@athenaintel/react 0.57.2 → 0.60.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (852) hide show
  1. package/README.md +795 -12
  2. package/dist/agent-runtime/src/addressed-agents.cjs +16 -0
  3. package/dist/agent-runtime/src/addressed-agents.cjs.map +1 -0
  4. package/dist/agent-runtime/src/addressed-agents.d.ts +30 -0
  5. package/dist/agent-runtime/src/addressed-agents.js +16 -0
  6. package/dist/agent-runtime/src/addressed-agents.js.map +1 -0
  7. package/dist/agent-runtime/src/answer-label.cjs +4 -3
  8. package/dist/agent-runtime/src/answer-label.cjs.map +1 -1
  9. package/dist/agent-runtime/src/answer-label.d.ts +13 -6
  10. package/dist/agent-runtime/src/answer-label.js +4 -3
  11. package/dist/agent-runtime/src/answer-label.js.map +1 -1
  12. package/dist/agent-runtime/src/chat-outbox-attachments.cjs.map +1 -1
  13. package/dist/agent-runtime/src/chat-outbox-attachments.d.ts +1 -1
  14. package/dist/agent-runtime/src/chat-outbox-attachments.js.map +1 -1
  15. package/dist/agent-runtime/src/chat-outbox-entry.cjs +101 -0
  16. package/dist/agent-runtime/src/chat-outbox-entry.cjs.map +1 -0
  17. package/dist/agent-runtime/src/chat-outbox-entry.d.ts +99 -0
  18. package/dist/agent-runtime/src/chat-outbox-entry.js +101 -0
  19. package/dist/agent-runtime/src/chat-outbox-entry.js.map +1 -0
  20. package/dist/agent-runtime/src/chat-outbox-legacy.cjs +252 -0
  21. package/dist/agent-runtime/src/chat-outbox-legacy.cjs.map +1 -0
  22. package/dist/agent-runtime/src/chat-outbox-legacy.d.ts +96 -0
  23. package/dist/agent-runtime/src/chat-outbox-legacy.js +252 -0
  24. package/dist/agent-runtime/src/chat-outbox-legacy.js.map +1 -0
  25. package/dist/agent-runtime/src/chat-outbox-policy.cjs +30 -0
  26. package/dist/agent-runtime/src/chat-outbox-policy.cjs.map +1 -0
  27. package/dist/agent-runtime/src/chat-outbox-policy.d.ts +42 -0
  28. package/dist/agent-runtime/src/chat-outbox-policy.js +30 -0
  29. package/dist/agent-runtime/src/chat-outbox-policy.js.map +1 -0
  30. package/dist/agent-runtime/src/chat-outbox-storage.cjs +306 -0
  31. package/dist/agent-runtime/src/chat-outbox-storage.cjs.map +1 -0
  32. package/dist/agent-runtime/src/chat-outbox-storage.d.ts +194 -0
  33. package/dist/agent-runtime/src/chat-outbox-storage.js +306 -0
  34. package/dist/agent-runtime/src/chat-outbox-storage.js.map +1 -0
  35. package/dist/agent-runtime/src/chat-outbox-thread.cjs +21 -94
  36. package/dist/agent-runtime/src/chat-outbox-thread.cjs.map +1 -1
  37. package/dist/agent-runtime/src/chat-outbox-thread.d.ts +22 -18
  38. package/dist/agent-runtime/src/chat-outbox-thread.js +21 -94
  39. package/dist/agent-runtime/src/chat-outbox-thread.js.map +1 -1
  40. package/dist/agent-runtime/src/chat-outbox.cjs +492 -547
  41. package/dist/agent-runtime/src/chat-outbox.cjs.map +1 -1
  42. package/dist/agent-runtime/src/chat-outbox.d.ts +110 -142
  43. package/dist/agent-runtime/src/chat-outbox.js +492 -547
  44. package/dist/agent-runtime/src/chat-outbox.js.map +1 -1
  45. package/dist/agent-runtime/src/composer-markdown.cjs +0 -16
  46. package/dist/agent-runtime/src/composer-markdown.cjs.map +1 -1
  47. package/dist/agent-runtime/src/composer-markdown.d.ts +1 -1
  48. package/dist/agent-runtime/src/composer-markdown.js +1 -17
  49. package/dist/agent-runtime/src/composer-markdown.js.map +1 -1
  50. package/dist/agent-runtime/src/deep-agent-transport-recipe.cjs +3 -1
  51. package/dist/agent-runtime/src/deep-agent-transport-recipe.cjs.map +1 -1
  52. package/dist/agent-runtime/src/deep-agent-transport-recipe.d.ts +8 -1
  53. package/dist/agent-runtime/src/deep-agent-transport-recipe.js +3 -1
  54. package/dist/agent-runtime/src/deep-agent-transport-recipe.js.map +1 -1
  55. package/dist/agent-runtime/src/dictation-preferences.d.ts +356 -0
  56. package/dist/agent-runtime/src/dictation-record.d.ts +279 -0
  57. package/dist/agent-runtime/src/dictation-session.d.ts +106 -7
  58. package/dist/agent-runtime/src/dictation-snippets.d.ts +9 -0
  59. package/dist/agent-runtime/src/dictation-transfer.d.ts +142 -0
  60. package/dist/agent-runtime/src/edit-command.cjs.map +1 -1
  61. package/dist/agent-runtime/src/edit-command.d.ts +1 -1
  62. package/dist/agent-runtime/src/edit-command.js.map +1 -1
  63. package/dist/agent-runtime/src/errors.cjs +1 -0
  64. package/dist/agent-runtime/src/errors.cjs.map +1 -1
  65. package/dist/agent-runtime/src/errors.js +1 -0
  66. package/dist/agent-runtime/src/errors.js.map +1 -1
  67. package/dist/agent-runtime/src/generated/runconfig-contract.cjs +24 -0
  68. package/dist/agent-runtime/src/generated/runconfig-contract.cjs.map +1 -1
  69. package/dist/agent-runtime/src/generated/runconfig-contract.d.ts +3 -3
  70. package/dist/agent-runtime/src/generated/runconfig-contract.js +24 -0
  71. package/dist/agent-runtime/src/generated/runconfig-contract.js.map +1 -1
  72. package/dist/agent-runtime/src/index.d.ts +14 -8
  73. package/dist/agent-runtime/src/lane-follow.cjs +289 -0
  74. package/dist/agent-runtime/src/lane-follow.cjs.map +1 -0
  75. package/dist/agent-runtime/src/lane-follow.js +289 -0
  76. package/dist/agent-runtime/src/lane-follow.js.map +1 -0
  77. package/dist/agent-runtime/src/lane-images.cjs +387 -0
  78. package/dist/agent-runtime/src/lane-images.cjs.map +1 -0
  79. package/dist/agent-runtime/src/lane-images.js +387 -0
  80. package/dist/agent-runtime/src/lane-images.js.map +1 -0
  81. package/dist/agent-runtime/src/message-window.js +1 -1
  82. package/dist/agent-runtime/src/messages.cjs +19 -1
  83. package/dist/agent-runtime/src/messages.cjs.map +1 -1
  84. package/dist/agent-runtime/src/messages.d.ts +8 -0
  85. package/dist/agent-runtime/src/messages.js +21 -3
  86. package/dist/agent-runtime/src/messages.js.map +1 -1
  87. package/dist/agent-runtime/src/named-agents.cjs +301 -0
  88. package/dist/agent-runtime/src/named-agents.cjs.map +1 -0
  89. package/dist/agent-runtime/src/named-agents.d.ts +246 -0
  90. package/dist/agent-runtime/src/named-agents.js +301 -0
  91. package/dist/agent-runtime/src/named-agents.js.map +1 -0
  92. package/dist/agent-runtime/src/offline-status.cjs.map +1 -1
  93. package/dist/agent-runtime/src/offline-status.d.ts +93 -2
  94. package/dist/agent-runtime/src/offline-status.js.map +1 -1
  95. package/dist/agent-runtime/src/ptc-subcalls.cjs +41 -0
  96. package/dist/agent-runtime/src/ptc-subcalls.cjs.map +1 -0
  97. package/dist/agent-runtime/src/ptc-subcalls.js +41 -0
  98. package/dist/agent-runtime/src/ptc-subcalls.js.map +1 -0
  99. package/dist/agent-runtime/src/queue.cjs +2 -2
  100. package/dist/agent-runtime/src/queue.cjs.map +1 -1
  101. package/dist/agent-runtime/src/queue.d.ts +20 -25
  102. package/dist/agent-runtime/src/queue.js +2 -2
  103. package/dist/agent-runtime/src/queue.js.map +1 -1
  104. package/dist/agent-runtime/src/quota-safe-local-storage-session.cjs +314 -84
  105. package/dist/agent-runtime/src/quota-safe-local-storage-session.cjs.map +1 -1
  106. package/dist/agent-runtime/src/quota-safe-local-storage-session.d.ts +137 -40
  107. package/dist/agent-runtime/src/quota-safe-local-storage-session.js +318 -88
  108. package/dist/agent-runtime/src/quota-safe-local-storage-session.js.map +1 -1
  109. package/dist/agent-runtime/src/run-send.cjs +54 -0
  110. package/dist/agent-runtime/src/run-send.cjs.map +1 -0
  111. package/dist/agent-runtime/src/run-send.d.ts +51 -0
  112. package/dist/agent-runtime/src/run-send.js +54 -0
  113. package/dist/agent-runtime/src/run-send.js.map +1 -0
  114. package/dist/agent-runtime/src/running-tool-placeholder.cjs +6 -0
  115. package/dist/agent-runtime/src/running-tool-placeholder.cjs.map +1 -1
  116. package/dist/agent-runtime/src/running-tool-placeholder.js +6 -0
  117. package/dist/agent-runtime/src/running-tool-placeholder.js.map +1 -1
  118. package/dist/agent-runtime/src/runtime.d.ts +9 -5
  119. package/dist/agent-runtime/src/sealed-idb.cjs +64 -0
  120. package/dist/agent-runtime/src/sealed-idb.cjs.map +1 -1
  121. package/dist/agent-runtime/src/sealed-idb.d.ts +16 -0
  122. package/dist/agent-runtime/src/sealed-idb.js +64 -0
  123. package/dist/agent-runtime/src/sealed-idb.js.map +1 -1
  124. package/dist/agent-runtime/src/send-recovery.cjs +90 -118
  125. package/dist/agent-runtime/src/send-recovery.cjs.map +1 -1
  126. package/dist/agent-runtime/src/send-recovery.d.ts +25 -29
  127. package/dist/agent-runtime/src/send-recovery.js +90 -118
  128. package/dist/agent-runtime/src/send-recovery.js.map +1 -1
  129. package/dist/agent-runtime/src/statewire-diagnostics.d.ts +4 -1
  130. package/dist/agent-runtime/src/statewire-held-sends.cjs +191 -0
  131. package/dist/agent-runtime/src/statewire-held-sends.cjs.map +1 -0
  132. package/dist/agent-runtime/src/statewire-held-sends.d.ts +119 -0
  133. package/dist/agent-runtime/src/statewire-held-sends.js +191 -0
  134. package/dist/agent-runtime/src/statewire-held-sends.js.map +1 -0
  135. package/dist/agent-runtime/src/statewire-state.cjs +4 -0
  136. package/dist/agent-runtime/src/statewire-state.cjs.map +1 -1
  137. package/dist/agent-runtime/src/statewire-state.js +4 -0
  138. package/dist/agent-runtime/src/statewire-state.js.map +1 -1
  139. package/dist/agent-runtime/src/statewire-transport.cjs +8 -2
  140. package/dist/agent-runtime/src/statewire-transport.cjs.map +1 -1
  141. package/dist/agent-runtime/src/statewire-transport.d.ts +14 -5
  142. package/dist/agent-runtime/src/statewire-transport.js +8 -2
  143. package/dist/agent-runtime/src/statewire-transport.js.map +1 -1
  144. package/dist/agent-runtime/src/subagent-transcripts.cjs +1 -23
  145. package/dist/agent-runtime/src/subagent-transcripts.cjs.map +1 -1
  146. package/dist/agent-runtime/src/subagent-transcripts.js +3 -25
  147. package/dist/agent-runtime/src/subagent-transcripts.js.map +1 -1
  148. package/dist/agent-runtime/src/subagents.cjs +22 -29
  149. package/dist/agent-runtime/src/subagents.cjs.map +1 -1
  150. package/dist/agent-runtime/src/subagents.js +23 -30
  151. package/dist/agent-runtime/src/subagents.js.map +1 -1
  152. package/dist/agent-runtime/src/thread-extras.cjs +27 -19
  153. package/dist/agent-runtime/src/thread-extras.cjs.map +1 -1
  154. package/dist/agent-runtime/src/thread-extras.d.ts +19 -6
  155. package/dist/agent-runtime/src/thread-extras.js +27 -19
  156. package/dist/agent-runtime/src/thread-extras.js.map +1 -1
  157. package/dist/agent-runtime/src/thread-handoff-flow-machine.d.ts +8 -8
  158. package/dist/agent-runtime/src/tool-metadata.cjs +19 -0
  159. package/dist/agent-runtime/src/tool-metadata.cjs.map +1 -1
  160. package/dist/agent-runtime/src/tool-metadata.js +19 -0
  161. package/dist/agent-runtime/src/tool-metadata.js.map +1 -1
  162. package/dist/agent-runtime/src/tool-names.cjs +21 -0
  163. package/dist/agent-runtime/src/tool-names.cjs.map +1 -1
  164. package/dist/agent-runtime/src/tool-names.d.ts +8 -0
  165. package/dist/agent-runtime/src/tool-names.js +21 -0
  166. package/dist/agent-runtime/src/tool-names.js.map +1 -1
  167. package/dist/agent-runtime/src/typed-interrupt-kinds.cjs +247 -0
  168. package/dist/agent-runtime/src/typed-interrupt-kinds.cjs.map +1 -0
  169. package/dist/agent-runtime/src/typed-interrupt-kinds.d.ts +173 -0
  170. package/dist/agent-runtime/src/typed-interrupt-kinds.js +247 -0
  171. package/dist/agent-runtime/src/typed-interrupt-kinds.js.map +1 -0
  172. package/dist/agent-runtime/src/typed-interrupts.cjs +48 -0
  173. package/dist/agent-runtime/src/typed-interrupts.cjs.map +1 -0
  174. package/dist/agent-runtime/src/typed-interrupts.d.ts +75 -0
  175. package/dist/agent-runtime/src/typed-interrupts.js +48 -0
  176. package/dist/agent-runtime/src/typed-interrupts.js.map +1 -0
  177. package/dist/agent-runtime/src/types.d.ts +1 -1
  178. package/dist/agent-runtime/src/use-conversation-list.cjs +1 -0
  179. package/dist/agent-runtime/src/use-conversation-list.cjs.map +1 -1
  180. package/dist/agent-runtime/src/use-conversation-list.d.ts +7 -0
  181. package/dist/agent-runtime/src/use-conversation-list.js +1 -0
  182. package/dist/agent-runtime/src/use-conversation-list.js.map +1 -1
  183. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.cjs +46 -29
  184. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.cjs.map +1 -1
  185. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.d.ts +14 -22
  186. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.js +46 -29
  187. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.js.map +1 -1
  188. package/dist/agent-runtime/src/use-deep-agent-runtime.cjs +78 -14
  189. package/dist/agent-runtime/src/use-deep-agent-runtime.cjs.map +1 -1
  190. package/dist/agent-runtime/src/use-deep-agent-runtime.d.ts +34 -7
  191. package/dist/agent-runtime/src/use-deep-agent-runtime.js +79 -15
  192. package/dist/agent-runtime/src/use-deep-agent-runtime.js.map +1 -1
  193. package/dist/agent-runtime/src/use-deep-agent-thread.cjs +16 -1
  194. package/dist/agent-runtime/src/use-deep-agent-thread.cjs.map +1 -1
  195. package/dist/agent-runtime/src/use-deep-agent-thread.d.ts +7 -2
  196. package/dist/agent-runtime/src/use-deep-agent-thread.js +16 -1
  197. package/dist/agent-runtime/src/use-deep-agent-thread.js.map +1 -1
  198. package/dist/agent-runtime/src/use-deep-agent-voice.cjs +30 -4
  199. package/dist/agent-runtime/src/use-deep-agent-voice.cjs.map +1 -1
  200. package/dist/agent-runtime/src/use-deep-agent-voice.d.ts +22 -4
  201. package/dist/agent-runtime/src/use-deep-agent-voice.js +30 -4
  202. package/dist/agent-runtime/src/use-deep-agent-voice.js.map +1 -1
  203. package/dist/agent-runtime/src/withdrawn-turns.d.ts +5 -4
  204. package/dist/agent-runtime/src/word-device-fit.d.ts +174 -0
  205. package/dist/agent-runtime/src/work-in.d.ts +127 -0
  206. package/dist/assets/AthenaAssetEmbed.cjs.map +1 -1
  207. package/dist/assets/AthenaAssetEmbed.d.ts +6 -1
  208. package/dist/assets/AthenaAssetEmbed.js.map +1 -1
  209. package/dist/assets/asset-panel-store.cjs +13 -5
  210. package/dist/assets/asset-panel-store.cjs.map +1 -1
  211. package/dist/assets/asset-panel-store.d.ts +33 -2
  212. package/dist/assets/asset-panel-store.js +13 -5
  213. package/dist/assets/asset-panel-store.js.map +1 -1
  214. package/dist/auth/AthenaCredentialSourceContext.cjs +11 -0
  215. package/dist/auth/AthenaCredentialSourceContext.cjs.map +1 -1
  216. package/dist/auth/AthenaCredentialSourceContext.d.ts +6 -0
  217. package/dist/auth/AthenaCredentialSourceContext.js +11 -0
  218. package/dist/auth/AthenaCredentialSourceContext.js.map +1 -1
  219. package/dist/auth/account-identity.cjs +13 -2
  220. package/dist/auth/account-identity.cjs.map +1 -1
  221. package/dist/auth/account-identity.d.ts +9 -0
  222. package/dist/auth/account-identity.js +13 -2
  223. package/dist/auth/account-identity.js.map +1 -1
  224. package/dist/auth/credential-source.cjs +20 -4
  225. package/dist/auth/credential-source.cjs.map +1 -1
  226. package/dist/auth/credential-source.d.ts +9 -0
  227. package/dist/auth/credential-source.js +20 -4
  228. package/dist/auth/credential-source.js.map +1 -1
  229. package/dist/catalog/chat-pickers.cjs +31 -0
  230. package/dist/catalog/chat-pickers.cjs.map +1 -1
  231. package/dist/catalog/chat-pickers.d.ts +17 -0
  232. package/dist/catalog/chat-pickers.js +33 -2
  233. package/dist/catalog/chat-pickers.js.map +1 -1
  234. package/dist/catalog/runtime-catalog.cjs +63 -3
  235. package/dist/catalog/runtime-catalog.cjs.map +1 -1
  236. package/dist/catalog/runtime-catalog.d.ts +63 -3
  237. package/dist/catalog/runtime-catalog.js +64 -4
  238. package/dist/catalog/runtime-catalog.js.map +1 -1
  239. package/dist/chat/AthenaChat.cjs +301 -98
  240. package/dist/chat/AthenaChat.cjs.map +1 -1
  241. package/dist/chat/AthenaChat.d.ts +80 -4
  242. package/dist/chat/AthenaChat.js +302 -99
  243. package/dist/chat/AthenaChat.js.map +1 -1
  244. package/dist/chat/StatewireApprovalCard.cjs +35 -5
  245. package/dist/chat/StatewireApprovalCard.cjs.map +1 -1
  246. package/dist/chat/StatewireApprovalCard.d.ts +55 -2
  247. package/dist/chat/StatewireApprovalCard.js +37 -7
  248. package/dist/chat/StatewireApprovalCard.js.map +1 -1
  249. package/dist/chat/StatewireQueuedMessages.cjs +17 -2
  250. package/dist/chat/StatewireQueuedMessages.cjs.map +1 -1
  251. package/dist/chat/StatewireQueuedMessages.d.ts +8 -45
  252. package/dist/chat/StatewireQueuedMessages.js +18 -3
  253. package/dist/chat/StatewireQueuedMessages.js.map +1 -1
  254. package/dist/chat/chat-agent-mentions.cjs +70 -0
  255. package/dist/chat/chat-agent-mentions.cjs.map +1 -0
  256. package/dist/chat/chat-agent-mentions.d.ts +13 -0
  257. package/dist/chat/chat-agent-mentions.js +70 -0
  258. package/dist/chat/chat-agent-mentions.js.map +1 -0
  259. package/dist/chat/composer-actions.cjs +12 -0
  260. package/dist/chat/composer-actions.cjs.map +1 -0
  261. package/dist/chat/composer-actions.d.ts +22 -0
  262. package/dist/chat/composer-actions.js +12 -0
  263. package/dist/chat/composer-actions.js.map +1 -0
  264. package/dist/chat/follow-up-suggestions.cjs +185 -0
  265. package/dist/chat/follow-up-suggestions.cjs.map +1 -0
  266. package/dist/chat/follow-up-suggestions.d.ts +64 -0
  267. package/dist/chat/follow-up-suggestions.js +185 -0
  268. package/dist/chat/follow-up-suggestions.js.map +1 -0
  269. package/dist/chat/super-grouping/ToolTimeline.cjs +4 -3
  270. package/dist/chat/super-grouping/ToolTimeline.cjs.map +1 -1
  271. package/dist/chat/super-grouping/ToolTimeline.d.ts +7 -3
  272. package/dist/chat/super-grouping/ToolTimeline.js +4 -3
  273. package/dist/chat/super-grouping/ToolTimeline.js.map +1 -1
  274. package/dist/chat/turn-changes.cjs +284 -0
  275. package/dist/chat/turn-changes.cjs.map +1 -0
  276. package/dist/chat/turn-changes.d.ts +130 -0
  277. package/dist/chat/turn-changes.js +284 -0
  278. package/dist/chat/turn-changes.js.map +1 -0
  279. package/dist/chat/typed-interrupts/StatewireTypedInterruptCard.cjs +31 -0
  280. package/dist/chat/typed-interrupts/StatewireTypedInterruptCard.cjs.map +1 -0
  281. package/dist/chat/typed-interrupts/StatewireTypedInterruptCard.d.ts +31 -0
  282. package/dist/chat/typed-interrupts/StatewireTypedInterruptCard.js +31 -0
  283. package/dist/chat/typed-interrupts/StatewireTypedInterruptCard.js.map +1 -0
  284. package/dist/chat/typed-interrupts/approval-cards.cjs +250 -0
  285. package/dist/chat/typed-interrupts/approval-cards.cjs.map +1 -0
  286. package/dist/chat/typed-interrupts/approval-cards.d.ts +22 -0
  287. package/dist/chat/typed-interrupts/approval-cards.js +250 -0
  288. package/dist/chat/typed-interrupts/approval-cards.js.map +1 -0
  289. package/dist/chat/typed-interrupts/form-cards.cjs +289 -0
  290. package/dist/chat/typed-interrupts/form-cards.cjs.map +1 -0
  291. package/dist/chat/typed-interrupts/form-cards.d.ts +6 -0
  292. package/dist/chat/typed-interrupts/form-cards.js +289 -0
  293. package/dist/chat/typed-interrupts/form-cards.js.map +1 -0
  294. package/dist/chat/typed-interrupts/interrupt-card-shell.cjs +182 -0
  295. package/dist/chat/typed-interrupts/interrupt-card-shell.cjs.map +1 -0
  296. package/dist/chat/typed-interrupts/interrupt-card-shell.d.ts +47 -0
  297. package/dist/chat/typed-interrupts/interrupt-card-shell.js +182 -0
  298. package/dist/chat/typed-interrupts/interrupt-card-shell.js.map +1 -0
  299. package/dist/chat/typed-interrupts/json-schema-form.cjs +388 -0
  300. package/dist/chat/typed-interrupts/json-schema-form.cjs.map +1 -0
  301. package/dist/chat/typed-interrupts/json-schema-form.d.ts +33 -0
  302. package/dist/chat/typed-interrupts/json-schema-form.js +388 -0
  303. package/dist/chat/typed-interrupts/json-schema-form.js.map +1 -0
  304. package/dist/chat/typed-interrupts/questionnaire-card.cjs +449 -0
  305. package/dist/chat/typed-interrupts/questionnaire-card.cjs.map +1 -0
  306. package/dist/chat/typed-interrupts/questionnaire-card.d.ts +20 -0
  307. package/dist/chat/typed-interrupts/questionnaire-card.js +449 -0
  308. package/dist/chat/typed-interrupts/questionnaire-card.js.map +1 -0
  309. package/dist/chat/typed-interrupts/request-file-card.cjs +159 -0
  310. package/dist/chat/typed-interrupts/request-file-card.cjs.map +1 -0
  311. package/dist/chat/typed-interrupts/request-file-card.d.ts +2 -0
  312. package/dist/chat/typed-interrupts/request-file-card.js +159 -0
  313. package/dist/chat/typed-interrupts/request-file-card.js.map +1 -0
  314. package/dist/chat/typed-interrupts/toolkit-selection-card.cjs +189 -0
  315. package/dist/chat/typed-interrupts/toolkit-selection-card.cjs.map +1 -0
  316. package/dist/chat/typed-interrupts/toolkit-selection-card.d.ts +23 -0
  317. package/dist/chat/typed-interrupts/toolkit-selection-card.js +189 -0
  318. package/dist/chat/typed-interrupts/toolkit-selection-card.js.map +1 -0
  319. package/dist/chat/typed-interrupts/typed-interrupt-body.cjs +26 -0
  320. package/dist/chat/typed-interrupts/typed-interrupt-body.cjs.map +1 -0
  321. package/dist/chat/typed-interrupts/typed-interrupt-body.d.ts +3 -0
  322. package/dist/chat/typed-interrupts/typed-interrupt-body.js +26 -0
  323. package/dist/chat/typed-interrupts/typed-interrupt-body.js.map +1 -0
  324. package/dist/chat/typed-interrupts/typed-interrupt-graphql.cjs +105 -0
  325. package/dist/chat/typed-interrupts/typed-interrupt-graphql.cjs.map +1 -0
  326. package/dist/chat/typed-interrupts/typed-interrupt-graphql.d.ts +29 -0
  327. package/dist/chat/typed-interrupts/typed-interrupt-graphql.js +105 -0
  328. package/dist/chat/typed-interrupts/typed-interrupt-graphql.js.map +1 -0
  329. package/dist/chat/typed-interrupts/typed-interrupt-notice.cjs +70 -0
  330. package/dist/chat/typed-interrupts/typed-interrupt-notice.cjs.map +1 -0
  331. package/dist/chat/typed-interrupts/typed-interrupt-notice.d.ts +45 -0
  332. package/dist/chat/typed-interrupts/typed-interrupt-notice.js +70 -0
  333. package/dist/chat/typed-interrupts/typed-interrupt-notice.js.map +1 -0
  334. package/dist/chat/typed-interrupts/typed-interrupt-panel.cjs +76 -0
  335. package/dist/chat/typed-interrupts/typed-interrupt-panel.cjs.map +1 -0
  336. package/dist/chat/typed-interrupts/typed-interrupt-panel.d.ts +11 -0
  337. package/dist/chat/typed-interrupts/typed-interrupt-panel.js +76 -0
  338. package/dist/chat/typed-interrupts/typed-interrupt-panel.js.map +1 -0
  339. package/dist/chat/typed-interrupts/typed-interrupt-types.d.ts +46 -0
  340. package/dist/chat/typed-interrupts/use-interrupt-draft.cjs +106 -0
  341. package/dist/chat/typed-interrupts/use-interrupt-draft.cjs.map +1 -0
  342. package/dist/chat/typed-interrupts/use-interrupt-draft.d.ts +29 -0
  343. package/dist/chat/typed-interrupts/use-interrupt-draft.js +106 -0
  344. package/dist/chat/typed-interrupts/use-interrupt-draft.js.map +1 -0
  345. package/dist/chat/typed-interrupts/use-statewire-typed-interrupt.cjs +231 -0
  346. package/dist/chat/typed-interrupts/use-statewire-typed-interrupt.cjs.map +1 -0
  347. package/dist/chat/typed-interrupts/use-statewire-typed-interrupt.d.ts +66 -0
  348. package/dist/chat/typed-interrupts/use-statewire-typed-interrupt.js +231 -0
  349. package/dist/chat/typed-interrupts/use-statewire-typed-interrupt.js.map +1 -0
  350. package/dist/chat-ui/composer/composer-named-agents.cjs +13 -0
  351. package/dist/chat-ui/composer/composer-named-agents.cjs.map +1 -0
  352. package/dist/chat-ui/composer/composer-named-agents.d.ts +20 -0
  353. package/dist/chat-ui/composer/composer-named-agents.js +13 -0
  354. package/dist/chat-ui/composer/composer-named-agents.js.map +1 -0
  355. package/dist/chat-ui/composer/slash-command-menu.cjs +143 -0
  356. package/dist/chat-ui/composer/slash-command-menu.cjs.map +1 -0
  357. package/dist/chat-ui/composer/slash-command-menu.d.ts +19 -0
  358. package/dist/chat-ui/composer/slash-command-menu.js +143 -0
  359. package/dist/chat-ui/composer/slash-command-menu.js.map +1 -0
  360. package/dist/chat-ui/composer/slash-commands-extension.cjs +51 -0
  361. package/dist/chat-ui/composer/slash-commands-extension.cjs.map +1 -0
  362. package/dist/chat-ui/composer/slash-commands-extension.d.ts +39 -0
  363. package/dist/chat-ui/composer/slash-commands-extension.js +51 -0
  364. package/dist/chat-ui/composer/slash-commands-extension.js.map +1 -0
  365. package/dist/chat-ui/composer/slash-commands.cjs +74 -0
  366. package/dist/chat-ui/composer/slash-commands.cjs.map +1 -0
  367. package/dist/chat-ui/composer/slash-commands.d.ts +82 -0
  368. package/dist/chat-ui/composer/slash-commands.js +74 -0
  369. package/dist/chat-ui/composer/slash-commands.js.map +1 -0
  370. package/dist/chat-ui/composer/tiptap-composer.cjs +135 -9
  371. package/dist/chat-ui/composer/tiptap-composer.cjs.map +1 -1
  372. package/dist/chat-ui/composer/tiptap-composer.d.ts +61 -2
  373. package/dist/chat-ui/composer/tiptap-composer.js +135 -9
  374. package/dist/chat-ui/composer/tiptap-composer.js.map +1 -1
  375. package/dist/chat-ui/index.cjs +5 -0
  376. package/dist/chat-ui/index.cjs.map +1 -1
  377. package/dist/chat-ui/index.d.ts +4 -2
  378. package/dist/chat-ui/index.js +5 -0
  379. package/dist/chat-ui/index.js.map +1 -1
  380. package/dist/chat-ui/mentions/mention-chip.cjs +10 -4
  381. package/dist/chat-ui/mentions/mention-chip.cjs.map +1 -1
  382. package/dist/chat-ui/mentions/mention-chip.js +11 -5
  383. package/dist/chat-ui/mentions/mention-chip.js.map +1 -1
  384. package/dist/chat-ui/mentions/mention-extension.cjs +8 -1
  385. package/dist/chat-ui/mentions/mention-extension.cjs.map +1 -1
  386. package/dist/chat-ui/mentions/mention-extension.js +8 -1
  387. package/dist/chat-ui/mentions/mention-extension.js.map +1 -1
  388. package/dist/chat-ui/mentions/suggestions/components/get-scope-name.cjs +1 -0
  389. package/dist/chat-ui/mentions/suggestions/components/get-scope-name.cjs.map +1 -1
  390. package/dist/chat-ui/mentions/suggestions/components/get-scope-name.js +1 -0
  391. package/dist/chat-ui/mentions/suggestions/components/get-scope-name.js.map +1 -1
  392. package/dist/chat-ui/mentions/suggestions/components/mention-icon.cjs +20 -2
  393. package/dist/chat-ui/mentions/suggestions/components/mention-icon.cjs.map +1 -1
  394. package/dist/chat-ui/mentions/suggestions/components/mention-icon.d.ts +10 -1
  395. package/dist/chat-ui/mentions/suggestions/components/mention-icon.js +22 -4
  396. package/dist/chat-ui/mentions/suggestions/components/mention-icon.js.map +1 -1
  397. package/dist/chat-ui/mentions/suggestions/components/menu-item.cjs +1 -1
  398. package/dist/chat-ui/mentions/suggestions/components/menu-item.cjs.map +1 -1
  399. package/dist/chat-ui/mentions/suggestions/components/menu-item.js +1 -1
  400. package/dist/chat-ui/mentions/suggestions/components/menu-item.js.map +1 -1
  401. package/dist/chat-ui/mentions/suggestions/data/api-client.cjs +45 -0
  402. package/dist/chat-ui/mentions/suggestions/data/api-client.cjs.map +1 -1
  403. package/dist/chat-ui/mentions/suggestions/data/api-client.d.ts +48 -0
  404. package/dist/chat-ui/mentions/suggestions/data/api-client.js +45 -0
  405. package/dist/chat-ui/mentions/suggestions/data/api-client.js.map +1 -1
  406. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icon-names.generated.cjs +89 -0
  407. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icon-names.generated.cjs.map +1 -0
  408. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icon-names.generated.d.ts +8 -0
  409. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icon-names.generated.js +89 -0
  410. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icon-names.generated.js.map +1 -0
  411. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.cjs +140 -116
  412. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.cjs.map +1 -1
  413. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.d.ts +46 -12
  414. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.js +141 -117
  415. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.js.map +1 -1
  416. package/dist/chat-ui/mentions/suggestions/data/sources/index.cjs +272 -25
  417. package/dist/chat-ui/mentions/suggestions/data/sources/index.cjs.map +1 -1
  418. package/dist/chat-ui/mentions/suggestions/data/sources/index.d.ts +88 -10
  419. package/dist/chat-ui/mentions/suggestions/data/sources/index.js +274 -27
  420. package/dist/chat-ui/mentions/suggestions/data/sources/index.js.map +1 -1
  421. package/dist/chat-ui/mentions/suggestions/data/types.cjs.map +1 -1
  422. package/dist/chat-ui/mentions/suggestions/data/types.d.ts +27 -1
  423. package/dist/chat-ui/mentions/suggestions/data/types.js.map +1 -1
  424. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.cjs +56 -5
  425. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.cjs.map +1 -1
  426. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.d.ts +26 -6
  427. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.js +57 -6
  428. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.js.map +1 -1
  429. package/dist/chat-ui/mentions/suggestions/mention-suggestions.extension.cjs +34 -17
  430. package/dist/chat-ui/mentions/suggestions/mention-suggestions.extension.cjs.map +1 -1
  431. package/dist/chat-ui/mentions/suggestions/mention-suggestions.extension.d.ts +19 -1
  432. package/dist/chat-ui/mentions/suggestions/mention-suggestions.extension.js +35 -18
  433. package/dist/chat-ui/mentions/suggestions/mention-suggestions.extension.js.map +1 -1
  434. package/dist/chat-ui/mentions/use-asset-icon-app-url.cjs +12 -0
  435. package/dist/chat-ui/mentions/use-asset-icon-app-url.cjs.map +1 -0
  436. package/dist/chat-ui/mentions/use-asset-icon-app-url.d.ts +8 -0
  437. package/dist/chat-ui/mentions/use-asset-icon-app-url.js +12 -0
  438. package/dist/chat-ui/mentions/use-asset-icon-app-url.js.map +1 -0
  439. package/dist/chat-ui/statewire.d.ts +1 -1
  440. package/dist/chat-ui/thread/statewire-history-edge.cjs +15 -0
  441. package/dist/chat-ui/thread/statewire-history-edge.cjs.map +1 -1
  442. package/dist/chat-ui/thread/statewire-history-edge.d.ts +4 -1
  443. package/dist/chat-ui/thread/statewire-history-edge.js +15 -0
  444. package/dist/chat-ui/thread/statewire-history-edge.js.map +1 -1
  445. package/dist/collab/client.cjs +41 -6
  446. package/dist/collab/client.cjs.map +1 -1
  447. package/dist/collab/client.d.ts +38 -7
  448. package/dist/collab/client.js +41 -6
  449. package/dist/collab/client.js.map +1 -1
  450. package/dist/composer/ComposerAttachedReferences.cjs +119 -0
  451. package/dist/composer/ComposerAttachedReferences.cjs.map +1 -0
  452. package/dist/composer/ComposerAttachedReferences.d.ts +26 -0
  453. package/dist/composer/ComposerAttachedReferences.js +119 -0
  454. package/dist/composer/ComposerAttachedReferences.js.map +1 -0
  455. package/dist/composer/ComposerNamedAgents.cjs +63 -0
  456. package/dist/composer/ComposerNamedAgents.cjs.map +1 -0
  457. package/dist/composer/ComposerNamedAgents.d.ts +16 -0
  458. package/dist/composer/ComposerNamedAgents.js +63 -0
  459. package/dist/composer/ComposerNamedAgents.js.map +1 -0
  460. package/dist/composer/attached-references.cjs +159 -0
  461. package/dist/composer/attached-references.cjs.map +1 -0
  462. package/dist/composer/attached-references.d.ts +86 -0
  463. package/dist/composer/attached-references.js +159 -0
  464. package/dist/composer/attached-references.js.map +1 -0
  465. package/dist/composer/build-composed-message.cjs +14 -7
  466. package/dist/composer/build-composed-message.cjs.map +1 -1
  467. package/dist/composer/build-composed-message.d.ts +6 -1
  468. package/dist/composer/build-composed-message.js +14 -7
  469. package/dist/composer/build-composed-message.js.map +1 -1
  470. package/dist/composer/composer-handoff.cjs +6 -2
  471. package/dist/composer/composer-handoff.cjs.map +1 -1
  472. package/dist/composer/composer-handoff.d.ts +7 -1
  473. package/dist/composer/composer-handoff.js +6 -2
  474. package/dist/composer/composer-handoff.js.map +1 -1
  475. package/dist/composer/folder-upload.cjs +149 -0
  476. package/dist/composer/folder-upload.cjs.map +1 -0
  477. package/dist/composer/folder-upload.d.ts +79 -0
  478. package/dist/composer/folder-upload.js +149 -0
  479. package/dist/composer/folder-upload.js.map +1 -0
  480. package/dist/composer/index.d.ts +1 -1
  481. package/dist/composer/staged-message-metadata.cjs +12 -0
  482. package/dist/composer/staged-message-metadata.cjs.map +1 -0
  483. package/dist/composer/staged-message-metadata.d.ts +15 -0
  484. package/dist/composer/staged-message-metadata.js +12 -0
  485. package/dist/composer/staged-message-metadata.js.map +1 -0
  486. package/dist/composer/useAttachToChat.cjs +35 -0
  487. package/dist/composer/useAttachToChat.cjs.map +1 -0
  488. package/dist/composer/useAttachToChat.d.ts +54 -0
  489. package/dist/composer/useAttachToChat.js +35 -0
  490. package/dist/composer/useAttachToChat.js.map +1 -0
  491. package/dist/composer/useAttachedReferencesComposerProps.cjs +19 -0
  492. package/dist/composer/useAttachedReferencesComposerProps.cjs.map +1 -0
  493. package/dist/composer/useAttachedReferencesComposerProps.d.ts +12 -0
  494. package/dist/composer/useAttachedReferencesComposerProps.js +19 -0
  495. package/dist/composer/useAttachedReferencesComposerProps.js.map +1 -0
  496. package/dist/composer/useFileUpload.cjs +95 -7
  497. package/dist/composer/useFileUpload.cjs.map +1 -1
  498. package/dist/composer/useFileUpload.d.ts +21 -2
  499. package/dist/composer/useFileUpload.js +95 -7
  500. package/dist/composer/useFileUpload.js.map +1 -1
  501. package/dist/data/athena-api-error.cjs +125 -0
  502. package/dist/data/athena-api-error.cjs.map +1 -0
  503. package/dist/data/athena-api-error.d.ts +96 -0
  504. package/dist/data/athena-api-error.js +125 -0
  505. package/dist/data/athena-api-error.js.map +1 -0
  506. package/dist/data/athena-data-client.cjs +106 -0
  507. package/dist/data/athena-data-client.cjs.map +1 -0
  508. package/dist/data/athena-data-client.d.ts +74 -0
  509. package/dist/data/athena-data-client.js +106 -0
  510. package/dist/data/athena-data-client.js.map +1 -0
  511. package/dist/data/athena-member.cjs +93 -0
  512. package/dist/data/athena-member.cjs.map +1 -0
  513. package/dist/data/athena-member.d.ts +125 -0
  514. package/dist/data/athena-member.js +93 -0
  515. package/dist/data/athena-member.js.map +1 -0
  516. package/dist/data/athena-request.cjs +460 -0
  517. package/dist/data/athena-request.cjs.map +1 -0
  518. package/dist/data/athena-request.d.ts +120 -0
  519. package/dist/data/athena-request.js +460 -0
  520. package/dist/data/athena-request.js.map +1 -0
  521. package/dist/data/use-athena-fetch.cjs +14 -0
  522. package/dist/data/use-athena-fetch.cjs.map +1 -0
  523. package/dist/data/use-athena-fetch.d.ts +19 -0
  524. package/dist/data/use-athena-fetch.js +14 -0
  525. package/dist/data/use-athena-fetch.js.map +1 -0
  526. package/dist/data/use-athena-graphql.cjs +66 -0
  527. package/dist/data/use-athena-graphql.cjs.map +1 -0
  528. package/dist/data/use-athena-graphql.d.ts +56 -0
  529. package/dist/data/use-athena-graphql.js +66 -0
  530. package/dist/data/use-athena-graphql.js.map +1 -0
  531. package/dist/data/use-athena-rest.cjs +33 -0
  532. package/dist/data/use-athena-rest.cjs.map +1 -0
  533. package/dist/data/use-athena-rest.d.ts +21 -0
  534. package/dist/data/use-athena-rest.js +33 -0
  535. package/dist/data/use-athena-rest.js.map +1 -0
  536. package/dist/data/use-semantic-query.cjs +44 -0
  537. package/dist/data/use-semantic-query.cjs.map +1 -0
  538. package/dist/data/use-semantic-query.d.ts +92 -0
  539. package/dist/data/use-semantic-query.js +44 -0
  540. package/dist/data/use-semantic-query.js.map +1 -0
  541. package/dist/diagnostics/athena-diagnostics.cjs.map +1 -1
  542. package/dist/diagnostics/athena-diagnostics.d.ts +5 -1
  543. package/dist/diagnostics/athena-diagnostics.js.map +1 -1
  544. package/dist/diagnostics/errors.cjs +7 -0
  545. package/dist/diagnostics/errors.cjs.map +1 -1
  546. package/dist/diagnostics/errors.d.ts +7 -0
  547. package/dist/diagnostics/errors.js +7 -0
  548. package/dist/diagnostics/errors.js.map +1 -1
  549. package/dist/index.cjs +155 -11
  550. package/dist/index.cjs.map +1 -1
  551. package/dist/index.d.ts +72 -13
  552. package/dist/index.js +148 -4
  553. package/dist/index.js.map +1 -1
  554. package/dist/keryx-http/src/initial-sync.cjs +64 -16
  555. package/dist/keryx-http/src/initial-sync.cjs.map +1 -1
  556. package/dist/keryx-http/src/initial-sync.d.ts +31 -1
  557. package/dist/keryx-http/src/initial-sync.js +64 -16
  558. package/dist/keryx-http/src/initial-sync.js.map +1 -1
  559. package/dist/keryx-http/src/own-awareness.cjs +20 -0
  560. package/dist/keryx-http/src/own-awareness.cjs.map +1 -0
  561. package/dist/keryx-http/src/own-awareness.d.ts +50 -0
  562. package/dist/keryx-http/src/own-awareness.js +20 -0
  563. package/dist/keryx-http/src/own-awareness.js.map +1 -0
  564. package/dist/keryx-http/src/update-attributions.cjs +26 -1
  565. package/dist/keryx-http/src/update-attributions.cjs.map +1 -1
  566. package/dist/keryx-http/src/update-attributions.d.ts +10 -1
  567. package/dist/keryx-http/src/update-attributions.js +26 -1
  568. package/dist/keryx-http/src/update-attributions.js.map +1 -1
  569. package/dist/offline/chat-outbox.cjs +262 -26
  570. package/dist/offline/chat-outbox.cjs.map +1 -1
  571. package/dist/offline/chat-outbox.d.ts +90 -12
  572. package/dist/offline/chat-outbox.js +263 -27
  573. package/dist/offline/chat-outbox.js.map +1 -1
  574. package/dist/provider/AthenaProvider.cjs +60 -22
  575. package/dist/provider/AthenaProvider.cjs.map +1 -1
  576. package/dist/provider/AthenaProvider.d.ts +24 -8
  577. package/dist/provider/AthenaProvider.js +61 -23
  578. package/dist/provider/AthenaProvider.js.map +1 -1
  579. package/dist/react/package.json.cjs +1 -1
  580. package/dist/react/package.json.js +1 -1
  581. package/dist/references/src/anchors/parse.cjs +11 -1
  582. package/dist/references/src/anchors/parse.cjs.map +1 -1
  583. package/dist/references/src/anchors/parse.js +11 -1
  584. package/dist/references/src/anchors/parse.js.map +1 -1
  585. package/dist/references/src/anchors/schemas.d.ts +1 -0
  586. package/dist/references/src/anchors/serialize.cjs +1 -0
  587. package/dist/references/src/anchors/serialize.cjs.map +1 -1
  588. package/dist/references/src/anchors/serialize.js +1 -0
  589. package/dist/references/src/anchors/serialize.js.map +1 -1
  590. package/dist/references/src/anchors/types.cjs +5 -0
  591. package/dist/references/src/anchors/types.cjs.map +1 -1
  592. package/dist/references/src/anchors/types.d.ts +9 -0
  593. package/dist/references/src/anchors/types.js +5 -0
  594. package/dist/references/src/anchors/types.js.map +1 -1
  595. package/dist/references/src/attachable.cjs +149 -0
  596. package/dist/references/src/attachable.cjs.map +1 -0
  597. package/dist/references/src/attachable.d.ts +87 -0
  598. package/dist/references/src/attachable.js +149 -0
  599. package/dist/references/src/attachable.js.map +1 -0
  600. package/dist/references/src/schemas.d.ts +2 -0
  601. package/dist/runtime/StatewirePlanModeLaneSync.cjs +93 -0
  602. package/dist/runtime/StatewirePlanModeLaneSync.cjs.map +1 -0
  603. package/dist/runtime/StatewirePlanModeLaneSync.d.ts +34 -0
  604. package/dist/runtime/StatewirePlanModeLaneSync.js +93 -0
  605. package/dist/runtime/StatewirePlanModeLaneSync.js.map +1 -0
  606. package/dist/runtime/StatewireThreadConfigLaneSync.cjs +2 -0
  607. package/dist/runtime/StatewireThreadConfigLaneSync.cjs.map +1 -1
  608. package/dist/runtime/StatewireThreadConfigLaneSync.d.ts +4 -0
  609. package/dist/runtime/StatewireThreadConfigLaneSync.js +2 -0
  610. package/dist/runtime/StatewireThreadConfigLaneSync.js.map +1 -1
  611. package/dist/runtime/statewire-plan-mode.cjs +71 -0
  612. package/dist/runtime/statewire-plan-mode.cjs.map +1 -0
  613. package/dist/runtime/statewire-plan-mode.d.ts +88 -0
  614. package/dist/runtime/statewire-plan-mode.js +71 -0
  615. package/dist/runtime/statewire-plan-mode.js.map +1 -0
  616. package/dist/runtime/statewire-run-config.cjs +3 -1
  617. package/dist/runtime/statewire-run-config.cjs.map +1 -1
  618. package/dist/runtime/statewire-run-config.d.ts +7 -0
  619. package/dist/runtime/statewire-run-config.js +3 -1
  620. package/dist/runtime/statewire-run-config.js.map +1 -1
  621. package/dist/runtime/statewire-session-key.cjs +11 -5
  622. package/dist/runtime/statewire-session-key.cjs.map +1 -1
  623. package/dist/runtime/statewire-session-key.d.ts +22 -10
  624. package/dist/runtime/statewire-session-key.js +11 -5
  625. package/dist/runtime/statewire-session-key.js.map +1 -1
  626. package/dist/runtime/useAthenaStatewireRuntime.cjs +64 -9
  627. package/dist/runtime/useAthenaStatewireRuntime.cjs.map +1 -1
  628. package/dist/runtime/useAthenaStatewireRuntime.d.ts +26 -10
  629. package/dist/runtime/useAthenaStatewireRuntime.js +66 -11
  630. package/dist/runtime/useAthenaStatewireRuntime.js.map +1 -1
  631. package/dist/search/useAthenaAssets.cjs +394 -0
  632. package/dist/search/useAthenaAssets.cjs.map +1 -0
  633. package/dist/search/useAthenaAssets.d.ts +186 -0
  634. package/dist/search/useAthenaAssets.js +394 -0
  635. package/dist/search/useAthenaAssets.js.map +1 -0
  636. package/dist/sheet-range/index.cjs +4 -0
  637. package/dist/sheet-range/index.cjs.map +1 -1
  638. package/dist/sheet-range/index.d.ts +4 -2
  639. package/dist/sheet-range/index.js +4 -0
  640. package/dist/sheet-range/index.js.map +1 -1
  641. package/dist/sheet-range/query-range.cjs +102 -0
  642. package/dist/sheet-range/query-range.cjs.map +1 -0
  643. package/dist/sheet-range/query-range.d.ts +46 -0
  644. package/dist/sheet-range/query-range.js +102 -0
  645. package/dist/sheet-range/query-range.js.map +1 -0
  646. package/dist/styles.css +1 -1
  647. package/dist/subagents/index.cjs +49 -0
  648. package/dist/subagents/index.cjs.map +1 -0
  649. package/dist/subagents/index.d.ts +16 -0
  650. package/dist/subagents/index.js +49 -0
  651. package/dist/subagents/index.js.map +1 -0
  652. package/dist/subagents/lane-follow.cjs +19 -0
  653. package/dist/subagents/lane-follow.cjs.map +1 -0
  654. package/dist/subagents/lane-follow.d.ts +9 -0
  655. package/dist/subagents/lane-follow.js +19 -0
  656. package/dist/subagents/lane-follow.js.map +1 -0
  657. package/dist/subagents/lane-model.cjs +178 -0
  658. package/dist/subagents/lane-model.cjs.map +1 -0
  659. package/dist/subagents/lane-model.d.ts +140 -0
  660. package/dist/subagents/lane-model.js +178 -0
  661. package/dist/subagents/lane-model.js.map +1 -0
  662. package/dist/subagents/lane-parts.cjs +517 -0
  663. package/dist/subagents/lane-parts.cjs.map +1 -0
  664. package/dist/subagents/lane-parts.d.ts +130 -0
  665. package/dist/subagents/lane-parts.js +517 -0
  666. package/dist/subagents/lane-parts.js.map +1 -0
  667. package/dist/subagents/subagent-lane-group.cjs +215 -0
  668. package/dist/subagents/subagent-lane-group.cjs.map +1 -0
  669. package/dist/subagents/subagent-lane-group.d.ts +67 -0
  670. package/dist/subagents/subagent-lane-group.js +215 -0
  671. package/dist/subagents/subagent-lane-group.js.map +1 -0
  672. package/dist/subagents/subagent-transcript-drawer.cjs +431 -0
  673. package/dist/subagents/subagent-transcript-drawer.cjs.map +1 -0
  674. package/dist/subagents/subagent-transcript-drawer.d.ts +78 -0
  675. package/dist/subagents/subagent-transcript-drawer.js +431 -0
  676. package/dist/subagents/subagent-transcript-drawer.js.map +1 -0
  677. package/dist/subagents/task-subagent-group.cjs +115 -0
  678. package/dist/subagents/task-subagent-group.cjs.map +1 -0
  679. package/dist/subagents/task-subagent-group.d.ts +36 -0
  680. package/dist/subagents/task-subagent-group.js +115 -0
  681. package/dist/subagents/task-subagent-group.js.map +1 -0
  682. package/dist/subagents/use-omitted-images-in-view.cjs +68 -0
  683. package/dist/subagents/use-omitted-images-in-view.cjs.map +1 -0
  684. package/dist/subagents/use-omitted-images-in-view.d.ts +21 -0
  685. package/dist/subagents/use-omitted-images-in-view.js +68 -0
  686. package/dist/subagents/use-omitted-images-in-view.js.map +1 -0
  687. package/dist/threads/Inbox.cjs +2 -2
  688. package/dist/threads/Inbox.cjs.map +1 -1
  689. package/dist/threads/SessionList.cjs +6 -6
  690. package/dist/threads/SessionList.cjs.map +1 -1
  691. package/dist/threads/SessionsPage.cjs +13 -7
  692. package/dist/threads/SessionsPage.cjs.map +1 -1
  693. package/dist/threads/SessionsPage.d.ts +10 -1
  694. package/dist/threads/SessionsPage.js +9 -3
  695. package/dist/threads/SessionsPage.js.map +1 -1
  696. package/dist/threads/session-list-model.cjs.map +1 -1
  697. package/dist/threads/session-list-model.d.ts +2 -1
  698. package/dist/threads/session-list-model.js.map +1 -1
  699. package/dist/threads/session-row-parts.cjs +3 -3
  700. package/dist/threads/session-row-parts.cjs.map +1 -1
  701. package/dist/threads/sessions-page-model.cjs +13 -5
  702. package/dist/threads/sessions-page-model.cjs.map +1 -1
  703. package/dist/threads/sessions-page-model.d.ts +7 -0
  704. package/dist/threads/sessions-page-model.js +11 -3
  705. package/dist/threads/sessions-page-model.js.map +1 -1
  706. package/dist/threads/sessions-page-storage.cjs +8 -8
  707. package/dist/threads/sessions-page-storage.cjs.map +1 -1
  708. package/dist/threads/sessions-page-storage.d.ts +5 -1
  709. package/dist/threads/sessions-page-storage.js +8 -8
  710. package/dist/threads/sessions-page-storage.js.map +1 -1
  711. package/dist/threads/statewire-thread-list.cjs +14 -2
  712. package/dist/threads/statewire-thread-list.cjs.map +1 -1
  713. package/dist/threads/statewire-thread-list.d.ts +11 -2
  714. package/dist/threads/statewire-thread-list.js +14 -2
  715. package/dist/threads/statewire-thread-list.js.map +1 -1
  716. package/dist/threads/use-athena-sessions.cjs +1 -0
  717. package/dist/threads/use-athena-sessions.cjs.map +1 -1
  718. package/dist/threads/use-athena-sessions.d.ts +7 -0
  719. package/dist/threads/use-athena-sessions.js +1 -0
  720. package/dist/threads/use-athena-sessions.js.map +1 -1
  721. package/dist/threads/use-athena-thread-agent.cjs +31 -0
  722. package/dist/threads/use-athena-thread-agent.cjs.map +1 -0
  723. package/dist/threads/use-athena-thread-agent.d.ts +38 -0
  724. package/dist/threads/use-athena-thread-agent.js +31 -0
  725. package/dist/threads/use-athena-thread-agent.js.map +1 -0
  726. package/dist/threads/use-athena-thread-plan-mode.cjs +18 -0
  727. package/dist/threads/use-athena-thread-plan-mode.cjs.map +1 -0
  728. package/dist/threads/use-athena-thread-plan-mode.d.ts +18 -0
  729. package/dist/threads/use-athena-thread-plan-mode.js +18 -0
  730. package/dist/threads/use-athena-thread-plan-mode.js.map +1 -0
  731. package/dist/threads/use-rest-conversation-history.d.ts +1 -0
  732. package/dist/tools/agent-creations.cjs +97 -0
  733. package/dist/tools/agent-creations.cjs.map +1 -0
  734. package/dist/tools/agent-creations.d.ts +38 -0
  735. package/dist/tools/agent-creations.js +97 -0
  736. package/dist/tools/agent-creations.js.map +1 -0
  737. package/dist/tools/agent-highlights.cjs +100 -0
  738. package/dist/tools/agent-highlights.cjs.map +1 -0
  739. package/dist/tools/agent-highlights.d.ts +57 -0
  740. package/dist/tools/agent-highlights.js +100 -0
  741. package/dist/tools/agent-highlights.js.map +1 -0
  742. package/dist/tools/append-document-tool-ui.cjs +1 -0
  743. package/dist/tools/append-document-tool-ui.cjs.map +1 -1
  744. package/dist/tools/append-document-tool-ui.d.ts +7 -0
  745. package/dist/tools/append-document-tool-ui.js +2 -1
  746. package/dist/tools/append-document-tool-ui.js.map +1 -1
  747. package/dist/tools/auto-open-tools.cjs +144 -71
  748. package/dist/tools/auto-open-tools.cjs.map +1 -1
  749. package/dist/tools/auto-open-tools.d.ts +131 -1
  750. package/dist/tools/auto-open-tools.js +145 -72
  751. package/dist/tools/auto-open-tools.js.map +1 -1
  752. package/dist/tools/browser-tool-uis.cjs +594 -0
  753. package/dist/tools/browser-tool-uis.cjs.map +1 -0
  754. package/dist/tools/browser-tool-uis.d.ts +8 -0
  755. package/dist/tools/browser-tool-uis.js +594 -0
  756. package/dist/tools/browser-tool-uis.js.map +1 -0
  757. package/dist/tools/computer-asset-tool-uis.cjs +313 -0
  758. package/dist/tools/computer-asset-tool-uis.cjs.map +1 -0
  759. package/dist/tools/computer-asset-tool-uis.d.ts +5 -0
  760. package/dist/tools/computer-asset-tool-uis.js +313 -0
  761. package/dist/tools/computer-asset-tool-uis.js.map +1 -0
  762. package/dist/tools/document-edit-tool-uis.cjs +218 -0
  763. package/dist/tools/document-edit-tool-uis.cjs.map +1 -0
  764. package/dist/tools/document-edit-tool-uis.d.ts +40 -0
  765. package/dist/tools/document-edit-tool-uis.js +218 -0
  766. package/dist/tools/document-edit-tool-uis.js.map +1 -0
  767. package/dist/tools/drive-tool-uis.cjs +429 -0
  768. package/dist/tools/drive-tool-uis.cjs.map +1 -0
  769. package/dist/tools/drive-tool-uis.d.ts +121 -0
  770. package/dist/tools/drive-tool-uis.js +429 -0
  771. package/dist/tools/drive-tool-uis.js.map +1 -0
  772. package/dist/tools/email-calendar-tool-uis.cjs +789 -0
  773. package/dist/tools/email-calendar-tool-uis.cjs.map +1 -0
  774. package/dist/tools/email-calendar-tool-uis.d.ts +129 -0
  775. package/dist/tools/email-calendar-tool-uis.js +789 -0
  776. package/dist/tools/email-calendar-tool-uis.js.map +1 -0
  777. package/dist/tools/ontology-tool-uis.cjs +83 -0
  778. package/dist/tools/ontology-tool-uis.cjs.map +1 -0
  779. package/dist/tools/ontology-tool-uis.d.ts +9 -0
  780. package/dist/tools/ontology-tool-uis.js +83 -0
  781. package/dist/tools/ontology-tool-uis.js.map +1 -0
  782. package/dist/tools/orchestration-tool-uis.cjs +586 -0
  783. package/dist/tools/orchestration-tool-uis.cjs.map +1 -0
  784. package/dist/tools/orchestration-tool-uis.d.ts +141 -0
  785. package/dist/tools/orchestration-tool-uis.js +586 -0
  786. package/dist/tools/orchestration-tool-uis.js.map +1 -0
  787. package/dist/tools/presentation-edit-tool-uis.cjs +516 -0
  788. package/dist/tools/presentation-edit-tool-uis.cjs.map +1 -0
  789. package/dist/tools/presentation-edit-tool-uis.d.ts +73 -0
  790. package/dist/tools/presentation-edit-tool-uis.js +516 -0
  791. package/dist/tools/presentation-edit-tool-uis.js.map +1 -0
  792. package/dist/tools/project-tool-uis.cjs +213 -0
  793. package/dist/tools/project-tool-uis.cjs.map +1 -0
  794. package/dist/tools/project-tool-uis.d.ts +14 -0
  795. package/dist/tools/project-tool-uis.js +213 -0
  796. package/dist/tools/project-tool-uis.js.map +1 -0
  797. package/dist/tools/sandbox-tool-uis.cjs +491 -0
  798. package/dist/tools/sandbox-tool-uis.cjs.map +1 -0
  799. package/dist/tools/sandbox-tool-uis.d.ts +116 -0
  800. package/dist/tools/sandbox-tool-uis.js +491 -0
  801. package/dist/tools/sandbox-tool-uis.js.map +1 -0
  802. package/dist/tools/sheet-query-tool-ui.cjs +138 -0
  803. package/dist/tools/sheet-query-tool-ui.cjs.map +1 -0
  804. package/dist/tools/sheet-query-tool-ui.d.ts +15 -0
  805. package/dist/tools/sheet-query-tool-ui.js +138 -0
  806. package/dist/tools/sheet-query-tool-ui.js.map +1 -0
  807. package/dist/tools/studio-screenshot-tool-uis.cjs +262 -0
  808. package/dist/tools/studio-screenshot-tool-uis.cjs.map +1 -0
  809. package/dist/tools/studio-screenshot-tool-uis.d.ts +52 -0
  810. package/dist/tools/studio-screenshot-tool-uis.js +262 -0
  811. package/dist/tools/studio-screenshot-tool-uis.js.map +1 -0
  812. package/dist/tools/subagent-task-tool-ui.cjs +24 -475
  813. package/dist/tools/subagent-task-tool-ui.cjs.map +1 -1
  814. package/dist/tools/subagent-task-tool-ui.d.ts +19 -103
  815. package/dist/tools/subagent-task-tool-ui.js +28 -479
  816. package/dist/tools/subagent-task-tool-ui.js.map +1 -1
  817. package/dist/tools/tool-summary.cjs +36 -0
  818. package/dist/tools/tool-summary.cjs.map +1 -1
  819. package/dist/tools/tool-summary.js +36 -0
  820. package/dist/tools/tool-summary.js.map +1 -1
  821. package/dist/tools/tool-uis.cjs +181 -53
  822. package/dist/tools/tool-uis.cjs.map +1 -1
  823. package/dist/tools/tool-uis.d.ts +40 -0
  824. package/dist/tools/tool-uis.js +183 -55
  825. package/dist/tools/tool-uis.js.map +1 -1
  826. package/dist/typed-interrupts/index.cjs +15 -0
  827. package/dist/typed-interrupts/index.cjs.map +1 -0
  828. package/dist/typed-interrupts/index.d.ts +20 -0
  829. package/dist/typed-interrupts/index.js +15 -0
  830. package/dist/typed-interrupts/index.js.map +1 -0
  831. package/dist/version.cjs +4 -0
  832. package/dist/version.cjs.map +1 -1
  833. package/dist/version.d.ts +9 -0
  834. package/dist/version.js +4 -0
  835. package/dist/version.js.map +1 -1
  836. package/dist/workbench/live-desktop-api.cjs +2 -1
  837. package/dist/workbench/live-desktop-api.cjs.map +1 -1
  838. package/dist/workbench/live-desktop-api.js +2 -1
  839. package/dist/workbench/live-desktop-api.js.map +1 -1
  840. package/dist/workbench/session-workbench-panes.cjs +6 -6
  841. package/dist/workbench/session-workbench-panes.cjs.map +1 -1
  842. package/dist/workbench/session-workspace-api.cjs +7 -2
  843. package/dist/workbench/session-workspace-api.cjs.map +1 -1
  844. package/dist/workbench/session-workspace-api.d.ts +10 -0
  845. package/dist/workbench/session-workspace-api.js +7 -2
  846. package/dist/workbench/session-workspace-api.js.map +1 -1
  847. package/package.json +28 -6
  848. package/dist/agent-runtime/src/chat-outbox-store.cjs +0 -510
  849. package/dist/agent-runtime/src/chat-outbox-store.cjs.map +0 -1
  850. package/dist/agent-runtime/src/chat-outbox-store.d.ts +0 -210
  851. package/dist/agent-runtime/src/chat-outbox-store.js +0 -510
  852. package/dist/agent-runtime/src/chat-outbox-store.js.map +0 -1
@@ -1,57 +1,293 @@
1
- import { createIndexedDbChatOutboxStore } from "../agent-runtime/src/chat-outbox-store.js";
2
- import { CHAT_OUTBOX_CLAIM_LEASE_MS, CHAT_OUTBOX_ASK_AFTER_MS } from "../agent-runtime/src/chat-outbox.js";
3
- const ownerStores = /* @__PURE__ */ new Map();
1
+ import { clearChatOutboxes, countChatOutboxMessages as countChatOutboxMessages$1, listChatOutboxes, chatSessionNamespace, adoptUnscopedChatSessions, chatSessionBackend, createSealedSessionCodec, createChatOutboxDirectory, chatSessionMemoryNamespace, chatSessionMemoryBackend } from "../agent-runtime/src/chat-outbox-storage.js";
2
+ import { CHAT_OUTBOX_ASK_AFTER_MS } from "../agent-runtime/src/chat-outbox.js";
3
+ import { createLegacyChatOutboxReader } from "../agent-runtime/src/chat-outbox-legacy.js";
4
+ import { sessionPrincipal } from "../agent-runtime/src/quota-safe-local-storage-session.js";
5
+ async function resolveChatSessionKeeping(owner) {
6
+ const namespace = await owner.namespace;
7
+ if (namespace !== null) {
8
+ const writeKey = await owner.host.current.getKey("write").catch(() => null);
9
+ if (writeKey) return { kind: "sealed", namespace, principal: owner.principal, codec: owner.codec };
10
+ const threads = await threadsKeptSealed(owner, namespace);
11
+ if (threads.size > 0) {
12
+ return {
13
+ kind: "memory",
14
+ scope: owner.memoryScope,
15
+ principal: owner.principal,
16
+ sealedThreads: { namespace, codec: owner.drainCodec, threads }
17
+ };
18
+ }
19
+ }
20
+ return { kind: "memory", scope: owner.memoryScope, principal: owner.principal };
21
+ }
22
+ async function threadsKeptSealed(owner, namespace) {
23
+ const readKey = await owner.host.current.getKey("read").catch(() => null);
24
+ if (!readKey) return /* @__PURE__ */ new Set();
25
+ const listing = await listChatOutboxes({
26
+ backend: chatSessionBackend(),
27
+ namespace,
28
+ principal: owner.principal,
29
+ codec: owner.codec
30
+ }).catch(() => EMPTY_LISTING);
31
+ return new Set(
32
+ listing.threads.filter(({ entries }) => entries.length > 0).map(({ threadId }) => threadId)
33
+ );
34
+ }
35
+ const SDK_CHAT_SESSION_ENVIRONMENT = "athena-sdk";
36
+ const owners = /* @__PURE__ */ new Map();
4
37
  function keylessHost(ownerId) {
5
38
  return { ownerId, getKey: async () => null };
6
39
  }
7
- function ownerStore(ownerId, host) {
8
- let owner = ownerStores.get(ownerId);
40
+ function canKeepSealedSessions() {
41
+ return typeof indexedDB !== "undefined" && typeof crypto !== "undefined" && typeof crypto.subtle !== "undefined";
42
+ }
43
+ function memorySource(ownerId) {
44
+ return {
45
+ backend: chatSessionMemoryBackend(),
46
+ namespace: chatSessionMemoryNamespace(ownerId),
47
+ principal: sessionPrincipal(ownerId)
48
+ };
49
+ }
50
+ function sealedSource(owner, namespace) {
51
+ return {
52
+ backend: chatSessionBackend(),
53
+ namespace,
54
+ principal: owner.principal,
55
+ codec: owner.codec,
56
+ legacy: owner.legacy
57
+ };
58
+ }
59
+ const EMPTY_LISTING = { threads: [], unreadable: 0 };
60
+ function mergeListings(a, b) {
61
+ if (b.threads.length === 0 && b.unreadable === 0) return a;
62
+ if (a.threads.length === 0 && a.unreadable === 0) return b;
63
+ const byThread = /* @__PURE__ */ new Map();
64
+ for (const thread of [...a.threads, ...b.threads]) {
65
+ const list = byThread.get(thread.threadId) ?? [];
66
+ for (const entry of thread.entries) if (!list.some(({ id }) => id === entry.id)) list.push(entry);
67
+ byThread.set(thread.threadId, list);
68
+ }
69
+ const threads = [...byThread].map(([threadId, entries]) => ({
70
+ threadId,
71
+ entries: entries.sort((x, y) => x.queuedAt - y.queuedAt)
72
+ })).sort((x, y) => {
73
+ var _a, _b;
74
+ return (((_a = x.entries[0]) == null ? void 0 : _a.queuedAt) ?? 0) - (((_b = y.entries[0]) == null ? void 0 : _b.queuedAt) ?? 0);
75
+ });
76
+ return { threads, unreadable: a.unreadable + b.unreadable };
77
+ }
78
+ function listingSignature(listing) {
79
+ return JSON.stringify([
80
+ listing.unreadable,
81
+ listing.threads.map(({ threadId, entries }) => [
82
+ threadId,
83
+ entries.map(({ id, state, failed, queuedAt, text }) => [id, state, failed, queuedAt, text])
84
+ ])
85
+ ]);
86
+ }
87
+ function mergedDirectory({
88
+ memory,
89
+ sealed
90
+ }) {
91
+ let sealedDirectory = null;
92
+ let cached = null;
93
+ const listeners = /* @__PURE__ */ new Set();
94
+ let stops = [];
95
+ let generation = 0;
96
+ let heard = listingSignature(EMPTY_LISTING);
97
+ const notify = () => {
98
+ const signature = listingSignature(directory.getSnapshot());
99
+ if (signature === heard) return;
100
+ heard = signature;
101
+ for (const listener of [...listeners]) {
102
+ try {
103
+ listener();
104
+ } catch {
105
+ }
106
+ }
107
+ };
108
+ const start = () => {
109
+ const started = ++generation;
110
+ stops.push(memory.subscribe(notify));
111
+ memory.refresh();
112
+ void sealed.then((directory2) => {
113
+ sealedDirectory = directory2;
114
+ if (!directory2 || started !== generation || listeners.size === 0) return;
115
+ stops.push(directory2.subscribe(notify));
116
+ directory2.refresh();
117
+ });
118
+ };
119
+ const directory = {
120
+ getSnapshot() {
121
+ const memorySnapshot = memory.getSnapshot();
122
+ const sealedSnapshot = (sealedDirectory == null ? void 0 : sealedDirectory.getSnapshot()) ?? EMPTY_LISTING;
123
+ if (!cached || cached.memory !== memorySnapshot || cached.sealed !== sealedSnapshot) {
124
+ cached = {
125
+ memory: memorySnapshot,
126
+ sealed: sealedSnapshot,
127
+ merged: mergeListings(sealedSnapshot, memorySnapshot)
128
+ };
129
+ }
130
+ return cached.merged;
131
+ },
132
+ subscribe(listener) {
133
+ listeners.add(listener);
134
+ if (listeners.size === 1) start();
135
+ return () => {
136
+ listeners.delete(listener);
137
+ if (listeners.size === 0) {
138
+ generation += 1;
139
+ for (const stop of stops) stop();
140
+ stops = [];
141
+ }
142
+ };
143
+ },
144
+ refresh() {
145
+ memory.refresh();
146
+ sealedDirectory == null ? void 0 : sealedDirectory.refresh();
147
+ }
148
+ };
149
+ return directory;
150
+ }
151
+ function sessionKeys(current) {
152
+ let keysOf = null;
153
+ const keys = /* @__PURE__ */ new Map();
154
+ const getKey = (purpose) => {
155
+ const host = current.current;
156
+ if (keysOf !== host) {
157
+ keysOf = host;
158
+ keys.clear();
159
+ }
160
+ let key = keys.get(purpose);
161
+ if (!key) {
162
+ const asked = host.getKey(purpose).catch(() => null);
163
+ key = asked;
164
+ keys.set(purpose, asked);
165
+ void asked.then((value) => {
166
+ if (value === null && keys.get(purpose) === asked) keys.delete(purpose);
167
+ });
168
+ }
169
+ return key;
170
+ };
171
+ return { getKey, forget: () => keys.clear() };
172
+ }
173
+ function ownerStorage(ownerId, host) {
174
+ let owner = owners.get(ownerId);
9
175
  if (!owner) {
10
176
  const current = { current: host ?? keylessHost(ownerId) };
177
+ const principal = sessionPrincipal(ownerId);
178
+ const sealedAvailable = canKeepSealedSessions();
179
+ const namespace = sealedAvailable ? chatSessionNamespace({ environment: SDK_CHAT_SESSION_ENVIRONMENT, ownerId }).then(async (resolved) => {
180
+ await adoptUnscopedChatSessions({
181
+ backend: chatSessionBackend(),
182
+ namespace: resolved,
183
+ principal
184
+ }).catch(() => 0);
185
+ return resolved;
186
+ }).catch(() => null) : Promise.resolve(null);
187
+ const keys = sessionKeys(current);
188
+ const codec = createSealedSessionCodec({ getKey: keys.getKey, scope: ownerId });
189
+ const drainCodec = createSealedSessionCodec({
190
+ getKey: (purpose) => keys.getKey(purpose === "write" ? "read" : purpose),
191
+ scope: ownerId
192
+ });
193
+ const legacy = createLegacyChatOutboxReader({
194
+ ownerId,
195
+ getKey: () => current.current.getKey("read")
196
+ });
197
+ const directory = mergedDirectory({
198
+ memory: createChatOutboxDirectory(memorySource(ownerId)),
199
+ sealed: namespace.then(
200
+ (resolved) => resolved === null ? null : createChatOutboxDirectory(sealedSource({ codec, legacy, principal }, resolved))
201
+ )
202
+ });
11
203
  owner = {
204
+ ownerId,
205
+ principal,
206
+ codec,
207
+ drainCodec,
208
+ legacy,
209
+ namespace,
210
+ memoryScope: ownerId,
12
211
  host: current,
13
- store: createIndexedDbChatOutboxStore({
14
- ownerId,
15
- getKey: (_ownerId, purpose) => current.current.getKey(purpose)
16
- })
212
+ directory,
213
+ forgetKeys: keys.forget
17
214
  };
18
- ownerStores.set(ownerId, owner);
215
+ owners.set(ownerId, owner);
19
216
  }
20
217
  if (host) owner.host.current = host;
21
- return owner.store;
218
+ return owner;
219
+ }
220
+ function chatOutboxStorageFor(host) {
221
+ return ownerStorage(host.ownerId, host);
22
222
  }
23
- function chatOutboxStoreFor(host) {
24
- return ownerStore(host.ownerId, host);
223
+ async function sealedSourceOf(owner) {
224
+ const namespace = await owner.namespace;
225
+ return namespace === null ? null : sealedSource(owner, namespace);
25
226
  }
26
- function countChatOutboxMessages(ownerId) {
27
- return ownerStore(ownerId).count();
227
+ async function countChatOutboxMessages(ownerId) {
228
+ const owner = ownerStorage(ownerId);
229
+ const sealed = await sealedSourceOf(owner);
230
+ const [kept, inMemory] = await Promise.all([
231
+ sealed ? countChatOutboxMessages$1(sealed) : 0,
232
+ countChatOutboxMessages$1(memorySource(ownerId))
233
+ ]);
234
+ return kept + inMemory;
28
235
  }
29
236
  function subscribeChatOutbox(ownerId, listener) {
30
- return ownerStore(ownerId).subscribe(listener);
237
+ return ownerStorage(ownerId).directory.subscribe(listener);
31
238
  }
32
- async function listChatOutboxMessages(ownerId, now = Date.now()) {
33
- const records = await ownerStore(ownerId).listAll();
34
- return records.map(({ entry, claim, failure, memoryOnly }) => ({
239
+ function summaryOf(entry, { inMemory, now }) {
240
+ return {
35
241
  id: entry.id,
36
242
  threadId: entry.threadId,
37
243
  text: entry.text,
38
244
  newChat: entry.newChat,
39
- status: failure ? "failed" : claim && now - claim.at < CHAT_OUTBOX_CLAIM_LEASE_MS ? "sending" : now - entry.queuedAt > CHAT_OUTBOX_ASK_AFTER_MS ? "ask" : "waiting",
40
- inMemory: memoryOnly === true
41
- }));
245
+ status: entry.failed ? "failed" : entry.state !== void 0 && entry.state !== "held" ? "sending" : now - entry.queuedAt > CHAT_OUTBOX_ASK_AFTER_MS ? "ask" : "waiting",
246
+ inMemory,
247
+ queuedAt: entry.queuedAt
248
+ };
249
+ }
250
+ async function listChatOutboxMessages(ownerId, now = Date.now()) {
251
+ const owner = ownerStorage(ownerId);
252
+ const sealed = await sealedSourceOf(owner);
253
+ const [kept, inMemory] = await Promise.all([
254
+ sealed ? listChatOutboxes(sealed) : EMPTY_LISTING,
255
+ listChatOutboxes(memorySource(ownerId))
256
+ ]);
257
+ const summaries = [
258
+ ...kept.threads.flatMap(
259
+ ({ entries }) => entries.map((entry) => summaryOf(entry, { inMemory: false, now }))
260
+ ),
261
+ ...inMemory.threads.flatMap(
262
+ ({ entries }) => entries.map((entry) => summaryOf(entry, { inMemory: true, now }))
263
+ )
264
+ ];
265
+ return summaries.sort((a, b) => a.queuedAt - b.queuedAt);
42
266
  }
43
- function clearChatOutbox(ownerId) {
44
- return ownerStore(ownerId).clear();
267
+ async function clearChatOutbox(ownerId) {
268
+ const owner = ownerStorage(ownerId);
269
+ const sealed = await sealedSourceOf(owner);
270
+ owner.forgetKeys();
271
+ if (sealed) await clearChatOutboxes(sealed);
272
+ else await owner.legacy.clear();
273
+ await clearChatOutboxes(memorySource(ownerId));
274
+ owner.directory.refresh();
45
275
  }
46
- function clearUnopenableChatOutbox(ownerId) {
47
- return createIndexedDbChatOutboxStore({ ownerId, getKey: async () => null }).clear();
276
+ async function clearUnopenableChatOutbox(ownerId) {
277
+ const owner = ownerStorage(ownerId);
278
+ owner.forgetKeys();
279
+ const sealed = await sealedSourceOf(owner);
280
+ if (sealed) await clearChatOutboxes(sealed);
281
+ else await owner.legacy.clear();
282
+ owner.directory.refresh();
48
283
  }
49
284
  export {
50
- chatOutboxStoreFor,
285
+ chatOutboxStorageFor,
51
286
  clearChatOutbox,
52
287
  clearUnopenableChatOutbox,
53
288
  countChatOutboxMessages,
54
289
  listChatOutboxMessages,
290
+ resolveChatSessionKeeping,
55
291
  subscribeChatOutbox
56
292
  };
57
293
  //# sourceMappingURL=chat-outbox.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"chat-outbox.js","sources":["../../src/offline/chat-outbox.ts"],"sourcesContent":["import {\n CHAT_OUTBOX_ASK_AFTER_MS,\n CHAT_OUTBOX_CLAIM_LEASE_MS,\n type ChatOutboxKeyPurpose,\n type ChatOutboxSignal,\n type ChatOutboxStore,\n createIndexedDbChatOutboxStore,\n} from '@athenaintel/agent-runtime';\n\n/**\n * Opt-in: messages typed while Athena can't be reached wait on this device, sealed with the host's\n * key, and are sent once Athena is back while the app is in front, after a countdown the person\n * can cancel (`@athenaintel/agent-runtime`'s chat outbox, shown at the top of the queue tray).\n * Without it a send goes to the transport as before.\n *\n * - `ownerId` names whose they are (the signed-in person, with the environment). Another owner's\n * messages are never shown or sent: each owner's are sealed under their own key.\n * - `getKey(purpose)` returns the AES-GCM key: `read` opens what is kept (the key if one exists,\n * never made for this), `write` keeps a new message (only while the deployment lets devices keep\n * copies). `null` keeps a new message in memory only, for as long as the page stays open. Unlike\n * the chat history's, this key guards the only copy of what someone wrote: a host must never\n * replace or drop it except at a sign-out the person chose.\n * - `reachability` says Athena can be reached: the host's own model (the device online AND agora\n * answering a health read, as Midas's main process decides it), by default the browser being\n * online. Either way a conversation whose own channel keeps failing to connect counts as out of\n * reach too.\n * - `foreground` says the app is in front; by default a visible document. A desktop host passes\n * `windowInFrontSignal()` (visible and focused).\n * - `openThread` opens another of the person's conversations the tray lists as holding waiting\n * messages (`newChat`: one that never started). Without it, a provider with a thread list\n * switches to it; otherwise the tray names it without Open.\n */\nexport interface AthenaChatOutbox {\n ownerId: string;\n getKey: (purpose: ChatOutboxKeyPurpose) => Promise<CryptoKey | null>;\n reachability?: ChatOutboxSignal;\n foreground?: ChatOutboxSignal;\n openThread?: (target: { threadId: string; newChat: boolean }) => void;\n}\n\ninterface OwnerStore {\n store: ChatOutboxStore;\n /** The latest host for this owner: the store asks it for the key. */\n host: { current: AthenaChatOutbox };\n}\n\n// process-local: one store per owner in this page, so every provider of the person (a chat in a\n// tab, another in a pane) shares one change bus and one memory of the messages this device could\n// not keep: a thread switch or a closed tab never loses them, and a sign-out counts them.\nconst ownerStores = new Map<string, OwnerStore>();\n\n/** A host that has no key to give (counting and deleting never need one). */\nfunction keylessHost(ownerId: string): AthenaChatOutbox {\n return { ownerId, getKey: async () => null };\n}\n\nfunction ownerStore(ownerId: string, host?: AthenaChatOutbox): ChatOutboxStore {\n let owner = ownerStores.get(ownerId);\n if (!owner) {\n const current = { current: host ?? keylessHost(ownerId) };\n owner = {\n host: current,\n store: createIndexedDbChatOutboxStore({\n ownerId,\n getKey: (_ownerId, purpose) => current.current.getKey(purpose),\n }),\n };\n ownerStores.set(ownerId, owner);\n }\n if (host) owner.host.current = host;\n return owner.store;\n}\n\n/** The page's chat outbox store for `host`'s owner, made on first use. */\nexport function chatOutboxStoreFor(host: AthenaChatOutbox): ChatOutboxStore {\n return ownerStore(host.ownerId, host);\n}\n\n/**\n * How many messages wait for `ownerId` (kept on the device, including records this build cannot\n * open, and waiting in this page's memory), counted without opening them. Rejects when the\n * device's records cannot be counted at all.\n */\nexport function countChatOutboxMessages(ownerId: string): Promise<number> {\n return ownerStore(ownerId).count();\n}\n\n/**\n * Calls `listener` after any change to `ownerId`'s waiting messages, this window's or another's\n * (one kept, handed to its conversation, cancelled, failed or retried), so a host can show how many\n * wait (`countChatOutboxMessages`) without asking on a timer. Returns what stops it.\n */\nexport function subscribeChatOutbox(ownerId: string, listener: () => void): () => void {\n return ownerStore(ownerId).subscribe(listener);\n}\n\n/** A message waiting in an owner's outbox, as a host lists it (its \"Waiting to sync\" list). */\nexport interface ChatOutboxMessageSummary {\n id: string;\n threadId: string;\n /** The text as it will be sent. */\n text: string;\n /** Typed into a chat that had never started. */\n newChat: boolean;\n /**\n * Where it stands, as the queue tray shows it: waiting to be sent, being handed to its\n * conversation now (a window's claim on it still holds), waiting for the person (it waited more\n * than a day: Send, Edit or Discard), or failed (Retry or Discard; never retried on its own).\n */\n status: 'waiting' | 'sending' | 'ask' | 'failed';\n /** Kept only in this page's memory: this device could not keep it. */\n inMemory: boolean;\n}\n\n/**\n * The messages waiting for `ownerId` that this page can open (oldest first), each with where it\n * stands, for a host's list of what waits to sync; the tray in the conversation acts on them.\n * Records this page cannot open (no key here, a newer build's) are left out, so a host counts with\n * `countChatOutboxMessages`.\n */\nexport async function listChatOutboxMessages(\n ownerId: string,\n now: number = Date.now(),\n): Promise<ChatOutboxMessageSummary[]> {\n const records = await ownerStore(ownerId).listAll();\n return records.map(({ entry, claim, failure, memoryOnly }) => ({\n id: entry.id,\n threadId: entry.threadId,\n text: entry.text,\n newChat: entry.newChat,\n status: failure\n ? 'failed'\n : claim && now - claim.at < CHAT_OUTBOX_CLAIM_LEASE_MS\n ? 'sending'\n : now - entry.queuedAt > CHAT_OUTBOX_ASK_AFTER_MS\n ? 'ask'\n : 'waiting',\n inMemory: memoryOnly === true,\n }));\n}\n\n/** A sign-out the person chose: every message waiting for `ownerId` goes, on the device and in memory. */\nexport function clearChatOutbox(ownerId: string): Promise<void> {\n return ownerStore(ownerId).clear();\n}\n\n/**\n * Deletes the records kept on this device for `ownerId`, never the messages waiting in this page's\n * memory: for a host whose key for them no longer exists (a chosen sign-out deleted it before the\n * page could delete the records), so nothing can ever open them and they must not be counted.\n */\nexport function clearUnopenableChatOutbox(ownerId: string): Promise<void> {\n return createIndexedDbChatOutboxStore({ ownerId, getKey: async () => null }).clear();\n}\n"],"names":[],"mappings":";;AAiDA,MAAM,kCAAkB,IAAA;AAGxB,SAAS,YAAY,SAAmC;AACtD,SAAO,EAAE,SAAS,QAAQ,YAAY,KAAA;AACxC;AAEA,SAAS,WAAW,SAAiB,MAA0C;AAC7E,MAAI,QAAQ,YAAY,IAAI,OAAO;AACnC,MAAI,CAAC,OAAO;AACV,UAAM,UAAU,EAAE,SAAS,QAAQ,YAAY,OAAO,EAAA;AACtD,YAAQ;AAAA,MACN,MAAM;AAAA,MACN,OAAO,+BAA+B;AAAA,QACpC;AAAA,QACA,QAAQ,CAAC,UAAU,YAAY,QAAQ,QAAQ,OAAO,OAAO;AAAA,MAAA,CAC9D;AAAA,IAAA;AAEH,gBAAY,IAAI,SAAS,KAAK;AAAA,EAChC;AACA,MAAI,KAAM,OAAM,KAAK,UAAU;AAC/B,SAAO,MAAM;AACf;AAGO,SAAS,mBAAmB,MAAyC;AAC1E,SAAO,WAAW,KAAK,SAAS,IAAI;AACtC;AAOO,SAAS,wBAAwB,SAAkC;AACxE,SAAO,WAAW,OAAO,EAAE,MAAA;AAC7B;AAOO,SAAS,oBAAoB,SAAiB,UAAkC;AACrF,SAAO,WAAW,OAAO,EAAE,UAAU,QAAQ;AAC/C;AA0BA,eAAsB,uBACpB,SACA,MAAc,KAAK,OACkB;AACrC,QAAM,UAAU,MAAM,WAAW,OAAO,EAAE,QAAA;AAC1C,SAAO,QAAQ,IAAI,CAAC,EAAE,OAAO,OAAO,SAAS,kBAAkB;AAAA,IAC7D,IAAI,MAAM;AAAA,IACV,UAAU,MAAM;AAAA,IAChB,MAAM,MAAM;AAAA,IACZ,SAAS,MAAM;AAAA,IACf,QAAQ,UACJ,WACA,SAAS,MAAM,MAAM,KAAK,6BACxB,YACA,MAAM,MAAM,WAAW,2BACrB,QACA;AAAA,IACR,UAAU,eAAe;AAAA,EAAA,EACzB;AACJ;AAGO,SAAS,gBAAgB,SAAgC;AAC9D,SAAO,WAAW,OAAO,EAAE,MAAA;AAC7B;AAOO,SAAS,0BAA0B,SAAgC;AACxE,SAAO,+BAA+B,EAAE,SAAS,QAAQ,YAAY,KAAA,CAAM,EAAE,MAAA;AAC/E;"}
1
+ {"version":3,"file":"chat-outbox.js","sources":["../../src/offline/chat-outbox.ts"],"sourcesContent":["import {\n adoptUnscopedChatSessions,\n CHAT_OUTBOX_ASK_AFTER_MS,\n type ChatOutboxDirectory,\n type ChatOutboxDirectoryThread,\n type ChatOutboxListedEntry,\n type ChatOutboxListing,\n type ChatOutboxSignal,\n type ChatOutboxStorageSource,\n type ChatSessionKeyProvider,\n type ChatSessionKeyPurpose,\n chatSessionBackend,\n chatSessionMemoryBackend,\n chatSessionMemoryNamespace,\n chatSessionNamespace,\n clearChatOutboxes,\n countChatOutboxMessages as countChatOutboxSource,\n createChatOutboxDirectory,\n createLegacyChatOutboxReader,\n createSealedSessionCodec,\n type LegacyChatOutboxReader,\n listChatOutboxes,\n sessionPrincipal,\n} from '@athenaintel/agent-runtime';\n\n/**\n * Opt-in: messages typed while Athena can't be reached wait on this device, sealed with the host's\n * key, and are sent once Athena is back while the app is in front, after a countdown the person\n * can cancel (`@athenaintel/agent-runtime`'s chat outbox, shown at the top of the queue tray).\n * Without it a send goes to the transport as before.\n *\n * - `ownerId` names whose they are (the signed-in person, with the environment). Another owner's\n * messages are never shown or sent: each owner's are sealed under their own key.\n * - `getKey(purpose)` returns the AES-GCM key: `read` opens what is kept (the key if one exists,\n * never made for this), `write` keeps a new message (only while the deployment lets devices keep\n * copies). With no `write` key when a conversation opens, its messages wait in memory only, for\n * as long as the page stays open. Unlike the chat history's, this key guards the only copy of\n * what someone wrote: a host must never replace or drop it except at a sign-out the person chose.\n * - `reachability` says Athena can be reached: the host's own model (the device online AND agora\n * answering a health read, as Midas's main process decides it), by default the browser being\n * online. Either way a conversation whose own channel keeps failing to connect counts as out of\n * reach too.\n * - `foreground` says the app is in front; by default a visible document. A desktop host passes\n * `windowInFrontSignal()` (visible and focused).\n * - `openThread` opens another of the person's conversations the tray lists as holding waiting\n * messages (`newChat`: one that never started). Without it, a provider with a thread list\n * switches to it; otherwise the tray names it without Open.\n */\nexport interface AthenaChatOutbox {\n ownerId: string;\n getKey: ChatSessionKeyProvider;\n reachability?: ChatOutboxSignal;\n foreground?: ChatOutboxSignal;\n openThread?: (target: { threadId: string; newChat: boolean }) => void;\n}\n\n/**\n * Where a conversation's session (and so its waiting messages) lives when the provider keeps a\n * chat outbox: `pending` until the owner's namespace and write key are known, then sealed in\n * IndexedDB, or in page memory where there is no write key (or no IndexedDB).\n */\nexport type AthenaChatSessionKeeping =\n | { kind: 'pending' }\n | {\n kind: 'sealed';\n namespace: string;\n /** The owner's statewire principal ({@link ChatOutboxOwnerStorage.principal}). */\n principal: string;\n codec: ChatOutboxOwnerStorage['codec'];\n }\n | {\n kind: 'memory';\n scope: string;\n /** The owner's statewire principal ({@link ChatOutboxOwnerStorage.principal}). */\n principal: string;\n /**\n * Conversations that already kept messages sealed on this device when the write key went\n * (the deployment stopped letting devices keep copies): they reopen that record with the\n * read key, so what waits there can still be sent, edited or discarded.\n */\n sealedThreads?: {\n namespace: string;\n codec: ChatOutboxOwnerStorage['codec'];\n threads: ReadonlySet<string>;\n };\n };\n\n/**\n * Where `owner`'s conversations keep their sessions now: sealed when this page can keep sealed\n * sessions and the host gives a write key, in memory otherwise.\n */\nexport async function resolveChatSessionKeeping(\n owner: ChatOutboxOwnerStorage,\n): Promise<Exclude<AthenaChatSessionKeeping, { kind: 'pending' }>> {\n const namespace = await owner.namespace;\n if (namespace !== null) {\n const writeKey = await owner.host.current.getKey('write').catch(() => null);\n if (writeKey) return { kind: 'sealed', namespace, principal: owner.principal, codec: owner.codec };\n const threads = await threadsKeptSealed(owner, namespace);\n if (threads.size > 0) {\n return {\n kind: 'memory',\n scope: owner.memoryScope,\n principal: owner.principal,\n sealedThreads: { namespace, codec: owner.drainCodec, threads },\n };\n }\n }\n return { kind: 'memory', scope: owner.memoryScope, principal: owner.principal };\n}\n\n/** Threads whose sealed record holds waiting messages this page can open with the read key. */\nasync function threadsKeptSealed(\n owner: ChatOutboxOwnerStorage,\n namespace: string,\n): Promise<ReadonlySet<string>> {\n const readKey = await owner.host.current.getKey('read').catch(() => null);\n if (!readKey) return new Set();\n const listing = await listChatOutboxes({\n backend: chatSessionBackend(),\n namespace,\n principal: owner.principal,\n codec: owner.codec,\n }).catch(() => EMPTY_LISTING);\n return new Set(\n listing.threads.filter(({ entries }) => entries.length > 0).map(({ threadId }) => threadId),\n );\n}\n\n/** The environment chat sessions of the SDK are kept under (`ownerId` already names the deployment). */\nconst SDK_CHAT_SESSION_ENVIRONMENT = 'athena-sdk';\n\n/**\n * Where one owner's waiting messages live in this page: each conversation's statewire session\n * (sealed in IndexedDB, or in page memory where there is no write key), the previous build's\n * store until each conversation moves its messages over, and one live list of all of them.\n */\nexport interface ChatOutboxOwnerStorage {\n ownerId: string;\n /**\n * The owner's statewire principal (`user:<ownerId>`): the owner is the account the host names,\n * and every session record sits under it (`<namespace><principal>:<threadId>`).\n */\n principal: string;\n /** Seals and opens this owner's session records with the latest host's key. */\n codec: ReturnType<typeof createSealedSessionCodec>;\n /**\n * Reopens a record already kept on the device once there is no write key, rewriting it with the\n * read key only as its waiting messages are sent or discarded (`sealedThreads`).\n */\n drainCodec: ReturnType<typeof createSealedSessionCodec>;\n /** The previous build's sealed store (`athena-chat-outbox:v1`). */\n legacy: LegacyChatOutboxReader;\n /** The owner's sealed-session namespace; `null` where this page cannot keep sealed sessions. */\n namespace: Promise<string | null>;\n /** The page-memory sessions' scope (`ChatSessionStorage({kind: 'memory', scope})`). */\n memoryScope: string;\n /** Every conversation's waiting messages, sealed and in memory. */\n directory: ChatOutboxDirectory;\n /** The latest host of this owner: the codec and the legacy reader ask it for the key. */\n host: { current: AthenaChatOutbox };\n /** Drops the keys the codec kept (a sign-out): the next seal asks the host again. */\n forgetKeys: () => void;\n}\n\n// process-local: one storage per owner in this page, so every provider of the person (a chat in a\n// tab, another in a pane) shares one codec (statewire keys a session by it), one live list and the\n// page-memory sessions of conversations this device could not keep.\nconst owners = new Map<string, ChatOutboxOwnerStorage>();\n\n/** A host that has no key to give (counting and deleting never need one). */\nfunction keylessHost(ownerId: string): AthenaChatOutbox {\n return { ownerId, getKey: async () => null };\n}\n\nfunction canKeepSealedSessions(): boolean {\n return (\n typeof indexedDB !== 'undefined' &&\n typeof crypto !== 'undefined' &&\n typeof crypto.subtle !== 'undefined'\n );\n}\n\nfunction memorySource(ownerId: string): ChatOutboxStorageSource {\n return {\n backend: chatSessionMemoryBackend(),\n namespace: chatSessionMemoryNamespace(ownerId),\n principal: sessionPrincipal(ownerId),\n };\n}\n\nfunction sealedSource(\n owner: Pick<ChatOutboxOwnerStorage, 'codec' | 'legacy' | 'principal'>,\n namespace: string,\n): ChatOutboxStorageSource {\n return {\n backend: chatSessionBackend(),\n namespace,\n principal: owner.principal,\n codec: owner.codec,\n legacy: owner.legacy,\n };\n}\n\nconst EMPTY_LISTING: ChatOutboxListing = { threads: [], unreadable: 0 };\n\n/** Both listings as one: a thread's entries from either, oldest first; threads by their oldest. */\nfunction mergeListings(a: ChatOutboxListing, b: ChatOutboxListing): ChatOutboxListing {\n if (b.threads.length === 0 && b.unreadable === 0) return a;\n if (a.threads.length === 0 && a.unreadable === 0) return b;\n const byThread = new Map<string, ChatOutboxListedEntry[]>();\n for (const thread of [...a.threads, ...b.threads]) {\n const list = byThread.get(thread.threadId) ?? [];\n for (const entry of thread.entries) if (!list.some(({ id }) => id === entry.id)) list.push(entry);\n byThread.set(thread.threadId, list);\n }\n const threads: ChatOutboxDirectoryThread[] = [...byThread]\n .map(([threadId, entries]) => ({\n threadId,\n entries: entries.sort((x, y) => x.queuedAt - y.queuedAt),\n }))\n .sort((x, y) => (x.entries[0]?.queuedAt ?? 0) - (y.entries[0]?.queuedAt ?? 0));\n return { threads, unreadable: a.unreadable + b.unreadable };\n}\n\n/** What a listing shows, as one string: two reads of the same messages compare equal. */\nfunction listingSignature(listing: ChatOutboxListing): string {\n return JSON.stringify([\n listing.unreadable,\n listing.threads.map(({ threadId, entries }) => [\n threadId,\n entries.map(({ id, state, failed, queuedAt, text }) => [id, state, failed, queuedAt, text]),\n ]),\n ]);\n}\n\n/**\n * The sealed directory (once the namespace resolves) and the memory one as one directory, with one\n * snapshot object per pair of inner snapshots.\n */\nfunction mergedDirectory({\n memory,\n sealed,\n}: {\n memory: ChatOutboxDirectory;\n sealed: Promise<ChatOutboxDirectory | null>;\n}): ChatOutboxDirectory {\n let sealedDirectory: ChatOutboxDirectory | null = null;\n let cached: { memory: ChatOutboxListing; sealed: ChatOutboxListing; merged: ChatOutboxListing } | null = null;\n const listeners = new Set<() => void>();\n let stops: (() => void)[] = [];\n let generation = 0;\n // Inner directories hand out a new listing on every read: listeners hear only a change.\n let heard = listingSignature(EMPTY_LISTING);\n const notify = () => {\n const signature = listingSignature(directory.getSnapshot());\n if (signature === heard) return;\n heard = signature;\n for (const listener of [...listeners]) {\n try {\n listener();\n } catch {\n // A listener's fault never reaches the directory.\n }\n }\n };\n const start = () => {\n const started = ++generation;\n stops.push(memory.subscribe(notify));\n memory.refresh();\n void sealed.then((directory) => {\n sealedDirectory = directory;\n if (!directory || started !== generation || listeners.size === 0) return;\n stops.push(directory.subscribe(notify));\n directory.refresh();\n });\n };\n const directory: ChatOutboxDirectory = {\n getSnapshot() {\n const memorySnapshot = memory.getSnapshot();\n const sealedSnapshot = sealedDirectory?.getSnapshot() ?? EMPTY_LISTING;\n if (!cached || cached.memory !== memorySnapshot || cached.sealed !== sealedSnapshot) {\n cached = {\n memory: memorySnapshot,\n sealed: sealedSnapshot,\n merged: mergeListings(sealedSnapshot, memorySnapshot),\n };\n }\n return cached.merged;\n },\n subscribe(listener) {\n listeners.add(listener);\n if (listeners.size === 1) start();\n return () => {\n listeners.delete(listener);\n if (listeners.size === 0) {\n generation += 1;\n for (const stop of stops) stop();\n stops = [];\n }\n };\n },\n refresh() {\n memory.refresh();\n sealedDirectory?.refresh();\n },\n };\n return directory;\n}\n\n/**\n * The key the sealed sessions use, per purpose, asked of the latest host once and kept while that\n * host stays: a session seals its record on every save, and a host that asks its key of another\n * process (the desktop's main) must not be asked on each one. No key is asked again next time.\n */\nfunction sessionKeys(current: { current: AthenaChatOutbox }): {\n getKey: ChatSessionKeyProvider;\n forget: () => void;\n} {\n let keysOf: AthenaChatOutbox | null = null;\n const keys = new Map<ChatSessionKeyPurpose, Promise<CryptoKey | null>>();\n const getKey: ChatSessionKeyProvider = (purpose) => {\n const host = current.current;\n if (keysOf !== host) {\n keysOf = host;\n keys.clear();\n }\n let key = keys.get(purpose);\n if (!key) {\n const asked = host.getKey(purpose).catch(() => null);\n key = asked;\n keys.set(purpose, asked);\n void asked.then((value) => {\n if (value === null && keys.get(purpose) === asked) keys.delete(purpose);\n });\n }\n return key;\n };\n return { getKey, forget: () => keys.clear() };\n}\n\nfunction ownerStorage(ownerId: string, host?: AthenaChatOutbox): ChatOutboxOwnerStorage {\n let owner = owners.get(ownerId);\n if (!owner) {\n const current = { current: host ?? keylessHost(ownerId) };\n const principal = sessionPrincipal(ownerId);\n const sealedAvailable = canKeepSealedSessions();\n // The namespace is the owner's: the records statewire 0.24 kept in it without the principal in\n // the key are theirs, and move under it before anything mounts or lists them.\n const namespace: Promise<string | null> = sealedAvailable\n ? chatSessionNamespace({ environment: SDK_CHAT_SESSION_ENVIRONMENT, ownerId })\n .then(async (resolved) => {\n await adoptUnscopedChatSessions({\n backend: chatSessionBackend(),\n namespace: resolved,\n principal,\n }).catch(() => 0);\n return resolved;\n })\n .catch(() => null)\n : Promise.resolve(null);\n const keys = sessionKeys(current);\n const codec = createSealedSessionCodec({ getKey: keys.getKey, scope: ownerId });\n const drainCodec = createSealedSessionCodec({\n getKey: (purpose) => keys.getKey(purpose === 'write' ? 'read' : purpose),\n scope: ownerId,\n });\n const legacy = createLegacyChatOutboxReader({\n ownerId,\n getKey: () => current.current.getKey('read'),\n });\n const directory = mergedDirectory({\n memory: createChatOutboxDirectory(memorySource(ownerId)),\n sealed: namespace.then((resolved) =>\n resolved === null\n ? null\n : createChatOutboxDirectory(sealedSource({ codec, legacy, principal }, resolved)),\n ),\n });\n owner = {\n ownerId,\n principal,\n codec,\n drainCodec,\n legacy,\n namespace,\n memoryScope: ownerId,\n host: current,\n directory,\n forgetKeys: keys.forget,\n };\n owners.set(ownerId, owner);\n }\n if (host) owner.host.current = host;\n return owner;\n}\n\n/** The page's chat outbox storage for `host`'s owner, made on first use. */\nexport function chatOutboxStorageFor(host: AthenaChatOutbox): ChatOutboxOwnerStorage {\n return ownerStorage(host.ownerId, host);\n}\n\n/** The owner's sealed source, or `null` where this page keeps no sealed sessions. */\nasync function sealedSourceOf(owner: ChatOutboxOwnerStorage): Promise<ChatOutboxStorageSource | null> {\n const namespace = await owner.namespace;\n return namespace === null ? null : sealedSource(owner, namespace);\n}\n\n/**\n * How many messages wait for `ownerId` (kept on the device, including records this build cannot\n * open, and waiting in this page's memory), counted without asking for a key it does not have.\n * Rejects when the device's records cannot be counted at all.\n */\nexport async function countChatOutboxMessages(ownerId: string): Promise<number> {\n const owner = ownerStorage(ownerId);\n const sealed = await sealedSourceOf(owner);\n const [kept, inMemory] = await Promise.all([\n sealed ? countChatOutboxSource(sealed) : 0,\n countChatOutboxSource(memorySource(ownerId)),\n ]);\n return kept + inMemory;\n}\n\n/**\n * Calls `listener` after any change to `ownerId`'s waiting messages, this window's or another's\n * (one kept, handed to its conversation, cancelled, failed or retried), so a host can show how many\n * wait (`countChatOutboxMessages`) without asking on a timer. Returns what stops it.\n */\nexport function subscribeChatOutbox(ownerId: string, listener: () => void): () => void {\n return ownerStorage(ownerId).directory.subscribe(listener);\n}\n\n/** A message waiting in an owner's outbox, as a host lists it (its \"Waiting to sync\" list). */\nexport interface ChatOutboxMessageSummary {\n id: string;\n threadId: string;\n /** The text as it will be sent. */\n text: string;\n /** Typed into a chat that had never started. */\n newChat: boolean;\n /**\n * Where it stands, as the queue tray shows it: waiting to be sent, handed to its conversation\n * (released from the outbox and on its way, or sent and not answered yet), waiting for the person\n * (it waited more than a day: Send, Edit or Discard), or failed (Retry, Edit or Discard; never\n * retried on its own).\n */\n status: 'waiting' | 'sending' | 'ask' | 'failed';\n /** Kept only in this page's memory: this device could not keep it. */\n inMemory: boolean;\n /**\n * When it was typed, or sent where it went at once (epoch ms). A host counts a message `sending`\n * as waiting to sync only once it goes unaccepted for a while (`messageWaitsToSync` in\n * `@athenaintel/agent-runtime/offline-status`): the list holds every send until its answer is\n * written back, an ordinary one on its way included.\n */\n queuedAt: number;\n}\n\nfunction summaryOf(\n entry: ChatOutboxListedEntry,\n { inMemory, now }: { inMemory: boolean; now: number },\n): ChatOutboxMessageSummary {\n return {\n id: entry.id,\n threadId: entry.threadId,\n text: entry.text,\n newChat: entry.newChat,\n status: entry.failed\n ? 'failed'\n : entry.state !== undefined && entry.state !== 'held'\n ? 'sending'\n : now - entry.queuedAt > CHAT_OUTBOX_ASK_AFTER_MS\n ? 'ask'\n : 'waiting',\n inMemory,\n queuedAt: entry.queuedAt,\n };\n}\n\n/**\n * The messages waiting for `ownerId` that this page can open (oldest first), each with where it\n * stands, for a host's list of what waits to sync; the tray in the conversation acts on them.\n * Records this page cannot open (no key here, a newer build's) are left out, so a host counts with\n * `countChatOutboxMessages`.\n */\nexport async function listChatOutboxMessages(\n ownerId: string,\n now: number = Date.now(),\n): Promise<ChatOutboxMessageSummary[]> {\n const owner = ownerStorage(ownerId);\n const sealed = await sealedSourceOf(owner);\n const [kept, inMemory] = await Promise.all([\n sealed ? listChatOutboxes(sealed) : EMPTY_LISTING,\n listChatOutboxes(memorySource(ownerId)),\n ]);\n const summaries = [\n ...kept.threads.flatMap(({ entries }) =>\n entries.map((entry) => summaryOf(entry, { inMemory: false, now })),\n ),\n ...inMemory.threads.flatMap(({ entries }) =>\n entries.map((entry) => summaryOf(entry, { inMemory: true, now })),\n ),\n ];\n return summaries.sort((a, b) => a.queuedAt - b.queuedAt);\n}\n\n/** A sign-out the person chose: every message waiting for `ownerId` goes, on the device and in memory. */\nexport async function clearChatOutbox(ownerId: string): Promise<void> {\n const owner = ownerStorage(ownerId);\n const sealed = await sealedSourceOf(owner);\n owner.forgetKeys();\n if (sealed) await clearChatOutboxes(sealed);\n else await owner.legacy.clear();\n await clearChatOutboxes(memorySource(ownerId));\n owner.directory.refresh();\n}\n\n/**\n * Deletes the records kept on this device for `ownerId`, never the messages waiting in this page's\n * memory: for a host whose key for them no longer exists (a chosen sign-out deleted it before the\n * page could delete the records), so nothing can ever open them and they must not be counted.\n */\nexport async function clearUnopenableChatOutbox(ownerId: string): Promise<void> {\n const owner = ownerStorage(ownerId);\n owner.forgetKeys();\n const sealed = await sealedSourceOf(owner);\n if (sealed) await clearChatOutboxes(sealed);\n else await owner.legacy.clear();\n owner.directory.refresh();\n}\n"],"names":["directory","countChatOutboxSource"],"mappings":";;;;AA2FA,eAAsB,0BACpB,OACiE;AACjE,QAAM,YAAY,MAAM,MAAM;AAC9B,MAAI,cAAc,MAAM;AACtB,UAAM,WAAW,MAAM,MAAM,KAAK,QAAQ,OAAO,OAAO,EAAE,MAAM,MAAM,IAAI;AAC1E,QAAI,SAAU,QAAO,EAAE,MAAM,UAAU,WAAW,WAAW,MAAM,WAAW,OAAO,MAAM,MAAA;AAC3F,UAAM,UAAU,MAAM,kBAAkB,OAAO,SAAS;AACxD,QAAI,QAAQ,OAAO,GAAG;AACpB,aAAO;AAAA,QACL,MAAM;AAAA,QACN,OAAO,MAAM;AAAA,QACb,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AAA;AAClB;AAOA,eAAsB,0BAA0B,SAAgC;AAC9E,QAAM,QAAQ,aAAa,OAAO;AAClC,QAAM,WAAA;AACN,QAAM,SAAS,MAAM,eAAe,KAAK;AACzC,MAAI,OAAQ,OAAM,kBAAkB,MAAM;AAAA,MACrC,OAAM,MAAM,OAAO,MAAA;AACxB,QAAM,UAAU,QAAA;AAClB;"}
@@ -3,6 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
4
  const react = require("@assistant-ui/react");
5
5
  const require$$0 = require("react");
6
+ const namedAgents = require("../agent-runtime/src/named-agents.cjs");
6
7
  const offlineHistory = require("../offline/offline-history.cjs");
7
8
  const chatOutbox = require("../offline/chat-outbox.cjs");
8
9
  const athenaUrls = require("../lib/athena-urls.cjs");
@@ -10,6 +11,7 @@ const mint = require("../collab/mint.cjs");
10
11
  const auth = require("../runtime/auth.cjs");
11
12
  const AthenaAuthContext = require("../auth/AthenaAuthContext.cjs");
12
13
  const AthenaCredentialSourceContext = require("../auth/AthenaCredentialSourceContext.cjs");
14
+ const athenaDataClient = require("../data/athena-data-client.cjs");
13
15
  const credentialSource = require("../auth/credential-source.cjs");
14
16
  const authRefusalRestart = require("../runtime/auth-refusal-restart.cjs");
15
17
  const useAthenaStatewireRuntime = require("../runtime/useAthenaStatewireRuntime.cjs");
@@ -22,6 +24,7 @@ const statewireThreadConfigLane = require("../runtime/statewire-thread-config-la
22
24
  const mintThreadId = require("../threads/mint-thread-id.cjs");
23
25
  const statewireLifecycleContext = require("./statewire-lifecycle-context.cjs");
24
26
  const composerHandoff = require("../composer/composer-handoff.cjs");
27
+ const attachedReferences = require("../composer/attached-references.cjs");
25
28
  const signBackInDraft = require("../composer/sign-back-in-draft.cjs");
26
29
  const signBackIn = require("../auth/sign-back-in.cjs");
27
30
  const statewireHistoryContext = require("./statewire-history-context.cjs");
@@ -29,6 +32,7 @@ const earlierStepsButton = require("../chat/super-grouping/earlier-steps-button.
29
32
  const useTurnSteps = require("../chat/super-grouping/use-turn-steps.cjs");
30
33
  const statewireWindowContext = require("./statewire-window-context.cjs");
31
34
  const StatewireClientToolBridge = require("../chat/StatewireClientToolBridge.cjs");
35
+ const StatewirePlanModeLaneSync = require("../runtime/StatewirePlanModeLaneSync.cjs");
32
36
  const StatewireThreadConfigLaneSync = require("../runtime/StatewireThreadConfigLaneSync.cjs");
33
37
  const statewireServerLaneContext = require("../runtime/statewire-server-lane-context.cjs");
34
38
  const athenaDiagnostics = require("../diagnostics/athena-diagnostics.cjs");
@@ -54,8 +58,8 @@ const toolOutputs = require("../agent-runtime/src/tool-outputs.cjs");
54
58
  const historyStore = require("../agent-runtime/src/history-store.cjs");
55
59
  const threadStatus = require("../agent-runtime/src/thread-status.cjs");
56
60
  const useDeepAgentChatOutbox = require("../agent-runtime/src/use-deep-agent-chat-outbox.cjs");
57
- const useDeepAgentConfig = require("../agent-runtime/src/use-deep-agent-config.cjs");
58
61
  const chatOutboxSignals = require("../agent-runtime/src/chat-outbox-signals.cjs");
62
+ const useDeepAgentConfig = require("../agent-runtime/src/use-deep-agent-config.cjs");
59
63
  const resolveTokenOverride = ({
60
64
  config,
61
65
  token
@@ -148,6 +152,7 @@ function ComposerDraftCarry({ isNewChat }) {
148
152
  }
149
153
  const EMPTY_MODES = [];
150
154
  const CHAT_OUTBOX_ATTACHMENT_READ_TIMEOUT_MS = 1e4;
155
+ const CHAT_SESSION_KEEPING_PENDING = { kind: "pending" };
151
156
  function withEntry(record, key, value) {
152
157
  if (value === null) {
153
158
  if (!(key in record)) return record;
@@ -182,6 +187,7 @@ function AthenaStatewireRuntimeMount({
182
187
  systemPrompt,
183
188
  appId,
184
189
  extraRunConfig,
190
+ planMode,
185
191
  snapshotCache,
186
192
  toolOutputs: toolOutputs2,
187
193
  chatOutbox: chatOutbox2 = null,
@@ -211,7 +217,7 @@ function AthenaStatewireRuntimeMount({
211
217
  },
212
218
  [binding, threadId]
213
219
  );
214
- const outboxRef = require$$0.useRef(null);
220
+ const [defaultForeground] = require$$0.useState(chatOutboxSignals.documentVisibleSignal);
215
221
  const [lifecycle, dispatchLifecycle] = require$$0.useReducer(
216
222
  statewireLifecycle.statewireLifecycleReducer,
217
223
  statewireLifecycle.initialStatewireLifecycle
@@ -239,6 +245,7 @@ function AthenaStatewireRuntimeMount({
239
245
  systemPrompt,
240
246
  appId,
241
247
  extraRunConfig,
248
+ planMode,
242
249
  snapshotCache,
243
250
  toolOutputs: toolOutputs2,
244
251
  subagentLaneHistory,
@@ -255,9 +262,9 @@ function AthenaStatewireRuntimeMount({
255
262
  onRawConnectionChange: (connection) => {
256
263
  dispatchLifecycle({ type: "raw-connection", reconnect: connection.reconnect });
257
264
  },
258
- onCommandChange: (update) => {
259
- var _a;
260
- return (_a = outboxRef.current) == null ? void 0 : _a.observeCommand(update);
265
+ ...chatOutbox2 && {
266
+ chatSession: chatOutbox2.keeping,
267
+ foreground: chatOutbox2.foreground ?? defaultForeground
261
268
  },
262
269
  // The lane as the host holds it: anything that decides from the lane waits
263
270
  // for this, never the placeholder or remembered snapshot rendered before.
@@ -294,17 +301,20 @@ function AthenaStatewireRuntimeMount({
294
301
  () => chatOutboxSignals.allChatOutboxSignals(hostReachability ?? browserOnline, channelReachability),
295
302
  [hostReachability, browserOnline, channelReachability]
296
303
  );
297
- const [defaultForeground] = require$$0.useState(chatOutboxSignals.documentVisibleSignal);
298
304
  const composerHandoff$1 = composerHandoff.useComposerHandoffStore();
299
305
  const outbox = useDeepAgentChatOutbox.useDeepAgentChatOutbox({
300
306
  client,
301
307
  threadId,
302
308
  isNewChat,
303
- store: (chatOutbox2 == null ? void 0 : chatOutbox2.store) ?? null,
309
+ ...chatOutbox2 && {
310
+ directory: chatOutbox2.storage.directory,
311
+ legacy: { reader: chatOutbox2.storage.legacy }
312
+ },
304
313
  reachability,
305
314
  foreground: (chatOutbox2 == null ? void 0 : chatOutbox2.foreground) ?? defaultForeground,
306
315
  // Cancel and Edit give the draft back, after anything typed since. Its attachments come back
307
- // as mentions in it, remembered so a message held again from it is asked about again.
316
+ // as mentions in it, remembered so a message held again from it is asked about again, the
317
+ // agents it named come back to the To line, and what an app attached to it comes back as chips.
308
318
  restore: (entry) => {
309
319
  const draft = entry.composerMarkdown ?? entry.text;
310
320
  const current = client.composer.getState().text ?? "";
@@ -318,12 +328,13 @@ ${draft}` : draft);
318
328
  attachments: entry.attachments
319
329
  });
320
330
  }
331
+ namedAgents.giveBackDeepAgentOutboxNamedAgents(entry);
332
+ attachedReferences.giveBackHeldAttachedReferences(entry);
321
333
  },
322
334
  ...(chatOutbox2 == null ? void 0 : chatOutbox2.openThread) && { openThread: chatOutbox2.openThread },
323
335
  ...(chatOutbox2 == null ? void 0 : chatOutbox2.checkAttachments) && { checkAttachments: chatOutbox2.checkAttachments },
324
- enabled: chatOutbox2 !== null
336
+ enabled: chatOutbox2 !== null && chatOutbox2.keeping.kind !== "pending"
325
337
  });
326
- outboxRef.current = outbox;
327
338
  authRefusalRestart.useRestartAfterAuthRefusal({
328
339
  connection: lifecycle.connection,
329
340
  reconnect: lifecycle.reconnect
@@ -360,9 +371,10 @@ ${draft}` : draft);
360
371
  lifecycle: lifecycleValue,
361
372
  serverLane,
362
373
  threadConfig,
374
+ planMode: planMode ?? null,
363
375
  outbox
364
376
  }),
365
- [binding, sessionPersistence, threadId, isNewChat, client, lifecycleValue, serverLane, threadConfig, outbox]
377
+ [binding, sessionPersistence, threadId, isNewChat, client, lifecycleValue, serverLane, threadConfig, planMode, outbox]
366
378
  );
367
379
  require$$0.useLayoutEffect(() => {
368
380
  onPublish(snapshot);
@@ -463,6 +475,16 @@ function AthenaStatewireStandalone({
463
475
  },
464
476
  published.threadId
465
477
  ),
478
+ /* @__PURE__ */ jsxRuntime.jsx(
479
+ StatewirePlanModeLaneSync.StatewirePlanModeLaneSync,
480
+ {
481
+ threadId: published.threadId,
482
+ planMode: published.planMode,
483
+ lane: published.serverLane,
484
+ channelLive: statewireLifecycle.isStatewireChannelLive(published.lifecycle.connection)
485
+ },
486
+ `plan-mode:${published.threadId}`
487
+ ),
466
488
  /* @__PURE__ */ jsxRuntime.jsx(ComposerHandoffDrain, {}),
467
489
  /* @__PURE__ */ jsxRuntime.jsx(ComposerDraftCarry, { isNewChat: published.isNewChat }),
468
490
  /* @__PURE__ */ jsxRuntime.jsx(useDeepAgentChatOutbox.DeepAgentChatOutboxContext.Provider, { value: published.outbox, children: /* @__PURE__ */ jsxRuntime.jsx(chatModeContext.AthenaChatModeSelectionContext.Provider, { value: chatModeSelection, children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -571,9 +593,10 @@ function AthenaStatewireActiveThreadHost({
571
593
  ...standaloneProps,
572
594
  children: [
573
595
  /* @__PURE__ */ jsxRuntime.jsx(statewireThreadList.StatewireThreadTitlePoller, {}),
574
- /* @__PURE__ */ jsxRuntime.jsx(statewireThreadList.StatewireThreadListSendSync, { startChannel }),
575
- /* @__PURE__ */ jsxRuntime.jsx(AssetPanelThreadSync, {}),
576
- children
596
+ /* @__PURE__ */ jsxRuntime.jsxs(statewireThreadList.StatewireThreadListSendSync, { startChannel, children: [
597
+ /* @__PURE__ */ jsxRuntime.jsx(AssetPanelThreadSync, {}),
598
+ children
599
+ ] })
577
600
  ]
578
601
  }
579
602
  );
@@ -608,6 +631,7 @@ function AthenaProvider({
608
631
  workbench,
609
632
  knowledgeBase,
610
633
  systemPrompt,
634
+ planMode,
611
635
  appId,
612
636
  threadId: threadIdProp,
613
637
  threadIsNew,
@@ -737,13 +761,25 @@ function AthenaProvider({
737
761
  const chatOutboxRef = require$$0.useRef(chatOutbox$1);
738
762
  chatOutboxRef.current = chatOutbox$1;
739
763
  const chatOutboxOwnerId = (chatOutbox$1 == null ? void 0 : chatOutbox$1.ownerId) ?? null;
740
- const chatOutboxStore = require$$0.useMemo(() => {
764
+ const chatOutboxStorage = require$$0.useMemo(() => {
741
765
  const host = chatOutboxRef.current;
742
- return host && host.ownerId === chatOutboxOwnerId ? chatOutbox.chatOutboxStoreFor(host) : null;
766
+ return host && host.ownerId === chatOutboxOwnerId ? chatOutbox.chatOutboxStorageFor(host) : null;
743
767
  }, [chatOutboxOwnerId]);
744
768
  require$$0.useEffect(() => {
745
- if (chatOutbox$1) chatOutbox.chatOutboxStoreFor(chatOutbox$1);
769
+ if (chatOutbox$1) chatOutbox.chatOutboxStorageFor(chatOutbox$1);
746
770
  }, [chatOutbox$1]);
771
+ const [chatSessionKeeping, setChatSessionKeeping] = require$$0.useState(null);
772
+ require$$0.useEffect(() => {
773
+ if (!chatOutboxStorage) return;
774
+ let live = true;
775
+ void chatOutbox.resolveChatSessionKeeping(chatOutboxStorage).then((keeping) => {
776
+ if (live) setChatSessionKeeping({ storage: chatOutboxStorage, keeping });
777
+ });
778
+ return () => {
779
+ live = false;
780
+ };
781
+ }, [chatOutboxStorage]);
782
+ const chatOutboxKeeping = (chatSessionKeeping == null ? void 0 : chatSessionKeeping.storage) === chatOutboxStorage && chatSessionKeeping ? chatSessionKeeping.keeping : CHAT_SESSION_KEEPING_PENDING;
747
783
  const chatOutboxReachability = chatOutbox$1 == null ? void 0 : chatOutbox$1.reachability;
748
784
  const chatOutboxForeground = chatOutbox$1 == null ? void 0 : chatOutbox$1.foreground;
749
785
  const chatOutboxOpenThread = chatOutbox$1 == null ? void 0 : chatOutbox$1.openThread;
@@ -762,16 +798,17 @@ function AthenaProvider({
762
798
  })
763
799
  );
764
800
  const chatOutboxHost = require$$0.useMemo(
765
- () => chatOutboxOwnerId === null ? null : {
766
- store: chatOutboxStore,
801
+ () => chatOutboxStorage === null ? null : {
802
+ storage: chatOutboxStorage,
803
+ keeping: chatOutboxKeeping,
767
804
  ...chatOutboxReachability && { reachability: chatOutboxReachability },
768
805
  ...chatOutboxForeground && { foreground: chatOutboxForeground },
769
806
  ...chatOutboxOpenThread && { openThread: chatOutboxOpenThread },
770
807
  checkAttachments: checkChatOutboxAttachments
771
808
  },
772
809
  [
773
- chatOutboxOwnerId,
774
- chatOutboxStore,
810
+ chatOutboxStorage,
811
+ chatOutboxKeeping,
775
812
  chatOutboxReachability,
776
813
  chatOutboxForeground,
777
814
  chatOutboxOpenThread,
@@ -887,6 +924,7 @@ function AthenaProvider({
887
924
  workbench,
888
925
  knowledgeBase,
889
926
  systemPrompt,
927
+ planMode,
890
928
  appId,
891
929
  extraRunConfig: configuredExtraRunConfig,
892
930
  snapshotCache,
@@ -928,7 +966,7 @@ function AthenaProvider({
928
966
  {
929
967
  className: themeStyleVars ? "athena-sdk athena-themed" : "athena-sdk",
930
968
  style: themeStyleVars,
931
- children: /* @__PURE__ */ jsxRuntime.jsx(PostHogProvider.PostHogProvider, { config: posthogConfig, children: /* @__PURE__ */ jsxRuntime.jsx(composerHandoff.ComposerHandoffContext.Provider, { value: composerHandoff$1, children: /* @__PURE__ */ jsxRuntime.jsx(statewireSessionLane.StatewireSessionLaneContext.Provider, { value: sessionLane, children: /* @__PURE__ */ jsxRuntime.jsx(themeStyleContext.AthenaThemeStyleContext.Provider, { value: themeStyleVars, children: /* @__PURE__ */ jsxRuntime.jsx(AthenaCredentialSourceContext.AthenaCredentialSourceContext.Provider, { value: credentials, children: /* @__PURE__ */ jsxRuntime.jsx(agentSelectionContext.AthenaAgentSelectionContext.Provider, { value: agentSelection, children: /* @__PURE__ */ jsxRuntime.jsx(offlineHistory.AthenaOfflineSnapshotsContext.Provider, { value: offlineSnapshots, children: awaitingKeptSnapshots ? null : inner }) }) }) }) }) }) })
969
+ children: /* @__PURE__ */ jsxRuntime.jsx(PostHogProvider.PostHogProvider, { config: posthogConfig, children: /* @__PURE__ */ jsxRuntime.jsx(composerHandoff.ComposerHandoffContext.Provider, { value: composerHandoff$1, children: /* @__PURE__ */ jsxRuntime.jsx(statewireSessionLane.StatewireSessionLaneContext.Provider, { value: sessionLane, children: /* @__PURE__ */ jsxRuntime.jsx(themeStyleContext.AthenaThemeStyleContext.Provider, { value: themeStyleVars, children: /* @__PURE__ */ jsxRuntime.jsx(AthenaCredentialSourceContext.AthenaCredentialSourceContext.Provider, { value: credentials, children: /* @__PURE__ */ jsxRuntime.jsx(agentSelectionContext.AthenaAgentSelectionContext.Provider, { value: agentSelection, children: /* @__PURE__ */ jsxRuntime.jsx(offlineHistory.AthenaOfflineSnapshotsContext.Provider, { value: offlineSnapshots, children: /* @__PURE__ */ jsxRuntime.jsx(athenaDataClient.AthenaDataQueryClientProvider, { children: awaitingKeptSnapshots ? null : inner }) }) }) }) }) }) }) })
932
970
  }
933
971
  );
934
972
  }