@ai-matrx/chat 0.6.6 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (249) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/README.md +1 -1
  3. package/dist/agents/components/agent-widgets/AgentChatHistorySidebar.js +16 -55
  4. package/dist/agents/components/chat/chat-door.d.ts +67 -0
  5. package/dist/agents/components/chat/chat-door.js +100 -0
  6. package/dist/agents/components/conversation-history/AgentConversationList.d.ts +83 -0
  7. package/dist/agents/components/conversation-history/AgentConversationList.js +252 -0
  8. package/dist/agents/components/conversation-history/ConversationArchiveSection.d.ts +5 -1
  9. package/dist/agents/components/conversation-history/ConversationArchiveSection.js +22 -4
  10. package/dist/agents/components/conversation-history/ConversationHistorySidebar.js +20 -65
  11. package/dist/agents/components/inputs/input-components/TextareaInput.js +2 -0
  12. package/dist/agents/components/inputs/input-components/VariableInputComponent.js +7 -6
  13. package/dist/agents/components/inputs/smart-input/ConversationCompanionPills.d.ts +3 -0
  14. package/dist/agents/components/inputs/smart-input/ConversationCompanionPills.js +40 -0
  15. package/dist/agents/components/inputs/smart-input/ConversationContextRail.js +6 -29
  16. package/dist/agents/components/inputs/smart-input/DeviceToolsModeRow.d.ts +3 -0
  17. package/dist/agents/components/inputs/smart-input/DeviceToolsModeRow.js +35 -0
  18. package/dist/agents/components/inputs/smart-input/InboxQueueStrip.js +0 -8
  19. package/dist/agents/components/inputs/smart-input/RunToolPicker.js +15 -11
  20. package/dist/agents/components/inputs/smart-input/composer/ComposerPlusMenu.js +22 -0
  21. package/dist/agents/components/inputs/smart-input/rail-pill.d.ts +35 -0
  22. package/dist/agents/components/inputs/smart-input/rail-pill.js +30 -0
  23. package/dist/agents/components/inputs/variable-input-variations/AgentVariableForm.js +52 -48
  24. package/dist/agents/components/run-controls/panels/shared.d.ts +1 -1
  25. package/dist/agents/components/shared/AgentModeController.js +3 -2
  26. package/dist/agents/components/shell/AgentRunSidebarMenu.js +15 -54
  27. package/dist/agents/components/working-document/documents-workspace/DocumentsListRail.js +1 -2
  28. package/dist/agents/engine.d.ts +15 -0
  29. package/dist/agents/engine.js +17 -0
  30. package/dist/agents/hooks/useModelControls.js +3 -175
  31. package/dist/agents/redux/agent-definition/selectors.d.ts +237 -237
  32. package/dist/agents/redux/agent-shortcut-categories/selectors.d.ts +50 -50
  33. package/dist/agents/redux/agent-shortcuts/selectors.d.ts +147 -147
  34. package/dist/agents/redux/conversation-history/thunks.js +6 -18
  35. package/dist/agents/redux/conversation-list/conversation-list.selectors.d.ts +1 -73
  36. package/dist/agents/redux/conversation-list/conversation-list.selectors.js +2 -36
  37. package/dist/agents/redux/conversation-list/conversation-list.slice.d.ts +7 -22
  38. package/dist/agents/redux/conversation-list/conversation-list.slice.js +7 -62
  39. package/dist/agents/redux/conversation-list/conversation-list.thunks.d.ts +0 -25
  40. package/dist/agents/redux/conversation-list/conversation-list.thunks.js +2 -58
  41. package/dist/agents/redux/conversation-list/conversation-list.types.d.ts +0 -5
  42. package/dist/agents/redux/conversation-list/conversation-rows.d.ts +16 -0
  43. package/dist/agents/redux/conversation-list/conversation-rows.js +24 -0
  44. package/dist/agents/redux/conversation-list/conversation-trash.thunks.d.ts +1 -0
  45. package/dist/agents/redux/conversation-list/conversation-trash.thunks.js +13 -18
  46. package/dist/agents/redux/execution-system/active-requests/active-requests.selectors.d.ts +54 -54
  47. package/dist/agents/redux/execution-system/context-state/context-state.selectors.d.ts +14 -14
  48. package/dist/agents/redux/execution-system/conversations/conversations.selectors.d.ts +5 -5
  49. package/dist/agents/redux/execution-system/instance-context/instance-context.selectors.d.ts +3 -3
  50. package/dist/agents/redux/execution-system/instance-resources/instance-resources.selectors.d.ts +8 -8
  51. package/dist/agents/redux/execution-system/instance-ui-state/instance-ui-state.selectors.d.ts +5 -5
  52. package/dist/agents/redux/execution-system/instance-variable-values/instance-variable-values.selectors.d.ts +7 -7
  53. package/dist/agents/redux/execution-system/messages/messages.selectors.d.ts +1 -1
  54. package/dist/agents/redux/execution-system/observability/observability.selectors.d.ts +7 -7
  55. package/dist/agents/redux/execution-system/observational-memory/observational-memory.selectors.d.ts +1 -1
  56. package/dist/agents/redux/execution-system/selectors/aggregate.selectors.d.ts +14 -14
  57. package/dist/agents/redux/execution-system/thunks/create-instance.thunk.d.ts +10 -1
  58. package/dist/agents/redux/execution-system/thunks/create-instance.thunk.js +114 -265
  59. package/dist/agents/redux/execution-system/thunks/dispatch-matrx-extend-tool.thunk.js +18 -2
  60. package/dist/agents/redux/execution-system/thunks/dispatch-surface-client-tool.thunk.js +10 -28
  61. package/dist/agents/redux/execution-system/thunks/dispatch-surface-write.thunk.js +10 -25
  62. package/dist/agents/redux/execution-system/thunks/execute-instance.thunk.js +20 -0
  63. package/dist/agents/redux/execution-system/thunks/execute-manual-instance.thunk.js +6 -1
  64. package/dist/agents/redux/execution-system/thunks/notify-and-play-dispatcher.d.ts +58 -0
  65. package/dist/agents/redux/execution-system/thunks/notify-and-play-dispatcher.js +62 -0
  66. package/dist/agents/redux/execution-system/thunks/post-delegated-tool-outcome.d.ts +23 -0
  67. package/dist/agents/redux/execution-system/thunks/post-delegated-tool-outcome.js +37 -0
  68. package/dist/agents/redux/execution-system/thunks/resume-instance.thunk.js +10 -2
  69. package/dist/agents/redux/execution-system/utils/build-tool-injection.d.ts +7 -0
  70. package/dist/agents/redux/execution-system/utils/build-tool-injection.js +18 -6
  71. package/dist/agents/redux/execution-system/utils/host-turn.d.ts +45 -0
  72. package/dist/agents/redux/execution-system/utils/host-turn.js +119 -0
  73. package/dist/agents/redux/proposed-directives/proposedDirectivesSlice.d.ts +1 -1
  74. package/dist/agents/scribe-tools/dispatcher/dispatch-scribe-tool.thunk.d.ts +50 -20
  75. package/dist/agents/scribe-tools/dispatcher/dispatch-scribe-tool.thunk.js +9 -101
  76. package/dist/agents/types/tool-injection.types.d.ts +18 -2
  77. package/dist/agents/ui-first-tools/redux/agent-lists.selectors.d.ts +2 -2
  78. package/dist/agents/ui-first-tools/redux/pending-asks.slice.d.ts +2 -1
  79. package/dist/agents/ui-first-tools/redux/resolve-asks-with-input.thunk.js +1 -1
  80. package/dist/agents/ui-first-tools/tools/ask-response.d.ts +29 -0
  81. package/dist/agents/ui-first-tools/tools/ask-response.js +15 -0
  82. package/dist/agents/ui-first-tools/tools/schemas.d.ts +3 -25
  83. package/dist/agents/ui-first-tools/tools/schemas.js +1 -12
  84. package/dist/agents/ui-first-tools/ui/ApprovalCard.js +1 -1
  85. package/dist/agents/ui-first-tools/ui/AskWizard.d.ts +1 -1
  86. package/dist/agents/ui-first-tools/ui/AskWizard.js +1 -1
  87. package/dist/cx-chat/_legacy-stubs.d.ts +5 -5
  88. package/dist/cx-chat/components/SsrSidebarChats.js +13 -15
  89. package/dist/cx-chat/components/messages/UserMessage.d.ts +2 -2
  90. package/dist/cx-chat/types/conversation.d.ts +6 -6
  91. package/dist/cx-chat/utils/buildContentBlocksForSave.d.ts +1 -1
  92. package/dist/cx-chat/utils/cx-content-converter.d.ts +1 -1
  93. package/dist/host/bare-host-chrome.js +9 -3
  94. package/dist/host/composer-extensions.d.ts +75 -0
  95. package/dist/host/composer-extensions.js +92 -0
  96. package/dist/host/configure.js +1 -0
  97. package/dist/host/contract.d.ts +105 -13
  98. package/dist/host/defaults/confirm.d.ts +15 -0
  99. package/dist/host/defaults/confirm.js +25 -0
  100. package/dist/host/defaults/files-ui.d.ts +85 -0
  101. package/dist/host/defaults/files-ui.js +158 -0
  102. package/dist/host/defaults/gates.d.ts +27 -0
  103. package/dist/host/defaults/gates.js +72 -0
  104. package/dist/host/defaults/media-client.d.ts +15 -0
  105. package/dist/host/defaults/media-client.js +40 -0
  106. package/dist/host/defaults/voice.d.ts +81 -0
  107. package/dist/host/defaults/voice.js +239 -0
  108. package/dist/host/device-tool-handoff.d.ts +26 -0
  109. package/dist/host/device-tool-handoff.js +45 -0
  110. package/dist/host/index.d.ts +1 -0
  111. package/dist/host/index.js +4 -1
  112. package/dist/host/microphone.d.ts +11 -0
  113. package/dist/host/microphone.js +17 -0
  114. package/dist/host/ui-slots.d.ts +29 -74
  115. package/dist/host/ui-slots.js +40 -42
  116. package/dist/store/create-chat-store.d.ts +2 -2
  117. package/dist/store/middlewares.d.ts +5 -5
  118. package/dist/store/slices.d.ts +1 -1
  119. package/dist/surfaces/redux/selectors.d.ts +2 -2
  120. package/dist/tool-call-visualization/components/ToolCallVisualization.js +3 -2
  121. package/dist/tool-call-visualization/configured-rows/ConfiguredRowRenderer.d.ts +15 -0
  122. package/dist/tool-call-visualization/configured-rows/ConfiguredRowRenderer.js +36 -0
  123. package/dist/tool-call-visualization/configured-rows/ConfiguredToolRow.d.ts +40 -0
  124. package/dist/tool-call-visualization/configured-rows/ConfiguredToolRow.js +296 -0
  125. package/dist/tool-call-visualization/configured-rows/CopyToolButton.d.ts +23 -0
  126. package/dist/tool-call-visualization/configured-rows/CopyToolButton.js +62 -0
  127. package/dist/tool-call-visualization/configured-rows/ToolProgressView.d.ts +23 -0
  128. package/dist/tool-call-visualization/configured-rows/ToolProgressView.js +147 -0
  129. package/dist/tool-call-visualization/configured-rows/field-components.d.ts +15 -0
  130. package/dist/tool-call-visualization/configured-rows/field-components.js +244 -0
  131. package/dist/tool-call-visualization/configured-rows/helpers.d.ts +39 -0
  132. package/dist/tool-call-visualization/configured-rows/helpers.js +110 -0
  133. package/dist/tool-call-visualization/configured-rows/register.d.ts +25 -0
  134. package/dist/tool-call-visualization/configured-rows/register.js +51 -0
  135. package/dist/tool-call-visualization/configured-rows/registries.d.ts +27 -0
  136. package/dist/tool-call-visualization/configured-rows/registries.js +14 -0
  137. package/dist/tool-call-visualization/configured-rows/to-row-entry.d.ts +8 -0
  138. package/dist/tool-call-visualization/configured-rows/to-row-entry.js +38 -0
  139. package/dist/tool-call-visualization/configured-rows/transforms.d.ts +14 -0
  140. package/dist/tool-call-visualization/configured-rows/transforms.js +30 -0
  141. package/dist/tool-call-visualization/configured-rows/types.d.ts +140 -0
  142. package/dist/tool-call-visualization/redux/selectors.d.ts +1 -1
  143. package/dist/tool-call-visualization/registry/registry.d.ts +1 -1
  144. package/dist/tool-call-visualization/registry/registry.js +8 -1
  145. package/dist/tool-call-visualization/types.d.ts +1 -1
  146. package/dist/ui/chat-protocol-types.d.ts +0 -1
  147. package/dist/ui/ownership.d.ts +25 -0
  148. package/dist/ui/ownership.js +18 -0
  149. package/dist/voice-agent/audio/audioCapture.js +11 -6
  150. package/dist/window-panels/windows/agents/AgentRunHistoryWindow.d.ts +1 -2
  151. package/dist/window-panels/windows/agents/AgentRunHistoryWindow.js +21 -181
  152. package/dist/window-panels/windows/agents/AgentRunWindow.js +26 -13
  153. package/package.json +4627 -125
  154. package/dist/agents/components/agent-widgets/chat-assistant/AssistantMessageCard.d.ts +0 -7
  155. package/dist/agents/components/agent-widgets/chat-assistant/AssistantMessageCard.js +0 -33
  156. package/dist/agents/components/agent-widgets/chat-assistant/StatusCard.d.ts +0 -6
  157. package/dist/agents/components/agent-widgets/chat-assistant/StatusCard.js +0 -21
  158. package/dist/agents/components/agent-widgets/chat-assistant/UserMessageCard.d.ts +0 -6
  159. package/dist/agents/components/agent-widgets/chat-assistant/UserMessageCard.js +0 -11
  160. package/dist/agents/components/agent-widgets/chat-assistant/VariableInputCard.d.ts +0 -12
  161. package/dist/agents/components/agent-widgets/chat-assistant/VariableInputCard.js +0 -7
  162. package/dist/agents/components/agent-widgets/execution-gates/PreExecutionCard.d.ts +0 -4
  163. package/dist/agents/components/agent-widgets/execution-gates/PreExecutionCard.js +0 -81
  164. package/dist/agents/components/run/run-sidebar/SidebarHeader.d.ts +0 -21
  165. package/dist/agents/components/run/run-sidebar/SidebarHeader.js +0 -50
  166. package/dist/agents/components/run-controls/AdvancedRunSettings/index.d.ts +0 -6
  167. package/dist/agents/components/run-controls/AdvancedRunSettings/index.js +0 -32
  168. package/dist/agents/components/run-controls/RunSettingsModal.d.ts +0 -5
  169. package/dist/agents/components/run-controls/RunSettingsModal.js +0 -22
  170. package/dist/agents/components/shell/AgentBuildSidebarExtras.d.ts +0 -6
  171. package/dist/agents/components/shell/AgentBuildSidebarExtras.js +0 -30
  172. package/dist/agents/constants/agent-system-competitors.d.ts +0 -9
  173. package/dist/agents/constants/agent-system-competitors.js +0 -125
  174. package/dist/agents/hooks/message-crud/useMessageActions.d.ts +0 -29
  175. package/dist/agents/hooks/message-crud/useMessageActions.js +0 -119
  176. package/dist/agents/hooks/useConversationPendingCalls.d.ts +0 -30
  177. package/dist/agents/hooks/useConversationPendingCalls.js +0 -42
  178. package/dist/agents/model-registry/model-classes.d.ts +0 -1
  179. package/dist/agents/model-registry/model-classes.js +0 -1
  180. package/dist/agents/redux/conversation-history/index.d.ts +0 -18
  181. package/dist/agents/redux/conversation-history/index.js +0 -4
  182. package/dist/agents/redux/execution-system/instance-variable-values/instance-variable-values.thunks.d.ts +0 -38
  183. package/dist/agents/redux/execution-system/instance-variable-values/instance-variable-values.thunks.js +0 -42
  184. package/dist/agents/redux/execution-system/message-crud/server/compact-turns.thunk.d.ts +0 -58
  185. package/dist/agents/redux/execution-system/message-crud/server/compact-turns.thunk.js +0 -50
  186. package/dist/agents/redux/execution-system/message-crud/server/fork-and-run-server.thunk.d.ts +0 -76
  187. package/dist/agents/redux/execution-system/message-crud/server/fork-and-run-server.thunk.js +0 -101
  188. package/dist/agents/redux/execution-system/thunks/attach-workflow-run.d.ts +0 -38
  189. package/dist/agents/redux/execution-system/thunks/attach-workflow-run.js +0 -25
  190. package/dist/agents/redux/execution-system/utils/source-slice-helpers.d.ts +0 -45
  191. package/dist/agents/redux/execution-system/utils/source-slice-helpers.js +0 -50
  192. package/dist/agents/runtime/realtime/launchRealtimeSession.thunk.d.ts +0 -25
  193. package/dist/agents/runtime/realtime/launchRealtimeSession.thunk.js +0 -15
  194. package/dist/agents/services/agentService.d.ts +0 -12
  195. package/dist/agents/services/agentService.js +0 -92
  196. package/dist/agents/utils/escape-code-fences.d.ts +0 -15
  197. package/dist/agents/utils/escape-code-fences.js +0 -9
  198. package/dist/agents/utils/normalize-managed-options.d.ts +0 -30
  199. package/dist/agents/utils/normalize-managed-options.js +0 -29
  200. package/dist/agents/utils/processedDocumentContext.d.ts +0 -51
  201. package/dist/agents/utils/processedDocumentContext.js +0 -51
  202. package/dist/agents/utils/variable-validation.d.ts +0 -28
  203. package/dist/agents/utils/variable-validation.js +0 -54
  204. package/dist/cx-chat/components/ChatConversationSkeleton.d.ts +0 -9
  205. package/dist/cx-chat/components/ChatConversationSkeleton.js +0 -45
  206. package/dist/cx-chat/components/ChatPanelBackButton.d.ts +0 -1
  207. package/dist/cx-chat/components/ChatPanelBackButton.js +0 -26
  208. package/dist/cx-chat/components/messages/MessageErrorBoundary.d.ts +0 -20
  209. package/dist/cx-chat/components/messages/MessageErrorBoundary.js +0 -40
  210. package/dist/cx-chat/components/variable-inputs/CheckboxGroupInput.d.ts +0 -14
  211. package/dist/cx-chat/components/variable-inputs/CheckboxGroupInput.js +0 -160
  212. package/dist/cx-chat/components/variable-inputs/NumberInput.d.ts +0 -15
  213. package/dist/cx-chat/components/variable-inputs/NumberInput.js +0 -79
  214. package/dist/cx-chat/components/variable-inputs/RadioGroupInput.d.ts +0 -14
  215. package/dist/cx-chat/components/variable-inputs/RadioGroupInput.js +0 -125
  216. package/dist/cx-chat/components/variable-inputs/SelectInput.d.ts +0 -14
  217. package/dist/cx-chat/components/variable-inputs/SelectInput.js +0 -92
  218. package/dist/cx-chat/components/variable-inputs/TextareaInput.d.ts +0 -14
  219. package/dist/cx-chat/components/variable-inputs/TextareaInput.js +0 -46
  220. package/dist/cx-chat/components/variable-inputs/ToggleInput.d.ts +0 -14
  221. package/dist/cx-chat/components/variable-inputs/ToggleInput.js +0 -46
  222. package/dist/cx-chat/hooks/useChatPersistence.d.ts +0 -28
  223. package/dist/cx-chat/hooks/useChatPersistence.js +0 -180
  224. package/dist/cx-chat/hooks/useInstanceBootstrap.d.ts +0 -1
  225. package/dist/cx-chat/hooks/useInstanceBootstrap.js +0 -115
  226. package/dist/cx-chat/types/content.d.ts +0 -184
  227. package/dist/cx-chat/types/content.js +0 -91
  228. package/dist/cx-chat/types/cx-tables.d.ts +0 -176
  229. package/dist/cx-chat/utils/settings-diff.d.ts +0 -13
  230. package/dist/cx-chat/utils/settings-diff.js +0 -25
  231. package/dist/public-chat/components/AgentSelector.d.ts +0 -22
  232. package/dist/public-chat/components/AgentSelector.js +0 -80
  233. package/dist/public-chat/components/GuidedVariableInputs.d.ts +0 -25
  234. package/dist/public-chat/components/GuidedVariableInputs.js +0 -623
  235. package/dist/public-chat/components/PublicVariableInputs.d.ts +0 -29
  236. package/dist/public-chat/components/PublicVariableInputs.js +0 -172
  237. package/dist/public-chat/types/content.d.ts +0 -184
  238. package/dist/public-chat/types/content.js +0 -91
  239. package/dist/tool-call-visualization/renderers/_shared-entity/EntityOpenActions.d.ts +0 -15
  240. package/dist/tool-call-visualization/renderers/_shared-entity/EntityOpenActions.js +0 -31
  241. package/dist/tool-call-visualization/utils/toolCallBlockToLifecycleEntry.d.ts +0 -24
  242. package/dist/tool-call-visualization/utils/toolCallBlockToLifecycleEntry.js +0 -26
  243. package/dist/ui/AudioOutputBlockSkeleton.d.ts +0 -17
  244. package/dist/ui/AudioOutputBlockSkeleton.js +0 -78
  245. package/dist/ui/lazy/PublicChatVariableInputs.d.ts +0 -2
  246. package/dist/ui/lazy/PublicChatVariableInputs.js +0 -16
  247. package/dist/utils/xml/readXmlTag.d.ts +0 -12
  248. package/dist/utils/xml/readXmlTag.js +0 -66
  249. /package/dist/{cx-chat/types/cx-tables.js → tool-call-visualization/configured-rows/types.js} +0 -0
@@ -0,0 +1,140 @@
1
+ /**
2
+ * Display config shapes for the per-tool registry. Every visual segment is
3
+ * `PhaseAware` so a tool can show different text/icons/colors while running,
4
+ * after success, and after failure (e.g. "Getting X" → "Got X" → "Failed to
5
+ * get X"). All fields are optional — anything left out falls back to the
6
+ * default rendering used by tools that aren't registered at all.
7
+ */
8
+ import type { ComponentType } from 'react';
9
+ /** One incremental update a long-running tool reported (a `tool_progress` event). */
10
+ export interface ToolProgressRow {
11
+ /** Arrival time, ms since epoch. */
12
+ at: number;
13
+ /** Short status line shown to the person. */
14
+ label?: string | undefined;
15
+ /** Named step id: groups updates for checklist display. */
16
+ step?: string | undefined;
17
+ status?: 'pending' | 'active' | 'done' | 'error' | undefined;
18
+ /** 0-1 (fraction) or 0-100 (percent); the view normalizes either. */
19
+ percent?: number | undefined;
20
+ data?: unknown;
21
+ }
22
+ /**
23
+ * What a configured row reads: one tool call in the flat shape the config paths address
24
+ * (`args.x`, `output.y`, `message`). The package folds a `ToolLifecycleEntry` into it
25
+ * (`toRowEntry`); a host with its own call records can build it directly.
26
+ */
27
+ export interface ToolRowEntry {
28
+ callId: string;
29
+ toolName: string;
30
+ startedAt: number;
31
+ endedAt?: number | undefined;
32
+ phase: 'started' | 'completed' | 'error';
33
+ args?: unknown;
34
+ output?: unknown;
35
+ message?: string | undefined;
36
+ progress?: ToolProgressRow[] | undefined;
37
+ }
38
+ export type Phase = 'started' | 'completed' | 'error';
39
+ export type PhaseMap<T> = Partial<Record<Phase, T>>;
40
+ export type PhaseAware<T> = T | PhaseMap<T>;
41
+ export type IconName = string;
42
+ export type ColorToken = 'blue' | 'sky' | 'emerald' | 'amber' | 'red' | 'violet' | 'slate' | 'primary' | 'muted';
43
+ /**
44
+ * Name of a registered value transformer. The generic ones (`titleCase`, `textClean`, `truncate80`, ...)
45
+ * ship with the package; a host adds its own with `registerRowTransforms`.
46
+ */
47
+ export type TransformName = string;
48
+ export interface InfoSpec {
49
+ path: string;
50
+ transform?: TransformName | TransformName[];
51
+ fallback?: string;
52
+ }
53
+ export interface InlineConfig {
54
+ hidden?: PhaseAware<boolean>;
55
+ /**
56
+ * Lucide icon name OR an `InfoSpec` whose path resolves to either:
57
+ * - a lucide icon name (string passed through `transforms` is fine, e.g.
58
+ * `browserCategoryIcon` mapping `args.category` → lucide name)
59
+ * - a URL (http(s):// or data:) — rendered as an `<img>` instead of a
60
+ * lucide component. Useful for favicons.
61
+ * If the resolution returns nothing, falls back to the phase-default icon.
62
+ */
63
+ icon?: PhaseAware<IconName | InfoSpec>;
64
+ prefix?: PhaseAware<string>;
65
+ /**
66
+ * Default: titleCase(toolName). Pass `''` to suppress, a literal string to
67
+ * override, or an `InfoSpec` to pull the name from args/output (e.g. the
68
+ * category passed into `load_chrome_tools`, or the title of the active tab).
69
+ */
70
+ name?: PhaseAware<string | InfoSpec>;
71
+ suffix?: PhaseAware<string>;
72
+ info?: PhaseAware<string | InfoSpec>;
73
+ color?: PhaseAware<ColorToken>;
74
+ isMultiline?: boolean;
75
+ spinIcon?: PhaseAware<boolean>;
76
+ /**
77
+ * Shimmer the label while phase is `started`. Default: true. Set false to
78
+ * suppress (e.g. very fast tools where the shimmer is overkill).
79
+ */
80
+ shimmerOnRunning?: boolean;
81
+ }
82
+ export interface ArgsConfig {
83
+ hidden?: PhaseAware<boolean>;
84
+ displayType?: 'json' | 'key-value' | 'values-only';
85
+ }
86
+ export interface ResultsConfig {
87
+ hidden?: PhaseAware<boolean>;
88
+ displayType?: 'json' | 'key-value' | 'values-only' | 'custom';
89
+ keysInfo?: KeyDisplay[];
90
+ /**
91
+ * When true (and phase is `completed`), render the result content directly
92
+ * under the row — visible by default, no click required. The click-to-expand
93
+ * still works for inspecting args + raw JSON. Use for tools whose result
94
+ * payload IS the point (screenshots, charts).
95
+ */
96
+ alwaysShow?: boolean;
97
+ }
98
+ export type FieldComponentName = 'BoldLabel' | 'TextDisplay' | 'Markdown' | 'Code' | 'Json' | 'Image' | 'Base64Image' | 'Badge' | 'Chips' | 'TabCard' | 'Table';
99
+ export interface KeyDisplay {
100
+ key: string;
101
+ component: FieldComponentName;
102
+ className?: string;
103
+ transform?: TransformName | TransformName[] | null;
104
+ fallback?: string;
105
+ }
106
+ /**
107
+ * How to render a tool's incremental progress updates (the `progress[]` log
108
+ * a long-running tool emits via server `tool_progress` events or client
109
+ * `ctx.reportProgress`). Entirely optional: a tool with no progress entries
110
+ * renders nothing extra. When entries DO exist, the generic default ('log',
111
+ * auto-collapse) applies even without a config block — registering one only
112
+ * customizes the presentation.
113
+ */
114
+ export type ProgressDisplayMode =
115
+ /** Chronological list of recent updates; collapses to a summary on completion. */
116
+ 'log'
117
+ /** Single status line that the latest update replaces. */
118
+ | 'latest'
119
+ /** Named steps (grouped by `step`) ticking pending → active → done/error. */
120
+ | 'steps';
121
+ export interface ProgressConfig {
122
+ hidden?: PhaseAware<boolean>;
123
+ /** Default 'log'. */
124
+ mode?: ProgressDisplayMode;
125
+ /** 'log' mode: how many recent lines to keep visible while running. Default 4. */
126
+ visibleWhileRunning?: number;
127
+ /** Keep progress expanded after completion instead of collapsing. Default false. */
128
+ showWhenComplete?: boolean;
129
+ }
130
+ export interface ToolDisplayEntry {
131
+ inline?: InlineConfig;
132
+ args?: ArgsConfig;
133
+ results?: ResultsConfig;
134
+ /** Opt-in incremental-progress display for long-running tools. */
135
+ progress?: ProgressConfig;
136
+ CustomComponent?: ComponentType<{
137
+ entry: ToolRowEntry;
138
+ kind: 'server' | 'client';
139
+ }>;
140
+ }
@@ -26,7 +26,7 @@ export declare const selectOrderedToolLifecycles: (requestId: string) => ((state
26
26
  voiceAgent: import("../../voice-agent/types.js").VoiceAgentState;
27
27
  agentDefinition: import("../../agents/types/agent-definition.types.js").AgentDefinitionSliceState;
28
28
  conversationList: import("../../agents/redux/conversation-list/conversation-list.types.js").ConversationListState;
29
- conversationHistory: import("../../agents/redux/conversation-history/index.js").ConversationHistoryState;
29
+ conversationHistory: import("../../agents/redux/conversation-history/types.js").ConversationHistoryState;
30
30
  agentShortcut: import("../../agents/redux/agent-shortcuts/types.js").AgentShortcutSliceState;
31
31
  agentShortcutCategory: import("../../agents/redux/agent-shortcut-categories/types.js").AgentShortcutCategorySliceState;
32
32
  surfaceUserState: import("../../surfaces/redux/userStateSlice.js").SurfaceUserStateSlice;
@@ -53,7 +53,7 @@ export declare function getToolGlyph(toolName: string | null): ToolGlyphSpec;
53
53
  * own header + menu, so the shell drops the fold line once complete), "line"
54
54
  * (default) uses the slim collapsible verb-phrase row.
55
55
  */
56
- export declare function getToolChrome(toolName: string | null): "line" | "card";
56
+ export declare function getToolChrome(toolName: string | null): "line" | "card" | "row";
57
57
  export declare function getToolDisplayName(toolName: string | null): string;
58
58
  /**
59
59
  * Resolve the verb-phrase label for a tool's slim row.
@@ -53,7 +53,14 @@ const WorkbookOverlay = clientLazy(() => import("../renderers/workbook/WorkbookO
53
53
  const DictionaryInline = clientLazy(() => import("../renderers/dictionary/DictionaryInline.js").then((m) => ({ default: m.DictionaryInline })));
54
54
  const DictionaryOverlay = clientLazy(() => import("../renderers/dictionary/DictionaryOverlay.js").then((m) => ({ default: m.DictionaryOverlay })));
55
55
  const ResearchInline = clientLazy(() => import("../renderers/research/ResearchInline.js").then((m) => ({ default: m.ResearchInline })));
56
- import { researchOverlayTabs } from "../renderers/research/ResearchOverlay.js";
56
+ const ResearchReportTab = clientLazy(() => import("../renderers/research/ResearchOverlay.js").then((m) => ({ default: m.ResearchReportTab })));
57
+ const ResearchSourcesTab = clientLazy(() => import("../renderers/research/ResearchOverlay.js").then((m) => ({ default: m.ResearchSourcesTab })));
58
+ const ResearchFullTextTab = clientLazy(() => import("../renderers/research/ResearchOverlay.js").then((m) => ({ default: m.ResearchFullTextTab })));
59
+ const researchOverlayTabs = [
60
+ { id: "report", label: "Report", Component: ResearchReportTab },
61
+ { id: "sources", label: "Sources", Component: ResearchSourcesTab },
62
+ { id: "fulltext", label: "Full Text", Component: ResearchFullTextTab }
63
+ ];
57
64
  const RandomWheelInline = clientLazy(() => import("../renderers/random-wheel/RandomWheelInline.js").then((m) => ({ default: m.RandomWheelInline })));
58
65
  const RecordsInline = clientLazy(() => import("../renderers/records/RecordsInline.js").then((m) => ({ default: m.RecordsInline })));
59
66
  const CtxGetInline = clientLazy(() => import("../renderers/ctx/CtxGetInline.js").then((m) => ({ default: m.CtxGetInline })));
@@ -161,7 +161,7 @@ export interface ToolRenderer {
161
161
  * icons — the component's own header (`EntityCard`) carries the name +
162
162
  * "Open in" menu. While still streaming it shows the slim row.
163
163
  */
164
- chrome?: "line" | "card";
164
+ chrome?: "line" | "card" | "row";
165
165
  /**
166
166
  * Optional verb-phrase labels for the slim row. When omitted, the shell
167
167
  * falls back to a small built-in map (for common widget tools) and then
@@ -17,7 +17,6 @@
17
17
  * USAGE
18
18
  * ─────
19
19
  * import type { CanonicalMessage, CanonicalBlock } from '@/lib/chat-protocol/types';
20
- * const messages = buildCanonicalMessages(dbMessages, toolCalls);
21
20
  * const streaming = buildStreamingState(streamEvents);
22
21
  */
23
22
  /** Bump this when the shape of CanonicalMessage or CanonicalBlock changes. */
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Pure record transforms chat writes with (gap 9, AUDIT-C) — package code, never host slots: a
3
+ * slot left them throwing on a bare host, and a wrong answer here would corrupt a write.
4
+ * Same rules as matrx-frontend's `lib/organizations/globalOwnership` + `lib/row-access`.
5
+ *
6
+ * GLOBAL OWNERSHIP. Storage homes a global row in the SYSTEM organization (the column is NOT
7
+ * NULL); the client's scope model reads "global" as "no owner". So a row read from the system
8
+ * org goes out with no organization AND no person (storage stamps the acting admin onto a global
9
+ * write, and a person reads as "personal scope"); a record written back gets the system org again.
10
+ */
11
+ interface OwnedRecord {
12
+ organizationId?: string | null;
13
+ userId?: string | null;
14
+ }
15
+ /** A record owned by the system organization is GLOBAL: present it with no owner at all. */
16
+ export declare function toGlobalOwnershipRecord<T extends OwnedRecord>(record: T, systemOrgId: string): T;
17
+ /** The inverse, for writing a record read through the rule back: "no owner" is the system org. */
18
+ export declare function fromGlobalOwnershipRecord<T extends OwnedRecord>(record: T, systemOrgId: string): T;
19
+ /** The write for "Publish to the web" / "Stop publishing": the switch, when, and who flipped it. */
20
+ export declare function publishedToWebPatch(on: boolean, userId: string | null): {
21
+ published_to_web: boolean;
22
+ published_to_web_at: string | null;
23
+ published_to_web_by: string | null;
24
+ };
25
+ export {};
@@ -0,0 +1,18 @@
1
+ function toGlobalOwnershipRecord(record, systemOrgId) {
2
+ if (!record || record.organizationId !== systemOrgId) return record;
3
+ const out = { ...record, organizationId: null };
4
+ if ("userId" in record) out.userId = null;
5
+ return out;
6
+ }
7
+ function fromGlobalOwnershipRecord(record, systemOrgId) {
8
+ if (!record || record.organizationId) return record;
9
+ return { ...record, organizationId: systemOrgId };
10
+ }
11
+ function publishedToWebPatch(on, userId) {
12
+ return { published_to_web: on, published_to_web_at: (/* @__PURE__ */ new Date()).toISOString(), published_to_web_by: userId };
13
+ }
14
+ export {
15
+ fromGlobalOwnershipRecord,
16
+ publishedToWebPatch,
17
+ toGlobalOwnershipRecord
18
+ };
@@ -5,6 +5,8 @@ import {
5
5
  } from "../constants.js";
6
6
  import { writeAmplitude } from "./amplitudeBus.js";
7
7
  import { acquireMicStream, releaseMicStream } from "@ai-matrx/browser-audio/core";
8
+ import { getChatHost, isChatHostConfigured } from "../../host/configure.js";
9
+ import { withMicrophoneGrant } from "../../host/microphone.js";
8
10
  const WORKLET_PATH = "/pcm-processor-worklet.js";
9
11
  function createAudioCapture(options = {}) {
10
12
  const sampleRateHz = options.sampleRateHz ?? SAMPLE_RATE_HZ;
@@ -79,12 +81,15 @@ function createAudioCapture(options = {}) {
79
81
  return true;
80
82
  };
81
83
  try {
82
- stream = await acquireMicStream({
83
- echoCancellation: true,
84
- noiseSuppression: true,
85
- autoGainControl: true,
86
- sampleRate: sampleRateHz
87
- });
84
+ stream = await withMicrophoneGrant(
85
+ () => acquireMicStream({
86
+ echoCancellation: true,
87
+ noiseSuppression: true,
88
+ autoGainControl: true,
89
+ sampleRate: sampleRateHz
90
+ }),
91
+ isChatHostConfigured() ? getChatHost().microphone : null
92
+ );
88
93
  holdingMic = true;
89
94
  } catch (err) {
90
95
  const code = err?.name === "NotAllowedError" ? "permission-denied" : err?.name === "NotFoundError" ? "no-microphone" : err?.name === "NotReadableError" ? "device-busy" : "unknown";
@@ -1,4 +1,3 @@
1
- import React from "react";
2
1
  interface AgentRunHistoryWindowProps {
3
2
  isOpen: boolean;
4
3
  onClose: () => void;
@@ -7,7 +6,7 @@ interface AgentRunHistoryWindowProps {
7
6
  /** What the history is of ("Recipe Scaler") — see the opener. */
8
7
  subject?: string | null;
9
8
  }
10
- export default function AgentRunHistoryWindow({ isOpen, onClose, agentId, initialSelectedConversationId, subject, }: AgentRunHistoryWindowProps): React.JSX.Element | null;
9
+ export default function AgentRunHistoryWindow({ isOpen, onClose, agentId, initialSelectedConversationId, subject, }: AgentRunHistoryWindowProps): import("react").JSX.Element | null;
11
10
  /** The window's title: the caller's subject while its agent is shown, else the agent's name. */
12
11
  export declare function runHistoryWindowTitle(args: {
13
12
  agentId: string | null;
@@ -1,18 +1,8 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
- import { ArchivedDisclosure } from "@ai-matrx/design-system";
3
+ import { useCallback, useEffect, useRef, useState } from "react";
4
4
  import {
5
- useCallback,
6
- useEffect,
7
- useMemo,
8
- useRef,
9
- useState
10
- } from "react";
11
- import {
12
- ChevronDown,
13
- ChevronRight,
14
5
  Clock,
15
- MessageSquare,
16
6
  Loader2,
17
7
  History,
18
8
  Workflow
@@ -20,17 +10,16 @@ import {
20
10
  import { WindowPanel } from "../../../host/ui-slots.js";
21
11
  import { useAppDispatch, useAppSelector } from "../../../store/hooks.js";
22
12
  import { selectAgentById } from "../../../agents/redux/agent-definition/selectors.js";
23
- import { fetchAgentConversations } from "../../../agents/redux/conversation-list/conversation-list.thunks.js";
24
- import { makeSelectAgentConversations } from "../../../agents/redux/conversation-list/conversation-list.selectors.js";
13
+ import {
14
+ AgentVersionGroupedList,
15
+ useAgentConversationList
16
+ } from "../../../agents/components/conversation-history/AgentConversationList.js";
25
17
  import { AgentConversationDisplay } from "../../../agents/components/messages-display/AgentConversationDisplay.js";
26
18
  import { loadConversation } from "../../../agents/redux/execution-system/thunks/load-conversation.thunk.js";
27
19
  import { followWhatIsStillInFlight } from "../../../agents/runtime-reconnect/follow-what-is-still-in-flight.js";
28
20
  import { createManualInstance } from "../../../agents/redux/execution-system/thunks/create-instance.thunk.js";
29
21
  import { useAppStore } from "../../../store/hooks.js";
30
22
  import { AgentListDropdown } from "@ai-matrx/agents/catalog/react";
31
- import { ItemRow } from "../../../host/ui-slots.js";
32
- import { buildConversationMenu } from "../../../agents/components/conversation-actions/conversationActionRegistry.js";
33
- import { renameConversation } from "../../../agents/redux/conversation-list/conversation-row-actions.thunks.js";
34
23
  import { SurfaceRuntimeProvider } from "../../../surfaces/runtime/SurfaceRuntimeContext.js";
35
24
  import { AGENT_RUN_HISTORY_SURFACE_NAME } from "../../../surfaces/manifests/agent-run-history.manifest.js";
36
25
  import { NonEditableContextMenu } from "../../../host/ui-slots.js";
@@ -41,109 +30,7 @@ import {
41
30
  } from "./agent-run-history-scope.js";
42
31
  import { ErrorAlchemyMenu } from "../../../host/ui-slots.js";
43
32
  import { CHAT_WINDOWS } from "../../../host/windows.js";
44
- import { Button } from "@ai-matrx/design-system/controls";
45
33
  const SURFACE_KEY = "agent-run-history-window";
46
- function formatDate(iso) {
47
- if (!iso) return "";
48
- const d = new Date(iso);
49
- const now = /* @__PURE__ */ new Date();
50
- const diffDays = Math.floor((now.getTime() - d.getTime()) / 864e5);
51
- if (diffDays === 0)
52
- return d.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
53
- if (diffDays === 1) return "Yesterday";
54
- if (diffDays < 7) return `${diffDays}d ago`;
55
- return d.toLocaleDateString([], { month: "short", day: "numeric" });
56
- }
57
- function groupByVersion(conversations) {
58
- const map = /* @__PURE__ */ new Map();
59
- for (const conv of conversations) {
60
- const v = conv.agentVersionNumber ?? 0;
61
- const group = map.get(v);
62
- if (group) {
63
- group.push(conv);
64
- } else {
65
- map.set(v, [conv]);
66
- }
67
- }
68
- return Array.from(map.entries()).sort(([a], [b]) => b - a).map(([versionNumber, convs]) => ({
69
- versionNumber,
70
- conversations: [...convs].sort(
71
- (a, b) => new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime()
72
- )
73
- }));
74
- }
75
- function VersionGroupRow({
76
- group,
77
- agentId,
78
- selectedId,
79
- onSelect,
80
- defaultOpen
81
- }) {
82
- const [open, setOpen] = useState(defaultOpen);
83
- const hasActive = group.conversations.some(
84
- (c) => c.conversationId === selectedId
85
- );
86
- return /* @__PURE__ */ jsxs("div", { children: [
87
- /* @__PURE__ */ jsxs(Button, { variant: "quiet", pressed: hasActive, icon: open ? /* @__PURE__ */ jsx(ChevronDown, {}) : /* @__PURE__ */ jsx(ChevronRight, {}), onClick: () => setOpen((v) => !v), className: "w-full", children: [
88
- /* @__PURE__ */ jsx("span", { className: "text-[11px] font-semibold text-muted-foreground uppercase tracking-wide flex-1 min-w-0 truncate", children: group.versionNumber ? `Version ${group.versionNumber}` : "Latest" }),
89
- /* @__PURE__ */ jsx("span", { className: "text-[10px] text-muted-foreground/60 shrink-0 ml-1", children: group.conversations.length })
90
- ] }),
91
- open && /* @__PURE__ */ jsx("div", { className: "pl-2", children: group.conversations.map((conv) => /* @__PURE__ */ jsx(
92
- VersionConversationRow,
93
- {
94
- conv,
95
- agentId,
96
- isActive: conv.conversationId === selectedId,
97
- onSelect
98
- },
99
- conv.conversationId
100
- )) })
101
- ] });
102
- }
103
- function VersionConversationRow({
104
- conv,
105
- agentId,
106
- isActive,
107
- onSelect
108
- }) {
109
- const dispatch = useAppDispatch();
110
- const date = formatDate(conv.updatedAt);
111
- const href = `/agents/go/${agentId}/run?conversationId=${conv.conversationId}`;
112
- return /* @__PURE__ */ jsx(
113
- ItemRow,
114
- {
115
- sourceFeature: "agent-runner",
116
- label: conv.title?.trim() || "Untitled",
117
- active: isActive,
118
- size: "sm",
119
- onOpen: () => onSelect(conv.conversationId),
120
- menu: () => buildConversationMenu({
121
- conversationId: conv.conversationId,
122
- title: conv.title,
123
- isFavorite: conv.isFavorite ?? false,
124
- isArchived: conv.status === "archived",
125
- excludeFromKg: conv.excludeFromKg ?? false,
126
- href,
127
- dispatch
128
- }),
129
- rename: {
130
- value: conv.title ?? "",
131
- emptyFallback: "Untitled",
132
- onCommit: (next) => void dispatch(
133
- renameConversation({
134
- conversationId: conv.conversationId,
135
- title: next
136
- })
137
- )
138
- },
139
- trailing: /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1 text-[10px] text-muted-foreground/70", children: [
140
- /* @__PURE__ */ jsx(MessageSquare, { className: "w-2.5 h-2.5 shrink-0" }),
141
- conv.messageCount,
142
- date ? ` \xB7 ${date}` : ""
143
- ] })
144
- }
145
- );
146
- }
147
34
  function RunHistorySidebar({
148
35
  agentId,
149
36
  selectedConversationId,
@@ -152,42 +39,16 @@ function RunHistorySidebar({
152
39
  onScope,
153
40
  subjectLabel
154
41
  }) {
155
- const dispatch = useAppDispatch();
156
- const agentName = useAppSelector(
157
- (state) => agentId ? selectAgentById(state, agentId)?.name ?? null : null
158
- );
159
- const canonicalAgentId = useAppSelector((state) => {
160
- if (!agentId) return null;
161
- const agent = selectAgentById(state, agentId);
162
- return agent?.parentAgentId ?? agent?.id ?? agentId;
163
- });
164
- const selectConversations = useMemo(
165
- () => canonicalAgentId ? makeSelectAgentConversations(canonicalAgentId, null) : null,
166
- [canonicalAgentId]
167
- );
168
- const conversationState = useAppSelector(
169
- (state) => selectConversations ? selectConversations(state) : null
170
- );
171
- const status = conversationState?.status ?? "idle";
172
- const conversations = conversationState?.conversations ?? [];
173
- const archived = conversationState?.archived ?? [];
174
- const error = conversationState?.error ?? null;
175
- const [showArchived, setShowArchived] = useState(false);
176
- useEffect(() => {
177
- if (canonicalAgentId && status === "idle") {
178
- dispatch(
179
- fetchAgentConversations({
180
- agentId: canonicalAgentId,
181
- versionFilter: null
182
- })
183
- );
184
- }
185
- }, [canonicalAgentId, status, dispatch]);
186
- const versionGroups = useMemo(
187
- () => groupByVersion(conversations),
188
- [conversations]
189
- );
190
- const archivedGroups = useMemo(() => groupByVersion(archived), [archived]);
42
+ const list = useAgentConversationList(agentId);
43
+ const {
44
+ canonicalAgentId,
45
+ agentName,
46
+ status,
47
+ error,
48
+ conversations,
49
+ archived,
50
+ versionGroups
51
+ } = list;
191
52
  useEffect(() => {
192
53
  if (!canonicalAgentId) {
193
54
  onScope(null);
@@ -197,7 +58,7 @@ function RunHistorySidebar({
197
58
  canonicalAgentId,
198
59
  status,
199
60
  error,
200
- fetchedAt: conversationState?.fetchedAt ?? null,
61
+ fetchedAt: list.fetchedAt,
201
62
  conversations,
202
63
  versionGroups: versionGroups.map((g) => ({
203
64
  versionNumber: g.versionNumber,
@@ -209,7 +70,7 @@ function RunHistorySidebar({
209
70
  canonicalAgentId,
210
71
  status,
211
72
  error,
212
- conversationState?.fetchedAt,
73
+ list.fetchedAt,
213
74
  conversations,
214
75
  versionGroups
215
76
  ]);
@@ -252,35 +113,14 @@ function RunHistorySidebar({
252
113
  /* @__PURE__ */ jsx(History, { className: "w-6 h-6 text-muted-foreground mb-2 opacity-40" }),
253
114
  /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "No conversations yet" })
254
115
  ] }),
255
- agentId && versionGroups.map((group, i) => /* @__PURE__ */ jsx(
256
- VersionGroupRow,
116
+ agentId && /* @__PURE__ */ jsx(
117
+ AgentVersionGroupedList,
257
118
  {
258
- group,
259
119
  agentId,
120
+ list,
260
121
  selectedId: selectedConversationId,
261
122
  onSelect,
262
- defaultOpen: i === 0
263
- },
264
- group.versionNumber
265
- )),
266
- agentId && /* @__PURE__ */ jsx(
267
- ArchivedDisclosure,
268
- {
269
- count: archived.length,
270
- open: showArchived,
271
- onOpenChange: setShowArchived,
272
- className: "mx-1 mt-1",
273
- children: archivedGroups.map((group) => /* @__PURE__ */ jsx(
274
- VersionGroupRow,
275
- {
276
- group,
277
- agentId,
278
- selectedId: selectedConversationId,
279
- onSelect,
280
- defaultOpen: false
281
- },
282
- group.versionNumber
283
- ))
123
+ sourceFeature: "agent-runner"
284
124
  }
285
125
  )
286
126
  ]
@@ -3,7 +3,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import { logFailure } from "../../../ui/expectedRefusal.js";
4
4
  import { useCallback, useEffect, useRef, useState } from "react";
5
5
  import { AlertTriangle, Brain, Loader2, RotateCw, SquarePen } from "lucide-react";
6
- import { Button } from "@ai-matrx/design-system/controls";
6
+ import { Button, SegmentedControl } from "@ai-matrx/design-system/controls";
7
7
  import { WindowPanel } from "../../../host/ui-slots.js";
8
8
  import { useAppDispatch, useAppSelector } from "../../../store/hooks.js";
9
9
  import { toast } from "../../../host/notify.js";
@@ -134,30 +134,43 @@ function AgentRunWindowSidebar({
134
134
  },
135
135
  chat.conversationId
136
136
  )) }) : null;
137
- if (!agentId || !canonicalAgentId) {
138
- return /* @__PURE__ */ jsxs("div", { className: "flex h-full min-h-0 flex-col", children: [
139
- sessionSection,
140
- /* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-col items-center justify-center gap-2 px-3 py-10 text-center", children: [
141
- /* @__PURE__ */ jsx(Brain, { className: "h-6 w-6 text-muted-foreground opacity-25" }),
142
- /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "Select an agent from the header to see its history." })
143
- ] })
144
- ] });
145
- }
137
+ const [listScope, setListScope] = useState("all");
138
+ const agentOnly = listScope === "agent" && !!canonicalAgentId;
139
+ const scopeToggle = /* @__PURE__ */ jsx("div", { className: "shrink-0 px-2 pt-2 pb-1", children: /* @__PURE__ */ jsx(
140
+ SegmentedControl,
141
+ {
142
+ "aria-label": "Which chats to list",
143
+ fill: true,
144
+ value: agentOnly ? "agent" : "all",
145
+ onValueChange: (next) => setListScope(next),
146
+ data: [
147
+ { value: "all", label: "All agents" },
148
+ {
149
+ value: "agent",
150
+ label: "This agent",
151
+ title: canonicalAgentId ? "Only chats with the agent in the title bar" : "Pick an agent in the title bar first",
152
+ disabled: !canonicalAgentId
153
+ }
154
+ ]
155
+ }
156
+ ) });
146
157
  return /* @__PURE__ */ jsx(
147
158
  ConversationHistorySidebar,
148
159
  {
149
160
  variant: "consumer",
150
- scopeId: `${surfaceKey ?? "agent-run-window"}:history:${canonicalAgentId}`,
151
- agentIds: [canonicalAgentId],
161
+ scopeId: agentOnly ? `${surfaceKey ?? "agent-run-window"}:history:${canonicalAgentId}` : `${surfaceKey ?? "agent-run-window"}:history:all`,
162
+ agentIds: agentOnly && canonicalAgentId ? [canonicalAgentId] : [],
152
163
  surfaceId: "agent-runner",
153
164
  activeConversationId: null,
154
165
  onOpenConversation: handleOpenConversation,
155
166
  openInPlace: true,
156
167
  surfaceKey: surfaceKey ?? void 0,
157
168
  getConversationHref,
169
+ headerSlot: scopeToggle,
158
170
  topSlot: sessionSection,
159
171
  className: "bg-transparent"
160
- }
172
+ },
173
+ agentOnly ? `agent:${canonicalAgentId}` : "all"
161
174
  );
162
175
  }
163
176
  function AgentRunWindowNewRunButton({