@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
@@ -1,119 +0,0 @@
1
- "use client";
2
- import { useCallback } from "react";
3
- import { useRouter } from "../../../host/navigation.js";
4
- import { useAppDispatch } from "../../../store/hooks.js";
5
- import { editMessage } from "../../redux/execution-system/message-crud/edit-message.thunk.js";
6
- import { forkConversation } from "../../redux/execution-system/message-crud/fork-conversation.thunk.js";
7
- import { softDeleteConversation } from "../../redux/execution-system/message-crud/soft-delete-conversation.thunk.js";
8
- import { launchConversation } from "../../redux/execution-system/thunks/launch-conversation.thunk.js";
9
- function useMessageActions({
10
- conversationId,
11
- messageId,
12
- position,
13
- surfaceKey,
14
- buildInvocationForResubmit,
15
- onNavigateToFork
16
- }) {
17
- const dispatch = useAppDispatch();
18
- const router = useRouter();
19
- const saveFullContent = useCallback(
20
- async (newContent) => {
21
- await dispatch(
22
- editMessage({
23
- conversationId,
24
- messageId,
25
- newContent
26
- })
27
- ).unwrap();
28
- },
29
- [conversationId, messageId, dispatch]
30
- );
31
- const forkAtThisMessage = useCallback(async () => {
32
- if (typeof position !== "number") {
33
- console.warn(
34
- "[useMessageActions] forkAtThisMessage called without `position` \u2014 skipping. Pass the message position when constructing the hook."
35
- );
36
- return null;
37
- }
38
- const result = await dispatch(
39
- forkConversation({
40
- conversationId,
41
- atPosition: position,
42
- surfaceKey
43
- })
44
- ).unwrap();
45
- if (onNavigateToFork) {
46
- onNavigateToFork(result.conversationId);
47
- } else {
48
- router.push(`/agents/runs/${result.conversationId}`);
49
- }
50
- return result.conversationId;
51
- }, [
52
- conversationId,
53
- position,
54
- surfaceKey,
55
- dispatch,
56
- onNavigateToFork,
57
- router
58
- ]);
59
- const editAndResubmit = useCallback(
60
- async (newUserInput) => {
61
- if (typeof position !== "number") {
62
- console.warn(
63
- "[useMessageActions] editAndResubmit called without `position` \u2014 skipping."
64
- );
65
- return null;
66
- }
67
- const forkPosition = Math.max(0, position - 1);
68
- const fork = await dispatch(
69
- forkConversation({
70
- conversationId,
71
- atPosition: forkPosition,
72
- surfaceKey
73
- })
74
- ).unwrap();
75
- if (buildInvocationForResubmit) {
76
- const invocation = buildInvocationForResubmit(fork.conversationId);
77
- const withInput = {
78
- ...invocation,
79
- identity: {
80
- ...invocation.identity,
81
- conversationId: fork.conversationId
82
- },
83
- inputs: invocation.inputs ? { ...invocation.inputs, userInput: newUserInput } : { userInput: newUserInput }
84
- };
85
- await dispatch(launchConversation(withInput)).unwrap();
86
- }
87
- if (onNavigateToFork) {
88
- onNavigateToFork(fork.conversationId);
89
- } else {
90
- router.push(`/agents/runs/${fork.conversationId}`);
91
- }
92
- return fork.conversationId;
93
- },
94
- [
95
- conversationId,
96
- position,
97
- surfaceKey,
98
- dispatch,
99
- buildInvocationForResubmit,
100
- onNavigateToFork,
101
- router
102
- ]
103
- );
104
- const deleteConversation = useCallback(async () => {
105
- const result = await dispatch(
106
- softDeleteConversation({ conversationId })
107
- ).unwrap();
108
- return result.deleted;
109
- }, [conversationId, dispatch]);
110
- return {
111
- saveFullContent,
112
- forkAtThisMessage,
113
- editAndResubmit,
114
- deleteConversation
115
- };
116
- }
117
- export {
118
- useMessageActions
119
- };
@@ -1,30 +0,0 @@
1
- /**
2
- * useConversationPendingCalls — surface durable client-delegated tool prompts.
3
- *
4
- * Mount this hook in any component that renders a conversation. It fetches
5
- * the list of `cx_tool_call` rows the server has persisted in
6
- * `status='delegated'` for this conversation and exposes them so the UI can
7
- * render pending prompts exactly as if the original SSE had just delivered
8
- * the `tool_delegated` events live.
9
- *
10
- * Use case: the user closed their browser during a tool prompt and reopened
11
- * the conversation the next day. The server preserved the call; this hook
12
- * surfaces it.
13
- *
14
- * Intentionally stateless — no Redux slice is introduced. Callers keep the
15
- * list in local state and re-run the fetch when they need to.
16
- */
17
- import { type PendingCallSummary } from "../api/fetch-pending-calls.js";
18
- export interface UseConversationPendingCallsResult {
19
- /** All client-delegated calls currently awaiting the user's response. */
20
- pendingCalls: PendingCallSummary[];
21
- /** True from the moment the hook starts fetching until the first response. */
22
- isLoading: boolean;
23
- /** Re-fetch from the server (e.g. after POSTing a tool_result). */
24
- refresh: () => Promise<PendingCallSummary[]>;
25
- }
26
- export interface UseConversationPendingCallsOptions {
27
- /** Skip the automatic fetch-on-mount. Default: false. */
28
- skip?: boolean;
29
- }
30
- export declare function useConversationPendingCalls(conversationId: string | null | undefined, options?: UseConversationPendingCallsOptions): UseConversationPendingCallsResult;
@@ -1,42 +0,0 @@
1
- import { useCallback, useEffect, useRef, useState } from "react";
2
- import { useAppDispatch } from "../../store/hooks.js";
3
- import {
4
- fetchConversationPendingCalls
5
- } from "../api/fetch-pending-calls.js";
6
- function useConversationPendingCalls(conversationId, options = {}) {
7
- const { skip = false } = options;
8
- const dispatch = useAppDispatch();
9
- const [pendingCalls, setPendingCalls] = useState([]);
10
- const [isLoading, setIsLoading] = useState(false);
11
- const latestRequestRef = useRef(0);
12
- const refresh = useCallback(async () => {
13
- if (!conversationId) return [];
14
- const tick = ++latestRequestRef.current;
15
- setIsLoading(true);
16
- try {
17
- const calls = await dispatch(
18
- fetchConversationPendingCalls(conversationId)
19
- );
20
- if (tick === latestRequestRef.current) {
21
- setPendingCalls(calls);
22
- }
23
- return calls;
24
- } finally {
25
- if (tick === latestRequestRef.current) {
26
- setIsLoading(false);
27
- }
28
- }
29
- }, [conversationId, dispatch]);
30
- useEffect(() => {
31
- if (skip) return;
32
- if (!conversationId) {
33
- setPendingCalls([]);
34
- return;
35
- }
36
- void refresh();
37
- }, [conversationId, refresh, skip]);
38
- return { pendingCalls, isLoading, refresh };
39
- }
40
- export {
41
- useConversationPendingCalls
42
- };
@@ -1 +0,0 @@
1
- export * from "@ai-matrx/agents/models";
@@ -1 +0,0 @@
1
- export * from "@ai-matrx/agents/models";
@@ -1,18 +0,0 @@
1
- /**
2
- * conversation-history — reusable, scope-keyed conversation sidebar slice.
3
- *
4
- * Ships alongside `conversation-list`:
5
- * - `conversation-list` owns per-agent RPC caches (used by the Runner) and
6
- * the global user list.
7
- * - `conversation-history` owns feature-scoped, multi-agent, paginated
8
- * views (used by the /code workspace and future consumers).
9
- *
10
- * Pattern:
11
- * dispatch(fetchConversationHistory({ scopeId, agentIds, replace: true }))
12
- * dispatch(fetchConversationHistory({ scopeId, replace: false })) // load more
13
- * useAppSelector(makeSelectGroupedByDate(scopeId))
14
- */
15
- export * from "./slice.js";
16
- export * from "./selectors.js";
17
- export * from "./thunks.js";
18
- export * from "./types.js";
@@ -1,4 +0,0 @@
1
- export * from "./slice.js";
2
- export * from "./selectors.js";
3
- export * from "./thunks.js";
4
- export * from "./types.js";
@@ -1,38 +0,0 @@
1
- /**
2
- * Instance Variable Values — Undo-aware thunks
3
- *
4
- * Wraps setUserVariableValue / setUserVariableValues so every variable edit
5
- * also pushes a combined { text, userValues } snapshot to the user-input
6
- * undo stack. This keeps both fields restorable together on Cmd+Z.
7
- *
8
- * Components should import setVariableValueWithUndo / setVariableValuesWithUndo
9
- * from here instead of calling the raw slice actions directly.
10
- */
11
- import type { ChatRootState, ChatDispatch } from "../../../../store/root-state.js";
12
- export declare const setVariableValueWithUndo: import("@reduxjs/toolkit").AsyncThunk<void, {
13
- conversationId: string;
14
- name: string;
15
- value: unknown;
16
- }, {
17
- extra?: unknown;
18
- rejectValue?: unknown;
19
- serializedErrorType?: unknown;
20
- pendingMeta?: unknown;
21
- fulfilledMeta?: unknown;
22
- rejectedMeta?: unknown;
23
- state: ChatRootState;
24
- dispatch: ChatDispatch;
25
- }>;
26
- export declare const setVariableValuesWithUndo: import("@reduxjs/toolkit").AsyncThunk<void, {
27
- conversationId: string;
28
- values: Record<string, unknown>;
29
- }, {
30
- extra?: unknown;
31
- rejectValue?: unknown;
32
- serializedErrorType?: unknown;
33
- pendingMeta?: unknown;
34
- fulfilledMeta?: unknown;
35
- rejectedMeta?: unknown;
36
- state: ChatRootState;
37
- dispatch: ChatDispatch;
38
- }>;
@@ -1,42 +0,0 @@
1
- import { createAsyncThunk } from "@reduxjs/toolkit";
2
- import {
3
- setUserVariableValue,
4
- setUserVariableValues
5
- } from "./instance-variable-values.slice.js";
6
- import { pushInputSnapshot } from "../instance-user-input/instance-user-input.slice.js";
7
- const setVariableValueWithUndo = createAsyncThunk(
8
- "instanceVariableValues/setValueWithUndo",
9
- async ({ conversationId, name, value }, { getState, dispatch }) => {
10
- const state = getState();
11
- const currentText = state.instanceUserInput.byConversationId[conversationId]?.text ?? "";
12
- const currentValues = state.instanceVariableValues.byConversationId[conversationId]?.userValues ?? {};
13
- dispatch(
14
- pushInputSnapshot({
15
- conversationId,
16
- text: currentText,
17
- userValues: currentValues
18
- })
19
- );
20
- dispatch(setUserVariableValue({ conversationId, name, value }));
21
- }
22
- );
23
- const setVariableValuesWithUndo = createAsyncThunk(
24
- "instanceVariableValues/setValuesWithUndo",
25
- async ({ conversationId, values }, { getState, dispatch }) => {
26
- const state = getState();
27
- const currentText = state.instanceUserInput.byConversationId[conversationId]?.text ?? "";
28
- const currentValues = state.instanceVariableValues.byConversationId[conversationId]?.userValues ?? {};
29
- dispatch(
30
- pushInputSnapshot({
31
- conversationId,
32
- text: currentText,
33
- userValues: currentValues
34
- })
35
- );
36
- dispatch(setUserVariableValues({ conversationId, values }));
37
- }
38
- );
39
- export {
40
- setVariableValueWithUndo,
41
- setVariableValuesWithUndo
42
- };
@@ -1,58 +0,0 @@
1
- /**
2
- * compactTurns — compact one or more **whole turns** at once.
3
- *
4
- * Endpoint: `POST /cx/conversations/{id}/turns/compact`.
5
- *
6
- * A turn = one `role: "user"` message → the next `role: "user"` message
7
- * (exclusive). The server resolves the turn boundary from the live
8
- * conversation, then delegates to `/messages/replace` (`mode: "user"`)
9
- * or `/messages/hide` (`mode: "system"`) under the hood.
10
- *
11
- * The caller supplies the summary content directly — this endpoint does
12
- * NOT run an LLM. Use whatever summarization agent you like upstream, or
13
- * invoke a chat endpoint separately and pass the result here.
14
- */
15
- import type { ChatDispatch, ChatRootState } from "../../../../../store/root-state.js";
16
- interface CompactTurnsArgs {
17
- conversationId: string;
18
- /** Inclusive start — must be a live `role: "user"` message id. */
19
- fromUserMessageId: string;
20
- /**
21
- * Exclusive end — also a `role: "user"` message id. The compaction
22
- * range ends BEFORE this message. Omit to compact all the way to the
23
- * end of the conversation.
24
- */
25
- toUserMessageId?: string;
26
- summaryContent: Array<{
27
- [key: string]: unknown;
28
- }>;
29
- /**
30
- * Default `"user"` — soft-delete + insert a visible summary (same
31
- * semantics as `replaceMessages`). `"system"` hides from the model
32
- * only (no summary row inserted, user view unchanged).
33
- */
34
- mode?: "user" | "system";
35
- /** Default true. Keeps tool_use ↔ tool_result pairs adjacent. */
36
- cascadeToolPairs?: boolean;
37
- /** Arbitrary metadata copied onto the summary row (user mode only). */
38
- summaryMetadata?: Record<string, unknown>;
39
- }
40
- export declare const compactTurns: import("@reduxjs/toolkit").AsyncThunk<{
41
- compaction_group_id: string;
42
- summary_message_id: string | null;
43
- compacted_message_ids: string[];
44
- turn_count: number;
45
- position_range: [number, number];
46
- }, CompactTurnsArgs, {
47
- extra?: unknown;
48
- serializedErrorType?: unknown;
49
- pendingMeta?: unknown;
50
- fulfilledMeta?: unknown;
51
- rejectedMeta?: unknown;
52
- dispatch: ChatDispatch;
53
- state: ChatRootState;
54
- rejectValue: {
55
- message: string;
56
- };
57
- }>;
58
- export {};
@@ -1,50 +0,0 @@
1
- import { createAsyncThunk } from "@reduxjs/toolkit";
2
- import { callCompactTurns } from "../../../../../host/server/call-api.js";
3
- import { loadConversation } from "../../thunks/load-conversation.thunk.js";
4
- import { markCacheBypass } from "../cache-bypass.slice.js";
5
- import { invalidateConversationCache } from "../invalidate-conversation-cache.thunk.js";
6
- const compactTurns = createAsyncThunk(
7
- "messages/compactTurnsServer",
8
- async ({
9
- conversationId,
10
- fromUserMessageId,
11
- toUserMessageId,
12
- summaryContent,
13
- mode,
14
- cascadeToolPairs,
15
- summaryMetadata
16
- }, { dispatch, rejectWithValue }) => {
17
- const result = await dispatch(
18
- callCompactTurns({
19
- conversationId,
20
- body: {
21
- range: {
22
- from_user_message_id: fromUserMessageId,
23
- to_user_message_id: toUserMessageId ?? null
24
- },
25
- summary_content: summaryContent,
26
- mode: mode ?? "user",
27
- cascade_tool_pairs: cascadeToolPairs ?? true,
28
- summary_metadata: summaryMetadata ?? null
29
- }
30
- })
31
- );
32
- if (result.error) {
33
- return rejectWithValue({
34
- message: result.error.message ?? `Compact turns failed: HTTP ${result.error.status ?? "unknown"}`
35
- });
36
- }
37
- if (!result.data) {
38
- return rejectWithValue({
39
- message: "Compact turns returned no payload"
40
- });
41
- }
42
- dispatch(markCacheBypass({ conversationId, conversation: true }));
43
- void dispatch(invalidateConversationCache({ conversationId }));
44
- void dispatch(loadConversation({ conversationId }));
45
- return result.data;
46
- }
47
- );
48
- export {
49
- compactTurns
50
- };
@@ -1,76 +0,0 @@
1
- /**
2
- * forkAndRunServer — atomic "fork + new turn" via the streaming server
3
- * endpoint. Replaces the legacy 3-call pattern (`forkConversation` →
4
- * `editMessage` → `executeInstance`) used by the "Edit & Resubmit (Fork)"
5
- * flow in `UserActionBar.tsx`.
6
- *
7
- * Endpoint: `POST /ai/conversations/{id}/fork-and-run` (streaming).
8
- *
9
- * Stream wire shape:
10
- * • FIRST event: `{ kind: "conversation.forked", new_conversation_id, ... }`
11
- * — see `features/agents/types/conversation-stream-events.ts`.
12
- * • Subsequent events: identical to `POST /ai/conversations/{id}` —
13
- * `record_reserved`, `chunk`, `tool_event`, `end`, ...
14
- *
15
- * **WIRE-UP-FIRST, INTEGRATION-LATER:** This thunk captures the new
16
- * `conversation_id` from the first event, dispatches `loadConversation` after
17
- * the stream completes to materialize the new conversation in Redux, and
18
- * exposes per-event callbacks so a caller can drive UI feedback. It does NOT
19
- * yet plug into `processStream` for live token-by-token rendering into the
20
- * fork's slice entries. Once we've validated the endpoint end-to-end, the
21
- * follow-up is to route subsequent events into `processStream` with the new
22
- * `conversation_id` so the user watches the new turn stream into the fork
23
- * exactly like a normal continuation. Until then this is honest atomic
24
- * fork-and-run with a post-completion hydration.
25
- *
26
- * Does NOT touch any existing thunk or call site. Opt in per surface.
27
- */
28
- import type { ChatDispatch, ChatRootState } from "../../../../../store/root-state.js";
29
- import { type ApiCallError, type ConversationForkAndRunBody } from "../../../../../host/server/call-api.js";
30
- import type { TypedStreamEvent } from "@ai-matrx/agents/generated/stream-events";
31
- import { type ConversationForkedEvent } from "../../../../types/conversation-stream-events.js";
32
- interface ForkAndRunServerArgs {
33
- /** Source conversation to fork from. */
34
- conversationId: string;
35
- /**
36
- * Full ForkAndRunRequest body. Caller supplies fork selector
37
- * (`from_message_id` + `exclusive`, or `up_to_position`) and the
38
- * standard turn payload (`user_input`, `tools`, etc.). Default values are
39
- * NOT injected here — pass the body in OpenAPI shape.
40
- */
41
- body: ConversationForkAndRunBody;
42
- /**
43
- * Optional surface key. When set, focus jumps to the new conversation
44
- * the instant `conversation.forked` arrives — so the user watches the
45
- * new turn stream in (post-integration) rather than seeing it land in
46
- * the source.
47
- */
48
- surfaceKey?: string;
49
- /** Optional per-event callbacks for UI wiring. */
50
- onForked?: (event: ConversationForkedEvent) => void;
51
- onStreamEvent?: (event: TypedStreamEvent) => void;
52
- onStreamComplete?: (newConversationId: string | null) => void;
53
- onStreamError?: (error: ApiCallError) => void;
54
- signal?: AbortSignal;
55
- }
56
- interface ForkAndRunServerResult {
57
- /** The new conversation id, captured from the `conversation.forked` event. */
58
- newConversationId: string;
59
- sourceConversationId: string;
60
- forkedAtPosition: number | null;
61
- /** Number of messages copied into the fork from the source. */
62
- copiedMessageCount: number;
63
- }
64
- export declare const forkAndRunServer: import("@reduxjs/toolkit").AsyncThunk<ForkAndRunServerResult, ForkAndRunServerArgs, {
65
- extra?: unknown;
66
- serializedErrorType?: unknown;
67
- pendingMeta?: unknown;
68
- fulfilledMeta?: unknown;
69
- rejectedMeta?: unknown;
70
- dispatch: ChatDispatch;
71
- state: ChatRootState;
72
- rejectValue: {
73
- message: string;
74
- };
75
- }>;
76
- export {};
@@ -1,101 +0,0 @@
1
- import { createAsyncThunk } from "@reduxjs/toolkit";
2
- import {
3
- callConversationForkAndRun
4
- } from "../../../../../host/server/call-api.js";
5
- import {
6
- isConversationForkedEvent
7
- } from "../../../../types/conversation-stream-events.js";
8
- import { loadConversation } from "../../thunks/load-conversation.thunk.js";
9
- import { setFocus } from "../../conversation-focus/conversation-focus.slice.js";
10
- import { markCacheBypass } from "../cache-bypass.slice.js";
11
- import { invalidateConversationCache } from "../invalidate-conversation-cache.thunk.js";
12
- const forkAndRunServer = createAsyncThunk(
13
- "conversations/forkAndRunServer",
14
- async (args, { dispatch, rejectWithValue }) => {
15
- const {
16
- conversationId,
17
- body,
18
- surfaceKey,
19
- onForked,
20
- onStreamEvent,
21
- onStreamComplete,
22
- onStreamError,
23
- signal
24
- } = args;
25
- let forkedEvent = null;
26
- const result = await dispatch(
27
- callConversationForkAndRun({
28
- conversationId,
29
- body,
30
- signal,
31
- onStreamEvent: (event) => {
32
- if (!forkedEvent && isConversationForkedEvent(event)) {
33
- forkedEvent = event;
34
- onForked?.(event);
35
- if (surfaceKey) {
36
- dispatch(
37
- setFocus({
38
- surfaceKey,
39
- conversationId: event.new_conversation_id
40
- })
41
- );
42
- }
43
- return;
44
- }
45
- onStreamEvent?.(event);
46
- },
47
- onStreamComplete: () => {
48
- onStreamComplete?.(forkedEvent?.new_conversation_id ?? null);
49
- },
50
- onStreamError
51
- })
52
- );
53
- if (result.error) {
54
- onStreamError?.(result.error);
55
- return rejectWithValue({
56
- message: result.error.message ?? `fork-and-run failed: HTTP ${result.error.status ?? "unknown"}`
57
- });
58
- }
59
- if (!forkedEvent) {
60
- return rejectWithValue({
61
- message: "fork-and-run stream completed without emitting a `conversation.forked` event"
62
- });
63
- }
64
- const forked = forkedEvent;
65
- try {
66
- await dispatch(
67
- loadConversation({ conversationId: forked.new_conversation_id })
68
- ).unwrap();
69
- } catch (err) {
70
- console.error(
71
- "[forkAndRunServer] loadConversation after stream failed",
72
- err
73
- );
74
- return rejectWithValue({
75
- message: `fork-and-run streamed successfully but rehydration failed: ${err instanceof Error ? err.message : String(err)}`
76
- });
77
- }
78
- dispatch(markCacheBypass({ conversationId, conversation: true }));
79
- dispatch(
80
- markCacheBypass({
81
- conversationId: forked.new_conversation_id,
82
- conversation: true
83
- })
84
- );
85
- void dispatch(invalidateConversationCache({ conversationId }));
86
- void dispatch(
87
- invalidateConversationCache({
88
- conversationId: forked.new_conversation_id
89
- })
90
- );
91
- return {
92
- newConversationId: forked.new_conversation_id,
93
- sourceConversationId: forked.source_conversation_id,
94
- forkedAtPosition: forked.forked_at_position,
95
- copiedMessageCount: forked.message_count
96
- };
97
- }
98
- );
99
- export {
100
- forkAndRunServer
101
- };
@@ -1,38 +0,0 @@
1
- /**
2
- * attachWorkflowRun — rejoin a durable workflow run that nobody is following.
3
- *
4
- * ## Why this exists
5
- *
6
- * `adoptForeignStream` + `followWorkflowRunStream` cover the run you STARTED:
7
- * the start response hands you a request row and a run id in the same breath.
8
- * But a workflow run is durable server work — it outlives the tab that started
9
- * it. After a refresh (or on a second device, or from a run row in a list) the
10
- * run is still executing and there is no inline stream left to adopt, so the
11
- * surface has no `requestId` to follow under and the live view dies. A run that
12
- * dies on page refresh is the same defect as a spinner (CLAUDE.md § THE
13
- * FLOATING LAW), so this is the missing half of the pair.
14
- *
15
- * It mints a fresh `activeRequests` row for the run and follows the run's SSE
16
- * feed into it. The feed replays from seq 0 (Last-Event-ID cursor starts unset),
17
- * so the node lifecycle the surface missed while away arrives on `onEvent` and
18
- * the stage view rebuilds itself — no bespoke catch-up read.
19
- *
20
- * The row is new on purpose: `activeRequests` rows are per-viewer stream
21
- * accumulators, not identities of the run. The run's identity is its `run_id`.
22
- */
23
- import type { ChatThunk } from "../../../../store/root-state.js";
24
- import { type WorkflowRunWireEvent } from "./follow-workflow-run-stream.js";
25
- export interface AttachWorkflowRunOptions {
26
- /** The durable run to rejoin. */
27
- runId: string;
28
- /** Caller teardown — abort to stop following. */
29
- signal: AbortSignal;
30
- /** Fires with the freshly minted ids, before any event is processed. */
31
- onAttached?: (ids: {
32
- requestId: string;
33
- conversationId: string;
34
- }) => void;
35
- /** Every workflow event (replayed lifecycle first, then live). Must not throw. */
36
- onEvent?: (event: WorkflowRunWireEvent) => void;
37
- }
38
- export declare function attachWorkflowRun(opts: AttachWorkflowRunOptions): ChatThunk<Promise<void>>;
@@ -1,25 +0,0 @@
1
- import { createRequest } from "../active-requests/active-requests.slice.js";
2
- import { generateConversationId, generateRequestId } from "../utils/ids.js";
3
- import {
4
- followWorkflowRunStream
5
- } from "./follow-workflow-run-stream.js";
6
- function attachWorkflowRun(opts) {
7
- return async (dispatch) => {
8
- const requestId = generateRequestId();
9
- const conversationId = generateConversationId();
10
- dispatch(createRequest({ requestId, conversationId }));
11
- opts.onAttached?.({ requestId, conversationId });
12
- await dispatch(
13
- followWorkflowRunStream({
14
- runId: opts.runId,
15
- requestId,
16
- conversationId,
17
- signal: opts.signal,
18
- onEvent: opts.onEvent
19
- })
20
- );
21
- };
22
- }
23
- export {
24
- attachWorkflowRun
25
- };