@inf-monkeys-tech/monkeys 1.0.65 → 1.0.68

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/README.md +6 -0
  2. package/lib/contracts/capability.d.ts +4 -0
  3. package/lib/contracts/capability.d.ts.map +1 -1
  4. package/lib/contracts/capability.js +1 -0
  5. package/lib/contracts/capability.js.map +1 -1
  6. package/lib/contracts/declarative-control-http.d.ts +81420 -0
  7. package/lib/contracts/declarative-control-http.d.ts.map +1 -0
  8. package/lib/contracts/declarative-control-http.js +926 -0
  9. package/lib/contracts/declarative-control-http.js.map +1 -0
  10. package/lib/contracts/declarative-control.d.ts +17753 -0
  11. package/lib/contracts/declarative-control.d.ts.map +1 -0
  12. package/lib/contracts/declarative-control.js +1078 -0
  13. package/lib/contracts/declarative-control.js.map +1 -0
  14. package/lib/contracts/index.d.ts +2 -0
  15. package/lib/contracts/index.d.ts.map +1 -1
  16. package/lib/contracts/index.js +2 -0
  17. package/lib/contracts/index.js.map +1 -1
  18. package/lib/contracts/menu.d.ts +1 -1
  19. package/lib/contracts/page.d.ts +3 -3
  20. package/lib/contracts/semantic.d.ts +78 -1
  21. package/lib/contracts/semantic.d.ts.map +1 -1
  22. package/lib/contracts/semantic.js +27 -1
  23. package/lib/contracts/semantic.js.map +1 -1
  24. package/lib/contracts/tenant.d.ts +81 -12
  25. package/lib/contracts/tenant.d.ts.map +1 -1
  26. package/lib/contracts/tenant.js +279 -93
  27. package/lib/contracts/tenant.js.map +1 -1
  28. package/lib/contracts/trend.d.ts +4 -4
  29. package/lib/esm/contracts/index.mjs +2963 -1048
  30. package/lib/esm/contracts/index.mjs.map +1 -1
  31. package/lib/esm/index.mjs +5820 -3025
  32. package/lib/esm/index.mjs.map +1 -1
  33. package/lib/esm/runtime/index.mjs +2529 -632
  34. package/lib/esm/runtime/index.mjs.map +1 -1
  35. package/lib/esm/schemas/index.mjs +2081 -982
  36. package/lib/esm/schemas/index.mjs.map +1 -1
  37. package/lib/json-schema/capability-registry.schema.json +2 -1
  38. package/lib/json-schema/declarative-control-ontology-definition.schema.json +130 -0
  39. package/lib/json-schema/index.json +13 -0
  40. package/lib/json-schema/navigation-release.schema.json +2037 -0
  41. package/lib/json-schema/navigation-runtime-bundle.schema.json +7505 -0
  42. package/lib/json-schema/navigation.schema.json +4649 -0
  43. package/lib/json-schema/page-release.schema.json +2465 -0
  44. package/lib/json-schema/page-runtime-bundle.schema.json +5713 -0
  45. package/lib/json-schema/page.schema.json +7944 -0
  46. package/lib/json-schema/publication-plan.schema.json +1286 -0
  47. package/lib/json-schema/route-space.schema.json +93 -0
  48. package/lib/json-schema/stable-ref-alias-map.schema.json +535 -0
  49. package/lib/json-schema/tenant-product-config.schema.json +73 -0
  50. package/lib/json-schema/tenant-runtime-config.schema.json +73 -0
  51. package/lib/json-schema/workbench-release.schema.json +2481 -0
  52. package/lib/json-schema/workbench-runtime-bundle.schema.json +5290 -0
  53. package/lib/json-schema/workbench.schema.json +6698 -0
  54. package/lib/runtime/declarative-control-compiler.d.ts +141 -0
  55. package/lib/runtime/declarative-control-compiler.d.ts.map +1 -0
  56. package/lib/runtime/declarative-control-compiler.js +875 -0
  57. package/lib/runtime/declarative-control-compiler.js.map +1 -0
  58. package/lib/runtime/index.d.ts +1 -0
  59. package/lib/runtime/index.d.ts.map +1 -1
  60. package/lib/runtime/index.js +1 -0
  61. package/lib/runtime/index.js.map +1 -1
  62. package/lib/schemas/index.d.ts +14061 -3830
  63. package/lib/schemas/index.d.ts.map +1 -1
  64. package/lib/schemas/index.js +76 -4
  65. package/lib/schemas/index.js.map +1 -1
  66. package/package.json +1 -1
@@ -7012,7 +7012,8 @@ var CapabilitySourceTypeSchema = z3.enum([
7012
7012
  "plugin-manifest",
7013
7013
  "openapi",
7014
7014
  "workflow",
7015
- "comfyui"
7015
+ "comfyui",
7016
+ "design-view-provider"
7016
7017
  ]);
7017
7018
  var CapabilityRegistrySourceSchema = z3.object({
7018
7019
  sourceType: CapabilitySourceTypeSchema,
@@ -8680,7 +8681,7 @@ function toAgentSessionViewModel(projection, snapshot) {
8680
8681
  }
8681
8682
 
8682
8683
  // src/contracts/semantic.ts
8683
- import { z as z9 } from "zod";
8684
+ import { z as z10 } from "zod";
8684
8685
 
8685
8686
  // src/contracts/data.ts
8686
8687
  import { z as z6 } from "zod";
@@ -9306,39 +9307,996 @@ var MenuContributionResultSchema = z8.object({
9306
9307
  nodes: z8.array(CompiledMenuNodeSchema).max(MENU_MAX_NODES)
9307
9308
  }).strict();
9308
9309
 
9310
+ // src/contracts/declarative-control.ts
9311
+ import { z as z9 } from "zod";
9312
+ var DECLARATIVE_CONTROL_SCHEMA_VERSION = 1;
9313
+ var uniqueArray = (values, identity) => {
9314
+ const seen = /* @__PURE__ */ new Set();
9315
+ for (const value of values) {
9316
+ const key = identity(value);
9317
+ if (seen.has(key)) return key;
9318
+ seen.add(key);
9319
+ }
9320
+ return void 0;
9321
+ };
9322
+ var I18nTextSchema = z9.object({
9323
+ defaultLocale: LocaleIdentifierSchema,
9324
+ values: z9.record(LocaleIdentifierSchema, z9.string().trim().min(1))
9325
+ }).strict().superRefine((value, context) => {
9326
+ if (!Object.prototype.hasOwnProperty.call(value.values, value.defaultLocale)) {
9327
+ context.addIssue({
9328
+ code: "custom",
9329
+ path: ["values", value.defaultLocale],
9330
+ message: "I18nText values must contain the default locale."
9331
+ });
9332
+ }
9333
+ });
9334
+ var ScopedIdentityRefSchema = z9.object({
9335
+ kind: ContractIdentifierSchema,
9336
+ id: ContractIdentifierSchema,
9337
+ ownerRepo: ContractIdentifierSchema
9338
+ }).strict();
9339
+ var TenantScopeSchema = z9.object({
9340
+ tenantRef: ScopedIdentityRefSchema,
9341
+ dataSpaceRef: ScopedIdentityRefSchema,
9342
+ teamRef: ScopedIdentityRefSchema.optional()
9343
+ }).strict().superRefine((value, context) => {
9344
+ const expectedKinds = [
9345
+ ["tenantRef", value.tenantRef, "tenant"],
9346
+ ["dataSpaceRef", value.dataSpaceRef, "data-space"],
9347
+ ["teamRef", value.teamRef, "team"]
9348
+ ];
9349
+ expectedKinds.forEach(([field, reference, expectedKind]) => {
9350
+ if (reference && reference.kind !== expectedKind) {
9351
+ context.addIssue({ code: "custom", path: [field, "kind"], message: `${field} must reference ${expectedKind}.` });
9352
+ }
9353
+ });
9354
+ });
9355
+ var ReferenceVisibilitySchema = z9.enum(["tenant", "global", "public"]);
9356
+ var StableRefShape = {
9357
+ kind: ContractIdentifierSchema,
9358
+ id: ContractIdentifierSchema,
9359
+ ownerRepo: ContractIdentifierSchema,
9360
+ visibility: ReferenceVisibilitySchema,
9361
+ tenantScope: TenantScopeSchema.optional()
9362
+ };
9363
+ var validateReferenceScope = (value, context) => {
9364
+ if (value.visibility === "tenant" && !value.tenantScope) {
9365
+ context.addIssue({ code: "custom", path: ["tenantScope"], message: "Tenant references require an explicit tenant scope." });
9366
+ }
9367
+ if (value.visibility !== "tenant" && value.tenantScope) {
9368
+ context.addIssue({ code: "custom", path: ["tenantScope"], message: "Global and public references cannot carry a tenant scope." });
9369
+ }
9370
+ };
9371
+ var StableRefSchema = z9.object(StableRefShape).strict().superRefine(validateReferenceScope);
9372
+ var RevisionRefSchema = z9.object({
9373
+ ...StableRefShape,
9374
+ revision: z9.number().int().positive(),
9375
+ schemaVersion: ContractVersionSchema,
9376
+ contentHash: Sha256Schema
9377
+ }).strict().superRefine(validateReferenceScope);
9378
+ var scopedIdentityKey = (reference) => `${reference.kind}:${reference.id}:${reference.ownerRepo}`;
9379
+ var tenantScopeKey = (scope) => `${scopedIdentityKey(scope.tenantRef)}:${scopedIdentityKey(scope.dataSpaceRef)}:${scope.teamRef ? scopedIdentityKey(scope.teamRef) : ""}`;
9380
+ var stableRefIdentity = (reference) => `${reference.visibility}:${reference.tenantScope ? tenantScopeKey(reference.tenantScope) : ""}:${reference.kind}:${reference.id}:${reference.ownerRepo}`;
9381
+ var exactRevisionRef = (left, right) => stableRefIdentity(left) === stableRefIdentity(right) && left.revision === right.revision && left.schemaVersion === right.schemaVersion && left.contentHash === right.contentHash;
9382
+ var StableRefAliasSchema = z9.object({
9383
+ aliasRef: StableRefSchema,
9384
+ canonicalRef: StableRefSchema,
9385
+ validFrom: IsoDateTimeSchema,
9386
+ validUntil: IsoDateTimeSchema.nullable(),
9387
+ evidenceRef: RevisionRefSchema
9388
+ }).strict().superRefine((value, context) => {
9389
+ if (value.aliasRef.kind !== value.canonicalRef.kind) {
9390
+ context.addIssue({ code: "custom", path: ["canonicalRef", "kind"], message: "Alias and canonical references must have the same kind." });
9391
+ }
9392
+ if (value.validUntil && value.validUntil <= value.validFrom) {
9393
+ context.addIssue({ code: "custom", path: ["validUntil"], message: "Alias validUntil must be later than validFrom." });
9394
+ }
9395
+ });
9396
+ var StableRefAliasMapSchema = z9.object({
9397
+ contract: z9.literal("StableRefAliasMap"),
9398
+ schemaVersion: z9.literal(DECLARATIVE_CONTROL_SCHEMA_VERSION),
9399
+ tenantScope: TenantScopeSchema,
9400
+ aliases: z9.array(StableRefAliasSchema),
9401
+ contentHash: Sha256Schema
9402
+ }).strict().superRefine((value, context) => {
9403
+ const duplicate = uniqueArray(value.aliases, (entry) => stableRefIdentity(entry.aliasRef));
9404
+ if (duplicate) context.addIssue({ code: "custom", path: ["aliases"], message: `Duplicate alias reference: ${duplicate}` });
9405
+ });
9406
+ var DeclarativeLifecycleSchema = z9.enum(["active", "deprecated", "retired"]);
9407
+ var ProductSurfaceSchema = z9.enum(["studio", "kernel"]);
9408
+ var GroupRefSchema = StableRefSchema.superRefine((value, context) => {
9409
+ if (value.kind !== "group") context.addIssue({ code: "custom", path: ["kind"], message: "Access group references must use kind group." });
9410
+ });
9411
+ var AccessConditionRefSchema = RevisionRefSchema.superRefine((value, context) => {
9412
+ if (value.kind !== "access-condition") {
9413
+ context.addIssue({ code: "custom", path: ["kind"], message: "Access condition references must use kind access-condition." });
9414
+ }
9415
+ });
9416
+ var AccessPolicySchema = z9.object({
9417
+ authenticated: z9.boolean(),
9418
+ groupAllOf: z9.array(GroupRefSchema),
9419
+ groupAnyOf: z9.array(GroupRefSchema),
9420
+ permissionAllOf: z9.array(ContractIdentifierSchema),
9421
+ permissionAnyOf: z9.array(ContractIdentifierSchema),
9422
+ conditionAllOf: z9.array(AccessConditionRefSchema)
9423
+ }).strict().superRefine((value, context) => {
9424
+ const checks = [
9425
+ ["groupAllOf", value.groupAllOf, (candidate) => stableRefIdentity(candidate)],
9426
+ ["groupAnyOf", value.groupAnyOf, (candidate) => stableRefIdentity(candidate)],
9427
+ ["permissionAllOf", value.permissionAllOf, String],
9428
+ ["permissionAnyOf", value.permissionAnyOf, String],
9429
+ ["conditionAllOf", value.conditionAllOf, (candidate) => `${stableRefIdentity(candidate)}@${candidate.revision}`]
9430
+ ];
9431
+ checks.forEach(([field, values, identity]) => {
9432
+ if (uniqueArray(values, identity)) context.addIssue({ code: "custom", path: [field], message: `${field} entries must be unique.` });
9433
+ });
9434
+ });
9435
+ var ManagementAccessSchema = z9.object({
9436
+ edit: AccessPolicySchema,
9437
+ preview: AccessPolicySchema,
9438
+ publish: AccessPolicySchema,
9439
+ deactivate: AccessPolicySchema,
9440
+ rollback: AccessPolicySchema,
9441
+ retire: AccessPolicySchema
9442
+ }).strict();
9443
+ var RoutePathTemplateSchema = z9.string().trim().regex(/^\/(?!\/)/, "Expected an application-relative path.").superRefine((value, context) => {
9444
+ if (value.includes("?") || value.includes("#") || value.includes("\\")) {
9445
+ context.addIssue({ code: "custom", message: "Route paths cannot contain query strings, fragments, or backslashes." });
9446
+ }
9447
+ if (value.split("/").some((segment) => segment === "." || segment === "..")) {
9448
+ context.addIssue({ code: "custom", message: "Route paths cannot contain traversal segments." });
9449
+ }
9450
+ if (/^[a-z][a-z0-9+.-]*:/i.test(value) || value.includes("://")) {
9451
+ context.addIssue({ code: "custom", message: "Route paths cannot contain a scheme or host." });
9452
+ }
9453
+ });
9454
+ var RouteSpaceParameterSchema = z9.object({
9455
+ name: ContractIdentifierSchema,
9456
+ type: z9.enum(["identifier", "integer", "slug", "uuid"]),
9457
+ required: z9.boolean()
9458
+ }).strict();
9459
+ var RouteSpaceSchema = z9.object({
9460
+ contract: z9.literal("RouteSpace"),
9461
+ schemaVersion: z9.literal(DECLARATIVE_CONTROL_SCHEMA_VERSION),
9462
+ routeSpaceId: ContractIdentifierSchema,
9463
+ supportedSurface: ProductSurfaceSchema,
9464
+ basePath: RoutePathTemplateSchema,
9465
+ caseSensitive: z9.boolean(),
9466
+ trailingSlash: z9.enum(["preserve", "remove", "require"]),
9467
+ reservedPaths: z9.array(RoutePathTemplateSchema),
9468
+ parameters: z9.array(RouteSpaceParameterSchema)
9469
+ }).strict().superRefine((value, context) => {
9470
+ if (uniqueArray(value.parameters, (parameter) => parameter.name)) {
9471
+ context.addIssue({ code: "custom", path: ["parameters"], message: "RouteSpace parameter names must be unique." });
9472
+ }
9473
+ if (uniqueArray(value.reservedPaths, (path) => path)) {
9474
+ context.addIssue({ code: "custom", path: ["reservedPaths"], message: "RouteSpace reserved paths must be unique." });
9475
+ }
9476
+ });
9477
+ var RouteClaimBaseSchema = z9.object({
9478
+ kind: z9.enum(["canonical", "alias", "redirect"]),
9479
+ routeSpaceRevisionRef: RevisionRefSchema,
9480
+ pathTemplate: RoutePathTemplateSchema,
9481
+ redirectTargetRef: StableRefSchema.optional()
9482
+ }).strict().superRefine((value, context) => {
9483
+ if (value.routeSpaceRevisionRef.kind !== "route-space") {
9484
+ context.addIssue({ code: "custom", path: ["routeSpaceRevisionRef", "kind"], message: "Route claims must reference a route-space revision." });
9485
+ }
9486
+ if (value.kind === "redirect" && !value.redirectTargetRef) {
9487
+ context.addIssue({ code: "custom", path: ["redirectTargetRef"], message: "Redirect claims require a governed target reference." });
9488
+ }
9489
+ if (value.kind !== "redirect" && value.redirectTargetRef) {
9490
+ context.addIssue({ code: "custom", path: ["redirectTargetRef"], message: "Only redirect claims may declare redirectTargetRef." });
9491
+ }
9492
+ });
9493
+ var LegacyRouteClaimSchema = RouteClaimBaseSchema;
9494
+ var RouteClaimSchema = RouteClaimBaseSchema.safeExtend({
9495
+ surface: ProductSurfaceSchema
9496
+ }).strict();
9497
+ var DeclarativeRouteClaimSchema = RouteClaimSchema;
9498
+ var LegacyDeclarativeRouteClaimSchema = LegacyRouteClaimSchema;
9499
+ var LegacyCompiledRouteMatcherSchema = z9.object({
9500
+ caseSensitive: z9.boolean(),
9501
+ trailingSlash: z9.enum(["preserve", "remove", "require"]),
9502
+ parameters: z9.array(RouteSpaceParameterSchema)
9503
+ }).strict();
9504
+ var CompiledRouteMatcherSchema = LegacyCompiledRouteMatcherSchema.safeExtend({
9505
+ surface: ProductSurfaceSchema
9506
+ }).strict();
9507
+ var CompiledRouteClaimSchema = RouteClaimSchema.safeExtend({
9508
+ normalizedPath: RoutePathTemplateSchema,
9509
+ matcher: CompiledRouteMatcherSchema
9510
+ }).strict();
9511
+ var LegacyCompiledRouteClaimSchema = LegacyRouteClaimSchema.safeExtend({
9512
+ normalizedPath: RoutePathTemplateSchema,
9513
+ matcher: LegacyCompiledRouteMatcherSchema
9514
+ }).strict();
9515
+ var validateDeclaredRouteSurfaces = (supportedSurfaces, routeClaims, context) => {
9516
+ if (uniqueArray(supportedSurfaces, (surface) => surface)) {
9517
+ context.addIssue({ code: "custom", path: ["supportedSurfaces"], message: "Supported surfaces must be unique." });
9518
+ }
9519
+ const explicitClaims = routeClaims.filter((claim) => "surface" in claim);
9520
+ if (explicitClaims.length > 0 && explicitClaims.length < routeClaims.length) {
9521
+ context.addIssue({ code: "custom", path: ["routeClaims"], message: "Route claims must either all declare surface or all omit it for legacy compatibility." });
9522
+ return;
9523
+ }
9524
+ routeClaims.forEach((claim, index) => {
9525
+ if ("surface" in claim && !supportedSurfaces.includes(claim.surface)) {
9526
+ context.addIssue({ code: "custom", path: ["routeClaims", index, "surface"], message: "Route claim surface must be declared by supportedSurfaces." });
9527
+ }
9528
+ });
9529
+ if (explicitClaims.length !== routeClaims.length) return;
9530
+ supportedSurfaces.forEach((surface) => {
9531
+ const canonicalCount = explicitClaims.filter((claim) => claim.surface === surface && claim.kind === "canonical").length;
9532
+ if (canonicalCount !== 1) {
9533
+ context.addIssue({ code: "custom", path: ["routeClaims"], message: `Surface ${surface} requires exactly one canonical route claim.` });
9534
+ }
9535
+ });
9536
+ };
9537
+ var ReleaseOperationSchema = z9.enum(["activate", "deactivate", "rollback"]);
9538
+ var ReleaseDependencyRoleSchema = z9.enum([
9539
+ "route-space",
9540
+ "shell",
9541
+ "page",
9542
+ "page-release",
9543
+ "workbench",
9544
+ "workbench-release",
9545
+ "navigation",
9546
+ "navigation-release",
9547
+ "menu-action",
9548
+ "application-menu-catalog",
9549
+ "capability",
9550
+ "provider",
9551
+ "ontology-definition",
9552
+ "view",
9553
+ "projection",
9554
+ "action",
9555
+ "token",
9556
+ "schema",
9557
+ "compiler",
9558
+ "workflow",
9559
+ "agent",
9560
+ "built-in-application",
9561
+ "design",
9562
+ "layout-policy",
9563
+ "performance-budget",
9564
+ "observation-policy"
9565
+ ]);
9566
+ var DependencyKindByRole = {
9567
+ "route-space": "route-space",
9568
+ shell: "shell",
9569
+ page: "page",
9570
+ "page-release": "page-release",
9571
+ workbench: "workbench",
9572
+ "workbench-release": "workbench-release",
9573
+ navigation: "navigation",
9574
+ "navigation-release": "navigation-release",
9575
+ "menu-action": "menu-action",
9576
+ "application-menu-catalog": "application-menu-catalog",
9577
+ capability: "capability",
9578
+ provider: "view-provider",
9579
+ "ontology-definition": "ontology-definition",
9580
+ view: "view",
9581
+ projection: "projection",
9582
+ action: "domain-command",
9583
+ token: "design-token",
9584
+ schema: "schema",
9585
+ compiler: "compiler",
9586
+ workflow: "workflow",
9587
+ agent: "agent",
9588
+ "built-in-application": "built-in-application",
9589
+ design: "design",
9590
+ "layout-policy": "layout-policy",
9591
+ "performance-budget": "performance-budget",
9592
+ "observation-policy": "observation-policy"
9593
+ };
9594
+ var ReleaseDependencySchema = z9.object({
9595
+ role: ReleaseDependencyRoleSchema,
9596
+ revisionRef: RevisionRefSchema
9597
+ }).strict().superRefine((value, context) => {
9598
+ const expectedKind = DependencyKindByRole[value.role];
9599
+ if (value.revisionRef.kind !== expectedKind) {
9600
+ context.addIssue({
9601
+ code: "custom",
9602
+ path: ["revisionRef", "kind"],
9603
+ message: `Dependency role ${value.role} requires reference kind ${expectedKind}.`
9604
+ });
9605
+ }
9606
+ });
9607
+ var ReleaseValidationSchema = z9.object({
9608
+ result: z9.enum(["pass", "fail"]),
9609
+ inputHash: Sha256Schema,
9610
+ diagnosticRefs: z9.array(RevisionRefSchema)
9611
+ }).strict();
9612
+ var ReleaseEvidenceSchema = z9.object({
9613
+ publicationPlanRef: StableRefSchema,
9614
+ expectedHeadRevisionRef: RevisionRefSchema.nullable(),
9615
+ validation: ReleaseValidationSchema,
9616
+ approvalPolicyRevisionRef: RevisionRefSchema,
9617
+ approvalDecisionRevisionRef: RevisionRefSchema,
9618
+ actorRef: StableRefSchema,
9619
+ reason: z9.string().trim().min(1).max(4096),
9620
+ idempotencyKey: ContractIdentifierSchema,
9621
+ occurredAt: IsoDateTimeSchema,
9622
+ evidenceRefs: z9.array(RevisionRefSchema).min(1)
9623
+ }).strict().superRefine((value, context) => {
9624
+ const expectedKinds = [
9625
+ ["publicationPlanRef", value.publicationPlanRef, "publication-plan"],
9626
+ ["approvalPolicyRevisionRef", value.approvalPolicyRevisionRef, "approval-policy"],
9627
+ ["approvalDecisionRevisionRef", value.approvalDecisionRevisionRef, "approval-decision"],
9628
+ ["actorRef", value.actorRef, "actor"]
9629
+ ];
9630
+ expectedKinds.forEach(([field, reference, expectedKind]) => {
9631
+ if (reference.kind !== expectedKind) {
9632
+ context.addIssue({ code: "custom", path: [field, "kind"], message: `${field} must reference ${expectedKind}.` });
9633
+ }
9634
+ });
9635
+ value.evidenceRefs.forEach((reference, index) => {
9636
+ if (reference.kind !== "evidence") context.addIssue({ code: "custom", path: ["evidenceRefs", index, "kind"], message: "Release evidenceRefs must reference evidence revisions." });
9637
+ });
9638
+ });
9639
+ var PublicationPlanOperationSchema = z9.object({
9640
+ releaseKind: z9.enum(["page-release", "workbench-release", "navigation-release"]),
9641
+ releaseSlotId: ContractIdentifierSchema,
9642
+ releaseRevisionRef: RevisionRefSchema,
9643
+ expectedHeadRevisionRef: RevisionRefSchema.nullable()
9644
+ }).strict().superRefine((value, context) => {
9645
+ if (value.releaseRevisionRef.kind !== value.releaseKind || value.releaseRevisionRef.id !== value.releaseSlotId) {
9646
+ context.addIssue({ code: "custom", path: ["releaseRevisionRef"], message: "Publication Plan operation must pin the exact release slot revision." });
9647
+ }
9648
+ if (value.expectedHeadRevisionRef && (value.expectedHeadRevisionRef.kind !== value.releaseKind || value.expectedHeadRevisionRef.id !== value.releaseSlotId)) {
9649
+ context.addIssue({ code: "custom", path: ["expectedHeadRevisionRef"], message: "Expected head must identify the same release slot." });
9650
+ }
9651
+ });
9652
+ var PublicationPlanSchema = z9.object({
9653
+ contract: z9.literal("PublicationPlan"),
9654
+ schemaVersion: z9.literal(DECLARATIVE_CONTROL_SCHEMA_VERSION),
9655
+ planId: ContractIdentifierSchema,
9656
+ tenantScope: TenantScopeSchema,
9657
+ environmentRef: StableRefSchema,
9658
+ operations: z9.array(PublicationPlanOperationSchema).min(1),
9659
+ validation: ReleaseValidationSchema,
9660
+ approvalPolicyRevisionRef: RevisionRefSchema,
9661
+ approvalDecisionRevisionRef: RevisionRefSchema,
9662
+ actorRef: StableRefSchema,
9663
+ idempotencyKey: ContractIdentifierSchema,
9664
+ evidenceRefs: z9.array(RevisionRefSchema).min(1),
9665
+ createdAt: IsoDateTimeSchema
9666
+ }).strict().superRefine((value, context) => {
9667
+ if (value.environmentRef.kind !== "environment") context.addIssue({ code: "custom", path: ["environmentRef", "kind"], message: "Publication Plan requires an environment reference." });
9668
+ const governedRefs = [
9669
+ ["approvalPolicyRevisionRef", value.approvalPolicyRevisionRef, "approval-policy"],
9670
+ ["approvalDecisionRevisionRef", value.approvalDecisionRevisionRef, "approval-decision"],
9671
+ ["actorRef", value.actorRef, "actor"]
9672
+ ];
9673
+ governedRefs.forEach(([field, reference, expectedKind]) => {
9674
+ if (reference.kind !== expectedKind) context.addIssue({ code: "custom", path: [field, "kind"], message: `${field} must reference ${expectedKind}.` });
9675
+ });
9676
+ value.operations.forEach((operation, index) => {
9677
+ [operation.releaseRevisionRef, operation.expectedHeadRevisionRef].forEach((reference, referenceIndex) => {
9678
+ if (reference?.tenantScope && tenantScopeKey(reference.tenantScope) !== tenantScopeKey(value.tenantScope)) {
9679
+ const field = referenceIndex === 0 ? "releaseRevisionRef" : "expectedHeadRevisionRef";
9680
+ context.addIssue({ code: "custom", path: ["operations", index, field, "tenantScope"], message: "Publication Plan operation belongs to another tenant scope." });
9681
+ }
9682
+ });
9683
+ });
9684
+ value.evidenceRefs.forEach((reference, index) => {
9685
+ if (reference.kind !== "evidence") context.addIssue({ code: "custom", path: ["evidenceRefs", index, "kind"], message: "Publication Plan evidenceRefs must reference evidence revisions." });
9686
+ });
9687
+ if (uniqueArray(value.operations, (operation) => `${operation.releaseKind}:${operation.releaseSlotId}`)) {
9688
+ context.addIssue({ code: "custom", path: ["operations"], message: "Publication Plan release slots must be unique." });
9689
+ }
9690
+ });
9691
+ var IdentitySchema = z9.object({
9692
+ name: I18nTextSchema,
9693
+ description: I18nTextSchema.optional(),
9694
+ tags: z9.array(ContractIdentifierSchema).default([])
9695
+ }).strict();
9696
+ var WorkbenchIdentitySchema = IdentitySchema.extend({ iconRef: StableRefSchema.optional() }).strict();
9697
+ var ReleaseBaseShape = {
9698
+ schemaVersion: z9.literal(DECLARATIVE_CONTROL_SCHEMA_VERSION),
9699
+ releaseSlotId: ContractIdentifierSchema,
9700
+ tenantScope: TenantScopeSchema,
9701
+ operation: ReleaseOperationSchema,
9702
+ dependencySnapshot: z9.array(ReleaseDependencySchema),
9703
+ evidence: ReleaseEvidenceSchema
9704
+ };
9705
+ var validateDependencySnapshot = (snapshot, context) => {
9706
+ const duplicate = uniqueArray(snapshot, (dependency) => `${dependency.role}:${stableRefIdentity(dependency.revisionRef)}@${dependency.revisionRef.revision}`);
9707
+ if (duplicate) context.addIssue({ code: "custom", path: ["dependencySnapshot"], message: `Duplicate dependency: ${duplicate}` });
9708
+ };
9709
+ var validateReleaseExpectedHead = (value, expectedKind, context) => {
9710
+ const expectedHead = value.evidence.expectedHeadRevisionRef;
9711
+ if (expectedHead && (expectedHead.kind !== expectedKind || expectedHead.id !== value.releaseSlotId)) {
9712
+ context.addIssue({ code: "custom", path: ["evidence", "expectedHeadRevisionRef"], message: "Expected head must identify the same release slot." });
9713
+ }
9714
+ if (expectedHead?.tenantScope && tenantScopeKey(expectedHead.tenantScope) !== tenantScopeKey(value.tenantScope)) {
9715
+ context.addIssue({ code: "custom", path: ["evidence", "expectedHeadRevisionRef", "tenantScope"], message: "Expected head belongs to another tenant scope." });
9716
+ }
9717
+ };
9718
+ var BindingSourceSchema = z9.discriminatedUnion("kind", [
9719
+ z9.object({ kind: z9.literal("constant"), value: z9.union([z9.string(), z9.number().finite(), z9.boolean(), z9.null()]) }).strict(),
9720
+ z9.object({ kind: z9.literal("route-parameter"), name: ContractIdentifierSchema }).strict(),
9721
+ z9.object({ kind: z9.literal("query-parameter"), name: ContractIdentifierSchema }).strict(),
9722
+ z9.object({ kind: z9.literal("identity"), name: z9.enum(["tenantId", "teamId", "userId"]) }).strict(),
9723
+ z9.object({ kind: z9.literal("intent-field"), path: z9.string().trim().regex(/^[A-Za-z0-9_.-]+$/) }).strict(),
9724
+ z9.object({ kind: z9.literal("binding-field"), bindingId: ContractIdentifierSchema, path: z9.string().trim().regex(/^[A-Za-z0-9_.-]+$/) }).strict()
9725
+ ]);
9726
+ var CapabilityInstanceSchema = z9.object({
9727
+ instanceId: ContractIdentifierSchema,
9728
+ nodeId: ContractIdentifierSchema,
9729
+ capabilityRevisionRef: RevisionRefSchema,
9730
+ providerRevisionRef: RevisionRefSchema,
9731
+ propertySchemaRevisionRef: RevisionRefSchema,
9732
+ properties: JsonObjectSchema,
9733
+ allowedSideEffects: z9.array(z9.enum(["network", "storage", "navigation", "worker", "websocket"]))
9734
+ }).strict();
9735
+ var OntologyBindingSchema = z9.object({
9736
+ bindingId: ContractIdentifierSchema,
9737
+ ontologyDefinitionRevisionRef: RevisionRefSchema,
9738
+ viewRevisionRef: RevisionRefSchema.optional(),
9739
+ projectionRevisionRef: RevisionRefSchema.optional(),
9740
+ parameters: z9.record(ContractIdentifierSchema, BindingSourceSchema),
9741
+ target: z9.object({ capabilityInstanceId: ContractIdentifierSchema, port: ContractIdentifierSchema }).strict(),
9742
+ renderModelSchemaRevisionRef: RevisionRefSchema,
9743
+ pagination: z9.enum(["none", "cursor", "offset"]),
9744
+ cache: z9.enum(["none", "identity-scoped", "tenant-scoped"]),
9745
+ cancelOnChange: z9.boolean()
9746
+ }).strict().superRefine((value, context) => {
9747
+ if ((value.viewRevisionRef ? 1 : 0) + (value.projectionRevisionRef ? 1 : 0) !== 1) {
9748
+ context.addIssue({ code: "custom", path: ["viewRevisionRef"], message: "Ontology bindings require exactly one View or Projection revision." });
9749
+ }
9750
+ if (value.ontologyDefinitionRevisionRef.kind !== "ontology-definition") {
9751
+ context.addIssue({ code: "custom", path: ["ontologyDefinitionRevisionRef", "kind"], message: "Expected an ontology-definition revision." });
9752
+ }
9753
+ });
9754
+ var ActionBindingSchema = z9.object({
9755
+ bindingId: ContractIdentifierSchema,
9756
+ commandRevisionRef: RevisionRefSchema,
9757
+ source: z9.object({ capabilityInstanceId: ContractIdentifierSchema, port: ContractIdentifierSchema }).strict(),
9758
+ sourceIntentSchemaRevisionRef: RevisionRefSchema,
9759
+ inputSchemaRevisionRef: RevisionRefSchema,
9760
+ inputMapping: z9.record(ContractIdentifierSchema, BindingSourceSchema),
9761
+ accessPolicy: AccessPolicySchema,
9762
+ confirmation: I18nTextSchema.optional(),
9763
+ idempotencyKeySource: z9.enum(["interaction", "record-and-interaction", "caller-provided"]),
9764
+ compensationCommandRevisionRef: RevisionRefSchema.optional(),
9765
+ resultSchemaRevisionRef: RevisionRefSchema,
9766
+ success: z9.object({
9767
+ refreshBindingIds: z9.array(ContractIdentifierSchema),
9768
+ navigationTargetRef: StableRefSchema.optional()
9769
+ }).strict(),
9770
+ recovery: z9.enum(["retry-safe", "compensating-command", "manual-review"]),
9771
+ lineageRequired: z9.literal(true)
9772
+ }).strict().superRefine((value, context) => {
9773
+ if (value.commandRevisionRef.kind !== "domain-command") {
9774
+ context.addIssue({ code: "custom", path: ["commandRevisionRef", "kind"], message: "Action bindings must reference a domain-command revision." });
9775
+ }
9776
+ if (value.sourceIntentSchemaRevisionRef.kind !== "schema") {
9777
+ context.addIssue({ code: "custom", path: ["sourceIntentSchemaRevisionRef", "kind"], message: "Action source intents must pin a schema revision." });
9778
+ }
9779
+ if (value.inputSchemaRevisionRef.kind !== "schema") {
9780
+ context.addIssue({ code: "custom", path: ["inputSchemaRevisionRef", "kind"], message: "Action command inputs must pin a schema revision." });
9781
+ }
9782
+ if (value.recovery === "compensating-command" && !value.compensationCommandRevisionRef) {
9783
+ context.addIssue({ code: "custom", path: ["compensationCommandRevisionRef"], message: "Compensating recovery requires a compensation command." });
9784
+ }
9785
+ });
9786
+ var PageSchema = z9.object({
9787
+ contract: z9.literal("Page"),
9788
+ schemaVersion: z9.literal(DECLARATIVE_CONTROL_SCHEMA_VERSION),
9789
+ pageId: ContractIdentifierSchema,
9790
+ tenantScope: TenantScopeSchema,
9791
+ identity: IdentitySchema,
9792
+ supportedSurfaces: z9.array(ProductSurfaceSchema).min(1),
9793
+ lifecycle: DeclarativeLifecycleSchema,
9794
+ routeClaims: z9.array(z9.union([DeclarativeRouteClaimSchema, LegacyDeclarativeRouteClaimSchema])).min(1),
9795
+ shellRevisionRef: RevisionRefSchema,
9796
+ renderTree: RenderTreeSchema,
9797
+ capabilityInstances: z9.array(CapabilityInstanceSchema).min(1),
9798
+ ontologyBindings: z9.array(OntologyBindingSchema),
9799
+ actionBindings: z9.array(ActionBindingSchema),
9800
+ pageAccessPolicy: AccessPolicySchema,
9801
+ managementAccess: ManagementAccessSchema,
9802
+ tokenRevisionRefs: z9.array(RevisionRefSchema).min(1),
9803
+ performanceBudgetRef: RevisionRefSchema,
9804
+ observationPolicyRevisionRef: RevisionRefSchema,
9805
+ privacyClassification: z9.enum(["public", "internal", "confidential", "restricted"])
9806
+ }).strict().superRefine((value, context) => {
9807
+ validateDeclaredRouteSurfaces(value.supportedSurfaces, value.routeClaims, context);
9808
+ const uniqueness = [
9809
+ ["capabilityInstances", value.capabilityInstances, (candidate) => String(candidate.instanceId)],
9810
+ ["ontologyBindings", value.ontologyBindings, (candidate) => String(candidate.bindingId)],
9811
+ ["actionBindings", value.actionBindings, (candidate) => String(candidate.bindingId)]
9812
+ ];
9813
+ uniqueness.forEach(([field, values, identity]) => {
9814
+ if (uniqueArray(values, identity)) context.addIssue({ code: "custom", path: [field], message: `${field} identities must be unique.` });
9815
+ });
9816
+ const instanceIds = new Set(value.capabilityInstances.map((instance) => instance.instanceId));
9817
+ value.ontologyBindings.forEach((binding, index) => {
9818
+ if (!instanceIds.has(binding.target.capabilityInstanceId)) {
9819
+ context.addIssue({ code: "custom", path: ["ontologyBindings", index, "target", "capabilityInstanceId"], message: "Ontology binding targets an unknown capability instance." });
9820
+ }
9821
+ });
9822
+ value.actionBindings.forEach((binding, index) => {
9823
+ if (!instanceIds.has(binding.source.capabilityInstanceId)) {
9824
+ context.addIssue({ code: "custom", path: ["actionBindings", index, "source", "capabilityInstanceId"], message: "Action binding sources an unknown capability instance." });
9825
+ }
9826
+ binding.success.refreshBindingIds.forEach((bindingId) => {
9827
+ if (!value.ontologyBindings.some((candidate) => candidate.bindingId === bindingId)) {
9828
+ context.addIssue({ code: "custom", path: ["actionBindings", index, "success", "refreshBindingIds"], message: `Unknown refresh binding: ${bindingId}` });
9829
+ }
9830
+ });
9831
+ });
9832
+ if (value.shellRevisionRef.kind !== "shell") context.addIssue({ code: "custom", path: ["shellRevisionRef", "kind"], message: "Page shellRevisionRef must reference a shell." });
9833
+ value.capabilityInstances.forEach((instance, index) => {
9834
+ const refs = [
9835
+ ["capabilityRevisionRef", instance.capabilityRevisionRef, "capability"],
9836
+ ["providerRevisionRef", instance.providerRevisionRef, "view-provider"],
9837
+ ["propertySchemaRevisionRef", instance.propertySchemaRevisionRef, "schema"]
9838
+ ];
9839
+ refs.forEach(([field, reference, expectedKind]) => {
9840
+ if (reference.kind !== expectedKind) context.addIssue({ code: "custom", path: ["capabilityInstances", index, field, "kind"], message: `${field} must reference ${expectedKind}.` });
9841
+ });
9842
+ });
9843
+ value.tokenRevisionRefs.forEach((reference, index) => {
9844
+ if (reference.kind !== "design-token") context.addIssue({ code: "custom", path: ["tokenRevisionRefs", index, "kind"], message: "Page token references must use kind design-token." });
9845
+ });
9846
+ if (value.performanceBudgetRef.kind !== "performance-budget") context.addIssue({ code: "custom", path: ["performanceBudgetRef", "kind"], message: "Page requires a performance-budget revision." });
9847
+ if (value.observationPolicyRevisionRef.kind !== "observation-policy") context.addIssue({ code: "custom", path: ["observationPolicyRevisionRef", "kind"], message: "Page requires an observation-policy revision." });
9848
+ });
9849
+ var PageReleaseSchema = z9.object({
9850
+ contract: z9.literal("PageRelease"),
9851
+ ...ReleaseBaseShape,
9852
+ pageRevisionRef: RevisionRefSchema,
9853
+ target: z9.object({
9854
+ environmentRef: StableRefSchema,
9855
+ surface: ProductSurfaceSchema,
9856
+ routeSpaceRevisionRef: RevisionRefSchema,
9857
+ normalizedPath: RoutePathTemplateSchema,
9858
+ routeClaim: z9.union([CompiledRouteClaimSchema, LegacyCompiledRouteClaimSchema])
9859
+ }).strict()
9860
+ }).strict().superRefine((value, context) => {
9861
+ validateDependencySnapshot(value.dependencySnapshot, context);
9862
+ validateReleaseExpectedHead(value, "page-release", context);
9863
+ if (value.pageRevisionRef.kind !== "page") context.addIssue({ code: "custom", path: ["pageRevisionRef", "kind"], message: "Expected a page revision." });
9864
+ if (value.target.environmentRef.kind !== "environment") context.addIssue({ code: "custom", path: ["target", "environmentRef", "kind"], message: "Page release target requires an environment reference." });
9865
+ if (value.target.routeSpaceRevisionRef.kind !== "route-space") context.addIssue({ code: "custom", path: ["target", "routeSpaceRevisionRef", "kind"], message: "Page release target requires a route-space revision." });
9866
+ if (value.target.normalizedPath !== value.target.routeClaim.normalizedPath || !exactRevisionRef(value.target.routeSpaceRevisionRef, value.target.routeClaim.routeSpaceRevisionRef)) {
9867
+ context.addIssue({ code: "custom", path: ["target", "routeClaim"], message: "Page Release route authority must pin the exact compiled claim and normalized path." });
9868
+ }
9869
+ if ("surface" in value.target.routeClaim && value.target.routeClaim.surface !== value.target.surface) {
9870
+ context.addIssue({ code: "custom", path: ["target", "routeClaim", "surface"], message: "Page Release route claim must match the target surface." });
9871
+ }
9872
+ });
9873
+ var WorkbenchGroupSchema = z9.object({
9874
+ groupId: ContractIdentifierSchema,
9875
+ label: I18nTextSchema,
9876
+ iconRef: StableRefSchema.optional(),
9877
+ order: z9.number().int(),
9878
+ collapsedByDefault: z9.boolean(),
9879
+ accessPolicy: AccessPolicySchema.optional()
9880
+ }).strict();
9881
+ var WorkbenchAppInstanceSchema = z9.object({
9882
+ instanceId: ContractIdentifierSchema,
9883
+ kind: z9.enum(["built-in-application", "workflow-form", "workflow", "agent", "design", "capability"]),
9884
+ targetRevisionRef: RevisionRefSchema,
9885
+ providerRevisionRef: RevisionRefSchema,
9886
+ inputSchemaRevisionRef: RevisionRefSchema,
9887
+ input: JsonObjectSchema,
9888
+ groupId: ContractIdentifierSchema,
9889
+ order: z9.number().int(),
9890
+ display: z9.object({ name: I18nTextSchema.optional(), iconRef: StableRefSchema.optional() }).strict(),
9891
+ accessPolicy: AccessPolicySchema
9892
+ }).strict();
9893
+ var WorkbenchSchema = z9.object({
9894
+ contract: z9.literal("Workbench"),
9895
+ schemaVersion: z9.literal(DECLARATIVE_CONTROL_SCHEMA_VERSION),
9896
+ workbenchId: ContractIdentifierSchema,
9897
+ tenantScope: TenantScopeSchema,
9898
+ purpose: z9.enum(["instance", "template"]),
9899
+ sourceTemplateRevisionRef: RevisionRefSchema.optional(),
9900
+ identity: WorkbenchIdentitySchema,
9901
+ supportedSurfaces: z9.array(ProductSurfaceSchema).min(1),
9902
+ lifecycle: DeclarativeLifecycleSchema,
9903
+ routeClaims: z9.array(z9.union([DeclarativeRouteClaimSchema, LegacyDeclarativeRouteClaimSchema])).min(1),
9904
+ groups: z9.array(WorkbenchGroupSchema).min(1),
9905
+ appInstances: z9.array(WorkbenchAppInstanceSchema).min(1),
9906
+ defaultEntry: z9.object({ groupId: ContractIdentifierSchema, instanceId: ContractIdentifierSchema, showDefaultGroup: z9.boolean() }).strict(),
9907
+ layout: z9.object({
9908
+ hostCapabilityRevisionRef: RevisionRefSchema,
9909
+ hostProviderRevisionRef: RevisionRefSchema,
9910
+ layoutPolicyRevisionRef: RevisionRefSchema,
9911
+ tokenRevisionRefs: z9.array(RevisionRefSchema).min(1)
9912
+ }).strict(),
9913
+ workbenchAccessPolicy: AccessPolicySchema,
9914
+ managementAccess: ManagementAccessSchema,
9915
+ personalPreferencesPolicy: z9.object({
9916
+ allowed: z9.array(z9.enum(["collapsed-groups", "recent-entry", "layout-density"])),
9917
+ authority: z9.literal("identity-overlay")
9918
+ }).strict(),
9919
+ performanceBudgetRef: RevisionRefSchema,
9920
+ observationPolicyRevisionRef: RevisionRefSchema,
9921
+ privacyClassification: z9.enum(["public", "internal", "confidential", "restricted"])
9922
+ }).strict().superRefine((value, context) => {
9923
+ validateDeclaredRouteSurfaces(value.supportedSurfaces, value.routeClaims, context);
9924
+ if (value.purpose === "template" && value.sourceTemplateRevisionRef) {
9925
+ context.addIssue({ code: "custom", path: ["sourceTemplateRevisionRef"], message: "Templates cannot derive from another template at runtime." });
9926
+ }
9927
+ const duplicateGroup = uniqueArray(value.groups, (group) => group.groupId);
9928
+ if (duplicateGroup) context.addIssue({ code: "custom", path: ["groups"], message: `Duplicate Workbench group: ${duplicateGroup}` });
9929
+ const duplicateInstance = uniqueArray(value.appInstances, (instance) => instance.instanceId);
9930
+ if (duplicateInstance) context.addIssue({ code: "custom", path: ["appInstances"], message: `Duplicate Workbench instance: ${duplicateInstance}` });
9931
+ const groupIds = new Set(value.groups.map((group) => group.groupId));
9932
+ value.appInstances.forEach((instance, index) => {
9933
+ if (!groupIds.has(instance.groupId)) context.addIssue({ code: "custom", path: ["appInstances", index, "groupId"], message: "Workbench app references an unknown group." });
9934
+ });
9935
+ const defaultInstance = value.appInstances.find((instance) => instance.instanceId === value.defaultEntry.instanceId);
9936
+ if (!defaultInstance || defaultInstance.groupId !== value.defaultEntry.groupId) {
9937
+ context.addIssue({ code: "custom", path: ["defaultEntry"], message: "Workbench default entry must reference an app in the declared group." });
9938
+ }
9939
+ const targetKindByInstanceKind = {
9940
+ "built-in-application": "built-in-application",
9941
+ "workflow-form": "workflow",
9942
+ workflow: "workflow",
9943
+ agent: "agent",
9944
+ design: "design",
9945
+ capability: "capability"
9946
+ };
9947
+ value.appInstances.forEach((instance, index) => {
9948
+ if (instance.targetRevisionRef.kind !== targetKindByInstanceKind[instance.kind]) context.addIssue({ code: "custom", path: ["appInstances", index, "targetRevisionRef", "kind"], message: `Workbench ${instance.kind} target has an incompatible reference kind.` });
9949
+ if (instance.providerRevisionRef.kind !== "view-provider") context.addIssue({ code: "custom", path: ["appInstances", index, "providerRevisionRef", "kind"], message: "Workbench app provider must use kind view-provider." });
9950
+ if (instance.inputSchemaRevisionRef.kind !== "schema") context.addIssue({ code: "custom", path: ["appInstances", index, "inputSchemaRevisionRef", "kind"], message: "Workbench app input must pin a schema revision." });
9951
+ });
9952
+ const layoutRefs = [
9953
+ ["hostCapabilityRevisionRef", value.layout.hostCapabilityRevisionRef, "capability"],
9954
+ ["hostProviderRevisionRef", value.layout.hostProviderRevisionRef, "view-provider"],
9955
+ ["layoutPolicyRevisionRef", value.layout.layoutPolicyRevisionRef, "layout-policy"]
9956
+ ];
9957
+ layoutRefs.forEach(([field, reference, expectedKind]) => {
9958
+ if (reference.kind !== expectedKind) context.addIssue({ code: "custom", path: ["layout", field, "kind"], message: `${field} must reference ${expectedKind}.` });
9959
+ });
9960
+ value.layout.tokenRevisionRefs.forEach((reference, index) => {
9961
+ if (reference.kind !== "design-token") context.addIssue({ code: "custom", path: ["layout", "tokenRevisionRefs", index, "kind"], message: "Workbench token references must use kind design-token." });
9962
+ });
9963
+ });
9964
+ var WorkbenchReleaseSchema = z9.object({
9965
+ contract: z9.literal("WorkbenchRelease"),
9966
+ ...ReleaseBaseShape,
9967
+ workbenchRevisionRef: RevisionRefSchema,
9968
+ target: z9.object({
9969
+ environmentRef: StableRefSchema,
9970
+ surface: ProductSurfaceSchema,
9971
+ workbenchId: ContractIdentifierSchema,
9972
+ routeSpaceRevisionRef: RevisionRefSchema,
9973
+ normalizedPath: RoutePathTemplateSchema,
9974
+ routeClaim: z9.union([CompiledRouteClaimSchema, LegacyCompiledRouteClaimSchema]),
9975
+ order: z9.number().int(),
9976
+ isDefaultCandidate: z9.boolean()
9977
+ }).strict()
9978
+ }).strict().superRefine((value, context) => {
9979
+ validateDependencySnapshot(value.dependencySnapshot, context);
9980
+ validateReleaseExpectedHead(value, "workbench-release", context);
9981
+ if (value.workbenchRevisionRef.kind !== "workbench") context.addIssue({ code: "custom", path: ["workbenchRevisionRef", "kind"], message: "Expected a workbench revision." });
9982
+ if (value.target.environmentRef.kind !== "environment") context.addIssue({ code: "custom", path: ["target", "environmentRef", "kind"], message: "Workbench release target requires an environment reference." });
9983
+ if (value.target.routeSpaceRevisionRef.kind !== "route-space") context.addIssue({ code: "custom", path: ["target", "routeSpaceRevisionRef", "kind"], message: "Workbench release target requires a route-space revision." });
9984
+ if (value.target.normalizedPath !== value.target.routeClaim.normalizedPath || !exactRevisionRef(value.target.routeSpaceRevisionRef, value.target.routeClaim.routeSpaceRevisionRef)) {
9985
+ context.addIssue({ code: "custom", path: ["target", "routeClaim"], message: "Workbench Release route authority must pin the exact compiled claim and normalized path." });
9986
+ }
9987
+ if ("surface" in value.target.routeClaim && value.target.routeClaim.surface !== value.target.surface) {
9988
+ context.addIssue({ code: "custom", path: ["target", "routeClaim", "surface"], message: "Workbench Release route claim must match the target surface." });
9989
+ }
9990
+ });
9991
+ var NavigationNodeBaseShape = {
9992
+ nodeId: ContractIdentifierSchema,
9993
+ parentNodeId: ContractIdentifierSchema.nullable(),
9994
+ order: z9.number().int(),
9995
+ disabled: z9.boolean().optional()
9996
+ };
9997
+ var NavigationGroupNodeSchema = z9.object({
9998
+ ...NavigationNodeBaseShape,
9999
+ kind: z9.literal("group"),
10000
+ label: I18nTextSchema,
10001
+ iconRef: StableRefSchema.optional(),
10002
+ collapsedByDefault: z9.boolean(),
10003
+ audience: AccessPolicySchema
10004
+ }).strict();
10005
+ var NavigationTargetNodeSchema = z9.object({
10006
+ ...NavigationNodeBaseShape,
10007
+ kind: z9.literal("target"),
10008
+ label: I18nTextSchema,
10009
+ iconRef: StableRefSchema.optional(),
10010
+ tone: z9.enum(["default", "danger"]).optional(),
10011
+ targetRef: StableRefSchema,
10012
+ parameterMapping: z9.record(ContractIdentifierSchema, BindingSourceSchema),
10013
+ audience: AccessPolicySchema
10014
+ }).strict();
10015
+ var NavigationSeparatorNodeSchema = z9.object({
10016
+ ...NavigationNodeBaseShape,
10017
+ kind: z9.literal("separator")
10018
+ }).strict();
10019
+ var NavigationNodeSchema = z9.discriminatedUnion("kind", [
10020
+ NavigationGroupNodeSchema,
10021
+ NavigationTargetNodeSchema,
10022
+ NavigationSeparatorNodeSchema
10023
+ ]);
10024
+ var validateNavigationTree = (nodes, context) => {
10025
+ const byId = /* @__PURE__ */ new Map();
10026
+ nodes.forEach((node, index) => {
10027
+ if (byId.has(node.nodeId)) context.addIssue({ code: "custom", path: ["nodes", index, "nodeId"], message: `Duplicate Navigation node: ${node.nodeId}` });
10028
+ else byId.set(node.nodeId, { node, index });
10029
+ });
10030
+ const siblingOrders = /* @__PURE__ */ new Set();
10031
+ nodes.forEach((node, index) => {
10032
+ const orderKey = `${node.parentNodeId ?? ""}:${node.order}`;
10033
+ if (siblingOrders.has(orderKey)) context.addIssue({ code: "custom", path: ["nodes", index, "order"], message: "Sibling Navigation order values must be unique." });
10034
+ siblingOrders.add(orderKey);
10035
+ if (node.parentNodeId) {
10036
+ const parent = byId.get(node.parentNodeId)?.node;
10037
+ if (!parent) context.addIssue({ code: "custom", path: ["nodes", index, "parentNodeId"], message: "Navigation node has an unknown parent." });
10038
+ else if (parent.kind !== "group") context.addIssue({ code: "custom", path: ["nodes", index, "parentNodeId"], message: "Navigation parents must be groups." });
10039
+ }
10040
+ const ancestors = /* @__PURE__ */ new Set([node.nodeId]);
10041
+ let parentId = node.parentNodeId;
10042
+ while (parentId) {
10043
+ if (ancestors.has(parentId)) {
10044
+ context.addIssue({ code: "custom", path: ["nodes", index, "parentNodeId"], message: `Navigation cycle contains ${node.nodeId}.` });
10045
+ break;
10046
+ }
10047
+ ancestors.add(parentId);
10048
+ parentId = byId.get(parentId)?.node.parentNodeId ?? null;
10049
+ }
10050
+ });
10051
+ };
10052
+ var NavigationSchema = z9.object({
10053
+ contract: z9.literal("Navigation"),
10054
+ schemaVersion: z9.literal(DECLARATIVE_CONTROL_SCHEMA_VERSION),
10055
+ navigationId: ContractIdentifierSchema,
10056
+ tenantScope: TenantScopeSchema,
10057
+ identity: IdentitySchema,
10058
+ supportedSurfaces: z9.array(ProductSurfaceSchema).min(1),
10059
+ placements: z9.array(ContractIdentifierSchema).min(1),
10060
+ lifecycle: DeclarativeLifecycleSchema,
10061
+ nodes: z9.array(NavigationNodeSchema),
10062
+ managementAccess: ManagementAccessSchema,
10063
+ performanceBudgetRef: RevisionRefSchema,
10064
+ observationPolicyRevisionRef: RevisionRefSchema
10065
+ }).strict().superRefine((value, context) => {
10066
+ validateNavigationTree(value.nodes, context);
10067
+ value.nodes.forEach((node, index) => {
10068
+ if (node.kind === "target" && !["page", "workbench", "menu-action", "domain-command"].includes(node.targetRef.kind)) {
10069
+ context.addIssue({ code: "custom", path: ["nodes", index, "targetRef", "kind"], message: "Navigation targets must reference Page, Workbench, registered Menu Action, or DomainCommand identities." });
10070
+ }
10071
+ });
10072
+ });
10073
+ var ResolvedNavigationTargetSchema = z9.object({
10074
+ nodeId: ContractIdentifierSchema,
10075
+ stableTargetRef: StableRefSchema,
10076
+ targetRevisionRef: RevisionRefSchema,
10077
+ releaseRevisionRef: RevisionRefSchema.optional()
10078
+ }).strict();
10079
+ var NavigationReleaseSchema = z9.object({
10080
+ contract: z9.literal("NavigationRelease"),
10081
+ ...ReleaseBaseShape,
10082
+ navigationRevisionRef: RevisionRefSchema,
10083
+ target: z9.object({
10084
+ environmentRef: StableRefSchema,
10085
+ surface: ProductSurfaceSchema,
10086
+ placement: ContractIdentifierSchema
10087
+ }).strict(),
10088
+ resolvedTargets: z9.array(ResolvedNavigationTargetSchema)
10089
+ }).strict().superRefine((value, context) => {
10090
+ validateDependencySnapshot(value.dependencySnapshot, context);
10091
+ validateReleaseExpectedHead(value, "navigation-release", context);
10092
+ if (value.navigationRevisionRef.kind !== "navigation") context.addIssue({ code: "custom", path: ["navigationRevisionRef", "kind"], message: "Expected a navigation revision." });
10093
+ if (value.target.environmentRef.kind !== "environment") context.addIssue({ code: "custom", path: ["target", "environmentRef", "kind"], message: "Navigation release target requires an environment reference." });
10094
+ if (uniqueArray(value.resolvedTargets, (target) => target.nodeId)) context.addIssue({ code: "custom", path: ["resolvedTargets"], message: "Resolved Navigation node IDs must be unique." });
10095
+ });
10096
+ var RuntimeDiagnosticSchema = z9.object({
10097
+ code: ContractIdentifierSchema,
10098
+ severity: z9.enum(["info", "warning", "error"]),
10099
+ path: z9.string().trim().min(1),
10100
+ message: z9.string().trim().min(1)
10101
+ }).strict();
10102
+ var RuntimeBundleBaseShape = {
10103
+ schemaVersion: z9.literal(DECLARATIVE_CONTROL_SCHEMA_VERSION),
10104
+ tenantScope: TenantScopeSchema,
10105
+ releaseRevisionRef: RevisionRefSchema,
10106
+ compilerRevisionRef: RevisionRefSchema,
10107
+ generation: z9.number().int().nonnegative(),
10108
+ dependencySnapshot: z9.array(ReleaseDependencySchema),
10109
+ contentHash: Sha256Schema,
10110
+ rebuildable: z9.literal(true),
10111
+ diagnostics: z9.array(RuntimeDiagnosticSchema)
10112
+ };
10113
+ var PageRuntimeBundleSchema = z9.object({
10114
+ contract: z9.literal("PageRuntimeBundle"),
10115
+ ...RuntimeBundleBaseShape,
10116
+ pageId: ContractIdentifierSchema,
10117
+ pageRevisionRef: RevisionRefSchema,
10118
+ surface: ProductSurfaceSchema,
10119
+ routeClaims: z9.array(CompiledRouteClaimSchema),
10120
+ shellRevisionRef: RevisionRefSchema,
10121
+ renderTree: RenderTreeSchema,
10122
+ capabilityInstances: z9.array(CapabilityInstanceSchema),
10123
+ ontologyBindings: z9.array(OntologyBindingSchema),
10124
+ actionBindings: z9.array(ActionBindingSchema),
10125
+ pageAccessPolicy: AccessPolicySchema,
10126
+ tokenRevisionRefs: z9.array(RevisionRefSchema),
10127
+ performanceBudgetRef: RevisionRefSchema,
10128
+ observationPolicyRevisionRef: RevisionRefSchema,
10129
+ privacyClassification: z9.enum(["public", "internal", "confidential", "restricted"])
10130
+ }).strict();
10131
+ var ResolvedWorkbenchAppInstanceSchema = WorkbenchAppInstanceSchema.extend({
10132
+ targetAccessPolicy: AccessPolicySchema
10133
+ }).strict();
10134
+ var WorkbenchRuntimeTargetSchema = WorkbenchReleaseSchema.shape.target.safeExtend({
10135
+ routeClaim: CompiledRouteClaimSchema
10136
+ }).strict();
10137
+ var WorkbenchRuntimeBundleSchema = z9.object({
10138
+ contract: z9.literal("WorkbenchRuntimeBundle"),
10139
+ ...RuntimeBundleBaseShape,
10140
+ workbenchId: ContractIdentifierSchema,
10141
+ workbenchRevisionRef: RevisionRefSchema,
10142
+ surface: ProductSurfaceSchema,
10143
+ routeClaims: z9.array(CompiledRouteClaimSchema),
10144
+ groups: z9.array(WorkbenchGroupSchema),
10145
+ appInstances: z9.array(ResolvedWorkbenchAppInstanceSchema),
10146
+ defaultEntry: WorkbenchSchema.shape.defaultEntry,
10147
+ layout: WorkbenchSchema.shape.layout,
10148
+ workbenchAccessPolicy: AccessPolicySchema,
10149
+ personalPreferencesPolicy: WorkbenchSchema.shape.personalPreferencesPolicy,
10150
+ target: WorkbenchRuntimeTargetSchema,
10151
+ performanceBudgetRef: RevisionRefSchema,
10152
+ observationPolicyRevisionRef: RevisionRefSchema,
10153
+ privacyClassification: z9.enum(["public", "internal", "confidential", "restricted"])
10154
+ }).strict();
10155
+ var CompiledNavigationTargetSchema = ResolvedNavigationTargetSchema.extend({
10156
+ kind: z9.literal("route"),
10157
+ accessPolicy: AccessPolicySchema,
10158
+ routeClaim: CompiledRouteClaimSchema
10159
+ }).strict();
10160
+ var CompiledNavigationRegisteredMenuActionTargetSchema = ResolvedNavigationTargetSchema.extend({
10161
+ kind: z9.literal("registered-menu-action"),
10162
+ accessPolicy: AccessPolicySchema,
10163
+ execution: z9.literal("client"),
10164
+ applicationId: ContractIdentifierSchema,
10165
+ actionRef: ContractIdentifierSchema,
10166
+ inputSchemaRef: ContractIdentifierSchema.optional(),
10167
+ input: JsonObjectSchema,
10168
+ sourceCatalogRevisionRef: RevisionRefSchema
10169
+ }).strict();
10170
+ var CompiledNavigationDomainCommandTargetSchema = ResolvedNavigationTargetSchema.extend({
10171
+ kind: z9.literal("governed-domain-command"),
10172
+ accessPolicy: AccessPolicySchema,
10173
+ execution: z9.literal("server"),
10174
+ commandRevisionRef: RevisionRefSchema,
10175
+ inputSchemaRevisionRef: RevisionRefSchema,
10176
+ resultSchemaRevisionRef: RevisionRefSchema.optional(),
10177
+ input: JsonObjectSchema
10178
+ }).strict();
10179
+ var CompiledNavigationResolvedTargetSchema = z9.discriminatedUnion("kind", [
10180
+ CompiledNavigationTargetSchema,
10181
+ CompiledNavigationRegisteredMenuActionTargetSchema,
10182
+ CompiledNavigationDomainCommandTargetSchema
10183
+ ]);
10184
+ var CompiledNavigationGroupNodeSchema = NavigationGroupNodeSchema.extend({
10185
+ ancestorAccessPolicies: z9.array(AccessPolicySchema)
10186
+ }).strict();
10187
+ var CompiledNavigationTargetNodeSchema = NavigationTargetNodeSchema.extend({
10188
+ ancestorAccessPolicies: z9.array(AccessPolicySchema),
10189
+ resolvedTarget: CompiledNavigationResolvedTargetSchema
10190
+ }).strict();
10191
+ var CompiledNavigationSeparatorNodeSchema = NavigationSeparatorNodeSchema.extend({
10192
+ ancestorAccessPolicies: z9.array(AccessPolicySchema)
10193
+ }).strict();
10194
+ var CompiledNavigationNodeSchema = z9.discriminatedUnion("kind", [
10195
+ CompiledNavigationGroupNodeSchema,
10196
+ CompiledNavigationTargetNodeSchema,
10197
+ CompiledNavigationSeparatorNodeSchema
10198
+ ]);
10199
+ var NavigationRuntimeBundleSchema = z9.object({
10200
+ contract: z9.literal("NavigationRuntimeBundle"),
10201
+ ...RuntimeBundleBaseShape,
10202
+ navigationId: ContractIdentifierSchema,
10203
+ navigationRevisionRef: RevisionRefSchema,
10204
+ surface: ProductSurfaceSchema,
10205
+ placement: ContractIdentifierSchema,
10206
+ nodes: z9.array(CompiledNavigationNodeSchema),
10207
+ performanceBudgetRef: RevisionRefSchema,
10208
+ observationPolicyRevisionRef: RevisionRefSchema
10209
+ }).strict();
10210
+ var DeclarativeControlOntologyDefinitionSchema = OntologyDefinitionSchema.extend({
10211
+ classification: z9.literal("control"),
10212
+ discovery: z9.object({
10213
+ ordinaryDataBrowser: z9.literal(false),
10214
+ businessSearch: z9.literal(false),
10215
+ businessStatistics: z9.literal(false),
10216
+ ordinaryExport: z9.literal(false),
10217
+ genericWrite: z9.literal(false)
10218
+ }).strict()
10219
+ }).strict();
10220
+ var controlDefinition = (ontologyId, bodySchemaRef) => DeclarativeControlOntologyDefinitionSchema.parse({
10221
+ contract: "OntologyDefinition",
10222
+ ontologyId,
10223
+ dataSpaceId: "monkeys.control",
10224
+ ownerRepo: "monkeys-js-sdk",
10225
+ bodySchemaRef,
10226
+ authority: { service: "monkeys-data-server", storage: "domain-record", scope: "tenant" },
10227
+ relationKinds: [],
10228
+ metricKinds: [],
10229
+ classification: "control",
10230
+ discovery: {
10231
+ ordinaryDataBrowser: false,
10232
+ businessSearch: false,
10233
+ businessStatistics: false,
10234
+ ordinaryExport: false,
10235
+ genericWrite: false
10236
+ }
10237
+ });
10238
+ var DECLARATIVE_CONTROL_ONTOLOGY_DEFINITIONS = Object.freeze([
10239
+ controlDefinition("monkeys.system.page", "monkeys.system.page/v1"),
10240
+ controlDefinition("monkeys.system.page-release", "monkeys.system.page-release/v1"),
10241
+ controlDefinition("monkeys.system.workbench", "monkeys.system.workbench/v1"),
10242
+ controlDefinition("monkeys.system.workbench-release", "monkeys.system.workbench-release/v1"),
10243
+ controlDefinition("monkeys.system.navigation", "monkeys.system.navigation/v1"),
10244
+ controlDefinition("monkeys.system.navigation-release", "monkeys.system.navigation-release/v1")
10245
+ ]);
10246
+
9309
10247
  // src/contracts/semantic.ts
9310
- var ConceptRelationshipSchema = z9.object({
10248
+ var ExactRefKindSchema = (kind) => RevisionRefSchema.superRefine((value, context) => {
10249
+ if (value.kind !== kind) context.addIssue({ code: "custom", path: ["kind"], message: `Reference must use kind ${kind}.` });
10250
+ });
10251
+ var SchemaDefinitionSchema = z10.object({
10252
+ contract: z10.literal("Schema"),
10253
+ schemaVersion: z10.literal(1),
10254
+ schemaId: ContractIdentifierSchema,
10255
+ ownerRepo: ContractIdentifierSchema,
10256
+ dialect: z10.literal("https://json-schema.org/draft/2020-12/schema"),
10257
+ document: JsonObjectSchema
10258
+ }).strict();
10259
+ var OntologyViewDefinitionSchema = z10.object({
10260
+ contract: z10.literal("View"),
10261
+ schemaVersion: z10.literal(1),
10262
+ viewId: ContractIdentifierSchema,
10263
+ ownerRepo: ContractIdentifierSchema,
10264
+ ontologyDefinitionRevisionRef: ExactRefKindSchema("ontology-definition"),
10265
+ renderModelSchemaRevisionRef: ExactRefKindSchema("schema"),
10266
+ requiredPermissionCodes: z10.array(ContractIdentifierSchema).default([])
10267
+ }).strict();
10268
+ var ConceptRelationshipSchema = z10.object({
9311
10269
  kind: ContractIdentifierSchema,
9312
10270
  targetConceptId: ContractIdentifierSchema,
9313
- cardinality: z9.enum(["one", "optional", "many"])
10271
+ cardinality: z10.enum(["one", "optional", "many"])
9314
10272
  }).strict();
9315
- var ConceptDefinitionSchema = z9.object({
9316
- contract: z9.literal("ConceptDefinition"),
10273
+ var ConceptDefinitionSchema = z10.object({
10274
+ contract: z10.literal("ConceptDefinition"),
9317
10275
  conceptId: ContractIdentifierSchema,
9318
10276
  ownerRepo: ContractIdentifierSchema,
9319
- displayName: z9.string().trim().min(1),
9320
- description: z9.string().optional(),
10277
+ displayName: z10.string().trim().min(1),
10278
+ description: z10.string().optional(),
9321
10279
  schemaRef: ContractIdentifierSchema,
9322
10280
  ontologyId: ContractIdentifierSchema.optional(),
9323
- capabilityIds: z9.array(ContractIdentifierSchema).default([]),
9324
- commandNames: z9.array(ContractIdentifierSchema).default([]),
9325
- relationships: z9.array(ConceptRelationshipSchema).default([])
10281
+ capabilityIds: z10.array(ContractIdentifierSchema).default([]),
10282
+ commandNames: z10.array(ContractIdentifierSchema).default([]),
10283
+ relationships: z10.array(ConceptRelationshipSchema).default([])
9326
10284
  }).strict();
9327
- var DomainCommandDefinitionSchema = z9.object({
9328
- contract: z9.literal("DomainCommandDefinition"),
10285
+ var DomainCommandDefinitionSchema = z10.object({
10286
+ contract: z10.literal("DomainCommandDefinition"),
9329
10287
  commandName: ContractIdentifierSchema,
9330
10288
  ownerRepo: ContractIdentifierSchema,
9331
- displayName: z9.string().trim().min(1),
9332
- description: z9.string().optional(),
9333
- targetKinds: z9.array(ContractIdentifierSchema).min(1),
10289
+ displayName: z10.string().trim().min(1),
10290
+ description: z10.string().optional(),
10291
+ targetKinds: z10.array(ContractIdentifierSchema).min(1),
9334
10292
  inputSchemaRef: ContractIdentifierSchema,
9335
10293
  outputSchemaRef: ContractIdentifierSchema.optional(),
9336
- requiredPermissionCodes: z9.array(ContractIdentifierSchema).default([]),
10294
+ requiredPermissionCodes: z10.array(ContractIdentifierSchema).default([]),
9337
10295
  handlerRef: EntityRefSchema,
9338
- sideEffects: z9.array(z9.enum(["data-write", "execution", "navigation", "notification", "external-call"])).default([])
10296
+ sideEffects: z10.array(z10.enum(["data-write", "execution", "navigation", "notification", "external-call"])).default([])
9339
10297
  }).strict();
9340
- var DomainCommandSchema = z9.object({
9341
- contract: z9.literal("DomainCommand"),
10298
+ var DomainCommandSchema = z10.object({
10299
+ contract: z10.literal("DomainCommand"),
9342
10300
  commandId: ContractIdentifierSchema,
9343
10301
  commandName: ContractIdentifierSchema,
9344
10302
  requestId: ContractIdentifierSchema,
@@ -9346,30 +10304,30 @@ var DomainCommandSchema = z9.object({
9346
10304
  idempotencyKey: ContractIdentifierSchema,
9347
10305
  targetRef: EntityRefSchema,
9348
10306
  actorRef: EntityRefSchema,
9349
- source: z9.object({
9350
- product: z9.enum(["studio", "kernel", "agent", "mcp", "service"]),
10307
+ source: z10.object({
10308
+ product: z10.enum(["studio", "kernel", "agent", "mcp", "service"]),
9351
10309
  pageId: ContractIdentifierSchema.optional(),
9352
10310
  capabilityId: ContractIdentifierSchema.optional()
9353
10311
  }).strict(),
9354
10312
  payload: JsonObjectSchema,
9355
10313
  issuedAt: IsoDateTimeSchema
9356
10314
  }).strict();
9357
- var ProductDeclarationSchema = z9.object({
9358
- contract: z9.literal("ProductDeclaration"),
10315
+ var ProductDeclarationSchema = z10.object({
10316
+ contract: z10.literal("ProductDeclaration"),
9359
10317
  declarationId: ContractIdentifierSchema,
9360
10318
  ownerRepo: ContractIdentifierSchema,
9361
- concepts: z9.array(ConceptDefinitionSchema).default([]),
9362
- ontologies: z9.array(OntologyDefinitionSchema).default([]),
9363
- projections: z9.array(ProjectionSpecSchema).default([]),
9364
- commands: z9.array(DomainCommandDefinitionSchema).default([]),
9365
- capabilities: z9.array(CapabilityManifestSchema).default([]),
9366
- pages: z9.array(PageDefinitionSchema).default([]),
9367
- menus: z9.array(MenuDefinitionSchema).default([])
9368
- }).strict();
9369
- var DeclarationGraphEdgeSchema = z9.object({
10319
+ concepts: z10.array(ConceptDefinitionSchema).default([]),
10320
+ ontologies: z10.array(OntologyDefinitionSchema).default([]),
10321
+ projections: z10.array(ProjectionSpecSchema).default([]),
10322
+ commands: z10.array(DomainCommandDefinitionSchema).default([]),
10323
+ capabilities: z10.array(CapabilityManifestSchema).default([]),
10324
+ pages: z10.array(PageDefinitionSchema).default([]),
10325
+ menus: z10.array(MenuDefinitionSchema).default([])
10326
+ }).strict();
10327
+ var DeclarationGraphEdgeSchema = z10.object({
9370
10328
  from: EntityRefSchema,
9371
10329
  to: EntityRefSchema,
9372
- relation: z9.enum([
10330
+ relation: z10.enum([
9373
10331
  "uses-ontology",
9374
10332
  "uses-projection",
9375
10333
  "uses-capability",
@@ -9377,17 +10335,17 @@ var DeclarationGraphEdgeSchema = z9.object({
9377
10335
  "relates-to-concept"
9378
10336
  ])
9379
10337
  }).strict();
9380
- var ChangeImpactSchema = z9.object({
10338
+ var ChangeImpactSchema = z10.object({
9381
10339
  changedRef: EntityRefSchema,
9382
- affectedRefs: z9.array(EntityRefSchema),
9383
- reasons: z9.array(ContractIdentifierSchema).min(1)
10340
+ affectedRefs: z10.array(EntityRefSchema),
10341
+ reasons: z10.array(ContractIdentifierSchema).min(1)
9384
10342
  }).strict();
9385
- var ChangeImpactGraphSchema = z9.object({
9386
- contract: z9.literal("ChangeImpactGraph"),
10343
+ var ChangeImpactGraphSchema = z10.object({
10344
+ contract: z10.literal("ChangeImpactGraph"),
9387
10345
  declarationId: ContractIdentifierSchema,
9388
- nodes: z9.array(EntityRefSchema),
9389
- edges: z9.array(DeclarationGraphEdgeSchema),
9390
- impacts: z9.array(ChangeImpactSchema),
10346
+ nodes: z10.array(EntityRefSchema),
10347
+ edges: z10.array(DeclarationGraphEdgeSchema),
10348
+ impacts: z10.array(ChangeImpactSchema),
9391
10349
  generatedAt: IsoDateTimeSchema
9392
10350
  }).strict();
9393
10351
 
@@ -9546,132 +10504,1051 @@ var compileProductDeclaration = (input) => {
9546
10504
  if (!ontologiesById.has(ontologyId)) throw new Error(`Projection ${projection.projectionId} references unknown ontology ${ontologyId}.`);
9547
10505
  addEdge(ref("projection", projection.projectionId), ref("ontology", ontologyId), "uses-ontology");
9548
10506
  }
9549
- }
9550
- for (const command of declaration.commands) addNode("command", command.commandName);
9551
- for (const capability of declaration.capabilities) addNode("capability", capability.id);
9552
- for (const menu of declaration.menus) addNode("menu", `${menu.applicationId}/${menu.surface}/${menu.menuId}`);
9553
- for (const concept of declaration.concepts) {
9554
- addNode("concept", concept.conceptId);
9555
- if (concept.ontologyId) {
9556
- if (!ontologiesById.has(concept.ontologyId)) throw new Error(`Concept ${concept.conceptId} references unknown ontology ${concept.ontologyId}.`);
9557
- addEdge(ref("concept", concept.conceptId), ref("ontology", concept.ontologyId), "uses-ontology");
10507
+ }
10508
+ for (const command of declaration.commands) addNode("command", command.commandName);
10509
+ for (const capability of declaration.capabilities) addNode("capability", capability.id);
10510
+ for (const menu of declaration.menus) addNode("menu", `${menu.applicationId}/${menu.surface}/${menu.menuId}`);
10511
+ for (const concept of declaration.concepts) {
10512
+ addNode("concept", concept.conceptId);
10513
+ if (concept.ontologyId) {
10514
+ if (!ontologiesById.has(concept.ontologyId)) throw new Error(`Concept ${concept.conceptId} references unknown ontology ${concept.ontologyId}.`);
10515
+ addEdge(ref("concept", concept.conceptId), ref("ontology", concept.ontologyId), "uses-ontology");
10516
+ }
10517
+ for (const capabilityId of concept.capabilityIds) {
10518
+ if (!capabilitiesById.has(capabilityId)) throw new Error(`Concept ${concept.conceptId} references unknown capability ${capabilityId}.`);
10519
+ addEdge(ref("concept", concept.conceptId), ref("capability", capabilityId), "uses-capability");
10520
+ }
10521
+ for (const commandName of concept.commandNames) {
10522
+ if (!commandsByName.has(commandName)) throw new Error(`Concept ${concept.conceptId} references unknown command ${commandName}.`);
10523
+ addEdge(ref("concept", concept.conceptId), ref("command", commandName), "uses-command");
10524
+ }
10525
+ for (const relationship of concept.relationships) {
10526
+ if (!conceptsById.has(relationship.targetConceptId)) {
10527
+ throw new Error(`Concept ${concept.conceptId} references unknown concept ${relationship.targetConceptId}.`);
10528
+ }
10529
+ addEdge(ref("concept", concept.conceptId), ref("concept", relationship.targetConceptId), "relates-to-concept");
10530
+ }
10531
+ }
10532
+ for (const page of declaration.pages) {
10533
+ addNode("page", page.pageId);
10534
+ if (page.binding.ontologyId) {
10535
+ if (!ontologiesById.has(page.binding.ontologyId)) throw new Error(`Page ${page.pageId} references unknown ontology ${page.binding.ontologyId}.`);
10536
+ addEdge(ref("page", page.pageId), ref("ontology", page.binding.ontologyId), "uses-ontology");
10537
+ }
10538
+ if (page.binding.projectionRef) {
10539
+ if (!projectionsById.has(page.binding.projectionRef)) throw new Error(`Page ${page.pageId} references unknown projection ${page.binding.projectionRef}.`);
10540
+ addEdge(ref("page", page.pageId), ref("projection", page.binding.projectionRef), "uses-projection");
10541
+ }
10542
+ for (const capabilityRef of [page.capabilityRef, ...page.capabilityRefs].filter(Boolean)) {
10543
+ if (!capabilitiesById.has(capabilityRef.id)) throw new Error(`Page ${page.pageId} references unknown capability ${capabilityRef.id}.`);
10544
+ addEdge(ref("page", page.pageId), ref("capability", capabilityRef.id), "uses-capability");
10545
+ }
10546
+ }
10547
+ uniqueIndex(nodes, refKey, "declaration node");
10548
+ return Object.freeze({
10549
+ declaration: Object.freeze(declaration),
10550
+ conceptsById,
10551
+ ontologiesById,
10552
+ projectionsById,
10553
+ commandsByName,
10554
+ capabilitiesById,
10555
+ pagesById,
10556
+ menusByKey,
10557
+ nodes: Object.freeze(nodes),
10558
+ edges: Object.freeze(edges)
10559
+ });
10560
+ };
10561
+ var validateDomainCommand = (input, definitions, permissionCodes) => {
10562
+ const command = DomainCommandSchema.parse(input);
10563
+ const commandsByName = uniqueIndex(
10564
+ definitions.map((definition2) => DomainCommandDefinitionSchema.parse(definition2)),
10565
+ (definition2) => definition2.commandName,
10566
+ "command name"
10567
+ );
10568
+ const definition = commandsByName.get(command.commandName);
10569
+ if (!definition) throw new Error(`Unknown domain command: ${command.commandName}`);
10570
+ if (!definition.targetKinds.includes(command.targetRef.kind)) {
10571
+ throw new Error(`Command ${command.commandName} does not accept target kind ${command.targetRef.kind}.`);
10572
+ }
10573
+ const granted = new Set(permissionCodes);
10574
+ const missing = definition.requiredPermissionCodes.filter((permission) => !granted.has(permission));
10575
+ if (missing.length) throw new Error(`Command ${command.commandName} requires permissions: ${missing.join(", ")}`);
10576
+ return Object.freeze(command);
10577
+ };
10578
+ var declarationValuesByRef = (compiled) => {
10579
+ const values = /* @__PURE__ */ new Map();
10580
+ for (const value of compiled.declaration.ontologies) values.set(refKey(ref("ontology", value.ontologyId)), value);
10581
+ for (const value of compiled.declaration.projections) values.set(refKey(ref("projection", value.projectionId)), value);
10582
+ for (const value of compiled.declaration.commands) values.set(refKey(ref("command", value.commandName)), value);
10583
+ for (const value of compiled.declaration.capabilities) values.set(refKey(ref("capability", value.id)), value);
10584
+ for (const value of compiled.declaration.concepts) values.set(refKey(ref("concept", value.conceptId)), value);
10585
+ for (const value of compiled.declaration.pages) values.set(refKey(ref("page", value.pageId)), value);
10586
+ return values;
10587
+ };
10588
+ var buildChangeImpactGraph = (previousInput, nextInput, generatedAt = (/* @__PURE__ */ new Date()).toISOString()) => {
10589
+ const previous = compileProductDeclaration(previousInput);
10590
+ const next = compileProductDeclaration(nextInput);
10591
+ const previousValues = declarationValuesByRef(previous);
10592
+ const nextValues = declarationValuesByRef(next);
10593
+ const changedKeys = /* @__PURE__ */ new Set();
10594
+ for (const key of /* @__PURE__ */ new Set([...previousValues.keys(), ...nextValues.keys()])) {
10595
+ if (JSON.stringify(previousValues.get(key)) !== JSON.stringify(nextValues.get(key))) changedKeys.add(key);
10596
+ }
10597
+ const reverse = /* @__PURE__ */ new Map();
10598
+ for (const edge of [...previous.edges, ...next.edges]) {
10599
+ const dependency = refKey(edge.to);
10600
+ const dependent = refKey(edge.from);
10601
+ const values = reverse.get(dependency) ?? /* @__PURE__ */ new Set();
10602
+ values.add(dependent);
10603
+ reverse.set(dependency, values);
10604
+ }
10605
+ const refs = /* @__PURE__ */ new Map();
10606
+ for (const node of [...previous.nodes, ...next.nodes]) refs.set(refKey(node), node);
10607
+ const impacts = Array.from(changedKeys).sort().map((changedKey) => {
10608
+ const affected = /* @__PURE__ */ new Set();
10609
+ const queue = [...reverse.get(changedKey) ?? []];
10610
+ while (queue.length) {
10611
+ const current = queue.shift();
10612
+ if (affected.has(current)) continue;
10613
+ affected.add(current);
10614
+ queue.push(...reverse.get(current) ?? []);
10615
+ }
10616
+ return {
10617
+ changedRef: refs.get(changedKey) ?? (() => {
10618
+ const separator = changedKey.indexOf(":");
10619
+ return ref(changedKey.slice(0, separator), changedKey.slice(separator + 1));
10620
+ })(),
10621
+ affectedRefs: Array.from(affected).sort().map((key) => refs.get(key)),
10622
+ reasons: affected.size ? ["dependency"] : ["direct-change"]
10623
+ };
10624
+ });
10625
+ return ChangeImpactGraphSchema.parse({
10626
+ contract: "ChangeImpactGraph",
10627
+ declarationId: next.declaration.declarationId,
10628
+ nodes: Array.from(refs.values()).sort((left, right) => refKey(left).localeCompare(refKey(right))),
10629
+ edges: next.edges,
10630
+ impacts,
10631
+ generatedAt
10632
+ });
10633
+ };
10634
+
10635
+ // src/runtime/render-tree-compiler.ts
10636
+ var compileRenderTree = (input) => {
10637
+ const tree = RenderTreeSchema.parse(input);
10638
+ const nodesById = /* @__PURE__ */ new Map();
10639
+ for (const node of tree.nodes) {
10640
+ if (nodesById.has(node.nodeId)) throw new Error(`Duplicate render node id: ${node.nodeId}`);
10641
+ nodesById.set(node.nodeId, node);
10642
+ }
10643
+ const root = nodesById.get(tree.rootNodeId);
10644
+ if (!root) throw new Error(`Render tree ${tree.treeId} has no root node ${tree.rootNodeId}.`);
10645
+ if (root.parentNodeId !== void 0) throw new Error(`Render tree root ${root.nodeId} cannot declare a parent.`);
10646
+ for (const node of tree.nodes) {
10647
+ if (node.nodeId !== root.nodeId && node.parentNodeId === void 0) {
10648
+ throw new Error(`Render node ${node.nodeId} is disconnected from root ${root.nodeId}.`);
10649
+ }
10650
+ if (node.parentNodeId !== void 0) {
10651
+ const parent = nodesById.get(node.parentNodeId);
10652
+ if (!parent) throw new Error(`Render node ${node.nodeId} references missing parent ${node.parentNodeId}.`);
10653
+ if (!parent.children.includes(node.nodeId)) {
10654
+ throw new Error(`Render node ${node.nodeId} is not declared by parent ${parent.nodeId}.`);
10655
+ }
10656
+ }
10657
+ for (const childId of node.children) {
10658
+ const child = nodesById.get(childId);
10659
+ if (!child) throw new Error(`Render node ${node.nodeId} references missing child ${childId}.`);
10660
+ if (child.parentNodeId !== node.nodeId) {
10661
+ throw new Error(`Render child ${childId} does not point back to parent ${node.nodeId}.`);
10662
+ }
10663
+ }
10664
+ }
10665
+ const visiting = /* @__PURE__ */ new Set();
10666
+ const visited = /* @__PURE__ */ new Set();
10667
+ const traversal = [];
10668
+ const visit = (node) => {
10669
+ if (visiting.has(node.nodeId)) throw new Error(`Render tree ${tree.treeId} contains a cycle at ${node.nodeId}.`);
10670
+ if (visited.has(node.nodeId)) return;
10671
+ visiting.add(node.nodeId);
10672
+ traversal.push(node);
10673
+ node.children.forEach((childId) => visit(nodesById.get(childId)));
10674
+ visiting.delete(node.nodeId);
10675
+ visited.add(node.nodeId);
10676
+ };
10677
+ visit(root);
10678
+ if (visited.size !== nodesById.size) {
10679
+ const disconnected = tree.nodes.find((node) => !visited.has(node.nodeId));
10680
+ throw new Error(`Render node ${disconnected.nodeId} is not reachable from root ${root.nodeId}.`);
10681
+ }
10682
+ const childrenOf = (nodeId) => {
10683
+ const node = nodesById.get(nodeId);
10684
+ if (!node) throw new Error(`Unknown render node: ${nodeId}`);
10685
+ return Object.freeze(node.children.map((childId) => nodesById.get(childId)));
10686
+ };
10687
+ const ancestorsOf = (nodeId) => {
10688
+ let node = nodesById.get(nodeId);
10689
+ if (!node) throw new Error(`Unknown render node: ${nodeId}`);
10690
+ const ancestors = [];
10691
+ while (node.parentNodeId !== void 0) {
10692
+ node = nodesById.get(node.parentNodeId);
10693
+ ancestors.push(node);
10694
+ }
10695
+ return Object.freeze(ancestors);
10696
+ };
10697
+ return Object.freeze({
10698
+ tree,
10699
+ root,
10700
+ nodesById,
10701
+ traversal: Object.freeze(traversal),
10702
+ childrenOf,
10703
+ ancestorsOf
10704
+ });
10705
+ };
10706
+
10707
+ // src/runtime/declarative-control-compiler.ts
10708
+ var DeclarativeControlCompilationError = class extends Error {
10709
+ constructor(code, path, message) {
10710
+ super(`${code} at ${path}: ${message}`);
10711
+ this.code = code;
10712
+ this.path = path;
10713
+ this.name = "DeclarativeControlCompilationError";
10714
+ }
10715
+ };
10716
+ var scopedIdentityKey2 = (reference) => `${reference.kind}:${reference.id}:${reference.ownerRepo}`;
10717
+ var scopeKey = (scope) => `${scopedIdentityKey2(scope.tenantRef)}:${scopedIdentityKey2(scope.dataSpaceRef)}:${scope.teamRef ? scopedIdentityKey2(scope.teamRef) : ""}`;
10718
+ var stableRefKey = (reference) => `${reference.visibility}:${reference.tenantScope ? scopeKey(reference.tenantScope) : ""}:${reference.kind}:${reference.id}:${reference.ownerRepo}`;
10719
+ var revisionRefKey = (reference) => `${stableRefKey(reference)}@${reference.revision}:v${reference.schemaVersion}:${reference.contentHash.toLowerCase()}`;
10720
+ var sameStableRef = (left, right) => stableRefKey(left) === stableRefKey(right);
10721
+ var sameRevisionRef = (left, right) => revisionRefKey(left) === revisionRefKey(right);
10722
+ var assertUniqueRegistryKeys = (keys, path) => {
10723
+ const seen = /* @__PURE__ */ new Set();
10724
+ keys.forEach((key, index) => {
10725
+ if (seen.has(key)) {
10726
+ throw new DeclarativeControlCompilationError("REGISTRY_CONFLICT", `${path}[${index}]`, `Duplicate registry identity: ${key}`);
10727
+ }
10728
+ seen.add(key);
10729
+ });
10730
+ };
10731
+ var stableSerialize = (value) => {
10732
+ if (value === void 0) return "null";
10733
+ if (value === null || typeof value !== "object") return JSON.stringify(value) ?? "null";
10734
+ if (Array.isArray(value)) return `[${value.map((item) => stableSerialize(item)).join(",")}]`;
10735
+ const record = value;
10736
+ return `{${Object.keys(record).filter((key) => record[key] !== void 0).sort().map((key) => `${JSON.stringify(key)}:${stableSerialize(record[key])}`).join(",")}}`;
10737
+ };
10738
+ var SHA256_INITIAL = [
10739
+ 1779033703,
10740
+ 3144134277,
10741
+ 1013904242,
10742
+ 2773480762,
10743
+ 1359893119,
10744
+ 2600822924,
10745
+ 528734635,
10746
+ 1541459225
10747
+ ];
10748
+ var SHA256_ROUND = [
10749
+ 1116352408,
10750
+ 1899447441,
10751
+ 3049323471,
10752
+ 3921009573,
10753
+ 961987163,
10754
+ 1508970993,
10755
+ 2453635748,
10756
+ 2870763221,
10757
+ 3624381080,
10758
+ 310598401,
10759
+ 607225278,
10760
+ 1426881987,
10761
+ 1925078388,
10762
+ 2162078206,
10763
+ 2614888103,
10764
+ 3248222580,
10765
+ 3835390401,
10766
+ 4022224774,
10767
+ 264347078,
10768
+ 604807628,
10769
+ 770255983,
10770
+ 1249150122,
10771
+ 1555081692,
10772
+ 1996064986,
10773
+ 2554220882,
10774
+ 2821834349,
10775
+ 2952996808,
10776
+ 3210313671,
10777
+ 3336571891,
10778
+ 3584528711,
10779
+ 113926993,
10780
+ 338241895,
10781
+ 666307205,
10782
+ 773529912,
10783
+ 1294757372,
10784
+ 1396182291,
10785
+ 1695183700,
10786
+ 1986661051,
10787
+ 2177026350,
10788
+ 2456956037,
10789
+ 2730485921,
10790
+ 2820302411,
10791
+ 3259730800,
10792
+ 3345764771,
10793
+ 3516065817,
10794
+ 3600352804,
10795
+ 4094571909,
10796
+ 275423344,
10797
+ 430227734,
10798
+ 506948616,
10799
+ 659060556,
10800
+ 883997877,
10801
+ 958139571,
10802
+ 1322822218,
10803
+ 1537002063,
10804
+ 1747873779,
10805
+ 1955562222,
10806
+ 2024104815,
10807
+ 2227730452,
10808
+ 2361852424,
10809
+ 2428436474,
10810
+ 2756734187,
10811
+ 3204031479,
10812
+ 3329325298
10813
+ ];
10814
+ var rotateRight = (value, amount) => value >>> amount | value << 32 - amount;
10815
+ var sha256Hex = (value) => {
10816
+ const source = [...new TextEncoder().encode(value)];
10817
+ const bitLength = source.length * 8;
10818
+ source.push(128);
10819
+ while (source.length % 64 !== 56) source.push(0);
10820
+ const high = Math.floor(bitLength / 4294967296);
10821
+ const low = bitLength >>> 0;
10822
+ for (let shift = 24; shift >= 0; shift -= 8) source.push(high >>> shift & 255);
10823
+ for (let shift = 24; shift >= 0; shift -= 8) source.push(low >>> shift & 255);
10824
+ const hash = [...SHA256_INITIAL];
10825
+ const words = new Array(64).fill(0);
10826
+ for (let offset = 0; offset < source.length; offset += 64) {
10827
+ for (let index = 0; index < 16; index += 1) {
10828
+ const start = offset + index * 4;
10829
+ words[index] = (source[start] << 24 | source[start + 1] << 16 | source[start + 2] << 8 | source[start + 3]) >>> 0;
10830
+ }
10831
+ for (let index = 16; index < 64; index += 1) {
10832
+ const previous = words[index - 15];
10833
+ const recent = words[index - 2];
10834
+ const small0 = rotateRight(previous, 7) ^ rotateRight(previous, 18) ^ previous >>> 3;
10835
+ const small1 = rotateRight(recent, 17) ^ rotateRight(recent, 19) ^ recent >>> 10;
10836
+ words[index] = words[index - 16] + small0 + words[index - 7] + small1 >>> 0;
10837
+ }
10838
+ let [a, b, c, d, e, f, g, h] = hash;
10839
+ for (let index = 0; index < 64; index += 1) {
10840
+ const big1 = rotateRight(e, 6) ^ rotateRight(e, 11) ^ rotateRight(e, 25);
10841
+ const choice = e & f ^ ~e & g;
10842
+ const temp1 = h + big1 + choice + SHA256_ROUND[index] + words[index] >>> 0;
10843
+ const big0 = rotateRight(a, 2) ^ rotateRight(a, 13) ^ rotateRight(a, 22);
10844
+ const majority = a & b ^ a & c ^ b & c;
10845
+ const temp2 = big0 + majority >>> 0;
10846
+ h = g;
10847
+ g = f;
10848
+ f = e;
10849
+ e = d + temp1 >>> 0;
10850
+ d = c;
10851
+ c = b;
10852
+ b = a;
10853
+ a = temp1 + temp2 >>> 0;
10854
+ }
10855
+ hash[0] = hash[0] + a >>> 0;
10856
+ hash[1] = hash[1] + b >>> 0;
10857
+ hash[2] = hash[2] + c >>> 0;
10858
+ hash[3] = hash[3] + d >>> 0;
10859
+ hash[4] = hash[4] + e >>> 0;
10860
+ hash[5] = hash[5] + f >>> 0;
10861
+ hash[6] = hash[6] + g >>> 0;
10862
+ hash[7] = hash[7] + h >>> 0;
10863
+ }
10864
+ return hash.map((part) => part.toString(16).padStart(8, "0")).join("");
10865
+ };
10866
+ var canonicalContentHash = (value) => sha256Hex(stableSerialize(value));
10867
+ var declarativeCreateTemplateSourceHash = (document) => canonicalContentHash(document);
10868
+ var declarativeCreateTemplateRevisionHash = (registration) => canonicalContentHash(registration.document);
10869
+ var declarativeRouteSpaceSourceHash = (routeSpace) => canonicalContentHash(routeSpace);
10870
+ var declarativeRouteSpaceRevisionHash = (registration) => canonicalContentHash(registration.routeSpace);
10871
+ var declarativeProductResourceSourceHash = (document) => canonicalContentHash(document);
10872
+ var declarativeProductResourceRevisionHash = (registration) => canonicalContentHash(registration.document);
10873
+ var deepFreeze = (value) => {
10874
+ if (value === null || typeof value !== "object" || Object.isFrozen(value)) return value;
10875
+ Object.values(value).forEach((child) => deepFreeze(child));
10876
+ return Object.freeze(value);
10877
+ };
10878
+ var assertTenantCompatible = (reference, scope, path) => {
10879
+ if (reference.visibility === "tenant" && scopeKey(reference.tenantScope) !== scopeKey(scope)) {
10880
+ throw new DeclarativeControlCompilationError("CROSS_TENANT_REFERENCE", path, `Reference ${reference.kind}/${reference.id} belongs to another tenant scope.`);
10881
+ }
10882
+ };
10883
+ var assertSameTenantScope = (candidate, expected, path) => {
10884
+ if (scopeKey(candidate) !== scopeKey(expected)) {
10885
+ throw new DeclarativeControlCompilationError("CROSS_TENANT_REFERENCE", path, "Record and release tenant scopes do not match.");
10886
+ }
10887
+ };
10888
+ var stableFromRevision = (reference) => StableRefSchema.parse({
10889
+ kind: reference.kind,
10890
+ id: reference.id,
10891
+ ownerRepo: reference.ownerRepo,
10892
+ visibility: reference.visibility,
10893
+ ...reference.tenantScope ? { tenantScope: reference.tenantScope } : {}
10894
+ });
10895
+ var assertRevisionIdentity = (reference, expectedKind, expectedId, scope, path) => {
10896
+ if (reference.kind !== expectedKind || reference.id !== expectedId) {
10897
+ throw new DeclarativeControlCompilationError("REVISION_MISMATCH", path, `Expected ${expectedKind}/${expectedId}, received ${reference.kind}/${reference.id}.`);
10898
+ }
10899
+ assertTenantCompatible(reference, scope, path);
10900
+ };
10901
+ var dependencyKey = (role, reference) => `${role}:${revisionRefKey(reference)}`;
10902
+ var requireDependencies = (snapshot, required) => {
10903
+ const available = new Set(snapshot.map((dependency) => dependencyKey(dependency.role, dependency.revisionRef)));
10904
+ for (const dependency of required) {
10905
+ const key = dependencyKey(dependency.role, dependency.revisionRef);
10906
+ if (!available.has(key)) {
10907
+ throw new DeclarativeControlCompilationError("DEPENDENCY_MISSING", "dependencySnapshot", `Missing exact ${dependency.role} dependency ${revisionRefKey(dependency.revisionRef)}.`);
10908
+ }
10909
+ }
10910
+ };
10911
+ var assertDependencyScopes = (snapshot, scope) => snapshot.forEach((dependency, index) => assertTenantCompatible(dependency.revisionRef, scope, `dependencySnapshot[${index}].revisionRef`));
10912
+ var requireReleaseReady = (release) => {
10913
+ if (release.evidence.validation.result !== "pass") {
10914
+ throw new DeclarativeControlCompilationError("RELEASE_VALIDATION_FAILED", "evidence.validation.result", "Runtime bundles require a passing release validation result.");
10915
+ }
10916
+ };
10917
+ var refSet = (values) => new Set(values.map(stableRefKey));
10918
+ var chainRequiresAll = (policies, field) => {
10919
+ if (field === "permissionAllOf") return new Set(policies.flatMap((policy) => policy.permissionAllOf));
10920
+ if (field === "groupAllOf") return refSet(policies.flatMap((policy) => policy.groupAllOf));
10921
+ return new Set(policies.flatMap((policy) => policy.conditionAllOf.map(revisionRefKey)));
10922
+ };
10923
+ var chainImpliesAny = (policies, targetAny, allValues, anyValues) => {
10924
+ if (targetAny.size === 0) return true;
10925
+ if ([...allValues].some((value) => targetAny.has(value))) return true;
10926
+ return policies.some((policy) => {
10927
+ const values = anyValues(policy);
10928
+ return values.length > 0 && values.every((value) => targetAny.has(value));
10929
+ });
10930
+ };
10931
+ var accessPolicyChainImplies = (policyInputs, targetInput) => {
10932
+ const policies = policyInputs.map((policy) => AccessPolicySchema.parse(policy));
10933
+ const target = AccessPolicySchema.parse(targetInput);
10934
+ if (target.authenticated && !policies.some((policy) => policy.authenticated)) return false;
10935
+ const permissionAll = chainRequiresAll(policies, "permissionAllOf");
10936
+ if (target.permissionAllOf.some((permission) => !permissionAll.has(permission))) return false;
10937
+ if (!chainImpliesAny(policies, new Set(target.permissionAnyOf), permissionAll, (policy) => policy.permissionAnyOf)) return false;
10938
+ const groupAll = chainRequiresAll(policies, "groupAllOf");
10939
+ if (target.groupAllOf.some((group) => !groupAll.has(stableRefKey(group)))) return false;
10940
+ if (!chainImpliesAny(
10941
+ policies,
10942
+ refSet(target.groupAnyOf),
10943
+ groupAll,
10944
+ (policy) => policy.groupAnyOf.map(stableRefKey)
10945
+ )) return false;
10946
+ const conditionAll = chainRequiresAll(policies, "conditionAllOf");
10947
+ if (target.conditionAllOf.some((condition) => !conditionAll.has(revisionRefKey(condition)))) return false;
10948
+ return true;
10949
+ };
10950
+ var normalizePath = (path, routeSpace) => {
10951
+ let normalized = path;
10952
+ if (!routeSpace.caseSensitive) {
10953
+ normalized = normalized.split("/").map((segment) => segment.startsWith(":") ? segment : segment.toLowerCase()).join("/");
10954
+ }
10955
+ if (routeSpace.trailingSlash === "remove" && normalized.length > 1) normalized = normalized.replace(/\/+$/, "");
10956
+ if (routeSpace.trailingSlash === "require" && normalized.length > 1 && !normalized.endsWith("/")) normalized += "/";
10957
+ return normalized;
10958
+ };
10959
+ var compileRouteClaims = (input) => {
10960
+ const registrations = input.routeSpaces.map((entry, index) => {
10961
+ const revisionRef = RevisionRefSchema.parse(entry.revisionRef);
10962
+ const routeSpace = RouteSpaceSchema.parse(entry.routeSpace);
10963
+ if (revisionRef.kind !== "route-space" || revisionRef.id !== routeSpace.routeSpaceId) {
10964
+ throw new DeclarativeControlCompilationError("ROUTE_SPACE_MISMATCH", `routeSpaces[${index}]`, "RouteSpace registration identity does not match its pinned revision.");
10965
+ }
10966
+ return { revisionRef, routeSpace };
10967
+ });
10968
+ assertUniqueRegistryKeys(registrations.map((entry) => revisionRefKey(entry.revisionRef)), "routeSpaces");
10969
+ const routeSpacesByRevision = new Map(registrations.map((entry) => [revisionRefKey(entry.revisionRef), entry.routeSpace]));
10970
+ const normalizedPaths = /* @__PURE__ */ new Set();
10971
+ const compiled = [];
10972
+ input.claims.forEach((inputClaim, index) => {
10973
+ const parsedClaim = "surface" in inputClaim ? RouteClaimSchema.parse(inputClaim) : LegacyRouteClaimSchema.parse(inputClaim);
10974
+ const routeSpace = routeSpacesByRevision.get(revisionRefKey(parsedClaim.routeSpaceRevisionRef));
10975
+ if (!routeSpace) throw new DeclarativeControlCompilationError("ROUTE_SPACE_MISSING", `routeClaims[${index}].routeSpaceRevisionRef`, "No exact RouteSpace registration exists.");
10976
+ const claim = RouteClaimSchema.parse({
10977
+ ...parsedClaim,
10978
+ surface: "surface" in parsedClaim ? parsedClaim.surface : routeSpace.supportedSurface
10979
+ });
10980
+ if (routeSpace.supportedSurface !== claim.surface) {
10981
+ throw new DeclarativeControlCompilationError("ROUTE_SPACE_MISMATCH", `routeClaims[${index}].surface`, `Route claim surface ${claim.surface} does not match RouteSpace ${routeSpace.routeSpaceId}.`);
10982
+ }
10983
+ if (claim.surface !== input.surface) return;
10984
+ const normalizedPath = normalizePath(claim.pathTemplate, routeSpace);
10985
+ const knownParameters = new Set(routeSpace.parameters.map((parameter) => parameter.name));
10986
+ const pathParameters = [...normalizedPath.matchAll(/:([A-Za-z][A-Za-z0-9_-]*)/g)].map((match) => match[1]);
10987
+ if (new Set(pathParameters).size !== pathParameters.length) {
10988
+ throw new DeclarativeControlCompilationError("ROUTE_SPACE_MISMATCH", `routeClaims[${index}].pathTemplate`, "Route parameters must be unique within a path.");
10989
+ }
10990
+ const unknownParameter = pathParameters.find((parameter) => !knownParameters.has(parameter));
10991
+ if (unknownParameter) {
10992
+ throw new DeclarativeControlCompilationError("ROUTE_SPACE_MISMATCH", `routeClaims[${index}].pathTemplate`, `Route parameter ${unknownParameter} is not declared by ${routeSpace.routeSpaceId}.`);
10993
+ }
10994
+ const reserved = routeSpace.reservedPaths.some((candidate) => {
10995
+ const normalizedReserved = normalizePath(candidate, routeSpace);
10996
+ return normalizedPath === normalizedReserved || normalizedPath.startsWith(`${normalizedReserved}/`);
10997
+ });
10998
+ if (reserved) throw new DeclarativeControlCompilationError("ROUTE_RESERVED", `routeClaims[${index}].pathTemplate`, `Route ${normalizedPath} is reserved by ${routeSpace.routeSpaceId}.`);
10999
+ const routeIdentity = `${revisionRefKey(claim.routeSpaceRevisionRef)}:${normalizedPath}`;
11000
+ if (normalizedPaths.has(routeIdentity)) throw new DeclarativeControlCompilationError("ROUTE_CONFLICT", `routeClaims[${index}].pathTemplate`, `Duplicate normalized route ${normalizedPath}.`);
11001
+ normalizedPaths.add(routeIdentity);
11002
+ compiled.push(CompiledRouteClaimSchema.parse({
11003
+ ...claim,
11004
+ normalizedPath,
11005
+ matcher: {
11006
+ surface: claim.surface,
11007
+ caseSensitive: routeSpace.caseSensitive,
11008
+ trailingSlash: routeSpace.trailingSlash,
11009
+ parameters: routeSpace.parameters
11010
+ }
11011
+ }));
11012
+ });
11013
+ if (!compiled.some((claim) => claim.kind === "canonical")) {
11014
+ throw new DeclarativeControlCompilationError("ROUTE_CONFLICT", "routeClaims", "At least one canonical route claim is required.");
11015
+ }
11016
+ return Object.freeze(compiled);
11017
+ };
11018
+ var routeParameterPattern = (type) => {
11019
+ if (type === "integer") return /^-?\d+$/;
11020
+ if (type === "uuid") return /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
11021
+ if (type === "slug") return /^[A-Za-z0-9]+(?:[._-][A-Za-z0-9]+)*$/;
11022
+ return /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
11023
+ };
11024
+ var materializeRouteSpacePath = (input) => {
11025
+ const routeSpace = RouteSpaceSchema.parse(input.routeSpace);
11026
+ const applicationPath = RoutePathTemplateSchema.parse(input.applicationPath);
11027
+ const basePath = routeSpace.basePath === "/" ? "" : routeSpace.basePath.replace(/\/+$/, "");
11028
+ let browserTemplate = normalizePath(`${basePath}${applicationPath === "/" ? "/" : applicationPath}` || "/", routeSpace);
11029
+ const parameters = input.parameters || {};
11030
+ const declared = new Map(routeSpace.parameters.map((parameter) => [parameter.name, parameter]));
11031
+ const referenced = [...browserTemplate.matchAll(/:([A-Za-z][A-Za-z0-9_-]*)/g)].map((match) => match[1]);
11032
+ for (const name of referenced) {
11033
+ const definition = declared.get(name);
11034
+ const raw = parameters[name];
11035
+ if (!definition || raw === void 0 || raw === null || String(raw).trim() === "") {
11036
+ throw new DeclarativeControlCompilationError("ROUTE_SPACE_MISMATCH", "parameters", `Route parameter ${name} is not resolved by ${routeSpace.routeSpaceId}.`);
11037
+ }
11038
+ const value = String(raw);
11039
+ if (!routeParameterPattern(definition.type).test(value)) {
11040
+ throw new DeclarativeControlCompilationError("ROUTE_SPACE_MISMATCH", `parameters.${name}`, `Route parameter ${name} does not satisfy ${definition.type}.`);
11041
+ }
11042
+ browserTemplate = browserTemplate.replace(`:${name}`, encodeURIComponent(value));
11043
+ }
11044
+ const unknown = Object.keys(parameters).find((name) => !declared.has(name));
11045
+ if (unknown) throw new DeclarativeControlCompilationError("ROUTE_SPACE_MISMATCH", `parameters.${unknown}`, `RouteSpace ${routeSpace.routeSpaceId} does not declare ${unknown}.`);
11046
+ return browserTemplate;
11047
+ };
11048
+ var renderTreeDepth = (tree) => {
11049
+ const byId = new Map(tree.nodes.map((node) => [node.nodeId, node]));
11050
+ let maximum = 0;
11051
+ tree.nodes.forEach((node) => {
11052
+ let depth = 1;
11053
+ let parentId = node.parentNodeId;
11054
+ while (parentId) {
11055
+ depth += 1;
11056
+ parentId = byId.get(parentId)?.parentNodeId;
11057
+ }
11058
+ maximum = Math.max(maximum, depth);
11059
+ });
11060
+ return maximum;
11061
+ };
11062
+ var compareLegacyEntityRef = (reference, revision) => reference.kind === revision.kind && reference.id === revision.id && String(reference.version) === String(revision.revision) && reference.ownerRepo === revision.ownerRepo;
11063
+ var pageDependencies = (page, compilerRevisionRef) => [
11064
+ ...page.routeClaims.map((claim) => ({ role: "route-space", revisionRef: claim.routeSpaceRevisionRef })),
11065
+ { role: "shell", revisionRef: page.shellRevisionRef },
11066
+ ...page.capabilityInstances.flatMap((instance) => [
11067
+ { role: "capability", revisionRef: instance.capabilityRevisionRef },
11068
+ { role: "provider", revisionRef: instance.providerRevisionRef },
11069
+ { role: "schema", revisionRef: instance.propertySchemaRevisionRef }
11070
+ ]),
11071
+ ...page.ontologyBindings.flatMap((binding) => [
11072
+ { role: "ontology-definition", revisionRef: binding.ontologyDefinitionRevisionRef },
11073
+ ...binding.viewRevisionRef ? [{ role: "view", revisionRef: binding.viewRevisionRef }] : [],
11074
+ ...binding.projectionRevisionRef ? [{ role: "projection", revisionRef: binding.projectionRevisionRef }] : [],
11075
+ { role: "schema", revisionRef: binding.renderModelSchemaRevisionRef }
11076
+ ]),
11077
+ ...page.actionBindings.flatMap((binding) => [
11078
+ { role: "action", revisionRef: binding.commandRevisionRef },
11079
+ { role: "schema", revisionRef: binding.sourceIntentSchemaRevisionRef },
11080
+ { role: "schema", revisionRef: binding.inputSchemaRevisionRef },
11081
+ { role: "schema", revisionRef: binding.resultSchemaRevisionRef },
11082
+ ...binding.compensationCommandRevisionRef ? [{ role: "action", revisionRef: binding.compensationCommandRevisionRef }] : []
11083
+ ]),
11084
+ ...page.tokenRevisionRefs.map((revisionRef) => ({ role: "token", revisionRef })),
11085
+ { role: "performance-budget", revisionRef: page.performanceBudgetRef },
11086
+ { role: "observation-policy", revisionRef: page.observationPolicyRevisionRef },
11087
+ { role: "compiler", revisionRef: compilerRevisionRef }
11088
+ ];
11089
+ var compilePageRuntimeBundle = (input) => {
11090
+ const page = PageSchema.parse(input.page);
11091
+ const pageRevisionRef = RevisionRefSchema.parse(input.pageRevisionRef);
11092
+ const release = PageReleaseSchema.parse(input.release);
11093
+ const releaseRevisionRef = RevisionRefSchema.parse(input.releaseRevisionRef);
11094
+ const compilerRevisionRef = RevisionRefSchema.parse(input.compilerRevisionRef);
11095
+ const scope = TenantScopeSchema.parse(page.tenantScope);
11096
+ assertSameTenantScope(release.tenantScope, scope, "release.tenantScope");
11097
+ assertRevisionIdentity(pageRevisionRef, "page", page.pageId, scope, "pageRevisionRef");
11098
+ assertRevisionIdentity(release.pageRevisionRef, "page", page.pageId, scope, "release.pageRevisionRef");
11099
+ if (!sameRevisionRef(pageRevisionRef, release.pageRevisionRef)) throw new DeclarativeControlCompilationError("REVISION_MISMATCH", "release.pageRevisionRef", "Release does not pin the supplied Page revision.");
11100
+ assertRevisionIdentity(releaseRevisionRef, "page-release", release.releaseSlotId, scope, "releaseRevisionRef");
11101
+ requireReleaseReady(release);
11102
+ requireDependencies(release.dependencySnapshot, pageDependencies(page, compilerRevisionRef));
11103
+ assertDependencyScopes(release.dependencySnapshot, scope);
11104
+ if (page.renderTree.nodes.length > input.limits.maxRenderNodes) throw new DeclarativeControlCompilationError("RENDER_NODE_LIMIT_EXCEEDED", "page.renderTree.nodes", "RenderTree exceeds the caller-approved node limit.");
11105
+ if (renderTreeDepth(page.renderTree) > input.limits.maxRenderDepth) throw new DeclarativeControlCompilationError("RENDER_DEPTH_EXCEEDED", "page.renderTree.nodes", "RenderTree exceeds the caller-approved depth limit.");
11106
+ const renderTree = compileRenderTree(page.renderTree).tree;
11107
+ const instancesByNode = new Map(page.capabilityInstances.map((instance) => [instance.nodeId, instance]));
11108
+ const registrations = input.capabilityRegistry.map((registration, registrationIndex) => ({
11109
+ ...registration,
11110
+ capabilityRevisionRef: RevisionRefSchema.parse(registration.capabilityRevisionRef),
11111
+ providerRevisionRef: RevisionRefSchema.parse(registration.providerRevisionRef),
11112
+ inputPorts: registration.inputPorts.map((port, portIndex) => {
11113
+ const schemaRevisionRef = RevisionRefSchema.parse(port.schemaRevisionRef);
11114
+ if (schemaRevisionRef.kind !== "schema") {
11115
+ throw new DeclarativeControlCompilationError("PORT_TYPE_MISMATCH", `capabilityRegistry[${registrationIndex}].inputPorts[${portIndex}].schemaRevisionRef`, "Capability ports must pin schema revisions.");
11116
+ }
11117
+ return { ...port, schemaRevisionRef };
11118
+ }),
11119
+ outputPorts: registration.outputPorts.map((port, portIndex) => {
11120
+ const schemaRevisionRef = RevisionRefSchema.parse(port.schemaRevisionRef);
11121
+ if (schemaRevisionRef.kind !== "schema") {
11122
+ throw new DeclarativeControlCompilationError("PORT_TYPE_MISMATCH", `capabilityRegistry[${registrationIndex}].outputPorts[${portIndex}].schemaRevisionRef`, "Capability ports must pin schema revisions.");
11123
+ }
11124
+ return { ...port, schemaRevisionRef };
11125
+ })
11126
+ }));
11127
+ assertUniqueRegistryKeys(registrations.map((registration) => `${revisionRefKey(registration.capabilityRevisionRef)}:${revisionRefKey(registration.providerRevisionRef)}`), "capabilityRegistry");
11128
+ const registrationsByPair = new Map(registrations.map((registration) => [
11129
+ `${revisionRefKey(registration.capabilityRevisionRef)}:${revisionRefKey(registration.providerRevisionRef)}`,
11130
+ registration
11131
+ ]));
11132
+ page.capabilityInstances.forEach((instance, index) => {
11133
+ const node = renderTree.nodes.find((candidate) => candidate.nodeId === instance.nodeId);
11134
+ if (!node || !compareLegacyEntityRef(node.capabilityRef, instance.capabilityRevisionRef) || !node.providerRef || !compareLegacyEntityRef(node.providerRef, instance.providerRevisionRef) || node.pageRef.id !== page.pageId) {
11135
+ throw new DeclarativeControlCompilationError("CAPABILITY_BINDING_MISMATCH", `capabilityInstances[${index}]`, "RenderTree node identity does not match the declared capability/provider instance.");
11136
+ }
11137
+ const registration = registrationsByPair.get(`${revisionRefKey(instance.capabilityRevisionRef)}:${revisionRefKey(instance.providerRevisionRef)}`);
11138
+ if (!registration?.editorEligible) {
11139
+ throw new DeclarativeControlCompilationError("CAPABILITY_NOT_EDITOR_ELIGIBLE", `capabilityInstances[${index}]`, "Capability/provider pair is not editor-eligible.");
11140
+ }
11141
+ if (instance.allowedSideEffects.some((sideEffect) => !registration.allowedSideEffects.includes(sideEffect))) {
11142
+ throw new DeclarativeControlCompilationError("CAPABILITY_BINDING_MISMATCH", `capabilityInstances[${index}].allowedSideEffects`, "Page requests undeclared provider side effects.");
11143
+ }
11144
+ });
11145
+ page.ontologyBindings.forEach((binding, index) => {
11146
+ const instance = page.capabilityInstances.find((candidate) => candidate.instanceId === binding.target.capabilityInstanceId);
11147
+ const registration = instance && registrationsByPair.get(`${revisionRefKey(instance.capabilityRevisionRef)}:${revisionRefKey(instance.providerRevisionRef)}`);
11148
+ const port = registration?.inputPorts.find((candidate) => candidate.name === binding.target.port);
11149
+ if (!port || !sameRevisionRef(port.schemaRevisionRef, binding.renderModelSchemaRevisionRef)) {
11150
+ throw new DeclarativeControlCompilationError("PORT_TYPE_MISMATCH", `ontologyBindings[${index}].target.port`, "Ontology render model does not match the registered capability input port.");
11151
+ }
11152
+ });
11153
+ page.actionBindings.forEach((binding, index) => {
11154
+ const instance = page.capabilityInstances.find((candidate) => candidate.instanceId === binding.source.capabilityInstanceId);
11155
+ const registration = instance && registrationsByPair.get(`${revisionRefKey(instance.capabilityRevisionRef)}:${revisionRefKey(instance.providerRevisionRef)}`);
11156
+ const port = registration?.outputPorts.find((candidate) => candidate.name === binding.source.port);
11157
+ if (!port || !sameRevisionRef(port.schemaRevisionRef, binding.sourceIntentSchemaRevisionRef)) {
11158
+ throw new DeclarativeControlCompilationError("PORT_TYPE_MISMATCH", `actionBindings[${index}].sourceIntentSchemaRevisionRef`, "Action source intent does not match the registered capability output port.");
11159
+ }
11160
+ });
11161
+ const routeClaims = compileRouteClaims({ claims: page.routeClaims, routeSpaces: input.routeSpaces, surface: release.target.surface });
11162
+ const releaseRoute = routeClaims.find((claim) => claim.kind === "canonical" && claim.normalizedPath === release.target.normalizedPath);
11163
+ if (!releaseRoute || !sameRevisionRef(releaseRoute.routeSpaceRevisionRef, release.target.routeSpaceRevisionRef)) {
11164
+ throw new DeclarativeControlCompilationError("ROUTE_SPACE_MISMATCH", "release.target", "Release target does not match a canonical Page route claim.");
11165
+ }
11166
+ if (!page.supportedSurfaces.includes(release.target.surface)) {
11167
+ throw new DeclarativeControlCompilationError("ROUTE_SPACE_MISMATCH", "release.target.surface", "Page does not support the release surface.");
11168
+ }
11169
+ const unsigned = {
11170
+ contract: "PageRuntimeBundle",
11171
+ schemaVersion: 1,
11172
+ tenantScope: scope,
11173
+ releaseRevisionRef,
11174
+ compilerRevisionRef,
11175
+ generation: input.generation,
11176
+ dependencySnapshot: release.dependencySnapshot,
11177
+ rebuildable: true,
11178
+ diagnostics: [],
11179
+ pageId: page.pageId,
11180
+ pageRevisionRef,
11181
+ surface: release.target.surface,
11182
+ routeClaims,
11183
+ shellRevisionRef: page.shellRevisionRef,
11184
+ renderTree,
11185
+ capabilityInstances: page.capabilityInstances,
11186
+ ontologyBindings: page.ontologyBindings,
11187
+ actionBindings: page.actionBindings,
11188
+ pageAccessPolicy: page.pageAccessPolicy,
11189
+ tokenRevisionRefs: page.tokenRevisionRefs,
11190
+ performanceBudgetRef: page.performanceBudgetRef,
11191
+ observationPolicyRevisionRef: page.observationPolicyRevisionRef,
11192
+ privacyClassification: page.privacyClassification
11193
+ };
11194
+ return deepFreeze(PageRuntimeBundleSchema.parse({ ...unsigned, contentHash: canonicalContentHash(unsigned) }));
11195
+ };
11196
+ var workbenchDependencyRole = (kind) => {
11197
+ switch (kind) {
11198
+ case "workflow":
11199
+ return "workflow";
11200
+ case "agent":
11201
+ return "agent";
11202
+ case "capability":
11203
+ return "capability";
11204
+ case "design":
11205
+ return "design";
11206
+ case "built-in-application":
11207
+ return "built-in-application";
11208
+ default:
11209
+ return "workflow";
11210
+ }
11211
+ };
11212
+ var workbenchDependencies = (workbench, compilerRevisionRef) => [
11213
+ ...workbench.routeClaims.map((claim) => ({ role: "route-space", revisionRef: claim.routeSpaceRevisionRef })),
11214
+ ...workbench.appInstances.flatMap((instance) => [
11215
+ { role: workbenchDependencyRole(instance.targetRevisionRef.kind), revisionRef: instance.targetRevisionRef },
11216
+ { role: "provider", revisionRef: instance.providerRevisionRef },
11217
+ { role: "schema", revisionRef: instance.inputSchemaRevisionRef }
11218
+ ]),
11219
+ { role: "capability", revisionRef: workbench.layout.hostCapabilityRevisionRef },
11220
+ { role: "provider", revisionRef: workbench.layout.hostProviderRevisionRef },
11221
+ { role: "layout-policy", revisionRef: workbench.layout.layoutPolicyRevisionRef },
11222
+ ...workbench.layout.tokenRevisionRefs.map((revisionRef) => ({ role: "token", revisionRef })),
11223
+ { role: "performance-budget", revisionRef: workbench.performanceBudgetRef },
11224
+ { role: "observation-policy", revisionRef: workbench.observationPolicyRevisionRef },
11225
+ { role: "compiler", revisionRef: compilerRevisionRef }
11226
+ ];
11227
+ var compileWorkbenchRuntimeBundle = (input) => {
11228
+ const workbench = WorkbenchSchema.parse(input.workbench);
11229
+ const workbenchRevisionRef = RevisionRefSchema.parse(input.workbenchRevisionRef);
11230
+ const release = WorkbenchReleaseSchema.parse(input.release);
11231
+ const releaseRevisionRef = RevisionRefSchema.parse(input.releaseRevisionRef);
11232
+ const compilerRevisionRef = RevisionRefSchema.parse(input.compilerRevisionRef);
11233
+ const scope = TenantScopeSchema.parse(workbench.tenantScope);
11234
+ assertSameTenantScope(release.tenantScope, scope, "release.tenantScope");
11235
+ if (workbench.purpose === "template") throw new DeclarativeControlCompilationError("WORKBENCH_TEMPLATE_UNRELEASABLE", "workbench.purpose", "Workbench templates cannot be activated.");
11236
+ if (workbench.groups.length > input.limits.maxWorkbenchGroups || workbench.appInstances.length > input.limits.maxWorkbenchInstances) {
11237
+ throw new DeclarativeControlCompilationError("WORKBENCH_INSTANCE_LIMIT_EXCEEDED", "workbench", "Workbench exceeds caller-approved compilation limits.");
11238
+ }
11239
+ assertRevisionIdentity(workbenchRevisionRef, "workbench", workbench.workbenchId, scope, "workbenchRevisionRef");
11240
+ assertRevisionIdentity(release.workbenchRevisionRef, "workbench", workbench.workbenchId, scope, "release.workbenchRevisionRef");
11241
+ if (!sameRevisionRef(workbenchRevisionRef, release.workbenchRevisionRef)) throw new DeclarativeControlCompilationError("REVISION_MISMATCH", "release.workbenchRevisionRef", "Release does not pin the supplied Workbench revision.");
11242
+ assertRevisionIdentity(releaseRevisionRef, "workbench-release", release.releaseSlotId, scope, "releaseRevisionRef");
11243
+ if (release.target.workbenchId !== workbench.workbenchId) throw new DeclarativeControlCompilationError("REVISION_MISMATCH", "release.target.workbenchId", "Release target does not match Workbench identity.");
11244
+ requireReleaseReady(release);
11245
+ requireDependencies(release.dependencySnapshot, workbenchDependencies(workbench, compilerRevisionRef));
11246
+ assertDependencyScopes(release.dependencySnapshot, scope);
11247
+ const routeClaims = compileRouteClaims({ claims: workbench.routeClaims, routeSpaces: input.routeSpaces, surface: release.target.surface });
11248
+ const releaseRoute = routeClaims.find((claim) => claim.kind === "canonical" && claim.normalizedPath === release.target.normalizedPath);
11249
+ if (!releaseRoute || !sameRevisionRef(releaseRoute.routeSpaceRevisionRef, release.target.routeSpaceRevisionRef)) {
11250
+ throw new DeclarativeControlCompilationError("ROUTE_SPACE_MISMATCH", "release.target", "Release target does not match a canonical Workbench route claim.");
11251
+ }
11252
+ const targetRegistry = input.targetRegistry.map((registration) => ({
11253
+ stableTargetRef: StableRefSchema.parse(registration.stableTargetRef),
11254
+ targetRevisionRef: RevisionRefSchema.parse(registration.targetRevisionRef),
11255
+ accessPolicy: AccessPolicySchema.parse(registration.accessPolicy)
11256
+ }));
11257
+ assertUniqueRegistryKeys(targetRegistry.map((registration) => stableRefKey(registration.stableTargetRef)), "targetRegistry");
11258
+ const targetsByStableRef = new Map(targetRegistry.map((registration) => [stableRefKey(registration.stableTargetRef), registration]));
11259
+ const groupsById = new Map(workbench.groups.map((group) => [group.groupId, group]));
11260
+ const appInstances = workbench.appInstances.map((instance, index) => {
11261
+ const stableTarget = StableRefSchema.parse({
11262
+ kind: instance.targetRevisionRef.kind,
11263
+ id: instance.targetRevisionRef.id,
11264
+ ownerRepo: instance.targetRevisionRef.ownerRepo,
11265
+ visibility: instance.targetRevisionRef.visibility,
11266
+ ...instance.targetRevisionRef.tenantScope ? { tenantScope: instance.targetRevisionRef.tenantScope } : {}
11267
+ });
11268
+ const registration = targetsByStableRef.get(stableRefKey(stableTarget));
11269
+ if (!registration || !sameStableRef(registration.stableTargetRef, stableFromRevision(registration.targetRevisionRef)) || !sameRevisionRef(registration.targetRevisionRef, instance.targetRevisionRef)) {
11270
+ throw new DeclarativeControlCompilationError("NAV_TARGET_UNRELEASED", `appInstances[${index}].targetRevisionRef`, "Workbench app target is not present at the exact registered revision.");
11271
+ }
11272
+ assertTenantCompatible(instance.targetRevisionRef, scope, `appInstances[${index}].targetRevisionRef`);
11273
+ const group = groupsById.get(instance.groupId);
11274
+ const chain = [workbench.workbenchAccessPolicy, ...group?.accessPolicy ? [group.accessPolicy] : [], instance.accessPolicy];
11275
+ if (!accessPolicyChainImplies(chain, registration.accessPolicy)) {
11276
+ throw new DeclarativeControlCompilationError("AUDIENCE_WIDER_THAN_TARGET", `appInstances[${index}].accessPolicy`, "Workbench and instance audience is wider than the target audience.");
11277
+ }
11278
+ return { ...instance, targetAccessPolicy: registration.accessPolicy };
11279
+ });
11280
+ const unsigned = {
11281
+ contract: "WorkbenchRuntimeBundle",
11282
+ schemaVersion: 1,
11283
+ tenantScope: scope,
11284
+ releaseRevisionRef,
11285
+ compilerRevisionRef,
11286
+ generation: input.generation,
11287
+ dependencySnapshot: release.dependencySnapshot,
11288
+ rebuildable: true,
11289
+ diagnostics: [],
11290
+ workbenchId: workbench.workbenchId,
11291
+ workbenchRevisionRef,
11292
+ surface: release.target.surface,
11293
+ routeClaims,
11294
+ groups: workbench.groups,
11295
+ appInstances,
11296
+ defaultEntry: workbench.defaultEntry,
11297
+ layout: workbench.layout,
11298
+ workbenchAccessPolicy: workbench.workbenchAccessPolicy,
11299
+ personalPreferencesPolicy: workbench.personalPreferencesPolicy,
11300
+ target: { ...release.target, routeClaim: releaseRoute },
11301
+ performanceBudgetRef: workbench.performanceBudgetRef,
11302
+ observationPolicyRevisionRef: workbench.observationPolicyRevisionRef,
11303
+ privacyClassification: workbench.privacyClassification
11304
+ };
11305
+ return deepFreeze(WorkbenchRuntimeBundleSchema.parse({ ...unsigned, contentHash: canonicalContentHash(unsigned) }));
11306
+ };
11307
+ var navigationDepth = (navigation) => {
11308
+ const byId = new Map(navigation.nodes.map((node) => [node.nodeId, node]));
11309
+ let maximum = 0;
11310
+ navigation.nodes.forEach((node) => {
11311
+ let depth = 1;
11312
+ let parentId = node.parentNodeId;
11313
+ while (parentId) {
11314
+ depth += 1;
11315
+ parentId = byId.get(parentId)?.parentNodeId ?? null;
11316
+ }
11317
+ maximum = Math.max(maximum, depth);
11318
+ });
11319
+ return maximum;
11320
+ };
11321
+ var orderedNavigationNodes = (navigation) => {
11322
+ const children = /* @__PURE__ */ new Map();
11323
+ navigation.nodes.forEach((node) => {
11324
+ const parent = node.parentNodeId ?? "";
11325
+ const siblings = children.get(parent) ?? [];
11326
+ children.set(parent, [...siblings, node]);
11327
+ });
11328
+ children.forEach((siblings) => siblings.sort((left, right) => left.order - right.order || left.nodeId.localeCompare(right.nodeId)));
11329
+ const ordered = [];
11330
+ const append = (parentId) => {
11331
+ for (const node of children.get(parentId) ?? []) {
11332
+ ordered.push(node);
11333
+ append(node.nodeId);
11334
+ }
11335
+ };
11336
+ append("");
11337
+ return ordered;
11338
+ };
11339
+ var navigationDependencies = (navigation, release, compilerRevisionRef) => [
11340
+ ...release.resolvedTargets.flatMap((target) => [
11341
+ { role: target.targetRevisionRef.kind === "domain-command" ? "action" : target.targetRevisionRef.kind, revisionRef: target.targetRevisionRef },
11342
+ ...target.releaseRevisionRef ? [{ role: target.releaseRevisionRef.kind, revisionRef: target.releaseRevisionRef }] : []
11343
+ ]),
11344
+ { role: "performance-budget", revisionRef: navigation.performanceBudgetRef },
11345
+ { role: "observation-policy", revisionRef: navigation.observationPolicyRevisionRef },
11346
+ { role: "compiler", revisionRef: compilerRevisionRef }
11347
+ ];
11348
+ var compileNavigationRuntimeBundle = (input) => {
11349
+ const navigation = NavigationSchema.parse(input.navigation);
11350
+ const navigationRevisionRef = RevisionRefSchema.parse(input.navigationRevisionRef);
11351
+ const release = NavigationReleaseSchema.parse(input.release);
11352
+ const releaseRevisionRef = RevisionRefSchema.parse(input.releaseRevisionRef);
11353
+ const compilerRevisionRef = RevisionRefSchema.parse(input.compilerRevisionRef);
11354
+ const scope = TenantScopeSchema.parse(navigation.tenantScope);
11355
+ assertSameTenantScope(release.tenantScope, scope, "release.tenantScope");
11356
+ if (navigation.nodes.length > input.limits.maxNavigationNodes) throw new DeclarativeControlCompilationError("NAV_NODE_LIMIT_EXCEEDED", "navigation.nodes", "Navigation exceeds the caller-approved node limit.");
11357
+ if (navigationDepth(navigation) > input.limits.maxNavigationDepth) throw new DeclarativeControlCompilationError("NAV_DEPTH_EXCEEDED", "navigation.nodes", "Navigation exceeds the caller-approved depth limit.");
11358
+ assertRevisionIdentity(navigationRevisionRef, "navigation", navigation.navigationId, scope, "navigationRevisionRef");
11359
+ assertRevisionIdentity(release.navigationRevisionRef, "navigation", navigation.navigationId, scope, "release.navigationRevisionRef");
11360
+ if (!sameRevisionRef(navigationRevisionRef, release.navigationRevisionRef)) throw new DeclarativeControlCompilationError("REVISION_MISMATCH", "release.navigationRevisionRef", "Release does not pin the supplied Navigation revision.");
11361
+ assertRevisionIdentity(releaseRevisionRef, "navigation-release", release.releaseSlotId, scope, "releaseRevisionRef");
11362
+ if (release.target.surface !== navigation.supportedSurfaces.find((surface) => surface === release.target.surface) || !navigation.placements.includes(release.target.placement)) {
11363
+ throw new DeclarativeControlCompilationError("REVISION_MISMATCH", "release.target", "Navigation release target is not declared by the Navigation record.");
11364
+ }
11365
+ requireReleaseReady(release);
11366
+ requireDependencies(release.dependencySnapshot, navigationDependencies(navigation, release, compilerRevisionRef));
11367
+ assertDependencyScopes(release.dependencySnapshot, scope);
11368
+ const targetRegistry = input.targetRegistry.map((registration, index) => {
11369
+ const common = {
11370
+ stableTargetRef: StableRefSchema.parse(registration.stableTargetRef),
11371
+ targetRevisionRef: RevisionRefSchema.parse(registration.targetRevisionRef),
11372
+ surface: ProductSurfaceSchema.parse(registration.surface),
11373
+ accessPolicy: AccessPolicySchema.parse(registration.accessPolicy)
11374
+ };
11375
+ if (registration.kind === "route") {
11376
+ const routeClaim = CompiledRouteClaimSchema.parse(registration.routeClaim);
11377
+ if (routeClaim.surface !== common.surface) {
11378
+ throw new DeclarativeControlCompilationError("ROUTE_SPACE_MISMATCH", `targetRegistry[${index}].routeClaim.surface`, "Navigation route claim must match its registered surface.");
11379
+ }
11380
+ return {
11381
+ ...common,
11382
+ kind: "route",
11383
+ releaseRevisionRef: registration.releaseRevisionRef ? RevisionRefSchema.parse(registration.releaseRevisionRef) : void 0,
11384
+ routeClaim
11385
+ };
11386
+ }
11387
+ if (registration.kind === "registered-menu-action") {
11388
+ const sourceCatalogRevisionRef = RevisionRefSchema.parse(registration.sourceCatalogRevisionRef);
11389
+ if (sourceCatalogRevisionRef.kind !== "application-menu-catalog" || registration.targetRevisionRef.kind !== "menu-action") {
11390
+ throw new DeclarativeControlCompilationError("NAV_TARGET_UNRELEASED", "targetRegistry", "Registered Menu Actions require exact menu-action and application-menu-catalog revisions.");
11391
+ }
11392
+ if (registration.inputSchemaRef && !registration.validateInput) {
11393
+ throw new DeclarativeControlCompilationError("NAV_TARGET_UNRELEASED", "targetRegistry", "Registered Menu Actions with input schemas require the active catalog validator.");
11394
+ }
11395
+ return { ...common, kind: "registered-menu-action", applicationId: registration.applicationId, actionRef: registration.actionRef, inputSchemaRef: registration.inputSchemaRef, validateInput: registration.validateInput, sourceCatalogRevisionRef };
11396
+ }
11397
+ if (registration.targetRevisionRef.kind !== "domain-command") {
11398
+ throw new DeclarativeControlCompilationError("NAV_TARGET_UNRELEASED", "targetRegistry", "Governed DomainCommand actions require an exact domain-command revision.");
9558
11399
  }
9559
- for (const capabilityId of concept.capabilityIds) {
9560
- if (!capabilitiesById.has(capabilityId)) throw new Error(`Concept ${concept.conceptId} references unknown capability ${capabilityId}.`);
9561
- addEdge(ref("concept", concept.conceptId), ref("capability", capabilityId), "uses-capability");
11400
+ const inputSchemaRevisionRef = RevisionRefSchema.parse(registration.inputSchemaRevisionRef);
11401
+ const resultSchemaRevisionRef = registration.resultSchemaRevisionRef ? RevisionRefSchema.parse(registration.resultSchemaRevisionRef) : void 0;
11402
+ if (inputSchemaRevisionRef.kind !== "schema" || resultSchemaRevisionRef && resultSchemaRevisionRef.kind !== "schema") {
11403
+ throw new DeclarativeControlCompilationError("NAV_TARGET_UNRELEASED", "targetRegistry", "Governed DomainCommand actions require exact input and output Schema revisions.");
9562
11404
  }
9563
- for (const commandName of concept.commandNames) {
9564
- if (!commandsByName.has(commandName)) throw new Error(`Concept ${concept.conceptId} references unknown command ${commandName}.`);
9565
- addEdge(ref("concept", concept.conceptId), ref("command", commandName), "uses-command");
11405
+ return { ...common, kind: "governed-domain-command", inputSchemaRevisionRef, resultSchemaRevisionRef };
11406
+ });
11407
+ assertUniqueRegistryKeys(targetRegistry.map((registration) => stableRefKey(registration.stableTargetRef)), "targetRegistry");
11408
+ const targetsByStableRef = new Map(targetRegistry.map((registration) => [stableRefKey(registration.stableTargetRef), registration]));
11409
+ const releasedByNodeId = new Map(release.resolvedTargets.map((target) => [target.nodeId, target]));
11410
+ const nodesById = new Map(navigation.nodes.map((node) => [node.nodeId, node]));
11411
+ const nodes = orderedNavigationNodes(navigation).map((node, index) => {
11412
+ const ancestors = [];
11413
+ let parentId = node.parentNodeId;
11414
+ while (parentId) {
11415
+ const parent = nodesById.get(parentId);
11416
+ if (parent?.kind === "group") ancestors.unshift(parent.audience);
11417
+ parentId = parent?.parentNodeId ?? null;
9566
11418
  }
9567
- for (const relationship of concept.relationships) {
9568
- if (!conceptsById.has(relationship.targetConceptId)) {
9569
- throw new Error(`Concept ${concept.conceptId} references unknown concept ${relationship.targetConceptId}.`);
9570
- }
9571
- addEdge(ref("concept", concept.conceptId), ref("concept", relationship.targetConceptId), "relates-to-concept");
11419
+ if (node.kind !== "target") return { ...node, ancestorAccessPolicies: ancestors };
11420
+ if (!["page", "workbench", "menu-action", "domain-command"].includes(node.targetRef.kind)) {
11421
+ throw new DeclarativeControlCompilationError("NAV_TARGET_UNRELEASED", `nodes[${index}].targetRef.kind`, "Navigation targets may reference only Page, Workbench, registered Menu Action, or DomainCommand identities.");
9572
11422
  }
9573
- }
9574
- for (const page of declaration.pages) {
9575
- addNode("page", page.pageId);
9576
- if (page.binding.ontologyId) {
9577
- if (!ontologiesById.has(page.binding.ontologyId)) throw new Error(`Page ${page.pageId} references unknown ontology ${page.binding.ontologyId}.`);
9578
- addEdge(ref("page", page.pageId), ref("ontology", page.binding.ontologyId), "uses-ontology");
11423
+ const registration = targetsByStableRef.get(stableRefKey(node.targetRef));
11424
+ const released = releasedByNodeId.get(node.nodeId);
11425
+ if (!registration || !released || !sameStableRef(registration.stableTargetRef, stableFromRevision(registration.targetRevisionRef)) || !sameStableRef(registration.stableTargetRef, released.stableTargetRef) || !sameRevisionRef(registration.targetRevisionRef, released.targetRevisionRef) || registration.kind === "route" && (Boolean(registration.releaseRevisionRef) !== Boolean(released.releaseRevisionRef) || registration.releaseRevisionRef && released.releaseRevisionRef && !sameRevisionRef(registration.releaseRevisionRef, released.releaseRevisionRef))) {
11426
+ throw new DeclarativeControlCompilationError("NAV_TARGET_UNRELEASED", `nodes[${index}].targetRef`, "Navigation target is not resolved to the exact active release recorded by NavigationRelease.");
9579
11427
  }
9580
- if (page.binding.projectionRef) {
9581
- if (!projectionsById.has(page.binding.projectionRef)) throw new Error(`Page ${page.pageId} references unknown projection ${page.binding.projectionRef}.`);
9582
- addEdge(ref("page", page.pageId), ref("projection", page.binding.projectionRef), "uses-projection");
11428
+ if (registration.surface !== release.target.surface) {
11429
+ throw new DeclarativeControlCompilationError("NAV_TARGET_UNRELEASED", `nodes[${index}].targetRef`, "Navigation target is active on another surface.");
9583
11430
  }
9584
- for (const capabilityRef of [page.capabilityRef, ...page.capabilityRefs].filter(Boolean)) {
9585
- if (!capabilitiesById.has(capabilityRef.id)) throw new Error(`Page ${page.pageId} references unknown capability ${capabilityRef.id}.`);
9586
- addEdge(ref("page", page.pageId), ref("capability", capabilityRef.id), "uses-capability");
11431
+ assertTenantCompatible(registration.targetRevisionRef, scope, `nodes[${index}].targetRef`);
11432
+ if (!accessPolicyChainImplies([...ancestors, node.audience], registration.accessPolicy)) {
11433
+ throw new DeclarativeControlCompilationError("AUDIENCE_WIDER_THAN_TARGET", `nodes[${index}].audience`, "Effective Navigation audience is wider than the target audience.");
9587
11434
  }
9588
- }
9589
- uniqueIndex(nodes, refKey, "declaration node");
9590
- return Object.freeze({
9591
- declaration: Object.freeze(declaration),
9592
- conceptsById,
9593
- ontologiesById,
9594
- projectionsById,
9595
- commandsByName,
9596
- capabilitiesById,
9597
- pagesById,
9598
- menusByKey,
9599
- nodes: Object.freeze(nodes),
9600
- edges: Object.freeze(edges)
9601
- });
9602
- };
9603
- var validateDomainCommand = (input, definitions, permissionCodes) => {
9604
- const command = DomainCommandSchema.parse(input);
9605
- const commandsByName = uniqueIndex(
9606
- definitions.map((definition2) => DomainCommandDefinitionSchema.parse(definition2)),
9607
- (definition2) => definition2.commandName,
9608
- "command name"
9609
- );
9610
- const definition = commandsByName.get(command.commandName);
9611
- if (!definition) throw new Error(`Unknown domain command: ${command.commandName}`);
9612
- if (!definition.targetKinds.includes(command.targetRef.kind)) {
9613
- throw new Error(`Command ${command.commandName} does not accept target kind ${command.targetRef.kind}.`);
9614
- }
9615
- const granted = new Set(permissionCodes);
9616
- const missing = definition.requiredPermissionCodes.filter((permission) => !granted.has(permission));
9617
- if (missing.length) throw new Error(`Command ${command.commandName} requires permissions: ${missing.join(", ")}`);
9618
- return Object.freeze(command);
9619
- };
9620
- var declarationValuesByRef = (compiled) => {
9621
- const values = /* @__PURE__ */ new Map();
9622
- for (const value of compiled.declaration.ontologies) values.set(refKey(ref("ontology", value.ontologyId)), value);
9623
- for (const value of compiled.declaration.projections) values.set(refKey(ref("projection", value.projectionId)), value);
9624
- for (const value of compiled.declaration.commands) values.set(refKey(ref("command", value.commandName)), value);
9625
- for (const value of compiled.declaration.capabilities) values.set(refKey(ref("capability", value.id)), value);
9626
- for (const value of compiled.declaration.concepts) values.set(refKey(ref("concept", value.conceptId)), value);
9627
- for (const value of compiled.declaration.pages) values.set(refKey(ref("page", value.pageId)), value);
9628
- return values;
9629
- };
9630
- var buildChangeImpactGraph = (previousInput, nextInput, generatedAt = (/* @__PURE__ */ new Date()).toISOString()) => {
9631
- const previous = compileProductDeclaration(previousInput);
9632
- const next = compileProductDeclaration(nextInput);
9633
- const previousValues = declarationValuesByRef(previous);
9634
- const nextValues = declarationValuesByRef(next);
9635
- const changedKeys = /* @__PURE__ */ new Set();
9636
- for (const key of /* @__PURE__ */ new Set([...previousValues.keys(), ...nextValues.keys()])) {
9637
- if (JSON.stringify(previousValues.get(key)) !== JSON.stringify(nextValues.get(key))) changedKeys.add(key);
9638
- }
9639
- const reverse = /* @__PURE__ */ new Map();
9640
- for (const edge of [...previous.edges, ...next.edges]) {
9641
- const dependency = refKey(edge.to);
9642
- const dependent = refKey(edge.from);
9643
- const values = reverse.get(dependency) ?? /* @__PURE__ */ new Set();
9644
- values.add(dependent);
9645
- reverse.set(dependency, values);
9646
- }
9647
- const refs = /* @__PURE__ */ new Map();
9648
- for (const node of [...previous.nodes, ...next.nodes]) refs.set(refKey(node), node);
9649
- const impacts = Array.from(changedKeys).sort().map((changedKey) => {
9650
- const affected = /* @__PURE__ */ new Set();
9651
- const queue = [...reverse.get(changedKey) ?? []];
9652
- while (queue.length) {
9653
- const current = queue.shift();
9654
- if (affected.has(current)) continue;
9655
- affected.add(current);
9656
- queue.push(...reverse.get(current) ?? []);
11435
+ const mappedInput = Object.fromEntries(Object.entries(node.parameterMapping).map(([name, source]) => {
11436
+ if (source.kind !== "constant") {
11437
+ throw new DeclarativeControlCompilationError("NAV_TARGET_UNRELEASED", `nodes[${index}].parameterMapping.${name}`, "Navigation actions accept only publication-time constant input.");
11438
+ }
11439
+ return [name, source.value];
11440
+ }));
11441
+ let resolvedTarget;
11442
+ if (registration.kind === "route") {
11443
+ resolvedTarget = { ...released, kind: "route", accessPolicy: registration.accessPolicy, routeClaim: registration.routeClaim };
11444
+ } else if (registration.kind === "registered-menu-action") {
11445
+ if (!registration.inputSchemaRef && Object.keys(mappedInput).length > 0) {
11446
+ throw new DeclarativeControlCompilationError("NAV_TARGET_UNRELEASED", `nodes[${index}].parameterMapping`, "The registered Menu Action does not accept input.");
11447
+ }
11448
+ let input2;
11449
+ try {
11450
+ input2 = JsonObjectSchema.parse(registration.validateInput ? registration.validateInput(mappedInput) : mappedInput);
11451
+ } catch (error) {
11452
+ throw new DeclarativeControlCompilationError(
11453
+ "NAV_ACTION_INPUT_INVALID",
11454
+ `nodes[${index}].parameterMapping`,
11455
+ `Registered Menu Action input failed its active catalog schema: ${error instanceof Error ? error.message : String(error)}`
11456
+ );
11457
+ }
11458
+ const sourceDependency = release.dependencySnapshot.find((dependency) => dependency.role === "application-menu-catalog" && sameRevisionRef(dependency.revisionRef, registration.sourceCatalogRevisionRef));
11459
+ if (!sourceDependency) throw new DeclarativeControlCompilationError("DEPENDENCY_MISSING", `nodes[${index}].targetRef`, "Registered Menu Action source catalog is not pinned by NavigationRelease.");
11460
+ resolvedTarget = {
11461
+ ...released,
11462
+ kind: "registered-menu-action",
11463
+ accessPolicy: registration.accessPolicy,
11464
+ execution: "client",
11465
+ applicationId: registration.applicationId,
11466
+ actionRef: registration.actionRef,
11467
+ ...registration.inputSchemaRef ? { inputSchemaRef: registration.inputSchemaRef } : {},
11468
+ input: input2,
11469
+ sourceCatalogRevisionRef: registration.sourceCatalogRevisionRef
11470
+ };
11471
+ } else {
11472
+ const inputDependency = release.dependencySnapshot.find(
11473
+ (dependency) => dependency.role === "schema" && sameRevisionRef(dependency.revisionRef, registration.inputSchemaRevisionRef)
11474
+ );
11475
+ const resultDependency = registration.resultSchemaRevisionRef ? release.dependencySnapshot.find(
11476
+ (dependency) => dependency.role === "schema" && sameRevisionRef(dependency.revisionRef, registration.resultSchemaRevisionRef)
11477
+ ) : void 0;
11478
+ if (!inputDependency || registration.resultSchemaRevisionRef && !resultDependency) {
11479
+ throw new DeclarativeControlCompilationError("DEPENDENCY_MISSING", `nodes[${index}].targetRef`, "Governed DomainCommand schemas are not pinned by NavigationRelease.");
11480
+ }
11481
+ resolvedTarget = {
11482
+ ...released,
11483
+ kind: "governed-domain-command",
11484
+ accessPolicy: registration.accessPolicy,
11485
+ execution: "server",
11486
+ commandRevisionRef: registration.targetRevisionRef,
11487
+ inputSchemaRevisionRef: registration.inputSchemaRevisionRef,
11488
+ ...registration.resultSchemaRevisionRef ? { resultSchemaRevisionRef: registration.resultSchemaRevisionRef } : {},
11489
+ input: JsonObjectSchema.parse(mappedInput)
11490
+ };
9657
11491
  }
9658
11492
  return {
9659
- changedRef: refs.get(changedKey) ?? (() => {
9660
- const separator = changedKey.indexOf(":");
9661
- return ref(changedKey.slice(0, separator), changedKey.slice(separator + 1));
9662
- })(),
9663
- affectedRefs: Array.from(affected).sort().map((key) => refs.get(key)),
9664
- reasons: affected.size ? ["dependency"] : ["direct-change"]
11493
+ ...node,
11494
+ ancestorAccessPolicies: ancestors,
11495
+ resolvedTarget
9665
11496
  };
9666
11497
  });
9667
- return ChangeImpactGraphSchema.parse({
9668
- contract: "ChangeImpactGraph",
9669
- declarationId: next.declaration.declarationId,
9670
- nodes: Array.from(refs.values()).sort((left, right) => refKey(left).localeCompare(refKey(right))),
9671
- edges: next.edges,
9672
- impacts,
9673
- generatedAt
11498
+ const unsigned = {
11499
+ contract: "NavigationRuntimeBundle",
11500
+ schemaVersion: 1,
11501
+ tenantScope: scope,
11502
+ releaseRevisionRef,
11503
+ compilerRevisionRef,
11504
+ generation: input.generation,
11505
+ dependencySnapshot: release.dependencySnapshot,
11506
+ rebuildable: true,
11507
+ diagnostics: [],
11508
+ navigationId: navigation.navigationId,
11509
+ navigationRevisionRef,
11510
+ surface: release.target.surface,
11511
+ placement: release.target.placement,
11512
+ nodes,
11513
+ performanceBudgetRef: navigation.performanceBudgetRef,
11514
+ observationPolicyRevisionRef: navigation.observationPolicyRevisionRef
11515
+ };
11516
+ return deepFreeze(NavigationRuntimeBundleSchema.parse({ ...unsigned, contentHash: canonicalContentHash(unsigned) }));
11517
+ };
11518
+ var validateWorkbenchRuntimeSet = (bundleInputs) => {
11519
+ const bundles = bundleInputs.map((bundle) => WorkbenchRuntimeBundleSchema.parse(bundle));
11520
+ if (bundles.length === 0) {
11521
+ throw new DeclarativeControlCompilationError("WORKBENCH_RELEASE_SET_INVALID", "bundles", "An active Workbench release set must retain at least one Workbench.");
11522
+ }
11523
+ const first = bundles[0];
11524
+ const seenIds = /* @__PURE__ */ new Set();
11525
+ const seenOrders = /* @__PURE__ */ new Set();
11526
+ let defaultCount = 0;
11527
+ bundles.forEach((bundle, index) => {
11528
+ if (scopeKey(bundle.tenantScope) !== scopeKey(first.tenantScope) || bundle.surface !== first.surface || !sameStableRef(bundle.target.environmentRef, first.target.environmentRef)) {
11529
+ throw new DeclarativeControlCompilationError("WORKBENCH_RELEASE_SET_INVALID", `bundles[${index}]`, "Workbench release set entries must share tenant, environment, and surface.");
11530
+ }
11531
+ if (seenIds.has(bundle.workbenchId)) throw new DeclarativeControlCompilationError("WORKBENCH_RELEASE_SET_INVALID", `bundles[${index}].workbenchId`, "Workbench identities must be unique in an active release set.");
11532
+ if (seenOrders.has(bundle.target.order)) throw new DeclarativeControlCompilationError("WORKBENCH_RELEASE_SET_INVALID", `bundles[${index}].target.order`, "Workbench order values must be unique in an active release set.");
11533
+ seenIds.add(bundle.workbenchId);
11534
+ seenOrders.add(bundle.target.order);
11535
+ if (bundle.target.isDefaultCandidate) defaultCount += 1;
9674
11536
  });
11537
+ if (defaultCount > 1) throw new DeclarativeControlCompilationError("WORKBENCH_RELEASE_SET_INVALID", "bundles", "An active Workbench release set may have at most one default candidate.");
11538
+ return Object.freeze([...bundles].sort((left, right) => left.target.order - right.target.order || left.workbenchId.localeCompare(right.workbenchId)));
11539
+ };
11540
+ var resolveWorkbenchEntry = (input) => {
11541
+ if (input.requestedWorkbenchId) {
11542
+ const requested = input.bundles.find((bundle) => bundle.workbenchId === input.requestedWorkbenchId);
11543
+ if (!requested) return { status: "not-found", workbenchId: input.requestedWorkbenchId };
11544
+ if (!input.isAllowed(requested)) return { status: "forbidden", workbenchId: input.requestedWorkbenchId };
11545
+ return { status: "resolved", bundle: requested, source: "explicit" };
11546
+ }
11547
+ const allowed = input.bundles.filter(input.isAllowed).sort((left, right) => left.target.order - right.target.order || left.workbenchId.localeCompare(right.workbenchId));
11548
+ const defaultBundle = allowed.find((bundle) => bundle.target.isDefaultCandidate);
11549
+ if (defaultBundle) return { status: "resolved", bundle: defaultBundle, source: "default" };
11550
+ if (allowed[0]) return { status: "resolved", bundle: allowed[0], source: "first-accessible" };
11551
+ return { status: "forbidden", workbenchId: "" };
9675
11552
  };
9676
11553
 
9677
11554
  // src/runtime/menu-compiler.ts
@@ -9688,19 +11565,19 @@ var pageKey = (page) => `${page.applicationId}\0${page.pageId}`;
9688
11565
  var targetKey = (page, activationId) => `${page.applicationId}\0${page.pageId}\0${activationId}`;
9689
11566
  var actionKey = (applicationId, actionRef) => `${applicationId}\0${actionRef}`;
9690
11567
  var providerKey = (applicationId, providerId) => `${applicationId}\0${providerId}`;
9691
- var stableSerialize = (value) => {
11568
+ var stableSerialize2 = (value) => {
9692
11569
  if (value === void 0) return "null";
9693
11570
  if (value === null || typeof value !== "object") return JSON.stringify(value) ?? "null";
9694
- if (Array.isArray(value)) return `[${value.map((item) => stableSerialize(item)).join(",")}]`;
11571
+ if (Array.isArray(value)) return `[${value.map((item) => stableSerialize2(item)).join(",")}]`;
9695
11572
  const record = value;
9696
- return `{${Object.keys(record).filter((key) => record[key] !== void 0).sort().map((key) => `${JSON.stringify(key)}:${stableSerialize(record[key])}`).join(",")}}`;
11573
+ return `{${Object.keys(record).filter((key) => record[key] !== void 0).sort().map((key) => `${JSON.stringify(key)}:${stableSerialize2(record[key])}`).join(",")}}`;
9697
11574
  };
9698
- var deepFreeze = (value) => {
11575
+ var deepFreeze2 = (value) => {
9699
11576
  if (value === null || typeof value !== "object" || Object.isFrozen(value)) return value;
9700
- Object.values(value).forEach((child) => deepFreeze(child));
11577
+ Object.values(value).forEach((child) => deepFreeze2(child));
9701
11578
  return Object.freeze(value);
9702
11579
  };
9703
- var SHA256_INITIAL = [
11580
+ var SHA256_INITIAL2 = [
9704
11581
  1779033703,
9705
11582
  3144134277,
9706
11583
  1013904242,
@@ -9710,7 +11587,7 @@ var SHA256_INITIAL = [
9710
11587
  528734635,
9711
11588
  1541459225
9712
11589
  ];
9713
- var SHA256_ROUND = [
11590
+ var SHA256_ROUND2 = [
9714
11591
  1116352408,
9715
11592
  1899447441,
9716
11593
  3049323471,
@@ -9776,8 +11653,8 @@ var SHA256_ROUND = [
9776
11653
  3204031479,
9777
11654
  3329325298
9778
11655
  ];
9779
- var rotateRight = (value, amount) => value >>> amount | value << 32 - amount;
9780
- var sha256Hex = (value) => {
11656
+ var rotateRight2 = (value, amount) => value >>> amount | value << 32 - amount;
11657
+ var sha256Hex2 = (value) => {
9781
11658
  const source = [...new TextEncoder().encode(value)];
9782
11659
  const bitLength = source.length * 8;
9783
11660
  source.push(128);
@@ -9786,7 +11663,7 @@ var sha256Hex = (value) => {
9786
11663
  const low = bitLength >>> 0;
9787
11664
  for (let shift = 24; shift >= 0; shift -= 8) source.push(high >>> shift & 255);
9788
11665
  for (let shift = 24; shift >= 0; shift -= 8) source.push(low >>> shift & 255);
9789
- const hash = [...SHA256_INITIAL];
11666
+ const hash = [...SHA256_INITIAL2];
9790
11667
  const words = new Array(64).fill(0);
9791
11668
  for (let offset = 0; offset < source.length; offset += 64) {
9792
11669
  for (let index = 0; index < 16; index += 1) {
@@ -9796,16 +11673,16 @@ var sha256Hex = (value) => {
9796
11673
  for (let index = 16; index < 64; index += 1) {
9797
11674
  const previous = words[index - 15];
9798
11675
  const recent = words[index - 2];
9799
- const small0 = rotateRight(previous, 7) ^ rotateRight(previous, 18) ^ previous >>> 3;
9800
- const small1 = rotateRight(recent, 17) ^ rotateRight(recent, 19) ^ recent >>> 10;
11676
+ const small0 = rotateRight2(previous, 7) ^ rotateRight2(previous, 18) ^ previous >>> 3;
11677
+ const small1 = rotateRight2(recent, 17) ^ rotateRight2(recent, 19) ^ recent >>> 10;
9801
11678
  words[index] = words[index - 16] + small0 + words[index - 7] + small1 >>> 0;
9802
11679
  }
9803
11680
  let [a, b, c, d, e, f, g, h] = hash;
9804
11681
  for (let index = 0; index < 64; index += 1) {
9805
- const big1 = rotateRight(e, 6) ^ rotateRight(e, 11) ^ rotateRight(e, 25);
11682
+ const big1 = rotateRight2(e, 6) ^ rotateRight2(e, 11) ^ rotateRight2(e, 25);
9806
11683
  const choice = e & f ^ ~e & g;
9807
- const temp1 = h + big1 + choice + SHA256_ROUND[index] + words[index] >>> 0;
9808
- const big0 = rotateRight(a, 2) ^ rotateRight(a, 13) ^ rotateRight(a, 22);
11684
+ const temp1 = h + big1 + choice + SHA256_ROUND2[index] + words[index] >>> 0;
11685
+ const big0 = rotateRight2(a, 2) ^ rotateRight2(a, 13) ^ rotateRight2(a, 22);
9809
11686
  const majority = a & b ^ a & c ^ b & c;
9810
11687
  const temp2 = big0 + majority >>> 0;
9811
11688
  h = g;
@@ -10033,10 +11910,10 @@ var compileMenuRuntimeBundle = (input) => {
10033
11910
  normalizedSourceInput = { exposure: node.behavior.input.exposure, value: normalized };
10034
11911
  runtimeInput = node.behavior.input.exposure === "client" ? { exposure: "client", value: normalized } : { exposure: "server" };
10035
11912
  if (node.behavior.input.exposure === "server" && definition.applicationId === applicationId) {
10036
- serverInputByTargetKey.set(identity, deepFreeze(normalized));
11913
+ serverInputByTargetKey.set(identity, deepFreeze2(normalized));
10037
11914
  }
10038
11915
  }
10039
- const signature = stableSerialize({
11916
+ const signature = stableSerialize2({
10040
11917
  kind: "navigate",
10041
11918
  page: node.behavior.page,
10042
11919
  activationId,
@@ -10144,7 +12021,7 @@ var compileMenuRuntimeBundle = (input) => {
10144
12021
  };
10145
12022
  const document = MenuRuntimeBundleSchema.parse({
10146
12023
  ...unsignedDocument,
10147
- contentHash: sha256Hex(stableSerialize(unsignedDocument))
12024
+ contentHash: sha256Hex2(stableSerialize2(unsignedDocument))
10148
12025
  });
10149
12026
  const menusByKey = new Map(document.menus.map((menu) => [
10150
12027
  menuKey(menu.applicationId, menu.surface, menu.menuId),
@@ -10171,7 +12048,7 @@ var compileMenuRuntimeBundle = (input) => {
10171
12048
  return target ? Object.freeze({ status: "resolved", target }) : Object.freeze({ status: "unmatched" });
10172
12049
  };
10173
12050
  return Object.freeze({
10174
- document: deepFreeze(document),
12051
+ document: deepFreeze2(document),
10175
12052
  menusByKey,
10176
12053
  navigationTargetsByKey: documentTargetsByKey,
10177
12054
  serverInputByTargetKey,
@@ -10586,83 +12463,11 @@ var buildApplicationHandoffUrl = (targetPath, handoff) => {
10586
12463
  return isRelative ? `${url.pathname}${url.search}${url.hash}` : url.toString();
10587
12464
  };
10588
12465
 
10589
- // src/runtime/render-tree-compiler.ts
10590
- var compileRenderTree = (input) => {
10591
- const tree = RenderTreeSchema.parse(input);
10592
- const nodesById = /* @__PURE__ */ new Map();
10593
- for (const node of tree.nodes) {
10594
- if (nodesById.has(node.nodeId)) throw new Error(`Duplicate render node id: ${node.nodeId}`);
10595
- nodesById.set(node.nodeId, node);
10596
- }
10597
- const root = nodesById.get(tree.rootNodeId);
10598
- if (!root) throw new Error(`Render tree ${tree.treeId} has no root node ${tree.rootNodeId}.`);
10599
- if (root.parentNodeId !== void 0) throw new Error(`Render tree root ${root.nodeId} cannot declare a parent.`);
10600
- for (const node of tree.nodes) {
10601
- if (node.nodeId !== root.nodeId && node.parentNodeId === void 0) {
10602
- throw new Error(`Render node ${node.nodeId} is disconnected from root ${root.nodeId}.`);
10603
- }
10604
- if (node.parentNodeId !== void 0) {
10605
- const parent = nodesById.get(node.parentNodeId);
10606
- if (!parent) throw new Error(`Render node ${node.nodeId} references missing parent ${node.parentNodeId}.`);
10607
- if (!parent.children.includes(node.nodeId)) {
10608
- throw new Error(`Render node ${node.nodeId} is not declared by parent ${parent.nodeId}.`);
10609
- }
10610
- }
10611
- for (const childId of node.children) {
10612
- const child = nodesById.get(childId);
10613
- if (!child) throw new Error(`Render node ${node.nodeId} references missing child ${childId}.`);
10614
- if (child.parentNodeId !== node.nodeId) {
10615
- throw new Error(`Render child ${childId} does not point back to parent ${node.nodeId}.`);
10616
- }
10617
- }
10618
- }
10619
- const visiting = /* @__PURE__ */ new Set();
10620
- const visited = /* @__PURE__ */ new Set();
10621
- const traversal = [];
10622
- const visit = (node) => {
10623
- if (visiting.has(node.nodeId)) throw new Error(`Render tree ${tree.treeId} contains a cycle at ${node.nodeId}.`);
10624
- if (visited.has(node.nodeId)) return;
10625
- visiting.add(node.nodeId);
10626
- traversal.push(node);
10627
- node.children.forEach((childId) => visit(nodesById.get(childId)));
10628
- visiting.delete(node.nodeId);
10629
- visited.add(node.nodeId);
10630
- };
10631
- visit(root);
10632
- if (visited.size !== nodesById.size) {
10633
- const disconnected = tree.nodes.find((node) => !visited.has(node.nodeId));
10634
- throw new Error(`Render node ${disconnected.nodeId} is not reachable from root ${root.nodeId}.`);
10635
- }
10636
- const childrenOf = (nodeId) => {
10637
- const node = nodesById.get(nodeId);
10638
- if (!node) throw new Error(`Unknown render node: ${nodeId}`);
10639
- return Object.freeze(node.children.map((childId) => nodesById.get(childId)));
10640
- };
10641
- const ancestorsOf = (nodeId) => {
10642
- let node = nodesById.get(nodeId);
10643
- if (!node) throw new Error(`Unknown render node: ${nodeId}`);
10644
- const ancestors = [];
10645
- while (node.parentNodeId !== void 0) {
10646
- node = nodesById.get(node.parentNodeId);
10647
- ancestors.push(node);
10648
- }
10649
- return Object.freeze(ancestors);
10650
- };
10651
- return Object.freeze({
10652
- tree,
10653
- root,
10654
- nodesById,
10655
- traversal: Object.freeze(traversal),
10656
- childrenOf,
10657
- ancestorsOf
10658
- });
10659
- };
10660
-
10661
12466
  // src/contracts/tenant.ts
10662
- import { z as z11 } from "zod";
12467
+ import { z as z12 } from "zod";
10663
12468
 
10664
12469
  // src/contracts/theme.ts
10665
- import { z as z10 } from "zod";
12470
+ import { z as z11 } from "zod";
10666
12471
 
10667
12472
  // src/theme-tokens/core.ts
10668
12473
  var import_ajv = __toESM(require_ajv());
@@ -12889,20 +14694,20 @@ function assertMonkeysThemeTokensComplete(input) {
12889
14694
  }
12890
14695
 
12891
14696
  // src/contracts/theme.ts
12892
- var ThemeTokenTypeSchema = z10.enum(THEME_TOKEN_TYPES);
12893
- var ThemeTokenSchema = z10.record(z10.string(), z10.unknown()).superRefine((input, context) => {
14697
+ var ThemeTokenTypeSchema = z11.enum(THEME_TOKEN_TYPES);
14698
+ var ThemeTokenSchema = z11.record(z11.string(), z11.unknown()).superRefine((input, context) => {
12894
14699
  const issues = validateThemeTokensDocumentStructure({ token: input });
12895
14700
  for (const issue of issues) {
12896
14701
  context.addIssue({ code: "custom", message: `${issue.path} ${issue.message}` });
12897
14702
  }
12898
14703
  });
12899
- var ThemeTokenGroupSchema = z10.record(z10.string(), z10.unknown()).superRefine((input, context) => {
14704
+ var ThemeTokenGroupSchema = z11.record(z11.string(), z11.unknown()).superRefine((input, context) => {
12900
14705
  const issues = validateThemeTokensDocumentStructure(input);
12901
14706
  for (const issue of issues) {
12902
14707
  context.addIssue({ code: "custom", message: `${issue.path} ${issue.message}` });
12903
14708
  }
12904
14709
  });
12905
- var ThemeTokensSchema = z10.record(z10.string(), z10.unknown()).superRefine((input, context) => {
14710
+ var ThemeTokensSchema = z11.record(z11.string(), z11.unknown()).superRefine((input, context) => {
12906
14711
  const issues = validateThemeTokensDocument(input);
12907
14712
  for (const issue of issues) {
12908
14713
  context.addIssue({ code: "custom", message: `${issue.path} ${issue.message}` });
@@ -12929,9 +14734,9 @@ var ResolvedThemeTokensSchema = ThemeTokensSchema.superRefine((input, context) =
12929
14734
  });
12930
14735
 
12931
14736
  // src/contracts/tenant.ts
12932
- var DesignTokenFileSourceSchema = z11.object({
12933
- type: z11.literal("file"),
12934
- path: z11.string().trim().min(1).superRefine((source, context) => {
14737
+ var DesignTokenFileSourceSchema = z12.object({
14738
+ type: z12.literal("file"),
14739
+ path: z12.string().trim().min(1).superRefine((source, context) => {
12935
14740
  const isWindowsDrivePath = /^[a-z]:[\\/]/i.test(source);
12936
14741
  if (!isWindowsDrivePath && /^[a-z][a-z\d+.-]*:/i.test(source)) {
12937
14742
  context.addIssue({
@@ -12941,9 +14746,9 @@ var DesignTokenFileSourceSchema = z11.object({
12941
14746
  }
12942
14747
  })
12943
14748
  }).strict();
12944
- var DesignTokenUrlSourceSchema = z11.object({
12945
- type: z11.literal("url"),
12946
- url: z11.string().trim().min(1).superRefine((source, context) => {
14749
+ var DesignTokenUrlSourceSchema = z12.object({
14750
+ type: z12.literal("url"),
14751
+ url: z12.string().trim().min(1).superRefine((source, context) => {
12947
14752
  if (!/^https?:\/\//i.test(source)) {
12948
14753
  context.addIssue({
12949
14754
  code: "custom",
@@ -12952,55 +14757,45 @@ var DesignTokenUrlSourceSchema = z11.object({
12952
14757
  }
12953
14758
  })
12954
14759
  }).strict();
12955
- var DesignTokenInlineSourceSchema = z11.object({
12956
- type: z11.literal("inline"),
14760
+ var DesignTokenInlineSourceSchema = z12.object({
14761
+ type: z12.literal("inline"),
12957
14762
  document: ThemeTokensSchema
12958
14763
  }).strict();
12959
- var DesignTokenSourceSchema = z11.discriminatedUnion("type", [
12960
- DesignTokenFileSourceSchema,
12961
- DesignTokenUrlSourceSchema,
12962
- DesignTokenInlineSourceSchema
12963
- ]);
12964
- var TenantDesignTokensConfigSchema = z11.object({
14764
+ var DesignTokenSourceSchema = z12.discriminatedUnion("type", [DesignTokenFileSourceSchema, DesignTokenUrlSourceSchema, DesignTokenInlineSourceSchema]);
14765
+ var TenantDesignTokensConfigSchema = z12.object({
12965
14766
  /** Ordered tenant overrides. The backend always applies the product default first. */
12966
- tokenSources: z11.array(DesignTokenSourceSchema)
14767
+ tokenSources: z12.array(DesignTokenSourceSchema)
12967
14768
  }).strict();
12968
- var TenantAuthBindingSchema = z11.object({
12969
- kind: z11.literal("auth-provider"),
14769
+ var TenantAuthBindingSchema = z12.object({
14770
+ kind: z12.literal("auth-provider"),
12970
14771
  providerId: ContractIdentifierSchema,
12971
14772
  policyRef: ContractIdentifierSchema.optional()
12972
14773
  }).strict();
12973
- var TenantDataBindingSchema = z11.discriminatedUnion("kind", [
12974
- z11.object({
12975
- kind: z11.literal("data-provider"),
14774
+ var TenantDataBindingSchema = z12.discriminatedUnion("kind", [
14775
+ z12.object({
14776
+ kind: z12.literal("data-provider"),
12976
14777
  providerId: ContractIdentifierSchema,
12977
14778
  domainRef: ContractIdentifierSchema.optional()
12978
14779
  }).strict(),
12979
- z11.object({
12980
- kind: z11.literal("projection"),
14780
+ z12.object({
14781
+ kind: z12.literal("projection"),
12981
14782
  projectionRef: ContractIdentifierSchema,
12982
14783
  domainRef: ContractIdentifierSchema.optional()
12983
14784
  }).strict()
12984
14785
  ]);
12985
- var TenantAuthBindingsSchema = z11.record(
12986
- ContractIdentifierSchema,
12987
- TenantAuthBindingSchema
12988
- );
12989
- var TenantDataBindingsSchema = z11.record(
12990
- ContractIdentifierSchema,
12991
- TenantDataBindingSchema
12992
- );
12993
- var TenantTrendRadarSourceSchema = z11.object({
14786
+ var TenantAuthBindingsSchema = z12.record(ContractIdentifierSchema, TenantAuthBindingSchema);
14787
+ var TenantDataBindingsSchema = z12.record(ContractIdentifierSchema, TenantDataBindingSchema);
14788
+ var TenantTrendRadarSourceSchema = z12.object({
12994
14789
  ontologyId: ContractIdentifierSchema,
12995
14790
  viewId: ContractIdentifierSchema
12996
14791
  }).strict();
12997
- var TenantTrendRadarCollectionTargetSchema = z11.object({
14792
+ var TenantTrendRadarCollectionTargetSchema = z12.object({
12998
14793
  ontologyId: ContractIdentifierSchema
12999
14794
  }).strict();
13000
- var TenantTrendRadarEvaluationSchema = z11.object({
14795
+ var TenantTrendRadarEvaluationSchema = z12.object({
13001
14796
  workflowId: ContractIdentifierSchema
13002
14797
  }).strict();
13003
- var TenantTrendRadarDerivedMetricsSchema = z11.object({
14798
+ var TenantTrendRadarDerivedMetricsSchema = z12.object({
13004
14799
  productCountFieldKey: ContractIdentifierSchema,
13005
14800
  salesValueCountFieldKey: ContractIdentifierSchema,
13006
14801
  salesSumFieldKey: ContractIdentifierSchema
@@ -13008,7 +14803,7 @@ var TenantTrendRadarDerivedMetricsSchema = z11.object({
13008
14803
  ({ productCountFieldKey, salesValueCountFieldKey, salesSumFieldKey }) => (/* @__PURE__ */ new Set([productCountFieldKey, salesValueCountFieldKey, salesSumFieldKey])).size === 3,
13009
14804
  { message: "Trend Radar derived metric Field Keys must be distinct." }
13010
14805
  );
13011
- var TenantTrendRadarSourcesSchema = z11.object({
14806
+ var TenantTrendRadarSourcesSchema = z12.object({
13012
14807
  products: TenantTrendRadarSourceSchema.optional(),
13013
14808
  hotwords: TenantTrendRadarSourceSchema.optional(),
13014
14809
  brands: TenantTrendRadarSourceSchema.optional(),
@@ -13016,58 +14811,54 @@ var TenantTrendRadarSourcesSchema = z11.object({
13016
14811
  derivedMetrics: TenantTrendRadarDerivedMetricsSchema.optional(),
13017
14812
  evaluation: TenantTrendRadarEvaluationSchema.optional()
13018
14813
  }).strict();
13019
- var AssetVariantsSchema = z11.object({
13020
- light: z11.string().optional(),
13021
- dark: z11.string().optional()
14814
+ var AssetVariantsSchema = z12.object({
14815
+ light: z12.string().optional(),
14816
+ dark: z12.string().optional()
13022
14817
  }).strict();
13023
- var TenantAgentThemeConfigSchema = z11.object({
14818
+ var TenantAgentThemeConfigSchema = z12.object({
13024
14819
  logo: AssetVariantsSchema.optional(),
13025
- brandDisplayMode: z11.enum(["auto", "logo-only", "logo-name", "name-only"]).optional(),
13026
- density: z11.enum(["compact", "default", "comfortable"]).optional(),
14820
+ brandDisplayMode: z12.enum(["auto", "logo-only", "logo-name", "name-only"]).optional(),
14821
+ density: z12.enum(["compact", "default", "comfortable"]).optional(),
13027
14822
  sidebar: AgentWorkbenchSidebarConfigSchema.optional(),
13028
14823
  /** @deprecated Use sidebar.navigationMode. */
13029
- navigationMode: z11.enum(["default", "session", "trend"]).optional(),
14824
+ navigationMode: z12.enum(["default", "session", "trend"]).optional(),
13030
14825
  /** @deprecated Use sidebar.quickStartEnabled. */
13031
- quickStartEnabled: z11.boolean().optional()
14826
+ quickStartEnabled: z12.boolean().optional()
13032
14827
  }).strict();
13033
14828
  var LEGACY_CURRENT_USER_MENU_ITEM_IDS = ["dark-mode", "language", "settings", "logout"];
13034
14829
  var CURRENT_USER_MENU_CONTROL_REFS = ["dark-mode", "language"];
13035
14830
  var CURRENT_USER_MENU_ACTION_REFS = ["logout"];
13036
- var CurrentUserMenuIdentifierSchema = z11.string().trim().regex(/^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/, "Expected a stable current-user menu identifier.");
13037
- var CurrentUserMenuDisplayTextSchema = z11.union([
13038
- z11.string().trim().min(1),
13039
- z11.record(z11.string().trim().min(1), z11.string().trim().min(1)).refine((value) => Object.keys(value).length > 0, "Localized menu text must contain at least one locale.")
14831
+ var CurrentUserMenuIdentifierSchema = z12.string().trim().regex(/^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/, "Expected a stable current-user menu identifier.");
14832
+ var CurrentUserMenuDisplayTextSchema = z12.union([
14833
+ z12.string().trim().min(1),
14834
+ z12.record(z12.string().trim().min(1), z12.string().trim().min(1)).refine((value) => Object.keys(value).length > 0, "Localized menu text must contain at least one locale.")
13040
14835
  ]);
13041
- var CurrentUserMenuNavigationItemSchema = z11.object({
14836
+ var CurrentUserMenuNavigationItemSchema = z12.object({
13042
14837
  id: CurrentUserMenuIdentifierSchema,
13043
- kind: z11.literal("navigation"),
14838
+ kind: z12.literal("navigation"),
13044
14839
  ref: CurrentUserMenuIdentifierSchema
13045
14840
  }).strict();
13046
- var CurrentUserMenuControlItemSchema = z11.object({
14841
+ var CurrentUserMenuControlItemSchema = z12.object({
13047
14842
  id: CurrentUserMenuIdentifierSchema,
13048
- kind: z11.literal("control"),
13049
- ref: z11.enum(CURRENT_USER_MENU_CONTROL_REFS)
14843
+ kind: z12.literal("control"),
14844
+ ref: z12.enum(CURRENT_USER_MENU_CONTROL_REFS)
13050
14845
  }).strict();
13051
- var CurrentUserMenuActionItemSchema = z11.object({
14846
+ var CurrentUserMenuActionItemSchema = z12.object({
13052
14847
  id: CurrentUserMenuIdentifierSchema,
13053
- kind: z11.literal("action"),
13054
- ref: z11.enum(CURRENT_USER_MENU_ACTION_REFS),
13055
- tone: z11.enum(["default", "danger"]).optional()
13056
- }).strict();
13057
- var CurrentUserMenuItemSchema = z11.discriminatedUnion("kind", [
13058
- CurrentUserMenuNavigationItemSchema,
13059
- CurrentUserMenuControlItemSchema,
13060
- CurrentUserMenuActionItemSchema
13061
- ]);
13062
- var CurrentUserMenuSectionSchema = z11.object({
14848
+ kind: z12.literal("action"),
14849
+ ref: z12.enum(CURRENT_USER_MENU_ACTION_REFS),
14850
+ tone: z12.enum(["default", "danger"]).optional()
14851
+ }).strict();
14852
+ var CurrentUserMenuItemSchema = z12.discriminatedUnion("kind", [CurrentUserMenuNavigationItemSchema, CurrentUserMenuControlItemSchema, CurrentUserMenuActionItemSchema]);
14853
+ var CurrentUserMenuSectionSchema = z12.object({
13063
14854
  id: CurrentUserMenuIdentifierSchema,
13064
14855
  label: CurrentUserMenuDisplayTextSchema.optional(),
13065
- dividerBefore: z11.boolean().optional(),
13066
- items: z11.array(CurrentUserMenuItemSchema)
14856
+ dividerBefore: z12.boolean().optional(),
14857
+ items: z12.array(CurrentUserMenuItemSchema)
13067
14858
  }).strict();
13068
- var CurrentUserMenuConfigSchema = z11.object({
13069
- version: z11.literal(1),
13070
- sections: z11.array(CurrentUserMenuSectionSchema).max(20)
14859
+ var CurrentUserMenuConfigSchema = z12.object({
14860
+ version: z12.literal(1),
14861
+ sections: z12.array(CurrentUserMenuSectionSchema).max(20)
13071
14862
  }).strict().superRefine((value, context) => {
13072
14863
  const sectionIds = /* @__PURE__ */ new Set();
13073
14864
  const itemIds = /* @__PURE__ */ new Set();
@@ -13101,7 +14892,7 @@ var CurrentUserMenuConfigSchema = z11.object({
13101
14892
  });
13102
14893
  }
13103
14894
  });
13104
- var LegacyCurrentUserMenuProfileSchema = z11.array(z11.enum(LEGACY_CURRENT_USER_MENU_ITEM_IDS)).superRefine((value, context) => {
14895
+ var LegacyCurrentUserMenuProfileSchema = z12.array(z12.enum(LEGACY_CURRENT_USER_MENU_ITEM_IDS)).superRefine((value, context) => {
13105
14896
  const seen = /* @__PURE__ */ new Set();
13106
14897
  value.forEach((item, index) => {
13107
14898
  if (seen.has(item)) {
@@ -13114,73 +14905,69 @@ var LegacyCurrentUserMenuProfileSchema = z11.array(z11.enum(LEGACY_CURRENT_USER_
13114
14905
  seen.add(item);
13115
14906
  });
13116
14907
  });
13117
- var CurrentUserMenuProfileSchema = z11.union([
13118
- z11.literal("*"),
13119
- LegacyCurrentUserMenuProfileSchema,
13120
- CurrentUserMenuConfigSchema
13121
- ]);
13122
- var ThemeHeadbarSchema = z11.object({
13123
- theme: z11.enum(["card", "glassy", "ghost"]).optional(),
13124
- navPosition: z11.enum(["left", "center", "right"]).optional(),
13125
- actions: z11.union([z11.literal("*"), z11.array(ContractIdentifierSchema)]).optional(),
14908
+ var CurrentUserMenuProfileSchema = z12.union([z12.literal("*"), LegacyCurrentUserMenuProfileSchema, CurrentUserMenuConfigSchema]);
14909
+ var ThemeHeadbarSchema = z12.object({
14910
+ theme: z12.enum(["card", "glassy", "ghost"]).optional(),
14911
+ navPosition: z12.enum(["left", "center", "right"]).optional(),
14912
+ actions: z12.union([z12.literal("*"), z12.array(ContractIdentifierSchema)]).optional(),
13126
14913
  profile: CurrentUserMenuProfileSchema.optional(),
13127
- showTeamQuota: z11.boolean().optional()
14914
+ showTeamQuota: z12.boolean().optional()
13128
14915
  }).strict();
13129
- var TenantHeadbarModuleLeafSchema = z11.object({
14916
+ var TenantHeadbarModuleLeafSchema = z12.object({
13130
14917
  id: ContractIdentifierSchema,
13131
- extraInfo: z11.boolean().optional(),
13132
- displayName: z11.union([z11.string(), z11.record(LocaleIdentifierSchema, z11.string())]).optional(),
13133
- visible: z11.boolean().optional(),
13134
- disabled: z11.boolean().optional(),
13135
- icon: z11.string().optional(),
13136
- showQuickSwitcher: z11.boolean().optional(),
13137
- showSidebar: z11.boolean().optional(),
13138
- showContentFrame: z11.boolean().optional()
14918
+ extraInfo: z12.boolean().optional(),
14919
+ displayName: z12.union([z12.string(), z12.record(LocaleIdentifierSchema, z12.string())]).optional(),
14920
+ visible: z12.boolean().optional(),
14921
+ disabled: z12.boolean().optional(),
14922
+ icon: z12.string().optional(),
14923
+ showQuickSwitcher: z12.boolean().optional(),
14924
+ showSidebar: z12.boolean().optional(),
14925
+ showContentFrame: z12.boolean().optional()
13139
14926
  }).strict();
13140
14927
  var TenantHeadbarModuleItemSchema = TenantHeadbarModuleLeafSchema.extend({
13141
- children: z11.array(TenantHeadbarModuleLeafSchema).optional()
13142
- }).strict();
13143
- var KernelHeadbarSchema = z11.object({
13144
- theme: z11.literal("card").optional(),
13145
- layoutMode: z11.enum(["boxed", "full-bleed"]).optional(),
13146
- heightPx: z11.number().positive().optional(),
13147
- navPosition: z11.enum(["left", "center", "right"]).optional(),
13148
- brandTitle: z11.string().optional(),
13149
- menuRadius: z11.enum(["default", "none", "sm", "md", "lg", "xl", "full"]).optional()
13150
- }).strict();
13151
- var CustomIconSchema = z11.object({
13152
- color: z11.string().optional(),
13153
- url: z11.string().optional(),
13154
- type: z11.enum(["svg", "image"]).optional(),
13155
- hintTextColor: z11.string().optional()
13156
- }).strict();
13157
- var WorkbenchCustomerToolSchema = z11.object({
14928
+ children: z12.array(TenantHeadbarModuleLeafSchema).optional()
14929
+ }).strict();
14930
+ var KernelHeadbarSchema = z12.object({
14931
+ theme: z12.literal("card").optional(),
14932
+ layoutMode: z12.enum(["boxed", "full-bleed"]).optional(),
14933
+ heightPx: z12.number().positive().optional(),
14934
+ navPosition: z12.enum(["left", "center", "right"]).optional(),
14935
+ brandTitle: z12.string().optional(),
14936
+ menuRadius: z12.enum(["default", "none", "sm", "md", "lg", "xl", "full"]).optional()
14937
+ }).strict();
14938
+ var CustomIconSchema = z12.object({
14939
+ color: z12.string().optional(),
14940
+ url: z12.string().optional(),
14941
+ type: z12.enum(["svg", "image"]).optional(),
14942
+ hintTextColor: z12.string().optional()
14943
+ }).strict();
14944
+ var WorkbenchCustomerToolSchema = z12.object({
13158
14945
  id: ContractIdentifierSchema,
13159
- label: z11.union([z11.string(), z11.record(LocaleIdentifierSchema, z11.string())]).optional(),
13160
- fixed: z11.boolean().optional()
14946
+ label: z12.union([z12.string(), z12.record(LocaleIdentifierSchema, z12.string())]).optional(),
14947
+ fixed: z12.boolean().optional()
13161
14948
  }).strict();
13162
- var WorkbenchStudioOverrideSchema = z11.object({
13163
- studioName: z11.string().trim().min(1),
13164
- dropdownToolsDefault: z11.array(ContractIdentifierSchema).optional(),
13165
- existingToolsDefault: z11.array(ContractIdentifierSchema).optional(),
13166
- historyColumnsDefault: z11.number().int().min(1).max(6).optional()
14949
+ var WorkbenchStudioOverrideSchema = z12.object({
14950
+ studioName: z12.string().trim().min(1),
14951
+ dropdownToolsDefault: z12.array(ContractIdentifierSchema).optional(),
14952
+ existingToolsDefault: z12.array(ContractIdentifierSchema).optional(),
14953
+ historyColumnsDefault: z12.number().int().min(1).max(6).optional()
13167
14954
  }).strict();
13168
- var TenantWorkbenchPageContextSchema = z11.object({
14955
+ var TenantWorkbenchPageContextSchema = z12.object({
13169
14956
  workflow: JsonObjectSchema.optional(),
13170
14957
  agent: JsonObjectSchema.optional(),
13171
14958
  agentId: ContractIdentifierSchema.optional(),
13172
14959
  designProject: JsonObjectSchema.optional(),
13173
14960
  designMetadataId: ContractIdentifierSchema.optional(),
13174
- iframeUrl: z11.string().trim().min(1).optional(),
13175
- info: z11.object({
14961
+ iframeUrl: z12.string().trim().min(1).optional(),
14962
+ info: z12.object({
13176
14963
  displayName: LocalizedTextSchema.optional(),
13177
14964
  description: LocalizedTextSchema.optional(),
13178
- iconUrl: z11.string().trim().min(1).optional()
14965
+ iconUrl: z12.string().trim().min(1).optional()
13179
14966
  }).strict().optional(),
13180
- isBuiltinPinned: z11.boolean().optional(),
13181
- isBuiltinReadonly: z11.boolean().optional()
14967
+ isBuiltinPinned: z12.boolean().optional(),
14968
+ isBuiltinReadonly: z12.boolean().optional()
13182
14969
  }).strict();
13183
- var TenantWorkbenchPageEnvelopeSchema = z11.object({
14970
+ var TenantWorkbenchPageEnvelopeSchema = z12.object({
13184
14971
  definition: PageDefinitionSchema,
13185
14972
  context: TenantWorkbenchPageContextSchema
13186
14973
  }).strict().superRefine(({ definition }, context) => {
@@ -13213,66 +15000,77 @@ var TenantWorkbenchPageEnvelopeSchema = z11.object({
13213
15000
  });
13214
15001
  }
13215
15002
  });
13216
- var TenantWorkbenchPageGroupSchema = z11.object({
15003
+ var TenantWorkbenchPageGroupSchema = z12.object({
13217
15004
  id: ContractIdentifierSchema,
13218
- pageIds: z11.array(ContractIdentifierSchema),
15005
+ pageIds: z12.array(ContractIdentifierSchema),
13219
15006
  displayName: LocalizedTextSchema,
13220
- isBuiltIn: z11.boolean(),
13221
- iconUrl: z11.string().optional(),
13222
- sortIndex: z11.number().int().nullable().optional(),
15007
+ isBuiltIn: z12.boolean(),
15008
+ iconUrl: z12.string().optional(),
15009
+ sortIndex: z12.number().int().nullable().optional(),
13223
15010
  presetRelationId: ContractIdentifierSchema.optional(),
13224
15011
  relationKey: ContractIdentifierSchema.nullable().optional(),
13225
15012
  studioId: ContractIdentifierSchema.optional()
13226
15013
  }).strict();
13227
- var TenantWorkbenchConfigSchema = z11.object({
13228
- pages: z11.array(TenantWorkbenchPageEnvelopeSchema),
13229
- pageGroups: z11.array(TenantWorkbenchPageGroupSchema),
13230
- catalog: z11.object({ enabled: z11.boolean().optional(), defaultEntry: z11.boolean().optional() }).strict().optional(),
13231
- quickSwitcherMaxItems: z11.number().int().nonnegative().optional(),
13232
- defaultOrder: z11.object({
13233
- groups: z11.array(ContractIdentifierSchema),
13234
- pages: z11.record(ContractIdentifierSchema, z11.array(ContractIdentifierSchema))
15014
+ var TenantWorkbenchConfigSchema = z12.object({
15015
+ pages: z12.array(TenantWorkbenchPageEnvelopeSchema),
15016
+ pageGroups: z12.array(TenantWorkbenchPageGroupSchema),
15017
+ catalog: z12.object({
15018
+ enabled: z12.boolean().optional(),
15019
+ defaultEntry: z12.boolean().optional()
13235
15020
  }).strict().optional(),
13236
- customers: z11.object({
13237
- dropdownToolsDefault: z11.array(ContractIdentifierSchema).optional(),
13238
- layoutManagerTools: z11.array(WorkbenchCustomerToolSchema).optional(),
13239
- studioTabsMode: z11.enum(["dropdown", "tabs"]).optional(),
13240
- historyWatermark: z11.object({
13241
- svgUrl: z11.string().optional(),
13242
- coverage: z11.array(z11.enum(["list", "detail", "download"])).optional(),
13243
- maxLongEdgeRatio: z11.number().positive().optional(),
13244
- sizing: z11.object({
15021
+ quickSwitcherMaxItems: z12.number().int().nonnegative().optional(),
15022
+ defaultOrder: z12.object({
15023
+ groups: z12.array(ContractIdentifierSchema),
15024
+ pages: z12.record(ContractIdentifierSchema, z12.array(ContractIdentifierSchema))
15025
+ }).strict().optional(),
15026
+ customers: z12.object({
15027
+ dropdownToolsDefault: z12.array(ContractIdentifierSchema).optional(),
15028
+ layoutManagerTools: z12.array(WorkbenchCustomerToolSchema).optional(),
15029
+ studioTabsMode: z12.enum(["dropdown", "tabs"]).optional(),
15030
+ historyWatermark: z12.object({
15031
+ svgUrl: z12.string().optional(),
15032
+ coverage: z12.array(z12.enum(["list", "detail", "download"])).optional(),
15033
+ maxLongEdgeRatio: z12.number().positive().optional(),
15034
+ sizing: z12.object({
13245
15035
  mode: ContractIdentifierSchema,
13246
- heightRatio: z11.number().positive().optional(),
13247
- minHeightPx: z11.number().nonnegative().optional(),
13248
- maxHeightPx: z11.number().nonnegative().optional()
15036
+ heightRatio: z12.number().positive().optional(),
15037
+ minHeightPx: z12.number().nonnegative().optional(),
15038
+ maxHeightPx: z12.number().nonnegative().optional()
13249
15039
  }).strict().optional(),
13250
- enhance: z11.object({
13251
- enabled: z11.boolean().optional(),
13252
- backgroundLumaThreshold: z11.number().min(0).max(1).optional(),
13253
- stroke: z11.object({
13254
- color: z11.string().optional(),
13255
- opacity: z11.number().min(0).max(1).optional(),
13256
- widthRatio: z11.number().nonnegative().optional(),
13257
- blurRatio: z11.number().nonnegative().optional(),
13258
- steps: z11.number().int().positive().optional()
15040
+ enhance: z12.object({
15041
+ enabled: z12.boolean().optional(),
15042
+ backgroundLumaThreshold: z12.number().min(0).max(1).optional(),
15043
+ stroke: z12.object({
15044
+ color: z12.string().optional(),
15045
+ opacity: z12.number().min(0).max(1).optional(),
15046
+ widthRatio: z12.number().nonnegative().optional(),
15047
+ blurRatio: z12.number().nonnegative().optional(),
15048
+ steps: z12.number().int().positive().optional()
13259
15049
  }).strict().optional()
13260
15050
  }).strict().optional()
13261
15051
  }).strict().optional(),
13262
- layoutManagerEnabled: z11.boolean().optional(),
13263
- existingToolsDefault: z11.array(ContractIdentifierSchema).optional(),
13264
- historyColumnsDefault: z11.number().int().min(1).max(6).optional(),
13265
- studioOverrides: z11.array(WorkbenchStudioOverrideSchema).optional()
15052
+ layoutManagerEnabled: z12.boolean().optional(),
15053
+ existingToolsDefault: z12.array(ContractIdentifierSchema).optional(),
15054
+ historyColumnsDefault: z12.number().int().min(1).max(6).optional(),
15055
+ studioOverrides: z12.array(WorkbenchStudioOverrideSchema).optional()
13266
15056
  }).strict().optional()
13267
15057
  }).strict().superRefine(({ pages, pageGroups }, context) => {
13268
15058
  const pageIds = pages.map(({ definition }) => definition.pageId);
13269
15059
  const pageIdSet = new Set(pageIds);
13270
15060
  if (pageIdSet.size !== pageIds.length) {
13271
- context.addIssue({ code: "custom", path: ["pages"], message: "Tenant workbench page ids must be unique." });
15061
+ context.addIssue({
15062
+ code: "custom",
15063
+ path: ["pages"],
15064
+ message: "Tenant workbench page ids must be unique."
15065
+ });
13272
15066
  }
13273
15067
  const groupIds = pageGroups.map(({ id }) => id);
13274
15068
  if (new Set(groupIds).size !== groupIds.length) {
13275
- context.addIssue({ code: "custom", path: ["pageGroups"], message: "Tenant workbench page group ids must be unique." });
15069
+ context.addIssue({
15070
+ code: "custom",
15071
+ path: ["pageGroups"],
15072
+ message: "Tenant workbench page group ids must be unique."
15073
+ });
13276
15074
  }
13277
15075
  pageGroups.forEach((group, groupIndex) => {
13278
15076
  group.pageIds.forEach((pageId, pageIndex) => {
@@ -13286,38 +15084,41 @@ var TenantWorkbenchConfigSchema = z11.object({
13286
15084
  });
13287
15085
  });
13288
15086
  });
13289
- var LoginPageSchema = z11.object({
13290
- background: z11.object({ imageUrl: z11.string().optional(), gradient: z11.string().optional() }).strict().optional(),
13291
- logo: z11.object({
13292
- url: z11.string().optional(),
13293
- lightUrl: z11.string().optional(),
13294
- darkUrl: z11.string().optional(),
13295
- position: z11.enum(["top", "middle", "bottom"]).optional(),
13296
- scale: z11.number().positive().optional()
15087
+ var LoginPageSchema = z12.object({
15088
+ background: z12.object({
15089
+ imageUrl: z12.string().optional(),
15090
+ gradient: z12.string().optional()
15091
+ }).strict().optional(),
15092
+ logo: z12.object({
15093
+ url: z12.string().optional(),
15094
+ lightUrl: z12.string().optional(),
15095
+ darkUrl: z12.string().optional(),
15096
+ position: z12.enum(["top", "middle", "bottom"]).optional(),
15097
+ scale: z12.number().positive().optional()
13297
15098
  }).strict().optional(),
13298
- customCss: z11.string().optional()
15099
+ customCss: z12.string().optional()
13299
15100
  }).strict();
13300
15101
  var LandingPageHeadbarConfigShape = {
13301
- headbarMode: z11.enum(["shared", "hidden"]).optional()
15102
+ headbarMode: z12.enum(["shared", "hidden"]).optional()
13302
15103
  };
13303
- var LandingPageDefaultConfigSchema = z11.object({
13304
- mode: z11.literal("default"),
15104
+ var LandingPageDefaultConfigSchema = z12.object({
15105
+ mode: z12.literal("default"),
13305
15106
  ...LandingPageHeadbarConfigShape
13306
15107
  }).strict();
13307
- var LandingPageMarkdownConfigSchema = z11.object({
13308
- mode: z11.literal("markdown"),
13309
- content: z11.string(),
15108
+ var LandingPageMarkdownConfigSchema = z12.object({
15109
+ mode: z12.literal("markdown"),
15110
+ content: z12.string(),
13310
15111
  ...LandingPageHeadbarConfigShape
13311
15112
  }).strict();
13312
- var LandingPageHtmlConfigSchema = z11.object({
13313
- mode: z11.literal("html"),
13314
- content: z11.string(),
15113
+ var LandingPageHtmlConfigSchema = z12.object({
15114
+ mode: z12.literal("html"),
15115
+ content: z12.string(),
13315
15116
  ...LandingPageHeadbarConfigShape
13316
15117
  }).strict();
13317
- var LandingPageIframeConfigSchema = z11.object({
13318
- mode: z11.literal("iframe"),
15118
+ var LandingPageIframeConfigSchema = z12.object({
15119
+ mode: z12.literal("iframe"),
13319
15120
  ...LandingPageHeadbarConfigShape,
13320
- url: z11.string().refine((value) => {
15121
+ url: z12.string().refine((value) => {
13321
15122
  if (/^\/(?!\/)/.test(value)) {
13322
15123
  return !value.includes("\\");
13323
15124
  }
@@ -13329,13 +15130,13 @@ var LandingPageIframeConfigSchema = z11.object({
13329
15130
  }
13330
15131
  }, "Landing page iframe URL must use a root-relative path or HTTP(S) without embedded credentials.")
13331
15132
  }).strict();
13332
- var TenantLandingPageConfigSchema = z11.discriminatedUnion("mode", [
15133
+ var TenantLandingPageConfigSchema = z12.discriminatedUnion("mode", [
13333
15134
  LandingPageDefaultConfigSchema,
13334
15135
  LandingPageMarkdownConfigSchema,
13335
15136
  LandingPageHtmlConfigSchema,
13336
15137
  LandingPageIframeConfigSchema
13337
15138
  ]);
13338
- var ListFooterPageSizeOptionsSchema = z11.array(z11.number().int().positive().max(1e3)).min(1).max(10).superRefine((options, context) => {
15139
+ var ListFooterPageSizeOptionsSchema = z12.array(z12.number().int().positive().max(1e3)).min(1).max(10).superRefine((options, context) => {
13339
15140
  const seen = /* @__PURE__ */ new Set();
13340
15141
  options.forEach((option, index) => {
13341
15142
  if (seen.has(option)) {
@@ -13348,263 +15149,339 @@ var ListFooterPageSizeOptionsSchema = z11.array(z11.number().int().positive().ma
13348
15149
  seen.add(option);
13349
15150
  });
13350
15151
  });
13351
- var TenantListFooterConfigSchema = z11.object({
13352
- showTotal: z11.boolean().optional(),
13353
- showPageSize: z11.boolean().optional(),
15152
+ var TenantListFooterConfigSchema = z12.object({
15153
+ showTotal: z12.boolean().optional(),
15154
+ showPageSize: z12.boolean().optional(),
13354
15155
  pageSizeOptions: ListFooterPageSizeOptionsSchema.optional(),
13355
- paginationMode: z11.enum(["auto", "pages", "compact"]).optional(),
13356
- alignment: z11.enum(["start", "end", "space-between"]).optional(),
13357
- density: z11.enum(["compact", "default", "comfortable"]).optional()
13358
- }).strict();
13359
- var TenantApplicationConfigSchema = z11.object({
13360
- theme: z11.object({
13361
- id: z11.string().optional(),
13362
- name: z11.string().optional(),
13363
- title: z11.string().optional(),
15156
+ paginationMode: z12.enum(["auto", "pages", "compact"]).optional(),
15157
+ alignment: z12.enum(["start", "end", "space-between"]).optional(),
15158
+ density: z12.enum(["compact", "default", "comfortable"]).optional()
15159
+ }).strict();
15160
+ var TenantApplicationConfigSchema = z12.object({
15161
+ theme: z12.object({
15162
+ id: z12.string().optional(),
15163
+ name: z12.string().optional(),
15164
+ title: z12.string().optional(),
13364
15165
  favicon: AssetVariantsSchema.optional(),
13365
15166
  logo: AssetVariantsSchema.optional(),
13366
- pwaIcon: z11.string().optional(),
13367
- form: z11.object({ variant: z11.enum(["bento", "ghost"]) }).strict().optional(),
13368
- toast: z11.object({
13369
- position: z11.enum(["top-right", "top-left", "bottom-right", "bottom-left", "top-center", "bottom-center"])
15167
+ pwaIcon: z12.string().optional(),
15168
+ form: z12.object({ variant: z12.enum(["bento", "ghost"]) }).strict().optional(),
15169
+ toast: z12.object({
15170
+ position: z12.enum(["top-right", "top-left", "bottom-right", "bottom-left", "top-center", "bottom-center"])
15171
+ }).strict().optional(),
15172
+ icons: z12.object({
15173
+ error: CustomIconSchema.optional(),
15174
+ empty: CustomIconSchema.optional()
13370
15175
  }).strict().optional(),
13371
- icons: z11.object({ error: CustomIconSchema.optional(), empty: CustomIconSchema.optional() }).strict().optional(),
13372
- views: z11.object({
13373
- form: z11.object({
13374
- toast: z11.object({ afterCreate: z11.boolean(), afterDelete: z11.boolean() }).strict(),
13375
- progress: z11.enum(["estimate", "infinite"]),
13376
- onlyResult: z11.boolean(),
13377
- tabular: z11.object({ theme: z11.enum(["default", "tentiary", "primary"]) }).strict()
15176
+ views: z12.object({
15177
+ form: z12.object({
15178
+ toast: z12.object({
15179
+ afterCreate: z12.boolean(),
15180
+ afterDelete: z12.boolean()
15181
+ }).strict(),
15182
+ progress: z12.enum(["estimate", "infinite"]),
15183
+ onlyResult: z12.boolean(),
15184
+ tabular: z12.object({ theme: z12.enum(["default", "tentiary", "primary"]) }).strict()
13378
15185
  }).strict()
13379
15186
  }).strict().optional(),
13380
15187
  loginPage: LoginPageSchema.optional(),
13381
- extraLanguageURL: z11.record(z11.string(), z11.string()).optional(),
13382
- hideSpaceHeader: z11.boolean().optional(),
13383
- showSidebarTeamSelector: z11.boolean().optional(),
13384
- showWorkbenchSidebar: z11.boolean().optional(),
13385
- workbenchViewTheme: z11.enum(["default", "bsd-blue"]).optional(),
13386
- defaults: z11.object({
13387
- showFormInImageDetail: z11.boolean().optional(),
13388
- darkMode: z11.enum(["light", "dark", "auto"]).optional(),
13389
- language: z11.enum(["en-US", "zh-CN", "ja-JP"]).optional(),
13390
- showDarkModeToggle: z11.boolean().optional(),
13391
- showLanguageToggle: z11.boolean().optional()
15188
+ extraLanguageURL: z12.record(z12.string(), z12.string()).optional(),
15189
+ hideSpaceHeader: z12.boolean().optional(),
15190
+ showSidebarTeamSelector: z12.boolean().optional(),
15191
+ showWorkbenchSidebar: z12.boolean().optional(),
15192
+ workbenchViewTheme: z12.enum(["default", "bsd-blue"]).optional(),
15193
+ defaults: z12.object({
15194
+ showFormInImageDetail: z12.boolean().optional(),
15195
+ darkMode: z12.enum(["light", "dark", "auto"]).optional(),
15196
+ language: z12.enum(["en-US", "zh-CN", "ja-JP"]).optional(),
15197
+ showDarkModeToggle: z12.boolean().optional(),
15198
+ showLanguageToggle: z12.boolean().optional()
13392
15199
  }).strict().optional(),
13393
- modules: z11.object({
13394
- monkeysSpaceSidebar: z11.union([z11.literal("*"), z11.array(ContractIdentifierSchema)]).optional(),
13395
- monkeysSpaceHeadbar: z11.union([
13396
- z11.literal("*"),
13397
- z11.array(TenantHeadbarModuleItemSchema)
13398
- ]).optional(),
13399
- settingsSidebar: z11.union([z11.literal("*"), z11.array(ContractIdentifierSchema)]).optional()
15200
+ modules: z12.object({
15201
+ monkeysSpaceSidebar: z12.union([z12.literal("*"), z12.array(ContractIdentifierSchema)]).optional(),
15202
+ monkeysSpaceHeadbar: z12.union([z12.literal("*"), z12.array(TenantHeadbarModuleItemSchema)]).optional(),
15203
+ settingsSidebar: z12.union([z12.literal("*"), z12.array(ContractIdentifierSchema)]).optional()
13400
15204
  }).strict().optional(),
13401
15205
  headbar: ThemeHeadbarSchema.optional(),
13402
- kernelLayout: z11.object({
13403
- navigationMode: z11.enum(["sidebar", "topbar"]).optional(),
13404
- allowNavigationModeSwitch: z11.boolean().optional(),
15206
+ kernelLayout: z12.object({
15207
+ navigationMode: z12.enum(["sidebar", "topbar"]).optional(),
15208
+ allowNavigationModeSwitch: z12.boolean().optional(),
13405
15209
  headbar: KernelHeadbarSchema.optional()
13406
15210
  }).strict().optional(),
13407
- paginationPosition: z11.enum(["left", "right"]).optional(),
15211
+ paginationPosition: z12.enum(["left", "right"]).optional(),
13408
15212
  listFooter: TenantListFooterConfigSchema.optional(),
13409
- ugcViewIconOnlyMode: z11.boolean().optional(),
13410
- workflowPreviewExecutionGrid: z11.object({
13411
- selectionModeDisplayType: z11.enum(["operation-button", "dropdown-menu"]).optional(),
13412
- clickBehavior: z11.enum(["preview", "select", "fill-form", "none"]).optional(),
13413
- showErrorFilter: z11.boolean().optional(),
13414
- displayType: z11.enum(["grid", "masonry"]).optional(),
13415
- showDetailButton: z11.boolean().optional(),
13416
- aspectRatio: z11.enum(["1:1", "4:3", "3:4", "16:9", "9:16"]).optional()
15213
+ ugcViewIconOnlyMode: z12.boolean().optional(),
15214
+ workflowPreviewExecutionGrid: z12.object({
15215
+ selectionModeDisplayType: z12.enum(["operation-button", "dropdown-menu"]).optional(),
15216
+ clickBehavior: z12.enum(["preview", "select", "fill-form", "none"]).optional(),
15217
+ showErrorFilter: z12.boolean().optional(),
15218
+ displayType: z12.enum(["grid", "masonry"]).optional(),
15219
+ showDetailButton: z12.boolean().optional(),
15220
+ aspectRatio: z12.enum(["1:1", "4:3", "3:4", "16:9", "9:16"]).optional()
13417
15221
  }).strict().optional(),
13418
- workbenchSidebarDefaultOpen: z11.boolean().optional(),
13419
- workbenchSidebarMoreAction: z11.boolean().optional(),
13420
- workbenchSidebarApart: z11.boolean().optional(),
13421
- workbenchSidebarToggleGroupDetail: z11.boolean().optional(),
13422
- workbenchSidebarViewType: z11.boolean().optional(),
13423
- workbenchSidebarFormViewEmbed: z11.boolean().optional(),
13424
- workbenchSidebarModernMode: z11.boolean().optional(),
13425
- ugc: z11.object({ onItemClick: z11.boolean(), subtitle: z11.boolean().optional() }).strict().optional(),
13426
- uniImagePreview: z11.boolean().optional(),
13427
- imagePreviewStyle: z11.union([z11.literal(false), z11.enum(["simple", "normal", "uni"])]).optional(),
13428
- teamAsUser: z11.boolean().optional(),
13429
- themeMode: z11.enum(["shadow", "border"]).optional(),
13430
- density: z11.enum(["compact", "default", "comfortable"]).optional(),
13431
- statusStates: z11.object({
13432
- loading: z11.object({ variant: z11.enum(["spinner", "skeleton"]).optional() }).strict().optional(),
13433
- empty: z11.object({ variant: z11.enum(["default", "compact"]).optional() }).strict().optional(),
13434
- error: z11.object({ showRetry: z11.boolean().optional() }).strict().optional(),
13435
- permission: z11.object({ showRequestAccess: z11.boolean().optional() }).strict().optional(),
13436
- density: z11.enum(["compact", "default", "comfortable"]).optional()
15222
+ workbenchSidebarDefaultOpen: z12.boolean().optional(),
15223
+ workbenchSidebarMoreAction: z12.boolean().optional(),
15224
+ workbenchSidebarApart: z12.boolean().optional(),
15225
+ workbenchSidebarToggleGroupDetail: z12.boolean().optional(),
15226
+ workbenchSidebarViewType: z12.boolean().optional(),
15227
+ workbenchSidebarFormViewEmbed: z12.boolean().optional(),
15228
+ workbenchSidebarModernMode: z12.boolean().optional(),
15229
+ ugc: z12.object({
15230
+ onItemClick: z12.boolean(),
15231
+ subtitle: z12.boolean().optional()
13437
15232
  }).strict().optional(),
13438
- pageZoom: z11.number().positive().optional(),
13439
- miniMode: z11.object({ showPreviewViewExecutionResultGrid: z11.boolean() }).strict().optional(),
13440
- workflow: z11.object({ allowConcurrentRuns: z11.boolean() }).strict().optional(),
13441
- historyResult: z11.object({ display: z11.boolean() }).strict().optional(),
13442
- uploader: z11.object({
13443
- orientation: z11.enum(["vertical", "horizontal"]),
13444
- pasteButton: z11.boolean(),
13445
- statusText: z11.boolean()
15233
+ uniImagePreview: z12.boolean().optional(),
15234
+ imagePreviewStyle: z12.union([z12.literal(false), z12.enum(["simple", "normal", "uni"])]).optional(),
15235
+ teamAsUser: z12.boolean().optional(),
15236
+ themeMode: z12.enum(["shadow", "border"]).optional(),
15237
+ density: z12.enum(["compact", "default", "comfortable"]).optional(),
15238
+ statusStates: z12.object({
15239
+ loading: z12.object({ variant: z12.enum(["spinner", "skeleton"]).optional() }).strict().optional(),
15240
+ empty: z12.object({ variant: z12.enum(["default", "compact"]).optional() }).strict().optional(),
15241
+ error: z12.object({ showRetry: z12.boolean().optional() }).strict().optional(),
15242
+ permission: z12.object({ showRequestAccess: z12.boolean().optional() }).strict().optional(),
15243
+ density: z12.enum(["compact", "default", "comfortable"]).optional()
13446
15244
  }).strict().optional(),
13447
- designProjects: z11.object({
13448
- oneOnOne: z11.boolean(),
13449
- newTabOpenBoard: z11.boolean(),
13450
- defaultShowGrid: z11.boolean().optional(),
13451
- createDefaultFrame: z11.boolean(),
13452
- showPageMenu: z11.boolean(),
13453
- showMainMenu: z11.boolean(),
13454
- showStylePanel: z11.boolean(),
13455
- showToolbar: z11.boolean(),
13456
- toolbarPosition: z11.enum(["bottom", "left"]).optional(),
13457
- showContextMenu: z11.boolean(),
13458
- showActionsMenu: z11.boolean(),
13459
- showPageAndLayerSidebar: z11.boolean().optional(),
13460
- showBoardOperationSidebar: z11.boolean().optional(),
13461
- showMiniToolsToolbar: z11.boolean().optional(),
13462
- showRightSidebar: z11.boolean().optional(),
13463
- showRealtimeDrawing: z11.boolean().optional(),
13464
- showWorkflow: z11.boolean().optional(),
13465
- showVersionManager: z11.boolean().optional(),
13466
- showAgent: z11.boolean().optional(),
13467
- AgentTools: z11.array(ContractIdentifierSchema).optional()
15245
+ pageZoom: z12.number().positive().optional(),
15246
+ miniMode: z12.object({ showPreviewViewExecutionResultGrid: z12.boolean() }).strict().optional(),
15247
+ workflow: z12.object({ allowConcurrentRuns: z12.boolean() }).strict().optional(),
15248
+ historyResult: z12.object({ display: z12.boolean() }).strict().optional(),
15249
+ uploader: z12.object({
15250
+ orientation: z12.enum(["vertical", "horizontal"]),
15251
+ pasteButton: z12.boolean(),
15252
+ statusText: z12.boolean()
15253
+ }).strict().optional(),
15254
+ designProjects: z12.object({
15255
+ oneOnOne: z12.boolean(),
15256
+ newTabOpenBoard: z12.boolean(),
15257
+ defaultShowGrid: z12.boolean().optional(),
15258
+ createDefaultFrame: z12.boolean(),
15259
+ showPageMenu: z12.boolean(),
15260
+ showMainMenu: z12.boolean(),
15261
+ showStylePanel: z12.boolean(),
15262
+ showToolbar: z12.boolean(),
15263
+ toolbarPosition: z12.enum(["bottom", "left"]).optional(),
15264
+ showContextMenu: z12.boolean(),
15265
+ showActionsMenu: z12.boolean(),
15266
+ showPageAndLayerSidebar: z12.boolean().optional(),
15267
+ showBoardOperationSidebar: z12.boolean().optional(),
15268
+ showMiniToolsToolbar: z12.boolean().optional(),
15269
+ showRightSidebar: z12.boolean().optional(),
15270
+ showRealtimeDrawing: z12.boolean().optional(),
15271
+ showWorkflow: z12.boolean().optional(),
15272
+ showVersionManager: z12.boolean().optional(),
15273
+ showAgent: z12.boolean().optional(),
15274
+ AgentTools: z12.array(ContractIdentifierSchema).optional()
13468
15275
  }).strict().optional(),
13469
15276
  workbench: TenantWorkbenchConfigSchema.optional(),
13470
- visionProWorkflows: z11.array(ContractIdentifierSchema).optional(),
13471
- initTeam: z11.boolean().optional(),
13472
- imageThumbnail: z11.boolean().optional(),
13473
- pages: z11.object({
13474
- allowPageKeys: z11.union([z11.literal("*"), z11.array(ContractIdentifierSchema)]),
15277
+ visionProWorkflows: z12.array(ContractIdentifierSchema).optional(),
15278
+ initTeam: z12.boolean().optional(),
15279
+ imageThumbnail: z12.boolean().optional(),
15280
+ pages: z12.object({
15281
+ allowPageKeys: z12.union([z12.literal("*"), z12.array(ContractIdentifierSchema)]),
13475
15282
  defaultPageKey: ContractIdentifierSchema.optional(),
13476
- homeEntryEnabled: z11.boolean().optional()
15283
+ homeEntryEnabled: z12.boolean().optional()
13477
15284
  }).strict().optional(),
13478
15285
  agent: TenantAgentThemeConfigSchema.optional()
13479
15286
  }).strict(),
13480
15287
  landingPage: TenantLandingPageConfigSchema.optional(),
13481
- auth: z11.object({
13482
- enabled: z11.array(ContractIdentifierSchema).default([]),
13483
- oidc: z11.object({ buttonText: z11.string().optional(), autoSignin: z11.boolean().optional() }).strict().optional(),
13484
- password: z11.object({
13485
- registrationEnabled: z11.boolean().optional(),
13486
- disableAutoRegister: z11.boolean().optional()
15288
+ auth: z12.object({
15289
+ enabled: z12.array(ContractIdentifierSchema).default([]),
15290
+ oidc: z12.object({
15291
+ buttonText: z12.string().optional(),
15292
+ autoSignin: z12.boolean().optional()
15293
+ }).strict().optional(),
15294
+ password: z12.object({
15295
+ registrationEnabled: z12.boolean().optional(),
15296
+ disableAutoRegister: z12.boolean().optional()
13487
15297
  }).strict().optional(),
13488
- registrationApproval: z11.object({
13489
- enabled: z11.boolean().optional()
15298
+ registrationApproval: z12.object({
15299
+ enabled: z12.boolean().optional()
13490
15300
  }).strict().optional(),
13491
- hideAuthToast: z11.boolean().optional(),
13492
- autoReload: z11.boolean().optional(),
13493
- defaultOtherTeam: z11.boolean().optional()
15301
+ hideAuthToast: z12.boolean().optional(),
15302
+ autoReload: z12.boolean().optional(),
15303
+ defaultOtherTeam: z12.boolean().optional()
13494
15304
  }).strict(),
13495
- endpoints: z11.record(ContractIdentifierSchema, z11.string()),
13496
- module: z11.union([z11.literal("*"), z11.array(ContractIdentifierSchema)]),
13497
- behavior: z11.object({
13498
- clearWorkflowFormStorageAfterUpdate: z11.boolean().optional(),
13499
- autoApproveOAuth: z11.boolean().optional(),
13500
- rememberWorkflowModelSelection: z11.boolean().optional()
15305
+ endpoints: z12.record(ContractIdentifierSchema, z12.string()),
15306
+ module: z12.union([z12.literal("*"), z12.array(ContractIdentifierSchema)]),
15307
+ behavior: z12.object({
15308
+ clearWorkflowFormStorageAfterUpdate: z12.boolean().optional(),
15309
+ autoApproveOAuth: z12.boolean().optional(),
15310
+ rememberWorkflowModelSelection: z12.boolean().optional()
13501
15311
  }).strict(),
13502
- dataManagement: z11.object({
13503
- favoriteOntologyId: z11.string().optional(),
13504
- pairedOntologyId: z11.string().optional(),
13505
- galleryOntologyIds: z11.array(ContractIdentifierSchema).max(20).optional(),
13506
- galleryOntologyId: z11.string().optional(),
13507
- dataBrowserDefaultOntologyId: z11.string().optional(),
13508
- workflowResultOntologyId: z11.string().optional(),
13509
- homeAdvertisement: z11.object({
15312
+ dataManagement: z12.object({
15313
+ favoriteOntologyId: z12.string().optional(),
15314
+ pairedOntologyId: z12.string().optional(),
15315
+ galleryOntologyIds: z12.array(ContractIdentifierSchema).max(20).optional(),
15316
+ galleryOntologyId: z12.string().optional(),
15317
+ dataBrowserDefaultOntologyId: z12.string().optional(),
15318
+ workflowResultOntologyId: z12.string().optional(),
15319
+ homeAdvertisement: z12.object({
15320
+ ontologyId: ContractIdentifierSchema,
15321
+ viewId: ContractIdentifierSchema.optional(),
15322
+ viewType: z12.enum(["filter", "container", "share_link"]).optional(),
15323
+ teamId: ContractIdentifierSchema.optional(),
15324
+ teamOnly: z12.boolean().optional(),
15325
+ pageSize: z12.number().int().positive().optional(),
15326
+ sortBy: z12.enum(["pin_order", "asset_id", "updated_timestamp", "created_timestamp"]).optional(),
15327
+ sortOrder: z12.enum(["asc", "desc"]).optional(),
15328
+ fieldMap: z12.record(z12.string(), z12.string()).optional(),
15329
+ columnIds: z12.record(z12.string(), z12.string()).optional()
15330
+ }).strict().optional(),
15331
+ homeShortcutBackground: z12.object({
13510
15332
  ontologyId: ContractIdentifierSchema,
13511
15333
  viewId: ContractIdentifierSchema.optional(),
13512
- viewType: z11.enum(["filter", "container", "share_link"]).optional(),
15334
+ viewType: z12.enum(["filter", "container", "share_link"]).optional(),
13513
15335
  teamId: ContractIdentifierSchema.optional(),
13514
- teamOnly: z11.boolean().optional(),
13515
- pageSize: z11.number().int().positive().optional(),
13516
- sortBy: z11.enum(["pin_order", "asset_id", "updated_timestamp", "created_timestamp"]).optional(),
13517
- sortOrder: z11.enum(["asc", "desc"]).optional(),
13518
- fieldMap: z11.record(z11.string(), z11.string()).optional(),
13519
- columnIds: z11.record(z11.string(), z11.string()).optional()
15336
+ teamOnly: z12.boolean().optional(),
15337
+ pageSize: z12.number().int().positive().optional(),
15338
+ sortBy: z12.enum(["pin_order", "asset_id", "updated_timestamp"]).optional(),
15339
+ sortOrder: z12.enum(["asc", "desc"]).optional(),
15340
+ fieldMap: z12.record(z12.string(), z12.string()).optional(),
15341
+ columnIds: z12.record(z12.string(), z12.string()).optional()
13520
15342
  }).strict().optional(),
13521
- homeTrendAssistant: z11.object({
15343
+ homeTrendAssistant: z12.object({
13522
15344
  ontologyId: ContractIdentifierSchema.optional(),
13523
15345
  viewId: ContractIdentifierSchema.optional(),
13524
15346
  viewInstanceId: ContractIdentifierSchema.optional(),
13525
- viewName: z11.string().optional(),
15347
+ viewName: z12.string().optional(),
13526
15348
  teamId: ContractIdentifierSchema.optional(),
13527
15349
  designOptionsWorkflowId: ContractIdentifierSchema.optional(),
13528
- tep: z11.object({ baseUrl: z11.string().optional(), timeoutMs: z11.number().int().positive().optional() }).strict().optional(),
13529
- runtime: z11.object({ appId: ContractIdentifierSchema, tepBaseUrlConfigured: z11.boolean(), tepAuthorizationConfigured: z11.boolean(), tepCookieConfigured: z11.boolean() }).strict().optional()
15350
+ tep: z12.object({
15351
+ baseUrl: z12.string().optional(),
15352
+ timeoutMs: z12.number().int().positive().optional()
15353
+ }).strict().optional(),
15354
+ runtime: z12.object({
15355
+ appId: ContractIdentifierSchema,
15356
+ tepBaseUrlConfigured: z12.boolean(),
15357
+ tepAuthorizationConfigured: z12.boolean(),
15358
+ tepCookieConfigured: z12.boolean()
15359
+ }).strict().optional()
13530
15360
  }).strict().optional(),
13531
- staticTrendReport: z11.object({
15361
+ staticTrendReport: z12.object({
13532
15362
  ontologyId: ContractIdentifierSchema,
13533
15363
  viewId: ContractIdentifierSchema.optional(),
13534
15364
  teamId: ContractIdentifierSchema.optional()
13535
15365
  }).strict().optional(),
13536
15366
  trendRadar: TenantTrendRadarSourcesSchema.optional(),
13537
- sharing: z11.object({
13538
- silentViewLinks: z11.object({ enabled: z11.boolean().optional(), placement: z11.object({ mode: z11.enum(["sourceOntology", "ontology"]).optional(), ontologyId: ContractIdentifierSchema.optional(), parentId: ContractIdentifierSchema.optional(), navId: ContractIdentifierSchema.optional() }).strict().optional() }).strict().optional(),
13539
- 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(),
13540
- shareDialog: z11.object({
13541
- 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(),
13542
- accessLevel: z11.object({ enabled: z11.boolean().optional(), allowed: z11.array(z11.enum(["read", "write"])).optional(), default: z11.enum(["read", "write"]).optional() }).strict().optional(),
13543
- viewTreeDelivery: z11.object({ enabled: z11.boolean().optional(), allowed: z11.array(z11.enum(["manual", "auto"])).optional(), default: z11.enum(["manual", "auto"]).optional() }).strict().optional()
15367
+ sharing: z12.object({
15368
+ silentViewLinks: z12.object({
15369
+ enabled: z12.boolean().optional(),
15370
+ placement: z12.object({
15371
+ mode: z12.enum(["sourceOntology", "ontology"]).optional(),
15372
+ ontologyId: ContractIdentifierSchema.optional(),
15373
+ parentId: ContractIdentifierSchema.optional(),
15374
+ navId: ContractIdentifierSchema.optional()
15375
+ }).strict().optional()
15376
+ }).strict().optional(),
15377
+ shareAccess: z12.object({
15378
+ publicLinksEnabled: z12.boolean().optional(),
15379
+ passwordGateEnabled: z12.boolean().optional(),
15380
+ passwordAccessTtlSeconds: z12.number().int().positive().optional(),
15381
+ defaultViewTreeDelivery: z12.enum(["manual", "auto"]).optional()
15382
+ }).strict().optional(),
15383
+ shareDialog: z12.object({
15384
+ audience: z12.object({
15385
+ enabled: z12.boolean().optional(),
15386
+ allowed: z12.array(z12.enum(["user", "team", "public"])).optional(),
15387
+ default: z12.enum(["user", "team", "public"]).optional()
15388
+ }).strict().optional(),
15389
+ accessLevel: z12.object({
15390
+ enabled: z12.boolean().optional(),
15391
+ allowed: z12.array(z12.enum(["read", "write"])).optional(),
15392
+ default: z12.enum(["read", "write"]).optional()
15393
+ }).strict().optional(),
15394
+ viewTreeDelivery: z12.object({
15395
+ enabled: z12.boolean().optional(),
15396
+ allowed: z12.array(z12.enum(["manual", "auto"])).optional(),
15397
+ default: z12.enum(["manual", "auto"]).optional()
15398
+ }).strict().optional()
13544
15399
  }).strict().optional()
13545
15400
  }).strict().optional()
13546
15401
  }).strict().optional(),
13547
- kernelRuntime: z11.object({
13548
- integrations: z11.object({
13549
- 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(),
13550
- 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(),
13551
- 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()
15402
+ kernelRuntime: z12.object({
15403
+ integrations: z12.object({
15404
+ harbor: z12.object({
15405
+ endpoint: z12.string().optional(),
15406
+ projectScopes: z12.array(z12.string()).optional(),
15407
+ authMode: z12.string().optional(),
15408
+ principal: z12.string().optional(),
15409
+ autoSync: z12.boolean().optional(),
15410
+ proxyUrl: z12.string().optional()
15411
+ }).strict().optional(),
15412
+ gitlab: z12.object({
15413
+ baseUrl: z12.string().optional(),
15414
+ groupScopes: z12.array(z12.string()).optional(),
15415
+ tokenMode: z12.string().optional(),
15416
+ deployProjectPath: z12.string().optional(),
15417
+ deploymentReportsEnabled: z12.boolean().optional(),
15418
+ proxyUrl: z12.string().optional()
15419
+ }).strict().optional(),
15420
+ kubernetes: z12.object({
15421
+ accessMode: z12.string().optional(),
15422
+ clusterAlias: z12.string().optional(),
15423
+ agentProjectPath: z12.string().optional(),
15424
+ agentName: z12.string().optional(),
15425
+ namespaceScopes: z12.array(z12.string()).optional(),
15426
+ rolloutObserverEnabled: z12.boolean().optional(),
15427
+ proxyUrl: z12.string().optional()
15428
+ }).strict().optional()
13552
15429
  }).strict().optional()
13553
15430
  }).strict().optional(),
13554
- data: z11.object({}).strict().optional(),
13555
- storage: z11.object({
13556
- presignMode: z11.enum(["frontend", "backend", "both"]).optional(),
13557
- presign: z11.object({
13558
- expiresInSeconds: z11.number().int().positive(),
13559
- buckets: z11.array(
13560
- z11.object({
15431
+ data: z12.object({}).strict().optional(),
15432
+ storage: z12.object({
15433
+ presignMode: z12.enum(["frontend", "backend", "both"]).optional(),
15434
+ presign: z12.object({
15435
+ expiresInSeconds: z12.number().int().positive(),
15436
+ buckets: z12.array(
15437
+ z12.object({
13561
15438
  id: ContractIdentifierSchema,
13562
15439
  provider: ContractIdentifierSchema,
13563
15440
  preferredUrlPatternId: ContractIdentifierSchema,
13564
- urlPatterns: z11.array(
13565
- z11.object({
15441
+ urlPatterns: z12.array(
15442
+ z12.object({
13566
15443
  id: ContractIdentifierSchema,
13567
- type: z11.enum(["bucket-hostname", "provider-hostname"]),
13568
- hostname: z11.string().trim().min(1),
13569
- preferred: z11.boolean().optional(),
13570
- bucketSegment: z11.string().optional()
15444
+ type: z12.enum(["bucket-hostname", "provider-hostname"]),
15445
+ hostname: z12.string().trim().min(1),
15446
+ preferred: z12.boolean().optional(),
15447
+ bucketSegment: z12.string().optional()
13571
15448
  }).strict()
13572
15449
  )
13573
15450
  }).strict()
13574
15451
  )
13575
15452
  }).strict().optional()
13576
15453
  }).strict().optional(),
13577
- monkeyData: z11.object({ baseUrl: z11.string().optional() }).strict().optional()
15454
+ monkeyData: z12.object({ baseUrl: z12.string().optional() }).strict().optional()
13578
15455
  }).strict();
13579
- var TenantProductConfigSchema = z11.object({
13580
- contract: z11.literal("TenantProductConfig"),
15456
+ var TenantProductConfigSchema = z12.object({
15457
+ contract: z12.literal("TenantProductConfig"),
13581
15458
  tenantId: ContractIdentifierSchema,
13582
15459
  appId: ContractIdentifierSchema,
13583
15460
  environment: ContractIdentifierSchema,
13584
15461
  designTokens: TenantDesignTokensConfigSchema,
13585
- moduleRefs: z11.array(ContractIdentifierSchema).default([]),
13586
- pageRefs: z11.array(ContractIdentifierSchema).default([]),
13587
- featureFlags: z11.record(z11.string(), z11.boolean()).default({}),
15462
+ moduleRefs: z12.array(ContractIdentifierSchema).default([]),
15463
+ pageRefs: z12.array(ContractIdentifierSchema).default([]),
15464
+ featureFlags: z12.record(z12.string(), z12.boolean()).default({}),
13588
15465
  authBinding: TenantAuthBindingsSchema,
13589
15466
  dataBinding: TenantDataBindingsSchema,
13590
- sourceMap: z11.record(z11.string(), ContractIdentifierSchema),
13591
- warnings: z11.array(z11.string()).default([]),
15467
+ sourceMap: z12.record(z12.string(), ContractIdentifierSchema),
15468
+ warnings: z12.array(z12.string()).default([]),
13592
15469
  menus: MenuDefinitionSetSchema.optional(),
13593
15470
  applicationConfig: TenantApplicationConfigSchema
13594
15471
  }).strict();
13595
- var TenantRuntimeConfigSchema = z11.object({
13596
- contract: z11.literal("TenantRuntimeConfig"),
15472
+ var TenantRuntimeConfigSchema = z12.object({
15473
+ contract: z12.literal("TenantRuntimeConfig"),
13597
15474
  tenantId: ContractIdentifierSchema,
13598
15475
  appId: ContractIdentifierSchema,
13599
15476
  environment: ContractIdentifierSchema,
13600
15477
  designTokens: ResolvedThemeTokensSchema,
13601
- moduleRefs: z11.array(ContractIdentifierSchema).default([]),
13602
- pageRefs: z11.array(ContractIdentifierSchema).default([]),
13603
- featureFlags: z11.record(z11.string(), z11.boolean()).default({}),
15478
+ moduleRefs: z12.array(ContractIdentifierSchema).default([]),
15479
+ pageRefs: z12.array(ContractIdentifierSchema).default([]),
15480
+ featureFlags: z12.record(z12.string(), z12.boolean()).default({}),
13604
15481
  authBinding: TenantAuthBindingsSchema,
13605
15482
  dataBinding: TenantDataBindingsSchema,
13606
- sourceMap: z11.record(z11.string(), ContractIdentifierSchema),
13607
- warnings: z11.array(z11.string()).default([]),
15483
+ sourceMap: z12.record(z12.string(), ContractIdentifierSchema),
15484
+ warnings: z12.array(z12.string()).default([]),
13608
15485
  menuBundle: MenuRuntimeBundleSchema.optional(),
13609
15486
  applicationConfig: TenantApplicationConfigSchema
13610
15487
  }).strict();
@@ -13880,8 +15757,8 @@ var compileWorkflowPersistenceProjection = (input) => {
13880
15757
  };
13881
15758
 
13882
15759
  // src/contracts/access.ts
13883
- import { z as z12 } from "zod";
13884
- var PermissionDefinitionSchema = z12.object({
15760
+ import { z as z13 } from "zod";
15761
+ var PermissionDefinitionSchema = z13.object({
13885
15762
  code: ContractIdentifierSchema,
13886
15763
  name: LocalizedTextSchema,
13887
15764
  description: LocalizedTextSchema.optional(),
@@ -13889,29 +15766,29 @@ var PermissionDefinitionSchema = z12.object({
13889
15766
  action: ContractIdentifierSchema,
13890
15767
  domain: ContractIdentifierSchema.optional()
13891
15768
  }).strict();
13892
- var PermissionBundleSchema = z12.object({
15769
+ var PermissionBundleSchema = z13.object({
13893
15770
  bundleId: ContractIdentifierSchema,
13894
15771
  name: LocalizedTextSchema,
13895
- permissionCodes: z12.array(ContractIdentifierSchema).default([])
15772
+ permissionCodes: z13.array(ContractIdentifierSchema).default([])
13896
15773
  }).strict();
13897
- var SystemGroupDefinitionSchema = z12.object({
15774
+ var SystemGroupDefinitionSchema = z13.object({
13898
15775
  groupCode: ContractIdentifierSchema,
13899
15776
  name: LocalizedTextSchema,
13900
15777
  description: LocalizedTextSchema.optional(),
13901
- permissionPolicy: z12.enum(["bundles", "studio_current", "all_current"]).default("bundles"),
13902
- permissionBundleIds: z12.array(ContractIdentifierSchema).default([])
15778
+ permissionPolicy: z13.enum(["bundles", "studio_current", "all_current"]).default("bundles"),
15779
+ permissionBundleIds: z13.array(ContractIdentifierSchema).default([])
13903
15780
  }).strict().refine((value) => value.permissionPolicy !== "bundles" || value.permissionBundleIds.length > 0, {
13904
15781
  message: "A bundles permission policy requires at least one permission bundle.",
13905
15782
  path: ["permissionBundleIds"]
13906
15783
  });
13907
- var ProductAccessDeclarationSchema = z12.object({
13908
- contract: z12.literal("ProductAccessDeclaration"),
15784
+ var ProductAccessDeclarationSchema = z13.object({
15785
+ contract: z13.literal("ProductAccessDeclaration"),
13909
15786
  declarationId: ContractIdentifierSchema,
13910
15787
  version: ContractVersionSchema,
13911
15788
  ownerRepo: ContractIdentifierSchema,
13912
- permissions: z12.array(PermissionDefinitionSchema).default([]),
13913
- permissionBundles: z12.array(PermissionBundleSchema).default([]),
13914
- systemGroups: z12.array(SystemGroupDefinitionSchema).min(1)
15789
+ permissions: z13.array(PermissionDefinitionSchema).default([]),
15790
+ permissionBundles: z13.array(PermissionBundleSchema).default([]),
15791
+ systemGroups: z13.array(SystemGroupDefinitionSchema).min(1)
13915
15792
  }).strict();
13916
15793
 
13917
15794
  // src/runtime/access-compiler.ts
@@ -13972,27 +15849,34 @@ var compileProductAccessDeclaration = (input) => {
13972
15849
  export {
13973
15850
  APPLICATION_HANDOFF_QUERY_PARAMETER,
13974
15851
  DEFAULT_CONDUCTOR_OWNER_EMAIL,
15852
+ DeclarativeControlCompilationError,
13975
15853
  MONKEYS_REQUIRED_THEME_TOKEN_PATHS,
13976
15854
  MenuCompilationError,
13977
15855
  ThemeTokenValidationError,
15856
+ accessPolicyChainImplies,
13978
15857
  applyViewRuntimeBindings,
13979
15858
  assertMonkeysThemeTokensComplete,
13980
15859
  assertThemeTokensDocumentStructure,
13981
15860
  buildApplicationHandoffUrl,
13982
15861
  buildChangeImpactGraph,
15862
+ canonicalContentHash,
13983
15863
  compileCapabilityRegistry,
13984
15864
  compileConductorWorkflowDefinition,
13985
15865
  compileMenuRuntimeBundle,
15866
+ compileNavigationRuntimeBundle,
15867
+ compilePageRuntimeBundle,
13986
15868
  compilePageRuntimeProjection,
13987
15869
  compileProductAccessDeclaration,
13988
15870
  compileProductDeclaration,
13989
15871
  compileProductRuntimeCatalog,
13990
15872
  compileRenderTree,
15873
+ compileRouteClaims,
13991
15874
  compileTenantRuntimeBindings,
13992
15875
  compileTenantRuntimeConfig,
13993
15876
  compileToolCapabilityManifest,
13994
15877
  compileViewProviderInput,
13995
15878
  compileViewProviderRegistry,
15879
+ compileWorkbenchRuntimeBundle,
13996
15880
  compileWorkflowDefinitionFromConductor,
13997
15881
  compileWorkflowPersistenceProjection,
13998
15882
  createAgentSessionEventProjection,
@@ -14000,8 +15884,15 @@ export {
14000
15884
  createOpenApiCapabilityRegistrySource,
14001
15885
  createToolCapabilityManifest,
14002
15886
  createWorkflowCapabilityManifest,
15887
+ declarativeCreateTemplateRevisionHash,
15888
+ declarativeCreateTemplateSourceHash,
15889
+ declarativeProductResourceRevisionHash,
15890
+ declarativeProductResourceSourceHash,
15891
+ declarativeRouteSpaceRevisionHash,
15892
+ declarativeRouteSpaceSourceHash,
14003
15893
  extractOpenApiCapabilityManifests,
14004
15894
  isCompiledMenuItemSelected,
15895
+ materializeRouteSpacePath,
14005
15896
  mergeThemeTokenDocuments,
14006
15897
  parseApplicationHandoff,
14007
15898
  projectAgentSessionEvents,
@@ -14010,11 +15901,17 @@ export {
14010
15901
  readMenuActivationFromSearch,
14011
15902
  resolveMenuActivationId,
14012
15903
  resolveThemeTokens,
15904
+ resolveWorkbenchEntry,
15905
+ revisionRefKey,
15906
+ sameRevisionRef,
15907
+ sameStableRef,
14013
15908
  serializeApplicationHandoff,
14014
15909
  serializeMenuActivationSearch,
15910
+ stableRefKey,
14015
15911
  toAgentSessionViewModel,
14016
15912
  validateDomainCommand,
14017
15913
  validateThemeTokensDocument,
14018
- validateThemeTokensDocumentStructure
15914
+ validateThemeTokensDocumentStructure,
15915
+ validateWorkbenchRuntimeSet
14019
15916
  };
14020
15917
  //# sourceMappingURL=index.mjs.map