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