@ai-matrx/content-ir 0.9.0 → 0.10.1
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 +63 -0
- package/README.md +24 -5
- package/dist/convert.cjs +1680 -0
- package/dist/convert.cjs.map +1 -0
- package/dist/convert.d.cts +230 -0
- package/dist/convert.d.ts +230 -0
- package/dist/convert.js +1666 -0
- package/dist/convert.js.map +1 -0
- package/dist/core.cjs +2493 -0
- package/dist/core.cjs.map +1 -0
- package/dist/core.d.cts +370 -0
- package/dist/core.d.ts +370 -0
- package/dist/core.js +2452 -0
- package/dist/core.js.map +1 -0
- package/dist/index.cjs +3 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -2030
- package/dist/index.d.ts +9 -2030
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/ir-tree-DbLVxbf1.d.cts +441 -0
- package/dist/ir-tree-Dsc_66ek.d.ts +441 -0
- package/dist/ir-types-95bA2cXH.d.cts +119 -0
- package/dist/ir-types-95bA2cXH.d.ts +119 -0
- package/dist/kind-schema.types-CwncWj9U.d.cts +139 -0
- package/dist/kind-schema.types-CwncWj9U.d.ts +139 -0
- package/dist/registry.cjs +468 -0
- package/dist/registry.cjs.map +1 -0
- package/dist/registry.d.cts +357 -0
- package/dist/registry.d.ts +357 -0
- package/dist/registry.js +456 -0
- package/dist/registry.js.map +1 -0
- package/dist/session.cjs +2052 -0
- package/dist/session.cjs.map +1 -0
- package/dist/session.d.cts +75 -0
- package/dist/session.d.ts +75 -0
- package/dist/session.js +2047 -0
- package/dist/session.js.map +1 -0
- package/dist/wire.cjs +310 -0
- package/dist/wire.cjs.map +1 -0
- package/dist/wire.d.cts +326 -0
- package/dist/wire.d.ts +326 -0
- package/dist/wire.js +291 -0
- package/dist/wire.js.map +1 -0
- package/package.json +73 -1
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* KindSchema — the data-defined field model for a registered kind.
|
|
3
|
+
*
|
|
4
|
+
* `__kind` (KIND_KEY) is the carried discriminator: it is NOT part of a
|
|
5
|
+
* kind's field map; the parser enforces it via `KindSchema.kind` and stamps
|
|
6
|
+
* it onto every compliant snapshot.
|
|
7
|
+
*
|
|
8
|
+
* Moved from app/(dev)/demos/json-block-detector/kind-schemas.ts.
|
|
9
|
+
*
|
|
10
|
+
* 2026-07-15 expressivity extension (A2) — four constructs the Python-owned
|
|
11
|
+
* pydantic schemas need that the v1 vocabulary could not express:
|
|
12
|
+
* - `{type:"json"}` / `{type:"json[]"}` — any JSON value / array of any
|
|
13
|
+
* JSON values (pydantic bare `Any` fields, `items: {}` arrays, `{}`
|
|
14
|
+
* schemas). A `json` value is implicitly nullable — `null` IS a JSON
|
|
15
|
+
* value — so `nullable` is meaningless (and ignored) on it.
|
|
16
|
+
* - `record` values widened to `"json"` (pydantic `dict[str, Any]` /
|
|
17
|
+
* `additionalProperties: true`).
|
|
18
|
+
* - `union` may now carry `kinds` (object unions — anyOf over kind refs,
|
|
19
|
+
* optionally mixed with scalars). Refs externalize to `kind_edge` rows
|
|
20
|
+
* exactly like `array.itemKinds`.
|
|
21
|
+
* - `KindSchema.root` — a NON-OBJECT root form: the kind's VALUE is the
|
|
22
|
+
* root field itself (scalar / array / json / open object), not a `__kind`
|
|
23
|
+
* object with fields. Root-form kinds are data-only: the streaming
|
|
24
|
+
* `__kind` parser cannot type them (a scalar cannot carry a
|
|
25
|
+
* discriminator) and refuses them loudly; validation goes through the
|
|
26
|
+
* emitted JSON Schema (ajv / Pydantic). `root` and a non-empty `fields`
|
|
27
|
+
* are mutually exclusive.
|
|
28
|
+
* - `inline_object.open` — `additionalProperties: true`; fixes the
|
|
29
|
+
* open-empty-object defect where an open `inline_object{fields:{}}`
|
|
30
|
+
* materialized as CLOSED (schema_proposal / item_presentation class).
|
|
31
|
+
*
|
|
32
|
+
* 2026-07-15 input-semantics extension (W3-A, agent-input bridge) — the
|
|
33
|
+
* constructs the Wave-1 sufficiency survey of all 1,529 live agent variables
|
|
34
|
+
* showed FieldSchema could not carry, added so `AgentVariable` ⇄ kind
|
|
35
|
+
* conversion is faithful:
|
|
36
|
+
* - `FieldBase.description` — human guidance; round-trips JSON Schema
|
|
37
|
+
* `description` and VariableDefinition `helpText`.
|
|
38
|
+
* - `FieldBase.default` — the field's default VALUE (JSON Schema `default`,
|
|
39
|
+
* VariableDefinition `defaultValue`). Annotation-level: validators never
|
|
40
|
+
* apply it; emitters carry it verbatim.
|
|
41
|
+
* - `enum.open` — "one of these options OR any string" (the FE's
|
|
42
|
+
* `allowOther`). Emits as `anyOf: [{type:"string", enum}, {type:"string"}]`
|
|
43
|
+
* so the option set survives instead of widening to bare `string`.
|
|
44
|
+
* - `number` bounds `min`/`max`/`step` — JSON Schema
|
|
45
|
+
* `minimum`/`maximum`/`multipleOf` (number/slider components).
|
|
46
|
+
* - `string[].values` (+ `open`) — an items-enum: array of strings drawn
|
|
47
|
+
* from an option set (checkbox components), `open` meaning the set is
|
|
48
|
+
* advisory (`allowOther` on a multi-select).
|
|
49
|
+
* Picklist bindings, scope bindings, and media component identity are
|
|
50
|
+
* PROVENANCE, not structure — they never enter FieldSchema; the bridge
|
|
51
|
+
* carries them out-of-band (see convert/kind-variable-bridge.ts sidecar).
|
|
52
|
+
*/
|
|
53
|
+
/** System discriminator — hardcoded, not part of per-kind field schemas. */
|
|
54
|
+
declare const KIND_KEY = "__kind";
|
|
55
|
+
type ScalarFieldType = "string" | "number" | "boolean";
|
|
56
|
+
type ArrayItemScalarType = "string" | "number" | "boolean";
|
|
57
|
+
/** Value domain of a `record` field — typed scalars, or any JSON value. */
|
|
58
|
+
type RecordValueType = ArrayItemScalarType | "json";
|
|
59
|
+
type FieldBase = {
|
|
60
|
+
required?: boolean;
|
|
61
|
+
nullable?: boolean;
|
|
62
|
+
/** Human guidance — JSON Schema `description` / variable `helpText`. */
|
|
63
|
+
description?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Default VALUE (JSON Schema `default` / variable `defaultValue`).
|
|
66
|
+
* Annotation-level: validators never apply it; emitters carry it verbatim.
|
|
67
|
+
*/
|
|
68
|
+
default?: unknown;
|
|
69
|
+
};
|
|
70
|
+
type FieldSchema = (FieldBase & {
|
|
71
|
+
type: "string" | "boolean";
|
|
72
|
+
}) | (FieldBase & {
|
|
73
|
+
type: "number";
|
|
74
|
+
/** Inclusive lower bound — JSON Schema `minimum`. */
|
|
75
|
+
min?: number;
|
|
76
|
+
/** Inclusive upper bound — JSON Schema `maximum`. */
|
|
77
|
+
max?: number;
|
|
78
|
+
/** Increment — JSON Schema `multipleOf`. Annotation-level in the parser. */
|
|
79
|
+
step?: number;
|
|
80
|
+
}) | (FieldBase & {
|
|
81
|
+
type: "string[]";
|
|
82
|
+
/** Items-enum: each item must be one of these values (checkbox option sets). */
|
|
83
|
+
values?: string[];
|
|
84
|
+
/** With `values`: the set is advisory — any string item is also legal (`allowOther`). */
|
|
85
|
+
open?: boolean;
|
|
86
|
+
}) | (FieldBase & {
|
|
87
|
+
type: "number[]" | "boolean[]";
|
|
88
|
+
}) | (FieldBase & {
|
|
89
|
+
type: "json";
|
|
90
|
+
}) | (FieldBase & {
|
|
91
|
+
type: "json[]";
|
|
92
|
+
}) | (FieldBase & {
|
|
93
|
+
type: "array";
|
|
94
|
+
itemKinds: string[];
|
|
95
|
+
}) | (FieldBase & {
|
|
96
|
+
type: "object";
|
|
97
|
+
kind: string;
|
|
98
|
+
}) | (FieldBase & {
|
|
99
|
+
type: "inline_object";
|
|
100
|
+
fields: Record<string, FieldSchema>;
|
|
101
|
+
/** additionalProperties: true — unknown keys are legal, not residue-only. */
|
|
102
|
+
open?: boolean;
|
|
103
|
+
}) | (FieldBase & {
|
|
104
|
+
type: "record";
|
|
105
|
+
values: RecordValueType;
|
|
106
|
+
}) | (FieldBase & {
|
|
107
|
+
type: "enum";
|
|
108
|
+
values: string[];
|
|
109
|
+
/** "One of these OR any string" — the option set is advisory (`allowOther`). */
|
|
110
|
+
open?: boolean;
|
|
111
|
+
}) | (FieldBase & {
|
|
112
|
+
type: "union";
|
|
113
|
+
scalars: Array<"string" | "number" | "boolean">;
|
|
114
|
+
/** Object union members — kind refs (anyOf of $refs), may mix with scalars. */
|
|
115
|
+
kinds?: string[];
|
|
116
|
+
});
|
|
117
|
+
/**
|
|
118
|
+
* Domain fields only — __kind is enforced by the parser via KindSchema.kind
|
|
119
|
+
* (block slug). A kind with `root` set has NO field map (fields stays `{}`):
|
|
120
|
+
* its value is the root field's type at the top level. See the module header.
|
|
121
|
+
*/
|
|
122
|
+
type KindSchema = {
|
|
123
|
+
kind: string;
|
|
124
|
+
fields: Record<string, FieldSchema>;
|
|
125
|
+
/** Non-object root form — mutually exclusive with a non-empty `fields`. */
|
|
126
|
+
root?: FieldSchema;
|
|
127
|
+
};
|
|
128
|
+
declare function readObjectKind(value: Record<string, unknown>): string | null;
|
|
129
|
+
declare function isScalarArrayType(type: FieldSchema["type"]): type is "string[]" | "number[]" | "boolean[]";
|
|
130
|
+
declare function scalarArrayItemType(type: "string[]" | "number[]" | "boolean[]"): ArrayItemScalarType;
|
|
131
|
+
/**
|
|
132
|
+
* Does this field's value domain accept ANY JSON shape (object/array/scalar/
|
|
133
|
+
* null alike)? True for `json` and `json[]` ITEMS — the parser treats the
|
|
134
|
+
* subtree under such a field as opaque (no kind identification, no raw_object
|
|
135
|
+
* degradation: unknown structure is the declared contract, not a failure).
|
|
136
|
+
*/
|
|
137
|
+
declare function isJsonAnyField(field: FieldSchema): boolean;
|
|
138
|
+
|
|
139
|
+
export { type ArrayItemScalarType as A, type FieldSchema as F, KIND_KEY as K, type RecordValueType as R, type ScalarFieldType as S, type KindSchema as a, isScalarArrayType as b, isJsonAnyField as i, readObjectKind as r, scalarArrayItemType as s };
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* KindSchema — the data-defined field model for a registered kind.
|
|
3
|
+
*
|
|
4
|
+
* `__kind` (KIND_KEY) is the carried discriminator: it is NOT part of a
|
|
5
|
+
* kind's field map; the parser enforces it via `KindSchema.kind` and stamps
|
|
6
|
+
* it onto every compliant snapshot.
|
|
7
|
+
*
|
|
8
|
+
* Moved from app/(dev)/demos/json-block-detector/kind-schemas.ts.
|
|
9
|
+
*
|
|
10
|
+
* 2026-07-15 expressivity extension (A2) — four constructs the Python-owned
|
|
11
|
+
* pydantic schemas need that the v1 vocabulary could not express:
|
|
12
|
+
* - `{type:"json"}` / `{type:"json[]"}` — any JSON value / array of any
|
|
13
|
+
* JSON values (pydantic bare `Any` fields, `items: {}` arrays, `{}`
|
|
14
|
+
* schemas). A `json` value is implicitly nullable — `null` IS a JSON
|
|
15
|
+
* value — so `nullable` is meaningless (and ignored) on it.
|
|
16
|
+
* - `record` values widened to `"json"` (pydantic `dict[str, Any]` /
|
|
17
|
+
* `additionalProperties: true`).
|
|
18
|
+
* - `union` may now carry `kinds` (object unions — anyOf over kind refs,
|
|
19
|
+
* optionally mixed with scalars). Refs externalize to `kind_edge` rows
|
|
20
|
+
* exactly like `array.itemKinds`.
|
|
21
|
+
* - `KindSchema.root` — a NON-OBJECT root form: the kind's VALUE is the
|
|
22
|
+
* root field itself (scalar / array / json / open object), not a `__kind`
|
|
23
|
+
* object with fields. Root-form kinds are data-only: the streaming
|
|
24
|
+
* `__kind` parser cannot type them (a scalar cannot carry a
|
|
25
|
+
* discriminator) and refuses them loudly; validation goes through the
|
|
26
|
+
* emitted JSON Schema (ajv / Pydantic). `root` and a non-empty `fields`
|
|
27
|
+
* are mutually exclusive.
|
|
28
|
+
* - `inline_object.open` — `additionalProperties: true`; fixes the
|
|
29
|
+
* open-empty-object defect where an open `inline_object{fields:{}}`
|
|
30
|
+
* materialized as CLOSED (schema_proposal / item_presentation class).
|
|
31
|
+
*
|
|
32
|
+
* 2026-07-15 input-semantics extension (W3-A, agent-input bridge) — the
|
|
33
|
+
* constructs the Wave-1 sufficiency survey of all 1,529 live agent variables
|
|
34
|
+
* showed FieldSchema could not carry, added so `AgentVariable` ⇄ kind
|
|
35
|
+
* conversion is faithful:
|
|
36
|
+
* - `FieldBase.description` — human guidance; round-trips JSON Schema
|
|
37
|
+
* `description` and VariableDefinition `helpText`.
|
|
38
|
+
* - `FieldBase.default` — the field's default VALUE (JSON Schema `default`,
|
|
39
|
+
* VariableDefinition `defaultValue`). Annotation-level: validators never
|
|
40
|
+
* apply it; emitters carry it verbatim.
|
|
41
|
+
* - `enum.open` — "one of these options OR any string" (the FE's
|
|
42
|
+
* `allowOther`). Emits as `anyOf: [{type:"string", enum}, {type:"string"}]`
|
|
43
|
+
* so the option set survives instead of widening to bare `string`.
|
|
44
|
+
* - `number` bounds `min`/`max`/`step` — JSON Schema
|
|
45
|
+
* `minimum`/`maximum`/`multipleOf` (number/slider components).
|
|
46
|
+
* - `string[].values` (+ `open`) — an items-enum: array of strings drawn
|
|
47
|
+
* from an option set (checkbox components), `open` meaning the set is
|
|
48
|
+
* advisory (`allowOther` on a multi-select).
|
|
49
|
+
* Picklist bindings, scope bindings, and media component identity are
|
|
50
|
+
* PROVENANCE, not structure — they never enter FieldSchema; the bridge
|
|
51
|
+
* carries them out-of-band (see convert/kind-variable-bridge.ts sidecar).
|
|
52
|
+
*/
|
|
53
|
+
/** System discriminator — hardcoded, not part of per-kind field schemas. */
|
|
54
|
+
declare const KIND_KEY = "__kind";
|
|
55
|
+
type ScalarFieldType = "string" | "number" | "boolean";
|
|
56
|
+
type ArrayItemScalarType = "string" | "number" | "boolean";
|
|
57
|
+
/** Value domain of a `record` field — typed scalars, or any JSON value. */
|
|
58
|
+
type RecordValueType = ArrayItemScalarType | "json";
|
|
59
|
+
type FieldBase = {
|
|
60
|
+
required?: boolean;
|
|
61
|
+
nullable?: boolean;
|
|
62
|
+
/** Human guidance — JSON Schema `description` / variable `helpText`. */
|
|
63
|
+
description?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Default VALUE (JSON Schema `default` / variable `defaultValue`).
|
|
66
|
+
* Annotation-level: validators never apply it; emitters carry it verbatim.
|
|
67
|
+
*/
|
|
68
|
+
default?: unknown;
|
|
69
|
+
};
|
|
70
|
+
type FieldSchema = (FieldBase & {
|
|
71
|
+
type: "string" | "boolean";
|
|
72
|
+
}) | (FieldBase & {
|
|
73
|
+
type: "number";
|
|
74
|
+
/** Inclusive lower bound — JSON Schema `minimum`. */
|
|
75
|
+
min?: number;
|
|
76
|
+
/** Inclusive upper bound — JSON Schema `maximum`. */
|
|
77
|
+
max?: number;
|
|
78
|
+
/** Increment — JSON Schema `multipleOf`. Annotation-level in the parser. */
|
|
79
|
+
step?: number;
|
|
80
|
+
}) | (FieldBase & {
|
|
81
|
+
type: "string[]";
|
|
82
|
+
/** Items-enum: each item must be one of these values (checkbox option sets). */
|
|
83
|
+
values?: string[];
|
|
84
|
+
/** With `values`: the set is advisory — any string item is also legal (`allowOther`). */
|
|
85
|
+
open?: boolean;
|
|
86
|
+
}) | (FieldBase & {
|
|
87
|
+
type: "number[]" | "boolean[]";
|
|
88
|
+
}) | (FieldBase & {
|
|
89
|
+
type: "json";
|
|
90
|
+
}) | (FieldBase & {
|
|
91
|
+
type: "json[]";
|
|
92
|
+
}) | (FieldBase & {
|
|
93
|
+
type: "array";
|
|
94
|
+
itemKinds: string[];
|
|
95
|
+
}) | (FieldBase & {
|
|
96
|
+
type: "object";
|
|
97
|
+
kind: string;
|
|
98
|
+
}) | (FieldBase & {
|
|
99
|
+
type: "inline_object";
|
|
100
|
+
fields: Record<string, FieldSchema>;
|
|
101
|
+
/** additionalProperties: true — unknown keys are legal, not residue-only. */
|
|
102
|
+
open?: boolean;
|
|
103
|
+
}) | (FieldBase & {
|
|
104
|
+
type: "record";
|
|
105
|
+
values: RecordValueType;
|
|
106
|
+
}) | (FieldBase & {
|
|
107
|
+
type: "enum";
|
|
108
|
+
values: string[];
|
|
109
|
+
/** "One of these OR any string" — the option set is advisory (`allowOther`). */
|
|
110
|
+
open?: boolean;
|
|
111
|
+
}) | (FieldBase & {
|
|
112
|
+
type: "union";
|
|
113
|
+
scalars: Array<"string" | "number" | "boolean">;
|
|
114
|
+
/** Object union members — kind refs (anyOf of $refs), may mix with scalars. */
|
|
115
|
+
kinds?: string[];
|
|
116
|
+
});
|
|
117
|
+
/**
|
|
118
|
+
* Domain fields only — __kind is enforced by the parser via KindSchema.kind
|
|
119
|
+
* (block slug). A kind with `root` set has NO field map (fields stays `{}`):
|
|
120
|
+
* its value is the root field's type at the top level. See the module header.
|
|
121
|
+
*/
|
|
122
|
+
type KindSchema = {
|
|
123
|
+
kind: string;
|
|
124
|
+
fields: Record<string, FieldSchema>;
|
|
125
|
+
/** Non-object root form — mutually exclusive with a non-empty `fields`. */
|
|
126
|
+
root?: FieldSchema;
|
|
127
|
+
};
|
|
128
|
+
declare function readObjectKind(value: Record<string, unknown>): string | null;
|
|
129
|
+
declare function isScalarArrayType(type: FieldSchema["type"]): type is "string[]" | "number[]" | "boolean[]";
|
|
130
|
+
declare function scalarArrayItemType(type: "string[]" | "number[]" | "boolean[]"): ArrayItemScalarType;
|
|
131
|
+
/**
|
|
132
|
+
* Does this field's value domain accept ANY JSON shape (object/array/scalar/
|
|
133
|
+
* null alike)? True for `json` and `json[]` ITEMS — the parser treats the
|
|
134
|
+
* subtree under such a field as opaque (no kind identification, no raw_object
|
|
135
|
+
* degradation: unknown structure is the declared contract, not a failure).
|
|
136
|
+
*/
|
|
137
|
+
declare function isJsonAnyField(field: FieldSchema): boolean;
|
|
138
|
+
|
|
139
|
+
export { type ArrayItemScalarType as A, type FieldSchema as F, KIND_KEY as K, type RecordValueType as R, type ScalarFieldType as S, type KindSchema as a, isScalarArrayType as b, isJsonAnyField as i, readObjectKind as r, scalarArrayItemType as s };
|