@ai-matrx/agents 0.40.0 → 0.41.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.
@@ -1,19 +1,5 @@
1
1
  import * as react from 'react';
2
2
 
3
- /**
4
- * @ai-matrx/agents/context — the context value rules, headless.
5
- *
6
- * Contract: common-docs/systems/scopes-context/context-delivery/RULES.md.
7
- * Parity corpus: ./rules-corpus.json (run here by rules.test.ts and by aidream's
8
- * pytest against the Python twin `resolve_context_rule`). Every function here
9
- * is pure, zero-React, and safe to import on a server.
10
- *
11
- * The one flow a client runs per turn:
12
- * rows = values.map(v => resolveContextRow(v, savedRows, cap)) // what the table shows
13
- * context = buildContextWire(rows) // what the request sends
14
- * …on `context_receipt`: compareReceipt(rows, receipt) // screen vs server
15
- */
16
-
17
3
  /** Which layer decided a field — lowest to highest. */
18
4
  type ContextLayer = "default" | "page" | "agent" | "you";
19
5
  type ContextDelivery = "inline" | "on_request" | "off";
@@ -128,7 +114,7 @@ type ContextViewLoader = (target: ContextViewTarget) => Promise<ContextViewedTex
128
114
  interface ContextReceiptBlock {
129
115
  /** Stable id: the per-turn slot it rode in, or the system-prompt addition's name. */
130
116
  id: string;
131
- /** The id in words (`humanizeContextKey`). */
117
+ /** The id in words (`humanizeIdentifier`, `@ai-matrx/kit/text-case`). */
132
118
  label: string;
133
119
  /** Size and hash; the text comes from the viewer (`kind: "block"`). */
134
120
  delivered: ContextDeliveredRef;
@@ -301,13 +287,20 @@ interface ContextRulesTableProps {
301
287
  * switch still shows).
302
288
  */
303
289
  onSetInclude?: ((changes: ContextRuleChange[]) => void) | undefined;
290
+ /**
291
+ * Host slots inside a row's Item cell, never a second renderer: `renderRowLead`
292
+ * before the label (a status mark), `renderRowTrail` after it (an admin's
293
+ * machine name). Each renders inline and truncates with the label.
294
+ */
295
+ renderRowLead?: ((row: ResolvedContextRow) => react.ReactNode) | undefined;
296
+ renderRowTrail?: ((row: ResolvedContextRow) => react.ReactNode) | undefined;
304
297
  className?: string;
305
298
  }
306
299
  /**
307
300
  * The context rules table: Item | Include | Chars | Inline max. Presentational
308
301
  * and state-agnostic — every edit goes out through `onChange`.
309
302
  */
310
- declare function ContextRulesTable({ rows, cap, readOnly, mismatches, onChange, onOpenRow, density, selectedKey, hierarchy, onSetInclude, className, }: ContextRulesTableProps): react.JSX.Element;
303
+ declare function ContextRulesTable({ rows, cap, readOnly, mismatches, onChange, onOpenRow, density, selectedKey, hierarchy, onSetInclude, renderRowLead, renderRowTrail, className, }: ContextRulesTableProps): react.JSX.Element;
311
304
 
312
305
  /**
313
306
  * The header's "N · chars" total. A row whose size is not known yet (an
@@ -1,19 +1,5 @@
1
1
  import * as react from 'react';
2
2
 
3
- /**
4
- * @ai-matrx/agents/context — the context value rules, headless.
5
- *
6
- * Contract: common-docs/systems/scopes-context/context-delivery/RULES.md.
7
- * Parity corpus: ./rules-corpus.json (run here by rules.test.ts and by aidream's
8
- * pytest against the Python twin `resolve_context_rule`). Every function here
9
- * is pure, zero-React, and safe to import on a server.
10
- *
11
- * The one flow a client runs per turn:
12
- * rows = values.map(v => resolveContextRow(v, savedRows, cap)) // what the table shows
13
- * context = buildContextWire(rows) // what the request sends
14
- * …on `context_receipt`: compareReceipt(rows, receipt) // screen vs server
15
- */
16
-
17
3
  /** Which layer decided a field — lowest to highest. */
18
4
  type ContextLayer = "default" | "page" | "agent" | "you";
19
5
  type ContextDelivery = "inline" | "on_request" | "off";
@@ -128,7 +114,7 @@ type ContextViewLoader = (target: ContextViewTarget) => Promise<ContextViewedTex
128
114
  interface ContextReceiptBlock {
129
115
  /** Stable id: the per-turn slot it rode in, or the system-prompt addition's name. */
130
116
  id: string;
131
- /** The id in words (`humanizeContextKey`). */
117
+ /** The id in words (`humanizeIdentifier`, `@ai-matrx/kit/text-case`). */
132
118
  label: string;
133
119
  /** Size and hash; the text comes from the viewer (`kind: "block"`). */
134
120
  delivered: ContextDeliveredRef;
@@ -301,13 +287,20 @@ interface ContextRulesTableProps {
301
287
  * switch still shows).
302
288
  */
303
289
  onSetInclude?: ((changes: ContextRuleChange[]) => void) | undefined;
290
+ /**
291
+ * Host slots inside a row's Item cell, never a second renderer: `renderRowLead`
292
+ * before the label (a status mark), `renderRowTrail` after it (an admin's
293
+ * machine name). Each renders inline and truncates with the label.
294
+ */
295
+ renderRowLead?: ((row: ResolvedContextRow) => react.ReactNode) | undefined;
296
+ renderRowTrail?: ((row: ResolvedContextRow) => react.ReactNode) | undefined;
304
297
  className?: string;
305
298
  }
306
299
  /**
307
300
  * The context rules table: Item | Include | Chars | Inline max. Presentational
308
301
  * and state-agnostic — every edit goes out through `onChange`.
309
302
  */
310
- declare function ContextRulesTable({ rows, cap, readOnly, mismatches, onChange, onOpenRow, density, selectedKey, hierarchy, onSetInclude, className, }: ContextRulesTableProps): react.JSX.Element;
303
+ declare function ContextRulesTable({ rows, cap, readOnly, mismatches, onChange, onOpenRow, density, selectedKey, hierarchy, onSetInclude, renderRowLead, renderRowTrail, className, }: ContextRulesTableProps): react.JSX.Element;
311
304
 
312
305
  /**
313
306
  * The header's "N · chars" total. A row whose size is not known yet (an
@@ -12,7 +12,6 @@ import {
12
12
  } from "@ai-matrx/design-system";
13
13
 
14
14
  // context/index.ts
15
- import { IDENTIFIER_ACRONYMS, humanizeIdentifier } from "@ai-matrx/kit/text-case";
16
15
  var DEFAULT_INLINE_MAX_CHARS = 200;
17
16
  var DEFAULT_INLINE_CAP = 5e4;
18
17
  var CONTEXT_ROW_BLOCKS = {
@@ -472,6 +471,8 @@ function ContextRulesTable({
472
471
  selectedKey,
473
472
  hierarchy,
474
473
  onSetInclude,
474
+ renderRowLead,
475
+ renderRowTrail,
475
476
  className
476
477
  }) {
477
478
  const comfortable = density === "comfortable";
@@ -489,7 +490,9 @@ function ContextRulesTable({
489
490
  mismatches: mismatches?.filter((m) => m.key === row.key) ?? [],
490
491
  onChange,
491
492
  onOpenRow,
492
- comfortable
493
+ comfortable,
494
+ lead: renderRowLead?.(row),
495
+ trail: renderRowTrail?.(row)
493
496
  },
494
497
  rowId(row)
495
498
  );
@@ -553,6 +556,60 @@ function levelSwitch(level, bulk) {
553
556
  if (level.master) return { checked: level.master.on, onToggle: level.master.onToggle };
554
557
  return { checked: levelRows(level).some((r) => r.include), onToggle: bulk };
555
558
  }
559
+ var useIsoLayoutEffect = typeof window === "undefined" ? React2.useEffect : React2.useLayoutEffect;
560
+ function HeadingPath({ path, name }) {
561
+ const boxRef = React2.useRef(null);
562
+ const fullRef = React2.useRef(null);
563
+ const [compact, setCompact] = React2.useState(false);
564
+ const multi = path.length > 1;
565
+ useIsoLayoutEffect(() => {
566
+ const box = boxRef.current;
567
+ const full = fullRef.current;
568
+ if (!multi || !box || !full) return void 0;
569
+ const fit = () => setCompact(full.scrollWidth > box.clientWidth);
570
+ fit();
571
+ if (typeof ResizeObserver === "undefined") return void 0;
572
+ const observer = new ResizeObserver(fit);
573
+ observer.observe(box);
574
+ return () => observer.disconnect();
575
+ }, [multi, name]);
576
+ const shown = multi && compact ? path.slice(-1) : path;
577
+ return /* @__PURE__ */ jsxs3(
578
+ "span",
579
+ {
580
+ ref: boxRef,
581
+ "data-compact": multi && compact ? "true" : void 0,
582
+ className: "relative flex min-w-0 flex-1 items-center gap-1 overflow-hidden",
583
+ title: name,
584
+ children: [
585
+ multi ? /* @__PURE__ */ jsx3(
586
+ "span",
587
+ {
588
+ ref: fullRef,
589
+ "aria-hidden": true,
590
+ className: "pointer-events-none invisible absolute left-0 top-0 flex items-center gap-1 whitespace-nowrap",
591
+ children: path.map((part, i) => /* @__PURE__ */ jsxs3(React2.Fragment, { children: [
592
+ i > 0 ? /* @__PURE__ */ jsx3("span", { children: "\u203A" }) : null,
593
+ /* @__PURE__ */ jsx3("span", { children: part })
594
+ ] }, `${i}:${part}`))
595
+ }
596
+ ) : null,
597
+ shown.map((part, i) => /* @__PURE__ */ jsxs3(React2.Fragment, { children: [
598
+ i > 0 ? /* @__PURE__ */ jsx3("span", { className: "shrink-0 text-muted-foreground", children: "\u203A" }) : null,
599
+ /* @__PURE__ */ jsx3(
600
+ "span",
601
+ {
602
+ className: cn2(
603
+ i < shown.length - 1 ? "shrink-0 whitespace-nowrap text-muted-foreground" : "min-w-0 truncate"
604
+ ),
605
+ children: part
606
+ }
607
+ )
608
+ ] }, `${i}:${part}`))
609
+ ]
610
+ }
611
+ );
612
+ }
556
613
  function LevelHeading({
557
614
  kind,
558
615
  path,
@@ -579,10 +636,7 @@ function LevelHeading({
579
636
  ),
580
637
  children: [
581
638
  /* @__PURE__ */ jsxs3("div", { role: "cell", className: cn2("flex min-w-0 items-center gap-1", kind === "group" && "pl-2"), children: [
582
- /* @__PURE__ */ jsx3("span", { className: "flex min-w-0 items-center gap-1 truncate", title: name, children: path.map((part, i) => /* @__PURE__ */ jsxs3(React2.Fragment, { children: [
583
- i > 0 ? /* @__PURE__ */ jsx3("span", { className: "shrink-0 text-muted-foreground", children: "\u203A" }) : null,
584
- /* @__PURE__ */ jsx3("span", { className: cn2("truncate", i < path.length - 1 && "text-muted-foreground"), children: part })
585
- ] }, `${i}:${part}`)) }),
639
+ /* @__PURE__ */ jsx3(HeadingPath, { path, name }),
586
640
  total > 0 ? /* @__PURE__ */ jsx3("span", { className: "shrink-0 font-normal tabular-nums text-muted-foreground", children: count === total ? total : `${count}/${total}` }) : null
587
641
  ] }),
588
642
  /* @__PURE__ */ jsx3("div", { role: "cell", className: "flex justify-center", children: showSwitch ? /* @__PURE__ */ jsx3(
@@ -611,7 +665,9 @@ function ContextRuleRow({
611
665
  selected,
612
666
  mismatches,
613
667
  onChange,
614
- onOpenRow
668
+ onOpenRow,
669
+ lead,
670
+ trail
615
671
  }) {
616
672
  const selfChecked = row.blockedBy === "self_check" || mismatches.some((m) => m.reason === "self_check");
617
673
  const decided = selfChecked ? SELF_CHECK_TOOLTIP : row.serverResolved ? SERVER_RESOLVED_TOOLTIP : `Include: ${LAYER_LABEL[row.decided_by.include]} \xB7 Limit: ${LAYER_LABEL[row.decided_by.max_inline_chars]}`;
@@ -664,13 +720,15 @@ function ContextRuleRow({
664
720
  ) }),
665
721
  /* @__PURE__ */ jsx3(TooltipContent2, { children: describeMismatches(mismatches) })
666
722
  ] }) : null,
723
+ lead ? /* @__PURE__ */ jsx3("span", { className: "inline-flex shrink-0 items-center", children: lead }) : null,
667
724
  /* @__PURE__ */ jsxs3(Tooltip2, { children: [
668
725
  /* @__PURE__ */ jsx3(TooltipTrigger2, { asChild: true, children: labelNode }),
669
726
  /* @__PURE__ */ jsxs3(TooltipContent2, { children: [
670
727
  /* @__PURE__ */ jsx3("div", { children: row.label }),
671
728
  /* @__PURE__ */ jsx3("div", { className: "font-normal text-muted-foreground", children: decided })
672
729
  ] })
673
- ] })
730
+ ] }),
731
+ trail ? /* @__PURE__ */ jsx3("span", { className: "min-w-0 max-w-[45%] shrink truncate text-muted-foreground", children: trail }) : null
674
732
  ]
675
733
  }
676
734
  ),