@ai-matrx/content-ir 0.6.0 → 0.8.0
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/CHANGELOG.md +38 -0
- package/dist/index.cjs +55 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +49 -1
- package/dist/index.d.ts +49 -1
- package/dist/index.js +55 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1656,6 +1656,54 @@ declare function collectReferencedKinds(fields: Record<string, FieldSchema>): st
|
|
|
1656
1656
|
declare function collectSchemaReferencedKinds(schema: KindSchema): string[];
|
|
1657
1657
|
declare function kindSchemaToJsonSchema(kind: string, resolve: (kind: string) => KindSchema | undefined, options?: KindJsonSchemaOptions): KindJsonSchemaExport | null;
|
|
1658
1658
|
|
|
1659
|
+
/**
|
|
1660
|
+
* JSON Schema → KindSchema — THE registry-facing direction.
|
|
1661
|
+
*
|
|
1662
|
+
* 🚨 WHY THIS FILE IS THE POINT OF THE WHOLE CONVERT LAYER (Arman's ruling,
|
|
1663
|
+
* 2026-08-29): a kind's fields must be DERIVED from its schema, never stored a
|
|
1664
|
+
* second time. `content_ir.kind_definition` used to carry both — a JSON Schema
|
|
1665
|
+
* AND a flattened field list written beside it — and the two had already
|
|
1666
|
+
* diverged on 13 of the 62 live kinds that carried both: stored lists holding
|
|
1667
|
+
* `__kind` as if it were a data field, enums flattened to bare strings,
|
|
1668
|
+
* min/max bounds and required flags the schema states and the copy never
|
|
1669
|
+
* learned. A cache that can disagree with its source is not a cache.
|
|
1670
|
+
*
|
|
1671
|
+
* The heavy lifting lives in `openai-schema-converter.ts` (it also serves the
|
|
1672
|
+
* agent-authoring flow, which needs the problems/dropped-metadata detail).
|
|
1673
|
+
* This module is the narrow, honest door the registry calls: one schema in,
|
|
1674
|
+
* one `KindSchema` out, plus whatever child kinds the schema declared inline
|
|
1675
|
+
* or through `$defs`.
|
|
1676
|
+
*
|
|
1677
|
+
* Accepts both storage shapes seen in the wild: a bare JSON Schema, and the
|
|
1678
|
+
* provider `{name, schema, strict}` response-format envelope that 5 live rows
|
|
1679
|
+
* carry.
|
|
1680
|
+
*/
|
|
1681
|
+
|
|
1682
|
+
type KindSchemaFromJsonResult = {
|
|
1683
|
+
/**
|
|
1684
|
+
* The requested kind's schema, or null when the input could not be read as
|
|
1685
|
+
* an object contract at all. NEVER a partial guess: a field the vocabulary
|
|
1686
|
+
* cannot express degrades to `json` (widening, always safe), and only a
|
|
1687
|
+
* structurally unusable root yields null.
|
|
1688
|
+
*/
|
|
1689
|
+
schema: KindSchema | null;
|
|
1690
|
+
/**
|
|
1691
|
+
* Child kinds the schema declared inline or via `$defs`, keyed by slug.
|
|
1692
|
+
* A registry that ingests these gets the whole tree from ONE row's schema —
|
|
1693
|
+
* which is how a nested kind renders before its children's rows load.
|
|
1694
|
+
*/
|
|
1695
|
+
children: Record<string, KindSchema>;
|
|
1696
|
+
/** Conversion notes. `severity: "error"` entries are worth screaming about. */
|
|
1697
|
+
problems: ConversionProblem[];
|
|
1698
|
+
};
|
|
1699
|
+
/**
|
|
1700
|
+
* Derive `kind`'s field schema from its JSON Schema.
|
|
1701
|
+
*
|
|
1702
|
+
* Pure and synchronous — no registry, no IO — so a host can call it from a
|
|
1703
|
+
* warm load, a cold fetch, a reducer, or a test.
|
|
1704
|
+
*/
|
|
1705
|
+
declare function kindSchemaFromJsonSchema(kind: string, jsonSchema: unknown): KindSchemaFromJsonResult;
|
|
1706
|
+
|
|
1659
1707
|
/**
|
|
1660
1708
|
* Streaming partial kinds — the TS twin of the Python producer's contract.
|
|
1661
1709
|
*
|
|
@@ -1979,4 +2027,4 @@ declare function emitPayloadJson(kind: string, value: unknown): string;
|
|
|
1979
2027
|
*/
|
|
1980
2028
|
declare function emitPayloadFence(kind: string, value: unknown): string;
|
|
1981
2029
|
|
|
1982
|
-
export { type AnyPartialKindEvent, type ArrayItemKindBinding, type ArrayItemScalarType, type BlockSchemaDraft, type CanonicalBlockIR, type CanonicalContent, type CanonicalSegment, type CompleteValueEnvelopeOptions, type CompliantKindSnapshot, type ContentRegionInit, type ConversionProblem, type DroppedMetadata, type DualGateDefinition, type DualGateInput, type DualGateResolvedComponent, type DualGateResult, type FieldComparison, type FieldSchema, type Fingerprinter, IR_ENVELOPE_CACHE_VERSION, IR_ENVELOPE_KEY, IR_PARTIAL_KEY, IR_VERSION, type InboundEnvelopeHooks, type InboundEnvelopeVerdict, type IrDiscriminator, type IrEnvelopeCache, type IrKindState, type IrPath, type IrResidue, type IrStructuredNode, IrTree, type IrTreeNode, type ItemKindRefCheck, JSON_DISCRIMINATOR, type JsonPath, type JsonSchemaNode, JsonStreamTokenizer, type JsonToken, KIND_KEY, type KindBlockProps, type KindDefinition, type KindEdgeSpec, type KindJsonSchemaExport, type KindJsonSchemaOptions, type KindResolution, type KindSchema, KindStorageError, type KindStorageShape, type KindStreamEvent, KindStreamParser, type KindStreamParserOptions, type KindTier, type KindVerdict, type LegResult, NODE_OUTCOME_KIND, type NodeOutcomeWrapper, type NormalizeJsonRegionOptions, ParseSession, type ParseSessionOptions, type PartialKindEvent, type PartialKindNode, type PartialKindState, type Punct, ROOT_STORAGE_NAME, RUN_RESULT_KIND, type RawObjectCause, type RecordValueType, type RegionEndReason, type RegionFormat, type RegionSourceKind, type RetractedKindEvent, type RunResultWrapper, type SavePlanEntry, type SavePlanValidation, type ScalarFieldType, type SchemaConversionResult, type SchemaLayoutMode, type SchemaResolver, type StoredFieldElement, type SupersededKindEvent, advancePartialKind, buildAgentSchemaWithRenderBlockSupport, buildCompliantKindSnapshot, classifyInboundEnvelopeMetadata, collectReferencedKinds, collectSchemaReferencedKinds, compareWithExistingKindSchema, convertAiSchemaToBlockFields, createFingerprinter, createKindStreamParser, describeDualGateFailure, disposeParseSession, emitPayloadFence, emitPayloadJson, emptyValueForFieldSchema, envelopeCacheFromEnvelopes, envelopeFromCompleteValue, fenceDiscriminator, fieldsToDbPayload, fingerprintText, formatBlockLabel, getParseSession, injectKindIntoObjectSchema, irPathIsUnderOrEqual, irPathKey, irPathLabel, irPathsEqual, isCanonicalBlockIR, isDuplicateBlockSlug, isEmptyResidue, isIrEnvelopeCache, isJsonAnyField, isProvisionalKind, isScalarArrayType, isTerminalKindEvent, kindSchemaToJsonSchema, kindSchemaToStorage, kindVerdictOf, makePartialKindStalenessGate, mergeResidueIntoValue, normalizeAiSchemaInput, normalizeJsonRegion, openParseSession, readEnvelope, readNodeOutcomeValue, readObjectKind, readOutputRef, readPartialKindEvent, readRunResultValue, reconstructRegionValue, rehydrateNodeOutcome, rehydrateRunResult, reuseEnvelopeIfCurrent, runKindDualGate, runSchemaConversion, sanitizeInboundEnvelopeMetadata, sanitizeInboundPartialKindMetadata, scalarArrayItemType, schemaLayoutMode, schemaStructureDepth, setJsonRootKeyLookup, storageToKindSchema, stripKindDeep, validateBlockSchemaSavePlan, validateStructuralLeg, withRootKind, xmlDiscriminator };
|
|
2030
|
+
export { type AnyPartialKindEvent, type ArrayItemKindBinding, type ArrayItemScalarType, type BlockSchemaDraft, type CanonicalBlockIR, type CanonicalContent, type CanonicalSegment, type CompleteValueEnvelopeOptions, type CompliantKindSnapshot, type ContentRegionInit, type ConversionProblem, type DroppedMetadata, type DualGateDefinition, type DualGateInput, type DualGateResolvedComponent, type DualGateResult, type FieldComparison, type FieldSchema, type Fingerprinter, IR_ENVELOPE_CACHE_VERSION, IR_ENVELOPE_KEY, IR_PARTIAL_KEY, IR_VERSION, type InboundEnvelopeHooks, type InboundEnvelopeVerdict, type IrDiscriminator, type IrEnvelopeCache, type IrKindState, type IrPath, type IrResidue, type IrStructuredNode, IrTree, type IrTreeNode, type ItemKindRefCheck, JSON_DISCRIMINATOR, type JsonPath, type JsonSchemaNode, JsonStreamTokenizer, type JsonToken, KIND_KEY, type KindBlockProps, type KindDefinition, type KindEdgeSpec, type KindJsonSchemaExport, type KindJsonSchemaOptions, type KindResolution, type KindSchema, type KindSchemaFromJsonResult, KindStorageError, type KindStorageShape, type KindStreamEvent, KindStreamParser, type KindStreamParserOptions, type KindTier, type KindVerdict, type LegResult, NODE_OUTCOME_KIND, type NodeOutcomeWrapper, type NormalizeJsonRegionOptions, ParseSession, type ParseSessionOptions, type PartialKindEvent, type PartialKindNode, type PartialKindState, type Punct, ROOT_STORAGE_NAME, RUN_RESULT_KIND, type RawObjectCause, type RecordValueType, type RegionEndReason, type RegionFormat, type RegionSourceKind, type RetractedKindEvent, type RunResultWrapper, type SavePlanEntry, type SavePlanValidation, type ScalarFieldType, type SchemaConversionResult, type SchemaLayoutMode, type SchemaResolver, type StoredFieldElement, type SupersededKindEvent, advancePartialKind, buildAgentSchemaWithRenderBlockSupport, buildCompliantKindSnapshot, classifyInboundEnvelopeMetadata, collectReferencedKinds, collectSchemaReferencedKinds, compareWithExistingKindSchema, convertAiSchemaToBlockFields, createFingerprinter, createKindStreamParser, describeDualGateFailure, disposeParseSession, emitPayloadFence, emitPayloadJson, emptyValueForFieldSchema, envelopeCacheFromEnvelopes, envelopeFromCompleteValue, fenceDiscriminator, fieldsToDbPayload, fingerprintText, formatBlockLabel, getParseSession, injectKindIntoObjectSchema, irPathIsUnderOrEqual, irPathKey, irPathLabel, irPathsEqual, isCanonicalBlockIR, isDuplicateBlockSlug, isEmptyResidue, isIrEnvelopeCache, isJsonAnyField, isProvisionalKind, isScalarArrayType, isTerminalKindEvent, kindSchemaFromJsonSchema, kindSchemaToJsonSchema, kindSchemaToStorage, kindVerdictOf, makePartialKindStalenessGate, mergeResidueIntoValue, normalizeAiSchemaInput, normalizeJsonRegion, openParseSession, readEnvelope, readNodeOutcomeValue, readObjectKind, readOutputRef, readPartialKindEvent, readRunResultValue, reconstructRegionValue, rehydrateNodeOutcome, rehydrateRunResult, reuseEnvelopeIfCurrent, runKindDualGate, runSchemaConversion, sanitizeInboundEnvelopeMetadata, sanitizeInboundPartialKindMetadata, scalarArrayItemType, schemaLayoutMode, schemaStructureDepth, setJsonRootKeyLookup, storageToKindSchema, stripKindDeep, validateBlockSchemaSavePlan, validateStructuralLeg, withRootKind, xmlDiscriminator };
|
package/dist/index.d.ts
CHANGED
|
@@ -1656,6 +1656,54 @@ declare function collectReferencedKinds(fields: Record<string, FieldSchema>): st
|
|
|
1656
1656
|
declare function collectSchemaReferencedKinds(schema: KindSchema): string[];
|
|
1657
1657
|
declare function kindSchemaToJsonSchema(kind: string, resolve: (kind: string) => KindSchema | undefined, options?: KindJsonSchemaOptions): KindJsonSchemaExport | null;
|
|
1658
1658
|
|
|
1659
|
+
/**
|
|
1660
|
+
* JSON Schema → KindSchema — THE registry-facing direction.
|
|
1661
|
+
*
|
|
1662
|
+
* 🚨 WHY THIS FILE IS THE POINT OF THE WHOLE CONVERT LAYER (Arman's ruling,
|
|
1663
|
+
* 2026-08-29): a kind's fields must be DERIVED from its schema, never stored a
|
|
1664
|
+
* second time. `content_ir.kind_definition` used to carry both — a JSON Schema
|
|
1665
|
+
* AND a flattened field list written beside it — and the two had already
|
|
1666
|
+
* diverged on 13 of the 62 live kinds that carried both: stored lists holding
|
|
1667
|
+
* `__kind` as if it were a data field, enums flattened to bare strings,
|
|
1668
|
+
* min/max bounds and required flags the schema states and the copy never
|
|
1669
|
+
* learned. A cache that can disagree with its source is not a cache.
|
|
1670
|
+
*
|
|
1671
|
+
* The heavy lifting lives in `openai-schema-converter.ts` (it also serves the
|
|
1672
|
+
* agent-authoring flow, which needs the problems/dropped-metadata detail).
|
|
1673
|
+
* This module is the narrow, honest door the registry calls: one schema in,
|
|
1674
|
+
* one `KindSchema` out, plus whatever child kinds the schema declared inline
|
|
1675
|
+
* or through `$defs`.
|
|
1676
|
+
*
|
|
1677
|
+
* Accepts both storage shapes seen in the wild: a bare JSON Schema, and the
|
|
1678
|
+
* provider `{name, schema, strict}` response-format envelope that 5 live rows
|
|
1679
|
+
* carry.
|
|
1680
|
+
*/
|
|
1681
|
+
|
|
1682
|
+
type KindSchemaFromJsonResult = {
|
|
1683
|
+
/**
|
|
1684
|
+
* The requested kind's schema, or null when the input could not be read as
|
|
1685
|
+
* an object contract at all. NEVER a partial guess: a field the vocabulary
|
|
1686
|
+
* cannot express degrades to `json` (widening, always safe), and only a
|
|
1687
|
+
* structurally unusable root yields null.
|
|
1688
|
+
*/
|
|
1689
|
+
schema: KindSchema | null;
|
|
1690
|
+
/**
|
|
1691
|
+
* Child kinds the schema declared inline or via `$defs`, keyed by slug.
|
|
1692
|
+
* A registry that ingests these gets the whole tree from ONE row's schema —
|
|
1693
|
+
* which is how a nested kind renders before its children's rows load.
|
|
1694
|
+
*/
|
|
1695
|
+
children: Record<string, KindSchema>;
|
|
1696
|
+
/** Conversion notes. `severity: "error"` entries are worth screaming about. */
|
|
1697
|
+
problems: ConversionProblem[];
|
|
1698
|
+
};
|
|
1699
|
+
/**
|
|
1700
|
+
* Derive `kind`'s field schema from its JSON Schema.
|
|
1701
|
+
*
|
|
1702
|
+
* Pure and synchronous — no registry, no IO — so a host can call it from a
|
|
1703
|
+
* warm load, a cold fetch, a reducer, or a test.
|
|
1704
|
+
*/
|
|
1705
|
+
declare function kindSchemaFromJsonSchema(kind: string, jsonSchema: unknown): KindSchemaFromJsonResult;
|
|
1706
|
+
|
|
1659
1707
|
/**
|
|
1660
1708
|
* Streaming partial kinds — the TS twin of the Python producer's contract.
|
|
1661
1709
|
*
|
|
@@ -1979,4 +2027,4 @@ declare function emitPayloadJson(kind: string, value: unknown): string;
|
|
|
1979
2027
|
*/
|
|
1980
2028
|
declare function emitPayloadFence(kind: string, value: unknown): string;
|
|
1981
2029
|
|
|
1982
|
-
export { type AnyPartialKindEvent, type ArrayItemKindBinding, type ArrayItemScalarType, type BlockSchemaDraft, type CanonicalBlockIR, type CanonicalContent, type CanonicalSegment, type CompleteValueEnvelopeOptions, type CompliantKindSnapshot, type ContentRegionInit, type ConversionProblem, type DroppedMetadata, type DualGateDefinition, type DualGateInput, type DualGateResolvedComponent, type DualGateResult, type FieldComparison, type FieldSchema, type Fingerprinter, IR_ENVELOPE_CACHE_VERSION, IR_ENVELOPE_KEY, IR_PARTIAL_KEY, IR_VERSION, type InboundEnvelopeHooks, type InboundEnvelopeVerdict, type IrDiscriminator, type IrEnvelopeCache, type IrKindState, type IrPath, type IrResidue, type IrStructuredNode, IrTree, type IrTreeNode, type ItemKindRefCheck, JSON_DISCRIMINATOR, type JsonPath, type JsonSchemaNode, JsonStreamTokenizer, type JsonToken, KIND_KEY, type KindBlockProps, type KindDefinition, type KindEdgeSpec, type KindJsonSchemaExport, type KindJsonSchemaOptions, type KindResolution, type KindSchema, KindStorageError, type KindStorageShape, type KindStreamEvent, KindStreamParser, type KindStreamParserOptions, type KindTier, type KindVerdict, type LegResult, NODE_OUTCOME_KIND, type NodeOutcomeWrapper, type NormalizeJsonRegionOptions, ParseSession, type ParseSessionOptions, type PartialKindEvent, type PartialKindNode, type PartialKindState, type Punct, ROOT_STORAGE_NAME, RUN_RESULT_KIND, type RawObjectCause, type RecordValueType, type RegionEndReason, type RegionFormat, type RegionSourceKind, type RetractedKindEvent, type RunResultWrapper, type SavePlanEntry, type SavePlanValidation, type ScalarFieldType, type SchemaConversionResult, type SchemaLayoutMode, type SchemaResolver, type StoredFieldElement, type SupersededKindEvent, advancePartialKind, buildAgentSchemaWithRenderBlockSupport, buildCompliantKindSnapshot, classifyInboundEnvelopeMetadata, collectReferencedKinds, collectSchemaReferencedKinds, compareWithExistingKindSchema, convertAiSchemaToBlockFields, createFingerprinter, createKindStreamParser, describeDualGateFailure, disposeParseSession, emitPayloadFence, emitPayloadJson, emptyValueForFieldSchema, envelopeCacheFromEnvelopes, envelopeFromCompleteValue, fenceDiscriminator, fieldsToDbPayload, fingerprintText, formatBlockLabel, getParseSession, injectKindIntoObjectSchema, irPathIsUnderOrEqual, irPathKey, irPathLabel, irPathsEqual, isCanonicalBlockIR, isDuplicateBlockSlug, isEmptyResidue, isIrEnvelopeCache, isJsonAnyField, isProvisionalKind, isScalarArrayType, isTerminalKindEvent, kindSchemaToJsonSchema, kindSchemaToStorage, kindVerdictOf, makePartialKindStalenessGate, mergeResidueIntoValue, normalizeAiSchemaInput, normalizeJsonRegion, openParseSession, readEnvelope, readNodeOutcomeValue, readObjectKind, readOutputRef, readPartialKindEvent, readRunResultValue, reconstructRegionValue, rehydrateNodeOutcome, rehydrateRunResult, reuseEnvelopeIfCurrent, runKindDualGate, runSchemaConversion, sanitizeInboundEnvelopeMetadata, sanitizeInboundPartialKindMetadata, scalarArrayItemType, schemaLayoutMode, schemaStructureDepth, setJsonRootKeyLookup, storageToKindSchema, stripKindDeep, validateBlockSchemaSavePlan, validateStructuralLeg, withRootKind, xmlDiscriminator };
|
|
2030
|
+
export { type AnyPartialKindEvent, type ArrayItemKindBinding, type ArrayItemScalarType, type BlockSchemaDraft, type CanonicalBlockIR, type CanonicalContent, type CanonicalSegment, type CompleteValueEnvelopeOptions, type CompliantKindSnapshot, type ContentRegionInit, type ConversionProblem, type DroppedMetadata, type DualGateDefinition, type DualGateInput, type DualGateResolvedComponent, type DualGateResult, type FieldComparison, type FieldSchema, type Fingerprinter, IR_ENVELOPE_CACHE_VERSION, IR_ENVELOPE_KEY, IR_PARTIAL_KEY, IR_VERSION, type InboundEnvelopeHooks, type InboundEnvelopeVerdict, type IrDiscriminator, type IrEnvelopeCache, type IrKindState, type IrPath, type IrResidue, type IrStructuredNode, IrTree, type IrTreeNode, type ItemKindRefCheck, JSON_DISCRIMINATOR, type JsonPath, type JsonSchemaNode, JsonStreamTokenizer, type JsonToken, KIND_KEY, type KindBlockProps, type KindDefinition, type KindEdgeSpec, type KindJsonSchemaExport, type KindJsonSchemaOptions, type KindResolution, type KindSchema, type KindSchemaFromJsonResult, KindStorageError, type KindStorageShape, type KindStreamEvent, KindStreamParser, type KindStreamParserOptions, type KindTier, type KindVerdict, type LegResult, NODE_OUTCOME_KIND, type NodeOutcomeWrapper, type NormalizeJsonRegionOptions, ParseSession, type ParseSessionOptions, type PartialKindEvent, type PartialKindNode, type PartialKindState, type Punct, ROOT_STORAGE_NAME, RUN_RESULT_KIND, type RawObjectCause, type RecordValueType, type RegionEndReason, type RegionFormat, type RegionSourceKind, type RetractedKindEvent, type RunResultWrapper, type SavePlanEntry, type SavePlanValidation, type ScalarFieldType, type SchemaConversionResult, type SchemaLayoutMode, type SchemaResolver, type StoredFieldElement, type SupersededKindEvent, advancePartialKind, buildAgentSchemaWithRenderBlockSupport, buildCompliantKindSnapshot, classifyInboundEnvelopeMetadata, collectReferencedKinds, collectSchemaReferencedKinds, compareWithExistingKindSchema, convertAiSchemaToBlockFields, createFingerprinter, createKindStreamParser, describeDualGateFailure, disposeParseSession, emitPayloadFence, emitPayloadJson, emptyValueForFieldSchema, envelopeCacheFromEnvelopes, envelopeFromCompleteValue, fenceDiscriminator, fieldsToDbPayload, fingerprintText, formatBlockLabel, getParseSession, injectKindIntoObjectSchema, irPathIsUnderOrEqual, irPathKey, irPathLabel, irPathsEqual, isCanonicalBlockIR, isDuplicateBlockSlug, isEmptyResidue, isIrEnvelopeCache, isJsonAnyField, isProvisionalKind, isScalarArrayType, isTerminalKindEvent, kindSchemaFromJsonSchema, kindSchemaToJsonSchema, kindSchemaToStorage, kindVerdictOf, makePartialKindStalenessGate, mergeResidueIntoValue, normalizeAiSchemaInput, normalizeJsonRegion, openParseSession, readEnvelope, readNodeOutcomeValue, readObjectKind, readOutputRef, readPartialKindEvent, readRunResultValue, reconstructRegionValue, rehydrateNodeOutcome, rehydrateRunResult, reuseEnvelopeIfCurrent, runKindDualGate, runSchemaConversion, sanitizeInboundEnvelopeMetadata, sanitizeInboundPartialKindMetadata, scalarArrayItemType, schemaLayoutMode, schemaStructureDepth, setJsonRootKeyLookup, storageToKindSchema, stripKindDeep, validateBlockSchemaSavePlan, validateStructuralLeg, withRootKind, xmlDiscriminator };
|
package/dist/index.js
CHANGED
|
@@ -3207,14 +3207,13 @@ function registerDeclaredKindDraft(declaredKind, objectNode, path, ctx) {
|
|
|
3207
3207
|
for (const [propName, propNode] of Object.entries(objectNode.properties)) {
|
|
3208
3208
|
if (!isRecord4(propNode)) continue;
|
|
3209
3209
|
if (propName === KIND_KEY) continue;
|
|
3210
|
-
|
|
3210
|
+
fields[propName] = convertFieldOrWiden(
|
|
3211
3211
|
propName,
|
|
3212
3212
|
propNode,
|
|
3213
3213
|
memberRequired.has(propName),
|
|
3214
3214
|
`${path}.${propName}`,
|
|
3215
3215
|
ctx
|
|
3216
3216
|
);
|
|
3217
|
-
if (converted) fields[propName] = converted;
|
|
3218
3217
|
}
|
|
3219
3218
|
ctx.blockSchemas.push({
|
|
3220
3219
|
slug: declaredKind,
|
|
@@ -3222,6 +3221,21 @@ function registerDeclaredKindDraft(declaredKind, objectNode, path, ctx) {
|
|
|
3222
3221
|
fields
|
|
3223
3222
|
});
|
|
3224
3223
|
}
|
|
3224
|
+
function convertFieldOrWiden(fieldName, node, required, path, ctx) {
|
|
3225
|
+
const before = ctx.problems.length;
|
|
3226
|
+
const converted = convertProperty(fieldName, node, required, path, ctx);
|
|
3227
|
+
if (converted) return converted;
|
|
3228
|
+
for (let i = before; i < ctx.problems.length; i++) {
|
|
3229
|
+
const problem = ctx.problems[i];
|
|
3230
|
+
if (problem && problem.severity === "error") problem.severity = "warning";
|
|
3231
|
+
}
|
|
3232
|
+
ctx.problems.push({
|
|
3233
|
+
severity: "warning",
|
|
3234
|
+
path,
|
|
3235
|
+
message: `Field "${fieldName}" has no exact field type \u2014 carried as any JSON value (json) rather than dropped from the kind.`
|
|
3236
|
+
});
|
|
3237
|
+
return { ...requiredNullableFlags(required), type: "json" };
|
|
3238
|
+
}
|
|
3225
3239
|
function convertProperty(fieldName, node, required, path, ctx) {
|
|
3226
3240
|
const core = convertPropertyCore(fieldName, node, required, path, ctx);
|
|
3227
3241
|
const field = core === null ? null : attachNodeMetadata(node, core);
|
|
@@ -3612,16 +3626,13 @@ function convertPropertyCore(fieldName, node, required, path, ctx) {
|
|
|
3612
3626
|
for (const [propName, propNode] of Object.entries(itemNode.properties)) {
|
|
3613
3627
|
if (!isRecord4(propNode)) continue;
|
|
3614
3628
|
if (propName === KIND_KEY) continue;
|
|
3615
|
-
|
|
3629
|
+
itemFields[propName] = convertFieldOrWiden(
|
|
3616
3630
|
propName,
|
|
3617
3631
|
propNode,
|
|
3618
3632
|
itemRequired.has(propName),
|
|
3619
3633
|
`${path}[].${propName}`,
|
|
3620
3634
|
ctx
|
|
3621
3635
|
);
|
|
3622
|
-
if (converted) {
|
|
3623
|
-
itemFields[propName] = converted;
|
|
3624
|
-
}
|
|
3625
3636
|
}
|
|
3626
3637
|
const alreadyHasBlockKind = propNameIsBlockKind(itemNode.properties) || itemRequired.has(KIND_KEY);
|
|
3627
3638
|
ctx.arrayBindings.push({
|
|
@@ -3666,16 +3677,13 @@ function convertPropertyCore(fieldName, node, required, path, ctx) {
|
|
|
3666
3677
|
for (const [propName, propNode] of Object.entries(node.properties)) {
|
|
3667
3678
|
if (!isRecord4(propNode)) continue;
|
|
3668
3679
|
if (propName === KIND_KEY) continue;
|
|
3669
|
-
|
|
3680
|
+
nestedFields[propName] = convertFieldOrWiden(
|
|
3670
3681
|
propName,
|
|
3671
3682
|
propNode,
|
|
3672
3683
|
nestedRequired.has(propName),
|
|
3673
3684
|
`${path}.${propName}`,
|
|
3674
3685
|
ctx
|
|
3675
3686
|
);
|
|
3676
|
-
if (converted) {
|
|
3677
|
-
nestedFields[propName] = converted;
|
|
3678
|
-
}
|
|
3679
3687
|
}
|
|
3680
3688
|
const referencedKind = readBlockKindFromProperties(node.properties);
|
|
3681
3689
|
if (referencedKind) {
|
|
@@ -3860,16 +3868,13 @@ function convertAiSchemaToBlockFields(schemaName, rootSchema, strict) {
|
|
|
3860
3868
|
for (const [fieldName, fieldNode] of Object.entries(properties)) {
|
|
3861
3869
|
if (!isRecord4(fieldNode)) continue;
|
|
3862
3870
|
if (fieldName === KIND_KEY) continue;
|
|
3863
|
-
|
|
3871
|
+
convertedFields[fieldName] = convertFieldOrWiden(
|
|
3864
3872
|
fieldName,
|
|
3865
3873
|
fieldNode,
|
|
3866
3874
|
required.has(fieldName),
|
|
3867
3875
|
fieldName,
|
|
3868
3876
|
ctx
|
|
3869
3877
|
);
|
|
3870
|
-
if (converted) {
|
|
3871
|
-
convertedFields[fieldName] = converted;
|
|
3872
|
-
}
|
|
3873
3878
|
}
|
|
3874
3879
|
const rootHasKind = propNameIsBlockKind(properties) || required.has(KIND_KEY);
|
|
3875
3880
|
if (!rootHasKind) {
|
|
@@ -4289,6 +4294,41 @@ function kindSchemaToJsonSchema(kind, resolve, options = {}) {
|
|
|
4289
4294
|
return { name: kind, schema: { ...rootNode, $defs: defs }, strict, unresolved };
|
|
4290
4295
|
}
|
|
4291
4296
|
|
|
4297
|
+
// convert/json-schema-to-kind.ts
|
|
4298
|
+
function kindSchemaFromJsonSchema(kind, jsonSchema) {
|
|
4299
|
+
if (jsonSchema === null || jsonSchema === void 0) {
|
|
4300
|
+
return { schema: null, children: {}, problems: [] };
|
|
4301
|
+
}
|
|
4302
|
+
const normalized = normalizeAiSchemaInput(jsonSchema);
|
|
4303
|
+
const rootSchema = normalized.rootSchema ?? (typeof jsonSchema === "object" && !Array.isArray(jsonSchema) ? jsonSchema : null);
|
|
4304
|
+
if (!rootSchema) {
|
|
4305
|
+
return {
|
|
4306
|
+
schema: null,
|
|
4307
|
+
children: {},
|
|
4308
|
+
problems: [
|
|
4309
|
+
{
|
|
4310
|
+
severity: "error",
|
|
4311
|
+
path: "",
|
|
4312
|
+
message: `Kind "${kind}": emitted_json_schema is not a JSON object.`
|
|
4313
|
+
}
|
|
4314
|
+
]
|
|
4315
|
+
};
|
|
4316
|
+
}
|
|
4317
|
+
const converted = convertAiSchemaToBlockFields(kind, rootSchema, false);
|
|
4318
|
+
let schema = null;
|
|
4319
|
+
const children = {};
|
|
4320
|
+
for (const draft of converted.blockSchemas) {
|
|
4321
|
+
const asKindSchema = {
|
|
4322
|
+
kind: draft.slug,
|
|
4323
|
+
fields: draft.fields,
|
|
4324
|
+
...draft.root ? { root: draft.root } : {}
|
|
4325
|
+
};
|
|
4326
|
+
if (draft.slug === kind) schema = asKindSchema;
|
|
4327
|
+
else children[draft.slug] = asKindSchema;
|
|
4328
|
+
}
|
|
4329
|
+
return { schema, children, problems: converted.problems };
|
|
4330
|
+
}
|
|
4331
|
+
|
|
4292
4332
|
// wire/partial-kind.ts
|
|
4293
4333
|
var IR_PARTIAL_KEY = "__ir_partial";
|
|
4294
4334
|
var PARTIAL_STATES = [
|
|
@@ -4571,6 +4611,6 @@ function emitPayloadFence(kind, value) {
|
|
|
4571
4611
|
return "```json\n" + emitPayloadJson(kind, value) + "\n```";
|
|
4572
4612
|
}
|
|
4573
4613
|
|
|
4574
|
-
export { IR_ENVELOPE_CACHE_VERSION, IR_ENVELOPE_KEY, IR_PARTIAL_KEY, IR_VERSION, IrTree, JSON_DISCRIMINATOR, JsonStreamTokenizer, KIND_KEY, KindStorageError, KindStreamParser, NODE_OUTCOME_KIND, ParseSession, ROOT_STORAGE_NAME, RUN_RESULT_KIND, advancePartialKind, buildAgentSchemaWithRenderBlockSupport, buildCompliantKindSnapshot, classifyInboundEnvelopeMetadata, collectReferencedKinds, collectSchemaReferencedKinds, compareWithExistingKindSchema, convertAiSchemaToBlockFields, createFingerprinter, createKindStreamParser, describeDualGateFailure, disposeParseSession, emitPayloadFence, emitPayloadJson, emptyValueForFieldSchema, envelopeCacheFromEnvelopes, envelopeFromCompleteValue, fenceDiscriminator, fieldsToDbPayload, fingerprintText, formatBlockLabel, getParseSession, injectKindIntoObjectSchema, irPathIsUnderOrEqual, irPathKey, irPathLabel, irPathsEqual, isCanonicalBlockIR, isDuplicateBlockSlug, isEmptyResidue, isIrEnvelopeCache, isJsonAnyField, isProvisionalKind, isScalarArrayType, isTerminalKindEvent, kindSchemaToJsonSchema, kindSchemaToStorage, kindVerdictOf, makePartialKindStalenessGate, mergeResidueIntoValue, normalizeAiSchemaInput, normalizeJsonRegion, openParseSession, readEnvelope, readNodeOutcomeValue, readObjectKind, readOutputRef, readPartialKindEvent, readRunResultValue, reconstructRegionValue, rehydrateNodeOutcome, rehydrateRunResult, reuseEnvelopeIfCurrent, runKindDualGate, runSchemaConversion, sanitizeInboundEnvelopeMetadata, sanitizeInboundPartialKindMetadata, scalarArrayItemType, schemaLayoutMode, schemaStructureDepth, setJsonRootKeyLookup, storageToKindSchema, stripKindDeep, validateBlockSchemaSavePlan, validateStructuralLeg, withRootKind, xmlDiscriminator };
|
|
4614
|
+
export { IR_ENVELOPE_CACHE_VERSION, IR_ENVELOPE_KEY, IR_PARTIAL_KEY, IR_VERSION, IrTree, JSON_DISCRIMINATOR, JsonStreamTokenizer, KIND_KEY, KindStorageError, KindStreamParser, NODE_OUTCOME_KIND, ParseSession, ROOT_STORAGE_NAME, RUN_RESULT_KIND, advancePartialKind, buildAgentSchemaWithRenderBlockSupport, buildCompliantKindSnapshot, classifyInboundEnvelopeMetadata, collectReferencedKinds, collectSchemaReferencedKinds, compareWithExistingKindSchema, convertAiSchemaToBlockFields, createFingerprinter, createKindStreamParser, describeDualGateFailure, disposeParseSession, emitPayloadFence, emitPayloadJson, emptyValueForFieldSchema, envelopeCacheFromEnvelopes, envelopeFromCompleteValue, fenceDiscriminator, fieldsToDbPayload, fingerprintText, formatBlockLabel, getParseSession, injectKindIntoObjectSchema, irPathIsUnderOrEqual, irPathKey, irPathLabel, irPathsEqual, isCanonicalBlockIR, isDuplicateBlockSlug, isEmptyResidue, isIrEnvelopeCache, isJsonAnyField, isProvisionalKind, isScalarArrayType, isTerminalKindEvent, kindSchemaFromJsonSchema, kindSchemaToJsonSchema, kindSchemaToStorage, kindVerdictOf, makePartialKindStalenessGate, mergeResidueIntoValue, normalizeAiSchemaInput, normalizeJsonRegion, openParseSession, readEnvelope, readNodeOutcomeValue, readObjectKind, readOutputRef, readPartialKindEvent, readRunResultValue, reconstructRegionValue, rehydrateNodeOutcome, rehydrateRunResult, reuseEnvelopeIfCurrent, runKindDualGate, runSchemaConversion, sanitizeInboundEnvelopeMetadata, sanitizeInboundPartialKindMetadata, scalarArrayItemType, schemaLayoutMode, schemaStructureDepth, setJsonRootKeyLookup, storageToKindSchema, stripKindDeep, validateBlockSchemaSavePlan, validateStructuralLeg, withRootKind, xmlDiscriminator };
|
|
4575
4615
|
//# sourceMappingURL=index.js.map
|
|
4576
4616
|
//# sourceMappingURL=index.js.map
|