@athenaintel/react 0.20.0 → 0.21.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 (347) hide show
  1. package/README.md +74 -0
  2. package/dist/assets/use-asset-embed.cjs +8 -0
  3. package/dist/assets/use-asset-embed.cjs.map +1 -1
  4. package/dist/assets/use-asset-embed.js +8 -0
  5. package/dist/assets/use-asset-embed.js.map +1 -1
  6. package/dist/chat/StatewireApprovalCard.cjs +22 -4
  7. package/dist/chat/StatewireApprovalCard.cjs.map +1 -1
  8. package/dist/chat/StatewireApprovalCard.d.ts +14 -0
  9. package/dist/chat/StatewireApprovalCard.js +23 -5
  10. package/dist/chat/StatewireApprovalCard.js.map +1 -1
  11. package/dist/chat/StatewireClientToolBridge.cjs +2 -1
  12. package/dist/chat/StatewireClientToolBridge.cjs.map +1 -1
  13. package/dist/chat/StatewireClientToolBridge.js +2 -1
  14. package/dist/chat/StatewireClientToolBridge.js.map +1 -1
  15. package/dist/chat/StatewireQueuedMessages.cjs +2 -1
  16. package/dist/chat/StatewireQueuedMessages.cjs.map +1 -1
  17. package/dist/chat/StatewireQueuedMessages.js +2 -1
  18. package/dist/chat/StatewireQueuedMessages.js.map +1 -1
  19. package/dist/chat/athena-citation-links.cjs +17 -1
  20. package/dist/chat/athena-citation-links.cjs.map +1 -1
  21. package/dist/chat/athena-citation-links.js +17 -1
  22. package/dist/chat/athena-citation-links.js.map +1 -1
  23. package/dist/chat/statewire-client-tools.cjs +2 -1
  24. package/dist/chat/statewire-client-tools.cjs.map +1 -1
  25. package/dist/chat/statewire-client-tools.js +2 -1
  26. package/dist/chat/statewire-client-tools.js.map +1 -1
  27. package/dist/chat/super-grouping/SuperGroupingCard.cjs +69 -187
  28. package/dist/chat/super-grouping/SuperGroupingCard.cjs.map +1 -1
  29. package/dist/chat/super-grouping/SuperGroupingCard.d.ts +10 -6
  30. package/dist/chat/super-grouping/SuperGroupingCard.js +73 -191
  31. package/dist/chat/super-grouping/SuperGroupingCard.js.map +1 -1
  32. package/dist/chat/super-grouping/ToolTimeline.cjs +131 -0
  33. package/dist/chat/super-grouping/ToolTimeline.cjs.map +1 -0
  34. package/dist/chat/super-grouping/ToolTimeline.d.ts +16 -0
  35. package/dist/chat/super-grouping/ToolTimeline.js +131 -0
  36. package/dist/chat/super-grouping/ToolTimeline.js.map +1 -0
  37. package/dist/chat/super-grouping/activity-timeline.cjs +14 -8
  38. package/dist/chat/super-grouping/activity-timeline.cjs.map +1 -1
  39. package/dist/chat/super-grouping/activity-timeline.d.ts +3 -0
  40. package/dist/chat/super-grouping/activity-timeline.js +14 -8
  41. package/dist/chat/super-grouping/activity-timeline.js.map +1 -1
  42. package/dist/chat/super-grouping/timeline-step.cjs +65 -0
  43. package/dist/chat/super-grouping/timeline-step.cjs.map +1 -0
  44. package/dist/chat/super-grouping/timeline-step.d.ts +17 -0
  45. package/dist/chat/super-grouping/timeline-step.js +65 -0
  46. package/dist/chat/super-grouping/timeline-step.js.map +1 -0
  47. package/dist/chat/tiptap-text.cjs +8 -8
  48. package/dist/chat/tiptap-text.cjs.map +1 -1
  49. package/dist/chat/use-athena-run-live.cjs +2 -1
  50. package/dist/chat/use-athena-run-live.cjs.map +1 -1
  51. package/dist/chat/use-athena-run-live.js +2 -1
  52. package/dist/chat/use-athena-run-live.js.map +1 -1
  53. package/dist/chat/use-statewire-approval-request.cjs +7 -2
  54. package/dist/chat/use-statewire-approval-request.cjs.map +1 -1
  55. package/dist/chat/use-statewire-approval-request.d.ts +12 -2
  56. package/dist/chat/use-statewire-approval-request.js +8 -3
  57. package/dist/chat/use-statewire-approval-request.js.map +1 -1
  58. package/dist/chat-ui/composer/tiptap-composer.cjs +24 -65
  59. package/dist/chat-ui/composer/tiptap-composer.cjs.map +1 -1
  60. package/dist/chat-ui/composer/tiptap-composer.js +24 -65
  61. package/dist/chat-ui/composer/tiptap-composer.js.map +1 -1
  62. package/dist/chat-ui/index.cjs +2 -1
  63. package/dist/chat-ui/index.cjs.map +1 -1
  64. package/dist/chat-ui/index.js +2 -1
  65. package/dist/chat-ui/index.js.map +1 -1
  66. package/dist/chat-ui/mentions/mention-chip.cjs +49 -4
  67. package/dist/chat-ui/mentions/mention-chip.cjs.map +1 -1
  68. package/dist/chat-ui/mentions/mention-chip.d.ts +11 -0
  69. package/dist/chat-ui/mentions/mention-chip.js +50 -5
  70. package/dist/chat-ui/mentions/mention-chip.js.map +1 -1
  71. package/dist/chat-ui/mentions/mention-extension.cjs +18 -6
  72. package/dist/chat-ui/mentions/mention-extension.cjs.map +1 -1
  73. package/dist/chat-ui/mentions/mention-extension.d.ts +2 -0
  74. package/dist/chat-ui/mentions/mention-extension.js +18 -6
  75. package/dist/chat-ui/mentions/mention-extension.js.map +1 -1
  76. package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-list.cjs +1 -1
  77. package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-list.cjs.map +1 -1
  78. package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-list.js +1 -1
  79. package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-list.js.map +1 -1
  80. package/dist/chat-ui/mentions/suggestions/components/menu-item.cjs +9 -6
  81. package/dist/chat-ui/mentions/suggestions/components/menu-item.cjs.map +1 -1
  82. package/dist/chat-ui/mentions/suggestions/components/menu-item.d.ts +2 -2
  83. package/dist/chat-ui/mentions/suggestions/components/menu-item.js +10 -7
  84. package/dist/chat-ui/mentions/suggestions/components/menu-item.js.map +1 -1
  85. package/dist/chat-ui/mentions/suggestions/components/menu-list.cjs +2 -2
  86. package/dist/chat-ui/mentions/suggestions/components/menu-list.cjs.map +1 -1
  87. package/dist/chat-ui/mentions/suggestions/components/menu-list.d.ts +2 -2
  88. package/dist/chat-ui/mentions/suggestions/components/menu-list.js +2 -2
  89. package/dist/chat-ui/mentions/suggestions/components/menu-list.js.map +1 -1
  90. package/dist/chat-ui/mentions/suggestions/data/api-client.cjs +2 -1
  91. package/dist/chat-ui/mentions/suggestions/data/api-client.cjs.map +1 -1
  92. package/dist/chat-ui/mentions/suggestions/data/api-client.d.ts +3 -2
  93. package/dist/chat-ui/mentions/suggestions/data/api-client.js +2 -1
  94. package/dist/chat-ui/mentions/suggestions/data/api-client.js.map +1 -1
  95. package/dist/chat-ui/messages/message-components.cjs +6 -29
  96. package/dist/chat-ui/messages/message-components.cjs.map +1 -1
  97. package/dist/chat-ui/messages/message-components.d.ts +1 -13
  98. package/dist/chat-ui/messages/message-components.js +8 -31
  99. package/dist/chat-ui/messages/message-components.js.map +1 -1
  100. package/dist/chat-ui/messages/runtime-message.cjs +3 -2
  101. package/dist/chat-ui/messages/runtime-message.cjs.map +1 -1
  102. package/dist/chat-ui/messages/runtime-message.js +3 -2
  103. package/dist/chat-ui/messages/runtime-message.js.map +1 -1
  104. package/dist/chat-ui/messages/statewire-continue-run.cjs +23 -8
  105. package/dist/chat-ui/messages/statewire-continue-run.cjs.map +1 -1
  106. package/dist/chat-ui/messages/statewire-continue-run.d.ts +14 -4
  107. package/dist/chat-ui/messages/statewire-continue-run.js +23 -8
  108. package/dist/chat-ui/messages/statewire-continue-run.js.map +1 -1
  109. package/dist/chat-ui/messages/user-edit-composer.cjs +2 -1
  110. package/dist/chat-ui/messages/user-edit-composer.cjs.map +1 -1
  111. package/dist/chat-ui/messages/user-edit-composer.js +2 -1
  112. package/dist/chat-ui/messages/user-edit-composer.js.map +1 -1
  113. package/dist/chat-ui/rich-text/chat-message-body.cjs +76 -0
  114. package/dist/chat-ui/rich-text/chat-message-body.cjs.map +1 -0
  115. package/dist/chat-ui/rich-text/chat-message-body.d.ts +5 -0
  116. package/dist/chat-ui/rich-text/chat-message-body.js +76 -0
  117. package/dist/chat-ui/rich-text/chat-message-body.js.map +1 -0
  118. package/dist/chat-ui/rich-text/chat-node-views.cjs +51 -0
  119. package/dist/chat-ui/rich-text/chat-node-views.cjs.map +1 -0
  120. package/dist/chat-ui/rich-text/chat-node-views.d.ts +13 -0
  121. package/dist/chat-ui/rich-text/chat-node-views.js +51 -0
  122. package/dist/chat-ui/rich-text/chat-node-views.js.map +1 -0
  123. package/dist/chat-ui/rich-text/chat-text-schema.cjs +70 -0
  124. package/dist/chat-ui/rich-text/chat-text-schema.cjs.map +1 -0
  125. package/dist/chat-ui/rich-text/chat-text-schema.d.ts +7 -0
  126. package/dist/chat-ui/rich-text/chat-text-schema.js +70 -0
  127. package/dist/chat-ui/rich-text/chat-text-schema.js.map +1 -0
  128. package/dist/chat-ui/rich-text/dom-output-spec.cjs +83 -0
  129. package/dist/chat-ui/rich-text/dom-output-spec.cjs.map +1 -0
  130. package/dist/chat-ui/rich-text/dom-output-spec.d.ts +11 -0
  131. package/dist/chat-ui/rich-text/dom-output-spec.js +83 -0
  132. package/dist/chat-ui/rich-text/dom-output-spec.js.map +1 -0
  133. package/dist/chat-ui/statewire.cjs +2 -1
  134. package/dist/chat-ui/statewire.cjs.map +1 -1
  135. package/dist/chat-ui/statewire.js +2 -1
  136. package/dist/chat-ui/statewire.js.map +1 -1
  137. package/dist/chat-ui/thread/statewire-history-edge.cjs +2 -1
  138. package/dist/chat-ui/thread/statewire-history-edge.cjs.map +1 -1
  139. package/dist/chat-ui/thread/statewire-history-edge.js +2 -1
  140. package/dist/chat-ui/thread/statewire-history-edge.js.map +1 -1
  141. package/dist/index.cjs +2 -1
  142. package/dist/index.cjs.map +1 -1
  143. package/dist/index.js +2 -1
  144. package/dist/index.js.map +1 -1
  145. package/dist/node_modules/qrcode-generator/dist/qrcode.cjs +32 -0
  146. package/dist/node_modules/qrcode-generator/dist/qrcode.cjs.map +1 -0
  147. package/dist/node_modules/qrcode-generator/dist/qrcode.js +31 -0
  148. package/dist/node_modules/qrcode-generator/dist/qrcode.js.map +1 -0
  149. package/dist/node_modules/zod/v4/classic/errors.cjs +44 -0
  150. package/dist/node_modules/zod/v4/classic/errors.cjs.map +1 -0
  151. package/dist/node_modules/zod/v4/classic/errors.js +44 -0
  152. package/dist/node_modules/zod/v4/classic/errors.js.map +1 -0
  153. package/dist/node_modules/zod/v4/classic/iso.cjs +43 -0
  154. package/dist/node_modules/zod/v4/classic/iso.cjs.map +1 -0
  155. package/dist/node_modules/zod/v4/classic/iso.js +43 -0
  156. package/dist/node_modules/zod/v4/classic/iso.js.map +1 -0
  157. package/dist/node_modules/zod/v4/classic/parse.cjs +29 -0
  158. package/dist/node_modules/zod/v4/classic/parse.cjs.map +1 -0
  159. package/dist/node_modules/zod/v4/classic/parse.js +29 -0
  160. package/dist/node_modules/zod/v4/classic/parse.js.map +1 -0
  161. package/dist/node_modules/zod/v4/classic/schemas.cjs +871 -0
  162. package/dist/node_modules/zod/v4/classic/schemas.cjs.map +1 -0
  163. package/dist/node_modules/zod/v4/classic/schemas.js +871 -0
  164. package/dist/node_modules/zod/v4/classic/schemas.js.map +1 -0
  165. package/dist/node_modules/zod/v4/core/api.cjs +570 -0
  166. package/dist/node_modules/zod/v4/core/api.cjs.map +1 -0
  167. package/dist/node_modules/zod/v4/core/api.js +570 -0
  168. package/dist/node_modules/zod/v4/core/api.js.map +1 -0
  169. package/dist/node_modules/zod/v4/core/checks.cjs +411 -0
  170. package/dist/node_modules/zod/v4/core/checks.cjs.map +1 -0
  171. package/dist/node_modules/zod/v4/core/checks.js +411 -0
  172. package/dist/node_modules/zod/v4/core/checks.js.map +1 -0
  173. package/dist/node_modules/zod/v4/core/core.cjs +77 -0
  174. package/dist/node_modules/zod/v4/core/core.cjs.map +1 -0
  175. package/dist/node_modules/zod/v4/core/core.js +77 -0
  176. package/dist/node_modules/zod/v4/core/core.js.map +1 -0
  177. package/dist/node_modules/zod/v4/core/doc.cjs +38 -0
  178. package/dist/node_modules/zod/v4/core/doc.cjs.map +1 -0
  179. package/dist/node_modules/zod/v4/core/doc.js +38 -0
  180. package/dist/node_modules/zod/v4/core/doc.js.map +1 -0
  181. package/dist/node_modules/zod/v4/core/errors.cjs +76 -0
  182. package/dist/node_modules/zod/v4/core/errors.cjs.map +1 -0
  183. package/dist/node_modules/zod/v4/core/errors.js +76 -0
  184. package/dist/node_modules/zod/v4/core/errors.js.map +1 -0
  185. package/dist/node_modules/zod/v4/core/json-schema-processors.cjs +312 -0
  186. package/dist/node_modules/zod/v4/core/json-schema-processors.cjs.map +1 -0
  187. package/dist/node_modules/zod/v4/core/json-schema-processors.js +312 -0
  188. package/dist/node_modules/zod/v4/core/json-schema-processors.js.map +1 -0
  189. package/dist/node_modules/zod/v4/core/parse.cjs +96 -0
  190. package/dist/node_modules/zod/v4/core/parse.cjs.map +1 -0
  191. package/dist/node_modules/zod/v4/core/parse.js +96 -0
  192. package/dist/node_modules/zod/v4/core/parse.js.map +1 -0
  193. package/dist/node_modules/zod/v4/core/regexes.cjs +86 -0
  194. package/dist/node_modules/zod/v4/core/regexes.cjs.map +1 -0
  195. package/dist/node_modules/zod/v4/core/regexes.js +86 -0
  196. package/dist/node_modules/zod/v4/core/regexes.js.map +1 -0
  197. package/dist/node_modules/zod/v4/core/registries.cjs +52 -0
  198. package/dist/node_modules/zod/v4/core/registries.cjs.map +1 -0
  199. package/dist/node_modules/zod/v4/core/registries.js +52 -0
  200. package/dist/node_modules/zod/v4/core/registries.js.map +1 -0
  201. package/dist/node_modules/zod/v4/core/schemas.cjs +1412 -0
  202. package/dist/node_modules/zod/v4/core/schemas.cjs.map +1 -0
  203. package/dist/node_modules/zod/v4/core/schemas.js +1413 -0
  204. package/dist/node_modules/zod/v4/core/schemas.js.map +1 -0
  205. package/dist/node_modules/zod/v4/core/to-json-schema.cjs +370 -0
  206. package/dist/node_modules/zod/v4/core/to-json-schema.cjs.map +1 -0
  207. package/dist/node_modules/zod/v4/core/to-json-schema.js +370 -0
  208. package/dist/node_modules/zod/v4/core/to-json-schema.js.map +1 -0
  209. package/dist/node_modules/zod/v4/core/util.cjs +444 -0
  210. package/dist/node_modules/zod/v4/core/util.cjs.map +1 -0
  211. package/dist/node_modules/zod/v4/core/util.js +444 -0
  212. package/dist/node_modules/zod/v4/core/util.js.map +1 -0
  213. package/dist/node_modules/zod/v4/core/versions.cjs +9 -0
  214. package/dist/node_modules/zod/v4/core/versions.cjs.map +1 -0
  215. package/dist/node_modules/zod/v4/core/versions.js +9 -0
  216. package/dist/node_modules/zod/v4/core/versions.js.map +1 -0
  217. package/dist/packages/agent-runtime/src/client-tool-bridge.cjs +7 -1
  218. package/dist/packages/agent-runtime/src/client-tool-bridge.cjs.map +1 -1
  219. package/dist/packages/agent-runtime/src/client-tool-bridge.js +7 -1
  220. package/dist/packages/agent-runtime/src/client-tool-bridge.js.map +1 -1
  221. package/dist/packages/agent-runtime/src/conversation-list.cjs +4 -0
  222. package/dist/packages/agent-runtime/src/conversation-list.cjs.map +1 -1
  223. package/dist/packages/agent-runtime/src/conversation-list.js +4 -0
  224. package/dist/packages/agent-runtime/src/conversation-list.js.map +1 -1
  225. package/dist/packages/agent-runtime/src/edit-command.cjs.map +1 -1
  226. package/dist/packages/agent-runtime/src/edit-command.js.map +1 -1
  227. package/dist/packages/agent-runtime/src/generated/runconfig-contract.cjs +2 -0
  228. package/dist/packages/agent-runtime/src/generated/runconfig-contract.cjs.map +1 -1
  229. package/dist/packages/agent-runtime/src/generated/runconfig-contract.js +2 -0
  230. package/dist/packages/agent-runtime/src/generated/runconfig-contract.js.map +1 -1
  231. package/dist/packages/agent-runtime/src/interrupts.cjs +31 -7
  232. package/dist/packages/agent-runtime/src/interrupts.cjs.map +1 -1
  233. package/dist/packages/agent-runtime/src/interrupts.js +31 -7
  234. package/dist/packages/agent-runtime/src/interrupts.js.map +1 -1
  235. package/dist/packages/agent-runtime/src/messages.cjs +35 -5
  236. package/dist/packages/agent-runtime/src/messages.cjs.map +1 -1
  237. package/dist/packages/agent-runtime/src/messages.js +35 -5
  238. package/dist/packages/agent-runtime/src/messages.js.map +1 -1
  239. package/dist/packages/agent-runtime/src/protocol.cjs +4 -6
  240. package/dist/packages/agent-runtime/src/protocol.cjs.map +1 -1
  241. package/dist/packages/agent-runtime/src/protocol.js +4 -6
  242. package/dist/packages/agent-runtime/src/protocol.js.map +1 -1
  243. package/dist/packages/agent-runtime/src/quota-safe-local-storage-session.cjs +296 -14
  244. package/dist/packages/agent-runtime/src/quota-safe-local-storage-session.cjs.map +1 -1
  245. package/dist/packages/agent-runtime/src/quota-safe-local-storage-session.js +293 -11
  246. package/dist/packages/agent-runtime/src/quota-safe-local-storage-session.js.map +1 -1
  247. package/dist/packages/agent-runtime/src/screen-point.cjs +68 -0
  248. package/dist/packages/agent-runtime/src/screen-point.cjs.map +1 -0
  249. package/dist/packages/agent-runtime/src/screen-point.js +68 -0
  250. package/dist/packages/agent-runtime/src/screen-point.js.map +1 -0
  251. package/dist/packages/agent-runtime/src/statewire-transport.cjs +6 -1
  252. package/dist/packages/agent-runtime/src/statewire-transport.cjs.map +1 -1
  253. package/dist/packages/agent-runtime/src/statewire-transport.js +6 -1
  254. package/dist/packages/agent-runtime/src/statewire-transport.js.map +1 -1
  255. package/dist/packages/agent-runtime/src/thread-handoff.cjs +85 -0
  256. package/dist/packages/agent-runtime/src/thread-handoff.cjs.map +1 -0
  257. package/dist/packages/agent-runtime/src/thread-handoff.js +85 -0
  258. package/dist/packages/agent-runtime/src/thread-handoff.js.map +1 -0
  259. package/dist/packages/agent-runtime/src/thread-snapshot-cache.cjs +1 -1
  260. package/dist/packages/agent-runtime/src/thread-snapshot-cache.cjs.map +1 -1
  261. package/dist/packages/agent-runtime/src/thread-snapshot-cache.js +1 -1
  262. package/dist/packages/agent-runtime/src/thread-snapshot-cache.js.map +1 -1
  263. package/dist/packages/agent-runtime/src/tool-metadata.cjs +0 -8
  264. package/dist/packages/agent-runtime/src/tool-metadata.cjs.map +1 -1
  265. package/dist/packages/agent-runtime/src/tool-metadata.js +0 -8
  266. package/dist/packages/agent-runtime/src/tool-metadata.js.map +1 -1
  267. package/dist/packages/agent-runtime/src/use-deep-agent-config.cjs +14 -0
  268. package/dist/packages/agent-runtime/src/use-deep-agent-config.cjs.map +1 -0
  269. package/dist/packages/agent-runtime/src/use-deep-agent-config.js +14 -0
  270. package/dist/packages/agent-runtime/src/use-deep-agent-config.js.map +1 -0
  271. package/dist/packages/agent-runtime/src/use-deep-agent-edit-submit.cjs +21 -5
  272. package/dist/packages/agent-runtime/src/use-deep-agent-edit-submit.cjs.map +1 -1
  273. package/dist/packages/agent-runtime/src/use-deep-agent-edit-submit.js +21 -5
  274. package/dist/packages/agent-runtime/src/use-deep-agent-edit-submit.js.map +1 -1
  275. package/dist/packages/agent-runtime/src/use-deep-agent-runtime.cjs +13 -3
  276. package/dist/packages/agent-runtime/src/use-deep-agent-runtime.cjs.map +1 -1
  277. package/dist/packages/agent-runtime/src/use-deep-agent-runtime.js +14 -4
  278. package/dist/packages/agent-runtime/src/use-deep-agent-runtime.js.map +1 -1
  279. package/dist/packages/agent-runtime/src/use-deep-agent-thread.cjs +35 -15
  280. package/dist/packages/agent-runtime/src/use-deep-agent-thread.cjs.map +1 -1
  281. package/dist/packages/agent-runtime/src/use-deep-agent-thread.js +35 -15
  282. package/dist/packages/agent-runtime/src/use-deep-agent-thread.js.map +1 -1
  283. package/dist/packages/agent-runtime/src/voice-presentation.cjs.map +1 -1
  284. package/dist/packages/agent-runtime/src/voice-presentation.js.map +1 -1
  285. package/dist/packages/react/package.json.cjs +1 -1
  286. package/dist/packages/react/package.json.js +1 -1
  287. package/dist/provider/AthenaProvider.cjs +2 -1
  288. package/dist/provider/AthenaProvider.cjs.map +1 -1
  289. package/dist/provider/AthenaProvider.js +2 -1
  290. package/dist/provider/AthenaProvider.js.map +1 -1
  291. package/dist/runtime/statewire-lifecycle.cjs +2 -1
  292. package/dist/runtime/statewire-lifecycle.cjs.map +1 -1
  293. package/dist/runtime/statewire-lifecycle.js +2 -1
  294. package/dist/runtime/statewire-lifecycle.js.map +1 -1
  295. package/dist/runtime/useAthenaStatewireRuntime.cjs +2 -1
  296. package/dist/runtime/useAthenaStatewireRuntime.cjs.map +1 -1
  297. package/dist/runtime/useAthenaStatewireRuntime.js +2 -1
  298. package/dist/runtime/useAthenaStatewireRuntime.js.map +1 -1
  299. package/dist/styles.css +1 -1
  300. package/dist/threads/conversation-list-fetcher.cjs +4 -0
  301. package/dist/threads/conversation-list-fetcher.cjs.map +1 -1
  302. package/dist/threads/conversation-list-fetcher.js +4 -0
  303. package/dist/threads/conversation-list-fetcher.js.map +1 -1
  304. package/dist/threads/statewire-thread-list.cjs +2 -1
  305. package/dist/threads/statewire-thread-list.cjs.map +1 -1
  306. package/dist/threads/statewire-thread-list.js +2 -1
  307. package/dist/threads/statewire-thread-list.js.map +1 -1
  308. package/dist/threads/use-rest-conversation-history.cjs +2 -1
  309. package/dist/threads/use-rest-conversation-history.cjs.map +1 -1
  310. package/dist/threads/use-rest-conversation-history.js +2 -1
  311. package/dist/threads/use-rest-conversation-history.js.map +1 -1
  312. package/dist/threads/use-statewire-conversation-history.cjs +2 -1
  313. package/dist/threads/use-statewire-conversation-history.cjs.map +1 -1
  314. package/dist/threads/use-statewire-conversation-history.d.ts +1 -0
  315. package/dist/threads/use-statewire-conversation-history.js +2 -1
  316. package/dist/threads/use-statewire-conversation-history.js.map +1 -1
  317. package/dist/tools/index.cjs +2 -1
  318. package/dist/tools/index.cjs.map +1 -1
  319. package/dist/tools/index.js +2 -1
  320. package/dist/tools/index.js.map +1 -1
  321. package/dist/tools/misc-tool-uis.cjs +2 -1
  322. package/dist/tools/misc-tool-uis.cjs.map +1 -1
  323. package/dist/tools/misc-tool-uis.js +2 -1
  324. package/dist/tools/misc-tool-uis.js.map +1 -1
  325. package/dist/tools/primitives.cjs +2 -1
  326. package/dist/tools/primitives.cjs.map +1 -1
  327. package/dist/tools/primitives.js +2 -1
  328. package/dist/tools/primitives.js.map +1 -1
  329. package/dist/tools/tool-fallback.cjs +2 -1
  330. package/dist/tools/tool-fallback.cjs.map +1 -1
  331. package/dist/tools/tool-fallback.js +2 -1
  332. package/dist/tools/tool-fallback.js.map +1 -1
  333. package/dist/tools/voice-update-tool-ui.cjs +2 -1
  334. package/dist/tools/voice-update-tool-ui.cjs.map +1 -1
  335. package/dist/tools/voice-update-tool-ui.js +2 -1
  336. package/dist/tools/voice-update-tool-ui.js.map +1 -1
  337. package/dist/voice/index.cjs +6 -0
  338. package/dist/voice/index.cjs.map +1 -0
  339. package/dist/voice/index.d.ts +2 -0
  340. package/dist/voice/index.js +6 -0
  341. package/dist/voice/index.js.map +1 -0
  342. package/dist/voice/use-athena-voice-session.cjs +315 -0
  343. package/dist/voice/use-athena-voice-session.cjs.map +1 -0
  344. package/dist/voice/use-athena-voice-session.d.ts +145 -0
  345. package/dist/voice/use-athena-voice-session.js +315 -0
  346. package/dist/voice/use-athena-voice-session.js.map +1 -0
  347. package/package.json +17 -3
@@ -1 +1 @@
1
- {"version":3,"file":"tiptap-text.cjs","sources":["../../src/chat/tiptap-text.tsx"],"sourcesContent":["import { useEditor, EditorContent } from \"@tiptap/react\";\nimport StarterKit from \"@tiptap/starter-kit\";\nimport Link from \"@tiptap/extension-link\";\nimport { Table } from \"@tiptap/extension-table\";\nimport { TableRow } from \"@tiptap/extension-table-row\";\nimport { TableCell } from \"@tiptap/extension-table-cell\";\nimport { TableHeader } from \"@tiptap/extension-table-header\";\nimport { Markdown } from \"tiptap-markdown\";\nimport type { FC } from \"react\";\nimport { useEffect, useRef } from \"react\";\nimport { MentionExtension } from \"../chat-ui/mentions/mention-extension\";\nimport { useAthenaLinkClickHandler } from \"./athena-citation-links\";\n\nconst extensions = [\n StarterKit.configure({\n codeBlock: {\n HTMLAttributes: {\n class: \"rounded-md bg-muted p-3 font-mono text-sm\",\n },\n },\n }),\n Link.configure({\n openOnClick: false,\n autolink: true,\n HTMLAttributes: {\n class: \"text-primary underline\",\n target: \"_blank\",\n rel: \"noopener noreferrer\",\n },\n }),\n Table.configure({\n resizable: false,\n HTMLAttributes: {\n class: \"aui-table\",\n },\n }),\n TableRow,\n TableCell,\n TableHeader,\n Markdown.configure({\n html: true,\n tightLists: true,\n linkify: true,\n breaks: true,\n transformPastedText: false,\n transformCopiedText: false,\n }),\n MentionExtension,\n];\n\nexport const TiptapText: FC<{ text: string }> = ({ text }) => {\n const handleLinkClick = useAthenaLinkClickHandler();\n const handleLinkClickRef = useRef(handleLinkClick);\n handleLinkClickRef.current = handleLinkClick;\n\n const editor = useEditor({\n immediatelyRender: true,\n extensions,\n content: text,\n editable: false,\n editorProps: {\n attributes: {\n class: \"prose prose-sm dark:prose-invert max-w-none focus:outline-none\",\n },\n handleClick: (_view, _pos, event) => {\n if (event.button !== 0) {\n return false;\n }\n\n const target = event.target;\n const targetElement =\n target instanceof HTMLElement\n ? target\n : target instanceof Node\n ? target.parentElement\n : null;\n if (!targetElement) {\n return false;\n }\n\n const link = targetElement.closest(\"a[href]\");\n if (!(link instanceof HTMLAnchorElement)) {\n return false;\n }\n\n if (\n handleLinkClickRef.current({\n href: link.getAttribute(\"href\") ?? link.href,\n linkText: link.textContent,\n target: link.target,\n nativeEvent: event,\n })\n ) {\n return true;\n }\n\n event.preventDefault();\n window.open(link.href, link.target || \"_blank\")?.focus();\n return true;\n },\n },\n });\n\n useEffect(() => {\n if (editor && text !== (editor.storage as any).markdown?.getMarkdown()) {\n editor.commands.setContent(text);\n }\n }, [text, editor]);\n\n return <EditorContent editor={editor} />;\n};\n"],"names":["Table","TableRow","TableCell","TableHeader","Markdown","MentionExtension","useAthenaLinkClickHandler","useRef","useEditor","useEffect","jsx","EditorContent"],"mappings":";;;;;;;;;;;;;;AAaA,MAAM,aAAa;AAAA,EACjB,WAAW,UAAU;AAAA,IACnB,WAAW;AAAA,MACT,gBAAgB;AAAA,QACd,OAAO;AAAA,MAAA;AAAA,IACT;AAAA,EACF,CACD;AAAA,EACD,KAAK,UAAU;AAAA,IACb,aAAa;AAAA,IACb,UAAU;AAAA,IACV,gBAAgB;AAAA,MACd,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,KAAK;AAAA,IAAA;AAAA,EACP,CACD;AAAA,EACDA,eAAAA,MAAM,UAAU;AAAA,IACd,WAAW;AAAA,IACX,gBAAgB;AAAA,MACd,OAAO;AAA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,UAAU,MAAM;;AACd,QAAI,UAAU,WAAU,YAAO,QAAgB,aAAvB,mBAAiC,gBAAe;AACtE,aAAO,SAAS,WAAW,IAAI;AAAA,IACjC;AAAA,EACF,GAAG,CAAC,MAAM,MAAM,CAAC;AAEjB,SAAOC,+BAACC,QAAAA,iBAAc,QAAgB;AACxC;;"}
1
+ {"version":3,"file":"tiptap-text.cjs","sources":["../../src/chat/tiptap-text.tsx"],"sourcesContent":["import { useEditor, EditorContent } from \"@tiptap/react\";\nimport StarterKit from \"@tiptap/starter-kit\";\nimport Link from \"@tiptap/extension-link\";\nimport { Table } from \"@tiptap/extension-table\";\nimport { TableRow } from \"@tiptap/extension-table-row\";\nimport { TableCell } from \"@tiptap/extension-table-cell\";\nimport { TableHeader } from \"@tiptap/extension-table-header\";\nimport { Markdown } from \"tiptap-markdown\";\nimport type { FC } from \"react\";\nimport { useEffect, useRef } from \"react\";\nimport { MentionExtension } from \"../chat-ui/mentions/mention-extension\";\nimport { useAthenaLinkClickHandler } from \"./athena-citation-links\";\n\nconst extensions = [\n StarterKit.configure({\n codeBlock: {\n HTMLAttributes: {\n class: \"rounded-md bg-muted p-3 font-mono text-sm\",\n },\n },\n }),\n Link.configure({\n openOnClick: false,\n autolink: true,\n HTMLAttributes: {\n class: \"text-primary underline\",\n target: \"_blank\",\n rel: \"noopener noreferrer\",\n },\n }),\n Table.configure({\n resizable: false,\n HTMLAttributes: {\n class: \"aui-table\",\n },\n }),\n TableRow,\n TableCell,\n TableHeader,\n Markdown.configure({\n html: true,\n tightLists: true,\n linkify: true,\n breaks: true,\n transformPastedText: false,\n transformCopiedText: false,\n }),\n MentionExtension,\n];\n\nexport const TiptapText: FC<{ text: string }> = ({ text }) => {\n const handleLinkClick = useAthenaLinkClickHandler();\n const handleLinkClickRef = useRef(handleLinkClick);\n handleLinkClickRef.current = handleLinkClick;\n\n const editor = useEditor({\n immediatelyRender: true,\n extensions,\n content: text,\n editable: false,\n editorProps: {\n attributes: {\n class: \"prose prose-sm dark:prose-invert max-w-none focus:outline-none\",\n },\n handleClick: (_view, _pos, event) => {\n if (event.button !== 0) {\n return false;\n }\n\n const target = event.target;\n const targetElement =\n target instanceof HTMLElement\n ? target\n : target instanceof Node\n ? target.parentElement\n : null;\n if (!targetElement) {\n return false;\n }\n\n const link = targetElement.closest(\"a[href]\");\n if (!(link instanceof HTMLAnchorElement)) {\n return false;\n }\n\n if (\n handleLinkClickRef.current({\n href: link.getAttribute(\"href\") ?? link.href,\n linkText: link.textContent,\n target: link.target,\n nativeEvent: event,\n })\n ) {\n return true;\n }\n\n event.preventDefault();\n window.open(link.href, link.target || \"_blank\")?.focus();\n return true;\n },\n },\n });\n\n useEffect(() => {\n if (editor && text !== (editor.storage as any).markdown?.getMarkdown()) {\n editor.commands.setContent(text);\n }\n }, [text, editor]);\n\n return <EditorContent editor={editor} />;\n};\n"],"names":["Table","TableRow","TableCell","TableHeader","Markdown","MentionExtension","useAthenaLinkClickHandler","useRef","useEditor","useEffect","jsx","EditorContent"],"mappings":";;;;;;;;;;;;;;AAaA,MAAM,aAAa;AAAA,EACjB,WAAW,UAAU;AAAA,IACnB,WAAW;AAAA,MACT,gBAAgB;AAAA,QACd,OAAO;AAAA,MAAA;AAAA,IACT;AAAA,EACF,CACD;AAAA,EACD,KAAK,UAAU;AAAA,IACb,aAAa;AAAA,IACb,UAAU;AAAA,IACV,gBAAgB;AAAA,MACd,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,KAAK;AAAA,IAAA;AAAA,EACP,CACD;AAAA,EACDA,MAAAA,MAAM,UAAU;AAAA,IACd,WAAW;AAAA,IACX,gBAAgB;AAAA,MACd,OAAO;AAAA,IAAA;AAAA,EACT,CACD;AAAA,EACDC,SAAAA;AAAAA,EACAC,UAAAA;AAAAA,EACAC,YAAAA;AAAAA,EACAC,eAAAA,SAAS,UAAU;AAAA,IACjB,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,qBAAqB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
@@ -11,10 +11,11 @@ require("../packages/agent-runtime/src/statewire-state.cjs");
11
11
  require("../packages/agent-runtime/src/messages.cjs");
12
12
  require("@assistant-ui/react-statewire");
13
13
  require("@assistant-ui/store");
14
- require("@assistant-ui/react-statewire/local-storage");
14
+ require("../packages/agent-runtime/src/quota-safe-local-storage-session.cjs");
15
15
  require("../packages/agent-runtime/src/statewire-attach-observer.cjs");
16
16
  const threadStatus = require("../packages/agent-runtime/src/thread-status.cjs");
17
17
  require("@assistant-ui/core");
18
+ require("../packages/agent-runtime/src/thread-handoff.cjs");
18
19
  function useAthenaRunLive() {
19
20
  const connection = threadStatus.useDeepAgentConnection();
20
21
  return react.useAuiState((s) => threadStatus.readRunLive(s.thread, connection));
@@ -1 +1 @@
1
- {"version":3,"file":"use-athena-run-live.cjs","sources":["../../src/chat/use-athena-run-live.ts"],"sourcesContent":["import { useAuiState } from '@assistant-ui/react';\nimport { readRunLive, useDeepAgentConnection } from '@athenaintel/agent-runtime';\n\n/**\n * Whether the thread has a live run — `thread.isRunning` folded through the\n * host's channel state, so a run behind a first dial (a new chat's first\n * send, switching back to a thread that was running) still reads as live\n * while a run behind a genuine reconnect or eviction does not. Surfaces\n * that gate on a live run (message edit, the voice card's live state, the\n * approval resume lock) read this instead of `thread.isRunning`, which\n * follows the presented status and blinks off for the attach round-trip.\n */\nexport function useAthenaRunLive(): boolean {\n const connection = useDeepAgentConnection();\n return useAuiState((s) => readRunLive(s.thread, connection));\n}\n"],"names":["useDeepAgentConnection","useAuiState","readRunLive"],"mappings":";;;;;;;;;;;;;;;;;AAYO,SAAS,mBAA4B;AAC1C,QAAM,aAAaA,aAAAA,uBAAA;AACnB,SAAOC,MAAAA,YAAY,CAAC,MAAMC,aAAAA,YAAY,EAAE,QAAQ,UAAU,CAAC;AAC7D;;"}
1
+ {"version":3,"file":"use-athena-run-live.cjs","sources":["../../src/chat/use-athena-run-live.ts"],"sourcesContent":["import { useAuiState } from '@assistant-ui/react';\nimport { readRunLive, useDeepAgentConnection } from '@athenaintel/agent-runtime';\n\n/**\n * Whether the thread has a live run — `thread.isRunning` folded through the\n * host's channel state, so a run behind a first dial (a new chat's first\n * send, switching back to a thread that was running) still reads as live\n * while a run behind a genuine reconnect or eviction does not. Surfaces\n * that gate on a live run (message edit, the voice card's live state, the\n * approval resume lock) read this instead of `thread.isRunning`, which\n * follows the presented status and blinks off for the attach round-trip.\n */\nexport function useAthenaRunLive(): boolean {\n const connection = useDeepAgentConnection();\n return useAuiState((s) => readRunLive(s.thread, connection));\n}\n"],"names":["useDeepAgentConnection","useAuiState","readRunLive"],"mappings":";;;;;;;;;;;;;;;;;;AAYO,SAAS,mBAA4B;AAC1C,QAAM,aAAaA,aAAAA,uBAAA;AACnB,SAAOC,MAAAA,YAAY,CAAC,MAAMC,aAAAA,YAAY,EAAE,QAAQ,UAAU,CAAC;AAC7D;;"}
@@ -9,10 +9,11 @@ import "../packages/agent-runtime/src/statewire-state.js";
9
9
  import "../packages/agent-runtime/src/messages.js";
10
10
  import "@assistant-ui/react-statewire";
11
11
  import "@assistant-ui/store";
12
- import "@assistant-ui/react-statewire/local-storage";
12
+ import "../packages/agent-runtime/src/quota-safe-local-storage-session.js";
13
13
  import "../packages/agent-runtime/src/statewire-attach-observer.js";
14
14
  import { useDeepAgentConnection, readRunLive } from "../packages/agent-runtime/src/thread-status.js";
15
15
  import "@assistant-ui/core";
16
+ import "../packages/agent-runtime/src/thread-handoff.js";
16
17
  function useAthenaRunLive() {
17
18
  const connection = useDeepAgentConnection();
18
19
  return useAuiState((s) => readRunLive(s.thread, connection));
@@ -1 +1 @@
1
- {"version":3,"file":"use-athena-run-live.js","sources":["../../src/chat/use-athena-run-live.ts"],"sourcesContent":["import { useAuiState } from '@assistant-ui/react';\nimport { readRunLive, useDeepAgentConnection } from '@athenaintel/agent-runtime';\n\n/**\n * Whether the thread has a live run — `thread.isRunning` folded through the\n * host's channel state, so a run behind a first dial (a new chat's first\n * send, switching back to a thread that was running) still reads as live\n * while a run behind a genuine reconnect or eviction does not. Surfaces\n * that gate on a live run (message edit, the voice card's live state, the\n * approval resume lock) read this instead of `thread.isRunning`, which\n * follows the presented status and blinks off for the attach round-trip.\n */\nexport function useAthenaRunLive(): boolean {\n const connection = useDeepAgentConnection();\n return useAuiState((s) => readRunLive(s.thread, connection));\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAYO,SAAS,mBAA4B;AAC1C,QAAM,aAAa,uBAAA;AACnB,SAAO,YAAY,CAAC,MAAM,YAAY,EAAE,QAAQ,UAAU,CAAC;AAC7D;"}
1
+ {"version":3,"file":"use-athena-run-live.js","sources":["../../src/chat/use-athena-run-live.ts"],"sourcesContent":["import { useAuiState } from '@assistant-ui/react';\nimport { readRunLive, useDeepAgentConnection } from '@athenaintel/agent-runtime';\n\n/**\n * Whether the thread has a live run — `thread.isRunning` folded through the\n * host's channel state, so a run behind a first dial (a new chat's first\n * send, switching back to a thread that was running) still reads as live\n * while a run behind a genuine reconnect or eviction does not. Surfaces\n * that gate on a live run (message edit, the voice card's live state, the\n * approval resume lock) read this instead of `thread.isRunning`, which\n * follows the presented status and blinks off for the attach round-trip.\n */\nexport function useAthenaRunLive(): boolean {\n const connection = useDeepAgentConnection();\n return useAuiState((s) => readRunLive(s.thread, connection));\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAYO,SAAS,mBAA4B;AAC1C,QAAM,aAAa,uBAAA;AACnB,SAAO,YAAY,CAAC,MAAM,YAAY,EAAE,QAAQ,UAAU,CAAC;AAC7D;"}
@@ -11,16 +11,18 @@ const interrupts = require("../packages/agent-runtime/src/interrupts.cjs");
11
11
  require("../packages/agent-runtime/src/messages.cjs");
12
12
  require("../packages/agent-runtime/src/statewire-state.cjs");
13
13
  require("@assistant-ui/store");
14
- require("@assistant-ui/react-statewire/local-storage");
14
+ require("../packages/agent-runtime/src/quota-safe-local-storage-session.cjs");
15
15
  require("../packages/agent-runtime/src/statewire-attach-observer.cjs");
16
16
  require("../packages/agent-runtime/src/thread-status.cjs");
17
17
  require("@assistant-ui/core");
18
+ require("../packages/agent-runtime/src/thread-handoff.cjs");
18
19
  const useAthenaRunLive = require("./use-athena-run-live.cjs");
19
20
  function useStatewireApprovalRequest(options = {}) {
20
21
  var _a;
21
22
  const {
22
23
  interruptPredicate = interrupts.isApprovalCardInterrupt,
23
- pendingResumeGraceMs = interrupts.HITL_PENDING_RESUME_GRACE_MS
24
+ pendingResumeGraceMs = interrupts.HITL_PENDING_RESUME_GRACE_MS,
25
+ onResumeRejected
24
26
  } = options;
25
27
  const sendCommand = reactStatewire.useStatewireSendCommand();
26
28
  const request = (_a = reactStatewire.useStatewireRuns().inputRequests) == null ? void 0 : _a.find(interruptPredicate);
@@ -34,6 +36,9 @@ function useStatewireApprovalRequest(options = {}) {
34
36
  requestId,
35
37
  isRunning,
36
38
  pendingResumeGraceMs,
39
+ onResumeRejected,
40
+ // The dispatch promise is handed to the lock: a refusal releases it and
41
+ // reaches `onResumeRejected`.
37
42
  sendResume: (id, value) => sendCommand({
38
43
  type: "run/input",
39
44
  requestId: id,
@@ -1 +1 @@
1
- {"version":3,"file":"use-statewire-approval-request.cjs","sources":["../../src/chat/use-statewire-approval-request.ts"],"sourcesContent":["import type { StatewireThread } from '@assistant-ui/react-statewire';\nimport {\n useStatewireRuns,\n useStatewireSendCommand,\n useStatewireState,\n} from '@assistant-ui/react-statewire';\nimport {\n type AbandonedInputRequest,\n asHitlApproval,\n findAbandonedInterrupt,\n HITL_PENDING_RESUME_GRACE_MS,\n type HitlApprovalPayload,\n isApprovalCardInterrupt,\n type PendingActionRequest,\n pendingActionRequests,\n readAbandonedInputRequests,\n useApprovalResumeLock,\n} from '@athenaintel/agent-runtime';\nimport { useMemo } from 'react';\nimport { useAthenaRunLive } from './use-athena-run-live';\n\n/** Selects which pending interrupt an approval surface answers. */\nexport type StatewireInterruptPredicate = (\n request: StatewireThread.InputRequestState,\n) => request is StatewireThread.CustomInputRequest;\n\nexport interface UseStatewireApprovalRequestOptions {\n /**\n * Which pending interrupt to answer. Defaults to `isApprovalCardInterrupt`\n * (client-tool parks excluded — the client-tool bridge owns those, and a\n * generic resume would corrupt the parked tool call).\n */\n interruptPredicate?: StatewireInterruptPredicate;\n /**\n * How long a sent decision keeps the actions locked when no resume run ever\n * starts. Defaults to {@link HITL_PENDING_RESUME_GRACE_MS}.\n */\n pendingResumeGraceMs?: number;\n}\n\nexport interface StatewireApprovalRequest<TValue> {\n /** The pending interrupt this surface answers, if any. */\n request: StatewireThread.CustomInputRequest | undefined;\n requestId: string | undefined;\n /** The payload narrowed to the Athena HITL approval shape, or `null`. */\n hitl: HitlApprovalPayload | null;\n /** Every gated call the approval covers, in decision order (empty for non-HITL parks). */\n actionRequests: PendingActionRequest[];\n /** An interrupt a non-resume dispatch dropped — the \"approval was cancelled\" notice. */\n abandonedInterrupt: AbandonedInputRequest | undefined;\n /** True after a resume until the request identity changes (or recovery fires). */\n pending: boolean;\n /** Answer the request with `{ type: 'run/input', requestId, response: { type: 'resume', value } }`. */\n resume: (value: TValue) => void;\n}\n\n/**\n * The headless half of every statewire approval surface: selects the pending\n * interrupt from the runs projection, narrows its payload, reads the\n * host-published abandoned interrupts, and wires the shared optimistic resume\n * lock to the thread's `run/input` command. `StatewireApprovalCard` renders\n * over it; hosts with their own decision UI (per-lane subagent cards) build\n * on it directly so the selection and lock semantics cannot drift.\n *\n * Requires a statewire aui scope (throws outside one, like every\n * `useStatewire*` hook) — gate the mount with `hasStatewireThreadExtras`.\n */\nexport function useStatewireApprovalRequest<\n TValue extends StatewireThread.InputResponse = Record<string, string>,\n>(options: UseStatewireApprovalRequestOptions = {}): StatewireApprovalRequest<TValue> {\n const {\n interruptPredicate = isApprovalCardInterrupt,\n pendingResumeGraceMs = HITL_PENDING_RESUME_GRACE_MS,\n } = options;\n const sendCommand = useStatewireSendCommand();\n // The runs projection is memoized by the lib, so this derivation is\n // reference-stable between state updates.\n const request = useStatewireRuns().inputRequests?.find(interruptPredicate);\n const requestId = request?.id;\n\n // The host publishes the interrupts a non-resume dispatch dropped. Select\n // the raw array reference (pre-stream-safe) and derive inline; a `.find`\n // selector would return a fresh object every update.\n const abandoned = useStatewireState(readAbandonedInputRequests);\n const abandonedInterrupt = findAbandonedInterrupt(abandoned);\n\n const hitl = asHitlApproval(request?.payload);\n const actionRequests = useMemo(() => pendingActionRequests(hitl), [hitl]);\n\n const isRunning = useAthenaRunLive();\n const { pending, resume } = useApprovalResumeLock<TValue>({\n requestId,\n isRunning,\n pendingResumeGraceMs,\n sendResume: (id, value) =>\n sendCommand({\n type: 'run/input',\n requestId: id,\n response: { type: 'resume', value },\n }),\n });\n\n return { request, requestId, hitl, actionRequests, abandonedInterrupt, pending, resume };\n}\n"],"names":["isApprovalCardInterrupt","HITL_PENDING_RESUME_GRACE_MS","useStatewireSendCommand","useStatewireRuns","useStatewireState","readAbandonedInputRequests","findAbandonedInterrupt","asHitlApproval","useMemo","pendingActionRequests","useAthenaRunLive","useApprovalResumeLock"],"mappings":";;;;;;;;;;;;;;;;;;AAmEO,SAAS,4BAEd,UAA8C,IAAsC;;AACpF,QAAM;AAAA,IACJ,qBAAqBA,WAAAA;AAAAA,IACrB,uBAAuBC,WAAAA;AAAAA,EAAA,IACrB;AACJ,QAAM,cAAcC,eAAAA,wBAAA;AAGpB,QAAM,WAAUC,oBAAAA,iBAAA,EAAmB,kBAAnBA,mBAAkC,KAAK;AACvD,QAAM,YAAY,mCAAS;AAK3B,QAAM,YAAYC,eAAAA,kBAAkBC,qCAA0B;AAC9D,QAAM,qBAAqBC,WAAAA,uBAAuB,SAAS;AAE3D,QAAM,OAAOC,WAAAA,eAAe,mCAAS,OAAO;AAC5C,QAAM,iBAAiBC,MAAAA,QAAQ,MAAMC,WAAAA,sBAAsB,IAAI,GAAG,CAAC,IAAI,CAAC;AAExE,QAAM,YAAYC,iBAAAA,iBAAA;AAClB,QAAM,EAAE,SAAS,OAAA,IAAWC,iCAA8B;AAAA,IACxD;AAAA,IACA;AAAA,IACA;AAAA,IACA,YAAY,CAAC,IAAI,UACf,YAAY;AAAA,MACV,MAAM;AAAA,MACN,WAAW;AAAA,MACX,UAAU,EAAE,MAAM,UAAU,MAAA;AAAA,IAAM,CACnC;AAAA,EAAA,CACJ;AAED,SAAO,EAAE,SAAS,WAAW,MAAM,gBAAgB,oBAAoB,SAAS,OAAA;AAClF;;"}
1
+ {"version":3,"file":"use-statewire-approval-request.cjs","sources":["../../src/chat/use-statewire-approval-request.ts"],"sourcesContent":["import type { StatewireThread } from '@assistant-ui/react-statewire';\nimport {\n useStatewireRuns,\n useStatewireSendCommand,\n useStatewireState,\n} from '@assistant-ui/react-statewire';\nimport {\n type AbandonedInputRequest,\n asHitlApproval,\n findAbandonedInterrupt,\n HITL_PENDING_RESUME_GRACE_MS,\n type HitlApprovalPayload,\n isApprovalCardInterrupt,\n type PendingActionRequest,\n pendingActionRequests,\n readAbandonedInputRequests,\n useApprovalResumeLock,\n} from '@athenaintel/agent-runtime';\nimport { useMemo } from 'react';\nimport { useAthenaRunLive } from './use-athena-run-live';\n\n/** Selects which pending interrupt an approval surface answers. */\nexport type StatewireInterruptPredicate = (\n request: StatewireThread.InputRequestState,\n) => request is StatewireThread.CustomInputRequest;\n\nexport interface UseStatewireApprovalRequestOptions {\n /**\n * Which pending interrupt to answer. Defaults to `isApprovalCardInterrupt`\n * (client-tool parks excluded — the client-tool bridge owns those, and a\n * generic resume would corrupt the parked tool call).\n */\n interruptPredicate?: StatewireInterruptPredicate;\n /**\n * How long a sent decision keeps the actions locked when no resume run ever\n * starts. Defaults to {@link HITL_PENDING_RESUME_GRACE_MS}.\n */\n pendingResumeGraceMs?: number;\n /**\n * The host refused the `run/input` (or the transport lost it): the\n * optimistic fold rolls back, the request is on screen again with its\n * actions re-enabled, and this is the surface's one chance to say why.\n */\n onResumeRejected?: (error: unknown, requestId: string) => void;\n}\n\nexport interface StatewireApprovalRequest<TValue> {\n /** The pending interrupt this surface answers, if any. */\n request: StatewireThread.CustomInputRequest | undefined;\n requestId: string | undefined;\n /** The payload narrowed to the Athena HITL approval shape, or `null`. */\n hitl: HitlApprovalPayload | null;\n /** Every gated call the approval covers, in decision order (empty for non-HITL parks). */\n actionRequests: PendingActionRequest[];\n /** An interrupt a non-resume dispatch dropped — the \"approval was cancelled\" notice. */\n abandonedInterrupt: AbandonedInputRequest | undefined;\n /** True after a resume until the request identity changes (or recovery fires). */\n pending: boolean;\n /**\n * Answer the request with `{ type: 'run/input', requestId, response: { type: 'resume', value } }`.\n * Returns the dispatch promise (settles when the host accepts, rejects when\n * it refuses), or `undefined` when the lock dropped the send.\n */\n resume: (value: TValue) => Promise<unknown> | undefined;\n}\n\n/**\n * The headless half of every statewire approval surface: selects the pending\n * interrupt from the runs projection, narrows its payload, reads the\n * host-published abandoned interrupts, and wires the shared optimistic resume\n * lock to the thread's `run/input` command. `StatewireApprovalCard` renders\n * over it; hosts with their own decision UI (per-lane subagent cards) build\n * on it directly so the selection and lock semantics cannot drift.\n *\n * Requires a statewire aui scope (throws outside one, like every\n * `useStatewire*` hook) — gate the mount with `hasStatewireThreadExtras`.\n */\nexport function useStatewireApprovalRequest<\n TValue extends StatewireThread.InputResponse = Record<string, string>,\n>(options: UseStatewireApprovalRequestOptions = {}): StatewireApprovalRequest<TValue> {\n const {\n interruptPredicate = isApprovalCardInterrupt,\n pendingResumeGraceMs = HITL_PENDING_RESUME_GRACE_MS,\n onResumeRejected,\n } = options;\n const sendCommand = useStatewireSendCommand();\n // The runs projection is memoized by the lib, so this derivation is\n // reference-stable between state updates.\n const request = useStatewireRuns().inputRequests?.find(interruptPredicate);\n const requestId = request?.id;\n\n // The host publishes the interrupts a non-resume dispatch dropped. Select\n // the raw array reference (pre-stream-safe) and derive inline; a `.find`\n // selector would return a fresh object every update.\n const abandoned = useStatewireState(readAbandonedInputRequests);\n const abandonedInterrupt = findAbandonedInterrupt(abandoned);\n\n const hitl = asHitlApproval(request?.payload);\n const actionRequests = useMemo(() => pendingActionRequests(hitl), [hitl]);\n\n const isRunning = useAthenaRunLive();\n const { pending, resume } = useApprovalResumeLock<TValue>({\n requestId,\n isRunning,\n pendingResumeGraceMs,\n onResumeRejected,\n // The dispatch promise is handed to the lock: a refusal releases it and\n // reaches `onResumeRejected`.\n sendResume: (id, value) =>\n sendCommand({\n type: 'run/input',\n requestId: id,\n response: { type: 'resume', value },\n }),\n });\n\n return { request, requestId, hitl, actionRequests, abandonedInterrupt, pending, resume };\n}\n"],"names":["isApprovalCardInterrupt","HITL_PENDING_RESUME_GRACE_MS","useStatewireSendCommand","useStatewireRuns","useStatewireState","readAbandonedInputRequests","findAbandonedInterrupt","asHitlApproval","useMemo","pendingActionRequests","useAthenaRunLive","useApprovalResumeLock"],"mappings":";;;;;;;;;;;;;;;;;;;AA6EO,SAAS,4BAEd,UAA8C,IAAsC;;AACpF,QAAM;AAAA,IACJ,qBAAqBA,WAAAA;AAAAA,IACrB,uBAAuBC,WAAAA;AAAAA,IACvB;AAAA,EAAA,IACE;AACJ,QAAM,cAAcC,eAAAA,wBAAA;AAGpB,QAAM,WAAUC,oBAAAA,iBAAA,EAAmB,kBAAnBA,mBAAkC,KAAK;AACvD,QAAM,YAAY,mCAAS;AAK3B,QAAM,YAAYC,eAAAA,kBAAkBC,qCAA0B;AAC9D,QAAM,qBAAqBC,WAAAA,uBAAuB,SAAS;AAE3D,QAAM,OAAOC,WAAAA,eAAe,mCAAS,OAAO;AAC5C,QAAM,iBAAiBC,MAAAA,QAAQ,MAAMC,WAAAA,sBAAsB,IAAI,GAAG,CAAC,IAAI,CAAC;AAExE,QAAM,YAAYC,iBAAAA,iBAAA;AAClB,QAAM,EAAE,SAAS,OAAA,IAAWC,iCAA8B;AAAA,IACxD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA;AAAA,IAGA,YAAY,CAAC,IAAI,UACf,YAAY;AAAA,MACV,MAAM;AAAA,MACN,WAAW;AAAA,MACX,UAAU,EAAE,MAAM,UAAU,MAAA;AAAA,IAAM,CACnC;AAAA,EAAA,CACJ;AAED,SAAO,EAAE,SAAS,WAAW,MAAM,gBAAgB,oBAAoB,SAAS,OAAA;AAClF;;"}
@@ -14,6 +14,12 @@ export interface UseStatewireApprovalRequestOptions {
14
14
  * starts. Defaults to {@link HITL_PENDING_RESUME_GRACE_MS}.
15
15
  */
16
16
  pendingResumeGraceMs?: number;
17
+ /**
18
+ * The host refused the `run/input` (or the transport lost it): the
19
+ * optimistic fold rolls back, the request is on screen again with its
20
+ * actions re-enabled, and this is the surface's one chance to say why.
21
+ */
22
+ onResumeRejected?: (error: unknown, requestId: string) => void;
17
23
  }
18
24
  export interface StatewireApprovalRequest<TValue> {
19
25
  /** The pending interrupt this surface answers, if any. */
@@ -27,8 +33,12 @@ export interface StatewireApprovalRequest<TValue> {
27
33
  abandonedInterrupt: AbandonedInputRequest | undefined;
28
34
  /** True after a resume until the request identity changes (or recovery fires). */
29
35
  pending: boolean;
30
- /** Answer the request with `{ type: 'run/input', requestId, response: { type: 'resume', value } }`. */
31
- resume: (value: TValue) => void;
36
+ /**
37
+ * Answer the request with `{ type: 'run/input', requestId, response: { type: 'resume', value } }`.
38
+ * Returns the dispatch promise (settles when the host accepts, rejects when
39
+ * it refuses), or `undefined` when the lock dropped the send.
40
+ */
41
+ resume: (value: TValue) => Promise<unknown> | undefined;
32
42
  }
33
43
  /**
34
44
  * The headless half of every statewire approval surface: selects the pending
@@ -5,20 +5,22 @@ import "@assistant-ui/tap";
5
5
  import "statewire";
6
6
  import "../packages/agent-runtime/src/statewire-suspended.js";
7
7
  import "@tanstack/react-query";
8
- import { HITL_PENDING_RESUME_GRACE_MS, isApprovalCardInterrupt, readAbandonedInputRequests, findAbandonedInterrupt, asHitlApproval, pendingActionRequests, useApprovalResumeLock } from "../packages/agent-runtime/src/interrupts.js";
8
+ import { isApprovalCardInterrupt, HITL_PENDING_RESUME_GRACE_MS, readAbandonedInputRequests, findAbandonedInterrupt, asHitlApproval, pendingActionRequests, useApprovalResumeLock } from "../packages/agent-runtime/src/interrupts.js";
9
9
  import "../packages/agent-runtime/src/messages.js";
10
10
  import "../packages/agent-runtime/src/statewire-state.js";
11
11
  import "@assistant-ui/store";
12
- import "@assistant-ui/react-statewire/local-storage";
12
+ import "../packages/agent-runtime/src/quota-safe-local-storage-session.js";
13
13
  import "../packages/agent-runtime/src/statewire-attach-observer.js";
14
14
  import "../packages/agent-runtime/src/thread-status.js";
15
15
  import "@assistant-ui/core";
16
+ import "../packages/agent-runtime/src/thread-handoff.js";
16
17
  import { useAthenaRunLive } from "./use-athena-run-live.js";
17
18
  function useStatewireApprovalRequest(options = {}) {
18
19
  var _a;
19
20
  const {
20
21
  interruptPredicate = isApprovalCardInterrupt,
21
- pendingResumeGraceMs = HITL_PENDING_RESUME_GRACE_MS
22
+ pendingResumeGraceMs = HITL_PENDING_RESUME_GRACE_MS,
23
+ onResumeRejected
22
24
  } = options;
23
25
  const sendCommand = useStatewireSendCommand();
24
26
  const request = (_a = useStatewireRuns().inputRequests) == null ? void 0 : _a.find(interruptPredicate);
@@ -32,6 +34,9 @@ function useStatewireApprovalRequest(options = {}) {
32
34
  requestId,
33
35
  isRunning,
34
36
  pendingResumeGraceMs,
37
+ onResumeRejected,
38
+ // The dispatch promise is handed to the lock: a refusal releases it and
39
+ // reaches `onResumeRejected`.
35
40
  sendResume: (id, value) => sendCommand({
36
41
  type: "run/input",
37
42
  requestId: id,
@@ -1 +1 @@
1
- {"version":3,"file":"use-statewire-approval-request.js","sources":["../../src/chat/use-statewire-approval-request.ts"],"sourcesContent":["import type { StatewireThread } from '@assistant-ui/react-statewire';\nimport {\n useStatewireRuns,\n useStatewireSendCommand,\n useStatewireState,\n} from '@assistant-ui/react-statewire';\nimport {\n type AbandonedInputRequest,\n asHitlApproval,\n findAbandonedInterrupt,\n HITL_PENDING_RESUME_GRACE_MS,\n type HitlApprovalPayload,\n isApprovalCardInterrupt,\n type PendingActionRequest,\n pendingActionRequests,\n readAbandonedInputRequests,\n useApprovalResumeLock,\n} from '@athenaintel/agent-runtime';\nimport { useMemo } from 'react';\nimport { useAthenaRunLive } from './use-athena-run-live';\n\n/** Selects which pending interrupt an approval surface answers. */\nexport type StatewireInterruptPredicate = (\n request: StatewireThread.InputRequestState,\n) => request is StatewireThread.CustomInputRequest;\n\nexport interface UseStatewireApprovalRequestOptions {\n /**\n * Which pending interrupt to answer. Defaults to `isApprovalCardInterrupt`\n * (client-tool parks excluded — the client-tool bridge owns those, and a\n * generic resume would corrupt the parked tool call).\n */\n interruptPredicate?: StatewireInterruptPredicate;\n /**\n * How long a sent decision keeps the actions locked when no resume run ever\n * starts. Defaults to {@link HITL_PENDING_RESUME_GRACE_MS}.\n */\n pendingResumeGraceMs?: number;\n}\n\nexport interface StatewireApprovalRequest<TValue> {\n /** The pending interrupt this surface answers, if any. */\n request: StatewireThread.CustomInputRequest | undefined;\n requestId: string | undefined;\n /** The payload narrowed to the Athena HITL approval shape, or `null`. */\n hitl: HitlApprovalPayload | null;\n /** Every gated call the approval covers, in decision order (empty for non-HITL parks). */\n actionRequests: PendingActionRequest[];\n /** An interrupt a non-resume dispatch dropped — the \"approval was cancelled\" notice. */\n abandonedInterrupt: AbandonedInputRequest | undefined;\n /** True after a resume until the request identity changes (or recovery fires). */\n pending: boolean;\n /** Answer the request with `{ type: 'run/input', requestId, response: { type: 'resume', value } }`. */\n resume: (value: TValue) => void;\n}\n\n/**\n * The headless half of every statewire approval surface: selects the pending\n * interrupt from the runs projection, narrows its payload, reads the\n * host-published abandoned interrupts, and wires the shared optimistic resume\n * lock to the thread's `run/input` command. `StatewireApprovalCard` renders\n * over it; hosts with their own decision UI (per-lane subagent cards) build\n * on it directly so the selection and lock semantics cannot drift.\n *\n * Requires a statewire aui scope (throws outside one, like every\n * `useStatewire*` hook) — gate the mount with `hasStatewireThreadExtras`.\n */\nexport function useStatewireApprovalRequest<\n TValue extends StatewireThread.InputResponse = Record<string, string>,\n>(options: UseStatewireApprovalRequestOptions = {}): StatewireApprovalRequest<TValue> {\n const {\n interruptPredicate = isApprovalCardInterrupt,\n pendingResumeGraceMs = HITL_PENDING_RESUME_GRACE_MS,\n } = options;\n const sendCommand = useStatewireSendCommand();\n // The runs projection is memoized by the lib, so this derivation is\n // reference-stable between state updates.\n const request = useStatewireRuns().inputRequests?.find(interruptPredicate);\n const requestId = request?.id;\n\n // The host publishes the interrupts a non-resume dispatch dropped. Select\n // the raw array reference (pre-stream-safe) and derive inline; a `.find`\n // selector would return a fresh object every update.\n const abandoned = useStatewireState(readAbandonedInputRequests);\n const abandonedInterrupt = findAbandonedInterrupt(abandoned);\n\n const hitl = asHitlApproval(request?.payload);\n const actionRequests = useMemo(() => pendingActionRequests(hitl), [hitl]);\n\n const isRunning = useAthenaRunLive();\n const { pending, resume } = useApprovalResumeLock<TValue>({\n requestId,\n isRunning,\n pendingResumeGraceMs,\n sendResume: (id, value) =>\n sendCommand({\n type: 'run/input',\n requestId: id,\n response: { type: 'resume', value },\n }),\n });\n\n return { request, requestId, hitl, actionRequests, abandonedInterrupt, pending, resume };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAmEO,SAAS,4BAEd,UAA8C,IAAsC;;AACpF,QAAM;AAAA,IACJ,qBAAqB;AAAA,IACrB,uBAAuB;AAAA,EAAA,IACrB;AACJ,QAAM,cAAc,wBAAA;AAGpB,QAAM,WAAU,sBAAA,EAAmB,kBAAnB,mBAAkC,KAAK;AACvD,QAAM,YAAY,mCAAS;AAK3B,QAAM,YAAY,kBAAkB,0BAA0B;AAC9D,QAAM,qBAAqB,uBAAuB,SAAS;AAE3D,QAAM,OAAO,eAAe,mCAAS,OAAO;AAC5C,QAAM,iBAAiB,QAAQ,MAAM,sBAAsB,IAAI,GAAG,CAAC,IAAI,CAAC;AAExE,QAAM,YAAY,iBAAA;AAClB,QAAM,EAAE,SAAS,OAAA,IAAW,sBAA8B;AAAA,IACxD;AAAA,IACA;AAAA,IACA;AAAA,IACA,YAAY,CAAC,IAAI,UACf,YAAY;AAAA,MACV,MAAM;AAAA,MACN,WAAW;AAAA,MACX,UAAU,EAAE,MAAM,UAAU,MAAA;AAAA,IAAM,CACnC;AAAA,EAAA,CACJ;AAED,SAAO,EAAE,SAAS,WAAW,MAAM,gBAAgB,oBAAoB,SAAS,OAAA;AAClF;"}
1
+ {"version":3,"file":"use-statewire-approval-request.js","sources":["../../src/chat/use-statewire-approval-request.ts"],"sourcesContent":["import type { StatewireThread } from '@assistant-ui/react-statewire';\nimport {\n useStatewireRuns,\n useStatewireSendCommand,\n useStatewireState,\n} from '@assistant-ui/react-statewire';\nimport {\n type AbandonedInputRequest,\n asHitlApproval,\n findAbandonedInterrupt,\n HITL_PENDING_RESUME_GRACE_MS,\n type HitlApprovalPayload,\n isApprovalCardInterrupt,\n type PendingActionRequest,\n pendingActionRequests,\n readAbandonedInputRequests,\n useApprovalResumeLock,\n} from '@athenaintel/agent-runtime';\nimport { useMemo } from 'react';\nimport { useAthenaRunLive } from './use-athena-run-live';\n\n/** Selects which pending interrupt an approval surface answers. */\nexport type StatewireInterruptPredicate = (\n request: StatewireThread.InputRequestState,\n) => request is StatewireThread.CustomInputRequest;\n\nexport interface UseStatewireApprovalRequestOptions {\n /**\n * Which pending interrupt to answer. Defaults to `isApprovalCardInterrupt`\n * (client-tool parks excluded — the client-tool bridge owns those, and a\n * generic resume would corrupt the parked tool call).\n */\n interruptPredicate?: StatewireInterruptPredicate;\n /**\n * How long a sent decision keeps the actions locked when no resume run ever\n * starts. Defaults to {@link HITL_PENDING_RESUME_GRACE_MS}.\n */\n pendingResumeGraceMs?: number;\n /**\n * The host refused the `run/input` (or the transport lost it): the\n * optimistic fold rolls back, the request is on screen again with its\n * actions re-enabled, and this is the surface's one chance to say why.\n */\n onResumeRejected?: (error: unknown, requestId: string) => void;\n}\n\nexport interface StatewireApprovalRequest<TValue> {\n /** The pending interrupt this surface answers, if any. */\n request: StatewireThread.CustomInputRequest | undefined;\n requestId: string | undefined;\n /** The payload narrowed to the Athena HITL approval shape, or `null`. */\n hitl: HitlApprovalPayload | null;\n /** Every gated call the approval covers, in decision order (empty for non-HITL parks). */\n actionRequests: PendingActionRequest[];\n /** An interrupt a non-resume dispatch dropped — the \"approval was cancelled\" notice. */\n abandonedInterrupt: AbandonedInputRequest | undefined;\n /** True after a resume until the request identity changes (or recovery fires). */\n pending: boolean;\n /**\n * Answer the request with `{ type: 'run/input', requestId, response: { type: 'resume', value } }`.\n * Returns the dispatch promise (settles when the host accepts, rejects when\n * it refuses), or `undefined` when the lock dropped the send.\n */\n resume: (value: TValue) => Promise<unknown> | undefined;\n}\n\n/**\n * The headless half of every statewire approval surface: selects the pending\n * interrupt from the runs projection, narrows its payload, reads the\n * host-published abandoned interrupts, and wires the shared optimistic resume\n * lock to the thread's `run/input` command. `StatewireApprovalCard` renders\n * over it; hosts with their own decision UI (per-lane subagent cards) build\n * on it directly so the selection and lock semantics cannot drift.\n *\n * Requires a statewire aui scope (throws outside one, like every\n * `useStatewire*` hook) — gate the mount with `hasStatewireThreadExtras`.\n */\nexport function useStatewireApprovalRequest<\n TValue extends StatewireThread.InputResponse = Record<string, string>,\n>(options: UseStatewireApprovalRequestOptions = {}): StatewireApprovalRequest<TValue> {\n const {\n interruptPredicate = isApprovalCardInterrupt,\n pendingResumeGraceMs = HITL_PENDING_RESUME_GRACE_MS,\n onResumeRejected,\n } = options;\n const sendCommand = useStatewireSendCommand();\n // The runs projection is memoized by the lib, so this derivation is\n // reference-stable between state updates.\n const request = useStatewireRuns().inputRequests?.find(interruptPredicate);\n const requestId = request?.id;\n\n // The host publishes the interrupts a non-resume dispatch dropped. Select\n // the raw array reference (pre-stream-safe) and derive inline; a `.find`\n // selector would return a fresh object every update.\n const abandoned = useStatewireState(readAbandonedInputRequests);\n const abandonedInterrupt = findAbandonedInterrupt(abandoned);\n\n const hitl = asHitlApproval(request?.payload);\n const actionRequests = useMemo(() => pendingActionRequests(hitl), [hitl]);\n\n const isRunning = useAthenaRunLive();\n const { pending, resume } = useApprovalResumeLock<TValue>({\n requestId,\n isRunning,\n pendingResumeGraceMs,\n onResumeRejected,\n // The dispatch promise is handed to the lock: a refusal releases it and\n // reaches `onResumeRejected`.\n sendResume: (id, value) =>\n sendCommand({\n type: 'run/input',\n requestId: id,\n response: { type: 'resume', value },\n }),\n });\n\n return { request, requestId, hitl, actionRequests, abandonedInterrupt, pending, resume };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AA6EO,SAAS,4BAEd,UAA8C,IAAsC;;AACpF,QAAM;AAAA,IACJ,qBAAqB;AAAA,IACrB,uBAAuB;AAAA,IACvB;AAAA,EAAA,IACE;AACJ,QAAM,cAAc,wBAAA;AAGpB,QAAM,WAAU,sBAAA,EAAmB,kBAAnB,mBAAkC,KAAK;AACvD,QAAM,YAAY,mCAAS;AAK3B,QAAM,YAAY,kBAAkB,0BAA0B;AAC9D,QAAM,qBAAqB,uBAAuB,SAAS;AAE3D,QAAM,OAAO,eAAe,mCAAS,OAAO;AAC5C,QAAM,iBAAiB,QAAQ,MAAM,sBAAsB,IAAI,GAAG,CAAC,IAAI,CAAC;AAExE,QAAM,YAAY,iBAAA;AAClB,QAAM,EAAE,SAAS,OAAA,IAAW,sBAA8B;AAAA,IACxD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA;AAAA,IAGA,YAAY,CAAC,IAAI,UACf,YAAY;AAAA,MACV,MAAM;AAAA,MACN,WAAW;AAAA,MACX,UAAU,EAAE,MAAM,UAAU,MAAA;AAAA,IAAM,CACnC;AAAA,EAAA,CACJ;AAED,SAAO,EAAE,SAAS,WAAW,MAAM,gBAAgB,oBAAoB,SAAS,OAAA;AAClF;"}
@@ -5,14 +5,11 @@ const athenaDiagnostics = require("../../diagnostics/athena-diagnostics.cjs");
5
5
  const clipboard = require("../../composer/clipboard.cjs");
6
6
  const react = require("react");
7
7
  const react$2 = require("@tiptap/react");
8
- const StarterKit = require("@tiptap/starter-kit");
9
- const Link = require("@tiptap/extension-link");
10
8
  const Placeholder = require("@tiptap/extension-placeholder");
11
9
  const core = require("@tiptap/core");
12
- const tiptapMarkdown = require("tiptap-markdown");
13
10
  const react$1 = require("@assistant-ui/react");
14
11
  const lucideReact = require("lucide-react");
15
- const mentionExtension = require("../mentions/mention-extension.cjs");
12
+ const chatTextSchema = require("../rich-text/chat-text-schema.cjs");
16
13
  const mentionSuggestions_extension = require("../mentions/suggestions/mention-suggestions.extension.cjs");
17
14
  const mentionSuggestionPopup = require("../mentions/suggestions/components/mention-suggestion-popup.cjs");
18
15
  const mentionSuggestionList = require("../mentions/suggestions/components/mention-suggestion-list.cjs");
@@ -27,10 +24,11 @@ require("../../packages/agent-runtime/src/statewire-state.cjs");
27
24
  require("../../packages/agent-runtime/src/messages.cjs");
28
25
  require("@assistant-ui/react-statewire");
29
26
  require("@assistant-ui/store");
30
- require("@assistant-ui/react-statewire/local-storage");
27
+ require("../../packages/agent-runtime/src/quota-safe-local-storage-session.cjs");
31
28
  require("../../packages/agent-runtime/src/statewire-attach-observer.cjs");
32
29
  require("../../packages/agent-runtime/src/thread-status.cjs");
33
30
  require("@assistant-ui/core");
31
+ require("../../packages/agent-runtime/src/thread-handoff.cjs");
34
32
  const pendingAttachmentUploads = require("./pending-attachment-uploads.cjs");
35
33
  const cnfast = require("cnfast");
36
34
  const SubmitKeybind = core.Extension.create({
@@ -44,45 +42,19 @@ const SubmitKeybind = core.Extension.create({
44
42
  return {
45
43
  Enter: () => {
46
44
  if (this.options.isMentionOpen()) return false;
45
+ if (["listItem", "taskItem", "codeBlock", "table", "blockquote"].some(
46
+ (node) => this.editor.isActive(node)
47
+ )) return false;
47
48
  this.options.onSubmit();
48
49
  return true;
49
50
  },
50
51
  "Shift-Enter": () => {
51
- this.editor.commands.setHardBreak();
52
- return true;
52
+ return this.editor.commands.newlineInCode() || this.editor.commands.setHardBreak();
53
53
  }
54
54
  };
55
55
  }
56
56
  });
57
57
  const MENTION_STYLES = `
58
- .mention-chip {
59
- display: inline-flex;
60
- align-items: center;
61
- gap: 4px;
62
- background: rgba(148, 163, 184, 0.1);
63
- color: #475569;
64
- border: 1px solid #cbd5e1;
65
- border-radius: 6px;
66
- padding: 1px 6px;
67
- font-size: 0.85em;
68
- font-weight: 500;
69
- white-space: nowrap;
70
- user-select: all;
71
- vertical-align: middle;
72
- height: 20px;
73
- line-height: 1;
74
- }
75
- .mention-chip-icon {
76
- width: 14px;
77
- height: 14px;
78
- flex-shrink: 0;
79
- }
80
- .mention-chip-text {
81
- white-space: nowrap;
82
- overflow: hidden;
83
- text-overflow: ellipsis;
84
- max-width: 180px;
85
- }
86
58
  .image-preview-composer .mention-chip[data-display-as-preview="true"] {
87
59
  display: none;
88
60
  }
@@ -95,9 +67,6 @@ const MENTION_STYLES = `
95
67
  max-height: 120px;
96
68
  overflow-y: auto;
97
69
  }
98
- .athena-chat-composer .ProseMirror p {
99
- margin: 0;
100
- }
101
70
  .athena-chat-composer .ProseMirror p.is-editor-empty:first-child::before {
102
71
  content: attr(data-placeholder);
103
72
  float: left;
@@ -106,16 +75,6 @@ const MENTION_STYLES = `
106
75
  height: 0;
107
76
  }
108
77
  `;
109
- const DraftMarkdown = tiptapMarkdown.Markdown.configure({
110
- html: true,
111
- tightLists: true,
112
- tightListClass: "tight",
113
- bulletListMarker: "-",
114
- linkify: true,
115
- breaks: true,
116
- transformPastedText: true,
117
- transformCopiedText: false
118
- });
119
78
  function serializeDraft(editor) {
120
79
  return editor.storage.markdown.getMarkdown();
121
80
  }
@@ -400,18 +359,8 @@ const TiptapComposer = react.forwardRef(
400
359
  const editor = react$2.useEditor({
401
360
  editable: !disabled,
402
361
  extensions: [
403
- StarterKit.configure({
404
- heading: false,
405
- blockquote: false,
406
- bulletList: false,
407
- orderedList: false,
408
- codeBlock: false,
409
- horizontalRule: false
410
- }),
362
+ ...chatTextSchema.createChatTextExtensions(),
411
363
  Placeholder.configure({ placeholder }),
412
- Link.configure({ openOnClick: false, autolink: true, linkOnPaste: true }),
413
- DraftMarkdown,
414
- mentionExtension.MentionExtension,
415
364
  mentionSuggestions_extension.MentionSuggestionsExtension.configure({
416
365
  store,
417
366
  callbacks: callbacksRef.current
@@ -423,7 +372,7 @@ const TiptapComposer = react.forwardRef(
423
372
  ],
424
373
  editorProps: {
425
374
  attributes: {
426
- class: "w-full resize-none bg-transparent px-1.5 py-2 text-sm leading-snug outline-none",
375
+ class: cnfast.cn(chatTextSchema.CHAT_TEXT_CLASS, "w-full resize-none bg-transparent px-1.5 py-2 outline-none"),
427
376
  "data-testid": "athena-chat-composer"
428
377
  },
429
378
  handlePaste,
@@ -461,11 +410,21 @@ const TiptapComposer = react.forwardRef(
461
410
  const currentMarkdown = serializeDraft(editor);
462
411
  lastEmittedMarkdownRef.current = currentMarkdown;
463
412
  if (value === currentMarkdown) return;
464
- applyingRuntimeTextRef.current = true;
465
- editor.commands.setContent(value);
466
- applyingRuntimeTextRef.current = false;
467
- lastEmittedMarkdownRef.current = serializeDraft(editor);
468
- onDraftStateChange == null ? void 0 : onDraftStateChange(value.trim().length > 0);
413
+ let cancelled = false;
414
+ queueMicrotask(() => {
415
+ if (cancelled || editor.isDestroyed) return;
416
+ applyingRuntimeTextRef.current = true;
417
+ try {
418
+ editor.commands.setContent(value);
419
+ lastEmittedMarkdownRef.current = serializeDraft(editor);
420
+ } finally {
421
+ applyingRuntimeTextRef.current = false;
422
+ }
423
+ onDraftStateChange == null ? void 0 : onDraftStateChange(value.trim().length > 0);
424
+ });
425
+ return () => {
426
+ cancelled = true;
427
+ };
469
428
  }, [composerInput.value, editor, onDraftStateChange]);
470
429
  const insertAssetMention = react.useCallback(
471
430
  (asset, sourceFile) => {
@@ -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 StarterKit from \"@tiptap/starter-kit\";\nimport Link from \"@tiptap/extension-link\";\nimport Placeholder from \"@tiptap/extension-placeholder\";\nimport { Extension, type Editor } from \"@tiptap/core\";\nimport { Markdown } from \"tiptap-markdown\";\nimport { unstable_useComposerInput, useAui } from \"@assistant-ui/react\";\nimport { LoaderCircleIcon, XIcon } from \"lucide-react\";\nimport { cn } from \"../../lib/utils\";\nimport { MentionExtension } from \"../mentions/mention-extension\";\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\";\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 this.options.onSubmit();\n return true;\n },\n \"Shift-Enter\": () => {\n this.editor.commands.setHardBreak();\n return true;\n },\n };\n },\n});\n\n// ── CSS for mention chips + editor ──\n\nconst MENTION_STYLES = `\n .mention-chip {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n background: rgba(148, 163, 184, 0.1);\n color: #475569;\n border: 1px solid #cbd5e1;\n border-radius: 6px;\n padding: 1px 6px;\n font-size: 0.85em;\n font-weight: 500;\n white-space: nowrap;\n user-select: all;\n vertical-align: middle;\n height: 20px;\n line-height: 1;\n }\n .mention-chip-icon {\n width: 14px;\n height: 14px;\n flex-shrink: 0;\n }\n .mention-chip-text {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n max-width: 180px;\n }\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 {\n margin: 0;\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`;\n\n/**\n * The Markdown extension as the Olympus chat composer configures it\n * (`MarkdownMessageConfig`): one serializer for every chat surface, so a\n * draft reads the same to the agent whichever composer sent it.\n */\nconst DraftMarkdown = Markdown.configure({\n html: true,\n tightLists: true,\n tightListClass: \"tight\",\n bulletListMarker: \"-\",\n linkify: true,\n breaks: true,\n transformPastedText: true,\n transformCopiedText: false,\n});\n\ninterface MarkdownStorage {\n getMarkdown(): string;\n}\n\n/** The draft as it is sent: Markdown, mentions as `[@Name](url)` links. */\nexport function serializeDraft(editor: Editor): string {\n return (editor.storage as { markdown: MarkdownStorage }).markdown.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\nexport interface TiptapComposerProps {\n placeholder?: string;\n threadId: string;\n disabled?: boolean;\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\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 webpages = NO_WEBPAGES,\n tools,\n rootCategories,\n onDraftStateChange,\n showImagePreviews = false,\n onAttachmentError,\n fileIntake,\n waitForHostUploads,\n interceptSubmit,\n },\n outerRef,\n ) => {\n const aui = useAui();\n const composerInput = unstable_useComposerInput();\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();\n clearImagePreviews();\n onDraftStateChange?.(false);\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();\n clearImagePreviews();\n onDraftStateChange?.(false);\n } finally {\n submitInFlightRef.current = false;\n }\n }, [\n clearImagePreviews,\n composerInput,\n disabled,\n interceptSubmit,\n onDraftStateChange,\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 StarterKit.configure({\n heading: false,\n blockquote: false,\n bulletList: false,\n orderedList: false,\n codeBlock: false,\n horizontalRule: false,\n }),\n Placeholder.configure({ placeholder }),\n Link.configure({ openOnClick: false, autolink: true, linkOnPaste: true }),\n DraftMarkdown,\n MentionExtension,\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:\n \"w-full resize-none bg-transparent px-1.5 py-2 text-sm leading-snug 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 applyingRuntimeTextRef.current = true;\n editor.commands.setContent(value);\n applyingRuntimeTextRef.current = false;\n lastEmittedMarkdownRef.current = serializeDraft(editor);\n onDraftStateChange?.(value.trim().length > 0);\n }, [composerInput.value, editor, onDraftStateChange]);\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 useImperativeHandle(\n outerRef,\n () => ({ submit: handleSubmit, addAttachment, insertAssetMention }),\n [addAttachment, handleSubmit, insertAssetMention],\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 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","Markdown","jsx","jsxs","LoaderCircleIcon","XIcon","forwardRef","useAui","unstable_useComposerInput","useRef","PendingAttachmentUploads","useState","useCallback","useEffect","useMentionSuggestions","extractPastedImages","clipboardHasMeaningfulText","athenaDiagnostics","useEditor","MentionExtension","MentionSuggestionsExtension","registerChatAssetMentionHandler","useImperativeHandle","Fragment","cn","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;AACzC,aAAK,QA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AA,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` — 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 { 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 {\n registerChatAssetMentionHandler,\n type UploadedChatAsset,\n} from \"@athenaintel/agent-runtime\";\nimport { PendingAttachmentUploads } from \"./pending-attachment-uploads\";\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 // 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`;\n\ninterface MarkdownStorage {\n getMarkdown(): string;\n}\n\n/** The draft as it is sent: Markdown, mentions as `[@Name](url)` links. */\nexport function serializeDraft(editor: Editor): string {\n return (editor.storage as { markdown: MarkdownStorage }).markdown.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\nexport interface TiptapComposerProps {\n placeholder?: string;\n threadId: string;\n disabled?: boolean;\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\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 webpages = NO_WEBPAGES,\n tools,\n rootCategories,\n onDraftStateChange,\n showImagePreviews = false,\n onAttachmentError,\n fileIntake,\n waitForHostUploads,\n interceptSubmit,\n },\n outerRef,\n ) => {\n const aui = useAui();\n const composerInput = unstable_useComposerInput();\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();\n clearImagePreviews();\n onDraftStateChange?.(false);\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();\n clearImagePreviews();\n onDraftStateChange?.(false);\n } finally {\n submitInFlightRef.current = false;\n }\n }, [\n clearImagePreviews,\n composerInput,\n disabled,\n interceptSubmit,\n onDraftStateChange,\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);\n lastEmittedMarkdownRef.current = serializeDraft(editor);\n } finally {\n applyingRuntimeTextRef.current = false;\n }\n onDraftStateChange?.(value.trim().length > 0);\n });\n return () => { cancelled = true; };\n }, [composerInput.value, editor, onDraftStateChange]);\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 useImperativeHandle(\n outerRef,\n () => ({ submit: handleSubmit, addAttachment, insertAssetMention }),\n [addAttachment, handleSubmit, insertAssetMention],\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 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","jsx","jsxs","LoaderCircleIcon","XIcon","forwardRef","useAui","unstable_useComposerInput","useRef","PendingAttachmentUploads","useState","useCallback","useEffect","useMentionSuggestions","extractPastedImages","clipboardHasMeaningfulText","athenaDiagnostics","useEditor","createChatTextExtensions","MentionSuggestionsExtension","cn","CHAT_TEXT_CLASS","registerChatAssetMentionHandler","useImperativeHandle","Fragment","EditorContent","MentionSuggestionPopup","MentionSuggestionList"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqEA,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;AAGzC,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,M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