@athenaintel/react 0.42.2 → 0.48.0

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 (685) hide show
  1. package/README.md +225 -3
  2. package/dist/agent-runtime/src/answer-label.cjs +137 -0
  3. package/dist/agent-runtime/src/answer-label.cjs.map +1 -0
  4. package/dist/agent-runtime/src/answer-label.d.ts +104 -0
  5. package/dist/agent-runtime/src/answer-label.js +137 -0
  6. package/dist/agent-runtime/src/answer-label.js.map +1 -0
  7. package/dist/agent-runtime/src/answer-rows.cjs +180 -0
  8. package/dist/agent-runtime/src/answer-rows.cjs.map +1 -0
  9. package/dist/agent-runtime/src/answer-rows.d.ts +86 -0
  10. package/dist/agent-runtime/src/answer-rows.js +180 -0
  11. package/dist/agent-runtime/src/answer-rows.js.map +1 -0
  12. package/dist/agent-runtime/src/client-tool-bridge.cjs +15 -15
  13. package/dist/agent-runtime/src/client-tool-bridge.cjs.map +1 -1
  14. package/dist/agent-runtime/src/conversation-index.cjs +8 -8
  15. package/dist/agent-runtime/src/conversation-index.cjs.map +1 -1
  16. package/dist/agent-runtime/src/conversation-list-groups.d.ts +74 -0
  17. package/dist/agent-runtime/src/decision-checks.cjs +207 -0
  18. package/dist/agent-runtime/src/decision-checks.cjs.map +1 -0
  19. package/dist/agent-runtime/src/decision-checks.d.ts +142 -0
  20. package/dist/agent-runtime/src/decision-checks.js +207 -0
  21. package/dist/agent-runtime/src/decision-checks.js.map +1 -0
  22. package/dist/agent-runtime/src/desktop-handoff.d.ts +12 -0
  23. package/dist/agent-runtime/src/errors.cjs +18 -0
  24. package/dist/agent-runtime/src/errors.cjs.map +1 -1
  25. package/dist/agent-runtime/src/errors.d.ts +7 -0
  26. package/dist/agent-runtime/src/errors.js +18 -0
  27. package/dist/agent-runtime/src/errors.js.map +1 -1
  28. package/dist/agent-runtime/src/generated/runconfig-contract.cjs +12 -0
  29. package/dist/agent-runtime/src/generated/runconfig-contract.cjs.map +1 -1
  30. package/dist/agent-runtime/src/generated/runconfig-contract.d.ts +6 -6
  31. package/dist/agent-runtime/src/generated/runconfig-contract.js +12 -0
  32. package/dist/agent-runtime/src/generated/runconfig-contract.js.map +1 -1
  33. package/dist/agent-runtime/src/handoff-arrival.cjs +60 -0
  34. package/dist/agent-runtime/src/handoff-arrival.cjs.map +1 -0
  35. package/dist/agent-runtime/src/handoff-arrival.d.ts +46 -0
  36. package/dist/agent-runtime/src/handoff-arrival.js +60 -0
  37. package/dist/agent-runtime/src/handoff-arrival.js.map +1 -0
  38. package/dist/agent-runtime/src/index.d.ts +15 -8
  39. package/dist/agent-runtime/src/interrupts.cjs +43 -18
  40. package/dist/agent-runtime/src/interrupts.cjs.map +1 -1
  41. package/dist/agent-runtime/src/interrupts.d.ts +19 -2
  42. package/dist/agent-runtime/src/interrupts.js +28 -3
  43. package/dist/agent-runtime/src/interrupts.js.map +1 -1
  44. package/dist/agent-runtime/src/lane-history.cjs +8 -8
  45. package/dist/agent-runtime/src/lane-history.cjs.map +1 -1
  46. package/dist/agent-runtime/src/messages.cjs +43 -8
  47. package/dist/agent-runtime/src/messages.cjs.map +1 -1
  48. package/dist/agent-runtime/src/messages.d.ts +25 -3
  49. package/dist/agent-runtime/src/messages.js +43 -8
  50. package/dist/agent-runtime/src/messages.js.map +1 -1
  51. package/dist/agent-runtime/src/offline-status.cjs +36 -0
  52. package/dist/agent-runtime/src/offline-status.cjs.map +1 -0
  53. package/dist/agent-runtime/src/offline-status.d.ts +118 -3
  54. package/dist/agent-runtime/src/offline-status.js +36 -0
  55. package/dist/agent-runtime/src/offline-status.js.map +1 -0
  56. package/dist/agent-runtime/src/queue.cjs +0 -9
  57. package/dist/agent-runtime/src/queue.cjs.map +1 -1
  58. package/dist/agent-runtime/src/queue.js +0 -9
  59. package/dist/agent-runtime/src/queue.js.map +1 -1
  60. package/dist/agent-runtime/src/quota-safe-local-storage-session.cjs +9 -9
  61. package/dist/agent-runtime/src/quota-safe-local-storage-session.cjs.map +1 -1
  62. package/dist/agent-runtime/src/runtime-catalog.cjs +42 -0
  63. package/dist/agent-runtime/src/runtime-catalog.cjs.map +1 -0
  64. package/dist/agent-runtime/src/runtime-catalog.d.ts +35 -0
  65. package/dist/agent-runtime/src/runtime-catalog.js +42 -0
  66. package/dist/agent-runtime/src/runtime-catalog.js.map +1 -0
  67. package/dist/agent-runtime/src/runtime-messages.cjs.map +1 -1
  68. package/dist/agent-runtime/src/runtime-messages.d.ts +1 -1
  69. package/dist/agent-runtime/src/runtime-messages.js.map +1 -1
  70. package/dist/agent-runtime/src/runtime.d.ts +40 -0
  71. package/dist/agent-runtime/src/statewire-suspended.cjs +3 -3
  72. package/dist/agent-runtime/src/statewire-suspended.cjs.map +1 -1
  73. package/dist/agent-runtime/src/subagents.cjs +32 -2
  74. package/dist/agent-runtime/src/subagents.cjs.map +1 -1
  75. package/dist/agent-runtime/src/subagents.d.ts +9 -0
  76. package/dist/agent-runtime/src/subagents.js +30 -0
  77. package/dist/agent-runtime/src/subagents.js.map +1 -1
  78. package/dist/agent-runtime/src/thread-driver.cjs +67 -0
  79. package/dist/agent-runtime/src/thread-driver.cjs.map +1 -0
  80. package/dist/agent-runtime/src/thread-driver.d.ts +49 -0
  81. package/dist/agent-runtime/src/thread-driver.js +67 -0
  82. package/dist/agent-runtime/src/thread-driver.js.map +1 -0
  83. package/dist/agent-runtime/src/thread-handoff-flow-machine.d.ts +172 -0
  84. package/dist/agent-runtime/src/thread-handoff-protocol.d.ts +756 -0
  85. package/dist/agent-runtime/src/thread-handoff-qr.d.ts +11 -0
  86. package/dist/agent-runtime/src/thread-handoff.d.ts +3 -364
  87. package/dist/agent-runtime/src/thread-status.cjs +3 -3
  88. package/dist/agent-runtime/src/thread-status.cjs.map +1 -1
  89. package/dist/agent-runtime/src/tool-metadata.cjs +210 -33
  90. package/dist/agent-runtime/src/tool-metadata.cjs.map +1 -1
  91. package/dist/agent-runtime/src/tool-metadata.d.ts +12 -0
  92. package/dist/agent-runtime/src/tool-metadata.js +210 -33
  93. package/dist/agent-runtime/src/tool-metadata.js.map +1 -1
  94. package/dist/agent-runtime/src/tool-names.cjs +2 -0
  95. package/dist/agent-runtime/src/tool-names.cjs.map +1 -1
  96. package/dist/agent-runtime/src/tool-names.d.ts +2 -0
  97. package/dist/agent-runtime/src/tool-names.js +2 -0
  98. package/dist/agent-runtime/src/tool-names.js.map +1 -1
  99. package/dist/agent-runtime/src/types.d.ts +10 -2
  100. package/dist/agent-runtime/src/use-conversation-list.cjs +11 -11
  101. package/dist/agent-runtime/src/use-conversation-list.cjs.map +1 -1
  102. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.cjs +24 -19
  103. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.cjs.map +1 -1
  104. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.d.ts +2 -1
  105. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.js +6 -1
  106. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.js.map +1 -1
  107. package/dist/agent-runtime/src/use-deep-agent-config.cjs +14 -14
  108. package/dist/agent-runtime/src/use-deep-agent-config.cjs.map +1 -1
  109. package/dist/agent-runtime/src/use-deep-agent-edit-submit.cjs +6 -6
  110. package/dist/agent-runtime/src/use-deep-agent-edit-submit.cjs.map +1 -1
  111. package/dist/agent-runtime/src/use-deep-agent-runtime.cjs +16 -16
  112. package/dist/agent-runtime/src/use-deep-agent-runtime.cjs.map +1 -1
  113. package/dist/agent-runtime/src/use-deep-agent-thread.cjs +45 -45
  114. package/dist/agent-runtime/src/use-deep-agent-thread.cjs.map +1 -1
  115. package/dist/agent-runtime/src/use-deep-agent-voice.cjs +572 -134
  116. package/dist/agent-runtime/src/use-deep-agent-voice.cjs.map +1 -1
  117. package/dist/agent-runtime/src/use-deep-agent-voice.d.ts +137 -10
  118. package/dist/agent-runtime/src/use-deep-agent-voice.js +514 -76
  119. package/dist/agent-runtime/src/use-deep-agent-voice.js.map +1 -1
  120. package/dist/agent-runtime/src/use-deep-agent-window-sync.cjs +26 -26
  121. package/dist/agent-runtime/src/use-deep-agent-window-sync.cjs.map +1 -1
  122. package/dist/agent-runtime/src/use-historical-edit-attachments.cjs +4 -4
  123. package/dist/agent-runtime/src/use-historical-edit-attachments.cjs.map +1 -1
  124. package/dist/agent-runtime/src/use-thread-handoff-flow.d.ts +28 -26
  125. package/dist/agent-runtime/src/voice-media.cjs +117 -0
  126. package/dist/agent-runtime/src/voice-media.cjs.map +1 -0
  127. package/dist/agent-runtime/src/voice-media.d.ts +49 -0
  128. package/dist/agent-runtime/src/voice-media.js +117 -0
  129. package/dist/agent-runtime/src/voice-media.js.map +1 -0
  130. package/dist/agent-runtime/src/voice-wire-types.d.ts +32 -0
  131. package/dist/assets/AssetPanel.cjs +11 -11
  132. package/dist/assets/AssetPanel.cjs.map +1 -1
  133. package/dist/assets/AthenaAssetEmbed.cjs +11 -9
  134. package/dist/assets/AthenaAssetEmbed.cjs.map +1 -1
  135. package/dist/assets/AthenaAssetEmbed.d.ts +7 -0
  136. package/dist/assets/AthenaAssetEmbed.js +4 -2
  137. package/dist/assets/AthenaAssetEmbed.js.map +1 -1
  138. package/dist/assets/AthenaLayout.cjs +16 -16
  139. package/dist/assets/AthenaLayout.cjs.map +1 -1
  140. package/dist/assets/use-asset-content.cjs +4 -4
  141. package/dist/assets/use-asset-content.cjs.map +1 -1
  142. package/dist/assets/use-asset-embed.cjs +14 -7
  143. package/dist/assets/use-asset-embed.cjs.map +1 -1
  144. package/dist/assets/use-asset-embed.d.ts +11 -1
  145. package/dist/assets/use-asset-embed.js +10 -3
  146. package/dist/assets/use-asset-embed.js.map +1 -1
  147. package/dist/auth/AthenaAuthContext.cjs +3 -3
  148. package/dist/auth/AthenaAuthContext.cjs.map +1 -1
  149. package/dist/auth/AthenaAuthProvider.cjs +8 -8
  150. package/dist/auth/AthenaAuthProvider.cjs.map +1 -1
  151. package/dist/auth/AthenaCredentialSourceContext.cjs +5 -5
  152. package/dist/auth/AthenaCredentialSourceContext.cjs.map +1 -1
  153. package/dist/auth/AthenaSSOProvider.cjs +14 -14
  154. package/dist/auth/AthenaSSOProvider.cjs.map +1 -1
  155. package/dist/auth/credential-source.cjs +26 -13
  156. package/dist/auth/credential-source.cjs.map +1 -1
  157. package/dist/auth/credential-source.d.ts +8 -0
  158. package/dist/auth/credential-source.js +26 -13
  159. package/dist/auth/credential-source.js.map +1 -1
  160. package/dist/catalog/agent-model-options.cjs +25 -17
  161. package/dist/catalog/agent-model-options.cjs.map +1 -1
  162. package/dist/catalog/agent-model-options.d.ts +38 -5
  163. package/dist/catalog/agent-model-options.js +25 -17
  164. package/dist/catalog/agent-model-options.js.map +1 -1
  165. package/dist/catalog/channel-refusal.cjs +36 -0
  166. package/dist/catalog/channel-refusal.cjs.map +1 -0
  167. package/dist/catalog/channel-refusal.d.ts +29 -0
  168. package/dist/catalog/channel-refusal.js +36 -0
  169. package/dist/catalog/channel-refusal.js.map +1 -0
  170. package/dist/catalog/chat-pickers.cjs +60 -24
  171. package/dist/catalog/chat-pickers.cjs.map +1 -1
  172. package/dist/catalog/chat-pickers.d.ts +12 -2
  173. package/dist/catalog/chat-pickers.js +56 -20
  174. package/dist/catalog/chat-pickers.js.map +1 -1
  175. package/dist/catalog/runtime-catalog.cjs +89 -23
  176. package/dist/catalog/runtime-catalog.cjs.map +1 -1
  177. package/dist/catalog/runtime-catalog.d.ts +8 -2
  178. package/dist/catalog/runtime-catalog.js +83 -17
  179. package/dist/catalog/runtime-catalog.js.map +1 -1
  180. package/dist/catalog/use-athena-chat-mode.cjs +12 -12
  181. package/dist/catalog/use-athena-chat-mode.cjs.map +1 -1
  182. package/dist/chat/AthenaChat.cjs +155 -67
  183. package/dist/chat/AthenaChat.cjs.map +1 -1
  184. package/dist/chat/AthenaChat.d.ts +42 -2
  185. package/dist/chat/AthenaChat.js +106 -18
  186. package/dist/chat/AthenaChat.js.map +1 -1
  187. package/dist/chat/AthenaChatErrorBoundary.cjs +3 -3
  188. package/dist/chat/AthenaChatErrorBoundary.cjs.map +1 -1
  189. package/dist/chat/DrivingOnChip.cjs +23 -0
  190. package/dist/chat/DrivingOnChip.cjs.map +1 -0
  191. package/dist/chat/DrivingOnChip.d.ts +17 -0
  192. package/dist/chat/DrivingOnChip.js +23 -0
  193. package/dist/chat/DrivingOnChip.js.map +1 -0
  194. package/dist/chat/StatewireApprovalCard.cjs +125 -31
  195. package/dist/chat/StatewireApprovalCard.cjs.map +1 -1
  196. package/dist/chat/StatewireApprovalCard.d.ts +73 -1
  197. package/dist/chat/StatewireApprovalCard.js +115 -21
  198. package/dist/chat/StatewireApprovalCard.js.map +1 -1
  199. package/dist/chat/StatewireClientToolBridge.cjs +2 -2
  200. package/dist/chat/StatewireClientToolBridge.cjs.map +1 -1
  201. package/dist/chat/StatewireQueuedMessages.cjs +25 -63
  202. package/dist/chat/StatewireQueuedMessages.cjs.map +1 -1
  203. package/dist/chat/StatewireQueuedMessages.d.ts +11 -13
  204. package/dist/chat/StatewireQueuedMessages.js +16 -54
  205. package/dist/chat/StatewireQueuedMessages.js.map +1 -1
  206. package/dist/chat/WaitingOnYouBanner.cjs +3 -3
  207. package/dist/chat/WaitingOnYouBanner.cjs.map +1 -1
  208. package/dist/chat/athena-chat-welcome.cjs +2 -2
  209. package/dist/chat/athena-chat-welcome.cjs.map +1 -1
  210. package/dist/chat/athena-citation-links.cjs +5 -5
  211. package/dist/chat/athena-citation-links.cjs.map +1 -1
  212. package/dist/chat/athena-composer-controls.cjs +26 -16
  213. package/dist/chat/athena-composer-controls.cjs.map +1 -1
  214. package/dist/chat/athena-composer-controls.d.ts +6 -0
  215. package/dist/chat/athena-composer-controls.js +26 -16
  216. package/dist/chat/athena-composer-controls.js.map +1 -1
  217. package/dist/chat/athena-turn-end-status.cjs +42 -0
  218. package/dist/chat/athena-turn-end-status.cjs.map +1 -0
  219. package/dist/chat/athena-turn-end-status.d.ts +24 -0
  220. package/dist/chat/athena-turn-end-status.js +42 -0
  221. package/dist/chat/athena-turn-end-status.js.map +1 -0
  222. package/dist/chat/browser-decision-check.cjs +131 -0
  223. package/dist/chat/browser-decision-check.cjs.map +1 -0
  224. package/dist/chat/browser-decision-check.d.ts +61 -0
  225. package/dist/chat/browser-decision-check.js +131 -0
  226. package/dist/chat/browser-decision-check.js.map +1 -0
  227. package/dist/chat/chat-outbox-rows.cjs +3 -3
  228. package/dist/chat/chat-outbox-rows.cjs.map +1 -1
  229. package/dist/chat/chat-voice-controls.cjs +93 -28
  230. package/dist/chat/chat-voice-controls.cjs.map +1 -1
  231. package/dist/chat/chat-voice-controls.d.ts +36 -2
  232. package/dist/chat/chat-voice-controls.js +89 -24
  233. package/dist/chat/chat-voice-controls.js.map +1 -1
  234. package/dist/chat/composer-keyboard-hint.cjs +5 -5
  235. package/dist/chat/composer-keyboard-hint.cjs.map +1 -1
  236. package/dist/chat/device-operation.cjs +29 -0
  237. package/dist/chat/device-operation.cjs.map +1 -0
  238. package/dist/chat/device-operation.d.ts +34 -0
  239. package/dist/chat/device-operation.js +29 -0
  240. package/dist/chat/device-operation.js.map +1 -0
  241. package/dist/chat/super-grouping/CollapsibleGroup.cjs +14 -14
  242. package/dist/chat/super-grouping/CollapsibleGroup.cjs.map +1 -1
  243. package/dist/chat/super-grouping/GroupedMessageParts.cjs +4 -4
  244. package/dist/chat/super-grouping/GroupedMessageParts.cjs.map +1 -1
  245. package/dist/chat/super-grouping/SuperGroupingCard.cjs +60 -38
  246. package/dist/chat/super-grouping/SuperGroupingCard.cjs.map +1 -1
  247. package/dist/chat/super-grouping/SuperGroupingCard.d.ts +24 -4
  248. package/dist/chat/super-grouping/SuperGroupingCard.js +37 -15
  249. package/dist/chat/super-grouping/SuperGroupingCard.js.map +1 -1
  250. package/dist/chat/super-grouping/SuperGroupingTranscript.cjs +32 -32
  251. package/dist/chat/super-grouping/SuperGroupingTranscript.cjs.map +1 -1
  252. package/dist/chat/super-grouping/SuperGroupingTranscript.js +3 -3
  253. package/dist/chat/super-grouping/SuperGroupingTranscript.js.map +1 -1
  254. package/dist/chat/super-grouping/ToolTimeline.cjs +97 -37
  255. package/dist/chat/super-grouping/ToolTimeline.cjs.map +1 -1
  256. package/dist/chat/super-grouping/ToolTimeline.d.ts +14 -2
  257. package/dist/chat/super-grouping/ToolTimeline.js +94 -34
  258. package/dist/chat/super-grouping/ToolTimeline.js.map +1 -1
  259. package/dist/chat/super-grouping/activity-timeline.cjs +47 -12
  260. package/dist/chat/super-grouping/activity-timeline.cjs.map +1 -1
  261. package/dist/chat/super-grouping/activity-timeline.d.ts +21 -0
  262. package/dist/chat/super-grouping/activity-timeline.js +47 -12
  263. package/dist/chat/super-grouping/activity-timeline.js.map +1 -1
  264. package/dist/chat/super-grouping/grouping-function.cjs +4 -0
  265. package/dist/chat/super-grouping/grouping-function.cjs.map +1 -1
  266. package/dist/chat/super-grouping/grouping-function.d.ts +7 -0
  267. package/dist/chat/super-grouping/grouping-function.js +5 -1
  268. package/dist/chat/super-grouping/grouping-function.js.map +1 -1
  269. package/dist/chat/super-grouping/index.cjs +6 -0
  270. package/dist/chat/super-grouping/index.cjs.map +1 -1
  271. package/dist/chat/super-grouping/index.d.ts +6 -2
  272. package/dist/chat/super-grouping/index.js +7 -1
  273. package/dist/chat/super-grouping/index.js.map +1 -1
  274. package/dist/chat/super-grouping/timeline-step.cjs +61 -2
  275. package/dist/chat/super-grouping/timeline-step.cjs.map +1 -1
  276. package/dist/chat/super-grouping/timeline-step.d.ts +13 -1
  277. package/dist/chat/super-grouping/timeline-step.js +61 -2
  278. package/dist/chat/super-grouping/timeline-step.js.map +1 -1
  279. package/dist/chat/super-grouping/tool-part-placement.cjs +17 -0
  280. package/dist/chat/super-grouping/tool-part-placement.cjs.map +1 -0
  281. package/dist/chat/super-grouping/tool-part-placement.d.ts +22 -0
  282. package/dist/chat/super-grouping/tool-part-placement.js +17 -0
  283. package/dist/chat/super-grouping/tool-part-placement.js.map +1 -0
  284. package/dist/chat/thread-scroll-to-bottom.cjs +2 -2
  285. package/dist/chat/thread-scroll-to-bottom.cjs.map +1 -1
  286. package/dist/chat/thread-scroll-to-bottom.d.ts +10 -7
  287. package/dist/chat/thread-scroll-to-bottom.js +2 -2
  288. package/dist/chat/thread-scroll-to-bottom.js.map +1 -1
  289. package/dist/chat/tooltip-icon-button.cjs +2 -2
  290. package/dist/chat/tooltip-icon-button.cjs.map +1 -1
  291. package/dist/chat/use-athena-voice-live.cjs +11 -0
  292. package/dist/chat/use-athena-voice-live.cjs.map +1 -0
  293. package/dist/chat/use-athena-voice-live.d.ts +11 -0
  294. package/dist/chat/use-athena-voice-live.js +11 -0
  295. package/dist/chat/use-athena-voice-live.js.map +1 -0
  296. package/dist/chat/use-statewire-approval-request.cjs +56 -24
  297. package/dist/chat/use-statewire-approval-request.cjs.map +1 -1
  298. package/dist/chat/use-statewire-approval-request.d.ts +33 -4
  299. package/dist/chat/use-statewire-approval-request.js +41 -9
  300. package/dist/chat/use-statewire-approval-request.js.map +1 -1
  301. package/dist/chat-ui/auth/sign-in-card.cjs +2 -2
  302. package/dist/chat-ui/auth/sign-in-card.cjs.map +1 -1
  303. package/dist/chat-ui/composer/tiptap-composer.cjs +138 -107
  304. package/dist/chat-ui/composer/tiptap-composer.cjs.map +1 -1
  305. package/dist/chat-ui/composer/tiptap-composer.d.ts +20 -4
  306. package/dist/chat-ui/composer/tiptap-composer.js +85 -54
  307. package/dist/chat-ui/composer/tiptap-composer.js.map +1 -1
  308. package/dist/chat-ui/header/conversation-history-panel.cjs +49 -23
  309. package/dist/chat-ui/header/conversation-history-panel.cjs.map +1 -1
  310. package/dist/chat-ui/header/conversation-history-panel.d.ts +12 -1
  311. package/dist/chat-ui/header/conversation-history-panel.js +38 -12
  312. package/dist/chat-ui/header/conversation-history-panel.js.map +1 -1
  313. package/dist/chat-ui/index.cjs +18 -0
  314. package/dist/chat-ui/index.cjs.map +1 -1
  315. package/dist/chat-ui/index.d.ts +7 -1
  316. package/dist/chat-ui/index.js +18 -0
  317. package/dist/chat-ui/index.js.map +1 -1
  318. package/dist/chat-ui/mentions/mention-chip.cjs +147 -38
  319. package/dist/chat-ui/mentions/mention-chip.cjs.map +1 -1
  320. package/dist/chat-ui/mentions/mention-chip.d.ts +17 -1
  321. package/dist/chat-ui/mentions/mention-chip.js +146 -37
  322. package/dist/chat-ui/mentions/mention-chip.js.map +1 -1
  323. package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-list.cjs +10 -9
  324. package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-list.cjs.map +1 -1
  325. package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-list.js +3 -2
  326. package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-list.js.map +1 -1
  327. package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-popup.cjs +2 -2
  328. package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-popup.cjs.map +1 -1
  329. package/dist/chat-ui/mentions/suggestions/components/menu-list.cjs +29 -6
  330. package/dist/chat-ui/mentions/suggestions/components/menu-list.cjs.map +1 -1
  331. package/dist/chat-ui/mentions/suggestions/components/menu-list.d.ts +7 -1
  332. package/dist/chat-ui/mentions/suggestions/components/menu-list.js +25 -2
  333. package/dist/chat-ui/mentions/suggestions/components/menu-list.js.map +1 -1
  334. package/dist/chat-ui/mentions/suggestions/components/use-keyboard-navigation.cjs +2 -2
  335. package/dist/chat-ui/mentions/suggestions/components/use-keyboard-navigation.cjs.map +1 -1
  336. package/dist/chat-ui/mentions/suggestions/components/use-menu-navigation.cjs +2 -2
  337. package/dist/chat-ui/mentions/suggestions/components/use-menu-navigation.cjs.map +1 -1
  338. package/dist/chat-ui/mentions/suggestions/data/api-client.cjs +3 -3
  339. package/dist/chat-ui/mentions/suggestions/data/api-client.cjs.map +1 -1
  340. package/dist/chat-ui/mentions/suggestions/data/orchestrator.cjs +56 -2
  341. package/dist/chat-ui/mentions/suggestions/data/orchestrator.cjs.map +1 -1
  342. package/dist/chat-ui/mentions/suggestions/data/orchestrator.d.ts +12 -0
  343. package/dist/chat-ui/mentions/suggestions/data/orchestrator.js +56 -2
  344. package/dist/chat-ui/mentions/suggestions/data/orchestrator.js.map +1 -1
  345. package/dist/chat-ui/mentions/suggestions/data/sources/index.cjs +24 -3
  346. package/dist/chat-ui/mentions/suggestions/data/sources/index.cjs.map +1 -1
  347. package/dist/chat-ui/mentions/suggestions/data/sources/index.d.ts +7 -0
  348. package/dist/chat-ui/mentions/suggestions/data/sources/index.js +24 -3
  349. package/dist/chat-ui/mentions/suggestions/data/sources/index.js.map +1 -1
  350. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.cjs +35 -13
  351. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.cjs.map +1 -1
  352. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.d.ts +15 -1
  353. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.js +28 -6
  354. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.js.map +1 -1
  355. package/dist/chat-ui/mentions/suggestions/data/use-menu-items.cjs +9 -6
  356. package/dist/chat-ui/mentions/suggestions/data/use-menu-items.cjs.map +1 -1
  357. package/dist/chat-ui/mentions/suggestions/data/use-menu-items.d.ts +3 -0
  358. package/dist/chat-ui/mentions/suggestions/data/use-menu-items.js +5 -2
  359. package/dist/chat-ui/mentions/suggestions/data/use-menu-items.js.map +1 -1
  360. package/dist/chat-ui/mentions/use-account-workspace-id.cjs +45 -10
  361. package/dist/chat-ui/mentions/use-account-workspace-id.cjs.map +1 -1
  362. package/dist/chat-ui/mentions/use-account-workspace-id.d.ts +24 -1
  363. package/dist/chat-ui/mentions/use-account-workspace-id.js +46 -11
  364. package/dist/chat-ui/mentions/use-account-workspace-id.js.map +1 -1
  365. package/dist/chat-ui/mentions/use-member-avatar.cjs +4 -4
  366. package/dist/chat-ui/mentions/use-member-avatar.cjs.map +1 -1
  367. package/dist/chat-ui/mentions/use-mention-asset.cjs +140 -0
  368. package/dist/chat-ui/mentions/use-mention-asset.cjs.map +1 -0
  369. package/dist/chat-ui/mentions/use-mention-asset.d.ts +16 -0
  370. package/dist/chat-ui/mentions/use-mention-asset.js +140 -0
  371. package/dist/chat-ui/mentions/use-mention-asset.js.map +1 -0
  372. package/dist/chat-ui/messages/answer-label.cjs +42 -0
  373. package/dist/chat-ui/messages/answer-label.cjs.map +1 -0
  374. package/dist/chat-ui/messages/answer-label.d.ts +33 -0
  375. package/dist/chat-ui/messages/answer-label.js +42 -0
  376. package/dist/chat-ui/messages/answer-label.js.map +1 -0
  377. package/dist/chat-ui/messages/arrival-animation.cjs +13 -0
  378. package/dist/chat-ui/messages/arrival-animation.cjs.map +1 -0
  379. package/dist/chat-ui/messages/arrival-animation.d.ts +14 -0
  380. package/dist/chat-ui/messages/arrival-animation.js +13 -0
  381. package/dist/chat-ui/messages/arrival-animation.js.map +1 -0
  382. package/dist/chat-ui/messages/continue-pill.cjs +5 -5
  383. package/dist/chat-ui/messages/continue-pill.cjs.map +1 -1
  384. package/dist/chat-ui/messages/handoff-arrival-divider.cjs +44 -0
  385. package/dist/chat-ui/messages/handoff-arrival-divider.cjs.map +1 -0
  386. package/dist/chat-ui/messages/handoff-arrival-divider.d.ts +17 -0
  387. package/dist/chat-ui/messages/handoff-arrival-divider.js +44 -0
  388. package/dist/chat-ui/messages/handoff-arrival-divider.js.map +1 -0
  389. package/dist/chat-ui/messages/message-actions-config.cjs +3 -3
  390. package/dist/chat-ui/messages/message-actions-config.cjs.map +1 -1
  391. package/dist/chat-ui/messages/message-components.cjs +8 -4
  392. package/dist/chat-ui/messages/message-components.cjs.map +1 -1
  393. package/dist/chat-ui/messages/message-components.js +5 -1
  394. package/dist/chat-ui/messages/message-components.js.map +1 -1
  395. package/dist/chat-ui/messages/message-images.cjs +66 -0
  396. package/dist/chat-ui/messages/message-images.cjs.map +1 -0
  397. package/dist/chat-ui/messages/message-images.d.ts +16 -0
  398. package/dist/chat-ui/messages/message-images.js +66 -0
  399. package/dist/chat-ui/messages/message-images.js.map +1 -0
  400. package/dist/chat-ui/messages/user-edit-composer.cjs +2 -2
  401. package/dist/chat-ui/messages/user-edit-composer.cjs.map +1 -1
  402. package/dist/chat-ui/messages/wake-marker.cjs +3 -3
  403. package/dist/chat-ui/messages/wake-marker.cjs.map +1 -1
  404. package/dist/chat-ui/rich-text/chat-link.cjs +7 -6
  405. package/dist/chat-ui/rich-text/chat-link.cjs.map +1 -1
  406. package/dist/chat-ui/rich-text/chat-link.d.ts +2 -3
  407. package/dist/chat-ui/rich-text/chat-link.js +6 -5
  408. package/dist/chat-ui/rich-text/chat-link.js.map +1 -1
  409. package/dist/chat-ui/rich-text/chat-message-body.cjs +8 -8
  410. package/dist/chat-ui/rich-text/chat-message-body.cjs.map +1 -1
  411. package/dist/chat-ui/rich-text/chat-node-views.cjs +7 -6
  412. package/dist/chat-ui/rich-text/chat-node-views.cjs.map +1 -1
  413. package/dist/chat-ui/rich-text/chat-node-views.js +1 -0
  414. package/dist/chat-ui/rich-text/chat-node-views.js.map +1 -1
  415. package/dist/chat-ui/rich-text/dom-output-spec.cjs +2 -2
  416. package/dist/chat-ui/rich-text/dom-output-spec.cjs.map +1 -1
  417. package/dist/chat-ui/statewire.cjs +3 -0
  418. package/dist/chat-ui/statewire.cjs.map +1 -1
  419. package/dist/chat-ui/statewire.d.ts +2 -1
  420. package/dist/chat-ui/statewire.js +3 -0
  421. package/dist/chat-ui/statewire.js.map +1 -1
  422. package/dist/chat-ui/thread/chat-thread-shell.cjs +43 -14
  423. package/dist/chat-ui/thread/chat-thread-shell.cjs.map +1 -1
  424. package/dist/chat-ui/thread/chat-thread-shell.d.ts +16 -2
  425. package/dist/chat-ui/thread/chat-thread-shell.js +35 -6
  426. package/dist/chat-ui/thread/chat-thread-shell.js.map +1 -1
  427. package/dist/chat-ui/thread/composer-send-or-stop.cjs +30 -20
  428. package/dist/chat-ui/thread/composer-send-or-stop.cjs.map +1 -1
  429. package/dist/chat-ui/thread/composer-send-or-stop.d.ts +8 -0
  430. package/dist/chat-ui/thread/composer-send-or-stop.js +29 -19
  431. package/dist/chat-ui/thread/composer-send-or-stop.js.map +1 -1
  432. package/dist/chat-ui/thread/statewire-history-edge.cjs +20 -21
  433. package/dist/chat-ui/thread/statewire-history-edge.cjs.map +1 -1
  434. package/dist/chat-ui/thread/statewire-history-edge.js +3 -4
  435. package/dist/chat-ui/thread/statewire-history-edge.js.map +1 -1
  436. package/dist/chat-ui/thread/thread-loading-overlay.cjs +5 -5
  437. package/dist/chat-ui/thread/thread-loading-overlay.cjs.map +1 -1
  438. package/dist/collab/client.cjs +40 -3
  439. package/dist/collab/client.cjs.map +1 -1
  440. package/dist/collab/client.d.ts +25 -0
  441. package/dist/collab/client.js +40 -3
  442. package/dist/collab/client.js.map +1 -1
  443. package/dist/collab/document-status.cjs +150 -0
  444. package/dist/collab/document-status.cjs.map +1 -0
  445. package/dist/collab/document-status.d.ts +68 -0
  446. package/dist/collab/document-status.js +150 -0
  447. package/dist/collab/document-status.js.map +1 -0
  448. package/dist/collab/index.cjs +7 -0
  449. package/dist/collab/index.cjs.map +1 -1
  450. package/dist/collab/index.d.ts +6 -1
  451. package/dist/collab/index.js +7 -0
  452. package/dist/collab/index.js.map +1 -1
  453. package/dist/collab/presence-react.cjs +11 -11
  454. package/dist/collab/presence-react.cjs.map +1 -1
  455. package/dist/collab/react.cjs +6 -6
  456. package/dist/collab/react.cjs.map +1 -1
  457. package/dist/composer/AttachmentContext.cjs +24 -11
  458. package/dist/composer/AttachmentContext.cjs.map +1 -1
  459. package/dist/composer/AttachmentContext.js +18 -5
  460. package/dist/composer/AttachmentContext.js.map +1 -1
  461. package/dist/composer/ComposerAttachmentPreview.cjs +78 -23
  462. package/dist/composer/ComposerAttachmentPreview.cjs.map +1 -1
  463. package/dist/composer/ComposerAttachmentPreview.d.ts +5 -3
  464. package/dist/composer/ComposerAttachmentPreview.js +79 -24
  465. package/dist/composer/ComposerAttachmentPreview.js.map +1 -1
  466. package/dist/composer/ComposerDropZone.cjs +7 -7
  467. package/dist/composer/ComposerDropZone.cjs.map +1 -1
  468. package/dist/composer/FileUploadButton.cjs +37 -22
  469. package/dist/composer/FileUploadButton.cjs.map +1 -1
  470. package/dist/composer/FileUploadButton.d.ts +6 -0
  471. package/dist/composer/FileUploadButton.js +34 -19
  472. package/dist/composer/FileUploadButton.js.map +1 -1
  473. package/dist/composer/QuoteContext.cjs +8 -8
  474. package/dist/composer/QuoteContext.cjs.map +1 -1
  475. package/dist/composer/composer-handoff.cjs +4 -4
  476. package/dist/composer/composer-handoff.cjs.map +1 -1
  477. package/dist/composer/useAppendToComposer.cjs +4 -4
  478. package/dist/composer/useAppendToComposer.cjs.map +1 -1
  479. package/dist/composer/useAttachFiles.cjs +23 -6
  480. package/dist/composer/useAttachFiles.cjs.map +1 -1
  481. package/dist/composer/useAttachFiles.d.ts +15 -7
  482. package/dist/composer/useAttachFiles.js +22 -5
  483. package/dist/composer/useAttachFiles.js.map +1 -1
  484. package/dist/composer/useComposerAttachment.cjs +4 -4
  485. package/dist/composer/useComposerAttachment.cjs.map +1 -1
  486. package/dist/composer/useFileUpload.cjs +21 -16
  487. package/dist/composer/useFileUpload.cjs.map +1 -1
  488. package/dist/composer/useFileUpload.d.ts +12 -0
  489. package/dist/composer/useFileUpload.js +12 -7
  490. package/dist/composer/useFileUpload.js.map +1 -1
  491. package/dist/composer/useReadComposerDraft.cjs +2 -2
  492. package/dist/composer/useReadComposerDraft.cjs.map +1 -1
  493. package/dist/composer/useSendMessage.cjs +4 -4
  494. package/dist/composer/useSendMessage.cjs.map +1 -1
  495. package/dist/diagnostics/useAthenaDiagnostics.cjs +4 -4
  496. package/dist/diagnostics/useAthenaDiagnostics.cjs.map +1 -1
  497. package/dist/dictation/audio-level-history.cjs +3 -3
  498. package/dist/dictation/audio-level-history.cjs.map +1 -1
  499. package/dist/dictation/dictation-controls.cjs +24 -20
  500. package/dist/dictation/dictation-controls.cjs.map +1 -1
  501. package/dist/dictation/dictation-controls.d.ts +6 -1
  502. package/dist/dictation/dictation-controls.js +24 -20
  503. package/dist/dictation/dictation-controls.js.map +1 -1
  504. package/dist/dictation/use-athena-dictation-engine.cjs +3 -3
  505. package/dist/dictation/use-athena-dictation-engine.cjs.map +1 -1
  506. package/dist/dictation/use-dictation.cjs +22 -22
  507. package/dist/dictation/use-dictation.cjs.map +1 -1
  508. package/dist/index.cjs +26 -2
  509. package/dist/index.cjs.map +1 -1
  510. package/dist/index.d.ts +15 -3
  511. package/dist/index.js +26 -2
  512. package/dist/index.js.map +1 -1
  513. package/dist/keryx-http/src/receive-only-socket.cjs +40 -0
  514. package/dist/keryx-http/src/receive-only-socket.cjs.map +1 -0
  515. package/dist/keryx-http/src/receive-only-socket.d.ts +27 -0
  516. package/dist/keryx-http/src/receive-only-socket.js +40 -0
  517. package/dist/keryx-http/src/receive-only-socket.js.map +1 -0
  518. package/dist/keryx-http/src/update-attributions.cjs +111 -0
  519. package/dist/keryx-http/src/update-attributions.cjs.map +1 -0
  520. package/dist/keryx-http/src/update-attributions.d.ts +75 -0
  521. package/dist/keryx-http/src/update-attributions.js +111 -0
  522. package/dist/keryx-http/src/update-attributions.js.map +1 -0
  523. package/dist/lib/owner-document.cjs +6 -6
  524. package/dist/lib/owner-document.cjs.map +1 -1
  525. package/dist/lib/use-athena-rest-query.cjs +4 -4
  526. package/dist/lib/use-athena-rest-query.cjs.map +1 -1
  527. package/dist/lib/use-document-active.cjs +4 -4
  528. package/dist/lib/use-document-active.cjs.map +1 -1
  529. package/dist/lib/use-prefers-reduced-motion.cjs +2 -2
  530. package/dist/lib/use-prefers-reduced-motion.cjs.map +1 -1
  531. package/dist/offline/offline-history.cjs +7 -7
  532. package/dist/offline/offline-history.cjs.map +1 -1
  533. package/dist/provider/AthenaContext.cjs +3 -3
  534. package/dist/provider/AthenaContext.cjs.map +1 -1
  535. package/dist/provider/AthenaProvider.cjs +116 -79
  536. package/dist/provider/AthenaProvider.cjs.map +1 -1
  537. package/dist/provider/AthenaProvider.js +40 -3
  538. package/dist/provider/AthenaProvider.js.map +1 -1
  539. package/dist/provider/PostHogProvider.cjs +2 -2
  540. package/dist/provider/PostHogProvider.cjs.map +1 -1
  541. package/dist/provider/agent-selection-context.cjs +2 -2
  542. package/dist/provider/agent-selection-context.cjs.map +1 -1
  543. package/dist/provider/chat-mode-context.cjs +2 -2
  544. package/dist/provider/chat-mode-context.cjs.map +1 -1
  545. package/dist/provider/session-persistence-context.cjs +10 -0
  546. package/dist/provider/session-persistence-context.cjs.map +1 -0
  547. package/dist/provider/session-persistence-context.d.ts +15 -0
  548. package/dist/provider/session-persistence-context.js +10 -0
  549. package/dist/provider/session-persistence-context.js.map +1 -0
  550. package/dist/provider/statewire-history-context.cjs +4 -4
  551. package/dist/provider/statewire-history-context.cjs.map +1 -1
  552. package/dist/provider/statewire-lifecycle-context.cjs +3 -3
  553. package/dist/provider/statewire-lifecycle-context.cjs.map +1 -1
  554. package/dist/provider/statewire-window-context.cjs +3 -3
  555. package/dist/provider/statewire-window-context.cjs.map +1 -1
  556. package/dist/provider/theme-style-context.cjs +3 -3
  557. package/dist/provider/theme-style-context.cjs.map +1 -1
  558. package/dist/react/package.json.cjs +1 -1
  559. package/dist/react/package.json.js +1 -1
  560. package/dist/references/src/tool-option-schemas.d.ts +0 -34
  561. package/dist/runtime/StatewireThreadConfigLaneSync.cjs +10 -10
  562. package/dist/runtime/StatewireThreadConfigLaneSync.cjs.map +1 -1
  563. package/dist/runtime/auth-refusal-restart.cjs +7 -7
  564. package/dist/runtime/auth-refusal-restart.cjs.map +1 -1
  565. package/dist/runtime/auth.cjs +13 -13
  566. package/dist/runtime/auth.cjs.map +1 -1
  567. package/dist/runtime/statewire-lifecycle.cjs +1 -0
  568. package/dist/runtime/statewire-lifecycle.cjs.map +1 -1
  569. package/dist/runtime/statewire-lifecycle.d.ts +3 -1
  570. package/dist/runtime/statewire-lifecycle.js +2 -1
  571. package/dist/runtime/statewire-lifecycle.js.map +1 -1
  572. package/dist/runtime/statewire-server-lane-context.cjs +2 -2
  573. package/dist/runtime/statewire-server-lane-context.cjs.map +1 -1
  574. package/dist/runtime/statewire-session-lane.cjs +4 -4
  575. package/dist/runtime/statewire-session-lane.cjs.map +1 -1
  576. package/dist/runtime/useAthenaStatewireRuntime.cjs +10 -8
  577. package/dist/runtime/useAthenaStatewireRuntime.cjs.map +1 -1
  578. package/dist/runtime/useAthenaStatewireRuntime.d.ts +2 -0
  579. package/dist/runtime/useAthenaStatewireRuntime.js +2 -0
  580. package/dist/runtime/useAthenaStatewireRuntime.js.map +1 -1
  581. package/dist/styles.css +1 -1
  582. package/dist/threads/Inbox.cjs +8 -8
  583. package/dist/threads/Inbox.cjs.map +1 -1
  584. package/dist/threads/SessionList.cjs +9 -9
  585. package/dist/threads/SessionList.cjs.map +1 -1
  586. package/dist/threads/SessionsPage.cjs +11 -11
  587. package/dist/threads/SessionsPage.cjs.map +1 -1
  588. package/dist/threads/index-triggered-refresh.cjs +10 -10
  589. package/dist/threads/index-triggered-refresh.cjs.map +1 -1
  590. package/dist/threads/mark-viewed-thread-read.cjs +12 -12
  591. package/dist/threads/mark-viewed-thread-read.cjs.map +1 -1
  592. package/dist/threads/offline-session-list.cjs +3 -3
  593. package/dist/threads/offline-session-list.cjs.map +1 -1
  594. package/dist/threads/session-list-tab-share.cjs +5 -5
  595. package/dist/threads/session-list-tab-share.cjs.map +1 -1
  596. package/dist/threads/statewire-thread-list.cjs +55 -51
  597. package/dist/threads/statewire-thread-list.cjs.map +1 -1
  598. package/dist/threads/statewire-thread-list.js +6 -2
  599. package/dist/threads/statewire-thread-list.js.map +1 -1
  600. package/dist/threads/thread-id-context.cjs +5 -5
  601. package/dist/threads/thread-id-context.cjs.map +1 -1
  602. package/dist/threads/use-athena-session-attention.cjs +2 -2
  603. package/dist/threads/use-athena-session-attention.cjs.map +1 -1
  604. package/dist/threads/use-athena-sessions.cjs +10 -10
  605. package/dist/threads/use-athena-sessions.cjs.map +1 -1
  606. package/dist/threads/use-athena-thread-model.cjs +3 -3
  607. package/dist/threads/use-athena-thread-model.cjs.map +1 -1
  608. package/dist/threads/use-rest-conversation-history.cjs +3 -3
  609. package/dist/threads/use-rest-conversation-history.cjs.map +1 -1
  610. package/dist/threads/use-statewire-conversation-history.cjs +8 -8
  611. package/dist/threads/use-statewire-conversation-history.cjs.map +1 -1
  612. package/dist/threads/use-thread-archive.cjs +9 -9
  613. package/dist/threads/use-thread-archive.cjs.map +1 -1
  614. package/dist/threads/use-thread-favorite.cjs +2 -2
  615. package/dist/threads/use-thread-favorite.cjs.map +1 -1
  616. package/dist/threads/use-thread-field-override.cjs +20 -20
  617. package/dist/threads/use-thread-field-override.cjs.map +1 -1
  618. package/dist/threads/use-thread-read-state.cjs +4 -4
  619. package/dist/threads/use-thread-read-state.cjs.map +1 -1
  620. package/dist/threads/use-thread-rename.cjs +2 -2
  621. package/dist/threads/use-thread-rename.cjs.map +1 -1
  622. package/dist/threads/useAthenaThreadManager.cjs +2 -2
  623. package/dist/threads/useAthenaThreadManager.cjs.map +1 -1
  624. package/dist/tools/NestedPtcMessages.cjs +6 -6
  625. package/dist/tools/NestedPtcMessages.cjs.map +1 -1
  626. package/dist/tools/append-document-tool-ui.cjs +7 -7
  627. package/dist/tools/append-document-tool-ui.cjs.map +1 -1
  628. package/dist/tools/file-tool-uis.cjs +2 -2
  629. package/dist/tools/file-tool-uis.cjs.map +1 -1
  630. package/dist/tools/misc-tool-uis.cjs +2 -2
  631. package/dist/tools/misc-tool-uis.cjs.map +1 -1
  632. package/dist/tools/primitives.cjs +6 -6
  633. package/dist/tools/primitives.cjs.map +1 -1
  634. package/dist/tools/read-asset-tool-ui.cjs +6 -6
  635. package/dist/tools/read-asset-tool-ui.cjs.map +1 -1
  636. package/dist/tools/subagent-task-tool-ui.cjs +21 -21
  637. package/dist/tools/subagent-task-tool-ui.cjs.map +1 -1
  638. package/dist/tools/test-recording-tool-uis.cjs +16 -16
  639. package/dist/tools/test-recording-tool-uis.cjs.map +1 -1
  640. package/dist/tools/todo-plan-store.cjs +4 -4
  641. package/dist/tools/todo-plan-store.cjs.map +1 -1
  642. package/dist/tools/tool-appearance.cjs +3 -3
  643. package/dist/tools/tool-appearance.cjs.map +1 -1
  644. package/dist/tools/tool-fallback.cjs +14 -14
  645. package/dist/tools/tool-fallback.cjs.map +1 -1
  646. package/dist/tools/tool-summary.cjs +0 -2
  647. package/dist/tools/tool-summary.cjs.map +1 -1
  648. package/dist/tools/tool-summary.js +0 -2
  649. package/dist/tools/tool-summary.js.map +1 -1
  650. package/dist/tools/tool-uis.cjs +74 -74
  651. package/dist/tools/tool-uis.cjs.map +1 -1
  652. package/dist/tools/use-elapsed-seconds.cjs +3 -3
  653. package/dist/tools/use-elapsed-seconds.cjs.map +1 -1
  654. package/dist/tools/write-todos-tool-ui.cjs +9 -9
  655. package/dist/tools/write-todos-tool-ui.cjs.map +1 -1
  656. package/dist/ui/image-viewer.cjs +382 -0
  657. package/dist/ui/image-viewer.cjs.map +1 -0
  658. package/dist/ui/image-viewer.d.ts +50 -0
  659. package/dist/ui/image-viewer.js +382 -0
  660. package/dist/ui/image-viewer.js.map +1 -0
  661. package/dist/voice/chat.cjs +6 -0
  662. package/dist/voice/chat.cjs.map +1 -1
  663. package/dist/voice/chat.d.ts +1 -1
  664. package/dist/voice/chat.js +8 -2
  665. package/dist/voice/livekit-join.cjs +52 -101
  666. package/dist/voice/livekit-join.cjs.map +1 -1
  667. package/dist/voice/livekit-join.d.ts +1 -6
  668. package/dist/voice/livekit-join.js +52 -101
  669. package/dist/voice/livekit-join.js.map +1 -1
  670. package/dist/voice/livekit.cjs.map +1 -1
  671. package/dist/voice/livekit.d.ts +11 -1
  672. package/dist/voice/livekit.js.map +1 -1
  673. package/dist/voice/use-athena-voice-session.cjs +34 -34
  674. package/dist/voice/use-athena-voice-session.cjs.map +1 -1
  675. package/dist/workbench/ComputerLiveDesktop.cjs +13 -13
  676. package/dist/workbench/ComputerLiveDesktop.cjs.map +1 -1
  677. package/dist/workbench/SessionWorkbench.cjs +22 -22
  678. package/dist/workbench/SessionWorkbench.cjs.map +1 -1
  679. package/dist/workbench/session-workbench-context.cjs +3 -3
  680. package/dist/workbench/session-workbench-context.cjs.map +1 -1
  681. package/dist/workbench/session-workbench-panes.cjs +8 -8
  682. package/dist/workbench/session-workbench-panes.cjs.map +1 -1
  683. package/dist/workbench/workbench-layout-context.cjs +3 -3
  684. package/dist/workbench/workbench-layout-context.cjs.map +1 -1
  685. package/package.json +2 -1
@@ -1 +1 @@
1
- {"version":3,"file":"tiptap-composer.cjs","sources":["../../../src/chat-ui/composer/tiptap-composer.tsx"],"sourcesContent":["/**\n * Tiptap Composer — Full Olympus mention system integration\n *\n * Uses the ported Olympus infrastructure:\n * - MentionSuggestionList (with scope navigation, breadcrumbs, keyboard nav)\n * - MentionSuggestionPopup (Floating UI positioning)\n * - MentionSuggestionsExtension (Tiptap @ trigger)\n * - MentionExtension (inline mention chips)\n * - useMentionSuggestions (full Olympus categories + async data)\n *\n * Auth credentials for GraphQL are provided via MentionAuthCtx, and the host\n * app (Chrome side panel, Office task pane, the SDK's AthenaChat) supplies any\n * host-only mention items — browser tabs through `webpages`, its own Tools /\n * Toolkits list through `tools`.\n *\n * The draft serializes to Markdown through `tiptap-markdown`, so pasted\n * hyperlinks keep their URL, formatting marks survive, paragraphs stay\n * separated, and a mention is the `[@Name](url)` link the message renderer\n * parses back into a chip. Send delivers that Markdown with every plain-text\n * run written exactly as typed (`serializeComposerMessage`), as the Olympus\n * chat composer does, and the message carries the draft it was sent from\n * (`metadata.composer_markdown`, only when the two differ) so its bubble\n * shows the text exactly as typed.\n */\n\nimport { athenaDiagnostics } from \"../../diagnostics/athena-diagnostics\";\nimport {\n clipboardHasMeaningfulText,\n extractPastedImages,\n extractPastedNonImageFiles,\n isImageFile,\n} from \"../../composer/clipboard\";\nimport {\n useRef,\n useState,\n useCallback,\n useEffect,\n forwardRef,\n useImperativeHandle,\n type DragEvent as ReactDragEvent,\n} from \"react\";\nimport { useEditor, EditorContent } from \"@tiptap/react\";\nimport Placeholder from \"@tiptap/extension-placeholder\";\nimport { Extension, type Editor } from \"@tiptap/core\";\nimport { unstable_useComposerInput, useAui } from \"@assistant-ui/react\";\nimport {\n takeRestoredAttachments,\n useComposerHandoffStore,\n} from \"../../composer/composer-handoff\";\nimport { useStatewireSessionLane } from \"../../runtime/statewire-session-lane\";\nimport { LoaderCircleIcon, XIcon } from \"lucide-react\";\nimport { cn } from \"../../lib/utils\";\nimport { CHAT_TEXT_CLASS, createChatTextExtensions } from \"../rich-text/chat-text-schema\";\nimport {\n MentionSuggestionsExtension,\n type MentionSuggestionCallbacks,\n type MentionSuggestionRenderProps,\n} from \"../mentions/suggestions/mention-suggestions.extension\";\nimport { MentionSuggestionPopup } from \"../mentions/suggestions/components/mention-suggestion-popup\";\nimport {\n MentionSuggestionList,\n} from \"../mentions/suggestions/components/mention-suggestion-list\";\nimport {\n useMentionSuggestions,\n type MentionRootCategory,\n} from \"../mentions/suggestions/data/use-mention-suggestions\";\nimport type {\n MentionTool,\n MenuItem,\n WebpageMention,\n} from \"../mentions/suggestions/data/types\";\nimport type { KeyboardNavigationHandle } from \"../mentions/suggestions/components/use-keyboard-navigation\";\nimport { Selection } from \"@tiptap/pm/state\";\nimport type { EditorView } from \"@tiptap/pm/view\";\nimport {\n isAthenaAssetDrag,\n readAthenaAssetDrop,\n registerChatAssetMentionHandler,\n type UploadedChatAsset,\n type ChatOutbox,\n type ChatOutboxAttachment,\n useDeepAgentChatOutboxContext,\n withDeepAgentComposerMarkdown,\n} from \"@athenaintel/agent-runtime\";\nimport {\n captureComposerSend,\n ComposerDraftWhitespace,\n type ComposerSend,\n draftForReturnedSend,\n prepareComposerSend,\n serializeComposerDraft,\n} from \"./composer-message\";\nimport { PendingAttachmentUploads } from \"./pending-attachment-uploads\";\nimport { runInputRulesOnEnter } from \"./run-input-rules-on-enter\";\n\n// ── Submit keybind extension ──\n\nconst SubmitKeybind = Extension.create<{ onSubmit: () => void; isMentionOpen: () => boolean }>({\n name: \"submitKeybind\",\n priority: 1000,\n addOptions() {\n return { onSubmit: () => {}, isMentionOpen: () => false };\n },\n addKeyboardShortcuts() {\n return {\n Enter: () => {\n // Don't submit when the mention popup is open — let it handle Enter\n if (this.options.isMentionOpen()) return false;\n // A typed \"1.\" or \"-\" starts a list rather than sending.\n if (runInputRulesOnEnter(this.editor)) return true;\n // Let the schema's keymaps continue lists, insert code newlines, and\n // split paragraphs inside structured blocks, as in the web composer.\n if ([\"listItem\", \"taskItem\", \"codeBlock\", \"table\", \"blockquote\"].some(\n (node) => this.editor.isActive(node),\n )) return false;\n this.options.onSubmit();\n return true;\n },\n \"Shift-Enter\": () => {\n return this.editor.commands.newlineInCode() || this.editor.commands.setHardBreak();\n },\n };\n },\n});\n\n// ── CSS for mention chips + editor ──\n\nconst MENTION_STYLES = `\n .image-preview-composer .mention-chip[data-display-as-preview=\"true\"] {\n display: none;\n }\n /* Scoped to this editor: hosts render other ProseMirror instances on the\n same page (AthenaChat's message renderer), which must keep their own\n height and placeholder rules. */\n .athena-chat-composer .ProseMirror {\n outline: none;\n min-height: 36px;\n max-height: 120px;\n overflow-y: auto;\n }\n .athena-chat-composer .ProseMirror p.is-editor-empty:first-child::before {\n content: attr(data-placeholder);\n float: left;\n color: #9ca3af;\n pointer-events: none;\n height: 0;\n }\n /* The paper appearance (the SDK thread): a taller resting height, room for\n about eight lines before the draft scrolls, and a placeholder at 35% of\n the text colour. Same specificity as the rules above, so order decides. */\n .athena-chat-composer--paper .ProseMirror {\n min-height: 44px;\n max-height: 12rem;\n }\n .athena-chat-composer--paper .ProseMirror p.is-editor-empty:first-child::before {\n color: color-mix(in srgb, currentColor 35%, transparent);\n }\n`;\n\n/**\n * The editor's look. `default` is what the Chrome extension and Office add-in\n * render; `paper` pairs with `ChatComposerDock appearance=\"paper\"`.\n */\nexport type TiptapComposerAppearance = \"default\" | \"paper\";\n\n/**\n * The draft as Markdown, mentions as `[@Name](url)` links: what the composer\n * mirrors into the composer runtime and parses back on a restore\n * (`serializeComposerDraft`, which reads back into the same document). Send\n * delivers it with plain text written as typed (`serializeComposerMessage`).\n */\nexport function serializeDraft(editor: Editor): string {\n return serializeComposerDraft(editor);\n}\n\n/**\n * Append `text` to the editor's draft as typed plain text — never read as\n * Markdown — one space after any text already on the last line, the way a\n * dictated phrase joins the draft. Returns whether anything was added.\n */\nfunction appendPlainText(editor: Editor, text: string): boolean {\n const words = text.trim();\n if (!words || editor.isDestroyed) return false;\n const end = Selection.atEnd(editor.state.doc);\n const before = end.$from.nodeBefore;\n const needsSpace =\n before !== null &&\n before.type.name !== \"hardBreak\" &&\n !(before.isText && /\\s$/.test(before.text ?? \"\"));\n editor\n .chain()\n .setTextSelection(end.from)\n // A text node, not a string: the Markdown extension parses string content\n // as Markdown, which would turn spoken words into formatting.\n .insertContent({ type: \"text\", text: needsSpace ? ` ${words}` : words })\n .run();\n return true;\n}\n\n/**\n * A host's own intake for the files pasted into or dropped on the composer\n * (AthenaChat uploads them into its attachment pills). Without `onDrop` the\n * composer leaves drops untouched so an enclosing drop zone receives them.\n */\nexport interface ComposerFileIntake {\n onPaste: (files: readonly File[]) => void;\n onDrop?: (files: readonly File[]) => void;\n}\n\n// ── Main component ──\n\nexport interface TiptapComposerHandle {\n submit: () => Promise<void>;\n addAttachment: (file: File) => Promise<void>;\n insertAssetMention: (asset: UploadedChatAsset) => void;\n /**\n * Focuses the editor and types the `@` trigger at the caret (after a space\n * when the caret follows a word), opening the mention menu — the toolbar's\n * `@` button. A no-op while the editor is disabled or the menu is open.\n * Optional on the type so hosts' handle stand-ins written before it keep\n * type-checking; the composer itself always provides it.\n */\n openMentionMenu?: () => void;\n /**\n * Appends `text` to the draft as typed plain text, never read as Markdown,\n * one space after any text on the draft's last line — how dictated words\n * join the draft. Optional on the type, like `openMentionMenu`.\n */\n appendText?: (text: string) => void;\n /**\n * The draft as a send would deliver it — `text` with plain text exactly as\n * typed, `draftMarkdown` the same document as Markdown that reads back into\n * it — or `null` before the editor mounts. For a host that sends the draft\n * itself (AthenaChat's dictated send) through `prepareComposerSend`.\n */\n captureSend?: () => ComposerSend | null;\n}\n\nexport interface TiptapComposerProps {\n placeholder?: string;\n threadId: string;\n disabled?: boolean;\n /**\n * Holds the send, not the draft: Enter and `submit()` send nothing and leave the draft as typed,\n * while typing goes on. For a host that keeps nothing while Athena can't be reached (no chat\n * outbox: the Chrome side panel, the Office task pane); its send control says why\n * (`ComposerSendOrStop`'s `sendBlockedReason`).\n */\n sendBlocked?: boolean;\n /** Editor look; defaults to the side-panel / task-pane editor. */\n appearance?: TiptapComposerAppearance;\n /** Host-provided browser-tab mentions; empty in hosts without tab access. */\n webpages?: readonly WebpageMention[];\n /**\n * Host-provided Tools / Toolkits mention candidates. When set they replace\n * the server tool catalog for those categories (see `useMentionSuggestions`).\n */\n tools?: readonly MentionTool[];\n rootCategories?: readonly MentionRootCategory[];\n onDraftStateChange?: (hasDraft: boolean) => void;\n /** Show local image thumbnails while mention-backed uploads are in the draft. */\n showImagePreviews?: boolean;\n /**\n * Paste and drop attach files of any type, as Olympus's composer does.\n * Off by default: those hosts attach pasted or dropped images only.\n */\n attachAnyFile?: boolean;\n /** Surface paste/drop attachment failures in host UI as well as diagnostics. */\n onAttachmentError?: (message: string) => void;\n /**\n * Host-owned intake for pasted and dropped files. Without it the composer\n * attaches them itself through `aui.composer.addAttachment`.\n */\n fileIntake?: ComposerFileIntake;\n /**\n * Awaited before every submit (Enter and the imperative handle), after the\n * composer's own pending uploads have settled: a host whose uploads live\n * outside the composer (AthenaChat's attachment pills) resolves once they\n * land, so a send never leaves without its attachment.\n */\n waitForHostUploads?: () => Promise<void> | void;\n /**\n * Optional submit interception: called with the serialized draft — possibly\n * empty, for a host composing its own extras into the send — before the\n * composer-runtime send. Return `true` when the host consumed the draft\n * through another lane (e.g. a live voice session) — the editor clears and\n * the normal send is skipped. Return `false` to fall through unchanged.\n * The editor stays read-only while an asynchronous interception settles.\n * `text` is plain text written exactly as typed (what the model should\n * read); `draftMarkdown` is the same draft with plain text escaped for\n * Markdown (`serializeComposerDraft`), for a host that sends the message\n * itself: `prepareComposerSend` remembers it, so a send handed back loads\n * exactly, and puts it on the message as its composer markdown.\n */\n interceptSubmit?: (text: string, draftMarkdown: string) => boolean | Promise<boolean>;\n /**\n * Whether the host has something pending that rides the next send besides the text (AthenaChat's\n * attachment pills or a quote). While sends are on hold such a message waits in the chat outbox\n * only through {@link TiptapComposerProps.holdPendingExtras}; without it the draft stays and the\n * composer says why (`onAttachmentError`).\n */\n hasPendingExtras?: () => boolean;\n /**\n * Holds the draft in the chat outbox together with the host's pending extras (AthenaChat composes\n * its uploaded attachments and its quote around the text, as its send would) and clears them;\n * `true` once held, after which the editor clears. Called while sends are on hold (Athena can't\n * be reached, or earlier messages still wait), only when `hasPendingExtras` says there are some.\n * `attachments` are files already in Athena the draft itself carries (mentions a held message\n * gave back); the held message names them with the host's own.\n */\n holdPendingExtras?: (args: {\n outbox: ChatOutbox;\n send: ComposerSend;\n attachments: ChatOutboxAttachment[];\n }) => boolean;\n /**\n * Called after a draft has left the editor — through the composer-runtime\n * send or a host interception — from Enter and the imperative handle alike.\n * Hosts use it for per-send UI such as a first-use keyboard hint.\n */\n onSubmitted?: () => void;\n}\n\n/** The assets the draft mentions (asset mention chips), by id. */\nfunction assetMentionIds(editor: Editor): Set<string> {\n const ids = new Set<string>();\n editor.state.doc.descendants((node) => {\n if (\n node.type.name === \"mention\" &&\n node.attrs.type === \"asset\" &&\n typeof node.attrs.id === \"string\"\n ) {\n ids.add(node.attrs.id);\n }\n });\n return ids;\n}\n\n/** What the composer says when a message with an attachment or a quote can't wait to be sent. */\nexport const OFFLINE_EXTRAS_MESSAGE =\n \"Athena can't be reached. A message with an attachment or a quote can't wait to be sent — remove it to send the text when Athena is back.\";\n\n/** What the composer says when a message with an attachment or a quote would overtake messages still waiting. */\nexport const WAITING_EXTRAS_MESSAGE =\n \"Messages you wrote while Athena couldn't be reached haven't gone yet. A message with an attachment or a quote can't wait behind them — send it once they've gone.\";\n\n/**\n * Resolves once the outbox has read the thread's kept messages (at once when it has), or after\n * `CHAT_OUTBOX_READ_WAIT_MS` (a store that never answers then counts as read: `shouldHold` still\n * holds while Athena can't be reached).\n */\nfunction chatOutboxRead(outbox: ChatOutbox): Promise<void> {\n if (outbox.getSnapshot().loaded) return Promise.resolve();\n return new Promise((resolve) => {\n let stop = (): void => undefined;\n const timer = setTimeout(() => {\n stop();\n resolve();\n }, CHAT_OUTBOX_READ_WAIT_MS);\n stop = outbox.subscribe(() => {\n if (!outbox.getSnapshot().loaded) return;\n clearTimeout(timer);\n stop();\n resolve();\n });\n });\n}\n\n/** The longest a send with an attachment or a quote waits for the outbox's first read. */\nconst CHAT_OUTBOX_READ_WAIT_MS = 2_000;\n\nconst NO_WEBPAGES: readonly WebpageMention[] = [];\n\ninterface ComposerImagePreview {\n key: string;\n file: File;\n name: string;\n src: string;\n assetId?: string;\n}\n\nfunction revokeImagePreview(src: string): void {\n if (typeof URL.revokeObjectURL === \"function\") URL.revokeObjectURL(src);\n}\n\nfunction ImagePreviewStrip({\n previews,\n onRemove,\n}: {\n previews: readonly ComposerImagePreview[];\n onRemove: (preview: ComposerImagePreview) => void;\n}) {\n if (previews.length === 0) return null;\n\n return (\n <div\n className=\"flex w-full gap-2 overflow-x-auto px-1.5 pb-1 pt-1.5\"\n role=\"list\"\n aria-label=\"Image attachments\"\n >\n {previews.map((preview) => {\n const uploading = preview.assetId === undefined;\n return (\n <div\n key={preview.key}\n className=\"group relative h-16 w-[clamp(76px,30vw,112px)] shrink-0 overflow-hidden rounded-lg border border-neutral-200 bg-neutral-100 shadow-sm\"\n role=\"listitem\"\n >\n <img\n src={preview.src}\n alt={preview.name}\n className=\"size-full object-cover\"\n />\n <div className=\"absolute inset-x-0 bottom-0 truncate bg-gradient-to-t from-black/75 to-transparent px-1.5 pb-1 pt-4 text-[10px] font-medium text-white\">\n {preview.name}\n </div>\n {uploading ? (\n <span\n className=\"absolute left-1 top-1 inline-flex size-5 items-center justify-center rounded-full bg-black/65 text-white\"\n title=\"Uploading image\"\n >\n <LoaderCircleIcon className=\"size-3 animate-spin\" />\n </span>\n ) : (\n <button\n type=\"button\"\n onClick={() => onRemove(preview)}\n className=\"absolute right-1 top-1 inline-flex size-5 items-center justify-center rounded-full bg-black/65 text-white opacity-80 transition-opacity hover:bg-black/80 hover:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white\"\n aria-label={`Remove ${preview.name}`}\n title=\"Remove image\"\n >\n <XIcon className=\"size-3\" />\n </button>\n )}\n </div>\n );\n })}\n </div>\n );\n}\n\nexport const TiptapComposer = forwardRef<\n TiptapComposerHandle,\n TiptapComposerProps\n>(\n (\n {\n placeholder = \"Message Athena... (type @ to mention)\",\n threadId,\n disabled = false,\n sendBlocked = false,\n appearance = \"default\",\n webpages = NO_WEBPAGES,\n tools,\n rootCategories,\n onDraftStateChange,\n showImagePreviews = false,\n attachAnyFile = false,\n onAttachmentError,\n fileIntake,\n waitForHostUploads,\n interceptSubmit,\n hasPendingExtras,\n holdPendingExtras,\n onSubmitted,\n },\n outerRef,\n ) => {\n const aui = useAui();\n // The thread's chat outbox (a host's `chatOutbox`): a send while Athena can't be reached, or\n // behind messages still waiting, waits there instead of reaching the transport.\n const outbox = useDeepAgentChatOutboxContext();\n const outboxRef = useRef(outbox);\n outboxRef.current = outbox;\n const composerInput = unstable_useComposerInput();\n const handoff = useComposerHandoffStore();\n const applyingRuntimeTextRef = useRef(false);\n // What this editor last mirrored into the composer runtime; a value equal to\n // it is our own echo and needs no re-serialization or restore.\n const lastEmittedMarkdownRef = useRef<string | null>(null);\n // The returned send last loaded from its draft: the runtime still holds its\n // verbatim text, which must not be parsed over the draft on a later pass.\n const restoredSendRef = useRef<string | null>(null);\n const listRef = useRef<KeyboardNavigationHandle>(null);\n const pendingUploadsRef = useRef(new PendingAttachmentUploads());\n const submitInFlightRef = useRef(false);\n const interceptionPendingRef = useRef(false);\n const disabledRef = useRef(disabled);\n disabledRef.current = disabled;\n const setEditorEditable = useCallback((ed: Editor) => {\n ed.setEditable(!disabledRef.current && !interceptionPendingRef.current, false);\n ed.view.dom.setAttribute(\"aria-busy\", String(interceptionPendingRef.current));\n ed.view.dom.setAttribute(\"aria-readonly\", String(!ed.isEditable));\n }, []);\n // Read through a ref: a hold that starts while a send waits for its uploads still holds it.\n const sendBlockedRef = useRef(sendBlocked);\n sendBlockedRef.current = sendBlocked;\n // The provider's session lane (`AthenaProvider`; none for a host's own runtime).\n const sessionLane = useStatewireSessionLane();\n const sessionLaneRef = useRef(sessionLane);\n sessionLaneRef.current = sessionLane;\n const imagePreviewsRef = useRef<ComposerImagePreview[]>([]);\n const [imagePreviews, setImagePreviews] = useState<ComposerImagePreview[]>([]);\n\n const replaceImagePreviews = useCallback((next: ComposerImagePreview[]) => {\n imagePreviewsRef.current = next;\n setImagePreviews(next);\n }, []);\n\n const removeImagePreviews = useCallback(\n (shouldRemove: (preview: ComposerImagePreview) => boolean) => {\n const kept: ComposerImagePreview[] = [];\n let removed = false;\n for (const preview of imagePreviewsRef.current) {\n if (shouldRemove(preview)) {\n revokeImagePreview(preview.src);\n removed = true;\n } else kept.push(preview);\n }\n if (removed) replaceImagePreviews(kept);\n },\n [replaceImagePreviews],\n );\n\n const clearImagePreviews = useCallback(() => {\n removeImagePreviews(() => true);\n }, [removeImagePreviews]);\n\n useEffect(() => clearImagePreviews(), [clearImagePreviews, threadId]);\n useEffect(\n () => () => {\n for (const preview of imagePreviewsRef.current) {\n revokeImagePreview(preview.src);\n }\n imagePreviewsRef.current = [];\n },\n [],\n );\n\n const { store } = useMentionSuggestions({ webpages, tools, rootCategories });\n\n // Popup state\n const [popupOpen, setPopupOpen] = useState(false);\n const popupOpenRef = useRef(false);\n const [popupProps, setPopupProps] = useState<MentionSuggestionRenderProps | null>(null);\n\n // Suggestion callbacks — drive the popup lifecycle\n const callbacksRef = useRef<MentionSuggestionCallbacks>({\n onStart: (props) => {\n setPopupOpen(true);\n popupOpenRef.current = true;\n setPopupProps(props);\n },\n onUpdate: (props) => {\n setPopupProps(props);\n },\n onKeyDown: (event) => {\n // Route keyboard events to the MentionSuggestionList\n return listRef.current?.onKeyDown(event) ?? false;\n },\n onExit: () => {\n setPopupOpen(false);\n popupOpenRef.current = false;\n setPopupProps(null);\n },\n });\n\n // Editor ref — needed because handleSubmit is created before useEditor returns\n const editorRef = useRef<ReturnType<typeof useEditor>>(null);\n\n // Submit via composer runtime so attachments (screenshots, files) are included.\n // aui.composer.setText() + aui.composer.send() bundles text + pending attachments.\n //\n // Statewire turns a send during an active run into a queued command. Do not\n // cancel first: cancellation aborts the shared run for every connected\n // client and turns a normal queued follow-up into a destructive stop.\n const handleSubmit = useCallback(async () => {\n if (disabled || sendBlockedRef.current) return;\n if (submitInFlightRef.current) return;\n submitInFlightRef.current = true;\n try {\n await pendingUploadsRef.current.waitForIdle();\n await waitForHostUploads?.();\n // The sign-in provider is still resolving who is signed in, so the chat's\n // session lane is pending and a send now would be refused unsent: it waits\n // for the lane with the draft still in the editor, and goes as typed then.\n const lane = sessionLaneRef.current;\n if (lane?.isPending()) await lane.whenKnown();\n if (sendBlockedRef.current) return;\n const ed = editorRef.current;\n if (!ed) return;\n // The model reads the sent text literally, so plain text goes out\n // exactly as typed; the draft keeps its Markdown escaping.\n const { text, draftMarkdown } = captureComposerSend(ed);\n const submittedDocument = ed.state.doc;\n const consumeSubmittedDraft = () => {\n if (ed.state.doc.eq(submittedDocument)) {\n takeRestoredAttachments({ store: handoff, threadId, assetIdsInDraft: new Set() });\n ed.commands.clearContent(false);\n lastEmittedMarkdownRef.current = \"\";\n composerInput.setText(\"\");\n clearImagePreviews();\n onDraftStateChange?.(false);\n } else {\n // Runtime restores and host commands can replace even a read-only\n // editor. Keep that newer draft, including after a fallback send\n // clears the composer's runtime text.\n composerInput.setText(serializeDraft(ed));\n }\n onSubmitted?.();\n };\n\n // Athena can't be reached (or earlier messages still wait): the message waits in the chat\n // outbox, shown in the queue tray as not sent. The host's pending extras (AthenaChat's\n // uploaded attachments and its quote) wait with it when the host holds them\n // (`holdPendingExtras`). What can't wait (an attachment this composer holds itself, which\n // never reached Athena, or extras a host can't hold) keeps the draft where it is, and the\n // composer says why; such a message first waits for the thread's kept messages to be read,\n // so it goes as before only when Athena answers and nothing older waits.\n const waitingOutbox = outboxRef.current;\n const runtimeAttachments = (aui.composer.getState().attachments?.length ?? 0) > 0;\n const hostExtras = Boolean(hasPendingExtras?.());\n const cannotWait = runtimeAttachments || (hostExtras && !holdPendingExtras);\n if (waitingOutbox && cannotWait) await chatOutboxRead(waitingOutbox);\n if (waitingOutbox?.shouldHold()) {\n if (cannotWait) {\n onAttachmentError?.(\n waitingOutbox.getSnapshot().rows.length > 0\n ? WAITING_EXTRAS_MESSAGE\n : OFFLINE_EXTRAS_MESSAGE,\n );\n return;\n }\n if (!text && !(hostExtras && holdPendingExtras)) return;\n // Attachments a held message gave back to this draft (Cancel, Edit) and still in it: the\n // message held now names them again, so they are asked about again before it goes.\n const attachments = takeRestoredAttachments({\n store: handoff,\n threadId,\n assetIdsInDraft: assetMentionIds(ed),\n });\n if (hostExtras && holdPendingExtras) {\n if (\n !holdPendingExtras({\n outbox: waitingOutbox,\n send: { text, draftMarkdown },\n attachments,\n })\n ) {\n return;\n }\n } else {\n waitingOutbox.hold({\n text,\n composerMarkdown: draftMarkdown,\n metadata: withDeepAgentComposerMarkdown({\n metadata: undefined,\n text,\n markdown: draftMarkdown,\n }),\n ...(attachments.length > 0 && { attachments }),\n });\n }\n consumeSubmittedDraft();\n return;\n }\n\n // Interception carries TEXT only: a draft with pending attachments\n // (screenshots, files) must ride the composer-runtime send that\n // bundles them, or the attachments would silently vanish. Attachment\n // state is read only when a host actually intercepts. It runs before\n // the empty check because a host may compose extras of its own into\n // an otherwise empty draft (AthenaChat's quote and attachment pills).\n if (interceptSubmit) {\n const hasAttachments =\n (aui.composer.getState().attachments?.length ?? 0) > 0;\n if (!hasAttachments) {\n // A host can wait for server acceptance. Keep the captured draft\n // read-only until that decision, so clearing it cannot erase typing\n // accepted after the capture. A changed disabled prop still wins.\n interceptionPendingRef.current = true;\n setEditorEditable(ed);\n let intercepted: boolean;\n try {\n intercepted = await interceptSubmit(text, draftMarkdown);\n } finally {\n interceptionPendingRef.current = false;\n if (!ed.isDestroyed) setEditorEditable(ed);\n }\n if (ed.isDestroyed) return;\n if (intercepted) {\n consumeSubmittedDraft();\n return;\n }\n }\n }\n\n if (!text) return;\n if (!composerInput.canSend) return;\n\n // A send statewire hands back (refused during a reconnect) is restored\n // from the draft it was sent from, not parsed from its verbatim text;\n // the message carries that draft so its bubble shows it as typed.\n prepareComposerSend({ threadId, text, draftMarkdown });\n composerInput.setText(text);\n composerInput.send({ steer: false });\n\n consumeSubmittedDraft();\n } finally {\n submitInFlightRef.current = false;\n }\n }, [\n clearImagePreviews,\n composerInput,\n disabled,\n handoff,\n hasPendingExtras,\n holdPendingExtras,\n interceptSubmit,\n onAttachmentError,\n onDraftStateChange,\n onSubmitted,\n setEditorEditable,\n threadId,\n waitForHostUploads,\n ]);\n\n const handleSubmitRef = useRef(handleSubmit);\n handleSubmitRef.current = handleSubmit;\n\n const addAttachment = useCallback(\n (file: File) => {\n let previewKey: string | undefined;\n if (\n showImagePreviews &&\n file.type.startsWith(\"image/\") &&\n typeof URL.createObjectURL === \"function\"\n ) {\n previewKey = crypto.randomUUID();\n replaceImagePreviews([\n ...imagePreviewsRef.current,\n {\n key: previewKey,\n file,\n name: file.name || \"Pasted image\",\n src: URL.createObjectURL(file),\n },\n ]);\n }\n\n return pendingUploadsRef.current\n .track(aui.composer.addAttachment(file))\n .catch((error: unknown) => {\n if (previewKey) {\n removeImagePreviews((preview) => preview.key === previewKey);\n }\n throw error;\n });\n },\n [aui, removeImagePreviews, replaceImagePreviews, showImagePreviews],\n );\n\n // Handle paste events — intercept images from clipboard and add as attachments\n const handlePaste = useCallback(\n (_view: unknown, event: ClipboardEvent) => {\n const clipboardData = event.clipboardData;\n if (!clipboardData) return false;\n\n const images = extractPastedImages({ clipboardData });\n const otherFiles = attachAnyFile\n ? extractPastedNonImageFiles({ clipboardData })\n : [];\n if (images.length === 0 && otherFiles.length === 0) return false;\n // Office and spreadsheet copies put the cells' text beside a bitmap of\n // them: the text is what the user copied, so the editor's native paste\n // keeps it and the incidental screenshot is left alone. A copied image\n // file's own name (Finder, Explorer) is not such text. Only a bitmap\n // competes with text; a copied document is the thing being pasted.\n if (\n otherFiles.length === 0 &&\n clipboardHasMeaningfulText({\n clipboardData,\n pastedFileNames: images.map((image) => image.originalName),\n })\n ) {\n return false;\n }\n event.preventDefault();\n\n const files = [...images.map((image) => image.file), ...otherFiles];\n if (fileIntake) {\n fileIntake.onPaste(files);\n return true;\n }\n for (const file of files) {\n void addAttachment(file).catch((error: unknown) => {\n onAttachmentError?.(\n isImageFile(file)\n ? \"Couldn’t paste that image.\"\n : \"Couldn’t paste that file.\",\n );\n athenaDiagnostics.error(\n \"composer.attachment.error\",\n error,\n { code: \"attachment_failed\", message: \"Pasted file upload failed\" },\n { source: \"paste\", type: file.type },\n );\n });\n }\n return true;\n },\n [addAttachment, attachAnyFile, fileIntake, onAttachmentError],\n );\n\n // Without a host intake the composer attaches dropped files itself; a host\n // intake without `onDrop` leaves drops to the enclosing drop zone.\n const addDroppedFiles = useCallback(\n (files: FileList | readonly File[]) => {\n const attachable = Array.from(files).filter(\n (file) => attachAnyFile || isImageFile(file),\n );\n if (attachable.length === 0) return false;\n if (fileIntake) {\n if (!fileIntake.onDrop) return false;\n fileIntake.onDrop(attachable);\n return true;\n }\n for (const file of attachable) {\n void addAttachment(file).catch((error: unknown) => {\n onAttachmentError?.(\n isImageFile(file)\n ? \"Couldn’t attach that dropped image.\"\n : \"Couldn’t attach that dropped file.\",\n );\n athenaDiagnostics.error(\n \"composer.attachment.error\",\n error,\n { code: \"attachment_failed\", message: \"Dropped file upload failed\" },\n { source: \"drop\", type: file.type },\n );\n });\n }\n return true;\n },\n [addAttachment, attachAnyFile, fileIntake, onAttachmentError],\n );\n\n // Read through a ref: the mention inserter is defined after the editor.\n const insertAssetMentionRef = useRef<(asset: UploadedChatAsset) => void>(\n () => {},\n );\n\n // A Spaces asset dragged in from Olympus becomes a mention. Without this,\n // ProseMirror pastes the drag's text — FlexLayout's `--flexlayout--`.\n const handleAssetDrop = useCallback(\n (event: DragEvent, view?: EditorView): boolean => {\n if (disabledRef.current || !event.dataTransfer) return false;\n const dropped = readAthenaAssetDrop(event.dataTransfer);\n if (!dropped) return false;\n event.preventDefault();\n if (dropped.kind !== \"asset\") return true;\n const position = view?.posAtCoords({\n left: event.clientX,\n top: event.clientY,\n });\n if (view) {\n // A drop outside the text (e.g. on the preview strip) lands at the\n // end rather than replacing whatever is selected.\n const { state } = view;\n view.dispatch(\n state.tr.setSelection(\n position\n ? Selection.near(state.doc.resolve(position.pos))\n : Selection.atEnd(state.doc),\n ),\n );\n }\n insertAssetMentionRef.current(dropped.asset);\n return true;\n },\n [],\n );\n\n // ProseMirror owns drops that land in the editable surface. The React\n // wrapper below catches the rest of the composer area; defaultPrevented\n // keeps one gesture from being attached twice.\n const handleDrop = useCallback(\n (view: EditorView, event: DragEvent) => {\n if (handleAssetDrop(event, view)) return true;\n const files = event.dataTransfer?.files;\n if (!files?.length) return false;\n const handled = addDroppedFiles(files);\n if (handled) event.preventDefault();\n return handled;\n },\n [addDroppedFiles, handleAssetDrop],\n );\n\n const handleComposerDrop = useCallback(\n (event: ReactDragEvent<HTMLDivElement>) => {\n if (event.defaultPrevented) return;\n if (handleAssetDrop(event.nativeEvent, editorRef.current?.view)) return;\n if (addDroppedFiles(event.dataTransfer.files)) event.preventDefault();\n },\n [addDroppedFiles, handleAssetDrop],\n );\n\n // Read through a ref so a host can change the hint (e.g. while a run is\n // live) without rebuilding the editor; the effect below repaints it.\n const placeholderRef = useRef(placeholder);\n placeholderRef.current = placeholder;\n const editor = useEditor({\n editable: !disabled,\n extensions: [\n ...createChatTextExtensions(),\n ComposerDraftWhitespace,\n Placeholder.configure({ placeholder: () => placeholderRef.current }),\n MentionSuggestionsExtension.configure({\n store,\n callbacks: callbacksRef.current,\n }),\n SubmitKeybind.configure({\n onSubmit: () => void handleSubmitRef.current(),\n isMentionOpen: () => popupOpenRef.current,\n }),\n ],\n editorProps: {\n attributes: {\n class: cn(CHAT_TEXT_CLASS, \"w-full resize-none bg-transparent px-1.5 py-2 outline-none\"),\n \"data-testid\": \"athena-chat-composer\",\n },\n handlePaste,\n handleDrop,\n },\n onUpdate: ({ editor: updatedEditor }) => {\n const nextText = serializeDraft(updatedEditor);\n lastEmittedMarkdownRef.current = nextText;\n if (!applyingRuntimeTextRef.current) {\n composerInput.setText(nextText);\n }\n onDraftStateChange?.(nextText.trim().length > 0);\n\n if (showImagePreviews) {\n const mentionedAssetIds = new Set<string>();\n updatedEditor.state.doc.descendants((node) => {\n if (\n node.type.name === \"mention\" &&\n node.attrs.type === \"asset\" &&\n typeof node.attrs.id === \"string\"\n ) {\n mentionedAssetIds.add(node.attrs.id);\n }\n });\n removeImagePreviews(\n (preview) =>\n preview.assetId !== undefined &&\n !mentionedAssetIds.has(preview.assetId),\n );\n }\n },\n immediatelyRender: false,\n });\n\n // Keep ref in sync so handleSubmit always has the editor\n editorRef.current = editor;\n\n useEffect(() => {\n if (editor && !editor.isDestroyed) setEditorEditable(editor);\n }, [disabled, editor, setEditorEditable]);\n\n // The placeholder decoration is recomputed per transaction; an empty one\n // repaints a changed hint at once.\n useEffect(() => {\n if (!editor || editor.isDestroyed) return;\n editor.view.dispatch(editor.state.tr.setMeta(\"addToHistory\", false));\n }, [editor, placeholder]);\n\n // This rich editor replaces ComposerPrimitive.Input, so it must mirror its\n // draft into assistant-ui's composer state. Statewire restores that state\n // when a send is rejected during reconnect, and a host may write to it\n // (`useAppendToComposer`); mirroring it back into Tiptap — parsed as the\n // Markdown it was serialized to, mention links included — preserves the\n // user's message instead of leaving an empty composer. A send this composer\n // made (its text is verbatim) that comes back to the empty composer soon\n // after loads the draft it was sent from (`draftForReturnedSend`); any other\n // value, a host's prefill included, is parsed as Markdown. Our own echo is\n // skipped on the ref; a restore's re-serialization may differ from the\n // value byte-for-byte, so the ref takes that form to stop a second pass,\n // and a returned send already loaded from its draft is not loaded again.\n useEffect(() => {\n if (!editor) return;\n const value = composerInput.value;\n if (value === lastEmittedMarkdownRef.current) return;\n if (value === restoredSendRef.current) return;\n restoredSendRef.current = null;\n const currentMarkdown = serializeDraft(editor);\n lastEmittedMarkdownRef.current = currentMarkdown;\n // Statewire puts a refused send back only into an empty composer.\n const returnedDraft: string | null = editor.isEmpty\n ? draftForReturnedSend({ threadId, text: value })\n : null;\n const restored = returnedDraft ?? value;\n if (restored === currentMarkdown) return;\n // React node views flush their mounts synchronously. Restore outside\n // React's effect phase, and cancel a restore superseded by a newer draft.\n let cancelled = false;\n queueMicrotask(() => {\n if (cancelled || editor.isDestroyed) return;\n applyingRuntimeTextRef.current = true;\n try {\n editor.commands.setContent(restored, { emitUpdate: false });\n lastEmittedMarkdownRef.current = serializeDraft(editor);\n if (returnedDraft !== null) restoredSendRef.current = value;\n } finally {\n applyingRuntimeTextRef.current = false;\n }\n onDraftStateChange?.(value.trim().length > 0);\n // A host prefill (`useAppendToComposer(..., { focus: true })`) asked\n // for the caret after its text: now that the text is on screen.\n if (handoff?.focusOnNextMirror) {\n handoff.focusOnNextMirror = false;\n editor.commands.focus(\"end\");\n }\n });\n return () => { cancelled = true; };\n }, [composerInput.value, editor, handoff, onDraftStateChange, threadId]);\n\n // Lets host UI outside the chat place the caret at the end of the draft\n // (`useAppendToComposer` focus option) without reaching into the DOM.\n useEffect(() => {\n if (!editor || !handoff) return;\n handoff.focusEnd = () => {\n if (!editor.isDestroyed) editor.commands.focus(\"end\");\n };\n // `useFocusComposer` asked before this editor mounted.\n if (handoff.focusOnMount) {\n handoff.focusOnMount = false;\n handoff.focusEnd();\n }\n return () => {\n handoff.focusEnd = null;\n };\n }, [editor, handoff]);\n\n const insertAssetMention = useCallback(\n (asset: UploadedChatAsset, sourceFile?: File) => {\n const currentEditor = editorRef.current;\n if (!currentEditor) throw new Error(\"The chat composer is not ready.\");\n currentEditor\n .chain()\n .focus()\n .insertContent({\n type: \"mention\",\n attrs: {\n type: \"asset\",\n name: asset.title,\n id: asset.id,\n assetType: asset.assetType,\n displayAsPreview:\n showImagePreviews && sourceFile?.type.startsWith(\"image/\"),\n },\n })\n // A text node, not a string: the Markdown extension parses string\n // content as Markdown, which would drop a lone space.\n .insertContent({ type: \"text\", text: \" \" })\n .run();\n\n if (\n showImagePreviews &&\n sourceFile?.type.startsWith(\"image/\") &&\n typeof URL.createObjectURL === \"function\"\n ) {\n const existing = imagePreviewsRef.current.find(\n (preview) => preview.file === sourceFile,\n );\n if (existing) {\n replaceImagePreviews(\n imagePreviewsRef.current.map((preview) =>\n preview.key === existing.key\n ? { ...preview, assetId: asset.id, name: asset.title }\n : preview,\n ),\n );\n } else {\n replaceImagePreviews([\n ...imagePreviewsRef.current,\n {\n key: crypto.randomUUID(),\n file: sourceFile,\n name: asset.title,\n src: URL.createObjectURL(sourceFile),\n assetId: asset.id,\n },\n ]);\n }\n }\n },\n [replaceImagePreviews, showImagePreviews],\n );\n insertAssetMentionRef.current = insertAssetMention;\n\n const removeImagePreview = useCallback(\n (preview: ComposerImagePreview) => {\n if (!preview.assetId) return;\n const currentEditor = editorRef.current;\n if (!currentEditor) return;\n const positions: Array<{ from: number; to: number }> = [];\n currentEditor.state.doc.descendants((node, position) => {\n if (\n node.type.name === \"mention\" &&\n node.attrs.type === \"asset\" &&\n node.attrs.id === preview.assetId\n ) {\n positions.push({ from: position, to: position + node.nodeSize });\n }\n });\n let transaction = currentEditor.state.tr;\n for (const position of positions.reverse()) {\n transaction = transaction.delete(position.from, position.to);\n }\n if (transaction.docChanged) currentEditor.view.dispatch(transaction);\n removeImagePreviews((candidate) => candidate.key === preview.key);\n currentEditor.commands.focus();\n },\n [removeImagePreviews],\n );\n\n useEffect(\n () => registerChatAssetMentionHandler(threadId, insertAssetMention),\n [insertAssetMention, threadId],\n );\n\n const openMentionMenu = useCallback(() => {\n if (disabled) return;\n const currentEditor = editorRef.current;\n if (!currentEditor || currentEditor.isDestroyed) return;\n if (popupOpenRef.current) {\n currentEditor.commands.focus();\n return;\n }\n // The suggestion plugin only opens on an `@` that starts a word\n // (`allowedPrefixes`), so a trigger typed right after text — or after a\n // mention chip, which `textBetween` reports as its leaf text — gets the\n // separating space a user would type.\n const { from } = currentEditor.state.selection;\n const before =\n from > 0\n ? currentEditor.state.doc.textBetween(from - 1, from, \"\\0\", \"\\0\")\n : \"\";\n const needsSpace = before.length > 0 && !/[\\s([{\"']/.test(before);\n currentEditor\n .chain()\n .focus()\n .insertContent({ type: \"text\", text: needsSpace ? \" @\" : \"@\" })\n .run();\n }, [disabled]);\n\n const appendText = useCallback((text: string) => {\n const currentEditor = editorRef.current;\n if (currentEditor) appendPlainText(currentEditor, text);\n }, []);\n\n const captureSend = useCallback((): ComposerSend | null => {\n const currentEditor = editorRef.current;\n return currentEditor && !currentEditor.isDestroyed\n ? captureComposerSend(currentEditor)\n : null;\n }, []);\n\n useImperativeHandle(\n outerRef,\n () => ({\n submit: handleSubmit,\n addAttachment,\n insertAssetMention,\n openMentionMenu,\n appendText,\n captureSend,\n }),\n [\n addAttachment,\n appendText,\n captureSend,\n handleSubmit,\n insertAssetMention,\n openMentionMenu,\n ],\n );\n\n return (\n <>\n <style>{MENTION_STYLES}</style>\n <div\n className={cn(\n \"athena-chat-composer flex-1 min-w-0\",\n appearance === \"paper\" && \"athena-chat-composer--paper\",\n showImagePreviews && \"image-preview-composer\",\n )}\n aria-label=\"Message composer\"\n aria-disabled={disabled}\n onDragOver={(event) => {\n const types = Array.from(event.dataTransfer.types);\n if (\n types.includes(\"Files\") ||\n (!disabled && isAthenaAssetDrag(types))\n ) {\n event.preventDefault();\n event.dataTransfer.dropEffect = \"copy\";\n }\n }}\n onDrop={handleComposerDrop}\n >\n <ImagePreviewStrip\n previews={imagePreviews}\n onRemove={removeImagePreview}\n />\n <EditorContent editor={editor} />\n </div>\n\n {/* Olympus-style mention popup */}\n {popupOpen && popupProps && editor && (\n <MentionSuggestionPopup clientRect={popupProps.clientRect}>\n <MentionSuggestionList\n ref={listRef}\n store={store}\n editor={editor}\n query={popupProps.query}\n command={(item: MenuItem) => popupProps.command(item)}\n closeMenu={() => {\n setPopupOpen(false);\n editor.commands.focus();\n }}\n />\n </MentionSuggestionPopup>\n )}\n </>\n );\n },\n);\n\nTiptapComposer.displayName = \"TiptapComposer\";\n"],"names":["Extension","runInputRulesOnEnter","serializeComposerDraft","Selection","jsx","jsxs","LoaderCircleIcon","XIcon","forwardRef","useAui","useDeepAgentChatOutboxContext","useRef","unstable_useComposerInput","useComposerHandoffStore","PendingAttachmentUploads","useCallback","useStatewireSessionLane","useState","useEffect","useMentionSuggestions","captureComposerSend","takeRestoredAttachments","withDeepAgentComposerMarkdown","prepareComposerSend","extractPastedImages","extractPastedNonImageFiles","clipboardHasMeaningfulText","isImageFile","athenaDiagnostics","readAthenaAssetDrop","state","useEditor","createChatTextExtensions","ComposerDraftWhitespace","MentionSuggestionsExtension","cn","CHAT_TEXT_CLASS","draftForReturnedSend","registerChatAssetMentionHandler","useImperativeHandle","Fragment","isAthenaAssetDrag","EditorContent","MentionSuggestionPopup","MentionSuggestionList"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAiGA,MAAM,gBAAgBA,KAAAA,UAAU,OAA+D;AAAA,EAC7F,MAAM;AAAA,EACN,UAAU;AAAA,EACV,aAAa;AACX,WAAO,EAAE,UAAU,MAAM;AAAA,IAAC,GAAG,eAAe,MAAM,MAAA;AAAA,EACpD;AAAA,EACA,uBAAuB;AACrB,WAAO;AAAA,MACL,OAAO,MAAM;AAEX,YAAI,KAAK,QAAQ,cAAA,EAAiB,QAAO;AAEzC,YAAIC,0CAAqB,KAAK,MAAM,EAAG,QAAO;AAG9C,YAAI,CAAC,YAAY,YAAY,aAAa,SAAS,YAAY,EAAE;AAAA,UAC/D,CAAC,SAAS,KAAK,OAAO,SAA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vC,2BAAAA;AAAAA,QAACwC,sBAAAA;AAAAA,QAAA;AAAA,UACC,KAAK;AAAA,UACL;AAAA,UACA;AAAA,UACA,OAAO,WAAW;AAAA,UAClB,SAAS,CAAC,SAAmB,WAAW,QAAQ,IAAI;AAAA,UACpD,WAAW,MAAM;AACf,yBAAa,KAAK;AAClB,mBAAO,SAAS,MAAA;AAAA,UAClB;AAAA,QAAA;AAAA,MAAA,EACF,CACF;AAAA,IAAA,GAEJ;AAAA,EAEF;AACF;AAEA,eAAe,cAAc;;;;;"}
1
+ {"version":3,"file":"tiptap-composer.cjs","sources":["../../../src/chat-ui/composer/tiptap-composer.tsx"],"sourcesContent":["/**\n * Tiptap Composer — Full Olympus mention system integration\n *\n * Uses the ported Olympus infrastructure:\n * - MentionSuggestionList (with scope navigation, breadcrumbs, keyboard nav)\n * - MentionSuggestionPopup (Floating UI positioning)\n * - MentionSuggestionsExtension (Tiptap @ trigger)\n * - MentionExtension (inline mention chips)\n * - useMentionSuggestions (full Olympus categories + async data)\n *\n * Auth credentials for GraphQL are provided via MentionAuthCtx, and the host\n * app (Chrome side panel, Office task pane, the SDK's AthenaChat) supplies any\n * host-only mention items — browser tabs through `webpages`, its own Tools /\n * Toolkits list through `tools`.\n *\n * The draft serializes to Markdown through `tiptap-markdown`, so pasted\n * hyperlinks keep their URL, formatting marks survive, paragraphs stay\n * separated, and a mention is the `[@Name](url)` link the message renderer\n * parses back into a chip. Send delivers that Markdown with every plain-text\n * run written exactly as typed (`serializeComposerMessage`), as the Olympus\n * chat composer does, and the message carries the draft it was sent from\n * (`metadata.composer_markdown`, only when the two differ) so its bubble\n * shows the text exactly as typed.\n */\n\nimport { athenaDiagnostics } from \"../../diagnostics/athena-diagnostics\";\nimport {\n clipboardHasMeaningfulText,\n extractPastedImages,\n extractPastedNonImageFiles,\n isImageFile,\n} from \"../../composer/clipboard\";\nimport {\n useRef,\n useState,\n useCallback,\n useEffect,\n forwardRef,\n useImperativeHandle,\n type DragEvent as ReactDragEvent,\n} from \"react\";\nimport { useEditor, EditorContent } from \"@tiptap/react\";\nimport Placeholder from \"@tiptap/extension-placeholder\";\nimport { Extension, type Editor } from \"@tiptap/core\";\nimport { unstable_useComposerInput, useAui } from \"@assistant-ui/react\";\nimport {\n takeRestoredAttachments,\n useComposerHandoffStore,\n} from \"../../composer/composer-handoff\";\nimport { useStatewireSessionLane } from \"../../runtime/statewire-session-lane\";\nimport { LoaderCircleIcon, XIcon } from \"lucide-react\";\nimport { cn } from \"../../lib/utils\";\nimport { ImageViewer } from \"../../ui/image-viewer\";\nimport { CHAT_TEXT_CLASS, createChatTextExtensions } from \"../rich-text/chat-text-schema\";\nimport {\n MentionSuggestionsExtension,\n type MentionSuggestionCallbacks,\n type MentionSuggestionRenderProps,\n} from \"../mentions/suggestions/mention-suggestions.extension\";\nimport { MentionSuggestionPopup } from \"../mentions/suggestions/components/mention-suggestion-popup\";\nimport {\n MentionSuggestionList,\n} from \"../mentions/suggestions/components/mention-suggestion-list\";\nimport {\n useMentionSuggestions,\n type MentionRootCategory,\n} from \"../mentions/suggestions/data/use-mention-suggestions\";\nimport type {\n MentionTool,\n MenuItem,\n WebpageMention,\n} from \"../mentions/suggestions/data/types\";\nimport type { KeyboardNavigationHandle } from \"../mentions/suggestions/components/use-keyboard-navigation\";\nimport { Selection } from \"@tiptap/pm/state\";\nimport type { EditorView } from \"@tiptap/pm/view\";\nimport {\n isAthenaAssetDrag,\n readAthenaAssetDrop,\n registerChatAssetMentionHandler,\n type UploadedChatAsset,\n type ChatOutbox,\n type ChatOutboxAttachment,\n useDeepAgentChatOutboxContext,\n withDeepAgentComposerMarkdown,\n} from \"@athenaintel/agent-runtime\";\nimport {\n attachedMessageBehindWaiting,\n attachedMessageNeedsConnection,\n type LabelCopy,\n} from \"@athenaintel/agent-runtime/offline-status\";\nimport {\n captureComposerSend,\n ComposerDraftWhitespace,\n type ComposerSend,\n draftForReturnedSend,\n prepareComposerSend,\n serializeComposerDraft,\n} from \"./composer-message\";\nimport { PendingAttachmentUploads } from \"./pending-attachment-uploads\";\nimport { runInputRulesOnEnter } from \"./run-input-rules-on-enter\";\n\n// ── Submit keybind extension ──\n\nconst SubmitKeybind = Extension.create<{ onSubmit: () => void; isMentionOpen: () => boolean }>({\n name: \"submitKeybind\",\n priority: 1000,\n addOptions() {\n return { onSubmit: () => {}, isMentionOpen: () => false };\n },\n addKeyboardShortcuts() {\n return {\n Enter: () => {\n // Don't submit when the mention popup is open — let it handle Enter\n if (this.options.isMentionOpen()) return false;\n // A typed \"1.\" or \"-\" starts a list rather than sending.\n if (runInputRulesOnEnter(this.editor)) return true;\n // Let the schema's keymaps continue lists, insert code newlines, and\n // split paragraphs inside structured blocks, as in the web composer.\n if ([\"listItem\", \"taskItem\", \"codeBlock\", \"table\", \"blockquote\"].some(\n (node) => this.editor.isActive(node),\n )) return false;\n this.options.onSubmit();\n return true;\n },\n \"Shift-Enter\": () => {\n return this.editor.commands.newlineInCode() || this.editor.commands.setHardBreak();\n },\n };\n },\n});\n\n// ── CSS for mention chips + editor ──\n\nconst MENTION_STYLES = `\n .image-preview-composer .mention-chip[data-display-as-preview=\"true\"] {\n display: none;\n }\n /* Scoped to this editor: hosts render other ProseMirror instances on the\n same page (AthenaChat's message renderer), which must keep their own\n height and placeholder rules. */\n .athena-chat-composer .ProseMirror {\n outline: none;\n min-height: 36px;\n max-height: 120px;\n overflow-y: auto;\n }\n .athena-chat-composer .ProseMirror p.is-editor-empty:first-child::before {\n content: attr(data-placeholder);\n float: left;\n color: #9ca3af;\n pointer-events: none;\n height: 0;\n }\n /* The paper appearance (the SDK thread): a taller resting height, room for\n about eight lines before the draft scrolls, and a placeholder at 35% of\n the text colour. Same specificity as the rules above, so order decides. */\n .athena-chat-composer--paper .ProseMirror {\n min-height: 44px;\n max-height: 12rem;\n }\n .athena-chat-composer--paper .ProseMirror p.is-editor-empty:first-child::before {\n color: color-mix(in srgb, currentColor 35%, transparent);\n }\n`;\n\n/**\n * The editor's look. `default` is what the Chrome extension and Office add-in\n * render; `paper` pairs with `ChatComposerDock appearance=\"paper\"`.\n */\nexport type TiptapComposerAppearance = \"default\" | \"paper\";\n\n/**\n * The draft as Markdown, mentions as `[@Name](url)` links: what the composer\n * mirrors into the composer runtime and parses back on a restore\n * (`serializeComposerDraft`, which reads back into the same document). Send\n * delivers it with plain text written as typed (`serializeComposerMessage`).\n */\nexport function serializeDraft(editor: Editor): string {\n return serializeComposerDraft(editor);\n}\n\n/**\n * Append `text` to the editor's draft as typed plain text — never read as\n * Markdown — one space after any text already on the last line, the way a\n * dictated phrase joins the draft. Returns whether anything was added.\n */\nfunction appendPlainText(editor: Editor, text: string): boolean {\n const words = text.trim();\n if (!words || editor.isDestroyed) return false;\n const end = Selection.atEnd(editor.state.doc);\n const before = end.$from.nodeBefore;\n const needsSpace =\n before !== null &&\n before.type.name !== \"hardBreak\" &&\n !(before.isText && /\\s$/.test(before.text ?? \"\"));\n editor\n .chain()\n .setTextSelection(end.from)\n // A text node, not a string: the Markdown extension parses string content\n // as Markdown, which would turn spoken words into formatting.\n .insertContent({ type: \"text\", text: needsSpace ? ` ${words}` : words })\n .run();\n return true;\n}\n\n/**\n * A host's own intake for the files pasted into or dropped on the composer\n * (AthenaChat uploads them into its attachment pills). Without `onDrop` the\n * composer leaves drops untouched so an enclosing drop zone receives them.\n */\nexport interface ComposerFileIntake {\n onPaste: (files: readonly File[]) => void;\n onDrop?: (files: readonly File[]) => void;\n}\n\n// ── Main component ──\n\nexport interface TiptapComposerHandle {\n submit: () => Promise<void>;\n addAttachment: (file: File) => Promise<void>;\n insertAssetMention: (asset: UploadedChatAsset) => void;\n /**\n * Focuses the editor and types the `@` trigger at the caret (after a space\n * when the caret follows a word), opening the mention menu — the toolbar's\n * `@` button. A no-op while the editor is disabled or the menu is open.\n * Optional on the type so hosts' handle stand-ins written before it keep\n * type-checking; the composer itself always provides it.\n */\n openMentionMenu?: () => void;\n /**\n * Appends `text` to the draft as typed plain text, never read as Markdown,\n * one space after any text on the draft's last line — how dictated words\n * join the draft. Optional on the type, like `openMentionMenu`.\n */\n appendText?: (text: string) => void;\n /**\n * The draft as a send would deliver it — `text` with plain text exactly as\n * typed, `draftMarkdown` the same document as Markdown that reads back into\n * it — or `null` before the editor mounts. For a host that sends the draft\n * itself (AthenaChat's dictated send) through `prepareComposerSend`.\n */\n captureSend?: () => ComposerSend | null;\n}\n\nexport interface TiptapComposerProps {\n placeholder?: string;\n threadId: string;\n disabled?: boolean;\n /**\n * Holds the send, not the draft: Enter and `submit()` send nothing and leave the draft as typed,\n * while typing goes on. For a host that keeps nothing while Athena can't be reached (no chat\n * outbox: the Chrome side panel, the Office task pane); its send control says why\n * (`ComposerSendOrStop`'s `sendBlockedReason`).\n */\n sendBlocked?: boolean;\n /**\n * Why the `@` menu can't ask Athena right now, or `null` while it can: a host that keeps nothing\n * while Athena can't be reached passes `NEEDS_CONNECTION` (`@athenaintel/agent-runtime/offline-status`).\n * The menu then fetches nothing; the host's own items (its tabs, its tool list) and what it\n * already loaded still show, and a search or a category that would load from Athena says this\n * instead of spinning or \"No results found\". Once it clears, lookups that failed meanwhile run again.\n */\n mentionSearchUnavailable?: LabelCopy | null;\n /** Editor look; defaults to the side-panel / task-pane editor. */\n appearance?: TiptapComposerAppearance;\n /** Host-provided browser-tab mentions; empty in hosts without tab access. */\n webpages?: readonly WebpageMention[];\n /**\n * Host-provided Tools / Toolkits mention candidates. When set they replace\n * the server tool catalog for those categories (see `useMentionSuggestions`).\n */\n tools?: readonly MentionTool[];\n rootCategories?: readonly MentionRootCategory[];\n onDraftStateChange?: (hasDraft: boolean) => void;\n /** Show local image thumbnails while mention-backed uploads are in the draft. */\n showImagePreviews?: boolean;\n /**\n * Paste and drop attach files of any type, as Olympus's composer does.\n * Off by default: those hosts attach pasted or dropped images only.\n */\n attachAnyFile?: boolean;\n /** Surface paste/drop attachment failures in host UI as well as diagnostics. */\n onAttachmentError?: (message: string) => void;\n /**\n * Host-owned intake for pasted and dropped files. Without it the composer\n * attaches them itself through `aui.composer.addAttachment`.\n */\n fileIntake?: ComposerFileIntake;\n /**\n * Awaited before every submit (Enter and the imperative handle), after the\n * composer's own pending uploads have settled: a host whose uploads live\n * outside the composer (AthenaChat's attachment pills) resolves once they\n * land, so a send never leaves without its attachment.\n */\n waitForHostUploads?: () => Promise<void> | void;\n /**\n * Optional submit interception: called with the serialized draft — possibly\n * empty, for a host composing its own extras into the send — before the\n * composer-runtime send. Return `true` when the host consumed the draft\n * through another lane (e.g. a live voice session) — the editor clears and\n * the normal send is skipped. Return `false` to fall through unchanged.\n * The editor stays read-only while an asynchronous interception settles.\n * `text` is plain text written exactly as typed (what the model should\n * read); `draftMarkdown` is the same draft with plain text escaped for\n * Markdown (`serializeComposerDraft`), for a host that sends the message\n * itself: `prepareComposerSend` remembers it, so a send handed back loads\n * exactly, and puts it on the message as its composer markdown.\n */\n interceptSubmit?: (text: string, draftMarkdown: string) => boolean | Promise<boolean>;\n /**\n * Whether the host has something pending that rides the next send besides the text (AthenaChat's\n * attachment pills or a quote). While sends are on hold such a message waits in the chat outbox\n * only through {@link TiptapComposerProps.holdPendingExtras}; without it the draft stays and the\n * composer says why (`onAttachmentError`).\n */\n hasPendingExtras?: () => boolean;\n /**\n * Holds the draft in the chat outbox together with the host's pending extras (AthenaChat composes\n * its uploaded attachments and its quote around the text, as its send would) and clears them;\n * `true` once held, after which the editor clears. Called while sends are on hold (Athena can't\n * be reached, or earlier messages still wait), only when `hasPendingExtras` says there are some.\n * `attachments` are files already in Athena the draft itself carries (mentions a held message\n * gave back); the held message names them with the host's own.\n */\n holdPendingExtras?: (args: {\n outbox: ChatOutbox;\n send: ComposerSend;\n attachments: ChatOutboxAttachment[];\n }) => boolean;\n /**\n * Called after a draft has left the editor — through the composer-runtime\n * send or a host interception — from Enter and the imperative handle alike.\n * Hosts use it for per-send UI such as a first-use keyboard hint.\n */\n onSubmitted?: () => void;\n}\n\n/** The assets the draft mentions (asset mention chips), by id. */\nfunction assetMentionIds(editor: Editor): Set<string> {\n const ids = new Set<string>();\n editor.state.doc.descendants((node) => {\n if (\n node.type.name === \"mention\" &&\n node.attrs.type === \"asset\" &&\n typeof node.attrs.id === \"string\"\n ) {\n ids.add(node.attrs.id);\n }\n });\n return ids;\n}\n\n/**\n * Resolves once the outbox has read the thread's kept messages (at once when it has), or after\n * `CHAT_OUTBOX_READ_WAIT_MS` (a store that never answers then counts as read: `shouldHold` still\n * holds while Athena can't be reached).\n */\nfunction chatOutboxRead(outbox: ChatOutbox): Promise<void> {\n if (outbox.getSnapshot().loaded) return Promise.resolve();\n return new Promise((resolve) => {\n let stop = (): void => undefined;\n const timer = setTimeout(() => {\n stop();\n resolve();\n }, CHAT_OUTBOX_READ_WAIT_MS);\n stop = outbox.subscribe(() => {\n if (!outbox.getSnapshot().loaded) return;\n clearTimeout(timer);\n stop();\n resolve();\n });\n });\n}\n\n/** The longest a send with an attachment or a quote waits for the outbox's first read. */\nconst CHAT_OUTBOX_READ_WAIT_MS = 2_000;\n\nconst NO_WEBPAGES: readonly WebpageMention[] = [];\n\nexport interface ComposerImagePreview {\n key: string;\n file: File;\n name: string;\n src: string;\n assetId?: string;\n}\n\nfunction revokeImagePreview(src: string): void {\n if (typeof URL.revokeObjectURL === \"function\") URL.revokeObjectURL(src);\n}\n\nexport function ImagePreviewStrip({\n previews,\n onRemove,\n}: {\n previews: readonly ComposerImagePreview[];\n onRemove: (preview: ComposerImagePreview) => void;\n}) {\n // The picture open in the viewer, by its preview's key: removing another\n // picture never moves the viewer to a different one.\n const [viewingKey, setViewingKey] = useState<string | null>(null);\n const viewingIndex = previews.findIndex((preview) => preview.key === viewingKey);\n if (previews.length === 0) return null;\n\n return (\n <>\n <div\n className=\"flex w-full gap-2 overflow-x-auto px-1.5 pb-1 pt-1.5\"\n role=\"list\"\n aria-label=\"Image attachments\"\n >\n {previews.map((preview) => {\n const uploading = preview.assetId === undefined;\n return (\n <div\n key={preview.key}\n className=\"group relative h-16 w-[clamp(76px,30vw,112px)] shrink-0 overflow-hidden rounded-lg border border-neutral-200 bg-neutral-100 shadow-sm\"\n role=\"listitem\"\n >\n <button\n type=\"button\"\n onClick={() => setViewingKey(preview.key)}\n className=\"block size-full cursor-zoom-in focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring\"\n aria-label={`View ${preview.name}`}\n title={`View ${preview.name}`}\n >\n <img\n src={preview.src}\n alt={preview.name}\n className=\"size-full object-cover\"\n draggable={false}\n />\n </button>\n <div className=\"pointer-events-none absolute inset-x-0 bottom-0 truncate bg-gradient-to-t from-black/75 to-transparent px-1.5 pb-1 pt-4 text-[10px] font-medium text-white\">\n {preview.name}\n </div>\n {uploading ? (\n <span\n className=\"absolute left-1 top-1 inline-flex size-5 items-center justify-center rounded-full bg-black/65 text-white\"\n title=\"Uploading image\"\n >\n <LoaderCircleIcon className=\"size-3 animate-spin\" />\n </span>\n ) : (\n <button\n type=\"button\"\n onClick={() => onRemove(preview)}\n className=\"absolute right-1 top-1 inline-flex size-5 items-center justify-center rounded-full bg-black/65 text-white opacity-80 transition-opacity hover:bg-black/80 hover:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white\"\n aria-label={`Remove ${preview.name}`}\n title=\"Remove image\"\n >\n <XIcon className=\"size-3\" />\n </button>\n )}\n </div>\n );\n })}\n </div>\n <ImageViewer\n images={previews}\n index={viewingIndex === -1 ? null : viewingIndex}\n onIndexChange={(index) => setViewingKey(index === null ? null : (previews[index]?.key ?? null))}\n />\n </>\n );\n}\n\nexport const TiptapComposer = forwardRef<\n TiptapComposerHandle,\n TiptapComposerProps\n>(\n (\n {\n placeholder = \"Message Athena... (type @ to mention)\",\n threadId,\n disabled = false,\n sendBlocked = false,\n mentionSearchUnavailable = null,\n appearance = \"default\",\n webpages = NO_WEBPAGES,\n tools,\n rootCategories,\n onDraftStateChange,\n showImagePreviews = false,\n attachAnyFile = false,\n onAttachmentError,\n fileIntake,\n waitForHostUploads,\n interceptSubmit,\n hasPendingExtras,\n holdPendingExtras,\n onSubmitted,\n },\n outerRef,\n ) => {\n const aui = useAui();\n // The thread's chat outbox (a host's `chatOutbox`): a send while Athena can't be reached, or\n // behind messages still waiting, waits there instead of reaching the transport.\n const outbox = useDeepAgentChatOutboxContext();\n const outboxRef = useRef(outbox);\n outboxRef.current = outbox;\n const composerInput = unstable_useComposerInput();\n const handoff = useComposerHandoffStore();\n const applyingRuntimeTextRef = useRef(false);\n // What this editor last mirrored into the composer runtime; a value equal to\n // it is our own echo and needs no re-serialization or restore.\n const lastEmittedMarkdownRef = useRef<string | null>(null);\n // The returned send last loaded from its draft: the runtime still holds its\n // verbatim text, which must not be parsed over the draft on a later pass.\n const restoredSendRef = useRef<string | null>(null);\n const listRef = useRef<KeyboardNavigationHandle>(null);\n const pendingUploadsRef = useRef(new PendingAttachmentUploads());\n const submitInFlightRef = useRef(false);\n const interceptionPendingRef = useRef(false);\n const disabledRef = useRef(disabled);\n disabledRef.current = disabled;\n const setEditorEditable = useCallback((ed: Editor) => {\n ed.setEditable(!disabledRef.current && !interceptionPendingRef.current, false);\n ed.view.dom.setAttribute(\"aria-busy\", String(interceptionPendingRef.current));\n ed.view.dom.setAttribute(\"aria-readonly\", String(!ed.isEditable));\n }, []);\n // Read through a ref: a hold that starts while a send waits for its uploads still holds it.\n const sendBlockedRef = useRef(sendBlocked);\n sendBlockedRef.current = sendBlocked;\n // The provider's session lane (`AthenaProvider`; none for a host's own runtime).\n const sessionLane = useStatewireSessionLane();\n const sessionLaneRef = useRef(sessionLane);\n sessionLaneRef.current = sessionLane;\n const imagePreviewsRef = useRef<ComposerImagePreview[]>([]);\n const [imagePreviews, setImagePreviews] = useState<ComposerImagePreview[]>([]);\n\n const replaceImagePreviews = useCallback((next: ComposerImagePreview[]) => {\n imagePreviewsRef.current = next;\n setImagePreviews(next);\n }, []);\n\n const removeImagePreviews = useCallback(\n (shouldRemove: (preview: ComposerImagePreview) => boolean) => {\n const kept: ComposerImagePreview[] = [];\n let removed = false;\n for (const preview of imagePreviewsRef.current) {\n if (shouldRemove(preview)) {\n revokeImagePreview(preview.src);\n removed = true;\n } else kept.push(preview);\n }\n if (removed) replaceImagePreviews(kept);\n },\n [replaceImagePreviews],\n );\n\n const clearImagePreviews = useCallback(() => {\n removeImagePreviews(() => true);\n }, [removeImagePreviews]);\n\n useEffect(() => clearImagePreviews(), [clearImagePreviews, threadId]);\n useEffect(\n () => () => {\n for (const preview of imagePreviewsRef.current) {\n revokeImagePreview(preview.src);\n }\n imagePreviewsRef.current = [];\n },\n [],\n );\n\n const { store } = useMentionSuggestions({\n webpages,\n tools,\n rootCategories,\n athenaUnavailable: mentionSearchUnavailable,\n });\n\n // Popup state\n const [popupOpen, setPopupOpen] = useState(false);\n const popupOpenRef = useRef(false);\n const [popupProps, setPopupProps] = useState<MentionSuggestionRenderProps | null>(null);\n\n // Suggestion callbacks — drive the popup lifecycle\n const callbacksRef = useRef<MentionSuggestionCallbacks>({\n onStart: (props) => {\n setPopupOpen(true);\n popupOpenRef.current = true;\n setPopupProps(props);\n },\n onUpdate: (props) => {\n setPopupProps(props);\n },\n onKeyDown: (event) => {\n // Route keyboard events to the MentionSuggestionList\n return listRef.current?.onKeyDown(event) ?? false;\n },\n onExit: () => {\n setPopupOpen(false);\n popupOpenRef.current = false;\n setPopupProps(null);\n },\n });\n\n // Editor ref — needed because handleSubmit is created before useEditor returns\n const editorRef = useRef<ReturnType<typeof useEditor>>(null);\n\n // Submit via composer runtime so attachments (screenshots, files) are included.\n // aui.composer.setText() + aui.composer.send() bundles text + pending attachments.\n //\n // Statewire turns a send during an active run into a queued command. Do not\n // cancel first: cancellation aborts the shared run for every connected\n // client and turns a normal queued follow-up into a destructive stop.\n const handleSubmit = useCallback(async () => {\n if (disabled || sendBlockedRef.current) return;\n if (submitInFlightRef.current) return;\n submitInFlightRef.current = true;\n try {\n await pendingUploadsRef.current.waitForIdle();\n await waitForHostUploads?.();\n // The sign-in provider is still resolving who is signed in, so the chat's\n // session lane is pending and a send now would be refused unsent: it waits\n // for the lane with the draft still in the editor, and goes as typed then.\n const lane = sessionLaneRef.current;\n if (lane?.isPending()) await lane.whenKnown();\n if (sendBlockedRef.current) return;\n const ed = editorRef.current;\n if (!ed) return;\n // The model reads the sent text literally, so plain text goes out\n // exactly as typed; the draft keeps its Markdown escaping.\n const { text, draftMarkdown } = captureComposerSend(ed);\n const submittedDocument = ed.state.doc;\n const consumeSubmittedDraft = () => {\n if (ed.state.doc.eq(submittedDocument)) {\n takeRestoredAttachments({ store: handoff, threadId, assetIdsInDraft: new Set() });\n ed.commands.clearContent(false);\n lastEmittedMarkdownRef.current = \"\";\n composerInput.setText(\"\");\n clearImagePreviews();\n onDraftStateChange?.(false);\n } else {\n // Runtime restores and host commands can replace even a read-only\n // editor. Keep that newer draft, including after a fallback send\n // clears the composer's runtime text.\n composerInput.setText(serializeDraft(ed));\n }\n onSubmitted?.();\n };\n\n // Athena can't be reached (or earlier messages still wait): the message waits in the chat\n // outbox, shown in the queue tray as not sent. The host's pending extras (AthenaChat's\n // uploaded attachments and its quote) wait with it when the host holds them\n // (`holdPendingExtras`). What can't wait (an attachment this composer holds itself, which\n // never reached Athena, or extras a host can't hold) keeps the draft where it is, and the\n // composer says why; such a message first waits for the thread's kept messages to be read,\n // so it goes as before only when Athena answers and nothing older waits.\n const waitingOutbox = outboxRef.current;\n const runtimeAttachments = (aui.composer.getState().attachments?.length ?? 0) > 0;\n const hostExtras = Boolean(hasPendingExtras?.());\n const cannotWait = runtimeAttachments || (hostExtras && !holdPendingExtras);\n if (waitingOutbox && cannotWait) await chatOutboxRead(waitingOutbox);\n if (waitingOutbox?.shouldHold()) {\n if (cannotWait) {\n // The words every Athena app uses (`@athenaintel/agent-runtime/offline-status`), naming a\n // quote too: a host's extras can carry one.\n onAttachmentError?.(\n waitingOutbox.getSnapshot().rows.length > 0\n ? attachedMessageBehindWaiting({ withQuote: true })\n : attachedMessageNeedsConnection({ withQuote: true }),\n );\n return;\n }\n if (!text && !(hostExtras && holdPendingExtras)) return;\n // Attachments a held message gave back to this draft (Cancel, Edit) and still in it: the\n // message held now names them again, so they are asked about again before it goes.\n const attachments = takeRestoredAttachments({\n store: handoff,\n threadId,\n assetIdsInDraft: assetMentionIds(ed),\n });\n if (hostExtras && holdPendingExtras) {\n if (\n !holdPendingExtras({\n outbox: waitingOutbox,\n send: { text, draftMarkdown },\n attachments,\n })\n ) {\n return;\n }\n } else {\n waitingOutbox.hold({\n text,\n composerMarkdown: draftMarkdown,\n metadata: withDeepAgentComposerMarkdown({\n metadata: undefined,\n text,\n markdown: draftMarkdown,\n }),\n ...(attachments.length > 0 && { attachments }),\n });\n }\n consumeSubmittedDraft();\n return;\n }\n\n // Interception carries TEXT only: a draft with pending attachments\n // (screenshots, files) must ride the composer-runtime send that\n // bundles them, or the attachments would silently vanish. Attachment\n // state is read only when a host actually intercepts. It runs before\n // the empty check because a host may compose extras of its own into\n // an otherwise empty draft (AthenaChat's quote and attachment pills).\n if (interceptSubmit) {\n const hasAttachments =\n (aui.composer.getState().attachments?.length ?? 0) > 0;\n if (!hasAttachments) {\n // A host can wait for server acceptance. Keep the captured draft\n // read-only until that decision, so clearing it cannot erase typing\n // accepted after the capture. A changed disabled prop still wins.\n interceptionPendingRef.current = true;\n setEditorEditable(ed);\n let intercepted: boolean;\n try {\n intercepted = await interceptSubmit(text, draftMarkdown);\n } finally {\n interceptionPendingRef.current = false;\n if (!ed.isDestroyed) setEditorEditable(ed);\n }\n if (ed.isDestroyed) return;\n if (intercepted) {\n consumeSubmittedDraft();\n return;\n }\n }\n }\n\n if (!text) return;\n if (!composerInput.canSend) return;\n\n // A send statewire hands back (refused during a reconnect) is restored\n // from the draft it was sent from, not parsed from its verbatim text;\n // the message carries that draft so its bubble shows it as typed.\n prepareComposerSend({ threadId, text, draftMarkdown });\n composerInput.setText(text);\n composerInput.send({ steer: false });\n\n consumeSubmittedDraft();\n } finally {\n submitInFlightRef.current = false;\n }\n }, [\n clearImagePreviews,\n composerInput,\n disabled,\n handoff,\n hasPendingExtras,\n holdPendingExtras,\n interceptSubmit,\n onAttachmentError,\n onDraftStateChange,\n onSubmitted,\n setEditorEditable,\n threadId,\n waitForHostUploads,\n ]);\n\n const handleSubmitRef = useRef(handleSubmit);\n handleSubmitRef.current = handleSubmit;\n\n const addAttachment = useCallback(\n (file: File) => {\n let previewKey: string | undefined;\n if (\n showImagePreviews &&\n file.type.startsWith(\"image/\") &&\n typeof URL.createObjectURL === \"function\"\n ) {\n previewKey = crypto.randomUUID();\n replaceImagePreviews([\n ...imagePreviewsRef.current,\n {\n key: previewKey,\n file,\n name: file.name || \"Pasted image\",\n src: URL.createObjectURL(file),\n },\n ]);\n }\n\n return pendingUploadsRef.current\n .track(aui.composer.addAttachment(file))\n .catch((error: unknown) => {\n if (previewKey) {\n removeImagePreviews((preview) => preview.key === previewKey);\n }\n throw error;\n });\n },\n [aui, removeImagePreviews, replaceImagePreviews, showImagePreviews],\n );\n\n // Handle paste events — intercept images from clipboard and add as attachments\n const handlePaste = useCallback(\n (_view: unknown, event: ClipboardEvent) => {\n const clipboardData = event.clipboardData;\n if (!clipboardData) return false;\n\n const images = extractPastedImages({ clipboardData });\n const otherFiles = attachAnyFile\n ? extractPastedNonImageFiles({ clipboardData })\n : [];\n if (images.length === 0 && otherFiles.length === 0) return false;\n // Office and spreadsheet copies put the cells' text beside a bitmap of\n // them: the text is what the user copied, so the editor's native paste\n // keeps it and the incidental screenshot is left alone. A copied image\n // file's own name (Finder, Explorer) is not such text. Only a bitmap\n // competes with text; a copied document is the thing being pasted.\n if (\n otherFiles.length === 0 &&\n clipboardHasMeaningfulText({\n clipboardData,\n pastedFileNames: images.map((image) => image.originalName),\n })\n ) {\n return false;\n }\n event.preventDefault();\n\n const files = [...images.map((image) => image.file), ...otherFiles];\n if (fileIntake) {\n fileIntake.onPaste(files);\n return true;\n }\n for (const file of files) {\n void addAttachment(file).catch((error: unknown) => {\n onAttachmentError?.(\n isImageFile(file)\n ? \"Couldn’t paste that image.\"\n : \"Couldn’t paste that file.\",\n );\n athenaDiagnostics.error(\n \"composer.attachment.error\",\n error,\n { code: \"attachment_failed\", message: \"Pasted file upload failed\" },\n { source: \"paste\", type: file.type },\n );\n });\n }\n return true;\n },\n [addAttachment, attachAnyFile, fileIntake, onAttachmentError],\n );\n\n // Without a host intake the composer attaches dropped files itself; a host\n // intake without `onDrop` leaves drops to the enclosing drop zone.\n const addDroppedFiles = useCallback(\n (files: FileList | readonly File[]) => {\n const attachable = Array.from(files).filter(\n (file) => attachAnyFile || isImageFile(file),\n );\n if (attachable.length === 0) return false;\n if (fileIntake) {\n if (!fileIntake.onDrop) return false;\n fileIntake.onDrop(attachable);\n return true;\n }\n for (const file of attachable) {\n void addAttachment(file).catch((error: unknown) => {\n onAttachmentError?.(\n isImageFile(file)\n ? \"Couldn’t attach that dropped image.\"\n : \"Couldn’t attach that dropped file.\",\n );\n athenaDiagnostics.error(\n \"composer.attachment.error\",\n error,\n { code: \"attachment_failed\", message: \"Dropped file upload failed\" },\n { source: \"drop\", type: file.type },\n );\n });\n }\n return true;\n },\n [addAttachment, attachAnyFile, fileIntake, onAttachmentError],\n );\n\n // Read through a ref: the mention inserter is defined after the editor.\n const insertAssetMentionRef = useRef<(asset: UploadedChatAsset) => void>(\n () => {},\n );\n\n // A Spaces asset dragged in from Olympus becomes a mention. Without this,\n // ProseMirror pastes the drag's text — FlexLayout's `--flexlayout--`.\n const handleAssetDrop = useCallback(\n (event: DragEvent, view?: EditorView): boolean => {\n if (disabledRef.current || !event.dataTransfer) return false;\n const dropped = readAthenaAssetDrop(event.dataTransfer);\n if (!dropped) return false;\n event.preventDefault();\n if (dropped.kind !== \"asset\") return true;\n const position = view?.posAtCoords({\n left: event.clientX,\n top: event.clientY,\n });\n if (view) {\n // A drop outside the text (e.g. on the preview strip) lands at the\n // end rather than replacing whatever is selected.\n const { state } = view;\n view.dispatch(\n state.tr.setSelection(\n position\n ? Selection.near(state.doc.resolve(position.pos))\n : Selection.atEnd(state.doc),\n ),\n );\n }\n insertAssetMentionRef.current(dropped.asset);\n return true;\n },\n [],\n );\n\n // ProseMirror owns drops that land in the editable surface. The React\n // wrapper below catches the rest of the composer area; defaultPrevented\n // keeps one gesture from being attached twice.\n const handleDrop = useCallback(\n (view: EditorView, event: DragEvent) => {\n if (handleAssetDrop(event, view)) return true;\n const files = event.dataTransfer?.files;\n if (!files?.length) return false;\n const handled = addDroppedFiles(files);\n if (handled) event.preventDefault();\n return handled;\n },\n [addDroppedFiles, handleAssetDrop],\n );\n\n const handleComposerDrop = useCallback(\n (event: ReactDragEvent<HTMLDivElement>) => {\n if (event.defaultPrevented) return;\n if (handleAssetDrop(event.nativeEvent, editorRef.current?.view)) return;\n if (addDroppedFiles(event.dataTransfer.files)) event.preventDefault();\n },\n [addDroppedFiles, handleAssetDrop],\n );\n\n // Read through a ref so a host can change the hint (e.g. while a run is\n // live) without rebuilding the editor; the effect below repaints it.\n const placeholderRef = useRef(placeholder);\n placeholderRef.current = placeholder;\n const editor = useEditor({\n editable: !disabled,\n extensions: [\n ...createChatTextExtensions(),\n ComposerDraftWhitespace,\n Placeholder.configure({ placeholder: () => placeholderRef.current }),\n MentionSuggestionsExtension.configure({\n store,\n callbacks: callbacksRef.current,\n }),\n SubmitKeybind.configure({\n onSubmit: () => void handleSubmitRef.current(),\n isMentionOpen: () => popupOpenRef.current,\n }),\n ],\n editorProps: {\n attributes: {\n class: cn(CHAT_TEXT_CLASS, \"w-full resize-none bg-transparent px-1.5 py-2 outline-none\"),\n \"data-testid\": \"athena-chat-composer\",\n },\n handlePaste,\n handleDrop,\n },\n onUpdate: ({ editor: updatedEditor }) => {\n const nextText = serializeDraft(updatedEditor);\n lastEmittedMarkdownRef.current = nextText;\n if (!applyingRuntimeTextRef.current) {\n composerInput.setText(nextText);\n }\n onDraftStateChange?.(nextText.trim().length > 0);\n\n if (showImagePreviews) {\n const mentionedAssetIds = new Set<string>();\n updatedEditor.state.doc.descendants((node) => {\n if (\n node.type.name === \"mention\" &&\n node.attrs.type === \"asset\" &&\n typeof node.attrs.id === \"string\"\n ) {\n mentionedAssetIds.add(node.attrs.id);\n }\n });\n removeImagePreviews(\n (preview) =>\n preview.assetId !== undefined &&\n !mentionedAssetIds.has(preview.assetId),\n );\n }\n },\n immediatelyRender: false,\n });\n\n // Keep ref in sync so handleSubmit always has the editor\n editorRef.current = editor;\n\n useEffect(() => {\n if (editor && !editor.isDestroyed) setEditorEditable(editor);\n }, [disabled, editor, setEditorEditable]);\n\n // The placeholder decoration is recomputed per transaction; an empty one\n // repaints a changed hint at once.\n useEffect(() => {\n if (!editor || editor.isDestroyed) return;\n editor.view.dispatch(editor.state.tr.setMeta(\"addToHistory\", false));\n }, [editor, placeholder]);\n\n // This rich editor replaces ComposerPrimitive.Input, so it must mirror its\n // draft into assistant-ui's composer state. Statewire restores that state\n // when a send is rejected during reconnect, and a host may write to it\n // (`useAppendToComposer`); mirroring it back into Tiptap — parsed as the\n // Markdown it was serialized to, mention links included — preserves the\n // user's message instead of leaving an empty composer. A send this composer\n // made (its text is verbatim) that comes back to the empty composer soon\n // after loads the draft it was sent from (`draftForReturnedSend`); any other\n // value, a host's prefill included, is parsed as Markdown. Our own echo is\n // skipped on the ref; a restore's re-serialization may differ from the\n // value byte-for-byte, so the ref takes that form to stop a second pass,\n // and a returned send already loaded from its draft is not loaded again.\n useEffect(() => {\n if (!editor) return;\n const value = composerInput.value;\n if (value === lastEmittedMarkdownRef.current) return;\n if (value === restoredSendRef.current) return;\n restoredSendRef.current = null;\n const currentMarkdown = serializeDraft(editor);\n lastEmittedMarkdownRef.current = currentMarkdown;\n // Statewire puts a refused send back only into an empty composer.\n const returnedDraft: string | null = editor.isEmpty\n ? draftForReturnedSend({ threadId, text: value })\n : null;\n const restored = returnedDraft ?? value;\n if (restored === currentMarkdown) return;\n // React node views flush their mounts synchronously. Restore outside\n // React's effect phase, and cancel a restore superseded by a newer draft.\n let cancelled = false;\n queueMicrotask(() => {\n if (cancelled || editor.isDestroyed) return;\n applyingRuntimeTextRef.current = true;\n try {\n editor.commands.setContent(restored, { emitUpdate: false });\n lastEmittedMarkdownRef.current = serializeDraft(editor);\n if (returnedDraft !== null) restoredSendRef.current = value;\n } finally {\n applyingRuntimeTextRef.current = false;\n }\n onDraftStateChange?.(value.trim().length > 0);\n // A host prefill (`useAppendToComposer(..., { focus: true })`) asked\n // for the caret after its text: now that the text is on screen.\n if (handoff?.focusOnNextMirror) {\n handoff.focusOnNextMirror = false;\n editor.commands.focus(\"end\");\n }\n });\n return () => { cancelled = true; };\n }, [composerInput.value, editor, handoff, onDraftStateChange, threadId]);\n\n // Lets host UI outside the chat place the caret at the end of the draft\n // (`useAppendToComposer` focus option) without reaching into the DOM.\n useEffect(() => {\n if (!editor || !handoff) return;\n handoff.focusEnd = () => {\n if (!editor.isDestroyed) editor.commands.focus(\"end\");\n };\n // `useFocusComposer` asked before this editor mounted.\n if (handoff.focusOnMount) {\n handoff.focusOnMount = false;\n handoff.focusEnd();\n }\n return () => {\n handoff.focusEnd = null;\n };\n }, [editor, handoff]);\n\n const insertAssetMention = useCallback(\n (asset: UploadedChatAsset, sourceFile?: File) => {\n const currentEditor = editorRef.current;\n if (!currentEditor) throw new Error(\"The chat composer is not ready.\");\n currentEditor\n .chain()\n .focus()\n .insertContent({\n type: \"mention\",\n attrs: {\n type: \"asset\",\n name: asset.title,\n id: asset.id,\n assetType: asset.assetType,\n displayAsPreview:\n showImagePreviews && sourceFile?.type.startsWith(\"image/\"),\n },\n })\n // A text node, not a string: the Markdown extension parses string\n // content as Markdown, which would drop a lone space.\n .insertContent({ type: \"text\", text: \" \" })\n .run();\n\n if (\n showImagePreviews &&\n sourceFile?.type.startsWith(\"image/\") &&\n typeof URL.createObjectURL === \"function\"\n ) {\n const existing = imagePreviewsRef.current.find(\n (preview) => preview.file === sourceFile,\n );\n if (existing) {\n replaceImagePreviews(\n imagePreviewsRef.current.map((preview) =>\n preview.key === existing.key\n ? { ...preview, assetId: asset.id, name: asset.title }\n : preview,\n ),\n );\n } else {\n replaceImagePreviews([\n ...imagePreviewsRef.current,\n {\n key: crypto.randomUUID(),\n file: sourceFile,\n name: asset.title,\n src: URL.createObjectURL(sourceFile),\n assetId: asset.id,\n },\n ]);\n }\n }\n },\n [replaceImagePreviews, showImagePreviews],\n );\n insertAssetMentionRef.current = insertAssetMention;\n\n const removeImagePreview = useCallback(\n (preview: ComposerImagePreview) => {\n if (!preview.assetId) return;\n const currentEditor = editorRef.current;\n if (!currentEditor) return;\n const positions: Array<{ from: number; to: number }> = [];\n currentEditor.state.doc.descendants((node, position) => {\n if (\n node.type.name === \"mention\" &&\n node.attrs.type === \"asset\" &&\n node.attrs.id === preview.assetId\n ) {\n positions.push({ from: position, to: position + node.nodeSize });\n }\n });\n let transaction = currentEditor.state.tr;\n for (const position of positions.reverse()) {\n transaction = transaction.delete(position.from, position.to);\n }\n if (transaction.docChanged) currentEditor.view.dispatch(transaction);\n removeImagePreviews((candidate) => candidate.key === preview.key);\n currentEditor.commands.focus();\n },\n [removeImagePreviews],\n );\n\n useEffect(\n () => registerChatAssetMentionHandler(threadId, insertAssetMention),\n [insertAssetMention, threadId],\n );\n\n const openMentionMenu = useCallback(() => {\n if (disabled) return;\n const currentEditor = editorRef.current;\n if (!currentEditor || currentEditor.isDestroyed) return;\n if (popupOpenRef.current) {\n currentEditor.commands.focus();\n return;\n }\n // The suggestion plugin only opens on an `@` that starts a word\n // (`allowedPrefixes`), so a trigger typed right after text — or after a\n // mention chip, which `textBetween` reports as its leaf text — gets the\n // separating space a user would type.\n const { from } = currentEditor.state.selection;\n const before =\n from > 0\n ? currentEditor.state.doc.textBetween(from - 1, from, \"\\0\", \"\\0\")\n : \"\";\n const needsSpace = before.length > 0 && !/[\\s([{\"']/.test(before);\n currentEditor\n .chain()\n .focus()\n .insertContent({ type: \"text\", text: needsSpace ? \" @\" : \"@\" })\n .run();\n }, [disabled]);\n\n const appendText = useCallback((text: string) => {\n const currentEditor = editorRef.current;\n if (currentEditor) appendPlainText(currentEditor, text);\n }, []);\n\n const captureSend = useCallback((): ComposerSend | null => {\n const currentEditor = editorRef.current;\n return currentEditor && !currentEditor.isDestroyed\n ? captureComposerSend(currentEditor)\n : null;\n }, []);\n\n useImperativeHandle(\n outerRef,\n () => ({\n submit: handleSubmit,\n addAttachment,\n insertAssetMention,\n openMentionMenu,\n appendText,\n captureSend,\n }),\n [\n addAttachment,\n appendText,\n captureSend,\n handleSubmit,\n insertAssetMention,\n openMentionMenu,\n ],\n );\n\n return (\n <>\n <style>{MENTION_STYLES}</style>\n <div\n className={cn(\n \"athena-chat-composer flex-1 min-w-0\",\n appearance === \"paper\" && \"athena-chat-composer--paper\",\n showImagePreviews && \"image-preview-composer\",\n )}\n aria-label=\"Message composer\"\n aria-disabled={disabled}\n onDragOver={(event) => {\n const types = Array.from(event.dataTransfer.types);\n if (\n types.includes(\"Files\") ||\n (!disabled && isAthenaAssetDrag(types))\n ) {\n event.preventDefault();\n event.dataTransfer.dropEffect = \"copy\";\n }\n }}\n onDrop={handleComposerDrop}\n >\n <ImagePreviewStrip\n previews={imagePreviews}\n onRemove={removeImagePreview}\n />\n <EditorContent editor={editor} />\n </div>\n\n {/* Olympus-style mention popup */}\n {popupOpen && popupProps && editor && (\n <MentionSuggestionPopup clientRect={popupProps.clientRect}>\n <MentionSuggestionList\n ref={listRef}\n store={store}\n editor={editor}\n query={popupProps.query}\n command={(item: MenuItem) => popupProps.command(item)}\n closeMenu={() => {\n setPopupOpen(false);\n editor.commands.focus();\n }}\n />\n </MentionSuggestionPopup>\n )}\n </>\n );\n },\n);\n\nTiptapComposer.displayName = \"TiptapComposer\";\n"],"names":["Extension","runInputRulesOnEnter","serializeComposerDraft","Selection","useState","jsxs","Fragment","jsx","LoaderCircleIcon","XIcon","ImageViewer","forwardRef","useAui","useDeepAgentChatOutboxContext","useRef","unstable_useComposerInput","useComposerHandoffStore","PendingAttachmentUploads","useCallback","useStatewireSessionLane","useEffect","useMentionSuggestions","captureComposerSend","takeRestoredAttachments","attachedMessageBehindWaiting","attachedMessageNeedsConnection","withDeepAgentComposerMarkdown","prepareComposerSend","extractPastedImages","extractPastedNonImageFiles","clipboardHasMeaningfulText","isImageFile","athenaDiagnostics","readAthenaAssetDrop","state","useEditor","createChatTextExtensions","ComposerDraftWhitespace","MentionSuggestionsExtension","cn","CHAT_TEXT_CLASS","draftForReturnedSend","registerChatAssetMentionHandler","useImperativeHandle","isAthenaAssetDrag","EditorContent","MentionSuggestionPopup","MentionSuggestionList"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuGA,MAAM,gBAAgBA,KAAAA,UAAU,OAA+D;AAAA,EAC7F,MAAM;AAAA,EACN,UAAU;AAAA,EACV,aAAa;AACX,WAAO,EAAE,UAAU,MAAM;AAAA,IAAC,GAAG,eAAe,MAAM,MAAA;AAAA,EACpD;AAAA,EACA,uBAAuB;AACrB,WAAO;AAAA,MACL,OAAO,MAAM;AAEX,YAAI,KAAK,QAAQ,cAAA,EAAiB,QAAO;AAEzC,YAAIC,0CAAqB,KAAK,MAAM,EAAG,QAAO;AAG9C,YAAI,CAAC,YAAY,YAAY,aAAa,SAAS,YAAY,EAAE;AAAA,UAC/D,CAAC,SAAS,KAAK,OAAO,SAAS,IAAI;AAAA,QAAA,EAClC,QAAO;AACV,aAAK,QAAQ,SAAA;AACb,eAAO;AAAA,MACT;AAAA,MACA,eAAe,MAAM;AACnB,eAAO,KAAK,OAAO,SAAS,cAAA,KAAmB,KAAK,OAAO,SAAS,aAAA;AAAA,MACtE;AAAA,IAAA;AAAA,EAEJ;AACF,CAAC;AAID,MAAM,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA4ChB,SAAS,eAAe,QAAwB;AACrD,SAAOC,gBAAA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;AAAA,YAClC;AAAA,UACF;AAAA,UACA,QAAQ;AAAA,UAER,UAAA;AAAA,YAAArC,2BAAAA;AAAAA,cAAC;AAAA,cAAA;AAAA,gBACC,UAAU;AAAA,gBACV,UAAU;AAAA,cAAA;AAAA,YAAA;AAAA,YAEZA,+BAACsC,QAAAA,iBAAc,OAAA,CAAgB;AAAA,UAAA;AAAA,QAAA;AAAA,MAAA;AAAA,MAIhC,aAAa,cAAc,yCACzBC,uBAAAA,wBAAA,EAAuB,YAAY,WAAW,YAC7C,UAAAvC,2BAAAA;AAAAA,QAACwC,sBAAAA;AAAAA,QAAA;AAAA,UACC,KAAK;AAAA,UACL;AAAA,UACA;AAAA,UACA,OAAO,WAAW;AAAA,UAClB,SAAS,CAAC,SAAmB,WAAW,QAAQ,IAAI;AAAA,UACpD,WAAW,MAAM;AACf,yBAAa,KAAK;AAClB,mBAAO,SAAS,MAAA;AAAA,UAClB;AAAA,QAAA;AAAA,MAAA,EACF,CACF;AAAA,IAAA,GAEJ;AAAA,EAEF;AACF;AAEA,eAAe,cAAc;;;;"}
@@ -26,6 +26,7 @@ import { type Editor } from "@tiptap/core";
26
26
  import { type MentionRootCategory } from "../mentions/suggestions/data/use-mention-suggestions";
27
27
  import type { MentionTool, WebpageMention } from "../mentions/suggestions/data/types";
28
28
  import { type UploadedChatAsset, type ChatOutbox, type ChatOutboxAttachment } from "../../agent-runtime/src/index";
29
+ import { type LabelCopy } from "../../agent-runtime/src/offline-status";
29
30
  import { type ComposerSend } from "./composer-message";
30
31
  /**
31
32
  * The editor's look. `default` is what the Chrome extension and Office add-in
@@ -85,6 +86,14 @@ export interface TiptapComposerProps {
85
86
  * (`ComposerSendOrStop`'s `sendBlockedReason`).
86
87
  */
87
88
  sendBlocked?: boolean;
89
+ /**
90
+ * Why the `@` menu can't ask Athena right now, or `null` while it can: a host that keeps nothing
91
+ * while Athena can't be reached passes `NEEDS_CONNECTION` (`@athenaintel/agent-runtime/offline-status`).
92
+ * The menu then fetches nothing; the host's own items (its tabs, its tool list) and what it
93
+ * already loaded still show, and a search or a category that would load from Athena says this
94
+ * instead of spinning or "No results found". Once it clears, lookups that failed meanwhile run again.
95
+ */
96
+ mentionSearchUnavailable?: LabelCopy | null;
88
97
  /** Editor look; defaults to the side-panel / task-pane editor. */
89
98
  appearance?: TiptapComposerAppearance;
90
99
  /** Host-provided browser-tab mentions; empty in hosts without tab access. */
@@ -158,8 +167,15 @@ export interface TiptapComposerProps {
158
167
  */
159
168
  onSubmitted?: () => void;
160
169
  }
161
- /** What the composer says when a message with an attachment or a quote can't wait to be sent. */
162
- export declare const OFFLINE_EXTRAS_MESSAGE = "Athena can't be reached. A message with an attachment or a quote can't wait to be sent \u2014 remove it to send the text when Athena is back.";
163
- /** What the composer says when a message with an attachment or a quote would overtake messages still waiting. */
164
- export declare const WAITING_EXTRAS_MESSAGE = "Messages you wrote while Athena couldn't be reached haven't gone yet. A message with an attachment or a quote can't wait behind them \u2014 send it once they've gone.";
170
+ export interface ComposerImagePreview {
171
+ key: string;
172
+ file: File;
173
+ name: string;
174
+ src: string;
175
+ assetId?: string;
176
+ }
177
+ export declare function ImagePreviewStrip({ previews, onRemove, }: {
178
+ previews: readonly ComposerImagePreview[];
179
+ onRemove: (preview: ComposerImagePreview) => void;
180
+ }): import("react").JSX.Element | null;
165
181
  export declare const TiptapComposer: import("react").ForwardRefExoticComponent<TiptapComposerProps & import("react").RefAttributes<TiptapComposerHandle>>;
@@ -9,12 +9,14 @@ import { useAui, unstable_useComposerInput } from "@assistant-ui/react";
9
9
  import { useComposerHandoffStore, takeRestoredAttachments } from "../../composer/composer-handoff.js";
10
10
  import { useStatewireSessionLane } from "../../runtime/statewire-session-lane.js";
11
11
  import { LoaderCircleIcon, XIcon } from "lucide-react";
12
+ import { ImageViewer } from "../../ui/image-viewer.js";
12
13
  import { CHAT_TEXT_CLASS, createChatTextExtensions } from "../rich-text/chat-text-schema.js";
13
14
  import { MentionSuggestionsExtension } from "../mentions/suggestions/mention-suggestions.extension.js";
14
15
  import { MentionSuggestionPopup } from "../mentions/suggestions/components/mention-suggestion-popup.js";
15
16
  import { MentionSuggestionList } from "../mentions/suggestions/components/mention-suggestion-list.js";
16
17
  import { useMentionSuggestions } from "../mentions/suggestions/data/use-mention-suggestions.js";
17
18
  import { Selection } from "@tiptap/pm/state";
19
+ import { attachedMessageBehindWaiting, attachedMessageNeedsConnection } from "../../agent-runtime/src/offline-status.js";
18
20
  import { captureComposerSend, prepareComposerSend, ComposerDraftWhitespace, draftForReturnedSend, serializeComposerDraft } from "./composer-message.js";
19
21
  import { PendingAttachmentUploads } from "./pending-attachment-uploads.js";
20
22
  import { runInputRulesOnEnter } from "./run-input-rules-on-enter.js";
@@ -99,8 +101,6 @@ function assetMentionIds(editor) {
99
101
  });
100
102
  return ids;
101
103
  }
102
- const OFFLINE_EXTRAS_MESSAGE = "Athena can't be reached. A message with an attachment or a quote can't wait to be sent — remove it to send the text when Athena is back.";
103
- const WAITING_EXTRAS_MESSAGE = "Messages you wrote while Athena couldn't be reached haven't gone yet. A message with an attachment or a quote can't wait behind them — send it once they've gone.";
104
104
  function chatOutboxRead(outbox) {
105
105
  if (outbox.getSnapshot().loaded) return Promise.resolve();
106
106
  return new Promise((resolve) => {
@@ -126,55 +126,81 @@ function ImagePreviewStrip({
126
126
  previews,
127
127
  onRemove
128
128
  }) {
129
+ const [viewingKey, setViewingKey] = useState(null);
130
+ const viewingIndex = previews.findIndex((preview) => preview.key === viewingKey);
129
131
  if (previews.length === 0) return null;
130
- return /* @__PURE__ */ jsx(
131
- "div",
132
- {
133
- className: "flex w-full gap-2 overflow-x-auto px-1.5 pb-1 pt-1.5",
134
- role: "list",
135
- "aria-label": "Image attachments",
136
- children: previews.map((preview) => {
137
- const uploading = preview.assetId === void 0;
138
- return /* @__PURE__ */ jsxs(
139
- "div",
140
- {
141
- className: "group relative h-16 w-[clamp(76px,30vw,112px)] shrink-0 overflow-hidden rounded-lg border border-neutral-200 bg-neutral-100 shadow-sm",
142
- role: "listitem",
143
- children: [
144
- /* @__PURE__ */ jsx(
145
- "img",
146
- {
147
- src: preview.src,
148
- alt: preview.name,
149
- className: "size-full object-cover"
150
- }
151
- ),
152
- /* @__PURE__ */ jsx("div", { className: "absolute inset-x-0 bottom-0 truncate bg-gradient-to-t from-black/75 to-transparent px-1.5 pb-1 pt-4 text-[10px] font-medium text-white", children: preview.name }),
153
- uploading ? /* @__PURE__ */ jsx(
154
- "span",
155
- {
156
- className: "absolute left-1 top-1 inline-flex size-5 items-center justify-center rounded-full bg-black/65 text-white",
157
- title: "Uploading image",
158
- children: /* @__PURE__ */ jsx(LoaderCircleIcon, { className: "size-3 animate-spin" })
159
- }
160
- ) : /* @__PURE__ */ jsx(
161
- "button",
162
- {
163
- type: "button",
164
- onClick: () => onRemove(preview),
165
- className: "absolute right-1 top-1 inline-flex size-5 items-center justify-center rounded-full bg-black/65 text-white opacity-80 transition-opacity hover:bg-black/80 hover:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white",
166
- "aria-label": `Remove ${preview.name}`,
167
- title: "Remove image",
168
- children: /* @__PURE__ */ jsx(XIcon, { className: "size-3" })
169
- }
170
- )
171
- ]
172
- },
173
- preview.key
174
- );
175
- })
176
- }
177
- );
132
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
133
+ /* @__PURE__ */ jsx(
134
+ "div",
135
+ {
136
+ className: "flex w-full gap-2 overflow-x-auto px-1.5 pb-1 pt-1.5",
137
+ role: "list",
138
+ "aria-label": "Image attachments",
139
+ children: previews.map((preview) => {
140
+ const uploading = preview.assetId === void 0;
141
+ return /* @__PURE__ */ jsxs(
142
+ "div",
143
+ {
144
+ className: "group relative h-16 w-[clamp(76px,30vw,112px)] shrink-0 overflow-hidden rounded-lg border border-neutral-200 bg-neutral-100 shadow-sm",
145
+ role: "listitem",
146
+ children: [
147
+ /* @__PURE__ */ jsx(
148
+ "button",
149
+ {
150
+ type: "button",
151
+ onClick: () => setViewingKey(preview.key),
152
+ className: "block size-full cursor-zoom-in focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",
153
+ "aria-label": `View ${preview.name}`,
154
+ title: `View ${preview.name}`,
155
+ children: /* @__PURE__ */ jsx(
156
+ "img",
157
+ {
158
+ src: preview.src,
159
+ alt: preview.name,
160
+ className: "size-full object-cover",
161
+ draggable: false
162
+ }
163
+ )
164
+ }
165
+ ),
166
+ /* @__PURE__ */ jsx("div", { className: "pointer-events-none absolute inset-x-0 bottom-0 truncate bg-gradient-to-t from-black/75 to-transparent px-1.5 pb-1 pt-4 text-[10px] font-medium text-white", children: preview.name }),
167
+ uploading ? /* @__PURE__ */ jsx(
168
+ "span",
169
+ {
170
+ className: "absolute left-1 top-1 inline-flex size-5 items-center justify-center rounded-full bg-black/65 text-white",
171
+ title: "Uploading image",
172
+ children: /* @__PURE__ */ jsx(LoaderCircleIcon, { className: "size-3 animate-spin" })
173
+ }
174
+ ) : /* @__PURE__ */ jsx(
175
+ "button",
176
+ {
177
+ type: "button",
178
+ onClick: () => onRemove(preview),
179
+ className: "absolute right-1 top-1 inline-flex size-5 items-center justify-center rounded-full bg-black/65 text-white opacity-80 transition-opacity hover:bg-black/80 hover:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white",
180
+ "aria-label": `Remove ${preview.name}`,
181
+ title: "Remove image",
182
+ children: /* @__PURE__ */ jsx(XIcon, { className: "size-3" })
183
+ }
184
+ )
185
+ ]
186
+ },
187
+ preview.key
188
+ );
189
+ })
190
+ }
191
+ ),
192
+ /* @__PURE__ */ jsx(
193
+ ImageViewer,
194
+ {
195
+ images: previews,
196
+ index: viewingIndex === -1 ? null : viewingIndex,
197
+ onIndexChange: (index) => {
198
+ var _a;
199
+ return setViewingKey(index === null ? null : ((_a = previews[index]) == null ? void 0 : _a.key) ?? null);
200
+ }
201
+ }
202
+ )
203
+ ] });
178
204
  }
179
205
  const TiptapComposer = forwardRef(
180
206
  ({
@@ -182,6 +208,7 @@ const TiptapComposer = forwardRef(
182
208
  threadId,
183
209
  disabled = false,
184
210
  sendBlocked = false,
211
+ mentionSearchUnavailable = null,
185
212
  appearance = "default",
186
213
  webpages = NO_WEBPAGES,
187
214
  tools,
@@ -255,7 +282,12 @@ const TiptapComposer = forwardRef(
255
282
  },
256
283
  []
257
284
  );
258
- const { store } = useMentionSuggestions({ webpages, tools, rootCategories });
285
+ const { store } = useMentionSuggestions({
286
+ webpages,
287
+ tools,
288
+ rootCategories,
289
+ athenaUnavailable: mentionSearchUnavailable
290
+ });
259
291
  const [popupOpen, setPopupOpen] = useState(false);
260
292
  const popupOpenRef = useRef(false);
261
293
  const [popupProps, setPopupProps] = useState(null);
@@ -315,7 +347,7 @@ const TiptapComposer = forwardRef(
315
347
  if (waitingOutbox == null ? void 0 : waitingOutbox.shouldHold()) {
316
348
  if (cannotWait) {
317
349
  onAttachmentError == null ? void 0 : onAttachmentError(
318
- waitingOutbox.getSnapshot().rows.length > 0 ? WAITING_EXTRAS_MESSAGE : OFFLINE_EXTRAS_MESSAGE
350
+ waitingOutbox.getSnapshot().rows.length > 0 ? attachedMessageBehindWaiting({ withQuote: true }) : attachedMessageNeedsConnection({ withQuote: true })
319
351
  );
320
352
  return;
321
353
  }
@@ -786,9 +818,8 @@ const TiptapComposer = forwardRef(
786
818
  );
787
819
  TiptapComposer.displayName = "TiptapComposer";
788
820
  export {
789
- OFFLINE_EXTRAS_MESSAGE,
821
+ ImagePreviewStrip,
790
822
  TiptapComposer,
791
- WAITING_EXTRAS_MESSAGE,
792
823
  serializeDraft
793
824
  };
794
825
  //# sourceMappingURL=tiptap-composer.js.map