@ai-matrx/agents 0.28.1 → 0.29.1

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 (54) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/content-transfer/index.cjs +1 -0
  3. package/dist/content-transfer/index.cjs.map +1 -1
  4. package/dist/content-transfer/index.d.cts +2 -1
  5. package/dist/content-transfer/index.d.ts +2 -1
  6. package/dist/content-transfer/index.js +1 -0
  7. package/dist/content-transfer/index.js.map +1 -1
  8. package/dist/content-transfer/react/index.cjs +1 -0
  9. package/dist/content-transfer/react/index.cjs.map +1 -1
  10. package/dist/content-transfer/react/index.js +1 -0
  11. package/dist/content-transfer/react/index.js.map +1 -1
  12. package/dist/context/index.cjs +29 -5
  13. package/dist/context/index.cjs.map +1 -1
  14. package/dist/context/index.d.cts +65 -13
  15. package/dist/context/index.d.ts +65 -13
  16. package/dist/context/index.js +29 -5
  17. package/dist/context/index.js.map +1 -1
  18. package/dist/context/react/index.cjs +262 -78
  19. package/dist/context/react/index.cjs.map +1 -1
  20. package/dist/context/react/index.d.cts +100 -21
  21. package/dist/context/react/index.d.ts +100 -21
  22. package/dist/context/react/index.js +261 -77
  23. package/dist/context/react/index.js.map +1 -1
  24. package/dist/index.d.cts +2 -1
  25. package/dist/index.d.ts +2 -1
  26. package/dist/mandates/index.cjs +3 -2
  27. package/dist/mandates/index.cjs.map +1 -1
  28. package/dist/mandates/index.d.cts +6 -5
  29. package/dist/mandates/index.d.ts +6 -5
  30. package/dist/mandates/index.js +3 -2
  31. package/dist/mandates/index.js.map +1 -1
  32. package/dist/matrx/index.d.cts +4 -2
  33. package/dist/matrx/index.d.ts +4 -2
  34. package/dist/{operations-Dp4ut-ac.d.ts → operations-C3iHFcnt.d.ts} +2 -94
  35. package/dist/{operations--f5ko9Su.d.cts → operations-C9QvBH_2.d.cts} +2 -94
  36. package/dist/portable/index.cjs +164 -0
  37. package/dist/portable/index.cjs.map +1 -0
  38. package/dist/portable/index.d.cts +74 -0
  39. package/dist/portable/index.d.ts +74 -0
  40. package/dist/portable/index.js +141 -0
  41. package/dist/portable/index.js.map +1 -0
  42. package/dist/portable/mcp.cjs +512 -0
  43. package/dist/portable/mcp.cjs.map +1 -0
  44. package/dist/portable/mcp.d.cts +81 -0
  45. package/dist/portable/mcp.d.ts +81 -0
  46. package/dist/portable/mcp.js +492 -0
  47. package/dist/portable/mcp.js.map +1 -0
  48. package/dist/transport-CxD0fL8p.d.cts +94 -0
  49. package/dist/transport-CxD0fL8p.d.ts +94 -0
  50. package/dist/types.generated-BydVlqDC.d.cts +49 -0
  51. package/dist/types.generated-BydVlqDC.d.ts +49 -0
  52. package/mandates/snapshots/keys.0.29.0.json +652 -0
  53. package/mandates/snapshots/keys.0.29.1.json +653 -0
  54. package/package.json +22 -2
@@ -32,9 +32,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
32
32
  var react_exports = {};
33
33
  __export(react_exports, {
34
34
  ContextDeliveredValue: () => ContextDeliveredValue,
35
+ ContextReceiptBlockDetail: () => ContextReceiptBlockDetail,
36
+ ContextReceiptBlocks: () => ContextReceiptBlocks,
35
37
  ContextRulesChip: () => ContextRulesChip,
36
38
  ContextRulesPanelBody: () => ContextRulesPanelBody,
37
39
  ContextRulesTable: () => ContextRulesTable,
40
+ DeliveredSection: () => DeliveredSection,
38
41
  InlineMaxInput: () => InlineMaxInput,
39
42
  summarizeContextRows: () => summarizeContextRows
40
43
  });
@@ -46,6 +49,14 @@ var import_design_system2 = require("@ai-matrx/design-system");
46
49
  // context/index.ts
47
50
  var DEFAULT_INLINE_MAX_CHARS = 200;
48
51
  var DEFAULT_INLINE_CAP = 5e4;
52
+ var CONTEXT_ROW_BLOCKS = {
53
+ organization: ["organization_catalog"]
54
+ };
55
+ function unclaimedBlocks(blocks, rowKeys) {
56
+ const claimed = /* @__PURE__ */ new Set();
57
+ for (const key of rowKeys) for (const id of CONTEXT_ROW_BLOCKS[key] ?? []) claimed.add(id);
58
+ return (blocks ?? []).filter((b) => !claimed.has(b.id));
59
+ }
49
60
  var SERVER_AUTHORITATIVE_KEYS = {
50
61
  user: "manifest",
51
62
  client: "manifest",
@@ -573,7 +584,7 @@ function ContextRuleRow({
573
584
  var React2 = __toESM(require("react"), 1);
574
585
  var import_design_system3 = require("@ai-matrx/design-system");
575
586
  var import_jsx_runtime4 = require("react/jsx-runtime");
576
- var BLIND_TOOLTIP = "This model can't read context";
587
+ var BLIND_TOOLTIP = "This model can't read these values";
577
588
  var BLIND_LABEL = "Not read";
578
589
  function summarizeContextRows(rows) {
579
590
  let count = 0;
@@ -638,6 +649,8 @@ function ContextRulesChip({
638
649
  onOpenChange?.(next);
639
650
  };
640
651
  const { count, charsLabel } = summarizeContextRows(rows);
652
+ const name = label?.trim() ?? "";
653
+ const faceName = name ? `${name} \xB7 ${count} included` : `${count} included`;
641
654
  const anyOverride = rows.some(hasOverride);
642
655
  const blind = !modelReadsContext;
643
656
  const warn = mismatchCount > 0 && !blind;
@@ -648,20 +661,21 @@ function ContextRulesChip({
648
661
  "button",
649
662
  {
650
663
  type: "button",
651
- "aria-label": `Context: ${label}`,
664
+ "aria-label": faceName,
652
665
  "data-mismatch": warn ? "true" : void 0,
653
666
  "data-blind": blind ? "true" : void 0,
654
667
  onClick: isMobile ? () => setOpen(true) : void 0,
655
668
  className: (0, import_design_system3.cn)(
656
- "inline-flex h-7 max-w-[14rem] items-center gap-1.5 rounded-full border border-border bg-card px-2 text-xs text-foreground hover:bg-accent",
669
+ "relative inline-flex h-6 max-w-[12rem] shrink-0 items-center gap-1 rounded-md border border-border bg-card px-1.5 text-xs font-medium text-foreground transition-colors hover:bg-accent",
670
+ comfortable && "after:absolute after:-inset-x-1.5 after:-inset-y-2.5 after:content-['']",
657
671
  !eyeOpen && "text-muted-foreground",
658
672
  blind && "border-dashed",
659
673
  warn && "border-warning/60 ring-1 ring-warning",
660
674
  className
661
675
  ),
662
676
  children: [
663
- eyeOpen ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(EyeIcon, { className: "h-3.5 w-3.5 shrink-0" }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(EyeOffIcon, { className: "h-3.5 w-3.5 shrink-0" }),
664
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "min-w-0 truncate", children: label }),
677
+ eyeOpen ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(EyeIcon, { className: "h-3 w-3 shrink-0" }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(EyeOffIcon, { className: "h-3 w-3 shrink-0" }),
678
+ name ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "min-w-0 truncate", children: name }) : null,
665
679
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "shrink-0 tabular-nums text-muted-foreground", children: count }),
666
680
  warn ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "inline-flex shrink-0 items-center gap-0.5 tabular-nums text-warning", children: [
667
681
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(TriangleAlertIcon, { className: "h-3 w-3" }),
@@ -670,9 +684,10 @@ function ContextRulesChip({
670
684
  ]
671
685
  }
672
686
  );
673
- const withBlindTip = (trigger) => blind ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_design_system3.Tooltip, { children: [
687
+ const faceTip = blind ? BLIND_TOOLTIP : name ? null : faceName;
688
+ const withBlindTip = (trigger) => faceTip ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_design_system3.Tooltip, { children: [
674
689
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_design_system3.TooltipTrigger, { asChild: true, children: trigger }),
675
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_design_system3.TooltipContent, { children: BLIND_TOOLTIP })
690
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_design_system3.TooltipContent, { children: faceTip })
676
691
  ] }) : trigger;
677
692
  const body = /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex min-h-0 flex-col", children: [
678
693
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
@@ -684,7 +699,7 @@ function ContextRulesChip({
684
699
  ),
685
700
  children: [
686
701
  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" }),
687
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "min-w-0 truncate text-sm font-medium", children: label }),
702
+ name ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "min-w-0 truncate text-sm font-medium", children: name }) : null,
688
703
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "shrink-0 text-xs tabular-nums text-muted-foreground", children: `${count} \xB7 ${charsLabel} chars` }),
689
704
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "ml-auto flex shrink-0 items-center gap-0.5", children: [
690
705
  blind ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "mr-1 text-xs text-muted-foreground", children: BLIND_LABEL }) : null,
@@ -692,7 +707,7 @@ function ContextRulesChip({
692
707
  import_design_system3.Switch,
693
708
  {
694
709
  size: "sm",
695
- "aria-label": "Page context",
710
+ "aria-label": "Include this page",
696
711
  checked: on,
697
712
  disabled: readOnly || !onToggleAll,
698
713
  onCheckedChange: (next) => onToggleAll?.(next),
@@ -732,7 +747,7 @@ function ContextRulesChip({
732
747
  if (isMobile) {
733
748
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_design_system3.TooltipProvider, { delayDuration: 300, titleTooltips: false, children: [
734
749
  withBlindTip(faceButton),
735
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_design_system3.BottomSheet, { open, onOpenChange: setOpen, title: label, surface: "solid", children: body })
750
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_design_system3.BottomSheet, { open, onOpenChange: setOpen, title: name || faceName, surface: "solid", children: body })
736
751
  ] });
737
752
  }
738
753
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_design_system3.TooltipProvider, { delayDuration: 300, titleTooltips: false, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_design_system3.Popover, { open, onOpenChange: setOpen, children: [
@@ -740,7 +755,7 @@ function ContextRulesChip({
740
755
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
741
756
  import_design_system3.PopoverContent,
742
757
  {
743
- align: "start",
758
+ align: "end",
744
759
  className: "w-[26rem] max-w-[calc(100vw-1rem)] overflow-hidden p-0",
745
760
  children: body
746
761
  }
@@ -749,31 +764,99 @@ function ContextRulesChip({
749
764
  }
750
765
 
751
766
  // context/react/ContextRulesPanelBody.tsx
752
- var React3 = __toESM(require("react"), 1);
753
- var import_design_system5 = require("@ai-matrx/design-system");
767
+ var React4 = __toESM(require("react"), 1);
768
+ var import_design_system6 = require("@ai-matrx/design-system");
754
769
 
755
770
  // context/react/ContextDeliveredValue.tsx
771
+ var React3 = __toESM(require("react"), 1);
756
772
  var import_design_system4 = require("@ai-matrx/design-system");
757
773
  var import_jsx_runtime5 = require("react/jsx-runtime");
758
774
  function ContextDeliveredValue({
759
775
  row,
776
+ load,
760
777
  className
761
778
  }) {
762
- if (!row.delivered && !row.onRequest) {
779
+ const blocks = row.deliveredBlocks ?? [];
780
+ if (!row.delivered && !row.onRequest && blocks.length === 0) {
763
781
  return isServerAuthoritativeKey(row.key) ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { "data-testid": "context-server-fills", className: (0, import_design_system4.cn)("text-xs text-muted-foreground", className), children: "Filled in by the server" }) : null;
764
782
  }
765
783
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: (0, import_design_system4.cn)("flex flex-col gap-3", className), children: [
766
- row.delivered ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DeliveredBlock, { title: "Agent received", text: row.delivered }) : null,
767
- row.onRequest ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DeliveredBlock, { title: "Returned on request", text: row.onRequest }) : null
784
+ row.delivered ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
785
+ DeliveredSection,
786
+ {
787
+ title: "Agent received",
788
+ target: { kind: "delivered", key: row.key },
789
+ ref_: row.delivered,
790
+ load
791
+ }
792
+ ) : null,
793
+ blocks.map((block) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
794
+ DeliveredSection,
795
+ {
796
+ title: block.label,
797
+ target: { kind: "block", key: block.id },
798
+ ref_: block.delivered,
799
+ load
800
+ },
801
+ block.id
802
+ )),
803
+ row.onRequest ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
804
+ DeliveredSection,
805
+ {
806
+ title: "Returned on request",
807
+ target: { kind: "on_request", key: row.key },
808
+ ref_: row.onRequest,
809
+ load
810
+ }
811
+ ) : null
768
812
  ] });
769
813
  }
770
- function DeliveredBlock({ title, text }) {
771
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("section", { className: "flex flex-col gap-1", "aria-label": title, children: [
814
+ function DeliveredSection({
815
+ title,
816
+ target,
817
+ ref_,
818
+ load
819
+ }) {
820
+ const [loaded, setLoaded] = React3.useState({ state: "loading" });
821
+ const [attempt, setAttempt] = React3.useState(0);
822
+ const { kind, key } = target;
823
+ React3.useEffect(() => {
824
+ if (!load) return;
825
+ let live = true;
826
+ setLoaded({ state: "loading" });
827
+ load({ kind, key }).then(
828
+ (viewed) => {
829
+ if (live) setLoaded({ state: "done", text: viewed.text });
830
+ },
831
+ (error) => {
832
+ if (live)
833
+ setLoaded({
834
+ state: "error",
835
+ message: error instanceof Error && error.message ? error.message : "Couldn't load"
836
+ });
837
+ }
838
+ );
839
+ return () => {
840
+ live = false;
841
+ };
842
+ }, [load, kind, key, attempt]);
843
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("section", { className: "flex flex-col gap-1", "aria-label": title, "data-view-kind": kind, "data-view-key": key, children: [
772
844
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-baseline gap-2 text-xs", children: [
773
845
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "font-medium", children: title }),
774
- text.truncated ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "tabular-nums text-muted-foreground", children: `First ${text.text.length.toLocaleString()} of ${text.chars.toLocaleString()} chars` }) : null
846
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "tabular-nums text-muted-foreground", children: `${formatChars(ref_.chars)} chars` })
775
847
  ] }),
776
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
848
+ !load ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-xs text-muted-foreground", children: "\u2014" }) : loaded.state === "loading" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_design_system4.Skeleton, { "data-testid": "context-delivered-loading", className: "h-16 w-full" }) : loaded.state === "error" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-2 text-xs text-destructive", role: "alert", children: [
849
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "min-w-0 truncate", title: loaded.message, children: loaded.message }),
850
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
851
+ "button",
852
+ {
853
+ type: "button",
854
+ onClick: () => setAttempt((n) => n + 1),
855
+ className: "shrink-0 rounded px-1.5 py-0.5 text-foreground hover:bg-accent",
856
+ children: "Retry"
857
+ }
858
+ )
859
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
777
860
  "pre",
778
861
  {
779
862
  "data-testid": "context-delivered-text",
@@ -782,14 +865,88 @@ function DeliveredBlock({ title, text }) {
782
865
  "whitespace-pre-wrap break-words rounded border border-border",
783
866
  "bg-muted/40 p-2 font-mono text-[11px] text-foreground"
784
867
  ),
785
- children: text.text
868
+ children: loaded.text
786
869
  }
787
870
  )
788
871
  ] });
789
872
  }
790
873
 
791
- // context/react/ContextRulesPanelBody.tsx
874
+ // context/react/ContextReceiptBlocks.tsx
875
+ var import_design_system5 = require("@ai-matrx/design-system");
792
876
  var import_jsx_runtime6 = require("react/jsx-runtime");
877
+ function ContextReceiptBlocks({
878
+ blocks,
879
+ selectedId,
880
+ onOpenBlock,
881
+ density = "compact",
882
+ className
883
+ }) {
884
+ if (blocks.length === 0) return null;
885
+ const comfortable = density === "comfortable";
886
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { role: "table", "aria-label": "Also sent", className: (0, import_design_system5.cn)("text-xs", className), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { role: "rowgroup", children: [
887
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
888
+ "div",
889
+ {
890
+ role: "row",
891
+ className: "flex h-6 items-center bg-muted/40 px-2 font-medium text-muted-foreground",
892
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { role: "cell", children: "Also sent" })
893
+ }
894
+ ),
895
+ blocks.map((block) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
896
+ "div",
897
+ {
898
+ role: "row",
899
+ "data-block-id": block.id,
900
+ "aria-selected": selectedId === block.id || void 0,
901
+ className: (0, import_design_system5.cn)(
902
+ CONTEXT_RULES_GRID[density],
903
+ "border-b border-border/50",
904
+ comfortable ? "min-h-11" : "h-7",
905
+ selectedId === block.id && "bg-accent"
906
+ ),
907
+ children: [
908
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { role: "cell", className: "col-span-2 flex min-w-0 items-center", children: onOpenBlock ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
909
+ "button",
910
+ {
911
+ type: "button",
912
+ title: block.label,
913
+ onClick: () => onOpenBlock(block.id),
914
+ className: "block min-w-0 flex-1 truncate text-left hover:underline focus-visible:underline focus-visible:outline-none",
915
+ children: block.label
916
+ }
917
+ ) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { title: block.label, className: "block min-w-0 flex-1 truncate", children: block.label }) }),
918
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { role: "cell", className: "text-right tabular-nums", children: formatChars(block.delivered.chars) }),
919
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { role: "cell" })
920
+ ]
921
+ },
922
+ block.id
923
+ ))
924
+ ] }) });
925
+ }
926
+ function ContextReceiptBlockDetail({
927
+ block,
928
+ load,
929
+ className
930
+ }) {
931
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: (0, import_design_system5.cn)("flex flex-col gap-3 p-3", className), children: [
932
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex min-w-0 items-baseline gap-2", children: [
933
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h3", { className: "min-w-0 truncate text-sm font-medium", children: block.label }),
934
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "shrink-0 text-xs tabular-nums text-muted-foreground", children: `${formatChars(block.delivered.chars)} chars \xB7 ${DELIVERY_LABEL.inline}` })
935
+ ] }),
936
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
937
+ DeliveredSection,
938
+ {
939
+ title: "Agent received",
940
+ target: { kind: "block", key: block.id },
941
+ ref_: block.delivered,
942
+ load
943
+ }
944
+ )
945
+ ] });
946
+ }
947
+
948
+ // context/react/ContextRulesPanelBody.tsx
949
+ var import_jsx_runtime7 = require("react/jsx-runtime");
793
950
  function layerCells(row) {
794
951
  const { surface, agent, default_max } = row.layers ?? {};
795
952
  const declared = agent?.declared === true;
@@ -812,38 +969,38 @@ function layerCells(row) {
812
969
  var LAYERS = ["default", "page", "agent", "you"];
813
970
  function LayerTable({ row }) {
814
971
  const cells = layerCells(row);
815
- const cell = (text, winning) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
972
+ const cell = (text, winning) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
816
973
  "span",
817
974
  {
818
975
  role: "cell",
819
976
  "data-winning": winning ? "true" : void 0,
820
- className: (0, import_design_system5.cn)(
977
+ className: (0, import_design_system6.cn)(
821
978
  "rounded px-1.5 py-0.5 text-right tabular-nums",
822
979
  winning ? "bg-primary/10 font-medium text-foreground" : "text-muted-foreground"
823
980
  ),
824
981
  children: text
825
982
  }
826
983
  );
827
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { role: "table", "aria-label": "Layers", className: "text-xs", children: [
828
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
984
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { role: "table", "aria-label": "Layers", className: "text-xs", children: [
985
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
829
986
  "div",
830
987
  {
831
988
  role: "row",
832
989
  className: "grid h-7 grid-cols-[1fr_5rem_5rem] items-center gap-x-2 border-b border-border font-medium text-muted-foreground",
833
990
  children: [
834
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { role: "columnheader", children: "Layer" }),
835
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { role: "columnheader", className: "text-right", children: "Include" }),
836
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { role: "columnheader", className: "text-right", children: "Inline max" })
991
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { role: "columnheader", children: "Layer" }),
992
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { role: "columnheader", className: "text-right", children: "Include" }),
993
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { role: "columnheader", className: "text-right", children: "Inline max" })
837
994
  ]
838
995
  }
839
996
  ),
840
- LAYERS.map((layer) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
997
+ LAYERS.map((layer) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
841
998
  "div",
842
999
  {
843
1000
  role: "row",
844
1001
  className: "grid h-7 grid-cols-[1fr_5rem_5rem] items-center gap-x-2 border-b border-border/50",
845
1002
  children: [
846
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { role: "cell", children: LAYER_LABEL[layer] }),
1003
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { role: "cell", children: LAYER_LABEL[layer] }),
847
1004
  cell(cells[layer].include, row.decided_by.include === layer),
848
1005
  cell(cells[layer].limit, row.decided_by.max_inline_chars === layer)
849
1006
  ]
@@ -859,21 +1016,22 @@ function RowDetail({
859
1016
  mismatches,
860
1017
  onChange,
861
1018
  renderDetail,
862
- comfortable
1019
+ comfortable,
1020
+ loadView
863
1021
  }) {
864
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex flex-col gap-3 p-3", children: [
865
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex min-w-0 items-baseline gap-2", children: [
866
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h3", { className: "min-w-0 truncate text-sm font-medium", children: row.label }),
867
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "shrink-0 text-xs tabular-nums text-muted-foreground", children: `${formatChars(row.chars)} chars \xB7 ${DELIVERY_LABEL[row.delivery]}` })
1022
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex flex-col gap-3 p-3", children: [
1023
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex min-w-0 items-baseline gap-2", children: [
1024
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("h3", { className: "min-w-0 truncate text-sm font-medium", children: row.label }),
1025
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "shrink-0 text-xs tabular-nums text-muted-foreground", children: `${formatChars(row.chars)} chars \xB7 ${DELIVERY_LABEL[row.delivery]}` })
868
1026
  ] }),
869
- mismatches.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex items-start gap-1.5 rounded-md border border-warning/40 bg-warning/10 px-2 py-1.5 text-xs text-warning", children: [
870
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(TriangleAlertIcon, { className: "mt-0.5 h-3.5 w-3.5 shrink-0" }),
871
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: describeMismatches(mismatches) })
1027
+ mismatches.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex items-start gap-1.5 rounded-md border border-warning/40 bg-warning/10 px-2 py-1.5 text-xs text-warning", children: [
1028
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TriangleAlertIcon, { className: "mt-0.5 h-3.5 w-3.5 shrink-0" }),
1029
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: describeMismatches(mismatches) })
872
1030
  ] }) : null,
873
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "grid grid-cols-[auto_1fr] items-center gap-x-4 gap-y-2 text-xs", children: [
874
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "text-muted-foreground", children: "Include" }),
875
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: (0, import_design_system5.cn)("flex items-center", comfortable ? "h-11" : "h-7"), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
876
- import_design_system5.Switch,
1031
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "grid grid-cols-[auto_1fr] items-center gap-x-4 gap-y-2 text-xs", children: [
1032
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-muted-foreground", children: "Include" }),
1033
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: (0, import_design_system6.cn)("flex items-center", comfortable ? "h-11" : "h-7"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1034
+ import_design_system6.Switch,
877
1035
  {
878
1036
  size: "sm",
879
1037
  "aria-label": `Include ${row.label}`,
@@ -882,8 +1040,8 @@ function RowDetail({
882
1040
  onCheckedChange: (next) => onChange(row.key, row.surfaceKey, withInclude(row, next))
883
1041
  }
884
1042
  ) }),
885
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "text-muted-foreground", children: "Inline max" }),
886
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "flex", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1043
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-muted-foreground", children: "Inline max" }),
1044
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "flex", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
887
1045
  InlineMaxInput,
888
1046
  {
889
1047
  label: row.label,
@@ -897,8 +1055,8 @@ function RowDetail({
897
1055
  }
898
1056
  ) })
899
1057
  ] }),
900
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(LayerTable, { row }),
901
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ContextDeliveredValue, { row }),
1058
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(LayerTable, { row }),
1059
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ContextDeliveredValue, { row, load: loadView }),
902
1060
  renderDetail ? renderDetail(row) : null
903
1061
  ] });
904
1062
  }
@@ -906,6 +1064,8 @@ function ContextRulesPanelBody({
906
1064
  rows,
907
1065
  cap,
908
1066
  mismatches,
1067
+ blocks,
1068
+ loadView,
909
1069
  readOnly,
910
1070
  onChange,
911
1071
  renderDetail,
@@ -914,45 +1074,68 @@ function ContextRulesPanelBody({
914
1074
  onSelectedKeyChange,
915
1075
  className
916
1076
  }) {
917
- const [selectedState, setSelectedState] = React3.useState(null);
918
- const [query, setQuery] = React3.useState("");
1077
+ const [selectedState, setSelectedState] = React4.useState(null);
1078
+ const [query, setQuery] = React4.useState("");
1079
+ const [openBlockId, setOpenBlockId] = React4.useState(null);
919
1080
  const selectedKey = selectedProp !== void 0 ? selectedProp : selectedState;
920
1081
  const select = (key) => {
1082
+ setOpenBlockId(null);
921
1083
  if (selectedProp === void 0) setSelectedState(key);
922
1084
  onSelectedKeyChange?.(key);
923
1085
  };
1086
+ const openBlock = (id) => {
1087
+ select(null);
1088
+ setOpenBlockId(id);
1089
+ };
924
1090
  const q = query.trim().toLowerCase();
925
1091
  const visible = q ? rows.filter((r) => r.label.toLowerCase().includes(q) || r.key.toLowerCase().includes(q)) : rows;
926
- const selected = selectedKey ? rows.find((r) => r.key === selectedKey) ?? null : null;
1092
+ const alsoSent = unclaimedBlocks(
1093
+ blocks,
1094
+ rows.filter((r) => r.delivered).map((r) => r.key)
1095
+ );
1096
+ const visibleBlocks = q ? alsoSent.filter((b) => b.label.toLowerCase().includes(q) || b.id.toLowerCase().includes(q)) : alsoSent;
1097
+ const openedBlock = openBlockId ? (blocks ?? []).find((b) => b.id === openBlockId) ?? null : null;
1098
+ const selected = !openedBlock && selectedKey ? rows.find((r) => r.key === selectedKey) ?? null : null;
927
1099
  const comfortable = !!isMobile;
928
- const search = /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "relative shrink-0 border-b border-border p-2", children: [
929
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SearchIcon, { className: "pointer-events-none absolute left-4 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground" }),
930
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
931
- import_design_system5.Input,
1100
+ const search = /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "relative shrink-0 border-b border-border p-2", children: [
1101
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(SearchIcon, { className: "pointer-events-none absolute left-4 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground" }),
1102
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1103
+ import_design_system6.Input,
932
1104
  {
933
1105
  type: "search",
934
1106
  "aria-label": "Search context",
935
1107
  placeholder: "Search",
936
1108
  value: query,
937
1109
  onChange: (e) => setQuery(e.target.value),
938
- className: (0, import_design_system5.cn)("pl-7 shadow-none", comfortable ? "h-11 text-base" : "h-8 text-xs")
1110
+ className: (0, import_design_system6.cn)("pl-7 shadow-none", comfortable ? "h-11 text-base" : "h-8 text-xs")
939
1111
  }
940
1112
  )
941
1113
  ] });
942
- const table = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "min-h-0 flex-1 overflow-y-auto", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
943
- ContextRulesTable,
944
- {
945
- rows: visible,
946
- cap,
947
- readOnly,
948
- density: comfortable ? "comfortable" : "compact",
949
- selectedKey,
950
- onChange,
951
- onOpenRow: (key) => select(key),
952
- ...mismatches ? { mismatches } : {}
953
- }
954
- ) });
955
- const detail = selected ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1114
+ const table = /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "min-h-0 flex-1 overflow-y-auto", children: [
1115
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1116
+ ContextRulesTable,
1117
+ {
1118
+ rows: visible,
1119
+ cap,
1120
+ readOnly,
1121
+ density: comfortable ? "comfortable" : "compact",
1122
+ selectedKey,
1123
+ onChange,
1124
+ onOpenRow: (key) => select(key),
1125
+ ...mismatches ? { mismatches } : {}
1126
+ }
1127
+ ),
1128
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1129
+ ContextReceiptBlocks,
1130
+ {
1131
+ blocks: visibleBlocks,
1132
+ selectedId: openedBlock?.id ?? null,
1133
+ onOpenBlock: openBlock,
1134
+ density: comfortable ? "comfortable" : "compact"
1135
+ }
1136
+ )
1137
+ ] });
1138
+ const detail = openedBlock ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ContextReceiptBlockDetail, { block: openedBlock, load: loadView }) : selected ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
956
1139
  RowDetail,
957
1140
  {
958
1141
  row: selected,
@@ -961,35 +1144,36 @@ function ContextRulesPanelBody({
961
1144
  mismatches: mismatches?.filter((m) => m.key === selected.key) ?? [],
962
1145
  onChange,
963
1146
  renderDetail,
964
- comfortable
1147
+ comfortable,
1148
+ loadView
965
1149
  }
966
1150
  ) : null;
967
1151
  if (isMobile) {
968
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_design_system5.TooltipProvider, { delayDuration: 300, titleTooltips: false, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: (0, import_design_system5.cn)("flex h-full min-h-0 flex-col", className), children: selected ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
969
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "flex h-12 shrink-0 items-center border-b border-border px-1", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
1152
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_design_system6.TooltipProvider, { delayDuration: 300, titleTooltips: false, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: (0, import_design_system6.cn)("flex h-full min-h-0 flex-col", className), children: detail ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
1153
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "flex h-12 shrink-0 items-center border-b border-border px-1", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
970
1154
  "button",
971
1155
  {
972
1156
  type: "button",
973
1157
  onClick: () => select(null),
974
1158
  className: "inline-flex h-11 items-center gap-1 rounded-md px-2 text-sm text-muted-foreground hover:text-foreground",
975
1159
  children: [
976
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ChevronLeftIcon, { className: "h-4 w-4" }),
1160
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ChevronLeftIcon, { className: "h-4 w-4" }),
977
1161
  "Back"
978
1162
  ]
979
1163
  }
980
1164
  ) }),
981
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "min-h-0 flex-1 overflow-y-auto", children: detail })
982
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
1165
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "min-h-0 flex-1 overflow-y-auto", children: detail })
1166
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
983
1167
  search,
984
1168
  table
985
1169
  ] }) }) });
986
1170
  }
987
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_design_system5.TooltipProvider, { delayDuration: 300, titleTooltips: false, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: (0, import_design_system5.cn)("flex h-full min-h-0", className), children: [
988
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("aside", { className: "flex w-[22rem] shrink-0 flex-col border-r border-border", children: [
1171
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_design_system6.TooltipProvider, { delayDuration: 300, titleTooltips: false, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: (0, import_design_system6.cn)("flex h-full min-h-0", className), children: [
1172
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("aside", { className: "flex w-[22rem] shrink-0 flex-col border-r border-border", children: [
989
1173
  search,
990
1174
  table
991
1175
  ] }),
992
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("section", { className: "min-h-0 min-w-0 flex-1 overflow-y-auto", children: detail ?? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "flex h-full items-center justify-center text-xs text-muted-foreground", children: "Select an item" }) })
1176
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("section", { className: "min-h-0 min-w-0 flex-1 overflow-y-auto", children: detail ?? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "flex h-full items-center justify-center text-xs text-muted-foreground", children: "Select an item" }) })
993
1177
  ] }) });
994
1178
  }
995
1179
  //# sourceMappingURL=index.cjs.map