@40rty/ams-ui 0.3.0 → 0.3.2

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,4 +1,18 @@
1
1
  'use client';
2
+ import {
3
+ PRESENCE_FACT_LIMIT,
4
+ derivePresenceView,
5
+ factIdentity,
6
+ factRegister,
7
+ readLabel,
8
+ useBandFacts,
9
+ useDismissedLabels,
10
+ useForgetFact,
11
+ useUndismissedFacts,
12
+ useVisibleFacts,
13
+ viewHasHeld,
14
+ viewIsEmpty
15
+ } from "./chunk-TEPH476O.js";
2
16
  import {
3
17
  AnimatePresence,
4
18
  motion,
@@ -356,72 +370,6 @@ function Fallback() {
356
370
  return /* @__PURE__ */ jsx3("span", { className: presenceClass.fallback, children: FALLBACK });
357
371
  }
358
372
 
359
- // src/agent/presence/read-data.ts
360
- function factRegister(fact) {
361
- if (fact.provenance === "recalled") return "recalled";
362
- if (fact.provenance !== void 0) return "inferred";
363
- return fact.tier === "profile" ? "recalled" : "inferred";
364
- }
365
- function readFacts(frame) {
366
- const raw = frame.data === void 0 ? void 0 : Reflect.get(frame.data, "facts");
367
- if (!Array.isArray(raw)) return [];
368
- const out = [];
369
- for (const f of raw) {
370
- if (typeof f !== "object" || f === null) continue;
371
- const label = Reflect.get(f, "label");
372
- const value = Reflect.get(f, "value");
373
- if (typeof label !== "string" || typeof value !== "string") continue;
374
- const tier = Reflect.get(f, "tier");
375
- const scope = Reflect.get(f, "scope");
376
- out.push({
377
- label,
378
- value,
379
- ...tier === "session" || tier === "profile" ? { tier } : {},
380
- ...typeof scope === "string" && scope.length > 0 ? { scope } : {}
381
- });
382
- }
383
- return out;
384
- }
385
- function factIdentity(fact) {
386
- return `${fact.label}=${fact.value}`;
387
- }
388
- function readLabel(frame) {
389
- if (frame.data === void 0) return "";
390
- const l = Reflect.get(frame.data, "label");
391
- return typeof l === "string" ? l : "";
392
- }
393
-
394
- // src/agent/presence/use-forget-fact.ts
395
- import * as React3 from "react";
396
- import { useFourtySession, useOptimisticFlowSet, useReconcileFlowSet, PRESENCE_FACT_DISMISS_SIGNAL } from "@40rty/ams-sdk";
397
- var DISMISSED_FLOW = "presence.dismissed";
398
- function useVisibleFacts(frame) {
399
- return useVisibleFactList(frame !== null ? readFacts(frame) : []);
400
- }
401
- function useVisibleFactList(facts) {
402
- const dismissed = useOptimisticFlowSet(DISMISSED_FLOW);
403
- return facts.filter((f) => !dismissed.has(f.label));
404
- }
405
- var useUndismissedFacts = useVisibleFactList;
406
- function useForgetFact() {
407
- const { sendImmediateSignal } = useFourtySession();
408
- const dismissed = useOptimisticFlowSet(DISMISSED_FLOW);
409
- const forget = React3.useCallback(
410
- (f) => {
411
- dismissed.add(f.label);
412
- sendImmediateSignal({ type: PRESENCE_FACT_DISMISS_SIGNAL, payload: { label: f.label, value: f.value } });
413
- },
414
- [dismissed, sendImmediateSignal]
415
- );
416
- return { forget };
417
- }
418
- function useReconcileDismissed(presentLabels) {
419
- useReconcileFlowSet(DISMISSED_FLOW, presentLabels);
420
- }
421
- function useDismissedLabels() {
422
- return useOptimisticFlowSet(DISMISSED_FLOW);
423
- }
424
-
425
373
  // src/agent/presence/swatch.tsx
426
374
  import { colorHexOf } from "@40rty/ams-sdk";
427
375
  import { jsx as jsx4 } from "react/jsx-runtime";
@@ -487,7 +435,7 @@ var CARD_EASE = [0.22, 1, 0.36, 1];
487
435
  var CARD_SETTLE_MS = 260;
488
436
 
489
437
  // src/agent/presence/source-cards/card-frame.tsx
490
- import * as React4 from "react";
438
+ import * as React3 from "react";
491
439
  import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
492
440
  var EXIT_TRANSITION = { duration: 0.62, ease: CARD_EASE };
493
441
  var CARD_EXIT = {
@@ -506,7 +454,7 @@ var CARD_POSE = {
506
454
  // A miss is a statement, so it is not dimmed into near-invisibility.
507
455
  missed: { opacity: 0.7, scale: 0.94, y: 0 }
508
456
  };
509
- var SourceCardFrame = React4.forwardRef(function SourceCardFrame2({ kind, state, size, slots, children }, ref) {
457
+ var SourceCardFrame = React3.forwardRef(function SourceCardFrame2({ kind, state, size, slots, children }, ref) {
510
458
  const box = slots === void 0 ? sourceCardBox(size) : sourceCardSpan(size, slots);
511
459
  const pose = CARD_POSE[state];
512
460
  return /* @__PURE__ */ jsxs2(
@@ -650,7 +598,7 @@ function SourcePlate({
650
598
  }
651
599
 
652
600
  // src/agent/presence/source-cards/card-marks.tsx
653
- import * as React5 from "react";
601
+ import * as React4 from "react";
654
602
  import { useGenerationStyle } from "@40rty/ams-sdk";
655
603
  import { Fragment as Fragment2, jsx as jsx7 } from "react/jsx-runtime";
656
604
  function SourceImage({
@@ -658,10 +606,10 @@ function SourceImage({
658
606
  caption
659
607
  }) {
660
608
  const generation = useGenerationStyle();
661
- const [broken, setBroken] = React5.useState(false);
662
- const [loaded, setLoaded] = React5.useState(false);
609
+ const [broken, setBroken] = React4.useState(false);
610
+ const [loaded, setLoaded] = React4.useState(false);
663
611
  const usable = imageUrl !== void 0 && imageUrl.length > 0 && !broken;
664
- const ref = React5.useCallback((node) => {
612
+ const ref = React4.useCallback((node) => {
665
613
  if (node !== null && node.complete && node.naturalWidth > 0) setLoaded(true);
666
614
  }, []);
667
615
  if (!usable) return /* @__PURE__ */ jsx7(Fragment2, { children: caption });
@@ -791,9 +739,9 @@ function RatingStars({
791
739
  }
792
740
 
793
741
  // src/agent/presence/source-cards/ProductSourceCard.tsx
794
- import * as React6 from "react";
742
+ import * as React5 from "react";
795
743
  import { jsx as jsx8 } from "react/jsx-runtime";
796
- var ProductSourceCard = React6.forwardRef(
744
+ var ProductSourceCard = React5.forwardRef(
797
745
  function ProductSourceCard2({
798
746
  source,
799
747
  sourceKind,
@@ -819,10 +767,10 @@ var productSourceForm = {
819
767
  };
820
768
 
821
769
  // src/agent/presence/source-cards/CollectionSourceCard.tsx
822
- import * as React7 from "react";
770
+ import * as React6 from "react";
823
771
  import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
824
772
  var STEP_RATIO = 0.1;
825
- var CollectionSourceCard = React7.forwardRef(
773
+ var CollectionSourceCard = React6.forwardRef(
826
774
  function CollectionSourceCard2({
827
775
  source,
828
776
  sourceKind,
@@ -881,7 +829,7 @@ var collectionSourceForm = {
881
829
  };
882
830
 
883
831
  // src/agent/presence/source-cards/ArticleSourceCard.tsx
884
- import * as React8 from "react";
832
+ import * as React7 from "react";
885
833
  import { jsx as jsx10 } from "react/jsx-runtime";
886
834
  function articleLines(size, weight) {
887
835
  const headline = { width: 0.68, weight: weight + 1 };
@@ -898,7 +846,7 @@ function articleLines(size, weight) {
898
846
  closer
899
847
  ];
900
848
  }
901
- var ArticleSourceCard = React8.forwardRef(
849
+ var ArticleSourceCard = React7.forwardRef(
902
850
  function ArticleSourceCard2({
903
851
  sourceKind,
904
852
  size,
@@ -917,7 +865,7 @@ var articleSourceForm = {
917
865
  };
918
866
 
919
867
  // src/agent/presence/source-cards/PolicySourceCard.tsx
920
- import * as React9 from "react";
868
+ import * as React8 from "react";
921
869
  import { jsx as jsx11, jsxs as jsxs5 } from "react/jsx-runtime";
922
870
  var FOLD_RATIO = 0.32;
923
871
  function policyLines(weight) {
@@ -927,7 +875,7 @@ function policyLines(weight) {
927
875
  { width: 0.5, weight }
928
876
  ];
929
877
  }
930
- var PolicySourceCard = React9.forwardRef(
878
+ var PolicySourceCard = React8.forwardRef(
931
879
  function PolicySourceCard2({
932
880
  sourceKind,
933
881
  size,
@@ -962,7 +910,7 @@ var policySourceForm = {
962
910
  };
963
911
 
964
912
  // src/agent/presence/source-cards/ReviewSourceCard.tsx
965
- import * as React10 from "react";
913
+ import * as React9 from "react";
966
914
 
967
915
  // src/agent/presence/source-cards/review-passage.ts
968
916
  function str(value) {
@@ -1062,8 +1010,8 @@ function Passage({ passage }) {
1062
1010
  );
1063
1011
  }
1064
1012
  function useRead(count, still) {
1065
- const [at, setAt] = React10.useState(0);
1066
- React10.useEffect(() => {
1013
+ const [at, setAt] = React9.useState(0);
1014
+ React9.useEffect(() => {
1067
1015
  if (still || count <= 1) return;
1068
1016
  const last = Math.min(count, COLUMN_MAX) - 1;
1069
1017
  if (at >= last) return;
@@ -1072,7 +1020,7 @@ function useRead(count, still) {
1072
1020
  }, [count, still, at]);
1073
1021
  return Math.min(at, Math.max(0, Math.min(count, COLUMN_MAX) - 1));
1074
1022
  }
1075
- var ReviewSourceCard = React10.forwardRef(
1023
+ var ReviewSourceCard = React9.forwardRef(
1076
1024
  function ReviewSourceCard2({ source, records, sourceKind, size, found, pending, chosen }, ref) {
1077
1025
  const box = sourceCardSpan(size, REVIEW_SLOTS);
1078
1026
  const state = sourceCardState(found, pending, chosen);
@@ -1160,10 +1108,10 @@ function registerDefaultPresenceSourceForms() {
1160
1108
  registerDefaultPresenceSourceForms();
1161
1109
 
1162
1110
  // src/agent/presence/source-cards/SourceCard.tsx
1163
- import * as React11 from "react";
1111
+ import * as React10 from "react";
1164
1112
  import { resolvePresenceSourceForm } from "@40rty/ams-sdk";
1165
1113
  import { jsx as jsx13 } from "react/jsx-runtime";
1166
- var PresenceSourceCard = React11.forwardRef(function PresenceSourceCard2({ source, records, sourceKind, size, found, pending, chosen }, ref) {
1114
+ var PresenceSourceCard = React10.forwardRef(function PresenceSourceCard2({ source, records, sourceKind, size, found, pending, chosen }, ref) {
1167
1115
  const def = resolvePresenceSourceForm(sourceKind);
1168
1116
  if (def === void 0) return null;
1169
1117
  const { Component } = def;
@@ -1183,7 +1131,7 @@ var PresenceSourceCard = React11.forwardRef(function PresenceSourceCard2({ sourc
1183
1131
  });
1184
1132
 
1185
1133
  // src/agent/presence/SourceSift.tsx
1186
- import * as React12 from "react";
1134
+ import * as React11 from "react";
1187
1135
 
1188
1136
  // src/agent/presence/sift-deck.ts
1189
1137
  import { resolvePresenceSourceForm as resolvePresenceSourceForm2 } from "@40rty/ams-sdk";
@@ -1376,27 +1324,27 @@ function SourceSift({
1376
1324
  size = "band",
1377
1325
  reserveTrack = false
1378
1326
  }) {
1379
- const admitted = React12.useRef(/* @__PURE__ */ new Map());
1327
+ const admitted = React11.useRef(/* @__PURE__ */ new Map());
1380
1328
  const deck = siftDeck(sources, materialized, SIFT_MAX_CARDS[size], admitted.current);
1381
1329
  for (const card of deck.cards) admitted.current.set(card.key, card.slots);
1382
1330
  const controls = useAnimationControls();
1383
- const seen = React12.useRef(criteria);
1384
- const [pass, setPass] = React12.useState(0);
1385
- React12.useEffect(() => {
1331
+ const seen = React11.useRef(criteria);
1332
+ const [pass, setPass] = React11.useState(0);
1333
+ React11.useEffect(() => {
1386
1334
  if (criteria > seen.current) setPass((n) => n + 1);
1387
1335
  seen.current = criteria;
1388
1336
  }, [criteria]);
1389
- React12.useEffect(() => {
1337
+ React11.useEffect(() => {
1390
1338
  if (pass === 0) return;
1391
1339
  void controls.start({
1392
1340
  opacity: [1, 0.62, 1],
1393
1341
  transition: { duration: 0.62, ease: "easeInOut", times: [0, 0.34, 1] }
1394
1342
  });
1395
1343
  }, [pass, controls]);
1396
- const lastRest = React12.useRef(0);
1344
+ const lastRest = React11.useRef(0);
1397
1345
  const live = deck.cards.length > 0;
1398
- const [resolving, setResolving] = React12.useState(false);
1399
- React12.useEffect(() => {
1346
+ const [resolving, setResolving] = React11.useState(false);
1347
+ React11.useEffect(() => {
1400
1348
  if (live) setResolving(true);
1401
1349
  }, [live]);
1402
1350
  if (!live && !resolving) return null;
@@ -1606,48 +1554,8 @@ function bandRowTemplate(railWidth, deckWidth) {
1606
1554
  return `minmax(0, ${railWidth}px) minmax(${VOICE_MIN_WIDTH}px, 1fr) minmax(0, ${deckWidth}px)`;
1607
1555
  }
1608
1556
 
1609
- // src/agent/presence/fact-rail.ts
1610
- var PRESENCE_FACT_LIMIT = 3;
1611
- var PRESENCE_DURABLE_SLOTS = 1;
1612
- function rankFactElements(facts, liveTurnId) {
1613
- const thisTurn = [];
1614
- const profile = [];
1615
- const older = [];
1616
- for (const el of facts) {
1617
- if (liveTurnId !== void 0 && el.turnId === liveTurnId) thisTurn.push(el);
1618
- else if (el.tier === "profile") profile.push(el);
1619
- else older.push(el);
1620
- }
1621
- return [...thisTurn, ...profile, ...newestReadFirst(older)];
1622
- }
1623
- function newestReadFirst(facts) {
1624
- const reads = /* @__PURE__ */ new Map();
1625
- for (const el of facts) {
1626
- const held = reads.get(el.turnId);
1627
- if (held === void 0) reads.set(el.turnId, [el]);
1628
- else held.push(el);
1629
- }
1630
- const out = [];
1631
- for (const read of [...reads.values()].reverse()) out.push(...read);
1632
- return out;
1633
- }
1634
- function selectPresenceFacts(facts, liveTurnId) {
1635
- return rankFactElements(facts, liveTurnId);
1636
- }
1637
- function isDurable(fact) {
1638
- return fact.tier === "profile";
1639
- }
1640
- function capWithDurableFloor(facts, limit) {
1641
- const head = facts.slice(0, limit);
1642
- if (limit < PRESENCE_DURABLE_SLOTS) return head;
1643
- if (head.some(isDurable)) return head;
1644
- const durable = facts.slice(limit).find(isDurable);
1645
- if (durable === void 0) return head;
1646
- return [...head.slice(0, limit - PRESENCE_DURABLE_SLOTS), durable];
1647
- }
1648
-
1649
1557
  // src/agent/presence/folded.tsx
1650
- import * as React13 from "react";
1558
+ import * as React12 from "react";
1651
1559
  import { jsx as jsx17, jsxs as jsxs10 } from "react/jsx-runtime";
1652
1560
  function Sep() {
1653
1561
  return /* @__PURE__ */ jsx17("span", { "aria-hidden": true, className: presenceClass.factSep, "data-dot": "true", children: "\xB7" });
@@ -1669,7 +1577,7 @@ function FoldedRead({ label, facts, text }) {
1669
1577
  label.length > 0 && /* @__PURE__ */ jsx17(Eyebrow, { children: label }),
1670
1578
  label.length > 0 && /* @__PURE__ */ jsx17(Rule, {}),
1671
1579
  shown.length > 0 ? /* @__PURE__ */ jsxs10("div", { className: presenceClass.facts, "data-folded": "true", children: [
1672
- shown.map((f, i) => /* @__PURE__ */ jsxs10(React13.Fragment, { children: [
1580
+ shown.map((f, i) => /* @__PURE__ */ jsxs10(React12.Fragment, { children: [
1673
1581
  i > 0 && /* @__PURE__ */ jsx17(Sep, {}),
1674
1582
  /* @__PURE__ */ jsx17(FactChip2, { fact: f })
1675
1583
  ] }, f.label)),
@@ -1703,11 +1611,11 @@ function BriefHandle({
1703
1611
  }
1704
1612
 
1705
1613
  // src/agent/presence/PresenceBrief.tsx
1706
- import * as React15 from "react";
1614
+ import * as React14 from "react";
1707
1615
  import { usePresenceElements, usePresenceLiveTurn } from "@40rty/ams-sdk";
1708
1616
 
1709
1617
  // src/agent/presence/BriefIdentity.tsx
1710
- import * as React14 from "react";
1618
+ import * as React13 from "react";
1711
1619
  import { useVisitorName } from "@40rty/ams-sdk";
1712
1620
  import { jsx as jsx18 } from "react/jsx-runtime";
1713
1621
  var SETTLE = [0.22, 1, 0.36, 1];
@@ -1717,9 +1625,9 @@ function NameField({
1717
1625
  initial
1718
1626
  }) {
1719
1627
  const { identity } = useLabels().presence.brief;
1720
- const [draft, setDraft] = React14.useState(initial);
1721
- const ref = React14.useRef(null);
1722
- React14.useEffect(() => {
1628
+ const [draft, setDraft] = React13.useState(initial);
1629
+ const ref = React13.useRef(null);
1630
+ React13.useEffect(() => {
1723
1631
  ref.current?.focus();
1724
1632
  }, []);
1725
1633
  const commit = () => {
@@ -1755,7 +1663,7 @@ function NameField({
1755
1663
  function BriefIdentity() {
1756
1664
  const { name, setName } = useVisitorName();
1757
1665
  const { identity } = useLabels().presence.brief;
1758
- const [editing, setEditing] = React14.useState(false);
1666
+ const [editing, setEditing] = React13.useState(false);
1759
1667
  if (editing) {
1760
1668
  return /* @__PURE__ */ jsx18("div", { className: presenceClass.identity, children: /* @__PURE__ */ jsx18(
1761
1669
  NameField,
@@ -1792,79 +1700,6 @@ function BriefIdentity() {
1792
1700
  ) });
1793
1701
  }
1794
1702
 
1795
- // src/agent/presence/element-view.ts
1796
- function toFact(el) {
1797
- if (el.scope === void 0) {
1798
- return { label: el.label, value: el.value, tier: el.tier, provenance: el.provenance };
1799
- }
1800
- return {
1801
- label: el.label,
1802
- value: el.value,
1803
- tier: el.tier,
1804
- provenance: el.provenance,
1805
- scope: el.scope
1806
- };
1807
- }
1808
- function isWorthShowing(el) {
1809
- return el.provenance !== "stated";
1810
- }
1811
- function derivePresenceView(elements, liveTurnId) {
1812
- const sources = [];
1813
- const showable = [];
1814
- const heldLabels = [];
1815
- let voice = "";
1816
- let ask;
1817
- let concession;
1818
- for (const el of elements) {
1819
- switch (el.kind) {
1820
- case "source":
1821
- sources.push(el);
1822
- break;
1823
- case "fact":
1824
- heldLabels.push(el.label);
1825
- if (isWorthShowing(el)) showable.push(el);
1826
- break;
1827
- case "voice":
1828
- if (el.register === "lead") voice = el.text;
1829
- break;
1830
- case "ask":
1831
- ask = el;
1832
- break;
1833
- case "concession":
1834
- concession = el;
1835
- break;
1836
- }
1837
- }
1838
- const facts = selectPresenceFacts(showable, liveTurnId).map(toFact);
1839
- return { sources, facts, hiddenFacts: 0, heldLabels, voice, ask, concession };
1840
- }
1841
- function withCappedFacts(view, facts, reachable, limit) {
1842
- const drawn = capWithDurableFloor(facts, limit);
1843
- const shown = new Set(drawn.map(factIdentity));
1844
- return {
1845
- sources: view.sources,
1846
- facts: drawn,
1847
- // `+N` COUNTS WHAT THE BRIEF HOLDS AND THE BAND IS NOT SHOWING — the two are
1848
- // different lists, and counting the wrong one is a door onto an empty room.
1849
- // It was `facts.length - limit`: `facts` is the BAND's set, which includes
1850
- // the optimistic bridge (a pick shown before the agent's read lands), while
1851
- // the brief shows only what the agent knows. A visitor who picked a size got
1852
- // a "+4" whose destination held two entries. Counting the REACHABLE set that
1853
- // the band did not draw is exact by construction, whatever fills the slots.
1854
- hiddenFacts: reachable.filter((f) => !shown.has(factIdentity(f))).length,
1855
- heldLabels: view.heldLabels,
1856
- voice: view.voice,
1857
- ask: view.ask,
1858
- concession: view.concession
1859
- };
1860
- }
1861
- function viewIsEmpty(view) {
1862
- return view.sources.length === 0 && view.facts.length === 0 && view.voice.length === 0 && view.ask === void 0 && view.concession === void 0;
1863
- }
1864
- function viewHasHeld(view) {
1865
- return view.facts.length > 0 || view.voice.length > 0 || view.ask !== void 0;
1866
- }
1867
-
1868
1703
  // src/agent/presence/PresenceBrief.tsx
1869
1704
  import { jsx as jsx19, jsxs as jsxs11 } from "react/jsx-runtime";
1870
1705
  var SETTLE2 = [0.22, 1, 0.36, 1];
@@ -1891,7 +1726,7 @@ function Group({
1891
1726
  function PresenceBriefBody({ facts }) {
1892
1727
  const { forget } = useForgetFact();
1893
1728
  const { brief } = useLabels().presence;
1894
- const { recalled, inferred } = React15.useMemo(() => partition(facts), [facts]);
1729
+ const { recalled, inferred } = React14.useMemo(() => partition(facts), [facts]);
1895
1730
  if (facts.length === 0) return null;
1896
1731
  return /* @__PURE__ */ jsxs11("div", { className: presenceClass.brief, children: [
1897
1732
  /* @__PURE__ */ jsx19(BriefIdentity, {}),
@@ -1902,7 +1737,7 @@ function PresenceBriefBody({ facts }) {
1902
1737
  function PresenceBriefDrawer() {
1903
1738
  const elements = usePresenceElements();
1904
1739
  const liveTurnId = usePresenceLiveTurn();
1905
- const view = React15.useMemo(
1740
+ const view = React14.useMemo(
1906
1741
  () => derivePresenceView(elements, liveTurnId),
1907
1742
  [elements, liveTurnId]
1908
1743
  );
@@ -1921,11 +1756,11 @@ function PresenceBriefDrawer() {
1921
1756
  }
1922
1757
 
1923
1758
  // src/agent/presence/use-measured-height.ts
1924
- import * as React16 from "react";
1759
+ import * as React15 from "react";
1925
1760
  function useMeasuredHeight() {
1926
- const ref = React16.useRef(null);
1927
- const [height, setHeight] = React16.useState(0);
1928
- React16.useLayoutEffect(() => {
1761
+ const ref = React15.useRef(null);
1762
+ const [height, setHeight] = React15.useState(0);
1763
+ React15.useLayoutEffect(() => {
1929
1764
  const el = ref.current;
1930
1765
  if (el === null) return;
1931
1766
  if (typeof ResizeObserver === "undefined") {
@@ -1997,15 +1832,15 @@ function registerDefaultPresenceForms() {
1997
1832
  registerDefaultPresenceForms();
1998
1833
 
1999
1834
  // src/agent/presence/AgentPresenceWidget.tsx
2000
- import * as React22 from "react";
1835
+ import * as React20 from "react";
2001
1836
  import {
2002
1837
  usePresenceMaterialized,
2003
- useFourtySession as useFourtySession2
1838
+ useFourtySession
2004
1839
  } from "@40rty/ams-sdk";
2005
1840
  import { useFormFactor as useFormFactor2 } from "@40rty/ams-sdk";
2006
1841
 
2007
1842
  // src/agent/presence/band-beat.ts
2008
- import * as React17 from "react";
1843
+ import * as React16 from "react";
2009
1844
  var BAND_BEAT_MS = 260;
2010
1845
  var BAND_REGION_STAGGER_S = 0.06;
2011
1846
  var BAND_REGION_ORDER = {
@@ -2018,11 +1853,11 @@ function bandRegionDelay(region) {
2018
1853
  }
2019
1854
  var BAND_SETTLE = [0.22, 1, 0.36, 1];
2020
1855
  function useBandBeat(value, signature) {
2021
- const [drawn, setDrawn] = React17.useState(value);
2022
- const latest = React17.useRef(value);
1856
+ const [drawn, setDrawn] = React16.useState(value);
1857
+ const latest = React16.useRef(value);
2023
1858
  latest.current = value;
2024
- const composedAt = React17.useRef(Number.NEGATIVE_INFINITY);
2025
- React17.useEffect(() => {
1859
+ const composedAt = React16.useRef(Number.NEGATIVE_INFINITY);
1860
+ React16.useEffect(() => {
2026
1861
  const since = performance.now() - composedAt.current;
2027
1862
  if (since >= BAND_BEAT_MS) {
2028
1863
  composedAt.current = performance.now();
@@ -2039,21 +1874,21 @@ function useBandBeat(value, signature) {
2039
1874
  }
2040
1875
 
2041
1876
  // src/agent/presence/fact-slots.ts
2042
- import * as React18 from "react";
1877
+ import * as React17 from "react";
2043
1878
  function emptySlotRegistry(limit) {
2044
1879
  return { slots: new Array(limit).fill(void 0), clock: 0 };
2045
1880
  }
2046
- function isDurable2(fact) {
1881
+ function isDurable(fact) {
2047
1882
  return fact.tier === "profile";
2048
1883
  }
2049
1884
  function evictionCandidate(slots, incoming) {
2050
- const durableCount = slots.filter((t) => t !== void 0 && isDurable2(t.fact)).length;
1885
+ const durableCount = slots.filter((t) => t !== void 0 && isDurable(t.fact)).length;
2051
1886
  let choice;
2052
1887
  let stalest = Number.POSITIVE_INFINITY;
2053
1888
  for (let i = 0; i < slots.length; i += 1) {
2054
1889
  const tenant = slots[i];
2055
1890
  if (tenant === void 0) return i;
2056
- const protectedDurable = isDurable2(tenant.fact) && durableCount <= 1 && !isDurable2(incoming);
1891
+ const protectedDurable = isDurable(tenant.fact) && durableCount <= 1 && !isDurable(incoming);
2057
1892
  if (protectedDurable) continue;
2058
1893
  if (tenant.seen < stalest) {
2059
1894
  stalest = tenant.seen;
@@ -2120,8 +1955,8 @@ function assignSlots(registry, facts, dismissed) {
2120
1955
  }
2121
1956
  function useFactSlots(facts) {
2122
1957
  const dismissed = useDismissedLabels();
2123
- const registry = React18.useRef(emptySlotRegistry(PRESENCE_FACT_LIMIT));
2124
- return React18.useMemo(() => {
1958
+ const registry = React17.useRef(emptySlotRegistry(PRESENCE_FACT_LIMIT));
1959
+ return React17.useMemo(() => {
2125
1960
  const next = assignSlots(registry.current, facts, dismissed);
2126
1961
  registry.current = next.registry;
2127
1962
  return next.slotted;
@@ -2129,8 +1964,8 @@ function useFactSlots(facts) {
2129
1964
  }
2130
1965
  function useRetainedFacts(facts) {
2131
1966
  const dismissed = useDismissedLabels();
2132
- const held = React18.useRef([]);
2133
- return React18.useMemo(() => {
1967
+ const held = React17.useRef([]);
1968
+ return React17.useMemo(() => {
2134
1969
  const present = new Map(facts.map((f) => [f.label, f]));
2135
1970
  const known = new Set(held.current.map((f) => f.label));
2136
1971
  const asserts = facts.some((f) => !known.has(f.label));
@@ -2150,8 +1985,8 @@ function useRetainedFacts(facts) {
2150
1985
  }, [facts]);
2151
1986
  }
2152
1987
  function useHeldSlotCount(slots, holdMs) {
2153
- const [held, setHeld] = React18.useState(slots);
2154
- React18.useEffect(() => {
1988
+ const [held, setHeld] = React17.useState(slots);
1989
+ React17.useEffect(() => {
2155
1990
  if (slots >= held) {
2156
1991
  setHeld(slots);
2157
1992
  return;
@@ -2163,12 +1998,12 @@ function useHeldSlotCount(slots, holdMs) {
2163
1998
  }
2164
1999
 
2165
2000
  // src/agent/presence/CriteriaRail.tsx
2166
- import * as React19 from "react";
2001
+ import * as React18 from "react";
2167
2002
  import { Fragment as Fragment4, jsx as jsx22, jsxs as jsxs13 } from "react/jsx-runtime";
2168
2003
  var CRITERION_EXIT_S = 0.16;
2169
2004
  var CRITERION_ENTER_DELAY_S = 0.08;
2170
- var Criterion = React19.forwardRef(function Criterion2({ fact, slot, onOpenBrief }, ref) {
2171
- const attach = React19.useCallback((el) => {
2005
+ var Criterion = React18.forwardRef(function Criterion2({ fact, slot, onOpenBrief }, ref) {
2006
+ const attach = React18.useCallback((el) => {
2172
2007
  if (typeof ref === "function") {
2173
2008
  ref(el);
2174
2009
  return;
@@ -2316,7 +2151,7 @@ function CriteriaRail({
2316
2151
  }
2317
2152
 
2318
2153
  // src/agent/presence/VoiceLine.tsx
2319
- import * as React20 from "react";
2154
+ import * as React19 from "react";
2320
2155
  import { jsx as jsx23 } from "react/jsx-runtime";
2321
2156
  var WORD_FADE_S = 0.14;
2322
2157
  var WORD_STAGGER_S = 0.014;
@@ -2334,7 +2169,7 @@ function partsWithWordIndex(text) {
2334
2169
  }
2335
2170
  function VoiceLine({ text, className, style, delay = 0 }) {
2336
2171
  const reduce = useReducedMotion();
2337
- const parts = React20.useMemo(() => partsWithWordIndex(text), [text]);
2172
+ const parts = React19.useMemo(() => partsWithWordIndex(text), [text]);
2338
2173
  const words = parts.length === 0 ? 0 : parts[parts.length - 1].word + 1;
2339
2174
  const step = words <= 1 ? 0 : Math.min(WORD_STAGGER_S, SWEEP_MAX_S / words);
2340
2175
  if (reduce === true) return /* @__PURE__ */ jsx23("span", { className, style, children: text });
@@ -2440,26 +2275,6 @@ function streamLeadLine(view) {
2440
2275
  return leadTextOf(view).trim();
2441
2276
  }
2442
2277
 
2443
- // src/agent/presence/use-band-facts.ts
2444
- import * as React21 from "react";
2445
- import { usePresenceElements as usePresenceElements2, usePresenceLiveTurn as usePresenceLiveTurn2 } from "@40rty/ams-sdk";
2446
- function useBandFacts() {
2447
- const elements = usePresenceElements2();
2448
- const liveTurnId = usePresenceLiveTurn2();
2449
- const rawView = React21.useMemo(
2450
- () => derivePresenceView(elements, liveTurnId),
2451
- [elements, liveTurnId]
2452
- );
2453
- useReconcileDismissed(rawView.heldLabels.length > 0 ? rawView.heldLabels : null);
2454
- const all = useVisibleFactList(rawView.facts);
2455
- const reachable = all;
2456
- const view = React21.useMemo(
2457
- () => withCappedFacts(rawView, all, reachable, PRESENCE_FACT_LIMIT),
2458
- [rawView, all]
2459
- );
2460
- return { view, all: reachable };
2461
- }
2462
-
2463
2278
  // src/agent/presence/PresenceFiller.tsx
2464
2279
  import { jsx as jsx25 } from "react/jsx-runtime";
2465
2280
  function PresenceFiller() {
@@ -2479,14 +2294,14 @@ function AgentPresenceWidget({
2479
2294
  idleContent
2480
2295
  }) {
2481
2296
  const materialized = usePresenceMaterialized();
2482
- const { isRunning, isSubmitting } = useFourtySession2();
2297
+ const { isRunning, isSubmitting } = useFourtySession();
2483
2298
  const working = isRunning || isSubmitting;
2484
2299
  const { isMobile } = useFormFactor2();
2485
2300
  const [measureRef, height] = useMeasuredHeight();
2486
2301
  const measured = !staticBand && height > 0;
2487
- const firstMeasure = React22.useRef(true);
2302
+ const firstMeasure = React20.useRef(true);
2488
2303
  const snap = firstMeasure.current && measured;
2489
- React22.useEffect(() => {
2304
+ React20.useEffect(() => {
2490
2305
  if (measured) firstMeasure.current = false;
2491
2306
  }, [measured]);
2492
2307
  const { view: liveView, all: facts } = useBandFacts();
@@ -2614,7 +2429,7 @@ function registerBaselineFactForms() {
2614
2429
  }
2615
2430
 
2616
2431
  // src/agent/presence/LayoutMorphSkeleton.tsx
2617
- import * as React23 from "react";
2432
+ import * as React21 from "react";
2618
2433
  import { useDocumentVisible, useInterval } from "@40rty/ams-sdk";
2619
2434
  import { jsx as jsx29 } from "react/jsx-runtime";
2620
2435
  var LAYOUT_ARCHETYPES = [
@@ -2664,7 +2479,7 @@ function useLayoutMorph(active) {
2664
2479
  const reduce = useReducedMotion();
2665
2480
  const visible = useDocumentVisible();
2666
2481
  const phrases = useLabels().presence.composing;
2667
- const [index, setIndex] = React23.useState(0);
2482
+ const [index, setIndex] = React21.useState(0);
2668
2483
  const advancing = active && visible && reduce !== true;
2669
2484
  useInterval(() => setIndex((x) => (x + 1) % LAYOUT_ARCHETYPES.length), MORPH_MS, advancing);
2670
2485
  const archetype = LAYOUT_ARCHETYPES[index];
@@ -2712,13 +2527,13 @@ function InlinePresenceRead({
2712
2527
  }
2713
2528
 
2714
2529
  // src/agent/presence/KnowledgePeek.tsx
2715
- import * as React24 from "react";
2716
- import { usePresenceElements as usePresenceElements3, usePresenceLiveTurn as usePresenceLiveTurn3 } from "@40rty/ams-sdk";
2530
+ import * as React22 from "react";
2531
+ import { usePresenceElements as usePresenceElements2, usePresenceLiveTurn as usePresenceLiveTurn2 } from "@40rty/ams-sdk";
2717
2532
  import { jsx as jsx31 } from "react/jsx-runtime";
2718
2533
  function PresenceBriefRail() {
2719
- const elements = usePresenceElements3();
2720
- const liveTurnId = usePresenceLiveTurn3();
2721
- const view = React24.useMemo(
2534
+ const elements = usePresenceElements2();
2535
+ const liveTurnId = usePresenceLiveTurn2();
2536
+ const view = React22.useMemo(
2722
2537
  () => derivePresenceView(elements, liveTurnId),
2723
2538
  [elements, liveTurnId]
2724
2539
  );
@@ -2736,11 +2551,6 @@ export {
2736
2551
  Eyebrow,
2737
2552
  Rule,
2738
2553
  Fallback,
2739
- readFacts,
2740
- readLabel,
2741
- useVisibleFacts,
2742
- useVisibleFactList,
2743
- useForgetFact,
2744
2554
  colorSwatch,
2745
2555
  sourceCardClass,
2746
2556
  sourceCardState,
@@ -2778,8 +2588,6 @@ export {
2778
2588
  criteriaRegionWidth,
2779
2589
  criteriaRailTemplate,
2780
2590
  bandRowTemplate,
2781
- PRESENCE_FACT_LIMIT,
2782
- PRESENCE_DURABLE_SLOTS,
2783
2591
  FoldedRead,
2784
2592
  BriefHandle,
2785
2593
  PresenceBriefBody,