@ai-matrx/chat 0.4.2 → 0.4.8

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 (144) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/dist/agent-copy/RichCopySplit.d.ts +17 -0
  3. package/dist/agent-copy/RichCopySplit.js +34 -0
  4. package/dist/agents/components/agent-widgets/chat-assistant/AssistantMessageCard.js +1 -1
  5. package/dist/agents/components/chat/ConversationRecordsChip.js +1 -1
  6. package/dist/agents/components/context-items/bodies/WorkingDocumentBody.d.ts +5 -2
  7. package/dist/agents/components/context-items/bodies/WorkingDocumentBody.js +6 -1
  8. package/dist/agents/components/context-policies-display/ContextValueBody.js +1 -1
  9. package/dist/agents/components/context-preview/ContextCompareView.js +1 -1
  10. package/dist/agents/components/custom-agent/CustomAgentWindow.js +1 -1
  11. package/dist/agents/components/inputs/smart-input/AgentTextarea.d.ts +6 -1
  12. package/dist/agents/components/inputs/smart-input/AgentTextarea.js +2 -2
  13. package/dist/agents/components/inputs/smart-input/ComposerToolsNotice.d.ts +1 -0
  14. package/dist/agents/components/inputs/smart-input/ComposerToolsNotice.js +5 -0
  15. package/dist/agents/components/inputs/smart-input/ConversationContextRail.d.ts +5 -1
  16. package/dist/agents/components/inputs/smart-input/ConversationContextRail.js +6 -1
  17. package/dist/agents/components/inputs/smart-input/InboxQueueStrip.d.ts +6 -1
  18. package/dist/agents/components/inputs/smart-input/InboxQueueStrip.js +6 -1
  19. package/dist/agents/components/inputs/smart-input/InputActionButtons.js +8 -6
  20. package/dist/agents/components/inputs/smart-input/SmartInputFileDropTarget.d.ts +5 -1
  21. package/dist/agents/components/inputs/smart-input/SmartInputFileDropTarget.js +8 -1
  22. package/dist/agents/components/inputs/smart-input/composer/ComposerAgentPill.js +2 -2
  23. package/dist/agents/components/inputs/smart-input/composer/ComposerChipsRow.d.ts +5 -2
  24. package/dist/agents/components/inputs/smart-input/composer/ComposerChipsRow.js +6 -1
  25. package/dist/agents/components/inputs/smart-input/composer/ComposerMetaRow.d.ts +6 -8
  26. package/dist/agents/components/inputs/smart-input/composer/ComposerMetaRow.js +13 -1
  27. package/dist/agents/components/inputs/smart-input/composer/useOutputShapeCatalog.d.ts +1 -1
  28. package/dist/agents/components/inputs/smart-input/composer/useOutputShapeCatalog.js +1 -1
  29. package/dist/agents/components/live-run/LiveRunDisplay.js +1 -1
  30. package/dist/agents/components/live-run/RunSetDisplay.js +1 -1
  31. package/dist/agents/components/memory/components/AgentMemoryAllView.js +1 -1
  32. package/dist/agents/components/messages-display/assistant/AgentAssistantMessage.d.ts +1 -0
  33. package/dist/agents/components/messages-display/assistant/AgentAssistantMessage.js +4 -3
  34. package/dist/agents/components/messages-display/assistant/AgentEmptyMessageDisplay.js +1 -1
  35. package/dist/agents/components/messages-display/assistant/AssistantMessageFooter.d.ts +2 -2
  36. package/dist/agents/components/messages-display/assistant/AssistantMessageFooter.js +4 -7
  37. package/dist/agents/components/messages-display/assistant/InPlaceAnswerEditor.js +2 -2
  38. package/dist/agents/components/messages-display/citations/MessageSourcesRow.js +1 -1
  39. package/dist/agents/components/messages-display/rich-document/chat-message-source.d.ts +2 -0
  40. package/dist/agents/components/messages-display/rich-document/chat-message-source.js +41 -0
  41. package/dist/agents/components/messages-display/rich-document/chatMessageActions.d.ts +31 -0
  42. package/dist/agents/components/messages-display/rich-document/chatMessageActions.js +39 -0
  43. package/dist/agents/components/messages-display/user/AgentUserMessage.d.ts +1 -0
  44. package/dist/agents/components/messages-display/user/AgentUserMessage.js +7 -4
  45. package/dist/agents/components/messages-display/user/CollabNoteMessage.js +1 -1
  46. package/dist/agents/components/messages-display/user/UserActionBar.js +49 -39
  47. package/dist/agents/components/working-document/WorkingDocumentEditor.d.ts +1 -1
  48. package/dist/agents/components/working-document/WorkingDocumentPanel.js +2 -1
  49. package/dist/agents/identity/run-tier-store.js +3 -0
  50. package/dist/agents/redux/agent-definition/cache-bust-middleware.js +2 -0
  51. package/dist/agents/redux/agent-settings/agentSettingsSlice.d.ts +0 -4
  52. package/dist/agents/redux/agent-settings/agentSettingsSlice.js +12 -5
  53. package/dist/agents/redux/execution-system/host-conversations/host-conversation.thunks.d.ts +4 -1
  54. package/dist/agents/redux/execution-system/host-conversations/host-conversation.thunks.js +45 -0
  55. package/dist/agents/redux/execution-system/inbox/inbox-turn-end.middleware.js +2 -1
  56. package/dist/agents/redux/execution-system/instance-ui-state/run-configuration-persist.js +2 -0
  57. package/dist/agents/redux/execution-system/messages/messages.selectors.js +1 -1
  58. package/dist/agents/redux/execution-system/thunks/execute-instance.thunk.js +6 -0
  59. package/dist/agents/redux/execution-system/thunks/process-stream.js +25 -12
  60. package/dist/agents/redux/execution-system/thunks/run-headless-agent-json.d.ts +2 -0
  61. package/dist/agents/redux/execution-system/thunks/run-headless-agent-json.js +25 -4
  62. package/dist/agents/redux/execution-system/utils/assemble-cx-content-blocks.js +2 -1
  63. package/dist/agents/redux/execution-system/utils/inbound-render-block.d.ts +8 -0
  64. package/dist/agents/redux/execution-system/utils/inbound-render-block.js +17 -2
  65. package/dist/agents/redux/execution-system/utils/normalize-content-blocks.js +1 -1
  66. package/dist/agents/redux/execution-system/utils/progress-data-block.d.ts +11 -0
  67. package/dist/agents/redux/execution-system/utils/progress-data-block.js +37 -0
  68. package/dist/agents/redux/execution-system/utils/stream-block-accumulator.js +10 -8
  69. package/dist/agents/redux/mcp/mcp.slice.js +15 -7
  70. package/dist/agents/redux/tools/tools.thunks.js +3 -0
  71. package/dist/agents/runtime-reconnect/ServerOperationBanner.d.ts +6 -1
  72. package/dist/agents/runtime-reconnect/ServerOperationBanner.js +6 -1
  73. package/dist/agents/runtime-reconnect/reconnect-server-operation.thunk.js +10 -6
  74. package/dist/agents/ui-first-tools/ui/ApprovalCard.js +1 -1
  75. package/dist/agents/ui-first-tools/ui/AskCard.js +1 -1
  76. package/dist/agents/ui-first-tools/ui/lists/TaskPanel.js +1 -1
  77. package/dist/conversation/hooks/useDomCapturePrint.js +1 -1
  78. package/dist/conversation/utils/markdown-print.js +1 -1
  79. package/dist/cx-chat/components/messages/AssistantMessage.js +3 -5
  80. package/dist/cx-conversation/AssistantMessage.js +3 -5
  81. package/dist/host/app-data-slots.d.ts +85 -0
  82. package/dist/host/app-data-slots.js +42 -0
  83. package/dist/host/bare-host-chrome.js +1 -0
  84. package/dist/host/defaults/prefs.d.ts +19 -0
  85. package/dist/host/defaults/prefs.js +52 -0
  86. package/dist/host/defaults/workspace-gate.js +2 -1
  87. package/dist/host/index.d.ts +1 -1
  88. package/dist/host/index.js +2 -1
  89. package/dist/host/react.js +16 -1
  90. package/dist/host/source.d.ts +21 -0
  91. package/dist/host/ui-slots.d.ts +1 -23
  92. package/dist/host/ui-slots.js +0 -34
  93. package/dist/public-chat/components/PublicMessageOptionsMenu.js +2 -1
  94. package/dist/surfaces/redux/surfaceConfigSlice.js +2 -0
  95. package/dist/surfaces/redux/userStateSlice.js +3 -1
  96. package/dist/surfaces/runtime/agent-offer.js +1 -1
  97. package/dist/surfaces/runtime/surface-writeback.js +1 -1
  98. package/dist/tool-call-visualization/db-renderer/fetchToolRendererRow.js +2 -0
  99. package/dist/tool-call-visualization/renderers/agent-call/AgentCallInline.js +1 -1
  100. package/dist/tool-call-visualization/renderers/agent-call/CollabCallCard.js +1 -1
  101. package/dist/tool-call-visualization/renderers/fs/FsInline.js +1 -1
  102. package/dist/tool-call-visualization/renderers/random-wheel/RandomWheelInline.js +1 -1
  103. package/dist/tool-call-visualization/renderers/research/ResearchOverlay.js +4 -4
  104. package/dist/tool-call-visualization/renderers/research/SubagentReportBlock.js +2 -2
  105. package/dist/tool-call-visualization/renderers/scrape/ScrapeOverlay.js +1 -1
  106. package/dist/tool-call-visualization/renderers/search/SearchInline.js +1 -1
  107. package/dist/tool-call-visualization/renderers/search/SearchOverlay.js +1 -1
  108. package/dist/tool-call-visualization/renderers/sql/SqlInline.js +1 -1
  109. package/dist/tool-call-visualization/result-fields/KeyValueGrid.js +1 -1
  110. package/dist/tool-call-visualization/result-fields/ResultMarkdown.js +1 -1
  111. package/dist/tool-call-visualization/result-fields/ResultValue.js +1 -1
  112. package/dist/tool-call-visualization/surface-write/SurfaceWriteDiff.js +1 -1
  113. package/dist/ui/AudioOutputBlockSkeleton.d.ts +17 -0
  114. package/dist/ui/AudioOutputBlockSkeleton.js +78 -0
  115. package/dist/ui/chat-protocol-from-stream.d.ts +60 -0
  116. package/dist/ui/chat-protocol-from-stream.js +135 -0
  117. package/dist/ui/markdown-stream/EnhancedChatMarkdown.d.ts +59 -0
  118. package/dist/ui/markdown-stream/EnhancedChatMarkdown.js +1108 -0
  119. package/dist/ui/markdown-stream/MarkdownStream.d.ts +88 -0
  120. package/dist/ui/markdown-stream/MarkdownStream.js +14 -0
  121. package/dist/ui/markdown-stream/MarkdownStreamImpl.d.ts +4 -0
  122. package/dist/ui/markdown-stream/MarkdownStreamImpl.js +86 -0
  123. package/dist/ui/markdown-stream/StreamAwareChatMarkdown.d.ts +58 -0
  124. package/dist/ui/markdown-stream/StreamAwareChatMarkdown.js +294 -0
  125. package/dist/ui/markdown-stream/internal-handlers/AgentCallChildTrace.d.ts +22 -0
  126. package/dist/ui/markdown-stream/internal-handlers/AgentCallChildTrace.js +128 -0
  127. package/dist/ui/markdown-stream/internal-handlers/InlineAssistantError.d.ts +3 -0
  128. package/dist/ui/markdown-stream/internal-handlers/InlineAssistantError.js +26 -0
  129. package/dist/ui/markdown-stream/internal-handlers/InlineThinkingSlot.d.ts +14 -0
  130. package/dist/ui/markdown-stream/internal-handlers/InlineThinkingSlot.js +23 -0
  131. package/dist/ui/markdown-stream/internal-handlers/ToolHandlers.d.ts +42 -0
  132. package/dist/ui/markdown-stream/internal-handlers/ToolHandlers.js +109 -0
  133. package/dist/ui/markdown-stream/useBoundAgentOutputSchema.d.ts +2 -0
  134. package/dist/ui/markdown-stream/useBoundAgentOutputSchema.js +33 -0
  135. package/dist/window-panels/windows/agents/AgentAssistantMarkdownDebugWindow.js +1 -1
  136. package/package.json +10 -8
  137. package/dist/host/content-ir-slots.d.ts +0 -235
  138. package/dist/host/content-ir-slots.js +0 -135
  139. package/dist/host/markdown-slots.d.ts +0 -53
  140. package/dist/host/markdown-slots.js +0 -32
  141. package/dist/host/rich-document-slots.d.ts +0 -123
  142. package/dist/host/rich-document-slots.js +0 -36
  143. package/dist/utils/content-ir/report-kind-at-raw-renderer.d.ts +0 -19
  144. package/dist/utils/content-ir/report-kind-at-raw-renderer.js +0 -32
@@ -4,7 +4,7 @@ import React from "react";
4
4
  import { ChevronRight, File, Folder, FolderOpen } from "lucide-react";
5
5
  import { formatFileSize } from "@ai-matrx/kit/format";
6
6
  import { cn } from "@ai-matrx/design-system";
7
- import { BasicMarkdownContent } from "../../../host/markdown-slots.js";
7
+ import { BasicMarkdownContent } from "@ai-matrx/rich-content/display/chat-markdown/BasicMarkdownContent";
8
8
  import { getArg, isTerminal, resultAsObject } from "../_shared.js";
9
9
  import { GenericRenderer } from "../../registry/GenericRenderer.js";
10
10
  import { ToolErrorCard } from "../../result-fields/ToolErrorCard.js";
@@ -22,7 +22,7 @@ import {
22
22
  import { useAppDispatch } from "../../../store/hooks.js";
23
23
  import { cn } from "@ai-matrx/design-system";
24
24
  import { setContextEntry } from "../../../agents/redux/execution-system/instance-context/instance-context.slice.js";
25
- import { BasicMarkdownContent } from "../../../host/markdown-slots.js";
25
+ import { BasicMarkdownContent } from "@ai-matrx/rich-content/display/chat-markdown/BasicMarkdownContent";
26
26
  import { filterStepEvents, isTerminal, resultAsObject } from "../_shared.js";
27
27
  import { ErrorAlchemyMenu } from "../../../host/ui-slots.js";
28
28
  const SPIN_FULL_TURNS = 6;
@@ -12,10 +12,7 @@ import {
12
12
  Link2
13
13
  } from "lucide-react";
14
14
  import { cn } from "@ai-matrx/design-system";
15
- import { RichContent } from "../../../host/ui-slots.js";
16
- import { copyRichContent } from "../../../host/ui-slots.js";
17
- import { RichDocument } from "../../../host/ui-slots.js";
18
- import { BasicMarkdownContent } from "../../../host/markdown-slots.js";
15
+ import { BasicMarkdownContent } from "@ai-matrx/rich-content/display/chat-markdown/BasicMarkdownContent";
19
16
  import { resultAsString } from "../_shared.js";
20
17
  import {
21
18
  parseSearch,
@@ -23,6 +20,9 @@ import {
23
20
  getDomain
24
21
  } from "../search/parseSearch.js";
25
22
  import { Button } from "@ai-matrx/design-system/controls";
23
+ import { RichContent } from "@ai-matrx/rich-content/levels/RichContent";
24
+ import { copyRichContent } from "@ai-matrx/rich-content/copy/copy-commands";
25
+ import { RichDocument } from "@ai-matrx/rich-content/rich-document/RichDocument";
26
26
  const Favicon = ({ url, className }) => {
27
27
  const [failed, setFailed] = useState(false);
28
28
  const src = url ? getFaviconUrl(url) : "";
@@ -10,10 +10,10 @@ import {
10
10
  Minimize2
11
11
  } from "lucide-react";
12
12
  import { cn } from "@ai-matrx/design-system";
13
- import { RichContent } from "../../../host/ui-slots.js";
14
- import { RichDocument } from "../../../host/ui-slots.js";
15
13
  import { useAutoScrollOnStream } from "../useAutoScrollOnStream.js";
16
14
  import { AGENT_ICON } from "@ai-matrx/icons/domain";
15
+ import { RichContent } from "@ai-matrx/rich-content/levels/RichContent";
16
+ import { RichDocument } from "@ai-matrx/rich-content/rich-document/RichDocument";
17
17
  const PARTIAL_MAX_PX = 400;
18
18
  const SubagentReportBlock = ({
19
19
  report,
@@ -10,7 +10,7 @@ import {
10
10
  } from "lucide-react";
11
11
  import { cn } from "@ai-matrx/design-system";
12
12
  import { InlineMediaRef } from "@ai-matrx/media/react";
13
- import { BasicMarkdownContent } from "../../../host/markdown-slots.js";
13
+ import { BasicMarkdownContent } from "@ai-matrx/rich-content/display/chat-markdown/BasicMarkdownContent";
14
14
  import { getFaviconUrl } from "../search/parseSearch.js";
15
15
  import { parseScrape } from "./parseScrape.js";
16
16
  import { AGENT_ICON } from "@ai-matrx/icons/domain";
@@ -10,7 +10,7 @@ import {
10
10
  BookOpen
11
11
  } from "lucide-react";
12
12
  import { cn } from "@ai-matrx/design-system";
13
- import { BasicMarkdownContent } from "../../../host/markdown-slots.js";
13
+ import { BasicMarkdownContent } from "@ai-matrx/rich-content/display/chat-markdown/BasicMarkdownContent";
14
14
  import { useAppSelector } from "../../../store/hooks.js";
15
15
  import { useOpenScraperWindow } from "../../../host/window-openers.js";
16
16
  import { selectIsLatestToolActivity } from "../../../agents/redux/execution-system/active-requests/active-requests.selectors.js";
@@ -12,7 +12,7 @@ import {
12
12
  Lightbulb
13
13
  } from "lucide-react";
14
14
  import { cn } from "@ai-matrx/design-system";
15
- import { BasicMarkdownContent } from "../../../host/markdown-slots.js";
15
+ import { BasicMarkdownContent } from "@ai-matrx/rich-content/display/chat-markdown/BasicMarkdownContent";
16
16
  import { PartPeekPopover } from "../_shared-entity/PartPeekPopover.js";
17
17
  import { resultAsString } from "../_shared.js";
18
18
  import {
@@ -7,7 +7,7 @@ import {
7
7
  CollapsibleContent,
8
8
  CollapsibleTrigger
9
9
  } from "@ai-matrx/design-system";
10
- import { BasicMarkdownContent } from "../../../host/markdown-slots.js";
10
+ import { BasicMarkdownContent } from "@ai-matrx/rich-content/display/chat-markdown/BasicMarkdownContent";
11
11
  import { getArg, isTerminal, resultAsObject } from "../_shared.js";
12
12
  import { ResultValue } from "../../result-fields/ResultValue.js";
13
13
  import { ToolResultValue } from "../../result-fields/ToolResultValue.js";
@@ -16,7 +16,7 @@ import {
16
16
  } from "./document-presentation.js";
17
17
  import { KindValueNode } from "./KindValueNode.js";
18
18
  import { rootKindSlug } from "../../utils/content-ir/surfaces/json-kind-signal.js";
19
- import { useReportKindAtRawRenderer } from "../../utils/content-ir/report-kind-at-raw-renderer.js";
19
+ import { useReportKindAtRawRenderer } from "@ai-matrx/rich-content/utils/report-kind-at-raw-renderer";
20
20
  import { humanizeIdentifier } from "@ai-matrx/kit/text-case";
21
21
  import { Button } from "@ai-matrx/design-system/controls";
22
22
  const INLINE_ENTRY_CAP = 8;
@@ -2,7 +2,7 @@
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import React from "react";
4
4
  import { ChevronDown, ChevronUp } from "lucide-react";
5
- import { BasicMarkdownContent } from "../../host/markdown-slots.js";
5
+ import { BasicMarkdownContent } from "@ai-matrx/rich-content/display/chat-markdown/BasicMarkdownContent";
6
6
  import { Collapsible, CollapsibleContent } from "@ai-matrx/design-system";
7
7
  import { cn } from "@ai-matrx/design-system";
8
8
  import { Button } from "@ai-matrx/design-system/controls";
@@ -17,7 +17,7 @@ import { KindValueNode } from "./KindValueNode.js";
17
17
  import { ResultRecordRef } from "./ResultRecordRef.js";
18
18
  import { TextWithDoors } from "../../host/ui-slots.js";
19
19
  import { valueCarriesKind } from "../../utils/content-ir/surfaces/json-kind-signal.js";
20
- import { useReportKindAtRawRenderer } from "../../utils/content-ir/report-kind-at-raw-renderer.js";
20
+ import { useReportKindAtRawRenderer } from "@ai-matrx/rich-content/utils/report-kind-at-raw-renderer";
21
21
  import { Button } from "@ai-matrx/design-system/controls";
22
22
  const INLINE_MAX_DEPTH = 2;
23
23
  const INLINE_ROW_CAP = 3;
@@ -7,7 +7,6 @@ import {
7
7
  LARGE_INPUT_CHARS,
8
8
  TextDiff
9
9
  } from "@ai-matrx/diff/react";
10
- import { RichContent } from "../../host/ui-slots.js";
11
10
  import { useIsMobile } from "@ai-matrx/kit/media-query";
12
11
  import { useSessionKnob } from "../../host/prefs-react.js";
13
12
  import { cn } from "@ai-matrx/design-system";
@@ -16,6 +15,7 @@ import {
16
15
  diffLanguageOf
17
16
  } from "./readSurfaceWrite.js";
18
17
  import { formatCount } from "@ai-matrx/kit/format";
18
+ import { RichContent } from "@ai-matrx/rich-content/levels/RichContent";
19
19
  function viewFromKnob(value) {
20
20
  if (value === "split") return "split";
21
21
  if (value === "changes") return "highlight";
@@ -0,0 +1,17 @@
1
+ /**
2
+ * components/mardown-display/blocks/audio/AudioOutputBlockSkeleton.tsx
3
+ *
4
+ * The loading twin of `<AudioOutputBlock>` (landscape layout). Same outer
5
+ * card, same dimensions, same internal grid — so when generation finishes and
6
+ * the real player mounts, NOTHING shifts. Use this anywhere an audio response
7
+ * is being generated/resolved instead of a bare "Generating audio…" line.
8
+ *
9
+ * Purely presentational; no audio engine, no file actions.
10
+ */
11
+ import React from "react";
12
+ export interface AudioOutputBlockSkeletonProps {
13
+ /** Status line shown next to the shimmer. Default "Generating audio…". */
14
+ label?: string;
15
+ }
16
+ declare const AudioOutputBlockSkeleton: React.FC<AudioOutputBlockSkeletonProps>;
17
+ export default AudioOutputBlockSkeleton;
@@ -0,0 +1,78 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { Music } from "lucide-react";
4
+ function Bar({ className = "" }) {
5
+ return /* @__PURE__ */ jsx("div", { className: `rounded-full bg-muted/70 animate-pulse ${className}` });
6
+ }
7
+ const AudioOutputBlockSkeleton = ({
8
+ label = "Generating audio\u2026"
9
+ }) => {
10
+ return /* @__PURE__ */ jsxs(
11
+ "div",
12
+ {
13
+ className: "relative rounded-xl border border-border bg-card p-4 my-2 shadow-sm overflow-hidden",
14
+ role: "status",
15
+ "aria-label": label,
16
+ children: [
17
+ /* @__PURE__ */ jsx("div", { className: "pointer-events-none absolute inset-0 animate-[audio-shimmer_1.6s_ease-in-out_infinite] bg-gradient-to-r from-transparent via-primary/10 to-transparent" }),
18
+ /* @__PURE__ */ jsxs("div", { className: "relative flex gap-4 items-start", children: [
19
+ /* @__PURE__ */ jsx("div", { className: "w-16 h-16 rounded-xl flex-shrink-0 bg-gradient-to-br from-[hsl(var(--primary)/0.15)] to-[hsl(var(--secondary)/0.15)] border border-border flex items-center justify-center", children: /* @__PURE__ */ jsx(
20
+ Music,
21
+ {
22
+ size: 24,
23
+ className: "text-primary/60 animate-pulse",
24
+ strokeWidth: 1.5
25
+ }
26
+ ) }),
27
+ /* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0", children: [
28
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between mb-2", children: [
29
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1 space-y-1.5", children: [
30
+ /* @__PURE__ */ jsx(Bar, { className: "h-3 w-2/3" }),
31
+ /* @__PURE__ */ jsx(Bar, { className: "h-2.5 w-1/3" })
32
+ ] }),
33
+ /* @__PURE__ */ jsx("div", { className: "flex items-end gap-[2px] h-5 w-8", "aria-hidden": true, children: [60, 90, 45, 75].map((h, i) => /* @__PURE__ */ jsx(
34
+ "span",
35
+ {
36
+ className: "w-[3px] rounded-full bg-primary/50 animate-pulse",
37
+ style: { height: `${h}%` }
38
+ },
39
+ i
40
+ )) })
41
+ ] }),
42
+ /* @__PURE__ */ jsxs("div", { className: "mb-2", children: [
43
+ /* @__PURE__ */ jsx(Bar, { className: "h-1.5 w-full" }),
44
+ /* @__PURE__ */ jsxs("div", { className: "flex justify-between mt-1", children: [
45
+ /* @__PURE__ */ jsx(Bar, { className: "h-2 w-8" }),
46
+ /* @__PURE__ */ jsx(Bar, { className: "h-2 w-8" })
47
+ ] })
48
+ ] }),
49
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
50
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
51
+ /* @__PURE__ */ jsx(Bar, { className: "h-7 w-7 !rounded-full" }),
52
+ /* @__PURE__ */ jsx(Bar, { className: "h-9 w-9 !rounded-full bg-primary/30" }),
53
+ /* @__PURE__ */ jsx(Bar, { className: "h-7 w-7 !rounded-full" }),
54
+ /* @__PURE__ */ jsx(Bar, { className: "h-7 w-7 !rounded-full" })
55
+ ] }),
56
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 w-28", children: [
57
+ /* @__PURE__ */ jsx(Bar, { className: "h-4 w-4 !rounded-full" }),
58
+ /* @__PURE__ */ jsx(Bar, { className: "h-1.5 flex-1" })
59
+ ] })
60
+ ] }),
61
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 mt-2 pt-2 border-t border-border", children: [
62
+ /* @__PURE__ */ jsx(Bar, { className: "h-4 w-20" }),
63
+ /* @__PURE__ */ jsx(Bar, { className: "h-4 w-16" }),
64
+ /* @__PURE__ */ jsxs("span", { className: "ml-auto inline-flex items-center gap-1.5 text-[11px] text-muted-foreground", children: [
65
+ /* @__PURE__ */ jsx(Music, { size: 11, className: "text-primary/60" }),
66
+ label
67
+ ] })
68
+ ] })
69
+ ] })
70
+ ] })
71
+ ]
72
+ }
73
+ );
74
+ };
75
+ var AudioOutputBlockSkeleton_default = AudioOutputBlockSkeleton;
76
+ export {
77
+ AudioOutputBlockSkeleton_default as default
78
+ };
@@ -0,0 +1,60 @@
1
+ /**
2
+ * lib/chat-protocol/from-stream.ts
3
+ *
4
+ * Converts raw TypedStreamEvent arrays into CanonicalBlock[] / StreamingState.
5
+ *
6
+ * DESIGN PRINCIPLES
7
+ * ─────────────────
8
+ * • Zero platform deps — pure TypeScript, no JSX, no React.
9
+ * • Single source of truth — all stream-to-canonical logic lives here.
10
+ * • Immutable output — every returned object is readonly.
11
+ * • Event engine stays here — no consumer should pick through TypedStreamEvent[].
12
+ *
13
+ * STREAM CONTRACT (backend ToolEventPayload.event values)
14
+ * ────────────────────────────────────────────────────────
15
+ * tool_started → creates ToolCallBlock (phase: 'running')
16
+ * tool_progress → appends ToolProgress to existing block
17
+ * tool_step → appends ToolProgress to existing block
18
+ * tool_result_preview → appends ToolProgress to existing block
19
+ * tool_completed → sets output, phase: 'complete'
20
+ * tool_error → sets error, phase: 'error'
21
+ * chunk → appends to / creates TextBlock
22
+ * reasoning_chunk → appends to / creates ThinkingBlock
23
+ * error → creates ErrorBlock
24
+ */
25
+ import type { TypedStreamEvent } from "@ai-matrx/agents/generated/stream-events";
26
+ import type { CanonicalBlock, ToolCallBlock, StreamingState, CanonicalMessage, MessageStatus } from "./chat-protocol-types.js";
27
+ /**
28
+ * Incrementally converts a stream of StreamEvents into an ordered array of
29
+ * canonical blocks.
30
+ *
31
+ * Call this once on a complete array, or call it progressively in real time
32
+ * (the function is pure and O(n) — safe to call on every new event batch).
33
+ */
34
+ export declare function buildCanonicalBlocks(events: TypedStreamEvent[]): CanonicalBlock[];
35
+ /**
36
+ * Build a live StreamingState from the events received so far.
37
+ *
38
+ * This is a pure function — call it on every new event batch during streaming.
39
+ * The output is immutable and safe to pass directly to renderers.
40
+ */
41
+ export declare function buildStreamingState(events: TypedStreamEvent[]): StreamingState;
42
+ /**
43
+ * Extract the persistable subset of tool blocks from a completed stream.
44
+ *
45
+ * Progress notifications are stripped — only the final input/output/error
46
+ * state needs to be stored in the DB.
47
+ */
48
+ export declare function extractPersistableToolBlocks(events: TypedStreamEvent[]): ReadonlyArray<ToolCallBlock>;
49
+ /**
50
+ * Build a complete CanonicalMessage from a finished stream.
51
+ *
52
+ * Typically called in the `onComplete` callback of a streaming hook,
53
+ * immediately before the message is persisted and the stream events cleared.
54
+ */
55
+ export declare function buildCanonicalMessageFromStream(params: {
56
+ id: string;
57
+ timestamp?: Date;
58
+ status?: MessageStatus;
59
+ events: TypedStreamEvent[];
60
+ }): CanonicalMessage;
@@ -0,0 +1,135 @@
1
+ import { PROTOCOL_VERSION } from "./chat-protocol-types.js";
2
+ import { streamErrorText } from "@ai-matrx/agents/matrx";
3
+ function buildCanonicalBlocks(events) {
4
+ const blocks = [];
5
+ const toolIndex = /* @__PURE__ */ new Map();
6
+ function getOrCreateToolBlock(callId, toolName) {
7
+ const existingIdx = toolIndex.get(callId);
8
+ if (existingIdx !== void 0) return existingIdx;
9
+ const idx = blocks.length;
10
+ blocks.push({
11
+ type: "tool_call",
12
+ callId,
13
+ toolName,
14
+ input: { name: toolName, arguments: {} },
15
+ progress: [],
16
+ phase: "pending"
17
+ });
18
+ toolIndex.set(callId, idx);
19
+ return idx;
20
+ }
21
+ for (const event of events) {
22
+ if (event.event === "chunk") {
23
+ const text = event.data.text;
24
+ if (!text) continue;
25
+ const last = blocks[blocks.length - 1];
26
+ if (last && last.type === "text") {
27
+ last.content += text;
28
+ } else {
29
+ blocks.push({ type: "text", content: text });
30
+ }
31
+ continue;
32
+ }
33
+ if (event.event === "reasoning_chunk") {
34
+ const text = event.data.text;
35
+ if (!text) continue;
36
+ const last = blocks[blocks.length - 1];
37
+ if (last && last.type === "thinking") {
38
+ last.content += text;
39
+ } else {
40
+ blocks.push({ type: "thinking", content: text });
41
+ }
42
+ continue;
43
+ }
44
+ if (event.event === "tool_event") {
45
+ const te = event.data;
46
+ const { call_id: callId, tool_name: toolName, message } = te;
47
+ const data = te.data ?? {};
48
+ switch (te.event) {
49
+ case "tool_started": {
50
+ const idx = getOrCreateToolBlock(callId, toolName);
51
+ const tb = blocks[idx];
52
+ const args = data.arguments;
53
+ tb.input = {
54
+ name: toolName,
55
+ arguments: args && typeof args === "object" && !Array.isArray(args) ? args : {}
56
+ };
57
+ tb.phase = "running";
58
+ if (message) tb.progress.push({ message });
59
+ break;
60
+ }
61
+ case "tool_progress":
62
+ case "tool_step":
63
+ case "tool_result_preview": {
64
+ const idx = getOrCreateToolBlock(callId, toolName);
65
+ const tb = blocks[idx];
66
+ if (message) tb.progress.push({ message });
67
+ break;
68
+ }
69
+ case "tool_completed": {
70
+ const idx = getOrCreateToolBlock(callId, toolName);
71
+ const tb = blocks[idx];
72
+ tb.output = {
73
+ status: "success",
74
+ result: data.result ?? data
75
+ };
76
+ tb.phase = "complete";
77
+ if (message) tb.progress.push({ message });
78
+ break;
79
+ }
80
+ case "tool_error": {
81
+ const idx = getOrCreateToolBlock(callId, toolName);
82
+ const tb = blocks[idx];
83
+ tb.error = { message: message ?? "Tool execution failed" };
84
+ tb.phase = "error";
85
+ break;
86
+ }
87
+ }
88
+ continue;
89
+ }
90
+ if (event.event === "error") {
91
+ const err = event.data;
92
+ blocks.push({
93
+ type: "error",
94
+ errorType: err.error_type,
95
+ message: streamErrorText(event) ?? err.message
96
+ });
97
+ continue;
98
+ }
99
+ }
100
+ return blocks;
101
+ }
102
+ function buildStreamingState(events) {
103
+ const blocks = buildCanonicalBlocks(events);
104
+ const hasEnd = events.some((e) => e.event === "end");
105
+ const hasError = events.some((e) => e.event === "error");
106
+ const isLive = !hasEnd && !hasError;
107
+ const streamError = blocks.find((b) => b.type === "error");
108
+ return {
109
+ blocks,
110
+ isLive,
111
+ streamError
112
+ };
113
+ }
114
+ function extractPersistableToolBlocks(events) {
115
+ const blocks = buildCanonicalBlocks(events);
116
+ return blocks.filter((b) => b.type === "tool_call");
117
+ }
118
+ function buildCanonicalMessageFromStream(params) {
119
+ const { id, timestamp = /* @__PURE__ */ new Date(), status = "complete", events } = params;
120
+ return {
121
+ id,
122
+ role: "assistant",
123
+ timestamp,
124
+ status,
125
+ isCondensed: false,
126
+ blocks: buildCanonicalBlocks(events),
127
+ schemaVersion: PROTOCOL_VERSION
128
+ };
129
+ }
130
+ export {
131
+ buildCanonicalBlocks,
132
+ buildCanonicalMessageFromStream,
133
+ buildStreamingState,
134
+ extractPersistableToolBlocks
135
+ };
@@ -0,0 +1,59 @@
1
+ import type { AnswerEditRemarkMeta } from "../../agents/redux/execution-system/instance-resources/remarks.js";
2
+ import React from "react";
3
+ /** Server-processed block from the content_block protocol. */
4
+ export interface ServerProcessedBlock {
5
+ blockId: string;
6
+ blockIndex: number;
7
+ type: string;
8
+ status: "streaming" | "complete" | "error";
9
+ content?: string | null;
10
+ data?: Record<string, unknown> | null;
11
+ metadata?: Record<string, unknown>;
12
+ }
13
+ export interface ChatMarkdownDisplayProps {
14
+ requestId?: string;
15
+ /**
16
+ * Every committed row this render stands for, in transcript order, when a
17
+ * multi-iteration turn renders as ONE member (its last row is `messageId`).
18
+ * Settled, the turn renders every row's record — each as its own run, so
19
+ * grouping and folding match a per-row reload.
20
+ */
21
+ recordMessageIds?: readonly string[];
22
+ streamSlotStart?: number;
23
+ streamSlotEnd?: number;
24
+ /**
25
+ * Render ONE collaboration `agent_call` child's live blocks from `requestId`
26
+ * (the parent request it streams inside) — the call id of the owning card.
27
+ * Its blocks go through the normal BlockRenderer path, so kinds route as in
28
+ * the parent (`selectAgentCallChildSlots`; the transcript still hides them).
29
+ */
30
+ agentCallId?: string;
31
+ /** Turn ID for DB-loaded turn rendering */
32
+ turnId?: string;
33
+ /** Conversation ID for DB-loaded turn rendering */
34
+ conversationId?: string;
35
+ content: string;
36
+ taskId?: string;
37
+ className?: string;
38
+ isStreamActive?: boolean;
39
+ /**
40
+ * An in-body edit produced the full new text. `previousContent` is the text
41
+ * the edit was applied to (this renderer's current content) — a persisting
42
+ * host diffs the two and splices ONLY the changed span into its stored bytes,
43
+ * because this content is display text (whitespace-normalized, reasoning
44
+ * scrubbed), never the stored row (RC-B5).
45
+ */
46
+ onContentChange?: (newContent: string, previousContent: string, remark?: AnswerEditRemarkMeta) => void;
47
+ analysisData?: Record<string, unknown>;
48
+ messageId?: string;
49
+ allowFullScreenEditor?: boolean;
50
+ hideCopyButton?: boolean;
51
+ /** Pre-processed blocks from server (new content_block protocol). Bypasses client-side parsing. */
52
+ serverProcessedBlocks?: ServerProcessedBlock[];
53
+ /**
54
+ * When false with onContentChange, edits call onContentChange(fullMarkdown) but the
55
+ * rendered document does not switch to local `editedContent` (UI keeps `content` prop).
56
+ */
57
+ applyLocalEdits?: boolean;
58
+ }
59
+ export declare const EnhancedChatMarkdownInternal: React.FC<ChatMarkdownDisplayProps>;