@ericsanchezok/synergy-util 3.0.23 → 3.1.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 (74) hide show
  1. package/LICENSE.codex +201 -0
  2. package/NOTICE +9 -0
  3. package/dist/activity.d.ts +9 -4
  4. package/dist/activity.js +20 -19
  5. package/dist/asset-reference.d.ts +15 -0
  6. package/dist/asset-reference.js +98 -0
  7. package/dist/atomic-file.d.ts +9 -0
  8. package/dist/atomic-file.js +86 -0
  9. package/dist/attachment-presentation.d.ts +26 -0
  10. package/dist/attachment-presentation.js +11 -0
  11. package/dist/capability.d.ts +1 -1
  12. package/dist/capability.js +5 -19
  13. package/dist/cli-command.d.ts +12 -0
  14. package/dist/cli-command.js +3 -0
  15. package/dist/encode.d.ts +3 -0
  16. package/dist/encode.js +7 -0
  17. package/dist/error.d.ts +36 -56
  18. package/dist/feature-config.d.ts +4 -0
  19. package/dist/feature-config.js +23 -0
  20. package/dist/features.d.ts +134 -0
  21. package/dist/features.js +195 -0
  22. package/dist/file-patch.d.ts +31 -0
  23. package/dist/file-patch.js +218 -0
  24. package/dist/filesystem-identity.d.ts +28 -0
  25. package/dist/filesystem-identity.js +71 -0
  26. package/dist/fn.d.ts +1 -1
  27. package/dist/fs-lock.d.ts +5 -1
  28. package/dist/fs-lock.js +14 -6
  29. package/dist/input-assistance.d.ts +51 -0
  30. package/dist/input-assistance.js +61 -0
  31. package/dist/installed-launcher.d.ts +18 -0
  32. package/dist/installed-launcher.js +39 -0
  33. package/dist/io-retry.d.ts +11 -0
  34. package/dist/io-retry.js +36 -0
  35. package/dist/json-value.d.ts +4 -0
  36. package/dist/json-value.js +12 -0
  37. package/dist/markdown-assets.d.ts +6 -0
  38. package/dist/markdown-assets.js +29 -0
  39. package/dist/markdown-link.d.ts +2 -0
  40. package/dist/markdown-link.js +8 -0
  41. package/dist/native-assets.d.ts +7 -0
  42. package/dist/native-assets.js +28 -0
  43. package/dist/network-error.d.ts +7 -0
  44. package/dist/network-error.js +111 -0
  45. package/dist/plugin-policy.d.ts +1 -1
  46. package/dist/process-group.d.ts +45 -0
  47. package/dist/process-group.js +156 -0
  48. package/dist/process-identity.js +5 -2
  49. package/dist/projection-patch.d.ts +9 -0
  50. package/dist/projection-patch.js +74 -0
  51. package/dist/reasoning-item.d.ts +1 -0
  52. package/dist/reasoning-item.js +16 -0
  53. package/dist/render-artifact.d.ts +352 -0
  54. package/dist/render-artifact.js +115 -0
  55. package/dist/render-ui.d.ts +202 -0
  56. package/dist/render-ui.js +208 -0
  57. package/dist/resource-reference.d.ts +73 -0
  58. package/dist/resource-reference.js +227 -0
  59. package/dist/retry.d.ts +4 -0
  60. package/dist/retry.js +56 -23
  61. package/dist/runtime-startup.d.ts +240 -2
  62. package/dist/runtime-startup.js +108 -9
  63. package/dist/terminal.d.ts +217 -0
  64. package/dist/terminal.js +111 -0
  65. package/dist/tool-display.d.ts +10 -0
  66. package/dist/tool-display.js +22 -1
  67. package/dist/tool-timeout.d.ts +21 -0
  68. package/dist/tool-timeout.js +1 -0
  69. package/dist/tool.d.ts +6 -7
  70. package/dist/workbench-view.d.ts +692 -0
  71. package/dist/workbench-view.js +90 -0
  72. package/dist/worker-plan.d.ts +39 -0
  73. package/dist/worker-plan.js +33 -0
  74. package/package.json +28 -4
@@ -0,0 +1,352 @@
1
+ import { z } from "zod";
2
+ /** Portable render protocol shared by the Media owner and its untrusted UI runtime. */
3
+ export declare namespace RenderArtifact {
4
+ const MIME = "application/vnd.synergy.visual+json";
5
+ const SOURCE_BYTES: number;
6
+ const STATE_BYTES: number;
7
+ const IMAGE_URL_LIMIT: number;
8
+ const Library: z.ZodEnum<{
9
+ chart: "chart";
10
+ d3: "d3";
11
+ mermaid: "mermaid";
12
+ }>;
13
+ const ID: z.ZodString;
14
+ const Source: z.ZodObject<{
15
+ format: z.ZodLiteral<"synergy.visual">;
16
+ version: z.ZodLiteral<1>;
17
+ id: z.ZodString;
18
+ mode: z.ZodEnum<{
19
+ interactive: "interactive";
20
+ static: "static";
21
+ }>;
22
+ title: z.ZodString;
23
+ layout: z.ZodEnum<{
24
+ normal: "normal";
25
+ wide: "wide";
26
+ }>;
27
+ libraries: z.ZodArray<z.ZodEnum<{
28
+ chart: "chart";
29
+ d3: "d3";
30
+ mermaid: "mermaid";
31
+ }>>;
32
+ renderer: z.ZodOptional<z.ZodEnum<{
33
+ html: "html";
34
+ native: "native";
35
+ }>>;
36
+ ui: z.ZodOptional<z.ZodObject<{
37
+ state: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
38
+ computed: z.ZodDefault<z.ZodArray<z.ZodObject<{
39
+ id: z.ZodString;
40
+ op: z.ZodEnum<{
41
+ add: "add";
42
+ divide: "divide";
43
+ max: "max";
44
+ min: "min";
45
+ multiply: "multiply";
46
+ subtract: "subtract";
47
+ }>;
48
+ inputs: z.ZodTuple<[z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodObject<{
49
+ ref: z.ZodString;
50
+ }, z.core.$strict>]>, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodObject<{
51
+ ref: z.ZodString;
52
+ }, z.core.$strict>]>], null>;
53
+ }, z.core.$strict>>>;
54
+ nodes: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
55
+ id: z.ZodString;
56
+ parent: z.ZodOptional<z.ZodString>;
57
+ type: z.ZodLiteral<"heading">;
58
+ text: z.ZodString;
59
+ level: z.ZodOptional<z.ZodEnum<{
60
+ 2: "2";
61
+ 3: "3";
62
+ }>>;
63
+ }, z.core.$strict>, z.ZodObject<{
64
+ id: z.ZodString;
65
+ parent: z.ZodOptional<z.ZodString>;
66
+ type: z.ZodLiteral<"text">;
67
+ text: z.ZodString;
68
+ }, z.core.$strict>, z.ZodObject<{
69
+ id: z.ZodString;
70
+ parent: z.ZodOptional<z.ZodString>;
71
+ type: z.ZodLiteral<"row">;
72
+ columns: z.ZodOptional<z.ZodNumber>;
73
+ }, z.core.$strict>, z.ZodObject<{
74
+ id: z.ZodString;
75
+ parent: z.ZodOptional<z.ZodString>;
76
+ type: z.ZodLiteral<"card">;
77
+ title: z.ZodOptional<z.ZodString>;
78
+ }, z.core.$strict>, z.ZodObject<{
79
+ id: z.ZodString;
80
+ parent: z.ZodOptional<z.ZodString>;
81
+ type: z.ZodLiteral<"metric">;
82
+ label: z.ZodString;
83
+ value: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodObject<{
84
+ ref: z.ZodString;
85
+ }, z.core.$strict>]>;
86
+ prefix: z.ZodOptional<z.ZodString>;
87
+ suffix: z.ZodOptional<z.ZodString>;
88
+ }, z.core.$strict>, z.ZodObject<{
89
+ id: z.ZodString;
90
+ parent: z.ZodOptional<z.ZodString>;
91
+ type: z.ZodLiteral<"slider">;
92
+ label: z.ZodString;
93
+ state: z.ZodString;
94
+ min: z.ZodNumber;
95
+ max: z.ZodNumber;
96
+ step: z.ZodOptional<z.ZodNumber>;
97
+ }, z.core.$strict>, z.ZodObject<{
98
+ id: z.ZodString;
99
+ parent: z.ZodOptional<z.ZodString>;
100
+ type: z.ZodLiteral<"select">;
101
+ label: z.ZodString;
102
+ state: z.ZodString;
103
+ options: z.ZodArray<z.ZodString>;
104
+ }, z.core.$strict>, z.ZodObject<{
105
+ id: z.ZodString;
106
+ parent: z.ZodOptional<z.ZodString>;
107
+ type: z.ZodLiteral<"checkbox">;
108
+ label: z.ZodString;
109
+ state: z.ZodString;
110
+ }, z.core.$strict>, z.ZodObject<{
111
+ id: z.ZodString;
112
+ parent: z.ZodOptional<z.ZodString>;
113
+ type: z.ZodLiteral<"button">;
114
+ label: z.ZodString;
115
+ text: z.ZodString;
116
+ }, z.core.$strict>, z.ZodObject<{
117
+ id: z.ZodString;
118
+ parent: z.ZodOptional<z.ZodString>;
119
+ type: z.ZodLiteral<"bar">;
120
+ label: z.ZodString;
121
+ items: z.ZodArray<z.ZodObject<{
122
+ label: z.ZodString;
123
+ value: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodObject<{
124
+ ref: z.ZodString;
125
+ }, z.core.$strict>]>;
126
+ }, z.core.$strict>>;
127
+ }, z.core.$strict>], "type">>;
128
+ }, z.core.$strict>>;
129
+ html: z.ZodString;
130
+ replaces: z.ZodOptional<z.ZodString>;
131
+ }, z.core.$strict>;
132
+ type Source = z.infer<typeof Source>;
133
+ const Descriptor: z.ZodObject<{
134
+ format: z.ZodLiteral<"synergy.visual">;
135
+ version: z.ZodLiteral<1>;
136
+ id: z.ZodString;
137
+ mode: z.ZodEnum<{
138
+ interactive: "interactive";
139
+ static: "static";
140
+ }>;
141
+ title: z.ZodString;
142
+ layout: z.ZodEnum<{
143
+ normal: "normal";
144
+ wide: "wide";
145
+ }>;
146
+ libraries: z.ZodArray<z.ZodEnum<{
147
+ chart: "chart";
148
+ d3: "d3";
149
+ mermaid: "mermaid";
150
+ }>>;
151
+ renderer: z.ZodOptional<z.ZodEnum<{
152
+ html: "html";
153
+ native: "native";
154
+ }>>;
155
+ replaces: z.ZodOptional<z.ZodString>;
156
+ source: z.ZodString;
157
+ }, z.core.$strict>;
158
+ type Descriptor = z.infer<typeof Descriptor>;
159
+ const Content: z.ZodObject<{
160
+ modelContent: z.ZodOptional<z.ZodType<z.JSONType, unknown, z.core.$ZodTypeInternals<z.JSONType, unknown>>>;
161
+ uiContent: z.ZodOptional<z.ZodType<z.JSONType, unknown, z.core.$ZodTypeInternals<z.JSONType, unknown>>>;
162
+ }, z.core.$strict>;
163
+ type Content = z.infer<typeof Content>;
164
+ const State: z.ZodObject<{
165
+ revision: z.ZodNumber;
166
+ updatedAt: z.ZodNumber;
167
+ mutationID: z.ZodOptional<z.ZodString>;
168
+ content: z.ZodObject<{
169
+ modelContent: z.ZodOptional<z.ZodType<z.JSONType, unknown, z.core.$ZodTypeInternals<z.JSONType, unknown>>>;
170
+ uiContent: z.ZodOptional<z.ZodType<z.JSONType, unknown, z.core.$ZodTypeInternals<z.JSONType, unknown>>>;
171
+ }, z.core.$strict>;
172
+ }, z.core.$strict>;
173
+ type State = z.infer<typeof State>;
174
+ const Write: z.ZodObject<{
175
+ revision: z.ZodNumber;
176
+ mutationID: z.ZodString;
177
+ content: z.ZodObject<{
178
+ modelContent: z.ZodOptional<z.ZodType<z.JSONType, unknown, z.core.$ZodTypeInternals<z.JSONType, unknown>>>;
179
+ uiContent: z.ZodOptional<z.ZodType<z.JSONType, unknown, z.core.$ZodTypeInternals<z.JSONType, unknown>>>;
180
+ }, z.core.$strict>;
181
+ }, z.core.$strict>;
182
+ type Write = z.infer<typeof Write>;
183
+ const Target: z.ZodObject<{
184
+ sessionID: z.ZodString;
185
+ messageID: z.ZodString;
186
+ partID: z.ZodString;
187
+ }, z.core.$strict>;
188
+ type Target = z.infer<typeof Target>;
189
+ const Snapshot: z.ZodObject<{
190
+ descriptor: z.ZodObject<{
191
+ format: z.ZodLiteral<"synergy.visual">;
192
+ version: z.ZodLiteral<1>;
193
+ id: z.ZodString;
194
+ mode: z.ZodEnum<{
195
+ interactive: "interactive";
196
+ static: "static";
197
+ }>;
198
+ title: z.ZodString;
199
+ layout: z.ZodEnum<{
200
+ normal: "normal";
201
+ wide: "wide";
202
+ }>;
203
+ libraries: z.ZodArray<z.ZodEnum<{
204
+ chart: "chart";
205
+ d3: "d3";
206
+ mermaid: "mermaid";
207
+ }>>;
208
+ renderer: z.ZodOptional<z.ZodEnum<{
209
+ html: "html";
210
+ native: "native";
211
+ }>>;
212
+ replaces: z.ZodOptional<z.ZodString>;
213
+ source: z.ZodString;
214
+ }, z.core.$strict>;
215
+ source: z.ZodObject<{
216
+ format: z.ZodLiteral<"synergy.visual">;
217
+ version: z.ZodLiteral<1>;
218
+ id: z.ZodString;
219
+ mode: z.ZodEnum<{
220
+ interactive: "interactive";
221
+ static: "static";
222
+ }>;
223
+ title: z.ZodString;
224
+ layout: z.ZodEnum<{
225
+ normal: "normal";
226
+ wide: "wide";
227
+ }>;
228
+ libraries: z.ZodArray<z.ZodEnum<{
229
+ chart: "chart";
230
+ d3: "d3";
231
+ mermaid: "mermaid";
232
+ }>>;
233
+ renderer: z.ZodOptional<z.ZodEnum<{
234
+ html: "html";
235
+ native: "native";
236
+ }>>;
237
+ ui: z.ZodOptional<z.ZodObject<{
238
+ state: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
239
+ computed: z.ZodDefault<z.ZodArray<z.ZodObject<{
240
+ id: z.ZodString;
241
+ op: z.ZodEnum<{
242
+ add: "add";
243
+ divide: "divide";
244
+ max: "max";
245
+ min: "min";
246
+ multiply: "multiply";
247
+ subtract: "subtract";
248
+ }>;
249
+ inputs: z.ZodTuple<[z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodObject<{
250
+ ref: z.ZodString;
251
+ }, z.core.$strict>]>, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodObject<{
252
+ ref: z.ZodString;
253
+ }, z.core.$strict>]>], null>;
254
+ }, z.core.$strict>>>;
255
+ nodes: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
256
+ id: z.ZodString;
257
+ parent: z.ZodOptional<z.ZodString>;
258
+ type: z.ZodLiteral<"heading">;
259
+ text: z.ZodString;
260
+ level: z.ZodOptional<z.ZodEnum<{
261
+ 2: "2";
262
+ 3: "3";
263
+ }>>;
264
+ }, z.core.$strict>, z.ZodObject<{
265
+ id: z.ZodString;
266
+ parent: z.ZodOptional<z.ZodString>;
267
+ type: z.ZodLiteral<"text">;
268
+ text: z.ZodString;
269
+ }, z.core.$strict>, z.ZodObject<{
270
+ id: z.ZodString;
271
+ parent: z.ZodOptional<z.ZodString>;
272
+ type: z.ZodLiteral<"row">;
273
+ columns: z.ZodOptional<z.ZodNumber>;
274
+ }, z.core.$strict>, z.ZodObject<{
275
+ id: z.ZodString;
276
+ parent: z.ZodOptional<z.ZodString>;
277
+ type: z.ZodLiteral<"card">;
278
+ title: z.ZodOptional<z.ZodString>;
279
+ }, z.core.$strict>, z.ZodObject<{
280
+ id: z.ZodString;
281
+ parent: z.ZodOptional<z.ZodString>;
282
+ type: z.ZodLiteral<"metric">;
283
+ label: z.ZodString;
284
+ value: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodObject<{
285
+ ref: z.ZodString;
286
+ }, z.core.$strict>]>;
287
+ prefix: z.ZodOptional<z.ZodString>;
288
+ suffix: z.ZodOptional<z.ZodString>;
289
+ }, z.core.$strict>, z.ZodObject<{
290
+ id: z.ZodString;
291
+ parent: z.ZodOptional<z.ZodString>;
292
+ type: z.ZodLiteral<"slider">;
293
+ label: z.ZodString;
294
+ state: z.ZodString;
295
+ min: z.ZodNumber;
296
+ max: z.ZodNumber;
297
+ step: z.ZodOptional<z.ZodNumber>;
298
+ }, z.core.$strict>, z.ZodObject<{
299
+ id: z.ZodString;
300
+ parent: z.ZodOptional<z.ZodString>;
301
+ type: z.ZodLiteral<"select">;
302
+ label: z.ZodString;
303
+ state: z.ZodString;
304
+ options: z.ZodArray<z.ZodString>;
305
+ }, z.core.$strict>, z.ZodObject<{
306
+ id: z.ZodString;
307
+ parent: z.ZodOptional<z.ZodString>;
308
+ type: z.ZodLiteral<"checkbox">;
309
+ label: z.ZodString;
310
+ state: z.ZodString;
311
+ }, z.core.$strict>, z.ZodObject<{
312
+ id: z.ZodString;
313
+ parent: z.ZodOptional<z.ZodString>;
314
+ type: z.ZodLiteral<"button">;
315
+ label: z.ZodString;
316
+ text: z.ZodString;
317
+ }, z.core.$strict>, z.ZodObject<{
318
+ id: z.ZodString;
319
+ parent: z.ZodOptional<z.ZodString>;
320
+ type: z.ZodLiteral<"bar">;
321
+ label: z.ZodString;
322
+ items: z.ZodArray<z.ZodObject<{
323
+ label: z.ZodString;
324
+ value: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodObject<{
325
+ ref: z.ZodString;
326
+ }, z.core.$strict>]>;
327
+ }, z.core.$strict>>;
328
+ }, z.core.$strict>], "type">>;
329
+ }, z.core.$strict>>;
330
+ html: z.ZodString;
331
+ replaces: z.ZodOptional<z.ZodString>;
332
+ }, z.core.$strict>;
333
+ state: z.ZodObject<{
334
+ revision: z.ZodNumber;
335
+ updatedAt: z.ZodNumber;
336
+ mutationID: z.ZodOptional<z.ZodString>;
337
+ content: z.ZodObject<{
338
+ modelContent: z.ZodOptional<z.ZodType<z.JSONType, unknown, z.core.$ZodTypeInternals<z.JSONType, unknown>>>;
339
+ uiContent: z.ZodOptional<z.ZodType<z.JSONType, unknown, z.core.$ZodTypeInternals<z.JSONType, unknown>>>;
340
+ }, z.core.$strict>;
341
+ }, z.core.$strict>;
342
+ }, z.core.$strip>;
343
+ const FollowUp: z.ZodObject<{
344
+ requestID: z.ZodString;
345
+ text: z.ZodString;
346
+ image: z.ZodOptional<z.ZodString>;
347
+ }, z.core.$strict>;
348
+ type FollowUp = z.infer<typeof FollowUp>;
349
+ function emptyState(): State;
350
+ function descriptor(metadata: unknown): Descriptor | undefined;
351
+ function state(metadata: unknown): State;
352
+ }
@@ -0,0 +1,115 @@
1
+ import { z } from "zod";
2
+ import { JsonValue } from "./json-value";
3
+ import { RenderUI } from "./render-ui";
4
+ /** Portable render protocol shared by the Media owner and its untrusted UI runtime. */
5
+ export var RenderArtifact;
6
+ (function (RenderArtifact) {
7
+ RenderArtifact.MIME = "application/vnd.synergy.visual+json";
8
+ RenderArtifact.SOURCE_BYTES = 1024 * 1024;
9
+ RenderArtifact.STATE_BYTES = 16 * 1024;
10
+ RenderArtifact.IMAGE_URL_LIMIT = 350 * 1024;
11
+ RenderArtifact.Library = z.enum(["d3", "chart", "mermaid"]);
12
+ RenderArtifact.ID = z.string().uuid();
13
+ const SourceFields = z
14
+ .object({
15
+ format: z.literal("synergy.visual"),
16
+ version: z.literal(1),
17
+ id: RenderArtifact.ID,
18
+ mode: z.enum(["static", "interactive"]),
19
+ title: z.string().min(1).max(160),
20
+ layout: z.enum(["normal", "wide"]),
21
+ libraries: z.array(RenderArtifact.Library).max(3),
22
+ renderer: z.enum(["native", "html"]).optional(),
23
+ ui: RenderUI.Spec.optional(),
24
+ html: z
25
+ .string()
26
+ .min(1)
27
+ .refine((text) => new TextEncoder().encode(text).byteLength <= RenderArtifact.SOURCE_BYTES, "HTML exceeds 1 MiB"),
28
+ replaces: RenderArtifact.ID.optional(),
29
+ })
30
+ .strict();
31
+ RenderArtifact.Source = SourceFields.superRefine((source, ctx) => {
32
+ if ((source.renderer === "native") !== (source.ui !== undefined))
33
+ ctx.addIssue({ code: "custom", message: "Native sources require ui; HTML sources cannot contain ui" });
34
+ if (source.ui && source.libraries.length)
35
+ ctx.addIssue({ code: "custom", message: "Native sources cannot load libraries" });
36
+ }).meta({ ref: "RenderSource" });
37
+ RenderArtifact.Descriptor = SourceFields.omit({ html: true, ui: true })
38
+ .extend({
39
+ source: z.string().regex(/^asset:\/\/[a-f0-9]{16}\.bin$/),
40
+ })
41
+ .strict()
42
+ .meta({ ref: "RenderDescriptor" });
43
+ RenderArtifact.Content = z
44
+ .object({
45
+ modelContent: JsonValue.optional(),
46
+ uiContent: JsonValue.optional(),
47
+ })
48
+ .strict()
49
+ .refine((value) => {
50
+ try {
51
+ return new TextEncoder().encode(JSON.stringify(value)).byteLength <= RenderArtifact.STATE_BYTES;
52
+ }
53
+ catch {
54
+ return false;
55
+ }
56
+ }, "State exceeds 16 KiB")
57
+ .meta({ ref: "RenderContent" });
58
+ RenderArtifact.State = z
59
+ .object({
60
+ revision: z.number().int().nonnegative(),
61
+ updatedAt: z.number().nonnegative(),
62
+ mutationID: z.string().max(100).optional(),
63
+ content: RenderArtifact.Content,
64
+ })
65
+ .strict()
66
+ .meta({ ref: "RenderState" });
67
+ RenderArtifact.Write = z
68
+ .object({
69
+ revision: z.number().int().nonnegative(),
70
+ mutationID: z.string().min(1).max(100),
71
+ content: RenderArtifact.Content,
72
+ })
73
+ .strict()
74
+ .meta({ ref: "RenderStateWrite" });
75
+ RenderArtifact.Target = z
76
+ .object({
77
+ sessionID: z.string().regex(/^ses_[\w]+$/),
78
+ messageID: z.string().regex(/^msg_[\w]+$/),
79
+ partID: z.string().regex(/^prt_[\w]+$/),
80
+ })
81
+ .strict()
82
+ .meta({ ref: "RenderTarget" });
83
+ RenderArtifact.Snapshot = z
84
+ .object({ descriptor: RenderArtifact.Descriptor, source: RenderArtifact.Source, state: RenderArtifact.State })
85
+ .meta({ ref: "RenderSnapshot" });
86
+ RenderArtifact.FollowUp = z
87
+ .object({
88
+ requestID: z.string().min(1).max(100),
89
+ text: z.string().trim().min(1).max(8000),
90
+ image: z
91
+ .string()
92
+ .max(RenderArtifact.IMAGE_URL_LIMIT)
93
+ .regex(/^data:image\/png;base64,iVBORw0KGgo[A-Za-z0-9+/]*={0,2}$/)
94
+ .optional(),
95
+ })
96
+ .strict();
97
+ function emptyState() {
98
+ return { revision: 0, updatedAt: 0, content: {} };
99
+ }
100
+ RenderArtifact.emptyState = emptyState;
101
+ function descriptor(metadata) {
102
+ if (!metadata || typeof metadata !== "object" || !("visual" in metadata))
103
+ return;
104
+ const result = RenderArtifact.Descriptor.safeParse(metadata.visual);
105
+ return result.success ? result.data : undefined;
106
+ }
107
+ RenderArtifact.descriptor = descriptor;
108
+ function state(metadata) {
109
+ if (!metadata || typeof metadata !== "object" || !("visualState" in metadata))
110
+ return emptyState();
111
+ const result = RenderArtifact.State.safeParse(metadata.visualState);
112
+ return result.success ? result.data : emptyState();
113
+ }
114
+ RenderArtifact.state = state;
115
+ })(RenderArtifact || (RenderArtifact = {}));
@@ -0,0 +1,202 @@
1
+ import { z } from "zod";
2
+ export declare namespace RenderUI {
3
+ const Key: z.ZodString;
4
+ const Value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
5
+ type Value = z.infer<typeof Value>;
6
+ const Binding: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodObject<{
7
+ ref: z.ZodString;
8
+ }, z.core.$strict>]>;
9
+ type Binding = z.infer<typeof Binding>;
10
+ const Node: z.ZodDiscriminatedUnion<[z.ZodObject<{
11
+ id: z.ZodString;
12
+ parent: z.ZodOptional<z.ZodString>;
13
+ type: z.ZodLiteral<"heading">;
14
+ text: z.ZodString;
15
+ level: z.ZodOptional<z.ZodEnum<{
16
+ 2: "2";
17
+ 3: "3";
18
+ }>>;
19
+ }, z.core.$strict>, z.ZodObject<{
20
+ id: z.ZodString;
21
+ parent: z.ZodOptional<z.ZodString>;
22
+ type: z.ZodLiteral<"text">;
23
+ text: z.ZodString;
24
+ }, z.core.$strict>, z.ZodObject<{
25
+ id: z.ZodString;
26
+ parent: z.ZodOptional<z.ZodString>;
27
+ type: z.ZodLiteral<"row">;
28
+ columns: z.ZodOptional<z.ZodNumber>;
29
+ }, z.core.$strict>, z.ZodObject<{
30
+ id: z.ZodString;
31
+ parent: z.ZodOptional<z.ZodString>;
32
+ type: z.ZodLiteral<"card">;
33
+ title: z.ZodOptional<z.ZodString>;
34
+ }, z.core.$strict>, z.ZodObject<{
35
+ id: z.ZodString;
36
+ parent: z.ZodOptional<z.ZodString>;
37
+ type: z.ZodLiteral<"metric">;
38
+ label: z.ZodString;
39
+ value: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodObject<{
40
+ ref: z.ZodString;
41
+ }, z.core.$strict>]>;
42
+ prefix: z.ZodOptional<z.ZodString>;
43
+ suffix: z.ZodOptional<z.ZodString>;
44
+ }, z.core.$strict>, z.ZodObject<{
45
+ id: z.ZodString;
46
+ parent: z.ZodOptional<z.ZodString>;
47
+ type: z.ZodLiteral<"slider">;
48
+ label: z.ZodString;
49
+ state: z.ZodString;
50
+ min: z.ZodNumber;
51
+ max: z.ZodNumber;
52
+ step: z.ZodOptional<z.ZodNumber>;
53
+ }, z.core.$strict>, z.ZodObject<{
54
+ id: z.ZodString;
55
+ parent: z.ZodOptional<z.ZodString>;
56
+ type: z.ZodLiteral<"select">;
57
+ label: z.ZodString;
58
+ state: z.ZodString;
59
+ options: z.ZodArray<z.ZodString>;
60
+ }, z.core.$strict>, z.ZodObject<{
61
+ id: z.ZodString;
62
+ parent: z.ZodOptional<z.ZodString>;
63
+ type: z.ZodLiteral<"checkbox">;
64
+ label: z.ZodString;
65
+ state: z.ZodString;
66
+ }, z.core.$strict>, z.ZodObject<{
67
+ id: z.ZodString;
68
+ parent: z.ZodOptional<z.ZodString>;
69
+ type: z.ZodLiteral<"button">;
70
+ label: z.ZodString;
71
+ text: z.ZodString;
72
+ }, z.core.$strict>, z.ZodObject<{
73
+ id: z.ZodString;
74
+ parent: z.ZodOptional<z.ZodString>;
75
+ type: z.ZodLiteral<"bar">;
76
+ label: z.ZodString;
77
+ items: z.ZodArray<z.ZodObject<{
78
+ label: z.ZodString;
79
+ value: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodObject<{
80
+ ref: z.ZodString;
81
+ }, z.core.$strict>]>;
82
+ }, z.core.$strict>>;
83
+ }, z.core.$strict>], "type">;
84
+ type Node = z.infer<typeof Node>;
85
+ const Computed: z.ZodObject<{
86
+ id: z.ZodString;
87
+ op: z.ZodEnum<{
88
+ add: "add";
89
+ divide: "divide";
90
+ max: "max";
91
+ min: "min";
92
+ multiply: "multiply";
93
+ subtract: "subtract";
94
+ }>;
95
+ inputs: z.ZodTuple<[z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodObject<{
96
+ ref: z.ZodString;
97
+ }, z.core.$strict>]>, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodObject<{
98
+ ref: z.ZodString;
99
+ }, z.core.$strict>]>], null>;
100
+ }, z.core.$strict>;
101
+ const Spec: z.ZodObject<{
102
+ state: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
103
+ computed: z.ZodDefault<z.ZodArray<z.ZodObject<{
104
+ id: z.ZodString;
105
+ op: z.ZodEnum<{
106
+ add: "add";
107
+ divide: "divide";
108
+ max: "max";
109
+ min: "min";
110
+ multiply: "multiply";
111
+ subtract: "subtract";
112
+ }>;
113
+ inputs: z.ZodTuple<[z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodObject<{
114
+ ref: z.ZodString;
115
+ }, z.core.$strict>]>, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodObject<{
116
+ ref: z.ZodString;
117
+ }, z.core.$strict>]>], null>;
118
+ }, z.core.$strict>>>;
119
+ nodes: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
120
+ id: z.ZodString;
121
+ parent: z.ZodOptional<z.ZodString>;
122
+ type: z.ZodLiteral<"heading">;
123
+ text: z.ZodString;
124
+ level: z.ZodOptional<z.ZodEnum<{
125
+ 2: "2";
126
+ 3: "3";
127
+ }>>;
128
+ }, z.core.$strict>, z.ZodObject<{
129
+ id: z.ZodString;
130
+ parent: z.ZodOptional<z.ZodString>;
131
+ type: z.ZodLiteral<"text">;
132
+ text: z.ZodString;
133
+ }, z.core.$strict>, z.ZodObject<{
134
+ id: z.ZodString;
135
+ parent: z.ZodOptional<z.ZodString>;
136
+ type: z.ZodLiteral<"row">;
137
+ columns: z.ZodOptional<z.ZodNumber>;
138
+ }, z.core.$strict>, z.ZodObject<{
139
+ id: z.ZodString;
140
+ parent: z.ZodOptional<z.ZodString>;
141
+ type: z.ZodLiteral<"card">;
142
+ title: z.ZodOptional<z.ZodString>;
143
+ }, z.core.$strict>, z.ZodObject<{
144
+ id: z.ZodString;
145
+ parent: z.ZodOptional<z.ZodString>;
146
+ type: z.ZodLiteral<"metric">;
147
+ label: z.ZodString;
148
+ value: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodObject<{
149
+ ref: z.ZodString;
150
+ }, z.core.$strict>]>;
151
+ prefix: z.ZodOptional<z.ZodString>;
152
+ suffix: z.ZodOptional<z.ZodString>;
153
+ }, z.core.$strict>, z.ZodObject<{
154
+ id: z.ZodString;
155
+ parent: z.ZodOptional<z.ZodString>;
156
+ type: z.ZodLiteral<"slider">;
157
+ label: z.ZodString;
158
+ state: z.ZodString;
159
+ min: z.ZodNumber;
160
+ max: z.ZodNumber;
161
+ step: z.ZodOptional<z.ZodNumber>;
162
+ }, z.core.$strict>, z.ZodObject<{
163
+ id: z.ZodString;
164
+ parent: z.ZodOptional<z.ZodString>;
165
+ type: z.ZodLiteral<"select">;
166
+ label: z.ZodString;
167
+ state: z.ZodString;
168
+ options: z.ZodArray<z.ZodString>;
169
+ }, z.core.$strict>, z.ZodObject<{
170
+ id: z.ZodString;
171
+ parent: z.ZodOptional<z.ZodString>;
172
+ type: z.ZodLiteral<"checkbox">;
173
+ label: z.ZodString;
174
+ state: z.ZodString;
175
+ }, z.core.$strict>, z.ZodObject<{
176
+ id: z.ZodString;
177
+ parent: z.ZodOptional<z.ZodString>;
178
+ type: z.ZodLiteral<"button">;
179
+ label: z.ZodString;
180
+ text: z.ZodString;
181
+ }, z.core.$strict>, z.ZodObject<{
182
+ id: z.ZodString;
183
+ parent: z.ZodOptional<z.ZodString>;
184
+ type: z.ZodLiteral<"bar">;
185
+ label: z.ZodString;
186
+ items: z.ZodArray<z.ZodObject<{
187
+ label: z.ZodString;
188
+ value: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodObject<{
189
+ ref: z.ZodString;
190
+ }, z.core.$strict>]>;
191
+ }, z.core.$strict>>;
192
+ }, z.core.$strict>], "type">>;
193
+ }, z.core.$strict>;
194
+ type Spec = z.infer<typeof Spec>;
195
+ /**
196
+ * Provenance: https://www.openui.com/blog/how-chatgpt-intelligent-ui-works
197
+ * Local adaptation: bounded declarative data, keyed controls and local arithmetic replace authored programs.
198
+ */
199
+ function evaluate(spec: Spec, state: Record<string, Value>): Record<string, Value>;
200
+ function preview(input: unknown): Spec | undefined;
201
+ function fallback(spec: Spec): string;
202
+ }