@athenaintel/react 0.57.2 → 0.60.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (852) hide show
  1. package/README.md +795 -12
  2. package/dist/agent-runtime/src/addressed-agents.cjs +16 -0
  3. package/dist/agent-runtime/src/addressed-agents.cjs.map +1 -0
  4. package/dist/agent-runtime/src/addressed-agents.d.ts +30 -0
  5. package/dist/agent-runtime/src/addressed-agents.js +16 -0
  6. package/dist/agent-runtime/src/addressed-agents.js.map +1 -0
  7. package/dist/agent-runtime/src/answer-label.cjs +4 -3
  8. package/dist/agent-runtime/src/answer-label.cjs.map +1 -1
  9. package/dist/agent-runtime/src/answer-label.d.ts +13 -6
  10. package/dist/agent-runtime/src/answer-label.js +4 -3
  11. package/dist/agent-runtime/src/answer-label.js.map +1 -1
  12. package/dist/agent-runtime/src/chat-outbox-attachments.cjs.map +1 -1
  13. package/dist/agent-runtime/src/chat-outbox-attachments.d.ts +1 -1
  14. package/dist/agent-runtime/src/chat-outbox-attachments.js.map +1 -1
  15. package/dist/agent-runtime/src/chat-outbox-entry.cjs +101 -0
  16. package/dist/agent-runtime/src/chat-outbox-entry.cjs.map +1 -0
  17. package/dist/agent-runtime/src/chat-outbox-entry.d.ts +99 -0
  18. package/dist/agent-runtime/src/chat-outbox-entry.js +101 -0
  19. package/dist/agent-runtime/src/chat-outbox-entry.js.map +1 -0
  20. package/dist/agent-runtime/src/chat-outbox-legacy.cjs +252 -0
  21. package/dist/agent-runtime/src/chat-outbox-legacy.cjs.map +1 -0
  22. package/dist/agent-runtime/src/chat-outbox-legacy.d.ts +96 -0
  23. package/dist/agent-runtime/src/chat-outbox-legacy.js +252 -0
  24. package/dist/agent-runtime/src/chat-outbox-legacy.js.map +1 -0
  25. package/dist/agent-runtime/src/chat-outbox-policy.cjs +30 -0
  26. package/dist/agent-runtime/src/chat-outbox-policy.cjs.map +1 -0
  27. package/dist/agent-runtime/src/chat-outbox-policy.d.ts +42 -0
  28. package/dist/agent-runtime/src/chat-outbox-policy.js +30 -0
  29. package/dist/agent-runtime/src/chat-outbox-policy.js.map +1 -0
  30. package/dist/agent-runtime/src/chat-outbox-storage.cjs +306 -0
  31. package/dist/agent-runtime/src/chat-outbox-storage.cjs.map +1 -0
  32. package/dist/agent-runtime/src/chat-outbox-storage.d.ts +194 -0
  33. package/dist/agent-runtime/src/chat-outbox-storage.js +306 -0
  34. package/dist/agent-runtime/src/chat-outbox-storage.js.map +1 -0
  35. package/dist/agent-runtime/src/chat-outbox-thread.cjs +21 -94
  36. package/dist/agent-runtime/src/chat-outbox-thread.cjs.map +1 -1
  37. package/dist/agent-runtime/src/chat-outbox-thread.d.ts +22 -18
  38. package/dist/agent-runtime/src/chat-outbox-thread.js +21 -94
  39. package/dist/agent-runtime/src/chat-outbox-thread.js.map +1 -1
  40. package/dist/agent-runtime/src/chat-outbox.cjs +492 -547
  41. package/dist/agent-runtime/src/chat-outbox.cjs.map +1 -1
  42. package/dist/agent-runtime/src/chat-outbox.d.ts +110 -142
  43. package/dist/agent-runtime/src/chat-outbox.js +492 -547
  44. package/dist/agent-runtime/src/chat-outbox.js.map +1 -1
  45. package/dist/agent-runtime/src/composer-markdown.cjs +0 -16
  46. package/dist/agent-runtime/src/composer-markdown.cjs.map +1 -1
  47. package/dist/agent-runtime/src/composer-markdown.d.ts +1 -1
  48. package/dist/agent-runtime/src/composer-markdown.js +1 -17
  49. package/dist/agent-runtime/src/composer-markdown.js.map +1 -1
  50. package/dist/agent-runtime/src/deep-agent-transport-recipe.cjs +3 -1
  51. package/dist/agent-runtime/src/deep-agent-transport-recipe.cjs.map +1 -1
  52. package/dist/agent-runtime/src/deep-agent-transport-recipe.d.ts +8 -1
  53. package/dist/agent-runtime/src/deep-agent-transport-recipe.js +3 -1
  54. package/dist/agent-runtime/src/deep-agent-transport-recipe.js.map +1 -1
  55. package/dist/agent-runtime/src/dictation-preferences.d.ts +356 -0
  56. package/dist/agent-runtime/src/dictation-record.d.ts +279 -0
  57. package/dist/agent-runtime/src/dictation-session.d.ts +106 -7
  58. package/dist/agent-runtime/src/dictation-snippets.d.ts +9 -0
  59. package/dist/agent-runtime/src/dictation-transfer.d.ts +142 -0
  60. package/dist/agent-runtime/src/edit-command.cjs.map +1 -1
  61. package/dist/agent-runtime/src/edit-command.d.ts +1 -1
  62. package/dist/agent-runtime/src/edit-command.js.map +1 -1
  63. package/dist/agent-runtime/src/errors.cjs +1 -0
  64. package/dist/agent-runtime/src/errors.cjs.map +1 -1
  65. package/dist/agent-runtime/src/errors.js +1 -0
  66. package/dist/agent-runtime/src/errors.js.map +1 -1
  67. package/dist/agent-runtime/src/generated/runconfig-contract.cjs +24 -0
  68. package/dist/agent-runtime/src/generated/runconfig-contract.cjs.map +1 -1
  69. package/dist/agent-runtime/src/generated/runconfig-contract.d.ts +3 -3
  70. package/dist/agent-runtime/src/generated/runconfig-contract.js +24 -0
  71. package/dist/agent-runtime/src/generated/runconfig-contract.js.map +1 -1
  72. package/dist/agent-runtime/src/index.d.ts +14 -8
  73. package/dist/agent-runtime/src/lane-follow.cjs +289 -0
  74. package/dist/agent-runtime/src/lane-follow.cjs.map +1 -0
  75. package/dist/agent-runtime/src/lane-follow.js +289 -0
  76. package/dist/agent-runtime/src/lane-follow.js.map +1 -0
  77. package/dist/agent-runtime/src/lane-images.cjs +387 -0
  78. package/dist/agent-runtime/src/lane-images.cjs.map +1 -0
  79. package/dist/agent-runtime/src/lane-images.js +387 -0
  80. package/dist/agent-runtime/src/lane-images.js.map +1 -0
  81. package/dist/agent-runtime/src/message-window.js +1 -1
  82. package/dist/agent-runtime/src/messages.cjs +19 -1
  83. package/dist/agent-runtime/src/messages.cjs.map +1 -1
  84. package/dist/agent-runtime/src/messages.d.ts +8 -0
  85. package/dist/agent-runtime/src/messages.js +21 -3
  86. package/dist/agent-runtime/src/messages.js.map +1 -1
  87. package/dist/agent-runtime/src/named-agents.cjs +301 -0
  88. package/dist/agent-runtime/src/named-agents.cjs.map +1 -0
  89. package/dist/agent-runtime/src/named-agents.d.ts +246 -0
  90. package/dist/agent-runtime/src/named-agents.js +301 -0
  91. package/dist/agent-runtime/src/named-agents.js.map +1 -0
  92. package/dist/agent-runtime/src/offline-status.cjs.map +1 -1
  93. package/dist/agent-runtime/src/offline-status.d.ts +93 -2
  94. package/dist/agent-runtime/src/offline-status.js.map +1 -1
  95. package/dist/agent-runtime/src/ptc-subcalls.cjs +41 -0
  96. package/dist/agent-runtime/src/ptc-subcalls.cjs.map +1 -0
  97. package/dist/agent-runtime/src/ptc-subcalls.js +41 -0
  98. package/dist/agent-runtime/src/ptc-subcalls.js.map +1 -0
  99. package/dist/agent-runtime/src/queue.cjs +2 -2
  100. package/dist/agent-runtime/src/queue.cjs.map +1 -1
  101. package/dist/agent-runtime/src/queue.d.ts +20 -25
  102. package/dist/agent-runtime/src/queue.js +2 -2
  103. package/dist/agent-runtime/src/queue.js.map +1 -1
  104. package/dist/agent-runtime/src/quota-safe-local-storage-session.cjs +314 -84
  105. package/dist/agent-runtime/src/quota-safe-local-storage-session.cjs.map +1 -1
  106. package/dist/agent-runtime/src/quota-safe-local-storage-session.d.ts +137 -40
  107. package/dist/agent-runtime/src/quota-safe-local-storage-session.js +318 -88
  108. package/dist/agent-runtime/src/quota-safe-local-storage-session.js.map +1 -1
  109. package/dist/agent-runtime/src/run-send.cjs +54 -0
  110. package/dist/agent-runtime/src/run-send.cjs.map +1 -0
  111. package/dist/agent-runtime/src/run-send.d.ts +51 -0
  112. package/dist/agent-runtime/src/run-send.js +54 -0
  113. package/dist/agent-runtime/src/run-send.js.map +1 -0
  114. package/dist/agent-runtime/src/running-tool-placeholder.cjs +6 -0
  115. package/dist/agent-runtime/src/running-tool-placeholder.cjs.map +1 -1
  116. package/dist/agent-runtime/src/running-tool-placeholder.js +6 -0
  117. package/dist/agent-runtime/src/running-tool-placeholder.js.map +1 -1
  118. package/dist/agent-runtime/src/runtime.d.ts +9 -5
  119. package/dist/agent-runtime/src/sealed-idb.cjs +64 -0
  120. package/dist/agent-runtime/src/sealed-idb.cjs.map +1 -1
  121. package/dist/agent-runtime/src/sealed-idb.d.ts +16 -0
  122. package/dist/agent-runtime/src/sealed-idb.js +64 -0
  123. package/dist/agent-runtime/src/sealed-idb.js.map +1 -1
  124. package/dist/agent-runtime/src/send-recovery.cjs +90 -118
  125. package/dist/agent-runtime/src/send-recovery.cjs.map +1 -1
  126. package/dist/agent-runtime/src/send-recovery.d.ts +25 -29
  127. package/dist/agent-runtime/src/send-recovery.js +90 -118
  128. package/dist/agent-runtime/src/send-recovery.js.map +1 -1
  129. package/dist/agent-runtime/src/statewire-diagnostics.d.ts +4 -1
  130. package/dist/agent-runtime/src/statewire-held-sends.cjs +191 -0
  131. package/dist/agent-runtime/src/statewire-held-sends.cjs.map +1 -0
  132. package/dist/agent-runtime/src/statewire-held-sends.d.ts +119 -0
  133. package/dist/agent-runtime/src/statewire-held-sends.js +191 -0
  134. package/dist/agent-runtime/src/statewire-held-sends.js.map +1 -0
  135. package/dist/agent-runtime/src/statewire-state.cjs +4 -0
  136. package/dist/agent-runtime/src/statewire-state.cjs.map +1 -1
  137. package/dist/agent-runtime/src/statewire-state.js +4 -0
  138. package/dist/agent-runtime/src/statewire-state.js.map +1 -1
  139. package/dist/agent-runtime/src/statewire-transport.cjs +8 -2
  140. package/dist/agent-runtime/src/statewire-transport.cjs.map +1 -1
  141. package/dist/agent-runtime/src/statewire-transport.d.ts +14 -5
  142. package/dist/agent-runtime/src/statewire-transport.js +8 -2
  143. package/dist/agent-runtime/src/statewire-transport.js.map +1 -1
  144. package/dist/agent-runtime/src/subagent-transcripts.cjs +1 -23
  145. package/dist/agent-runtime/src/subagent-transcripts.cjs.map +1 -1
  146. package/dist/agent-runtime/src/subagent-transcripts.js +3 -25
  147. package/dist/agent-runtime/src/subagent-transcripts.js.map +1 -1
  148. package/dist/agent-runtime/src/subagents.cjs +22 -29
  149. package/dist/agent-runtime/src/subagents.cjs.map +1 -1
  150. package/dist/agent-runtime/src/subagents.js +23 -30
  151. package/dist/agent-runtime/src/subagents.js.map +1 -1
  152. package/dist/agent-runtime/src/thread-extras.cjs +27 -19
  153. package/dist/agent-runtime/src/thread-extras.cjs.map +1 -1
  154. package/dist/agent-runtime/src/thread-extras.d.ts +19 -6
  155. package/dist/agent-runtime/src/thread-extras.js +27 -19
  156. package/dist/agent-runtime/src/thread-extras.js.map +1 -1
  157. package/dist/agent-runtime/src/thread-handoff-flow-machine.d.ts +8 -8
  158. package/dist/agent-runtime/src/tool-metadata.cjs +19 -0
  159. package/dist/agent-runtime/src/tool-metadata.cjs.map +1 -1
  160. package/dist/agent-runtime/src/tool-metadata.js +19 -0
  161. package/dist/agent-runtime/src/tool-metadata.js.map +1 -1
  162. package/dist/agent-runtime/src/tool-names.cjs +21 -0
  163. package/dist/agent-runtime/src/tool-names.cjs.map +1 -1
  164. package/dist/agent-runtime/src/tool-names.d.ts +8 -0
  165. package/dist/agent-runtime/src/tool-names.js +21 -0
  166. package/dist/agent-runtime/src/tool-names.js.map +1 -1
  167. package/dist/agent-runtime/src/typed-interrupt-kinds.cjs +247 -0
  168. package/dist/agent-runtime/src/typed-interrupt-kinds.cjs.map +1 -0
  169. package/dist/agent-runtime/src/typed-interrupt-kinds.d.ts +173 -0
  170. package/dist/agent-runtime/src/typed-interrupt-kinds.js +247 -0
  171. package/dist/agent-runtime/src/typed-interrupt-kinds.js.map +1 -0
  172. package/dist/agent-runtime/src/typed-interrupts.cjs +48 -0
  173. package/dist/agent-runtime/src/typed-interrupts.cjs.map +1 -0
  174. package/dist/agent-runtime/src/typed-interrupts.d.ts +75 -0
  175. package/dist/agent-runtime/src/typed-interrupts.js +48 -0
  176. package/dist/agent-runtime/src/typed-interrupts.js.map +1 -0
  177. package/dist/agent-runtime/src/types.d.ts +1 -1
  178. package/dist/agent-runtime/src/use-conversation-list.cjs +1 -0
  179. package/dist/agent-runtime/src/use-conversation-list.cjs.map +1 -1
  180. package/dist/agent-runtime/src/use-conversation-list.d.ts +7 -0
  181. package/dist/agent-runtime/src/use-conversation-list.js +1 -0
  182. package/dist/agent-runtime/src/use-conversation-list.js.map +1 -1
  183. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.cjs +46 -29
  184. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.cjs.map +1 -1
  185. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.d.ts +14 -22
  186. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.js +46 -29
  187. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.js.map +1 -1
  188. package/dist/agent-runtime/src/use-deep-agent-runtime.cjs +78 -14
  189. package/dist/agent-runtime/src/use-deep-agent-runtime.cjs.map +1 -1
  190. package/dist/agent-runtime/src/use-deep-agent-runtime.d.ts +34 -7
  191. package/dist/agent-runtime/src/use-deep-agent-runtime.js +79 -15
  192. package/dist/agent-runtime/src/use-deep-agent-runtime.js.map +1 -1
  193. package/dist/agent-runtime/src/use-deep-agent-thread.cjs +16 -1
  194. package/dist/agent-runtime/src/use-deep-agent-thread.cjs.map +1 -1
  195. package/dist/agent-runtime/src/use-deep-agent-thread.d.ts +7 -2
  196. package/dist/agent-runtime/src/use-deep-agent-thread.js +16 -1
  197. package/dist/agent-runtime/src/use-deep-agent-thread.js.map +1 -1
  198. package/dist/agent-runtime/src/use-deep-agent-voice.cjs +30 -4
  199. package/dist/agent-runtime/src/use-deep-agent-voice.cjs.map +1 -1
  200. package/dist/agent-runtime/src/use-deep-agent-voice.d.ts +22 -4
  201. package/dist/agent-runtime/src/use-deep-agent-voice.js +30 -4
  202. package/dist/agent-runtime/src/use-deep-agent-voice.js.map +1 -1
  203. package/dist/agent-runtime/src/withdrawn-turns.d.ts +5 -4
  204. package/dist/agent-runtime/src/word-device-fit.d.ts +174 -0
  205. package/dist/agent-runtime/src/work-in.d.ts +127 -0
  206. package/dist/assets/AthenaAssetEmbed.cjs.map +1 -1
  207. package/dist/assets/AthenaAssetEmbed.d.ts +6 -1
  208. package/dist/assets/AthenaAssetEmbed.js.map +1 -1
  209. package/dist/assets/asset-panel-store.cjs +13 -5
  210. package/dist/assets/asset-panel-store.cjs.map +1 -1
  211. package/dist/assets/asset-panel-store.d.ts +33 -2
  212. package/dist/assets/asset-panel-store.js +13 -5
  213. package/dist/assets/asset-panel-store.js.map +1 -1
  214. package/dist/auth/AthenaCredentialSourceContext.cjs +11 -0
  215. package/dist/auth/AthenaCredentialSourceContext.cjs.map +1 -1
  216. package/dist/auth/AthenaCredentialSourceContext.d.ts +6 -0
  217. package/dist/auth/AthenaCredentialSourceContext.js +11 -0
  218. package/dist/auth/AthenaCredentialSourceContext.js.map +1 -1
  219. package/dist/auth/account-identity.cjs +13 -2
  220. package/dist/auth/account-identity.cjs.map +1 -1
  221. package/dist/auth/account-identity.d.ts +9 -0
  222. package/dist/auth/account-identity.js +13 -2
  223. package/dist/auth/account-identity.js.map +1 -1
  224. package/dist/auth/credential-source.cjs +20 -4
  225. package/dist/auth/credential-source.cjs.map +1 -1
  226. package/dist/auth/credential-source.d.ts +9 -0
  227. package/dist/auth/credential-source.js +20 -4
  228. package/dist/auth/credential-source.js.map +1 -1
  229. package/dist/catalog/chat-pickers.cjs +31 -0
  230. package/dist/catalog/chat-pickers.cjs.map +1 -1
  231. package/dist/catalog/chat-pickers.d.ts +17 -0
  232. package/dist/catalog/chat-pickers.js +33 -2
  233. package/dist/catalog/chat-pickers.js.map +1 -1
  234. package/dist/catalog/runtime-catalog.cjs +63 -3
  235. package/dist/catalog/runtime-catalog.cjs.map +1 -1
  236. package/dist/catalog/runtime-catalog.d.ts +63 -3
  237. package/dist/catalog/runtime-catalog.js +64 -4
  238. package/dist/catalog/runtime-catalog.js.map +1 -1
  239. package/dist/chat/AthenaChat.cjs +301 -98
  240. package/dist/chat/AthenaChat.cjs.map +1 -1
  241. package/dist/chat/AthenaChat.d.ts +80 -4
  242. package/dist/chat/AthenaChat.js +302 -99
  243. package/dist/chat/AthenaChat.js.map +1 -1
  244. package/dist/chat/StatewireApprovalCard.cjs +35 -5
  245. package/dist/chat/StatewireApprovalCard.cjs.map +1 -1
  246. package/dist/chat/StatewireApprovalCard.d.ts +55 -2
  247. package/dist/chat/StatewireApprovalCard.js +37 -7
  248. package/dist/chat/StatewireApprovalCard.js.map +1 -1
  249. package/dist/chat/StatewireQueuedMessages.cjs +17 -2
  250. package/dist/chat/StatewireQueuedMessages.cjs.map +1 -1
  251. package/dist/chat/StatewireQueuedMessages.d.ts +8 -45
  252. package/dist/chat/StatewireQueuedMessages.js +18 -3
  253. package/dist/chat/StatewireQueuedMessages.js.map +1 -1
  254. package/dist/chat/chat-agent-mentions.cjs +70 -0
  255. package/dist/chat/chat-agent-mentions.cjs.map +1 -0
  256. package/dist/chat/chat-agent-mentions.d.ts +13 -0
  257. package/dist/chat/chat-agent-mentions.js +70 -0
  258. package/dist/chat/chat-agent-mentions.js.map +1 -0
  259. package/dist/chat/composer-actions.cjs +12 -0
  260. package/dist/chat/composer-actions.cjs.map +1 -0
  261. package/dist/chat/composer-actions.d.ts +22 -0
  262. package/dist/chat/composer-actions.js +12 -0
  263. package/dist/chat/composer-actions.js.map +1 -0
  264. package/dist/chat/follow-up-suggestions.cjs +185 -0
  265. package/dist/chat/follow-up-suggestions.cjs.map +1 -0
  266. package/dist/chat/follow-up-suggestions.d.ts +64 -0
  267. package/dist/chat/follow-up-suggestions.js +185 -0
  268. package/dist/chat/follow-up-suggestions.js.map +1 -0
  269. package/dist/chat/super-grouping/ToolTimeline.cjs +4 -3
  270. package/dist/chat/super-grouping/ToolTimeline.cjs.map +1 -1
  271. package/dist/chat/super-grouping/ToolTimeline.d.ts +7 -3
  272. package/dist/chat/super-grouping/ToolTimeline.js +4 -3
  273. package/dist/chat/super-grouping/ToolTimeline.js.map +1 -1
  274. package/dist/chat/turn-changes.cjs +284 -0
  275. package/dist/chat/turn-changes.cjs.map +1 -0
  276. package/dist/chat/turn-changes.d.ts +130 -0
  277. package/dist/chat/turn-changes.js +284 -0
  278. package/dist/chat/turn-changes.js.map +1 -0
  279. package/dist/chat/typed-interrupts/StatewireTypedInterruptCard.cjs +31 -0
  280. package/dist/chat/typed-interrupts/StatewireTypedInterruptCard.cjs.map +1 -0
  281. package/dist/chat/typed-interrupts/StatewireTypedInterruptCard.d.ts +31 -0
  282. package/dist/chat/typed-interrupts/StatewireTypedInterruptCard.js +31 -0
  283. package/dist/chat/typed-interrupts/StatewireTypedInterruptCard.js.map +1 -0
  284. package/dist/chat/typed-interrupts/approval-cards.cjs +250 -0
  285. package/dist/chat/typed-interrupts/approval-cards.cjs.map +1 -0
  286. package/dist/chat/typed-interrupts/approval-cards.d.ts +22 -0
  287. package/dist/chat/typed-interrupts/approval-cards.js +250 -0
  288. package/dist/chat/typed-interrupts/approval-cards.js.map +1 -0
  289. package/dist/chat/typed-interrupts/form-cards.cjs +289 -0
  290. package/dist/chat/typed-interrupts/form-cards.cjs.map +1 -0
  291. package/dist/chat/typed-interrupts/form-cards.d.ts +6 -0
  292. package/dist/chat/typed-interrupts/form-cards.js +289 -0
  293. package/dist/chat/typed-interrupts/form-cards.js.map +1 -0
  294. package/dist/chat/typed-interrupts/interrupt-card-shell.cjs +182 -0
  295. package/dist/chat/typed-interrupts/interrupt-card-shell.cjs.map +1 -0
  296. package/dist/chat/typed-interrupts/interrupt-card-shell.d.ts +47 -0
  297. package/dist/chat/typed-interrupts/interrupt-card-shell.js +182 -0
  298. package/dist/chat/typed-interrupts/interrupt-card-shell.js.map +1 -0
  299. package/dist/chat/typed-interrupts/json-schema-form.cjs +388 -0
  300. package/dist/chat/typed-interrupts/json-schema-form.cjs.map +1 -0
  301. package/dist/chat/typed-interrupts/json-schema-form.d.ts +33 -0
  302. package/dist/chat/typed-interrupts/json-schema-form.js +388 -0
  303. package/dist/chat/typed-interrupts/json-schema-form.js.map +1 -0
  304. package/dist/chat/typed-interrupts/questionnaire-card.cjs +449 -0
  305. package/dist/chat/typed-interrupts/questionnaire-card.cjs.map +1 -0
  306. package/dist/chat/typed-interrupts/questionnaire-card.d.ts +20 -0
  307. package/dist/chat/typed-interrupts/questionnaire-card.js +449 -0
  308. package/dist/chat/typed-interrupts/questionnaire-card.js.map +1 -0
  309. package/dist/chat/typed-interrupts/request-file-card.cjs +159 -0
  310. package/dist/chat/typed-interrupts/request-file-card.cjs.map +1 -0
  311. package/dist/chat/typed-interrupts/request-file-card.d.ts +2 -0
  312. package/dist/chat/typed-interrupts/request-file-card.js +159 -0
  313. package/dist/chat/typed-interrupts/request-file-card.js.map +1 -0
  314. package/dist/chat/typed-interrupts/toolkit-selection-card.cjs +189 -0
  315. package/dist/chat/typed-interrupts/toolkit-selection-card.cjs.map +1 -0
  316. package/dist/chat/typed-interrupts/toolkit-selection-card.d.ts +23 -0
  317. package/dist/chat/typed-interrupts/toolkit-selection-card.js +189 -0
  318. package/dist/chat/typed-interrupts/toolkit-selection-card.js.map +1 -0
  319. package/dist/chat/typed-interrupts/typed-interrupt-body.cjs +26 -0
  320. package/dist/chat/typed-interrupts/typed-interrupt-body.cjs.map +1 -0
  321. package/dist/chat/typed-interrupts/typed-interrupt-body.d.ts +3 -0
  322. package/dist/chat/typed-interrupts/typed-interrupt-body.js +26 -0
  323. package/dist/chat/typed-interrupts/typed-interrupt-body.js.map +1 -0
  324. package/dist/chat/typed-interrupts/typed-interrupt-graphql.cjs +105 -0
  325. package/dist/chat/typed-interrupts/typed-interrupt-graphql.cjs.map +1 -0
  326. package/dist/chat/typed-interrupts/typed-interrupt-graphql.d.ts +29 -0
  327. package/dist/chat/typed-interrupts/typed-interrupt-graphql.js +105 -0
  328. package/dist/chat/typed-interrupts/typed-interrupt-graphql.js.map +1 -0
  329. package/dist/chat/typed-interrupts/typed-interrupt-notice.cjs +70 -0
  330. package/dist/chat/typed-interrupts/typed-interrupt-notice.cjs.map +1 -0
  331. package/dist/chat/typed-interrupts/typed-interrupt-notice.d.ts +45 -0
  332. package/dist/chat/typed-interrupts/typed-interrupt-notice.js +70 -0
  333. package/dist/chat/typed-interrupts/typed-interrupt-notice.js.map +1 -0
  334. package/dist/chat/typed-interrupts/typed-interrupt-panel.cjs +76 -0
  335. package/dist/chat/typed-interrupts/typed-interrupt-panel.cjs.map +1 -0
  336. package/dist/chat/typed-interrupts/typed-interrupt-panel.d.ts +11 -0
  337. package/dist/chat/typed-interrupts/typed-interrupt-panel.js +76 -0
  338. package/dist/chat/typed-interrupts/typed-interrupt-panel.js.map +1 -0
  339. package/dist/chat/typed-interrupts/typed-interrupt-types.d.ts +46 -0
  340. package/dist/chat/typed-interrupts/use-interrupt-draft.cjs +106 -0
  341. package/dist/chat/typed-interrupts/use-interrupt-draft.cjs.map +1 -0
  342. package/dist/chat/typed-interrupts/use-interrupt-draft.d.ts +29 -0
  343. package/dist/chat/typed-interrupts/use-interrupt-draft.js +106 -0
  344. package/dist/chat/typed-interrupts/use-interrupt-draft.js.map +1 -0
  345. package/dist/chat/typed-interrupts/use-statewire-typed-interrupt.cjs +231 -0
  346. package/dist/chat/typed-interrupts/use-statewire-typed-interrupt.cjs.map +1 -0
  347. package/dist/chat/typed-interrupts/use-statewire-typed-interrupt.d.ts +66 -0
  348. package/dist/chat/typed-interrupts/use-statewire-typed-interrupt.js +231 -0
  349. package/dist/chat/typed-interrupts/use-statewire-typed-interrupt.js.map +1 -0
  350. package/dist/chat-ui/composer/composer-named-agents.cjs +13 -0
  351. package/dist/chat-ui/composer/composer-named-agents.cjs.map +1 -0
  352. package/dist/chat-ui/composer/composer-named-agents.d.ts +20 -0
  353. package/dist/chat-ui/composer/composer-named-agents.js +13 -0
  354. package/dist/chat-ui/composer/composer-named-agents.js.map +1 -0
  355. package/dist/chat-ui/composer/slash-command-menu.cjs +143 -0
  356. package/dist/chat-ui/composer/slash-command-menu.cjs.map +1 -0
  357. package/dist/chat-ui/composer/slash-command-menu.d.ts +19 -0
  358. package/dist/chat-ui/composer/slash-command-menu.js +143 -0
  359. package/dist/chat-ui/composer/slash-command-menu.js.map +1 -0
  360. package/dist/chat-ui/composer/slash-commands-extension.cjs +51 -0
  361. package/dist/chat-ui/composer/slash-commands-extension.cjs.map +1 -0
  362. package/dist/chat-ui/composer/slash-commands-extension.d.ts +39 -0
  363. package/dist/chat-ui/composer/slash-commands-extension.js +51 -0
  364. package/dist/chat-ui/composer/slash-commands-extension.js.map +1 -0
  365. package/dist/chat-ui/composer/slash-commands.cjs +74 -0
  366. package/dist/chat-ui/composer/slash-commands.cjs.map +1 -0
  367. package/dist/chat-ui/composer/slash-commands.d.ts +82 -0
  368. package/dist/chat-ui/composer/slash-commands.js +74 -0
  369. package/dist/chat-ui/composer/slash-commands.js.map +1 -0
  370. package/dist/chat-ui/composer/tiptap-composer.cjs +135 -9
  371. package/dist/chat-ui/composer/tiptap-composer.cjs.map +1 -1
  372. package/dist/chat-ui/composer/tiptap-composer.d.ts +61 -2
  373. package/dist/chat-ui/composer/tiptap-composer.js +135 -9
  374. package/dist/chat-ui/composer/tiptap-composer.js.map +1 -1
  375. package/dist/chat-ui/index.cjs +5 -0
  376. package/dist/chat-ui/index.cjs.map +1 -1
  377. package/dist/chat-ui/index.d.ts +4 -2
  378. package/dist/chat-ui/index.js +5 -0
  379. package/dist/chat-ui/index.js.map +1 -1
  380. package/dist/chat-ui/mentions/mention-chip.cjs +10 -4
  381. package/dist/chat-ui/mentions/mention-chip.cjs.map +1 -1
  382. package/dist/chat-ui/mentions/mention-chip.js +11 -5
  383. package/dist/chat-ui/mentions/mention-chip.js.map +1 -1
  384. package/dist/chat-ui/mentions/mention-extension.cjs +8 -1
  385. package/dist/chat-ui/mentions/mention-extension.cjs.map +1 -1
  386. package/dist/chat-ui/mentions/mention-extension.js +8 -1
  387. package/dist/chat-ui/mentions/mention-extension.js.map +1 -1
  388. package/dist/chat-ui/mentions/suggestions/components/get-scope-name.cjs +1 -0
  389. package/dist/chat-ui/mentions/suggestions/components/get-scope-name.cjs.map +1 -1
  390. package/dist/chat-ui/mentions/suggestions/components/get-scope-name.js +1 -0
  391. package/dist/chat-ui/mentions/suggestions/components/get-scope-name.js.map +1 -1
  392. package/dist/chat-ui/mentions/suggestions/components/mention-icon.cjs +20 -2
  393. package/dist/chat-ui/mentions/suggestions/components/mention-icon.cjs.map +1 -1
  394. package/dist/chat-ui/mentions/suggestions/components/mention-icon.d.ts +10 -1
  395. package/dist/chat-ui/mentions/suggestions/components/mention-icon.js +22 -4
  396. package/dist/chat-ui/mentions/suggestions/components/mention-icon.js.map +1 -1
  397. package/dist/chat-ui/mentions/suggestions/components/menu-item.cjs +1 -1
  398. package/dist/chat-ui/mentions/suggestions/components/menu-item.cjs.map +1 -1
  399. package/dist/chat-ui/mentions/suggestions/components/menu-item.js +1 -1
  400. package/dist/chat-ui/mentions/suggestions/components/menu-item.js.map +1 -1
  401. package/dist/chat-ui/mentions/suggestions/data/api-client.cjs +45 -0
  402. package/dist/chat-ui/mentions/suggestions/data/api-client.cjs.map +1 -1
  403. package/dist/chat-ui/mentions/suggestions/data/api-client.d.ts +48 -0
  404. package/dist/chat-ui/mentions/suggestions/data/api-client.js +45 -0
  405. package/dist/chat-ui/mentions/suggestions/data/api-client.js.map +1 -1
  406. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icon-names.generated.cjs +89 -0
  407. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icon-names.generated.cjs.map +1 -0
  408. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icon-names.generated.d.ts +8 -0
  409. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icon-names.generated.js +89 -0
  410. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icon-names.generated.js.map +1 -0
  411. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.cjs +140 -116
  412. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.cjs.map +1 -1
  413. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.d.ts +46 -12
  414. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.js +141 -117
  415. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.js.map +1 -1
  416. package/dist/chat-ui/mentions/suggestions/data/sources/index.cjs +272 -25
  417. package/dist/chat-ui/mentions/suggestions/data/sources/index.cjs.map +1 -1
  418. package/dist/chat-ui/mentions/suggestions/data/sources/index.d.ts +88 -10
  419. package/dist/chat-ui/mentions/suggestions/data/sources/index.js +274 -27
  420. package/dist/chat-ui/mentions/suggestions/data/sources/index.js.map +1 -1
  421. package/dist/chat-ui/mentions/suggestions/data/types.cjs.map +1 -1
  422. package/dist/chat-ui/mentions/suggestions/data/types.d.ts +27 -1
  423. package/dist/chat-ui/mentions/suggestions/data/types.js.map +1 -1
  424. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.cjs +56 -5
  425. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.cjs.map +1 -1
  426. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.d.ts +26 -6
  427. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.js +57 -6
  428. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.js.map +1 -1
  429. package/dist/chat-ui/mentions/suggestions/mention-suggestions.extension.cjs +34 -17
  430. package/dist/chat-ui/mentions/suggestions/mention-suggestions.extension.cjs.map +1 -1
  431. package/dist/chat-ui/mentions/suggestions/mention-suggestions.extension.d.ts +19 -1
  432. package/dist/chat-ui/mentions/suggestions/mention-suggestions.extension.js +35 -18
  433. package/dist/chat-ui/mentions/suggestions/mention-suggestions.extension.js.map +1 -1
  434. package/dist/chat-ui/mentions/use-asset-icon-app-url.cjs +12 -0
  435. package/dist/chat-ui/mentions/use-asset-icon-app-url.cjs.map +1 -0
  436. package/dist/chat-ui/mentions/use-asset-icon-app-url.d.ts +8 -0
  437. package/dist/chat-ui/mentions/use-asset-icon-app-url.js +12 -0
  438. package/dist/chat-ui/mentions/use-asset-icon-app-url.js.map +1 -0
  439. package/dist/chat-ui/statewire.d.ts +1 -1
  440. package/dist/chat-ui/thread/statewire-history-edge.cjs +15 -0
  441. package/dist/chat-ui/thread/statewire-history-edge.cjs.map +1 -1
  442. package/dist/chat-ui/thread/statewire-history-edge.d.ts +4 -1
  443. package/dist/chat-ui/thread/statewire-history-edge.js +15 -0
  444. package/dist/chat-ui/thread/statewire-history-edge.js.map +1 -1
  445. package/dist/collab/client.cjs +41 -6
  446. package/dist/collab/client.cjs.map +1 -1
  447. package/dist/collab/client.d.ts +38 -7
  448. package/dist/collab/client.js +41 -6
  449. package/dist/collab/client.js.map +1 -1
  450. package/dist/composer/ComposerAttachedReferences.cjs +119 -0
  451. package/dist/composer/ComposerAttachedReferences.cjs.map +1 -0
  452. package/dist/composer/ComposerAttachedReferences.d.ts +26 -0
  453. package/dist/composer/ComposerAttachedReferences.js +119 -0
  454. package/dist/composer/ComposerAttachedReferences.js.map +1 -0
  455. package/dist/composer/ComposerNamedAgents.cjs +63 -0
  456. package/dist/composer/ComposerNamedAgents.cjs.map +1 -0
  457. package/dist/composer/ComposerNamedAgents.d.ts +16 -0
  458. package/dist/composer/ComposerNamedAgents.js +63 -0
  459. package/dist/composer/ComposerNamedAgents.js.map +1 -0
  460. package/dist/composer/attached-references.cjs +159 -0
  461. package/dist/composer/attached-references.cjs.map +1 -0
  462. package/dist/composer/attached-references.d.ts +86 -0
  463. package/dist/composer/attached-references.js +159 -0
  464. package/dist/composer/attached-references.js.map +1 -0
  465. package/dist/composer/build-composed-message.cjs +14 -7
  466. package/dist/composer/build-composed-message.cjs.map +1 -1
  467. package/dist/composer/build-composed-message.d.ts +6 -1
  468. package/dist/composer/build-composed-message.js +14 -7
  469. package/dist/composer/build-composed-message.js.map +1 -1
  470. package/dist/composer/composer-handoff.cjs +6 -2
  471. package/dist/composer/composer-handoff.cjs.map +1 -1
  472. package/dist/composer/composer-handoff.d.ts +7 -1
  473. package/dist/composer/composer-handoff.js +6 -2
  474. package/dist/composer/composer-handoff.js.map +1 -1
  475. package/dist/composer/folder-upload.cjs +149 -0
  476. package/dist/composer/folder-upload.cjs.map +1 -0
  477. package/dist/composer/folder-upload.d.ts +79 -0
  478. package/dist/composer/folder-upload.js +149 -0
  479. package/dist/composer/folder-upload.js.map +1 -0
  480. package/dist/composer/index.d.ts +1 -1
  481. package/dist/composer/staged-message-metadata.cjs +12 -0
  482. package/dist/composer/staged-message-metadata.cjs.map +1 -0
  483. package/dist/composer/staged-message-metadata.d.ts +15 -0
  484. package/dist/composer/staged-message-metadata.js +12 -0
  485. package/dist/composer/staged-message-metadata.js.map +1 -0
  486. package/dist/composer/useAttachToChat.cjs +35 -0
  487. package/dist/composer/useAttachToChat.cjs.map +1 -0
  488. package/dist/composer/useAttachToChat.d.ts +54 -0
  489. package/dist/composer/useAttachToChat.js +35 -0
  490. package/dist/composer/useAttachToChat.js.map +1 -0
  491. package/dist/composer/useAttachedReferencesComposerProps.cjs +19 -0
  492. package/dist/composer/useAttachedReferencesComposerProps.cjs.map +1 -0
  493. package/dist/composer/useAttachedReferencesComposerProps.d.ts +12 -0
  494. package/dist/composer/useAttachedReferencesComposerProps.js +19 -0
  495. package/dist/composer/useAttachedReferencesComposerProps.js.map +1 -0
  496. package/dist/composer/useFileUpload.cjs +95 -7
  497. package/dist/composer/useFileUpload.cjs.map +1 -1
  498. package/dist/composer/useFileUpload.d.ts +21 -2
  499. package/dist/composer/useFileUpload.js +95 -7
  500. package/dist/composer/useFileUpload.js.map +1 -1
  501. package/dist/data/athena-api-error.cjs +125 -0
  502. package/dist/data/athena-api-error.cjs.map +1 -0
  503. package/dist/data/athena-api-error.d.ts +96 -0
  504. package/dist/data/athena-api-error.js +125 -0
  505. package/dist/data/athena-api-error.js.map +1 -0
  506. package/dist/data/athena-data-client.cjs +106 -0
  507. package/dist/data/athena-data-client.cjs.map +1 -0
  508. package/dist/data/athena-data-client.d.ts +74 -0
  509. package/dist/data/athena-data-client.js +106 -0
  510. package/dist/data/athena-data-client.js.map +1 -0
  511. package/dist/data/athena-member.cjs +93 -0
  512. package/dist/data/athena-member.cjs.map +1 -0
  513. package/dist/data/athena-member.d.ts +125 -0
  514. package/dist/data/athena-member.js +93 -0
  515. package/dist/data/athena-member.js.map +1 -0
  516. package/dist/data/athena-request.cjs +460 -0
  517. package/dist/data/athena-request.cjs.map +1 -0
  518. package/dist/data/athena-request.d.ts +120 -0
  519. package/dist/data/athena-request.js +460 -0
  520. package/dist/data/athena-request.js.map +1 -0
  521. package/dist/data/use-athena-fetch.cjs +14 -0
  522. package/dist/data/use-athena-fetch.cjs.map +1 -0
  523. package/dist/data/use-athena-fetch.d.ts +19 -0
  524. package/dist/data/use-athena-fetch.js +14 -0
  525. package/dist/data/use-athena-fetch.js.map +1 -0
  526. package/dist/data/use-athena-graphql.cjs +66 -0
  527. package/dist/data/use-athena-graphql.cjs.map +1 -0
  528. package/dist/data/use-athena-graphql.d.ts +56 -0
  529. package/dist/data/use-athena-graphql.js +66 -0
  530. package/dist/data/use-athena-graphql.js.map +1 -0
  531. package/dist/data/use-athena-rest.cjs +33 -0
  532. package/dist/data/use-athena-rest.cjs.map +1 -0
  533. package/dist/data/use-athena-rest.d.ts +21 -0
  534. package/dist/data/use-athena-rest.js +33 -0
  535. package/dist/data/use-athena-rest.js.map +1 -0
  536. package/dist/data/use-semantic-query.cjs +44 -0
  537. package/dist/data/use-semantic-query.cjs.map +1 -0
  538. package/dist/data/use-semantic-query.d.ts +92 -0
  539. package/dist/data/use-semantic-query.js +44 -0
  540. package/dist/data/use-semantic-query.js.map +1 -0
  541. package/dist/diagnostics/athena-diagnostics.cjs.map +1 -1
  542. package/dist/diagnostics/athena-diagnostics.d.ts +5 -1
  543. package/dist/diagnostics/athena-diagnostics.js.map +1 -1
  544. package/dist/diagnostics/errors.cjs +7 -0
  545. package/dist/diagnostics/errors.cjs.map +1 -1
  546. package/dist/diagnostics/errors.d.ts +7 -0
  547. package/dist/diagnostics/errors.js +7 -0
  548. package/dist/diagnostics/errors.js.map +1 -1
  549. package/dist/index.cjs +155 -11
  550. package/dist/index.cjs.map +1 -1
  551. package/dist/index.d.ts +72 -13
  552. package/dist/index.js +148 -4
  553. package/dist/index.js.map +1 -1
  554. package/dist/keryx-http/src/initial-sync.cjs +64 -16
  555. package/dist/keryx-http/src/initial-sync.cjs.map +1 -1
  556. package/dist/keryx-http/src/initial-sync.d.ts +31 -1
  557. package/dist/keryx-http/src/initial-sync.js +64 -16
  558. package/dist/keryx-http/src/initial-sync.js.map +1 -1
  559. package/dist/keryx-http/src/own-awareness.cjs +20 -0
  560. package/dist/keryx-http/src/own-awareness.cjs.map +1 -0
  561. package/dist/keryx-http/src/own-awareness.d.ts +50 -0
  562. package/dist/keryx-http/src/own-awareness.js +20 -0
  563. package/dist/keryx-http/src/own-awareness.js.map +1 -0
  564. package/dist/keryx-http/src/update-attributions.cjs +26 -1
  565. package/dist/keryx-http/src/update-attributions.cjs.map +1 -1
  566. package/dist/keryx-http/src/update-attributions.d.ts +10 -1
  567. package/dist/keryx-http/src/update-attributions.js +26 -1
  568. package/dist/keryx-http/src/update-attributions.js.map +1 -1
  569. package/dist/offline/chat-outbox.cjs +262 -26
  570. package/dist/offline/chat-outbox.cjs.map +1 -1
  571. package/dist/offline/chat-outbox.d.ts +90 -12
  572. package/dist/offline/chat-outbox.js +263 -27
  573. package/dist/offline/chat-outbox.js.map +1 -1
  574. package/dist/provider/AthenaProvider.cjs +60 -22
  575. package/dist/provider/AthenaProvider.cjs.map +1 -1
  576. package/dist/provider/AthenaProvider.d.ts +24 -8
  577. package/dist/provider/AthenaProvider.js +61 -23
  578. package/dist/provider/AthenaProvider.js.map +1 -1
  579. package/dist/react/package.json.cjs +1 -1
  580. package/dist/react/package.json.js +1 -1
  581. package/dist/references/src/anchors/parse.cjs +11 -1
  582. package/dist/references/src/anchors/parse.cjs.map +1 -1
  583. package/dist/references/src/anchors/parse.js +11 -1
  584. package/dist/references/src/anchors/parse.js.map +1 -1
  585. package/dist/references/src/anchors/schemas.d.ts +1 -0
  586. package/dist/references/src/anchors/serialize.cjs +1 -0
  587. package/dist/references/src/anchors/serialize.cjs.map +1 -1
  588. package/dist/references/src/anchors/serialize.js +1 -0
  589. package/dist/references/src/anchors/serialize.js.map +1 -1
  590. package/dist/references/src/anchors/types.cjs +5 -0
  591. package/dist/references/src/anchors/types.cjs.map +1 -1
  592. package/dist/references/src/anchors/types.d.ts +9 -0
  593. package/dist/references/src/anchors/types.js +5 -0
  594. package/dist/references/src/anchors/types.js.map +1 -1
  595. package/dist/references/src/attachable.cjs +149 -0
  596. package/dist/references/src/attachable.cjs.map +1 -0
  597. package/dist/references/src/attachable.d.ts +87 -0
  598. package/dist/references/src/attachable.js +149 -0
  599. package/dist/references/src/attachable.js.map +1 -0
  600. package/dist/references/src/schemas.d.ts +2 -0
  601. package/dist/runtime/StatewirePlanModeLaneSync.cjs +93 -0
  602. package/dist/runtime/StatewirePlanModeLaneSync.cjs.map +1 -0
  603. package/dist/runtime/StatewirePlanModeLaneSync.d.ts +34 -0
  604. package/dist/runtime/StatewirePlanModeLaneSync.js +93 -0
  605. package/dist/runtime/StatewirePlanModeLaneSync.js.map +1 -0
  606. package/dist/runtime/StatewireThreadConfigLaneSync.cjs +2 -0
  607. package/dist/runtime/StatewireThreadConfigLaneSync.cjs.map +1 -1
  608. package/dist/runtime/StatewireThreadConfigLaneSync.d.ts +4 -0
  609. package/dist/runtime/StatewireThreadConfigLaneSync.js +2 -0
  610. package/dist/runtime/StatewireThreadConfigLaneSync.js.map +1 -1
  611. package/dist/runtime/statewire-plan-mode.cjs +71 -0
  612. package/dist/runtime/statewire-plan-mode.cjs.map +1 -0
  613. package/dist/runtime/statewire-plan-mode.d.ts +88 -0
  614. package/dist/runtime/statewire-plan-mode.js +71 -0
  615. package/dist/runtime/statewire-plan-mode.js.map +1 -0
  616. package/dist/runtime/statewire-run-config.cjs +3 -1
  617. package/dist/runtime/statewire-run-config.cjs.map +1 -1
  618. package/dist/runtime/statewire-run-config.d.ts +7 -0
  619. package/dist/runtime/statewire-run-config.js +3 -1
  620. package/dist/runtime/statewire-run-config.js.map +1 -1
  621. package/dist/runtime/statewire-session-key.cjs +11 -5
  622. package/dist/runtime/statewire-session-key.cjs.map +1 -1
  623. package/dist/runtime/statewire-session-key.d.ts +22 -10
  624. package/dist/runtime/statewire-session-key.js +11 -5
  625. package/dist/runtime/statewire-session-key.js.map +1 -1
  626. package/dist/runtime/useAthenaStatewireRuntime.cjs +64 -9
  627. package/dist/runtime/useAthenaStatewireRuntime.cjs.map +1 -1
  628. package/dist/runtime/useAthenaStatewireRuntime.d.ts +26 -10
  629. package/dist/runtime/useAthenaStatewireRuntime.js +66 -11
  630. package/dist/runtime/useAthenaStatewireRuntime.js.map +1 -1
  631. package/dist/search/useAthenaAssets.cjs +394 -0
  632. package/dist/search/useAthenaAssets.cjs.map +1 -0
  633. package/dist/search/useAthenaAssets.d.ts +186 -0
  634. package/dist/search/useAthenaAssets.js +394 -0
  635. package/dist/search/useAthenaAssets.js.map +1 -0
  636. package/dist/sheet-range/index.cjs +4 -0
  637. package/dist/sheet-range/index.cjs.map +1 -1
  638. package/dist/sheet-range/index.d.ts +4 -2
  639. package/dist/sheet-range/index.js +4 -0
  640. package/dist/sheet-range/index.js.map +1 -1
  641. package/dist/sheet-range/query-range.cjs +102 -0
  642. package/dist/sheet-range/query-range.cjs.map +1 -0
  643. package/dist/sheet-range/query-range.d.ts +46 -0
  644. package/dist/sheet-range/query-range.js +102 -0
  645. package/dist/sheet-range/query-range.js.map +1 -0
  646. package/dist/styles.css +1 -1
  647. package/dist/subagents/index.cjs +49 -0
  648. package/dist/subagents/index.cjs.map +1 -0
  649. package/dist/subagents/index.d.ts +16 -0
  650. package/dist/subagents/index.js +49 -0
  651. package/dist/subagents/index.js.map +1 -0
  652. package/dist/subagents/lane-follow.cjs +19 -0
  653. package/dist/subagents/lane-follow.cjs.map +1 -0
  654. package/dist/subagents/lane-follow.d.ts +9 -0
  655. package/dist/subagents/lane-follow.js +19 -0
  656. package/dist/subagents/lane-follow.js.map +1 -0
  657. package/dist/subagents/lane-model.cjs +178 -0
  658. package/dist/subagents/lane-model.cjs.map +1 -0
  659. package/dist/subagents/lane-model.d.ts +140 -0
  660. package/dist/subagents/lane-model.js +178 -0
  661. package/dist/subagents/lane-model.js.map +1 -0
  662. package/dist/subagents/lane-parts.cjs +517 -0
  663. package/dist/subagents/lane-parts.cjs.map +1 -0
  664. package/dist/subagents/lane-parts.d.ts +130 -0
  665. package/dist/subagents/lane-parts.js +517 -0
  666. package/dist/subagents/lane-parts.js.map +1 -0
  667. package/dist/subagents/subagent-lane-group.cjs +215 -0
  668. package/dist/subagents/subagent-lane-group.cjs.map +1 -0
  669. package/dist/subagents/subagent-lane-group.d.ts +67 -0
  670. package/dist/subagents/subagent-lane-group.js +215 -0
  671. package/dist/subagents/subagent-lane-group.js.map +1 -0
  672. package/dist/subagents/subagent-transcript-drawer.cjs +431 -0
  673. package/dist/subagents/subagent-transcript-drawer.cjs.map +1 -0
  674. package/dist/subagents/subagent-transcript-drawer.d.ts +78 -0
  675. package/dist/subagents/subagent-transcript-drawer.js +431 -0
  676. package/dist/subagents/subagent-transcript-drawer.js.map +1 -0
  677. package/dist/subagents/task-subagent-group.cjs +115 -0
  678. package/dist/subagents/task-subagent-group.cjs.map +1 -0
  679. package/dist/subagents/task-subagent-group.d.ts +36 -0
  680. package/dist/subagents/task-subagent-group.js +115 -0
  681. package/dist/subagents/task-subagent-group.js.map +1 -0
  682. package/dist/subagents/use-omitted-images-in-view.cjs +68 -0
  683. package/dist/subagents/use-omitted-images-in-view.cjs.map +1 -0
  684. package/dist/subagents/use-omitted-images-in-view.d.ts +21 -0
  685. package/dist/subagents/use-omitted-images-in-view.js +68 -0
  686. package/dist/subagents/use-omitted-images-in-view.js.map +1 -0
  687. package/dist/threads/Inbox.cjs +2 -2
  688. package/dist/threads/Inbox.cjs.map +1 -1
  689. package/dist/threads/SessionList.cjs +6 -6
  690. package/dist/threads/SessionList.cjs.map +1 -1
  691. package/dist/threads/SessionsPage.cjs +13 -7
  692. package/dist/threads/SessionsPage.cjs.map +1 -1
  693. package/dist/threads/SessionsPage.d.ts +10 -1
  694. package/dist/threads/SessionsPage.js +9 -3
  695. package/dist/threads/SessionsPage.js.map +1 -1
  696. package/dist/threads/session-list-model.cjs.map +1 -1
  697. package/dist/threads/session-list-model.d.ts +2 -1
  698. package/dist/threads/session-list-model.js.map +1 -1
  699. package/dist/threads/session-row-parts.cjs +3 -3
  700. package/dist/threads/session-row-parts.cjs.map +1 -1
  701. package/dist/threads/sessions-page-model.cjs +13 -5
  702. package/dist/threads/sessions-page-model.cjs.map +1 -1
  703. package/dist/threads/sessions-page-model.d.ts +7 -0
  704. package/dist/threads/sessions-page-model.js +11 -3
  705. package/dist/threads/sessions-page-model.js.map +1 -1
  706. package/dist/threads/sessions-page-storage.cjs +8 -8
  707. package/dist/threads/sessions-page-storage.cjs.map +1 -1
  708. package/dist/threads/sessions-page-storage.d.ts +5 -1
  709. package/dist/threads/sessions-page-storage.js +8 -8
  710. package/dist/threads/sessions-page-storage.js.map +1 -1
  711. package/dist/threads/statewire-thread-list.cjs +14 -2
  712. package/dist/threads/statewire-thread-list.cjs.map +1 -1
  713. package/dist/threads/statewire-thread-list.d.ts +11 -2
  714. package/dist/threads/statewire-thread-list.js +14 -2
  715. package/dist/threads/statewire-thread-list.js.map +1 -1
  716. package/dist/threads/use-athena-sessions.cjs +1 -0
  717. package/dist/threads/use-athena-sessions.cjs.map +1 -1
  718. package/dist/threads/use-athena-sessions.d.ts +7 -0
  719. package/dist/threads/use-athena-sessions.js +1 -0
  720. package/dist/threads/use-athena-sessions.js.map +1 -1
  721. package/dist/threads/use-athena-thread-agent.cjs +31 -0
  722. package/dist/threads/use-athena-thread-agent.cjs.map +1 -0
  723. package/dist/threads/use-athena-thread-agent.d.ts +38 -0
  724. package/dist/threads/use-athena-thread-agent.js +31 -0
  725. package/dist/threads/use-athena-thread-agent.js.map +1 -0
  726. package/dist/threads/use-athena-thread-plan-mode.cjs +18 -0
  727. package/dist/threads/use-athena-thread-plan-mode.cjs.map +1 -0
  728. package/dist/threads/use-athena-thread-plan-mode.d.ts +18 -0
  729. package/dist/threads/use-athena-thread-plan-mode.js +18 -0
  730. package/dist/threads/use-athena-thread-plan-mode.js.map +1 -0
  731. package/dist/threads/use-rest-conversation-history.d.ts +1 -0
  732. package/dist/tools/agent-creations.cjs +97 -0
  733. package/dist/tools/agent-creations.cjs.map +1 -0
  734. package/dist/tools/agent-creations.d.ts +38 -0
  735. package/dist/tools/agent-creations.js +97 -0
  736. package/dist/tools/agent-creations.js.map +1 -0
  737. package/dist/tools/agent-highlights.cjs +100 -0
  738. package/dist/tools/agent-highlights.cjs.map +1 -0
  739. package/dist/tools/agent-highlights.d.ts +57 -0
  740. package/dist/tools/agent-highlights.js +100 -0
  741. package/dist/tools/agent-highlights.js.map +1 -0
  742. package/dist/tools/append-document-tool-ui.cjs +1 -0
  743. package/dist/tools/append-document-tool-ui.cjs.map +1 -1
  744. package/dist/tools/append-document-tool-ui.d.ts +7 -0
  745. package/dist/tools/append-document-tool-ui.js +2 -1
  746. package/dist/tools/append-document-tool-ui.js.map +1 -1
  747. package/dist/tools/auto-open-tools.cjs +144 -71
  748. package/dist/tools/auto-open-tools.cjs.map +1 -1
  749. package/dist/tools/auto-open-tools.d.ts +131 -1
  750. package/dist/tools/auto-open-tools.js +145 -72
  751. package/dist/tools/auto-open-tools.js.map +1 -1
  752. package/dist/tools/browser-tool-uis.cjs +594 -0
  753. package/dist/tools/browser-tool-uis.cjs.map +1 -0
  754. package/dist/tools/browser-tool-uis.d.ts +8 -0
  755. package/dist/tools/browser-tool-uis.js +594 -0
  756. package/dist/tools/browser-tool-uis.js.map +1 -0
  757. package/dist/tools/computer-asset-tool-uis.cjs +313 -0
  758. package/dist/tools/computer-asset-tool-uis.cjs.map +1 -0
  759. package/dist/tools/computer-asset-tool-uis.d.ts +5 -0
  760. package/dist/tools/computer-asset-tool-uis.js +313 -0
  761. package/dist/tools/computer-asset-tool-uis.js.map +1 -0
  762. package/dist/tools/document-edit-tool-uis.cjs +218 -0
  763. package/dist/tools/document-edit-tool-uis.cjs.map +1 -0
  764. package/dist/tools/document-edit-tool-uis.d.ts +40 -0
  765. package/dist/tools/document-edit-tool-uis.js +218 -0
  766. package/dist/tools/document-edit-tool-uis.js.map +1 -0
  767. package/dist/tools/drive-tool-uis.cjs +429 -0
  768. package/dist/tools/drive-tool-uis.cjs.map +1 -0
  769. package/dist/tools/drive-tool-uis.d.ts +121 -0
  770. package/dist/tools/drive-tool-uis.js +429 -0
  771. package/dist/tools/drive-tool-uis.js.map +1 -0
  772. package/dist/tools/email-calendar-tool-uis.cjs +789 -0
  773. package/dist/tools/email-calendar-tool-uis.cjs.map +1 -0
  774. package/dist/tools/email-calendar-tool-uis.d.ts +129 -0
  775. package/dist/tools/email-calendar-tool-uis.js +789 -0
  776. package/dist/tools/email-calendar-tool-uis.js.map +1 -0
  777. package/dist/tools/ontology-tool-uis.cjs +83 -0
  778. package/dist/tools/ontology-tool-uis.cjs.map +1 -0
  779. package/dist/tools/ontology-tool-uis.d.ts +9 -0
  780. package/dist/tools/ontology-tool-uis.js +83 -0
  781. package/dist/tools/ontology-tool-uis.js.map +1 -0
  782. package/dist/tools/orchestration-tool-uis.cjs +586 -0
  783. package/dist/tools/orchestration-tool-uis.cjs.map +1 -0
  784. package/dist/tools/orchestration-tool-uis.d.ts +141 -0
  785. package/dist/tools/orchestration-tool-uis.js +586 -0
  786. package/dist/tools/orchestration-tool-uis.js.map +1 -0
  787. package/dist/tools/presentation-edit-tool-uis.cjs +516 -0
  788. package/dist/tools/presentation-edit-tool-uis.cjs.map +1 -0
  789. package/dist/tools/presentation-edit-tool-uis.d.ts +73 -0
  790. package/dist/tools/presentation-edit-tool-uis.js +516 -0
  791. package/dist/tools/presentation-edit-tool-uis.js.map +1 -0
  792. package/dist/tools/project-tool-uis.cjs +213 -0
  793. package/dist/tools/project-tool-uis.cjs.map +1 -0
  794. package/dist/tools/project-tool-uis.d.ts +14 -0
  795. package/dist/tools/project-tool-uis.js +213 -0
  796. package/dist/tools/project-tool-uis.js.map +1 -0
  797. package/dist/tools/sandbox-tool-uis.cjs +491 -0
  798. package/dist/tools/sandbox-tool-uis.cjs.map +1 -0
  799. package/dist/tools/sandbox-tool-uis.d.ts +116 -0
  800. package/dist/tools/sandbox-tool-uis.js +491 -0
  801. package/dist/tools/sandbox-tool-uis.js.map +1 -0
  802. package/dist/tools/sheet-query-tool-ui.cjs +138 -0
  803. package/dist/tools/sheet-query-tool-ui.cjs.map +1 -0
  804. package/dist/tools/sheet-query-tool-ui.d.ts +15 -0
  805. package/dist/tools/sheet-query-tool-ui.js +138 -0
  806. package/dist/tools/sheet-query-tool-ui.js.map +1 -0
  807. package/dist/tools/studio-screenshot-tool-uis.cjs +262 -0
  808. package/dist/tools/studio-screenshot-tool-uis.cjs.map +1 -0
  809. package/dist/tools/studio-screenshot-tool-uis.d.ts +52 -0
  810. package/dist/tools/studio-screenshot-tool-uis.js +262 -0
  811. package/dist/tools/studio-screenshot-tool-uis.js.map +1 -0
  812. package/dist/tools/subagent-task-tool-ui.cjs +24 -475
  813. package/dist/tools/subagent-task-tool-ui.cjs.map +1 -1
  814. package/dist/tools/subagent-task-tool-ui.d.ts +19 -103
  815. package/dist/tools/subagent-task-tool-ui.js +28 -479
  816. package/dist/tools/subagent-task-tool-ui.js.map +1 -1
  817. package/dist/tools/tool-summary.cjs +36 -0
  818. package/dist/tools/tool-summary.cjs.map +1 -1
  819. package/dist/tools/tool-summary.js +36 -0
  820. package/dist/tools/tool-summary.js.map +1 -1
  821. package/dist/tools/tool-uis.cjs +181 -53
  822. package/dist/tools/tool-uis.cjs.map +1 -1
  823. package/dist/tools/tool-uis.d.ts +40 -0
  824. package/dist/tools/tool-uis.js +183 -55
  825. package/dist/tools/tool-uis.js.map +1 -1
  826. package/dist/typed-interrupts/index.cjs +15 -0
  827. package/dist/typed-interrupts/index.cjs.map +1 -0
  828. package/dist/typed-interrupts/index.d.ts +20 -0
  829. package/dist/typed-interrupts/index.js +15 -0
  830. package/dist/typed-interrupts/index.js.map +1 -0
  831. package/dist/version.cjs +4 -0
  832. package/dist/version.cjs.map +1 -1
  833. package/dist/version.d.ts +9 -0
  834. package/dist/version.js +4 -0
  835. package/dist/version.js.map +1 -1
  836. package/dist/workbench/live-desktop-api.cjs +2 -1
  837. package/dist/workbench/live-desktop-api.cjs.map +1 -1
  838. package/dist/workbench/live-desktop-api.js +2 -1
  839. package/dist/workbench/live-desktop-api.js.map +1 -1
  840. package/dist/workbench/session-workbench-panes.cjs +6 -6
  841. package/dist/workbench/session-workbench-panes.cjs.map +1 -1
  842. package/dist/workbench/session-workspace-api.cjs +7 -2
  843. package/dist/workbench/session-workspace-api.cjs.map +1 -1
  844. package/dist/workbench/session-workspace-api.d.ts +10 -0
  845. package/dist/workbench/session-workspace-api.js +7 -2
  846. package/dist/workbench/session-workspace-api.js.map +1 -1
  847. package/package.json +28 -6
  848. package/dist/agent-runtime/src/chat-outbox-store.cjs +0 -510
  849. package/dist/agent-runtime/src/chat-outbox-store.cjs.map +0 -1
  850. package/dist/agent-runtime/src/chat-outbox-store.d.ts +0 -210
  851. package/dist/agent-runtime/src/chat-outbox-store.js +0 -510
  852. package/dist/agent-runtime/src/chat-outbox-store.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"useFileUpload.js","sources":["../../src/composer/useFileUpload.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\nimport { useAthenaConfig } from '../provider/AthenaContext';\n\nexport interface UploadedAsset {\n id: string;\n title: string;\n fileName: string;\n fileSize: number;\n mediaType: string;\n /**\n * The position, in the batch `upload` was given, of the file this asset was\n * uploaded from (the upload's `success_file_indexes`; absent from a server\n * that does not send them).\n */\n fileIndex?: number;\n /**\n * A local `blob:` URL of the picture this attachment was uploaded from, for\n * the composer's thumbnail and full-screen viewer. Set by the composer's\n * intake for image files, and revoked when the draft lets the attachment go.\n */\n previewUrl?: string;\n}\n\nexport interface UploadProgress {\n current: number;\n total: number;\n fileName: string;\n /** 0–1 normalized progress for the current file */\n percent: number;\n}\n\nexport interface UseFileUploadReturn {\n /** Upload one or more files to Athena. Returns the created asset(s). */\n upload: (files: File[]) => Promise<UploadedAsset[]>;\n /** Whether an upload is currently in progress. */\n isUploading: boolean;\n /** Upload progress info (null when idle). */\n progress: UploadProgress | null;\n /** Last upload error (null when no error). */\n error: string | null;\n /** Clear the error state. */\n clearError: () => void;\n}\n\nconst MAX_FILE_SIZE = 5 * 1024 * 1024 * 1024; // 5 GB\n\n/**\n * Hook for uploading files to the Athena platform via the Athena upload endpoint.\n * Files become Athena assets (documents, spreadsheets, PDFs, images, etc.).\n *\n * Usage:\n * const { upload, isUploading, progress, error } = useFileUpload();\n * const assets = await upload(fileList);\n */\nexport function useFileUpload(): UseFileUploadReturn {\n const config = useAthenaConfig();\n // Keep config in a ref so upload() always reads the latest token at call\n // time. AthenaConfig's token is a getter that returns the current value\n // from PropelAuth, and reading via the ref avoids capturing stale\n // destructured values in the useCallback closure.\n const configRef = useRef(config);\n configRef.current = config;\n const { backendUrl, apiKey } = config;\n const [isUploading, setIsUploading] = useState(false);\n const [progress, setProgress] = useState<UploadProgress | null>(null);\n const [error, setError] = useState<string | null>(null);\n const xhrRef = useRef<XMLHttpRequest | null>(null);\n\n // Abort any in-flight upload when the component unmounts\n useEffect(() => {\n return () => {\n xhrRef.current?.abort();\n };\n }, []);\n\n const clearError = useCallback(() => setError(null), []);\n\n const upload = useCallback(\n async (files: File[]): Promise<UploadedAsset[]> => {\n if (files.length === 0) return [];\n\n // Validate file sizes\n for (const file of files) {\n if (file.size > MAX_FILE_SIZE) {\n const msg = `File \"${file.name}\" exceeds the maximum size of 5 GB.`;\n setError(msg);\n throw new Error(msg);\n }\n }\n\n setIsUploading(true);\n setError(null);\n setProgress({ current: 0, total: files.length, fileName: files[0]?.name ?? '', percent: 0 });\n\n try {\n const formData = new FormData();\n for (const file of files) {\n formData.append('files', file, file.name);\n }\n\n // Derive the upload URL from the configured Athena backend URL.\n // If backendUrl points at a nested Athena endpoint, trim it back to the API base first.\n const baseUrl = backendUrl.replace(/\\/api\\/assistant-ui\\/?$/, '');\n const uploadUrl = `${baseUrl}/api/upload/`;\n\n // Read the current token at call time so rotated tokens are picked up.\n const currentToken = configRef.current.token;\n const headers: Record<string, string> = {};\n if (currentToken) {\n headers['Authorization'] = `Bearer ${currentToken}`;\n } else if (apiKey) {\n headers['X-API-KEY'] = apiKey;\n }\n\n const xhr = new XMLHttpRequest();\n xhrRef.current = xhr;\n\n const result = await new Promise<{ success: UploadedAsset[]; errors: Array<{ file: { filename: string }; error: string }> }>((resolve, reject) => {\n xhr.upload.addEventListener('progress', (e) => {\n if (e.lengthComputable) {\n const percent = e.loaded / e.total;\n // Estimate which file we're on based on progress\n const fileIndex = Math.min(\n Math.floor(percent * files.length),\n files.length - 1,\n );\n setProgress({\n current: fileIndex + 1,\n total: files.length,\n fileName: files[fileIndex]?.name ?? '',\n percent,\n });\n }\n });\n\n xhr.addEventListener('load', () => {\n if (xhr.status >= 200 && xhr.status < 300) {\n try {\n const data = JSON.parse(xhr.responseText);\n const fileIndexes: unknown = data.success_file_indexes;\n const assets: UploadedAsset[] = (data.success ?? []).map((a: Record<string, unknown>, at: number) => {\n const fileIndex = Array.isArray(fileIndexes) ? fileIndexes[at] : undefined;\n return {\n id: a.id as string,\n title: (a.title ?? a.file_name) as string,\n fileName: a.file_name as string,\n fileSize: a.file_size as number,\n mediaType: a.media_type as string,\n ...(typeof fileIndex === 'number' && { fileIndex }),\n };\n });\n resolve({ success: assets, errors: data.errors ?? [] });\n } catch {\n reject(new Error('Failed to parse upload response'));\n }\n } else if (xhr.status === 401 || xhr.status === 403) {\n reject(new Error('Authentication failed. Check your API key or token.'));\n } else {\n reject(new Error(`Upload failed with status ${xhr.status}`));\n }\n });\n\n xhr.addEventListener('error', () => reject(new Error('Network error during upload')));\n xhr.addEventListener('abort', () => reject(new Error('Upload was cancelled')));\n\n xhr.open('POST', uploadUrl);\n for (const [key, value] of Object.entries(headers)) {\n xhr.setRequestHeader(key, value);\n }\n xhr.withCredentials = !currentToken && !apiKey;\n xhr.send(formData);\n });\n\n if (result.errors.length > 0) {\n const errMsg = result.errors.map((e) => `${e.file.filename}: ${e.error}`).join('; ');\n if (result.success.length === 0) {\n setError(errMsg);\n throw new Error(errMsg);\n }\n // Partial success — set error but still return successful uploads\n setError(errMsg);\n }\n\n return result.success;\n } catch (err) {\n const msg = err instanceof Error ? err.message : 'Upload failed';\n setError(msg);\n throw err;\n } finally {\n xhrRef.current = null;\n setIsUploading(false);\n setProgress(null);\n }\n },\n [backendUrl, apiKey],\n );\n\n return { upload, isUploading, progress, error, clearError };\n}\n"],"names":["_a"],"mappings":";;AA4CA,MAAM,gBAAgB,IAAI,OAAO,OAAO;AAUjC,SAAS,gBAAqC;AACnD,QAAM,SAAS,gBAAA;AAKf,QAAM,YAAY,OAAO,MAAM;AAC/B,YAAU,UAAU;AACpB,QAAM,EAAE,YAAY,OAAA,IAAW;AAC/B,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,KAAK;AACpD,QAAM,CAAC,UAAU,WAAW,IAAI,SAAgC,IAAI;AACpE,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAwB,IAAI;AACtD,QAAM,SAAS,OAA8B,IAAI;AAGjD,YAAU,MAAM;AACd,WAAO,MAAM;;AACX,mBAAO,YAAP,mBAAgB;AAAA,IAClB;AAAA,EACF,GAAG,CAAA,CAAE;AAEL,QAAM,aAAa,YAAY,MAAM,SAAS,IAAI,GAAG,CAAA,CAAE;AAEvD,QAAM,SAAS;AAAA,IACb,OAAO,UAA4C;;AACjD,UAAI,MAAM,WAAW,EAAG,QAAO,CAAA;AAG/B,iBAAW,QAAQ,OAAO;AACxB,YAAI,KAAK,OAAO,eAAe;AAC7B,gBAAM,MAAM,SAAS,KAAK,IAAI;AAC9B,mBAAS,GAAG;AACZ,gBAAM,IAAI,MAAM,GAAG;AAAA,QACrB;AAAA,MACF;AAEA,qBAAe,IAAI;AACnB,eAAS,IAAI;AACb,kBAAY,EAAE,SAAS,GA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M;AAAA,QACjB;AAEA,eAAO,OAAO;AAAA,MAChB,SAAS,KAAK;AACZ,cAAM,MAAM,eAAe,QAAQ,IAAI,UAAU;AACjD,iBAAS,GAAG;AACZ,cAAM;AAAA,MACR,UAAA;AACE,eAAO,UAAU;AACjB,uBAAe,KAAK;AACpB,oBAAY,IAAI;AAAA,MAClB;AAAA,IACF;AAAA,IACA,CAAC,YAAY,MAAM;AAAA,EAAA;AAGrB,SAAO,EAAE,QAAQ,aAAa,UAAU,OAAO,WAAA;AACjD;"}
1
+ {"version":3,"file":"useFileUpload.js","sources":["../../src/composer/useFileUpload.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\nimport type { MentionAuthContext } from '../chat-ui/mentions/suggestions/data/api-client';\nimport { useAthenaConfig } from '../provider/AthenaContext';\nimport {\n FOLDER_UPLOAD_PATH,\n folderUploadResultOf,\n startFolderUpload,\n waitForFolderUploadTask,\n} from './folder-upload';\n\nexport interface UploadedAsset {\n id: string;\n title: string;\n fileName: string;\n fileSize: number;\n mediaType: string;\n /**\n * The position, in the batch `upload` was given, of the file this asset was\n * uploaded from (the upload's `success_file_indexes`; absent from a server\n * that does not send them).\n */\n fileIndex?: number;\n /**\n * A local `blob:` URL of the picture this attachment was uploaded from, for\n * the composer's thumbnail and full-screen viewer. Set by the composer's\n * intake for image files, and revoked when the draft lets the attachment go.\n */\n previewUrl?: string;\n}\n\nexport interface UploadProgress {\n current: number;\n total: number;\n fileName: string;\n /** 0–1 normalized progress for the current file */\n percent: number;\n}\n\n/** A file Athena refused while it took others from the same upload, with its reason. */\nexport interface UploadRefusal {\n fileName: string;\n error: string;\n}\n\nexport interface UploadOptions {\n /**\n * The folder the files go into. agora's async upload takes them there, and refuses the whole\n * upload, before it takes any file, unless the person may edit that folder. Without one they are\n * filed at the workspace's root, as before.\n */\n parentFolderId?: string | null;\n /**\n * Hears the files Athena refused when it took others from the same upload, before `upload`\n * resolves with the ones it took (the hook's `error` says the same, as one line). An upload that\n * took none rejects instead.\n */\n onFilesRefused?: (refused: readonly UploadRefusal[]) => void;\n}\n\nexport interface UseFileUploadReturn {\n /** Upload one or more files to Athena (into a folder, `parentFolderId`). Returns the created asset(s). */\n upload: (files: File[], options?: UploadOptions) => Promise<UploadedAsset[]>;\n /** Whether an upload is currently in progress. */\n isUploading: boolean;\n /** Upload progress info (null when idle). */\n progress: UploadProgress | null;\n /** Last upload error (null when no error). */\n error: string | null;\n /** Clear the error state. */\n clearError: () => void;\n}\n\nconst MAX_FILE_SIZE = 5 * 1024 * 1024 * 1024; // 5 GB\n\n/**\n * Hook for uploading files to the Athena platform via the Athena upload endpoint.\n * Files become Athena assets (documents, spreadsheets, PDFs, images, etc.).\n *\n * Usage:\n * const { upload, isUploading, progress, error } = useFileUpload();\n * const assets = await upload(fileList);\n */\nexport function useFileUpload(): UseFileUploadReturn {\n const config = useAthenaConfig();\n // Keep config in a ref so upload() always reads the latest token at call\n // time. AthenaConfig's token is a getter that returns the current value\n // from PropelAuth, and reading via the ref avoids capturing stale\n // destructured values in the useCallback closure.\n const configRef = useRef(config);\n configRef.current = config;\n const { backendUrl, apiKey } = config;\n const [isUploading, setIsUploading] = useState(false);\n const [progress, setProgress] = useState<UploadProgress | null>(null);\n const [error, setError] = useState<string | null>(null);\n const xhrRef = useRef<XMLHttpRequest | null>(null);\n // An upload into a folder reads its task until it ends: let go of it when the component goes.\n const taskWaitRef = useRef<AbortController | null>(null);\n\n // Abort any in-flight upload when the component unmounts\n useEffect(() => {\n return () => {\n xhrRef.current?.abort();\n taskWaitRef.current?.abort();\n };\n }, []);\n\n const clearError = useCallback(() => setError(null), []);\n\n /**\n * Into a folder: agora's async upload (`POST /api/upload/async` with `parent_folder_id`, which\n * authorizes EDIT on the folder before it takes a file), its bytes' progress reported as the\n * quick upload's is, then its task read until it ends (`folder-upload.ts`).\n */\n const uploadIntoFolder = useCallback(\n async ({\n files,\n parentFolderId,\n baseUrl,\n headers,\n currentToken,\n }: {\n files: File[];\n parentFolderId: string;\n baseUrl: string;\n headers: Record<string, string>;\n currentToken: string | null | undefined;\n }): Promise<{ uploaded: UploadedAsset[]; refused: UploadRefusal[] }> => {\n const send = (form: FormData) =>\n new Promise<Response>((resolve, reject) => {\n const xhr = new XMLHttpRequest();\n xhrRef.current = xhr;\n xhr.upload.addEventListener('progress', (e) => {\n if (!e.lengthComputable) return;\n const percent = e.loaded / e.total;\n const fileIndex = Math.min(Math.floor(percent * files.length), files.length - 1);\n setProgress({\n current: fileIndex + 1,\n total: files.length,\n fileName: files[fileIndex]?.name ?? '',\n percent,\n });\n });\n xhr.addEventListener('load', () =>\n resolve(new Response(xhr.responseText, { status: xhr.status })),\n );\n xhr.addEventListener('error', () => reject(new Error('Network error during upload')));\n xhr.addEventListener('abort', () => reject(new Error('Upload was cancelled')));\n xhr.open('POST', `${baseUrl}${FOLDER_UPLOAD_PATH}`);\n for (const [key, value] of Object.entries(headers)) xhr.setRequestHeader(key, value);\n xhr.withCredentials = !currentToken && !configRef.current.apiKey;\n xhr.send(form);\n });\n const taskId = await startFolderUpload({ send, files, parentFolderId });\n const config = configRef.current;\n const auth: MentionAuthContext = {\n backendUrl: baseUrl,\n appUrl: config.appUrl,\n apiKey: config.apiKey,\n credentials: 'include',\n get accessToken() {\n return configRef.current.token ?? undefined;\n },\n getAccessToken: async () => (await configRef.current.getToken?.()) ?? undefined,\n renewAccessToken: async () =>\n (await configRef.current.getToken?.({ force: true })) ?? undefined,\n };\n const waiting = new AbortController();\n taskWaitRef.current = waiting;\n try {\n const task = await waitForFolderUploadTask({ auth, taskId, signal: waiting.signal });\n const { uploaded, failed } = folderUploadResultOf({ task, files });\n if (failed.length > 0) {\n const errMsg = failed.map((entry) => `${entry.fileName}: ${entry.error}`).join('; ');\n setError(errMsg);\n if (uploaded.length === 0) throw new Error(errMsg);\n }\n return { uploaded, refused: failed };\n } finally {\n if (taskWaitRef.current === waiting) taskWaitRef.current = null;\n }\n },\n [],\n );\n\n const upload = useCallback(\n async (files: File[], options: UploadOptions = {}): Promise<UploadedAsset[]> => {\n if (files.length === 0) return [];\n\n // Validate file sizes\n for (const file of files) {\n if (file.size > MAX_FILE_SIZE) {\n const msg = `File \"${file.name}\" exceeds the maximum size of 5 GB.`;\n setError(msg);\n throw new Error(msg);\n }\n }\n\n setIsUploading(true);\n setError(null);\n setProgress({ current: 0, total: files.length, fileName: files[0]?.name ?? '', percent: 0 });\n\n try {\n // Derive the upload URL from the configured Athena backend URL.\n // If backendUrl points at a nested Athena endpoint, trim it back to the API base first.\n const baseUrl = backendUrl.replace(/\\/api\\/assistant-ui\\/?$/, '');\n const uploadUrl = `${baseUrl}/api/upload/`;\n\n // Read the current token at call time so rotated tokens are picked up.\n const currentToken = configRef.current.token;\n const headers: Record<string, string> = {};\n if (currentToken) {\n headers['Authorization'] = `Bearer ${currentToken}`;\n } else if (apiKey) {\n headers['X-API-KEY'] = apiKey;\n }\n\n const { parentFolderId, onFilesRefused } = options;\n if (parentFolderId) {\n const { uploaded, refused } = await uploadIntoFolder({\n files,\n parentFolderId,\n baseUrl,\n headers,\n currentToken,\n });\n if (refused.length > 0) onFilesRefused?.(refused);\n return uploaded;\n }\n\n const formData = new FormData();\n for (const file of files) {\n formData.append('files', file, file.name);\n }\n\n const xhr = new XMLHttpRequest();\n xhrRef.current = xhr;\n\n const result = await new Promise<{ success: UploadedAsset[]; errors: Array<{ file: { filename: string }; error: string }> }>((resolve, reject) => {\n xhr.upload.addEventListener('progress', (e) => {\n if (e.lengthComputable) {\n const percent = e.loaded / e.total;\n // Estimate which file we're on based on progress\n const fileIndex = Math.min(\n Math.floor(percent * files.length),\n files.length - 1,\n );\n setProgress({\n current: fileIndex + 1,\n total: files.length,\n fileName: files[fileIndex]?.name ?? '',\n percent,\n });\n }\n });\n\n xhr.addEventListener('load', () => {\n if (xhr.status >= 200 && xhr.status < 300) {\n try {\n const data = JSON.parse(xhr.responseText);\n const fileIndexes: unknown = data.success_file_indexes;\n const assets: UploadedAsset[] = (data.success ?? []).map((a: Record<string, unknown>, at: number) => {\n const fileIndex = Array.isArray(fileIndexes) ? fileIndexes[at] : undefined;\n return {\n id: a.id as string,\n title: (a.title ?? a.file_name) as string,\n fileName: a.file_name as string,\n fileSize: a.file_size as number,\n mediaType: a.media_type as string,\n ...(typeof fileIndex === 'number' && { fileIndex }),\n };\n });\n resolve({ success: assets, errors: data.errors ?? [] });\n } catch {\n reject(new Error('Failed to parse upload response'));\n }\n } else if (xhr.status === 401 || xhr.status === 403) {\n reject(new Error('Authentication failed. Check your API key or token.'));\n } else {\n reject(new Error(`Upload failed with status ${xhr.status}`));\n }\n });\n\n xhr.addEventListener('error', () => reject(new Error('Network error during upload')));\n xhr.addEventListener('abort', () => reject(new Error('Upload was cancelled')));\n\n xhr.open('POST', uploadUrl);\n for (const [key, value] of Object.entries(headers)) {\n xhr.setRequestHeader(key, value);\n }\n xhr.withCredentials = !currentToken && !apiKey;\n xhr.send(formData);\n });\n\n if (result.errors.length > 0) {\n const errMsg = result.errors.map((e) => `${e.file.filename}: ${e.error}`).join('; ');\n if (result.success.length === 0) {\n setError(errMsg);\n throw new Error(errMsg);\n }\n // Partial success — set error but still return successful uploads\n setError(errMsg);\n onFilesRefused?.(\n result.errors.map((e) => ({ fileName: e.file.filename, error: e.error })),\n );\n }\n\n return result.success;\n } catch (err) {\n const msg = err instanceof Error ? err.message : 'Upload failed';\n setError(msg);\n throw err;\n } finally {\n xhrRef.current = null;\n setIsUploading(false);\n setProgress(null);\n }\n },\n [backendUrl, apiKey, uploadIntoFolder],\n );\n\n return { upload, isUploading, progress, error, clearError };\n}\n"],"names":["config","_a"],"mappings":";;;AAwEA,MAAM,gBAAgB,IAAI,OAAO,OAAO;AAUjC,SAAS,gBAAqC;AACnD,QAAM,SAAS,gBAAA;AAKf,QAAM,YAAY,OAAO,MAAM;AAC/B,YAAU,UAAU;AACpB,QAAM,EAAE,YAAY,OAAA,IAAW;AAC/B,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,KAAK;AACpD,QA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C;AACpF,cAAI,iBAAiB,SAAS,MAAM,OAAO,IAAI,MAAM,sBAAsB,CAAC,CAAC;AAE7E,cAAI,KAAK,QAAQ,SAAS;AAC1B,qBAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,OAAO,GAAG;AAClD,gBAAI,iBAAiB,KAAK,KAAK;AAAA,UACjC;AACA,cAAI,kBAAkB,CAAC,gBAAgB,CAAC;AACxC,cAAI,KAAK,QAAQ;AAAA,QACnB,CAAC;AAED,YAAI,OAAO,OAAO,SAAS,GAAG;AAC5B,gBAAM,SAAS,OAAO,OAAO,IAAI,CAAC,MAAM,GAAG,EAAE,KAAK,QAAQ,KAAK,EAAE,KAAK,EAAE,EAAE,KAAK,IAAI;AACnF,cAAI,OAAO,QAAQ,WAAW,GAAG;AAC/B,qBAAS,MAAM;AACf,kBAAM,IAAI,MAAM,MAAM;AAAA,UACxB;AAEA,mBAAS,MAAM;AACf;AAAA,YACE,OAAO,OAAO,IAAI,CAAC,OAAO,EAAE,UAAU,EAAE,KAAK,UAAU,OAAO,EAAE,QAAQ;AAAA;AAAA,QAE5E;AAEA,eAAO,OAAO;AAAA,MAChB,SAAS,KAAK;AACZ,cAAM,MAAM,eAAe,QAAQ,IAAI,UAAU;AACjD,iBAAS,GAAG;AACZ,cAAM;AAAA,MACR,UAAA;AACE,eAAO,UAAU;AACjB,uBAAe,KAAK;AACpB,oBAAY,IAAI;AAAA,MAClB;AAAA,IACF;AAAA,IACA,CAAC,YAAY,QAAQ,gBAAgB;AAAA,EAAA;AAGvC,SAAO,EAAE,QAAQ,aAAa,UAAU,OAAO,WAAA;AACjD;"}
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+ var _a, _b;
6
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
7
+ const AthenaApiErrorKind = {
8
+ /** Agora answered with an error status (4xx or 5xx). */
9
+ Http: "http",
10
+ /** Agora answered a GraphQL operation with errors (a refused read, an invalid query), or with no data. */
11
+ GraphQL: "graphql",
12
+ /** No answer came: offline, a refused CORS preflight, a dropped connection. */
13
+ Network: "network",
14
+ /** No answer came within the request's `timeoutMs`, so the SDK abandoned it. */
15
+ Timeout: "timeout",
16
+ /** The provider could not resolve a credential: its `getToken` threw. */
17
+ Credential: "credential",
18
+ /** The answer could not be read: not the JSON it said it was, or cut off. */
19
+ Response: "response",
20
+ /** The SDK refused to send the request (the message says why). */
21
+ Request: "request"
22
+ };
23
+ const ATHENA_API_ERROR = Symbol.for("athena-sdk.AthenaApiError");
24
+ class AthenaApiError extends (_b = Error, _a = ATHENA_API_ERROR, _b) {
25
+ constructor(options) {
26
+ super(options.message, options.cause === void 0 ? void 0 : { cause: options.cause });
27
+ __publicField(this, _a, true);
28
+ __publicField(this, "kind");
29
+ /**
30
+ * The HTTP status agora answered with: a GraphQL error answered with 200 says
31
+ * 200. `0` when no answer came (`network`, `timeout`, `credential`,
32
+ * `request`).
33
+ */
34
+ __publicField(this, "status");
35
+ /**
36
+ * Agora's machine-readable code: the first GraphQL error's
37
+ * `extensions.code`, or a REST error's `detail.code`. `null` when it gave
38
+ * none.
39
+ */
40
+ __publicField(this, "code");
41
+ /** Every GraphQL error of the answer; empty for other failures. */
42
+ __publicField(this, "errors");
43
+ /** A REST error's `detail` (FastAPI's envelope), else its body as read; `undefined` when there was none. */
44
+ __publicField(this, "detail");
45
+ /**
46
+ * How long agora asked the caller to wait before trying again (`Retry-After`,
47
+ * or the `retryAfterSeconds` of a rate-limit refusal), in ms; `null` when it
48
+ * did not say.
49
+ */
50
+ __publicField(this, "retryAfterMs");
51
+ /** The request's method. */
52
+ __publicField(this, "method");
53
+ /** The request's path, without its query string. */
54
+ __publicField(this, "path");
55
+ this.name = "AthenaApiError";
56
+ this.kind = options.kind;
57
+ this.status = options.status ?? 0;
58
+ this.code = options.code ?? null;
59
+ this.errors = options.errors ?? [];
60
+ this.detail = options.detail;
61
+ this.retryAfterMs = options.retryAfterMs ?? null;
62
+ this.method = options.method;
63
+ this.path = options.path;
64
+ }
65
+ toJSON() {
66
+ return {
67
+ name: this.name,
68
+ kind: this.kind,
69
+ status: this.status,
70
+ code: this.code,
71
+ message: this.message,
72
+ errors: this.errors,
73
+ detail: this.detail,
74
+ retryAfterMs: this.retryAfterMs,
75
+ method: this.method,
76
+ path: this.path
77
+ };
78
+ }
79
+ }
80
+ function isAthenaApiError(value) {
81
+ return value instanceof AthenaApiError || typeof value === "object" && value !== null && Reflect.get(value, ATHENA_API_ERROR) === true;
82
+ }
83
+ function isRecord(value) {
84
+ return typeof value === "object" && value !== null && !Array.isArray(value);
85
+ }
86
+ function graphQLErrorEntries(body) {
87
+ const errors = isRecord(body) ? body.errors : void 0;
88
+ if (!Array.isArray(errors)) return [];
89
+ return errors.flatMap((entry) => {
90
+ if (!isRecord(entry) || typeof entry.message !== "string") return [];
91
+ const path = Array.isArray(entry.path) ? entry.path.filter((part) => typeof part === "string" || typeof part === "number") : void 0;
92
+ return [
93
+ {
94
+ message: entry.message,
95
+ ...path ? { path } : {},
96
+ ...isRecord(entry.extensions) ? { extensions: entry.extensions } : {}
97
+ }
98
+ ];
99
+ });
100
+ }
101
+ function graphQLErrorCode(entry) {
102
+ var _a2;
103
+ const code = (_a2 = entry == null ? void 0 : entry.extensions) == null ? void 0 : _a2.code;
104
+ return typeof code === "string" ? code : null;
105
+ }
106
+ function restErrorDetail(body) {
107
+ const detail = isRecord(body) && "detail" in body ? body.detail : body;
108
+ if (typeof detail === "string") {
109
+ return { detail, code: null, message: detail || null, retryAfterSeconds: null };
110
+ }
111
+ if (!isRecord(detail)) return { detail, code: null, message: null, retryAfterSeconds: null };
112
+ return {
113
+ detail,
114
+ code: typeof detail.code === "string" ? detail.code : null,
115
+ message: typeof detail.message === "string" ? detail.message : null,
116
+ retryAfterSeconds: typeof detail.retryAfterSeconds === "number" && Number.isFinite(detail.retryAfterSeconds) ? detail.retryAfterSeconds : null
117
+ };
118
+ }
119
+ exports.AthenaApiError = AthenaApiError;
120
+ exports.AthenaApiErrorKind = AthenaApiErrorKind;
121
+ exports.graphQLErrorCode = graphQLErrorCode;
122
+ exports.graphQLErrorEntries = graphQLErrorEntries;
123
+ exports.isAthenaApiError = isAthenaApiError;
124
+ exports.restErrorDetail = restErrorDetail;
125
+ //# sourceMappingURL=athena-api-error.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"athena-api-error.cjs","sources":["../../src/data/athena-api-error.ts"],"sourcesContent":["/**\n * What the SDK's data layer throws (`useAthenaFetch`, `useAthenaGraphQL`,\n * `useAthenaGraphQLMutation`, `useAthenaRest`, `useSemanticQuery`): one typed\n * error that says how a request failed (`kind`), with the HTTP status, agora's\n * machine-readable code and its message. A request its caller cancelled is the\n * one exception: it rejects with the abort's own reason, as `fetch` does.\n */\n\n/** How a request failed. */\nexport const AthenaApiErrorKind = {\n /** Agora answered with an error status (4xx or 5xx). */\n Http: 'http',\n /** Agora answered a GraphQL operation with errors (a refused read, an invalid query), or with no data. */\n GraphQL: 'graphql',\n /** No answer came: offline, a refused CORS preflight, a dropped connection. */\n Network: 'network',\n /** No answer came within the request's `timeoutMs`, so the SDK abandoned it. */\n Timeout: 'timeout',\n /** The provider could not resolve a credential: its `getToken` threw. */\n Credential: 'credential',\n /** The answer could not be read: not the JSON it said it was, or cut off. */\n Response: 'response',\n /** The SDK refused to send the request (the message says why). */\n Request: 'request',\n} as const;\nexport type AthenaApiErrorKind = (typeof AthenaApiErrorKind)[keyof typeof AthenaApiErrorKind];\n\n/** One entry of a GraphQL answer's `errors`. */\nexport interface AthenaGraphQLErrorEntry {\n message: string;\n path?: readonly (string | number)[];\n /** Agora puts its `code` here (`UNAUTHORIZED`, `BAD_USER_INPUT`, `RATE_LIMITED`…). */\n extensions?: Readonly<Record<string, unknown>>;\n}\n\nexport interface AthenaApiErrorOptions {\n kind: AthenaApiErrorKind;\n message: string;\n /** The HTTP status agora answered with; `0` (the default) when no answer came. */\n status?: number;\n code?: string | null;\n errors?: readonly AthenaGraphQLErrorEntry[];\n detail?: unknown;\n retryAfterMs?: number | null;\n method: string;\n path: string;\n cause?: unknown;\n}\n\n/** Marks an `AthenaApiError` across copies of the SDK (a host bundling two builds). */\nconst ATHENA_API_ERROR: unique symbol = Symbol.for('athena-sdk.AthenaApiError');\n\nexport class AthenaApiError extends Error {\n readonly [ATHENA_API_ERROR] = true;\n readonly kind: AthenaApiErrorKind;\n /**\n * The HTTP status agora answered with: a GraphQL error answered with 200 says\n * 200. `0` when no answer came (`network`, `timeout`, `credential`,\n * `request`).\n */\n readonly status: number;\n /**\n * Agora's machine-readable code: the first GraphQL error's\n * `extensions.code`, or a REST error's `detail.code`. `null` when it gave\n * none.\n */\n readonly code: string | null;\n /** Every GraphQL error of the answer; empty for other failures. */\n readonly errors: readonly AthenaGraphQLErrorEntry[];\n /** A REST error's `detail` (FastAPI's envelope), else its body as read; `undefined` when there was none. */\n readonly detail: unknown;\n /**\n * How long agora asked the caller to wait before trying again (`Retry-After`,\n * or the `retryAfterSeconds` of a rate-limit refusal), in ms; `null` when it\n * did not say.\n */\n readonly retryAfterMs: number | null;\n /** The request's method. */\n readonly method: string;\n /** The request's path, without its query string. */\n readonly path: string;\n\n constructor(options: AthenaApiErrorOptions) {\n super(options.message, options.cause === undefined ? undefined : { cause: options.cause });\n this.name = 'AthenaApiError';\n this.kind = options.kind;\n this.status = options.status ?? 0;\n this.code = options.code ?? null;\n this.errors = options.errors ?? [];\n this.detail = options.detail;\n this.retryAfterMs = options.retryAfterMs ?? null;\n this.method = options.method;\n this.path = options.path;\n }\n\n toJSON(): Record<string, unknown> {\n return {\n name: this.name,\n kind: this.kind,\n status: this.status,\n code: this.code,\n message: this.message,\n errors: this.errors,\n detail: this.detail,\n retryAfterMs: this.retryAfterMs,\n method: this.method,\n path: this.path,\n };\n }\n}\n\n/** Whether `value` is an `AthenaApiError`, from this copy of the SDK or another. */\nexport function isAthenaApiError(value: unknown): value is AthenaApiError {\n return (\n value instanceof AthenaApiError ||\n (typeof value === 'object' && value !== null && Reflect.get(value, ATHENA_API_ERROR) === true)\n );\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n/** The `errors` of a GraphQL answer, read leniently: entries without a string message are dropped. */\nexport function graphQLErrorEntries(body: unknown): AthenaGraphQLErrorEntry[] {\n const errors = isRecord(body) ? body.errors : undefined;\n if (!Array.isArray(errors)) return [];\n return errors.flatMap((entry): AthenaGraphQLErrorEntry[] => {\n if (!isRecord(entry) || typeof entry.message !== 'string') return [];\n const path = Array.isArray(entry.path)\n ? entry.path.filter((part): part is string | number => typeof part === 'string' || typeof part === 'number')\n : undefined;\n return [\n {\n message: entry.message,\n ...(path ? { path } : {}),\n ...(isRecord(entry.extensions) ? { extensions: entry.extensions } : {}),\n },\n ];\n });\n}\n\n/** The string `extensions.code` of a GraphQL error, if it has one. */\nexport function graphQLErrorCode(entry: AthenaGraphQLErrorEntry | undefined): string | null {\n const code = entry?.extensions?.code;\n return typeof code === 'string' ? code : null;\n}\n\n/**\n * What a REST error body says: FastAPI's `{ detail }` envelope, whose detail\n * is a string or agora's structured `{ code, message, retryAfterSeconds }`.\n */\nexport function restErrorDetail(body: unknown): {\n detail: unknown;\n code: string | null;\n message: string | null;\n retryAfterSeconds: number | null;\n} {\n const detail = isRecord(body) && 'detail' in body ? body.detail : body;\n if (typeof detail === 'string') {\n return { detail, code: null, message: detail || null, retryAfterSeconds: null };\n }\n if (!isRecord(detail)) return { detail, code: null, message: null, retryAfterSeconds: null };\n return {\n detail,\n code: typeof detail.code === 'string' ? detail.code : null,\n message: typeof detail.message === 'string' ? detail.message : null,\n retryAfterSeconds:\n typeof detail.retryAfterSeconds === 'number' && Number.isFinite(detail.retryAfterSeconds)\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AAO,SAAS,WAAW,OAAO,OAAO;AAAA,IACtD,SAAS,OAAO,OAAO,YAAY,WAAW,OAAO,UAAU;AAAA,IAC/D,mBACE,OAAO,OAAO,sBAAsB,YAAY,OAAO,SAAS,OAAO,iBAAiB,IACpF,OAAO,oBACP;AAAA,EAAA;AAEV;;;;;;;"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * What the SDK's data layer throws (`useAthenaFetch`, `useAthenaGraphQL`,
3
+ * `useAthenaGraphQLMutation`, `useAthenaRest`, `useSemanticQuery`): one typed
4
+ * error that says how a request failed (`kind`), with the HTTP status, agora's
5
+ * machine-readable code and its message. A request its caller cancelled is the
6
+ * one exception: it rejects with the abort's own reason, as `fetch` does.
7
+ */
8
+ /** How a request failed. */
9
+ export declare const AthenaApiErrorKind: {
10
+ /** Agora answered with an error status (4xx or 5xx). */
11
+ readonly Http: 'http';
12
+ /** Agora answered a GraphQL operation with errors (a refused read, an invalid query), or with no data. */
13
+ readonly GraphQL: 'graphql';
14
+ /** No answer came: offline, a refused CORS preflight, a dropped connection. */
15
+ readonly Network: 'network';
16
+ /** No answer came within the request's `timeoutMs`, so the SDK abandoned it. */
17
+ readonly Timeout: 'timeout';
18
+ /** The provider could not resolve a credential: its `getToken` threw. */
19
+ readonly Credential: 'credential';
20
+ /** The answer could not be read: not the JSON it said it was, or cut off. */
21
+ readonly Response: 'response';
22
+ /** The SDK refused to send the request (the message says why). */
23
+ readonly Request: 'request';
24
+ };
25
+ export type AthenaApiErrorKind = (typeof AthenaApiErrorKind)[keyof typeof AthenaApiErrorKind];
26
+ /** One entry of a GraphQL answer's `errors`. */
27
+ export interface AthenaGraphQLErrorEntry {
28
+ message: string;
29
+ path?: readonly (string | number)[];
30
+ /** Agora puts its `code` here (`UNAUTHORIZED`, `BAD_USER_INPUT`, `RATE_LIMITED`…). */
31
+ extensions?: Readonly<Record<string, unknown>>;
32
+ }
33
+ export interface AthenaApiErrorOptions {
34
+ kind: AthenaApiErrorKind;
35
+ message: string;
36
+ /** The HTTP status agora answered with; `0` (the default) when no answer came. */
37
+ status?: number;
38
+ code?: string | null;
39
+ errors?: readonly AthenaGraphQLErrorEntry[];
40
+ detail?: unknown;
41
+ retryAfterMs?: number | null;
42
+ method: string;
43
+ path: string;
44
+ cause?: unknown;
45
+ }
46
+ /** Marks an `AthenaApiError` across copies of the SDK (a host bundling two builds). */
47
+ declare const ATHENA_API_ERROR: unique symbol;
48
+ export declare class AthenaApiError extends Error {
49
+ readonly [ATHENA_API_ERROR] = true;
50
+ readonly kind: AthenaApiErrorKind;
51
+ /**
52
+ * The HTTP status agora answered with: a GraphQL error answered with 200 says
53
+ * 200. `0` when no answer came (`network`, `timeout`, `credential`,
54
+ * `request`).
55
+ */
56
+ readonly status: number;
57
+ /**
58
+ * Agora's machine-readable code: the first GraphQL error's
59
+ * `extensions.code`, or a REST error's `detail.code`. `null` when it gave
60
+ * none.
61
+ */
62
+ readonly code: string | null;
63
+ /** Every GraphQL error of the answer; empty for other failures. */
64
+ readonly errors: readonly AthenaGraphQLErrorEntry[];
65
+ /** A REST error's `detail` (FastAPI's envelope), else its body as read; `undefined` when there was none. */
66
+ readonly detail: unknown;
67
+ /**
68
+ * How long agora asked the caller to wait before trying again (`Retry-After`,
69
+ * or the `retryAfterSeconds` of a rate-limit refusal), in ms; `null` when it
70
+ * did not say.
71
+ */
72
+ readonly retryAfterMs: number | null;
73
+ /** The request's method. */
74
+ readonly method: string;
75
+ /** The request's path, without its query string. */
76
+ readonly path: string;
77
+ constructor(options: AthenaApiErrorOptions);
78
+ toJSON(): Record<string, unknown>;
79
+ }
80
+ /** Whether `value` is an `AthenaApiError`, from this copy of the SDK or another. */
81
+ export declare function isAthenaApiError(value: unknown): value is AthenaApiError;
82
+ /** The `errors` of a GraphQL answer, read leniently: entries without a string message are dropped. */
83
+ export declare function graphQLErrorEntries(body: unknown): AthenaGraphQLErrorEntry[];
84
+ /** The string `extensions.code` of a GraphQL error, if it has one. */
85
+ export declare function graphQLErrorCode(entry: AthenaGraphQLErrorEntry | undefined): string | null;
86
+ /**
87
+ * What a REST error body says: FastAPI's `{ detail }` envelope, whose detail
88
+ * is a string or agora's structured `{ code, message, retryAfterSeconds }`.
89
+ */
90
+ export declare function restErrorDetail(body: unknown): {
91
+ detail: unknown;
92
+ code: string | null;
93
+ message: string | null;
94
+ retryAfterSeconds: number | null;
95
+ };
96
+ export {};
@@ -0,0 +1,125 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+ var _a, _b;
5
+ const AthenaApiErrorKind = {
6
+ /** Agora answered with an error status (4xx or 5xx). */
7
+ Http: "http",
8
+ /** Agora answered a GraphQL operation with errors (a refused read, an invalid query), or with no data. */
9
+ GraphQL: "graphql",
10
+ /** No answer came: offline, a refused CORS preflight, a dropped connection. */
11
+ Network: "network",
12
+ /** No answer came within the request's `timeoutMs`, so the SDK abandoned it. */
13
+ Timeout: "timeout",
14
+ /** The provider could not resolve a credential: its `getToken` threw. */
15
+ Credential: "credential",
16
+ /** The answer could not be read: not the JSON it said it was, or cut off. */
17
+ Response: "response",
18
+ /** The SDK refused to send the request (the message says why). */
19
+ Request: "request"
20
+ };
21
+ const ATHENA_API_ERROR = Symbol.for("athena-sdk.AthenaApiError");
22
+ class AthenaApiError extends (_b = Error, _a = ATHENA_API_ERROR, _b) {
23
+ constructor(options) {
24
+ super(options.message, options.cause === void 0 ? void 0 : { cause: options.cause });
25
+ __publicField(this, _a, true);
26
+ __publicField(this, "kind");
27
+ /**
28
+ * The HTTP status agora answered with: a GraphQL error answered with 200 says
29
+ * 200. `0` when no answer came (`network`, `timeout`, `credential`,
30
+ * `request`).
31
+ */
32
+ __publicField(this, "status");
33
+ /**
34
+ * Agora's machine-readable code: the first GraphQL error's
35
+ * `extensions.code`, or a REST error's `detail.code`. `null` when it gave
36
+ * none.
37
+ */
38
+ __publicField(this, "code");
39
+ /** Every GraphQL error of the answer; empty for other failures. */
40
+ __publicField(this, "errors");
41
+ /** A REST error's `detail` (FastAPI's envelope), else its body as read; `undefined` when there was none. */
42
+ __publicField(this, "detail");
43
+ /**
44
+ * How long agora asked the caller to wait before trying again (`Retry-After`,
45
+ * or the `retryAfterSeconds` of a rate-limit refusal), in ms; `null` when it
46
+ * did not say.
47
+ */
48
+ __publicField(this, "retryAfterMs");
49
+ /** The request's method. */
50
+ __publicField(this, "method");
51
+ /** The request's path, without its query string. */
52
+ __publicField(this, "path");
53
+ this.name = "AthenaApiError";
54
+ this.kind = options.kind;
55
+ this.status = options.status ?? 0;
56
+ this.code = options.code ?? null;
57
+ this.errors = options.errors ?? [];
58
+ this.detail = options.detail;
59
+ this.retryAfterMs = options.retryAfterMs ?? null;
60
+ this.method = options.method;
61
+ this.path = options.path;
62
+ }
63
+ toJSON() {
64
+ return {
65
+ name: this.name,
66
+ kind: this.kind,
67
+ status: this.status,
68
+ code: this.code,
69
+ message: this.message,
70
+ errors: this.errors,
71
+ detail: this.detail,
72
+ retryAfterMs: this.retryAfterMs,
73
+ method: this.method,
74
+ path: this.path
75
+ };
76
+ }
77
+ }
78
+ function isAthenaApiError(value) {
79
+ return value instanceof AthenaApiError || typeof value === "object" && value !== null && Reflect.get(value, ATHENA_API_ERROR) === true;
80
+ }
81
+ function isRecord(value) {
82
+ return typeof value === "object" && value !== null && !Array.isArray(value);
83
+ }
84
+ function graphQLErrorEntries(body) {
85
+ const errors = isRecord(body) ? body.errors : void 0;
86
+ if (!Array.isArray(errors)) return [];
87
+ return errors.flatMap((entry) => {
88
+ if (!isRecord(entry) || typeof entry.message !== "string") return [];
89
+ const path = Array.isArray(entry.path) ? entry.path.filter((part) => typeof part === "string" || typeof part === "number") : void 0;
90
+ return [
91
+ {
92
+ message: entry.message,
93
+ ...path ? { path } : {},
94
+ ...isRecord(entry.extensions) ? { extensions: entry.extensions } : {}
95
+ }
96
+ ];
97
+ });
98
+ }
99
+ function graphQLErrorCode(entry) {
100
+ var _a2;
101
+ const code = (_a2 = entry == null ? void 0 : entry.extensions) == null ? void 0 : _a2.code;
102
+ return typeof code === "string" ? code : null;
103
+ }
104
+ function restErrorDetail(body) {
105
+ const detail = isRecord(body) && "detail" in body ? body.detail : body;
106
+ if (typeof detail === "string") {
107
+ return { detail, code: null, message: detail || null, retryAfterSeconds: null };
108
+ }
109
+ if (!isRecord(detail)) return { detail, code: null, message: null, retryAfterSeconds: null };
110
+ return {
111
+ detail,
112
+ code: typeof detail.code === "string" ? detail.code : null,
113
+ message: typeof detail.message === "string" ? detail.message : null,
114
+ retryAfterSeconds: typeof detail.retryAfterSeconds === "number" && Number.isFinite(detail.retryAfterSeconds) ? detail.retryAfterSeconds : null
115
+ };
116
+ }
117
+ export {
118
+ AthenaApiError,
119
+ AthenaApiErrorKind,
120
+ graphQLErrorCode,
121
+ graphQLErrorEntries,
122
+ isAthenaApiError,
123
+ restErrorDetail
124
+ };
125
+ //# sourceMappingURL=athena-api-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"athena-api-error.js","sources":["../../src/data/athena-api-error.ts"],"sourcesContent":["/**\n * What the SDK's data layer throws (`useAthenaFetch`, `useAthenaGraphQL`,\n * `useAthenaGraphQLMutation`, `useAthenaRest`, `useSemanticQuery`): one typed\n * error that says how a request failed (`kind`), with the HTTP status, agora's\n * machine-readable code and its message. A request its caller cancelled is the\n * one exception: it rejects with the abort's own reason, as `fetch` does.\n */\n\n/** How a request failed. */\nexport const AthenaApiErrorKind = {\n /** Agora answered with an error status (4xx or 5xx). */\n Http: 'http',\n /** Agora answered a GraphQL operation with errors (a refused read, an invalid query), or with no data. */\n GraphQL: 'graphql',\n /** No answer came: offline, a refused CORS preflight, a dropped connection. */\n Network: 'network',\n /** No answer came within the request's `timeoutMs`, so the SDK abandoned it. */\n Timeout: 'timeout',\n /** The provider could not resolve a credential: its `getToken` threw. */\n Credential: 'credential',\n /** The answer could not be read: not the JSON it said it was, or cut off. */\n Response: 'response',\n /** The SDK refused to send the request (the message says why). */\n Request: 'request',\n} as const;\nexport type AthenaApiErrorKind = (typeof AthenaApiErrorKind)[keyof typeof AthenaApiErrorKind];\n\n/** One entry of a GraphQL answer's `errors`. */\nexport interface AthenaGraphQLErrorEntry {\n message: string;\n path?: readonly (string | number)[];\n /** Agora puts its `code` here (`UNAUTHORIZED`, `BAD_USER_INPUT`, `RATE_LIMITED`…). */\n extensions?: Readonly<Record<string, unknown>>;\n}\n\nexport interface AthenaApiErrorOptions {\n kind: AthenaApiErrorKind;\n message: string;\n /** The HTTP status agora answered with; `0` (the default) when no answer came. */\n status?: number;\n code?: string | null;\n errors?: readonly AthenaGraphQLErrorEntry[];\n detail?: unknown;\n retryAfterMs?: number | null;\n method: string;\n path: string;\n cause?: unknown;\n}\n\n/** Marks an `AthenaApiError` across copies of the SDK (a host bundling two builds). */\nconst ATHENA_API_ERROR: unique symbol = Symbol.for('athena-sdk.AthenaApiError');\n\nexport class AthenaApiError extends Error {\n readonly [ATHENA_API_ERROR] = true;\n readonly kind: AthenaApiErrorKind;\n /**\n * The HTTP status agora answered with: a GraphQL error answered with 200 says\n * 200. `0` when no answer came (`network`, `timeout`, `credential`,\n * `request`).\n */\n readonly status: number;\n /**\n * Agora's machine-readable code: the first GraphQL error's\n * `extensions.code`, or a REST error's `detail.code`. `null` when it gave\n * none.\n */\n readonly code: string | null;\n /** Every GraphQL error of the answer; empty for other failures. */\n readonly errors: readonly AthenaGraphQLErrorEntry[];\n /** A REST error's `detail` (FastAPI's envelope), else its body as read; `undefined` when there was none. */\n readonly detail: unknown;\n /**\n * How long agora asked the caller to wait before trying again (`Retry-After`,\n * or the `retryAfterSeconds` of a rate-limit refusal), in ms; `null` when it\n * did not say.\n */\n readonly retryAfterMs: number | null;\n /** The request's method. */\n readonly method: string;\n /** The request's path, without its query string. */\n readonly path: string;\n\n constructor(options: AthenaApiErrorOptions) {\n super(options.message, options.cause === undefined ? undefined : { cause: options.cause });\n this.name = 'AthenaApiError';\n this.kind = options.kind;\n this.status = options.status ?? 0;\n this.code = options.code ?? null;\n this.errors = options.errors ?? [];\n this.detail = options.detail;\n this.retryAfterMs = options.retryAfterMs ?? null;\n this.method = options.method;\n this.path = options.path;\n }\n\n toJSON(): Record<string, unknown> {\n return {\n name: this.name,\n kind: this.kind,\n status: this.status,\n code: this.code,\n message: this.message,\n errors: this.errors,\n detail: this.detail,\n retryAfterMs: this.retryAfterMs,\n method: this.method,\n path: this.path,\n };\n }\n}\n\n/** Whether `value` is an `AthenaApiError`, from this copy of the SDK or another. */\nexport function isAthenaApiError(value: unknown): value is AthenaApiError {\n return (\n value instanceof AthenaApiError ||\n (typeof value === 'object' && value !== null && Reflect.get(value, ATHENA_API_ERROR) === true)\n );\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n/** The `errors` of a GraphQL answer, read leniently: entries without a string message are dropped. */\nexport function graphQLErrorEntries(body: unknown): AthenaGraphQLErrorEntry[] {\n const errors = isRecord(body) ? body.errors : undefined;\n if (!Array.isArray(errors)) return [];\n return errors.flatMap((entry): AthenaGraphQLErrorEntry[] => {\n if (!isRecord(entry) || typeof entry.message !== 'string') return [];\n const path = Array.isArray(entry.path)\n ? entry.path.filter((part): part is string | number => typeof part === 'string' || typeof part === 'number')\n : undefined;\n return [\n {\n message: entry.message,\n ...(path ? { path } : {}),\n ...(isRecord(entry.extensions) ? { extensions: entry.extensions } : {}),\n },\n ];\n });\n}\n\n/** The string `extensions.code` of a GraphQL error, if it has one. */\nexport function graphQLErrorCode(entry: AthenaGraphQLErrorEntry | undefined): string | null {\n const code = entry?.extensions?.code;\n return typeof code === 'string' ? code : null;\n}\n\n/**\n * What a REST error body says: FastAPI's `{ detail }` envelope, whose detail\n * is a string or agora's structured `{ code, message, retryAfterSeconds }`.\n */\nexport function restErrorDetail(body: unknown): {\n detail: unknown;\n code: string | null;\n message: string | null;\n retryAfterSeconds: number | null;\n} {\n const detail = isRecord(body) && 'detail' in body ? body.detail : body;\n if (typeof detail === 'string') {\n return { detail, code: null, message: detail || null, retryAfterSeconds: null };\n }\n if (!isRecord(detail)) return { detail, code: null, message: null, retryAfterSeconds: null };\n return {\n detail,\n code: typeof detail.code === 'string' ? detail.code : null,\n message: typeof detail.message === 'string' ? detail.message : null,\n retryAfterSeconds:\n typeof detail.retryAfterSeconds === 'number' && Number.isFinite(detail.retryAfterSeconds)\n ? detail.retryAfterSeconds\n : null,\n };\n}\n"],"names":["_a"],"mappings":";;;AASO;AAAA,MAAM,qBAAqB;AAAA;AAAA,EAEhC,MAAM;AAAA;AAAA,EAEN,SAAS;AAAA;AAAA,EAET,SAAS;AAAA;AAAA,EAET,SAAS;AAAA;AAAA,EAET,YAAY;AAAA;AAAA,EAEZ,UAAU;AAAA;AAAA,EAEV,SAAS;AACX;AA0BA,MAAM,mBAAkC,OAAO,IAAI,2BAA2B;AAEvE,MAAM,wBAAuB,YACxB,uBADwB,IAAM;AAAA,EA8BxC,YAAY,SAAgC;AAC1C,UAAM,QAAQ,SAAS,QAAQ,UAAU,SAAY,SAAY,EAAE,OAAO,QAAQ,MAAA,CAAO;AA9B3F,wBAAU,IAAoB;AACrB;AAMA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA;AAAA;AAEA;AAAA;AAMA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA;AAAA;AAEA;AAAA;AAIP,SAAK,OAAO;AACZ,SAAK,OAAO,QAAQ;AACpB,SAAK,SAAS,QAAQ,UAAU;AAChC,SAAK,OAAO,QAAQ,QAAQ;AAC5B,SAAK,SAAS,QAAQ,UAAU,CAAA;AAChC,SAAK,SAAS,QAAQ;AACtB,SAAK,eAAe,QAAQ,gBAAgB;AAC5C,SAAK,SAAS,QAAQ;AACtB,SAAK,OAAO,QAAQ;AAAA,EACtB;AAA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C3C;AAMO,SAAS,gBAAgB,MAK9B;AACA,QAAM,SAAS,SAAS,IAAI,KAAK,YAAY,OAAO,KAAK,SAAS;AAClE,MAAI,OAAO,WAAW,UAAU;AAC9B,WAAO,EAAE,QAAQ,MAAM,MAAM,SAAS,UAAU,MAAM,mBAAmB,KAAA;AAAA,EAC3E;AACA,MAAI,CAAC,SAAS,MAAM,EAAG,QAAO,EAAE,QAAQ,MAAM,MAAM,SAAS,MAAM,mBAAmB,KAAA;AACtF,SAAO;AAAA,IACL;AAAA,IACA,MAAM,OAAO,OAAO,SAAS,WAAW,OAAO,OAAO;AAAA,IACtD,SAAS,OAAO,OAAO,YAAY,WAAW,OAAO,UAAU;AAAA,IAC/D,mBACE,OAAO,OAAO,sBAAsB,YAAY,OAAO,SAAS,OAAO,iBAAiB,IACpF,OAAO,oBACP;AAAA,EAAA;AAEV;"}
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const reactQuery = require("@tanstack/react-query");
5
+ const require$$0 = require("react");
6
+ const accountIdentity = require("../auth/account-identity.cjs");
7
+ const AthenaAuthContext = require("../auth/AthenaAuthContext.cjs");
8
+ const AthenaCredentialSourceContext = require("../auth/AthenaCredentialSourceContext.cjs");
9
+ const AthenaContext = require("../provider/AthenaContext.cjs");
10
+ const athenaApiError = require("./athena-api-error.cjs");
11
+ const athenaRequest = require("./athena-request.cjs");
12
+ const AthenaDataQueryClientContext = require$$0.createContext(null);
13
+ function AthenaDataQueryClientProvider({ children }) {
14
+ const [client] = require$$0.useState(() => new reactQuery.QueryClient());
15
+ require$$0.useEffect(() => {
16
+ client.mount();
17
+ return () => client.unmount();
18
+ }, [client]);
19
+ return /* @__PURE__ */ jsxRuntime.jsx(AthenaDataQueryClientContext.Provider, { value: client, children });
20
+ }
21
+ function useAthenaDataQueryClient() {
22
+ const own = require$$0.useContext(AthenaDataQueryClientContext);
23
+ const inContext = require$$0.useContext(reactQuery.QueryClientContext);
24
+ const fallback = require$$0.useRef(null);
25
+ if (own) return own;
26
+ if (inContext) return inContext;
27
+ fallback.current ?? (fallback.current = new reactQuery.QueryClient());
28
+ return fallback.current;
29
+ }
30
+ const AthenaDataKind = {
31
+ GraphQL: "graphql",
32
+ Rest: "rest",
33
+ SemanticQuery: "semantic-query"
34
+ };
35
+ function useAthenaDataScope() {
36
+ var _a, _b;
37
+ const { backendUrl, apiKey, token } = AthenaContext.useAthenaConfig();
38
+ const principal = ((_b = (_a = require$$0.useContext(AthenaAuthContext.AthenaAuthContext)) == null ? void 0 : _a.user) == null ? void 0 : _b.userId) ?? "";
39
+ const scopeEpoch = AthenaCredentialSourceContext.useAthenaCredentialScopeEpoch();
40
+ const [apiKeyPart, heldTokenPart] = accountIdentity.credentialKeyParts({ apiKey, heldToken: token });
41
+ return require$$0.useMemo(
42
+ () => ["athena-sdk", "data", backendUrl, principal, apiKeyPart, heldTokenPart, scopeEpoch],
43
+ [backendUrl, principal, apiKeyPart, heldTokenPart, scopeEpoch]
44
+ );
45
+ }
46
+ const ATHENA_DATA_STALE_MS = 3e4;
47
+ const MAX_TRANSIENT_RETRIES = 2;
48
+ const MAX_RETRY_DELAY_MS = 3e4;
49
+ const MAX_HINTED_RETRY_DELAY_MS = 6e4;
50
+ function retryAthenaRead(failureCount, error) {
51
+ if (!athenaApiError.isAthenaApiError(error) || failureCount >= MAX_TRANSIENT_RETRIES) return false;
52
+ if (error.kind === athenaApiError.AthenaApiErrorKind.Network) return true;
53
+ return error.kind === athenaApiError.AthenaApiErrorKind.Http && error.status >= 500;
54
+ }
55
+ function athenaRetryDelay(failureCount, error) {
56
+ if (athenaApiError.isAthenaApiError(error) && error.retryAfterMs !== null) {
57
+ return Math.min(error.retryAfterMs, MAX_HINTED_RETRY_DELAY_MS);
58
+ }
59
+ return Math.min(1e3 * 2 ** failureCount, MAX_RETRY_DELAY_MS);
60
+ }
61
+ function enabledAnd(enabled, ready) {
62
+ if (typeof enabled === "function") return (query) => ready && enabled(query);
63
+ return ready && (enabled ?? true);
64
+ }
65
+ function inScope(queryKey, scope) {
66
+ return scope.every((part, at) => Object.is(queryKey[at], part));
67
+ }
68
+ function matchesFilter(queryKey, scope, filter) {
69
+ var _a;
70
+ if (!filter) return true;
71
+ const kind = queryKey[scope.length];
72
+ const subject = queryKey[scope.length + 1];
73
+ if (typeof subject !== "string") return false;
74
+ if (kind === AthenaDataKind.GraphQL) {
75
+ const operationName = queryKey[scope.length + 3];
76
+ const name = (_a = athenaRequest.selectedGraphQLOperation(subject, typeof operationName === "string" ? operationName : null)) == null ? void 0 : _a.name;
77
+ return typeof name === "string" && (filter.operationNames ?? []).includes(name);
78
+ }
79
+ if (kind === AthenaDataKind.Rest) {
80
+ return (filter.paths ?? []).some((prefix) => subject.startsWith(prefix));
81
+ }
82
+ if (kind === AthenaDataKind.SemanticQuery) {
83
+ return (filter.semanticModelIds ?? []).includes(subject);
84
+ }
85
+ return false;
86
+ }
87
+ function useInvalidateAthenaQueries() {
88
+ const client = useAthenaDataQueryClient();
89
+ const scope = useAthenaDataScope();
90
+ return require$$0.useCallback(
91
+ (filter) => client.invalidateQueries({
92
+ predicate: ({ queryKey }) => inScope(queryKey, scope) && matchesFilter(queryKey, scope, filter)
93
+ }),
94
+ [client, scope]
95
+ );
96
+ }
97
+ exports.ATHENA_DATA_STALE_MS = ATHENA_DATA_STALE_MS;
98
+ exports.AthenaDataKind = AthenaDataKind;
99
+ exports.AthenaDataQueryClientProvider = AthenaDataQueryClientProvider;
100
+ exports.athenaRetryDelay = athenaRetryDelay;
101
+ exports.enabledAnd = enabledAnd;
102
+ exports.retryAthenaRead = retryAthenaRead;
103
+ exports.useAthenaDataQueryClient = useAthenaDataQueryClient;
104
+ exports.useAthenaDataScope = useAthenaDataScope;
105
+ exports.useInvalidateAthenaQueries = useInvalidateAthenaQueries;
106
+ //# sourceMappingURL=athena-data-client.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"athena-data-client.cjs","sources":["../../src/data/athena-data-client.tsx"],"sourcesContent":["/**\n * What every data hook shares: the SDK's own `QueryClient` (one per\n * `AthenaProvider`, so a host needs no `QueryClientProvider` and the hooks\n * never write into a host's cache), the identity every cache key starts with,\n * and the retry rule.\n *\n * Cache isolation: every key starts with the backend, the signed-in person,\n * the credential's fingerprint (the API key's, and who the held token acts as\n * and in which workspace, never the secret) and the provider's credential\n * scope epoch, which moves once a host's `getToken` hands out a token that\n * acts as someone else or is scoped to another workspace or org. A switch of\n * person, key or workspace therefore reads under new keys and never serves the\n * previous identity's answers.\n */\nimport {\n QueryClient,\n QueryClientContext,\n type QueryKey,\n} from '@tanstack/react-query';\nimport {\n createContext,\n type ReactNode,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { credentialKeyParts } from '../auth/account-identity';\nimport { AthenaAuthContext } from '../auth/AthenaAuthContext';\nimport { useAthenaCredentialScopeEpoch } from '../auth/AthenaCredentialSourceContext';\nimport { useAthenaConfig } from '../provider/AthenaContext';\nimport { AthenaApiErrorKind, isAthenaApiError } from './athena-api-error';\nimport { selectedGraphQLOperation } from './athena-request';\n\nconst AthenaDataQueryClientContext = createContext<QueryClient | null>(null);\n\n/**\n * Gives the data hooks under it one `QueryClient` of their own for as long as\n * it is mounted (`AthenaProvider` mounts it). Mounted as `QueryClientProvider`\n * mounts a client, so reads refetch on reconnect and, when asked, on focus.\n */\nexport function AthenaDataQueryClientProvider({ children }: { children: ReactNode }) {\n const [client] = useState(() => new QueryClient());\n useEffect(() => {\n client.mount();\n return () => client.unmount();\n }, [client]);\n return (\n <AthenaDataQueryClientContext.Provider value={client}>{children}</AthenaDataQueryClientContext.Provider>\n );\n}\n\n/**\n * The data hooks' client: the provider's own, else (a provider-less tree, as in\n * a host's tests) a `QueryClient` in context, else one of the calling hook's.\n */\nexport function useAthenaDataQueryClient(): QueryClient {\n const own = useContext(AthenaDataQueryClientContext);\n const inContext = useContext(QueryClientContext);\n const fallback = useRef<QueryClient | null>(null);\n if (own) return own;\n if (inContext) return inContext;\n fallback.current ??= new QueryClient();\n return fallback.current;\n}\n\n/**\n * The first parts of every data key: whose reads they are. After the two tags:\n * the backend, the signed-in person (`''` when the provider knows none), the\n * API key's fingerprint, who the held token acts as and where, and the scope\n * epoch.\n */\nexport type AthenaDataScope = readonly ['athena-sdk', 'data', string, string, string, string, number];\n\n/** What a data key holds after its scope. */\nexport const AthenaDataKind = {\n GraphQL: 'graphql',\n Rest: 'rest',\n SemanticQuery: 'semantic-query',\n} as const;\nexport type AthenaDataKind = (typeof AthenaDataKind)[keyof typeof AthenaDataKind];\n\n/** The scope the provider's reads are cached under now (see the module comment). */\nexport function useAthenaDataScope(): AthenaDataScope {\n const { backendUrl, apiKey, token } = useAthenaConfig();\n const principal = useContext(AthenaAuthContext)?.user?.userId ?? '';\n const scopeEpoch = useAthenaCredentialScopeEpoch();\n const [apiKeyPart, heldTokenPart] = credentialKeyParts({ apiKey, heldToken: token });\n return useMemo(\n () => ['athena-sdk', 'data', backendUrl, principal, apiKeyPart, heldTokenPart, scopeEpoch] as const,\n [backendUrl, principal, apiKeyPart, heldTokenPart, scopeEpoch],\n );\n}\n\n/** How long an answer serves another read of the same thing before agora is asked again. */\nexport const ATHENA_DATA_STALE_MS = 30_000;\n\nconst MAX_TRANSIENT_RETRIES = 2;\nconst MAX_RETRY_DELAY_MS = 30_000;\nconst MAX_HINTED_RETRY_DELAY_MS = 60_000;\n\n/**\n * Whether a failed read is asked again: only what may answer differently a\n * moment later (no answer at all, or a 5xx), twice at most. A 4xx (a 429 the\n * transport already waited out included), a GraphQL error, a timeout, a\n * credential that could not be resolved and an unreadable answer are not.\n */\nexport function retryAthenaRead(failureCount: number, error: unknown): boolean {\n if (!isAthenaApiError(error) || failureCount >= MAX_TRANSIENT_RETRIES) return false;\n if (error.kind === AthenaApiErrorKind.Network) return true;\n return error.kind === AthenaApiErrorKind.Http && error.status >= 500;\n}\n\n/** The wait before asking again: what agora asked for (`Retry-After`), else 1 s, 2 s, 4 s… */\nexport function athenaRetryDelay(failureCount: number, error: unknown): number {\n if (isAthenaApiError(error) && error.retryAfterMs !== null) {\n return Math.min(error.retryAfterMs, MAX_HINTED_RETRY_DELAY_MS);\n }\n return Math.min(1_000 * 2 ** failureCount, MAX_RETRY_DELAY_MS);\n}\n\n/** `enabled` as a host passed it, and also `ready`. */\nexport function enabledAnd<TQuery>(\n enabled: boolean | ((query: TQuery) => boolean) | undefined,\n ready: boolean,\n): boolean | ((query: TQuery) => boolean) {\n if (typeof enabled === 'function') return (query: TQuery) => ready && enabled(query);\n return ready && (enabled ?? true);\n}\n\n/** Which of the current identity's reads to read again; every field is optional, and none means all. */\nexport interface AthenaDataQueryFilter {\n /** GraphQL reads whose operation has one of these names. */\n operationNames?: readonly string[];\n /** REST reads whose path starts with one of these. */\n paths?: readonly string[];\n /** Semantic queries of these models. */\n semanticModelIds?: readonly string[];\n}\n\nfunction inScope(queryKey: QueryKey, scope: AthenaDataScope): boolean {\n return scope.every((part, at) => Object.is(queryKey[at], part));\n}\n\nfunction matchesFilter(\n queryKey: QueryKey,\n scope: AthenaDataScope,\n filter: AthenaDataQueryFilter | undefined,\n): boolean {\n if (!filter) return true;\n const kind = queryKey[scope.length];\n const subject = queryKey[scope.length + 1];\n if (typeof subject !== 'string') return false;\n if (kind === AthenaDataKind.GraphQL) {\n // The operation the read runs: the one its `operationName` names, else its document's only one.\n const operationName = queryKey[scope.length + 3];\n const name = selectedGraphQLOperation(subject, typeof operationName === 'string' ? operationName : null)?.name;\n return typeof name === 'string' && (filter.operationNames ?? []).includes(name);\n }\n if (kind === AthenaDataKind.Rest) {\n return (filter.paths ?? []).some((prefix) => subject.startsWith(prefix));\n }\n if (kind === AthenaDataKind.SemanticQuery) {\n return (filter.semanticModelIds ?? []).includes(subject);\n }\n return false;\n}\n\n/**\n * Answers a function that has the current identity's data reads read again:\n * those `filter` names, or every one without it. Reads on screen are sent at\n * once; the rest read again when next shown. Call it after a write that\n * changes what they answer.\n */\nexport function useInvalidateAthenaQueries(): (filter?: AthenaDataQueryFilter) => Promise<void> {\n const client = useAthenaDataQueryClient();\n const scope = useAthenaDataScope();\n return useCallback(\n (filter?: AthenaDataQueryFilter) =>\n client.invalidateQueries({\n predicate: ({ queryKey }) => inScope(queryKey, scope) && matchesFilter(queryKey, scope, filter),\n }),\n [client, scope],\n );\n}\n"],"names":["createContext","useState","QueryClient","useEffect","useContext","QueryClientContext","useRef","useAthenaConfig","AthenaAuthContext","useAthenaCredentialScopeEpoch","credentialKeyParts","useMemo","isAthenaApiError","AthenaApiErrorKind","selectedGraphQLOperation","useCallback"],"mappings":";;;;;;;;;;;AAoCA,MAAM,+BAA+BA,WAAAA,cAAkC,IAAI;AAOpE,SAAS,8BAA8B,EAAE,YAAqC;AACnF,QAAM,CAAC,MAAM,IAAIC,WAAAA,SAAS,MAAM,IAAIC,WAAAA,aAAa;AACjDC,aAAAA,UAAU,MAAM;AACd,WAAO,MAAA;AACP,WAAO,MAAM,OAAO,QAAA;AAAA,EACtB,GAAG,CAAC,MAAM,CAAC;AACX,wCACG,6BAA6B,UAA7B,EAAsC,OAAO,QAAS,UAAS;AAEpE;AAMO,SAAS,2BAAwC;AACtD,QAAM,MAAMC,WAAAA,WAAW,4BAA4B;AACnD,QAAM,YAAYA,WAAAA,WAAWC,6BAAkB;AAC/C,QAAM,WAAWC,WAAAA,OAA2B,IAAI;AAChD,MAAI,IAAK,QAAO;AAChB,MAAI,UAAW,QAAO;AACtB,WAAS,YAAT,SAAS,UAAY,IAAIJ,uBAAA;AACzB,SAAO,SAAS;AAClB;AAWO,MAAM,iBAAiB;AAAA,EAC5B,SAAS;AAAA,EACT,MAAM;AAAA,EACN,eAAe;AACjB;AAIO,SAAS,qBAAsC;;AACpD,QAAM,EAAE,YAAY,QAAQ,MAAA,IAAUK,cAAAA,gBAAA;AACtC,QAAM,cAAYH,sBAAAA,WAAWI,kBAAAA,iBAAiB,MAA5BJ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