@ai-matrx/content-ir-react 0.7.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.
Files changed (46) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/dist/component-resolution.types-BS1ySIg-.d.cts +104 -0
  3. package/dist/component-resolution.types-BS1ySIg-.d.ts +104 -0
  4. package/dist/component-resolution.types-fvR92hW7.d.cts +142 -0
  5. package/dist/component-resolution.types-fvR92hW7.d.ts +142 -0
  6. package/dist/db-component.cjs +226 -0
  7. package/dist/db-component.cjs.map +1 -0
  8. package/dist/db-component.d.cts +267 -0
  9. package/dist/db-component.d.ts +267 -0
  10. package/dist/db-component.js +194 -0
  11. package/dist/db-component.js.map +1 -0
  12. package/dist/host-types-CZ_Bkp4R.d.ts +131 -0
  13. package/dist/host-types-DvGv8s9L.d.cts +131 -0
  14. package/dist/host.cjs +74 -0
  15. package/dist/host.cjs.map +1 -0
  16. package/dist/host.d.cts +24 -0
  17. package/dist/host.d.ts +24 -0
  18. package/dist/host.js +52 -0
  19. package/dist/host.js.map +1 -0
  20. package/dist/index.cjs +356 -90
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.cts +280 -672
  23. package/dist/index.d.ts +280 -672
  24. package/dist/index.js +316 -31
  25. package/dist/index.js.map +1 -1
  26. package/dist/react.cjs +361 -0
  27. package/dist/react.cjs.map +1 -0
  28. package/dist/react.d.cts +195 -0
  29. package/dist/react.d.ts +195 -0
  30. package/dist/react.js +344 -0
  31. package/dist/react.js.map +1 -0
  32. package/dist/resolver.cjs +327 -0
  33. package/dist/resolver.cjs.map +1 -0
  34. package/dist/resolver.d.cts +133 -0
  35. package/dist/resolver.d.ts +133 -0
  36. package/dist/resolver.js +304 -0
  37. package/dist/resolver.js.map +1 -0
  38. package/dist/route-C1XNcubB.d.ts +433 -0
  39. package/dist/route-C55jsF4B.d.cts +433 -0
  40. package/dist/route.cjs +259 -0
  41. package/dist/route.cjs.map +1 -0
  42. package/dist/route.d.cts +4 -0
  43. package/dist/route.d.ts +4 -0
  44. package/dist/route.js +247 -0
  45. package/dist/route.js.map +1 -0
  46. package/package.json +79 -5
@@ -0,0 +1,195 @@
1
+ import { c as KindDefinitionSource, C as ContentIrHost } from './host-types-DvGv8s9L.cjs';
2
+ import { d as ComponentResolutionSource } from './component-resolution.types-BS1ySIg-.cjs';
3
+ import * as React from 'react';
4
+ import React__default, { ReactNode } from 'react';
5
+ import '@ai-matrx/content-ir';
6
+
7
+ /**
8
+ * The two registries this hook watches. Passed explicitly by a host whose
9
+ * render path sits BELOW no provider — matrx-frontend's block renderer runs
10
+ * deep inside chat, workflow, and canvas trees that predate this package, and
11
+ * threading a provider through all of them to read two counters would be the
12
+ * tail wagging the dog.
13
+ */
14
+ interface KindVersionSources {
15
+ kinds: Pick<KindDefinitionSource, "getKindVersion" | "subscribeKind">;
16
+ components: Pick<ComponentResolutionSource, "getKindVersion" | "subscribeKind">;
17
+ }
18
+ /**
19
+ * Subscribes the caller to registry changes FOR ONE KIND and returns that
20
+ * kind's combined version. Pass null for blocks with no envelope kind — they
21
+ * never repaint from registries (nothing to learn about them).
22
+ *
23
+ * `sources` defaults to the provider's host. Passing them explicitly is the
24
+ * supported way to use this hook outside a provider.
25
+ */
26
+ declare function useContentIrKindVersion(kind: string | null, sources?: KindVersionSources): number;
27
+
28
+ declare function isRecordValue(value: unknown): value is Record<string, unknown>;
29
+ /**
30
+ * True when `applyIrKindRoute` has a registered render path for this kind — a
31
+ * compiled legacy bridge OR any ACTIVE resolver row (including db-sourced user
32
+ * components, which route to `db_kind_component`). Mirrors the route's own
33
+ * decision order; requires the resolver warm tier for db rows (see the warm
34
+ * tick in {@link KindInstanceRender}).
35
+ */
36
+ /**
37
+ * Is there a render path for this kind that is NOT the generic key/value floor?
38
+ *
39
+ * 🚨 READ THIS BEFORE USING IT AS A HEALTH SIGNAL. It answers a narrow
40
+ * question — "will a direct-object render mount something other than the
41
+ * generic view?" — and it is the right question for the fallback decision it
42
+ * was written for. It is the WRONG question for "does this kind work".
43
+ *
44
+ * It cannot see any of: whether the kind's schema loads, whether a streamed
45
+ * payload is recognized from text, or what `applyIrKindRoute` returns for a
46
+ * real envelope. On 2026-08-29 every one of ~221 kinds that had stopped
47
+ * rendering in chat still answered `true` here, because their component rows
48
+ * were fine — the recognition step ahead of the component was not.
49
+ *
50
+ * For "does this kind work", run the render paths
51
+ * (`features/content-ir/render-paths`) and read the route's actual answer.
52
+ */
53
+ declare function kindIsRoutable(kind: string, host: ContentIrHost): boolean;
54
+ interface KindInstanceRenderProps {
55
+ kind: string;
56
+ /** The canonical instance value (a `kind_example.data` row, a form-emitted instance, a node output). */
57
+ value: unknown;
58
+ /** Show the honest "no component registered" notice when unroutable. Default true. */
59
+ showRoutingNote?: boolean;
60
+ /**
61
+ * What to render when the routing decision lands on "no component exists for
62
+ * this kind". The universal document view is the right answer almost
63
+ * everywhere — it reads well and hides nothing. It is still the wrong answer
64
+ * when the raw value is an internal ENVELOPE rather than content: an
65
+ * `agent_result` dumped the verbatim prompt, the model id and the token bill
66
+ * into the box a learner was waiting on. Passing a fallback lets that caller
67
+ * show what the reader actually wants WITHOUT anyone second-guessing the
68
+ * routing decision — this component stays the ONE place that decides whether
69
+ * a kind has a component.
70
+ *
71
+ * Omitted → the host's floor, exactly as before.
72
+ */
73
+ unroutableFallback?: ReactNode;
74
+ /**
75
+ * Chrome, per THE WRAPPER LAW: a host frame either IS the chrome or has none.
76
+ * "card" (default) keeps a bordered surface for preview surfaces. "bare"
77
+ * renders with NO border/background/pad — for a host that already draws a
78
+ * titled card, where the default produced a two-tone box-in-a-box with a dead
79
+ * band around it.
80
+ */
81
+ variant?: "card" | "bare";
82
+ className?: string;
83
+ }
84
+ declare function KindInstanceRender({ kind, value, showRoutingNote, unroutableFallback, variant, className, }: KindInstanceRenderProps): React.JSX.Element;
85
+
86
+ /**
87
+ * The safety net + the "still arriving" affordance for a provisional kind
88
+ * render (streaming partial kinds — see `route/partial-kind-route.ts` and
89
+ * `common-docs/systems/content-ir-system/STREAMING_PARTIAL_KINDS.md`).
90
+ *
91
+ * TWO JOBS
92
+ * --------
93
+ * 1. **Never let a component throw mid-stream.** A provisional value may be
94
+ * missing required fields. The routed kind opted in to tolerating that
95
+ * (`partialReady`), but an opt-in is a claim, not a proof — so a throw is
96
+ * caught here, SCREAMS through the host's error reporter, drops the kind
97
+ * back to withhold for the session (`markKindPartialUnsafe`), and falls back
98
+ * to the kind's own loading skeleton. The user sees the pre-partial
99
+ * behavior, not a broken message.
100
+ * 2. **Say it is still arriving.** The user must be able to tell a live fill-in
101
+ * from a finished render, and it must not read as an error. A quiet chip
102
+ * rides the block's top edge — absolutely positioned and
103
+ * `pointer-events-none`, so it costs the content no layout and cannot shift
104
+ * the page when it disappears. It sits ON the border rather than inside the
105
+ * block: a routed kind often renders its own chrome, and a chip inside the
106
+ * box lands on top of those controls.
107
+ *
108
+ * No wrapper chrome: no border, no background, no padding. The kind component
109
+ * already carries its own (THE WRAPPER LAW).
110
+ */
111
+
112
+ interface ProvisionalKindBoundaryOwnProps {
113
+ kind: string;
114
+ /** Rendered instead of the children when the provisional render throws. */
115
+ fallback: ReactNode;
116
+ children: ReactNode;
117
+ }
118
+ declare function ProvisionalKindBoundary(props: ProvisionalKindBoundaryOwnProps): React__default.JSX.Element;
119
+ /**
120
+ * The "still arriving" frame. `aria-busy` carries the same fact to assistive
121
+ * tech that the chip carries visually. The chip's own rendering is a host seam
122
+ * (`renderShimmer`) so an app with a shimmer primitive uses it and one without
123
+ * still says the true thing, plainly.
124
+ */
125
+ declare function ProvisionalKindFrame({ children }: {
126
+ children: ReactNode;
127
+ }): React__default.JSX.Element;
128
+
129
+ interface GenericStructuredViewProps {
130
+ /** The raw region source — the zero-loss floor when no envelope survived. */
131
+ content: string;
132
+ /** Carries `__ir` (the parsed envelope) and `__ir_route` (the seam marker). */
133
+ metadata?: Record<string, unknown>;
134
+ /**
135
+ * What to show while the region is still streaming. Hosts with a shimmer or
136
+ * an icon set pass theirs; the default is the same sentence, plainly.
137
+ */
138
+ streamingIndicator?: ReactNode;
139
+ className?: string;
140
+ }
141
+ declare function GenericStructuredView({ content, metadata, streamingIndicator, className, }: GenericStructuredViewProps): React.JSX.Element;
142
+
143
+ interface DelegatedOutputProps {
144
+ output: unknown;
145
+ /** The wrapper's `output_kind` — the node's DECLARATION, the fallback. */
146
+ declaredKind: string | null;
147
+ /**
148
+ * What to draw for a value with no kind at all, and as the unroutable
149
+ * fallback. Hosts with a settled-output body (the same one their readout
150
+ * uses — never a second reader) pass it; otherwise the floor draws it.
151
+ *
152
+ * A RENDER FUNCTION, not a node: the fallback needs the payload, and the only
153
+ * component that has read it is this one. Handing back a static node would
154
+ * force every host to re-read the wrapper itself — a second reader, which is
155
+ * exactly what this family exists to prevent.
156
+ */
157
+ fallback?: (output: unknown) => ReactNode;
158
+ /** What to say when the step produced nothing. */
159
+ emptyLabel?: string;
160
+ }
161
+ /**
162
+ * The delegation seam — the ONLY thing these components do with a payload.
163
+ *
164
+ * In-band `__kind` wins over the node's DECLARATION, the same law a run reducer
165
+ * follows: the discriminator inside the value describes what we are actually
166
+ * holding, so it is what routes. With no kind at all there is nothing to route
167
+ * to, and the host's fallback (or the floor) shows what the step produced.
168
+ */
169
+ declare function DelegatedOutput({ output, declaredKind, fallback, emptyLabel, }: DelegatedOutputProps): React.JSX.Element;
170
+ interface NodeOutcomeViewProps {
171
+ serverData?: unknown;
172
+ /** Passed through to {@link DelegatedOutput}. */
173
+ fallback?: (output: unknown) => ReactNode;
174
+ }
175
+ /** THE renderer for the `node_outcome` runtime wrapper kind. */
176
+ declare function NodeOutcomeView({ serverData, fallback }: NodeOutcomeViewProps): React.JSX.Element | null;
177
+ interface RunResultViewProps {
178
+ serverData?: unknown;
179
+ fallback?: (output: unknown) => ReactNode;
180
+ }
181
+ /**
182
+ * THE renderer for the `run_result` runtime wrapper kind.
183
+ *
184
+ * One finished run: one `node_outcome` per TERMINAL node — each delegated to
185
+ * {@link NodeOutcomeView}, which delegates the payload inside it to the data
186
+ * kind's own component. Recursion all the way down; no payload is rendered
187
+ * here, and no `final_text` is read here.
188
+ *
189
+ * The run's own `output` is rendered ONLY when the run declared no terminal
190
+ * outcomes — otherwise it is the same content the outcomes already carry, and
191
+ * showing both is the duplication the wrapper exists to prevent.
192
+ */
193
+ declare function RunResultView({ serverData, fallback }: RunResultViewProps): React.JSX.Element | null;
194
+
195
+ export { DelegatedOutput, type DelegatedOutputProps, GenericStructuredView, type GenericStructuredViewProps, KindInstanceRender, type KindInstanceRenderProps, type KindVersionSources, NodeOutcomeView, type NodeOutcomeViewProps, ProvisionalKindBoundary, ProvisionalKindFrame, RunResultView, type RunResultViewProps, isRecordValue, kindIsRoutable, useContentIrKindVersion };
@@ -0,0 +1,195 @@
1
+ import { c as KindDefinitionSource, C as ContentIrHost } from './host-types-CZ_Bkp4R.js';
2
+ import { d as ComponentResolutionSource } from './component-resolution.types-BS1ySIg-.js';
3
+ import * as React from 'react';
4
+ import React__default, { ReactNode } from 'react';
5
+ import '@ai-matrx/content-ir';
6
+
7
+ /**
8
+ * The two registries this hook watches. Passed explicitly by a host whose
9
+ * render path sits BELOW no provider — matrx-frontend's block renderer runs
10
+ * deep inside chat, workflow, and canvas trees that predate this package, and
11
+ * threading a provider through all of them to read two counters would be the
12
+ * tail wagging the dog.
13
+ */
14
+ interface KindVersionSources {
15
+ kinds: Pick<KindDefinitionSource, "getKindVersion" | "subscribeKind">;
16
+ components: Pick<ComponentResolutionSource, "getKindVersion" | "subscribeKind">;
17
+ }
18
+ /**
19
+ * Subscribes the caller to registry changes FOR ONE KIND and returns that
20
+ * kind's combined version. Pass null for blocks with no envelope kind — they
21
+ * never repaint from registries (nothing to learn about them).
22
+ *
23
+ * `sources` defaults to the provider's host. Passing them explicitly is the
24
+ * supported way to use this hook outside a provider.
25
+ */
26
+ declare function useContentIrKindVersion(kind: string | null, sources?: KindVersionSources): number;
27
+
28
+ declare function isRecordValue(value: unknown): value is Record<string, unknown>;
29
+ /**
30
+ * True when `applyIrKindRoute` has a registered render path for this kind — a
31
+ * compiled legacy bridge OR any ACTIVE resolver row (including db-sourced user
32
+ * components, which route to `db_kind_component`). Mirrors the route's own
33
+ * decision order; requires the resolver warm tier for db rows (see the warm
34
+ * tick in {@link KindInstanceRender}).
35
+ */
36
+ /**
37
+ * Is there a render path for this kind that is NOT the generic key/value floor?
38
+ *
39
+ * 🚨 READ THIS BEFORE USING IT AS A HEALTH SIGNAL. It answers a narrow
40
+ * question — "will a direct-object render mount something other than the
41
+ * generic view?" — and it is the right question for the fallback decision it
42
+ * was written for. It is the WRONG question for "does this kind work".
43
+ *
44
+ * It cannot see any of: whether the kind's schema loads, whether a streamed
45
+ * payload is recognized from text, or what `applyIrKindRoute` returns for a
46
+ * real envelope. On 2026-08-29 every one of ~221 kinds that had stopped
47
+ * rendering in chat still answered `true` here, because their component rows
48
+ * were fine — the recognition step ahead of the component was not.
49
+ *
50
+ * For "does this kind work", run the render paths
51
+ * (`features/content-ir/render-paths`) and read the route's actual answer.
52
+ */
53
+ declare function kindIsRoutable(kind: string, host: ContentIrHost): boolean;
54
+ interface KindInstanceRenderProps {
55
+ kind: string;
56
+ /** The canonical instance value (a `kind_example.data` row, a form-emitted instance, a node output). */
57
+ value: unknown;
58
+ /** Show the honest "no component registered" notice when unroutable. Default true. */
59
+ showRoutingNote?: boolean;
60
+ /**
61
+ * What to render when the routing decision lands on "no component exists for
62
+ * this kind". The universal document view is the right answer almost
63
+ * everywhere — it reads well and hides nothing. It is still the wrong answer
64
+ * when the raw value is an internal ENVELOPE rather than content: an
65
+ * `agent_result` dumped the verbatim prompt, the model id and the token bill
66
+ * into the box a learner was waiting on. Passing a fallback lets that caller
67
+ * show what the reader actually wants WITHOUT anyone second-guessing the
68
+ * routing decision — this component stays the ONE place that decides whether
69
+ * a kind has a component.
70
+ *
71
+ * Omitted → the host's floor, exactly as before.
72
+ */
73
+ unroutableFallback?: ReactNode;
74
+ /**
75
+ * Chrome, per THE WRAPPER LAW: a host frame either IS the chrome or has none.
76
+ * "card" (default) keeps a bordered surface for preview surfaces. "bare"
77
+ * renders with NO border/background/pad — for a host that already draws a
78
+ * titled card, where the default produced a two-tone box-in-a-box with a dead
79
+ * band around it.
80
+ */
81
+ variant?: "card" | "bare";
82
+ className?: string;
83
+ }
84
+ declare function KindInstanceRender({ kind, value, showRoutingNote, unroutableFallback, variant, className, }: KindInstanceRenderProps): React.JSX.Element;
85
+
86
+ /**
87
+ * The safety net + the "still arriving" affordance for a provisional kind
88
+ * render (streaming partial kinds — see `route/partial-kind-route.ts` and
89
+ * `common-docs/systems/content-ir-system/STREAMING_PARTIAL_KINDS.md`).
90
+ *
91
+ * TWO JOBS
92
+ * --------
93
+ * 1. **Never let a component throw mid-stream.** A provisional value may be
94
+ * missing required fields. The routed kind opted in to tolerating that
95
+ * (`partialReady`), but an opt-in is a claim, not a proof — so a throw is
96
+ * caught here, SCREAMS through the host's error reporter, drops the kind
97
+ * back to withhold for the session (`markKindPartialUnsafe`), and falls back
98
+ * to the kind's own loading skeleton. The user sees the pre-partial
99
+ * behavior, not a broken message.
100
+ * 2. **Say it is still arriving.** The user must be able to tell a live fill-in
101
+ * from a finished render, and it must not read as an error. A quiet chip
102
+ * rides the block's top edge — absolutely positioned and
103
+ * `pointer-events-none`, so it costs the content no layout and cannot shift
104
+ * the page when it disappears. It sits ON the border rather than inside the
105
+ * block: a routed kind often renders its own chrome, and a chip inside the
106
+ * box lands on top of those controls.
107
+ *
108
+ * No wrapper chrome: no border, no background, no padding. The kind component
109
+ * already carries its own (THE WRAPPER LAW).
110
+ */
111
+
112
+ interface ProvisionalKindBoundaryOwnProps {
113
+ kind: string;
114
+ /** Rendered instead of the children when the provisional render throws. */
115
+ fallback: ReactNode;
116
+ children: ReactNode;
117
+ }
118
+ declare function ProvisionalKindBoundary(props: ProvisionalKindBoundaryOwnProps): React__default.JSX.Element;
119
+ /**
120
+ * The "still arriving" frame. `aria-busy` carries the same fact to assistive
121
+ * tech that the chip carries visually. The chip's own rendering is a host seam
122
+ * (`renderShimmer`) so an app with a shimmer primitive uses it and one without
123
+ * still says the true thing, plainly.
124
+ */
125
+ declare function ProvisionalKindFrame({ children }: {
126
+ children: ReactNode;
127
+ }): React__default.JSX.Element;
128
+
129
+ interface GenericStructuredViewProps {
130
+ /** The raw region source — the zero-loss floor when no envelope survived. */
131
+ content: string;
132
+ /** Carries `__ir` (the parsed envelope) and `__ir_route` (the seam marker). */
133
+ metadata?: Record<string, unknown>;
134
+ /**
135
+ * What to show while the region is still streaming. Hosts with a shimmer or
136
+ * an icon set pass theirs; the default is the same sentence, plainly.
137
+ */
138
+ streamingIndicator?: ReactNode;
139
+ className?: string;
140
+ }
141
+ declare function GenericStructuredView({ content, metadata, streamingIndicator, className, }: GenericStructuredViewProps): React.JSX.Element;
142
+
143
+ interface DelegatedOutputProps {
144
+ output: unknown;
145
+ /** The wrapper's `output_kind` — the node's DECLARATION, the fallback. */
146
+ declaredKind: string | null;
147
+ /**
148
+ * What to draw for a value with no kind at all, and as the unroutable
149
+ * fallback. Hosts with a settled-output body (the same one their readout
150
+ * uses — never a second reader) pass it; otherwise the floor draws it.
151
+ *
152
+ * A RENDER FUNCTION, not a node: the fallback needs the payload, and the only
153
+ * component that has read it is this one. Handing back a static node would
154
+ * force every host to re-read the wrapper itself — a second reader, which is
155
+ * exactly what this family exists to prevent.
156
+ */
157
+ fallback?: (output: unknown) => ReactNode;
158
+ /** What to say when the step produced nothing. */
159
+ emptyLabel?: string;
160
+ }
161
+ /**
162
+ * The delegation seam — the ONLY thing these components do with a payload.
163
+ *
164
+ * In-band `__kind` wins over the node's DECLARATION, the same law a run reducer
165
+ * follows: the discriminator inside the value describes what we are actually
166
+ * holding, so it is what routes. With no kind at all there is nothing to route
167
+ * to, and the host's fallback (or the floor) shows what the step produced.
168
+ */
169
+ declare function DelegatedOutput({ output, declaredKind, fallback, emptyLabel, }: DelegatedOutputProps): React.JSX.Element;
170
+ interface NodeOutcomeViewProps {
171
+ serverData?: unknown;
172
+ /** Passed through to {@link DelegatedOutput}. */
173
+ fallback?: (output: unknown) => ReactNode;
174
+ }
175
+ /** THE renderer for the `node_outcome` runtime wrapper kind. */
176
+ declare function NodeOutcomeView({ serverData, fallback }: NodeOutcomeViewProps): React.JSX.Element | null;
177
+ interface RunResultViewProps {
178
+ serverData?: unknown;
179
+ fallback?: (output: unknown) => ReactNode;
180
+ }
181
+ /**
182
+ * THE renderer for the `run_result` runtime wrapper kind.
183
+ *
184
+ * One finished run: one `node_outcome` per TERMINAL node — each delegated to
185
+ * {@link NodeOutcomeView}, which delegates the payload inside it to the data
186
+ * kind's own component. Recursion all the way down; no payload is rendered
187
+ * here, and no `final_text` is read here.
188
+ *
189
+ * The run's own `output` is rendered ONLY when the run declared no terminal
190
+ * outcomes — otherwise it is the same content the outcomes already carry, and
191
+ * showing both is the duplication the wrapper exists to prevent.
192
+ */
193
+ declare function RunResultView({ serverData, fallback }: RunResultViewProps): React.JSX.Element | null;
194
+
195
+ export { DelegatedOutput, type DelegatedOutputProps, GenericStructuredView, type GenericStructuredViewProps, KindInstanceRender, type KindInstanceRenderProps, type KindVersionSources, NodeOutcomeView, type NodeOutcomeViewProps, ProvisionalKindBoundary, ProvisionalKindFrame, RunResultView, type RunResultViewProps, isRecordValue, kindIsRoutable, useContentIrKindVersion };