@inf-monkeys-tech/monkeys 1.1.12 → 1.1.14

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 (46) hide show
  1. package/README.md +11 -1
  2. package/lib/contracts/declarative-control-http.d.ts +101 -0
  3. package/lib/contracts/declarative-control-http.d.ts.map +1 -1
  4. package/lib/contracts/declarative-control-http.js +5 -0
  5. package/lib/contracts/declarative-control-http.js.map +1 -1
  6. package/lib/contracts/declarative-control.d.ts +11 -0
  7. package/lib/contracts/declarative-control.d.ts.map +1 -1
  8. package/lib/contracts/declarative-control.js +3 -0
  9. package/lib/contracts/declarative-control.js.map +1 -1
  10. package/lib/contracts/declarative-publication-job.d.ts +24 -0
  11. package/lib/contracts/declarative-publication-job.d.ts.map +1 -1
  12. package/lib/contracts/render.d.ts +4 -0
  13. package/lib/contracts/render.d.ts.map +1 -1
  14. package/lib/contracts/render.js +2 -0
  15. package/lib/contracts/render.js.map +1 -1
  16. package/lib/esm/contracts/index.mjs +10 -0
  17. package/lib/esm/contracts/index.mjs.map +1 -1
  18. package/lib/esm/index.mjs +248 -9
  19. package/lib/esm/index.mjs.map +1 -1
  20. package/lib/esm/runtime/index.mjs +248 -9
  21. package/lib/esm/runtime/index.mjs.map +1 -1
  22. package/lib/esm/schemas/index.mjs +10 -0
  23. package/lib/esm/schemas/index.mjs.map +1 -1
  24. package/lib/json-schema/design-capability-catalog-artifact.schema.json +10 -0
  25. package/lib/json-schema/overlay-node.schema.json +5 -0
  26. package/lib/json-schema/page-runtime-bundle.schema.json +10 -0
  27. package/lib/json-schema/render-node.schema.json +5 -0
  28. package/lib/json-schema/render-tree.schema.json +5 -0
  29. package/lib/json-schema/view-provider-descriptor.schema.json +5 -0
  30. package/lib/json-schema/workbench-runtime-bundle.schema.json +10 -0
  31. package/lib/json-schema/workbench.schema.json +10 -0
  32. package/lib/runtime/declarative-control-compiler.d.ts +4 -0
  33. package/lib/runtime/declarative-control-compiler.d.ts.map +1 -1
  34. package/lib/runtime/declarative-control-compiler.js +29 -10
  35. package/lib/runtime/declarative-control-compiler.js.map +1 -1
  36. package/lib/runtime/declarative-runtime-contract.d.ts +45 -0
  37. package/lib/runtime/declarative-runtime-contract.d.ts.map +1 -0
  38. package/lib/runtime/declarative-runtime-contract.js +250 -0
  39. package/lib/runtime/declarative-runtime-contract.js.map +1 -0
  40. package/lib/runtime/index.d.ts +1 -0
  41. package/lib/runtime/index.d.ts.map +1 -1
  42. package/lib/runtime/index.js +1 -0
  43. package/lib/runtime/index.js.map +1 -1
  44. package/lib/schemas/index.d.ts +12 -0
  45. package/lib/schemas/index.d.ts.map +1 -1
  46. package/package.json +1 -1
@@ -7868,6 +7868,7 @@ var RenderNodeSchema = z3.object({
7868
7868
  semanticRef: EntityRefSchema.optional(),
7869
7869
  dataContextRef: EntityRefSchema.optional(),
7870
7870
  capabilityRef: EntityRefSchema,
7871
+ runtimeContractVersion: ContractIdentifierSchema.optional(),
7871
7872
  providerRef: EntityRefSchema.optional(),
7872
7873
  stateRef: EntityRefSchema.optional(),
7873
7874
  surface: RenderSurfaceSchema,
@@ -8033,6 +8034,7 @@ var ViewProviderDescriptorSchema = z3.object({
8033
8034
  contract: z3.literal("ViewProviderDescriptor"),
8034
8035
  providerId: ContractIdentifierSchema,
8035
8036
  providerVersion: ContractIdentifierSchema,
8037
+ runtimeContractVersion: ContractIdentifierSchema.optional(),
8036
8038
  ownerRepo: ContractIdentifierSchema,
8037
8039
  capabilityRef: EntityRefSchema,
8038
8040
  rendererKey: ContractIdentifierSchema,
@@ -12327,6 +12329,7 @@ var QueryBindingSchema = z13.object({
12327
12329
  }
12328
12330
  });
12329
12331
  var CapabilityInstanceSchema = z13.object({
12332
+ runtimeContractVersion: ContractIdentifierSchema.optional(),
12330
12333
  instanceId: ContractIdentifierSchema,
12331
12334
  nodeId: ContractIdentifierSchema,
12332
12335
  capabilityRevisionRef: RevisionRefSchema,
@@ -14180,6 +14183,7 @@ var WorkbenchGroupSchema = z13.object({
14180
14183
  accessPolicy: AccessPolicySchema.optional()
14181
14184
  }).strict();
14182
14185
  var WorkbenchAppInstanceSchema = z13.object({
14186
+ runtimeContractVersion: ContractIdentifierSchema.optional(),
14183
14187
  instanceId: ContractIdentifierSchema,
14184
14188
  kind: z13.enum([
14185
14189
  "built-in-application",
@@ -14225,6 +14229,7 @@ var WorkbenchSchema = z13.object({
14225
14229
  showDefaultGroup: z13.boolean()
14226
14230
  }).strict(),
14227
14231
  layout: z13.object({
14232
+ runtimeContractVersion: ContractIdentifierSchema.optional(),
14228
14233
  hostCapabilityRevisionRef: RevisionRefSchema,
14229
14234
  hostProviderRevisionRef: RevisionRefSchema,
14230
14235
  layoutPolicyRevisionRef: RevisionRefSchema,
@@ -15858,6 +15863,7 @@ var DeclarativeCapabilitySchemaDocumentSchema = z15.object({
15858
15863
  }
15859
15864
  });
15860
15865
  var DeclarativeCapabilityAuthoringRegistrationSchema = z15.object({
15866
+ runtimeContractVersion: ContractIdentifierSchema.optional(),
15861
15867
  registrationRevisionRef: RevisionRefSchema,
15862
15868
  capabilityRevisionRef: RevisionRefSchema,
15863
15869
  providerRevisionRef: RevisionRefSchema,
@@ -15984,6 +15990,9 @@ var ProductDeclarativeCapabilityRegistrationSchema = z15.object({
15984
15990
  declarativeRegistration: DeclarativeCapabilityAuthoringRegistrationSchema,
15985
15991
  requiredPermissionCodes: z15.array(ContractIdentifierSchema).default([])
15986
15992
  }).strict().superRefine((value, context) => {
15993
+ if (value.provider.runtimeContractVersion !== value.declarativeRegistration.runtimeContractVersion) {
15994
+ context.addIssue({ code: "custom", path: ["declarativeRegistration", "runtimeContractVersion"], message: "The authoring contract must match its runtime provider." });
15995
+ }
15987
15996
  const ownerRepo = value.manifest.ownerRepo;
15988
15997
  const registration = value.declarativeRegistration;
15989
15998
  if (ownerRepo === "monkeys-design") {
@@ -16498,6 +16507,7 @@ var DeclarativeBindingAuthoringChoiceSchema = DeclarativeAuthoringChoiceSchema.e
16498
16507
  }).strict()
16499
16508
  }).strict();
16500
16509
  var DeclarativeWorkbenchTargetChoiceSchema = z15.object({
16510
+ runtimeContractVersion: ContractIdentifierSchema.optional(),
16501
16511
  stableTargetRef: StableRefSchema,
16502
16512
  targetRevisionRef: RevisionRefSchema,
16503
16513
  providerRevisionRef: RevisionRefSchema,
@@ -17501,6 +17511,7 @@ var stableRefKey = (reference) => `${reference.visibility}:${reference.tenantSco
17501
17511
  var revisionRefKey = (reference) => `${stableRefKey(reference)}@${reference.revision}:v${reference.schemaVersion}:${reference.contentHash.toLowerCase()}`;
17502
17512
  var sameStableRef = (left, right) => stableRefKey(left) === stableRefKey(right);
17503
17513
  var sameRevisionRef = (left, right) => revisionRefKey(left) === revisionRefKey(right);
17514
+ var sameSchemaContract = (left, right) => left.kind === "schema" && right.kind === "schema" && sameStableRef(left, right) && left.schemaVersion === right.schemaVersion && left.contentHash === right.contentHash;
17504
17515
  var assertUniqueRegistryKeys = (keys, path) => {
17505
17516
  const seen = /* @__PURE__ */ new Set();
17506
17517
  keys.forEach((key, index) => {
@@ -17770,7 +17781,7 @@ var compileDesignCapabilityCatalogArtifact = (input) => {
17770
17781
  ...unsignedRegistration
17771
17782
  } = registration;
17772
17783
  const registrationHash = canonicalContentHash(unsignedRegistration);
17773
- if (registration.capabilityRevisionRef.id !== entry.manifest.id || registration.capabilityRevisionRef.ownerRepo !== entry.manifest.ownerRepo || String(registration.capabilityRevisionRef.revision) !== String(entry.manifest.capabilityVersion) || registration.capabilityRevisionRef.contentHash !== canonicalContentHash(entry.manifest) || registration.providerRevisionRef.id !== entry.provider.providerId || registration.providerRevisionRef.ownerRepo !== entry.provider.ownerRepo || String(registration.providerRevisionRef.revision) !== String(entry.provider.providerVersion) || registration.providerRevisionRef.contentHash !== canonicalContentHash(entry.provider) || registration.sourceContentHash !== registrationHash || registration.registrationRevisionRef.contentHash !== registrationHash) {
17784
+ if (registration.runtimeContractVersion !== entry.provider.runtimeContractVersion || registration.capabilityRevisionRef.id !== entry.manifest.id || registration.capabilityRevisionRef.ownerRepo !== entry.manifest.ownerRepo || String(registration.capabilityRevisionRef.revision) !== String(entry.manifest.capabilityVersion) || registration.capabilityRevisionRef.contentHash !== canonicalContentHash(entry.manifest) || registration.providerRevisionRef.id !== entry.provider.providerId || registration.providerRevisionRef.ownerRepo !== entry.provider.ownerRepo || String(registration.providerRevisionRef.revision) !== String(entry.provider.providerVersion) || registration.providerRevisionRef.contentHash !== canonicalContentHash(entry.provider) || registration.sourceContentHash !== registrationHash || registration.registrationRevisionRef.contentHash !== registrationHash) {
17774
17785
  throw new DeclarativeControlCompilationError(
17775
17786
  "DESIGN_CATALOG_INVALID",
17776
17787
  `entries[${index}]`,
@@ -18711,6 +18722,7 @@ var resolvePage = (input) => {
18711
18722
  version: 1,
18712
18723
  ownerRepo: input.pageOwnerRepo
18713
18724
  },
18725
+ ...registration.runtimeContractVersion ? { runtimeContractVersion: registration.runtimeContractVersion } : {},
18714
18726
  capabilityRef: simpleEntityRef(registration.revisionRef),
18715
18727
  providerRef: simpleEntityRef(registration.providerRevisionRef),
18716
18728
  surface: node.surface ?? defaultRenderSurface,
@@ -18725,6 +18737,7 @@ var resolvePage = (input) => {
18725
18737
  ...node.repeat ? { repeat: { ...node.repeat, limit: node.repeat.limit ?? 200 } } : {}
18726
18738
  });
18727
18739
  capabilityInstances.push({
18740
+ ...registration.runtimeContractVersion ? { runtimeContractVersion: registration.runtimeContractVersion } : {},
18728
18741
  instanceId: node.id,
18729
18742
  nodeId: node.id,
18730
18743
  capabilityRevisionRef: registration.revisionRef,
@@ -19274,6 +19287,9 @@ var compilePageRuntimeBundleInternal = (input, legacy) => {
19274
19287
  "Capability/provider pair has no exact governed Design registration."
19275
19288
  );
19276
19289
  }
19290
+ if (instance.runtimeContractVersion !== registration.runtimeContractVersion || node.runtimeContractVersion !== instance.runtimeContractVersion) {
19291
+ throw new DeclarativeControlCompilationError("CAPABILITY_BINDING_MISMATCH", `capabilityInstances[${index}].runtimeContractVersion`, "Runtime contract must be issued by the exact governed registration.");
19292
+ }
19277
19293
  if (instance.allowedSideEffects.some(
19278
19294
  (sideEffect) => !registration.allowedSideEffects.includes(sideEffect)
19279
19295
  )) {
@@ -19334,7 +19350,7 @@ var compilePageRuntimeBundleInternal = (input, legacy) => {
19334
19350
  const port = registration?.inputPorts.find(
19335
19351
  (candidate) => candidate.name === binding.target.port
19336
19352
  );
19337
- if (!port || !sameRevisionRef(
19353
+ if (!port || !sameSchemaContract(
19338
19354
  port.schemaRevisionRef,
19339
19355
  binding.renderModelSchemaRevisionRef
19340
19356
  )) {
@@ -19354,7 +19370,7 @@ var compilePageRuntimeBundleInternal = (input, legacy) => {
19354
19370
  const pageChangePort = sourceRegistration?.outputPorts.find(
19355
19371
  (candidate) => candidate.name === binding.cursorWindow.pageChangePort
19356
19372
  );
19357
- if (!pageChangePort || !sameRevisionRef(
19373
+ if (!pageChangePort || !sameSchemaContract(
19358
19374
  pageChangePort.schemaRevisionRef,
19359
19375
  binding.cursorWindow.pageChangeIntentSchemaRevisionRef
19360
19376
  )) {
@@ -19376,7 +19392,7 @@ var compilePageRuntimeBundleInternal = (input, legacy) => {
19376
19392
  const port = registration?.inputPorts.find(
19377
19393
  (candidate) => candidate.name === binding.target.port
19378
19394
  );
19379
- if (!port || !sameRevisionRef(
19395
+ if (!port || !sameSchemaContract(
19380
19396
  port.schemaRevisionRef,
19381
19397
  binding.targetProjection?.schemaRevisionRef ?? binding.renderModelSchemaRevisionRef
19382
19398
  )) {
@@ -19406,7 +19422,7 @@ var compilePageRuntimeBundleInternal = (input, legacy) => {
19406
19422
  const pageChangePort = sourceRegistration?.outputPorts.find(
19407
19423
  (candidate) => candidate.name === binding.cursorWindow.pageChangePort
19408
19424
  );
19409
- if (!pageChangePort || !sameRevisionRef(
19425
+ if (!pageChangePort || !sameSchemaContract(
19410
19426
  pageChangePort.schemaRevisionRef,
19411
19427
  binding.cursorWindow.pageChangeIntentSchemaRevisionRef
19412
19428
  )) {
@@ -19455,7 +19471,7 @@ var compilePageRuntimeBundleInternal = (input, legacy) => {
19455
19471
  const port = registration?.outputPorts.find(
19456
19472
  (candidate) => candidate.name === binding.source.port
19457
19473
  );
19458
- if (!port || !sameRevisionRef(
19474
+ if (!port || !sameSchemaContract(
19459
19475
  port.schemaRevisionRef,
19460
19476
  binding.sourceIntentSchemaRevisionRef
19461
19477
  )) {
@@ -19476,7 +19492,7 @@ var compilePageRuntimeBundleInternal = (input, legacy) => {
19476
19492
  const port = registration?.outputPorts.find(
19477
19493
  (candidate) => candidate.name === binding.source.port
19478
19494
  );
19479
- if (!port || !sameRevisionRef(
19495
+ if (!port || !sameSchemaContract(
19480
19496
  port.schemaRevisionRef,
19481
19497
  binding.sourceIntentSchemaRevisionRef
19482
19498
  )) {
@@ -19799,6 +19815,14 @@ var compileWorkbenchRuntimeBundle = (input) => {
19799
19815
  const groupsById = new Map(
19800
19816
  workbench.groups.map((group) => [group.groupId, group])
19801
19817
  );
19818
+ const contractFor = (capabilityRef, providerRef, declared) => {
19819
+ const registration = input.capabilityRegistry?.find((candidate) => sameRevisionRef(candidate.capabilityRevisionRef, capabilityRef) && sameRevisionRef(candidate.providerRevisionRef, providerRef));
19820
+ if (declared !== void 0 && declared !== registration?.runtimeContractVersion) {
19821
+ throw new DeclarativeControlCompilationError("CAPABILITY_BINDING_MISMATCH", "workbench.runtimeContractVersion", "Runtime contract must be issued by the exact governed registration.");
19822
+ }
19823
+ return registration?.runtimeContractVersion;
19824
+ };
19825
+ const layoutContract = contractFor(workbench.layout.hostCapabilityRevisionRef, workbench.layout.hostProviderRevisionRef, workbench.layout.runtimeContractVersion);
19802
19826
  const appInstances = workbench.appInstances.map((instance, index) => {
19803
19827
  const stableTarget = StableRefSchema.parse({
19804
19828
  kind: instance.targetRevisionRef.kind,
@@ -19839,7 +19863,8 @@ var compileWorkbenchRuntimeBundle = (input) => {
19839
19863
  "Workbench and instance audience is wider than the target audience."
19840
19864
  );
19841
19865
  }
19842
- return { ...instance, targetAccessPolicy: registration.accessPolicy };
19866
+ const runtimeContractVersion = contractFor(instance.targetRevisionRef, instance.providerRevisionRef, instance.runtimeContractVersion);
19867
+ return { ...instance, ...runtimeContractVersion ? { runtimeContractVersion } : {}, targetAccessPolicy: registration.accessPolicy };
19843
19868
  });
19844
19869
  const unsigned = {
19845
19870
  contract: "WorkbenchRuntimeBundle",
@@ -19862,7 +19887,7 @@ var compileWorkbenchRuntimeBundle = (input) => {
19862
19887
  groups: workbench.groups,
19863
19888
  appInstances,
19864
19889
  defaultEntry: workbench.defaultEntry,
19865
- layout: workbench.layout,
19890
+ layout: { ...workbench.layout, ...layoutContract ? { runtimeContractVersion: layoutContract } : {} },
19866
19891
  workbenchAccessPolicy: workbench.workbenchAccessPolicy,
19867
19892
  personalPreferencesPolicy: workbench.personalPreferencesPolicy,
19868
19893
  target: { ...release.target, routeClaim: releaseRoute },
@@ -24551,6 +24576,213 @@ var compileTenantRuntimeBindings = (config, policy) => {
24551
24576
  });
24552
24577
  };
24553
24578
 
24579
+ // src/runtime/declarative-runtime-contract.ts
24580
+ var assertViewProviderContract = (node, provider) => {
24581
+ if (node.capabilityRef.kind !== "capability" || node.providerRef?.kind !== "view-provider" || node.capabilityRef.id !== provider.capabilityRef.id || node.capabilityRef.ownerRepo !== provider.capabilityRef.ownerRepo || node.providerRef.id !== provider.providerId || node.providerRef.ownerRepo !== provider.ownerRepo) {
24582
+ throw new TypeError("Runtime capability and provider identities do not match their registered owners.");
24583
+ }
24584
+ if (node.runtimeContractVersion !== void 0) {
24585
+ if (node.runtimeContractVersion !== provider.runtimeContractVersion) {
24586
+ throw new TypeError("The provider does not implement the declared runtime contract.");
24587
+ }
24588
+ } else if (String(node.capabilityRef.version) !== String(provider.capabilityRef.version) || String(node.providerRef.version) !== provider.providerVersion) {
24589
+ throw new TypeError("An unversioned runtime contract requires an exact provider snapshot.");
24590
+ }
24591
+ };
24592
+ var supportsCapabilityInputSchema = (entry, reference, runtimeContractVersion, portName) => entry.declarativeRegistration.inputPorts.some((port) => (portName === void 0 || port.name === portName) && (sameSchemaContract(port.schemaRevisionRef, reference) || runtimeContractVersion !== void 0 && runtimeContractVersion === entry.provider.runtimeContractVersion && reference.schemaVersion === port.schemaRevisionRef.schemaVersion && sameStableRef(port.schemaRevisionRef, reference)));
24593
+ var assertDeclarativeCapabilityContract = (entry, request) => {
24594
+ const registration = entry.declarativeRegistration;
24595
+ if (request.inputSchemaRevisionRef && !supportsCapabilityInputSchema(entry, request.inputSchemaRevisionRef, request.runtimeContractVersion)) {
24596
+ throw new TypeError("The input schema is not owned by the runtime contract.");
24597
+ }
24598
+ if (!sameStableRef(request.capabilityRevisionRef, registration.capabilityRevisionRef) || !sameStableRef(request.providerRevisionRef, registration.providerRevisionRef) || request.capabilityRevisionRef.schemaVersion !== registration.capabilityRevisionRef.schemaVersion || request.providerRevisionRef.schemaVersion !== registration.providerRevisionRef.schemaVersion) {
24599
+ throw new TypeError("Runtime contract snapshots must retain their registered identity, scope and schema version.");
24600
+ }
24601
+ if (request.runtimeContractVersion !== void 0) {
24602
+ if (request.runtimeContractVersion !== entry.provider.runtimeContractVersion || request.propertySchemaRevisionRef && (!sameStableRef(request.propertySchemaRevisionRef, registration.propertySchemaRevisionRef) || request.propertySchemaRevisionRef.schemaVersion !== registration.propertySchemaRevisionRef.schemaVersion)) {
24603
+ throw new TypeError("The capability does not implement the declared runtime contract.");
24604
+ }
24605
+ return;
24606
+ }
24607
+ const capabilityVersion = String(request.capabilityRevisionRef.revision);
24608
+ const providerVersion = String(request.providerRevisionRef.revision);
24609
+ const manifest = {
24610
+ ...entry.manifest,
24611
+ capabilityVersion,
24612
+ runtime: {
24613
+ ...entry.manifest.runtime,
24614
+ providerBindings: entry.manifest.runtime.providerBindings.map((binding) => ({
24615
+ ...binding,
24616
+ providerRef: binding.providerRef.id === entry.provider.providerId ? { ...binding.providerRef, version: providerVersion } : binding.providerRef
24617
+ }))
24618
+ }
24619
+ };
24620
+ const { runtimeContractVersion: _contract, ...descriptor } = entry.provider;
24621
+ const provider = {
24622
+ ...descriptor,
24623
+ providerVersion,
24624
+ capabilityRef: { ...descriptor.capabilityRef, version: capabilityVersion },
24625
+ ...descriptor.sideEffectAdapterRef ? { sideEffectAdapterRef: { ...descriptor.sideEffectAdapterRef, version: capabilityVersion } } : {}
24626
+ };
24627
+ const exact = sameRevisionRef(request.capabilityRevisionRef, registration.capabilityRevisionRef) && sameRevisionRef(request.providerRevisionRef, registration.providerRevisionRef);
24628
+ const equivalent = request.capabilityRevisionRef.contentHash === canonicalContentHash(manifest) && request.providerRevisionRef.contentHash === canonicalContentHash(provider);
24629
+ if (!exact && !equivalent || request.propertySchemaRevisionRef && !sameSchemaContract(request.propertySchemaRevisionRef, registration.propertySchemaRevisionRef)) {
24630
+ throw new TypeError("The historical capability snapshot is not supported by the current runtime contract.");
24631
+ }
24632
+ };
24633
+ var acceptsPreviousSchema = (previous, next) => {
24634
+ if (canonicalContentHash(previous) === canonicalContentHash(next) || next === true) return true;
24635
+ if (previous === false) return true;
24636
+ if (!previous || !next || typeof previous !== "object" || typeof next !== "object" || Array.isArray(previous) || Array.isArray(next)) return false;
24637
+ const withoutAnnotations = (schema2) => Object.fromEntries(Object.entries(schema2).filter(([key]) => !["title", "description", "examples", "$comment"].includes(key)));
24638
+ const before = withoutAnnotations(previous);
24639
+ const after = withoutAnnotations(next);
24640
+ const {
24641
+ properties: oldProperties,
24642
+ required: oldRequired,
24643
+ additionalProperties: oldAdditional,
24644
+ enum: oldEnum,
24645
+ ...oldFixed
24646
+ } = before;
24647
+ const {
24648
+ properties: newProperties,
24649
+ required: newRequired,
24650
+ additionalProperties: newAdditional,
24651
+ enum: newEnum,
24652
+ ...newFixed
24653
+ } = after;
24654
+ if (canonicalContentHash(oldFixed) !== canonicalContentHash(newFixed)) return false;
24655
+ if (newEnum && (!oldEnum || oldEnum.some((value) => !newEnum.some((candidate) => canonicalContentHash(candidate) === canonicalContentHash(value))))) return false;
24656
+ if ((newRequired ?? []).some((key) => !(oldRequired ?? []).includes(key))) return false;
24657
+ const oldExtra = oldAdditional ?? true;
24658
+ const newExtra = newAdditional ?? true;
24659
+ if (!acceptsPreviousSchema(oldExtra, newExtra)) return false;
24660
+ const keys = /* @__PURE__ */ new Set([...Object.keys(oldProperties ?? {}), ...Object.keys(newProperties ?? {})]);
24661
+ for (const key of keys) {
24662
+ if (!acceptsPreviousSchema(oldProperties?.[key] ?? oldExtra, newProperties?.[key] ?? newExtra)) return false;
24663
+ }
24664
+ return true;
24665
+ };
24666
+ var assertCompatibleCapabilityUpgrade = (previous, next) => {
24667
+ if (previous.provider.runtimeContractVersion !== void 0 && previous.provider.runtimeContractVersion !== next.provider.runtimeContractVersion || !sameStableRef(previous.declarativeRegistration.capabilityRevisionRef, next.declarativeRegistration.capabilityRevisionRef) || !sameStableRef(previous.declarativeRegistration.providerRevisionRef, next.declarativeRegistration.providerRevisionRef)) {
24668
+ throw new TypeError("A breaking runtime contract requires a new capability/provider identity while the existing contract remains supported.");
24669
+ }
24670
+ const providerContract = (entry) => {
24671
+ const { providerVersion: _revision, capabilityRef, performance: _performance, sideEffectAdapterRef, ...rest } = entry.provider;
24672
+ const { version: _capabilityRevision, ...capability } = capabilityRef;
24673
+ return {
24674
+ ...rest,
24675
+ runtimeContractVersion: next.provider.runtimeContractVersion,
24676
+ capabilityRef: capability,
24677
+ ...sideEffectAdapterRef ? { sideEffectAdapterRef: { ...sideEffectAdapterRef, version: void 0 } } : {}
24678
+ };
24679
+ };
24680
+ if (canonicalContentHash(providerContract(previous)) !== canonicalContentHash(providerContract(next))) {
24681
+ throw new TypeError("A compatible provider upgrade must preserve lifecycle, effects, ownership and public rendering semantics.");
24682
+ }
24683
+ const manifestContract = (entry) => ({
24684
+ kind: entry.manifest.kind,
24685
+ runtime: { ...entry.manifest.runtime, providerBindings: entry.manifest.runtime.providerBindings.map((binding) => ({ ...binding, providerRef: { ...binding.providerRef, version: void 0 } })) },
24686
+ placement: entry.manifest.placement,
24687
+ accessibility: entry.manifest.accessibility
24688
+ });
24689
+ if (canonicalContentHash(manifestContract(previous)) !== canonicalContentHash(manifestContract(next))) {
24690
+ throw new TypeError("Capability behavior, placement and access semantics must preserve the published runtime contract.");
24691
+ }
24692
+ const oldRegistration = previous.declarativeRegistration;
24693
+ const newRegistration = next.declarativeRegistration;
24694
+ const schema2 = (entry, reference) => {
24695
+ const document = entry.schemaDocuments.find((candidate) => sameSchemaContract(candidate.schemaRevisionRef, reference));
24696
+ if (!document || canonicalContentHash(document.document) !== reference.contentHash) throw new TypeError("Runtime contract schema integrity failed.");
24697
+ return document.document;
24698
+ };
24699
+ const checkSchema = (oldRef, newRef, output = false) => {
24700
+ if (!sameStableRef(oldRef, newRef) || oldRef.schemaVersion !== newRef.schemaVersion || !acceptsPreviousSchema(
24701
+ schema2(output ? newRegistration : oldRegistration, output ? newRef : oldRef),
24702
+ schema2(output ? oldRegistration : newRegistration, output ? oldRef : newRef)
24703
+ )) {
24704
+ throw new TypeError(`Schema ${oldRef.id} breaks the published runtime contract.`);
24705
+ }
24706
+ };
24707
+ checkSchema(oldRegistration.propertySchemaRevisionRef, newRegistration.propertySchemaRevisionRef);
24708
+ for (const direction of ["inputPorts", "outputPorts"]) {
24709
+ const oldPorts = oldRegistration[direction];
24710
+ const newPorts = newRegistration[direction];
24711
+ const oldManifestPorts = previous.manifest.ports?.[direction === "inputPorts" ? "inputs" : "outputs"] ?? [];
24712
+ const newManifestPorts = next.manifest.ports?.[direction === "inputPorts" ? "inputs" : "outputs"] ?? [];
24713
+ for (const port of oldManifestPorts) {
24714
+ const replacement = newManifestPorts.find((candidate) => candidate.name === port.name);
24715
+ if (!replacement || canonicalContentHash(port) !== canonicalContentHash(replacement)) throw new TypeError("Published runtime port semantics changed.");
24716
+ }
24717
+ if (newManifestPorts.some((port) => port.required && !oldManifestPorts.some((previousPort) => previousPort.name === port.name)) || newPorts.some((port) => port.required && !oldPorts.some((previousPort) => previousPort.name === port.name))) {
24718
+ throw new TypeError("New runtime ports must be optional for published declarations.");
24719
+ }
24720
+ for (const port of oldPorts) {
24721
+ const replacement = newPorts.find((candidate) => candidate.name === port.name);
24722
+ if (!replacement || port.required !== replacement.required || port.multiple !== replacement.multiple) throw new TypeError("Public runtime port cardinality changed.");
24723
+ checkSchema(port.schemaRevisionRef, replacement.schemaRevisionRef, direction === "outputPorts");
24724
+ }
24725
+ }
24726
+ const requirements = (entry) => entry.ontologyRequirements.map((requirement) => {
24727
+ const { revision: _revision, contentHash: _hash, ...schema3 } = requirement.renderModelSchemaRevisionRef;
24728
+ return { ...requirement, renderModelSchemaRevisionRef: schema3 };
24729
+ });
24730
+ if (canonicalContentHash(requirements(oldRegistration)) !== canonicalContentHash(requirements(newRegistration))) {
24731
+ throw new TypeError("Runtime Ontology access requirements changed.");
24732
+ }
24733
+ const existingOutputs = new Set(oldRegistration.outputPorts.map((port) => port.name));
24734
+ const existingActions = newRegistration.actionRequirements.filter((requirement) => existingOutputs.has(requirement.outputPort));
24735
+ if (canonicalContentHash(oldRegistration.actionRequirements) !== canonicalContentHash(existingActions)) {
24736
+ throw new TypeError("Published output action and permission requirements changed.");
24737
+ }
24738
+ for (const key of ["allowedSideEffects", "allowedSlots", "supportedSurfaces", "allowedParentCapabilityRefs", "allowedChildCapabilityRefs"]) {
24739
+ if (canonicalContentHash(oldRegistration[key]) !== canonicalContentHash(newRegistration[key])) throw new TypeError(`Runtime contract ${key} changed.`);
24740
+ }
24741
+ };
24742
+ var projectRuntimeContracts = (bundle, entries) => {
24743
+ const resolve = (request) => {
24744
+ if (request.runtimeContractVersion) return request.runtimeContractVersion;
24745
+ const candidates = entries.filter((entry) => sameStableRef(entry.declarativeRegistration.capabilityRevisionRef, request.capabilityRevisionRef) && sameStableRef(entry.declarativeRegistration.providerRevisionRef, request.providerRevisionRef));
24746
+ const current = [...candidates].sort((a, b) => b.declarativeRegistration.capabilityRevisionRef.revision - a.declarativeRegistration.capabilityRevisionRef.revision || b.declarativeRegistration.registrationRevisionRef.revision - a.declarativeRegistration.registrationRevisionRef.revision || Number(Boolean(b.provider.runtimeContractVersion)) - Number(Boolean(a.provider.runtimeContractVersion)))[0];
24747
+ if (!current?.provider.runtimeContractVersion) return void 0;
24748
+ try {
24749
+ assertDeclarativeCapabilityContract(current, request);
24750
+ return current.provider.runtimeContractVersion;
24751
+ } catch {
24752
+ const historical = candidates.find((entry) => sameRevisionRef(entry.declarativeRegistration.capabilityRevisionRef, request.capabilityRevisionRef) && sameRevisionRef(entry.declarativeRegistration.providerRevisionRef, request.providerRevisionRef));
24753
+ if (!historical) return void 0;
24754
+ try {
24755
+ assertDeclarativeCapabilityContract(historical, request);
24756
+ assertCompatibleCapabilityUpgrade(historical, current);
24757
+ return current.provider.runtimeContractVersion;
24758
+ } catch {
24759
+ return void 0;
24760
+ }
24761
+ }
24762
+ };
24763
+ const projected = structuredClone(bundle);
24764
+ if (projected.contract === "PageRuntimeBundle") {
24765
+ for (const instance of projected.capabilityInstances) {
24766
+ const contract = resolve(instance);
24767
+ if (!contract) continue;
24768
+ const node = projected.renderTree.nodes.find((node2) => node2.nodeId === instance.nodeId);
24769
+ if (!node || String(node.providerRef?.version) !== String(instance.providerRevisionRef.revision) || String(node.capabilityRef.version) !== String(instance.capabilityRevisionRef.revision) || node.providerRef?.id !== instance.providerRevisionRef.id || node.capabilityRef.id !== instance.capabilityRevisionRef.id) continue;
24770
+ instance.runtimeContractVersion = contract;
24771
+ node.runtimeContractVersion = contract;
24772
+ }
24773
+ } else {
24774
+ for (const instance of projected.appInstances) {
24775
+ const contract2 = resolve({ capabilityRevisionRef: instance.targetRevisionRef, providerRevisionRef: instance.providerRevisionRef, inputSchemaRevisionRef: instance.inputSchemaRevisionRef, runtimeContractVersion: instance.runtimeContractVersion });
24776
+ if (contract2) instance.runtimeContractVersion = contract2;
24777
+ }
24778
+ const contract = resolve({ capabilityRevisionRef: projected.layout.hostCapabilityRevisionRef, providerRevisionRef: projected.layout.hostProviderRevisionRef, runtimeContractVersion: projected.layout.runtimeContractVersion });
24779
+ if (contract) projected.layout.runtimeContractVersion = contract;
24780
+ }
24781
+ const { contentHash: _hash, ...unsigned } = projected;
24782
+ projected.contentHash = canonicalContentHash(unsigned);
24783
+ return projected;
24784
+ };
24785
+
24554
24786
  // src/runtime/view-render-model.ts
24555
24787
  var DEFAULT_FORBIDDEN_RENDER_MODEL_KEYS = Object.freeze([
24556
24788
  "tenant",
@@ -25610,12 +25842,16 @@ export {
25610
25842
  NAVIGATION_UNAVAILABLE_CAPABILITY_HEADER,
25611
25843
  PageStreamReducerError,
25612
25844
  ThemeTokenValidationError,
25845
+ acceptsPreviousSchema,
25613
25846
  accessPolicyChainImplies,
25614
25847
  applyPageStreamEvent,
25615
25848
  applyRecordEditorDraft,
25616
25849
  applyViewRuntimeBindings,
25850
+ assertCompatibleCapabilityUpgrade,
25851
+ assertDeclarativeCapabilityContract,
25617
25852
  assertMonkeysThemeTokensComplete,
25618
25853
  assertThemeTokensDocumentStructure,
25854
+ assertViewProviderContract,
25619
25855
  buildApplicationHandoffUrl,
25620
25856
  buildChangeImpactGraph,
25621
25857
  canonicalContentHash,
@@ -25684,6 +25920,7 @@ export {
25684
25920
  projectNavigationCompatibility,
25685
25921
  projectPageProperties,
25686
25922
  projectRecordEditorValidation,
25923
+ projectRuntimeContracts,
25687
25924
  publishOpenApiToolCapabilityManifests,
25688
25925
  readApplicationHandoffFromUrl,
25689
25926
  readMenuActivationFromSearch,
@@ -25700,10 +25937,12 @@ export {
25700
25937
  resolveWorkflowColumnResult,
25701
25938
  revisionRefKey,
25702
25939
  sameRevisionRef,
25940
+ sameSchemaContract,
25703
25941
  sameStableRef,
25704
25942
  serializeApplicationHandoff,
25705
25943
  serializeMenuActivationSearch,
25706
25944
  stableRefKey,
25945
+ supportsCapabilityInputSchema,
25707
25946
  toAgentSessionViewModel,
25708
25947
  validateDomainCommand,
25709
25948
  validateThemeTokensDocument,