@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,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const store = require("@assistant-ui/store");
4
- const react = require("react");
4
+ const require$$0 = require("react");
5
5
  const runconfigContract = require("./generated/runconfig-contract.cjs");
6
6
  const messageWindow = require("./message-window.cjs");
7
7
  const threadExtras = require("./thread-extras.cjs");
@@ -19,12 +19,12 @@ const useStatewireExtras = () => store.useAuiState((s) => {
19
19
  });
20
20
  function useDeepAgentMessageWindow() {
21
21
  const documents = useStatewireExtras().documents;
22
- const mounted = react.useSyncExternalStore(
22
+ const mounted = require$$0.useSyncExternalStore(
23
23
  (documents == null ? void 0 : documents.subscribe) ?? noopSubscribe,
24
24
  () => documents == null ? void 0 : documents.list(),
25
25
  () => documents == null ? void 0 : documents.list()
26
26
  );
27
- return react.useMemo(() => messageWindow.readDeepAgentMessageWindow(mounted), [mounted]);
27
+ return require$$0.useMemo(() => messageWindow.readDeepAgentMessageWindow(mounted), [mounted]);
28
28
  }
29
29
  function pageShowedEarlierMessage(from, messages) {
30
30
  if (from.secondId !== void 0) {
@@ -61,33 +61,33 @@ function useDeepAgentWindowSync({
61
61
  }) {
62
62
  const { sendCommand, invoke, connection } = useStatewireExtras();
63
63
  const window = useDeepAgentMessageWindow();
64
- const [loading, setLoading] = react.useState(false);
65
- const [requests, setRequests] = react.useState(0);
66
- const servedRequestsRef = react.useRef(0);
67
- const inflightRef = react.useRef(false);
68
- const chainRef = react.useRef({ epoch: 0, loads: 0, unseen: 0, requested: false });
69
- const openingFillRef = react.useRef(0);
70
- const pageFromRef = react.useRef(null);
71
- const aliveRef = react.useRef(true);
72
- const statedRef = react.useRef(null);
73
- const restatedConnectionRef = react.useRef(null);
74
- const answeredRef = react.useRef(/* @__PURE__ */ new Map());
75
- const toolOutputsInFlightRef = react.useRef(0);
76
- const toolOutputsWaitingRef = react.useRef(false);
77
- const [toolOutputSettles, setToolOutputSettles] = react.useState(0);
78
- const onHistoryLoadRef = react.useRef(onHistoryLoad);
64
+ const [loading, setLoading] = require$$0.useState(false);
65
+ const [requests, setRequests] = require$$0.useState(0);
66
+ const servedRequestsRef = require$$0.useRef(0);
67
+ const inflightRef = require$$0.useRef(false);
68
+ const chainRef = require$$0.useRef({ epoch: 0, loads: 0, unseen: 0, requested: false });
69
+ const openingFillRef = require$$0.useRef(0);
70
+ const pageFromRef = require$$0.useRef(null);
71
+ const aliveRef = require$$0.useRef(true);
72
+ const statedRef = require$$0.useRef(null);
73
+ const restatedConnectionRef = require$$0.useRef(null);
74
+ const answeredRef = require$$0.useRef(/* @__PURE__ */ new Map());
75
+ const toolOutputsInFlightRef = require$$0.useRef(0);
76
+ const toolOutputsWaitingRef = require$$0.useRef(false);
77
+ const [toolOutputSettles, setToolOutputSettles] = require$$0.useState(0);
78
+ const onHistoryLoadRef = require$$0.useRef(onHistoryLoad);
79
79
  onHistoryLoadRef.current = onHistoryLoad;
80
- const onErrorRef = react.useRef(onError);
80
+ const onErrorRef = require$$0.useRef(onError);
81
81
  onErrorRef.current = onError;
82
- const nowRef = react.useRef(now);
82
+ const nowRef = require$$0.useRef(now);
83
83
  nowRef.current = now;
84
- react.useEffect(() => {
84
+ require$$0.useEffect(() => {
85
85
  aliveRef.current = true;
86
86
  return () => {
87
87
  aliveRef.current = false;
88
88
  };
89
89
  }, []);
90
- react.useEffect(() => {
90
+ require$$0.useEffect(() => {
91
91
  if (connection.status !== "connected" || restatedConnectionRef.current === connection) return;
92
92
  if (window === null) return;
93
93
  restatedConnectionRef.current = connection;
@@ -98,7 +98,7 @@ function useDeepAgentWindowSync({
98
98
  (_a = onErrorRef.current) == null ? void 0 : _a.call(onErrorRef, error, "athena/interest");
99
99
  });
100
100
  }, [connection, invoke, window]);
101
- react.useEffect(() => {
101
+ require$$0.useEffect(() => {
102
102
  var _a;
103
103
  if (window === null || inflightRef.current) return;
104
104
  const from = pageFromRef.current;
@@ -165,7 +165,7 @@ function useDeepAgentWindowSync({
165
165
  maxUnseenLoads,
166
166
  pageSize
167
167
  ]);
168
- react.useEffect(() => {
168
+ require$$0.useEffect(() => {
169
169
  var _a;
170
170
  if (window === null || toolOutputs === void 0) return;
171
171
  toolOutputsWaitingRef.current = false;
@@ -214,10 +214,10 @@ function useDeepAgentWindowSync({
214
214
  maxConcurrentToolOutputs,
215
215
  toolOutputSettles
216
216
  ]);
217
- const loadOlder = react.useCallback(() => {
217
+ const loadOlder = require$$0.useCallback(() => {
218
218
  setRequests((count) => count + 1);
219
219
  }, []);
220
- const canLoadOlder = react.useMemo(
220
+ const canLoadOlder = require$$0.useMemo(
221
221
  () => window !== null && messageWindow.pageInterestRequests(window, pageSize) !== null,
222
222
  [window, pageSize]
223
223
  );
@@ -1 +1 @@
1
- {"version":3,"file":"use-deep-agent-window-sync.cjs","sources":["../../../../agent-runtime/src/use-deep-agent-window-sync.ts"],"sourcesContent":["import type { StatewireThread } from '@assistant-ui/react-statewire';\nimport { useAuiState } from '@assistant-ui/store';\nimport { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';\nimport { DEEP_AGENT_INTEREST_PROTOCOL } from './generated/runconfig-contract';\nimport {\n buildToolOutputCommand,\n type DeepAgentInterestRequest,\n type DeepAgentMessageWindow,\n interestsCovered,\n pageInterestRequests,\n readDeepAgentMessageWindow,\n readToolOutputResult,\n readTruncatedToolOutputArtifact,\n} from './message-window';\nimport { hasStatewireThreadExtras } from './thread-extras';\nimport type { DeepAgentToolOutputStore } from './tool-outputs';\n\n/**\n * Pages of older history chained per approach to the top. A renderer lowers\n * its near-top level once prepended content has pushed the first message out\n * of its band; this bounds the case where it cannot (no viewport to scroll,\n * a list too short to overflow) so a 2,000-message thread never streams whole.\n */\nexport const DEEP_AGENT_MAX_CHAINED_HISTORY_LOADS = 3;\n\n/**\n * Pages of older history that add no converted message — every message on\n * them folds into the first loaded turn, such as one agent run's hundreds of\n * tool steps — loaded on top of a request (or an approach's chain) before it\n * stops. Such a page changes nothing the user can see, so it neither answers\n * an ask nor counts against the per-approach chain.\n */\nexport const DEEP_AGENT_MAX_UNSEEN_HISTORY_LOADS = 25;\n\n/** The converted thread messages the tool-output half scans (web and native `ThreadMessage` both satisfy it). */\nexport interface DeepAgentWindowSyncMessage {\n readonly id: string;\n /** The converted role; lets the opening fill tell a turn's prompt from its reply. */\n readonly role?: string;\n readonly content: readonly { readonly type: string; readonly artifact?: unknown }[];\n}\n\n/** One page interest round trip, for the host's telemetry. */\nexport interface DeepAgentHistoryLoadEvent {\n /** The page's ordinal (`1` extends the head). */\n page: number;\n request: DeepAgentInterestRequest;\n durationMs: number;\n}\n\nexport interface UseDeepAgentWindowSyncOptions {\n /**\n * The converted thread messages — read by the host through its platform\n * `useAuiState((s) => s.thread.messages)`, so this hook imports neither\n * `@assistant-ui/react` nor `@assistant-ui/react-native`.\n */\n messages: readonly DeepAgentWindowSyncMessage[];\n /** Messages per page; the thread's window size by default. */\n pageSize?: number;\n /**\n * Full tool outputs fetched back for cut tool messages; the same store the\n * thread converts with (`useDeepAgentThread({ toolOutputs })`). Omitted, the\n * tool-output half is inert (a surface that never shows a cut output whole).\n */\n toolOutputs?: DeepAgentToolOutputStore | undefined;\n /**\n * The renderer's report that the top of the LOADED history is near — a\n * level, not an edge: while it holds and older messages exist, pages load\n * one after another (bounded by `maxChainedLoads` per approach). Omitted for\n * hosts with only a manual affordance (`loadOlder`).\n */\n nearTop?: boolean;\n /** Bumped on every rise of `nearTop` (and every explicit request), so the chain bound is per approach. */\n nearTopEpoch?: number;\n /**\n * Whether a message's content is mounted right now, so lazy fetches (cut\n * tool outputs) target what the user can see rather than the whole loaded\n * history. Omitted: every message counts as mounted (the flat renderers).\n */\n isMessageMounted?: ((messageId: string) => boolean) | undefined;\n /**\n * Cut tool outputs this mount reads at once; the rest wait for one to\n * settle. One mounted message can hold a whole agent run — a hundred tool\n * steps — and the host rate-limits a client's frames, so a reader that sends\n * them all together gets refusals back for most of them. Omitted: every\n * mounted output is asked for together (renderers whose mounted set is\n * already small).\n */\n maxConcurrentToolOutputs?: number;\n maxChainedLoads?: number;\n /** Pages adding no converted message loaded per request before it stops; see {@link DEEP_AGENT_MAX_UNSEEN_HISTORY_LOADS}. */\n maxUnseenLoads?: number;\n /** A page interest resolved (telemetry). */\n onHistoryLoad?: ((event: DeepAgentHistoryLoadEvent) => void) | undefined;\n /** A read failed; the sync itself recovers (the pending marks are released). */\n onError?: ((error: unknown, command: 'athena/interest' | 'history/tool_output') => void) | undefined;\n now?: () => number;\n}\n\nexport interface DeepAgentWindowSyncState {\n /** The joined window, or `null` while the head interest has not resolved (both halves are inert). */\n window: DeepAgentMessageWindow | null;\n /** Whether the host holds messages older than the loaded window. */\n hasOlder: boolean;\n /**\n * Whether the next page can be asked for: older messages exist and the\n * host's interest cap has room for them. `hasOlder && !canLoadOlder` is the\n * depth limit (`MAX_INTERESTS × MAX_MESSAGE_WINDOW` messages loaded in one\n * connection) — an edge row says so instead of offering a dead button.\n */\n canLoadOlder: boolean;\n /** A page of older history is in flight. */\n loading: boolean;\n /** Ask for the next page of older history now (an edge row's button, a keypress). A no-op before the head resolved or at the beginning. */\n loadOlder: () => void;\n}\n\nconst everyMessageMounted = (): boolean => true;\nconst defaultNow = (): number => Date.now();\nconst noopSubscribe = () => () => {};\n\n/** The statewire extras of the nearest aui thread; throws on a non-statewire thread like the library's own hooks. */\nconst useStatewireExtras = (): StatewireThread.Extras =>\n useAuiState((s) => {\n if (!hasStatewireThreadExtras(s.thread.extras)) {\n throw new Error('useDeepAgentWindowSync requires a statewire thread');\n }\n return s.thread.extras as StatewireThread.Extras;\n });\n\n/** The joined interest window of the nearest statewire thread. */\nexport function useDeepAgentMessageWindow(): DeepAgentMessageWindow | null {\n const documents = useStatewireExtras().documents;\n const mounted = useSyncExternalStore(\n documents?.subscribe ?? noopSubscribe,\n () => documents?.list(),\n () => documents?.list()\n );\n return useMemo(() => readDeepAgentMessageWindow(mounted), [mounted]);\n}\n\n/**\n * The client half of the interest window, shared by every surface — mounted\n * once per runtime, inside its aui provider.\n *\n * - **Older history.** While the host renderer reports the top of the loaded\n * history near (`nearTop`) and the window says older messages exist, this\n * re-states the interests with one more page (anchored at the window's\n * first message) — the host mounts its documents for this client alone —\n * chaining at most `maxChainedLoads` pages per approach; `loadOlder` asks\n * for one page on demand (an edge row's button). Never two loads in flight.\n * A reconnect whose hello does not carry the interests this mount last\n * stated (the host remembers a client id's view across its attaches; a new\n * host instance does not) re-states them.\n * - **Cut tool outputs.** Tool cards whose output the wire carried cut\n * (`artifact._athena_content_truncated`) get it fetched whole through\n * `history/tool_output` once their message is mounted, at most\n * `maxConcurrentToolOutputs` at a time; the converter puts it back\n * (`toolOutputs`), so the card re-renders complete. An output the host\n * replaced since (the marker's `chars` changed) is fetched again.\n */\n/**\n * Whether an older page put a new converted message ahead of the thread's\n * first one. Older history only ever merges into or lands before the first\n * converted message, so the second one is a stable landmark: it moved down iff\n * the page showed something. A new tail message does not move it. Without a\n * second message (or once it is gone) the converted count decides.\n */\nfunction pageShowedEarlierMessage(\n from: { count: number; secondId: string | undefined },\n messages: readonly DeepAgentWindowSyncMessage[]\n): boolean {\n if (from.secondId !== undefined) {\n const index = messages.findIndex((message) => message.id === from.secondId);\n if (index !== -1) return index > 1;\n }\n return messages.length > from.count;\n}\n\n/**\n * Whether the loaded thread still opens without context: it should open on a\n * prompt and hold at least one earlier turn, so the newest turn shows with the\n * one before it (a turn is a prompt followed by its reply). Queued and live\n * prompts land at the tail with no reply yet, so they never count; prompts\n * alone need nothing. Without roles, a lone converted message stands in for it.\n */\nfunction opensMidTurn(messages: readonly DeepAgentWindowSyncMessage[]): boolean {\n const first = messages[0];\n if (first === undefined) return false;\n if (messages.every((message) => message.role === undefined)) return messages.length < 2;\n if (first.role !== 'user') return true;\n if (messages.every((message) => message.role === 'user')) return false;\n let turns = 0;\n for (let index = 1; index < messages.length; index += 1) {\n if (messages[index - 1]!.role === 'user' && messages[index]!.role !== 'user') turns += 1;\n }\n return turns < 2;\n}\n\nexport function useDeepAgentWindowSync({\n messages,\n pageSize,\n toolOutputs,\n nearTop = false,\n nearTopEpoch = 0,\n isMessageMounted = everyMessageMounted,\n maxConcurrentToolOutputs = Number.POSITIVE_INFINITY,\n maxChainedLoads = DEEP_AGENT_MAX_CHAINED_HISTORY_LOADS,\n maxUnseenLoads = DEEP_AGENT_MAX_UNSEEN_HISTORY_LOADS,\n onHistoryLoad,\n onError,\n now = defaultNow,\n}: UseDeepAgentWindowSyncOptions): DeepAgentWindowSyncState {\n const { sendCommand, invoke, connection } = useStatewireExtras();\n const window = useDeepAgentMessageWindow();\n const [loading, setLoading] = useState(false);\n const [requests, setRequests] = useState(0);\n const servedRequestsRef = useRef(0);\n const inflightRef = useRef(false);\n const chainRef = useRef({ epoch: 0, loads: 0, unseen: 0, requested: false });\n // Pages loaded to show the opening turn's prompt; `null` once it shows, the\n // user took over, or a page failed — never re-armed for this mount.\n const openingFillRef = useRef<number | null>(0);\n // The converted thread when the in-flight page was stated; `null` once its\n // settle was judged (or it failed).\n const pageFromRef = useRef<{ count: number; secondId: string | undefined } | null>(null);\n const aliveRef = useRef(true);\n // The interests this mount last stated, re-stated on the next connected\n // session (a hello resets the documents) so a reconnect keeps the loaded history.\n const statedRef = useRef<DeepAgentInterestRequest[] | null>(null);\n const restatedConnectionRef = useRef<unknown>(null);\n // Outputs already asked for and answered by this mount — fetched, refused,\n // or failed — by the `chars` they were asked for. The converter re-runs on\n // every wire change, and the store is a bounded LRU: without this memory a\n // refused read would leave on every pass, and once a transcript holds more\n // cut outputs than the store retains, each fetch would evict a still-loaded\n // output and the next pass would fetch it again, forever. An evicted output\n // renders its cut text (the REST display limit) rather than re-entering the\n // loop; a marker whose `chars` moved (the host replaced the output) is asked\n // for again.\n const answeredRef = useRef(new Map<string, number>());\n // Reads this mount has in flight, and whether a pass left outputs waiting\n // for one to settle (`maxConcurrentToolOutputs`): only then does a settle\n // re-run the pass, so an unbounded mount renders no more than before.\n const toolOutputsInFlightRef = useRef(0);\n const toolOutputsWaitingRef = useRef(false);\n const [toolOutputSettles, setToolOutputSettles] = useState(0);\n const onHistoryLoadRef = useRef(onHistoryLoad);\n onHistoryLoadRef.current = onHistoryLoad;\n const onErrorRef = useRef(onError);\n onErrorRef.current = onError;\n const nowRef = useRef(now);\n nowRef.current = now;\n useEffect(() => {\n aliveRef.current = true;\n return () => {\n aliveRef.current = false;\n };\n }, []);\n\n useEffect(() => {\n if (connection.status !== 'connected' || restatedConnectionRef.current === connection) return;\n // Decided once per connected session, on the hello's interest document.\n if (window === null) return;\n restatedConnectionRef.current = connection;\n const stated = statedRef.current;\n if (stated === null || interestsCovered(window.requests, stated)) return;\n invoke(DEEP_AGENT_INTEREST_PROTOCOL, 'set', [stated]).catch((error: unknown) => {\n onErrorRef.current?.(error, 'athena/interest');\n });\n }, [connection, invoke, window]);\n\n useEffect(() => {\n if (window === null || inflightRef.current) return;\n const from = pageFromRef.current;\n pageFromRef.current = null;\n const lastPageUnseen =\n from !== null && from.count > 0 && !pageShowedEarlierMessage(from, messages);\n const pageRequests = pageInterestRequests(window, pageSize);\n if (pageRequests === null) return;\n const requested = requests !== servedRequestsRef.current;\n const chain = chainRef.current;\n let fillPage = false;\n if (\n openingFillRef.current !== null &&\n (requested || nearTop || (messages.length > 0 && !opensMidTurn(messages)))\n ) {\n openingFillRef.current = null;\n }\n if (requested) {\n // An explicit ask re-arms the chain for this approach.\n servedRequestsRef.current = requests;\n chainRef.current = { epoch: nearTopEpoch, loads: 1, unseen: 0, requested: true };\n } else if (lastPageUnseen && (chain.requested || (nearTop && chain.epoch === nearTopEpoch))) {\n // The page landed inside the first loaded turn: keep going until one shows.\n if (chain.unseen >= maxUnseenLoads) return;\n chain.unseen += 1;\n } else if (openingFillRef.current !== null && opensMidTurn(messages)) {\n if (openingFillRef.current >= maxUnseenLoads) return;\n openingFillRef.current += 1;\n fillPage = true;\n } else {\n if (!nearTop) return;\n if (chain.epoch !== nearTopEpoch) {\n chainRef.current = { epoch: nearTopEpoch, loads: 0, unseen: 0, requested: false };\n }\n if (chainRef.current.loads >= maxChainedLoads) return;\n chainRef.current.loads += 1;\n }\n pageFromRef.current = { count: messages.length, secondId: messages[1]?.id };\n const page = window.pages + 1;\n const request = pageRequests[pageRequests.length - 1] as DeepAgentInterestRequest;\n inflightRef.current = true;\n setLoading(true);\n const startedAt = nowRef.current();\n invoke(DEEP_AGENT_INTEREST_PROTOCOL, 'set', [pageRequests])\n .then(() => {\n statedRef.current = pageRequests;\n onHistoryLoadRef.current?.({\n page,\n request,\n durationMs: Math.max(0, Math.round(nowRef.current() - startedAt)),\n });\n })\n .catch((error: unknown) => {\n pageFromRef.current = null;\n if (fillPage) openingFillRef.current = null;\n onErrorRef.current?.(error, 'athena/interest');\n })\n .finally(() => {\n inflightRef.current = false;\n if (aliveRef.current) setLoading(false);\n });\n // `loading` re-arms the chain once a page settled after its documents moved the window.\n }, [\n nearTop,\n nearTopEpoch,\n requests,\n window,\n loading,\n messages,\n invoke,\n maxChainedLoads,\n maxUnseenLoads,\n pageSize,\n ]);\n\n useEffect(() => {\n if (window === null || toolOutputs === undefined) return;\n toolOutputsWaitingRef.current = false;\n for (const message of messages) {\n if (!isMessageMounted(message.id)) continue;\n for (const part of message.content) {\n if (part.type !== 'tool-call') continue;\n const marker = readTruncatedToolOutputArtifact(part.artifact);\n if (marker === null || toolOutputs.isPending(marker.messageId)) continue;\n // Fetched for this very length already; a different length means the\n // host replaced the output under the same id since.\n if (toolOutputs.entry(marker.messageId)?.chars === marker.chars) continue;\n if (answeredRef.current.get(marker.messageId) === marker.chars) continue;\n if (toolOutputsInFlightRef.current >= maxConcurrentToolOutputs) {\n toolOutputsWaitingRef.current = true;\n return;\n }\n const { messageId, chars } = marker;\n toolOutputsInFlightRef.current += 1;\n toolOutputs.markPending(messageId);\n Promise.resolve(sendCommand(buildToolOutputCommand({ messageId })))\n .then((payload) => {\n answeredRef.current.set(messageId, chars);\n const result = readToolOutputResult(payload);\n if (result === null) {\n toolOutputs.clearPending(messageId);\n return;\n }\n toolOutputs.set(result.messageId, { content: result.content, chars });\n })\n .catch((error: unknown) => {\n answeredRef.current.set(messageId, chars);\n toolOutputs.clearPending(messageId);\n onErrorRef.current?.(error, 'history/tool_output');\n })\n .finally(() => {\n toolOutputsInFlightRef.current -= 1;\n if (toolOutputsWaitingRef.current && aliveRef.current) {\n setToolOutputSettles((count) => count + 1);\n }\n });\n }\n }\n }, [\n messages,\n isMessageMounted,\n window,\n sendCommand,\n toolOutputs,\n maxConcurrentToolOutputs,\n toolOutputSettles,\n ]);\n\n const loadOlder = useCallback(() => {\n setRequests((count) => count + 1);\n }, []);\n\n const canLoadOlder = useMemo(\n () => window !== null && pageInterestRequests(window, pageSize) !== null,\n [window, pageSize]\n );\n\n return { window, hasOlder: window?.hasOlder ?? false, canLoadOlder, loading, loadOlder };\n}\n"],"names":["useAuiState","hasStatewireThreadExtras","useSyncExternalStore","useMemo","readDeepAgentMessageWindow","useState","useRef","useEffect","interestsCovered","DEEP_AGENT_INTEREST_PROTOCOL","pageInterestRequests","_a","readTruncatedToolOutputArtifact","buildTo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AAC;AAAA,MACL;AAAA,IACF;AAAA,EACF,GAAG;AAAA,IACD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACD;AAED,QAAM,YAAYI,MAAAA,YAAY,MAAM;AAClC,gBAAY,CAAC,UAAU,QAAQ,CAAC;AAAA,EAClC,GAAG,CAAA,CAAE;AAEL,QAAM,eAAeZ,MAAAA;AAAAA,IACnB,MAAM,WAAW,QAAQO,cAAAA,qBAAqB,QAAQ,QAAQ,MAAM;AAAA,IACpE,CAAC,QAAQ,QAAQ;AAAA,EAAA;AAGnB,SAAO,EAAE,QAAQ,WAAU,iCAAQ,aAAY,OAAO,cAAc,SAAS,UAAA;AAC/E;;;;;"}
1
+ {"version":3,"file":"use-deep-agent-window-sync.cjs","sources":["../../../../agent-runtime/src/use-deep-agent-window-sync.ts"],"sourcesContent":["import type { StatewireThread } from '@assistant-ui/react-statewire';\nimport { useAuiState } from '@assistant-ui/store';\nimport { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';\nimport { DEEP_AGENT_INTEREST_PROTOCOL } from './generated/runconfig-contract';\nimport {\n buildToolOutputCommand,\n type DeepAgentInterestRequest,\n type DeepAgentMessageWindow,\n interestsCovered,\n pageInterestRequests,\n readDeepAgentMessageWindow,\n readToolOutputResult,\n readTruncatedToolOutputArtifact,\n} from './message-window';\nimport { hasStatewireThreadExtras } from './thread-extras';\nimport type { DeepAgentToolOutputStore } from './tool-outputs';\n\n/**\n * Pages of older history chained per approach to the top. A renderer lowers\n * its near-top level once prepended content has pushed the first message out\n * of its band; this bounds the case where it cannot (no viewport to scroll,\n * a list too short to overflow) so a 2,000-message thread never streams whole.\n */\nexport const DEEP_AGENT_MAX_CHAINED_HISTORY_LOADS = 3;\n\n/**\n * Pages of older history that add no converted message — every message on\n * them folds into the first loaded turn, such as one agent run's hundreds of\n * tool steps — loaded on top of a request (or an approach's chain) before it\n * stops. Such a page changes nothing the user can see, so it neither answers\n * an ask nor counts against the per-approach chain.\n */\nexport const DEEP_AGENT_MAX_UNSEEN_HISTORY_LOADS = 25;\n\n/** The converted thread messages the tool-output half scans (web and native `ThreadMessage` both satisfy it). */\nexport interface DeepAgentWindowSyncMessage {\n readonly id: string;\n /** The converted role; lets the opening fill tell a turn's prompt from its reply. */\n readonly role?: string;\n readonly content: readonly { readonly type: string; readonly artifact?: unknown }[];\n}\n\n/** One page interest round trip, for the host's telemetry. */\nexport interface DeepAgentHistoryLoadEvent {\n /** The page's ordinal (`1` extends the head). */\n page: number;\n request: DeepAgentInterestRequest;\n durationMs: number;\n}\n\nexport interface UseDeepAgentWindowSyncOptions {\n /**\n * The converted thread messages — read by the host through its platform\n * `useAuiState((s) => s.thread.messages)`, so this hook imports neither\n * `@assistant-ui/react` nor `@assistant-ui/react-native`.\n */\n messages: readonly DeepAgentWindowSyncMessage[];\n /** Messages per page; the thread's window size by default. */\n pageSize?: number;\n /**\n * Full tool outputs fetched back for cut tool messages; the same store the\n * thread converts with (`useDeepAgentThread({ toolOutputs })`). Omitted, the\n * tool-output half is inert (a surface that never shows a cut output whole).\n */\n toolOutputs?: DeepAgentToolOutputStore | undefined;\n /**\n * The renderer's report that the top of the LOADED history is near — a\n * level, not an edge: while it holds and older messages exist, pages load\n * one after another (bounded by `maxChainedLoads` per approach). Omitted for\n * hosts with only a manual affordance (`loadOlder`).\n */\n nearTop?: boolean;\n /** Bumped on every rise of `nearTop` (and every explicit request), so the chain bound is per approach. */\n nearTopEpoch?: number;\n /**\n * Whether a message's content is mounted right now, so lazy fetches (cut\n * tool outputs) target what the user can see rather than the whole loaded\n * history. Omitted: every message counts as mounted (the flat renderers).\n */\n isMessageMounted?: ((messageId: string) => boolean) | undefined;\n /**\n * Cut tool outputs this mount reads at once; the rest wait for one to\n * settle. One mounted message can hold a whole agent run — a hundred tool\n * steps — and the host rate-limits a client's frames, so a reader that sends\n * them all together gets refusals back for most of them. Omitted: every\n * mounted output is asked for together (renderers whose mounted set is\n * already small).\n */\n maxConcurrentToolOutputs?: number;\n maxChainedLoads?: number;\n /** Pages adding no converted message loaded per request before it stops; see {@link DEEP_AGENT_MAX_UNSEEN_HISTORY_LOADS}. */\n maxUnseenLoads?: number;\n /** A page interest resolved (telemetry). */\n onHistoryLoad?: ((event: DeepAgentHistoryLoadEvent) => void) | undefined;\n /** A read failed; the sync itself recovers (the pending marks are released). */\n onError?: ((error: unknown, command: 'athena/interest' | 'history/tool_output') => void) | undefined;\n now?: () => number;\n}\n\nexport interface DeepAgentWindowSyncState {\n /** The joined window, or `null` while the head interest has not resolved (both halves are inert). */\n window: DeepAgentMessageWindow | null;\n /** Whether the host holds messages older than the loaded window. */\n hasOlder: boolean;\n /**\n * Whether the next page can be asked for: older messages exist and the\n * host's interest cap has room for them. `hasOlder && !canLoadOlder` is the\n * depth limit (`MAX_INTERESTS × MAX_MESSAGE_WINDOW` messages loaded in one\n * connection) — an edge row says so instead of offering a dead button.\n */\n canLoadOlder: boolean;\n /** A page of older history is in flight. */\n loading: boolean;\n /** Ask for the next page of older history now (an edge row's button, a keypress). A no-op before the head resolved or at the beginning. */\n loadOlder: () => void;\n}\n\nconst everyMessageMounted = (): boolean => true;\nconst defaultNow = (): number => Date.now();\nconst noopSubscribe = () => () => {};\n\n/** The statewire extras of the nearest aui thread; throws on a non-statewire thread like the library's own hooks. */\nconst useStatewireExtras = (): StatewireThread.Extras =>\n useAuiState((s) => {\n if (!hasStatewireThreadExtras(s.thread.extras)) {\n throw new Error('useDeepAgentWindowSync requires a statewire thread');\n }\n return s.thread.extras as StatewireThread.Extras;\n });\n\n/** The joined interest window of the nearest statewire thread. */\nexport function useDeepAgentMessageWindow(): DeepAgentMessageWindow | null {\n const documents = useStatewireExtras().documents;\n const mounted = useSyncExternalStore(\n documents?.subscribe ?? noopSubscribe,\n () => documents?.list(),\n () => documents?.list()\n );\n return useMemo(() => readDeepAgentMessageWindow(mounted), [mounted]);\n}\n\n/**\n * The client half of the interest window, shared by every surface — mounted\n * once per runtime, inside its aui provider.\n *\n * - **Older history.** While the host renderer reports the top of the loaded\n * history near (`nearTop`) and the window says older messages exist, this\n * re-states the interests with one more page (anchored at the window's\n * first message) — the host mounts its documents for this client alone —\n * chaining at most `maxChainedLoads` pages per approach; `loadOlder` asks\n * for one page on demand (an edge row's button). Never two loads in flight.\n * A reconnect whose hello does not carry the interests this mount last\n * stated (the host remembers a client id's view across its attaches; a new\n * host instance does not) re-states them.\n * - **Cut tool outputs.** Tool cards whose output the wire carried cut\n * (`artifact._athena_content_truncated`) get it fetched whole through\n * `history/tool_output` once their message is mounted, at most\n * `maxConcurrentToolOutputs` at a time; the converter puts it back\n * (`toolOutputs`), so the card re-renders complete. An output the host\n * replaced since (the marker's `chars` changed) is fetched again.\n */\n/**\n * Whether an older page put a new converted message ahead of the thread's\n * first one. Older history only ever merges into or lands before the first\n * converted message, so the second one is a stable landmark: it moved down iff\n * the page showed something. A new tail message does not move it. Without a\n * second message (or once it is gone) the converted count decides.\n */\nfunction pageShowedEarlierMessage(\n from: { count: number; secondId: string | undefined },\n messages: readonly DeepAgentWindowSyncMessage[]\n): boolean {\n if (from.secondId !== undefined) {\n const index = messages.findIndex((message) => message.id === from.secondId);\n if (index !== -1) return index > 1;\n }\n return messages.length > from.count;\n}\n\n/**\n * Whether the loaded thread still opens without context: it should open on a\n * prompt and hold at least one earlier turn, so the newest turn shows with the\n * one before it (a turn is a prompt followed by its reply). Queued and live\n * prompts land at the tail with no reply yet, so they never count; prompts\n * alone need nothing. Without roles, a lone converted message stands in for it.\n */\nfunction opensMidTurn(messages: readonly DeepAgentWindowSyncMessage[]): boolean {\n const first = messages[0];\n if (first === undefined) return false;\n if (messages.every((message) => message.role === undefined)) return messages.length < 2;\n if (first.role !== 'user') return true;\n if (messages.every((message) => message.role === 'user')) return false;\n let turns = 0;\n for (let index = 1; index < messages.length; index += 1) {\n if (messages[index - 1]!.role === 'user' && messages[index]!.role !== 'user') turns += 1;\n }\n return turns < 2;\n}\n\nexport function useDeepAgentWindowSync({\n messages,\n pageSize,\n toolOutputs,\n nearTop = false,\n nearTopEpoch = 0,\n isMessageMounted = everyMessageMounted,\n maxConcurrentToolOutputs = Number.POSITIVE_INFINITY,\n maxChainedLoads = DEEP_AGENT_MAX_CHAINED_HISTORY_LOADS,\n maxUnseenLoads = DEEP_AGENT_MAX_UNSEEN_HISTORY_LOADS,\n onHistoryLoad,\n onError,\n now = defaultNow,\n}: UseDeepAgentWindowSyncOptions): DeepAgentWindowSyncState {\n const { sendCommand, invoke, connection } = useStatewireExtras();\n const window = useDeepAgentMessageWindow();\n const [loading, setLoading] = useState(false);\n const [requests, setRequests] = useState(0);\n const servedRequestsRef = useRef(0);\n const inflightRef = useRef(false);\n const chainRef = useRef({ epoch: 0, loads: 0, unseen: 0, requested: false });\n // Pages loaded to show the opening turn's prompt; `null` once it shows, the\n // user took over, or a page failed — never re-armed for this mount.\n const openingFillRef = useRef<number | null>(0);\n // The converted thread when the in-flight page was stated; `null` once its\n // settle was judged (or it failed).\n const pageFromRef = useRef<{ count: number; secondId: string | undefined } | null>(null);\n const aliveRef = useRef(true);\n // The interests this mount last stated, re-stated on the next connected\n // session (a hello resets the documents) so a reconnect keeps the loaded history.\n const statedRef = useRef<DeepAgentInterestRequest[] | null>(null);\n const restatedConnectionRef = useRef<unknown>(null);\n // Outputs already asked for and answered by this mount — fetched, refused,\n // or failed — by the `chars` they were asked for. The converter re-runs on\n // every wire change, and the store is a bounded LRU: without this memory a\n // refused read would leave on every pass, and once a transcript holds more\n // cut outputs than the store retains, each fetch would evict a still-loaded\n // output and the next pass would fetch it again, forever. An evicted output\n // renders its cut text (the REST display limit) rather than re-entering the\n // loop; a marker whose `chars` moved (the host replaced the output) is asked\n // for again.\n const answeredRef = useRef(new Map<string, number>());\n // Reads this mount has in flight, and whether a pass left outputs waiting\n // for one to settle (`maxConcurrentToolOutputs`): only then does a settle\n // re-run the pass, so an unbounded mount renders no more than before.\n const toolOutputsInFlightRef = useRef(0);\n const toolOutputsWaitingRef = useRef(false);\n const [toolOutputSettles, setToolOutputSettles] = useState(0);\n const onHistoryLoadRef = useRef(onHistoryLoad);\n onHistoryLoadRef.current = onHistoryLoad;\n const onErrorRef = useRef(onError);\n onErrorRef.current = onError;\n const nowRef = useRef(now);\n nowRef.current = now;\n useEffect(() => {\n aliveRef.current = true;\n return () => {\n aliveRef.current = false;\n };\n }, []);\n\n useEffect(() => {\n if (connection.status !== 'connected' || restatedConnectionRef.current === connection) return;\n // Decided once per connected session, on the hello's interest document.\n if (window === null) return;\n restatedConnectionRef.current = connection;\n const stated = statedRef.current;\n if (stated === null || interestsCovered(window.requests, stated)) return;\n invoke(DEEP_AGENT_INTEREST_PROTOCOL, 'set', [stated]).catch((error: unknown) => {\n onErrorRef.current?.(error, 'athena/interest');\n });\n }, [connection, invoke, window]);\n\n useEffect(() => {\n if (window === null || inflightRef.current) return;\n const from = pageFromRef.current;\n pageFromRef.current = null;\n const lastPageUnseen =\n from !== null && from.count > 0 && !pageShowedEarlierMessage(from, messages);\n const pageRequests = pageInterestRequests(window, pageSize);\n if (pageRequests === null) return;\n const requested = requests !== servedRequestsRef.current;\n const chain = chainRef.current;\n let fillPage = false;\n if (\n openingFillRef.current !== null &&\n (requested || nearTop || (messages.length > 0 && !opensMidTurn(messages)))\n ) {\n openingFillRef.current = null;\n }\n if (requested) {\n // An explicit ask re-arms the chain for this approach.\n servedRequestsRef.current = requests;\n chainRef.current = { epoch: nearTopEpoch, loads: 1, unseen: 0, requested: true };\n } else if (lastPageUnseen && (chain.requested || (nearTop && chain.epoch === nearTopEpoch))) {\n // The page landed inside the first loaded turn: keep going until one shows.\n if (chain.unseen >= maxUnseenLoads) return;\n chain.unseen += 1;\n } else if (openingFillRef.current !== null && opensMidTurn(messages)) {\n if (openingFillRef.current >= maxUnseenLoads) return;\n openingFillRef.current += 1;\n fillPage = true;\n } else {\n if (!nearTop) return;\n if (chain.epoch !== nearTopEpoch) {\n chainRef.current = { epoch: nearTopEpoch, loads: 0, unseen: 0, requested: false };\n }\n if (chainRef.current.loads >= maxChainedLoads) return;\n chainRef.current.loads += 1;\n }\n pageFromRef.current = { count: messages.length, secondId: messages[1]?.id };\n const page = window.pages + 1;\n const request = pageRequests[pageRequests.length - 1] as DeepAgentInterestRequest;\n inflightRef.current = true;\n setLoading(true);\n const startedAt = nowRef.current();\n invoke(DEEP_AGENT_INTEREST_PROTOCOL, 'set', [pageRequests])\n .then(() => {\n statedRef.current = pageRequests;\n onHistoryLoadRef.current?.({\n page,\n request,\n durationMs: Math.max(0, Math.round(nowRef.current() - startedAt)),\n });\n })\n .catch((error: unknown) => {\n pageFromRef.current = null;\n if (fillPage) openingFillRef.current = null;\n onErrorRef.current?.(error, 'athena/interest');\n })\n .finally(() => {\n inflightRef.current = false;\n if (aliveRef.current) setLoading(false);\n });\n // `loading` re-arms the chain once a page settled after its documents moved the window.\n }, [\n nearTop,\n nearTopEpoch,\n requests,\n window,\n loading,\n messages,\n invoke,\n maxChainedLoads,\n maxUnseenLoads,\n pageSize,\n ]);\n\n useEffect(() => {\n if (window === null || toolOutputs === undefined) return;\n toolOutputsWaitingRef.current = false;\n for (const message of messages) {\n if (!isMessageMounted(message.id)) continue;\n for (const part of message.content) {\n if (part.type !== 'tool-call') continue;\n const marker = readTruncatedToolOutputArtifact(part.artifact);\n if (marker === null || toolOutputs.isPending(marker.messageId)) continue;\n // Fetched for this very length already; a different length means the\n // host replaced the output under the same id since.\n if (toolOutputs.entry(marker.messageId)?.chars === marker.chars) continue;\n if (answeredRef.current.get(marker.messageId) === marker.chars) continue;\n if (toolOutputsInFlightRef.current >= maxConcurrentToolOutputs) {\n toolOutputsWaitingRef.current = true;\n return;\n }\n const { messageId, chars } = marker;\n toolOutputsInFlightRef.current += 1;\n toolOutputs.markPending(messageId);\n Promise.resolve(sendCommand(buildToolOutputCommand({ messageId })))\n .then((payload) => {\n answeredRef.current.set(messageId, chars);\n const result = readToolOutputResult(payload);\n if (result === null) {\n toolOutputs.clearPending(messageId);\n return;\n }\n toolOutputs.set(result.messageId, { content: result.content, chars });\n })\n .catch((error: unknown) => {\n answeredRef.current.set(messageId, chars);\n toolOutputs.clearPending(messageId);\n onErrorRef.current?.(error, 'history/tool_output');\n })\n .finally(() => {\n toolOutputsInFlightRef.current -= 1;\n if (toolOutputsWaitingRef.current && aliveRef.current) {\n setToolOutputSettles((count) => count + 1);\n }\n });\n }\n }\n }, [\n messages,\n isMessageMounted,\n window,\n sendCommand,\n toolOutputs,\n maxConcurrentToolOutputs,\n toolOutputSettles,\n ]);\n\n const loadOlder = useCallback(() => {\n setRequests((count) => count + 1);\n }, []);\n\n const canLoadOlder = useMemo(\n () => window !== null && pageInterestRequests(window, pageSize) !== null,\n [window, pageSize]\n );\n\n return { window, hasOlder: window?.hasOlder ?? false, canLoadOlder, loading, loadOlder };\n}\n"],"names":["useAuiState","hasStatewireThreadExtras","useSyncExternalStore","useMemo","readDeepAgentMessageWindow","useState","useRef","useEffect","interestsCovered","DEEP_AGENT_INTEREST_PROTOCOL","pageInterestRequests","_a","readTruncatedToolOutputArtifact","buildToolOutputCommand","readToolOutputResult","useCallback"],"mappings":";;;;;;;AAuBO,MAAM,uCAAuC;AAS7C,MAAM,sCAAsC;AAqFnD,MAAM,sBAAsB,MAAe;AAC3C,MAAM,aAAa,MAAc,KAAK,IAAA;AACtC,MAAM,gBAAgB,MAAM,MAAM;AAAC;AAGnC,MAAM,qBAAqB,MACzBA,kBAAY,CAAC,MAAM;AACjB,MAAI,CAACC,aAAAA,yBAAyB,EAAE,OAAO,MAAM,GAAG;AAC9C,UAAM,IAAI,MAAM,oDAAoD;AAAA,EACtE;AACA,SAAO,EAAE,OAAO;AAClB,CAAC;AAGI,SAAS,4BAA2D;AACzE,QAAM,YAAY,qBAAqB;AACvC,QAAM,UAAUC,WAAAA;AAAAA,KACd,uCAAW,cAAa;AAAA,IACxB,MAAM,uCAAW;AAAA,IACjB,MAAM,uCAAW;AAAA,EAAK;AAExB,SAAOC,WAAAA,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@assistant-ui/store");
4
- const react = require("react");
4
+ const require$$0 = require("react");
5
5
  function useHistoricalEditAttachments() {
6
6
  const aui = store.useAui();
7
7
  const isEditing = store.useAuiState((state) => state.message.composer.isEditing);
8
- const restoredMessage = react.useRef(null);
9
- const [restoreError, setRestoreError] = react.useState();
10
- react.useEffect(() => {
8
+ const restoredMessage = require$$0.useRef(null);
9
+ const [restoreError, setRestoreError] = require$$0.useState();
10
+ require$$0.useEffect(() => {
11
11
  if (!isEditing) {
12
12
  restoredMessage.current = null;
13
13
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"use-historical-edit-attachments.cjs","sources":["../../../../agent-runtime/src/use-historical-edit-attachments.ts"],"sourcesContent":["import type { ThreadUserMessagePart } from \"@assistant-ui/core\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\nimport { useEffect, useRef, useState } from \"react\";\n\n/** Restore once per edit so published SDKs work with unpatched upstream AUI. */\nexport function useHistoricalEditAttachments(): void {\n\tconst aui = useAui();\n\tconst isEditing = useAuiState((state) => state.message.composer.isEditing);\n\tconst restoredMessage = useRef<string | null>(null);\n\tconst [restoreError, setRestoreError] = useState<Error>();\n\tuseEffect(() => {\n\t\tif (!isEditing) {\n\t\t\trestoredMessage.current = null;\n\t\t\treturn;\n\t\t}\n\t\tconst message = aui.message().getState();\n\t\tif (message.role !== \"user\" || restoredMessage.current === message.id)\n\t\t\treturn;\n\t\trestoredMessage.current = message.id;\n\t\tconst composer = aui.message().composer();\n\t\t// Match occurrences, preserving repeated images without duplicating parts\n\t\t// already lifted by the monorepo's patched core. Removing one afterward\n\t\t// must remain a deliberate removal throughout this edit session.\n\t\tconst existing = composer\n\t\t\t.getState()\n\t\t\t.attachments.flatMap((attachment) => attachment.content ?? []);\n\t\tfor (const part of message.content) {\n\t\t\tif (part.type !== \"image\" && part.type !== \"file\") continue;\n\t\t\tconst index = existing.findIndex((candidate) =>\n\t\t\t\tsamePart(candidate, part),\n\t\t\t);\n\t\t\tif (index >= 0) {\n\t\t\t\texisting.splice(index, 1);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tvoid composer\n\t\t\t\t.addAttachment({\n\t\t\t\t\tname: part.filename ?? (part.type === \"image\" ? \"image\" : \"document\"),\n\t\t\t\t\ttype: part.type === \"image\" ? \"image\" : \"document\",\n\t\t\t\t\tcontentType: part.type === \"image\" ? \"image/*\" : part.mimeType,\n\t\t\t\t\tcontent: [part],\n\t\t\t\t})\n\t\t\t\t.catch((error: unknown) => {\n\t\t\t\t\tsetRestoreError(\n\t\t\t\t\t\terror instanceof Error ? error : new Error(String(error)),\n\t\t\t\t\t);\n\t\t\t\t});\n\t\t}\n\t}, [aui, isEditing]);\n\tif (restoreError) throw restoreError;\n}\n\nfunction samePart(\n\tleft: ThreadUserMessagePart,\n\tright: ThreadUserMessagePart,\n): boolean {\n\tif (left.type === \"image\" && right.type === \"image\")\n\t\treturn left.image === right.image;\n\tif (left.type === \"file\" && right.type === \"file\")\n\t\treturn (\n\t\t\tleft.data === right.data &&\n\t\t\tleft.mimeType === right.mimeType &&\n\t\t\tleft.filename === right.filename\n\t\t);\n\treturn false;\n}\n"],"names":["useAui","useAuiState","useRef","useState","useEffect"],"mappings":";;;;AAKO,SAAS,+BAAqC;AACpD,QAAM,MAAMA,MAAAA,OAAA;AACZ,QAAM,YAAYC,MAAAA,YAAY,CAAC,UAAU,MAAM,QAAQ,SAAS,SAAS;AACzE,QAAM,kBAAkBC,MAAAA,OAAsB,IAAI;AAClD,QAAM,CAAC,cAAc,eAAe,IAAIC,eAAA;AACxCC,QAAAA,UAAU,MAAM;AACf,QAAI,CAAC,WAAW;AACf,sBAAgB,UAAU;AAC1B;AAAA,IACD;AACA,UAAM,UAAU,IAAI,QAAA,EAAU,SAAA;AAC9B,QAAI,QAAQ,SAAS,UAAU,gBAAgB,YAAY,QAAQ;AAClE;AACD,oBAAgB,UAAU,QAAQ;AAClC,UAAM,WAAW,IAAI,QAAA,EAAU,SAAA;AAI/B,UAAM,WAAW,SACf,SAAA,EACA,YAAY,QAAQ,CAAC,eAAe,WAAW,WAAW,EAAE;AAC9D,eAAW,QAAQ,QAAQ,SAAS;AACnC,UAAI,KAAK,SAAS,WAAW,KAAK,SAAS,OAAQ;AACnD,YAAM,QAAQ,SAAS;AAAA,QAAU,CAAC,cACjC,SAAS,WAAW,IAAI;AAAA,MAAA;AAEzB,UAAI,SAAS,GAAG;AACf,iBAAS,OAAO,OAAO,CAAC;AACxB;AAAA,MACD;AACA,WAAK,SACH,cAAc;AAAA,QACd,MAAM,KAAK,aAAa,KAAK,SAAS,UAAU,UAAU;AAAA,QAC1D,MAAM,KAAK,SAAS,UAAU,UAAU;AAAA,QACxC,aAAa,KAAK,SAAS,UAAU,YAAY,KAAK;AAAA,QACtD,SAAS,CAAC,IAAI;AAAA,MAAA,CACd,EACA,MAAM,CAAC,UAAmB;AAC1B;AAAA,UACC,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;AAAA,QAAA;AAAA,MAE1D,CAAC;AAAA,IACH;AAAA,EACD,GAAG,CAAC,KAAK,SAAS,CAAC;AACnB,MAAI,aAAc,OAAM;AACzB;AAEA,SAAS,SACR,MACA,OACU;AACV,MAAI,KAAK,SAAS,WAAW,MAAM,SAAS;AAC3C,WAAO,KAAK,UAAU,MAAM;AAC7B,MAAI,KAAK,SAAS,UAAU,MAAM,SAAS;AAC1C,WACC,KAAK,SAAS,MAAM,QACpB,KAAK,aAAa,MAAM,YACxB,KAAK,aAAa,MAAM;AAE1B,SAAO;AACR;;"}
1
+ {"version":3,"file":"use-historical-edit-attachments.cjs","sources":["../../../../agent-runtime/src/use-historical-edit-attachments.ts"],"sourcesContent":["import type { ThreadUserMessagePart } from \"@assistant-ui/core\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\nimport { useEffect, useRef, useState } from \"react\";\n\n/** Restore once per edit so published SDKs work with unpatched upstream AUI. */\nexport function useHistoricalEditAttachments(): void {\n\tconst aui = useAui();\n\tconst isEditing = useAuiState((state) => state.message.composer.isEditing);\n\tconst restoredMessage = useRef<string | null>(null);\n\tconst [restoreError, setRestoreError] = useState<Error>();\n\tuseEffect(() => {\n\t\tif (!isEditing) {\n\t\t\trestoredMessage.current = null;\n\t\t\treturn;\n\t\t}\n\t\tconst message = aui.message().getState();\n\t\tif (message.role !== \"user\" || restoredMessage.current === message.id)\n\t\t\treturn;\n\t\trestoredMessage.current = message.id;\n\t\tconst composer = aui.message().composer();\n\t\t// Match occurrences, preserving repeated images without duplicating parts\n\t\t// already lifted by the monorepo's patched core. Removing one afterward\n\t\t// must remain a deliberate removal throughout this edit session.\n\t\tconst existing = composer\n\t\t\t.getState()\n\t\t\t.attachments.flatMap((attachment) => attachment.content ?? []);\n\t\tfor (const part of message.content) {\n\t\t\tif (part.type !== \"image\" && part.type !== \"file\") continue;\n\t\t\tconst index = existing.findIndex((candidate) =>\n\t\t\t\tsamePart(candidate, part),\n\t\t\t);\n\t\t\tif (index >= 0) {\n\t\t\t\texisting.splice(index, 1);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tvoid composer\n\t\t\t\t.addAttachment({\n\t\t\t\t\tname: part.filename ?? (part.type === \"image\" ? \"image\" : \"document\"),\n\t\t\t\t\ttype: part.type === \"image\" ? \"image\" : \"document\",\n\t\t\t\t\tcontentType: part.type === \"image\" ? \"image/*\" : part.mimeType,\n\t\t\t\t\tcontent: [part],\n\t\t\t\t})\n\t\t\t\t.catch((error: unknown) => {\n\t\t\t\t\tsetRestoreError(\n\t\t\t\t\t\terror instanceof Error ? error : new Error(String(error)),\n\t\t\t\t\t);\n\t\t\t\t});\n\t\t}\n\t}, [aui, isEditing]);\n\tif (restoreError) throw restoreError;\n}\n\nfunction samePart(\n\tleft: ThreadUserMessagePart,\n\tright: ThreadUserMessagePart,\n): boolean {\n\tif (left.type === \"image\" && right.type === \"image\")\n\t\treturn left.image === right.image;\n\tif (left.type === \"file\" && right.type === \"file\")\n\t\treturn (\n\t\t\tleft.data === right.data &&\n\t\t\tleft.mimeType === right.mimeType &&\n\t\t\tleft.filename === right.filename\n\t\t);\n\treturn false;\n}\n"],"names":["useAui","useAuiState","useRef","useState","useEffect"],"mappings":";;;;AAKO,SAAS,+BAAqC;AACpD,QAAM,MAAMA,MAAAA,OAAA;AACZ,QAAM,YAAYC,MAAAA,YAAY,CAAC,UAAU,MAAM,QAAQ,SAAS,SAAS;AACzE,QAAM,kBAAkBC,WAAAA,OAAsB,IAAI;AAClD,QAAM,CAAC,cAAc,eAAe,IAAIC,oBAAA;AACxCC,aAAAA,UAAU,MAAM;AACf,QAAI,CAAC,WAAW;AACf,sBAAgB,UAAU;AAC1B;AAAA,IACD;AACA,UAAM,UAAU,IAAI,QAAA,EAAU,SAAA;AAC9B,QAAI,QAAQ,SAAS,UAAU,gBAAgB,YAAY,QAAQ;AAClE;AACD,oBAAgB,UAAU,QAAQ;AAClC,UAAM,WAAW,IAAI,QAAA,EAAU,SAAA;AAI/B,UAAM,WAAW,SACf,SAAA,EACA,YAAY,QAAQ,CAAC,eAAe,WAAW,WAAW,EAAE;AAC9D,eAAW,QAAQ,QAAQ,SAAS;AACnC,UAAI,KAAK,SAAS,WAAW,KAAK,SAAS,OAAQ;AACnD,YAAM,QAAQ,SAAS;AAAA,QAAU,CAAC,cACjC,SAAS,WAAW,IAAI;AAAA,MAAA;AAEzB,UAAI,SAAS,GAAG;AACf,iBAAS,OAAO,OAAO,CAAC;AACxB;AAAA,MACD;AACA,WAAK,SACH,cAAc;AAAA,QACd,MAAM,KAAK,aAAa,KAAK,SAAS,UAAU,UAAU;AAAA,QAC1D,MAAM,KAAK,SAAS,UAAU,UAAU;AAAA,QACxC,aAAa,KAAK,SAAS,UAAU,YAAY,KAAK;AAAA,QACtD,SAAS,CAAC,IAAI;AAAA,MAAA,CACd,EACA,MAAM,CAAC,UAAmB;AAC1B;AAAA,UACC,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;AAAA,QAAA;AAAA,MAE1D,CAAC;AAAA,IACH;AAAA,EACD,GAAG,CAAC,KAAK,SAAS,CAAC;AACnB,MAAI,aAAc,OAAM;AACzB;AAEA,SAAS,SACR,MACA,OACU;AACV,MAAI,KAAK,SAAS,WAAW,MAAM,SAAS;AAC3C,WAAO,KAAK,UAAU,MAAM;AAC7B,MAAI,KAAK,SAAS,UAAU,MAAM,SAAS;AAC1C,WACC,KAAK,SAAS,MAAM,QACpB,KAAK,aAAa,MAAM,YACxB,KAAK,aAAa,MAAM;AAE1B,SAAO;AACR;;"}
@@ -1,84 +1,86 @@
1
- import { type HandoffLaunch, type HandoffOutcome, type HandoffSource, type ServerHandoffDestination, type ThreadHandoffTransport, type ThreadHandoffView } from './thread-handoff';
1
+ import { type HandoffLaunch, type HandoffMode, type HandoffOutcome, type HandoffSource, type OfficeLaunchMode, type ServerHandoffDestination, type ThreadHandoffDestination, type ThreadHandoffTransport, type ThreadHandoffView } from './thread-handoff-protocol';
2
2
  /** Mobile: a push lands in seconds; the QR path needs time to unlock a phone. */
3
3
  export declare const DEFAULT_MOBILE_HANDOFF_TIMEOUT_MS = 120000;
4
4
  /** Office: launching a desktop host from cold takes tens of seconds. */
5
5
  export declare const DEFAULT_OFFICE_HANDOFF_TIMEOUT_MS = 180000;
6
- export type ThreadHandoffFlowPhase = {
6
+ /** "Wherever I pick up next": the whole ten-minute life of the record. */
7
+ export declare const DEFAULT_PICKUP_HANDOFF_TIMEOUT_MS = 600000;
8
+ export type ThreadHandoffFlowPhase<D extends ThreadHandoffDestination = ServerHandoffDestination> = {
7
9
  status: 'idle';
8
10
  } | {
9
11
  status: 'creating';
10
- destination: ServerHandoffDestination;
12
+ destination: D;
11
13
  threadId: string;
12
14
  } | {
13
15
  status: 'waiting';
14
- destination: ServerHandoffDestination;
16
+ destination: D;
15
17
  threadId: string;
16
18
  handoff: ThreadHandoffView;
17
19
  launch: HandoffLaunch;
18
20
  startedAt: number;
19
21
  } | {
20
22
  status: 'acknowledged';
21
- destination: ServerHandoffDestination;
23
+ destination: D;
22
24
  threadId: string;
23
25
  handoff: ThreadHandoffView;
24
26
  launch: HandoffLaunch;
25
27
  } | {
26
28
  status: 'failed';
27
- destination: ServerHandoffDestination;
29
+ destination: D;
28
30
  threadId: string;
29
31
  handoff: ThreadHandoffView | null;
30
32
  launch: HandoffLaunch | null;
31
33
  reason: string;
32
34
  } | {
33
35
  status: 'timeout';
34
- destination: ServerHandoffDestination;
36
+ destination: D;
35
37
  threadId: string;
36
38
  handoff: ThreadHandoffView | null;
37
39
  launch: HandoffLaunch;
38
40
  };
39
- export interface StartThreadHandoffInput {
41
+ export interface StartThreadHandoffInput<D extends ThreadHandoffDestination = ServerHandoffDestination> {
40
42
  threadId: string;
41
- destination: ServerHandoffDestination;
43
+ destination: D;
44
+ officeLaunchMode?: OfficeLaunchMode;
45
+ expectedWorkspaceId?: string;
46
+ /** The composer's unsent text; the destination prefills it and never sends it. */
47
+ draft?: string;
48
+ /** `voice` offers "Continue by voice" on the destination; omitted means text. */
49
+ mode?: HandoffMode;
42
50
  }
43
- export interface ThreadHandoffFlowCallbacks {
51
+ export interface ThreadHandoffFlowCallbacks<D extends ThreadHandoffDestination = ServerHandoffDestination> {
44
52
  /** The server accepted the handoff; open the launch URL / show the QR. */
45
53
  onLaunched?: (context: {
46
- destination: ServerHandoffDestination;
54
+ destination: D;
47
55
  threadId: string;
48
56
  handoff: ThreadHandoffView;
49
57
  launch: HandoffLaunch;
50
58
  }) => void;
51
59
  /** Terminal result (acknowledged/failed/timeout); `cancelled` is not reported. */
52
60
  onSettled?: (context: {
53
- destination: ServerHandoffDestination;
61
+ destination: D;
54
62
  threadId: string;
55
63
  outcome: Exclude<HandoffOutcome, {
56
64
  status: 'cancelled';
57
65
  }>;
58
66
  }) => void;
59
67
  }
60
- export interface UseThreadHandoffFlowOptions extends ThreadHandoffFlowCallbacks {
68
+ export interface UseThreadHandoffFlowOptions<D extends ThreadHandoffDestination = ServerHandoffDestination> extends ThreadHandoffFlowCallbacks<D> {
61
69
  transport: ThreadHandoffTransport;
62
70
  source: HandoffSource;
63
- timeoutMs?: Partial<Record<ServerHandoffDestination, number>>;
71
+ /** Change this with the person, workspace, environment or active thread to cancel the old flow. */
72
+ scopeKey?: string;
73
+ timeoutMs?: Partial<Record<ThreadHandoffDestination, number>>;
64
74
  pollIntervalMs?: number;
65
75
  }
66
- export interface ThreadHandoffFlowController {
67
- phase: ThreadHandoffFlowPhase;
76
+ export interface ThreadHandoffFlowController<D extends ThreadHandoffDestination = ServerHandoffDestination> {
77
+ phase: ThreadHandoffFlowPhase<D>;
68
78
  /** True while a handoff is being created or awaiting the destination. */
69
79
  isActive: boolean;
70
- start: (input: StartThreadHandoffInput) => Promise<void>;
80
+ start: (input: StartThreadHandoffInput<D>) => Promise<void>;
71
81
  /** Stop waiting; the source keeps its copilot. The server record simply expires. */
72
82
  cancel: () => void;
73
83
  /** Back to idle after a terminal phase (dismisses the result UI). */
74
84
  reset: () => void;
75
85
  }
76
- /**
77
- * Drives one server-brokered handoff (mobile / Word / PowerPoint / Excel):
78
- * create → launch → poll until the destination acknowledges. Exactly one
79
- * handoff runs at a time; starting another cancels the previous wait.
80
- *
81
- * Source-side effects (closing the copilot only after `acknowledged`, toasts,
82
- * opening `ms-word:` URLs) belong to the caller via `onLaunched`/`onSettled`.
83
- */
84
- export declare function useThreadHandoffFlow({ transport, source, timeoutMs, pollIntervalMs, onLaunched, onSettled, }: UseThreadHandoffFlowOptions): ThreadHandoffFlowController;
86
+ export declare function useThreadHandoffFlow<D extends ThreadHandoffDestination = ServerHandoffDestination>({ transport, source, scopeKey, timeoutMs, pollIntervalMs, onLaunched, onSettled, }: UseThreadHandoffFlowOptions<D>): ThreadHandoffFlowController<D>;
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const VOICE_MICROPHONE_CAPTURE = {
4
+ echoCancellation: true,
5
+ noiseSuppression: true,
6
+ autoGainControl: true
7
+ };
8
+ const VOICE_DEVICE_IDENTITY = /^(user-.+)-[^-]+$/;
9
+ function isOwnOtherVoiceDevice({
10
+ identity,
11
+ localIdentity
12
+ }) {
13
+ var _a, _b;
14
+ if (localIdentity === void 0 || identity === localIdentity) return false;
15
+ const person = (_a = VOICE_DEVICE_IDENTITY.exec(localIdentity)) == null ? void 0 : _a[1];
16
+ return person !== void 0 && ((_b = VOICE_DEVICE_IDENTITY.exec(identity)) == null ? void 0 : _b[1]) === person;
17
+ }
18
+ async function connectVoiceMedia({
19
+ createDriver,
20
+ handlers
21
+ }) {
22
+ const { signal } = handlers;
23
+ const endedError = () => {
24
+ const error = new Error("The voice session ended");
25
+ error.name = "AbortError";
26
+ return error;
27
+ };
28
+ if (signal == null ? void 0 : signal.aborted) throw endedError();
29
+ const driver = createDriver();
30
+ let connected = false;
31
+ let joined = false;
32
+ let closed = false;
33
+ let disconnecting = null;
34
+ let rejectEnded;
35
+ const ended = new Promise((_, reject) => {
36
+ rejectEnded = reject;
37
+ });
38
+ const close = () => {
39
+ closed = true;
40
+ signal == null ? void 0 : signal.removeEventListener("abort", onAbort);
41
+ if (!disconnecting) {
42
+ try {
43
+ disconnecting = Promise.resolve(driver.disconnect()).then(
44
+ () => void 0
45
+ );
46
+ } catch (error) {
47
+ disconnecting = Promise.reject(error);
48
+ }
49
+ }
50
+ return disconnecting;
51
+ };
52
+ const disconnectAgain = async () => {
53
+ try {
54
+ await driver.disconnect();
55
+ } catch {
56
+ }
57
+ };
58
+ const onAbort = () => {
59
+ rejectEnded(endedError());
60
+ void close().catch(() => void 0);
61
+ };
62
+ signal == null ? void 0 : signal.addEventListener("abort", onAbort, { once: true });
63
+ if (signal == null ? void 0 : signal.aborted) onAbort();
64
+ driver.onDisconnected(({ reason, joinFailure }) => {
65
+ if (closed) return;
66
+ if (!connected && joinFailure) return;
67
+ rejectEnded(new Error(reason));
68
+ void close().catch(() => void 0);
69
+ if (joined) handlers.onDisconnected(reason);
70
+ });
71
+ const checkOpen = () => {
72
+ if (closed) throw endedError();
73
+ };
74
+ const joining = (async () => {
75
+ try {
76
+ checkOpen();
77
+ await driver.connect();
78
+ connected = true;
79
+ checkOpen();
80
+ await driver.setMicrophoneEnabled({
81
+ enabled: !handlers.micMuted,
82
+ initial: true
83
+ });
84
+ checkOpen();
85
+ } catch (error) {
86
+ const alreadyClosed = closed;
87
+ await close().catch(() => void 0);
88
+ if (alreadyClosed) await disconnectAgain();
89
+ throw error;
90
+ }
91
+ })();
92
+ await Promise.race([joining, ended]);
93
+ checkOpen();
94
+ joined = true;
95
+ return {
96
+ setMicrophoneEnabled: (enabled) => {
97
+ const changing = (async () => {
98
+ checkOpen();
99
+ try {
100
+ await driver.setMicrophoneEnabled({ enabled, initial: false });
101
+ checkOpen();
102
+ } finally {
103
+ if (closed) await disconnectAgain();
104
+ }
105
+ })();
106
+ return Promise.race([changing, ended]);
107
+ },
108
+ disconnect: () => {
109
+ rejectEnded(endedError());
110
+ return close();
111
+ }
112
+ };
113
+ }
114
+ exports.VOICE_MICROPHONE_CAPTURE = VOICE_MICROPHONE_CAPTURE;
115
+ exports.connectVoiceMedia = connectVoiceMedia;
116
+ exports.isOwnOtherVoiceDevice = isOwnOtherVoiceDevice;
117
+ //# sourceMappingURL=voice-media.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"voice-media.cjs","sources":["../../../../agent-runtime/src/voice-media.ts"],"sourcesContent":["/** Capture processing shared by browser and native chat voice rooms. */\nexport const VOICE_MICROPHONE_CAPTURE = {\n echoCancellation: true,\n noiseSuppression: true,\n autoGainControl: true,\n} as const;\n\n/** `user-<user id>-<client>`: one device of the call's owner (agora's `voice_client_identity`). */\nconst VOICE_DEVICE_IDENTITY = /^(user-.+)-[^-]+$/;\n\n/**\n * Whether a remote participant of a chat voice room is another of the person's\n * own devices. The room holds the voice agent and the owner's devices, and\n * while a call moves (`voice/transfer-*`) the old and the new device are in it\n * together. A device plays the agent only: the other device's microphone is\n * the person's own voice, and on a browser's one `<audio>` sink it would also\n * take the agent's place. `false` while this device's identity is unknown.\n */\nexport function isOwnOtherVoiceDevice({\n identity,\n localIdentity,\n}: {\n identity: string;\n localIdentity: string | undefined;\n}): boolean {\n if (localIdentity === undefined || identity === localIdentity) return false;\n const person = VOICE_DEVICE_IDENTITY.exec(localIdentity)?.[1];\n return person !== undefined && VOICE_DEVICE_IDENTITY.exec(identity)?.[1] === person;\n}\n\nexport interface VoiceMediaHandlers {\n micMuted: boolean;\n signal?: AbortSignal;\n onDisconnected: (reason: string) => void;\n}\n\nexport interface VoiceMediaSession {\n setMicrophoneEnabled(enabled: boolean): Promise<void>;\n disconnect(): Promise<void>;\n}\n\n/**\n * The platform owns its room, audio sink and capture configuration. The shared\n * lifecycle owns cancellation, late capture, mute and loss of that room. No DOM\n * or LiveKit implementation is imported by this entrypoint.\n */\nexport interface VoiceMediaDriver {\n connect(): Promise<void>;\n setMicrophoneEnabled(options: {\n enabled: boolean;\n initial: boolean;\n }): Promise<unknown>;\n /** Must also release the platform's remote audio sinks. Safe to call again. */\n disconnect(): Promise<unknown>;\n onDisconnected(\n listener: (event: { reason: string; joinFailure: boolean }) => void\n ): void;\n}\n\nexport async function connectVoiceMedia({\n createDriver,\n handlers,\n}: {\n createDriver: () => VoiceMediaDriver;\n handlers: VoiceMediaHandlers;\n}): Promise<VoiceMediaSession> {\n const { signal } = handlers;\n // Hermes does not need a DOMException implementation to cancel a voice join.\n const endedError = (): Error => {\n const error = new Error('The voice session ended');\n error.name = 'AbortError';\n return error;\n };\n if (signal?.aborted) throw endedError();\n const driver = createDriver();\n let connected = false;\n let joined = false;\n let closed = false;\n let disconnecting: Promise<void> | null = null;\n let rejectEnded!: (error: Error) => void;\n const ended = new Promise<never>((_, reject) => {\n rejectEnded = reject;\n });\n const close = (): Promise<void> => {\n closed = true;\n signal?.removeEventListener('abort', onAbort);\n if (!disconnecting) {\n try {\n // Invoke synchronously so a browser's playback sinks stop at hangup.\n disconnecting = Promise.resolve(driver.disconnect()).then(\n () => undefined\n );\n } catch (error) {\n disconnecting = Promise.reject(error);\n }\n }\n return disconnecting;\n };\n const disconnectAgain = async (): Promise<void> => {\n try {\n await driver.disconnect();\n } catch {\n /* Preserve the original failure. */\n }\n };\n const onAbort = (): void => {\n rejectEnded(endedError());\n void close().catch(() => undefined);\n };\n signal?.addEventListener('abort', onAbort, { once: true });\n // A platform factory may synchronously cancel the attempt that created it.\n if (signal?.aborted) onAbort();\n driver.onDisconnected(({ reason, joinFailure }) => {\n if (closed) return;\n // Preserve connect()'s real cause when its room emits JOIN_FAILURE first.\n if (!connected && joinFailure) return;\n rejectEnded(new Error(reason));\n void close().catch(() => undefined);\n if (joined) handlers.onDisconnected(reason);\n });\n const checkOpen = (): void => {\n if (closed) throw endedError();\n };\n const joining = (async () => {\n try {\n checkOpen();\n await driver.connect();\n connected = true;\n checkOpen();\n await driver.setMicrophoneEnabled({\n enabled: !handlers.micMuted,\n initial: true,\n });\n checkOpen();\n } catch (error) {\n const alreadyClosed = closed;\n await close().catch(() => undefined);\n // An uncancellable platform capture can finish after its first close.\n if (alreadyClosed) await disconnectAgain();\n throw error;\n }\n })();\n await Promise.race([joining, ended]);\n checkOpen();\n joined = true;\n return {\n setMicrophoneEnabled: (enabled) => {\n const changing = (async () => {\n checkOpen();\n try {\n await driver.setMicrophoneEnabled({ enabled, initial: false });\n checkOpen();\n } finally {\n if (closed) await disconnectAgain();\n }\n })();\n return Promise.race([changing, ended]);\n },\n disconnect: () => {\n rejectEnded(endedError());\n return close();\n },\n };\n}\n"],"names":[],"mappings":";;AACO,MAAM,2BAA2B;AAAA,EACtC,kBAAkB;AAAA,EAClB,kBAAkB;AAAA,EAClB,iBAAiB;AACnB;AAGA,MAAM,wBAAwB;AAUvB,SAAS,sBAAsB;AAAA,EACpC;AAAA,EACA;AACF,GAGY;;AACV,MAAI,kBAAkB,UAAa,aAAa,cAAe,QAAO;AACtE,QAAM,UAAS,2BAAsB,KAAK,aAAa,MAAxC,mBAA4C;AAC3D,SAAO,WAAW,YAAa,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AAS,eAAe,MAAM;AAAA,EAC5C,CAAC;AACD,QAAM,YAAY,MAAY;AAC5B,QAAI,cAAc,WAAA;AAAA,EACpB;AACA,QAAM,WAAW,YAAY;AAC3B,QAAI;AACF,gBAAA;AACA,YAAM,OAAO,QAAA;AACb,kBAAY;AACZ,gBAAA;AACA,YAAM,OAAO,qBAAqB;AAAA,QAChC,SAAS,CAAC,SAAS;AAAA,QACnB,SAAS;AAAA,MAAA,CACV;AACD,gBAAA;AAAA,IACF,SAAS,OAAO;AACd,YAAM,gBAAgB;AACtB,YAAM,MAAA,EAAQ,MAAM,MAAM,MAAS;AAEnC,UAAI,qBAAqB,gBAAA;AACzB,YAAM;AAAA,IACR;AAAA,EACF,GAAA;AACA,QAAM,QAAQ,KAAK,CAAC,SAAS,KAAK,CAAC;AACnC,YAAA;AACA,WAAS;AACT,SAAO;AAAA,IACL,sBAAsB,CAAC,YAAY;AACjC,YAAM,YAAY,YAAY;AAC5B,kBAAA;AACA,YAAI;AACF,gBAAM,OAAO,qBAAqB,EAAE,SAAS,SAAS,OAAO;AAC7D,oBAAA;AAAA,QACF,UAAA;AACE,cAAI,cAAc,gBAAA;AAAA,QACpB;AAAA,MACF,GAAA;AACA,aAAO,QAAQ,KAAK,CAAC,UAAU,KAAK,CAAC;AAAA,IACvC;AAAA,IACA,YAAY,MAAM;AAChB,kBAAY,YAAY;AACxB,aAAO,MAAA;AAAA,IACT;AAAA,EAAA;AAEJ;;;;"}
@@ -0,0 +1,49 @@
1
+ /** Capture processing shared by browser and native chat voice rooms. */
2
+ export declare const VOICE_MICROPHONE_CAPTURE: {
3
+ readonly echoCancellation: true;
4
+ readonly noiseSuppression: true;
5
+ readonly autoGainControl: true;
6
+ };
7
+ /**
8
+ * Whether a remote participant of a chat voice room is another of the person's
9
+ * own devices. The room holds the voice agent and the owner's devices, and
10
+ * while a call moves (`voice/transfer-*`) the old and the new device are in it
11
+ * together. A device plays the agent only: the other device's microphone is
12
+ * the person's own voice, and on a browser's one `<audio>` sink it would also
13
+ * take the agent's place. `false` while this device's identity is unknown.
14
+ */
15
+ export declare function isOwnOtherVoiceDevice({ identity, localIdentity, }: {
16
+ identity: string;
17
+ localIdentity: string | undefined;
18
+ }): boolean;
19
+ export interface VoiceMediaHandlers {
20
+ micMuted: boolean;
21
+ signal?: AbortSignal;
22
+ onDisconnected: (reason: string) => void;
23
+ }
24
+ export interface VoiceMediaSession {
25
+ setMicrophoneEnabled(enabled: boolean): Promise<void>;
26
+ disconnect(): Promise<void>;
27
+ }
28
+ /**
29
+ * The platform owns its room, audio sink and capture configuration. The shared
30
+ * lifecycle owns cancellation, late capture, mute and loss of that room. No DOM
31
+ * or LiveKit implementation is imported by this entrypoint.
32
+ */
33
+ export interface VoiceMediaDriver {
34
+ connect(): Promise<void>;
35
+ setMicrophoneEnabled(options: {
36
+ enabled: boolean;
37
+ initial: boolean;
38
+ }): Promise<unknown>;
39
+ /** Must also release the platform's remote audio sinks. Safe to call again. */
40
+ disconnect(): Promise<unknown>;
41
+ onDisconnected(listener: (event: {
42
+ reason: string;
43
+ joinFailure: boolean;
44
+ }) => void): void;
45
+ }
46
+ export declare function connectVoiceMedia({ createDriver, handlers, }: {
47
+ createDriver: () => VoiceMediaDriver;
48
+ handlers: VoiceMediaHandlers;
49
+ }): Promise<VoiceMediaSession>;