@ai-matrx/agents 0.38.4 → 0.41.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 (57) hide show
  1. package/CHANGELOG.md +29 -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 +0 -25
  25. package/dist/context/index.cjs.map +1 -1
  26. package/dist/context/index.d.cts +2 -17
  27. package/dist/context/index.d.ts +2 -17
  28. package/dist/context/index.js +0 -25
  29. package/dist/context/index.js.map +1 -1
  30. package/dist/context/react/index.cjs +280 -98
  31. package/dist/context/react/index.cjs.map +1 -1
  32. package/dist/context/react/index.d.cts +134 -16
  33. package/dist/context/react/index.d.ts +134 -16
  34. package/dist/context/react/index.js +283 -101
  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-ClN6zfUo.d.cts} +4 -4
  43. package/dist/{keys.generated-DxG5tgWt.d.ts → keys.generated-ClN6zfUo.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/mandates/snapshots/keys.0.41.0.json +653 -0
  57. 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,11 +41,18 @@ __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
@@ -132,24 +141,6 @@ function resolveContextRule(input) {
132
141
  clamped
133
142
  };
134
143
  }
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
144
  function formatChars(n) {
154
145
  if (n === null || n === void 0 || !Number.isFinite(n)) return "\u2014";
155
146
  const abs = Math.abs(n);
@@ -229,6 +220,79 @@ var ArrowDownToLineIcon = icon(
229
220
  ] })
230
221
  );
231
222
 
223
+ // context/react/hierarchy.ts
224
+ var AI_MATRX_LEVEL = { id: "ai_matrx", path: ["AI Matrx"], order: 900 };
225
+ var ATTACHED_LEVEL = { id: "attached", path: ["Attached"], order: 500 };
226
+ var PAGE_LEVEL = { id: "page", path: ["Page"], order: 100 };
227
+ var ORIGIN_LEVEL = {
228
+ page: PAGE_LEVEL,
229
+ attached: ATTACHED_LEVEL,
230
+ system: AI_MATRX_LEVEL
231
+ };
232
+ function placeByOrigin(row) {
233
+ return { level: ORIGIN_LEVEL[row.origin] };
234
+ }
235
+ function stableSort(list, ref) {
236
+ 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);
237
+ }
238
+ function buildContextLevels(rows, hierarchy) {
239
+ const place = hierarchy?.place ?? placeByOrigin;
240
+ const levels = /* @__PURE__ */ new Map();
241
+ const levelFor = (ref) => {
242
+ let node = levels.get(ref.id);
243
+ if (!node) {
244
+ node = { ref, rows: [], groups: [], master: null };
245
+ levels.set(ref.id, node);
246
+ }
247
+ return node;
248
+ };
249
+ for (const master of hierarchy?.masters ?? []) levelFor(master.level).master = master;
250
+ for (const row of rows) {
251
+ const where = place(row);
252
+ const level = levelFor(where.level);
253
+ if (!where.group) {
254
+ level.rows.push(row);
255
+ continue;
256
+ }
257
+ let group = level.groups.find((g) => g.ref.id === where.group.id);
258
+ if (!group) {
259
+ group = { ref: where.group, rows: [] };
260
+ level.groups.push(group);
261
+ }
262
+ group.rows.push(row);
263
+ }
264
+ const out = [...levels.values()];
265
+ for (const level of out) level.groups = stableSort(level.groups, (g) => g.ref);
266
+ return stableSort(out, (level) => level.ref);
267
+ }
268
+ function levelRows(level) {
269
+ return [...level.rows, ...level.groups.flatMap((g) => g.rows)];
270
+ }
271
+ function inheritedInclude(row, cap) {
272
+ return resolveContextRule({
273
+ ...row.layers ?? {},
274
+ chars: row.chars,
275
+ cap,
276
+ user: null,
277
+ identity: isServerAuthoritativeKey(row.key)
278
+ }).include;
279
+ }
280
+ function includeChanges(rows, include, cap) {
281
+ const changes = [];
282
+ for (const row of rows) {
283
+ if (row.include === include) continue;
284
+ const next = { ...row.userRule ?? {} };
285
+ if (inheritedInclude(row, cap) === include) delete next.include;
286
+ else next.include = include;
287
+ changes.push({
288
+ key: row.key,
289
+ surfaceKey: row.surfaceKey,
290
+ rule: Object.keys(next).length === 0 ? null : next
291
+ });
292
+ }
293
+ return changes;
294
+ }
295
+
232
296
  // context/react/InlineMaxInput.tsx
233
297
  var React = __toESM(require("react"), 1);
234
298
  var import_design_system = require("@ai-matrx/design-system");
@@ -410,13 +474,24 @@ function InlineMaxInput({
410
474
  ] });
411
475
  }
412
476
 
477
+ // context/react/summary.ts
478
+ function summarizeContextRows(rows) {
479
+ let count = 0;
480
+ let chars = 0;
481
+ let known = 0;
482
+ for (const r of rows) {
483
+ if (!r.include) continue;
484
+ count += 1;
485
+ if (r.chars === null || r.chars === void 0) continue;
486
+ chars += r.chars;
487
+ known += 1;
488
+ }
489
+ const charsLabel = count > 0 && known === 0 ? "\u2014" : known < count ? `${formatChars(chars)}+` : formatChars(chars);
490
+ return { count, chars, charsLabel };
491
+ }
492
+
413
493
  // context/react/ContextRulesTable.tsx
414
494
  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
495
  var CONTEXT_RULES_GRID = {
421
496
  compact: "grid grid-cols-[minmax(0,1fr)_2.75rem_4rem_6.5rem] items-center gap-x-2 px-2",
422
497
  // Phone widths (375px): the fixed columns stay compact so Item always keeps
@@ -432,11 +507,37 @@ function ContextRulesTable({
432
507
  onOpenRow,
433
508
  density = "compact",
434
509
  selectedKey,
510
+ hierarchy,
511
+ onSetInclude,
512
+ renderRowLead,
513
+ renderRowTrail,
435
514
  className
436
515
  }) {
437
516
  const comfortable = density === "comfortable";
438
- const present = GROUPS.filter((g) => rows.some((r) => r.origin === g.origin));
439
- const grouped = present.length > 1;
517
+ const levels = buildContextLevels(rows, hierarchy);
518
+ const headed = Boolean(hierarchy) || levels.length > 1;
519
+ const renderRow = (row, depth) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
520
+ ContextRuleRow,
521
+ {
522
+ row,
523
+ cap,
524
+ density,
525
+ depth: headed ? depth : 0,
526
+ readOnly,
527
+ selected: selectedKey === row.key,
528
+ mismatches: mismatches?.filter((m) => m.key === row.key) ?? [],
529
+ onChange,
530
+ onOpenRow,
531
+ comfortable,
532
+ lead: renderRowLead?.(row),
533
+ trail: renderRowTrail?.(row)
534
+ },
535
+ rowId(row)
536
+ );
537
+ const bulk = (list) => onSetInclude && !readOnly ? (next) => {
538
+ const changes = includeChanges(list, next, cap);
539
+ if (changes.length > 0) onSetInclude(changes);
540
+ } : void 0;
440
541
  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
542
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
442
543
  "div",
@@ -454,43 +555,115 @@ function ContextRulesTable({
454
555
  ]
455
556
  }
456
557
  ),
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))
558
+ 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) => {
559
+ const all = levelRows(level);
560
+ const name = level.ref.path.join(" \u203A ");
561
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { role: "rowgroup", "aria-label": headed ? name : void 0, "data-level": level.ref.id, children: [
562
+ headed ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
563
+ LevelHeading,
564
+ {
565
+ kind: "level",
566
+ path: level.ref.path,
567
+ rows: all,
568
+ density,
569
+ readOnly,
570
+ ...levelSwitch(level, bulk(all))
571
+ }
572
+ ) : null,
573
+ level.rows.map((row) => renderRow(row, 1)),
574
+ level.groups.map((group) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { role: "rowgroup", "aria-label": group.ref.label, "data-group": group.ref.id, children: [
575
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
576
+ LevelHeading,
577
+ {
578
+ kind: "group",
579
+ path: [group.ref.label],
580
+ rows: group.rows,
581
+ density,
582
+ readOnly,
583
+ onToggle: bulk(group.rows),
584
+ checked: group.rows.some((r) => r.include)
585
+ }
586
+ ),
587
+ group.rows.map((row) => renderRow(row, 2))
588
+ ] }, group.ref.id))
589
+ ] }, level.ref.id);
590
+ })
482
591
  ] }) });
483
592
  }
593
+ function levelSwitch(level, bulk) {
594
+ if (level.master) return { checked: level.master.on, onToggle: level.master.onToggle };
595
+ return { checked: levelRows(level).some((r) => r.include), onToggle: bulk };
596
+ }
597
+ function LevelHeading({
598
+ kind,
599
+ path,
600
+ rows,
601
+ density,
602
+ readOnly,
603
+ checked,
604
+ onToggle
605
+ }) {
606
+ const name = path.join(" \u203A ");
607
+ const { count, charsLabel } = summarizeContextRows(rows);
608
+ const total = rows.length;
609
+ const showSwitch = Boolean(onToggle) || readOnly && total > 0;
610
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
611
+ "div",
612
+ {
613
+ role: "row",
614
+ "data-heading": kind,
615
+ className: (0, import_design_system2.cn)(
616
+ CONTEXT_RULES_GRID[density],
617
+ "border-b border-border/50 font-medium",
618
+ density === "comfortable" ? "min-h-11" : "h-7",
619
+ kind === "level" ? "bg-muted/60 text-foreground" : "bg-muted/25 text-muted-foreground"
620
+ ),
621
+ children: [
622
+ /* @__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: [
623
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "flex min-w-0 items-center gap-1 overflow-hidden", title: name, children: path.map((part, i) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(React2.Fragment, { children: [
624
+ i > 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "shrink-0 text-muted-foreground", children: "\u203A" }) : null,
625
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
626
+ "span",
627
+ {
628
+ className: (0, import_design_system2.cn)(
629
+ "truncate",
630
+ i < path.length - 1 ? "max-w-[45%] shrink-0 text-muted-foreground" : "min-w-0"
631
+ ),
632
+ children: part
633
+ }
634
+ )
635
+ ] }, `${i}:${part}`)) }),
636
+ 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
637
+ ] }),
638
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { role: "cell", className: "flex justify-center", children: showSwitch ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
639
+ import_design_system2.Switch,
640
+ {
641
+ size: "sm",
642
+ "aria-label": `Include ${name}`,
643
+ checked,
644
+ disabled: readOnly || !onToggle,
645
+ onCheckedChange: (next) => onToggle?.(next)
646
+ }
647
+ ) : null }),
648
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { role: "cell", className: "text-right font-normal tabular-nums text-muted-foreground", children: total > 0 ? charsLabel : null }),
649
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { role: "cell" })
650
+ ]
651
+ }
652
+ );
653
+ }
484
654
  function ContextRuleRow({
485
655
  row,
486
656
  cap,
487
657
  density,
658
+ depth,
488
659
  comfortable,
489
660
  readOnly,
490
661
  selected,
491
662
  mismatches,
492
663
  onChange,
493
- onOpenRow
664
+ onOpenRow,
665
+ lead,
666
+ trail
494
667
  }) {
495
668
  const selfChecked = row.blockedBy === "self_check" || mismatches.some((m) => m.reason === "self_check");
496
669
  const decided = selfChecked ? SELF_CHECK_TOOLTIP : row.serverResolved ? SERVER_RESOLVED_TOOLTIP : `Include: ${LAYER_LABEL[row.decided_by.include]} \xB7 Limit: ${LAYER_LABEL[row.decided_by.max_inline_chars]}`;
@@ -520,27 +693,41 @@ function ContextRuleRow({
520
693
  selected && "bg-accent"
521
694
  ),
522
695
  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
- ] }),
696
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
697
+ "div",
698
+ {
699
+ role: "cell",
700
+ className: (0, import_design_system2.cn)(
701
+ "flex min-w-0 items-center gap-1.5",
702
+ depth === 1 && "pl-2",
703
+ depth === 2 && "pl-4",
704
+ !row.include && "opacity-50"
705
+ ),
706
+ children: [
707
+ mismatches.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_design_system2.Tooltip, { children: [
708
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_design_system2.TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
709
+ "span",
710
+ {
711
+ role: "img",
712
+ "aria-label": "Mismatch",
713
+ className: "inline-flex shrink-0 text-warning",
714
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(TriangleAlertIcon, { className: "h-3.5 w-3.5" })
715
+ }
716
+ ) }),
717
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_design_system2.TooltipContent, { children: describeMismatches(mismatches) })
718
+ ] }) : null,
719
+ lead ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "inline-flex shrink-0 items-center", children: lead }) : null,
720
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_design_system2.Tooltip, { children: [
721
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_design_system2.TooltipTrigger, { asChild: true, children: labelNode }),
722
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_design_system2.TooltipContent, { children: [
723
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { children: row.label }),
724
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "font-normal text-muted-foreground", children: decided })
725
+ ] })
726
+ ] }),
727
+ trail ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "min-w-0 max-w-[45%] shrink truncate text-muted-foreground", children: trail }) : null
728
+ ]
729
+ }
730
+ ),
544
731
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { role: "cell", className: "flex justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
545
732
  import_design_system2.Switch,
546
733
  {
@@ -584,25 +771,11 @@ function ContextRuleRow({
584
771
  }
585
772
 
586
773
  // context/react/ContextRulesChip.tsx
587
- var React2 = __toESM(require("react"), 1);
774
+ var React3 = __toESM(require("react"), 1);
588
775
  var import_design_system3 = require("@ai-matrx/design-system");
589
776
  var import_jsx_runtime4 = require("react/jsx-runtime");
590
777
  var BLIND_TOOLTIP = "This model can't read these values";
591
778
  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
779
  function IconButton({
607
780
  label,
608
781
  onClick,
@@ -632,6 +805,8 @@ function ContextRulesChip({
632
805
  cap,
633
806
  on,
634
807
  onToggleAll,
808
+ hierarchy,
809
+ onSetInclude,
635
810
  onChange,
636
811
  onResetAll,
637
812
  onOpenFullView,
@@ -645,7 +820,7 @@ function ContextRulesChip({
645
820
  onOpenChange,
646
821
  className
647
822
  }) {
648
- const [openState, setOpenState] = React2.useState(false);
823
+ const [openState, setOpenState] = React3.useState(false);
649
824
  const open = openProp ?? openState;
650
825
  const setOpen = (next) => {
651
826
  if (openProp === void 0) setOpenState(next);
@@ -658,7 +833,8 @@ function ContextRulesChip({
658
833
  const blind = !modelReadsContext;
659
834
  const warn = mismatchCount > 0 && !blind;
660
835
  const comfortable = !!isMobile;
661
- const hasPage = on !== void 0;
836
+ const hasPage = on !== void 0 && !hierarchy;
837
+ const headerName = hierarchy ? "" : name;
662
838
  const eyeOpen = !blind && on !== false;
663
839
  const faceButton = /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
664
840
  "button",
@@ -702,7 +878,7 @@ function ContextRulesChip({
702
878
  ),
703
879
  children: [
704
880
  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,
881
+ headerName ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "min-w-0 truncate text-sm font-medium", children: headerName }) : null,
706
882
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "shrink-0 text-xs tabular-nums text-muted-foreground", children: `${count} \xB7 ${charsLabel} chars` }),
707
883
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "ml-auto flex shrink-0 items-center gap-0.5", children: [
708
884
  blind ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "mr-1 text-xs text-muted-foreground", children: BLIND_LABEL }) : null,
@@ -742,6 +918,8 @@ function ContextRulesChip({
742
918
  readOnly,
743
919
  density: comfortable ? "comfortable" : "compact",
744
920
  onChange,
921
+ hierarchy,
922
+ onSetInclude,
745
923
  ...mismatches ? { mismatches } : {},
746
924
  ...onOpenRow ? { onOpenRow } : {}
747
925
  }
@@ -767,11 +945,11 @@ function ContextRulesChip({
767
945
  }
768
946
 
769
947
  // context/react/ContextRulesPanelBody.tsx
770
- var React4 = __toESM(require("react"), 1);
948
+ var React5 = __toESM(require("react"), 1);
771
949
  var import_design_system6 = require("@ai-matrx/design-system");
772
950
 
773
951
  // context/react/ContextDeliveredValue.tsx
774
- var React3 = __toESM(require("react"), 1);
952
+ var React4 = __toESM(require("react"), 1);
775
953
  var import_design_system4 = require("@ai-matrx/design-system");
776
954
  var import_jsx_runtime5 = require("react/jsx-runtime");
777
955
  function ContextDeliveredValue({
@@ -832,10 +1010,10 @@ function DeliveredSection({
832
1010
  ref_,
833
1011
  load
834
1012
  }) {
835
- const [loaded, setLoaded] = React3.useState({ state: "loading" });
836
- const [attempt, setAttempt] = React3.useState(0);
1013
+ const [loaded, setLoaded] = React4.useState({ state: "loading" });
1014
+ const [attempt, setAttempt] = React4.useState(0);
837
1015
  const { kind, key } = target;
838
- React3.useEffect(() => {
1016
+ React4.useEffect(() => {
839
1017
  if (!load) return;
840
1018
  let live = true;
841
1019
  setLoaded({ state: "loading" });
@@ -1106,15 +1284,17 @@ function ContextRulesPanelBody({
1106
1284
  loadView,
1107
1285
  readOnly,
1108
1286
  onChange,
1287
+ hierarchy,
1288
+ onSetInclude,
1109
1289
  renderDetail,
1110
1290
  isMobile,
1111
1291
  selectedKey: selectedProp,
1112
1292
  onSelectedKeyChange,
1113
1293
  className
1114
1294
  }) {
1115
- const [selectedState, setSelectedState] = React4.useState(null);
1116
- const [query, setQuery] = React4.useState("");
1117
- const [openBlockId, setOpenBlockId] = React4.useState(null);
1295
+ const [selectedState, setSelectedState] = React5.useState(null);
1296
+ const [query, setQuery] = React5.useState("");
1297
+ const [openBlockId, setOpenBlockId] = React5.useState(null);
1118
1298
  const selectedKey = selectedProp !== void 0 ? selectedProp : selectedState;
1119
1299
  const select = (key) => {
1120
1300
  setOpenBlockId(null);
@@ -1159,6 +1339,8 @@ function ContextRulesPanelBody({
1159
1339
  density: comfortable ? "comfortable" : "compact",
1160
1340
  selectedKey,
1161
1341
  onChange,
1342
+ hierarchy,
1343
+ onSetInclude,
1162
1344
  onOpenRow: (key) => select(key),
1163
1345
  ...mismatches ? { mismatches } : {}
1164
1346
  }