@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
@@ -31,6 +31,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  // context/react/index.ts
32
32
  var react_exports = {};
33
33
  __export(react_exports, {
34
+ AI_MATRX_LEVEL: () => AI_MATRX_LEVEL,
35
+ ATTACHED_LEVEL: () => ATTACHED_LEVEL,
34
36
  ContextDeliveredValue: () => ContextDeliveredValue,
35
37
  ContextReceiptBlockDetail: () => ContextReceiptBlockDetail,
36
38
  ContextReceiptBlocks: () => ContextReceiptBlocks,
@@ -39,14 +41,22 @@ __export(react_exports, {
39
41
  ContextRulesTable: () => ContextRulesTable,
40
42
  DeliveredSection: () => DeliveredSection,
41
43
  InlineMaxInput: () => InlineMaxInput,
44
+ PAGE_LEVEL: () => PAGE_LEVEL,
45
+ buildContextLevels: () => buildContextLevels,
46
+ includeChanges: () => includeChanges,
47
+ inheritedInclude: () => inheritedInclude,
48
+ levelRows: () => levelRows,
49
+ placeByOrigin: () => placeByOrigin,
42
50
  summarizeContextRows: () => summarizeContextRows
43
51
  });
44
52
  module.exports = __toCommonJS(react_exports);
45
53
 
46
54
  // context/react/ContextRulesTable.tsx
55
+ var React2 = __toESM(require("react"), 1);
47
56
  var import_design_system2 = require("@ai-matrx/design-system");
48
57
 
49
58
  // context/index.ts
59
+ var import_text_case = require("@ai-matrx/kit/text-case");
50
60
  var DEFAULT_INLINE_MAX_CHARS = 200;
51
61
  var DEFAULT_INLINE_CAP = 5e4;
52
62
  var CONTEXT_ROW_BLOCKS = {
@@ -132,24 +142,6 @@ function resolveContextRule(input) {
132
142
  clamped
133
143
  };
134
144
  }
135
- var CONTEXT_KEY_ACRONYMS = [
136
- "ID",
137
- "URL",
138
- "PDF",
139
- "HTML",
140
- "JSON",
141
- "API",
142
- "AI",
143
- "UI",
144
- "CSV",
145
- "SMS",
146
- "SEO",
147
- "LLM",
148
- "MCP",
149
- "UUID",
150
- "ISO"
151
- ];
152
- var ACRONYM_SET = new Set(CONTEXT_KEY_ACRONYMS.map((a) => a.toLowerCase()));
153
145
  function formatChars(n) {
154
146
  if (n === null || n === void 0 || !Number.isFinite(n)) return "\u2014";
155
147
  const abs = Math.abs(n);
@@ -229,6 +221,79 @@ var ArrowDownToLineIcon = icon(
229
221
  ] })
230
222
  );
231
223
 
224
+ // context/react/hierarchy.ts
225
+ var AI_MATRX_LEVEL = { id: "ai_matrx", path: ["AI Matrx"], order: 900 };
226
+ var ATTACHED_LEVEL = { id: "attached", path: ["Attached"], order: 500 };
227
+ var PAGE_LEVEL = { id: "page", path: ["Page"], order: 100 };
228
+ var ORIGIN_LEVEL = {
229
+ page: PAGE_LEVEL,
230
+ attached: ATTACHED_LEVEL,
231
+ system: AI_MATRX_LEVEL
232
+ };
233
+ function placeByOrigin(row) {
234
+ return { level: ORIGIN_LEVEL[row.origin] };
235
+ }
236
+ function stableSort(list, ref) {
237
+ return list.map((item, i) => ({ item, i })).sort((a, b) => (ref(a.item).order ?? 0) - (ref(b.item).order ?? 0) || a.i - b.i).map(({ item }) => item);
238
+ }
239
+ function buildContextLevels(rows, hierarchy) {
240
+ const place = hierarchy?.place ?? placeByOrigin;
241
+ const levels = /* @__PURE__ */ new Map();
242
+ const levelFor = (ref) => {
243
+ let node = levels.get(ref.id);
244
+ if (!node) {
245
+ node = { ref, rows: [], groups: [], master: null };
246
+ levels.set(ref.id, node);
247
+ }
248
+ return node;
249
+ };
250
+ for (const master of hierarchy?.masters ?? []) levelFor(master.level).master = master;
251
+ for (const row of rows) {
252
+ const where = place(row);
253
+ const level = levelFor(where.level);
254
+ if (!where.group) {
255
+ level.rows.push(row);
256
+ continue;
257
+ }
258
+ let group = level.groups.find((g) => g.ref.id === where.group.id);
259
+ if (!group) {
260
+ group = { ref: where.group, rows: [] };
261
+ level.groups.push(group);
262
+ }
263
+ group.rows.push(row);
264
+ }
265
+ const out = [...levels.values()];
266
+ for (const level of out) level.groups = stableSort(level.groups, (g) => g.ref);
267
+ return stableSort(out, (level) => level.ref);
268
+ }
269
+ function levelRows(level) {
270
+ return [...level.rows, ...level.groups.flatMap((g) => g.rows)];
271
+ }
272
+ function inheritedInclude(row, cap) {
273
+ return resolveContextRule({
274
+ ...row.layers ?? {},
275
+ chars: row.chars,
276
+ cap,
277
+ user: null,
278
+ identity: isServerAuthoritativeKey(row.key)
279
+ }).include;
280
+ }
281
+ function includeChanges(rows, include, cap) {
282
+ const changes = [];
283
+ for (const row of rows) {
284
+ if (row.include === include) continue;
285
+ const next = { ...row.userRule ?? {} };
286
+ if (inheritedInclude(row, cap) === include) delete next.include;
287
+ else next.include = include;
288
+ changes.push({
289
+ key: row.key,
290
+ surfaceKey: row.surfaceKey,
291
+ rule: Object.keys(next).length === 0 ? null : next
292
+ });
293
+ }
294
+ return changes;
295
+ }
296
+
232
297
  // context/react/InlineMaxInput.tsx
233
298
  var React = __toESM(require("react"), 1);
234
299
  var import_design_system = require("@ai-matrx/design-system");
@@ -410,13 +475,24 @@ function InlineMaxInput({
410
475
  ] });
411
476
  }
412
477
 
478
+ // context/react/summary.ts
479
+ function summarizeContextRows(rows) {
480
+ let count = 0;
481
+ let chars = 0;
482
+ let known = 0;
483
+ for (const r of rows) {
484
+ if (!r.include) continue;
485
+ count += 1;
486
+ if (r.chars === null || r.chars === void 0) continue;
487
+ chars += r.chars;
488
+ known += 1;
489
+ }
490
+ const charsLabel = count > 0 && known === 0 ? "\u2014" : known < count ? `${formatChars(chars)}+` : formatChars(chars);
491
+ return { count, chars, charsLabel };
492
+ }
493
+
413
494
  // context/react/ContextRulesTable.tsx
414
495
  var import_jsx_runtime3 = require("react/jsx-runtime");
415
- var GROUPS = [
416
- { origin: "page", label: "Page" },
417
- { origin: "attached", label: "Attached" },
418
- { origin: "system", label: "System" }
419
- ];
420
496
  var CONTEXT_RULES_GRID = {
421
497
  compact: "grid grid-cols-[minmax(0,1fr)_2.75rem_4rem_6.5rem] items-center gap-x-2 px-2",
422
498
  // Phone widths (375px): the fixed columns stay compact so Item always keeps
@@ -432,11 +508,33 @@ function ContextRulesTable({
432
508
  onOpenRow,
433
509
  density = "compact",
434
510
  selectedKey,
511
+ hierarchy,
512
+ onSetInclude,
435
513
  className
436
514
  }) {
437
515
  const comfortable = density === "comfortable";
438
- const present = GROUPS.filter((g) => rows.some((r) => r.origin === g.origin));
439
- const grouped = present.length > 1;
516
+ const levels = buildContextLevels(rows, hierarchy);
517
+ const headed = Boolean(hierarchy) || levels.length > 1;
518
+ const renderRow = (row, depth) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
519
+ ContextRuleRow,
520
+ {
521
+ row,
522
+ cap,
523
+ density,
524
+ depth: headed ? depth : 0,
525
+ readOnly,
526
+ selected: selectedKey === row.key,
527
+ mismatches: mismatches?.filter((m) => m.key === row.key) ?? [],
528
+ onChange,
529
+ onOpenRow,
530
+ comfortable
531
+ },
532
+ rowId(row)
533
+ );
534
+ const bulk = (list) => onSetInclude && !readOnly ? (next) => {
535
+ const changes = includeChanges(list, next, cap);
536
+ if (changes.length > 0) onSetInclude(changes);
537
+ } : void 0;
440
538
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_design_system2.TooltipProvider, { delayDuration: 300, titleTooltips: false, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { role: "table", "aria-label": "Values", "data-density": density, className: (0, import_design_system2.cn)("text-xs", className), children: [
441
539
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
442
540
  "div",
@@ -454,37 +552,98 @@ function ContextRulesTable({
454
552
  ]
455
553
  }
456
554
  ),
457
- rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "px-2 py-3 text-center text-muted-foreground", children: "None" }) : present.map((g) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { role: "rowgroup", "aria-label": grouped ? g.label : void 0, children: [
458
- grouped ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
459
- "div",
460
- {
461
- role: "row",
462
- className: "flex h-6 items-center bg-muted/40 px-2 font-medium text-muted-foreground",
463
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { role: "cell", children: g.label })
464
- }
465
- ) : null,
466
- rows.filter((r) => r.origin === g.origin).map((row) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
467
- ContextRuleRow,
468
- {
469
- row,
470
- cap,
471
- density,
472
- readOnly,
473
- selected: selectedKey === row.key,
474
- mismatches: mismatches?.filter((m) => m.key === row.key) ?? [],
475
- onChange,
476
- onOpenRow,
477
- comfortable
478
- },
479
- rowId(row)
480
- ))
481
- ] }, g.origin))
555
+ levels.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "px-2 py-3 text-center text-muted-foreground", children: "None" }) : levels.map((level) => {
556
+ const all = levelRows(level);
557
+ const name = level.ref.path.join(" \u203A ");
558
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { role: "rowgroup", "aria-label": headed ? name : void 0, "data-level": level.ref.id, children: [
559
+ headed ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
560
+ LevelHeading,
561
+ {
562
+ kind: "level",
563
+ path: level.ref.path,
564
+ rows: all,
565
+ density,
566
+ readOnly,
567
+ ...levelSwitch(level, bulk(all))
568
+ }
569
+ ) : null,
570
+ level.rows.map((row) => renderRow(row, 1)),
571
+ level.groups.map((group) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { role: "rowgroup", "aria-label": group.ref.label, "data-group": group.ref.id, children: [
572
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
573
+ LevelHeading,
574
+ {
575
+ kind: "group",
576
+ path: [group.ref.label],
577
+ rows: group.rows,
578
+ density,
579
+ readOnly,
580
+ onToggle: bulk(group.rows),
581
+ checked: group.rows.some((r) => r.include)
582
+ }
583
+ ),
584
+ group.rows.map((row) => renderRow(row, 2))
585
+ ] }, group.ref.id))
586
+ ] }, level.ref.id);
587
+ })
482
588
  ] }) });
483
589
  }
590
+ function levelSwitch(level, bulk) {
591
+ if (level.master) return { checked: level.master.on, onToggle: level.master.onToggle };
592
+ return { checked: levelRows(level).some((r) => r.include), onToggle: bulk };
593
+ }
594
+ function LevelHeading({
595
+ kind,
596
+ path,
597
+ rows,
598
+ density,
599
+ readOnly,
600
+ checked,
601
+ onToggle
602
+ }) {
603
+ const name = path.join(" \u203A ");
604
+ const { count, charsLabel } = summarizeContextRows(rows);
605
+ const total = rows.length;
606
+ const showSwitch = Boolean(onToggle) || readOnly && total > 0;
607
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
608
+ "div",
609
+ {
610
+ role: "row",
611
+ "data-heading": kind,
612
+ className: (0, import_design_system2.cn)(
613
+ CONTEXT_RULES_GRID[density],
614
+ "border-b border-border/50 font-medium",
615
+ density === "comfortable" ? "min-h-11" : "h-7",
616
+ kind === "level" ? "bg-muted/60 text-foreground" : "bg-muted/25 text-muted-foreground"
617
+ ),
618
+ children: [
619
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { role: "cell", className: (0, import_design_system2.cn)("flex min-w-0 items-center gap-1", kind === "group" && "pl-2"), children: [
620
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "flex min-w-0 items-center gap-1 truncate", title: name, children: path.map((part, i) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(React2.Fragment, { children: [
621
+ i > 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "shrink-0 text-muted-foreground", children: "\u203A" }) : null,
622
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: (0, import_design_system2.cn)("truncate", i < path.length - 1 && "text-muted-foreground"), children: part })
623
+ ] }, `${i}:${part}`)) }),
624
+ total > 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "shrink-0 font-normal tabular-nums text-muted-foreground", children: count === total ? total : `${count}/${total}` }) : null
625
+ ] }),
626
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { role: "cell", className: "flex justify-center", children: showSwitch ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
627
+ import_design_system2.Switch,
628
+ {
629
+ size: "sm",
630
+ "aria-label": `Include ${name}`,
631
+ checked,
632
+ disabled: readOnly || !onToggle,
633
+ onCheckedChange: (next) => onToggle?.(next)
634
+ }
635
+ ) : null }),
636
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { role: "cell", className: "text-right font-normal tabular-nums text-muted-foreground", children: total > 0 ? charsLabel : null }),
637
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { role: "cell" })
638
+ ]
639
+ }
640
+ );
641
+ }
484
642
  function ContextRuleRow({
485
643
  row,
486
644
  cap,
487
645
  density,
646
+ depth,
488
647
  comfortable,
489
648
  readOnly,
490
649
  selected,
@@ -520,27 +679,39 @@ function ContextRuleRow({
520
679
  selected && "bg-accent"
521
680
  ),
522
681
  children: [
523
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { role: "cell", className: (0, import_design_system2.cn)("flex min-w-0 items-center gap-1.5", !row.include && "opacity-50"), children: [
524
- mismatches.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_design_system2.Tooltip, { children: [
525
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_design_system2.TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
526
- "span",
527
- {
528
- role: "img",
529
- "aria-label": "Mismatch",
530
- className: "inline-flex shrink-0 text-warning",
531
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(TriangleAlertIcon, { className: "h-3.5 w-3.5" })
532
- }
533
- ) }),
534
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_design_system2.TooltipContent, { children: describeMismatches(mismatches) })
535
- ] }) : null,
536
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_design_system2.Tooltip, { children: [
537
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_design_system2.TooltipTrigger, { asChild: true, children: labelNode }),
538
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_design_system2.TooltipContent, { children: [
539
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { children: row.label }),
540
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "font-normal text-muted-foreground", children: decided })
541
- ] })
542
- ] })
543
- ] }),
682
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
683
+ "div",
684
+ {
685
+ role: "cell",
686
+ className: (0, import_design_system2.cn)(
687
+ "flex min-w-0 items-center gap-1.5",
688
+ depth === 1 && "pl-2",
689
+ depth === 2 && "pl-4",
690
+ !row.include && "opacity-50"
691
+ ),
692
+ children: [
693
+ mismatches.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_design_system2.Tooltip, { children: [
694
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_design_system2.TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
695
+ "span",
696
+ {
697
+ role: "img",
698
+ "aria-label": "Mismatch",
699
+ className: "inline-flex shrink-0 text-warning",
700
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(TriangleAlertIcon, { className: "h-3.5 w-3.5" })
701
+ }
702
+ ) }),
703
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_design_system2.TooltipContent, { children: describeMismatches(mismatches) })
704
+ ] }) : null,
705
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_design_system2.Tooltip, { children: [
706
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_design_system2.TooltipTrigger, { asChild: true, children: labelNode }),
707
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_design_system2.TooltipContent, { children: [
708
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { children: row.label }),
709
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "font-normal text-muted-foreground", children: decided })
710
+ ] })
711
+ ] })
712
+ ]
713
+ }
714
+ ),
544
715
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { role: "cell", className: "flex justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
545
716
  import_design_system2.Switch,
546
717
  {
@@ -584,25 +755,11 @@ function ContextRuleRow({
584
755
  }
585
756
 
586
757
  // context/react/ContextRulesChip.tsx
587
- var React2 = __toESM(require("react"), 1);
758
+ var React3 = __toESM(require("react"), 1);
588
759
  var import_design_system3 = require("@ai-matrx/design-system");
589
760
  var import_jsx_runtime4 = require("react/jsx-runtime");
590
761
  var BLIND_TOOLTIP = "This model can't read these values";
591
762
  var BLIND_LABEL = "Not read";
592
- function summarizeContextRows(rows) {
593
- let count = 0;
594
- let chars = 0;
595
- let known = 0;
596
- for (const r of rows) {
597
- if (!r.include) continue;
598
- count += 1;
599
- if (r.chars === null || r.chars === void 0) continue;
600
- chars += r.chars;
601
- known += 1;
602
- }
603
- const charsLabel = count > 0 && known === 0 ? "\u2014" : known < count ? `${formatChars(chars)}+` : formatChars(chars);
604
- return { count, chars, charsLabel };
605
- }
606
763
  function IconButton({
607
764
  label,
608
765
  onClick,
@@ -632,6 +789,8 @@ function ContextRulesChip({
632
789
  cap,
633
790
  on,
634
791
  onToggleAll,
792
+ hierarchy,
793
+ onSetInclude,
635
794
  onChange,
636
795
  onResetAll,
637
796
  onOpenFullView,
@@ -645,7 +804,7 @@ function ContextRulesChip({
645
804
  onOpenChange,
646
805
  className
647
806
  }) {
648
- const [openState, setOpenState] = React2.useState(false);
807
+ const [openState, setOpenState] = React3.useState(false);
649
808
  const open = openProp ?? openState;
650
809
  const setOpen = (next) => {
651
810
  if (openProp === void 0) setOpenState(next);
@@ -658,7 +817,8 @@ function ContextRulesChip({
658
817
  const blind = !modelReadsContext;
659
818
  const warn = mismatchCount > 0 && !blind;
660
819
  const comfortable = !!isMobile;
661
- const hasPage = on !== void 0;
820
+ const hasPage = on !== void 0 && !hierarchy;
821
+ const headerName = hierarchy ? "" : name;
662
822
  const eyeOpen = !blind && on !== false;
663
823
  const faceButton = /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
664
824
  "button",
@@ -702,7 +862,7 @@ function ContextRulesChip({
702
862
  ),
703
863
  children: [
704
864
  eyeOpen ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(EyeIcon, { className: "h-4 w-4 shrink-0 text-muted-foreground" }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(EyeOffIcon, { className: "h-4 w-4 shrink-0 text-muted-foreground" }),
705
- name ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "min-w-0 truncate text-sm font-medium", children: name }) : null,
865
+ headerName ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "min-w-0 truncate text-sm font-medium", children: headerName }) : null,
706
866
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "shrink-0 text-xs tabular-nums text-muted-foreground", children: `${count} \xB7 ${charsLabel} chars` }),
707
867
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "ml-auto flex shrink-0 items-center gap-0.5", children: [
708
868
  blind ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "mr-1 text-xs text-muted-foreground", children: BLIND_LABEL }) : null,
@@ -742,6 +902,8 @@ function ContextRulesChip({
742
902
  readOnly,
743
903
  density: comfortable ? "comfortable" : "compact",
744
904
  onChange,
905
+ hierarchy,
906
+ onSetInclude,
745
907
  ...mismatches ? { mismatches } : {},
746
908
  ...onOpenRow ? { onOpenRow } : {}
747
909
  }
@@ -767,11 +929,11 @@ function ContextRulesChip({
767
929
  }
768
930
 
769
931
  // context/react/ContextRulesPanelBody.tsx
770
- var React4 = __toESM(require("react"), 1);
932
+ var React5 = __toESM(require("react"), 1);
771
933
  var import_design_system6 = require("@ai-matrx/design-system");
772
934
 
773
935
  // context/react/ContextDeliveredValue.tsx
774
- var React3 = __toESM(require("react"), 1);
936
+ var React4 = __toESM(require("react"), 1);
775
937
  var import_design_system4 = require("@ai-matrx/design-system");
776
938
  var import_jsx_runtime5 = require("react/jsx-runtime");
777
939
  function ContextDeliveredValue({
@@ -832,10 +994,10 @@ function DeliveredSection({
832
994
  ref_,
833
995
  load
834
996
  }) {
835
- const [loaded, setLoaded] = React3.useState({ state: "loading" });
836
- const [attempt, setAttempt] = React3.useState(0);
997
+ const [loaded, setLoaded] = React4.useState({ state: "loading" });
998
+ const [attempt, setAttempt] = React4.useState(0);
837
999
  const { kind, key } = target;
838
- React3.useEffect(() => {
1000
+ React4.useEffect(() => {
839
1001
  if (!load) return;
840
1002
  let live = true;
841
1003
  setLoaded({ state: "loading" });
@@ -1106,15 +1268,17 @@ function ContextRulesPanelBody({
1106
1268
  loadView,
1107
1269
  readOnly,
1108
1270
  onChange,
1271
+ hierarchy,
1272
+ onSetInclude,
1109
1273
  renderDetail,
1110
1274
  isMobile,
1111
1275
  selectedKey: selectedProp,
1112
1276
  onSelectedKeyChange,
1113
1277
  className
1114
1278
  }) {
1115
- const [selectedState, setSelectedState] = React4.useState(null);
1116
- const [query, setQuery] = React4.useState("");
1117
- const [openBlockId, setOpenBlockId] = React4.useState(null);
1279
+ const [selectedState, setSelectedState] = React5.useState(null);
1280
+ const [query, setQuery] = React5.useState("");
1281
+ const [openBlockId, setOpenBlockId] = React5.useState(null);
1118
1282
  const selectedKey = selectedProp !== void 0 ? selectedProp : selectedState;
1119
1283
  const select = (key) => {
1120
1284
  setOpenBlockId(null);
@@ -1159,6 +1323,8 @@ function ContextRulesPanelBody({
1159
1323
  density: comfortable ? "comfortable" : "compact",
1160
1324
  selectedKey,
1161
1325
  onChange,
1326
+ hierarchy,
1327
+ onSetInclude,
1162
1328
  onOpenRow: (key) => select(key),
1163
1329
  ...mismatches ? { mismatches } : {}
1164
1330
  }