@athenaintel/react 0.57.2 → 0.60.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (852) hide show
  1. package/README.md +795 -12
  2. package/dist/agent-runtime/src/addressed-agents.cjs +16 -0
  3. package/dist/agent-runtime/src/addressed-agents.cjs.map +1 -0
  4. package/dist/agent-runtime/src/addressed-agents.d.ts +30 -0
  5. package/dist/agent-runtime/src/addressed-agents.js +16 -0
  6. package/dist/agent-runtime/src/addressed-agents.js.map +1 -0
  7. package/dist/agent-runtime/src/answer-label.cjs +4 -3
  8. package/dist/agent-runtime/src/answer-label.cjs.map +1 -1
  9. package/dist/agent-runtime/src/answer-label.d.ts +13 -6
  10. package/dist/agent-runtime/src/answer-label.js +4 -3
  11. package/dist/agent-runtime/src/answer-label.js.map +1 -1
  12. package/dist/agent-runtime/src/chat-outbox-attachments.cjs.map +1 -1
  13. package/dist/agent-runtime/src/chat-outbox-attachments.d.ts +1 -1
  14. package/dist/agent-runtime/src/chat-outbox-attachments.js.map +1 -1
  15. package/dist/agent-runtime/src/chat-outbox-entry.cjs +101 -0
  16. package/dist/agent-runtime/src/chat-outbox-entry.cjs.map +1 -0
  17. package/dist/agent-runtime/src/chat-outbox-entry.d.ts +99 -0
  18. package/dist/agent-runtime/src/chat-outbox-entry.js +101 -0
  19. package/dist/agent-runtime/src/chat-outbox-entry.js.map +1 -0
  20. package/dist/agent-runtime/src/chat-outbox-legacy.cjs +252 -0
  21. package/dist/agent-runtime/src/chat-outbox-legacy.cjs.map +1 -0
  22. package/dist/agent-runtime/src/chat-outbox-legacy.d.ts +96 -0
  23. package/dist/agent-runtime/src/chat-outbox-legacy.js +252 -0
  24. package/dist/agent-runtime/src/chat-outbox-legacy.js.map +1 -0
  25. package/dist/agent-runtime/src/chat-outbox-policy.cjs +30 -0
  26. package/dist/agent-runtime/src/chat-outbox-policy.cjs.map +1 -0
  27. package/dist/agent-runtime/src/chat-outbox-policy.d.ts +42 -0
  28. package/dist/agent-runtime/src/chat-outbox-policy.js +30 -0
  29. package/dist/agent-runtime/src/chat-outbox-policy.js.map +1 -0
  30. package/dist/agent-runtime/src/chat-outbox-storage.cjs +306 -0
  31. package/dist/agent-runtime/src/chat-outbox-storage.cjs.map +1 -0
  32. package/dist/agent-runtime/src/chat-outbox-storage.d.ts +194 -0
  33. package/dist/agent-runtime/src/chat-outbox-storage.js +306 -0
  34. package/dist/agent-runtime/src/chat-outbox-storage.js.map +1 -0
  35. package/dist/agent-runtime/src/chat-outbox-thread.cjs +21 -94
  36. package/dist/agent-runtime/src/chat-outbox-thread.cjs.map +1 -1
  37. package/dist/agent-runtime/src/chat-outbox-thread.d.ts +22 -18
  38. package/dist/agent-runtime/src/chat-outbox-thread.js +21 -94
  39. package/dist/agent-runtime/src/chat-outbox-thread.js.map +1 -1
  40. package/dist/agent-runtime/src/chat-outbox.cjs +492 -547
  41. package/dist/agent-runtime/src/chat-outbox.cjs.map +1 -1
  42. package/dist/agent-runtime/src/chat-outbox.d.ts +110 -142
  43. package/dist/agent-runtime/src/chat-outbox.js +492 -547
  44. package/dist/agent-runtime/src/chat-outbox.js.map +1 -1
  45. package/dist/agent-runtime/src/composer-markdown.cjs +0 -16
  46. package/dist/agent-runtime/src/composer-markdown.cjs.map +1 -1
  47. package/dist/agent-runtime/src/composer-markdown.d.ts +1 -1
  48. package/dist/agent-runtime/src/composer-markdown.js +1 -17
  49. package/dist/agent-runtime/src/composer-markdown.js.map +1 -1
  50. package/dist/agent-runtime/src/deep-agent-transport-recipe.cjs +3 -1
  51. package/dist/agent-runtime/src/deep-agent-transport-recipe.cjs.map +1 -1
  52. package/dist/agent-runtime/src/deep-agent-transport-recipe.d.ts +8 -1
  53. package/dist/agent-runtime/src/deep-agent-transport-recipe.js +3 -1
  54. package/dist/agent-runtime/src/deep-agent-transport-recipe.js.map +1 -1
  55. package/dist/agent-runtime/src/dictation-preferences.d.ts +356 -0
  56. package/dist/agent-runtime/src/dictation-record.d.ts +279 -0
  57. package/dist/agent-runtime/src/dictation-session.d.ts +106 -7
  58. package/dist/agent-runtime/src/dictation-snippets.d.ts +9 -0
  59. package/dist/agent-runtime/src/dictation-transfer.d.ts +142 -0
  60. package/dist/agent-runtime/src/edit-command.cjs.map +1 -1
  61. package/dist/agent-runtime/src/edit-command.d.ts +1 -1
  62. package/dist/agent-runtime/src/edit-command.js.map +1 -1
  63. package/dist/agent-runtime/src/errors.cjs +1 -0
  64. package/dist/agent-runtime/src/errors.cjs.map +1 -1
  65. package/dist/agent-runtime/src/errors.js +1 -0
  66. package/dist/agent-runtime/src/errors.js.map +1 -1
  67. package/dist/agent-runtime/src/generated/runconfig-contract.cjs +24 -0
  68. package/dist/agent-runtime/src/generated/runconfig-contract.cjs.map +1 -1
  69. package/dist/agent-runtime/src/generated/runconfig-contract.d.ts +3 -3
  70. package/dist/agent-runtime/src/generated/runconfig-contract.js +24 -0
  71. package/dist/agent-runtime/src/generated/runconfig-contract.js.map +1 -1
  72. package/dist/agent-runtime/src/index.d.ts +14 -8
  73. package/dist/agent-runtime/src/lane-follow.cjs +289 -0
  74. package/dist/agent-runtime/src/lane-follow.cjs.map +1 -0
  75. package/dist/agent-runtime/src/lane-follow.js +289 -0
  76. package/dist/agent-runtime/src/lane-follow.js.map +1 -0
  77. package/dist/agent-runtime/src/lane-images.cjs +387 -0
  78. package/dist/agent-runtime/src/lane-images.cjs.map +1 -0
  79. package/dist/agent-runtime/src/lane-images.js +387 -0
  80. package/dist/agent-runtime/src/lane-images.js.map +1 -0
  81. package/dist/agent-runtime/src/message-window.js +1 -1
  82. package/dist/agent-runtime/src/messages.cjs +19 -1
  83. package/dist/agent-runtime/src/messages.cjs.map +1 -1
  84. package/dist/agent-runtime/src/messages.d.ts +8 -0
  85. package/dist/agent-runtime/src/messages.js +21 -3
  86. package/dist/agent-runtime/src/messages.js.map +1 -1
  87. package/dist/agent-runtime/src/named-agents.cjs +301 -0
  88. package/dist/agent-runtime/src/named-agents.cjs.map +1 -0
  89. package/dist/agent-runtime/src/named-agents.d.ts +246 -0
  90. package/dist/agent-runtime/src/named-agents.js +301 -0
  91. package/dist/agent-runtime/src/named-agents.js.map +1 -0
  92. package/dist/agent-runtime/src/offline-status.cjs.map +1 -1
  93. package/dist/agent-runtime/src/offline-status.d.ts +93 -2
  94. package/dist/agent-runtime/src/offline-status.js.map +1 -1
  95. package/dist/agent-runtime/src/ptc-subcalls.cjs +41 -0
  96. package/dist/agent-runtime/src/ptc-subcalls.cjs.map +1 -0
  97. package/dist/agent-runtime/src/ptc-subcalls.js +41 -0
  98. package/dist/agent-runtime/src/ptc-subcalls.js.map +1 -0
  99. package/dist/agent-runtime/src/queue.cjs +2 -2
  100. package/dist/agent-runtime/src/queue.cjs.map +1 -1
  101. package/dist/agent-runtime/src/queue.d.ts +20 -25
  102. package/dist/agent-runtime/src/queue.js +2 -2
  103. package/dist/agent-runtime/src/queue.js.map +1 -1
  104. package/dist/agent-runtime/src/quota-safe-local-storage-session.cjs +314 -84
  105. package/dist/agent-runtime/src/quota-safe-local-storage-session.cjs.map +1 -1
  106. package/dist/agent-runtime/src/quota-safe-local-storage-session.d.ts +137 -40
  107. package/dist/agent-runtime/src/quota-safe-local-storage-session.js +318 -88
  108. package/dist/agent-runtime/src/quota-safe-local-storage-session.js.map +1 -1
  109. package/dist/agent-runtime/src/run-send.cjs +54 -0
  110. package/dist/agent-runtime/src/run-send.cjs.map +1 -0
  111. package/dist/agent-runtime/src/run-send.d.ts +51 -0
  112. package/dist/agent-runtime/src/run-send.js +54 -0
  113. package/dist/agent-runtime/src/run-send.js.map +1 -0
  114. package/dist/agent-runtime/src/running-tool-placeholder.cjs +6 -0
  115. package/dist/agent-runtime/src/running-tool-placeholder.cjs.map +1 -1
  116. package/dist/agent-runtime/src/running-tool-placeholder.js +6 -0
  117. package/dist/agent-runtime/src/running-tool-placeholder.js.map +1 -1
  118. package/dist/agent-runtime/src/runtime.d.ts +9 -5
  119. package/dist/agent-runtime/src/sealed-idb.cjs +64 -0
  120. package/dist/agent-runtime/src/sealed-idb.cjs.map +1 -1
  121. package/dist/agent-runtime/src/sealed-idb.d.ts +16 -0
  122. package/dist/agent-runtime/src/sealed-idb.js +64 -0
  123. package/dist/agent-runtime/src/sealed-idb.js.map +1 -1
  124. package/dist/agent-runtime/src/send-recovery.cjs +90 -118
  125. package/dist/agent-runtime/src/send-recovery.cjs.map +1 -1
  126. package/dist/agent-runtime/src/send-recovery.d.ts +25 -29
  127. package/dist/agent-runtime/src/send-recovery.js +90 -118
  128. package/dist/agent-runtime/src/send-recovery.js.map +1 -1
  129. package/dist/agent-runtime/src/statewire-diagnostics.d.ts +4 -1
  130. package/dist/agent-runtime/src/statewire-held-sends.cjs +191 -0
  131. package/dist/agent-runtime/src/statewire-held-sends.cjs.map +1 -0
  132. package/dist/agent-runtime/src/statewire-held-sends.d.ts +119 -0
  133. package/dist/agent-runtime/src/statewire-held-sends.js +191 -0
  134. package/dist/agent-runtime/src/statewire-held-sends.js.map +1 -0
  135. package/dist/agent-runtime/src/statewire-state.cjs +4 -0
  136. package/dist/agent-runtime/src/statewire-state.cjs.map +1 -1
  137. package/dist/agent-runtime/src/statewire-state.js +4 -0
  138. package/dist/agent-runtime/src/statewire-state.js.map +1 -1
  139. package/dist/agent-runtime/src/statewire-transport.cjs +8 -2
  140. package/dist/agent-runtime/src/statewire-transport.cjs.map +1 -1
  141. package/dist/agent-runtime/src/statewire-transport.d.ts +14 -5
  142. package/dist/agent-runtime/src/statewire-transport.js +8 -2
  143. package/dist/agent-runtime/src/statewire-transport.js.map +1 -1
  144. package/dist/agent-runtime/src/subagent-transcripts.cjs +1 -23
  145. package/dist/agent-runtime/src/subagent-transcripts.cjs.map +1 -1
  146. package/dist/agent-runtime/src/subagent-transcripts.js +3 -25
  147. package/dist/agent-runtime/src/subagent-transcripts.js.map +1 -1
  148. package/dist/agent-runtime/src/subagents.cjs +22 -29
  149. package/dist/agent-runtime/src/subagents.cjs.map +1 -1
  150. package/dist/agent-runtime/src/subagents.js +23 -30
  151. package/dist/agent-runtime/src/subagents.js.map +1 -1
  152. package/dist/agent-runtime/src/thread-extras.cjs +27 -19
  153. package/dist/agent-runtime/src/thread-extras.cjs.map +1 -1
  154. package/dist/agent-runtime/src/thread-extras.d.ts +19 -6
  155. package/dist/agent-runtime/src/thread-extras.js +27 -19
  156. package/dist/agent-runtime/src/thread-extras.js.map +1 -1
  157. package/dist/agent-runtime/src/thread-handoff-flow-machine.d.ts +8 -8
  158. package/dist/agent-runtime/src/tool-metadata.cjs +19 -0
  159. package/dist/agent-runtime/src/tool-metadata.cjs.map +1 -1
  160. package/dist/agent-runtime/src/tool-metadata.js +19 -0
  161. package/dist/agent-runtime/src/tool-metadata.js.map +1 -1
  162. package/dist/agent-runtime/src/tool-names.cjs +21 -0
  163. package/dist/agent-runtime/src/tool-names.cjs.map +1 -1
  164. package/dist/agent-runtime/src/tool-names.d.ts +8 -0
  165. package/dist/agent-runtime/src/tool-names.js +21 -0
  166. package/dist/agent-runtime/src/tool-names.js.map +1 -1
  167. package/dist/agent-runtime/src/typed-interrupt-kinds.cjs +247 -0
  168. package/dist/agent-runtime/src/typed-interrupt-kinds.cjs.map +1 -0
  169. package/dist/agent-runtime/src/typed-interrupt-kinds.d.ts +173 -0
  170. package/dist/agent-runtime/src/typed-interrupt-kinds.js +247 -0
  171. package/dist/agent-runtime/src/typed-interrupt-kinds.js.map +1 -0
  172. package/dist/agent-runtime/src/typed-interrupts.cjs +48 -0
  173. package/dist/agent-runtime/src/typed-interrupts.cjs.map +1 -0
  174. package/dist/agent-runtime/src/typed-interrupts.d.ts +75 -0
  175. package/dist/agent-runtime/src/typed-interrupts.js +48 -0
  176. package/dist/agent-runtime/src/typed-interrupts.js.map +1 -0
  177. package/dist/agent-runtime/src/types.d.ts +1 -1
  178. package/dist/agent-runtime/src/use-conversation-list.cjs +1 -0
  179. package/dist/agent-runtime/src/use-conversation-list.cjs.map +1 -1
  180. package/dist/agent-runtime/src/use-conversation-list.d.ts +7 -0
  181. package/dist/agent-runtime/src/use-conversation-list.js +1 -0
  182. package/dist/agent-runtime/src/use-conversation-list.js.map +1 -1
  183. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.cjs +46 -29
  184. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.cjs.map +1 -1
  185. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.d.ts +14 -22
  186. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.js +46 -29
  187. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.js.map +1 -1
  188. package/dist/agent-runtime/src/use-deep-agent-runtime.cjs +78 -14
  189. package/dist/agent-runtime/src/use-deep-agent-runtime.cjs.map +1 -1
  190. package/dist/agent-runtime/src/use-deep-agent-runtime.d.ts +34 -7
  191. package/dist/agent-runtime/src/use-deep-agent-runtime.js +79 -15
  192. package/dist/agent-runtime/src/use-deep-agent-runtime.js.map +1 -1
  193. package/dist/agent-runtime/src/use-deep-agent-thread.cjs +16 -1
  194. package/dist/agent-runtime/src/use-deep-agent-thread.cjs.map +1 -1
  195. package/dist/agent-runtime/src/use-deep-agent-thread.d.ts +7 -2
  196. package/dist/agent-runtime/src/use-deep-agent-thread.js +16 -1
  197. package/dist/agent-runtime/src/use-deep-agent-thread.js.map +1 -1
  198. package/dist/agent-runtime/src/use-deep-agent-voice.cjs +30 -4
  199. package/dist/agent-runtime/src/use-deep-agent-voice.cjs.map +1 -1
  200. package/dist/agent-runtime/src/use-deep-agent-voice.d.ts +22 -4
  201. package/dist/agent-runtime/src/use-deep-agent-voice.js +30 -4
  202. package/dist/agent-runtime/src/use-deep-agent-voice.js.map +1 -1
  203. package/dist/agent-runtime/src/withdrawn-turns.d.ts +5 -4
  204. package/dist/agent-runtime/src/word-device-fit.d.ts +174 -0
  205. package/dist/agent-runtime/src/work-in.d.ts +127 -0
  206. package/dist/assets/AthenaAssetEmbed.cjs.map +1 -1
  207. package/dist/assets/AthenaAssetEmbed.d.ts +6 -1
  208. package/dist/assets/AthenaAssetEmbed.js.map +1 -1
  209. package/dist/assets/asset-panel-store.cjs +13 -5
  210. package/dist/assets/asset-panel-store.cjs.map +1 -1
  211. package/dist/assets/asset-panel-store.d.ts +33 -2
  212. package/dist/assets/asset-panel-store.js +13 -5
  213. package/dist/assets/asset-panel-store.js.map +1 -1
  214. package/dist/auth/AthenaCredentialSourceContext.cjs +11 -0
  215. package/dist/auth/AthenaCredentialSourceContext.cjs.map +1 -1
  216. package/dist/auth/AthenaCredentialSourceContext.d.ts +6 -0
  217. package/dist/auth/AthenaCredentialSourceContext.js +11 -0
  218. package/dist/auth/AthenaCredentialSourceContext.js.map +1 -1
  219. package/dist/auth/account-identity.cjs +13 -2
  220. package/dist/auth/account-identity.cjs.map +1 -1
  221. package/dist/auth/account-identity.d.ts +9 -0
  222. package/dist/auth/account-identity.js +13 -2
  223. package/dist/auth/account-identity.js.map +1 -1
  224. package/dist/auth/credential-source.cjs +20 -4
  225. package/dist/auth/credential-source.cjs.map +1 -1
  226. package/dist/auth/credential-source.d.ts +9 -0
  227. package/dist/auth/credential-source.js +20 -4
  228. package/dist/auth/credential-source.js.map +1 -1
  229. package/dist/catalog/chat-pickers.cjs +31 -0
  230. package/dist/catalog/chat-pickers.cjs.map +1 -1
  231. package/dist/catalog/chat-pickers.d.ts +17 -0
  232. package/dist/catalog/chat-pickers.js +33 -2
  233. package/dist/catalog/chat-pickers.js.map +1 -1
  234. package/dist/catalog/runtime-catalog.cjs +63 -3
  235. package/dist/catalog/runtime-catalog.cjs.map +1 -1
  236. package/dist/catalog/runtime-catalog.d.ts +63 -3
  237. package/dist/catalog/runtime-catalog.js +64 -4
  238. package/dist/catalog/runtime-catalog.js.map +1 -1
  239. package/dist/chat/AthenaChat.cjs +301 -98
  240. package/dist/chat/AthenaChat.cjs.map +1 -1
  241. package/dist/chat/AthenaChat.d.ts +80 -4
  242. package/dist/chat/AthenaChat.js +302 -99
  243. package/dist/chat/AthenaChat.js.map +1 -1
  244. package/dist/chat/StatewireApprovalCard.cjs +35 -5
  245. package/dist/chat/StatewireApprovalCard.cjs.map +1 -1
  246. package/dist/chat/StatewireApprovalCard.d.ts +55 -2
  247. package/dist/chat/StatewireApprovalCard.js +37 -7
  248. package/dist/chat/StatewireApprovalCard.js.map +1 -1
  249. package/dist/chat/StatewireQueuedMessages.cjs +17 -2
  250. package/dist/chat/StatewireQueuedMessages.cjs.map +1 -1
  251. package/dist/chat/StatewireQueuedMessages.d.ts +8 -45
  252. package/dist/chat/StatewireQueuedMessages.js +18 -3
  253. package/dist/chat/StatewireQueuedMessages.js.map +1 -1
  254. package/dist/chat/chat-agent-mentions.cjs +70 -0
  255. package/dist/chat/chat-agent-mentions.cjs.map +1 -0
  256. package/dist/chat/chat-agent-mentions.d.ts +13 -0
  257. package/dist/chat/chat-agent-mentions.js +70 -0
  258. package/dist/chat/chat-agent-mentions.js.map +1 -0
  259. package/dist/chat/composer-actions.cjs +12 -0
  260. package/dist/chat/composer-actions.cjs.map +1 -0
  261. package/dist/chat/composer-actions.d.ts +22 -0
  262. package/dist/chat/composer-actions.js +12 -0
  263. package/dist/chat/composer-actions.js.map +1 -0
  264. package/dist/chat/follow-up-suggestions.cjs +185 -0
  265. package/dist/chat/follow-up-suggestions.cjs.map +1 -0
  266. package/dist/chat/follow-up-suggestions.d.ts +64 -0
  267. package/dist/chat/follow-up-suggestions.js +185 -0
  268. package/dist/chat/follow-up-suggestions.js.map +1 -0
  269. package/dist/chat/super-grouping/ToolTimeline.cjs +4 -3
  270. package/dist/chat/super-grouping/ToolTimeline.cjs.map +1 -1
  271. package/dist/chat/super-grouping/ToolTimeline.d.ts +7 -3
  272. package/dist/chat/super-grouping/ToolTimeline.js +4 -3
  273. package/dist/chat/super-grouping/ToolTimeline.js.map +1 -1
  274. package/dist/chat/turn-changes.cjs +284 -0
  275. package/dist/chat/turn-changes.cjs.map +1 -0
  276. package/dist/chat/turn-changes.d.ts +130 -0
  277. package/dist/chat/turn-changes.js +284 -0
  278. package/dist/chat/turn-changes.js.map +1 -0
  279. package/dist/chat/typed-interrupts/StatewireTypedInterruptCard.cjs +31 -0
  280. package/dist/chat/typed-interrupts/StatewireTypedInterruptCard.cjs.map +1 -0
  281. package/dist/chat/typed-interrupts/StatewireTypedInterruptCard.d.ts +31 -0
  282. package/dist/chat/typed-interrupts/StatewireTypedInterruptCard.js +31 -0
  283. package/dist/chat/typed-interrupts/StatewireTypedInterruptCard.js.map +1 -0
  284. package/dist/chat/typed-interrupts/approval-cards.cjs +250 -0
  285. package/dist/chat/typed-interrupts/approval-cards.cjs.map +1 -0
  286. package/dist/chat/typed-interrupts/approval-cards.d.ts +22 -0
  287. package/dist/chat/typed-interrupts/approval-cards.js +250 -0
  288. package/dist/chat/typed-interrupts/approval-cards.js.map +1 -0
  289. package/dist/chat/typed-interrupts/form-cards.cjs +289 -0
  290. package/dist/chat/typed-interrupts/form-cards.cjs.map +1 -0
  291. package/dist/chat/typed-interrupts/form-cards.d.ts +6 -0
  292. package/dist/chat/typed-interrupts/form-cards.js +289 -0
  293. package/dist/chat/typed-interrupts/form-cards.js.map +1 -0
  294. package/dist/chat/typed-interrupts/interrupt-card-shell.cjs +182 -0
  295. package/dist/chat/typed-interrupts/interrupt-card-shell.cjs.map +1 -0
  296. package/dist/chat/typed-interrupts/interrupt-card-shell.d.ts +47 -0
  297. package/dist/chat/typed-interrupts/interrupt-card-shell.js +182 -0
  298. package/dist/chat/typed-interrupts/interrupt-card-shell.js.map +1 -0
  299. package/dist/chat/typed-interrupts/json-schema-form.cjs +388 -0
  300. package/dist/chat/typed-interrupts/json-schema-form.cjs.map +1 -0
  301. package/dist/chat/typed-interrupts/json-schema-form.d.ts +33 -0
  302. package/dist/chat/typed-interrupts/json-schema-form.js +388 -0
  303. package/dist/chat/typed-interrupts/json-schema-form.js.map +1 -0
  304. package/dist/chat/typed-interrupts/questionnaire-card.cjs +449 -0
  305. package/dist/chat/typed-interrupts/questionnaire-card.cjs.map +1 -0
  306. package/dist/chat/typed-interrupts/questionnaire-card.d.ts +20 -0
  307. package/dist/chat/typed-interrupts/questionnaire-card.js +449 -0
  308. package/dist/chat/typed-interrupts/questionnaire-card.js.map +1 -0
  309. package/dist/chat/typed-interrupts/request-file-card.cjs +159 -0
  310. package/dist/chat/typed-interrupts/request-file-card.cjs.map +1 -0
  311. package/dist/chat/typed-interrupts/request-file-card.d.ts +2 -0
  312. package/dist/chat/typed-interrupts/request-file-card.js +159 -0
  313. package/dist/chat/typed-interrupts/request-file-card.js.map +1 -0
  314. package/dist/chat/typed-interrupts/toolkit-selection-card.cjs +189 -0
  315. package/dist/chat/typed-interrupts/toolkit-selection-card.cjs.map +1 -0
  316. package/dist/chat/typed-interrupts/toolkit-selection-card.d.ts +23 -0
  317. package/dist/chat/typed-interrupts/toolkit-selection-card.js +189 -0
  318. package/dist/chat/typed-interrupts/toolkit-selection-card.js.map +1 -0
  319. package/dist/chat/typed-interrupts/typed-interrupt-body.cjs +26 -0
  320. package/dist/chat/typed-interrupts/typed-interrupt-body.cjs.map +1 -0
  321. package/dist/chat/typed-interrupts/typed-interrupt-body.d.ts +3 -0
  322. package/dist/chat/typed-interrupts/typed-interrupt-body.js +26 -0
  323. package/dist/chat/typed-interrupts/typed-interrupt-body.js.map +1 -0
  324. package/dist/chat/typed-interrupts/typed-interrupt-graphql.cjs +105 -0
  325. package/dist/chat/typed-interrupts/typed-interrupt-graphql.cjs.map +1 -0
  326. package/dist/chat/typed-interrupts/typed-interrupt-graphql.d.ts +29 -0
  327. package/dist/chat/typed-interrupts/typed-interrupt-graphql.js +105 -0
  328. package/dist/chat/typed-interrupts/typed-interrupt-graphql.js.map +1 -0
  329. package/dist/chat/typed-interrupts/typed-interrupt-notice.cjs +70 -0
  330. package/dist/chat/typed-interrupts/typed-interrupt-notice.cjs.map +1 -0
  331. package/dist/chat/typed-interrupts/typed-interrupt-notice.d.ts +45 -0
  332. package/dist/chat/typed-interrupts/typed-interrupt-notice.js +70 -0
  333. package/dist/chat/typed-interrupts/typed-interrupt-notice.js.map +1 -0
  334. package/dist/chat/typed-interrupts/typed-interrupt-panel.cjs +76 -0
  335. package/dist/chat/typed-interrupts/typed-interrupt-panel.cjs.map +1 -0
  336. package/dist/chat/typed-interrupts/typed-interrupt-panel.d.ts +11 -0
  337. package/dist/chat/typed-interrupts/typed-interrupt-panel.js +76 -0
  338. package/dist/chat/typed-interrupts/typed-interrupt-panel.js.map +1 -0
  339. package/dist/chat/typed-interrupts/typed-interrupt-types.d.ts +46 -0
  340. package/dist/chat/typed-interrupts/use-interrupt-draft.cjs +106 -0
  341. package/dist/chat/typed-interrupts/use-interrupt-draft.cjs.map +1 -0
  342. package/dist/chat/typed-interrupts/use-interrupt-draft.d.ts +29 -0
  343. package/dist/chat/typed-interrupts/use-interrupt-draft.js +106 -0
  344. package/dist/chat/typed-interrupts/use-interrupt-draft.js.map +1 -0
  345. package/dist/chat/typed-interrupts/use-statewire-typed-interrupt.cjs +231 -0
  346. package/dist/chat/typed-interrupts/use-statewire-typed-interrupt.cjs.map +1 -0
  347. package/dist/chat/typed-interrupts/use-statewire-typed-interrupt.d.ts +66 -0
  348. package/dist/chat/typed-interrupts/use-statewire-typed-interrupt.js +231 -0
  349. package/dist/chat/typed-interrupts/use-statewire-typed-interrupt.js.map +1 -0
  350. package/dist/chat-ui/composer/composer-named-agents.cjs +13 -0
  351. package/dist/chat-ui/composer/composer-named-agents.cjs.map +1 -0
  352. package/dist/chat-ui/composer/composer-named-agents.d.ts +20 -0
  353. package/dist/chat-ui/composer/composer-named-agents.js +13 -0
  354. package/dist/chat-ui/composer/composer-named-agents.js.map +1 -0
  355. package/dist/chat-ui/composer/slash-command-menu.cjs +143 -0
  356. package/dist/chat-ui/composer/slash-command-menu.cjs.map +1 -0
  357. package/dist/chat-ui/composer/slash-command-menu.d.ts +19 -0
  358. package/dist/chat-ui/composer/slash-command-menu.js +143 -0
  359. package/dist/chat-ui/composer/slash-command-menu.js.map +1 -0
  360. package/dist/chat-ui/composer/slash-commands-extension.cjs +51 -0
  361. package/dist/chat-ui/composer/slash-commands-extension.cjs.map +1 -0
  362. package/dist/chat-ui/composer/slash-commands-extension.d.ts +39 -0
  363. package/dist/chat-ui/composer/slash-commands-extension.js +51 -0
  364. package/dist/chat-ui/composer/slash-commands-extension.js.map +1 -0
  365. package/dist/chat-ui/composer/slash-commands.cjs +74 -0
  366. package/dist/chat-ui/composer/slash-commands.cjs.map +1 -0
  367. package/dist/chat-ui/composer/slash-commands.d.ts +82 -0
  368. package/dist/chat-ui/composer/slash-commands.js +74 -0
  369. package/dist/chat-ui/composer/slash-commands.js.map +1 -0
  370. package/dist/chat-ui/composer/tiptap-composer.cjs +135 -9
  371. package/dist/chat-ui/composer/tiptap-composer.cjs.map +1 -1
  372. package/dist/chat-ui/composer/tiptap-composer.d.ts +61 -2
  373. package/dist/chat-ui/composer/tiptap-composer.js +135 -9
  374. package/dist/chat-ui/composer/tiptap-composer.js.map +1 -1
  375. package/dist/chat-ui/index.cjs +5 -0
  376. package/dist/chat-ui/index.cjs.map +1 -1
  377. package/dist/chat-ui/index.d.ts +4 -2
  378. package/dist/chat-ui/index.js +5 -0
  379. package/dist/chat-ui/index.js.map +1 -1
  380. package/dist/chat-ui/mentions/mention-chip.cjs +10 -4
  381. package/dist/chat-ui/mentions/mention-chip.cjs.map +1 -1
  382. package/dist/chat-ui/mentions/mention-chip.js +11 -5
  383. package/dist/chat-ui/mentions/mention-chip.js.map +1 -1
  384. package/dist/chat-ui/mentions/mention-extension.cjs +8 -1
  385. package/dist/chat-ui/mentions/mention-extension.cjs.map +1 -1
  386. package/dist/chat-ui/mentions/mention-extension.js +8 -1
  387. package/dist/chat-ui/mentions/mention-extension.js.map +1 -1
  388. package/dist/chat-ui/mentions/suggestions/components/get-scope-name.cjs +1 -0
  389. package/dist/chat-ui/mentions/suggestions/components/get-scope-name.cjs.map +1 -1
  390. package/dist/chat-ui/mentions/suggestions/components/get-scope-name.js +1 -0
  391. package/dist/chat-ui/mentions/suggestions/components/get-scope-name.js.map +1 -1
  392. package/dist/chat-ui/mentions/suggestions/components/mention-icon.cjs +20 -2
  393. package/dist/chat-ui/mentions/suggestions/components/mention-icon.cjs.map +1 -1
  394. package/dist/chat-ui/mentions/suggestions/components/mention-icon.d.ts +10 -1
  395. package/dist/chat-ui/mentions/suggestions/components/mention-icon.js +22 -4
  396. package/dist/chat-ui/mentions/suggestions/components/mention-icon.js.map +1 -1
  397. package/dist/chat-ui/mentions/suggestions/components/menu-item.cjs +1 -1
  398. package/dist/chat-ui/mentions/suggestions/components/menu-item.cjs.map +1 -1
  399. package/dist/chat-ui/mentions/suggestions/components/menu-item.js +1 -1
  400. package/dist/chat-ui/mentions/suggestions/components/menu-item.js.map +1 -1
  401. package/dist/chat-ui/mentions/suggestions/data/api-client.cjs +45 -0
  402. package/dist/chat-ui/mentions/suggestions/data/api-client.cjs.map +1 -1
  403. package/dist/chat-ui/mentions/suggestions/data/api-client.d.ts +48 -0
  404. package/dist/chat-ui/mentions/suggestions/data/api-client.js +45 -0
  405. package/dist/chat-ui/mentions/suggestions/data/api-client.js.map +1 -1
  406. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icon-names.generated.cjs +89 -0
  407. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icon-names.generated.cjs.map +1 -0
  408. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icon-names.generated.d.ts +8 -0
  409. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icon-names.generated.js +89 -0
  410. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icon-names.generated.js.map +1 -0
  411. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.cjs +140 -116
  412. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.cjs.map +1 -1
  413. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.d.ts +46 -12
  414. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.js +141 -117
  415. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.js.map +1 -1
  416. package/dist/chat-ui/mentions/suggestions/data/sources/index.cjs +272 -25
  417. package/dist/chat-ui/mentions/suggestions/data/sources/index.cjs.map +1 -1
  418. package/dist/chat-ui/mentions/suggestions/data/sources/index.d.ts +88 -10
  419. package/dist/chat-ui/mentions/suggestions/data/sources/index.js +274 -27
  420. package/dist/chat-ui/mentions/suggestions/data/sources/index.js.map +1 -1
  421. package/dist/chat-ui/mentions/suggestions/data/types.cjs.map +1 -1
  422. package/dist/chat-ui/mentions/suggestions/data/types.d.ts +27 -1
  423. package/dist/chat-ui/mentions/suggestions/data/types.js.map +1 -1
  424. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.cjs +56 -5
  425. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.cjs.map +1 -1
  426. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.d.ts +26 -6
  427. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.js +57 -6
  428. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.js.map +1 -1
  429. package/dist/chat-ui/mentions/suggestions/mention-suggestions.extension.cjs +34 -17
  430. package/dist/chat-ui/mentions/suggestions/mention-suggestions.extension.cjs.map +1 -1
  431. package/dist/chat-ui/mentions/suggestions/mention-suggestions.extension.d.ts +19 -1
  432. package/dist/chat-ui/mentions/suggestions/mention-suggestions.extension.js +35 -18
  433. package/dist/chat-ui/mentions/suggestions/mention-suggestions.extension.js.map +1 -1
  434. package/dist/chat-ui/mentions/use-asset-icon-app-url.cjs +12 -0
  435. package/dist/chat-ui/mentions/use-asset-icon-app-url.cjs.map +1 -0
  436. package/dist/chat-ui/mentions/use-asset-icon-app-url.d.ts +8 -0
  437. package/dist/chat-ui/mentions/use-asset-icon-app-url.js +12 -0
  438. package/dist/chat-ui/mentions/use-asset-icon-app-url.js.map +1 -0
  439. package/dist/chat-ui/statewire.d.ts +1 -1
  440. package/dist/chat-ui/thread/statewire-history-edge.cjs +15 -0
  441. package/dist/chat-ui/thread/statewire-history-edge.cjs.map +1 -1
  442. package/dist/chat-ui/thread/statewire-history-edge.d.ts +4 -1
  443. package/dist/chat-ui/thread/statewire-history-edge.js +15 -0
  444. package/dist/chat-ui/thread/statewire-history-edge.js.map +1 -1
  445. package/dist/collab/client.cjs +41 -6
  446. package/dist/collab/client.cjs.map +1 -1
  447. package/dist/collab/client.d.ts +38 -7
  448. package/dist/collab/client.js +41 -6
  449. package/dist/collab/client.js.map +1 -1
  450. package/dist/composer/ComposerAttachedReferences.cjs +119 -0
  451. package/dist/composer/ComposerAttachedReferences.cjs.map +1 -0
  452. package/dist/composer/ComposerAttachedReferences.d.ts +26 -0
  453. package/dist/composer/ComposerAttachedReferences.js +119 -0
  454. package/dist/composer/ComposerAttachedReferences.js.map +1 -0
  455. package/dist/composer/ComposerNamedAgents.cjs +63 -0
  456. package/dist/composer/ComposerNamedAgents.cjs.map +1 -0
  457. package/dist/composer/ComposerNamedAgents.d.ts +16 -0
  458. package/dist/composer/ComposerNamedAgents.js +63 -0
  459. package/dist/composer/ComposerNamedAgents.js.map +1 -0
  460. package/dist/composer/attached-references.cjs +159 -0
  461. package/dist/composer/attached-references.cjs.map +1 -0
  462. package/dist/composer/attached-references.d.ts +86 -0
  463. package/dist/composer/attached-references.js +159 -0
  464. package/dist/composer/attached-references.js.map +1 -0
  465. package/dist/composer/build-composed-message.cjs +14 -7
  466. package/dist/composer/build-composed-message.cjs.map +1 -1
  467. package/dist/composer/build-composed-message.d.ts +6 -1
  468. package/dist/composer/build-composed-message.js +14 -7
  469. package/dist/composer/build-composed-message.js.map +1 -1
  470. package/dist/composer/composer-handoff.cjs +6 -2
  471. package/dist/composer/composer-handoff.cjs.map +1 -1
  472. package/dist/composer/composer-handoff.d.ts +7 -1
  473. package/dist/composer/composer-handoff.js +6 -2
  474. package/dist/composer/composer-handoff.js.map +1 -1
  475. package/dist/composer/folder-upload.cjs +149 -0
  476. package/dist/composer/folder-upload.cjs.map +1 -0
  477. package/dist/composer/folder-upload.d.ts +79 -0
  478. package/dist/composer/folder-upload.js +149 -0
  479. package/dist/composer/folder-upload.js.map +1 -0
  480. package/dist/composer/index.d.ts +1 -1
  481. package/dist/composer/staged-message-metadata.cjs +12 -0
  482. package/dist/composer/staged-message-metadata.cjs.map +1 -0
  483. package/dist/composer/staged-message-metadata.d.ts +15 -0
  484. package/dist/composer/staged-message-metadata.js +12 -0
  485. package/dist/composer/staged-message-metadata.js.map +1 -0
  486. package/dist/composer/useAttachToChat.cjs +35 -0
  487. package/dist/composer/useAttachToChat.cjs.map +1 -0
  488. package/dist/composer/useAttachToChat.d.ts +54 -0
  489. package/dist/composer/useAttachToChat.js +35 -0
  490. package/dist/composer/useAttachToChat.js.map +1 -0
  491. package/dist/composer/useAttachedReferencesComposerProps.cjs +19 -0
  492. package/dist/composer/useAttachedReferencesComposerProps.cjs.map +1 -0
  493. package/dist/composer/useAttachedReferencesComposerProps.d.ts +12 -0
  494. package/dist/composer/useAttachedReferencesComposerProps.js +19 -0
  495. package/dist/composer/useAttachedReferencesComposerProps.js.map +1 -0
  496. package/dist/composer/useFileUpload.cjs +95 -7
  497. package/dist/composer/useFileUpload.cjs.map +1 -1
  498. package/dist/composer/useFileUpload.d.ts +21 -2
  499. package/dist/composer/useFileUpload.js +95 -7
  500. package/dist/composer/useFileUpload.js.map +1 -1
  501. package/dist/data/athena-api-error.cjs +125 -0
  502. package/dist/data/athena-api-error.cjs.map +1 -0
  503. package/dist/data/athena-api-error.d.ts +96 -0
  504. package/dist/data/athena-api-error.js +125 -0
  505. package/dist/data/athena-api-error.js.map +1 -0
  506. package/dist/data/athena-data-client.cjs +106 -0
  507. package/dist/data/athena-data-client.cjs.map +1 -0
  508. package/dist/data/athena-data-client.d.ts +74 -0
  509. package/dist/data/athena-data-client.js +106 -0
  510. package/dist/data/athena-data-client.js.map +1 -0
  511. package/dist/data/athena-member.cjs +93 -0
  512. package/dist/data/athena-member.cjs.map +1 -0
  513. package/dist/data/athena-member.d.ts +125 -0
  514. package/dist/data/athena-member.js +93 -0
  515. package/dist/data/athena-member.js.map +1 -0
  516. package/dist/data/athena-request.cjs +460 -0
  517. package/dist/data/athena-request.cjs.map +1 -0
  518. package/dist/data/athena-request.d.ts +120 -0
  519. package/dist/data/athena-request.js +460 -0
  520. package/dist/data/athena-request.js.map +1 -0
  521. package/dist/data/use-athena-fetch.cjs +14 -0
  522. package/dist/data/use-athena-fetch.cjs.map +1 -0
  523. package/dist/data/use-athena-fetch.d.ts +19 -0
  524. package/dist/data/use-athena-fetch.js +14 -0
  525. package/dist/data/use-athena-fetch.js.map +1 -0
  526. package/dist/data/use-athena-graphql.cjs +66 -0
  527. package/dist/data/use-athena-graphql.cjs.map +1 -0
  528. package/dist/data/use-athena-graphql.d.ts +56 -0
  529. package/dist/data/use-athena-graphql.js +66 -0
  530. package/dist/data/use-athena-graphql.js.map +1 -0
  531. package/dist/data/use-athena-rest.cjs +33 -0
  532. package/dist/data/use-athena-rest.cjs.map +1 -0
  533. package/dist/data/use-athena-rest.d.ts +21 -0
  534. package/dist/data/use-athena-rest.js +33 -0
  535. package/dist/data/use-athena-rest.js.map +1 -0
  536. package/dist/data/use-semantic-query.cjs +44 -0
  537. package/dist/data/use-semantic-query.cjs.map +1 -0
  538. package/dist/data/use-semantic-query.d.ts +92 -0
  539. package/dist/data/use-semantic-query.js +44 -0
  540. package/dist/data/use-semantic-query.js.map +1 -0
  541. package/dist/diagnostics/athena-diagnostics.cjs.map +1 -1
  542. package/dist/diagnostics/athena-diagnostics.d.ts +5 -1
  543. package/dist/diagnostics/athena-diagnostics.js.map +1 -1
  544. package/dist/diagnostics/errors.cjs +7 -0
  545. package/dist/diagnostics/errors.cjs.map +1 -1
  546. package/dist/diagnostics/errors.d.ts +7 -0
  547. package/dist/diagnostics/errors.js +7 -0
  548. package/dist/diagnostics/errors.js.map +1 -1
  549. package/dist/index.cjs +155 -11
  550. package/dist/index.cjs.map +1 -1
  551. package/dist/index.d.ts +72 -13
  552. package/dist/index.js +148 -4
  553. package/dist/index.js.map +1 -1
  554. package/dist/keryx-http/src/initial-sync.cjs +64 -16
  555. package/dist/keryx-http/src/initial-sync.cjs.map +1 -1
  556. package/dist/keryx-http/src/initial-sync.d.ts +31 -1
  557. package/dist/keryx-http/src/initial-sync.js +64 -16
  558. package/dist/keryx-http/src/initial-sync.js.map +1 -1
  559. package/dist/keryx-http/src/own-awareness.cjs +20 -0
  560. package/dist/keryx-http/src/own-awareness.cjs.map +1 -0
  561. package/dist/keryx-http/src/own-awareness.d.ts +50 -0
  562. package/dist/keryx-http/src/own-awareness.js +20 -0
  563. package/dist/keryx-http/src/own-awareness.js.map +1 -0
  564. package/dist/keryx-http/src/update-attributions.cjs +26 -1
  565. package/dist/keryx-http/src/update-attributions.cjs.map +1 -1
  566. package/dist/keryx-http/src/update-attributions.d.ts +10 -1
  567. package/dist/keryx-http/src/update-attributions.js +26 -1
  568. package/dist/keryx-http/src/update-attributions.js.map +1 -1
  569. package/dist/offline/chat-outbox.cjs +262 -26
  570. package/dist/offline/chat-outbox.cjs.map +1 -1
  571. package/dist/offline/chat-outbox.d.ts +90 -12
  572. package/dist/offline/chat-outbox.js +263 -27
  573. package/dist/offline/chat-outbox.js.map +1 -1
  574. package/dist/provider/AthenaProvider.cjs +60 -22
  575. package/dist/provider/AthenaProvider.cjs.map +1 -1
  576. package/dist/provider/AthenaProvider.d.ts +24 -8
  577. package/dist/provider/AthenaProvider.js +61 -23
  578. package/dist/provider/AthenaProvider.js.map +1 -1
  579. package/dist/react/package.json.cjs +1 -1
  580. package/dist/react/package.json.js +1 -1
  581. package/dist/references/src/anchors/parse.cjs +11 -1
  582. package/dist/references/src/anchors/parse.cjs.map +1 -1
  583. package/dist/references/src/anchors/parse.js +11 -1
  584. package/dist/references/src/anchors/parse.js.map +1 -1
  585. package/dist/references/src/anchors/schemas.d.ts +1 -0
  586. package/dist/references/src/anchors/serialize.cjs +1 -0
  587. package/dist/references/src/anchors/serialize.cjs.map +1 -1
  588. package/dist/references/src/anchors/serialize.js +1 -0
  589. package/dist/references/src/anchors/serialize.js.map +1 -1
  590. package/dist/references/src/anchors/types.cjs +5 -0
  591. package/dist/references/src/anchors/types.cjs.map +1 -1
  592. package/dist/references/src/anchors/types.d.ts +9 -0
  593. package/dist/references/src/anchors/types.js +5 -0
  594. package/dist/references/src/anchors/types.js.map +1 -1
  595. package/dist/references/src/attachable.cjs +149 -0
  596. package/dist/references/src/attachable.cjs.map +1 -0
  597. package/dist/references/src/attachable.d.ts +87 -0
  598. package/dist/references/src/attachable.js +149 -0
  599. package/dist/references/src/attachable.js.map +1 -0
  600. package/dist/references/src/schemas.d.ts +2 -0
  601. package/dist/runtime/StatewirePlanModeLaneSync.cjs +93 -0
  602. package/dist/runtime/StatewirePlanModeLaneSync.cjs.map +1 -0
  603. package/dist/runtime/StatewirePlanModeLaneSync.d.ts +34 -0
  604. package/dist/runtime/StatewirePlanModeLaneSync.js +93 -0
  605. package/dist/runtime/StatewirePlanModeLaneSync.js.map +1 -0
  606. package/dist/runtime/StatewireThreadConfigLaneSync.cjs +2 -0
  607. package/dist/runtime/StatewireThreadConfigLaneSync.cjs.map +1 -1
  608. package/dist/runtime/StatewireThreadConfigLaneSync.d.ts +4 -0
  609. package/dist/runtime/StatewireThreadConfigLaneSync.js +2 -0
  610. package/dist/runtime/StatewireThreadConfigLaneSync.js.map +1 -1
  611. package/dist/runtime/statewire-plan-mode.cjs +71 -0
  612. package/dist/runtime/statewire-plan-mode.cjs.map +1 -0
  613. package/dist/runtime/statewire-plan-mode.d.ts +88 -0
  614. package/dist/runtime/statewire-plan-mode.js +71 -0
  615. package/dist/runtime/statewire-plan-mode.js.map +1 -0
  616. package/dist/runtime/statewire-run-config.cjs +3 -1
  617. package/dist/runtime/statewire-run-config.cjs.map +1 -1
  618. package/dist/runtime/statewire-run-config.d.ts +7 -0
  619. package/dist/runtime/statewire-run-config.js +3 -1
  620. package/dist/runtime/statewire-run-config.js.map +1 -1
  621. package/dist/runtime/statewire-session-key.cjs +11 -5
  622. package/dist/runtime/statewire-session-key.cjs.map +1 -1
  623. package/dist/runtime/statewire-session-key.d.ts +22 -10
  624. package/dist/runtime/statewire-session-key.js +11 -5
  625. package/dist/runtime/statewire-session-key.js.map +1 -1
  626. package/dist/runtime/useAthenaStatewireRuntime.cjs +64 -9
  627. package/dist/runtime/useAthenaStatewireRuntime.cjs.map +1 -1
  628. package/dist/runtime/useAthenaStatewireRuntime.d.ts +26 -10
  629. package/dist/runtime/useAthenaStatewireRuntime.js +66 -11
  630. package/dist/runtime/useAthenaStatewireRuntime.js.map +1 -1
  631. package/dist/search/useAthenaAssets.cjs +394 -0
  632. package/dist/search/useAthenaAssets.cjs.map +1 -0
  633. package/dist/search/useAthenaAssets.d.ts +186 -0
  634. package/dist/search/useAthenaAssets.js +394 -0
  635. package/dist/search/useAthenaAssets.js.map +1 -0
  636. package/dist/sheet-range/index.cjs +4 -0
  637. package/dist/sheet-range/index.cjs.map +1 -1
  638. package/dist/sheet-range/index.d.ts +4 -2
  639. package/dist/sheet-range/index.js +4 -0
  640. package/dist/sheet-range/index.js.map +1 -1
  641. package/dist/sheet-range/query-range.cjs +102 -0
  642. package/dist/sheet-range/query-range.cjs.map +1 -0
  643. package/dist/sheet-range/query-range.d.ts +46 -0
  644. package/dist/sheet-range/query-range.js +102 -0
  645. package/dist/sheet-range/query-range.js.map +1 -0
  646. package/dist/styles.css +1 -1
  647. package/dist/subagents/index.cjs +49 -0
  648. package/dist/subagents/index.cjs.map +1 -0
  649. package/dist/subagents/index.d.ts +16 -0
  650. package/dist/subagents/index.js +49 -0
  651. package/dist/subagents/index.js.map +1 -0
  652. package/dist/subagents/lane-follow.cjs +19 -0
  653. package/dist/subagents/lane-follow.cjs.map +1 -0
  654. package/dist/subagents/lane-follow.d.ts +9 -0
  655. package/dist/subagents/lane-follow.js +19 -0
  656. package/dist/subagents/lane-follow.js.map +1 -0
  657. package/dist/subagents/lane-model.cjs +178 -0
  658. package/dist/subagents/lane-model.cjs.map +1 -0
  659. package/dist/subagents/lane-model.d.ts +140 -0
  660. package/dist/subagents/lane-model.js +178 -0
  661. package/dist/subagents/lane-model.js.map +1 -0
  662. package/dist/subagents/lane-parts.cjs +517 -0
  663. package/dist/subagents/lane-parts.cjs.map +1 -0
  664. package/dist/subagents/lane-parts.d.ts +130 -0
  665. package/dist/subagents/lane-parts.js +517 -0
  666. package/dist/subagents/lane-parts.js.map +1 -0
  667. package/dist/subagents/subagent-lane-group.cjs +215 -0
  668. package/dist/subagents/subagent-lane-group.cjs.map +1 -0
  669. package/dist/subagents/subagent-lane-group.d.ts +67 -0
  670. package/dist/subagents/subagent-lane-group.js +215 -0
  671. package/dist/subagents/subagent-lane-group.js.map +1 -0
  672. package/dist/subagents/subagent-transcript-drawer.cjs +431 -0
  673. package/dist/subagents/subagent-transcript-drawer.cjs.map +1 -0
  674. package/dist/subagents/subagent-transcript-drawer.d.ts +78 -0
  675. package/dist/subagents/subagent-transcript-drawer.js +431 -0
  676. package/dist/subagents/subagent-transcript-drawer.js.map +1 -0
  677. package/dist/subagents/task-subagent-group.cjs +115 -0
  678. package/dist/subagents/task-subagent-group.cjs.map +1 -0
  679. package/dist/subagents/task-subagent-group.d.ts +36 -0
  680. package/dist/subagents/task-subagent-group.js +115 -0
  681. package/dist/subagents/task-subagent-group.js.map +1 -0
  682. package/dist/subagents/use-omitted-images-in-view.cjs +68 -0
  683. package/dist/subagents/use-omitted-images-in-view.cjs.map +1 -0
  684. package/dist/subagents/use-omitted-images-in-view.d.ts +21 -0
  685. package/dist/subagents/use-omitted-images-in-view.js +68 -0
  686. package/dist/subagents/use-omitted-images-in-view.js.map +1 -0
  687. package/dist/threads/Inbox.cjs +2 -2
  688. package/dist/threads/Inbox.cjs.map +1 -1
  689. package/dist/threads/SessionList.cjs +6 -6
  690. package/dist/threads/SessionList.cjs.map +1 -1
  691. package/dist/threads/SessionsPage.cjs +13 -7
  692. package/dist/threads/SessionsPage.cjs.map +1 -1
  693. package/dist/threads/SessionsPage.d.ts +10 -1
  694. package/dist/threads/SessionsPage.js +9 -3
  695. package/dist/threads/SessionsPage.js.map +1 -1
  696. package/dist/threads/session-list-model.cjs.map +1 -1
  697. package/dist/threads/session-list-model.d.ts +2 -1
  698. package/dist/threads/session-list-model.js.map +1 -1
  699. package/dist/threads/session-row-parts.cjs +3 -3
  700. package/dist/threads/session-row-parts.cjs.map +1 -1
  701. package/dist/threads/sessions-page-model.cjs +13 -5
  702. package/dist/threads/sessions-page-model.cjs.map +1 -1
  703. package/dist/threads/sessions-page-model.d.ts +7 -0
  704. package/dist/threads/sessions-page-model.js +11 -3
  705. package/dist/threads/sessions-page-model.js.map +1 -1
  706. package/dist/threads/sessions-page-storage.cjs +8 -8
  707. package/dist/threads/sessions-page-storage.cjs.map +1 -1
  708. package/dist/threads/sessions-page-storage.d.ts +5 -1
  709. package/dist/threads/sessions-page-storage.js +8 -8
  710. package/dist/threads/sessions-page-storage.js.map +1 -1
  711. package/dist/threads/statewire-thread-list.cjs +14 -2
  712. package/dist/threads/statewire-thread-list.cjs.map +1 -1
  713. package/dist/threads/statewire-thread-list.d.ts +11 -2
  714. package/dist/threads/statewire-thread-list.js +14 -2
  715. package/dist/threads/statewire-thread-list.js.map +1 -1
  716. package/dist/threads/use-athena-sessions.cjs +1 -0
  717. package/dist/threads/use-athena-sessions.cjs.map +1 -1
  718. package/dist/threads/use-athena-sessions.d.ts +7 -0
  719. package/dist/threads/use-athena-sessions.js +1 -0
  720. package/dist/threads/use-athena-sessions.js.map +1 -1
  721. package/dist/threads/use-athena-thread-agent.cjs +31 -0
  722. package/dist/threads/use-athena-thread-agent.cjs.map +1 -0
  723. package/dist/threads/use-athena-thread-agent.d.ts +38 -0
  724. package/dist/threads/use-athena-thread-agent.js +31 -0
  725. package/dist/threads/use-athena-thread-agent.js.map +1 -0
  726. package/dist/threads/use-athena-thread-plan-mode.cjs +18 -0
  727. package/dist/threads/use-athena-thread-plan-mode.cjs.map +1 -0
  728. package/dist/threads/use-athena-thread-plan-mode.d.ts +18 -0
  729. package/dist/threads/use-athena-thread-plan-mode.js +18 -0
  730. package/dist/threads/use-athena-thread-plan-mode.js.map +1 -0
  731. package/dist/threads/use-rest-conversation-history.d.ts +1 -0
  732. package/dist/tools/agent-creations.cjs +97 -0
  733. package/dist/tools/agent-creations.cjs.map +1 -0
  734. package/dist/tools/agent-creations.d.ts +38 -0
  735. package/dist/tools/agent-creations.js +97 -0
  736. package/dist/tools/agent-creations.js.map +1 -0
  737. package/dist/tools/agent-highlights.cjs +100 -0
  738. package/dist/tools/agent-highlights.cjs.map +1 -0
  739. package/dist/tools/agent-highlights.d.ts +57 -0
  740. package/dist/tools/agent-highlights.js +100 -0
  741. package/dist/tools/agent-highlights.js.map +1 -0
  742. package/dist/tools/append-document-tool-ui.cjs +1 -0
  743. package/dist/tools/append-document-tool-ui.cjs.map +1 -1
  744. package/dist/tools/append-document-tool-ui.d.ts +7 -0
  745. package/dist/tools/append-document-tool-ui.js +2 -1
  746. package/dist/tools/append-document-tool-ui.js.map +1 -1
  747. package/dist/tools/auto-open-tools.cjs +144 -71
  748. package/dist/tools/auto-open-tools.cjs.map +1 -1
  749. package/dist/tools/auto-open-tools.d.ts +131 -1
  750. package/dist/tools/auto-open-tools.js +145 -72
  751. package/dist/tools/auto-open-tools.js.map +1 -1
  752. package/dist/tools/browser-tool-uis.cjs +594 -0
  753. package/dist/tools/browser-tool-uis.cjs.map +1 -0
  754. package/dist/tools/browser-tool-uis.d.ts +8 -0
  755. package/dist/tools/browser-tool-uis.js +594 -0
  756. package/dist/tools/browser-tool-uis.js.map +1 -0
  757. package/dist/tools/computer-asset-tool-uis.cjs +313 -0
  758. package/dist/tools/computer-asset-tool-uis.cjs.map +1 -0
  759. package/dist/tools/computer-asset-tool-uis.d.ts +5 -0
  760. package/dist/tools/computer-asset-tool-uis.js +313 -0
  761. package/dist/tools/computer-asset-tool-uis.js.map +1 -0
  762. package/dist/tools/document-edit-tool-uis.cjs +218 -0
  763. package/dist/tools/document-edit-tool-uis.cjs.map +1 -0
  764. package/dist/tools/document-edit-tool-uis.d.ts +40 -0
  765. package/dist/tools/document-edit-tool-uis.js +218 -0
  766. package/dist/tools/document-edit-tool-uis.js.map +1 -0
  767. package/dist/tools/drive-tool-uis.cjs +429 -0
  768. package/dist/tools/drive-tool-uis.cjs.map +1 -0
  769. package/dist/tools/drive-tool-uis.d.ts +121 -0
  770. package/dist/tools/drive-tool-uis.js +429 -0
  771. package/dist/tools/drive-tool-uis.js.map +1 -0
  772. package/dist/tools/email-calendar-tool-uis.cjs +789 -0
  773. package/dist/tools/email-calendar-tool-uis.cjs.map +1 -0
  774. package/dist/tools/email-calendar-tool-uis.d.ts +129 -0
  775. package/dist/tools/email-calendar-tool-uis.js +789 -0
  776. package/dist/tools/email-calendar-tool-uis.js.map +1 -0
  777. package/dist/tools/ontology-tool-uis.cjs +83 -0
  778. package/dist/tools/ontology-tool-uis.cjs.map +1 -0
  779. package/dist/tools/ontology-tool-uis.d.ts +9 -0
  780. package/dist/tools/ontology-tool-uis.js +83 -0
  781. package/dist/tools/ontology-tool-uis.js.map +1 -0
  782. package/dist/tools/orchestration-tool-uis.cjs +586 -0
  783. package/dist/tools/orchestration-tool-uis.cjs.map +1 -0
  784. package/dist/tools/orchestration-tool-uis.d.ts +141 -0
  785. package/dist/tools/orchestration-tool-uis.js +586 -0
  786. package/dist/tools/orchestration-tool-uis.js.map +1 -0
  787. package/dist/tools/presentation-edit-tool-uis.cjs +516 -0
  788. package/dist/tools/presentation-edit-tool-uis.cjs.map +1 -0
  789. package/dist/tools/presentation-edit-tool-uis.d.ts +73 -0
  790. package/dist/tools/presentation-edit-tool-uis.js +516 -0
  791. package/dist/tools/presentation-edit-tool-uis.js.map +1 -0
  792. package/dist/tools/project-tool-uis.cjs +213 -0
  793. package/dist/tools/project-tool-uis.cjs.map +1 -0
  794. package/dist/tools/project-tool-uis.d.ts +14 -0
  795. package/dist/tools/project-tool-uis.js +213 -0
  796. package/dist/tools/project-tool-uis.js.map +1 -0
  797. package/dist/tools/sandbox-tool-uis.cjs +491 -0
  798. package/dist/tools/sandbox-tool-uis.cjs.map +1 -0
  799. package/dist/tools/sandbox-tool-uis.d.ts +116 -0
  800. package/dist/tools/sandbox-tool-uis.js +491 -0
  801. package/dist/tools/sandbox-tool-uis.js.map +1 -0
  802. package/dist/tools/sheet-query-tool-ui.cjs +138 -0
  803. package/dist/tools/sheet-query-tool-ui.cjs.map +1 -0
  804. package/dist/tools/sheet-query-tool-ui.d.ts +15 -0
  805. package/dist/tools/sheet-query-tool-ui.js +138 -0
  806. package/dist/tools/sheet-query-tool-ui.js.map +1 -0
  807. package/dist/tools/studio-screenshot-tool-uis.cjs +262 -0
  808. package/dist/tools/studio-screenshot-tool-uis.cjs.map +1 -0
  809. package/dist/tools/studio-screenshot-tool-uis.d.ts +52 -0
  810. package/dist/tools/studio-screenshot-tool-uis.js +262 -0
  811. package/dist/tools/studio-screenshot-tool-uis.js.map +1 -0
  812. package/dist/tools/subagent-task-tool-ui.cjs +24 -475
  813. package/dist/tools/subagent-task-tool-ui.cjs.map +1 -1
  814. package/dist/tools/subagent-task-tool-ui.d.ts +19 -103
  815. package/dist/tools/subagent-task-tool-ui.js +28 -479
  816. package/dist/tools/subagent-task-tool-ui.js.map +1 -1
  817. package/dist/tools/tool-summary.cjs +36 -0
  818. package/dist/tools/tool-summary.cjs.map +1 -1
  819. package/dist/tools/tool-summary.js +36 -0
  820. package/dist/tools/tool-summary.js.map +1 -1
  821. package/dist/tools/tool-uis.cjs +181 -53
  822. package/dist/tools/tool-uis.cjs.map +1 -1
  823. package/dist/tools/tool-uis.d.ts +40 -0
  824. package/dist/tools/tool-uis.js +183 -55
  825. package/dist/tools/tool-uis.js.map +1 -1
  826. package/dist/typed-interrupts/index.cjs +15 -0
  827. package/dist/typed-interrupts/index.cjs.map +1 -0
  828. package/dist/typed-interrupts/index.d.ts +20 -0
  829. package/dist/typed-interrupts/index.js +15 -0
  830. package/dist/typed-interrupts/index.js.map +1 -0
  831. package/dist/version.cjs +4 -0
  832. package/dist/version.cjs.map +1 -1
  833. package/dist/version.d.ts +9 -0
  834. package/dist/version.js +4 -0
  835. package/dist/version.js.map +1 -1
  836. package/dist/workbench/live-desktop-api.cjs +2 -1
  837. package/dist/workbench/live-desktop-api.cjs.map +1 -1
  838. package/dist/workbench/live-desktop-api.js +2 -1
  839. package/dist/workbench/live-desktop-api.js.map +1 -1
  840. package/dist/workbench/session-workbench-panes.cjs +6 -6
  841. package/dist/workbench/session-workbench-panes.cjs.map +1 -1
  842. package/dist/workbench/session-workspace-api.cjs +7 -2
  843. package/dist/workbench/session-workspace-api.cjs.map +1 -1
  844. package/dist/workbench/session-workspace-api.d.ts +10 -0
  845. package/dist/workbench/session-workspace-api.js +7 -2
  846. package/dist/workbench/session-workspace-api.js.map +1 -1
  847. package/package.json +28 -6
  848. package/dist/agent-runtime/src/chat-outbox-store.cjs +0 -510
  849. package/dist/agent-runtime/src/chat-outbox-store.cjs.map +0 -1
  850. package/dist/agent-runtime/src/chat-outbox-store.d.ts +0 -210
  851. package/dist/agent-runtime/src/chat-outbox-store.js +0 -510
  852. package/dist/agent-runtime/src/chat-outbox-store.js.map +0 -1
@@ -5,14 +5,14 @@ function useDeepAgentChatOutbox({
5
5
  client,
6
6
  threadId,
7
7
  isNewChat,
8
- store,
8
+ directory,
9
+ legacy,
9
10
  reachability,
10
11
  foreground,
11
12
  restore,
12
13
  openThread,
13
14
  onEvent,
14
15
  checkAttachments,
15
- sendGate,
16
16
  enabled = true,
17
17
  countdownMs
18
18
  }) {
@@ -28,9 +28,6 @@ function useDeepAgentChatOutbox({
28
28
  const checkAttachmentsRef = useRef(checkAttachments);
29
29
  checkAttachmentsRef.current = checkAttachments;
30
30
  const checksAttachments = checkAttachments !== void 0;
31
- const sendGateRef = useRef(sendGate);
32
- sendGateRef.current = sendGate;
33
- const gatesSends = sendGate !== void 0;
34
31
  const reachabilityRef = useRef(reachability);
35
32
  reachabilityRef.current = reachability;
36
33
  const foregroundRef = useRef(foreground);
@@ -55,7 +52,11 @@ function useDeepAgentChatOutbox({
55
52
  const isNewChatRef = useRef(isNewChat);
56
53
  isNewChatRef.current = isNewChat;
57
54
  const [outbox, setOutbox] = useState(null);
55
+ const legacyRef = useRef(legacy);
56
+ legacyRef.current = legacy;
57
+ const migrates = legacy !== void 0;
58
58
  useEffect(() => {
59
+ var _a;
59
60
  if (!enabled || !threadId) {
60
61
  setOutbox(null);
61
62
  return void 0;
@@ -64,7 +65,39 @@ function useDeepAgentChatOutbox({
64
65
  threadId,
65
66
  // Read at each hold: a chat that starts while mounted stamps its later messages as started.
66
67
  isNewChat: () => isNewChatRef.current,
67
- store,
68
+ ...directory && { directory },
69
+ ...migrates && {
70
+ legacy: {
71
+ reader: {
72
+ listAll: () => {
73
+ var _a2;
74
+ return ((_a2 = legacyRef.current) == null ? void 0 : _a2.reader.listAll()) ?? Promise.resolve([]);
75
+ },
76
+ list: (id) => {
77
+ var _a2;
78
+ return ((_a2 = legacyRef.current) == null ? void 0 : _a2.reader.list(id)) ?? Promise.resolve([]);
79
+ },
80
+ count: () => {
81
+ var _a2;
82
+ return ((_a2 = legacyRef.current) == null ? void 0 : _a2.reader.count()) ?? Promise.resolve(0);
83
+ },
84
+ remove: (id, messageId) => {
85
+ var _a2;
86
+ return ((_a2 = legacyRef.current) == null ? void 0 : _a2.reader.remove(id, messageId)) ?? Promise.resolve();
87
+ },
88
+ clear: () => {
89
+ var _a2;
90
+ return ((_a2 = legacyRef.current) == null ? void 0 : _a2.reader.clear()) ?? Promise.resolve();
91
+ }
92
+ },
93
+ ...((_a = legacyRef.current) == null ? void 0 : _a.isKept) !== void 0 && {
94
+ isKept: (id, messageId) => {
95
+ var _a2, _b;
96
+ return ((_b = (_a2 = legacyRef.current) == null ? void 0 : _a2.isKept) == null ? void 0 : _b.call(_a2, id, messageId)) ?? Promise.resolve(false);
97
+ }
98
+ }
99
+ }
100
+ },
68
101
  reachability: stableSignals.reachability,
69
102
  foreground: stableSignals.foreground,
70
103
  thread: {
@@ -79,34 +112,18 @@ function useDeepAgentChatOutbox({
79
112
  restore: (entry) => restoreRef.current(entry),
80
113
  ...canOpenThreads && {
81
114
  openThread: (target) => {
82
- var _a;
83
- return (_a = openThreadRef.current) == null ? void 0 : _a.call(openThreadRef, target);
115
+ var _a2;
116
+ return (_a2 = openThreadRef.current) == null ? void 0 : _a2.call(openThreadRef, target);
84
117
  }
85
118
  },
86
119
  onEvent: (event) => {
87
- var _a;
88
- return (_a = onEventRef.current) == null ? void 0 : _a.call(onEventRef, event);
120
+ var _a2;
121
+ return (_a2 = onEventRef.current) == null ? void 0 : _a2.call(onEventRef, event);
89
122
  },
90
123
  ...checksAttachments && {
91
124
  checkAttachments: (attachments) => {
92
- var _a;
93
- return ((_a = checkAttachmentsRef.current) == null ? void 0 : _a.call(checkAttachmentsRef, attachments)) ?? Promise.resolve("ok");
94
- }
95
- },
96
- ...gatesSends && {
97
- sendGate: {
98
- keyOf: (entry) => {
99
- var _a;
100
- return ((_a = sendGateRef.current) == null ? void 0 : _a.keyOf(entry)) ?? "";
101
- },
102
- mayHandOff: (entry) => {
103
- var _a;
104
- return ((_a = sendGateRef.current) == null ? void 0 : _a.mayHandOff(entry)) ?? true;
105
- },
106
- subscribe: (listener) => {
107
- var _a;
108
- return ((_a = sendGateRef.current) == null ? void 0 : _a.subscribe(listener)) ?? (() => void 0);
109
- }
125
+ var _a2;
126
+ return ((_a2 = checkAttachmentsRef.current) == null ? void 0 : _a2.call(checkAttachmentsRef, attachments)) ?? Promise.resolve("ok");
110
127
  }
111
128
  },
112
129
  ...countdownMs !== void 0 && { countdownMs }
@@ -116,7 +133,7 @@ function useDeepAgentChatOutbox({
116
133
  created.dispose();
117
134
  setOutbox((current) => current === created ? null : current);
118
135
  };
119
- }, [enabled, threadId, store, countdownMs, canOpenThreads, checksAttachments, gatesSends]);
136
+ }, [enabled, threadId, directory, countdownMs, canOpenThreads, checksAttachments, migrates]);
120
137
  return outbox !== null && outbox.threadId === threadId ? outbox : null;
121
138
  }
122
139
  const EMPTY_SNAPSHOT = {
@@ -1 +1 @@
1
- {"version":3,"file":"use-deep-agent-chat-outbox.js","sources":["../../../../agent-runtime/src/use-deep-agent-chat-outbox.ts"],"sourcesContent":["import {\n type Context,\n createContext,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n useSyncExternalStore,\n} from \"react\";\nimport type { ChatOutboxAttachmentCheck } from \"./chat-outbox-attachments\";\nimport {\n type ChatOutbox,\n type ChatOutboxCommandUpdate,\n type ChatOutboxEvent,\n type ChatOutboxSendGate,\n type ChatOutboxSignal,\n type ChatOutboxSnapshot,\n createChatOutbox,\n} from \"./chat-outbox\";\nimport type { ChatOutboxEntry, ChatOutboxStore } from \"./chat-outbox-store\";\nimport { type ChatOutboxClientHost, createStatewireChatOutboxPort } from \"./chat-outbox-thread\";\n\nexport interface UseDeepAgentChatOutboxOptions {\n /** The thread's assistant-ui client (`useDeepAgentRuntime`'s result). */\n client: ChatOutboxClientHost;\n threadId: string;\n /** The conversation has never started (a new chat). */\n isNewChat: boolean;\n /**\n * This person's outbox store, one per person for the life of the page or app (a message the\n * device cannot keep waits in its memory, across thread switches); `null` keeps waiting messages\n * in this outbox alone.\n */\n store: ChatOutboxStore | null;\n /** Athena's reachability (the host's own model: the browser online AND agora answering). */\n reachability: ChatOutboxSignal;\n /** The app is in front (a visible tab, an active app, a focused desktop window). */\n foreground: ChatOutboxSignal;\n /** Give a cancelled message's text back to the composer. */\n restore: (entry: ChatOutboxEntry) => void;\n /**\n * Open another of the person's conversations holding waiting messages (the tray's Open); omit\n * it where the host cannot switch conversations.\n */\n openThread?: (target: { threadId: string; newChat: boolean }) => void;\n onEvent?: (event: ChatOutboxEvent) => void;\n /**\n * Asks Athena whether a waiting message's attachments can still be opened, right before it goes\n * (`createChatOutboxAttachmentCheck`); omitted, attachments go unchecked.\n */\n checkAttachments?: ChatOutboxAttachmentCheck;\n /**\n * Which waiting messages go together, and when (`ChatOutboxOptions.sendGate`): a host whose\n * messages carry per-send settings keeps a message with other settings than a send the\n * conversation has not taken yet waiting until it has. Read through a ref: a host may rebuild it.\n */\n sendGate?: ChatOutboxSendGate;\n /** Off: no outbox (a read-only or suspended surface); sends behave as before. */\n enabled?: boolean;\n /** The countdown before a waiting message is sent (tests); defaults to `CHAT_OUTBOX_COUNTDOWN_MS`. */\n countdownMs?: number;\n}\n\n/**\n * The chat outbox for the mounted thread (`chat-outbox.ts`), one per thread and store: a thread\n * switch disposes it and makes the next thread's. The host forwards statewire's command lifecycle\n * to {@link ChatOutbox.observeCommand} (its `useDeepAgentRuntime` `onCommandChange`), shares the\n * instance through {@link DeepAgentChatOutboxContext}, and has its composer call\n * {@link ChatOutbox.shouldHold} / {@link ChatOutbox.hold} before sending.\n */\nexport function useDeepAgentChatOutbox({\n client,\n threadId,\n isNewChat,\n store,\n reachability,\n foreground,\n restore,\n openThread,\n onEvent,\n checkAttachments,\n sendGate,\n enabled = true,\n countdownMs,\n}: UseDeepAgentChatOutboxOptions): ChatOutbox | null {\n const clientRef = useRef(client);\n clientRef.current = client;\n const restoreRef = useRef(restore);\n restoreRef.current = restore;\n const openThreadRef = useRef(openThread);\n openThreadRef.current = openThread;\n const canOpenThreads = openThread !== undefined;\n const onEventRef = useRef(onEvent);\n onEventRef.current = onEvent;\n const checkAttachmentsRef = useRef(checkAttachments);\n checkAttachmentsRef.current = checkAttachments;\n const checksAttachments = checkAttachments !== undefined;\n const sendGateRef = useRef(sendGate);\n sendGateRef.current = sendGate;\n const gatesSends = sendGate !== undefined;\n const reachabilityRef = useRef(reachability);\n reachabilityRef.current = reachability;\n const foregroundRef = useRef(foreground);\n foregroundRef.current = foreground;\n // The client's notifications reach the port through this set, so a client whose identity\n // changes mid-thread is followed without remaking the outbox (and losing its countdown).\n const [threadListeners] = useState(() => new Set<() => void>());\n // A host without an outbox (`enabled` false) is never subscribed to.\n useEffect(() => {\n if (!enabled) return undefined;\n return client.subscribe(() => {\n for (const listener of threadListeners) listener();\n });\n }, [client, threadListeners, enabled]);\n // Signals read through refs for the same reason: a host rebuilding its signal objects per render\n // never remakes the outbox.\n const [stableSignals] = useState(() => {\n const forward = (pick: () => ChatOutboxSignal): ChatOutboxSignal => ({\n get: () => pick().get(),\n subscribe: (listener) => pick().subscribe(listener),\n });\n return {\n reachability: forward(() => reachabilityRef.current),\n foreground: forward(() => foregroundRef.current),\n };\n });\n const isNewChatRef = useRef(isNewChat);\n isNewChatRef.current = isNewChat;\n\n const [outbox, setOutbox] = useState<ChatOutbox | null>(null);\n // Made in an effect, not during render: the outbox subscribes to its signals and reads its\n // store, and a render React throws away must not leave those behind.\n // biome-ignore lint/correctness/useExhaustiveDependencies: one outbox per thread and store; everything else is read through refs.\n useEffect(() => {\n if (!enabled || !threadId) {\n setOutbox(null);\n return undefined;\n }\n const created = createChatOutbox({\n threadId,\n // Read at each hold: a chat that starts while mounted stamps its later messages as started.\n isNewChat: () => isNewChatRef.current,\n store,\n reachability: stableSignals.reachability,\n foreground: stableSignals.foreground,\n thread: {\n ...createStatewireChatOutboxPort({ client: () => clientRef.current }),\n subscribe: (listener) => {\n threadListeners.add(listener);\n return () => {\n threadListeners.delete(listener);\n };\n },\n },\n restore: (entry) => restoreRef.current(entry),\n ...(canOpenThreads && {\n openThread: (target: { threadId: string; newChat: boolean }) => openThreadRef.current?.(target),\n }),\n onEvent: (event) => onEventRef.current?.(event),\n ...(checksAttachments && {\n checkAttachments: (attachments: Parameters<ChatOutboxAttachmentCheck>[0]) =>\n checkAttachmentsRef.current?.(attachments) ?? Promise.resolve(\"ok\" as const),\n }),\n ...(gatesSends && {\n sendGate: {\n keyOf: (entry: ChatOutboxEntry) => sendGateRef.current?.keyOf(entry) ?? \"\",\n mayHandOff: (entry: ChatOutboxEntry) => sendGateRef.current?.mayHandOff(entry) ?? true,\n subscribe: (listener: () => void) => sendGateRef.current?.subscribe(listener) ?? (() => undefined),\n },\n }),\n ...(countdownMs !== undefined && { countdownMs }),\n });\n setOutbox(created);\n return () => {\n created.dispose();\n setOutbox((current) => (current === created ? null : current));\n };\n }, [enabled, threadId, store, countdownMs, canOpenThreads, checksAttachments, gatesSends]);\n // During a thread switch's first render the previous thread's outbox is still in state.\n return outbox !== null && outbox.threadId === threadId ? outbox : null;\n}\n\nconst EMPTY_SNAPSHOT: ChatOutboxSnapshot = {\n rows: [],\n countdownEndsAt: null,\n durable: true,\n loaded: true,\n elsewhere: [],\n};\nconst noopSubscribe = () => () => undefined;\n\n/** The outbox's rows and countdown, re-rendering on every change (`null` outbox: nothing waits). */\nexport function useChatOutboxSnapshot(outbox: ChatOutbox | null): ChatOutboxSnapshot {\n return useSyncExternalStore(\n outbox ? outbox.subscribe : noopSubscribe,\n () => outbox?.getSnapshot() ?? EMPTY_SNAPSHOT,\n () => outbox?.getSnapshot() ?? EMPTY_SNAPSHOT,\n );\n}\n\n/**\n * Whether Athena can be reached, as the thread's outbox reads it: `true` without an outbox (a host\n * that keeps none sends and edits as before). What a sent message's Edit is offered on; a boolean,\n * so a reader re-renders only when it flips.\n */\nexport function useChatOutboxReachable(outbox: ChatOutbox | null): boolean {\n const subscribe = useCallback(\n (listener: () => void) => (outbox ? outbox.reachability.subscribe(listener) : () => undefined),\n [outbox],\n );\n const reachable = () => outbox?.reachability.get() ?? true;\n return useSyncExternalStore(subscribe, reachable, reachable);\n}\n\n/**\n * The context lives on `globalThis`, not in module scope, because two copies of this module can\n * run in one page: the SDK bundles agent-runtime into its dist while a host such as Olympus imports\n * agent-runtime directly. The host provides its thread's outbox through its own copy and mounts the\n * SDK's queue tray, which reads it through the SDK's copy: one context per copy, and the tray would\n * never see a waiting message (`asset-attachment.ts` shares its registry the same way).\n */\nconst CHAT_OUTBOX_CONTEXT = Symbol.for(\"@athenaintel/agent-runtime/deep-agent-chat-outbox-context\");\n\ntype ChatOutboxContextHost = typeof globalThis & {\n [CHAT_OUTBOX_CONTEXT]?: Context<ChatOutbox | null>;\n};\n\nfunction sharedChatOutboxContext(): Context<ChatOutbox | null> {\n const host = globalThis as ChatOutboxContextHost;\n return (host[CHAT_OUTBOX_CONTEXT] ??= createContext<ChatOutbox | null>(null));\n}\n\n/** The mounted thread's chat outbox, shared from its runtime provider to its composer and tray. */\nexport const DeepAgentChatOutboxContext: Context<ChatOutbox | null> = sharedChatOutboxContext();\n\nexport function useDeepAgentChatOutboxContext(): ChatOutbox | null {\n return useContext(DeepAgentChatOutboxContext);\n}\n\n/** Forward statewire's command lifecycle to an outbox held in a ref (the runtime is made first). */\nexport function forwardChatOutboxCommand(\n outbox: { current: ChatOutbox | null },\n update: ChatOutboxCommandUpdate,\n): void {\n outbox.current?.observeCommand(update);\n}\n"],"names":[],"mappings":";;;AAuEO,SAAS,uBAAuB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV;AACF,GAAqD;AACnD,QAAM,YAAY,OAAO,MAAM;AAC/B,YAAU,UAAU;AACpB,QAAM,aAAa,OAAO,OAAO;AACjC,aAAW,UAAU;AACrB,QAAM,gBAAgB,OAAO,UAAU;AACvC,gBAAc,UAAU;AACxB,QAAM,iBAAiB,eAAe;AACtC,QAAM,aAAa,OAAO,OAAO;AACjC,aAAW,UAAU;AACrB,QAAM,sBAAsB,OAAO,gBAAgB;AACnD,sBAAoB,UAAU;AAC9B,QAAM,oBAAoB,qBAAqB;AAC/C,QAAM,cAAc,OAAO,QAAQ;AACnC,cAAY,UAAU;AACtB,QAAM,aAAa,aAAa;AAChC,QAAM,kBAAkB,OAAO,YAAY;AAC3C,kBAAgB,UAAU;AAC1B,QAAM,gBAAgB,OAAO,UAAU;AACvC,gBAAc,UAAU;AAGxB,QAAM,CAAC,eAAe,IAAI,SAAS,MAAM,oBAAI,KAAiB;AAE9D,YAAU,MAAM;AACd,QAAI,CAAC,QAAS,QAAO;AACrB,WAAO,OAAO,UAAU,MAAM;AAC5B,iB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S;AAC7D;AASA,MAAM,sBAAsB,OAAO,IAAI,2DAA2D;AAMlG,SAAS,0BAAsD;AAC7D,QAAM,OAAO;AACb,SAAQ,0DAA8B,cAAiC,IAAI;AAC7E;AAGO,MAAM,6BAAyD,wBAAA;AAE/D,SAAS,gCAAmD;AACjE,SAAO,WAAW,0BAA0B;AAC9C;"}
1
+ {"version":3,"file":"use-deep-agent-chat-outbox.js","sources":["../../../../agent-runtime/src/use-deep-agent-chat-outbox.ts"],"sourcesContent":["import {\n type Context,\n createContext,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n useSyncExternalStore,\n} from \"react\";\nimport type { ChatOutboxAttachmentCheck } from \"./chat-outbox-attachments\";\nimport {\n type ChatOutbox,\n type ChatOutboxEvent,\n type ChatOutboxLegacyOptions,\n type ChatOutboxSignal,\n type ChatOutboxSnapshot,\n createChatOutbox,\n} from \"./chat-outbox\";\nimport type { ChatOutboxEntry } from \"./chat-outbox-entry\";\nimport type { ChatOutboxDirectory } from \"./chat-outbox-storage\";\nimport { type ChatOutboxClientHost, createStatewireChatOutboxPort } from \"./chat-outbox-thread\";\n\nexport interface UseDeepAgentChatOutboxOptions {\n /** The thread's assistant-ui client (`useDeepAgentRuntime`'s result). */\n client: ChatOutboxClientHost;\n threadId: string;\n /** The conversation has never started (a new chat). */\n isNewChat: boolean;\n /**\n * Every thread's waiting messages (`createChatOutboxDirectory`, one per person over the same\n * backend, namespace and codec as the thread sessions): the tray's other conversations.\n */\n directory?: ChatOutboxDirectory;\n /** The previous store (`createLegacyChatOutboxReader`): this thread's records move into its outbox. */\n legacy?: ChatOutboxLegacyOptions;\n /** Athena's reachability (the host's own model: the browser online AND agora answering). */\n reachability: ChatOutboxSignal;\n /** The app is in front (a visible tab, an active app, a focused desktop window). */\n foreground: ChatOutboxSignal;\n /** Give a cancelled message's text back to the composer. */\n restore: (entry: ChatOutboxEntry) => void;\n /**\n * Open another of the person's conversations holding waiting messages (the tray's Open); omit\n * it where the host cannot switch conversations.\n */\n openThread?: (target: { threadId: string; newChat: boolean }) => void;\n onEvent?: (event: ChatOutboxEvent) => void;\n /**\n * Asks Athena whether a waiting message's attachments can still be opened, right before it goes\n * (`createChatOutboxAttachmentCheck`); omitted, attachments go unchecked.\n */\n checkAttachments?: ChatOutboxAttachmentCheck;\n /** Off: no outbox (a read-only or suspended surface, a thread without a session); sends behave as before. */\n enabled?: boolean;\n /** The countdown before a waiting message is sent (tests); defaults to `CHAT_OUTBOX_COUNTDOWN_MS`. */\n countdownMs?: number;\n}\n\n/**\n * The chat outbox for the mounted thread (`chat-outbox.ts`), one per thread: a thread switch\n * disposes it and makes the next thread's. It reads the thread's statewire outbox\n * (`extras.outbox`), so the thread must mount a session (`useDeepAgentRuntime`'s `session`). The\n * host shares the instance through {@link DeepAgentChatOutboxContext} and has its composer call\n * {@link ChatOutbox.shouldHold} / {@link ChatOutbox.hold} before sending.\n */\nexport function useDeepAgentChatOutbox({\n client,\n threadId,\n isNewChat,\n directory,\n legacy,\n reachability,\n foreground,\n restore,\n openThread,\n onEvent,\n checkAttachments,\n enabled = true,\n countdownMs,\n}: UseDeepAgentChatOutboxOptions): ChatOutbox | null {\n const clientRef = useRef(client);\n clientRef.current = client;\n const restoreRef = useRef(restore);\n restoreRef.current = restore;\n const openThreadRef = useRef(openThread);\n openThreadRef.current = openThread;\n const canOpenThreads = openThread !== undefined;\n const onEventRef = useRef(onEvent);\n onEventRef.current = onEvent;\n const checkAttachmentsRef = useRef(checkAttachments);\n checkAttachmentsRef.current = checkAttachments;\n const checksAttachments = checkAttachments !== undefined;\n const reachabilityRef = useRef(reachability);\n reachabilityRef.current = reachability;\n const foregroundRef = useRef(foreground);\n foregroundRef.current = foreground;\n // The client's notifications reach the port through this set, so a client whose identity\n // changes mid-thread is followed without remaking the outbox (and losing its countdown).\n const [threadListeners] = useState(() => new Set<() => void>());\n // A host without an outbox (`enabled` false) is never subscribed to.\n useEffect(() => {\n if (!enabled) return undefined;\n return client.subscribe(() => {\n for (const listener of threadListeners) listener();\n });\n }, [client, threadListeners, enabled]);\n // Signals read through refs for the same reason: a host rebuilding its signal objects per render\n // never remakes the outbox.\n const [stableSignals] = useState(() => {\n const forward = (pick: () => ChatOutboxSignal): ChatOutboxSignal => ({\n get: () => pick().get(),\n subscribe: (listener) => pick().subscribe(listener),\n });\n return {\n reachability: forward(() => reachabilityRef.current),\n foreground: forward(() => foregroundRef.current),\n };\n });\n const isNewChatRef = useRef(isNewChat);\n isNewChatRef.current = isNewChat;\n\n const [outbox, setOutbox] = useState<ChatOutbox | null>(null);\n const legacyRef = useRef(legacy);\n legacyRef.current = legacy;\n const migrates = legacy !== undefined;\n // Made in an effect, not during render: the outbox subscribes to its signals and its thread, and\n // a render React throws away must not leave those behind.\n // biome-ignore lint/correctness/useExhaustiveDependencies: one outbox per thread and directory; everything else is read through refs.\n useEffect(() => {\n if (!enabled || !threadId) {\n setOutbox(null);\n return undefined;\n }\n const created = createChatOutbox({\n threadId,\n // Read at each hold: a chat that starts while mounted stamps its later messages as started.\n isNewChat: () => isNewChatRef.current,\n ...(directory && { directory }),\n ...(migrates && {\n legacy: {\n reader: {\n listAll: () => legacyRef.current?.reader.listAll() ?? Promise.resolve([]),\n list: (id: string) => legacyRef.current?.reader.list(id) ?? Promise.resolve([]),\n count: () => legacyRef.current?.reader.count() ?? Promise.resolve(0),\n remove: (id: string, messageId: string) =>\n legacyRef.current?.reader.remove(id, messageId) ?? Promise.resolve(),\n clear: () => legacyRef.current?.reader.clear() ?? Promise.resolve(),\n },\n ...(legacyRef.current?.isKept !== undefined && {\n isKept: (id: string, messageId: string) =>\n legacyRef.current?.isKept?.(id, messageId) ?? Promise.resolve(false),\n }),\n },\n }),\n reachability: stableSignals.reachability,\n foreground: stableSignals.foreground,\n thread: {\n ...createStatewireChatOutboxPort({ client: () => clientRef.current }),\n subscribe: (listener) => {\n threadListeners.add(listener);\n return () => {\n threadListeners.delete(listener);\n };\n },\n },\n restore: (entry) => restoreRef.current(entry),\n ...(canOpenThreads && {\n openThread: (target: { threadId: string; newChat: boolean }) => openThreadRef.current?.(target),\n }),\n onEvent: (event) => onEventRef.current?.(event),\n ...(checksAttachments && {\n checkAttachments: (attachments: Parameters<ChatOutboxAttachmentCheck>[0]) =>\n checkAttachmentsRef.current?.(attachments) ?? Promise.resolve(\"ok\" as const),\n }),\n ...(countdownMs !== undefined && { countdownMs }),\n });\n setOutbox(created);\n return () => {\n created.dispose();\n setOutbox((current) => (current === created ? null : current));\n };\n }, [enabled, threadId, directory, countdownMs, canOpenThreads, checksAttachments, migrates]);\n // During a thread switch's first render the previous thread's outbox is still in state.\n return outbox !== null && outbox.threadId === threadId ? outbox : null;\n}\n\nconst EMPTY_SNAPSHOT: ChatOutboxSnapshot = {\n rows: [],\n countdownEndsAt: null,\n durable: true,\n loaded: true,\n elsewhere: [],\n};\nconst noopSubscribe = () => () => undefined;\n\n/** The outbox's rows and countdown, re-rendering on every change (`null` outbox: nothing waits). */\nexport function useChatOutboxSnapshot(outbox: ChatOutbox | null): ChatOutboxSnapshot {\n return useSyncExternalStore(\n outbox ? outbox.subscribe : noopSubscribe,\n () => outbox?.getSnapshot() ?? EMPTY_SNAPSHOT,\n () => outbox?.getSnapshot() ?? EMPTY_SNAPSHOT,\n );\n}\n\n/**\n * Whether Athena can be reached, as the thread's outbox reads it: `true` without an outbox (a host\n * that keeps none sends and edits as before). What a sent message's Edit is offered on; a boolean,\n * so a reader re-renders only when it flips.\n */\nexport function useChatOutboxReachable(outbox: ChatOutbox | null): boolean {\n const subscribe = useCallback(\n (listener: () => void) => (outbox ? outbox.reachability.subscribe(listener) : () => undefined),\n [outbox],\n );\n const reachable = () => outbox?.reachability.get() ?? true;\n return useSyncExternalStore(subscribe, reachable, reachable);\n}\n\n/**\n * The context lives on `globalThis`, not in module scope, because two copies of this module can\n * run in one page: the SDK bundles agent-runtime into its dist while a host such as Olympus imports\n * agent-runtime directly. The host provides its thread's outbox through its own copy and mounts the\n * SDK's queue tray, which reads it through the SDK's copy: one context per copy, and the tray would\n * never see a waiting message (`asset-attachment.ts` shares its registry the same way).\n */\nconst CHAT_OUTBOX_CONTEXT = Symbol.for(\"@athenaintel/agent-runtime/deep-agent-chat-outbox-context\");\n\ntype ChatOutboxContextHost = typeof globalThis & {\n [CHAT_OUTBOX_CONTEXT]?: Context<ChatOutbox | null>;\n};\n\nfunction sharedChatOutboxContext(): Context<ChatOutbox | null> {\n const host = globalThis as ChatOutboxContextHost;\n return (host[CHAT_OUTBOX_CONTEXT] ??= createContext<ChatOutbox | null>(null));\n}\n\n/** The mounted thread's chat outbox, shared from its runtime provider to its composer and tray. */\nexport const DeepAgentChatOutboxContext: Context<ChatOutbox | null> = sharedChatOutboxContext();\n\nexport function useDeepAgentChatOutboxContext(): ChatOutbox | null {\n return useContext(DeepAgentChatOutboxContext);\n}\n"],"names":["_a"],"mappings":";;;AAkEO,SAAS,uBAAuB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV;AACF,GAAqD;AACnD,QAAM,YAAY,OAAO,MAAM;AAC/B,YAAU,UAAU;AACpB,QAAM,aAAa,OAAO,OAAO;AACjC,aAAW,UAAU;AACrB,QAAM,gBAAgB,OAAO,UAAU;AACvC,gBAAc,UAAU;AACxB,QAAM,iBAAiB,eAAe;AACtC,QAAM,aAAa,OAAO,OAAO;AACjC,aAAW,UAAU;AACrB,QAAM,sBAAsB,OAAO,gBAAgB;AACnD,sBAAoB,UAAU;AAC9B,QAAM,oBAAoB,qBAAqB;AAC/C,QAAM,kBAAkB,OAAO,YAAY;AAC3C,kBAAgB,UAAU;AAC1B,QAAM,gBAAgB,OAAO,UAAU;AACvC,gBAAc,UAAU;AAGxB,QAAM,CAAC,eAAe,IAAI,SAAS,MAAM,oBAAI,KAAiB;AAE9D,YAAU,MAAM;AACd,QAAI,CAAC,QAAS,Q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a,EAAE,YAAA;AAAA,IAAY,CAChD;AACD,cAAU,OAAO;AACjB,WAAO,MAAM;AACX,cAAQ,QAAA;AACR,gBAAU,CAAC,YAAa,YAAY,UAAU,OAAO,OAAQ;AAAA,IAC/D;AAAA,EACF,GAAG,CAAC,SAAS,UAAU,WAAW,aAAa,gBAAgB,mBAAmB,QAAQ,CAAC;AAE3F,SAAO,WAAW,QAAQ,OAAO,aAAa,WAAW,SAAS;AACpE;AAEA,MAAM,iBAAqC;AAAA,EACzC,MAAM,CAAA;AAAA,EACN,iBAAiB;AAAA,EACjB,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,WAAW,CAAA;AACb;AACA,MAAM,gBAAgB,MAAM,MAAM;AAG3B,SAAS,sBAAsB,QAA+C;AACnF,SAAO;AAAA,IACL,SAAS,OAAO,YAAY;AAAA,IAC5B,OAAM,iCAAQ,kBAAiB;AAAA,IAC/B,OAAM,iCAAQ,kBAAiB;AAAA,EAAA;AAEnC;AAOO,SAAS,uBAAuB,QAAoC;AACzE,QAAM,YAAY;AAAA,IAChB,CAAC,aAA0B,SAAS,OAAO,aAAa,UAAU,QAAQ,IAAI,MAAM;AAAA,IACpF,CAAC,MAAM;AAAA,EAAA;AAET,QAAM,YAAY,OAAM,iCAAQ,aAAa,UAAS;AACtD,SAAO,qBAAqB,WAAW,WAAW,SAAS;AAC7D;AASA,MAAM,sBAAsB,OAAO,IAAI,2DAA2D;AAMlG,SAAS,0BAAsD;AAC7D,QAAM,OAAO;AACb,SAAQ,0DAA8B,cAAiC,IAAI;AAC7E;AAGO,MAAM,6BAAyD,wBAAA;AAE/D,SAAS,gCAAmD;AACjE,SAAO,WAAW,0BAA0B;AAC9C;"}
@@ -1,12 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const tap = require("@assistant-ui/tap");
3
4
  const require$$0 = require("react");
5
+ const chatOutboxPolicy = require("./chat-outbox-policy.cjs");
4
6
  const errors = require("./errors.cjs");
5
7
  const modelContext = require("./model-context.cjs");
6
8
  const quotaSafeLocalStorageSession = require("./quota-safe-local-storage-session.cjs");
7
9
  const sendRecovery = require("./send-recovery.cjs");
8
10
  const sessionLaneScope = require("./session-lane-scope.cjs");
9
- const threadExtras = require("./thread-extras.cjs");
11
+ const statewireHeldSends = require("./statewire-held-sends.cjs");
10
12
  const useDeepAgentConfig = require("./use-deep-agent-config.cjs");
11
13
  const useDeepAgentThread = require("./use-deep-agent-thread.cjs");
12
14
  function pendingSessionAttachKey(attachKey) {
@@ -38,6 +40,14 @@ function loadSessionRecord(store) {
38
40
  return null;
39
41
  }
40
42
  }
43
+ const ObservedSessionStorage = tap.resource(function useObservedSessionStorage({
44
+ element,
45
+ observe
46
+ }) {
47
+ const store = tap.useResource(element);
48
+ observe(store);
49
+ return store;
50
+ });
41
51
  function logUnhandledStatewireError(surface, error) {
42
52
  if (errors.isStatewireChannelTeardown(error)) {
43
53
  console.debug(`[${surface}] statewire channel teardown:`, error);
@@ -49,6 +59,9 @@ function logUnhandledStatewireError(surface, error) {
49
59
  }
50
60
  console.error(`[${surface}] statewire transport error:`, error);
51
61
  }
62
+ function isPromiseLike(value) {
63
+ return typeof value === "object" && value !== null && typeof value.then === "function";
64
+ }
52
65
  function useDeepAgentRuntime(options) {
53
66
  const {
54
67
  surface,
@@ -56,6 +69,7 @@ function useDeepAgentRuntime(options) {
56
69
  useClient,
57
70
  runConfig,
58
71
  onBeforeSendRetry,
72
+ foreground,
59
73
  onError,
60
74
  onStateChange,
61
75
  onCommandChange,
@@ -70,18 +84,43 @@ function useDeepAgentRuntime(options) {
70
84
  onStateChangeRef.current = onStateChange;
71
85
  const onCommandChangeRef = require$$0.useRef(onCommandChange);
72
86
  onCommandChangeRef.current = onCommandChange;
87
+ const foregroundRef = require$$0.useRef(foreground);
88
+ foregroundRef.current = foreground;
89
+ const holdsHiddenReloads = foreground !== void 0;
73
90
  const diagnosticsRef = require$$0.useRef(threadOptions.diagnostics);
74
91
  diagnosticsRef.current = threadOptions.diagnostics;
75
92
  const onBeforeSendRetryRef = require$$0.useRef(onBeforeSendRetry);
76
93
  onBeforeSendRetryRef.current = onBeforeSendRetry;
77
94
  const clientRef = require$$0.useRef(null);
95
+ const storageSessionRef = require$$0.useRef(null);
96
+ const observeStorageSession = require$$0.useRef((store) => {
97
+ storageSessionRef.current = store;
98
+ }).current;
78
99
  const failureStampsRef = require$$0.useRef(
79
100
  void 0
80
101
  );
81
- failureStampsRef.current = session === false || session.kind === "pending" ? void 0 : session.kind === "local-storage" ? canPersistLocalSession ? () => quotaSafeLocalStorageSession.readPersistedFailedSendStamps(session.key(threadOptions.threadId)) : void 0 : () => quotaSafeLocalStorageSession.readFailedSendStampsFromRecord(loadSessionRecord(session.store));
102
+ failureStampsRef.current = session === false || session.kind === "pending" ? void 0 : session.kind === "local-storage" ? canPersistLocalSession ? () => quotaSafeLocalStorageSession.readPersistedFailedSendStamps(
103
+ quotaSafeLocalStorageSession.localStorageSessionKey({
104
+ namespace: session.namespace,
105
+ principal: session.principal,
106
+ threadId: threadOptions.threadId
107
+ })
108
+ ) : void 0 : session.kind === "session-store" ? () => quotaSafeLocalStorageSession.readFailedSendStampsFromRecord(loadSessionRecord(session.store)) : session.kind === "storage" ? () => {
109
+ const store = storageSessionRef.current;
110
+ return store ? quotaSafeLocalStorageSession.readFailedSendStampsFromRecord(loadSessionRecord(store)) : null;
111
+ } : void 0;
82
112
  const sessionPending = session !== false && session.kind === "pending";
83
113
  const attachKey = sessionPending ? pendingSessionAttachKey(threadOptions.attachKey) : threadOptions.attachKey;
84
- const laneKey = session !== false && session.kind === "local-storage" ? session.key : null;
114
+ const laneNamespace = session !== false && session.kind === "local-storage" ? session.namespace : null;
115
+ const lanePrincipal = session !== false && session.kind === "local-storage" ? session.principal : null;
116
+ const laneKey = require$$0.useMemo(
117
+ () => laneNamespace === null || lanePrincipal === null ? null : (threadId) => quotaSafeLocalStorageSession.localStorageSessionKey({
118
+ namespace: laneNamespace,
119
+ principal: lanePrincipal,
120
+ threadId
121
+ }),
122
+ [laneNamespace, lanePrincipal]
123
+ );
85
124
  const [laneEpochState, setLaneEpochState] = require$$0.useState(
86
125
  () => sessionLaneScope.nextSessionLaneEpoch({
87
126
  previous: sessionLaneScope.INITIAL_SESSION_LANE_EPOCH,
@@ -99,10 +138,10 @@ function useDeepAgentRuntime(options) {
99
138
  const attachId = useDeepAgentThread.deepAgentAttachId({ threadId: threadOptions.threadId, attachKey, laneEpoch });
100
139
  const sendRecovery$1 = require$$0.useMemo(
101
140
  () => sendRecovery.createDeepAgentSendRecovery({
102
- lane: () => {
141
+ outbox: () => {
103
142
  const client2 = clientRef.current;
104
143
  if (!client2) return null;
105
- return threadExtras.readStatewireFailedSendLane(client2.thread().getState().extras);
144
+ return statewireHeldSends.readStatewireOutbox(client2.thread().getState().extras);
106
145
  },
107
146
  failureStamps: () => {
108
147
  var _a;
@@ -138,21 +177,51 @@ function useDeepAgentRuntime(options) {
138
177
  storage: {
139
178
  session: quotaSafeLocalStorageSession.QuotaSafeLocalStorageSession({
140
179
  threadId: threadOptions.threadId,
141
- key: session.key,
180
+ namespace: session.namespace,
181
+ principal: session.principal,
182
+ ...session.unscopedPrefix !== void 0 && { unscopedPrefix: session.unscopedPrefix },
142
183
  ...session.onStorageDegraded === void 0 ? {} : { onStorageDegraded: session.onStorageDegraded }
143
184
  })
144
185
  }
145
186
  },
146
187
  ...session !== false && session.kind === "session-store" && { sessionStore: session.store },
188
+ ...session !== false && session.kind === "storage" && {
189
+ storage: {
190
+ session: ObservedSessionStorage({
191
+ element: session.session(threadOptions.threadId),
192
+ observe: observeStorageSession
193
+ })
194
+ }
195
+ },
196
+ ...holdsHiddenReloads && {
197
+ onFlush: chatOutboxPolicy.createChatOutboxFlushPolicy({
198
+ foreground: () => {
199
+ var _a;
200
+ return ((_a = foregroundRef.current) == null ? void 0 : _a.get()) ?? true;
201
+ },
202
+ outbox: () => {
203
+ var _a;
204
+ const client2 = clientRef.current;
205
+ if (!client2) return null;
206
+ const outbox = (_a = client2.thread().getState().extras) == null ? void 0 : _a.outbox;
207
+ return outbox && typeof outbox.hold === "function" ? outbox : null;
208
+ }
209
+ })
210
+ },
147
211
  onStateChange: (state, ctx) => {
148
212
  var _a;
149
- sendRecoveryRef.current.observeStateChange(state);
150
213
  (_a = onStateChangeRef.current) == null ? void 0 : _a.call(onStateChangeRef, state, ctx);
151
214
  },
215
+ // A durable `settled` update is acked once the returned promise resolves:
216
+ // the host's handler and send recovery both finish before it is.
152
217
  onCommandChange: (update, ctx) => {
153
218
  var _a;
154
- sendRecoveryRef.current.observeCommand(update);
155
- (_a = onCommandChangeRef.current) == null ? void 0 : _a.call(onCommandChangeRef, update, ctx);
219
+ const recovered = sendRecoveryRef.current.onCommandChange(update, ctx);
220
+ const observed = (_a = onCommandChangeRef.current) == null ? void 0 : _a.call(onCommandChangeRef, update, ctx);
221
+ if (recovered === void 0 && !isPromiseLike(observed)) return observed;
222
+ const settled = Promise.all([recovered, observed]).then(() => void 0);
223
+ settled.catch(() => void 0);
224
+ return settled;
156
225
  },
157
226
  onError: (error) => {
158
227
  const handler = onErrorRef.current;
@@ -165,11 +234,6 @@ function useDeepAgentRuntime(options) {
165
234
  });
166
235
  const client = useClient(thread);
167
236
  clientRef.current = client;
168
- require$$0.useEffect(() => {
169
- const unsubscribe = client.subscribe(() => sendRecovery$1.observeFailedLaneChange());
170
- sendRecovery$1.observeFailedLaneChange();
171
- return unsubscribe;
172
- }, [client, sendRecovery$1]);
173
237
  const getRunConfigRef = require$$0.useRef(runConfig == null ? void 0 : runConfig.get);
174
238
  getRunConfigRef.current = runConfig == null ? void 0 : runConfig.get;
175
239
  const hasRunConfig = runConfig !== void 0;
@@ -1 +1 @@
1
- {"version":3,"file":"use-deep-agent-runtime.cjs","sources":["../../../../agent-runtime/src/use-deep-agent-runtime.ts"],"sourcesContent":["import { useEffect, useMemo, useRef, useState } from 'react';\nimport { isStatewireChannelTeardown } from './errors';\nimport { type DeepAgentModelContextHost, registerDeepAgentRunConfig } from './model-context';\nimport {\n isStorageQuotaError,\n QuotaSafeLocalStorageSession,\n readFailedSendStampsFromRecord,\n readPersistedFailedSendStamps,\n type SessionStorageDegradation,\n} from './quota-safe-local-storage-session';\nimport { createDeepAgentSendRecovery } from './send-recovery';\nimport { INITIAL_SESSION_LANE_EPOCH, nextSessionLaneEpoch } from './session-lane-scope';\nimport type { StatewireTransportOptions } from './statewire-transport';\nimport { readStatewireFailedSendLane } from './thread-extras';\nimport { isConfigSyncUnavailableRejection } from './use-deep-agent-config';\nimport {\n deepAgentAttachId,\n useDeepAgentThread,\n type UseDeepAgentThreadOptions,\n} from './use-deep-agent-thread';\n\n/** The thread element `useDeepAgentThread` produces — what the host's `useAui`\n * consumes (`useAui({ thread })`). */\nexport type DeepAgentThreadElement = ReturnType<typeof useDeepAgentThread>;\n\n/**\n * Durable command-lane persistence for the thread — where the lane identity and\n * the commands still awaiting a durable verdict live, so a reload resumes the\n * lane instead of minting a new client.\n *\n * - `local-storage`: browser hosts. Backed by {@link QuotaSafeLocalStorageSession}\n * (the upstream `LocalStorageSession` contract with Athena keys, legacy\n * metadata, and retention). A storage failure after mounting — the origin\n * out of quota after statewire's own sweep, a lockdown-mode write refusal —\n * degrades the session to memory-only persistence and is reported through\n * `onStorageDegraded` (default: one console warning); it never stops the\n * connection. Guarded by a shared availability probe: SSR, storage-blocked\n * iframes, and locked-down browsers keep the session process-local, exactly\n * as before the seam existed, while an origin that is merely full mounts the\n * session and lets it degrade. `key` scopes the stored lane — a thread id is\n * only meaningful against the backend (and, where relevant, principal) that\n * minted it, so include the sync-host URL.\n * - `session-store`: React Native hosts pass a hydrated library store backed\n * by AsyncStorage. Its synchronous `load()` is\n * also the send-recovery freshness gate's view of the persisted failed lane,\n * so a store that persists `failed` gets the same 24 h staleness rule as the\n * browser hosts.\n * - `pending`: the principal the lane is scoped by is not known yet (the\n * host's signed-in user is still loading). See {@link DeepAgentPendingSession}.\n * - `false`: process-local session (a reload mints a new client).\n *\n * A `local-storage` `key` names one principal's lanes (and one backend's). The\n * statewire session that mounts on a lane keeps the client id, lane clocks and\n * journal it loaded there, and everything in that journal is sent under\n * whatever credential the transport holds at its next attach. So a mounted\n * session never moves to another key: when the key starts naming another\n * principal's lanes for the same thread (another account signed in under a\n * mounted chat), the runtime starts a new lane epoch\n * (`UseDeepAgentThreadOptions['laneEpoch']`). The whole statewire thread\n * remounts on the new principal's lane and attaches afresh, as that lane's own\n * client, with nothing remembered or pooled from before. The previous\n * principal's record stays where it is, with its client id and whatever it had\n * journaled and not yet delivered: that principal's next mount on this browser\n * resends it as them, and the retention sweep retires it otherwise. It is never\n * sent as anyone else. A key for the same principal (a token refresh, a fresh\n * `key` function) and a thread switch keep the lane as it is. A host whose\n * principal arrives after mount passes `pending` until it does, never a\n * stand-in key: moving off a stand-in would be a principal change, a second\n * attach.\n */\nexport type DeepAgentSessionPersistence =\n | {\n kind: 'local-storage';\n key: (threadId: string) => string;\n onStorageDegraded?: (degradation: SessionStorageDegradation) => void;\n }\n | { kind: 'session-store'; store: NonNullable<StatewireTransportOptions['sessionStore']> }\n | DeepAgentPendingSession\n | false;\n\n/**\n * The durable lane's principal is not known yet. A lane belongs to one\n * principal and a mounted session cannot move to another lane (see\n * {@link DeepAgentSessionPersistence}), so nothing is mounted, nothing is\n * journaled and the transport stays parked — no dial — until the host passes\n * the real persistence. The park is an attach identity of its own: the attach\n * that follows makes every per-attach decision afresh (the remembered-snapshot\n * seed, the pooled hello, which the park leaves in the pool) and dials the real\n * lane once, as the thread's first attach. The park carries no connection\n * message, so it reads like a never-started chat rather than a paused one; a\n * host suspension, when one applies, wins.\n */\nexport type DeepAgentPendingSession = { kind: 'pending' };\n\n/**\n * The attach key a pending-lane park runs under. It differs from every key the\n * host passes, so the real attach after it is a new attach identity.\n */\nexport function pendingSessionAttachKey(attachKey: string | number | undefined): string {\n return `session-pending:${attachKey ?? ''}`;\n}\n\n/** Structural view of the browser storage global — this package compiles\n * without the DOM lib (React Native honesty; see `globals.d.ts`). */\ntype StorageGlobals = {\n localStorage?: {\n setItem(key: string, value: string): void;\n removeItem(key: string): void;\n };\n navigator?: { locks?: unknown };\n};\n\n/**\n * Whether a localStorage-backed session can persist here. A write probe, not a\n * `typeof` check: storage-blocked iframes (SDK embeds under third-party-storage\n * blocking) throw from the `localStorage` accessor itself, and lockdown-mode\n * origins throw from `setItem` — each of those must mean \"stay process-local\",\n * never a crash at mount. An origin that is merely out of quota still reads\n * and takes locks, so it mounts the session: {@link QuotaSafeLocalStorageSession}\n * degrades that to memory-only persistence and recovers when room frees,\n * where staying process-local would give up cross-tab sharing for the whole\n * page load over a condition that clears.\n *\n * The Web Locks API is probed too: the session storage serializes the shared\n * record across tabs through `navigator.locks` and refuses to mount without it\n * (the same precondition as the vendor `LocalStorageSession`), so an origin\n * with localStorage but no Web Locks — older WebViews, Safari before 15.4 —\n * must also stay process-local instead of throwing at mount.\n */\nexport function canPersistDeepAgentSession(): boolean {\n try {\n const globals = globalThis as StorageGlobals;\n if (!globals.navigator?.locks) return false;\n const storage = globals.localStorage;\n if (!storage) return false;\n const probeKey = '__athena_statewire_session_probe__';\n try {\n storage.setItem(probeKey, probeKey);\n storage.removeItem(probeKey);\n } catch (error) {\n return isStorageQuotaError(error);\n }\n return true;\n } catch {\n return false;\n }\n}\n\n/** A host session store's current record, or `null` when the read throws —\n * the recovery gate must never take the runtime down over a storage fault. */\nfunction loadSessionRecord(\n store: NonNullable<StatewireTransportOptions['sessionStore']>\n): ReturnType<NonNullable<StatewireTransportOptions['sessionStore']>['load']> | null {\n try {\n return store.load();\n } catch {\n return null;\n }\n}\n\n/**\n * The shared tail of every surface's transport error policy: channel teardown\n * is lifecycle noise (logged at debug), as is `config_sync_unavailable` — only\n * `config/*` writes emit it, and the host's config sync already handles it\n * through its own command promise (regionally-pinned workspaces run on\n * local-only config); everything else is a real transport error. Hosts with their own error chain\n * (paywall, telemetry, send-failure stores) end it with this so the fallback\n * logging stays uniform per surface.\n */\nexport function logUnhandledStatewireError(surface: string, error: Error): void {\n if (isStatewireChannelTeardown(error)) {\n console.debug(`[${surface}] statewire channel teardown:`, error);\n return;\n }\n if (isConfigSyncUnavailableRejection(error)) {\n console.debug(`[${surface}] config sync unavailable (handled by config sync):`, error);\n return;\n }\n console.error(`[${surface}] statewire transport error:`, error);\n}\n\n/**\n * The imperative thread-state slice of an assistant-ui client — structural so\n * web and native `useAui` results both satisfy it. The send-recovery layer\n * reads the statewire thread extras through it (the sanctioned imperative\n * pattern: `aui.thread().getState()` inside callbacks/effects, never render).\n */\nexport interface DeepAgentThreadStateClientHost {\n thread: () => { getState: () => { extras?: unknown } };\n subscribe: (listener: () => void) => () => void;\n}\n\n/** Deep-agent runConfig registration on the ambient model context (see\n * {@link registerDeepAgentRunConfig}). */\nexport interface DeepAgentRunConfigRegistration {\n /**\n * Builds the `runConfig` that drives the run. The core pulls it when the\n * model context notifies (mount and each key change); the server reads that\n * synced value at command admission. The per-render ref makes each pull use\n * the latest closure but does not trigger a pull itself.\n */\n get: () => Record<string, unknown>;\n /**\n * Re-registers the provider and notifies model-context sync when this value\n * changes (reference equality). Include getter inputs that can change while\n * mounted; they reach the server only after a key change triggers a pull.\n */\n key?: unknown;\n /**\n * Notifies when a getter input changes outside React, so model-context sync\n * pulls `get` at once, before a command sent right after leaves (Olympus\n * stages a send's named agents right before `composer.send`). Subscribed\n * when the provider registers; a key change subscribes again.\n */\n subscribe?: (listener: () => void) => () => void;\n}\n\nexport interface UseDeepAgentRuntimeOptions<\n TClient extends DeepAgentModelContextHost & DeepAgentThreadStateClientHost,\n> extends Omit<UseDeepAgentThreadOptions, 'storage' | 'sessionStore' | 'laneEpoch'> {\n /** Host surface tag for the shared fallback error logging (e.g.\n * `'AthenaDeepAgent'`, `'AthenaSDK'`, `'ChromeStatewire'`). */\n surface: string;\n /** Durable command-lane persistence; defaults to process-local. */\n session?: DeepAgentSessionPersistence;\n /**\n * Builds the host's assistant-ui client from the thread element — pass the\n * platform `useAui` (web hosts from `@assistant-ui/react`, React Native\n * hosts from `@assistant-ui/react-native`; this package imports neither).\n * Called unconditionally on every render, so it MUST be (or call) a hook\n * following the rules of hooks — define it at module scope with a `use*`\n * name: `const useHostClient = (thread: DeepAgentThreadElement) =>\n * useAui({ thread })`.\n */\n useClient: (thread: DeepAgentThreadElement) => TClient;\n /** Registers the deep-agent runConfig on the client's model context. Hosts\n * that register elsewhere (e.g. a bridge component mounted under the\n * provider) omit it. */\n runConfig?: DeepAgentRunConfigRegistration;\n /**\n * Called right before send recovery dispatches a failed send again, with its\n * message id: the host puts back the per-send context that message was sent\n * with (Olympus stages the agents it named) before its command leaves. A\n * promise holds that retry (and the ones behind it) until it settles, then\n * the host is asked again: it can't put the context back while a send with\n * another one is still on its way (see `DeepAgentSendRecoveryOptions.beforeRetry`).\n * A function returned is called when the retry does not go after all.\n */\n onBeforeSendRetry?: (messageId: string) => void | PromiseLike<void> | (() => void);\n}\n\n/**\n * The configurable deep-agent statewire runtime — the one hook every Athena\n * chat surface (Olympus, `@athenaintel/react` SDK, Chrome extension, Office\n * add-in, mobile) mounts its assistant-ui client through.\n *\n * Composes the pieces every surface previously wired by hand:\n * `useDeepAgentThread` (attach lifecycle, auth parking, lane projection,\n * connection/running observers), durable session persistence with the shared\n * availability guard, transport-level send recovery (failed sends the server\n * never judged auto-retry under their original message id — `send-recovery.ts`),\n * the platform client via `useClient`, and the\n * runConfig model-context registration on provider notifications. Everything\n * host-specific — auth headers, run-config building, error policy, adapters,\n * diagnostics recorders — stays an option, so per-surface behavior is\n * configuration, not a fork.\n */\nexport function useDeepAgentRuntime<\n TClient extends DeepAgentModelContextHost & DeepAgentThreadStateClientHost,\n>(options: UseDeepAgentRuntimeOptions<TClient>): TClient {\n const {\n surface,\n session = false,\n useClient,\n runConfig,\n onBeforeSendRetry,\n onError,\n onStateChange,\n onCommandChange,\n ...threadOptions\n } = options;\n\n // Probed once per mount, like every browser host did individually: an origin\n // that cannot persist stays process-local for the mount's lifetime.\n const [canPersistLocalSession] = useState(canPersistDeepAgentSession);\n\n // Per-render refs so the transport never remounts on a new closure identity\n // and always reads the latest policy.\n const onErrorRef = useRef(onError);\n onErrorRef.current = onError;\n const surfaceRef = useRef(surface);\n surfaceRef.current = surface;\n const onStateChangeRef = useRef(onStateChange);\n onStateChangeRef.current = onStateChange;\n const onCommandChangeRef = useRef(onCommandChange);\n onCommandChangeRef.current = onCommandChange;\n const diagnosticsRef = useRef(threadOptions.diagnostics);\n diagnosticsRef.current = threadOptions.diagnostics;\n const onBeforeSendRetryRef = useRef(onBeforeSendRetry);\n onBeforeSendRetryRef.current = onBeforeSendRetry;\n const clientRef = useRef<TClient | null>(null);\n\n // Where the persisted session record lives, for the recovery freshness gate\n // (read per sweep — undefined means \"no persistence, everything is fresh\").\n const failureStampsRef = useRef<(() => ReadonlyMap<string, number> | null) | undefined>(\n undefined\n );\n failureStampsRef.current =\n session === false || session.kind === 'pending'\n ? undefined\n : session.kind === 'local-storage'\n ? canPersistLocalSession\n ? () => readPersistedFailedSendStamps(session.key(threadOptions.threadId))\n : undefined\n : () => readFailedSendStampsFromRecord(loadSessionRecord(session.store));\n\n // A pending lane parks the thread under an attach identity of its own (see\n // `DeepAgentPendingSession`), so the attach once the lane is known is new.\n const sessionPending = session !== false && session.kind === 'pending';\n const attachKey = sessionPending\n ? pendingSessionAttachKey(threadOptions.attachKey)\n : threadOptions.attachKey;\n\n // The lane's scope, as the host's `key` names it: whose lanes this mount\n // runs on. A key that starts naming another principal's lanes starts a new\n // lane epoch, which remounts the whole thread on the new lane instead of\n // moving the mounted session there (see `DeepAgentSessionPersistence`).\n // Tracked whether or not this origin can persist: a process-local session\n // holds the previous principal's journal in memory just the same. A pending\n // lane keeps the last known scope, so a sign-out and a sign-in as someone\n // else with a gap between them is still a change.\n const laneKey = session !== false && session.kind === 'local-storage' ? session.key : null;\n const [laneEpochState, setLaneEpochState] = useState(() =>\n nextSessionLaneEpoch({\n previous: INITIAL_SESSION_LANE_EPOCH,\n threadId: threadOptions.threadId,\n key: laneKey,\n })\n );\n const nextLaneEpochState = nextSessionLaneEpoch({\n previous: laneEpochState,\n threadId: threadOptions.threadId,\n key: laneKey,\n });\n // React's derived-state update: re-renders at once with the new epoch, and\n // this render already uses it, so no render pairs the new key with the\n // mounted thread.\n if (nextLaneEpochState !== laneEpochState) setLaneEpochState(nextLaneEpochState);\n const laneEpoch = nextLaneEpochState.epoch;\n\n // Send recovery, keyed by attach identity exactly like the thread's session\n // (a switch, re-attach or new lane epoch gets fresh hydration gating and\n // retry budgets, so it never re-dispatches a previous principal's failed\n // sends). The controller re-dispatches failed sends the server never judged;\n // see `send-recovery.ts` for the contract.\n const attachId = deepAgentAttachId({ threadId: threadOptions.threadId, attachKey, laneEpoch });\n // biome-ignore lint/correctness/useExhaustiveDependencies: keyed by attach identity on purpose; every other input is read through a per-render ref.\n const sendRecovery = useMemo(\n () =>\n createDeepAgentSendRecovery({\n lane: () => {\n const client = clientRef.current;\n if (!client) return null;\n return readStatewireFailedSendLane(client.thread().getState().extras);\n },\n failureStamps: () => failureStampsRef.current?.() ?? null,\n diagnostics: () => diagnosticsRef.current,\n beforeRetry: (messageId) => onBeforeSendRetryRef.current?.(messageId),\n }),\n [attachId]\n );\n useEffect(() => () => sendRecovery.dispose(), [sendRecovery]);\n const sendRecoveryRef = useRef(sendRecovery);\n sendRecoveryRef.current = sendRecovery;\n\n const thread = useDeepAgentThread({\n ...threadOptions,\n ...(attachKey !== undefined && { attachKey }),\n laneEpoch,\n // Parked without a message (a host suspension, when one applies, wins):\n // nothing dials and nothing journals until the lane is known. What paints\n // the first frame is the real attach's to report, not the park's.\n ...(sessionPending && {\n suspended: threadOptions.suspended || {},\n onAttachSource: undefined,\n }),\n // A pooled dial for the thread is the real attach's to take: a park that\n // only waits for the lane neither takes nor discards it. A host suspension\n // still discards it, as it does without a pending lane.\n ...(sessionPending && !threadOptions.suspended && { prewarmPool: undefined }),\n ...(session !== false &&\n session.kind === 'local-storage' &&\n canPersistLocalSession && {\n storage: {\n session: QuotaSafeLocalStorageSession({\n threadId: threadOptions.threadId,\n key: session.key,\n ...(session.onStorageDegraded === undefined\n ? {}\n : { onStorageDegraded: session.onStorageDegraded }),\n }),\n },\n }),\n ...(session !== false && session.kind === 'session-store' && { sessionStore: session.store }),\n onStateChange: (state, ctx) => {\n sendRecoveryRef.current.observeStateChange(state);\n onStateChangeRef.current?.(state, ctx);\n },\n onCommandChange: (update, ctx) => {\n sendRecoveryRef.current.observeCommand(update);\n onCommandChangeRef.current?.(update, ctx);\n },\n onError: (error) => {\n const handler = onErrorRef.current;\n if (handler) {\n handler(error);\n return;\n }\n logUnhandledStatewireError(surfaceRef.current, error);\n },\n });\n\n const client = useClient(thread);\n clientRef.current = client;\n\n // A locked shared journal can publish failed history after onCommandChange,\n // with no canonical state change to wake recovery. Observe the client that\n // owns the visible failed lane; the controller guards in-flight retries.\n useEffect(() => {\n const unsubscribe = client.subscribe(() => sendRecovery.observeFailedLaneChange());\n sendRecovery.observeFailedLaneChange();\n return unsubscribe;\n }, [client, sendRecovery]);\n\n // Commands travel bare, so the runConfig that drives the run rides the\n // ambient model context: `contextSync: 'command-send'` mirrors it to the\n // server, which reads `config.runConfig` at command admission. The core pulls\n // on model-context notifications; the per-render ref ensures each pull uses\n // the latest closure but does not trigger a pull itself.\n const getRunConfigRef = useRef(runConfig?.get);\n getRunConfigRef.current = runConfig?.get;\n const hasRunConfig = runConfig !== undefined;\n const runConfigKey = runConfig?.key;\n // A host's own notifications (inputs that change outside React) pull too.\n const subscribeRunConfigRef = useRef(runConfig?.subscribe);\n subscribeRunConfigRef.current = runConfig?.subscribe;\n const hasRunConfigSubscribe = runConfig?.subscribe !== undefined;\n useEffect(() => {\n if (!hasRunConfig) return undefined;\n return registerDeepAgentRunConfig(\n client,\n () => getRunConfigRef.current?.() ?? {},\n hasRunConfigSubscribe\n ? (listener) => subscribeRunConfigRef.current?.(listener) ?? (() => {})\n : undefined\n );\n }, [client, hasRunConfig, runConfigKey, hasRunConfigSubscribe]);\n\n return client;\n}\n\n"],"names":["isStorageQuotaError","isStatewireChannelTeardown","isConfigSyncUnavailableRejection","useState","useRef","readPersistedFailedSendStamps","readFailedSendStampsFromRecord","nextSessionLaneEpoch","INITIAL_SESSION_LANE_EPOCH","deepAgentAttachId","sendRecovery","useMemo","createDeepAgentSendRecovery","client","readStatewireFailedSendLane","useEffect","useDeepAgentThread","QuotaSafeLocalStorageSession","registerDeepAgentRunConfig"],"mappings":";;;;;;;;;;;AAkGO,SAAS,wBAAwB,WAAgD;AACtF,SAAO,mBAAmB,aAAa,EAAE;AAC3C;AA6BO,SAAS,6BAAsC;;AACpD,MAAI;AACF,UAAM,UAAU;AAChB,QAAI,GAAC,aAAQ,cAAR,mBAAmB,OAAO,QAAO;AACtC,UAAM,UAAU,QAAQ;AACxB,QAAI,CAAC,QAAS,QAAO;AACrB,UAAM,WAAW;AACjB,QAAI;AACF,cAAQ,QAAQ,UAAU,QAAQ;AAClC,cAAQ,WAAW,QAAQ;AAAA,IAC7B,SAAS,OAAO;AACd,aAAOA,6BAAAA,oBAAoB,KAAK;AAAA,IAClC;AACA,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAIA,SAAS,kBACP,OACmF;AACnF,MAAI;AACF,WAAO,MAAM,KAAA;AAAA,EACf,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAWO,SAAS,2BAA2B,SAAiB,OAAoB;AAC9E,MAAIC,OAAAA,2BAA2B,KAAK,GAAG;AACrC,YAAQ,MAAM,IAAI,OAAO,iCAAiC,KAAK;AAC/D;AAAA,EACF;AACA,MAAIC,mBAAAA,iCAAiC,KAAK,GAAG;AAC3C,YAAQ,MAAM,IAAI,OAAO,uDAAuD,KAAK;AACrF;AAAA,EACF;AACA,UAAQ,MAAM,IAAI,OAAO,gCAAgC,KAAK;AAChE;AAwFO,SAAS,oBAEd,SAAuD;AACvD,QAAM;AAAA,IACJ;AAAA,IACA,UAAU;AAAA,IACV;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AM;AAAA,QAAC;AAAA,UACnE;AAAA,IAAA;AAAA,EAER,GAAG,CAAC,QAAQ,cAAc,cAAc,qBAAqB,CAAC;AAE9D,SAAO;AACT;;;;;"}
1
+ {"version":3,"file":"use-deep-agent-runtime.cjs","sources":["../../../../agent-runtime/src/use-deep-agent-runtime.ts"],"sourcesContent":["import { type ResourceElement, resource, useResource } from '@assistant-ui/tap';\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport type { StatewireClient } from 'statewire';\nimport { createChatOutboxFlushPolicy } from './chat-outbox-policy';\nimport { isStatewireChannelTeardown } from './errors';\nimport { type DeepAgentModelContextHost, registerDeepAgentRunConfig } from './model-context';\nimport {\n isStorageQuotaError,\n localStorageSessionKey,\n QuotaSafeLocalStorageSession,\n readFailedSendStampsFromRecord,\n readPersistedFailedSendStamps,\n type SessionStorageDegradation,\n} from './quota-safe-local-storage-session';\nimport { createDeepAgentSendRecovery } from './send-recovery';\nimport { INITIAL_SESSION_LANE_EPOCH, nextSessionLaneEpoch } from './session-lane-scope';\nimport { readStatewireOutbox } from './statewire-held-sends';\nimport type { StatewireTransportOptions } from './statewire-transport';\nimport { isConfigSyncUnavailableRejection } from './use-deep-agent-config';\nimport {\n deepAgentAttachId,\n useDeepAgentThread,\n type UseDeepAgentThreadOptions,\n} from './use-deep-agent-thread';\n\n/** The thread element `useDeepAgentThread` produces — what the host's `useAui`\n * consumes (`useAui({ thread })`). */\nexport type DeepAgentThreadElement = ReturnType<typeof useDeepAgentThread>;\n\n/**\n * Durable command-lane persistence for the thread — where the lane identity and\n * the commands still awaiting a durable verdict live, so a reload resumes the\n * lane instead of minting a new client.\n *\n * - `local-storage`: browser hosts. Backed by {@link QuotaSafeLocalStorageSession}\n * (the upstream `LocalStorageSession` contract with Athena keys, legacy\n * metadata, and retention). A storage failure after mounting — the origin\n * out of quota after statewire's own sweep, a lockdown-mode write refusal —\n * degrades the session to memory-only persistence and is reported through\n * `onStorageDegraded` (default: one console warning); it never stops the\n * connection. Guarded by a shared availability probe: SSR, storage-blocked\n * iframes, and locked-down browsers keep the session process-local, exactly\n * as before the seam existed, while an origin that is merely full mounts the\n * session and lets it degrade. `namespace` (the sync host) and `principal`\n * (the signed-in account) scope the stored lane: a thread id is only\n * meaningful against the backend and the principal that minted it.\n * - `session-store`: React Native hosts pass a hydrated library store backed\n * by AsyncStorage. Its synchronous `load()` is\n * also the send-recovery freshness gate's view of the persisted failed lane,\n * so a store that persists `failed` gets the same 24 h staleness rule as the\n * browser hosts.\n * - `pending`: the principal the lane is scoped by is not known yet (the\n * host's signed-in user is still loading). See {@link DeepAgentPendingSession}.\n * - `false`: process-local session (a reload mints a new client).\n *\n * A `local-storage` `namespace` and `principal` name one principal's lanes (and one backend's). The\n * statewire session that mounts on a lane keeps the client id, lane clocks and\n * journal it loaded there, and everything in that journal is sent under\n * whatever credential the transport holds at its next attach. So a mounted\n * session never moves to another key: when the key starts naming another\n * principal's lanes for the same thread (another account signed in under a\n * mounted chat), the runtime starts a new lane epoch\n * (`UseDeepAgentThreadOptions['laneEpoch']`). The whole statewire thread\n * remounts on the new principal's lane and attaches afresh, as that lane's own\n * client, with nothing remembered or pooled from before. The previous\n * principal's record stays where it is, with its client id and whatever it had\n * journaled and not yet delivered: that principal's next mount on this browser\n * resends it as them, and the retention sweep retires it otherwise. It is never\n * sent as anyone else. The same principal again (a token refresh, a fresh\n * persistence object) and a thread switch keep the lane as it is. A host whose\n * principal arrives after mount passes `pending` until it does, never a\n * stand-in key: moving off a stand-in would be a principal change, a second\n * attach.\n */\nexport type DeepAgentSessionPersistence =\n | {\n kind: 'local-storage';\n /** The backend the lanes belong to, as a key prefix: the sync host and `:`. */\n namespace: string;\n /** The signed-in account the lanes belong to (`sessionPrincipal(userId)`). */\n principal: string;\n /**\n * Where statewire 0.24 kept this account's lanes (`<syncUrl>:<userId>:`): a thread's lane\n * there moves under its scoped key on mount (`adoptUnscopedLocalStorageSessions`).\n */\n unscopedPrefix?: string;\n onStorageDegraded?: (degradation: SessionStorageDegradation) => void;\n }\n | { kind: 'session-store'; store: NonNullable<StatewireTransportOptions['sessionStore']> }\n | {\n kind: 'storage';\n /**\n * The thread's mounted session storage (`ChatSessionStorage`: sealed IndexedDB, or page\n * memory where devices keep no copies), made per thread. The surfaces that keep a chat\n * outbox use it: the outbox is the session's outbox.\n */\n session: (threadId: string) => ResourceElement<StatewireClient.SessionStorage>;\n }\n | DeepAgentPendingSession\n | false;\n\n/**\n * The durable lane's principal is not known yet. A lane belongs to one\n * principal and a mounted session cannot move to another lane (see\n * {@link DeepAgentSessionPersistence}), so nothing is mounted, nothing is\n * journaled and the transport stays parked — no dial — until the host passes\n * the real persistence. The park is an attach identity of its own: the attach\n * that follows makes every per-attach decision afresh (the remembered-snapshot\n * seed, the pooled hello, which the park leaves in the pool) and dials the real\n * lane once, as the thread's first attach. The park carries no connection\n * message, so it reads like a never-started chat rather than a paused one; a\n * host suspension, when one applies, wins.\n */\nexport type DeepAgentPendingSession = { kind: 'pending' };\n\n/**\n * The attach key a pending-lane park runs under. It differs from every key the\n * host passes, so the real attach after it is a new attach identity.\n */\nexport function pendingSessionAttachKey(attachKey: string | number | undefined): string {\n return `session-pending:${attachKey ?? ''}`;\n}\n\n/** Structural view of the browser storage global — this package compiles\n * without the DOM lib (React Native honesty; see `globals.d.ts`). */\ntype StorageGlobals = {\n localStorage?: {\n setItem(key: string, value: string): void;\n removeItem(key: string): void;\n };\n navigator?: { locks?: unknown };\n};\n\n/**\n * Whether a localStorage-backed session can persist here. A write probe, not a\n * `typeof` check: storage-blocked iframes (SDK embeds under third-party-storage\n * blocking) throw from the `localStorage` accessor itself, and lockdown-mode\n * origins throw from `setItem` — each of those must mean \"stay process-local\",\n * never a crash at mount. An origin that is merely out of quota still reads\n * and takes locks, so it mounts the session: {@link QuotaSafeLocalStorageSession}\n * degrades that to memory-only persistence and recovers when room frees,\n * where staying process-local would give up cross-tab sharing for the whole\n * page load over a condition that clears.\n *\n * The Web Locks API is probed too: the session storage serializes the shared\n * record across tabs through `navigator.locks` and refuses to mount without it\n * (the same precondition as the vendor `LocalStorageSession`), so an origin\n * with localStorage but no Web Locks — older WebViews, Safari before 15.4 —\n * must also stay process-local instead of throwing at mount.\n */\nexport function canPersistDeepAgentSession(): boolean {\n try {\n const globals = globalThis as StorageGlobals;\n if (!globals.navigator?.locks) return false;\n const storage = globals.localStorage;\n if (!storage) return false;\n const probeKey = '__athena_statewire_session_probe__';\n try {\n storage.setItem(probeKey, probeKey);\n storage.removeItem(probeKey);\n } catch (error) {\n return isStorageQuotaError(error);\n }\n return true;\n } catch {\n return false;\n }\n}\n\n/** A host session store's current record, or `null` when the read throws —\n * the recovery gate must never take the runtime down over a storage fault. */\nfunction loadSessionRecord(\n store: NonNullable<StatewireTransportOptions['sessionStore']>\n): ReturnType<NonNullable<StatewireTransportOptions['sessionStore']>['load']> | null {\n try {\n return store.load();\n } catch {\n return null;\n }\n}\n\n/**\n * A mounted `storage.session` element that hands its store to `observe`, so the recovery\n * freshness gate can read the stored `ts` of a failed send off the record the session hydrated.\n */\nconst ObservedSessionStorage = resource(function useObservedSessionStorage({\n element,\n observe,\n}: {\n element: ResourceElement<StatewireClient.SessionStorage>;\n observe: (store: StatewireClient.SessionStorage) => void;\n}): StatewireClient.SessionStorage {\n const store = useResource(element);\n observe(store);\n return store;\n});\n\n/**\n * The shared tail of every surface's transport error policy: channel teardown\n * is lifecycle noise (logged at debug), as is `config_sync_unavailable` — only\n * `config/*` writes emit it, and the host's config sync already handles it\n * through its own command promise (regionally-pinned workspaces run on\n * local-only config); everything else is a real transport error. Hosts with their own error chain\n * (paywall, telemetry, send-failure stores) end it with this so the fallback\n * logging stays uniform per surface.\n */\nexport function logUnhandledStatewireError(surface: string, error: Error): void {\n if (isStatewireChannelTeardown(error)) {\n console.debug(`[${surface}] statewire channel teardown:`, error);\n return;\n }\n if (isConfigSyncUnavailableRejection(error)) {\n console.debug(`[${surface}] config sync unavailable (handled by config sync):`, error);\n return;\n }\n console.error(`[${surface}] statewire transport error:`, error);\n}\n\n/**\n * The imperative thread-state slice of an assistant-ui client — structural so\n * web and native `useAui` results both satisfy it. The send-recovery layer\n * reads the statewire thread extras through it (the sanctioned imperative\n * pattern: `aui.thread().getState()` inside callbacks/effects, never render).\n */\nexport interface DeepAgentThreadStateClientHost {\n thread: () => { getState: () => { extras?: unknown } };\n subscribe: (listener: () => void) => () => void;\n}\n\n/** Deep-agent runConfig registration on the ambient model context (see\n * {@link registerDeepAgentRunConfig}). */\nexport interface DeepAgentRunConfigRegistration {\n /**\n * Builds the `runConfig` that drives the run. The core pulls it when the\n * model context notifies (mount and each key change); the server reads that\n * synced value at command admission. The per-render ref makes each pull use\n * the latest closure but does not trigger a pull itself.\n */\n get: () => Record<string, unknown>;\n /**\n * Re-registers the provider and notifies model-context sync when this value\n * changes (reference equality). Include getter inputs that can change while\n * mounted; they reach the server only after a key change triggers a pull.\n */\n key?: unknown;\n /**\n * Notifies when a getter input changes outside React, so model-context sync\n * pulls `get` at once, before a command sent right after leaves (Olympus\n * stages a send's named agents right before `composer.send`). Subscribed\n * when the provider registers; a key change subscribes again.\n */\n subscribe?: (listener: () => void) => () => void;\n}\n\nexport interface UseDeepAgentRuntimeOptions<\n TClient extends DeepAgentModelContextHost & DeepAgentThreadStateClientHost,\n> extends Omit<UseDeepAgentThreadOptions, 'storage' | 'sessionStore' | 'laneEpoch'> {\n /** Host surface tag for the shared fallback error logging (e.g.\n * `'AthenaDeepAgent'`, `'AthenaSDK'`, `'ChromeStatewire'`). */\n surface: string;\n /** Durable command-lane persistence; defaults to process-local. */\n session?: DeepAgentSessionPersistence;\n /**\n * Builds the host's assistant-ui client from the thread element — pass the\n * platform `useAui` (web hosts from `@assistant-ui/react`, React Native\n * hosts from `@assistant-ui/react-native`; this package imports neither).\n * Called unconditionally on every render, so it MUST be (or call) a hook\n * following the rules of hooks — define it at module scope with a `use*`\n * name: `const useHostClient = (thread: DeepAgentThreadElement) =>\n * useAui({ thread })`.\n */\n useClient: (thread: DeepAgentThreadElement) => TClient;\n /** Registers the deep-agent runConfig on the client's model context. Hosts\n * that register elsewhere (e.g. a bridge component mounted under the\n * provider) omit it. */\n runConfig?: DeepAgentRunConfigRegistration;\n /**\n * Called right before send recovery dispatches a failed send again, with its\n * message id: the host puts back the per-send context that message was sent\n * with (Olympus stages the agents it named) before its command leaves. A\n * promise holds that retry (and the ones behind it) until it settles, then\n * the host is asked again: it can't put the context back while a send with\n * another one is still on its way (see `DeepAgentSendRecoveryOptions.beforeRetry`).\n * A function returned is called when the retry does not go after all.\n */\n onBeforeSendRetry?: (messageId: string) => void | PromiseLike<void> | (() => void);\n /**\n * Whether the app is in front (a visible tab, a focused desktop window). While it says no, the\n * message sends a flush offers as queued before this page mounted are held, so a hidden tab never\n * sends a backlog; the visible tab's chat outbox counts them down and sends them. Omitted, every\n * tab sends them.\n */\n foreground?: { get(): boolean };\n}\n\nfunction isPromiseLike(value: unknown): value is PromiseLike<unknown> {\n return (\n typeof value === 'object' &&\n value !== null &&\n typeof (value as { then?: unknown }).then === 'function'\n );\n}\n\n/**\n * The configurable deep-agent statewire runtime — the one hook every Athena\n * chat surface (Olympus, `@athenaintel/react` SDK, Chrome extension, Office\n * add-in, mobile) mounts its assistant-ui client through.\n *\n * Composes the pieces every surface previously wired by hand:\n * `useDeepAgentThread` (attach lifecycle, auth parking, lane projection,\n * connection/running observers), durable session persistence with the shared\n * availability guard, transport-level send recovery (failed sends the server\n * never judged auto-retry under their original message id — `send-recovery.ts`),\n * the platform client via `useClient`, and the\n * runConfig model-context registration on provider notifications. Everything\n * host-specific — auth headers, run-config building, error policy, adapters,\n * diagnostics recorders — stays an option, so per-surface behavior is\n * configuration, not a fork.\n */\nexport function useDeepAgentRuntime<\n TClient extends DeepAgentModelContextHost & DeepAgentThreadStateClientHost,\n>(options: UseDeepAgentRuntimeOptions<TClient>): TClient {\n const {\n surface,\n session = false,\n useClient,\n runConfig,\n onBeforeSendRetry,\n foreground,\n onError,\n onStateChange,\n onCommandChange,\n ...threadOptions\n } = options;\n\n // Probed once per mount, like every browser host did individually: an origin\n // that cannot persist stays process-local for the mount's lifetime.\n const [canPersistLocalSession] = useState(canPersistDeepAgentSession);\n\n // Per-render refs so the transport never remounts on a new closure identity\n // and always reads the latest policy.\n const onErrorRef = useRef(onError);\n onErrorRef.current = onError;\n const surfaceRef = useRef(surface);\n surfaceRef.current = surface;\n const onStateChangeRef = useRef(onStateChange);\n onStateChangeRef.current = onStateChange;\n const onCommandChangeRef = useRef(onCommandChange);\n onCommandChangeRef.current = onCommandChange;\n const foregroundRef = useRef(foreground);\n foregroundRef.current = foreground;\n const holdsHiddenReloads = foreground !== undefined;\n const diagnosticsRef = useRef(threadOptions.diagnostics);\n diagnosticsRef.current = threadOptions.diagnostics;\n const onBeforeSendRetryRef = useRef(onBeforeSendRetry);\n onBeforeSendRetryRef.current = onBeforeSendRetry;\n const clientRef = useRef<TClient | null>(null);\n\n // Where the persisted session record lives, for the recovery freshness gate\n // (read per sweep — undefined means \"no persistence, everything is fresh\").\n // The mounted `kind: 'storage'` session's store, so the gate reads the stored `ts` of a\n // failed send there too (a sealed IndexedDB record has no synchronous reader of its own).\n const storageSessionRef = useRef<StatewireClient.SessionStorage | null>(null);\n const observeStorageSession = useRef((store: StatewireClient.SessionStorage) => {\n storageSessionRef.current = store;\n }).current;\n const failureStampsRef = useRef<(() => ReadonlyMap<string, number> | null) | undefined>(\n undefined\n );\n failureStampsRef.current =\n session === false || session.kind === 'pending'\n ? undefined\n : session.kind === 'local-storage'\n ? canPersistLocalSession\n ? () =>\n readPersistedFailedSendStamps(\n localStorageSessionKey({\n namespace: session.namespace,\n principal: session.principal,\n threadId: threadOptions.threadId,\n })\n )\n : undefined\n : session.kind === 'session-store'\n ? () => readFailedSendStampsFromRecord(loadSessionRecord(session.store))\n : session.kind === 'storage'\n ? () => {\n const store = storageSessionRef.current;\n return store ? readFailedSendStampsFromRecord(loadSessionRecord(store)) : null;\n }\n : undefined;\n\n // A pending lane parks the thread under an attach identity of its own (see\n // `DeepAgentPendingSession`), so the attach once the lane is known is new.\n const sessionPending = session !== false && session.kind === 'pending';\n const attachKey = sessionPending\n ? pendingSessionAttachKey(threadOptions.attachKey)\n : threadOptions.attachKey;\n\n // The lane's scope, as the host's `key` names it: whose lanes this mount\n // runs on. A key that starts naming another principal's lanes starts a new\n // lane epoch, which remounts the whole thread on the new lane instead of\n // moving the mounted session there (see `DeepAgentSessionPersistence`).\n // Tracked whether or not this origin can persist: a process-local session\n // holds the previous principal's journal in memory just the same. A pending\n // lane keeps the last known scope, so a sign-out and a sign-in as someone\n // else with a gap between them is still a change.\n const laneNamespace =\n session !== false && session.kind === 'local-storage' ? session.namespace : null;\n const lanePrincipal =\n session !== false && session.kind === 'local-storage' ? session.principal : null;\n const laneKey = useMemo(\n () =>\n laneNamespace === null || lanePrincipal === null\n ? null\n : (threadId: string) =>\n localStorageSessionKey({\n namespace: laneNamespace,\n principal: lanePrincipal,\n threadId,\n }),\n [laneNamespace, lanePrincipal]\n );\n const [laneEpochState, setLaneEpochState] = useState(() =>\n nextSessionLaneEpoch({\n previous: INITIAL_SESSION_LANE_EPOCH,\n threadId: threadOptions.threadId,\n key: laneKey,\n })\n );\n const nextLaneEpochState = nextSessionLaneEpoch({\n previous: laneEpochState,\n threadId: threadOptions.threadId,\n key: laneKey,\n });\n // React's derived-state update: re-renders at once with the new epoch, and\n // this render already uses it, so no render pairs the new key with the\n // mounted thread.\n if (nextLaneEpochState !== laneEpochState) setLaneEpochState(nextLaneEpochState);\n const laneEpoch = nextLaneEpochState.epoch;\n\n // Send recovery, keyed by attach identity exactly like the thread's session\n // (a switch, re-attach or new lane epoch gets fresh hydration gating and\n // retry budgets, so it never re-dispatches a previous principal's failed\n // sends). The controller re-dispatches failed sends the server never judged;\n // see `send-recovery.ts` for the contract.\n const attachId = deepAgentAttachId({ threadId: threadOptions.threadId, attachKey, laneEpoch });\n // biome-ignore lint/correctness/useExhaustiveDependencies: keyed by attach identity on purpose; every other input is read through a per-render ref.\n const sendRecovery = useMemo(\n () =>\n createDeepAgentSendRecovery({\n outbox: () => {\n const client = clientRef.current;\n if (!client) return null;\n return readStatewireOutbox(client.thread().getState().extras);\n },\n failureStamps: () => failureStampsRef.current?.() ?? null,\n diagnostics: () => diagnosticsRef.current,\n beforeRetry: (messageId) => onBeforeSendRetryRef.current?.(messageId),\n }),\n [attachId]\n );\n useEffect(() => () => sendRecovery.dispose(), [sendRecovery]);\n const sendRecoveryRef = useRef(sendRecovery);\n sendRecoveryRef.current = sendRecovery;\n\n const thread = useDeepAgentThread({\n ...threadOptions,\n ...(attachKey !== undefined && { attachKey }),\n laneEpoch,\n // Parked without a message (a host suspension, when one applies, wins):\n // nothing dials and nothing journals until the lane is known. What paints\n // the first frame is the real attach's to report, not the park's.\n ...(sessionPending && {\n suspended: threadOptions.suspended || {},\n onAttachSource: undefined,\n }),\n // A pooled dial for the thread is the real attach's to take: a park that\n // only waits for the lane neither takes nor discards it. A host suspension\n // still discards it, as it does without a pending lane.\n ...(sessionPending && !threadOptions.suspended && { prewarmPool: undefined }),\n ...(session !== false &&\n session.kind === 'local-storage' &&\n canPersistLocalSession && {\n storage: {\n session: QuotaSafeLocalStorageSession({\n threadId: threadOptions.threadId,\n namespace: session.namespace,\n principal: session.principal,\n ...(session.unscopedPrefix !== undefined && { unscopedPrefix: session.unscopedPrefix }),\n ...(session.onStorageDegraded === undefined\n ? {}\n : { onStorageDegraded: session.onStorageDegraded }),\n }),\n },\n }),\n ...(session !== false && session.kind === 'session-store' && { sessionStore: session.store }),\n ...(session !== false &&\n session.kind === 'storage' && {\n storage: {\n session: ObservedSessionStorage({\n element: session.session(threadOptions.threadId),\n observe: observeStorageSession,\n }),\n },\n }),\n ...(holdsHiddenReloads && {\n onFlush: createChatOutboxFlushPolicy({\n foreground: () => foregroundRef.current?.get() ?? true,\n outbox: () => {\n const client = clientRef.current;\n if (!client) return null;\n const outbox = (client.thread().getState().extras as { outbox?: { hold?: unknown } } | undefined)?.outbox;\n return outbox && typeof outbox.hold === 'function' ? (outbox as { hold(id: string): void }) : null;\n },\n }),\n }),\n onStateChange: (state, ctx) => {\n onStateChangeRef.current?.(state, ctx);\n },\n // A durable `settled` update is acked once the returned promise resolves:\n // the host's handler and send recovery both finish before it is.\n onCommandChange: (update, ctx) => {\n const recovered = sendRecoveryRef.current.onCommandChange(update, ctx);\n const observed = onCommandChangeRef.current?.(update, ctx);\n if (recovered === undefined && !isPromiseLike(observed)) return observed;\n const settled = Promise.all([recovered, observed]).then(() => undefined);\n // Only a durable update's promise is awaited; never leave one unhandled.\n settled.catch(() => undefined);\n return settled;\n },\n onError: (error) => {\n const handler = onErrorRef.current;\n if (handler) {\n handler(error);\n return;\n }\n logUnhandledStatewireError(surfaceRef.current, error);\n },\n });\n\n const client = useClient(thread);\n clientRef.current = client;\n\n\n // Commands travel bare, so the runConfig that drives the run rides the\n // ambient model context: `contextSync: 'command-send'` mirrors it to the\n // server, which reads `config.runConfig` at command admission. The core pulls\n // on model-context notifications; the per-render ref ensures each pull uses\n // the latest closure but does not trigger a pull itself.\n const getRunConfigRef = useRef(runConfig?.get);\n getRunConfigRef.current = runConfig?.get;\n const hasRunConfig = runConfig !== undefined;\n const runConfigKey = runConfig?.key;\n // A host's own notifications (inputs that change outside React) pull too.\n const subscribeRunConfigRef = useRef(runConfig?.subscribe);\n subscribeRunConfigRef.current = runConfig?.subscribe;\n const hasRunConfigSubscribe = runConfig?.subscribe !== undefined;\n useEffect(() => {\n if (!hasRunConfig) return undefined;\n return registerDeepAgentRunConfig(\n client,\n () => getRunConfigRef.current?.() ?? {},\n hasRunConfigSubscribe\n ? (listener) => subscribeRunConfigRef.current?.(listener) ?? (() => {})\n : undefined\n );\n }, [client, hasRunConfig, runConfigKey, hasRunConfigSubscribe]);\n\n return client;\n}\n\n"],"names":["isStorageQuotaError","resource","useResource","isStatewireChannelTeardown","isConfigSyncUnavailableRejection","useState","useRef","readPersistedFailedSendStamps","localStorageSessionKey","readFailedSendStampsFromRecord","useMemo","nextSessionLaneEpoch","INITIAL_SESSION_LANE_EPOCH","deepAgentAttachId","sendRecovery","createDeepAgentSendRecovery","client","readStatewireOutbox","useEffect","useDeepAgentThread","QuotaSafeLocalStorageSession","createChatOutboxFlushPolicy","registerDeepAgentRunConfig"],"mappings":";;;;;;;;;;;;;AAuHO,SAAS,wBAAwB,WAAgD;AACtF,SAAO,mBAAmB,aAAa,EAAE;AAC3C;AA6BO,SAAS,6BAAsC;;AACpD,MAAI;AACF,UAAM,UAAU;AAChB,QAAI,GAAC,aAAQ,cAAR,mBAAmB,OAAO,QAAO;AACtC,UAAM,UAAU,QAAQ;AACxB,QAAI,CAAC,QAAS,QAAO;AACrB,UAAM,WAAW;AACjB,QAAI;AACF,cAAQ,QAAQ,UAAU,QAAQ;AAClC,cAAQ,WAAW,QAAQ;AAAA,IAC7B,SAAS,OAAO;AACd,aAAOA,6BAAAA,oBAAoB,KAAK;AAAA,IAClC;AACA,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAIA,SAAS,kBACP,OACmF;AACnF,MAAI;AACF,WAAO,MAAM,KAAA;AAAA,EACf,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAMA,MAAM,yBAAyBC,IAAAA,SAAS,SAAS,0BAA0B;AAAA,EACzE;AAAA,EACA;AACF,GAGmC;AACjC,QAAM,QAAQC,IAAAA,YAAY,OAAO;AACjC,UAAQ,KAAK;AACb,SAAO;AACT,CAAC;AAWM,SAAS,2BAA2B,SAAiB,OAAoB;AAC9E,MAAIC,OAAAA,2BAA2B,KAAK,GAAG;AACrC,YAAQ,MAAM,IAAI,OAAO,iCAAiC,KAAK;AAC/D;AAAA,EACF;AACA,MAAIC,mBAAAA,iCAAiC,KAAK,GAAG;AAC3C,YAAQ,MAAM,IAAI,OAAO,uDAAuD,KAAK;AACrF;AAAA,EACF;AACA,UAAQ,MAAM,IAAI,OAAO,gCAAgC,KAAK;AAChE;AA+EA,SAAS,cAAc,OAA+C;AACp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ACrC,QAAM,eAAe,cAAc;AACnC,QAAM,eAAe,uCAAW;AAEhC,QAAM,wBAAwBA,WAAAA,OAAO,uCAAW,SAAS;AACzD,wBAAsB,UAAU,uCAAW;AAC3C,QAAM,yBAAwB,uCAAW,eAAc;AACvDY,aAAAA,UAAU,MAAM;AACd,QAAI,CAAC,aAAc,QAAO;AAC1B,WAAOI,aAAAA;AAAAA,MACL;AAAA,MACA;;AAAM,sCAAgB,YAAhB,6CAA+B,CAAA;AAAA;AAAA,MACrC,wBACI,CAAC,aAAA;;AAAa,4CAAsB,YAAtB,+CAAgC,eAAc,MAAM;AAAA,QAAC;AAAA,UACnE;AAAA,IAAA;AAAA,EAER,GAAG,CAAC,QAAQ,cAAc,cAAc,qBAAqB,CAAC;AAE9D,SAAO;AACT;;;;;"}
@@ -1,3 +1,5 @@
1
+ import { type ResourceElement } from '@assistant-ui/tap';
2
+ import type { StatewireClient } from 'statewire';
1
3
  import { type DeepAgentModelContextHost } from './model-context';
2
4
  import { type SessionStorageDegradation } from './quota-safe-local-storage-session';
3
5
  import type { StatewireTransportOptions } from './statewire-transport';
@@ -19,9 +21,9 @@ export type DeepAgentThreadElement = ReturnType<typeof useDeepAgentThread>;
19
21
  * connection. Guarded by a shared availability probe: SSR, storage-blocked
20
22
  * iframes, and locked-down browsers keep the session process-local, exactly
21
23
  * as before the seam existed, while an origin that is merely full mounts the
22
- * session and lets it degrade. `key` scopes the stored lane — a thread id is
23
- * only meaningful against the backend (and, where relevant, principal) that
24
- * minted it, so include the sync-host URL.
24
+ * session and lets it degrade. `namespace` (the sync host) and `principal`
25
+ * (the signed-in account) scope the stored lane: a thread id is only
26
+ * meaningful against the backend and the principal that minted it.
25
27
  * - `session-store`: React Native hosts pass a hydrated library store backed
26
28
  * by AsyncStorage. Its synchronous `load()` is
27
29
  * also the send-recovery freshness gate's view of the persisted failed lane,
@@ -31,7 +33,7 @@ export type DeepAgentThreadElement = ReturnType<typeof useDeepAgentThread>;
31
33
  * host's signed-in user is still loading). See {@link DeepAgentPendingSession}.
32
34
  * - `false`: process-local session (a reload mints a new client).
33
35
  *
34
- * A `local-storage` `key` names one principal's lanes (and one backend's). The
36
+ * A `local-storage` `namespace` and `principal` name one principal's lanes (and one backend's). The
35
37
  * statewire session that mounts on a lane keeps the client id, lane clocks and
36
38
  * journal it loaded there, and everything in that journal is sent under
37
39
  * whatever credential the transport holds at its next attach. So a mounted
@@ -44,19 +46,35 @@ export type DeepAgentThreadElement = ReturnType<typeof useDeepAgentThread>;
44
46
  * principal's record stays where it is, with its client id and whatever it had
45
47
  * journaled and not yet delivered: that principal's next mount on this browser
46
48
  * resends it as them, and the retention sweep retires it otherwise. It is never
47
- * sent as anyone else. A key for the same principal (a token refresh, a fresh
48
- * `key` function) and a thread switch keep the lane as it is. A host whose
49
+ * sent as anyone else. The same principal again (a token refresh, a fresh
50
+ * persistence object) and a thread switch keep the lane as it is. A host whose
49
51
  * principal arrives after mount passes `pending` until it does, never a
50
52
  * stand-in key: moving off a stand-in would be a principal change, a second
51
53
  * attach.
52
54
  */
53
55
  export type DeepAgentSessionPersistence = {
54
56
  kind: 'local-storage';
55
- key: (threadId: string) => string;
57
+ /** The backend the lanes belong to, as a key prefix: the sync host and `:`. */
58
+ namespace: string;
59
+ /** The signed-in account the lanes belong to (`sessionPrincipal(userId)`). */
60
+ principal: string;
61
+ /**
62
+ * Where statewire 0.24 kept this account's lanes (`<syncUrl>:<userId>:`): a thread's lane
63
+ * there moves under its scoped key on mount (`adoptUnscopedLocalStorageSessions`).
64
+ */
65
+ unscopedPrefix?: string;
56
66
  onStorageDegraded?: (degradation: SessionStorageDegradation) => void;
57
67
  } | {
58
68
  kind: 'session-store';
59
69
  store: NonNullable<StatewireTransportOptions['sessionStore']>;
70
+ } | {
71
+ kind: 'storage';
72
+ /**
73
+ * The thread's mounted session storage (`ChatSessionStorage`: sealed IndexedDB, or page
74
+ * memory where devices keep no copies), made per thread. The surfaces that keep a chat
75
+ * outbox use it: the outbox is the session's outbox.
76
+ */
77
+ session: (threadId: string) => ResourceElement<StatewireClient.SessionStorage>;
60
78
  } | DeepAgentPendingSession | false;
61
79
  /**
62
80
  * The durable lane's principal is not known yet. A lane belongs to one
@@ -174,6 +192,15 @@ export interface UseDeepAgentRuntimeOptions<TClient extends DeepAgentModelContex
174
192
  * A function returned is called when the retry does not go after all.
175
193
  */
176
194
  onBeforeSendRetry?: (messageId: string) => void | PromiseLike<void> | (() => void);
195
+ /**
196
+ * Whether the app is in front (a visible tab, a focused desktop window). While it says no, the
197
+ * message sends a flush offers as queued before this page mounted are held, so a hidden tab never
198
+ * sends a backlog; the visible tab's chat outbox counts them down and sends them. Omitted, every
199
+ * tab sends them.
200
+ */
201
+ foreground?: {
202
+ get(): boolean;
203
+ };
177
204
  }
178
205
  /**
179
206
  * The configurable deep-agent statewire runtime — the one hook every Athena