@ai-matrx/content-ir 0.19.20 → 0.19.21

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/session.js CHANGED
@@ -1253,7 +1253,7 @@ var KindStreamParser = class {
1253
1253
  }
1254
1254
  if (!declaredKind && committedKind && this.speculativeKinds.has(pathKey)) {
1255
1255
  this.speculativeKinds.delete(pathKey);
1256
- this.finalizeSpeculatedObject(path, objectValue, committedKind, at);
1256
+ this.finalizeSpeculatedObject(path, objectValue, committedKind, at, true);
1257
1257
  return;
1258
1258
  }
1259
1259
  if (path.length === 0 && !declaredKind && !committedKind && this.rootSurfaceKind) {
@@ -1331,7 +1331,7 @@ var KindStreamParser = class {
1331
1331
  });
1332
1332
  }
1333
1333
  /** Validate + complete an object typed purely by parent prediction. */
1334
- finalizeSpeculatedObject(path, objectValue, kind, at) {
1334
+ finalizeSpeculatedObject(path, objectValue, kind, at, requireSharedField = false) {
1335
1335
  const schema = this.lookupSchema(kind);
1336
1336
  if (!schema) {
1337
1337
  this.emitRawObject(
@@ -1344,6 +1344,15 @@ var KindStreamParser = class {
1344
1344
  );
1345
1345
  return;
1346
1346
  }
1347
+ if (requireSharedField && !Object.keys(objectValue).some((key) => key in schema.fields)) {
1348
+ this.emitRawObject(
1349
+ path,
1350
+ objectValue,
1351
+ `Object carries none of "${kind}"'s fields.`,
1352
+ at
1353
+ );
1354
+ return;
1355
+ }
1347
1356
  const outcome = this.validateObjectAgainstSchema(
1348
1357
  { ...objectValue, [KIND_KEY]: kind },
1349
1358
  schema
@@ -1604,16 +1613,7 @@ var KindStreamParser = class {
1604
1613
  ...emptyOutcome
1605
1614
  };
1606
1615
  }
1607
- for (const [fieldName, fieldSchema] of Object.entries(schema.fields)) {
1608
- if (fieldSchema.required) {
1609
- if (!(fieldName in objectValue)) {
1610
- return {
1611
- error: `Kind "${schema.kind}" is missing required field "${fieldName}".`,
1612
- ...emptyOutcome
1613
- };
1614
- }
1615
- continue;
1616
- }
1616
+ for (const fieldName of Object.keys(schema.fields)) {
1617
1617
  if (!(fieldName in objectValue)) {
1618
1618
  optionalMissing.push(fieldName);
1619
1619
  }
@@ -1820,17 +1820,7 @@ var KindStreamParser = class {
1820
1820
  validateObjectAgainstFields(objectValue, fields) {
1821
1821
  const optionalMissing = [];
1822
1822
  const extraFields = [];
1823
- const emptyOutcome = { optionalMissing, extraFields };
1824
- for (const [fieldName, fieldSchema] of Object.entries(fields)) {
1825
- if (fieldSchema.required) {
1826
- if (!(fieldName in objectValue)) {
1827
- return {
1828
- error: `Inline object is missing required field "${fieldName}".`,
1829
- ...emptyOutcome
1830
- };
1831
- }
1832
- continue;
1833
- }
1823
+ for (const fieldName of Object.keys(fields)) {
1834
1824
  if (!(fieldName in objectValue)) {
1835
1825
  optionalMissing.push(fieldName);
1836
1826
  }