@ai-matrx/agents 0.25.3 → 0.27.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 (38) hide show
  1. package/CHANGELOG.md +16 -3
  2. package/dist/content-transfer/index.cjs.map +1 -1
  3. package/dist/content-transfer/index.js.map +1 -1
  4. package/dist/content-transfer/react/index.cjs.map +1 -1
  5. package/dist/content-transfer/react/index.js.map +1 -1
  6. package/dist/context/index.cjs +47 -3
  7. package/dist/context/index.cjs.map +1 -1
  8. package/dist/context/index.d.cts +79 -1
  9. package/dist/context/index.d.ts +79 -1
  10. package/dist/context/index.js +45 -3
  11. package/dist/context/index.js.map +1 -1
  12. package/dist/context/react/index.cjs +77 -38
  13. package/dist/context/react/index.cjs.map +1 -1
  14. package/dist/context/react/index.d.cts +31 -1
  15. package/dist/context/react/index.d.ts +31 -1
  16. package/dist/context/react/index.js +77 -38
  17. package/dist/context/react/index.js.map +1 -1
  18. package/dist/index.cjs +26 -0
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.cts +1 -1
  21. package/dist/index.d.ts +1 -1
  22. package/dist/index.js +26 -0
  23. package/dist/index.js.map +1 -1
  24. package/dist/mandates/index.cjs +2 -2
  25. package/dist/mandates/index.cjs.map +1 -1
  26. package/dist/mandates/index.d.cts +4 -4
  27. package/dist/mandates/index.d.ts +4 -4
  28. package/dist/mandates/index.js +2 -2
  29. package/dist/mandates/index.js.map +1 -1
  30. package/dist/matrx/index.cjs +26 -0
  31. package/dist/matrx/index.cjs.map +1 -1
  32. package/dist/matrx/index.d.cts +17 -1
  33. package/dist/matrx/index.d.ts +17 -1
  34. package/dist/matrx/index.js +26 -0
  35. package/dist/matrx/index.js.map +1 -1
  36. package/mandates/snapshots/keys.0.25.4.json +652 -0
  37. package/mandates/snapshots/keys.0.27.0.json +652 -0
  38. package/package.json +1 -1
@@ -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,15 @@ 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;
86
+ /** Display-only, from a receipt: the server's own statement of it, also read. */
87
+ serverRendered?: ContextDeliveredText;
70
88
  key: string;
71
89
  label: string;
72
90
  surfaceKey: string;
@@ -201,4 +219,16 @@ interface InlineMaxInputProps {
201
219
  */
202
220
  declare function InlineMaxInput({ value, inherited, cap, onCommit, disabled, label, comfortable, placeholder, }: InlineMaxInputProps): react.JSX.Element;
203
221
 
204
- export { ContextRulesChip, type ContextRulesChipProps, type ContextRulesDensity, ContextRulesPanelBody, type ContextRulesPanelBodyProps, ContextRulesTable, type ContextRulesTableProps, InlineMaxInput, type InlineMaxInputProps, summarizeContextRows };
222
+ /**
223
+ * What the model READ for one value — the receipt's `delivered` (its own
224
+ * element in the rendered context block) and, for an on-request value, what
225
+ * the `context` tool returns (`on_request`). Verbatim; never the client's copy.
226
+ * Renders nothing when the receipt carries neither (the host may then show
227
+ * the value the page will send, labelled so). RULES.md §5.
228
+ */
229
+ declare function ContextDeliveredValue({ row, className, }: {
230
+ row: Pick<ResolvedContextRow, "delivered" | "onRequest" | "serverRendered">;
231
+ className?: string;
232
+ }): react.JSX.Element | null;
233
+
234
+ export { ContextDeliveredValue, ContextRulesChip, type ContextRulesChipProps, type ContextRulesDensity, ContextRulesPanelBody, type ContextRulesPanelBodyProps, ContextRulesTable, type ContextRulesTableProps, InlineMaxInput, type InlineMaxInputProps, summarizeContextRows };
@@ -728,9 +728,46 @@ 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 && !row.serverRendered) 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
+ row.serverRendered ? /* @__PURE__ */ jsx5(DeliveredBlock, { title: "Agent also received", text: row.serverRendered }) : null
746
+ ] });
747
+ }
748
+ function DeliveredBlock({ title, text }) {
749
+ return /* @__PURE__ */ jsxs5("section", { className: "flex flex-col gap-1", "aria-label": title, children: [
750
+ /* @__PURE__ */ jsxs5("div", { className: "flex items-baseline gap-2 text-xs", children: [
751
+ /* @__PURE__ */ jsx5("span", { className: "font-medium", children: title }),
752
+ text.truncated ? /* @__PURE__ */ jsx5("span", { className: "tabular-nums text-muted-foreground", children: `First ${text.text.length.toLocaleString()} of ${text.chars.toLocaleString()} chars` }) : null
753
+ ] }),
754
+ /* @__PURE__ */ jsx5(
755
+ "pre",
756
+ {
757
+ "data-testid": "context-delivered-text",
758
+ className: cn4(
759
+ "max-h-[min(50dvh,22rem)] cursor-text select-text overflow-auto",
760
+ "whitespace-pre-wrap break-words rounded border border-border",
761
+ "bg-muted/40 p-2 font-mono text-[11px] text-foreground"
762
+ ),
763
+ children: text.text
764
+ }
765
+ )
766
+ ] });
767
+ }
768
+
769
+ // context/react/ContextRulesPanelBody.tsx
770
+ import { Fragment as Fragment2, jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
734
771
  function layerCells(row) {
735
772
  const { surface, agent, default_max } = row.layers ?? {};
736
773
  const declared = agent?.declared === true;
@@ -753,38 +790,38 @@ function layerCells(row) {
753
790
  var LAYERS = ["default", "page", "agent", "you"];
754
791
  function LayerTable({ row }) {
755
792
  const cells = layerCells(row);
756
- const cell = (text, winning) => /* @__PURE__ */ jsx5(
793
+ const cell = (text, winning) => /* @__PURE__ */ jsx6(
757
794
  "span",
758
795
  {
759
796
  role: "cell",
760
797
  "data-winning": winning ? "true" : void 0,
761
- className: cn4(
798
+ className: cn5(
762
799
  "rounded px-1.5 py-0.5 text-right tabular-nums",
763
800
  winning ? "bg-primary/10 font-medium text-foreground" : "text-muted-foreground"
764
801
  ),
765
802
  children: text
766
803
  }
767
804
  );
768
- return /* @__PURE__ */ jsxs5("div", { role: "table", "aria-label": "Layers", className: "text-xs", children: [
769
- /* @__PURE__ */ jsxs5(
805
+ return /* @__PURE__ */ jsxs6("div", { role: "table", "aria-label": "Layers", className: "text-xs", children: [
806
+ /* @__PURE__ */ jsxs6(
770
807
  "div",
771
808
  {
772
809
  role: "row",
773
810
  className: "grid h-7 grid-cols-[1fr_5rem_5rem] items-center gap-x-2 border-b border-border font-medium text-muted-foreground",
774
811
  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" })
812
+ /* @__PURE__ */ jsx6("span", { role: "columnheader", children: "Layer" }),
813
+ /* @__PURE__ */ jsx6("span", { role: "columnheader", className: "text-right", children: "Include" }),
814
+ /* @__PURE__ */ jsx6("span", { role: "columnheader", className: "text-right", children: "Inline max" })
778
815
  ]
779
816
  }
780
817
  ),
781
- LAYERS.map((layer) => /* @__PURE__ */ jsxs5(
818
+ LAYERS.map((layer) => /* @__PURE__ */ jsxs6(
782
819
  "div",
783
820
  {
784
821
  role: "row",
785
822
  className: "grid h-7 grid-cols-[1fr_5rem_5rem] items-center gap-x-2 border-b border-border/50",
786
823
  children: [
787
- /* @__PURE__ */ jsx5("span", { role: "cell", children: LAYER_LABEL[layer] }),
824
+ /* @__PURE__ */ jsx6("span", { role: "cell", children: LAYER_LABEL[layer] }),
788
825
  cell(cells[layer].include, row.decided_by.include === layer),
789
826
  cell(cells[layer].limit, row.decided_by.max_inline_chars === layer)
790
827
  ]
@@ -802,18 +839,18 @@ function RowDetail({
802
839
  renderDetail,
803
840
  comfortable
804
841
  }) {
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]}` })
842
+ return /* @__PURE__ */ jsxs6("div", { className: "flex flex-col gap-3 p-3", children: [
843
+ /* @__PURE__ */ jsxs6("div", { className: "flex min-w-0 items-baseline gap-2", children: [
844
+ /* @__PURE__ */ jsx6("h3", { className: "min-w-0 truncate text-sm font-medium", children: row.label }),
845
+ /* @__PURE__ */ jsx6("span", { className: "shrink-0 text-xs tabular-nums text-muted-foreground", children: `${formatChars(row.chars)} chars \xB7 ${DELIVERY_LABEL[row.delivery]}` })
809
846
  ] }),
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) })
847
+ 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: [
848
+ /* @__PURE__ */ jsx6(TriangleAlertIcon, { className: "mt-0.5 h-3.5 w-3.5 shrink-0" }),
849
+ /* @__PURE__ */ jsx6("span", { children: describeMismatches(mismatches) })
813
850
  ] }) : 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(
851
+ /* @__PURE__ */ jsxs6("div", { className: "grid grid-cols-[auto_1fr] items-center gap-x-4 gap-y-2 text-xs", children: [
852
+ /* @__PURE__ */ jsx6("span", { className: "text-muted-foreground", children: "Include" }),
853
+ /* @__PURE__ */ jsx6("div", { className: cn5("flex items-center", comfortable ? "h-11" : "h-7"), children: /* @__PURE__ */ jsx6(
817
854
  Switch3,
818
855
  {
819
856
  size: "sm",
@@ -823,8 +860,8 @@ function RowDetail({
823
860
  onCheckedChange: (next) => onChange(row.key, row.surfaceKey, withInclude(row, next))
824
861
  }
825
862
  ) }),
826
- /* @__PURE__ */ jsx5("span", { className: "text-muted-foreground", children: "Inline max" }),
827
- /* @__PURE__ */ jsx5("div", { className: "flex", children: /* @__PURE__ */ jsx5(
863
+ /* @__PURE__ */ jsx6("span", { className: "text-muted-foreground", children: "Inline max" }),
864
+ /* @__PURE__ */ jsx6("div", { className: "flex", children: /* @__PURE__ */ jsx6(
828
865
  InlineMaxInput,
829
866
  {
830
867
  label: row.label,
@@ -838,7 +875,8 @@ function RowDetail({
838
875
  }
839
876
  ) })
840
877
  ] }),
841
- /* @__PURE__ */ jsx5(LayerTable, { row }),
878
+ /* @__PURE__ */ jsx6(LayerTable, { row }),
879
+ /* @__PURE__ */ jsx6(ContextDeliveredValue, { row }),
842
880
  renderDetail ? renderDetail(row) : null
843
881
  ] });
844
882
  }
@@ -865,9 +903,9 @@ function ContextRulesPanelBody({
865
903
  const visible = q ? rows.filter((r) => r.label.toLowerCase().includes(q) || r.key.toLowerCase().includes(q)) : rows;
866
904
  const selected = selectedKey ? rows.find((r) => r.key === selectedKey) ?? null : null;
867
905
  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(
906
+ const search = /* @__PURE__ */ jsxs6("div", { className: "relative shrink-0 border-b border-border p-2", children: [
907
+ /* @__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" }),
908
+ /* @__PURE__ */ jsx6(
871
909
  Input2,
872
910
  {
873
911
  type: "search",
@@ -875,11 +913,11 @@ function ContextRulesPanelBody({
875
913
  placeholder: "Search",
876
914
  value: query,
877
915
  onChange: (e) => setQuery(e.target.value),
878
- className: cn4("pl-7 shadow-none", comfortable ? "h-11 text-base" : "h-8 text-xs")
916
+ className: cn5("pl-7 shadow-none", comfortable ? "h-11 text-base" : "h-8 text-xs")
879
917
  }
880
918
  )
881
919
  ] });
882
- const table = /* @__PURE__ */ jsx5("div", { className: "min-h-0 flex-1 overflow-y-auto", children: /* @__PURE__ */ jsx5(
920
+ const table = /* @__PURE__ */ jsx6("div", { className: "min-h-0 flex-1 overflow-y-auto", children: /* @__PURE__ */ jsx6(
883
921
  ContextRulesTable,
884
922
  {
885
923
  rows: visible,
@@ -892,7 +930,7 @@ function ContextRulesPanelBody({
892
930
  ...mismatches ? { mismatches } : {}
893
931
  }
894
932
  ) });
895
- const detail = selected ? /* @__PURE__ */ jsx5(
933
+ const detail = selected ? /* @__PURE__ */ jsx6(
896
934
  RowDetail,
897
935
  {
898
936
  row: selected,
@@ -905,34 +943,35 @@ function ContextRulesPanelBody({
905
943
  }
906
944
  ) : null;
907
945
  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(
946
+ 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: [
947
+ /* @__PURE__ */ jsx6("div", { className: "flex h-12 shrink-0 items-center border-b border-border px-1", children: /* @__PURE__ */ jsxs6(
910
948
  "button",
911
949
  {
912
950
  type: "button",
913
951
  onClick: () => select(null),
914
952
  className: "inline-flex h-11 items-center gap-1 rounded-md px-2 text-sm text-muted-foreground hover:text-foreground",
915
953
  children: [
916
- /* @__PURE__ */ jsx5(ChevronLeftIcon, { className: "h-4 w-4" }),
954
+ /* @__PURE__ */ jsx6(ChevronLeftIcon, { className: "h-4 w-4" }),
917
955
  "Back"
918
956
  ]
919
957
  }
920
958
  ) }),
921
- /* @__PURE__ */ jsx5("div", { className: "min-h-0 flex-1 overflow-y-auto", children: detail })
922
- ] }) : /* @__PURE__ */ jsxs5(Fragment2, { children: [
959
+ /* @__PURE__ */ jsx6("div", { className: "min-h-0 flex-1 overflow-y-auto", children: detail })
960
+ ] }) : /* @__PURE__ */ jsxs6(Fragment2, { children: [
923
961
  search,
924
962
  table
925
963
  ] }) }) });
926
964
  }
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: [
965
+ return /* @__PURE__ */ jsx6(TooltipProvider3, { delayDuration: 300, titleTooltips: false, children: /* @__PURE__ */ jsxs6("div", { className: cn5("flex h-full min-h-0", className), children: [
966
+ /* @__PURE__ */ jsxs6("aside", { className: "flex w-[22rem] shrink-0 flex-col border-r border-border", children: [
929
967
  search,
930
968
  table
931
969
  ] }),
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" }) })
970
+ /* @__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
971
  ] }) });
934
972
  }
935
973
  export {
974
+ ContextDeliveredValue,
936
975
  ContextRulesChip,
937
976
  ContextRulesPanelBody,
938
977
  ContextRulesTable,