@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,9 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const addressedAgents = require("./addressed-agents.cjs");
4
+ const chatOutboxEntry = require("./chat-outbox-entry.cjs");
5
+ const chatOutboxLegacy = require("./chat-outbox-legacy.cjs");
6
+ const chatOutboxThread = require("./chat-outbox-thread.cjs");
7
+ const statewireHeldSends = require("./statewire-held-sends.cjs");
8
+ const statewireTransport = require("./statewire-transport.cjs");
3
9
  const CHAT_OUTBOX_COUNTDOWN_MS = 5e3;
4
10
  const CHAT_OUTBOX_ASK_AFTER_MS = 24 * 60 * 60 * 1e3;
5
- const CHAT_OUTBOX_CLAIM_LEASE_MS = 3e4;
6
11
  const CHAT_OUTBOX_ATTACHMENT_CHECK_TIMEOUT_MS = 15e3;
12
+ const CHAT_OUTBOX_ATTACHMENT_REFUSED_CODE = "attachment-unavailable";
13
+ const CHAT_OUTBOX_ATTACHMENT_UNKNOWN_CODE = "attachment-check-failed";
7
14
  const CHAT_EDIT_UNREACHABLE_LABEL = "Can't edit while Athena can't be reached";
8
15
  const CHAT_EDIT_KEPT_MESSAGE = "Can't reach Athena right now. Your edit stays here — submit it once Athena is back.";
9
16
  class ChatEditUnreachableError extends Error {
@@ -13,51 +20,59 @@ class ChatEditUnreachableError extends Error {
13
20
  }
14
21
  }
15
22
  function chatOutboxFailureMessage(reason) {
16
- switch (reason) {
17
- case "refused":
18
- return "This conversation can't be reached right now.";
19
- case "prepare":
20
- return "Couldn't prepare this message to send.";
21
- case "attachment":
22
- return "An attachment is no longer available to you.";
23
- default:
24
- return "Couldn't send this message.";
25
- }
26
- }
27
- const AWAY_CAUSES = /* @__PURE__ */ new Set(["unmount", "stream-gone"]);
28
- function chatOutboxCommandMessageId(params) {
29
- var _a;
30
- const first = params == null ? void 0 : params[0];
31
- const id = (_a = first == null ? void 0 : first.message) == null ? void 0 : _a.id;
32
- return typeof id === "string" ? id : null;
23
+ return reason === "attachment" ? "An attachment is no longer available to you." : "Couldn't send this message.";
33
24
  }
34
- function failureOf(error) {
35
- const failure = error == null ? void 0 : error.failure;
36
- const fate = typeof (failure == null ? void 0 : failure.fate) === "string" ? failure.fate : void 0;
37
- const cause = typeof (failure == null ? void 0 : failure.cause) === "string" ? failure.cause : void 0;
38
- const message = error instanceof Error ? error.message : String(error);
39
- return { fate, cause, message };
40
- }
41
- function defaultMessageId() {
25
+ const MIGRATION_CONFIRM_ATTEMPTS = 20;
26
+ const MIGRATION_CONFIRM_DELAY_MS = 250;
27
+ function randomId() {
42
28
  var _a;
43
29
  const host = globalThis;
44
30
  if (typeof ((_a = host.crypto) == null ? void 0 : _a.randomUUID) === "function") return host.crypto.randomUUID();
45
31
  const hex = Array.from({ length: 32 }, () => Math.floor(Math.random() * 16).toString(16)).join("");
46
32
  return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-4${hex.slice(13, 16)}-a${hex.slice(17, 20)}-${hex.slice(20, 32)}`;
47
33
  }
48
- function sameChatOutboxRowState(a, b) {
49
- if (a.kind !== b.kind) return false;
50
- switch (a.kind) {
51
- case "countdown":
52
- return a.endsAt === b.endsAt;
53
- case "failed":
54
- return a.reason === b.reason && a.message === b.message;
55
- default:
56
- return true;
34
+ function isRecord(value) {
35
+ return typeof value === "object" && value !== null && !Array.isArray(value);
36
+ }
37
+ function reanchorHeldSendParams(command, view) {
38
+ const params = command.params[0];
39
+ if (!isRecord(params)) return null;
40
+ const rest = command.params.slice(1);
41
+ if (command.method === "run/edit") {
42
+ const next = statewireHeldSends.reanchorRunSend(command, { wireMessages: view.wireMessages, runId: view.runId });
43
+ return (next == null ? void 0 : next.method) === "run/edit" ? next.params : null;
57
44
  }
45
+ if (command.method !== "run/send") return null;
46
+ if (view.runId !== null && params.runId === view.runId) return null;
47
+ const { runAnchorMessageId: _anchor, ...unanchored } = params;
48
+ if (view.runId !== null) return [{ ...unanchored, runId: view.runId }, ...rest];
49
+ const wire = view.wireMessages ?? [];
50
+ return [
51
+ { ...unanchored, runId: randomId(), runAnchorMessageId: wire.length > 0 ? chatOutboxThread.chatOutboxWireAnchorId(wire) : null },
52
+ ...rest
53
+ ];
54
+ }
55
+ function failureReason(error) {
56
+ return "code" in error && error.code === CHAT_OUTBOX_ATTACHMENT_REFUSED_CODE ? "attachment" : "error";
58
57
  }
59
- function sameChatOutboxEntry(a, b) {
60
- return a === b || a.id === b.id && a.threadId === b.threadId && a.text === b.text && a.newChat === b.newChat && a.queuedAt === b.queuedAt && a.composerMarkdown === b.composerMarkdown;
58
+ function sameEntry(a, b) {
59
+ return a.id === b.id && a.outboxId === b.outboxId && a.threadId === b.threadId && a.text === b.text && a.queuedAt === b.queuedAt && a.newChat === b.newChat && a.durable === b.durable && a.composerMarkdown === b.composerMarkdown && a.composerHtml === b.composerHtml && sameJson(a.metadata, b.metadata) && sameJson(a.files, b.files) && sameJson(a.attachments, b.attachments);
60
+ }
61
+ function sameJson(a, b) {
62
+ if (Object.is(a, b)) return true;
63
+ if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) return false;
64
+ if (Array.isArray(a) || Array.isArray(b)) {
65
+ return Array.isArray(a) && Array.isArray(b) && a.length === b.length && a.every((item, index) => sameJson(item, b[index]));
66
+ }
67
+ const ka = Object.keys(a);
68
+ const kb = Object.keys(b);
69
+ return ka.length === kb.length && ka.every((key) => Object.hasOwn(b, key) && sameJson(Reflect.get(a, key), Reflect.get(b, key)));
70
+ }
71
+ function sameState(a, b) {
72
+ if (a.kind !== b.kind) return false;
73
+ if (a.kind === "countdown") return a.endsAt === b.endsAt;
74
+ if (a.kind === "failed") return a.reason === b.reason && a.message === b.message;
75
+ return true;
61
76
  }
62
77
  function sameChatOutboxSnapshot(a, b) {
63
78
  if (a === b) return true;
@@ -66,12 +81,12 @@ function sameChatOutboxSnapshot(a, b) {
66
81
  for (let index = 0; index < a.rows.length; index += 1) {
67
82
  const x = a.rows[index];
68
83
  const y = b.rows[index];
69
- if (!x || !y || x.entry !== y.entry || !sameChatOutboxRowState(x.state, y.state)) return false;
84
+ if (!x || !y || x.entry !== y.entry || !sameState(x.state, y.state)) return false;
70
85
  }
71
86
  for (let index = 0; index < a.elsewhere.length; index += 1) {
72
87
  const x = a.elsewhere[index];
73
88
  const y = b.elsewhere[index];
74
- if (!x || !y || x.threadId !== y.threadId || x.count !== y.count || x.newChat !== y.newChat || !sameChatOutboxEntry(x.first, y.first)) {
89
+ if (!x || !y || x.threadId !== y.threadId || x.count !== y.count || x.newChat !== y.newChat || x.first !== y.first) {
75
90
  return false;
76
91
  }
77
92
  }
@@ -81,7 +96,6 @@ function createChatOutbox(options) {
81
96
  const {
82
97
  threadId,
83
98
  isNewChat,
84
- store,
85
99
  reachability,
86
100
  foreground,
87
101
  thread,
@@ -89,117 +103,128 @@ function createChatOutbox(options) {
89
103
  openThread,
90
104
  onEvent,
91
105
  checkAttachments,
92
- sendGate,
106
+ directory,
107
+ legacy,
93
108
  now = () => Date.now(),
94
109
  countdownMs = CHAT_OUTBOX_COUNTDOWN_MS,
95
110
  askAfterMs = CHAT_OUTBOX_ASK_AFTER_MS,
96
- claimLeaseMs = CHAT_OUTBOX_CLAIM_LEASE_MS,
97
111
  attachmentCheckTimeoutMs = CHAT_OUTBOX_ATTACHMENT_CHECK_TIMEOUT_MS,
98
- newMessageId = defaultMessageId,
112
+ newMessageId = randomId,
99
113
  setTimer = (task, ms) => {
100
- const timer = setTimeout(task, ms);
101
- return () => clearTimeout(timer);
114
+ const timer2 = setTimeout(task, ms);
115
+ return () => clearTimeout(timer2);
102
116
  }
103
117
  } = options;
104
- const claimant = newMessageId();
105
118
  let disposed = false;
106
- let loaded = store === null;
107
- let entries = [];
108
- let elsewhere = [];
109
- let claims = /* @__PURE__ */ new Map();
110
- const persisted = /* @__PURE__ */ new Set();
111
- const unsettled = /* @__PURE__ */ new Map();
112
- let listingsStarted = 0;
113
- const phases = /* @__PURE__ */ new Map();
114
- const sendNow = /* @__PURE__ */ new Set();
115
- const handedInRegain = /* @__PURE__ */ new Map();
116
- let regain = 0;
117
- let wasReachable = reachability.get();
118
- let countdown = null;
119
- let leaseTimer = null;
120
- const checkTimers = /* @__PURE__ */ new Set();
121
- const readyToGo = /* @__PURE__ */ new Map();
122
- let releasing = false;
119
+ let openSince = null;
120
+ let pending = [];
121
+ const landing = /* @__PURE__ */ new Map();
122
+ const dropOnLanding = /* @__PURE__ */ new Set();
123
+ const countdownRequested = /* @__PURE__ */ new Set();
124
+ const released = /* @__PURE__ */ new Set();
125
+ const legacyAwaitingDelivery = /* @__PURE__ */ new Map();
126
+ const checking = /* @__PURE__ */ new Set();
127
+ const failing = /* @__PURE__ */ new Set();
123
128
  const asked = /* @__PURE__ */ new Set();
129
+ const checkTimers = /* @__PURE__ */ new Set();
130
+ let timer = null;
131
+ let migration = legacy ? "idle" : "done";
132
+ let migrationAttempts = 0;
133
+ const entryCache = /* @__PURE__ */ new Map();
124
134
  const listeners = /* @__PURE__ */ new Set();
125
- let snapshot = {
126
- rows: [],
127
- countdownEndsAt: null,
128
- durable: true,
129
- loaded,
130
- elsewhere
131
- };
135
+ let rows = [];
136
+ let snapshot = { rows: [], countdownEndsAt: null, durable: true, loaded: false, elsewhere: [] };
132
137
  const emit = (event) => {
133
138
  try {
134
139
  onEvent == null ? void 0 : onEvent(event);
135
140
  } catch {
136
141
  }
137
142
  };
138
- const phaseOf = (id) => phases.get(id) ?? { kind: "idle" };
139
- const isBusy = (phase) => phase.kind === "claiming" || phase.kind === "handed" || phase.kind === "awaiting-thread";
140
- const claimedElsewhere = (id) => {
141
- const claim = claims.get(id);
142
- return claim !== void 0 && claim.by !== claimant && now() - claim.at < claimLeaseMs;
143
+ const gateOpen = () => reachability.get() && foreground.get() && thread.outbox() !== null;
144
+ const stable = (entry) => {
145
+ const key = entry.outboxId ?? `pending:${entry.id}`;
146
+ const cached = entryCache.get(key);
147
+ if (cached && sameEntry(cached, entry)) return cached;
148
+ entryCache.set(key, entry);
149
+ return entry;
143
150
  };
144
- const settledFor = (id, listing) => {
145
- if (!unsettled.has(id)) return true;
146
- const settledAt = unsettled.get(id);
147
- return settledAt !== void 0 && listing > settledAt;
151
+ const readRows = (outbox) => {
152
+ if (!outbox) return [];
153
+ const result = [];
154
+ for (const stored of outbox.entries) {
155
+ if (stored.state !== "held") continue;
156
+ const entry = chatOutboxEntry.chatOutboxEntryOf(stored, threadId);
157
+ if (!entry) continue;
158
+ result.push({ stored, entry: stable(entry), meta: chatOutboxEntry.readChatOutboxLocalMeta(stored.localMeta) });
159
+ }
160
+ return result;
148
161
  };
149
- const writePending = (id) => unsettled.has(id) && unsettled.get(id) === void 0;
150
- const markUnsettled = (id, write) => {
151
- unsettled.set(id, void 0);
152
- const settle = () => {
153
- if (!unsettled.has(id)) return;
154
- unsettled.set(id, listingsStarted);
155
- evaluate();
156
- };
157
- void write.then(settle, settle);
162
+ const isAsk = (row) => now() - row.entry.queuedAt > askAfterMs;
163
+ const lineOf = (current) => {
164
+ const line = [];
165
+ for (const row of current) {
166
+ if (row.meta.error || failing.has(row.stored.id) || isAsk(row)) break;
167
+ if (checking.has(row.stored.id) || released.has(row.stored.id)) continue;
168
+ line.push(row);
169
+ }
170
+ return line;
158
171
  };
159
- const rowState = (entry, line) => {
160
- const phase = phaseOf(entry.id);
161
- if (phase.kind === "failed") {
162
- return { kind: "failed", reason: phase.reason, message: chatOutboxFailureMessage(phase.reason) };
163
- }
164
- if (isBusy(phase) || claimedElsewhere(entry.id)) return { kind: "sending" };
165
- if (countdown !== null && line.run.some((candidate) => candidate.id === entry.id)) {
166
- return { kind: "countdown", endsAt: countdown.endsAt };
167
- }
168
- if (line.askId === entry.id) return { kind: "ask" };
172
+ const countdownCurrent = (meta, since) => meta.countdownEndsAt !== void 0 && meta.countdownFrom !== void 0 && meta.countdownFrom >= since;
173
+ const lineEndsAt = (line) => {
174
+ if (openSince === null || line.length === 0) return null;
175
+ let endsAt = 0;
176
+ for (const row of line) {
177
+ if (!countdownCurrent(row.meta, openSince)) return null;
178
+ endsAt = Math.max(endsAt, row.meta.countdownEndsAt ?? 0);
179
+ }
180
+ return endsAt;
181
+ };
182
+ const rowState = (row, line, endsAt, blocked) => {
183
+ if (row.meta.error) {
184
+ const reason = failureReason(row.meta.error);
185
+ return { kind: "failed", reason, message: chatOutboxFailureMessage(reason) };
186
+ }
187
+ if (checking.has(row.stored.id) || released.has(row.stored.id)) return { kind: "sending" };
188
+ if (blocked) return { kind: "waiting" };
189
+ if (isAsk(row)) return { kind: "ask" };
190
+ if (endsAt !== null && line.includes(row)) return { kind: "countdown", endsAt };
169
191
  return { kind: "waiting" };
170
192
  };
171
- const keyOf = (entry) => (sendGate == null ? void 0 : sendGate.keyOf(entry)) ?? "";
172
- const mayHandOff = (entry) => (sendGate == null ? void 0 : sendGate.mayHandOff(entry)) ?? true;
173
- const computeLine = () => {
174
- const run = [];
175
- let lineKey = null;
176
- for (const entry of entries) {
177
- const phase = phaseOf(entry.id);
178
- if (phase.kind === "failed") continue;
179
- const key = keyOf(entry);
180
- if (lineKey === null) lineKey = key;
181
- else if (key !== lineKey) break;
182
- if (isBusy(phase) || claimedElsewhere(entry.id)) continue;
183
- if (handedInRegain.get(entry.id) === regain && !sendNow.has(entry.id)) continue;
184
- if (!sendNow.has(entry.id) && now() - entry.queuedAt > askAfterMs) {
185
- return { run, askId: run.length === 0 ? entry.id : null };
186
- }
187
- run.push(entry);
193
+ const publish = (current, line, endsAt) => {
194
+ const outbox = thread.outbox();
195
+ const built = [];
196
+ let blocked = false;
197
+ for (const row of current) {
198
+ const state = rowState(row, line, endsAt, blocked);
199
+ built.push({ entry: row.entry, state });
200
+ if (state.kind === "failed" || state.kind === "ask") blocked = true;
201
+ }
202
+ for (const entry of landing.values()) built.push({ entry, state: { kind: "waiting" } });
203
+ for (const waiting of pending) built.push({ entry: waiting.entry, state: { kind: "waiting" } });
204
+ const elsewhere = [];
205
+ for (const other of (directory == null ? void 0 : directory.getSnapshot().threads) ?? []) {
206
+ const first = other.entries[0];
207
+ if (other.threadId === threadId || !first) continue;
208
+ elsewhere.push({
209
+ threadId: other.threadId,
210
+ count: other.entries.length,
211
+ first,
212
+ newChat: other.entries.every((entry) => entry.newChat)
213
+ });
188
214
  }
189
- const head = run[0];
190
- if (head !== void 0 && !mayHandOff(head)) return { run: [], askId: null };
191
- return { run, askId: null };
192
- };
193
- const gateOpen = () => reachability.get() && foreground.get();
194
- const publish = () => {
195
- const line = gateOpen() ? computeLine() : { run: [], askId: null };
196
215
  const next = {
197
- rows: entries.map((entry) => ({ entry, state: rowState(entry, line) })),
198
- countdownEndsAt: (countdown == null ? void 0 : countdown.endsAt) ?? null,
199
- durable: entries.every((entry) => persisted.has(entry.id)),
200
- loaded,
216
+ rows: built,
217
+ countdownEndsAt: endsAt,
218
+ durable: built.every((row) => row.entry.durable),
219
+ loaded: outbox !== null,
201
220
  elsewhere
202
221
  };
222
+ if (elsewhere.length === snapshot.elsewhere.length) {
223
+ next.elsewhere = elsewhere.map((item, index) => {
224
+ const previous = snapshot.elsewhere[index];
225
+ return previous && previous.threadId === item.threadId && previous.count === item.count && previous.newChat === item.newChat && sameEntry(previous.first, item.first) ? previous : item;
226
+ });
227
+ }
203
228
  if (sameChatOutboxSnapshot(snapshot, next)) return;
204
229
  snapshot = next;
205
230
  for (const listener of listeners) {
@@ -209,110 +234,55 @@ function createChatOutbox(options) {
209
234
  }
210
235
  }
211
236
  };
212
- const stopCountdown = () => {
213
- countdown == null ? void 0 : countdown.cancel();
214
- countdown = null;
215
- };
216
- const dropEntry = (id) => {
217
- entries = entries.filter((entry) => entry.id !== id);
218
- unsettled.delete(id);
219
- phases.delete(id);
220
- readyToGo.delete(id);
221
- sendNow.delete(id);
222
- persisted.delete(id);
223
- claims.delete(id);
224
- asked.delete(id);
225
- if (countdown == null ? void 0 : countdown.ids.includes(id)) stopCountdown();
226
- };
227
- const letGo = (id, event) => {
228
- if (!entries.some((entry) => entry.id === id)) return;
229
- dropEntry(id);
230
- emit(event);
231
- if (store) void store.remove(threadId, id).catch(() => void 0);
232
- };
233
- const fail = (id, reason) => {
234
- phases.set(id, { kind: "failed", reason });
235
- sendNow.delete(id);
236
- emit({ type: "failed", threadId, messageId: id, message: chatOutboxFailureMessage(reason), reason });
237
- if (store) {
238
- void store.markFailed({ threadId, id, claimant, failure: { reason, at: now() } }).catch(() => void 0);
239
- }
240
- };
241
- const releaseClaim = (id) => {
242
- if (store) void store.release({ threadId, id, claimant }).catch(() => void 0);
243
- };
244
- const handOff = (entry, auto) => {
245
- if (thread.heldIds().has(entry.id)) {
246
- letGo(entry.id, { type: "adopted", threadId, messageId: entry.id });
247
- return;
248
- }
249
- const readiness = thread.readiness();
250
- if (readiness === "refused") {
251
- fail(entry.id, "refused");
252
- return;
253
- }
254
- if (readiness === "connecting") {
255
- phases.set(entry.id, { kind: "awaiting-thread" });
256
- return;
237
+ const releaseNow = (row, auto) => {
238
+ var _a;
239
+ const outbox = thread.outbox();
240
+ if (!outbox) return;
241
+ const view = thread.view();
242
+ released.add(row.stored.id);
243
+ emit({ type: "handed", threadId, messageId: row.entry.id, auto, ageMs: now() - row.entry.queuedAt });
244
+ try {
245
+ outbox.update(row.stored.id, (current) => {
246
+ if (current.state !== "held") return {};
247
+ const params = reanchorHeldSendParams(current.command, view);
248
+ return {
249
+ held: false,
250
+ localMeta: chatOutboxEntry.withoutTransientLocalMeta(current.localMeta),
251
+ ...params !== null && { command: { params } }
252
+ };
253
+ });
254
+ } catch {
257
255
  }
258
- if (writePending(entry.id)) {
259
- phases.set(entry.id, { kind: "awaiting-thread" });
260
- return;
256
+ (_a = thread.wake) == null ? void 0 : _a.call(thread);
257
+ if (legacy && row.meta.legacyId !== void 0 && !row.entry.durable) {
258
+ legacyAwaitingDelivery.set(row.entry.id, row.meta.legacyId);
261
259
  }
262
- sendNow.delete(entry.id);
263
- phases.set(entry.id, { kind: "claiming" });
264
- const claim = store ? store.claim({ threadId, id: entry.id, claimant, now: now(), leaseMs: claimLeaseMs }) : Promise.resolve("claimed");
265
- void claim.then(
266
- (result) => {
267
- if (disposed || phaseOf(entry.id).kind !== "claiming") return;
268
- if (result === "gone") {
269
- dropEntry(entry.id);
270
- evaluate();
271
- return;
272
- }
273
- if (result === "taken") {
274
- phases.set(entry.id, { kind: "idle" });
275
- claims.set(entry.id, { by: "elsewhere", at: now() });
276
- evaluate();
277
- return;
278
- }
279
- if (!stillGoes(entry)) return;
280
- checkThenDispatch(entry, auto);
281
- },
282
- () => {
283
- if (disposed || phaseOf(entry.id).kind !== "claiming") return;
284
- fail(entry.id, "prepare");
285
- evaluate();
286
- }
287
- );
288
260
  };
289
- const stillGoes = (entry) => {
290
- if (thread.heldIds().has(entry.id)) {
291
- letGo(entry.id, { type: "adopted", threadId, messageId: entry.id });
292
- evaluate();
293
- return false;
294
- }
295
- const ready = thread.readiness();
296
- if (ready === "refused") {
297
- fail(entry.id, "refused");
298
- evaluate();
299
- return false;
300
- }
301
- if (!gateOpen() || ready !== "ready") {
302
- phases.set(entry.id, gateOpen() ? { kind: "awaiting-thread" } : { kind: "idle" });
303
- releaseClaim(entry.id);
304
- evaluate();
305
- return false;
261
+ const markFailed = (row, code) => {
262
+ const outbox = thread.outbox();
263
+ checking.delete(row.stored.id);
264
+ if (!outbox) return;
265
+ failing.add(row.stored.id);
266
+ const error = { fate: "rejected", cause: "server", code };
267
+ try {
268
+ outbox.update(row.stored.id, (current) => {
269
+ if (current.state !== "held") return {};
270
+ const base = chatOutboxEntry.withoutTransientLocalMeta(current.localMeta);
271
+ return { localMeta: { ...isRecord(base) ? base : {}, error } };
272
+ });
273
+ } catch {
306
274
  }
307
- return true;
275
+ const reason = failureReason(error);
276
+ emit({ type: "failed", threadId, messageId: row.entry.id, message: chatOutboxFailureMessage(reason), reason });
308
277
  };
309
- const checkThenDispatch = (entry, auto) => {
310
- const attachments = entry.attachments ?? [];
278
+ const release = (row, auto) => {
279
+ const attachments = row.entry.attachments ?? [];
311
280
  if (attachments.length === 0 || !checkAttachments) {
312
- readyToGo.set(entry.id, auto);
313
- releaseReady();
281
+ releaseNow(row, auto);
314
282
  return;
315
283
  }
284
+ if (checking.has(row.stored.id)) return;
285
+ checking.add(row.stored.id);
316
286
  let answered = false;
317
287
  let stopTimer = () => void 0;
318
288
  const answer = (verdict) => {
@@ -320,284 +290,255 @@ function createChatOutbox(options) {
320
290
  answered = true;
321
291
  stopTimer();
322
292
  checkTimers.delete(stopTimer);
323
- if (disposed || phaseOf(entry.id).kind !== "claiming") return;
324
- if (!stillGoes(entry)) return;
293
+ if (disposed || !checking.has(row.stored.id)) return;
325
294
  if (verdict === "ok") {
326
- readyToGo.set(entry.id, auto);
327
- releaseReady();
295
+ checking.delete(row.stored.id);
296
+ if (!auto || gateOpen()) releaseNow(row, auto);
297
+ evaluate();
328
298
  return;
329
299
  }
330
- fail(entry.id, verdict === "refused" ? "attachment" : "error");
300
+ markFailed(row, verdict === "refused" ? CHAT_OUTBOX_ATTACHMENT_REFUSED_CODE : CHAT_OUTBOX_ATTACHMENT_UNKNOWN_CODE);
331
301
  evaluate();
332
302
  };
333
303
  stopTimer = setTimer(() => answer("unknown"), attachmentCheckTimeoutMs);
334
304
  checkTimers.add(stopTimer);
335
- let checking;
305
+ let checked;
336
306
  try {
337
- checking = checkAttachments(attachments);
307
+ checked = checkAttachments(attachments);
338
308
  } catch (error) {
339
- checking = Promise.reject(error);
309
+ checked = Promise.reject(error);
340
310
  }
341
- void checking.then(answer, () => answer("unknown"));
311
+ void checked.then(answer, () => answer("unknown"));
342
312
  };
343
- function releaseReady() {
344
- if (releasing || disposed) return;
345
- releasing = true;
346
- let heldBack = false;
347
- try {
348
- for (const entry of [...entries]) {
349
- if (phaseOf(entry.id).kind !== "claiming") continue;
350
- const auto = readyToGo.get(entry.id);
351
- if (auto === void 0) return;
352
- if (!mayHandOff(entry)) {
353
- holdBackFrom(entry);
354
- heldBack = true;
355
- return;
356
- }
357
- readyToGo.delete(entry.id);
358
- if (stillGoes(entry)) dispatch(entry, auto);
359
- }
360
- } finally {
361
- releasing = false;
362
- if (heldBack) evaluateLine();
363
- }
364
- }
365
- function holdBackFrom(first) {
366
- let behind = false;
367
- for (const entry of entries) {
368
- if (entry.id === first.id) behind = true;
369
- if (!behind || phaseOf(entry.id).kind !== "claiming") continue;
370
- readyToGo.delete(entry.id);
371
- phases.set(entry.id, { kind: "idle" });
372
- releaseClaim(entry.id);
373
- }
374
- }
375
- const dispatch = (entry, auto) => {
376
- handedInRegain.set(entry.id, regain);
377
- phases.set(entry.id, { kind: "handed", journaled: false });
378
- emit({
379
- type: "handed",
313
+ const startMigration = (outbox) => {
314
+ if (!legacy || migration !== "idle") return;
315
+ migration = "running";
316
+ const isKept = legacy.isKept === void 0 ? async (messageId) => {
317
+ var _a;
318
+ return ((_a = thread.outbox()) == null ? void 0 : _a.entries.some((entry) => {
319
+ var _a2;
320
+ return entry.durable && ((_a2 = chatOutboxEntry.chatOutboxEntryOf(entry, threadId)) == null ? void 0 : _a2.id) === messageId;
321
+ })) ?? false;
322
+ } : (messageId) => legacy.isKept(threadId, messageId);
323
+ void chatOutboxLegacy.migrateLegacyChatOutbox({
380
324
  threadId,
381
- messageId: entry.id,
382
- auto,
383
- ageMs: now() - entry.queuedAt,
384
- ...entry.sendContext !== void 0 && { sendContext: entry.sendContext }
385
- });
386
- let sent;
387
- try {
388
- sent = thread.send(entry);
389
- } catch (error) {
390
- sent = Promise.reject(error);
391
- }
392
- void sent.then(
393
- () => {
394
- if (disposed) return;
395
- letGo(entry.id, { type: "delivered", threadId, messageId: entry.id, status: "accepted" });
396
- evaluate();
397
- },
398
- (error) => {
399
- if (disposed) return;
400
- const phase = phaseOf(entry.id);
401
- if (phase.kind === "handed" && phase.journaled) return;
402
- if (phase.kind !== "handed") return;
403
- const failure = failureOf(error);
404
- if (failure.cause !== void 0 && AWAY_CAUSES.has(failure.cause)) {
405
- phases.set(entry.id, { kind: "idle" });
406
- handedInRegain.delete(entry.id);
407
- releaseClaim(entry.id);
408
- evaluate();
409
- return;
325
+ reader: legacy.reader,
326
+ outbox,
327
+ isKept,
328
+ messageIdsShown: () => thread.view().messageIds
329
+ }).then(
330
+ (result) => {
331
+ var _a;
332
+ migration = "done";
333
+ if (result.inserted + result.removed + result.kept > 0) emit({ type: "migrated", threadId, ...result });
334
+ directory == null ? void 0 : directory.refresh();
335
+ const inMemory = ((_a = thread.outbox()) == null ? void 0 : _a.entries.some((entry) => !entry.durable)) ?? false;
336
+ if (result.kept > 0 && !inMemory && migrationAttempts < MIGRATION_CONFIRM_ATTEMPTS && !disposed) {
337
+ migrationAttempts += 1;
338
+ const stop = setTimer(() => {
339
+ checkTimers.delete(stop);
340
+ migration = "idle";
341
+ evaluate();
342
+ }, MIGRATION_CONFIRM_DELAY_MS);
343
+ checkTimers.add(stop);
410
344
  }
411
- fail(entry.id, "error");
412
- evaluate();
345
+ },
346
+ () => {
347
+ migration = "idle";
413
348
  }
414
349
  );
415
350
  };
416
- const startCountdown = (run) => {
417
- stopCountdown();
418
- const ids = run.map((entry) => entry.id);
419
- const endsAt = now() + countdownMs;
420
- const cancel = setTimer(() => {
421
- if (disposed || (countdown == null ? void 0 : countdown.endsAt) !== endsAt) return;
422
- countdown = null;
423
- if (!gateOpen()) {
424
- evaluate();
425
- return;
426
- }
427
- for (const id of ids) {
428
- const entry = entries.find((candidate) => candidate.id === id);
429
- if (!entry) continue;
430
- const phase = phaseOf(id);
431
- if (phase.kind !== "idle" || claimedElsewhere(id)) continue;
432
- if (!mayHandOff(entry)) break;
433
- handOff(entry, true);
434
- }
435
- evaluate();
436
- }, countdownMs);
437
- countdown = { endsAt, ids, cancel };
438
- emit({ type: "countdown-started", threadId, count: ids.length });
439
- };
440
- const scheduleLeaseCheck = () => {
441
- leaseTimer == null ? void 0 : leaseTimer();
442
- leaseTimer = null;
443
- let soonest = Number.POSITIVE_INFINITY;
444
- for (const [id, claim] of claims) {
445
- if (claim.by === claimant || !entries.some((entry) => entry.id === id)) continue;
446
- const expires = claim.at + claimLeaseMs - now();
447
- if (expires > 0) soonest = Math.min(soonest, expires);
448
- }
449
- if (Number.isFinite(soonest)) leaseTimer = setTimer(() => evaluate(), soonest + 1);
450
- };
451
351
  function evaluate() {
452
- evaluateLine();
453
- releaseReady();
454
- }
455
- function evaluateLine() {
456
352
  if (disposed) return;
457
- const reachable = reachability.get();
458
- if (reachable && !wasReachable) regain += 1;
459
- wasReachable = reachable;
460
- if (loaded) {
461
- const held = thread.heldIds();
462
- for (const entry of [...entries]) {
463
- const phase = phaseOf(entry.id);
464
- if (phase.kind === "handed") {
465
- if (held.has(entry.id)) phases.set(entry.id, { kind: "handed", journaled: true });
466
- continue;
353
+ const outbox = thread.outbox();
354
+ if (outbox && pending.length > 0) {
355
+ const waiting = pending;
356
+ pending = [];
357
+ for (let index = 0; index < waiting.length; index += 1) {
358
+ const item = waiting[index];
359
+ try {
360
+ outbox.insert(item.insert);
361
+ landing.set(item.entry.id, item.entry);
362
+ emit({ type: "held", threadId, messageId: item.entry.id, durable: true });
363
+ } catch {
364
+ pending = waiting.slice(index);
365
+ break;
467
366
  }
468
- if (phase.kind === "claiming") continue;
469
- if (held.has(entry.id)) letGo(entry.id, { type: "adopted", threadId, messageId: entry.id });
470
367
  }
471
- if (!gateOpen()) {
472
- for (const entry of entries) {
473
- if (phaseOf(entry.id).kind === "awaiting-thread") phases.set(entry.id, { kind: "idle" });
474
- }
475
- } else if (thread.readiness() !== "connecting") {
476
- let held2 = false;
477
- let handedKey = null;
478
- for (const entry of entries) {
479
- if (phaseOf(entry.id).kind !== "awaiting-thread") continue;
480
- phases.set(entry.id, { kind: "idle" });
481
- const key = keyOf(entry);
482
- held2 || (held2 = handedKey !== null && key !== handedKey || !mayHandOff(entry));
483
- if (held2) continue;
484
- handedKey = key;
485
- handOff(entry, true);
486
- }
487
- }
488
- }
489
- if (!loaded || !gateOpen()) {
490
- stopCountdown();
491
- publish();
492
- return;
493
- }
494
- const line = computeLine();
495
- if (line.askId !== null && !asked.has(line.askId)) {
496
- asked.add(line.askId);
497
- const entry = entries.find((candidate) => candidate.id === line.askId);
498
- if (entry) emit({ type: "asked", threadId, messageId: entry.id, ageMs: now() - entry.queuedAt });
499
368
  }
500
- const immediate = [];
501
- for (const entry of line.run) {
502
- if (!sendNow.has(entry.id)) break;
503
- immediate.push(entry);
504
- }
505
- for (const entry of immediate) handOff(entry, false);
506
- const run = line.run.slice(immediate.length).filter((entry) => !sendNow.has(entry.id));
507
- if (run.length === 0) {
508
- stopCountdown();
509
- } else if (countdown === null || countdown.ids.length !== run.length || run.some((entry, index) => (countdown == null ? void 0 : countdown.ids[index]) !== entry.id)) {
510
- startCountdown(run);
369
+ if (outbox) startMigration(outbox);
370
+ if (legacy && legacyAwaitingDelivery.size > 0) {
371
+ const delivered = thread.view().messageIds;
372
+ for (const [messageId, legacyId] of legacyAwaitingDelivery) {
373
+ if (!delivered.has(messageId)) continue;
374
+ legacyAwaitingDelivery.delete(messageId);
375
+ void legacy.reader.remove(threadId, legacyId).catch(() => void 0);
376
+ }
511
377
  }
512
- scheduleLeaseCheck();
513
- publish();
514
- }
515
- const applyRecords = (records, listing) => {
516
- const mine = records.filter((record) => record.entry.threadId === threadId);
517
- const stored = new Map(mine.map((record) => [record.entry.id, record]));
518
- claims = new Map(
519
- mine.flatMap((record) => record.claim ? [[record.entry.id, record.claim]] : [])
520
- );
521
- for (const record of mine) {
522
- if (!settledFor(record.entry.id, listing)) continue;
523
- if (record.memoryOnly) persisted.delete(record.entry.id);
524
- else persisted.add(record.entry.id);
525
- const phase = phaseOf(record.entry.id);
526
- if (record.failure && phase.kind !== "failed" && !isBusy(phase)) {
527
- phases.set(record.entry.id, { kind: "failed", reason: record.failure.reason });
378
+ let current = readRows(outbox);
379
+ const dropped = /* @__PURE__ */ new Set();
380
+ for (const row of current) {
381
+ landing.delete(row.entry.id);
382
+ if (!dropOnLanding.delete(row.entry.id) || !outbox) continue;
383
+ dropped.add(row.stored.id);
384
+ try {
385
+ outbox.remove(row.stored.id);
386
+ } catch {
528
387
  }
529
388
  }
530
- const kept = entries.filter(
531
- (entry) => stored.has(entry.id) || !settledFor(entry.id, listing) || isBusy(phaseOf(entry.id))
532
- );
533
- for (const entry of entries) {
534
- if (kept.includes(entry)) continue;
535
- if (countdown == null ? void 0 : countdown.ids.includes(entry.id)) stopCountdown();
536
- phases.delete(entry.id);
537
- persisted.delete(entry.id);
538
- sendNow.delete(entry.id);
389
+ current = current.filter((row) => !dropped.has(row.stored.id));
390
+ const shown = current.length > 0 ? thread.view().messageIds : /* @__PURE__ */ new Set();
391
+ for (const row of current) {
392
+ if (!shown.has(row.entry.id) || !outbox) continue;
393
+ try {
394
+ outbox.remove(row.stored.id);
395
+ } catch {
396
+ }
397
+ emit({ type: "adopted", threadId, messageId: row.entry.id });
398
+ }
399
+ current = current.filter((row) => !shown.has(row.entry.id));
400
+ const heldIds = new Set(current.map((row) => row.stored.id));
401
+ for (const id of released) if (!heldIds.has(id)) released.delete(id);
402
+ for (const id of checking) if (!heldIds.has(id)) checking.delete(id);
403
+ for (const row of current) if (row.meta.error) failing.delete(row.stored.id);
404
+ for (const id of failing) if (!heldIds.has(id)) failing.delete(id);
405
+ for (const key of entryCache.keys()) if (!key.startsWith("pending:") && !heldIds.has(key)) entryCache.delete(key);
406
+ rows = current;
407
+ const open = gateOpen();
408
+ if (open && openSince === null) openSince = now();
409
+ if (!open) openSince = null;
410
+ let line = [];
411
+ let endsAt = null;
412
+ if (open && openSince !== null) {
413
+ line = lineOf(current);
414
+ const head = current.find(
415
+ (row) => !row.meta.error && !failing.has(row.stored.id) && !checking.has(row.stored.id) && !released.has(row.stored.id)
416
+ );
417
+ if (head && isAsk(head) && !asked.has(head.stored.id)) {
418
+ asked.add(head.stored.id);
419
+ emit({ type: "asked", threadId, messageId: head.entry.id, ageMs: now() - head.entry.queuedAt });
420
+ }
421
+ const since = openSince;
422
+ const starting = line.filter((row) => !countdownCurrent(row.meta, since));
423
+ for (const row of line) if (countdownCurrent(row.meta, since)) countdownRequested.delete(row.stored.id);
424
+ const toRequest = starting.filter((row) => !countdownRequested.has(row.stored.id));
425
+ if (toRequest.length > 0 && outbox) {
426
+ const from = now();
427
+ for (const row of toRequest) {
428
+ countdownRequested.add(row.stored.id);
429
+ try {
430
+ outbox.update(row.stored.id, (stored) => {
431
+ const meta = chatOutboxEntry.readChatOutboxLocalMeta(stored.localMeta);
432
+ if (stored.state !== "held" || countdownCurrent(meta, since)) return {};
433
+ const base = isRecord(stored.localMeta) ? stored.localMeta : {};
434
+ return { localMeta: { ...base, countdownFrom: from, countdownEndsAt: from + countdownMs } };
435
+ });
436
+ } catch {
437
+ countdownRequested.delete(row.stored.id);
438
+ }
439
+ }
440
+ emit({ type: "countdown-started", threadId, count: line.length });
441
+ }
442
+ endsAt = lineEndsAt(line);
443
+ }
444
+ if (endsAt !== null && endsAt <= now()) {
445
+ timer == null ? void 0 : timer.cancel();
446
+ timer = null;
447
+ for (const row of line) release(row, true);
448
+ queueMicrotask(evaluate);
449
+ publish(current, [], null);
450
+ return;
539
451
  }
540
- const known = new Set(kept.map((entry) => entry.id));
541
- const added = mine.filter((record) => !known.has(record.entry.id)).map((record) => record.entry);
542
- entries = [...kept, ...added].sort((a, b) => a.queuedAt - b.queuedAt);
543
- for (const [id, settledAt] of unsettled) {
544
- if (settledAt !== void 0 && listing > settledAt) unsettled.delete(id);
452
+ if (endsAt === null) {
453
+ timer == null ? void 0 : timer.cancel();
454
+ timer = null;
455
+ } else if ((timer == null ? void 0 : timer.at) !== endsAt) {
456
+ timer == null ? void 0 : timer.cancel();
457
+ const at = endsAt;
458
+ timer = {
459
+ at,
460
+ cancel: setTimer(
461
+ () => {
462
+ if ((timer == null ? void 0 : timer.at) === at) timer = null;
463
+ evaluate();
464
+ },
465
+ Math.max(0, at - now())
466
+ )
467
+ };
545
468
  }
546
- const byThread = /* @__PURE__ */ new Map();
547
- for (const record of records) {
548
- if (record.entry.threadId === threadId) continue;
549
- const current = byThread.get(record.entry.threadId);
550
- if (current) {
551
- current.count += 1;
552
- current.newChat && (current.newChat = record.entry.newChat);
553
- } else {
554
- byThread.set(record.entry.threadId, {
555
- count: 1,
556
- first: record.entry,
557
- newChat: record.entry.newChat
558
- });
559
- }
469
+ publish(current, line, endsAt);
470
+ }
471
+ const findRow = (id) => rows.find((row) => row.entry.id === id);
472
+ const forgetLegacy = (row) => {
473
+ legacyAwaitingDelivery.delete(row.entry.id);
474
+ if (legacy && row.meta.legacyId !== void 0) {
475
+ void legacy.reader.remove(threadId, row.meta.legacyId).catch(() => void 0);
560
476
  }
561
- elsewhere = [...byThread].map(([otherThreadId, other]) => ({ threadId: otherThreadId, ...other })).sort((a, b) => a.first.queuedAt - b.first.queuedAt);
562
477
  };
563
- let reading = null;
564
- let readAgain = false;
565
- const reload = () => {
566
- if (!store || disposed) return;
567
- if (reading) {
568
- readAgain = true;
569
- return;
570
- }
571
- listingsStarted += 1;
572
- const listing = listingsStarted;
573
- reading = store.listAll().then(
574
- (records) => {
575
- if (disposed) return;
576
- applyRecords(records, listing);
577
- loaded = true;
578
- },
579
- () => {
580
- loaded = true;
478
+ const buildInsert = (id, input) => {
479
+ const queuedAt = now();
480
+ const newChat = typeof isNewChat === "function" ? isNewChat() : isNewChat;
481
+ const files = input.files ?? [];
482
+ const metadata = addressedAgents.withAddressedAgents(input.metadata, input.addressedAgents);
483
+ const parts = [
484
+ ...files.map((file) => ({
485
+ type: "file",
486
+ mediaType: file.mediaType,
487
+ url: file.url,
488
+ ...file.filename !== void 0 && { filename: file.filename }
489
+ })),
490
+ ...input.text.length > 0 ? [{ type: "text", text: input.text }] : []
491
+ ];
492
+ const view = thread.view();
493
+ const params = {
494
+ type: "run/send",
495
+ behavior: "auto",
496
+ runId: view.runId ?? randomId(),
497
+ message: { id, role: "user", parts, ...metadata !== void 0 && { metadata } },
498
+ ...view.runId === null && {
499
+ runAnchorMessageId: view.wireMessages && view.wireMessages.length > 0 ? chatOutboxThread.chatOutboxWireAnchorId(view.wireMessages) : null
581
500
  }
582
- ).finally(() => {
583
- reading = null;
584
- if (disposed) return;
585
- evaluate();
586
- if (readAgain) {
587
- readAgain = false;
588
- reload();
501
+ };
502
+ const attachments = input.attachments && input.attachments.length > 0 ? input.attachments : void 0;
503
+ const localMeta = {
504
+ kind: chatOutboxEntry.CHAT_OUTBOX_LOCAL_META_KIND,
505
+ threadId,
506
+ queuedAt,
507
+ newChat,
508
+ ...input.composerMarkdown !== void 0 && { composerMarkdown: input.composerMarkdown },
509
+ ...input.composerHtml !== void 0 && { composerHtml: input.composerHtml },
510
+ ...attachments && { attachments }
511
+ };
512
+ const entry = {
513
+ id,
514
+ threadId,
515
+ text: input.text,
516
+ queuedAt,
517
+ newChat,
518
+ durable: false,
519
+ ...input.composerMarkdown !== void 0 && { composerMarkdown: input.composerMarkdown },
520
+ ...input.composerHtml !== void 0 && { composerHtml: input.composerHtml },
521
+ ...metadata !== void 0 && { metadata },
522
+ ...files.length > 0 && { files },
523
+ ...attachments && { attachments }
524
+ };
525
+ return {
526
+ entry,
527
+ insert: {
528
+ protocol: statewireTransport.DEEP_AGENT_STATEWIRE_PROTOCOL,
529
+ command: { method: "run/send", params: [params] },
530
+ held: true,
531
+ localMeta
589
532
  }
590
- });
533
+ };
591
534
  };
592
535
  const unsubscribers = [
593
536
  reachability.subscribe(evaluate),
594
537
  foreground.subscribe(evaluate),
595
538
  thread.subscribe(evaluate),
596
- ...sendGate ? [sendGate.subscribe(evaluate)] : [],
597
- ...store ? [store.subscribe(reload)] : []
539
+ ...directory ? [directory.subscribe(evaluate)] : []
598
540
  ];
599
- reload();
600
- publish();
541
+ evaluate();
601
542
  return {
602
543
  threadId,
603
544
  reachability,
@@ -609,117 +550,120 @@ function createChatOutbox(options) {
609
550
  };
610
551
  },
611
552
  shouldHold() {
553
+ if (thread.outbox() === null && pending.length === 0) return false;
612
554
  if (!reachability.get()) return true;
613
- if (!loaded) return true;
614
- return entries.some((entry) => {
615
- const phase = phaseOf(entry.id);
616
- return phase.kind !== "failed" && !(phase.kind === "handed" && phase.journaled);
617
- });
555
+ return pending.length > 0 || landing.size > 0 || readRows(thread.outbox()).length > 0;
618
556
  },
619
557
  hold(input) {
620
- const entry = {
621
- id: newMessageId(),
622
- threadId,
623
- text: input.text,
624
- queuedAt: now(),
625
- newChat: typeof isNewChat === "function" ? isNewChat() : isNewChat,
626
- ...input.composerMarkdown !== void 0 && { composerMarkdown: input.composerMarkdown },
627
- ...input.composerHtml !== void 0 && { composerHtml: input.composerHtml },
628
- ...input.metadata !== void 0 && { metadata: input.metadata },
629
- ...input.sendContext !== void 0 && { sendContext: input.sendContext },
630
- ...input.files !== void 0 && input.files.length > 0 && { files: input.files },
631
- ...input.attachments !== void 0 && input.attachments.length > 0 && { attachments: input.attachments }
632
- };
633
- if (!loaded && gateOpen()) sendNow.add(entry.id);
634
- entries = [...entries, entry];
635
- if (store) {
636
- persisted.add(entry.id);
637
- const write = store.put(entry);
638
- markUnsettled(entry.id, write);
639
- void write.then(
640
- (kept) => {
641
- if (!kept) persisted.delete(entry.id);
642
- emit({ type: "held", threadId, messageId: entry.id, durable: kept });
643
- publish();
644
- },
645
- () => {
646
- persisted.delete(entry.id);
647
- emit({ type: "held", threadId, messageId: entry.id, durable: false });
648
- publish();
649
- }
650
- );
651
- } else {
652
- emit({ type: "held", threadId, messageId: entry.id, durable: false });
558
+ const built = buildInsert(newMessageId(), input);
559
+ const outbox = thread.outbox();
560
+ let inserted = false;
561
+ if (outbox && pending.length === 0) {
562
+ try {
563
+ outbox.insert(built.insert);
564
+ landing.set(built.entry.id, built.entry);
565
+ inserted = true;
566
+ } catch {
567
+ inserted = false;
568
+ }
653
569
  }
570
+ if (!inserted) pending = [...pending, built];
571
+ else emit({ type: "held", threadId, messageId: built.entry.id, durable: true });
654
572
  evaluate();
655
- return entry;
573
+ const row = findRow(built.entry.id);
574
+ return (row == null ? void 0 : row.entry) ?? built.entry;
656
575
  },
657
576
  cancel(id) {
658
- const entry = entries.find((candidate) => candidate.id === id);
659
- if (!entry || isBusy(phaseOf(id))) return;
660
- dropEntry(id);
577
+ var _a, _b;
578
+ const row = findRow(id);
579
+ if (!row) {
580
+ const waiting = ((_a = pending.find((item) => item.entry.id === id)) == null ? void 0 : _a.entry) ?? landing.get(id);
581
+ if (!waiting) return;
582
+ pending = pending.filter((item) => item.entry !== waiting);
583
+ if (landing.delete(id)) dropOnLanding.add(id);
584
+ emit({ type: "cancelled", threadId, messageId: id });
585
+ try {
586
+ restore(waiting);
587
+ } finally {
588
+ evaluate();
589
+ }
590
+ return;
591
+ }
592
+ try {
593
+ (_b = thread.outbox()) == null ? void 0 : _b.remove(row.stored.id);
594
+ } catch {
595
+ return;
596
+ }
597
+ forgetLegacy(row);
661
598
  emit({ type: "cancelled", threadId, messageId: id });
662
- if (store) void store.remove(threadId, id).catch(() => void 0);
663
599
  try {
664
- restore(entry);
600
+ restore(row.entry);
665
601
  } finally {
666
602
  evaluate();
667
603
  }
668
604
  },
669
605
  send(id) {
670
- const entry = entries.find((candidate) => candidate.id === id);
671
- if (!entry || isBusy(phaseOf(id))) return;
672
- const wasFailed = phaseOf(id).kind === "failed";
673
- phases.set(id, { kind: "idle" });
674
- handedInRegain.delete(id);
675
- sendNow.add(id);
676
- if (wasFailed && store) {
677
- const write = store.clearFailure({ threadId, id });
678
- markUnsettled(id, write);
679
- void write.catch(() => void 0);
680
- }
606
+ const row = findRow(id);
607
+ if (!row || released.has(row.stored.id)) return;
608
+ failing.delete(row.stored.id);
609
+ release(row, false);
681
610
  evaluate();
682
611
  },
683
- discard(id) {
684
- const entry = entries.find((candidate) => candidate.id === id);
685
- if (!entry || isBusy(phaseOf(id))) return;
686
- dropEntry(id);
687
- emit({ type: "discarded", threadId, messageId: id });
688
- if (store) void store.remove(threadId, id).catch(() => void 0);
612
+ edit(id, input) {
613
+ const row = findRow(id);
614
+ const outbox = thread.outbox();
615
+ if (!row || !outbox) return;
616
+ const rebuilt = buildInsert(id, input);
617
+ const message = rebuilt.insert.command.params[0].message;
618
+ try {
619
+ outbox.update(row.stored.id, (current) => {
620
+ if (current.state !== "held") return {};
621
+ const params = current.command.params[0];
622
+ const stripped = chatOutboxEntry.withoutTransientLocalMeta(current.localMeta);
623
+ const base = isRecord(stripped) ? stripped : {};
624
+ const { composerMarkdown: _md, composerHtml: _html, attachments: _attachments, ...kept } = base;
625
+ return {
626
+ localMeta: { ...kept, ...rebuilt.insert.localMeta, queuedAt: row.entry.queuedAt },
627
+ command: { params: [{ ...isRecord(params) ? params : {}, message }, ...current.command.params.slice(1)] }
628
+ };
629
+ });
630
+ } catch {
631
+ return;
632
+ }
633
+ evaluate();
634
+ failing.delete(row.stored.id);
635
+ const edited = findRow(id);
636
+ if (edited) release(edited, false);
689
637
  evaluate();
690
638
  },
691
- observeCommand(update) {
692
- if (disposed) return;
693
- const id = chatOutboxCommandMessageId(update.params);
694
- if (id === null) return;
695
- const phase = phaseOf(id);
696
- if (phase.kind === "handed") {
697
- if (update.status === "queued") {
698
- phases.set(id, { kind: "handed", journaled: true });
639
+ discard(id) {
640
+ var _a;
641
+ const row = findRow(id);
642
+ if (!row) {
643
+ if (!pending.some((item) => item.entry.id === id) && !landing.has(id)) return;
644
+ pending = pending.filter((item) => item.entry.id !== id);
645
+ if (landing.delete(id)) dropOnLanding.add(id);
646
+ } else {
647
+ try {
648
+ (_a = thread.outbox()) == null ? void 0 : _a.remove(row.stored.id);
649
+ } catch {
699
650
  return;
700
651
  }
701
- letGo(id, { type: "delivered", threadId, messageId: id, status: update.status });
702
- evaluate();
703
- return;
652
+ forgetLegacy(row);
704
653
  }
705
- if (entries.some((entry) => entry.id === id)) evaluate();
654
+ emit({ type: "discarded", threadId, messageId: id });
655
+ evaluate();
706
656
  },
707
657
  openThread: openThread ?? null,
708
658
  dispose() {
709
659
  if (disposed) return;
710
660
  disposed = true;
711
- stopCountdown();
712
- leaseTimer == null ? void 0 : leaseTimer();
661
+ timer == null ? void 0 : timer.cancel();
662
+ timer = null;
713
663
  for (const stop of checkTimers) stop();
714
664
  checkTimers.clear();
715
- readyToGo.clear();
716
665
  for (const unsubscribe of unsubscribers) unsubscribe();
717
666
  listeners.clear();
718
- if (store) {
719
- for (const [id, phase] of phases) {
720
- if (phase.kind === "claiming") releaseClaim(id);
721
- }
722
- }
723
667
  }
724
668
  };
725
669
  }
@@ -727,11 +671,12 @@ exports.CHAT_EDIT_KEPT_MESSAGE = CHAT_EDIT_KEPT_MESSAGE;
727
671
  exports.CHAT_EDIT_UNREACHABLE_LABEL = CHAT_EDIT_UNREACHABLE_LABEL;
728
672
  exports.CHAT_OUTBOX_ASK_AFTER_MS = CHAT_OUTBOX_ASK_AFTER_MS;
729
673
  exports.CHAT_OUTBOX_ATTACHMENT_CHECK_TIMEOUT_MS = CHAT_OUTBOX_ATTACHMENT_CHECK_TIMEOUT_MS;
730
- exports.CHAT_OUTBOX_CLAIM_LEASE_MS = CHAT_OUTBOX_CLAIM_LEASE_MS;
674
+ exports.CHAT_OUTBOX_ATTACHMENT_REFUSED_CODE = CHAT_OUTBOX_ATTACHMENT_REFUSED_CODE;
675
+ exports.CHAT_OUTBOX_ATTACHMENT_UNKNOWN_CODE = CHAT_OUTBOX_ATTACHMENT_UNKNOWN_CODE;
731
676
  exports.CHAT_OUTBOX_COUNTDOWN_MS = CHAT_OUTBOX_COUNTDOWN_MS;
732
677
  exports.ChatEditUnreachableError = ChatEditUnreachableError;
733
- exports.chatOutboxCommandMessageId = chatOutboxCommandMessageId;
734
678
  exports.chatOutboxFailureMessage = chatOutboxFailureMessage;
735
679
  exports.createChatOutbox = createChatOutbox;
680
+ exports.reanchorHeldSendParams = reanchorHeldSendParams;
736
681
  exports.sameChatOutboxSnapshot = sameChatOutboxSnapshot;
737
682
  //# sourceMappingURL=chat-outbox.cjs.map