@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
@@ -74,7 +74,7 @@ export declare const selectLatestAnswerText: (conversationId: string) => ((state
74
74
  voiceAgent: import("../../../../voice-agent/types.js").VoiceAgentState;
75
75
  agentDefinition: import("../../../types/agent-definition.types.js").AgentDefinitionSliceState;
76
76
  conversationList: import("../../conversation-list/conversation-list.types.js").ConversationListState;
77
- conversationHistory: import("../../conversation-history/index.js").ConversationHistoryState;
77
+ conversationHistory: import("../../conversation-history/types.js").ConversationHistoryState;
78
78
  agentShortcut: import("../../agent-shortcuts/types.js").AgentShortcutSliceState;
79
79
  agentShortcutCategory: import("../../agent-shortcut-categories/types.js").AgentShortcutCategorySliceState;
80
80
  surfaceUserState: import("../../../../surfaces/redux/userStateSlice.js").SurfaceUserStateSlice;
@@ -145,7 +145,7 @@ export declare const selectLatestAccumulatedText: (conversationId: string) => ((
145
145
  voiceAgent: import("../../../../voice-agent/types.js").VoiceAgentState;
146
146
  agentDefinition: import("../../../types/agent-definition.types.js").AgentDefinitionSliceState;
147
147
  conversationList: import("../../conversation-list/conversation-list.types.js").ConversationListState;
148
- conversationHistory: import("../../conversation-history/index.js").ConversationHistoryState;
148
+ conversationHistory: import("../../conversation-history/types.js").ConversationHistoryState;
149
149
  agentShortcut: import("../../agent-shortcuts/types.js").AgentShortcutSliceState;
150
150
  agentShortcutCategory: import("../../agent-shortcut-categories/types.js").AgentShortcutCategorySliceState;
151
151
  surfaceUserState: import("../../../../surfaces/redux/userStateSlice.js").SurfaceUserStateSlice;
@@ -273,7 +273,7 @@ export declare const selectPendingToolCallsForInstance: (conversationId: string)
273
273
  voiceAgent: import("../../../../voice-agent/types.js").VoiceAgentState;
274
274
  agentDefinition: import("../../../types/agent-definition.types.js").AgentDefinitionSliceState;
275
275
  conversationList: import("../../conversation-list/conversation-list.types.js").ConversationListState;
276
- conversationHistory: import("../../conversation-history/index.js").ConversationHistoryState;
276
+ conversationHistory: import("../../conversation-history/types.js").ConversationHistoryState;
277
277
  agentShortcut: import("../../agent-shortcuts/types.js").AgentShortcutSliceState;
278
278
  agentShortcutCategory: import("../../agent-shortcut-categories/types.js").AgentShortcutCategorySliceState;
279
279
  surfaceUserState: import("../../../../surfaces/redux/userStateSlice.js").SurfaceUserStateSlice;
@@ -366,7 +366,7 @@ export declare function makeSelectAssembledRequest(conversationId: string): ((st
366
366
  voiceAgent: import("../../../../voice-agent/types.js").VoiceAgentState;
367
367
  agentDefinition: import("../../../types/agent-definition.types.js").AgentDefinitionSliceState;
368
368
  conversationList: import("../../conversation-list/conversation-list.types.js").ConversationListState;
369
- conversationHistory: import("../../conversation-history/index.js").ConversationHistoryState;
369
+ conversationHistory: import("../../conversation-history/types.js").ConversationHistoryState;
370
370
  agentShortcut: import("../../agent-shortcuts/types.js").AgentShortcutSliceState;
371
371
  agentShortcutCategory: import("../../agent-shortcut-categories/types.js").AgentShortcutCategorySliceState;
372
372
  surfaceUserState: import("../../../../surfaces/redux/userStateSlice.js").SurfaceUserStateSlice;
@@ -487,7 +487,7 @@ export declare const selectInstanceSummary: (conversationId: string) => ((state:
487
487
  voiceAgent: import("../../../../voice-agent/types.js").VoiceAgentState;
488
488
  agentDefinition: import("../../../types/agent-definition.types.js").AgentDefinitionSliceState;
489
489
  conversationList: import("../../conversation-list/conversation-list.types.js").ConversationListState;
490
- conversationHistory: import("../../conversation-history/index.js").ConversationHistoryState;
490
+ conversationHistory: import("../../conversation-history/types.js").ConversationHistoryState;
491
491
  agentShortcut: import("../../agent-shortcuts/types.js").AgentShortcutSliceState;
492
492
  agentShortcutCategory: import("../../agent-shortcut-categories/types.js").AgentShortcutCategorySliceState;
493
493
  surfaceUserState: import("../../../../surfaces/redux/userStateSlice.js").SurfaceUserStateSlice;
@@ -650,7 +650,7 @@ export declare const makeSelectInstanceDisplaySnapshot: () => ((state: {
650
650
  voiceAgent: import("../../../../voice-agent/types.js").VoiceAgentState;
651
651
  agentDefinition: import("../../../types/agent-definition.types.js").AgentDefinitionSliceState;
652
652
  conversationList: import("../../conversation-list/conversation-list.types.js").ConversationListState;
653
- conversationHistory: import("../../conversation-history/index.js").ConversationHistoryState;
653
+ conversationHistory: import("../../conversation-history/types.js").ConversationHistoryState;
654
654
  agentShortcut: import("../../agent-shortcuts/types.js").AgentShortcutSliceState;
655
655
  agentShortcutCategory: import("../../agent-shortcut-categories/types.js").AgentShortcutCategorySliceState;
656
656
  surfaceUserState: import("../../../../surfaces/redux/userStateSlice.js").SurfaceUserStateSlice;
@@ -746,7 +746,7 @@ export declare const selectActiveInstancesByDisplayMode: ((state: {
746
746
  voiceAgent: import("../../../../voice-agent/types.js").VoiceAgentState;
747
747
  agentDefinition: import("../../../types/agent-definition.types.js").AgentDefinitionSliceState;
748
748
  conversationList: import("../../conversation-list/conversation-list.types.js").ConversationListState;
749
- conversationHistory: import("../../conversation-history/index.js").ConversationHistoryState;
749
+ conversationHistory: import("../../conversation-history/types.js").ConversationHistoryState;
750
750
  agentShortcut: import("../../agent-shortcuts/types.js").AgentShortcutSliceState;
751
751
  agentShortcutCategory: import("../../agent-shortcut-categories/types.js").AgentShortcutCategorySliceState;
752
752
  surfaceUserState: import("../../../../surfaces/redux/userStateSlice.js").SurfaceUserStateSlice;
@@ -813,7 +813,7 @@ export declare const selectOverlayInstancesByDisplayMode: ((state: {
813
813
  voiceAgent: import("../../../../voice-agent/types.js").VoiceAgentState;
814
814
  agentDefinition: import("../../../types/agent-definition.types.js").AgentDefinitionSliceState;
815
815
  conversationList: import("../../conversation-list/conversation-list.types.js").ConversationListState;
816
- conversationHistory: import("../../conversation-history/index.js").ConversationHistoryState;
816
+ conversationHistory: import("../../conversation-history/types.js").ConversationHistoryState;
817
817
  agentShortcut: import("../../agent-shortcuts/types.js").AgentShortcutSliceState;
818
818
  agentShortcutCategory: import("../../agent-shortcut-categories/types.js").AgentShortcutCategorySliceState;
819
819
  surfaceUserState: import("../../../../surfaces/redux/userStateSlice.js").SurfaceUserStateSlice;
@@ -879,7 +879,7 @@ export declare const selectActiveModalInstanceIds: ((state: {
879
879
  voiceAgent: import("../../../../voice-agent/types.js").VoiceAgentState;
880
880
  agentDefinition: import("../../../types/agent-definition.types.js").AgentDefinitionSliceState;
881
881
  conversationList: import("../../conversation-list/conversation-list.types.js").ConversationListState;
882
- conversationHistory: import("../../conversation-history/index.js").ConversationHistoryState;
882
+ conversationHistory: import("../../conversation-history/types.js").ConversationHistoryState;
883
883
  agentShortcut: import("../../agent-shortcuts/types.js").AgentShortcutSliceState;
884
884
  agentShortcutCategory: import("../../agent-shortcut-categories/types.js").AgentShortcutCategorySliceState;
885
885
  surfaceUserState: import("../../../../surfaces/redux/userStateSlice.js").SurfaceUserStateSlice;
@@ -945,7 +945,7 @@ export declare const selectActivePanelInstanceIds: ((state: {
945
945
  voiceAgent: import("../../../../voice-agent/types.js").VoiceAgentState;
946
946
  agentDefinition: import("../../../types/agent-definition.types.js").AgentDefinitionSliceState;
947
947
  conversationList: import("../../conversation-list/conversation-list.types.js").ConversationListState;
948
- conversationHistory: import("../../conversation-history/index.js").ConversationHistoryState;
948
+ conversationHistory: import("../../conversation-history/types.js").ConversationHistoryState;
949
949
  agentShortcut: import("../../agent-shortcuts/types.js").AgentShortcutSliceState;
950
950
  agentShortcutCategory: import("../../agent-shortcut-categories/types.js").AgentShortcutCategorySliceState;
951
951
  surfaceUserState: import("../../../../surfaces/redux/userStateSlice.js").SurfaceUserStateSlice;
@@ -1022,7 +1022,7 @@ export declare const selectLatestRenderBlocks: (conversationId: string) => ((sta
1022
1022
  voiceAgent: import("../../../../voice-agent/types.js").VoiceAgentState;
1023
1023
  agentDefinition: import("../../../types/agent-definition.types.js").AgentDefinitionSliceState;
1024
1024
  conversationList: import("../../conversation-list/conversation-list.types.js").ConversationListState;
1025
- conversationHistory: import("../../conversation-history/index.js").ConversationHistoryState;
1025
+ conversationHistory: import("../../conversation-history/types.js").ConversationHistoryState;
1026
1026
  agentShortcut: import("../../agent-shortcuts/types.js").AgentShortcutSliceState;
1027
1027
  agentShortcutCategory: import("../../agent-shortcut-categories/types.js").AgentShortcutCategorySliceState;
1028
1028
  surfaceUserState: import("../../../../surfaces/redux/userStateSlice.js").SurfaceUserStateSlice;
@@ -1093,7 +1093,7 @@ export declare const selectLatestActiveTools: (conversationId: string) => ((stat
1093
1093
  voiceAgent: import("../../../../voice-agent/types.js").VoiceAgentState;
1094
1094
  agentDefinition: import("../../../types/agent-definition.types.js").AgentDefinitionSliceState;
1095
1095
  conversationList: import("../../conversation-list/conversation-list.types.js").ConversationListState;
1096
- conversationHistory: import("../../conversation-history/index.js").ConversationHistoryState;
1096
+ conversationHistory: import("../../conversation-history/types.js").ConversationHistoryState;
1097
1097
  agentShortcut: import("../../agent-shortcuts/types.js").AgentShortcutSliceState;
1098
1098
  agentShortcutCategory: import("../../agent-shortcut-categories/types.js").AgentShortcutCategorySliceState;
1099
1099
  surfaceUserState: import("../../../../surfaces/redux/userStateSlice.js").SurfaceUserStateSlice;
@@ -1160,7 +1160,7 @@ export declare const selectLatestToolLifecycles: (conversationId: string) => ((s
1160
1160
  voiceAgent: import("../../../../voice-agent/types.js").VoiceAgentState;
1161
1161
  agentDefinition: import("../../../types/agent-definition.types.js").AgentDefinitionSliceState;
1162
1162
  conversationList: import("../../conversation-list/conversation-list.types.js").ConversationListState;
1163
- conversationHistory: import("../../conversation-history/index.js").ConversationHistoryState;
1163
+ conversationHistory: import("../../conversation-history/types.js").ConversationHistoryState;
1164
1164
  agentShortcut: import("../../agent-shortcuts/types.js").AgentShortcutSliceState;
1165
1165
  agentShortcutCategory: import("../../agent-shortcut-categories/types.js").AgentShortcutCategorySliceState;
1166
1166
  surfaceUserState: import("../../../../surfaces/redux/userStateSlice.js").SurfaceUserStateSlice;
@@ -1272,7 +1272,7 @@ export declare const makeSelectAvailableShortcuts: (context: ShortcutContext) =>
1272
1272
  voiceAgent: import("../../../../voice-agent/types.js").VoiceAgentState;
1273
1273
  agentDefinition: import("../../../types/agent-definition.types.js").AgentDefinitionSliceState;
1274
1274
  conversationList: import("../../conversation-list/conversation-list.types.js").ConversationListState;
1275
- conversationHistory: import("../../conversation-history/index.js").ConversationHistoryState;
1275
+ conversationHistory: import("../../conversation-history/types.js").ConversationHistoryState;
1276
1276
  agentShortcut: import("../../agent-shortcuts/types.js").AgentShortcutSliceState;
1277
1277
  agentShortcutCategory: import("../../agent-shortcut-categories/types.js").AgentShortcutCategorySliceState;
1278
1278
  surfaceUserState: import("../../../../surfaces/redux/userStateSlice.js").SurfaceUserStateSlice;
@@ -169,7 +169,16 @@ interface StartNewConversationArgs {
169
169
  * Dispatches setFocus to switch the surface to the new conversation.
170
170
  * The old conversation remains fully cached in Redux.
171
171
  */
172
- export declare const startNewConversation: import("@reduxjs/toolkit").AsyncThunk<string, StartNewConversationArgs, import("@reduxjs/toolkit").AsyncThunkConfig>;
172
+ export declare const startNewConversation: import("@reduxjs/toolkit").AsyncThunk<string, StartNewConversationArgs, {
173
+ dispatch?: import("redux-thunk").ThunkDispatch<unknown, unknown, import("redux").UnknownAction>;
174
+ extra?: unknown;
175
+ rejectValue?: unknown;
176
+ serializedErrorType?: unknown;
177
+ pendingMeta?: unknown;
178
+ fulfilledMeta?: unknown;
179
+ rejectedMeta?: unknown;
180
+ state: ChatRootState;
181
+ }>;
173
182
  interface StartNewConversationAndExecuteArgs {
174
183
  currentConversationId: string;
175
184
  surfaceKey: string;
@@ -478,100 +478,110 @@ const createManualInstanceNoAgent = createAsyncThunk(
478
478
  return conversationId;
479
479
  }
480
480
  );
481
+ function cloneConversationShell(state, dispatch, { currentConversationId, autoClear, apiEndpointMode, carryText }) {
482
+ const instance = state.conversations.byConversationId[currentConversationId];
483
+ if (!instance) {
484
+ throw new Error(`Conversation ${currentConversationId} not found`);
485
+ }
486
+ const { agentId, origin, sourceFeature } = instance;
487
+ const currentUIState = state.instanceUIState.byConversationId[currentConversationId];
488
+ const currentInput = state.instanceUserInput.byConversationId[currentConversationId];
489
+ const snapshot = agentId ? readAgentSnapshot(state, agentId) : null;
490
+ const newConversationId = generateConversationId();
491
+ dispatch(
492
+ createInstance({
493
+ conversationId: newConversationId,
494
+ agentId,
495
+ agentType: snapshot?.agentType ?? instance.agentType,
496
+ origin,
497
+ sourceFeature,
498
+ // Lifecycle stays in lockstep with the uiState inherited below.
499
+ conversationLifecycle: deriveConversationLifecycle(
500
+ autoClear,
501
+ currentUIState?.showAutoClearToggle
502
+ )
503
+ })
504
+ );
505
+ dispatch(
506
+ initInstanceOverrides({
507
+ conversationId: newConversationId,
508
+ baseSettings: snapshot?.baseSettings ?? {}
509
+ })
510
+ );
511
+ dispatch(
512
+ initInputCapabilities({
513
+ conversationId: newConversationId,
514
+ base: snapshot?.inputCapabilities ?? {}
515
+ })
516
+ );
517
+ dispatch(
518
+ initInstanceVariables({
519
+ conversationId: newConversationId,
520
+ definitions: snapshot?.variableDefinitions ?? [],
521
+ scopeValues: {}
522
+ })
523
+ );
524
+ dispatch(initInstanceResources({ conversationId: newConversationId }));
525
+ dispatch(initInstanceContext({ conversationId: newConversationId }));
526
+ dispatch(
527
+ initInstanceUserInput({
528
+ conversationId: newConversationId,
529
+ ...carryText !== void 0 ? { text: carryText } : {},
530
+ lastSubmittedText: currentInput?.lastSubmittedText,
531
+ lastSubmittedUserValues: currentInput?.lastSubmittedUserValues,
532
+ originalSubmittedText: currentInput?.originalSubmittedText,
533
+ originalSubmittedUserValues: currentInput?.originalSubmittedUserValues,
534
+ originalSubmittedAttachments: currentInput?.originalSubmittedAttachments
535
+ })
536
+ );
537
+ dispatch(initInstanceClientTools({ conversationId: newConversationId }));
538
+ dispatch(
539
+ initInstanceUIState({
540
+ conversationId: newConversationId,
541
+ displayMode: currentUIState?.displayMode,
542
+ isCreator: snapshot?.isCreator ?? currentUIState?.isCreator ?? false,
543
+ autoClearConversation: autoClear,
544
+ showAutoClearToggle: currentUIState?.showAutoClearToggle,
545
+ autoRun: currentUIState?.autoRun,
546
+ allowChat: currentUIState?.allowChat,
547
+ showPreExecutionGate: currentUIState?.showPreExecutionGate,
548
+ showVariablePanel: (snapshot?.variableDefinitions?.length ?? 0) > 0 || (currentUIState?.showVariablePanel ?? false),
549
+ showDefinitionMessages: currentUIState?.showDefinitionMessages,
550
+ showDefinitionMessageContent: currentUIState?.showDefinitionMessageContent,
551
+ hiddenMessageCount: currentUIState?.hiddenMessageCount,
552
+ widgetHandleId: currentUIState?.widgetHandleId,
553
+ // The slice defaults these to true / false when absent.
554
+ submitOnEnter: currentUIState?.submitOnEnter,
555
+ reuseConversationId: currentUIState?.reuseConversationId,
556
+ builderAdvancedSettings: currentUIState?.builderAdvancedSettings,
557
+ hideReasoning: currentUIState?.hideReasoning,
558
+ hideToolResults: currentUIState?.hideToolResults,
559
+ responseDensity: currentUIState?.responseDensity,
560
+ preExecutionMessage: currentUIState?.preExecutionMessage,
561
+ variablesPanelStyle: currentUIState?.variablesPanelStyle,
562
+ jsonExtraction: currentUIState?.jsonExtraction,
563
+ originalText: currentUIState?.originalText
564
+ })
565
+ );
566
+ dispatch(
567
+ initInstanceMessages({
568
+ conversationId: newConversationId,
569
+ apiEndpointMode
570
+ })
571
+ );
572
+ return newConversationId;
573
+ }
481
574
  const startNewConversation = createAsyncThunk(
482
575
  "instances/startNewConversation",
483
576
  async ({ currentConversationId, surfaceKey }, { dispatch, getState }) => {
484
577
  const state = getState();
485
- const instance = state.conversations.byConversationId[currentConversationId];
486
- if (!instance) {
487
- throw new Error(`Conversation ${currentConversationId} not found`);
488
- }
489
- const { agentId, sourceFeature } = instance;
490
578
  const currentUIState = state.instanceUIState.byConversationId[currentConversationId];
491
- const currentInputEntry = state.instanceUserInput.byConversationId[currentConversationId];
492
- const snapshot = agentId ? readAgentSnapshot(state, agentId) : null;
493
- const newConversationId = generateConversationId();
494
- dispatch(
495
- createInstance({
496
- conversationId: newConversationId,
497
- agentId,
498
- agentType: snapshot?.agentType ?? instance.agentType,
499
- origin: instance.origin,
500
- sourceFeature,
501
- // Keep the new conversation's lifecycle in lockstep with the uiState it
502
- // inherits below (autoClear defaults ON here, mirroring the builder's
503
- // fresh-start affordance).
504
- conversationLifecycle: deriveConversationLifecycle(
505
- currentUIState?.autoClearConversation ?? true,
506
- currentUIState?.showAutoClearToggle
507
- )
508
- })
509
- );
510
- dispatch(
511
- initInstanceOverrides({
512
- conversationId: newConversationId,
513
- baseSettings: snapshot?.baseSettings ?? {}
514
- })
515
- );
516
- dispatch(
517
- initInputCapabilities({
518
- conversationId: newConversationId,
519
- base: snapshot?.inputCapabilities ?? {}
520
- })
521
- );
522
- dispatch(
523
- initInstanceVariables({
524
- conversationId: newConversationId,
525
- definitions: snapshot?.variableDefinitions ?? [],
526
- scopeValues: {}
527
- })
528
- );
529
- dispatch(initInstanceResources({ conversationId: newConversationId }));
530
- dispatch(initInstanceContext({ conversationId: newConversationId }));
531
- dispatch(
532
- initInstanceUserInput({
533
- conversationId: newConversationId,
534
- lastSubmittedText: currentInputEntry?.lastSubmittedText,
535
- lastSubmittedUserValues: currentInputEntry?.lastSubmittedUserValues,
536
- originalSubmittedText: currentInputEntry?.originalSubmittedText,
537
- originalSubmittedUserValues: currentInputEntry?.originalSubmittedUserValues,
538
- originalSubmittedAttachments: currentInputEntry?.originalSubmittedAttachments
539
- })
540
- );
541
- dispatch(initInstanceClientTools({ conversationId: newConversationId }));
542
- dispatch(
543
- initInstanceUIState({
544
- conversationId: newConversationId,
545
- displayMode: currentUIState?.displayMode,
546
- isCreator: snapshot?.isCreator ?? currentUIState?.isCreator ?? false,
547
- autoClearConversation: currentUIState?.autoClearConversation ?? true,
548
- showAutoClearToggle: currentUIState?.showAutoClearToggle,
549
- autoRun: currentUIState?.autoRun,
550
- allowChat: currentUIState?.allowChat,
551
- showPreExecutionGate: currentUIState?.showPreExecutionGate,
552
- showVariablePanel: (snapshot?.variableDefinitions?.length ?? 0) > 0 || (currentUIState?.showVariablePanel ?? false),
553
- showDefinitionMessages: currentUIState?.showDefinitionMessages,
554
- showDefinitionMessageContent: currentUIState?.showDefinitionMessageContent,
555
- hiddenMessageCount: currentUIState?.hiddenMessageCount,
556
- widgetHandleId: currentUIState?.widgetHandleId,
557
- submitOnEnter: currentUIState?.submitOnEnter,
558
- reuseConversationId: currentUIState?.reuseConversationId,
559
- builderAdvancedSettings: currentUIState?.builderAdvancedSettings,
560
- hideReasoning: currentUIState?.hideReasoning,
561
- hideToolResults: currentUIState?.hideToolResults,
562
- responseDensity: currentUIState?.responseDensity,
563
- preExecutionMessage: currentUIState?.preExecutionMessage,
564
- variablesPanelStyle: currentUIState?.variablesPanelStyle,
565
- jsonExtraction: currentUIState?.jsonExtraction,
566
- originalText: currentUIState?.originalText
567
- })
568
- );
569
- dispatch(
570
- initInstanceMessages({
571
- conversationId: newConversationId,
572
- apiEndpointMode: "agent"
573
- })
574
- );
579
+ const newConversationId = cloneConversationShell(state, dispatch, {
580
+ currentConversationId,
581
+ // Fresh-start affordance: autoClear defaults ON here.
582
+ autoClear: currentUIState?.autoClearConversation ?? true,
583
+ apiEndpointMode: "agent"
584
+ });
575
585
  dispatch(setFocus({ surfaceKey, conversationId: newConversationId }));
576
586
  return newConversationId;
577
587
  }
@@ -586,93 +596,13 @@ const startNewConversationAndExecute = createAsyncThunk(
586
596
  const currentMode = state.messages.byConversationId[currentConversationId]?.apiEndpointMode ?? "agent";
587
597
  const userInputText = currentInput?.text ?? "";
588
598
  const userValues = currentVariables?.userValues ?? {};
589
- const instance = state.conversations.byConversationId[currentConversationId];
590
- if (!instance) {
591
- throw new Error(`Conversation ${currentConversationId} not found`);
592
- }
593
- const { agentId, origin, sourceFeature } = instance;
594
- const newConversationId = generateConversationId();
595
- const snapshot = agentId ? readAgentSnapshot(state, agentId) : null;
596
- dispatch(
597
- createInstance({
598
- conversationId: newConversationId,
599
- agentId,
600
- agentType: snapshot?.agentType ?? instance.agentType,
601
- origin,
602
- sourceFeature,
603
- // The autoclear split IS the iterate affordance — the fresh conversation
604
- // is splittable again on the next submit.
605
- conversationLifecycle: deriveConversationLifecycle(
606
- true,
607
- currentUIState?.showAutoClearToggle
608
- )
609
- })
610
- );
611
- dispatch(
612
- initInstanceOverrides({
613
- conversationId: newConversationId,
614
- baseSettings: snapshot?.baseSettings ?? {}
615
- })
616
- );
617
- dispatch(
618
- initInputCapabilities({
619
- conversationId: newConversationId,
620
- base: snapshot?.inputCapabilities ?? {}
621
- })
622
- );
623
- dispatch(
624
- initInstanceVariables({
625
- conversationId: newConversationId,
626
- definitions: snapshot?.variableDefinitions ?? [],
627
- scopeValues: {}
628
- })
629
- );
630
- dispatch(initInstanceResources({ conversationId: newConversationId }));
631
- dispatch(initInstanceContext({ conversationId: newConversationId }));
632
- dispatch(
633
- initInstanceUserInput({
634
- conversationId: newConversationId,
635
- lastSubmittedText: currentInput?.lastSubmittedText,
636
- lastSubmittedUserValues: currentInput?.lastSubmittedUserValues,
637
- originalSubmittedText: currentInput?.originalSubmittedText,
638
- originalSubmittedUserValues: currentInput?.originalSubmittedUserValues,
639
- originalSubmittedAttachments: currentInput?.originalSubmittedAttachments
640
- })
641
- );
642
- dispatch(initInstanceClientTools({ conversationId: newConversationId }));
643
- dispatch(
644
- initInstanceUIState({
645
- conversationId: newConversationId,
646
- displayMode: currentUIState?.displayMode,
647
- isCreator: snapshot?.isCreator ?? currentUIState?.isCreator ?? false,
648
- autoClearConversation: true,
649
- showAutoClearToggle: currentUIState?.showAutoClearToggle,
650
- autoRun: currentUIState?.autoRun,
651
- allowChat: currentUIState?.allowChat,
652
- showPreExecutionGate: currentUIState?.showPreExecutionGate,
653
- showVariablePanel: (snapshot?.variableDefinitions?.length ?? 0) > 0 || (currentUIState?.showVariablePanel ?? false),
654
- showDefinitionMessages: currentUIState?.showDefinitionMessages,
655
- showDefinitionMessageContent: currentUIState?.showDefinitionMessageContent,
656
- hiddenMessageCount: currentUIState?.hiddenMessageCount,
657
- widgetHandleId: currentUIState?.widgetHandleId,
658
- submitOnEnter: currentUIState?.submitOnEnter ?? true,
659
- reuseConversationId: currentUIState?.reuseConversationId ?? false,
660
- builderAdvancedSettings: currentUIState?.builderAdvancedSettings,
661
- hideReasoning: currentUIState?.hideReasoning,
662
- hideToolResults: currentUIState?.hideToolResults,
663
- responseDensity: currentUIState?.responseDensity,
664
- preExecutionMessage: currentUIState?.preExecutionMessage,
665
- variablesPanelStyle: currentUIState?.variablesPanelStyle,
666
- jsonExtraction: currentUIState?.jsonExtraction,
667
- originalText: currentUIState?.originalText
668
- })
669
- );
670
- dispatch(
671
- initInstanceMessages({
672
- conversationId: newConversationId,
673
- apiEndpointMode: currentMode
674
- })
675
- );
599
+ const newConversationId = cloneConversationShell(state, dispatch, {
600
+ currentConversationId,
601
+ // The autoclear split IS the iterate affordance — the fresh conversation
602
+ // is splittable again on the next submit.
603
+ autoClear: true,
604
+ apiEndpointMode: currentMode
605
+ });
676
606
  dispatch(
677
607
  copyInstanceRequestDraft({
678
608
  sourceConversationId: currentConversationId,
@@ -712,98 +642,17 @@ const splitInputIntoNewConversation = createAsyncThunk(
712
642
  async ({ currentConversationId, surfaceKey }, { dispatch, getState }) => {
713
643
  const state = getState();
714
644
  const currentInput = state.instanceUserInput.byConversationId[currentConversationId];
715
- const currentUIState = state.instanceUIState.byConversationId[currentConversationId];
716
- const instance = state.conversations.byConversationId[currentConversationId];
717
- if (!instance) {
718
- throw new Error(`Conversation ${currentConversationId} not found`);
719
- }
720
- const { agentId, origin, sourceFeature } = instance;
721
- const snapshot = agentId ? readAgentSnapshot(state, agentId) : null;
722
645
  const carryText = currentInput?.lastSubmittedText ?? "";
723
646
  const carryUserValues = currentInput?.lastSubmittedUserValues ?? {};
724
647
  const currentMode = state.messages.byConversationId[currentConversationId]?.apiEndpointMode ?? "agent";
725
- const newConversationId = generateConversationId();
726
- dispatch(
727
- createInstance({
728
- conversationId: newConversationId,
729
- agentId,
730
- agentType: snapshot?.agentType ?? instance.agentType,
731
- origin,
732
- sourceFeature,
733
- // This IS the split — the fresh conversation must remain "iterate" so
734
- // the next submit can split it again.
735
- conversationLifecycle: deriveConversationLifecycle(
736
- true,
737
- currentUIState?.showAutoClearToggle
738
- )
739
- })
740
- );
741
- dispatch(
742
- initInstanceOverrides({
743
- conversationId: newConversationId,
744
- baseSettings: snapshot?.baseSettings ?? {}
745
- })
746
- );
747
- dispatch(
748
- initInputCapabilities({
749
- conversationId: newConversationId,
750
- base: snapshot?.inputCapabilities ?? {}
751
- })
752
- );
753
- dispatch(
754
- initInstanceVariables({
755
- conversationId: newConversationId,
756
- definitions: snapshot?.variableDefinitions ?? [],
757
- scopeValues: {}
758
- })
759
- );
760
- dispatch(initInstanceResources({ conversationId: newConversationId }));
761
- dispatch(initInstanceContext({ conversationId: newConversationId }));
762
- dispatch(
763
- initInstanceUserInput({
764
- conversationId: newConversationId,
765
- text: carryText,
766
- lastSubmittedText: currentInput?.lastSubmittedText,
767
- lastSubmittedUserValues: currentInput?.lastSubmittedUserValues,
768
- originalSubmittedText: currentInput?.originalSubmittedText,
769
- originalSubmittedUserValues: currentInput?.originalSubmittedUserValues,
770
- originalSubmittedAttachments: currentInput?.originalSubmittedAttachments
771
- })
772
- );
773
- dispatch(initInstanceClientTools({ conversationId: newConversationId }));
774
- dispatch(
775
- initInstanceUIState({
776
- conversationId: newConversationId,
777
- displayMode: currentUIState?.displayMode,
778
- isCreator: snapshot?.isCreator ?? currentUIState?.isCreator ?? false,
779
- autoClearConversation: true,
780
- showAutoClearToggle: currentUIState?.showAutoClearToggle,
781
- autoRun: currentUIState?.autoRun,
782
- allowChat: currentUIState?.allowChat,
783
- showPreExecutionGate: currentUIState?.showPreExecutionGate,
784
- showVariablePanel: (snapshot?.variableDefinitions?.length ?? 0) > 0 || (currentUIState?.showVariablePanel ?? false),
785
- showDefinitionMessages: currentUIState?.showDefinitionMessages,
786
- showDefinitionMessageContent: currentUIState?.showDefinitionMessageContent,
787
- hiddenMessageCount: currentUIState?.hiddenMessageCount,
788
- widgetHandleId: currentUIState?.widgetHandleId,
789
- submitOnEnter: currentUIState?.submitOnEnter ?? true,
790
- reuseConversationId: currentUIState?.reuseConversationId ?? false,
791
- builderAdvancedSettings: currentUIState?.builderAdvancedSettings,
792
- hideReasoning: currentUIState?.hideReasoning,
793
- hideToolResults: currentUIState?.hideToolResults,
794
- responseDensity: currentUIState?.responseDensity,
795
- preExecutionMessage: currentUIState?.preExecutionMessage,
796
- variablesPanelStyle: currentUIState?.variablesPanelStyle,
797
- jsonExtraction: currentUIState?.jsonExtraction,
798
- originalText: currentUIState?.originalText
799
- })
800
- );
801
- dispatch(
802
- initInstanceMessages({
803
- conversationId: newConversationId,
804
- apiEndpointMode: currentMode
805
- })
806
- );
648
+ const newConversationId = cloneConversationShell(state, dispatch, {
649
+ currentConversationId,
650
+ // This IS the split — the fresh conversation must remain "iterate" so
651
+ // the next submit can split it again.
652
+ autoClear: true,
653
+ apiEndpointMode: currentMode,
654
+ carryText
655
+ });
807
656
  dispatch(
808
657
  copyInstanceRequestDraft({
809
658
  sourceConversationId: currentConversationId,
@@ -4,13 +4,26 @@ import { upsertToolLifecycle } from "../active-requests/active-requests.slice.js
4
4
  import { invokeMatrxExtendTool } from "../../../../host/server/extension-bridge.js";
5
5
  import { getChatHost, isChatHostConfigured } from "../../../../host/configure.js";
6
6
  import { extractErrorMessage } from "@ai-matrx/data/net";
7
+ import { trackInFlightDeviceCall } from "../../../../host/device-tool-handoff.js";
8
+ import { getLatchedTurn, readDevicePermissionMode } from "../utils/host-turn.js";
7
9
  const dispatchMatrxExtendTool = createAsyncThunk(
8
10
  "matrxExtendTools/dispatch",
9
- async ({ conversationId, requestId, callId, toolName, args }, { dispatch }) => {
11
+ async ({ conversationId, requestId, callId, toolName, args }, { dispatch, getState }) => {
10
12
  const startedAt = performance.now();
13
+ const tracked = trackInFlightDeviceCall({ conversationId, requestId, callId, toolName, args });
11
14
  try {
12
15
  const deviceTools = isChatHostConfigured() ? getChatHost().deviceTools : null;
13
- const invocation = deviceTools ? await deviceTools.invoke(toolName, args, { conversationId, callId }) : await invokeMatrxExtendTool(toolName, args);
16
+ const latched = deviceTools ? getLatchedTurn(conversationId) : null;
17
+ const invocation = deviceTools ? await deviceTools.invoke(toolName, args, {
18
+ conversationId,
19
+ callId,
20
+ agentId: latched?.agentId ?? getState().conversations?.byConversationId?.[conversationId]?.agentId ?? null,
21
+ permissionMode: latched?.permissionMode ?? readDevicePermissionMode(
22
+ getState().conversations?.byConversationId?.[conversationId]?.agentId ?? null
23
+ ),
24
+ ...latched?.deviceRef !== void 0 && { deviceRef: latched.deviceRef }
25
+ }) : await invokeMatrxExtendTool(toolName, args);
26
+ if (tracked.handedOff()) return;
14
27
  if (!invocation.handled) {
15
28
  const message = invocation.reason === "matrx_extend_unavailable" ? `'${toolName}' runs inside the Matrx Extend browser extension, and no Matrx Extend is installed or reachable in this browser right now. Nothing ran and nothing was changed. Tell the user plainly, and ask them to install or enable Matrx Extend and reload this page \u2014 or take a route that does not need the extension.` : `Matrx Extend is installed here, but it does not own a tool named '${toolName}', so nothing ran and nothing was changed. Do not retry the same name: use a tool that is actually offered this turn, or tell the user this capability is not available on this browser.`;
16
29
  dispatch(
@@ -101,6 +114,7 @@ const dispatchMatrxExtendTool = createAsyncThunk(
101
114
  })
102
115
  );
103
116
  } catch (cause) {
117
+ if (tracked.handedOff()) return;
104
118
  const message = extractErrorMessage(cause);
105
119
  dispatch(
106
120
  upsertToolLifecycle({
@@ -133,6 +147,8 @@ const dispatchMatrxExtendTool = createAsyncThunk(
133
147
  duration_ms: Math.round(performance.now() - startedAt)
134
148
  })
135
149
  );
150
+ } finally {
151
+ tracked.done();
136
152
  }
137
153
  }
138
154
  );
@@ -1,7 +1,6 @@
1
1
  import { createAsyncThunk } from "@reduxjs/toolkit";
2
2
  import { extractErrorMessage } from "@ai-matrx/data/net";
3
- import { submitToolResult } from "../../../api/submit-tool-results.js";
4
- import { upsertToolLifecycle } from "../active-requests/active-requests.slice.js";
3
+ import { postDelegatedToolOutcome } from "./post-delegated-tool-outcome.js";
5
4
  import { executeSurfaceClientTool } from "../../../../surfaces/runtime/surface-client-tools.js";
6
5
  import { createSurfaceToolCall } from "./surface-tool-call.js";
7
6
  const dispatchSurfaceClientTool = createAsyncThunk(
@@ -9,32 +8,15 @@ const dispatchSurfaceClientTool = createAsyncThunk(
9
8
  async ({ conversationId, requestId, callId, toolName, args }, { dispatch, getState }) => {
10
9
  const startedAt = performance.now();
11
10
  const finish = (output, errorMessage) => {
12
- const durationMs = Math.round(performance.now() - startedAt);
13
- dispatch(
14
- upsertToolLifecycle({
15
- requestId,
16
- callId,
17
- toolName,
18
- status: errorMessage ? "error" : "completed",
19
- isDelegated: true,
20
- result: output,
21
- ...errorMessage ? {
22
- errorType: "surface_client_tool_failed",
23
- errorMessage
24
- } : {}
25
- })
26
- );
27
- dispatch(
28
- submitToolResult({
29
- conversationId,
30
- call_id: callId,
31
- tool_name: toolName,
32
- is_error: Boolean(errorMessage),
33
- output,
34
- duration_ms: durationMs,
35
- ...errorMessage ? { error_message: errorMessage } : {}
36
- })
37
- );
11
+ postDelegatedToolOutcome(dispatch, {
12
+ conversationId,
13
+ requestId,
14
+ callId,
15
+ toolName,
16
+ output,
17
+ error: errorMessage ? { type: "surface_client_tool_failed", message: errorMessage } : void 0,
18
+ durationMs: Math.round(performance.now() - startedAt)
19
+ });
38
20
  };
39
21
  try {
40
22
  const call = await createSurfaceToolCall({