@athenaintel/react 0.42.2 → 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 (685) hide show
  1. package/README.md +225 -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/conversation-list-groups.d.ts +74 -0
  17. package/dist/agent-runtime/src/decision-checks.cjs +207 -0
  18. package/dist/agent-runtime/src/decision-checks.cjs.map +1 -0
  19. package/dist/agent-runtime/src/decision-checks.d.ts +142 -0
  20. package/dist/agent-runtime/src/decision-checks.js +207 -0
  21. package/dist/agent-runtime/src/decision-checks.js.map +1 -0
  22. package/dist/agent-runtime/src/desktop-handoff.d.ts +12 -0
  23. package/dist/agent-runtime/src/errors.cjs +18 -0
  24. package/dist/agent-runtime/src/errors.cjs.map +1 -1
  25. package/dist/agent-runtime/src/errors.d.ts +7 -0
  26. package/dist/agent-runtime/src/errors.js +18 -0
  27. package/dist/agent-runtime/src/errors.js.map +1 -1
  28. package/dist/agent-runtime/src/generated/runconfig-contract.cjs +12 -0
  29. package/dist/agent-runtime/src/generated/runconfig-contract.cjs.map +1 -1
  30. package/dist/agent-runtime/src/generated/runconfig-contract.d.ts +6 -6
  31. package/dist/agent-runtime/src/generated/runconfig-contract.js +12 -0
  32. package/dist/agent-runtime/src/generated/runconfig-contract.js.map +1 -1
  33. package/dist/agent-runtime/src/handoff-arrival.cjs +60 -0
  34. package/dist/agent-runtime/src/handoff-arrival.cjs.map +1 -0
  35. package/dist/agent-runtime/src/handoff-arrival.d.ts +46 -0
  36. package/dist/agent-runtime/src/handoff-arrival.js +60 -0
  37. package/dist/agent-runtime/src/handoff-arrival.js.map +1 -0
  38. package/dist/agent-runtime/src/index.d.ts +15 -8
  39. package/dist/agent-runtime/src/interrupts.cjs +43 -18
  40. package/dist/agent-runtime/src/interrupts.cjs.map +1 -1
  41. package/dist/agent-runtime/src/interrupts.d.ts +19 -2
  42. package/dist/agent-runtime/src/interrupts.js +28 -3
  43. package/dist/agent-runtime/src/interrupts.js.map +1 -1
  44. package/dist/agent-runtime/src/lane-history.cjs +8 -8
  45. package/dist/agent-runtime/src/lane-history.cjs.map +1 -1
  46. package/dist/agent-runtime/src/messages.cjs +43 -8
  47. package/dist/agent-runtime/src/messages.cjs.map +1 -1
  48. package/dist/agent-runtime/src/messages.d.ts +25 -3
  49. package/dist/agent-runtime/src/messages.js +43 -8
  50. package/dist/agent-runtime/src/messages.js.map +1 -1
  51. package/dist/agent-runtime/src/offline-status.cjs +36 -0
  52. package/dist/agent-runtime/src/offline-status.cjs.map +1 -0
  53. package/dist/agent-runtime/src/offline-status.d.ts +118 -3
  54. package/dist/agent-runtime/src/offline-status.js +36 -0
  55. package/dist/agent-runtime/src/offline-status.js.map +1 -0
  56. package/dist/agent-runtime/src/queue.cjs +0 -9
  57. package/dist/agent-runtime/src/queue.cjs.map +1 -1
  58. package/dist/agent-runtime/src/queue.js +0 -9
  59. package/dist/agent-runtime/src/queue.js.map +1 -1
  60. package/dist/agent-runtime/src/quota-safe-local-storage-session.cjs +9 -9
  61. package/dist/agent-runtime/src/quota-safe-local-storage-session.cjs.map +1 -1
  62. package/dist/agent-runtime/src/runtime-catalog.cjs +42 -0
  63. package/dist/agent-runtime/src/runtime-catalog.cjs.map +1 -0
  64. package/dist/agent-runtime/src/runtime-catalog.d.ts +35 -0
  65. package/dist/agent-runtime/src/runtime-catalog.js +42 -0
  66. package/dist/agent-runtime/src/runtime-catalog.js.map +1 -0
  67. package/dist/agent-runtime/src/runtime-messages.cjs.map +1 -1
  68. package/dist/agent-runtime/src/runtime-messages.d.ts +1 -1
  69. package/dist/agent-runtime/src/runtime-messages.js.map +1 -1
  70. package/dist/agent-runtime/src/runtime.d.ts +40 -0
  71. package/dist/agent-runtime/src/statewire-suspended.cjs +3 -3
  72. package/dist/agent-runtime/src/statewire-suspended.cjs.map +1 -1
  73. package/dist/agent-runtime/src/subagents.cjs +32 -2
  74. package/dist/agent-runtime/src/subagents.cjs.map +1 -1
  75. package/dist/agent-runtime/src/subagents.d.ts +9 -0
  76. package/dist/agent-runtime/src/subagents.js +30 -0
  77. package/dist/agent-runtime/src/subagents.js.map +1 -1
  78. package/dist/agent-runtime/src/thread-driver.cjs +67 -0
  79. package/dist/agent-runtime/src/thread-driver.cjs.map +1 -0
  80. package/dist/agent-runtime/src/thread-driver.d.ts +49 -0
  81. package/dist/agent-runtime/src/thread-driver.js +67 -0
  82. package/dist/agent-runtime/src/thread-driver.js.map +1 -0
  83. package/dist/agent-runtime/src/thread-handoff-flow-machine.d.ts +172 -0
  84. package/dist/agent-runtime/src/thread-handoff-protocol.d.ts +756 -0
  85. package/dist/agent-runtime/src/thread-handoff-qr.d.ts +11 -0
  86. package/dist/agent-runtime/src/thread-handoff.d.ts +3 -364
  87. package/dist/agent-runtime/src/thread-status.cjs +3 -3
  88. package/dist/agent-runtime/src/thread-status.cjs.map +1 -1
  89. package/dist/agent-runtime/src/tool-metadata.cjs +210 -33
  90. package/dist/agent-runtime/src/tool-metadata.cjs.map +1 -1
  91. package/dist/agent-runtime/src/tool-metadata.d.ts +12 -0
  92. package/dist/agent-runtime/src/tool-metadata.js +210 -33
  93. package/dist/agent-runtime/src/tool-metadata.js.map +1 -1
  94. package/dist/agent-runtime/src/tool-names.cjs +2 -0
  95. package/dist/agent-runtime/src/tool-names.cjs.map +1 -1
  96. package/dist/agent-runtime/src/tool-names.d.ts +2 -0
  97. package/dist/agent-runtime/src/tool-names.js +2 -0
  98. package/dist/agent-runtime/src/tool-names.js.map +1 -1
  99. package/dist/agent-runtime/src/types.d.ts +10 -2
  100. package/dist/agent-runtime/src/use-conversation-list.cjs +11 -11
  101. package/dist/agent-runtime/src/use-conversation-list.cjs.map +1 -1
  102. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.cjs +24 -19
  103. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.cjs.map +1 -1
  104. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.d.ts +2 -1
  105. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.js +6 -1
  106. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.js.map +1 -1
  107. package/dist/agent-runtime/src/use-deep-agent-config.cjs +14 -14
  108. package/dist/agent-runtime/src/use-deep-agent-config.cjs.map +1 -1
  109. package/dist/agent-runtime/src/use-deep-agent-edit-submit.cjs +6 -6
  110. package/dist/agent-runtime/src/use-deep-agent-edit-submit.cjs.map +1 -1
  111. package/dist/agent-runtime/src/use-deep-agent-runtime.cjs +16 -16
  112. package/dist/agent-runtime/src/use-deep-agent-runtime.cjs.map +1 -1
  113. package/dist/agent-runtime/src/use-deep-agent-thread.cjs +45 -45
  114. package/dist/agent-runtime/src/use-deep-agent-thread.cjs.map +1 -1
  115. package/dist/agent-runtime/src/use-deep-agent-voice.cjs +572 -134
  116. package/dist/agent-runtime/src/use-deep-agent-voice.cjs.map +1 -1
  117. package/dist/agent-runtime/src/use-deep-agent-voice.d.ts +137 -10
  118. package/dist/agent-runtime/src/use-deep-agent-voice.js +514 -76
  119. package/dist/agent-runtime/src/use-deep-agent-voice.js.map +1 -1
  120. package/dist/agent-runtime/src/use-deep-agent-window-sync.cjs +26 -26
  121. package/dist/agent-runtime/src/use-deep-agent-window-sync.cjs.map +1 -1
  122. package/dist/agent-runtime/src/use-historical-edit-attachments.cjs +4 -4
  123. package/dist/agent-runtime/src/use-historical-edit-attachments.cjs.map +1 -1
  124. package/dist/agent-runtime/src/use-thread-handoff-flow.d.ts +28 -26
  125. package/dist/agent-runtime/src/voice-media.cjs +117 -0
  126. package/dist/agent-runtime/src/voice-media.cjs.map +1 -0
  127. package/dist/agent-runtime/src/voice-media.d.ts +49 -0
  128. package/dist/agent-runtime/src/voice-media.js +117 -0
  129. package/dist/agent-runtime/src/voice-media.js.map +1 -0
  130. package/dist/agent-runtime/src/voice-wire-types.d.ts +32 -0
  131. package/dist/assets/AssetPanel.cjs +11 -11
  132. package/dist/assets/AssetPanel.cjs.map +1 -1
  133. package/dist/assets/AthenaAssetEmbed.cjs +11 -9
  134. package/dist/assets/AthenaAssetEmbed.cjs.map +1 -1
  135. package/dist/assets/AthenaAssetEmbed.d.ts +7 -0
  136. package/dist/assets/AthenaAssetEmbed.js +4 -2
  137. package/dist/assets/AthenaAssetEmbed.js.map +1 -1
  138. package/dist/assets/AthenaLayout.cjs +16 -16
  139. package/dist/assets/AthenaLayout.cjs.map +1 -1
  140. package/dist/assets/use-asset-content.cjs +4 -4
  141. package/dist/assets/use-asset-content.cjs.map +1 -1
  142. package/dist/assets/use-asset-embed.cjs +14 -7
  143. package/dist/assets/use-asset-embed.cjs.map +1 -1
  144. package/dist/assets/use-asset-embed.d.ts +11 -1
  145. package/dist/assets/use-asset-embed.js +10 -3
  146. package/dist/assets/use-asset-embed.js.map +1 -1
  147. package/dist/auth/AthenaAuthContext.cjs +3 -3
  148. package/dist/auth/AthenaAuthContext.cjs.map +1 -1
  149. package/dist/auth/AthenaAuthProvider.cjs +8 -8
  150. package/dist/auth/AthenaAuthProvider.cjs.map +1 -1
  151. package/dist/auth/AthenaCredentialSourceContext.cjs +5 -5
  152. package/dist/auth/AthenaCredentialSourceContext.cjs.map +1 -1
  153. package/dist/auth/AthenaSSOProvider.cjs +14 -14
  154. package/dist/auth/AthenaSSOProvider.cjs.map +1 -1
  155. package/dist/auth/credential-source.cjs +26 -13
  156. package/dist/auth/credential-source.cjs.map +1 -1
  157. package/dist/auth/credential-source.d.ts +8 -0
  158. package/dist/auth/credential-source.js +26 -13
  159. package/dist/auth/credential-source.js.map +1 -1
  160. package/dist/catalog/agent-model-options.cjs +25 -17
  161. package/dist/catalog/agent-model-options.cjs.map +1 -1
  162. package/dist/catalog/agent-model-options.d.ts +38 -5
  163. package/dist/catalog/agent-model-options.js +25 -17
  164. package/dist/catalog/agent-model-options.js.map +1 -1
  165. package/dist/catalog/channel-refusal.cjs +36 -0
  166. package/dist/catalog/channel-refusal.cjs.map +1 -0
  167. package/dist/catalog/channel-refusal.d.ts +29 -0
  168. package/dist/catalog/channel-refusal.js +36 -0
  169. package/dist/catalog/channel-refusal.js.map +1 -0
  170. package/dist/catalog/chat-pickers.cjs +60 -24
  171. package/dist/catalog/chat-pickers.cjs.map +1 -1
  172. package/dist/catalog/chat-pickers.d.ts +12 -2
  173. package/dist/catalog/chat-pickers.js +56 -20
  174. package/dist/catalog/chat-pickers.js.map +1 -1
  175. package/dist/catalog/runtime-catalog.cjs +89 -23
  176. package/dist/catalog/runtime-catalog.cjs.map +1 -1
  177. package/dist/catalog/runtime-catalog.d.ts +8 -2
  178. package/dist/catalog/runtime-catalog.js +83 -17
  179. package/dist/catalog/runtime-catalog.js.map +1 -1
  180. package/dist/catalog/use-athena-chat-mode.cjs +12 -12
  181. package/dist/catalog/use-athena-chat-mode.cjs.map +1 -1
  182. package/dist/chat/AthenaChat.cjs +155 -67
  183. package/dist/chat/AthenaChat.cjs.map +1 -1
  184. package/dist/chat/AthenaChat.d.ts +42 -2
  185. package/dist/chat/AthenaChat.js +106 -18
  186. package/dist/chat/AthenaChat.js.map +1 -1
  187. package/dist/chat/AthenaChatErrorBoundary.cjs +3 -3
  188. package/dist/chat/AthenaChatErrorBoundary.cjs.map +1 -1
  189. package/dist/chat/DrivingOnChip.cjs +23 -0
  190. package/dist/chat/DrivingOnChip.cjs.map +1 -0
  191. package/dist/chat/DrivingOnChip.d.ts +17 -0
  192. package/dist/chat/DrivingOnChip.js +23 -0
  193. package/dist/chat/DrivingOnChip.js.map +1 -0
  194. package/dist/chat/StatewireApprovalCard.cjs +125 -31
  195. package/dist/chat/StatewireApprovalCard.cjs.map +1 -1
  196. package/dist/chat/StatewireApprovalCard.d.ts +73 -1
  197. package/dist/chat/StatewireApprovalCard.js +115 -21
  198. package/dist/chat/StatewireApprovalCard.js.map +1 -1
  199. package/dist/chat/StatewireClientToolBridge.cjs +2 -2
  200. package/dist/chat/StatewireClientToolBridge.cjs.map +1 -1
  201. package/dist/chat/StatewireQueuedMessages.cjs +25 -63
  202. package/dist/chat/StatewireQueuedMessages.cjs.map +1 -1
  203. package/dist/chat/StatewireQueuedMessages.d.ts +11 -13
  204. package/dist/chat/StatewireQueuedMessages.js +16 -54
  205. package/dist/chat/StatewireQueuedMessages.js.map +1 -1
  206. package/dist/chat/WaitingOnYouBanner.cjs +3 -3
  207. package/dist/chat/WaitingOnYouBanner.cjs.map +1 -1
  208. package/dist/chat/athena-chat-welcome.cjs +2 -2
  209. package/dist/chat/athena-chat-welcome.cjs.map +1 -1
  210. package/dist/chat/athena-citation-links.cjs +5 -5
  211. package/dist/chat/athena-citation-links.cjs.map +1 -1
  212. package/dist/chat/athena-composer-controls.cjs +26 -16
  213. package/dist/chat/athena-composer-controls.cjs.map +1 -1
  214. package/dist/chat/athena-composer-controls.d.ts +6 -0
  215. package/dist/chat/athena-composer-controls.js +26 -16
  216. package/dist/chat/athena-composer-controls.js.map +1 -1
  217. package/dist/chat/athena-turn-end-status.cjs +42 -0
  218. package/dist/chat/athena-turn-end-status.cjs.map +1 -0
  219. package/dist/chat/athena-turn-end-status.d.ts +24 -0
  220. package/dist/chat/athena-turn-end-status.js +42 -0
  221. package/dist/chat/athena-turn-end-status.js.map +1 -0
  222. package/dist/chat/browser-decision-check.cjs +131 -0
  223. package/dist/chat/browser-decision-check.cjs.map +1 -0
  224. package/dist/chat/browser-decision-check.d.ts +61 -0
  225. package/dist/chat/browser-decision-check.js +131 -0
  226. package/dist/chat/browser-decision-check.js.map +1 -0
  227. package/dist/chat/chat-outbox-rows.cjs +3 -3
  228. package/dist/chat/chat-outbox-rows.cjs.map +1 -1
  229. package/dist/chat/chat-voice-controls.cjs +93 -28
  230. package/dist/chat/chat-voice-controls.cjs.map +1 -1
  231. package/dist/chat/chat-voice-controls.d.ts +36 -2
  232. package/dist/chat/chat-voice-controls.js +89 -24
  233. package/dist/chat/chat-voice-controls.js.map +1 -1
  234. package/dist/chat/composer-keyboard-hint.cjs +5 -5
  235. package/dist/chat/composer-keyboard-hint.cjs.map +1 -1
  236. package/dist/chat/device-operation.cjs +29 -0
  237. package/dist/chat/device-operation.cjs.map +1 -0
  238. package/dist/chat/device-operation.d.ts +34 -0
  239. package/dist/chat/device-operation.js +29 -0
  240. package/dist/chat/device-operation.js.map +1 -0
  241. package/dist/chat/super-grouping/CollapsibleGroup.cjs +14 -14
  242. package/dist/chat/super-grouping/CollapsibleGroup.cjs.map +1 -1
  243. package/dist/chat/super-grouping/GroupedMessageParts.cjs +4 -4
  244. package/dist/chat/super-grouping/GroupedMessageParts.cjs.map +1 -1
  245. package/dist/chat/super-grouping/SuperGroupingCard.cjs +60 -38
  246. package/dist/chat/super-grouping/SuperGroupingCard.cjs.map +1 -1
  247. package/dist/chat/super-grouping/SuperGroupingCard.d.ts +24 -4
  248. package/dist/chat/super-grouping/SuperGroupingCard.js +37 -15
  249. package/dist/chat/super-grouping/SuperGroupingCard.js.map +1 -1
  250. package/dist/chat/super-grouping/SuperGroupingTranscript.cjs +32 -32
  251. package/dist/chat/super-grouping/SuperGroupingTranscript.cjs.map +1 -1
  252. package/dist/chat/super-grouping/SuperGroupingTranscript.js +3 -3
  253. package/dist/chat/super-grouping/SuperGroupingTranscript.js.map +1 -1
  254. package/dist/chat/super-grouping/ToolTimeline.cjs +97 -37
  255. package/dist/chat/super-grouping/ToolTimeline.cjs.map +1 -1
  256. package/dist/chat/super-grouping/ToolTimeline.d.ts +14 -2
  257. package/dist/chat/super-grouping/ToolTimeline.js +94 -34
  258. package/dist/chat/super-grouping/ToolTimeline.js.map +1 -1
  259. package/dist/chat/super-grouping/activity-timeline.cjs +47 -12
  260. package/dist/chat/super-grouping/activity-timeline.cjs.map +1 -1
  261. package/dist/chat/super-grouping/activity-timeline.d.ts +21 -0
  262. package/dist/chat/super-grouping/activity-timeline.js +47 -12
  263. package/dist/chat/super-grouping/activity-timeline.js.map +1 -1
  264. package/dist/chat/super-grouping/grouping-function.cjs +4 -0
  265. package/dist/chat/super-grouping/grouping-function.cjs.map +1 -1
  266. package/dist/chat/super-grouping/grouping-function.d.ts +7 -0
  267. package/dist/chat/super-grouping/grouping-function.js +5 -1
  268. package/dist/chat/super-grouping/grouping-function.js.map +1 -1
  269. package/dist/chat/super-grouping/index.cjs +6 -0
  270. package/dist/chat/super-grouping/index.cjs.map +1 -1
  271. package/dist/chat/super-grouping/index.d.ts +6 -2
  272. package/dist/chat/super-grouping/index.js +7 -1
  273. package/dist/chat/super-grouping/index.js.map +1 -1
  274. package/dist/chat/super-grouping/timeline-step.cjs +61 -2
  275. package/dist/chat/super-grouping/timeline-step.cjs.map +1 -1
  276. package/dist/chat/super-grouping/timeline-step.d.ts +13 -1
  277. package/dist/chat/super-grouping/timeline-step.js +61 -2
  278. package/dist/chat/super-grouping/timeline-step.js.map +1 -1
  279. package/dist/chat/super-grouping/tool-part-placement.cjs +17 -0
  280. package/dist/chat/super-grouping/tool-part-placement.cjs.map +1 -0
  281. package/dist/chat/super-grouping/tool-part-placement.d.ts +22 -0
  282. package/dist/chat/super-grouping/tool-part-placement.js +17 -0
  283. package/dist/chat/super-grouping/tool-part-placement.js.map +1 -0
  284. package/dist/chat/thread-scroll-to-bottom.cjs +2 -2
  285. package/dist/chat/thread-scroll-to-bottom.cjs.map +1 -1
  286. package/dist/chat/thread-scroll-to-bottom.d.ts +10 -7
  287. package/dist/chat/thread-scroll-to-bottom.js +2 -2
  288. package/dist/chat/thread-scroll-to-bottom.js.map +1 -1
  289. package/dist/chat/tooltip-icon-button.cjs +2 -2
  290. package/dist/chat/tooltip-icon-button.cjs.map +1 -1
  291. package/dist/chat/use-athena-voice-live.cjs +11 -0
  292. package/dist/chat/use-athena-voice-live.cjs.map +1 -0
  293. package/dist/chat/use-athena-voice-live.d.ts +11 -0
  294. package/dist/chat/use-athena-voice-live.js +11 -0
  295. package/dist/chat/use-athena-voice-live.js.map +1 -0
  296. package/dist/chat/use-statewire-approval-request.cjs +56 -24
  297. package/dist/chat/use-statewire-approval-request.cjs.map +1 -1
  298. package/dist/chat/use-statewire-approval-request.d.ts +33 -4
  299. package/dist/chat/use-statewire-approval-request.js +41 -9
  300. package/dist/chat/use-statewire-approval-request.js.map +1 -1
  301. package/dist/chat-ui/auth/sign-in-card.cjs +2 -2
  302. package/dist/chat-ui/auth/sign-in-card.cjs.map +1 -1
  303. package/dist/chat-ui/composer/tiptap-composer.cjs +138 -107
  304. package/dist/chat-ui/composer/tiptap-composer.cjs.map +1 -1
  305. package/dist/chat-ui/composer/tiptap-composer.d.ts +20 -4
  306. package/dist/chat-ui/composer/tiptap-composer.js +85 -54
  307. package/dist/chat-ui/composer/tiptap-composer.js.map +1 -1
  308. package/dist/chat-ui/header/conversation-history-panel.cjs +49 -23
  309. package/dist/chat-ui/header/conversation-history-panel.cjs.map +1 -1
  310. package/dist/chat-ui/header/conversation-history-panel.d.ts +12 -1
  311. package/dist/chat-ui/header/conversation-history-panel.js +38 -12
  312. package/dist/chat-ui/header/conversation-history-panel.js.map +1 -1
  313. package/dist/chat-ui/index.cjs +18 -0
  314. package/dist/chat-ui/index.cjs.map +1 -1
  315. package/dist/chat-ui/index.d.ts +7 -1
  316. package/dist/chat-ui/index.js +18 -0
  317. package/dist/chat-ui/index.js.map +1 -1
  318. package/dist/chat-ui/mentions/mention-chip.cjs +147 -38
  319. package/dist/chat-ui/mentions/mention-chip.cjs.map +1 -1
  320. package/dist/chat-ui/mentions/mention-chip.d.ts +17 -1
  321. package/dist/chat-ui/mentions/mention-chip.js +146 -37
  322. package/dist/chat-ui/mentions/mention-chip.js.map +1 -1
  323. package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-list.cjs +10 -9
  324. package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-list.cjs.map +1 -1
  325. package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-list.js +3 -2
  326. package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-list.js.map +1 -1
  327. package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-popup.cjs +2 -2
  328. package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-popup.cjs.map +1 -1
  329. package/dist/chat-ui/mentions/suggestions/components/menu-list.cjs +29 -6
  330. package/dist/chat-ui/mentions/suggestions/components/menu-list.cjs.map +1 -1
  331. package/dist/chat-ui/mentions/suggestions/components/menu-list.d.ts +7 -1
  332. package/dist/chat-ui/mentions/suggestions/components/menu-list.js +25 -2
  333. package/dist/chat-ui/mentions/suggestions/components/menu-list.js.map +1 -1
  334. package/dist/chat-ui/mentions/suggestions/components/use-keyboard-navigation.cjs +2 -2
  335. package/dist/chat-ui/mentions/suggestions/components/use-keyboard-navigation.cjs.map +1 -1
  336. package/dist/chat-ui/mentions/suggestions/components/use-menu-navigation.cjs +2 -2
  337. package/dist/chat-ui/mentions/suggestions/components/use-menu-navigation.cjs.map +1 -1
  338. package/dist/chat-ui/mentions/suggestions/data/api-client.cjs +3 -3
  339. package/dist/chat-ui/mentions/suggestions/data/api-client.cjs.map +1 -1
  340. package/dist/chat-ui/mentions/suggestions/data/orchestrator.cjs +56 -2
  341. package/dist/chat-ui/mentions/suggestions/data/orchestrator.cjs.map +1 -1
  342. package/dist/chat-ui/mentions/suggestions/data/orchestrator.d.ts +12 -0
  343. package/dist/chat-ui/mentions/suggestions/data/orchestrator.js +56 -2
  344. package/dist/chat-ui/mentions/suggestions/data/orchestrator.js.map +1 -1
  345. package/dist/chat-ui/mentions/suggestions/data/sources/index.cjs +24 -3
  346. package/dist/chat-ui/mentions/suggestions/data/sources/index.cjs.map +1 -1
  347. package/dist/chat-ui/mentions/suggestions/data/sources/index.d.ts +7 -0
  348. package/dist/chat-ui/mentions/suggestions/data/sources/index.js +24 -3
  349. package/dist/chat-ui/mentions/suggestions/data/sources/index.js.map +1 -1
  350. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.cjs +35 -13
  351. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.cjs.map +1 -1
  352. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.d.ts +15 -1
  353. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.js +28 -6
  354. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.js.map +1 -1
  355. package/dist/chat-ui/mentions/suggestions/data/use-menu-items.cjs +9 -6
  356. package/dist/chat-ui/mentions/suggestions/data/use-menu-items.cjs.map +1 -1
  357. package/dist/chat-ui/mentions/suggestions/data/use-menu-items.d.ts +3 -0
  358. package/dist/chat-ui/mentions/suggestions/data/use-menu-items.js +5 -2
  359. package/dist/chat-ui/mentions/suggestions/data/use-menu-items.js.map +1 -1
  360. package/dist/chat-ui/mentions/use-account-workspace-id.cjs +45 -10
  361. package/dist/chat-ui/mentions/use-account-workspace-id.cjs.map +1 -1
  362. package/dist/chat-ui/mentions/use-account-workspace-id.d.ts +24 -1
  363. package/dist/chat-ui/mentions/use-account-workspace-id.js +46 -11
  364. package/dist/chat-ui/mentions/use-account-workspace-id.js.map +1 -1
  365. package/dist/chat-ui/mentions/use-member-avatar.cjs +4 -4
  366. package/dist/chat-ui/mentions/use-member-avatar.cjs.map +1 -1
  367. package/dist/chat-ui/mentions/use-mention-asset.cjs +140 -0
  368. package/dist/chat-ui/mentions/use-mention-asset.cjs.map +1 -0
  369. package/dist/chat-ui/mentions/use-mention-asset.d.ts +16 -0
  370. package/dist/chat-ui/mentions/use-mention-asset.js +140 -0
  371. package/dist/chat-ui/mentions/use-mention-asset.js.map +1 -0
  372. package/dist/chat-ui/messages/answer-label.cjs +42 -0
  373. package/dist/chat-ui/messages/answer-label.cjs.map +1 -0
  374. package/dist/chat-ui/messages/answer-label.d.ts +33 -0
  375. package/dist/chat-ui/messages/answer-label.js +42 -0
  376. package/dist/chat-ui/messages/answer-label.js.map +1 -0
  377. package/dist/chat-ui/messages/arrival-animation.cjs +13 -0
  378. package/dist/chat-ui/messages/arrival-animation.cjs.map +1 -0
  379. package/dist/chat-ui/messages/arrival-animation.d.ts +14 -0
  380. package/dist/chat-ui/messages/arrival-animation.js +13 -0
  381. package/dist/chat-ui/messages/arrival-animation.js.map +1 -0
  382. package/dist/chat-ui/messages/continue-pill.cjs +5 -5
  383. package/dist/chat-ui/messages/continue-pill.cjs.map +1 -1
  384. package/dist/chat-ui/messages/handoff-arrival-divider.cjs +44 -0
  385. package/dist/chat-ui/messages/handoff-arrival-divider.cjs.map +1 -0
  386. package/dist/chat-ui/messages/handoff-arrival-divider.d.ts +17 -0
  387. package/dist/chat-ui/messages/handoff-arrival-divider.js +44 -0
  388. package/dist/chat-ui/messages/handoff-arrival-divider.js.map +1 -0
  389. package/dist/chat-ui/messages/message-actions-config.cjs +3 -3
  390. package/dist/chat-ui/messages/message-actions-config.cjs.map +1 -1
  391. package/dist/chat-ui/messages/message-components.cjs +8 -4
  392. package/dist/chat-ui/messages/message-components.cjs.map +1 -1
  393. package/dist/chat-ui/messages/message-components.js +5 -1
  394. package/dist/chat-ui/messages/message-components.js.map +1 -1
  395. package/dist/chat-ui/messages/message-images.cjs +66 -0
  396. package/dist/chat-ui/messages/message-images.cjs.map +1 -0
  397. package/dist/chat-ui/messages/message-images.d.ts +16 -0
  398. package/dist/chat-ui/messages/message-images.js +66 -0
  399. package/dist/chat-ui/messages/message-images.js.map +1 -0
  400. package/dist/chat-ui/messages/user-edit-composer.cjs +2 -2
  401. package/dist/chat-ui/messages/user-edit-composer.cjs.map +1 -1
  402. package/dist/chat-ui/messages/wake-marker.cjs +3 -3
  403. package/dist/chat-ui/messages/wake-marker.cjs.map +1 -1
  404. package/dist/chat-ui/rich-text/chat-link.cjs +7 -6
  405. package/dist/chat-ui/rich-text/chat-link.cjs.map +1 -1
  406. package/dist/chat-ui/rich-text/chat-link.d.ts +2 -3
  407. package/dist/chat-ui/rich-text/chat-link.js +6 -5
  408. package/dist/chat-ui/rich-text/chat-link.js.map +1 -1
  409. package/dist/chat-ui/rich-text/chat-message-body.cjs +8 -8
  410. package/dist/chat-ui/rich-text/chat-message-body.cjs.map +1 -1
  411. package/dist/chat-ui/rich-text/chat-node-views.cjs +7 -6
  412. package/dist/chat-ui/rich-text/chat-node-views.cjs.map +1 -1
  413. package/dist/chat-ui/rich-text/chat-node-views.js +1 -0
  414. package/dist/chat-ui/rich-text/chat-node-views.js.map +1 -1
  415. package/dist/chat-ui/rich-text/dom-output-spec.cjs +2 -2
  416. package/dist/chat-ui/rich-text/dom-output-spec.cjs.map +1 -1
  417. package/dist/chat-ui/statewire.cjs +3 -0
  418. package/dist/chat-ui/statewire.cjs.map +1 -1
  419. package/dist/chat-ui/statewire.d.ts +2 -1
  420. package/dist/chat-ui/statewire.js +3 -0
  421. package/dist/chat-ui/statewire.js.map +1 -1
  422. package/dist/chat-ui/thread/chat-thread-shell.cjs +43 -14
  423. package/dist/chat-ui/thread/chat-thread-shell.cjs.map +1 -1
  424. package/dist/chat-ui/thread/chat-thread-shell.d.ts +16 -2
  425. package/dist/chat-ui/thread/chat-thread-shell.js +35 -6
  426. package/dist/chat-ui/thread/chat-thread-shell.js.map +1 -1
  427. package/dist/chat-ui/thread/composer-send-or-stop.cjs +30 -20
  428. package/dist/chat-ui/thread/composer-send-or-stop.cjs.map +1 -1
  429. package/dist/chat-ui/thread/composer-send-or-stop.d.ts +8 -0
  430. package/dist/chat-ui/thread/composer-send-or-stop.js +29 -19
  431. package/dist/chat-ui/thread/composer-send-or-stop.js.map +1 -1
  432. package/dist/chat-ui/thread/statewire-history-edge.cjs +20 -21
  433. package/dist/chat-ui/thread/statewire-history-edge.cjs.map +1 -1
  434. package/dist/chat-ui/thread/statewire-history-edge.js +3 -4
  435. package/dist/chat-ui/thread/statewire-history-edge.js.map +1 -1
  436. package/dist/chat-ui/thread/thread-loading-overlay.cjs +5 -5
  437. package/dist/chat-ui/thread/thread-loading-overlay.cjs.map +1 -1
  438. package/dist/collab/client.cjs +40 -3
  439. package/dist/collab/client.cjs.map +1 -1
  440. package/dist/collab/client.d.ts +25 -0
  441. package/dist/collab/client.js +40 -3
  442. package/dist/collab/client.js.map +1 -1
  443. package/dist/collab/document-status.cjs +150 -0
  444. package/dist/collab/document-status.cjs.map +1 -0
  445. package/dist/collab/document-status.d.ts +68 -0
  446. package/dist/collab/document-status.js +150 -0
  447. package/dist/collab/document-status.js.map +1 -0
  448. package/dist/collab/index.cjs +7 -0
  449. package/dist/collab/index.cjs.map +1 -1
  450. package/dist/collab/index.d.ts +6 -1
  451. package/dist/collab/index.js +7 -0
  452. package/dist/collab/index.js.map +1 -1
  453. package/dist/collab/presence-react.cjs +11 -11
  454. package/dist/collab/presence-react.cjs.map +1 -1
  455. package/dist/collab/react.cjs +6 -6
  456. package/dist/collab/react.cjs.map +1 -1
  457. package/dist/composer/AttachmentContext.cjs +24 -11
  458. package/dist/composer/AttachmentContext.cjs.map +1 -1
  459. package/dist/composer/AttachmentContext.js +18 -5
  460. package/dist/composer/AttachmentContext.js.map +1 -1
  461. package/dist/composer/ComposerAttachmentPreview.cjs +78 -23
  462. package/dist/composer/ComposerAttachmentPreview.cjs.map +1 -1
  463. package/dist/composer/ComposerAttachmentPreview.d.ts +5 -3
  464. package/dist/composer/ComposerAttachmentPreview.js +79 -24
  465. package/dist/composer/ComposerAttachmentPreview.js.map +1 -1
  466. package/dist/composer/ComposerDropZone.cjs +7 -7
  467. package/dist/composer/ComposerDropZone.cjs.map +1 -1
  468. package/dist/composer/FileUploadButton.cjs +37 -22
  469. package/dist/composer/FileUploadButton.cjs.map +1 -1
  470. package/dist/composer/FileUploadButton.d.ts +6 -0
  471. package/dist/composer/FileUploadButton.js +34 -19
  472. package/dist/composer/FileUploadButton.js.map +1 -1
  473. package/dist/composer/QuoteContext.cjs +8 -8
  474. package/dist/composer/QuoteContext.cjs.map +1 -1
  475. package/dist/composer/composer-handoff.cjs +4 -4
  476. package/dist/composer/composer-handoff.cjs.map +1 -1
  477. package/dist/composer/useAppendToComposer.cjs +4 -4
  478. package/dist/composer/useAppendToComposer.cjs.map +1 -1
  479. package/dist/composer/useAttachFiles.cjs +23 -6
  480. package/dist/composer/useAttachFiles.cjs.map +1 -1
  481. package/dist/composer/useAttachFiles.d.ts +15 -7
  482. package/dist/composer/useAttachFiles.js +22 -5
  483. package/dist/composer/useAttachFiles.js.map +1 -1
  484. package/dist/composer/useComposerAttachment.cjs +4 -4
  485. package/dist/composer/useComposerAttachment.cjs.map +1 -1
  486. package/dist/composer/useFileUpload.cjs +21 -16
  487. package/dist/composer/useFileUpload.cjs.map +1 -1
  488. package/dist/composer/useFileUpload.d.ts +12 -0
  489. package/dist/composer/useFileUpload.js +12 -7
  490. package/dist/composer/useFileUpload.js.map +1 -1
  491. package/dist/composer/useReadComposerDraft.cjs +2 -2
  492. package/dist/composer/useReadComposerDraft.cjs.map +1 -1
  493. package/dist/composer/useSendMessage.cjs +4 -4
  494. package/dist/composer/useSendMessage.cjs.map +1 -1
  495. package/dist/diagnostics/useAthenaDiagnostics.cjs +4 -4
  496. package/dist/diagnostics/useAthenaDiagnostics.cjs.map +1 -1
  497. package/dist/dictation/audio-level-history.cjs +3 -3
  498. package/dist/dictation/audio-level-history.cjs.map +1 -1
  499. package/dist/dictation/dictation-controls.cjs +24 -20
  500. package/dist/dictation/dictation-controls.cjs.map +1 -1
  501. package/dist/dictation/dictation-controls.d.ts +6 -1
  502. package/dist/dictation/dictation-controls.js +24 -20
  503. package/dist/dictation/dictation-controls.js.map +1 -1
  504. package/dist/dictation/use-athena-dictation-engine.cjs +3 -3
  505. package/dist/dictation/use-athena-dictation-engine.cjs.map +1 -1
  506. package/dist/dictation/use-dictation.cjs +22 -22
  507. package/dist/dictation/use-dictation.cjs.map +1 -1
  508. package/dist/index.cjs +26 -2
  509. package/dist/index.cjs.map +1 -1
  510. package/dist/index.d.ts +15 -3
  511. package/dist/index.js +26 -2
  512. package/dist/index.js.map +1 -1
  513. package/dist/keryx-http/src/receive-only-socket.cjs +40 -0
  514. package/dist/keryx-http/src/receive-only-socket.cjs.map +1 -0
  515. package/dist/keryx-http/src/receive-only-socket.d.ts +27 -0
  516. package/dist/keryx-http/src/receive-only-socket.js +40 -0
  517. package/dist/keryx-http/src/receive-only-socket.js.map +1 -0
  518. package/dist/keryx-http/src/update-attributions.cjs +111 -0
  519. package/dist/keryx-http/src/update-attributions.cjs.map +1 -0
  520. package/dist/keryx-http/src/update-attributions.d.ts +75 -0
  521. package/dist/keryx-http/src/update-attributions.js +111 -0
  522. package/dist/keryx-http/src/update-attributions.js.map +1 -0
  523. package/dist/lib/owner-document.cjs +6 -6
  524. package/dist/lib/owner-document.cjs.map +1 -1
  525. package/dist/lib/use-athena-rest-query.cjs +4 -4
  526. package/dist/lib/use-athena-rest-query.cjs.map +1 -1
  527. package/dist/lib/use-document-active.cjs +4 -4
  528. package/dist/lib/use-document-active.cjs.map +1 -1
  529. package/dist/lib/use-prefers-reduced-motion.cjs +2 -2
  530. package/dist/lib/use-prefers-reduced-motion.cjs.map +1 -1
  531. package/dist/offline/offline-history.cjs +7 -7
  532. package/dist/offline/offline-history.cjs.map +1 -1
  533. package/dist/provider/AthenaContext.cjs +3 -3
  534. package/dist/provider/AthenaContext.cjs.map +1 -1
  535. package/dist/provider/AthenaProvider.cjs +116 -79
  536. package/dist/provider/AthenaProvider.cjs.map +1 -1
  537. package/dist/provider/AthenaProvider.js +40 -3
  538. package/dist/provider/AthenaProvider.js.map +1 -1
  539. package/dist/provider/PostHogProvider.cjs +2 -2
  540. package/dist/provider/PostHogProvider.cjs.map +1 -1
  541. package/dist/provider/agent-selection-context.cjs +2 -2
  542. package/dist/provider/agent-selection-context.cjs.map +1 -1
  543. package/dist/provider/chat-mode-context.cjs +2 -2
  544. package/dist/provider/chat-mode-context.cjs.map +1 -1
  545. package/dist/provider/session-persistence-context.cjs +10 -0
  546. package/dist/provider/session-persistence-context.cjs.map +1 -0
  547. package/dist/provider/session-persistence-context.d.ts +15 -0
  548. package/dist/provider/session-persistence-context.js +10 -0
  549. package/dist/provider/session-persistence-context.js.map +1 -0
  550. package/dist/provider/statewire-history-context.cjs +4 -4
  551. package/dist/provider/statewire-history-context.cjs.map +1 -1
  552. package/dist/provider/statewire-lifecycle-context.cjs +3 -3
  553. package/dist/provider/statewire-lifecycle-context.cjs.map +1 -1
  554. package/dist/provider/statewire-window-context.cjs +3 -3
  555. package/dist/provider/statewire-window-context.cjs.map +1 -1
  556. package/dist/provider/theme-style-context.cjs +3 -3
  557. package/dist/provider/theme-style-context.cjs.map +1 -1
  558. package/dist/react/package.json.cjs +1 -1
  559. package/dist/react/package.json.js +1 -1
  560. package/dist/references/src/tool-option-schemas.d.ts +0 -34
  561. package/dist/runtime/StatewireThreadConfigLaneSync.cjs +10 -10
  562. package/dist/runtime/StatewireThreadConfigLaneSync.cjs.map +1 -1
  563. package/dist/runtime/auth-refusal-restart.cjs +7 -7
  564. package/dist/runtime/auth-refusal-restart.cjs.map +1 -1
  565. package/dist/runtime/auth.cjs +13 -13
  566. package/dist/runtime/auth.cjs.map +1 -1
  567. package/dist/runtime/statewire-lifecycle.cjs +1 -0
  568. package/dist/runtime/statewire-lifecycle.cjs.map +1 -1
  569. package/dist/runtime/statewire-lifecycle.d.ts +3 -1
  570. package/dist/runtime/statewire-lifecycle.js +2 -1
  571. package/dist/runtime/statewire-lifecycle.js.map +1 -1
  572. package/dist/runtime/statewire-server-lane-context.cjs +2 -2
  573. package/dist/runtime/statewire-server-lane-context.cjs.map +1 -1
  574. package/dist/runtime/statewire-session-lane.cjs +4 -4
  575. package/dist/runtime/statewire-session-lane.cjs.map +1 -1
  576. package/dist/runtime/useAthenaStatewireRuntime.cjs +10 -8
  577. package/dist/runtime/useAthenaStatewireRuntime.cjs.map +1 -1
  578. package/dist/runtime/useAthenaStatewireRuntime.d.ts +2 -0
  579. package/dist/runtime/useAthenaStatewireRuntime.js +2 -0
  580. package/dist/runtime/useAthenaStatewireRuntime.js.map +1 -1
  581. package/dist/styles.css +1 -1
  582. package/dist/threads/Inbox.cjs +8 -8
  583. package/dist/threads/Inbox.cjs.map +1 -1
  584. package/dist/threads/SessionList.cjs +9 -9
  585. package/dist/threads/SessionList.cjs.map +1 -1
  586. package/dist/threads/SessionsPage.cjs +11 -11
  587. package/dist/threads/SessionsPage.cjs.map +1 -1
  588. package/dist/threads/index-triggered-refresh.cjs +10 -10
  589. package/dist/threads/index-triggered-refresh.cjs.map +1 -1
  590. package/dist/threads/mark-viewed-thread-read.cjs +12 -12
  591. package/dist/threads/mark-viewed-thread-read.cjs.map +1 -1
  592. package/dist/threads/offline-session-list.cjs +3 -3
  593. package/dist/threads/offline-session-list.cjs.map +1 -1
  594. package/dist/threads/session-list-tab-share.cjs +5 -5
  595. package/dist/threads/session-list-tab-share.cjs.map +1 -1
  596. package/dist/threads/statewire-thread-list.cjs +55 -51
  597. package/dist/threads/statewire-thread-list.cjs.map +1 -1
  598. package/dist/threads/statewire-thread-list.js +6 -2
  599. package/dist/threads/statewire-thread-list.js.map +1 -1
  600. package/dist/threads/thread-id-context.cjs +5 -5
  601. package/dist/threads/thread-id-context.cjs.map +1 -1
  602. package/dist/threads/use-athena-session-attention.cjs +2 -2
  603. package/dist/threads/use-athena-session-attention.cjs.map +1 -1
  604. package/dist/threads/use-athena-sessions.cjs +10 -10
  605. package/dist/threads/use-athena-sessions.cjs.map +1 -1
  606. package/dist/threads/use-athena-thread-model.cjs +3 -3
  607. package/dist/threads/use-athena-thread-model.cjs.map +1 -1
  608. package/dist/threads/use-rest-conversation-history.cjs +3 -3
  609. package/dist/threads/use-rest-conversation-history.cjs.map +1 -1
  610. package/dist/threads/use-statewire-conversation-history.cjs +8 -8
  611. package/dist/threads/use-statewire-conversation-history.cjs.map +1 -1
  612. package/dist/threads/use-thread-archive.cjs +9 -9
  613. package/dist/threads/use-thread-archive.cjs.map +1 -1
  614. package/dist/threads/use-thread-favorite.cjs +2 -2
  615. package/dist/threads/use-thread-favorite.cjs.map +1 -1
  616. package/dist/threads/use-thread-field-override.cjs +20 -20
  617. package/dist/threads/use-thread-field-override.cjs.map +1 -1
  618. package/dist/threads/use-thread-read-state.cjs +4 -4
  619. package/dist/threads/use-thread-read-state.cjs.map +1 -1
  620. package/dist/threads/use-thread-rename.cjs +2 -2
  621. package/dist/threads/use-thread-rename.cjs.map +1 -1
  622. package/dist/threads/useAthenaThreadManager.cjs +2 -2
  623. package/dist/threads/useAthenaThreadManager.cjs.map +1 -1
  624. package/dist/tools/NestedPtcMessages.cjs +6 -6
  625. package/dist/tools/NestedPtcMessages.cjs.map +1 -1
  626. package/dist/tools/append-document-tool-ui.cjs +7 -7
  627. package/dist/tools/append-document-tool-ui.cjs.map +1 -1
  628. package/dist/tools/file-tool-uis.cjs +2 -2
  629. package/dist/tools/file-tool-uis.cjs.map +1 -1
  630. package/dist/tools/misc-tool-uis.cjs +2 -2
  631. package/dist/tools/misc-tool-uis.cjs.map +1 -1
  632. package/dist/tools/primitives.cjs +6 -6
  633. package/dist/tools/primitives.cjs.map +1 -1
  634. package/dist/tools/read-asset-tool-ui.cjs +6 -6
  635. package/dist/tools/read-asset-tool-ui.cjs.map +1 -1
  636. package/dist/tools/subagent-task-tool-ui.cjs +21 -21
  637. package/dist/tools/subagent-task-tool-ui.cjs.map +1 -1
  638. package/dist/tools/test-recording-tool-uis.cjs +16 -16
  639. package/dist/tools/test-recording-tool-uis.cjs.map +1 -1
  640. package/dist/tools/todo-plan-store.cjs +4 -4
  641. package/dist/tools/todo-plan-store.cjs.map +1 -1
  642. package/dist/tools/tool-appearance.cjs +3 -3
  643. package/dist/tools/tool-appearance.cjs.map +1 -1
  644. package/dist/tools/tool-fallback.cjs +14 -14
  645. package/dist/tools/tool-fallback.cjs.map +1 -1
  646. package/dist/tools/tool-summary.cjs +0 -2
  647. package/dist/tools/tool-summary.cjs.map +1 -1
  648. package/dist/tools/tool-summary.js +0 -2
  649. package/dist/tools/tool-summary.js.map +1 -1
  650. package/dist/tools/tool-uis.cjs +74 -74
  651. package/dist/tools/tool-uis.cjs.map +1 -1
  652. package/dist/tools/use-elapsed-seconds.cjs +3 -3
  653. package/dist/tools/use-elapsed-seconds.cjs.map +1 -1
  654. package/dist/tools/write-todos-tool-ui.cjs +9 -9
  655. package/dist/tools/write-todos-tool-ui.cjs.map +1 -1
  656. package/dist/ui/image-viewer.cjs +382 -0
  657. package/dist/ui/image-viewer.cjs.map +1 -0
  658. package/dist/ui/image-viewer.d.ts +50 -0
  659. package/dist/ui/image-viewer.js +382 -0
  660. package/dist/ui/image-viewer.js.map +1 -0
  661. package/dist/voice/chat.cjs +6 -0
  662. package/dist/voice/chat.cjs.map +1 -1
  663. package/dist/voice/chat.d.ts +1 -1
  664. package/dist/voice/chat.js +8 -2
  665. package/dist/voice/livekit-join.cjs +52 -101
  666. package/dist/voice/livekit-join.cjs.map +1 -1
  667. package/dist/voice/livekit-join.d.ts +1 -6
  668. package/dist/voice/livekit-join.js +52 -101
  669. package/dist/voice/livekit-join.js.map +1 -1
  670. package/dist/voice/livekit.cjs.map +1 -1
  671. package/dist/voice/livekit.d.ts +11 -1
  672. package/dist/voice/livekit.js.map +1 -1
  673. package/dist/voice/use-athena-voice-session.cjs +34 -34
  674. package/dist/voice/use-athena-voice-session.cjs.map +1 -1
  675. package/dist/workbench/ComputerLiveDesktop.cjs +13 -13
  676. package/dist/workbench/ComputerLiveDesktop.cjs.map +1 -1
  677. package/dist/workbench/SessionWorkbench.cjs +22 -22
  678. package/dist/workbench/SessionWorkbench.cjs.map +1 -1
  679. package/dist/workbench/session-workbench-context.cjs +3 -3
  680. package/dist/workbench/session-workbench-context.cjs.map +1 -1
  681. package/dist/workbench/session-workbench-panes.cjs +8 -8
  682. package/dist/workbench/session-workbench-panes.cjs.map +1 -1
  683. package/dist/workbench/workbench-layout-context.cjs +3 -3
  684. package/dist/workbench/workbench-layout-context.cjs.map +1 -1
  685. package/package.json +2 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DrivingOnChip.cjs","sources":["../../src/chat/DrivingOnChip.tsx"],"sourcesContent":["import { type ThreadDriverSurface, useDrivingOn } from '@athenaintel/agent-runtime/thread-driver';\nimport { MonitorSmartphoneIcon } from 'lucide-react';\nimport type { FC } from 'react';\nimport { cn } from '../lib/utils';\n\nexport interface DrivingOnChipProps {\n /** The app this chat runs in; the chip shows only while another app drives. */\n here: ThreadDriverSurface;\n /** Applied to the outer wrapper (host spacing). */\n className?: string;\n}\n\n/**\n * \"Driving on your phone\": the person's newest message in this conversation\n * came from another of their apps (the host's `state.driver`). A hint, never a\n * lock — sending here makes this app the driver and the chip goes away. Renders\n * nothing while this app drives, once the other app has been quiet for a while,\n * during a live call (the call strip says where it is), and outside a statewire\n * thread.\n */\nexport const DrivingOnChip: FC<DrivingOnChipProps> = ({ here, className }) => {\n const drivingOn = useDrivingOn(here);\n if (!drivingOn) return null;\n return (\n <div className={cn('aui-driving-on-chip flex justify-center', className)}>\n <span\n role=\"status\"\n className=\"inline-flex items-center gap-1.5 rounded-full border border-border bg-muted/60 px-2.5 py-1 text-muted-foreground text-xs\"\n >\n <MonitorSmartphoneIcon className=\"size-3.5 shrink-0\" aria-hidden />\n {drivingOn.label}\n </span>\n </div>\n );\n};\n"],"names":["useDrivingOn","cn","jsxs","jsx","MonitorSmartphoneIcon"],"mappings":";;;;;;AAoBO,MAAM,gBAAwC,CAAC,EAAE,MAAM,gBAAgB;AAC5E,QAAM,YAAYA,aAAAA,aAAa,IAAI;AACnC,MAAI,CAAC,UAAW,QAAO;AACvB,wCACG,OAAA,EAAI,WAAWC,OAAAA,GAAG,2CAA2C,SAAS,GACrE,UAAAC,2BAAAA;AAAAA,IAAC;AAAA,IAAA;AAAA,MACC,MAAK;AAAA,MACL,WAAU;AAAA,MAEV,UAAA;AAAA,QAAAC,2BAAAA,IAACC,YAAAA,uBAAA,EAAsB,WAAU,qBAAoB,eAAW,MAAC;AAAA,QAChE,UAAU;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA,GAEf;AAEJ;;"}
@@ -0,0 +1,17 @@
1
+ import { type ThreadDriverSurface } from '../agent-runtime/src/thread-driver';
2
+ import type { FC } from 'react';
3
+ export interface DrivingOnChipProps {
4
+ /** The app this chat runs in; the chip shows only while another app drives. */
5
+ here: ThreadDriverSurface;
6
+ /** Applied to the outer wrapper (host spacing). */
7
+ className?: string;
8
+ }
9
+ /**
10
+ * "Driving on your phone": the person's newest message in this conversation
11
+ * came from another of their apps (the host's `state.driver`). A hint, never a
12
+ * lock — sending here makes this app the driver and the chip goes away. Renders
13
+ * nothing while this app drives, once the other app has been quiet for a while,
14
+ * during a live call (the call strip says where it is), and outside a statewire
15
+ * thread.
16
+ */
17
+ export declare const DrivingOnChip: FC<DrivingOnChipProps>;
@@ -0,0 +1,23 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useDrivingOn } from "../agent-runtime/src/thread-driver.js";
3
+ import { MonitorSmartphoneIcon } from "lucide-react";
4
+ import { cn } from "cnfast";
5
+ const DrivingOnChip = ({ here, className }) => {
6
+ const drivingOn = useDrivingOn(here);
7
+ if (!drivingOn) return null;
8
+ return /* @__PURE__ */ jsx("div", { className: cn("aui-driving-on-chip flex justify-center", className), children: /* @__PURE__ */ jsxs(
9
+ "span",
10
+ {
11
+ role: "status",
12
+ className: "inline-flex items-center gap-1.5 rounded-full border border-border bg-muted/60 px-2.5 py-1 text-muted-foreground text-xs",
13
+ children: [
14
+ /* @__PURE__ */ jsx(MonitorSmartphoneIcon, { className: "size-3.5 shrink-0", "aria-hidden": true }),
15
+ drivingOn.label
16
+ ]
17
+ }
18
+ ) });
19
+ };
20
+ export {
21
+ DrivingOnChip
22
+ };
23
+ //# sourceMappingURL=DrivingOnChip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DrivingOnChip.js","sources":["../../src/chat/DrivingOnChip.tsx"],"sourcesContent":["import { type ThreadDriverSurface, useDrivingOn } from '@athenaintel/agent-runtime/thread-driver';\nimport { MonitorSmartphoneIcon } from 'lucide-react';\nimport type { FC } from 'react';\nimport { cn } from '../lib/utils';\n\nexport interface DrivingOnChipProps {\n /** The app this chat runs in; the chip shows only while another app drives. */\n here: ThreadDriverSurface;\n /** Applied to the outer wrapper (host spacing). */\n className?: string;\n}\n\n/**\n * \"Driving on your phone\": the person's newest message in this conversation\n * came from another of their apps (the host's `state.driver`). A hint, never a\n * lock — sending here makes this app the driver and the chip goes away. Renders\n * nothing while this app drives, once the other app has been quiet for a while,\n * during a live call (the call strip says where it is), and outside a statewire\n * thread.\n */\nexport const DrivingOnChip: FC<DrivingOnChipProps> = ({ here, className }) => {\n const drivingOn = useDrivingOn(here);\n if (!drivingOn) return null;\n return (\n <div className={cn('aui-driving-on-chip flex justify-center', className)}>\n <span\n role=\"status\"\n className=\"inline-flex items-center gap-1.5 rounded-full border border-border bg-muted/60 px-2.5 py-1 text-muted-foreground text-xs\"\n >\n <MonitorSmartphoneIcon className=\"size-3.5 shrink-0\" aria-hidden />\n {drivingOn.label}\n </span>\n </div>\n );\n};\n"],"names":[],"mappings":";;;;AAoBO,MAAM,gBAAwC,CAAC,EAAE,MAAM,gBAAgB;AAC5E,QAAM,YAAY,aAAa,IAAI;AACnC,MAAI,CAAC,UAAW,QAAO;AACvB,6BACG,OAAA,EAAI,WAAW,GAAG,2CAA2C,SAAS,GACrE,UAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,MAAK;AAAA,MACL,WAAU;AAAA,MAEV,UAAA;AAAA,QAAA,oBAAC,uBAAA,EAAsB,WAAU,qBAAoB,eAAW,MAAC;AAAA,QAChE,UAAU;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA,GAEf;AAEJ;"}
@@ -2,13 +2,20 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
4
  const react = require("@assistant-ui/react");
5
+ const reactStatewire = require("@assistant-ui/react-statewire");
5
6
  const lucideReact = require("lucide-react");
6
- const react$1 = require("react");
7
+ const require$$0 = require("react");
7
8
  const button = require("../ui/button.cjs");
8
9
  const useStatewireApprovalRequest = require("./use-statewire-approval-request.cjs");
9
10
  const threadExtras = require("../agent-runtime/src/thread-extras.cjs");
11
+ const errors = require("../agent-runtime/src/errors.cjs");
10
12
  const interrupts = require("../agent-runtime/src/interrupts.cjs");
11
13
  const cnfast = require("cnfast");
14
+ function answerApproves(answer) {
15
+ if (answer.kind === "input") return interrupts.resumeValueApproves(answer.value);
16
+ const lanes = Object.values(answer.laneDecisions);
17
+ return lanes.length === 0 || lanes.some(interrupts.resumeValueApproves);
18
+ }
12
19
  const NO_HOST_QUEUED_LANE_DECISIONS = Object.freeze({});
13
20
  const StatewireApprovalCard = (props) => {
14
21
  const extras = react.useAuiState((s) => s.thread.extras);
@@ -27,9 +34,23 @@ const StatewireApprovalCardInner = ({
27
34
  readOnly = false,
28
35
  readOnlyNotice = "Waiting for someone with edit access to respond.",
29
36
  nonHitlNotice = "This request needs an answer this surface cannot collect.",
30
- onResumeRejected
37
+ onResumeRejected,
38
+ confirmDecision
31
39
  }) => {
32
40
  var _a, _b, _c;
41
+ const approvalEpochRef = require$$0.useRef(0);
42
+ const [decisionFailure, setDecisionFailure] = require$$0.useState();
43
+ const reportResumeRejected = require$$0.useCallback(
44
+ (error, failedRequestId) => {
45
+ setDecisionFailure({
46
+ requestId: failedRequestId,
47
+ message: errors.statewireRejectionDetailMessage(error) ?? "Your decision could not be sent. Try again.",
48
+ epoch: approvalEpochRef.current
49
+ });
50
+ onResumeRejected == null ? void 0 : onResumeRejected(error, failedRequestId);
51
+ },
52
+ [onResumeRejected]
53
+ );
33
54
  const {
34
55
  request,
35
56
  requestId,
@@ -46,15 +67,27 @@ const StatewireApprovalCardInner = ({
46
67
  } = useStatewireApprovalRequest.useStatewireApprovalRequest({
47
68
  interruptPredicate,
48
69
  pendingResumeGraceMs,
49
- onResumeRejected
70
+ onResumeRejected: reportResumeRejected
50
71
  });
51
- const [dismissedId, setDismissedId] = react$1.useState();
52
- const [detailsOverride, setDetailsOverride] = react$1.useState();
53
- const [liveSentKey, setLiveSentKey] = react$1.useState();
54
- const [staleQueuedRequestId, setStaleQueuedRequestId] = react$1.useState();
55
- const [replayingRequestId, setReplayingRequestId] = react$1.useState();
56
- const sentLaneIdsRef = react$1.useRef(/* @__PURE__ */ new Set());
57
- const replayedRequestIdRef = react$1.useRef(void 0);
72
+ const mirroredApproval = reactStatewire.useStatewireState(
73
+ (state) => interrupts.asHitlApproval(interrupts.interruptMirrorPayload(interrupts.readInterruptMirror(state))) !== null
74
+ );
75
+ const approvalPresent = requestId !== void 0 || mirroredApproval;
76
+ const previousApprovalPresentRef = require$$0.useRef(approvalPresent);
77
+ if (previousApprovalPresentRef.current && !approvalPresent) approvalEpochRef.current += 1;
78
+ previousApprovalPresentRef.current = approvalPresent;
79
+ const [dismissedId, setDismissedId] = require$$0.useState();
80
+ const [detailsOverride, setDetailsOverride] = require$$0.useState();
81
+ const [liveSentKey, setLiveSentKey] = require$$0.useState();
82
+ const [staleQueuedRequestId, setStaleQueuedRequestId] = require$$0.useState();
83
+ const [replayingRequestId, setReplayingRequestId] = require$$0.useState();
84
+ const sentLaneIdsRef = require$$0.useRef(/* @__PURE__ */ new Set());
85
+ const replayedRequestIdRef = require$$0.useRef(void 0);
86
+ const [confirming, setConfirming] = require$$0.useState(false);
87
+ const currentRequestIdRef = require$$0.useRef(requestId);
88
+ currentRequestIdRef.current = requestId;
89
+ const confirmDecisionRef = require$$0.useRef(confirmDecision);
90
+ confirmDecisionRef.current = confirmDecision;
58
91
  const isLive = request === void 0 && liveHitl !== null;
59
92
  const hitl = isLive ? liveHitl : parkedHitl;
60
93
  const actionRequests = isLive ? liveActionRequests : parkedActionRequests;
@@ -64,7 +97,7 @@ const StatewireApprovalCardInner = ({
64
97
  const positional = laneIds === null || !isLive && laneIds.length <= 1;
65
98
  const liveKey = isLive ? (laneIds == null ? void 0 : laneIds.join("|")) ?? null : null;
66
99
  const viewKey = requestId ?? liveKey ?? void 0;
67
- const prevViewKeyRef = react$1.useRef(viewKey);
100
+ const prevViewKeyRef = require$$0.useRef(viewKey);
68
101
  if (prevViewKeyRef.current !== viewKey) {
69
102
  prevViewKeyRef.current = viewKey;
70
103
  if (detailsOverride !== void 0) setDetailsOverride(void 0);
@@ -90,9 +123,9 @@ const StatewireApprovalCardInner = ({
90
123
  const queuedLanesAwaitingHost = !isLive && !readOnly && !handledElsewhere && requestId !== void 0 && undecidedLaneIds !== null && undecidedLaneIds.length === 0 && !pending && !replaying;
91
124
  const queuedLaneGraceMs = pendingResumeGraceMs ?? interrupts.HITL_PENDING_RESUME_GRACE_MS;
92
125
  const laneKey = laneIds == null ? void 0 : laneIds.join("|");
93
- const onResumeRejectedRef = react$1.useRef(onResumeRejected);
94
- onResumeRejectedRef.current = onResumeRejected;
95
- react$1.useEffect(() => {
126
+ const onResumeRejectedRef = require$$0.useRef(reportResumeRejected);
127
+ onResumeRejectedRef.current = reportResumeRejected;
128
+ require$$0.useEffect(() => {
96
129
  if (!queuedLanesAwaitingHost || requestId === void 0 || laneKey === void 0) {
97
130
  return void 0;
98
131
  }
@@ -118,41 +151,101 @@ const StatewireApprovalCardInner = ({
118
151
  }, queuedLaneGraceMs);
119
152
  return () => clearTimeout(timer);
120
153
  }, [queuedLanesAwaitingHost, requestId, laneKey, queuedLaneGraceMs, replayQueuedLanes]);
121
- const decide = react$1.useCallback(
154
+ const withDecisionCheck = require$$0.useCallback(
155
+ (answer, deliver) => {
156
+ const confirmer = confirmDecisionRef.current;
157
+ if (confirmer === void 0 || !answerApproves(answer)) {
158
+ deliver();
159
+ return;
160
+ }
161
+ setConfirming(true);
162
+ confirmer(answer).catch(() => void 0).then((token) => {
163
+ setConfirming(false);
164
+ if (answer.kind === "input" && currentRequestIdRef.current !== answer.requestId) {
165
+ return;
166
+ }
167
+ deliver(token ? { decisionCheck: token } : void 0);
168
+ });
169
+ },
170
+ []
171
+ );
172
+ const sendLiveLanes = require$$0.useCallback(
173
+ ({
174
+ key,
175
+ lanes,
176
+ epoch,
177
+ extras
178
+ }) => {
179
+ const sentLaneIds = key.split("|");
180
+ setLiveSentKey(key);
181
+ Promise.resolve(sendLaneDecisions(lanes, extras)).then(
182
+ () => {
183
+ if (epoch !== approvalEpochRef.current) return;
184
+ for (const id of sentLaneIds) sentLaneIdsRef.current.add(id);
185
+ },
186
+ (error) => {
187
+ if (epoch !== approvalEpochRef.current) return;
188
+ setLiveSentKey((current) => current === key ? void 0 : current);
189
+ reportResumeRejected(error, sentLaneIds[0] ?? "");
190
+ }
191
+ );
192
+ },
193
+ [sendLaneDecisions, reportResumeRejected]
194
+ );
195
+ const decide = require$$0.useCallback(
122
196
  (value) => {
197
+ setDecisionFailure(void 0);
198
+ const epoch = approvalEpochRef.current;
123
199
  if (positional || undecidedLaneIds === null) {
124
- resume(value);
200
+ if (requestId === void 0) return;
201
+ withDecisionCheck({ kind: "input", requestId, value }, (extras) => {
202
+ resume(value, extras);
203
+ });
125
204
  return;
126
205
  }
127
206
  const lanes = interrupts.fanLaneDecision({ interruptIds: undecidedLaneIds, decision: value });
128
207
  if (!isLive) {
129
- sendLaneDecisions(lanes);
208
+ if (requestId === void 0) return;
209
+ withDecisionCheck(
210
+ { kind: "input", requestId, value: { lane_decisions: lanes } },
211
+ (extras) => {
212
+ sendLaneDecisions(lanes, extras);
213
+ }
214
+ );
130
215
  return;
131
216
  }
132
217
  const key = undecidedLaneIds.join("|");
133
- setLiveSentKey(key);
134
- Promise.resolve(sendLaneDecisions(lanes)).then(
135
- () => {
136
- for (const id of undecidedLaneIds) sentLaneIdsRef.current.add(id);
137
- },
138
- (error) => {
139
- setLiveSentKey((current) => current === key ? void 0 : current);
140
- onResumeRejected == null ? void 0 : onResumeRejected(error, undecidedLaneIds[0] ?? "");
141
- }
218
+ withDecisionCheck(
219
+ { kind: "lanes", laneDecisions: lanes },
220
+ (extras) => sendLiveLanes({ key, lanes, epoch, extras })
142
221
  );
143
222
  },
144
- [positional, undecidedLaneIds, isLive, resume, sendLaneDecisions, onResumeRejected]
223
+ [
224
+ positional,
225
+ undecidedLaneIds,
226
+ isLive,
227
+ requestId,
228
+ resume,
229
+ sendLaneDecisions,
230
+ sendLiveLanes,
231
+ withDecisionCheck
232
+ ]
145
233
  );
146
- const decideEach = react$1.useMemo(() => {
234
+ const decideEach = require$$0.useMemo(() => {
147
235
  if (interrupts.actionRequestToolCallIds(actionRequests) === null || !positional) return null;
148
236
  return (decision) => {
237
+ setDecisionFailure(void 0);
149
238
  const decisions = {};
150
239
  for (const request2 of actionRequests) {
151
240
  if (request2.toolCallId !== void 0) decisions[request2.toolCallId] = decision(request2);
152
241
  }
153
- resume(interrupts.hitlResumeActionDecisions(decisions));
242
+ const value = interrupts.hitlResumeActionDecisions(decisions);
243
+ if (requestId === void 0) return;
244
+ withDecisionCheck({ kind: "input", requestId, value }, (extras) => {
245
+ resume(value, extras);
246
+ });
154
247
  };
155
- }, [actionRequests, positional, resume]);
248
+ }, [actionRequests, positional, requestId, resume, withDecisionCheck]);
156
249
  if (!request && !isLive) {
157
250
  if (!abandonedInterrupt || abandonedInterrupt.id === dismissedId) return null;
158
251
  return /* @__PURE__ */ jsxRuntime.jsxs(
@@ -187,7 +280,7 @@ const StatewireApprovalCardInner = ({
187
280
  const showDetails = hasDetails && (detailsOverride ?? actionRequests.length <= 1);
188
281
  const sessionApprovalOffered = hitl !== null && interrupts.canApproveForSession(actionRequests);
189
282
  const laneDecided = undecidedLaneIds !== null && laneIds !== null && (undecidedLaneIds.length === 0 || liveSentKey === undecidedLaneIds.join("|"));
190
- const locked = pending || laneDecided || replaying;
283
+ const locked = pending || laneDecided || replaying || confirming;
191
284
  const editor = !readOnly && hitl !== null && renderEditor ? renderEditor({
192
285
  ...context,
193
286
  locked,
@@ -223,6 +316,7 @@ const StatewireApprovalCardInner = ({
223
316
  ] }) : message })
224
317
  ] })
225
318
  ] }) }),
319
+ decisionFailure && decisionFailure.epoch === approvalEpochRef.current && (decisionFailure.requestId === requestId || (laneIds == null ? void 0 : laneIds.includes(decisionFailure.requestId))) ? /* @__PURE__ */ jsxRuntime.jsx("p", { role: "alert", "data-testid": "statewire-approval-error", children: decisionFailure.message }) : null,
226
320
  isLive ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pt-1 text-muted-foreground text-xs", "data-testid": "statewire-approval-live", children: laneDecided ? "Decision sent — it applies as soon as this step pauses." : "Other work keeps running while you decide." }) : null,
227
321
  hasDetails && editor == null ? /* @__PURE__ */ jsxRuntime.jsxs(
228
322
  "button",
@@ -1 +1 @@
1
- {"version":3,"file":"StatewireApprovalCard.cjs","sources":["../../src/chat/StatewireApprovalCard.tsx"],"sourcesContent":["import { useAuiState } from '@assistant-ui/react';\nimport type { StatewireThread } from '@assistant-ui/react-statewire';\nimport {\n actionRequestToolCallIds,\n canApproveForSession,\n fanLaneDecision,\n HITL_PENDING_RESUME_GRACE_MS,\n type HitlActionDecision,\n type HitlApprovalPayload,\n hasStatewireThreadExtras,\n hitlResumeActionDecisions,\n hitlResumeApprove,\n hitlResumeApproveForSession,\n hitlResumeReject,\n interruptResumeDecline,\n laneInterruptIds,\n type PendingActionRequest,\n type PendingApprovalContext,\n readInterruptMessage,\n} from '@athenaintel/agent-runtime';\nimport {\n CheckCheckIcon,\n CheckIcon,\n ChevronDownIcon,\n ShieldAlertIcon,\n XIcon,\n} from 'lucide-react';\nimport {\n type FC,\n type ReactNode,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { cn } from '../lib/utils';\nimport { Button } from '../ui/button';\nimport {\n type StatewireInterruptPredicate,\n useStatewireApprovalRequest,\n} from './use-statewire-approval-request';\n\n/**\n * Human-in-the-loop approval card for the statewire transport — the one\n * approval UI every Athena chat surface mounts (the SDK's `AthenaChat`, the\n * Chrome side panel, the Office task pane, Olympus).\n *\n * When the deep-agent runtime hits an approval-gated tool call, the backend\n * parks the run on an `interrupt` input request. This card reads that request\n * through `useStatewireApprovalRequest` and answers it with\n * `{ type: 'run/input', requestId, response: { type: 'resume', value } }` —\n * the exact command the backend's resume path consumes. Without an answer the\n * run stays parked forever, so this card must be mounted on every statewire\n * chat surface. On legacy (non-statewire) threads it renders nothing.\n *\n * A gated call raised inside a delegated subagent parks only its lane: the\n * host mirrors that interrupt while the sibling lanes keep streaming, before\n * any input request exists. The card renders the mirrored payload the same\n * way and answers it with `run/lane-input` keyed by the lane's langgraph\n * interrupt id (`laneInterruptIds`); the host queues the decision and applies\n * it the moment the run parks, so the approver never waits on the siblings.\n * Once parked, a payload whose calls all carry interrupt ids resumes as a\n * `lane_decisions` map too — one positional `run/input` can only answer the\n * first of several parked lanes.\n *\n * Recovery of a queued decision the host never applies is ordered host\n * first: the host's answerer resumes the park or drops (and flushes) the\n * queue within `QUEUED_LANE_ANSWER_BUDGET_SECONDS` of the park, and this\n * card's grace (`HITL_PENDING_RESUME_GRACE_MS`, longer than that budget)\n * fires only when the host stayed silent. When it fires, the card that sent\n * the queued decision asks the host to replay it (`run/lane-replay` — the\n * host resumes as the approver, under the meta it recorded, and refuses any\n * other caller); every other card, and a replay the host refuses, hands the\n * decision back to a person by unlocking the actions. A queued decision is\n * never re-sent as a `run/input` of the viewing client's own: that would run\n * the approver's decision under the viewer's identity and configuration.\n *\n * Host-specific review UIs (subagent cards, email summaries) slot in through\n * `renderDetails`; a host composer that must also OWN the decision (an\n * editable email whose edits have to reach the backend) takes over the\n * details and the decision row through `renderEditor`; requests another\n * surface answers (typed interrupt families, per-lane subagent approvals)\n * stand down through `isHandledElsewhere`; viewers without edit rights see\n * `readOnlyNotice`.\n */\n\n/** What the card reads in place of the host's queued lanes once it has given up on them. */\nconst NO_HOST_QUEUED_LANE_DECISIONS: Readonly<Record<string, unknown>> = Object.freeze({});\n\n/** The pending request a host slot renders or judges. */\nexport interface StatewireApprovalRequestContext {\n /** The parked input request — `undefined` while the run still streams (a live lane approval). */\n request: StatewireThread.CustomInputRequest | undefined;\n /** The payload narrowed to the Athena HITL approval shape, or `null` for a generic park. */\n hitl: HitlApprovalPayload | null;\n /** Every gated call the approval covers, in decision order (empty for non-HITL parks). */\n actionRequests: PendingActionRequest[];\n}\n\n/** The request a host editor renders, plus the decisions it may send for it. */\nexport interface StatewireApprovalEditorContext extends StatewireApprovalRequestContext {\n /** A decision is in flight (or a live lane already answered); the editor must not send another. */\n locked: boolean;\n /** Whether \"approve all for this session\" may be offered for this batch. */\n sessionApprovalOffered: boolean;\n approve: () => void;\n approveForSession: () => void;\n reject: (reason?: string) => void;\n /**\n * Answer each gated call on its own — the only way an EDITED call reaches\n * the backend. `decision` is asked once per call, in order, so the answer\n * always names exactly the parked calls (a partial map is refused\n * server-side and nothing runs). `null` when the batch cannot take\n * per-action answers: a call without a `tool_call_id`, or a live / multi-\n * lane approval, which resumes per lane and carries no edit.\n */\n decideEach: ((decision: (request: PendingActionRequest) => HitlActionDecision) => void) | null;\n}\n\nexport interface StatewireApprovalCardProps {\n /** Surface-styling overrides merged onto the default classes. */\n classNames?: {\n /** The approval card container. */\n root?: string;\n /** The \"approval was cancelled\" notice container. */\n abandoned?: string;\n /** The disclosed details block. */\n details?: string;\n /** The decision row. */\n actions?: string;\n };\n /** Copy shown when an interrupt payload carries no message. */\n fallbackMessage?: string;\n /**\n * Which pending interrupt this card answers. Defaults to\n * `isApprovalCardInterrupt` (client-tool parks excluded — keep it that way\n * unless the surface handles those itself).\n */\n interruptPredicate?: StatewireInterruptPredicate;\n /**\n * How long a clicked decision keeps the buttons locked when no resume run\n * ever starts (a `run/input` the host rejected before any run began).\n * Defaults to `HITL_PENDING_RESUME_GRACE_MS`.\n */\n pendingResumeGraceMs?: number;\n /**\n * Return true when another surface answers this request (a typed Athena\n * interrupt family, per-lane subagent approval cards). The card renders\n * nothing for it — two surfaces must never answer the same input request.\n */\n isHandledElsewhere?: (context: StatewireApprovalRequestContext) => boolean;\n /**\n * Replace the default argument disclosure (one JSON block per gated call)\n * with a host-specific review UI. Rendered inside the collapsible details\n * region; the decision buttons stay with the card.\n */\n renderDetails?: (context: StatewireApprovalRequestContext) => ReactNode;\n /** Replace the default approval icon and heading. Return null to keep it. */\n renderHeader?: (context: StatewireApprovalRequestContext) => ReactNode;\n /**\n * Replace BOTH the details region and the decision row with a host\n * composer that decides the request itself through the context's\n * callbacks (an editable email whose edits must be what runs). Return\n * `null`/`undefined` to keep the default card for this request. Not\n * consulted for read-only viewers or non-HITL parks.\n */\n renderEditor?: (context: StatewireApprovalEditorContext) => ReactNode;\n /**\n * The viewer may see the request (it explains why the run is parked) but\n * cannot decide it — answering steers the shared run. Renders\n * `readOnlyNotice` in place of the buttons.\n */\n readOnly?: boolean;\n readOnlyNotice?: ReactNode;\n /**\n * Copy for a park that is not a HITL approval — a typed Athena interrupt\n * this surface has no card for. The only honest action is to decline it\n * (`{ action: 'reject' }`, which every typed raiser treats as a clean user\n * decline); a generic \"Continue\" would be rejected by the raiser's resume\n * schema and surface as a tool error.\n */\n nonHitlNotice?: ReactNode;\n /**\n * The host refused a decision (or the transport lost it). The optimistic\n * fold has rolled back and the request is on screen again with its actions\n * re-enabled; this is where a host tells the user why (a toast, a log line).\n */\n onResumeRejected?: (error: unknown, requestId: string) => void;\n}\n\nexport const StatewireApprovalCard: FC<StatewireApprovalCardProps> = (props) => {\n const extras = useAuiState((s) => s.thread.extras);\n if (!hasStatewireThreadExtras(extras)) return null;\n return <StatewireApprovalCardInner {...props} />;\n};\n\nconst StatewireApprovalCardInner: FC<StatewireApprovalCardProps> = ({\n classNames,\n fallbackMessage,\n interruptPredicate,\n pendingResumeGraceMs,\n isHandledElsewhere,\n renderDetails,\n renderHeader,\n renderEditor,\n readOnly = false,\n readOnlyNotice = 'Waiting for someone with edit access to respond.',\n nonHitlNotice = 'This request needs an answer this surface cannot collect.',\n onResumeRejected,\n}) => {\n const {\n request,\n requestId,\n hitl: parkedHitl,\n actionRequests: parkedActionRequests,\n liveHitl,\n liveActionRequests,\n queuedLaneDecisions,\n abandonedInterrupt,\n pending,\n resume,\n sendLaneDecisions,\n replayQueuedLanes,\n } = useStatewireApprovalRequest<StatewireThread.InputResponse>({\n interruptPredicate,\n pendingResumeGraceMs,\n onResumeRejected,\n });\n const [dismissedId, setDismissedId] = useState<string>();\n // The card shares the chat column with the thread. A lone gated call is\n // small enough to show inline, but a fan-out of a dozen calls would swallow\n // the conversation, so a batch starts collapsed until someone opens it.\n const [detailsOverride, setDetailsOverride] = useState<boolean>();\n // The live lanes a decision was sent for (joined ids); the buttons stay\n // locked until the host echoes them in `queuedLaneDecisions` or refuses.\n const [liveSentKey, setLiveSentKey] = useState<string>();\n // The parked request whose host-queued lanes outlived the grace window\n // (see `queuedLanesAwaitingHost` below): its queue is read as stale.\n const [staleQueuedRequestId, setStaleQueuedRequestId] = useState<string>();\n // The parked request whose queued lanes this card has asked the host to\n // replay (`run/lane-replay` in flight): locked until the host answers.\n const [replayingRequestId, setReplayingRequestId] = useState<string>();\n // The lanes THIS card decided live (its own `run/lane-input` the host\n // accepted). Only a queue this card recorded is replayed from here — the\n // host refuses any other caller, and a second editor's card must not even\n // ask. Pruned to the lanes on screen whenever a different view arrives, so\n // the record survives the live → parked transition of the same lanes (and\n // a fold that briefly shows nothing) and dies with a new request.\n const sentLaneIdsRef = useRef<Set<string>>(new Set());\n // The parked request already replayed once from here: a request is\n // replayed at most once, then the grace hands the decision back.\n const replayedRequestIdRef = useRef<string>(undefined);\n\n const isLive = request === undefined && liveHitl !== null;\n const hitl = isLive ? liveHitl : parkedHitl;\n const actionRequests = isLive ? liveActionRequests : parkedActionRequests;\n const laneIds = laneInterruptIds(actionRequests);\n // The host answers the lanes it queued from its own settle path, within its\n // published budget of the park (`QUEUED_LANE_ANSWER_BUDGET_SECONDS`). A\n // parked request whose queued lanes are still unanswered past the grace\n // window has a silent answerer, and either this card asked the host to\n // replay them and was refused, or the queue is not this card's to replay —\n // so the queue no longer counts as a decision here: the actions re-enable\n // and the next click answers the parked request itself (a resume the host\n // accepts, and whose dispatch drops the stale queue).\n const hostQueuedLaneDecisions =\n requestId !== undefined && staleQueuedRequestId === requestId\n ? NO_HOST_QUEUED_LANE_DECISIONS\n : queuedLaneDecisions;\n const undecidedLaneIds =\n laneIds?.filter((id) => !(id in hostQueuedLaneDecisions)) ?? null;\n // A lone parked lane (or an unstamped batch) answers with one positional\n // `run/input`; that is the only resume the backend binds per-action answers\n // to, so it is the only place an edited call can go.\n const positional = laneIds === null || (!isLive && laneIds.length <= 1);\n const liveKey = isLive ? (laneIds?.join('|') ?? null) : null;\n const viewKey = requestId ?? liveKey ?? undefined;\n\n // A fresh approval gets the default for ITS batch size, not the disclosure\n // the previous one was left in. Reset during render via React's \"previous\n // value\" pattern.\n const prevViewKeyRef = useRef(viewKey);\n if (prevViewKeyRef.current !== viewKey) {\n prevViewKeyRef.current = viewKey;\n if (detailsOverride !== undefined) setDetailsOverride(undefined);\n if (liveSentKey !== undefined) setLiveSentKey(undefined);\n if (laneIds !== null) {\n for (const id of sentLaneIdsRef.current) {\n if (!laneIds.includes(id)) sentLaneIdsRef.current.delete(id);\n }\n }\n }\n // The per-request marks (stale queue, replayed once, replay in flight)\n // outlive the optimistic fold of a click's own `run/input`: the request\n // leaves and comes back under the SAME id when the host refuses it, and a\n // card that forgot its stale mark then would relock over the standing\n // queue for another grace, and could replay it a second time. They are\n // forgotten only for a genuinely different parked request.\n if (\n requestId !== undefined &&\n staleQueuedRequestId !== undefined &&\n requestId !== staleQueuedRequestId\n ) {\n setStaleQueuedRequestId(undefined);\n }\n if (\n requestId !== undefined &&\n replayingRequestId !== undefined &&\n requestId !== replayingRequestId\n ) {\n setReplayingRequestId(undefined);\n }\n if (\n requestId !== undefined &&\n replayedRequestIdRef.current !== undefined &&\n requestId !== replayedRequestIdRef.current\n ) {\n replayedRequestIdRef.current = undefined;\n }\n\n const context: StatewireApprovalRequestContext = { request, hitl, actionRequests };\n const handledElsewhere = isHandledElsewhere?.(context) ?? false;\n const replaying = replayingRequestId !== undefined && replayingRequestId === requestId;\n\n // Parked, every lane the request covers already queued on the host, no\n // resume of our own in flight, and this card is the one that would decide\n // (not a viewer, not a request another surface owns): the host's answerer\n // is expected to resume the run within its budget. Start the clock on it,\n // longer than that budget. When it runs out the host has stayed silent: if\n // this card queued those lanes itself, it asks the host to replay them as\n // their approver (`run/lane-replay`); otherwise — and when the host refuses\n // the replay — the queue no longer counts as a decision here and the actions\n // re-enable, so a person decides. Never a `run/input` of this client's own\n // carrying someone else's recorded decision.\n const queuedLanesAwaitingHost =\n !isLive &&\n !readOnly &&\n !handledElsewhere &&\n requestId !== undefined &&\n undecidedLaneIds !== null &&\n undecidedLaneIds.length === 0 &&\n !pending &&\n !replaying;\n const queuedLaneGraceMs = pendingResumeGraceMs ?? HITL_PENDING_RESUME_GRACE_MS;\n const laneKey = laneIds?.join('|');\n const onResumeRejectedRef = useRef(onResumeRejected);\n onResumeRejectedRef.current = onResumeRejected;\n useEffect(() => {\n if (!queuedLanesAwaitingHost || requestId === undefined || laneKey === undefined) {\n return undefined;\n }\n const timer = setTimeout(() => {\n const ownQueue =\n laneKey.split('|').every((id) => sentLaneIdsRef.current.has(id)) &&\n replayedRequestIdRef.current !== requestId;\n if (!ownQueue) {\n setStaleQueuedRequestId(requestId);\n return;\n }\n replayedRequestIdRef.current = requestId;\n setReplayingRequestId(requestId);\n replayQueuedLanes(requestId).then(\n () => {\n setReplayingRequestId((current) => (current === requestId ? undefined : current));\n },\n (error: unknown) => {\n setReplayingRequestId((current) => (current === requestId ? undefined : current));\n setStaleQueuedRequestId(requestId);\n onResumeRejectedRef.current?.(error, requestId);\n },\n );\n }, queuedLaneGraceMs);\n return () => clearTimeout(timer);\n }, [queuedLanesAwaitingHost, requestId, laneKey, queuedLaneGraceMs, replayQueuedLanes]);\n\n const decide = useCallback(\n (value: Record<string, string>) => {\n // Several parked lanes (or a live one) answer by interrupt id: a\n // positional `run/input` would resume only the first and re-park the\n // rest. A lone parked lane keeps the positional resume every host\n // already speaks.\n if (positional || undecidedLaneIds === null) {\n resume(value);\n return;\n }\n const lanes = fanLaneDecision({ interruptIds: undecidedLaneIds, decision: value });\n if (!isLive) {\n sendLaneDecisions(lanes);\n return;\n }\n const key = undecidedLaneIds.join('|');\n setLiveSentKey(key);\n Promise.resolve(sendLaneDecisions(lanes)).then(\n () => {\n // The host holds these decisions for this card's caller: they are\n // the only queue this card may ask it to replay.\n for (const id of undecidedLaneIds) sentLaneIdsRef.current.add(id);\n },\n (error: unknown) => {\n setLiveSentKey((current) => (current === key ? undefined : current));\n onResumeRejected?.(error, undecidedLaneIds[0] ?? '');\n },\n );\n },\n [positional, undecidedLaneIds, isLive, resume, sendLaneDecisions, onResumeRejected],\n );\n\n const decideEach = useMemo<StatewireApprovalEditorContext['decideEach']>(() => {\n if (actionRequestToolCallIds(actionRequests) === null || !positional) return null;\n return (decision) => {\n const decisions: Record<string, HitlActionDecision> = {};\n for (const request of actionRequests) {\n if (request.toolCallId !== undefined) decisions[request.toolCallId] = decision(request);\n }\n // The edited argument set comes from the wire as JSON; the resume value\n // is that JSON going back.\n resume(hitlResumeActionDecisions(decisions) as StatewireThread.InputResponse);\n };\n }, [actionRequests, positional, resume]);\n\n if (!request && !isLive) {\n if (!abandonedInterrupt || abandonedInterrupt.id === dismissedId) return null;\n return (\n <div\n className={cn(\n 'aui-approval-abandoned flex w-full items-center justify-between gap-3 rounded-xl border border-border bg-muted/40 px-3 py-2 text-muted-foreground text-xs',\n classNames?.abandoned,\n )}\n >\n <p>Approval was cancelled — the run moved on.</p>\n <button\n type=\"button\"\n aria-label=\"Dismiss cancelled approval\"\n onClick={() => setDismissedId(abandonedInterrupt.id)}\n className=\"shrink-0 rounded-md p-1 transition-colors hover:bg-muted hover:text-foreground\"\n >\n <XIcon className=\"size-3.5\" />\n </button>\n </div>\n );\n }\n\n if (handledElsewhere) return null;\n // A live mirror without lane stamps cannot be answered before the run\n // parks; the parked request renders it then.\n if (isLive && laneIds === null) return null;\n\n const message = readInterruptMessage(request ? request.payload : liveHitl, fallbackMessage);\n const toolName = hitl?.context?.tool_name ?? hitl?.context?.tool_id;\n const pendingCount = hitl?.context?.pending_action_count ?? 1;\n const hasDetails = hitl !== null && actionRequests.length > 0;\n const showDetails = hasDetails && (detailsOverride ?? actionRequests.length <= 1);\n const sessionApprovalOffered = hitl !== null && canApproveForSession(actionRequests);\n const laneDecided =\n undecidedLaneIds !== null &&\n laneIds !== null &&\n (undecidedLaneIds.length === 0 || liveSentKey === undecidedLaneIds.join('|'));\n const locked = pending || laneDecided || replaying;\n\n const editor =\n !readOnly && hitl !== null && renderEditor\n ? renderEditor({\n ...context,\n locked,\n sessionApprovalOffered,\n approve: () => decide(hitlResumeApprove()),\n approveForSession: () => decide(hitlResumeApproveForSession()),\n reject: (reason) => decide(hitlResumeReject(reason)),\n decideEach,\n })\n : undefined;\n const customHeader = renderHeader?.(context);\n\n return (\n <section\n aria-label={hitl ? 'Approval required' : 'Input required'}\n className={cn(\n 'aui-approval-card w-full rounded-2xl border border-border bg-card px-4 py-3 text-foreground shadow-xs',\n classNames?.root,\n )}\n >\n <div className=\"flex items-start gap-3\">\n {customHeader != null ? (\n <div className=\"min-w-0 flex-1\">{customHeader}</div>\n ) : (\n <>\n <ShieldAlertIcon className=\"mt-0.5 size-4 shrink-0 text-muted-foreground\" />\n <div className=\"min-w-0 flex-1\">\n <p className=\"flex items-center gap-2 font-semibold text-sm\">\n <span>{hitl ? 'Approval required' : 'Waiting for input'}</span>\n {hitl && pendingCount > 1 ? (\n <span className=\"shrink-0 rounded-full border border-border bg-muted px-1.5 py-px font-normal text-[11px] text-muted-foreground\">\n {pendingCount} tool calls\n </span>\n ) : null}\n </p>\n <p className=\"pt-1 text-muted-foreground text-sm leading-snug\">\n {hitl && pendingCount === 1 && toolName ? (\n <>\n <span className=\"font-mono text-foreground\">{toolName}</span> requires approval before it runs.\n </>\n ) : (\n message\n )}\n </p>\n </div>\n </>\n )}\n </div>\n {isLive ? (\n <p className=\"pt-1 text-muted-foreground text-xs\" data-testid=\"statewire-approval-live\">\n {laneDecided\n ? 'Decision sent — it applies as soon as this step pauses.'\n : 'Other work keeps running while you decide.'}\n </p>\n ) : null}\n {hasDetails && editor == null ? (\n <button\n type=\"button\"\n onClick={() => setDetailsOverride(!showDetails)}\n aria-expanded={showDetails}\n className=\"mt-2 flex items-center gap-1 rounded px-1 py-0.5 text-muted-foreground text-xs transition-colors hover:text-foreground\"\n >\n <ChevronDownIcon\n className={cn('size-3 transition-transform', showDetails && 'rotate-180')}\n />\n {showDetails ? 'Hide details' : 'Review details'}\n </button>\n ) : null}\n {/* EVERY pending gated call renders, in order — one decision\n authorizes the whole batch, so nothing may hide behind a host's\n richer cards. All read-only: this runtime resumes through\n `hitl_response_to_decisions`, which has no `tool_args` channel —\n an editable composer would let someone rewrite an email and then\n watch the original go out — unless the host takes over the\n decision too (`renderEditor`), which sends the edit per call. */}\n {editor != null ? (\n <div className={cn('mt-3 flex flex-col gap-2', classNames?.details)}>{editor}</div>\n ) : showDetails ? (\n <div className={cn('mt-2 flex flex-col gap-2', classNames?.details)}>\n {renderDetails ? (\n renderDetails(context)\n ) : (\n <DefaultApprovalDetails actionRequests={actionRequests} />\n )}\n </div>\n ) : null}\n {editor != null ? null : (\n <div className={cn('flex flex-wrap items-center gap-2 pt-3', classNames?.actions)}>\n {readOnly ? (\n <p className=\"text-muted-foreground text-sm\" data-testid=\"statewire-approval-read-only\">\n {readOnlyNotice}\n </p>\n ) : hitl ? (\n <>\n <Button\n size=\"sm\"\n disabled={locked}\n onClick={() => decide(hitlResumeApprove())}\n >\n <CheckIcon />\n Approve\n </Button>\n {sessionApprovalOffered ? (\n <Button\n size=\"sm\"\n variant=\"outline\"\n disabled={locked}\n onClick={() => decide(hitlResumeApproveForSession())}\n data-testid=\"statewire-approval-approve-session\"\n >\n <CheckCheckIcon />\n Approve all for this session\n </Button>\n ) : null}\n <Button\n size=\"sm\"\n variant=\"outline\"\n disabled={locked}\n onClick={() => decide(hitlResumeReject())}\n >\n <XIcon />\n Reject\n </Button>\n </>\n ) : (\n <>\n <p className=\"text-muted-foreground text-sm\" data-testid=\"statewire-approval-non-hitl\">\n {nonHitlNotice}\n </p>\n <Button\n size=\"sm\"\n variant=\"outline\"\n disabled={pending}\n onClick={() => resume(interruptResumeDecline())}\n >\n <XIcon />\n Decline\n </Button>\n </>\n )}\n </div>\n )}\n </section>\n );\n};\n\n/**\n * What the backend resolved about a call before asking (where a Slack write\n * goes and as whom, Slack Connect warnings), above its raw arguments.\n */\nconst ApprovalContextFacts: FC<{ context: PendingApprovalContext }> = ({ context }) => (\n <div className=\"mt-1 space-y-0.5\" data-testid=\"statewire-approval-context\">\n {context.facts.map((fact) => (\n <p key={fact.label}>\n <span className=\"font-semibold\">{fact.label}:</span> {fact.value}\n </p>\n ))}\n {context.warnings.map((warning) => (\n <p\n key={warning.message}\n className={warning.severity === 'info' ? undefined : 'font-semibold'}\n >\n {warning.message}\n </p>\n ))}\n </div>\n);\n\n/** One block per gated call: its name (when the batch has several), its resolved facts, and its arguments as JSON. */\nconst DefaultApprovalDetails: FC<{ actionRequests: PendingActionRequest[] }> = ({\n actionRequests,\n}) => (\n <>\n {actionRequests.map((action, index) => (\n <div\n key={`${action.name}-${index}`}\n className=\"rounded-lg border border-border/60 bg-muted/40 p-2 text-foreground text-xs leading-relaxed\"\n >\n {actionRequests.length > 1 ? (\n <p className=\"font-mono font-semibold\">{action.name}</p>\n ) : null}\n {action.approvalContext ? <ApprovalContextFacts context={action.approvalContext} /> : null}\n {Object.keys(action.args).length > 0 ? (\n <pre className=\"mt-1 max-h-32 overflow-auto whitespace-pre-wrap break-words rounded bg-background p-1.5 font-mono text-[11px]\">\n {JSON.stringify(action.args, null, 2)}\n </pre>\n ) : (\n <p className=\"text-muted-foreground\">No arguments.</p>\n )}\n </div>\n ))}\n </>\n);\n"],"names":["useAuiState","hasStatewireThreadExtras","jsx","useStatewireApprovalRequest","useState","useRef","laneInterruptIds","HITL_PENDING_RESUME_GRACE_MS","useEffect","_a","useCallback","fanLaneDecision","useMemo","actionRequestToolCallIds","request","hitlResumeActionDecisions","jsxs","cn","XIcon","readInterruptMessage","canApproveForSession","hitlResumeApprove","hitlResumeApproveForSession","hitlResumeReject","Fragment","ShieldAlertIcon","ChevronDownIcon","Button","CheckIcon","CheckCheckIcon","interruptResumeDecline"],"mappings":";;;;;;;;;;;AAwFA,MAAM,gCAAmE,OAAO,OAAO,EAAE;AAuGlF,MAAM,wBAAwD,CAAC,UAAU;AAC9E,QAAM,SAASA,MAAAA,YAAY,CAAC,MAAM,EAAE,OAAO,MAAM;AACjD,MAAI,CAACC,aAAAA,yBAAyB,MAAM,EAAG,QAAO;AAC9C,SAAOC,+BAAC,4BAAA,EAA4B,GAAG,MAAA,CAAO;AAChD;AAEA,MAAM,6BAA6D,CAAC;AAAA,EAClE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX,iBAAiB;AAAA,EACjB,gBAAgB;AAAA,EAChB;AACF,MAAM;;AACJ,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN,gBAAgB;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,IACEC,wDAA2D;AAAA,IAC7D;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACD;AACD,QAAM,CAAC,aAAa,cAAc,IAAIC,iBAAA;AAItC,QAAM,CAAC,iBAAiB,kBAAkB,IAAIA,iBAA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AA,QAAQ;AAAA,IAAA;AAAA,IAHJ,QAAQ;AAAA,EAAA,CAKhB;AAAA,GACH;AAIF,MAAM,yBAAyE,CAAC;AAAA,EAC9E;AACF,MACEA,2BAAAA,IAAAsB,WAAAA,UAAA,EACG,UAAA,eAAe,IAAI,CAAC,QAAQ,UAC3BR,2BAAAA;AAAAA,EAAC;AAAA,EAAA;AAAA,IAEC,WAAU;AAAA,IAET,UAAA;AAAA,MAAA,eAAe,SAAS,IACvBd,2BAAAA,IAAC,KAAA,EAAE,WAAU,2BAA2B,UAAA,OAAO,MAAK,IAClD;AAAA,MACH,OAAO,kBAAkBA,2BAAAA,IAAC,wBAAqB,SAAS,OAAO,iBAAiB,IAAK;AAAA,MACrF,OAAO,KAAK,OAAO,IAAI,EAAE,SAAS,IACjCA,2BAAAA,IAAC,OAAA,EAAI,WAAU,iHACZ,eAAK,UAAU,OAAO,MAAM,MAAM,CAAC,EAAA,CACtC,IAEAA,+BAAC,KAAA,EAAE,WAAU,yBAAwB,UAAA,gBAAA,CAAa;AAAA,IAAA;AAAA,EAAA;AAAA,EAZ/C,GAAG,OAAO,IAAI,IAAI,KAAK;AAc9B,CACD,GACH;;"}
1
+ {"version":3,"file":"StatewireApprovalCard.cjs","sources":["../../src/chat/StatewireApprovalCard.tsx"],"sourcesContent":["import { useAuiState } from '@assistant-ui/react';\nimport { type StatewireThread, useStatewireState } from '@assistant-ui/react-statewire';\nimport {\n actionRequestToolCallIds,\n asHitlApproval,\n canApproveForSession,\n fanLaneDecision,\n HITL_PENDING_RESUME_GRACE_MS,\n type HitlActionDecision,\n type HitlApprovalPayload,\n hasStatewireThreadExtras,\n hitlResumeActionDecisions,\n hitlResumeApprove,\n hitlResumeApproveForSession,\n hitlResumeReject,\n interruptResumeDecline,\n interruptMirrorPayload,\n laneInterruptIds,\n type PendingActionRequest,\n type PendingApprovalContext,\n readInterruptMessage,\n readInterruptMirror,\n type ResumeExtras,\n resumeValueApproves,\n statewireRejectionDetailMessage,\n} from '@athenaintel/agent-runtime';\nimport {\n CheckCheckIcon,\n CheckIcon,\n ChevronDownIcon,\n ShieldAlertIcon,\n XIcon,\n} from 'lucide-react';\nimport {\n type FC,\n type ReactNode,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { cn } from '../lib/utils';\nimport { Button } from '../ui/button';\nimport {\n type StatewireInterruptPredicate,\n useStatewireApprovalRequest,\n} from './use-statewire-approval-request';\n\n/**\n * Human-in-the-loop approval card for the statewire transport — the one\n * approval UI every Athena chat surface mounts (the SDK's `AthenaChat`, the\n * Chrome side panel, the Office task pane, Olympus).\n *\n * When the deep-agent runtime hits an approval-gated tool call, the backend\n * parks the run on an `interrupt` input request. This card reads that request\n * through `useStatewireApprovalRequest` and answers it with\n * `{ type: 'run/input', requestId, response: { type: 'resume', value } }` —\n * the exact command the backend's resume path consumes. Without an answer the\n * run stays parked forever, so this card must be mounted on every statewire\n * chat surface. On legacy (non-statewire) threads it renders nothing.\n *\n * A gated call raised inside a delegated subagent parks only its lane: the\n * host mirrors that interrupt while the sibling lanes keep streaming, before\n * any input request exists. The card renders the mirrored payload the same\n * way and answers it with `run/lane-input` keyed by the lane's langgraph\n * interrupt id (`laneInterruptIds`); the host queues the decision and applies\n * it the moment the run parks, so the approver never waits on the siblings.\n * Once parked, a payload whose calls all carry interrupt ids resumes as a\n * `lane_decisions` map too — one positional `run/input` can only answer the\n * first of several parked lanes.\n *\n * Recovery of a queued decision the host never applies is ordered host\n * first: the host's answerer resumes the park or drops (and flushes) the\n * queue within `QUEUED_LANE_ANSWER_BUDGET_SECONDS` of the park, and this\n * card's grace (`HITL_PENDING_RESUME_GRACE_MS`, longer than that budget)\n * fires only when the host stayed silent. When it fires, the card that sent\n * the queued decision asks the host to replay it (`run/lane-replay` — the\n * host resumes as the approver, under the meta it recorded, and refuses any\n * other caller); every other card, and a replay the host refuses, hands the\n * decision back to a person by unlocking the actions. A queued decision is\n * never re-sent as a `run/input` of the viewing client's own: that would run\n * the approver's decision under the viewer's identity and configuration.\n *\n * Host-specific review UIs (subagent cards, email summaries) slot in through\n * `renderDetails`; a host composer that must also OWN the decision (an\n * editable email whose edits have to reach the backend) takes over the\n * details and the decision row through `renderEditor`; requests another\n * surface answers (typed interrupt families, per-lane subagent approvals)\n * stand down through `isHandledElsewhere`; viewers without edit rights see\n * `readOnlyNotice`.\n */\n\n/**\n * The answer a passkey decision check confirms before the card sends it\n * (identity 0b.9): a `run/input` resume of the parked request, or the lane\n * decisions of a `run/lane-input` sent while sibling lanes still stream.\n */\nexport type StatewireDecisionAnswer =\n | {\n readonly kind: 'input';\n readonly requestId: string;\n readonly value: StatewireThread.InputResponse;\n }\n | {\n readonly kind: 'lanes';\n readonly laneDecisions: Readonly<Record<string, StatewireThread.InputResponse>>;\n };\n\n/**\n * Runs the host's passkey check for an approving answer and resolves its\n * token, or `undefined` to send the answer without one. While checks are\n * report-only, an answer goes ahead without a check (no passkey yet, a\n * cancelled prompt); the host decides what to tell the person. Never called\n * for an answer that only rejects.\n */\nexport type StatewireDecisionConfirmer = (\n answer: StatewireDecisionAnswer,\n) => Promise<string | undefined>;\n\nfunction answerApproves(answer: StatewireDecisionAnswer): boolean {\n if (answer.kind === 'input') return resumeValueApproves(answer.value);\n const lanes = Object.values(answer.laneDecisions);\n return lanes.length === 0 || lanes.some(resumeValueApproves);\n}\n\n/** What the card reads in place of the host's queued lanes once it has given up on them. */\nconst NO_HOST_QUEUED_LANE_DECISIONS: Readonly<Record<string, unknown>> = Object.freeze({});\n\n/** The pending request a host slot renders or judges. */\nexport interface StatewireApprovalRequestContext {\n /** The parked input request — `undefined` while the run still streams (a live lane approval). */\n request: StatewireThread.CustomInputRequest | undefined;\n /** The payload narrowed to the Athena HITL approval shape, or `null` for a generic park. */\n hitl: HitlApprovalPayload | null;\n /** Every gated call the approval covers, in decision order (empty for non-HITL parks). */\n actionRequests: PendingActionRequest[];\n}\n\n/** The request a host editor renders, plus the decisions it may send for it. */\nexport interface StatewireApprovalEditorContext extends StatewireApprovalRequestContext {\n /** A decision is in flight (or a live lane already answered); the editor must not send another. */\n locked: boolean;\n /** Whether \"approve all for this session\" may be offered for this batch. */\n sessionApprovalOffered: boolean;\n approve: () => void;\n approveForSession: () => void;\n reject: (reason?: string) => void;\n /**\n * Answer each gated call on its own — the only way an EDITED call reaches\n * the backend. `decision` is asked once per call, in order, so the answer\n * always names exactly the parked calls (a partial map is refused\n * server-side and nothing runs). `null` when the batch cannot take\n * per-action answers: a call without a `tool_call_id`, or a live / multi-\n * lane approval, which resumes per lane and carries no edit.\n */\n decideEach: ((decision: (request: PendingActionRequest) => HitlActionDecision) => void) | null;\n}\n\nexport interface StatewireApprovalCardProps {\n /** Surface-styling overrides merged onto the default classes. */\n classNames?: {\n /** The approval card container. */\n root?: string;\n /** The \"approval was cancelled\" notice container. */\n abandoned?: string;\n /** The disclosed details block. */\n details?: string;\n /** The decision row. */\n actions?: string;\n };\n /** Copy shown when an interrupt payload carries no message. */\n fallbackMessage?: string;\n /**\n * Which pending interrupt this card answers. Defaults to\n * `isApprovalCardInterrupt` (client-tool parks excluded — keep it that way\n * unless the surface handles those itself).\n */\n interruptPredicate?: StatewireInterruptPredicate;\n /**\n * How long a clicked decision keeps the buttons locked when no resume run\n * ever starts (a `run/input` the host rejected before any run began).\n * Defaults to `HITL_PENDING_RESUME_GRACE_MS`.\n */\n pendingResumeGraceMs?: number;\n /**\n * Return true when another surface answers this request (a typed Athena\n * interrupt family, per-lane subagent approval cards). The card renders\n * nothing for it — two surfaces must never answer the same input request.\n */\n isHandledElsewhere?: (context: StatewireApprovalRequestContext) => boolean;\n /**\n * Replace the default argument disclosure (one JSON block per gated call)\n * with a host-specific review UI. Rendered inside the collapsible details\n * region; the decision buttons stay with the card.\n */\n renderDetails?: (context: StatewireApprovalRequestContext) => ReactNode;\n /** Replace the default approval icon and heading. Return null to keep it. */\n renderHeader?: (context: StatewireApprovalRequestContext) => ReactNode;\n /**\n * Replace BOTH the details region and the decision row with a host\n * composer that decides the request itself through the context's\n * callbacks (an editable email whose edits must be what runs). Return\n * `null`/`undefined` to keep the default card for this request. Not\n * consulted for read-only viewers or non-HITL parks.\n */\n renderEditor?: (context: StatewireApprovalEditorContext) => ReactNode;\n /**\n * The viewer may see the request (it explains why the run is parked) but\n * cannot decide it — answering steers the shared run. Renders\n * `readOnlyNotice` in place of the buttons.\n */\n readOnly?: boolean;\n readOnlyNotice?: ReactNode;\n /**\n * Copy for a park that is not a HITL approval — a typed Athena interrupt\n * this surface has no card for. The only honest action is to decline it\n * (`{ action: 'reject' }`, which every typed raiser treats as a clean user\n * decline); a generic \"Continue\" would be rejected by the raiser's resume\n * schema and surface as a tool error.\n */\n nonHitlNotice?: ReactNode;\n /**\n * The host refused a decision (or the transport lost it). The optimistic\n * fold has rolled back and the request is on screen again with its actions\n * re-enabled; this is where a host tells the user why (a toast, a log line).\n */\n onResumeRejected?: (error: unknown, requestId: string) => void;\n /**\n * The host's passkey decision check (identity 0b.9). An answer that lets\n * anything run is handed to it first and sent with the token it resolves\n * as `decisionCheck`; the decision buttons stay locked while it runs. An\n * answer that only rejects never is. Omit it and every answer is sent as\n * before, with no check.\n */\n confirmDecision?: StatewireDecisionConfirmer;\n}\n\nexport const StatewireApprovalCard: FC<StatewireApprovalCardProps> = (props) => {\n const extras = useAuiState((s) => s.thread.extras);\n if (!hasStatewireThreadExtras(extras)) return null;\n return <StatewireApprovalCardInner {...props} />;\n};\n\nconst StatewireApprovalCardInner: FC<StatewireApprovalCardProps> = ({\n classNames,\n fallbackMessage,\n interruptPredicate,\n pendingResumeGraceMs,\n isHandledElsewhere,\n renderDetails,\n renderHeader,\n renderEditor,\n readOnly = false,\n readOnlyNotice = 'Waiting for someone with edit access to respond.',\n nonHitlNotice = 'This request needs an answer this surface cannot collect.',\n onResumeRejected,\n confirmDecision,\n}) => {\n const approvalEpochRef = useRef(0);\n const [decisionFailure, setDecisionFailure] = useState<{\n requestId: string;\n message: string;\n epoch: number;\n }>();\n const reportResumeRejected = useCallback(\n (error: unknown, failedRequestId: string) => {\n setDecisionFailure({\n requestId: failedRequestId,\n message: statewireRejectionDetailMessage(error) ?? 'Your decision could not be sent. Try again.',\n epoch: approvalEpochRef.current,\n });\n onResumeRejected?.(error, failedRequestId);\n },\n [onResumeRejected],\n );\n const {\n request,\n requestId,\n hitl: parkedHitl,\n actionRequests: parkedActionRequests,\n liveHitl,\n liveActionRequests,\n queuedLaneDecisions,\n abandonedInterrupt,\n pending,\n resume,\n sendLaneDecisions,\n replayQueuedLanes,\n } = useStatewireApprovalRequest<StatewireThread.InputResponse>({\n interruptPredicate,\n pendingResumeGraceMs,\n onResumeRejected: reportResumeRejected,\n });\n // Read the host mirror: the optimistic resume fold can temporarily hide\n // `liveHitl` and the parked request without ending this approval.\n const mirroredApproval = useStatewireState(\n (state) => asHitlApproval(interruptMirrorPayload(readInterruptMirror(state))) !== null,\n );\n const approvalPresent = requestId !== undefined || mirroredApproval;\n const previousApprovalPresentRef = useRef(approvalPresent);\n if (previousApprovalPresentRef.current && !approvalPresent) approvalEpochRef.current += 1;\n previousApprovalPresentRef.current = approvalPresent;\n const [dismissedId, setDismissedId] = useState<string>();\n // The card shares the chat column with the thread. A lone gated call is\n // small enough to show inline, but a fan-out of a dozen calls would swallow\n // the conversation, so a batch starts collapsed until someone opens it.\n const [detailsOverride, setDetailsOverride] = useState<boolean>();\n // The live lanes a decision was sent for (joined ids); the buttons stay\n // locked until the host echoes them in `queuedLaneDecisions` or refuses.\n const [liveSentKey, setLiveSentKey] = useState<string>();\n // The parked request whose host-queued lanes outlived the grace window\n // (see `queuedLanesAwaitingHost` below): its queue is read as stale.\n const [staleQueuedRequestId, setStaleQueuedRequestId] = useState<string>();\n // The parked request whose queued lanes this card has asked the host to\n // replay (`run/lane-replay` in flight): locked until the host answers.\n const [replayingRequestId, setReplayingRequestId] = useState<string>();\n // The lanes THIS card decided live (its own `run/lane-input` the host\n // accepted). Only a queue this card recorded is replayed from here — the\n // host refuses any other caller, and a second editor's card must not even\n // ask. Pruned to the lanes on screen whenever a different view arrives, so\n // the record survives the live → parked transition of the same lanes (and\n // a fold that briefly shows nothing) and dies with a new request.\n const sentLaneIdsRef = useRef<Set<string>>(new Set());\n // The parked request already replayed once from here: a request is\n // replayed at most once, then the grace hands the decision back.\n const replayedRequestIdRef = useRef<string>(undefined);\n // A passkey check is running for the answer clicked here; the buttons stay\n // locked until it settles.\n const [confirming, setConfirming] = useState(false);\n // The parked request on screen now, read after a check settles: an answer\n // confirmed for a request that is no longer parked is never sent.\n const currentRequestIdRef = useRef(requestId);\n currentRequestIdRef.current = requestId;\n const confirmDecisionRef = useRef(confirmDecision);\n confirmDecisionRef.current = confirmDecision;\n\n const isLive = request === undefined && liveHitl !== null;\n const hitl = isLive ? liveHitl : parkedHitl;\n const actionRequests = isLive ? liveActionRequests : parkedActionRequests;\n const laneIds = laneInterruptIds(actionRequests);\n // The host answers the lanes it queued from its own settle path, within its\n // published budget of the park (`QUEUED_LANE_ANSWER_BUDGET_SECONDS`). A\n // parked request whose queued lanes are still unanswered past the grace\n // window has a silent answerer, and either this card asked the host to\n // replay them and was refused, or the queue is not this card's to replay —\n // so the queue no longer counts as a decision here: the actions re-enable\n // and the next click answers the parked request itself (a resume the host\n // accepts, and whose dispatch drops the stale queue).\n const hostQueuedLaneDecisions =\n requestId !== undefined && staleQueuedRequestId === requestId\n ? NO_HOST_QUEUED_LANE_DECISIONS\n : queuedLaneDecisions;\n const undecidedLaneIds =\n laneIds?.filter((id) => !(id in hostQueuedLaneDecisions)) ?? null;\n // A lone parked lane (or an unstamped batch) answers with one positional\n // `run/input`; that is the only resume the backend binds per-action answers\n // to, so it is the only place an edited call can go.\n const positional = laneIds === null || (!isLive && laneIds.length <= 1);\n const liveKey = isLive ? (laneIds?.join('|') ?? null) : null;\n const viewKey = requestId ?? liveKey ?? undefined;\n\n // A fresh approval gets the default for ITS batch size, not the disclosure\n // the previous one was left in. Reset during render via React's \"previous\n // value\" pattern.\n const prevViewKeyRef = useRef(viewKey);\n if (prevViewKeyRef.current !== viewKey) {\n prevViewKeyRef.current = viewKey;\n if (detailsOverride !== undefined) setDetailsOverride(undefined);\n if (liveSentKey !== undefined) setLiveSentKey(undefined);\n if (laneIds !== null) {\n for (const id of sentLaneIdsRef.current) {\n if (!laneIds.includes(id)) sentLaneIdsRef.current.delete(id);\n }\n }\n }\n // The per-request marks (stale queue, replayed once, replay in flight)\n // outlive the optimistic fold of a click's own `run/input`: the request\n // leaves and comes back under the SAME id when the host refuses it, and a\n // card that forgot its stale mark then would relock over the standing\n // queue for another grace, and could replay it a second time. They are\n // forgotten only for a genuinely different parked request.\n if (\n requestId !== undefined &&\n staleQueuedRequestId !== undefined &&\n requestId !== staleQueuedRequestId\n ) {\n setStaleQueuedRequestId(undefined);\n }\n if (\n requestId !== undefined &&\n replayingRequestId !== undefined &&\n requestId !== replayingRequestId\n ) {\n setReplayingRequestId(undefined);\n }\n if (\n requestId !== undefined &&\n replayedRequestIdRef.current !== undefined &&\n requestId !== replayedRequestIdRef.current\n ) {\n replayedRequestIdRef.current = undefined;\n }\n\n const context: StatewireApprovalRequestContext = { request, hitl, actionRequests };\n const handledElsewhere = isHandledElsewhere?.(context) ?? false;\n const replaying = replayingRequestId !== undefined && replayingRequestId === requestId;\n\n // Parked, every lane the request covers already queued on the host, no\n // resume of our own in flight, and this card is the one that would decide\n // (not a viewer, not a request another surface owns): the host's answerer\n // is expected to resume the run within its budget. Start the clock on it,\n // longer than that budget. When it runs out the host has stayed silent: if\n // this card queued those lanes itself, it asks the host to replay them as\n // their approver (`run/lane-replay`); otherwise — and when the host refuses\n // the replay — the queue no longer counts as a decision here and the actions\n // re-enable, so a person decides. Never a `run/input` of this client's own\n // carrying someone else's recorded decision.\n const queuedLanesAwaitingHost =\n !isLive &&\n !readOnly &&\n !handledElsewhere &&\n requestId !== undefined &&\n undecidedLaneIds !== null &&\n undecidedLaneIds.length === 0 &&\n !pending &&\n !replaying;\n const queuedLaneGraceMs = pendingResumeGraceMs ?? HITL_PENDING_RESUME_GRACE_MS;\n const laneKey = laneIds?.join('|');\n const onResumeRejectedRef = useRef(reportResumeRejected);\n onResumeRejectedRef.current = reportResumeRejected;\n useEffect(() => {\n if (!queuedLanesAwaitingHost || requestId === undefined || laneKey === undefined) {\n return undefined;\n }\n const timer = setTimeout(() => {\n const ownQueue =\n laneKey.split('|').every((id) => sentLaneIdsRef.current.has(id)) &&\n replayedRequestIdRef.current !== requestId;\n if (!ownQueue) {\n setStaleQueuedRequestId(requestId);\n return;\n }\n replayedRequestIdRef.current = requestId;\n setReplayingRequestId(requestId);\n replayQueuedLanes(requestId).then(\n () => {\n setReplayingRequestId((current) => (current === requestId ? undefined : current));\n },\n (error: unknown) => {\n setReplayingRequestId((current) => (current === requestId ? undefined : current));\n setStaleQueuedRequestId(requestId);\n onResumeRejectedRef.current?.(error, requestId);\n },\n );\n }, queuedLaneGraceMs);\n return () => clearTimeout(timer);\n }, [queuedLanesAwaitingHost, requestId, laneKey, queuedLaneGraceMs, replayQueuedLanes]);\n\n /**\n * Send `answer` through `deliver`, with a passkey check first when it\n * approves and the host runs one. The check is the person's own act on\n * their device; while it is open the card is locked, and if the parked\n * request changed meanwhile the confirmed answer is dropped, never sent to\n * whatever parked next.\n */\n const withDecisionCheck = useCallback(\n (answer: StatewireDecisionAnswer, deliver: (extras?: ResumeExtras) => void) => {\n const confirmer = confirmDecisionRef.current;\n if (confirmer === undefined || !answerApproves(answer)) {\n deliver();\n return;\n }\n setConfirming(true);\n confirmer(answer)\n .catch(() => undefined)\n .then((token) => {\n setConfirming(false);\n if (answer.kind === 'input' && currentRequestIdRef.current !== answer.requestId) {\n return;\n }\n deliver(token ? { decisionCheck: token } : undefined);\n });\n },\n [],\n );\n\n // A live lane decision: the host queues it until the run parks, and holds\n // it for this card's caller, the only queue this card may ask it to replay.\n const sendLiveLanes = useCallback(\n ({\n key,\n lanes,\n epoch,\n extras,\n }: {\n key: string;\n lanes: Readonly<Record<string, StatewireThread.InputResponse>>;\n epoch: number;\n extras?: ResumeExtras;\n }) => {\n const sentLaneIds = key.split('|');\n setLiveSentKey(key);\n Promise.resolve(sendLaneDecisions(lanes, extras)).then(\n () => {\n if (epoch !== approvalEpochRef.current) return;\n for (const id of sentLaneIds) sentLaneIdsRef.current.add(id);\n },\n (error: unknown) => {\n if (epoch !== approvalEpochRef.current) return;\n setLiveSentKey((current) => (current === key ? undefined : current));\n reportResumeRejected(error, sentLaneIds[0] ?? '');\n },\n );\n },\n [sendLaneDecisions, reportResumeRejected],\n );\n\n const decide = useCallback(\n (value: Record<string, string>) => {\n setDecisionFailure(undefined);\n const epoch = approvalEpochRef.current;\n // Several parked lanes (or a live one) answer by interrupt id: a\n // positional `run/input` would resume only the first and re-park the\n // rest. A lone parked lane keeps the positional resume every host\n // already speaks.\n if (positional || undecidedLaneIds === null) {\n if (requestId === undefined) return;\n withDecisionCheck({ kind: 'input', requestId, value }, (extras) => {\n resume(value, extras);\n });\n return;\n }\n const lanes = fanLaneDecision({ interruptIds: undecidedLaneIds, decision: value });\n if (!isLive) {\n if (requestId === undefined) return;\n withDecisionCheck(\n { kind: 'input', requestId, value: { lane_decisions: lanes } },\n (extras) => {\n sendLaneDecisions(lanes, extras);\n },\n );\n return;\n }\n const key = undecidedLaneIds.join('|');\n withDecisionCheck({ kind: 'lanes', laneDecisions: lanes }, (extras) =>\n sendLiveLanes({ key, lanes, epoch, extras }),\n );\n },\n [\n positional,\n undecidedLaneIds,\n isLive,\n requestId,\n resume,\n sendLaneDecisions,\n sendLiveLanes,\n withDecisionCheck,\n ],\n );\n\n const decideEach = useMemo<StatewireApprovalEditorContext['decideEach']>(() => {\n if (actionRequestToolCallIds(actionRequests) === null || !positional) return null;\n return (decision) => {\n setDecisionFailure(undefined);\n const decisions: Record<string, HitlActionDecision> = {};\n for (const request of actionRequests) {\n if (request.toolCallId !== undefined) decisions[request.toolCallId] = decision(request);\n }\n // The edited argument set comes from the wire as JSON; the resume value\n // is that JSON going back.\n const value = hitlResumeActionDecisions(decisions) as StatewireThread.InputResponse;\n if (requestId === undefined) return;\n withDecisionCheck({ kind: 'input', requestId, value }, (extras) => {\n resume(value, extras);\n });\n };\n }, [actionRequests, positional, requestId, resume, withDecisionCheck]);\n\n if (!request && !isLive) {\n if (!abandonedInterrupt || abandonedInterrupt.id === dismissedId) return null;\n return (\n <div\n className={cn(\n 'aui-approval-abandoned flex w-full items-center justify-between gap-3 rounded-xl border border-border bg-muted/40 px-3 py-2 text-muted-foreground text-xs',\n classNames?.abandoned,\n )}\n >\n <p>Approval was cancelled — the run moved on.</p>\n <button\n type=\"button\"\n aria-label=\"Dismiss cancelled approval\"\n onClick={() => setDismissedId(abandonedInterrupt.id)}\n className=\"shrink-0 rounded-md p-1 transition-colors hover:bg-muted hover:text-foreground\"\n >\n <XIcon className=\"size-3.5\" />\n </button>\n </div>\n );\n }\n\n if (handledElsewhere) return null;\n // A live mirror without lane stamps cannot be answered before the run\n // parks; the parked request renders it then.\n if (isLive && laneIds === null) return null;\n\n const message = readInterruptMessage(request ? request.payload : liveHitl, fallbackMessage);\n const toolName = hitl?.context?.tool_name ?? hitl?.context?.tool_id;\n const pendingCount = hitl?.context?.pending_action_count ?? 1;\n const hasDetails = hitl !== null && actionRequests.length > 0;\n const showDetails = hasDetails && (detailsOverride ?? actionRequests.length <= 1);\n const sessionApprovalOffered = hitl !== null && canApproveForSession(actionRequests);\n const laneDecided =\n undecidedLaneIds !== null &&\n laneIds !== null &&\n (undecidedLaneIds.length === 0 || liveSentKey === undecidedLaneIds.join('|'));\n const locked = pending || laneDecided || replaying || confirming;\n\n const editor =\n !readOnly && hitl !== null && renderEditor\n ? renderEditor({\n ...context,\n locked,\n sessionApprovalOffered,\n approve: () => decide(hitlResumeApprove()),\n approveForSession: () => decide(hitlResumeApproveForSession()),\n reject: (reason) => decide(hitlResumeReject(reason)),\n decideEach,\n })\n : undefined;\n const customHeader = renderHeader?.(context);\n\n return (\n <section\n aria-label={hitl ? 'Approval required' : 'Input required'}\n className={cn(\n 'aui-approval-card w-full rounded-2xl border border-border bg-card px-4 py-3 text-foreground shadow-xs',\n classNames?.root,\n )}\n >\n <div className=\"flex items-start gap-3\">\n {customHeader != null ? (\n <div className=\"min-w-0 flex-1\">{customHeader}</div>\n ) : (\n <>\n <ShieldAlertIcon className=\"mt-0.5 size-4 shrink-0 text-muted-foreground\" />\n <div className=\"min-w-0 flex-1\">\n <p className=\"flex items-center gap-2 font-semibold text-sm\">\n <span>{hitl ? 'Approval required' : 'Waiting for input'}</span>\n {hitl && pendingCount > 1 ? (\n <span className=\"shrink-0 rounded-full border border-border bg-muted px-1.5 py-px font-normal text-[11px] text-muted-foreground\">\n {pendingCount} tool calls\n </span>\n ) : null}\n </p>\n <p className=\"pt-1 text-muted-foreground text-sm leading-snug\">\n {hitl && pendingCount === 1 && toolName ? (\n <>\n <span className=\"font-mono text-foreground\">{toolName}</span> requires approval before it runs.\n </>\n ) : (\n message\n )}\n </p>\n </div>\n </>\n )}\n </div>\n {decisionFailure && decisionFailure.epoch === approvalEpochRef.current &&\n (decisionFailure.requestId === requestId || laneIds?.includes(decisionFailure.requestId)) ? (\n <p role=\"alert\" data-testid=\"statewire-approval-error\">{decisionFailure.message}</p>\n ) : null}\n {isLive ? (\n <p className=\"pt-1 text-muted-foreground text-xs\" data-testid=\"statewire-approval-live\">\n {laneDecided\n ? 'Decision sent — it applies as soon as this step pauses.'\n : 'Other work keeps running while you decide.'}\n </p>\n ) : null}\n {hasDetails && editor == null ? (\n <button\n type=\"button\"\n onClick={() => setDetailsOverride(!showDetails)}\n aria-expanded={showDetails}\n className=\"mt-2 flex items-center gap-1 rounded px-1 py-0.5 text-muted-foreground text-xs transition-colors hover:text-foreground\"\n >\n <ChevronDownIcon\n className={cn('size-3 transition-transform', showDetails && 'rotate-180')}\n />\n {showDetails ? 'Hide details' : 'Review details'}\n </button>\n ) : null}\n {/* EVERY pending gated call renders, in order — one decision\n authorizes the whole batch, so nothing may hide behind a host's\n richer cards. All read-only: this runtime resumes through\n `hitl_response_to_decisions`, which has no `tool_args` channel —\n an editable composer would let someone rewrite an email and then\n watch the original go out — unless the host takes over the\n decision too (`renderEditor`), which sends the edit per call. */}\n {editor != null ? (\n <div className={cn('mt-3 flex flex-col gap-2', classNames?.details)}>{editor}</div>\n ) : showDetails ? (\n <div className={cn('mt-2 flex flex-col gap-2', classNames?.details)}>\n {renderDetails ? (\n renderDetails(context)\n ) : (\n <DefaultApprovalDetails actionRequests={actionRequests} />\n )}\n </div>\n ) : null}\n {editor != null ? null : (\n <div className={cn('flex flex-wrap items-center gap-2 pt-3', classNames?.actions)}>\n {readOnly ? (\n <p className=\"text-muted-foreground text-sm\" data-testid=\"statewire-approval-read-only\">\n {readOnlyNotice}\n </p>\n ) : hitl ? (\n <>\n <Button\n size=\"sm\"\n disabled={locked}\n onClick={() => decide(hitlResumeApprove())}\n >\n <CheckIcon />\n Approve\n </Button>\n {sessionApprovalOffered ? (\n <Button\n size=\"sm\"\n variant=\"outline\"\n disabled={locked}\n onClick={() => decide(hitlResumeApproveForSession())}\n data-testid=\"statewire-approval-approve-session\"\n >\n <CheckCheckIcon />\n Approve all for this session\n </Button>\n ) : null}\n <Button\n size=\"sm\"\n variant=\"outline\"\n disabled={locked}\n onClick={() => decide(hitlResumeReject())}\n >\n <XIcon />\n Reject\n </Button>\n </>\n ) : (\n <>\n <p className=\"text-muted-foreground text-sm\" data-testid=\"statewire-approval-non-hitl\">\n {nonHitlNotice}\n </p>\n <Button\n size=\"sm\"\n variant=\"outline\"\n disabled={pending}\n onClick={() => resume(interruptResumeDecline())}\n >\n <XIcon />\n Decline\n </Button>\n </>\n )}\n </div>\n )}\n </section>\n );\n};\n\n/**\n * What the backend resolved about a call before asking (where a Slack write\n * goes and as whom, Slack Connect warnings), above its raw arguments.\n */\nconst ApprovalContextFacts: FC<{ context: PendingApprovalContext }> = ({ context }) => (\n <div className=\"mt-1 space-y-0.5\" data-testid=\"statewire-approval-context\">\n {context.facts.map((fact) => (\n <p key={fact.label}>\n <span className=\"font-semibold\">{fact.label}:</span> {fact.value}\n </p>\n ))}\n {context.warnings.map((warning) => (\n <p\n key={warning.message}\n className={warning.severity === 'info' ? undefined : 'font-semibold'}\n >\n {warning.message}\n </p>\n ))}\n </div>\n);\n\n/** One block per gated call: its name (when the batch has several), its resolved facts, and its arguments as JSON. */\nconst DefaultApprovalDetails: FC<{ actionRequests: PendingActionRequest[] }> = ({\n actionRequests,\n}) => (\n <>\n {actionRequests.map((action, index) => (\n <div\n key={`${action.name}-${index}`}\n className=\"rounded-lg border border-border/60 bg-muted/40 p-2 text-foreground text-xs leading-relaxed\"\n >\n {actionRequests.length > 1 ? (\n <p className=\"font-mono font-semibold\">{action.name}</p>\n ) : null}\n {action.approvalContext ? <ApprovalContextFacts context={action.approvalContext} /> : null}\n {Object.keys(action.args).length > 0 ? (\n <pre className=\"mt-1 max-h-32 overflow-auto whitespace-pre-wrap break-words rounded bg-background p-1.5 font-mono text-[11px]\">\n {JSON.stringify(action.args, null, 2)}\n </pre>\n ) : (\n <p className=\"text-muted-foreground\">No arguments.</p>\n )}\n </div>\n ))}\n </>\n);\n"],"names":["resumeValueApproves","useAuiState","hasStatewireThreadExtras","jsx","useRef","useState","useCallback","statewireRejectionDetailMessage","useStatewireApprovalRequest","useStatewireState","asHitlApproval","interruptMirrorPayload","readInterruptMirror","laneInterruptIds","HITL_PENDING_RESUME_GRACE_MS","useEffect","_a","fanLaneDecision","useMemo","actionRequestToolCallIds","request","hitlResumeActionDecisions","jsxs","cn","XIcon","readInterruptMessage","canApproveForSession","hitlResumeApprove","hitlResumeApproveForSession","hitlResumeReject","Fragment","ShieldAlertIcon","ChevronDownIcon","Button","CheckIcon","CheckCheckIcon","interruptResumeDecline"],"mappings":";;;;;;;;;;;;;AAwHA,SAAS,eAAe,QAA0C;AAChE,MAAI,OAAO,SAAS,QAAS,QAAOA,WAAAA,oBAAoB,OAAO,KAAK;AACpE,QAAM,QAAQ,OAAO,OAAO,OAAO,aAAa;AACh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O,KAAK,OAAO,IAAI,EAAE,SAAS,IACjCA,2BAAAA,IAAC,OAAA,EAAI,WAAU,iHACZ,eAAK,UAAU,OAAO,MAAM,MAAM,CAAC,EAAA,CACtC,IAEAA,+BAAC,KAAA,EAAE,WAAU,yBAAwB,UAAA,gBAAA,CAAa;AAAA,IAAA;AAAA,EAAA;AAAA,EAZ/C,GAAG,OAAO,IAAI,IAAI,KAAK;AAc9B,CACD,GACH;;"}
@@ -1,7 +1,71 @@
1
- import type { StatewireThread } from '@assistant-ui/react-statewire';
1
+ import { type StatewireThread } from '@assistant-ui/react-statewire';
2
2
  import { type HitlActionDecision, type HitlApprovalPayload, type PendingActionRequest } from '../agent-runtime/src/index';
3
3
  import { type FC, type ReactNode } from 'react';
4
4
  import { type StatewireInterruptPredicate } from './use-statewire-approval-request';
5
+ /**
6
+ * Human-in-the-loop approval card for the statewire transport — the one
7
+ * approval UI every Athena chat surface mounts (the SDK's `AthenaChat`, the
8
+ * Chrome side panel, the Office task pane, Olympus).
9
+ *
10
+ * When the deep-agent runtime hits an approval-gated tool call, the backend
11
+ * parks the run on an `interrupt` input request. This card reads that request
12
+ * through `useStatewireApprovalRequest` and answers it with
13
+ * `{ type: 'run/input', requestId, response: { type: 'resume', value } }` —
14
+ * the exact command the backend's resume path consumes. Without an answer the
15
+ * run stays parked forever, so this card must be mounted on every statewire
16
+ * chat surface. On legacy (non-statewire) threads it renders nothing.
17
+ *
18
+ * A gated call raised inside a delegated subagent parks only its lane: the
19
+ * host mirrors that interrupt while the sibling lanes keep streaming, before
20
+ * any input request exists. The card renders the mirrored payload the same
21
+ * way and answers it with `run/lane-input` keyed by the lane's langgraph
22
+ * interrupt id (`laneInterruptIds`); the host queues the decision and applies
23
+ * it the moment the run parks, so the approver never waits on the siblings.
24
+ * Once parked, a payload whose calls all carry interrupt ids resumes as a
25
+ * `lane_decisions` map too — one positional `run/input` can only answer the
26
+ * first of several parked lanes.
27
+ *
28
+ * Recovery of a queued decision the host never applies is ordered host
29
+ * first: the host's answerer resumes the park or drops (and flushes) the
30
+ * queue within `QUEUED_LANE_ANSWER_BUDGET_SECONDS` of the park, and this
31
+ * card's grace (`HITL_PENDING_RESUME_GRACE_MS`, longer than that budget)
32
+ * fires only when the host stayed silent. When it fires, the card that sent
33
+ * the queued decision asks the host to replay it (`run/lane-replay` — the
34
+ * host resumes as the approver, under the meta it recorded, and refuses any
35
+ * other caller); every other card, and a replay the host refuses, hands the
36
+ * decision back to a person by unlocking the actions. A queued decision is
37
+ * never re-sent as a `run/input` of the viewing client's own: that would run
38
+ * the approver's decision under the viewer's identity and configuration.
39
+ *
40
+ * Host-specific review UIs (subagent cards, email summaries) slot in through
41
+ * `renderDetails`; a host composer that must also OWN the decision (an
42
+ * editable email whose edits have to reach the backend) takes over the
43
+ * details and the decision row through `renderEditor`; requests another
44
+ * surface answers (typed interrupt families, per-lane subagent approvals)
45
+ * stand down through `isHandledElsewhere`; viewers without edit rights see
46
+ * `readOnlyNotice`.
47
+ */
48
+ /**
49
+ * The answer a passkey decision check confirms before the card sends it
50
+ * (identity 0b.9): a `run/input` resume of the parked request, or the lane
51
+ * decisions of a `run/lane-input` sent while sibling lanes still stream.
52
+ */
53
+ export type StatewireDecisionAnswer = {
54
+ readonly kind: 'input';
55
+ readonly requestId: string;
56
+ readonly value: StatewireThread.InputResponse;
57
+ } | {
58
+ readonly kind: 'lanes';
59
+ readonly laneDecisions: Readonly<Record<string, StatewireThread.InputResponse>>;
60
+ };
61
+ /**
62
+ * Runs the host's passkey check for an approving answer and resolves its
63
+ * token, or `undefined` to send the answer without one. While checks are
64
+ * report-only, an answer goes ahead without a check (no passkey yet, a
65
+ * cancelled prompt); the host decides what to tell the person. Never called
66
+ * for an answer that only rejects.
67
+ */
68
+ export type StatewireDecisionConfirmer = (answer: StatewireDecisionAnswer) => Promise<string | undefined>;
5
69
  /** The pending request a host slot renders or judges. */
6
70
  export interface StatewireApprovalRequestContext {
7
71
  /** The parked input request — `undefined` while the run still streams (a live lane approval). */
@@ -99,5 +163,13 @@ export interface StatewireApprovalCardProps {
99
163
  * re-enabled; this is where a host tells the user why (a toast, a log line).
100
164
  */
101
165
  onResumeRejected?: (error: unknown, requestId: string) => void;
166
+ /**
167
+ * The host's passkey decision check (identity 0b.9). An answer that lets
168
+ * anything run is handed to it first and sent with the token it resolves
169
+ * as `decisionCheck`; the decision buttons stay locked while it runs. An
170
+ * answer that only rejects never is. Omit it and every answer is sent as
171
+ * before, with no check.
172
+ */
173
+ confirmDecision?: StatewireDecisionConfirmer;
102
174
  }
103
175
  export declare const StatewireApprovalCard: FC<StatewireApprovalCardProps>;