@athenaintel/react 0.57.2 → 0.60.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 (852) hide show
  1. package/README.md +795 -12
  2. package/dist/agent-runtime/src/addressed-agents.cjs +16 -0
  3. package/dist/agent-runtime/src/addressed-agents.cjs.map +1 -0
  4. package/dist/agent-runtime/src/addressed-agents.d.ts +30 -0
  5. package/dist/agent-runtime/src/addressed-agents.js +16 -0
  6. package/dist/agent-runtime/src/addressed-agents.js.map +1 -0
  7. package/dist/agent-runtime/src/answer-label.cjs +4 -3
  8. package/dist/agent-runtime/src/answer-label.cjs.map +1 -1
  9. package/dist/agent-runtime/src/answer-label.d.ts +13 -6
  10. package/dist/agent-runtime/src/answer-label.js +4 -3
  11. package/dist/agent-runtime/src/answer-label.js.map +1 -1
  12. package/dist/agent-runtime/src/chat-outbox-attachments.cjs.map +1 -1
  13. package/dist/agent-runtime/src/chat-outbox-attachments.d.ts +1 -1
  14. package/dist/agent-runtime/src/chat-outbox-attachments.js.map +1 -1
  15. package/dist/agent-runtime/src/chat-outbox-entry.cjs +101 -0
  16. package/dist/agent-runtime/src/chat-outbox-entry.cjs.map +1 -0
  17. package/dist/agent-runtime/src/chat-outbox-entry.d.ts +99 -0
  18. package/dist/agent-runtime/src/chat-outbox-entry.js +101 -0
  19. package/dist/agent-runtime/src/chat-outbox-entry.js.map +1 -0
  20. package/dist/agent-runtime/src/chat-outbox-legacy.cjs +252 -0
  21. package/dist/agent-runtime/src/chat-outbox-legacy.cjs.map +1 -0
  22. package/dist/agent-runtime/src/chat-outbox-legacy.d.ts +96 -0
  23. package/dist/agent-runtime/src/chat-outbox-legacy.js +252 -0
  24. package/dist/agent-runtime/src/chat-outbox-legacy.js.map +1 -0
  25. package/dist/agent-runtime/src/chat-outbox-policy.cjs +30 -0
  26. package/dist/agent-runtime/src/chat-outbox-policy.cjs.map +1 -0
  27. package/dist/agent-runtime/src/chat-outbox-policy.d.ts +42 -0
  28. package/dist/agent-runtime/src/chat-outbox-policy.js +30 -0
  29. package/dist/agent-runtime/src/chat-outbox-policy.js.map +1 -0
  30. package/dist/agent-runtime/src/chat-outbox-storage.cjs +306 -0
  31. package/dist/agent-runtime/src/chat-outbox-storage.cjs.map +1 -0
  32. package/dist/agent-runtime/src/chat-outbox-storage.d.ts +194 -0
  33. package/dist/agent-runtime/src/chat-outbox-storage.js +306 -0
  34. package/dist/agent-runtime/src/chat-outbox-storage.js.map +1 -0
  35. package/dist/agent-runtime/src/chat-outbox-thread.cjs +21 -94
  36. package/dist/agent-runtime/src/chat-outbox-thread.cjs.map +1 -1
  37. package/dist/agent-runtime/src/chat-outbox-thread.d.ts +22 -18
  38. package/dist/agent-runtime/src/chat-outbox-thread.js +21 -94
  39. package/dist/agent-runtime/src/chat-outbox-thread.js.map +1 -1
  40. package/dist/agent-runtime/src/chat-outbox.cjs +492 -547
  41. package/dist/agent-runtime/src/chat-outbox.cjs.map +1 -1
  42. package/dist/agent-runtime/src/chat-outbox.d.ts +110 -142
  43. package/dist/agent-runtime/src/chat-outbox.js +492 -547
  44. package/dist/agent-runtime/src/chat-outbox.js.map +1 -1
  45. package/dist/agent-runtime/src/composer-markdown.cjs +0 -16
  46. package/dist/agent-runtime/src/composer-markdown.cjs.map +1 -1
  47. package/dist/agent-runtime/src/composer-markdown.d.ts +1 -1
  48. package/dist/agent-runtime/src/composer-markdown.js +1 -17
  49. package/dist/agent-runtime/src/composer-markdown.js.map +1 -1
  50. package/dist/agent-runtime/src/deep-agent-transport-recipe.cjs +3 -1
  51. package/dist/agent-runtime/src/deep-agent-transport-recipe.cjs.map +1 -1
  52. package/dist/agent-runtime/src/deep-agent-transport-recipe.d.ts +8 -1
  53. package/dist/agent-runtime/src/deep-agent-transport-recipe.js +3 -1
  54. package/dist/agent-runtime/src/deep-agent-transport-recipe.js.map +1 -1
  55. package/dist/agent-runtime/src/dictation-preferences.d.ts +356 -0
  56. package/dist/agent-runtime/src/dictation-record.d.ts +279 -0
  57. package/dist/agent-runtime/src/dictation-session.d.ts +106 -7
  58. package/dist/agent-runtime/src/dictation-snippets.d.ts +9 -0
  59. package/dist/agent-runtime/src/dictation-transfer.d.ts +142 -0
  60. package/dist/agent-runtime/src/edit-command.cjs.map +1 -1
  61. package/dist/agent-runtime/src/edit-command.d.ts +1 -1
  62. package/dist/agent-runtime/src/edit-command.js.map +1 -1
  63. package/dist/agent-runtime/src/errors.cjs +1 -0
  64. package/dist/agent-runtime/src/errors.cjs.map +1 -1
  65. package/dist/agent-runtime/src/errors.js +1 -0
  66. package/dist/agent-runtime/src/errors.js.map +1 -1
  67. package/dist/agent-runtime/src/generated/runconfig-contract.cjs +24 -0
  68. package/dist/agent-runtime/src/generated/runconfig-contract.cjs.map +1 -1
  69. package/dist/agent-runtime/src/generated/runconfig-contract.d.ts +3 -3
  70. package/dist/agent-runtime/src/generated/runconfig-contract.js +24 -0
  71. package/dist/agent-runtime/src/generated/runconfig-contract.js.map +1 -1
  72. package/dist/agent-runtime/src/index.d.ts +14 -8
  73. package/dist/agent-runtime/src/lane-follow.cjs +289 -0
  74. package/dist/agent-runtime/src/lane-follow.cjs.map +1 -0
  75. package/dist/agent-runtime/src/lane-follow.js +289 -0
  76. package/dist/agent-runtime/src/lane-follow.js.map +1 -0
  77. package/dist/agent-runtime/src/lane-images.cjs +387 -0
  78. package/dist/agent-runtime/src/lane-images.cjs.map +1 -0
  79. package/dist/agent-runtime/src/lane-images.js +387 -0
  80. package/dist/agent-runtime/src/lane-images.js.map +1 -0
  81. package/dist/agent-runtime/src/message-window.js +1 -1
  82. package/dist/agent-runtime/src/messages.cjs +19 -1
  83. package/dist/agent-runtime/src/messages.cjs.map +1 -1
  84. package/dist/agent-runtime/src/messages.d.ts +8 -0
  85. package/dist/agent-runtime/src/messages.js +21 -3
  86. package/dist/agent-runtime/src/messages.js.map +1 -1
  87. package/dist/agent-runtime/src/named-agents.cjs +301 -0
  88. package/dist/agent-runtime/src/named-agents.cjs.map +1 -0
  89. package/dist/agent-runtime/src/named-agents.d.ts +246 -0
  90. package/dist/agent-runtime/src/named-agents.js +301 -0
  91. package/dist/agent-runtime/src/named-agents.js.map +1 -0
  92. package/dist/agent-runtime/src/offline-status.cjs.map +1 -1
  93. package/dist/agent-runtime/src/offline-status.d.ts +93 -2
  94. package/dist/agent-runtime/src/offline-status.js.map +1 -1
  95. package/dist/agent-runtime/src/ptc-subcalls.cjs +41 -0
  96. package/dist/agent-runtime/src/ptc-subcalls.cjs.map +1 -0
  97. package/dist/agent-runtime/src/ptc-subcalls.js +41 -0
  98. package/dist/agent-runtime/src/ptc-subcalls.js.map +1 -0
  99. package/dist/agent-runtime/src/queue.cjs +2 -2
  100. package/dist/agent-runtime/src/queue.cjs.map +1 -1
  101. package/dist/agent-runtime/src/queue.d.ts +20 -25
  102. package/dist/agent-runtime/src/queue.js +2 -2
  103. package/dist/agent-runtime/src/queue.js.map +1 -1
  104. package/dist/agent-runtime/src/quota-safe-local-storage-session.cjs +314 -84
  105. package/dist/agent-runtime/src/quota-safe-local-storage-session.cjs.map +1 -1
  106. package/dist/agent-runtime/src/quota-safe-local-storage-session.d.ts +137 -40
  107. package/dist/agent-runtime/src/quota-safe-local-storage-session.js +318 -88
  108. package/dist/agent-runtime/src/quota-safe-local-storage-session.js.map +1 -1
  109. package/dist/agent-runtime/src/run-send.cjs +54 -0
  110. package/dist/agent-runtime/src/run-send.cjs.map +1 -0
  111. package/dist/agent-runtime/src/run-send.d.ts +51 -0
  112. package/dist/agent-runtime/src/run-send.js +54 -0
  113. package/dist/agent-runtime/src/run-send.js.map +1 -0
  114. package/dist/agent-runtime/src/running-tool-placeholder.cjs +6 -0
  115. package/dist/agent-runtime/src/running-tool-placeholder.cjs.map +1 -1
  116. package/dist/agent-runtime/src/running-tool-placeholder.js +6 -0
  117. package/dist/agent-runtime/src/running-tool-placeholder.js.map +1 -1
  118. package/dist/agent-runtime/src/runtime.d.ts +9 -5
  119. package/dist/agent-runtime/src/sealed-idb.cjs +64 -0
  120. package/dist/agent-runtime/src/sealed-idb.cjs.map +1 -1
  121. package/dist/agent-runtime/src/sealed-idb.d.ts +16 -0
  122. package/dist/agent-runtime/src/sealed-idb.js +64 -0
  123. package/dist/agent-runtime/src/sealed-idb.js.map +1 -1
  124. package/dist/agent-runtime/src/send-recovery.cjs +90 -118
  125. package/dist/agent-runtime/src/send-recovery.cjs.map +1 -1
  126. package/dist/agent-runtime/src/send-recovery.d.ts +25 -29
  127. package/dist/agent-runtime/src/send-recovery.js +90 -118
  128. package/dist/agent-runtime/src/send-recovery.js.map +1 -1
  129. package/dist/agent-runtime/src/statewire-diagnostics.d.ts +4 -1
  130. package/dist/agent-runtime/src/statewire-held-sends.cjs +191 -0
  131. package/dist/agent-runtime/src/statewire-held-sends.cjs.map +1 -0
  132. package/dist/agent-runtime/src/statewire-held-sends.d.ts +119 -0
  133. package/dist/agent-runtime/src/statewire-held-sends.js +191 -0
  134. package/dist/agent-runtime/src/statewire-held-sends.js.map +1 -0
  135. package/dist/agent-runtime/src/statewire-state.cjs +4 -0
  136. package/dist/agent-runtime/src/statewire-state.cjs.map +1 -1
  137. package/dist/agent-runtime/src/statewire-state.js +4 -0
  138. package/dist/agent-runtime/src/statewire-state.js.map +1 -1
  139. package/dist/agent-runtime/src/statewire-transport.cjs +8 -2
  140. package/dist/agent-runtime/src/statewire-transport.cjs.map +1 -1
  141. package/dist/agent-runtime/src/statewire-transport.d.ts +14 -5
  142. package/dist/agent-runtime/src/statewire-transport.js +8 -2
  143. package/dist/agent-runtime/src/statewire-transport.js.map +1 -1
  144. package/dist/agent-runtime/src/subagent-transcripts.cjs +1 -23
  145. package/dist/agent-runtime/src/subagent-transcripts.cjs.map +1 -1
  146. package/dist/agent-runtime/src/subagent-transcripts.js +3 -25
  147. package/dist/agent-runtime/src/subagent-transcripts.js.map +1 -1
  148. package/dist/agent-runtime/src/subagents.cjs +22 -29
  149. package/dist/agent-runtime/src/subagents.cjs.map +1 -1
  150. package/dist/agent-runtime/src/subagents.js +23 -30
  151. package/dist/agent-runtime/src/subagents.js.map +1 -1
  152. package/dist/agent-runtime/src/thread-extras.cjs +27 -19
  153. package/dist/agent-runtime/src/thread-extras.cjs.map +1 -1
  154. package/dist/agent-runtime/src/thread-extras.d.ts +19 -6
  155. package/dist/agent-runtime/src/thread-extras.js +27 -19
  156. package/dist/agent-runtime/src/thread-extras.js.map +1 -1
  157. package/dist/agent-runtime/src/thread-handoff-flow-machine.d.ts +8 -8
  158. package/dist/agent-runtime/src/tool-metadata.cjs +19 -0
  159. package/dist/agent-runtime/src/tool-metadata.cjs.map +1 -1
  160. package/dist/agent-runtime/src/tool-metadata.js +19 -0
  161. package/dist/agent-runtime/src/tool-metadata.js.map +1 -1
  162. package/dist/agent-runtime/src/tool-names.cjs +21 -0
  163. package/dist/agent-runtime/src/tool-names.cjs.map +1 -1
  164. package/dist/agent-runtime/src/tool-names.d.ts +8 -0
  165. package/dist/agent-runtime/src/tool-names.js +21 -0
  166. package/dist/agent-runtime/src/tool-names.js.map +1 -1
  167. package/dist/agent-runtime/src/typed-interrupt-kinds.cjs +247 -0
  168. package/dist/agent-runtime/src/typed-interrupt-kinds.cjs.map +1 -0
  169. package/dist/agent-runtime/src/typed-interrupt-kinds.d.ts +173 -0
  170. package/dist/agent-runtime/src/typed-interrupt-kinds.js +247 -0
  171. package/dist/agent-runtime/src/typed-interrupt-kinds.js.map +1 -0
  172. package/dist/agent-runtime/src/typed-interrupts.cjs +48 -0
  173. package/dist/agent-runtime/src/typed-interrupts.cjs.map +1 -0
  174. package/dist/agent-runtime/src/typed-interrupts.d.ts +75 -0
  175. package/dist/agent-runtime/src/typed-interrupts.js +48 -0
  176. package/dist/agent-runtime/src/typed-interrupts.js.map +1 -0
  177. package/dist/agent-runtime/src/types.d.ts +1 -1
  178. package/dist/agent-runtime/src/use-conversation-list.cjs +1 -0
  179. package/dist/agent-runtime/src/use-conversation-list.cjs.map +1 -1
  180. package/dist/agent-runtime/src/use-conversation-list.d.ts +7 -0
  181. package/dist/agent-runtime/src/use-conversation-list.js +1 -0
  182. package/dist/agent-runtime/src/use-conversation-list.js.map +1 -1
  183. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.cjs +46 -29
  184. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.cjs.map +1 -1
  185. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.d.ts +14 -22
  186. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.js +46 -29
  187. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.js.map +1 -1
  188. package/dist/agent-runtime/src/use-deep-agent-runtime.cjs +78 -14
  189. package/dist/agent-runtime/src/use-deep-agent-runtime.cjs.map +1 -1
  190. package/dist/agent-runtime/src/use-deep-agent-runtime.d.ts +34 -7
  191. package/dist/agent-runtime/src/use-deep-agent-runtime.js +79 -15
  192. package/dist/agent-runtime/src/use-deep-agent-runtime.js.map +1 -1
  193. package/dist/agent-runtime/src/use-deep-agent-thread.cjs +16 -1
  194. package/dist/agent-runtime/src/use-deep-agent-thread.cjs.map +1 -1
  195. package/dist/agent-runtime/src/use-deep-agent-thread.d.ts +7 -2
  196. package/dist/agent-runtime/src/use-deep-agent-thread.js +16 -1
  197. package/dist/agent-runtime/src/use-deep-agent-thread.js.map +1 -1
  198. package/dist/agent-runtime/src/use-deep-agent-voice.cjs +30 -4
  199. package/dist/agent-runtime/src/use-deep-agent-voice.cjs.map +1 -1
  200. package/dist/agent-runtime/src/use-deep-agent-voice.d.ts +22 -4
  201. package/dist/agent-runtime/src/use-deep-agent-voice.js +30 -4
  202. package/dist/agent-runtime/src/use-deep-agent-voice.js.map +1 -1
  203. package/dist/agent-runtime/src/withdrawn-turns.d.ts +5 -4
  204. package/dist/agent-runtime/src/word-device-fit.d.ts +174 -0
  205. package/dist/agent-runtime/src/work-in.d.ts +127 -0
  206. package/dist/assets/AthenaAssetEmbed.cjs.map +1 -1
  207. package/dist/assets/AthenaAssetEmbed.d.ts +6 -1
  208. package/dist/assets/AthenaAssetEmbed.js.map +1 -1
  209. package/dist/assets/asset-panel-store.cjs +13 -5
  210. package/dist/assets/asset-panel-store.cjs.map +1 -1
  211. package/dist/assets/asset-panel-store.d.ts +33 -2
  212. package/dist/assets/asset-panel-store.js +13 -5
  213. package/dist/assets/asset-panel-store.js.map +1 -1
  214. package/dist/auth/AthenaCredentialSourceContext.cjs +11 -0
  215. package/dist/auth/AthenaCredentialSourceContext.cjs.map +1 -1
  216. package/dist/auth/AthenaCredentialSourceContext.d.ts +6 -0
  217. package/dist/auth/AthenaCredentialSourceContext.js +11 -0
  218. package/dist/auth/AthenaCredentialSourceContext.js.map +1 -1
  219. package/dist/auth/account-identity.cjs +13 -2
  220. package/dist/auth/account-identity.cjs.map +1 -1
  221. package/dist/auth/account-identity.d.ts +9 -0
  222. package/dist/auth/account-identity.js +13 -2
  223. package/dist/auth/account-identity.js.map +1 -1
  224. package/dist/auth/credential-source.cjs +20 -4
  225. package/dist/auth/credential-source.cjs.map +1 -1
  226. package/dist/auth/credential-source.d.ts +9 -0
  227. package/dist/auth/credential-source.js +20 -4
  228. package/dist/auth/credential-source.js.map +1 -1
  229. package/dist/catalog/chat-pickers.cjs +31 -0
  230. package/dist/catalog/chat-pickers.cjs.map +1 -1
  231. package/dist/catalog/chat-pickers.d.ts +17 -0
  232. package/dist/catalog/chat-pickers.js +33 -2
  233. package/dist/catalog/chat-pickers.js.map +1 -1
  234. package/dist/catalog/runtime-catalog.cjs +63 -3
  235. package/dist/catalog/runtime-catalog.cjs.map +1 -1
  236. package/dist/catalog/runtime-catalog.d.ts +63 -3
  237. package/dist/catalog/runtime-catalog.js +64 -4
  238. package/dist/catalog/runtime-catalog.js.map +1 -1
  239. package/dist/chat/AthenaChat.cjs +301 -98
  240. package/dist/chat/AthenaChat.cjs.map +1 -1
  241. package/dist/chat/AthenaChat.d.ts +80 -4
  242. package/dist/chat/AthenaChat.js +302 -99
  243. package/dist/chat/AthenaChat.js.map +1 -1
  244. package/dist/chat/StatewireApprovalCard.cjs +35 -5
  245. package/dist/chat/StatewireApprovalCard.cjs.map +1 -1
  246. package/dist/chat/StatewireApprovalCard.d.ts +55 -2
  247. package/dist/chat/StatewireApprovalCard.js +37 -7
  248. package/dist/chat/StatewireApprovalCard.js.map +1 -1
  249. package/dist/chat/StatewireQueuedMessages.cjs +17 -2
  250. package/dist/chat/StatewireQueuedMessages.cjs.map +1 -1
  251. package/dist/chat/StatewireQueuedMessages.d.ts +8 -45
  252. package/dist/chat/StatewireQueuedMessages.js +18 -3
  253. package/dist/chat/StatewireQueuedMessages.js.map +1 -1
  254. package/dist/chat/chat-agent-mentions.cjs +70 -0
  255. package/dist/chat/chat-agent-mentions.cjs.map +1 -0
  256. package/dist/chat/chat-agent-mentions.d.ts +13 -0
  257. package/dist/chat/chat-agent-mentions.js +70 -0
  258. package/dist/chat/chat-agent-mentions.js.map +1 -0
  259. package/dist/chat/composer-actions.cjs +12 -0
  260. package/dist/chat/composer-actions.cjs.map +1 -0
  261. package/dist/chat/composer-actions.d.ts +22 -0
  262. package/dist/chat/composer-actions.js +12 -0
  263. package/dist/chat/composer-actions.js.map +1 -0
  264. package/dist/chat/follow-up-suggestions.cjs +185 -0
  265. package/dist/chat/follow-up-suggestions.cjs.map +1 -0
  266. package/dist/chat/follow-up-suggestions.d.ts +64 -0
  267. package/dist/chat/follow-up-suggestions.js +185 -0
  268. package/dist/chat/follow-up-suggestions.js.map +1 -0
  269. package/dist/chat/super-grouping/ToolTimeline.cjs +4 -3
  270. package/dist/chat/super-grouping/ToolTimeline.cjs.map +1 -1
  271. package/dist/chat/super-grouping/ToolTimeline.d.ts +7 -3
  272. package/dist/chat/super-grouping/ToolTimeline.js +4 -3
  273. package/dist/chat/super-grouping/ToolTimeline.js.map +1 -1
  274. package/dist/chat/turn-changes.cjs +284 -0
  275. package/dist/chat/turn-changes.cjs.map +1 -0
  276. package/dist/chat/turn-changes.d.ts +130 -0
  277. package/dist/chat/turn-changes.js +284 -0
  278. package/dist/chat/turn-changes.js.map +1 -0
  279. package/dist/chat/typed-interrupts/StatewireTypedInterruptCard.cjs +31 -0
  280. package/dist/chat/typed-interrupts/StatewireTypedInterruptCard.cjs.map +1 -0
  281. package/dist/chat/typed-interrupts/StatewireTypedInterruptCard.d.ts +31 -0
  282. package/dist/chat/typed-interrupts/StatewireTypedInterruptCard.js +31 -0
  283. package/dist/chat/typed-interrupts/StatewireTypedInterruptCard.js.map +1 -0
  284. package/dist/chat/typed-interrupts/approval-cards.cjs +250 -0
  285. package/dist/chat/typed-interrupts/approval-cards.cjs.map +1 -0
  286. package/dist/chat/typed-interrupts/approval-cards.d.ts +22 -0
  287. package/dist/chat/typed-interrupts/approval-cards.js +250 -0
  288. package/dist/chat/typed-interrupts/approval-cards.js.map +1 -0
  289. package/dist/chat/typed-interrupts/form-cards.cjs +289 -0
  290. package/dist/chat/typed-interrupts/form-cards.cjs.map +1 -0
  291. package/dist/chat/typed-interrupts/form-cards.d.ts +6 -0
  292. package/dist/chat/typed-interrupts/form-cards.js +289 -0
  293. package/dist/chat/typed-interrupts/form-cards.js.map +1 -0
  294. package/dist/chat/typed-interrupts/interrupt-card-shell.cjs +182 -0
  295. package/dist/chat/typed-interrupts/interrupt-card-shell.cjs.map +1 -0
  296. package/dist/chat/typed-interrupts/interrupt-card-shell.d.ts +47 -0
  297. package/dist/chat/typed-interrupts/interrupt-card-shell.js +182 -0
  298. package/dist/chat/typed-interrupts/interrupt-card-shell.js.map +1 -0
  299. package/dist/chat/typed-interrupts/json-schema-form.cjs +388 -0
  300. package/dist/chat/typed-interrupts/json-schema-form.cjs.map +1 -0
  301. package/dist/chat/typed-interrupts/json-schema-form.d.ts +33 -0
  302. package/dist/chat/typed-interrupts/json-schema-form.js +388 -0
  303. package/dist/chat/typed-interrupts/json-schema-form.js.map +1 -0
  304. package/dist/chat/typed-interrupts/questionnaire-card.cjs +449 -0
  305. package/dist/chat/typed-interrupts/questionnaire-card.cjs.map +1 -0
  306. package/dist/chat/typed-interrupts/questionnaire-card.d.ts +20 -0
  307. package/dist/chat/typed-interrupts/questionnaire-card.js +449 -0
  308. package/dist/chat/typed-interrupts/questionnaire-card.js.map +1 -0
  309. package/dist/chat/typed-interrupts/request-file-card.cjs +159 -0
  310. package/dist/chat/typed-interrupts/request-file-card.cjs.map +1 -0
  311. package/dist/chat/typed-interrupts/request-file-card.d.ts +2 -0
  312. package/dist/chat/typed-interrupts/request-file-card.js +159 -0
  313. package/dist/chat/typed-interrupts/request-file-card.js.map +1 -0
  314. package/dist/chat/typed-interrupts/toolkit-selection-card.cjs +189 -0
  315. package/dist/chat/typed-interrupts/toolkit-selection-card.cjs.map +1 -0
  316. package/dist/chat/typed-interrupts/toolkit-selection-card.d.ts +23 -0
  317. package/dist/chat/typed-interrupts/toolkit-selection-card.js +189 -0
  318. package/dist/chat/typed-interrupts/toolkit-selection-card.js.map +1 -0
  319. package/dist/chat/typed-interrupts/typed-interrupt-body.cjs +26 -0
  320. package/dist/chat/typed-interrupts/typed-interrupt-body.cjs.map +1 -0
  321. package/dist/chat/typed-interrupts/typed-interrupt-body.d.ts +3 -0
  322. package/dist/chat/typed-interrupts/typed-interrupt-body.js +26 -0
  323. package/dist/chat/typed-interrupts/typed-interrupt-body.js.map +1 -0
  324. package/dist/chat/typed-interrupts/typed-interrupt-graphql.cjs +105 -0
  325. package/dist/chat/typed-interrupts/typed-interrupt-graphql.cjs.map +1 -0
  326. package/dist/chat/typed-interrupts/typed-interrupt-graphql.d.ts +29 -0
  327. package/dist/chat/typed-interrupts/typed-interrupt-graphql.js +105 -0
  328. package/dist/chat/typed-interrupts/typed-interrupt-graphql.js.map +1 -0
  329. package/dist/chat/typed-interrupts/typed-interrupt-notice.cjs +70 -0
  330. package/dist/chat/typed-interrupts/typed-interrupt-notice.cjs.map +1 -0
  331. package/dist/chat/typed-interrupts/typed-interrupt-notice.d.ts +45 -0
  332. package/dist/chat/typed-interrupts/typed-interrupt-notice.js +70 -0
  333. package/dist/chat/typed-interrupts/typed-interrupt-notice.js.map +1 -0
  334. package/dist/chat/typed-interrupts/typed-interrupt-panel.cjs +76 -0
  335. package/dist/chat/typed-interrupts/typed-interrupt-panel.cjs.map +1 -0
  336. package/dist/chat/typed-interrupts/typed-interrupt-panel.d.ts +11 -0
  337. package/dist/chat/typed-interrupts/typed-interrupt-panel.js +76 -0
  338. package/dist/chat/typed-interrupts/typed-interrupt-panel.js.map +1 -0
  339. package/dist/chat/typed-interrupts/typed-interrupt-types.d.ts +46 -0
  340. package/dist/chat/typed-interrupts/use-interrupt-draft.cjs +106 -0
  341. package/dist/chat/typed-interrupts/use-interrupt-draft.cjs.map +1 -0
  342. package/dist/chat/typed-interrupts/use-interrupt-draft.d.ts +29 -0
  343. package/dist/chat/typed-interrupts/use-interrupt-draft.js +106 -0
  344. package/dist/chat/typed-interrupts/use-interrupt-draft.js.map +1 -0
  345. package/dist/chat/typed-interrupts/use-statewire-typed-interrupt.cjs +231 -0
  346. package/dist/chat/typed-interrupts/use-statewire-typed-interrupt.cjs.map +1 -0
  347. package/dist/chat/typed-interrupts/use-statewire-typed-interrupt.d.ts +66 -0
  348. package/dist/chat/typed-interrupts/use-statewire-typed-interrupt.js +231 -0
  349. package/dist/chat/typed-interrupts/use-statewire-typed-interrupt.js.map +1 -0
  350. package/dist/chat-ui/composer/composer-named-agents.cjs +13 -0
  351. package/dist/chat-ui/composer/composer-named-agents.cjs.map +1 -0
  352. package/dist/chat-ui/composer/composer-named-agents.d.ts +20 -0
  353. package/dist/chat-ui/composer/composer-named-agents.js +13 -0
  354. package/dist/chat-ui/composer/composer-named-agents.js.map +1 -0
  355. package/dist/chat-ui/composer/slash-command-menu.cjs +143 -0
  356. package/dist/chat-ui/composer/slash-command-menu.cjs.map +1 -0
  357. package/dist/chat-ui/composer/slash-command-menu.d.ts +19 -0
  358. package/dist/chat-ui/composer/slash-command-menu.js +143 -0
  359. package/dist/chat-ui/composer/slash-command-menu.js.map +1 -0
  360. package/dist/chat-ui/composer/slash-commands-extension.cjs +51 -0
  361. package/dist/chat-ui/composer/slash-commands-extension.cjs.map +1 -0
  362. package/dist/chat-ui/composer/slash-commands-extension.d.ts +39 -0
  363. package/dist/chat-ui/composer/slash-commands-extension.js +51 -0
  364. package/dist/chat-ui/composer/slash-commands-extension.js.map +1 -0
  365. package/dist/chat-ui/composer/slash-commands.cjs +74 -0
  366. package/dist/chat-ui/composer/slash-commands.cjs.map +1 -0
  367. package/dist/chat-ui/composer/slash-commands.d.ts +82 -0
  368. package/dist/chat-ui/composer/slash-commands.js +74 -0
  369. package/dist/chat-ui/composer/slash-commands.js.map +1 -0
  370. package/dist/chat-ui/composer/tiptap-composer.cjs +135 -9
  371. package/dist/chat-ui/composer/tiptap-composer.cjs.map +1 -1
  372. package/dist/chat-ui/composer/tiptap-composer.d.ts +61 -2
  373. package/dist/chat-ui/composer/tiptap-composer.js +135 -9
  374. package/dist/chat-ui/composer/tiptap-composer.js.map +1 -1
  375. package/dist/chat-ui/index.cjs +5 -0
  376. package/dist/chat-ui/index.cjs.map +1 -1
  377. package/dist/chat-ui/index.d.ts +4 -2
  378. package/dist/chat-ui/index.js +5 -0
  379. package/dist/chat-ui/index.js.map +1 -1
  380. package/dist/chat-ui/mentions/mention-chip.cjs +10 -4
  381. package/dist/chat-ui/mentions/mention-chip.cjs.map +1 -1
  382. package/dist/chat-ui/mentions/mention-chip.js +11 -5
  383. package/dist/chat-ui/mentions/mention-chip.js.map +1 -1
  384. package/dist/chat-ui/mentions/mention-extension.cjs +8 -1
  385. package/dist/chat-ui/mentions/mention-extension.cjs.map +1 -1
  386. package/dist/chat-ui/mentions/mention-extension.js +8 -1
  387. package/dist/chat-ui/mentions/mention-extension.js.map +1 -1
  388. package/dist/chat-ui/mentions/suggestions/components/get-scope-name.cjs +1 -0
  389. package/dist/chat-ui/mentions/suggestions/components/get-scope-name.cjs.map +1 -1
  390. package/dist/chat-ui/mentions/suggestions/components/get-scope-name.js +1 -0
  391. package/dist/chat-ui/mentions/suggestions/components/get-scope-name.js.map +1 -1
  392. package/dist/chat-ui/mentions/suggestions/components/mention-icon.cjs +20 -2
  393. package/dist/chat-ui/mentions/suggestions/components/mention-icon.cjs.map +1 -1
  394. package/dist/chat-ui/mentions/suggestions/components/mention-icon.d.ts +10 -1
  395. package/dist/chat-ui/mentions/suggestions/components/mention-icon.js +22 -4
  396. package/dist/chat-ui/mentions/suggestions/components/mention-icon.js.map +1 -1
  397. package/dist/chat-ui/mentions/suggestions/components/menu-item.cjs +1 -1
  398. package/dist/chat-ui/mentions/suggestions/components/menu-item.cjs.map +1 -1
  399. package/dist/chat-ui/mentions/suggestions/components/menu-item.js +1 -1
  400. package/dist/chat-ui/mentions/suggestions/components/menu-item.js.map +1 -1
  401. package/dist/chat-ui/mentions/suggestions/data/api-client.cjs +45 -0
  402. package/dist/chat-ui/mentions/suggestions/data/api-client.cjs.map +1 -1
  403. package/dist/chat-ui/mentions/suggestions/data/api-client.d.ts +48 -0
  404. package/dist/chat-ui/mentions/suggestions/data/api-client.js +45 -0
  405. package/dist/chat-ui/mentions/suggestions/data/api-client.js.map +1 -1
  406. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icon-names.generated.cjs +89 -0
  407. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icon-names.generated.cjs.map +1 -0
  408. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icon-names.generated.d.ts +8 -0
  409. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icon-names.generated.js +89 -0
  410. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icon-names.generated.js.map +1 -0
  411. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.cjs +140 -116
  412. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.cjs.map +1 -1
  413. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.d.ts +46 -12
  414. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.js +141 -117
  415. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.js.map +1 -1
  416. package/dist/chat-ui/mentions/suggestions/data/sources/index.cjs +272 -25
  417. package/dist/chat-ui/mentions/suggestions/data/sources/index.cjs.map +1 -1
  418. package/dist/chat-ui/mentions/suggestions/data/sources/index.d.ts +88 -10
  419. package/dist/chat-ui/mentions/suggestions/data/sources/index.js +274 -27
  420. package/dist/chat-ui/mentions/suggestions/data/sources/index.js.map +1 -1
  421. package/dist/chat-ui/mentions/suggestions/data/types.cjs.map +1 -1
  422. package/dist/chat-ui/mentions/suggestions/data/types.d.ts +27 -1
  423. package/dist/chat-ui/mentions/suggestions/data/types.js.map +1 -1
  424. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.cjs +56 -5
  425. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.cjs.map +1 -1
  426. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.d.ts +26 -6
  427. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.js +57 -6
  428. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.js.map +1 -1
  429. package/dist/chat-ui/mentions/suggestions/mention-suggestions.extension.cjs +34 -17
  430. package/dist/chat-ui/mentions/suggestions/mention-suggestions.extension.cjs.map +1 -1
  431. package/dist/chat-ui/mentions/suggestions/mention-suggestions.extension.d.ts +19 -1
  432. package/dist/chat-ui/mentions/suggestions/mention-suggestions.extension.js +35 -18
  433. package/dist/chat-ui/mentions/suggestions/mention-suggestions.extension.js.map +1 -1
  434. package/dist/chat-ui/mentions/use-asset-icon-app-url.cjs +12 -0
  435. package/dist/chat-ui/mentions/use-asset-icon-app-url.cjs.map +1 -0
  436. package/dist/chat-ui/mentions/use-asset-icon-app-url.d.ts +8 -0
  437. package/dist/chat-ui/mentions/use-asset-icon-app-url.js +12 -0
  438. package/dist/chat-ui/mentions/use-asset-icon-app-url.js.map +1 -0
  439. package/dist/chat-ui/statewire.d.ts +1 -1
  440. package/dist/chat-ui/thread/statewire-history-edge.cjs +15 -0
  441. package/dist/chat-ui/thread/statewire-history-edge.cjs.map +1 -1
  442. package/dist/chat-ui/thread/statewire-history-edge.d.ts +4 -1
  443. package/dist/chat-ui/thread/statewire-history-edge.js +15 -0
  444. package/dist/chat-ui/thread/statewire-history-edge.js.map +1 -1
  445. package/dist/collab/client.cjs +41 -6
  446. package/dist/collab/client.cjs.map +1 -1
  447. package/dist/collab/client.d.ts +38 -7
  448. package/dist/collab/client.js +41 -6
  449. package/dist/collab/client.js.map +1 -1
  450. package/dist/composer/ComposerAttachedReferences.cjs +119 -0
  451. package/dist/composer/ComposerAttachedReferences.cjs.map +1 -0
  452. package/dist/composer/ComposerAttachedReferences.d.ts +26 -0
  453. package/dist/composer/ComposerAttachedReferences.js +119 -0
  454. package/dist/composer/ComposerAttachedReferences.js.map +1 -0
  455. package/dist/composer/ComposerNamedAgents.cjs +63 -0
  456. package/dist/composer/ComposerNamedAgents.cjs.map +1 -0
  457. package/dist/composer/ComposerNamedAgents.d.ts +16 -0
  458. package/dist/composer/ComposerNamedAgents.js +63 -0
  459. package/dist/composer/ComposerNamedAgents.js.map +1 -0
  460. package/dist/composer/attached-references.cjs +159 -0
  461. package/dist/composer/attached-references.cjs.map +1 -0
  462. package/dist/composer/attached-references.d.ts +86 -0
  463. package/dist/composer/attached-references.js +159 -0
  464. package/dist/composer/attached-references.js.map +1 -0
  465. package/dist/composer/build-composed-message.cjs +14 -7
  466. package/dist/composer/build-composed-message.cjs.map +1 -1
  467. package/dist/composer/build-composed-message.d.ts +6 -1
  468. package/dist/composer/build-composed-message.js +14 -7
  469. package/dist/composer/build-composed-message.js.map +1 -1
  470. package/dist/composer/composer-handoff.cjs +6 -2
  471. package/dist/composer/composer-handoff.cjs.map +1 -1
  472. package/dist/composer/composer-handoff.d.ts +7 -1
  473. package/dist/composer/composer-handoff.js +6 -2
  474. package/dist/composer/composer-handoff.js.map +1 -1
  475. package/dist/composer/folder-upload.cjs +149 -0
  476. package/dist/composer/folder-upload.cjs.map +1 -0
  477. package/dist/composer/folder-upload.d.ts +79 -0
  478. package/dist/composer/folder-upload.js +149 -0
  479. package/dist/composer/folder-upload.js.map +1 -0
  480. package/dist/composer/index.d.ts +1 -1
  481. package/dist/composer/staged-message-metadata.cjs +12 -0
  482. package/dist/composer/staged-message-metadata.cjs.map +1 -0
  483. package/dist/composer/staged-message-metadata.d.ts +15 -0
  484. package/dist/composer/staged-message-metadata.js +12 -0
  485. package/dist/composer/staged-message-metadata.js.map +1 -0
  486. package/dist/composer/useAttachToChat.cjs +35 -0
  487. package/dist/composer/useAttachToChat.cjs.map +1 -0
  488. package/dist/composer/useAttachToChat.d.ts +54 -0
  489. package/dist/composer/useAttachToChat.js +35 -0
  490. package/dist/composer/useAttachToChat.js.map +1 -0
  491. package/dist/composer/useAttachedReferencesComposerProps.cjs +19 -0
  492. package/dist/composer/useAttachedReferencesComposerProps.cjs.map +1 -0
  493. package/dist/composer/useAttachedReferencesComposerProps.d.ts +12 -0
  494. package/dist/composer/useAttachedReferencesComposerProps.js +19 -0
  495. package/dist/composer/useAttachedReferencesComposerProps.js.map +1 -0
  496. package/dist/composer/useFileUpload.cjs +95 -7
  497. package/dist/composer/useFileUpload.cjs.map +1 -1
  498. package/dist/composer/useFileUpload.d.ts +21 -2
  499. package/dist/composer/useFileUpload.js +95 -7
  500. package/dist/composer/useFileUpload.js.map +1 -1
  501. package/dist/data/athena-api-error.cjs +125 -0
  502. package/dist/data/athena-api-error.cjs.map +1 -0
  503. package/dist/data/athena-api-error.d.ts +96 -0
  504. package/dist/data/athena-api-error.js +125 -0
  505. package/dist/data/athena-api-error.js.map +1 -0
  506. package/dist/data/athena-data-client.cjs +106 -0
  507. package/dist/data/athena-data-client.cjs.map +1 -0
  508. package/dist/data/athena-data-client.d.ts +74 -0
  509. package/dist/data/athena-data-client.js +106 -0
  510. package/dist/data/athena-data-client.js.map +1 -0
  511. package/dist/data/athena-member.cjs +93 -0
  512. package/dist/data/athena-member.cjs.map +1 -0
  513. package/dist/data/athena-member.d.ts +125 -0
  514. package/dist/data/athena-member.js +93 -0
  515. package/dist/data/athena-member.js.map +1 -0
  516. package/dist/data/athena-request.cjs +460 -0
  517. package/dist/data/athena-request.cjs.map +1 -0
  518. package/dist/data/athena-request.d.ts +120 -0
  519. package/dist/data/athena-request.js +460 -0
  520. package/dist/data/athena-request.js.map +1 -0
  521. package/dist/data/use-athena-fetch.cjs +14 -0
  522. package/dist/data/use-athena-fetch.cjs.map +1 -0
  523. package/dist/data/use-athena-fetch.d.ts +19 -0
  524. package/dist/data/use-athena-fetch.js +14 -0
  525. package/dist/data/use-athena-fetch.js.map +1 -0
  526. package/dist/data/use-athena-graphql.cjs +66 -0
  527. package/dist/data/use-athena-graphql.cjs.map +1 -0
  528. package/dist/data/use-athena-graphql.d.ts +56 -0
  529. package/dist/data/use-athena-graphql.js +66 -0
  530. package/dist/data/use-athena-graphql.js.map +1 -0
  531. package/dist/data/use-athena-rest.cjs +33 -0
  532. package/dist/data/use-athena-rest.cjs.map +1 -0
  533. package/dist/data/use-athena-rest.d.ts +21 -0
  534. package/dist/data/use-athena-rest.js +33 -0
  535. package/dist/data/use-athena-rest.js.map +1 -0
  536. package/dist/data/use-semantic-query.cjs +44 -0
  537. package/dist/data/use-semantic-query.cjs.map +1 -0
  538. package/dist/data/use-semantic-query.d.ts +92 -0
  539. package/dist/data/use-semantic-query.js +44 -0
  540. package/dist/data/use-semantic-query.js.map +1 -0
  541. package/dist/diagnostics/athena-diagnostics.cjs.map +1 -1
  542. package/dist/diagnostics/athena-diagnostics.d.ts +5 -1
  543. package/dist/diagnostics/athena-diagnostics.js.map +1 -1
  544. package/dist/diagnostics/errors.cjs +7 -0
  545. package/dist/diagnostics/errors.cjs.map +1 -1
  546. package/dist/diagnostics/errors.d.ts +7 -0
  547. package/dist/diagnostics/errors.js +7 -0
  548. package/dist/diagnostics/errors.js.map +1 -1
  549. package/dist/index.cjs +155 -11
  550. package/dist/index.cjs.map +1 -1
  551. package/dist/index.d.ts +72 -13
  552. package/dist/index.js +148 -4
  553. package/dist/index.js.map +1 -1
  554. package/dist/keryx-http/src/initial-sync.cjs +64 -16
  555. package/dist/keryx-http/src/initial-sync.cjs.map +1 -1
  556. package/dist/keryx-http/src/initial-sync.d.ts +31 -1
  557. package/dist/keryx-http/src/initial-sync.js +64 -16
  558. package/dist/keryx-http/src/initial-sync.js.map +1 -1
  559. package/dist/keryx-http/src/own-awareness.cjs +20 -0
  560. package/dist/keryx-http/src/own-awareness.cjs.map +1 -0
  561. package/dist/keryx-http/src/own-awareness.d.ts +50 -0
  562. package/dist/keryx-http/src/own-awareness.js +20 -0
  563. package/dist/keryx-http/src/own-awareness.js.map +1 -0
  564. package/dist/keryx-http/src/update-attributions.cjs +26 -1
  565. package/dist/keryx-http/src/update-attributions.cjs.map +1 -1
  566. package/dist/keryx-http/src/update-attributions.d.ts +10 -1
  567. package/dist/keryx-http/src/update-attributions.js +26 -1
  568. package/dist/keryx-http/src/update-attributions.js.map +1 -1
  569. package/dist/offline/chat-outbox.cjs +262 -26
  570. package/dist/offline/chat-outbox.cjs.map +1 -1
  571. package/dist/offline/chat-outbox.d.ts +90 -12
  572. package/dist/offline/chat-outbox.js +263 -27
  573. package/dist/offline/chat-outbox.js.map +1 -1
  574. package/dist/provider/AthenaProvider.cjs +60 -22
  575. package/dist/provider/AthenaProvider.cjs.map +1 -1
  576. package/dist/provider/AthenaProvider.d.ts +24 -8
  577. package/dist/provider/AthenaProvider.js +61 -23
  578. package/dist/provider/AthenaProvider.js.map +1 -1
  579. package/dist/react/package.json.cjs +1 -1
  580. package/dist/react/package.json.js +1 -1
  581. package/dist/references/src/anchors/parse.cjs +11 -1
  582. package/dist/references/src/anchors/parse.cjs.map +1 -1
  583. package/dist/references/src/anchors/parse.js +11 -1
  584. package/dist/references/src/anchors/parse.js.map +1 -1
  585. package/dist/references/src/anchors/schemas.d.ts +1 -0
  586. package/dist/references/src/anchors/serialize.cjs +1 -0
  587. package/dist/references/src/anchors/serialize.cjs.map +1 -1
  588. package/dist/references/src/anchors/serialize.js +1 -0
  589. package/dist/references/src/anchors/serialize.js.map +1 -1
  590. package/dist/references/src/anchors/types.cjs +5 -0
  591. package/dist/references/src/anchors/types.cjs.map +1 -1
  592. package/dist/references/src/anchors/types.d.ts +9 -0
  593. package/dist/references/src/anchors/types.js +5 -0
  594. package/dist/references/src/anchors/types.js.map +1 -1
  595. package/dist/references/src/attachable.cjs +149 -0
  596. package/dist/references/src/attachable.cjs.map +1 -0
  597. package/dist/references/src/attachable.d.ts +87 -0
  598. package/dist/references/src/attachable.js +149 -0
  599. package/dist/references/src/attachable.js.map +1 -0
  600. package/dist/references/src/schemas.d.ts +2 -0
  601. package/dist/runtime/StatewirePlanModeLaneSync.cjs +93 -0
  602. package/dist/runtime/StatewirePlanModeLaneSync.cjs.map +1 -0
  603. package/dist/runtime/StatewirePlanModeLaneSync.d.ts +34 -0
  604. package/dist/runtime/StatewirePlanModeLaneSync.js +93 -0
  605. package/dist/runtime/StatewirePlanModeLaneSync.js.map +1 -0
  606. package/dist/runtime/StatewireThreadConfigLaneSync.cjs +2 -0
  607. package/dist/runtime/StatewireThreadConfigLaneSync.cjs.map +1 -1
  608. package/dist/runtime/StatewireThreadConfigLaneSync.d.ts +4 -0
  609. package/dist/runtime/StatewireThreadConfigLaneSync.js +2 -0
  610. package/dist/runtime/StatewireThreadConfigLaneSync.js.map +1 -1
  611. package/dist/runtime/statewire-plan-mode.cjs +71 -0
  612. package/dist/runtime/statewire-plan-mode.cjs.map +1 -0
  613. package/dist/runtime/statewire-plan-mode.d.ts +88 -0
  614. package/dist/runtime/statewire-plan-mode.js +71 -0
  615. package/dist/runtime/statewire-plan-mode.js.map +1 -0
  616. package/dist/runtime/statewire-run-config.cjs +3 -1
  617. package/dist/runtime/statewire-run-config.cjs.map +1 -1
  618. package/dist/runtime/statewire-run-config.d.ts +7 -0
  619. package/dist/runtime/statewire-run-config.js +3 -1
  620. package/dist/runtime/statewire-run-config.js.map +1 -1
  621. package/dist/runtime/statewire-session-key.cjs +11 -5
  622. package/dist/runtime/statewire-session-key.cjs.map +1 -1
  623. package/dist/runtime/statewire-session-key.d.ts +22 -10
  624. package/dist/runtime/statewire-session-key.js +11 -5
  625. package/dist/runtime/statewire-session-key.js.map +1 -1
  626. package/dist/runtime/useAthenaStatewireRuntime.cjs +64 -9
  627. package/dist/runtime/useAthenaStatewireRuntime.cjs.map +1 -1
  628. package/dist/runtime/useAthenaStatewireRuntime.d.ts +26 -10
  629. package/dist/runtime/useAthenaStatewireRuntime.js +66 -11
  630. package/dist/runtime/useAthenaStatewireRuntime.js.map +1 -1
  631. package/dist/search/useAthenaAssets.cjs +394 -0
  632. package/dist/search/useAthenaAssets.cjs.map +1 -0
  633. package/dist/search/useAthenaAssets.d.ts +186 -0
  634. package/dist/search/useAthenaAssets.js +394 -0
  635. package/dist/search/useAthenaAssets.js.map +1 -0
  636. package/dist/sheet-range/index.cjs +4 -0
  637. package/dist/sheet-range/index.cjs.map +1 -1
  638. package/dist/sheet-range/index.d.ts +4 -2
  639. package/dist/sheet-range/index.js +4 -0
  640. package/dist/sheet-range/index.js.map +1 -1
  641. package/dist/sheet-range/query-range.cjs +102 -0
  642. package/dist/sheet-range/query-range.cjs.map +1 -0
  643. package/dist/sheet-range/query-range.d.ts +46 -0
  644. package/dist/sheet-range/query-range.js +102 -0
  645. package/dist/sheet-range/query-range.js.map +1 -0
  646. package/dist/styles.css +1 -1
  647. package/dist/subagents/index.cjs +49 -0
  648. package/dist/subagents/index.cjs.map +1 -0
  649. package/dist/subagents/index.d.ts +16 -0
  650. package/dist/subagents/index.js +49 -0
  651. package/dist/subagents/index.js.map +1 -0
  652. package/dist/subagents/lane-follow.cjs +19 -0
  653. package/dist/subagents/lane-follow.cjs.map +1 -0
  654. package/dist/subagents/lane-follow.d.ts +9 -0
  655. package/dist/subagents/lane-follow.js +19 -0
  656. package/dist/subagents/lane-follow.js.map +1 -0
  657. package/dist/subagents/lane-model.cjs +178 -0
  658. package/dist/subagents/lane-model.cjs.map +1 -0
  659. package/dist/subagents/lane-model.d.ts +140 -0
  660. package/dist/subagents/lane-model.js +178 -0
  661. package/dist/subagents/lane-model.js.map +1 -0
  662. package/dist/subagents/lane-parts.cjs +517 -0
  663. package/dist/subagents/lane-parts.cjs.map +1 -0
  664. package/dist/subagents/lane-parts.d.ts +130 -0
  665. package/dist/subagents/lane-parts.js +517 -0
  666. package/dist/subagents/lane-parts.js.map +1 -0
  667. package/dist/subagents/subagent-lane-group.cjs +215 -0
  668. package/dist/subagents/subagent-lane-group.cjs.map +1 -0
  669. package/dist/subagents/subagent-lane-group.d.ts +67 -0
  670. package/dist/subagents/subagent-lane-group.js +215 -0
  671. package/dist/subagents/subagent-lane-group.js.map +1 -0
  672. package/dist/subagents/subagent-transcript-drawer.cjs +431 -0
  673. package/dist/subagents/subagent-transcript-drawer.cjs.map +1 -0
  674. package/dist/subagents/subagent-transcript-drawer.d.ts +78 -0
  675. package/dist/subagents/subagent-transcript-drawer.js +431 -0
  676. package/dist/subagents/subagent-transcript-drawer.js.map +1 -0
  677. package/dist/subagents/task-subagent-group.cjs +115 -0
  678. package/dist/subagents/task-subagent-group.cjs.map +1 -0
  679. package/dist/subagents/task-subagent-group.d.ts +36 -0
  680. package/dist/subagents/task-subagent-group.js +115 -0
  681. package/dist/subagents/task-subagent-group.js.map +1 -0
  682. package/dist/subagents/use-omitted-images-in-view.cjs +68 -0
  683. package/dist/subagents/use-omitted-images-in-view.cjs.map +1 -0
  684. package/dist/subagents/use-omitted-images-in-view.d.ts +21 -0
  685. package/dist/subagents/use-omitted-images-in-view.js +68 -0
  686. package/dist/subagents/use-omitted-images-in-view.js.map +1 -0
  687. package/dist/threads/Inbox.cjs +2 -2
  688. package/dist/threads/Inbox.cjs.map +1 -1
  689. package/dist/threads/SessionList.cjs +6 -6
  690. package/dist/threads/SessionList.cjs.map +1 -1
  691. package/dist/threads/SessionsPage.cjs +13 -7
  692. package/dist/threads/SessionsPage.cjs.map +1 -1
  693. package/dist/threads/SessionsPage.d.ts +10 -1
  694. package/dist/threads/SessionsPage.js +9 -3
  695. package/dist/threads/SessionsPage.js.map +1 -1
  696. package/dist/threads/session-list-model.cjs.map +1 -1
  697. package/dist/threads/session-list-model.d.ts +2 -1
  698. package/dist/threads/session-list-model.js.map +1 -1
  699. package/dist/threads/session-row-parts.cjs +3 -3
  700. package/dist/threads/session-row-parts.cjs.map +1 -1
  701. package/dist/threads/sessions-page-model.cjs +13 -5
  702. package/dist/threads/sessions-page-model.cjs.map +1 -1
  703. package/dist/threads/sessions-page-model.d.ts +7 -0
  704. package/dist/threads/sessions-page-model.js +11 -3
  705. package/dist/threads/sessions-page-model.js.map +1 -1
  706. package/dist/threads/sessions-page-storage.cjs +8 -8
  707. package/dist/threads/sessions-page-storage.cjs.map +1 -1
  708. package/dist/threads/sessions-page-storage.d.ts +5 -1
  709. package/dist/threads/sessions-page-storage.js +8 -8
  710. package/dist/threads/sessions-page-storage.js.map +1 -1
  711. package/dist/threads/statewire-thread-list.cjs +14 -2
  712. package/dist/threads/statewire-thread-list.cjs.map +1 -1
  713. package/dist/threads/statewire-thread-list.d.ts +11 -2
  714. package/dist/threads/statewire-thread-list.js +14 -2
  715. package/dist/threads/statewire-thread-list.js.map +1 -1
  716. package/dist/threads/use-athena-sessions.cjs +1 -0
  717. package/dist/threads/use-athena-sessions.cjs.map +1 -1
  718. package/dist/threads/use-athena-sessions.d.ts +7 -0
  719. package/dist/threads/use-athena-sessions.js +1 -0
  720. package/dist/threads/use-athena-sessions.js.map +1 -1
  721. package/dist/threads/use-athena-thread-agent.cjs +31 -0
  722. package/dist/threads/use-athena-thread-agent.cjs.map +1 -0
  723. package/dist/threads/use-athena-thread-agent.d.ts +38 -0
  724. package/dist/threads/use-athena-thread-agent.js +31 -0
  725. package/dist/threads/use-athena-thread-agent.js.map +1 -0
  726. package/dist/threads/use-athena-thread-plan-mode.cjs +18 -0
  727. package/dist/threads/use-athena-thread-plan-mode.cjs.map +1 -0
  728. package/dist/threads/use-athena-thread-plan-mode.d.ts +18 -0
  729. package/dist/threads/use-athena-thread-plan-mode.js +18 -0
  730. package/dist/threads/use-athena-thread-plan-mode.js.map +1 -0
  731. package/dist/threads/use-rest-conversation-history.d.ts +1 -0
  732. package/dist/tools/agent-creations.cjs +97 -0
  733. package/dist/tools/agent-creations.cjs.map +1 -0
  734. package/dist/tools/agent-creations.d.ts +38 -0
  735. package/dist/tools/agent-creations.js +97 -0
  736. package/dist/tools/agent-creations.js.map +1 -0
  737. package/dist/tools/agent-highlights.cjs +100 -0
  738. package/dist/tools/agent-highlights.cjs.map +1 -0
  739. package/dist/tools/agent-highlights.d.ts +57 -0
  740. package/dist/tools/agent-highlights.js +100 -0
  741. package/dist/tools/agent-highlights.js.map +1 -0
  742. package/dist/tools/append-document-tool-ui.cjs +1 -0
  743. package/dist/tools/append-document-tool-ui.cjs.map +1 -1
  744. package/dist/tools/append-document-tool-ui.d.ts +7 -0
  745. package/dist/tools/append-document-tool-ui.js +2 -1
  746. package/dist/tools/append-document-tool-ui.js.map +1 -1
  747. package/dist/tools/auto-open-tools.cjs +144 -71
  748. package/dist/tools/auto-open-tools.cjs.map +1 -1
  749. package/dist/tools/auto-open-tools.d.ts +131 -1
  750. package/dist/tools/auto-open-tools.js +145 -72
  751. package/dist/tools/auto-open-tools.js.map +1 -1
  752. package/dist/tools/browser-tool-uis.cjs +594 -0
  753. package/dist/tools/browser-tool-uis.cjs.map +1 -0
  754. package/dist/tools/browser-tool-uis.d.ts +8 -0
  755. package/dist/tools/browser-tool-uis.js +594 -0
  756. package/dist/tools/browser-tool-uis.js.map +1 -0
  757. package/dist/tools/computer-asset-tool-uis.cjs +313 -0
  758. package/dist/tools/computer-asset-tool-uis.cjs.map +1 -0
  759. package/dist/tools/computer-asset-tool-uis.d.ts +5 -0
  760. package/dist/tools/computer-asset-tool-uis.js +313 -0
  761. package/dist/tools/computer-asset-tool-uis.js.map +1 -0
  762. package/dist/tools/document-edit-tool-uis.cjs +218 -0
  763. package/dist/tools/document-edit-tool-uis.cjs.map +1 -0
  764. package/dist/tools/document-edit-tool-uis.d.ts +40 -0
  765. package/dist/tools/document-edit-tool-uis.js +218 -0
  766. package/dist/tools/document-edit-tool-uis.js.map +1 -0
  767. package/dist/tools/drive-tool-uis.cjs +429 -0
  768. package/dist/tools/drive-tool-uis.cjs.map +1 -0
  769. package/dist/tools/drive-tool-uis.d.ts +121 -0
  770. package/dist/tools/drive-tool-uis.js +429 -0
  771. package/dist/tools/drive-tool-uis.js.map +1 -0
  772. package/dist/tools/email-calendar-tool-uis.cjs +789 -0
  773. package/dist/tools/email-calendar-tool-uis.cjs.map +1 -0
  774. package/dist/tools/email-calendar-tool-uis.d.ts +129 -0
  775. package/dist/tools/email-calendar-tool-uis.js +789 -0
  776. package/dist/tools/email-calendar-tool-uis.js.map +1 -0
  777. package/dist/tools/ontology-tool-uis.cjs +83 -0
  778. package/dist/tools/ontology-tool-uis.cjs.map +1 -0
  779. package/dist/tools/ontology-tool-uis.d.ts +9 -0
  780. package/dist/tools/ontology-tool-uis.js +83 -0
  781. package/dist/tools/ontology-tool-uis.js.map +1 -0
  782. package/dist/tools/orchestration-tool-uis.cjs +586 -0
  783. package/dist/tools/orchestration-tool-uis.cjs.map +1 -0
  784. package/dist/tools/orchestration-tool-uis.d.ts +141 -0
  785. package/dist/tools/orchestration-tool-uis.js +586 -0
  786. package/dist/tools/orchestration-tool-uis.js.map +1 -0
  787. package/dist/tools/presentation-edit-tool-uis.cjs +516 -0
  788. package/dist/tools/presentation-edit-tool-uis.cjs.map +1 -0
  789. package/dist/tools/presentation-edit-tool-uis.d.ts +73 -0
  790. package/dist/tools/presentation-edit-tool-uis.js +516 -0
  791. package/dist/tools/presentation-edit-tool-uis.js.map +1 -0
  792. package/dist/tools/project-tool-uis.cjs +213 -0
  793. package/dist/tools/project-tool-uis.cjs.map +1 -0
  794. package/dist/tools/project-tool-uis.d.ts +14 -0
  795. package/dist/tools/project-tool-uis.js +213 -0
  796. package/dist/tools/project-tool-uis.js.map +1 -0
  797. package/dist/tools/sandbox-tool-uis.cjs +491 -0
  798. package/dist/tools/sandbox-tool-uis.cjs.map +1 -0
  799. package/dist/tools/sandbox-tool-uis.d.ts +116 -0
  800. package/dist/tools/sandbox-tool-uis.js +491 -0
  801. package/dist/tools/sandbox-tool-uis.js.map +1 -0
  802. package/dist/tools/sheet-query-tool-ui.cjs +138 -0
  803. package/dist/tools/sheet-query-tool-ui.cjs.map +1 -0
  804. package/dist/tools/sheet-query-tool-ui.d.ts +15 -0
  805. package/dist/tools/sheet-query-tool-ui.js +138 -0
  806. package/dist/tools/sheet-query-tool-ui.js.map +1 -0
  807. package/dist/tools/studio-screenshot-tool-uis.cjs +262 -0
  808. package/dist/tools/studio-screenshot-tool-uis.cjs.map +1 -0
  809. package/dist/tools/studio-screenshot-tool-uis.d.ts +52 -0
  810. package/dist/tools/studio-screenshot-tool-uis.js +262 -0
  811. package/dist/tools/studio-screenshot-tool-uis.js.map +1 -0
  812. package/dist/tools/subagent-task-tool-ui.cjs +24 -475
  813. package/dist/tools/subagent-task-tool-ui.cjs.map +1 -1
  814. package/dist/tools/subagent-task-tool-ui.d.ts +19 -103
  815. package/dist/tools/subagent-task-tool-ui.js +28 -479
  816. package/dist/tools/subagent-task-tool-ui.js.map +1 -1
  817. package/dist/tools/tool-summary.cjs +36 -0
  818. package/dist/tools/tool-summary.cjs.map +1 -1
  819. package/dist/tools/tool-summary.js +36 -0
  820. package/dist/tools/tool-summary.js.map +1 -1
  821. package/dist/tools/tool-uis.cjs +181 -53
  822. package/dist/tools/tool-uis.cjs.map +1 -1
  823. package/dist/tools/tool-uis.d.ts +40 -0
  824. package/dist/tools/tool-uis.js +183 -55
  825. package/dist/tools/tool-uis.js.map +1 -1
  826. package/dist/typed-interrupts/index.cjs +15 -0
  827. package/dist/typed-interrupts/index.cjs.map +1 -0
  828. package/dist/typed-interrupts/index.d.ts +20 -0
  829. package/dist/typed-interrupts/index.js +15 -0
  830. package/dist/typed-interrupts/index.js.map +1 -0
  831. package/dist/version.cjs +4 -0
  832. package/dist/version.cjs.map +1 -1
  833. package/dist/version.d.ts +9 -0
  834. package/dist/version.js +4 -0
  835. package/dist/version.js.map +1 -1
  836. package/dist/workbench/live-desktop-api.cjs +2 -1
  837. package/dist/workbench/live-desktop-api.cjs.map +1 -1
  838. package/dist/workbench/live-desktop-api.js +2 -1
  839. package/dist/workbench/live-desktop-api.js.map +1 -1
  840. package/dist/workbench/session-workbench-panes.cjs +6 -6
  841. package/dist/workbench/session-workbench-panes.cjs.map +1 -1
  842. package/dist/workbench/session-workspace-api.cjs +7 -2
  843. package/dist/workbench/session-workspace-api.cjs.map +1 -1
  844. package/dist/workbench/session-workspace-api.d.ts +10 -0
  845. package/dist/workbench/session-workspace-api.js +7 -2
  846. package/dist/workbench/session-workspace-api.js.map +1 -1
  847. package/package.json +28 -6
  848. package/dist/agent-runtime/src/chat-outbox-store.cjs +0 -510
  849. package/dist/agent-runtime/src/chat-outbox-store.cjs.map +0 -1
  850. package/dist/agent-runtime/src/chat-outbox-store.d.ts +0 -210
  851. package/dist/agent-runtime/src/chat-outbox-store.js +0 -510
  852. package/dist/agent-runtime/src/chat-outbox-store.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attached-references.cjs","sources":["../../src/composer/attached-references.ts"],"sourcesContent":["import {\n type AttachableReference,\n attachableReferenceKey,\n MAX_ATTACHED_REFERENCES,\n normalizeAttachableReference,\n readAttachedReferences as readMessageAttachedReferences,\n withAttachedReferences,\n} from '@athenaintel/references/attachable';\nimport { useCallback, useSyncExternalStore } from 'react';\n\n/**\n * What each conversation's next message carries as attached references (`useAttachToChat`), and\n * the hand-off of that list to the message that leaves.\n *\n * - **The pending list.** Per thread, in the order attached, each reference once (by kind and\n * pointer, an asset's anchor included), at most {@link MAX_ATTACHED_REFERENCES}. The composer\n * shows it as removable chips (`ComposerAttachedReferences`). It is kept in memory for the page\n * and dropped when the signed-in identity changes ({@link keepAttachedReferencesForIdentity}):\n * what one person attached is never sent as someone else's.\n * - **The send.** statewire captures a new message's metadata once, as it journals it\n * (`getMessageMetadata`), without saying which message it is for. So the composer stages the\n * list right before `aui.composer.send` ({@link stageAttachedReferencesForSend}) and the runtime's\n * getter takes it for the message that follows ({@link withStagedAttachedReferences}).\n * The references then ride the message's own metadata (`attachedReferences`), never its text, so\n * a send that waits, is retried or is posted again after a reload keeps its own attachments. A\n * slot nobody takes expires. Both send paths stage them ({@link stageThreadAttachedReferencesForSend}):\n * `AthenaChat`'s composed send, and `TiptapComposer`'s own through its host's `prepareSend`\n * (`useAttachedReferencesComposerProps`). A composer whose host doesn't opt in sends none and\n * never loads this module (the Office pane's budget counts on it).\n * - **The way back.** Sending takes the chips off the composer, and they come back with the send:\n * a send statewire refuses and hands back ({@link restoreSentAttachedReferences}, by its text),\n * or a message held in the chat outbox that is cancelled or edited\n * ({@link giveBackHeldAttachedReferences}, from its metadata).\n *\n * agora reads the list off the message, refuses whatever it can't read, and resolves each one with\n * the person's own permission before the agent is told about it; the client never gates.\n */\n\nconst EMPTY: readonly AttachableReference[] = Object.freeze([]);\n\n// process-local: client-only — the references each thread's composer sends with its next message.\nconst pending = new Map<string, readonly AttachableReference[]>();\nconst listeners = new Set<() => void>();\nlet attachedForIdentity: string | null = null;\n\nfunction notify(): void {\n for (const listener of [...listeners]) listener();\n}\n\nfunction subscribe(listener: () => void): () => void {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n}\n\nfunction setPending(threadId: string, references: readonly AttachableReference[]): void {\n if (references.length === 0) pending.delete(threadId);\n else pending.set(threadId, Object.freeze([...references]));\n notify();\n}\n\n/** Why a reference was not attached. */\nexport type AttachRefusalReason =\n /** Not a reference an app may attach (an unknown kind, a malformed id, URL or anchor). */\n | 'invalid_reference'\n /** The next message already carries {@link MAX_ATTACHED_REFERENCES}. */\n | 'too_many'\n /** No conversation to attach it to (outside `<AthenaProvider>`'s chat). */\n | 'no_thread';\n\n/** What `attach` did. */\nexport type AttachReferenceResult =\n | {\n attached: true;\n /** The reference as it will be sent (normalized: unknown fields dropped, label cut). */\n reference: AttachableReference;\n /** It was attached already; its label is updated and it keeps its place. */\n duplicate: boolean;\n }\n | { attached: false; reason: AttachRefusalReason };\n\n/** Attach `reference` to `threadId`'s next message. */\nexport function attachReferenceToThread({\n threadId,\n reference,\n}: {\n threadId: string | null;\n reference: unknown;\n}): AttachReferenceResult {\n if (!threadId) return { attached: false, reason: 'no_thread' };\n const normalized = normalizeAttachableReference(reference);\n if (normalized === null) return { attached: false, reason: 'invalid_reference' };\n const key = attachableReferenceKey(normalized);\n const current = pending.get(threadId) ?? EMPTY;\n const index = current.findIndex((entry) => attachableReferenceKey(entry) === key);\n if (index >= 0) {\n setPending(\n threadId,\n current.map((entry, position) => (position === index ? normalized : entry)),\n );\n return { attached: true, reference: normalized, duplicate: true };\n }\n if (current.length >= MAX_ATTACHED_REFERENCES) return { attached: false, reason: 'too_many' };\n setPending(threadId, [...current, normalized]);\n return { attached: true, reference: normalized, duplicate: false };\n}\n\n/** Take `reference` (matched by kind and pointer) off `threadId`'s next message. */\nexport function detachReferenceFromThread({\n threadId,\n reference,\n}: {\n threadId: string | null;\n reference: AttachableReference;\n}): void {\n if (!threadId) return;\n const current = pending.get(threadId);\n if (!current) return;\n const key = attachableReferenceKey(reference);\n const kept = current.filter((entry) => attachableReferenceKey(entry) !== key);\n if (kept.length !== current.length) setPending(threadId, kept);\n}\n\n/** Take every reference off `threadId`'s next message. */\nexport function clearAttachedReferences(threadId: string | null): void {\n if (!threadId || !pending.has(threadId)) return;\n setPending(threadId, EMPTY);\n}\n\n/** The references `threadId`'s next message carries, in the order attached. */\nexport function readPendingAttachedReferences(threadId: string | null): readonly AttachableReference[] {\n return (threadId ? pending.get(threadId) : undefined) ?? EMPTY;\n}\n\n/** {@link readPendingAttachedReferences}, re-rendering when the list changes. */\nexport function usePendingAttachedReferences(threadId: string | null): readonly AttachableReference[] {\n const read = useCallback(() => readPendingAttachedReferences(threadId), [threadId]);\n return useSyncExternalStore(subscribe, read, read);\n}\n\n/** Forget every pending, staged and sent reference (tests, and a change of identity). */\nexport function forgetAllAttachedReferences(): void {\n pending.clear();\n stagedForSend.clear();\n sentWithText.clear();\n notify();\n}\n\n/**\n * Keep the pending references only while `identity` (the signed-in person) stays the same: a\n * change forgets every one, so nothing attached under one identity is sent under another.\n */\nexport function keepAttachedReferencesForIdentity(identity: string): void {\n if (attachedForIdentity !== null && attachedForIdentity !== identity) {\n forgetAllAttachedReferences();\n }\n attachedForIdentity = identity;\n}\n\n// ── The send ────────────────────────────────────────────────────────────────\n\n/** How long staged references wait for the message they were staged for before they expire. */\nexport const ATTACHED_REFERENCES_STAGED_TTL_MS = 10_000;\n\n// process-local: client-only — the references each thread's composer staged for the message it\n// submits next, taken once by the runtime's `getMessageMetadata`.\nconst stagedForSend = new Map<\n string,\n { references: readonly AttachableReference[]; stagedAt: number }\n>();\n\n/**\n * Stage `references` for the message `threadId`'s composer submits next. Call right before the send\n * (`aui.composer.send`). A send attaching nothing stages nothing and lets an earlier slot go.\n */\nexport function stageAttachedReferencesForSend({\n threadId,\n references,\n}: {\n threadId: string;\n references: readonly AttachableReference[];\n}): void {\n if (!threadId) return;\n if (references.length === 0) {\n stagedForSend.delete(threadId);\n return;\n }\n stagedForSend.set(threadId, { references, stagedAt: Date.now() });\n}\n\n/** The references staged for the message `threadId` journals now, taking the slot. */\nexport function takeStagedAttachedReferences(threadId: string): readonly AttachableReference[] {\n const staged = stagedForSend.get(threadId);\n stagedForSend.delete(threadId);\n if (!staged || Date.now() - staged.stagedAt > ATTACHED_REFERENCES_STAGED_TTL_MS) return EMPTY;\n return staged.references;\n}\n\n/**\n * The metadata a runtime's `getMessageMetadata` adds for the message `threadId` journals now: the\n * references staged for it under `attachedReferences`, taking the slot, over `metadata` (what the\n * rest of the getter produced). `metadata` unchanged when none are staged.\n */\nexport function withStagedAttachedReferences(\n threadId: string,\n metadata: Record<string, unknown> | undefined,\n): Record<string, unknown> | undefined {\n const references = takeStagedAttachedReferences(threadId);\n return references.length === 0 ? metadata : withAttachedReferences(metadata, references);\n}\n\n/** How many sent texts each thread remembers the references of, and how many threads. */\nconst SENT_TEXTS_KEPT_PER_THREAD = 20;\nconst THREADS_WITH_SENT_TEXTS_KEPT = 50;\n\n// process-local: client-only — the references each recent send carried, by its text, so a send\n// handed back (statewire refused it during a reconnect) brings its chips back.\nconst sentWithText = new Map<string, Map<string, readonly AttachableReference[]>>();\n\nfunction setBounded<K, V>(map: Map<K, V>, key: K, value: V, limit: number): void {\n map.delete(key);\n map.set(key, value);\n while (map.size > limit) {\n const oldest = map.keys().next();\n if (oldest.done) break;\n map.delete(oldest.value);\n }\n}\n\n/**\n * Right before `threadId`'s composer sends `text`: stage the references pending for it, remember\n * them with the text (so the text coming back brings them back) and take them off the composer.\n * Returns what the message carries, `[]` when nothing was attached.\n */\nexport function stageThreadAttachedReferencesForSend({\n threadId,\n text,\n}: {\n threadId: string;\n text: string;\n}): readonly AttachableReference[] {\n const references = readPendingAttachedReferences(threadId);\n stageAttachedReferencesForSend({ threadId, references });\n if (!threadId) return references;\n const texts = sentWithText.get(threadId);\n if (references.length === 0) {\n texts?.delete(text);\n return references;\n }\n const kept = texts ?? new Map<string, readonly AttachableReference[]>();\n setBounded(kept, text, references, SENT_TEXTS_KEPT_PER_THREAD);\n setBounded(sentWithText, threadId, kept, THREADS_WITH_SENT_TEXTS_KEPT);\n clearAttachedReferences(threadId);\n return references;\n}\n\nfunction reattach(threadId: string, references: readonly AttachableReference[]): void {\n for (const reference of references) attachReferenceToThread({ threadId, reference });\n}\n\n/**\n * Text a send carried came back to `threadId`'s composer (statewire handed a refused send back):\n * the references it carried come back as chips, after any attached since.\n */\nexport function restoreSentAttachedReferences({\n threadId,\n text,\n}: {\n threadId: string;\n text: string;\n}): void {\n const references = sentWithText.get(threadId)?.get(text);\n if (references) reattach(threadId, references);\n}\n\n/**\n * A message held in the chat outbox was given back to the composer (Cancel, Edit): the references\n * its metadata carries come back as chips.\n */\nexport function giveBackHeldAttachedReferences(entry: {\n threadId: string;\n metadata?: unknown;\n}): void {\n reattach(entry.threadId, readMessageAttachedReferences(entry.metadata));\n}\n"],"names":["normalizeAttachableReference","attachableReferenceKey","MAX_ATTACHED_REFERENCES","useCallback","useSyncExternalStore","withAttachedReferences","readMessageAttachedReferences"],"mappings":";;;;AAsCA,MAAM,QAAwC,OAAO,OAAO,EAAE;AAG9D,MAAM,8BAAc,IAAA;AACpB,MAAM,gCAAgB,IAAA;AACtB,IAAI,sBAAqC;AAEzC,SAAS,SAAe;AACtB,aAAW,YAAY,CAAC,GAAG,SAAS,EAAG,UAAA;AACzC;AAEA,SAAS,UAAU,UAAkC;AACnD,YAAU,IAAI,QAAQ;AACtB,SAAO,MAAM;AACX,cAAU,OAAO,QAAQ;AAAA,EAC3B;AACF;AAEA,SAAS,WAAW,UAAkB,YAAkD;AACtF,MAAI,WAAW,WAAW,EAAG,SAAQ,OAAO,QAAQ;AAAA,MAC/C,SAAQ,IAAI,UAAU,OAAO,OAAO,CAAC,GAAG,UAAU,CAAC,CAAC;AACzD,SAAA;AACF;AAuBO,SAAS,wBAAwB;AAAA,EACtC;AAAA,EACA;AACF,GAG0B;AACxB,MAAI,CAAC,SAAU,QAAO,EAAE,UAAU,OAAO,QAAQ,YAAA;AACjD,QAAM,aAAaA,WAAAA,6BAA6B,SAAS;AACzD,MAAI,eAAe,KAAM,QAAO,EAAE,UAAU,OAAO,QAAQ,oBAAA;AAC3D,QAAM,MAAMC,WAAAA,uBAAuB,UAAU;AAC7C,QAAM,UAAU,QAAQ,IAAI,QAAQ,KAAK;AACzC,QAAM,QAAQ,QAAQ,UAAU,CAAC,UAAUA,kCAAuB,KAAK,MAAM,GAAG;AAChF,MAAI,SAAS,GAAG;AACd;AAAA,MACE;AAAA,MACA,QAAQ,IAAI,CAAC,OAAO,aAAc,aAAa,QAAQ,aAAa,KAAM;AAAA,IAAA;AAE5E,WAAO,EAAE,UAAU,MAAM,WAAW,YAAY,WAAW,KAAA;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,WAAW;AACrF;AAMO,SAAS,8BAA8B;AAAA,EAC5C;AAAA,EACA;AACF,GAGS;;AACP,QAAM,cAAa,kBAAa,IAAI,QAAQ,MAAzB,mBAA4B,IAAI;AACnD,MAAI,WAAY,UAAS,UAAU,UAAU;AAC/C;AAMO,SAAS,+BAA+B,OAGtC;AACP,WAAS,MAAM,UAAUC,WAAAA,uBAA8B,MAAM,QAAQ,CAAC;AACxE;;;;;;;;;;;;;;;"}
@@ -0,0 +1,86 @@
1
+ import { type AttachableReference } from '../references/src/attachable';
2
+ /** Why a reference was not attached. */
3
+ export type AttachRefusalReason =
4
+ /** Not a reference an app may attach (an unknown kind, a malformed id, URL or anchor). */
5
+ 'invalid_reference'
6
+ /** The next message already carries {@link MAX_ATTACHED_REFERENCES}. */
7
+ | 'too_many'
8
+ /** No conversation to attach it to (outside `<AthenaProvider>`'s chat). */
9
+ | 'no_thread';
10
+ /** What `attach` did. */
11
+ export type AttachReferenceResult = {
12
+ attached: true;
13
+ /** The reference as it will be sent (normalized: unknown fields dropped, label cut). */
14
+ reference: AttachableReference;
15
+ /** It was attached already; its label is updated and it keeps its place. */
16
+ duplicate: boolean;
17
+ } | {
18
+ attached: false;
19
+ reason: AttachRefusalReason;
20
+ };
21
+ /** Attach `reference` to `threadId`'s next message. */
22
+ export declare function attachReferenceToThread({ threadId, reference, }: {
23
+ threadId: string | null;
24
+ reference: unknown;
25
+ }): AttachReferenceResult;
26
+ /** Take `reference` (matched by kind and pointer) off `threadId`'s next message. */
27
+ export declare function detachReferenceFromThread({ threadId, reference, }: {
28
+ threadId: string | null;
29
+ reference: AttachableReference;
30
+ }): void;
31
+ /** Take every reference off `threadId`'s next message. */
32
+ export declare function clearAttachedReferences(threadId: string | null): void;
33
+ /** The references `threadId`'s next message carries, in the order attached. */
34
+ export declare function readPendingAttachedReferences(threadId: string | null): readonly AttachableReference[];
35
+ /** {@link readPendingAttachedReferences}, re-rendering when the list changes. */
36
+ export declare function usePendingAttachedReferences(threadId: string | null): readonly AttachableReference[];
37
+ /** Forget every pending, staged and sent reference (tests, and a change of identity). */
38
+ export declare function forgetAllAttachedReferences(): void;
39
+ /**
40
+ * Keep the pending references only while `identity` (the signed-in person) stays the same: a
41
+ * change forgets every one, so nothing attached under one identity is sent under another.
42
+ */
43
+ export declare function keepAttachedReferencesForIdentity(identity: string): void;
44
+ /** How long staged references wait for the message they were staged for before they expire. */
45
+ export declare const ATTACHED_REFERENCES_STAGED_TTL_MS = 10000;
46
+ /**
47
+ * Stage `references` for the message `threadId`'s composer submits next. Call right before the send
48
+ * (`aui.composer.send`). A send attaching nothing stages nothing and lets an earlier slot go.
49
+ */
50
+ export declare function stageAttachedReferencesForSend({ threadId, references, }: {
51
+ threadId: string;
52
+ references: readonly AttachableReference[];
53
+ }): void;
54
+ /** The references staged for the message `threadId` journals now, taking the slot. */
55
+ export declare function takeStagedAttachedReferences(threadId: string): readonly AttachableReference[];
56
+ /**
57
+ * The metadata a runtime's `getMessageMetadata` adds for the message `threadId` journals now: the
58
+ * references staged for it under `attachedReferences`, taking the slot, over `metadata` (what the
59
+ * rest of the getter produced). `metadata` unchanged when none are staged.
60
+ */
61
+ export declare function withStagedAttachedReferences(threadId: string, metadata: Record<string, unknown> | undefined): Record<string, unknown> | undefined;
62
+ /**
63
+ * Right before `threadId`'s composer sends `text`: stage the references pending for it, remember
64
+ * them with the text (so the text coming back brings them back) and take them off the composer.
65
+ * Returns what the message carries, `[]` when nothing was attached.
66
+ */
67
+ export declare function stageThreadAttachedReferencesForSend({ threadId, text, }: {
68
+ threadId: string;
69
+ text: string;
70
+ }): readonly AttachableReference[];
71
+ /**
72
+ * Text a send carried came back to `threadId`'s composer (statewire handed a refused send back):
73
+ * the references it carried come back as chips, after any attached since.
74
+ */
75
+ export declare function restoreSentAttachedReferences({ threadId, text, }: {
76
+ threadId: string;
77
+ text: string;
78
+ }): void;
79
+ /**
80
+ * A message held in the chat outbox was given back to the composer (Cancel, Edit): the references
81
+ * its metadata carries come back as chips.
82
+ */
83
+ export declare function giveBackHeldAttachedReferences(entry: {
84
+ threadId: string;
85
+ metadata?: unknown;
86
+ }): void;
@@ -0,0 +1,159 @@
1
+ import { normalizeAttachableReference, attachableReferenceKey, MAX_ATTACHED_REFERENCES, withAttachedReferences, readAttachedReferences } from "../references/src/attachable.js";
2
+ import { useCallback, useSyncExternalStore } from "react";
3
+ const EMPTY = Object.freeze([]);
4
+ const pending = /* @__PURE__ */ new Map();
5
+ const listeners = /* @__PURE__ */ new Set();
6
+ let attachedForIdentity = null;
7
+ function notify() {
8
+ for (const listener of [...listeners]) listener();
9
+ }
10
+ function subscribe(listener) {
11
+ listeners.add(listener);
12
+ return () => {
13
+ listeners.delete(listener);
14
+ };
15
+ }
16
+ function setPending(threadId, references) {
17
+ if (references.length === 0) pending.delete(threadId);
18
+ else pending.set(threadId, Object.freeze([...references]));
19
+ notify();
20
+ }
21
+ function attachReferenceToThread({
22
+ threadId,
23
+ reference
24
+ }) {
25
+ if (!threadId) return { attached: false, reason: "no_thread" };
26
+ const normalized = normalizeAttachableReference(reference);
27
+ if (normalized === null) return { attached: false, reason: "invalid_reference" };
28
+ const key = attachableReferenceKey(normalized);
29
+ const current = pending.get(threadId) ?? EMPTY;
30
+ const index = current.findIndex((entry) => attachableReferenceKey(entry) === key);
31
+ if (index >= 0) {
32
+ setPending(
33
+ threadId,
34
+ current.map((entry, position) => position === index ? normalized : entry)
35
+ );
36
+ return { attached: true, reference: normalized, duplicate: true };
37
+ }
38
+ if (current.length >= MAX_ATTACHED_REFERENCES) return { attached: false, reason: "too_many" };
39
+ setPending(threadId, [...current, normalized]);
40
+ return { attached: true, reference: normalized, duplicate: false };
41
+ }
42
+ function detachReferenceFromThread({
43
+ threadId,
44
+ reference
45
+ }) {
46
+ if (!threadId) return;
47
+ const current = pending.get(threadId);
48
+ if (!current) return;
49
+ const key = attachableReferenceKey(reference);
50
+ const kept = current.filter((entry) => attachableReferenceKey(entry) !== key);
51
+ if (kept.length !== current.length) setPending(threadId, kept);
52
+ }
53
+ function clearAttachedReferences(threadId) {
54
+ if (!threadId || !pending.has(threadId)) return;
55
+ setPending(threadId, EMPTY);
56
+ }
57
+ function readPendingAttachedReferences(threadId) {
58
+ return (threadId ? pending.get(threadId) : void 0) ?? EMPTY;
59
+ }
60
+ function usePendingAttachedReferences(threadId) {
61
+ const read = useCallback(() => readPendingAttachedReferences(threadId), [threadId]);
62
+ return useSyncExternalStore(subscribe, read, read);
63
+ }
64
+ function forgetAllAttachedReferences() {
65
+ pending.clear();
66
+ stagedForSend.clear();
67
+ sentWithText.clear();
68
+ notify();
69
+ }
70
+ function keepAttachedReferencesForIdentity(identity) {
71
+ if (attachedForIdentity !== null && attachedForIdentity !== identity) {
72
+ forgetAllAttachedReferences();
73
+ }
74
+ attachedForIdentity = identity;
75
+ }
76
+ const ATTACHED_REFERENCES_STAGED_TTL_MS = 1e4;
77
+ const stagedForSend = /* @__PURE__ */ new Map();
78
+ function stageAttachedReferencesForSend({
79
+ threadId,
80
+ references
81
+ }) {
82
+ if (!threadId) return;
83
+ if (references.length === 0) {
84
+ stagedForSend.delete(threadId);
85
+ return;
86
+ }
87
+ stagedForSend.set(threadId, { references, stagedAt: Date.now() });
88
+ }
89
+ function takeStagedAttachedReferences(threadId) {
90
+ const staged = stagedForSend.get(threadId);
91
+ stagedForSend.delete(threadId);
92
+ if (!staged || Date.now() - staged.stagedAt > ATTACHED_REFERENCES_STAGED_TTL_MS) return EMPTY;
93
+ return staged.references;
94
+ }
95
+ function withStagedAttachedReferences(threadId, metadata) {
96
+ const references = takeStagedAttachedReferences(threadId);
97
+ return references.length === 0 ? metadata : withAttachedReferences(metadata, references);
98
+ }
99
+ const SENT_TEXTS_KEPT_PER_THREAD = 20;
100
+ const THREADS_WITH_SENT_TEXTS_KEPT = 50;
101
+ const sentWithText = /* @__PURE__ */ new Map();
102
+ function setBounded(map, key, value, limit) {
103
+ map.delete(key);
104
+ map.set(key, value);
105
+ while (map.size > limit) {
106
+ const oldest = map.keys().next();
107
+ if (oldest.done) break;
108
+ map.delete(oldest.value);
109
+ }
110
+ }
111
+ function stageThreadAttachedReferencesForSend({
112
+ threadId,
113
+ text
114
+ }) {
115
+ const references = readPendingAttachedReferences(threadId);
116
+ stageAttachedReferencesForSend({ threadId, references });
117
+ if (!threadId) return references;
118
+ const texts = sentWithText.get(threadId);
119
+ if (references.length === 0) {
120
+ texts == null ? void 0 : texts.delete(text);
121
+ return references;
122
+ }
123
+ const kept = texts ?? /* @__PURE__ */ new Map();
124
+ setBounded(kept, text, references, SENT_TEXTS_KEPT_PER_THREAD);
125
+ setBounded(sentWithText, threadId, kept, THREADS_WITH_SENT_TEXTS_KEPT);
126
+ clearAttachedReferences(threadId);
127
+ return references;
128
+ }
129
+ function reattach(threadId, references) {
130
+ for (const reference of references) attachReferenceToThread({ threadId, reference });
131
+ }
132
+ function restoreSentAttachedReferences({
133
+ threadId,
134
+ text
135
+ }) {
136
+ var _a;
137
+ const references = (_a = sentWithText.get(threadId)) == null ? void 0 : _a.get(text);
138
+ if (references) reattach(threadId, references);
139
+ }
140
+ function giveBackHeldAttachedReferences(entry) {
141
+ reattach(entry.threadId, readAttachedReferences(entry.metadata));
142
+ }
143
+ export {
144
+ ATTACHED_REFERENCES_STAGED_TTL_MS,
145
+ attachReferenceToThread,
146
+ clearAttachedReferences,
147
+ detachReferenceFromThread,
148
+ forgetAllAttachedReferences,
149
+ giveBackHeldAttachedReferences,
150
+ keepAttachedReferencesForIdentity,
151
+ readPendingAttachedReferences,
152
+ restoreSentAttachedReferences,
153
+ stageAttachedReferencesForSend,
154
+ stageThreadAttachedReferencesForSend,
155
+ takeStagedAttachedReferences,
156
+ usePendingAttachedReferences,
157
+ withStagedAttachedReferences
158
+ };
159
+ //# sourceMappingURL=attached-references.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attached-references.js","sources":["../../src/composer/attached-references.ts"],"sourcesContent":["import {\n type AttachableReference,\n attachableReferenceKey,\n MAX_ATTACHED_REFERENCES,\n normalizeAttachableReference,\n readAttachedReferences as readMessageAttachedReferences,\n withAttachedReferences,\n} from '@athenaintel/references/attachable';\nimport { useCallback, useSyncExternalStore } from 'react';\n\n/**\n * What each conversation's next message carries as attached references (`useAttachToChat`), and\n * the hand-off of that list to the message that leaves.\n *\n * - **The pending list.** Per thread, in the order attached, each reference once (by kind and\n * pointer, an asset's anchor included), at most {@link MAX_ATTACHED_REFERENCES}. The composer\n * shows it as removable chips (`ComposerAttachedReferences`). It is kept in memory for the page\n * and dropped when the signed-in identity changes ({@link keepAttachedReferencesForIdentity}):\n * what one person attached is never sent as someone else's.\n * - **The send.** statewire captures a new message's metadata once, as it journals it\n * (`getMessageMetadata`), without saying which message it is for. So the composer stages the\n * list right before `aui.composer.send` ({@link stageAttachedReferencesForSend}) and the runtime's\n * getter takes it for the message that follows ({@link withStagedAttachedReferences}).\n * The references then ride the message's own metadata (`attachedReferences`), never its text, so\n * a send that waits, is retried or is posted again after a reload keeps its own attachments. A\n * slot nobody takes expires. Both send paths stage them ({@link stageThreadAttachedReferencesForSend}):\n * `AthenaChat`'s composed send, and `TiptapComposer`'s own through its host's `prepareSend`\n * (`useAttachedReferencesComposerProps`). A composer whose host doesn't opt in sends none and\n * never loads this module (the Office pane's budget counts on it).\n * - **The way back.** Sending takes the chips off the composer, and they come back with the send:\n * a send statewire refuses and hands back ({@link restoreSentAttachedReferences}, by its text),\n * or a message held in the chat outbox that is cancelled or edited\n * ({@link giveBackHeldAttachedReferences}, from its metadata).\n *\n * agora reads the list off the message, refuses whatever it can't read, and resolves each one with\n * the person's own permission before the agent is told about it; the client never gates.\n */\n\nconst EMPTY: readonly AttachableReference[] = Object.freeze([]);\n\n// process-local: client-only — the references each thread's composer sends with its next message.\nconst pending = new Map<string, readonly AttachableReference[]>();\nconst listeners = new Set<() => void>();\nlet attachedForIdentity: string | null = null;\n\nfunction notify(): void {\n for (const listener of [...listeners]) listener();\n}\n\nfunction subscribe(listener: () => void): () => void {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n}\n\nfunction setPending(threadId: string, references: readonly AttachableReference[]): void {\n if (references.length === 0) pending.delete(threadId);\n else pending.set(threadId, Object.freeze([...references]));\n notify();\n}\n\n/** Why a reference was not attached. */\nexport type AttachRefusalReason =\n /** Not a reference an app may attach (an unknown kind, a malformed id, URL or anchor). */\n | 'invalid_reference'\n /** The next message already carries {@link MAX_ATTACHED_REFERENCES}. */\n | 'too_many'\n /** No conversation to attach it to (outside `<AthenaProvider>`'s chat). */\n | 'no_thread';\n\n/** What `attach` did. */\nexport type AttachReferenceResult =\n | {\n attached: true;\n /** The reference as it will be sent (normalized: unknown fields dropped, label cut). */\n reference: AttachableReference;\n /** It was attached already; its label is updated and it keeps its place. */\n duplicate: boolean;\n }\n | { attached: false; reason: AttachRefusalReason };\n\n/** Attach `reference` to `threadId`'s next message. */\nexport function attachReferenceToThread({\n threadId,\n reference,\n}: {\n threadId: string | null;\n reference: unknown;\n}): AttachReferenceResult {\n if (!threadId) return { attached: false, reason: 'no_thread' };\n const normalized = normalizeAttachableReference(reference);\n if (normalized === null) return { attached: false, reason: 'invalid_reference' };\n const key = attachableReferenceKey(normalized);\n const current = pending.get(threadId) ?? EMPTY;\n const index = current.findIndex((entry) => attachableReferenceKey(entry) === key);\n if (index >= 0) {\n setPending(\n threadId,\n current.map((entry, position) => (position === index ? normalized : entry)),\n );\n return { attached: true, reference: normalized, duplicate: true };\n }\n if (current.length >= MAX_ATTACHED_REFERENCES) return { attached: false, reason: 'too_many' };\n setPending(threadId, [...current, normalized]);\n return { attached: true, reference: normalized, duplicate: false };\n}\n\n/** Take `reference` (matched by kind and pointer) off `threadId`'s next message. */\nexport function detachReferenceFromThread({\n threadId,\n reference,\n}: {\n threadId: string | null;\n reference: AttachableReference;\n}): void {\n if (!threadId) return;\n const current = pending.get(threadId);\n if (!current) return;\n const key = attachableReferenceKey(reference);\n const kept = current.filter((entry) => attachableReferenceKey(entry) !== key);\n if (kept.length !== current.length) setPending(threadId, kept);\n}\n\n/** Take every reference off `threadId`'s next message. */\nexport function clearAttachedReferences(threadId: string | null): void {\n if (!threadId || !pending.has(threadId)) return;\n setPending(threadId, EMPTY);\n}\n\n/** The references `threadId`'s next message carries, in the order attached. */\nexport function readPendingAttachedReferences(threadId: string | null): readonly AttachableReference[] {\n return (threadId ? pending.get(threadId) : undefined) ?? EMPTY;\n}\n\n/** {@link readPendingAttachedReferences}, re-rendering when the list changes. */\nexport function usePendingAttachedReferences(threadId: string | null): readonly AttachableReference[] {\n const read = useCallback(() => readPendingAttachedReferences(threadId), [threadId]);\n return useSyncExternalStore(subscribe, read, read);\n}\n\n/** Forget every pending, staged and sent reference (tests, and a change of identity). */\nexport function forgetAllAttachedReferences(): void {\n pending.clear();\n stagedForSend.clear();\n sentWithText.clear();\n notify();\n}\n\n/**\n * Keep the pending references only while `identity` (the signed-in person) stays the same: a\n * change forgets every one, so nothing attached under one identity is sent under another.\n */\nexport function keepAttachedReferencesForIdentity(identity: string): void {\n if (attachedForIdentity !== null && attachedForIdentity !== identity) {\n forgetAllAttachedReferences();\n }\n attachedForIdentity = identity;\n}\n\n// ── The send ────────────────────────────────────────────────────────────────\n\n/** How long staged references wait for the message they were staged for before they expire. */\nexport const ATTACHED_REFERENCES_STAGED_TTL_MS = 10_000;\n\n// process-local: client-only — the references each thread's composer staged for the message it\n// submits next, taken once by the runtime's `getMessageMetadata`.\nconst stagedForSend = new Map<\n string,\n { references: readonly AttachableReference[]; stagedAt: number }\n>();\n\n/**\n * Stage `references` for the message `threadId`'s composer submits next. Call right before the send\n * (`aui.composer.send`). A send attaching nothing stages nothing and lets an earlier slot go.\n */\nexport function stageAttachedReferencesForSend({\n threadId,\n references,\n}: {\n threadId: string;\n references: readonly AttachableReference[];\n}): void {\n if (!threadId) return;\n if (references.length === 0) {\n stagedForSend.delete(threadId);\n return;\n }\n stagedForSend.set(threadId, { references, stagedAt: Date.now() });\n}\n\n/** The references staged for the message `threadId` journals now, taking the slot. */\nexport function takeStagedAttachedReferences(threadId: string): readonly AttachableReference[] {\n const staged = stagedForSend.get(threadId);\n stagedForSend.delete(threadId);\n if (!staged || Date.now() - staged.stagedAt > ATTACHED_REFERENCES_STAGED_TTL_MS) return EMPTY;\n return staged.references;\n}\n\n/**\n * The metadata a runtime's `getMessageMetadata` adds for the message `threadId` journals now: the\n * references staged for it under `attachedReferences`, taking the slot, over `metadata` (what the\n * rest of the getter produced). `metadata` unchanged when none are staged.\n */\nexport function withStagedAttachedReferences(\n threadId: string,\n metadata: Record<string, unknown> | undefined,\n): Record<string, unknown> | undefined {\n const references = takeStagedAttachedReferences(threadId);\n return references.length === 0 ? metadata : withAttachedReferences(metadata, references);\n}\n\n/** How many sent texts each thread remembers the references of, and how many threads. */\nconst SENT_TEXTS_KEPT_PER_THREAD = 20;\nconst THREADS_WITH_SENT_TEXTS_KEPT = 50;\n\n// process-local: client-only — the references each recent send carried, by its text, so a send\n// handed back (statewire refused it during a reconnect) brings its chips back.\nconst sentWithText = new Map<string, Map<string, readonly AttachableReference[]>>();\n\nfunction setBounded<K, V>(map: Map<K, V>, key: K, value: V, limit: number): void {\n map.delete(key);\n map.set(key, value);\n while (map.size > limit) {\n const oldest = map.keys().next();\n if (oldest.done) break;\n map.delete(oldest.value);\n }\n}\n\n/**\n * Right before `threadId`'s composer sends `text`: stage the references pending for it, remember\n * them with the text (so the text coming back brings them back) and take them off the composer.\n * Returns what the message carries, `[]` when nothing was attached.\n */\nexport function stageThreadAttachedReferencesForSend({\n threadId,\n text,\n}: {\n threadId: string;\n text: string;\n}): readonly AttachableReference[] {\n const references = readPendingAttachedReferences(threadId);\n stageAttachedReferencesForSend({ threadId, references });\n if (!threadId) return references;\n const texts = sentWithText.get(threadId);\n if (references.length === 0) {\n texts?.delete(text);\n return references;\n }\n const kept = texts ?? new Map<string, readonly AttachableReference[]>();\n setBounded(kept, text, references, SENT_TEXTS_KEPT_PER_THREAD);\n setBounded(sentWithText, threadId, kept, THREADS_WITH_SENT_TEXTS_KEPT);\n clearAttachedReferences(threadId);\n return references;\n}\n\nfunction reattach(threadId: string, references: readonly AttachableReference[]): void {\n for (const reference of references) attachReferenceToThread({ threadId, reference });\n}\n\n/**\n * Text a send carried came back to `threadId`'s composer (statewire handed a refused send back):\n * the references it carried come back as chips, after any attached since.\n */\nexport function restoreSentAttachedReferences({\n threadId,\n text,\n}: {\n threadId: string;\n text: string;\n}): void {\n const references = sentWithText.get(threadId)?.get(text);\n if (references) reattach(threadId, references);\n}\n\n/**\n * A message held in the chat outbox was given back to the composer (Cancel, Edit): the references\n * its metadata carries come back as chips.\n */\nexport function giveBackHeldAttachedReferences(entry: {\n threadId: string;\n metadata?: unknown;\n}): void {\n reattach(entry.threadId, readMessageAttachedReferences(entry.metadata));\n}\n"],"names":["readMessageAttachedReferences"],"mappings":";;AAsCA,MAAM,QAAwC,OAAO,OAAO,EAAE;AAG9D,MAAM,8BAAc,IAAA;AACpB,MAAM,gCAAgB,IAAA;AACtB,IAAI,sBAAqC;AAEzC,SAAS,SAAe;AACtB,aAAW,YAAY,CAAC,GAAG,SAAS,EAAG,UAAA;AACzC;AAEA,SAAS,UAAU,UAAkC;AACnD,YAAU,IAAI,QAAQ;AACtB,SAAO,MAAM;AACX,cAAU,OAAO,QAAQ;AAAA,EAC3B;AACF;AAEA,SAAS,WAAW,UAAkB,YAAkD;AACtF,MAAI,WAAW,WAAW,EAAG,SAAQ,OAAO,QAAQ;AAAA,MAC/C,SAAQ,IAAI,UAAU,OAAO,OAAO,CAAC,GAAG,UAAU,CAAC,CAAC;AACzD,SAAA;AACF;AAuBO,SAAS,wBAAwB;AAAA,EACtC;AAAA,EACA;AACF,GAG0B;AACxB,MAAI,CAAC,SAAU,QAAO,EAAE,UAAU,OAAO,QAAQ,YAAA;AACjD,QAAM,aAAa,6BAA6B,SAAS;AACzD,MAAI,eAAe,KAAM,QAAO,EAAE,UAAU,OAAO,QAAQ,oBAAA;AAC3D,QAAM,MAAM,uBAAuB,UAAU;AAC7C,QAAM,UAA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AAO;AAAA,EACT;AACA,QAAM,OAAO,SAAS,oBAAI,IAAA;AAC1B,aAAW,MAAM,MAAM,YAAY,0BAA0B;AAC7D,aAAW,cAAc,UAAU,MAAM,4BAA4B;AACrE,0BAAwB,QAAQ;AAChC,SAAO;AACT;AAEA,SAAS,SAAS,UAAkB,YAAkD;AACpF,aAAW,aAAa,WAAY,yBAAwB,EAAE,UAAU,WAAW;AACrF;AAMO,SAAS,8BAA8B;AAAA,EAC5C;AAAA,EACA;AACF,GAGS;;AACP,QAAM,cAAa,kBAAa,IAAI,QAAQ,MAAzB,mBAA4B,IAAI;AACnD,MAAI,WAAY,UAAS,UAAU,UAAU;AAC/C;AAMO,SAAS,+BAA+B,OAGtC;AACP,WAAS,MAAM,UAAUA,uBAA8B,MAAM,QAAQ,CAAC;AACxE;"}
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const attachable = require("../references/src/attachable.cjs");
3
4
  const AttachmentContext = require("./AttachmentContext.cjs");
4
5
  const composerMessage = require("../chat-ui/composer/composer-message.cjs");
5
6
  const composerMarkdown = require("../agent-runtime/src/composer-markdown.cjs");
@@ -54,7 +55,9 @@ function holdComposedSend({
54
55
  carried = [],
55
56
  quote,
56
57
  send,
57
- appUrl
58
+ appUrl,
59
+ addressedAgents,
60
+ attachedReferences = []
58
61
  }) {
59
62
  const composed = buildComposedSend({ attachments, quote, send, appUrl });
60
63
  if (!composed) return null;
@@ -72,12 +75,16 @@ function holdComposedSend({
72
75
  return outbox.hold({
73
76
  text: composed.text,
74
77
  composerMarkdown: composed.draftMarkdown,
75
- metadata: composerMarkdown.withDeepAgentComposerMarkdown({
76
- metadata: void 0,
77
- text: composed.text,
78
- markdown: composed.draftMarkdown
79
- }),
80
- attachments: [...named.values()]
78
+ metadata: attachable.withAttachedReferences(
79
+ composerMarkdown.withDeepAgentComposerMarkdown({
80
+ metadata: void 0,
81
+ text: composed.text,
82
+ markdown: composed.draftMarkdown
83
+ }),
84
+ attachedReferences
85
+ ),
86
+ attachments: [...named.values()],
87
+ ...addressedAgents && { addressedAgents }
81
88
  });
82
89
  }
83
90
  exports.buildComposedMessage = buildComposedMessage;
@@ -1 +1 @@
1
- {"version":3,"file":"build-composed-message.cjs","sources":["../../src/composer/build-composed-message.ts"],"sourcesContent":["import {\n type ChatOutbox,\n type ChatOutboxAttachment,\n type ChatOutboxEntry,\n withDeepAgentComposerMarkdown,\n} from '@athenaintel/agent-runtime';\nimport type { UploadedAsset } from './useFileUpload';\nimport type { QuoteData } from './QuoteContext';\nimport { buildAttachmentMarkdownWithAppUrl } from './AttachmentContext';\nimport {\n type ComposerSend,\n escapeCharacterReferences,\n} from '../chat-ui/composer/composer-message';\n\n/**\n * Assembles a composed message from attachments, a quote, and user text.\n * Used by both the TipTap Enter-key submit and the send-button click handler\n * to avoid duplicating the message-assembly logic.\n *\n * Returns an empty string if all inputs are empty.\n */\nexport function buildComposedMessage(opts: {\n attachments?: UploadedAsset[];\n quote?: QuoteData | null;\n userText?: string;\n appUrl?: string;\n}): string {\n const parts: string[] = [];\n\n if (opts.attachments && opts.attachments.length > 0) {\n const attachmentMd = buildAttachmentMarkdownWithAppUrl({\n attachments: opts.attachments,\n appUrl: opts.appUrl,\n });\n if (attachmentMd) parts.push(attachmentMd);\n }\n\n if (opts.quote) {\n const quotedLines = opts.quote.text.split('\\n').map((l) => `> ${l}`).join('\\n');\n const sourceLabel = opts.quote.sourceTitle\n ? `From \"${opts.quote.sourceTitle}\"`\n : opts.quote.sourceRole === 'assistant'\n ? 'Quoting assistant'\n : 'Quoting';\n parts.push(`${sourceLabel}:\\n${quotedLines}`);\n }\n\n const trimmed = opts.userText?.trim();\n if (trimmed) parts.push(trimmed);\n\n return parts.join('\\n\\n');\n}\n\n/**\n * The composed message a send delivers and the draft it came from: the same\n * attachments and quote around the editor's text as typed in one, and around\n * the editor's draft in the other (`ComposerSend`). `null` when there is\n * nothing to send.\n *\n * The quote and the attachment titles are text the person did not type in\n * the editor, and the message carries them as they are. The draft writes an\n * `&` in them that starts a character reference as `&amp;`, as the composer's\n * draft does for typed text, so it reads back as the message and stays a draft\n * of the message's own text (`isComposerMarkdownOfText`, which agora applies\n * too): a quoted `&lt;` would otherwise read as `<` in the draft and the\n * message would lose its composer markdown.\n */\nexport function buildComposedSend({\n attachments,\n quote,\n send,\n appUrl,\n}: {\n attachments?: UploadedAsset[];\n quote?: QuoteData | null;\n send: ComposerSend;\n appUrl?: string;\n}): ComposerSend | null {\n const text = buildComposedMessage({ attachments, quote, userText: send.text, appUrl });\n if (!text) return null;\n const draftMarkdown = buildComposedMessage({\n attachments: attachments?.map((attachment) => ({\n ...attachment,\n title: escapeCharacterReferences(attachment.title),\n })),\n quote: quote && {\n ...quote,\n text: escapeCharacterReferences(quote.text),\n ...(quote.sourceTitle !== undefined && {\n sourceTitle: escapeCharacterReferences(quote.sourceTitle),\n }),\n },\n userText: send.draftMarkdown,\n appUrl,\n });\n return { text, draftMarkdown };\n}\n\n/**\n * Holds a composed message in the chat outbox while sends are on hold (Athena can't be reached, or\n * earlier messages still wait): the uploaded attachments and the quote around the editor's text,\n * exactly as {@link buildComposedSend} would send them, so it goes with them once Athena is back.\n * The attachments are files already in Athena (an upload that finished before the drop); they are\n * named on the held message so the outbox asks Athena, right before it goes, that each can still\n * be opened. Cancel or Edit gives back the composed draft: the attachments as mentions in the\n * editor, the quote as quoted lines, nothing lost. `carried` are files already in Athena the\n * editor's own draft carries (mentions a held message gave back), named with the pills. `null`\n * when there is nothing to hold.\n */\nexport function holdComposedSend({\n outbox,\n attachments,\n carried = [],\n quote,\n send,\n appUrl,\n}: {\n outbox: ChatOutbox;\n attachments?: UploadedAsset[];\n carried?: readonly ChatOutboxAttachment[];\n quote?: QuoteData | null;\n send: ComposerSend;\n appUrl?: string;\n}): ChatOutboxEntry | null {\n const composed = buildComposedSend({ attachments, quote, send, appUrl });\n if (!composed) return null;\n const named = new Map<string, ChatOutboxAttachment>();\n for (const attachment of attachments ?? []) {\n named.set(attachment.id, {\n assetId: attachment.id,\n title: attachment.title,\n ...(attachment.mediaType && { mediaType: attachment.mediaType }),\n });\n }\n for (const attachment of carried) {\n if (!named.has(attachment.assetId)) named.set(attachment.assetId, attachment);\n }\n return outbox.hold({\n text: composed.text,\n composerMarkdown: composed.draftMarkdown,\n metadata: withDeepAgentComposerMarkdown({\n metadata: undefined,\n text: composed.text,\n markdown: composed.draftMarkdown,\n }),\n attachments: [...named.values()],\n });\n}\n"],"names":["buildAttachmentMarkdownWithAppUrl","escapeCharacterReferences","withDeepAgentComposerMarkdown"],"mappings":";;;;;AAqBO,SAAS,qBAAqB,MAK1B;;AACT,QAAM,QAAkB,CAAA;AAExB,MAAI,KAAK,eAAe,KAAK,YAAY,SAAS,GAAG;AACnD,UAAM,eAAeA,kBAAAA,kCAAkC;AAAA,MACrD,aAAa,KAAK;AAAA,MAClB,QAAQ,KAAK;AAAA,IAAA,CACd;AACD,QAAI,aAAc,OAAM,KAAK,YAAY;AAAA,EAC3C;AAEA,MAAI,KAAK,OAAO;AACd,UAAM,cAAc,KAAK,MAAM,KAAK,MAAM,IAAI,EAAE,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,EAAE,KAAK,IAAI;AAC9E,UAAM,cAAc,KAAK,MAAM,cAC3B,SAAS,KAAK,MAAM,WAAW,MAC/B,KAAK,MAAM,eAAe,cACxB,sBACA;AACN,UAAM,KAAK,GAAG,WAAW;AAAA,EAAM,WAAW,EAAE;AAAA,EAC9C;AAEA,QAAM,WAAU,UAAK,aAAL,mBAAe;AAC/B,MAAI,QAAS,OAAM,KAAK,OAAO;AAE/B,SAAO,MAAM,KAAK,MAAM;AAC1B;AAgBO,SAAS,kBAAkB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAKwB;AACtB,QAAM,OAAO,qBAAqB,EAAE,aAAa,OAAO,UAAU,KAAK,MAAM,QAAQ;AACrF,MAAI,CAAC,KAAM,QAAO;A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;"}
1
+ {"version":3,"file":"build-composed-message.cjs","sources":["../../src/composer/build-composed-message.ts"],"sourcesContent":["import {\n type ChatOutbox,\n type ChatOutboxAttachment,\n type ChatOutboxEntry,\n withDeepAgentComposerMarkdown,\n} from '@athenaintel/agent-runtime';\nimport {\n type AttachableReference,\n withAttachedReferences,\n} from '@athenaintel/references/attachable';\nimport type { UploadedAsset } from './useFileUpload';\nimport type { QuoteData } from './QuoteContext';\nimport { buildAttachmentMarkdownWithAppUrl } from './AttachmentContext';\nimport {\n type ComposerSend,\n escapeCharacterReferences,\n} from '../chat-ui/composer/composer-message';\n\n/**\n * Assembles a composed message from attachments, a quote, and user text.\n * Used by both the TipTap Enter-key submit and the send-button click handler\n * to avoid duplicating the message-assembly logic.\n *\n * Returns an empty string if all inputs are empty.\n */\nexport function buildComposedMessage(opts: {\n attachments?: UploadedAsset[];\n quote?: QuoteData | null;\n userText?: string;\n appUrl?: string;\n}): string {\n const parts: string[] = [];\n\n if (opts.attachments && opts.attachments.length > 0) {\n const attachmentMd = buildAttachmentMarkdownWithAppUrl({\n attachments: opts.attachments,\n appUrl: opts.appUrl,\n });\n if (attachmentMd) parts.push(attachmentMd);\n }\n\n if (opts.quote) {\n const quotedLines = opts.quote.text.split('\\n').map((l) => `> ${l}`).join('\\n');\n const sourceLabel = opts.quote.sourceTitle\n ? `From \"${opts.quote.sourceTitle}\"`\n : opts.quote.sourceRole === 'assistant'\n ? 'Quoting assistant'\n : 'Quoting';\n parts.push(`${sourceLabel}:\\n${quotedLines}`);\n }\n\n const trimmed = opts.userText?.trim();\n if (trimmed) parts.push(trimmed);\n\n return parts.join('\\n\\n');\n}\n\n/**\n * The composed message a send delivers and the draft it came from: the same\n * attachments and quote around the editor's text as typed in one, and around\n * the editor's draft in the other (`ComposerSend`). `null` when there is\n * nothing to send.\n *\n * The quote and the attachment titles are text the person did not type in\n * the editor, and the message carries them as they are. The draft writes an\n * `&` in them that starts a character reference as `&amp;`, as the composer's\n * draft does for typed text, so it reads back as the message and stays a draft\n * of the message's own text (`isComposerMarkdownOfText`, which agora applies\n * too): a quoted `&lt;` would otherwise read as `<` in the draft and the\n * message would lose its composer markdown.\n */\nexport function buildComposedSend({\n attachments,\n quote,\n send,\n appUrl,\n}: {\n attachments?: UploadedAsset[];\n quote?: QuoteData | null;\n send: ComposerSend;\n appUrl?: string;\n}): ComposerSend | null {\n const text = buildComposedMessage({ attachments, quote, userText: send.text, appUrl });\n if (!text) return null;\n const draftMarkdown = buildComposedMessage({\n attachments: attachments?.map((attachment) => ({\n ...attachment,\n title: escapeCharacterReferences(attachment.title),\n })),\n quote: quote && {\n ...quote,\n text: escapeCharacterReferences(quote.text),\n ...(quote.sourceTitle !== undefined && {\n sourceTitle: escapeCharacterReferences(quote.sourceTitle),\n }),\n },\n userText: send.draftMarkdown,\n appUrl,\n });\n return { text, draftMarkdown };\n}\n\n/**\n * Holds a composed message in the chat outbox while sends are on hold (Athena can't be reached, or\n * earlier messages still wait): the uploaded attachments and the quote around the editor's text,\n * exactly as {@link buildComposedSend} would send them, so it goes with them once Athena is back.\n * The attachments are files already in Athena (an upload that finished before the drop); they are\n * named on the held message so the outbox asks Athena, right before it goes, that each can still\n * be opened. Cancel or Edit gives back the composed draft: the attachments as mentions in the\n * editor, the quote as quoted lines, nothing lost. `carried` are files already in Athena the\n * editor's own draft carries (mentions a held message gave back), named with the pills. `null`\n * when there is nothing to hold.\n */\nexport function holdComposedSend({\n outbox,\n attachments,\n carried = [],\n quote,\n send,\n appUrl,\n addressedAgents,\n attachedReferences = [],\n}: {\n outbox: ChatOutbox;\n attachments?: UploadedAsset[];\n carried?: readonly ChatOutboxAttachment[];\n quote?: QuoteData | null;\n send: ComposerSend;\n appUrl?: string;\n /** The agents the message names (`message.metadata.addressedAgents`). */\n addressedAgents?: readonly string[];\n /** The references attached to the message (`message.metadata.attachedReferences`). */\n attachedReferences?: readonly AttachableReference[];\n}): ChatOutboxEntry | null {\n const composed = buildComposedSend({ attachments, quote, send, appUrl });\n if (!composed) return null;\n const named = new Map<string, ChatOutboxAttachment>();\n for (const attachment of attachments ?? []) {\n named.set(attachment.id, {\n assetId: attachment.id,\n title: attachment.title,\n ...(attachment.mediaType && { mediaType: attachment.mediaType }),\n });\n }\n for (const attachment of carried) {\n if (!named.has(attachment.assetId)) named.set(attachment.assetId, attachment);\n }\n return outbox.hold({\n text: composed.text,\n composerMarkdown: composed.draftMarkdown,\n metadata: withAttachedReferences(\n withDeepAgentComposerMarkdown({\n metadata: undefined,\n text: composed.text,\n markdown: composed.draftMarkdown,\n }),\n attachedReferences,\n ),\n attachments: [...named.values()],\n ...(addressedAgents && { addressedAgents }),\n });\n}\n"],"names":["buildAttachmentMarkdownWithAppUrl","escapeCharacterReferences","withAttachedReferences","withDeepAgentComposerMarkdown"],"mappings":";;;;;;AAyBO,SAAS,qBAAqB,MAK1B;;AACT,QAAM,QAAkB,CAAA;AAExB,MAAI,KAAK,eAAe,KAAK,YAAY,SAAS,GAAG;AACnD,UAAM,eAAeA,kBAAAA,kCAAkC;AAAA,MACrD,aAAa,KAAK;AAAA,MAClB,QAAQ,KAAK;AAAA,IAAA,CACd;AACD,QAAI,aAAc,OAAM,KAAK,YAAY;AAAA,EAC3C;AAEA,MAAI,KAAK,OAAO;AACd,UAAM,cAAc,KAAK,MAAM,KAAK,MAAM,IAAI,EAAE,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,EAAE,KAAK,IAAI;AAC9E,UAAM,cAAc,KAAK,MAAM,cAC3B,SAAS,KAAK,MAAM,WAAW,MAC/B,KAAK,MAAM,eAAe,cACxB,sBACA;AACN,UAAM,KAAK,GAAG,WAAW;AAAA,EAAM,WAAW,EAAE;AAAA,EAC9C;AAEA,QAAM,WAAU,UAAK,aAAL,mBAAe;AAC/B,MAAI,QAAS,OAAM,KAAK,OAAO;AAE/B,SAAO,MAAM,KAAK,MAAM;AAC1B;AAgBO,SAAS,kBAAkB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF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,+CAA8B;AAAA,QAC5B,UAAU;AAAA,QACV,MAAM,SAAS;AAAA,QACf,UAAU,SAAS;AAAA,MAAA,CACpB;AAAA,MACD;AAAA,IAAA;AAAA,IAEF,aAAa,CAAC,GAAG,MAAM,QAAQ;AAAA,IAC/B,GAAI,mBAAmB,EAAE,gBAAA;AAAA,EAAgB,CAC1C;AACH;;;;"}
@@ -1,4 +1,5 @@
1
1
  import { type ChatOutbox, type ChatOutboxAttachment, type ChatOutboxEntry } from '../agent-runtime/src/index';
2
+ import { type AttachableReference } from '../references/src/attachable';
2
3
  import type { UploadedAsset } from './useFileUpload';
3
4
  import type { QuoteData } from './QuoteContext';
4
5
  import { type ComposerSend } from '../chat-ui/composer/composer-message';
@@ -46,11 +47,15 @@ export declare function buildComposedSend({ attachments, quote, send, appUrl, }:
46
47
  * editor's own draft carries (mentions a held message gave back), named with the pills. `null`
47
48
  * when there is nothing to hold.
48
49
  */
49
- export declare function holdComposedSend({ outbox, attachments, carried, quote, send, appUrl, }: {
50
+ export declare function holdComposedSend({ outbox, attachments, carried, quote, send, appUrl, addressedAgents, attachedReferences, }: {
50
51
  outbox: ChatOutbox;
51
52
  attachments?: UploadedAsset[];
52
53
  carried?: readonly ChatOutboxAttachment[];
53
54
  quote?: QuoteData | null;
54
55
  send: ComposerSend;
55
56
  appUrl?: string;
57
+ /** The agents the message names (`message.metadata.addressedAgents`). */
58
+ addressedAgents?: readonly string[];
59
+ /** The references attached to the message (`message.metadata.attachedReferences`). */
60
+ attachedReferences?: readonly AttachableReference[];
56
61
  }): ChatOutboxEntry | null;
@@ -1,3 +1,4 @@
1
+ import { withAttachedReferences } from "../references/src/attachable.js";
1
2
  import { buildAttachmentMarkdownWithAppUrl } from "./AttachmentContext.js";
2
3
  import { escapeCharacterReferences } from "../chat-ui/composer/composer-message.js";
3
4
  import { withDeepAgentComposerMarkdown } from "../agent-runtime/src/composer-markdown.js";
@@ -52,7 +53,9 @@ function holdComposedSend({
52
53
  carried = [],
53
54
  quote,
54
55
  send,
55
- appUrl
56
+ appUrl,
57
+ addressedAgents,
58
+ attachedReferences = []
56
59
  }) {
57
60
  const composed = buildComposedSend({ attachments, quote, send, appUrl });
58
61
  if (!composed) return null;
@@ -70,12 +73,16 @@ function holdComposedSend({
70
73
  return outbox.hold({
71
74
  text: composed.text,
72
75
  composerMarkdown: composed.draftMarkdown,
73
- metadata: withDeepAgentComposerMarkdown({
74
- metadata: void 0,
75
- text: composed.text,
76
- markdown: composed.draftMarkdown
77
- }),
78
- attachments: [...named.values()]
76
+ metadata: withAttachedReferences(
77
+ withDeepAgentComposerMarkdown({
78
+ metadata: void 0,
79
+ text: composed.text,
80
+ markdown: composed.draftMarkdown
81
+ }),
82
+ attachedReferences
83
+ ),
84
+ attachments: [...named.values()],
85
+ ...addressedAgents && { addressedAgents }
79
86
  });
80
87
  }
81
88
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"build-composed-message.js","sources":["../../src/composer/build-composed-message.ts"],"sourcesContent":["import {\n type ChatOutbox,\n type ChatOutboxAttachment,\n type ChatOutboxEntry,\n withDeepAgentComposerMarkdown,\n} from '@athenaintel/agent-runtime';\nimport type { UploadedAsset } from './useFileUpload';\nimport type { QuoteData } from './QuoteContext';\nimport { buildAttachmentMarkdownWithAppUrl } from './AttachmentContext';\nimport {\n type ComposerSend,\n escapeCharacterReferences,\n} from '../chat-ui/composer/composer-message';\n\n/**\n * Assembles a composed message from attachments, a quote, and user text.\n * Used by both the TipTap Enter-key submit and the send-button click handler\n * to avoid duplicating the message-assembly logic.\n *\n * Returns an empty string if all inputs are empty.\n */\nexport function buildComposedMessage(opts: {\n attachments?: UploadedAsset[];\n quote?: QuoteData | null;\n userText?: string;\n appUrl?: string;\n}): string {\n const parts: string[] = [];\n\n if (opts.attachments && opts.attachments.length > 0) {\n const attachmentMd = buildAttachmentMarkdownWithAppUrl({\n attachments: opts.attachments,\n appUrl: opts.appUrl,\n });\n if (attachmentMd) parts.push(attachmentMd);\n }\n\n if (opts.quote) {\n const quotedLines = opts.quote.text.split('\\n').map((l) => `> ${l}`).join('\\n');\n const sourceLabel = opts.quote.sourceTitle\n ? `From \"${opts.quote.sourceTitle}\"`\n : opts.quote.sourceRole === 'assistant'\n ? 'Quoting assistant'\n : 'Quoting';\n parts.push(`${sourceLabel}:\\n${quotedLines}`);\n }\n\n const trimmed = opts.userText?.trim();\n if (trimmed) parts.push(trimmed);\n\n return parts.join('\\n\\n');\n}\n\n/**\n * The composed message a send delivers and the draft it came from: the same\n * attachments and quote around the editor's text as typed in one, and around\n * the editor's draft in the other (`ComposerSend`). `null` when there is\n * nothing to send.\n *\n * The quote and the attachment titles are text the person did not type in\n * the editor, and the message carries them as they are. The draft writes an\n * `&` in them that starts a character reference as `&amp;`, as the composer's\n * draft does for typed text, so it reads back as the message and stays a draft\n * of the message's own text (`isComposerMarkdownOfText`, which agora applies\n * too): a quoted `&lt;` would otherwise read as `<` in the draft and the\n * message would lose its composer markdown.\n */\nexport function buildComposedSend({\n attachments,\n quote,\n send,\n appUrl,\n}: {\n attachments?: UploadedAsset[];\n quote?: QuoteData | null;\n send: ComposerSend;\n appUrl?: string;\n}): ComposerSend | null {\n const text = buildComposedMessage({ attachments, quote, userText: send.text, appUrl });\n if (!text) return null;\n const draftMarkdown = buildComposedMessage({\n attachments: attachments?.map((attachment) => ({\n ...attachment,\n title: escapeCharacterReferences(attachment.title),\n })),\n quote: quote && {\n ...quote,\n text: escapeCharacterReferences(quote.text),\n ...(quote.sourceTitle !== undefined && {\n sourceTitle: escapeCharacterReferences(quote.sourceTitle),\n }),\n },\n userText: send.draftMarkdown,\n appUrl,\n });\n return { text, draftMarkdown };\n}\n\n/**\n * Holds a composed message in the chat outbox while sends are on hold (Athena can't be reached, or\n * earlier messages still wait): the uploaded attachments and the quote around the editor's text,\n * exactly as {@link buildComposedSend} would send them, so it goes with them once Athena is back.\n * The attachments are files already in Athena (an upload that finished before the drop); they are\n * named on the held message so the outbox asks Athena, right before it goes, that each can still\n * be opened. Cancel or Edit gives back the composed draft: the attachments as mentions in the\n * editor, the quote as quoted lines, nothing lost. `carried` are files already in Athena the\n * editor's own draft carries (mentions a held message gave back), named with the pills. `null`\n * when there is nothing to hold.\n */\nexport function holdComposedSend({\n outbox,\n attachments,\n carried = [],\n quote,\n send,\n appUrl,\n}: {\n outbox: ChatOutbox;\n attachments?: UploadedAsset[];\n carried?: readonly ChatOutboxAttachment[];\n quote?: QuoteData | null;\n send: ComposerSend;\n appUrl?: string;\n}): ChatOutboxEntry | null {\n const composed = buildComposedSend({ attachments, quote, send, appUrl });\n if (!composed) return null;\n const named = new Map<string, ChatOutboxAttachment>();\n for (const attachment of attachments ?? []) {\n named.set(attachment.id, {\n assetId: attachment.id,\n title: attachment.title,\n ...(attachment.mediaType && { mediaType: attachment.mediaType }),\n });\n }\n for (const attachment of carried) {\n if (!named.has(attachment.assetId)) named.set(attachment.assetId, attachment);\n }\n return outbox.hold({\n text: composed.text,\n composerMarkdown: composed.draftMarkdown,\n metadata: withDeepAgentComposerMarkdown({\n metadata: undefined,\n text: composed.text,\n markdown: composed.draftMarkdown,\n }),\n attachments: [...named.values()],\n });\n}\n"],"names":[],"mappings":";;;AAqBO,SAAS,qBAAqB,MAK1B;;AACT,QAAM,QAAkB,CAAA;AAExB,MAAI,KAAK,eAAe,KAAK,YAAY,SAAS,GAAG;AACnD,UAAM,eAAe,kCAAkC;AAAA,MACrD,aAAa,KAAK;AAAA,MAClB,QAAQ,KAAK;AAAA,IAAA,CACd;AACD,QAAI,aAAc,OAAM,KAAK,YAAY;AAAA,EAC3C;AAEA,MAAI,KAAK,OAAO;AACd,UAAM,cAAc,KAAK,MAAM,KAAK,MAAM,IAAI,EAAE,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,EAAE,KAAK,IAAI;AAC9E,UAAM,cAAc,KAAK,MAAM,cAC3B,SAAS,KAAK,MAAM,WAAW,MAC/B,KAAK,MAAM,eAAe,cACxB,sBACA;AACN,UAAM,KAAK,GAAG,WAAW;AAA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,IAAI,WAAW,SAAS,UAAU;AAAA,EAC9E;AACA,SAAO,OAAO,KAAK;AAAA,IACjB,MAAM,SAAS;AAAA,IACf,kBAAkB,SAAS;AAAA,IAC3B,UAAU,8BAA8B;AAAA,MACtC,UAAU;AAAA,MACV,MAAM,SAAS;AAAA,MACf,UAAU,SAAS;AAAA,IAAA,CACpB;AAAA,IACD,aAAa,CAAC,GAAG,MAAM,QAAQ;AAAA,EAAA,CAChC;AACH;"}
1
+ {"version":3,"file":"build-composed-message.js","sources":["../../src/composer/build-composed-message.ts"],"sourcesContent":["import {\n type ChatOutbox,\n type ChatOutboxAttachment,\n type ChatOutboxEntry,\n withDeepAgentComposerMarkdown,\n} from '@athenaintel/agent-runtime';\nimport {\n type AttachableReference,\n withAttachedReferences,\n} from '@athenaintel/references/attachable';\nimport type { UploadedAsset } from './useFileUpload';\nimport type { QuoteData } from './QuoteContext';\nimport { buildAttachmentMarkdownWithAppUrl } from './AttachmentContext';\nimport {\n type ComposerSend,\n escapeCharacterReferences,\n} from '../chat-ui/composer/composer-message';\n\n/**\n * Assembles a composed message from attachments, a quote, and user text.\n * Used by both the TipTap Enter-key submit and the send-button click handler\n * to avoid duplicating the message-assembly logic.\n *\n * Returns an empty string if all inputs are empty.\n */\nexport function buildComposedMessage(opts: {\n attachments?: UploadedAsset[];\n quote?: QuoteData | null;\n userText?: string;\n appUrl?: string;\n}): string {\n const parts: string[] = [];\n\n if (opts.attachments && opts.attachments.length > 0) {\n const attachmentMd = buildAttachmentMarkdownWithAppUrl({\n attachments: opts.attachments,\n appUrl: opts.appUrl,\n });\n if (attachmentMd) parts.push(attachmentMd);\n }\n\n if (opts.quote) {\n const quotedLines = opts.quote.text.split('\\n').map((l) => `> ${l}`).join('\\n');\n const sourceLabel = opts.quote.sourceTitle\n ? `From \"${opts.quote.sourceTitle}\"`\n : opts.quote.sourceRole === 'assistant'\n ? 'Quoting assistant'\n : 'Quoting';\n parts.push(`${sourceLabel}:\\n${quotedLines}`);\n }\n\n const trimmed = opts.userText?.trim();\n if (trimmed) parts.push(trimmed);\n\n return parts.join('\\n\\n');\n}\n\n/**\n * The composed message a send delivers and the draft it came from: the same\n * attachments and quote around the editor's text as typed in one, and around\n * the editor's draft in the other (`ComposerSend`). `null` when there is\n * nothing to send.\n *\n * The quote and the attachment titles are text the person did not type in\n * the editor, and the message carries them as they are. The draft writes an\n * `&` in them that starts a character reference as `&amp;`, as the composer's\n * draft does for typed text, so it reads back as the message and stays a draft\n * of the message's own text (`isComposerMarkdownOfText`, which agora applies\n * too): a quoted `&lt;` would otherwise read as `<` in the draft and the\n * message would lose its composer markdown.\n */\nexport function buildComposedSend({\n attachments,\n quote,\n send,\n appUrl,\n}: {\n attachments?: UploadedAsset[];\n quote?: QuoteData | null;\n send: ComposerSend;\n appUrl?: string;\n}): ComposerSend | null {\n const text = buildComposedMessage({ attachments, quote, userText: send.text, appUrl });\n if (!text) return null;\n const draftMarkdown = buildComposedMessage({\n attachments: attachments?.map((attachment) => ({\n ...attachment,\n title: escapeCharacterReferences(attachment.title),\n })),\n quote: quote && {\n ...quote,\n text: escapeCharacterReferences(quote.text),\n ...(quote.sourceTitle !== undefined && {\n sourceTitle: escapeCharacterReferences(quote.sourceTitle),\n }),\n },\n userText: send.draftMarkdown,\n appUrl,\n });\n return { text, draftMarkdown };\n}\n\n/**\n * Holds a composed message in the chat outbox while sends are on hold (Athena can't be reached, or\n * earlier messages still wait): the uploaded attachments and the quote around the editor's text,\n * exactly as {@link buildComposedSend} would send them, so it goes with them once Athena is back.\n * The attachments are files already in Athena (an upload that finished before the drop); they are\n * named on the held message so the outbox asks Athena, right before it goes, that each can still\n * be opened. Cancel or Edit gives back the composed draft: the attachments as mentions in the\n * editor, the quote as quoted lines, nothing lost. `carried` are files already in Athena the\n * editor's own draft carries (mentions a held message gave back), named with the pills. `null`\n * when there is nothing to hold.\n */\nexport function holdComposedSend({\n outbox,\n attachments,\n carried = [],\n quote,\n send,\n appUrl,\n addressedAgents,\n attachedReferences = [],\n}: {\n outbox: ChatOutbox;\n attachments?: UploadedAsset[];\n carried?: readonly ChatOutboxAttachment[];\n quote?: QuoteData | null;\n send: ComposerSend;\n appUrl?: string;\n /** The agents the message names (`message.metadata.addressedAgents`). */\n addressedAgents?: readonly string[];\n /** The references attached to the message (`message.metadata.attachedReferences`). */\n attachedReferences?: readonly AttachableReference[];\n}): ChatOutboxEntry | null {\n const composed = buildComposedSend({ attachments, quote, send, appUrl });\n if (!composed) return null;\n const named = new Map<string, ChatOutboxAttachment>();\n for (const attachment of attachments ?? []) {\n named.set(attachment.id, {\n assetId: attachment.id,\n title: attachment.title,\n ...(attachment.mediaType && { mediaType: attachment.mediaType }),\n });\n }\n for (const attachment of carried) {\n if (!named.has(attachment.assetId)) named.set(attachment.assetId, attachment);\n }\n return outbox.hold({\n text: composed.text,\n composerMarkdown: composed.draftMarkdown,\n metadata: withAttachedReferences(\n withDeepAgentComposerMarkdown({\n metadata: undefined,\n text: composed.text,\n markdown: composed.draftMarkdown,\n }),\n attachedReferences,\n ),\n attachments: [...named.values()],\n ...(addressedAgents && { addressedAgents }),\n });\n}\n"],"names":[],"mappings":";;;;AAyBO,SAAS,qBAAqB,MAK1B;;AACT,QAAM,QAAkB,CAAA;AAExB,MAAI,KAAK,eAAe,KAAK,YAAY,SAAS,GAAG;AACnD,UAAM,eAAe,kCAAkC;AAAA,MACrD,aAAa,KAAK;AAAA,MAClB,QAAQ,KAAK;AAAA,IAAA,CACd;AACD,QAAI,aAAc,OAAM,KAAK,YAAY;AAAA,EAC3C;AAEA,MAAI,KAAK,OAAO;AACd,UAAM,cAAc,KAAK,MAAM,KAAK,MAAM,IAAI,EAAE,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,EAAE,KAAK,IAAI;AAC9E,UAAM,cAAc,KAAK,MAAM,cAC3B,SAAS,KAAK,MAAM,WAAW,MAC/B,KAAK,MAAM,eAAe,cACxB,sBACA;AACN,UAAM,KAAK,GAAG,WAAW;AAAA,EAAM,WAAW,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WAAW,OAAO,EAAG,OAAM,IAAI,WAAW,SAAS,UAAU;AAAA,EAC9E;AACA,SAAO,OAAO,KAAK;AAAA,IACjB,MAAM,SAAS;AAAA,IACf,kBAAkB,SAAS;AAAA,IAC3B,UAAU;AAAA,MACR,8BAA8B;AAAA,QAC5B,UAAU;AAAA,QACV,MAAM,SAAS;AAAA,QACf,UAAU,SAAS;AAAA,MAAA,CACpB;AAAA,MACD;AAAA,IAAA;AAAA,IAEF,aAAa,CAAC,GAAG,MAAM,QAAQ;AAAA,IAC/B,GAAI,mBAAmB,EAAE,gBAAA;AAAA,EAAgB,CAC1C;AACH;"}
@@ -6,6 +6,7 @@ const athenaDiagnostics = require("../diagnostics/athena-diagnostics.cjs");
6
6
  const errors = require("../diagnostics/errors.cjs");
7
7
  const statewireSessionLane = require("../runtime/statewire-session-lane.cjs");
8
8
  const statewireThreadList = require("../threads/statewire-thread-list.cjs");
9
+ const runSend = require("../agent-runtime/src/run-send.cjs");
9
10
  function createComposerHandoffStore() {
10
11
  return {
11
12
  pending: [],
@@ -76,7 +77,7 @@ function applyComposerWrite({
76
77
  store,
77
78
  write
78
79
  }) {
79
- var _a;
80
+ var _a, _b;
80
81
  const current = target.composer.getState().text ?? "";
81
82
  const next = mergeComposerDraft({ current, write });
82
83
  target.composer.setText(next);
@@ -89,7 +90,10 @@ function applyComposerWrite({
89
90
  data: { phase: "applied", send: write.send, focus: write.focus, chars: next.length }
90
91
  });
91
92
  if (write.send) {
92
- return Promise.resolve(target.composer.send({ steer: false })).then(() => void 0);
93
+ const isRunning = ((_b = target.thread) == null ? void 0 : _b.call(target).getState().isRunning) ?? false;
94
+ return Promise.resolve(target.composer.send(runSend.autoComposerSendOptions(isRunning))).then(
95
+ () => void 0
96
+ );
93
97
  }
94
98
  return void 0;
95
99
  }
@@ -1 +1 @@
1
- {"version":3,"file":"composer-handoff.cjs","sources":["../../src/composer/composer-handoff.ts"],"sourcesContent":["/**\n * Composer handoff: writes to the chat composer from host UI that lives\n * outside `<AthenaChat>` (a sidebar, an agenda card, a workflow button).\n *\n * Two problems it solves for `useAppendToComposer` / `useSendMessage`:\n *\n * 1. A write before the chat is ready is lost. While the thread list is still\n * resolving the active thread, or the thread's history is still loading,\n * the composer the hooks write to belongs to a mount that is about to be\n * replaced (thread-list mode keys the statewire subtree by thread), and\n * the draft goes with it. The store below lives ABOVE that mount, so a\n * write made too early waits here and the ready mount drains it.\n * 2. A prefilled draft should put the caret after the text so the user can\n * keep typing or dictating. The Tiptap editor mirrors runtime text on a\n * later tick; the `focusOnNextMirror` flag asks it to focus at the end\n * right after that mirror lands, instead of the host guessing a delay.\n *\n * Every queued write is bound to the statewire thread it was made for and\n * drains only into that thread's mount; a thread switch, an identity change\n * or a provider unmount drops what waits with a `composer_write_dropped`\n * error, never into another user's or another thread's composer.\n */\nimport { createContext, useCallback, useContext } from 'react';\nimport { useAuiState } from '@assistant-ui/react';\nimport type { ChatOutboxAttachment } from '@athenaintel/agent-runtime';\nimport { athenaDiagnostics } from '../diagnostics/athena-diagnostics';\nimport { AthenaSdkError } from '../diagnostics/errors';\nimport { useStatewireSessionLanePending } from '../runtime/statewire-session-lane';\nimport { useAthenaStatewireThreadList } from '../threads/statewire-thread-list';\n\n/** The slice of the assistant-ui client the handoff writes to. */\nexport interface ComposerTarget {\n composer: {\n getState: () => { text: string };\n setText: (text: string) => void;\n send: (options?: { steer?: boolean }) => unknown;\n };\n}\n\nexport interface ComposerWrite {\n text: string;\n /** Replace the draft instead of appending on a new line. */\n replace: boolean;\n /** Submit right after writing. */\n send: boolean;\n /** Put the caret at the end of the draft once the editor shows it. */\n focus: boolean;\n /** The statewire thread the write was made for; it drains only into that thread's mount. */\n threadId: string | null;\n /** Settled once the write has been applied (and, for `send`, with the send's outcome). */\n resolve?: (outcome: Promise<void> | void) => void;\n /** Settled with `composer_write_dropped` when the write can no longer land. */\n reject?: (error: AthenaSdkError) => void;\n}\n\nexport interface ComposerHandoffStore {\n /** Writes waiting for a ready composer, oldest first. Adjacent plain appends fold together. */\n pending: ComposerWrite[];\n /** Set by a `focus` write; the editor consumes it after mirroring the draft. */\n focusOnNextMirror: boolean;\n /** Registered by the mounted editor: place the caret at the end of the draft. */\n focusEnd: (() => void) | null;\n /** Set by `useFocusComposer` before the editor mounted; the editor consumes it when it does. */\n focusOnMount: boolean;\n /**\n * Per thread, the attachments of messages the chat outbox gave back to the composer (Cancel, or\n * Edit on one that couldn't be sent): files already in Athena, back in the draft as mentions. A\n * message held again from that draft names those still in it, so the outbox asks Athena about\n * them again before it goes ({@link rememberRestoredAttachments}, {@link takeRestoredAttachments}).\n */\n restoredAttachments?: Map<string, ChatOutboxAttachment[]>;\n}\n\nexport function createComposerHandoffStore(): ComposerHandoffStore {\n return {\n pending: [],\n focusOnNextMirror: false,\n focusEnd: null,\n focusOnMount: false,\n restoredAttachments: new Map(),\n };\n}\n\n/** A held message given back to `threadId`'s composer: remember the attachments it carried. */\nexport function rememberRestoredAttachments({\n store,\n threadId,\n attachments,\n}: {\n store: ComposerHandoffStore;\n threadId: string;\n attachments: readonly ChatOutboxAttachment[];\n}): void {\n if (attachments.length === 0) return;\n store.restoredAttachments ??= new Map();\n const kept = store.restoredAttachments.get(threadId) ?? [];\n const known = new Set(kept.map((attachment) => attachment.assetId));\n store.restoredAttachments.set(threadId, [\n ...kept,\n ...attachments.filter((attachment) => !known.has(attachment.assetId)),\n ]);\n}\n\n/**\n * The remembered attachments of `threadId`'s draft whose mentions it still holds, for the message\n * leaving it now; the composer forgets them all (sent, held again, or removed from the draft).\n */\nexport function takeRestoredAttachments({\n store,\n threadId,\n assetIdsInDraft,\n}: {\n store: ComposerHandoffStore | null;\n threadId: string;\n assetIdsInDraft: ReadonlySet<string>;\n}): ChatOutboxAttachment[] {\n const kept = store?.restoredAttachments?.get(threadId);\n if (!kept) return [];\n store?.restoredAttachments?.delete(threadId);\n return kept.filter((attachment) => assetIdsInDraft.has(attachment.assetId));\n}\n\nexport const ComposerHandoffContext = createContext<ComposerHandoffStore | null>(null);\n\n/** The provider's handoff store, or null outside `AthenaProvider`. */\nexport function useComposerHandoffStore(): ComposerHandoffStore | null {\n return useContext(ComposerHandoffContext);\n}\n\n/**\n * Puts the caret at the end of the composer's draft and leaves the draft as it is; asked before the\n * editor has mounted, it focuses the editor as it mounts. For a host that shows the chat again and\n * wants typing to land in it (a launcher window a shortcut brings back).\n */\nexport function useFocusComposer(): () => void {\n const store = useComposerHandoffStore();\n return useCallback(() => {\n if (store) focusComposer({ store });\n }, [store]);\n}\n\n/** The caret to the end of the draft now, or, with no editor mounted yet, as one mounts. */\nexport function focusComposer({ store }: { store: ComposerHandoffStore }): void {\n if (store.focusEnd) store.focusEnd();\n else store.focusOnMount = true;\n}\n\n/**\n * Whether a composer write lands now: in thread-list mode the list has\n * resolved which thread is active, that thread's history has loaded, and the\n * chat's session lane is known (the sign-in provider above has resolved who is\n * signed in; see `StatewireSessionLane`). Until then the composer the hooks\n * write to is the one of a mount that is about to be replaced, and the draft\n * goes with it, or a send would go into a parked lane that refuses it unsent.\n *\n * Deliberately not the socket status: a never-started chat sits in\n * `standby` until its first send and must still take a prefill.\n */\nexport function useComposerReady(): boolean {\n const list = useAthenaStatewireThreadList();\n const threadLoading = useAuiState((s) => s.optional.thread?.isLoading ?? false);\n const lanePending = useStatewireSessionLanePending();\n return !(list?.isLoading ?? false) && !threadLoading && !lanePending;\n}\n\n/** The draft after `write`: `replace` (or an empty draft) takes the text as is. */\nexport function mergeComposerDraft({\n current,\n write,\n}: {\n current: string;\n write: Pick<ComposerWrite, 'text' | 'replace'>;\n}): string {\n if (write.replace || !current) return write.text;\n return `${current}\\n${write.text}`;\n}\n\n/**\n * Write into the live composer. Returns the send's outcome for a `send`\n * write so callers can await it.\n */\nexport function applyComposerWrite({\n target,\n store,\n write,\n}: {\n target: ComposerTarget;\n store: ComposerHandoffStore | null;\n write: ComposerWrite;\n}): Promise<void> | void {\n const current = target.composer.getState().text ?? '';\n const next = mergeComposerDraft({ current, write });\n target.composer.setText(next);\n if (write.focus && store) {\n // An unchanged draft never re-mirrors, so focus at once; otherwise the\n // editor focuses itself right after it has shown the new text.\n if (next === current) store.focusEnd?.();\n else store.focusOnNextMirror = true;\n }\n athenaDiagnostics.emit('composer.handoff', {\n level: 'debug',\n data: { phase: 'applied', send: write.send, focus: write.focus, chars: next.length },\n });\n if (write.send) {\n return Promise.resolve(target.composer.send({ steer: false })).then(() => undefined);\n }\n return undefined;\n}\n\n/**\n * Hold a write until the composer is ready. Writes keep their order; a plain\n * append folds into a directly preceding plain append for the same thread\n * (one draft, not two), while a replace or a send is kept as its own step so\n * no message is lost and every send settles on its own.\n */\nexport function queueComposerWrite({\n store,\n write,\n}: {\n store: ComposerHandoffStore;\n write: ComposerWrite;\n}): void {\n const last = store.pending[store.pending.length - 1];\n const foldable =\n last !== undefined &&\n !last.send &&\n !write.send &&\n !write.replace &&\n last.threadId === write.threadId &&\n last.resolve === undefined &&\n write.resolve === undefined;\n if (foldable) {\n last.text = mergeComposerDraft({ current: last.text, write });\n last.focus = last.focus || write.focus;\n } else {\n store.pending.push(write);\n }\n athenaDiagnostics.emit('composer.handoff', {\n level: 'debug',\n data: { phase: 'deferred', send: write.send, focus: write.focus, queued: store.pending.length },\n });\n}\n\nfunction dropWrite({ write, reason }: { write: ComposerWrite; reason: string }): void {\n const error = new AthenaSdkError({\n code: 'composer_write_dropped',\n message: `A composer ${write.send ? 'send' : 'draft'} queued before the chat was ready was dropped: ${reason}.`,\n hint: 'Make the write again from the chat that is active now.',\n context: { threadId: write.threadId, send: write.send },\n });\n athenaDiagnostics.emit('composer.handoff', {\n level: 'warn',\n error,\n data: { phase: 'dropped', send: write.send, reason, threadId: write.threadId },\n });\n write.reject?.(error);\n}\n\n/**\n * Deliver the pending writes, in order, into a now-ready composer. A write\n * made for another thread is dropped (rejected), never applied here.\n */\nexport function drainComposerHandoff({\n store,\n target,\n threadId,\n}: {\n store: ComposerHandoffStore;\n target: ComposerTarget;\n /** The statewire thread of the mount that is draining. */\n threadId: string | null;\n}): void {\n const writes = store.pending;\n if (writes.length === 0) return;\n store.pending = [];\n for (const write of writes) {\n if (write.threadId !== null && threadId !== null && write.threadId !== threadId) {\n dropWrite({ write, reason: `it was made for thread ${write.threadId}, thread ${threadId} is active` });\n continue;\n }\n const outcome = applyComposerWrite({ target, store, write });\n write.resolve?.(outcome);\n }\n}\n\n/** Drop every pending write (identity changed, provider unmounted). */\nexport function clearComposerHandoff({\n store,\n reason,\n}: {\n store: ComposerHandoffStore;\n reason: string;\n}): void {\n // Another identity, or no provider: the attachments given back belong to drafts that are gone.\n store.restoredAttachments?.clear();\n const writes = store.pending;\n if (writes.length === 0) return;\n store.pending = [];\n for (const write of writes) dropWrite({ write, reason });\n}\n"],"names":["createContext","useContext","useCallback","useAthenaStatewireThreadList","useAuiState","useStatewireSessionLanePending","athenaDiagnostics","AthenaSdkError"],"mappings":";;;;;;;;AAyEO,SAAS,6BAAmD;AACjE,SAAO;AAAA,IACL,SAAS,CAAA;AAAA,IACT,mBAAmB;AAAA,IACnB,UAAU;AAAA,IACV,cAAc;AAAA,IACd,yCAAyB,IAAA;AAAA,EAAI;AAEjC;AAGO,SAAS,4BAA4B;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AACF,GAIS;AACP,MAAI,YAAY,WAAW,EAAG;AAC9B,QAAM,wBAAN,MAAM,0CAA4B,IAAA;AAClC,QAAM,OAAO,MAAM,oBAAoB,IAAI,QAAQ,KAAK,CAAA;AACxD,QAAM,QAAQ,IAAI,IAAI,KAAK,IAAI,CAAC,eAAe,WAAW,OAAO,CAAC;AAClE,QAAM,oBAAoB,IAAI,UAAU;AAAA,IACtC,GAAG;AAAA,IACH,GAAG,YAAY,OAAO,CAAC,eAAe,CAAC,MAAM,IAAI,WAAW,OAAO,CAAC;AAAA,EAAA,CACrE;AACH;AAMO,SAAS,wBAAwB;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AACF,GAI2B;;AACzB,QAAM,QAAO,oCAAO,wBAAP,mBAA4B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AW,MAAM,MAAM,MAAM,QAAQ,UAAU,MAAM,SAAA;AAAA,EAAS,CAC9E;AACD,cAAM,WAAN,+BAAe;AACjB;AAMO,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AACF,GAKS;;AACP,QAAM,SAAS,MAAM;AACrB,MAAI,OAAO,WAAW,EAAG;AACzB,QAAM,UAAU,CAAA;AAChB,aAAW,SAAS,QAAQ;AAC1B,QAAI,MAAM,aAAa,QAAQ,aAAa,QAAQ,MAAM,aAAa,UAAU;AAC/E,gBAAU,EAAE,OAAO,QAAQ,0BAA0B,MAAM,QAAQ,YAAY,QAAQ,aAAA,CAAc;AACrG;AAAA,IACF;AACA,UAAM,UAAU,mBAAmB,EAAE,QAAQ,OAAO,OAAO;AAC3D,gBAAM,YAAN,+BAAgB;AAAA,EAClB;AACF;AAGO,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA;AACF,GAGS;;AAEP,cAAM,wBAAN,mBAA2B;AAC3B,QAAM,SAAS,MAAM;AACrB,MAAI,OAAO,WAAW,EAAG;AACzB,QAAM,UAAU,CAAA;AAChB,aAAW,SAAS,OAAQ,WAAU,EAAE,OAAO,QAAQ;AACzD;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"composer-handoff.cjs","sources":["../../src/composer/composer-handoff.ts"],"sourcesContent":["/**\n * Composer handoff: writes to the chat composer from host UI that lives\n * outside `<AthenaChat>` (a sidebar, an agenda card, a workflow button).\n *\n * Two problems it solves for `useAppendToComposer` / `useSendMessage`:\n *\n * 1. A write before the chat is ready is lost. While the thread list is still\n * resolving the active thread, or the thread's history is still loading,\n * the composer the hooks write to belongs to a mount that is about to be\n * replaced (thread-list mode keys the statewire subtree by thread), and\n * the draft goes with it. The store below lives ABOVE that mount, so a\n * write made too early waits here and the ready mount drains it.\n * 2. A prefilled draft should put the caret after the text so the user can\n * keep typing or dictating. The Tiptap editor mirrors runtime text on a\n * later tick; the `focusOnNextMirror` flag asks it to focus at the end\n * right after that mirror lands, instead of the host guessing a delay.\n *\n * Every queued write is bound to the statewire thread it was made for and\n * drains only into that thread's mount; a thread switch, an identity change\n * or a provider unmount drops what waits with a `composer_write_dropped`\n * error, never into another user's or another thread's composer.\n */\nimport { createContext, useCallback, useContext } from 'react';\nimport { useAuiState } from '@assistant-ui/react';\nimport { autoComposerSendOptions, type ChatOutboxAttachment } from '@athenaintel/agent-runtime';\nimport { athenaDiagnostics } from '../diagnostics/athena-diagnostics';\nimport { AthenaSdkError } from '../diagnostics/errors';\nimport { useStatewireSessionLanePending } from '../runtime/statewire-session-lane';\nimport { useAthenaStatewireThreadList } from '../threads/statewire-thread-list';\n\n/** The slice of the assistant-ui client the handoff writes to. */\nexport interface ComposerTarget {\n composer: {\n getState: () => { text: string };\n setText: (text: string) => void;\n send: (options?: { steer?: boolean }) => unknown;\n };\n /** The thread the composer sends into; its running state picks the `auto` send. */\n thread?: () => { getState: () => { isRunning: boolean } };\n}\n\nexport interface ComposerWrite {\n text: string;\n /** Replace the draft instead of appending on a new line. */\n replace: boolean;\n /** Submit right after writing. */\n send: boolean;\n /** Put the caret at the end of the draft once the editor shows it. */\n focus: boolean;\n /** The statewire thread the write was made for; it drains only into that thread's mount. */\n threadId: string | null;\n /** Settled once the write has been applied (and, for `send`, with the send's outcome). */\n resolve?: (outcome: Promise<void> | void) => void;\n /** Settled with `composer_write_dropped` when the write can no longer land. */\n reject?: (error: AthenaSdkError) => void;\n}\n\nexport interface ComposerHandoffStore {\n /** Writes waiting for a ready composer, oldest first. Adjacent plain appends fold together. */\n pending: ComposerWrite[];\n /** Set by a `focus` write; the editor consumes it after mirroring the draft. */\n focusOnNextMirror: boolean;\n /** Registered by the mounted editor: place the caret at the end of the draft. */\n focusEnd: (() => void) | null;\n /** Set by `useFocusComposer` before the editor mounted; the editor consumes it when it does. */\n focusOnMount: boolean;\n /**\n * Per thread, the attachments of messages the chat outbox gave back to the composer (Cancel, or\n * Edit on one that couldn't be sent): files already in Athena, back in the draft as mentions. A\n * message held again from that draft names those still in it, so the outbox asks Athena about\n * them again before it goes ({@link rememberRestoredAttachments}, {@link takeRestoredAttachments}).\n */\n restoredAttachments?: Map<string, ChatOutboxAttachment[]>;\n}\n\nexport function createComposerHandoffStore(): ComposerHandoffStore {\n return {\n pending: [],\n focusOnNextMirror: false,\n focusEnd: null,\n focusOnMount: false,\n restoredAttachments: new Map(),\n };\n}\n\n/** A held message given back to `threadId`'s composer: remember the attachments it carried. */\nexport function rememberRestoredAttachments({\n store,\n threadId,\n attachments,\n}: {\n store: ComposerHandoffStore;\n threadId: string;\n attachments: readonly ChatOutboxAttachment[];\n}): void {\n if (attachments.length === 0) return;\n store.restoredAttachments ??= new Map();\n const kept = store.restoredAttachments.get(threadId) ?? [];\n const known = new Set(kept.map((attachment) => attachment.assetId));\n store.restoredAttachments.set(threadId, [\n ...kept,\n ...attachments.filter((attachment) => !known.has(attachment.assetId)),\n ]);\n}\n\n/**\n * The remembered attachments of `threadId`'s draft whose mentions it still holds, for the message\n * leaving it now; the composer forgets them all (sent, held again, or removed from the draft).\n */\nexport function takeRestoredAttachments({\n store,\n threadId,\n assetIdsInDraft,\n}: {\n store: ComposerHandoffStore | null;\n threadId: string;\n assetIdsInDraft: ReadonlySet<string>;\n}): ChatOutboxAttachment[] {\n const kept = store?.restoredAttachments?.get(threadId);\n if (!kept) return [];\n store?.restoredAttachments?.delete(threadId);\n return kept.filter((attachment) => assetIdsInDraft.has(attachment.assetId));\n}\n\nexport const ComposerHandoffContext = createContext<ComposerHandoffStore | null>(null);\n\n/** The provider's handoff store, or null outside `AthenaProvider`. */\nexport function useComposerHandoffStore(): ComposerHandoffStore | null {\n return useContext(ComposerHandoffContext);\n}\n\n/**\n * Puts the caret at the end of the composer's draft and leaves the draft as it is; asked before the\n * editor has mounted, it focuses the editor as it mounts. For a host that shows the chat again and\n * wants typing to land in it (a launcher window a shortcut brings back).\n */\nexport function useFocusComposer(): () => void {\n const store = useComposerHandoffStore();\n return useCallback(() => {\n if (store) focusComposer({ store });\n }, [store]);\n}\n\n/** The caret to the end of the draft now, or, with no editor mounted yet, as one mounts. */\nexport function focusComposer({ store }: { store: ComposerHandoffStore }): void {\n if (store.focusEnd) store.focusEnd();\n else store.focusOnMount = true;\n}\n\n/**\n * Whether a composer write lands now: in thread-list mode the list has\n * resolved which thread is active, that thread's history has loaded, and the\n * chat's session lane is known (the sign-in provider above has resolved who is\n * signed in; see `StatewireSessionLane`). Until then the composer the hooks\n * write to is the one of a mount that is about to be replaced, and the draft\n * goes with it, or a send would go into a parked lane that refuses it unsent.\n *\n * Deliberately not the socket status: a never-started chat sits in\n * `standby` until its first send and must still take a prefill.\n */\nexport function useComposerReady(): boolean {\n const list = useAthenaStatewireThreadList();\n const threadLoading = useAuiState((s) => s.optional.thread?.isLoading ?? false);\n const lanePending = useStatewireSessionLanePending();\n return !(list?.isLoading ?? false) && !threadLoading && !lanePending;\n}\n\n/** The draft after `write`: `replace` (or an empty draft) takes the text as is. */\nexport function mergeComposerDraft({\n current,\n write,\n}: {\n current: string;\n write: Pick<ComposerWrite, 'text' | 'replace'>;\n}): string {\n if (write.replace || !current) return write.text;\n return `${current}\\n${write.text}`;\n}\n\n/**\n * Write into the live composer. Returns the send's outcome for a `send`\n * write so callers can await it.\n */\nexport function applyComposerWrite({\n target,\n store,\n write,\n}: {\n target: ComposerTarget;\n store: ComposerHandoffStore | null;\n write: ComposerWrite;\n}): Promise<void> | void {\n const current = target.composer.getState().text ?? '';\n const next = mergeComposerDraft({ current, write });\n target.composer.setText(next);\n if (write.focus && store) {\n // An unchanged draft never re-mirrors, so focus at once; otherwise the\n // editor focuses itself right after it has shown the new text.\n if (next === current) store.focusEnd?.();\n else store.focusOnNextMirror = true;\n }\n athenaDiagnostics.emit('composer.handoff', {\n level: 'debug',\n data: { phase: 'applied', send: write.send, focus: write.focus, chars: next.length },\n });\n if (write.send) {\n const isRunning = target.thread?.().getState().isRunning ?? false;\n return Promise.resolve(target.composer.send(autoComposerSendOptions(isRunning))).then(\n () => undefined,\n );\n }\n return undefined;\n}\n\n/**\n * Hold a write until the composer is ready. Writes keep their order; a plain\n * append folds into a directly preceding plain append for the same thread\n * (one draft, not two), while a replace or a send is kept as its own step so\n * no message is lost and every send settles on its own.\n */\nexport function queueComposerWrite({\n store,\n write,\n}: {\n store: ComposerHandoffStore;\n write: ComposerWrite;\n}): void {\n const last = store.pending[store.pending.length - 1];\n const foldable =\n last !== undefined &&\n !last.send &&\n !write.send &&\n !write.replace &&\n last.threadId === write.threadId &&\n last.resolve === undefined &&\n write.resolve === undefined;\n if (foldable) {\n last.text = mergeComposerDraft({ current: last.text, write });\n last.focus = last.focus || write.focus;\n } else {\n store.pending.push(write);\n }\n athenaDiagnostics.emit('composer.handoff', {\n level: 'debug',\n data: { phase: 'deferred', send: write.send, focus: write.focus, queued: store.pending.length },\n });\n}\n\nfunction dropWrite({ write, reason }: { write: ComposerWrite; reason: string }): void {\n const error = new AthenaSdkError({\n code: 'composer_write_dropped',\n message: `A composer ${write.send ? 'send' : 'draft'} queued before the chat was ready was dropped: ${reason}.`,\n hint: 'Make the write again from the chat that is active now.',\n context: { threadId: write.threadId, send: write.send },\n });\n athenaDiagnostics.emit('composer.handoff', {\n level: 'warn',\n error,\n data: { phase: 'dropped', send: write.send, reason, threadId: write.threadId },\n });\n write.reject?.(error);\n}\n\n/**\n * Deliver the pending writes, in order, into a now-ready composer. A write\n * made for another thread is dropped (rejected), never applied here.\n */\nexport function drainComposerHandoff({\n store,\n target,\n threadId,\n}: {\n store: ComposerHandoffStore;\n target: ComposerTarget;\n /** The statewire thread of the mount that is draining. */\n threadId: string | null;\n}): void {\n const writes = store.pending;\n if (writes.length === 0) return;\n store.pending = [];\n for (const write of writes) {\n if (write.threadId !== null && threadId !== null && write.threadId !== threadId) {\n dropWrite({ write, reason: `it was made for thread ${write.threadId}, thread ${threadId} is active` });\n continue;\n }\n const outcome = applyComposerWrite({ target, store, write });\n write.resolve?.(outcome);\n }\n}\n\n/** Drop every pending write (identity changed, provider unmounted). */\nexport function clearComposerHandoff({\n store,\n reason,\n}: {\n store: ComposerHandoffStore;\n reason: string;\n}): void {\n // Another identity, or no provider: the attachments given back belong to drafts that are gone.\n store.restoredAttachments?.clear();\n const writes = store.pending;\n if (writes.length === 0) return;\n store.pending = [];\n for (const write of writes) dropWrite({ write, reason });\n}\n"],"names":["createContext","useContext","useCallback","useAthenaStatewireThreadList","useAuiState","useStatewireSessionLanePending","athenaDiagnostics","autoComposerSendOptions","AthenaSdkError"],"mappings":";;;;;;;;;AA2EO,SAAS,6BAAmD;AACjE,SAAO;AAAA,IACL,SAAS,CAAA;AAAA,IACT,mBAAmB;AAAA,IACnB,UAAU;AAAA,IACV,cAAc;AAAA,IACd,yCAAyB,IAAA;AAAA,EAAI;AAEjC;AAGO,SAAS,4BAA4B;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AACF,GAIS;AACP,MAAI,YAAY,WAAW,EAAG;AAC9B,QAAM,wBAAN,MAAM,0CAA4B,IAAA;AAClC,QAAM,OAAO,MAAM,oBAAoB,IAAI,QAAQ,KAAK,CAAA;AACxD,QAAM,QAAQ,IAAI,IAAI,KAAK,IAAI,CAAC,eAAe,WAAW,OAAO,CAAC;AAClE,QAAM,oBAAoB,IAAI,UAAU;AAAA,IACtC,GAAG;AAAA,IACH,GAAG,YAAY,OAAO,CAAC,eAAe,CAAC,MAAM,IAAI,WAAW,OAAO,CAAC;AAAA,EAAA,CACrE;AACH;AAMO,SAAS,wBAAwB;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AACF,GAI2B;;AACzB,QAAM,QAAO,oCAAO,wBAAP,mBAA4B,IAAI;AAC7C,MAAI,CAAC,KAAM,QAAO,CAAA;AAClB,uCAAO,wBAAP,mBAA4B,OAAO;AACnC,SAAO,KAAK,OAAO,CAAC,eAAe,gBAAgB,IAAI,WAAW,OAAO,CAAC;AAC5E;AAEO,MAAM,yBAAyBA,WAAAA,cAA2C,IAAI;AAG9E,SAAS,0BAAuD;AACrE,SA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P,QAAM,SAAS,MAAM;AACrB,MAAI,OAAO,WAAW,EAAG;AACzB,QAAM,UAAU,CAAA;AAChB,aAAW,SAAS,QAAQ;AAC1B,QAAI,MAAM,aAAa,QAAQ,aAAa,QAAQ,MAAM,aAAa,UAAU;AAC/E,gBAAU,EAAE,OAAO,QAAQ,0BAA0B,MAAM,QAAQ,YAAY,QAAQ,aAAA,CAAc;AACrG;AAAA,IACF;AACA,UAAM,UAAU,mBAAmB,EAAE,QAAQ,OAAO,OAAO;AAC3D,gBAAM,YAAN,+BAAgB;AAAA,EAClB;AACF;AAGO,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA;AACF,GAGS;;AAEP,cAAM,wBAAN,mBAA2B;AAC3B,QAAM,SAAS,MAAM;AACrB,MAAI,OAAO,WAAW,EAAG;AACzB,QAAM,UAAU,CAAA;AAChB,aAAW,SAAS,OAAQ,WAAU,EAAE,OAAO,QAAQ;AACzD;;;;;;;;;;;;;;"}
@@ -1,4 +1,4 @@
1
- import type { ChatOutboxAttachment } from '../agent-runtime/src/index';
1
+ import { type ChatOutboxAttachment } from '../agent-runtime/src/index';
2
2
  import { AthenaSdkError } from '../diagnostics/errors';
3
3
  /** The slice of the assistant-ui client the handoff writes to. */
4
4
  export interface ComposerTarget {
@@ -11,6 +11,12 @@ export interface ComposerTarget {
11
11
  steer?: boolean;
12
12
  }) => unknown;
13
13
  };
14
+ /** The thread the composer sends into; its running state picks the `auto` send. */
15
+ thread?: () => {
16
+ getState: () => {
17
+ isRunning: boolean;
18
+ };
19
+ };
14
20
  }
15
21
  export interface ComposerWrite {
16
22
  text: string;