@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,76 @@
1
+ import type { DeepAgentMessageWindowDeclaration } from "./message-window";
2
+ import { type DeepAgentHeadersResolver, type DeepAgentWakeFetch } from "./deep-agent-transport-recipe";
3
+ import { type AttachRetryGate, type DeepAgentAttachTimingEvent } from "./statewire-attach-observer";
4
+ import { type DeepAgentPrewarmTransportFactory, type DeepAgentThreadPrewarmPool, type DeepAgentThreadPrewarmPoolOptions } from "./thread-prewarm";
5
+ /** What signalled the intent to open the thread. */
6
+ export type DeepAgentPrewarmReason = "hover" | "pointerdown" | "click" | "route";
7
+ export interface DeepAgentThreadPrewarmControllerOptions<TState> {
8
+ /** Base URL of the deep-agent statewire host (the `…/v2/threads` mount). */
9
+ baseUrl: string;
10
+ /** The mounted thread's auth resolver — a pooled attach must be the attach the thread would open. */
11
+ headers: DeepAgentHeadersResolver;
12
+ /** The mounted thread's head window declaration (`useDeepAgentThread({ messageWindow })`); the pooled dial must ask for the same shape. */
13
+ messageWindow?: DeepAgentMessageWindowDeclaration | undefined;
14
+ /** The mounted thread's lane paging (`useDeepAgentThread({ laneHistory })`); the pooled dial and the wake must declare the same contract version. */
15
+ laneHistory?: boolean | undefined;
16
+ /** SSE when true, WebSocket otherwise; match the mounted thread. */
17
+ sse?: boolean;
18
+ /** Attach timing + retry hints for both the wake and the pooled dials. */
19
+ onAttachTiming?: (input: {
20
+ threadId: string;
21
+ event: DeepAgentAttachTimingEvent;
22
+ }) => void;
23
+ /** A pooled hello landed (hosts with a snapshot cache remember it here). */
24
+ onState?: DeepAgentThreadPrewarmPoolOptions<TState>["onState"];
25
+ onDiscard?: DeepAgentThreadPrewarmPoolOptions<TState>["onDiscard"];
26
+ /** Pool sizing; defaults are the pool's own. */
27
+ pool?: Pick<DeepAgentThreadPrewarmPoolOptions<TState>, "maxEntries" | "graceMs" | "ttlMs">;
28
+ /** One wake per thread per window: the route is idempotent, a flickering hover must not hammer it. */
29
+ wakeDedupeMs?: number;
30
+ maxWakeRecords?: number;
31
+ /** Test seams. */
32
+ fetch?: DeepAgentWakeFetch;
33
+ retryGate?: AttachRetryGate;
34
+ createTransport?: DeepAgentPrewarmTransportFactory<TState>;
35
+ now?: () => number;
36
+ }
37
+ export interface DeepAgentThreadPrewarmController<TState> {
38
+ /** Hand this to `useDeepAgentThread` / `useDeepAgentRuntime` as `prewarmPool`. */
39
+ readonly pool: DeepAgentThreadPrewarmPool<TState>;
40
+ /**
41
+ * Warm a thread the user is about to open. Every intent wakes the server
42
+ * instance (`POST …/prewarm`, deduped); only a hover dwell also dials a
43
+ * pooled attach — a pointer-down or click is followed by the thread's own
44
+ * attach within a frame or two, and a pooled dial started then is disposed
45
+ * before its handshake completes. Returns whether a pooled dial started.
46
+ */
47
+ prewarm(threadId: string, input: {
48
+ reason: DeepAgentPrewarmReason;
49
+ }): boolean;
50
+ /** The intent lapsed (pointer left the row): keep the dial warm for the grace window. */
51
+ release(threadId: string): void;
52
+ /** Whether a switch to `threadId` can seed its first frame from a pooled hello. */
53
+ isWarm(threadId: string): boolean;
54
+ /** Logout / identity change: drop every pooled dial and wake record. */
55
+ clear(): void;
56
+ }
57
+ /**
58
+ * The host-agnostic half of a surface's thread prewarm: the wake-then-dial
59
+ * policy Olympus runs from its sidebar, over the shared attach recipe, so a
60
+ * conversation list in any surface warms a thread the same way. A host binds
61
+ * one controller per (statewire host, principal) and clears it when either
62
+ * changes: a pooled attach dials with that principal's token.
63
+ *
64
+ * The wake's `Retry-After` (503/429) lands in the retry gate keyed by the
65
+ * thread URL, and the attach recipe waits that floor out before it dials —
66
+ * both the pooled attach and the thread's own attach after the click honour
67
+ * the server's hint without any host code. The one dial that can race the
68
+ * hint is the hover's own speculative attach, started alongside the wake; a
69
+ * floor that arrives while it is still handshaking discards it.
70
+ */
71
+ export declare function createDeepAgentThreadPrewarmController<TState>({ baseUrl, headers, messageWindow, laneHistory, sse, onAttachTiming, onState, onDiscard, pool: poolOptions, wakeDedupeMs, maxWakeRecords, fetch: fetchOverride, retryGate, createTransport, now, }: DeepAgentThreadPrewarmControllerOptions<TState>): DeepAgentThreadPrewarmController<TState>;
72
+ /** The retry-gate key the wake and the attach share for a thread. */
73
+ export declare function deepAgentPrewarmGateKey({ baseUrl, threadId, }: {
74
+ baseUrl: string;
75
+ threadId: string;
76
+ }): string;
@@ -0,0 +1,118 @@
1
+ import { type ResourceElement } from '@assistant-ui/tap';
2
+ import type { Statewire } from 'statewire';
3
+ /**
4
+ * Pre-dialed statewire attaches for threads the user is ABOUT to open.
5
+ *
6
+ * A thread switch today starts its network work only after React has torn
7
+ * down the previous thread and mounted the new one — the attach (socket open
8
+ * + server authorize + history load + hello) queues behind the heaviest part
9
+ * of the switch. The pool moves that attach ahead of the click: on sidebar
10
+ * hover (dwell-gated) or pointer-down the host asks the pool to `prewarm` a
11
+ * thread, and the pool mounts the thread's transport in a standalone tap root
12
+ * — built by the same recipe the thread uses — so it dials immediately. The
13
+ * server does its expensive work (authorize, `_load_history`, the hello) while
14
+ * the pointer is still on the row, and the instance it activates stays warm
15
+ * for the click.
16
+ *
17
+ * A pooled attach rides a process-local session lane, never the thread's
18
+ * persisted one: a persisted lane is single-consumer per tab (its Web Lock
19
+ * serializes every session mounted on it), and a pooled root sharing the
20
+ * lane with the thread's own session stalled the thread's dial behind the
21
+ * held lock and livelocked its teardown. The pool never hands its client over,
22
+ * so it has no use for the lane.
23
+ *
24
+ * Warm-and-seed, not a live handoff: when the thread mounts it `take`s the
25
+ * pooled hello as its seed — its first frame is the transcript, with no
26
+ * loading treatment — and dials its OWN attach against the now-warm instance;
27
+ * the pooled root is disposed in the same step, so one socket is live per
28
+ * thread after mount. A statewire session is a single-consumer object: handing
29
+ * a root one tap tree mounted to another tree's client left the client's
30
+ * change feed unreliable, and the outgoing thread's teardown redialed the
31
+ * shared root in a tight loop — so the pool never shares a live root.
32
+ *
33
+ * A take that arrives BEFORE the pooled hello does not close the socket. The
34
+ * server is still mid-`authorize`/activation on it, and pinned treats a client
35
+ * that leaves before it is served as grounds to discard the half-built
36
+ * instance record (`LocalDirectory.discard_unserved`) — with the wake and the
37
+ * thread's own attach still resolving on that same record, both then bounce
38
+ * off "instance closing; retry" (a 503 on the wake, a 1011 close on the
39
+ * attach) and the click pays a statewire backoff plus a cold re-activation
40
+ * instead of the warm instance the hover paid for (staging, 2026-09-04: every
41
+ * hover the pointer clicked through within a few hundred ms did this). The
42
+ * taken dial is kept as an orphan until its hello lands — remembered through
43
+ * `onState`, then disposed — or the grace window passes. `has` / `hasState` /
44
+ * `take` no longer see it, but it is still a live socket: it counts toward
45
+ * `maxEntries` (the oldest live root evicts first, orphan or not), and a
46
+ * renewed `prewarm` for the same thread re-adopts it instead of dialing a
47
+ * second socket.
48
+ *
49
+ * Bounds: at most `maxEntries` live roots (oldest evicts), each released
50
+ * entry disposed after `graceMs`, every entry disposed after `ttlMs`. A root
51
+ * that is refused (`gone`, or an `unauthorized` retry) or whose dial fails is
52
+ * discarded at once so the pool never retries a denial or a dead server the
53
+ * thread's own attach handles (and parks) with its full policy. Nothing here
54
+ * decides *what* to prewarm — hosts gate on their own rules (never the active
55
+ * thread, never a new chat, never under a view-as lens).
56
+ */
57
+ type TransportValue<TState> = Statewire<TState | undefined>;
58
+ type TransportElement<TState> = ResourceElement<TransportValue<TState>>;
59
+ /** Builds the thread's transport element — once per prewarm. The transport must
60
+ * leave its session process-local (no `sessionStore`; see the module notes). */
61
+ export type DeepAgentPrewarmTransportFactory<TState> = (input: {
62
+ threadId: string;
63
+ }) => TransportElement<TState>;
64
+ export type DeepAgentPrewarmDiscardReason = 'released' | 'expired' | 'evicted' | 'refused' | 'failed' | 'taken' | 'cleared' | 'discarded';
65
+ export interface DeepAgentThreadPrewarmPoolOptions<TState> {
66
+ createTransport: DeepAgentPrewarmTransportFactory<TState>;
67
+ /** Live roots retained; the oldest evicts beyond this. */
68
+ maxEntries?: number;
69
+ /** How long a released (hover-left) entry stays warm before disposal. */
70
+ graceMs?: number;
71
+ /** Hard lifetime of any entry since its prewarm. */
72
+ ttlMs?: number;
73
+ /** The hello landed on a pooled root (state is the live wire state). */
74
+ onState?: (input: {
75
+ threadId: string;
76
+ state: TState;
77
+ }) => void;
78
+ onDiscard?: (input: {
79
+ threadId: string;
80
+ reason: DeepAgentPrewarmDiscardReason;
81
+ }) => void;
82
+ now?: () => number;
83
+ }
84
+ /** What a mounting thread takes from the pool: the hello, if it landed. */
85
+ export interface PrewarmedDeepAgentHello<TState> {
86
+ threadId: string;
87
+ /** The wire state the pooled attach replicated, or `undefined` before the hello. */
88
+ state: TState | undefined;
89
+ /** Whether the pooled attach had reached `connected` when taken. */
90
+ connected: boolean;
91
+ /** `now()` at prewarm — when the dial started. */
92
+ dialedAt: number;
93
+ }
94
+ export interface DeepAgentThreadPrewarmPool<TState> {
95
+ /** Start (or refresh) a warm root for the thread. Returns `true` when a dial was started. */
96
+ prewarm(threadId: string): boolean;
97
+ /** The intent lapsed (hover left): keep the root warm for `graceMs`, then dispose. */
98
+ release(threadId: string): void;
99
+ has(threadId: string): boolean;
100
+ /** The root has replicated a hello. */
101
+ hasState(threadId: string): boolean;
102
+ /**
103
+ * Hand the pooled hello to the mounting thread and dispose the root (its
104
+ * socket closes): the thread seeds its first frame from the state and dials
105
+ * its own attach against the instance the pool warmed. Before the hello the
106
+ * dial stays up alongside the thread's own attach until it lands (or the
107
+ * grace window passes) — see the module notes — and the entry leaves the
108
+ * pool's view either way (`has` is false, a second take is `null`) while
109
+ * still counting toward `maxEntries`.
110
+ */
111
+ take(threadId: string): PrewarmedDeepAgentHello<TState> | null;
112
+ /** Dispose one entry immediately (e.g. the thread attaches on its own terms). */
113
+ discard(threadId: string): void;
114
+ clear(): void;
115
+ readonly size: number;
116
+ }
117
+ export declare function createDeepAgentThreadPrewarmPool<TState>({ createTransport, maxEntries, graceMs, ttlMs, onState, onDiscard, now, }: DeepAgentThreadPrewarmPoolOptions<TState>): DeepAgentThreadPrewarmPool<TState>;
118
+ export {};
@@ -0,0 +1,99 @@
1
+ import type { DeepAgentStreamValues } from './types';
2
+ /**
3
+ * Per-tab LRU of the last wire state seen per thread, so a switch back to a
4
+ * recently-visited thread can mount with that snapshot instead of an empty
5
+ * "loading" state (see `UseDeepAgentThreadOptions.snapshotCache`). Entries are
6
+ * references into states the wire already produced — remembering is O(1) and
7
+ * copies nothing; the bound is `maxThreads` retained states.
8
+ */
9
+ export interface DeepAgentThreadSnapshotCache {
10
+ /** Record the latest hydrated wire state for a thread. */
11
+ remember(threadId: string, state: DeepAgentStreamValues): void;
12
+ /** The freshest remembered state for a thread, or `undefined` when none is
13
+ * held or the entry aged out. */
14
+ take(threadId: string): DeepAgentStreamValues | undefined;
15
+ /**
16
+ * Drop a single thread's entry. Called when the server refuses
17
+ * authorization for the thread — a refused thread must not warm-paint on
18
+ * its next mount.
19
+ */
20
+ forget(threadId: string): void;
21
+ /**
22
+ * Drop every entry. Called when the acting identity changes — a snapshot
23
+ * captured under one account must never seed a mount under another.
24
+ */
25
+ clear(): void;
26
+ /**
27
+ * Whether a fresh entry is held for the thread, without consuming or
28
+ * touching it. Hosts read it at selection time to decide whether the switch
29
+ * can paint from a seed (no loading treatment) or must cover the attach
30
+ * wait. Optional so hand-rolled caches keep type-checking; the built-in
31
+ * cache implements it.
32
+ */
33
+ peek?(threadId: string): boolean;
34
+ }
35
+ /** A write observed on the cache — the durable-mirror seam (see `onChange`). */
36
+ export type DeepAgentThreadSnapshotCacheChange = {
37
+ type: 'remember';
38
+ threadId: string;
39
+ state: DeepAgentStreamValues;
40
+ at: number;
41
+ } | {
42
+ type: 'forget';
43
+ threadId: string;
44
+ } | {
45
+ type: 'clear';
46
+ };
47
+ export interface DeepAgentThreadSnapshotCacheOptions {
48
+ /** Threads retained; the least-recently written entry evicts beyond this. */
49
+ maxThreads?: number;
50
+ /**
51
+ * Entries older than this are dropped at read time. The seed's value is
52
+ * "the thread you just left" — a snapshot from long ago is more likely to
53
+ * flash content the server has since rewritten than to save a paint.
54
+ */
55
+ maxAgeMs?: number;
56
+ /**
57
+ * Observer of every write (`remember`, `forget`, `clear`). Hosts mirror
58
+ * entries into durable storage from here so a reload can seed too; the
59
+ * observer is never invoked for `restore`, which re-admits mirrored entries.
60
+ * Exceptions are swallowed — a mirror fault must not break the wire path.
61
+ */
62
+ onChange?: (change: DeepAgentThreadSnapshotCacheChange) => void;
63
+ /** Injectable clock (tests). */
64
+ now?: () => number;
65
+ }
66
+ /** The built-in cache: the host contract plus the durable-mirror re-admission. */
67
+ export interface CreatedDeepAgentThreadSnapshotCache extends DeepAgentThreadSnapshotCache {
68
+ peek(threadId: string): boolean;
69
+ /**
70
+ * Re-admit an entry captured earlier — a mirrored snapshot after a reload —
71
+ * under its ORIGINAL capture time, so the age bound still applies. Never
72
+ * displaces a fresher in-memory entry and never notifies `onChange`.
73
+ */
74
+ restore(threadId: string, state: DeepAgentStreamValues, at: number): void;
75
+ }
76
+ export declare function createDeepAgentThreadSnapshotCache(options?: DeepAgentThreadSnapshotCacheOptions): CreatedDeepAgentThreadSnapshotCache;
77
+ /**
78
+ * Shape a remembered wire state for use as a mount's `initialState`.
79
+ *
80
+ * Messages/todos and the other app-owned keys seed as captured. The run lane
81
+ * seeds by what the user left: a thread whose run was `running` when the
82
+ * snapshot was taken seeds a running entry (see {@link seedRunsLane}) so the
83
+ * switch back reads Running with a Stop control on its first frame — the same
84
+ * frame `runs: []` would render as "ready" with a Send button over a thread the
85
+ * server is still mid-run on. Every other live-lifecycle lane normalizes to
86
+ * resting: a seeded input request could collect a decision the server may have
87
+ * already resolved, so an `input-required` entry seeds as no run at all.
88
+ * `__interrupt__` is dropped for the same reason, and so are `ptc_subagents`
89
+ * (the live in-eval dispatch lane — a seeded "running" dispatch card under a
90
+ * resting thread would render active with no eval behind it) and
91
+ * `outOfBandRunActive` (the host's out-of-band-run-in-progress flag — seeding a
92
+ * finished run's `true` would hide the composer until the attach corrected
93
+ * it). Durable thread properties (`runConfig`, `config`, `sessionPersisted`, …)
94
+ * seed as captured; the attach snapshot then replaces the whole seed. The
95
+ * protocol lane seeds as a seed's own copy (`withSeedProtocolLane`), so
96
+ * `isDeepAgentHostState` never reads the seed, or a state folded over it, as
97
+ * what the host holds now.
98
+ */
99
+ export declare function toThreadSnapshotSeed(state: DeepAgentStreamValues): DeepAgentStreamValues;
@@ -0,0 +1,329 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const sealedIdb = require("./sealed-idb.cjs");
4
+ const THREAD_SNAPSHOT_MIRROR_DATABASE = "athena-thread-snapshots:v2";
5
+ const THREAD_SNAPSHOT_MIRROR_FORMAT = 1;
6
+ const MAX_MIRRORED_SNAPSHOTS_PER_OWNER = 30;
7
+ const MAX_MIRRORED_SNAPSHOT_MESSAGES = 150;
8
+ const SNAPSHOT_MIRROR_DEBOUNCE_MS = 1500;
9
+ const DATABASE_VERSION = 1;
10
+ const SNAPSHOTS_STORE = "snapshots";
11
+ const LISTS_STORE = "lists";
12
+ const BY_OWNER = "byOwner";
13
+ const BY_OWNER_AT = "byOwnerAt";
14
+ function upgradeMirrorDatabase(db) {
15
+ if (!db.objectStoreNames.contains(SNAPSHOTS_STORE)) {
16
+ const store = db.createObjectStore(SNAPSHOTS_STORE, { keyPath: "key" });
17
+ store.createIndex(BY_OWNER, "owner", { unique: false });
18
+ store.createIndex(BY_OWNER_AT, ["owner", "at"], { unique: false });
19
+ }
20
+ if (!db.objectStoreNames.contains(LISTS_STORE)) {
21
+ const lists = db.createObjectStore(LISTS_STORE, { keyPath: "key" });
22
+ lists.createIndex(BY_OWNER, "owner", { unique: false });
23
+ }
24
+ }
25
+ function isRestingThreadSnapshot(state) {
26
+ var _a;
27
+ const run = (_a = state.runs) == null ? void 0 : _a[0];
28
+ if (run && run.status === "running") return false;
29
+ if (state.outOfBandRunActive === true) return false;
30
+ return Array.isArray(state.messages);
31
+ }
32
+ function classifyThreadSnapshotForMirror(state, maxMessages = MAX_MIRRORED_SNAPSHOT_MESSAGES) {
33
+ var _a;
34
+ if (!isRestingThreadSnapshot(state)) return "skip";
35
+ return (((_a = state.messages) == null ? void 0 : _a.length) ?? 0) <= maxMessages ? "persist" : "invalidate";
36
+ }
37
+ function isOwnFormat(record) {
38
+ if (typeof record !== "object" || record === null) return true;
39
+ const format = record.format;
40
+ return typeof format !== "number" || format <= THREAD_SNAPSHOT_MIRROR_FORMAT;
41
+ }
42
+ function isRecord(value) {
43
+ return typeof value === "object" && value !== null;
44
+ }
45
+ function createThreadSnapshotMirror({
46
+ getKey,
47
+ factory = sealedIdb.idbGlobals.indexedDB,
48
+ databaseName = THREAD_SNAPSHOT_MIRROR_DATABASE,
49
+ debounceMs = SNAPSHOT_MIRROR_DEBOUNCE_MS,
50
+ maxPerOwner = MAX_MIRRORED_SNAPSHOTS_PER_OWNER,
51
+ maxMessages = MAX_MIRRORED_SNAPSHOT_MESSAGES
52
+ }) {
53
+ const database = sealedIdb.lazySealedDatabase({
54
+ factory,
55
+ name: databaseName,
56
+ version: DATABASE_VERSION,
57
+ upgrade: upgradeMirrorDatabase
58
+ });
59
+ const keyOf = async (ownerId, purpose) => {
60
+ try {
61
+ return await getKey(ownerId, purpose);
62
+ } catch {
63
+ return null;
64
+ }
65
+ };
66
+ const aadOf = (kind, owner, key) => `athena-thread-snapshot|${THREAD_SNAPSHOT_MIRROR_FORMAT}|${kind}|${owner}|${key}`;
67
+ const pending = /* @__PURE__ */ new Map();
68
+ const pendingLists = /* @__PURE__ */ new Map();
69
+ let queue = Promise.resolve();
70
+ const enqueue = (task) => {
71
+ queue = queue.then(task, task).catch(() => {
72
+ });
73
+ return queue;
74
+ };
75
+ const pruneOwner = async (db, owner) => {
76
+ const KeyRange = sealedIdb.idbGlobals.IDBKeyRange;
77
+ if (!KeyRange) return;
78
+ const tx = db.transaction(SNAPSHOTS_STORE, "readwrite");
79
+ const store = tx.objectStore(SNAPSHOTS_STORE);
80
+ const index = store.index(BY_OWNER_AT);
81
+ const range = KeyRange.bound([owner, Number.NEGATIVE_INFINITY], [owner, Number.POSITIVE_INFINITY]);
82
+ const beyond = [];
83
+ await new Promise((resolve, reject) => {
84
+ let kept = 0;
85
+ const request = index.openKeyCursor(range, "prev");
86
+ request.onsuccess = () => {
87
+ const cursor = request.result;
88
+ if (!cursor) {
89
+ resolve();
90
+ return;
91
+ }
92
+ kept += 1;
93
+ if (kept > maxPerOwner) beyond.push(cursor.primaryKey);
94
+ cursor.continue();
95
+ };
96
+ request.onerror = () => reject(request.error ?? new Error("IndexedDB cursor failed"));
97
+ });
98
+ for (const key of beyond) {
99
+ if (isOwnFormat(await sealedIdb.requestToPromise(store.get(key)))) store.delete(key);
100
+ }
101
+ await sealedIdb.transactionDone(tx);
102
+ };
103
+ const put = (input) => enqueue(async () => {
104
+ const db = await database();
105
+ if (!db) return;
106
+ const cryptoKey = await keyOf(input.ownerId, "write");
107
+ if (!cryptoKey) return;
108
+ const owner = await sealedIdb.sha256Hex(input.ownerId);
109
+ const key = await sealedIdb.sha256Hex(`${input.ownerId}|${input.threadId}`);
110
+ const sealed = await sealedIdb.sealJson({
111
+ key: cryptoKey,
112
+ value: { threadId: input.threadId, state: input.state },
113
+ aad: aadOf("snapshot", owner, key)
114
+ });
115
+ const tx = db.transaction(SNAPSHOTS_STORE, "readwrite");
116
+ const store = tx.objectStore(SNAPSHOTS_STORE);
117
+ if (isOwnFormat(await sealedIdb.requestToPromise(store.get(key)))) {
118
+ store.put({
119
+ key,
120
+ owner,
121
+ at: input.at,
122
+ format: THREAD_SNAPSHOT_MIRROR_FORMAT,
123
+ sealed
124
+ });
125
+ }
126
+ await sealedIdb.transactionDone(tx);
127
+ await pruneOwner(db, owner);
128
+ });
129
+ const deleteSnapshot = (input) => enqueue(async () => {
130
+ const db = await database();
131
+ if (!db) return;
132
+ const key = await sealedIdb.sha256Hex(`${input.ownerId}|${input.threadId}`);
133
+ const tx = db.transaction(SNAPSHOTS_STORE, "readwrite");
134
+ const store = tx.objectStore(SNAPSHOTS_STORE);
135
+ if (isOwnFormat(await sealedIdb.requestToPromise(store.get(key)))) store.delete(key);
136
+ await sealedIdb.transactionDone(tx);
137
+ });
138
+ const pendingKey = (ownerId, threadId) => `${ownerId}\0${threadId}`;
139
+ const flushPending = (key) => {
140
+ const entry = pending.get(key);
141
+ if (!entry) return Promise.resolve();
142
+ pending.delete(key);
143
+ clearTimeout(entry.timer);
144
+ return put(entry.input);
145
+ };
146
+ const putList = (input) => enqueue(async () => {
147
+ const db = await database();
148
+ if (!db) return;
149
+ const cryptoKey = await keyOf(input.ownerId, "write");
150
+ if (!cryptoKey) return;
151
+ const owner = await sealedIdb.sha256Hex(input.ownerId);
152
+ const key = await sealedIdb.sha256Hex(`${input.ownerId}|list|${input.listKey}`);
153
+ const sealed = await sealedIdb.sealJson({ key: cryptoKey, value: input.value, aad: aadOf("list", owner, key) });
154
+ const tx = db.transaction(LISTS_STORE, "readwrite");
155
+ const store = tx.objectStore(LISTS_STORE);
156
+ if (isOwnFormat(await sealedIdb.requestToPromise(store.get(key)))) {
157
+ store.put({
158
+ key,
159
+ owner,
160
+ at: Date.now(),
161
+ format: THREAD_SNAPSHOT_MIRROR_FORMAT,
162
+ sealed
163
+ });
164
+ }
165
+ await sealedIdb.transactionDone(tx);
166
+ });
167
+ const flushList = (key) => {
168
+ const entry = pendingLists.get(key);
169
+ if (!entry) return Promise.resolve();
170
+ pendingLists.delete(key);
171
+ clearTimeout(entry.timer);
172
+ return putList(entry.input);
173
+ };
174
+ const dropPendingOf = (ownerId) => {
175
+ for (const [key, entry] of pending) {
176
+ if (ownerId === null || entry.input.ownerId === ownerId) {
177
+ clearTimeout(entry.timer);
178
+ pending.delete(key);
179
+ }
180
+ }
181
+ for (const [key, entry] of pendingLists) {
182
+ if (ownerId === null || entry.input.ownerId === ownerId) {
183
+ clearTimeout(entry.timer);
184
+ pendingLists.delete(key);
185
+ }
186
+ }
187
+ };
188
+ return {
189
+ async load(ownerId) {
190
+ try {
191
+ const db = await database();
192
+ if (!db) return [];
193
+ const cryptoKey = await keyOf(ownerId, "read");
194
+ if (!cryptoKey) return [];
195
+ const owner = await sealedIdb.sha256Hex(ownerId);
196
+ const records = await sealedIdb.requestToPromise(
197
+ db.transaction(SNAPSHOTS_STORE, "readonly").objectStore(SNAPSHOTS_STORE).index(BY_OWNER).getAll(owner)
198
+ );
199
+ const loaded = [];
200
+ const unreadable = [];
201
+ for (const record of records) {
202
+ if (!record || record.format > THREAD_SNAPSHOT_MIRROR_FORMAT) continue;
203
+ try {
204
+ const value = await sealedIdb.openJson({
205
+ key: cryptoKey,
206
+ sealed: record.sealed,
207
+ aad: aadOf("snapshot", owner, record.key)
208
+ });
209
+ if (isRecord(value) && typeof value.threadId === "string" && isRecord(value.state) && typeof record.at === "number") {
210
+ loaded.push({ threadId: value.threadId, state: value.state, at: record.at });
211
+ }
212
+ } catch {
213
+ unreadable.push(record.key);
214
+ }
215
+ }
216
+ if (unreadable.length > 0) {
217
+ void enqueue(async () => {
218
+ const tx = db.transaction(SNAPSHOTS_STORE, "readwrite");
219
+ for (const key of unreadable) tx.objectStore(SNAPSHOTS_STORE).delete(key);
220
+ await sealedIdb.transactionDone(tx);
221
+ });
222
+ }
223
+ return loaded.sort((a, b) => a.at - b.at);
224
+ } catch {
225
+ return [];
226
+ }
227
+ },
228
+ write(input) {
229
+ const key = pendingKey(input.ownerId, input.threadId);
230
+ const verdict = classifyThreadSnapshotForMirror(input.state, maxMessages);
231
+ if (verdict === "invalidate") {
232
+ const existing2 = pending.get(key);
233
+ if (existing2) clearTimeout(existing2.timer);
234
+ pending.delete(key);
235
+ void deleteSnapshot(input);
236
+ return;
237
+ }
238
+ if (verdict === "skip") return;
239
+ const existing = pending.get(key);
240
+ if (existing) clearTimeout(existing.timer);
241
+ pending.set(key, {
242
+ input,
243
+ timer: setTimeout(() => {
244
+ void flushPending(key);
245
+ }, debounceMs)
246
+ });
247
+ },
248
+ remove(input) {
249
+ const key = pendingKey(input.ownerId, input.threadId);
250
+ const existing = pending.get(key);
251
+ if (existing) clearTimeout(existing.timer);
252
+ pending.delete(key);
253
+ void deleteSnapshot(input);
254
+ },
255
+ writeList(input) {
256
+ const key = pendingKey(input.ownerId, `list:${input.listKey}`);
257
+ const existing = pendingLists.get(key);
258
+ if (existing) clearTimeout(existing.timer);
259
+ pendingLists.set(key, {
260
+ input,
261
+ timer: setTimeout(() => {
262
+ void flushList(key);
263
+ }, debounceMs)
264
+ });
265
+ },
266
+ async loadList({ ownerId, listKey }) {
267
+ try {
268
+ const db = await database();
269
+ if (!db) return null;
270
+ const cryptoKey = await keyOf(ownerId, "read");
271
+ if (!cryptoKey) return null;
272
+ const owner = await sealedIdb.sha256Hex(ownerId);
273
+ const key = await sealedIdb.sha256Hex(`${ownerId}|list|${listKey}`);
274
+ const record = await sealedIdb.requestToPromise(
275
+ db.transaction(LISTS_STORE, "readonly").objectStore(LISTS_STORE).get(key)
276
+ );
277
+ if (!record || record.format > THREAD_SNAPSHOT_MIRROR_FORMAT || record.owner !== owner) return null;
278
+ try {
279
+ const value = await sealedIdb.openJson({ key: cryptoKey, sealed: record.sealed, aad: aadOf("list", owner, key) });
280
+ return { value, at: record.at };
281
+ } catch {
282
+ return null;
283
+ }
284
+ } catch {
285
+ return null;
286
+ }
287
+ },
288
+ clearOwner(ownerId) {
289
+ dropPendingOf(ownerId);
290
+ return enqueue(async () => {
291
+ const db = await database();
292
+ if (!db) return;
293
+ const owner = await sealedIdb.sha256Hex(ownerId);
294
+ const tx = db.transaction([SNAPSHOTS_STORE, LISTS_STORE], "readwrite");
295
+ for (const storeName of [SNAPSHOTS_STORE, LISTS_STORE]) {
296
+ const store = tx.objectStore(storeName);
297
+ const keys = await sealedIdb.requestToPromise(store.index(BY_OWNER).getAllKeys(owner));
298
+ for (const key of keys) store.delete(key);
299
+ }
300
+ await sealedIdb.transactionDone(tx);
301
+ });
302
+ },
303
+ clearAll() {
304
+ dropPendingOf(null);
305
+ return enqueue(async () => {
306
+ const db = await database();
307
+ if (!db) return;
308
+ const tx = db.transaction([SNAPSHOTS_STORE, LISTS_STORE], "readwrite");
309
+ tx.objectStore(SNAPSHOTS_STORE).clear();
310
+ tx.objectStore(LISTS_STORE).clear();
311
+ await sealedIdb.transactionDone(tx);
312
+ });
313
+ },
314
+ async flush() {
315
+ await Promise.all([...pending.keys()].map(flushPending));
316
+ await Promise.all([...pendingLists.keys()].map(flushList));
317
+ await queue;
318
+ }
319
+ };
320
+ }
321
+ exports.MAX_MIRRORED_SNAPSHOTS_PER_OWNER = MAX_MIRRORED_SNAPSHOTS_PER_OWNER;
322
+ exports.MAX_MIRRORED_SNAPSHOT_MESSAGES = MAX_MIRRORED_SNAPSHOT_MESSAGES;
323
+ exports.SNAPSHOT_MIRROR_DEBOUNCE_MS = SNAPSHOT_MIRROR_DEBOUNCE_MS;
324
+ exports.THREAD_SNAPSHOT_MIRROR_DATABASE = THREAD_SNAPSHOT_MIRROR_DATABASE;
325
+ exports.THREAD_SNAPSHOT_MIRROR_FORMAT = THREAD_SNAPSHOT_MIRROR_FORMAT;
326
+ exports.classifyThreadSnapshotForMirror = classifyThreadSnapshotForMirror;
327
+ exports.createThreadSnapshotMirror = createThreadSnapshotMirror;
328
+ exports.isRestingThreadSnapshot = isRestingThreadSnapshot;
329
+ //# sourceMappingURL=thread-snapshot-mirror.cjs.map