@ai-matrx/content-ir-react 0.13.18 → 0.15.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.
@@ -17,6 +17,25 @@ interface DirectiveApplyResult {
17
17
  */
18
18
  records?: DirectiveRecordRef[];
19
19
  }
20
+ /**
21
+ * What the server's action ledger says about ONE block, read on mount so a
22
+ * reloaded page never offers "Apply" for work that already ran (reviewer
23
+ * defect 5, 2026-10-02).
24
+ *
25
+ * - `not_applied` — still to do (or partly done: the batch re-applies, and the
26
+ * server replays the members it already holds). The card offers Apply.
27
+ * - `in_flight` — another request is applying it right now. The card says it
28
+ * is finishing and asks again shortly; it offers neither Apply nor a tally.
29
+ * - `applied` — the ledger holds every item. The card shows the tally exactly
30
+ * as a fresh apply would: the ledger's own sentence and the records, as doors.
31
+ */
32
+ interface DirectiveApplyState {
33
+ state: "not_applied" | "in_flight" | "applied";
34
+ /** The ledger row's sentence ("Created task."), never composed client-side. */
35
+ message?: string | null;
36
+ /** The records the original apply wrote — the tally's doors. */
37
+ records?: DirectiveRecordRef[];
38
+ }
20
39
  /** One record a directive names: the noun it is, and its id. */
21
40
  interface DirectiveRecordRef {
22
41
  noun: string;
@@ -43,6 +62,28 @@ interface DirectiveAskRequest {
43
62
  items: Record<string, unknown>[];
44
63
  /** The noun's human label ("Task"), from the host's catalog when it has one. */
45
64
  nounLabel: string;
65
+ /**
66
+ * True for "Run again": the ledger already holds this block, and a yes runs
67
+ * it a SECOND time (`force`) — another copy for a create, the same fields
68
+ * written again for an update, another delete for a restored record. The
69
+ * question must say so.
70
+ */
71
+ again?: boolean;
72
+ }
73
+ /**
74
+ * The shell a card hands its host — the two keys, plus WHERE it sits.
75
+ *
76
+ * `conversationId` is the conversation the card renders in (a chat message),
77
+ * absent in a person's own content (a note). It is the idempotency NAMESPACE:
78
+ * a card in an agent's message must apply under the SAME key as that
79
+ * proposal's Approve button, or the one action could run twice.
80
+ */
81
+ interface DirectiveShell {
82
+ __kind: string;
83
+ items: Record<string, unknown>[];
84
+ conversationId?: string;
85
+ /** "Run again": skip the ledger's dedup and apply a second time. */
86
+ force?: boolean;
46
87
  }
47
88
  interface DirectiveOpenItemOptions {
48
89
  /** The item, `__kind`-stamped when the shape has an item kind. */
@@ -71,10 +112,7 @@ interface DirectiveHost {
71
112
  * item against the registered model and runs the ONE handler; idempotent).
72
113
  * Reject with an Error whose message is safe to show.
73
114
  */
74
- confirm?: (shell: {
75
- __kind: string;
76
- items: Record<string, unknown>[];
77
- }) => Promise<DirectiveApplyResult>;
115
+ confirm?: (shell: DirectiveShell) => Promise<DirectiveApplyResult>;
78
116
  /**
79
117
  * Ask the person BEFORE anything runs, naming the consequence (the records,
80
118
  * what changes). Resolve `true` to go ahead, `false` to leave the card as it
@@ -84,6 +122,17 @@ interface DirectiveHost {
84
122
  * will read "Applying…" while its dialog is up).
85
123
  */
86
124
  ask?: (request: DirectiveAskRequest) => Promise<boolean>;
125
+ /**
126
+ * Has this exact block already been applied? Read ONCE when the card mounts
127
+ * (and again while the answer is `in_flight`), so the card survives a reload:
128
+ * the server ledger, not component state, is what knows. The identity is the
129
+ * server's (it hashes the validated items in the same namespace `confirm`
130
+ * applies in), so a host asks — it never computes. Batch on the host side if
131
+ * a page carries many cards. Reject with an Error when the ledger cannot be
132
+ * read: the card reports it and offers Apply, which is safe because `confirm`
133
+ * is idempotent. Absent → the card starts at Apply, as before.
134
+ */
135
+ applyState?: (shell: DirectiveShell) => Promise<DirectiveApplyState>;
87
136
  /**
88
137
  * Draw ONE existing record by its live name, as a way to open it. Used on
89
138
  * update/delete rows (the record that will change), in the host's own ask
@@ -102,6 +151,20 @@ interface DirectiveHost {
102
151
  /** Where a decode failure or an unhonourable shell is reported. Default: console.error. */
103
152
  reportError?: (message: string) => void;
104
153
  }
154
+ /** Where a directive renders — today, the conversation it sits in (if any). */
155
+ interface DirectiveScope {
156
+ conversationId?: string | null;
157
+ }
158
+ /**
159
+ * Tell every card below WHERE it renders. A host draws a chat message's
160
+ * directives inside one of these (or passes `conversationId` to
161
+ * `DirectiveRender`), so the card applies in that conversation's namespace —
162
+ * the same key the agent's proposal approves under. A note mounts none.
163
+ */
164
+ declare function DirectiveScopeProvider({ conversationId, children, }: DirectiveScope & {
165
+ children: ReactNode;
166
+ }): react.JSX.Element;
167
+ declare function useDirectiveScope(): DirectiveScope;
105
168
  interface DirectiveHostProviderProps {
106
169
  host: DirectiveHost;
107
170
  children: ReactNode;
@@ -602,4 +665,4 @@ interface KindRouteBinding {
602
665
  /** Bind the pure routes to one host's env + owned block types. */
603
666
  declare function createKindRouteBinding(env: KindRouteEnv, options?: KindRouteOptions): KindRouteBinding;
604
667
 
605
- export { kindServerDataFromStoredValue as A, markKindPartialUnsafe as B, type ContentIrHost as C, DB_KIND_COMPONENT_KEY as D, readIrRouteMarker as E, resetPartialUnsafeKinds as F, GENERIC_STRUCTURED_COMPONENT_KEY as G, resetSourcelessDbRowReports as H, IR_PROVISIONAL_KEY as I, resolveAnnouncedKindLoading as J, type KindRouteEnv as K, resolveProvisionalKindRender as L, resolveSupersededKindRender as M, routeEnvOf as N, useDirectiveHost as O, type PartialRenderOptions as P, type StructuredValueRenderProps as S, type KindDefinitionSource as a, type ContentIrRenderSeams as b, DIRECTIVE_BLOCK_TYPE as c, type DirectiveApplyResult as d, type DirectiveAskRequest as e, type DirectiveCopyProps as f, type DirectiveHost as g, DirectiveHostProvider as h, type DirectiveHostProviderProps as i, type DirectiveOpenItemOptions as j, type DirectiveRecordProps as k, type DirectiveRecordRef as l, type GenericFallbackReason as m, IR_ROUTE_KEY as n, type IrRenderBlock as o, type IrRoutableBlock as p, type IrRouteMarker as q, type KindRouteBinding as r, type KindRouteOptions as s, type ProvisionalKindRender as t, type SupersededKindRender as u, applyIrKindRoute as v, createKindRouteBinding as w, envelopeFromPartialKind as x, isPartialReadyKind as y, isProvisionalBlock as z };
668
+ export { createKindRouteBinding as A, envelopeFromPartialKind as B, type ContentIrHost as C, DB_KIND_COMPONENT_KEY as D, isPartialReadyKind as E, isProvisionalBlock as F, GENERIC_STRUCTURED_COMPONENT_KEY as G, kindServerDataFromStoredValue as H, IR_PROVISIONAL_KEY as I, markKindPartialUnsafe as J, type KindRouteEnv as K, readIrRouteMarker as L, resetPartialUnsafeKinds as M, resetSourcelessDbRowReports as N, resolveAnnouncedKindLoading as O, type PartialRenderOptions as P, resolveProvisionalKindRender as Q, resolveSupersededKindRender as R, type StructuredValueRenderProps as S, routeEnvOf as T, useDirectiveHost as U, useDirectiveScope as V, type KindDefinitionSource as a, type ContentIrRenderSeams as b, DIRECTIVE_BLOCK_TYPE as c, type DirectiveApplyResult as d, type DirectiveApplyState as e, type DirectiveAskRequest as f, type DirectiveCopyProps as g, type DirectiveHost as h, DirectiveHostProvider as i, type DirectiveHostProviderProps as j, type DirectiveOpenItemOptions as k, type DirectiveRecordProps as l, type DirectiveRecordRef as m, type DirectiveScope as n, DirectiveScopeProvider as o, type DirectiveShell as p, type GenericFallbackReason as q, IR_ROUTE_KEY as r, type IrRenderBlock as s, type IrRoutableBlock as t, type IrRouteMarker as u, type KindRouteBinding as v, type KindRouteOptions as w, type ProvisionalKindRender as x, type SupersededKindRender as y, applyIrKindRoute as z };
@@ -17,6 +17,25 @@ interface DirectiveApplyResult {
17
17
  */
18
18
  records?: DirectiveRecordRef[];
19
19
  }
20
+ /**
21
+ * What the server's action ledger says about ONE block, read on mount so a
22
+ * reloaded page never offers "Apply" for work that already ran (reviewer
23
+ * defect 5, 2026-10-02).
24
+ *
25
+ * - `not_applied` — still to do (or partly done: the batch re-applies, and the
26
+ * server replays the members it already holds). The card offers Apply.
27
+ * - `in_flight` — another request is applying it right now. The card says it
28
+ * is finishing and asks again shortly; it offers neither Apply nor a tally.
29
+ * - `applied` — the ledger holds every item. The card shows the tally exactly
30
+ * as a fresh apply would: the ledger's own sentence and the records, as doors.
31
+ */
32
+ interface DirectiveApplyState {
33
+ state: "not_applied" | "in_flight" | "applied";
34
+ /** The ledger row's sentence ("Created task."), never composed client-side. */
35
+ message?: string | null;
36
+ /** The records the original apply wrote — the tally's doors. */
37
+ records?: DirectiveRecordRef[];
38
+ }
20
39
  /** One record a directive names: the noun it is, and its id. */
21
40
  interface DirectiveRecordRef {
22
41
  noun: string;
@@ -43,6 +62,28 @@ interface DirectiveAskRequest {
43
62
  items: Record<string, unknown>[];
44
63
  /** The noun's human label ("Task"), from the host's catalog when it has one. */
45
64
  nounLabel: string;
65
+ /**
66
+ * True for "Run again": the ledger already holds this block, and a yes runs
67
+ * it a SECOND time (`force`) — another copy for a create, the same fields
68
+ * written again for an update, another delete for a restored record. The
69
+ * question must say so.
70
+ */
71
+ again?: boolean;
72
+ }
73
+ /**
74
+ * The shell a card hands its host — the two keys, plus WHERE it sits.
75
+ *
76
+ * `conversationId` is the conversation the card renders in (a chat message),
77
+ * absent in a person's own content (a note). It is the idempotency NAMESPACE:
78
+ * a card in an agent's message must apply under the SAME key as that
79
+ * proposal's Approve button, or the one action could run twice.
80
+ */
81
+ interface DirectiveShell {
82
+ __kind: string;
83
+ items: Record<string, unknown>[];
84
+ conversationId?: string;
85
+ /** "Run again": skip the ledger's dedup and apply a second time. */
86
+ force?: boolean;
46
87
  }
47
88
  interface DirectiveOpenItemOptions {
48
89
  /** The item, `__kind`-stamped when the shape has an item kind. */
@@ -71,10 +112,7 @@ interface DirectiveHost {
71
112
  * item against the registered model and runs the ONE handler; idempotent).
72
113
  * Reject with an Error whose message is safe to show.
73
114
  */
74
- confirm?: (shell: {
75
- __kind: string;
76
- items: Record<string, unknown>[];
77
- }) => Promise<DirectiveApplyResult>;
115
+ confirm?: (shell: DirectiveShell) => Promise<DirectiveApplyResult>;
78
116
  /**
79
117
  * Ask the person BEFORE anything runs, naming the consequence (the records,
80
118
  * what changes). Resolve `true` to go ahead, `false` to leave the card as it
@@ -84,6 +122,17 @@ interface DirectiveHost {
84
122
  * will read "Applying…" while its dialog is up).
85
123
  */
86
124
  ask?: (request: DirectiveAskRequest) => Promise<boolean>;
125
+ /**
126
+ * Has this exact block already been applied? Read ONCE when the card mounts
127
+ * (and again while the answer is `in_flight`), so the card survives a reload:
128
+ * the server ledger, not component state, is what knows. The identity is the
129
+ * server's (it hashes the validated items in the same namespace `confirm`
130
+ * applies in), so a host asks — it never computes. Batch on the host side if
131
+ * a page carries many cards. Reject with an Error when the ledger cannot be
132
+ * read: the card reports it and offers Apply, which is safe because `confirm`
133
+ * is idempotent. Absent → the card starts at Apply, as before.
134
+ */
135
+ applyState?: (shell: DirectiveShell) => Promise<DirectiveApplyState>;
87
136
  /**
88
137
  * Draw ONE existing record by its live name, as a way to open it. Used on
89
138
  * update/delete rows (the record that will change), in the host's own ask
@@ -102,6 +151,20 @@ interface DirectiveHost {
102
151
  /** Where a decode failure or an unhonourable shell is reported. Default: console.error. */
103
152
  reportError?: (message: string) => void;
104
153
  }
154
+ /** Where a directive renders — today, the conversation it sits in (if any). */
155
+ interface DirectiveScope {
156
+ conversationId?: string | null;
157
+ }
158
+ /**
159
+ * Tell every card below WHERE it renders. A host draws a chat message's
160
+ * directives inside one of these (or passes `conversationId` to
161
+ * `DirectiveRender`), so the card applies in that conversation's namespace —
162
+ * the same key the agent's proposal approves under. A note mounts none.
163
+ */
164
+ declare function DirectiveScopeProvider({ conversationId, children, }: DirectiveScope & {
165
+ children: ReactNode;
166
+ }): react.JSX.Element;
167
+ declare function useDirectiveScope(): DirectiveScope;
105
168
  interface DirectiveHostProviderProps {
106
169
  host: DirectiveHost;
107
170
  children: ReactNode;
@@ -602,4 +665,4 @@ interface KindRouteBinding {
602
665
  /** Bind the pure routes to one host's env + owned block types. */
603
666
  declare function createKindRouteBinding(env: KindRouteEnv, options?: KindRouteOptions): KindRouteBinding;
604
667
 
605
- export { kindServerDataFromStoredValue as A, markKindPartialUnsafe as B, type ContentIrHost as C, DB_KIND_COMPONENT_KEY as D, readIrRouteMarker as E, resetPartialUnsafeKinds as F, GENERIC_STRUCTURED_COMPONENT_KEY as G, resetSourcelessDbRowReports as H, IR_PROVISIONAL_KEY as I, resolveAnnouncedKindLoading as J, type KindRouteEnv as K, resolveProvisionalKindRender as L, resolveSupersededKindRender as M, routeEnvOf as N, useDirectiveHost as O, type PartialRenderOptions as P, type StructuredValueRenderProps as S, type KindDefinitionSource as a, type ContentIrRenderSeams as b, DIRECTIVE_BLOCK_TYPE as c, type DirectiveApplyResult as d, type DirectiveAskRequest as e, type DirectiveCopyProps as f, type DirectiveHost as g, DirectiveHostProvider as h, type DirectiveHostProviderProps as i, type DirectiveOpenItemOptions as j, type DirectiveRecordProps as k, type DirectiveRecordRef as l, type GenericFallbackReason as m, IR_ROUTE_KEY as n, type IrRenderBlock as o, type IrRoutableBlock as p, type IrRouteMarker as q, type KindRouteBinding as r, type KindRouteOptions as s, type ProvisionalKindRender as t, type SupersededKindRender as u, applyIrKindRoute as v, createKindRouteBinding as w, envelopeFromPartialKind as x, isPartialReadyKind as y, isProvisionalBlock as z };
668
+ export { createKindRouteBinding as A, envelopeFromPartialKind as B, type ContentIrHost as C, DB_KIND_COMPONENT_KEY as D, isPartialReadyKind as E, isProvisionalBlock as F, GENERIC_STRUCTURED_COMPONENT_KEY as G, kindServerDataFromStoredValue as H, IR_PROVISIONAL_KEY as I, markKindPartialUnsafe as J, type KindRouteEnv as K, readIrRouteMarker as L, resetPartialUnsafeKinds as M, resetSourcelessDbRowReports as N, resolveAnnouncedKindLoading as O, type PartialRenderOptions as P, resolveProvisionalKindRender as Q, resolveSupersededKindRender as R, type StructuredValueRenderProps as S, routeEnvOf as T, useDirectiveHost as U, useDirectiveScope as V, type KindDefinitionSource as a, type ContentIrRenderSeams as b, DIRECTIVE_BLOCK_TYPE as c, type DirectiveApplyResult as d, type DirectiveApplyState as e, type DirectiveAskRequest as f, type DirectiveCopyProps as g, type DirectiveHost as h, DirectiveHostProvider as i, type DirectiveHostProviderProps as j, type DirectiveOpenItemOptions as k, type DirectiveRecordProps as l, type DirectiveRecordRef as m, type DirectiveScope as n, DirectiveScopeProvider as o, type DirectiveShell as p, type GenericFallbackReason as q, IR_ROUTE_KEY as r, type IrRenderBlock as s, type IrRoutableBlock as t, type IrRouteMarker as u, type KindRouteBinding as v, type KindRouteOptions as w, type ProvisionalKindRender as x, type SupersededKindRender as y, applyIrKindRoute as z };
package/dist/route.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { D as DB_KIND_COMPONENT_KEY, c as DIRECTIVE_BLOCK_TYPE, G as GENERIC_STRUCTURED_COMPONENT_KEY, m as GenericFallbackReason, I as IR_PROVISIONAL_KEY, n as IR_ROUTE_KEY, q as IrRouteMarker, r as KindRouteBinding, s as KindRouteOptions, P as PartialRenderOptions, t as ProvisionalKindRender, u as SupersededKindRender, v as applyIrKindRoute, w as createKindRouteBinding, x as envelopeFromPartialKind, y as isPartialReadyKind, z as isProvisionalBlock, A as kindServerDataFromStoredValue, B as markKindPartialUnsafe, E as readIrRouteMarker, F as resetPartialUnsafeKinds, H as resetSourcelessDbRowReports, J as resolveAnnouncedKindLoading, L as resolveProvisionalKindRender, M as resolveSupersededKindRender } from './route-DxK1SoPh.cjs';
1
+ export { D as DB_KIND_COMPONENT_KEY, c as DIRECTIVE_BLOCK_TYPE, G as GENERIC_STRUCTURED_COMPONENT_KEY, q as GenericFallbackReason, I as IR_PROVISIONAL_KEY, r as IR_ROUTE_KEY, u as IrRouteMarker, v as KindRouteBinding, w as KindRouteOptions, P as PartialRenderOptions, x as ProvisionalKindRender, y as SupersededKindRender, z as applyIrKindRoute, A as createKindRouteBinding, B as envelopeFromPartialKind, E as isPartialReadyKind, F as isProvisionalBlock, H as kindServerDataFromStoredValue, J as markKindPartialUnsafe, L as readIrRouteMarker, M as resetPartialUnsafeKinds, N as resetSourcelessDbRowReports, O as resolveAnnouncedKindLoading, Q as resolveProvisionalKindRender, R as resolveSupersededKindRender } from './route-BCtPhF7W.cjs';
2
2
  import './component-resolution.types-DLO2w-0n.cjs';
3
3
  import 'react';
4
4
  import '@ai-matrx/content-ir';
package/dist/route.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { D as DB_KIND_COMPONENT_KEY, c as DIRECTIVE_BLOCK_TYPE, G as GENERIC_STRUCTURED_COMPONENT_KEY, m as GenericFallbackReason, I as IR_PROVISIONAL_KEY, n as IR_ROUTE_KEY, q as IrRouteMarker, r as KindRouteBinding, s as KindRouteOptions, P as PartialRenderOptions, t as ProvisionalKindRender, u as SupersededKindRender, v as applyIrKindRoute, w as createKindRouteBinding, x as envelopeFromPartialKind, y as isPartialReadyKind, z as isProvisionalBlock, A as kindServerDataFromStoredValue, B as markKindPartialUnsafe, E as readIrRouteMarker, F as resetPartialUnsafeKinds, H as resetSourcelessDbRowReports, J as resolveAnnouncedKindLoading, L as resolveProvisionalKindRender, M as resolveSupersededKindRender } from './route-JGZfl2nL.js';
1
+ export { D as DB_KIND_COMPONENT_KEY, c as DIRECTIVE_BLOCK_TYPE, G as GENERIC_STRUCTURED_COMPONENT_KEY, q as GenericFallbackReason, I as IR_PROVISIONAL_KEY, r as IR_ROUTE_KEY, u as IrRouteMarker, v as KindRouteBinding, w as KindRouteOptions, P as PartialRenderOptions, x as ProvisionalKindRender, y as SupersededKindRender, z as applyIrKindRoute, A as createKindRouteBinding, B as envelopeFromPartialKind, E as isPartialReadyKind, F as isProvisionalBlock, H as kindServerDataFromStoredValue, J as markKindPartialUnsafe, L as readIrRouteMarker, M as resetPartialUnsafeKinds, N as resetSourcelessDbRowReports, O as resolveAnnouncedKindLoading, Q as resolveProvisionalKindRender, R as resolveSupersededKindRender } from './route-DDbgc-ID.js';
2
2
  import './component-resolution.types-DLO2w-0n.js';
3
3
  import 'react';
4
4
  import '@ai-matrx/content-ir';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-matrx/content-ir-react",
3
- "version": "0.13.18",
3
+ "version": "0.15.0",
4
4
  "description": "The shared AI Matrx Content IR RENDER layer: kind routing, the component resolver, provisional (streaming) rendering, the runtime-wrapper chrome, and the generic structured floor — as portable React.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -124,8 +124,8 @@
124
124
  "react": ">=19.0.0"
125
125
  },
126
126
  "dependencies": {
127
- "@ai-matrx/kit": "latest",
128
- "@ai-matrx/content-ir": "latest"
127
+ "@ai-matrx/content-ir": "latest",
128
+ "@ai-matrx/kit": "latest"
129
129
  },
130
130
  "devDependencies": {
131
131
  "@arethetypeswrong/cli": "^0.18.5",