@ai-matrx/agents 0.25.3 → 0.25.4

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.
@@ -50,6 +50,15 @@ interface ContextRuleResult {
50
50
  };
51
51
  clamped: boolean;
52
52
  }
53
+ /** Text the model actually read for one value (receipt `delivered` / `on_request`). */
54
+ interface ContextDeliveredText {
55
+ /** Cut at the receipt's cap; `chars` is the whole length. */
56
+ text: string;
57
+ chars: number;
58
+ truncated: boolean;
59
+ /** SHA-256 hex of the whole text (UTF-8). */
60
+ sha256: string;
61
+ }
53
62
  type ContextRowOrigin = "page" | "attached" | "system";
54
63
  /** Why the server kept a value from the model on this turn (receipt `blocked_by`). */
55
64
  type ContextBlockedBy = "model" | "self_check";
@@ -67,6 +76,13 @@ interface ResolvedContextRow extends Omit<ContextRuleResult, "delivery"> {
67
76
  fromReceipt?: boolean;
68
77
  /** From a receipt: why the server kept this value from the model this turn. */
69
78
  blockedBy?: ContextBlockedBy;
79
+ /**
80
+ * Display-only, from a receipt: what the model read for this value. When set,
81
+ * a detail view shows THIS — never `value`, the client's pre-send copy.
82
+ */
83
+ delivered?: ContextDeliveredText;
84
+ /** Display-only, from a receipt: what the `context` tool returns for it. */
85
+ onRequest?: ContextDeliveredText;
70
86
  key: string;
71
87
  label: string;
72
88
  surfaceKey: string;
@@ -201,4 +217,16 @@ interface InlineMaxInputProps {
201
217
  */
202
218
  declare function InlineMaxInput({ value, inherited, cap, onCommit, disabled, label, comfortable, placeholder, }: InlineMaxInputProps): react.JSX.Element;
203
219
 
204
- export { ContextRulesChip, type ContextRulesChipProps, type ContextRulesDensity, ContextRulesPanelBody, type ContextRulesPanelBodyProps, ContextRulesTable, type ContextRulesTableProps, InlineMaxInput, type InlineMaxInputProps, summarizeContextRows };
220
+ /**
221
+ * What the model READ for one value — the receipt's `delivered` (its own
222
+ * element in the rendered context block) and, for an on-request value, what
223
+ * the `context` tool returns (`on_request`). Verbatim; never the client's copy.
224
+ * Renders nothing when the receipt carries neither (the host may then show
225
+ * the value the page will send, labelled so). RULES.md §5.
226
+ */
227
+ declare function ContextDeliveredValue({ row, className, }: {
228
+ row: Pick<ResolvedContextRow, "delivered" | "onRequest">;
229
+ className?: string;
230
+ }): react.JSX.Element | null;
231
+
232
+ export { ContextDeliveredValue, ContextRulesChip, type ContextRulesChipProps, type ContextRulesDensity, ContextRulesPanelBody, type ContextRulesPanelBodyProps, ContextRulesTable, type ContextRulesTableProps, InlineMaxInput, type InlineMaxInputProps, summarizeContextRows };
@@ -728,9 +728,45 @@ import {
728
728
  Input as Input2,
729
729
  Switch as Switch3,
730
730
  TooltipProvider as TooltipProvider3,
731
- cn as cn4
731
+ cn as cn5
732
732
  } from "@ai-matrx/design-system";
733
- import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
733
+
734
+ // context/react/ContextDeliveredValue.tsx
735
+ import { cn as cn4 } from "@ai-matrx/design-system";
736
+ import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
737
+ function ContextDeliveredValue({
738
+ row,
739
+ className
740
+ }) {
741
+ if (!row.delivered && !row.onRequest) return null;
742
+ return /* @__PURE__ */ jsxs5("div", { className: cn4("flex flex-col gap-3", className), children: [
743
+ row.delivered ? /* @__PURE__ */ jsx5(DeliveredBlock, { title: "Agent received", text: row.delivered }) : null,
744
+ row.onRequest ? /* @__PURE__ */ jsx5(DeliveredBlock, { title: "Returned on request", text: row.onRequest }) : null
745
+ ] });
746
+ }
747
+ function DeliveredBlock({ title, text }) {
748
+ return /* @__PURE__ */ jsxs5("section", { className: "flex flex-col gap-1", "aria-label": title, children: [
749
+ /* @__PURE__ */ jsxs5("div", { className: "flex items-baseline gap-2 text-xs", children: [
750
+ /* @__PURE__ */ jsx5("span", { className: "font-medium", children: title }),
751
+ text.truncated ? /* @__PURE__ */ jsx5("span", { className: "tabular-nums text-muted-foreground", children: `First ${text.text.length.toLocaleString()} of ${text.chars.toLocaleString()} chars` }) : null
752
+ ] }),
753
+ /* @__PURE__ */ jsx5(
754
+ "pre",
755
+ {
756
+ "data-testid": "context-delivered-text",
757
+ className: cn4(
758
+ "max-h-[min(50dvh,22rem)] cursor-text select-text overflow-auto",
759
+ "whitespace-pre-wrap break-words rounded border border-border",
760
+ "bg-muted/40 p-2 font-mono text-[11px] text-foreground"
761
+ ),
762
+ children: text.text
763
+ }
764
+ )
765
+ ] });
766
+ }
767
+
768
+ // context/react/ContextRulesPanelBody.tsx
769
+ import { Fragment as Fragment2, jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
734
770
  function layerCells(row) {
735
771
  const { surface, agent, default_max } = row.layers ?? {};
736
772
  const declared = agent?.declared === true;
@@ -753,38 +789,38 @@ function layerCells(row) {
753
789
  var LAYERS = ["default", "page", "agent", "you"];
754
790
  function LayerTable({ row }) {
755
791
  const cells = layerCells(row);
756
- const cell = (text, winning) => /* @__PURE__ */ jsx5(
792
+ const cell = (text, winning) => /* @__PURE__ */ jsx6(
757
793
  "span",
758
794
  {
759
795
  role: "cell",
760
796
  "data-winning": winning ? "true" : void 0,
761
- className: cn4(
797
+ className: cn5(
762
798
  "rounded px-1.5 py-0.5 text-right tabular-nums",
763
799
  winning ? "bg-primary/10 font-medium text-foreground" : "text-muted-foreground"
764
800
  ),
765
801
  children: text
766
802
  }
767
803
  );
768
- return /* @__PURE__ */ jsxs5("div", { role: "table", "aria-label": "Layers", className: "text-xs", children: [
769
- /* @__PURE__ */ jsxs5(
804
+ return /* @__PURE__ */ jsxs6("div", { role: "table", "aria-label": "Layers", className: "text-xs", children: [
805
+ /* @__PURE__ */ jsxs6(
770
806
  "div",
771
807
  {
772
808
  role: "row",
773
809
  className: "grid h-7 grid-cols-[1fr_5rem_5rem] items-center gap-x-2 border-b border-border font-medium text-muted-foreground",
774
810
  children: [
775
- /* @__PURE__ */ jsx5("span", { role: "columnheader", children: "Layer" }),
776
- /* @__PURE__ */ jsx5("span", { role: "columnheader", className: "text-right", children: "Include" }),
777
- /* @__PURE__ */ jsx5("span", { role: "columnheader", className: "text-right", children: "Inline max" })
811
+ /* @__PURE__ */ jsx6("span", { role: "columnheader", children: "Layer" }),
812
+ /* @__PURE__ */ jsx6("span", { role: "columnheader", className: "text-right", children: "Include" }),
813
+ /* @__PURE__ */ jsx6("span", { role: "columnheader", className: "text-right", children: "Inline max" })
778
814
  ]
779
815
  }
780
816
  ),
781
- LAYERS.map((layer) => /* @__PURE__ */ jsxs5(
817
+ LAYERS.map((layer) => /* @__PURE__ */ jsxs6(
782
818
  "div",
783
819
  {
784
820
  role: "row",
785
821
  className: "grid h-7 grid-cols-[1fr_5rem_5rem] items-center gap-x-2 border-b border-border/50",
786
822
  children: [
787
- /* @__PURE__ */ jsx5("span", { role: "cell", children: LAYER_LABEL[layer] }),
823
+ /* @__PURE__ */ jsx6("span", { role: "cell", children: LAYER_LABEL[layer] }),
788
824
  cell(cells[layer].include, row.decided_by.include === layer),
789
825
  cell(cells[layer].limit, row.decided_by.max_inline_chars === layer)
790
826
  ]
@@ -802,18 +838,18 @@ function RowDetail({
802
838
  renderDetail,
803
839
  comfortable
804
840
  }) {
805
- return /* @__PURE__ */ jsxs5("div", { className: "flex flex-col gap-3 p-3", children: [
806
- /* @__PURE__ */ jsxs5("div", { className: "flex min-w-0 items-baseline gap-2", children: [
807
- /* @__PURE__ */ jsx5("h3", { className: "min-w-0 truncate text-sm font-medium", children: row.label }),
808
- /* @__PURE__ */ jsx5("span", { className: "shrink-0 text-xs tabular-nums text-muted-foreground", children: `${formatChars(row.chars)} chars \xB7 ${DELIVERY_LABEL[row.delivery]}` })
841
+ return /* @__PURE__ */ jsxs6("div", { className: "flex flex-col gap-3 p-3", children: [
842
+ /* @__PURE__ */ jsxs6("div", { className: "flex min-w-0 items-baseline gap-2", children: [
843
+ /* @__PURE__ */ jsx6("h3", { className: "min-w-0 truncate text-sm font-medium", children: row.label }),
844
+ /* @__PURE__ */ jsx6("span", { className: "shrink-0 text-xs tabular-nums text-muted-foreground", children: `${formatChars(row.chars)} chars \xB7 ${DELIVERY_LABEL[row.delivery]}` })
809
845
  ] }),
810
- mismatches.length > 0 ? /* @__PURE__ */ jsxs5("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: [
811
- /* @__PURE__ */ jsx5(TriangleAlertIcon, { className: "mt-0.5 h-3.5 w-3.5 shrink-0" }),
812
- /* @__PURE__ */ jsx5("span", { children: describeMismatches(mismatches) })
846
+ 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: [
847
+ /* @__PURE__ */ jsx6(TriangleAlertIcon, { className: "mt-0.5 h-3.5 w-3.5 shrink-0" }),
848
+ /* @__PURE__ */ jsx6("span", { children: describeMismatches(mismatches) })
813
849
  ] }) : null,
814
- /* @__PURE__ */ jsxs5("div", { className: "grid grid-cols-[auto_1fr] items-center gap-x-4 gap-y-2 text-xs", children: [
815
- /* @__PURE__ */ jsx5("span", { className: "text-muted-foreground", children: "Include" }),
816
- /* @__PURE__ */ jsx5("div", { className: cn4("flex items-center", comfortable ? "h-11" : "h-7"), children: /* @__PURE__ */ jsx5(
850
+ /* @__PURE__ */ jsxs6("div", { className: "grid grid-cols-[auto_1fr] items-center gap-x-4 gap-y-2 text-xs", children: [
851
+ /* @__PURE__ */ jsx6("span", { className: "text-muted-foreground", children: "Include" }),
852
+ /* @__PURE__ */ jsx6("div", { className: cn5("flex items-center", comfortable ? "h-11" : "h-7"), children: /* @__PURE__ */ jsx6(
817
853
  Switch3,
818
854
  {
819
855
  size: "sm",
@@ -823,8 +859,8 @@ function RowDetail({
823
859
  onCheckedChange: (next) => onChange(row.key, row.surfaceKey, withInclude(row, next))
824
860
  }
825
861
  ) }),
826
- /* @__PURE__ */ jsx5("span", { className: "text-muted-foreground", children: "Inline max" }),
827
- /* @__PURE__ */ jsx5("div", { className: "flex", children: /* @__PURE__ */ jsx5(
862
+ /* @__PURE__ */ jsx6("span", { className: "text-muted-foreground", children: "Inline max" }),
863
+ /* @__PURE__ */ jsx6("div", { className: "flex", children: /* @__PURE__ */ jsx6(
828
864
  InlineMaxInput,
829
865
  {
830
866
  label: row.label,
@@ -838,7 +874,8 @@ function RowDetail({
838
874
  }
839
875
  ) })
840
876
  ] }),
841
- /* @__PURE__ */ jsx5(LayerTable, { row }),
877
+ /* @__PURE__ */ jsx6(LayerTable, { row }),
878
+ /* @__PURE__ */ jsx6(ContextDeliveredValue, { row }),
842
879
  renderDetail ? renderDetail(row) : null
843
880
  ] });
844
881
  }
@@ -865,9 +902,9 @@ function ContextRulesPanelBody({
865
902
  const visible = q ? rows.filter((r) => r.label.toLowerCase().includes(q) || r.key.toLowerCase().includes(q)) : rows;
866
903
  const selected = selectedKey ? rows.find((r) => r.key === selectedKey) ?? null : null;
867
904
  const comfortable = !!isMobile;
868
- const search = /* @__PURE__ */ jsxs5("div", { className: "relative shrink-0 border-b border-border p-2", children: [
869
- /* @__PURE__ */ jsx5(SearchIcon, { className: "pointer-events-none absolute left-4 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground" }),
870
- /* @__PURE__ */ jsx5(
905
+ const search = /* @__PURE__ */ jsxs6("div", { className: "relative shrink-0 border-b border-border p-2", children: [
906
+ /* @__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" }),
907
+ /* @__PURE__ */ jsx6(
871
908
  Input2,
872
909
  {
873
910
  type: "search",
@@ -875,11 +912,11 @@ function ContextRulesPanelBody({
875
912
  placeholder: "Search",
876
913
  value: query,
877
914
  onChange: (e) => setQuery(e.target.value),
878
- className: cn4("pl-7 shadow-none", comfortable ? "h-11 text-base" : "h-8 text-xs")
915
+ className: cn5("pl-7 shadow-none", comfortable ? "h-11 text-base" : "h-8 text-xs")
879
916
  }
880
917
  )
881
918
  ] });
882
- const table = /* @__PURE__ */ jsx5("div", { className: "min-h-0 flex-1 overflow-y-auto", children: /* @__PURE__ */ jsx5(
919
+ const table = /* @__PURE__ */ jsx6("div", { className: "min-h-0 flex-1 overflow-y-auto", children: /* @__PURE__ */ jsx6(
883
920
  ContextRulesTable,
884
921
  {
885
922
  rows: visible,
@@ -892,7 +929,7 @@ function ContextRulesPanelBody({
892
929
  ...mismatches ? { mismatches } : {}
893
930
  }
894
931
  ) });
895
- const detail = selected ? /* @__PURE__ */ jsx5(
932
+ const detail = selected ? /* @__PURE__ */ jsx6(
896
933
  RowDetail,
897
934
  {
898
935
  row: selected,
@@ -905,34 +942,35 @@ function ContextRulesPanelBody({
905
942
  }
906
943
  ) : null;
907
944
  if (isMobile) {
908
- return /* @__PURE__ */ jsx5(TooltipProvider3, { delayDuration: 300, titleTooltips: false, children: /* @__PURE__ */ jsx5("div", { className: cn4("flex h-full min-h-0 flex-col", className), children: selected ? /* @__PURE__ */ jsxs5(Fragment2, { children: [
909
- /* @__PURE__ */ jsx5("div", { className: "flex h-12 shrink-0 items-center border-b border-border px-1", children: /* @__PURE__ */ jsxs5(
945
+ 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: [
946
+ /* @__PURE__ */ jsx6("div", { className: "flex h-12 shrink-0 items-center border-b border-border px-1", children: /* @__PURE__ */ jsxs6(
910
947
  "button",
911
948
  {
912
949
  type: "button",
913
950
  onClick: () => select(null),
914
951
  className: "inline-flex h-11 items-center gap-1 rounded-md px-2 text-sm text-muted-foreground hover:text-foreground",
915
952
  children: [
916
- /* @__PURE__ */ jsx5(ChevronLeftIcon, { className: "h-4 w-4" }),
953
+ /* @__PURE__ */ jsx6(ChevronLeftIcon, { className: "h-4 w-4" }),
917
954
  "Back"
918
955
  ]
919
956
  }
920
957
  ) }),
921
- /* @__PURE__ */ jsx5("div", { className: "min-h-0 flex-1 overflow-y-auto", children: detail })
922
- ] }) : /* @__PURE__ */ jsxs5(Fragment2, { children: [
958
+ /* @__PURE__ */ jsx6("div", { className: "min-h-0 flex-1 overflow-y-auto", children: detail })
959
+ ] }) : /* @__PURE__ */ jsxs6(Fragment2, { children: [
923
960
  search,
924
961
  table
925
962
  ] }) }) });
926
963
  }
927
- return /* @__PURE__ */ jsx5(TooltipProvider3, { delayDuration: 300, titleTooltips: false, children: /* @__PURE__ */ jsxs5("div", { className: cn4("flex h-full min-h-0", className), children: [
928
- /* @__PURE__ */ jsxs5("aside", { className: "flex w-[22rem] shrink-0 flex-col border-r border-border", children: [
964
+ return /* @__PURE__ */ jsx6(TooltipProvider3, { delayDuration: 300, titleTooltips: false, children: /* @__PURE__ */ jsxs6("div", { className: cn5("flex h-full min-h-0", className), children: [
965
+ /* @__PURE__ */ jsxs6("aside", { className: "flex w-[22rem] shrink-0 flex-col border-r border-border", children: [
929
966
  search,
930
967
  table
931
968
  ] }),
932
- /* @__PURE__ */ jsx5("section", { className: "min-h-0 min-w-0 flex-1 overflow-y-auto", children: detail ?? /* @__PURE__ */ jsx5("div", { className: "flex h-full items-center justify-center text-xs text-muted-foreground", children: "Select an item" }) })
969
+ /* @__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" }) })
933
970
  ] }) });
934
971
  }
935
972
  export {
973
+ ContextDeliveredValue,
936
974
  ContextRulesChip,
937
975
  ContextRulesPanelBody,
938
976
  ContextRulesTable,