@ai-matrx/agents 0.38.4 → 0.40.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 (56) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/catalog/index.cjs +3 -1
  3. package/dist/catalog/index.cjs.map +1 -1
  4. package/dist/catalog/index.d.cts +2 -2
  5. package/dist/catalog/index.d.ts +2 -2
  6. package/dist/catalog/index.js +3 -1
  7. package/dist/catalog/index.js.map +1 -1
  8. package/dist/catalog/native/index.cjs +4 -1
  9. package/dist/catalog/native/index.cjs.map +1 -1
  10. package/dist/catalog/native/index.d.cts +8 -3
  11. package/dist/catalog/native/index.d.ts +8 -3
  12. package/dist/catalog/native/index.js +4 -1
  13. package/dist/catalog/native/index.js.map +1 -1
  14. package/dist/catalog/react/index.cjs +1 -0
  15. package/dist/catalog/react/index.cjs.map +1 -1
  16. package/dist/catalog/react/index.d.cts +13 -1
  17. package/dist/catalog/react/index.d.ts +13 -1
  18. package/dist/catalog/react/index.js +1 -0
  19. package/dist/catalog/react/index.js.map +1 -1
  20. package/dist/content-transfer/index.cjs.map +1 -1
  21. package/dist/content-transfer/index.js.map +1 -1
  22. package/dist/content-transfer/react/index.cjs.map +1 -1
  23. package/dist/content-transfer/react/index.js.map +1 -1
  24. package/dist/context/index.cjs +3 -23
  25. package/dist/context/index.cjs.map +1 -1
  26. package/dist/context/index.d.cts +10 -13
  27. package/dist/context/index.d.ts +10 -13
  28. package/dist/context/index.js +5 -23
  29. package/dist/context/index.js.map +1 -1
  30. package/dist/context/react/index.cjs +263 -97
  31. package/dist/context/react/index.cjs.map +1 -1
  32. package/dist/context/react/index.d.cts +140 -15
  33. package/dist/context/react/index.d.ts +140 -15
  34. package/dist/context/react/index.js +266 -100
  35. package/dist/context/react/index.js.map +1 -1
  36. package/dist/index.cjs +6 -3
  37. package/dist/index.cjs.map +1 -1
  38. package/dist/index.d.cts +9 -6
  39. package/dist/index.d.ts +9 -6
  40. package/dist/index.js +6 -3
  41. package/dist/index.js.map +1 -1
  42. package/dist/{keys.generated-DxG5tgWt.d.cts → keys.generated-myjGAtI0.d.cts} +4 -4
  43. package/dist/{keys.generated-DxG5tgWt.d.ts → keys.generated-myjGAtI0.d.ts} +4 -4
  44. package/dist/mandates/index.cjs +2 -2
  45. package/dist/mandates/index.cjs.map +1 -1
  46. package/dist/mandates/index.d.cts +2 -2
  47. package/dist/mandates/index.d.ts +2 -2
  48. package/dist/mandates/index.js +2 -2
  49. package/dist/mandates/index.js.map +1 -1
  50. package/dist/matrx/index.d.cts +1 -1
  51. package/dist/matrx/index.d.ts +1 -1
  52. package/dist/{orchestra-zpGHwOag.d.cts → orchestra-CiaTu58J.d.cts} +7 -0
  53. package/dist/{orchestra-zpGHwOag.d.ts → orchestra-CiaTu58J.d.ts} +7 -0
  54. package/mandates/snapshots/keys.0.39.0.json +653 -0
  55. package/mandates/snapshots/keys.0.40.0.json +653 -0
  56. package/package.json +4 -4
@@ -1,5 +1,19 @@
1
1
  import * as react from 'react';
2
2
 
3
+ /**
4
+ * @ai-matrx/agents/context — the context value rules, headless.
5
+ *
6
+ * Contract: common-docs/systems/scopes-context/context-delivery/RULES.md.
7
+ * Parity corpus: ./rules-corpus.json (run here by rules.test.ts and by aidream's
8
+ * pytest against the Python twin `resolve_context_rule`). Every function here
9
+ * is pure, zero-React, and safe to import on a server.
10
+ *
11
+ * The one flow a client runs per turn:
12
+ * rows = values.map(v => resolveContextRow(v, savedRows, cap)) // what the table shows
13
+ * context = buildContextWire(rows) // what the request sends
14
+ * …on `context_receipt`: compareReceipt(rows, receipt) // screen vs server
15
+ */
16
+
3
17
  /** Which layer decided a field — lowest to highest. */
4
18
  type ContextLayer = "default" | "page" | "agent" | "you";
5
19
  type ContextDelivery = "inline" | "on_request" | "off";
@@ -173,6 +187,95 @@ interface ContextReceiptMismatch {
173
187
  reason?: "self_check";
174
188
  }
175
189
 
190
+ /**
191
+ * THE HIERARCHY of the context rules table — where each value sits, and the
192
+ * switch at every level (Arman, 2026-10-02: "AI Matrx" for the platform's own
193
+ * values; the page by its section and real name; under it the page's own
194
+ * declared groups; a switch per level).
195
+ *
196
+ * The package never knows a page's groups: the host PLACES each row (level +
197
+ * group, both already-human labels) and may give a level a host switch (the
198
+ * page's own on/off). Without a host placement every row is placed by its
199
+ * origin. A level or group switch is NOT a new kind of rule: it is the
200
+ * person's per-value include rules for every value in it, written at once
201
+ * (`includeChanges`), so the server's gate and receipt see exactly the rules
202
+ * they already honour.
203
+ */
204
+
205
+ /** A level of the table: the platform, a page, the chat's attachments. */
206
+ interface ContextLevelRef {
207
+ /** Stable id (a surface key, `ai_matrx`, `attached`). */
208
+ id: string;
209
+ /** Heading, root first: `["Marketing", "Marketing Brand Cockpit"]`, `["AI Matrx"]`. */
210
+ path: readonly string[];
211
+ /** Sort order between levels (lower first). */
212
+ order?: number;
213
+ }
214
+ /** A group inside a level — the page's own declared group, label as declared. */
215
+ interface ContextGroupRef {
216
+ id: string;
217
+ label: string;
218
+ order?: number;
219
+ }
220
+ /** Where one row sits. */
221
+ interface ContextRowPlace {
222
+ level: ContextLevelRef;
223
+ /** Null: directly under the level. */
224
+ group?: ContextGroupRef | null;
225
+ }
226
+ /**
227
+ * A level whose switch is the host's own (the page on/off for this
228
+ * conversation) rather than the person's per-value rules. Shown even when the
229
+ * level has no rows, so the switch never disappears with its values.
230
+ */
231
+ interface ContextLevelMaster {
232
+ level: ContextLevelRef;
233
+ on: boolean;
234
+ onToggle?: ((next: boolean) => void) | undefined;
235
+ }
236
+ interface ContextHierarchy {
237
+ place: (row: ResolvedContextRow) => ContextRowPlace;
238
+ masters?: readonly ContextLevelMaster[];
239
+ }
240
+ interface ContextGroupNode {
241
+ ref: ContextGroupRef;
242
+ rows: ResolvedContextRow[];
243
+ }
244
+ interface ContextLevelNode {
245
+ ref: ContextLevelRef;
246
+ /** Rows directly under the level (no group). */
247
+ rows: ResolvedContextRow[];
248
+ groups: ContextGroupNode[];
249
+ master: ContextLevelMaster | null;
250
+ }
251
+ /** The platform's own values: the person, their organization, the client. */
252
+ declare const AI_MATRX_LEVEL: ContextLevelRef;
253
+ /** Files and documents attached to the conversation. */
254
+ declare const ATTACHED_LEVEL: ContextLevelRef;
255
+ /** A page the host has not named. */
256
+ declare const PAGE_LEVEL: ContextLevelRef;
257
+ /** The placement a host without one gets: by origin. */
258
+ declare function placeByOrigin(row: ResolvedContextRow): ContextRowPlace;
259
+ /** Rows → levels → groups, in the host's order (stable within equal orders). */
260
+ declare function buildContextLevels(rows: readonly ResolvedContextRow[], hierarchy?: ContextHierarchy | null): ContextLevelNode[];
261
+ /** Every row of a level, groups included. */
262
+ declare function levelRows(level: ContextLevelNode): ResolvedContextRow[];
263
+ /** What the row's include would be with no rule of the person's. */
264
+ declare function inheritedInclude(row: ResolvedContextRow, cap: number): boolean;
265
+ /** One person-rule write: `rule: null` removes the person's rule for that value. */
266
+ interface ContextRuleChange {
267
+ key: string;
268
+ surfaceKey: string;
269
+ rule: SavedContextRule | null;
270
+ }
271
+ /**
272
+ * A level or group switch: the person's include rule for every value in it
273
+ * that is not already `include`. A value whose default already gives
274
+ * `include` loses its own include rule instead (back to the default) — the
275
+ * saved rules stay minimal and "Reset all" means what it says.
276
+ */
277
+ declare function includeChanges(rows: readonly ResolvedContextRow[], include: boolean, cap: number): ContextRuleChange[];
278
+
176
279
  type ContextRulesDensity = "compact" | "comfortable";
177
280
  interface ContextRulesTableProps {
178
281
  rows: readonly ResolvedContextRow[];
@@ -187,13 +290,35 @@ interface ContextRulesTableProps {
187
290
  density?: ContextRulesDensity;
188
291
  /** Highlights the open row (master/detail). */
189
292
  selectedKey?: string | null;
293
+ /**
294
+ * Where each row sits (level → group) and the host's level switches. Omit:
295
+ * rows sit under their origin ("Page", "Attached", "AI Matrx").
296
+ */
297
+ hierarchy?: ContextHierarchy | null | undefined;
298
+ /**
299
+ * A level or group switch: the person's per-value rules for every value in
300
+ * it, at once. Omit: level and group switches are hidden (a host master
301
+ * switch still shows).
302
+ */
303
+ onSetInclude?: ((changes: ContextRuleChange[]) => void) | undefined;
190
304
  className?: string;
191
305
  }
192
306
  /**
193
307
  * The context rules table: Item | Include | Chars | Inline max. Presentational
194
308
  * and state-agnostic — every edit goes out through `onChange`.
195
309
  */
196
- declare function ContextRulesTable({ rows, cap, readOnly, mismatches, onChange, onOpenRow, density, selectedKey, className, }: ContextRulesTableProps): react.JSX.Element;
310
+ declare function ContextRulesTable({ rows, cap, readOnly, mismatches, onChange, onOpenRow, density, selectedKey, hierarchy, onSetInclude, className, }: ContextRulesTableProps): react.JSX.Element;
311
+
312
+ /**
313
+ * The header's "N · chars" total. A row whose size is not known yet (an
314
+ * attachment the server has not measured) never counts as 0: with some sizes
315
+ * unknown the total is a floor ("1.2k+"), with none known it is "—".
316
+ */
317
+ declare function summarizeContextRows(rows: readonly ResolvedContextRow[]): {
318
+ count: number;
319
+ chars: number;
320
+ charsLabel: string;
321
+ };
197
322
 
198
323
  interface ContextRulesChipProps {
199
324
  /**
@@ -205,9 +330,16 @@ interface ContextRulesChipProps {
205
330
  label?: string | null | undefined;
206
331
  rows: readonly ResolvedContextRow[];
207
332
  cap: number;
208
- /** Page context on/off. Omit when there is no page: the master switch is hidden. */
333
+ /**
334
+ * Page context on/off (the face's eye). With no `hierarchy`, also the
335
+ * header's master switch; with one, the page's switch is its level's
336
+ * (`hierarchy.masters`) and the header has none.
337
+ */
209
338
  on?: boolean | undefined;
210
339
  onToggleAll?: ((next: boolean) => void) | undefined;
340
+ /** Levels and groups with a switch each (see `ContextRulesTable`). */
341
+ hierarchy?: ContextHierarchy | null | undefined;
342
+ onSetInclude?: ((changes: ContextRuleChange[]) => void) | undefined;
211
343
  /** False: this turn's model cannot read context — muted face, no amber. */
212
344
  modelReadsContext?: boolean | undefined;
213
345
  onChange: (key: string, surfaceKey: string, next: SavedContextRule | null) => void;
@@ -223,22 +355,12 @@ interface ContextRulesChipProps {
223
355
  onOpenChange?: (open: boolean) => void;
224
356
  className?: string;
225
357
  }
226
- /**
227
- * The header's "N · chars" total. A row whose size is not known yet (an
228
- * attachment the server has not measured) never counts as 0: with some sizes
229
- * unknown the total is a floor ("1.2k+"), with none known it is "—".
230
- */
231
- declare function summarizeContextRows(rows: readonly ResolvedContextRow[]): {
232
- count: number;
233
- chars: number;
234
- charsLabel: string;
235
- };
236
358
  /**
237
359
  * The composer's value-group chip — far right of the composer's one row — and the surface it opens: a header (label,
238
360
  * "N · chars" summary, page master switch, reset-all, full view) over the
239
361
  * compact rules table. Popover on desktop, bottom sheet on mobile.
240
362
  */
241
- declare function ContextRulesChip({ label, rows, cap, on, onToggleAll, onChange, onResetAll, onOpenFullView, mismatchCount, modelReadsContext, mismatches, onOpenRow, isMobile, readOnly, open: openProp, onOpenChange, className, }: ContextRulesChipProps): react.JSX.Element;
363
+ declare function ContextRulesChip({ label, rows, cap, on, onToggleAll, hierarchy, onSetInclude, onChange, onResetAll, onOpenFullView, mismatchCount, modelReadsContext, mismatches, onOpenRow, isMobile, readOnly, open: openProp, onOpenChange, className, }: ContextRulesChipProps): react.JSX.Element;
242
364
 
243
365
  interface ContextRulesPanelBodyProps {
244
366
  rows: readonly ResolvedContextRow[];
@@ -250,6 +372,9 @@ interface ContextRulesPanelBodyProps {
250
372
  loadView?: ContextViewLoader;
251
373
  readOnly?: boolean | undefined;
252
374
  onChange: (key: string, surfaceKey: string, next: SavedContextRule | null) => void;
375
+ /** Levels and groups with a switch each (see `ContextRulesTable`). */
376
+ hierarchy?: ContextHierarchy | null | undefined;
377
+ onSetInclude?: ((changes: ContextRuleChange[]) => void) | undefined;
253
378
  /** Host content under the built-in controls (a value preview, source link…). */
254
379
  renderDetail?: (row: ResolvedContextRow) => react.ReactNode;
255
380
  isMobile?: boolean;
@@ -263,7 +388,7 @@ interface ContextRulesPanelBodyProps {
263
388
  * the left, the open row's controls, layer breakdown and host detail on the
264
389
  * right. On mobile: list, then detail with Back.
265
390
  */
266
- declare function ContextRulesPanelBody({ rows, cap, mismatches, blocks, loadView, readOnly, onChange, renderDetail, isMobile, selectedKey: selectedProp, onSelectedKeyChange, className, }: ContextRulesPanelBodyProps): react.JSX.Element;
391
+ declare function ContextRulesPanelBody({ rows, cap, mismatches, blocks, loadView, readOnly, onChange, hierarchy, onSetInclude, renderDetail, isMobile, selectedKey: selectedProp, onSelectedKeyChange, className, }: ContextRulesPanelBodyProps): react.JSX.Element;
267
392
 
268
393
  interface InlineMaxInputProps {
269
394
  /** The person's own limit, or null when inherited. */
@@ -335,4 +460,4 @@ declare function ContextReceiptBlockDetail({ block, load, className, }: {
335
460
  className?: string;
336
461
  }): react.JSX.Element;
337
462
 
338
- export { ContextDeliveredValue, ContextReceiptBlockDetail, ContextReceiptBlocks, type ContextReceiptBlocksProps, ContextRulesChip, type ContextRulesChipProps, type ContextRulesDensity, ContextRulesPanelBody, type ContextRulesPanelBodyProps, ContextRulesTable, type ContextRulesTableProps, DeliveredSection, InlineMaxInput, type InlineMaxInputProps, summarizeContextRows };
463
+ export { AI_MATRX_LEVEL, ATTACHED_LEVEL, ContextDeliveredValue, type ContextGroupNode, type ContextGroupRef, type ContextHierarchy, type ContextLevelMaster, type ContextLevelNode, type ContextLevelRef, ContextReceiptBlockDetail, ContextReceiptBlocks, type ContextReceiptBlocksProps, type ContextRowPlace, type ContextRuleChange, ContextRulesChip, type ContextRulesChipProps, type ContextRulesDensity, ContextRulesPanelBody, type ContextRulesPanelBodyProps, ContextRulesTable, type ContextRulesTableProps, DeliveredSection, InlineMaxInput, type InlineMaxInputProps, PAGE_LEVEL, buildContextLevels, includeChanges, inheritedInclude, levelRows, placeByOrigin, summarizeContextRows };
@@ -1,5 +1,19 @@
1
1
  import * as react from 'react';
2
2
 
3
+ /**
4
+ * @ai-matrx/agents/context — the context value rules, headless.
5
+ *
6
+ * Contract: common-docs/systems/scopes-context/context-delivery/RULES.md.
7
+ * Parity corpus: ./rules-corpus.json (run here by rules.test.ts and by aidream's
8
+ * pytest against the Python twin `resolve_context_rule`). Every function here
9
+ * is pure, zero-React, and safe to import on a server.
10
+ *
11
+ * The one flow a client runs per turn:
12
+ * rows = values.map(v => resolveContextRow(v, savedRows, cap)) // what the table shows
13
+ * context = buildContextWire(rows) // what the request sends
14
+ * …on `context_receipt`: compareReceipt(rows, receipt) // screen vs server
15
+ */
16
+
3
17
  /** Which layer decided a field — lowest to highest. */
4
18
  type ContextLayer = "default" | "page" | "agent" | "you";
5
19
  type ContextDelivery = "inline" | "on_request" | "off";
@@ -173,6 +187,95 @@ interface ContextReceiptMismatch {
173
187
  reason?: "self_check";
174
188
  }
175
189
 
190
+ /**
191
+ * THE HIERARCHY of the context rules table — where each value sits, and the
192
+ * switch at every level (Arman, 2026-10-02: "AI Matrx" for the platform's own
193
+ * values; the page by its section and real name; under it the page's own
194
+ * declared groups; a switch per level).
195
+ *
196
+ * The package never knows a page's groups: the host PLACES each row (level +
197
+ * group, both already-human labels) and may give a level a host switch (the
198
+ * page's own on/off). Without a host placement every row is placed by its
199
+ * origin. A level or group switch is NOT a new kind of rule: it is the
200
+ * person's per-value include rules for every value in it, written at once
201
+ * (`includeChanges`), so the server's gate and receipt see exactly the rules
202
+ * they already honour.
203
+ */
204
+
205
+ /** A level of the table: the platform, a page, the chat's attachments. */
206
+ interface ContextLevelRef {
207
+ /** Stable id (a surface key, `ai_matrx`, `attached`). */
208
+ id: string;
209
+ /** Heading, root first: `["Marketing", "Marketing Brand Cockpit"]`, `["AI Matrx"]`. */
210
+ path: readonly string[];
211
+ /** Sort order between levels (lower first). */
212
+ order?: number;
213
+ }
214
+ /** A group inside a level — the page's own declared group, label as declared. */
215
+ interface ContextGroupRef {
216
+ id: string;
217
+ label: string;
218
+ order?: number;
219
+ }
220
+ /** Where one row sits. */
221
+ interface ContextRowPlace {
222
+ level: ContextLevelRef;
223
+ /** Null: directly under the level. */
224
+ group?: ContextGroupRef | null;
225
+ }
226
+ /**
227
+ * A level whose switch is the host's own (the page on/off for this
228
+ * conversation) rather than the person's per-value rules. Shown even when the
229
+ * level has no rows, so the switch never disappears with its values.
230
+ */
231
+ interface ContextLevelMaster {
232
+ level: ContextLevelRef;
233
+ on: boolean;
234
+ onToggle?: ((next: boolean) => void) | undefined;
235
+ }
236
+ interface ContextHierarchy {
237
+ place: (row: ResolvedContextRow) => ContextRowPlace;
238
+ masters?: readonly ContextLevelMaster[];
239
+ }
240
+ interface ContextGroupNode {
241
+ ref: ContextGroupRef;
242
+ rows: ResolvedContextRow[];
243
+ }
244
+ interface ContextLevelNode {
245
+ ref: ContextLevelRef;
246
+ /** Rows directly under the level (no group). */
247
+ rows: ResolvedContextRow[];
248
+ groups: ContextGroupNode[];
249
+ master: ContextLevelMaster | null;
250
+ }
251
+ /** The platform's own values: the person, their organization, the client. */
252
+ declare const AI_MATRX_LEVEL: ContextLevelRef;
253
+ /** Files and documents attached to the conversation. */
254
+ declare const ATTACHED_LEVEL: ContextLevelRef;
255
+ /** A page the host has not named. */
256
+ declare const PAGE_LEVEL: ContextLevelRef;
257
+ /** The placement a host without one gets: by origin. */
258
+ declare function placeByOrigin(row: ResolvedContextRow): ContextRowPlace;
259
+ /** Rows → levels → groups, in the host's order (stable within equal orders). */
260
+ declare function buildContextLevels(rows: readonly ResolvedContextRow[], hierarchy?: ContextHierarchy | null): ContextLevelNode[];
261
+ /** Every row of a level, groups included. */
262
+ declare function levelRows(level: ContextLevelNode): ResolvedContextRow[];
263
+ /** What the row's include would be with no rule of the person's. */
264
+ declare function inheritedInclude(row: ResolvedContextRow, cap: number): boolean;
265
+ /** One person-rule write: `rule: null` removes the person's rule for that value. */
266
+ interface ContextRuleChange {
267
+ key: string;
268
+ surfaceKey: string;
269
+ rule: SavedContextRule | null;
270
+ }
271
+ /**
272
+ * A level or group switch: the person's include rule for every value in it
273
+ * that is not already `include`. A value whose default already gives
274
+ * `include` loses its own include rule instead (back to the default) — the
275
+ * saved rules stay minimal and "Reset all" means what it says.
276
+ */
277
+ declare function includeChanges(rows: readonly ResolvedContextRow[], include: boolean, cap: number): ContextRuleChange[];
278
+
176
279
  type ContextRulesDensity = "compact" | "comfortable";
177
280
  interface ContextRulesTableProps {
178
281
  rows: readonly ResolvedContextRow[];
@@ -187,13 +290,35 @@ interface ContextRulesTableProps {
187
290
  density?: ContextRulesDensity;
188
291
  /** Highlights the open row (master/detail). */
189
292
  selectedKey?: string | null;
293
+ /**
294
+ * Where each row sits (level → group) and the host's level switches. Omit:
295
+ * rows sit under their origin ("Page", "Attached", "AI Matrx").
296
+ */
297
+ hierarchy?: ContextHierarchy | null | undefined;
298
+ /**
299
+ * A level or group switch: the person's per-value rules for every value in
300
+ * it, at once. Omit: level and group switches are hidden (a host master
301
+ * switch still shows).
302
+ */
303
+ onSetInclude?: ((changes: ContextRuleChange[]) => void) | undefined;
190
304
  className?: string;
191
305
  }
192
306
  /**
193
307
  * The context rules table: Item | Include | Chars | Inline max. Presentational
194
308
  * and state-agnostic — every edit goes out through `onChange`.
195
309
  */
196
- declare function ContextRulesTable({ rows, cap, readOnly, mismatches, onChange, onOpenRow, density, selectedKey, className, }: ContextRulesTableProps): react.JSX.Element;
310
+ declare function ContextRulesTable({ rows, cap, readOnly, mismatches, onChange, onOpenRow, density, selectedKey, hierarchy, onSetInclude, className, }: ContextRulesTableProps): react.JSX.Element;
311
+
312
+ /**
313
+ * The header's "N · chars" total. A row whose size is not known yet (an
314
+ * attachment the server has not measured) never counts as 0: with some sizes
315
+ * unknown the total is a floor ("1.2k+"), with none known it is "—".
316
+ */
317
+ declare function summarizeContextRows(rows: readonly ResolvedContextRow[]): {
318
+ count: number;
319
+ chars: number;
320
+ charsLabel: string;
321
+ };
197
322
 
198
323
  interface ContextRulesChipProps {
199
324
  /**
@@ -205,9 +330,16 @@ interface ContextRulesChipProps {
205
330
  label?: string | null | undefined;
206
331
  rows: readonly ResolvedContextRow[];
207
332
  cap: number;
208
- /** Page context on/off. Omit when there is no page: the master switch is hidden. */
333
+ /**
334
+ * Page context on/off (the face's eye). With no `hierarchy`, also the
335
+ * header's master switch; with one, the page's switch is its level's
336
+ * (`hierarchy.masters`) and the header has none.
337
+ */
209
338
  on?: boolean | undefined;
210
339
  onToggleAll?: ((next: boolean) => void) | undefined;
340
+ /** Levels and groups with a switch each (see `ContextRulesTable`). */
341
+ hierarchy?: ContextHierarchy | null | undefined;
342
+ onSetInclude?: ((changes: ContextRuleChange[]) => void) | undefined;
211
343
  /** False: this turn's model cannot read context — muted face, no amber. */
212
344
  modelReadsContext?: boolean | undefined;
213
345
  onChange: (key: string, surfaceKey: string, next: SavedContextRule | null) => void;
@@ -223,22 +355,12 @@ interface ContextRulesChipProps {
223
355
  onOpenChange?: (open: boolean) => void;
224
356
  className?: string;
225
357
  }
226
- /**
227
- * The header's "N · chars" total. A row whose size is not known yet (an
228
- * attachment the server has not measured) never counts as 0: with some sizes
229
- * unknown the total is a floor ("1.2k+"), with none known it is "—".
230
- */
231
- declare function summarizeContextRows(rows: readonly ResolvedContextRow[]): {
232
- count: number;
233
- chars: number;
234
- charsLabel: string;
235
- };
236
358
  /**
237
359
  * The composer's value-group chip — far right of the composer's one row — and the surface it opens: a header (label,
238
360
  * "N · chars" summary, page master switch, reset-all, full view) over the
239
361
  * compact rules table. Popover on desktop, bottom sheet on mobile.
240
362
  */
241
- declare function ContextRulesChip({ label, rows, cap, on, onToggleAll, onChange, onResetAll, onOpenFullView, mismatchCount, modelReadsContext, mismatches, onOpenRow, isMobile, readOnly, open: openProp, onOpenChange, className, }: ContextRulesChipProps): react.JSX.Element;
363
+ declare function ContextRulesChip({ label, rows, cap, on, onToggleAll, hierarchy, onSetInclude, onChange, onResetAll, onOpenFullView, mismatchCount, modelReadsContext, mismatches, onOpenRow, isMobile, readOnly, open: openProp, onOpenChange, className, }: ContextRulesChipProps): react.JSX.Element;
242
364
 
243
365
  interface ContextRulesPanelBodyProps {
244
366
  rows: readonly ResolvedContextRow[];
@@ -250,6 +372,9 @@ interface ContextRulesPanelBodyProps {
250
372
  loadView?: ContextViewLoader;
251
373
  readOnly?: boolean | undefined;
252
374
  onChange: (key: string, surfaceKey: string, next: SavedContextRule | null) => void;
375
+ /** Levels and groups with a switch each (see `ContextRulesTable`). */
376
+ hierarchy?: ContextHierarchy | null | undefined;
377
+ onSetInclude?: ((changes: ContextRuleChange[]) => void) | undefined;
253
378
  /** Host content under the built-in controls (a value preview, source link…). */
254
379
  renderDetail?: (row: ResolvedContextRow) => react.ReactNode;
255
380
  isMobile?: boolean;
@@ -263,7 +388,7 @@ interface ContextRulesPanelBodyProps {
263
388
  * the left, the open row's controls, layer breakdown and host detail on the
264
389
  * right. On mobile: list, then detail with Back.
265
390
  */
266
- declare function ContextRulesPanelBody({ rows, cap, mismatches, blocks, loadView, readOnly, onChange, renderDetail, isMobile, selectedKey: selectedProp, onSelectedKeyChange, className, }: ContextRulesPanelBodyProps): react.JSX.Element;
391
+ declare function ContextRulesPanelBody({ rows, cap, mismatches, blocks, loadView, readOnly, onChange, hierarchy, onSetInclude, renderDetail, isMobile, selectedKey: selectedProp, onSelectedKeyChange, className, }: ContextRulesPanelBodyProps): react.JSX.Element;
267
392
 
268
393
  interface InlineMaxInputProps {
269
394
  /** The person's own limit, or null when inherited. */
@@ -335,4 +460,4 @@ declare function ContextReceiptBlockDetail({ block, load, className, }: {
335
460
  className?: string;
336
461
  }): react.JSX.Element;
337
462
 
338
- export { ContextDeliveredValue, ContextReceiptBlockDetail, ContextReceiptBlocks, type ContextReceiptBlocksProps, ContextRulesChip, type ContextRulesChipProps, type ContextRulesDensity, ContextRulesPanelBody, type ContextRulesPanelBodyProps, ContextRulesTable, type ContextRulesTableProps, DeliveredSection, InlineMaxInput, type InlineMaxInputProps, summarizeContextRows };
463
+ export { AI_MATRX_LEVEL, ATTACHED_LEVEL, ContextDeliveredValue, type ContextGroupNode, type ContextGroupRef, type ContextHierarchy, type ContextLevelMaster, type ContextLevelNode, type ContextLevelRef, ContextReceiptBlockDetail, ContextReceiptBlocks, type ContextReceiptBlocksProps, type ContextRowPlace, type ContextRuleChange, ContextRulesChip, type ContextRulesChipProps, type ContextRulesDensity, ContextRulesPanelBody, type ContextRulesPanelBodyProps, ContextRulesTable, type ContextRulesTableProps, DeliveredSection, InlineMaxInput, type InlineMaxInputProps, PAGE_LEVEL, buildContextLevels, includeChanges, inheritedInclude, levelRows, placeByOrigin, summarizeContextRows };