@athenaintel/react 0.28.1 → 0.32.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 (817) hide show
  1. package/README.md +479 -10
  2. package/dist/agent-runtime/src/asset-attachment.cjs.map +1 -0
  3. package/dist/agent-runtime/src/asset-attachment.js.map +1 -0
  4. package/dist/agent-runtime/src/athena-asset-drag.cjs +44 -0
  5. package/dist/agent-runtime/src/athena-asset-drag.cjs.map +1 -0
  6. package/dist/agent-runtime/src/athena-asset-drag.js +44 -0
  7. package/dist/agent-runtime/src/athena-asset-drag.js.map +1 -0
  8. package/dist/agent-runtime/src/auth-denial.cjs.map +1 -0
  9. package/dist/agent-runtime/src/auth-denial.js.map +1 -0
  10. package/dist/agent-runtime/src/client-tool-bridge.cjs.map +1 -0
  11. package/dist/agent-runtime/src/client-tool-bridge.js.map +1 -0
  12. package/dist/agent-runtime/src/client-tools.cjs.map +1 -0
  13. package/dist/agent-runtime/src/client-tools.js.map +1 -0
  14. package/dist/agent-runtime/src/composer-markdown.cjs +124 -0
  15. package/dist/agent-runtime/src/composer-markdown.cjs.map +1 -0
  16. package/dist/agent-runtime/src/composer-markdown.js +124 -0
  17. package/dist/agent-runtime/src/composer-markdown.js.map +1 -0
  18. package/dist/agent-runtime/src/config-mutations.cjs +59 -0
  19. package/dist/agent-runtime/src/config-mutations.cjs.map +1 -0
  20. package/dist/agent-runtime/src/config-mutations.js +59 -0
  21. package/dist/agent-runtime/src/config-mutations.js.map +1 -0
  22. package/dist/agent-runtime/src/conversation-index.cjs.map +1 -0
  23. package/dist/agent-runtime/src/conversation-index.js.map +1 -0
  24. package/dist/{packages/agent-runtime → agent-runtime}/src/conversation-list.cjs +36 -0
  25. package/dist/agent-runtime/src/conversation-list.cjs.map +1 -0
  26. package/dist/{packages/agent-runtime → agent-runtime}/src/conversation-list.js +36 -0
  27. package/dist/agent-runtime/src/conversation-list.js.map +1 -0
  28. package/dist/{packages/agent-runtime → agent-runtime}/src/deep-agent-transport-recipe.cjs +5 -3
  29. package/dist/agent-runtime/src/deep-agent-transport-recipe.cjs.map +1 -0
  30. package/dist/{packages/agent-runtime → agent-runtime}/src/deep-agent-transport-recipe.js +6 -4
  31. package/dist/agent-runtime/src/deep-agent-transport-recipe.js.map +1 -0
  32. package/dist/agent-runtime/src/edit-command.cjs.map +1 -0
  33. package/dist/agent-runtime/src/edit-command.js.map +1 -0
  34. package/dist/{packages/agent-runtime → agent-runtime}/src/errors.cjs +23 -0
  35. package/dist/agent-runtime/src/errors.cjs.map +1 -0
  36. package/dist/{packages/agent-runtime → agent-runtime}/src/errors.js +23 -0
  37. package/dist/agent-runtime/src/errors.js.map +1 -0
  38. package/dist/agent-runtime/src/execute-output.cjs +41 -0
  39. package/dist/agent-runtime/src/execute-output.cjs.map +1 -0
  40. package/dist/agent-runtime/src/execute-output.js +41 -0
  41. package/dist/agent-runtime/src/execute-output.js.map +1 -0
  42. package/dist/{packages/agent-runtime → agent-runtime}/src/generated/runconfig-contract.cjs +16 -2
  43. package/dist/agent-runtime/src/generated/runconfig-contract.cjs.map +1 -0
  44. package/dist/{packages/agent-runtime → agent-runtime}/src/generated/runconfig-contract.js +16 -2
  45. package/dist/agent-runtime/src/generated/runconfig-contract.js.map +1 -0
  46. package/dist/agent-runtime/src/github-wake-event.cjs.map +1 -0
  47. package/dist/agent-runtime/src/github-wake-event.js.map +1 -0
  48. package/dist/{packages/agent-runtime → agent-runtime}/src/interrupts.cjs +24 -1
  49. package/dist/agent-runtime/src/interrupts.cjs.map +1 -0
  50. package/dist/{packages/agent-runtime → agent-runtime}/src/interrupts.js +24 -1
  51. package/dist/agent-runtime/src/interrupts.js.map +1 -0
  52. package/dist/agent-runtime/src/message-author.cjs.map +1 -0
  53. package/dist/agent-runtime/src/message-author.js.map +1 -0
  54. package/dist/agent-runtime/src/message-window.cjs.map +1 -0
  55. package/dist/agent-runtime/src/message-window.js.map +1 -0
  56. package/dist/{packages/agent-runtime → agent-runtime}/src/messages.cjs +8 -4
  57. package/dist/agent-runtime/src/messages.cjs.map +1 -0
  58. package/dist/{packages/agent-runtime → agent-runtime}/src/messages.js +6 -2
  59. package/dist/agent-runtime/src/messages.js.map +1 -0
  60. package/dist/agent-runtime/src/model-context.cjs.map +1 -0
  61. package/dist/agent-runtime/src/model-context.js.map +1 -0
  62. package/dist/agent-runtime/src/optimistic-content.cjs.map +1 -0
  63. package/dist/agent-runtime/src/optimistic-content.js.map +1 -0
  64. package/dist/agent-runtime/src/protocol.cjs.map +1 -0
  65. package/dist/agent-runtime/src/protocol.js.map +1 -0
  66. package/dist/{packages/agent-runtime → agent-runtime}/src/queue.cjs +23 -2
  67. package/dist/agent-runtime/src/queue.cjs.map +1 -0
  68. package/dist/{packages/agent-runtime → agent-runtime}/src/queue.js +23 -2
  69. package/dist/agent-runtime/src/queue.js.map +1 -0
  70. package/dist/{packages/agent-runtime → agent-runtime}/src/quota-safe-local-storage-session.cjs +71 -13
  71. package/dist/agent-runtime/src/quota-safe-local-storage-session.cjs.map +1 -0
  72. package/dist/{packages/agent-runtime → agent-runtime}/src/quota-safe-local-storage-session.js +73 -15
  73. package/dist/agent-runtime/src/quota-safe-local-storage-session.js.map +1 -0
  74. package/dist/agent-runtime/src/runtime-messages.cjs.map +1 -0
  75. package/dist/agent-runtime/src/runtime-messages.js.map +1 -0
  76. package/dist/agent-runtime/src/screen-point.cjs.map +1 -0
  77. package/dist/agent-runtime/src/screen-point.js.map +1 -0
  78. package/dist/agent-runtime/src/send-recovery.cjs.map +1 -0
  79. package/dist/agent-runtime/src/send-recovery.js.map +1 -0
  80. package/dist/agent-runtime/src/statewire-attach-observer.cjs.map +1 -0
  81. package/dist/agent-runtime/src/statewire-attach-observer.js.map +1 -0
  82. package/dist/{packages/agent-runtime → agent-runtime}/src/statewire-state.cjs +8 -0
  83. package/dist/agent-runtime/src/statewire-state.cjs.map +1 -0
  84. package/dist/{packages/agent-runtime → agent-runtime}/src/statewire-state.js +8 -0
  85. package/dist/agent-runtime/src/statewire-state.js.map +1 -0
  86. package/dist/{packages/agent-runtime → agent-runtime}/src/statewire-suspended.cjs +4 -0
  87. package/dist/agent-runtime/src/statewire-suspended.cjs.map +1 -0
  88. package/dist/{packages/agent-runtime → agent-runtime}/src/statewire-suspended.js +4 -0
  89. package/dist/agent-runtime/src/statewire-suspended.js.map +1 -0
  90. package/dist/agent-runtime/src/statewire-transport.cjs +43 -0
  91. package/dist/agent-runtime/src/statewire-transport.cjs.map +1 -0
  92. package/dist/agent-runtime/src/statewire-transport.js +43 -0
  93. package/dist/agent-runtime/src/statewire-transport.js.map +1 -0
  94. package/dist/agent-runtime/src/streaming-markdown.cjs.map +1 -0
  95. package/dist/agent-runtime/src/streaming-markdown.js.map +1 -0
  96. package/dist/agent-runtime/src/subscription-wake-event.cjs +252 -0
  97. package/dist/agent-runtime/src/subscription-wake-event.cjs.map +1 -0
  98. package/dist/agent-runtime/src/subscription-wake-event.js +252 -0
  99. package/dist/agent-runtime/src/subscription-wake-event.js.map +1 -0
  100. package/dist/agent-runtime/src/thread-extras.cjs.map +1 -0
  101. package/dist/agent-runtime/src/thread-extras.js.map +1 -0
  102. package/dist/agent-runtime/src/thread-snapshot-cache.cjs.map +1 -0
  103. package/dist/agent-runtime/src/thread-snapshot-cache.js.map +1 -0
  104. package/dist/agent-runtime/src/thread-status.cjs.map +1 -0
  105. package/dist/agent-runtime/src/thread-status.js.map +1 -0
  106. package/dist/{packages/agent-runtime → agent-runtime}/src/tool-metadata.cjs +304 -9
  107. package/dist/agent-runtime/src/tool-metadata.cjs.map +1 -0
  108. package/dist/{packages/agent-runtime → agent-runtime}/src/tool-metadata.js +304 -9
  109. package/dist/agent-runtime/src/tool-metadata.js.map +1 -0
  110. package/dist/agent-runtime/src/tool-names.cjs +5 -0
  111. package/dist/agent-runtime/src/tool-names.cjs.map +1 -0
  112. package/dist/agent-runtime/src/tool-names.js +5 -0
  113. package/dist/agent-runtime/src/tool-names.js.map +1 -0
  114. package/dist/agent-runtime/src/tool-outputs.cjs.map +1 -0
  115. package/dist/agent-runtime/src/tool-outputs.js.map +1 -0
  116. package/dist/agent-runtime/src/tool-result.cjs.map +1 -0
  117. package/dist/agent-runtime/src/tool-result.js.map +1 -0
  118. package/dist/{packages/agent-runtime → agent-runtime}/src/use-conversation-list.cjs +33 -22
  119. package/dist/agent-runtime/src/use-conversation-list.cjs.map +1 -0
  120. package/dist/{packages/agent-runtime → agent-runtime}/src/use-conversation-list.js +34 -23
  121. package/dist/agent-runtime/src/use-conversation-list.js.map +1 -0
  122. package/dist/agent-runtime/src/use-deep-agent-config.cjs +129 -0
  123. package/dist/agent-runtime/src/use-deep-agent-config.cjs.map +1 -0
  124. package/dist/agent-runtime/src/use-deep-agent-config.js +129 -0
  125. package/dist/agent-runtime/src/use-deep-agent-config.js.map +1 -0
  126. package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-edit-submit.cjs +2 -0
  127. package/dist/agent-runtime/src/use-deep-agent-edit-submit.cjs.map +1 -0
  128. package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-edit-submit.js +2 -0
  129. package/dist/agent-runtime/src/use-deep-agent-edit-submit.js.map +1 -0
  130. package/dist/agent-runtime/src/use-deep-agent-runtime.cjs.map +1 -0
  131. package/dist/agent-runtime/src/use-deep-agent-runtime.js.map +1 -0
  132. package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-thread.cjs +1 -0
  133. package/dist/agent-runtime/src/use-deep-agent-thread.cjs.map +1 -0
  134. package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-thread.js +2 -1
  135. package/dist/agent-runtime/src/use-deep-agent-thread.js.map +1 -0
  136. package/dist/agent-runtime/src/use-deep-agent-window-sync.cjs.map +1 -0
  137. package/dist/agent-runtime/src/use-deep-agent-window-sync.js.map +1 -0
  138. package/dist/agent-runtime/src/use-historical-edit-attachments.cjs +52 -0
  139. package/dist/agent-runtime/src/use-historical-edit-attachments.cjs.map +1 -0
  140. package/dist/agent-runtime/src/use-historical-edit-attachments.js +52 -0
  141. package/dist/agent-runtime/src/use-historical-edit-attachments.js.map +1 -0
  142. package/dist/{packages/agent-runtime → agent-runtime}/src/voice-presentation.cjs +14 -0
  143. package/dist/agent-runtime/src/voice-presentation.cjs.map +1 -0
  144. package/dist/{packages/agent-runtime → agent-runtime}/src/voice-presentation.js +14 -0
  145. package/dist/agent-runtime/src/voice-presentation.js.map +1 -0
  146. package/dist/agent-runtime/src/voice-turn-grouping.cjs.map +1 -0
  147. package/dist/agent-runtime/src/voice-turn-grouping.js.map +1 -0
  148. package/dist/assets/AthenaAssetEmbed.cjs +13 -2
  149. package/dist/assets/AthenaAssetEmbed.cjs.map +1 -1
  150. package/dist/assets/AthenaAssetEmbed.d.ts +10 -0
  151. package/dist/assets/AthenaAssetEmbed.js +14 -3
  152. package/dist/assets/AthenaAssetEmbed.js.map +1 -1
  153. package/dist/assets/AthenaLayout.cjs +97 -31
  154. package/dist/assets/AthenaLayout.cjs.map +1 -1
  155. package/dist/assets/AthenaLayout.d.ts +13 -0
  156. package/dist/assets/AthenaLayout.js +98 -32
  157. package/dist/assets/AthenaLayout.js.map +1 -1
  158. package/dist/assets/asset-embed-messages.cjs +6 -0
  159. package/dist/assets/asset-embed-messages.cjs.map +1 -1
  160. package/dist/assets/asset-embed-messages.d.ts +13 -0
  161. package/dist/assets/asset-embed-messages.js +6 -0
  162. package/dist/assets/asset-embed-messages.js.map +1 -1
  163. package/dist/assets/asset-panel-store.cjs +68 -32
  164. package/dist/assets/asset-panel-store.cjs.map +1 -1
  165. package/dist/assets/asset-panel-store.d.ts +47 -1
  166. package/dist/assets/asset-panel-store.js +68 -32
  167. package/dist/assets/asset-panel-store.js.map +1 -1
  168. package/dist/assets/use-asset-embed.cjs +29 -8
  169. package/dist/assets/use-asset-embed.cjs.map +1 -1
  170. package/dist/assets/use-asset-embed.d.ts +7 -0
  171. package/dist/assets/use-asset-embed.js +29 -8
  172. package/dist/assets/use-asset-embed.js.map +1 -1
  173. package/dist/catalog/chat-pickers.cjs +152 -0
  174. package/dist/catalog/chat-pickers.cjs.map +1 -0
  175. package/dist/catalog/chat-pickers.d.ts +22 -0
  176. package/dist/catalog/chat-pickers.js +152 -0
  177. package/dist/catalog/chat-pickers.js.map +1 -0
  178. package/dist/catalog/runtime-catalog.cjs +181 -0
  179. package/dist/catalog/runtime-catalog.cjs.map +1 -0
  180. package/dist/catalog/runtime-catalog.d.ts +100 -0
  181. package/dist/catalog/runtime-catalog.js +181 -0
  182. package/dist/catalog/runtime-catalog.js.map +1 -0
  183. package/dist/chat/AthenaChat.cjs +122 -67
  184. package/dist/chat/AthenaChat.cjs.map +1 -1
  185. package/dist/chat/AthenaChat.d.ts +21 -4
  186. package/dist/chat/AthenaChat.js +124 -69
  187. package/dist/chat/AthenaChat.js.map +1 -1
  188. package/dist/chat/StatewireApprovalCard.cjs +38 -37
  189. package/dist/chat/StatewireApprovalCard.cjs.map +1 -1
  190. package/dist/chat/StatewireApprovalCard.d.ts +2 -0
  191. package/dist/chat/StatewireApprovalCard.js +39 -38
  192. package/dist/chat/StatewireApprovalCard.js.map +1 -1
  193. package/dist/chat/StatewireClientToolBridge.cjs +2 -2
  194. package/dist/chat/StatewireClientToolBridge.js +2 -2
  195. package/dist/chat/StatewireQueuedMessages.cjs +15 -12
  196. package/dist/chat/StatewireQueuedMessages.cjs.map +1 -1
  197. package/dist/chat/StatewireQueuedMessages.d.ts +22 -2
  198. package/dist/chat/StatewireQueuedMessages.js +15 -12
  199. package/dist/chat/StatewireQueuedMessages.js.map +1 -1
  200. package/dist/chat/StatewireRunRefusalNotice.cjs +48 -0
  201. package/dist/chat/StatewireRunRefusalNotice.cjs.map +1 -0
  202. package/dist/chat/StatewireRunRefusalNotice.d.ts +25 -0
  203. package/dist/chat/StatewireRunRefusalNotice.js +48 -0
  204. package/dist/chat/StatewireRunRefusalNotice.js.map +1 -0
  205. package/dist/chat/WaitingOnYouBanner.cjs +2 -2
  206. package/dist/chat/WaitingOnYouBanner.js +2 -2
  207. package/dist/chat/athena-citation-links.cjs +19 -15
  208. package/dist/chat/athena-citation-links.cjs.map +1 -1
  209. package/dist/chat/athena-citation-links.js +19 -15
  210. package/dist/chat/athena-citation-links.js.map +1 -1
  211. package/dist/chat/run-activity.cjs +9 -1
  212. package/dist/chat/run-activity.cjs.map +1 -1
  213. package/dist/chat/run-activity.d.ts +6 -0
  214. package/dist/chat/run-activity.js +10 -2
  215. package/dist/chat/run-activity.js.map +1 -1
  216. package/dist/chat/statewire-banners.cjs +30 -1
  217. package/dist/chat/statewire-banners.cjs.map +1 -1
  218. package/dist/chat/statewire-banners.d.ts +20 -1
  219. package/dist/chat/statewire-banners.js +32 -3
  220. package/dist/chat/statewire-banners.js.map +1 -1
  221. package/dist/chat/statewire-client-tools.cjs +1 -1
  222. package/dist/chat/statewire-client-tools.js +1 -1
  223. package/dist/chat/super-grouping/CollapsibleGroup.cjs +1 -1
  224. package/dist/chat/super-grouping/CollapsibleGroup.cjs.map +1 -1
  225. package/dist/chat/super-grouping/CollapsibleGroup.js +1 -1
  226. package/dist/chat/super-grouping/CollapsibleGroup.js.map +1 -1
  227. package/dist/chat/super-grouping/SuperGroupingCard.cjs +38 -16
  228. package/dist/chat/super-grouping/SuperGroupingCard.cjs.map +1 -1
  229. package/dist/chat/super-grouping/SuperGroupingCard.d.ts +21 -4
  230. package/dist/chat/super-grouping/SuperGroupingCard.js +39 -17
  231. package/dist/chat/super-grouping/SuperGroupingCard.js.map +1 -1
  232. package/dist/chat/super-grouping/SuperGroupingTranscript.cjs +377 -0
  233. package/dist/chat/super-grouping/SuperGroupingTranscript.cjs.map +1 -0
  234. package/dist/chat/super-grouping/SuperGroupingTranscript.d.ts +31 -0
  235. package/dist/chat/super-grouping/SuperGroupingTranscript.js +377 -0
  236. package/dist/chat/super-grouping/SuperGroupingTranscript.js.map +1 -0
  237. package/dist/chat/super-grouping/ToolTimeline.cjs +13 -2
  238. package/dist/chat/super-grouping/ToolTimeline.cjs.map +1 -1
  239. package/dist/chat/super-grouping/ToolTimeline.d.ts +10 -3
  240. package/dist/chat/super-grouping/ToolTimeline.js +13 -2
  241. package/dist/chat/super-grouping/ToolTimeline.js.map +1 -1
  242. package/dist/chat/super-grouping/activity-timeline.cjs +69 -29
  243. package/dist/chat/super-grouping/activity-timeline.cjs.map +1 -1
  244. package/dist/chat/super-grouping/activity-timeline.d.ts +60 -9
  245. package/dist/chat/super-grouping/activity-timeline.js +70 -30
  246. package/dist/chat/super-grouping/activity-timeline.js.map +1 -1
  247. package/dist/chat/super-grouping/index.cjs +14 -0
  248. package/dist/chat/super-grouping/index.cjs.map +1 -1
  249. package/dist/chat/super-grouping/index.d.ts +7 -2
  250. package/dist/chat/super-grouping/index.js +16 -2
  251. package/dist/chat/super-grouping/index.js.map +1 -1
  252. package/dist/chat/super-grouping/timeline-step.cjs +14 -5
  253. package/dist/chat/super-grouping/timeline-step.cjs.map +1 -1
  254. package/dist/chat/super-grouping/timeline-step.d.ts +10 -1
  255. package/dist/chat/super-grouping/timeline-step.js +15 -6
  256. package/dist/chat/super-grouping/timeline-step.js.map +1 -1
  257. package/dist/chat/super-grouping/toolkit-map.cjs +1 -0
  258. package/dist/chat/super-grouping/toolkit-map.cjs.map +1 -1
  259. package/dist/chat/super-grouping/toolkit-map.js +1 -0
  260. package/dist/chat/super-grouping/toolkit-map.js.map +1 -1
  261. package/dist/chat/super-grouping/turn-segments.cjs +82 -0
  262. package/dist/chat/super-grouping/turn-segments.cjs.map +1 -0
  263. package/dist/chat/super-grouping/turn-segments.d.ts +69 -0
  264. package/dist/chat/super-grouping/turn-segments.js +82 -0
  265. package/dist/chat/super-grouping/turn-segments.js.map +1 -0
  266. package/dist/chat/super-grouping/turn-timing.cjs +110 -0
  267. package/dist/chat/super-grouping/turn-timing.cjs.map +1 -0
  268. package/dist/chat/super-grouping/turn-timing.d.ts +52 -0
  269. package/dist/chat/super-grouping/turn-timing.js +110 -0
  270. package/dist/chat/super-grouping/turn-timing.js.map +1 -0
  271. package/dist/chat/tiptap-text.cjs +1 -1
  272. package/dist/chat/tiptap-text.js +1 -1
  273. package/dist/chat/use-athena-run-live.cjs +1 -1
  274. package/dist/chat/use-athena-run-live.js +1 -1
  275. package/dist/chat/use-statewire-approval-request.cjs +73 -4
  276. package/dist/chat/use-statewire-approval-request.cjs.map +1 -1
  277. package/dist/chat/use-statewire-approval-request.js +74 -5
  278. package/dist/chat/use-statewire-approval-request.js.map +1 -1
  279. package/dist/chat-ui/composer/composer-message.cjs +284 -0
  280. package/dist/chat-ui/composer/composer-message.cjs.map +1 -0
  281. package/dist/chat-ui/composer/composer-message.d.ts +152 -0
  282. package/dist/chat-ui/composer/composer-message.js +284 -0
  283. package/dist/chat-ui/composer/composer-message.js.map +1 -0
  284. package/dist/chat-ui/composer/tiptap-composer.cjs +97 -15
  285. package/dist/chat-ui/composer/tiptap-composer.cjs.map +1 -1
  286. package/dist/chat-ui/composer/tiptap-composer.d.ts +34 -6
  287. package/dist/chat-ui/composer/tiptap-composer.js +97 -15
  288. package/dist/chat-ui/composer/tiptap-composer.js.map +1 -1
  289. package/dist/chat-ui/index.cjs +4 -1
  290. package/dist/chat-ui/index.cjs.map +1 -1
  291. package/dist/chat-ui/index.d.ts +3 -2
  292. package/dist/chat-ui/index.js +5 -2
  293. package/dist/chat-ui/index.js.map +1 -1
  294. package/dist/chat-ui/mentions/mention-chip.cjs +31 -3
  295. package/dist/chat-ui/mentions/mention-chip.cjs.map +1 -1
  296. package/dist/chat-ui/mentions/mention-chip.d.ts +2 -5
  297. package/dist/chat-ui/mentions/mention-chip.js +33 -5
  298. package/dist/chat-ui/mentions/mention-chip.js.map +1 -1
  299. package/dist/chat-ui/mentions/mention-extension.cjs +9 -3
  300. package/dist/chat-ui/mentions/mention-extension.cjs.map +1 -1
  301. package/dist/chat-ui/mentions/mention-extension.js +9 -3
  302. package/dist/chat-ui/mentions/mention-extension.js.map +1 -1
  303. package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-popup.cjs +3 -1
  304. package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-popup.cjs.map +1 -1
  305. package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-popup.js +3 -1
  306. package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-popup.js.map +1 -1
  307. package/dist/chat-ui/mentions/suggestions/data/sources/index.cjs +65 -19
  308. package/dist/chat-ui/mentions/suggestions/data/sources/index.cjs.map +1 -1
  309. package/dist/chat-ui/mentions/suggestions/data/sources/index.d.ts +15 -0
  310. package/dist/chat-ui/mentions/suggestions/data/sources/index.js +67 -21
  311. package/dist/chat-ui/mentions/suggestions/data/sources/index.js.map +1 -1
  312. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.cjs +4 -2
  313. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.cjs.map +1 -1
  314. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.d.ts +2 -1
  315. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.js +5 -3
  316. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.js.map +1 -1
  317. package/dist/chat-ui/mentions/use-account-workspace-id.cjs +61 -0
  318. package/dist/chat-ui/mentions/use-account-workspace-id.cjs.map +1 -0
  319. package/dist/chat-ui/mentions/use-account-workspace-id.d.ts +3 -0
  320. package/dist/chat-ui/mentions/use-account-workspace-id.js +61 -0
  321. package/dist/chat-ui/mentions/use-account-workspace-id.js.map +1 -0
  322. package/dist/chat-ui/mentions/use-member-avatar.cjs +75 -0
  323. package/dist/chat-ui/mentions/use-member-avatar.cjs.map +1 -0
  324. package/dist/chat-ui/mentions/use-member-avatar.d.ts +2 -0
  325. package/dist/chat-ui/mentions/use-member-avatar.js +75 -0
  326. package/dist/chat-ui/mentions/use-member-avatar.js.map +1 -0
  327. package/dist/chat-ui/messages/message-components.cjs +30 -10
  328. package/dist/chat-ui/messages/message-components.cjs.map +1 -1
  329. package/dist/chat-ui/messages/message-components.d.ts +21 -1
  330. package/dist/chat-ui/messages/message-components.js +30 -10
  331. package/dist/chat-ui/messages/message-components.js.map +1 -1
  332. package/dist/chat-ui/messages/runtime-message.cjs +1 -1
  333. package/dist/chat-ui/messages/runtime-message.js +1 -1
  334. package/dist/chat-ui/messages/statewire-continue-run.cjs +5 -5
  335. package/dist/chat-ui/messages/statewire-continue-run.js +5 -5
  336. package/dist/chat-ui/messages/user-edit-composer.cjs +1 -1
  337. package/dist/chat-ui/messages/user-edit-composer.js +1 -1
  338. package/dist/chat-ui/messages/wake-marker.cjs +39 -4
  339. package/dist/chat-ui/messages/wake-marker.cjs.map +1 -1
  340. package/dist/chat-ui/messages/wake-marker.d.ts +16 -5
  341. package/dist/chat-ui/messages/wake-marker.js +40 -5
  342. package/dist/chat-ui/messages/wake-marker.js.map +1 -1
  343. package/dist/chat-ui/rich-text/chat-message-body.cjs +12 -8
  344. package/dist/chat-ui/rich-text/chat-message-body.cjs.map +1 -1
  345. package/dist/chat-ui/rich-text/chat-message-body.d.ts +6 -1
  346. package/dist/chat-ui/rich-text/chat-message-body.js +13 -9
  347. package/dist/chat-ui/rich-text/chat-message-body.js.map +1 -1
  348. package/dist/chat-ui/rich-text/chat-text-schema.cjs +64 -6
  349. package/dist/chat-ui/rich-text/chat-text-schema.cjs.map +1 -1
  350. package/dist/chat-ui/rich-text/chat-text-schema.d.ts +5 -0
  351. package/dist/chat-ui/rich-text/chat-text-schema.js +66 -8
  352. package/dist/chat-ui/rich-text/chat-text-schema.js.map +1 -1
  353. package/dist/chat-ui/statewire.cjs +1 -1
  354. package/dist/chat-ui/statewire.d.ts +1 -1
  355. package/dist/chat-ui/statewire.js +1 -1
  356. package/dist/chat-ui/thread/statewire-history-edge.cjs +2 -2
  357. package/dist/chat-ui/thread/statewire-history-edge.js +2 -2
  358. package/dist/collab/client.cjs +282 -16
  359. package/dist/collab/client.cjs.map +1 -1
  360. package/dist/collab/client.d.ts +127 -2
  361. package/dist/collab/client.js +285 -20
  362. package/dist/collab/client.js.map +1 -1
  363. package/dist/collab/index.cjs +2 -0
  364. package/dist/collab/index.cjs.map +1 -1
  365. package/dist/collab/index.d.ts +1 -1
  366. package/dist/collab/index.js +3 -1
  367. package/dist/composer/AttachmentContext.cjs +38 -12
  368. package/dist/composer/AttachmentContext.cjs.map +1 -1
  369. package/dist/composer/AttachmentContext.d.ts +22 -1
  370. package/dist/composer/AttachmentContext.js +40 -14
  371. package/dist/composer/AttachmentContext.js.map +1 -1
  372. package/dist/composer/QuoteContext.cjs +80 -28
  373. package/dist/composer/QuoteContext.cjs.map +1 -1
  374. package/dist/composer/QuoteContext.d.ts +35 -6
  375. package/dist/composer/QuoteContext.js +82 -30
  376. package/dist/composer/QuoteContext.js.map +1 -1
  377. package/dist/composer/build-composed-message.cjs +27 -0
  378. package/dist/composer/build-composed-message.cjs.map +1 -1
  379. package/dist/composer/build-composed-message.d.ts +21 -0
  380. package/dist/composer/build-composed-message.js +28 -1
  381. package/dist/composer/build-composed-message.js.map +1 -1
  382. package/dist/composer/composer-handoff.cjs +13 -1
  383. package/dist/composer/composer-handoff.cjs.map +1 -1
  384. package/dist/composer/composer-handoff.d.ts +12 -0
  385. package/dist/composer/composer-handoff.js +15 -3
  386. package/dist/composer/composer-handoff.js.map +1 -1
  387. package/dist/composer/index.d.ts +6 -3
  388. package/dist/composer/useReadComposerDraft.cjs +16 -0
  389. package/dist/composer/useReadComposerDraft.cjs.map +1 -0
  390. package/dist/composer/useReadComposerDraft.d.ts +6 -0
  391. package/dist/composer/useReadComposerDraft.js +16 -0
  392. package/dist/composer/useReadComposerDraft.js.map +1 -0
  393. package/dist/diagnostics/athena-diagnostics.cjs.map +1 -1
  394. package/dist/diagnostics/athena-diagnostics.d.ts +3 -1
  395. package/dist/diagnostics/athena-diagnostics.js.map +1 -1
  396. package/dist/diagnostics/errors.cjs +6 -0
  397. package/dist/diagnostics/errors.cjs.map +1 -1
  398. package/dist/diagnostics/errors.d.ts +6 -0
  399. package/dist/diagnostics/errors.js +6 -0
  400. package/dist/diagnostics/errors.js.map +1 -1
  401. package/dist/index.cjs +163 -7
  402. package/dist/index.cjs.map +1 -1
  403. package/dist/index.d.ts +55 -12
  404. package/dist/index.js +170 -14
  405. package/dist/index.js.map +1 -1
  406. package/dist/lib/owner-document.cjs +32 -0
  407. package/dist/lib/owner-document.cjs.map +1 -0
  408. package/dist/lib/owner-document.d.ts +17 -0
  409. package/dist/lib/owner-document.js +32 -0
  410. package/dist/lib/owner-document.js.map +1 -0
  411. package/dist/lib/portal-surface.cjs +55 -0
  412. package/dist/lib/portal-surface.cjs.map +1 -0
  413. package/dist/lib/portal-surface.d.ts +37 -0
  414. package/dist/lib/portal-surface.js +55 -0
  415. package/dist/lib/portal-surface.js.map +1 -0
  416. package/dist/lib/use-athena-rest-query.cjs +34 -0
  417. package/dist/lib/use-athena-rest-query.cjs.map +1 -0
  418. package/dist/lib/use-athena-rest-query.d.ts +31 -0
  419. package/dist/lib/use-athena-rest-query.js +34 -0
  420. package/dist/lib/use-athena-rest-query.js.map +1 -0
  421. package/dist/provider/AthenaProvider.cjs +70 -10
  422. package/dist/provider/AthenaProvider.cjs.map +1 -1
  423. package/dist/provider/AthenaProvider.d.ts +27 -2
  424. package/dist/provider/AthenaProvider.js +74 -14
  425. package/dist/provider/AthenaProvider.js.map +1 -1
  426. package/dist/provider/citation-links.d.ts +10 -2
  427. package/dist/{packages/react → react}/package.json.cjs +1 -1
  428. package/dist/{packages/react → react}/package.json.js +1 -1
  429. package/dist/runtime/StatewireModelLaneSync.cjs +96 -0
  430. package/dist/runtime/StatewireModelLaneSync.cjs.map +1 -0
  431. package/dist/runtime/StatewireModelLaneSync.d.ts +45 -0
  432. package/dist/runtime/StatewireModelLaneSync.js +96 -0
  433. package/dist/runtime/StatewireModelLaneSync.js.map +1 -0
  434. package/dist/runtime/statewire-lifecycle.cjs +20 -5
  435. package/dist/runtime/statewire-lifecycle.cjs.map +1 -1
  436. package/dist/runtime/statewire-lifecycle.d.ts +11 -0
  437. package/dist/runtime/statewire-lifecycle.js +20 -5
  438. package/dist/runtime/statewire-lifecycle.js.map +1 -1
  439. package/dist/runtime/statewire-model-lane.cjs +28 -0
  440. package/dist/runtime/statewire-model-lane.cjs.map +1 -0
  441. package/dist/runtime/statewire-model-lane.d.ts +64 -0
  442. package/dist/runtime/statewire-model-lane.js +28 -0
  443. package/dist/runtime/statewire-model-lane.js.map +1 -0
  444. package/dist/runtime/statewire-run-config.cjs +16 -2
  445. package/dist/runtime/statewire-run-config.cjs.map +1 -1
  446. package/dist/runtime/statewire-run-config.d.ts +10 -0
  447. package/dist/runtime/statewire-run-config.js +16 -2
  448. package/dist/runtime/statewire-run-config.js.map +1 -1
  449. package/dist/runtime/statewire-server-lane-context.cjs +24 -0
  450. package/dist/runtime/statewire-server-lane-context.cjs.map +1 -0
  451. package/dist/runtime/statewire-server-lane-context.d.ts +30 -0
  452. package/dist/runtime/statewire-server-lane-context.js +24 -0
  453. package/dist/runtime/statewire-server-lane-context.js.map +1 -0
  454. package/dist/runtime/useAthenaStatewireRuntime.cjs +47 -23
  455. package/dist/runtime/useAthenaStatewireRuntime.cjs.map +1 -1
  456. package/dist/runtime/useAthenaStatewireRuntime.d.ts +8 -1
  457. package/dist/runtime/useAthenaStatewireRuntime.js +48 -24
  458. package/dist/runtime/useAthenaStatewireRuntime.js.map +1 -1
  459. package/dist/search/useAthenaRepoSearch.cjs +5 -13
  460. package/dist/search/useAthenaRepoSearch.cjs.map +1 -1
  461. package/dist/search/useAthenaRepoSearch.d.ts +3 -3
  462. package/dist/search/useAthenaRepoSearch.js +6 -14
  463. package/dist/search/useAthenaRepoSearch.js.map +1 -1
  464. package/dist/sheet-range/a1.cjs +162 -0
  465. package/dist/sheet-range/a1.cjs.map +1 -0
  466. package/dist/sheet-range/a1.d.ts +91 -0
  467. package/dist/sheet-range/a1.js +162 -0
  468. package/dist/sheet-range/a1.js.map +1 -0
  469. package/dist/sheet-range/index.cjs +22 -0
  470. package/dist/sheet-range/index.cjs.map +1 -0
  471. package/dist/sheet-range/index.d.ts +12 -0
  472. package/dist/sheet-range/index.js +22 -0
  473. package/dist/sheet-range/index.js.map +1 -0
  474. package/dist/sheet-range/range-preview-table.cjs +75 -0
  475. package/dist/sheet-range/range-preview-table.cjs.map +1 -0
  476. package/dist/sheet-range/range-preview-table.d.ts +20 -0
  477. package/dist/sheet-range/range-preview-table.js +75 -0
  478. package/dist/sheet-range/range-preview-table.js.map +1 -0
  479. package/dist/sheet-range/range-preview.cjs +116 -0
  480. package/dist/sheet-range/range-preview.cjs.map +1 -0
  481. package/dist/sheet-range/range-preview.d.ts +67 -0
  482. package/dist/sheet-range/range-preview.js +116 -0
  483. package/dist/sheet-range/range-preview.js.map +1 -0
  484. package/dist/styles.css +1 -1
  485. package/dist/threads/Inbox.cjs +289 -0
  486. package/dist/threads/Inbox.cjs.map +1 -0
  487. package/dist/threads/Inbox.d.ts +46 -0
  488. package/dist/threads/Inbox.js +289 -0
  489. package/dist/threads/Inbox.js.map +1 -0
  490. package/dist/threads/SessionList.cjs +51 -126
  491. package/dist/threads/SessionList.cjs.map +1 -1
  492. package/dist/threads/SessionList.d.ts +26 -1
  493. package/dist/threads/SessionList.js +45 -120
  494. package/dist/threads/SessionList.js.map +1 -1
  495. package/dist/threads/SessionsPage.cjs +753 -0
  496. package/dist/threads/SessionsPage.cjs.map +1 -0
  497. package/dist/threads/SessionsPage.d.ts +35 -0
  498. package/dist/threads/SessionsPage.js +753 -0
  499. package/dist/threads/SessionsPage.js.map +1 -0
  500. package/dist/threads/api.cjs +23 -2
  501. package/dist/threads/api.cjs.map +1 -1
  502. package/dist/threads/api.d.ts +60 -0
  503. package/dist/threads/api.js +23 -2
  504. package/dist/threads/api.js.map +1 -1
  505. package/dist/threads/conversation-list-fetcher.cjs +9 -2
  506. package/dist/threads/conversation-list-fetcher.cjs.map +1 -1
  507. package/dist/threads/conversation-list-fetcher.d.ts +14 -1
  508. package/dist/threads/conversation-list-fetcher.js +9 -2
  509. package/dist/threads/conversation-list-fetcher.js.map +1 -1
  510. package/dist/threads/index.d.ts +2 -1
  511. package/dist/threads/pull-request-display.cjs +25 -0
  512. package/dist/threads/pull-request-display.cjs.map +1 -0
  513. package/dist/threads/pull-request-display.d.ts +15 -0
  514. package/dist/threads/pull-request-display.js +25 -0
  515. package/dist/threads/pull-request-display.js.map +1 -0
  516. package/dist/threads/session-list-model.cjs +16 -2
  517. package/dist/threads/session-list-model.cjs.map +1 -1
  518. package/dist/threads/session-list-model.d.ts +10 -0
  519. package/dist/threads/session-list-model.js +16 -2
  520. package/dist/threads/session-list-model.js.map +1 -1
  521. package/dist/threads/session-row-parts.cjs +152 -0
  522. package/dist/threads/session-row-parts.cjs.map +1 -0
  523. package/dist/threads/session-row-parts.d.ts +50 -0
  524. package/dist/threads/session-row-parts.js +152 -0
  525. package/dist/threads/session-row-parts.js.map +1 -0
  526. package/dist/threads/sessions-page-model.cjs +305 -0
  527. package/dist/threads/sessions-page-model.cjs.map +1 -0
  528. package/dist/threads/sessions-page-model.d.ts +86 -0
  529. package/dist/threads/sessions-page-model.js +305 -0
  530. package/dist/threads/sessions-page-model.js.map +1 -0
  531. package/dist/threads/sessions-page-storage.cjs +93 -0
  532. package/dist/threads/sessions-page-storage.cjs.map +1 -0
  533. package/dist/threads/sessions-page-storage.d.ts +23 -0
  534. package/dist/threads/sessions-page-storage.js +93 -0
  535. package/dist/threads/sessions-page-storage.js.map +1 -0
  536. package/dist/threads/sessions-query.cjs +235 -0
  537. package/dist/threads/sessions-query.cjs.map +1 -0
  538. package/dist/threads/sessions-query.d.ts +119 -0
  539. package/dist/threads/sessions-query.js +235 -0
  540. package/dist/threads/sessions-query.js.map +1 -0
  541. package/dist/threads/statewire-thread-list.cjs +133 -40
  542. package/dist/threads/statewire-thread-list.cjs.map +1 -1
  543. package/dist/threads/statewire-thread-list.d.ts +83 -2
  544. package/dist/threads/statewire-thread-list.js +134 -41
  545. package/dist/threads/statewire-thread-list.js.map +1 -1
  546. package/dist/threads/use-athena-sessions.cjs +198 -0
  547. package/dist/threads/use-athena-sessions.cjs.map +1 -0
  548. package/dist/threads/use-athena-sessions.d.ts +81 -0
  549. package/dist/threads/use-athena-sessions.js +198 -0
  550. package/dist/threads/use-athena-sessions.js.map +1 -0
  551. package/dist/threads/use-athena-thread-model.cjs +14 -0
  552. package/dist/threads/use-athena-thread-model.cjs.map +1 -0
  553. package/dist/threads/use-athena-thread-model.d.ts +22 -0
  554. package/dist/threads/use-athena-thread-model.js +14 -0
  555. package/dist/threads/use-athena-thread-model.js.map +1 -0
  556. package/dist/threads/use-rest-conversation-history.cjs +1 -1
  557. package/dist/threads/use-rest-conversation-history.js +1 -1
  558. package/dist/threads/use-statewire-conversation-history.cjs +1 -1
  559. package/dist/threads/use-statewire-conversation-history.d.ts +3 -0
  560. package/dist/threads/use-statewire-conversation-history.js +1 -1
  561. package/dist/threads/use-thread-read-state.cjs +73 -0
  562. package/dist/threads/use-thread-read-state.cjs.map +1 -0
  563. package/dist/threads/use-thread-read-state.d.ts +51 -0
  564. package/dist/threads/use-thread-read-state.js +73 -0
  565. package/dist/threads/use-thread-read-state.js.map +1 -0
  566. package/dist/tiptap-markdown-table/src/markdown-table-serializer.cjs.map +1 -0
  567. package/dist/tiptap-markdown-table/src/markdown-table-serializer.js.map +1 -0
  568. package/dist/tools/auto-open-tools.cjs +2 -0
  569. package/dist/tools/auto-open-tools.cjs.map +1 -1
  570. package/dist/tools/auto-open-tools.js +2 -0
  571. package/dist/tools/auto-open-tools.js.map +1 -1
  572. package/dist/tools/file-tool-uis.cjs +18 -43
  573. package/dist/tools/file-tool-uis.cjs.map +1 -1
  574. package/dist/tools/file-tool-uis.d.ts +1 -2
  575. package/dist/tools/file-tool-uis.js +18 -42
  576. package/dist/tools/file-tool-uis.js.map +1 -1
  577. package/dist/tools/index.cjs +6 -2
  578. package/dist/tools/index.cjs.map +1 -1
  579. package/dist/tools/index.d.ts +1 -0
  580. package/dist/tools/index.js +6 -2
  581. package/dist/tools/index.js.map +1 -1
  582. package/dist/tools/misc-tool-uis.cjs +2 -2
  583. package/dist/tools/misc-tool-uis.js +2 -2
  584. package/dist/tools/primitives.cjs +1 -1
  585. package/dist/tools/primitives.js +1 -1
  586. package/dist/tools/read-asset-tool-ui.cjs +21 -70
  587. package/dist/tools/read-asset-tool-ui.cjs.map +1 -1
  588. package/dist/tools/read-asset-tool-ui.js +21 -70
  589. package/dist/tools/read-asset-tool-ui.js.map +1 -1
  590. package/dist/tools/step-text.cjs +21 -0
  591. package/dist/tools/step-text.cjs.map +1 -0
  592. package/dist/tools/step-text.d.ts +10 -0
  593. package/dist/tools/step-text.js +21 -0
  594. package/dist/tools/step-text.js.map +1 -0
  595. package/dist/tools/tool-fallback.cjs +24 -5
  596. package/dist/tools/tool-fallback.cjs.map +1 -1
  597. package/dist/tools/tool-fallback.d.ts +3 -1
  598. package/dist/tools/tool-fallback.js +24 -5
  599. package/dist/tools/tool-fallback.js.map +1 -1
  600. package/dist/tools/tool-summary.cjs +661 -0
  601. package/dist/tools/tool-summary.cjs.map +1 -0
  602. package/dist/tools/tool-summary.d.ts +99 -0
  603. package/dist/tools/tool-summary.js +661 -0
  604. package/dist/tools/tool-summary.js.map +1 -0
  605. package/dist/tools/tool-uis.cjs +37 -95
  606. package/dist/tools/tool-uis.cjs.map +1 -1
  607. package/dist/tools/tool-uis.js +37 -95
  608. package/dist/tools/tool-uis.js.map +1 -1
  609. package/dist/tools/voice-update-tool-ui.cjs +1 -1
  610. package/dist/tools/voice-update-tool-ui.js +1 -1
  611. package/dist/tools/write-todos-tool-ui.cjs +3 -2
  612. package/dist/tools/write-todos-tool-ui.cjs.map +1 -1
  613. package/dist/tools/write-todos-tool-ui.d.ts +5 -0
  614. package/dist/tools/write-todos-tool-ui.js +5 -4
  615. package/dist/tools/write-todos-tool-ui.js.map +1 -1
  616. package/dist/ui/popover.cjs +6 -6
  617. package/dist/ui/popover.cjs.map +1 -1
  618. package/dist/ui/popover.js +6 -6
  619. package/dist/ui/popover.js.map +1 -1
  620. package/dist/ui/tooltip.cjs +16 -2
  621. package/dist/ui/tooltip.cjs.map +1 -1
  622. package/dist/ui/tooltip.d.ts +1 -1
  623. package/dist/ui/tooltip.js +16 -2
  624. package/dist/ui/tooltip.js.map +1 -1
  625. package/dist/version.cjs +1 -1
  626. package/dist/version.js +1 -1
  627. package/dist/voice/use-athena-voice-session.cjs.map +1 -1
  628. package/dist/voice/use-athena-voice-session.d.ts +3 -3
  629. package/dist/voice/use-athena-voice-session.js.map +1 -1
  630. package/dist/workbench/SessionWorkbench.cjs +378 -0
  631. package/dist/workbench/SessionWorkbench.cjs.map +1 -0
  632. package/dist/workbench/SessionWorkbench.d.ts +30 -0
  633. package/dist/workbench/SessionWorkbench.js +378 -0
  634. package/dist/workbench/SessionWorkbench.js.map +1 -0
  635. package/dist/workbench/session-workbench-context.cjs +26 -0
  636. package/dist/workbench/session-workbench-context.cjs.map +1 -0
  637. package/dist/workbench/session-workbench-context.d.ts +55 -0
  638. package/dist/workbench/session-workbench-context.js +26 -0
  639. package/dist/workbench/session-workbench-context.js.map +1 -0
  640. package/dist/workbench/session-workbench-model.cjs +288 -0
  641. package/dist/workbench/session-workbench-model.cjs.map +1 -0
  642. package/dist/workbench/session-workbench-model.d.ts +168 -0
  643. package/dist/workbench/session-workbench-model.js +288 -0
  644. package/dist/workbench/session-workbench-model.js.map +1 -0
  645. package/dist/workbench/session-workbench-panes.cjs +580 -0
  646. package/dist/workbench/session-workbench-panes.cjs.map +1 -0
  647. package/dist/workbench/session-workbench-panes.d.ts +16 -0
  648. package/dist/workbench/session-workbench-panes.js +580 -0
  649. package/dist/workbench/session-workbench-panes.js.map +1 -0
  650. package/dist/workbench/session-workspace-api.cjs +157 -0
  651. package/dist/workbench/session-workspace-api.cjs.map +1 -0
  652. package/dist/workbench/session-workspace-api.d.ts +70 -0
  653. package/dist/workbench/session-workspace-api.js +157 -0
  654. package/dist/workbench/session-workspace-api.js.map +1 -0
  655. package/dist/workbench/use-session-workspace.cjs +100 -0
  656. package/dist/workbench/use-session-workspace.cjs.map +1 -0
  657. package/dist/workbench/use-session-workspace.d.ts +45 -0
  658. package/dist/workbench/use-session-workspace.js +100 -0
  659. package/dist/workbench/use-session-workspace.js.map +1 -0
  660. package/dist/workbench/workbench-layout-context.cjs +10 -0
  661. package/dist/workbench/workbench-layout-context.cjs.map +1 -0
  662. package/dist/workbench/workbench-layout-context.d.ts +17 -0
  663. package/dist/workbench/workbench-layout-context.js +10 -0
  664. package/dist/workbench/workbench-layout-context.js.map +1 -0
  665. package/package.json +21 -10
  666. package/dist/node_modules/@assistant-ui/react-langchain/dist/converter.cjs +0 -77
  667. package/dist/node_modules/@assistant-ui/react-langchain/dist/converter.cjs.map +0 -1
  668. package/dist/node_modules/@assistant-ui/react-langchain/dist/converter.js +0 -77
  669. package/dist/node_modules/@assistant-ui/react-langchain/dist/converter.js.map +0 -1
  670. package/dist/node_modules/@assistant-ui/react-langgraph/dist/convertLangChainMessages.cjs +0 -181
  671. package/dist/node_modules/@assistant-ui/react-langgraph/dist/convertLangChainMessages.cjs.map +0 -1
  672. package/dist/node_modules/@assistant-ui/react-langgraph/dist/convertLangChainMessages.js +0 -181
  673. package/dist/node_modules/@assistant-ui/react-langgraph/dist/convertLangChainMessages.js.map +0 -1
  674. package/dist/packages/agent-runtime/src/asset-attachment.cjs.map +0 -1
  675. package/dist/packages/agent-runtime/src/asset-attachment.js.map +0 -1
  676. package/dist/packages/agent-runtime/src/auth-denial.cjs.map +0 -1
  677. package/dist/packages/agent-runtime/src/auth-denial.js.map +0 -1
  678. package/dist/packages/agent-runtime/src/client-tool-bridge.cjs.map +0 -1
  679. package/dist/packages/agent-runtime/src/client-tool-bridge.js.map +0 -1
  680. package/dist/packages/agent-runtime/src/client-tools.cjs.map +0 -1
  681. package/dist/packages/agent-runtime/src/client-tools.js.map +0 -1
  682. package/dist/packages/agent-runtime/src/conversation-index.cjs.map +0 -1
  683. package/dist/packages/agent-runtime/src/conversation-index.js.map +0 -1
  684. package/dist/packages/agent-runtime/src/conversation-list.cjs.map +0 -1
  685. package/dist/packages/agent-runtime/src/conversation-list.js.map +0 -1
  686. package/dist/packages/agent-runtime/src/deep-agent-transport-recipe.cjs.map +0 -1
  687. package/dist/packages/agent-runtime/src/deep-agent-transport-recipe.js.map +0 -1
  688. package/dist/packages/agent-runtime/src/edit-command.cjs.map +0 -1
  689. package/dist/packages/agent-runtime/src/edit-command.js.map +0 -1
  690. package/dist/packages/agent-runtime/src/errors.cjs.map +0 -1
  691. package/dist/packages/agent-runtime/src/errors.js.map +0 -1
  692. package/dist/packages/agent-runtime/src/generated/runconfig-contract.cjs.map +0 -1
  693. package/dist/packages/agent-runtime/src/generated/runconfig-contract.js.map +0 -1
  694. package/dist/packages/agent-runtime/src/github-wake-event.cjs.map +0 -1
  695. package/dist/packages/agent-runtime/src/github-wake-event.js.map +0 -1
  696. package/dist/packages/agent-runtime/src/interrupts.cjs.map +0 -1
  697. package/dist/packages/agent-runtime/src/interrupts.js.map +0 -1
  698. package/dist/packages/agent-runtime/src/message-author.cjs.map +0 -1
  699. package/dist/packages/agent-runtime/src/message-author.js.map +0 -1
  700. package/dist/packages/agent-runtime/src/message-window.cjs.map +0 -1
  701. package/dist/packages/agent-runtime/src/message-window.js.map +0 -1
  702. package/dist/packages/agent-runtime/src/messages.cjs.map +0 -1
  703. package/dist/packages/agent-runtime/src/messages.js.map +0 -1
  704. package/dist/packages/agent-runtime/src/model-context.cjs.map +0 -1
  705. package/dist/packages/agent-runtime/src/model-context.js.map +0 -1
  706. package/dist/packages/agent-runtime/src/optimistic-content.cjs.map +0 -1
  707. package/dist/packages/agent-runtime/src/optimistic-content.js.map +0 -1
  708. package/dist/packages/agent-runtime/src/protocol.cjs.map +0 -1
  709. package/dist/packages/agent-runtime/src/protocol.js.map +0 -1
  710. package/dist/packages/agent-runtime/src/queue.cjs.map +0 -1
  711. package/dist/packages/agent-runtime/src/queue.js.map +0 -1
  712. package/dist/packages/agent-runtime/src/quota-safe-local-storage-session.cjs.map +0 -1
  713. package/dist/packages/agent-runtime/src/quota-safe-local-storage-session.js.map +0 -1
  714. package/dist/packages/agent-runtime/src/runtime-messages.cjs.map +0 -1
  715. package/dist/packages/agent-runtime/src/runtime-messages.js.map +0 -1
  716. package/dist/packages/agent-runtime/src/screen-point.cjs.map +0 -1
  717. package/dist/packages/agent-runtime/src/screen-point.js.map +0 -1
  718. package/dist/packages/agent-runtime/src/send-recovery.cjs.map +0 -1
  719. package/dist/packages/agent-runtime/src/send-recovery.js.map +0 -1
  720. package/dist/packages/agent-runtime/src/statewire-attach-observer.cjs.map +0 -1
  721. package/dist/packages/agent-runtime/src/statewire-attach-observer.js.map +0 -1
  722. package/dist/packages/agent-runtime/src/statewire-state.cjs.map +0 -1
  723. package/dist/packages/agent-runtime/src/statewire-state.js.map +0 -1
  724. package/dist/packages/agent-runtime/src/statewire-suspended.cjs.map +0 -1
  725. package/dist/packages/agent-runtime/src/statewire-suspended.js.map +0 -1
  726. package/dist/packages/agent-runtime/src/statewire-transport.cjs +0 -11
  727. package/dist/packages/agent-runtime/src/statewire-transport.cjs.map +0 -1
  728. package/dist/packages/agent-runtime/src/statewire-transport.js +0 -11
  729. package/dist/packages/agent-runtime/src/statewire-transport.js.map +0 -1
  730. package/dist/packages/agent-runtime/src/streaming-markdown.cjs.map +0 -1
  731. package/dist/packages/agent-runtime/src/streaming-markdown.js.map +0 -1
  732. package/dist/packages/agent-runtime/src/thread-extras.cjs.map +0 -1
  733. package/dist/packages/agent-runtime/src/thread-extras.js.map +0 -1
  734. package/dist/packages/agent-runtime/src/thread-snapshot-cache.cjs.map +0 -1
  735. package/dist/packages/agent-runtime/src/thread-snapshot-cache.js.map +0 -1
  736. package/dist/packages/agent-runtime/src/thread-status.cjs.map +0 -1
  737. package/dist/packages/agent-runtime/src/thread-status.js.map +0 -1
  738. package/dist/packages/agent-runtime/src/tool-metadata.cjs.map +0 -1
  739. package/dist/packages/agent-runtime/src/tool-metadata.js.map +0 -1
  740. package/dist/packages/agent-runtime/src/tool-outputs.cjs.map +0 -1
  741. package/dist/packages/agent-runtime/src/tool-outputs.js.map +0 -1
  742. package/dist/packages/agent-runtime/src/tool-result.cjs.map +0 -1
  743. package/dist/packages/agent-runtime/src/tool-result.js.map +0 -1
  744. package/dist/packages/agent-runtime/src/use-conversation-list.cjs.map +0 -1
  745. package/dist/packages/agent-runtime/src/use-conversation-list.js.map +0 -1
  746. package/dist/packages/agent-runtime/src/use-deep-agent-config.cjs +0 -13
  747. package/dist/packages/agent-runtime/src/use-deep-agent-config.cjs.map +0 -1
  748. package/dist/packages/agent-runtime/src/use-deep-agent-config.js +0 -13
  749. package/dist/packages/agent-runtime/src/use-deep-agent-config.js.map +0 -1
  750. package/dist/packages/agent-runtime/src/use-deep-agent-edit-submit.cjs.map +0 -1
  751. package/dist/packages/agent-runtime/src/use-deep-agent-edit-submit.js.map +0 -1
  752. package/dist/packages/agent-runtime/src/use-deep-agent-runtime.cjs.map +0 -1
  753. package/dist/packages/agent-runtime/src/use-deep-agent-runtime.js.map +0 -1
  754. package/dist/packages/agent-runtime/src/use-deep-agent-thread.cjs.map +0 -1
  755. package/dist/packages/agent-runtime/src/use-deep-agent-thread.js.map +0 -1
  756. package/dist/packages/agent-runtime/src/use-deep-agent-window-sync.cjs.map +0 -1
  757. package/dist/packages/agent-runtime/src/use-deep-agent-window-sync.js.map +0 -1
  758. package/dist/packages/agent-runtime/src/voice-presentation.cjs.map +0 -1
  759. package/dist/packages/agent-runtime/src/voice-presentation.js.map +0 -1
  760. package/dist/packages/agent-runtime/src/voice-turn-grouping.cjs.map +0 -1
  761. package/dist/packages/agent-runtime/src/voice-turn-grouping.js.map +0 -1
  762. package/dist/packages/tiptap-markdown-table/src/markdown-table-serializer.cjs.map +0 -1
  763. package/dist/packages/tiptap-markdown-table/src/markdown-table-serializer.js.map +0 -1
  764. /package/dist/{packages/agent-runtime → agent-runtime}/src/asset-attachment.cjs +0 -0
  765. /package/dist/{packages/agent-runtime → agent-runtime}/src/asset-attachment.js +0 -0
  766. /package/dist/{packages/agent-runtime → agent-runtime}/src/auth-denial.cjs +0 -0
  767. /package/dist/{packages/agent-runtime → agent-runtime}/src/auth-denial.js +0 -0
  768. /package/dist/{packages/agent-runtime → agent-runtime}/src/client-tool-bridge.cjs +0 -0
  769. /package/dist/{packages/agent-runtime → agent-runtime}/src/client-tool-bridge.js +0 -0
  770. /package/dist/{packages/agent-runtime → agent-runtime}/src/client-tools.cjs +0 -0
  771. /package/dist/{packages/agent-runtime → agent-runtime}/src/client-tools.js +0 -0
  772. /package/dist/{packages/agent-runtime → agent-runtime}/src/conversation-index.cjs +0 -0
  773. /package/dist/{packages/agent-runtime → agent-runtime}/src/conversation-index.js +0 -0
  774. /package/dist/{packages/agent-runtime → agent-runtime}/src/edit-command.cjs +0 -0
  775. /package/dist/{packages/agent-runtime → agent-runtime}/src/edit-command.js +0 -0
  776. /package/dist/{packages/agent-runtime → agent-runtime}/src/github-wake-event.cjs +0 -0
  777. /package/dist/{packages/agent-runtime → agent-runtime}/src/github-wake-event.js +0 -0
  778. /package/dist/{packages/agent-runtime → agent-runtime}/src/message-author.cjs +0 -0
  779. /package/dist/{packages/agent-runtime → agent-runtime}/src/message-author.js +0 -0
  780. /package/dist/{packages/agent-runtime → agent-runtime}/src/message-window.cjs +0 -0
  781. /package/dist/{packages/agent-runtime → agent-runtime}/src/message-window.js +0 -0
  782. /package/dist/{packages/agent-runtime → agent-runtime}/src/model-context.cjs +0 -0
  783. /package/dist/{packages/agent-runtime → agent-runtime}/src/model-context.js +0 -0
  784. /package/dist/{packages/agent-runtime → agent-runtime}/src/optimistic-content.cjs +0 -0
  785. /package/dist/{packages/agent-runtime → agent-runtime}/src/optimistic-content.js +0 -0
  786. /package/dist/{packages/agent-runtime → agent-runtime}/src/protocol.cjs +0 -0
  787. /package/dist/{packages/agent-runtime → agent-runtime}/src/protocol.js +0 -0
  788. /package/dist/{packages/agent-runtime → agent-runtime}/src/runtime-messages.cjs +0 -0
  789. /package/dist/{packages/agent-runtime → agent-runtime}/src/runtime-messages.js +0 -0
  790. /package/dist/{packages/agent-runtime → agent-runtime}/src/screen-point.cjs +0 -0
  791. /package/dist/{packages/agent-runtime → agent-runtime}/src/screen-point.js +0 -0
  792. /package/dist/{packages/agent-runtime → agent-runtime}/src/send-recovery.cjs +0 -0
  793. /package/dist/{packages/agent-runtime → agent-runtime}/src/send-recovery.js +0 -0
  794. /package/dist/{packages/agent-runtime → agent-runtime}/src/statewire-attach-observer.cjs +0 -0
  795. /package/dist/{packages/agent-runtime → agent-runtime}/src/statewire-attach-observer.js +0 -0
  796. /package/dist/{packages/agent-runtime → agent-runtime}/src/streaming-markdown.cjs +0 -0
  797. /package/dist/{packages/agent-runtime → agent-runtime}/src/streaming-markdown.js +0 -0
  798. /package/dist/{packages/agent-runtime → agent-runtime}/src/thread-extras.cjs +0 -0
  799. /package/dist/{packages/agent-runtime → agent-runtime}/src/thread-extras.js +0 -0
  800. /package/dist/{packages/agent-runtime → agent-runtime}/src/thread-snapshot-cache.cjs +0 -0
  801. /package/dist/{packages/agent-runtime → agent-runtime}/src/thread-snapshot-cache.js +0 -0
  802. /package/dist/{packages/agent-runtime → agent-runtime}/src/thread-status.cjs +0 -0
  803. /package/dist/{packages/agent-runtime → agent-runtime}/src/thread-status.js +0 -0
  804. /package/dist/{packages/agent-runtime → agent-runtime}/src/tool-outputs.cjs +0 -0
  805. /package/dist/{packages/agent-runtime → agent-runtime}/src/tool-outputs.js +0 -0
  806. /package/dist/{packages/agent-runtime → agent-runtime}/src/tool-result.cjs +0 -0
  807. /package/dist/{packages/agent-runtime → agent-runtime}/src/tool-result.js +0 -0
  808. /package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-runtime.cjs +0 -0
  809. /package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-runtime.js +0 -0
  810. /package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-window-sync.cjs +0 -0
  811. /package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-window-sync.js +0 -0
  812. /package/dist/{packages/agent-runtime → agent-runtime}/src/voice-turn-grouping.cjs +0 -0
  813. /package/dist/{packages/agent-runtime → agent-runtime}/src/voice-turn-grouping.js +0 -0
  814. /package/dist/{packages/react → react}/package.json.cjs.map +0 -0
  815. /package/dist/{packages/react → react}/package.json.js.map +0 -0
  816. /package/dist/{packages/tiptap-markdown-table → tiptap-markdown-table}/src/markdown-table-serializer.cjs +0 -0
  817. /package/dist/{packages/tiptap-markdown-table → tiptap-markdown-table}/src/markdown-table-serializer.js +0 -0
@@ -11,14 +11,16 @@ const react$1 = require("@assistant-ui/react");
11
11
  const composerHandoff = require("../../composer/composer-handoff.cjs");
12
12
  const lucideReact = require("lucide-react");
13
13
  const chatTextSchema = require("../rich-text/chat-text-schema.cjs");
14
- const markdownStorage = require("../markdown-storage.cjs");
15
14
  const mentionSuggestions_extension = require("../mentions/suggestions/mention-suggestions.extension.cjs");
16
15
  const mentionSuggestionPopup = require("../mentions/suggestions/components/mention-suggestion-popup.cjs");
17
16
  const mentionSuggestionList = require("../mentions/suggestions/components/mention-suggestion-list.cjs");
18
17
  const useMentionSuggestions = require("../mentions/suggestions/data/use-mention-suggestions.cjs");
18
+ const state = require("@tiptap/pm/state");
19
+ const composerMessage = require("./composer-message.cjs");
19
20
  const pendingAttachmentUploads = require("./pending-attachment-uploads.cjs");
20
21
  const runInputRulesOnEnter = require("./run-input-rules-on-enter.cjs");
21
- const assetAttachment = require("../../packages/agent-runtime/src/asset-attachment.cjs");
22
+ const athenaAssetDrag = require("../../agent-runtime/src/athena-asset-drag.cjs");
23
+ const assetAttachment = require("../../agent-runtime/src/asset-attachment.cjs");
22
24
  const cnfast = require("cnfast");
23
25
  const SubmitKeybind = core.Extension.create({
24
26
  name: "submitKeybind",
@@ -76,7 +78,16 @@ const MENTION_STYLES = `
76
78
  }
77
79
  `;
78
80
  function serializeDraft(editor) {
79
- return markdownStorage.getMarkdownStorage(editor).getMarkdown();
81
+ return composerMessage.serializeComposerDraft(editor);
82
+ }
83
+ function appendPlainText(editor, text) {
84
+ const words = text.trim();
85
+ if (!words || editor.isDestroyed) return false;
86
+ const end = state.Selection.atEnd(editor.state.doc);
87
+ const before = end.$from.nodeBefore;
88
+ const needsSpace = before !== null && before.type.name !== "hardBreak" && !(before.isText && /\s$/.test(before.text ?? ""));
89
+ editor.chain().setTextSelection(end.from).insertContent({ type: "text", text: needsSpace ? ` ${words}` : words }).run();
90
+ return true;
80
91
  }
81
92
  const NO_WEBPAGES = [];
82
93
  function revokeImagePreview(src) {
@@ -158,6 +169,7 @@ const TiptapComposer = react.forwardRef(
158
169
  const handoff = composerHandoff.useComposerHandoffStore();
159
170
  const applyingRuntimeTextRef = react.useRef(false);
160
171
  const lastEmittedMarkdownRef = react.useRef(null);
172
+ const restoredSendRef = react.useRef(null);
161
173
  const listRef = react.useRef(null);
162
174
  const pendingUploadsRef = react.useRef(new pendingAttachmentUploads.PendingAttachmentUploads());
163
175
  const submitInFlightRef = react.useRef(false);
@@ -228,10 +240,10 @@ const TiptapComposer = react.forwardRef(
228
240
  await (waitForHostUploads == null ? void 0 : waitForHostUploads());
229
241
  const ed = editorRef.current;
230
242
  if (!ed) return;
231
- const text = serializeDraft(ed).trim();
243
+ const { text, draftMarkdown } = composerMessage.captureComposerSend(ed);
232
244
  if (interceptSubmit) {
233
245
  const hasAttachments = (((_a = aui.composer.getState().attachments) == null ? void 0 : _a.length) ?? 0) > 0;
234
- if (!hasAttachments && await interceptSubmit(text)) {
246
+ if (!hasAttachments && await interceptSubmit(text, draftMarkdown)) {
235
247
  ed.commands.clearContent(false);
236
248
  clearImagePreviews();
237
249
  onDraftStateChange == null ? void 0 : onDraftStateChange(false);
@@ -241,6 +253,7 @@ const TiptapComposer = react.forwardRef(
241
253
  }
242
254
  if (!text) return;
243
255
  if (!composerInput.canSend) return;
256
+ composerMessage.prepareComposerSend({ threadId, text, draftMarkdown });
244
257
  composerInput.setText(text);
245
258
  composerInput.send({ steer: false });
246
259
  ed.commands.clearContent(false);
@@ -257,6 +270,7 @@ const TiptapComposer = react.forwardRef(
257
270
  interceptSubmit,
258
271
  onDraftStateChange,
259
272
  onSubmitted,
273
+ threadId,
260
274
  waitForHostUploads
261
275
  ]);
262
276
  const handleSubmitRef = react.useRef(handleSubmit);
@@ -344,29 +358,65 @@ const TiptapComposer = react.forwardRef(
344
358
  },
345
359
  [addAttachment, fileIntake, onAttachmentError]
346
360
  );
361
+ const disabledRef = react.useRef(disabled);
362
+ disabledRef.current = disabled;
363
+ const insertAssetMentionRef = react.useRef(
364
+ () => {
365
+ }
366
+ );
367
+ const handleAssetDrop = react.useCallback(
368
+ (event, view) => {
369
+ if (disabledRef.current || !event.dataTransfer) return false;
370
+ const dropped = athenaAssetDrag.readAthenaAssetDrop(event.dataTransfer);
371
+ if (!dropped) return false;
372
+ event.preventDefault();
373
+ if (dropped.kind !== "asset") return true;
374
+ const position = view == null ? void 0 : view.posAtCoords({
375
+ left: event.clientX,
376
+ top: event.clientY
377
+ });
378
+ if (view) {
379
+ const { state: state$1 } = view;
380
+ view.dispatch(
381
+ state$1.tr.setSelection(
382
+ position ? state.Selection.near(state$1.doc.resolve(position.pos)) : state.Selection.atEnd(state$1.doc)
383
+ )
384
+ );
385
+ }
386
+ insertAssetMentionRef.current(dropped.asset);
387
+ return true;
388
+ },
389
+ []
390
+ );
347
391
  const handleDrop = react.useCallback(
348
- (_view, event) => {
392
+ (view, event) => {
349
393
  var _a;
394
+ if (handleAssetDrop(event, view)) return true;
350
395
  const files = (_a = event.dataTransfer) == null ? void 0 : _a.files;
351
396
  if (!(files == null ? void 0 : files.length)) return false;
352
397
  const handled = addDroppedImages(files);
353
398
  if (handled) event.preventDefault();
354
399
  return handled;
355
400
  },
356
- [addDroppedImages]
401
+ [addDroppedImages, handleAssetDrop]
357
402
  );
358
403
  const handleComposerDrop = react.useCallback(
359
404
  (event) => {
405
+ var _a;
360
406
  if (event.defaultPrevented) return;
407
+ if (handleAssetDrop(event.nativeEvent, (_a = editorRef.current) == null ? void 0 : _a.view)) return;
361
408
  if (addDroppedImages(event.dataTransfer.files)) event.preventDefault();
362
409
  },
363
- [addDroppedImages]
410
+ [addDroppedImages, handleAssetDrop]
364
411
  );
412
+ const placeholderRef = react.useRef(placeholder);
413
+ placeholderRef.current = placeholder;
365
414
  const editor = react$2.useEditor({
366
415
  editable: !disabled,
367
416
  extensions: [
368
417
  ...chatTextSchema.createChatTextExtensions(),
369
- Placeholder.configure({ placeholder }),
418
+ composerMessage.ComposerDraftWhitespace,
419
+ Placeholder.configure({ placeholder: () => placeholderRef.current }),
370
420
  mentionSuggestions_extension.MentionSuggestionsExtension.configure({
371
421
  store,
372
422
  callbacks: callbacksRef.current
@@ -409,20 +459,29 @@ const TiptapComposer = react.forwardRef(
409
459
  react.useEffect(() => {
410
460
  editor == null ? void 0 : editor.setEditable(!disabled);
411
461
  }, [disabled, editor]);
462
+ react.useEffect(() => {
463
+ if (!editor || editor.isDestroyed) return;
464
+ editor.view.dispatch(editor.state.tr.setMeta("addToHistory", false));
465
+ }, [editor, placeholder]);
412
466
  react.useEffect(() => {
413
467
  if (!editor) return;
414
468
  const value = composerInput.value;
415
469
  if (value === lastEmittedMarkdownRef.current) return;
470
+ if (value === restoredSendRef.current) return;
471
+ restoredSendRef.current = null;
416
472
  const currentMarkdown = serializeDraft(editor);
417
473
  lastEmittedMarkdownRef.current = currentMarkdown;
418
- if (value === currentMarkdown) return;
474
+ const returnedDraft = editor.isEmpty ? composerMessage.draftForReturnedSend({ threadId, text: value }) : null;
475
+ const restored = returnedDraft ?? value;
476
+ if (restored === currentMarkdown) return;
419
477
  let cancelled = false;
420
478
  queueMicrotask(() => {
421
479
  if (cancelled || editor.isDestroyed) return;
422
480
  applyingRuntimeTextRef.current = true;
423
481
  try {
424
- editor.commands.setContent(value, { emitUpdate: false });
482
+ editor.commands.setContent(restored, { emitUpdate: false });
425
483
  lastEmittedMarkdownRef.current = serializeDraft(editor);
484
+ if (returnedDraft !== null) restoredSendRef.current = value;
426
485
  } finally {
427
486
  applyingRuntimeTextRef.current = false;
428
487
  }
@@ -435,12 +494,16 @@ const TiptapComposer = react.forwardRef(
435
494
  return () => {
436
495
  cancelled = true;
437
496
  };
438
- }, [composerInput.value, editor, handoff, onDraftStateChange]);
497
+ }, [composerInput.value, editor, handoff, onDraftStateChange, threadId]);
439
498
  react.useEffect(() => {
440
499
  if (!editor || !handoff) return;
441
500
  handoff.focusEnd = () => {
442
501
  if (!editor.isDestroyed) editor.commands.focus("end");
443
502
  };
503
+ if (handoff.focusOnMount) {
504
+ handoff.focusOnMount = false;
505
+ handoff.focusEnd();
506
+ }
444
507
  return () => {
445
508
  handoff.focusEnd = null;
446
509
  };
@@ -485,6 +548,7 @@ const TiptapComposer = react.forwardRef(
485
548
  },
486
549
  [replaceImagePreviews, showImagePreviews]
487
550
  );
551
+ insertAssetMentionRef.current = insertAssetMention;
488
552
  const removeImagePreview = react.useCallback(
489
553
  (preview) => {
490
554
  if (!preview.assetId) return;
@@ -523,15 +587,32 @@ const TiptapComposer = react.forwardRef(
523
587
  const needsSpace = before.length > 0 && !/[\s([{"']/.test(before);
524
588
  currentEditor.chain().focus().insertContent({ type: "text", text: needsSpace ? " @" : "@" }).run();
525
589
  }, [disabled]);
590
+ const appendText = react.useCallback((text) => {
591
+ const currentEditor = editorRef.current;
592
+ if (currentEditor) appendPlainText(currentEditor, text);
593
+ }, []);
594
+ const captureSend = react.useCallback(() => {
595
+ const currentEditor = editorRef.current;
596
+ return currentEditor && !currentEditor.isDestroyed ? composerMessage.captureComposerSend(currentEditor) : null;
597
+ }, []);
526
598
  react.useImperativeHandle(
527
599
  outerRef,
528
600
  () => ({
529
601
  submit: handleSubmit,
530
602
  addAttachment,
531
603
  insertAssetMention,
532
- openMentionMenu
604
+ openMentionMenu,
605
+ appendText,
606
+ captureSend
533
607
  }),
534
- [addAttachment, handleSubmit, insertAssetMention, openMentionMenu]
608
+ [
609
+ addAttachment,
610
+ appendText,
611
+ captureSend,
612
+ handleSubmit,
613
+ insertAssetMention,
614
+ openMentionMenu
615
+ ]
535
616
  );
536
617
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
537
618
  /* @__PURE__ */ jsxRuntime.jsx("style", { children: MENTION_STYLES }),
@@ -546,7 +627,8 @@ const TiptapComposer = react.forwardRef(
546
627
  "aria-label": "Message composer",
547
628
  "aria-disabled": disabled,
548
629
  onDragOver: (event) => {
549
- if (Array.from(event.dataTransfer.types).includes("Files")) {
630
+ const types = Array.from(event.dataTransfer.types);
631
+ if (types.includes("Files") || !disabled && athenaAssetDrag.isAthenaAssetDrag(types)) {
550
632
  event.preventDefault();
551
633
  event.dataTransfer.dropEffect = "copy";
552
634
  }
@@ -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` — the serializer\n * the Olympus chat composer sends with — so pasted hyperlinks keep their URL,\n * formatting marks survive, paragraphs stay separated, and a mention is the\n * `[@Name](url)` link the message renderer parses back into a chip.\n */\n\nimport { athenaDiagnostics } from \"../../diagnostics/athena-diagnostics\";\nimport {\n clipboardHasMeaningfulText,\n extractPastedImages,\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 { useComposerHandoffStore } from \"../../composer/composer-handoff\";\nimport { LoaderCircleIcon, XIcon } from \"lucide-react\";\nimport { cn } from \"../../lib/utils\";\nimport { CHAT_TEXT_CLASS, createChatTextExtensions } from \"../rich-text/chat-text-schema\";\nimport { getMarkdownStorage } from \"../markdown-storage\";\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 {\n registerChatAssetMentionHandler,\n type UploadedChatAsset,\n} from \"@athenaintel/agent-runtime\";\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/** The draft as it is sent: Markdown, mentions as `[@Name](url)` links. */\nexport function serializeDraft(editor: Editor): string {\n return getMarkdownStorage(editor).getMarkdown();\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\nexport interface TiptapComposerProps {\n placeholder?: string;\n threadId: string;\n disabled?: 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 /** 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 */\n interceptSubmit?: (text: string) => boolean | Promise<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\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 appearance = \"default\",\n webpages = NO_WEBPAGES,\n tools,\n rootCategories,\n onDraftStateChange,\n showImagePreviews = false,\n onAttachmentError,\n fileIntake,\n waitForHostUploads,\n interceptSubmit,\n onSubmitted,\n },\n outerRef,\n ) => {\n const aui = useAui();\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 const listRef = useRef<KeyboardNavigationHandle>(null);\n const pendingUploadsRef = useRef(new PendingAttachmentUploads());\n const submitInFlightRef = useRef(false);\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) return;\n if (submitInFlightRef.current) return;\n submitInFlightRef.current = true;\n try {\n await pendingUploadsRef.current.waitForIdle();\n await waitForHostUploads?.();\n const ed = editorRef.current;\n if (!ed) return;\n const text = serializeDraft(ed).trim();\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 && (await interceptSubmit(text))) {\n ed.commands.clearContent(false);\n clearImagePreviews();\n onDraftStateChange?.(false);\n onSubmitted?.();\n return;\n }\n }\n\n if (!text) return;\n if (!composerInput.canSend) return;\n\n composerInput.setText(text);\n composerInput.send({ steer: false });\n\n ed.commands.clearContent(false);\n clearImagePreviews();\n onDraftStateChange?.(false);\n onSubmitted?.();\n } finally {\n submitInFlightRef.current = false;\n }\n }, [\n clearImagePreviews,\n composerInput,\n disabled,\n interceptSubmit,\n onDraftStateChange,\n onSubmitted,\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 if (images.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.\n if (\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);\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?.(\"Couldn’t paste that image.\");\n athenaDiagnostics.error(\n \"composer.attachment.error\",\n error,\n { code: \"attachment_failed\", message: \"Pasted image upload failed\" },\n { source: \"paste\", type: file.type },\n );\n });\n }\n return true;\n },\n [addAttachment, fileIntake, onAttachmentError],\n );\n\n // Without a host intake the composer attaches dropped images itself; a host\n // intake without `onDrop` leaves drops to the enclosing drop zone.\n const addDroppedImages = useCallback(\n (files: FileList | readonly File[]) => {\n const images = Array.from(files).filter((file) =>\n file.type.startsWith(\"image/\"),\n );\n if (images.length === 0) return false;\n if (fileIntake) {\n if (!fileIntake.onDrop) return false;\n fileIntake.onDrop(images);\n return true;\n }\n for (const file of images) {\n void addAttachment(file).catch((error: unknown) => {\n onAttachmentError?.(\"Couldn’t attach that dropped image.\");\n athenaDiagnostics.error(\n \"composer.attachment.error\",\n error,\n { code: \"attachment_failed\", message: \"Dropped image upload failed\" },\n { source: \"drop\", type: file.type },\n );\n });\n }\n return true;\n },\n [addAttachment, fileIntake, onAttachmentError],\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: unknown, event: DragEvent) => {\n const files = event.dataTransfer?.files;\n if (!files?.length) return false;\n const handled = addDroppedImages(files);\n if (handled) event.preventDefault();\n return handled;\n },\n [addDroppedImages],\n );\n\n const handleComposerDrop = useCallback(\n (event: ReactDragEvent<HTMLDivElement>) => {\n if (event.defaultPrevented) return;\n if (addDroppedImages(event.dataTransfer.files)) event.preventDefault();\n },\n [addDroppedImages],\n );\n\n const editor = useEditor({\n editable: !disabled,\n extensions: [\n ...createChatTextExtensions(),\n Placeholder.configure({ placeholder }),\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 editor?.setEditable(!disabled);\n }, [disabled, editor]);\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. 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 useEffect(() => {\n if (!editor) return;\n const value = composerInput.value;\n if (value === lastEmittedMarkdownRef.current) return;\n const currentMarkdown = serializeDraft(editor);\n lastEmittedMarkdownRef.current = currentMarkdown;\n if (value === 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(value, { emitUpdate: false });\n lastEmittedMarkdownRef.current = serializeDraft(editor);\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]);\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 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\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 useImperativeHandle(\n outerRef,\n () => ({\n submit: handleSubmit,\n addAttachment,\n insertAssetMention,\n openMentionMenu,\n }),\n [addAttachment, handleSubmit, insertAssetMention, openMentionMenu],\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 if (Array.from(event.dataTransfer.types).includes(\"Files\")) {\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","getMarkdownStorage","jsx","jsxs","LoaderCircleIcon","XIcon","forwardRef","useAui","unstable_useComposerInput","useComposerHandoffStore","useRef","PendingAttachmentUploads","useState","useCallback","useEffect","useMentionSuggestions","extractPastedImages","clipboardHasMeaningfulText","athenaDiagnostics","useEditor","createChatTextExtensions","MentionSuggestionsExtension","cn","CHAT_TEXT_CLASS","registerChatAssetMentionHandler","useImperativeHandle","Fragment","EditorContent","MentionSuggestionPopup","MentionSuggestionList"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAwEA,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;AA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,cAAA;AAAA,gBACC,UAAU;AAAA,gBACV,UAAU;AAAA,cAAA;AAAA,YAAA;AAAA,YAEZA,+BAACyB,QAAAA,iBAAc,OAAA,CAAgB;AAAA,UAAA;AAAA,QAAA;AAAA,MAAA;AAAA,MAIhC,aAAa,cAAc,yCACzBC,uBAAAA,wBAAA,EAAuB,YAAY,WAAW,YAC7C,UAAA1B,2BAAAA;AAAAA,QAAC2B,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} 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 { useComposerHandoffStore } from \"../../composer/composer-handoff\";\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} 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 /** 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 /** 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 * `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 * 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\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 appearance = \"default\",\n webpages = NO_WEBPAGES,\n tools,\n rootCategories,\n onDraftStateChange,\n showImagePreviews = false,\n onAttachmentError,\n fileIntake,\n waitForHostUploads,\n interceptSubmit,\n onSubmitted,\n },\n outerRef,\n ) => {\n const aui = useAui();\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 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) return;\n if (submitInFlightRef.current) return;\n submitInFlightRef.current = true;\n try {\n await pendingUploadsRef.current.waitForIdle();\n await waitForHostUploads?.();\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\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 && (await interceptSubmit(text, draftMarkdown))) {\n ed.commands.clearContent(false);\n clearImagePreviews();\n onDraftStateChange?.(false);\n onSubmitted?.();\n return;\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 ed.commands.clearContent(false);\n clearImagePreviews();\n onDraftStateChange?.(false);\n onSubmitted?.();\n } finally {\n submitInFlightRef.current = false;\n }\n }, [\n clearImagePreviews,\n composerInput,\n disabled,\n interceptSubmit,\n onDraftStateChange,\n onSubmitted,\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 if (images.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.\n if (\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);\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?.(\"Couldn’t paste that image.\");\n athenaDiagnostics.error(\n \"composer.attachment.error\",\n error,\n { code: \"attachment_failed\", message: \"Pasted image upload failed\" },\n { source: \"paste\", type: file.type },\n );\n });\n }\n return true;\n },\n [addAttachment, fileIntake, onAttachmentError],\n );\n\n // Without a host intake the composer attaches dropped images itself; a host\n // intake without `onDrop` leaves drops to the enclosing drop zone.\n const addDroppedImages = useCallback(\n (files: FileList | readonly File[]) => {\n const images = Array.from(files).filter((file) =>\n file.type.startsWith(\"image/\"),\n );\n if (images.length === 0) return false;\n if (fileIntake) {\n if (!fileIntake.onDrop) return false;\n fileIntake.onDrop(images);\n return true;\n }\n for (const file of images) {\n void addAttachment(file).catch((error: unknown) => {\n onAttachmentError?.(\"Couldn’t attach that dropped image.\");\n athenaDiagnostics.error(\n \"composer.attachment.error\",\n error,\n { code: \"attachment_failed\", message: \"Dropped image upload failed\" },\n { source: \"drop\", type: file.type },\n );\n });\n }\n return true;\n },\n [addAttachment, fileIntake, onAttachmentError],\n );\n\n // Read through a ref: the mention inserter is defined after the editor.\n const disabledRef = useRef(disabled);\n disabledRef.current = disabled;\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 = addDroppedImages(files);\n if (handled) event.preventDefault();\n return handled;\n },\n [addDroppedImages, 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 (addDroppedImages(event.dataTransfer.files)) event.preventDefault();\n },\n [addDroppedImages, 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 editor?.setEditable(!disabled);\n }, [disabled, editor]);\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","unstable_useComposerInput","useComposerHandoffStore","useRef","PendingAttachmentUploads","useState","useCallback","useEffect","useMentionSuggestions","captureComposerSend","prepareComposerSend","extractPastedImages","clipboardHasMeaningfulText","athenaDiagnostics","readAthenaAssetDrop","state","useEditor","createChatTextExtensions","ComposerDraftWhitespace","MentionSuggestionsExtension","cn","CHAT_TEXT_CLASS","draftForReturnedSend","registerChatAssetMentionHandler","useImperativeHandle","Fragment","isAthenaAssetDrag","EditorContent","MentionSuggestionPopup","MentionSuggestionList"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAuFA,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,gBAAAA,uBAAuB,MAAM;AACtC;AAOA,SAAS,gBAAgB,QAAgB,MAAuB;AAC9D,QAAM,QAAQ,KAAK,KAAA;AACnB,MAAI,CAAC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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;;;"}
@@ -13,21 +13,31 @@
13
13
  * host-only mention items — browser tabs through `webpages`, its own Tools /
14
14
  * Toolkits list through `tools`.
15
15
  *
16
- * The draft serializes to Markdown through `tiptap-markdown` — the serializer
17
- * the Olympus chat composer sends with — so pasted hyperlinks keep their URL,
18
- * formatting marks survive, paragraphs stay separated, and a mention is the
19
- * `[@Name](url)` link the message renderer parses back into a chip.
16
+ * The draft serializes to Markdown through `tiptap-markdown`, so pasted
17
+ * hyperlinks keep their URL, formatting marks survive, paragraphs stay
18
+ * separated, and a mention is the `[@Name](url)` link the message renderer
19
+ * parses back into a chip. Send delivers that Markdown with every plain-text
20
+ * run written exactly as typed (`serializeComposerMessage`), as the Olympus
21
+ * chat composer does, and the message carries the draft it was sent from
22
+ * (`metadata.composer_markdown`, only when the two differ) so its bubble
23
+ * shows the text exactly as typed.
20
24
  */
21
25
  import { type Editor } from "@tiptap/core";
22
26
  import { type MentionRootCategory } from "../mentions/suggestions/data/use-mention-suggestions";
23
27
  import type { MentionTool, WebpageMention } from "../mentions/suggestions/data/types";
24
28
  import { type UploadedChatAsset } from "@athenaintel/agent-runtime";
29
+ import { type ComposerSend } from "./composer-message";
25
30
  /**
26
31
  * The editor's look. `default` is what the Chrome extension and Office add-in
27
32
  * render; `paper` pairs with `ChatComposerDock appearance="paper"`.
28
33
  */
29
34
  export type TiptapComposerAppearance = "default" | "paper";
30
- /** The draft as it is sent: Markdown, mentions as `[@Name](url)` links. */
35
+ /**
36
+ * The draft as Markdown, mentions as `[@Name](url)` links: what the composer
37
+ * mirrors into the composer runtime and parses back on a restore
38
+ * (`serializeComposerDraft`, which reads back into the same document). Send
39
+ * delivers it with plain text written as typed (`serializeComposerMessage`).
40
+ */
31
41
  export declare function serializeDraft(editor: Editor): string;
32
42
  /**
33
43
  * A host's own intake for the files pasted into or dropped on the composer
@@ -50,6 +60,19 @@ export interface TiptapComposerHandle {
50
60
  * type-checking; the composer itself always provides it.
51
61
  */
52
62
  openMentionMenu?: () => void;
63
+ /**
64
+ * Appends `text` to the draft as typed plain text, never read as Markdown,
65
+ * one space after any text on the draft's last line — how dictated words
66
+ * join the draft. Optional on the type, like `openMentionMenu`.
67
+ */
68
+ appendText?: (text: string) => void;
69
+ /**
70
+ * The draft as a send would deliver it — `text` with plain text exactly as
71
+ * typed, `draftMarkdown` the same document as Markdown that reads back into
72
+ * it — or `null` before the editor mounts. For a host that sends the draft
73
+ * itself (AthenaChat's dictated send) through `prepareComposerSend`.
74
+ */
75
+ captureSend?: () => ComposerSend | null;
53
76
  }
54
77
  export interface TiptapComposerProps {
55
78
  placeholder?: string;
@@ -88,8 +111,13 @@ export interface TiptapComposerProps {
88
111
  * composer-runtime send. Return `true` when the host consumed the draft
89
112
  * through another lane (e.g. a live voice session) — the editor clears and
90
113
  * the normal send is skipped. Return `false` to fall through unchanged.
114
+ * `text` is plain text written exactly as typed (what the model should
115
+ * read); `draftMarkdown` is the same draft with plain text escaped for
116
+ * Markdown (`serializeComposerDraft`), for a host that sends the message
117
+ * itself: `prepareComposerSend` remembers it, so a send handed back loads
118
+ * exactly, and puts it on the message as its composer markdown.
91
119
  */
92
- interceptSubmit?: (text: string) => boolean | Promise<boolean>;
120
+ interceptSubmit?: (text: string, draftMarkdown: string) => boolean | Promise<boolean>;
93
121
  /**
94
122
  * Called after a draft has left the editor — through the composer-runtime
95
123
  * send or a host interception — from Enter and the imperative handle alike.