@ai-matrx/chat 0.3.28 → 0.3.30

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 (31) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/agents/components/chat/begin-fresh-chat.js +2 -2
  3. package/dist/agents/components/chat/sandbox-insight/SandboxActivityFeed.d.ts +0 -10
  4. package/dist/agents/components/chat/sandbox-insight/SandboxActivityFeed.js +2 -3
  5. package/dist/agents/components/context-policies-display/contextPolicyPreview.js +2 -1
  6. package/dist/agents/components/context-preview/AttachedContextSection.js +3 -2
  7. package/dist/agents/components/context-preview/ContextCompareView.js +2 -2
  8. package/dist/agents/components/inputs/smart-input/ComposerDraftNotice.js +2 -1
  9. package/dist/agents/components/inputs/smart-input/ConversationContextRail.js +0 -9
  10. package/dist/agents/components/observational-memory/components/MemoryStateInspector.js +3 -2
  11. package/dist/agents/components/run-controls/panels/ModelContextPanel.js +4 -4
  12. package/dist/agents/components/working-document/DocumentLinkPicker.d.ts +0 -8
  13. package/dist/agents/components/working-document/DocumentLinkPicker.js +2 -8
  14. package/dist/agents/utils/table-variable.js +2 -2
  15. package/dist/canvas/workspace/useCanvasWorkspaceConversation.js +4 -4
  16. package/dist/host/defaults/webpage-snapshot-view.js +2 -1
  17. package/dist/host/ui-slots.d.ts +0 -13
  18. package/dist/host/ui-slots.js +2 -1
  19. package/dist/surfaces/utils/surface-check-ledger.js +2 -7
  20. package/dist/tool-call-visualization/registry/registry.js +2 -1
  21. package/dist/tool-call-visualization/renderers/ctx/CtxItemCard.d.ts +0 -15
  22. package/dist/tool-call-visualization/renderers/ctx/CtxItemCard.js +2 -5
  23. package/dist/tool-call-visualization/renderers/research/ResearchOverlay.d.ts +0 -15
  24. package/dist/tool-call-visualization/renderers/research/ResearchOverlay.js +2 -1
  25. package/dist/tool-call-visualization/renderers/scrape/ScrapeInline.d.ts +0 -30
  26. package/dist/tool-call-visualization/renderers/scrape/ScrapeInline.js +2 -1
  27. package/dist/tool-call-visualization/renderers/scrape/ScrapeOverlay.d.ts +0 -11
  28. package/dist/tool-call-visualization/renderers/scrape/ScrapeOverlay.js +3 -2
  29. package/dist/tool-call-visualization/result-fields/KeyValueGrid.d.ts +0 -33
  30. package/dist/tool-call-visualization/result-fields/KeyValueGrid.js +2 -7
  31. package/package.json +7 -7
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @ai-matrx/chat
2
2
 
3
+ ## 0.3.30
4
+
5
+ The composer rail's Scratch pill no longer dead-ends: with no scratchpad attached it used to toast "Nothing to show in the canvas yet" and open nothing. It now opens the scratchpad canvas tab, whose body hydrates the active scratchpad and creates one when the pool is empty.
6
+
7
+ Consumer action: none.
8
+
9
+ ## 0.3.29
10
+
11
+ Never reached npm: the tag commit failed CI typecheck on a content-ir-react error fixed right after. These changes ship in 0.3.30.
12
+
13
+ Package-twins collapse onto `@ai-matrx/kit`: character counts across context, memory, scrape and tool-call views use `formatCount` (compact where the view was compact); sandbox activity and context-compare durations use `formatDurationMs` compact; the document link picker and surface-check age use `formatRelativeTime` ("5h ago" / "5h" where they said "today"); reserved-conversation, table-variable and canvas conversation ids use `isUuidShape`. The `isUuidValue` slot's DEFAULT now matches the registered host rule (trimmed RFC 9562); hosts still override it.
14
+
15
+ Consumer action: none.
16
+
3
17
  ## 0.3.28
4
18
 
5
19
  Automatic changed-only republish (docs/metadata drift since the last tag — see
@@ -1,4 +1,5 @@
1
1
  "use client";
2
+ import { isUuidShape } from "@ai-matrx/kit/uuid";
2
3
  import { clearFocus } from "../../redux/execution-system/conversation-focus/conversation-focus.slice.js";
3
4
  import { resolveMandateAsking } from "../../../mandates/resolve-asking.js";
4
5
  import { isOrganizationSelectionCancelled } from "../../../host/org.js";
@@ -38,9 +39,8 @@ function getFreshChatHref(activeAgentId, defaultAgentId) {
38
39
  }
39
40
  return `/chat/a/${encodeURIComponent(activeAgentId)}`;
40
41
  }
41
- const RESERVED_ID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
42
42
  function reservedConversationIdOf(param) {
43
- return param && RESERVED_ID_RE.test(param) ? param.toLowerCase() : null;
43
+ return param && isUuidShape(param) ? param.toLowerCase() : null;
44
44
  }
45
45
  function getReservedFreshChatHref(activeAgentId, defaultAgentId, conversationId) {
46
46
  return `${getFreshChatHref(activeAgentId, defaultAgentId)}?c=${conversationId}`;
@@ -1,13 +1,3 @@
1
- /**
2
- * SandboxActivityFeed — "what has the agent actually done inside the box?"
3
- *
4
- * One line per sandbox tool call, oldest → newest: the tool, its subject (the
5
- * command, or the path), how it ended (exit code / failed / still running),
6
- * how long it took, and the output on expand. It is the transcript's sandbox
7
- * work, extracted and put in one place — reading the SAME tool calls the
8
- * thread renders from (`sandbox-activity.ts` merges the live lifecycle map
9
- * with the persisted `cx_tool_call` rows), never a second data path.
10
- */
11
1
  import React from "react";
12
2
  export declare function SandboxActivityFeed({ conversationId, }: {
13
3
  conversationId: string;
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { formatDurationMs } from "@ai-matrx/kit/format";
3
4
  import React from "react";
4
5
  import { AlertTriangle, ChevronRight, Loader2, Terminal } from "lucide-react";
5
6
  import { cn, ErrorBox } from "@ai-matrx/design-system";
@@ -13,9 +14,7 @@ import { DURABLE_VFS_BADGE_TEXT } from "../../../../tool-call-visualization/rend
13
14
  import { ErrorAlchemyMenu } from "../../../../host/ui-slots.js";
14
15
  import { getToolDisplayName } from "../../../../tool-call-visualization/registry/registry.js";
15
16
  function formatDuration(ms) {
16
- if (ms === null) return null;
17
- if (ms < 1e3) return `${ms}ms`;
18
- return `${(ms / 1e3).toFixed(ms < 1e4 ? 1 : 0)}s`;
17
+ return ms === null ? null : formatDurationMs(ms, { style: "compact" });
19
18
  }
20
19
  const ActivityRow = ({ row }) => {
21
20
  const [open, setOpen] = React.useState(false);
@@ -1,3 +1,4 @@
1
+ import { formatCount } from "@ai-matrx/kit/format";
1
2
  import {
2
3
  previewKnownContext,
3
4
  resolveContextEntryValue
@@ -6,7 +7,7 @@ import { unwrapRichContextValue } from "./contextValueUtils.js";
6
7
  const PREVIEW_MAX = 32;
7
8
  const SIZE_HINT_RE = /^\d[\d,]*\s*chars$/i;
8
9
  function formatCharCount(n) {
9
- return `~${n.toLocaleString()} chars`;
10
+ return `~${formatCount(n)} chars`;
10
11
  }
11
12
  function extractCharCount(value) {
12
13
  if (value === void 0 || value === null) return null;
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import { formatCount } from "@ai-matrx/kit/format";
3
4
  import { Badge, Chip, Button } from "@ai-matrx/design-system/controls";
4
5
  import { useMemo } from "react";
5
6
  import {
@@ -272,7 +273,7 @@ function AttachedContextSection({
272
273
  ),
273
274
  /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate text-sm font-medium text-foreground", children: item.title }),
274
275
  /* @__PURE__ */ jsxs("span", { className: "shrink-0 text-[10px] tabular-nums text-muted-foreground", children: [
275
- item.chars.toLocaleString(),
276
+ formatCount(item.chars),
276
277
  " chars"
277
278
  ] }),
278
279
  item.onRemove && /* @__PURE__ */ jsx(RemoveX, { label: item.title, onRemove: item.onRemove })
@@ -306,7 +307,7 @@ function AttachedContextSection({
306
307
  ] }),
307
308
  " ",
308
309
  "\xB7 ~",
309
- totalChars.toLocaleString(),
310
+ formatCount(totalChars),
310
311
  " characters of content"
311
312
  ] })
312
313
  ] });
@@ -21,7 +21,7 @@ import { usePageCaptureContribution } from "../../../host/ui-slots.js";
21
21
  import { useContextPreview } from "./useContextPreview.js";
22
22
  import { ErrorAlchemyMenu } from "../../../host/ui-slots.js";
23
23
  import { AGENT_ICON } from "@ai-matrx/icons/domain";
24
- import { formatCount } from "@ai-matrx/kit/format";
24
+ import { formatCount, formatDurationMs } from "@ai-matrx/kit/format";
25
25
  import { getUserId } from "../../../host/identity.js";
26
26
  import { humanizeIdentifier } from "@ai-matrx/kit/text-case";
27
27
  import { useAgentName } from "../../identity/agent-identity.js";
@@ -525,7 +525,7 @@ function AnswerBoth({
525
525
  /* @__PURE__ */ jsx("span", { className: "text-[11px] font-semibold uppercase tracking-wider text-primary", children: p === "old" ? "Current system" : "Record store" }),
526
526
  /* @__PURE__ */ jsxs("span", { className: "text-[10px] tabular-nums text-muted-foreground", children: [
527
527
  a?.model && !/^[0-9a-f-]{36}$/i.test(a.model) ? a.model : "",
528
- typeof a?.duration_ms === "number" ? ` ${(a.duration_ms / 1e3).toFixed(1)} s` : "",
528
+ typeof a?.duration_ms === "number" ? ` ${formatDurationMs(a.duration_ms, { style: "compact" })}` : "",
529
529
  typeof a?.input_tokens === "number" ? ` \xB7 ${formatCount(a.input_tokens)} tokens in` : ""
530
530
  ] })
531
531
  ] }),
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { formatCount } from "@ai-matrx/kit/format";
3
4
  import { RotateCcw, TriangleAlert } from "lucide-react";
4
5
  import { useComposerDraftRestore } from "../../../redux/execution-system/instance-user-input/useComposerDraftRestore.js";
5
6
  import { Button } from "@ai-matrx/design-system/controls";
@@ -15,7 +16,7 @@ function ComposerDraftNotice({
15
16
  /* @__PURE__ */ jsx(RotateCcw, { className: "w-3 h-3 shrink-0" }),
16
17
  /* @__PURE__ */ jsxs("span", { className: "min-w-0", children: [
17
18
  "We put your unsent draft back (",
18
- restoredChars.toLocaleString(),
19
+ formatCount(restoredChars),
19
20
  " ",
20
21
  "characters)."
21
22
  ] }),
@@ -36,7 +36,6 @@ import {
36
36
  useOpenScratchpadPanel,
37
37
  useOpenWorkingDocumentPanel
38
38
  } from "../../../../host/window-openers.js";
39
- import { reportCanvasOpenDrop } from "../../../../host/ui-slots.js";
40
39
  import { selectCloudBrowserRunLive } from "../../../../host/ui-slots.js";
41
40
  import {
42
41
  selectInstanceContextEntries,
@@ -182,14 +181,6 @@ function ConversationContextRail({
182
181
  contextTab.toggle(key);
183
182
  };
184
183
  const toggleDocInCanvas = (kind) => {
185
- if (kind === "scratch" && !activeScratchId) {
186
- reportCanvasOpenDrop({
187
- reason: "nothing-to-show",
188
- requested: scratchTitle?.trim() || "Scratchpad",
189
- detail: "no scratchpad is attached to this conversation yet"
190
- });
191
- return;
192
- }
193
184
  const tabId = kind === "scratch" ? scratchpadTabId() : conversationDocumentsTabId(conversationId);
194
185
  if (canvasOpen && currentCanvasSourceId === tabId) {
195
186
  canvas.hide();
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import { formatCount } from "@ai-matrx/kit/format";
3
4
  import { useClipboard } from "@ai-matrx/kit/clipboard";
4
5
  import { toast } from "../../../../host/notify.js";
5
6
  import { useCallback, useEffect, useMemo, useState } from "react";
@@ -335,7 +336,7 @@ function BufferedObservationCard({
335
336
  "t"
336
337
  ] }),
337
338
  hasText && /* @__PURE__ */ jsxs("span", { children: [
338
- /* @__PURE__ */ jsx("span", { className: "text-foreground/70 font-mono", children: text.length.toLocaleString() }),
339
+ /* @__PURE__ */ jsx("span", { className: "text-foreground/70 font-mono", children: formatCount(text.length) }),
339
340
  " ",
340
341
  "chars"
341
342
  ] })
@@ -523,7 +524,7 @@ function TextPayload({
523
524
  ] }),
524
525
  hasText && text && /* @__PURE__ */ jsxs(Fragment, { children: [
525
526
  /* @__PURE__ */ jsxs("span", { className: "text-[10px] font-mono text-muted-foreground shrink-0", children: [
526
- text.length.toLocaleString(),
527
+ formatCount(text.length),
527
528
  " chars"
528
529
  ] }),
529
530
  /* @__PURE__ */ jsx(Button, { variant: "quiet", icon: copied ? /* @__PURE__ */ jsx(Check, {}) : /* @__PURE__ */ jsx(Copy, {}), glyphTone: copied ? "success" : void 0, onClick: handleCopy, title: "Copy", "aria-label": "Copy", className: "shrink-0" })
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
- import { formatDurationSeconds } from "@ai-matrx/kit/format";
3
+ import { formatDurationSeconds, formatCount } from "@ai-matrx/kit/format";
4
4
  import { useEffect, useMemo, useState } from "react";
5
5
  import { useAppDispatch, useAppSelector } from "../../../../store/hooks.js";
6
6
  import { useOrganizationRequired } from "../../../../host/ui-slots.js";
@@ -178,7 +178,7 @@ function TrimSummaryView({ trim }) {
178
178
  valueClassName: skipped ? "text-amber-500" : rewrittenCount > 0 ? "text-emerald-500" : "text-muted-foreground"
179
179
  }
180
180
  ),
181
- rewrittenCount > 0 && /* @__PURE__ */ jsx(StatRow, { label: "Freed", value: `${freed.toLocaleString()} chars` }),
181
+ rewrittenCount > 0 && /* @__PURE__ */ jsx(StatRow, { label: "Freed", value: `${formatCount(freed)} chars` }),
182
182
  rewrittenBlocks.length > 0 && /* @__PURE__ */ jsxs("div", { className: "text-[10px] font-mono text-muted-foreground space-y-0.5 mt-1", children: [
183
183
  rewrittenBlocks.slice(0, 8).map((b) => /* @__PURE__ */ jsxs("div", { className: "truncate", children: [
184
184
  "pos ",
@@ -189,9 +189,9 @@ function TrimSummaryView({ trim }) {
189
189
  b.tier,
190
190
  ") \xB7",
191
191
  " ",
192
- b.before_chars.toLocaleString(),
192
+ formatCount(b.before_chars),
193
193
  " \u2192 ",
194
- b.after_chars.toLocaleString()
194
+ formatCount(b.after_chars)
195
195
  ] }, `${b.message_position}:${b.call_id}`)),
196
196
  rewrittenBlocks.length > 8 && /* @__PURE__ */ jsxs("div", { className: "italic", children: [
197
197
  "\u2026and ",
@@ -1,11 +1,3 @@
1
- /**
2
- * DocumentLinkPicker — pick an existing document (working / scratch) of the
3
- * current user to LINK this conversation to. Powers cross-conversation sharing:
4
- * both conversations then point at the same `content.document` row, so
5
- * edits round-trip to all of them.
6
- *
7
- * Desktop: Popover. Mobile: BottomSheet (nested pickers must not use Popover).
8
- */
9
1
  import React from "react";
10
2
  import { type WorkingDocumentKind } from "../../redux/execution-system/instance-working-document/cx-working-document.service.js";
11
3
  interface DocumentLinkPickerProps {
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import { formatRelativeTime } from "@ai-matrx/kit/format";
3
4
  import React, { useCallback, useMemo, useState } from "react";
4
5
  import { FileText, Loader2, NotebookPen, Search } from "lucide-react";
5
6
  import { Input, Tabs, Tile } from "@ai-matrx/design-system/controls";
@@ -23,14 +24,7 @@ function previewOf(content) {
23
24
  return trimmed.length > 80 ? `${trimmed.slice(0, 80)}\u2026` : trimmed;
24
25
  }
25
26
  function formatWhen(iso) {
26
- const then = new Date(iso).getTime();
27
- if (Number.isNaN(then)) return "";
28
- const diff = Date.now() - then;
29
- const day = 864e5;
30
- if (diff < day) return "today";
31
- if (diff < 2 * day) return "yesterday";
32
- if (diff < 7 * day) return `${Math.floor(diff / day)}d ago`;
33
- return new Date(iso).toLocaleDateString();
27
+ return formatRelativeTime(iso, { fallback: "" });
34
28
  }
35
29
  const SCOPES = [
36
30
  { value: "mine", label: "Mine" },
@@ -1,4 +1,4 @@
1
- const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
1
+ import { isUuidShape } from "@ai-matrx/kit/uuid";
2
2
  function isTableVariableType(type) {
3
3
  return type === "table" || type === "tables";
4
4
  }
@@ -7,7 +7,7 @@ function tableVariableTypeOf(customComponent) {
7
7
  return typeof type === "string" && isTableVariableType(type) ? type : null;
8
8
  }
9
9
  function isTableId(value) {
10
- return typeof value === "string" && UUID_RE.test(value.trim());
10
+ return typeof value === "string" && isUuidShape(value.trim());
11
11
  }
12
12
  function readTableReference(value) {
13
13
  const out = [];
@@ -1,4 +1,5 @@
1
1
  "use client";
2
+ import { isUuidShape } from "@ai-matrx/kit/uuid";
2
3
  import { useEffect, useRef, useState } from "react";
3
4
  import { useAgentLauncher } from "../../agents/hooks/useAgentLauncher.js";
4
5
  import { DEFAULT_NEW_CHAT_MANDATE_KEY } from "../../agents/components/chat/chat-quick-actions.config.js";
@@ -15,10 +16,9 @@ function initialRequest(start) {
15
16
  return { kind: "open", conversationId: start.conversationId, agentId: start.agentId ?? null, nonce: 0 };
16
17
  return { kind: "new", nonce: 0 };
17
18
  }
18
- const CONVERSATION_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
19
19
  function conversationInAddress(param, search) {
20
20
  const value = new URLSearchParams(search).get(param);
21
- return value && CONVERSATION_ID.test(value) ? value : null;
21
+ return value && isUuidShape(value) ? value : null;
22
22
  }
23
23
  function workspaceChatMemoryKey(surfaceKey) {
24
24
  return `matrx:workspace-chat:${surfaceKey}`;
@@ -26,7 +26,7 @@ function workspaceChatMemoryKey(surfaceKey) {
26
26
  function recallWorkspaceConversation(surfaceKey) {
27
27
  try {
28
28
  const value = window.localStorage.getItem(workspaceChatMemoryKey(surfaceKey));
29
- return value && CONVERSATION_ID.test(value) ? value : null;
29
+ return value && isUuidShape(value) ? value : null;
30
30
  } catch {
31
31
  return null;
32
32
  }
@@ -46,7 +46,7 @@ function reserveWorkspaceConversationId(surfaceKey, fresh) {
46
46
  try {
47
47
  const key = reservedChatKey(surfaceKey);
48
48
  const kept = fresh ? null : window.localStorage.getItem(key);
49
- if (kept && CONVERSATION_ID.test(kept)) return kept;
49
+ if (kept && isUuidShape(kept)) return kept;
50
50
  const id = window.crypto.randomUUID();
51
51
  window.localStorage.setItem(key, id);
52
52
  return id;
@@ -1,3 +1,4 @@
1
+ import { formatCount } from "@ai-matrx/kit/format";
1
2
  import { createElement } from "react";
2
3
  function DefaultWebpageSnapshotView({
3
4
  snapshot,
@@ -17,7 +18,7 @@ function DefaultWebpageSnapshotView({
17
18
  { className: "font-medium text-foreground" },
18
19
  variant === "submitted" ? "Snapshot sent with this message" : "Snapshot attached to this draft"
19
20
  ),
20
- createElement("span", null, `${charCount.toLocaleString()} characters`),
21
+ createElement("span", null, `${formatCount(charCount)} characters`),
21
22
  scrapedAt ? createElement("span", null, scrapedAt) : null
22
23
  ) : null,
23
24
  createElement(
@@ -1,16 +1,3 @@
1
- /**
2
- * host/ui-slots — host registrations for app UI the package draws but does not own
3
- * (PACKAGE-INDEPENDENCE.md: "a host registration", not an import of app code).
4
- *
5
- * The host registers once at startup with `registerChatUi({...})`; package code
6
- * imports the named wrappers below. A component the host did not register renders
7
- * nothing (or its plain stand-in, marked `data-chat-slot-fallback`) and reports itself
8
- * ONCE through the host diagnostics port (never silent: Law 4); a function or hook it
9
- * did not register throws, naming the slot (or runs its declared stand-in, reported once). A test registers a stand-in the same way (`registerChatUi`).
10
- *
11
- * Slot shapes are the host component's own props — package call sites keep passing
12
- * exactly what they passed when they imported the component directly.
13
- */
14
1
  import { type ComponentType, type ChangeEvent, type ReactNode } from "react";
15
2
  import type { EditableContextMenuProps, NonEditableContextMenuProps } from "../context-menu/types.js";
16
3
  /** The host context menu's props (its registration is typed against them). */
@@ -1,4 +1,5 @@
1
1
  "use client";
2
+ import { isRfc9562Uuid } from "@ai-matrx/kit/uuid";
2
3
  import { createElement, Fragment, useRef } from "react";
3
4
  import { formatCost, usdToPoints } from "@ai-matrx/kit/format";
4
5
  import { reportUnregisteredHostSlot as reportUnregistered } from "./diagnostics.js";
@@ -143,7 +144,7 @@ const STAND_INS = {
143
144
  bookmarksToReferenceDirectives: () => NONE,
144
145
  notifyPrintOutcome: () => void 0,
145
146
  awaitEffectiveOrganizationId: async () => ({ status: "unavailable", reason: "This host registers no organization source.", cause: "no-selection" }),
146
- isUuidValue: (value) => typeof value === "string" && /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value),
147
+ isUuidValue: (value) => typeof value === "string" && isRfc9562Uuid(value.trim()),
147
148
  useClippedContentGuard: () => void 0,
148
149
  answerPreviewText: (text) => String(text ?? ""),
149
150
  beginPlaybackSession: () => ({ id: "", update: () => void 0, end: () => void 0 }),
@@ -1,3 +1,4 @@
1
+ import { formatRelativeTime } from "@ai-matrx/kit/format";
1
2
  const SURFACE_CHECK_FRESH_DAYS = 30;
2
3
  function daysSinceCheck(row, now = Date.now()) {
3
4
  if (!row.last_checked_at) return null;
@@ -11,13 +12,7 @@ function surfaceCheckState(row, now = Date.now()) {
11
12
  return days > SURFACE_CHECK_FRESH_DAYS ? "stale" : "fresh";
12
13
  }
13
14
  function checkAgeLabel(row, now = Date.now()) {
14
- const days = daysSinceCheck(row, now);
15
- if (days === null) return "never";
16
- if (days === 0) return "today";
17
- if (days === 1) return "1d";
18
- if (days < 30) return `${days}d`;
19
- const months = Math.floor(days / 30);
20
- return months < 12 ? `${months}mo` : `${Math.floor(days / 365)}y`;
15
+ return formatRelativeTime(row.last_checked_at, { style: "short", suffix: false, now, fallback: "never" });
21
16
  }
22
17
  function checkSortWeight(row, now = Date.now()) {
23
18
  const days = daysSinceCheck(row, now);
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { formatCount } from "@ai-matrx/kit/format";
3
4
  import {
4
5
  CheckCircle,
5
6
  FileSearch,
@@ -139,7 +140,7 @@ function scrapeHeaderExtras(entry) {
139
140
  "read"
140
141
  ] }),
141
142
  parsed.totalChars > 0 && /* @__PURE__ */ jsxs("span", { children: [
142
- parsed.totalChars.toLocaleString(),
143
+ formatCount(parsed.totalChars),
143
144
  " chars"
144
145
  ] })
145
146
  ] });
@@ -1,18 +1,3 @@
1
- /**
2
- * CtxItemCard — the note-card display for ONE context item.
3
- *
4
- * Shared by every CTX renderer (`ctx_get`, `ctx_batch`). Renders a single
5
- * resolved context object — `{ key, type, label, content }` (or `summary`
6
- * in summary mode) — as a polished note card: a header row carrying the
7
- * type icon, the human label, the raw key, and an optional size badge, then
8
- * the value itself via the recursive `<ResultValue>` field library.
9
- *
10
- * The component is deliberately shape-tolerant: the server `type` field is a
11
- * free string, so the icon is resolved through a string-keyed map with a
12
- * `Layers` fallback. `content` is handed straight to `<ResultValue>`, which
13
- * already knows how to render markdown, tables, json, media, and scalars by
14
- * shape — this card never reimplements rendering.
15
- */
16
1
  import React from "react";
17
2
  import { type ResultDensity } from "../../result-fields/ResultValue.js";
18
3
  export interface CtxItem {
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { formatCount } from "@ai-matrx/kit/format";
3
4
  import {
4
5
  FileText,
5
6
  File,
@@ -34,11 +35,7 @@ function iconForType(type) {
34
35
  return CTX_TYPE_ICON[type] ?? Layers;
35
36
  }
36
37
  function formatCharCount(n) {
37
- if (n >= 1e3) {
38
- const k = n / 1e3;
39
- return `${k >= 10 ? Math.round(k) : k.toFixed(1)}k chars`;
40
- }
41
- return `${n} char${n === 1 ? "" : "s"}`;
38
+ return `${formatCount(n, { style: "compact" })} char${n === 1 ? "" : "s"}`;
42
39
  }
43
40
  const CtxItemCard = ({
44
41
  item,
@@ -1,18 +1,3 @@
1
- /**
2
- * Research overlay tabs (`research_web`, `core_web_search_and_read`).
3
- *
4
- * Exposes Report · Sources · Full Text, plus a `researchOverlayTabs` array the
5
- * tool registry hands to `ToolUpdatesOverlay`. When the tool is opened in the
6
- * overlay these REPLACE the default "Results" tab and sit beside the standard
7
- * "Input" and "Raw" admin tabs:
8
- *
9
- * [ Report | Sources | Full Text | Input | Raw ]
10
- *
11
- * All three parse the raw blob via the ONE canonical `parseSearch` (the
12
- * deep-research `parser.ts` it used to use is deleted — no duplicate parsers).
13
- * The Report tab renders through `RichDocument` (full action toolkit); Sources
14
- * is the dense ranked + deep-read view; Full Text is a copyable synthesized dump.
15
- */
16
1
  import React from "react";
17
2
  import type { ToolOverlayTabSpec, ToolRendererProps } from "../../types.js";
18
3
  export declare const ResearchReportTab: React.FC<ToolRendererProps>;
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { formatCount } from "@ai-matrx/kit/format";
3
4
  import { useMemo, useState } from "react";
4
5
  import {
5
6
  BookOpen,
@@ -106,7 +107,7 @@ const ReadCard = ({
106
107
  content: expanded || !isLong ? read.text : `${read.text.slice(0, 500)}\u2026`
107
108
  }
108
109
  ),
109
- isLong && /* @__PURE__ */ jsx(Button, { variant: "quiet", tone: "primary", onClick: () => setExpanded((p) => !p), className: "mt-2", children: expanded ? "Show less" : `Show full content (${Math.round(read.text.length / 1e3)}k chars)` })
110
+ isLong && /* @__PURE__ */ jsx(Button, { variant: "quiet", tone: "primary", onClick: () => setExpanded((p) => !p), className: "mt-2", children: expanded ? "Show less" : `Show full content (${formatCount(read.text.length, { style: "compact" })} chars)` })
110
111
  ] })
111
112
  ] })
112
113
  ] });
@@ -1,33 +1,3 @@
1
- /**
2
- * ScrapeInline — the canonical inline renderer for the page-read / scrape family
3
- * (`web_read`, `core_web_read_web_pages`).
4
- *
5
- * Reading 40k tokens off a page is NOT a one-line event — so each page gets a
6
- * full rectangular CARD (favicon + title + domain + meta; a preview image when
7
- * one is present; an AI-review line ONLY when present). ONE card per page,
8
- * multiple cards when reading several pages at once.
9
- *
10
- * ─── The two phases ──────────────────────────────────────────────────────────
11
- *
12
- * • READING (live): a left-to-right "reading wave" shimmer sweeps across each
13
- * card (the `readingWave` keyframe in globals.css), mimicking a person
14
- * reading the page top-to-bottom while the content is fetched. While reading
15
- * we know the URLs (from `arguments.urls` and/or the real-time "Browsing
16
- * <url>" activity on `entry.events`) but not yet the body — so the card
17
- * shows the favicon + domain + a shimmering placeholder.
18
- * • DONE (persistent): the card fills in — title, a content snippet, the char
19
- * count, the optional preview image (durable, via `InlineMediaRef`), and the
20
- * optional AI-review line. A "View page" affordance opens the overlay.
21
- *
22
- * Phase is keyed on `selectIsLatestToolActivity(requestId, callId)` when a live
23
- * requestId is threaded (the card keeps reading until the model moves on), and
24
- * falls back to `entry.status` for the simulator / persisted snapshots.
25
- *
26
- * Images go through `InlineMediaRef` ONLY (never a raw <img>) so a page's
27
- * preview image self-heals if it's an expiring signed URL. Favicons use the
28
- * Google favicon service (not owned media → a plain <img> with a Globe fallback
29
- * is correct). Semantic tokens only; React Compiler is on (no manual memo).
30
- */
31
1
  import React from "react";
32
2
  import type { ToolRendererProps } from "../../types.js";
33
3
  export declare const ScrapeInline: React.FC<ToolRendererProps>;
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { formatCount } from "@ai-matrx/kit/format";
3
4
  import { useMemo, useState } from "react";
4
5
  import {
5
6
  Globe,
@@ -168,7 +169,7 @@ const ReadPageCard = ({ page, index, onOpen }) => {
168
169
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 pt-0.5 text-xs text-muted-foreground", children: [
169
170
  /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1", children: [
170
171
  /* @__PURE__ */ jsx(FileText, { className: "h-3 w-3" }),
171
- page.charCount.toLocaleString(),
172
+ formatCount(page.charCount),
172
173
  " chars"
173
174
  ] }),
174
175
  onOpen && /* @__PURE__ */ jsx(Button, { variant: "quiet", tone: "primary", iconEnd: /* @__PURE__ */ jsx(ArrowRight, {}), onClick: (e) => {
@@ -1,14 +1,3 @@
1
- /**
2
- * ScrapeOverlay — the full "hide nothing" page-read view for the scrape family
3
- * (`web_read`, `core_web_read_web_pages`), rendered in the fullscreen overlay
4
- * and the floating window panel.
5
- *
6
- * Layout: a page list on the left, the selected page's FULL content on the
7
- * right (rendered as markdown), plus the optional preview image and AI-review
8
- * when present. Same canonical `parseScrape` as the inline renderer; semantic
9
- * tokens only; favicons via the Google favicon service; the preview image via
10
- * `InlineMediaRef` (durable, never a raw <img>).
11
- */
12
1
  import React from "react";
13
2
  import type { ToolRendererProps } from "../../types.js";
14
3
  export declare const ScrapeOverlay: React.FC<ToolRendererProps>;
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import { formatCount } from "@ai-matrx/kit/format";
3
4
  import { useMemo, useState } from "react";
4
5
  import {
5
6
  Globe,
@@ -58,7 +59,7 @@ const ScrapeOverlay = ({ entry }) => {
58
59
  ] })
59
60
  ] }),
60
61
  parsed.totalChars > 0 && /* @__PURE__ */ jsxs("span", { className: "ml-auto text-xs tabular-nums text-muted-foreground", children: [
61
- parsed.totalChars.toLocaleString(),
62
+ formatCount(parsed.totalChars),
62
63
  " chars total"
63
64
  ] })
64
65
  ] }),
@@ -88,7 +89,7 @@ const ScrapeOverlay = ({ entry }) => {
88
89
  /* @__PURE__ */ jsxs("div", { className: "truncate text-xs text-muted-foreground", children: [
89
90
  p.domain,
90
91
  " \xB7 ",
91
- p.charCount.toLocaleString(),
92
+ formatCount(p.charCount),
92
93
  " chars"
93
94
  ] })
94
95
  ] })
@@ -1,36 +1,3 @@
1
- /**
2
- * KeyValueGrid — renders a plain object as a compact, shape-aware field layout.
3
- *
4
- * Fields are partitioned by what their VALUE is, not treated uniformly:
5
- *
6
- * inline — short values (scalar / uuid / url / boolean / empty) render as
7
- * single-line `Label value` rows on a two-column grid. Key, Type,
8
- * Label never burn two lines each again.
9
- * chips — numeric metadata (total_chars, count, duration_ms, tokens…)
10
- * renders as one wrapping row of quiet badges.
11
- * blocks — anything of unknown length (text, markdown, nested objects,
12
- * tables, lists, media) keeps a full-width section: small label
13
- * header, value beneath, recursing through {@link ResultValue}.
14
- *
15
- * Display order is inline rows → chips → blocks so unknown-length content
16
- * always sits last. Identifier keys (`id`, `*_id`, `uuid`) render the full
17
- * UUID with an always-visible copy button.
18
- *
19
- * Every key is reachable: nothing is dropped, only deferred behind a toggle.
20
- *
21
- * FIELDS THAT DO NOT APPLY (wall W61, 2026-09-12) obey the document's optional
22
- * -field policy (`document-presentation.tsx`), not the density. Before that,
23
- * `inline` silently skipped them and `full` printed the word "None" — the same
24
- * payload read two different ways, and the `full` reading put "Physician note:
25
- * None" at the top of a page written for a parent. Under the default `omit`
26
- * policy they leave the field list and are COUNTED on a quiet trailing line
27
- * that opens them; under `note` they keep their row with a quiet "Not
28
- * applicable"; under `show` the producer's value renders untouched.
29
- *
30
- * FIELD LABELS come from the producer's own JSON Schema `title` when the host
31
- * supplied one, and from the key otherwise. The key is the machine's name for
32
- * a field; the schema's title is the author's.
33
- */
34
1
  import React from "react";
35
2
  import { type ResultDensity } from "./ResultValue.js";
36
3
  export interface KeyValueGridProps {
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { formatCount } from "@ai-matrx/kit/format";
3
4
  import React from "react";
4
5
  import { cn } from "@ai-matrx/design-system";
5
6
  import {
@@ -53,13 +54,7 @@ function isMetaCountField(key, val) {
53
54
  return typeof val === "number" && Number.isFinite(val) && META_COUNT_KEY.test(key);
54
55
  }
55
56
  function formatMetaNumber(n) {
56
- if (Number.isInteger(n) && Math.abs(n) >= 1e4) {
57
- return new Intl.NumberFormat("en-US", {
58
- notation: "compact",
59
- maximumFractionDigits: 1
60
- }).format(n);
61
- }
62
- return n.toLocaleString("en-US");
57
+ return Number.isInteger(n) && Math.abs(n) >= 1e4 ? formatCount(n, { style: "compact" }) : formatCount(n, { locale: "en-US" });
63
58
  }
64
59
  function isInlineValue(key, val) {
65
60
  if (typeof val === "string" && isIdentifierKey(key)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-matrx/chat",
3
- "version": "0.3.28",
3
+ "version": "0.3.30",
4
4
  "description": "THE one AI Matrx person-to-agent chat system: the full chat (running agents, conversations, tool calls, streaming, context, surfaces, voice) as per-module subpaths @ai-matrx/chat/<domain>/<module> over a host contract (/host, /host/react) whose only required value is a db; plus the kernel compatibility entries (., /external-store, /matrx, /react, /tools, styles.css, tokens.css) until P28.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -226,24 +226,24 @@
226
226
  "server-only": "^0.0.1",
227
227
  "uuid": "^14.0.2",
228
228
  "zod": "^4.6.5",
229
- "@ai-matrx/alchemy": "latest",
229
+ "@ai-matrx/agents": "latest",
230
230
  "@ai-matrx/associations": "latest",
231
+ "@ai-matrx/alchemy": "latest",
231
232
  "@ai-matrx/browser-audio": "latest",
232
233
  "@ai-matrx/canvas": "latest",
233
234
  "@ai-matrx/content-ir": "latest",
234
- "@ai-matrx/agents": "latest",
235
235
  "@ai-matrx/content-ir-react": "latest",
236
236
  "@ai-matrx/data": "latest",
237
- "@ai-matrx/diff": "latest",
238
237
  "@ai-matrx/design-system": "latest",
238
+ "@ai-matrx/diff": "latest",
239
239
  "@ai-matrx/icons": "latest",
240
240
  "@ai-matrx/kit": "latest",
241
- "@ai-matrx/media": "latest",
242
241
  "@ai-matrx/print": "latest",
243
242
  "@ai-matrx/realtime": "latest",
244
- "@ai-matrx/records-ui": "latest",
243
+ "@ai-matrx/tap-target": "latest",
244
+ "@ai-matrx/media": "latest",
245
245
  "@ai-matrx/records": "latest",
246
- "@ai-matrx/tap-target": "latest"
246
+ "@ai-matrx/records-ui": "latest"
247
247
  },
248
248
  "devDependencies": {
249
249
  "@arethetypeswrong/cli": "^0.18.5",