@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 +1 @@
1
- {"version":3,"file":"quota-safe-local-storage-session.cjs","sources":["../../../../agent-runtime/src/quota-safe-local-storage-session.ts"],"sourcesContent":["import { resource, useResource } from \"@assistant-ui/tap\";\nimport type { StatewireClient, StatewireProtocol } from \"statewire\";\nimport { KeyValueSessionStorage } from \"statewire/storage\";\nimport { useCallback, useEffect, useMemo, useRef } from \"react\";\nimport {\n type DeepAgentSessionLaneScope,\n isSameSessionLaneScope,\n} from \"./session-lane-scope\";\nimport { DEEP_AGENT_STATEWIRE_PROTOCOL } from \"./statewire-transport\";\n\nconst SESSION_PREFIX = \"aui:statewire-session:\";\nconst SESSION_LOCK_PREFIX = \"aui:statewire-session-lock:\";\nconst SESSION_ACTIVE_PREFIX = \"aui:statewire-session-active:\";\nconst DAY_MS = 24 * 60 * 60 * 1000;\n/** The stored-record formats the statewire this build ships reads (it writes 3). */\nconst READABLE_STORAGE_VERSIONS: ReadonlySet<unknown> = new Set([1, 2, 3]);\n\n/** Structural view of the browser storage global — this package compiles\n * without the DOM lib (React Native honesty; see `globals.d.ts`). */\ntype StorageLike = {\n getItem(key: string): string | null;\n setItem(key: string, value: string): void;\n removeItem(key: string): void;\n key(index: number): string | null;\n readonly length: number;\n};\n\ntype LockGrant = object | null;\n\n/** The Web Locks API surface the session uses (`navigator.locks`). */\ntype LockManagerLike = {\n request<T>(\n name: string,\n callback: (lock: LockGrant) => T | Promise<T>\n ): Promise<T>;\n request<T>(\n name: string,\n options: { mode?: \"shared\" | \"exclusive\"; ifAvailable?: boolean },\n callback: (lock: LockGrant) => T | Promise<T>\n ): Promise<T>;\n};\n\ntype StorageEventLike = { key: string | null };\n\ntype BrowserGlobals = {\n localStorage?: StorageLike;\n navigator?: { locks?: LockManagerLike };\n addEventListener?: (\n type: \"storage\",\n listener: (event: StorageEventLike) => void\n ) => void;\n removeEventListener?: (\n type: \"storage\",\n listener: (event: StorageEventLike) => void\n ) => void;\n};\n\nconst browserGlobals = globalThis as BrowserGlobals;\n\n/** A persisted session record: per-lane failed entries (a pre-lane record carried them at the root). */\ntype SessionRecordLike = {\n failed?: unknown;\n lanes?: Record<string, { failed?: unknown } | null | undefined> | null;\n};\n\nexport function readPersistedFailedSendStamps(\n sessionKey: string\n): ReadonlyMap<string, number> | null {\n const storage = browserGlobals.localStorage;\n if (!storage) return null;\n let record: SessionRecordLike | null;\n try {\n const raw = storage.getItem(SESSION_PREFIX + sessionKey);\n record =\n raw === null ? null : (JSON.parse(raw) as SessionRecordLike | null);\n } catch {\n return null;\n }\n return readFailedSendStampsFromRecord(record);\n}\n\n/**\n * Send stamps (message id → epoch ms of the original send) off an already\n * loaded session record's failed lane — the storage-agnostic half of\n * {@link readPersistedFailedSendStamps}, for hosts whose session store is not\n * localStorage (the React Native AsyncStorage-backed store reads its record\n * synchronously through `SessionStorage.load()`).\n *\n * Returns `null` for no record (every failed entry then counts as fresh) and\n * an empty map for a record without failures.\n */\nexport function readFailedSendStampsFromRecord(\n record: SessionRecordLike | null | undefined\n): ReadonlyMap<string, number> | null {\n if (!record || typeof record !== \"object\") return null;\n const stamps = new Map<string, number>();\n const lanes =\n record.lanes && typeof record.lanes === \"object\" ? record.lanes : {};\n const failed = [\n ...(Array.isArray(record.failed) ? record.failed : []),\n ...Object.values(lanes).flatMap((lane) =>\n Array.isArray(lane?.failed) ? lane.failed : []\n ),\n ];\n for (const entry of failed) {\n const failed = entry as {\n ts?: unknown;\n params?: readonly { message?: { id?: unknown } }[];\n } | null;\n const messageId = failed?.params?.[0]?.message?.id;\n if (typeof messageId === \"string\" && typeof failed?.ts === \"number\") {\n stamps.set(messageId, failed.ts);\n }\n }\n return stamps;\n}\n\n/** A storage operation the session survived by degrading instead of failing. */\nexport type SessionStorageDegradation = {\n operation:\n | \"getItem\"\n | \"setItem\"\n | \"removeItem\"\n | \"getAllKeys\"\n | \"withUnused\"\n /** The lock manager refused the transaction fence; it ran unfenced. */\n | \"lock\"\n /**\n * The stored record is one this build cannot read (not JSON, or a newer\n * storage version): served as absent, and the key is shielded from being\n * overwritten so the record survives this tab.\n */\n | \"record\"\n /** statewire's own storage failure (a structurally invalid stored record). */\n | \"session\"\n /**\n * Queued commands persisted by an earlier statewire build no longer fit\n * the current wire/protocol range: parked in the lane's failed list (the\n * send-recovery sweep re-dispatches them) instead of blocking the mount.\n */\n | \"migrate\";\n key: string;\n error: unknown;\n};\n\ntype ProducedRange = NonNullable<StatewireClient.SessionCommand[\"produced\"]>;\n\nconst inRange = (value: string, range: StatewireProtocol.Range) =>\n value >= (range.minVersion ?? range.version) && value <= range.version;\n\n/** Mirrors statewire's own stored-command compatibility check. */\nconst storedCommandCompatible = (\n protocol: string,\n command: StatewireClient.SessionCommand,\n current: ProducedRange\n): boolean => {\n if (\n !command.produced ||\n !inRange(command.produced.wire.version, current.wire)\n )\n return false;\n if (current.protocols === \"*\") return true;\n if (command.produced.protocols === \"*\") return false;\n const produced = command.produced.protocols.find((p) => p.name === protocol);\n const offer = current.protocols.find((p) => p.name === protocol);\n return (\n produced !== undefined &&\n offer !== undefined &&\n inRange(produced.version, offer)\n );\n};\n\n/**\n * The oldest wire whose stored statements the current client still replays.\n * Bundled clients before #45143 offered 2026-09-13 through 2026-09-30 and\n * stamped every queued statement with 2026-09-13. The durable statement grammar\n * (protocol, method, params, meta, seq) is the same on 2026-09-30; only\n * frame-level context differs. So those statements ride the current wire\n * unchanged, while the network offer stays native 2026-09-30 only.\n */\nexport const STORED_STATEMENT_WIRE_FLOOR = \"2026-09-13\";\n\n/** A stored command the current wire replays as-is: re-stamp, don't park. */\nconst replayableOnCurrentWire = (\n protocol: string,\n command: StatewireClient.SessionCommand,\n current: ProducedRange\n): boolean =>\n command.produced !== undefined &&\n inRange(command.produced.wire.version, {\n version: current.wire.version,\n minVersion: STORED_STATEMENT_WIRE_FLOOR,\n }) &&\n storedCommandCompatible(\n protocol,\n { ...command, produced: { ...command.produced, wire: current.wire } },\n current\n );\n\n/**\n * statewire's `migrate` for a record whose queued commands were produced by\n * an earlier build. A command whose statement the current wire still replays\n * ({@link STORED_STATEMENT_WIRE_FLOOR}: an approval's `run/input` saved by a\n * previous bundled client, say) stays queued, re-stamped with the current\n * range, so it is delivered with its original seq. Every other incompatible\n * command leaves its lane's queue and is\n * retained as a `lost`/`session-lost` failed send re-stamped with the current\n * range. Client identity, lane clocks, compatible commands and existing failed\n * history are untouched, so the mount proceeds and the send-recovery sweep\n * (or the user, via the failed-send UI) re-dispatches the parked sends under\n * the negotiated format instead of the runtime throwing before it dials.\n *\n * Returns the record itself when nothing needed migrating, and the count of\n * parked commands otherwise.\n */\nexport function parkIncompatibleSessionCommands(\n record: StatewireClient.SessionRecord,\n current: ProducedRange,\n now: number = Date.now()\n): { record: StatewireClient.SessionRecord; parked: number; restamped: number } {\n let parked = 0;\n let restamped = 0;\n const lanes: Record<string, StatewireClient.SessionLane> = {};\n for (const [protocol, lane] of Object.entries(record.lanes)) {\n const kept: StatewireClient.SessionCommand[] = [];\n const failed: StatewireClient.FailedCommand[] = [];\n let laneRestamped = 0;\n for (const command of lane.commands) {\n if (storedCommandCompatible(protocol, command, current)) {\n kept.push(command);\n continue;\n }\n if (replayableOnCurrentWire(protocol, command, current)) {\n kept.push({ ...command, produced: current });\n laneRestamped += 1;\n continue;\n }\n failed.push({\n protocol,\n produced: current,\n command: command.method,\n params: command.params,\n ...(command.meta !== undefined && { meta: command.meta }),\n failure: { fate: \"lost\", cause: \"session-lost\" },\n ts: now,\n seq: command.seq,\n });\n }\n parked += failed.length;\n restamped += laneRestamped;\n lanes[protocol] =\n failed.length === 0 && laneRestamped === 0\n ? lane\n : {\n ...lane,\n commands: kept,\n ...((failed.length > 0 || lane.failed !== undefined) && {\n failed: [...(lane.failed ?? []), ...failed],\n }),\n };\n }\n return parked === 0 && restamped === 0\n ? { record, parked, restamped }\n : { record: { ...record, lanes }, parked, restamped };\n}\n\n/**\n * Whether `error` is the browser refusing a write for lack of room, under\n * every name the engines use — `QuotaExceededError` (Chromium, WebKit, current\n * Firefox), `NS_ERROR_DOM_QUOTA_REACHED` (older Firefox), the legacy\n * `DOMException` codes 22 (WebKit) and 1014 (Firefox) — or a plain error whose\n * message carries one of those (storage proxies and WebViews rewrap the\n * exception). Olympus's `isStorageQuotaError` recognises the same set; the two\n * stay in step.\n */\nexport function isStorageQuotaError(error: unknown): boolean {\n if (typeof error !== \"object\" || error === null) return false;\n const { name, code, message } = error as {\n name?: unknown;\n code?: unknown;\n message?: unknown;\n };\n return (\n name === \"QuotaExceededError\" ||\n name === \"NS_ERROR_DOM_QUOTA_REACHED\" ||\n code === 22 ||\n code === 1014 ||\n (typeof message === \"string\" &&\n /exceeded the quota|quotaexceedederror|ns_error_dom_quota_reached/i.test(\n message\n ))\n );\n}\n\n/** The one quota shape statewire's retention sweep recognises. */\nfunction asStatewireQuotaError(error: unknown): Error {\n if (error instanceof Error && error.name === \"QuotaExceededError\")\n return error;\n const normalized = new Error(\n error instanceof Error ? error.message : \"storage quota exceeded\"\n );\n normalized.name = \"QuotaExceededError\";\n return normalized;\n}\n\n/**\n * Why `raw` is a stored record this build cannot read, or `undefined` when it\n * may be one. Mirrors the two decode failures statewire raises for a record it\n * cannot read — invalid JSON, and a `statewireStorageVersion` newer than the\n * ones this build's statewire decodes (a tab left open across a\n * statewire upgrade, reading the record a newer tab keeps) — because statewire\n * throws those out of the resource at mount instead of treating the record as\n * absent. A structurally invalid record of the right version still fails\n * inside statewire.\n */\nfunction unreadableRecord(raw: string): Error | undefined {\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch (error) {\n return error instanceof Error\n ? error\n : new Error(\"stored session record is not JSON\");\n }\n if (typeof parsed !== \"object\" || parsed === null) {\n return new Error(\"stored session record is not an object\");\n }\n const version = (parsed as { statewireStorageVersion?: unknown })\n .statewireStorageVersion;\n if (version !== undefined && !READABLE_STORAGE_VERSIONS.has(version)) {\n return new Error(\n `stored session record uses storage version ${String(version)}`\n );\n }\n return undefined;\n}\n\ntype SyncBackend = {\n getItem: (key: string) => string | null;\n setItem: (key: string, value: string) => void;\n removeItem: (key: string) => void;\n getAllKeys: () => readonly string[];\n withUnused: (key: string, action: () => Promise<void>) => Promise<void>;\n};\n\n/**\n * The browser backend `@assistant-ui/react-statewire`'s `LocalStorageSession`\n * uses, reproduced here because that resource does not take a backend: raw\n * `localStorage`, with retention cleanup fenced by the same Web Locks so a\n * sweep never removes a record another tab is actively sharing.\n */\nfunction browserBackend({\n storage,\n locks,\n}: {\n storage: StorageLike;\n locks: LockManagerLike;\n}): SyncBackend {\n return {\n getItem: (key) => storage.getItem(key),\n setItem: (key, value) => storage.setItem(key, value),\n removeItem: (key) => storage.removeItem(key),\n getAllKeys: () =>\n Array.from({ length: storage.length }, (_, index) =>\n storage.key(index)\n ).filter((key): key is string => key !== null),\n withUnused: async (key, action) => {\n await locks.request(\n SESSION_ACTIVE_PREFIX + key,\n { ifAvailable: true },\n async (active) => {\n if (active === null) return;\n await locks.request(\n SESSION_LOCK_PREFIX + key.slice(SESSION_PREFIX.length),\n { ifAvailable: true },\n async (lock) => {\n if (lock === null) return;\n await action();\n }\n );\n }\n );\n },\n };\n}\n\n/**\n * Wraps a synchronous key-value backend so a failing origin degrades the\n * session to memory-only persistence instead of stopping the connection.\n *\n * statewire's session storage latches the first unrecognised write failure\n * and from then on rejects every send (`stopped/storage-error`, \"session\n * storage failed\" on the connection chip). It only recovers a\n * `QuotaExceededError` by that exact name — sweeping old session records and\n * retrying the write once — and latches again when the retry fails too. Here\n * the first quota failure per key is surfaced under that name so the sweep\n * runs; the retry that follows it and every other storage failure are absorbed\n * and reported through `onDegraded`, so chat keeps working.\n *\n * An absorbed write is kept in an in-memory overlay that `getItem` serves\n * first: statewire re-reads the record through `load()` on every shared-mode\n * transaction, so a stale persisted copy would otherwise win back its old\n * `nextSeq`, `clientId` and command journal. The overlay is per tab — another\n * tab sharing the thread still reads the last persisted copy, which is the\n * memory-only degradation this backend exists to allow. A later successful\n * write clears the overlay entry.\n *\n * A key whose read threw, or whose stored value this build cannot read (see\n * {@link unreadableRecord}), is served as absent and shielded: writes to it\n * stay in the overlay for good, so a fresh lane minted over an unreadable\n * record never overwrites what another tab or a newer build persisted.\n */\nexport function quotaTolerantBackend({\n inner,\n onDegraded,\n}: {\n inner: SyncBackend;\n onDegraded: (degradation: SessionStorageDegradation) => void;\n}): SyncBackend & KeyValueSessionStorage.Backend {\n // Keys whose write already surfaced a quota error to statewire: until a\n // write succeeds again, later failures on the key are absorbed instead of\n // surfaced, or every save would re-run statewire's sweep (which evicts\n // other threads' idle records) and the failure would latch on the retry.\n const quotaSurfaced = new Set<string>();\n // Absorbed writes, served ahead of the backend (see the function docs).\n const overlay = new Map<string, string>();\n // Keys served as absent and never written through (see the function docs).\n const shielded = new Set<string>();\n // statewire re-reads and re-decodes the record on every transaction; the\n // readability check is memoised on the raw string so it costs one string\n // comparison per read, not a second parse.\n const checked = new Map<\n string,\n { raw: string; verdict: Error | undefined }\n >();\n const readable = (key: string, raw: string): Error | undefined => {\n const previous = checked.get(key);\n if (previous !== undefined && previous.raw === raw) return previous.verdict;\n const verdict = unreadableRecord(raw);\n checked.set(key, { raw, verdict });\n return verdict;\n };\n return {\n getItem: (key) => {\n const shadowed = overlay.get(key);\n if (shadowed !== undefined) return shadowed;\n if (shielded.has(key)) return null;\n let raw: string | null;\n try {\n raw = inner.getItem(key);\n } catch (error) {\n shielded.add(key);\n onDegraded({ operation: \"getItem\", key, error });\n return null;\n }\n if (raw === null) return null;\n const unreadable = readable(key, raw);\n if (unreadable === undefined) return raw;\n shielded.add(key);\n onDegraded({ operation: \"record\", key, error: unreadable });\n return null;\n },\n setItem: (key, value) => {\n if (shielded.has(key)) {\n overlay.set(key, value);\n return;\n }\n try {\n inner.setItem(key, value);\n overlay.delete(key);\n quotaSurfaced.delete(key);\n } catch (error) {\n if (isStorageQuotaError(error) && !quotaSurfaced.has(key)) {\n quotaSurfaced.add(key);\n throw asStatewireQuotaError(error);\n }\n overlay.set(key, value);\n onDegraded({ operation: \"setItem\", key, error });\n }\n },\n removeItem: (key) => {\n overlay.delete(key);\n if (shielded.has(key)) return;\n try {\n inner.removeItem(key);\n } catch (error) {\n onDegraded({ operation: \"removeItem\", key, error });\n }\n },\n getAllKeys: () => {\n const keys = new Set<string>(overlay.keys());\n try {\n for (const key of inner.getAllKeys()) keys.add(key);\n } catch (error) {\n onDegraded({ operation: \"getAllKeys\", key: \"\", error });\n }\n return [...keys];\n },\n withUnused: async (key, action) => {\n try {\n await inner.withUnused(key, action);\n } catch (error) {\n onDegraded({ operation: \"withUnused\", key, error });\n }\n },\n };\n}\n\n/** A stored record's save stamp, or `undefined` when it carries none. */\nfunction savedAtOf(raw: string | null): number | undefined {\n if (raw === null) return undefined;\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch {\n return undefined;\n }\n if (typeof parsed !== \"object\" || parsed === null) return undefined;\n const { savedAt, updatedAt } = parsed as {\n savedAt?: unknown;\n updatedAt?: unknown;\n };\n const stamp = savedAt ?? updatedAt;\n return typeof stamp === \"number\" && Number.isFinite(stamp)\n ? stamp\n : undefined;\n}\n\n/**\n * Removes session records last saved more than `maxAgeMs` ago, skipping the\n * keys mounted in this tab and, through `withUnused`, those another tab holds.\n *\n * statewire's own retention sweep only retires records with nothing queued and\n * nothing failed: a record still carrying an unconfirmed or failed send is\n * exempt from both its age and count bounds, so every thread left with one\n * kept its key forever. Past the TTL those sends are long out of send\n * recovery's auto-retry window, so the record goes the same way an empty one\n * does.\n */\nexport async function retireExpiredSessionRecords({\n backend,\n mounted,\n maxAgeMs,\n now = Date.now(),\n}: {\n backend: Pick<\n SyncBackend,\n \"getItem\" | \"removeItem\" | \"getAllKeys\" | \"withUnused\"\n >;\n mounted: ReadonlyMap<string, number>;\n maxAgeMs: number;\n now?: number;\n}): Promise<void> {\n for (const key of backend.getAllKeys()) {\n if (!key.startsWith(SESSION_PREFIX) || mounted.has(key)) continue;\n const savedAt = savedAtOf(backend.getItem(key));\n if (savedAt === undefined || now - savedAt <= maxAgeMs) continue;\n await backend.withUnused(key, async () => {\n if (mounted.has(key) || savedAtOf(backend.getItem(key)) !== savedAt)\n return;\n backend.removeItem(key);\n });\n }\n}\n\ntype DegradationListener = (degradation: SessionStorageDegradation) => void;\n\ntype SharedBackend = {\n backend: SyncBackend & KeyValueSessionStorage.Backend;\n listeners: Set<DegradationListener>;\n /** Storage keys of the sessions mounted in this tab, with mount counts. */\n mounted: Map<string, number>;\n};\n\n/**\n * One backend per storage object — per origin, in a browser — shared by every\n * session mounted in the tab, exactly as the upstream resource's module-level\n * backend is. statewire keys its in-tab \"active\" bookkeeping by backend\n * identity, so a mount's retention sweep only skips the records of other\n * mounts on the *same* backend; and the absorbed-write overlay has to outlive\n * a remount of the same thread (a thread switch and back) or the remount would\n * read the stale persisted copy. Degradations fan out to every mounted\n * session's reporter.\n */\nconst sharedBackends = new WeakMap<StorageLike, SharedBackend>();\n\nfunction sharedBackend({\n storage,\n locks,\n}: {\n storage: StorageLike;\n locks: LockManagerLike;\n}): SharedBackend {\n let shared = sharedBackends.get(storage);\n if (shared === undefined) {\n const listeners = new Set<DegradationListener>();\n shared = {\n listeners,\n mounted: new Map(),\n backend: quotaTolerantBackend({\n inner: browserBackend({ storage, locks }),\n onDegraded: (degradation) => {\n for (const listener of listeners) listener(degradation);\n },\n }),\n };\n sharedBackends.set(storage, shared);\n }\n return shared;\n}\n\n/**\n * Athena's browser session store: `@assistant-ui/react-statewire`'s\n * `LocalStorageSession` contract (per-thread key under the shared prefix,\n * cross-tab Web Lock, storage-event subscription, retention) on top of\n * {@link quotaTolerantBackend}, with Athena's protocol lane and retention\n * policy.\n */\nconst useQuotaSafeLocalStorageSession = ({\n threadId,\n key = (id) => id,\n ttl = 7 * DAY_MS,\n max = 50,\n onStorageDegraded,\n}: QuotaSafeLocalStorageSession.Options): StatewireClient.SessionStorage => {\n const storage = browserGlobals.localStorage;\n const locks = browserGlobals.navigator?.locks;\n if (!storage)\n throw new Error(\n \"statewire: QuotaSafeLocalStorageSession requires localStorage\"\n );\n if (!locks)\n throw new Error(\n \"statewire: QuotaSafeLocalStorageSession requires the Web Locks API (navigator.locks)\"\n );\n const sessionKey = key(threadId);\n const storageKey = SESSION_PREFIX + sessionKey;\n const lockName = SESSION_LOCK_PREFIX + sessionKey;\n\n // One mounted store serves one lane scope (one principal, one backend) for\n // its whole life: the upstream `LocalStorageSession` contract, whose\n // principal guard this is. The statewire session over the store keeps the\n // client id, lane clocks and journal it loaded, so a store moved to another\n // principal's lane would carry them there and send the previous principal's\n // undelivered commands under the next one's credential. A thread switch keeps\n // the scope and re-targets the store; a change of scope refuses, and the host\n // remounts the account's thread (`useDeepAgentRuntime` does). The previous\n // principal's record is left as it is.\n const mountedScope = useRef<DeepAgentSessionLaneScope>({\n threadId,\n laneKey: sessionKey,\n });\n if (!isSameSessionLaneScope({ scope: mountedScope.current, key })) {\n throw new Error(\n \"statewire: principal changed; remount the account's thread/session\"\n );\n }\n\n const latestOnDegraded = useRef(onStorageDegraded);\n latestOnDegraded.current = onStorageDegraded;\n const reportDegradation = useMemo(() => {\n const reported = new Set<string>();\n return (degradation: SessionStorageDegradation) => {\n const handler = latestOnDegraded.current;\n if (handler) {\n try {\n handler(degradation);\n } catch {\n // Reporting runs inside the session's recovery path and must never\n // become the failure it is reporting.\n }\n return;\n }\n const dedupeKey = `${degradation.operation}:${degradation.key}`;\n if (reported.has(dedupeKey)) return;\n reported.add(dedupeKey);\n console.warn(\n `[statewire] session storage degraded to memory only (${degradation.operation} ${degradation.key})`,\n degradation.error\n );\n };\n }, []);\n\n const shared = sharedBackend({ storage, locks });\n // Registered during render as well as in the effect: the read statewire\n // makes while mounting below happens before any effect runs, and tap may\n // clean an effect up and re-run it within one commit.\n shared.listeners.add(reportDegradation);\n useEffect(() => {\n shared.listeners.add(reportDegradation);\n return () => {\n shared.listeners.delete(reportDegradation);\n };\n }, [shared, reportDegradation]);\n\n useEffect(() => {\n const { mounted } = shared;\n mounted.set(storageKey, (mounted.get(storageKey) ?? 0) + 1);\n retireExpiredSessionRecords({\n backend: shared.backend,\n mounted,\n maxAgeMs: ttl,\n }).catch((error: unknown) =>\n reportDegradation({ operation: \"withUnused\", key: storageKey, error })\n );\n return () => {\n const count = (mounted.get(storageKey) ?? 1) - 1;\n if (count === 0) mounted.delete(storageKey);\n else mounted.set(storageKey, count);\n };\n }, [shared, storageKey, ttl, reportDegradation]);\n\n // Hold the record's shared \"active\" lock while mounted so another tab's\n // retention sweep skips it (the same fence the upstream resource holds).\n useEffect(() => {\n let release: (() => void) | undefined;\n let disposed = false;\n Promise.resolve(\n locks.request(\n SESSION_ACTIVE_PREFIX + storageKey,\n { mode: \"shared\" },\n () => {\n if (disposed) return;\n return new Promise<void>((resolve) => {\n release = resolve;\n });\n }\n )\n ).catch((error: unknown) =>\n reportDegradation({ operation: \"lock\", key: storageKey, error })\n );\n return () => {\n disposed = true;\n release?.();\n };\n }, [locks, storageKey, reportDegradation]);\n\n // The storage resource includes migrate in its identity. A fresh callback\n // on every render replaces the store and prevents hydration from settling.\n const migrate = useCallback<\n NonNullable<StatewireClient.SessionStorage[\"migrate\"]>\n >(\n (record, current) => {\n const migrated = parkIncompatibleSessionCommands(record, current);\n if (migrated.parked === 0) return migrated.record;\n reportDegradation({\n operation: \"migrate\",\n key: storageKey,\n error: new Error(\n `${migrated.parked} queued statewire command(s) predate the current protocol range; parked as failed sends`\n ),\n });\n return migrated.record;\n },\n [reportDegradation, storageKey]\n );\n\n const sessionStorage = useResource(\n KeyValueSessionStorage({\n backend: shared.backend,\n key: sessionKey,\n namespace: SESSION_PREFIX,\n protocol: DEEP_AGENT_STATEWIRE_PROTOCOL,\n migrate,\n retention: { maxAgeMs: ttl, maxEntries: max },\n // A failure statewire raises itself (a structurally invalid stored\n // record) still stops the session; it is at least reported the same way.\n onError: (error) =>\n reportDegradation({ operation: \"session\", key: storageKey, error }),\n })\n );\n\n return useMemo(\n () => ({\n ...sessionStorage,\n lock: async <T>(fn: () => T | Promise<T>): Promise<T> => {\n let granted = false;\n try {\n return await locks.request(lockName, async () => {\n granted = true;\n return fn();\n });\n } catch (error) {\n if (granted) throw error;\n // The lock manager refused the request itself (a detached or\n // back/forward-cached document, a lockdown-mode origin): the\n // transaction runs unfenced rather than stopping the session.\n reportDegradation({ operation: \"lock\", key: storageKey, error });\n return fn();\n }\n },\n subscribe: (listener: () => void) => {\n const onStorage = (event: StorageEventLike) => {\n if (event.key === storageKey) listener();\n };\n browserGlobals.addEventListener?.(\"storage\", onStorage);\n return () => browserGlobals.removeEventListener?.(\"storage\", onStorage);\n },\n }),\n [sessionStorage, locks, storageKey, lockName, reportDegradation]\n );\n};\n\n/** Athena's browser session keys and retention policy. */\nexport const QuotaSafeLocalStorageSession = resource(\n useQuotaSafeLocalStorageSession\n);\n\nexport namespace QuotaSafeLocalStorageSession {\n export type Options = {\n threadId: string;\n /**\n * The lane's storage key for a thread, scoped by the principal (and the\n * sync host) the lane belongs to. It must keep naming the same principal's\n * lanes for the life of the mounted store: a change throws (\"principal\n * changed\"), as the upstream `LocalStorageSession` does, and the host\n * remounts the account's thread.\n */\n key?: (threadId: string) => string;\n ttl?: number;\n max?: number;\n /**\n * Called when a storage operation failed and the session carried on in\n * memory. Defaults to one `console.warn` per operation and key.\n */\n onStorageDegraded?: (degradation: SessionStorageDegradation) => void;\n };\n}\n"],"names":["storage","failed","useRef","isSameSessionLaneScope","useMemo","useEffect","useCallback","useResource","KeyValueSessionStorage","DEEP_AGENT_STATEWIRE_PROTOCOL","_a","resource"],"mappings":";;;;;;;AAUA,MAAM,iBAAiB;AACvB,MAAM,sBAAsB;AAC5B,MAAM,wBAAwB;AAC9B,MAAM,SAAS,KAAK,KAAK,KAAK;AAE9B,MAAM,4BAAkD,oBAAI,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC;AA0CzE,MAAM,iBAAiB;AAQhB,SAAS,8BACd,YACoC;AACpC,QAAMA,WAAU,eAAe;AAC/B,MAAI,CAACA,SAAS,QAAO;AACrB,MAAI;AACJ,MAAI;AACF,UAAM,MAAMA,SAAQ,QAAQ,iBAAiB,UAAU;AACvD,aACE,QAAQ,OAAO,OAAQ,KAAK,MAAM,GAAG;AAAA,EACzC,QAAQ;AACN,WAAO;AAAA,EACT;AACA,SAAO,+BAA+B,MAAM;AAC9C;AAYO,SAAS,+BACd,QACoC;;AACpC,MAAI,CAAC,UAAU,OAAO,WAAW,SAAU,QAAO;AAClD,QAAM,6BAAa,IAAA;AACnB,QAAM,QACJ,OAAO,SAAS,OAAO,OAAO,UAAU,WAAW,OAAO,QAAQ,CAAA;AACpE,QAAM,SAAS;AAAA,IACb,GAAI,MAAM,QAAQ,OAAO,MAAM,IAAI,OAAO,SAAS,CAAA;AAAA,IACnD,GAAG,OAAO,OAAO,KAAK,EAAE;AAAA,MAAQ,CAAC,SAC/B,MAAM,QAAQ,6BAAM,MAAM,IA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aAAO,SAAS;AAAA,IAClB;AAAA,IACA,CAAC,mBAAmB,UAAU;AAAA,EAAA;AAGhC,QAAM,iBAAiBC,IAAAA;AAAAA,IACrBC,+BAAuB;AAAA,MACrB,SAAS,OAAO;AAAA,MAChB,KAAK;AAAA,MACL,WAAW;AAAA,MACX,UAAUC,mBAAAA;AAAAA,MACV;AAAA,MACA,WAAW,EAAE,UAAU,KAAK,YAAY,IAAA;AAAA;AAAA;AAAA,MAGxC,SAAS,CAAC,UACR,kBAAkB,EAAE,WAAW,WAAW,KAAK,YAAY,MAAA,CAAO;AAAA,IAAA,CACrE;AAAA,EAAA;AAGH,SAAOL,WAAAA;AAAAA,IACL,OAAO;AAAA,MACL,GAAG;AAAA,MACH,MAAM,OAAU,OAAyC;AACvD,YAAI,UAAU;AACd,YAAI;AACF,iBAAO,MAAM,MAAM,QAAQ,UAAU,YAAY;AAC/C,sBAAU;AACV,mBAAO,GAAA;AAAA,UACT,CAAC;AAAA,QACH,SAAS,OAAO;AACd,cAAI,QAAS,OAAM;AAInB,4BAAkB,EAAE,WAAW,QAAQ,KAAK,YAAY,OAAO;AAC/D,iBAAO,GAAA;AAAA,QACT;AAAA,MACF;AAAA,MACA,WAAW,CAAC,aAAyB;;AACnC,cAAM,YAAY,CAAC,UAA4B;AAC7C,cAAI,MAAM,QAAQ,WAAY,UAAA;AAAA,QAChC;AACA,SAAAM,MAAA,eAAe,qBAAf,gBAAAA,IAAA,qBAAkC,WAAW;AAC7C,eAAO;;AAAM,kBAAAA,MAAA,eAAe,wBAAf,gBAAAA,IAAA,qBAAqC,WAAW;AAAA;AAAA,MAC/D;AAAA,IAAA;AAAA,IAEF,CAAC,gBAAgB,OAAO,YAAY,UAAU,iBAAiB;AAAA,EAAA;AAEnE;AAGO,MAAM,+BAA+BC,IAAAA;AAAAA,EAC1C;AACF;;;;;;;;;"}
1
+ {"version":3,"file":"quota-safe-local-storage-session.cjs","sources":["../../../../agent-runtime/src/quota-safe-local-storage-session.ts"],"sourcesContent":["import { resource, useResource } from \"@assistant-ui/tap\";\nimport type { StatewireClient, StatewireProtocol } from \"statewire\";\nimport { KeyValueSessionStorage, sessionNamespace } from \"statewire/storage\";\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport {\n type DeepAgentSessionLaneScope,\n isSameSessionLaneScope,\n} from \"./session-lane-scope\";\nimport { LEGACY_RUN_SEND_BEHAVIORS, upgradeLegacyRunCommand } from \"./run-send\";\nimport {\n DEEP_AGENT_LEGACY_STATEWIRE_PROTOCOL_VERSION,\n DEEP_AGENT_STATEWIRE_PROTOCOL,\n} from \"./statewire-transport\";\n\nconst SESSION_PREFIX = \"aui:statewire-session:\";\nconst SESSION_LOCK_PREFIX = \"aui:statewire-session-lock:\";\nconst SESSION_ACTIVE_PREFIX = \"aui:statewire-session-active:\";\n/** Held by a mounted tab for its life; another tab's `whenGone` waits on it. */\nconst TAB_LOCK_PREFIX = \"statewire-tab:\";\n/** Serializes durable `settled` delivery across the tabs sharing a record. */\nconst NOTIFY_LOCK_PREFIX = \"statewire-notify:\";\nconst DAY_MS = 24 * 60 * 60 * 1000;\n/**\n * A record's byte budget (UTF-16 code units, as localStorage counts them). Past it, statewire drops\n * the payloads of the record's stored `settled` updates, failures first, oldest first, so a lane\n * that keeps failing sends no longer grows to megabytes (#52031).\n */\nexport const LOCAL_SESSION_RECORD_BYTES = 512 * 1024;\n/** The stored-record formats the statewire this build ships reads (it writes 6). */\nconst READABLE_STORAGE_VERSIONS: ReadonlySet<unknown> = new Set([1, 2, 3, 4, 5, 6]);\n\n/** Structural view of the browser storage global — this package compiles\n * without the DOM lib (React Native honesty; see `globals.d.ts`). */\ntype StorageLike = {\n getItem(key: string): string | null;\n setItem(key: string, value: string): void;\n removeItem(key: string): void;\n key(index: number): string | null;\n readonly length: number;\n};\n\ntype LockGrant = object | null;\n\n/** The Web Locks API surface the session uses (`navigator.locks`). */\ntype LockManagerLike = {\n request<T>(\n name: string,\n callback: (lock: LockGrant) => T | Promise<T>\n ): Promise<T>;\n request<T>(\n name: string,\n options: {\n mode?: \"shared\" | \"exclusive\";\n ifAvailable?: boolean;\n signal?: AbortSignal;\n },\n callback: (lock: LockGrant) => T | Promise<T>\n ): Promise<T>;\n};\n\ntype StorageEventLike = { key: string | null };\n\ntype BrowserGlobals = {\n localStorage?: StorageLike;\n navigator?: { locks?: LockManagerLike };\n addEventListener?: (\n type: \"storage\",\n listener: (event: StorageEventLike) => void\n ) => void;\n removeEventListener?: (\n type: \"storage\",\n listener: (event: StorageEventLike) => void\n ) => void;\n};\n\nconst browserGlobals = globalThis as BrowserGlobals;\n\n/**\n * The session principal of a signed-in account: its stable subject (the user id), never a\n * per-login session id, so a sign-in that expires and comes back finds its lanes again.\n */\nexport function sessionPrincipal(subject: string): string {\n return `user:${subject}`;\n}\n\n/**\n * A thread's lane key under the localStorage prefix: `<namespace><principal>:<threadId>`,\n * the layout statewire's `KeyValueSessionStorage` stores it under.\n */\nexport function localStorageSessionKey({\n namespace,\n principal,\n threadId,\n}: {\n namespace: string;\n principal: string;\n threadId: string;\n}): string {\n return sessionNamespace(namespace, principal) + threadId;\n}\n\n/**\n * Moves the lanes statewire 0.24 kept for one account under unscoped keys\n * (`aui:statewire-session:<unscopedPrefix><threadId>`) to that account's scoped keys\n * (`aui:statewire-session:<namespace><principal>:<threadId>`, see {@link localStorageSessionKey}).\n * With `threadId`, that thread's lane only.\n *\n * Only call it for the signed-in account, with the prefix its 0.24 keys used (they named the user\n * id): nothing is moved into anyone else's scope, and other accounts' unscoped lanes stay where\n * they are until that account signs in here. A lane whose scoped key already holds a record is\n * left unscoped (a 0.24 tab still open can write there); it is never written over the newer\n * record, and retention retires it once it holds no sends. Returns how many lanes moved.\n */\nexport function adoptUnscopedLocalStorageSessions({\n namespace,\n principal,\n unscopedPrefix,\n threadId,\n storage = browserGlobals.localStorage,\n}: {\n namespace: string;\n principal: string;\n unscopedPrefix: string;\n threadId?: string;\n storage?: StorageLike;\n}): number {\n if (!storage) return 0;\n const from = SESSION_PREFIX + unscopedPrefix;\n let moved = 0;\n try {\n const keys =\n threadId === undefined\n ? Array.from({ length: storage.length }, (_, index) => storage.key(index)).filter(\n (key): key is string => key?.startsWith(from) === true\n )\n : [from + threadId];\n for (const key of keys) {\n const raw = storage.getItem(key);\n if (raw === null) continue;\n const target =\n SESSION_PREFIX +\n localStorageSessionKey({ namespace, principal, threadId: key.slice(from.length) });\n if (target === key || storage.getItem(target) !== null) continue;\n storage.setItem(target, raw);\n storage.removeItem(key);\n moved += 1;\n }\n } catch {\n // Storage that cannot be read or written keeps its lanes where they are.\n }\n return moved;\n}\n\n/**\n * A persisted session record as stored by any statewire build: format 5 keeps\n * failed sends as `settled` updates in each lane's `inbox`; formats 3 and 4\n * kept them in a per-lane `failed` list, and pre-lane records at the root.\n */\ntype SessionRecordLike = {\n failed?: unknown;\n lanes?: Readonly<\n Record<string, { failed?: unknown; inbox?: unknown } | null | undefined>\n > | null;\n};\n\nexport function readPersistedFailedSendStamps(\n sessionKey: string\n): ReadonlyMap<string, number> | null {\n const storage = browserGlobals.localStorage;\n if (!storage) return null;\n let record: SessionRecordLike | null;\n try {\n const raw = storage.getItem(SESSION_PREFIX + sessionKey);\n record =\n raw === null ? null : (JSON.parse(raw) as SessionRecordLike | null);\n } catch {\n return null;\n }\n return readFailedSendStampsFromRecord(record);\n}\n\n/**\n * Send stamps (message id → epoch ms of the original send) off an already\n * loaded session record's failed sends (format 5 `inbox` entries that carry a\n * failure, and the `failed` lists of older formats) — the storage-agnostic half of\n * {@link readPersistedFailedSendStamps}, for hosts whose session store is not\n * localStorage (the React Native AsyncStorage-backed store reads its record\n * synchronously through `SessionStorage.load()`).\n *\n * Returns `null` for no record (every failed entry then counts as fresh) and\n * an empty map for a record without failures.\n */\nexport function readFailedSendStampsFromRecord(\n record: SessionRecordLike | null | undefined\n): ReadonlyMap<string, number> | null {\n if (!record || typeof record !== \"object\") return null;\n const stamps = new Map<string, number>();\n const lanes =\n record.lanes && typeof record.lanes === \"object\" ? record.lanes : {};\n const failed = [\n ...(Array.isArray(record.failed) ? record.failed : []),\n ...Object.values(lanes).flatMap((lane) => [\n ...(Array.isArray(lane?.failed) ? lane.failed : []),\n ...(Array.isArray(lane?.inbox)\n ? lane.inbox.filter(\n (entry: unknown) =>\n (entry as { failure?: unknown } | null)?.failure !== undefined\n )\n : []),\n ]),\n ];\n for (const entry of failed) {\n const failed = entry as {\n ts?: unknown;\n params?: readonly { message?: { id?: unknown } }[];\n } | null;\n const messageId = failed?.params?.[0]?.message?.id;\n if (typeof messageId === \"string\" && typeof failed?.ts === \"number\") {\n stamps.set(messageId, failed.ts);\n }\n }\n return stamps;\n}\n\n/** A storage operation the session survived by degrading instead of failing. */\nexport type SessionStorageDegradation = {\n operation:\n | \"getItem\"\n | \"setItem\"\n | \"removeItem\"\n | \"getAllKeys\"\n | \"withUnused\"\n /** The lock manager refused the transaction fence; it ran unfenced. */\n | \"lock\"\n /**\n * The stored record is one this build cannot read (not JSON, or a newer\n * storage version): served as absent, and the key is shielded from being\n * overwritten so the record survives this tab.\n */\n | \"record\"\n /** statewire's own storage failure (a structurally invalid stored record). */\n | \"session\"\n /**\n * Queued commands persisted by an earlier statewire build no longer fit\n * the current wire/protocol range: parked as failed `settled` updates in\n * the lane's inbox (send recovery re-queues them) instead of blocking the\n * mount.\n */\n | \"migrate\";\n key: string;\n error: unknown;\n};\n\ntype ProducedRange = NonNullable<StatewireClient.SessionCommand[\"produced\"]>;\n\nconst inRange = (value: string, range: StatewireProtocol.Range) =>\n value >= (range.minVersion ?? range.version) && value <= range.version;\n\ntype StoredCommand = StatewireClient.OutboxCommand;\n\n/** Mirrors statewire's own stored-command compatibility check. */\nconst storedCommandCompatible = (\n protocol: string,\n command: StoredCommand,\n current: ProducedRange\n): boolean => {\n if (\n !command.produced ||\n !inRange(command.produced.wire.version, current.wire)\n )\n return false;\n if (current.protocols === \"*\") return true;\n if (command.produced.protocols === \"*\") return false;\n const produced = command.produced.protocols.find((p) => p.name === protocol);\n const offer = current.protocols.find((p) => p.name === protocol);\n return (\n produced !== undefined &&\n offer !== undefined &&\n inRange(produced.version, offer)\n );\n};\n\n/**\n * The oldest wire whose stored statements the current client still replays.\n * Bundled clients before #45143 offered 2026-09-13 through 2026-09-30 and\n * stamped every queued statement with 2026-09-13. The durable statement grammar\n * (protocol, method, params, meta, seq) is the same on 2026-09-30 and\n * 2026-11-01; only frame-level context and the attach results cursor differ.\n * So those statements ride the current wire unchanged, while the network offer\n * stays 2026-11-01 only.\n */\nexport const STORED_STATEMENT_WIRE_FLOOR = \"2026-09-13\";\n\n/** A stored command the current wire replays as-is: re-stamp, don't park. */\nconst replayableOnCurrentWire = (\n protocol: string,\n command: StoredCommand,\n current: ProducedRange\n): boolean =>\n command.produced !== undefined &&\n inRange(command.produced.wire.version, {\n version: current.wire.version,\n minVersion: STORED_STATEMENT_WIRE_FLOOR,\n }) &&\n storedCommandCompatible(\n protocol,\n { ...command, produced: { ...command.produced, wire: current.wire } },\n current\n );\n\n/**\n * A stored athena statement produced under the 2026-09-13 contract, as the\n * current contract says it: `run/enqueue`, `run/steer`, `run/steer-live` and\n * `run/prioritize` become `run/send` with the behavior each meant\n * (`upgradeLegacyRunCommand`), every other statement is unchanged, and the\n * athena offer it was produced under becomes the current one. `undefined` when\n * the command is not such a statement; `null` when it has no current\n * equivalent (a withdrawn ⚡), so it is parked.\n */\nfunction upgradeLegacyAthenaStatement(\n protocol: string,\n command: StoredCommand,\n current: ProducedRange\n): StoredCommand | null | undefined {\n if (protocol !== DEEP_AGENT_STATEWIRE_PROTOCOL || current.protocols === \"*\") return undefined;\n const produced = command.produced;\n if (produced === undefined || produced.protocols === \"*\") return undefined;\n const athena = produced.protocols.find((p) => p.name === protocol);\n const offer = current.protocols.find((p) => p.name === protocol);\n if (\n athena?.version !== DEEP_AGENT_LEGACY_STATEWIRE_PROTOCOL_VERSION ||\n offer === undefined ||\n inRange(athena.version, offer)\n )\n return undefined;\n const upgraded = upgradeLegacyRunCommand(command);\n if (upgraded === null && command.method in LEGACY_RUN_SEND_BEHAVIORS) return null;\n return {\n ...command,\n ...(upgraded ?? {}),\n produced: {\n ...produced,\n protocols: produced.protocols.map((p) => (p.name === protocol ? offer : p)),\n },\n };\n}\n\n/**\n * statewire's `migrate` for a record whose queued commands were produced by\n * an earlier build. A statement stored under the 2026-09-13 athena contract\n * is first said the current way ({@link upgradeLegacyAthenaStatement}). A command whose statement the current wire still replays\n * ({@link STORED_STATEMENT_WIRE_FLOOR}: an approval's `run/input` saved by a\n * previous bundled client, say) stays where it is, re-stamped with the current\n * range, so a stamped one is delivered with its original seq. Every other\n * incompatible command — stamped or still in the outbox — leaves its lane's\n * queue and becomes a `lost`/`session-lost` `settled` update in the lane's\n * inbox, under its own id, stamped `now`. Client identity, lane clocks,\n * compatible commands and undelivered updates are untouched, so the mount\n * proceeds and send recovery (or the user, through the held send) re-queues\n * the parked sends under the negotiated format instead of the runtime throwing\n * before it dials.\n *\n * Returns the record itself when nothing needed migrating, and the count of\n * parked commands otherwise.\n */\nexport function parkIncompatibleSessionCommands(\n record: StatewireClient.SessionRecord,\n current: ProducedRange,\n now: number = Date.now()\n): { record: StatewireClient.SessionRecord; parked: number; restamped: number } {\n let parked = 0;\n let restamped = 0;\n const lanes: Record<string, StatewireClient.SessionLane> = {};\n const park = (\n command: StoredCommand & { seq?: number }\n ): StatewireClient.StoredSettled => ({\n id: command.id,\n method: command.method,\n params: command.params,\n ...(command.meta !== undefined && { meta: command.meta }),\n ts: now,\n ...(command.seq !== undefined && { seq: command.seq }),\n ...(command.localMeta !== undefined && { localMeta: command.localMeta }),\n failure: { fate: \"lost\", cause: \"session-lost\" },\n });\n for (const [protocol, lane] of Object.entries(record.lanes)) {\n const inbox: StatewireClient.StoredSettled[] = [];\n let laneRestamped = 0;\n const sort = <T extends StoredCommand>(stored: readonly T[]): T[] =>\n stored.flatMap((original) => {\n const upgraded = upgradeLegacyAthenaStatement(protocol, original, current);\n if (upgraded === null) {\n inbox.push(park(original));\n return [];\n }\n const command = (upgraded ?? original) as T;\n if (upgraded !== undefined && storedCommandCompatible(protocol, command, current)) {\n laneRestamped += 1;\n return [command];\n }\n if (storedCommandCompatible(protocol, command, current))\n return [command];\n if (replayableOnCurrentWire(protocol, command, current)) {\n laneRestamped += 1;\n return [{ ...command, produced: current }];\n }\n inbox.push(park(command));\n return [];\n });\n const commands = sort(lane.commands);\n const outbox = lane.outbox === undefined ? undefined : sort(lane.outbox);\n parked += inbox.length;\n restamped += laneRestamped;\n const { outbox: _outbox, ...rest } = lane;\n lanes[protocol] =\n inbox.length === 0 && laneRestamped === 0\n ? lane\n : {\n ...rest,\n commands,\n ...(outbox !== undefined && outbox.length > 0 && { outbox }),\n ...((inbox.length > 0 || lane.inbox !== undefined) && {\n inbox: [...(lane.inbox ?? []), ...inbox],\n }),\n };\n }\n return parked === 0 && restamped === 0\n ? { record, parked, restamped }\n : { record: { ...record, lanes }, parked, restamped };\n}\n\n/**\n * Whether `error` is the browser refusing a write for lack of room, under\n * every name the engines use — `QuotaExceededError` (Chromium, WebKit, current\n * Firefox), `NS_ERROR_DOM_QUOTA_REACHED` (older Firefox), the legacy\n * `DOMException` codes 22 (WebKit) and 1014 (Firefox) — or a plain error whose\n * message carries one of those (storage proxies and WebViews rewrap the\n * exception). Olympus's `isStorageQuotaError` recognises the same set; the two\n * stay in step.\n */\nexport function isStorageQuotaError(error: unknown): boolean {\n if (typeof error !== \"object\" || error === null) return false;\n const { name, code, message } = error as {\n name?: unknown;\n code?: unknown;\n message?: unknown;\n };\n return (\n name === \"QuotaExceededError\" ||\n name === \"NS_ERROR_DOM_QUOTA_REACHED\" ||\n code === 22 ||\n code === 1014 ||\n (typeof message === \"string\" &&\n /exceeded the quota|quotaexceedederror|ns_error_dom_quota_reached/i.test(\n message\n ))\n );\n}\n\n/**\n * Why `raw` is a stored record this build cannot read, or `undefined` when it\n * may be one. Mirrors the two decode failures statewire raises for a record it\n * cannot read — invalid JSON, and a `statewireStorageVersion` newer than the\n * ones this build's statewire decodes (a tab left open across a\n * statewire upgrade, reading the record a newer tab keeps) — because statewire\n * throws those out of the resource at mount instead of treating the record as\n * absent. The same goes for a format-6 record that names another principal\n * than the one its key is scoped by (a record copied under another account's\n * key): statewire refuses it at mount. A structurally invalid record of the\n * right version still fails inside statewire.\n */\nfunction unreadableRecord(key: string, raw: string): Error | undefined {\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch {\n // Not JSON: statewire reads it as absent, reports `onEvict` `corrupt`, and the next save\n // replaces it (its sweeps remove it once unmounted). No build can read it, so nothing to shield.\n return undefined;\n }\n if (typeof parsed !== \"object\" || parsed === null) {\n return new Error(\"stored session record is not an object\");\n }\n const version = (parsed as { statewireStorageVersion?: unknown })\n .statewireStorageVersion;\n if (version !== undefined && !READABLE_STORAGE_VERSIONS.has(version)) {\n return new Error(\n `stored session record uses storage version ${String(version)}`\n );\n }\n // Every namespace ends in `:`, so a scoped key holds `:<principal>:`.\n const owner = (parsed as { principal?: unknown }).principal;\n if (\n version === 6 &&\n typeof owner === \"string\" &&\n !key.includes(`:${encodeURIComponent(owner)}:`)\n ) {\n return new Error(\"stored session record belongs to another principal\");\n }\n return undefined;\n}\n\ntype SyncBackend = {\n getItem: (key: string) => string | null;\n setItem: (key: string, value: string) => void;\n removeItem: (key: string) => void;\n getAllKeys: () => readonly string[];\n withUnused: (key: string, action: () => Promise<void>) => Promise<void>;\n subscribe?: (listener: (key: string) => void) => () => void;\n};\n\n/**\n * The browser backend `@assistant-ui/react-statewire`'s `LocalStorageSession`\n * uses, reproduced here because that resource does not take a backend: raw\n * `localStorage`, with retention cleanup fenced by the same Web Locks so a\n * sweep never removes a record another tab is actively sharing.\n */\nfunction browserBackend({\n storage,\n locks,\n}: {\n storage: StorageLike;\n locks: LockManagerLike;\n}): SyncBackend {\n return {\n getItem: (key) => storage.getItem(key),\n setItem: (key, value) => storage.setItem(key, value),\n removeItem: (key) => storage.removeItem(key),\n getAllKeys: () =>\n Array.from({ length: storage.length }, (_, index) =>\n storage.key(index)\n ).filter((key): key is string => key !== null),\n withUnused: async (key, action) => {\n await locks.request(\n SESSION_ACTIVE_PREFIX + key,\n { ifAvailable: true },\n async (active) => {\n if (active === null) return;\n await locks.request(\n SESSION_LOCK_PREFIX + key.slice(SESSION_PREFIX.length),\n { ifAvailable: true },\n async (lock) => {\n if (lock === null) return;\n await action();\n }\n );\n }\n );\n },\n subscribe: (listener) => {\n const onStorage = (event: StorageEventLike) => {\n if (event.key !== null) listener(event.key);\n };\n browserGlobals.addEventListener?.(\"storage\", onStorage);\n return () => browserGlobals.removeEventListener?.(\"storage\", onStorage);\n },\n };\n}\n\n/**\n * Wraps a synchronous key-value backend so a failing origin degrades the\n * session to memory-only persistence instead of stopping the connection.\n *\n * statewire's session storage latches the first unrecognised write failure\n * and from then on rejects every send (`stopped/storage-error`, \"session\n * storage failed\" on the connection chip), and refuses a send outright\n * (`aborted`/`quota`) when the write that would add it raises a\n * `QuotaExceededError`. Here every write failure is absorbed instead, so chat\n * keeps working: a quota failure first asks `onQuota` to make room (once per\n * key until a write lands again) and then writes the absorbed record through;\n * every other failure, and a quota failure the reclaim could not fix, is\n * reported through `onDegraded`.\n *\n * An absorbed write is kept in an in-memory overlay that `getItem` serves\n * first: statewire re-reads the record through `load()` on every shared-mode\n * transaction, so a stale persisted copy would otherwise win back its old\n * `nextSeq`, `clientId` and command journal. The overlay is per tab — another\n * tab sharing the thread still reads the last persisted copy, which is the\n * memory-only degradation this backend exists to allow. A later successful\n * write clears the overlay entry.\n *\n * A key whose read threw, or whose stored value this build cannot read (see\n * {@link unreadableRecord}), is served as absent and shielded: writes to it\n * stay in the overlay for good, so a fresh lane minted over an unreadable\n * record never overwrites what another tab or a newer build persisted.\n */\nexport function quotaTolerantBackend({\n inner,\n onDegraded,\n onQuota,\n}: {\n inner: SyncBackend;\n onDegraded: (degradation: SessionStorageDegradation) => void;\n /** Frees room after a quota failure on `key`; the absorbed write is retried once it settles. */\n onQuota?: (key: string) => Promise<void>;\n}): SyncBackend & KeyValueSessionStorage.Backend {\n // Keys whose quota failure already asked for a reclaim: until a write\n // succeeds again, later failures on the key are reported instead, or every\n // save would re-run the reclaim (which evicts other threads' idle records).\n const reclaimed = new Set<string>();\n // Absorbed writes, served ahead of the backend (see the function docs).\n const overlay = new Map<string, string>();\n // Keys served as absent and never written through (see the function docs).\n const shielded = new Set<string>();\n // statewire re-reads and re-decodes the record on every transaction; the\n // readability check is memoised on the raw string so it costs one string\n // comparison per read, not a second parse.\n const checked = new Map<\n string,\n { raw: string; verdict: Error | undefined }\n >();\n const readable = (key: string, raw: string): Error | undefined => {\n const previous = checked.get(key);\n if (previous !== undefined && previous.raw === raw) return previous.verdict;\n const verdict = unreadableRecord(key, raw);\n checked.set(key, { raw, verdict });\n return verdict;\n };\n const writeThrough = (key: string): void => {\n const value = overlay.get(key);\n if (value === undefined || shielded.has(key)) return;\n try {\n inner.setItem(key, value);\n } catch (error) {\n onDegraded({ operation: \"setItem\", key, error });\n return;\n }\n // A newer absorbed write may have landed while the reclaim ran.\n if (overlay.get(key) === value) overlay.delete(key);\n reclaimed.delete(key);\n };\n return {\n getItem: (key) => {\n const shadowed = overlay.get(key);\n if (shadowed !== undefined) return shadowed;\n if (shielded.has(key)) return null;\n let raw: string | null;\n try {\n raw = inner.getItem(key);\n } catch (error) {\n shielded.add(key);\n onDegraded({ operation: \"getItem\", key, error });\n return null;\n }\n if (raw === null) return null;\n const unreadable = readable(key, raw);\n if (unreadable === undefined) return raw;\n shielded.add(key);\n onDegraded({ operation: \"record\", key, error: unreadable });\n return null;\n },\n setItem: (key, value) => {\n if (shielded.has(key)) {\n overlay.set(key, value);\n return;\n }\n try {\n inner.setItem(key, value);\n overlay.delete(key);\n reclaimed.delete(key);\n } catch (error) {\n overlay.set(key, value);\n if (isStorageQuotaError(error) && onQuota && !reclaimed.has(key)) {\n reclaimed.add(key);\n onQuota(key).then(\n () => writeThrough(key),\n (reclaimError: unknown) =>\n onDegraded({ operation: \"withUnused\", key, error: reclaimError })\n );\n return;\n }\n onDegraded({ operation: \"setItem\", key, error });\n }\n },\n removeItem: (key) => {\n overlay.delete(key);\n if (shielded.has(key)) return;\n try {\n inner.removeItem(key);\n } catch (error) {\n onDegraded({ operation: \"removeItem\", key, error });\n }\n },\n getAllKeys: () => {\n const keys = new Set<string>(overlay.keys());\n try {\n for (const key of inner.getAllKeys()) keys.add(key);\n } catch (error) {\n onDegraded({ operation: \"getAllKeys\", key: \"\", error });\n }\n return [...keys];\n },\n withUnused: async (key, action) => {\n try {\n await inner.withUnused(key, action);\n } catch (error) {\n onDegraded({ operation: \"withUnused\", key, error });\n }\n },\n ...(inner.subscribe !== undefined && { subscribe: inner.subscribe }),\n };\n}\n\nconst asList = (value: unknown): readonly unknown[] =>\n Array.isArray(value) ? value : [];\n\n/**\n * What retention needs from a stored record: its save stamp, and whether it\n * holds anything a user could lose — a stamped command, an outbox entry, an\n * undelivered `settled` update, a sharer's removal note, a parked verdict, or\n * an older format's failed send. `undefined` when the record is not one this\n * build can read.\n */\nfunction retentionView(\n raw: string | null\n): { savedAt: number | undefined; holdsSends: boolean } | undefined {\n if (raw === null) return undefined;\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch {\n return undefined;\n }\n if (typeof parsed !== \"object\" || parsed === null) return undefined;\n const record = parsed as {\n savedAt?: unknown;\n updatedAt?: unknown;\n commands?: unknown;\n failed?: unknown;\n lanes?: unknown;\n };\n const stamp = record.savedAt ?? record.updatedAt;\n const lanes =\n typeof record.lanes === \"object\" && record.lanes !== null\n ? Object.values(record.lanes as Record<string, unknown>)\n : [];\n const holdsSends =\n asList(record.commands).length > 0 ||\n asList(record.failed).length > 0 ||\n lanes.some((lane) => {\n if (typeof lane !== \"object\" || lane === null) return false;\n const fields = lane as Record<string, unknown>;\n return [\n \"commands\",\n \"outbox\",\n \"inbox\",\n \"removed\",\n \"verdicts\",\n \"failed\",\n ].some((field) => asList(fields[field]).length > 0);\n });\n return {\n savedAt:\n typeof stamp === \"number\" && Number.isFinite(stamp) ? stamp : undefined,\n holdsSends,\n };\n}\n\n/**\n * Whether the localStorage session record under `sessionKey` still holds something a user could\n * lose (see {@link retentionView}): a host moving a thread to another session storage keeps it on\n * this one until it drains. `false` without localStorage or a readable record.\n */\nexport function persistedSessionHoldsSends(sessionKey: string): boolean {\n const storage = browserGlobals.localStorage;\n if (!storage) return false;\n let raw: string | null;\n try {\n raw = storage.getItem(SESSION_PREFIX + sessionKey);\n } catch {\n return false;\n }\n return retentionView(raw)?.holdsSends ?? false;\n}\n\n/**\n * Removes the session records that hold no sends (see {@link retentionView})\n * and were last saved more than `maxAgeMs` ago, skipping the keys mounted in\n * this tab and, through `withUnused`, those another tab holds. With `quota`\n * (the origin refused a write), the older half of the remaining empty records\n * goes too.\n *\n * A record that still holds a send — queued, held, stamped, or a failure\n * awaiting delivery — is never removed, whatever its age: it is a message the\n * user has not seen land, and statewire hands it back on the thread's next\n * mount.\n */\nexport async function retireExpiredSessionRecords({\n backend,\n mounted,\n maxAgeMs,\n quota = false,\n now = Date.now(),\n}: {\n backend: Pick<\n SyncBackend,\n \"getItem\" | \"removeItem\" | \"getAllKeys\" | \"withUnused\"\n >;\n mounted: ReadonlyMap<string, number>;\n maxAgeMs: number;\n quota?: boolean;\n now?: number;\n}): Promise<void> {\n const empty: { key: string; savedAt: number }[] = [];\n for (const key of backend.getAllKeys()) {\n if (!key.startsWith(SESSION_PREFIX) || mounted.has(key)) continue;\n const view = retentionView(backend.getItem(key));\n if (view?.savedAt === undefined || view.holdsSends) continue;\n empty.push({ key, savedAt: view.savedAt });\n }\n empty.sort((a, b) => b.savedAt - a.savedAt);\n const quotaStart = Math.floor(empty.length / 2);\n for (const [index, { key, savedAt }] of empty.entries()) {\n const expired = now - savedAt > maxAgeMs;\n if (!expired && !(quota && index >= quotaStart)) continue;\n await backend.withUnused(key, async () => {\n if (mounted.has(key)) return;\n const again = retentionView(backend.getItem(key));\n if (again?.savedAt !== savedAt || again.holdsSends) return;\n backend.removeItem(key);\n });\n }\n}\n\ntype DegradationListener = (degradation: SessionStorageDegradation) => void;\n\ntype SharedBackend = {\n backend: SyncBackend & KeyValueSessionStorage.Backend;\n listeners: Set<DegradationListener>;\n /** Storage keys of the sessions mounted in this tab, with mount counts. */\n mounted: Map<string, number>;\n /** The age past which an empty record goes; the longest a mounted session asked for. */\n maxAgeMs: Map<string, number>;\n};\n\n/**\n * One backend per storage object — per origin, in a browser — shared by every\n * session mounted in the tab, exactly as the upstream resource's module-level\n * backend is. statewire keys its in-tab \"active\" bookkeeping by backend\n * identity, so a mount's retention sweep only skips the records of other\n * mounts on the *same* backend; and the absorbed-write overlay has to outlive\n * a remount of the same thread (a thread switch and back) or the remount would\n * read the stale persisted copy. Degradations fan out to every mounted\n * session's reporter.\n */\nconst sharedBackends = new WeakMap<StorageLike, SharedBackend>();\n\nfunction sharedBackend({\n storage,\n locks,\n}: {\n storage: StorageLike;\n locks: LockManagerLike;\n}): SharedBackend {\n let shared = sharedBackends.get(storage);\n if (shared === undefined) {\n const listeners = new Set<DegradationListener>();\n const mounted = new Map<string, number>();\n const maxAgeMs = new Map<string, number>();\n const inner = browserBackend({ storage, locks });\n shared = {\n listeners,\n mounted,\n maxAgeMs,\n backend: quotaTolerantBackend({\n inner,\n onDegraded: (degradation) => {\n for (const listener of listeners) listener(degradation);\n },\n onQuota: () =>\n retireExpiredSessionRecords({\n backend: inner,\n mounted,\n maxAgeMs: Math.max(7 * DAY_MS, ...maxAgeMs.values()),\n quota: true,\n }),\n }),\n };\n sharedBackends.set(storage, shared);\n }\n return shared;\n}\n\n/** Runs `fn` under a Web Lock, or unfenced when the lock manager refuses the request itself. */\nasync function underLock<T>({\n locks,\n name,\n fn,\n onRefused,\n}: {\n locks: LockManagerLike;\n name: string;\n fn: () => T | Promise<T>;\n onRefused: (error: unknown) => void;\n}): Promise<T> {\n let granted = false;\n try {\n return await locks.request(name, async () => {\n granted = true;\n return fn();\n });\n } catch (error) {\n if (granted) throw error;\n // The lock manager refused the request itself (a detached or\n // back/forward-cached document, a lockdown-mode origin): the transaction\n // runs unfenced rather than stopping the session.\n onRefused(error);\n return fn();\n }\n}\n\nfunction newTabId(): string {\n const host = globalThis as { crypto?: { randomUUID?: () => string } };\n return (\n host.crypto?.randomUUID?.() ??\n `tab-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`\n );\n}\n\n/**\n * Athena's browser session store: `@assistant-ui/react-statewire`'s\n * `LocalStorageSession` contract (per-thread key under the shared prefix,\n * cross-tab Web Lock, tab ownership and settled-delivery lock, storage-event\n * subscription) over upstream `KeyValueSessionStorage` and\n * {@link quotaTolerantBackend}, with Athena's protocol lane and retention\n * policy: statewire retires every record no tab has mounted past `ttl`, sends\n * and all (reported through `onEvict` `dropped`), and empty ones past `max`;\n * {@link retireExpiredSessionRecords} also retires every account's empty\n * records past `ttl`. A record past `recordBytes` sheds the payloads of its\n * stored `settled` updates.\n */\nconst useQuotaSafeLocalStorageSession = ({\n threadId,\n namespace,\n principal,\n unscopedPrefix,\n ttl = 7 * DAY_MS,\n max = 50,\n recordBytes = LOCAL_SESSION_RECORD_BYTES,\n onStorageDegraded,\n onEvict,\n}: QuotaSafeLocalStorageSession.Options): StatewireClient.SessionStorage => {\n const storage = browserGlobals.localStorage;\n const locks = browserGlobals.navigator?.locks;\n if (!storage)\n throw new Error(\n \"statewire: QuotaSafeLocalStorageSession requires localStorage\"\n );\n if (!locks)\n throw new Error(\n \"statewire: QuotaSafeLocalStorageSession requires the Web Locks API (navigator.locks)\"\n );\n const sessionKey = localStorageSessionKey({ namespace, principal, threadId });\n const storageKey = SESSION_PREFIX + sessionKey;\n const lockName = SESSION_LOCK_PREFIX + sessionKey;\n\n // One mounted store serves one lane scope (one principal, one backend) for\n // its whole life: statewire refuses a principal change, and a backend change\n // is refused here the same way. The statewire session over the store keeps\n // the client id, lane clocks and journal it loaded, so a store moved to\n // another principal's lane would carry them there and send the previous\n // principal's undelivered commands under the next one's credential. A thread\n // switch keeps the scope and re-targets the store; a change of scope refuses,\n // and the host remounts the account's thread (`useDeepAgentRuntime` does).\n // The previous principal's record is left as it is.\n const mountedScope = useRef<DeepAgentSessionLaneScope>({\n threadId,\n laneKey: sessionKey,\n });\n if (\n !isSameSessionLaneScope({\n scope: mountedScope.current,\n key: (id) => localStorageSessionKey({ namespace, principal, threadId: id }),\n })\n ) {\n throw new Error(\n \"statewire: principal changed; remount the account's thread/session\"\n );\n }\n\n // The lane 0.24 kept for this account under its unscoped key moves to the\n // scoped one before statewire reads it.\n useMemo(() => {\n if (unscopedPrefix === undefined) return;\n adoptUnscopedLocalStorageSessions({\n namespace,\n principal,\n unscopedPrefix,\n threadId,\n storage,\n });\n }, [namespace, principal, unscopedPrefix, threadId, storage]);\n\n const latestOnDegraded = useRef(onStorageDegraded);\n latestOnDegraded.current = onStorageDegraded;\n const reportDegradation = useMemo(() => {\n const reported = new Set<string>();\n return (degradation: SessionStorageDegradation) => {\n const handler = latestOnDegraded.current;\n if (handler) {\n try {\n handler(degradation);\n } catch {\n // Reporting runs inside the session's recovery path and must never\n // become the failure it is reporting.\n }\n return;\n }\n const dedupeKey = `${degradation.operation}:${degradation.key}`;\n if (reported.has(dedupeKey)) return;\n reported.add(dedupeKey);\n console.warn(\n `[statewire] session storage degraded to memory only (${degradation.operation} ${degradation.key})`,\n degradation.error\n );\n };\n }, []);\n\n const latestOnEvict = useRef(onEvict);\n latestOnEvict.current = onEvict;\n const reportEvict = useCallback(\n (event: KeyValueSessionStorage.EvictEvent) => {\n try {\n latestOnEvict.current?.(event);\n } catch {\n // A reporting handler never fails the session's own bookkeeping.\n }\n },\n []\n );\n\n const shared = sharedBackend({ storage, locks });\n // Registered during render as well as in the effect: the read statewire\n // makes while mounting below happens before any effect runs, and tap may\n // clean an effect up and re-run it within one commit.\n shared.listeners.add(reportDegradation);\n useEffect(() => {\n shared.listeners.add(reportDegradation);\n return () => {\n shared.listeners.delete(reportDegradation);\n };\n }, [shared, reportDegradation]);\n\n useEffect(() => {\n const { mounted, maxAgeMs } = shared;\n mounted.set(storageKey, (mounted.get(storageKey) ?? 0) + 1);\n maxAgeMs.set(storageKey, ttl);\n retireExpiredSessionRecords({\n backend: shared.backend,\n mounted,\n maxAgeMs: ttl,\n }).catch((error: unknown) =>\n reportDegradation({ operation: \"withUnused\", key: storageKey, error })\n );\n return () => {\n const count = (mounted.get(storageKey) ?? 1) - 1;\n if (count === 0) {\n mounted.delete(storageKey);\n maxAgeMs.delete(storageKey);\n } else mounted.set(storageKey, count);\n };\n }, [shared, storageKey, ttl, reportDegradation]);\n\n // This tab's identity for the stamps it sends. The lock is held for the\n // tab's life, so another tab's `whenGone` resolves only once this one is\n // gone and it may take the stamps over.\n const [tabId] = useState(newTabId);\n useEffect(() => {\n let release: (() => void) | undefined;\n const held = new Promise<void>((resolve) => {\n release = resolve;\n });\n Promise.resolve(locks.request(TAB_LOCK_PREFIX + tabId, () => held)).catch(\n (error: unknown) =>\n reportDegradation({ operation: \"lock\", key: storageKey, error })\n );\n return () => release?.();\n }, [locks, tabId, storageKey, reportDegradation]);\n\n // Hold the record's shared \"active\" lock while mounted so another tab's\n // retention sweep skips it (the same fence the upstream resource holds).\n useEffect(() => {\n let release: (() => void) | undefined;\n let disposed = false;\n Promise.resolve(\n locks.request(\n SESSION_ACTIVE_PREFIX + storageKey,\n { mode: \"shared\" },\n () => {\n if (disposed) return;\n return new Promise<void>((resolve) => {\n release = resolve;\n });\n }\n )\n ).catch((error: unknown) =>\n reportDegradation({ operation: \"lock\", key: storageKey, error })\n );\n return () => {\n disposed = true;\n release?.();\n };\n }, [locks, storageKey, reportDegradation]);\n\n // The storage resource includes migrate in its identity. A fresh callback\n // on every render replaces the store and prevents hydration from settling.\n const migrate = useCallback<\n NonNullable<StatewireClient.SessionStorage[\"migrate\"]>\n >(\n (record, current) => {\n const migrated = parkIncompatibleSessionCommands(record, current);\n if (migrated.parked === 0) return migrated.record;\n reportDegradation({\n operation: \"migrate\",\n key: storageKey,\n error: new Error(\n `${migrated.parked} queued statewire command(s) predate the current protocol range; parked as failed sends`\n ),\n });\n return migrated.record;\n },\n [reportDegradation, storageKey]\n );\n\n const sessionStorage = useResource(\n KeyValueSessionStorage({\n backend: shared.backend,\n key: threadId,\n namespace: SESSION_PREFIX + namespace,\n principal,\n protocol: DEEP_AGENT_STATEWIRE_PROTOCOL,\n migrate,\n // statewire 0.27.1 retires a record past maxAgeMs even while it holds\n // sends: kept failures with their full params were what filled the\n // origin (#52031).\n retention: { maxAgeMs: ttl, maxEntries: max },\n limits: { recordBytes },\n // A failure statewire raises itself (a structurally invalid stored\n // record) still stops the session; it is at least reported the same way.\n onError: (error) =>\n reportDegradation({ operation: \"session\", key: storageKey, error }),\n onEvict: reportEvict,\n })\n );\n\n return useMemo(\n (): StatewireClient.SessionStorage => ({\n ...sessionStorage,\n lock: <T>(fn: () => T | Promise<T>): Promise<T> =>\n underLock({\n locks,\n name: lockName,\n fn,\n onRefused: (error) =>\n reportDegradation({ operation: \"lock\", key: storageKey, error }),\n }),\n notifyLock: <T>(fn: () => Promise<T>): Promise<T> =>\n underLock({\n locks,\n name: NOTIFY_LOCK_PREFIX + storageKey,\n fn,\n onRefused: (error) =>\n reportDegradation({ operation: \"lock\", key: storageKey, error }),\n }),\n owner: {\n id: tabId,\n whenGone: (id, signal) =>\n Promise.resolve(\n locks.request(TAB_LOCK_PREFIX + id, { signal }, () => undefined)\n ),\n },\n subscribe: (listener: () => void) => {\n const onStorage = (event: StorageEventLike) => {\n if (event.key === storageKey) listener();\n };\n browserGlobals.addEventListener?.(\"storage\", onStorage);\n return () => browserGlobals.removeEventListener?.(\"storage\", onStorage);\n },\n }),\n [sessionStorage, locks, storageKey, lockName, tabId, reportDegradation]\n );\n};\n\n/** Athena's browser session keys and retention policy. */\nexport const QuotaSafeLocalStorageSession = resource(\n useQuotaSafeLocalStorageSession\n);\n\nexport namespace QuotaSafeLocalStorageSession {\n export type Options = {\n threadId: string;\n /**\n * The backend the lanes belong to, as a key prefix (the sync host and `:`):\n * a thread id is only meaningful against the backend that minted it.\n */\n namespace: string;\n /**\n * The signed-in account the lanes belong to ({@link sessionPrincipal}).\n * Lanes are stored under `aui:statewire-session:<namespace><principal>:<threadId>`.\n * It must stay the same for the life of the mounted store: a change throws\n * (\"principal changed\"), and the host remounts the account's thread.\n */\n principal: string;\n /**\n * Where statewire 0.24 kept this account's lanes, after the\n * `aui:statewire-session:` prefix and before the thread id (its sync host\n * and user id). The thread's lane there moves to the scoped key on mount\n * ({@link adoptUnscopedLocalStorageSessions}).\n */\n unscopedPrefix?: string;\n /**\n * Age past which a record no tab has mounted is removed, unsent and failed\n * sends included. Default 7 days.\n */\n ttl?: number;\n /** Records holding no sends kept across the origin. Default 50. */\n max?: number;\n /**\n * A record's byte budget ({@link LOCAL_SESSION_RECORD_BYTES}): past it the\n * payloads of stored `settled` updates go, and a write that adds a send\n * still past it is refused (`aborted` / `quota`).\n */\n recordBytes?: number;\n /**\n * Called when a storage operation failed and the session carried on in\n * memory. Defaults to one `console.warn` per operation and key.\n */\n onStorageDegraded?: (degradation: SessionStorageDegradation) => void;\n /**\n * Called when statewire drops undelivered `settled` updates: past a\n * lane's inbox cap, or with a record its retention removed.\n */\n onEvict?: (event: KeyValueSessionStorage.EvictEvent) => void;\n };\n}\n"],"names":["sessionNamespace","storage","failed","DEEP_AGENT_STATEWIRE_PROTOCOL","DEEP_AGENT_LEGACY_STATEWIRE_PROTOCOL_VERSION","upgradeLegacyRunCommand","LEGACY_RUN_SEND_BEHAVIORS","_a","useRef","isSameSessionLaneScope","useMemo","useCallback","useEffect","useState","useResource","KeyValueSessionStorage","resource"],"mappings":";;;;;;;;AAcA,MAAM,iBAAiB;AACvB,MAAM,sBAAsB;AAC5B,MAAM,wBAAwB;AAE9B,MAAM,kBAAkB;AAExB,MAAM,qBAAqB;AAC3B,MAAM,SAAS,KAAK,KAAK,KAAK;AAMvB,MAAM,6BAA6B,MAAM;AAEhD,MAAM,4BAAkD,oBAAI,IAAI,CAAC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,QACN;AAAA,QACA,WAAW,CAAC,UACV,kBAAkB,EAAE,WAAW,QAAQ,KAAK,YAAY,MAAA,CAAO;AAAA,MAAA,CAClE;AAAA,MACH,YAAY,CAAI,OACd,UAAU;AAAA,QACR;AAAA,QACA,MAAM,qBAAqB;AAAA,QAC3B;AAAA,QACA,WAAW,CAAC,UACV,kBAAkB,EAAE,WAAW,QAAQ,KAAK,YAAY,MAAA,CAAO;AAAA,MAAA,CAClE;AAAA,MACH,OAAO;AAAA,QACL,IAAI;AAAA,QACJ,UAAU,CAAC,IAAI,WACb,QAAQ;AAAA,UACN,MAAM,QAAQ,kBAAkB,IAAI,EAAE,OAAA,GAAU,MAAM,MAAS;AAAA,QAAA;AAAA,MACjE;AAAA,MAEJ,WAAW,CAAC,aAAyB;;AACnC,cAAM,YAAY,CAAC,UAA4B;AAC7C,cAAI,MAAM,QAAQ,WAAY,UAAA;AAAA,QAChC;AACA,SAAAH,MAAA,eAAe,qBAAf,gBAAAA,IAAA,qBAAkC,WAAW;AAC7C,eAAO;;AAAM,kBAAAA,MAAA,eAAe,wBAAf,gBAAAA,IAAA,qBAAqC,WAAW;AAAA;AAAA,MAC/D;AAAA,IAAA;AAAA,IAEF,CAAC,gBAAgB,OAAO,YAAY,UAAU,OAAO,iBAAiB;AAAA,EAAA;AAE1E;AAGO,MAAM,+BAA+BS,IAAAA;AAAAA,EAC1C;AACF;;;;;;;;;;;;;;"}
@@ -1,16 +1,70 @@
1
1
  import type { StatewireClient } from "statewire";
2
2
  import { KeyValueSessionStorage } from "statewire/storage";
3
- /** A persisted session record: per-lane failed entries (a pre-lane record carried them at the root). */
3
+ /**
4
+ * A record's byte budget (UTF-16 code units, as localStorage counts them). Past it, statewire drops
5
+ * the payloads of the record's stored `settled` updates, failures first, oldest first, so a lane
6
+ * that keeps failing sends no longer grows to megabytes (#52031).
7
+ */
8
+ export declare const LOCAL_SESSION_RECORD_BYTES: number;
9
+ /** Structural view of the browser storage global — this package compiles
10
+ * without the DOM lib (React Native honesty; see `globals.d.ts`). */
11
+ type StorageLike = {
12
+ getItem(key: string): string | null;
13
+ setItem(key: string, value: string): void;
14
+ removeItem(key: string): void;
15
+ key(index: number): string | null;
16
+ readonly length: number;
17
+ };
18
+ /**
19
+ * The session principal of a signed-in account: its stable subject (the user id), never a
20
+ * per-login session id, so a sign-in that expires and comes back finds its lanes again.
21
+ */
22
+ export declare function sessionPrincipal(subject: string): string;
23
+ /**
24
+ * A thread's lane key under the localStorage prefix: `<namespace><principal>:<threadId>`,
25
+ * the layout statewire's `KeyValueSessionStorage` stores it under.
26
+ */
27
+ export declare function localStorageSessionKey({ namespace, principal, threadId, }: {
28
+ namespace: string;
29
+ principal: string;
30
+ threadId: string;
31
+ }): string;
32
+ /**
33
+ * Moves the lanes statewire 0.24 kept for one account under unscoped keys
34
+ * (`aui:statewire-session:<unscopedPrefix><threadId>`) to that account's scoped keys
35
+ * (`aui:statewire-session:<namespace><principal>:<threadId>`, see {@link localStorageSessionKey}).
36
+ * With `threadId`, that thread's lane only.
37
+ *
38
+ * Only call it for the signed-in account, with the prefix its 0.24 keys used (they named the user
39
+ * id): nothing is moved into anyone else's scope, and other accounts' unscoped lanes stay where
40
+ * they are until that account signs in here. A lane whose scoped key already holds a record is
41
+ * left unscoped (a 0.24 tab still open can write there); it is never written over the newer
42
+ * record, and retention retires it once it holds no sends. Returns how many lanes moved.
43
+ */
44
+ export declare function adoptUnscopedLocalStorageSessions({ namespace, principal, unscopedPrefix, threadId, storage, }: {
45
+ namespace: string;
46
+ principal: string;
47
+ unscopedPrefix: string;
48
+ threadId?: string;
49
+ storage?: StorageLike;
50
+ }): number;
51
+ /**
52
+ * A persisted session record as stored by any statewire build: format 5 keeps
53
+ * failed sends as `settled` updates in each lane's `inbox`; formats 3 and 4
54
+ * kept them in a per-lane `failed` list, and pre-lane records at the root.
55
+ */
4
56
  type SessionRecordLike = {
5
57
  failed?: unknown;
6
- lanes?: Record<string, {
58
+ lanes?: Readonly<Record<string, {
7
59
  failed?: unknown;
8
- } | null | undefined> | null;
60
+ inbox?: unknown;
61
+ } | null | undefined>> | null;
9
62
  };
10
63
  export declare function readPersistedFailedSendStamps(sessionKey: string): ReadonlyMap<string, number> | null;
11
64
  /**
12
65
  * Send stamps (message id → epoch ms of the original send) off an already
13
- * loaded session record's failed lane — the storage-agnostic half of
66
+ * loaded session record's failed sends (format 5 `inbox` entries that carry a
67
+ * failure, and the `failed` lists of older formats) — the storage-agnostic half of
14
68
  * {@link readPersistedFailedSendStamps}, for hosts whose session store is not
15
69
  * localStorage (the React Native AsyncStorage-backed store reads its record
16
70
  * synchronously through `SessionStorage.load()`).
@@ -34,8 +88,9 @@ export type SessionStorageDegradation = {
34
88
  | "session"
35
89
  /**
36
90
  * Queued commands persisted by an earlier statewire build no longer fit
37
- * the current wire/protocol range: parked in the lane's failed list (the
38
- * send-recovery sweep re-dispatches them) instead of blocking the mount.
91
+ * the current wire/protocol range: parked as failed `settled` updates in
92
+ * the lane's inbox (send recovery re-queues them) instead of blocking the
93
+ * mount.
39
94
  */
40
95
  | "migrate";
41
96
  key: string;
@@ -46,23 +101,26 @@ type ProducedRange = NonNullable<StatewireClient.SessionCommand["produced"]>;
46
101
  * The oldest wire whose stored statements the current client still replays.
47
102
  * Bundled clients before #45143 offered 2026-09-13 through 2026-09-30 and
48
103
  * stamped every queued statement with 2026-09-13. The durable statement grammar
49
- * (protocol, method, params, meta, seq) is the same on 2026-09-30; only
50
- * frame-level context differs. So those statements ride the current wire
51
- * unchanged, while the network offer stays native 2026-09-30 only.
104
+ * (protocol, method, params, meta, seq) is the same on 2026-09-30 and
105
+ * 2026-11-01; only frame-level context and the attach results cursor differ.
106
+ * So those statements ride the current wire unchanged, while the network offer
107
+ * stays 2026-11-01 only.
52
108
  */
53
109
  export declare const STORED_STATEMENT_WIRE_FLOOR = "2026-09-13";
54
110
  /**
55
111
  * statewire's `migrate` for a record whose queued commands were produced by
56
- * an earlier build. A command whose statement the current wire still replays
112
+ * an earlier build. A statement stored under the 2026-09-13 athena contract
113
+ * is first said the current way ({@link upgradeLegacyAthenaStatement}). A command whose statement the current wire still replays
57
114
  * ({@link STORED_STATEMENT_WIRE_FLOOR}: an approval's `run/input` saved by a
58
- * previous bundled client, say) stays queued, re-stamped with the current
59
- * range, so it is delivered with its original seq. Every other incompatible
60
- * command leaves its lane's queue and is
61
- * retained as a `lost`/`session-lost` failed send re-stamped with the current
62
- * range. Client identity, lane clocks, compatible commands and existing failed
63
- * history are untouched, so the mount proceeds and the send-recovery sweep
64
- * (or the user, via the failed-send UI) re-dispatches the parked sends under
65
- * the negotiated format instead of the runtime throwing before it dials.
115
+ * previous bundled client, say) stays where it is, re-stamped with the current
116
+ * range, so a stamped one is delivered with its original seq. Every other
117
+ * incompatible command — stamped or still in the outbox — leaves its lane's
118
+ * queue and becomes a `lost`/`session-lost` `settled` update in the lane's
119
+ * inbox, under its own id, stamped `now`. Client identity, lane clocks,
120
+ * compatible commands and undelivered updates are untouched, so the mount
121
+ * proceeds and send recovery (or the user, through the held send) re-queues
122
+ * the parked sends under the negotiated format instead of the runtime throwing
123
+ * before it dials.
66
124
  *
67
125
  * Returns the record itself when nothing needed migrating, and the count of
68
126
  * parked commands otherwise.
@@ -88,6 +146,7 @@ type SyncBackend = {
88
146
  removeItem: (key: string) => void;
89
147
  getAllKeys: () => readonly string[];
90
148
  withUnused: (key: string, action: () => Promise<void>) => Promise<void>;
149
+ subscribe?: (listener: (key: string) => void) => () => void;
91
150
  };
92
151
  /**
93
152
  * Wraps a synchronous key-value backend so a failing origin degrades the
@@ -95,12 +154,13 @@ type SyncBackend = {
95
154
  *
96
155
  * statewire's session storage latches the first unrecognised write failure
97
156
  * and from then on rejects every send (`stopped/storage-error`, "session
98
- * storage failed" on the connection chip). It only recovers a
99
- * `QuotaExceededError` by that exact name — sweeping old session records and
100
- * retrying the write once — and latches again when the retry fails too. Here
101
- * the first quota failure per key is surfaced under that name so the sweep
102
- * runs; the retry that follows it and every other storage failure are absorbed
103
- * and reported through `onDegraded`, so chat keeps working.
157
+ * storage failed" on the connection chip), and refuses a send outright
158
+ * (`aborted`/`quota`) when the write that would add it raises a
159
+ * `QuotaExceededError`. Here every write failure is absorbed instead, so chat
160
+ * keeps working: a quota failure first asks `onQuota` to make room (once per
161
+ * key until a write lands again) and then writes the absorbed record through;
162
+ * every other failure, and a quota failure the reclaim could not fix, is
163
+ * reported through `onDegraded`.
104
164
  *
105
165
  * An absorbed write is kept in an in-memory overlay that `getItem` serves
106
166
  * first: statewire re-reads the record through `load()` on every shared-mode
@@ -115,25 +175,35 @@ type SyncBackend = {
115
175
  * stay in the overlay for good, so a fresh lane minted over an unreadable
116
176
  * record never overwrites what another tab or a newer build persisted.
117
177
  */
118
- export declare function quotaTolerantBackend({ inner, onDegraded, }: {
178
+ export declare function quotaTolerantBackend({ inner, onDegraded, onQuota, }: {
119
179
  inner: SyncBackend;
120
180
  onDegraded: (degradation: SessionStorageDegradation) => void;
181
+ /** Frees room after a quota failure on `key`; the absorbed write is retried once it settles. */
182
+ onQuota?: (key: string) => Promise<void>;
121
183
  }): SyncBackend & KeyValueSessionStorage.Backend;
122
184
  /**
123
- * Removes session records last saved more than `maxAgeMs` ago, skipping the
124
- * keys mounted in this tab and, through `withUnused`, those another tab holds.
185
+ * Whether the localStorage session record under `sessionKey` still holds something a user could
186
+ * lose (see {@link retentionView}): a host moving a thread to another session storage keeps it on
187
+ * this one until it drains. `false` without localStorage or a readable record.
188
+ */
189
+ export declare function persistedSessionHoldsSends(sessionKey: string): boolean;
190
+ /**
191
+ * Removes the session records that hold no sends (see {@link retentionView})
192
+ * and were last saved more than `maxAgeMs` ago, skipping the keys mounted in
193
+ * this tab and, through `withUnused`, those another tab holds. With `quota`
194
+ * (the origin refused a write), the older half of the remaining empty records
195
+ * goes too.
125
196
  *
126
- * statewire's own retention sweep only retires records with nothing queued and
127
- * nothing failed: a record still carrying an unconfirmed or failed send is
128
- * exempt from both its age and count bounds, so every thread left with one
129
- * kept its key forever. Past the TTL those sends are long out of send
130
- * recovery's auto-retry window, so the record goes the same way an empty one
131
- * does.
197
+ * A record that still holds a send — queued, held, stamped, or a failure
198
+ * awaiting delivery — is never removed, whatever its age: it is a message the
199
+ * user has not seen land, and statewire hands it back on the thread's next
200
+ * mount.
132
201
  */
133
- export declare function retireExpiredSessionRecords({ backend, mounted, maxAgeMs, now, }: {
202
+ export declare function retireExpiredSessionRecords({ backend, mounted, maxAgeMs, quota, now, }: {
134
203
  backend: Pick<SyncBackend, "getItem" | "removeItem" | "getAllKeys" | "withUnused">;
135
204
  mounted: ReadonlyMap<string, number>;
136
205
  maxAgeMs: number;
206
+ quota?: boolean;
137
207
  now?: number;
138
208
  }): Promise<void>;
139
209
  /** Athena's browser session keys and retention policy. */
@@ -142,20 +212,47 @@ export declare namespace QuotaSafeLocalStorageSession {
142
212
  type Options = {
143
213
  threadId: string;
144
214
  /**
145
- * The lane's storage key for a thread, scoped by the principal (and the
146
- * sync host) the lane belongs to. It must keep naming the same principal's
147
- * lanes for the life of the mounted store: a change throws ("principal
148
- * changed"), as the upstream `LocalStorageSession` does, and the host
149
- * remounts the account's thread.
215
+ * The backend the lanes belong to, as a key prefix (the sync host and `:`):
216
+ * a thread id is only meaningful against the backend that minted it.
217
+ */
218
+ namespace: string;
219
+ /**
220
+ * The signed-in account the lanes belong to ({@link sessionPrincipal}).
221
+ * Lanes are stored under `aui:statewire-session:<namespace><principal>:<threadId>`.
222
+ * It must stay the same for the life of the mounted store: a change throws
223
+ * ("principal changed"), and the host remounts the account's thread.
224
+ */
225
+ principal: string;
226
+ /**
227
+ * Where statewire 0.24 kept this account's lanes, after the
228
+ * `aui:statewire-session:` prefix and before the thread id (its sync host
229
+ * and user id). The thread's lane there moves to the scoped key on mount
230
+ * ({@link adoptUnscopedLocalStorageSessions}).
231
+ */
232
+ unscopedPrefix?: string;
233
+ /**
234
+ * Age past which a record no tab has mounted is removed, unsent and failed
235
+ * sends included. Default 7 days.
150
236
  */
151
- key?: (threadId: string) => string;
152
237
  ttl?: number;
238
+ /** Records holding no sends kept across the origin. Default 50. */
153
239
  max?: number;
240
+ /**
241
+ * A record's byte budget ({@link LOCAL_SESSION_RECORD_BYTES}): past it the
242
+ * payloads of stored `settled` updates go, and a write that adds a send
243
+ * still past it is refused (`aborted` / `quota`).
244
+ */
245
+ recordBytes?: number;
154
246
  /**
155
247
  * Called when a storage operation failed and the session carried on in
156
248
  * memory. Defaults to one `console.warn` per operation and key.
157
249
  */
158
250
  onStorageDegraded?: (degradation: SessionStorageDegradation) => void;
251
+ /**
252
+ * Called when statewire drops undelivered `settled` updates: past a
253
+ * lane's inbox cap, or with a record its retention removed.
254
+ */
255
+ onEvict?: (event: KeyValueSessionStorage.EvictEvent) => void;
159
256
  };
160
257
  }
161
258
  export {};