@athenaintel/react 0.43.0 → 0.50.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 (746) hide show
  1. package/README.md +258 -8
  2. package/dist/agent-runtime/src/answer-label.cjs +137 -0
  3. package/dist/agent-runtime/src/answer-label.cjs.map +1 -0
  4. package/dist/agent-runtime/src/answer-label.d.ts +104 -0
  5. package/dist/agent-runtime/src/answer-label.js +137 -0
  6. package/dist/agent-runtime/src/answer-label.js.map +1 -0
  7. package/dist/agent-runtime/src/answer-rows.cjs +180 -0
  8. package/dist/agent-runtime/src/answer-rows.cjs.map +1 -0
  9. package/dist/agent-runtime/src/answer-rows.d.ts +86 -0
  10. package/dist/agent-runtime/src/answer-rows.js +180 -0
  11. package/dist/agent-runtime/src/answer-rows.js.map +1 -0
  12. package/dist/agent-runtime/src/call-recap.cjs +319 -0
  13. package/dist/agent-runtime/src/call-recap.cjs.map +1 -0
  14. package/dist/agent-runtime/src/call-recap.d.ts +142 -0
  15. package/dist/agent-runtime/src/call-recap.js +319 -0
  16. package/dist/agent-runtime/src/call-recap.js.map +1 -0
  17. package/dist/agent-runtime/src/chat-outbox-store.cjs +1 -0
  18. package/dist/agent-runtime/src/chat-outbox-store.cjs.map +1 -1
  19. package/dist/agent-runtime/src/chat-outbox-store.d.ts +7 -0
  20. package/dist/agent-runtime/src/chat-outbox-store.js +1 -0
  21. package/dist/agent-runtime/src/chat-outbox-store.js.map +1 -1
  22. package/dist/agent-runtime/src/chat-outbox.cjs +46 -5
  23. package/dist/agent-runtime/src/chat-outbox.cjs.map +1 -1
  24. package/dist/agent-runtime/src/chat-outbox.d.ts +29 -0
  25. package/dist/agent-runtime/src/chat-outbox.js +46 -5
  26. package/dist/agent-runtime/src/chat-outbox.js.map +1 -1
  27. package/dist/agent-runtime/src/client-tool-bridge.cjs +15 -15
  28. package/dist/agent-runtime/src/client-tool-bridge.cjs.map +1 -1
  29. package/dist/agent-runtime/src/conversation-index.cjs +8 -8
  30. package/dist/agent-runtime/src/conversation-index.cjs.map +1 -1
  31. package/dist/agent-runtime/src/conversation-index.d.ts +7 -0
  32. package/dist/agent-runtime/src/conversation-index.js.map +1 -1
  33. package/dist/agent-runtime/src/conversation-list.cjs +2 -1
  34. package/dist/agent-runtime/src/conversation-list.cjs.map +1 -1
  35. package/dist/agent-runtime/src/conversation-list.d.ts +19 -3
  36. package/dist/agent-runtime/src/conversation-list.js +2 -1
  37. package/dist/agent-runtime/src/conversation-list.js.map +1 -1
  38. package/dist/agent-runtime/src/decision-checks.cjs +207 -0
  39. package/dist/agent-runtime/src/decision-checks.cjs.map +1 -0
  40. package/dist/agent-runtime/src/decision-checks.d.ts +142 -0
  41. package/dist/agent-runtime/src/decision-checks.js +207 -0
  42. package/dist/agent-runtime/src/decision-checks.js.map +1 -0
  43. package/dist/agent-runtime/src/desktop-handoff.d.ts +12 -0
  44. package/dist/agent-runtime/src/errors.cjs +18 -0
  45. package/dist/agent-runtime/src/errors.cjs.map +1 -1
  46. package/dist/agent-runtime/src/errors.d.ts +7 -0
  47. package/dist/agent-runtime/src/errors.js +18 -0
  48. package/dist/agent-runtime/src/errors.js.map +1 -1
  49. package/dist/agent-runtime/src/generated/runconfig-contract.cjs +12 -0
  50. package/dist/agent-runtime/src/generated/runconfig-contract.cjs.map +1 -1
  51. package/dist/agent-runtime/src/generated/runconfig-contract.d.ts +6 -6
  52. package/dist/agent-runtime/src/generated/runconfig-contract.js +12 -0
  53. package/dist/agent-runtime/src/generated/runconfig-contract.js.map +1 -1
  54. package/dist/agent-runtime/src/handoff-arrival.cjs +60 -0
  55. package/dist/agent-runtime/src/handoff-arrival.cjs.map +1 -0
  56. package/dist/agent-runtime/src/handoff-arrival.d.ts +46 -0
  57. package/dist/agent-runtime/src/handoff-arrival.js +60 -0
  58. package/dist/agent-runtime/src/handoff-arrival.js.map +1 -0
  59. package/dist/agent-runtime/src/index.d.ts +16 -9
  60. package/dist/agent-runtime/src/interrupts.cjs +71 -19
  61. package/dist/agent-runtime/src/interrupts.cjs.map +1 -1
  62. package/dist/agent-runtime/src/interrupts.d.ts +40 -3
  63. package/dist/agent-runtime/src/interrupts.js +56 -4
  64. package/dist/agent-runtime/src/interrupts.js.map +1 -1
  65. package/dist/agent-runtime/src/lane-history.cjs +8 -8
  66. package/dist/agent-runtime/src/lane-history.cjs.map +1 -1
  67. package/dist/agent-runtime/src/messages.cjs +43 -8
  68. package/dist/agent-runtime/src/messages.cjs.map +1 -1
  69. package/dist/agent-runtime/src/messages.d.ts +25 -3
  70. package/dist/agent-runtime/src/messages.js +43 -8
  71. package/dist/agent-runtime/src/messages.js.map +1 -1
  72. package/dist/agent-runtime/src/model-context.cjs +3 -2
  73. package/dist/agent-runtime/src/model-context.cjs.map +1 -1
  74. package/dist/agent-runtime/src/model-context.d.ts +6 -1
  75. package/dist/agent-runtime/src/model-context.js +3 -2
  76. package/dist/agent-runtime/src/model-context.js.map +1 -1
  77. package/dist/agent-runtime/src/offline-status.cjs +36 -0
  78. package/dist/agent-runtime/src/offline-status.cjs.map +1 -0
  79. package/dist/agent-runtime/src/offline-status.d.ts +118 -3
  80. package/dist/agent-runtime/src/offline-status.js +36 -0
  81. package/dist/agent-runtime/src/offline-status.js.map +1 -0
  82. package/dist/agent-runtime/src/queue.cjs +0 -9
  83. package/dist/agent-runtime/src/queue.cjs.map +1 -1
  84. package/dist/agent-runtime/src/queue.js +0 -9
  85. package/dist/agent-runtime/src/queue.js.map +1 -1
  86. package/dist/agent-runtime/src/quota-safe-local-storage-session.cjs +9 -9
  87. package/dist/agent-runtime/src/quota-safe-local-storage-session.cjs.map +1 -1
  88. package/dist/agent-runtime/src/runtime-catalog.cjs +42 -0
  89. package/dist/agent-runtime/src/runtime-catalog.cjs.map +1 -0
  90. package/dist/agent-runtime/src/runtime-catalog.d.ts +35 -0
  91. package/dist/agent-runtime/src/runtime-catalog.js +42 -0
  92. package/dist/agent-runtime/src/runtime-catalog.js.map +1 -0
  93. package/dist/agent-runtime/src/runtime-messages.cjs.map +1 -1
  94. package/dist/agent-runtime/src/runtime-messages.d.ts +1 -1
  95. package/dist/agent-runtime/src/runtime-messages.js.map +1 -1
  96. package/dist/agent-runtime/src/runtime.d.ts +41 -0
  97. package/dist/agent-runtime/src/send-recovery.cjs +37 -3
  98. package/dist/agent-runtime/src/send-recovery.cjs.map +1 -1
  99. package/dist/agent-runtime/src/send-recovery.d.ts +19 -0
  100. package/dist/agent-runtime/src/send-recovery.js +37 -3
  101. package/dist/agent-runtime/src/send-recovery.js.map +1 -1
  102. package/dist/agent-runtime/src/statewire-suspended.cjs +3 -3
  103. package/dist/agent-runtime/src/statewire-suspended.cjs.map +1 -1
  104. package/dist/agent-runtime/src/subagents.cjs +32 -2
  105. package/dist/agent-runtime/src/subagents.cjs.map +1 -1
  106. package/dist/agent-runtime/src/subagents.d.ts +9 -0
  107. package/dist/agent-runtime/src/subagents.js +30 -0
  108. package/dist/agent-runtime/src/subagents.js.map +1 -1
  109. package/dist/agent-runtime/src/thread-driver.cjs +67 -0
  110. package/dist/agent-runtime/src/thread-driver.cjs.map +1 -0
  111. package/dist/agent-runtime/src/thread-driver.d.ts +49 -0
  112. package/dist/agent-runtime/src/thread-driver.js +67 -0
  113. package/dist/agent-runtime/src/thread-driver.js.map +1 -0
  114. package/dist/agent-runtime/src/thread-handoff-flow-machine.d.ts +172 -0
  115. package/dist/agent-runtime/src/thread-handoff-protocol.d.ts +868 -0
  116. package/dist/agent-runtime/src/thread-handoff-qr.d.ts +11 -0
  117. package/dist/agent-runtime/src/thread-handoff.d.ts +3 -364
  118. package/dist/agent-runtime/src/thread-status.cjs +3 -3
  119. package/dist/agent-runtime/src/thread-status.cjs.map +1 -1
  120. package/dist/agent-runtime/src/tool-metadata.cjs +210 -25
  121. package/dist/agent-runtime/src/tool-metadata.cjs.map +1 -1
  122. package/dist/agent-runtime/src/tool-metadata.d.ts +12 -0
  123. package/dist/agent-runtime/src/tool-metadata.js +210 -25
  124. package/dist/agent-runtime/src/tool-metadata.js.map +1 -1
  125. package/dist/agent-runtime/src/tool-names.cjs +2 -0
  126. package/dist/agent-runtime/src/tool-names.cjs.map +1 -1
  127. package/dist/agent-runtime/src/tool-names.d.ts +2 -0
  128. package/dist/agent-runtime/src/tool-names.js +2 -0
  129. package/dist/agent-runtime/src/tool-names.js.map +1 -1
  130. package/dist/agent-runtime/src/types.d.ts +10 -2
  131. package/dist/agent-runtime/src/use-conversation-list.cjs +14 -13
  132. package/dist/agent-runtime/src/use-conversation-list.cjs.map +1 -1
  133. package/dist/agent-runtime/src/use-conversation-list.d.ts +6 -0
  134. package/dist/agent-runtime/src/use-conversation-list.js +3 -2
  135. package/dist/agent-runtime/src/use-conversation-list.js.map +1 -1
  136. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.cjs +45 -20
  137. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.cjs.map +1 -1
  138. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.d.ts +10 -3
  139. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.js +27 -2
  140. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.js.map +1 -1
  141. package/dist/agent-runtime/src/use-deep-agent-config.cjs +14 -14
  142. package/dist/agent-runtime/src/use-deep-agent-config.cjs.map +1 -1
  143. package/dist/agent-runtime/src/use-deep-agent-edit-submit.cjs +6 -6
  144. package/dist/agent-runtime/src/use-deep-agent-edit-submit.cjs.map +1 -1
  145. package/dist/agent-runtime/src/use-deep-agent-runtime.cjs +40 -22
  146. package/dist/agent-runtime/src/use-deep-agent-runtime.cjs.map +1 -1
  147. package/dist/agent-runtime/src/use-deep-agent-runtime.d.ts +17 -0
  148. package/dist/agent-runtime/src/use-deep-agent-runtime.js +24 -6
  149. package/dist/agent-runtime/src/use-deep-agent-runtime.js.map +1 -1
  150. package/dist/agent-runtime/src/use-deep-agent-thread.cjs +45 -45
  151. package/dist/agent-runtime/src/use-deep-agent-thread.cjs.map +1 -1
  152. package/dist/agent-runtime/src/use-deep-agent-voice.cjs +588 -130
  153. package/dist/agent-runtime/src/use-deep-agent-voice.cjs.map +1 -1
  154. package/dist/agent-runtime/src/use-deep-agent-voice.d.ts +162 -10
  155. package/dist/agent-runtime/src/use-deep-agent-voice.js +529 -71
  156. package/dist/agent-runtime/src/use-deep-agent-voice.js.map +1 -1
  157. package/dist/agent-runtime/src/use-deep-agent-window-sync.cjs +26 -26
  158. package/dist/agent-runtime/src/use-deep-agent-window-sync.cjs.map +1 -1
  159. package/dist/agent-runtime/src/use-historical-edit-attachments.cjs +4 -4
  160. package/dist/agent-runtime/src/use-historical-edit-attachments.cjs.map +1 -1
  161. package/dist/agent-runtime/src/use-thread-handoff-flow.d.ts +34 -26
  162. package/dist/agent-runtime/src/voice-earcon.cjs +139 -0
  163. package/dist/agent-runtime/src/voice-earcon.cjs.map +1 -0
  164. package/dist/agent-runtime/src/voice-earcon.d.ts +38 -0
  165. package/dist/agent-runtime/src/voice-earcon.js +139 -0
  166. package/dist/agent-runtime/src/voice-earcon.js.map +1 -0
  167. package/dist/agent-runtime/src/voice-media.cjs +117 -0
  168. package/dist/agent-runtime/src/voice-media.cjs.map +1 -0
  169. package/dist/agent-runtime/src/voice-media.d.ts +63 -0
  170. package/dist/agent-runtime/src/voice-media.js +117 -0
  171. package/dist/agent-runtime/src/voice-media.js.map +1 -0
  172. package/dist/agent-runtime/src/voice-presentation.cjs +2 -0
  173. package/dist/agent-runtime/src/voice-presentation.cjs.map +1 -1
  174. package/dist/agent-runtime/src/voice-presentation.js +2 -0
  175. package/dist/agent-runtime/src/voice-presentation.js.map +1 -1
  176. package/dist/agent-runtime/src/voice-wire-types.d.ts +32 -0
  177. package/dist/assets/AssetPanel.cjs +11 -11
  178. package/dist/assets/AssetPanel.cjs.map +1 -1
  179. package/dist/assets/AthenaAssetEmbed.cjs +11 -9
  180. package/dist/assets/AthenaAssetEmbed.cjs.map +1 -1
  181. package/dist/assets/AthenaAssetEmbed.d.ts +18 -5
  182. package/dist/assets/AthenaAssetEmbed.js +4 -2
  183. package/dist/assets/AthenaAssetEmbed.js.map +1 -1
  184. package/dist/assets/AthenaLayout.cjs +16 -16
  185. package/dist/assets/AthenaLayout.cjs.map +1 -1
  186. package/dist/assets/use-asset-content.cjs +4 -4
  187. package/dist/assets/use-asset-content.cjs.map +1 -1
  188. package/dist/assets/use-asset-embed.cjs +14 -7
  189. package/dist/assets/use-asset-embed.cjs.map +1 -1
  190. package/dist/assets/use-asset-embed.d.ts +23 -6
  191. package/dist/assets/use-asset-embed.js +10 -3
  192. package/dist/assets/use-asset-embed.js.map +1 -1
  193. package/dist/auth/AthenaAuthContext.cjs +3 -3
  194. package/dist/auth/AthenaAuthContext.cjs.map +1 -1
  195. package/dist/auth/AthenaAuthProvider.cjs +8 -8
  196. package/dist/auth/AthenaAuthProvider.cjs.map +1 -1
  197. package/dist/auth/AthenaCredentialSourceContext.cjs +5 -5
  198. package/dist/auth/AthenaCredentialSourceContext.cjs.map +1 -1
  199. package/dist/auth/AthenaSSOProvider.cjs +14 -14
  200. package/dist/auth/AthenaSSOProvider.cjs.map +1 -1
  201. package/dist/auth/credential-source.cjs +26 -13
  202. package/dist/auth/credential-source.cjs.map +1 -1
  203. package/dist/auth/credential-source.d.ts +8 -0
  204. package/dist/auth/credential-source.js +26 -13
  205. package/dist/auth/credential-source.js.map +1 -1
  206. package/dist/catalog/agent-model-options.cjs +25 -17
  207. package/dist/catalog/agent-model-options.cjs.map +1 -1
  208. package/dist/catalog/agent-model-options.d.ts +38 -5
  209. package/dist/catalog/agent-model-options.js +25 -17
  210. package/dist/catalog/agent-model-options.js.map +1 -1
  211. package/dist/catalog/channel-refusal.cjs +36 -0
  212. package/dist/catalog/channel-refusal.cjs.map +1 -0
  213. package/dist/catalog/channel-refusal.d.ts +29 -0
  214. package/dist/catalog/channel-refusal.js +36 -0
  215. package/dist/catalog/channel-refusal.js.map +1 -0
  216. package/dist/catalog/chat-pickers.cjs +60 -24
  217. package/dist/catalog/chat-pickers.cjs.map +1 -1
  218. package/dist/catalog/chat-pickers.d.ts +12 -2
  219. package/dist/catalog/chat-pickers.js +56 -20
  220. package/dist/catalog/chat-pickers.js.map +1 -1
  221. package/dist/catalog/runtime-catalog.cjs +89 -23
  222. package/dist/catalog/runtime-catalog.cjs.map +1 -1
  223. package/dist/catalog/runtime-catalog.d.ts +8 -2
  224. package/dist/catalog/runtime-catalog.js +83 -17
  225. package/dist/catalog/runtime-catalog.js.map +1 -1
  226. package/dist/catalog/use-athena-chat-mode.cjs +12 -12
  227. package/dist/catalog/use-athena-chat-mode.cjs.map +1 -1
  228. package/dist/chat/AthenaChat.cjs +155 -67
  229. package/dist/chat/AthenaChat.cjs.map +1 -1
  230. package/dist/chat/AthenaChat.d.ts +42 -2
  231. package/dist/chat/AthenaChat.js +106 -18
  232. package/dist/chat/AthenaChat.js.map +1 -1
  233. package/dist/chat/AthenaChatErrorBoundary.cjs +3 -3
  234. package/dist/chat/AthenaChatErrorBoundary.cjs.map +1 -1
  235. package/dist/chat/DrivingOnChip.cjs +23 -0
  236. package/dist/chat/DrivingOnChip.cjs.map +1 -0
  237. package/dist/chat/DrivingOnChip.d.ts +17 -0
  238. package/dist/chat/DrivingOnChip.js +23 -0
  239. package/dist/chat/DrivingOnChip.js.map +1 -0
  240. package/dist/chat/StatewireApprovalCard.cjs +166 -37
  241. package/dist/chat/StatewireApprovalCard.cjs.map +1 -1
  242. package/dist/chat/StatewireApprovalCard.d.ts +91 -2
  243. package/dist/chat/StatewireApprovalCard.js +156 -27
  244. package/dist/chat/StatewireApprovalCard.js.map +1 -1
  245. package/dist/chat/StatewireClientToolBridge.cjs +2 -2
  246. package/dist/chat/StatewireClientToolBridge.cjs.map +1 -1
  247. package/dist/chat/StatewireQueuedMessages.cjs +81 -69
  248. package/dist/chat/StatewireQueuedMessages.cjs.map +1 -1
  249. package/dist/chat/StatewireQueuedMessages.d.ts +25 -13
  250. package/dist/chat/StatewireQueuedMessages.js +73 -61
  251. package/dist/chat/StatewireQueuedMessages.js.map +1 -1
  252. package/dist/chat/WaitingOnYouBanner.cjs +9 -5
  253. package/dist/chat/WaitingOnYouBanner.cjs.map +1 -1
  254. package/dist/chat/WaitingOnYouBanner.js +7 -3
  255. package/dist/chat/WaitingOnYouBanner.js.map +1 -1
  256. package/dist/chat/athena-chat-welcome.cjs +2 -2
  257. package/dist/chat/athena-chat-welcome.cjs.map +1 -1
  258. package/dist/chat/athena-citation-links.cjs +5 -5
  259. package/dist/chat/athena-citation-links.cjs.map +1 -1
  260. package/dist/chat/athena-composer-controls.cjs +26 -16
  261. package/dist/chat/athena-composer-controls.cjs.map +1 -1
  262. package/dist/chat/athena-composer-controls.d.ts +6 -0
  263. package/dist/chat/athena-composer-controls.js +26 -16
  264. package/dist/chat/athena-composer-controls.js.map +1 -1
  265. package/dist/chat/athena-turn-end-status.cjs +42 -0
  266. package/dist/chat/athena-turn-end-status.cjs.map +1 -0
  267. package/dist/chat/athena-turn-end-status.d.ts +24 -0
  268. package/dist/chat/athena-turn-end-status.js +42 -0
  269. package/dist/chat/athena-turn-end-status.js.map +1 -0
  270. package/dist/chat/browser-decision-check.cjs +131 -0
  271. package/dist/chat/browser-decision-check.cjs.map +1 -0
  272. package/dist/chat/browser-decision-check.d.ts +61 -0
  273. package/dist/chat/browser-decision-check.js +131 -0
  274. package/dist/chat/browser-decision-check.js.map +1 -0
  275. package/dist/chat/chat-outbox-rows.cjs +3 -3
  276. package/dist/chat/chat-outbox-rows.cjs.map +1 -1
  277. package/dist/chat/chat-voice-controls.cjs +96 -29
  278. package/dist/chat/chat-voice-controls.cjs.map +1 -1
  279. package/dist/chat/chat-voice-controls.d.ts +42 -3
  280. package/dist/chat/chat-voice-controls.js +92 -25
  281. package/dist/chat/chat-voice-controls.js.map +1 -1
  282. package/dist/chat/composer-keyboard-hint.cjs +5 -5
  283. package/dist/chat/composer-keyboard-hint.cjs.map +1 -1
  284. package/dist/chat/device-operation.cjs +29 -0
  285. package/dist/chat/device-operation.cjs.map +1 -0
  286. package/dist/chat/device-operation.d.ts +34 -0
  287. package/dist/chat/device-operation.js +29 -0
  288. package/dist/chat/device-operation.js.map +1 -0
  289. package/dist/chat/super-grouping/CollapsibleGroup.cjs +14 -14
  290. package/dist/chat/super-grouping/CollapsibleGroup.cjs.map +1 -1
  291. package/dist/chat/super-grouping/GroupedMessageParts.cjs +4 -4
  292. package/dist/chat/super-grouping/GroupedMessageParts.cjs.map +1 -1
  293. package/dist/chat/super-grouping/SuperGroupingCard.cjs +52 -36
  294. package/dist/chat/super-grouping/SuperGroupingCard.cjs.map +1 -1
  295. package/dist/chat/super-grouping/SuperGroupingCard.d.ts +19 -4
  296. package/dist/chat/super-grouping/SuperGroupingCard.js +29 -13
  297. package/dist/chat/super-grouping/SuperGroupingCard.js.map +1 -1
  298. package/dist/chat/super-grouping/SuperGroupingTranscript.cjs +32 -32
  299. package/dist/chat/super-grouping/SuperGroupingTranscript.cjs.map +1 -1
  300. package/dist/chat/super-grouping/SuperGroupingTranscript.js +3 -3
  301. package/dist/chat/super-grouping/SuperGroupingTranscript.js.map +1 -1
  302. package/dist/chat/super-grouping/ToolTimeline.cjs +73 -40
  303. package/dist/chat/super-grouping/ToolTimeline.cjs.map +1 -1
  304. package/dist/chat/super-grouping/ToolTimeline.d.ts +10 -2
  305. package/dist/chat/super-grouping/ToolTimeline.js +69 -36
  306. package/dist/chat/super-grouping/ToolTimeline.js.map +1 -1
  307. package/dist/chat/super-grouping/activity-timeline.cjs +47 -12
  308. package/dist/chat/super-grouping/activity-timeline.cjs.map +1 -1
  309. package/dist/chat/super-grouping/activity-timeline.d.ts +21 -0
  310. package/dist/chat/super-grouping/activity-timeline.js +47 -12
  311. package/dist/chat/super-grouping/activity-timeline.js.map +1 -1
  312. package/dist/chat/super-grouping/grouping-function.cjs +4 -0
  313. package/dist/chat/super-grouping/grouping-function.cjs.map +1 -1
  314. package/dist/chat/super-grouping/grouping-function.d.ts +7 -0
  315. package/dist/chat/super-grouping/grouping-function.js +5 -1
  316. package/dist/chat/super-grouping/grouping-function.js.map +1 -1
  317. package/dist/chat/super-grouping/index.cjs +6 -0
  318. package/dist/chat/super-grouping/index.cjs.map +1 -1
  319. package/dist/chat/super-grouping/index.d.ts +5 -2
  320. package/dist/chat/super-grouping/index.js +7 -1
  321. package/dist/chat/super-grouping/index.js.map +1 -1
  322. package/dist/chat/super-grouping/tool-part-placement.cjs +17 -0
  323. package/dist/chat/super-grouping/tool-part-placement.cjs.map +1 -0
  324. package/dist/chat/super-grouping/tool-part-placement.d.ts +22 -0
  325. package/dist/chat/super-grouping/tool-part-placement.js +17 -0
  326. package/dist/chat/super-grouping/tool-part-placement.js.map +1 -0
  327. package/dist/chat/thread-scroll-to-bottom.cjs +2 -2
  328. package/dist/chat/thread-scroll-to-bottom.cjs.map +1 -1
  329. package/dist/chat/thread-scroll-to-bottom.d.ts +10 -7
  330. package/dist/chat/thread-scroll-to-bottom.js +2 -2
  331. package/dist/chat/thread-scroll-to-bottom.js.map +1 -1
  332. package/dist/chat/tooltip-icon-button.cjs +2 -2
  333. package/dist/chat/tooltip-icon-button.cjs.map +1 -1
  334. package/dist/chat/use-athena-voice-live.cjs +11 -0
  335. package/dist/chat/use-athena-voice-live.cjs.map +1 -0
  336. package/dist/chat/use-athena-voice-live.d.ts +11 -0
  337. package/dist/chat/use-athena-voice-live.js +11 -0
  338. package/dist/chat/use-athena-voice-live.js.map +1 -0
  339. package/dist/chat/use-statewire-approval-request.cjs +56 -24
  340. package/dist/chat/use-statewire-approval-request.cjs.map +1 -1
  341. package/dist/chat/use-statewire-approval-request.d.ts +33 -4
  342. package/dist/chat/use-statewire-approval-request.js +41 -9
  343. package/dist/chat/use-statewire-approval-request.js.map +1 -1
  344. package/dist/chat-ui/auth/sign-in-card.cjs +2 -2
  345. package/dist/chat-ui/auth/sign-in-card.cjs.map +1 -1
  346. package/dist/chat-ui/composer/tiptap-composer.cjs +138 -107
  347. package/dist/chat-ui/composer/tiptap-composer.cjs.map +1 -1
  348. package/dist/chat-ui/composer/tiptap-composer.d.ts +20 -4
  349. package/dist/chat-ui/composer/tiptap-composer.js +85 -54
  350. package/dist/chat-ui/composer/tiptap-composer.js.map +1 -1
  351. package/dist/chat-ui/header/conversation-history-panel.cjs +49 -23
  352. package/dist/chat-ui/header/conversation-history-panel.cjs.map +1 -1
  353. package/dist/chat-ui/header/conversation-history-panel.d.ts +12 -1
  354. package/dist/chat-ui/header/conversation-history-panel.js +38 -12
  355. package/dist/chat-ui/header/conversation-history-panel.js.map +1 -1
  356. package/dist/chat-ui/index.cjs +21 -0
  357. package/dist/chat-ui/index.cjs.map +1 -1
  358. package/dist/chat-ui/index.d.ts +8 -1
  359. package/dist/chat-ui/index.js +21 -0
  360. package/dist/chat-ui/index.js.map +1 -1
  361. package/dist/chat-ui/mentions/mention-chip.cjs +4 -4
  362. package/dist/chat-ui/mentions/mention-chip.cjs.map +1 -1
  363. package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-list.cjs +10 -9
  364. package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-list.cjs.map +1 -1
  365. package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-list.js +3 -2
  366. package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-list.js.map +1 -1
  367. package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-popup.cjs +2 -2
  368. package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-popup.cjs.map +1 -1
  369. package/dist/chat-ui/mentions/suggestions/components/menu-list.cjs +29 -6
  370. package/dist/chat-ui/mentions/suggestions/components/menu-list.cjs.map +1 -1
  371. package/dist/chat-ui/mentions/suggestions/components/menu-list.d.ts +7 -1
  372. package/dist/chat-ui/mentions/suggestions/components/menu-list.js +25 -2
  373. package/dist/chat-ui/mentions/suggestions/components/menu-list.js.map +1 -1
  374. package/dist/chat-ui/mentions/suggestions/components/use-keyboard-navigation.cjs +2 -2
  375. package/dist/chat-ui/mentions/suggestions/components/use-keyboard-navigation.cjs.map +1 -1
  376. package/dist/chat-ui/mentions/suggestions/components/use-menu-navigation.cjs +2 -2
  377. package/dist/chat-ui/mentions/suggestions/components/use-menu-navigation.cjs.map +1 -1
  378. package/dist/chat-ui/mentions/suggestions/data/api-client.cjs +3 -3
  379. package/dist/chat-ui/mentions/suggestions/data/api-client.cjs.map +1 -1
  380. package/dist/chat-ui/mentions/suggestions/data/orchestrator.cjs +56 -2
  381. package/dist/chat-ui/mentions/suggestions/data/orchestrator.cjs.map +1 -1
  382. package/dist/chat-ui/mentions/suggestions/data/orchestrator.d.ts +12 -0
  383. package/dist/chat-ui/mentions/suggestions/data/orchestrator.js +56 -2
  384. package/dist/chat-ui/mentions/suggestions/data/orchestrator.js.map +1 -1
  385. package/dist/chat-ui/mentions/suggestions/data/sources/index.cjs +24 -3
  386. package/dist/chat-ui/mentions/suggestions/data/sources/index.cjs.map +1 -1
  387. package/dist/chat-ui/mentions/suggestions/data/sources/index.d.ts +7 -0
  388. package/dist/chat-ui/mentions/suggestions/data/sources/index.js +24 -3
  389. package/dist/chat-ui/mentions/suggestions/data/sources/index.js.map +1 -1
  390. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.cjs +35 -13
  391. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.cjs.map +1 -1
  392. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.d.ts +15 -1
  393. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.js +28 -6
  394. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.js.map +1 -1
  395. package/dist/chat-ui/mentions/suggestions/data/use-menu-items.cjs +9 -6
  396. package/dist/chat-ui/mentions/suggestions/data/use-menu-items.cjs.map +1 -1
  397. package/dist/chat-ui/mentions/suggestions/data/use-menu-items.d.ts +3 -0
  398. package/dist/chat-ui/mentions/suggestions/data/use-menu-items.js +5 -2
  399. package/dist/chat-ui/mentions/suggestions/data/use-menu-items.js.map +1 -1
  400. package/dist/chat-ui/mentions/use-account-workspace-id.cjs +45 -10
  401. package/dist/chat-ui/mentions/use-account-workspace-id.cjs.map +1 -1
  402. package/dist/chat-ui/mentions/use-account-workspace-id.d.ts +24 -1
  403. package/dist/chat-ui/mentions/use-account-workspace-id.js +46 -11
  404. package/dist/chat-ui/mentions/use-account-workspace-id.js.map +1 -1
  405. package/dist/chat-ui/mentions/use-member-avatar.cjs +4 -4
  406. package/dist/chat-ui/mentions/use-member-avatar.cjs.map +1 -1
  407. package/dist/chat-ui/mentions/use-mention-asset.cjs +3 -3
  408. package/dist/chat-ui/mentions/use-mention-asset.cjs.map +1 -1
  409. package/dist/chat-ui/messages/answer-label.cjs +42 -0
  410. package/dist/chat-ui/messages/answer-label.cjs.map +1 -0
  411. package/dist/chat-ui/messages/answer-label.d.ts +33 -0
  412. package/dist/chat-ui/messages/answer-label.js +42 -0
  413. package/dist/chat-ui/messages/answer-label.js.map +1 -0
  414. package/dist/chat-ui/messages/arrival-animation.cjs +13 -0
  415. package/dist/chat-ui/messages/arrival-animation.cjs.map +1 -0
  416. package/dist/chat-ui/messages/arrival-animation.d.ts +14 -0
  417. package/dist/chat-ui/messages/arrival-animation.js +13 -0
  418. package/dist/chat-ui/messages/arrival-animation.js.map +1 -0
  419. package/dist/chat-ui/messages/continue-pill.cjs +5 -5
  420. package/dist/chat-ui/messages/continue-pill.cjs.map +1 -1
  421. package/dist/chat-ui/messages/from-the-call-card.cjs +124 -0
  422. package/dist/chat-ui/messages/from-the-call-card.cjs.map +1 -0
  423. package/dist/chat-ui/messages/from-the-call-card.d.ts +17 -0
  424. package/dist/chat-ui/messages/from-the-call-card.js +124 -0
  425. package/dist/chat-ui/messages/from-the-call-card.js.map +1 -0
  426. package/dist/chat-ui/messages/handoff-arrival-divider.cjs +44 -0
  427. package/dist/chat-ui/messages/handoff-arrival-divider.cjs.map +1 -0
  428. package/dist/chat-ui/messages/handoff-arrival-divider.d.ts +17 -0
  429. package/dist/chat-ui/messages/handoff-arrival-divider.js +44 -0
  430. package/dist/chat-ui/messages/handoff-arrival-divider.js.map +1 -0
  431. package/dist/chat-ui/messages/message-actions-config.cjs +3 -3
  432. package/dist/chat-ui/messages/message-actions-config.cjs.map +1 -1
  433. package/dist/chat-ui/messages/message-components.cjs +8 -4
  434. package/dist/chat-ui/messages/message-components.cjs.map +1 -1
  435. package/dist/chat-ui/messages/message-components.js +5 -1
  436. package/dist/chat-ui/messages/message-components.js.map +1 -1
  437. package/dist/chat-ui/messages/message-images.cjs +66 -0
  438. package/dist/chat-ui/messages/message-images.cjs.map +1 -0
  439. package/dist/chat-ui/messages/message-images.d.ts +16 -0
  440. package/dist/chat-ui/messages/message-images.js +66 -0
  441. package/dist/chat-ui/messages/message-images.js.map +1 -0
  442. package/dist/chat-ui/messages/user-edit-composer.cjs +2 -2
  443. package/dist/chat-ui/messages/user-edit-composer.cjs.map +1 -1
  444. package/dist/chat-ui/messages/wake-marker.cjs +3 -3
  445. package/dist/chat-ui/messages/wake-marker.cjs.map +1 -1
  446. package/dist/chat-ui/rich-text/chat-link.cjs +3 -2
  447. package/dist/chat-ui/rich-text/chat-link.cjs.map +1 -1
  448. package/dist/chat-ui/rich-text/chat-link.d.ts +4 -0
  449. package/dist/chat-ui/rich-text/chat-link.js +4 -3
  450. package/dist/chat-ui/rich-text/chat-link.js.map +1 -1
  451. package/dist/chat-ui/rich-text/chat-message-body.cjs +9 -8
  452. package/dist/chat-ui/rich-text/chat-message-body.cjs.map +1 -1
  453. package/dist/chat-ui/rich-text/chat-message-body.d.ts +12 -0
  454. package/dist/chat-ui/rich-text/chat-message-body.js +2 -1
  455. package/dist/chat-ui/rich-text/chat-message-body.js.map +1 -1
  456. package/dist/chat-ui/rich-text/chat-node-views.cjs +6 -6
  457. package/dist/chat-ui/rich-text/chat-node-views.cjs.map +1 -1
  458. package/dist/chat-ui/rich-text/dom-output-spec.cjs +2 -2
  459. package/dist/chat-ui/rich-text/dom-output-spec.cjs.map +1 -1
  460. package/dist/chat-ui/statewire.cjs +3 -0
  461. package/dist/chat-ui/statewire.cjs.map +1 -1
  462. package/dist/chat-ui/statewire.d.ts +2 -1
  463. package/dist/chat-ui/statewire.js +3 -0
  464. package/dist/chat-ui/statewire.js.map +1 -1
  465. package/dist/chat-ui/thread/chat-thread-shell.cjs +45 -14
  466. package/dist/chat-ui/thread/chat-thread-shell.cjs.map +1 -1
  467. package/dist/chat-ui/thread/chat-thread-shell.d.ts +16 -2
  468. package/dist/chat-ui/thread/chat-thread-shell.js +37 -6
  469. package/dist/chat-ui/thread/chat-thread-shell.js.map +1 -1
  470. package/dist/chat-ui/thread/composer-send-or-stop.cjs +30 -20
  471. package/dist/chat-ui/thread/composer-send-or-stop.cjs.map +1 -1
  472. package/dist/chat-ui/thread/composer-send-or-stop.d.ts +8 -0
  473. package/dist/chat-ui/thread/composer-send-or-stop.js +29 -19
  474. package/dist/chat-ui/thread/composer-send-or-stop.js.map +1 -1
  475. package/dist/chat-ui/thread/statewire-history-edge.cjs +20 -21
  476. package/dist/chat-ui/thread/statewire-history-edge.cjs.map +1 -1
  477. package/dist/chat-ui/thread/statewire-history-edge.js +3 -4
  478. package/dist/chat-ui/thread/statewire-history-edge.js.map +1 -1
  479. package/dist/chat-ui/thread/thread-loading-overlay.cjs +5 -5
  480. package/dist/chat-ui/thread/thread-loading-overlay.cjs.map +1 -1
  481. package/dist/collab/client.cjs +52 -3
  482. package/dist/collab/client.cjs.map +1 -1
  483. package/dist/collab/client.d.ts +27 -0
  484. package/dist/collab/client.js +52 -3
  485. package/dist/collab/client.js.map +1 -1
  486. package/dist/collab/document-status.cjs +150 -0
  487. package/dist/collab/document-status.cjs.map +1 -0
  488. package/dist/collab/document-status.d.ts +68 -0
  489. package/dist/collab/document-status.js +150 -0
  490. package/dist/collab/document-status.js.map +1 -0
  491. package/dist/collab/index.cjs +7 -0
  492. package/dist/collab/index.cjs.map +1 -1
  493. package/dist/collab/index.d.ts +6 -1
  494. package/dist/collab/index.js +7 -0
  495. package/dist/collab/index.js.map +1 -1
  496. package/dist/collab/presence-react.cjs +11 -11
  497. package/dist/collab/presence-react.cjs.map +1 -1
  498. package/dist/collab/react.cjs +6 -6
  499. package/dist/collab/react.cjs.map +1 -1
  500. package/dist/composer/AttachmentContext.cjs +24 -11
  501. package/dist/composer/AttachmentContext.cjs.map +1 -1
  502. package/dist/composer/AttachmentContext.js +18 -5
  503. package/dist/composer/AttachmentContext.js.map +1 -1
  504. package/dist/composer/ComposerAttachmentPreview.cjs +78 -23
  505. package/dist/composer/ComposerAttachmentPreview.cjs.map +1 -1
  506. package/dist/composer/ComposerAttachmentPreview.d.ts +5 -3
  507. package/dist/composer/ComposerAttachmentPreview.js +79 -24
  508. package/dist/composer/ComposerAttachmentPreview.js.map +1 -1
  509. package/dist/composer/ComposerDropZone.cjs +7 -7
  510. package/dist/composer/ComposerDropZone.cjs.map +1 -1
  511. package/dist/composer/FileUploadButton.cjs +37 -22
  512. package/dist/composer/FileUploadButton.cjs.map +1 -1
  513. package/dist/composer/FileUploadButton.d.ts +6 -0
  514. package/dist/composer/FileUploadButton.js +34 -19
  515. package/dist/composer/FileUploadButton.js.map +1 -1
  516. package/dist/composer/QuoteContext.cjs +8 -8
  517. package/dist/composer/QuoteContext.cjs.map +1 -1
  518. package/dist/composer/composer-handoff.cjs +4 -4
  519. package/dist/composer/composer-handoff.cjs.map +1 -1
  520. package/dist/composer/index.d.ts +1 -1
  521. package/dist/composer/useAppendToComposer.cjs +4 -4
  522. package/dist/composer/useAppendToComposer.cjs.map +1 -1
  523. package/dist/composer/useAttachFiles.cjs +23 -6
  524. package/dist/composer/useAttachFiles.cjs.map +1 -1
  525. package/dist/composer/useAttachFiles.d.ts +15 -7
  526. package/dist/composer/useAttachFiles.js +22 -5
  527. package/dist/composer/useAttachFiles.js.map +1 -1
  528. package/dist/composer/useComposerAttachment.cjs +4 -4
  529. package/dist/composer/useComposerAttachment.cjs.map +1 -1
  530. package/dist/composer/useFileUpload.cjs +21 -16
  531. package/dist/composer/useFileUpload.cjs.map +1 -1
  532. package/dist/composer/useFileUpload.d.ts +12 -0
  533. package/dist/composer/useFileUpload.js +12 -7
  534. package/dist/composer/useFileUpload.js.map +1 -1
  535. package/dist/composer/useReadComposerDraft.cjs +27 -8
  536. package/dist/composer/useReadComposerDraft.cjs.map +1 -1
  537. package/dist/composer/useReadComposerDraft.d.ts +23 -1
  538. package/dist/composer/useReadComposerDraft.js +27 -8
  539. package/dist/composer/useReadComposerDraft.js.map +1 -1
  540. package/dist/composer/useSendMessage.cjs +4 -4
  541. package/dist/composer/useSendMessage.cjs.map +1 -1
  542. package/dist/diagnostics/useAthenaDiagnostics.cjs +4 -4
  543. package/dist/diagnostics/useAthenaDiagnostics.cjs.map +1 -1
  544. package/dist/dictation/audio-level-history.cjs +3 -3
  545. package/dist/dictation/audio-level-history.cjs.map +1 -1
  546. package/dist/dictation/dictation-controls.cjs +24 -20
  547. package/dist/dictation/dictation-controls.cjs.map +1 -1
  548. package/dist/dictation/dictation-controls.d.ts +6 -1
  549. package/dist/dictation/dictation-controls.js +24 -20
  550. package/dist/dictation/dictation-controls.js.map +1 -1
  551. package/dist/dictation/use-athena-dictation-engine.cjs +3 -3
  552. package/dist/dictation/use-athena-dictation-engine.cjs.map +1 -1
  553. package/dist/dictation/use-dictation.cjs +22 -22
  554. package/dist/dictation/use-dictation.cjs.map +1 -1
  555. package/dist/index.cjs +29 -2
  556. package/dist/index.cjs.map +1 -1
  557. package/dist/index.d.ts +18 -4
  558. package/dist/index.js +30 -3
  559. package/dist/index.js.map +1 -1
  560. package/dist/keryx-http/src/receive-only-socket.cjs +40 -0
  561. package/dist/keryx-http/src/receive-only-socket.cjs.map +1 -0
  562. package/dist/keryx-http/src/receive-only-socket.d.ts +27 -0
  563. package/dist/keryx-http/src/receive-only-socket.js +40 -0
  564. package/dist/keryx-http/src/receive-only-socket.js.map +1 -0
  565. package/dist/keryx-http/src/unconfirmed-update-attributions.cjs +190 -0
  566. package/dist/keryx-http/src/unconfirmed-update-attributions.cjs.map +1 -0
  567. package/dist/keryx-http/src/unconfirmed-update-attributions.d.ts +132 -0
  568. package/dist/keryx-http/src/unconfirmed-update-attributions.js +190 -0
  569. package/dist/keryx-http/src/unconfirmed-update-attributions.js.map +1 -0
  570. package/dist/keryx-http/src/update-attributions.cjs +141 -0
  571. package/dist/keryx-http/src/update-attributions.cjs.map +1 -0
  572. package/dist/keryx-http/src/update-attributions.d.ts +107 -0
  573. package/dist/keryx-http/src/update-attributions.js +141 -0
  574. package/dist/keryx-http/src/update-attributions.js.map +1 -0
  575. package/dist/lib/owner-document.cjs +6 -6
  576. package/dist/lib/owner-document.cjs.map +1 -1
  577. package/dist/lib/use-athena-rest-query.cjs +4 -4
  578. package/dist/lib/use-athena-rest-query.cjs.map +1 -1
  579. package/dist/lib/use-document-active.cjs +4 -4
  580. package/dist/lib/use-document-active.cjs.map +1 -1
  581. package/dist/lib/use-prefers-reduced-motion.cjs +2 -2
  582. package/dist/lib/use-prefers-reduced-motion.cjs.map +1 -1
  583. package/dist/offline/offline-history.cjs +7 -7
  584. package/dist/offline/offline-history.cjs.map +1 -1
  585. package/dist/provider/AthenaContext.cjs +3 -3
  586. package/dist/provider/AthenaContext.cjs.map +1 -1
  587. package/dist/provider/AthenaProvider.cjs +120 -79
  588. package/dist/provider/AthenaProvider.cjs.map +1 -1
  589. package/dist/provider/AthenaProvider.d.ts +11 -1
  590. package/dist/provider/AthenaProvider.js +44 -3
  591. package/dist/provider/AthenaProvider.js.map +1 -1
  592. package/dist/provider/PostHogProvider.cjs +2 -2
  593. package/dist/provider/PostHogProvider.cjs.map +1 -1
  594. package/dist/provider/agent-selection-context.cjs +2 -2
  595. package/dist/provider/agent-selection-context.cjs.map +1 -1
  596. package/dist/provider/chat-mode-context.cjs +2 -2
  597. package/dist/provider/chat-mode-context.cjs.map +1 -1
  598. package/dist/provider/session-persistence-context.cjs +10 -0
  599. package/dist/provider/session-persistence-context.cjs.map +1 -0
  600. package/dist/provider/session-persistence-context.d.ts +15 -0
  601. package/dist/provider/session-persistence-context.js +10 -0
  602. package/dist/provider/session-persistence-context.js.map +1 -0
  603. package/dist/provider/statewire-history-context.cjs +4 -4
  604. package/dist/provider/statewire-history-context.cjs.map +1 -1
  605. package/dist/provider/statewire-lifecycle-context.cjs +3 -3
  606. package/dist/provider/statewire-lifecycle-context.cjs.map +1 -1
  607. package/dist/provider/statewire-window-context.cjs +3 -3
  608. package/dist/provider/statewire-window-context.cjs.map +1 -1
  609. package/dist/provider/theme-style-context.cjs +3 -3
  610. package/dist/provider/theme-style-context.cjs.map +1 -1
  611. package/dist/react/package.json.cjs +1 -1
  612. package/dist/react/package.json.js +1 -1
  613. package/dist/runtime/StatewireThreadConfigLaneSync.cjs +10 -10
  614. package/dist/runtime/StatewireThreadConfigLaneSync.cjs.map +1 -1
  615. package/dist/runtime/auth-refusal-restart.cjs +7 -7
  616. package/dist/runtime/auth-refusal-restart.cjs.map +1 -1
  617. package/dist/runtime/auth.cjs +13 -13
  618. package/dist/runtime/auth.cjs.map +1 -1
  619. package/dist/runtime/statewire-lifecycle.cjs +1 -0
  620. package/dist/runtime/statewire-lifecycle.cjs.map +1 -1
  621. package/dist/runtime/statewire-lifecycle.d.ts +3 -1
  622. package/dist/runtime/statewire-lifecycle.js +2 -1
  623. package/dist/runtime/statewire-lifecycle.js.map +1 -1
  624. package/dist/runtime/statewire-server-lane-context.cjs +2 -2
  625. package/dist/runtime/statewire-server-lane-context.cjs.map +1 -1
  626. package/dist/runtime/statewire-session-lane.cjs +4 -4
  627. package/dist/runtime/statewire-session-lane.cjs.map +1 -1
  628. package/dist/runtime/useAthenaStatewireRuntime.cjs +10 -8
  629. package/dist/runtime/useAthenaStatewireRuntime.cjs.map +1 -1
  630. package/dist/runtime/useAthenaStatewireRuntime.d.ts +2 -0
  631. package/dist/runtime/useAthenaStatewireRuntime.js +2 -0
  632. package/dist/runtime/useAthenaStatewireRuntime.js.map +1 -1
  633. package/dist/styles.css +1 -1
  634. package/dist/threads/Inbox.cjs +8 -8
  635. package/dist/threads/Inbox.cjs.map +1 -1
  636. package/dist/threads/SessionList.cjs +9 -9
  637. package/dist/threads/SessionList.cjs.map +1 -1
  638. package/dist/threads/SessionsPage.cjs +11 -11
  639. package/dist/threads/SessionsPage.cjs.map +1 -1
  640. package/dist/threads/api.cjs.map +1 -1
  641. package/dist/threads/api.d.ts +15 -0
  642. package/dist/threads/api.js.map +1 -1
  643. package/dist/threads/conversation-list-fetcher.cjs +13 -5
  644. package/dist/threads/conversation-list-fetcher.cjs.map +1 -1
  645. package/dist/threads/conversation-list-fetcher.d.ts +4 -1
  646. package/dist/threads/conversation-list-fetcher.js +13 -5
  647. package/dist/threads/conversation-list-fetcher.js.map +1 -1
  648. package/dist/threads/index-triggered-refresh.cjs +10 -10
  649. package/dist/threads/index-triggered-refresh.cjs.map +1 -1
  650. package/dist/threads/mark-viewed-thread-read.cjs +12 -12
  651. package/dist/threads/mark-viewed-thread-read.cjs.map +1 -1
  652. package/dist/threads/offline-session-list.cjs +3 -3
  653. package/dist/threads/offline-session-list.cjs.map +1 -1
  654. package/dist/threads/session-list-tab-share.cjs +5 -5
  655. package/dist/threads/session-list-tab-share.cjs.map +1 -1
  656. package/dist/threads/statewire-thread-list.cjs +79 -57
  657. package/dist/threads/statewire-thread-list.cjs.map +1 -1
  658. package/dist/threads/statewire-thread-list.d.ts +20 -8
  659. package/dist/threads/statewire-thread-list.js +28 -6
  660. package/dist/threads/statewire-thread-list.js.map +1 -1
  661. package/dist/threads/thread-id-context.cjs +5 -5
  662. package/dist/threads/thread-id-context.cjs.map +1 -1
  663. package/dist/threads/use-athena-session-attention.cjs +2 -2
  664. package/dist/threads/use-athena-session-attention.cjs.map +1 -1
  665. package/dist/threads/use-athena-sessions.cjs +37 -15
  666. package/dist/threads/use-athena-sessions.cjs.map +1 -1
  667. package/dist/threads/use-athena-sessions.d.ts +10 -5
  668. package/dist/threads/use-athena-sessions.js +28 -6
  669. package/dist/threads/use-athena-sessions.js.map +1 -1
  670. package/dist/threads/use-athena-thread-model.cjs +3 -3
  671. package/dist/threads/use-athena-thread-model.cjs.map +1 -1
  672. package/dist/threads/use-rest-conversation-history.cjs +3 -3
  673. package/dist/threads/use-rest-conversation-history.cjs.map +1 -1
  674. package/dist/threads/use-rest-conversation-history.d.ts +1 -0
  675. package/dist/threads/use-statewire-conversation-history.cjs +8 -8
  676. package/dist/threads/use-statewire-conversation-history.cjs.map +1 -1
  677. package/dist/threads/use-thread-archive.cjs +9 -9
  678. package/dist/threads/use-thread-archive.cjs.map +1 -1
  679. package/dist/threads/use-thread-favorite.cjs +2 -2
  680. package/dist/threads/use-thread-favorite.cjs.map +1 -1
  681. package/dist/threads/use-thread-field-override.cjs +20 -20
  682. package/dist/threads/use-thread-field-override.cjs.map +1 -1
  683. package/dist/threads/use-thread-read-state.cjs +4 -4
  684. package/dist/threads/use-thread-read-state.cjs.map +1 -1
  685. package/dist/threads/use-thread-rename.cjs +2 -2
  686. package/dist/threads/use-thread-rename.cjs.map +1 -1
  687. package/dist/threads/useAthenaThreadManager.cjs +2 -2
  688. package/dist/threads/useAthenaThreadManager.cjs.map +1 -1
  689. package/dist/tools/NestedPtcMessages.cjs +6 -6
  690. package/dist/tools/NestedPtcMessages.cjs.map +1 -1
  691. package/dist/tools/append-document-tool-ui.cjs +7 -7
  692. package/dist/tools/append-document-tool-ui.cjs.map +1 -1
  693. package/dist/tools/file-tool-uis.cjs +2 -2
  694. package/dist/tools/file-tool-uis.cjs.map +1 -1
  695. package/dist/tools/misc-tool-uis.cjs +2 -2
  696. package/dist/tools/misc-tool-uis.cjs.map +1 -1
  697. package/dist/tools/primitives.cjs +6 -6
  698. package/dist/tools/primitives.cjs.map +1 -1
  699. package/dist/tools/read-asset-tool-ui.cjs +6 -6
  700. package/dist/tools/read-asset-tool-ui.cjs.map +1 -1
  701. package/dist/tools/subagent-task-tool-ui.cjs +21 -21
  702. package/dist/tools/subagent-task-tool-ui.cjs.map +1 -1
  703. package/dist/tools/test-recording-tool-uis.cjs +16 -16
  704. package/dist/tools/test-recording-tool-uis.cjs.map +1 -1
  705. package/dist/tools/todo-plan-store.cjs +4 -4
  706. package/dist/tools/todo-plan-store.cjs.map +1 -1
  707. package/dist/tools/tool-appearance.cjs +3 -3
  708. package/dist/tools/tool-appearance.cjs.map +1 -1
  709. package/dist/tools/tool-fallback.cjs +14 -14
  710. package/dist/tools/tool-fallback.cjs.map +1 -1
  711. package/dist/tools/tool-uis.cjs +74 -74
  712. package/dist/tools/tool-uis.cjs.map +1 -1
  713. package/dist/tools/use-elapsed-seconds.cjs +3 -3
  714. package/dist/tools/use-elapsed-seconds.cjs.map +1 -1
  715. package/dist/tools/write-todos-tool-ui.cjs +9 -9
  716. package/dist/tools/write-todos-tool-ui.cjs.map +1 -1
  717. package/dist/ui/image-viewer.cjs +382 -0
  718. package/dist/ui/image-viewer.cjs.map +1 -0
  719. package/dist/ui/image-viewer.d.ts +50 -0
  720. package/dist/ui/image-viewer.js +382 -0
  721. package/dist/ui/image-viewer.js.map +1 -0
  722. package/dist/voice/chat.cjs +6 -0
  723. package/dist/voice/chat.cjs.map +1 -1
  724. package/dist/voice/chat.d.ts +1 -1
  725. package/dist/voice/chat.js +8 -2
  726. package/dist/voice/livekit-join.cjs +52 -101
  727. package/dist/voice/livekit-join.cjs.map +1 -1
  728. package/dist/voice/livekit-join.d.ts +1 -6
  729. package/dist/voice/livekit-join.js +52 -101
  730. package/dist/voice/livekit-join.js.map +1 -1
  731. package/dist/voice/livekit.cjs.map +1 -1
  732. package/dist/voice/livekit.d.ts +11 -1
  733. package/dist/voice/livekit.js.map +1 -1
  734. package/dist/voice/use-athena-voice-session.cjs +34 -34
  735. package/dist/voice/use-athena-voice-session.cjs.map +1 -1
  736. package/dist/workbench/ComputerLiveDesktop.cjs +13 -13
  737. package/dist/workbench/ComputerLiveDesktop.cjs.map +1 -1
  738. package/dist/workbench/SessionWorkbench.cjs +22 -22
  739. package/dist/workbench/SessionWorkbench.cjs.map +1 -1
  740. package/dist/workbench/session-workbench-context.cjs +3 -3
  741. package/dist/workbench/session-workbench-context.cjs.map +1 -1
  742. package/dist/workbench/session-workbench-panes.cjs +8 -8
  743. package/dist/workbench/session-workbench-panes.cjs.map +1 -1
  744. package/dist/workbench/workbench-layout-context.cjs +3 -3
  745. package/dist/workbench/workbench-layout-context.cjs.map +1 -1
  746. package/package.json +2 -1
@@ -1 +1 @@
1
- {"version":3,"file":"use-mention-suggestions.cjs","sources":["../../../../../src/chat-ui/mentions/suggestions/data/use-mention-suggestions.ts"],"sourcesContent":["/**\n * Mention Suggestions Store — shared by every Athena chat host (the Chrome\n * side panel, the Office task pane, the SDK's AthenaChat).\n *\n * Full Olympus-style mention store with all categories:\n * Favorites, Assets, Projects, Browse Profiles, Folders,\n * current/group webpages, Team, Workspace, Drives + Global Search (assets,\n * plus workspace members when Team is offered).\n *\n * Uses registry + cache architecture from Olympus with\n * async data fetching via GraphQL. A host may hand the Tools / Toolkits\n * categories its own list instead of the server catalog (`tools`).\n */\n\nimport { Store } from \"@tanstack/store\";\nimport { useEffect, useMemo, useRef } from \"react\";\nimport type { MentionAuthContext } from \"./api-client\";\nimport { useMentionAuth } from \"./api-client\";\nimport { createItemCache, type ItemCache } from \"./item-cache\";\nimport {\n createScopeRegistry,\n registerSource,\n bindScopes,\n type ScopeRegistry,\n} from \"./scope-registry\";\nimport {\n transformRootCategories,\n fetchAssets,\n fetchFavorites,\n fetchFolders,\n fetchFolderContents,\n fetchTypedAssets,\n fetchTeam,\n fetchTools,\n fetchToolkits,\n fetchDrives,\n fetchGlobalSearch,\n transformProvidedTools,\n withProvidedTools,\n createTeamLoader,\n withTeam,\n} from \"./sources\";\nimport type { MentionTool, WebpageMention } from \"./types\";\n\nexport function webpageMentionFingerprint(\n webpages: readonly WebpageMention[],\n): string {\n return JSON.stringify(\n webpages.map(({ tabId, title, url, isCurrent }) => [\n tabId,\n title,\n url,\n isCurrent,\n ]),\n );\n}\n\n// ── Store types ──\n\nexport interface MentionSuggestionsStoreState {\n registry: ScopeRegistry;\n cache: ItemCache;\n}\n\nexport type MentionSuggestionsStore = Store<MentionSuggestionsStoreState>;\n\n// ── Categories ──\n\n/**\n * All mention menu categories, in display order.\n */\nexport const ROOT_MENTION_CATEGORIES = [\n \"favorites\",\n \"assets\",\n \"projects\",\n \"browse_profiles\",\n \"folders\",\n \"tools\",\n \"toolkits\",\n \"team\",\n \"drives\",\n] as const;\n\nexport type MentionRootCategory = (typeof ROOT_MENTION_CATEGORIES)[number];\n\n// ── Store builder ──\n\n/** Stable fingerprint of a host's tool list, for cache invalidation. */\nexport function providedToolsFingerprint(tools: readonly MentionTool[]): string {\n return JSON.stringify(\n tools.map(({ id, name, type, description, icon }) => [\n id,\n name,\n type,\n description ?? null,\n icon ?? null,\n ]),\n );\n}\n\nfunction buildStore({\n auth,\n getWebpages,\n getTools,\n rootCategories,\n}: {\n auth: MentionAuthContext;\n getWebpages: () => readonly WebpageMention[];\n /** Present when the host supplies the Tools / Toolkits list itself. */\n getTools?: () => readonly MentionTool[];\n rootCategories: readonly MentionRootCategory[];\n}): MentionSuggestionsStore {\n const registry = createScopeRegistry();\n const cache = createItemCache();\n\n // ── Root categories ──\n registerSource(registry, \"root\", transformRootCategories, {\n categories: [...rootCategories],\n getWebpages,\n });\n\n const loadTeam = createTeamLoader(auth);\n\n // ── Global search (aggregated) ──\n // A host's own tools ride along so a root query finds them beside assets,\n // and so do workspace members when the host offers Team.\n const withHostTools = getTools\n ? withProvidedTools(fetchGlobalSearch, getTools)\n : fetchGlobalSearch;\n registerSource(\n registry,\n \"global_search\",\n rootCategories.includes(\"team\") ? withTeam(withHostTools, loadTeam) : withHostTools,\n { auth },\n );\n bindScopes(registry, \"root\", \"global_search\");\n\n // ── Assets ──\n registerSource(registry, \"athena_assets\", fetchAssets, { auth, limit: 50 });\n\n // ── Favorites ──\n registerSource(registry, \"favorites\", fetchFavorites, { auth, limit: 50 });\n\n // ── Folders (flat list) ──\n registerSource(\n registry,\n \"athena_folders\",\n fetchFolders,\n { auth, limit: 50 },\n true /* isFlat */,\n );\n\n // ── Internal drive (folder navigation root) ──\n registerSource(registry, \"internal_drive\", fetchFolderContents, {\n auth,\n limit: 50,\n });\n\n // ── Projects ──\n registerSource(registry, \"athena_projects\", fetchTypedAssets, {\n auth,\n includeOnlyTypes: [\"project\"],\n limit: 50,\n });\n\n // ── Browse Profiles ──\n registerSource(registry, \"athena_browse_profiles\", fetchTypedAssets, {\n auth,\n includeOnlyTypes: [\"browse_profile\"],\n limit: 50,\n });\n\n // ── Tools & Toolkits ── the server catalog, or the host's own list\n if (getTools) {\n registerSource(registry, \"tools\", transformProvidedTools, {\n getTools,\n type: \"tool\",\n });\n registerSource(registry, \"toolkits\", transformProvidedTools, {\n getTools,\n type: \"toolkit\",\n });\n } else {\n registerSource(registry, \"tools\", fetchTools, { auth });\n registerSource(registry, \"toolkits\", fetchToolkits, { auth });\n }\n\n // ── Team ──\n registerSource(registry, \"team\", fetchTeam, { auth, loadTeam });\n\n // ── Drives (catalogs) ──\n registerSource(registry, \"drive_catalogs\", fetchDrives, { auth });\n\n return new Store<MentionSuggestionsStoreState>({ registry, cache });\n}\n\n// ── Hook ──\n\n/**\n * Creates a stable MentionSuggestionsStore.\n * Uses MentionAuthCtx for API credentials.\n */\nexport function useMentionSuggestions({\n webpages,\n tools,\n rootCategories = ROOT_MENTION_CATEGORIES,\n}: {\n webpages: readonly WebpageMention[];\n /**\n * Host-provided Tools / Toolkits candidates. When set (even empty) they\n * replace the server tool catalog for those categories and join root\n * search results; omitted, the categories fetch the catalog.\n */\n tools?: readonly MentionTool[];\n /** Categories shown at the top level; hosts can narrow the default set. */\n rootCategories?: readonly MentionRootCategory[];\n}): {\n store: MentionSuggestionsStore;\n invalidate: (scope: string) => void;\n} {\n const auth = useMentionAuth();\n const webpagesRef = useRef(webpages);\n webpagesRef.current = webpages;\n const toolsRef = useRef(tools);\n toolsRef.current = tools;\n const hasProvidedTools = tools !== undefined;\n\n // Depend on primitive values to avoid rebuilding store on object identity changes\n const store = useMemo(\n () =>\n buildStore({\n auth,\n getWebpages: () => webpagesRef.current,\n getTools: hasProvidedTools ? () => toolsRef.current ?? [] : undefined,\n rootCategories,\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [\n auth.backendUrl,\n auth.accessToken,\n auth.apiKey,\n auth.workspaceId,\n auth.userId,\n hasProvidedTools,\n rootCategories.join(\",\"),\n ],\n );\n\n const invalidate = useMemo(\n () => (scope: string) => {\n const state = store.state;\n const { registry, cache } = state;\n\n // Clear scope from cache\n if (cache.items) {\n for (const item of Object.values(cache.items)) {\n item.visibleInScopes.delete(scope);\n }\n // Remove orphaned items\n for (const [id, item] of Object.entries(cache.items)) {\n if (item.visibleInScopes.size === 0) {\n delete cache.items[id];\n }\n }\n }\n\n // Reset fetch states\n if (registry.entries[scope]) {\n registry.entries[scope].fetchStates = {};\n }\n\n store.setState((prev) => ({ ...prev }));\n },\n [store],\n );\n\n const webpageFingerprint = webpageMentionFingerprint(webpages);\n const previousWebpageFingerprintRef = useRef<string | null>(null);\n\n useEffect(() => {\n if (previousWebpageFingerprintRef.current === webpageFingerprint) return;\n previousWebpageFingerprintRef.current = webpageFingerprint;\n invalidate(\"root\");\n }, [invalidate, webpageFingerprint]);\n\n // A changed tool list drops the cached Tools / Toolkits entries (and the\n // root search results they were folded into) so the next open re-reads it.\n const toolsFingerprint = tools ? providedToolsFingerprint(tools) : null;\n const previousToolsFingerprintRef = useRef<string | null>(null);\n\n useEffect(() => {\n if (previousToolsFingerprintRef.current === toolsFingerprint) return;\n previousToolsFingerprintRef.current = toolsFingerprint;\n if (toolsFingerprint === null) return;\n invalidate(\"tools\");\n invalidate(\"toolkits\");\n invalidate(\"global_search\");\n }, [invalidate, toolsFingerprint]);\n\n return { store, invalidate };\n}\n"],"names":["createScopeRegistry","createItemCache","registerSource","transformRootCategories","createTeamLoader","withProvidedTools","fetchGlobalSearch","withTeam","bindScopes","fetchAssets","fetchFavorites","fetchFolders","fetchFolderContents","fetchTypedAssets","transformProvidedTools","fetchTools","fetchToolkits","fetchTeam","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AAyB,KAAK,IAAI;AACnE,QAAM,8BAA8BH,MAAAA,OAAsB,IAAI;AAE9DG,QAAAA,UAAU,MAAM;AACd,QAAI,4BAA4B,YAAY,iBAAkB;AAC9D,gCAA4B,UAAU;AACtC,QAAI,qBAAqB,KAAM;AAC/B,eAAW,OAAO;AAClB,eAAW,UAAU;AACrB,eAAW,eAAe;AAAA,EAC5B,GAAG,CAAC,YAAY,gBAAgB,CAAC;AAEjC,SAAO,EAAE,OAAAF,QAAO,WAAA;AAClB;;;;;"}
1
+ {"version":3,"file":"use-mention-suggestions.cjs","sources":["../../../../../src/chat-ui/mentions/suggestions/data/use-mention-suggestions.ts"],"sourcesContent":["/**\n * Mention Suggestions Store — shared by every Athena chat host (the Chrome\n * side panel, the Office task pane, the SDK's AthenaChat).\n *\n * Full Olympus-style mention store with all categories:\n * Favorites, Assets, Projects, Browse Profiles, Folders,\n * current/group webpages, Team, Workspace, Drives + Global Search (assets,\n * plus workspace members when Team is offered).\n *\n * Uses registry + cache architecture from Olympus with\n * async data fetching via GraphQL. A host may hand the Tools / Toolkits\n * categories its own list instead of the server catalog (`tools`).\n */\n\nimport type { LabelCopy } from \"@athenaintel/agent-runtime/offline-status\";\nimport { Store } from \"@tanstack/store\";\nimport { useEffect, useLayoutEffect, useMemo, useRef } from \"react\";\nimport type { MentionAuthContext } from \"./api-client\";\nimport { useMentionAuth } from \"./api-client\";\nimport { createItemCache, type ItemCache } from \"./item-cache\";\nimport { retryFailedFetches } from \"./orchestrator\";\nimport {\n createScopeRegistry,\n registerSource,\n bindScopes,\n type ScopeRegistry,\n} from \"./scope-registry\";\nimport {\n transformRootCategories,\n fetchAssets,\n fetchFavorites,\n fetchFolders,\n fetchFolderContents,\n fetchTypedAssets,\n fetchTeam,\n fetchTools,\n fetchToolkits,\n fetchDrives,\n fetchGlobalSearch,\n transformProvidedTools,\n withProvidedTools,\n createTeamLoader,\n withTeam,\n} from \"./sources\";\nimport type { MentionTool, WebpageMention } from \"./types\";\n\nexport function webpageMentionFingerprint(\n webpages: readonly WebpageMention[],\n): string {\n return JSON.stringify(\n webpages.map(({ tabId, title, url, isCurrent }) => [\n tabId,\n title,\n url,\n isCurrent,\n ]),\n );\n}\n\n// ── Store types ──\n\nexport interface MentionSuggestionsStoreState {\n registry: ScopeRegistry;\n cache: ItemCache;\n /**\n * Why nothing is asked of Athena right now, or `null` while it answers: the\n * scopes whose source asks Athena fetch nothing and say this instead, while\n * the host's own items (its tabs, its tool list) and what was already loaded\n * still show.\n */\n athenaUnavailable: LabelCopy | null;\n}\n\nexport type MentionSuggestionsStore = Store<MentionSuggestionsStoreState>;\n\n// ── Categories ──\n\n/**\n * All mention menu categories, in display order.\n */\nexport const ROOT_MENTION_CATEGORIES = [\n \"favorites\",\n \"assets\",\n \"projects\",\n \"browse_profiles\",\n \"folders\",\n \"tools\",\n \"toolkits\",\n \"team\",\n \"drives\",\n] as const;\n\nexport type MentionRootCategory = (typeof ROOT_MENTION_CATEGORIES)[number];\n\n// ── Store builder ──\n\n/** Stable fingerprint of a host's tool list, for cache invalidation. */\nexport function providedToolsFingerprint(tools: readonly MentionTool[]): string {\n return JSON.stringify(\n tools.map(({ id, name, type, description, icon }) => [\n id,\n name,\n type,\n description ?? null,\n icon ?? null,\n ]),\n );\n}\n\nfunction buildStore({\n auth,\n getWebpages,\n getTools,\n rootCategories,\n athenaUnavailable,\n}: {\n auth: MentionAuthContext;\n getWebpages: () => readonly WebpageMention[];\n /** Present when the host supplies the Tools / Toolkits list itself. */\n getTools?: () => readonly MentionTool[];\n rootCategories: readonly MentionRootCategory[];\n athenaUnavailable: LabelCopy | null;\n}): MentionSuggestionsStore {\n const registry = createScopeRegistry();\n const cache = createItemCache();\n\n // ── Root categories ──\n registerSource(registry, \"root\", transformRootCategories, {\n categories: [...rootCategories],\n getWebpages,\n });\n\n const loadTeam = createTeamLoader(auth);\n\n // ── Global search (aggregated) ──\n // A host's own tools ride along so a root query finds them beside assets,\n // and so do workspace members when the host offers Team.\n const withHostTools = getTools\n ? withProvidedTools(fetchGlobalSearch, getTools)\n : fetchGlobalSearch;\n registerSource(\n registry,\n \"global_search\",\n rootCategories.includes(\"team\") ? withTeam(withHostTools, loadTeam) : withHostTools,\n { auth },\n );\n bindScopes(registry, \"root\", \"global_search\");\n\n // ── Assets ──\n registerSource(registry, \"athena_assets\", fetchAssets, { auth, limit: 50 });\n\n // ── Favorites ──\n registerSource(registry, \"favorites\", fetchFavorites, { auth, limit: 50 });\n\n // ── Folders (flat list) ──\n registerSource(\n registry,\n \"athena_folders\",\n fetchFolders,\n { auth, limit: 50 },\n true /* isFlat */,\n );\n\n // ── Internal drive (folder navigation root) ──\n registerSource(registry, \"internal_drive\", fetchFolderContents, {\n auth,\n limit: 50,\n });\n\n // ── Projects ──\n registerSource(registry, \"athena_projects\", fetchTypedAssets, {\n auth,\n includeOnlyTypes: [\"project\"],\n limit: 50,\n });\n\n // ── Browse Profiles ──\n registerSource(registry, \"athena_browse_profiles\", fetchTypedAssets, {\n auth,\n includeOnlyTypes: [\"browse_profile\"],\n limit: 50,\n });\n\n // ── Tools & Toolkits ── the server catalog, or the host's own list\n if (getTools) {\n registerSource(registry, \"tools\", transformProvidedTools, {\n getTools,\n type: \"tool\",\n });\n registerSource(registry, \"toolkits\", transformProvidedTools, {\n getTools,\n type: \"toolkit\",\n });\n } else {\n registerSource(registry, \"tools\", fetchTools, { auth });\n registerSource(registry, \"toolkits\", fetchToolkits, { auth });\n }\n\n // ── Team ──\n registerSource(registry, \"team\", fetchTeam, { auth, loadTeam });\n\n // ── Drives (catalogs) ──\n registerSource(registry, \"drive_catalogs\", fetchDrives, { auth });\n\n return new Store<MentionSuggestionsStoreState>({\n registry,\n cache,\n athenaUnavailable,\n });\n}\n\n/** Two reasons say the same thing (a host may hand a new object with the same words). */\nfunction sameReason(a: LabelCopy | null, b: LabelCopy | null): boolean {\n if (a === null || b === null) return a === b;\n return a.label === b.label && a.detail === b.detail;\n}\n\n// ── Hook ──\n\n/**\n * Creates a stable MentionSuggestionsStore.\n * Uses MentionAuthCtx for API credentials.\n */\nexport function useMentionSuggestions({\n webpages,\n tools,\n rootCategories = ROOT_MENTION_CATEGORIES,\n athenaUnavailable = null,\n}: {\n webpages: readonly WebpageMention[];\n /**\n * Host-provided Tools / Toolkits candidates. When set (even empty) they\n * replace the server tool catalog for those categories and join root\n * search results; omitted, the categories fetch the catalog.\n */\n tools?: readonly MentionTool[];\n /** Categories shown at the top level; hosts can narrow the default set. */\n rootCategories?: readonly MentionRootCategory[];\n /**\n * Why nothing may be asked of Athena right now (`NEEDS_CONNECTION` while\n * Athena can't be reached), or `null`. Once it clears, the lookups that\n * failed meanwhile run again.\n */\n athenaUnavailable?: LabelCopy | null;\n}): {\n store: MentionSuggestionsStore;\n invalidate: (scope: string) => void;\n} {\n const auth = useMentionAuth();\n const webpagesRef = useRef(webpages);\n webpagesRef.current = webpages;\n const toolsRef = useRef(tools);\n toolsRef.current = tools;\n const hasProvidedTools = tools !== undefined;\n // Read once per store build: a store rebuilt meanwhile starts where the host stands.\n const athenaUnavailableRef = useRef(athenaUnavailable);\n athenaUnavailableRef.current = athenaUnavailable;\n\n // Depend on primitive values to avoid rebuilding store on object identity changes\n const store = useMemo(\n () =>\n buildStore({\n auth,\n getWebpages: () => webpagesRef.current,\n getTools: hasProvidedTools ? () => toolsRef.current ?? [] : undefined,\n rootCategories,\n athenaUnavailable: athenaUnavailableRef.current,\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [\n auth.backendUrl,\n auth.accessToken,\n auth.apiKey,\n auth.workspaceId,\n auth.userId,\n hasProvidedTools,\n rootCategories.join(\",\"),\n ],\n );\n\n const invalidate = useMemo(\n () => (scope: string) => {\n const state = store.state;\n const { registry, cache } = state;\n\n // Clear scope from cache\n if (cache.items) {\n for (const item of Object.values(cache.items)) {\n item.visibleInScopes.delete(scope);\n }\n // Remove orphaned items\n for (const [id, item] of Object.entries(cache.items)) {\n if (item.visibleInScopes.size === 0) {\n delete cache.items[id];\n }\n }\n }\n\n // Reset fetch states\n if (registry.entries[scope]) {\n registry.entries[scope].fetchStates = {};\n }\n\n store.setState((prev) => ({ ...prev }));\n },\n [store],\n );\n\n // Before the menu's own effects run, so no lookup leaves under a stale answer;\n // a value that changed nothing keeps the store's state (and its readers) as is.\n useLayoutEffect(() => {\n const unavailableBefore = store.state.athenaUnavailable;\n if (sameReason(unavailableBefore, athenaUnavailable)) return;\n store.setState((prev) => ({ ...prev, athenaUnavailable }));\n if (unavailableBefore !== null && athenaUnavailable === null) {\n retryFailedFetches(store);\n }\n }, [athenaUnavailable, store]);\n\n const webpageFingerprint = webpageMentionFingerprint(webpages);\n const previousWebpageFingerprintRef = useRef<string | null>(null);\n\n useEffect(() => {\n if (previousWebpageFingerprintRef.current === webpageFingerprint) return;\n previousWebpageFingerprintRef.current = webpageFingerprint;\n invalidate(\"root\");\n }, [invalidate, webpageFingerprint]);\n\n // A changed tool list drops the cached Tools / Toolkits entries (and the\n // root search results they were folded into) so the next open re-reads it.\n const toolsFingerprint = tools ? providedToolsFingerprint(tools) : null;\n const previousToolsFingerprintRef = useRef<string | null>(null);\n\n useEffect(() => {\n if (previousToolsFingerprintRef.current === toolsFingerprint) return;\n previousToolsFingerprintRef.current = toolsFingerprint;\n if (toolsFingerprint === null) return;\n invalidate(\"tools\");\n invalidate(\"toolkits\");\n invalidate(\"global_search\");\n }, [invalidate, toolsFingerprint]);\n\n return { store, invalidate };\n}\n"],"names":["createScopeRegistry","createItemCache","registerSource","transformRootCategories","createTeamLoader","withProvidedTools","fetchGlobalSearch","withTeam","bindScopes","fetchAssets","fetchFavorites","fetchFolders","fetchFolderContents","fetchTypedAssets","transformProvidedTools","fetchTools","fetchToolkits","fetchTeam","fetchDrives","Store","useMentionAuth","useRef","store","useMemo","useLayoutEffect","retryFailedFetches","useEffect"],"mappings":";;;;;;;;;AA8CO,SAAS,0BACd,UACQ;AACR,SAAO,KAAK;AAAA,IACV,SAAS,IAAI,CAAC,EAAE,OAAO,OAAO,K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ACtD,IAAAA,OAAM,SAAS,CAAC,UAAU,EAAE,GAAG,MAAM,oBAAoB;AACzD,QAAI,sBAAsB,QAAQ,sBAAsB,MAAM;AAC5DG,mBAAAA,mBAAmBH,MAAK;AAAA,IAC1B;AAAA,EACF,GAAG,CAAC,mBAAmBA,MAAK,CAAC;AAE7B,QAAM,qBAAqB,0BAA0B,QAAQ;AAC7D,QAAM,gCAAgCD,WAAAA,OAAsB,IAAI;AAEhEK,aAAAA,UAAU,MAAM;AACd,QAAI,8BAA8B,YAAY,mBAAoB;AAClE,kCAA8B,UAAU;AACxC,eAAW,MAAM;AAAA,EACnB,GAAG,CAAC,YAAY,kBAAkB,CAAC;AAInC,QAAM,mBAAmB,QAAQ,yBAAyB,KAAK,IAAI;AACnE,QAAM,8BAA8BL,WAAAA,OAAsB,IAAI;AAE9DK,aAAAA,UAAU,MAAM;AACd,QAAI,4BAA4B,YAAY,iBAAkB;AAC9D,gCAA4B,UAAU;AACtC,QAAI,qBAAqB,KAAM;AAC/B,eAAW,OAAO;AAClB,eAAW,UAAU;AACrB,eAAW,eAAe;AAAA,EAC5B,GAAG,CAAC,YAAY,gBAAgB,CAAC;AAEjC,SAAO,EAAE,OAAAJ,QAAO,WAAA;AAClB;;;;;"}
@@ -11,6 +11,7 @@
11
11
  * async data fetching via GraphQL. A host may hand the Tools / Toolkits
12
12
  * categories its own list instead of the server catalog (`tools`).
13
13
  */
14
+ import type { LabelCopy } from "../../../../agent-runtime/src/offline-status";
14
15
  import { Store } from "@tanstack/store";
15
16
  import { type ItemCache } from "./item-cache";
16
17
  import { type ScopeRegistry } from "./scope-registry";
@@ -19,6 +20,13 @@ export declare function webpageMentionFingerprint(webpages: readonly WebpageMent
19
20
  export interface MentionSuggestionsStoreState {
20
21
  registry: ScopeRegistry;
21
22
  cache: ItemCache;
23
+ /**
24
+ * Why nothing is asked of Athena right now, or `null` while it answers: the
25
+ * scopes whose source asks Athena fetch nothing and say this instead, while
26
+ * the host's own items (its tabs, its tool list) and what was already loaded
27
+ * still show.
28
+ */
29
+ athenaUnavailable: LabelCopy | null;
22
30
  }
23
31
  export type MentionSuggestionsStore = Store<MentionSuggestionsStoreState>;
24
32
  /**
@@ -32,7 +40,7 @@ export declare function providedToolsFingerprint(tools: readonly MentionTool[]):
32
40
  * Creates a stable MentionSuggestionsStore.
33
41
  * Uses MentionAuthCtx for API credentials.
34
42
  */
35
- export declare function useMentionSuggestions({ webpages, tools, rootCategories, }: {
43
+ export declare function useMentionSuggestions({ webpages, tools, rootCategories, athenaUnavailable, }: {
36
44
  webpages: readonly WebpageMention[];
37
45
  /**
38
46
  * Host-provided Tools / Toolkits candidates. When set (even empty) they
@@ -42,6 +50,12 @@ export declare function useMentionSuggestions({ webpages, tools, rootCategories,
42
50
  tools?: readonly MentionTool[];
43
51
  /** Categories shown at the top level; hosts can narrow the default set. */
44
52
  rootCategories?: readonly MentionRootCategory[];
53
+ /**
54
+ * Why nothing may be asked of Athena right now (`NEEDS_CONNECTION` while
55
+ * Athena can't be reached), or `null`. Once it clears, the lookups that
56
+ * failed meanwhile run again.
57
+ */
58
+ athenaUnavailable?: LabelCopy | null;
45
59
  }): {
46
60
  store: MentionSuggestionsStore;
47
61
  invalidate: (scope: string) => void;
@@ -1,9 +1,10 @@
1
1
  import { Store } from "@tanstack/store";
2
- import { useRef, useMemo, useEffect } from "react";
2
+ import { useRef, useMemo, useLayoutEffect, useEffect } from "react";
3
3
  import { useMentionAuth } from "./api-client.js";
4
4
  import { createItemCache } from "./item-cache.js";
5
+ import { retryFailedFetches } from "./orchestrator.js";
5
6
  import { registerSource, bindScopes, createScopeRegistry } from "./scope-registry.js";
6
- import { transformRootCategories, withTeam, withProvidedTools, fetchGlobalSearch, fetchAssets, fetchFavorites, fetchFolders, fetchFolderContents, fetchTypedAssets, transformProvidedTools, fetchTools, fetchToolkits, fetchTeam, fetchDrives, createTeamLoader } from "./sources/index.js";
7
+ import { transformRootCategories, withProvidedTools, fetchGlobalSearch, withTeam, fetchAssets, fetchFavorites, fetchFolders, fetchFolderContents, fetchTypedAssets, transformProvidedTools, fetchTools, fetchToolkits, fetchTeam, fetchDrives, createTeamLoader } from "./sources/index.js";
7
8
  function webpageMentionFingerprint(webpages) {
8
9
  return JSON.stringify(
9
10
  webpages.map(({ tabId, title, url, isCurrent }) => [
@@ -40,7 +41,8 @@ function buildStore({
40
41
  auth,
41
42
  getWebpages,
42
43
  getTools,
43
- rootCategories
44
+ rootCategories,
45
+ athenaUnavailable
44
46
  }) {
45
47
  const registry = createScopeRegistry();
46
48
  const cache = createItemCache();
@@ -95,12 +97,21 @@ function buildStore({
95
97
  }
96
98
  registerSource(registry, "team", fetchTeam, { auth, loadTeam });
97
99
  registerSource(registry, "drive_catalogs", fetchDrives, { auth });
98
- return new Store({ registry, cache });
100
+ return new Store({
101
+ registry,
102
+ cache,
103
+ athenaUnavailable
104
+ });
105
+ }
106
+ function sameReason(a, b) {
107
+ if (a === null || b === null) return a === b;
108
+ return a.label === b.label && a.detail === b.detail;
99
109
  }
100
110
  function useMentionSuggestions({
101
111
  webpages,
102
112
  tools,
103
- rootCategories = ROOT_MENTION_CATEGORIES
113
+ rootCategories = ROOT_MENTION_CATEGORIES,
114
+ athenaUnavailable = null
104
115
  }) {
105
116
  const auth = useMentionAuth();
106
117
  const webpagesRef = useRef(webpages);
@@ -108,12 +119,15 @@ function useMentionSuggestions({
108
119
  const toolsRef = useRef(tools);
109
120
  toolsRef.current = tools;
110
121
  const hasProvidedTools = tools !== void 0;
122
+ const athenaUnavailableRef = useRef(athenaUnavailable);
123
+ athenaUnavailableRef.current = athenaUnavailable;
111
124
  const store = useMemo(
112
125
  () => buildStore({
113
126
  auth,
114
127
  getWebpages: () => webpagesRef.current,
115
128
  getTools: hasProvidedTools ? () => toolsRef.current ?? [] : void 0,
116
- rootCategories
129
+ rootCategories,
130
+ athenaUnavailable: athenaUnavailableRef.current
117
131
  }),
118
132
  // eslint-disable-next-line react-hooks/exhaustive-deps
119
133
  [
@@ -147,6 +161,14 @@ function useMentionSuggestions({
147
161
  },
148
162
  [store]
149
163
  );
164
+ useLayoutEffect(() => {
165
+ const unavailableBefore = store.state.athenaUnavailable;
166
+ if (sameReason(unavailableBefore, athenaUnavailable)) return;
167
+ store.setState((prev) => ({ ...prev, athenaUnavailable }));
168
+ if (unavailableBefore !== null && athenaUnavailable === null) {
169
+ retryFailedFetches(store);
170
+ }
171
+ }, [athenaUnavailable, store]);
150
172
  const webpageFingerprint = webpageMentionFingerprint(webpages);
151
173
  const previousWebpageFingerprintRef = useRef(null);
152
174
  useEffect(() => {
@@ -1 +1 @@
1
- {"version":3,"file":"use-mention-suggestions.js","sources":["../../../../../src/chat-ui/mentions/suggestions/data/use-mention-suggestions.ts"],"sourcesContent":["/**\n * Mention Suggestions Store — shared by every Athena chat host (the Chrome\n * side panel, the Office task pane, the SDK's AthenaChat).\n *\n * Full Olympus-style mention store with all categories:\n * Favorites, Assets, Projects, Browse Profiles, Folders,\n * current/group webpages, Team, Workspace, Drives + Global Search (assets,\n * plus workspace members when Team is offered).\n *\n * Uses registry + cache architecture from Olympus with\n * async data fetching via GraphQL. A host may hand the Tools / Toolkits\n * categories its own list instead of the server catalog (`tools`).\n */\n\nimport { Store } from \"@tanstack/store\";\nimport { useEffect, useMemo, useRef } from \"react\";\nimport type { MentionAuthContext } from \"./api-client\";\nimport { useMentionAuth } from \"./api-client\";\nimport { createItemCache, type ItemCache } from \"./item-cache\";\nimport {\n createScopeRegistry,\n registerSource,\n bindScopes,\n type ScopeRegistry,\n} from \"./scope-registry\";\nimport {\n transformRootCategories,\n fetchAssets,\n fetchFavorites,\n fetchFolders,\n fetchFolderContents,\n fetchTypedAssets,\n fetchTeam,\n fetchTools,\n fetchToolkits,\n fetchDrives,\n fetchGlobalSearch,\n transformProvidedTools,\n withProvidedTools,\n createTeamLoader,\n withTeam,\n} from \"./sources\";\nimport type { MentionTool, WebpageMention } from \"./types\";\n\nexport function webpageMentionFingerprint(\n webpages: readonly WebpageMention[],\n): string {\n return JSON.stringify(\n webpages.map(({ tabId, title, url, isCurrent }) => [\n tabId,\n title,\n url,\n isCurrent,\n ]),\n );\n}\n\n// ── Store types ──\n\nexport interface MentionSuggestionsStoreState {\n registry: ScopeRegistry;\n cache: ItemCache;\n}\n\nexport type MentionSuggestionsStore = Store<MentionSuggestionsStoreState>;\n\n// ── Categories ──\n\n/**\n * All mention menu categories, in display order.\n */\nexport const ROOT_MENTION_CATEGORIES = [\n \"favorites\",\n \"assets\",\n \"projects\",\n \"browse_profiles\",\n \"folders\",\n \"tools\",\n \"toolkits\",\n \"team\",\n \"drives\",\n] as const;\n\nexport type MentionRootCategory = (typeof ROOT_MENTION_CATEGORIES)[number];\n\n// ── Store builder ──\n\n/** Stable fingerprint of a host's tool list, for cache invalidation. */\nexport function providedToolsFingerprint(tools: readonly MentionTool[]): string {\n return JSON.stringify(\n tools.map(({ id, name, type, description, icon }) => [\n id,\n name,\n type,\n description ?? null,\n icon ?? null,\n ]),\n );\n}\n\nfunction buildStore({\n auth,\n getWebpages,\n getTools,\n rootCategories,\n}: {\n auth: MentionAuthContext;\n getWebpages: () => readonly WebpageMention[];\n /** Present when the host supplies the Tools / Toolkits list itself. */\n getTools?: () => readonly MentionTool[];\n rootCategories: readonly MentionRootCategory[];\n}): MentionSuggestionsStore {\n const registry = createScopeRegistry();\n const cache = createItemCache();\n\n // ── Root categories ──\n registerSource(registry, \"root\", transformRootCategories, {\n categories: [...rootCategories],\n getWebpages,\n });\n\n const loadTeam = createTeamLoader(auth);\n\n // ── Global search (aggregated) ──\n // A host's own tools ride along so a root query finds them beside assets,\n // and so do workspace members when the host offers Team.\n const withHostTools = getTools\n ? withProvidedTools(fetchGlobalSearch, getTools)\n : fetchGlobalSearch;\n registerSource(\n registry,\n \"global_search\",\n rootCategories.includes(\"team\") ? withTeam(withHostTools, loadTeam) : withHostTools,\n { auth },\n );\n bindScopes(registry, \"root\", \"global_search\");\n\n // ── Assets ──\n registerSource(registry, \"athena_assets\", fetchAssets, { auth, limit: 50 });\n\n // ── Favorites ──\n registerSource(registry, \"favorites\", fetchFavorites, { auth, limit: 50 });\n\n // ── Folders (flat list) ──\n registerSource(\n registry,\n \"athena_folders\",\n fetchFolders,\n { auth, limit: 50 },\n true /* isFlat */,\n );\n\n // ── Internal drive (folder navigation root) ──\n registerSource(registry, \"internal_drive\", fetchFolderContents, {\n auth,\n limit: 50,\n });\n\n // ── Projects ──\n registerSource(registry, \"athena_projects\", fetchTypedAssets, {\n auth,\n includeOnlyTypes: [\"project\"],\n limit: 50,\n });\n\n // ── Browse Profiles ──\n registerSource(registry, \"athena_browse_profiles\", fetchTypedAssets, {\n auth,\n includeOnlyTypes: [\"browse_profile\"],\n limit: 50,\n });\n\n // ── Tools & Toolkits ── the server catalog, or the host's own list\n if (getTools) {\n registerSource(registry, \"tools\", transformProvidedTools, {\n getTools,\n type: \"tool\",\n });\n registerSource(registry, \"toolkits\", transformProvidedTools, {\n getTools,\n type: \"toolkit\",\n });\n } else {\n registerSource(registry, \"tools\", fetchTools, { auth });\n registerSource(registry, \"toolkits\", fetchToolkits, { auth });\n }\n\n // ── Team ──\n registerSource(registry, \"team\", fetchTeam, { auth, loadTeam });\n\n // ── Drives (catalogs) ──\n registerSource(registry, \"drive_catalogs\", fetchDrives, { auth });\n\n return new Store<MentionSuggestionsStoreState>({ registry, cache });\n}\n\n// ── Hook ──\n\n/**\n * Creates a stable MentionSuggestionsStore.\n * Uses MentionAuthCtx for API credentials.\n */\nexport function useMentionSuggestions({\n webpages,\n tools,\n rootCategories = ROOT_MENTION_CATEGORIES,\n}: {\n webpages: readonly WebpageMention[];\n /**\n * Host-provided Tools / Toolkits candidates. When set (even empty) they\n * replace the server tool catalog for those categories and join root\n * search results; omitted, the categories fetch the catalog.\n */\n tools?: readonly MentionTool[];\n /** Categories shown at the top level; hosts can narrow the default set. */\n rootCategories?: readonly MentionRootCategory[];\n}): {\n store: MentionSuggestionsStore;\n invalidate: (scope: string) => void;\n} {\n const auth = useMentionAuth();\n const webpagesRef = useRef(webpages);\n webpagesRef.current = webpages;\n const toolsRef = useRef(tools);\n toolsRef.current = tools;\n const hasProvidedTools = tools !== undefined;\n\n // Depend on primitive values to avoid rebuilding store on object identity changes\n const store = useMemo(\n () =>\n buildStore({\n auth,\n getWebpages: () => webpagesRef.current,\n getTools: hasProvidedTools ? () => toolsRef.current ?? [] : undefined,\n rootCategories,\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [\n auth.backendUrl,\n auth.accessToken,\n auth.apiKey,\n auth.workspaceId,\n auth.userId,\n hasProvidedTools,\n rootCategories.join(\",\"),\n ],\n );\n\n const invalidate = useMemo(\n () => (scope: string) => {\n const state = store.state;\n const { registry, cache } = state;\n\n // Clear scope from cache\n if (cache.items) {\n for (const item of Object.values(cache.items)) {\n item.visibleInScopes.delete(scope);\n }\n // Remove orphaned items\n for (const [id, item] of Object.entries(cache.items)) {\n if (item.visibleInScopes.size === 0) {\n delete cache.items[id];\n }\n }\n }\n\n // Reset fetch states\n if (registry.entries[scope]) {\n registry.entries[scope].fetchStates = {};\n }\n\n store.setState((prev) => ({ ...prev }));\n },\n [store],\n );\n\n const webpageFingerprint = webpageMentionFingerprint(webpages);\n const previousWebpageFingerprintRef = useRef<string | null>(null);\n\n useEffect(() => {\n if (previousWebpageFingerprintRef.current === webpageFingerprint) return;\n previousWebpageFingerprintRef.current = webpageFingerprint;\n invalidate(\"root\");\n }, [invalidate, webpageFingerprint]);\n\n // A changed tool list drops the cached Tools / Toolkits entries (and the\n // root search results they were folded into) so the next open re-reads it.\n const toolsFingerprint = tools ? providedToolsFingerprint(tools) : null;\n const previousToolsFingerprintRef = useRef<string | null>(null);\n\n useEffect(() => {\n if (previousToolsFingerprintRef.current === toolsFingerprint) return;\n previousToolsFingerprintRef.current = toolsFingerprint;\n if (toolsFingerprint === null) return;\n invalidate(\"tools\");\n invalidate(\"toolkits\");\n invalidate(\"global_search\");\n }, [invalidate, toolsFingerprint]);\n\n return { store, invalidate };\n}\n"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ggestions.js","sources":["../../../../../src/chat-ui/mentions/suggestions/data/use-mention-suggestions.ts"],"sourcesContent":["/**\n * Mention Suggestions Store — shared by every Athena chat host (the Chrome\n * side panel, the Office task pane, the SDK's AthenaChat).\n *\n * Full Olympus-style mention store with all categories:\n * Favorites, Assets, Projects, Browse Profiles, Folders,\n * current/group webpages, Team, Workspace, Drives + Global Search (assets,\n * plus workspace members when Team is offered).\n *\n * Uses registry + cache architecture from Olympus with\n * async data fetching via GraphQL. A host may hand the Tools / Toolkits\n * categories its own list instead of the server catalog (`tools`).\n */\n\nimport type { LabelCopy } from \"@athenaintel/agent-runtime/offline-status\";\nimport { Store } from \"@tanstack/store\";\nimport { useEffect, useLayoutEffect, useMemo, useRef } from \"react\";\nimport type { MentionAuthContext } from \"./api-client\";\nimport { useMentionAuth } from \"./api-client\";\nimport { createItemCache, type ItemCache } from \"./item-cache\";\nimport { retryFailedFetches } from \"./orchestrator\";\nimport {\n createScopeRegistry,\n registerSource,\n bindScopes,\n type ScopeRegistry,\n} from \"./scope-registry\";\nimport {\n transformRootCategories,\n fetchAssets,\n fetchFavorites,\n fetchFolders,\n fetchFolderContents,\n fetchTypedAssets,\n fetchTeam,\n fetchTools,\n fetchToolkits,\n fetchDrives,\n fetchGlobalSearch,\n transformProvidedTools,\n withProvidedTools,\n createTeamLoader,\n withTeam,\n} from \"./sources\";\nimport type { MentionTool, WebpageMention } from \"./types\";\n\nexport function webpageMentionFingerprint(\n webpages: readonly WebpageMention[],\n): string {\n return JSON.stringify(\n webpages.map(({ tabId, title, url, isCurrent }) => [\n tabId,\n title,\n url,\n isCurrent,\n ]),\n );\n}\n\n// ── Store types ──\n\nexport interface MentionSuggestionsStoreState {\n registry: ScopeRegistry;\n cache: ItemCache;\n /**\n * Why nothing is asked of Athena right now, or `null` while it answers: the\n * scopes whose source asks Athena fetch nothing and say this instead, while\n * the host's own items (its tabs, its tool list) and what was already loaded\n * still show.\n */\n athenaUnavailable: LabelCopy | null;\n}\n\nexport type MentionSuggestionsStore = Store<MentionSuggestionsStoreState>;\n\n// ── Categories ──\n\n/**\n * All mention menu categories, in display order.\n */\nexport const ROOT_MENTION_CATEGORIES = [\n \"favorites\",\n \"assets\",\n \"projects\",\n \"browse_profiles\",\n \"folders\",\n \"tools\",\n \"toolkits\",\n \"team\",\n \"drives\",\n] as const;\n\nexport type MentionRootCategory = (typeof ROOT_MENTION_CATEGORIES)[number];\n\n// ── Store builder ──\n\n/** Stable fingerprint of a host's tool list, for cache invalidation. */\nexport function providedToolsFingerprint(tools: readonly MentionTool[]): string {\n return JSON.stringify(\n tools.map(({ id, name, type, description, icon }) => [\n id,\n name,\n type,\n description ?? null,\n icon ?? null,\n ]),\n );\n}\n\nfunction buildStore({\n auth,\n getWebpages,\n getTools,\n rootCategories,\n athenaUnavailable,\n}: {\n auth: MentionAuthContext;\n getWebpages: () => readonly WebpageMention[];\n /** Present when the host supplies the Tools / Toolkits list itself. */\n getTools?: () => readonly MentionTool[];\n rootCategories: readonly MentionRootCategory[];\n athenaUnavailable: LabelCopy | null;\n}): MentionSuggestionsStore {\n const registry = createScopeRegistry();\n const cache = createItemCache();\n\n // ── Root categories ──\n registerSource(registry, \"root\", transformRootCategories, {\n categories: [...rootCategories],\n getWebpages,\n });\n\n const loadTeam = createTeamLoader(auth);\n\n // ── Global search (aggregated) ──\n // A host's own tools ride along so a root query finds them beside assets,\n // and so do workspace members when the host offers Team.\n const withHostTools = getTools\n ? withProvidedTools(fetchGlobalSearch, getTools)\n : fetchGlobalSearch;\n registerSource(\n registry,\n \"global_search\",\n rootCategories.includes(\"team\") ? withTeam(withHostTools, loadTeam) : withHostTools,\n { auth },\n );\n bindScopes(registry, \"root\", \"global_search\");\n\n // ── Assets ──\n registerSource(registry, \"athena_assets\", fetchAssets, { auth, limit: 50 });\n\n // ── Favorites ──\n registerSource(registry, \"favorites\", fetchFavorites, { auth, limit: 50 });\n\n // ── Folders (flat list) ──\n registerSource(\n registry,\n \"athena_folders\",\n fetchFolders,\n { auth, limit: 50 },\n true /* isFlat */,\n );\n\n // ── Internal drive (folder navigation root) ──\n registerSource(registry, \"internal_drive\", fetchFolderContents, {\n auth,\n limit: 50,\n });\n\n // ── Projects ──\n registerSource(registry, \"athena_projects\", fetchTypedAssets, {\n auth,\n includeOnlyTypes: [\"project\"],\n limit: 50,\n });\n\n // ── Browse Profiles ──\n registerSource(registry, \"athena_browse_profiles\", fetchTypedAssets, {\n auth,\n includeOnlyTypes: [\"browse_profile\"],\n limit: 50,\n });\n\n // ── Tools & Toolkits ── the server catalog, or the host's own list\n if (getTools) {\n registerSource(registry, \"tools\", transformProvidedTools, {\n getTools,\n type: \"tool\",\n });\n registerSource(registry, \"toolkits\", transformProvidedTools, {\n getTools,\n type: \"toolkit\",\n });\n } else {\n registerSource(registry, \"tools\", fetchTools, { auth });\n registerSource(registry, \"toolkits\", fetchToolkits, { auth });\n }\n\n // ── Team ──\n registerSource(registry, \"team\", fetchTeam, { auth, loadTeam });\n\n // ── Drives (catalogs) ──\n registerSource(registry, \"drive_catalogs\", fetchDrives, { auth });\n\n return new Store<MentionSuggestionsStoreState>({\n registry,\n cache,\n athenaUnavailable,\n });\n}\n\n/** Two reasons say the same thing (a host may hand a new object with the same words). */\nfunction sameReason(a: LabelCopy | null, b: LabelCopy | null): boolean {\n if (a === null || b === null) return a === b;\n return a.label === b.label && a.detail === b.detail;\n}\n\n// ── Hook ──\n\n/**\n * Creates a stable MentionSuggestionsStore.\n * Uses MentionAuthCtx for API credentials.\n */\nexport function useMentionSuggestions({\n webpages,\n tools,\n rootCategories = ROOT_MENTION_CATEGORIES,\n athenaUnavailable = null,\n}: {\n webpages: readonly WebpageMention[];\n /**\n * Host-provided Tools / Toolkits candidates. When set (even empty) they\n * replace the server tool catalog for those categories and join root\n * search results; omitted, the categories fetch the catalog.\n */\n tools?: readonly MentionTool[];\n /** Categories shown at the top level; hosts can narrow the default set. */\n rootCategories?: readonly MentionRootCategory[];\n /**\n * Why nothing may be asked of Athena right now (`NEEDS_CONNECTION` while\n * Athena can't be reached), or `null`. Once it clears, the lookups that\n * failed meanwhile run again.\n */\n athenaUnavailable?: LabelCopy | null;\n}): {\n store: MentionSuggestionsStore;\n invalidate: (scope: string) => void;\n} {\n const auth = useMentionAuth();\n const webpagesRef = useRef(webpages);\n webpagesRef.current = webpages;\n const toolsRef = useRef(tools);\n toolsRef.current = tools;\n const hasProvidedTools = tools !== undefined;\n // Read once per store build: a store rebuilt meanwhile starts where the host stands.\n const athenaUnavailableRef = useRef(athenaUnavailable);\n athenaUnavailableRef.current = athenaUnavailable;\n\n // Depend on primitive values to avoid rebuilding store on object identity changes\n const store = useMemo(\n () =>\n buildStore({\n auth,\n getWebpages: () => webpagesRef.current,\n getTools: hasProvidedTools ? () => toolsRef.current ?? [] : undefined,\n rootCategories,\n athenaUnavailable: athenaUnavailableRef.current,\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [\n auth.backendUrl,\n auth.accessToken,\n auth.apiKey,\n auth.workspaceId,\n auth.userId,\n hasProvidedTools,\n rootCategories.join(\",\"),\n ],\n );\n\n const invalidate = useMemo(\n () => (scope: string) => {\n const state = store.state;\n const { registry, cache } = state;\n\n // Clear scope from cache\n if (cache.items) {\n for (const item of Object.values(cache.items)) {\n item.visibleInScopes.delete(scope);\n }\n // Remove orphaned items\n for (const [id, item] of Object.entries(cache.items)) {\n if (item.visibleInScopes.size === 0) {\n delete cache.items[id];\n }\n }\n }\n\n // Reset fetch states\n if (registry.entries[scope]) {\n registry.entries[scope].fetchStates = {};\n }\n\n store.setState((prev) => ({ ...prev }));\n },\n [store],\n );\n\n // Before the menu's own effects run, so no lookup leaves under a stale answer;\n // a value that changed nothing keeps the store's state (and its readers) as is.\n useLayoutEffect(() => {\n const unavailableBefore = store.state.athenaUnavailable;\n if (sameReason(unavailableBefore, athenaUnavailable)) return;\n store.setState((prev) => ({ ...prev, athenaUnavailable }));\n if (unavailableBefore !== null && athenaUnavailable === null) {\n retryFailedFetches(store);\n }\n }, [athenaUnavailable, store]);\n\n const webpageFingerprint = webpageMentionFingerprint(webpages);\n const previousWebpageFingerprintRef = useRef<string | null>(null);\n\n useEffect(() => {\n if (previousWebpageFingerprintRef.current === webpageFingerprint) return;\n previousWebpageFingerprintRef.current = webpageFingerprint;\n invalidate(\"root\");\n }, [invalidate, webpageFingerprint]);\n\n // A changed tool list drops the cached Tools / Toolkits entries (and the\n // root search results they were folded into) so the next open re-reads it.\n const toolsFingerprint = tools ? providedToolsFingerprint(tools) : null;\n const previousToolsFingerprintRef = useRef<string | null>(null);\n\n useEffect(() => {\n if (previousToolsFingerprintRef.current === toolsFingerprint) return;\n previousToolsFingerprintRef.current = toolsFingerprint;\n if (toolsFingerprint === null) return;\n invalidate(\"tools\");\n invalidate(\"toolkits\");\n invalidate(\"global_search\");\n }, [invalidate, toolsFingerprint]);\n\n return { store, invalidate };\n}\n"],"names":[],"mappings":";;;;;;;AA8CO,SAAS,0BACd,UACQ;AACR,SAAO,KAAK;AAAA,IACV,SAAS,IAAI,CAAC,EAAE,OAAO,OAAO,KAAK,gBAAgB;AAAA,MACjD;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA,CACD;AAAA,EAAA;AAEL;AAuBO,MAAM,0BAA0B;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAOO,SAAS,yBAAyB,OAAuC;AAC9E,SAAO,KAAK;AAAA,IACV,MAAM,IAAI,CAAC,EAAE,IAAI,MAAM,MAAM,aAAa,WAAW;AAAA,MACnD;AAAA,MACA;AAAA,MACA;AAAA,MACA,eAAe;AAAA,MACf,QAAQ;AAAA,IAAA,CACT;AAAA,EAAA;AAEL;AAEA,SAAS,WAAW;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAO4B;AAC1B,QAAM,WAAW,oBAAA;AACjB,QAAM,QAAQ,gBAAA;AAGd,iB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BAAgB,SAAS,GAAG;AACnC,mBAAO,MAAM,MAAM,EAAE;AAAA,UACvB;AAAA,QACF;AAAA,MACF;AAGA,UAAI,SAAS,QAAQ,KAAK,GAAG;AAC3B,iBAAS,QAAQ,KAAK,EAAE,cAAc,CAAA;AAAA,MACxC;AAEA,YAAM,SAAS,CAAC,UAAU,EAAE,GAAG,OAAO;AAAA,IACxC;AAAA,IACA,CAAC,KAAK;AAAA,EAAA;AAKR,kBAAgB,MAAM;AACpB,UAAM,oBAAoB,MAAM,MAAM;AACtC,QAAI,WAAW,mBAAmB,iBAAiB,EAAG;AACtD,UAAM,SAAS,CAAC,UAAU,EAAE,GAAG,MAAM,oBAAoB;AACzD,QAAI,sBAAsB,QAAQ,sBAAsB,MAAM;AAC5D,yBAAmB,KAAK;AAAA,IAC1B;AAAA,EACF,GAAG,CAAC,mBAAmB,KAAK,CAAC;AAE7B,QAAM,qBAAqB,0BAA0B,QAAQ;AAC7D,QAAM,gCAAgC,OAAsB,IAAI;AAEhE,YAAU,MAAM;AACd,QAAI,8BAA8B,YAAY,mBAAoB;AAClE,kCAA8B,UAAU;AACxC,eAAW,MAAM;AAAA,EACnB,GAAG,CAAC,YAAY,kBAAkB,CAAC;AAInC,QAAM,mBAAmB,QAAQ,yBAAyB,KAAK,IAAI;AACnE,QAAM,8BAA8B,OAAsB,IAAI;AAE9D,YAAU,MAAM;AACd,QAAI,4BAA4B,YAAY,iBAAkB;AAC9D,gCAA4B,UAAU;AACtC,QAAI,qBAAqB,KAAM;AAC/B,eAAW,OAAO;AAClB,eAAW,UAAU;AACrB,eAAW,eAAe;AAAA,EAC5B,GAAG,CAAC,YAAY,gBAAgB,CAAC;AAEjC,SAAO,EAAE,OAAO,WAAA;AAClB;"}
@@ -1,20 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const reactStore = require("@tanstack/react-store");
4
- const react = require("react");
4
+ const require$$0 = require("react");
5
5
  const orchestrator = require("./orchestrator.cjs");
6
6
  function useMenuItems(store, options) {
7
7
  const { scope, query = "", minItems = 50, parentScope } = options;
8
- const [targetCount, setTargetCount] = react.useState(minItems);
9
- react.useEffect(() => {
8
+ const [targetCount, setTargetCount] = require$$0.useState(minItems);
9
+ require$$0.useEffect(() => {
10
10
  setTargetCount(minItems);
11
11
  }, [scope, query, minItems]);
12
12
  const snapshot = reactStore.useStore(
13
13
  store,
14
14
  () => orchestrator.selectItems(store, scope, query, targetCount, parentScope)
15
15
  );
16
- react.useEffect(() => {
17
- if (snapshot.items.length < targetCount && snapshot.hasMore && !snapshot.isFetching) {
16
+ const waitsOnAthena = snapshot.unavailable !== null;
17
+ require$$0.useEffect(() => {
18
+ if (!waitsOnAthena && snapshot.items.length < targetCount && snapshot.hasMore && !snapshot.isFetching) {
18
19
  orchestrator.triggerFetchIfNeeded(store, scope, query, targetCount, parentScope);
19
20
  }
20
21
  }, [
@@ -23,12 +24,13 @@ function useMenuItems(store, options) {
23
24
  query,
24
25
  targetCount,
25
26
  parentScope,
27
+ waitsOnAthena,
26
28
  snapshot.items.length,
27
29
  snapshot.hasMore,
28
30
  snapshot.isFetching
29
31
  ]);
30
32
  const loadMore = () => {
31
- if (snapshot.hasMore && !snapshot.isFetching) {
33
+ if (!waitsOnAthena && snapshot.hasMore && !snapshot.isFetching) {
32
34
  setTargetCount((prev) => prev + 50);
33
35
  }
34
36
  };
@@ -36,6 +38,7 @@ function useMenuItems(store, options) {
36
38
  items: snapshot.items,
37
39
  isFetching: snapshot.isFetching,
38
40
  hasMore: snapshot.hasMore,
41
+ unavailable: snapshot.unavailable,
39
42
  loadMore,
40
43
  targetCount
41
44
  // Expose for debugging
@@ -1 +1 @@
1
- {"version":3,"file":"use-menu-items.cjs","sources":["../../../../../src/chat-ui/mentions/suggestions/data/use-menu-items.ts"],"sourcesContent":["import { useStore } from '@tanstack/react-store';\nimport { useEffect, useState } from 'react';\nimport { selectItems, triggerFetchIfNeeded } from './orchestrator';\nimport type { MenuItem, MenuScope } from './types';\nimport type { MentionSuggestionsStore } from './use-mention-suggestions';\n\n/**\n * useMenuItems - Like React Query, but for menu items\n *\n * Clean, automatic hook that:\n * - Reads items from store (reactive!)\n * - Auto-fetches if needed (in useEffect)\n * - Returns clean interface { items, isFetching, hasMore }\n *\n * Usage:\n * ```typescript\n * const { items, isFetching, hasMore } = useMenuItems(store, {\n * scope: 'athena_folders',\n * query: 'doc',\n * minItems: 10,\n * parentScope: 'root'\n * });\n * ```\n */\nexport interface UseMenuItemsOptions {\n scope: MenuScope;\n query?: string;\n minItems?: number;\n parentScope?: MenuScope;\n}\n\nexport interface UseMenuItemsResult {\n items: MenuItem[];\n isFetching: boolean;\n hasMore: boolean;\n loadMore: () => void; // Explicit load more (not automatic!)\n targetCount: number; // Current target for debugging\n}\n\nexport function useMenuItems(\n store: MentionSuggestionsStore,\n options: UseMenuItemsOptions\n): UseMenuItemsResult {\n const { scope, query = '', minItems = 50, parentScope } = options;\n\n // Target item count (increases when user clicks \"Load More\")\n const [targetCount, setTargetCount] = useState(minItems);\n\n // Reset target when scope/query changes\n // biome-ignore lint/correctness/useExhaustiveDependencies: We intentionally reset on scope/query change\n useEffect(() => {\n setTargetCount(minItems);\n }, [scope, query, minItems]);\n\n // Read from store (pure, reactive)\n const snapshot = useStore(store, () =>\n selectItems(store, scope, query, targetCount, parentScope)\n );\n\n // Auto-fetch when: cached < target AND hasMore AND !fetching\n useEffect(() => {\n if (snapshot.items.length < targetCount && snapshot.hasMore && !snapshot.isFetching) {\n triggerFetchIfNeeded(store, scope, query, targetCount, parentScope);\n }\n }, [\n store,\n scope,\n query,\n targetCount,\n parentScope,\n snapshot.items.length,\n snapshot.hasMore,\n snapshot.isFetching,\n ]);\n\n // Explicit load more: Increase target by 50\n const loadMore = () => {\n if (snapshot.hasMore && !snapshot.isFetching) {\n setTargetCount((prev) => prev + 50);\n }\n };\n\n return {\n items: snapshot.items,\n isFetching: snapshot.isFetching,\n hasMore: snapshot.hasMore,\n loadMore,\n targetCount, // Expose for debugging\n };\n}\n"],"names":["useState","useEffect","useStore","selectItems","triggerFetchIfNeeded"],"mappings":";;;;;AAuCO,SAAS,aACd,OACA,SACoB;AACpB,QAAM,EAAE,OAAO,QAAQ,IAAI,WAAW,IAAI,gBAAgB;AAG1D,QAAM,CAAC,aAAa,cAAc,IAAIA,MAAAA,SAAS,QAAQ;AAIvDC,QAAAA,UAAU,MAAM;AACd,mBAAe,QAAQ;AAAA,EACzB,GAAG,CAAC,OAAO,OAAO,QAAQ,CAAC;AAG3B,QAAM,WAAWC,WAAAA;AAAAA,IAAS;AAAA,IAAO,MAC/BC,aAAAA,YAAY,OAAO,OAAO,OAAO,aAAa,WAAW;AAAA,EAAA;AAI3DF,QAAAA,UAAU,MAAM;AACd,QAAI,SAAS,MAAM,SAAS,eAAe,SAAS,WAAW,CAAC,SAAS,YAAY;AACnFG,mBAAAA,qBAAqB,OAAO,OAAO,OAAO,aAAa,WAAW;AAAA,IACpE;AAAA,EACF,GAAG;AAAA,IACD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS,MAAM;AAAA,IACf,SAAS;AAAA,IACT,SAAS;AAAA,EAAA,CACV;AAGD,QAAM,WAAW,MAAM;AACrB,QAAI,SAAS,WAAW,CAAC,SAAS,YAAY;AAC5C,qBAAe,CAAC,SAAS,OAAO,EAAE;AAAA,IACpC;AAAA,EACF;AAEA,SAAO;AAAA,IACL,OAAO,SAAS;AAAA,IAChB,YAAY,SAAS;AAAA,IACrB,SAAS,SAAS;AAAA,IAClB;AAAA,IACA;AAAA;AAAA,EAAA;AAEJ;;"}
1
+ {"version":3,"file":"use-menu-items.cjs","sources":["../../../../../src/chat-ui/mentions/suggestions/data/use-menu-items.ts"],"sourcesContent":["import type { LabelCopy } from '@athenaintel/agent-runtime/offline-status';\nimport { useStore } from '@tanstack/react-store';\nimport { useEffect, useState } from 'react';\nimport { selectItems, triggerFetchIfNeeded } from './orchestrator';\nimport type { MenuItem, MenuScope } from './types';\nimport type { MentionSuggestionsStore } from './use-mention-suggestions';\n\n/**\n * useMenuItems - Like React Query, but for menu items\n *\n * Clean, automatic hook that:\n * - Reads items from store (reactive!)\n * - Auto-fetches if needed (in useEffect)\n * - Returns clean interface { items, isFetching, hasMore }\n *\n * Usage:\n * ```typescript\n * const { items, isFetching, hasMore } = useMenuItems(store, {\n * scope: 'athena_folders',\n * query: 'doc',\n * minItems: 10,\n * parentScope: 'root'\n * });\n * ```\n */\nexport interface UseMenuItemsOptions {\n scope: MenuScope;\n query?: string;\n minItems?: number;\n parentScope?: MenuScope;\n}\n\nexport interface UseMenuItemsResult {\n items: MenuItem[];\n isFetching: boolean;\n hasMore: boolean;\n /** Why this scope can't load from Athena right now (`null` while it can, or for local items). */\n unavailable: LabelCopy | null;\n loadMore: () => void; // Explicit load more (not automatic!)\n targetCount: number; // Current target for debugging\n}\n\nexport function useMenuItems(\n store: MentionSuggestionsStore,\n options: UseMenuItemsOptions\n): UseMenuItemsResult {\n const { scope, query = '', minItems = 50, parentScope } = options;\n\n // Target item count (increases when user clicks \"Load More\")\n const [targetCount, setTargetCount] = useState(minItems);\n\n // Reset target when scope/query changes\n // biome-ignore lint/correctness/useExhaustiveDependencies: We intentionally reset on scope/query change\n useEffect(() => {\n setTargetCount(minItems);\n }, [scope, query, minItems]);\n\n // Read from store (pure, reactive)\n const snapshot = useStore(store, () =>\n selectItems(store, scope, query, targetCount, parentScope)\n );\n\n // Auto-fetch when: cached < target AND hasMore AND !fetching (and Athena can be asked)\n const waitsOnAthena = snapshot.unavailable !== null;\n useEffect(() => {\n if (\n !waitsOnAthena &&\n snapshot.items.length < targetCount &&\n snapshot.hasMore &&\n !snapshot.isFetching\n ) {\n triggerFetchIfNeeded(store, scope, query, targetCount, parentScope);\n }\n }, [\n store,\n scope,\n query,\n targetCount,\n parentScope,\n waitsOnAthena,\n snapshot.items.length,\n snapshot.hasMore,\n snapshot.isFetching,\n ]);\n\n // Explicit load more: Increase target by 50\n const loadMore = () => {\n if (!waitsOnAthena && snapshot.hasMore && !snapshot.isFetching) {\n setTargetCount((prev) => prev + 50);\n }\n };\n\n return {\n items: snapshot.items,\n isFetching: snapshot.isFetching,\n hasMore: snapshot.hasMore,\n unavailable: snapshot.unavailable,\n loadMore,\n targetCount, // Expose for debugging\n };\n}\n"],"names":["useState","useEffect","useStore","selectItems","triggerFetchIfNeeded"],"mappings":";;;;;AA0CO,SAAS,aACd,OACA,SACoB;AACpB,QAAM,EAAE,OAAO,QAAQ,IAAI,WAAW,IAAI,gBAAgB;AAG1D,QAAM,CAAC,aAAa,cAAc,IAAIA,WAAAA,SAAS,QAAQ;AAIvDC,aAAAA,UAAU,MAAM;AACd,mBAAe,QAAQ;AAAA,EACzB,GAAG,CAAC,OAAO,OAAO,QAAQ,CAAC;AAG3B,QAAM,WAAWC,WAAAA;AAAAA,IAAS;AAAA,IAAO,MAC/BC,aAAAA,YAAY,OAAO,OAAO,OAAO,aAAa,WAAW;AAAA,EAAA;AAI3D,QAAM,gBAAgB,SAAS,gBAAgB;AAC/CF,aAAAA,UAAU,MAAM;AACd,QACE,CAAC,iBACD,SAAS,MAAM,SAAS,eACxB,SAAS,WACT,CAAC,SAAS,YACV;AACAG,mBAAAA,qBAAqB,OAAO,OAAO,OAAO,aAAa,WAAW;AAAA,IACpE;AAAA,EACF,GAAG;AAAA,IACD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS,MAAM;AAAA,IACf,SAAS;AAAA,IACT,SAAS;AAAA,EAAA,CACV;AAGD,QAAM,WAAW,MAAM;AACrB,QAAI,CAAC,iBAAiB,SAAS,WAAW,CAAC,SAAS,YAAY;AAC9D,qBAAe,CAAC,SAAS,OAAO,EAAE;AAAA,IACpC;AAAA,EACF;AAEA,SAAO;AAAA,IACL,OAAO,SAAS;AAAA,IAChB,YAAY,SAAS;AAAA,IACrB,SAAS,SAAS;AAAA,IAClB,aAAa,SAAS;AAAA,IACtB;AAAA,IACA;AAAA;AAAA,EAAA;AAEJ;;"}
@@ -1,3 +1,4 @@
1
+ import type { LabelCopy } from '../../../../agent-runtime/src/offline-status';
1
2
  import type { MenuItem, MenuScope } from './types';
2
3
  import type { MentionSuggestionsStore } from './use-mention-suggestions';
3
4
  /**
@@ -28,6 +29,8 @@ export interface UseMenuItemsResult {
28
29
  items: MenuItem[];
29
30
  isFetching: boolean;
30
31
  hasMore: boolean;
32
+ /** Why this scope can't load from Athena right now (`null` while it can, or for local items). */
33
+ unavailable: LabelCopy | null;
31
34
  loadMore: () => void;
32
35
  targetCount: number;
33
36
  }
@@ -11,8 +11,9 @@ function useMenuItems(store, options) {
11
11
  store,
12
12
  () => selectItems(store, scope, query, targetCount, parentScope)
13
13
  );
14
+ const waitsOnAthena = snapshot.unavailable !== null;
14
15
  useEffect(() => {
15
- if (snapshot.items.length < targetCount && snapshot.hasMore && !snapshot.isFetching) {
16
+ if (!waitsOnAthena && snapshot.items.length < targetCount && snapshot.hasMore && !snapshot.isFetching) {
16
17
  triggerFetchIfNeeded(store, scope, query, targetCount, parentScope);
17
18
  }
18
19
  }, [
@@ -21,12 +22,13 @@ function useMenuItems(store, options) {
21
22
  query,
22
23
  targetCount,
23
24
  parentScope,
25
+ waitsOnAthena,
24
26
  snapshot.items.length,
25
27
  snapshot.hasMore,
26
28
  snapshot.isFetching
27
29
  ]);
28
30
  const loadMore = () => {
29
- if (snapshot.hasMore && !snapshot.isFetching) {
31
+ if (!waitsOnAthena && snapshot.hasMore && !snapshot.isFetching) {
30
32
  setTargetCount((prev) => prev + 50);
31
33
  }
32
34
  };
@@ -34,6 +36,7 @@ function useMenuItems(store, options) {
34
36
  items: snapshot.items,
35
37
  isFetching: snapshot.isFetching,
36
38
  hasMore: snapshot.hasMore,
39
+ unavailable: snapshot.unavailable,
37
40
  loadMore,
38
41
  targetCount
39
42
  // Expose for debugging
@@ -1 +1 @@
1
- {"version":3,"file":"use-menu-items.js","sources":["../../../../../src/chat-ui/mentions/suggestions/data/use-menu-items.ts"],"sourcesContent":["import { useStore } from '@tanstack/react-store';\nimport { useEffect, useState } from 'react';\nimport { selectItems, triggerFetchIfNeeded } from './orchestrator';\nimport type { MenuItem, MenuScope } from './types';\nimport type { MentionSuggestionsStore } from './use-mention-suggestions';\n\n/**\n * useMenuItems - Like React Query, but for menu items\n *\n * Clean, automatic hook that:\n * - Reads items from store (reactive!)\n * - Auto-fetches if needed (in useEffect)\n * - Returns clean interface { items, isFetching, hasMore }\n *\n * Usage:\n * ```typescript\n * const { items, isFetching, hasMore } = useMenuItems(store, {\n * scope: 'athena_folders',\n * query: 'doc',\n * minItems: 10,\n * parentScope: 'root'\n * });\n * ```\n */\nexport interface UseMenuItemsOptions {\n scope: MenuScope;\n query?: string;\n minItems?: number;\n parentScope?: MenuScope;\n}\n\nexport interface UseMenuItemsResult {\n items: MenuItem[];\n isFetching: boolean;\n hasMore: boolean;\n loadMore: () => void; // Explicit load more (not automatic!)\n targetCount: number; // Current target for debugging\n}\n\nexport function useMenuItems(\n store: MentionSuggestionsStore,\n options: UseMenuItemsOptions\n): UseMenuItemsResult {\n const { scope, query = '', minItems = 50, parentScope } = options;\n\n // Target item count (increases when user clicks \"Load More\")\n const [targetCount, setTargetCount] = useState(minItems);\n\n // Reset target when scope/query changes\n // biome-ignore lint/correctness/useExhaustiveDependencies: We intentionally reset on scope/query change\n useEffect(() => {\n setTargetCount(minItems);\n }, [scope, query, minItems]);\n\n // Read from store (pure, reactive)\n const snapshot = useStore(store, () =>\n selectItems(store, scope, query, targetCount, parentScope)\n );\n\n // Auto-fetch when: cached < target AND hasMore AND !fetching\n useEffect(() => {\n if (snapshot.items.length < targetCount && snapshot.hasMore && !snapshot.isFetching) {\n triggerFetchIfNeeded(store, scope, query, targetCount, parentScope);\n }\n }, [\n store,\n scope,\n query,\n targetCount,\n parentScope,\n snapshot.items.length,\n snapshot.hasMore,\n snapshot.isFetching,\n ]);\n\n // Explicit load more: Increase target by 50\n const loadMore = () => {\n if (snapshot.hasMore && !snapshot.isFetching) {\n setTargetCount((prev) => prev + 50);\n }\n };\n\n return {\n items: snapshot.items,\n isFetching: snapshot.isFetching,\n hasMore: snapshot.hasMore,\n loadMore,\n targetCount, // Expose for debugging\n };\n}\n"],"names":[],"mappings":";;;AAuCO,SAAS,aACd,OACA,SACoB;AACpB,QAAM,EAAE,OAAO,QAAQ,IAAI,WAAW,IAAI,gBAAgB;AAG1D,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,QAAQ;AAIvD,YAAU,MAAM;AACd,mBAAe,QAAQ;AAAA,EACzB,GAAG,CAAC,OAAO,OAAO,QAAQ,CAAC;AAG3B,QAAM,WAAW;AAAA,IAAS;AAAA,IAAO,MAC/B,YAAY,OAAO,OAAO,OAAO,aAAa,WAAW;AAAA,EAAA;AAI3D,YAAU,MAAM;AACd,QAAI,SAAS,MAAM,SAAS,eAAe,SAAS,WAAW,CAAC,SAAS,YAAY;AACnF,2BAAqB,OAAO,OAAO,OAAO,aAAa,WAAW;AAAA,IACpE;AAAA,EACF,GAAG;AAAA,IACD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS,MAAM;AAAA,IACf,SAAS;AAAA,IACT,SAAS;AAAA,EAAA,CACV;AAGD,QAAM,WAAW,MAAM;AACrB,QAAI,SAAS,WAAW,CAAC,SAAS,YAAY;AAC5C,qBAAe,CAAC,SAAS,OAAO,EAAE;AAAA,IACpC;AAAA,EACF;AAEA,SAAO;AAAA,IACL,OAAO,SAAS;AAAA,IAChB,YAAY,SAAS;AAAA,IACrB,SAAS,SAAS;AAAA,IAClB;AAAA,IACA;AAAA;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"use-menu-items.js","sources":["../../../../../src/chat-ui/mentions/suggestions/data/use-menu-items.ts"],"sourcesContent":["import type { LabelCopy } from '@athenaintel/agent-runtime/offline-status';\nimport { useStore } from '@tanstack/react-store';\nimport { useEffect, useState } from 'react';\nimport { selectItems, triggerFetchIfNeeded } from './orchestrator';\nimport type { MenuItem, MenuScope } from './types';\nimport type { MentionSuggestionsStore } from './use-mention-suggestions';\n\n/**\n * useMenuItems - Like React Query, but for menu items\n *\n * Clean, automatic hook that:\n * - Reads items from store (reactive!)\n * - Auto-fetches if needed (in useEffect)\n * - Returns clean interface { items, isFetching, hasMore }\n *\n * Usage:\n * ```typescript\n * const { items, isFetching, hasMore } = useMenuItems(store, {\n * scope: 'athena_folders',\n * query: 'doc',\n * minItems: 10,\n * parentScope: 'root'\n * });\n * ```\n */\nexport interface UseMenuItemsOptions {\n scope: MenuScope;\n query?: string;\n minItems?: number;\n parentScope?: MenuScope;\n}\n\nexport interface UseMenuItemsResult {\n items: MenuItem[];\n isFetching: boolean;\n hasMore: boolean;\n /** Why this scope can't load from Athena right now (`null` while it can, or for local items). */\n unavailable: LabelCopy | null;\n loadMore: () => void; // Explicit load more (not automatic!)\n targetCount: number; // Current target for debugging\n}\n\nexport function useMenuItems(\n store: MentionSuggestionsStore,\n options: UseMenuItemsOptions\n): UseMenuItemsResult {\n const { scope, query = '', minItems = 50, parentScope } = options;\n\n // Target item count (increases when user clicks \"Load More\")\n const [targetCount, setTargetCount] = useState(minItems);\n\n // Reset target when scope/query changes\n // biome-ignore lint/correctness/useExhaustiveDependencies: We intentionally reset on scope/query change\n useEffect(() => {\n setTargetCount(minItems);\n }, [scope, query, minItems]);\n\n // Read from store (pure, reactive)\n const snapshot = useStore(store, () =>\n selectItems(store, scope, query, targetCount, parentScope)\n );\n\n // Auto-fetch when: cached < target AND hasMore AND !fetching (and Athena can be asked)\n const waitsOnAthena = snapshot.unavailable !== null;\n useEffect(() => {\n if (\n !waitsOnAthena &&\n snapshot.items.length < targetCount &&\n snapshot.hasMore &&\n !snapshot.isFetching\n ) {\n triggerFetchIfNeeded(store, scope, query, targetCount, parentScope);\n }\n }, [\n store,\n scope,\n query,\n targetCount,\n parentScope,\n waitsOnAthena,\n snapshot.items.length,\n snapshot.hasMore,\n snapshot.isFetching,\n ]);\n\n // Explicit load more: Increase target by 50\n const loadMore = () => {\n if (!waitsOnAthena && snapshot.hasMore && !snapshot.isFetching) {\n setTargetCount((prev) => prev + 50);\n }\n };\n\n return {\n items: snapshot.items,\n isFetching: snapshot.isFetching,\n hasMore: snapshot.hasMore,\n unavailable: snapshot.unavailable,\n loadMore,\n targetCount, // Expose for debugging\n };\n}\n"],"names":[],"mappings":";;;AA0CO,SAAS,aACd,OACA,SACoB;AACpB,QAAM,EAAE,OAAO,QAAQ,IAAI,WAAW,IAAI,gBAAgB;AAG1D,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,QAAQ;AAIvD,YAAU,MAAM;AACd,mBAAe,QAAQ;AAAA,EACzB,GAAG,CAAC,OAAO,OAAO,QAAQ,CAAC;AAG3B,QAAM,WAAW;AAAA,IAAS;AAAA,IAAO,MAC/B,YAAY,OAAO,OAAO,OAAO,aAAa,WAAW;AAAA,EAAA;AAI3D,QAAM,gBAAgB,SAAS,gBAAgB;AAC/C,YAAU,MAAM;AACd,QACE,CAAC,iBACD,SAAS,MAAM,SAAS,eACxB,SAAS,WACT,CAAC,SAAS,YACV;AACA,2BAAqB,OAAO,OAAO,OAAO,aAAa,WAAW;AAAA,IACpE;AAAA,EACF,GAAG;AAAA,IACD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS,MAAM;AAAA,IACf,SAAS;AAAA,IACT,SAAS;AAAA,EAAA,CACV;AAGD,QAAM,WAAW,MAAM;AACrB,QAAI,CAAC,iBAAiB,SAAS,WAAW,CAAC,SAAS,YAAY;AAC9D,qBAAe,CAAC,SAAS,OAAO,EAAE;AAAA,IACpC;AAAA,EACF;AAEA,SAAO;AAAA,IACL,OAAO,SAAS;AAAA,IAChB,YAAY,SAAS;AAAA,IACrB,SAAS,SAAS;AAAA,IAClB,aAAa,SAAS;AAAA,IACtB;AAAA,IACA;AAAA;AAAA,EAAA;AAEJ;"}
@@ -1,20 +1,49 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const reactQuery = require("@tanstack/react-query");
4
- const react = require("react");
4
+ const AthenaCredentialSourceContext = require("../../auth/AthenaCredentialSourceContext.cjs");
5
+ const credentialSource = require("../../auth/credential-source.cjs");
5
6
  const runtimeCatalog = require("../../catalog/runtime-catalog.cjs");
7
+ const useAthenaRestQuery = require("../../lib/use-athena-rest-query.cjs");
6
8
  const credentialRenewal = require("../../runtime/credential-renewal.cjs");
7
9
  const api = require("../../threads/api.cjs");
8
- function useAccountWorkspaceId(auth) {
10
+ const tokenGetterIds = /* @__PURE__ */ new WeakMap();
11
+ let lastTokenGetterId = 0;
12
+ function tokenGetterId(getToken) {
13
+ if (getToken === void 0) return "";
14
+ let id = tokenGetterIds.get(getToken);
15
+ if (id === void 0) {
16
+ lastTokenGetterId += 1;
17
+ id = lastTokenGetterId;
18
+ tokenGetterIds.set(getToken, id);
19
+ }
20
+ return `getter:${id}`;
21
+ }
22
+ function heldTokenIdentity(token) {
23
+ if (!token) return "";
24
+ const subject = credentialSource.jwtSubject(token);
25
+ if (subject === null) return `token:${useAthenaRestQuery.keyPartFingerprint(token)}`;
26
+ const scope = credentialSource.jwtScope(token);
27
+ return scope === null ? `sub:${useAthenaRestQuery.keyPartFingerprint(subject)}` : `sub:${useAthenaRestQuery.keyPartFingerprint(subject)}|scope:${useAthenaRestQuery.keyPartFingerprint(scope)}`;
28
+ }
29
+ function useAccountIdentityRead(auth, { enabled, tokenGetter }) {
9
30
  const queryClient = runtimeCatalog.useCatalogQueryClient();
10
- const anonymousScope = react.useId();
11
- const principal = (auth == null ? void 0 : auth.apiKey) ? `key:${runtimeCatalog.credentialFingerprint({ credential: auth.apiKey })}` : (auth == null ? void 0 : auth.userId) ?? ((auth == null ? void 0 : auth.accessToken) ? `token:${runtimeCatalog.credentialFingerprint({ credential: auth.accessToken })}` : anonymousScope);
31
+ const identityEpoch = AthenaCredentialSourceContext.useAthenaCredentialIdentityEpoch();
12
32
  const query = reactQuery.useQuery(
13
33
  {
14
- queryKey: ["athena-sdk", "account-workspace", auth == null ? void 0 : auth.backendUrl, auth == null ? void 0 : auth.userId, principal],
34
+ queryKey: [
35
+ "athena-sdk",
36
+ "account",
37
+ (auth == null ? void 0 : auth.backendUrl) ?? "",
38
+ (auth == null ? void 0 : auth.userId) ?? "",
39
+ (auth == null ? void 0 : auth.apiKey) ? useAthenaRestQuery.keyPartFingerprint(auth.apiKey) : "",
40
+ tokenGetterId(tokenGetter),
41
+ heldTokenIdentity(auth == null ? void 0 : auth.accessToken),
42
+ identityEpoch
43
+ ],
15
44
  queryFn: async ({ signal }) => {
16
45
  if (!auth) return null;
17
- const identity = await credentialRenewal.withCredentialRenewal(
46
+ return credentialRenewal.withCredentialRenewal(
18
47
  async ({ force } = {}) => {
19
48
  var _a, _b;
20
49
  return {
@@ -25,15 +54,21 @@ function useAccountWorkspaceId(auth) {
25
54
  },
26
55
  (resolved) => api.fetchAccountIdentity(auth.backendUrl, resolved, { signal })
27
56
  );
28
- return identity.workspaceId ?? null;
29
57
  },
30
- enabled: auth !== null && !auth.workspaceId,
58
+ enabled: auth !== null && enabled,
31
59
  retry: false,
32
60
  staleTime: 6e4
33
61
  },
34
62
  queryClient
35
63
  );
36
- return (auth == null ? void 0 : auth.workspaceId) ?? query.data ?? void 0;
64
+ return query.data;
65
+ }
66
+ function useAccountIdentity(auth, options = {}) {
67
+ const identity = useAccountIdentityRead(auth, { enabled: true, ...options });
68
+ return {
69
+ userId: identity == null ? void 0 : identity.userId,
70
+ workspaceId: (auth == null ? void 0 : auth.workspaceId) ?? (identity == null ? void 0 : identity.workspaceId) ?? void 0
71
+ };
37
72
  }
38
- exports.useAccountWorkspaceId = useAccountWorkspaceId;
73
+ exports.useAccountIdentity = useAccountIdentity;
39
74
  //# sourceMappingURL=use-account-workspace-id.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-account-workspace-id.cjs","sources":["../../../src/chat-ui/mentions/use-account-workspace-id.ts"],"sourcesContent":["import { useQuery } from '@tanstack/react-query';\nimport { useId } from 'react';\nimport { credentialFingerprint, useCatalogQueryClient } from '../../catalog/runtime-catalog';\nimport { withCredentialRenewal } from '../../runtime/credential-renewal';\nimport { fetchAccountIdentity } from '../../threads/api';\nimport type { MentionAuthContext } from './suggestions/data/api-client';\n\n/** Account identity uses the host's query cache and never a process-wide user-id map. */\nexport function useAccountWorkspaceId(auth: MentionAuthContext | null): string | undefined {\n const queryClient = useCatalogQueryClient();\n const anonymousScope = useId();\n // A workspace API key wins even when the person is known; a bearer can\n // rotate without changing that person's cache identity.\n const principal = auth?.apiKey\n ? `key:${credentialFingerprint({ credential: auth.apiKey })}`\n : auth?.userId ??\n (auth?.accessToken\n ? `token:${credentialFingerprint({ credential: auth.accessToken })}`\n : anonymousScope);\n const query = useQuery(\n {\n queryKey: ['athena-sdk', 'account-workspace', auth?.backendUrl, auth?.userId, principal],\n queryFn: async ({ signal }) => {\n if (!auth) return null;\n const identity = await withCredentialRenewal(\n async ({ force }: { force?: boolean } = {}) => ({\n token:\n (force ? await auth.renewAccessToken?.() : await auth.getAccessToken?.()) ??\n auth.accessToken ??\n null,\n apiKey: auth.apiKey,\n credentials: auth.credentials,\n }),\n (resolved) => fetchAccountIdentity(auth.backendUrl, resolved, { signal })\n );\n return identity.workspaceId ?? null;\n },\n enabled: auth !== null && !auth.workspaceId,\n retry: false,\n staleTime: 60_000,\n },\n queryClient\n );\n return auth?.workspaceId ?? query.data ?? undefined;\n}\n"],"names":["useCatalogQueryClient","useId","credentialFingerprint","useQuery","withCredentialRenewal","fetchAccountIdentity"],"mappings":";;;;;;;AAQO,SAAS,sBAAsB,MAAqD;AACzF,QAAM,cAAcA,eAAAA,sBAAA;AACpB,QAAM,iBAAiBC,MAAAA,MAAA;AAGvB,QAAM,aAAY,6BAAM,UACpB,OAAOC,eAAAA,sBAAsB,EAAE,YAAY,KAAK,OAAA,CAAQ,CAAC,MACzD,6BAAM,aACL,6BAAM,eACH,SAASA,eAAAA,sBAAsB,EAAE,YAAY,KAAK,YAAA,CAAa,CAAC,KAChE;AACR,QAAM,QAAQC,WAAAA;AAAAA,IACZ;AAAA,MACE,UAAU,CAAC,cAAc,qBAAqB,6BAAM,YAAY,6BAAM,QAAQ,SAAS;AAAA,MACvF,SAAS,OAAO,EAAE,aAAa;AAC7B,YAAI,CAAC,KAAM,QAAO;AAClB,cAAM,WAAW,MAAMC,kBAAAA;AAAAA,UACrB,OAAO,EAAE,MAAA,IAA+B,OAAC;;AAAO;AAAA,cAC9C,QACG,QAAQ,QAAM,UAAK,qBAAL,iCAA4B,QAAM,UAAK,mBAAL,mCACjD,KAAK,eACL;AAAA,cACF,QAAQ,KAAK;AAAA,cACb,aAAa,KAAK;AAAA,YAAA;AAAA;AAAA,UAEpB,CAAC,aAAaC,IAAAA,qBAAqB,KAAK,YAAY,UAAU,EAAE,QAAQ;AAAA,QAAA;AAE1E,eAAO,SAAS,eAAe;AAAA,MACjC;AAAA,MACA,SAAS,SAAS,QAAQ,CAAC,KAAK;AAAA,MAChC,OAAO;AAAA,MACP,WAAW;AAAA,IAAA;AAAA,IAEb;AAAA,EAAA;AAEF,UAAO,6BAAM,gBAAe,MAAM,QAAQ;AAC5C;;"}
1
+ {"version":3,"file":"use-account-workspace-id.cjs","sources":["../../../src/chat-ui/mentions/use-account-workspace-id.ts"],"sourcesContent":["import { useQuery } from '@tanstack/react-query';\nimport { useAthenaCredentialIdentityEpoch } from '../../auth/AthenaCredentialSourceContext';\nimport { jwtScope, jwtSubject } from '../../auth/credential-source';\nimport { useCatalogQueryClient } from '../../catalog/runtime-catalog';\nimport { keyPartFingerprint } from '../../lib/use-athena-rest-query';\nimport { withCredentialRenewal } from '../../runtime/credential-renewal';\nimport type { AthenaStatewireTokenGetter } from '../../runtime/statewire-auth-headers';\nimport { type AccountIdentity, fetchAccountIdentity } from '../../threads/api';\nimport type { MentionAuthContext } from './suggestions/data/api-client';\n\n/** The credential's agora identity, as far as it is known yet. */\nexport interface AccountIdentityState {\n /** Agora's user id (`user_…`) for the credential; unknown until `/me` answers. */\n userId: string | undefined;\n /** The host's workspace when it names one, else the credential's current workspace. */\n workspaceId: string | undefined;\n}\n\nexport interface AccountIdentityOptions {\n /**\n * The provider's token getter, which `auth.getAccessToken` wraps (`AthenaChat`\n * passes `useAthenaConfig().getToken`). Its identity keeps two providers\n * apart when only their getters know who they sign in.\n */\n tokenGetter?: AthenaStatewireTokenGetter;\n}\n\n/** One id per token getter, so the key can name a getter without holding it. */\nconst tokenGetterIds = new WeakMap<AthenaStatewireTokenGetter, number>();\nlet lastTokenGetterId = 0;\n\nfunction tokenGetterId(getToken: AthenaStatewireTokenGetter | undefined): string {\n if (getToken === undefined) return '';\n let id = tokenGetterIds.get(getToken);\n if (id === undefined) {\n lastTokenGetterId += 1;\n id = lastTokenGetterId;\n tokenGetterIds.set(getToken, id);\n }\n return `getter:${id}`;\n}\n\n/**\n * Who a held token acts as, and where, without the token: its JWT subject and\n * the claims scoping it to a workspace or org (`jwtScope`), or the token\n * itself when it is opaque, fingerprinted. A renewal for the same person and\n * scope keeps it, so a rotation is not a new identity; the same person's token\n * scoped to another workspace is.\n */\nfunction heldTokenIdentity(token: string | null | undefined): string {\n if (!token) return '';\n const subject = jwtSubject(token);\n if (subject === null) return `token:${keyPartFingerprint(token)}`;\n const scope = jwtScope(token);\n return scope === null\n ? `sub:${keyPartFingerprint(subject)}`\n : `sub:${keyPartFingerprint(subject)}|scope:${keyPartFingerprint(scope)}`;\n}\n\n/**\n * One `/me` read per credential, through the host's query cache (never a\n * process-wide user-id map), keyed by the credential the read is sent with and\n * never by the secret: the backend, the signed-in person, the API key's\n * fingerprint, the provider's token getter, who the held token acts as and\n * which workspace it is scoped to, and the provider's credential identity\n * epoch (`useAthenaCredentialIdentityEpoch`), which moves once the getter has\n * handed out a token that acts as someone else. A renewal for the same person\n * and scope keeps the key, so the answer stays put; an API-key switch, a held\n * token scoped to another workspace, or a getter now signing in someone else,\n * reads `/me` again under a new key, never a cached answer for the previous\n * credential. The epoch follows the person, not the scope: a host getter that\n * alone hands out the same person's token for another workspace is read again\n * once the answer goes stale. `enabled` is the caller's: a reader that only\n * needs the workspace skips the read when the host names one.\n */\nfunction useAccountIdentityRead(\n auth: MentionAuthContext | null,\n { enabled, tokenGetter }: { enabled: boolean } & AccountIdentityOptions\n): AccountIdentity | null | undefined {\n const queryClient = useCatalogQueryClient();\n const identityEpoch = useAthenaCredentialIdentityEpoch();\n const query = useQuery(\n {\n queryKey: [\n 'athena-sdk',\n 'account',\n auth?.backendUrl ?? '',\n auth?.userId ?? '',\n auth?.apiKey ? keyPartFingerprint(auth.apiKey) : '',\n tokenGetterId(tokenGetter),\n heldTokenIdentity(auth?.accessToken),\n identityEpoch,\n ],\n queryFn: async ({ signal }) => {\n if (!auth) return null;\n return withCredentialRenewal(\n async ({ force }: { force?: boolean } = {}) => ({\n token:\n (force ? await auth.renewAccessToken?.() : await auth.getAccessToken?.()) ??\n auth.accessToken ??\n null,\n apiKey: auth.apiKey,\n credentials: auth.credentials,\n }),\n (resolved) => fetchAccountIdentity(auth.backendUrl, resolved, { signal })\n );\n },\n enabled: auth !== null && enabled,\n retry: false,\n staleTime: 60_000,\n },\n queryClient\n );\n return query.data;\n}\n\n/** The workspace mentions search: the host's when it names one, else the credential's own. */\nexport function useAccountWorkspaceId(auth: MentionAuthContext | null): string | undefined {\n const identity = useAccountIdentityRead(auth, { enabled: !auth?.workspaceId });\n return auth?.workspaceId ?? identity?.workspaceId ?? undefined;\n}\n\n/**\n * The credential's agora user id and workspace from the same read. The auth\n * context carries the identity provider's user id, not agora's, so \"who is\n * the viewer\" (an answer label's \"for you\") needs this one, and it reads\n * `/me` even when the host names a workspace.\n */\nexport function useAccountIdentity(\n auth: MentionAuthContext | null,\n options: AccountIdentityOptions = {}\n): AccountIdentityState {\n const identity = useAccountIdentityRead(auth, { enabled: true, ...options });\n return {\n userId: identity?.userId,\n workspaceId: auth?.workspaceId ?? identity?.workspaceId ?? undefined,\n };\n}\n"],"names":["jwtSubject","keyPartFingerprint","jwtScope","useCatalogQueryClient","useAthenaCredentialIdentityEpoch","useQuery","withCredentialRenewal","fetchAccountIdentity"],"mappings":";;;;;;;;;AA4BA,MAAM,qCAAqB,QAAA;AAC3B,IAAI,oBAAoB;AAExB,SAAS,cAAc,UAA0D;AAC/E,MAAI,aAAa,OAAW,QAAO;AACnC,MAAI,KAAK,eAAe,IAAI,QAAQ;AACpC,MAAI,OAAO,QAAW;AACpB,yBAAqB;AACrB,SAAK;AACL,mBAAe,IAAI,UAAU,EAAE;AAAA,EACjC;AACA,SAAO,UAAU,EAAE;AACrB;AASA,SAAS,kBAAkB,OAA0C;AACnE,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,UAAUA,iBAAAA,WAAW,KAAK;AAChC,MAAI,YAAY,KAAM,QAAO,SAASC,mBAAAA,mBAAmB,KAAK,CAAC;AAC/D,QAAM,QAAQC,iBAAAA,SAAS,KAAK;AAC5B,SAAO,UAAU,OACb,OAAOD,mBAAAA,mBAAmB,OAAO,CAAC,KAClC,OAAOA,mBAAAA,mBAAmB,OAAO,CAAC,UAAUA,mBAAAA,mBAAmB,KAAK,CAAC;AAC3E;AAkBA,SAAS,uBACP,MACA,EAAE,SAAS,eACyB;AACpC,QAAM,cAAcE,eAAAA,sBAAA;AACpB,QAAM,gBAAgBC,8BAAAA,iCAAA;AACtB,QAAM,QAAQC,WAAAA;AAAAA,IACZ;AAAA,MACE,UAAU;AAAA,QACR;AAAA,QACA;AAAA,SACA,6BAAM,eAAc;AAAA,SACpB,6BAAM,WAAU;AAAA,SAChB,6BAAM,UAASJ,mBAAAA,mBAAmB,KAAK,MAAM,IAAI;AAAA,QACjD,cAAc,WAAW;AAAA,QACzB,kBAAkB,6BAAM,WAAW;AAAA,QACnC;AAAA,MAAA;AAAA,MAEF,SAAS,OAAO,EAAE,aAAa;AAC7B,YAAI,CAAC,KAAM,QAAO;AAClB,eAAOK,kBAAAA;AAAAA,UACL,OAAO,EAAE,MAAA,IAA+B,OAAC;;AAAO;AAAA,cAC9C,QACG,QAAQ,QAAM,UAAK,qBAAL,iCAA4B,QAAM,UAAK,mBAAL,mCACjD,KAAK,eACL;AAAA,cACF,QAAQ,KAAK;AAAA,cACb,aAAa,KAAK;AAAA,YAAA;AAAA;AAAA,UAEpB,CAAC,aAAaC,IAAAA,qBAAqB,KAAK,YAAY,UAAU,EAAE,QAAQ;AAAA,QAAA;AAAA,MAE5E;AAAA,MACA,SAAS,SAAS,QAAQ;AAAA,MAC1B,OAAO;AAAA,MACP,WAAW;AAAA,IAAA;AAAA,IAEb;AAAA,EAAA;AAEF,SAAO,MAAM;AACf;AAcO,SAAS,mBACd,MACA,UAAkC,IACZ;AACtB,QAAM,WAAW,uBAAuB,MAAM,EAAE,SAAS,MAAM,GAAG,SAAS;AAC3E,SAAO;AAAA,IACL,QAAQ,qCAAU;AAAA,IAClB,cAAa,6BAAM,iBAAe,qCAAU,gBAAe;AAAA,EAAA;AAE/D;;"}
@@ -1,3 +1,26 @@
1
+ import type { AthenaStatewireTokenGetter } from '../../runtime/statewire-auth-headers';
1
2
  import type { MentionAuthContext } from './suggestions/data/api-client';
2
- /** Account identity uses the host's query cache and never a process-wide user-id map. */
3
+ /** The credential's agora identity, as far as it is known yet. */
4
+ export interface AccountIdentityState {
5
+ /** Agora's user id (`user_…`) for the credential; unknown until `/me` answers. */
6
+ userId: string | undefined;
7
+ /** The host's workspace when it names one, else the credential's current workspace. */
8
+ workspaceId: string | undefined;
9
+ }
10
+ export interface AccountIdentityOptions {
11
+ /**
12
+ * The provider's token getter, which `auth.getAccessToken` wraps (`AthenaChat`
13
+ * passes `useAthenaConfig().getToken`). Its identity keeps two providers
14
+ * apart when only their getters know who they sign in.
15
+ */
16
+ tokenGetter?: AthenaStatewireTokenGetter;
17
+ }
18
+ /** The workspace mentions search: the host's when it names one, else the credential's own. */
3
19
  export declare function useAccountWorkspaceId(auth: MentionAuthContext | null): string | undefined;
20
+ /**
21
+ * The credential's agora user id and workspace from the same read. The auth
22
+ * context carries the identity provider's user id, not agora's, so "who is
23
+ * the viewer" (an answer label's "for you") needs this one, and it reads
24
+ * `/me` even when the host names a workspace.
25
+ */
26
+ export declare function useAccountIdentity(auth: MentionAuthContext | null, options?: AccountIdentityOptions): AccountIdentityState;