@ai-matrx/content-ir 0.22.5 → 0.22.7

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.
package/dist/convert.js CHANGED
@@ -515,7 +515,7 @@ function buildAgentSchemaWithRenderBlockSupport(input, rootKindSlug, arrayBindin
515
515
  }
516
516
  function resolveRef(ref, ctx) {
517
517
  if (ref === "#" || ref === "#/") {
518
- return { slug: ctx.schemaName, node: ctx.rootSchema };
518
+ return { slug: ctx.schemaName, node: ctx.rootSchema, declaresKind: true };
519
519
  }
520
520
  const match = /^#\/(?:\$defs|definitions)\/(.+)$/.exec(ref);
521
521
  if (!match) return null;
@@ -525,7 +525,11 @@ function resolveRef(ref, ctx) {
525
525
  const node = ctx.defs[name];
526
526
  if (!isRecord(node)) return null;
527
527
  const declared = isRecord(node.properties) ? readBlockKindFromProperties(node.properties) : null;
528
- return { slug: declared ?? name, node };
528
+ return { slug: declared ?? name, node, declaresKind: declared !== null };
529
+ }
530
+ function inlineRefNode(refNode, resolved) {
531
+ const { $ref: _ref, ...beside } = refNode;
532
+ return { ...resolved.node, ...beside };
529
533
  }
530
534
  function refToObjectField(resolved, path, ctx) {
531
535
  if (ctx.refsInProgress.has(resolved.slug)) return;
@@ -595,6 +599,29 @@ function convertPropertyCore(fieldName, node, required, path, ctx) {
595
599
  });
596
600
  return null;
597
601
  }
602
+ if (!resolved.declaresKind) {
603
+ const guard = `$def:${node.$ref}`;
604
+ if (ctx.refsInProgress.has(guard)) {
605
+ ctx.problems.push({
606
+ severity: "info",
607
+ path,
608
+ message: `Self-referencing structure "${node.$ref}" \u2014 carried as any JSON value (json).`
609
+ });
610
+ return { ...requiredNullableFlags(required), type: "json" };
611
+ }
612
+ ctx.refsInProgress.add(guard);
613
+ try {
614
+ return convertPropertyCore(
615
+ fieldName,
616
+ inlineRefNode(node, resolved),
617
+ required,
618
+ path,
619
+ ctx
620
+ );
621
+ } finally {
622
+ ctx.refsInProgress.delete(guard);
623
+ }
624
+ }
598
625
  refToObjectField(resolved, path, ctx);
599
626
  return {
600
627
  ...requiredNullableFlags(required),
@@ -626,6 +653,10 @@ function convertPropertyCore(fieldName, node, required, path, ctx) {
626
653
  unsupported = true;
627
654
  continue;
628
655
  }
656
+ if (!resolvedVariant.declaresKind) {
657
+ anonymousObjects.push(inlineRefNode(variant, resolvedVariant));
658
+ continue;
659
+ }
629
660
  refToObjectField(resolvedVariant, path, ctx);
630
661
  memberKinds.push(resolvedVariant.slug);
631
662
  continue;