@autopilot-agent/core 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/README.md +10 -4
  2. package/dist/experimental/index.js +159 -59
  3. package/dist/experimental/index.mjs +159 -59
  4. package/dist/failure.d.ts +3 -0
  5. package/dist/failure.js +1 -0
  6. package/dist/failure.mjs +1 -0
  7. package/dist/index.d.ts +30 -5
  8. package/dist/index.js +346 -214
  9. package/dist/index.mjs +346 -214
  10. package/dist/internal/agent-runtime.d.ts +87 -2
  11. package/dist/internal/kernel/model-sampler.d.ts +5 -0
  12. package/dist/internal/kernel/run-context.d.ts +6 -0
  13. package/dist/internal/kernel/session-images.d.ts +21 -0
  14. package/dist/internal/kernel/turn-usage.d.ts +14 -0
  15. package/dist/internal/lib/document-parser.js +2 -2
  16. package/dist/internal/lib/image-normalization.d.ts +16 -0
  17. package/dist/internal/lib/llm.d.ts +7 -1
  18. package/dist/internal/lib/llm.js +3 -3
  19. package/dist/internal/lib/pdf-processor.js +1 -1
  20. package/dist/internal/tools/builtins/browser-tool.d.ts +13 -0
  21. package/dist/internal/tools/builtins/open-preview-tool.d.ts +5 -1
  22. package/dist/internal/tools/builtins/read-output-budget.d.ts +5 -0
  23. package/dist/internal/tools/builtins/render-ui-tool.d.ts +11 -0
  24. package/dist/internal/tools/builtins/static-preview.d.ts +15 -0
  25. package/dist/internal/tools/builtins/thread-tools.d.ts +125 -0
  26. package/dist/internal/tools/builtins/vision-analyze-tool.d.ts +1 -0
  27. package/dist/internal/tools/mcp-images.d.ts +6 -0
  28. package/dist/internal/tools/mcp-runtime.d.ts +4 -0
  29. package/dist/internal/tools/permissions/command-policy.d.ts +2 -0
  30. package/dist/internal/tools/policy-engine.d.ts +1 -0
  31. package/dist/internal/tools/process-utils.d.ts +1 -0
  32. package/dist/internal/tools/thread-observation-display.d.ts +2 -0
  33. package/dist/internal/tools/types.d.ts +21 -0
  34. package/dist/internal/types/agent-message.d.ts +12 -2
  35. package/dist/internal/types/index.d.ts +1 -1
  36. package/dist/runtime/adapters/memory/memory-lease-store.d.ts +6 -0
  37. package/dist/runtime/adapters/memory/memory-session-store.d.ts +14 -0
  38. package/dist/runtime/adapters/memory/memory-thread-store.d.ts +24 -0
  39. package/dist/runtime/adapters/memory/memory-transcript-store.d.ts +9 -0
  40. package/dist/runtime/application/approval-service.d.ts +5 -0
  41. package/dist/runtime/application/input-inbox-service.d.ts +1 -1
  42. package/dist/runtime/application/runtime-facts.d.ts +54 -0
  43. package/dist/runtime/application/session-service.d.ts +9 -0
  44. package/dist/runtime/application/thread-delivery-service.d.ts +97 -0
  45. package/dist/runtime/application/thread-execution-host.d.ts +7 -0
  46. package/dist/runtime/application/thread-service.d.ts +1027 -0
  47. package/dist/runtime/application/thread-task.d.ts +11 -0
  48. package/dist/runtime/application/thread-tool-binding.d.ts +218 -0
  49. package/dist/runtime/application/turn/turn-capability-ceiling.d.ts +2 -0
  50. package/dist/runtime/application/turn/turn-compaction-coordinator.d.ts +2 -1
  51. package/dist/runtime/application/turn/turn-event-recorder.d.ts +1 -0
  52. package/dist/runtime/application/turn/turn-execution-view.d.ts +43 -0
  53. package/dist/runtime/application/turn/turn-recovery-service.d.ts +14 -0
  54. package/dist/runtime/application/turn-service.d.ts +28 -0
  55. package/dist/runtime/application/user-question-service.d.ts +1 -0
  56. package/dist/runtime/bootstrap/runtime-bootstrap-service.d.ts +2 -0
  57. package/dist/runtime/domain/frozen-run-config.d.ts +2 -0
  58. package/dist/runtime/domain/index.d.ts +16 -1
  59. package/dist/runtime/domain/input-inbox.d.ts +16 -0
  60. package/dist/runtime/domain/model-ref.d.ts +1 -1
  61. package/dist/runtime/domain/session-presentation.d.ts +9 -0
  62. package/dist/runtime/domain/thread-collaboration.d.ts +179 -0
  63. package/dist/runtime/domain/turn.d.ts +8 -0
  64. package/dist/runtime/ports/index.d.ts +6 -0
  65. package/dist/runtime/ports/lease-store.d.ts +4 -0
  66. package/dist/runtime/ports/session-image-store.d.ts +26 -0
  67. package/dist/runtime/ports/session-store.d.ts +16 -0
  68. package/dist/runtime/ports/thread-handoff.d.ts +14 -0
  69. package/dist/runtime/ports/thread-store.d.ts +15 -0
  70. package/dist/runtime/ports/transcript-store.d.ts +8 -0
  71. package/dist/runtime/protocol/browser-capability.d.ts +81 -0
  72. package/dist/runtime/protocol/browser-operation.d.ts +89 -0
  73. package/dist/runtime/protocol/chat-capability.d.ts +1 -0
  74. package/dist/runtime/protocol/error-code.d.ts +1 -1
  75. package/dist/runtime/protocol/frozen-run-config-view.d.ts +2 -1
  76. package/dist/runtime/protocol/index.d.ts +2 -1
  77. package/dist/runtime/protocol/recoverable-turn-view.d.ts +3 -0
  78. package/dist/runtime/protocol/run-config.d.ts +13 -0
  79. package/dist/runtime/protocol/threads-capability.d.ts +14 -0
  80. package/dist/runtime/protocol/web-capability.d.ts +5 -1
  81. package/dist/runtime/protocol/work-preview-capability.d.ts +1 -0
  82. package/dist/runtime/provider/anthropic-messages-adapter.d.ts +4 -2
  83. package/dist/runtime/provider/api-protocol.d.ts +16 -2
  84. package/dist/runtime/provider/compatibility-presets.d.ts +19 -0
  85. package/dist/runtime/provider/frozen-provider-config.d.ts +4 -1
  86. package/dist/runtime/provider/index.d.ts +4 -2
  87. package/dist/runtime/provider/model-capability-catalog.d.ts +7 -0
  88. package/dist/runtime/provider/model-sample-resolver.d.ts +3 -2
  89. package/dist/runtime/provider/openai-chat-completions-adapter.d.ts +5 -1
  90. package/dist/runtime/provider/openai-responses-adapter.d.ts +22 -0
  91. package/dist/runtime/provider/provider-failure-guidance.d.ts +4 -0
  92. package/dist/runtime/provider/provider-failure-normalization.d.ts +9 -0
  93. package/dist/runtime/public/agent-runtime.d.ts +5 -0
  94. package/dist/ui/catalog.d.ts +870 -0
  95. package/dist/ui/document.d.ts +580 -0
  96. package/dist/ui/index.d.ts +4 -0
  97. package/dist/ui/index.js +1 -0
  98. package/dist/ui/index.mjs +1 -0
  99. package/package.json +17 -3
@@ -0,0 +1,580 @@
1
+ import { z } from "zod";
2
+ import { type UiSpec } from "./catalog";
3
+ export declare const UI_DOCUMENT_SCHEMA_VERSION: 1;
4
+ export interface UiDocumentPayload {
5
+ title: string;
6
+ fallbackText: string;
7
+ spec: UiSpec;
8
+ }
9
+ export interface UiDocument extends UiDocumentPayload {
10
+ schemaVersion: typeof UI_DOCUMENT_SCHEMA_VERSION;
11
+ uiId: string;
12
+ }
13
+ export declare const uiDocumentInputSchema: z.ZodObject<{
14
+ title: z.ZodString;
15
+ fallbackText: z.ZodString;
16
+ spec: z.ZodObject<{
17
+ root: z.ZodString;
18
+ elements: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodObject<{
19
+ type: z.ZodLiteral<"Stack" | "Grid" | "Card" | "Text" | "Metric" | "Tabs" | "Disclosure" | "NumberInput" | "Slider" | "Select" | "DataTable" | "LineChart" | "BarChart" | "Button" | "ItemList" | "Timeline" | "Steps" | "ChoiceGroup" | "Flowchart">;
20
+ props: z.ZodObject<{
21
+ direction: z.ZodEnum<{
22
+ TB: "TB";
23
+ LR: "LR";
24
+ }>;
25
+ description: z.ZodString;
26
+ nodes: z.ZodArray<z.ZodObject<{
27
+ id: z.ZodString;
28
+ label: z.ZodString;
29
+ kind: z.ZodOptional<z.ZodEnum<{
30
+ process: "process";
31
+ decision: "decision";
32
+ terminal: "terminal";
33
+ }>>;
34
+ }, z.core.$strict>>;
35
+ edges: z.ZodArray<z.ZodObject<{
36
+ id: z.ZodString;
37
+ from: z.ZodString;
38
+ to: z.ZodString;
39
+ label: z.ZodOptional<z.ZodString>;
40
+ }, z.core.$strict>>;
41
+ }, z.core.$strict> | z.ZodObject<{
42
+ direction: z.ZodEnum<{
43
+ row: "row";
44
+ column: "column";
45
+ }>;
46
+ gap: z.ZodUnion<readonly [z.ZodLiteral<4>, z.ZodLiteral<8>, z.ZodLiteral<12>, z.ZodLiteral<16>]>;
47
+ }, z.core.$strict> | z.ZodObject<{
48
+ columns: z.ZodUnion<readonly [z.ZodLiteral<2>, z.ZodLiteral<3>, z.ZodLiteral<4>]>;
49
+ gap: z.ZodUnion<readonly [z.ZodLiteral<4>, z.ZodLiteral<8>, z.ZodLiteral<12>, z.ZodLiteral<16>]>;
50
+ }, z.core.$strict> | z.ZodObject<{
51
+ title: z.ZodOptional<z.ZodString>;
52
+ }, z.core.$strict> | z.ZodObject<{
53
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
54
+ $state: z.ZodString;
55
+ }, z.core.$strict>]>;
56
+ size: z.ZodEnum<{
57
+ md: "md";
58
+ xs: "xs";
59
+ sm: "sm";
60
+ lg: "lg";
61
+ }>;
62
+ tone: z.ZodEnum<{
63
+ error: "error";
64
+ ink: "ink";
65
+ muted: "muted";
66
+ accent: "accent";
67
+ }>;
68
+ }, z.core.$strict> | z.ZodObject<{
69
+ label: z.ZodString;
70
+ value: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
71
+ $state: z.ZodString;
72
+ }, z.core.$strict>, z.ZodDiscriminatedUnion<[z.ZodObject<{
73
+ $computed: z.ZodLiteral<"savingsGrowth">;
74
+ args: z.ZodObject<{
75
+ P: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
76
+ $state: z.ZodString;
77
+ }, z.core.$strict>]>;
78
+ C: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
79
+ $state: z.ZodString;
80
+ }, z.core.$strict>]>;
81
+ R: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
82
+ $state: z.ZodString;
83
+ }, z.core.$strict>]>;
84
+ Y: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
85
+ $state: z.ZodString;
86
+ }, z.core.$strict>]>;
87
+ select: z.ZodLiteral<"final">;
88
+ }, z.core.$strict>;
89
+ }, z.core.$strict>, z.ZodObject<{
90
+ $computed: z.ZodLiteral<"weightedAverage">;
91
+ args: z.ZodObject<{
92
+ pairs: z.ZodArray<z.ZodObject<{
93
+ value: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
94
+ $state: z.ZodString;
95
+ }, z.core.$strict>]>;
96
+ weight: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
97
+ $state: z.ZodString;
98
+ }, z.core.$strict>]>;
99
+ }, z.core.$strict>>;
100
+ }, z.core.$strict>;
101
+ }, z.core.$strict>, z.ZodObject<{
102
+ $computed: z.ZodLiteral<"sum">;
103
+ args: z.ZodObject<{
104
+ values: z.ZodArray<z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
105
+ $state: z.ZodString;
106
+ }, z.core.$strict>]>>;
107
+ }, z.core.$strict>;
108
+ }, z.core.$strict>], "$computed">]>;
109
+ unit: z.ZodOptional<z.ZodString>;
110
+ tone: z.ZodOptional<z.ZodEnum<{
111
+ error: "error";
112
+ ink: "ink";
113
+ accent: "accent";
114
+ }>>;
115
+ }, z.core.$strict> | z.ZodObject<{
116
+ items: z.ZodArray<z.ZodObject<{
117
+ key: z.ZodString;
118
+ label: z.ZodString;
119
+ }, z.core.$strict>>;
120
+ }, z.core.$strict> | z.ZodObject<{
121
+ summary: z.ZodString;
122
+ defaultOpen: z.ZodBoolean;
123
+ }, z.core.$strict> | z.ZodObject<{
124
+ label: z.ZodString;
125
+ statePath: z.ZodString;
126
+ min: z.ZodNumber;
127
+ max: z.ZodNumber;
128
+ step: z.ZodNumber;
129
+ suffix: z.ZodOptional<z.ZodString>;
130
+ }, z.core.$strict> | z.ZodObject<{
131
+ label: z.ZodString;
132
+ statePath: z.ZodString;
133
+ min: z.ZodNumber;
134
+ max: z.ZodNumber;
135
+ step: z.ZodNumber;
136
+ suffix: z.ZodOptional<z.ZodString>;
137
+ }, z.core.$strict> | z.ZodObject<{
138
+ label: z.ZodString;
139
+ statePath: z.ZodString;
140
+ options: z.ZodArray<z.ZodObject<{
141
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
142
+ label: z.ZodString;
143
+ }, z.core.$strict>>;
144
+ }, z.core.$strict> | z.ZodObject<{
145
+ columns: z.ZodArray<z.ZodObject<{
146
+ key: z.ZodString;
147
+ label: z.ZodString;
148
+ align: z.ZodOptional<z.ZodEnum<{
149
+ left: "left";
150
+ right: "right";
151
+ }>>;
152
+ }, z.core.$strict>>;
153
+ rows: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
154
+ caption: z.ZodOptional<z.ZodString>;
155
+ filterColumnKey: z.ZodOptional<z.ZodString>;
156
+ sortable: z.ZodOptional<z.ZodBoolean>;
157
+ }, z.core.$strict> | z.ZodObject<{
158
+ title: z.ZodOptional<z.ZodString>;
159
+ xLabel: z.ZodOptional<z.ZodString>;
160
+ yLabel: z.ZodOptional<z.ZodString>;
161
+ unit: z.ZodOptional<z.ZodString>;
162
+ series: z.ZodUnion<readonly [z.ZodArray<z.ZodObject<{
163
+ name: z.ZodString;
164
+ points: z.ZodArray<z.ZodObject<{
165
+ x: z.ZodNumber;
166
+ y: z.ZodUnion<readonly [z.ZodNumber, z.ZodNull]>;
167
+ }, z.core.$strict>>;
168
+ }, z.core.$strict>>, z.ZodObject<{
169
+ $computed: z.ZodLiteral<"savingsGrowth">;
170
+ args: z.ZodObject<{
171
+ P: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
172
+ $state: z.ZodString;
173
+ }, z.core.$strict>]>;
174
+ C: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
175
+ $state: z.ZodString;
176
+ }, z.core.$strict>]>;
177
+ R: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
178
+ $state: z.ZodString;
179
+ }, z.core.$strict>]>;
180
+ Y: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
181
+ $state: z.ZodString;
182
+ }, z.core.$strict>]>;
183
+ select: z.ZodLiteral<"series">;
184
+ }, z.core.$strict>;
185
+ }, z.core.$strict>]>;
186
+ yMin: z.ZodOptional<z.ZodNumber>;
187
+ yMax: z.ZodOptional<z.ZodNumber>;
188
+ }, z.core.$strict> | z.ZodObject<{
189
+ title: z.ZodOptional<z.ZodString>;
190
+ xLabel: z.ZodOptional<z.ZodString>;
191
+ yLabel: z.ZodOptional<z.ZodString>;
192
+ unit: z.ZodOptional<z.ZodString>;
193
+ series: z.ZodUnion<readonly [z.ZodArray<z.ZodObject<{
194
+ name: z.ZodString;
195
+ points: z.ZodArray<z.ZodObject<{
196
+ x: z.ZodNumber;
197
+ y: z.ZodUnion<readonly [z.ZodNumber, z.ZodNull]>;
198
+ }, z.core.$strict>>;
199
+ }, z.core.$strict>>, z.ZodObject<{
200
+ $computed: z.ZodLiteral<"savingsGrowth">;
201
+ args: z.ZodObject<{
202
+ P: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
203
+ $state: z.ZodString;
204
+ }, z.core.$strict>]>;
205
+ C: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
206
+ $state: z.ZodString;
207
+ }, z.core.$strict>]>;
208
+ R: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
209
+ $state: z.ZodString;
210
+ }, z.core.$strict>]>;
211
+ Y: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
212
+ $state: z.ZodString;
213
+ }, z.core.$strict>]>;
214
+ select: z.ZodLiteral<"series">;
215
+ }, z.core.$strict>;
216
+ }, z.core.$strict>]>;
217
+ yMin: z.ZodOptional<z.ZodNumber>;
218
+ yMax: z.ZodOptional<z.ZodNumber>;
219
+ }, z.core.$strict> | z.ZodDiscriminatedUnion<[z.ZodObject<{
220
+ action: z.ZodLiteral<"continue_chat">;
221
+ fields: z.ZodArray<z.ZodObject<{
222
+ label: z.ZodString;
223
+ statePath: z.ZodString;
224
+ }, z.core.$strict>>;
225
+ text: z.ZodString;
226
+ }, z.core.$strict>, z.ZodObject<{
227
+ action: z.ZodLiteral<"reset_state">;
228
+ text: z.ZodString;
229
+ }, z.core.$strict>], "action"> | z.ZodObject<{
230
+ items: z.ZodArray<z.ZodObject<{
231
+ title: z.ZodString;
232
+ description: z.ZodOptional<z.ZodString>;
233
+ }, z.core.$strict>>;
234
+ ordered: z.ZodOptional<z.ZodBoolean>;
235
+ }, z.core.$strict> | z.ZodObject<{
236
+ items: z.ZodArray<z.ZodObject<{
237
+ label: z.ZodString;
238
+ title: z.ZodString;
239
+ description: z.ZodOptional<z.ZodString>;
240
+ }, z.core.$strict>>;
241
+ }, z.core.$strict> | z.ZodObject<{
242
+ items: z.ZodArray<z.ZodObject<{
243
+ title: z.ZodString;
244
+ description: z.ZodOptional<z.ZodString>;
245
+ }, z.core.$strict>>;
246
+ statePath: z.ZodString;
247
+ }, z.core.$strict> | z.ZodObject<{
248
+ label: z.ZodString;
249
+ statePath: z.ZodString;
250
+ options: z.ZodArray<z.ZodObject<{
251
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
252
+ label: z.ZodString;
253
+ description: z.ZodOptional<z.ZodString>;
254
+ }, z.core.$strict>>;
255
+ }, z.core.$strict>;
256
+ visible: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodUnion<readonly [z.ZodObject<{
257
+ $state: z.ZodString;
258
+ not: z.ZodOptional<z.ZodLiteral<true>>;
259
+ }, z.core.$strict>, z.ZodObject<{
260
+ $state: z.ZodString;
261
+ eq: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodObject<{
262
+ $state: z.ZodString;
263
+ }, z.core.$strict>]>;
264
+ not: z.ZodOptional<z.ZodLiteral<true>>;
265
+ }, z.core.$strict>, z.ZodObject<{
266
+ $state: z.ZodString;
267
+ neq: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodObject<{
268
+ $state: z.ZodString;
269
+ }, z.core.$strict>]>;
270
+ not: z.ZodOptional<z.ZodLiteral<true>>;
271
+ }, z.core.$strict>, z.ZodObject<{
272
+ $state: z.ZodString;
273
+ gt: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
274
+ $state: z.ZodString;
275
+ }, z.core.$strict>]>;
276
+ not: z.ZodOptional<z.ZodLiteral<true>>;
277
+ }, z.core.$strict>, z.ZodObject<{
278
+ $state: z.ZodString;
279
+ gte: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
280
+ $state: z.ZodString;
281
+ }, z.core.$strict>]>;
282
+ not: z.ZodOptional<z.ZodLiteral<true>>;
283
+ }, z.core.$strict>, z.ZodObject<{
284
+ $state: z.ZodString;
285
+ lt: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
286
+ $state: z.ZodString;
287
+ }, z.core.$strict>]>;
288
+ not: z.ZodOptional<z.ZodLiteral<true>>;
289
+ }, z.core.$strict>, z.ZodObject<{
290
+ $state: z.ZodString;
291
+ lte: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
292
+ $state: z.ZodString;
293
+ }, z.core.$strict>]>;
294
+ not: z.ZodOptional<z.ZodLiteral<true>>;
295
+ }, z.core.$strict>]>]>>;
296
+ }, z.core.$strict>, ...z.ZodObject<{
297
+ type: z.ZodLiteral<"Stack" | "Grid" | "Card" | "Text" | "Metric" | "Tabs" | "Disclosure" | "NumberInput" | "Slider" | "Select" | "DataTable" | "LineChart" | "BarChart" | "Button" | "ItemList" | "Timeline" | "Steps" | "ChoiceGroup" | "Flowchart">;
298
+ props: z.ZodObject<{
299
+ direction: z.ZodEnum<{
300
+ TB: "TB";
301
+ LR: "LR";
302
+ }>;
303
+ description: z.ZodString;
304
+ nodes: z.ZodArray<z.ZodObject<{
305
+ id: z.ZodString;
306
+ label: z.ZodString;
307
+ kind: z.ZodOptional<z.ZodEnum<{
308
+ process: "process";
309
+ decision: "decision";
310
+ terminal: "terminal";
311
+ }>>;
312
+ }, z.core.$strict>>;
313
+ edges: z.ZodArray<z.ZodObject<{
314
+ id: z.ZodString;
315
+ from: z.ZodString;
316
+ to: z.ZodString;
317
+ label: z.ZodOptional<z.ZodString>;
318
+ }, z.core.$strict>>;
319
+ }, z.core.$strict> | z.ZodObject<{
320
+ direction: z.ZodEnum<{
321
+ row: "row";
322
+ column: "column";
323
+ }>;
324
+ gap: z.ZodUnion<readonly [z.ZodLiteral<4>, z.ZodLiteral<8>, z.ZodLiteral<12>, z.ZodLiteral<16>]>;
325
+ }, z.core.$strict> | z.ZodObject<{
326
+ columns: z.ZodUnion<readonly [z.ZodLiteral<2>, z.ZodLiteral<3>, z.ZodLiteral<4>]>;
327
+ gap: z.ZodUnion<readonly [z.ZodLiteral<4>, z.ZodLiteral<8>, z.ZodLiteral<12>, z.ZodLiteral<16>]>;
328
+ }, z.core.$strict> | z.ZodObject<{
329
+ title: z.ZodOptional<z.ZodString>;
330
+ }, z.core.$strict> | z.ZodObject<{
331
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
332
+ $state: z.ZodString;
333
+ }, z.core.$strict>]>;
334
+ size: z.ZodEnum<{
335
+ md: "md";
336
+ xs: "xs";
337
+ sm: "sm";
338
+ lg: "lg";
339
+ }>;
340
+ tone: z.ZodEnum<{
341
+ error: "error";
342
+ ink: "ink";
343
+ muted: "muted";
344
+ accent: "accent";
345
+ }>;
346
+ }, z.core.$strict> | z.ZodObject<{
347
+ label: z.ZodString;
348
+ value: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
349
+ $state: z.ZodString;
350
+ }, z.core.$strict>, z.ZodDiscriminatedUnion<[z.ZodObject<{
351
+ $computed: z.ZodLiteral<"savingsGrowth">;
352
+ args: z.ZodObject<{
353
+ P: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
354
+ $state: z.ZodString;
355
+ }, z.core.$strict>]>;
356
+ C: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
357
+ $state: z.ZodString;
358
+ }, z.core.$strict>]>;
359
+ R: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
360
+ $state: z.ZodString;
361
+ }, z.core.$strict>]>;
362
+ Y: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
363
+ $state: z.ZodString;
364
+ }, z.core.$strict>]>;
365
+ select: z.ZodLiteral<"final">;
366
+ }, z.core.$strict>;
367
+ }, z.core.$strict>, z.ZodObject<{
368
+ $computed: z.ZodLiteral<"weightedAverage">;
369
+ args: z.ZodObject<{
370
+ pairs: z.ZodArray<z.ZodObject<{
371
+ value: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
372
+ $state: z.ZodString;
373
+ }, z.core.$strict>]>;
374
+ weight: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
375
+ $state: z.ZodString;
376
+ }, z.core.$strict>]>;
377
+ }, z.core.$strict>>;
378
+ }, z.core.$strict>;
379
+ }, z.core.$strict>, z.ZodObject<{
380
+ $computed: z.ZodLiteral<"sum">;
381
+ args: z.ZodObject<{
382
+ values: z.ZodArray<z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
383
+ $state: z.ZodString;
384
+ }, z.core.$strict>]>>;
385
+ }, z.core.$strict>;
386
+ }, z.core.$strict>], "$computed">]>;
387
+ unit: z.ZodOptional<z.ZodString>;
388
+ tone: z.ZodOptional<z.ZodEnum<{
389
+ error: "error";
390
+ ink: "ink";
391
+ accent: "accent";
392
+ }>>;
393
+ }, z.core.$strict> | z.ZodObject<{
394
+ items: z.ZodArray<z.ZodObject<{
395
+ key: z.ZodString;
396
+ label: z.ZodString;
397
+ }, z.core.$strict>>;
398
+ }, z.core.$strict> | z.ZodObject<{
399
+ summary: z.ZodString;
400
+ defaultOpen: z.ZodBoolean;
401
+ }, z.core.$strict> | z.ZodObject<{
402
+ label: z.ZodString;
403
+ statePath: z.ZodString;
404
+ min: z.ZodNumber;
405
+ max: z.ZodNumber;
406
+ step: z.ZodNumber;
407
+ suffix: z.ZodOptional<z.ZodString>;
408
+ }, z.core.$strict> | z.ZodObject<{
409
+ label: z.ZodString;
410
+ statePath: z.ZodString;
411
+ min: z.ZodNumber;
412
+ max: z.ZodNumber;
413
+ step: z.ZodNumber;
414
+ suffix: z.ZodOptional<z.ZodString>;
415
+ }, z.core.$strict> | z.ZodObject<{
416
+ label: z.ZodString;
417
+ statePath: z.ZodString;
418
+ options: z.ZodArray<z.ZodObject<{
419
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
420
+ label: z.ZodString;
421
+ }, z.core.$strict>>;
422
+ }, z.core.$strict> | z.ZodObject<{
423
+ columns: z.ZodArray<z.ZodObject<{
424
+ key: z.ZodString;
425
+ label: z.ZodString;
426
+ align: z.ZodOptional<z.ZodEnum<{
427
+ left: "left";
428
+ right: "right";
429
+ }>>;
430
+ }, z.core.$strict>>;
431
+ rows: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
432
+ caption: z.ZodOptional<z.ZodString>;
433
+ filterColumnKey: z.ZodOptional<z.ZodString>;
434
+ sortable: z.ZodOptional<z.ZodBoolean>;
435
+ }, z.core.$strict> | z.ZodObject<{
436
+ title: z.ZodOptional<z.ZodString>;
437
+ xLabel: z.ZodOptional<z.ZodString>;
438
+ yLabel: z.ZodOptional<z.ZodString>;
439
+ unit: z.ZodOptional<z.ZodString>;
440
+ series: z.ZodUnion<readonly [z.ZodArray<z.ZodObject<{
441
+ name: z.ZodString;
442
+ points: z.ZodArray<z.ZodObject<{
443
+ x: z.ZodNumber;
444
+ y: z.ZodUnion<readonly [z.ZodNumber, z.ZodNull]>;
445
+ }, z.core.$strict>>;
446
+ }, z.core.$strict>>, z.ZodObject<{
447
+ $computed: z.ZodLiteral<"savingsGrowth">;
448
+ args: z.ZodObject<{
449
+ P: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
450
+ $state: z.ZodString;
451
+ }, z.core.$strict>]>;
452
+ C: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
453
+ $state: z.ZodString;
454
+ }, z.core.$strict>]>;
455
+ R: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
456
+ $state: z.ZodString;
457
+ }, z.core.$strict>]>;
458
+ Y: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
459
+ $state: z.ZodString;
460
+ }, z.core.$strict>]>;
461
+ select: z.ZodLiteral<"series">;
462
+ }, z.core.$strict>;
463
+ }, z.core.$strict>]>;
464
+ yMin: z.ZodOptional<z.ZodNumber>;
465
+ yMax: z.ZodOptional<z.ZodNumber>;
466
+ }, z.core.$strict> | z.ZodObject<{
467
+ title: z.ZodOptional<z.ZodString>;
468
+ xLabel: z.ZodOptional<z.ZodString>;
469
+ yLabel: z.ZodOptional<z.ZodString>;
470
+ unit: z.ZodOptional<z.ZodString>;
471
+ series: z.ZodUnion<readonly [z.ZodArray<z.ZodObject<{
472
+ name: z.ZodString;
473
+ points: z.ZodArray<z.ZodObject<{
474
+ x: z.ZodNumber;
475
+ y: z.ZodUnion<readonly [z.ZodNumber, z.ZodNull]>;
476
+ }, z.core.$strict>>;
477
+ }, z.core.$strict>>, z.ZodObject<{
478
+ $computed: z.ZodLiteral<"savingsGrowth">;
479
+ args: z.ZodObject<{
480
+ P: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
481
+ $state: z.ZodString;
482
+ }, z.core.$strict>]>;
483
+ C: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
484
+ $state: z.ZodString;
485
+ }, z.core.$strict>]>;
486
+ R: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
487
+ $state: z.ZodString;
488
+ }, z.core.$strict>]>;
489
+ Y: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
490
+ $state: z.ZodString;
491
+ }, z.core.$strict>]>;
492
+ select: z.ZodLiteral<"series">;
493
+ }, z.core.$strict>;
494
+ }, z.core.$strict>]>;
495
+ yMin: z.ZodOptional<z.ZodNumber>;
496
+ yMax: z.ZodOptional<z.ZodNumber>;
497
+ }, z.core.$strict> | z.ZodDiscriminatedUnion<[z.ZodObject<{
498
+ action: z.ZodLiteral<"continue_chat">;
499
+ fields: z.ZodArray<z.ZodObject<{
500
+ label: z.ZodString;
501
+ statePath: z.ZodString;
502
+ }, z.core.$strict>>;
503
+ text: z.ZodString;
504
+ }, z.core.$strict>, z.ZodObject<{
505
+ action: z.ZodLiteral<"reset_state">;
506
+ text: z.ZodString;
507
+ }, z.core.$strict>], "action"> | z.ZodObject<{
508
+ items: z.ZodArray<z.ZodObject<{
509
+ title: z.ZodString;
510
+ description: z.ZodOptional<z.ZodString>;
511
+ }, z.core.$strict>>;
512
+ ordered: z.ZodOptional<z.ZodBoolean>;
513
+ }, z.core.$strict> | z.ZodObject<{
514
+ items: z.ZodArray<z.ZodObject<{
515
+ label: z.ZodString;
516
+ title: z.ZodString;
517
+ description: z.ZodOptional<z.ZodString>;
518
+ }, z.core.$strict>>;
519
+ }, z.core.$strict> | z.ZodObject<{
520
+ items: z.ZodArray<z.ZodObject<{
521
+ title: z.ZodString;
522
+ description: z.ZodOptional<z.ZodString>;
523
+ }, z.core.$strict>>;
524
+ statePath: z.ZodString;
525
+ }, z.core.$strict> | z.ZodObject<{
526
+ label: z.ZodString;
527
+ statePath: z.ZodString;
528
+ options: z.ZodArray<z.ZodObject<{
529
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
530
+ label: z.ZodString;
531
+ description: z.ZodOptional<z.ZodString>;
532
+ }, z.core.$strict>>;
533
+ }, z.core.$strict>;
534
+ visible: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodUnion<readonly [z.ZodObject<{
535
+ $state: z.ZodString;
536
+ not: z.ZodOptional<z.ZodLiteral<true>>;
537
+ }, z.core.$strict>, z.ZodObject<{
538
+ $state: z.ZodString;
539
+ eq: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodObject<{
540
+ $state: z.ZodString;
541
+ }, z.core.$strict>]>;
542
+ not: z.ZodOptional<z.ZodLiteral<true>>;
543
+ }, z.core.$strict>, z.ZodObject<{
544
+ $state: z.ZodString;
545
+ neq: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodObject<{
546
+ $state: z.ZodString;
547
+ }, z.core.$strict>]>;
548
+ not: z.ZodOptional<z.ZodLiteral<true>>;
549
+ }, z.core.$strict>, z.ZodObject<{
550
+ $state: z.ZodString;
551
+ gt: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
552
+ $state: z.ZodString;
553
+ }, z.core.$strict>]>;
554
+ not: z.ZodOptional<z.ZodLiteral<true>>;
555
+ }, z.core.$strict>, z.ZodObject<{
556
+ $state: z.ZodString;
557
+ gte: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
558
+ $state: z.ZodString;
559
+ }, z.core.$strict>]>;
560
+ not: z.ZodOptional<z.ZodLiteral<true>>;
561
+ }, z.core.$strict>, z.ZodObject<{
562
+ $state: z.ZodString;
563
+ lt: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
564
+ $state: z.ZodString;
565
+ }, z.core.$strict>]>;
566
+ not: z.ZodOptional<z.ZodLiteral<true>>;
567
+ }, z.core.$strict>, z.ZodObject<{
568
+ $state: z.ZodString;
569
+ lte: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
570
+ $state: z.ZodString;
571
+ }, z.core.$strict>]>;
572
+ not: z.ZodOptional<z.ZodLiteral<true>>;
573
+ }, z.core.$strict>]>]>>;
574
+ }, z.core.$strict>[]]>>;
575
+ state: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
576
+ }, z.core.$strict>;
577
+ }, z.core.$strict>;
578
+ export declare function validateUiDocumentInput(value: unknown): UiDocumentPayload;
579
+ export declare function createUiDocument(payload: UiDocumentPayload, uiId: string): UiDocument;
580
+ export declare function projectUiDocument(value: unknown): UiDocument;
@@ -0,0 +1,4 @@
1
+ export { UI_COMPONENT_NAMES, UI_COMPONENT_SCHEMAS, UI_COMPUTED_FUNCTION_NAMES, UI_COMPUTED_FUNCTIONS } from "./catalog";
2
+ export { UI_DOCUMENT_SCHEMA_VERSION, createUiDocument, projectUiDocument, uiDocumentInputSchema, validateUiDocumentInput } from "./document";
3
+ export type { UiComponentName, UiElement, UiScalar, UiSpec, UiState } from "./catalog";
4
+ export type { UiDocument, UiDocumentPayload } from "./document";
@@ -0,0 +1 @@
1
+ "use strict";var R=Object.defineProperty;var st=Object.getOwnPropertyDescriptor;var at=Object.getOwnPropertyNames;var ct=Object.prototype.hasOwnProperty;var lt=(e,r)=>{for(var o in r)R(e,o,{get:r[o],enumerable:!0})},ut=(e,r,o,c)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of at(r))!ct.call(e,a)&&a!==o&&R(e,a,{get:()=>r[a],enumerable:!(c=st(r,a))||c.enumerable});return e};var mt=e=>ut(R({},"__esModule",{value:!0}),e);var Gt={};lt(Gt,{UI_COMPONENT_NAMES:()=>v,UI_COMPONENT_SCHEMAS:()=>D,UI_COMPUTED_FUNCTIONS:()=>ot,UI_COMPUTED_FUNCTION_NAMES:()=>tt,UI_DOCUMENT_SCHEMA_VERSION:()=>A,createUiDocument:()=>Y,projectUiDocument:()=>X,uiDocumentInputSchema:()=>K,validateUiDocumentInput:()=>it});module.exports=mt(Gt);var t=require("zod"),I=64*1024,pt=128,ft=12,gt=24,q=16*1024,Q=16,F=12,N=200,E=Object.freeze({P:{min:0,max:1e12,integer:!1},C:{min:0,max:1e9,integer:!1},R:{min:0,max:.3,integer:!1},Y:{min:1,max:60,integer:!0}}),v=["Stack","Grid","Card","Text","Metric","Tabs","Disclosure","NumberInput","Slider","Select","DataTable","LineChart","BarChart","Button","ItemList","Timeline","Steps","ChoiceGroup","Flowchart"],tt=["savingsGrowth","weightedAverage","sum"],f=t.z.number().finite(),wt=t.z.string().max(500),L=t.z.union([t.z.string().max(200),f,t.z.boolean()]),ht=t.z.union([t.z.string().max(200),f,t.z.boolean()]),x=t.z.object({$state:t.z.string().min(2)}).strict(),O=t.z.union([f,x]),et=t.z.object({P:O,C:O,R:O,Y:O,select:t.z.enum(["final","series"])}).strict(),bt=t.z.discriminatedUnion("$computed",[t.z.object({$computed:t.z.literal("savingsGrowth"),args:et.extend({select:t.z.literal("final")})}).strict(),t.z.object({$computed:t.z.literal("weightedAverage"),args:t.z.object({pairs:t.z.array(t.z.object({value:O,weight:O}).strict()).min(1).max(N)}).strict()}).strict(),t.z.object({$computed:t.z.literal("sum"),args:t.z.object({values:t.z.array(O).max(N)}).strict()}).strict()]),H=t.z.object({$computed:t.z.literal("savingsGrowth"),args:et.extend({select:t.z.literal("series")})}).strict(),dt=t.z.union([wt,x]),yt=t.z.union([f,x,bt]),W=t.z.union([t.z.string(),f,t.z.boolean()]),U=t.z.literal(!0).optional(),Et=t.z.union([t.z.object({$state:t.z.string().min(2),not:U}).strict(),t.z.object({$state:t.z.string().min(2),eq:t.z.union([W,x]),not:U}).strict(),t.z.object({$state:t.z.string().min(2),neq:t.z.union([W,x]),not:U}).strict(),t.z.object({$state:t.z.string().min(2),gt:t.z.union([f,x]),not:U}).strict(),t.z.object({$state:t.z.string().min(2),gte:t.z.union([f,x]),not:U}).strict(),t.z.object({$state:t.z.string().min(2),lt:t.z.union([f,x]),not:U}).strict(),t.z.object({$state:t.z.string().min(2),lte:t.z.union([f,x]),not:U}).strict()]),St=t.z.union([t.z.boolean(),Et]),xt=t.z.object({x:f,y:t.z.union([f,t.z.null()])}).strict(),T=t.z.array(t.z.object({name:t.z.string().max(40),points:t.z.array(xt).max(N)}).strict()).min(1).max(4),Ut=t.z.union([t.z.string().max(120),f]),Ot=t.z.object({key:t.z.string().regex(/^[a-z0-9_]{1,32}$/),label:t.z.string().max(40),align:t.z.enum(["left","right"]).optional()}).strict(),Z=t.z.object({title:t.z.string().min(1).max(80),description:t.z.string().max(300).optional()}).strict(),jt=t.z.object({label:t.z.string().max(40),title:t.z.string().min(1).max(80),description:t.z.string().max(300).optional()}).strict(),Nt=t.z.object({value:L,label:t.z.string().max(40),description:t.z.string().max(300).optional()}).strict(),_=t.z.string().regex(/^[a-zA-Z0-9_-]{1,40}$/),D={Flowchart:t.z.object({direction:t.z.enum(["TB","LR"]),description:t.z.string().min(1).max(500),nodes:t.z.array(t.z.object({id:_,label:t.z.string().min(1).max(40),kind:t.z.enum(["process","decision","terminal"]).optional()}).strict()).min(1).max(24),edges:t.z.array(t.z.object({id:_,from:_,to:_,label:t.z.string().max(24).optional()}).strict()).max(48)}).strict(),Stack:t.z.object({direction:t.z.enum(["column","row"]),gap:t.z.union([t.z.literal(4),t.z.literal(8),t.z.literal(12),t.z.literal(16)])}).strict(),Grid:t.z.object({columns:t.z.union([t.z.literal(2),t.z.literal(3),t.z.literal(4)]),gap:t.z.union([t.z.literal(4),t.z.literal(8),t.z.literal(12),t.z.literal(16)])}).strict(),Card:t.z.object({title:t.z.string().max(80).optional()}).strict(),Text:t.z.object({value:dt,size:t.z.enum(["xs","sm","md","lg"]),tone:t.z.enum(["ink","muted","accent","error"])}).strict(),Metric:t.z.object({label:t.z.string().max(40),value:yt,unit:t.z.string().max(10).optional(),tone:t.z.enum(["ink","accent","error"]).optional()}).strict(),Tabs:t.z.object({items:t.z.array(t.z.object({key:t.z.string().regex(/^[a-z0-9_]{1,32}$/),label:t.z.string().max(40)}).strict()).min(2).max(6)}).strict(),Disclosure:t.z.object({summary:t.z.string().max(80),defaultOpen:t.z.boolean()}).strict(),NumberInput:t.z.object({label:t.z.string().max(40),statePath:t.z.string().min(1),min:f,max:f,step:f,suffix:t.z.string().max(10).optional()}).strict(),Slider:t.z.object({label:t.z.string().max(40),statePath:t.z.string().min(1),min:f,max:f,step:f,suffix:t.z.string().max(10).optional()}).strict(),Select:t.z.object({label:t.z.string().max(40),statePath:t.z.string().min(1),options:t.z.array(t.z.object({value:ht,label:t.z.string().max(40)}).strict()).min(2).max(12)}).strict(),DataTable:t.z.object({columns:t.z.array(Ot).min(1).max(8),rows:t.z.array(t.z.record(t.z.string(),Ut)).max(100),caption:t.z.string().max(120).optional(),filterColumnKey:t.z.string().regex(/^[a-z0-9_]{1,32}$/).optional(),sortable:t.z.boolean().optional()}).strict(),LineChart:t.z.object({title:t.z.string().max(80).optional(),xLabel:t.z.string().max(40).optional(),yLabel:t.z.string().max(40).optional(),unit:t.z.string().max(10).optional(),series:t.z.union([T,H]),yMin:f.optional(),yMax:f.optional()}).strict(),BarChart:t.z.object({title:t.z.string().max(80).optional(),xLabel:t.z.string().max(40).optional(),yLabel:t.z.string().max(40).optional(),unit:t.z.string().max(10).optional(),series:t.z.union([T,H]),yMin:f.optional(),yMax:f.optional()}).strict(),Button:t.z.discriminatedUnion("action",[t.z.object({action:t.z.literal("continue_chat"),fields:t.z.array(t.z.object({label:t.z.string().max(40),statePath:t.z.string().min(1)}).strict()).max(6),text:t.z.string().max(40)}).strict(),t.z.object({action:t.z.literal("reset_state"),text:t.z.string().max(40)}).strict()]),ItemList:t.z.object({items:t.z.array(Z).min(1).max(20),ordered:t.z.boolean().optional()}).strict(),Timeline:t.z.object({items:t.z.array(jt).min(1).max(20)}).strict(),Steps:t.z.object({items:t.z.array(Z).min(2).max(8),statePath:t.z.string().min(1)}).strict(),ChoiceGroup:t.z.object({label:t.z.string().max(40),statePath:t.z.string().min(1),options:t.z.array(Nt).min(2).max(8)}).strict()};function kt(e){let r={type:t.z.literal(e),props:D[e],visible:St.optional()};return e==="Stack"||e==="Grid"||e==="Card"?t.z.object({...r,children:t.z.array(t.z.string()).max(Q).optional()}).strict():e==="Tabs"?t.z.object({...r,slots:t.z.object({items:t.z.array(t.z.string()).max(F).optional()}).strict().optional()}).strict():e==="Disclosure"?t.z.object({...r,slots:t.z.object({content:t.z.array(t.z.string()).max(F).optional()}).strict().optional()}).strict():e==="Button"?t.z.object({...r,on:t.z.object({press:t.z.object({action:t.z.enum(["continue_chat","reset_state"])}).strict()}).strict()}).strict():t.z.object(r).strict()}var Ct=v.map(function(r){return kt(r)}),It=t.z.union(Ct),z=t.z.object({root:t.z.string().min(1),elements:t.z.record(t.z.string(),It),state:t.z.record(t.z.string(),L).optional()}).strict();function h(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let r=Object.getPrototypeOf(e);return r===Object.prototype||r===null}function C(e,r,o=new Set,c=0){if(c>32)throw new Error("JSON \u6DF1\u5EA6\u8D85\u9650");if(e===null)return 4;if(typeof e=="boolean")return e?4:5;if(typeof e=="number"){if(!Number.isFinite(e))throw new Error("JSON \u6570\u5B57\u5FC5\u987B\u6709\u9650");return new TextEncoder().encode(JSON.stringify(e)).byteLength}if(typeof e=="string")return new TextEncoder().encode(JSON.stringify(e)).byteLength;if(typeof e!="object")throw new Error("\u53EA\u63A5\u53D7 JSON \u6570\u636E");if(o.has(e))throw new Error("JSON \u4E0D\u5F97\u5FAA\u73AF\u5F15\u7528");o.add(e);let a=2;if(Array.isArray(e)){if(Object.getOwnPropertySymbols(e).length||Object.getOwnPropertyNames(e).length!==e.length+1)throw new Error("\u6570\u7EC4\u5FC5\u987B\u662F\u7A20\u5BC6 JSON \u6570\u7EC4");for(let n=0;n<e.length;n++){let s=Object.getOwnPropertyDescriptor(e,String(n));if(!s||!s.enumerable||!("value"in s))throw new Error("\u6570\u7EC4\u6210\u5458\u4E0D\u5408\u6CD5");if(a+=(n>0?1:0)+C(s.value,r,o,c+1),a>r)throw new Error("JSON \u5B57\u8282\u6570\u8D85\u9650")}}else{if(!h(e)||Object.getOwnPropertySymbols(e).length)throw new Error("\u5BF9\u8C61\u5FC5\u987B\u662F\u666E\u901A JSON \u5BF9\u8C61");let n=Object.getOwnPropertyNames(e);if(n.length!==Object.keys(e).length)throw new Error("\u5BF9\u8C61\u4E0D\u5F97\u5305\u542B\u975E\u679A\u4E3E\u5B57\u6BB5");for(let s=0;s<n.length;s++){let i=n[s];if(i==="__proto__"||i==="prototype"||i==="constructor")throw new Error("JSON \u5305\u542B\u5371\u9669\u952E");let l=Object.getOwnPropertyDescriptor(e,i);if(!l||!("value"in l))throw new Error("\u5BF9\u8C61\u4E0D\u5F97\u5305\u542B\u8BBF\u95EE\u5668");let u=JSON.stringify(i);if(a+=(s>0?1:0)+new TextEncoder().encode(u).byteLength+1,a+=C(l.value,r,o,c+1),a>r)throw new Error("JSON \u5B57\u8282\u6570\u8D85\u9650")}}if(o.delete(e),a>r)throw new Error("JSON \u5B57\u8282\u6570\u8D85\u9650");return a}function rt(e){if(!e.startsWith("/")||e==="/"||e.slice(1).includes("/"))throw new Error("state \u5F15\u7528\u5FC5\u987B\u6307\u5411\u9876\u5C42\u952E");let r=e.slice(1);if(/~(?:[^01]|$)/.test(r))throw new Error("state \u5F15\u7528\u7684 JSON Pointer \u7F16\u7801\u65E0\u6548");return r.replace(/~1/g,"/").replace(/~0/g,"~")}function k(e,r){if(!h(e)||Object.keys(e).length!==1||typeof e.$state!="string")throw new Error("state \u5F15\u7528\u4E0D\u5408\u6CD5");let o=rt(e.$state);if(!Object.prototype.hasOwnProperty.call(r,o))throw new Error("state \u5F15\u7528\u672A\u58F0\u660E");return{key:o,value:r[o]}}function J(e,r,o,c,a,n=!1){if(typeof r!="number"||r<c||r>a||n&&!Number.isInteger(r))throw new Error("\u8BA1\u7B97\u53C2\u6570\u8D85\u51FA\u8303\u56F4");for(let s of o.get(e)??[])if(s.kind==="range"){if(s.integer&&!Number.isInteger(r))throw new Error("\u6B65\u9AA4\u72B6\u6001\u5FC5\u987B\u4E3A\u6574\u6570");if(s.min<c||s.max>a||n&&(!Number.isInteger(s.min)||!Number.isInteger(s.max)||!Number.isInteger(s.step)))throw new Error("\u8F93\u5165\u63A7\u4EF6\u8303\u56F4\u4E0E\u8BA1\u7B97\u53C2\u6570\u4E0D\u5339\u914D")}else if(s.values.some(function(l){return typeof l!="number"||l<c||l>a||n&&!Number.isInteger(l)}))throw new Error("Select \u9009\u9879\u4E0E\u8BA1\u7B97\u53C2\u6570\u4E0D\u5339\u914D")}function $(e,r,o){if(typeof e=="number"&&Number.isFinite(e)&&e>=0)return e;let c=k(e,r);return J(c.key,c.value,o,0,Number.MAX_VALUE),c.value}function P(e,r,o,c){let a=E[r];if(typeof e=="number"){if(!Number.isFinite(e)||e<a.min||e>a.max||a.integer&&!Number.isInteger(e))throw new Error("savingsGrowth \u53C2\u6570\u8D85\u51FA\u8303\u56F4");return e}let n=k(e,o);return J(n.key,n.value,c,a.min,a.max,a.integer),n.value}function At(e,r,o,c){if(Object.keys(e).some(function(i){return i!=="$computed"&&i!=="args"}))throw new Error("computed \u8868\u8FBE\u5F0F\u5B57\u6BB5\u4E0D\u5408\u6CD5");let a=e.$computed,n=e.args;if(!h(n))throw new Error("computed args \u5FC5\u987B\u662F\u5BF9\u8C61");if(a==="savingsGrowth"){let s=["P","C","R","Y","select"];if(Object.keys(n).length!==s.length||s.some(function(u){return!Object.prototype.hasOwnProperty.call(n,u)}))throw new Error("savingsGrowth \u53C2\u6570\u4E0D\u5408\u6CD5");let i=n.select;if(i!=="final"&&i!=="series")throw new Error("savingsGrowth selector \u4E0D\u5408\u6CD5");if(i==="final"&&r!=="number"||i==="series"&&r!=="series")throw new Error("savingsGrowth selector \u4E0E\u76EE\u6807 prop \u7C7B\u578B\u4E0D\u5339\u914D");P(n.P,"P",o,c),P(n.C,"C",o,c),P(n.R,"R",o,c),P(n.Y,"Y",o,c);return}if(r!=="number")throw new Error("computed \u51FD\u6570\u7ED3\u679C\u7C7B\u578B\u4E0E\u76EE\u6807 prop \u4E0D\u5339\u914D");if(a==="sum"){if(Object.keys(n).length!==1||!Array.isArray(n.values)||n.values.length>N)throw new Error("sum \u53C2\u6570\u4E0D\u5408\u6CD5");for(let s of n.values)$(s,o,c);return}if(a==="weightedAverage"){if(Object.keys(n).length!==1||!Array.isArray(n.pairs)||n.pairs.length>N)throw new Error("weightedAverage \u53C2\u6570\u4E0D\u5408\u6CD5");let s=!1;for(let i of n.pairs){if(!h(i)||Object.keys(i).length!==2||!Object.prototype.hasOwnProperty.call(i,"value")||!Object.prototype.hasOwnProperty.call(i,"weight"))throw new Error("weightedAverage \u9879\u4E0D\u5408\u6CD5");$(i.value,o,c),$(i.weight,o,c)>0&&(s=!0)}if(!n.pairs.length||!s)throw new Error("weightedAverage \u6743\u91CD\u603B\u548C\u5FC5\u987B\u5927\u4E8E\u96F6");return}throw new Error("computed \u51FD\u6570\u4E0D\u5728\u767D\u540D\u5355\u4E2D")}function G(e,r,o,c){if(!(r==="string"&&typeof e=="string")&&!(r==="number"&&typeof e=="number"&&Number.isFinite(e)&&Math.abs(e)<1e15)){if(r==="series"&&Array.isArray(e)){T.parse(e);return}if(!h(e))throw new Error("\u52A8\u6001 prop \u7C7B\u578B\u4E0D\u5339\u914D");if(Object.prototype.hasOwnProperty.call(e,"$state")){let a=k(e,o);if(r==="string"&&typeof a.value=="string")return;if(r==="number"&&typeof a.value=="number"&&Math.abs(a.value)<1e15){J(a.key,a.value,c,-1e15,1e15);return}throw new Error("state \u5F15\u7528\u7C7B\u578B\u4E0E\u76EE\u6807 prop \u4E0D\u5339\u914D")}if(Object.prototype.hasOwnProperty.call(e,"$computed")){if(r==="string")throw new Error("computed \u51FD\u6570\u7ED3\u679C\u4E0D\u80FD\u7528\u4F5C\u6587\u672C prop");At(e,r==="series"?"series":"number",o,c);return}throw new Error("\u52A8\u6001 prop \u8868\u8FBE\u5F0F\u4E0D\u5728\u767D\u540D\u5355\u4E2D")}}function _t(e,r){if(typeof e=="boolean")return;if(!h(e)||typeof e.$state!="string")throw new Error("visible \u53EA\u5141\u8BB8\u5355\u5C42 state \u6761\u4EF6");let o=new Set(["$state","eq","neq","gt","gte","lt","lte","not"]);if(Object.keys(e).some(function(i){return!o.has(i)}))throw new Error("visible \u6761\u4EF6\u5305\u542B\u672A\u77E5\u5B57\u6BB5");let c=["eq","neq","gt","gte","lt","lte"].filter(function(i){return Object.prototype.hasOwnProperty.call(e,i)});if(c.length>1||e.not!==void 0&&e.not!==!0)throw new Error("visible \u4EC5\u5141\u8BB8\u4E00\u4E2A\u6BD4\u8F83\u7B26\u548C\u53EF\u9009 not");if(k({$state:e.$state},r),c.length===0)return;let a=c[0],n=e[a];if(["gt","gte","lt","lte"].includes(a)){if(typeof n=="number"&&Number.isFinite(n))return;if(typeof k(n,r).value!="number")throw new Error("visible \u6570\u503C\u6BD4\u8F83\u7C7B\u578B\u4E0D\u5339\u914D");return}if(["eq","neq"].includes(a)){if(typeof n=="string"||typeof n=="boolean"||typeof n=="number"&&Number.isFinite(n))return;let s=k(n,r);if(typeof s.value!="string"&&typeof s.value!="number"&&typeof s.value!="boolean")throw new Error("visible \u6BD4\u8F83\u7C7B\u578B\u4E0D\u5339\u914D");return}throw new Error("visible \u6BD4\u8F83\u7B26\u4E0D\u5408\u6CD5")}function Pt(e,r,o,c){let a=r.statePath;if(typeof a!="string"||!Object.prototype.hasOwnProperty.call(o,a))throw new Error("\u8F93\u5165\u63A7\u4EF6 statePath \u672A\u58F0\u660E");let n=o[a];if(e==="Select"||e==="ChoiceGroup"){let i=r.options;if(i.some(function(u){return u.value===null||typeof u.value=="number"&&!Number.isFinite(u.value)}))throw new Error("Select option \u503C\u4E0D\u5408\u6CD5");if(e==="ChoiceGroup"&&new Set(i.map(function(u){return u.value})).size!==i.length)throw new Error("ChoiceGroup option \u503C\u5FC5\u987B\u552F\u4E00");if(!i.some(function(u){return u.value===n}))throw new Error("Select \u521D\u59CB\u503C\u4E0D\u5728 options \u4E2D");c.set(a,[...c.get(a)??[],{kind:"select",values:i.map(function(u){return u.value})}])}else if(e==="Steps"){let i=r.items;if(typeof n!="number"||!Number.isInteger(n)||n<0||n>=i.length)throw new Error("Steps \u521D\u59CB\u503C\u5FC5\u987B\u4E3A\u6709\u6548\u6B65\u9AA4\u6574\u6570");c.set(a,[...c.get(a)??[],{kind:"range",min:0,max:i.length-1,step:1,integer:!0}])}else{let i=r.min,l=r.max,u=r.step;if(l<=i||u<=0||e==="Slider"&&(l-i)/u>1e3)throw new Error("\u8F93\u5165\u63A7\u4EF6 min/max/step \u4E0D\u5408\u6CD5");if(typeof n!="number"||!Number.isFinite(n)||n<i||n>l)throw new Error("\u8F93\u5165\u63A7\u4EF6\u521D\u59CB\u503C\u8D85\u51FA\u8303\u56F4");c.set(a,[...c.get(a)??[],{kind:"range",min:i,max:l,step:u}])}let s={...r};return delete s.statePath,s.value={$bindState:`/${a.replace(/~/g,"~0").replace(/\//g,"~1")}`},s}function Tt(e){let r=T.parse(e);for(let o of r)for(let c=1;c<o.points.length;c++)if(o.points[c].x<=o.points[c-1].x)throw new Error("\u56FE\u8868 x \u5FC5\u987B\u5347\u5E8F\u4E14\u4E0D\u91CD\u590D")}function Mt(e,r){let o=new Set,c=new Set;function a(n,s){if(s>ft)throw new Error("UI \u6811\u6DF1\u5EA6\u8D85\u9650");if(!Object.prototype.hasOwnProperty.call(r,n))throw new Error("UI \u5F15\u7528\u60AC\u7A7A");if(o.has(n))throw new Error("UI \u6811\u5305\u542B\u5FAA\u73AF");if(c.has(n))throw new Error("UI \u8282\u70B9\u4E0D\u5F97\u88AB\u91CD\u590D\u5F15\u7528");let i=r[n];if(!h(i))throw new Error("UI \u8282\u70B9\u5FC5\u987B\u662F\u5BF9\u8C61");o.add(n);let l=[];if(i.children!==void 0){if(!Array.isArray(i.children)||i.children.length>Q||i.children.some(function(m){return typeof m!="string"}))throw new Error("children \u4E0D\u5408\u6CD5\u6216\u8D85\u9650");l.push(...i.children)}if(i.slots!==void 0){if(!h(i.slots))throw new Error("slots \u5FC5\u987B\u662F\u5BF9\u8C61");for(let u of Object.values(i.slots)){if(!Array.isArray(u)||u.length>F||u.some(function(w){return typeof w!="string"}))throw new Error("slot children \u4E0D\u5408\u6CD5\u6216\u8D85\u9650");l.push(...u)}}if(new Set(l).size!==l.length)throw new Error("UI \u5B50\u8282\u70B9\u4E0D\u5F97\u91CD\u590D");for(let u of l)a(u,s+1);o.delete(n),c.add(n)}if(a(e,1),c.size!==Object.keys(r).length)throw new Error("UI elements \u542B\u4E0D\u53EF\u8FBE\u8282\u70B9")}function V(e){C(e,I);let r=z.parse(e),o=r.state??{};if(Object.keys(o).length>gt||C(o,q)>q)throw new Error("UI state \u8D85\u9650");let c=r.elements,a=Object.keys(c);if(a.length<1||a.length>pt)throw new Error("UI elements \u6570\u91CF\u8D85\u9650");Mt(r.root,c);let n=new Map,s={};for(let i of a){let l=c[i];if(!h(l))throw new Error("UI \u8282\u70B9\u5FC5\u987B\u662F\u5BF9\u8C61");let u=new Set(["type","props","children","slots","visible","on"]);if(Object.keys(l).some(function(y){return!u.has(y)}))throw new Error("UI \u8282\u70B9\u5305\u542B\u672A\u77E5\u5B57\u6BB5");if(typeof l.type!="string"||!v.includes(l.type))throw new Error("UI component \u4E0D\u5728\u767D\u540D\u5355\u4E2D");let m=l.type;if(!h(l.props))throw new Error("UI props \u5FC5\u987B\u662F\u5BF9\u8C61");let w=D[m].safeParse(l.props);if(!w.success)throw new Error("UI props \u4E0D\u7B26\u5408\u7EC4\u4EF6\u76EE\u5F55");let d=w.data,g=l.children,p=l.slots;if(["Stack","Grid","Card"].includes(m)){if(p!==void 0)throw new Error("\u6B64\u7EC4\u4EF6\u4E0D\u652F\u6301 slots")}else if(m==="Tabs"){if(g!==void 0||p&&Object.keys(p).some(function(y){return y!=="items"}))throw new Error("Tabs \u4EC5\u652F\u6301 slots.items")}else if(m==="Disclosure"){if(g!==void 0||p&&Object.keys(p).some(function(y){return y!=="content"}))throw new Error("Disclosure \u4EC5\u652F\u6301 slots.content")}else if(g!==void 0||p!==void 0)throw new Error("\u6B64\u7EC4\u4EF6\u4E0D\u652F\u6301 children \u6216 slots");m==="NumberInput"||m==="Slider"||m==="Select"||m==="Steps"||m==="ChoiceGroup"?s[i]={type:m,props:Pt(m,d,o,n),...g?{children:g}:{},...p?{slots:p}:{}}:s[i]={type:m,props:d,...g?{children:g}:{},...p?{slots:p}:{}},l.visible!==void 0&&(s[i].visible=l.visible),l.on!==void 0&&(s[i].on=l.on)}for(let i of a){let l=s[i],u=l.props;if(l.visible!==void 0&&_t(l.visible,o),l.type==="Text"&&G(u.value,"string",o,n),l.type==="Metric"&&G(u.value,"number",o,n),l.type==="LineChart"||l.type==="BarChart"){if(u.yMin!==void 0&&u.yMax!==void 0&&u.yMax<=u.yMin)throw new Error("\u56FE\u8868 yMin/yMax \u4E0D\u5408\u6CD5");Array.isArray(u.series)?Tt(u.series):G(u.series,"series",o,n)}if(l.type==="Flowchart"){let m=u.nodes,w=u.edges,d=new Set(m.map(function(b){return b.id}));if(d.size!==m.length)throw new Error("Flowchart \u8282\u70B9 id \u91CD\u590D");if(new Set(w.map(function(b){return b.id})).size!==w.length)throw new Error("Flowchart \u8FDE\u7EBF id \u91CD\u590D");let g=new Set;for(let p of w){if(!d.has(p.from)||!d.has(p.to))throw new Error("Flowchart \u8FDE\u7EBF\u5F15\u7528\u672A\u58F0\u660E\u8282\u70B9");let b=JSON.stringify([p.from,p.to,p.label??""]);if(g.has(b))throw new Error("Flowchart \u8FDE\u7EBF\u91CD\u590D");g.add(b)}}if(l.type==="DataTable"){let m=u.columns,w=new Set(m.map(function(p){return p.key})),d=u.rows;for(let g of d)if(Object.keys(g).some(function(b){return!w.has(b)}))throw new Error("DataTable row \u542B\u672A\u77E5\u5217");if(u.filterColumnKey!==void 0){let g=u.filterColumnKey;if(!w.has(g))throw new Error("DataTable filterColumnKey \u672A\u58F0\u660E");let p;for(let b of d){if(!Object.prototype.hasOwnProperty.call(b,g))throw new Error("DataTable \u7B5B\u9009\u5217\u503C\u7F3A\u5931");let y=typeof b[g];if(y!=="string"&&y!=="number")throw new Error("DataTable \u7B5B\u9009\u5217\u53EA\u5141\u8BB8\u5B57\u7B26\u4E32\u6216\u6570\u503C");if(p!==void 0&&p!==y)throw new Error("DataTable \u7B5B\u9009\u5217\u7C7B\u578B\u5FC5\u987B\u4E00\u81F4");p=y}}}if(l.type==="Button"){let m=u.action;if(l.on===void 0||Object.keys(l.on).length!==1||!Object.prototype.hasOwnProperty.call(l.on,"press"))throw new Error("Button \u4EC5\u652F\u6301 on.press");let w=l.on.press;if(!h(w)||Object.keys(w).length!==1||w.action!==m)throw new Error("Button action \u5FC5\u987B\u4E0E props.action \u4E00\u81F4");if(m==="continue_chat"){let d=u.fields;for(let g of d)if(!Object.prototype.hasOwnProperty.call(o,g.statePath))throw new Error("Button fields statePath \u672A\u58F0\u660E")}}else if(l.on!==void 0)throw new Error("\u53EA\u6709 Button \u53EF\u4EE5\u7ED1\u5B9A\u52A8\u4F5C")}return{root:r.root,elements:s,...r.state?{state:o}:{}}}function nt(e){let o=t.z.object({root:t.z.string().min(1),elements:t.z.record(t.z.string(),t.z.unknown()),state:t.z.record(t.z.string(),L).optional()}).strict().parse(e),c={};for(let[a,n]of Object.entries(o.elements)){if(!h(n)||!["NumberInput","Slider","Select","Steps","ChoiceGroup"].includes(String(n.type))||!h(n.props)){c[a]=n;continue}let s={...n.props},i=s.value;if(!h(i)||Object.keys(i).length!==1||typeof i.$bindState!="string")throw new Error("\u8F93\u5165\u63A7\u4EF6\u7ED1\u5B9A\u4E0D\u5408\u6CD5");delete s.value,s.statePath=rt(i.$bindState),c[a]={...n,props:s}}return V({...o,elements:c})}function j(e,r,o,c=!1){if(typeof e!="number"||!Number.isFinite(e)||e<r||e>o||c&&!Number.isInteger(e))throw new Error("\u8BA1\u7B97\u53C2\u6570\u8D85\u51FA\u8303\u56F4");return e}function M(e){if(!Number.isFinite(e)||Math.abs(e)>=1e15)throw new Error("\u8BA1\u7B97\u7ED3\u679C\u8D85\u51FA\u5B89\u5168\u8303\u56F4");return e}function vt(e){let r=j(e.P,E.P.min,E.P.max),o=j(e.C,E.C.min,E.C.max),c=j(e.R,E.R.min,E.R.max),a=j(e.Y,E.Y.min,E.Y.max,E.Y.integer),n=e.select;if(n!=="final"&&n!=="series")throw new Error("savingsGrowth selector \u4E0D\u5408\u6CD5");let s=c/12;function i(u){let m=u*12;if(s===0)return M(r+o*m);let w=Math.pow(1+s,m);return M(r*w+o*(w-1)/s)}if(n==="final")return i(a);let l=[];for(let u=0;u<=a;u++)l.push({x:u,y:i(u)});return[{name:"\u50A8\u84C4\u4F59\u989D",points:l}]}function Dt(e){if(!Array.isArray(e.values)||e.values.length>N)throw new Error("sum values \u4E0D\u5408\u6CD5");let r=0;for(let o of e.values)r+=j(o,0,Number.MAX_VALUE);return M(r)}function Rt(e){if(!Array.isArray(e.pairs)||e.pairs.length<1||e.pairs.length>N)throw new Error("weightedAverage pairs \u4E0D\u5408\u6CD5");let r=e.pairs.map(function(s){if(!h(s))throw new Error("weightedAverage pair \u4E0D\u5408\u6CD5");return{value:j(s.value,0,Number.MAX_VALUE),weight:j(s.weight,0,Number.MAX_VALUE)}}),o=Math.max(...r.map(function(s){return s.weight}));if(o<=0)throw new Error("weightedAverage \u6743\u91CD\u603B\u548C\u5FC5\u987B\u5927\u4E8E\u96F6");let c=r.reduce(function(s,i){return s+i.weight/o},0),a=r.reduce(function(s,i){return s+i.value*(i.weight/o/c)},0);return M(a)}var ot=Object.freeze({savingsGrowth:function(r){return vt(r)},weightedAverage:function(r){return Rt(r)},sum:function(r){return Dt(r)}});function B(e,r=I){return C(e,r)}var S=require("zod");var A=1,K=S.z.object({title:S.z.string().min(1).max(80),fallbackText:S.z.string().max(2e3),spec:z}).strict(),$t=S.z.object({schemaVersion:S.z.literal(A),uiId:S.z.string().regex(/^ui_[a-f0-9]{32}$/),title:S.z.string().min(1).max(80),fallbackText:S.z.string().max(2e3),spec:S.z.unknown()}).strict();function it(e){B(e,I);let r=K.parse(e),o={title:r.title,fallbackText:r.fallbackText,spec:V(r.spec)};return Y(o,`ui_${"0".repeat(32)}`),o}function Y(e,r){return X({schemaVersion:A,uiId:r,...e})}function X(e){B(e,I);let r=$t.parse(e),o=r.spec;if(typeof o!="object"||o===null||Array.isArray(o))throw new Error("UI spec \u6295\u5F71\u4E0D\u5408\u6CD5");let c=JSON.parse(JSON.stringify(nt(o)));return{schemaVersion:A,uiId:r.uiId,title:r.title,fallbackText:r.fallbackText,spec:c}}