@athenaintel/react 0.41.2 → 0.42.1

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 (451) hide show
  1. package/README.md +108 -9
  2. package/dist/agent-runtime/src/asset-attachment.d.ts +98 -0
  3. package/dist/agent-runtime/src/athena-asset-drag.d.ts +32 -0
  4. package/dist/agent-runtime/src/auth-denial.d.ts +29 -0
  5. package/dist/agent-runtime/src/chat-outbox-attachments.cjs +41 -0
  6. package/dist/agent-runtime/src/chat-outbox-attachments.cjs.map +1 -0
  7. package/dist/agent-runtime/src/chat-outbox-attachments.d.ts +38 -0
  8. package/dist/agent-runtime/src/chat-outbox-attachments.js +41 -0
  9. package/dist/agent-runtime/src/chat-outbox-attachments.js.map +1 -0
  10. package/dist/agent-runtime/src/chat-outbox-signals.cjs +63 -0
  11. package/dist/agent-runtime/src/chat-outbox-signals.cjs.map +1 -0
  12. package/dist/agent-runtime/src/chat-outbox-signals.d.ts +12 -0
  13. package/dist/agent-runtime/src/chat-outbox-signals.js +63 -0
  14. package/dist/agent-runtime/src/chat-outbox-signals.js.map +1 -0
  15. package/dist/agent-runtime/src/chat-outbox-store.cjs +509 -0
  16. package/dist/agent-runtime/src/chat-outbox-store.cjs.map +1 -0
  17. package/dist/agent-runtime/src/chat-outbox-store.d.ts +203 -0
  18. package/dist/agent-runtime/src/chat-outbox-store.js +509 -0
  19. package/dist/agent-runtime/src/chat-outbox-store.js.map +1 -0
  20. package/dist/agent-runtime/src/chat-outbox-thread.cjs +136 -0
  21. package/dist/agent-runtime/src/chat-outbox-thread.cjs.map +1 -0
  22. package/dist/agent-runtime/src/chat-outbox-thread.d.ts +118 -0
  23. package/dist/agent-runtime/src/chat-outbox-thread.js +136 -0
  24. package/dist/agent-runtime/src/chat-outbox-thread.js.map +1 -0
  25. package/dist/agent-runtime/src/chat-outbox.cjs +696 -0
  26. package/dist/agent-runtime/src/chat-outbox.cjs.map +1 -0
  27. package/dist/agent-runtime/src/chat-outbox.d.ts +285 -0
  28. package/dist/agent-runtime/src/chat-outbox.js +696 -0
  29. package/dist/agent-runtime/src/chat-outbox.js.map +1 -0
  30. package/dist/agent-runtime/src/chat-socket-reachability.d.ts +45 -0
  31. package/dist/agent-runtime/src/client-tool-bridge.d.ts +152 -0
  32. package/dist/agent-runtime/src/client-tools.d.ts +133 -0
  33. package/dist/agent-runtime/src/composer-markdown.cjs +10 -0
  34. package/dist/agent-runtime/src/composer-markdown.cjs.map +1 -1
  35. package/dist/agent-runtime/src/composer-markdown.d.ts +108 -0
  36. package/dist/agent-runtime/src/composer-markdown.js +10 -0
  37. package/dist/agent-runtime/src/composer-markdown.js.map +1 -1
  38. package/dist/agent-runtime/src/config-mutations.d.ts +51 -0
  39. package/dist/agent-runtime/src/conversation-index.d.ts +110 -0
  40. package/dist/agent-runtime/src/conversation-list.d.ts +343 -0
  41. package/dist/agent-runtime/src/deep-agent-transport-recipe.cjs +3 -2
  42. package/dist/agent-runtime/src/deep-agent-transport-recipe.cjs.map +1 -1
  43. package/dist/agent-runtime/src/deep-agent-transport-recipe.d.ts +166 -0
  44. package/dist/agent-runtime/src/deep-agent-transport-recipe.js +3 -2
  45. package/dist/agent-runtime/src/deep-agent-transport-recipe.js.map +1 -1
  46. package/dist/agent-runtime/src/desktop-handoff.d.ts +139 -0
  47. package/dist/agent-runtime/src/durable-thread-snapshot-cache.cjs +158 -0
  48. package/dist/agent-runtime/src/durable-thread-snapshot-cache.cjs.map +1 -0
  49. package/dist/agent-runtime/src/durable-thread-snapshot-cache.d.ts +60 -0
  50. package/dist/agent-runtime/src/durable-thread-snapshot-cache.js +158 -0
  51. package/dist/agent-runtime/src/durable-thread-snapshot-cache.js.map +1 -0
  52. package/dist/agent-runtime/src/edit-command.d.ts +156 -0
  53. package/dist/agent-runtime/src/errors.d.ts +174 -0
  54. package/dist/agent-runtime/src/execute-output.d.ts +31 -0
  55. package/dist/agent-runtime/src/generated/runconfig-contract.cjs +16 -2
  56. package/dist/agent-runtime/src/generated/runconfig-contract.cjs.map +1 -1
  57. package/dist/agent-runtime/src/generated/runconfig-contract.d.ts +202 -0
  58. package/dist/agent-runtime/src/generated/runconfig-contract.js +16 -2
  59. package/dist/agent-runtime/src/generated/runconfig-contract.js.map +1 -1
  60. package/dist/agent-runtime/src/github-wake-event.d.ts +77 -0
  61. package/dist/agent-runtime/src/index.d.ts +74 -0
  62. package/dist/agent-runtime/src/interrupts.cjs +17 -0
  63. package/dist/agent-runtime/src/interrupts.cjs.map +1 -1
  64. package/dist/agent-runtime/src/interrupts.d.ts +348 -0
  65. package/dist/agent-runtime/src/interrupts.js +17 -0
  66. package/dist/agent-runtime/src/interrupts.js.map +1 -1
  67. package/dist/agent-runtime/src/lane-follow.d.ts +121 -0
  68. package/dist/agent-runtime/src/lane-history.cjs +209 -0
  69. package/dist/agent-runtime/src/lane-history.cjs.map +1 -0
  70. package/dist/agent-runtime/src/lane-history.d.ts +175 -0
  71. package/dist/agent-runtime/src/lane-history.js +209 -0
  72. package/dist/agent-runtime/src/lane-history.js.map +1 -0
  73. package/dist/agent-runtime/src/lane-images.d.ts +184 -0
  74. package/dist/agent-runtime/src/message-author.d.ts +43 -0
  75. package/dist/agent-runtime/src/message-text.cjs +15 -0
  76. package/dist/agent-runtime/src/message-text.cjs.map +1 -0
  77. package/dist/agent-runtime/src/message-text.d.ts +47 -0
  78. package/dist/agent-runtime/src/message-text.js +15 -0
  79. package/dist/agent-runtime/src/message-text.js.map +1 -0
  80. package/dist/agent-runtime/src/message-window.cjs +15 -1
  81. package/dist/agent-runtime/src/message-window.cjs.map +1 -1
  82. package/dist/agent-runtime/src/message-window.d.ts +159 -0
  83. package/dist/agent-runtime/src/message-window.js +16 -2
  84. package/dist/agent-runtime/src/message-window.js.map +1 -1
  85. package/dist/agent-runtime/src/messages.cjs +88 -4
  86. package/dist/agent-runtime/src/messages.cjs.map +1 -1
  87. package/dist/agent-runtime/src/messages.d.ts +603 -0
  88. package/dist/agent-runtime/src/messages.js +88 -4
  89. package/dist/agent-runtime/src/messages.js.map +1 -1
  90. package/dist/agent-runtime/src/model-context.d.ts +22 -0
  91. package/dist/agent-runtime/src/offline-status.d.ts +157 -0
  92. package/dist/agent-runtime/src/optimistic-content.d.ts +21 -0
  93. package/dist/agent-runtime/src/protocol.cjs +12 -4
  94. package/dist/agent-runtime/src/protocol.cjs.map +1 -1
  95. package/dist/agent-runtime/src/protocol.d.ts +119 -0
  96. package/dist/agent-runtime/src/protocol.js +13 -5
  97. package/dist/agent-runtime/src/protocol.js.map +1 -1
  98. package/dist/agent-runtime/src/ptc-subcalls.d.ts +51 -0
  99. package/dist/agent-runtime/src/queue.d.ts +138 -0
  100. package/dist/agent-runtime/src/quota-safe-local-storage-session.d.ts +154 -0
  101. package/dist/agent-runtime/src/running-tool-placeholder.cjs +11 -0
  102. package/dist/agent-runtime/src/running-tool-placeholder.cjs.map +1 -0
  103. package/dist/agent-runtime/src/running-tool-placeholder.d.ts +25 -0
  104. package/dist/agent-runtime/src/running-tool-placeholder.js +11 -0
  105. package/dist/agent-runtime/src/running-tool-placeholder.js.map +1 -0
  106. package/dist/agent-runtime/src/runtime-messages.d.ts +104 -0
  107. package/dist/agent-runtime/src/screen-point.d.ts +151 -0
  108. package/dist/agent-runtime/src/sealed-idb.cjs +112 -0
  109. package/dist/agent-runtime/src/sealed-idb.cjs.map +1 -0
  110. package/dist/agent-runtime/src/sealed-idb.d.ts +106 -0
  111. package/dist/agent-runtime/src/sealed-idb.js +112 -0
  112. package/dist/agent-runtime/src/sealed-idb.js.map +1 -0
  113. package/dist/agent-runtime/src/send-recovery.d.ts +40 -0
  114. package/dist/agent-runtime/src/statewire-attach-observer.d.ts +194 -0
  115. package/dist/agent-runtime/src/statewire-diagnostics.d.ts +74 -0
  116. package/dist/agent-runtime/src/statewire-state.d.ts +29 -0
  117. package/dist/agent-runtime/src/statewire-suspended.cjs.map +1 -1
  118. package/dist/agent-runtime/src/statewire-suspended.d.ts +27 -0
  119. package/dist/agent-runtime/src/statewire-suspended.js.map +1 -1
  120. package/dist/agent-runtime/src/statewire-transport.d.ts +40 -0
  121. package/dist/agent-runtime/src/streaming-markdown.d.ts +46 -0
  122. package/dist/agent-runtime/src/subagent-transcripts.cjs +209 -0
  123. package/dist/agent-runtime/src/subagent-transcripts.cjs.map +1 -0
  124. package/dist/agent-runtime/src/subagent-transcripts.d.ts +71 -0
  125. package/dist/agent-runtime/src/subagent-transcripts.js +209 -0
  126. package/dist/agent-runtime/src/subagent-transcripts.js.map +1 -0
  127. package/dist/agent-runtime/src/subagents.cjs +253 -0
  128. package/dist/agent-runtime/src/subagents.cjs.map +1 -0
  129. package/dist/agent-runtime/src/subagents.d.ts +311 -0
  130. package/dist/agent-runtime/src/subagents.js +253 -0
  131. package/dist/agent-runtime/src/subagents.js.map +1 -0
  132. package/dist/agent-runtime/src/subscription-wake-event.d.ts +111 -0
  133. package/dist/agent-runtime/src/thread-extras.d.ts +43 -0
  134. package/dist/agent-runtime/src/thread-handoff.d.ts +364 -0
  135. package/dist/agent-runtime/src/thread-prewarm-controller.d.ts +76 -0
  136. package/dist/agent-runtime/src/thread-prewarm.d.ts +118 -0
  137. package/dist/agent-runtime/src/thread-snapshot-cache.d.ts +99 -0
  138. package/dist/agent-runtime/src/thread-snapshot-mirror.cjs +329 -0
  139. package/dist/agent-runtime/src/thread-snapshot-mirror.cjs.map +1 -0
  140. package/dist/agent-runtime/src/thread-snapshot-mirror.d.ts +101 -0
  141. package/dist/agent-runtime/src/thread-snapshot-mirror.js +329 -0
  142. package/dist/agent-runtime/src/thread-snapshot-mirror.js.map +1 -0
  143. package/dist/agent-runtime/src/thread-status.d.ts +53 -0
  144. package/dist/agent-runtime/src/tool-metadata.d.ts +146 -0
  145. package/dist/agent-runtime/src/tool-names.cjs +67 -0
  146. package/dist/agent-runtime/src/tool-names.cjs.map +1 -1
  147. package/dist/agent-runtime/src/tool-names.d.ts +60 -0
  148. package/dist/agent-runtime/src/tool-names.js +68 -1
  149. package/dist/agent-runtime/src/tool-names.js.map +1 -1
  150. package/dist/agent-runtime/src/tool-outputs.d.ts +35 -0
  151. package/dist/agent-runtime/src/tool-result.cjs +1 -0
  152. package/dist/agent-runtime/src/tool-result.cjs.map +1 -1
  153. package/dist/agent-runtime/src/tool-result.d.ts +126 -0
  154. package/dist/agent-runtime/src/tool-result.js +1 -0
  155. package/dist/agent-runtime/src/tool-result.js.map +1 -1
  156. package/dist/agent-runtime/src/types.d.ts +159 -0
  157. package/dist/agent-runtime/src/use-conversation-list.d.ts +76 -0
  158. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.cjs +136 -0
  159. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.cjs.map +1 -0
  160. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.d.ts +64 -0
  161. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.js +136 -0
  162. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.js.map +1 -0
  163. package/dist/agent-runtime/src/use-deep-agent-config.d.ts +169 -0
  164. package/dist/agent-runtime/src/use-deep-agent-edit-submit.cjs +13 -0
  165. package/dist/agent-runtime/src/use-deep-agent-edit-submit.cjs.map +1 -1
  166. package/dist/agent-runtime/src/use-deep-agent-edit-submit.d.ts +22 -0
  167. package/dist/agent-runtime/src/use-deep-agent-edit-submit.js +13 -0
  168. package/dist/agent-runtime/src/use-deep-agent-edit-submit.js.map +1 -1
  169. package/dist/agent-runtime/src/use-deep-agent-runtime.cjs +20 -2
  170. package/dist/agent-runtime/src/use-deep-agent-runtime.cjs.map +1 -1
  171. package/dist/agent-runtime/src/use-deep-agent-runtime.d.ts +168 -0
  172. package/dist/agent-runtime/src/use-deep-agent-runtime.js +20 -2
  173. package/dist/agent-runtime/src/use-deep-agent-runtime.js.map +1 -1
  174. package/dist/agent-runtime/src/use-deep-agent-thread.cjs +12 -4
  175. package/dist/agent-runtime/src/use-deep-agent-thread.cjs.map +1 -1
  176. package/dist/agent-runtime/src/use-deep-agent-thread.d.ts +320 -0
  177. package/dist/agent-runtime/src/use-deep-agent-thread.js +12 -4
  178. package/dist/agent-runtime/src/use-deep-agent-thread.js.map +1 -1
  179. package/dist/agent-runtime/src/use-deep-agent-voice.cjs +999 -0
  180. package/dist/agent-runtime/src/use-deep-agent-voice.cjs.map +1 -0
  181. package/dist/agent-runtime/src/use-deep-agent-voice.d.ts +409 -0
  182. package/dist/agent-runtime/src/use-deep-agent-voice.js +999 -0
  183. package/dist/agent-runtime/src/use-deep-agent-voice.js.map +1 -0
  184. package/dist/agent-runtime/src/use-deep-agent-window-sync.d.ts +102 -0
  185. package/dist/agent-runtime/src/use-historical-edit-attachments.d.ts +2 -0
  186. package/dist/agent-runtime/src/use-thread-handoff-flow.d.ts +84 -0
  187. package/dist/agent-runtime/src/voice-presentation.d.ts +80 -0
  188. package/dist/agent-runtime/src/voice-turn-grouping.d.ts +28 -0
  189. package/dist/agent-runtime/src/voice-wire-types.d.ts +15 -0
  190. package/dist/agent-runtime/src/withdrawn-turns.d.ts +97 -0
  191. package/dist/chat/AthenaChat.cjs +77 -6
  192. package/dist/chat/AthenaChat.cjs.map +1 -1
  193. package/dist/chat/AthenaChat.js +78 -7
  194. package/dist/chat/AthenaChat.js.map +1 -1
  195. package/dist/chat/StatewireApprovalCard.d.ts +1 -1
  196. package/dist/chat/StatewireClientToolBridge.d.ts +1 -1
  197. package/dist/chat/StatewireQueuedMessages.cjs +11 -4
  198. package/dist/chat/StatewireQueuedMessages.cjs.map +1 -1
  199. package/dist/chat/StatewireQueuedMessages.d.ts +1 -1
  200. package/dist/chat/StatewireQueuedMessages.js +11 -4
  201. package/dist/chat/StatewireQueuedMessages.js.map +1 -1
  202. package/dist/chat/chat-outbox-rows.cjs +223 -0
  203. package/dist/chat/chat-outbox-rows.cjs.map +1 -0
  204. package/dist/chat/chat-outbox-rows.d.ts +29 -0
  205. package/dist/chat/chat-outbox-rows.js +223 -0
  206. package/dist/chat/chat-outbox-rows.js.map +1 -0
  207. package/dist/chat/statewire-approval.d.ts +1 -1
  208. package/dist/chat/statewire-client-tools.d.ts +1 -1
  209. package/dist/chat/super-grouping/SuperGroupingCard.cjs +3 -1
  210. package/dist/chat/super-grouping/SuperGroupingCard.cjs.map +1 -1
  211. package/dist/chat/super-grouping/SuperGroupingCard.d.ts +7 -1
  212. package/dist/chat/super-grouping/SuperGroupingCard.js +3 -1
  213. package/dist/chat/super-grouping/SuperGroupingCard.js.map +1 -1
  214. package/dist/chat/super-grouping/SuperGroupingTranscript.cjs +7 -2
  215. package/dist/chat/super-grouping/SuperGroupingTranscript.cjs.map +1 -1
  216. package/dist/chat/super-grouping/SuperGroupingTranscript.d.ts +2 -2
  217. package/dist/chat/super-grouping/SuperGroupingTranscript.js +7 -2
  218. package/dist/chat/super-grouping/SuperGroupingTranscript.js.map +1 -1
  219. package/dist/chat/super-grouping/activity-timeline.cjs +19 -11
  220. package/dist/chat/super-grouping/activity-timeline.cjs.map +1 -1
  221. package/dist/chat/super-grouping/activity-timeline.d.ts +25 -9
  222. package/dist/chat/super-grouping/activity-timeline.js +19 -11
  223. package/dist/chat/super-grouping/activity-timeline.js.map +1 -1
  224. package/dist/chat/use-statewire-approval-request.cjs +36 -0
  225. package/dist/chat/use-statewire-approval-request.cjs.map +1 -1
  226. package/dist/chat/use-statewire-approval-request.d.ts +49 -1
  227. package/dist/chat/use-statewire-approval-request.js +39 -3
  228. package/dist/chat/use-statewire-approval-request.js.map +1 -1
  229. package/dist/chat-ui/composer/tiptap-composer.cjs +102 -3
  230. package/dist/chat-ui/composer/tiptap-composer.cjs.map +1 -1
  231. package/dist/chat-ui/composer/tiptap-composer.d.ts +32 -1
  232. package/dist/chat-ui/composer/tiptap-composer.js +103 -4
  233. package/dist/chat-ui/composer/tiptap-composer.js.map +1 -1
  234. package/dist/chat-ui/header/conversation-history-panel.d.ts +1 -1
  235. package/dist/chat-ui/index.d.ts +1 -1
  236. package/dist/chat-ui/messages/message-components.cjs +15 -0
  237. package/dist/chat-ui/messages/message-components.cjs.map +1 -1
  238. package/dist/chat-ui/messages/message-components.js +15 -0
  239. package/dist/chat-ui/messages/message-components.js.map +1 -1
  240. package/dist/chat-ui/messages/runtime-message.d.ts +1 -1
  241. package/dist/chat-ui/messages/statewire-continue-run.d.ts +1 -1
  242. package/dist/chat-ui/messages/user-edit-composer.cjs +15 -2
  243. package/dist/chat-ui/messages/user-edit-composer.cjs.map +1 -1
  244. package/dist/chat-ui/messages/user-edit-composer.d.ts +4 -2
  245. package/dist/chat-ui/messages/user-edit-composer.js +15 -2
  246. package/dist/chat-ui/messages/user-edit-composer.js.map +1 -1
  247. package/dist/chat-ui/messages/wake-marker.d.ts +1 -1
  248. package/dist/chat-ui/rich-text/chat-text-schema.cjs +1 -0
  249. package/dist/chat-ui/rich-text/chat-text-schema.cjs.map +1 -1
  250. package/dist/chat-ui/rich-text/chat-text-schema.d.ts +3 -0
  251. package/dist/chat-ui/rich-text/chat-text-schema.js +1 -0
  252. package/dist/chat-ui/rich-text/chat-text-schema.js.map +1 -1
  253. package/dist/chat-ui/statewire.cjs +1 -0
  254. package/dist/chat-ui/statewire.cjs.map +1 -1
  255. package/dist/chat-ui/statewire.d.ts +2 -2
  256. package/dist/chat-ui/statewire.js +2 -1
  257. package/dist/chat-ui/thread/statewire-history-edge.d.ts +1 -1
  258. package/dist/composer/AttachmentContext.cjs +8 -4
  259. package/dist/composer/AttachmentContext.cjs.map +1 -1
  260. package/dist/composer/AttachmentContext.d.ts +7 -0
  261. package/dist/composer/AttachmentContext.js +8 -4
  262. package/dist/composer/AttachmentContext.js.map +1 -1
  263. package/dist/composer/build-composed-message.cjs +34 -0
  264. package/dist/composer/build-composed-message.cjs.map +1 -1
  265. package/dist/composer/build-composed-message.d.ts +20 -0
  266. package/dist/composer/build-composed-message.js +35 -1
  267. package/dist/composer/build-composed-message.js.map +1 -1
  268. package/dist/composer/composer-handoff.cjs +39 -2
  269. package/dist/composer/composer-handoff.cjs.map +1 -1
  270. package/dist/composer/composer-handoff.d.ts +28 -3
  271. package/dist/composer/composer-handoff.js +39 -2
  272. package/dist/composer/composer-handoff.js.map +1 -1
  273. package/dist/composer/useAttachFiles.cjs +15 -2
  274. package/dist/composer/useAttachFiles.cjs.map +1 -1
  275. package/dist/composer/useAttachFiles.d.ts +11 -0
  276. package/dist/composer/useAttachFiles.js +15 -2
  277. package/dist/composer/useAttachFiles.js.map +1 -1
  278. package/dist/composer/useSendMessage.cjs.map +1 -1
  279. package/dist/composer/useSendMessage.d.ts +4 -3
  280. package/dist/composer/useSendMessage.js.map +1 -1
  281. package/dist/diagnostics/athena-diagnostics.cjs.map +1 -1
  282. package/dist/diagnostics/athena-diagnostics.d.ts +3 -1
  283. package/dist/diagnostics/athena-diagnostics.js.map +1 -1
  284. package/dist/index.cjs +18 -0
  285. package/dist/index.cjs.map +1 -1
  286. package/dist/index.d.ts +15 -6
  287. package/dist/index.js +19 -1
  288. package/dist/index.js.map +1 -1
  289. package/dist/offline/chat-outbox.cjs +57 -0
  290. package/dist/offline/chat-outbox.cjs.map +1 -0
  291. package/dist/offline/chat-outbox.d.ts +80 -0
  292. package/dist/offline/chat-outbox.js +57 -0
  293. package/dist/offline/chat-outbox.js.map +1 -0
  294. package/dist/offline/offline-history.cjs +77 -0
  295. package/dist/offline/offline-history.cjs.map +1 -0
  296. package/dist/offline/offline-history.d.ts +60 -0
  297. package/dist/offline/offline-history.js +77 -0
  298. package/dist/offline/offline-history.js.map +1 -0
  299. package/dist/provider/AthenaProvider.cjs +206 -9
  300. package/dist/provider/AthenaProvider.cjs.map +1 -1
  301. package/dist/provider/AthenaProvider.d.ts +22 -1
  302. package/dist/provider/AthenaProvider.js +207 -10
  303. package/dist/provider/AthenaProvider.js.map +1 -1
  304. package/dist/provider/statewire-window-context.d.ts +1 -1
  305. package/dist/react/package.json.cjs +1 -1
  306. package/dist/react/package.json.js +1 -1
  307. package/dist/references/src/anchors/file-line-range.d.ts +58 -0
  308. package/dist/references/src/anchors/format.d.ts +21 -0
  309. package/dist/references/src/anchors/message-anchors.d.ts +71 -0
  310. package/dist/references/src/anchors/parse.d.ts +8 -0
  311. package/dist/references/src/anchors/registry-contract.d.ts +24 -0
  312. package/dist/references/src/anchors/registry.d.ts +19 -0
  313. package/dist/references/src/anchors/schemas.d.ts +194 -0
  314. package/dist/references/src/anchors/serialize.d.ts +8 -0
  315. package/dist/references/src/anchors/time.d.ts +78 -0
  316. package/dist/references/src/anchors/types.d.ts +474 -0
  317. package/dist/references/src/asset-bounds.d.ts +27 -0
  318. package/dist/references/src/asset-links.d.ts +23 -0
  319. package/dist/references/src/asset-reference.d.ts +16 -0
  320. package/dist/references/src/formats/format-catalog.d.ts +79 -0
  321. package/dist/references/src/formats/markdown/parse-reference-markdown.d.ts +28 -0
  322. package/dist/references/src/formats/markdown/reference-display-name.d.ts +6 -0
  323. package/dist/references/src/formats/object/asset-object.d.ts +9 -0
  324. package/dist/references/src/formats/object/callable-object.d.ts +6 -0
  325. package/dist/references/src/formats/object/decode-reference-object-payload.d.ts +3 -0
  326. package/dist/references/src/formats/object/external-url-object.d.ts +9 -0
  327. package/dist/references/src/formats/object/group-object.d.ts +9 -0
  328. package/dist/references/src/formats/object/navigation-object.d.ts +9 -0
  329. package/dist/references/src/formats/object/parse-reference-object.d.ts +11 -0
  330. package/dist/references/src/formats/object/person-object.d.ts +9 -0
  331. package/dist/references/src/formats/uri/asset-mention-uri.d.ts +9 -0
  332. package/dist/references/src/formats/uri/asset-spaces-url.d.ts +9 -0
  333. package/dist/references/src/formats/uri/callable-mention-uris.d.ts +9 -0
  334. package/dist/references/src/formats/uri/detect-uri-wire.d.ts +9 -0
  335. package/dist/references/src/formats/uri/group-mention-uri.d.ts +12 -0
  336. package/dist/references/src/formats/uri/navigation-spaces-url.d.ts +14 -0
  337. package/dist/references/src/formats/uri/parse-reference-uri.d.ts +20 -0
  338. package/dist/references/src/formats/uri/person-mention-uri.d.ts +9 -0
  339. package/dist/references/src/formats/uri/template-placeholder.d.ts +12 -0
  340. package/dist/references/src/index.d.ts +47 -0
  341. package/dist/references/src/legacy/index.d.ts +14 -0
  342. package/dist/references/src/legacy/pre-reference-asset-url.d.ts +57 -0
  343. package/dist/references/src/legacy/pre-reference-citation-bridge.d.ts +22 -0
  344. package/dist/references/src/legacy/pre-reference-citation.d.ts +138 -0
  345. package/dist/references/src/legacy/pre-reference-external-url.d.ts +31 -0
  346. package/dist/references/src/legacy/pre-reference-format.d.ts +8 -0
  347. package/dist/references/src/legacy/pre-reference-mention.d.ts +27 -0
  348. package/dist/references/src/legacy/pre-reference-object.d.ts +8 -0
  349. package/dist/references/src/legacy/pre-reference-uri.d.ts +12 -0
  350. package/dist/references/src/legacy.d.ts +2 -0
  351. package/dist/references/src/mention-href-patterns.d.ts +19 -0
  352. package/dist/references/src/mention-node/index.d.ts +5 -0
  353. package/dist/references/src/mention-node/mention-node.d.ts +31 -0
  354. package/dist/references/src/mention-node/resolve-node-attrs.d.ts +27 -0
  355. package/dist/references/src/parse-reference.d.ts +23 -0
  356. package/dist/references/src/schemas.d.ts +463 -0
  357. package/dist/references/src/serialize-reference.d.ts +50 -0
  358. package/dist/references/src/sheet-name.d.ts +10 -0
  359. package/dist/references/src/tool-option-schemas.d.ts +597 -0
  360. package/dist/references/src/types.d.ts +125 -0
  361. package/dist/references/src/version-ref.d.ts +30 -0
  362. package/dist/runtime/statewire-lifecycle.d.ts +1 -1
  363. package/dist/runtime/statewire-model-lane.d.ts +1 -1
  364. package/dist/runtime/statewire-server-lane-context.d.ts +1 -1
  365. package/dist/runtime/statewire-session-key.cjs +7 -0
  366. package/dist/runtime/statewire-session-key.cjs.map +1 -1
  367. package/dist/runtime/statewire-session-key.d.ts +16 -0
  368. package/dist/runtime/statewire-session-key.js +8 -1
  369. package/dist/runtime/statewire-session-key.js.map +1 -1
  370. package/dist/runtime/statewire-session-lane.cjs +48 -0
  371. package/dist/runtime/statewire-session-lane.cjs.map +1 -0
  372. package/dist/runtime/statewire-session-lane.d.ts +29 -0
  373. package/dist/runtime/statewire-session-lane.js +48 -0
  374. package/dist/runtime/statewire-session-lane.js.map +1 -0
  375. package/dist/runtime/statewire-thread-config-lane.d.ts +1 -1
  376. package/dist/runtime/useAthenaStatewireRuntime.cjs +16 -5
  377. package/dist/runtime/useAthenaStatewireRuntime.cjs.map +1 -1
  378. package/dist/runtime/useAthenaStatewireRuntime.d.ts +15 -1
  379. package/dist/runtime/useAthenaStatewireRuntime.js +17 -6
  380. package/dist/runtime/useAthenaStatewireRuntime.js.map +1 -1
  381. package/dist/styles.css +1 -1
  382. package/dist/threads/api.d.ts +1 -1
  383. package/dist/threads/conversation-list-fetcher.d.ts +1 -1
  384. package/dist/threads/index-triggered-refresh.cjs +164 -0
  385. package/dist/threads/index-triggered-refresh.cjs.map +1 -0
  386. package/dist/threads/index-triggered-refresh.d.ts +70 -0
  387. package/dist/threads/index-triggered-refresh.js +164 -0
  388. package/dist/threads/index-triggered-refresh.js.map +1 -0
  389. package/dist/threads/offline-session-list.cjs +75 -0
  390. package/dist/threads/offline-session-list.cjs.map +1 -0
  391. package/dist/threads/offline-session-list.d.ts +27 -0
  392. package/dist/threads/offline-session-list.js +75 -0
  393. package/dist/threads/offline-session-list.js.map +1 -0
  394. package/dist/threads/pull-request-display.d.ts +1 -1
  395. package/dist/threads/session-list-model.d.ts +1 -1
  396. package/dist/threads/session-list-tab-share.cjs +150 -0
  397. package/dist/threads/session-list-tab-share.cjs.map +1 -0
  398. package/dist/threads/session-list-tab-share.d.ts +73 -0
  399. package/dist/threads/session-list-tab-share.js +150 -0
  400. package/dist/threads/session-list-tab-share.js.map +1 -0
  401. package/dist/threads/session-row-parts.d.ts +1 -1
  402. package/dist/threads/sessions-query.d.ts +1 -1
  403. package/dist/threads/statewire-thread-list.cjs +105 -20
  404. package/dist/threads/statewire-thread-list.cjs.map +1 -1
  405. package/dist/threads/statewire-thread-list.d.ts +31 -3
  406. package/dist/threads/statewire-thread-list.js +107 -22
  407. package/dist/threads/statewire-thread-list.js.map +1 -1
  408. package/dist/threads/thread-prefetcher.d.ts +1 -1
  409. package/dist/threads/use-athena-session-attention.d.ts +1 -1
  410. package/dist/threads/use-athena-sessions.cjs +32 -22
  411. package/dist/threads/use-athena-sessions.cjs.map +1 -1
  412. package/dist/threads/use-athena-sessions.js +33 -23
  413. package/dist/threads/use-athena-sessions.js.map +1 -1
  414. package/dist/threads/use-rest-conversation-history.d.ts +1 -1
  415. package/dist/threads/use-statewire-conversation-history.d.ts +5 -5
  416. package/dist/tiptap-markdown-table/src/markdown-table-serializer.d.ts +56 -0
  417. package/dist/tools/NestedPtcMessages.cjs +14 -9
  418. package/dist/tools/NestedPtcMessages.cjs.map +1 -1
  419. package/dist/tools/NestedPtcMessages.d.ts +9 -0
  420. package/dist/tools/NestedPtcMessages.js +6 -1
  421. package/dist/tools/NestedPtcMessages.js.map +1 -1
  422. package/dist/tools/index.d.ts +1 -1
  423. package/dist/tools/primitives.d.ts +1 -1
  424. package/dist/tools/subagent-task-tool-ui.cjs +494 -0
  425. package/dist/tools/subagent-task-tool-ui.cjs.map +1 -0
  426. package/dist/tools/subagent-task-tool-ui.d.ts +109 -0
  427. package/dist/tools/subagent-task-tool-ui.js +494 -0
  428. package/dist/tools/subagent-task-tool-ui.js.map +1 -0
  429. package/dist/tools/tool-fallback.d.ts +1 -1
  430. package/dist/tools/tool-icons.d.ts +1 -1
  431. package/dist/tools/tool-summary.d.ts +1 -1
  432. package/dist/tools/tool-uis.cjs +4 -0
  433. package/dist/tools/tool-uis.cjs.map +1 -1
  434. package/dist/tools/tool-uis.js +4 -0
  435. package/dist/tools/tool-uis.js.map +1 -1
  436. package/dist/voice/chat.cjs +6 -0
  437. package/dist/voice/chat.cjs.map +1 -0
  438. package/dist/voice/chat.d.ts +2 -0
  439. package/dist/voice/chat.js +6 -0
  440. package/dist/voice/chat.js.map +1 -0
  441. package/dist/voice/livekit-join.cjs +119 -0
  442. package/dist/voice/livekit-join.cjs.map +1 -0
  443. package/dist/voice/livekit-join.d.ts +8 -0
  444. package/dist/voice/livekit-join.js +119 -0
  445. package/dist/voice/livekit-join.js.map +1 -0
  446. package/dist/voice/livekit.cjs +32 -0
  447. package/dist/voice/livekit.cjs.map +1 -0
  448. package/dist/voice/livekit.d.ts +80 -0
  449. package/dist/voice/livekit.js +32 -0
  450. package/dist/voice/livekit.js.map +1 -0
  451. package/package.json +20 -10
@@ -0,0 +1,696 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const CHAT_OUTBOX_COUNTDOWN_MS = 5e3;
4
+ const CHAT_OUTBOX_ASK_AFTER_MS = 24 * 60 * 60 * 1e3;
5
+ const CHAT_OUTBOX_CLAIM_LEASE_MS = 3e4;
6
+ const CHAT_OUTBOX_ATTACHMENT_CHECK_TIMEOUT_MS = 15e3;
7
+ const CHAT_EDIT_UNREACHABLE_LABEL = "Can't edit while Athena can't be reached";
8
+ const CHAT_EDIT_KEPT_MESSAGE = "Can't reach Athena right now. Your edit stays here — submit it once Athena is back.";
9
+ class ChatEditUnreachableError extends Error {
10
+ constructor() {
11
+ super(CHAT_EDIT_KEPT_MESSAGE);
12
+ this.name = "ChatEditUnreachableError";
13
+ }
14
+ }
15
+ 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;
33
+ }
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() {
42
+ var _a;
43
+ const host = globalThis;
44
+ if (typeof ((_a = host.crypto) == null ? void 0 : _a.randomUUID) === "function") return host.crypto.randomUUID();
45
+ const hex = Array.from({ length: 32 }, () => Math.floor(Math.random() * 16).toString(16)).join("");
46
+ return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-4${hex.slice(13, 16)}-a${hex.slice(17, 20)}-${hex.slice(20, 32)}`;
47
+ }
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;
57
+ }
58
+ }
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;
61
+ }
62
+ function sameChatOutboxSnapshot(a, b) {
63
+ if (a === b) return true;
64
+ if (a.countdownEndsAt !== b.countdownEndsAt || a.durable !== b.durable || a.loaded !== b.loaded) return false;
65
+ if (a.rows.length !== b.rows.length || a.elsewhere.length !== b.elsewhere.length) return false;
66
+ for (let index = 0; index < a.rows.length; index += 1) {
67
+ const x = a.rows[index];
68
+ const y = b.rows[index];
69
+ if (!x || !y || x.entry !== y.entry || !sameChatOutboxRowState(x.state, y.state)) return false;
70
+ }
71
+ for (let index = 0; index < a.elsewhere.length; index += 1) {
72
+ const x = a.elsewhere[index];
73
+ 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)) {
75
+ return false;
76
+ }
77
+ }
78
+ return true;
79
+ }
80
+ function createChatOutbox(options) {
81
+ const {
82
+ threadId,
83
+ isNewChat,
84
+ store,
85
+ reachability,
86
+ foreground,
87
+ thread,
88
+ restore,
89
+ openThread,
90
+ onEvent,
91
+ checkAttachments,
92
+ now = () => Date.now(),
93
+ countdownMs = CHAT_OUTBOX_COUNTDOWN_MS,
94
+ askAfterMs = CHAT_OUTBOX_ASK_AFTER_MS,
95
+ claimLeaseMs = CHAT_OUTBOX_CLAIM_LEASE_MS,
96
+ attachmentCheckTimeoutMs = CHAT_OUTBOX_ATTACHMENT_CHECK_TIMEOUT_MS,
97
+ newMessageId = defaultMessageId,
98
+ setTimer = (task, ms) => {
99
+ const timer = setTimeout(task, ms);
100
+ return () => clearTimeout(timer);
101
+ }
102
+ } = options;
103
+ const claimant = newMessageId();
104
+ let disposed = false;
105
+ let loaded = store === null;
106
+ let entries = [];
107
+ let elsewhere = [];
108
+ let claims = /* @__PURE__ */ new Map();
109
+ const persisted = /* @__PURE__ */ new Set();
110
+ const unsettled = /* @__PURE__ */ new Map();
111
+ let listingsStarted = 0;
112
+ const phases = /* @__PURE__ */ new Map();
113
+ const sendNow = /* @__PURE__ */ new Set();
114
+ const handedInRegain = /* @__PURE__ */ new Map();
115
+ let regain = 0;
116
+ let wasReachable = reachability.get();
117
+ let countdown = null;
118
+ let leaseTimer = null;
119
+ const checkTimers = /* @__PURE__ */ new Set();
120
+ const readyToGo = /* @__PURE__ */ new Map();
121
+ let releasing = false;
122
+ const asked = /* @__PURE__ */ new Set();
123
+ const listeners = /* @__PURE__ */ new Set();
124
+ let snapshot = {
125
+ rows: [],
126
+ countdownEndsAt: null,
127
+ durable: true,
128
+ loaded,
129
+ elsewhere
130
+ };
131
+ const emit = (event) => {
132
+ try {
133
+ onEvent == null ? void 0 : onEvent(event);
134
+ } catch {
135
+ }
136
+ };
137
+ const phaseOf = (id) => phases.get(id) ?? { kind: "idle" };
138
+ const isBusy = (phase) => phase.kind === "claiming" || phase.kind === "handed" || phase.kind === "awaiting-thread";
139
+ const claimedElsewhere = (id) => {
140
+ const claim = claims.get(id);
141
+ return claim !== void 0 && claim.by !== claimant && now() - claim.at < claimLeaseMs;
142
+ };
143
+ const settledFor = (id, listing) => {
144
+ if (!unsettled.has(id)) return true;
145
+ const settledAt = unsettled.get(id);
146
+ return settledAt !== void 0 && listing > settledAt;
147
+ };
148
+ const writePending = (id) => unsettled.has(id) && unsettled.get(id) === void 0;
149
+ const markUnsettled = (id, write) => {
150
+ unsettled.set(id, void 0);
151
+ const settle = () => {
152
+ if (!unsettled.has(id)) return;
153
+ unsettled.set(id, listingsStarted);
154
+ evaluate();
155
+ };
156
+ void write.then(settle, settle);
157
+ };
158
+ const rowState = (entry, line) => {
159
+ const phase = phaseOf(entry.id);
160
+ if (phase.kind === "failed") {
161
+ return { kind: "failed", reason: phase.reason, message: chatOutboxFailureMessage(phase.reason) };
162
+ }
163
+ if (isBusy(phase) || claimedElsewhere(entry.id)) return { kind: "sending" };
164
+ if (countdown !== null && line.run.some((candidate) => candidate.id === entry.id)) {
165
+ return { kind: "countdown", endsAt: countdown.endsAt };
166
+ }
167
+ if (line.askId === entry.id) return { kind: "ask" };
168
+ return { kind: "waiting" };
169
+ };
170
+ const computeLine = () => {
171
+ const run = [];
172
+ for (const entry of entries) {
173
+ const phase = phaseOf(entry.id);
174
+ if (phase.kind === "failed") continue;
175
+ if (isBusy(phase) || claimedElsewhere(entry.id)) continue;
176
+ if (handedInRegain.get(entry.id) === regain && !sendNow.has(entry.id)) continue;
177
+ if (!sendNow.has(entry.id) && now() - entry.queuedAt > askAfterMs) {
178
+ return { run, askId: run.length === 0 ? entry.id : null };
179
+ }
180
+ run.push(entry);
181
+ }
182
+ return { run, askId: null };
183
+ };
184
+ const gateOpen = () => reachability.get() && foreground.get();
185
+ const publish = () => {
186
+ const line = gateOpen() ? computeLine() : { run: [], askId: null };
187
+ const next = {
188
+ rows: entries.map((entry) => ({ entry, state: rowState(entry, line) })),
189
+ countdownEndsAt: (countdown == null ? void 0 : countdown.endsAt) ?? null,
190
+ durable: entries.every((entry) => persisted.has(entry.id)),
191
+ loaded,
192
+ elsewhere
193
+ };
194
+ if (sameChatOutboxSnapshot(snapshot, next)) return;
195
+ snapshot = next;
196
+ for (const listener of listeners) {
197
+ try {
198
+ listener();
199
+ } catch {
200
+ }
201
+ }
202
+ };
203
+ const stopCountdown = () => {
204
+ countdown == null ? void 0 : countdown.cancel();
205
+ countdown = null;
206
+ };
207
+ const dropEntry = (id) => {
208
+ entries = entries.filter((entry) => entry.id !== id);
209
+ unsettled.delete(id);
210
+ phases.delete(id);
211
+ readyToGo.delete(id);
212
+ sendNow.delete(id);
213
+ persisted.delete(id);
214
+ claims.delete(id);
215
+ asked.delete(id);
216
+ if (countdown == null ? void 0 : countdown.ids.includes(id)) stopCountdown();
217
+ };
218
+ const letGo = (id, event) => {
219
+ if (!entries.some((entry) => entry.id === id)) return;
220
+ dropEntry(id);
221
+ emit(event);
222
+ if (store) void store.remove(threadId, id).catch(() => void 0);
223
+ };
224
+ const fail = (id, reason) => {
225
+ phases.set(id, { kind: "failed", reason });
226
+ sendNow.delete(id);
227
+ emit({ type: "failed", threadId, messageId: id, message: chatOutboxFailureMessage(reason), reason });
228
+ if (store) {
229
+ void store.markFailed({ threadId, id, claimant, failure: { reason, at: now() } }).catch(() => void 0);
230
+ }
231
+ };
232
+ const releaseClaim = (id) => {
233
+ if (store) void store.release({ threadId, id, claimant }).catch(() => void 0);
234
+ };
235
+ const handOff = (entry, auto) => {
236
+ if (thread.heldIds().has(entry.id)) {
237
+ letGo(entry.id, { type: "adopted", threadId, messageId: entry.id });
238
+ return;
239
+ }
240
+ const readiness = thread.readiness();
241
+ if (readiness === "refused") {
242
+ fail(entry.id, "refused");
243
+ return;
244
+ }
245
+ if (readiness === "connecting") {
246
+ phases.set(entry.id, { kind: "awaiting-thread" });
247
+ return;
248
+ }
249
+ if (writePending(entry.id)) {
250
+ phases.set(entry.id, { kind: "awaiting-thread" });
251
+ return;
252
+ }
253
+ sendNow.delete(entry.id);
254
+ phases.set(entry.id, { kind: "claiming" });
255
+ const claim = store ? store.claim({ threadId, id: entry.id, claimant, now: now(), leaseMs: claimLeaseMs }) : Promise.resolve("claimed");
256
+ void claim.then(
257
+ (result) => {
258
+ if (disposed || phaseOf(entry.id).kind !== "claiming") return;
259
+ if (result === "gone") {
260
+ dropEntry(entry.id);
261
+ evaluate();
262
+ return;
263
+ }
264
+ if (result === "taken") {
265
+ phases.set(entry.id, { kind: "idle" });
266
+ claims.set(entry.id, { by: "elsewhere", at: now() });
267
+ evaluate();
268
+ return;
269
+ }
270
+ if (!stillGoes(entry)) return;
271
+ checkThenDispatch(entry, auto);
272
+ },
273
+ () => {
274
+ if (disposed || phaseOf(entry.id).kind !== "claiming") return;
275
+ fail(entry.id, "prepare");
276
+ evaluate();
277
+ }
278
+ );
279
+ };
280
+ const stillGoes = (entry) => {
281
+ if (thread.heldIds().has(entry.id)) {
282
+ letGo(entry.id, { type: "adopted", threadId, messageId: entry.id });
283
+ evaluate();
284
+ return false;
285
+ }
286
+ const ready = thread.readiness();
287
+ if (ready === "refused") {
288
+ fail(entry.id, "refused");
289
+ evaluate();
290
+ return false;
291
+ }
292
+ if (!gateOpen() || ready !== "ready") {
293
+ phases.set(entry.id, gateOpen() ? { kind: "awaiting-thread" } : { kind: "idle" });
294
+ releaseClaim(entry.id);
295
+ evaluate();
296
+ return false;
297
+ }
298
+ return true;
299
+ };
300
+ const checkThenDispatch = (entry, auto) => {
301
+ const attachments = entry.attachments ?? [];
302
+ if (attachments.length === 0 || !checkAttachments) {
303
+ readyToGo.set(entry.id, auto);
304
+ releaseReady();
305
+ return;
306
+ }
307
+ let answered = false;
308
+ let stopTimer = () => void 0;
309
+ const answer = (verdict) => {
310
+ if (answered) return;
311
+ answered = true;
312
+ stopTimer();
313
+ checkTimers.delete(stopTimer);
314
+ if (disposed || phaseOf(entry.id).kind !== "claiming") return;
315
+ if (!stillGoes(entry)) return;
316
+ if (verdict === "ok") {
317
+ readyToGo.set(entry.id, auto);
318
+ releaseReady();
319
+ return;
320
+ }
321
+ fail(entry.id, verdict === "refused" ? "attachment" : "error");
322
+ evaluate();
323
+ };
324
+ stopTimer = setTimer(() => answer("unknown"), attachmentCheckTimeoutMs);
325
+ checkTimers.add(stopTimer);
326
+ let checking;
327
+ try {
328
+ checking = checkAttachments(attachments);
329
+ } catch (error) {
330
+ checking = Promise.reject(error);
331
+ }
332
+ void checking.then(answer, () => answer("unknown"));
333
+ };
334
+ function releaseReady() {
335
+ if (releasing || disposed) return;
336
+ releasing = true;
337
+ try {
338
+ for (const entry of [...entries]) {
339
+ if (phaseOf(entry.id).kind !== "claiming") continue;
340
+ const auto = readyToGo.get(entry.id);
341
+ if (auto === void 0) return;
342
+ readyToGo.delete(entry.id);
343
+ if (stillGoes(entry)) dispatch(entry, auto);
344
+ }
345
+ } finally {
346
+ releasing = false;
347
+ }
348
+ }
349
+ const dispatch = (entry, auto) => {
350
+ handedInRegain.set(entry.id, regain);
351
+ phases.set(entry.id, { kind: "handed", journaled: false });
352
+ emit({ type: "handed", threadId, messageId: entry.id, auto, ageMs: now() - entry.queuedAt });
353
+ let sent;
354
+ try {
355
+ sent = thread.send(entry);
356
+ } catch (error) {
357
+ sent = Promise.reject(error);
358
+ }
359
+ void sent.then(
360
+ () => {
361
+ if (disposed) return;
362
+ letGo(entry.id, { type: "delivered", threadId, messageId: entry.id, status: "accepted" });
363
+ evaluate();
364
+ },
365
+ (error) => {
366
+ if (disposed) return;
367
+ const phase = phaseOf(entry.id);
368
+ if (phase.kind === "handed" && phase.journaled) return;
369
+ if (phase.kind !== "handed") return;
370
+ const failure = failureOf(error);
371
+ if (failure.cause !== void 0 && AWAY_CAUSES.has(failure.cause)) {
372
+ phases.set(entry.id, { kind: "idle" });
373
+ handedInRegain.delete(entry.id);
374
+ releaseClaim(entry.id);
375
+ evaluate();
376
+ return;
377
+ }
378
+ fail(entry.id, "error");
379
+ evaluate();
380
+ }
381
+ );
382
+ };
383
+ const startCountdown = (run) => {
384
+ stopCountdown();
385
+ const ids = run.map((entry) => entry.id);
386
+ const endsAt = now() + countdownMs;
387
+ const cancel = setTimer(() => {
388
+ if (disposed || (countdown == null ? void 0 : countdown.endsAt) !== endsAt) return;
389
+ countdown = null;
390
+ if (!gateOpen()) {
391
+ evaluate();
392
+ return;
393
+ }
394
+ for (const id of ids) {
395
+ const entry = entries.find((candidate) => candidate.id === id);
396
+ if (!entry) continue;
397
+ const phase = phaseOf(id);
398
+ if (phase.kind !== "idle" || claimedElsewhere(id)) continue;
399
+ handOff(entry, true);
400
+ }
401
+ evaluate();
402
+ }, countdownMs);
403
+ countdown = { endsAt, ids, cancel };
404
+ emit({ type: "countdown-started", threadId, count: ids.length });
405
+ };
406
+ const scheduleLeaseCheck = () => {
407
+ leaseTimer == null ? void 0 : leaseTimer();
408
+ leaseTimer = null;
409
+ let soonest = Number.POSITIVE_INFINITY;
410
+ for (const [id, claim] of claims) {
411
+ if (claim.by === claimant || !entries.some((entry) => entry.id === id)) continue;
412
+ const expires = claim.at + claimLeaseMs - now();
413
+ if (expires > 0) soonest = Math.min(soonest, expires);
414
+ }
415
+ if (Number.isFinite(soonest)) leaseTimer = setTimer(() => evaluate(), soonest + 1);
416
+ };
417
+ function evaluate() {
418
+ evaluateLine();
419
+ releaseReady();
420
+ }
421
+ function evaluateLine() {
422
+ if (disposed) return;
423
+ const reachable = reachability.get();
424
+ if (reachable && !wasReachable) regain += 1;
425
+ wasReachable = reachable;
426
+ if (loaded) {
427
+ const held = thread.heldIds();
428
+ for (const entry of [...entries]) {
429
+ const phase = phaseOf(entry.id);
430
+ if (phase.kind === "handed") {
431
+ if (held.has(entry.id)) phases.set(entry.id, { kind: "handed", journaled: true });
432
+ continue;
433
+ }
434
+ if (phase.kind === "claiming") continue;
435
+ if (held.has(entry.id)) letGo(entry.id, { type: "adopted", threadId, messageId: entry.id });
436
+ }
437
+ if (!gateOpen()) {
438
+ for (const entry of entries) {
439
+ if (phaseOf(entry.id).kind === "awaiting-thread") phases.set(entry.id, { kind: "idle" });
440
+ }
441
+ } else if (thread.readiness() !== "connecting") {
442
+ for (const entry of entries) {
443
+ if (phaseOf(entry.id).kind === "awaiting-thread") {
444
+ phases.set(entry.id, { kind: "idle" });
445
+ handOff(entry, true);
446
+ }
447
+ }
448
+ }
449
+ }
450
+ if (!loaded || !gateOpen()) {
451
+ stopCountdown();
452
+ publish();
453
+ return;
454
+ }
455
+ const line = computeLine();
456
+ if (line.askId !== null && !asked.has(line.askId)) {
457
+ asked.add(line.askId);
458
+ const entry = entries.find((candidate) => candidate.id === line.askId);
459
+ if (entry) emit({ type: "asked", threadId, messageId: entry.id, ageMs: now() - entry.queuedAt });
460
+ }
461
+ const immediate = [];
462
+ for (const entry of line.run) {
463
+ if (!sendNow.has(entry.id)) break;
464
+ immediate.push(entry);
465
+ }
466
+ for (const entry of immediate) handOff(entry, false);
467
+ const run = line.run.slice(immediate.length).filter((entry) => !sendNow.has(entry.id));
468
+ if (run.length === 0) {
469
+ stopCountdown();
470
+ } else if (countdown === null || countdown.ids.length !== run.length || run.some((entry, index) => (countdown == null ? void 0 : countdown.ids[index]) !== entry.id)) {
471
+ startCountdown(run);
472
+ }
473
+ scheduleLeaseCheck();
474
+ publish();
475
+ }
476
+ const applyRecords = (records, listing) => {
477
+ const mine = records.filter((record) => record.entry.threadId === threadId);
478
+ const stored = new Map(mine.map((record) => [record.entry.id, record]));
479
+ claims = new Map(
480
+ mine.flatMap((record) => record.claim ? [[record.entry.id, record.claim]] : [])
481
+ );
482
+ for (const record of mine) {
483
+ if (!settledFor(record.entry.id, listing)) continue;
484
+ if (record.memoryOnly) persisted.delete(record.entry.id);
485
+ else persisted.add(record.entry.id);
486
+ const phase = phaseOf(record.entry.id);
487
+ if (record.failure && phase.kind !== "failed" && !isBusy(phase)) {
488
+ phases.set(record.entry.id, { kind: "failed", reason: record.failure.reason });
489
+ }
490
+ }
491
+ const kept = entries.filter(
492
+ (entry) => stored.has(entry.id) || !settledFor(entry.id, listing) || isBusy(phaseOf(entry.id))
493
+ );
494
+ for (const entry of entries) {
495
+ if (kept.includes(entry)) continue;
496
+ if (countdown == null ? void 0 : countdown.ids.includes(entry.id)) stopCountdown();
497
+ phases.delete(entry.id);
498
+ persisted.delete(entry.id);
499
+ sendNow.delete(entry.id);
500
+ }
501
+ const known = new Set(kept.map((entry) => entry.id));
502
+ const added = mine.filter((record) => !known.has(record.entry.id)).map((record) => record.entry);
503
+ entries = [...kept, ...added].sort((a, b) => a.queuedAt - b.queuedAt);
504
+ for (const [id, settledAt] of unsettled) {
505
+ if (settledAt !== void 0 && listing > settledAt) unsettled.delete(id);
506
+ }
507
+ const byThread = /* @__PURE__ */ new Map();
508
+ for (const record of records) {
509
+ if (record.entry.threadId === threadId) continue;
510
+ const current = byThread.get(record.entry.threadId);
511
+ if (current) {
512
+ current.count += 1;
513
+ current.newChat && (current.newChat = record.entry.newChat);
514
+ } else {
515
+ byThread.set(record.entry.threadId, {
516
+ count: 1,
517
+ first: record.entry,
518
+ newChat: record.entry.newChat
519
+ });
520
+ }
521
+ }
522
+ elsewhere = [...byThread].map(([otherThreadId, other]) => ({ threadId: otherThreadId, ...other })).sort((a, b) => a.first.queuedAt - b.first.queuedAt);
523
+ };
524
+ let reading = null;
525
+ let readAgain = false;
526
+ const reload = () => {
527
+ if (!store || disposed) return;
528
+ if (reading) {
529
+ readAgain = true;
530
+ return;
531
+ }
532
+ listingsStarted += 1;
533
+ const listing = listingsStarted;
534
+ reading = store.listAll().then(
535
+ (records) => {
536
+ if (disposed) return;
537
+ applyRecords(records, listing);
538
+ loaded = true;
539
+ },
540
+ () => {
541
+ loaded = true;
542
+ }
543
+ ).finally(() => {
544
+ reading = null;
545
+ if (disposed) return;
546
+ evaluate();
547
+ if (readAgain) {
548
+ readAgain = false;
549
+ reload();
550
+ }
551
+ });
552
+ };
553
+ const unsubscribers = [
554
+ reachability.subscribe(evaluate),
555
+ foreground.subscribe(evaluate),
556
+ thread.subscribe(evaluate),
557
+ ...store ? [store.subscribe(reload)] : []
558
+ ];
559
+ reload();
560
+ publish();
561
+ return {
562
+ threadId,
563
+ reachability,
564
+ getSnapshot: () => snapshot,
565
+ subscribe(listener) {
566
+ listeners.add(listener);
567
+ return () => {
568
+ listeners.delete(listener);
569
+ };
570
+ },
571
+ shouldHold() {
572
+ if (!reachability.get()) return true;
573
+ if (!loaded) return true;
574
+ return entries.some((entry) => {
575
+ const phase = phaseOf(entry.id);
576
+ return phase.kind !== "failed" && !(phase.kind === "handed" && phase.journaled);
577
+ });
578
+ },
579
+ hold(input) {
580
+ const entry = {
581
+ id: newMessageId(),
582
+ threadId,
583
+ text: input.text,
584
+ queuedAt: now(),
585
+ newChat: typeof isNewChat === "function" ? isNewChat() : isNewChat,
586
+ ...input.composerMarkdown !== void 0 && { composerMarkdown: input.composerMarkdown },
587
+ ...input.composerHtml !== void 0 && { composerHtml: input.composerHtml },
588
+ ...input.metadata !== void 0 && { metadata: input.metadata },
589
+ ...input.files !== void 0 && input.files.length > 0 && { files: input.files },
590
+ ...input.attachments !== void 0 && input.attachments.length > 0 && { attachments: input.attachments }
591
+ };
592
+ if (!loaded && gateOpen()) sendNow.add(entry.id);
593
+ entries = [...entries, entry];
594
+ if (store) {
595
+ persisted.add(entry.id);
596
+ const write = store.put(entry);
597
+ markUnsettled(entry.id, write);
598
+ void write.then(
599
+ (kept) => {
600
+ if (!kept) persisted.delete(entry.id);
601
+ emit({ type: "held", threadId, messageId: entry.id, durable: kept });
602
+ publish();
603
+ },
604
+ () => {
605
+ persisted.delete(entry.id);
606
+ emit({ type: "held", threadId, messageId: entry.id, durable: false });
607
+ publish();
608
+ }
609
+ );
610
+ } else {
611
+ emit({ type: "held", threadId, messageId: entry.id, durable: false });
612
+ }
613
+ evaluate();
614
+ return entry;
615
+ },
616
+ cancel(id) {
617
+ const entry = entries.find((candidate) => candidate.id === id);
618
+ if (!entry || isBusy(phaseOf(id))) return;
619
+ dropEntry(id);
620
+ emit({ type: "cancelled", threadId, messageId: id });
621
+ if (store) void store.remove(threadId, id).catch(() => void 0);
622
+ try {
623
+ restore(entry);
624
+ } finally {
625
+ evaluate();
626
+ }
627
+ },
628
+ send(id) {
629
+ const entry = entries.find((candidate) => candidate.id === id);
630
+ if (!entry || isBusy(phaseOf(id))) return;
631
+ const wasFailed = phaseOf(id).kind === "failed";
632
+ phases.set(id, { kind: "idle" });
633
+ handedInRegain.delete(id);
634
+ sendNow.add(id);
635
+ if (wasFailed && store) {
636
+ const write = store.clearFailure({ threadId, id });
637
+ markUnsettled(id, write);
638
+ void write.catch(() => void 0);
639
+ }
640
+ evaluate();
641
+ },
642
+ discard(id) {
643
+ const entry = entries.find((candidate) => candidate.id === id);
644
+ if (!entry || isBusy(phaseOf(id))) return;
645
+ dropEntry(id);
646
+ emit({ type: "discarded", threadId, messageId: id });
647
+ if (store) void store.remove(threadId, id).catch(() => void 0);
648
+ evaluate();
649
+ },
650
+ observeCommand(update) {
651
+ if (disposed) return;
652
+ const id = chatOutboxCommandMessageId(update.params);
653
+ if (id === null) return;
654
+ const phase = phaseOf(id);
655
+ if (phase.kind === "handed") {
656
+ if (update.status === "queued") {
657
+ phases.set(id, { kind: "handed", journaled: true });
658
+ return;
659
+ }
660
+ letGo(id, { type: "delivered", threadId, messageId: id, status: update.status });
661
+ evaluate();
662
+ return;
663
+ }
664
+ if (entries.some((entry) => entry.id === id)) evaluate();
665
+ },
666
+ openThread: openThread ?? null,
667
+ dispose() {
668
+ if (disposed) return;
669
+ disposed = true;
670
+ stopCountdown();
671
+ leaseTimer == null ? void 0 : leaseTimer();
672
+ for (const stop of checkTimers) stop();
673
+ checkTimers.clear();
674
+ readyToGo.clear();
675
+ for (const unsubscribe of unsubscribers) unsubscribe();
676
+ listeners.clear();
677
+ if (store) {
678
+ for (const [id, phase] of phases) {
679
+ if (phase.kind === "claiming") releaseClaim(id);
680
+ }
681
+ }
682
+ }
683
+ };
684
+ }
685
+ exports.CHAT_EDIT_KEPT_MESSAGE = CHAT_EDIT_KEPT_MESSAGE;
686
+ exports.CHAT_EDIT_UNREACHABLE_LABEL = CHAT_EDIT_UNREACHABLE_LABEL;
687
+ exports.CHAT_OUTBOX_ASK_AFTER_MS = CHAT_OUTBOX_ASK_AFTER_MS;
688
+ exports.CHAT_OUTBOX_ATTACHMENT_CHECK_TIMEOUT_MS = CHAT_OUTBOX_ATTACHMENT_CHECK_TIMEOUT_MS;
689
+ exports.CHAT_OUTBOX_CLAIM_LEASE_MS = CHAT_OUTBOX_CLAIM_LEASE_MS;
690
+ exports.CHAT_OUTBOX_COUNTDOWN_MS = CHAT_OUTBOX_COUNTDOWN_MS;
691
+ exports.ChatEditUnreachableError = ChatEditUnreachableError;
692
+ exports.chatOutboxCommandMessageId = chatOutboxCommandMessageId;
693
+ exports.chatOutboxFailureMessage = chatOutboxFailureMessage;
694
+ exports.createChatOutbox = createChatOutbox;
695
+ exports.sameChatOutboxSnapshot = sameChatOutboxSnapshot;
696
+ //# sourceMappingURL=chat-outbox.cjs.map