@assistant-ui/react 0.14.14 → 0.14.15

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 (207) hide show
  1. package/README.md +5 -1
  2. package/dist/client/ExternalThread.d.ts +2 -12
  3. package/dist/client/ExternalThread.d.ts.map +1 -1
  4. package/dist/client/ExternalThread.js +30 -29
  5. package/dist/client/ExternalThread.js.map +1 -1
  6. package/dist/client/InMemoryThreadList.d.ts.map +1 -1
  7. package/dist/client/InMemoryThreadList.js +11 -10
  8. package/dist/client/InMemoryThreadList.js.map +1 -1
  9. package/dist/client/SingleThreadList.d.ts.map +1 -1
  10. package/dist/client/SingleThreadList.js +9 -8
  11. package/dist/client/SingleThreadList.js.map +1 -1
  12. package/dist/context/providers/ThreadViewportProvider.js +1 -1
  13. package/dist/context/providers/ThreadViewportProvider.js.map +1 -1
  14. package/dist/context/react/ThreadViewportContext.js +1 -1
  15. package/dist/context/react/utils/createContextHook.js +1 -1
  16. package/dist/context/react/utils/ensureBinding.js.map +1 -1
  17. package/dist/context/react/utils/useRuntimeState.js +1 -1
  18. package/dist/context/stores/ThreadViewport.js.map +1 -1
  19. package/dist/devtools/DevToolsHooks.js.map +1 -1
  20. package/dist/index.d.ts +4 -4
  21. package/dist/index.js +3 -3
  22. package/dist/legacy-runtime/AssistantRuntimeProvider.js +1 -1
  23. package/dist/legacy-runtime/cloud/auiV0.js +1 -1
  24. package/dist/legacy-runtime/hooks/AssistantContext.js.map +1 -1
  25. package/dist/legacy-runtime/hooks/AttachmentContext.js.map +1 -1
  26. package/dist/legacy-runtime/hooks/ComposerContext.js.map +1 -1
  27. package/dist/legacy-runtime/hooks/MessageContext.js.map +1 -1
  28. package/dist/legacy-runtime/hooks/MessagePartContext.js.map +1 -1
  29. package/dist/legacy-runtime/hooks/ThreadContext.js +1 -1
  30. package/dist/legacy-runtime/hooks/ThreadContext.js.map +1 -1
  31. package/dist/legacy-runtime/hooks/ThreadListItemContext.js.map +1 -1
  32. package/dist/legacy-runtime/runtime-cores/assistant-transport/commandQueue.js +1 -1
  33. package/dist/legacy-runtime/runtime-cores/assistant-transport/replayBoundaryStream.js +1 -1
  34. package/dist/legacy-runtime/runtime-cores/assistant-transport/runManager.js +1 -1
  35. package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.js +1 -1
  36. package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.js.map +1 -1
  37. package/dist/legacy-runtime/runtime-cores/assistant-transport/useConvertedState.js +1 -1
  38. package/dist/legacy-runtime/runtime-cores/assistant-transport/useLatestRef.js +1 -1
  39. package/dist/mcp-apps/McpAppRenderer.d.ts.map +1 -1
  40. package/dist/mcp-apps/McpAppRenderer.js +7 -7
  41. package/dist/mcp-apps/McpAppRenderer.js.map +1 -1
  42. package/dist/mcp-apps/McpAppsRemoteHost.d.ts.map +1 -1
  43. package/dist/mcp-apps/McpAppsRemoteHost.js +5 -4
  44. package/dist/mcp-apps/McpAppsRemoteHost.js.map +1 -1
  45. package/dist/mcp-apps/app-frame.d.ts +1 -1
  46. package/dist/mcp-apps/app-frame.d.ts.map +1 -1
  47. package/dist/mcp-apps/app-frame.js +82 -104
  48. package/dist/mcp-apps/app-frame.js.map +1 -1
  49. package/dist/mcp-apps/bridge.d.ts +3 -3
  50. package/dist/mcp-apps/bridge.d.ts.map +1 -1
  51. package/dist/mcp-apps/bridge.js +35 -10
  52. package/dist/mcp-apps/bridge.js.map +1 -1
  53. package/dist/mcp-apps/types.d.ts +2 -12
  54. package/dist/mcp-apps/types.d.ts.map +1 -1
  55. package/dist/mcp-apps/types.js.map +1 -1
  56. package/dist/model-context/frame/useAssistantFrameHost.js +1 -1
  57. package/dist/model-context/makeAssistantVisible.js +1 -1
  58. package/dist/model-context/makeAssistantVisible.js.map +1 -1
  59. package/dist/primitives/actionBar/ActionBarCopy.js +1 -1
  60. package/dist/primitives/actionBar/ActionBarExportMarkdown.js +1 -1
  61. package/dist/primitives/actionBar/ActionBarExportMarkdown.js.map +1 -1
  62. package/dist/primitives/actionBar/ActionBarFeedbackNegative.js +1 -1
  63. package/dist/primitives/actionBar/ActionBarFeedbackPositive.js +1 -1
  64. package/dist/primitives/actionBar/ActionBarInteractionContext.js +1 -1
  65. package/dist/primitives/actionBar/ActionBarRoot.js +1 -1
  66. package/dist/primitives/actionBar/ActionBarStopSpeaking.js +1 -1
  67. package/dist/primitives/actionBarMore/ActionBarMoreContent.js +1 -1
  68. package/dist/primitives/actionBarMore/ActionBarMoreItem.js +1 -1
  69. package/dist/primitives/actionBarMore/ActionBarMoreRoot.js +1 -1
  70. package/dist/primitives/actionBarMore/ActionBarMoreSeparator.js +1 -1
  71. package/dist/primitives/actionBarMore/ActionBarMoreTrigger.js +1 -1
  72. package/dist/primitives/assistantModal/AssistantModalAnchor.js +1 -1
  73. package/dist/primitives/assistantModal/AssistantModalContent.js +1 -1
  74. package/dist/primitives/assistantModal/AssistantModalRoot.js +1 -1
  75. package/dist/primitives/assistantModal/AssistantModalTrigger.js +1 -1
  76. package/dist/primitives/attachment/AttachmentRemove.js +1 -1
  77. package/dist/primitives/attachment/AttachmentRemove.js.map +1 -1
  78. package/dist/primitives/attachment/AttachmentRoot.js +1 -1
  79. package/dist/primitives/attachment/AttachmentThumb.js +1 -1
  80. package/dist/primitives/branchPicker/BranchPickerRoot.js +1 -1
  81. package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.js +1 -1
  82. package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.js.map +1 -1
  83. package/dist/primitives/chainOfThought/ChainOfThoughtRoot.js +1 -1
  84. package/dist/primitives/composer/ComposerAddAttachment.js +1 -1
  85. package/dist/primitives/composer/ComposerAddAttachment.js.map +1 -1
  86. package/dist/primitives/composer/ComposerAttachmentDropzone.js +1 -1
  87. package/dist/primitives/composer/ComposerAttachmentDropzone.js.map +1 -1
  88. package/dist/primitives/composer/ComposerDictationTranscript.js +1 -1
  89. package/dist/primitives/composer/ComposerInput.js +1 -1
  90. package/dist/primitives/composer/ComposerInput.js.map +1 -1
  91. package/dist/primitives/composer/ComposerInputPluginContext.js +1 -1
  92. package/dist/primitives/composer/ComposerQuote.js +1 -1
  93. package/dist/primitives/composer/ComposerQuote.js.map +1 -1
  94. package/dist/primitives/composer/ComposerRoot.js +1 -1
  95. package/dist/primitives/composer/ComposerSend.js +1 -1
  96. package/dist/primitives/composer/ComposerStopDictation.js +1 -1
  97. package/dist/primitives/composer/ComposerStopDictation.js.map +1 -1
  98. package/dist/primitives/composer/trigger/TriggerPopover.js +2 -2
  99. package/dist/primitives/composer/trigger/TriggerPopover.js.map +1 -1
  100. package/dist/primitives/composer/trigger/TriggerPopoverAction.js +1 -1
  101. package/dist/primitives/composer/trigger/TriggerPopoverBack.js +1 -1
  102. package/dist/primitives/composer/trigger/TriggerPopoverCategories.js +1 -1
  103. package/dist/primitives/composer/trigger/TriggerPopoverDirective.js +1 -1
  104. package/dist/primitives/composer/trigger/TriggerPopoverItems.js +1 -1
  105. package/dist/primitives/composer/trigger/TriggerPopoverResource.d.ts.map +1 -1
  106. package/dist/primitives/composer/trigger/TriggerPopoverResource.js +8 -7
  107. package/dist/primitives/composer/trigger/TriggerPopoverResource.js.map +1 -1
  108. package/dist/primitives/composer/trigger/TriggerPopoverRootContext.js +1 -1
  109. package/dist/primitives/composer/trigger/triggerDetectionResource.d.ts.map +1 -1
  110. package/dist/primitives/composer/trigger/triggerDetectionResource.js +5 -4
  111. package/dist/primitives/composer/trigger/triggerDetectionResource.js.map +1 -1
  112. package/dist/primitives/composer/trigger/triggerKeyboardResource.d.ts.map +1 -1
  113. package/dist/primitives/composer/trigger/triggerKeyboardResource.js +8 -7
  114. package/dist/primitives/composer/trigger/triggerKeyboardResource.js.map +1 -1
  115. package/dist/primitives/composer/trigger/triggerNavigationResource.d.ts.map +1 -1
  116. package/dist/primitives/composer/trigger/triggerNavigationResource.js +13 -12
  117. package/dist/primitives/composer/trigger/triggerNavigationResource.js.map +1 -1
  118. package/dist/primitives/composer/trigger/triggerSelectionResource.d.ts.map +1 -1
  119. package/dist/primitives/composer/trigger/triggerSelectionResource.js +7 -6
  120. package/dist/primitives/composer/trigger/triggerSelectionResource.js.map +1 -1
  121. package/dist/primitives/error/ErrorMessage.js +1 -1
  122. package/dist/primitives/error/ErrorRoot.js +1 -1
  123. package/dist/primitives/message/MessagePartsGrouped.js +1 -1
  124. package/dist/primitives/message/MessagePartsGrouped.js.map +1 -1
  125. package/dist/primitives/message/MessageRoot.js +1 -1
  126. package/dist/primitives/message/MessageRoot.js.map +1 -1
  127. package/dist/primitives/messagePart/MessagePartImage.js +1 -1
  128. package/dist/primitives/messagePart/MessagePartText.js +1 -1
  129. package/dist/primitives/queueItem/QueueItemRemove.js +1 -1
  130. package/dist/primitives/queueItem/QueueItemRemove.js.map +1 -1
  131. package/dist/primitives/queueItem/QueueItemSteer.js +1 -1
  132. package/dist/primitives/queueItem/QueueItemSteer.js.map +1 -1
  133. package/dist/primitives/queueItem/QueueItemText.js +1 -1
  134. package/dist/primitives/reasoning/useScrollLock.js +1 -1
  135. package/dist/primitives/reasoning/useScrollLock.js.map +1 -1
  136. package/dist/primitives/selectionToolbar/SelectionToolbarQuote.js +1 -1
  137. package/dist/primitives/selectionToolbar/SelectionToolbarQuote.js.map +1 -1
  138. package/dist/primitives/selectionToolbar/SelectionToolbarRoot.js +1 -1
  139. package/dist/primitives/selectionToolbar/SelectionToolbarRoot.js.map +1 -1
  140. package/dist/primitives/suggestion/SuggestionDescription.js +1 -1
  141. package/dist/primitives/suggestion/SuggestionTitle.js +1 -1
  142. package/dist/primitives/suggestion/SuggestionTrigger.js +1 -1
  143. package/dist/primitives/suggestion/SuggestionTrigger.js.map +1 -1
  144. package/dist/primitives/thread/ThreadRoot.js +1 -1
  145. package/dist/primitives/thread/ThreadScrollToBottom.js +1 -1
  146. package/dist/primitives/thread/ThreadScrollToBottom.js.map +1 -1
  147. package/dist/primitives/thread/ThreadViewport.js +1 -1
  148. package/dist/primitives/thread/ThreadViewport.js.map +1 -1
  149. package/dist/primitives/thread/ThreadViewportFooter.js +1 -1
  150. package/dist/primitives/thread/ThreadViewportFooter.js.map +1 -1
  151. package/dist/primitives/thread/topAnchor/topAnchorTurn.js.map +1 -1
  152. package/dist/primitives/thread/topAnchor/topAnchorUtils.js.map +1 -1
  153. package/dist/primitives/thread/topAnchor/useTopAnchorReserve.js +1 -1
  154. package/dist/primitives/thread/useThreadViewportAutoScroll.js +1 -1
  155. package/dist/primitives/thread/useThreadViewportAutoScroll.js.map +1 -1
  156. package/dist/primitives/threadList/ThreadListNew.js +1 -1
  157. package/dist/primitives/threadList/ThreadListRoot.js +1 -1
  158. package/dist/primitives/threadListItem/ThreadListItemRoot.js +1 -1
  159. package/dist/primitives/threadListItemMore/ThreadListItemMoreContent.js +1 -1
  160. package/dist/primitives/threadListItemMore/ThreadListItemMoreItem.js +1 -1
  161. package/dist/primitives/threadListItemMore/ThreadListItemMoreSeparator.js +1 -1
  162. package/dist/primitives/threadListItemMore/ThreadListItemMoreTrigger.js +1 -1
  163. package/dist/sandbox-host/SandboxHost.d.ts +50 -0
  164. package/dist/sandbox-host/SandboxHost.d.ts.map +1 -0
  165. package/dist/sandbox-host/SandboxHost.js +85 -0
  166. package/dist/sandbox-host/SandboxHost.js.map +1 -0
  167. package/dist/unstable/useMentionAdapter.js +1 -1
  168. package/dist/unstable/useMentionAdapter.js.map +1 -1
  169. package/dist/unstable/useSlashCommandAdapter.js +1 -1
  170. package/dist/unstable/useSlashCommandAdapter.js.map +1 -1
  171. package/dist/utils/Primitive.js +1 -1
  172. package/dist/utils/createActionButton.js +1 -1
  173. package/dist/utils/createActionButton.js.map +1 -1
  174. package/dist/utils/hooks/useManagedRef.js +1 -1
  175. package/dist/utils/hooks/useMediaQuery.js +1 -1
  176. package/dist/utils/hooks/useMediaQuery.js.map +1 -1
  177. package/dist/utils/hooks/useOnResizeContent.js +1 -1
  178. package/dist/utils/hooks/useOnScrollToBottom.js +1 -1
  179. package/dist/utils/hooks/useSizeHandle.js +1 -1
  180. package/dist/utils/json/is-json.js.map +1 -1
  181. package/dist/utils/smooth/SmoothContext.js +1 -1
  182. package/dist/utils/smooth/SmoothContext.js.map +1 -1
  183. package/dist/utils/smooth/useSmooth.js +1 -1
  184. package/dist/utils/smooth/useSmooth.js.map +1 -1
  185. package/dist/utils/useToolArgsFieldStatus.d.ts +2 -2
  186. package/dist/utils/useToolArgsFieldStatus.d.ts.map +1 -1
  187. package/package.json +21 -20
  188. package/src/client/ExternalThread.ts +484 -515
  189. package/src/client/InMemoryThreadList.ts +153 -162
  190. package/src/client/SingleThreadList.ts +87 -84
  191. package/src/context/providers/ThreadViewportProvider.tsx +2 -2
  192. package/src/index.ts +8 -1
  193. package/src/mcp-apps/McpAppRenderer.tsx +28 -35
  194. package/src/mcp-apps/McpAppsRemoteHost.ts +25 -24
  195. package/src/mcp-apps/app-frame.tsx +100 -141
  196. package/src/mcp-apps/bridge.test.ts +100 -60
  197. package/src/mcp-apps/bridge.ts +43 -21
  198. package/src/mcp-apps/types.ts +2 -12
  199. package/src/primitives/composer/trigger/TriggerPopover.tsx +1 -1
  200. package/src/primitives/composer/trigger/TriggerPopoverResource.ts +75 -76
  201. package/src/primitives/composer/trigger/triggerDetectionResource.ts +6 -5
  202. package/src/primitives/composer/trigger/triggerKeyboardResource.ts +9 -13
  203. package/src/primitives/composer/trigger/triggerNavigationResource.ts +14 -19
  204. package/src/primitives/composer/trigger/triggerSelectionResource.ts +8 -7
  205. package/src/sandbox-host/SandboxHost.test.tsx +231 -0
  206. package/src/sandbox-host/SandboxHost.tsx +185 -0
  207. package/src/tests/local-runtime-queue.test.tsx +305 -0
@@ -1 +1 @@
1
- {"version":3,"file":"ThreadViewport.js","names":[],"sources":["../../../src/context/stores/ThreadViewport.ts"],"sourcesContent":["\"use client\";\n\nimport { create } from \"zustand\";\nimport type { Unsubscribe } from \"@assistant-ui/core\";\n\nexport type SizeHandle = {\n /** Update the height */\n setHeight: (height: number) => void;\n /** Unregister this handle */\n unregister: Unsubscribe;\n};\n\ntype SizeRegistry = {\n register: () => SizeHandle;\n};\n\nconst createSizeRegistry = (\n onChange: (total: number) => void,\n): SizeRegistry => {\n const entries = new Map<symbol, number>();\n\n const recalculate = () => {\n let total = 0;\n for (const height of entries.values()) {\n total += height;\n }\n onChange(total);\n };\n\n return {\n register: () => {\n const id = Symbol();\n entries.set(id, 0);\n\n return {\n setHeight: (height: number) => {\n if (entries.get(id) !== height) {\n entries.set(id, height);\n recalculate();\n }\n },\n unregister: () => {\n entries.delete(id);\n recalculate();\n },\n };\n },\n };\n};\n\nexport type ThreadViewportState = {\n readonly isAtBottom: boolean;\n readonly scrollToBottom: (config?: {\n behavior?: ScrollBehavior | undefined;\n }) => void;\n readonly onScrollToBottom: (\n callback: ({ behavior }: { behavior: ScrollBehavior }) => void,\n ) => Unsubscribe;\n\n /** Controls scroll anchoring: \"top\" anchors user messages at top, \"bottom\" is classic behavior */\n readonly turnAnchor: \"top\" | \"bottom\";\n\n /** Clamps tall user messages so the assistant response stays in view. */\n readonly topAnchorMessageClamp: {\n readonly tallerThan: string;\n readonly visibleHeight: string;\n };\n\n /** Raw height values from registered elements */\n readonly height: {\n /** Total viewport height */\n readonly viewport: number;\n /** Total content inset height (footer, anchor message, etc.) */\n readonly inset: number;\n };\n\n /** Current DOM elements used for geometry-based top anchoring */\n readonly element: {\n readonly viewport: HTMLElement | null;\n readonly anchor: HTMLElement | null;\n readonly target: HTMLElement | null;\n };\n\n /** Numeric clamp configuration for the active top-anchor target message */\n readonly targetConfig: {\n readonly tallerThan: number;\n readonly visibleHeight: number;\n } | null;\n\n /**\n * The current top-anchor turn activated in this viewport session.\n * History-loaded messages do not populate this; it is set when a run creates\n * a live user/assistant pair and remains after the run completes.\n */\n readonly topAnchorTurn: {\n readonly anchorId: string;\n readonly targetId: string;\n } | null;\n\n /** Register a viewport and get a handle to update its height */\n readonly registerViewport: () => SizeHandle;\n\n /** Register a content inset (footer, anchor message, etc.) and get a handle to update its height */\n readonly registerContentInset: () => SizeHandle;\n\n /** Register the scroll viewport element */\n readonly registerViewportElement: (\n element: HTMLElement | null,\n ) => Unsubscribe;\n\n /** Register the current anchor user message element */\n readonly registerAnchorElement: (element: HTMLElement | null) => Unsubscribe;\n\n /**\n * Register the current top-anchor target (last assistant response) element\n * along with its numeric clamp configuration. When unregistered, both\n * `element.target` and `targetConfig` clear together.\n */\n readonly registerAnchorTargetElement: (\n element: HTMLElement | null,\n config?: { readonly tallerThan: number; readonly visibleHeight: number },\n ) => Unsubscribe;\n\n readonly setTopAnchorTurn: (\n turn: { readonly anchorId: string; readonly targetId: string } | null,\n ) => void;\n};\n\nexport type ThreadViewportStoreOptions = {\n turnAnchor?: \"top\" | \"bottom\" | undefined;\n topAnchorMessageClamp?:\n | {\n tallerThan?: string | undefined;\n visibleHeight?: string | undefined;\n }\n | undefined;\n};\n\nexport const makeThreadViewportStore = (\n options: ThreadViewportStoreOptions = {},\n) => {\n const scrollToBottomListeners = new Set<\n (config: { behavior: ScrollBehavior }) => void\n >();\n\n const viewportRegistry = createSizeRegistry((total) => {\n store.setState({\n height: {\n ...store.getState().height,\n viewport: total,\n },\n });\n });\n const insetRegistry = createSizeRegistry((total) => {\n store.setState({\n height: {\n ...store.getState().height,\n inset: total,\n },\n });\n });\n const registerElementSlot = (\n key: \"viewport\" | \"anchor\",\n element: HTMLElement | null,\n ) => {\n store.setState({\n element: {\n ...store.getState().element,\n [key]: element,\n },\n });\n\n return () => {\n if (store.getState().element[key] !== element) return;\n store.setState({\n element: {\n ...store.getState().element,\n [key]: null,\n },\n });\n };\n };\n\n const store = create<ThreadViewportState>(() => ({\n isAtBottom: true,\n scrollToBottom: ({ behavior = \"auto\" } = {}) => {\n for (const listener of scrollToBottomListeners) {\n listener({ behavior });\n }\n },\n onScrollToBottom: (callback) => {\n scrollToBottomListeners.add(callback);\n return () => {\n scrollToBottomListeners.delete(callback);\n };\n },\n\n turnAnchor: options.turnAnchor ?? \"bottom\",\n topAnchorMessageClamp: {\n tallerThan: options.topAnchorMessageClamp?.tallerThan ?? \"10em\",\n visibleHeight: options.topAnchorMessageClamp?.visibleHeight ?? \"6em\",\n },\n\n height: {\n viewport: 0,\n inset: 0,\n },\n element: {\n viewport: null,\n anchor: null,\n target: null,\n },\n targetConfig: null,\n topAnchorTurn: null,\n\n registerViewport: viewportRegistry.register,\n registerContentInset: insetRegistry.register,\n registerViewportElement: (element) =>\n registerElementSlot(\"viewport\", element),\n registerAnchorElement: (element) => registerElementSlot(\"anchor\", element),\n registerAnchorTargetElement: (element, config) => {\n store.setState({\n element: {\n ...store.getState().element,\n target: element,\n },\n targetConfig: element && config ? config : null,\n });\n\n return () => {\n if (store.getState().element.target !== element) return;\n store.setState({\n element: {\n ...store.getState().element,\n target: null,\n },\n targetConfig: null,\n });\n };\n },\n setTopAnchorTurn: (topAnchorTurn) => {\n store.setState({ topAnchorTurn });\n },\n }));\n\n return store;\n};\n"],"mappings":";;;AAgBA,MAAM,sBACJ,aACiB;CACjB,MAAM,0BAAU,IAAI,IAAoB;CAExC,MAAM,oBAAoB;EACxB,IAAI,QAAQ;EACZ,KAAK,MAAM,UAAU,QAAQ,OAAO,GAClC,SAAS;EAEX,SAAS,KAAK;CAChB;CAEA,OAAO,EACL,gBAAgB;EACd,MAAM,KAAK,OAAO;EAClB,QAAQ,IAAI,IAAI,CAAC;EAEjB,OAAO;GACL,YAAY,WAAmB;IAC7B,IAAI,QAAQ,IAAI,EAAE,MAAM,QAAQ;KAC9B,QAAQ,IAAI,IAAI,MAAM;KACtB,YAAY;IACd;GACF;GACA,kBAAkB;IAChB,QAAQ,OAAO,EAAE;IACjB,YAAY;GACd;EACF;CACF,EACF;AACF;AA0FA,MAAa,2BACX,UAAsC,CAAC,MACpC;CACH,MAAM,0CAA0B,IAAI,IAElC;CAEF,MAAM,mBAAmB,oBAAoB,UAAU;EACrD,MAAM,SAAS,EACb,QAAQ;GACN,GAAG,MAAM,SAAS,EAAE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W,SAAS;IACjD,MAAM,SAAS;KACb,SAAS;MACP,GAAG,MAAM,SAAS,EAAE;MACpB,QAAQ;KACV;KACA,cAAc;IAChB,CAAC;GACH;EACF;EACA,mBAAmB,kBAAkB;GACnC,MAAM,SAAS,EAAE,cAAc,CAAC;EAClC;CACF,EAAE;CAEF,OAAO;AACT"}
1
+ {"version":3,"file":"ThreadViewport.js","names":[],"sources":["../../../src/context/stores/ThreadViewport.ts"],"sourcesContent":["\"use client\";\n\nimport { create } from \"zustand\";\nimport type { Unsubscribe } from \"@assistant-ui/core\";\n\nexport type SizeHandle = {\n /** Update the height */\n setHeight: (height: number) => void;\n /** Unregister this handle */\n unregister: Unsubscribe;\n};\n\ntype SizeRegistry = {\n register: () => SizeHandle;\n};\n\nconst createSizeRegistry = (\n onChange: (total: number) => void,\n): SizeRegistry => {\n const entries = new Map<symbol, number>();\n\n const recalculate = () => {\n let total = 0;\n for (const height of entries.values()) {\n total += height;\n }\n onChange(total);\n };\n\n return {\n register: () => {\n const id = Symbol();\n entries.set(id, 0);\n\n return {\n setHeight: (height: number) => {\n if (entries.get(id) !== height) {\n entries.set(id, height);\n recalculate();\n }\n },\n unregister: () => {\n entries.delete(id);\n recalculate();\n },\n };\n },\n };\n};\n\nexport type ThreadViewportState = {\n readonly isAtBottom: boolean;\n readonly scrollToBottom: (config?: {\n behavior?: ScrollBehavior | undefined;\n }) => void;\n readonly onScrollToBottom: (\n callback: ({ behavior }: { behavior: ScrollBehavior }) => void,\n ) => Unsubscribe;\n\n /** Controls scroll anchoring: \"top\" anchors user messages at top, \"bottom\" is classic behavior */\n readonly turnAnchor: \"top\" | \"bottom\";\n\n /** Clamps tall user messages so the assistant response stays in view. */\n readonly topAnchorMessageClamp: {\n readonly tallerThan: string;\n readonly visibleHeight: string;\n };\n\n /** Raw height values from registered elements */\n readonly height: {\n /** Total viewport height */\n readonly viewport: number;\n /** Total content inset height (footer, anchor message, etc.) */\n readonly inset: number;\n };\n\n /** Current DOM elements used for geometry-based top anchoring */\n readonly element: {\n readonly viewport: HTMLElement | null;\n readonly anchor: HTMLElement | null;\n readonly target: HTMLElement | null;\n };\n\n /** Numeric clamp configuration for the active top-anchor target message */\n readonly targetConfig: {\n readonly tallerThan: number;\n readonly visibleHeight: number;\n } | null;\n\n /**\n * The current top-anchor turn activated in this viewport session.\n * History-loaded messages do not populate this; it is set when a run creates\n * a live user/assistant pair and remains after the run completes.\n */\n readonly topAnchorTurn: {\n readonly anchorId: string;\n readonly targetId: string;\n } | null;\n\n /** Register a viewport and get a handle to update its height */\n readonly registerViewport: () => SizeHandle;\n\n /** Register a content inset (footer, anchor message, etc.) and get a handle to update its height */\n readonly registerContentInset: () => SizeHandle;\n\n /** Register the scroll viewport element */\n readonly registerViewportElement: (\n element: HTMLElement | null,\n ) => Unsubscribe;\n\n /** Register the current anchor user message element */\n readonly registerAnchorElement: (element: HTMLElement | null) => Unsubscribe;\n\n /**\n * Register the current top-anchor target (last assistant response) element\n * along with its numeric clamp configuration. When unregistered, both\n * `element.target` and `targetConfig` clear together.\n */\n readonly registerAnchorTargetElement: (\n element: HTMLElement | null,\n config?: { readonly tallerThan: number; readonly visibleHeight: number },\n ) => Unsubscribe;\n\n readonly setTopAnchorTurn: (\n turn: { readonly anchorId: string; readonly targetId: string } | null,\n ) => void;\n};\n\nexport type ThreadViewportStoreOptions = {\n turnAnchor?: \"top\" | \"bottom\" | undefined;\n topAnchorMessageClamp?:\n | {\n tallerThan?: string | undefined;\n visibleHeight?: string | undefined;\n }\n | undefined;\n};\n\nexport const makeThreadViewportStore = (\n options: ThreadViewportStoreOptions = {},\n) => {\n const scrollToBottomListeners = new Set<\n (config: { behavior: ScrollBehavior }) => void\n >();\n\n const viewportRegistry = createSizeRegistry((total) => {\n store.setState({\n height: {\n ...store.getState().height,\n viewport: total,\n },\n });\n });\n const insetRegistry = createSizeRegistry((total) => {\n store.setState({\n height: {\n ...store.getState().height,\n inset: total,\n },\n });\n });\n const registerElementSlot = (\n key: \"viewport\" | \"anchor\",\n element: HTMLElement | null,\n ) => {\n store.setState({\n element: {\n ...store.getState().element,\n [key]: element,\n },\n });\n\n return () => {\n if (store.getState().element[key] !== element) return;\n store.setState({\n element: {\n ...store.getState().element,\n [key]: null,\n },\n });\n };\n };\n\n const store = create<ThreadViewportState>(() => ({\n isAtBottom: true,\n scrollToBottom: ({ behavior = \"auto\" } = {}) => {\n for (const listener of scrollToBottomListeners) {\n listener({ behavior });\n }\n },\n onScrollToBottom: (callback) => {\n scrollToBottomListeners.add(callback);\n return () => {\n scrollToBottomListeners.delete(callback);\n };\n },\n\n turnAnchor: options.turnAnchor ?? \"bottom\",\n topAnchorMessageClamp: {\n tallerThan: options.topAnchorMessageClamp?.tallerThan ?? \"10em\",\n visibleHeight: options.topAnchorMessageClamp?.visibleHeight ?? \"6em\",\n },\n\n height: {\n viewport: 0,\n inset: 0,\n },\n element: {\n viewport: null,\n anchor: null,\n target: null,\n },\n targetConfig: null,\n topAnchorTurn: null,\n\n registerViewport: viewportRegistry.register,\n registerContentInset: insetRegistry.register,\n registerViewportElement: (element) =>\n registerElementSlot(\"viewport\", element),\n registerAnchorElement: (element) => registerElementSlot(\"anchor\", element),\n registerAnchorTargetElement: (element, config) => {\n store.setState({\n element: {\n ...store.getState().element,\n target: element,\n },\n targetConfig: element && config ? config : null,\n });\n\n return () => {\n if (store.getState().element.target !== element) return;\n store.setState({\n element: {\n ...store.getState().element,\n target: null,\n },\n targetConfig: null,\n });\n };\n },\n setTopAnchorTurn: (topAnchorTurn) => {\n store.setState({ topAnchorTurn });\n },\n }));\n\n return store;\n};\n"],"mappings":";;;AAgBA,MAAM,sBACJ,aACiB;CACjB,MAAM,0BAAU,IAAI,IAAoB;CAExC,MAAM,oBAAoB;EACxB,IAAI,QAAQ;EACZ,KAAK,MAAM,UAAU,QAAQ,OAAO,GAClC,SAAS;EAEX,SAAS,KAAK;CAChB;CAEA,OAAO,EACL,gBAAgB;EACd,MAAM,KAAK,OAAO;EAClB,QAAQ,IAA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AAU;GACV,OAAO;EACT;EACA,SAAS;GACP,UAAU;GACV,QAAQ;GACR,QAAQ;EACV;EACA,cAAc;EACd,eAAe;EAEf,kBAAkB,iBAAiB;EACnC,sBAAsB,cAAc;EACpC,0BAA0B,YACxB,oBAAoB,YAAY,OAAO;EACzC,wBAAwB,YAAY,oBAAoB,UAAU,OAAO;EACzE,8BAA8B,SAAS,WAAW;GAChD,MAAM,SAAS;IACb,SAAS;KACP,GAAG,MAAM,SAAS,CAAC,CAAC;KACpB,QAAQ;IACV;IACA,cAAc,WAAW,SAAS,SAAS;GAC7C,CAAC;GAED,aAAa;IACX,IAAI,MAAM,SAAS,CAAC,CAAC,QAAQ,WAAW,SAAS;IACjD,MAAM,SAAS;KACb,SAAS;MACP,GAAG,MAAM,SAAS,CAAC,CAAC;MACpB,QAAQ;KACV;KACA,cAAc;IAChB,CAAC;GACH;EACF;EACA,mBAAmB,kBAAkB;GACnC,MAAM,SAAS,EAAE,cAAc,CAAC;EAClC;CACF,EAAE;CAEF,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"DevToolsHooks.js","names":[],"sources":["../../src/devtools/DevToolsHooks.ts"],"sourcesContent":["import type { Unsubscribe } from \"@assistant-ui/core\";\nimport type { AssistantClient } from \"@assistant-ui/store\";\n\nexport interface EventLog {\n time: Date;\n event: string;\n data: unknown;\n}\n\ninterface DevToolsApiEntry {\n api: Partial<AssistantClient>;\n logs: EventLog[];\n}\n\ninterface DevToolsHook {\n apis: Map<number, DevToolsApiEntry>;\n nextId: number;\n listeners: Set<(apiId: number) => void>;\n}\n\ndeclare global {\n interface Window {\n __ASSISTANT_UI_DEVTOOLS_HOOK__?: DevToolsHook;\n }\n}\n\nlet cachedHook: DevToolsHook | undefined;\n\nconst getHook = (): DevToolsHook => {\n if (cachedHook) {\n return cachedHook;\n }\n\n const createHook = (): DevToolsHook => ({\n apis: new Map(),\n nextId: 0,\n listeners: new Set(),\n });\n\n if (typeof window === \"undefined\") {\n cachedHook = createHook();\n return cachedHook;\n }\n\n const existingHook = window.__ASSISTANT_UI_DEVTOOLS_HOOK__;\n if (existingHook) {\n cachedHook = existingHook;\n return existingHook;\n }\n\n const newHook = createHook();\n window.__ASSISTANT_UI_DEVTOOLS_HOOK__ = newHook;\n cachedHook = newHook;\n return newHook;\n};\n\nexport class DevToolsHooks {\n static subscribe(listener: () => void): Unsubscribe {\n const hook = getHook();\n hook.listeners.add(listener);\n return () => {\n hook.listeners.delete(listener);\n };\n }\n\n static clearEventLogs(apiId: number): void {\n const hook = getHook();\n const entry = hook.apis.get(apiId);\n if (!entry) return;\n\n entry.logs = [];\n DevToolsHooks.notifyListeners(apiId);\n }\n\n static getApis(): Map<number, DevToolsApiEntry> {\n return getHook().apis;\n }\n\n private static notifyListeners(apiId: number): void {\n const hook = getHook();\n hook.listeners.forEach((listener) => listener(apiId));\n }\n}\n\nexport class DevToolsProviderApi {\n private static readonly MAX_EVENT_LOGS_PER_API = 200;\n\n static register(aui: Partial<AssistantClient>): Unsubscribe {\n const hook = getHook();\n\n for (const entry of hook.apis.values()) {\n if (entry.api === aui) {\n return () => {};\n }\n }\n\n const apiId = hook.nextId++;\n const entry: DevToolsApiEntry = {\n api: aui,\n logs: [],\n };\n\n const eventUnsubscribe = aui.on?.(\"*\", (e) => {\n const entry = hook.apis.get(apiId);\n if (!entry) return;\n\n entry.logs.push({\n time: new Date(),\n event: e.event,\n data: e.payload,\n });\n\n if (entry.logs.length > DevToolsProviderApi.MAX_EVENT_LOGS_PER_API) {\n entry.logs = entry.logs.slice(\n -DevToolsProviderApi.MAX_EVENT_LOGS_PER_API,\n );\n }\n\n DevToolsProviderApi.notifyListeners(apiId);\n });\n\n const stateUnsubscribe = aui.subscribe?.(() => {\n DevToolsProviderApi.notifyListeners(apiId);\n });\n\n hook.apis.set(apiId, entry);\n DevToolsProviderApi.notifyListeners(apiId);\n\n return () => {\n const hook = getHook();\n const entry = hook.apis.get(apiId);\n if (!entry) return;\n\n eventUnsubscribe?.();\n stateUnsubscribe?.();\n\n hook.apis.delete(apiId);\n\n DevToolsProviderApi.notifyListeners(apiId);\n };\n }\n\n private static notifyListeners(apiId: number): void {\n const hook = getHook();\n hook.listeners.forEach((listener) => listener(apiId));\n }\n}\n"],"mappings":";AA0BA,IAAI;AAEJ,MAAM,gBAA8B;CAClC,IAAI,YACF,OAAO;CAGT,MAAM,oBAAkC;EACtC,sBAAM,IAAI,IAAI;EACd,QAAQ;EACR,2BAAW,IAAI,IAAI;CACrB;CAEA,IAAI,OAAO,WAAW,aAAa;EACjC,aAAa,WAAW;EACxB,OAAO;CACT;CAEA,MAAM,eAAe,OAAO;CAC5B,IAAI,cAAc;EAChB,aAAa;EACb,OAAO;CACT;CAEA,MAAM,UAAU,WAAW;CAC3B,OAAO,iCAAiC;CACxC,aAAa;CACb,OAAO;AACT;AAEA,IAAa,gBAAb,MAAa,cAAc;CACzB,OAAO,UAAU,UAAmC;EAClD,MAAM,OAAO,QAAQ;EACrB,KAAK,UAAU,IAAI,QAAQ;EAC3B,aAAa;GACX,KAAK,UAAU,OAAO,QAAQ;EAChC;CACF;CAEA,OAAO,eAAe,OAAqB;EAEzC,MAAM,QADO,QACI,EAAE,KAAK,IAAI,KAAK;EACjC,IAAI,CAAC,OAAO;EAEZ,MAAM,OAAO,CAAC;EACd,cAAc,gBAAgB,KAAK;CACrC;CAEA,OAAO,UAAyC;EAC9C,OAAO,QAAQ,EAAE;CACnB;CAEA,OAAe,gBAAgB,OAAqB;EAElD,QAAG,EAAE,UAAU,SAAS,aAAa,SAAS,KAAK,CAAC;CACtD;AACF;AAEA,IAAa,sBAAb,MAAa,oBAAoB;CAC/B,OAAwB,yBAAyB;CAEjD,OAAO,SAAS,KAA4C;EAC1D,MAAM,OAAO,QAAQ;EAErB,KAAK,MAAM,SAAS,KAAK,KAAK,OAAO,GACnC,IAAI,MAAM,QAAQ,KAChB,aAAa,CAAC;EAIlB,MAAM,QAAQ,KAAK;EACnB,MAAM,QAA0B;GAC9B,KAAK;GACL,MAAM,CAAC;EACT;EAEA,MAAM,mBAAmB,IAAI,KAAK,MAAM,MAAM;GAC5C,MAAM,QAAQ,KAAK,KAAK,IAAI,KAAK;GACjC,IAAI,CAAC,OAAO;GAEZ,MAAM,KAAK,KAAK;IACd,sBAAM,IAAI,KAAK;IACf,OAAO,EAAE;IACT,MAAM,EAAE;GACV,CAAC;GAED,IAAI,MAAM,KAAK,SAAS,oBAAoB,wBAC1C,MAAM,OAAO,MAAM,KAAK,MACtB,CAAC,oBAAoB,sBACvB;GAGF,oBAAoB,gBAAgB,KAAK;EAC3C,CAAC;EAED,MAAM,mBAAmB,IAAI,kBAAkB;GAC7C,oBAAoB,gBAAgB,KAAK;EAC3C,CAAC;EAED,KAAK,KAAK,IAAI,OAAO,KAAK;EAC1B,oBAAoB,gBAAgB,KAAK;EAEzC,aAAa;GACX,MAAM,OAAO,QAAQ;GAErB,IAAI,CADU,KAAK,KAAK,IAAI,KACnB,GAAG;GAEZ,mBAAmB;GACnB,mBAAmB;GAEnB,KAAK,KAAK,OAAO,KAAK;GAEtB,oBAAoB,gBAAgB,KAAK;EAC3C;CACF;CAEA,OAAe,gBAAgB,OAAqB;EAElD,QAAG,EAAE,UAAU,SAAS,aAAa,SAAS,KAAK,CAAC;CACtD;AACF"}
1
+ {"version":3,"file":"DevToolsHooks.js","names":[],"sources":["../../src/devtools/DevToolsHooks.ts"],"sourcesContent":["import type { Unsubscribe } from \"@assistant-ui/core\";\nimport type { AssistantClient } from \"@assistant-ui/store\";\n\nexport interface EventLog {\n time: Date;\n event: string;\n data: unknown;\n}\n\ninterface DevToolsApiEntry {\n api: Partial<AssistantClient>;\n logs: EventLog[];\n}\n\ninterface DevToolsHook {\n apis: Map<number, DevToolsApiEntry>;\n nextId: number;\n listeners: Set<(apiId: number) => void>;\n}\n\ndeclare global {\n interface Window {\n __ASSISTANT_UI_DEVTOOLS_HOOK__?: DevToolsHook;\n }\n}\n\nlet cachedHook: DevToolsHook | undefined;\n\nconst getHook = (): DevToolsHook => {\n if (cachedHook) {\n return cachedHook;\n }\n\n const createHook = (): DevToolsHook => ({\n apis: new Map(),\n nextId: 0,\n listeners: new Set(),\n });\n\n if (typeof window === \"undefined\") {\n cachedHook = createHook();\n return cachedHook;\n }\n\n const existingHook = window.__ASSISTANT_UI_DEVTOOLS_HOOK__;\n if (existingHook) {\n cachedHook = existingHook;\n return existingHook;\n }\n\n const newHook = createHook();\n window.__ASSISTANT_UI_DEVTOOLS_HOOK__ = newHook;\n cachedHook = newHook;\n return newHook;\n};\n\nexport class DevToolsHooks {\n static subscribe(listener: () => void): Unsubscribe {\n const hook = getHook();\n hook.listeners.add(listener);\n return () => {\n hook.listeners.delete(listener);\n };\n }\n\n static clearEventLogs(apiId: number): void {\n const hook = getHook();\n const entry = hook.apis.get(apiId);\n if (!entry) return;\n\n entry.logs = [];\n DevToolsHooks.notifyListeners(apiId);\n }\n\n static getApis(): Map<number, DevToolsApiEntry> {\n return getHook().apis;\n }\n\n private static notifyListeners(apiId: number): void {\n const hook = getHook();\n hook.listeners.forEach((listener) => listener(apiId));\n }\n}\n\nexport class DevToolsProviderApi {\n private static readonly MAX_EVENT_LOGS_PER_API = 200;\n\n static register(aui: Partial<AssistantClient>): Unsubscribe {\n const hook = getHook();\n\n for (const entry of hook.apis.values()) {\n if (entry.api === aui) {\n return () => {};\n }\n }\n\n const apiId = hook.nextId++;\n const entry: DevToolsApiEntry = {\n api: aui,\n logs: [],\n };\n\n const eventUnsubscribe = aui.on?.(\"*\", (e) => {\n const entry = hook.apis.get(apiId);\n if (!entry) return;\n\n entry.logs.push({\n time: new Date(),\n event: e.event,\n data: e.payload,\n });\n\n if (entry.logs.length > DevToolsProviderApi.MAX_EVENT_LOGS_PER_API) {\n entry.logs = entry.logs.slice(\n -DevToolsProviderApi.MAX_EVENT_LOGS_PER_API,\n );\n }\n\n DevToolsProviderApi.notifyListeners(apiId);\n });\n\n const stateUnsubscribe = aui.subscribe?.(() => {\n DevToolsProviderApi.notifyListeners(apiId);\n });\n\n hook.apis.set(apiId, entry);\n DevToolsProviderApi.notifyListeners(apiId);\n\n return () => {\n const hook = getHook();\n const entry = hook.apis.get(apiId);\n if (!entry) return;\n\n eventUnsubscribe?.();\n stateUnsubscribe?.();\n\n hook.apis.delete(apiId);\n\n DevToolsProviderApi.notifyListeners(apiId);\n };\n }\n\n private static notifyListeners(apiId: number): void {\n const hook = getHook();\n hook.listeners.forEach((listener) => listener(apiId));\n }\n}\n"],"mappings":";AA0BA,IAAI;AAEJ,MAAM,gBAA8B;CAClC,IAAI,YACF,OAAO;CAGT,MAAM,oBAAkC;EACtC,sBAAM,IAAI,IAAI;EACd,QAAQ;EACR,2BAAW,IAAI,IAAI;CACrB;CAEA,IAAI,OAAO,WAAW,aAAa;EACjC,aAAa,WAAW;EACxB,OAAO;CACT;CAEA,MAAM,eAAe,OAAO;CAC5B,IAAI,cAAc;EAChB,aAAa;EACb,OAAO;CACT;CAEA,MAAM,UAAU,WAAW;CAC3B,OAAO,iCAAiC;CACxC,aAAa;CACb,OAAO;AACT;AAEA,IAAa,gBAAb,MAAa,cAAc;CACzB,OAAO,UAAU,UAAmC;EAClD,MAAM,OAAO,QAAQ;EACrB,KAAK,UAAU,IAAI,QAAQ;EAC3B,aAAa;GACX,KAAK,UAAU,OAAO,QAAQ;EAChC;CACF;CAEA,OAAO,eAAe,OAAqB;EAEzC,MAAM,QADO,QACI,CAAC,CAAC,KAAK,IAAI,KAAK;EACjC,IAAI,CAAC,OAAO;EAEZ,MAAM,OAAO,CAAC;EACd,cAAc,gBAAgB,KAAK;CACrC;CAEA,OAAO,UAAyC;EAC9C,OAAO,QAAQ,CAAC,CAAC;CACnB;CAEA,OAAe,gBAAgB,OAAqB;EAElD,QAAG,CAAC,CAAC,UAAU,SAAS,aAAa,SAAS,KAAK,CAAC;CACtD;AACF;AAEA,IAAa,sBAAb,MAAa,oBAAoB;CAC/B,OAAwB,yBAAyB;CAEjD,OAAO,SAAS,KAA4C;EAC1D,MAAM,OAAO,QAAQ;EAErB,KAAK,MAAM,SAAS,KAAK,KAAK,OAAO,GACnC,IAAI,MAAM,QAAQ,KAChB,aAAa,CAAC;EAIlB,MAAM,QAAQ,KAAK;EACnB,MAAM,QAA0B;GAC9B,KAAK;GACL,MAAM,CAAC;EACT;EAEA,MAAM,mBAAmB,IAAI,KAAK,MAAM,MAAM;GAC5C,MAAM,QAAQ,KAAK,KAAK,IAAI,KAAK;GACjC,IAAI,CAAC,OAAO;GAEZ,MAAM,KAAK,KAAK;IACd,sBAAM,IAAI,KAAK;IACf,OAAO,EAAE;IACT,MAAM,EAAE;GACV,CAAC;GAED,IAAI,MAAM,KAAK,SAAS,oBAAoB,wBAC1C,MAAM,OAAO,MAAM,KAAK,MACtB,CAAC,oBAAoB,sBACvB;GAGF,oBAAoB,gBAAgB,KAAK;EAC3C,CAAC;EAED,MAAM,mBAAmB,IAAI,kBAAkB;GAC7C,oBAAoB,gBAAgB,KAAK;EAC3C,CAAC;EAED,KAAK,KAAK,IAAI,OAAO,KAAK;EAC1B,oBAAoB,gBAAgB,KAAK;EAEzC,aAAa;GACX,MAAM,OAAO,QAAQ;GAErB,IAAI,CADU,KAAK,KAAK,IAAI,KACnB,GAAG;GAEZ,mBAAmB;GACnB,mBAAmB;GAEnB,KAAK,KAAK,OAAO,KAAK;GAEtB,oBAAoB,gBAAgB,KAAK;EAC3C;CACF;CAEA,OAAe,gBAAgB,OAAqB;EAElD,QAAG,CAAC,CAAC,UAAU,SAAS,aAAa,SAAS,KAAK,CAAC;CACtD;AACF"}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /// <reference types="@assistant-ui/core/react" />
2
2
  import { Assistant } from "./augmentations.js";
3
- import { ExternalThread, ExternalThreadMessage, ExternalThreadProps, ExternalThreadQueueAdapter } from "./client/ExternalThread.js";
3
+ import { ExternalThread, ExternalThreadMessage, ExternalThreadProps } from "./client/ExternalThread.js";
4
4
  import { InMemoryThreadList, InMemoryThreadListProps } from "./client/InMemoryThreadList.js";
5
5
  import { SingleThreadList } from "./client/SingleThreadList.js";
6
6
  import { AssistantRuntimeProvider } from "./legacy-runtime/AssistantRuntimeProvider.js";
@@ -74,9 +74,9 @@ import { McpAppRenderer, McpAppRendererOptions } from "./mcp-apps/McpAppRenderer
74
74
  import { McpAppsRemoteHost } from "./mcp-apps/McpAppsRemoteHost.js";
75
75
  import { getMcpAppFromToolPart } from "./mcp-apps/utils.js";
76
76
  import { AssistantClient, AssistantEventCallback, AssistantEventName, AssistantEventPayload, AssistantEventScope, AssistantEventSelector, AssistantState, AuiIf, AuiProvider, useAui, useAuiEvent, useAuiState } from "@assistant-ui/store";
77
- import { AssistantContextConfig, AssistantDataUI, AssistantDataUIProps, AssistantInteractableProps, AssistantTool, AssistantToolProps, AssistantToolUI, AssistantToolUIProps, DataMessagePartComponent, DataMessagePartProps, DataRenderers, EmptyMessagePartComponent, EmptyMessagePartProps, EnrichedPartState, FileMessagePartComponent, FileMessagePartProps, GenerativeUIComponentRegistry, GenerativeUIMessagePartComponent, GenerativeUIMessagePartProps, GenerativeUIRender, GenerativeUIRenderError, GenerativeUIRenderProps, GroupByContext, ImageMessagePartComponent, ImageMessagePartProps, Interactables, McpAppResourceOutput, McpToolkitDefinition, PartState, ProviderToolConfig, QuoteMessagePartComponent, QuoteMessagePartProps, ReasoningGroupComponent, ReasoningGroupProps, ReasoningMessagePartComponent, ReasoningMessagePartProps, RuntimeAdapterProvider, RuntimeAdapters, SourceMessagePartComponent, SourceMessagePartProps, TextMessagePartComponent, TextMessagePartProps, ToolArgsStatus, ToolCallMessagePartComponent, ToolCallMessagePartProps, ToolCallText, ToolDefinition, Toolkit, ToolkitDefinition, ToolkitDefinitionEntry, Tools, Unstable_AudioMessagePartComponent, Unstable_AudioMessagePartProps, defineMcpToolkit, defineToolkit, groupPartByType, hitl, hitlTool, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, providerTool, stubTool, useAssistantContext, useAssistantDataUI, useAssistantInstructions, useAssistantInteractable, useAssistantTool, useAssistantToolUI, useAuiToolOverrides, useExternalStoreSharedOptions, useInlineRender, useInteractableState, useRuntimeAdapters, useToolArgsStatus, useVoiceControls, useVoiceState, useVoiceVolume } from "@assistant-ui/core/react";
77
+ import { AssistantContextConfig, AssistantDataUI, AssistantDataUIProps, AssistantInteractableProps, AssistantTool, AssistantToolProps, AssistantToolUI, AssistantToolUIProps, DataMessagePartComponent, DataMessagePartProps, DataRenderers, EmptyMessagePartComponent, EmptyMessagePartProps, EnrichedPartState, FileMessagePartComponent, FileMessagePartProps, GenerativeUIComponentRegistry, GenerativeUIMessagePartComponent, GenerativeUIMessagePartProps, GenerativeUIRender, GenerativeUIRenderError, GenerativeUIRenderProps, GroupByContext, ImageMessagePartComponent, ImageMessagePartProps, Interactables, McpAppResourceOutput, McpToolkitDefinition, PartState, ProviderToolConfig, QuoteMessagePartComponent, QuoteMessagePartProps, ReasoningGroupComponent, ReasoningGroupProps, ReasoningMessagePartComponent, ReasoningMessagePartProps, RuntimeAdapterProvider, RuntimeAdapters, SourceMessagePartComponent, SourceMessagePartProps, TextMessagePartComponent, TextMessagePartProps, ToolArgsStatus, ToolCallMessagePartComponent, ToolCallMessagePartProps, ToolCallText, ToolDefinition, Toolkit, ToolkitDefinition, ToolkitDefinitionEntry, Tools, Unstable_AudioMessagePartComponent, Unstable_AudioMessagePartProps, defineMcpToolkit, defineToolkit, externalTool, groupPartByType, hitl, hitlTool, humanTool, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, providerTool, stubTool, useAssistantContext, useAssistantDataUI, useAssistantInstructions, useAssistantInteractable, useAssistantTool, useAssistantToolUI, useAuiToolOverrides, useExternalStoreSharedOptions, useInlineRender, useInteractableState, useRuntimeAdapters, useToolArgsStatus, useVoiceControls, useVoiceState, useVoiceVolume } from "@assistant-ui/core/react";
78
78
  import { AssistantCloud } from "assistant-cloud";
79
- import { AddToolResultOptions, AppendMessage, AssistantFrameHost, AssistantFrameProvider, AssistantRuntime, Attachment, AttachmentAdapter, AttachmentRuntime, AttachmentState, AttachmentStatus, ChatModelAdapter, ChatModelRunOptions, ChatModelRunResult, ChatModelRunUpdate, CompleteAttachment, ComposerRuntime, ComposerState, CompositeAttachmentAdapter, CreateAppendMessage, CreateAttachment, CreateResumeRunConfig, CreateStartRunConfig, DataMessagePart, DictationAdapter, DictationState, EditComposerRuntime, EditComposerState, ExportedMessageRepository, ExportedMessageRepositoryItem, ExternalStoreAdapter, ExternalStoreMessageConverter, ExternalStoreSharedOptions, ExternalStoreThreadData, ExternalStoreThreadListAdapter, FRAME_MESSAGE_CHANNEL, FeedbackAdapter, FileMessagePart, FrameMessage, FrameMessageType, GenerativeUIMessagePart, GenerativeUINode, GenerativeUISpec, GenericThreadHistoryAdapter, ImageMessagePart, InMemoryThreadListAdapter, LanguageModelConfig, LanguageModelV1CallSettings, LocalRuntimeOptionsBase, MessageFormatAdapter, MessageFormatItem, MessageFormatRepository, MessagePartRuntime, MessagePartState, MessagePartStatus, MessageRuntime, MessageState, MessageStatus, MessageStorageEntry, MessageTiming, ModelContext, ModelContextProvider, ModelContextRegistry, ModelContextRegistryInstructionHandle, ModelContextRegistryProviderHandle, ModelContextRegistryToolHandle, PendingAttachment, QuoteInfo, RealtimeVoiceAdapter, ReasoningMessagePart, RemoteThreadListAdapter, SerializedModelContext, SerializedTool, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, SourceMessagePart, SourceProviderMetadata, SpeechSynthesisAdapter, SubmitFeedbackOptions, SuggestionAdapter, TextMessagePart, ThreadAssistantMessage, ThreadAssistantMessagePart, ThreadComposerRuntime, ThreadComposerState, ThreadHistoryAdapter, ThreadListItemRuntime, ThreadListItemState, ThreadListItemStatus, ThreadListRuntime, ThreadListState, ThreadMessage, ThreadMessageLike, ThreadRuntime, ThreadState, ThreadSuggestion, ThreadSystemMessage, ThreadUserMessage, ThreadUserMessagePart, ToolCallMessagePart, ToolCallMessagePartStatus, ToolModelContentPart, Unstable_AudioMessagePart, Unstable_DirectiveFormatter, Unstable_DirectiveSegment, Unstable_TriggerItem, Unsubscribe, VoiceSessionControls, VoiceSessionHelpers, VoiceSessionState, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, bindExternalStoreMessage, createVoiceSession, getExternalStoreMessages, mergeModelContexts, pickExternalStoreSharedOptions, tool, unstable_defaultDirectiveFormatter } from "@assistant-ui/core";
79
+ import { AddToolResultOptions, AppendMessage, AssistantFrameHost, AssistantFrameProvider, AssistantRuntime, Attachment, AttachmentAdapter, AttachmentRuntime, AttachmentState, AttachmentStatus, ChatModelAdapter, ChatModelRunOptions, ChatModelRunResult, ChatModelRunUpdate, CompleteAttachment, ComposerRuntime, ComposerState, CompositeAttachmentAdapter, CreateAppendMessage, CreateAttachment, CreateResumeRunConfig, CreateStartRunConfig, DataMessagePart, DictationAdapter, DictationState, EditComposerRuntime, EditComposerState, ExportedMessageRepository, ExportedMessageRepositoryItem, ExternalStoreAdapter, ExternalStoreMessageConverter, ExternalStoreSharedOptions, ExternalStoreThreadData, ExternalStoreThreadListAdapter, ExternalThreadQueueAdapter, FRAME_MESSAGE_CHANNEL, FeedbackAdapter, FileMessagePart, FrameMessage, FrameMessageType, GenerativeUIMessagePart, GenerativeUINode, GenerativeUISpec, GenericThreadHistoryAdapter, ImageMessagePart, InMemoryThreadListAdapter, LanguageModelConfig, LanguageModelV1CallSettings, LocalRuntimeOptionsBase, MessageFormatAdapter, MessageFormatItem, MessageFormatRepository, MessagePartRuntime, MessagePartState, MessagePartStatus, MessageQueueController, MessageQueueDriver, MessageRuntime, MessageState, MessageStatus, MessageStorageEntry, MessageTiming, ModelContext, ModelContextProvider, ModelContextRegistry, ModelContextRegistryInstructionHandle, ModelContextRegistryProviderHandle, ModelContextRegistryToolHandle, PendingAttachment, QuoteInfo, RealtimeVoiceAdapter, ReasoningMessagePart, RemoteThreadListAdapter, SerializedModelContext, SerializedTool, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, SourceMessagePart, SourceProviderMetadata, SpeechSynthesisAdapter, SubmitFeedbackOptions, SuggestionAdapter, TextMessagePart, ThreadAssistantMessage, ThreadAssistantMessagePart, ThreadComposerRuntime, ThreadComposerState, ThreadHistoryAdapter, ThreadListItemRuntime, ThreadListItemState, ThreadListItemStatus, ThreadListRuntime, ThreadListState, ThreadMessage, ThreadMessageLike, ThreadRuntime, ThreadState, ThreadSuggestion, ThreadSystemMessage, ThreadUserMessage, ThreadUserMessagePart, ToolCallMessagePart, ToolCallMessagePartStatus, ToolModelContentPart, Unstable_AudioMessagePart, Unstable_DirectiveFormatter, Unstable_DirectiveSegment, Unstable_TriggerItem, Unsubscribe, VoiceSessionControls, VoiceSessionHelpers, VoiceSessionState, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, bindExternalStoreMessage, createMessageQueue, createVoiceSession, getExternalStoreMessages, mergeModelContexts, pickExternalStoreSharedOptions, tool, unstable_defaultDirectiveFormatter } from "@assistant-ui/core";
80
80
  import { Tool } from "assistant-stream";
81
81
  import { ChainOfThoughtClient, ComposerSendOptions, ModelContext as ModelContextClient, QueueItemMethods, QueueItemState, SuggestionConfig, Suggestions } from "@assistant-ui/core/store";
82
- export { actionBarMore_d_exports as ActionBarMorePrimitive, actionBar_d_exports as ActionBarPrimitive, type AddToolResultOptions, type AppendMessage, type Assistant, type AssistantClient, AssistantCloud, type AssistantContextConfig, type AssistantDataUI, type AssistantDataUIProps, type AssistantEventCallback, type AssistantEventName, type AssistantEventPayload, type AssistantEventScope, type AssistantEventSelector, AssistantFrameHost, AssistantFrameProvider, type AssistantInteractableProps, assistantModal_d_exports as AssistantModalPrimitive, type AssistantRuntime, AssistantRuntimeProvider, type AssistantState, type AssistantTool, type AssistantToolProps, type AssistantToolUI, type AssistantToolUIProps, type AssistantTransportCommand, type AssistantTransportConnectionMetadata, type AssistantTransportProtocol, type Attachment, type AttachmentAdapter, attachment_d_exports as AttachmentPrimitive, type AttachmentRuntime, type AttachmentState, type AttachmentStatus, AuiIf, AuiProvider, branchPicker_d_exports as BranchPickerPrimitive, ChainOfThoughtByIndicesProvider, ChainOfThoughtClient, chainOfThought_d_exports as ChainOfThoughtPrimitive, type ChatModelAdapter, type ChatModelRunOptions, type ChatModelRunResult, type ChatModelRunUpdate, CloudFileAttachmentAdapter, type CompleteAttachment, ComposerAttachmentByIndexProvider, composer_d_exports as ComposerPrimitive, type ComposerRuntime, type ComposerSendOptions, type ComposerState, CompositeAttachmentAdapter, type CreateAppendMessage, type CreateAttachment, type CreateResumeRunConfig, type CreateStartRunConfig, type DataMessagePart, type DataMessagePartComponent, type DataMessagePartProps, DataRenderers, DevToolsHooks, DevToolsProviderApi, type DictationAdapter, type DictationState, type EditComposerRuntime, type EditComposerState, type EmptyMessagePartComponent, type EmptyMessagePartProps, type EnrichedPartState, error_d_exports as ErrorPrimitive, ExportedMessageRepository, type ExportedMessageRepositoryItem, type ExternalStoreAdapter, type ExternalStoreMessageConverter, type ExternalStoreSharedOptions, type ExternalStoreThreadData, type ExternalStoreThreadListAdapter, ExternalThread, type ExternalThreadMessage, type ExternalThreadProps, type ExternalThreadQueueAdapter, FRAME_MESSAGE_CHANNEL, type FeedbackAdapter, type FileMessagePart, type FileMessagePartComponent, type FileMessagePartProps, type FrameMessage, type FrameMessageType, type GenerativeUIComponentRegistry, type GenerativeUIMessagePart, type GenerativeUIMessagePartComponent, type GenerativeUIMessagePartProps, type GenerativeUINode, GenerativeUIRender, GenerativeUIRenderError, type GenerativeUIRenderProps, type GenerativeUISpec, type GenericThreadHistoryAdapter, type GroupByContext, internal_d_exports as INTERNAL, type ImageMessagePart, type ImageMessagePartComponent, type ImageMessagePartProps, InMemoryThreadList, InMemoryThreadListAdapter, type InMemoryThreadListProps, Interactables, type LanguageModelConfig, type LanguageModelV1CallSettings, type LocalRuntimeOptions, type LocalRuntimeOptionsBase, type McpAppDisplayMode, type McpAppHostContext, type McpAppHostInfo, type McpAppMetadata, McpAppRenderer, type McpAppRendererOptions, type McpAppResource, type McpAppResourceCSP, type McpAppResourceMeta, type McpAppResourceOutput, type McpAppSandboxConfig, type McpAppToolCallParams, type McpAppsHost, McpAppsRemoteHost, type McpAppsRemoteHostOptions, type McpToolkitDefinition, MessageAttachmentByIndexProvider, MessageByIndexProvider, type MessageFormatAdapter, type MessageFormatItem, type MessageFormatRepository, messagePart_d_exports as MessagePartPrimitive, type MessagePartRuntime, type MessagePartState, type MessagePartStatus, message_d_exports as MessagePrimitive, MessageProvider, type MessageRuntime, type MessageState, type MessageStatus, type MessageStorageEntry, type MessageTiming, type ModelContext, ModelContextClient, type ModelContextProvider, ModelContextRegistry, type ModelContextRegistryInstructionHandle, type ModelContextRegistryProviderHandle, type ModelContextRegistryToolHandle, PartByIndexProvider, type PartState, type PendingAttachment, type ProviderToolConfig, type QueueItemMethods, queueItem_d_exports as QueueItemPrimitive, type QueueItemState, type QuoteInfo, type QuoteMessagePartComponent, type QuoteMessagePartProps, ReadonlyThreadProvider, type RealtimeVoiceAdapter, type ReasoningGroupComponent, type ReasoningGroupProps, type ReasoningMessagePart, type ReasoningMessagePartComponent, type ReasoningMessagePartProps, type RemoteThreadListAdapter, RuntimeAdapterProvider, type RuntimeAdapters, selectionToolbar_d_exports as SelectionToolbarPrimitive, type SendCommandsRequestBody, type SerializedModelContext, type SerializedTool, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, SingleThreadList, type SourceMessagePart, type SourceMessagePartComponent, type SourceMessagePartProps, type SourceProviderMetadata, type SpeechSynthesisAdapter, type SubmitFeedbackOptions, type SuggestionAdapter, SuggestionByIndexProvider, type SuggestionConfig, suggestion_d_exports as SuggestionPrimitive, Suggestions, type TextMessagePart, type TextMessagePartComponent, type TextMessagePartProps, TextMessagePartProvider, type ThreadAssistantMessage, type ThreadAssistantMessagePart, type ThreadComposerRuntime, type ThreadComposerState, type ThreadHistoryAdapter, ThreadListItemByIndexProvider, threadListItemMore_d_exports as ThreadListItemMorePrimitive, threadListItem_d_exports as ThreadListItemPrimitive, type ThreadListItemRuntime, ThreadListItemRuntimeProvider, type ThreadListItemState, type ThreadListItemStatus, threadList_d_exports as ThreadListPrimitive, type ThreadListRuntime, type ThreadListState, type ThreadMessage, type ThreadMessageLike, thread_d_exports as ThreadPrimitive, type ThreadRuntime, type ThreadState, type ThreadSuggestion, type ThreadSystemMessage, type ThreadUserMessage, type ThreadUserMessagePart, type ThreadViewportState, type Tool, type ToolArgsStatus, type ToolCallMessagePart, type ToolCallMessagePartComponent, type ToolCallMessagePartMcpMetadata, type ToolCallMessagePartProps, type ToolCallMessagePartStatus, type ToolCallText, type ToolDefinition, type ToolExecutionStatus, type ToolModelContentPart, type Toolkit, type ToolkitDefinition, type ToolkitDefinitionEntry, Tools, type Unstable_AudioMessagePart, type Unstable_AudioMessagePartComponent, type Unstable_AudioMessagePartProps, type Unstable_DirectiveFormatter, type Unstable_DirectiveSegment, type Unstable_IconComponent, type Unstable_Mention, type Unstable_MentionCategory, type Unstable_MentionDirective, type Unstable_ModelContextToolsOptions, type RegisteredTrigger as Unstable_RegisteredTrigger, type Unstable_SlashCommand, type Unstable_SlashCommandAction, type TriggerBehavior as Unstable_TriggerBehavior, type Unstable_TriggerItem, type Unstable_UseMentionAdapterOptions, type Unstable_UseSlashCommandAdapterOptions, type Unsubscribe, type VoiceSessionControls, type VoiceSessionHelpers, type VoiceSessionState, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, bindExternalStoreMessage, createVoiceSession, defineMcpToolkit, defineToolkit, getExternalStoreMessages, getMcpAppFromToolPart, groupPartByType, hitl, hitlTool, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, makeAssistantVisible, mergeModelContexts, pickExternalStoreSharedOptions, providerTool, stubTool, tool, convertExternalMessages as unstable_convertExternalMessages, createMessageConverter as unstable_createMessageConverter, unstable_defaultDirectiveFormatter, unstable_useMentionAdapter, unstable_useSlashCommandAdapter, useTriggerPopoverRootContext as unstable_useTriggerPopoverRootContext, useTriggerPopoverRootContextOptional as unstable_useTriggerPopoverRootContextOptional, useTriggerPopoverScopeContext as unstable_useTriggerPopoverScopeContext, useTriggerPopoverScopeContextOptional as unstable_useTriggerPopoverScopeContextOptional, useTriggerPopoverTriggers as unstable_useTriggerPopoverTriggers, useTriggerPopoverTriggersOptional as unstable_useTriggerPopoverTriggersOptional, useAssistantContext, useAssistantDataUI, useAssistantFrameHost, useAssistantInstructions, useAssistantInteractable, useAssistantRuntime, useAssistantTool, useAssistantToolUI, useAssistantTransportRuntime, useAssistantTransportSendCommand, useAssistantTransportState, useAttachment, useAttachmentRuntime, useAui, useAuiEvent, useAuiState, useAuiToolOverrides, useCloudThreadListAdapter, useCloudThreadListRuntime, useComposer, useComposerRuntime, useEditComposer, useEditComposerAttachment, useEditComposerAttachmentRuntime, useExternalMessageConverter, useExternalStoreRuntime, useExternalStoreSharedOptions, useInlineRender, useInteractableState, useLocalRuntime, useMessage, useMessageAttachment, useMessageAttachmentRuntime, useMessagePart, useMessagePartData, useMessagePartFile, useMessagePartImage, useMessagePartReasoning, useMessagePartRuntime, useMessagePartSource, useMessagePartText, useMessageQuote, useMessageRuntime, useMessageTiming, useRemoteThreadListRuntime, useRuntimeAdapters, useScrollLock, useThread, useThreadComposer, useThreadComposerAttachment, useThreadComposerAttachmentRuntime, useThreadList, useThreadListItem, useThreadListItemRuntime, useThreadModelContext, useThreadRuntime, useThreadViewport, useThreadViewportAutoScroll, useThreadViewportStore, useToolArgsStatus, useVoiceControls, useVoiceState, useVoiceVolume };
82
+ export { actionBarMore_d_exports as ActionBarMorePrimitive, actionBar_d_exports as ActionBarPrimitive, type AddToolResultOptions, type AppendMessage, type Assistant, type AssistantClient, AssistantCloud, type AssistantContextConfig, type AssistantDataUI, type AssistantDataUIProps, type AssistantEventCallback, type AssistantEventName, type AssistantEventPayload, type AssistantEventScope, type AssistantEventSelector, AssistantFrameHost, AssistantFrameProvider, type AssistantInteractableProps, assistantModal_d_exports as AssistantModalPrimitive, type AssistantRuntime, AssistantRuntimeProvider, type AssistantState, type AssistantTool, type AssistantToolProps, type AssistantToolUI, type AssistantToolUIProps, type AssistantTransportCommand, type AssistantTransportConnectionMetadata, type AssistantTransportProtocol, type Attachment, type AttachmentAdapter, attachment_d_exports as AttachmentPrimitive, type AttachmentRuntime, type AttachmentState, type AttachmentStatus, AuiIf, AuiProvider, branchPicker_d_exports as BranchPickerPrimitive, ChainOfThoughtByIndicesProvider, ChainOfThoughtClient, chainOfThought_d_exports as ChainOfThoughtPrimitive, type ChatModelAdapter, type ChatModelRunOptions, type ChatModelRunResult, type ChatModelRunUpdate, CloudFileAttachmentAdapter, type CompleteAttachment, ComposerAttachmentByIndexProvider, composer_d_exports as ComposerPrimitive, type ComposerRuntime, type ComposerSendOptions, type ComposerState, CompositeAttachmentAdapter, type CreateAppendMessage, type CreateAttachment, type CreateResumeRunConfig, type CreateStartRunConfig, type DataMessagePart, type DataMessagePartComponent, type DataMessagePartProps, DataRenderers, DevToolsHooks, DevToolsProviderApi, type DictationAdapter, type DictationState, type EditComposerRuntime, type EditComposerState, type EmptyMessagePartComponent, type EmptyMessagePartProps, type EnrichedPartState, error_d_exports as ErrorPrimitive, ExportedMessageRepository, type ExportedMessageRepositoryItem, type ExternalStoreAdapter, type ExternalStoreMessageConverter, type ExternalStoreSharedOptions, type ExternalStoreThreadData, type ExternalStoreThreadListAdapter, ExternalThread, type ExternalThreadMessage, type ExternalThreadProps, type ExternalThreadQueueAdapter, FRAME_MESSAGE_CHANNEL, type FeedbackAdapter, type FileMessagePart, type FileMessagePartComponent, type FileMessagePartProps, type FrameMessage, type FrameMessageType, type GenerativeUIComponentRegistry, type GenerativeUIMessagePart, type GenerativeUIMessagePartComponent, type GenerativeUIMessagePartProps, type GenerativeUINode, GenerativeUIRender, GenerativeUIRenderError, type GenerativeUIRenderProps, type GenerativeUISpec, type GenericThreadHistoryAdapter, type GroupByContext, internal_d_exports as INTERNAL, type ImageMessagePart, type ImageMessagePartComponent, type ImageMessagePartProps, InMemoryThreadList, InMemoryThreadListAdapter, type InMemoryThreadListProps, Interactables, type LanguageModelConfig, type LanguageModelV1CallSettings, type LocalRuntimeOptions, type LocalRuntimeOptionsBase, type McpAppDisplayMode, type McpAppHostContext, type McpAppHostInfo, type McpAppMetadata, McpAppRenderer, type McpAppRendererOptions, type McpAppResource, type McpAppResourceCSP, type McpAppResourceMeta, type McpAppResourceOutput, type McpAppSandboxConfig, type McpAppToolCallParams, type McpAppsHost, McpAppsRemoteHost, type McpAppsRemoteHostOptions, type McpToolkitDefinition, MessageAttachmentByIndexProvider, MessageByIndexProvider, type MessageFormatAdapter, type MessageFormatItem, type MessageFormatRepository, messagePart_d_exports as MessagePartPrimitive, type MessagePartRuntime, type MessagePartState, type MessagePartStatus, message_d_exports as MessagePrimitive, MessageProvider, type MessageQueueController, type MessageQueueDriver, type MessageRuntime, type MessageState, type MessageStatus, type MessageStorageEntry, type MessageTiming, type ModelContext, ModelContextClient, type ModelContextProvider, ModelContextRegistry, type ModelContextRegistryInstructionHandle, type ModelContextRegistryProviderHandle, type ModelContextRegistryToolHandle, PartByIndexProvider, type PartState, type PendingAttachment, type ProviderToolConfig, type QueueItemMethods, queueItem_d_exports as QueueItemPrimitive, type QueueItemState, type QuoteInfo, type QuoteMessagePartComponent, type QuoteMessagePartProps, ReadonlyThreadProvider, type RealtimeVoiceAdapter, type ReasoningGroupComponent, type ReasoningGroupProps, type ReasoningMessagePart, type ReasoningMessagePartComponent, type ReasoningMessagePartProps, type RemoteThreadListAdapter, RuntimeAdapterProvider, type RuntimeAdapters, selectionToolbar_d_exports as SelectionToolbarPrimitive, type SendCommandsRequestBody, type SerializedModelContext, type SerializedTool, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, SingleThreadList, type SourceMessagePart, type SourceMessagePartComponent, type SourceMessagePartProps, type SourceProviderMetadata, type SpeechSynthesisAdapter, type SubmitFeedbackOptions, type SuggestionAdapter, SuggestionByIndexProvider, type SuggestionConfig, suggestion_d_exports as SuggestionPrimitive, Suggestions, type TextMessagePart, type TextMessagePartComponent, type TextMessagePartProps, TextMessagePartProvider, type ThreadAssistantMessage, type ThreadAssistantMessagePart, type ThreadComposerRuntime, type ThreadComposerState, type ThreadHistoryAdapter, ThreadListItemByIndexProvider, threadListItemMore_d_exports as ThreadListItemMorePrimitive, threadListItem_d_exports as ThreadListItemPrimitive, type ThreadListItemRuntime, ThreadListItemRuntimeProvider, type ThreadListItemState, type ThreadListItemStatus, threadList_d_exports as ThreadListPrimitive, type ThreadListRuntime, type ThreadListState, type ThreadMessage, type ThreadMessageLike, thread_d_exports as ThreadPrimitive, type ThreadRuntime, type ThreadState, type ThreadSuggestion, type ThreadSystemMessage, type ThreadUserMessage, type ThreadUserMessagePart, type ThreadViewportState, type Tool, type ToolArgsStatus, type ToolCallMessagePart, type ToolCallMessagePartComponent, type ToolCallMessagePartMcpMetadata, type ToolCallMessagePartProps, type ToolCallMessagePartStatus, type ToolCallText, type ToolDefinition, type ToolExecutionStatus, type ToolModelContentPart, type Toolkit, type ToolkitDefinition, type ToolkitDefinitionEntry, Tools, type Unstable_AudioMessagePart, type Unstable_AudioMessagePartComponent, type Unstable_AudioMessagePartProps, type Unstable_DirectiveFormatter, type Unstable_DirectiveSegment, type Unstable_IconComponent, type Unstable_Mention, type Unstable_MentionCategory, type Unstable_MentionDirective, type Unstable_ModelContextToolsOptions, type RegisteredTrigger as Unstable_RegisteredTrigger, type Unstable_SlashCommand, type Unstable_SlashCommandAction, type TriggerBehavior as Unstable_TriggerBehavior, type Unstable_TriggerItem, type Unstable_UseMentionAdapterOptions, type Unstable_UseSlashCommandAdapterOptions, type Unsubscribe, type VoiceSessionControls, type VoiceSessionHelpers, type VoiceSessionState, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, bindExternalStoreMessage, createMessageQueue, createVoiceSession, defineMcpToolkit, defineToolkit, externalTool, getExternalStoreMessages, getMcpAppFromToolPart, groupPartByType, hitl, hitlTool, humanTool, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, makeAssistantVisible, mergeModelContexts, pickExternalStoreSharedOptions, providerTool, stubTool, tool, convertExternalMessages as unstable_convertExternalMessages, createMessageConverter as unstable_createMessageConverter, unstable_defaultDirectiveFormatter, unstable_useMentionAdapter, unstable_useSlashCommandAdapter, useTriggerPopoverRootContext as unstable_useTriggerPopoverRootContext, useTriggerPopoverRootContextOptional as unstable_useTriggerPopoverRootContextOptional, useTriggerPopoverScopeContext as unstable_useTriggerPopoverScopeContext, useTriggerPopoverScopeContextOptional as unstable_useTriggerPopoverScopeContextOptional, useTriggerPopoverTriggers as unstable_useTriggerPopoverTriggers, useTriggerPopoverTriggersOptional as unstable_useTriggerPopoverTriggersOptional, useAssistantContext, useAssistantDataUI, useAssistantFrameHost, useAssistantInstructions, useAssistantInteractable, useAssistantRuntime, useAssistantTool, useAssistantToolUI, useAssistantTransportRuntime, useAssistantTransportSendCommand, useAssistantTransportState, useAttachment, useAttachmentRuntime, useAui, useAuiEvent, useAuiState, useAuiToolOverrides, useCloudThreadListAdapter, useCloudThreadListRuntime, useComposer, useComposerRuntime, useEditComposer, useEditComposerAttachment, useEditComposerAttachmentRuntime, useExternalMessageConverter, useExternalStoreRuntime, useExternalStoreSharedOptions, useInlineRender, useInteractableState, useLocalRuntime, useMessage, useMessageAttachment, useMessageAttachmentRuntime, useMessagePart, useMessagePartData, useMessagePartFile, useMessagePartImage, useMessagePartReasoning, useMessagePartRuntime, useMessagePartSource, useMessagePartText, useMessageQuote, useMessageRuntime, useMessageTiming, useRemoteThreadListRuntime, useRuntimeAdapters, useScrollLock, useThread, useThreadComposer, useThreadComposerAttachment, useThreadComposerAttachmentRuntime, useThreadList, useThreadListItem, useThreadListItemRuntime, useThreadModelContext, useThreadRuntime, useThreadViewport, useThreadViewportAutoScroll, useThreadViewportStore, useToolArgsStatus, useVoiceControls, useVoiceState, useVoiceVolume };
package/dist/index.js CHANGED
@@ -67,8 +67,8 @@ import { getMcpAppFromToolPart } from "./mcp-apps/utils.js";
67
67
  import { McpAppRenderer } from "./mcp-apps/McpAppRenderer.js";
68
68
  import { McpAppsRemoteHost } from "./mcp-apps/McpAppsRemoteHost.js";
69
69
  import { AuiIf, AuiProvider, useAui, useAuiEvent, useAuiState } from "@assistant-ui/store";
70
- import { DataRenderers, GenerativeUIRender, GenerativeUIRenderError, Interactables, RuntimeAdapterProvider, Tools, defineMcpToolkit, defineToolkit, groupPartByType, hitl, hitlTool, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, providerTool, stubTool, useAssistantContext, useAssistantDataUI, useAssistantInstructions, useAssistantInteractable, useAssistantTool, useAssistantToolUI, useAuiToolOverrides, useExternalStoreSharedOptions, useInlineRender, useInteractableState, useRuntimeAdapters, useToolArgsStatus, useVoiceControls, useVoiceState, useVoiceVolume } from "@assistant-ui/core/react";
70
+ import { DataRenderers, GenerativeUIRender, GenerativeUIRenderError, Interactables, RuntimeAdapterProvider, Tools, defineMcpToolkit, defineToolkit, externalTool, groupPartByType, hitl, hitlTool, humanTool, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, providerTool, stubTool, useAssistantContext, useAssistantDataUI, useAssistantInstructions, useAssistantInteractable, useAssistantTool, useAssistantToolUI, useAuiToolOverrides, useExternalStoreSharedOptions, useInlineRender, useInteractableState, useRuntimeAdapters, useToolArgsStatus, useVoiceControls, useVoiceState, useVoiceVolume } from "@assistant-ui/core/react";
71
71
  import { AssistantCloud } from "assistant-cloud";
72
- import { AssistantFrameHost, AssistantFrameProvider, CompositeAttachmentAdapter, ExportedMessageRepository, FRAME_MESSAGE_CHANNEL, InMemoryThreadListAdapter, ModelContextRegistry, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, bindExternalStoreMessage, createVoiceSession, getExternalStoreMessages, mergeModelContexts, pickExternalStoreSharedOptions, tool, unstable_defaultDirectiveFormatter } from "@assistant-ui/core";
72
+ import { AssistantFrameHost, AssistantFrameProvider, CompositeAttachmentAdapter, ExportedMessageRepository, FRAME_MESSAGE_CHANNEL, InMemoryThreadListAdapter, ModelContextRegistry, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, bindExternalStoreMessage, createMessageQueue, createVoiceSession, getExternalStoreMessages, mergeModelContexts, pickExternalStoreSharedOptions, tool, unstable_defaultDirectiveFormatter } from "@assistant-ui/core";
73
73
  import { ChainOfThoughtClient, ModelContext as ModelContextClient, Suggestions } from "@assistant-ui/core/store";
74
- export { actionBarMore_exports as ActionBarMorePrimitive, actionBar_exports as ActionBarPrimitive, AssistantCloud, AssistantFrameHost, AssistantFrameProvider, assistantModal_exports as AssistantModalPrimitive, AssistantRuntimeProvider, attachment_exports as AttachmentPrimitive, AuiIf, AuiProvider, branchPicker_exports as BranchPickerPrimitive, ChainOfThoughtByIndicesProvider, ChainOfThoughtClient, chainOfThought_exports as ChainOfThoughtPrimitive, CloudFileAttachmentAdapter, ComposerAttachmentByIndexProvider, composer_exports as ComposerPrimitive, CompositeAttachmentAdapter, DataRenderers, DevToolsHooks, DevToolsProviderApi, error_exports as ErrorPrimitive, ExportedMessageRepository, ExternalThread, FRAME_MESSAGE_CHANNEL, GenerativeUIRender, GenerativeUIRenderError, internal_exports as INTERNAL, InMemoryThreadList, InMemoryThreadListAdapter, Interactables, McpAppRenderer, McpAppsRemoteHost, MessageAttachmentByIndexProvider, MessageByIndexProvider, messagePart_exports as MessagePartPrimitive, message_exports as MessagePrimitive, MessageProvider, ModelContextClient, ModelContextRegistry, PartByIndexProvider, queueItem_exports as QueueItemPrimitive, ReadonlyThreadProvider, RuntimeAdapterProvider, selectionToolbar_exports as SelectionToolbarPrimitive, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, SingleThreadList, SuggestionByIndexProvider, suggestion_exports as SuggestionPrimitive, Suggestions, TextMessagePartProvider, ThreadListItemByIndexProvider, threadListItemMore_exports as ThreadListItemMorePrimitive, threadListItem_exports as ThreadListItemPrimitive, ThreadListItemRuntimeProvider, threadList_exports as ThreadListPrimitive, thread_exports as ThreadPrimitive, Tools, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, bindExternalStoreMessage, createVoiceSession, defineMcpToolkit, defineToolkit, getExternalStoreMessages, getMcpAppFromToolPart, groupPartByType, hitl, hitlTool, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, makeAssistantVisible, mergeModelContexts, pickExternalStoreSharedOptions, providerTool, stubTool, tool, convertExternalMessages as unstable_convertExternalMessages, createMessageConverter as unstable_createMessageConverter, unstable_defaultDirectiveFormatter, unstable_useMentionAdapter, unstable_useSlashCommandAdapter, useTriggerPopoverRootContext as unstable_useTriggerPopoverRootContext, useTriggerPopoverRootContextOptional as unstable_useTriggerPopoverRootContextOptional, useTriggerPopoverScopeContext as unstable_useTriggerPopoverScopeContext, useTriggerPopoverScopeContextOptional as unstable_useTriggerPopoverScopeContextOptional, useTriggerPopoverTriggers as unstable_useTriggerPopoverTriggers, useTriggerPopoverTriggersOptional as unstable_useTriggerPopoverTriggersOptional, useAssistantContext, useAssistantDataUI, useAssistantFrameHost, useAssistantInstructions, useAssistantInteractable, useAssistantRuntime, useAssistantTool, useAssistantToolUI, useAssistantTransportRuntime, useAssistantTransportSendCommand, useAssistantTransportState, useAttachment, useAttachmentRuntime, useAui, useAuiEvent, useAuiState, useAuiToolOverrides, useCloudThreadListAdapter, useCloudThreadListRuntime, useComposer, useComposerRuntime, useEditComposer, useEditComposerAttachment, useEditComposerAttachmentRuntime, useExternalMessageConverter, useExternalStoreRuntime, useExternalStoreSharedOptions, useInlineRender, useInteractableState, useLocalRuntime, useMessage, useMessageAttachment, useMessageAttachmentRuntime, useMessagePart, useMessagePartData, useMessagePartFile, useMessagePartImage, useMessagePartReasoning, useMessagePartRuntime, useMessagePartSource, useMessagePartText, useMessageQuote, useMessageRuntime, useMessageTiming, useRemoteThreadListRuntime, useRuntimeAdapters, useScrollLock, useThread, useThreadComposer, useThreadComposerAttachment, useThreadComposerAttachmentRuntime, useThreadList, useThreadListItem, useThreadListItemRuntime, useThreadModelContext, useThreadRuntime, useThreadViewport, useThreadViewportAutoScroll, useThreadViewportStore, useToolArgsStatus, useVoiceControls, useVoiceState, useVoiceVolume };
74
+ export { actionBarMore_exports as ActionBarMorePrimitive, actionBar_exports as ActionBarPrimitive, AssistantCloud, AssistantFrameHost, AssistantFrameProvider, assistantModal_exports as AssistantModalPrimitive, AssistantRuntimeProvider, attachment_exports as AttachmentPrimitive, AuiIf, AuiProvider, branchPicker_exports as BranchPickerPrimitive, ChainOfThoughtByIndicesProvider, ChainOfThoughtClient, chainOfThought_exports as ChainOfThoughtPrimitive, CloudFileAttachmentAdapter, ComposerAttachmentByIndexProvider, composer_exports as ComposerPrimitive, CompositeAttachmentAdapter, DataRenderers, DevToolsHooks, DevToolsProviderApi, error_exports as ErrorPrimitive, ExportedMessageRepository, ExternalThread, FRAME_MESSAGE_CHANNEL, GenerativeUIRender, GenerativeUIRenderError, internal_exports as INTERNAL, InMemoryThreadList, InMemoryThreadListAdapter, Interactables, McpAppRenderer, McpAppsRemoteHost, MessageAttachmentByIndexProvider, MessageByIndexProvider, messagePart_exports as MessagePartPrimitive, message_exports as MessagePrimitive, MessageProvider, ModelContextClient, ModelContextRegistry, PartByIndexProvider, queueItem_exports as QueueItemPrimitive, ReadonlyThreadProvider, RuntimeAdapterProvider, selectionToolbar_exports as SelectionToolbarPrimitive, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, SingleThreadList, SuggestionByIndexProvider, suggestion_exports as SuggestionPrimitive, Suggestions, TextMessagePartProvider, ThreadListItemByIndexProvider, threadListItemMore_exports as ThreadListItemMorePrimitive, threadListItem_exports as ThreadListItemPrimitive, ThreadListItemRuntimeProvider, threadList_exports as ThreadListPrimitive, thread_exports as ThreadPrimitive, Tools, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, bindExternalStoreMessage, createMessageQueue, createVoiceSession, defineMcpToolkit, defineToolkit, externalTool, getExternalStoreMessages, getMcpAppFromToolPart, groupPartByType, hitl, hitlTool, humanTool, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, makeAssistantVisible, mergeModelContexts, pickExternalStoreSharedOptions, providerTool, stubTool, tool, convertExternalMessages as unstable_convertExternalMessages, createMessageConverter as unstable_createMessageConverter, unstable_defaultDirectiveFormatter, unstable_useMentionAdapter, unstable_useSlashCommandAdapter, useTriggerPopoverRootContext as unstable_useTriggerPopoverRootContext, useTriggerPopoverRootContextOptional as unstable_useTriggerPopoverRootContextOptional, useTriggerPopoverScopeContext as unstable_useTriggerPopoverScopeContext, useTriggerPopoverScopeContextOptional as unstable_useTriggerPopoverScopeContextOptional, useTriggerPopoverTriggers as unstable_useTriggerPopoverTriggers, useTriggerPopoverTriggersOptional as unstable_useTriggerPopoverTriggersOptional, useAssistantContext, useAssistantDataUI, useAssistantFrameHost, useAssistantInstructions, useAssistantInteractable, useAssistantRuntime, useAssistantTool, useAssistantToolUI, useAssistantTransportRuntime, useAssistantTransportSendCommand, useAssistantTransportState, useAttachment, useAttachmentRuntime, useAui, useAuiEvent, useAuiState, useAuiToolOverrides, useCloudThreadListAdapter, useCloudThreadListRuntime, useComposer, useComposerRuntime, useEditComposer, useEditComposerAttachment, useEditComposerAttachmentRuntime, useExternalMessageConverter, useExternalStoreRuntime, useExternalStoreSharedOptions, useInlineRender, useInteractableState, useLocalRuntime, useMessage, useMessageAttachment, useMessageAttachmentRuntime, useMessagePart, useMessagePartData, useMessagePartFile, useMessagePartImage, useMessagePartReasoning, useMessagePartRuntime, useMessagePartSource, useMessagePartText, useMessageQuote, useMessageRuntime, useMessageTiming, useRemoteThreadListRuntime, useRuntimeAdapters, useScrollLock, useThread, useThreadComposer, useThreadComposerAttachment, useThreadComposerAttachmentRuntime, useThreadList, useThreadListItem, useThreadListItemRuntime, useThreadModelContext, useThreadRuntime, useThreadViewport, useThreadViewportAutoScroll, useThreadViewportStore, useToolArgsStatus, useVoiceControls, useVoiceState, useVoiceVolume };
@@ -3,7 +3,7 @@ import { ThreadPrimitiveViewportProvider } from "../context/providers/ThreadView
3
3
  import { DevToolsProviderApi } from "../devtools/DevToolsHooks.js";
4
4
  import { useAui } from "@assistant-ui/store";
5
5
  import { AssistantProviderBase } from "@assistant-ui/core/react";
6
- import { memo, useEffect } from "react";
6
+ import { memo, useEffect } from "@assistant-ui/tap/react-shim";
7
7
  import { jsx, jsxs } from "react/jsx-runtime";
8
8
  //#region src/legacy-runtime/AssistantRuntimeProvider.tsx
9
9
  const DevToolsRegistration = () => {
@@ -1,5 +1,5 @@
1
- import { fromThreadMessageLike } from "../runtime-cores/external-store/ThreadMessageLike.js";
2
1
  import { isJSONValue } from "../../utils/json/is-json.js";
2
+ import { fromThreadMessageLike } from "../runtime-cores/external-store/ThreadMessageLike.js";
3
3
  //#region src/legacy-runtime/cloud/auiV0.ts
4
4
  function auiV0Encode(message) {
5
5
  const status = message.status?.type === "running" ? {
@@ -1 +1 @@
1
- {"version":3,"file":"AssistantContext.js","names":[],"sources":["../../../src/legacy-runtime/hooks/AssistantContext.ts"],"sourcesContent":["\"use client\";\n\nimport { useAui } from \"@assistant-ui/store\";\nimport type { AssistantRuntime } from \"../runtime/AssistantRuntime\";\nimport type { ThreadListRuntime } from \"../runtime/ThreadListRuntime\";\nimport { createStateHookForRuntime } from \"../../context/react/utils/createStateHookForRuntime\";\n\n/**\n * @deprecated Use {@link useAui} instead. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n *\n * Hook to access the AssistantRuntime from the current context.\n *\n * The AssistantRuntime provides access to the top-level assistant state and actions,\n * including thread management, tool registration, and configuration.\n *\n * @param options Configuration options\n * @param options.optional Whether the hook should return null if no context is found\n * @returns The AssistantRuntime instance, or null if optional is true and no context exists\n *\n * @example\n * ```tsx\n * // Before:\n * function MyComponent() {\n * const runtime = useAssistantRuntime();\n * const handleNewThread = () => {\n * runtime.switchToNewThread();\n * };\n * return <button onClick={handleNewThread}>New Thread</button>;\n * }\n *\n * // After:\n * function MyComponent() {\n * const aui = useAui();\n * const handleNewThread = () => {\n * aui.threads().switchToNewThread();\n * };\n * return <button onClick={handleNewThread}>New Thread</button>;\n * }\n * ```\n */\nexport function useAssistantRuntime(options?: {\n optional?: false | undefined;\n}): AssistantRuntime;\nexport function useAssistantRuntime(options?: {\n optional?: boolean | undefined;\n}): AssistantRuntime | null;\nexport function useAssistantRuntime(options?: {\n optional?: boolean | undefined;\n}) {\n const aui = useAui();\n const runtime = aui.threads().__internal_getAssistantRuntime?.() ?? null;\n\n if (!runtime && !options?.optional) {\n throw new Error(\"AssistantRuntime is not available\");\n }\n\n return runtime;\n}\n\nconst useThreadListRuntime = (opt: {\n optional: boolean | undefined;\n}): ThreadListRuntime | null => useAssistantRuntime(opt)?.threads ?? null;\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.threads)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport const useThreadList = createStateHookForRuntime(useThreadListRuntime);\n"],"mappings":";;;;AA8CA,SAAgB,oBAAoB,SAEjC;CAED,MAAM,UADM,OACM,EAAE,QAAQ,EAAE,iCAAiC,KAAK;CAEpE,IAAI,CAAC,WAAW,CAAC,SAAS,UACxB,MAAM,IAAI,MAAM,mCAAmC;CAGrD,OAAO;AACT;AAEA,MAAM,wBAAwB,QAEE,oBAAoB,GAAG,GAAG,WAAW;;;;AAKrE,MAAa,gBAAgB,0BAA0B,oBAAoB"}
1
+ {"version":3,"file":"AssistantContext.js","names":[],"sources":["../../../src/legacy-runtime/hooks/AssistantContext.ts"],"sourcesContent":["\"use client\";\n\nimport { useAui } from \"@assistant-ui/store\";\nimport type { AssistantRuntime } from \"../runtime/AssistantRuntime\";\nimport type { ThreadListRuntime } from \"../runtime/ThreadListRuntime\";\nimport { createStateHookForRuntime } from \"../../context/react/utils/createStateHookForRuntime\";\n\n/**\n * @deprecated Use {@link useAui} instead. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n *\n * Hook to access the AssistantRuntime from the current context.\n *\n * The AssistantRuntime provides access to the top-level assistant state and actions,\n * including thread management, tool registration, and configuration.\n *\n * @param options Configuration options\n * @param options.optional Whether the hook should return null if no context is found\n * @returns The AssistantRuntime instance, or null if optional is true and no context exists\n *\n * @example\n * ```tsx\n * // Before:\n * function MyComponent() {\n * const runtime = useAssistantRuntime();\n * const handleNewThread = () => {\n * runtime.switchToNewThread();\n * };\n * return <button onClick={handleNewThread}>New Thread</button>;\n * }\n *\n * // After:\n * function MyComponent() {\n * const aui = useAui();\n * const handleNewThread = () => {\n * aui.threads().switchToNewThread();\n * };\n * return <button onClick={handleNewThread}>New Thread</button>;\n * }\n * ```\n */\nexport function useAssistantRuntime(options?: {\n optional?: false | undefined;\n}): AssistantRuntime;\nexport function useAssistantRuntime(options?: {\n optional?: boolean | undefined;\n}): AssistantRuntime | null;\nexport function useAssistantRuntime(options?: {\n optional?: boolean | undefined;\n}) {\n const aui = useAui();\n const runtime = aui.threads().__internal_getAssistantRuntime?.() ?? null;\n\n if (!runtime && !options?.optional) {\n throw new Error(\"AssistantRuntime is not available\");\n }\n\n return runtime;\n}\n\nconst useThreadListRuntime = (opt: {\n optional: boolean | undefined;\n}): ThreadListRuntime | null => useAssistantRuntime(opt)?.threads ?? null;\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.threads)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport const useThreadList = createStateHookForRuntime(useThreadListRuntime);\n"],"mappings":";;;;AA8CA,SAAgB,oBAAoB,SAEjC;CAED,MAAM,UADM,OACM,CAAC,CAAC,QAAQ,CAAC,CAAC,iCAAiC,KAAK;CAEpE,IAAI,CAAC,WAAW,CAAC,SAAS,UACxB,MAAM,IAAI,MAAM,mCAAmC;CAGrD,OAAO;AACT;AAEA,MAAM,wBAAwB,QAEE,oBAAoB,GAAG,CAAC,EAAE,WAAW;;;;AAKrE,MAAa,gBAAgB,0BAA0B,oBAAoB"}
@@ -1 +1 @@
1
- {"version":3,"file":"AttachmentContext.js","names":[],"sources":["../../../src/legacy-runtime/hooks/AttachmentContext.ts"],"sourcesContent":["\"use client\";\n\nimport type { AttachmentRuntime } from \"../runtime/AttachmentRuntime\";\nimport { createStateHookForRuntime } from \"../../context/react/utils/createStateHookForRuntime\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\n\n/**\n * @deprecated Use {@link useAui} with `aui.attachment()` instead. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport function useAttachmentRuntime(options?: {\n optional?: false | undefined;\n}): AttachmentRuntime;\nexport function useAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime | null;\nexport function useAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime | null {\n const aui = useAui();\n const runtime = useAuiState(() =>\n aui.attachment.source\n ? (aui.attachment().__internal_getRuntime?.() ?? null)\n : null,\n );\n if (!runtime && !options?.optional) {\n throw new Error(\"AttachmentRuntime is not available\");\n }\n return runtime;\n}\n\nexport function useThreadComposerAttachmentRuntime(options?: {\n optional?: false | undefined;\n}): AttachmentRuntime<\"thread-composer\">;\nexport function useThreadComposerAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime<\"thread-composer\"> | null;\nexport function useThreadComposerAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime<\"thread-composer\"> | null {\n const attachmentRuntime = useAttachmentRuntime(options);\n if (!attachmentRuntime) return null;\n if (attachmentRuntime.source !== \"thread-composer\")\n throw new Error(\n \"This component must be used within a thread's ComposerPrimitive.Attachments component.\",\n );\n return attachmentRuntime as AttachmentRuntime<\"thread-composer\">;\n}\n\nexport function useEditComposerAttachmentRuntime(options?: {\n optional?: false | undefined;\n}): AttachmentRuntime<\"edit-composer\">;\nexport function useEditComposerAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime<\"edit-composer\"> | null;\nexport function useEditComposerAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime<\"edit-composer\"> | null {\n const attachmentRuntime = useAttachmentRuntime(options);\n if (!attachmentRuntime) return null;\n if (attachmentRuntime.source !== \"edit-composer\")\n throw new Error(\n \"This component must be used within a message's ComposerPrimitive.Attachments component.\",\n );\n\n return attachmentRuntime as AttachmentRuntime<\"edit-composer\">;\n}\n\nexport function useMessageAttachmentRuntime(options?: {\n optional?: false | undefined;\n}): AttachmentRuntime<\"message\">;\nexport function useMessageAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime<\"message\"> | null;\nexport function useMessageAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime<\"message\"> | null {\n const attachmentRuntime = useAttachmentRuntime(options);\n if (!attachmentRuntime) return null;\n if (attachmentRuntime.source !== \"message\")\n throw new Error(\n \"This component must be used within a MessagePrimitive.Attachments component.\",\n );\n return attachmentRuntime as AttachmentRuntime<\"message\">;\n}\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.attachment)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport const useAttachment = createStateHookForRuntime(useAttachmentRuntime);\n\nexport const useThreadComposerAttachment = createStateHookForRuntime(\n useThreadComposerAttachmentRuntime,\n);\nexport const useEditComposerAttachment = createStateHookForRuntime(\n useEditComposerAttachmentRuntime,\n);\nexport const useMessageAttachment = createStateHookForRuntime(\n useMessageAttachmentRuntime,\n);\n"],"mappings":";;;;AAeA,SAAgB,qBAAqB,SAER;CAC3B,MAAM,MAAM,OAAO;CACnB,MAAM,UAAU,kBACd,IAAI,WAAW,SACV,IAAI,WAAW,EAAE,wBAAwB,KAAK,OAC/C,IACN;CACA,IAAI,CAAC,WAAW,CAAC,SAAS,UACxB,MAAM,IAAI,MAAM,oCAAoC;CAEtD,OAAO;AACT;AAQA,SAAgB,mCAAmC,SAEH;CAC9C,MAAM,oBAAoB,qBAAqB,OAAO;CACtD,IAAI,CAAC,mBAAmB,OAAO;CAC/B,IAAI,kBAAkB,WAAW,mBAC/B,MAAM,IAAI,MACR,wFACF;CACF,OAAO;AACT;AAQA,SAAgB,iCAAiC,SAEH;CAC5C,MAAM,oBAAoB,qBAAqB,OAAO;CACtD,IAAI,CAAC,mBAAmB,OAAO;CAC/B,IAAI,kBAAkB,WAAW,iBAC/B,MAAM,IAAI,MACR,yFACF;CAEF,OAAO;AACT;AAQA,SAAgB,4BAA4B,SAEJ;CACtC,MAAM,oBAAoB,qBAAqB,OAAO;CACtD,IAAI,CAAC,mBAAmB,OAAO;CAC/B,IAAI,kBAAkB,WAAW,WAC/B,MAAM,IAAI,MACR,8EACF;CACF,OAAO;AACT;;;;AAKA,MAAa,gBAAgB,0BAA0B,oBAAoB;AAE3E,MAAa,8BAA8B,0BACzC,kCACF;AACA,MAAa,4BAA4B,0BACvC,gCACF;AACA,MAAa,uBAAuB,0BAClC,2BACF"}
1
+ {"version":3,"file":"AttachmentContext.js","names":[],"sources":["../../../src/legacy-runtime/hooks/AttachmentContext.ts"],"sourcesContent":["\"use client\";\n\nimport type { AttachmentRuntime } from \"../runtime/AttachmentRuntime\";\nimport { createStateHookForRuntime } from \"../../context/react/utils/createStateHookForRuntime\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\n\n/**\n * @deprecated Use {@link useAui} with `aui.attachment()` instead. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport function useAttachmentRuntime(options?: {\n optional?: false | undefined;\n}): AttachmentRuntime;\nexport function useAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime | null;\nexport function useAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime | null {\n const aui = useAui();\n const runtime = useAuiState(() =>\n aui.attachment.source\n ? (aui.attachment().__internal_getRuntime?.() ?? null)\n : null,\n );\n if (!runtime && !options?.optional) {\n throw new Error(\"AttachmentRuntime is not available\");\n }\n return runtime;\n}\n\nexport function useThreadComposerAttachmentRuntime(options?: {\n optional?: false | undefined;\n}): AttachmentRuntime<\"thread-composer\">;\nexport function useThreadComposerAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime<\"thread-composer\"> | null;\nexport function useThreadComposerAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime<\"thread-composer\"> | null {\n const attachmentRuntime = useAttachmentRuntime(options);\n if (!attachmentRuntime) return null;\n if (attachmentRuntime.source !== \"thread-composer\")\n throw new Error(\n \"This component must be used within a thread's ComposerPrimitive.Attachments component.\",\n );\n return attachmentRuntime as AttachmentRuntime<\"thread-composer\">;\n}\n\nexport function useEditComposerAttachmentRuntime(options?: {\n optional?: false | undefined;\n}): AttachmentRuntime<\"edit-composer\">;\nexport function useEditComposerAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime<\"edit-composer\"> | null;\nexport function useEditComposerAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime<\"edit-composer\"> | null {\n const attachmentRuntime = useAttachmentRuntime(options);\n if (!attachmentRuntime) return null;\n if (attachmentRuntime.source !== \"edit-composer\")\n throw new Error(\n \"This component must be used within a message's ComposerPrimitive.Attachments component.\",\n );\n\n return attachmentRuntime as AttachmentRuntime<\"edit-composer\">;\n}\n\nexport function useMessageAttachmentRuntime(options?: {\n optional?: false | undefined;\n}): AttachmentRuntime<\"message\">;\nexport function useMessageAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime<\"message\"> | null;\nexport function useMessageAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime<\"message\"> | null {\n const attachmentRuntime = useAttachmentRuntime(options);\n if (!attachmentRuntime) return null;\n if (attachmentRuntime.source !== \"message\")\n throw new Error(\n \"This component must be used within a MessagePrimitive.Attachments component.\",\n );\n return attachmentRuntime as AttachmentRuntime<\"message\">;\n}\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.attachment)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport const useAttachment = createStateHookForRuntime(useAttachmentRuntime);\n\nexport const useThreadComposerAttachment = createStateHookForRuntime(\n useThreadComposerAttachmentRuntime,\n);\nexport const useEditComposerAttachment = createStateHookForRuntime(\n useEditComposerAttachmentRuntime,\n);\nexport const useMessageAttachment = createStateHookForRuntime(\n useMessageAttachmentRuntime,\n);\n"],"mappings":";;;;AAeA,SAAgB,qBAAqB,SAER;CAC3B,MAAM,MAAM,OAAO;CACnB,MAAM,UAAU,kBACd,IAAI,WAAW,SACV,IAAI,WAAW,CAAC,CAAC,wBAAwB,KAAK,OAC/C,IACN;CACA,IAAI,CAAC,WAAW,CAAC,SAAS,UACxB,MAAM,IAAI,MAAM,oCAAoC;CAEtD,OAAO;AACT;AAQA,SAAgB,mCAAmC,SAEH;CAC9C,MAAM,oBAAoB,qBAAqB,OAAO;CACtD,IAAI,CAAC,mBAAmB,OAAO;CAC/B,IAAI,kBAAkB,WAAW,mBAC/B,MAAM,IAAI,MACR,wFACF;CACF,OAAO;AACT;AAQA,SAAgB,iCAAiC,SAEH;CAC5C,MAAM,oBAAoB,qBAAqB,OAAO;CACtD,IAAI,CAAC,mBAAmB,OAAO;CAC/B,IAAI,kBAAkB,WAAW,iBAC/B,MAAM,IAAI,MACR,yFACF;CAEF,OAAO;AACT;AAQA,SAAgB,4BAA4B,SAEJ;CACtC,MAAM,oBAAoB,qBAAqB,OAAO;CACtD,IAAI,CAAC,mBAAmB,OAAO;CAC/B,IAAI,kBAAkB,WAAW,WAC/B,MAAM,IAAI,MACR,8EACF;CACF,OAAO;AACT;;;;AAKA,MAAa,gBAAgB,0BAA0B,oBAAoB;AAE3E,MAAa,8BAA8B,0BACzC,kCACF;AACA,MAAa,4BAA4B,0BACvC,gCACF;AACA,MAAa,uBAAuB,0BAClC,2BACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"ComposerContext.js","names":[],"sources":["../../../src/legacy-runtime/hooks/ComposerContext.ts"],"sourcesContent":["\"use client\";\n\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\nimport type { ComposerRuntime } from \"../runtime/ComposerRuntime\";\nimport { createStateHookForRuntime } from \"../../context/react/utils/createStateHookForRuntime\";\n\n/**\n * @deprecated Use {@link useAui} with `aui.composer()` instead. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n *\n * Hook to access the ComposerRuntime from the current context.\n *\n * The ComposerRuntime provides access to composer state and actions for message\n * composition, including text input, attachments, and sending functionality.\n * This hook automatically resolves to either the message's edit composer or\n * the thread's main composer depending on the context.\n *\n * @param options Configuration options\n * @param options.optional Whether the hook should return null if no context is found\n * @returns The ComposerRuntime instance, or null if optional is true and no context exists\n *\n * @example\n * ```tsx\n * // Before:\n * function ComposerActions() {\n * const runtime = useComposerRuntime();\n * const handleSend = () => {\n * if (runtime.getState().canSend) {\n * runtime.send();\n * }\n * };\n * const handleCancel = () => {\n * if (runtime.getState().canCancel) {\n * runtime.cancel();\n * }\n * };\n * return (\n * <div>\n * <button onClick={handleSend}>Send</button>\n * <button onClick={handleCancel}>Cancel</button>\n * </div>\n * );\n * }\n *\n * // After:\n * function ComposerActions() {\n * const aui = useAui();\n * const canSend = useAuiState((s) => s.composer.canSend);\n * const canCancel = useAuiState((s) => s.composer.canCancel);\n * const handleSend = () => {\n * if (canSend) {\n * aui.composer().send();\n * }\n * };\n * const handleCancel = () => {\n * if (canCancel) {\n * aui.composer().cancel();\n * }\n * };\n * return (\n * <div>\n * <button onClick={handleSend}>Send</button>\n * <button onClick={handleCancel}>Cancel</button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useComposerRuntime(options?: {\n optional?: false | undefined;\n}): ComposerRuntime;\nexport function useComposerRuntime(options?: {\n optional?: boolean | undefined;\n}): ComposerRuntime | null;\nexport function useComposerRuntime(options?: {\n optional?: boolean | undefined;\n}): ComposerRuntime | null {\n const aui = useAui();\n const runtime = useAuiState(() =>\n aui.composer.source\n ? (aui.composer().__internal_getRuntime?.() ?? null)\n : null,\n );\n if (!runtime && !options?.optional) {\n throw new Error(\"ComposerRuntime is not available\");\n }\n return runtime;\n}\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.composer)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n *\n * Hook to access the current composer state.\n *\n * This hook provides reactive access to the composer's state, including text content,\n * attachments, editing status, and send/cancel capabilities.\n *\n * @param selector Optional selector function to pick specific state properties\n * @returns The selected composer state or the entire composer state if no selector provided\n *\n * @example\n * ```tsx\n * // Before:\n * function ComposerStatus() {\n * const text = useComposer((state) => state.text);\n * const canSend = useComposer((state) => state.canSend);\n * const attachmentCount = useComposer((state) => state.attachments.length);\n * return (\n * <div>\n * Text: {text.length} chars,\n * Attachments: {attachmentCount},\n * Can send: {canSend}\n * </div>\n * );\n * }\n *\n * // After:\n * function ComposerStatus() {\n * const text = useAuiState((s) => s.composer.text);\n * const canSend = useAuiState((s) => s.composer.canSend);\n * const attachmentCount = useAuiState((s) => s.composer.attachments.length);\n * return (\n * <div>\n * Text: {text.length} chars,\n * Attachments: {attachmentCount},\n * Can send: {canSend}\n * </div>\n * );\n * }\n * ```\n */\nexport const useComposer = createStateHookForRuntime(useComposerRuntime);\n"],"mappings":";;;;AAyEA,SAAgB,mBAAmB,SAER;CACzB,MAAM,MAAM,OAAO;CACnB,MAAM,UAAU,kBACd,IAAI,SAAS,SACR,IAAI,SAAS,EAAE,wBAAwB,KAAK,OAC7C,IACN;CACA,IAAI,CAAC,WAAW,CAAC,SAAS,UACxB,MAAM,IAAI,MAAM,kCAAkC;CAEpD,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,MAAa,cAAc,0BAA0B,kBAAkB"}
1
+ {"version":3,"file":"ComposerContext.js","names":[],"sources":["../../../src/legacy-runtime/hooks/ComposerContext.ts"],"sourcesContent":["\"use client\";\n\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\nimport type { ComposerRuntime } from \"../runtime/ComposerRuntime\";\nimport { createStateHookForRuntime } from \"../../context/react/utils/createStateHookForRuntime\";\n\n/**\n * @deprecated Use {@link useAui} with `aui.composer()` instead. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n *\n * Hook to access the ComposerRuntime from the current context.\n *\n * The ComposerRuntime provides access to composer state and actions for message\n * composition, including text input, attachments, and sending functionality.\n * This hook automatically resolves to either the message's edit composer or\n * the thread's main composer depending on the context.\n *\n * @param options Configuration options\n * @param options.optional Whether the hook should return null if no context is found\n * @returns The ComposerRuntime instance, or null if optional is true and no context exists\n *\n * @example\n * ```tsx\n * // Before:\n * function ComposerActions() {\n * const runtime = useComposerRuntime();\n * const handleSend = () => {\n * if (runtime.getState().canSend) {\n * runtime.send();\n * }\n * };\n * const handleCancel = () => {\n * if (runtime.getState().canCancel) {\n * runtime.cancel();\n * }\n * };\n * return (\n * <div>\n * <button onClick={handleSend}>Send</button>\n * <button onClick={handleCancel}>Cancel</button>\n * </div>\n * );\n * }\n *\n * // After:\n * function ComposerActions() {\n * const aui = useAui();\n * const canSend = useAuiState((s) => s.composer.canSend);\n * const canCancel = useAuiState((s) => s.composer.canCancel);\n * const handleSend = () => {\n * if (canSend) {\n * aui.composer().send();\n * }\n * };\n * const handleCancel = () => {\n * if (canCancel) {\n * aui.composer().cancel();\n * }\n * };\n * return (\n * <div>\n * <button onClick={handleSend}>Send</button>\n * <button onClick={handleCancel}>Cancel</button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useComposerRuntime(options?: {\n optional?: false | undefined;\n}): ComposerRuntime;\nexport function useComposerRuntime(options?: {\n optional?: boolean | undefined;\n}): ComposerRuntime | null;\nexport function useComposerRuntime(options?: {\n optional?: boolean | undefined;\n}): ComposerRuntime | null {\n const aui = useAui();\n const runtime = useAuiState(() =>\n aui.composer.source\n ? (aui.composer().__internal_getRuntime?.() ?? null)\n : null,\n );\n if (!runtime && !options?.optional) {\n throw new Error(\"ComposerRuntime is not available\");\n }\n return runtime;\n}\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.composer)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n *\n * Hook to access the current composer state.\n *\n * This hook provides reactive access to the composer's state, including text content,\n * attachments, editing status, and send/cancel capabilities.\n *\n * @param selector Optional selector function to pick specific state properties\n * @returns The selected composer state or the entire composer state if no selector provided\n *\n * @example\n * ```tsx\n * // Before:\n * function ComposerStatus() {\n * const text = useComposer((state) => state.text);\n * const canSend = useComposer((state) => state.canSend);\n * const attachmentCount = useComposer((state) => state.attachments.length);\n * return (\n * <div>\n * Text: {text.length} chars,\n * Attachments: {attachmentCount},\n * Can send: {canSend}\n * </div>\n * );\n * }\n *\n * // After:\n * function ComposerStatus() {\n * const text = useAuiState((s) => s.composer.text);\n * const canSend = useAuiState((s) => s.composer.canSend);\n * const attachmentCount = useAuiState((s) => s.composer.attachments.length);\n * return (\n * <div>\n * Text: {text.length} chars,\n * Attachments: {attachmentCount},\n * Can send: {canSend}\n * </div>\n * );\n * }\n * ```\n */\nexport const useComposer = createStateHookForRuntime(useComposerRuntime);\n"],"mappings":";;;;AAyEA,SAAgB,mBAAmB,SAER;CACzB,MAAM,MAAM,OAAO;CACnB,MAAM,UAAU,kBACd,IAAI,SAAS,SACR,IAAI,SAAS,CAAC,CAAC,wBAAwB,KAAK,OAC7C,IACN;CACA,IAAI,CAAC,WAAW,CAAC,SAAS,UACxB,MAAM,IAAI,MAAM,kCAAkC;CAEpD,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,MAAa,cAAc,0BAA0B,kBAAkB"}
@@ -1 +1 @@
1
- {"version":3,"file":"MessageContext.js","names":[],"sources":["../../../src/legacy-runtime/hooks/MessageContext.ts"],"sourcesContent":["\"use client\";\n\nimport type { MessageRuntime } from \"../runtime/MessageRuntime\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\nimport { createStateHookForRuntime } from \"../../context/react/utils/createStateHookForRuntime\";\nimport type { EditComposerRuntime } from \"@assistant-ui/core\";\n\n/**\n * @deprecated Use {@link useAui} with `aui.message()` instead. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n *\n * Hook to access the MessageRuntime from the current context.\n *\n * The MessageRuntime provides access to message-level state and actions,\n * including message content, status, editing capabilities, and branching.\n *\n * @param options Configuration options\n * @param options.optional Whether the hook should return null if no context is found\n * @returns The MessageRuntime instance, or null if optional is true and no context exists\n *\n * @example\n * ```tsx\n * // Before:\n * function MessageActions() {\n * const runtime = useMessageRuntime();\n * const handleReload = () => {\n * runtime.reload();\n * };\n * const handleEdit = () => {\n * runtime.startEdit();\n * };\n * return (\n * <div>\n * <button onClick={handleReload}>Reload</button>\n * <button onClick={handleEdit}>Edit</button>\n * </div>\n * );\n * }\n *\n * // After:\n * function MessageActions() {\n * const aui = useAui();\n * const handleReload = () => {\n * aui.message().reload();\n * };\n * const handleEdit = () => {\n * aui.message().startEdit();\n * };\n * return (\n * <div>\n * <button onClick={handleReload}>Reload</button>\n * <button onClick={handleEdit}>Edit</button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useMessageRuntime(options?: {\n optional?: false | undefined;\n}): MessageRuntime;\nexport function useMessageRuntime(options?: {\n optional?: boolean | undefined;\n}): MessageRuntime | null;\nexport function useMessageRuntime(options?: {\n optional?: boolean | undefined;\n}) {\n const aui = useAui();\n const runtime = useAuiState(() =>\n aui.message.source\n ? (aui.message().__internal_getRuntime?.() ?? null)\n : null,\n );\n if (!runtime && !options?.optional) {\n throw new Error(\"MessageRuntime is not available\");\n }\n return runtime;\n}\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.message)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n *\n * Hook to access the current message state.\n *\n * This hook provides reactive access to the message's state, including content,\n * role, status, and other message-level properties.\n *\n * @param selector Optional selector function to pick specific state properties\n * @returns The selected message state or the entire message state if no selector provided\n *\n * @example\n * ```tsx\n * // Before:\n * function MessageContent() {\n * const role = useMessage((state) => state.role);\n * const content = useMessage((state) => state.content);\n * const isLoading = useMessage((state) => state.status.type === \"running\");\n * return (\n * <div className={`message-${role}`}>\n * {isLoading ? \"Loading...\" : content.map(part => part.text).join(\"\")}\n * </div>\n * );\n * }\n *\n * // After:\n * function MessageContent() {\n * const role = useAuiState((s) => s.message.role);\n * const content = useAuiState((s) => s.message.content);\n * const isLoading = useAuiState((s) => s.message.status.type === \"running\");\n * return (\n * <div className={`message-${role}`}>\n * {isLoading ? \"Loading...\" : content.map(part => part.text).join(\"\")}\n * </div>\n * );\n * }\n * ```\n */\nexport const useMessage = createStateHookForRuntime(useMessageRuntime);\n\nconst useEditComposerRuntime = (opt: {\n optional: boolean | undefined;\n}): EditComposerRuntime | null => useMessageRuntime(opt)?.composer ?? null;\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.message.composer)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport const useEditComposer = createStateHookForRuntime(\n useEditComposerRuntime,\n);\n"],"mappings":";;;;AA8DA,SAAgB,kBAAkB,SAE/B;CACD,MAAM,MAAM,OAAO;CACnB,MAAM,UAAU,kBACd,IAAI,QAAQ,SACP,IAAI,QAAQ,EAAE,wBAAwB,KAAK,OAC5C,IACN;CACA,IAAI,CAAC,WAAW,CAAC,SAAS,UACxB,MAAM,IAAI,MAAM,iCAAiC;CAEnD,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,MAAa,aAAa,0BAA0B,iBAAiB;AAErE,MAAM,0BAA0B,QAEE,kBAAkB,GAAG,GAAG,YAAY;;;;AAKtE,MAAa,kBAAkB,0BAC7B,sBACF"}
1
+ {"version":3,"file":"MessageContext.js","names":[],"sources":["../../../src/legacy-runtime/hooks/MessageContext.ts"],"sourcesContent":["\"use client\";\n\nimport type { MessageRuntime } from \"../runtime/MessageRuntime\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\nimport { createStateHookForRuntime } from \"../../context/react/utils/createStateHookForRuntime\";\nimport type { EditComposerRuntime } from \"@assistant-ui/core\";\n\n/**\n * @deprecated Use {@link useAui} with `aui.message()` instead. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n *\n * Hook to access the MessageRuntime from the current context.\n *\n * The MessageRuntime provides access to message-level state and actions,\n * including message content, status, editing capabilities, and branching.\n *\n * @param options Configuration options\n * @param options.optional Whether the hook should return null if no context is found\n * @returns The MessageRuntime instance, or null if optional is true and no context exists\n *\n * @example\n * ```tsx\n * // Before:\n * function MessageActions() {\n * const runtime = useMessageRuntime();\n * const handleReload = () => {\n * runtime.reload();\n * };\n * const handleEdit = () => {\n * runtime.startEdit();\n * };\n * return (\n * <div>\n * <button onClick={handleReload}>Reload</button>\n * <button onClick={handleEdit}>Edit</button>\n * </div>\n * );\n * }\n *\n * // After:\n * function MessageActions() {\n * const aui = useAui();\n * const handleReload = () => {\n * aui.message().reload();\n * };\n * const handleEdit = () => {\n * aui.message().startEdit();\n * };\n * return (\n * <div>\n * <button onClick={handleReload}>Reload</button>\n * <button onClick={handleEdit}>Edit</button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useMessageRuntime(options?: {\n optional?: false | undefined;\n}): MessageRuntime;\nexport function useMessageRuntime(options?: {\n optional?: boolean | undefined;\n}): MessageRuntime | null;\nexport function useMessageRuntime(options?: {\n optional?: boolean | undefined;\n}) {\n const aui = useAui();\n const runtime = useAuiState(() =>\n aui.message.source\n ? (aui.message().__internal_getRuntime?.() ?? null)\n : null,\n );\n if (!runtime && !options?.optional) {\n throw new Error(\"MessageRuntime is not available\");\n }\n return runtime;\n}\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.message)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n *\n * Hook to access the current message state.\n *\n * This hook provides reactive access to the message's state, including content,\n * role, status, and other message-level properties.\n *\n * @param selector Optional selector function to pick specific state properties\n * @returns The selected message state or the entire message state if no selector provided\n *\n * @example\n * ```tsx\n * // Before:\n * function MessageContent() {\n * const role = useMessage((state) => state.role);\n * const content = useMessage((state) => state.content);\n * const isLoading = useMessage((state) => state.status.type === \"running\");\n * return (\n * <div className={`message-${role}`}>\n * {isLoading ? \"Loading...\" : content.map(part => part.text).join(\"\")}\n * </div>\n * );\n * }\n *\n * // After:\n * function MessageContent() {\n * const role = useAuiState((s) => s.message.role);\n * const content = useAuiState((s) => s.message.content);\n * const isLoading = useAuiState((s) => s.message.status.type === \"running\");\n * return (\n * <div className={`message-${role}`}>\n * {isLoading ? \"Loading...\" : content.map(part => part.text).join(\"\")}\n * </div>\n * );\n * }\n * ```\n */\nexport const useMessage = createStateHookForRuntime(useMessageRuntime);\n\nconst useEditComposerRuntime = (opt: {\n optional: boolean | undefined;\n}): EditComposerRuntime | null => useMessageRuntime(opt)?.composer ?? null;\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.message.composer)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport const useEditComposer = createStateHookForRuntime(\n useEditComposerRuntime,\n);\n"],"mappings":";;;;AA8DA,SAAgB,kBAAkB,SAE/B;CACD,MAAM,MAAM,OAAO;CACnB,MAAM,UAAU,kBACd,IAAI,QAAQ,SACP,IAAI,QAAQ,CAAC,CAAC,wBAAwB,KAAK,OAC5C,IACN;CACA,IAAI,CAAC,WAAW,CAAC,SAAS,UACxB,MAAM,IAAI,MAAM,iCAAiC;CAEnD,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,MAAa,aAAa,0BAA0B,iBAAiB;AAErE,MAAM,0BAA0B,QAEE,kBAAkB,GAAG,CAAC,EAAE,YAAY;;;;AAKtE,MAAa,kBAAkB,0BAC7B,sBACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"MessagePartContext.js","names":[],"sources":["../../../src/legacy-runtime/hooks/MessagePartContext.ts"],"sourcesContent":["\"use client\";\n\nimport type { MessagePartRuntime } from \"../runtime/MessagePartRuntime\";\nimport { createStateHookForRuntime } from \"../../context/react/utils/createStateHookForRuntime\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\n\n/**\n * @deprecated Use {@link useAui} with `aui.part()` instead. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport function useMessagePartRuntime(options?: {\n optional?: false | undefined;\n}): MessagePartRuntime;\nexport function useMessagePartRuntime(options?: {\n optional?: boolean | undefined;\n}): MessagePartRuntime | null;\nexport function useMessagePartRuntime(options?: {\n optional?: boolean | undefined;\n}) {\n const aui = useAui();\n const runtime = useAuiState(() =>\n aui.part.source ? (aui.part().__internal_getRuntime?.() ?? null) : null,\n );\n if (!runtime && !options?.optional) {\n throw new Error(\"MessagePartRuntime is not available\");\n }\n return runtime;\n}\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.part)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport const useMessagePart = createStateHookForRuntime(useMessagePartRuntime);\n"],"mappings":";;;;AAeA,SAAgB,sBAAsB,SAEnC;CACD,MAAM,MAAM,OAAO;CACnB,MAAM,UAAU,kBACd,IAAI,KAAK,SAAU,IAAI,KAAK,EAAE,wBAAwB,KAAK,OAAQ,IACrE;CACA,IAAI,CAAC,WAAW,CAAC,SAAS,UACxB,MAAM,IAAI,MAAM,qCAAqC;CAEvD,OAAO;AACT;;;;AAKA,MAAa,iBAAiB,0BAA0B,qBAAqB"}
1
+ {"version":3,"file":"MessagePartContext.js","names":[],"sources":["../../../src/legacy-runtime/hooks/MessagePartContext.ts"],"sourcesContent":["\"use client\";\n\nimport type { MessagePartRuntime } from \"../runtime/MessagePartRuntime\";\nimport { createStateHookForRuntime } from \"../../context/react/utils/createStateHookForRuntime\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\n\n/**\n * @deprecated Use {@link useAui} with `aui.part()` instead. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport function useMessagePartRuntime(options?: {\n optional?: false | undefined;\n}): MessagePartRuntime;\nexport function useMessagePartRuntime(options?: {\n optional?: boolean | undefined;\n}): MessagePartRuntime | null;\nexport function useMessagePartRuntime(options?: {\n optional?: boolean | undefined;\n}) {\n const aui = useAui();\n const runtime = useAuiState(() =>\n aui.part.source ? (aui.part().__internal_getRuntime?.() ?? null) : null,\n );\n if (!runtime && !options?.optional) {\n throw new Error(\"MessagePartRuntime is not available\");\n }\n return runtime;\n}\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.part)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport const useMessagePart = createStateHookForRuntime(useMessagePartRuntime);\n"],"mappings":";;;;AAeA,SAAgB,sBAAsB,SAEnC;CACD,MAAM,MAAM,OAAO;CACnB,MAAM,UAAU,kBACd,IAAI,KAAK,SAAU,IAAI,KAAK,CAAC,CAAC,wBAAwB,KAAK,OAAQ,IACrE;CACA,IAAI,CAAC,WAAW,CAAC,SAAS,UACxB,MAAM,IAAI,MAAM,qCAAqC;CAEvD,OAAO;AACT;;;;AAKA,MAAa,iBAAiB,0BAA0B,qBAAqB"}
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { createStateHookForRuntime } from "../../context/react/utils/createStateHookForRuntime.js";
3
3
  import { useAui, useAuiEvent, useAuiState } from "@assistant-ui/store";
4
- import { useState } from "react";
4
+ import { useState } from "@assistant-ui/tap/react-shim";
5
5
  //#region src/legacy-runtime/hooks/ThreadContext.ts
6
6
  function useThreadRuntime(options) {
7
7
  const aui = useAui();
@@ -1 +1 @@
1
- {"version":3,"file":"ThreadContext.js","names":[],"sources":["../../../src/legacy-runtime/hooks/ThreadContext.ts"],"sourcesContent":["\"use client\";\n\nimport { useState } from \"react\";\nimport type { ThreadRuntime } from \"../runtime/ThreadRuntime\";\nimport type { ModelContext } from \"@assistant-ui/core\";\nimport { createStateHookForRuntime } from \"../../context/react/utils/createStateHookForRuntime\";\nimport type { ThreadComposerRuntime } from \"@assistant-ui/core\";\nimport { useAui, useAuiEvent, useAuiState } from \"@assistant-ui/store\";\n\n/**\n * @deprecated Use {@link useAui} with `aui.thread()` instead. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n *\n * Hook to access the ThreadRuntime from the current context.\n *\n * The ThreadRuntime provides access to thread-level state and actions,\n * including message management, thread state, and composer functionality.\n *\n * @param options Configuration options\n * @param options.optional Whether the hook should return null if no context is found\n * @returns The ThreadRuntime instance, or null if optional is true and no context exists\n *\n * @example\n * ```tsx\n * // Before:\n * function MyComponent() {\n * const runtime = useThreadRuntime();\n * const handleSendMessage = (text: string) => {\n * runtime.append({ role: \"user\", content: [{ type: \"text\", text }] });\n * };\n * return <button onClick={() => handleSendMessage(\"Hello!\")}>Send</button>;\n * }\n *\n * // After:\n * function MyComponent() {\n * const aui = useAui();\n * const handleSendMessage = (text: string) => {\n * aui.thread().append({ role: \"user\", content: [{ type: \"text\", text }] });\n * };\n * return <button onClick={() => handleSendMessage(\"Hello!\")}>Send</button>;\n * }\n * ```\n */\nexport function useThreadRuntime(options?: {\n optional?: false | undefined;\n}): ThreadRuntime;\nexport function useThreadRuntime(options?: {\n optional?: boolean | undefined;\n}): ThreadRuntime | null;\nexport function useThreadRuntime(options?: { optional?: boolean | undefined }) {\n const aui = useAui();\n const runtime = useAuiState(() =>\n aui.thread.source ? (aui.thread().__internal_getRuntime?.() ?? null) : null,\n );\n if (!runtime && !options?.optional) {\n throw new Error(\"ThreadRuntime is not available\");\n }\n return runtime;\n}\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.thread)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n *\n * Hook to access the current thread state.\n *\n * This hook provides reactive access to the thread's state, including messages,\n * running status, capabilities, and other thread-level properties.\n *\n * @param selector Optional selector function to pick specific state properties\n * @returns The selected thread state or the entire thread state if no selector provided\n *\n * @example\n * ```tsx\n * // Before:\n * function ThreadStatus() {\n * const isRunning = useThread((state) => state.isRunning);\n * const messageCount = useThread((state) => state.messages.length);\n * return <div>Running: {isRunning}, Messages: {messageCount}</div>;\n * }\n *\n * // After:\n * function ThreadStatus() {\n * const isRunning = useAuiState((s) => s.thread.isRunning);\n * const messageCount = useAuiState((s) => s.thread.messages.length);\n * return <div>Running: {isRunning}, Messages: {messageCount}</div>;\n * }\n * ```\n */\nexport const useThread = createStateHookForRuntime(useThreadRuntime);\n\nconst useThreadComposerRuntime = (opt: {\n optional: boolean | undefined;\n}): ThreadComposerRuntime | null => useThreadRuntime(opt)?.composer ?? null;\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.thread.composer)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport const useThreadComposer = createStateHookForRuntime(\n useThreadComposerRuntime,\n);\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.thread.modelContext)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport function useThreadModelContext(options?: {\n optional?: false | undefined;\n}): ModelContext;\nexport function useThreadModelContext(options?: {\n optional?: boolean | undefined;\n}): ModelContext | null;\nexport function useThreadModelContext(options?: {\n optional?: boolean | undefined;\n}): ModelContext | null {\n const [, rerender] = useState({});\n\n const runtime = useThreadRuntime(options);\n useAuiEvent(\"thread.modelContextUpdate\", () => rerender({}));\n\n if (!runtime) return null;\n return runtime?.getModelContext();\n}\n"],"mappings":";;;;;AAgDA,SAAgB,iBAAiB,SAA8C;CAC7E,MAAM,MAAM,OAAO;CACnB,MAAM,UAAU,kBACd,IAAI,OAAO,SAAU,IAAI,OAAO,EAAE,wBAAwB,KAAK,OAAQ,IACzE;CACA,IAAI,CAAC,WAAW,CAAC,SAAS,UACxB,MAAM,IAAI,MAAM,gCAAgC;CAElD,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAa,YAAY,0BAA0B,gBAAgB;AAEnE,MAAM,4BAA4B,QAEE,iBAAiB,GAAG,GAAG,YAAY;;;;AAKvE,MAAa,oBAAoB,0BAC/B,wBACF;AAWA,SAAgB,sBAAsB,SAEd;CACtB,MAAM,GAAG,YAAY,SAAS,CAAC,CAAC;CAEhC,MAAM,UAAU,iBAAiB,OAAO;CACxC,YAAY,mCAAmC,SAAS,CAAC,CAAC,CAAC;CAE3D,IAAI,CAAC,SAAS,OAAO;CACrB,OAAO,SAAS,gBAAgB;AAClC"}
1
+ {"version":3,"file":"ThreadContext.js","names":[],"sources":["../../../src/legacy-runtime/hooks/ThreadContext.ts"],"sourcesContent":["\"use client\";\n\nimport { useState } from \"react\";\nimport type { ThreadRuntime } from \"../runtime/ThreadRuntime\";\nimport type { ModelContext } from \"@assistant-ui/core\";\nimport { createStateHookForRuntime } from \"../../context/react/utils/createStateHookForRuntime\";\nimport type { ThreadComposerRuntime } from \"@assistant-ui/core\";\nimport { useAui, useAuiEvent, useAuiState } from \"@assistant-ui/store\";\n\n/**\n * @deprecated Use {@link useAui} with `aui.thread()` instead. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n *\n * Hook to access the ThreadRuntime from the current context.\n *\n * The ThreadRuntime provides access to thread-level state and actions,\n * including message management, thread state, and composer functionality.\n *\n * @param options Configuration options\n * @param options.optional Whether the hook should return null if no context is found\n * @returns The ThreadRuntime instance, or null if optional is true and no context exists\n *\n * @example\n * ```tsx\n * // Before:\n * function MyComponent() {\n * const runtime = useThreadRuntime();\n * const handleSendMessage = (text: string) => {\n * runtime.append({ role: \"user\", content: [{ type: \"text\", text }] });\n * };\n * return <button onClick={() => handleSendMessage(\"Hello!\")}>Send</button>;\n * }\n *\n * // After:\n * function MyComponent() {\n * const aui = useAui();\n * const handleSendMessage = (text: string) => {\n * aui.thread().append({ role: \"user\", content: [{ type: \"text\", text }] });\n * };\n * return <button onClick={() => handleSendMessage(\"Hello!\")}>Send</button>;\n * }\n * ```\n */\nexport function useThreadRuntime(options?: {\n optional?: false | undefined;\n}): ThreadRuntime;\nexport function useThreadRuntime(options?: {\n optional?: boolean | undefined;\n}): ThreadRuntime | null;\nexport function useThreadRuntime(options?: { optional?: boolean | undefined }) {\n const aui = useAui();\n const runtime = useAuiState(() =>\n aui.thread.source ? (aui.thread().__internal_getRuntime?.() ?? null) : null,\n );\n if (!runtime && !options?.optional) {\n throw new Error(\"ThreadRuntime is not available\");\n }\n return runtime;\n}\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.thread)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n *\n * Hook to access the current thread state.\n *\n * This hook provides reactive access to the thread's state, including messages,\n * running status, capabilities, and other thread-level properties.\n *\n * @param selector Optional selector function to pick specific state properties\n * @returns The selected thread state or the entire thread state if no selector provided\n *\n * @example\n * ```tsx\n * // Before:\n * function ThreadStatus() {\n * const isRunning = useThread((state) => state.isRunning);\n * const messageCount = useThread((state) => state.messages.length);\n * return <div>Running: {isRunning}, Messages: {messageCount}</div>;\n * }\n *\n * // After:\n * function ThreadStatus() {\n * const isRunning = useAuiState((s) => s.thread.isRunning);\n * const messageCount = useAuiState((s) => s.thread.messages.length);\n * return <div>Running: {isRunning}, Messages: {messageCount}</div>;\n * }\n * ```\n */\nexport const useThread = createStateHookForRuntime(useThreadRuntime);\n\nconst useThreadComposerRuntime = (opt: {\n optional: boolean | undefined;\n}): ThreadComposerRuntime | null => useThreadRuntime(opt)?.composer ?? null;\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.thread.composer)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport const useThreadComposer = createStateHookForRuntime(\n useThreadComposerRuntime,\n);\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.thread.modelContext)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport function useThreadModelContext(options?: {\n optional?: false | undefined;\n}): ModelContext;\nexport function useThreadModelContext(options?: {\n optional?: boolean | undefined;\n}): ModelContext | null;\nexport function useThreadModelContext(options?: {\n optional?: boolean | undefined;\n}): ModelContext | null {\n const [, rerender] = useState({});\n\n const runtime = useThreadRuntime(options);\n useAuiEvent(\"thread.modelContextUpdate\", () => rerender({}));\n\n if (!runtime) return null;\n return runtime?.getModelContext();\n}\n"],"mappings":";;;;;AAgDA,SAAgB,iBAAiB,SAA8C;CAC7E,MAAM,MAAM,OAAO;CACnB,MAAM,UAAU,kBACd,IAAI,OAAO,SAAU,IAAI,OAAO,CAAC,CAAC,wBAAwB,KAAK,OAAQ,IACzE;CACA,IAAI,CAAC,WAAW,CAAC,SAAS,UACxB,MAAM,IAAI,MAAM,gCAAgC;CAElD,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAa,YAAY,0BAA0B,gBAAgB;AAEnE,MAAM,4BAA4B,QAEE,iBAAiB,GAAG,CAAC,EAAE,YAAY;;;;AAKvE,MAAa,oBAAoB,0BAC/B,wBACF;AAWA,SAAgB,sBAAsB,SAEd;CACtB,MAAM,GAAG,YAAY,SAAS,CAAC,CAAC;CAEhC,MAAM,UAAU,iBAAiB,OAAO;CACxC,YAAY,mCAAmC,SAAS,CAAC,CAAC,CAAC;CAE3D,IAAI,CAAC,SAAS,OAAO;CACrB,OAAO,SAAS,gBAAgB;AAClC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ThreadListItemContext.js","names":[],"sources":["../../../src/legacy-runtime/hooks/ThreadListItemContext.ts"],"sourcesContent":["\"use client\";\n\nimport type { ThreadListItemRuntime } from \"../runtime/ThreadListItemRuntime\";\nimport { createStateHookForRuntime } from \"../../context/react/utils/createStateHookForRuntime\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\n\n/**\n * @deprecated Use {@link useAui} with `aui.threadListItem()` instead. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport function useThreadListItemRuntime(options?: {\n optional?: false | undefined;\n}): ThreadListItemRuntime;\nexport function useThreadListItemRuntime(options?: {\n optional?: boolean | undefined;\n}): ThreadListItemRuntime | null;\nexport function useThreadListItemRuntime(options?: {\n optional?: boolean | undefined;\n}) {\n const aui = useAui();\n const runtime = useAuiState(() =>\n aui.threadListItem.source\n ? (aui.threadListItem().__internal_getRuntime?.() ?? null)\n : null,\n );\n if (!runtime && !options?.optional) {\n throw new Error(\"ThreadListItemRuntime is not available\");\n }\n return runtime;\n}\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.threadListItem)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport const useThreadListItem = createStateHookForRuntime(\n useThreadListItemRuntime,\n);\n"],"mappings":";;;;AAeA,SAAgB,yBAAyB,SAEtC;CACD,MAAM,MAAM,OAAO;CACnB,MAAM,UAAU,kBACd,IAAI,eAAe,SACd,IAAI,eAAe,EAAE,wBAAwB,KAAK,OACnD,IACN;CACA,IAAI,CAAC,WAAW,CAAC,SAAS,UACxB,MAAM,IAAI,MAAM,wCAAwC;CAE1D,OAAO;AACT;;;;AAKA,MAAa,oBAAoB,0BAC/B,wBACF"}
1
+ {"version":3,"file":"ThreadListItemContext.js","names":[],"sources":["../../../src/legacy-runtime/hooks/ThreadListItemContext.ts"],"sourcesContent":["\"use client\";\n\nimport type { ThreadListItemRuntime } from \"../runtime/ThreadListItemRuntime\";\nimport { createStateHookForRuntime } from \"../../context/react/utils/createStateHookForRuntime\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\n\n/**\n * @deprecated Use {@link useAui} with `aui.threadListItem()` instead. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport function useThreadListItemRuntime(options?: {\n optional?: false | undefined;\n}): ThreadListItemRuntime;\nexport function useThreadListItemRuntime(options?: {\n optional?: boolean | undefined;\n}): ThreadListItemRuntime | null;\nexport function useThreadListItemRuntime(options?: {\n optional?: boolean | undefined;\n}) {\n const aui = useAui();\n const runtime = useAuiState(() =>\n aui.threadListItem.source\n ? (aui.threadListItem().__internal_getRuntime?.() ?? null)\n : null,\n );\n if (!runtime && !options?.optional) {\n throw new Error(\"ThreadListItemRuntime is not available\");\n }\n return runtime;\n}\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.threadListItem)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport const useThreadListItem = createStateHookForRuntime(\n useThreadListItemRuntime,\n);\n"],"mappings":";;;;AAeA,SAAgB,yBAAyB,SAEtC;CACD,MAAM,MAAM,OAAO;CACnB,MAAM,UAAU,kBACd,IAAI,eAAe,SACd,IAAI,eAAe,CAAC,CAAC,wBAAwB,KAAK,OACnD,IACN;CACA,IAAI,CAAC,WAAW,CAAC,SAAS,UACxB,MAAM,IAAI,MAAM,wCAAwC;CAE1D,OAAO;AACT;;;;AAKA,MAAa,oBAAoB,0BAC/B,wBACF"}
@@ -1,4 +1,4 @@
1
- import { useCallback, useEffect, useRef, useState } from "react";
1
+ import { useCallback, useEffect, useRef, useState } from "@assistant-ui/tap/react-shim";
2
2
  //#region src/legacy-runtime/runtime-cores/assistant-transport/commandQueue.ts
3
3
  const createInitialQueueState = () => ({
4
4
  queued: [],
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { useCallback, useEffect, useRef, useState } from "react";
2
+ import { useCallback, useEffect, useRef, useState } from "@assistant-ui/tap/react-shim";
3
3
  //#region src/legacy-runtime/runtime-cores/assistant-transport/replayBoundaryStream.ts
4
4
  const REPLAY_CONTENT_LENGTH_HEADER = "Aui-Replay-Content-Length";
5
5
  const useReplayRenderWait = () => {
@@ -1,5 +1,5 @@
1
1
  import { useLatestRef } from "./useLatestRef.js";
2
- import { useCallback, useRef, useState } from "react";
2
+ import { useCallback, useRef, useState } from "@assistant-ui/tap/react-shim";
3
3
  //#region src/legacy-runtime/runtime-cores/assistant-transport/runManager.ts
4
4
  function useRunManager(config) {
5
5
  const [isRunning, setIsRunning] = useState(false);
@@ -8,7 +8,7 @@ import { useConvertedState } from "./useConvertedState.js";
8
8
  import { useAui, useAuiState } from "@assistant-ui/store";
9
9
  import { InMemoryThreadListAdapter, createRequestHeaders } from "@assistant-ui/core";
10
10
  import { asAsyncIterableStream } from "assistant-stream/utils";
11
- import { useMemo, useRef, useState } from "react";
11
+ import { useMemo, useRef, useState } from "@assistant-ui/tap/react-shim";
12
12
  import { AssistantMessageAccumulator, AssistantTransportDecoder, DataStreamDecoder, toToolsJSONSchema, unstable_createInitialMessage } from "assistant-stream";
13
13
  //#region src/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.ts
14
14
  const convertAppendMessageToCommand = (message) => {
@@ -1 +1 @@
1
- {"version":3,"file":"useAssistantTransportRuntime.js","names":["createInitialMessage"],"sources":["../../../../src/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.ts"],"sourcesContent":["\"use client\";\n\nimport type { AppendMessage } from \"@assistant-ui/core\";\nimport {\n type ReadonlyJSONObject,\n type ReadonlyJSONValue,\n asAsyncIterableStream,\n} from \"assistant-stream/utils\";\nimport { useExternalStoreRuntime } from \"../external-store/useExternalStoreRuntime\";\nimport type { AssistantRuntime } from \"../../runtime/AssistantRuntime\";\nimport type { AddToolResultOptions } from \"@assistant-ui/core\";\nimport { useMemo, useRef, useState } from \"react\";\nimport {\n AssistantMessageAccumulator,\n DataStreamDecoder,\n AssistantTransportDecoder,\n unstable_createInitialMessage as createInitialMessage,\n toToolsJSONSchema,\n} from \"assistant-stream\";\nimport type {\n AssistantTransportOptions,\n AddMessageCommand,\n AddToolResultCommand,\n UserMessagePart,\n QueuedCommand,\n AssistantTransportCommand,\n SendCommandsRequestBody,\n} from \"./types\";\nimport { useCommandQueue } from \"./commandQueue\";\nimport {\n createReplayBoundaryStream,\n useReplayRenderWait,\n} from \"./replayBoundaryStream\";\nimport { useRunManager } from \"./runManager\";\nimport { useConvertedState } from \"./useConvertedState\";\nimport type { ToolExecutionStatus } from \"@assistant-ui/core\";\nimport { createRequestHeaders } from \"@assistant-ui/core\";\nimport { useRemoteThreadListRuntime } from \"../remote-thread-list/useRemoteThreadListRuntime\";\nimport { InMemoryThreadListAdapter } from \"@assistant-ui/core\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\nimport type { UserExternalState } from \"../../../augmentations\";\n\nconst convertAppendMessageToCommand = (\n message: AppendMessage,\n): AddMessageCommand => {\n if (message.role !== \"user\")\n throw new Error(\"Only user messages are supported\");\n\n const parts: UserMessagePart[] = [];\n const content = [\n ...message.content,\n ...(message.attachments?.flatMap((a) => a.content) ?? []),\n ];\n for (const contentPart of content) {\n if (contentPart.type === \"text\") {\n parts.push({ type: \"text\", text: contentPart.text });\n } else if (contentPart.type === \"image\") {\n parts.push({ type: \"image\", image: contentPart.image });\n }\n }\n\n return {\n type: \"add-message\",\n message: {\n role: \"user\",\n parts,\n },\n parentId: message.parentId,\n sourceId: message.sourceId,\n };\n};\n\nconst symbolAssistantTransportExtras = Symbol(\"assistant-transport-extras\");\ntype AssistantTransportExtras = {\n [symbolAssistantTransportExtras]: true;\n sendCommand: (command: AssistantTransportCommand) => void;\n state: UserExternalState;\n};\n\nconst asAssistantTransportExtras = (\n extras: unknown,\n): AssistantTransportExtras => {\n if (\n typeof extras !== \"object\" ||\n extras == null ||\n !(symbolAssistantTransportExtras in extras)\n )\n throw new Error(\n \"This method can only be called when you are using useAssistantTransportRuntime\",\n );\n\n return extras as AssistantTransportExtras;\n};\n\nexport const useAssistantTransportSendCommand = () => {\n const aui = useAui();\n\n return (command: AssistantTransportCommand) => {\n const extras = aui.thread().getState().extras;\n const transportExtras = asAssistantTransportExtras(extras);\n transportExtras.sendCommand(command);\n };\n};\n\nexport function useAssistantTransportState(): UserExternalState;\nexport function useAssistantTransportState<T>(\n selector: (state: UserExternalState) => T,\n): T;\nexport function useAssistantTransportState<T>(\n selector: (state: UserExternalState) => T = (t) => t as T,\n): T | UserExternalState {\n return useAuiState((s) =>\n selector(asAssistantTransportExtras(s.thread.extras).state),\n );\n}\n\nconst useAssistantTransportThreadRuntime = <T>(\n options: AssistantTransportOptions<T>,\n): AssistantRuntime => {\n const agentStateRef = useRef(options.initialState);\n const [, rerender] = useState(0);\n const resumeFlagRef = useRef(false);\n const [isReplaying, setIsReplaying] = useState(false);\n const waitForReplayRender = useReplayRenderWait();\n const parentIdRef = useRef<string | null | undefined>(undefined);\n const commandQueue = useCommandQueue({\n onQueue: () => runManager.schedule(),\n });\n\n const threadId = useAuiState((s) => s.threadListItem.remoteId);\n\n const runManager = useRunManager({\n onRun: async (signal: AbortSignal) => {\n const isResume = resumeFlagRef.current;\n resumeFlagRef.current = false;\n setIsReplaying(false);\n const commands: QueuedCommand[] = isResume ? [] : commandQueue.flush();\n if (commands.length === 0 && !isResume)\n throw new Error(\"No commands to send\");\n\n const headers = await createRequestHeaders(options.headers);\n const bodyValue =\n typeof options.body === \"function\"\n ? await options.body()\n : options.body;\n const context = runtime.thread.getModelContext();\n\n let requestBody: Record<string, unknown> = {\n commands,\n state: agentStateRef.current,\n system: context.system,\n tools: context.tools ? toToolsJSONSchema(context.tools) : undefined,\n threadId,\n ...(parentIdRef.current !== undefined && {\n parentId: parentIdRef.current,\n }),\n // nested (new format, aligned with AssistantChatTransport)\n callSettings: context.callSettings,\n config: context.config,\n // @deprecated spread at top level — use nested `callSettings`/`config` instead. Will be removed in a future version.\n ...context.callSettings,\n ...context.config,\n ...(bodyValue ?? {}),\n };\n\n if (options.prepareSendCommandsRequest) {\n requestBody = await options.prepareSendCommandsRequest(\n requestBody as SendCommandsRequestBody,\n );\n }\n\n const response = await fetch(\n isResume ? options.resumeApi! : options.api,\n {\n method: \"POST\",\n headers,\n body: JSON.stringify(requestBody),\n signal,\n },\n );\n\n options.onResponse?.(response);\n\n if (!response.ok) {\n throw new Error(`Status ${response.status}: ${await response.text()}`);\n }\n\n if (!response.body) {\n throw new Error(\"Response body is null\");\n }\n\n const body = await createReplayBoundaryStream(response, {\n setReplaying: setIsReplaying,\n waitForRender: waitForReplayRender,\n });\n\n // Select decoder based on protocol option\n const protocol = options.protocol ?? \"data-stream\";\n const decoder =\n protocol === \"assistant-transport\"\n ? new AssistantTransportDecoder()\n : new DataStreamDecoder();\n\n let err: string | undefined;\n const stream = body.pipeThrough(decoder).pipeThrough(\n new AssistantMessageAccumulator({\n initialMessage: createInitialMessage({\n unstable_state:\n (agentStateRef.current as ReadonlyJSONValue) ?? null,\n }),\n throttle: isResume,\n onError: (error) => {\n err = error;\n },\n }),\n );\n\n let markedDelivered = false;\n\n for await (const chunk of asAsyncIterableStream(stream)) {\n if (chunk.metadata.unstable_state === agentStateRef.current) continue;\n\n if (!markedDelivered) {\n commandQueue.markDelivered();\n markedDelivered = true;\n }\n\n agentStateRef.current = chunk.metadata.unstable_state as T;\n rerender((prev) => prev + 1);\n }\n\n if (err) {\n throw new Error(err);\n }\n },\n onFinish: options.onFinish,\n onCancel: () => {\n setIsReplaying(false);\n const cmds = [\n ...commandQueue.state.inTransit,\n ...commandQueue.state.queued,\n ];\n\n commandQueue.reset();\n\n options.onCancel?.({\n commands: cmds,\n updateState: (updater) => {\n agentStateRef.current = updater(agentStateRef.current);\n rerender((prev) => prev + 1);\n },\n });\n },\n onError: async (error) => {\n setIsReplaying(false);\n const inTransitCmds = [...commandQueue.state.inTransit];\n const queuedCmds = [...commandQueue.state.queued];\n\n commandQueue.reset();\n\n try {\n await options.onError?.(error as Error, {\n commands: inTransitCmds,\n updateState: (updater) => {\n agentStateRef.current = updater(agentStateRef.current);\n rerender((prev) => prev + 1);\n },\n });\n } finally {\n options.onCancel?.({\n commands: queuedCmds,\n updateState: (updater) => {\n agentStateRef.current = updater(agentStateRef.current);\n rerender((prev) => prev + 1);\n },\n error: error as Error,\n });\n }\n },\n });\n\n // Tool execution status state\n const [toolStatuses, setToolStatuses] = useState<\n Record<string, ToolExecutionStatus>\n >({});\n\n // Reactive conversion of agent state + connection metadata → UI state\n const pendingCommands = useMemo(\n () => [...commandQueue.state.inTransit, ...commandQueue.state.queued],\n [commandQueue.state],\n );\n const converted = useConvertedState(\n options.converter,\n agentStateRef.current,\n pendingCommands,\n runManager.isRunning,\n toolStatuses,\n );\n\n // Create runtime\n const runtime = useExternalStoreRuntime({\n messages: converted.messages,\n state: converted.state,\n isRunning: converted.isRunning,\n isLoading: isReplaying,\n adapters: options.adapters,\n unstable_enableToolInvocations: true,\n setToolStatuses,\n extras: {\n [symbolAssistantTransportExtras]: true,\n sendCommand: (command: AssistantTransportCommand) => {\n commandQueue.enqueue(command);\n },\n state: agentStateRef.current as UserExternalState,\n } satisfies AssistantTransportExtras,\n onNew: async (message: AppendMessage): Promise<void> => {\n parentIdRef.current = message.parentId;\n const command = convertAppendMessageToCommand(message);\n commandQueue.enqueue(command);\n },\n ...(options.capabilities?.edit && {\n onEdit: async (message: AppendMessage): Promise<void> => {\n parentIdRef.current = message.parentId;\n const command = convertAppendMessageToCommand(message);\n commandQueue.enqueue(command);\n },\n }),\n onCancel: async () => {\n runManager.cancel();\n },\n onResume: async () => {\n if (!options.resumeApi)\n throw new Error(\"Must pass resumeApi to options to resume runs\");\n\n resumeFlagRef.current = true;\n runManager.schedule();\n },\n onAddToolResult: async (\n toolOptions: AddToolResultOptions,\n ): Promise<void> => {\n const command: AddToolResultCommand = {\n type: \"add-tool-result\",\n toolCallId: toolOptions.toolCallId,\n result: toolOptions.result as ReadonlyJSONObject,\n toolName: toolOptions.toolName,\n isError: toolOptions.isError,\n ...(toolOptions.artifact && { artifact: toolOptions.artifact }),\n ...(toolOptions.modelContent !== undefined && {\n modelContent: toolOptions.modelContent,\n }),\n };\n\n commandQueue.enqueue(command);\n },\n onLoadExternalState: async (state) => {\n agentStateRef.current = state as T;\n rerender((prev) => prev + 1);\n },\n });\n\n return runtime;\n};\n\n/**\n * @alpha This is an experimental API that is subject to change.\n */\nexport const useAssistantTransportRuntime = <T>(\n options: AssistantTransportOptions<T>,\n): AssistantRuntime => {\n const runtime = useRemoteThreadListRuntime({\n runtimeHook: function RuntimeHook() {\n return useAssistantTransportThreadRuntime(options);\n },\n adapter: new InMemoryThreadListAdapter(),\n allowNesting: true,\n });\n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AC5C,cAAc,YAAY,aAC5B;GACF;GAEA,aAAa,QAAQ,OAAO;EAC9B;EACA,qBAAqB,OAAO,UAAU;GACpC,cAAc,UAAU;GACxB,UAAU,SAAS,OAAO,CAAC;EAC7B;CACF,CAAC;CAED,OAAO;AACT;;;;AAKA,MAAa,gCACX,YACqB;CAQrB,OAPgB,2BAA2B;EACzC,aAAa,SAAS,cAAc;GAClC,OAAO,mCAAmC,OAAO;EACnD;EACA,SAAS,IAAI,0BAA0B;EACvC,cAAc;CAChB,CACa;AACf"}
1
+ {"version":3,"file":"useAssistantTransportRuntime.js","names":["createInitialMessage"],"sources":["../../../../src/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.ts"],"sourcesContent":["\"use client\";\n\nimport type { AppendMessage } from \"@assistant-ui/core\";\nimport {\n type ReadonlyJSONObject,\n type ReadonlyJSONValue,\n asAsyncIterableStream,\n} from \"assistant-stream/utils\";\nimport { useExternalStoreRuntime } from \"../external-store/useExternalStoreRuntime\";\nimport type { AssistantRuntime } from \"../../runtime/AssistantRuntime\";\nimport type { AddToolResultOptions } from \"@assistant-ui/core\";\nimport { useMemo, useRef, useState } from \"react\";\nimport {\n AssistantMessageAccumulator,\n DataStreamDecoder,\n AssistantTransportDecoder,\n unstable_createInitialMessage as createInitialMessage,\n toToolsJSONSchema,\n} from \"assistant-stream\";\nimport type {\n AssistantTransportOptions,\n AddMessageCommand,\n AddToolResultCommand,\n UserMessagePart,\n QueuedCommand,\n AssistantTransportCommand,\n SendCommandsRequestBody,\n} from \"./types\";\nimport { useCommandQueue } from \"./commandQueue\";\nimport {\n createReplayBoundaryStream,\n useReplayRenderWait,\n} from \"./replayBoundaryStream\";\nimport { useRunManager } from \"./runManager\";\nimport { useConvertedState } from \"./useConvertedState\";\nimport type { ToolExecutionStatus } from \"@assistant-ui/core\";\nimport { createRequestHeaders } from \"@assistant-ui/core\";\nimport { useRemoteThreadListRuntime } from \"../remote-thread-list/useRemoteThreadListRuntime\";\nimport { InMemoryThreadListAdapter } from \"@assistant-ui/core\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\nimport type { UserExternalState } from \"../../../augmentations\";\n\nconst convertAppendMessageToCommand = (\n message: AppendMessage,\n): AddMessageCommand => {\n if (message.role !== \"user\")\n throw new Error(\"Only user messages are supported\");\n\n const parts: UserMessagePart[] = [];\n const content = [\n ...message.content,\n ...(message.attachments?.flatMap((a) => a.content) ?? []),\n ];\n for (const contentPart of content) {\n if (contentPart.type === \"text\") {\n parts.push({ type: \"text\", text: contentPart.text });\n } else if (contentPart.type === \"image\") {\n parts.push({ type: \"image\", image: contentPart.image });\n }\n }\n\n return {\n type: \"add-message\",\n message: {\n role: \"user\",\n parts,\n },\n parentId: message.parentId,\n sourceId: message.sourceId,\n };\n};\n\nconst symbolAssistantTransportExtras = Symbol(\"assistant-transport-extras\");\ntype AssistantTransportExtras = {\n [symbolAssistantTransportExtras]: true;\n sendCommand: (command: AssistantTransportCommand) => void;\n state: UserExternalState;\n};\n\nconst asAssistantTransportExtras = (\n extras: unknown,\n): AssistantTransportExtras => {\n if (\n typeof extras !== \"object\" ||\n extras == null ||\n !(symbolAssistantTransportExtras in extras)\n )\n throw new Error(\n \"This method can only be called when you are using useAssistantTransportRuntime\",\n );\n\n return extras as AssistantTransportExtras;\n};\n\nexport const useAssistantTransportSendCommand = () => {\n const aui = useAui();\n\n return (command: AssistantTransportCommand) => {\n const extras = aui.thread().getState().extras;\n const transportExtras = asAssistantTransportExtras(extras);\n transportExtras.sendCommand(command);\n };\n};\n\nexport function useAssistantTransportState(): UserExternalState;\nexport function useAssistantTransportState<T>(\n selector: (state: UserExternalState) => T,\n): T;\nexport function useAssistantTransportState<T>(\n selector: (state: UserExternalState) => T = (t) => t as T,\n): T | UserExternalState {\n return useAuiState((s) =>\n selector(asAssistantTransportExtras(s.thread.extras).state),\n );\n}\n\nconst useAssistantTransportThreadRuntime = <T>(\n options: AssistantTransportOptions<T>,\n): AssistantRuntime => {\n const agentStateRef = useRef(options.initialState);\n const [, rerender] = useState(0);\n const resumeFlagRef = useRef(false);\n const [isReplaying, setIsReplaying] = useState(false);\n const waitForReplayRender = useReplayRenderWait();\n const parentIdRef = useRef<string | null | undefined>(undefined);\n const commandQueue = useCommandQueue({\n onQueue: () => runManager.schedule(),\n });\n\n const threadId = useAuiState((s) => s.threadListItem.remoteId);\n\n const runManager = useRunManager({\n onRun: async (signal: AbortSignal) => {\n const isResume = resumeFlagRef.current;\n resumeFlagRef.current = false;\n setIsReplaying(false);\n const commands: QueuedCommand[] = isResume ? [] : commandQueue.flush();\n if (commands.length === 0 && !isResume)\n throw new Error(\"No commands to send\");\n\n const headers = await createRequestHeaders(options.headers);\n const bodyValue =\n typeof options.body === \"function\"\n ? await options.body()\n : options.body;\n const context = runtime.thread.getModelContext();\n\n let requestBody: Record<string, unknown> = {\n commands,\n state: agentStateRef.current,\n system: context.system,\n tools: context.tools ? toToolsJSONSchema(context.tools) : undefined,\n threadId,\n ...(parentIdRef.current !== undefined && {\n parentId: parentIdRef.current,\n }),\n // nested (new format, aligned with AssistantChatTransport)\n callSettings: context.callSettings,\n config: context.config,\n // @deprecated spread at top level — use nested `callSettings`/`config` instead. Will be removed in a future version.\n ...context.callSettings,\n ...context.config,\n ...(bodyValue ?? {}),\n };\n\n if (options.prepareSendCommandsRequest) {\n requestBody = await options.prepareSendCommandsRequest(\n requestBody as SendCommandsRequestBody,\n );\n }\n\n const response = await fetch(\n isResume ? options.resumeApi! : options.api,\n {\n method: \"POST\",\n headers,\n body: JSON.stringify(requestBody),\n signal,\n },\n );\n\n options.onResponse?.(response);\n\n if (!response.ok) {\n throw new Error(`Status ${response.status}: ${await response.text()}`);\n }\n\n if (!response.body) {\n throw new Error(\"Response body is null\");\n }\n\n const body = await createReplayBoundaryStream(response, {\n setReplaying: setIsReplaying,\n waitForRender: waitForReplayRender,\n });\n\n // Select decoder based on protocol option\n const protocol = options.protocol ?? \"data-stream\";\n const decoder =\n protocol === \"assistant-transport\"\n ? new AssistantTransportDecoder()\n : new DataStreamDecoder();\n\n let err: string | undefined;\n const stream = body.pipeThrough(decoder).pipeThrough(\n new AssistantMessageAccumulator({\n initialMessage: createInitialMessage({\n unstable_state:\n (agentStateRef.current as ReadonlyJSONValue) ?? null,\n }),\n throttle: isResume,\n onError: (error) => {\n err = error;\n },\n }),\n );\n\n let markedDelivered = false;\n\n for await (const chunk of asAsyncIterableStream(stream)) {\n if (chunk.metadata.unstable_state === agentStateRef.current) continue;\n\n if (!markedDelivered) {\n commandQueue.markDelivered();\n markedDelivered = true;\n }\n\n agentStateRef.current = chunk.metadata.unstable_state as T;\n rerender((prev) => prev + 1);\n }\n\n if (err) {\n throw new Error(err);\n }\n },\n onFinish: options.onFinish,\n onCancel: () => {\n setIsReplaying(false);\n const cmds = [\n ...commandQueue.state.inTransit,\n ...commandQueue.state.queued,\n ];\n\n commandQueue.reset();\n\n options.onCancel?.({\n commands: cmds,\n updateState: (updater) => {\n agentStateRef.current = updater(agentStateRef.current);\n rerender((prev) => prev + 1);\n },\n });\n },\n onError: async (error) => {\n setIsReplaying(false);\n const inTransitCmds = [...commandQueue.state.inTransit];\n const queuedCmds = [...commandQueue.state.queued];\n\n commandQueue.reset();\n\n try {\n await options.onError?.(error as Error, {\n commands: inTransitCmds,\n updateState: (updater) => {\n agentStateRef.current = updater(agentStateRef.current);\n rerender((prev) => prev + 1);\n },\n });\n } finally {\n options.onCancel?.({\n commands: queuedCmds,\n updateState: (updater) => {\n agentStateRef.current = updater(agentStateRef.current);\n rerender((prev) => prev + 1);\n },\n error: error as Error,\n });\n }\n },\n });\n\n // Tool execution status state\n const [toolStatuses, setToolStatuses] = useState<\n Record<string, ToolExecutionStatus>\n >({});\n\n // Reactive conversion of agent state + connection metadata → UI state\n const pendingCommands = useMemo(\n () => [...commandQueue.state.inTransit, ...commandQueue.state.queued],\n [commandQueue.state],\n );\n const converted = useConvertedState(\n options.converter,\n agentStateRef.current,\n pendingCommands,\n runManager.isRunning,\n toolStatuses,\n );\n\n // Create runtime\n const runtime = useExternalStoreRuntime({\n messages: converted.messages,\n state: converted.state,\n isRunning: converted.isRunning,\n isLoading: isReplaying,\n adapters: options.adapters,\n unstable_enableToolInvocations: true,\n setToolStatuses,\n extras: {\n [symbolAssistantTransportExtras]: true,\n sendCommand: (command: AssistantTransportCommand) => {\n commandQueue.enqueue(command);\n },\n state: agentStateRef.current as UserExternalState,\n } satisfies AssistantTransportExtras,\n onNew: async (message: AppendMessage): Promise<void> => {\n parentIdRef.current = message.parentId;\n const command = convertAppendMessageToCommand(message);\n commandQueue.enqueue(command);\n },\n ...(options.capabilities?.edit && {\n onEdit: async (message: AppendMessage): Promise<void> => {\n parentIdRef.current = message.parentId;\n const command = convertAppendMessageToCommand(message);\n commandQueue.enqueue(command);\n },\n }),\n onCancel: async () => {\n runManager.cancel();\n },\n onResume: async () => {\n if (!options.resumeApi)\n throw new Error(\"Must pass resumeApi to options to resume runs\");\n\n resumeFlagRef.current = true;\n runManager.schedule();\n },\n onAddToolResult: async (\n toolOptions: AddToolResultOptions,\n ): Promise<void> => {\n const command: AddToolResultCommand = {\n type: \"add-tool-result\",\n toolCallId: toolOptions.toolCallId,\n result: toolOptions.result as ReadonlyJSONObject,\n toolName: toolOptions.toolName,\n isError: toolOptions.isError,\n ...(toolOptions.artifact && { artifact: toolOptions.artifact }),\n ...(toolOptions.modelContent !== undefined && {\n modelContent: toolOptions.modelContent,\n }),\n };\n\n commandQueue.enqueue(command);\n },\n onLoadExternalState: async (state) => {\n agentStateRef.current = state as T;\n rerender((prev) => prev + 1);\n },\n });\n\n return runtime;\n};\n\n/**\n * @alpha This is an experimental API that is subject to change.\n */\nexport const useAssistantTransportRuntime = <T>(\n options: AssistantTransportOptions<T>,\n): AssistantRuntime => {\n const runtime = useRemoteThreadListRuntime({\n runtimeHook: function RuntimeHook() {\n return useAssistantTransportThreadRuntime(options);\n },\n adapter: new InMemoryThreadListAdapter(),\n allowNesting: true,\n });\n return runtime;\n};\n"],"mappings":";;;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AAa,EAC5C,cAAc,YAAY,aAC5B;GACF;GAEA,aAAa,QAAQ,OAAO;EAC9B;EACA,qBAAqB,OAAO,UAAU;GACpC,cAAc,UAAU;GACxB,UAAU,SAAS,OAAO,CAAC;EAC7B;CACF,CAAC;CAED,OAAO;AACT;;;;AAKA,MAAa,gCACX,YACqB;CAQrB,OAPgB,2BAA2B;EACzC,aAAa,SAAS,cAAc;GAClC,OAAO,mCAAmC,OAAO;EACnD;EACA,SAAS,IAAI,0BAA0B;EACvC,cAAc;CAChB,CACa;AACf"}
@@ -1,4 +1,4 @@
1
- import { useMemo } from "react";
1
+ import { useMemo } from "@assistant-ui/tap/react-shim";
2
2
  //#region src/legacy-runtime/runtime-cores/assistant-transport/useConvertedState.ts
3
3
  function useConvertedState(converter, agentState, pendingCommands, isSending, toolStatuses) {
4
4
  return useMemo(() => converter(agentState, {
@@ -1,4 +1,4 @@
1
- import { useEffect, useRef } from "react";
1
+ import { useEffect, useRef } from "@assistant-ui/tap/react-shim";
2
2
  //#region src/legacy-runtime/runtime-cores/assistant-transport/useLatestRef.ts
3
3
  function useLatestRef(value) {
4
4
  const ref = useRef(value);
@@ -1 +1 @@
1
- {"version":3,"file":"McpAppRenderer.d.ts","names":[],"sources":["../../src/mcp-apps/McpAppRenderer.tsx"],"mappings":";;;;;;KAkCY,qBAAA;;AAAZ;;;;EAME,IAAA,EAAM,eAAA,CAAgB,WAAA,GAEZ;EAAV,OAAA,GAAU,mBAAA;EASI;;;;EAJd,SAAA,WAU+C;EAR/C,QAAA,GAAW,cAAA,EAQ6C;EANxD,WAAA,GAAc,iBAAA,EAXR;EAaN,QAAA,GAAW,SAAA,EAXX;EAaA,eAAA,GAAkB,SAAA,EARlB;EAUA,aAAA,GAAgB,SAAA,KAAc,KAAA,EAAO,KAAA,KAAU,SAAA;AAAA;;;;;;;;;cAiJpC,cAAA,GAAc,KAAA,EAAA,qBAAA,KAAA,eAAA;EAAA,iBAGH,4BAAA;AAAA"}
1
+ {"version":3,"file":"McpAppRenderer.d.ts","names":[],"sources":["../../src/mcp-apps/McpAppRenderer.tsx"],"mappings":";;;;;;KA6BY,qBAAA;;AAAZ;;;;EAME,IAAA,EAAM,eAAA,CAAgB,WAAA,GAEZ;EAAV,OAAA,GAAU,mBAAA;EASI;;;;EAJd,SAAA,WAU+C;EAR/C,QAAA,GAAW,cAAA,EAQ6C;EANxD,WAAA,GAAc,iBAAA,EAXR;EAaN,QAAA,GAAW,SAAA,EAXX;EAaA,eAAA,GAAkB,SAAA,EARlB;EAUA,aAAA,GAAgB,SAAA,KAAc,KAAA,EAAO,KAAA,KAAU,SAAA;AAAA;;;;;;;;;cAiJpC,cAAA,GAAc,KAAA,EAAA,qBAAA,KAAA,eAAA;EAAA,iBAEL,4BAAA;AAAA"}
@@ -2,9 +2,9 @@
2
2
  import { McpAppFrame } from "./app-frame.js";
3
3
  import { getMcpAppFromToolPart } from "./utils.js";
4
4
  import { useAui } from "@assistant-ui/store";
5
- import { useEffect, useMemo, useRef, useState } from "react";
5
+ import { useEffect, useMemo, useRef, useState } from "@assistant-ui/tap/react-shim";
6
6
  import { Fragment, jsx } from "react/jsx-runtime";
7
- import { resource, tapConst, tapRef, tapResource } from "@assistant-ui/tap";
7
+ import { resource, useResource } from "@assistant-ui/tap";
8
8
  //#region src/mcp-apps/McpAppRenderer.tsx
9
9
  function getInput(part) {
10
10
  if (part.status.type === "running" && (part.argsText === "" || part.argsText === "{}")) return;
@@ -99,13 +99,13 @@ function InlineRenderer({ part, internalsRef, optionsRef }) {
99
99
  * renderer loads that resource from the configured host and displays it in a
100
100
  * sandboxed frame.
101
101
  */
102
- const McpAppRenderer = resource((options) => {
103
- const host = tapResource(options.host);
104
- const optionsRef = tapRef(options);
102
+ const McpAppRenderer = resource(function McpAppRenderer(options) {
103
+ const host = useResource(options.host);
104
+ const optionsRef = useRef(options);
105
105
  optionsRef.current = options;
106
- const internalsRef = tapRef({ host });
106
+ const internalsRef = useRef({ host });
107
107
  internalsRef.current = { host };
108
- return { render: tapConst(() => {
108
+ return { render: useMemo(() => {
109
109
  const Render = (props) => /* @__PURE__ */ jsx(InlineRenderer, {
110
110
  part: props,
111
111
  internalsRef,