@inf-monkeys-tech/monkeys 1.0.2 → 1.0.3

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.
@@ -0,0 +1,4564 @@
1
+ // src/contracts/artifact.ts
2
+ import { z as z2 } from "zod";
3
+
4
+ // src/contracts/common.ts
5
+ import { z } from "zod";
6
+ var JsonValueSchema = z.lazy(
7
+ () => z.union([
8
+ z.string(),
9
+ z.number().finite(),
10
+ z.boolean(),
11
+ z.null(),
12
+ z.array(JsonValueSchema),
13
+ z.record(z.string(), JsonValueSchema)
14
+ ])
15
+ );
16
+ var JsonObjectSchema = z.record(z.string(), JsonValueSchema);
17
+ var ContractIdentifierSchema = z.string().trim().min(1).max(256);
18
+ var ContractVersionSchema = z.number().int().positive();
19
+ var IsoDateTimeSchema = z.string().datetime({ offset: true });
20
+ var Sha256Schema = z.string().regex(/^[a-f0-9]{64}$/i, "Expected a SHA-256 hex digest.");
21
+ var LocaleIdentifierSchema = z.string().regex(/^[a-z]{2,3}(?:-[A-Z][a-z]{3})?(?:-[A-Z]{2}|-\d{3})?$/, "Expected a BCP 47 locale identifier.");
22
+ var LocalizedTextSchema = z.union([
23
+ z.string().trim().min(1),
24
+ z.record(LocaleIdentifierSchema, z.string().trim().min(1)).refine((value) => Object.keys(value).length > 0, "Localized text must contain at least one locale.")
25
+ ]);
26
+ var ContractMetadataSchema = z.object({
27
+ id: ContractIdentifierSchema,
28
+ version: ContractVersionSchema,
29
+ name: z.string().trim().min(1).optional(),
30
+ description: z.string().optional(),
31
+ labels: z.record(z.string(), z.string()).optional(),
32
+ createdAt: IsoDateTimeSchema.optional(),
33
+ updatedAt: IsoDateTimeSchema.optional()
34
+ }).strict();
35
+ var EntityRefSchema = z.object({
36
+ kind: ContractIdentifierSchema,
37
+ id: ContractIdentifierSchema,
38
+ version: z.union([ContractVersionSchema, z.string().trim().min(1)]).optional(),
39
+ ownerRepo: ContractIdentifierSchema.optional()
40
+ }).strict();
41
+
42
+ // src/contracts/artifact.ts
43
+ var StorageLocatorSchema = z2.object({
44
+ provider: ContractIdentifierSchema,
45
+ bucket: ContractIdentifierSchema.optional(),
46
+ key: ContractIdentifierSchema,
47
+ region: ContractIdentifierSchema.optional(),
48
+ url: z2.string().url().optional(),
49
+ expiresAt: IsoDateTimeSchema.optional()
50
+ }).strict();
51
+ var ArtifactAccessSchema = z2.object({
52
+ tenantId: ContractIdentifierSchema.optional(),
53
+ teamId: ContractIdentifierSchema.optional(),
54
+ ownerRef: EntityRefSchema.optional(),
55
+ visibility: z2.enum(["private", "team", "tenant", "public"])
56
+ }).strict();
57
+ var ArtifactManifestSchema = z2.object({
58
+ contract: z2.literal("ArtifactManifest"),
59
+ artifactId: ContractIdentifierSchema,
60
+ kind: ContractIdentifierSchema,
61
+ mimeType: z2.string().trim().min(1),
62
+ byteSize: z2.number().int().nonnegative().optional(),
63
+ sha256: Sha256Schema,
64
+ storage: StorageLocatorSchema,
65
+ sourceRef: EntityRefSchema.optional(),
66
+ runRef: EntityRefSchema,
67
+ outputRef: EntityRefSchema,
68
+ producer: z2.object({
69
+ service: ContractIdentifierSchema,
70
+ version: ContractIdentifierSchema,
71
+ capabilityRef: EntityRefSchema.optional()
72
+ }).strict(),
73
+ access: ArtifactAccessSchema,
74
+ metadata: z2.record(z2.string(), JsonValueSchema).default({}),
75
+ createdAt: IsoDateTimeSchema
76
+ }).strict();
77
+ var OutputRecordSchema = z2.object({
78
+ contract: z2.literal("OutputRecord"),
79
+ outputId: ContractIdentifierSchema,
80
+ runRef: EntityRefSchema,
81
+ outputPort: ContractIdentifierSchema,
82
+ value: JsonValueSchema.optional(),
83
+ artifactRefs: z2.array(EntityRefSchema).default([]),
84
+ schemaRef: ContractIdentifierSchema.optional(),
85
+ createdAt: IsoDateTimeSchema
86
+ }).strict();
87
+
88
+ // src/contracts/capability.ts
89
+ import { z as z4 } from "zod";
90
+
91
+ // src/contracts/render.ts
92
+ import { z as z3 } from "zod";
93
+ var ProductContextSchema = z3.enum(["studio", "kernel", "compute"]);
94
+ var RenderNodeStateSchema = z3.enum([
95
+ "idle",
96
+ "loading",
97
+ "empty",
98
+ "error",
99
+ "success",
100
+ "disabled",
101
+ "selected"
102
+ ]);
103
+ var RenderNodeKindSchema = z3.enum([
104
+ "shell",
105
+ "page",
106
+ "navigation",
107
+ "view",
108
+ "record",
109
+ "control",
110
+ "detail",
111
+ "action",
112
+ "overlay",
113
+ "professional-provider"
114
+ ]);
115
+ var RenderSurfaceSchema = z3.object({
116
+ frameOwner: z3.enum(["host", "provider", "none"]),
117
+ tone: ContractIdentifierSchema.optional(),
118
+ density: z3.enum(["compact", "default", "comfortable"])
119
+ }).strict();
120
+ var RenderScrollSchema = z3.object({
121
+ owner: z3.enum(["page", "surface", "provider"]),
122
+ axis: z3.enum(["x", "y", "both", "none"]),
123
+ restoreKey: ContractIdentifierSchema.optional(),
124
+ virtualizationBoundary: z3.boolean()
125
+ }).strict().superRefine((scroll, context) => {
126
+ if (scroll.owner === "provider" && scroll.restoreKey) {
127
+ context.addIssue({
128
+ code: "custom",
129
+ path: ["restoreKey"],
130
+ message: "Provider-owned scroll state cannot declare a host restoreKey."
131
+ });
132
+ }
133
+ if (scroll.virtualizationBoundary && scroll.owner !== "provider") {
134
+ context.addIssue({
135
+ code: "custom",
136
+ path: ["owner"],
137
+ message: "A virtualization boundary must keep scroll ownership in the provider."
138
+ });
139
+ }
140
+ });
141
+ var RenderActivationSchema = z3.object({
142
+ activationId: ContractIdentifierSchema,
143
+ mode: z3.enum(["navigate", "select", "drawer", "modal", "fullscreen", "inline"]),
144
+ targetPath: z3.string().trim().regex(/^\/(?!\/)/, "Expected an application-relative path.").optional(),
145
+ history: z3.enum(["push", "replace"]).optional()
146
+ }).strict().superRefine((activation, context) => {
147
+ if (activation.mode === "navigate" && !activation.targetPath) {
148
+ context.addIssue({ code: "custom", path: ["targetPath"], message: "Navigate activation requires an application-relative targetPath." });
149
+ }
150
+ if (activation.mode !== "navigate" && activation.targetPath) {
151
+ context.addIssue({ code: "custom", path: ["targetPath"], message: "Only navigate activation may declare targetPath." });
152
+ }
153
+ });
154
+ var RenderLifecycleSchema = z3.object({
155
+ mountPolicy: z3.enum(["always", "when-visible", "when-active"]),
156
+ queryPolicy: z3.enum(["always", "when-visible", "when-active", "manual"]),
157
+ retainOnDeactivate: z3.boolean(),
158
+ deepLink: z3.boolean(),
159
+ focusReturn: z3.boolean()
160
+ }).strict();
161
+ var RenderLayoutSchema = z3.object({
162
+ mode: z3.enum(["contents", "block", "flex", "grid", "absolute"]),
163
+ direction: z3.enum(["row", "column"]).optional(),
164
+ columns: z3.number().int().positive().optional(),
165
+ align: z3.enum(["start", "center", "end", "stretch"]).optional(),
166
+ justify: z3.enum(["start", "center", "end", "between", "around"]).optional(),
167
+ gapTokenRef: EntityRefSchema.optional()
168
+ }).strict().superRefine((layout, context) => {
169
+ if (layout.direction && layout.mode !== "flex") {
170
+ context.addIssue({ code: "custom", path: ["direction"], message: "direction is only valid for flex layout." });
171
+ }
172
+ if (layout.columns && layout.mode !== "grid") {
173
+ context.addIssue({ code: "custom", path: ["columns"], message: "columns is only valid for grid layout." });
174
+ }
175
+ if (layout.gapTokenRef && layout.gapTokenRef.kind !== "design-token") {
176
+ context.addIssue({ code: "custom", path: ["gapTokenRef", "kind"], message: "gapTokenRef must reference design-token." });
177
+ }
178
+ });
179
+ var RenderResponsiveRuleSchema = z3.object({
180
+ minWidthPx: z3.number().nonnegative().optional(),
181
+ maxWidthPx: z3.number().positive().optional(),
182
+ layout: RenderLayoutSchema
183
+ }).strict().superRefine((rule, context) => {
184
+ if (rule.minWidthPx === void 0 && rule.maxWidthPx === void 0) {
185
+ context.addIssue({ code: "custom", path: [], message: "Responsive rule must declare minWidthPx or maxWidthPx." });
186
+ }
187
+ if (rule.minWidthPx !== void 0 && rule.maxWidthPx !== void 0 && rule.minWidthPx > rule.maxWidthPx) {
188
+ context.addIssue({ code: "custom", path: ["maxWidthPx"], message: "maxWidthPx must be greater than or equal to minWidthPx." });
189
+ }
190
+ });
191
+ var requireRef = (reference, expectedKind, path, context) => {
192
+ if (!reference) return;
193
+ if (reference.kind !== expectedKind) {
194
+ context.addIssue({
195
+ code: "custom",
196
+ path: [...path, "kind"],
197
+ message: `${path.join(".")} must reference ${expectedKind}.`
198
+ });
199
+ }
200
+ };
201
+ var requirePinnedOwnedRef = (reference, expectedKind, path, context) => {
202
+ requireRef(reference, expectedKind, path, context);
203
+ if (!reference) return;
204
+ if (reference.version === void 0) {
205
+ context.addIssue({
206
+ code: "custom",
207
+ path: [...path, "version"],
208
+ message: `${path.join(".")} must pin a version.`
209
+ });
210
+ }
211
+ if (reference.ownerRepo === void 0) {
212
+ context.addIssue({
213
+ code: "custom",
214
+ path: [...path, "ownerRepo"],
215
+ message: `${path.join(".")} must declare its owner repository.`
216
+ });
217
+ }
218
+ };
219
+ var RenderNodeSchema = z3.object({
220
+ contract: z3.literal("RenderNode"),
221
+ nodeId: ContractIdentifierSchema,
222
+ kind: RenderNodeKindSchema,
223
+ version: ContractVersionSchema,
224
+ ownerRepo: ContractIdentifierSchema,
225
+ parentNodeId: ContractIdentifierSchema.optional(),
226
+ children: z3.array(ContractIdentifierSchema),
227
+ slot: ContractIdentifierSchema.optional(),
228
+ pageRef: EntityRefSchema,
229
+ semanticRef: EntityRefSchema.optional(),
230
+ dataContextRef: EntityRefSchema.optional(),
231
+ capabilityRef: EntityRefSchema,
232
+ providerRef: EntityRefSchema.optional(),
233
+ stateRef: EntityRefSchema.optional(),
234
+ surface: RenderSurfaceSchema,
235
+ scroll: RenderScrollSchema,
236
+ activation: RenderActivationSchema,
237
+ lifecycle: RenderLifecycleSchema,
238
+ layout: RenderLayoutSchema,
239
+ responsive: z3.array(RenderResponsiveRuleSchema),
240
+ accessRef: EntityRefSchema.optional(),
241
+ evidenceRef: EntityRefSchema.optional(),
242
+ state: RenderNodeStateSchema,
243
+ renderModel: JsonObjectSchema
244
+ }).strict().superRefine((node, context) => {
245
+ requireRef(node.pageRef, "page", ["pageRef"], context);
246
+ requirePinnedOwnedRef(node.capabilityRef, "capability", ["capabilityRef"], context);
247
+ requirePinnedOwnedRef(node.providerRef, "view-provider", ["providerRef"], context);
248
+ requireRef(node.accessRef, "access-policy", ["accessRef"], context);
249
+ requireRef(node.evidenceRef, "evidence", ["evidenceRef"], context);
250
+ if (node.parentNodeId === node.nodeId) {
251
+ context.addIssue({
252
+ code: "custom",
253
+ path: ["parentNodeId"],
254
+ message: "RenderNode cannot be its own parent."
255
+ });
256
+ }
257
+ if (new Set(node.children).size !== node.children.length) {
258
+ context.addIssue({ code: "custom", path: ["children"], message: "RenderNode children must be unique." });
259
+ }
260
+ if (node.children.includes(node.nodeId)) {
261
+ context.addIssue({ code: "custom", path: ["children"], message: "RenderNode cannot be its own child." });
262
+ }
263
+ if (node.surface.frameOwner === "provider" && !node.providerRef) {
264
+ context.addIssue({
265
+ code: "custom",
266
+ path: ["providerRef"],
267
+ message: "Provider-owned surfaces require providerRef."
268
+ });
269
+ }
270
+ });
271
+ var RenderTreeSchema = z3.object({
272
+ contract: z3.literal("RenderTree"),
273
+ treeId: ContractIdentifierSchema,
274
+ product: ProductContextSchema,
275
+ rootNodeId: ContractIdentifierSchema,
276
+ nodes: z3.array(RenderNodeSchema).min(1)
277
+ }).strict();
278
+ var OverlayZIndexLaneSchema = z3.enum([
279
+ "popover",
280
+ "drawer",
281
+ "modal",
282
+ "fullscreen",
283
+ "system"
284
+ ]);
285
+ var OverlayNodeSchema = z3.object({
286
+ contract: z3.literal("OverlayNode"),
287
+ overlayId: ContractIdentifierSchema,
288
+ renderNode: RenderNodeSchema,
289
+ presentation: z3.enum(["drawer", "modal", "fullscreen"]),
290
+ zIndexLane: OverlayZIndexLaneSchema,
291
+ url: z3.object({
292
+ parameter: ContractIdentifierSchema,
293
+ value: ContractIdentifierSchema,
294
+ openMode: z3.enum(["push", "replace"]),
295
+ closeMode: z3.enum(["back", "replace"])
296
+ }).strict(),
297
+ focus: z3.object({
298
+ initial: z3.enum(["first-interactive", "container", "explicit"]),
299
+ trap: z3.boolean()
300
+ }).strict(),
301
+ close: z3.object({
302
+ escape: z3.boolean(),
303
+ backdrop: z3.boolean()
304
+ }).strict()
305
+ }).strict().superRefine((value, context) => {
306
+ if (value.renderNode.kind !== "overlay") {
307
+ context.addIssue({
308
+ code: "custom",
309
+ path: ["renderNode", "kind"],
310
+ message: "OverlayNode renderNode.kind must be overlay."
311
+ });
312
+ }
313
+ if (value.renderNode.activation.mode !== value.presentation) {
314
+ context.addIssue({
315
+ code: "custom",
316
+ path: ["renderNode", "activation", "mode"],
317
+ message: "OverlayNode presentation must match the RenderNode activation mode."
318
+ });
319
+ }
320
+ if (value.presentation === "drawer" && value.zIndexLane !== "drawer") {
321
+ context.addIssue({
322
+ code: "custom",
323
+ path: ["zIndexLane"],
324
+ message: "Drawer overlays must use the drawer z-index lane."
325
+ });
326
+ }
327
+ if (value.presentation === "modal" && value.zIndexLane !== "modal") {
328
+ context.addIssue({
329
+ code: "custom",
330
+ path: ["zIndexLane"],
331
+ message: "Modal overlays must use the modal z-index lane."
332
+ });
333
+ }
334
+ if (value.presentation === "fullscreen" && value.zIndexLane !== "fullscreen" && value.zIndexLane !== "system") {
335
+ context.addIssue({
336
+ code: "custom",
337
+ path: ["zIndexLane"],
338
+ message: "Fullscreen overlays must use the fullscreen or system z-index lane."
339
+ });
340
+ }
341
+ });
342
+ var ProductPathSchema = z3.string().trim().regex(/^\/(?!\/)/, "Expected an application-relative path.");
343
+ var ApplicationHandoffEndpointSchema = z3.object({
344
+ product: ProductContextSchema,
345
+ pageId: ContractIdentifierSchema,
346
+ viewId: ContractIdentifierSchema.optional(),
347
+ objectRef: EntityRefSchema.optional(),
348
+ runtimeRef: EntityRefSchema.optional(),
349
+ activationId: ContractIdentifierSchema.optional(),
350
+ path: ProductPathSchema
351
+ }).strict();
352
+ var ApplicationHandoffSchema = z3.object({
353
+ contract: z3.literal("ApplicationHandoff"),
354
+ handoffId: ContractIdentifierSchema,
355
+ source: ApplicationHandoffEndpointSchema,
356
+ target: ApplicationHandoffEndpointSchema,
357
+ returnTarget: ApplicationHandoffEndpointSchema.optional(),
358
+ traceId: ContractIdentifierSchema.optional(),
359
+ createdAt: IsoDateTimeSchema
360
+ }).strict().superRefine((value, context) => {
361
+ if (value.source.product === value.target.product && value.source.pageId === value.target.pageId) {
362
+ context.addIssue({
363
+ code: "custom",
364
+ path: ["target"],
365
+ message: "ApplicationHandoff target must identify a different product page."
366
+ });
367
+ }
368
+ });
369
+ var ViewProviderDescriptorSchema = z3.object({
370
+ contract: z3.literal("ViewProviderDescriptor"),
371
+ providerId: ContractIdentifierSchema,
372
+ providerVersion: ContractIdentifierSchema,
373
+ ownerRepo: ContractIdentifierSchema,
374
+ capabilityRef: EntityRefSchema,
375
+ rendererKey: ContractIdentifierSchema,
376
+ renderModelSchemaRef: ContractIdentifierSchema,
377
+ intentSchemaRef: ContractIdentifierSchema.optional(),
378
+ loading: z3.enum(["eager", "lazy", "viewport", "on-activation"]),
379
+ stateOwner: z3.enum(["host", "provider", "external"]),
380
+ supportedPageTypes: z3.array(ContractIdentifierSchema).min(1),
381
+ supportedSurfaces: z3.array(z3.enum(["page", "workspace", "view", "record", "action", "overlay", "agent"])).min(1),
382
+ frameOwner: z3.enum(["host", "provider", "none"]),
383
+ sideEffects: z3.array(z3.enum(["network", "storage", "navigation", "worker", "websocket"])),
384
+ sideEffectAdapterRef: EntityRefSchema.optional(),
385
+ lifecycle: z3.object({
386
+ preserveMount: z3.boolean(),
387
+ preserveScroll: z3.boolean(),
388
+ focusModel: ContractIdentifierSchema
389
+ }).strict(),
390
+ performance: z3.object({
391
+ lazy: z3.boolean(),
392
+ virtualized: z3.boolean(),
393
+ budgetMs: z3.number().positive().optional()
394
+ }).strict(),
395
+ accessRef: EntityRefSchema.optional(),
396
+ evidenceRef: EntityRefSchema.optional()
397
+ }).strict().superRefine((provider, context) => {
398
+ requirePinnedOwnedRef(provider.capabilityRef, "capability", ["capabilityRef"], context);
399
+ requirePinnedOwnedRef(provider.sideEffectAdapterRef, "side-effect-adapter", ["sideEffectAdapterRef"], context);
400
+ requireRef(provider.accessRef, "access-policy", ["accessRef"], context);
401
+ requireRef(provider.evidenceRef, "evidence", ["evidenceRef"], context);
402
+ if (provider.capabilityRef.version === void 0) {
403
+ context.addIssue({
404
+ code: "custom",
405
+ path: ["capabilityRef", "version"],
406
+ message: "Provider capabilityRef must pin an active capability version."
407
+ });
408
+ }
409
+ if (provider.frameOwner === "provider" && provider.stateOwner === "host" && !provider.lifecycle.preserveMount) {
410
+ context.addIssue({
411
+ code: "custom",
412
+ path: ["lifecycle", "preserveMount"],
413
+ message: "Host-owned state on a provider-owned frame must preserve the provider mount."
414
+ });
415
+ }
416
+ if (provider.sideEffects.length > 0 && !provider.sideEffectAdapterRef) {
417
+ context.addIssue({ code: "custom", path: ["sideEffectAdapterRef"], message: "Providers with side effects require a pinned side-effect adapter." });
418
+ }
419
+ if (provider.sideEffects.length === 0 && provider.sideEffectAdapterRef) {
420
+ context.addIssue({ code: "custom", path: ["sideEffectAdapterRef"], message: "Pure providers cannot declare a side-effect adapter." });
421
+ }
422
+ });
423
+
424
+ // src/contracts/capability.ts
425
+ var ContractPortSchema = z4.object({
426
+ name: ContractIdentifierSchema,
427
+ schemaRef: ContractIdentifierSchema,
428
+ required: z4.boolean().default(false),
429
+ multiple: z4.boolean().default(false),
430
+ description: z4.string().optional()
431
+ }).strict();
432
+ var CapabilityProviderBindingSchema = z4.object({
433
+ providerRef: EntityRefSchema,
434
+ productContexts: z4.array(ProductContextSchema).default([]),
435
+ priority: z4.number().int().default(0)
436
+ }).strict();
437
+ var CapabilityManifestSchema = z4.object({
438
+ contract: z4.literal("CapabilityManifest"),
439
+ id: ContractIdentifierSchema,
440
+ capabilityVersion: ContractIdentifierSchema,
441
+ ownerRepo: ContractIdentifierSchema,
442
+ kind: z4.enum(["primitive", "composite", "view", "professional-provider", "tool", "workflow"]),
443
+ displayName: z4.string().trim().min(1),
444
+ description: z4.string().optional(),
445
+ ports: z4.object({
446
+ inputs: z4.array(ContractPortSchema).default([]),
447
+ outputs: z4.array(ContractPortSchema).default([])
448
+ }).strict(),
449
+ runtime: z4.object({
450
+ providerBindings: z4.array(CapabilityProviderBindingSchema).min(1),
451
+ loading: z4.enum(["eager", "lazy", "viewport", "on-activation"]),
452
+ fallbackCapabilityRef: EntityRefSchema.optional(),
453
+ stateOwner: z4.enum(["host", "provider", "external"]),
454
+ stateSchemaRef: ContractIdentifierSchema.optional(),
455
+ sideEffects: z4.array(z4.enum(["network", "storage", "navigation", "worker", "websocket"])).default([])
456
+ }).strict(),
457
+ placement: z4.object({
458
+ surfaces: z4.array(ContractIdentifierSchema).min(1),
459
+ slots: z4.array(ContractIdentifierSchema).default([]),
460
+ variants: z4.array(ContractIdentifierSchema).default([]),
461
+ tokenRefs: z4.array(ContractIdentifierSchema).default([])
462
+ }).strict(),
463
+ accessibility: z4.object({
464
+ keyboardModel: ContractIdentifierSchema,
465
+ focusModel: ContractIdentifierSchema,
466
+ labelContract: ContractIdentifierSchema
467
+ }).strict(),
468
+ observability: z4.object({
469
+ eventNamespace: ContractIdentifierSchema,
470
+ metrics: z4.array(ContractIdentifierSchema).default([]),
471
+ evidenceRefs: z4.array(ContractIdentifierSchema).default([]),
472
+ performanceBudgetMs: z4.number().positive().optional()
473
+ }).strict()
474
+ }).strict().superRefine((manifest, context) => {
475
+ const providerIds = /* @__PURE__ */ new Set();
476
+ manifest.runtime.providerBindings.forEach((binding, index) => {
477
+ const providerIdentity = `${binding.providerRef.kind}:${binding.providerRef.id}@${String(binding.providerRef.version)}:${binding.providerRef.ownerRepo ?? ""}`;
478
+ if (providerIds.has(providerIdentity)) {
479
+ context.addIssue({ code: "custom", path: ["runtime", "providerBindings", index], message: `Duplicate capability provider binding: ${providerIdentity}` });
480
+ }
481
+ providerIds.add(providerIdentity);
482
+ if (!["view", "professional-provider"].includes(manifest.kind)) return;
483
+ if (binding.providerRef.kind !== "view-provider") {
484
+ context.addIssue({ code: "custom", path: ["runtime", "providerBindings", index, "providerRef", "kind"], message: "View capabilities must resolve to view providers." });
485
+ }
486
+ if (binding.providerRef.version === void 0) {
487
+ context.addIssue({ code: "custom", path: ["runtime", "providerBindings", index, "providerRef", "version"], message: "View capability providers must pin a provider version." });
488
+ }
489
+ if (binding.providerRef.ownerRepo === void 0) {
490
+ context.addIssue({ code: "custom", path: ["runtime", "providerBindings", index, "providerRef", "ownerRepo"], message: "View capability providers must declare their owner repository." });
491
+ }
492
+ });
493
+ });
494
+ var CapabilitySourceTypeSchema = z4.enum([
495
+ "tool-manifest",
496
+ "plugin-manifest",
497
+ "openapi",
498
+ "workflow",
499
+ "comfyui"
500
+ ]);
501
+ var CapabilityRegistrySourceSchema = z4.object({
502
+ sourceType: CapabilitySourceTypeSchema,
503
+ sourceId: ContractIdentifierSchema,
504
+ ownerRepo: ContractIdentifierSchema
505
+ }).strict();
506
+ var CapabilityRegistryEntrySchema = z4.object({
507
+ manifest: CapabilityManifestSchema,
508
+ sources: z4.array(CapabilityRegistrySourceSchema).min(1)
509
+ }).strict();
510
+ var CapabilityRegistryDocumentSchema = z4.object({
511
+ contract: z4.literal("CapabilityRegistry"),
512
+ entries: z4.array(CapabilityRegistryEntrySchema)
513
+ }).strict().superRefine((registry, context) => {
514
+ const ids = /* @__PURE__ */ new Set();
515
+ registry.entries.forEach((entry, index) => {
516
+ if (ids.has(entry.manifest.id)) {
517
+ context.addIssue({
518
+ code: "custom",
519
+ path: ["entries", index, "manifest", "id"],
520
+ message: `Duplicate capability id: ${entry.manifest.id}`
521
+ });
522
+ }
523
+ ids.add(entry.manifest.id);
524
+ });
525
+ });
526
+
527
+ // src/contracts/context.ts
528
+ import { z as z5 } from "zod";
529
+ var ActorRefSchema = z5.object({
530
+ kind: z5.enum(["human", "agent", "service", "tenant", "public"]),
531
+ id: ContractIdentifierSchema.optional(),
532
+ userId: ContractIdentifierSchema.optional(),
533
+ agentId: ContractIdentifierSchema.optional(),
534
+ serviceId: ContractIdentifierSchema.optional()
535
+ }).strict();
536
+ var AuthorityScopeSchema = z5.object({
537
+ resource: ContractIdentifierSchema,
538
+ actions: z5.array(ContractIdentifierSchema).min(1),
539
+ constraints: z5.record(z5.string(), JsonValueSchema).optional()
540
+ }).strict();
541
+ var RequestScopeSchema = z5.object({
542
+ contract: z5.literal("RequestScope"),
543
+ requestId: ContractIdentifierSchema,
544
+ traceId: ContractIdentifierSchema.optional(),
545
+ appId: ContractIdentifierSchema,
546
+ tenantId: ContractIdentifierSchema.optional(),
547
+ teamId: ContractIdentifierSchema.optional(),
548
+ actor: ActorRefSchema,
549
+ session: z5.object({
550
+ authType: ContractIdentifierSchema,
551
+ authenticated: z5.boolean(),
552
+ membershipVerified: z5.boolean()
553
+ }).strict(),
554
+ permissionCodes: z5.array(ContractIdentifierSchema).default([]),
555
+ authority: z5.array(AuthorityScopeSchema).default([]),
556
+ issuedAt: IsoDateTimeSchema
557
+ }).strict();
558
+ var ExecutionLinkSchema = z5.object({
559
+ contract: z5.literal("ExecutionLink"),
560
+ requestId: ContractIdentifierSchema,
561
+ traceId: ContractIdentifierSchema.optional(),
562
+ correlationId: ContractIdentifierSchema.optional(),
563
+ causationId: ContractIdentifierSchema.optional(),
564
+ workflowRef: EntityRefSchema.optional(),
565
+ runRef: EntityRefSchema,
566
+ taskRef: EntityRefSchema.optional(),
567
+ parentRunRef: EntityRefSchema.optional()
568
+ }).strict();
569
+ var CompletionHeaderSchema = z5.object({
570
+ contract: z5.literal("CompletionHeader"),
571
+ eventId: ContractIdentifierSchema,
572
+ runtimeEventId: ContractIdentifierSchema,
573
+ idempotencyKey: ContractIdentifierSchema,
574
+ sequence: z5.number().int().nonnegative(),
575
+ execution: ExecutionLinkSchema,
576
+ producer: z5.object({
577
+ service: ContractIdentifierSchema,
578
+ runtime: ContractIdentifierSchema,
579
+ version: ContractIdentifierSchema
580
+ }).strict(),
581
+ status: z5.enum(["SUCCEEDED", "FAILED", "CANCELLED", "TIMED_OUT"]),
582
+ occurredAt: IsoDateTimeSchema,
583
+ payloadSchemaRef: ContractIdentifierSchema.optional()
584
+ }).strict();
585
+ var CompletionEventSchema = z5.object({
586
+ header: CompletionHeaderSchema,
587
+ payload: JsonValueSchema.optional()
588
+ }).strict();
589
+ var AgentRuntimeEventSchema = z5.object({
590
+ contract: z5.literal("AgentRuntimeEvent"),
591
+ runtimeEventId: ContractIdentifierSchema,
592
+ streamId: ContractIdentifierSchema,
593
+ sequence: z5.number().int().nonnegative(),
594
+ requestId: ContractIdentifierSchema,
595
+ teamId: ContractIdentifierSchema,
596
+ threadId: ContractIdentifierSchema.optional(),
597
+ eventType: z5.enum(["messages:append", "messages:update", "thread:update", "tool-call:upsert"]),
598
+ payload: JsonValueSchema,
599
+ occurredAt: IsoDateTimeSchema
600
+ }).strict();
601
+
602
+ // src/contracts/continuity.ts
603
+ import { z as z6 } from "zod";
604
+ var DataContinuityEnvelopeSchema = z6.object({
605
+ contract: z6.literal("DataContinuityEnvelope"),
606
+ tenantId: ContractIdentifierSchema,
607
+ teamId: ContractIdentifierSchema,
608
+ sourceRef: EntityRefSchema.optional(),
609
+ bodyRef: EntityRefSchema.optional(),
610
+ runRef: EntityRefSchema.optional(),
611
+ outputRef: EntityRefSchema.optional(),
612
+ artifactRef: EntityRefSchema.optional(),
613
+ requestId: ContractIdentifierSchema,
614
+ actorRef: EntityRefSchema,
615
+ schemaVersion: ContractVersionSchema
616
+ }).strict().refine(
617
+ (value) => Boolean(value.sourceRef || value.bodyRef || value.runRef || value.outputRef || value.artifactRef),
618
+ "At least one continuity ref is required."
619
+ );
620
+ var BodyRelationRecordSchema = z6.object({
621
+ contract: z6.literal("BodyRelationRecord"),
622
+ relationId: ContractIdentifierSchema,
623
+ relationKind: ContractIdentifierSchema,
624
+ subjectRef: EntityRefSchema,
625
+ objectRef: EntityRefSchema,
626
+ ownerRepo: ContractIdentifierSchema,
627
+ authorityScope: z6.enum(["tenant", "team", "global"]),
628
+ properties: JsonObjectSchema.default({}),
629
+ createdAt: IsoDateTimeSchema,
630
+ updatedAt: IsoDateTimeSchema
631
+ }).strict();
632
+ var ApplicationRunSchema = z6.object({
633
+ contract: z6.literal("ApplicationRun"),
634
+ runId: ContractIdentifierSchema,
635
+ definitionRef: EntityRefSchema,
636
+ runtimeLedgerRef: EntityRefSchema,
637
+ requestId: ContractIdentifierSchema,
638
+ actorRef: EntityRefSchema,
639
+ status: z6.enum(["PENDING", "RUNNING", "COMPLETED", "FAILED", "CANCELLED", "EXPIRED"]),
640
+ inputRefs: z6.array(EntityRefSchema).default([]),
641
+ outputRefs: z6.array(EntityRefSchema).default([]),
642
+ startedAt: IsoDateTimeSchema.optional(),
643
+ completedAt: IsoDateTimeSchema.optional(),
644
+ expiresAt: IsoDateTimeSchema.optional(),
645
+ metadata: JsonObjectSchema.default({})
646
+ }).strict();
647
+ var ExpiringAccessGrantSchema = z6.object({
648
+ contract: z6.literal("ExpiringAccessGrant"),
649
+ grantId: ContractIdentifierSchema,
650
+ subjectRef: EntityRefSchema,
651
+ resourceRef: EntityRefSchema,
652
+ permissions: z6.array(ContractIdentifierSchema).min(1),
653
+ issuedAt: IsoDateTimeSchema,
654
+ expiresAt: IsoDateTimeSchema,
655
+ revokedAt: IsoDateTimeSchema.optional()
656
+ }).strict().refine((value) => Date.parse(value.expiresAt) > Date.parse(value.issuedAt), "expiresAt must be after issuedAt");
657
+
658
+ // src/contracts/data.ts
659
+ import { z as z7 } from "zod";
660
+ var SourceRecordRefSchema = z7.object({
661
+ sourceId: ContractIdentifierSchema,
662
+ recordId: ContractIdentifierSchema,
663
+ recordVersion: z7.union([z7.number().int().nonnegative(), ContractIdentifierSchema]),
664
+ hash: Sha256Schema
665
+ }).strict();
666
+ var OntologyDefinitionSchema = z7.object({
667
+ contract: z7.literal("OntologyDefinition"),
668
+ ontologyId: ContractIdentifierSchema,
669
+ dataSpaceId: ContractIdentifierSchema,
670
+ ownerRepo: ContractIdentifierSchema,
671
+ bodySchemaRef: ContractIdentifierSchema,
672
+ authority: z7.object({
673
+ service: ContractIdentifierSchema,
674
+ storage: ContractIdentifierSchema,
675
+ scope: z7.enum(["tenant", "team", "user", "global"])
676
+ }).strict(),
677
+ relationKinds: z7.array(ContractIdentifierSchema).default([]),
678
+ metricKinds: z7.array(ContractIdentifierSchema).default([])
679
+ }).strict();
680
+ var ProjectionSpecSchema = z7.object({
681
+ contract: z7.literal("ProjectionSpec"),
682
+ projectionId: ContractIdentifierSchema,
683
+ ontologyIds: z7.array(ContractIdentifierSchema).min(1),
684
+ outputSchemaRef: ContractIdentifierSchema,
685
+ operator: z7.object({
686
+ kind: z7.enum(["query", "aggregate", "relationship", "search", "custom"]),
687
+ configuration: z7.record(z7.string(), JsonValueSchema).default({})
688
+ }).strict(),
689
+ materialization: z7.enum(["on-demand", "event-driven", "scheduled"]),
690
+ invalidationEvents: z7.array(ContractIdentifierSchema).default([]),
691
+ rebuildable: z7.literal(true),
692
+ lineagePolicy: z7.object({
693
+ sourceRecords: z7.boolean(),
694
+ bodyVersions: z7.boolean(),
695
+ runRefs: z7.boolean(),
696
+ actorRefs: z7.boolean()
697
+ }).strict()
698
+ }).strict();
699
+ var LineageRecordSchema = z7.object({
700
+ contract: z7.literal("LineageRecord"),
701
+ lineageId: ContractIdentifierSchema,
702
+ subjectRef: EntityRefSchema,
703
+ sourceRecords: z7.array(SourceRecordRefSchema).default([]),
704
+ bodyRefs: z7.array(EntityRefSchema).default([]),
705
+ runRefs: z7.array(EntityRefSchema).default([]),
706
+ outputRefs: z7.array(EntityRefSchema).default([]),
707
+ artifactRefs: z7.array(EntityRefSchema).default([]),
708
+ actorRefs: z7.array(EntityRefSchema).default([]),
709
+ evidenceRefs: z7.array(EntityRefSchema).default([]),
710
+ recordedAt: IsoDateTimeSchema
711
+ }).strict();
712
+ var DomainEventSchema = z7.object({
713
+ contract: z7.literal("DomainEvent"),
714
+ eventId: ContractIdentifierSchema,
715
+ eventType: ContractIdentifierSchema,
716
+ aggregateRef: EntityRefSchema,
717
+ aggregateVersion: z7.number().int().nonnegative(),
718
+ requestId: ContractIdentifierSchema,
719
+ actorRef: EntityRefSchema,
720
+ payload: JsonValueSchema,
721
+ occurredAt: IsoDateTimeSchema
722
+ }).strict();
723
+
724
+ // src/contracts/page.ts
725
+ import { z as z8 } from "zod";
726
+ var PageTypeSchema = z8.enum([
727
+ "page",
728
+ "workspace",
729
+ "view",
730
+ "record",
731
+ "action",
732
+ "overlay",
733
+ "agent",
734
+ "process",
735
+ "log",
736
+ "chat",
737
+ "preview",
738
+ "api",
739
+ "enhanced",
740
+ "agent-chat",
741
+ "agent-config",
742
+ "agent-log",
743
+ "design-board",
744
+ "global-design-board",
745
+ "iframe"
746
+ ]);
747
+ var PageVisibilitySchema = z8.object({
748
+ authenticated: z8.boolean().default(true),
749
+ permissionAllOf: z8.array(ContractIdentifierSchema).default([]),
750
+ permissionAnyOf: z8.array(ContractIdentifierSchema).default([]),
751
+ featureFlags: z8.array(ContractIdentifierSchema).default([]),
752
+ productContexts: z8.array(z8.enum(["studio", "kernel", "compute"])).min(1)
753
+ }).strict();
754
+ var PageRoutePathSchema = z8.string().trim().regex(/^\/(?!\/)/, "Expected an application-relative route path.");
755
+ var requireCapabilityReference = (reference, path, context) => {
756
+ if (reference.kind !== "capability") {
757
+ context.addIssue({
758
+ code: "custom",
759
+ path: [...path, "kind"],
760
+ message: "Page capability references must use kind capability."
761
+ });
762
+ }
763
+ if (reference.version === void 0) {
764
+ context.addIssue({
765
+ code: "custom",
766
+ path: [...path, "version"],
767
+ message: "Page capability references must pin an active capability version."
768
+ });
769
+ }
770
+ if (reference.ownerRepo === void 0) {
771
+ context.addIssue({
772
+ code: "custom",
773
+ path: [...path, "ownerRepo"],
774
+ message: "Page capability references must declare their owner repository."
775
+ });
776
+ }
777
+ };
778
+ var PageDefinitionSchema = z8.object({
779
+ contract: z8.literal("PageDefinition"),
780
+ pageId: ContractIdentifierSchema,
781
+ ownerRepo: ContractIdentifierSchema,
782
+ title: LocalizedTextSchema,
783
+ pageType: PageTypeSchema,
784
+ ownership: z8.object({
785
+ teamId: ContractIdentifierSchema.optional(),
786
+ creatorRef: EntityRefSchema.optional(),
787
+ studioId: ContractIdentifierSchema.optional(),
788
+ builtIn: z8.boolean()
789
+ }).strict(),
790
+ record: z8.object({
791
+ createdTimestamp: z8.number().int().nonnegative().optional(),
792
+ updatedTimestamp: z8.number().int().nonnegative().optional(),
793
+ deleted: z8.boolean().default(false)
794
+ }).strict(),
795
+ surface: z8.enum(["page", "workspace", "view", "record", "action", "overlay", "agent"]),
796
+ routeId: ContractIdentifierSchema,
797
+ routePath: PageRoutePathSchema,
798
+ rendererKey: ContractIdentifierSchema,
799
+ capabilityRef: EntityRefSchema,
800
+ capabilityRefs: z8.array(EntityRefSchema).default([]),
801
+ workflowRef: EntityRefSchema.optional(),
802
+ binding: z8.object({
803
+ sourceRef: ContractIdentifierSchema.optional(),
804
+ ontologyId: ContractIdentifierSchema.optional(),
805
+ projectionRef: ContractIdentifierSchema.optional(),
806
+ stateRef: ContractIdentifierSchema.optional()
807
+ }).strict(),
808
+ access: z8.object({
809
+ actions: z8.array(z8.enum(["read", "write", "execute", "manage-permissions"])).default([])
810
+ }).strict(),
811
+ rendererConfig: z8.object({
812
+ schemaRef: ContractIdentifierSchema,
813
+ value: JsonObjectSchema
814
+ }).strict(),
815
+ navigation: z8.object({
816
+ label: LocalizedTextSchema,
817
+ iconRef: ContractIdentifierSchema.optional(),
818
+ parentPageId: ContractIdentifierSchema.optional(),
819
+ order: z8.number().int().optional(),
820
+ hidden: z8.boolean().default(false),
821
+ pinned: z8.boolean().default(false)
822
+ }).strict(),
823
+ visibility: PageVisibilitySchema
824
+ }).strict().superRefine((page, context) => {
825
+ const capabilities = [page.capabilityRef, ...page.capabilityRefs];
826
+ const capabilityIdentities = /* @__PURE__ */ new Set();
827
+ capabilities.forEach((reference, index) => {
828
+ const path = index === 0 ? ["capabilityRef"] : ["capabilityRefs", index - 1];
829
+ requireCapabilityReference(reference, path, context);
830
+ const identity = `${reference.id}@${String(reference.version)}:${reference.ownerRepo ?? ""}`;
831
+ if (capabilityIdentities.has(identity)) {
832
+ context.addIssue({
833
+ code: "custom",
834
+ path,
835
+ message: `Duplicate page capability reference: ${identity}`
836
+ });
837
+ }
838
+ capabilityIdentities.add(identity);
839
+ });
840
+ if (page.workflowRef && page.workflowRef.kind !== "workflow") context.addIssue({ code: "custom", path: ["workflowRef", "kind"], message: "workflowRef must reference a workflow." });
841
+ });
842
+ var PageRuntimeDescriptorSchema = z8.object({
843
+ contract: z8.literal("PageRuntimeDescriptor"),
844
+ page: PageDefinitionSchema,
845
+ nodeId: ContractIdentifierSchema,
846
+ parentNodeId: ContractIdentifierSchema.optional(),
847
+ slot: ContractIdentifierSchema.optional(),
848
+ semanticRef: ContractIdentifierSchema.optional(),
849
+ dataContextRef: ContractIdentifierSchema.optional(),
850
+ providerRef: EntityRefSchema.optional(),
851
+ surface: z8.object({
852
+ frameOwner: ContractIdentifierSchema,
853
+ tone: ContractIdentifierSchema.optional(),
854
+ density: z8.enum(["compact", "default", "comfortable"]).default("default")
855
+ }).strict(),
856
+ scroll: z8.object({
857
+ owner: z8.enum(["page", "surface", "provider"]),
858
+ axis: z8.enum(["x", "y", "both", "none"]),
859
+ restoreKey: ContractIdentifierSchema.optional(),
860
+ virtualized: z8.boolean().default(false)
861
+ }).strict(),
862
+ activation: z8.enum(["navigate", "select", "drawer", "modal", "fullscreen"]),
863
+ lifecycle: z8.object({
864
+ mountPolicy: z8.enum(["always", "when-visible", "when-active"]),
865
+ queryPolicy: z8.enum(["always", "when-visible", "when-active", "manual"]),
866
+ deepLink: z8.boolean(),
867
+ focusReturn: z8.boolean()
868
+ }).strict()
869
+ }).strict();
870
+ var PageRouteProjectionSchema = z8.object({
871
+ pageId: ContractIdentifierSchema,
872
+ routeId: ContractIdentifierSchema,
873
+ path: PageRoutePathSchema
874
+ }).strict();
875
+ var PageNavigationProjectionSchema = z8.object({
876
+ pageId: ContractIdentifierSchema,
877
+ routeId: ContractIdentifierSchema,
878
+ path: PageRoutePathSchema,
879
+ label: LocalizedTextSchema,
880
+ iconRef: ContractIdentifierSchema.optional(),
881
+ parentPageId: ContractIdentifierSchema.optional(),
882
+ order: z8.number().int().optional(),
883
+ pinned: z8.boolean()
884
+ }).strict();
885
+ var PageGuardProjectionSchema = z8.object({
886
+ pageId: ContractIdentifierSchema,
887
+ authenticated: z8.boolean(),
888
+ permissionAllOf: z8.array(ContractIdentifierSchema),
889
+ permissionAnyOf: z8.array(ContractIdentifierSchema),
890
+ featureFlags: z8.array(ContractIdentifierSchema),
891
+ actions: z8.array(z8.enum(["read", "write", "execute", "manage-permissions"]))
892
+ }).strict();
893
+ var PageRendererProjectionSchema = z8.object({
894
+ pageId: ContractIdentifierSchema,
895
+ surface: z8.enum(["page", "workspace", "view", "record", "action", "overlay", "agent"]),
896
+ rendererKey: ContractIdentifierSchema,
897
+ capabilityRef: EntityRefSchema,
898
+ capabilityRefs: z8.array(EntityRefSchema),
899
+ providerRef: EntityRefSchema,
900
+ binding: PageDefinitionSchema.shape.binding,
901
+ rendererConfig: PageDefinitionSchema.shape.rendererConfig,
902
+ workflowRef: EntityRefSchema.optional()
903
+ }).strict().superRefine((renderer, context) => {
904
+ requireCapabilityReference(renderer.capabilityRef, ["capabilityRef"], context);
905
+ renderer.capabilityRefs.forEach((reference, index) => {
906
+ requireCapabilityReference(reference, ["capabilityRefs", index], context);
907
+ });
908
+ if (renderer.providerRef.kind !== "view-provider") {
909
+ context.addIssue({
910
+ code: "custom",
911
+ path: ["providerRef", "kind"],
912
+ message: "Renderer providerRef must use kind view-provider."
913
+ });
914
+ }
915
+ if (renderer.providerRef.version === void 0) {
916
+ context.addIssue({
917
+ code: "custom",
918
+ path: ["providerRef", "version"],
919
+ message: "Renderer providerRef must pin a provider version."
920
+ });
921
+ }
922
+ if (renderer.providerRef.ownerRepo === void 0) {
923
+ context.addIssue({
924
+ code: "custom",
925
+ path: ["providerRef", "ownerRepo"],
926
+ message: "Renderer providerRef must declare its owner repository."
927
+ });
928
+ }
929
+ });
930
+ var duplicateProjectionIdentity = (values, identity) => {
931
+ const seen = /* @__PURE__ */ new Set();
932
+ for (const value of values) {
933
+ const key = identity(value);
934
+ if (seen.has(key)) return key;
935
+ seen.add(key);
936
+ }
937
+ return void 0;
938
+ };
939
+ var PageRuntimeProjectionSchema = z8.object({
940
+ contract: z8.literal("PageRuntimeProjection"),
941
+ product: z8.enum(["studio", "kernel", "compute"]),
942
+ routes: z8.array(PageRouteProjectionSchema),
943
+ navigation: z8.array(PageNavigationProjectionSchema),
944
+ guards: z8.array(PageGuardProjectionSchema),
945
+ renderers: z8.array(PageRendererProjectionSchema)
946
+ }).strict().superRefine((projection, context) => {
947
+ const tables = [
948
+ ["routes", projection.routes.map((value) => value.pageId)],
949
+ ["navigation", projection.navigation.map((value) => value.pageId)],
950
+ ["guards", projection.guards.map((value) => value.pageId)],
951
+ ["renderers", projection.renderers.map((value) => value.pageId)]
952
+ ];
953
+ for (const [table, values] of tables) {
954
+ const duplicate = duplicateProjectionIdentity(values, (value) => value);
955
+ if (duplicate) {
956
+ context.addIssue({ code: "custom", path: [table], message: `Duplicate ${table} pageId: ${duplicate}` });
957
+ }
958
+ }
959
+ for (const identity of [
960
+ ["routeId", duplicateProjectionIdentity(projection.routes, (route) => route.routeId)],
961
+ ["path", duplicateProjectionIdentity(projection.routes, (route) => route.path)]
962
+ ]) {
963
+ if (identity[1]) {
964
+ context.addIssue({ code: "custom", path: ["routes"], message: `Duplicate route ${identity[0]}: ${identity[1]}` });
965
+ }
966
+ }
967
+ const routesByPageId = new Map(projection.routes.map((route) => [route.pageId, route]));
968
+ const guardPageIds = new Set(projection.guards.map((guard) => guard.pageId));
969
+ const rendererPageIds = new Set(projection.renderers.map((renderer) => renderer.pageId));
970
+ for (const route of projection.routes) {
971
+ if (!guardPageIds.has(route.pageId)) {
972
+ context.addIssue({ code: "custom", path: ["guards"], message: `Missing guard projection for ${route.pageId}.` });
973
+ }
974
+ if (!rendererPageIds.has(route.pageId)) {
975
+ context.addIssue({ code: "custom", path: ["renderers"], message: `Missing renderer projection for ${route.pageId}.` });
976
+ }
977
+ }
978
+ for (const guard of projection.guards) {
979
+ if (!routesByPageId.has(guard.pageId)) {
980
+ context.addIssue({ code: "custom", path: ["guards"], message: `Guard references unknown page ${guard.pageId}.` });
981
+ }
982
+ }
983
+ for (const renderer of projection.renderers) {
984
+ if (!routesByPageId.has(renderer.pageId)) {
985
+ context.addIssue({ code: "custom", path: ["renderers"], message: `Renderer references unknown page ${renderer.pageId}.` });
986
+ }
987
+ }
988
+ for (const navigation of projection.navigation) {
989
+ const route = routesByPageId.get(navigation.pageId);
990
+ if (!route || route.routeId !== navigation.routeId || route.path !== navigation.path) {
991
+ context.addIssue({
992
+ code: "custom",
993
+ path: ["navigation"],
994
+ message: `Navigation route projection for ${navigation.pageId} does not match its route table entry.`
995
+ });
996
+ }
997
+ }
998
+ });
999
+
1000
+ // src/contracts/semantic.ts
1001
+ import { z as z9 } from "zod";
1002
+ var ConceptRelationshipSchema = z9.object({
1003
+ kind: ContractIdentifierSchema,
1004
+ targetConceptId: ContractIdentifierSchema,
1005
+ cardinality: z9.enum(["one", "optional", "many"])
1006
+ }).strict();
1007
+ var ConceptDefinitionSchema = z9.object({
1008
+ contract: z9.literal("ConceptDefinition"),
1009
+ conceptId: ContractIdentifierSchema,
1010
+ ownerRepo: ContractIdentifierSchema,
1011
+ displayName: z9.string().trim().min(1),
1012
+ description: z9.string().optional(),
1013
+ schemaRef: ContractIdentifierSchema,
1014
+ ontologyId: ContractIdentifierSchema.optional(),
1015
+ capabilityIds: z9.array(ContractIdentifierSchema).default([]),
1016
+ commandNames: z9.array(ContractIdentifierSchema).default([]),
1017
+ relationships: z9.array(ConceptRelationshipSchema).default([])
1018
+ }).strict();
1019
+ var DomainCommandDefinitionSchema = z9.object({
1020
+ contract: z9.literal("DomainCommandDefinition"),
1021
+ commandName: ContractIdentifierSchema,
1022
+ ownerRepo: ContractIdentifierSchema,
1023
+ displayName: z9.string().trim().min(1),
1024
+ description: z9.string().optional(),
1025
+ targetKinds: z9.array(ContractIdentifierSchema).min(1),
1026
+ inputSchemaRef: ContractIdentifierSchema,
1027
+ outputSchemaRef: ContractIdentifierSchema.optional(),
1028
+ requiredPermissionCodes: z9.array(ContractIdentifierSchema).default([]),
1029
+ handlerRef: EntityRefSchema,
1030
+ sideEffects: z9.array(z9.enum(["data-write", "execution", "navigation", "notification", "external-call"])).default([])
1031
+ }).strict();
1032
+ var DomainCommandSchema = z9.object({
1033
+ contract: z9.literal("DomainCommand"),
1034
+ commandId: ContractIdentifierSchema,
1035
+ commandName: ContractIdentifierSchema,
1036
+ requestId: ContractIdentifierSchema,
1037
+ traceId: ContractIdentifierSchema,
1038
+ idempotencyKey: ContractIdentifierSchema,
1039
+ targetRef: EntityRefSchema,
1040
+ actorRef: EntityRefSchema,
1041
+ source: z9.object({
1042
+ product: z9.enum(["studio", "kernel", "compute", "agent", "mcp", "service"]),
1043
+ pageId: ContractIdentifierSchema.optional(),
1044
+ capabilityId: ContractIdentifierSchema.optional()
1045
+ }).strict(),
1046
+ payload: JsonObjectSchema,
1047
+ issuedAt: IsoDateTimeSchema
1048
+ }).strict();
1049
+ var ProductDeclarationSchema = z9.object({
1050
+ contract: z9.literal("ProductDeclaration"),
1051
+ declarationId: ContractIdentifierSchema,
1052
+ ownerRepo: ContractIdentifierSchema,
1053
+ concepts: z9.array(ConceptDefinitionSchema).default([]),
1054
+ ontologies: z9.array(OntologyDefinitionSchema).default([]),
1055
+ projections: z9.array(ProjectionSpecSchema).default([]),
1056
+ commands: z9.array(DomainCommandDefinitionSchema).default([]),
1057
+ capabilities: z9.array(CapabilityManifestSchema).default([]),
1058
+ pages: z9.array(PageDefinitionSchema).default([])
1059
+ }).strict();
1060
+ var DeclarationGraphEdgeSchema = z9.object({
1061
+ from: EntityRefSchema,
1062
+ to: EntityRefSchema,
1063
+ relation: z9.enum([
1064
+ "uses-ontology",
1065
+ "uses-projection",
1066
+ "uses-capability",
1067
+ "uses-command",
1068
+ "relates-to-concept"
1069
+ ])
1070
+ }).strict();
1071
+ var ChangeImpactSchema = z9.object({
1072
+ changedRef: EntityRefSchema,
1073
+ affectedRefs: z9.array(EntityRefSchema),
1074
+ reasons: z9.array(ContractIdentifierSchema).min(1)
1075
+ }).strict();
1076
+ var ChangeImpactGraphSchema = z9.object({
1077
+ contract: z9.literal("ChangeImpactGraph"),
1078
+ declarationId: ContractIdentifierSchema,
1079
+ nodes: z9.array(EntityRefSchema),
1080
+ edges: z9.array(DeclarationGraphEdgeSchema),
1081
+ impacts: z9.array(ChangeImpactSchema),
1082
+ generatedAt: IsoDateTimeSchema
1083
+ }).strict();
1084
+
1085
+ // src/contracts/tenant.ts
1086
+ import { z as z11 } from "zod";
1087
+
1088
+ // src/contracts/theme.ts
1089
+ import { z as z10 } from "zod";
1090
+
1091
+ // src/theme-tokens/core.ts
1092
+ import Ajv from "ajv";
1093
+
1094
+ // src/contracts/dtcg-format.schema.json
1095
+ var dtcg_format_schema_default = {
1096
+ $schema: "http://json-schema.org/draft-07/schema#",
1097
+ $id: "https://www.designtokens.org/schemas/2025.10/format.json",
1098
+ title: "DTCG Format Schema",
1099
+ description: "JSON Schema for the Design Tokens Community Group (DTCG) Format specification.",
1100
+ type: "object",
1101
+ properties: {
1102
+ $schema: {
1103
+ type: "string",
1104
+ format: "uri-reference",
1105
+ description: "URI reference to this JSON schema.",
1106
+ $comment: "$schema is not part of the official DTCG specification."
1107
+ },
1108
+ $type: {
1109
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/tokenType.json"
1110
+ },
1111
+ $description: {
1112
+ type: "string",
1113
+ description: "A plain text description of the group"
1114
+ },
1115
+ $extensions: {
1116
+ type: "object",
1117
+ description: "Vendor-specific extensions"
1118
+ },
1119
+ $extends: {
1120
+ oneOf: [
1121
+ {
1122
+ $ref: "#/definitions/curlyBraceReference"
1123
+ },
1124
+ {
1125
+ $ref: "#/definitions/jsonPointerReference"
1126
+ }
1127
+ ],
1128
+ description: "Reference to another group to inherit tokens and properties from"
1129
+ },
1130
+ $deprecated: {
1131
+ oneOf: [
1132
+ {
1133
+ type: "boolean"
1134
+ },
1135
+ {
1136
+ type: "string"
1137
+ }
1138
+ ],
1139
+ description: "Whether this group is deprecated"
1140
+ },
1141
+ $root: {
1142
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/token.json"
1143
+ }
1144
+ },
1145
+ patternProperties: {
1146
+ "^[^${}.][^{}.]*$": {
1147
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/groupOrToken.json"
1148
+ }
1149
+ },
1150
+ additionalProperties: false,
1151
+ definitions: {
1152
+ tokenOrGroupName: {
1153
+ title: "Token or Group Name",
1154
+ type: "string",
1155
+ pattern: "^[^${}.][^{}.]*$",
1156
+ description: "Valid token/group names: must not start with $ and must not contain {, }, or ."
1157
+ },
1158
+ curlyBraceReference: {
1159
+ title: "Curly Brace Reference",
1160
+ type: "string",
1161
+ pattern: "^\\{[^${}.][^{}.]*(\\.[^${}.][^{}.]*)*\\}$",
1162
+ description: "Curly brace reference (e.g., '{tokenName}' or '{group.nested.token}')"
1163
+ },
1164
+ jsonPointerReference: {
1165
+ title: "JSON Pointer Reference",
1166
+ type: "string",
1167
+ pattern: "^#/",
1168
+ format: "json-pointer-uri-fragment",
1169
+ description: "JSON Pointer reference (RFC 6901) to a location in the document (e.g., '#/path/to/target')"
1170
+ },
1171
+ jsonPointerReferenceObject: {
1172
+ title: "JSON Pointer Reference Object",
1173
+ type: "object",
1174
+ properties: {
1175
+ $ref: {
1176
+ $ref: "#/definitions/jsonPointerReference"
1177
+ }
1178
+ },
1179
+ required: ["$ref"],
1180
+ additionalProperties: false,
1181
+ description: "Object containing a JSON Pointer reference for property-level references"
1182
+ },
1183
+ tokenValueReference: {
1184
+ title: "Token Value Reference",
1185
+ oneOf: [
1186
+ {
1187
+ $ref: "#/definitions/curlyBraceReference"
1188
+ },
1189
+ {
1190
+ $ref: "#/definitions/jsonPointerReferenceObject"
1191
+ }
1192
+ ],
1193
+ description: "A reference to a token value using either curly brace syntax or JSON Pointer syntax"
1194
+ },
1195
+ "https://www.designtokens.org/schemas/2025.10/format/tokenType.json": {
1196
+ $schema: "http://json-schema.org/draft-07/schema#",
1197
+ $id: "https://www.designtokens.org/schemas/2025.10/format/tokenType.json",
1198
+ title: "TokenType",
1199
+ description: "A token type in the DTCG specification",
1200
+ type: "string",
1201
+ enum: [
1202
+ "color",
1203
+ "dimension",
1204
+ "fontFamily",
1205
+ "fontWeight",
1206
+ "duration",
1207
+ "cubicBezier",
1208
+ "number",
1209
+ "strokeStyle",
1210
+ "border",
1211
+ "transition",
1212
+ "shadow",
1213
+ "gradient",
1214
+ "typography"
1215
+ ]
1216
+ },
1217
+ "https://www.designtokens.org/schemas/2025.10/format/token.json": {
1218
+ $schema: "http://json-schema.org/draft-07/schema#",
1219
+ $id: "https://www.designtokens.org/schemas/2025.10/format/token.json",
1220
+ title: "Token",
1221
+ description: "A token in the DTCG specification",
1222
+ type: "object",
1223
+ properties: {
1224
+ $value: {
1225
+ description: "The token's value - can be a direct value or a reference to another token using curly brace syntax (e.g., '{token.name}'). Mutually exclusive with $ref."
1226
+ },
1227
+ $type: {
1228
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/tokenType.json"
1229
+ },
1230
+ $ref: {
1231
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/jsonPointerReference"
1232
+ },
1233
+ $description: {
1234
+ type: "string",
1235
+ description: "A plain text description of the token"
1236
+ },
1237
+ $extensions: {
1238
+ type: "object",
1239
+ description: "Vendor-specific extensions"
1240
+ },
1241
+ $deprecated: {
1242
+ oneOf: [
1243
+ {
1244
+ type: "boolean"
1245
+ },
1246
+ {
1247
+ type: "string"
1248
+ }
1249
+ ],
1250
+ description: "Whether this token is deprecated"
1251
+ }
1252
+ },
1253
+ additionalProperties: false,
1254
+ allOf: [
1255
+ {
1256
+ description: "Tokens cannot define both $value and $ref; they must choose exactly one form of reference or direct value.",
1257
+ if: {
1258
+ required: ["$value"],
1259
+ properties: {
1260
+ $value: true
1261
+ }
1262
+ },
1263
+ then: {
1264
+ not: {
1265
+ required: ["$ref"],
1266
+ properties: {
1267
+ $ref: true
1268
+ }
1269
+ }
1270
+ },
1271
+ else: {
1272
+ required: ["$ref"],
1273
+ properties: {
1274
+ $ref: true
1275
+ }
1276
+ }
1277
+ },
1278
+ {
1279
+ if: {
1280
+ required: ["$type"],
1281
+ properties: {
1282
+ $type: {
1283
+ const: "color"
1284
+ }
1285
+ }
1286
+ },
1287
+ then: {
1288
+ properties: {
1289
+ $value: {
1290
+ oneOf: [
1291
+ {
1292
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/values/color.json"
1293
+ },
1294
+ {
1295
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/tokenValueReference"
1296
+ }
1297
+ ]
1298
+ }
1299
+ }
1300
+ }
1301
+ },
1302
+ {
1303
+ if: {
1304
+ required: ["$type"],
1305
+ properties: {
1306
+ $type: {
1307
+ const: "dimension"
1308
+ }
1309
+ }
1310
+ },
1311
+ then: {
1312
+ properties: {
1313
+ $value: {
1314
+ oneOf: [
1315
+ {
1316
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/values/dimension.json"
1317
+ },
1318
+ {
1319
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/tokenValueReference"
1320
+ }
1321
+ ]
1322
+ }
1323
+ }
1324
+ }
1325
+ },
1326
+ {
1327
+ if: {
1328
+ required: ["$type"],
1329
+ properties: {
1330
+ $type: {
1331
+ const: "fontFamily"
1332
+ }
1333
+ }
1334
+ },
1335
+ then: {
1336
+ properties: {
1337
+ $value: {
1338
+ oneOf: [
1339
+ {
1340
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/values/fontFamily.json"
1341
+ },
1342
+ {
1343
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/tokenValueReference"
1344
+ }
1345
+ ]
1346
+ }
1347
+ }
1348
+ }
1349
+ },
1350
+ {
1351
+ if: {
1352
+ required: ["$type"],
1353
+ properties: {
1354
+ $type: {
1355
+ const: "fontWeight"
1356
+ }
1357
+ }
1358
+ },
1359
+ then: {
1360
+ properties: {
1361
+ $value: {
1362
+ oneOf: [
1363
+ {
1364
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/values/fontWeight.json"
1365
+ },
1366
+ {
1367
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/tokenValueReference"
1368
+ }
1369
+ ]
1370
+ }
1371
+ }
1372
+ }
1373
+ },
1374
+ {
1375
+ if: {
1376
+ required: ["$type"],
1377
+ properties: {
1378
+ $type: {
1379
+ const: "duration"
1380
+ }
1381
+ }
1382
+ },
1383
+ then: {
1384
+ properties: {
1385
+ $value: {
1386
+ oneOf: [
1387
+ {
1388
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/values/duration.json"
1389
+ },
1390
+ {
1391
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/tokenValueReference"
1392
+ }
1393
+ ]
1394
+ }
1395
+ }
1396
+ }
1397
+ },
1398
+ {
1399
+ if: {
1400
+ required: ["$type"],
1401
+ properties: {
1402
+ $type: {
1403
+ const: "cubicBezier"
1404
+ }
1405
+ }
1406
+ },
1407
+ then: {
1408
+ properties: {
1409
+ $value: {
1410
+ oneOf: [
1411
+ {
1412
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/values/cubicBezier.json"
1413
+ },
1414
+ {
1415
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/tokenValueReference"
1416
+ }
1417
+ ]
1418
+ }
1419
+ }
1420
+ }
1421
+ },
1422
+ {
1423
+ if: {
1424
+ required: ["$type"],
1425
+ properties: {
1426
+ $type: {
1427
+ const: "number"
1428
+ }
1429
+ }
1430
+ },
1431
+ then: {
1432
+ properties: {
1433
+ $value: {
1434
+ oneOf: [
1435
+ {
1436
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/values/number.json"
1437
+ },
1438
+ {
1439
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/tokenValueReference"
1440
+ }
1441
+ ]
1442
+ }
1443
+ }
1444
+ }
1445
+ },
1446
+ {
1447
+ if: {
1448
+ required: ["$type"],
1449
+ properties: {
1450
+ $type: {
1451
+ const: "strokeStyle"
1452
+ }
1453
+ }
1454
+ },
1455
+ then: {
1456
+ properties: {
1457
+ $value: {
1458
+ oneOf: [
1459
+ {
1460
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/values/strokeStyle.json"
1461
+ },
1462
+ {
1463
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/tokenValueReference"
1464
+ }
1465
+ ]
1466
+ }
1467
+ }
1468
+ }
1469
+ },
1470
+ {
1471
+ if: {
1472
+ required: ["$type"],
1473
+ properties: {
1474
+ $type: {
1475
+ const: "border"
1476
+ }
1477
+ }
1478
+ },
1479
+ then: {
1480
+ properties: {
1481
+ $value: {
1482
+ oneOf: [
1483
+ {
1484
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/values/border.json"
1485
+ },
1486
+ {
1487
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/tokenValueReference"
1488
+ }
1489
+ ]
1490
+ }
1491
+ }
1492
+ }
1493
+ },
1494
+ {
1495
+ if: {
1496
+ required: ["$type"],
1497
+ properties: {
1498
+ $type: {
1499
+ const: "transition"
1500
+ }
1501
+ }
1502
+ },
1503
+ then: {
1504
+ properties: {
1505
+ $value: {
1506
+ oneOf: [
1507
+ {
1508
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/values/transition.json"
1509
+ },
1510
+ {
1511
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/tokenValueReference"
1512
+ }
1513
+ ]
1514
+ }
1515
+ }
1516
+ }
1517
+ },
1518
+ {
1519
+ if: {
1520
+ required: ["$type"],
1521
+ properties: {
1522
+ $type: {
1523
+ const: "shadow"
1524
+ }
1525
+ }
1526
+ },
1527
+ then: {
1528
+ properties: {
1529
+ $value: {
1530
+ oneOf: [
1531
+ {
1532
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/values/shadow.json"
1533
+ },
1534
+ {
1535
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/tokenValueReference"
1536
+ }
1537
+ ]
1538
+ }
1539
+ }
1540
+ }
1541
+ },
1542
+ {
1543
+ if: {
1544
+ required: ["$type"],
1545
+ properties: {
1546
+ $type: {
1547
+ const: "gradient"
1548
+ }
1549
+ }
1550
+ },
1551
+ then: {
1552
+ properties: {
1553
+ $value: {
1554
+ oneOf: [
1555
+ {
1556
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/values/gradient.json"
1557
+ },
1558
+ {
1559
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/tokenValueReference"
1560
+ }
1561
+ ]
1562
+ }
1563
+ }
1564
+ }
1565
+ },
1566
+ {
1567
+ if: {
1568
+ required: ["$type"],
1569
+ properties: {
1570
+ $type: {
1571
+ const: "typography"
1572
+ }
1573
+ }
1574
+ },
1575
+ then: {
1576
+ properties: {
1577
+ $value: {
1578
+ oneOf: [
1579
+ {
1580
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/values/typography.json"
1581
+ },
1582
+ {
1583
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/tokenValueReference"
1584
+ }
1585
+ ]
1586
+ }
1587
+ }
1588
+ }
1589
+ },
1590
+ {
1591
+ if: {
1592
+ allOf: [
1593
+ {
1594
+ not: {
1595
+ required: ["$type"]
1596
+ }
1597
+ },
1598
+ {
1599
+ required: ["$value"]
1600
+ },
1601
+ {
1602
+ properties: {
1603
+ $value: {
1604
+ not: {
1605
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/tokenValueReference"
1606
+ }
1607
+ }
1608
+ }
1609
+ }
1610
+ ]
1611
+ },
1612
+ then: {
1613
+ properties: {
1614
+ $value: {
1615
+ oneOf: [
1616
+ {
1617
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/values/color.json"
1618
+ },
1619
+ {
1620
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/values/dimension.json"
1621
+ },
1622
+ {
1623
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/values/fontFamily.json"
1624
+ },
1625
+ {
1626
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/values/duration.json"
1627
+ },
1628
+ {
1629
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/values/cubicBezier.json"
1630
+ },
1631
+ {
1632
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/values/strokeStyle.json"
1633
+ },
1634
+ {
1635
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/values/border.json"
1636
+ },
1637
+ {
1638
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/values/transition.json"
1639
+ },
1640
+ {
1641
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/values/shadow.json"
1642
+ },
1643
+ {
1644
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/values/gradient.json"
1645
+ },
1646
+ {
1647
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/values/typography.json"
1648
+ },
1649
+ {
1650
+ anyOf: [
1651
+ {
1652
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/values/number.json"
1653
+ },
1654
+ {
1655
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/values/fontWeight.json"
1656
+ }
1657
+ ]
1658
+ }
1659
+ ]
1660
+ }
1661
+ }
1662
+ }
1663
+ }
1664
+ ]
1665
+ },
1666
+ "https://www.designtokens.org/schemas/2025.10/format/values/color.json": {
1667
+ $schema: "http://json-schema.org/draft-07/schema#",
1668
+ $id: "https://www.designtokens.org/schemas/2025.10/format/values/color.json",
1669
+ title: "Color Value",
1670
+ description: "Value schema for color type tokens. Represents a color in a specific color space.",
1671
+ type: "object",
1672
+ properties: {
1673
+ colorSpace: {
1674
+ description: "The color space or color model used to represent the color",
1675
+ oneOf: [
1676
+ {
1677
+ type: "string",
1678
+ enum: [
1679
+ "srgb",
1680
+ "srgb-linear",
1681
+ "hsl",
1682
+ "hwb",
1683
+ "lab",
1684
+ "lch",
1685
+ "oklab",
1686
+ "oklch",
1687
+ "display-p3",
1688
+ "a98-rgb",
1689
+ "prophoto-rgb",
1690
+ "rec2020",
1691
+ "xyz-d65",
1692
+ "xyz-d50"
1693
+ ]
1694
+ },
1695
+ {
1696
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/jsonPointerReferenceObject"
1697
+ }
1698
+ ]
1699
+ },
1700
+ components: {
1701
+ description: "Array of color components. The number and meaning of components depend on the color space. Each component can be a number or the 'none' keyword.",
1702
+ oneOf: [
1703
+ {
1704
+ type: "array"
1705
+ },
1706
+ {
1707
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/jsonPointerReferenceObject"
1708
+ }
1709
+ ]
1710
+ },
1711
+ alpha: {
1712
+ description: "The alpha (transparency) value of the color. 0 is fully transparent, 1 is fully opaque. If omitted, defaults to 1.",
1713
+ oneOf: [
1714
+ {
1715
+ type: "number",
1716
+ minimum: 0,
1717
+ maximum: 1
1718
+ },
1719
+ {
1720
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/jsonPointerReferenceObject"
1721
+ }
1722
+ ]
1723
+ },
1724
+ hex: {
1725
+ description: "Optional fallback value in 6-digit CSS hex color notation (e.g., '#ff00ff'). Must be 6 digits to avoid conflicts with the alpha value.",
1726
+ $comment: "Only JSON Pointer references (not curly brace references) are allowed for hex because no string token type exists in the specification that could be referenced with curly braces.",
1727
+ oneOf: [
1728
+ {
1729
+ type: "string",
1730
+ pattern: "^#[0-9a-fA-F]{6}$"
1731
+ },
1732
+ {
1733
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/jsonPointerReferenceObject"
1734
+ }
1735
+ ]
1736
+ }
1737
+ },
1738
+ required: ["colorSpace", "components"],
1739
+ additionalProperties: false,
1740
+ definitions: {
1741
+ zeroToOneComponent: {
1742
+ title: "Zero to One Component",
1743
+ description: "A color component normalized to the range [0-1] (e.g., RGB values, XYZ values)",
1744
+ oneOf: [
1745
+ {
1746
+ type: "number",
1747
+ minimum: 0,
1748
+ maximum: 1
1749
+ },
1750
+ {
1751
+ type: "string",
1752
+ const: "none"
1753
+ },
1754
+ {
1755
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/jsonPointerReferenceObject"
1756
+ }
1757
+ ]
1758
+ },
1759
+ hueComponent: {
1760
+ title: "Hue Component",
1761
+ description: "Hue angle from 0 up to (but not including) 360 degrees",
1762
+ oneOf: [
1763
+ {
1764
+ type: "number",
1765
+ minimum: 0,
1766
+ exclusiveMaximum: 360
1767
+ },
1768
+ {
1769
+ type: "string",
1770
+ const: "none"
1771
+ },
1772
+ {
1773
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/jsonPointerReferenceObject"
1774
+ }
1775
+ ]
1776
+ },
1777
+ percentageComponent: {
1778
+ title: "Percentage Component",
1779
+ description: "Percentage value from 0 to 100",
1780
+ oneOf: [
1781
+ {
1782
+ type: "number",
1783
+ minimum: 0,
1784
+ maximum: 100
1785
+ },
1786
+ {
1787
+ type: "string",
1788
+ const: "none"
1789
+ },
1790
+ {
1791
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/jsonPointerReferenceObject"
1792
+ }
1793
+ ]
1794
+ },
1795
+ chromaComponent: {
1796
+ title: "Chroma Component",
1797
+ description: "Chroma value from 0 to infinity",
1798
+ oneOf: [
1799
+ {
1800
+ type: "number",
1801
+ minimum: 0
1802
+ },
1803
+ {
1804
+ type: "string",
1805
+ const: "none"
1806
+ },
1807
+ {
1808
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/jsonPointerReferenceObject"
1809
+ }
1810
+ ]
1811
+ },
1812
+ unboundedComponent: {
1813
+ title: "Unbounded Component",
1814
+ description: "A color component with no numeric bounds (e.g., A and B in LAB/OKLAB color spaces)",
1815
+ oneOf: [
1816
+ {
1817
+ type: "number"
1818
+ },
1819
+ {
1820
+ type: "string",
1821
+ const: "none"
1822
+ },
1823
+ {
1824
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/jsonPointerReferenceObject"
1825
+ }
1826
+ ]
1827
+ },
1828
+ rgbComponents: {
1829
+ title: "RGB Components",
1830
+ description: "Array of RGB color components [Red, Green, Blue], each normalized to the range [0-1]",
1831
+ type: "array",
1832
+ minItems: 3,
1833
+ maxItems: 3,
1834
+ items: [
1835
+ {
1836
+ $ref: "#/definitions/zeroToOneComponent"
1837
+ },
1838
+ {
1839
+ $ref: "#/definitions/zeroToOneComponent"
1840
+ },
1841
+ {
1842
+ $ref: "#/definitions/zeroToOneComponent"
1843
+ }
1844
+ ]
1845
+ },
1846
+ xyzComponents: {
1847
+ title: "XYZ Components",
1848
+ description: "Array of XYZ color components [X, Y, Z], each normalized to the range [0-1]",
1849
+ type: "array",
1850
+ minItems: 3,
1851
+ maxItems: 3,
1852
+ items: [
1853
+ {
1854
+ $ref: "#/definitions/zeroToOneComponent"
1855
+ },
1856
+ {
1857
+ $ref: "#/definitions/zeroToOneComponent"
1858
+ },
1859
+ {
1860
+ $ref: "#/definitions/zeroToOneComponent"
1861
+ }
1862
+ ]
1863
+ }
1864
+ },
1865
+ allOf: [
1866
+ {
1867
+ if: {
1868
+ properties: {
1869
+ colorSpace: {
1870
+ const: "srgb"
1871
+ },
1872
+ components: {
1873
+ type: "array"
1874
+ }
1875
+ }
1876
+ },
1877
+ then: {
1878
+ properties: {
1879
+ components: {
1880
+ $ref: "#/definitions/rgbComponents"
1881
+ }
1882
+ }
1883
+ }
1884
+ },
1885
+ {
1886
+ if: {
1887
+ properties: {
1888
+ colorSpace: {
1889
+ const: "srgb-linear"
1890
+ },
1891
+ components: {
1892
+ type: "array"
1893
+ }
1894
+ }
1895
+ },
1896
+ then: {
1897
+ properties: {
1898
+ components: {
1899
+ $ref: "#/definitions/rgbComponents"
1900
+ }
1901
+ }
1902
+ }
1903
+ },
1904
+ {
1905
+ if: {
1906
+ properties: {
1907
+ colorSpace: {
1908
+ const: "display-p3"
1909
+ },
1910
+ components: {
1911
+ type: "array"
1912
+ }
1913
+ }
1914
+ },
1915
+ then: {
1916
+ properties: {
1917
+ components: {
1918
+ $ref: "#/definitions/rgbComponents"
1919
+ }
1920
+ }
1921
+ }
1922
+ },
1923
+ {
1924
+ if: {
1925
+ properties: {
1926
+ colorSpace: {
1927
+ const: "a98-rgb"
1928
+ },
1929
+ components: {
1930
+ type: "array"
1931
+ }
1932
+ }
1933
+ },
1934
+ then: {
1935
+ properties: {
1936
+ components: {
1937
+ $ref: "#/definitions/rgbComponents"
1938
+ }
1939
+ }
1940
+ }
1941
+ },
1942
+ {
1943
+ if: {
1944
+ properties: {
1945
+ colorSpace: {
1946
+ const: "prophoto-rgb"
1947
+ },
1948
+ components: {
1949
+ type: "array"
1950
+ }
1951
+ }
1952
+ },
1953
+ then: {
1954
+ properties: {
1955
+ components: {
1956
+ $ref: "#/definitions/rgbComponents"
1957
+ }
1958
+ }
1959
+ }
1960
+ },
1961
+ {
1962
+ if: {
1963
+ properties: {
1964
+ colorSpace: {
1965
+ const: "rec2020"
1966
+ },
1967
+ components: {
1968
+ type: "array"
1969
+ }
1970
+ }
1971
+ },
1972
+ then: {
1973
+ properties: {
1974
+ components: {
1975
+ $ref: "#/definitions/rgbComponents"
1976
+ }
1977
+ }
1978
+ }
1979
+ },
1980
+ {
1981
+ if: {
1982
+ properties: {
1983
+ colorSpace: {
1984
+ const: "xyz-d65"
1985
+ },
1986
+ components: {
1987
+ type: "array"
1988
+ }
1989
+ }
1990
+ },
1991
+ then: {
1992
+ properties: {
1993
+ components: {
1994
+ $ref: "#/definitions/xyzComponents"
1995
+ }
1996
+ }
1997
+ }
1998
+ },
1999
+ {
2000
+ if: {
2001
+ properties: {
2002
+ colorSpace: {
2003
+ const: "xyz-d50"
2004
+ },
2005
+ components: {
2006
+ type: "array"
2007
+ }
2008
+ }
2009
+ },
2010
+ then: {
2011
+ properties: {
2012
+ components: {
2013
+ $ref: "#/definitions/xyzComponents"
2014
+ }
2015
+ }
2016
+ }
2017
+ },
2018
+ {
2019
+ if: {
2020
+ properties: {
2021
+ colorSpace: {
2022
+ const: "hsl"
2023
+ },
2024
+ components: {
2025
+ type: "array"
2026
+ }
2027
+ }
2028
+ },
2029
+ then: {
2030
+ properties: {
2031
+ components: {
2032
+ type: "array",
2033
+ minItems: 3,
2034
+ maxItems: 3,
2035
+ items: [
2036
+ {
2037
+ $ref: "#/definitions/hueComponent"
2038
+ },
2039
+ {
2040
+ $ref: "#/definitions/percentageComponent"
2041
+ },
2042
+ {
2043
+ $ref: "#/definitions/percentageComponent"
2044
+ }
2045
+ ]
2046
+ }
2047
+ }
2048
+ }
2049
+ },
2050
+ {
2051
+ if: {
2052
+ properties: {
2053
+ colorSpace: {
2054
+ const: "hwb"
2055
+ },
2056
+ components: {
2057
+ type: "array"
2058
+ }
2059
+ }
2060
+ },
2061
+ then: {
2062
+ properties: {
2063
+ components: {
2064
+ type: "array",
2065
+ minItems: 3,
2066
+ maxItems: 3,
2067
+ items: [
2068
+ {
2069
+ $ref: "#/definitions/hueComponent"
2070
+ },
2071
+ {
2072
+ $ref: "#/definitions/percentageComponent"
2073
+ },
2074
+ {
2075
+ $ref: "#/definitions/percentageComponent"
2076
+ }
2077
+ ]
2078
+ }
2079
+ }
2080
+ }
2081
+ },
2082
+ {
2083
+ if: {
2084
+ properties: {
2085
+ colorSpace: {
2086
+ const: "lab"
2087
+ },
2088
+ components: {
2089
+ type: "array"
2090
+ }
2091
+ }
2092
+ },
2093
+ then: {
2094
+ properties: {
2095
+ components: {
2096
+ type: "array",
2097
+ minItems: 3,
2098
+ maxItems: 3,
2099
+ items: [
2100
+ {
2101
+ $ref: "#/definitions/percentageComponent"
2102
+ },
2103
+ {
2104
+ $ref: "#/definitions/unboundedComponent"
2105
+ },
2106
+ {
2107
+ $ref: "#/definitions/unboundedComponent"
2108
+ }
2109
+ ]
2110
+ }
2111
+ }
2112
+ }
2113
+ },
2114
+ {
2115
+ if: {
2116
+ properties: {
2117
+ colorSpace: {
2118
+ const: "lch"
2119
+ },
2120
+ components: {
2121
+ type: "array"
2122
+ }
2123
+ }
2124
+ },
2125
+ then: {
2126
+ properties: {
2127
+ components: {
2128
+ type: "array",
2129
+ minItems: 3,
2130
+ maxItems: 3,
2131
+ items: [
2132
+ {
2133
+ $ref: "#/definitions/percentageComponent"
2134
+ },
2135
+ {
2136
+ $ref: "#/definitions/chromaComponent"
2137
+ },
2138
+ {
2139
+ $ref: "#/definitions/hueComponent"
2140
+ }
2141
+ ]
2142
+ }
2143
+ }
2144
+ }
2145
+ },
2146
+ {
2147
+ if: {
2148
+ properties: {
2149
+ colorSpace: {
2150
+ const: "oklab"
2151
+ },
2152
+ components: {
2153
+ type: "array"
2154
+ }
2155
+ }
2156
+ },
2157
+ then: {
2158
+ properties: {
2159
+ components: {
2160
+ type: "array",
2161
+ minItems: 3,
2162
+ maxItems: 3,
2163
+ items: [
2164
+ {
2165
+ $ref: "#/definitions/zeroToOneComponent"
2166
+ },
2167
+ {
2168
+ $ref: "#/definitions/unboundedComponent"
2169
+ },
2170
+ {
2171
+ $ref: "#/definitions/unboundedComponent"
2172
+ }
2173
+ ]
2174
+ }
2175
+ }
2176
+ }
2177
+ },
2178
+ {
2179
+ if: {
2180
+ properties: {
2181
+ colorSpace: {
2182
+ const: "oklch"
2183
+ },
2184
+ components: {
2185
+ type: "array"
2186
+ }
2187
+ }
2188
+ },
2189
+ then: {
2190
+ properties: {
2191
+ components: {
2192
+ type: "array",
2193
+ minItems: 3,
2194
+ maxItems: 3,
2195
+ items: [
2196
+ {
2197
+ $ref: "#/definitions/zeroToOneComponent"
2198
+ },
2199
+ {
2200
+ $ref: "#/definitions/chromaComponent"
2201
+ },
2202
+ {
2203
+ $ref: "#/definitions/hueComponent"
2204
+ }
2205
+ ]
2206
+ }
2207
+ }
2208
+ }
2209
+ }
2210
+ ]
2211
+ },
2212
+ "https://www.designtokens.org/schemas/2025.10/format/values/dimension.json": {
2213
+ $schema: "http://json-schema.org/draft-07/schema#",
2214
+ $id: "https://www.designtokens.org/schemas/2025.10/format/values/dimension.json",
2215
+ title: "Dimension Value",
2216
+ description: "Value schema for dimension type tokens. Represents an amount of distance in a single dimension in the UI, such as a position, width, height, radius, or thickness.",
2217
+ type: "object",
2218
+ properties: {
2219
+ value: {
2220
+ description: "An integer or floating-point value representing the numeric value.",
2221
+ oneOf: [
2222
+ {
2223
+ type: "number"
2224
+ },
2225
+ {
2226
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/jsonPointerReferenceObject"
2227
+ }
2228
+ ]
2229
+ },
2230
+ unit: {
2231
+ description: "Unit of distance. Supported values: 'px' (idealized pixel, equivalent to dp on Android and pt on iOS), 'rem' (multiple of system's default font size).",
2232
+ oneOf: [
2233
+ {
2234
+ type: "string",
2235
+ enum: ["px", "rem"]
2236
+ },
2237
+ {
2238
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/jsonPointerReferenceObject"
2239
+ }
2240
+ ]
2241
+ }
2242
+ },
2243
+ required: ["value", "unit"],
2244
+ additionalProperties: false
2245
+ },
2246
+ "https://www.designtokens.org/schemas/2025.10/format/values/fontFamily.json": {
2247
+ $schema: "http://json-schema.org/draft-07/schema#",
2248
+ $id: "https://www.designtokens.org/schemas/2025.10/format/values/fontFamily.json",
2249
+ title: "Font Family Value",
2250
+ description: "Value schema for fontFamily type tokens. Represents a font name or an array of font names (ordered from most to least preferred).",
2251
+ oneOf: [
2252
+ {
2253
+ type: "string",
2254
+ description: "A single font name",
2255
+ not: {
2256
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/curlyBraceReference"
2257
+ }
2258
+ },
2259
+ {
2260
+ type: "array",
2261
+ description: "An array of font names, ordered from most to least preferred",
2262
+ items: {
2263
+ oneOf: [
2264
+ {
2265
+ type: "string",
2266
+ not: {
2267
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/curlyBraceReference"
2268
+ }
2269
+ },
2270
+ {
2271
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/jsonPointerReferenceObject"
2272
+ }
2273
+ ]
2274
+ },
2275
+ minItems: 1
2276
+ }
2277
+ ]
2278
+ },
2279
+ "https://www.designtokens.org/schemas/2025.10/format/values/fontWeight.json": {
2280
+ $schema: "http://json-schema.org/draft-07/schema#",
2281
+ $id: "https://www.designtokens.org/schemas/2025.10/format/values/fontWeight.json",
2282
+ title: "Font Weight Value",
2283
+ description: "Value schema for fontWeight type tokens. Represents a font weight as per the OpenType wght tag specification. Lower numbers represent lighter weights, higher numbers represent thicker weights.",
2284
+ oneOf: [
2285
+ {
2286
+ type: "number",
2287
+ description: "Numeric font weight value",
2288
+ minimum: 1,
2289
+ maximum: 1e3
2290
+ },
2291
+ {
2292
+ type: "string",
2293
+ description: "Pre-defined font weight string value",
2294
+ enum: [
2295
+ "thin",
2296
+ "hairline",
2297
+ "extra-light",
2298
+ "ultra-light",
2299
+ "light",
2300
+ "normal",
2301
+ "regular",
2302
+ "book",
2303
+ "medium",
2304
+ "semi-bold",
2305
+ "demi-bold",
2306
+ "bold",
2307
+ "extra-bold",
2308
+ "ultra-bold",
2309
+ "black",
2310
+ "heavy",
2311
+ "extra-black",
2312
+ "ultra-black"
2313
+ ]
2314
+ }
2315
+ ]
2316
+ },
2317
+ "https://www.designtokens.org/schemas/2025.10/format/values/duration.json": {
2318
+ $schema: "http://json-schema.org/draft-07/schema#",
2319
+ $id: "https://www.designtokens.org/schemas/2025.10/format/values/duration.json",
2320
+ title: "Duration Value",
2321
+ description: "Value schema for duration type tokens. Represents the length of time in milliseconds an animation or animation cycle takes to complete.",
2322
+ type: "object",
2323
+ properties: {
2324
+ value: {
2325
+ description: "An integer or floating-point value representing the numeric value.",
2326
+ oneOf: [
2327
+ {
2328
+ type: "number"
2329
+ },
2330
+ {
2331
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/jsonPointerReferenceObject"
2332
+ }
2333
+ ]
2334
+ },
2335
+ unit: {
2336
+ description: "Unit of time. Supported values: 'ms' (millisecond), 's' (second).",
2337
+ oneOf: [
2338
+ {
2339
+ type: "string",
2340
+ enum: ["ms", "s"]
2341
+ },
2342
+ {
2343
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/jsonPointerReferenceObject"
2344
+ }
2345
+ ]
2346
+ }
2347
+ },
2348
+ required: ["value", "unit"],
2349
+ additionalProperties: false
2350
+ },
2351
+ "https://www.designtokens.org/schemas/2025.10/format/values/cubicBezier.json": {
2352
+ $schema: "http://json-schema.org/draft-07/schema#",
2353
+ $id: "https://www.designtokens.org/schemas/2025.10/format/values/cubicBezier.json",
2354
+ title: "Cubic Bezier Value",
2355
+ description: "Value schema for cubicBezier type tokens. Represents how the value of an animated property progresses towards completion over the duration of an animation, effectively creating visual effects such as acceleration, deceleration, and bounce.",
2356
+ type: "array",
2357
+ items: [
2358
+ {
2359
+ $ref: "#/definitions/xCoordinate"
2360
+ },
2361
+ {
2362
+ $ref: "#/definitions/yCoordinate"
2363
+ },
2364
+ {
2365
+ $ref: "#/definitions/xCoordinate"
2366
+ },
2367
+ {
2368
+ $ref: "#/definitions/yCoordinate"
2369
+ }
2370
+ ],
2371
+ additionalItems: false,
2372
+ minItems: 4,
2373
+ maxItems: 4,
2374
+ definitions: {
2375
+ xCoordinate: {
2376
+ title: "X Coordinate",
2377
+ description: "X coordinate of control point (must be between 0 and 1)",
2378
+ oneOf: [
2379
+ {
2380
+ type: "number",
2381
+ minimum: 0,
2382
+ maximum: 1
2383
+ },
2384
+ {
2385
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/jsonPointerReferenceObject"
2386
+ }
2387
+ ]
2388
+ },
2389
+ yCoordinate: {
2390
+ title: "Y Coordinate",
2391
+ description: "Y coordinate of control point (can be any real number)",
2392
+ oneOf: [
2393
+ {
2394
+ type: "number"
2395
+ },
2396
+ {
2397
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/jsonPointerReferenceObject"
2398
+ }
2399
+ ]
2400
+ }
2401
+ }
2402
+ },
2403
+ "https://www.designtokens.org/schemas/2025.10/format/values/number.json": {
2404
+ $schema: "http://json-schema.org/draft-07/schema#",
2405
+ $id: "https://www.designtokens.org/schemas/2025.10/format/values/number.json",
2406
+ title: "Number Value",
2407
+ description: "Value schema for number type tokens. Numbers can be positive, negative and have fractions. Example uses are gradient stop positions or unitless line heights.",
2408
+ type: "number"
2409
+ },
2410
+ "https://www.designtokens.org/schemas/2025.10/format/values/strokeStyle.json": {
2411
+ $schema: "http://json-schema.org/draft-07/schema#",
2412
+ $id: "https://www.designtokens.org/schemas/2025.10/format/values/strokeStyle.json",
2413
+ title: "Stroke Style Value",
2414
+ description: "Value schema for strokeStyle type tokens. Represents the style applied to lines or borders.",
2415
+ oneOf: [
2416
+ {
2417
+ type: "string",
2418
+ enum: [
2419
+ "solid",
2420
+ "dashed",
2421
+ "dotted",
2422
+ "double",
2423
+ "groove",
2424
+ "ridge",
2425
+ "outset",
2426
+ "inset"
2427
+ ],
2428
+ description: "Pre-defined stroke style values with the same meaning as CSS line style values"
2429
+ },
2430
+ {
2431
+ type: "object",
2432
+ properties: {
2433
+ dashArray: {
2434
+ description: "Array of dimension values specifying lengths of alternating dashes and gaps",
2435
+ oneOf: [
2436
+ {
2437
+ type: "array",
2438
+ items: {
2439
+ oneOf: [
2440
+ {
2441
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/values/dimension.json"
2442
+ },
2443
+ {
2444
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/tokenValueReference"
2445
+ }
2446
+ ]
2447
+ },
2448
+ minItems: 1
2449
+ },
2450
+ {
2451
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/jsonPointerReferenceObject"
2452
+ }
2453
+ ]
2454
+ },
2455
+ lineCap: {
2456
+ description: "Line cap style, same meaning as SVG stroke-linecap attribute",
2457
+ oneOf: [
2458
+ {
2459
+ type: "string",
2460
+ enum: ["round", "butt", "square"]
2461
+ },
2462
+ {
2463
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/jsonPointerReferenceObject"
2464
+ }
2465
+ ]
2466
+ }
2467
+ },
2468
+ required: ["dashArray", "lineCap"],
2469
+ additionalProperties: false
2470
+ }
2471
+ ]
2472
+ },
2473
+ "https://www.designtokens.org/schemas/2025.10/format/values/border.json": {
2474
+ $schema: "http://json-schema.org/draft-07/schema#",
2475
+ $id: "https://www.designtokens.org/schemas/2025.10/format/values/border.json",
2476
+ title: "Border Value",
2477
+ description: "Value schema for border type tokens. Represents a border style.",
2478
+ type: "object",
2479
+ properties: {
2480
+ color: {
2481
+ description: "The color of the border",
2482
+ oneOf: [
2483
+ {
2484
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/values/color.json"
2485
+ },
2486
+ {
2487
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/tokenValueReference"
2488
+ }
2489
+ ]
2490
+ },
2491
+ width: {
2492
+ description: "The width or thickness of the border",
2493
+ oneOf: [
2494
+ {
2495
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/values/dimension.json"
2496
+ },
2497
+ {
2498
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/tokenValueReference"
2499
+ }
2500
+ ]
2501
+ },
2502
+ style: {
2503
+ description: "The border's style",
2504
+ oneOf: [
2505
+ {
2506
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/values/strokeStyle.json"
2507
+ },
2508
+ {
2509
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/tokenValueReference"
2510
+ }
2511
+ ]
2512
+ }
2513
+ },
2514
+ required: ["color", "width", "style"],
2515
+ additionalProperties: false
2516
+ },
2517
+ "https://www.designtokens.org/schemas/2025.10/format/values/transition.json": {
2518
+ $schema: "http://json-schema.org/draft-07/schema#",
2519
+ $id: "https://www.designtokens.org/schemas/2025.10/format/values/transition.json",
2520
+ title: "Transition Value",
2521
+ description: "Value schema for transition type tokens. Represents an animated transition between two states.",
2522
+ type: "object",
2523
+ properties: {
2524
+ duration: {
2525
+ description: "The duration of the transition",
2526
+ oneOf: [
2527
+ {
2528
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/values/duration.json"
2529
+ },
2530
+ {
2531
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/tokenValueReference"
2532
+ }
2533
+ ]
2534
+ },
2535
+ delay: {
2536
+ description: "The time to wait before the transition begins",
2537
+ oneOf: [
2538
+ {
2539
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/values/duration.json"
2540
+ },
2541
+ {
2542
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/tokenValueReference"
2543
+ }
2544
+ ]
2545
+ },
2546
+ timingFunction: {
2547
+ description: "The timing function of the transition",
2548
+ oneOf: [
2549
+ {
2550
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/values/cubicBezier.json"
2551
+ },
2552
+ {
2553
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/tokenValueReference"
2554
+ }
2555
+ ]
2556
+ }
2557
+ },
2558
+ required: ["duration", "delay", "timingFunction"],
2559
+ additionalProperties: false
2560
+ },
2561
+ "https://www.designtokens.org/schemas/2025.10/format/values/shadow.json": {
2562
+ $schema: "http://json-schema.org/draft-07/schema#",
2563
+ $id: "https://www.designtokens.org/schemas/2025.10/format/values/shadow.json",
2564
+ title: "Shadow Value",
2565
+ description: "Value schema for shadow type tokens. Represents a shadow style.",
2566
+ oneOf: [
2567
+ {
2568
+ $ref: "#/definitions/shadowObject"
2569
+ },
2570
+ {
2571
+ type: "array",
2572
+ description: "Array of shadow objects and/or references to shadow tokens",
2573
+ items: {
2574
+ oneOf: [
2575
+ {
2576
+ $ref: "#/definitions/shadowObject"
2577
+ },
2578
+ {
2579
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/tokenValueReference"
2580
+ }
2581
+ ]
2582
+ },
2583
+ minItems: 1
2584
+ }
2585
+ ],
2586
+ definitions: {
2587
+ shadowObject: {
2588
+ title: "Shadow Object",
2589
+ type: "object",
2590
+ properties: {
2591
+ color: {
2592
+ description: "The color of the shadow",
2593
+ oneOf: [
2594
+ {
2595
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/values/color.json"
2596
+ },
2597
+ {
2598
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/tokenValueReference"
2599
+ }
2600
+ ]
2601
+ },
2602
+ offsetX: {
2603
+ description: "The horizontal offset that shadow has from the element it is applied to",
2604
+ oneOf: [
2605
+ {
2606
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/values/dimension.json"
2607
+ },
2608
+ {
2609
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/tokenValueReference"
2610
+ }
2611
+ ]
2612
+ },
2613
+ offsetY: {
2614
+ description: "The vertical offset that shadow has from the element it is applied to",
2615
+ oneOf: [
2616
+ {
2617
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/values/dimension.json"
2618
+ },
2619
+ {
2620
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/tokenValueReference"
2621
+ }
2622
+ ]
2623
+ },
2624
+ blur: {
2625
+ description: "The blur radius that is applied to the shadow",
2626
+ oneOf: [
2627
+ {
2628
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/values/dimension.json"
2629
+ },
2630
+ {
2631
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/tokenValueReference"
2632
+ }
2633
+ ]
2634
+ },
2635
+ spread: {
2636
+ description: "The amount by which to expand or contract the shadow",
2637
+ oneOf: [
2638
+ {
2639
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/values/dimension.json"
2640
+ },
2641
+ {
2642
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/tokenValueReference"
2643
+ }
2644
+ ]
2645
+ },
2646
+ inset: {
2647
+ description: "Whether this shadow is inside the containing shape (inner shadow) rather than a drop shadow (default: false)",
2648
+ oneOf: [
2649
+ {
2650
+ type: "boolean"
2651
+ },
2652
+ {
2653
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/jsonPointerReferenceObject"
2654
+ }
2655
+ ]
2656
+ }
2657
+ },
2658
+ required: ["color", "offsetX", "offsetY", "blur", "spread"],
2659
+ additionalProperties: false
2660
+ }
2661
+ }
2662
+ },
2663
+ "https://www.designtokens.org/schemas/2025.10/format/values/gradient.json": {
2664
+ $schema: "http://json-schema.org/draft-07/schema#",
2665
+ $id: "https://www.designtokens.org/schemas/2025.10/format/values/gradient.json",
2666
+ title: "Gradient Value",
2667
+ description: "Value schema for gradient type tokens. Represents a color gradient.",
2668
+ type: "array",
2669
+ items: {
2670
+ oneOf: [
2671
+ {
2672
+ $ref: "#/definitions/gradientStop"
2673
+ },
2674
+ {
2675
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/tokenValueReference"
2676
+ }
2677
+ ]
2678
+ },
2679
+ minItems: 1,
2680
+ definitions: {
2681
+ gradientStop: {
2682
+ title: "Gradient Stop",
2683
+ type: "object",
2684
+ properties: {
2685
+ color: {
2686
+ description: "The color value at the stop's position on the gradient",
2687
+ oneOf: [
2688
+ {
2689
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/values/color.json"
2690
+ },
2691
+ {
2692
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/tokenValueReference"
2693
+ }
2694
+ ]
2695
+ },
2696
+ position: {
2697
+ description: "The position of the stop along the gradient's axis (range [0, 1]). Values outside this range are clamped.",
2698
+ oneOf: [
2699
+ {
2700
+ type: "number",
2701
+ minimum: 0,
2702
+ maximum: 1
2703
+ },
2704
+ {
2705
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/tokenValueReference"
2706
+ }
2707
+ ]
2708
+ }
2709
+ },
2710
+ required: ["color", "position"],
2711
+ additionalProperties: false
2712
+ }
2713
+ }
2714
+ },
2715
+ "https://www.designtokens.org/schemas/2025.10/format/values/typography.json": {
2716
+ $schema: "http://json-schema.org/draft-07/schema#",
2717
+ $id: "https://www.designtokens.org/schemas/2025.10/format/values/typography.json",
2718
+ title: "Typography Value",
2719
+ description: "Value schema for typography type tokens. Represents a typographic style.",
2720
+ type: "object",
2721
+ properties: {
2722
+ fontFamily: {
2723
+ description: "The typography's font",
2724
+ oneOf: [
2725
+ {
2726
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/values/fontFamily.json"
2727
+ },
2728
+ {
2729
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/tokenValueReference"
2730
+ }
2731
+ ]
2732
+ },
2733
+ fontSize: {
2734
+ description: "The size of the typography",
2735
+ oneOf: [
2736
+ {
2737
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/values/dimension.json"
2738
+ },
2739
+ {
2740
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/tokenValueReference"
2741
+ }
2742
+ ]
2743
+ },
2744
+ fontWeight: {
2745
+ description: "The weight of the typography",
2746
+ oneOf: [
2747
+ {
2748
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/values/fontWeight.json"
2749
+ },
2750
+ {
2751
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/tokenValueReference"
2752
+ }
2753
+ ]
2754
+ },
2755
+ letterSpacing: {
2756
+ description: "The horizontal spacing between characters",
2757
+ oneOf: [
2758
+ {
2759
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/values/dimension.json"
2760
+ },
2761
+ {
2762
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/tokenValueReference"
2763
+ }
2764
+ ]
2765
+ },
2766
+ lineHeight: {
2767
+ description: "The vertical spacing between lines of typography (interpreted as a multiplier of fontSize)",
2768
+ oneOf: [
2769
+ {
2770
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/values/number.json"
2771
+ },
2772
+ {
2773
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/tokenValueReference"
2774
+ }
2775
+ ]
2776
+ }
2777
+ },
2778
+ required: [
2779
+ "fontFamily",
2780
+ "fontSize",
2781
+ "fontWeight",
2782
+ "letterSpacing",
2783
+ "lineHeight"
2784
+ ],
2785
+ additionalProperties: false
2786
+ },
2787
+ "https://www.designtokens.org/schemas/2025.10/format/groupOrToken.json": {
2788
+ $schema: "http://json-schema.org/draft-07/schema#",
2789
+ $id: "https://www.designtokens.org/schemas/2025.10/format/groupOrToken.json",
2790
+ title: "Group or Token",
2791
+ description: "A group or a token in the DTCG specification. A token is identified by the presence of a $value property, while a group is any object without a $value property.",
2792
+ oneOf: [
2793
+ {
2794
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/group.json"
2795
+ },
2796
+ {
2797
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/token.json"
2798
+ }
2799
+ ]
2800
+ },
2801
+ "https://www.designtokens.org/schemas/2025.10/format/group.json": {
2802
+ $schema: "http://json-schema.org/draft-07/schema#",
2803
+ $id: "https://www.designtokens.org/schemas/2025.10/format/group.json",
2804
+ title: "Group",
2805
+ description: "A group in the DTCG specification",
2806
+ type: "object",
2807
+ properties: {
2808
+ $type: {
2809
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/tokenType.json"
2810
+ },
2811
+ $description: {
2812
+ type: "string",
2813
+ description: "A plain text description of the group"
2814
+ },
2815
+ $extensions: {
2816
+ type: "object",
2817
+ description: "Vendor-specific extensions"
2818
+ },
2819
+ $extends: {
2820
+ oneOf: [
2821
+ {
2822
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/curlyBraceReference"
2823
+ },
2824
+ {
2825
+ $ref: "https://www.designtokens.org/schemas/2025.10/format.json#/definitions/jsonPointerReference"
2826
+ }
2827
+ ],
2828
+ description: "Reference to another group to inherit tokens and properties from"
2829
+ },
2830
+ $deprecated: {
2831
+ oneOf: [
2832
+ {
2833
+ type: "boolean"
2834
+ },
2835
+ {
2836
+ type: "string"
2837
+ }
2838
+ ],
2839
+ description: "Whether this group is deprecated"
2840
+ },
2841
+ $root: {
2842
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/token.json"
2843
+ }
2844
+ },
2845
+ patternProperties: {
2846
+ "^[^${}.][^{}.]*$": {
2847
+ $ref: "https://www.designtokens.org/schemas/2025.10/format/groupOrToken.json"
2848
+ }
2849
+ },
2850
+ additionalProperties: false
2851
+ }
2852
+ }
2853
+ };
2854
+
2855
+ // src/theme-tokens/core.ts
2856
+ var THEME_TOKEN_TYPES = [
2857
+ "color",
2858
+ "dimension",
2859
+ "fontFamily",
2860
+ "fontWeight",
2861
+ "duration",
2862
+ "cubicBezier",
2863
+ "number",
2864
+ "strokeStyle",
2865
+ "border",
2866
+ "transition",
2867
+ "shadow",
2868
+ "gradient",
2869
+ "typography"
2870
+ ];
2871
+ var ThemeTokenValidationError = class extends TypeError {
2872
+ constructor(message, issues = []) {
2873
+ super(message);
2874
+ this.name = "ThemeTokenValidationError";
2875
+ this.issues = issues;
2876
+ }
2877
+ };
2878
+ var schema = dtcg_format_schema_default;
2879
+ var ajv = new Ajv({
2880
+ allErrors: true,
2881
+ strict: false,
2882
+ strictNumbers: true,
2883
+ validateFormats: false
2884
+ });
2885
+ var validateDtcgDocument = ajv.compile(schema);
2886
+ function isRecord(value) {
2887
+ return value !== null && typeof value === "object" && !Array.isArray(value);
2888
+ }
2889
+ function hasOwn(value, key) {
2890
+ return Object.prototype.hasOwnProperty.call(value, key);
2891
+ }
2892
+ function isToken(value) {
2893
+ return isRecord(value) && (hasOwn(value, "$value") || hasOwn(value, "$ref"));
2894
+ }
2895
+ function isGroup(value) {
2896
+ return isRecord(value) && !isToken(value);
2897
+ }
2898
+ function cloneJson(value) {
2899
+ if (Array.isArray(value)) return value.map((item) => cloneJson(item));
2900
+ if (!isRecord(value)) return value;
2901
+ return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, cloneJson(item)]));
2902
+ }
2903
+ function formatAjvIssues(errors) {
2904
+ return (errors ?? []).map((error) => ({
2905
+ path: error.instancePath || "/",
2906
+ message: `${error.message ?? "is invalid"}${error.params && Object.keys(error.params).length > 0 ? ` (${JSON.stringify(error.params)})` : ""}`
2907
+ }));
2908
+ }
2909
+ function validateThemeTokensDocumentStructure(input) {
2910
+ if (validateDtcgDocument(input)) return [];
2911
+ return formatAjvIssues(validateDtcgDocument.errors);
2912
+ }
2913
+ function assertThemeTokensDocumentStructure(input) {
2914
+ const issues = validateThemeTokensDocumentStructure(input);
2915
+ if (issues.length === 0) return;
2916
+ const summary = issues.slice(0, 5).map((issue) => `${issue.path} ${issue.message}`).join("; ");
2917
+ throw new ThemeTokenValidationError(`Invalid DTCG 2025.10 token document: ${summary}`, issues);
2918
+ }
2919
+ var GROUP_META_KEYS = /* @__PURE__ */ new Set(["$schema", "$type", "$description", "$deprecated", "$extensions"]);
2920
+ function mergeGroups(base, override, path, sourceMerge) {
2921
+ const output = cloneJson(base);
2922
+ for (const [key, value] of Object.entries(override)) {
2923
+ if (key === "$extends") continue;
2924
+ if (key.startsWith("$") && key !== "$root") {
2925
+ output[key] = cloneJson(value);
2926
+ continue;
2927
+ }
2928
+ if (!hasOwn(output, key)) {
2929
+ output[key] = cloneJson(value);
2930
+ continue;
2931
+ }
2932
+ const existing = output[key];
2933
+ const existingKind = isToken(existing) ? "token" : isGroup(existing) ? "group" : "metadata";
2934
+ const nextKind = isToken(value) ? "token" : isGroup(value) ? "group" : "metadata";
2935
+ if (existingKind === "group" && nextKind === "group") {
2936
+ output[key] = mergeGroups(existing, value, [...path, key], sourceMerge);
2937
+ continue;
2938
+ }
2939
+ if (existingKind !== nextKind) {
2940
+ const reason = sourceMerge ? "Token sources" : "Extended groups";
2941
+ throw new ThemeTokenValidationError(
2942
+ `${reason} cannot change ${[...path, key].join(".")} from ${existingKind} to ${nextKind}.`
2943
+ );
2944
+ }
2945
+ output[key] = cloneJson(value);
2946
+ }
2947
+ return output;
2948
+ }
2949
+ function decodeJsonPointer(reference) {
2950
+ if (!reference.startsWith("#/")) {
2951
+ throw new ThemeTokenValidationError(`JSON Pointer reference must start with "#/": ${reference}`);
2952
+ }
2953
+ let decoded;
2954
+ try {
2955
+ decoded = decodeURIComponent(reference.slice(1));
2956
+ } catch {
2957
+ throw new ThemeTokenValidationError(`JSON Pointer contains invalid URI encoding: ${reference}`);
2958
+ }
2959
+ return decoded.slice(1).split("/").map((segment) => segment.replace(/~1/g, "/").replace(/~0/g, "~"));
2960
+ }
2961
+ function getAtSegments(document, segments, reference) {
2962
+ let current = document;
2963
+ for (const segment of segments) {
2964
+ if (Array.isArray(current)) {
2965
+ if (!/^(0|[1-9]\d*)$/.test(segment) || Number(segment) >= current.length) {
2966
+ throw new ThemeTokenValidationError(`Unresolved JSON Pointer reference: ${reference}`);
2967
+ }
2968
+ current = current[Number(segment)];
2969
+ continue;
2970
+ }
2971
+ if (!isRecord(current) || !hasOwn(current, segment)) {
2972
+ throw new ThemeTokenValidationError(`Unresolved JSON Pointer reference: ${reference}`);
2973
+ }
2974
+ current = current[segment];
2975
+ }
2976
+ return current;
2977
+ }
2978
+ function parseCurlyReference(reference) {
2979
+ const match = reference.match(/^\{([^{}]+)\}$/);
2980
+ return match ? match[1].split(".") : null;
2981
+ }
2982
+ function getGroupReference(document, reference) {
2983
+ const curlyPath = parseCurlyReference(reference);
2984
+ const path = curlyPath ?? decodeJsonPointer(reference);
2985
+ const target = getAtSegments(document, path, reference);
2986
+ if (!isGroup(target)) {
2987
+ throw new ThemeTokenValidationError(`Group $extends must reference a group: ${reference}`);
2988
+ }
2989
+ return { group: target, key: path.join("."), path };
2990
+ }
2991
+ function materializeGroups(document) {
2992
+ const resolveGroup = (group, path, extendsStack) => {
2993
+ let merged = {};
2994
+ const extension = group.$extends;
2995
+ if (typeof extension === "string") {
2996
+ const target = getGroupReference(document, extension);
2997
+ if (extendsStack.includes(target.key)) {
2998
+ throw new ThemeTokenValidationError(
2999
+ `Circular group $extends reference: ${[...extendsStack, target.key].join(" -> ")}`
3000
+ );
3001
+ }
3002
+ const base = resolveGroup(target.group, target.path, [...extendsStack, target.key]);
3003
+ merged = mergeGroups(base, group, path, false);
3004
+ } else {
3005
+ merged = cloneJson(group);
3006
+ delete merged.$extends;
3007
+ }
3008
+ for (const [key, value] of Object.entries(merged)) {
3009
+ if (key.startsWith("$")) continue;
3010
+ if (isGroup(value)) {
3011
+ merged[key] = resolveGroup(value, [...path, key], extendsStack);
3012
+ }
3013
+ }
3014
+ return merged;
3015
+ };
3016
+ return resolveGroup(document, [], ["$root-document"]);
3017
+ }
3018
+ function collectTokens(document) {
3019
+ const tokens = /* @__PURE__ */ new Map();
3020
+ const visitGroup = (group, path, inheritedType, inheritedDeprecated) => {
3021
+ const groupType = group.$type ?? inheritedType;
3022
+ const groupDeprecated = group.$deprecated ?? inheritedDeprecated;
3023
+ for (const [key, value] of Object.entries(group)) {
3024
+ if (GROUP_META_KEYS.has(key) || key === "$extends") continue;
3025
+ const tokenPath = [...path, key].join(".");
3026
+ if (isToken(value)) {
3027
+ tokens.set(tokenPath, {
3028
+ token: value,
3029
+ inheritedType: groupType,
3030
+ inheritedDeprecated: groupDeprecated
3031
+ });
3032
+ } else if (isGroup(value)) {
3033
+ visitGroup(value, [...path, key], groupType, groupDeprecated);
3034
+ }
3035
+ }
3036
+ };
3037
+ visitGroup(document, []);
3038
+ return tokens;
3039
+ }
3040
+ function expectedChildType(parentType, key) {
3041
+ switch (parentType) {
3042
+ case "border":
3043
+ return { color: "color", width: "dimension", style: "strokeStyle" }[key];
3044
+ case "transition":
3045
+ return { duration: "duration", delay: "duration", timingFunction: "cubicBezier" }[key];
3046
+ case "shadow":
3047
+ return { color: "color", offsetX: "dimension", offsetY: "dimension", blur: "dimension", spread: "dimension" }[key];
3048
+ case "gradient":
3049
+ return { color: "color", position: "number" }[key];
3050
+ case "typography":
3051
+ return {
3052
+ fontFamily: "fontFamily",
3053
+ fontSize: "dimension",
3054
+ fontWeight: "fontWeight",
3055
+ letterSpacing: "dimension",
3056
+ lineHeight: "number"
3057
+ }[key];
3058
+ case "strokeStyle":
3059
+ return key === "dashArray" ? "dimension" : void 0;
3060
+ case "dimension":
3061
+ case "duration":
3062
+ return key === "value" ? "number" : void 0;
3063
+ case "color":
3064
+ return key === "alpha" || key === "components" ? "number" : void 0;
3065
+ default:
3066
+ return void 0;
3067
+ }
3068
+ }
3069
+ function assertResolvedValueMatchesType(type, value, path) {
3070
+ const syntheticDocument = {
3071
+ token: {
3072
+ $type: type,
3073
+ $value: value
3074
+ }
3075
+ };
3076
+ const issues = validateThemeTokensDocumentStructure(syntheticDocument);
3077
+ if (issues.length === 0) return;
3078
+ const mapped = issues.map((issue) => ({
3079
+ path: `${path}${issue.path.replace(/^\/token(?:\/\$value)?/, "")}`,
3080
+ message: issue.message
3081
+ }));
3082
+ const summary = mapped.slice(0, 5).map((issue) => `${issue.path} ${issue.message}`).join("; ");
3083
+ throw new ThemeTokenValidationError(`Token ${path} has an invalid ${type} value: ${summary}`, mapped);
3084
+ }
3085
+ function resolveThemeTokens(input) {
3086
+ assertThemeTokensDocumentStructure(input);
3087
+ const document = cloneJson(input);
3088
+ const materializedDocument = materializeGroups(document);
3089
+ const collected = collectTokens(materializedDocument);
3090
+ const resolved = /* @__PURE__ */ new Map();
3091
+ const resolvingTokens = [];
3092
+ const resolveToken = (path) => {
3093
+ const cached = resolved.get(path);
3094
+ if (cached) return cached;
3095
+ const entry = collected.get(path);
3096
+ if (!entry) throw new ThemeTokenValidationError(`Unknown token reference: ${path}`);
3097
+ if (resolvingTokens.includes(path)) {
3098
+ throw new ThemeTokenValidationError(`Circular token reference: ${[...resolvingTokens, path].join(" -> ")}`);
3099
+ }
3100
+ resolvingTokens.push(path);
3101
+ const token = entry.token;
3102
+ let tokenType = token.$type ?? entry.inheritedType;
3103
+ const inferReferenceType = (reference) => {
3104
+ const segments = decodeJsonPointer(reference);
3105
+ for (let length = segments.length; length > 0; length -= 1) {
3106
+ const candidate = segments.slice(0, length).join(".");
3107
+ if (!collected.has(candidate)) continue;
3108
+ const owner = resolveToken(candidate);
3109
+ if (length === segments.length || segments[length] === "$value") return owner.type;
3110
+ return void 0;
3111
+ }
3112
+ return void 0;
3113
+ };
3114
+ if (!tokenType && typeof token.$value === "string") {
3115
+ const aliasPath = parseCurlyReference(token.$value)?.join(".");
3116
+ if (aliasPath) tokenType = resolveToken(aliasPath).type;
3117
+ }
3118
+ if (!tokenType && typeof token.$ref === "string") tokenType = inferReferenceType(token.$ref);
3119
+ if (!tokenType) {
3120
+ resolvingTokens.pop();
3121
+ throw new ThemeTokenValidationError(
3122
+ `Token ${path} has no $type, does not inherit one, and cannot infer one from its reference.`
3123
+ );
3124
+ }
3125
+ const resolvingPointers = [];
3126
+ const resolvePointer = (reference, expectedType, location) => {
3127
+ const marker = `${path}:${reference}`;
3128
+ if (resolvingPointers.includes(marker)) {
3129
+ throw new ThemeTokenValidationError(
3130
+ `Circular JSON Pointer reference at ${location}: ${[...resolvingPointers, marker].join(" -> ")}`
3131
+ );
3132
+ }
3133
+ resolvingPointers.push(marker);
3134
+ const segments = decodeJsonPointer(reference);
3135
+ const target = getAtSegments(materializedDocument, segments, reference);
3136
+ let result2;
3137
+ if (isToken(target)) {
3138
+ const targetPath = segments.join(".");
3139
+ const targetToken = resolveToken(targetPath);
3140
+ if (expectedType && targetToken.type !== expectedType) {
3141
+ throw new ThemeTokenValidationError(
3142
+ `Reference at ${location} expects ${expectedType} but ${targetPath} is ${targetToken.type}.`
3143
+ );
3144
+ }
3145
+ result2 = targetToken.value;
3146
+ } else if (isGroup(target)) {
3147
+ throw new ThemeTokenValidationError(`JSON Pointer at ${location} references a group: ${reference}`);
3148
+ } else {
3149
+ result2 = resolveValue(target, expectedType, location);
3150
+ }
3151
+ resolvingPointers.pop();
3152
+ return result2;
3153
+ };
3154
+ const resolveValue = (value2, expectedType, location, contextType = expectedType) => {
3155
+ if (typeof value2 === "string") {
3156
+ const alias = parseCurlyReference(value2);
3157
+ if (!alias) return value2;
3158
+ const aliasPath = alias.join(".");
3159
+ const target = resolveToken(aliasPath);
3160
+ if (expectedType && target.type !== expectedType) {
3161
+ throw new ThemeTokenValidationError(
3162
+ `Reference at ${location} expects ${expectedType} but ${aliasPath} is ${target.type}.`
3163
+ );
3164
+ }
3165
+ return cloneJson(target.value);
3166
+ }
3167
+ if (Array.isArray(value2)) {
3168
+ return value2.map((item, index) => {
3169
+ const childType = contextType === "cubicBezier" ? "number" : contextType === "strokeStyle" ? "dimension" : void 0;
3170
+ return resolveValue(item, childType, `${location}/${index}`, contextType);
3171
+ });
3172
+ }
3173
+ if (!isRecord(value2)) return value2;
3174
+ if (Object.keys(value2).length === 1 && typeof value2.$ref === "string") {
3175
+ return resolvePointer(value2.$ref, expectedType, location);
3176
+ }
3177
+ return Object.fromEntries(Object.entries(value2).map(([key, child]) => {
3178
+ const childType = expectedChildType(contextType, key);
3179
+ return [key, resolveValue(child, childType, `${location}/${key}`, contextType)];
3180
+ }));
3181
+ };
3182
+ let value;
3183
+ if (typeof token.$ref === "string") {
3184
+ value = resolvePointer(token.$ref, tokenType, path);
3185
+ } else {
3186
+ value = resolveValue(token.$value, tokenType, path);
3187
+ }
3188
+ assertResolvedValueMatchesType(tokenType, value, path);
3189
+ const result = {
3190
+ path,
3191
+ type: tokenType,
3192
+ value,
3193
+ description: token.$description,
3194
+ deprecated: token.$deprecated ?? entry.inheritedDeprecated,
3195
+ extensions: token.$extensions
3196
+ };
3197
+ resolvingTokens.pop();
3198
+ resolved.set(path, result);
3199
+ return result;
3200
+ };
3201
+ for (const path of collected.keys()) resolveToken(path);
3202
+ const resolvedDocument = {};
3203
+ for (const token of resolved.values()) {
3204
+ const segments = token.path.split(".");
3205
+ let parent = resolvedDocument;
3206
+ segments.forEach((segment, index) => {
3207
+ if (index === segments.length - 1) {
3208
+ parent[segment] = {
3209
+ $type: token.type,
3210
+ $value: cloneJson(token.value),
3211
+ ...token.description !== void 0 ? { $description: token.description } : {},
3212
+ ...token.deprecated !== void 0 ? { $deprecated: cloneJson(token.deprecated) } : {},
3213
+ ...token.extensions !== void 0 ? { $extensions: cloneJson(token.extensions) } : {}
3214
+ };
3215
+ return;
3216
+ }
3217
+ const existing = parent[segment];
3218
+ if (!isRecord(existing)) parent[segment] = {};
3219
+ parent = parent[segment];
3220
+ });
3221
+ }
3222
+ return {
3223
+ document,
3224
+ materializedDocument,
3225
+ resolvedDocument,
3226
+ tokens: resolved
3227
+ };
3228
+ }
3229
+ function validateThemeTokensDocument(input) {
3230
+ const structuralIssues = validateThemeTokensDocumentStructure(input);
3231
+ if (structuralIssues.length > 0) return structuralIssues;
3232
+ try {
3233
+ resolveThemeTokens(input);
3234
+ return [];
3235
+ } catch (error) {
3236
+ if (error instanceof ThemeTokenValidationError) {
3237
+ return error.issues.length > 0 ? [...error.issues] : [{ path: "/", message: error.message }];
3238
+ }
3239
+ return [{ path: "/", message: error instanceof Error ? error.message : String(error) }];
3240
+ }
3241
+ }
3242
+ var REQUIRED_SEMANTIC_COLOR_PATHS = [
3243
+ "background",
3244
+ "foreground",
3245
+ "card",
3246
+ "card-foreground",
3247
+ "popover",
3248
+ "popover-foreground",
3249
+ "primary",
3250
+ "primary-foreground",
3251
+ "secondary",
3252
+ "secondary-foreground",
3253
+ "muted",
3254
+ "muted-foreground",
3255
+ "accent",
3256
+ "accent-foreground",
3257
+ "destructive",
3258
+ "destructive-foreground",
3259
+ "success",
3260
+ "success-foreground",
3261
+ "warning",
3262
+ "warning-foreground",
3263
+ "border",
3264
+ "input",
3265
+ "ring",
3266
+ "neocard"
3267
+ ];
3268
+ var MONKEYS_REQUIRED_THEME_TOKEN_PATHS = Object.freeze({
3269
+ ...Object.fromEntries(
3270
+ REQUIRED_SEMANTIC_COLOR_PATHS.flatMap((name) => [
3271
+ [`semantic.color.${name}.light`, "color"],
3272
+ [`semantic.color.${name}.dark`, "color"]
3273
+ ])
3274
+ ),
3275
+ "semantic.radius.base": "dimension",
3276
+ "semantic.spacing.global.compact": "dimension",
3277
+ "semantic.spacing.global.default": "dimension",
3278
+ "semantic.spacing.global.comfortable": "dimension",
3279
+ "semantic.font.body": "fontFamily"
3280
+ });
3281
+
3282
+ // src/contracts/theme.ts
3283
+ var ThemeTokenTypeSchema = z10.enum(THEME_TOKEN_TYPES);
3284
+ var ThemeTokenSchema = z10.record(z10.string(), z10.unknown()).superRefine((input, context) => {
3285
+ const issues = validateThemeTokensDocumentStructure({ token: input });
3286
+ for (const issue of issues) {
3287
+ context.addIssue({ code: "custom", message: `${issue.path} ${issue.message}` });
3288
+ }
3289
+ });
3290
+ var ThemeTokenGroupSchema = z10.record(z10.string(), z10.unknown()).superRefine((input, context) => {
3291
+ const issues = validateThemeTokensDocumentStructure(input);
3292
+ for (const issue of issues) {
3293
+ context.addIssue({ code: "custom", message: `${issue.path} ${issue.message}` });
3294
+ }
3295
+ });
3296
+ var ThemeTokensSchema = z10.record(z10.string(), z10.unknown()).superRefine((input, context) => {
3297
+ const issues = validateThemeTokensDocument(input);
3298
+ for (const issue of issues) {
3299
+ context.addIssue({ code: "custom", message: `${issue.path} ${issue.message}` });
3300
+ }
3301
+ });
3302
+ var unresolvedReference = /^\{[^{}]+\}$/;
3303
+ var ResolvedThemeTokensSchema = ThemeTokensSchema.superRefine((input, context) => {
3304
+ const visit = (value, path) => {
3305
+ if (typeof value === "string" && unresolvedReference.test(value)) {
3306
+ context.addIssue({ code: "custom", path, message: "Resolved theme tokens cannot contain token aliases." });
3307
+ return;
3308
+ }
3309
+ if (Array.isArray(value)) {
3310
+ value.forEach((item, index) => visit(item, [...path, index]));
3311
+ return;
3312
+ }
3313
+ if (!value || typeof value !== "object") return;
3314
+ for (const [key, child] of Object.entries(value)) {
3315
+ if (key === "$ref") context.addIssue({ code: "custom", path: [...path, key], message: "Resolved theme tokens cannot contain $ref." });
3316
+ visit(child, [...path, key]);
3317
+ }
3318
+ };
3319
+ visit(input, []);
3320
+ });
3321
+
3322
+ // src/contracts/tenant.ts
3323
+ var DesignTokenFileSourceSchema = z11.object({
3324
+ type: z11.literal("file"),
3325
+ path: z11.string().trim().min(1).superRefine((source, context) => {
3326
+ if (/^[a-z][a-z\d+.-]*:/i.test(source)) {
3327
+ context.addIssue({
3328
+ code: "custom",
3329
+ message: "Design token file sources must use local file paths."
3330
+ });
3331
+ }
3332
+ })
3333
+ }).strict();
3334
+ var DesignTokenUrlSourceSchema = z11.object({
3335
+ type: z11.literal("url"),
3336
+ url: z11.string().trim().min(1).superRefine((source, context) => {
3337
+ if (!/^https?:\/\//i.test(source)) {
3338
+ context.addIssue({
3339
+ code: "custom",
3340
+ message: "Design token URL sources must use HTTP(S)."
3341
+ });
3342
+ }
3343
+ })
3344
+ }).strict();
3345
+ var DesignTokenInlineSourceSchema = z11.object({
3346
+ type: z11.literal("inline"),
3347
+ document: ThemeTokensSchema
3348
+ }).strict();
3349
+ var DesignTokenSourceSchema = z11.discriminatedUnion("type", [
3350
+ DesignTokenFileSourceSchema,
3351
+ DesignTokenUrlSourceSchema,
3352
+ DesignTokenInlineSourceSchema
3353
+ ]);
3354
+ var TenantDesignTokensConfigSchema = z11.object({
3355
+ /** Ordered tenant overrides. The backend always applies the product default first. */
3356
+ tokenSources: z11.array(DesignTokenSourceSchema)
3357
+ }).strict();
3358
+ var TenantAuthBindingSchema = z11.object({
3359
+ kind: z11.literal("auth-provider"),
3360
+ providerId: ContractIdentifierSchema,
3361
+ policyRef: ContractIdentifierSchema.optional()
3362
+ }).strict();
3363
+ var TenantDataBindingSchema = z11.discriminatedUnion("kind", [
3364
+ z11.object({
3365
+ kind: z11.literal("data-provider"),
3366
+ providerId: ContractIdentifierSchema,
3367
+ domainRef: ContractIdentifierSchema.optional()
3368
+ }).strict(),
3369
+ z11.object({
3370
+ kind: z11.literal("projection"),
3371
+ projectionRef: ContractIdentifierSchema,
3372
+ domainRef: ContractIdentifierSchema.optional()
3373
+ }).strict()
3374
+ ]);
3375
+ var TenantAuthBindingsSchema = z11.record(
3376
+ ContractIdentifierSchema,
3377
+ TenantAuthBindingSchema
3378
+ );
3379
+ var TenantDataBindingsSchema = z11.record(
3380
+ ContractIdentifierSchema,
3381
+ TenantDataBindingSchema
3382
+ );
3383
+ var AssetVariantsSchema = z11.object({
3384
+ light: z11.string().optional(),
3385
+ dark: z11.string().optional()
3386
+ }).strict();
3387
+ var ThemeHeadbarSchema = z11.object({
3388
+ theme: z11.enum(["fixed", "card", "glassy", "ghost", "bsd-blue"]).optional(),
3389
+ navPosition: z11.enum(["left", "center", "right"]).optional(),
3390
+ actions: z11.union([z11.literal("*"), z11.array(ContractIdentifierSchema)]).optional(),
3391
+ profile: z11.union([z11.literal("*"), z11.array(ContractIdentifierSchema)]).optional(),
3392
+ showTeamQuota: z11.boolean().optional()
3393
+ }).strict();
3394
+ var KernelHeadbarSchema = z11.object({
3395
+ theme: z11.literal("card").optional(),
3396
+ layoutMode: z11.enum(["boxed", "full-bleed"]).optional(),
3397
+ heightPx: z11.number().positive().optional(),
3398
+ navPosition: z11.enum(["left", "center", "right"]).optional(),
3399
+ brandTitle: z11.string().optional(),
3400
+ menuRadius: z11.enum(["default", "none", "sm", "md", "lg", "xl", "full"]).optional()
3401
+ }).strict();
3402
+ var CustomIconSchema = z11.object({
3403
+ color: z11.string().optional(),
3404
+ url: z11.string().optional(),
3405
+ type: z11.enum(["svg", "image"]).optional(),
3406
+ hintTextColor: z11.string().optional()
3407
+ }).strict();
3408
+ var WorkbenchCustomerToolSchema = z11.object({
3409
+ id: ContractIdentifierSchema,
3410
+ label: z11.union([z11.string(), z11.record(LocaleIdentifierSchema, z11.string())]).optional(),
3411
+ fixed: z11.boolean().optional()
3412
+ }).strict();
3413
+ var WorkbenchStudioOverrideSchema = z11.object({
3414
+ studioName: z11.string().trim().min(1),
3415
+ dropdownToolsDefault: z11.array(ContractIdentifierSchema).optional(),
3416
+ existingToolsDefault: z11.array(ContractIdentifierSchema).optional(),
3417
+ historyColumnsDefault: z11.number().int().min(1).max(6).optional()
3418
+ }).strict();
3419
+ var TenantWorkbenchPageContextSchema = z11.object({
3420
+ workflow: JsonObjectSchema.optional(),
3421
+ agent: JsonObjectSchema.optional(),
3422
+ agentId: ContractIdentifierSchema.optional(),
3423
+ designProject: JsonObjectSchema.optional(),
3424
+ designMetadataId: ContractIdentifierSchema.optional(),
3425
+ iframeUrl: z11.string().trim().min(1).optional(),
3426
+ info: z11.object({
3427
+ displayName: LocalizedTextSchema.optional(),
3428
+ description: LocalizedTextSchema.optional(),
3429
+ iconUrl: z11.string().trim().min(1).optional()
3430
+ }).strict().optional(),
3431
+ isBuiltinPinned: z11.boolean().optional(),
3432
+ isBuiltinReadonly: z11.boolean().optional()
3433
+ }).strict();
3434
+ var TenantWorkbenchPageEnvelopeSchema = z11.object({
3435
+ definition: PageDefinitionSchema,
3436
+ context: TenantWorkbenchPageContextSchema
3437
+ }).strict().superRefine(({ definition }, context) => {
3438
+ if (definition.surface !== "view") {
3439
+ context.addIssue({
3440
+ code: "custom",
3441
+ path: ["definition", "surface"],
3442
+ message: "Tenant workbench pages must render on the view surface."
3443
+ });
3444
+ }
3445
+ if (!definition.ownership.builtIn) {
3446
+ context.addIssue({
3447
+ code: "custom",
3448
+ path: ["definition", "ownership", "builtIn"],
3449
+ message: "Tenant workbench pages must be declared as built-in pages."
3450
+ });
3451
+ }
3452
+ if (!definition.navigation.pinned) {
3453
+ context.addIssue({
3454
+ code: "custom",
3455
+ path: ["definition", "navigation", "pinned"],
3456
+ message: "Tenant workbench pages must be pinned in workbench navigation."
3457
+ });
3458
+ }
3459
+ if (!definition.visibility.productContexts.includes("studio")) {
3460
+ context.addIssue({
3461
+ code: "custom",
3462
+ path: ["definition", "visibility", "productContexts"],
3463
+ message: "Tenant workbench pages must include the studio product context."
3464
+ });
3465
+ }
3466
+ });
3467
+ var TenantWorkbenchPageGroupSchema = z11.object({
3468
+ id: ContractIdentifierSchema,
3469
+ pageIds: z11.array(ContractIdentifierSchema),
3470
+ displayName: LocalizedTextSchema,
3471
+ isBuiltIn: z11.boolean(),
3472
+ iconUrl: z11.string().optional(),
3473
+ sortIndex: z11.number().int().nullable().optional(),
3474
+ presetRelationId: ContractIdentifierSchema.optional(),
3475
+ relationKey: ContractIdentifierSchema.nullable().optional(),
3476
+ studioId: ContractIdentifierSchema.optional()
3477
+ }).strict();
3478
+ var TenantWorkbenchConfigSchema = z11.object({
3479
+ pages: z11.array(TenantWorkbenchPageEnvelopeSchema),
3480
+ pageGroups: z11.array(TenantWorkbenchPageGroupSchema),
3481
+ catalog: z11.object({ enabled: z11.boolean().optional(), defaultEntry: z11.boolean().optional() }).strict().optional(),
3482
+ quickSwitcherMaxItems: z11.number().int().nonnegative().optional(),
3483
+ defaultOrder: z11.object({
3484
+ groups: z11.array(ContractIdentifierSchema),
3485
+ pages: z11.record(ContractIdentifierSchema, z11.array(ContractIdentifierSchema))
3486
+ }).strict().optional(),
3487
+ customers: z11.object({
3488
+ dropdownToolsDefault: z11.array(ContractIdentifierSchema).optional(),
3489
+ layoutManagerTools: z11.array(WorkbenchCustomerToolSchema).optional(),
3490
+ studioTabsMode: z11.enum(["dropdown", "tabs"]).optional(),
3491
+ historyWatermark: z11.object({
3492
+ svgUrl: z11.string().optional(),
3493
+ coverage: z11.array(z11.enum(["list", "detail", "download"])).optional(),
3494
+ maxLongEdgeRatio: z11.number().positive().optional(),
3495
+ sizing: z11.object({
3496
+ mode: ContractIdentifierSchema,
3497
+ heightRatio: z11.number().positive().optional(),
3498
+ minHeightPx: z11.number().nonnegative().optional(),
3499
+ maxHeightPx: z11.number().nonnegative().optional()
3500
+ }).strict().optional(),
3501
+ enhance: z11.object({
3502
+ enabled: z11.boolean().optional(),
3503
+ backgroundLumaThreshold: z11.number().min(0).max(1).optional(),
3504
+ stroke: z11.object({
3505
+ color: z11.string().optional(),
3506
+ opacity: z11.number().min(0).max(1).optional(),
3507
+ widthRatio: z11.number().nonnegative().optional(),
3508
+ blurRatio: z11.number().nonnegative().optional(),
3509
+ steps: z11.number().int().positive().optional()
3510
+ }).strict().optional()
3511
+ }).strict().optional()
3512
+ }).strict().optional(),
3513
+ layoutManagerEnabled: z11.boolean().optional(),
3514
+ existingToolsDefault: z11.array(ContractIdentifierSchema).optional(),
3515
+ historyColumnsDefault: z11.number().int().min(1).max(6).optional(),
3516
+ studioOverrides: z11.array(WorkbenchStudioOverrideSchema).optional()
3517
+ }).strict().optional()
3518
+ }).strict().superRefine(({ pages, pageGroups }, context) => {
3519
+ const pageIds = pages.map(({ definition }) => definition.pageId);
3520
+ const pageIdSet = new Set(pageIds);
3521
+ if (pageIdSet.size !== pageIds.length) {
3522
+ context.addIssue({ code: "custom", path: ["pages"], message: "Tenant workbench page ids must be unique." });
3523
+ }
3524
+ const groupIds = pageGroups.map(({ id }) => id);
3525
+ if (new Set(groupIds).size !== groupIds.length) {
3526
+ context.addIssue({ code: "custom", path: ["pageGroups"], message: "Tenant workbench page group ids must be unique." });
3527
+ }
3528
+ pageGroups.forEach((group, groupIndex) => {
3529
+ group.pageIds.forEach((pageId, pageIndex) => {
3530
+ if (!pageIdSet.has(pageId)) {
3531
+ context.addIssue({
3532
+ code: "custom",
3533
+ path: ["pageGroups", groupIndex, "pageIds", pageIndex],
3534
+ message: `Tenant workbench page group references undeclared page ${pageId}.`
3535
+ });
3536
+ }
3537
+ });
3538
+ });
3539
+ });
3540
+ var LoginPageSchema = z11.object({
3541
+ background: z11.object({ imageUrl: z11.string().optional(), gradient: z11.string().optional() }).strict().optional(),
3542
+ logo: z11.object({
3543
+ url: z11.string().optional(),
3544
+ lightUrl: z11.string().optional(),
3545
+ darkUrl: z11.string().optional(),
3546
+ position: z11.enum(["top", "middle", "bottom"]).optional(),
3547
+ scale: z11.number().positive().optional()
3548
+ }).strict().optional(),
3549
+ customCss: z11.string().optional()
3550
+ }).strict();
3551
+ var TenantApplicationConfigSchema = z11.object({
3552
+ theme: z11.object({
3553
+ id: z11.string().optional(),
3554
+ name: z11.string().optional(),
3555
+ title: z11.string().optional(),
3556
+ favicon: AssetVariantsSchema.optional(),
3557
+ logo: AssetVariantsSchema.optional(),
3558
+ pwaIcon: z11.string().optional(),
3559
+ form: z11.object({ variant: z11.enum(["bento", "ghost"]) }).strict().optional(),
3560
+ toast: z11.object({
3561
+ position: z11.enum(["top-right", "top-left", "bottom-right", "bottom-left", "top-center", "bottom-center"])
3562
+ }).strict().optional(),
3563
+ icons: z11.object({ error: CustomIconSchema.optional(), empty: CustomIconSchema.optional() }).strict().optional(),
3564
+ views: z11.object({
3565
+ form: z11.object({
3566
+ toast: z11.object({ afterCreate: z11.boolean(), afterDelete: z11.boolean() }).strict(),
3567
+ progress: z11.enum(["estimate", "infinite"]),
3568
+ onlyResult: z11.boolean(),
3569
+ tabular: z11.object({ theme: z11.enum(["default", "tentiary", "primary"]) }).strict()
3570
+ }).strict()
3571
+ }).strict().optional(),
3572
+ loginPage: LoginPageSchema.optional(),
3573
+ extraLanguageURL: z11.record(z11.string(), z11.string()).optional(),
3574
+ hideSpaceHeader: z11.boolean().optional(),
3575
+ showSidebarTeamSelector: z11.boolean().optional(),
3576
+ showWorkbenchSidebar: z11.boolean().optional(),
3577
+ workbenchViewTheme: z11.enum(["default", "bsd-blue"]).optional(),
3578
+ defaults: z11.object({
3579
+ showFormInImageDetail: z11.boolean().optional(),
3580
+ darkMode: z11.enum(["light", "dark", "auto"]).optional(),
3581
+ language: z11.enum(["en-US", "zh-CN", "ja-JP"]).optional(),
3582
+ showDarkModeToggle: z11.boolean().optional(),
3583
+ showLanguageToggle: z11.boolean().optional()
3584
+ }).strict().optional(),
3585
+ modules: z11.object({
3586
+ monkeysSpaceSidebar: z11.union([z11.literal("*"), z11.array(ContractIdentifierSchema)]).optional(),
3587
+ monkeysSpaceHeadbar: z11.union([
3588
+ z11.literal("*"),
3589
+ z11.array(
3590
+ z11.object({
3591
+ id: ContractIdentifierSchema,
3592
+ extraInfo: z11.boolean().optional(),
3593
+ displayName: z11.union([z11.string(), z11.record(LocaleIdentifierSchema, z11.string())]).optional(),
3594
+ visible: z11.boolean().optional(),
3595
+ disabled: z11.boolean().optional(),
3596
+ icon: z11.string().optional(),
3597
+ showQuickSwitcher: z11.boolean().optional(),
3598
+ showSidebar: z11.boolean().optional()
3599
+ }).strict()
3600
+ )
3601
+ ]).optional(),
3602
+ settingsSidebar: z11.union([z11.literal("*"), z11.array(ContractIdentifierSchema)]).optional()
3603
+ }).strict().optional(),
3604
+ headbar: ThemeHeadbarSchema.optional(),
3605
+ kernelLayout: z11.object({
3606
+ navigationMode: z11.enum(["sidebar", "topbar"]).optional(),
3607
+ allowNavigationModeSwitch: z11.boolean().optional(),
3608
+ headbar: KernelHeadbarSchema.optional()
3609
+ }).strict().optional(),
3610
+ paginationPosition: z11.enum(["left", "right"]).optional(),
3611
+ ugcViewIconOnlyMode: z11.boolean().optional(),
3612
+ workflowPreviewExecutionGrid: z11.object({
3613
+ selectionModeDisplayType: z11.enum(["operation-button", "dropdown-menu"]).optional(),
3614
+ clickBehavior: z11.enum(["preview", "select", "fill-form", "none"]).optional(),
3615
+ showErrorFilter: z11.boolean().optional(),
3616
+ displayType: z11.enum(["grid", "masonry"]).optional(),
3617
+ showDetailButton: z11.boolean().optional()
3618
+ }).strict().optional(),
3619
+ workbenchSidebarDefaultOpen: z11.boolean().optional(),
3620
+ workbenchSidebarMoreAction: z11.boolean().optional(),
3621
+ workbenchSidebarApart: z11.boolean().optional(),
3622
+ workbenchSidebarToggleGroupDetail: z11.boolean().optional(),
3623
+ workbenchSidebarViewType: z11.boolean().optional(),
3624
+ workbenchSidebarFormViewEmbed: z11.boolean().optional(),
3625
+ workbenchSidebarModernMode: z11.boolean().optional(),
3626
+ ugc: z11.object({ onItemClick: z11.boolean(), subtitle: z11.boolean().optional() }).strict().optional(),
3627
+ uniImagePreview: z11.boolean().optional(),
3628
+ imagePreviewStyle: z11.union([z11.literal(false), z11.enum(["simple", "normal", "uni"])]).optional(),
3629
+ teamAsUser: z11.boolean().optional(),
3630
+ themeMode: z11.enum(["shadow", "border"]).optional(),
3631
+ density: z11.enum(["compact", "default", "comfortable"]).optional(),
3632
+ pageZoom: z11.number().positive().optional(),
3633
+ miniMode: z11.object({ showPreviewViewExecutionResultGrid: z11.boolean() }).strict().optional(),
3634
+ workflow: z11.object({ allowConcurrentRuns: z11.boolean() }).strict().optional(),
3635
+ historyResult: z11.object({ display: z11.boolean() }).strict().optional(),
3636
+ uploader: z11.object({
3637
+ orientation: z11.enum(["vertical", "horizontal"]),
3638
+ pasteButton: z11.boolean(),
3639
+ statusText: z11.boolean()
3640
+ }).strict().optional(),
3641
+ designProjects: z11.object({
3642
+ oneOnOne: z11.boolean(),
3643
+ newTabOpenBoard: z11.boolean(),
3644
+ defaultShowGrid: z11.boolean().optional(),
3645
+ createDefaultFrame: z11.boolean(),
3646
+ showPageMenu: z11.boolean(),
3647
+ showMainMenu: z11.boolean(),
3648
+ showStylePanel: z11.boolean(),
3649
+ showToolbar: z11.boolean(),
3650
+ toolbarPosition: z11.enum(["bottom", "left"]).optional(),
3651
+ showContextMenu: z11.boolean(),
3652
+ showActionsMenu: z11.boolean(),
3653
+ showPageAndLayerSidebar: z11.boolean().optional(),
3654
+ showBoardOperationSidebar: z11.boolean().optional(),
3655
+ showMiniToolsToolbar: z11.boolean().optional(),
3656
+ showRightSidebar: z11.boolean().optional(),
3657
+ showRealtimeDrawing: z11.boolean().optional(),
3658
+ showWorkflow: z11.boolean().optional(),
3659
+ showVersionManager: z11.boolean().optional(),
3660
+ showAgent: z11.boolean().optional(),
3661
+ AgentTools: z11.array(ContractIdentifierSchema).optional()
3662
+ }).strict().optional(),
3663
+ workbench: TenantWorkbenchConfigSchema.optional(),
3664
+ visionProWorkflows: z11.array(ContractIdentifierSchema).optional(),
3665
+ initTeam: z11.boolean().optional(),
3666
+ imageThumbnail: z11.boolean().optional(),
3667
+ pages: z11.object({
3668
+ allowPageKeys: z11.union([z11.literal("*"), z11.array(ContractIdentifierSchema)]),
3669
+ defaultPageKey: ContractIdentifierSchema.optional()
3670
+ }).strict().optional(),
3671
+ agent: z11.object({
3672
+ brandDisplayMode: z11.enum(["auto", "logo-only", "logo-name", "name-only"]).optional(),
3673
+ density: z11.enum(["compact", "default", "comfortable"]).optional()
3674
+ }).strict().optional()
3675
+ }).strict(),
3676
+ auth: z11.object({
3677
+ enabled: z11.array(ContractIdentifierSchema).default([]),
3678
+ oidc: z11.object({ buttonText: z11.string().optional(), autoSignin: z11.boolean().optional() }).strict().optional(),
3679
+ password: z11.object({ disableAutoRegister: z11.boolean().optional() }).strict().optional(),
3680
+ hideAuthToast: z11.boolean().optional(),
3681
+ autoReload: z11.boolean().optional(),
3682
+ defaultOtherTeam: z11.boolean().optional()
3683
+ }).strict(),
3684
+ endpoints: z11.record(ContractIdentifierSchema, z11.string()),
3685
+ module: z11.union([z11.literal("*"), z11.array(ContractIdentifierSchema)]),
3686
+ behavior: z11.object({
3687
+ clearWorkflowFormStorageAfterUpdate: z11.boolean().optional(),
3688
+ autoApproveOAuth: z11.boolean().optional(),
3689
+ rememberWorkflowModelSelection: z11.boolean().optional()
3690
+ }).strict(),
3691
+ dataManagement: z11.object({
3692
+ favoriteBucketId: z11.string().optional(),
3693
+ pairedBucketId: z11.string().optional(),
3694
+ galleryBucketId: z11.string().optional(),
3695
+ dataBrowserDefaultBucketId: z11.string().optional(),
3696
+ workflowResultBucketId: z11.string().optional(),
3697
+ homeAdvertisement: z11.object({
3698
+ bucketId: ContractIdentifierSchema,
3699
+ viewId: ContractIdentifierSchema.optional(),
3700
+ viewType: z11.enum(["filter", "container", "share_link"]).optional(),
3701
+ teamId: ContractIdentifierSchema.optional(),
3702
+ teamOnly: z11.boolean().optional(),
3703
+ pageSize: z11.number().int().positive().optional(),
3704
+ sortBy: z11.enum(["pin_order", "asset_id", "updated_timestamp", "created_timestamp"]).optional(),
3705
+ sortOrder: z11.enum(["asc", "desc"]).optional(),
3706
+ fieldMap: z11.record(z11.string(), z11.string()).optional(),
3707
+ columnIds: z11.record(z11.string(), z11.string()).optional()
3708
+ }).strict().optional(),
3709
+ homeTrendAssistant: z11.object({
3710
+ bucketId: ContractIdentifierSchema.optional(),
3711
+ viewId: ContractIdentifierSchema.optional(),
3712
+ viewInstanceId: ContractIdentifierSchema.optional(),
3713
+ viewName: z11.string().optional(),
3714
+ teamId: ContractIdentifierSchema.optional(),
3715
+ designOptionsWorkflowId: ContractIdentifierSchema.optional(),
3716
+ tep: z11.object({ baseUrl: z11.string().optional(), timeoutMs: z11.number().int().positive().optional() }).strict().optional(),
3717
+ runtime: z11.object({ appId: ContractIdentifierSchema, tepBaseUrlConfigured: z11.boolean(), tepAuthorizationConfigured: z11.boolean(), tepCookieConfigured: z11.boolean() }).strict().optional()
3718
+ }).strict().optional(),
3719
+ sharing: z11.object({
3720
+ silentViewLinks: z11.object({ enabled: z11.boolean().optional(), placement: z11.object({ mode: z11.enum(["sourceBucket", "bucket"]).optional(), bucketId: ContractIdentifierSchema.optional(), parentId: ContractIdentifierSchema.optional(), navId: ContractIdentifierSchema.optional() }).strict().optional() }).strict().optional(),
3721
+ shareAccess: z11.object({ publicLinksEnabled: z11.boolean().optional(), passwordGateEnabled: z11.boolean().optional(), passwordAccessTtlSeconds: z11.number().int().positive().optional(), defaultViewTreeDelivery: z11.enum(["manual", "auto"]).optional() }).strict().optional(),
3722
+ shareDialog: z11.object({
3723
+ audience: z11.object({ enabled: z11.boolean().optional(), allowed: z11.array(z11.enum(["user", "team", "public"])).optional(), default: z11.enum(["user", "team", "public"]).optional() }).strict().optional(),
3724
+ accessLevel: z11.object({ enabled: z11.boolean().optional(), allowed: z11.array(z11.enum(["read", "write"])).optional(), default: z11.enum(["read", "write"]).optional() }).strict().optional(),
3725
+ viewTreeDelivery: z11.object({ enabled: z11.boolean().optional(), allowed: z11.array(z11.enum(["manual", "auto"])).optional(), default: z11.enum(["manual", "auto"]).optional() }).strict().optional()
3726
+ }).strict().optional()
3727
+ }).strict().optional()
3728
+ }).strict().optional(),
3729
+ compute: z11.object({
3730
+ integrations: z11.object({
3731
+ harbor: z11.object({ endpoint: z11.string().optional(), projectScopes: z11.array(z11.string()).optional(), authMode: z11.string().optional(), principal: z11.string().optional(), autoSync: z11.boolean().optional(), proxyUrl: z11.string().optional() }).strict().optional(),
3732
+ gitlab: z11.object({ baseUrl: z11.string().optional(), groupScopes: z11.array(z11.string()).optional(), tokenMode: z11.string().optional(), deployProjectPath: z11.string().optional(), deploymentReportsEnabled: z11.boolean().optional(), proxyUrl: z11.string().optional() }).strict().optional(),
3733
+ kubernetes: z11.object({ accessMode: z11.string().optional(), clusterAlias: z11.string().optional(), agentProjectPath: z11.string().optional(), agentName: z11.string().optional(), namespaceScopes: z11.array(z11.string()).optional(), rolloutObserverEnabled: z11.boolean().optional(), proxyUrl: z11.string().optional() }).strict().optional()
3734
+ }).strict().optional()
3735
+ }).strict().optional(),
3736
+ data: z11.object({}).strict().optional(),
3737
+ storage: z11.object({
3738
+ presignMode: z11.enum(["frontend", "backend", "both"]).optional(),
3739
+ presign: z11.object({
3740
+ expiresInSeconds: z11.number().int().positive(),
3741
+ buckets: z11.array(
3742
+ z11.object({
3743
+ id: ContractIdentifierSchema,
3744
+ provider: ContractIdentifierSchema,
3745
+ preferredUrlPatternId: ContractIdentifierSchema,
3746
+ urlPatterns: z11.array(
3747
+ z11.object({
3748
+ id: ContractIdentifierSchema,
3749
+ type: z11.enum(["bucket-hostname", "provider-hostname"]),
3750
+ hostname: z11.string().trim().min(1),
3751
+ preferred: z11.boolean().optional(),
3752
+ bucketSegment: z11.string().optional()
3753
+ }).strict()
3754
+ )
3755
+ }).strict()
3756
+ )
3757
+ }).strict().optional()
3758
+ }).strict().optional(),
3759
+ monkeyData: z11.object({ baseUrl: z11.string().optional() }).strict().optional()
3760
+ }).strict();
3761
+ var TenantProductConfigSchema = z11.object({
3762
+ contract: z11.literal("TenantProductConfig"),
3763
+ tenantId: ContractIdentifierSchema,
3764
+ appId: ContractIdentifierSchema,
3765
+ environment: ContractIdentifierSchema,
3766
+ designTokens: TenantDesignTokensConfigSchema,
3767
+ moduleRefs: z11.array(ContractIdentifierSchema).default([]),
3768
+ pageRefs: z11.array(ContractIdentifierSchema).default([]),
3769
+ featureFlags: z11.record(z11.string(), z11.boolean()).default({}),
3770
+ authBinding: TenantAuthBindingsSchema,
3771
+ dataBinding: TenantDataBindingsSchema,
3772
+ sourceMap: z11.record(z11.string(), ContractIdentifierSchema),
3773
+ warnings: z11.array(z11.string()).default([]),
3774
+ applicationConfig: TenantApplicationConfigSchema
3775
+ }).strict();
3776
+ var TenantRuntimeConfigSchema = z11.object({
3777
+ contract: z11.literal("TenantRuntimeConfig"),
3778
+ tenantId: ContractIdentifierSchema,
3779
+ appId: ContractIdentifierSchema,
3780
+ environment: ContractIdentifierSchema,
3781
+ designTokens: ResolvedThemeTokensSchema,
3782
+ moduleRefs: z11.array(ContractIdentifierSchema).default([]),
3783
+ pageRefs: z11.array(ContractIdentifierSchema).default([]),
3784
+ featureFlags: z11.record(z11.string(), z11.boolean()).default({}),
3785
+ authBinding: TenantAuthBindingsSchema,
3786
+ dataBinding: TenantDataBindingsSchema,
3787
+ sourceMap: z11.record(z11.string(), ContractIdentifierSchema),
3788
+ warnings: z11.array(z11.string()).default([]),
3789
+ applicationConfig: TenantApplicationConfigSchema
3790
+ }).strict();
3791
+
3792
+ // src/contracts/trend.ts
3793
+ import { z as z12 } from "zod";
3794
+ var RadarDecisionMetricsSchema = z12.object({
3795
+ currentSales: z12.number().finite(),
3796
+ forecastSales: z12.number().finite(),
3797
+ searchHeat: z12.number().finite(),
3798
+ socialHeat: z12.number().finite(),
3799
+ confidence: z12.number().min(0).max(1)
3800
+ }).strict();
3801
+ var TrendSourceSchema = z12.object({
3802
+ sourceId: ContractIdentifierSchema,
3803
+ provider: ContractIdentifierSchema,
3804
+ channel: z12.enum(["trend", "ecommerce", "social", "search", "internal"]),
3805
+ collectedAt: IsoDateTimeSchema,
3806
+ sourceUrl: z12.string().url().optional(),
3807
+ evidenceRefs: z12.array(EntityRefSchema).default([])
3808
+ }).strict();
3809
+ var TrendIngestRunSchema = z12.object({
3810
+ contract: z12.literal("TrendIngestRun"),
3811
+ ingestRunId: ContractIdentifierSchema,
3812
+ sourceId: ContractIdentifierSchema,
3813
+ requestId: ContractIdentifierSchema,
3814
+ idempotencyKey: ContractIdentifierSchema,
3815
+ status: z12.enum(["RUNNING", "SUCCEEDED", "FAILED", "PARTIAL"]),
3816
+ recordCount: z12.number().int().nonnegative(),
3817
+ errorCount: z12.number().int().nonnegative(),
3818
+ startedAt: IsoDateTimeSchema,
3819
+ completedAt: IsoDateTimeSchema.optional()
3820
+ }).strict();
3821
+ var TrendSourceRecordSchema = z12.object({
3822
+ contract: z12.literal("TrendSourceRecord"),
3823
+ sourceRecordId: ContractIdentifierSchema,
3824
+ source: TrendSourceSchema,
3825
+ ingestRunRef: EntityRefSchema,
3826
+ recordVersion: z12.number().int().positive(),
3827
+ contentHash: Sha256Schema,
3828
+ payload: JsonValueSchema,
3829
+ idempotencyKey: ContractIdentifierSchema,
3830
+ collectedAt: IsoDateTimeSchema
3831
+ }).strict();
3832
+ var HotwordBodySchema = z12.object({
3833
+ contract: z12.literal("HotwordBody"),
3834
+ hotwordId: ContractIdentifierSchema,
3835
+ label: z12.string().trim().min(1),
3836
+ normalizedLabel: z12.string().trim().min(1),
3837
+ categories: z12.array(ContractIdentifierSchema).default([]),
3838
+ sourceRefs: z12.array(TrendSourceSchema).min(1),
3839
+ relationRefs: z12.array(EntityRefSchema).default([]),
3840
+ createdAt: IsoDateTimeSchema,
3841
+ updatedAt: IsoDateTimeSchema
3842
+ }).strict();
3843
+ var CommerceBodyFieldsSchema = {
3844
+ displayName: z12.string().trim().min(1),
3845
+ normalizedName: z12.string().trim().min(1),
3846
+ categories: z12.array(ContractIdentifierSchema).default([]),
3847
+ sourceRefs: z12.array(EntityRefSchema).min(1),
3848
+ relationRefs: z12.array(EntityRefSchema).default([]),
3849
+ createdAt: IsoDateTimeSchema,
3850
+ updatedAt: IsoDateTimeSchema
3851
+ };
3852
+ var BrandBodySchema = z12.object({
3853
+ contract: z12.literal("BrandBody"),
3854
+ brandId: ContractIdentifierSchema,
3855
+ ...CommerceBodyFieldsSchema
3856
+ }).strict();
3857
+ var ProductBodySchema = z12.object({
3858
+ contract: z12.literal("ProductBody"),
3859
+ productId: ContractIdentifierSchema,
3860
+ brandRef: EntityRefSchema.optional(),
3861
+ ...CommerceBodyFieldsSchema
3862
+ }).strict();
3863
+ var TrendMetricSnapshotSchema = z12.object({
3864
+ contract: z12.literal("TrendMetricSnapshot"),
3865
+ snapshotId: ContractIdentifierSchema,
3866
+ subjectRef: EntityRefSchema,
3867
+ observedAt: IsoDateTimeSchema,
3868
+ metrics: z12.record(z12.string(), z12.number().finite()),
3869
+ confidence: z12.number().min(0).max(1),
3870
+ evidenceRefs: z12.array(EntityRefSchema).min(1)
3871
+ }).strict();
3872
+ var RadarScoreModelBodySchema = z12.object({
3873
+ contract: z12.literal("RadarScoreModelBody"),
3874
+ modelId: ContractIdentifierSchema,
3875
+ version: z12.number().int().positive(),
3876
+ weights: RadarDecisionMetricsSchema,
3877
+ thresholds: z12.record(z12.string(), z12.number().finite()).default({}),
3878
+ explanationRules: z12.record(z12.string(), z12.string().trim().min(1)).default({}),
3879
+ createdAt: IsoDateTimeSchema
3880
+ }).strict();
3881
+ var RadarScoreProjectionSchema = z12.object({
3882
+ contract: z12.literal("RadarScoreProjection"),
3883
+ projectionId: ContractIdentifierSchema,
3884
+ subjectRef: EntityRefSchema,
3885
+ modelRef: EntityRefSchema,
3886
+ totalScore: z12.number().finite(),
3887
+ dimensions: RadarDecisionMetricsSchema,
3888
+ evidenceRefs: z12.array(EntityRefSchema).min(1),
3889
+ freshnessAt: IsoDateTimeSchema
3890
+ }).strict();
3891
+ var RadarPanoramaNodeSchema = z12.object({
3892
+ ref: EntityRefSchema,
3893
+ label: z12.string().trim().min(1),
3894
+ categories: z12.array(ContractIdentifierSchema).default([]),
3895
+ score: z12.number().finite().optional(),
3896
+ freshnessAt: IsoDateTimeSchema.optional()
3897
+ }).strict();
3898
+ var RadarPanoramaEdgeSchema = z12.object({
3899
+ sourceRef: EntityRefSchema,
3900
+ targetRef: EntityRefSchema,
3901
+ relation: ContractIdentifierSchema,
3902
+ evidenceRefs: z12.array(EntityRefSchema).default([])
3903
+ }).strict();
3904
+ var RadarPanoramaSchema = z12.object({
3905
+ contract: z12.literal("RadarPanorama"),
3906
+ nodes: z12.array(RadarPanoramaNodeSchema),
3907
+ edges: z12.array(RadarPanoramaEdgeSchema),
3908
+ generatedAt: IsoDateTimeSchema
3909
+ }).strict();
3910
+ var BrandGeneticsProfileSchema = z12.object({
3911
+ contract: z12.literal("BrandGeneticsProfile"),
3912
+ brandRef: EntityRefSchema,
3913
+ categories: z12.array(ContractIdentifierSchema).default([]),
3914
+ signature: z12.record(ContractIdentifierSchema, z12.number().finite()),
3915
+ relatedRefs: z12.array(EntityRefSchema).default([]),
3916
+ evidenceRefs: z12.array(EntityRefSchema).default([]),
3917
+ computedAt: IsoDateTimeSchema
3918
+ }).strict();
3919
+ var RadarOpportunityMatrixPointSchema = z12.object({
3920
+ subjectRef: EntityRefSchema,
3921
+ label: z12.string().trim().min(1),
3922
+ x: z12.number().finite(),
3923
+ y: z12.number().finite(),
3924
+ score: z12.number().finite(),
3925
+ evidenceRefs: z12.array(EntityRefSchema).default([])
3926
+ }).strict();
3927
+ var RadarOpportunityMatrixSchema = z12.object({
3928
+ contract: z12.literal("RadarOpportunityMatrix"),
3929
+ xMetric: z12.enum(["currentSales", "forecastSales", "searchHeat", "socialHeat", "confidence"]),
3930
+ yMetric: z12.enum(["currentSales", "forecastSales", "searchHeat", "socialHeat", "confidence"]),
3931
+ points: z12.array(RadarOpportunityMatrixPointSchema),
3932
+ computedAt: IsoDateTimeSchema
3933
+ }).strict();
3934
+ var RadarQueryBodySchema = z12.object({
3935
+ contract: z12.literal("RadarQueryBody"),
3936
+ queryId: ContractIdentifierSchema,
3937
+ filters: z12.record(z12.string(), JsonValueSchema).default({}),
3938
+ sort: z12.object({
3939
+ field: ContractIdentifierSchema,
3940
+ direction: z12.enum(["asc", "desc"])
3941
+ }).strict(),
3942
+ pageSize: z12.number().int().min(1).max(200),
3943
+ updatedAt: IsoDateTimeSchema
3944
+ }).strict();
3945
+ var SavedRadarQuerySchema = z12.object({
3946
+ contract: z12.literal("SavedRadarQuery"),
3947
+ savedQueryId: ContractIdentifierSchema,
3948
+ teamId: ContractIdentifierSchema,
3949
+ ownerRef: EntityRefSchema,
3950
+ name: z12.string().trim().min(1),
3951
+ queryRef: EntityRefSchema,
3952
+ expectedVersion: z12.number().int().nonnegative(),
3953
+ updatedAt: IsoDateTimeSchema
3954
+ }).strict();
3955
+ var RadarSelectionSchema = z12.object({
3956
+ contract: z12.literal("RadarSelection"),
3957
+ selectionId: ContractIdentifierSchema,
3958
+ teamId: ContractIdentifierSchema,
3959
+ ownerRef: EntityRefSchema,
3960
+ subjectRefs: z12.array(EntityRefSchema),
3961
+ status: z12.enum(["stashed", "selected", "rejected", "archived"]),
3962
+ note: z12.string().optional(),
3963
+ expectedVersion: z12.number().int().nonnegative(),
3964
+ updatedAt: IsoDateTimeSchema
3965
+ }).strict();
3966
+ var RadarAnalysisRunSchema = z12.object({
3967
+ contract: z12.literal("RadarAnalysisRun"),
3968
+ runId: ContractIdentifierSchema,
3969
+ teamId: ContractIdentifierSchema,
3970
+ selectionRef: EntityRefSchema,
3971
+ workflowRef: EntityRefSchema,
3972
+ executionRef: EntityRefSchema.optional(),
3973
+ designProjectRef: EntityRefSchema.optional(),
3974
+ replayedFromRef: EntityRefSchema.optional(),
3975
+ workflowDefinitionTeamId: ContractIdentifierSchema.optional(),
3976
+ workflowInput: z12.record(z12.string(), JsonValueSchema).default({}),
3977
+ createDesignProject: z12.boolean().default(true),
3978
+ designProjectName: z12.string().trim().min(1).max(200).optional(),
3979
+ modelRef: EntityRefSchema,
3980
+ requestId: ContractIdentifierSchema,
3981
+ idempotencyKey: ContractIdentifierSchema,
3982
+ status: z12.enum(["QUEUED", "RUNNING", "SUCCEEDED", "FAILED", "CANCELLED", "PARTIAL"]),
3983
+ outputRefs: z12.array(EntityRefSchema).default([]),
3984
+ error: z12.object({
3985
+ code: ContractIdentifierSchema,
3986
+ message: z12.string().trim().min(1),
3987
+ retryable: z12.boolean()
3988
+ }).strict().optional(),
3989
+ startedAt: IsoDateTimeSchema.optional(),
3990
+ completedAt: IsoDateTimeSchema.optional(),
3991
+ createdAt: IsoDateTimeSchema
3992
+ }).strict();
3993
+ var RadarActionRecordSchema = z12.object({
3994
+ contract: z12.literal("RadarActionRecord"),
3995
+ actionId: ContractIdentifierSchema,
3996
+ teamId: ContractIdentifierSchema,
3997
+ actorRef: EntityRefSchema,
3998
+ action: z12.enum(["stash", "select", "reject", "archive", "launch", "retry", "replay", "rollback"]),
3999
+ targetRef: EntityRefSchema,
4000
+ requestId: ContractIdentifierSchema,
4001
+ idempotencyKey: ContractIdentifierSchema,
4002
+ expectedVersion: z12.number().int().nonnegative(),
4003
+ occurredAt: IsoDateTimeSchema
4004
+ }).strict();
4005
+ var RadarWritebackRecordSchema = z12.object({
4006
+ contract: z12.literal("RadarWritebackRecord"),
4007
+ writebackId: ContractIdentifierSchema,
4008
+ actionRef: EntityRefSchema,
4009
+ targetRef: EntityRefSchema,
4010
+ status: z12.enum(["PENDING", "APPLIED", "FAILED"]),
4011
+ resultingVersion: z12.number().int().nonnegative().optional(),
4012
+ error: z12.string().trim().min(1).optional(),
4013
+ recordedAt: IsoDateTimeSchema
4014
+ }).strict();
4015
+
4016
+ // src/contracts/workflow-definition.ts
4017
+ import { z as z13 } from "zod";
4018
+ var ConductorTaskTypeSchema = z13.enum([
4019
+ "SIMPLE",
4020
+ "DYNAMIC",
4021
+ "FORK_JOIN",
4022
+ "FORK_JOIN_DYNAMIC",
4023
+ "DECISION",
4024
+ "SWITCH",
4025
+ "JOIN",
4026
+ "DO_WHILE",
4027
+ "SUB_WORKFLOW",
4028
+ "START_WORKFLOW",
4029
+ "EVENT",
4030
+ "WAIT",
4031
+ "HUMAN",
4032
+ "USER_DEFINED",
4033
+ "HTTP",
4034
+ "LAMBDA",
4035
+ "INLINE",
4036
+ "EXCLUSIVE_JOIN",
4037
+ "TERMINATE",
4038
+ "KAFKA_PUBLISH",
4039
+ "JSON_JQ_TRANSFORM",
4040
+ "SET_VARIABLE",
4041
+ "CALL_MCP_TOOL",
4042
+ "GENERATE_AUDIO",
4043
+ "GENERATE_IMAGE",
4044
+ "GENERATE_PDF",
4045
+ "GENERATE_VIDEO",
4046
+ "LIST_MCP_TOOLS",
4047
+ "LLM_CHAT_COMPLETE",
4048
+ "LLM_GENERATE_EMBEDDINGS",
4049
+ "LLM_INDEX_TEXT",
4050
+ "LLM_SEARCH_INDEX",
4051
+ "TITUS",
4052
+ "USER_TASK"
4053
+ ]);
4054
+ var requiredTaskFields = {
4055
+ DO_WHILE: ["inputParameters", "loopOver"],
4056
+ EVENT: ["sink"],
4057
+ FORK_JOIN: ["forkTasks"],
4058
+ FORK_JOIN_DYNAMIC: ["inputParameters", "dynamicForkTasksParam", "dynamicForkTasksInputParamName"],
4059
+ DYNAMIC: ["inputParameters"],
4060
+ JOIN: ["joinOn"],
4061
+ SUB_WORKFLOW: ["subWorkflowParam"],
4062
+ SWITCH: ["inputParameters", "decisionCases", "evaluatorType", "expression"],
4063
+ DECISION: ["inputParameters", "decisionCases"],
4064
+ WAIT: ["inputParameters"],
4065
+ TERMINATE: ["inputParameters"]
4066
+ };
4067
+ var ConductorTaskDefinitionSchema = z13.lazy(
4068
+ () => z13.object({
4069
+ name: ContractIdentifierSchema,
4070
+ taskReferenceName: ContractIdentifierSchema,
4071
+ type: ConductorTaskTypeSchema,
4072
+ inputParameters: z13.record(z13.string(), JsonValueSchema).optional(),
4073
+ startDelay: z13.number().int().nonnegative().optional(),
4074
+ optional: z13.boolean().optional(),
4075
+ asyncComplete: z13.boolean().optional(),
4076
+ rateLimited: z13.boolean().optional(),
4077
+ retryCount: z13.number().int().nonnegative().optional(),
4078
+ taskDefinition: z13.record(z13.string(), JsonValueSchema).optional(),
4079
+ loopCondition: z13.string().optional(),
4080
+ loopOver: z13.array(ConductorTaskDefinitionSchema).optional(),
4081
+ sink: z13.string().optional(),
4082
+ forkTasks: z13.array(z13.array(ConductorTaskDefinitionSchema)).optional(),
4083
+ joinOn: z13.array(ContractIdentifierSchema).optional(),
4084
+ defaultExclusiveJoinTask: z13.array(ContractIdentifierSchema).optional(),
4085
+ dynamicForkTasksParam: z13.string().optional(),
4086
+ dynamicForkTasksInputParamName: z13.string().optional(),
4087
+ subWorkflowParam: z13.object({
4088
+ $ref: z13.string().optional(),
4089
+ name: ContractIdentifierSchema,
4090
+ version: z13.number().int().positive().optional(),
4091
+ taskToDomain: z13.record(z13.string(), z13.string()).optional(),
4092
+ workflowDefinition: z13.record(z13.string(), JsonValueSchema).optional()
4093
+ }).strict().optional(),
4094
+ decisionCases: z13.record(z13.string(), z13.array(ConductorTaskDefinitionSchema)).optional(),
4095
+ defaultCase: z13.array(ConductorTaskDefinitionSchema).optional(),
4096
+ evaluatorType: z13.enum(["value-param", "javascript", "graaljs"]).optional(),
4097
+ expression: z13.string().optional(),
4098
+ __alias: JsonValueSchema.optional(),
4099
+ callbackFromWorker: z13.boolean().optional(),
4100
+ caseExpression: JsonValueSchema.optional(),
4101
+ caseValueParam: z13.string().optional(),
4102
+ dependencies: z13.array(JsonValueSchema).optional(),
4103
+ description: z13.string().optional(),
4104
+ dynamicTaskNameParam: z13.string().optional(),
4105
+ joinMode: z13.string().optional(),
4106
+ permissive: z13.boolean().optional(),
4107
+ joinTaskRef: ContractIdentifierSchema.optional(),
4108
+ forkTaskRef: ContractIdentifierSchema.optional()
4109
+ }).strict().superRefine((task, context) => {
4110
+ for (const field of requiredTaskFields[task.type] ?? []) {
4111
+ if (task[field] === void 0) {
4112
+ context.addIssue({ code: "custom", path: [field], message: `${task.type} task requires ${String(field)}.` });
4113
+ }
4114
+ }
4115
+ if (task.type === "DO_WHILE" && (task.inputParameters?.mode === void 0 || task.inputParameters.mode === "expression") && task.loopCondition === void 0 && task.inputParameters?.loopCondition === void 0) {
4116
+ context.addIssue({ code: "custom", path: ["loopCondition"], message: "Expression DO_WHILE task requires loopCondition." });
4117
+ }
4118
+ })
4119
+ );
4120
+ var ConductorWorkflowDefinitionSchema = z13.object({
4121
+ ownerApp: z13.string().optional(),
4122
+ createTime: z13.number().int().nonnegative().optional(),
4123
+ updateTime: z13.number().int().nonnegative().optional(),
4124
+ createdBy: z13.string().optional(),
4125
+ updatedBy: z13.string().optional(),
4126
+ name: ContractIdentifierSchema,
4127
+ description: z13.string().optional(),
4128
+ version: z13.number().int().positive(),
4129
+ tasks: z13.array(ConductorTaskDefinitionSchema),
4130
+ inputParameters: z13.array(ContractIdentifierSchema),
4131
+ outputParameters: z13.record(z13.string(), JsonValueSchema).optional(),
4132
+ failureWorkflow: ContractIdentifierSchema.optional(),
4133
+ schemaVersion: z13.number().int().positive().optional(),
4134
+ restartable: z13.boolean().optional(),
4135
+ workflowStatusListenerEnabled: z13.boolean().optional(),
4136
+ ownerEmail: z13.string().email().optional(),
4137
+ timeoutPolicy: z13.enum(["TIME_OUT_WF", "ALERT_ONLY"]).optional(),
4138
+ timeoutSeconds: z13.number().int().nonnegative(),
4139
+ variables: z13.record(z13.string(), JsonValueSchema).optional(),
4140
+ inputTemplate: z13.record(z13.string(), JsonValueSchema).optional()
4141
+ }).strict();
4142
+ var WorkflowParameterTypeSchema = z13.enum([
4143
+ "string",
4144
+ "file",
4145
+ "number",
4146
+ "boolean",
4147
+ "options",
4148
+ "json",
4149
+ "notice",
4150
+ "canvas-assist"
4151
+ ]);
4152
+ var WorkflowConditionalStateSchema = z13.object({
4153
+ conditions: z13.array(
4154
+ z13.object({
4155
+ field: z13.string(),
4156
+ operator: z13.enum(["is", "isNot", "isGreaterThan", "isLessThan", "isGreaterThanOrEqual", "isLessThanOrEqual", "in", "notIn"]),
4157
+ value: JsonValueSchema
4158
+ }).strict()
4159
+ ),
4160
+ logic: z13.enum(["AND", "OR"]).optional()
4161
+ }).strict();
4162
+ var ImageSelectMappingAppearanceSchema = z13.object({
4163
+ columns: z13.number().int().min(1).max(4).optional(),
4164
+ cardSize: z13.enum(["sm", "md", "lg"]).optional(),
4165
+ imageAspectRatio: z13.enum(["square", "4:5", "3:4", "16:9"]).optional(),
4166
+ gap: z13.enum(["sm", "md", "lg"]).optional(),
4167
+ radius: z13.enum(["sm", "md", "lg", "xl"]).optional(),
4168
+ borderStyle: z13.enum(["none", "soft", "strong"]).optional(),
4169
+ borderWidth: z13.union([z13.literal(0), z13.literal(1), z13.literal(2)]).optional(),
4170
+ enableScroll: z13.boolean().optional(),
4171
+ maxHeight: z13.number().int().min(160).max(1200).optional(),
4172
+ enableCollapse: z13.boolean().optional(),
4173
+ visibleRows: z13.number().int().min(1).max(6).optional(),
4174
+ hideLabel: z13.boolean().optional(),
4175
+ hideDescription: z13.boolean().optional(),
4176
+ hideValue: z13.boolean().optional()
4177
+ }).strict();
4178
+ var ComfyWorkflowPortBindingSchema = z13.object({
4179
+ node: z13.union([z13.string(), z13.number()]),
4180
+ key: z13.string().optional()
4181
+ }).strict();
4182
+ var WorkflowParameterTypeOptionsSchema = z13.object({
4183
+ editor: z13.enum(["code", "codeNodeEditor", "htmlEditor", "sqlEditor", "json"]).optional(),
4184
+ editorLanguage: z13.enum(["javaScript", "json", "python", "sql"]).optional(),
4185
+ maxValue: z13.number().optional(),
4186
+ minValue: z13.number().optional(),
4187
+ max: z13.number().optional(),
4188
+ min: z13.number().optional(),
4189
+ multipleValues: z13.boolean().optional(),
4190
+ numberPrecision: z13.number().nonnegative().optional(),
4191
+ password: z13.boolean().optional(),
4192
+ rows: z13.number().int().positive().optional(),
4193
+ assetType: z13.string().optional(),
4194
+ accept: z13.string().optional(),
4195
+ maxSize: z13.number().positive().optional(),
4196
+ fileType: z13.string().optional(),
4197
+ aiMultiShotMainImageField: z13.string().optional(),
4198
+ aiMultiShotWorkflowAppId: z13.string().optional(),
4199
+ aiMultiShotWorkflowId: z13.string().optional(),
4200
+ allowCustomInput: z13.boolean().optional(),
4201
+ allowUploadVideo: z13.boolean().optional(),
4202
+ aspectRatioField: z13.string().optional(),
4203
+ assemblyValueType: z13.string().optional(),
4204
+ autoAnalyzeDesignImage: z13.boolean().optional(),
4205
+ autoDetectAspectRatio: z13.boolean().optional(),
4206
+ autoIncrementId: z13.boolean().optional(),
4207
+ comfyOptions: ComfyWorkflowPortBindingSchema.optional(),
4208
+ comfyuiModelServerId: z13.string().optional(),
4209
+ comfyuiModelTypeName: z13.string().optional(),
4210
+ defaultCustomInput: JsonValueSchema.optional(),
4211
+ descriptionAlert: z13.boolean().optional(),
4212
+ disabled: z13.union([z13.boolean(), WorkflowConditionalStateSchema]).optional(),
4213
+ editable: z13.union([z13.boolean(), WorkflowConditionalStateSchema]).optional(),
4214
+ enableAiMultiShot: z13.boolean().optional(),
4215
+ enableBooleanSwitchMode: z13.boolean().optional(),
4216
+ enableClear: z13.boolean().optional(),
4217
+ enableExpand: z13.boolean().optional(),
4218
+ enableImageMask: z13.boolean().optional(),
4219
+ enableImageOverlay: z13.boolean().optional(),
4220
+ enablePopupEditor: z13.boolean().optional(),
4221
+ enablePromptFontSize: z13.boolean().optional(),
4222
+ enableReset: z13.boolean().optional(),
4223
+ enableSelectItemIcon: z13.boolean().optional(),
4224
+ enableSelectList: z13.boolean().optional(),
4225
+ enableSelectSearch: z13.boolean().optional(),
4226
+ enableSliderEnterMode: z13.boolean().optional(),
4227
+ enableVoice: z13.boolean().optional(),
4228
+ expandButtonText: z13.string().optional(),
4229
+ foldUp: z13.boolean().optional(),
4230
+ hidden: z13.boolean().optional(),
4231
+ hideRequiredDot: z13.boolean().optional(),
4232
+ inlineTitleWithSelect: z13.boolean().optional(),
4233
+ knowledgeGraphButtonText: z13.string().optional(),
4234
+ identifyAttributeCount: z13.union([z13.number().nonnegative(), z13.string().min(1), z13.object({ min: z13.number().nonnegative().optional(), max: z13.number().nonnegative().optional() }).strict()]).optional(),
4235
+ identifyAttributes: z13.array(JsonValueSchema).optional(),
4236
+ identifyMaxVariants: z13.number().int().nonnegative().optional(),
4237
+ identifySourceField: z13.string().optional(),
4238
+ imageOverlayBaseField: z13.string().optional(),
4239
+ imageOverlayOverlayField: z13.string().optional(),
4240
+ imageSelectMappingAppearance: ImageSelectMappingAppearanceSchema.optional(),
4241
+ imageSelectMappingColumns: z13.number().int().min(1).max(4).optional(),
4242
+ imageSelectMappingEnableCustomUpload: z13.boolean().optional(),
4243
+ imageSelectMappingHideLabel: z13.boolean().optional(),
4244
+ imageSelectMappingHideLink: z13.boolean().optional(),
4245
+ imageSelectMappingHideMeta: z13.boolean().optional(),
4246
+ imageSelectMappingInlineUseLargeUploadBox: z13.boolean().optional(),
4247
+ imageSelectMappingPromptField: z13.string().optional(),
4248
+ imageSelectMappingTabOrder: z13.enum(["template-first", "upload-first"]).optional(),
4249
+ imageSelectMappingTabWidthMode: z13.enum(["content", "fill"]).optional(),
4250
+ imageSelectMappingTemplatePrompt: LocalizedTextSchema.optional(),
4251
+ imageSelectMappingTemplateTabTitle: LocalizedTextSchema.optional(),
4252
+ imageSelectMappingUploadMode: z13.enum(["tabs", "inline"]).optional(),
4253
+ imageSelectMappingUploadPrompt: LocalizedTextSchema.optional(),
4254
+ imageSelectMappingUploadTabTitle: LocalizedTextSchema.optional(),
4255
+ endpoints: z13.array(JsonValueSchema).optional(),
4256
+ examples: z13.array(JsonValueSchema).optional(),
4257
+ extraData: JsonValueSchema.optional(),
4258
+ layer: JsonValueSchema.optional(),
4259
+ map: JsonValueSchema.optional(),
4260
+ multiline: z13.boolean().optional(),
4261
+ options: z13.array(JsonValueSchema).optional(),
4262
+ originalFiles: z13.array(JsonValueSchema).optional(),
4263
+ placeholder: LocalizedTextSchema.optional(),
4264
+ preserveSelectListOrder: z13.boolean().optional(),
4265
+ promptDictionary: JsonValueSchema.optional(),
4266
+ promptFontSize: z13.number().optional(),
4267
+ promptModeToggle: JsonValueSchema.optional(),
4268
+ requireActiveSelectFilter: z13.boolean().optional(),
4269
+ restoreDefaultOnEmptyEnter: z13.boolean().optional(),
4270
+ search: z13.boolean().optional(),
4271
+ selectButtonEnableCollapse: z13.boolean().optional(),
4272
+ selectButtonVisibleRows: z13.number().int().positive().optional(),
4273
+ selectList: z13.array(JsonValueSchema).optional(),
4274
+ selectListDisplayMode: z13.string().optional(),
4275
+ selectPromptField: z13.string().optional(),
4276
+ showAddLocalFileButton: z13.boolean().optional(),
4277
+ singleColumn: z13.boolean().optional(),
4278
+ singleFrameForMultiple: z13.boolean().optional(),
4279
+ textSingleLine: z13.boolean().optional(),
4280
+ textareaMiniHeight: z13.number().nonnegative().optional(),
4281
+ tips: LocalizedTextSchema.optional(),
4282
+ visibility: JsonValueSchema.optional(),
4283
+ voiceButtonText: z13.string().optional(),
4284
+ designAnalysisFields: z13.array(JsonValueSchema).optional(),
4285
+ designAnalysisFillStrategy: z13.string().optional(),
4286
+ designAnalysisMaxFields: z13.number().int().nonnegative().optional(),
4287
+ designAnalysisType: z13.string().optional(),
4288
+ designAnalysisFieldPrefix: z13.string().optional()
4289
+ }).strict();
4290
+ var WorkflowParameterSchema = z13.lazy(
4291
+ () => z13.object({
4292
+ displayName: LocalizedTextSchema,
4293
+ name: ContractIdentifierSchema,
4294
+ type: WorkflowParameterTypeSchema,
4295
+ typeOptions: WorkflowParameterTypeOptionsSchema.optional(),
4296
+ default: JsonValueSchema.optional(),
4297
+ description: LocalizedTextSchema.optional(),
4298
+ hint: z13.string().optional(),
4299
+ displayOptions: z13.object({
4300
+ hide: z13.record(z13.string(), z13.array(JsonValueSchema)).optional(),
4301
+ show: z13.record(z13.string(), z13.array(JsonValueSchema)).optional()
4302
+ }).strict().optional(),
4303
+ options: z13.array(z13.union([
4304
+ z13.object({ name: LocalizedTextSchema, value: z13.union([z13.string(), z13.number(), z13.boolean()]), action: z13.string().optional(), description: LocalizedTextSchema.optional() }).strict(),
4305
+ WorkflowParameterSchema,
4306
+ z13.object({ displayName: z13.string(), name: ContractIdentifierSchema, values: z13.array(WorkflowParameterSchema) }).strict()
4307
+ ])).optional(),
4308
+ placeholder: LocalizedTextSchema.optional(),
4309
+ isNodeSetting: z13.boolean().optional(),
4310
+ noDataExpression: z13.boolean().optional(),
4311
+ required: z13.boolean().optional(),
4312
+ example: z13.string().optional(),
4313
+ extractValue: z13.object({ type: z13.literal("regex"), regex: z13.string() }).strict().optional(),
4314
+ properties: z13.array(WorkflowParameterSchema).optional(),
4315
+ assetType: z13.string().optional(),
4316
+ flag: z13.boolean().optional(),
4317
+ enableExpand: z13.boolean().optional(),
4318
+ enableVoice: z13.boolean().optional(),
4319
+ expandButtonText: z13.string().optional(),
4320
+ knowledgeGraphButtonText: z13.string().optional(),
4321
+ selectListDisplayMode: z13.string().optional(),
4322
+ voiceButtonText: z13.string().optional()
4323
+ }).strict()
4324
+ );
4325
+ var WorkflowOutputBindingSchema = z13.object({ key: ContractIdentifierSchema, value: z13.string() }).strict();
4326
+ var WorkflowNodeSchema = z13.object({
4327
+ id: ContractIdentifierSchema,
4328
+ referenceName: ContractIdentifierSchema,
4329
+ capabilityRef: ContractIdentifierSchema,
4330
+ capabilityVersion: ContractIdentifierSchema.optional(),
4331
+ inputBindings: z13.record(z13.string(), JsonValueSchema).default({}),
4332
+ configuration: z13.object({ executor: z13.literal("conductor"), task: ConductorTaskDefinitionSchema }).strict()
4333
+ }).strict().superRefine((node, context) => {
4334
+ if (node.configuration.task.taskReferenceName !== node.referenceName) context.addIssue({ code: "custom", path: ["configuration", "task", "taskReferenceName"], message: "Conductor task reference must match node referenceName." });
4335
+ if (node.configuration.task.name !== node.capabilityRef) context.addIssue({ code: "custom", path: ["configuration", "task", "name"], message: "Conductor task name must match node capabilityRef." });
4336
+ if (JSON.stringify(node.configuration.task.inputParameters ?? {}) !== JSON.stringify(node.inputBindings)) context.addIssue({ code: "custom", path: ["configuration", "task", "inputParameters"], message: "Conductor task inputs must match node inputBindings." });
4337
+ });
4338
+ var WorkflowEdgeSchema = z13.object({
4339
+ from: ContractIdentifierSchema,
4340
+ to: ContractIdentifierSchema,
4341
+ outputPort: ContractIdentifierSchema.optional(),
4342
+ inputPort: ContractIdentifierSchema.optional(),
4343
+ condition: z13.string().optional()
4344
+ }).strict();
4345
+ var WorkflowTriggerSchema = z13.object({
4346
+ id: ContractIdentifierSchema,
4347
+ type: z13.enum(["manual", "schedule", "webhook", "event", "api"]),
4348
+ enabled: z13.boolean(),
4349
+ schedule: z13.object({ cron: z13.string().trim().min(1) }).strict().optional(),
4350
+ webhook: z13.object({
4351
+ path: z13.string().trim().min(1).optional(),
4352
+ method: z13.enum(["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"]),
4353
+ auth: z13.enum(["NONE", "BASIC", "CUSTOM_HEADER"]),
4354
+ basicAuth: z13.object({ username: z13.string(), password: z13.string() }).strict().optional(),
4355
+ headerAuth: z13.object({ name: z13.string().trim().min(1), value: z13.string() }).strict().optional(),
4356
+ responseUntil: z13.enum(["WORKFLOW_STARTED", "WORKFLOW_COMPLETED_OR_FINISHED"])
4357
+ }).strict().optional(),
4358
+ event: z13.object({
4359
+ eventType: ContractIdentifierSchema,
4360
+ configuration: JsonValueSchema.optional()
4361
+ }).strict().optional()
4362
+ }).strict().superRefine((trigger, context) => {
4363
+ if (trigger.type === "schedule" && !trigger.schedule) context.addIssue({ code: "custom", path: ["schedule"], message: "Schedule trigger requires schedule configuration." });
4364
+ if (trigger.type === "webhook" && !trigger.webhook) context.addIssue({ code: "custom", path: ["webhook"], message: "Webhook trigger requires webhook configuration." });
4365
+ if (trigger.type === "event" && !trigger.event) context.addIssue({ code: "custom", path: ["event"], message: "Event trigger requires event configuration." });
4366
+ });
4367
+ var WorkflowValidationIssueSchema = z13.object({
4368
+ taskReferenceName: ContractIdentifierSchema,
4369
+ issueType: z13.enum(["ERROR", "WARNING"]),
4370
+ detailReason: z13.object({ type: ContractIdentifierSchema, name: ContractIdentifierSchema, detailInformation: JsonValueSchema.optional() }).strict(),
4371
+ humanMessage: z13.object({ en: z13.string(), zh: z13.string() }).strict()
4372
+ }).strict();
4373
+ var WorkflowDefinitionSchema = z13.object({
4374
+ contract: z13.literal("WorkflowDefinition"),
4375
+ metadata: ContractMetadataSchema.omit({ name: true, description: true, labels: true }).extend({
4376
+ name: LocalizedTextSchema,
4377
+ description: LocalizedTextSchema.optional(),
4378
+ role: z13.enum(["workflow", "template"]),
4379
+ teamId: ContractIdentifierSchema,
4380
+ creatorRef: EntityRefSchema,
4381
+ tags: z13.array(ContractIdentifierSchema).default([])
4382
+ }).strict(),
4383
+ revision: z13.object({
4384
+ kind: z13.enum(["release", "backup"]),
4385
+ recordVersion: z13.number().int().positive(),
4386
+ sourceVersion: z13.number().int().positive().optional()
4387
+ }).strict().superRefine((revision, context) => {
4388
+ if (revision.kind === "backup" && revision.sourceVersion === void 0) context.addIssue({ code: "custom", path: ["sourceVersion"], message: "Backup revisions require a sourceVersion." });
4389
+ }),
4390
+ presentation: z13.object({ iconUrl: z13.string().optional(), thumbnail: z13.string().optional() }).strict(),
4391
+ ports: z13.object({ inputs: z13.array(ContractPortSchema).default([]), outputs: z13.array(ContractPortSchema).default([]) }).strict(),
4392
+ parameters: z13.object({ variables: z13.array(WorkflowParameterSchema).default([]), outputs: z13.array(WorkflowOutputBindingSchema).default([]) }).strict(),
4393
+ graph: z13.object({ nodes: z13.array(WorkflowNodeSchema), edges: z13.array(WorkflowEdgeSchema).default([]) }).strict(),
4394
+ execution: z13.object({
4395
+ timeoutMs: z13.number().int().positive().optional(),
4396
+ retries: z13.number().int().nonnegative().default(0),
4397
+ concurrencyLimit: z13.number().int().positive().optional(),
4398
+ idempotency: z13.enum(["required", "supported", "none"]),
4399
+ rateLimit: z13.object({ enabled: z13.boolean(), max: z13.number().int().nonnegative(), windowMs: z13.number().int().nonnegative() }).strict().superRefine((rateLimit, context) => {
4400
+ if (rateLimit.enabled && (rateLimit.max === 0 || rateLimit.windowMs === 0)) context.addIssue({ code: "custom", message: "Enabled rate limit requires positive max and windowMs." });
4401
+ }).optional(),
4402
+ conductor: z13.object({
4403
+ ownerApp: z13.string().optional(),
4404
+ createTime: z13.number().int().nonnegative().optional(),
4405
+ updateTime: z13.number().int().nonnegative().optional(),
4406
+ createdBy: z13.string().optional(),
4407
+ updatedBy: z13.string().optional(),
4408
+ failureWorkflow: ContractIdentifierSchema.optional(),
4409
+ schemaVersion: z13.number().int().positive().optional(),
4410
+ restartable: z13.boolean().optional(),
4411
+ workflowStatusListenerEnabled: z13.boolean().optional(),
4412
+ ownerEmail: z13.string().email().optional(),
4413
+ timeoutPolicy: z13.enum(["TIME_OUT_WF", "ALERT_ONLY"]).optional(),
4414
+ variables: z13.record(z13.string(), JsonValueSchema).optional(),
4415
+ inputTemplate: z13.record(z13.string(), JsonValueSchema).optional()
4416
+ }).strict()
4417
+ }).strict(),
4418
+ triggers: z13.array(WorkflowTriggerSchema).default([]),
4419
+ views: z13.array(z13.object({ pageRef: ContractIdentifierSchema, placement: ContractIdentifierSchema.optional() }).strict()).default([]),
4420
+ dataContracts: z13.object({ reads: z13.array(ContractIdentifierSchema).default([]), writes: z13.array(ContractIdentifierSchema).default([]), emits: z13.array(ContractIdentifierSchema).default([]) }).strict(),
4421
+ governance: z13.object({ activated: z13.boolean(), validated: z13.boolean(), validationIssues: z13.array(WorkflowValidationIssueSchema).default([]), hidden: z13.boolean().optional() }).strict(),
4422
+ interfaces: z13.object({
4423
+ openai: z13.object({ enabled: z13.boolean(), modelName: z13.string().trim().min(1).optional() }).strict(),
4424
+ shortcutRef: EntityRefSchema.optional(),
4425
+ preferredAppId: ContractIdentifierSchema.optional()
4426
+ }).strict().superRefine((interfaces, context) => {
4427
+ if (interfaces.openai.enabled && !interfaces.openai.modelName) context.addIssue({ code: "custom", path: ["openai", "modelName"], message: "Enabled OpenAI interface requires modelName." });
4428
+ if (interfaces.shortcutRef && interfaces.shortcutRef.kind !== "workflow") context.addIssue({ code: "custom", path: ["shortcutRef", "kind"], message: "shortcutRef must reference a workflow." });
4429
+ })
4430
+ }).strict().superRefine((definition, context) => {
4431
+ const nodeIds = new Set(definition.graph.nodes.map((node) => node.id));
4432
+ const references = new Set(definition.graph.nodes.map((node) => node.referenceName));
4433
+ if (nodeIds.size !== definition.graph.nodes.length) context.addIssue({ code: "custom", path: ["graph", "nodes"], message: "Workflow node ids must be unique." });
4434
+ if (references.size !== definition.graph.nodes.length) context.addIssue({ code: "custom", path: ["graph", "nodes"], message: "Workflow node reference names must be unique." });
4435
+ definition.graph.edges.forEach((edge, index) => {
4436
+ if (!nodeIds.has(edge.from) || !nodeIds.has(edge.to)) context.addIssue({ code: "custom", path: ["graph", "edges", index], message: "Workflow edges must reference existing node ids." });
4437
+ });
4438
+ if (definition.revision.kind === "release" && definition.metadata.version !== definition.revision.recordVersion) context.addIssue({ code: "custom", path: ["revision", "recordVersion"], message: "Release recordVersion must equal metadata.version." });
4439
+ });
4440
+ export {
4441
+ ActorRefSchema,
4442
+ AgentRuntimeEventSchema,
4443
+ ApplicationHandoffEndpointSchema,
4444
+ ApplicationHandoffSchema,
4445
+ ApplicationRunSchema,
4446
+ ArtifactAccessSchema,
4447
+ ArtifactManifestSchema,
4448
+ AuthorityScopeSchema,
4449
+ BodyRelationRecordSchema,
4450
+ BrandBodySchema,
4451
+ BrandGeneticsProfileSchema,
4452
+ CapabilityManifestSchema,
4453
+ CapabilityProviderBindingSchema,
4454
+ CapabilityRegistryDocumentSchema,
4455
+ CapabilityRegistryEntrySchema,
4456
+ CapabilityRegistrySourceSchema,
4457
+ CapabilitySourceTypeSchema,
4458
+ ChangeImpactGraphSchema,
4459
+ ChangeImpactSchema,
4460
+ CompletionEventSchema,
4461
+ CompletionHeaderSchema,
4462
+ ConceptDefinitionSchema,
4463
+ ConceptRelationshipSchema,
4464
+ ConductorTaskDefinitionSchema,
4465
+ ConductorTaskTypeSchema,
4466
+ ConductorWorkflowDefinitionSchema,
4467
+ ContractIdentifierSchema,
4468
+ ContractMetadataSchema,
4469
+ ContractPortSchema,
4470
+ ContractVersionSchema,
4471
+ DataContinuityEnvelopeSchema,
4472
+ DeclarationGraphEdgeSchema,
4473
+ DesignTokenSourceSchema,
4474
+ DomainCommandDefinitionSchema,
4475
+ DomainCommandSchema,
4476
+ DomainEventSchema,
4477
+ EntityRefSchema,
4478
+ ExecutionLinkSchema,
4479
+ ExpiringAccessGrantSchema,
4480
+ HotwordBodySchema,
4481
+ IsoDateTimeSchema,
4482
+ JsonObjectSchema,
4483
+ JsonValueSchema,
4484
+ LineageRecordSchema,
4485
+ LocaleIdentifierSchema,
4486
+ LocalizedTextSchema,
4487
+ OntologyDefinitionSchema,
4488
+ OutputRecordSchema,
4489
+ OverlayNodeSchema,
4490
+ OverlayZIndexLaneSchema,
4491
+ PageDefinitionSchema,
4492
+ PageGuardProjectionSchema,
4493
+ PageNavigationProjectionSchema,
4494
+ PageRendererProjectionSchema,
4495
+ PageRoutePathSchema,
4496
+ PageRouteProjectionSchema,
4497
+ PageRuntimeDescriptorSchema,
4498
+ PageRuntimeProjectionSchema,
4499
+ PageTypeSchema,
4500
+ PageVisibilitySchema,
4501
+ ProductBodySchema,
4502
+ ProductContextSchema,
4503
+ ProductDeclarationSchema,
4504
+ ProjectionSpecSchema,
4505
+ RadarActionRecordSchema,
4506
+ RadarAnalysisRunSchema,
4507
+ RadarDecisionMetricsSchema,
4508
+ RadarOpportunityMatrixPointSchema,
4509
+ RadarOpportunityMatrixSchema,
4510
+ RadarPanoramaEdgeSchema,
4511
+ RadarPanoramaNodeSchema,
4512
+ RadarPanoramaSchema,
4513
+ RadarQueryBodySchema,
4514
+ RadarScoreModelBodySchema,
4515
+ RadarScoreProjectionSchema,
4516
+ RadarSelectionSchema,
4517
+ RadarWritebackRecordSchema,
4518
+ RenderActivationSchema,
4519
+ RenderLayoutSchema,
4520
+ RenderLifecycleSchema,
4521
+ RenderNodeKindSchema,
4522
+ RenderNodeSchema,
4523
+ RenderNodeStateSchema,
4524
+ RenderResponsiveRuleSchema,
4525
+ RenderScrollSchema,
4526
+ RenderSurfaceSchema,
4527
+ RenderTreeSchema,
4528
+ RequestScopeSchema,
4529
+ ResolvedThemeTokensSchema,
4530
+ SavedRadarQuerySchema,
4531
+ Sha256Schema,
4532
+ SourceRecordRefSchema,
4533
+ StorageLocatorSchema,
4534
+ TenantApplicationConfigSchema,
4535
+ TenantAuthBindingSchema,
4536
+ TenantAuthBindingsSchema,
4537
+ TenantDataBindingSchema,
4538
+ TenantDataBindingsSchema,
4539
+ TenantDesignTokensConfigSchema,
4540
+ TenantProductConfigSchema,
4541
+ TenantRuntimeConfigSchema,
4542
+ TenantWorkbenchConfigSchema,
4543
+ TenantWorkbenchPageContextSchema,
4544
+ TenantWorkbenchPageEnvelopeSchema,
4545
+ TenantWorkbenchPageGroupSchema,
4546
+ ThemeTokenGroupSchema,
4547
+ ThemeTokenSchema,
4548
+ ThemeTokenTypeSchema,
4549
+ ThemeTokensSchema,
4550
+ TrendIngestRunSchema,
4551
+ TrendMetricSnapshotSchema,
4552
+ TrendSourceRecordSchema,
4553
+ TrendSourceSchema,
4554
+ ViewProviderDescriptorSchema,
4555
+ WorkflowDefinitionSchema,
4556
+ WorkflowEdgeSchema,
4557
+ WorkflowNodeSchema,
4558
+ WorkflowOutputBindingSchema,
4559
+ WorkflowParameterSchema,
4560
+ WorkflowParameterTypeSchema,
4561
+ WorkflowTriggerSchema,
4562
+ WorkflowValidationIssueSchema
4563
+ };
4564
+ //# sourceMappingURL=index.mjs.map