@ai-matrx/content-ir 0.6.0 → 0.7.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 +13 -0
- package/dist/index.cjs +36 -0
- 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 +36 -1
- 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
|
@@ -4289,6 +4289,41 @@ function kindSchemaToJsonSchema(kind, resolve, options = {}) {
|
|
|
4289
4289
|
return { name: kind, schema: { ...rootNode, $defs: defs }, strict, unresolved };
|
|
4290
4290
|
}
|
|
4291
4291
|
|
|
4292
|
+
// convert/json-schema-to-kind.ts
|
|
4293
|
+
function kindSchemaFromJsonSchema(kind, jsonSchema) {
|
|
4294
|
+
if (jsonSchema === null || jsonSchema === void 0) {
|
|
4295
|
+
return { schema: null, children: {}, problems: [] };
|
|
4296
|
+
}
|
|
4297
|
+
const normalized = normalizeAiSchemaInput(jsonSchema);
|
|
4298
|
+
const rootSchema = normalized.rootSchema ?? (typeof jsonSchema === "object" && !Array.isArray(jsonSchema) ? jsonSchema : null);
|
|
4299
|
+
if (!rootSchema) {
|
|
4300
|
+
return {
|
|
4301
|
+
schema: null,
|
|
4302
|
+
children: {},
|
|
4303
|
+
problems: [
|
|
4304
|
+
{
|
|
4305
|
+
severity: "error",
|
|
4306
|
+
path: "",
|
|
4307
|
+
message: `Kind "${kind}": emitted_json_schema is not a JSON object.`
|
|
4308
|
+
}
|
|
4309
|
+
]
|
|
4310
|
+
};
|
|
4311
|
+
}
|
|
4312
|
+
const converted = convertAiSchemaToBlockFields(kind, rootSchema, false);
|
|
4313
|
+
let schema = null;
|
|
4314
|
+
const children = {};
|
|
4315
|
+
for (const draft of converted.blockSchemas) {
|
|
4316
|
+
const asKindSchema = {
|
|
4317
|
+
kind: draft.slug,
|
|
4318
|
+
fields: draft.fields,
|
|
4319
|
+
...draft.root ? { root: draft.root } : {}
|
|
4320
|
+
};
|
|
4321
|
+
if (draft.slug === kind) schema = asKindSchema;
|
|
4322
|
+
else children[draft.slug] = asKindSchema;
|
|
4323
|
+
}
|
|
4324
|
+
return { schema, children, problems: converted.problems };
|
|
4325
|
+
}
|
|
4326
|
+
|
|
4292
4327
|
// wire/partial-kind.ts
|
|
4293
4328
|
var IR_PARTIAL_KEY = "__ir_partial";
|
|
4294
4329
|
var PARTIAL_STATES = [
|
|
@@ -4571,6 +4606,6 @@ function emitPayloadFence(kind, value) {
|
|
|
4571
4606
|
return "```json\n" + emitPayloadJson(kind, value) + "\n```";
|
|
4572
4607
|
}
|
|
4573
4608
|
|
|
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 };
|
|
4609
|
+
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
4610
|
//# sourceMappingURL=index.js.map
|
|
4576
4611
|
//# sourceMappingURL=index.js.map
|