@athenaintel/react 0.43.0 → 0.48.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 (661) hide show
  1. package/README.md +215 -3
  2. package/dist/agent-runtime/src/answer-label.cjs +137 -0
  3. package/dist/agent-runtime/src/answer-label.cjs.map +1 -0
  4. package/dist/agent-runtime/src/answer-label.d.ts +104 -0
  5. package/dist/agent-runtime/src/answer-label.js +137 -0
  6. package/dist/agent-runtime/src/answer-label.js.map +1 -0
  7. package/dist/agent-runtime/src/answer-rows.cjs +180 -0
  8. package/dist/agent-runtime/src/answer-rows.cjs.map +1 -0
  9. package/dist/agent-runtime/src/answer-rows.d.ts +86 -0
  10. package/dist/agent-runtime/src/answer-rows.js +180 -0
  11. package/dist/agent-runtime/src/answer-rows.js.map +1 -0
  12. package/dist/agent-runtime/src/client-tool-bridge.cjs +15 -15
  13. package/dist/agent-runtime/src/client-tool-bridge.cjs.map +1 -1
  14. package/dist/agent-runtime/src/conversation-index.cjs +8 -8
  15. package/dist/agent-runtime/src/conversation-index.cjs.map +1 -1
  16. package/dist/agent-runtime/src/decision-checks.cjs +207 -0
  17. package/dist/agent-runtime/src/decision-checks.cjs.map +1 -0
  18. package/dist/agent-runtime/src/decision-checks.d.ts +142 -0
  19. package/dist/agent-runtime/src/decision-checks.js +207 -0
  20. package/dist/agent-runtime/src/decision-checks.js.map +1 -0
  21. package/dist/agent-runtime/src/desktop-handoff.d.ts +12 -0
  22. package/dist/agent-runtime/src/errors.cjs +18 -0
  23. package/dist/agent-runtime/src/errors.cjs.map +1 -1
  24. package/dist/agent-runtime/src/errors.d.ts +7 -0
  25. package/dist/agent-runtime/src/errors.js +18 -0
  26. package/dist/agent-runtime/src/errors.js.map +1 -1
  27. package/dist/agent-runtime/src/generated/runconfig-contract.cjs +12 -0
  28. package/dist/agent-runtime/src/generated/runconfig-contract.cjs.map +1 -1
  29. package/dist/agent-runtime/src/generated/runconfig-contract.d.ts +6 -6
  30. package/dist/agent-runtime/src/generated/runconfig-contract.js +12 -0
  31. package/dist/agent-runtime/src/generated/runconfig-contract.js.map +1 -1
  32. package/dist/agent-runtime/src/handoff-arrival.cjs +60 -0
  33. package/dist/agent-runtime/src/handoff-arrival.cjs.map +1 -0
  34. package/dist/agent-runtime/src/handoff-arrival.d.ts +46 -0
  35. package/dist/agent-runtime/src/handoff-arrival.js +60 -0
  36. package/dist/agent-runtime/src/handoff-arrival.js.map +1 -0
  37. package/dist/agent-runtime/src/index.d.ts +14 -8
  38. package/dist/agent-runtime/src/interrupts.cjs +43 -18
  39. package/dist/agent-runtime/src/interrupts.cjs.map +1 -1
  40. package/dist/agent-runtime/src/interrupts.d.ts +19 -2
  41. package/dist/agent-runtime/src/interrupts.js +28 -3
  42. package/dist/agent-runtime/src/interrupts.js.map +1 -1
  43. package/dist/agent-runtime/src/lane-history.cjs +8 -8
  44. package/dist/agent-runtime/src/lane-history.cjs.map +1 -1
  45. package/dist/agent-runtime/src/messages.cjs +43 -8
  46. package/dist/agent-runtime/src/messages.cjs.map +1 -1
  47. package/dist/agent-runtime/src/messages.d.ts +25 -3
  48. package/dist/agent-runtime/src/messages.js +43 -8
  49. package/dist/agent-runtime/src/messages.js.map +1 -1
  50. package/dist/agent-runtime/src/offline-status.cjs +36 -0
  51. package/dist/agent-runtime/src/offline-status.cjs.map +1 -0
  52. package/dist/agent-runtime/src/offline-status.d.ts +118 -3
  53. package/dist/agent-runtime/src/offline-status.js +36 -0
  54. package/dist/agent-runtime/src/offline-status.js.map +1 -0
  55. package/dist/agent-runtime/src/queue.cjs +0 -9
  56. package/dist/agent-runtime/src/queue.cjs.map +1 -1
  57. package/dist/agent-runtime/src/queue.js +0 -9
  58. package/dist/agent-runtime/src/queue.js.map +1 -1
  59. package/dist/agent-runtime/src/quota-safe-local-storage-session.cjs +9 -9
  60. package/dist/agent-runtime/src/quota-safe-local-storage-session.cjs.map +1 -1
  61. package/dist/agent-runtime/src/runtime-catalog.cjs +42 -0
  62. package/dist/agent-runtime/src/runtime-catalog.cjs.map +1 -0
  63. package/dist/agent-runtime/src/runtime-catalog.d.ts +35 -0
  64. package/dist/agent-runtime/src/runtime-catalog.js +42 -0
  65. package/dist/agent-runtime/src/runtime-catalog.js.map +1 -0
  66. package/dist/agent-runtime/src/runtime-messages.cjs.map +1 -1
  67. package/dist/agent-runtime/src/runtime-messages.d.ts +1 -1
  68. package/dist/agent-runtime/src/runtime-messages.js.map +1 -1
  69. package/dist/agent-runtime/src/runtime.d.ts +40 -0
  70. package/dist/agent-runtime/src/statewire-suspended.cjs +3 -3
  71. package/dist/agent-runtime/src/statewire-suspended.cjs.map +1 -1
  72. package/dist/agent-runtime/src/subagents.cjs +32 -2
  73. package/dist/agent-runtime/src/subagents.cjs.map +1 -1
  74. package/dist/agent-runtime/src/subagents.d.ts +9 -0
  75. package/dist/agent-runtime/src/subagents.js +30 -0
  76. package/dist/agent-runtime/src/subagents.js.map +1 -1
  77. package/dist/agent-runtime/src/thread-driver.cjs +67 -0
  78. package/dist/agent-runtime/src/thread-driver.cjs.map +1 -0
  79. package/dist/agent-runtime/src/thread-driver.d.ts +49 -0
  80. package/dist/agent-runtime/src/thread-driver.js +67 -0
  81. package/dist/agent-runtime/src/thread-driver.js.map +1 -0
  82. package/dist/agent-runtime/src/thread-handoff-flow-machine.d.ts +172 -0
  83. package/dist/agent-runtime/src/thread-handoff-protocol.d.ts +756 -0
  84. package/dist/agent-runtime/src/thread-handoff-qr.d.ts +11 -0
  85. package/dist/agent-runtime/src/thread-handoff.d.ts +3 -364
  86. package/dist/agent-runtime/src/thread-status.cjs +3 -3
  87. package/dist/agent-runtime/src/thread-status.cjs.map +1 -1
  88. package/dist/agent-runtime/src/tool-metadata.cjs +210 -25
  89. package/dist/agent-runtime/src/tool-metadata.cjs.map +1 -1
  90. package/dist/agent-runtime/src/tool-metadata.d.ts +12 -0
  91. package/dist/agent-runtime/src/tool-metadata.js +210 -25
  92. package/dist/agent-runtime/src/tool-metadata.js.map +1 -1
  93. package/dist/agent-runtime/src/tool-names.cjs +2 -0
  94. package/dist/agent-runtime/src/tool-names.cjs.map +1 -1
  95. package/dist/agent-runtime/src/tool-names.d.ts +2 -0
  96. package/dist/agent-runtime/src/tool-names.js +2 -0
  97. package/dist/agent-runtime/src/tool-names.js.map +1 -1
  98. package/dist/agent-runtime/src/types.d.ts +10 -2
  99. package/dist/agent-runtime/src/use-conversation-list.cjs +11 -11
  100. package/dist/agent-runtime/src/use-conversation-list.cjs.map +1 -1
  101. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.cjs +24 -19
  102. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.cjs.map +1 -1
  103. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.d.ts +2 -1
  104. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.js +6 -1
  105. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.js.map +1 -1
  106. package/dist/agent-runtime/src/use-deep-agent-config.cjs +14 -14
  107. package/dist/agent-runtime/src/use-deep-agent-config.cjs.map +1 -1
  108. package/dist/agent-runtime/src/use-deep-agent-edit-submit.cjs +6 -6
  109. package/dist/agent-runtime/src/use-deep-agent-edit-submit.cjs.map +1 -1
  110. package/dist/agent-runtime/src/use-deep-agent-runtime.cjs +16 -16
  111. package/dist/agent-runtime/src/use-deep-agent-runtime.cjs.map +1 -1
  112. package/dist/agent-runtime/src/use-deep-agent-thread.cjs +45 -45
  113. package/dist/agent-runtime/src/use-deep-agent-thread.cjs.map +1 -1
  114. package/dist/agent-runtime/src/use-deep-agent-voice.cjs +547 -124
  115. package/dist/agent-runtime/src/use-deep-agent-voice.cjs.map +1 -1
  116. package/dist/agent-runtime/src/use-deep-agent-voice.d.ts +129 -10
  117. package/dist/agent-runtime/src/use-deep-agent-voice.js +487 -64
  118. package/dist/agent-runtime/src/use-deep-agent-voice.js.map +1 -1
  119. package/dist/agent-runtime/src/use-deep-agent-window-sync.cjs +26 -26
  120. package/dist/agent-runtime/src/use-deep-agent-window-sync.cjs.map +1 -1
  121. package/dist/agent-runtime/src/use-historical-edit-attachments.cjs +4 -4
  122. package/dist/agent-runtime/src/use-historical-edit-attachments.cjs.map +1 -1
  123. package/dist/agent-runtime/src/use-thread-handoff-flow.d.ts +28 -26
  124. package/dist/agent-runtime/src/voice-media.cjs +117 -0
  125. package/dist/agent-runtime/src/voice-media.cjs.map +1 -0
  126. package/dist/agent-runtime/src/voice-media.d.ts +49 -0
  127. package/dist/agent-runtime/src/voice-media.js +117 -0
  128. package/dist/agent-runtime/src/voice-media.js.map +1 -0
  129. package/dist/agent-runtime/src/voice-wire-types.d.ts +32 -0
  130. package/dist/assets/AssetPanel.cjs +11 -11
  131. package/dist/assets/AssetPanel.cjs.map +1 -1
  132. package/dist/assets/AthenaAssetEmbed.cjs +11 -9
  133. package/dist/assets/AthenaAssetEmbed.cjs.map +1 -1
  134. package/dist/assets/AthenaAssetEmbed.d.ts +7 -0
  135. package/dist/assets/AthenaAssetEmbed.js +4 -2
  136. package/dist/assets/AthenaAssetEmbed.js.map +1 -1
  137. package/dist/assets/AthenaLayout.cjs +16 -16
  138. package/dist/assets/AthenaLayout.cjs.map +1 -1
  139. package/dist/assets/use-asset-content.cjs +4 -4
  140. package/dist/assets/use-asset-content.cjs.map +1 -1
  141. package/dist/assets/use-asset-embed.cjs +14 -7
  142. package/dist/assets/use-asset-embed.cjs.map +1 -1
  143. package/dist/assets/use-asset-embed.d.ts +11 -1
  144. package/dist/assets/use-asset-embed.js +10 -3
  145. package/dist/assets/use-asset-embed.js.map +1 -1
  146. package/dist/auth/AthenaAuthContext.cjs +3 -3
  147. package/dist/auth/AthenaAuthContext.cjs.map +1 -1
  148. package/dist/auth/AthenaAuthProvider.cjs +8 -8
  149. package/dist/auth/AthenaAuthProvider.cjs.map +1 -1
  150. package/dist/auth/AthenaCredentialSourceContext.cjs +5 -5
  151. package/dist/auth/AthenaCredentialSourceContext.cjs.map +1 -1
  152. package/dist/auth/AthenaSSOProvider.cjs +14 -14
  153. package/dist/auth/AthenaSSOProvider.cjs.map +1 -1
  154. package/dist/auth/credential-source.cjs +26 -13
  155. package/dist/auth/credential-source.cjs.map +1 -1
  156. package/dist/auth/credential-source.d.ts +8 -0
  157. package/dist/auth/credential-source.js +26 -13
  158. package/dist/auth/credential-source.js.map +1 -1
  159. package/dist/catalog/agent-model-options.cjs +25 -17
  160. package/dist/catalog/agent-model-options.cjs.map +1 -1
  161. package/dist/catalog/agent-model-options.d.ts +38 -5
  162. package/dist/catalog/agent-model-options.js +25 -17
  163. package/dist/catalog/agent-model-options.js.map +1 -1
  164. package/dist/catalog/channel-refusal.cjs +36 -0
  165. package/dist/catalog/channel-refusal.cjs.map +1 -0
  166. package/dist/catalog/channel-refusal.d.ts +29 -0
  167. package/dist/catalog/channel-refusal.js +36 -0
  168. package/dist/catalog/channel-refusal.js.map +1 -0
  169. package/dist/catalog/chat-pickers.cjs +60 -24
  170. package/dist/catalog/chat-pickers.cjs.map +1 -1
  171. package/dist/catalog/chat-pickers.d.ts +12 -2
  172. package/dist/catalog/chat-pickers.js +56 -20
  173. package/dist/catalog/chat-pickers.js.map +1 -1
  174. package/dist/catalog/runtime-catalog.cjs +89 -23
  175. package/dist/catalog/runtime-catalog.cjs.map +1 -1
  176. package/dist/catalog/runtime-catalog.d.ts +8 -2
  177. package/dist/catalog/runtime-catalog.js +83 -17
  178. package/dist/catalog/runtime-catalog.js.map +1 -1
  179. package/dist/catalog/use-athena-chat-mode.cjs +12 -12
  180. package/dist/catalog/use-athena-chat-mode.cjs.map +1 -1
  181. package/dist/chat/AthenaChat.cjs +155 -67
  182. package/dist/chat/AthenaChat.cjs.map +1 -1
  183. package/dist/chat/AthenaChat.d.ts +42 -2
  184. package/dist/chat/AthenaChat.js +106 -18
  185. package/dist/chat/AthenaChat.js.map +1 -1
  186. package/dist/chat/AthenaChatErrorBoundary.cjs +3 -3
  187. package/dist/chat/AthenaChatErrorBoundary.cjs.map +1 -1
  188. package/dist/chat/DrivingOnChip.cjs +23 -0
  189. package/dist/chat/DrivingOnChip.cjs.map +1 -0
  190. package/dist/chat/DrivingOnChip.d.ts +17 -0
  191. package/dist/chat/DrivingOnChip.js +23 -0
  192. package/dist/chat/DrivingOnChip.js.map +1 -0
  193. package/dist/chat/StatewireApprovalCard.cjs +125 -31
  194. package/dist/chat/StatewireApprovalCard.cjs.map +1 -1
  195. package/dist/chat/StatewireApprovalCard.d.ts +73 -1
  196. package/dist/chat/StatewireApprovalCard.js +115 -21
  197. package/dist/chat/StatewireApprovalCard.js.map +1 -1
  198. package/dist/chat/StatewireClientToolBridge.cjs +2 -2
  199. package/dist/chat/StatewireClientToolBridge.cjs.map +1 -1
  200. package/dist/chat/StatewireQueuedMessages.cjs +25 -63
  201. package/dist/chat/StatewireQueuedMessages.cjs.map +1 -1
  202. package/dist/chat/StatewireQueuedMessages.d.ts +11 -13
  203. package/dist/chat/StatewireQueuedMessages.js +16 -54
  204. package/dist/chat/StatewireQueuedMessages.js.map +1 -1
  205. package/dist/chat/WaitingOnYouBanner.cjs +3 -3
  206. package/dist/chat/WaitingOnYouBanner.cjs.map +1 -1
  207. package/dist/chat/athena-chat-welcome.cjs +2 -2
  208. package/dist/chat/athena-chat-welcome.cjs.map +1 -1
  209. package/dist/chat/athena-citation-links.cjs +5 -5
  210. package/dist/chat/athena-citation-links.cjs.map +1 -1
  211. package/dist/chat/athena-composer-controls.cjs +26 -16
  212. package/dist/chat/athena-composer-controls.cjs.map +1 -1
  213. package/dist/chat/athena-composer-controls.d.ts +6 -0
  214. package/dist/chat/athena-composer-controls.js +26 -16
  215. package/dist/chat/athena-composer-controls.js.map +1 -1
  216. package/dist/chat/athena-turn-end-status.cjs +42 -0
  217. package/dist/chat/athena-turn-end-status.cjs.map +1 -0
  218. package/dist/chat/athena-turn-end-status.d.ts +24 -0
  219. package/dist/chat/athena-turn-end-status.js +42 -0
  220. package/dist/chat/athena-turn-end-status.js.map +1 -0
  221. package/dist/chat/browser-decision-check.cjs +131 -0
  222. package/dist/chat/browser-decision-check.cjs.map +1 -0
  223. package/dist/chat/browser-decision-check.d.ts +61 -0
  224. package/dist/chat/browser-decision-check.js +131 -0
  225. package/dist/chat/browser-decision-check.js.map +1 -0
  226. package/dist/chat/chat-outbox-rows.cjs +3 -3
  227. package/dist/chat/chat-outbox-rows.cjs.map +1 -1
  228. package/dist/chat/chat-voice-controls.cjs +93 -28
  229. package/dist/chat/chat-voice-controls.cjs.map +1 -1
  230. package/dist/chat/chat-voice-controls.d.ts +36 -2
  231. package/dist/chat/chat-voice-controls.js +89 -24
  232. package/dist/chat/chat-voice-controls.js.map +1 -1
  233. package/dist/chat/composer-keyboard-hint.cjs +5 -5
  234. package/dist/chat/composer-keyboard-hint.cjs.map +1 -1
  235. package/dist/chat/device-operation.cjs +29 -0
  236. package/dist/chat/device-operation.cjs.map +1 -0
  237. package/dist/chat/device-operation.d.ts +34 -0
  238. package/dist/chat/device-operation.js +29 -0
  239. package/dist/chat/device-operation.js.map +1 -0
  240. package/dist/chat/super-grouping/CollapsibleGroup.cjs +14 -14
  241. package/dist/chat/super-grouping/CollapsibleGroup.cjs.map +1 -1
  242. package/dist/chat/super-grouping/GroupedMessageParts.cjs +4 -4
  243. package/dist/chat/super-grouping/GroupedMessageParts.cjs.map +1 -1
  244. package/dist/chat/super-grouping/SuperGroupingCard.cjs +52 -36
  245. package/dist/chat/super-grouping/SuperGroupingCard.cjs.map +1 -1
  246. package/dist/chat/super-grouping/SuperGroupingCard.d.ts +19 -4
  247. package/dist/chat/super-grouping/SuperGroupingCard.js +29 -13
  248. package/dist/chat/super-grouping/SuperGroupingCard.js.map +1 -1
  249. package/dist/chat/super-grouping/SuperGroupingTranscript.cjs +32 -32
  250. package/dist/chat/super-grouping/SuperGroupingTranscript.cjs.map +1 -1
  251. package/dist/chat/super-grouping/SuperGroupingTranscript.js +3 -3
  252. package/dist/chat/super-grouping/SuperGroupingTranscript.js.map +1 -1
  253. package/dist/chat/super-grouping/ToolTimeline.cjs +73 -40
  254. package/dist/chat/super-grouping/ToolTimeline.cjs.map +1 -1
  255. package/dist/chat/super-grouping/ToolTimeline.d.ts +10 -2
  256. package/dist/chat/super-grouping/ToolTimeline.js +69 -36
  257. package/dist/chat/super-grouping/ToolTimeline.js.map +1 -1
  258. package/dist/chat/super-grouping/activity-timeline.cjs +47 -12
  259. package/dist/chat/super-grouping/activity-timeline.cjs.map +1 -1
  260. package/dist/chat/super-grouping/activity-timeline.d.ts +21 -0
  261. package/dist/chat/super-grouping/activity-timeline.js +47 -12
  262. package/dist/chat/super-grouping/activity-timeline.js.map +1 -1
  263. package/dist/chat/super-grouping/grouping-function.cjs +4 -0
  264. package/dist/chat/super-grouping/grouping-function.cjs.map +1 -1
  265. package/dist/chat/super-grouping/grouping-function.d.ts +7 -0
  266. package/dist/chat/super-grouping/grouping-function.js +5 -1
  267. package/dist/chat/super-grouping/grouping-function.js.map +1 -1
  268. package/dist/chat/super-grouping/index.cjs +6 -0
  269. package/dist/chat/super-grouping/index.cjs.map +1 -1
  270. package/dist/chat/super-grouping/index.d.ts +5 -2
  271. package/dist/chat/super-grouping/index.js +7 -1
  272. package/dist/chat/super-grouping/index.js.map +1 -1
  273. package/dist/chat/super-grouping/tool-part-placement.cjs +17 -0
  274. package/dist/chat/super-grouping/tool-part-placement.cjs.map +1 -0
  275. package/dist/chat/super-grouping/tool-part-placement.d.ts +22 -0
  276. package/dist/chat/super-grouping/tool-part-placement.js +17 -0
  277. package/dist/chat/super-grouping/tool-part-placement.js.map +1 -0
  278. package/dist/chat/thread-scroll-to-bottom.cjs +2 -2
  279. package/dist/chat/thread-scroll-to-bottom.cjs.map +1 -1
  280. package/dist/chat/thread-scroll-to-bottom.d.ts +10 -7
  281. package/dist/chat/thread-scroll-to-bottom.js +2 -2
  282. package/dist/chat/thread-scroll-to-bottom.js.map +1 -1
  283. package/dist/chat/tooltip-icon-button.cjs +2 -2
  284. package/dist/chat/tooltip-icon-button.cjs.map +1 -1
  285. package/dist/chat/use-athena-voice-live.cjs +11 -0
  286. package/dist/chat/use-athena-voice-live.cjs.map +1 -0
  287. package/dist/chat/use-athena-voice-live.d.ts +11 -0
  288. package/dist/chat/use-athena-voice-live.js +11 -0
  289. package/dist/chat/use-athena-voice-live.js.map +1 -0
  290. package/dist/chat/use-statewire-approval-request.cjs +56 -24
  291. package/dist/chat/use-statewire-approval-request.cjs.map +1 -1
  292. package/dist/chat/use-statewire-approval-request.d.ts +33 -4
  293. package/dist/chat/use-statewire-approval-request.js +41 -9
  294. package/dist/chat/use-statewire-approval-request.js.map +1 -1
  295. package/dist/chat-ui/auth/sign-in-card.cjs +2 -2
  296. package/dist/chat-ui/auth/sign-in-card.cjs.map +1 -1
  297. package/dist/chat-ui/composer/tiptap-composer.cjs +138 -107
  298. package/dist/chat-ui/composer/tiptap-composer.cjs.map +1 -1
  299. package/dist/chat-ui/composer/tiptap-composer.d.ts +20 -4
  300. package/dist/chat-ui/composer/tiptap-composer.js +85 -54
  301. package/dist/chat-ui/composer/tiptap-composer.js.map +1 -1
  302. package/dist/chat-ui/header/conversation-history-panel.cjs +49 -23
  303. package/dist/chat-ui/header/conversation-history-panel.cjs.map +1 -1
  304. package/dist/chat-ui/header/conversation-history-panel.d.ts +12 -1
  305. package/dist/chat-ui/header/conversation-history-panel.js +38 -12
  306. package/dist/chat-ui/header/conversation-history-panel.js.map +1 -1
  307. package/dist/chat-ui/index.cjs +18 -0
  308. package/dist/chat-ui/index.cjs.map +1 -1
  309. package/dist/chat-ui/index.d.ts +7 -1
  310. package/dist/chat-ui/index.js +18 -0
  311. package/dist/chat-ui/index.js.map +1 -1
  312. package/dist/chat-ui/mentions/mention-chip.cjs +4 -4
  313. package/dist/chat-ui/mentions/mention-chip.cjs.map +1 -1
  314. package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-list.cjs +10 -9
  315. package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-list.cjs.map +1 -1
  316. package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-list.js +3 -2
  317. package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-list.js.map +1 -1
  318. package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-popup.cjs +2 -2
  319. package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-popup.cjs.map +1 -1
  320. package/dist/chat-ui/mentions/suggestions/components/menu-list.cjs +29 -6
  321. package/dist/chat-ui/mentions/suggestions/components/menu-list.cjs.map +1 -1
  322. package/dist/chat-ui/mentions/suggestions/components/menu-list.d.ts +7 -1
  323. package/dist/chat-ui/mentions/suggestions/components/menu-list.js +25 -2
  324. package/dist/chat-ui/mentions/suggestions/components/menu-list.js.map +1 -1
  325. package/dist/chat-ui/mentions/suggestions/components/use-keyboard-navigation.cjs +2 -2
  326. package/dist/chat-ui/mentions/suggestions/components/use-keyboard-navigation.cjs.map +1 -1
  327. package/dist/chat-ui/mentions/suggestions/components/use-menu-navigation.cjs +2 -2
  328. package/dist/chat-ui/mentions/suggestions/components/use-menu-navigation.cjs.map +1 -1
  329. package/dist/chat-ui/mentions/suggestions/data/api-client.cjs +3 -3
  330. package/dist/chat-ui/mentions/suggestions/data/api-client.cjs.map +1 -1
  331. package/dist/chat-ui/mentions/suggestions/data/orchestrator.cjs +56 -2
  332. package/dist/chat-ui/mentions/suggestions/data/orchestrator.cjs.map +1 -1
  333. package/dist/chat-ui/mentions/suggestions/data/orchestrator.d.ts +12 -0
  334. package/dist/chat-ui/mentions/suggestions/data/orchestrator.js +56 -2
  335. package/dist/chat-ui/mentions/suggestions/data/orchestrator.js.map +1 -1
  336. package/dist/chat-ui/mentions/suggestions/data/sources/index.cjs +24 -3
  337. package/dist/chat-ui/mentions/suggestions/data/sources/index.cjs.map +1 -1
  338. package/dist/chat-ui/mentions/suggestions/data/sources/index.d.ts +7 -0
  339. package/dist/chat-ui/mentions/suggestions/data/sources/index.js +24 -3
  340. package/dist/chat-ui/mentions/suggestions/data/sources/index.js.map +1 -1
  341. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.cjs +35 -13
  342. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.cjs.map +1 -1
  343. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.d.ts +15 -1
  344. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.js +28 -6
  345. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.js.map +1 -1
  346. package/dist/chat-ui/mentions/suggestions/data/use-menu-items.cjs +9 -6
  347. package/dist/chat-ui/mentions/suggestions/data/use-menu-items.cjs.map +1 -1
  348. package/dist/chat-ui/mentions/suggestions/data/use-menu-items.d.ts +3 -0
  349. package/dist/chat-ui/mentions/suggestions/data/use-menu-items.js +5 -2
  350. package/dist/chat-ui/mentions/suggestions/data/use-menu-items.js.map +1 -1
  351. package/dist/chat-ui/mentions/use-account-workspace-id.cjs +45 -10
  352. package/dist/chat-ui/mentions/use-account-workspace-id.cjs.map +1 -1
  353. package/dist/chat-ui/mentions/use-account-workspace-id.d.ts +24 -1
  354. package/dist/chat-ui/mentions/use-account-workspace-id.js +46 -11
  355. package/dist/chat-ui/mentions/use-account-workspace-id.js.map +1 -1
  356. package/dist/chat-ui/mentions/use-member-avatar.cjs +4 -4
  357. package/dist/chat-ui/mentions/use-member-avatar.cjs.map +1 -1
  358. package/dist/chat-ui/mentions/use-mention-asset.cjs +3 -3
  359. package/dist/chat-ui/mentions/use-mention-asset.cjs.map +1 -1
  360. package/dist/chat-ui/messages/answer-label.cjs +42 -0
  361. package/dist/chat-ui/messages/answer-label.cjs.map +1 -0
  362. package/dist/chat-ui/messages/answer-label.d.ts +33 -0
  363. package/dist/chat-ui/messages/answer-label.js +42 -0
  364. package/dist/chat-ui/messages/answer-label.js.map +1 -0
  365. package/dist/chat-ui/messages/arrival-animation.cjs +13 -0
  366. package/dist/chat-ui/messages/arrival-animation.cjs.map +1 -0
  367. package/dist/chat-ui/messages/arrival-animation.d.ts +14 -0
  368. package/dist/chat-ui/messages/arrival-animation.js +13 -0
  369. package/dist/chat-ui/messages/arrival-animation.js.map +1 -0
  370. package/dist/chat-ui/messages/continue-pill.cjs +5 -5
  371. package/dist/chat-ui/messages/continue-pill.cjs.map +1 -1
  372. package/dist/chat-ui/messages/handoff-arrival-divider.cjs +44 -0
  373. package/dist/chat-ui/messages/handoff-arrival-divider.cjs.map +1 -0
  374. package/dist/chat-ui/messages/handoff-arrival-divider.d.ts +17 -0
  375. package/dist/chat-ui/messages/handoff-arrival-divider.js +44 -0
  376. package/dist/chat-ui/messages/handoff-arrival-divider.js.map +1 -0
  377. package/dist/chat-ui/messages/message-actions-config.cjs +3 -3
  378. package/dist/chat-ui/messages/message-actions-config.cjs.map +1 -1
  379. package/dist/chat-ui/messages/message-components.cjs +8 -4
  380. package/dist/chat-ui/messages/message-components.cjs.map +1 -1
  381. package/dist/chat-ui/messages/message-components.js +5 -1
  382. package/dist/chat-ui/messages/message-components.js.map +1 -1
  383. package/dist/chat-ui/messages/message-images.cjs +66 -0
  384. package/dist/chat-ui/messages/message-images.cjs.map +1 -0
  385. package/dist/chat-ui/messages/message-images.d.ts +16 -0
  386. package/dist/chat-ui/messages/message-images.js +66 -0
  387. package/dist/chat-ui/messages/message-images.js.map +1 -0
  388. package/dist/chat-ui/messages/user-edit-composer.cjs +2 -2
  389. package/dist/chat-ui/messages/user-edit-composer.cjs.map +1 -1
  390. package/dist/chat-ui/messages/wake-marker.cjs +3 -3
  391. package/dist/chat-ui/messages/wake-marker.cjs.map +1 -1
  392. package/dist/chat-ui/rich-text/chat-link.cjs +2 -2
  393. package/dist/chat-ui/rich-text/chat-link.cjs.map +1 -1
  394. package/dist/chat-ui/rich-text/chat-message-body.cjs +8 -8
  395. package/dist/chat-ui/rich-text/chat-message-body.cjs.map +1 -1
  396. package/dist/chat-ui/rich-text/chat-node-views.cjs +6 -6
  397. package/dist/chat-ui/rich-text/chat-node-views.cjs.map +1 -1
  398. package/dist/chat-ui/rich-text/dom-output-spec.cjs +2 -2
  399. package/dist/chat-ui/rich-text/dom-output-spec.cjs.map +1 -1
  400. package/dist/chat-ui/statewire.cjs +3 -0
  401. package/dist/chat-ui/statewire.cjs.map +1 -1
  402. package/dist/chat-ui/statewire.d.ts +2 -1
  403. package/dist/chat-ui/statewire.js +3 -0
  404. package/dist/chat-ui/statewire.js.map +1 -1
  405. package/dist/chat-ui/thread/chat-thread-shell.cjs +43 -14
  406. package/dist/chat-ui/thread/chat-thread-shell.cjs.map +1 -1
  407. package/dist/chat-ui/thread/chat-thread-shell.d.ts +16 -2
  408. package/dist/chat-ui/thread/chat-thread-shell.js +35 -6
  409. package/dist/chat-ui/thread/chat-thread-shell.js.map +1 -1
  410. package/dist/chat-ui/thread/composer-send-or-stop.cjs +30 -20
  411. package/dist/chat-ui/thread/composer-send-or-stop.cjs.map +1 -1
  412. package/dist/chat-ui/thread/composer-send-or-stop.d.ts +8 -0
  413. package/dist/chat-ui/thread/composer-send-or-stop.js +29 -19
  414. package/dist/chat-ui/thread/composer-send-or-stop.js.map +1 -1
  415. package/dist/chat-ui/thread/statewire-history-edge.cjs +20 -21
  416. package/dist/chat-ui/thread/statewire-history-edge.cjs.map +1 -1
  417. package/dist/chat-ui/thread/statewire-history-edge.js +3 -4
  418. package/dist/chat-ui/thread/statewire-history-edge.js.map +1 -1
  419. package/dist/chat-ui/thread/thread-loading-overlay.cjs +5 -5
  420. package/dist/chat-ui/thread/thread-loading-overlay.cjs.map +1 -1
  421. package/dist/collab/client.cjs +40 -3
  422. package/dist/collab/client.cjs.map +1 -1
  423. package/dist/collab/client.d.ts +25 -0
  424. package/dist/collab/client.js +40 -3
  425. package/dist/collab/client.js.map +1 -1
  426. package/dist/collab/document-status.cjs +150 -0
  427. package/dist/collab/document-status.cjs.map +1 -0
  428. package/dist/collab/document-status.d.ts +68 -0
  429. package/dist/collab/document-status.js +150 -0
  430. package/dist/collab/document-status.js.map +1 -0
  431. package/dist/collab/index.cjs +7 -0
  432. package/dist/collab/index.cjs.map +1 -1
  433. package/dist/collab/index.d.ts +6 -1
  434. package/dist/collab/index.js +7 -0
  435. package/dist/collab/index.js.map +1 -1
  436. package/dist/collab/presence-react.cjs +11 -11
  437. package/dist/collab/presence-react.cjs.map +1 -1
  438. package/dist/collab/react.cjs +6 -6
  439. package/dist/collab/react.cjs.map +1 -1
  440. package/dist/composer/AttachmentContext.cjs +24 -11
  441. package/dist/composer/AttachmentContext.cjs.map +1 -1
  442. package/dist/composer/AttachmentContext.js +18 -5
  443. package/dist/composer/AttachmentContext.js.map +1 -1
  444. package/dist/composer/ComposerAttachmentPreview.cjs +78 -23
  445. package/dist/composer/ComposerAttachmentPreview.cjs.map +1 -1
  446. package/dist/composer/ComposerAttachmentPreview.d.ts +5 -3
  447. package/dist/composer/ComposerAttachmentPreview.js +79 -24
  448. package/dist/composer/ComposerAttachmentPreview.js.map +1 -1
  449. package/dist/composer/ComposerDropZone.cjs +7 -7
  450. package/dist/composer/ComposerDropZone.cjs.map +1 -1
  451. package/dist/composer/FileUploadButton.cjs +37 -22
  452. package/dist/composer/FileUploadButton.cjs.map +1 -1
  453. package/dist/composer/FileUploadButton.d.ts +6 -0
  454. package/dist/composer/FileUploadButton.js +34 -19
  455. package/dist/composer/FileUploadButton.js.map +1 -1
  456. package/dist/composer/QuoteContext.cjs +8 -8
  457. package/dist/composer/QuoteContext.cjs.map +1 -1
  458. package/dist/composer/composer-handoff.cjs +4 -4
  459. package/dist/composer/composer-handoff.cjs.map +1 -1
  460. package/dist/composer/useAppendToComposer.cjs +4 -4
  461. package/dist/composer/useAppendToComposer.cjs.map +1 -1
  462. package/dist/composer/useAttachFiles.cjs +23 -6
  463. package/dist/composer/useAttachFiles.cjs.map +1 -1
  464. package/dist/composer/useAttachFiles.d.ts +15 -7
  465. package/dist/composer/useAttachFiles.js +22 -5
  466. package/dist/composer/useAttachFiles.js.map +1 -1
  467. package/dist/composer/useComposerAttachment.cjs +4 -4
  468. package/dist/composer/useComposerAttachment.cjs.map +1 -1
  469. package/dist/composer/useFileUpload.cjs +21 -16
  470. package/dist/composer/useFileUpload.cjs.map +1 -1
  471. package/dist/composer/useFileUpload.d.ts +12 -0
  472. package/dist/composer/useFileUpload.js +12 -7
  473. package/dist/composer/useFileUpload.js.map +1 -1
  474. package/dist/composer/useReadComposerDraft.cjs +2 -2
  475. package/dist/composer/useReadComposerDraft.cjs.map +1 -1
  476. package/dist/composer/useSendMessage.cjs +4 -4
  477. package/dist/composer/useSendMessage.cjs.map +1 -1
  478. package/dist/diagnostics/useAthenaDiagnostics.cjs +4 -4
  479. package/dist/diagnostics/useAthenaDiagnostics.cjs.map +1 -1
  480. package/dist/dictation/audio-level-history.cjs +3 -3
  481. package/dist/dictation/audio-level-history.cjs.map +1 -1
  482. package/dist/dictation/dictation-controls.cjs +24 -20
  483. package/dist/dictation/dictation-controls.cjs.map +1 -1
  484. package/dist/dictation/dictation-controls.d.ts +6 -1
  485. package/dist/dictation/dictation-controls.js +24 -20
  486. package/dist/dictation/dictation-controls.js.map +1 -1
  487. package/dist/dictation/use-athena-dictation-engine.cjs +3 -3
  488. package/dist/dictation/use-athena-dictation-engine.cjs.map +1 -1
  489. package/dist/dictation/use-dictation.cjs +22 -22
  490. package/dist/dictation/use-dictation.cjs.map +1 -1
  491. package/dist/index.cjs +26 -2
  492. package/dist/index.cjs.map +1 -1
  493. package/dist/index.d.ts +15 -3
  494. package/dist/index.js +26 -2
  495. package/dist/index.js.map +1 -1
  496. package/dist/keryx-http/src/receive-only-socket.cjs +40 -0
  497. package/dist/keryx-http/src/receive-only-socket.cjs.map +1 -0
  498. package/dist/keryx-http/src/receive-only-socket.d.ts +27 -0
  499. package/dist/keryx-http/src/receive-only-socket.js +40 -0
  500. package/dist/keryx-http/src/receive-only-socket.js.map +1 -0
  501. package/dist/keryx-http/src/update-attributions.cjs +111 -0
  502. package/dist/keryx-http/src/update-attributions.cjs.map +1 -0
  503. package/dist/keryx-http/src/update-attributions.d.ts +75 -0
  504. package/dist/keryx-http/src/update-attributions.js +111 -0
  505. package/dist/keryx-http/src/update-attributions.js.map +1 -0
  506. package/dist/lib/owner-document.cjs +6 -6
  507. package/dist/lib/owner-document.cjs.map +1 -1
  508. package/dist/lib/use-athena-rest-query.cjs +4 -4
  509. package/dist/lib/use-athena-rest-query.cjs.map +1 -1
  510. package/dist/lib/use-document-active.cjs +4 -4
  511. package/dist/lib/use-document-active.cjs.map +1 -1
  512. package/dist/lib/use-prefers-reduced-motion.cjs +2 -2
  513. package/dist/lib/use-prefers-reduced-motion.cjs.map +1 -1
  514. package/dist/offline/offline-history.cjs +7 -7
  515. package/dist/offline/offline-history.cjs.map +1 -1
  516. package/dist/provider/AthenaContext.cjs +3 -3
  517. package/dist/provider/AthenaContext.cjs.map +1 -1
  518. package/dist/provider/AthenaProvider.cjs +116 -79
  519. package/dist/provider/AthenaProvider.cjs.map +1 -1
  520. package/dist/provider/AthenaProvider.js +40 -3
  521. package/dist/provider/AthenaProvider.js.map +1 -1
  522. package/dist/provider/PostHogProvider.cjs +2 -2
  523. package/dist/provider/PostHogProvider.cjs.map +1 -1
  524. package/dist/provider/agent-selection-context.cjs +2 -2
  525. package/dist/provider/agent-selection-context.cjs.map +1 -1
  526. package/dist/provider/chat-mode-context.cjs +2 -2
  527. package/dist/provider/chat-mode-context.cjs.map +1 -1
  528. package/dist/provider/session-persistence-context.cjs +10 -0
  529. package/dist/provider/session-persistence-context.cjs.map +1 -0
  530. package/dist/provider/session-persistence-context.d.ts +15 -0
  531. package/dist/provider/session-persistence-context.js +10 -0
  532. package/dist/provider/session-persistence-context.js.map +1 -0
  533. package/dist/provider/statewire-history-context.cjs +4 -4
  534. package/dist/provider/statewire-history-context.cjs.map +1 -1
  535. package/dist/provider/statewire-lifecycle-context.cjs +3 -3
  536. package/dist/provider/statewire-lifecycle-context.cjs.map +1 -1
  537. package/dist/provider/statewire-window-context.cjs +3 -3
  538. package/dist/provider/statewire-window-context.cjs.map +1 -1
  539. package/dist/provider/theme-style-context.cjs +3 -3
  540. package/dist/provider/theme-style-context.cjs.map +1 -1
  541. package/dist/react/package.json.cjs +1 -1
  542. package/dist/react/package.json.js +1 -1
  543. package/dist/runtime/StatewireThreadConfigLaneSync.cjs +10 -10
  544. package/dist/runtime/StatewireThreadConfigLaneSync.cjs.map +1 -1
  545. package/dist/runtime/auth-refusal-restart.cjs +7 -7
  546. package/dist/runtime/auth-refusal-restart.cjs.map +1 -1
  547. package/dist/runtime/auth.cjs +13 -13
  548. package/dist/runtime/auth.cjs.map +1 -1
  549. package/dist/runtime/statewire-lifecycle.cjs +1 -0
  550. package/dist/runtime/statewire-lifecycle.cjs.map +1 -1
  551. package/dist/runtime/statewire-lifecycle.d.ts +3 -1
  552. package/dist/runtime/statewire-lifecycle.js +2 -1
  553. package/dist/runtime/statewire-lifecycle.js.map +1 -1
  554. package/dist/runtime/statewire-server-lane-context.cjs +2 -2
  555. package/dist/runtime/statewire-server-lane-context.cjs.map +1 -1
  556. package/dist/runtime/statewire-session-lane.cjs +4 -4
  557. package/dist/runtime/statewire-session-lane.cjs.map +1 -1
  558. package/dist/runtime/useAthenaStatewireRuntime.cjs +10 -8
  559. package/dist/runtime/useAthenaStatewireRuntime.cjs.map +1 -1
  560. package/dist/runtime/useAthenaStatewireRuntime.d.ts +2 -0
  561. package/dist/runtime/useAthenaStatewireRuntime.js +2 -0
  562. package/dist/runtime/useAthenaStatewireRuntime.js.map +1 -1
  563. package/dist/styles.css +1 -1
  564. package/dist/threads/Inbox.cjs +8 -8
  565. package/dist/threads/Inbox.cjs.map +1 -1
  566. package/dist/threads/SessionList.cjs +9 -9
  567. package/dist/threads/SessionList.cjs.map +1 -1
  568. package/dist/threads/SessionsPage.cjs +11 -11
  569. package/dist/threads/SessionsPage.cjs.map +1 -1
  570. package/dist/threads/index-triggered-refresh.cjs +10 -10
  571. package/dist/threads/index-triggered-refresh.cjs.map +1 -1
  572. package/dist/threads/mark-viewed-thread-read.cjs +12 -12
  573. package/dist/threads/mark-viewed-thread-read.cjs.map +1 -1
  574. package/dist/threads/offline-session-list.cjs +3 -3
  575. package/dist/threads/offline-session-list.cjs.map +1 -1
  576. package/dist/threads/session-list-tab-share.cjs +5 -5
  577. package/dist/threads/session-list-tab-share.cjs.map +1 -1
  578. package/dist/threads/statewire-thread-list.cjs +51 -51
  579. package/dist/threads/statewire-thread-list.cjs.map +1 -1
  580. package/dist/threads/thread-id-context.cjs +5 -5
  581. package/dist/threads/thread-id-context.cjs.map +1 -1
  582. package/dist/threads/use-athena-session-attention.cjs +2 -2
  583. package/dist/threads/use-athena-session-attention.cjs.map +1 -1
  584. package/dist/threads/use-athena-sessions.cjs +10 -10
  585. package/dist/threads/use-athena-sessions.cjs.map +1 -1
  586. package/dist/threads/use-athena-thread-model.cjs +3 -3
  587. package/dist/threads/use-athena-thread-model.cjs.map +1 -1
  588. package/dist/threads/use-rest-conversation-history.cjs +3 -3
  589. package/dist/threads/use-rest-conversation-history.cjs.map +1 -1
  590. package/dist/threads/use-statewire-conversation-history.cjs +8 -8
  591. package/dist/threads/use-statewire-conversation-history.cjs.map +1 -1
  592. package/dist/threads/use-thread-archive.cjs +9 -9
  593. package/dist/threads/use-thread-archive.cjs.map +1 -1
  594. package/dist/threads/use-thread-favorite.cjs +2 -2
  595. package/dist/threads/use-thread-favorite.cjs.map +1 -1
  596. package/dist/threads/use-thread-field-override.cjs +20 -20
  597. package/dist/threads/use-thread-field-override.cjs.map +1 -1
  598. package/dist/threads/use-thread-read-state.cjs +4 -4
  599. package/dist/threads/use-thread-read-state.cjs.map +1 -1
  600. package/dist/threads/use-thread-rename.cjs +2 -2
  601. package/dist/threads/use-thread-rename.cjs.map +1 -1
  602. package/dist/threads/useAthenaThreadManager.cjs +2 -2
  603. package/dist/threads/useAthenaThreadManager.cjs.map +1 -1
  604. package/dist/tools/NestedPtcMessages.cjs +6 -6
  605. package/dist/tools/NestedPtcMessages.cjs.map +1 -1
  606. package/dist/tools/append-document-tool-ui.cjs +7 -7
  607. package/dist/tools/append-document-tool-ui.cjs.map +1 -1
  608. package/dist/tools/file-tool-uis.cjs +2 -2
  609. package/dist/tools/file-tool-uis.cjs.map +1 -1
  610. package/dist/tools/misc-tool-uis.cjs +2 -2
  611. package/dist/tools/misc-tool-uis.cjs.map +1 -1
  612. package/dist/tools/primitives.cjs +6 -6
  613. package/dist/tools/primitives.cjs.map +1 -1
  614. package/dist/tools/read-asset-tool-ui.cjs +6 -6
  615. package/dist/tools/read-asset-tool-ui.cjs.map +1 -1
  616. package/dist/tools/subagent-task-tool-ui.cjs +21 -21
  617. package/dist/tools/subagent-task-tool-ui.cjs.map +1 -1
  618. package/dist/tools/test-recording-tool-uis.cjs +16 -16
  619. package/dist/tools/test-recording-tool-uis.cjs.map +1 -1
  620. package/dist/tools/todo-plan-store.cjs +4 -4
  621. package/dist/tools/todo-plan-store.cjs.map +1 -1
  622. package/dist/tools/tool-appearance.cjs +3 -3
  623. package/dist/tools/tool-appearance.cjs.map +1 -1
  624. package/dist/tools/tool-fallback.cjs +14 -14
  625. package/dist/tools/tool-fallback.cjs.map +1 -1
  626. package/dist/tools/tool-uis.cjs +74 -74
  627. package/dist/tools/tool-uis.cjs.map +1 -1
  628. package/dist/tools/use-elapsed-seconds.cjs +3 -3
  629. package/dist/tools/use-elapsed-seconds.cjs.map +1 -1
  630. package/dist/tools/write-todos-tool-ui.cjs +9 -9
  631. package/dist/tools/write-todos-tool-ui.cjs.map +1 -1
  632. package/dist/ui/image-viewer.cjs +382 -0
  633. package/dist/ui/image-viewer.cjs.map +1 -0
  634. package/dist/ui/image-viewer.d.ts +50 -0
  635. package/dist/ui/image-viewer.js +382 -0
  636. package/dist/ui/image-viewer.js.map +1 -0
  637. package/dist/voice/chat.cjs +6 -0
  638. package/dist/voice/chat.cjs.map +1 -1
  639. package/dist/voice/chat.d.ts +1 -1
  640. package/dist/voice/chat.js +8 -2
  641. package/dist/voice/livekit-join.cjs +52 -101
  642. package/dist/voice/livekit-join.cjs.map +1 -1
  643. package/dist/voice/livekit-join.d.ts +1 -6
  644. package/dist/voice/livekit-join.js +52 -101
  645. package/dist/voice/livekit-join.js.map +1 -1
  646. package/dist/voice/livekit.cjs.map +1 -1
  647. package/dist/voice/livekit.d.ts +11 -1
  648. package/dist/voice/livekit.js.map +1 -1
  649. package/dist/voice/use-athena-voice-session.cjs +34 -34
  650. package/dist/voice/use-athena-voice-session.cjs.map +1 -1
  651. package/dist/workbench/ComputerLiveDesktop.cjs +13 -13
  652. package/dist/workbench/ComputerLiveDesktop.cjs.map +1 -1
  653. package/dist/workbench/SessionWorkbench.cjs +22 -22
  654. package/dist/workbench/SessionWorkbench.cjs.map +1 -1
  655. package/dist/workbench/session-workbench-context.cjs +3 -3
  656. package/dist/workbench/session-workbench-context.cjs.map +1 -1
  657. package/dist/workbench/session-workbench-panes.cjs +8 -8
  658. package/dist/workbench/session-workbench-panes.cjs.map +1 -1
  659. package/dist/workbench/workbench-layout-context.cjs +3 -3
  660. package/dist/workbench/workbench-layout-context.cjs.map +1 -1
  661. package/package.json +2 -1
@@ -1 +1 @@
1
- {"version":3,"file":"statewire-history-context.cjs","sources":["../../src/provider/statewire-history-context.ts"],"sourcesContent":["import { createContext, useContext, useSyncExternalStore } from 'react';\n\n/**\n * Where the open thread's windowed history stands, as the chat's history edge\n * (`StatewireHistoryEdge`) knows it: whether the host holds older messages the\n * client has not loaded, and how to ask for the next page. The edge publishes\n * it; other surfaces of the same provider read it — the session workbench's\n * Shell pane, whose rows come from the loaded transcript, says its count is\n * partial and offers the earlier commands.\n */\nexport interface StatewireHistoryState {\n /** The thread the edge reported for; `null` while no edge is mounted. */\n threadId: string | null;\n /** The host holds messages older than the loaded window. */\n hasOlder: boolean;\n /** The next page can be asked for: older messages exist and the host's interest cap has room. */\n canLoadOlder: boolean;\n /** A page of older history is in flight. */\n loading: boolean;\n /** Ask for the next page (the edge row's own action); `null` while no edge is mounted. */\n loadOlder: (() => void) | null;\n}\n\nexport const NO_STATEWIRE_HISTORY: StatewireHistoryState = {\n threadId: null,\n hasOlder: false,\n canLoadOlder: false,\n loading: false,\n loadOlder: null,\n};\n\n/** A tiny external store: the edge writes, readers subscribe. */\nexport interface StatewireHistoryStore {\n get: () => StatewireHistoryState;\n set: (next: StatewireHistoryState) => void;\n subscribe: (listener: () => void) => () => void;\n}\n\nexport function createStatewireHistoryStore(): StatewireHistoryStore {\n let state = NO_STATEWIRE_HISTORY;\n const listeners = new Set<() => void>();\n return {\n get: () => state,\n set: (next) => {\n if (\n next.threadId === state.threadId &&\n next.hasOlder === state.hasOlder &&\n next.canLoadOlder === state.canLoadOlder &&\n next.loading === state.loading &&\n next.loadOlder === state.loadOlder\n ) {\n return;\n }\n state = next;\n for (const listener of listeners) listener();\n },\n subscribe: (listener) => {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n };\n}\n\n/** Provided by `AthenaProvider`, one store per provider. */\nexport const StatewireHistoryContext = createContext<StatewireHistoryStore | null>(null);\n\nconst subscribeToNothing = () => () => {};\nconst readNoHistory = () => NO_STATEWIRE_HISTORY;\n\n/**\n * The history state the edge reported for *threadId*, or `null` when none\n * did: no provider, no history edge mounted (a host that renders its own\n * transcript), or another thread's report.\n */\nexport function useStatewireHistory(threadId: string | null): StatewireHistoryState | null {\n const store = useContext(StatewireHistoryContext);\n const state = useSyncExternalStore(\n store?.subscribe ?? subscribeToNothing,\n store?.get ?? readNoHistory,\n store?.get ?? readNoHistory,\n );\n return threadId !== null && state.threadId === threadId ? state : null;\n}\n"],"names":["createContext","useContext","useSyncExternalStore"],"mappings":";;;AAuBO,MAAM,uBAA8C;AAAA,EACzD,UAAU;AAAA,EACV,UAAU;AAAA,EACV,cAAc;AAAA,EACd,SAAS;AAAA,EACT,WAAW;AACb;AASO,SAAS,8BAAqD;AACnE,MAAI,QAAQ;AACZ,QAAM,gCAAgB,IAAA;AACtB,SAAO;AAAA,IACL,KAAK,MAAM;AAAA,IACX,KAAK,CAAC,SAAS;AACb,UACE,KAAK,aAAa,MAAM,YACxB,KAAK,aAAa,MAAM,YACxB,KAAK,iBAAiB,MAAM,gBAC5B,KAAK,YAAY,MAAM,WACvB,KAAK,cAAc,MAAM,WACzB;AACA;AAAA,MACF;AACA,cAAQ;AACR,iBAAW,YAAY,UAAW,UAAA;AAAA,IACpC;AAAA,IACA,WAAW,CAAC,aAAa;AACvB,gBAAU,IAAI,QAAQ;AACtB,aAAO,MAAM;AACX,kBAAU,OAAO,QAAQ;AAAA,MAC3B;AAAA,IACF;AAAA,EAAA;AAEJ;AAGO,MAAM,0BAA0BA,MAAAA,cAA4C,IAAI;AAEvF,MAAM,qBAAqB,MAAM,MAAM;AAAC;AACxC,MAAM,gBAAgB,MAAM;AAOrB,SAAS,oBAAoB,UAAuD;AACzF,QAAM,QAAQC,MAAAA,WAAW,uBAAuB;AAChD,QAAM,QAAQC,MAAAA;AAAAA,KACZ,+BAAO,cAAa;AAAA,KACpB,+BAAO,QAAO;AAAA,KACd,+BAAO,QAAO;AAAA,EAAA;AAEhB,SAAO,aAAa,QAAQ,MAAM,aAAa,WAAW,QAAQ;AACpE;;;;;"}
1
+ {"version":3,"file":"statewire-history-context.cjs","sources":["../../src/provider/statewire-history-context.ts"],"sourcesContent":["import { createContext, useContext, useSyncExternalStore } from 'react';\n\n/**\n * Where the open thread's windowed history stands, as the chat's history edge\n * (`StatewireHistoryEdge`) knows it: whether the host holds older messages the\n * client has not loaded, and how to ask for the next page. The edge publishes\n * it; other surfaces of the same provider read it — the session workbench's\n * Shell pane, whose rows come from the loaded transcript, says its count is\n * partial and offers the earlier commands.\n */\nexport interface StatewireHistoryState {\n /** The thread the edge reported for; `null` while no edge is mounted. */\n threadId: string | null;\n /** The host holds messages older than the loaded window. */\n hasOlder: boolean;\n /** The next page can be asked for: older messages exist and the host's interest cap has room. */\n canLoadOlder: boolean;\n /** A page of older history is in flight. */\n loading: boolean;\n /** Ask for the next page (the edge row's own action); `null` while no edge is mounted. */\n loadOlder: (() => void) | null;\n}\n\nexport const NO_STATEWIRE_HISTORY: StatewireHistoryState = {\n threadId: null,\n hasOlder: false,\n canLoadOlder: false,\n loading: false,\n loadOlder: null,\n};\n\n/** A tiny external store: the edge writes, readers subscribe. */\nexport interface StatewireHistoryStore {\n get: () => StatewireHistoryState;\n set: (next: StatewireHistoryState) => void;\n subscribe: (listener: () => void) => () => void;\n}\n\nexport function createStatewireHistoryStore(): StatewireHistoryStore {\n let state = NO_STATEWIRE_HISTORY;\n const listeners = new Set<() => void>();\n return {\n get: () => state,\n set: (next) => {\n if (\n next.threadId === state.threadId &&\n next.hasOlder === state.hasOlder &&\n next.canLoadOlder === state.canLoadOlder &&\n next.loading === state.loading &&\n next.loadOlder === state.loadOlder\n ) {\n return;\n }\n state = next;\n for (const listener of listeners) listener();\n },\n subscribe: (listener) => {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n };\n}\n\n/** Provided by `AthenaProvider`, one store per provider. */\nexport const StatewireHistoryContext = createContext<StatewireHistoryStore | null>(null);\n\nconst subscribeToNothing = () => () => {};\nconst readNoHistory = () => NO_STATEWIRE_HISTORY;\n\n/**\n * The history state the edge reported for *threadId*, or `null` when none\n * did: no provider, no history edge mounted (a host that renders its own\n * transcript), or another thread's report.\n */\nexport function useStatewireHistory(threadId: string | null): StatewireHistoryState | null {\n const store = useContext(StatewireHistoryContext);\n const state = useSyncExternalStore(\n store?.subscribe ?? subscribeToNothing,\n store?.get ?? readNoHistory,\n store?.get ?? readNoHistory,\n );\n return threadId !== null && state.threadId === threadId ? state : null;\n}\n"],"names":["createContext","useContext","useSyncExternalStore"],"mappings":";;;AAuBO,MAAM,uBAA8C;AAAA,EACzD,UAAU;AAAA,EACV,UAAU;AAAA,EACV,cAAc;AAAA,EACd,SAAS;AAAA,EACT,WAAW;AACb;AASO,SAAS,8BAAqD;AACnE,MAAI,QAAQ;AACZ,QAAM,gCAAgB,IAAA;AACtB,SAAO;AAAA,IACL,KAAK,MAAM;AAAA,IACX,KAAK,CAAC,SAAS;AACb,UACE,KAAK,aAAa,MAAM,YACxB,KAAK,aAAa,MAAM,YACxB,KAAK,iBAAiB,MAAM,gBAC5B,KAAK,YAAY,MAAM,WACvB,KAAK,cAAc,MAAM,WACzB;AACA;AAAA,MACF;AACA,cAAQ;AACR,iBAAW,YAAY,UAAW,UAAA;AAAA,IACpC;AAAA,IACA,WAAW,CAAC,aAAa;AACvB,gBAAU,IAAI,QAAQ;AACtB,aAAO,MAAM;AACX,kBAAU,OAAO,QAAQ;AAAA,MAC3B;AAAA,IACF;AAAA,EAAA;AAEJ;AAGO,MAAM,0BAA0BA,WAAAA,cAA4C,IAAI;AAEvF,MAAM,qBAAqB,MAAM,MAAM;AAAC;AACxC,MAAM,gBAAgB,MAAM;AAOrB,SAAS,oBAAoB,UAAuD;AACzF,QAAM,QAAQC,WAAAA,WAAW,uBAAuB;AAChD,QAAM,QAAQC,WAAAA;AAAAA,KACZ,+BAAO,cAAa;AAAA,KACpB,+BAAO,QAAO;AAAA,KACd,+BAAO,QAAO;AAAA,EAAA;AAEhB,SAAO,aAAa,QAAQ,MAAM,aAAa,WAAW,QAAQ;AACpE;;;;;"}
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const react = require("react");
4
- const AthenaStatewireLifecycleContext = react.createContext(null);
3
+ const require$$0 = require("react");
4
+ const AthenaStatewireLifecycleContext = require$$0.createContext(null);
5
5
  function useAthenaStatewireLifecycle() {
6
- return react.useContext(AthenaStatewireLifecycleContext);
6
+ return require$$0.useContext(AthenaStatewireLifecycleContext);
7
7
  }
8
8
  exports.AthenaStatewireLifecycleContext = AthenaStatewireLifecycleContext;
9
9
  exports.useAthenaStatewireLifecycle = useAthenaStatewireLifecycle;
@@ -1 +1 @@
1
- {"version":3,"file":"statewire-lifecycle-context.cjs","sources":["../../src/provider/statewire-lifecycle-context.tsx"],"sourcesContent":["import { createContext, useContext } from 'react';\nimport type { AthenaStatewireLifecycleState } from '../runtime/statewire-lifecycle';\n\n/**\n * Statewire transport lifecycle (connection status, transport errors,\n * reconnect handle). Provided by `AthenaProvider`; `null` outside the\n * provider, so lifecycle-driven UI renders nothing there.\n */\nexport const AthenaStatewireLifecycleContext =\n createContext<AthenaStatewireLifecycleState | null>(null);\n\n/** Read the statewire lifecycle, or null outside `AthenaProvider`. */\nexport function useAthenaStatewireLifecycle(): AthenaStatewireLifecycleState | null {\n return useContext(AthenaStatewireLifecycleContext);\n}\n"],"names":["createContext","useContext"],"mappings":";;;AAQO,MAAM,kCACXA,MAAAA,cAAoD,IAAI;AAGnD,SAAS,8BAAoE;AAClF,SAAOC,MAAAA,WAAW,+BAA+B;AACnD;;;"}
1
+ {"version":3,"file":"statewire-lifecycle-context.cjs","sources":["../../src/provider/statewire-lifecycle-context.tsx"],"sourcesContent":["import { createContext, useContext } from 'react';\nimport type { AthenaStatewireLifecycleState } from '../runtime/statewire-lifecycle';\n\n/**\n * Statewire transport lifecycle (connection status, transport errors,\n * reconnect handle). Provided by `AthenaProvider`; `null` outside the\n * provider, so lifecycle-driven UI renders nothing there.\n */\nexport const AthenaStatewireLifecycleContext =\n createContext<AthenaStatewireLifecycleState | null>(null);\n\n/** Read the statewire lifecycle, or null outside `AthenaProvider`. */\nexport function useAthenaStatewireLifecycle(): AthenaStatewireLifecycleState | null {\n return useContext(AthenaStatewireLifecycleContext);\n}\n"],"names":["createContext","useContext"],"mappings":";;;AAQO,MAAM,kCACXA,WAAAA,cAAoD,IAAI;AAGnD,SAAS,8BAAoE;AAClF,SAAOC,WAAAA,WAAW,+BAA+B;AACnD;;;"}
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const react = require("react");
4
- const StatewireToolOutputsContext = react.createContext(null);
3
+ const require$$0 = require("react");
4
+ const StatewireToolOutputsContext = require$$0.createContext(null);
5
5
  function useStatewireToolOutputs() {
6
- return react.useContext(StatewireToolOutputsContext);
6
+ return require$$0.useContext(StatewireToolOutputsContext);
7
7
  }
8
8
  exports.StatewireToolOutputsContext = StatewireToolOutputsContext;
9
9
  exports.useStatewireToolOutputs = useStatewireToolOutputs;
@@ -1 +1 @@
1
- {"version":3,"file":"statewire-window-context.cjs","sources":["../../src/provider/statewire-window-context.tsx"],"sourcesContent":["import type { DeepAgentToolOutputStore } from '@athenaintel/agent-runtime';\nimport { createContext, useContext } from 'react';\n\n/**\n * The store of full tool outputs fetched back for a windowed wire's cut tool\n * messages — the SAME instance the thread converts with\n * (`useAthenaStatewireRuntime({ toolOutputs })`), so the edge row's lazy\n * fetch and the converter's substitution meet. Provided by `AthenaProvider`\n * (one per provider, cleared with the acting identity); hosts that mount the\n * runtime themselves pass the store to `StatewireHistoryEdge` directly.\n */\nexport const StatewireToolOutputsContext = createContext<DeepAgentToolOutputStore | null>(null);\n\n/** The provider's tool-output store, or `null` outside `AthenaProvider`. */\nexport function useStatewireToolOutputs(): DeepAgentToolOutputStore | null {\n return useContext(StatewireToolOutputsContext);\n}\n"],"names":["createContext","useContext"],"mappings":";;;AAWO,MAAM,8BAA8BA,MAAAA,cAA+C,IAAI;AAGvF,SAAS,0BAA2D;AACzE,SAAOC,MAAAA,WAAW,2BAA2B;AAC/C;;;"}
1
+ {"version":3,"file":"statewire-window-context.cjs","sources":["../../src/provider/statewire-window-context.tsx"],"sourcesContent":["import type { DeepAgentToolOutputStore } from '@athenaintel/agent-runtime';\nimport { createContext, useContext } from 'react';\n\n/**\n * The store of full tool outputs fetched back for a windowed wire's cut tool\n * messages — the SAME instance the thread converts with\n * (`useAthenaStatewireRuntime({ toolOutputs })`), so the edge row's lazy\n * fetch and the converter's substitution meet. Provided by `AthenaProvider`\n * (one per provider, cleared with the acting identity); hosts that mount the\n * runtime themselves pass the store to `StatewireHistoryEdge` directly.\n */\nexport const StatewireToolOutputsContext = createContext<DeepAgentToolOutputStore | null>(null);\n\n/** The provider's tool-output store, or `null` outside `AthenaProvider`. */\nexport function useStatewireToolOutputs(): DeepAgentToolOutputStore | null {\n return useContext(StatewireToolOutputsContext);\n}\n"],"names":["createContext","useContext"],"mappings":";;;AAWO,MAAM,8BAA8BA,WAAAA,cAA+C,IAAI;AAGvF,SAAS,0BAA2D;AACzE,SAAOC,WAAAA,WAAW,2BAA2B;AAC/C;;;"}
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const react = require("react");
4
- const AthenaThemeStyleContext = react.createContext(
3
+ const require$$0 = require("react");
4
+ const AthenaThemeStyleContext = require$$0.createContext(
5
5
  void 0
6
6
  );
7
7
  function useAthenaThemeStyle() {
8
- return react.useContext(AthenaThemeStyleContext);
8
+ return require$$0.useContext(AthenaThemeStyleContext);
9
9
  }
10
10
  exports.AthenaThemeStyleContext = AthenaThemeStyleContext;
11
11
  exports.useAthenaThemeStyle = useAthenaThemeStyle;
@@ -1 +1 @@
1
- {"version":3,"file":"theme-style-context.cjs","sources":["../../src/provider/theme-style-context.ts"],"sourcesContent":["import { createContext, useContext } from 'react';\n\n/**\n * The provider theme's CSS variables (`themeToStyleVars`), `undefined` without\n * a `theme`. SDK content portaled out of the provider's wrapper (a popover\n * under `document.body`) never inherits the variables the wrapper sets, so it\n * applies these itself to keep the host's palette.\n */\nexport const AthenaThemeStyleContext = createContext<Record<string, string> | undefined>(\n undefined,\n);\n\nexport function useAthenaThemeStyle(): Record<string, string> | undefined {\n return useContext(AthenaThemeStyleContext);\n}\n"],"names":["createContext","useContext"],"mappings":";;;AAQO,MAAM,0BAA0BA,MAAAA;AAAAA,EACrC;AACF;AAEO,SAAS,sBAA0D;AACxE,SAAOC,MAAAA,WAAW,uBAAuB;AAC3C;;;"}
1
+ {"version":3,"file":"theme-style-context.cjs","sources":["../../src/provider/theme-style-context.ts"],"sourcesContent":["import { createContext, useContext } from 'react';\n\n/**\n * The provider theme's CSS variables (`themeToStyleVars`), `undefined` without\n * a `theme`. SDK content portaled out of the provider's wrapper (a popover\n * under `document.body`) never inherits the variables the wrapper sets, so it\n * applies these itself to keep the host's palette.\n */\nexport const AthenaThemeStyleContext = createContext<Record<string, string> | undefined>(\n undefined,\n);\n\nexport function useAthenaThemeStyle(): Record<string, string> | undefined {\n return useContext(AthenaThemeStyleContext);\n}\n"],"names":["createContext","useContext"],"mappings":";;;AAQO,MAAM,0BAA0BA,WAAAA;AAAAA,EACrC;AACF;AAEO,SAAS,sBAA0D;AACxE,SAAOC,WAAAA,WAAW,uBAAuB;AAC3C;;;"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const version = "0.43.0";
3
+ const version = "0.48.0";
4
4
  const packageJson = {
5
5
  version
6
6
  };
@@ -1,4 +1,4 @@
1
- const version = "0.43.0";
1
+ const version = "0.48.0";
2
2
  const packageJson = {
3
3
  version
4
4
  };
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const reactStatewire = require("@assistant-ui/react-statewire");
4
- const react = require("react");
4
+ const require$$0 = require("react");
5
5
  const athenaDiagnostics = require("../diagnostics/athena-diagnostics.cjs");
6
6
  const statewireThreadConfigLane = require("./statewire-thread-config-lane.cjs");
7
7
  const useDeepAgentConfig = require("../agent-runtime/src/use-deep-agent-config.cjs");
@@ -31,22 +31,22 @@ function StatewireThreadConfigLaneSync({
31
31
  serverConfig: lane.config,
32
32
  sendCommand
33
33
  });
34
- const seenRef = react.useRef(config);
35
- const pendingRef = react.useRef(/* @__PURE__ */ new Set());
36
- const attemptsRef = react.useRef(/* @__PURE__ */ new Map());
37
- const closedRef = react.useRef(false);
38
- const patchConfigRef = react.useRef(patchConfig);
34
+ const seenRef = require$$0.useRef(config);
35
+ const pendingRef = require$$0.useRef(/* @__PURE__ */ new Set());
36
+ const attemptsRef = require$$0.useRef(/* @__PURE__ */ new Map());
37
+ const closedRef = require$$0.useRef(false);
38
+ const patchConfigRef = require$$0.useRef(patchConfig);
39
39
  patchConfigRef.current = patchConfig;
40
- const [retryTick, setRetryTick] = react.useState(0);
41
- const retryTimerRef = react.useRef(null);
42
- react.useEffect(
40
+ const [retryTick, setRetryTick] = require$$0.useState(0);
41
+ const retryTimerRef = require$$0.useRef(null);
42
+ require$$0.useEffect(
43
43
  () => () => {
44
44
  if (retryTimerRef.current !== null) clearTimeout(retryTimerRef.current);
45
45
  },
46
46
  []
47
47
  );
48
48
  const landed = lane.landed;
49
- react.useEffect(() => {
49
+ require$$0.useEffect(() => {
50
50
  const pending = pendingRef.current;
51
51
  const attempts = attemptsRef.current;
52
52
  for (const key of statewireThreadConfigLane.PROVIDER_THREAD_CONFIG_KEYS) {
@@ -1 +1 @@
1
- {"version":3,"file":"StatewireThreadConfigLaneSync.cjs","sources":["../../src/runtime/StatewireThreadConfigLaneSync.tsx"],"sourcesContent":["import { useStatewireSendCommand } from '@assistant-ui/react-statewire';\nimport {\n type DeepAgentConfigControllerInputs,\n isConfigSyncUnavailableRejection,\n isConfigWriteForbiddenRejection,\n statewireTransportOutcome,\n useDeepAgentConfigController,\n} from '@athenaintel/agent-runtime';\nimport { useEffect, useRef, useState } from 'react';\nimport { athenaDiagnostics } from '../diagnostics/athena-diagnostics';\nimport type { AthenaStatewireServerLane } from './statewire-server-lane-context';\nimport {\n decideThreadConfigLanePatch,\n PROVIDER_THREAD_CONFIG_KEYS,\n type ProviderThreadConfig,\n type ProviderThreadConfigKey,\n type ProviderThreadConfigPatch,\n patchedThreadConfigKeys,\n sameThreadConfigValue,\n} from './statewire-thread-config-lane';\n\n/** Writes of one change, the first included, before the sync gives up on it. */\nconst MAX_PATCH_ATTEMPTS_PER_CHANGE = 3;\n\n/** Wait before re-writing a change the channel dropped: 1 s, then 4 s. */\nconst RETRY_BACKOFF_MS = [1_000, 4_000] as const;\n\n/**\n * What a `statewire.config` event says about a write: the thread, the model it\n * set (`null`: unset), and the other provider-owned keys it set\n * (`config_keys`), never their values (a system prompt is the host's text).\n */\nfunction configWriteData({\n threadId,\n patch,\n}: {\n threadId: string;\n patch: ProviderThreadConfigPatch;\n}): Record<string, unknown> {\n const otherKeys = patchedThreadConfigKeys(patch).filter((key) => key !== 'model');\n return {\n thread_id: threadId,\n ...(Object.hasOwn(patch, 'model') && { model: patch.model }),\n ...(otherKeys.length > 0 && { config_keys: otherKeys }),\n };\n}\n\n/**\n * Writes the provider-owned thread-config keys to the thread's server config\n * lane when the host changes the props that feed them during an attach:\n * `model`, `systemPrompt` (`system_prompt`), `tools` and `frontendTools`\n * (`enabled_tools`), `workbench` and `knowledgeBase` (`knowledge_base`).\n *\n * Once a thread has a lane (version > 0), agora composes every run from the\n * lane and drops the thread-config keys a send carries, so a model, prompt,\n * tool list or asset list changed after the thread's first turn would never\n * apply. A change of such a prop therefore becomes one `config/patch`\n * carrying exactly the changed keys, each with the value the send would carry\n * (`null` when the send carries none: the key is unset, so the collab agent's\n * own value, or the default, applies). An empty tool or asset list is `null`,\n * as the send omits it.\n *\n * Only a CHANGE is written. A prop's value when the attach starts is never\n * written, even when the lane holds another value: that value is another\n * client's (or an earlier session's) choice for this thread, and an SDK app's\n * global setting must not overwrite it just by opening the thread. Hosts that\n * want the picker to follow the thread read `useAthenaThreadModel`.\n *\n * Decisions read the lane the host itself sent on this attach (`lane`, from\n * the transport), never the rendered thread state: before the attach snapshot\n * lands that state is a placeholder without a lane, or a remembered snapshot\n * with an older one, and comparing a change against either would write over\n * the session's real config. A change made before the snapshot lands waits\n * for it.\n *\n * A version-0 thread needs no write: the next send carries the values and\n * agora's deferral seed persists them. A change stays pending until the lane\n * exists, so a lane an earlier send seeds with the previous values is\n * corrected when it lands. A refusal that can never succeed (a view-only\n * collaborator, a workspace without server config) stops the sync for the\n * attach and is reported on the diagnostics bus. A write the channel dropped\n * (a lost stream, the host's expired verdict) stays pending and is written\n * again after a backoff once the channel is live, at most\n * {@link MAX_PATCH_ATTEMPTS_PER_CHANGE} times per change.\n *\n * The writes go through the `config/*` command family, which agora gates on\n * EDIT on the thread's session asset (`_authorize_config_write`).\n *\n * Mounted under the runtime's `AuiProvider`, keyed by the thread, so each\n * attach starts with nothing pending.\n */\nexport function StatewireThreadConfigLaneSync({\n threadId,\n config,\n lane,\n channelLive,\n}: {\n threadId: string;\n /** The values this thread's sends carry, published with the thread (see the provider). */\n config: ProviderThreadConfig;\n lane: AthenaStatewireServerLane;\n /** Whether the channel can take a command now; writes wait for it. */\n channelLive: boolean;\n}): null {\n const send = useStatewireSendCommand();\n const sendCommand: DeepAgentConfigControllerInputs['sendCommand'] = (command) =>\n Promise.resolve(send(command));\n const { configVersion, custom, patchConfig } = useDeepAgentConfigController({\n serverConfig: lane.config,\n sendCommand,\n });\n\n const seenRef = useRef(config);\n const pendingRef = useRef(new Set<ProviderThreadConfigKey>());\n const attemptsRef = useRef(new Map<ProviderThreadConfigKey, number>());\n const closedRef = useRef(false);\n const patchConfigRef = useRef(patchConfig);\n patchConfigRef.current = patchConfig;\n // Bumped (after a backoff) to re-run the effect for a write the channel dropped.\n const [retryTick, setRetryTick] = useState(0);\n const retryTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n useEffect(\n () => () => {\n if (retryTimerRef.current !== null) clearTimeout(retryTimerRef.current);\n },\n [],\n );\n const landed = lane.landed;\n\n useEffect(() => {\n const pending = pendingRef.current;\n const attempts = attemptsRef.current;\n for (const key of PROVIDER_THREAD_CONFIG_KEYS) {\n if (sameThreadConfigValue(config[key], seenRef.current[key])) continue;\n pending.add(key);\n attempts.set(key, 0);\n }\n seenRef.current = config;\n if (pending.size === 0 || closedRef.current || !channelLive) return;\n const decision = decideThreadConfigLanePatch({\n desired: config,\n keys: pending,\n landed,\n configVersion,\n custom,\n });\n if (decision.kind === 'wait') return;\n pending.clear();\n if (decision.kind === 'done') return;\n\n const { patch } = decision;\n const patchKeys = patchedThreadConfigKeys(patch);\n for (const key of patchKeys) attempts.set(key, (attempts.get(key) ?? 0) + 1);\n const modelOnly = patchKeys.length === 1 && patchKeys[0] === 'model';\n patchConfigRef.current(patch).catch((error: unknown) => {\n const data = configWriteData({ threadId, patch });\n if (isConfigWriteForbiddenRejection(error) || isConfigSyncUnavailableRejection(error)) {\n closedRef.current = true;\n athenaDiagnostics.emit('statewire.config', {\n level: 'warn',\n data: {\n ...data,\n reason: isConfigWriteForbiddenRejection(error)\n ? 'config_write_forbidden'\n : 'config_sync_unavailable',\n },\n });\n return;\n }\n const outcome = statewireTransportOutcome(error);\n if (outcome !== null) {\n // Channel weather (a dropped stream, the host's expired verdict): keep\n // each change pending and write it again after a backoff, once the\n // channel is live, unless its prop has moved on or the attach is gone.\n athenaDiagnostics.emit('statewire.config', {\n level: 'debug',\n data: { ...data, outcome },\n });\n if (outcome === 'unmount') return;\n const retryKeys = patchKeys.filter(\n (key) =>\n sameThreadConfigValue(seenRef.current[key], patch[key] ?? null) &&\n (attempts.get(key) ?? 0) < MAX_PATCH_ATTEMPTS_PER_CHANGE,\n );\n if (retryKeys.length === 0) return;\n for (const key of retryKeys) pendingRef.current.add(key);\n const written = Math.max(...retryKeys.map((key) => attempts.get(key) ?? 1));\n const delay = RETRY_BACKOFF_MS[Math.min(written - 1, RETRY_BACKOFF_MS.length - 1)];\n retryTimerRef.current = setTimeout(() => {\n retryTimerRef.current = null;\n setRetryTick((tick) => tick + 1);\n }, delay);\n return;\n }\n athenaDiagnostics.error(\n 'statewire.config',\n error,\n modelOnly\n ? {\n code: 'statewire_rejected',\n message: 'The statewire host refused the model change',\n hint: 'Inspect error.detail: agora rejections carry a structured {code, message}. The thread keeps running with the model its server config holds.',\n }\n : {\n code: 'statewire_rejected',\n message: 'The statewire host refused the thread config change',\n hint: 'Inspect error.detail: agora rejections carry a structured {code, message}. The thread keeps running with the config its server config holds.',\n },\n data,\n );\n });\n }, [config, landed, configVersion, custom, channelLive, retryTick, threadId]);\n\n return null;\n}\n"],"names":["patchedThreadConfigKeys","useStatewireSendCommand","useDeepAgentConfigController","useRef","useState","useEffect","PROVIDER_THREAD_CONFIG_KEYS","sameThreadConfigValue","decideThreadConfigLanePatch","isConfigWriteForbiddenRejection","isConf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AG,MAAM,QAAA;AAAA,QAAQ,CAC1B;AACD,YAAI,YAAY,UAAW;AAC3B,cAAM,YAAY,UAAU;AAAA,UAC1B,CAAC,QACCJ,0BAAAA,sBAAsB,QAAQ,QAAQ,GAAG,GAAG,MAAM,GAAG,KAAK,IAAI,MAC7D,SAAS,IAAI,GAAG,KAAK,KAAK;AAAA,QAAA;AAE/B,YAAI,UAAU,WAAW,EAAG;AAC5B,mBAAW,OAAO,UAAW,YAAW,QAAQ,IAAI,GAAG;AACvD,cAAM,UAAU,KAAK,IAAI,GAAG,UAAU,IAAI,CAAC,QAAQ,SAAS,IAAI,GAAG,KAAK,CAAC,CAAC;AAC1E,cAAM,QAAQ,iBAAiB,KAAK,IAAI,UAAU,GAAG,iBAAiB,SAAS,CAAC,CAAC;AACjF,sBAAc,UAAU,WAAW,MAAM;AACvC,wBAAc,UAAU;AACxB,uBAAa,CAAC,SAAS,OAAO,CAAC;AAAA,QACjC,GAAG,KAAK;AACR;AAAA,MACF;AACAI,wBAAAA,kBAAkB;AAAA,QAChB;AAAA,QACA;AAAA,QACA,YACI;AAAA,UACE,MAAM;AAAA,UACN,SAAS;AAAA,UACT,MAAM;AAAA,QAAA,IAER;AAAA,UACE,MAAM;AAAA,UACN,SAAS;AAAA,UACT,MAAM;AAAA,QAAA;AAAA,QAEZ;AAAA,MAAA;AAAA,IAEJ,CAAC;AAAA,EACH,GAAG,CAAC,QAAQ,QAAQ,eAAe,QAAQ,aAAa,WAAW,QAAQ,CAAC;AAE5E,SAAO;AACT;;"}
1
+ {"version":3,"file":"StatewireThreadConfigLaneSync.cjs","sources":["../../src/runtime/StatewireThreadConfigLaneSync.tsx"],"sourcesContent":["import { useStatewireSendCommand } from '@assistant-ui/react-statewire';\nimport {\n type DeepAgentConfigControllerInputs,\n isConfigSyncUnavailableRejection,\n isConfigWriteForbiddenRejection,\n statewireTransportOutcome,\n useDeepAgentConfigController,\n} from '@athenaintel/agent-runtime';\nimport { useEffect, useRef, useState } from 'react';\nimport { athenaDiagnostics } from '../diagnostics/athena-diagnostics';\nimport type { AthenaStatewireServerLane } from './statewire-server-lane-context';\nimport {\n decideThreadConfigLanePatch,\n PROVIDER_THREAD_CONFIG_KEYS,\n type ProviderThreadConfig,\n type ProviderThreadConfigKey,\n type ProviderThreadConfigPatch,\n patchedThreadConfigKeys,\n sameThreadConfigValue,\n} from './statewire-thread-config-lane';\n\n/** Writes of one change, the first included, before the sync gives up on it. */\nconst MAX_PATCH_ATTEMPTS_PER_CHANGE = 3;\n\n/** Wait before re-writing a change the channel dropped: 1 s, then 4 s. */\nconst RETRY_BACKOFF_MS = [1_000, 4_000] as const;\n\n/**\n * What a `statewire.config` event says about a write: the thread, the model it\n * set (`null`: unset), and the other provider-owned keys it set\n * (`config_keys`), never their values (a system prompt is the host's text).\n */\nfunction configWriteData({\n threadId,\n patch,\n}: {\n threadId: string;\n patch: ProviderThreadConfigPatch;\n}): Record<string, unknown> {\n const otherKeys = patchedThreadConfigKeys(patch).filter((key) => key !== 'model');\n return {\n thread_id: threadId,\n ...(Object.hasOwn(patch, 'model') && { model: patch.model }),\n ...(otherKeys.length > 0 && { config_keys: otherKeys }),\n };\n}\n\n/**\n * Writes the provider-owned thread-config keys to the thread's server config\n * lane when the host changes the props that feed them during an attach:\n * `model`, `systemPrompt` (`system_prompt`), `tools` and `frontendTools`\n * (`enabled_tools`), `workbench` and `knowledgeBase` (`knowledge_base`).\n *\n * Once a thread has a lane (version > 0), agora composes every run from the\n * lane and drops the thread-config keys a send carries, so a model, prompt,\n * tool list or asset list changed after the thread's first turn would never\n * apply. A change of such a prop therefore becomes one `config/patch`\n * carrying exactly the changed keys, each with the value the send would carry\n * (`null` when the send carries none: the key is unset, so the collab agent's\n * own value, or the default, applies). An empty tool or asset list is `null`,\n * as the send omits it.\n *\n * Only a CHANGE is written. A prop's value when the attach starts is never\n * written, even when the lane holds another value: that value is another\n * client's (or an earlier session's) choice for this thread, and an SDK app's\n * global setting must not overwrite it just by opening the thread. Hosts that\n * want the picker to follow the thread read `useAthenaThreadModel`.\n *\n * Decisions read the lane the host itself sent on this attach (`lane`, from\n * the transport), never the rendered thread state: before the attach snapshot\n * lands that state is a placeholder without a lane, or a remembered snapshot\n * with an older one, and comparing a change against either would write over\n * the session's real config. A change made before the snapshot lands waits\n * for it.\n *\n * A version-0 thread needs no write: the next send carries the values and\n * agora's deferral seed persists them. A change stays pending until the lane\n * exists, so a lane an earlier send seeds with the previous values is\n * corrected when it lands. A refusal that can never succeed (a view-only\n * collaborator, a workspace without server config) stops the sync for the\n * attach and is reported on the diagnostics bus. A write the channel dropped\n * (a lost stream, the host's expired verdict) stays pending and is written\n * again after a backoff once the channel is live, at most\n * {@link MAX_PATCH_ATTEMPTS_PER_CHANGE} times per change.\n *\n * The writes go through the `config/*` command family, which agora gates on\n * EDIT on the thread's session asset (`_authorize_config_write`).\n *\n * Mounted under the runtime's `AuiProvider`, keyed by the thread, so each\n * attach starts with nothing pending.\n */\nexport function StatewireThreadConfigLaneSync({\n threadId,\n config,\n lane,\n channelLive,\n}: {\n threadId: string;\n /** The values this thread's sends carry, published with the thread (see the provider). */\n config: ProviderThreadConfig;\n lane: AthenaStatewireServerLane;\n /** Whether the channel can take a command now; writes wait for it. */\n channelLive: boolean;\n}): null {\n const send = useStatewireSendCommand();\n const sendCommand: DeepAgentConfigControllerInputs['sendCommand'] = (command) =>\n Promise.resolve(send(command));\n const { configVersion, custom, patchConfig } = useDeepAgentConfigController({\n serverConfig: lane.config,\n sendCommand,\n });\n\n const seenRef = useRef(config);\n const pendingRef = useRef(new Set<ProviderThreadConfigKey>());\n const attemptsRef = useRef(new Map<ProviderThreadConfigKey, number>());\n const closedRef = useRef(false);\n const patchConfigRef = useRef(patchConfig);\n patchConfigRef.current = patchConfig;\n // Bumped (after a backoff) to re-run the effect for a write the channel dropped.\n const [retryTick, setRetryTick] = useState(0);\n const retryTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n useEffect(\n () => () => {\n if (retryTimerRef.current !== null) clearTimeout(retryTimerRef.current);\n },\n [],\n );\n const landed = lane.landed;\n\n useEffect(() => {\n const pending = pendingRef.current;\n const attempts = attemptsRef.current;\n for (const key of PROVIDER_THREAD_CONFIG_KEYS) {\n if (sameThreadConfigValue(config[key], seenRef.current[key])) continue;\n pending.add(key);\n attempts.set(key, 0);\n }\n seenRef.current = config;\n if (pending.size === 0 || closedRef.current || !channelLive) return;\n const decision = decideThreadConfigLanePatch({\n desired: config,\n keys: pending,\n landed,\n configVersion,\n custom,\n });\n if (decision.kind === 'wait') return;\n pending.clear();\n if (decision.kind === 'done') return;\n\n const { patch } = decision;\n const patchKeys = patchedThreadConfigKeys(patch);\n for (const key of patchKeys) attempts.set(key, (attempts.get(key) ?? 0) + 1);\n const modelOnly = patchKeys.length === 1 && patchKeys[0] === 'model';\n patchConfigRef.current(patch).catch((error: unknown) => {\n const data = configWriteData({ threadId, patch });\n if (isConfigWriteForbiddenRejection(error) || isConfigSyncUnavailableRejection(error)) {\n closedRef.current = true;\n athenaDiagnostics.emit('statewire.config', {\n level: 'warn',\n data: {\n ...data,\n reason: isConfigWriteForbiddenRejection(error)\n ? 'config_write_forbidden'\n : 'config_sync_unavailable',\n },\n });\n return;\n }\n const outcome = statewireTransportOutcome(error);\n if (outcome !== null) {\n // Channel weather (a dropped stream, the host's expired verdict): keep\n // each change pending and write it again after a backoff, once the\n // channel is live, unless its prop has moved on or the attach is gone.\n athenaDiagnostics.emit('statewire.config', {\n level: 'debug',\n data: { ...data, outcome },\n });\n if (outcome === 'unmount') return;\n const retryKeys = patchKeys.filter(\n (key) =>\n sameThreadConfigValue(seenRef.current[key], patch[key] ?? null) &&\n (attempts.get(key) ?? 0) < MAX_PATCH_ATTEMPTS_PER_CHANGE,\n );\n if (retryKeys.length === 0) return;\n for (const key of retryKeys) pendingRef.current.add(key);\n const written = Math.max(...retryKeys.map((key) => attempts.get(key) ?? 1));\n const delay = RETRY_BACKOFF_MS[Math.min(written - 1, RETRY_BACKOFF_MS.length - 1)];\n retryTimerRef.current = setTimeout(() => {\n retryTimerRef.current = null;\n setRetryTick((tick) => tick + 1);\n }, delay);\n return;\n }\n athenaDiagnostics.error(\n 'statewire.config',\n error,\n modelOnly\n ? {\n code: 'statewire_rejected',\n message: 'The statewire host refused the model change',\n hint: 'Inspect error.detail: agora rejections carry a structured {code, message}. The thread keeps running with the model its server config holds.',\n }\n : {\n code: 'statewire_rejected',\n message: 'The statewire host refused the thread config change',\n hint: 'Inspect error.detail: agora rejections carry a structured {code, message}. The thread keeps running with the config its server config holds.',\n },\n data,\n );\n });\n }, [config, landed, configVersion, custom, channelLive, retryTick, threadId]);\n\n return null;\n}\n"],"names":["patchedThreadConfigKeys","useStatewireSendCommand","useDeepAgentConfigController","useRef","useState","useEffect","PROVIDER_THREAD_CONFIG_KEYS","sameThreadConfigValue","decideThreadConfigLanePatch","isConfigWriteForbiddenRejection","isConfigSyncUnavailableRejection","athenaDiagnostics","statewireTransportOutcome"],"mappings":";;;;;;;;AAsBA,MAAM,gCAAgC;AAGtC,MAAM,mBAAmB,CAAC,KAAO,GAAK;AAOtC,SAAS,gBAAgB;AAAA,EACvB;AAAA,EACA;AACF,GAG4B;AAC1B,QAAM,YAAYA,0BAAAA,wBAAwB,KAAK,EAAE,OAAO,CAAC,QAAQ,QAAQ,OAAO;AAChF,SAAO;AAAA,IACL,WAAW;AAAA,IACX,GAAI,OAAO,OAAO,OAAO,OAAO,KAAK,EAAE,OAAO,MAAM,MAAA;AAAA,IACpD,GAAI,UAAU,SAAS,KAAK,EAAE,aAAa,UAAA;AAAA,EAAU;AAEzD;AA8CO,SAAS,8BAA8B;AAAA,EAC5C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAOS;AACP,QAAM,OAAOC,eAAAA,wBAAA;AACb,QAAM,cAA8D,CAAC,YACnE,QAAQ,QAAQ,KAAK,OAAO,CAAC;AAC/B,QAAM,EAAE,eAAe,QAAQ,YAAA,IAAgBC,mBAAAA,6BAA6B;AAAA,IAC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AAA,UACE,MAAM;AAAA,UACN,SAAS;AAAA,UACT,MAAM;AAAA,QAAA,IAER;AAAA,UACE,MAAM;AAAA,UACN,SAAS;AAAA,UACT,MAAM;AAAA,QAAA;AAAA,QAEZ;AAAA,MAAA;AAAA,IAEJ,CAAC;AAAA,EACH,GAAG,CAAC,QAAQ,QAAQ,eAAe,QAAQ,aAAa,WAAW,QAAQ,CAAC;AAE5E,SAAO;AACT;;"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const react = require("react");
3
+ const require$$0 = require("react");
4
4
  const AthenaCredentialSourceContext = require("../auth/AthenaCredentialSourceContext.cjs");
5
5
  function authRefusalVerdict(connection) {
6
6
  if (!connection) return "unchanged";
@@ -18,14 +18,14 @@ function useRestartAfterAuthRefusal({
18
18
  reconnect
19
19
  }) {
20
20
  const credentials = AthenaCredentialSourceContext.useAthenaCredentialSource();
21
- const refusedRef = react.useRef(false);
22
- const restartingRef = react.useRef(false);
23
- const statusRef = react.useRef(connection == null ? void 0 : connection.status);
21
+ const refusedRef = require$$0.useRef(false);
22
+ const restartingRef = require$$0.useRef(false);
23
+ const statusRef = require$$0.useRef(connection == null ? void 0 : connection.status);
24
24
  statusRef.current = connection == null ? void 0 : connection.status;
25
- const reconnectRef = react.useRef(reconnect);
25
+ const reconnectRef = require$$0.useRef(reconnect);
26
26
  reconnectRef.current = reconnect;
27
27
  const verdict = authRefusalVerdict(connection);
28
- react.useEffect(() => {
28
+ require$$0.useEffect(() => {
29
29
  if (verdict === "refused") {
30
30
  refusedRef.current = true;
31
31
  restartingRef.current = false;
@@ -34,7 +34,7 @@ function useRestartAfterAuthRefusal({
34
34
  restartingRef.current = false;
35
35
  }
36
36
  }, [verdict, connection]);
37
- react.useEffect(() => {
37
+ require$$0.useEffect(() => {
38
38
  if (!credentials) return;
39
39
  const restart = () => {
40
40
  if (!refusedRef.current || restartingRef.current) return;
@@ -1 +1 @@
1
- {"version":3,"file":"auth-refusal-restart.cjs","sources":["../../src/runtime/auth-refusal-restart.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport { useAthenaCredentialSource } from '../auth/AthenaCredentialSourceContext';\n\n/** The slice of a statewire connection state this module reads. */\nexport type AuthRefusalConnection =\n | { status: 'stopped'; reason?: string }\n | { status: 'retrying'; cause?: string }\n | { status: string };\n\n/**\n * What a connection state says about credential refusal: `refused` when the\n * host refused the credential (a terminal `unauthorized` stop, or a retry\n * whose cause is `unauthorized`), `recovered` once it connects, `unchanged`\n * otherwise — including the parked `standby`, which follows a refusal and must\n * keep it on record.\n */\nexport function authRefusalVerdict(\n connection: AuthRefusalConnection | null | undefined,\n): 'refused' | 'recovered' | 'unchanged' {\n if (!connection) return 'unchanged';\n if (connection.status === 'connected') return 'recovered';\n if (connection.status === 'stopped') {\n return 'reason' in connection && connection.reason === 'unauthorized' ? 'refused' : 'unchanged';\n }\n if (connection.status === 'retrying') {\n return 'cause' in connection && connection.cause === 'unauthorized' ? 'refused' : 'unchanged';\n }\n return 'unchanged';\n}\n\n/**\n * Restart a connection the host stopped (or the runtime parked) for refusing\n * its credential, as soon as a new credential exists — instead of leaving the\n * \"Unauthorized\" state up until someone clicks retry or reloads.\n *\n * Two triggers, both only while a refusal is on record, the connection has\n * given up (stopped, or parked in standby) rather than still retrying on its\n * own — its own retry already renews the token — and no restart is under way:\n * the credential source reports a different token (a renewal, a sign-in\n * provider refresh), or the tab becomes visible / comes back online, which\n * forces a renewal first. Each refusal allows one restart per trigger, so a\n * credential the host keeps refusing never loops.\n */\nexport function useRestartAfterAuthRefusal({\n connection,\n reconnect,\n}: {\n connection: AuthRefusalConnection | null | undefined;\n reconnect: (() => void) | null | undefined;\n}): void {\n const credentials = useAthenaCredentialSource();\n const refusedRef = useRef(false);\n const restartingRef = useRef(false);\n const statusRef = useRef(connection?.status);\n statusRef.current = connection?.status;\n const reconnectRef = useRef(reconnect);\n reconnectRef.current = reconnect;\n\n const verdict = authRefusalVerdict(connection);\n useEffect(() => {\n if (verdict === 'refused') {\n refusedRef.current = true;\n restartingRef.current = false;\n } else if (verdict === 'recovered') {\n refusedRef.current = false;\n restartingRef.current = false;\n }\n }, [verdict, connection]);\n\n useEffect(() => {\n if (!credentials) return;\n const restart = () => {\n if (!refusedRef.current || restartingRef.current) return;\n if (statusRef.current === 'retrying' || statusRef.current === 'connecting') return;\n const reconnectNow = reconnectRef.current;\n if (!reconnectNow) return;\n restartingRef.current = true;\n reconnectNow();\n };\n const unsubscribe = credentials.subscribe(restart);\n if (typeof window === 'undefined' || typeof document === 'undefined') return unsubscribe;\n const renewThenRestart = () => {\n if (!refusedRef.current || restartingRef.current) return;\n if (statusRef.current === 'retrying' || statusRef.current === 'connecting') return;\n if (document.visibilityState === 'hidden') return;\n void credentials.getToken({ force: true }).then(restart, restart);\n };\n document.addEventListener('visibilitychange', renewThenRestart);\n window.addEventListener('online', renewThenRestart);\n return () => {\n unsubscribe();\n document.removeEventListener('visibilitychange', renewThenRestart);\n window.removeEventListener('online', renewThenRestart);\n };\n }, [credentials]);\n}\n"],"names":["useAthenaCredentialSource","useRef","useEffect"],"mappings":";;;;AAgBO,SAAS,mBACd,YACuC;AACvC,MAAI,CAAC,WAAY,QAAO;AACxB,MAAI,WAAW,WAAW,YAAa,QAAO;AAC9C,MAAI,WAAW,WAAW,WAAW;AACnC,WAAO,YAAY,cAAc,WAAW,WAAW,iBAAiB,YAAY;AAAA,EACtF;AACA,MAAI,WAAW,WAAW,YAAY;AACpC,WAAO,WAAW,cAAc,WAAW,UAAU,iBAAiB,YAAY;AAAA,EACpF;AACA,SAAO;AACT;AAeO,SAAS,2BAA2B;AAAA,EACzC;AAAA,EACA;AACF,GAGS;AACP,QAAM,cAAcA,8BAAAA,0BAAA;AACpB,QAAM,aAAaC,MAAAA,OAAO,KAAK;AAC/B,QAAM,gBAAgBA,MAAAA,OAAO,KAAK;AAClC,QAAM,YAAYA,MAAAA,OAAO,yCAAY,MAAM;AAC3C,YAAU,UAAU,yCAAY;AAChC,QAAM,eAAeA,MAAAA,OAAO,SAAS;AACrC,eAAa,UAAU;AAEvB,QAAM,UAAU,mBAAmB,UAAU;AAC7CC,QAAAA,UAAU,MAAM;AACd,QAAI,YAAY,WAAW;AACzB,iBAAW,UAAU;AACrB,oBAAc,UAAU;AAAA,IAC1B,WAAW,YAAY,aAAa;AAClC,iBAAW,UAAU;AACrB,oBAAc,UAAU;AAAA,IAC1B;AAAA,EACF,GAAG,CAAC,SAAS,UAAU,CAAC;AAExBA,QAAAA,UAAU,MAAM;AACd,QAAI,CAAC,YAAa;AAClB,UAAM,UAAU,MAAM;AACpB,UAAI,CAAC,WAAW,WAAW,cAAc,QAAS;AAClD,UAAI,UAAU,YAAY,cAAc,UAAU,YAAY,aAAc;AAC5E,YAAM,eAAe,aAAa;AAClC,UAAI,CAAC,aAAc;AACnB,oBAAc,UAAU;AACxB,mBAAA;AAAA,IACF;AACA,UAAM,cAAc,YAAY,UAAU,OAAO;AACjD,QAAI,OAAO,WAAW,eAAe,OAAO,aAAa,YAAa,QAAO;AAC7E,UAAM,mBAAmB,MAAM;AAC7B,UAAI,CAAC,WAAW,WAAW,cAAc,QAAS;AAClD,UAAI,UAAU,YAAY,cAAc,UAAU,YAAY,aAAc;AAC5E,UAAI,SAAS,oBAAoB,SAAU;AAC3C,WAAK,YAAY,SAAS,EAAE,OAAO,MAAM,EAAE,KAAK,SAAS,OAAO;AAAA,IAClE;AACA,aAAS,iBAAiB,oBAAoB,gBAAgB;AAC9D,WAAO,iBAAiB,UAAU,gBAAgB;AAClD,WAAO,MAAM;AACX,kBAAA;AACA,eAAS,oBAAoB,oBAAoB,gBAAgB;AACjE,aAAO,oBAAoB,UAAU,gBAAgB;AAAA,IACvD;AAAA,EACF,GAAG,CAAC,WAAW,CAAC;AAClB;;;"}
1
+ {"version":3,"file":"auth-refusal-restart.cjs","sources":["../../src/runtime/auth-refusal-restart.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport { useAthenaCredentialSource } from '../auth/AthenaCredentialSourceContext';\n\n/** The slice of a statewire connection state this module reads. */\nexport type AuthRefusalConnection =\n | { status: 'stopped'; reason?: string }\n | { status: 'retrying'; cause?: string }\n | { status: string };\n\n/**\n * What a connection state says about credential refusal: `refused` when the\n * host refused the credential (a terminal `unauthorized` stop, or a retry\n * whose cause is `unauthorized`), `recovered` once it connects, `unchanged`\n * otherwise — including the parked `standby`, which follows a refusal and must\n * keep it on record.\n */\nexport function authRefusalVerdict(\n connection: AuthRefusalConnection | null | undefined,\n): 'refused' | 'recovered' | 'unchanged' {\n if (!connection) return 'unchanged';\n if (connection.status === 'connected') return 'recovered';\n if (connection.status === 'stopped') {\n return 'reason' in connection && connection.reason === 'unauthorized' ? 'refused' : 'unchanged';\n }\n if (connection.status === 'retrying') {\n return 'cause' in connection && connection.cause === 'unauthorized' ? 'refused' : 'unchanged';\n }\n return 'unchanged';\n}\n\n/**\n * Restart a connection the host stopped (or the runtime parked) for refusing\n * its credential, as soon as a new credential exists — instead of leaving the\n * \"Unauthorized\" state up until someone clicks retry or reloads.\n *\n * Two triggers, both only while a refusal is on record, the connection has\n * given up (stopped, or parked in standby) rather than still retrying on its\n * own — its own retry already renews the token — and no restart is under way:\n * the credential source reports a different token (a renewal, a sign-in\n * provider refresh), or the tab becomes visible / comes back online, which\n * forces a renewal first. Each refusal allows one restart per trigger, so a\n * credential the host keeps refusing never loops.\n */\nexport function useRestartAfterAuthRefusal({\n connection,\n reconnect,\n}: {\n connection: AuthRefusalConnection | null | undefined;\n reconnect: (() => void) | null | undefined;\n}): void {\n const credentials = useAthenaCredentialSource();\n const refusedRef = useRef(false);\n const restartingRef = useRef(false);\n const statusRef = useRef(connection?.status);\n statusRef.current = connection?.status;\n const reconnectRef = useRef(reconnect);\n reconnectRef.current = reconnect;\n\n const verdict = authRefusalVerdict(connection);\n useEffect(() => {\n if (verdict === 'refused') {\n refusedRef.current = true;\n restartingRef.current = false;\n } else if (verdict === 'recovered') {\n refusedRef.current = false;\n restartingRef.current = false;\n }\n }, [verdict, connection]);\n\n useEffect(() => {\n if (!credentials) return;\n const restart = () => {\n if (!refusedRef.current || restartingRef.current) return;\n if (statusRef.current === 'retrying' || statusRef.current === 'connecting') return;\n const reconnectNow = reconnectRef.current;\n if (!reconnectNow) return;\n restartingRef.current = true;\n reconnectNow();\n };\n const unsubscribe = credentials.subscribe(restart);\n if (typeof window === 'undefined' || typeof document === 'undefined') return unsubscribe;\n const renewThenRestart = () => {\n if (!refusedRef.current || restartingRef.current) return;\n if (statusRef.current === 'retrying' || statusRef.current === 'connecting') return;\n if (document.visibilityState === 'hidden') return;\n void credentials.getToken({ force: true }).then(restart, restart);\n };\n document.addEventListener('visibilitychange', renewThenRestart);\n window.addEventListener('online', renewThenRestart);\n return () => {\n unsubscribe();\n document.removeEventListener('visibilitychange', renewThenRestart);\n window.removeEventListener('online', renewThenRestart);\n };\n }, [credentials]);\n}\n"],"names":["useAthenaCredentialSource","useRef","useEffect"],"mappings":";;;;AAgBO,SAAS,mBACd,YACuC;AACvC,MAAI,CAAC,WAAY,QAAO;AACxB,MAAI,WAAW,WAAW,YAAa,QAAO;AAC9C,MAAI,WAAW,WAAW,WAAW;AACnC,WAAO,YAAY,cAAc,WAAW,WAAW,iBAAiB,YAAY;AAAA,EACtF;AACA,MAAI,WAAW,WAAW,YAAY;AACpC,WAAO,WAAW,cAAc,WAAW,UAAU,iBAAiB,YAAY;AAAA,EACpF;AACA,SAAO;AACT;AAeO,SAAS,2BAA2B;AAAA,EACzC;AAAA,EACA;AACF,GAGS;AACP,QAAM,cAAcA,8BAAAA,0BAAA;AACpB,QAAM,aAAaC,WAAAA,OAAO,KAAK;AAC/B,QAAM,gBAAgBA,WAAAA,OAAO,KAAK;AAClC,QAAM,YAAYA,WAAAA,OAAO,yCAAY,MAAM;AAC3C,YAAU,UAAU,yCAAY;AAChC,QAAM,eAAeA,WAAAA,OAAO,SAAS;AACrC,eAAa,UAAU;AAEvB,QAAM,UAAU,mBAAmB,UAAU;AAC7CC,aAAAA,UAAU,MAAM;AACd,QAAI,YAAY,WAAW;AACzB,iBAAW,UAAU;AACrB,oBAAc,UAAU;AAAA,IAC1B,WAAW,YAAY,aAAa;AAClC,iBAAW,UAAU;AACrB,oBAAc,UAAU;AAAA,IAC1B;AAAA,EACF,GAAG,CAAC,SAAS,UAAU,CAAC;AAExBA,aAAAA,UAAU,MAAM;AACd,QAAI,CAAC,YAAa;AAClB,UAAM,UAAU,MAAM;AACpB,UAAI,CAAC,WAAW,WAAW,cAAc,QAAS;AAClD,UAAI,UAAU,YAAY,cAAc,UAAU,YAAY,aAAc;AAC5E,YAAM,eAAe,aAAa;AAClC,UAAI,CAAC,aAAc;AACnB,oBAAc,UAAU;AACxB,mBAAA;AAAA,IACF;AACA,UAAM,cAAc,YAAY,UAAU,OAAO;AACjD,QAAI,OAAO,WAAW,eAAe,OAAO,aAAa,YAAa,QAAO;AAC7E,UAAM,mBAAmB,MAAM;AAC7B,UAAI,CAAC,WAAW,WAAW,cAAc,QAAS;AAClD,UAAI,UAAU,YAAY,cAAc,UAAU,YAAY,aAAc;AAC5E,UAAI,SAAS,oBAAoB,SAAU;AAC3C,WAAK,YAAY,SAAS,EAAE,OAAO,MAAM,EAAE,KAAK,SAAS,OAAO;AAAA,IAClE;AACA,aAAS,iBAAiB,oBAAoB,gBAAgB;AAC9D,WAAO,iBAAiB,UAAU,gBAAgB;AAClD,WAAO,MAAM;AACX,kBAAA;AACA,eAAS,oBAAoB,oBAAoB,gBAAgB;AACjE,aAAO,oBAAoB,UAAU,gBAAgB;AAAA,IACvD;AAAA,EACF,GAAG,CAAC,WAAW,CAAC;AAClB;;;"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const react = require("react");
3
+ const require$$0 = require("react");
4
4
  const athenaDiagnostics = require("../diagnostics/athena-diagnostics.cjs");
5
5
  const errors = require("../diagnostics/errors.cjs");
6
6
  const CUSTOMER_APP_HOST = /^.+\.(?:(?:[a-z0-9-]+-)?app(?:\.[a-z0-9-]+)*|computer(?:-[a-z0-9-]+)?\.stg|code-sandpack(?:\.[a-z0-9-]+)*)\.athenaintel\.com$/i;
@@ -204,7 +204,7 @@ function useParentBridge({
204
204
  mintRetryPolicy = DEFAULT_MINT_RETRY_POLICY
205
205
  } = {}) {
206
206
  const isInIframe = typeof window !== "undefined" && window.parent !== window;
207
- const runtimeTrustedOrigins = react.useMemo(() => {
207
+ const runtimeTrustedOrigins = require$$0.useMemo(() => {
208
208
  const origins = /* @__PURE__ */ new Set();
209
209
  if (typeof window !== "undefined") {
210
210
  origins.add(window.location.origin);
@@ -217,22 +217,22 @@ function useParentBridge({
217
217
  }
218
218
  return [...origins];
219
219
  }, [trustedOrigins]);
220
- const [state, setState] = react.useState({
220
+ const [state, setState] = require$$0.useState({
221
221
  token: null,
222
222
  ...EMPTY_BRIDGE_URLS,
223
223
  hostAnswered: false,
224
224
  ready: false,
225
225
  error: null
226
226
  });
227
- const mintRetryPolicyRef = react.useRef(mintRetryPolicy);
227
+ const mintRetryPolicyRef = require$$0.useRef(mintRetryPolicy);
228
228
  mintRetryPolicyRef.current = mintRetryPolicy;
229
- const readySignalSent = react.useRef(false);
230
- const configReceived = react.useRef(false);
231
- const parentUrlsRef = react.useRef(EMPTY_BRIDGE_URLS);
232
- const tokenRef = react.useRef(state.token);
229
+ const readySignalSent = require$$0.useRef(false);
230
+ const configReceived = require$$0.useRef(false);
231
+ const parentUrlsRef = require$$0.useRef(EMPTY_BRIDGE_URLS);
232
+ const tokenRef = require$$0.useRef(state.token);
233
233
  tokenRef.current = state.token;
234
- const renewerRef = react.useRef(null);
235
- react.useEffect(() => {
234
+ const renewerRef = require$$0.useRef(null);
235
+ require$$0.useEffect(() => {
236
236
  if (!isInIframe) return;
237
237
  const endBridgeSpan = athenaDiagnostics.athenaDiagnostics.span("auth.bridge", "auth.bridge.start", {
238
238
  mode: "iframe"
@@ -324,7 +324,7 @@ function useParentBridge({
324
324
  for (const resolve of [...tokenWaiters]) resolve(null);
325
325
  };
326
326
  }, [isInIframe, runtimeTrustedOrigins]);
327
- react.useEffect(() => {
327
+ require$$0.useEffect(() => {
328
328
  if (isInIframe) return;
329
329
  if (typeof window === "undefined") return;
330
330
  let cancelled = false;
@@ -517,14 +517,14 @@ function useParentBridge({
517
517
  renewerRef.current = null;
518
518
  };
519
519
  }, [isInIframe]);
520
- const renewToken = react.useCallback(
520
+ const renewToken = require$$0.useCallback(
521
521
  (options) => {
522
522
  var _a;
523
523
  return ((_a = renewerRef.current) == null ? void 0 : _a.call(renewerRef, options)) ?? Promise.resolve(tokenRef.current);
524
524
  },
525
525
  []
526
526
  );
527
- return react.useMemo(() => ({ ...state, renewToken }), [state, renewToken]);
527
+ return require$$0.useMemo(() => ({ ...state, renewToken }), [state, renewToken]);
528
528
  }
529
529
  function useParentAuth() {
530
530
  return useParentBridge().token;
@@ -1 +1 @@
1
- {"version":3,"file":"auth.cjs","sources":["../../src/runtime/auth.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport type { AthenaTokenRenewer } from '../auth/credential-source';\nimport { athenaDiagnostics } from '../diagnostics/athena-diagnostics';\nimport { AthenaSdkError } from '../diagnostics/errors';\n\n/**\n * Hosts under `athenaintel.com` that serve customer-written code:\n * - Marathon's computer and application apps: `{id}.app.athenaintel.com`,\n * `{id}.staging-app.athenaintel.com`, `{id}.canary-app.athenaintel.com`, an\n * environment's `{id}.app.{env}.athenaintel.com`, and the staging wildcard\n * `{id}.computer.stg.athenaintel.com` (and `{id}.computer-canary.stg.athenaintel.com`);\n * - the Sandpack bundler's User Interface previews:\n * `{id}-sandpack.code-sandpack.athenaintel.com` (and `.code-sandpack.{env}.`).\n * They are never a trusted parent and never a backend the bridge points the\n * SDK at.\n */\nconst CUSTOMER_APP_HOST =\n /^.+\\.(?:(?:[a-z0-9-]+-)?app(?:\\.[a-z0-9-]+)*|computer(?:-[a-z0-9-]+)?\\.stg|code-sandpack(?:\\.[a-z0-9-]+)*)\\.athenaintel\\.com$/i;\n\n/** Whether `hostname` serves customer apps (see {@link CUSTOMER_APP_HOST}). */\nexport function isCustomerAppHost(hostname: string): boolean {\n return CUSTOMER_APP_HOST.test(hostname);\n}\n\nfunction isLoopbackHost(hostname: string): boolean {\n return hostname === 'localhost' || hostname === '127.0.0.1' || hostname === '[::1]';\n}\n\nfunction isAthenaHost(hostname: string): boolean {\n return hostname === 'athenaintel.com' || hostname.endsWith('.athenaintel.com');\n}\n\n/**\n * Check whether a PostMessage origin is trusted as the parent.\n * Accepts:\n * - explicit trusted origins passed by the host app\n * - the current iframe origin (for same-origin wrappers like Marathon)\n * - Athena's own hosts under athenaintel.com and localhost (default\n * behavior), except the customer-app hosts Marathon serves\n */\nexport function isTrustedParentOrigin({\n origin,\n trustedOrigins,\n}: {\n origin: string;\n trustedOrigins: string[];\n}): boolean {\n try {\n const normalizedOrigin = new URL(origin).origin;\n if (trustedOrigins.includes(normalizedOrigin)) {\n return true;\n }\n\n const { hostname } = new URL(normalizedOrigin);\n if (isCustomerAppHost(hostname)) {\n return false;\n }\n return isAthenaHost(hostname) || hostname === 'localhost';\n } catch {\n return false;\n }\n}\n\n/** Why {@link isAcceptableBridgeUrl} refused a URL. */\nexport type BridgeUrlRefusal = 'invalid' | 'insecure' | 'customer_app_host' | 'other_domain';\n\n/**\n * Whether a URL a trusted parent sent in `athena-config` may become the\n * SDK's backend, statewire mount or app URL. The SDK sends its bearer token\n * to the first two, so a URL is taken only when it is `https:` (plain\n * `http:` only between loopback hosts, for local development), carries no\n * credentials, is not a customer-code host ({@link CUSTOMER_APP_HOST}), and\n * is one of Athena's own hosts or, for a parent outside `athenaintel.com`,\n * the parent's own host or a subdomain of it. Sibling hosts are not taken:\n * without a public-suffix list `portal.example.co.uk` and `tenant.github.io`\n * cannot be told apart from a private domain, so a wrapper whose backend is\n * elsewhere passes its URLs through `config`. Returns the refusal, or `null`\n * when the URL is acceptable.\n */\nexport function refuseBridgeUrl({\n url,\n parentOrigin,\n}: {\n url: string;\n parentOrigin: string;\n}): BridgeUrlRefusal | null {\n let parsed: URL;\n let parentHostname: string;\n try {\n parsed = new URL(url);\n parentHostname = new URL(parentOrigin).hostname;\n } catch {\n return 'invalid';\n }\n if (parsed.username || parsed.password) return 'invalid';\n const { hostname } = parsed;\n const loopbackPair = isLoopbackHost(hostname) && isLoopbackHost(parentHostname);\n if (parsed.protocol !== 'https:' && !(parsed.protocol === 'http:' && loopbackPair)) {\n return 'insecure';\n }\n if (isCustomerAppHost(hostname)) return 'customer_app_host';\n if (loopbackPair || isAthenaHost(hostname)) return null;\n // Athena and loopback parents point only at Athena's own hosts (above).\n if (isAthenaHost(parentHostname) || isLoopbackHost(parentHostname)) return 'other_domain';\n return hostname === parentHostname || hostname.endsWith(`.${parentHostname}`)\n ? null\n : 'other_domain';\n}\n\n/** {@link refuseBridgeUrl} as a predicate. */\nexport function isAcceptableBridgeUrl(options: { url: string; parentOrigin: string }): boolean {\n return refuseBridgeUrl(options) === null;\n}\n\nexport interface ParentBridgeState {\n /** PropelAuth access token from the parent window. */\n token: string | null;\n /**\n * Statewire sync mount (`…/v2/threads`) minted by the host. `null` when the\n * host minted none; the provider then derives it from the configured\n * `apiUrl`'s origin (or the environment preset).\n */\n statewireSyncUrl: string | null;\n /**\n * Bare Agora API base (no path) minted by the host. `null` when the host\n * minted none; the provider then uses the configured `backendUrl` (or the\n * environment preset).\n */\n backendBaseUrl: string | null;\n /** Athena frontend origin provided by the parent wrapper. */\n appUrl: string | null;\n /**\n * True once a host answered the bridge — a `/_athena/auth` mint or an\n * `athena-config` message — whether or not it minted the statewire fields.\n * Lets the provider tell an outdated host (answered, no mount) from no host\n * at all (the environment preset applies).\n */\n hostAnswered: boolean;\n /** True once config has been received from the parent (or timeout fired). */\n ready: boolean;\n /**\n * Set when the Marathon mint (`/_athena/auth`) gave up. It gives up when it\n * gets a refusal (401, 403, or any 4xx other than 404), a body it cannot\n * read, or a transient failure (5xx, 408, 429, a network error, a timeout)\n * on every attempt of one bounded retry cycle. `code` is\n * `auth_bridge_failed`, or `auth_bridge_timeout` when the last attempt\n * timed out. After that the bridge does not mint again in the background. A\n * forced renewal (`renewToken({ force: true })`) starts one new bounded\n * cycle. A token that an earlier mint handed out is kept (the server still\n * validates it), and the bridge never puts an empty token in its place. The\n * next successful mint clears it. Absent or `null` otherwise.\n */\n error?: AthenaSdkError | null;\n}\n\n/**\n * {@link ParentBridgeState} plus the bridge's token renewal: `force` (the\n * token was refused) asks the host for a new one — a fresh `/_athena/auth`\n * mint on a Marathon origin, or an `athena-auth-ready` request answered by the\n * parent window's next `athena-auth` — and resolves the held token otherwise.\n */\nexport type ParentBridge = ParentBridgeState & { renewToken: AthenaTokenRenewer };\n\nconst BRIDGE_URL_FIELDS = ['statewireSyncUrl', 'backendBaseUrl', 'appUrl'] as const;\n\ntype BridgeUrlField = (typeof BRIDGE_URL_FIELDS)[number];\n\n/** The URL half of {@link ParentBridgeState} — what a host can hand the SDK. */\nexport type ParentBridgeUrls = Pick<ParentBridgeState, BridgeUrlField>;\n\nconst EMPTY_BRIDGE_URLS: ParentBridgeUrls = {\n statewireSyncUrl: null,\n backendBaseUrl: null,\n appUrl: null,\n};\n\n/**\n * Fold a URL payload over the current URL set without vetting it (the\n * same-origin `/_athena/auth` mint body; a parent's `athena-config` goes\n * through {@link acceptBridgeConfigMessage}). A field is taken only when it is\n * a string; anything else keeps the previous value. Keys outside\n * {@link BridgeUrlField} (a legacy parent's `apiUrl` / `backendUrl` among\n * them) are dropped.\n */\nexport function mergeBridgeConfigMessage(\n previous: ParentBridgeUrls,\n payload: Partial<Record<BridgeUrlField, unknown>>,\n): ParentBridgeUrls {\n const next: ParentBridgeUrls = {\n statewireSyncUrl: previous.statewireSyncUrl,\n backendBaseUrl: previous.backendBaseUrl,\n appUrl: previous.appUrl,\n };\n for (const field of BRIDGE_URL_FIELDS) {\n const value = payload[field];\n if (typeof value === 'string') {\n next[field] = value;\n }\n }\n return next;\n}\n\n/** A URL field of an `athena-config` message that was not taken, and why. */\nexport interface RejectedBridgeUrl {\n field: BridgeUrlField;\n reason: BridgeUrlRefusal | 'changed';\n}\n\n/**\n * Fold an `athena-config` message from a trusted parent over the current URL\n * set, taking only what is safe to point the SDK's bearer at: each string\n * field must pass {@link refuseBridgeUrl} against the parent's origin. The\n * first config message sets the URLs; once `locked` (a config message was\n * already taken) a value that differs from the held one, including a field\n * the first message left unset, is refused (`changed`), so a later message\n * cannot repoint a running SDK. Resending the same value is fine.\n */\nexport function acceptBridgeConfigMessage({\n previous,\n payload,\n parentOrigin,\n locked = false,\n}: {\n previous: ParentBridgeUrls;\n payload: Partial<Record<BridgeUrlField, unknown>>;\n parentOrigin: string;\n locked?: boolean;\n}): { urls: ParentBridgeUrls; rejected: RejectedBridgeUrl[] } {\n const urls: ParentBridgeUrls = {\n statewireSyncUrl: previous.statewireSyncUrl,\n backendBaseUrl: previous.backendBaseUrl,\n appUrl: previous.appUrl,\n };\n const rejected: RejectedBridgeUrl[] = [];\n for (const field of BRIDGE_URL_FIELDS) {\n const value = payload[field];\n if (typeof value !== 'string') continue;\n const held = previous[field];\n if (locked || held !== null) {\n if (held !== value) rejected.push({ field, reason: 'changed' });\n continue;\n }\n const refusal = refuseBridgeUrl({ url: value, parentOrigin });\n if (refusal !== null) {\n rejected.push({ field, reason: refusal });\n continue;\n }\n urls[field] = value;\n }\n return { urls, rejected };\n}\n\n/**\n * Read the URL set out of a `/_athena/auth` mint body. Non-string fields are\n * `null`.\n */\nexport function readAuthMintUrls(data: Partial<Record<BridgeUrlField, unknown>>): ParentBridgeUrls {\n return mergeBridgeConfigMessage(EMPTY_BRIDGE_URLS, data);\n}\n\nexport interface ParentBridgeOptions {\n /**\n * Exact parent origins that are allowed to send auth/config via postMessage.\n * Useful for private-cloud or custom-domain deployments.\n */\n trustedOrigins?: string[];\n /** @internal Overrides {@link DEFAULT_MINT_RETRY_POLICY}; used by tests. */\n mintRetryPolicy?: MintRetryPolicy;\n}\n\n/** How long to wait for the parent bridge before falling back to defaults. */\nconst BRIDGE_TIMEOUT_MS = 2000;\n/** How long a renewal waits for the parent window to answer `athena-auth-ready`. */\nconst PARENT_TOKEN_RENEWAL_TIMEOUT_MS = 5000;\nconst TOKEN_REFRESH_BUFFER_MS = 5 * 60 * 1000;\nconst TOKEN_REFRESH_MIN_DELAY_MS = 60 * 1000;\nconst DEFAULT_TOKEN_REFRESH_MS = 55 * 60 * 1000;\nconst EMPTY_TRUSTED_ORIGINS: string[] = [];\n\n/**\n * How one Marathon mint cycle retries. A cycle is the initial acquisition, a\n * scheduled refresh, or a forced renewal. It sends at most `maxAttempts`\n * requests. It retries only a transient failure (5xx, 408, 429, a network\n * error, a timeout), after a capped exponential backoff with jitter, and then\n * it gives up. Nothing retries in the background after a cycle gave up.\n */\nexport interface MintRetryPolicy {\n /** Requests per cycle, the first one included. */\n maxAttempts: number;\n /** Ceiling of the delay before the first retry; it doubles for each retry. */\n baseDelayMs: number;\n /** Largest delay before any retry. */\n maxDelayMs: number;\n /** How long one request can take before it is aborted and counted as a timeout. */\n timeoutMs: number;\n /** Source of jitter in `[0, 1)`. */\n random: () => number;\n}\n\nexport const DEFAULT_MINT_RETRY_POLICY: MintRetryPolicy = {\n maxAttempts: 4,\n baseDelayMs: 500,\n maxDelayMs: 4000,\n timeoutMs: BRIDGE_TIMEOUT_MS,\n random: Math.random,\n};\n\n/** Untrusted shape of the `/_athena/auth` mint body; every field is type-guarded on read. */\ninterface AthenaAuthResponse {\n token?: unknown;\n statewireSyncUrl?: unknown;\n backendBaseUrl?: unknown;\n appUrl?: unknown;\n expires_at?: unknown;\n}\n\nconst normalizeOrigin = (value: string): string | null => {\n try {\n return new URL(value).origin;\n } catch {\n return null;\n }\n};\n\nexport const getTokenRefreshDelay = (expiresAt: unknown, nowMs: number): number => {\n if (typeof expiresAt !== 'string') {\n return DEFAULT_TOKEN_REFRESH_MS;\n }\n\n const expiresAtMs = Date.parse(expiresAt);\n if (!Number.isFinite(expiresAtMs)) {\n return DEFAULT_TOKEN_REFRESH_MS;\n }\n\n return Math.max(TOKEN_REFRESH_MIN_DELAY_MS, expiresAtMs - nowMs - TOKEN_REFRESH_BUFFER_MS);\n};\n\n/**\n * The delay before retry number `retry` of a mint cycle (1 is the first\n * retry). The ceiling is `min(maxDelayMs, baseDelayMs * 2^(retry - 1))`, and\n * equal jitter puts the wait between half of that ceiling and all of it, so\n * viewers whose mint failed at the same time do not retry at the same time.\n */\nexport function getMintRetryDelay({\n retry,\n policy = DEFAULT_MINT_RETRY_POLICY,\n}: {\n retry: number;\n policy?: Pick<MintRetryPolicy, 'baseDelayMs' | 'maxDelayMs' | 'random'>;\n}): number {\n const safeRetry = Number.isFinite(retry) ? Math.max(1, Math.floor(retry)) : 1;\n const ceiling = Math.min(policy.maxDelayMs, policy.baseDelayMs * 2 ** (safeRetry - 1));\n const jitter = Math.min(1, Math.max(0, policy.random()));\n return Math.round(ceiling / 2 + (ceiling / 2) * jitter);\n}\n\n/** A mint status worth another attempt: the host, or something in front of it, is briefly unwell. */\nexport function isRetryableMintStatus(status: number): boolean {\n return status >= 500 || status === 408 || status === 429;\n}\n\n/** A failed `/_athena/auth` request that is worth another attempt. */\ninterface TransientMintFailure {\n kind: 'transient';\n status: number | null;\n reason: 'status' | 'network' | 'timeout';\n hostError: string | null;\n cause?: unknown;\n}\n\n/** A failed `/_athena/auth` request that ends its cycle at once. */\ninterface RefusedMintFailure {\n kind: 'refused';\n status: number;\n /** `status`: a 4xx other than 404, 408 and 429. `invalid_body`: a 2xx whose body is not a JSON object. */\n reason: 'status' | 'invalid_body';\n hostError: string | null;\n}\n\nexport type MintFailure = TransientMintFailure | RefusedMintFailure;\n\n/** The outcome of one `/_athena/auth` request. */\ntype MintAttempt =\n | { kind: 'minted'; data: AthenaAuthResponse }\n /** 404: this is not a Marathon origin. */\n | { kind: 'absent'; status: number }\n | MintFailure\n | { kind: 'cancelled' };\n\n/** The `error` string of a Marathon failure body (`{\"error\":\"mint_failed\"}`), if any. */\nasync function readHostError(resp: Response): Promise<string | null> {\n try {\n const body: unknown = await resp.json();\n if (body && typeof body === 'object' && 'error' in body) {\n const value = (body as { error?: unknown }).error;\n return typeof value === 'string' ? value.slice(0, 100) : null;\n }\n } catch {\n // An empty or non-JSON error body tells nothing more than the status.\n }\n return null;\n}\n\nconst MINT_RETRY_NOTE =\n 'The SDK stopped retrying and does not connect without a credential. Remount the provider, or call renewToken({ force: true }), to try again.';\n\nfunction mintFailureHint(failure: MintFailure): string {\n if (failure.kind === 'transient') {\n return `The host could not mint a viewer token. Check the Marathon and Agora logs. ${MINT_RETRY_NOTE}`;\n }\n if (failure.reason === 'invalid_body') {\n return `The host answered /_athena/auth without a JSON mint body, so this origin is not a Marathon bridge. Pass token, getToken or apiKey. ${MINT_RETRY_NOTE}`;\n }\n if (failure.status === 401) {\n return `The host has no session for this viewer. Sign in again through the app URL. ${MINT_RETRY_NOTE}`;\n }\n if (failure.status === 403) {\n return `The host does not give this viewer access to the app. ${MINT_RETRY_NOTE}`;\n }\n return `The host refused the mint request. ${MINT_RETRY_NOTE}`;\n}\n\n/** The typed error that a mint cycle reports when it gives up. */\nexport function mintFailureError({\n failure,\n attempts,\n phase,\n}: {\n failure: MintFailure;\n attempts: number;\n phase: 'initial' | 'renewal';\n}): AthenaSdkError {\n const timedOut = failure.kind === 'transient' && failure.reason === 'timeout';\n const answer =\n failure.status !== null ? `HTTP ${failure.status}` : timedOut ? 'a timeout' : 'a network error';\n const message =\n failure.kind === 'transient'\n ? `The host auth bridge (/_athena/auth) failed ${attempts} time${attempts === 1 ? '' : 's'} (last: ${answer}).`\n : failure.reason === 'invalid_body'\n ? `The host auth bridge (/_athena/auth) answered ${answer} without a JSON mint body.`\n : `The host auth bridge (/_athena/auth) refused the mint (${answer}).`;\n return new AthenaSdkError({\n code: timedOut ? 'auth_bridge_timeout' : 'auth_bridge_failed',\n message,\n hint: mintFailureHint(failure),\n ...(failure.status !== null && { status: failure.status }),\n ...(failure.hostError !== null && { detail: { code: failure.hostError } }),\n ...(failure.kind === 'transient' && failure.cause !== undefined && { cause: failure.cause }),\n context: {\n mode: 'marathon',\n phase,\n attempts,\n reason: failure.reason,\n host_error: failure.hostError,\n },\n });\n}\n\n/**\n * Listens for auth tokens AND environment config from the host environment.\n *\n * Two transport modes, picked automatically:\n *\n * 1. **Iframe (legacy / Olympus inline preview)**: a parent window posts\n * `athena-config` and `athena-auth` via PostMessage. The hook also posts\n * `athena-auth-ready` so the parent knows when to (re-)send. Only the\n * window that frames the app (`event.source === window.parent`) on a\n * trusted origin ({@link isTrustedParentOrigin}) is heard, and an\n * `athena-config` URL is taken only once and only when it passes\n * {@link refuseBridgeUrl}.\n *\n * 2. **Standalone (Marathon-served deploy URL)**: top-level navigation, no\n * parent. The hook fetches `/_athena/auth` on its own origin. Marathon\n * validates its session cookie (sent by the browser automatically) and\n * returns `{ token, statewireSyncUrl, backendBaseUrl, appUrl }` — the\n * statewire mount, the bare Agora base and the app origin. A 404 means\n * we're not on a Marathon origin — the hook falls through with empty\n * state. Any other failure fails closed: one bounded retry cycle\n * ({@link MintRetryPolicy}) for a transient failure, none for a refusal,\n * and then `error` is set and `ready` flips with no token — never an\n * empty or anonymous one.\n *\n * In both modes the app never blocks indefinitely: the iframe bridge flips\n * `ready: true` after a timeout, and a Marathon mint cycle ends after at most\n * `maxAttempts` requests.\n */\nexport function useParentBridge({\n trustedOrigins = EMPTY_TRUSTED_ORIGINS,\n mintRetryPolicy = DEFAULT_MINT_RETRY_POLICY,\n}: ParentBridgeOptions = {}): ParentBridge {\n const isInIframe = typeof window !== 'undefined' && window.parent !== window;\n const runtimeTrustedOrigins = useMemo(() => {\n const origins = new Set<string>();\n\n if (typeof window !== 'undefined') {\n origins.add(window.location.origin);\n }\n\n for (const trustedOrigin of trustedOrigins) {\n const normalizedOrigin = normalizeOrigin(trustedOrigin);\n if (normalizedOrigin) {\n origins.add(normalizedOrigin);\n }\n }\n\n return [...origins];\n }, [trustedOrigins]);\n\n const [state, setState] = useState<ParentBridgeState>({\n token: null,\n ...EMPTY_BRIDGE_URLS,\n hostAnswered: false,\n ready: false,\n error: null,\n });\n // Read when a mint cycle starts, so a caller's inline policy object does not\n // restart the bridge on every render.\n const mintRetryPolicyRef = useRef(mintRetryPolicy);\n mintRetryPolicyRef.current = mintRetryPolicy;\n const readySignalSent = useRef(false);\n const configReceived = useRef(false);\n // The URLs the parent has set so far: a later `athena-config` may not change them.\n const parentUrlsRef = useRef<ParentBridgeUrls>(EMPTY_BRIDGE_URLS);\n const tokenRef = useRef<string | null>(state.token);\n tokenRef.current = state.token;\n // Installed by whichever transport mode is active (iframe or Marathon).\n const renewerRef = useRef<AthenaTokenRenewer | null>(null);\n\n useEffect(() => {\n if (!isInIframe) return;\n\n const endBridgeSpan = athenaDiagnostics.span('auth.bridge', 'auth.bridge.start', {\n mode: 'iframe',\n });\n let spanEnded = false;\n const endOnce: typeof endBridgeSpan = (name, options) => {\n if (spanEnded) return 0;\n spanEnded = true;\n return endBridgeSpan(name, options);\n };\n\n // Renewals waiting for the parent's next `athena-auth`.\n const tokenWaiters = new Set<(token: string | null) => void>();\n\n const handler = (event: MessageEvent) => {\n // Only the window that frames this app speaks for the host: a popup,\n // an opener or a sibling frame on a trusted origin does not.\n if (event.source !== window.parent) return;\n if (\n !isTrustedParentOrigin({ origin: event.origin, trustedOrigins: runtimeTrustedOrigins })\n ) {\n return;\n }\n if (!event.data || typeof event.data !== 'object') return;\n\n if (event.data.type === 'athena-config') {\n const { urls, rejected } = acceptBridgeConfigMessage({\n previous: parentUrlsRef.current,\n payload: event.data,\n parentOrigin: event.origin,\n locked: configReceived.current,\n });\n configReceived.current = true;\n parentUrlsRef.current = urls;\n for (const { field, reason } of rejected) {\n athenaDiagnostics.emit('auth.bridge.config_rejected', {\n level: 'warn',\n data: { mode: 'iframe', field, reason },\n });\n }\n setState((prev) => ({\n ...prev,\n ...urls,\n hostAnswered: true,\n // Don't set ready here — wait for athena-auth (token) or the timeout.\n // Setting ready on config alone causes a race: the thread list fires\n // before the token arrives, falling back to X-API-KEY.\n }));\n }\n\n if (event.data.type === 'athena-auth' && typeof event.data.token === 'string') {\n endOnce('auth.bridge.ready', { data: { mode: 'iframe' } });\n athenaDiagnostics.emit('auth.token.acquired', {\n level: 'debug',\n data: { source: 'iframe-postmessage' },\n });\n setState((prev) => ({\n ...prev,\n token: event.data.token,\n ready: true,\n }));\n tokenRef.current = event.data.token;\n for (const resolve of [...tokenWaiters]) resolve(event.data.token);\n }\n };\n window.addEventListener('message', handler);\n\n // A renewal asks the parent to send its current token again — the same\n // `athena-auth-ready` handshake a parent already answers — and settles on\n // the next `athena-auth`, or on the held token when none arrives in time.\n renewerRef.current = ({ force }) => {\n if (!force) return Promise.resolve(tokenRef.current);\n return new Promise<string | null>((resolve) => {\n const settle = (token: string | null) => {\n clearTimeout(timer);\n tokenWaiters.delete(settle);\n resolve(token ?? tokenRef.current);\n };\n const timer = setTimeout(() => settle(null), PARENT_TOKEN_RENEWAL_TIMEOUT_MS);\n tokenWaiters.add(settle);\n window.parent.postMessage({ type: 'athena-auth-ready' }, '*');\n });\n };\n\n if (!readySignalSent.current) {\n window.parent.postMessage({ type: 'athena-auth-ready' }, '*');\n readySignalSent.current = true;\n }\n\n const timer = setTimeout(() => {\n endOnce('auth.bridge.timeout', {\n data: {\n mode: 'iframe',\n timeout_ms: BRIDGE_TIMEOUT_MS,\n config_received: configReceived.current,\n },\n });\n setState((prev) => (prev.ready ? prev : { ...prev, ready: true }));\n }, BRIDGE_TIMEOUT_MS);\n\n return () => {\n window.removeEventListener('message', handler);\n clearTimeout(timer);\n renewerRef.current = null;\n for (const resolve of [...tokenWaiters]) resolve(null);\n };\n }, [isInIframe, runtimeTrustedOrigins]);\n\n useEffect(() => {\n if (isInIframe) return;\n if (typeof window === 'undefined') return;\n\n let cancelled = false;\n let refreshTimer: ReturnType<typeof setTimeout> | null = null;\n let controller: AbortController | null = null;\n let inFlight: Promise<string | null> | null = null;\n let retryWait: { timer: ReturnType<typeof setTimeout>; resolve: () => void } | null = null;\n\n const clearRefreshTimer = () => {\n if (refreshTimer) {\n clearTimeout(refreshTimer);\n refreshTimer = null;\n }\n };\n\n const endRetryWait = () => {\n if (!retryWait) return;\n clearTimeout(retryWait.timer);\n const { resolve } = retryWait;\n retryWait = null;\n resolve();\n };\n\n /** The backoff between two attempts of one cycle; unmounting ends it at once. */\n const waitBeforeRetry = (delayMs: number) =>\n new Promise<void>((resolve) => {\n retryWait = { timer: setTimeout(endRetryWait, delayMs), resolve };\n });\n\n // The only background mint: once per token, shortly before it expires. It\n // is not rescheduled when its cycle gives up. A forced renewal that gives\n // up leaves it in place on purpose: the held token is still live, and\n // this one bounded cycle keeps a viewer connected past a brief outage.\n const scheduleRefresh = (expiresAt: unknown) => {\n clearRefreshTimer();\n const delay = getTokenRefreshDelay(expiresAt, Date.now());\n refreshTimer = setTimeout(() => {\n refreshTimer = null;\n void fetchAuth({ initial: false });\n }, delay);\n };\n\n /** One `/_athena/auth` request, classified. */\n const mintOnce = async (timeoutMs: number): Promise<MintAttempt> => {\n const requestController = new AbortController();\n controller = requestController;\n let timedOut = false;\n const requestTimer = setTimeout(() => {\n timedOut = true;\n requestController.abort();\n }, timeoutMs);\n\n try {\n const resp = await fetch('/_athena/auth', {\n credentials: 'include',\n headers: { Accept: 'application/json' },\n signal: requestController.signal,\n });\n if (cancelled) return { kind: 'cancelled' };\n // Not a Marathon origin: expected for standalone apps and local dev.\n if (resp.status === 404) return { kind: 'absent', status: resp.status };\n if (!resp.ok) {\n const hostError = await readHostError(resp);\n if (cancelled) return { kind: 'cancelled' };\n // `readHostError` swallows the abort of a stalled error body. Only a\n // retryable status becomes a timeout: a refusal (401, 403, other\n // 4xx) is known from its status and still fails after one request.\n if (timedOut && isRetryableMintStatus(resp.status)) {\n return { kind: 'transient', status: null, reason: 'timeout', hostError: null };\n }\n return isRetryableMintStatus(resp.status)\n ? { kind: 'transient', status: resp.status, reason: 'status', hostError }\n : { kind: 'refused', status: resp.status, reason: 'status', hostError };\n }\n\n let data: unknown;\n try {\n data = await resp.json();\n } catch (error) {\n if (cancelled) return { kind: 'cancelled' };\n if (timedOut) {\n return { kind: 'transient', status: null, reason: 'timeout', hostError: null, cause: error };\n }\n return { kind: 'refused', status: resp.status, reason: 'invalid_body', hostError: null };\n }\n if (cancelled) return { kind: 'cancelled' };\n // Marathon's 200 always carries a token. A 2xx without one is a\n // broken mint: it must not replace a held token or count as success.\n const token = data && typeof data === 'object' ? (data as { token?: unknown }).token : null;\n if (typeof token !== 'string' || token === '') {\n return { kind: 'refused', status: resp.status, reason: 'invalid_body', hostError: null };\n }\n return { kind: 'minted', data: data as AthenaAuthResponse };\n } catch (error) {\n if (cancelled) return { kind: 'cancelled' };\n if (timedOut) {\n return { kind: 'transient', status: null, reason: 'timeout', hostError: null, cause: error };\n }\n return { kind: 'transient', status: null, reason: 'network', hostError: null, cause: error };\n } finally {\n clearTimeout(requestTimer);\n if (controller === requestController) controller = null;\n }\n };\n\n /**\n * One bounded mint cycle: the initial acquisition (a span the provider\n * waits on) or a renewal (the scheduled refresh, a forced renewal). It\n * retries a transient failure up to `maxAttempts` requests in all, with\n * a capped, jittered backoff. On a refusal, or after the last attempt, it\n * gives up: it reports one typed error, sets `error`, keeps any token an\n * earlier mint handed out, and schedules nothing.\n */\n const runMintCycle = async ({ initial }: { initial: boolean }): Promise<string | null> => {\n const policy = mintRetryPolicyRef.current;\n const maxAttempts = Math.max(1, Math.floor(policy.maxAttempts));\n const phase = initial ? 'initial' : 'renewal';\n const endBridgeSpan = initial\n ? athenaDiagnostics.span('auth.bridge', 'auth.bridge.start', { mode: 'marathon' })\n : null;\n\n let attempts = 0;\n let lastFailure: MintFailure | null = null;\n while (attempts < maxAttempts) {\n attempts += 1;\n const outcome = await mintOnce(policy.timeoutMs);\n if (cancelled || outcome.kind === 'cancelled') return null;\n\n if (outcome.kind === 'absent') {\n endBridgeSpan?.('auth.bridge.absent', {\n data: { mode: 'marathon', status: outcome.status },\n });\n // 404 means no bridge here, so an earlier mint failure no longer\n // applies; the provider falls back to its other credentials.\n setState((prev) =>\n prev.ready && prev.error == null ? prev : { ...prev, ready: true, error: null },\n );\n return null;\n }\n\n if (outcome.kind === 'minted') {\n const { data } = outcome;\n if (endBridgeSpan) {\n endBridgeSpan('auth.bridge.ready', {\n data: { mode: 'marathon', has_token: typeof data.token === 'string', attempts },\n });\n athenaDiagnostics.emit('auth.token.acquired', {\n level: 'debug',\n data: { source: 'marathon', expires_at: data.expires_at },\n });\n } else {\n athenaDiagnostics.emit('auth.token.refreshed', {\n level: 'debug',\n data: { source: 'marathon', expires_at: data.expires_at, attempts },\n });\n }\n const token = typeof data.token === 'string' ? data.token : null;\n setState({\n token,\n ...readAuthMintUrls(data),\n hostAnswered: true,\n ready: true,\n error: null,\n });\n tokenRef.current = token;\n scheduleRefresh(data.expires_at);\n return token;\n }\n\n lastFailure = outcome;\n if (outcome.kind === 'refused' || attempts >= maxAttempts) break;\n\n const delayMs = getMintRetryDelay({ retry: attempts, policy });\n athenaDiagnostics.emit('auth.bridge.retry', {\n level: 'warn',\n data: {\n mode: 'marathon',\n phase,\n status: outcome.status,\n reason: outcome.reason,\n host_error: outcome.hostError,\n attempt: attempts,\n max_attempts: maxAttempts,\n delay_ms: delayMs,\n },\n });\n await waitBeforeRetry(delayMs);\n if (cancelled) return null;\n }\n\n if (!lastFailure) return null;\n const error = mintFailureError({ failure: lastFailure, attempts, phase });\n const failureData = {\n mode: 'marathon',\n phase,\n status: lastFailure.status,\n reason: lastFailure.reason,\n attempts,\n };\n if (endBridgeSpan) {\n endBridgeSpan(\n error.code === 'auth_bridge_timeout' ? 'auth.bridge.timeout' : 'auth.bridge.error',\n { data: failureData, error },\n );\n } else {\n athenaDiagnostics.emit('auth.token.refresh_failed', {\n level: 'error',\n data: failureData,\n error,\n });\n }\n setState((prev) => ({ ...prev, error, ready: true }));\n return null;\n };\n\n // One mint cycle at a time. The initial acquisition, a scheduled refresh\n // and forced renewals that overlap share the cycle in flight (its\n // requests, their timeouts and its backoff) instead of starting their own,\n // so concurrent callers never multiply the requests.\n const fetchAuth = (options: { initial: boolean }): Promise<string | null> => {\n inFlight ??= runMintCycle(options).finally(() => {\n inFlight = null;\n });\n return inFlight;\n };\n\n // A forced renewal mints now instead of waiting for the scheduled refresh\n // (joining a cycle already in flight), and may start a new bounded cycle\n // after one gave up. The schedule restarts from the new token's expiry.\n renewerRef.current = ({ force }) => {\n if (!force) return Promise.resolve(tokenRef.current);\n return fetchAuth({ initial: false }).then((token) => token ?? tokenRef.current);\n };\n\n void fetchAuth({ initial: true });\n\n return () => {\n cancelled = true;\n controller?.abort();\n clearRefreshTimer();\n endRetryWait();\n renewerRef.current = null;\n };\n }, [isInIframe]);\n\n const renewToken = useCallback<AthenaTokenRenewer>(\n (options) => renewerRef.current?.(options) ?? Promise.resolve(tokenRef.current),\n [],\n );\n\n return useMemo(() => ({ ...state, renewToken }), [state, renewToken]);\n}\n\n/**\n * Legacy hook — returns just the auth token from the parent bridge.\n * Prefer useParentBridge() for new code.\n */\nexport function useParentAuth(): string | null {\n return useParentBridge().token;\n}\n"],"names":["AthenaSdkError","useMemo","useState","useRef","useEffect","athenaDiagnostics","timer","useCallback"],"mappings":";;;;;AAgBA,MAAM,oBACJ;AAGK,SAAS,kBAAkB,UAA2B;AAC3D,SAAO,kBAAkB,KAAK,QAAQ;AACxC;AAEA,SAAS,eAAe,UAA2B;AACjD,SAAO,aAAa,eAAe,aAAa,eAAe,aAAa;AAC9E;AAEA,SAAS,aAAa,UAA2B;AAC/C,SAAO,aAAa,qBAAqB,SAAS,SAAS,kBAAkB;AAC/E;AAUO,SAAS,sBAAsB;AAAA,EACpC;AAAA,EACA;AACF,GAGY;AACV,MAAI;AACF,UAAM,mBAAmB,IAAI,IAAI,MAAM,EAAE;AACzC,QAAI,eAAe,SAAS,gBAAgB,GAAG;AAC7C,aAAO;AAAA,IACT;AAEA,UAAM,EAA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O;AAAA;AAAA,IAC9E,CAAA;AAAA,EAAC;AAGH,SAAON,MAAAA,QAAQ,OAAO,EAAE,GAAG,OAAO,eAAe,CAAC,OAAO,UAAU,CAAC;AACtE;AAMO,SAAS,gBAA+B;AAC7C,SAAO,kBAAkB;AAC3B;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"auth.cjs","sources":["../../src/runtime/auth.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport type { AthenaTokenRenewer } from '../auth/credential-source';\nimport { athenaDiagnostics } from '../diagnostics/athena-diagnostics';\nimport { AthenaSdkError } from '../diagnostics/errors';\n\n/**\n * Hosts under `athenaintel.com` that serve customer-written code:\n * - Marathon's computer and application apps: `{id}.app.athenaintel.com`,\n * `{id}.staging-app.athenaintel.com`, `{id}.canary-app.athenaintel.com`, an\n * environment's `{id}.app.{env}.athenaintel.com`, and the staging wildcard\n * `{id}.computer.stg.athenaintel.com` (and `{id}.computer-canary.stg.athenaintel.com`);\n * - the Sandpack bundler's User Interface previews:\n * `{id}-sandpack.code-sandpack.athenaintel.com` (and `.code-sandpack.{env}.`).\n * They are never a trusted parent and never a backend the bridge points the\n * SDK at.\n */\nconst CUSTOMER_APP_HOST =\n /^.+\\.(?:(?:[a-z0-9-]+-)?app(?:\\.[a-z0-9-]+)*|computer(?:-[a-z0-9-]+)?\\.stg|code-sandpack(?:\\.[a-z0-9-]+)*)\\.athenaintel\\.com$/i;\n\n/** Whether `hostname` serves customer apps (see {@link CUSTOMER_APP_HOST}). */\nexport function isCustomerAppHost(hostname: string): boolean {\n return CUSTOMER_APP_HOST.test(hostname);\n}\n\nfunction isLoopbackHost(hostname: string): boolean {\n return hostname === 'localhost' || hostname === '127.0.0.1' || hostname === '[::1]';\n}\n\nfunction isAthenaHost(hostname: string): boolean {\n return hostname === 'athenaintel.com' || hostname.endsWith('.athenaintel.com');\n}\n\n/**\n * Check whether a PostMessage origin is trusted as the parent.\n * Accepts:\n * - explicit trusted origins passed by the host app\n * - the current iframe origin (for same-origin wrappers like Marathon)\n * - Athena's own hosts under athenaintel.com and localhost (default\n * behavior), except the customer-app hosts Marathon serves\n */\nexport function isTrustedParentOrigin({\n origin,\n trustedOrigins,\n}: {\n origin: string;\n trustedOrigins: string[];\n}): boolean {\n try {\n const normalizedOrigin = new URL(origin).origin;\n if (trustedOrigins.includes(normalizedOrigin)) {\n return true;\n }\n\n const { hostname } = new URL(normalizedOrigin);\n if (isCustomerAppHost(hostname)) {\n return false;\n }\n return isAthenaHost(hostname) || hostname === 'localhost';\n } catch {\n return false;\n }\n}\n\n/** Why {@link isAcceptableBridgeUrl} refused a URL. */\nexport type BridgeUrlRefusal = 'invalid' | 'insecure' | 'customer_app_host' | 'other_domain';\n\n/**\n * Whether a URL a trusted parent sent in `athena-config` may become the\n * SDK's backend, statewire mount or app URL. The SDK sends its bearer token\n * to the first two, so a URL is taken only when it is `https:` (plain\n * `http:` only between loopback hosts, for local development), carries no\n * credentials, is not a customer-code host ({@link CUSTOMER_APP_HOST}), and\n * is one of Athena's own hosts or, for a parent outside `athenaintel.com`,\n * the parent's own host or a subdomain of it. Sibling hosts are not taken:\n * without a public-suffix list `portal.example.co.uk` and `tenant.github.io`\n * cannot be told apart from a private domain, so a wrapper whose backend is\n * elsewhere passes its URLs through `config`. Returns the refusal, or `null`\n * when the URL is acceptable.\n */\nexport function refuseBridgeUrl({\n url,\n parentOrigin,\n}: {\n url: string;\n parentOrigin: string;\n}): BridgeUrlRefusal | null {\n let parsed: URL;\n let parentHostname: string;\n try {\n parsed = new URL(url);\n parentHostname = new URL(parentOrigin).hostname;\n } catch {\n return 'invalid';\n }\n if (parsed.username || parsed.password) return 'invalid';\n const { hostname } = parsed;\n const loopbackPair = isLoopbackHost(hostname) && isLoopbackHost(parentHostname);\n if (parsed.protocol !== 'https:' && !(parsed.protocol === 'http:' && loopbackPair)) {\n return 'insecure';\n }\n if (isCustomerAppHost(hostname)) return 'customer_app_host';\n if (loopbackPair || isAthenaHost(hostname)) return null;\n // Athena and loopback parents point only at Athena's own hosts (above).\n if (isAthenaHost(parentHostname) || isLoopbackHost(parentHostname)) return 'other_domain';\n return hostname === parentHostname || hostname.endsWith(`.${parentHostname}`)\n ? null\n : 'other_domain';\n}\n\n/** {@link refuseBridgeUrl} as a predicate. */\nexport function isAcceptableBridgeUrl(options: { url: string; parentOrigin: string }): boolean {\n return refuseBridgeUrl(options) === null;\n}\n\nexport interface ParentBridgeState {\n /** PropelAuth access token from the parent window. */\n token: string | null;\n /**\n * Statewire sync mount (`…/v2/threads`) minted by the host. `null` when the\n * host minted none; the provider then derives it from the configured\n * `apiUrl`'s origin (or the environment preset).\n */\n statewireSyncUrl: string | null;\n /**\n * Bare Agora API base (no path) minted by the host. `null` when the host\n * minted none; the provider then uses the configured `backendUrl` (or the\n * environment preset).\n */\n backendBaseUrl: string | null;\n /** Athena frontend origin provided by the parent wrapper. */\n appUrl: string | null;\n /**\n * True once a host answered the bridge — a `/_athena/auth` mint or an\n * `athena-config` message — whether or not it minted the statewire fields.\n * Lets the provider tell an outdated host (answered, no mount) from no host\n * at all (the environment preset applies).\n */\n hostAnswered: boolean;\n /** True once config has been received from the parent (or timeout fired). */\n ready: boolean;\n /**\n * Set when the Marathon mint (`/_athena/auth`) gave up. It gives up when it\n * gets a refusal (401, 403, or any 4xx other than 404), a body it cannot\n * read, or a transient failure (5xx, 408, 429, a network error, a timeout)\n * on every attempt of one bounded retry cycle. `code` is\n * `auth_bridge_failed`, or `auth_bridge_timeout` when the last attempt\n * timed out. After that the bridge does not mint again in the background. A\n * forced renewal (`renewToken({ force: true })`) starts one new bounded\n * cycle. A token that an earlier mint handed out is kept (the server still\n * validates it), and the bridge never puts an empty token in its place. The\n * next successful mint clears it. Absent or `null` otherwise.\n */\n error?: AthenaSdkError | null;\n}\n\n/**\n * {@link ParentBridgeState} plus the bridge's token renewal: `force` (the\n * token was refused) asks the host for a new one — a fresh `/_athena/auth`\n * mint on a Marathon origin, or an `athena-auth-ready` request answered by the\n * parent window's next `athena-auth` — and resolves the held token otherwise.\n */\nexport type ParentBridge = ParentBridgeState & { renewToken: AthenaTokenRenewer };\n\nconst BRIDGE_URL_FIELDS = ['statewireSyncUrl', 'backendBaseUrl', 'appUrl'] as const;\n\ntype BridgeUrlField = (typeof BRIDGE_URL_FIELDS)[number];\n\n/** The URL half of {@link ParentBridgeState} — what a host can hand the SDK. */\nexport type ParentBridgeUrls = Pick<ParentBridgeState, BridgeUrlField>;\n\nconst EMPTY_BRIDGE_URLS: ParentBridgeUrls = {\n statewireSyncUrl: null,\n backendBaseUrl: null,\n appUrl: null,\n};\n\n/**\n * Fold a URL payload over the current URL set without vetting it (the\n * same-origin `/_athena/auth` mint body; a parent's `athena-config` goes\n * through {@link acceptBridgeConfigMessage}). A field is taken only when it is\n * a string; anything else keeps the previous value. Keys outside\n * {@link BridgeUrlField} (a legacy parent's `apiUrl` / `backendUrl` among\n * them) are dropped.\n */\nexport function mergeBridgeConfigMessage(\n previous: ParentBridgeUrls,\n payload: Partial<Record<BridgeUrlField, unknown>>,\n): ParentBridgeUrls {\n const next: ParentBridgeUrls = {\n statewireSyncUrl: previous.statewireSyncUrl,\n backendBaseUrl: previous.backendBaseUrl,\n appUrl: previous.appUrl,\n };\n for (const field of BRIDGE_URL_FIELDS) {\n const value = payload[field];\n if (typeof value === 'string') {\n next[field] = value;\n }\n }\n return next;\n}\n\n/** A URL field of an `athena-config` message that was not taken, and why. */\nexport interface RejectedBridgeUrl {\n field: BridgeUrlField;\n reason: BridgeUrlRefusal | 'changed';\n}\n\n/**\n * Fold an `athena-config` message from a trusted parent over the current URL\n * set, taking only what is safe to point the SDK's bearer at: each string\n * field must pass {@link refuseBridgeUrl} against the parent's origin. The\n * first config message sets the URLs; once `locked` (a config message was\n * already taken) a value that differs from the held one, including a field\n * the first message left unset, is refused (`changed`), so a later message\n * cannot repoint a running SDK. Resending the same value is fine.\n */\nexport function acceptBridgeConfigMessage({\n previous,\n payload,\n parentOrigin,\n locked = false,\n}: {\n previous: ParentBridgeUrls;\n payload: Partial<Record<BridgeUrlField, unknown>>;\n parentOrigin: string;\n locked?: boolean;\n}): { urls: ParentBridgeUrls; rejected: RejectedBridgeUrl[] } {\n const urls: ParentBridgeUrls = {\n statewireSyncUrl: previous.statewireSyncUrl,\n backendBaseUrl: previous.backendBaseUrl,\n appUrl: previous.appUrl,\n };\n const rejected: RejectedBridgeUrl[] = [];\n for (const field of BRIDGE_URL_FIELDS) {\n const value = payload[field];\n if (typeof value !== 'string') continue;\n const held = previous[field];\n if (locked || held !== null) {\n if (held !== value) rejected.push({ field, reason: 'changed' });\n continue;\n }\n const refusal = refuseBridgeUrl({ url: value, parentOrigin });\n if (refusal !== null) {\n rejected.push({ field, reason: refusal });\n continue;\n }\n urls[field] = value;\n }\n return { urls, rejected };\n}\n\n/**\n * Read the URL set out of a `/_athena/auth` mint body. Non-string fields are\n * `null`.\n */\nexport function readAuthMintUrls(data: Partial<Record<BridgeUrlField, unknown>>): ParentBridgeUrls {\n return mergeBridgeConfigMessage(EMPTY_BRIDGE_URLS, data);\n}\n\nexport interface ParentBridgeOptions {\n /**\n * Exact parent origins that are allowed to send auth/config via postMessage.\n * Useful for private-cloud or custom-domain deployments.\n */\n trustedOrigins?: string[];\n /** @internal Overrides {@link DEFAULT_MINT_RETRY_POLICY}; used by tests. */\n mintRetryPolicy?: MintRetryPolicy;\n}\n\n/** How long to wait for the parent bridge before falling back to defaults. */\nconst BRIDGE_TIMEOUT_MS = 2000;\n/** How long a renewal waits for the parent window to answer `athena-auth-ready`. */\nconst PARENT_TOKEN_RENEWAL_TIMEOUT_MS = 5000;\nconst TOKEN_REFRESH_BUFFER_MS = 5 * 60 * 1000;\nconst TOKEN_REFRESH_MIN_DELAY_MS = 60 * 1000;\nconst DEFAULT_TOKEN_REFRESH_MS = 55 * 60 * 1000;\nconst EMPTY_TRUSTED_ORIGINS: string[] = [];\n\n/**\n * How one Marathon mint cycle retries. A cycle is the initial acquisition, a\n * scheduled refresh, or a forced renewal. It sends at most `maxAttempts`\n * requests. It retries only a transient failure (5xx, 408, 429, a network\n * error, a timeout), after a capped exponential backoff with jitter, and then\n * it gives up. Nothing retries in the background after a cycle gave up.\n */\nexport interface MintRetryPolicy {\n /** Requests per cycle, the first one included. */\n maxAttempts: number;\n /** Ceiling of the delay before the first retry; it doubles for each retry. */\n baseDelayMs: number;\n /** Largest delay before any retry. */\n maxDelayMs: number;\n /** How long one request can take before it is aborted and counted as a timeout. */\n timeoutMs: number;\n /** Source of jitter in `[0, 1)`. */\n random: () => number;\n}\n\nexport const DEFAULT_MINT_RETRY_POLICY: MintRetryPolicy = {\n maxAttempts: 4,\n baseDelayMs: 500,\n maxDelayMs: 4000,\n timeoutMs: BRIDGE_TIMEOUT_MS,\n random: Math.random,\n};\n\n/** Untrusted shape of the `/_athena/auth` mint body; every field is type-guarded on read. */\ninterface AthenaAuthResponse {\n token?: unknown;\n statewireSyncUrl?: unknown;\n backendBaseUrl?: unknown;\n appUrl?: unknown;\n expires_at?: unknown;\n}\n\nconst normalizeOrigin = (value: string): string | null => {\n try {\n return new URL(value).origin;\n } catch {\n return null;\n }\n};\n\nexport const getTokenRefreshDelay = (expiresAt: unknown, nowMs: number): number => {\n if (typeof expiresAt !== 'string') {\n return DEFAULT_TOKEN_REFRESH_MS;\n }\n\n const expiresAtMs = Date.parse(expiresAt);\n if (!Number.isFinite(expiresAtMs)) {\n return DEFAULT_TOKEN_REFRESH_MS;\n }\n\n return Math.max(TOKEN_REFRESH_MIN_DELAY_MS, expiresAtMs - nowMs - TOKEN_REFRESH_BUFFER_MS);\n};\n\n/**\n * The delay before retry number `retry` of a mint cycle (1 is the first\n * retry). The ceiling is `min(maxDelayMs, baseDelayMs * 2^(retry - 1))`, and\n * equal jitter puts the wait between half of that ceiling and all of it, so\n * viewers whose mint failed at the same time do not retry at the same time.\n */\nexport function getMintRetryDelay({\n retry,\n policy = DEFAULT_MINT_RETRY_POLICY,\n}: {\n retry: number;\n policy?: Pick<MintRetryPolicy, 'baseDelayMs' | 'maxDelayMs' | 'random'>;\n}): number {\n const safeRetry = Number.isFinite(retry) ? Math.max(1, Math.floor(retry)) : 1;\n const ceiling = Math.min(policy.maxDelayMs, policy.baseDelayMs * 2 ** (safeRetry - 1));\n const jitter = Math.min(1, Math.max(0, policy.random()));\n return Math.round(ceiling / 2 + (ceiling / 2) * jitter);\n}\n\n/** A mint status worth another attempt: the host, or something in front of it, is briefly unwell. */\nexport function isRetryableMintStatus(status: number): boolean {\n return status >= 500 || status === 408 || status === 429;\n}\n\n/** A failed `/_athena/auth` request that is worth another attempt. */\ninterface TransientMintFailure {\n kind: 'transient';\n status: number | null;\n reason: 'status' | 'network' | 'timeout';\n hostError: string | null;\n cause?: unknown;\n}\n\n/** A failed `/_athena/auth` request that ends its cycle at once. */\ninterface RefusedMintFailure {\n kind: 'refused';\n status: number;\n /** `status`: a 4xx other than 404, 408 and 429. `invalid_body`: a 2xx whose body is not a JSON object. */\n reason: 'status' | 'invalid_body';\n hostError: string | null;\n}\n\nexport type MintFailure = TransientMintFailure | RefusedMintFailure;\n\n/** The outcome of one `/_athena/auth` request. */\ntype MintAttempt =\n | { kind: 'minted'; data: AthenaAuthResponse }\n /** 404: this is not a Marathon origin. */\n | { kind: 'absent'; status: number }\n | MintFailure\n | { kind: 'cancelled' };\n\n/** The `error` string of a Marathon failure body (`{\"error\":\"mint_failed\"}`), if any. */\nasync function readHostError(resp: Response): Promise<string | null> {\n try {\n const body: unknown = await resp.json();\n if (body && typeof body === 'object' && 'error' in body) {\n const value = (body as { error?: unknown }).error;\n return typeof value === 'string' ? value.slice(0, 100) : null;\n }\n } catch {\n // An empty or non-JSON error body tells nothing more than the status.\n }\n return null;\n}\n\nconst MINT_RETRY_NOTE =\n 'The SDK stopped retrying and does not connect without a credential. Remount the provider, or call renewToken({ force: true }), to try again.';\n\nfunction mintFailureHint(failure: MintFailure): string {\n if (failure.kind === 'transient') {\n return `The host could not mint a viewer token. Check the Marathon and Agora logs. ${MINT_RETRY_NOTE}`;\n }\n if (failure.reason === 'invalid_body') {\n return `The host answered /_athena/auth without a JSON mint body, so this origin is not a Marathon bridge. Pass token, getToken or apiKey. ${MINT_RETRY_NOTE}`;\n }\n if (failure.status === 401) {\n return `The host has no session for this viewer. Sign in again through the app URL. ${MINT_RETRY_NOTE}`;\n }\n if (failure.status === 403) {\n return `The host does not give this viewer access to the app. ${MINT_RETRY_NOTE}`;\n }\n return `The host refused the mint request. ${MINT_RETRY_NOTE}`;\n}\n\n/** The typed error that a mint cycle reports when it gives up. */\nexport function mintFailureError({\n failure,\n attempts,\n phase,\n}: {\n failure: MintFailure;\n attempts: number;\n phase: 'initial' | 'renewal';\n}): AthenaSdkError {\n const timedOut = failure.kind === 'transient' && failure.reason === 'timeout';\n const answer =\n failure.status !== null ? `HTTP ${failure.status}` : timedOut ? 'a timeout' : 'a network error';\n const message =\n failure.kind === 'transient'\n ? `The host auth bridge (/_athena/auth) failed ${attempts} time${attempts === 1 ? '' : 's'} (last: ${answer}).`\n : failure.reason === 'invalid_body'\n ? `The host auth bridge (/_athena/auth) answered ${answer} without a JSON mint body.`\n : `The host auth bridge (/_athena/auth) refused the mint (${answer}).`;\n return new AthenaSdkError({\n code: timedOut ? 'auth_bridge_timeout' : 'auth_bridge_failed',\n message,\n hint: mintFailureHint(failure),\n ...(failure.status !== null && { status: failure.status }),\n ...(failure.hostError !== null && { detail: { code: failure.hostError } }),\n ...(failure.kind === 'transient' && failure.cause !== undefined && { cause: failure.cause }),\n context: {\n mode: 'marathon',\n phase,\n attempts,\n reason: failure.reason,\n host_error: failure.hostError,\n },\n });\n}\n\n/**\n * Listens for auth tokens AND environment config from the host environment.\n *\n * Two transport modes, picked automatically:\n *\n * 1. **Iframe (legacy / Olympus inline preview)**: a parent window posts\n * `athena-config` and `athena-auth` via PostMessage. The hook also posts\n * `athena-auth-ready` so the parent knows when to (re-)send. Only the\n * window that frames the app (`event.source === window.parent`) on a\n * trusted origin ({@link isTrustedParentOrigin}) is heard, and an\n * `athena-config` URL is taken only once and only when it passes\n * {@link refuseBridgeUrl}.\n *\n * 2. **Standalone (Marathon-served deploy URL)**: top-level navigation, no\n * parent. The hook fetches `/_athena/auth` on its own origin. Marathon\n * validates its session cookie (sent by the browser automatically) and\n * returns `{ token, statewireSyncUrl, backendBaseUrl, appUrl }` — the\n * statewire mount, the bare Agora base and the app origin. A 404 means\n * we're not on a Marathon origin — the hook falls through with empty\n * state. Any other failure fails closed: one bounded retry cycle\n * ({@link MintRetryPolicy}) for a transient failure, none for a refusal,\n * and then `error` is set and `ready` flips with no token — never an\n * empty or anonymous one.\n *\n * In both modes the app never blocks indefinitely: the iframe bridge flips\n * `ready: true` after a timeout, and a Marathon mint cycle ends after at most\n * `maxAttempts` requests.\n */\nexport function useParentBridge({\n trustedOrigins = EMPTY_TRUSTED_ORIGINS,\n mintRetryPolicy = DEFAULT_MINT_RETRY_POLICY,\n}: ParentBridgeOptions = {}): ParentBridge {\n const isInIframe = typeof window !== 'undefined' && window.parent !== window;\n const runtimeTrustedOrigins = useMemo(() => {\n const origins = new Set<string>();\n\n if (typeof window !== 'undefined') {\n origins.add(window.location.origin);\n }\n\n for (const trustedOrigin of trustedOrigins) {\n const normalizedOrigin = normalizeOrigin(trustedOrigin);\n if (normalizedOrigin) {\n origins.add(normalizedOrigin);\n }\n }\n\n return [...origins];\n }, [trustedOrigins]);\n\n const [state, setState] = useState<ParentBridgeState>({\n token: null,\n ...EMPTY_BRIDGE_URLS,\n hostAnswered: false,\n ready: false,\n error: null,\n });\n // Read when a mint cycle starts, so a caller's inline policy object does not\n // restart the bridge on every render.\n const mintRetryPolicyRef = useRef(mintRetryPolicy);\n mintRetryPolicyRef.current = mintRetryPolicy;\n const readySignalSent = useRef(false);\n const configReceived = useRef(false);\n // The URLs the parent has set so far: a later `athena-config` may not change them.\n const parentUrlsRef = useRef<ParentBridgeUrls>(EMPTY_BRIDGE_URLS);\n const tokenRef = useRef<string | null>(state.token);\n tokenRef.current = state.token;\n // Installed by whichever transport mode is active (iframe or Marathon).\n const renewerRef = useRef<AthenaTokenRenewer | null>(null);\n\n useEffect(() => {\n if (!isInIframe) return;\n\n const endBridgeSpan = athenaDiagnostics.span('auth.bridge', 'auth.bridge.start', {\n mode: 'iframe',\n });\n let spanEnded = false;\n const endOnce: typeof endBridgeSpan = (name, options) => {\n if (spanEnded) return 0;\n spanEnded = true;\n return endBridgeSpan(name, options);\n };\n\n // Renewals waiting for the parent's next `athena-auth`.\n const tokenWaiters = new Set<(token: string | null) => void>();\n\n const handler = (event: MessageEvent) => {\n // Only the window that frames this app speaks for the host: a popup,\n // an opener or a sibling frame on a trusted origin does not.\n if (event.source !== window.parent) return;\n if (\n !isTrustedParentOrigin({ origin: event.origin, trustedOrigins: runtimeTrustedOrigins })\n ) {\n return;\n }\n if (!event.data || typeof event.data !== 'object') return;\n\n if (event.data.type === 'athena-config') {\n const { urls, rejected } = acceptBridgeConfigMessage({\n previous: parentUrlsRef.current,\n payload: event.data,\n parentOrigin: event.origin,\n locked: configReceived.current,\n });\n configReceived.current = true;\n parentUrlsRef.current = urls;\n for (const { field, reason } of rejected) {\n athenaDiagnostics.emit('auth.bridge.config_rejected', {\n level: 'warn',\n data: { mode: 'iframe', field, reason },\n });\n }\n setState((prev) => ({\n ...prev,\n ...urls,\n hostAnswered: true,\n // Don't set ready here — wait for athena-auth (token) or the timeout.\n // Setting ready on config alone causes a race: the thread list fires\n // before the token arrives, falling back to X-API-KEY.\n }));\n }\n\n if (event.data.type === 'athena-auth' && typeof event.data.token === 'string') {\n endOnce('auth.bridge.ready', { data: { mode: 'iframe' } });\n athenaDiagnostics.emit('auth.token.acquired', {\n level: 'debug',\n data: { source: 'iframe-postmessage' },\n });\n setState((prev) => ({\n ...prev,\n token: event.data.token,\n ready: true,\n }));\n tokenRef.current = event.data.token;\n for (const resolve of [...tokenWaiters]) resolve(event.data.token);\n }\n };\n window.addEventListener('message', handler);\n\n // A renewal asks the parent to send its current token again — the same\n // `athena-auth-ready` handshake a parent already answers — and settles on\n // the next `athena-auth`, or on the held token when none arrives in time.\n renewerRef.current = ({ force }) => {\n if (!force) return Promise.resolve(tokenRef.current);\n return new Promise<string | null>((resolve) => {\n const settle = (token: string | null) => {\n clearTimeout(timer);\n tokenWaiters.delete(settle);\n resolve(token ?? tokenRef.current);\n };\n const timer = setTimeout(() => settle(null), PARENT_TOKEN_RENEWAL_TIMEOUT_MS);\n tokenWaiters.add(settle);\n window.parent.postMessage({ type: 'athena-auth-ready' }, '*');\n });\n };\n\n if (!readySignalSent.current) {\n window.parent.postMessage({ type: 'athena-auth-ready' }, '*');\n readySignalSent.current = true;\n }\n\n const timer = setTimeout(() => {\n endOnce('auth.bridge.timeout', {\n data: {\n mode: 'iframe',\n timeout_ms: BRIDGE_TIMEOUT_MS,\n config_received: configReceived.current,\n },\n });\n setState((prev) => (prev.ready ? prev : { ...prev, ready: true }));\n }, BRIDGE_TIMEOUT_MS);\n\n return () => {\n window.removeEventListener('message', handler);\n clearTimeout(timer);\n renewerRef.current = null;\n for (const resolve of [...tokenWaiters]) resolve(null);\n };\n }, [isInIframe, runtimeTrustedOrigins]);\n\n useEffect(() => {\n if (isInIframe) return;\n if (typeof window === 'undefined') return;\n\n let cancelled = false;\n let refreshTimer: ReturnType<typeof setTimeout> | null = null;\n let controller: AbortController | null = null;\n let inFlight: Promise<string | null> | null = null;\n let retryWait: { timer: ReturnType<typeof setTimeout>; resolve: () => void } | null = null;\n\n const clearRefreshTimer = () => {\n if (refreshTimer) {\n clearTimeout(refreshTimer);\n refreshTimer = null;\n }\n };\n\n const endRetryWait = () => {\n if (!retryWait) return;\n clearTimeout(retryWait.timer);\n const { resolve } = retryWait;\n retryWait = null;\n resolve();\n };\n\n /** The backoff between two attempts of one cycle; unmounting ends it at once. */\n const waitBeforeRetry = (delayMs: number) =>\n new Promise<void>((resolve) => {\n retryWait = { timer: setTimeout(endRetryWait, delayMs), resolve };\n });\n\n // The only background mint: once per token, shortly before it expires. It\n // is not rescheduled when its cycle gives up. A forced renewal that gives\n // up leaves it in place on purpose: the held token is still live, and\n // this one bounded cycle keeps a viewer connected past a brief outage.\n const scheduleRefresh = (expiresAt: unknown) => {\n clearRefreshTimer();\n const delay = getTokenRefreshDelay(expiresAt, Date.now());\n refreshTimer = setTimeout(() => {\n refreshTimer = null;\n void fetchAuth({ initial: false });\n }, delay);\n };\n\n /** One `/_athena/auth` request, classified. */\n const mintOnce = async (timeoutMs: number): Promise<MintAttempt> => {\n const requestController = new AbortController();\n controller = requestController;\n let timedOut = false;\n const requestTimer = setTimeout(() => {\n timedOut = true;\n requestController.abort();\n }, timeoutMs);\n\n try {\n const resp = await fetch('/_athena/auth', {\n credentials: 'include',\n headers: { Accept: 'application/json' },\n signal: requestController.signal,\n });\n if (cancelled) return { kind: 'cancelled' };\n // Not a Marathon origin: expected for standalone apps and local dev.\n if (resp.status === 404) return { kind: 'absent', status: resp.status };\n if (!resp.ok) {\n const hostError = await readHostError(resp);\n if (cancelled) return { kind: 'cancelled' };\n // `readHostError` swallows the abort of a stalled error body. Only a\n // retryable status becomes a timeout: a refusal (401, 403, other\n // 4xx) is known from its status and still fails after one request.\n if (timedOut && isRetryableMintStatus(resp.status)) {\n return { kind: 'transient', status: null, reason: 'timeout', hostError: null };\n }\n return isRetryableMintStatus(resp.status)\n ? { kind: 'transient', status: resp.status, reason: 'status', hostError }\n : { kind: 'refused', status: resp.status, reason: 'status', hostError };\n }\n\n let data: unknown;\n try {\n data = await resp.json();\n } catch (error) {\n if (cancelled) return { kind: 'cancelled' };\n if (timedOut) {\n return { kind: 'transient', status: null, reason: 'timeout', hostError: null, cause: error };\n }\n return { kind: 'refused', status: resp.status, reason: 'invalid_body', hostError: null };\n }\n if (cancelled) return { kind: 'cancelled' };\n // Marathon's 200 always carries a token. A 2xx without one is a\n // broken mint: it must not replace a held token or count as success.\n const token = data && typeof data === 'object' ? (data as { token?: unknown }).token : null;\n if (typeof token !== 'string' || token === '') {\n return { kind: 'refused', status: resp.status, reason: 'invalid_body', hostError: null };\n }\n return { kind: 'minted', data: data as AthenaAuthResponse };\n } catch (error) {\n if (cancelled) return { kind: 'cancelled' };\n if (timedOut) {\n return { kind: 'transient', status: null, reason: 'timeout', hostError: null, cause: error };\n }\n return { kind: 'transient', status: null, reason: 'network', hostError: null, cause: error };\n } finally {\n clearTimeout(requestTimer);\n if (controller === requestController) controller = null;\n }\n };\n\n /**\n * One bounded mint cycle: the initial acquisition (a span the provider\n * waits on) or a renewal (the scheduled refresh, a forced renewal). It\n * retries a transient failure up to `maxAttempts` requests in all, with\n * a capped, jittered backoff. On a refusal, or after the last attempt, it\n * gives up: it reports one typed error, sets `error`, keeps any token an\n * earlier mint handed out, and schedules nothing.\n */\n const runMintCycle = async ({ initial }: { initial: boolean }): Promise<string | null> => {\n const policy = mintRetryPolicyRef.current;\n const maxAttempts = Math.max(1, Math.floor(policy.maxAttempts));\n const phase = initial ? 'initial' : 'renewal';\n const endBridgeSpan = initial\n ? athenaDiagnostics.span('auth.bridge', 'auth.bridge.start', { mode: 'marathon' })\n : null;\n\n let attempts = 0;\n let lastFailure: MintFailure | null = null;\n while (attempts < maxAttempts) {\n attempts += 1;\n const outcome = await mintOnce(policy.timeoutMs);\n if (cancelled || outcome.kind === 'cancelled') return null;\n\n if (outcome.kind === 'absent') {\n endBridgeSpan?.('auth.bridge.absent', {\n data: { mode: 'marathon', status: outcome.status },\n });\n // 404 means no bridge here, so an earlier mint failure no longer\n // applies; the provider falls back to its other credentials.\n setState((prev) =>\n prev.ready && prev.error == null ? prev : { ...prev, ready: true, error: null },\n );\n return null;\n }\n\n if (outcome.kind === 'minted') {\n const { data } = outcome;\n if (endBridgeSpan) {\n endBridgeSpan('auth.bridge.ready', {\n data: { mode: 'marathon', has_token: typeof data.token === 'string', attempts },\n });\n athenaDiagnostics.emit('auth.token.acquired', {\n level: 'debug',\n data: { source: 'marathon', expires_at: data.expires_at },\n });\n } else {\n athenaDiagnostics.emit('auth.token.refreshed', {\n level: 'debug',\n data: { source: 'marathon', expires_at: data.expires_at, attempts },\n });\n }\n const token = typeof data.token === 'string' ? data.token : null;\n setState({\n token,\n ...readAuthMintUrls(data),\n hostAnswered: true,\n ready: true,\n error: null,\n });\n tokenRef.current = token;\n scheduleRefresh(data.expires_at);\n return token;\n }\n\n lastFailure = outcome;\n if (outcome.kind === 'refused' || attempts >= maxAttempts) break;\n\n const delayMs = getMintRetryDelay({ retry: attempts, policy });\n athenaDiagnostics.emit('auth.bridge.retry', {\n level: 'warn',\n data: {\n mode: 'marathon',\n phase,\n status: outcome.status,\n reason: outcome.reason,\n host_error: outcome.hostError,\n attempt: attempts,\n max_attempts: maxAttempts,\n delay_ms: delayMs,\n },\n });\n await waitBeforeRetry(delayMs);\n if (cancelled) return null;\n }\n\n if (!lastFailure) return null;\n const error = mintFailureError({ failure: lastFailure, attempts, phase });\n const failureData = {\n mode: 'marathon',\n phase,\n status: lastFailure.status,\n reason: lastFailure.reason,\n attempts,\n };\n if (endBridgeSpan) {\n endBridgeSpan(\n error.code === 'auth_bridge_timeout' ? 'auth.bridge.timeout' : 'auth.bridge.error',\n { data: failureData, error },\n );\n } else {\n athenaDiagnostics.emit('auth.token.refresh_failed', {\n level: 'error',\n data: failureData,\n error,\n });\n }\n setState((prev) => ({ ...prev, error, ready: true }));\n return null;\n };\n\n // One mint cycle at a time. The initial acquisition, a scheduled refresh\n // and forced renewals that overlap share the cycle in flight (its\n // requests, their timeouts and its backoff) instead of starting their own,\n // so concurrent callers never multiply the requests.\n const fetchAuth = (options: { initial: boolean }): Promise<string | null> => {\n inFlight ??= runMintCycle(options).finally(() => {\n inFlight = null;\n });\n return inFlight;\n };\n\n // A forced renewal mints now instead of waiting for the scheduled refresh\n // (joining a cycle already in flight), and may start a new bounded cycle\n // after one gave up. The schedule restarts from the new token's expiry.\n renewerRef.current = ({ force }) => {\n if (!force) return Promise.resolve(tokenRef.current);\n return fetchAuth({ initial: false }).then((token) => token ?? tokenRef.current);\n };\n\n void fetchAuth({ initial: true });\n\n return () => {\n cancelled = true;\n controller?.abort();\n clearRefreshTimer();\n endRetryWait();\n renewerRef.current = null;\n };\n }, [isInIframe]);\n\n const renewToken = useCallback<AthenaTokenRenewer>(\n (options) => renewerRef.current?.(options) ?? Promise.resolve(tokenRef.current),\n [],\n );\n\n return useMemo(() => ({ ...state, renewToken }), [state, renewToken]);\n}\n\n/**\n * Legacy hook — returns just the auth token from the parent bridge.\n * Prefer useParentBridge() for new code.\n */\nexport function useParentAuth(): string | null {\n return useParentBridge().token;\n}\n"],"names":["AthenaSdkError","useMemo","useState","useRef","useEffect","athenaDiagnostics","timer","useCallback"],"mappings":";;;;;AAgBA,MAAM,oBACJ;AAGK,SAAS,kBAAkB,UAA2B;AAC3D,SAAO,kBAAkB,KAAK,QAAQ;AACxC;AAEA,SAAS,eAAe,UAA2B;AACjD,SAAO,aAAa,eAAe,aAAa,eAAe,aAAa;AAC9E;AAEA,SAAS,aAAa,UAA2B;AAC/C,SAAO,aAAa,qBAAqB,SAAS,SAAS,kBAAkB;AAC/E;AAUO,SAAS,sBAAsB;AAAA,EACpC;AAAA,EACA;AACF,GAGY;AACV,MAAI;AACF,UAAM,mBAAmB,IAAI,IAAI,MAAM,EAAE;AACzC,QAAI,eAAe,SAAS,gBAAgB,GAAG;AAC7C,aAAO;AAAA,IACT;AAEA,UAAM,EAAE,SAAA,IAAa,IAAI,IAAI,gBAAgB;AAC7C,QAAI,kBAAkB,QAAQ,GAAG;AAC/B,aAAO;AAAA,IACT;AACA,WAAO,aAAa,QAAQ,KAAK,aAAa;AAAA,EAChD,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAkBO,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AACF,GAG4B;AAC1B,MAAI;AACJ,MAAI;AACJ,MAAI;AACF,aAAS,IAAI,IAAI,GAAG;AACpB,qBAAiB,IAAI,IAAI,YAAY,EAAE;AAAA,EACzC,QAAQ;AACN,WAAO;AAAA,EACT;AACA,MAAI,OAAO,YAA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AE,MAAM,aAAa,MAAA;AAAA,QAAM;AAAA,MAE/B,OAAO;AACLA,0BAAAA,kBAAkB,KAAK,6BAA6B;AAAA,UAClD,OAAO;AAAA,UACP,MAAM;AAAA,UACN;AAAA,QAAA,CACD;AAAA,MACH;AACA,eAAS,CAAC,UAAU,EAAE,GAAG,MAAM,OAAO,OAAO,OAAO;AACpD,aAAO;AAAA,IACT;AAMA,UAAM,YAAY,CAAC,YAA0D;AAC3E,8BAAa,aAAa,OAAO,EAAE,QAAQ,MAAM;AAC/C,mBAAW;AAAA,MACb,CAAC;AACD,aAAO;AAAA,IACT;AAKA,eAAW,UAAU,CAAC,EAAE,YAAY;AAClC,UAAI,CAAC,MAAO,QAAO,QAAQ,QAAQ,SAAS,OAAO;AACnD,aAAO,UAAU,EAAE,SAAS,OAAO,EAAE,KAAK,CAAC,UAAU,SAAS,SAAS,OAAO;AAAA,IAChF;AAEA,SAAK,UAAU,EAAE,SAAS,MAAM;AAEhC,WAAO,MAAM;AACX,kBAAY;AACZ,+CAAY;AACZ,wBAAA;AACA,mBAAA;AACA,iBAAW,UAAU;AAAA,IACvB;AAAA,EACF,GAAG,CAAC,UAAU,CAAC;AAEf,QAAM,aAAaE,WAAAA;AAAAA,IACjB,CAAC;;AAAY,+BAAW,YAAX,oCAAqB,aAAY,QAAQ,QAAQ,SAAS,OAAO;AAAA;AAAA,IAC9E,CAAA;AAAA,EAAC;AAGH,SAAON,WAAAA,QAAQ,OAAO,EAAE,GAAG,OAAO,eAAe,CAAC,OAAO,UAAU,CAAC;AACtE;AAMO,SAAS,gBAA+B;AAC7C,SAAO,kBAAkB;AAC3B;;;;;;;;;;;;;;"}
@@ -3,6 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const errors = require("../agent-runtime/src/errors.cjs");
4
4
  function athenaStatewireErrorNotice(error) {
5
5
  if (errors.isStatewireChannelTeardown(error)) return null;
6
+ if (errors.isVoiceCommandRejection(error)) return null;
6
7
  const rejection = errors.statewireRejectionPayload(error);
7
8
  const detail = errors.statewireRejectionDetailMessage(error);
8
9
  if ((rejection == null ? void 0 : rejection.status) === 402) {