@athenaintel/react 0.41.3 → 0.42.2

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 (479) hide show
  1. package/README.md +132 -10
  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.d.ts +60 -0
  48. package/dist/agent-runtime/src/edit-command.d.ts +156 -0
  49. package/dist/agent-runtime/src/errors.d.ts +174 -0
  50. package/dist/agent-runtime/src/execute-output.d.ts +31 -0
  51. package/dist/agent-runtime/src/generated/runconfig-contract.cjs +16 -2
  52. package/dist/agent-runtime/src/generated/runconfig-contract.cjs.map +1 -1
  53. package/dist/agent-runtime/src/generated/runconfig-contract.d.ts +202 -0
  54. package/dist/agent-runtime/src/generated/runconfig-contract.js +16 -2
  55. package/dist/agent-runtime/src/generated/runconfig-contract.js.map +1 -1
  56. package/dist/agent-runtime/src/github-wake-event.d.ts +77 -0
  57. package/dist/agent-runtime/src/index.d.ts +74 -0
  58. package/dist/agent-runtime/src/interrupts.cjs +17 -0
  59. package/dist/agent-runtime/src/interrupts.cjs.map +1 -1
  60. package/dist/agent-runtime/src/interrupts.d.ts +348 -0
  61. package/dist/agent-runtime/src/interrupts.js +17 -0
  62. package/dist/agent-runtime/src/interrupts.js.map +1 -1
  63. package/dist/agent-runtime/src/lane-follow.d.ts +121 -0
  64. package/dist/agent-runtime/src/lane-history.cjs +209 -0
  65. package/dist/agent-runtime/src/lane-history.cjs.map +1 -0
  66. package/dist/agent-runtime/src/lane-history.d.ts +175 -0
  67. package/dist/agent-runtime/src/lane-history.js +209 -0
  68. package/dist/agent-runtime/src/lane-history.js.map +1 -0
  69. package/dist/agent-runtime/src/lane-images.d.ts +184 -0
  70. package/dist/agent-runtime/src/message-author.d.ts +43 -0
  71. package/dist/agent-runtime/src/message-text.cjs +15 -0
  72. package/dist/agent-runtime/src/message-text.cjs.map +1 -0
  73. package/dist/agent-runtime/src/message-text.d.ts +47 -0
  74. package/dist/agent-runtime/src/message-text.js +15 -0
  75. package/dist/agent-runtime/src/message-text.js.map +1 -0
  76. package/dist/agent-runtime/src/message-window.cjs +15 -1
  77. package/dist/agent-runtime/src/message-window.cjs.map +1 -1
  78. package/dist/agent-runtime/src/message-window.d.ts +159 -0
  79. package/dist/agent-runtime/src/message-window.js +16 -2
  80. package/dist/agent-runtime/src/message-window.js.map +1 -1
  81. package/dist/agent-runtime/src/messages.cjs +123 -8
  82. package/dist/agent-runtime/src/messages.cjs.map +1 -1
  83. package/dist/agent-runtime/src/messages.d.ts +621 -0
  84. package/dist/agent-runtime/src/messages.js +123 -8
  85. package/dist/agent-runtime/src/messages.js.map +1 -1
  86. package/dist/agent-runtime/src/model-context.d.ts +22 -0
  87. package/dist/agent-runtime/src/offline-status.d.ts +157 -0
  88. package/dist/agent-runtime/src/optimistic-content.d.ts +21 -0
  89. package/dist/agent-runtime/src/protocol.cjs +12 -4
  90. package/dist/agent-runtime/src/protocol.cjs.map +1 -1
  91. package/dist/agent-runtime/src/protocol.d.ts +119 -0
  92. package/dist/agent-runtime/src/protocol.js +13 -5
  93. package/dist/agent-runtime/src/protocol.js.map +1 -1
  94. package/dist/agent-runtime/src/ptc-subcalls.d.ts +51 -0
  95. package/dist/agent-runtime/src/queue.d.ts +138 -0
  96. package/dist/agent-runtime/src/quota-safe-local-storage-session.cjs +10 -0
  97. package/dist/agent-runtime/src/quota-safe-local-storage-session.cjs.map +1 -1
  98. package/dist/agent-runtime/src/quota-safe-local-storage-session.d.ts +161 -0
  99. package/dist/agent-runtime/src/quota-safe-local-storage-session.js +10 -0
  100. package/dist/agent-runtime/src/quota-safe-local-storage-session.js.map +1 -1
  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/session-lane-scope.cjs +25 -0
  115. package/dist/agent-runtime/src/session-lane-scope.cjs.map +1 -0
  116. package/dist/agent-runtime/src/session-lane-scope.d.ts +59 -0
  117. package/dist/agent-runtime/src/session-lane-scope.js +25 -0
  118. package/dist/agent-runtime/src/session-lane-scope.js.map +1 -0
  119. package/dist/agent-runtime/src/statewire-attach-observer.d.ts +194 -0
  120. package/dist/agent-runtime/src/statewire-diagnostics.d.ts +74 -0
  121. package/dist/agent-runtime/src/statewire-state.d.ts +29 -0
  122. package/dist/agent-runtime/src/statewire-suspended.cjs.map +1 -1
  123. package/dist/agent-runtime/src/statewire-suspended.d.ts +27 -0
  124. package/dist/agent-runtime/src/statewire-suspended.js.map +1 -1
  125. package/dist/agent-runtime/src/statewire-transport.d.ts +40 -0
  126. package/dist/agent-runtime/src/streaming-markdown.d.ts +46 -0
  127. package/dist/agent-runtime/src/subagent-transcripts.cjs +209 -0
  128. package/dist/agent-runtime/src/subagent-transcripts.cjs.map +1 -0
  129. package/dist/agent-runtime/src/subagent-transcripts.d.ts +71 -0
  130. package/dist/agent-runtime/src/subagent-transcripts.js +209 -0
  131. package/dist/agent-runtime/src/subagent-transcripts.js.map +1 -0
  132. package/dist/agent-runtime/src/subagents.cjs +253 -0
  133. package/dist/agent-runtime/src/subagents.cjs.map +1 -0
  134. package/dist/agent-runtime/src/subagents.d.ts +311 -0
  135. package/dist/agent-runtime/src/subagents.js +253 -0
  136. package/dist/agent-runtime/src/subagents.js.map +1 -0
  137. package/dist/agent-runtime/src/subscription-wake-event.d.ts +111 -0
  138. package/dist/agent-runtime/src/thread-extras.d.ts +43 -0
  139. package/dist/agent-runtime/src/thread-handoff.d.ts +364 -0
  140. package/dist/agent-runtime/src/thread-prewarm-controller.d.ts +76 -0
  141. package/dist/agent-runtime/src/thread-prewarm.d.ts +118 -0
  142. package/dist/agent-runtime/src/thread-snapshot-cache.d.ts +99 -0
  143. package/dist/agent-runtime/src/thread-snapshot-mirror.cjs +46 -117
  144. package/dist/agent-runtime/src/thread-snapshot-mirror.cjs.map +1 -1
  145. package/dist/agent-runtime/src/thread-snapshot-mirror.d.ts +101 -0
  146. package/dist/agent-runtime/src/thread-snapshot-mirror.js +17 -88
  147. package/dist/agent-runtime/src/thread-snapshot-mirror.js.map +1 -1
  148. package/dist/agent-runtime/src/thread-status.d.ts +53 -0
  149. package/dist/agent-runtime/src/tool-metadata.d.ts +146 -0
  150. package/dist/agent-runtime/src/tool-names.cjs +71 -0
  151. package/dist/agent-runtime/src/tool-names.cjs.map +1 -1
  152. package/dist/agent-runtime/src/tool-names.d.ts +67 -0
  153. package/dist/agent-runtime/src/tool-names.js +72 -1
  154. package/dist/agent-runtime/src/tool-names.js.map +1 -1
  155. package/dist/agent-runtime/src/tool-outputs.d.ts +35 -0
  156. package/dist/agent-runtime/src/tool-result.cjs +1 -0
  157. package/dist/agent-runtime/src/tool-result.cjs.map +1 -1
  158. package/dist/agent-runtime/src/tool-result.d.ts +126 -0
  159. package/dist/agent-runtime/src/tool-result.js +1 -0
  160. package/dist/agent-runtime/src/tool-result.js.map +1 -1
  161. package/dist/agent-runtime/src/types.d.ts +159 -0
  162. package/dist/agent-runtime/src/use-conversation-list.d.ts +76 -0
  163. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.cjs +136 -0
  164. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.cjs.map +1 -0
  165. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.d.ts +64 -0
  166. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.js +136 -0
  167. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.js.map +1 -0
  168. package/dist/agent-runtime/src/use-deep-agent-config.d.ts +169 -0
  169. package/dist/agent-runtime/src/use-deep-agent-edit-submit.cjs +13 -0
  170. package/dist/agent-runtime/src/use-deep-agent-edit-submit.cjs.map +1 -1
  171. package/dist/agent-runtime/src/use-deep-agent-edit-submit.d.ts +22 -0
  172. package/dist/agent-runtime/src/use-deep-agent-edit-submit.js +13 -0
  173. package/dist/agent-runtime/src/use-deep-agent-edit-submit.js.map +1 -1
  174. package/dist/agent-runtime/src/use-deep-agent-runtime.cjs +37 -2
  175. package/dist/agent-runtime/src/use-deep-agent-runtime.cjs.map +1 -1
  176. package/dist/agent-runtime/src/use-deep-agent-runtime.d.ts +177 -0
  177. package/dist/agent-runtime/src/use-deep-agent-runtime.js +38 -3
  178. package/dist/agent-runtime/src/use-deep-agent-runtime.js.map +1 -1
  179. package/dist/agent-runtime/src/use-deep-agent-thread.cjs +39 -13
  180. package/dist/agent-runtime/src/use-deep-agent-thread.cjs.map +1 -1
  181. package/dist/agent-runtime/src/use-deep-agent-thread.d.ts +352 -0
  182. package/dist/agent-runtime/src/use-deep-agent-thread.js +39 -13
  183. package/dist/agent-runtime/src/use-deep-agent-thread.js.map +1 -1
  184. package/dist/agent-runtime/src/use-deep-agent-voice.cjs +1019 -0
  185. package/dist/agent-runtime/src/use-deep-agent-voice.cjs.map +1 -0
  186. package/dist/agent-runtime/src/use-deep-agent-voice.d.ts +409 -0
  187. package/dist/agent-runtime/src/use-deep-agent-voice.js +1019 -0
  188. package/dist/agent-runtime/src/use-deep-agent-voice.js.map +1 -0
  189. package/dist/agent-runtime/src/use-deep-agent-window-sync.d.ts +102 -0
  190. package/dist/agent-runtime/src/use-historical-edit-attachments.d.ts +2 -0
  191. package/dist/agent-runtime/src/use-thread-handoff-flow.d.ts +84 -0
  192. package/dist/agent-runtime/src/voice-presentation.cjs +2 -0
  193. package/dist/agent-runtime/src/voice-presentation.cjs.map +1 -1
  194. package/dist/agent-runtime/src/voice-presentation.d.ts +80 -0
  195. package/dist/agent-runtime/src/voice-presentation.js +2 -0
  196. package/dist/agent-runtime/src/voice-presentation.js.map +1 -1
  197. package/dist/agent-runtime/src/voice-turn-grouping.d.ts +28 -0
  198. package/dist/agent-runtime/src/voice-wire-types.d.ts +15 -0
  199. package/dist/agent-runtime/src/withdrawn-turns.d.ts +97 -0
  200. package/dist/catalog/runtime-catalog.js +1 -1
  201. package/dist/chat/AthenaChat.cjs +192 -103
  202. package/dist/chat/AthenaChat.cjs.map +1 -1
  203. package/dist/chat/AthenaChat.d.ts +9 -0
  204. package/dist/chat/AthenaChat.js +194 -105
  205. package/dist/chat/AthenaChat.js.map +1 -1
  206. package/dist/chat/StatewireApprovalCard.d.ts +1 -1
  207. package/dist/chat/StatewireClientToolBridge.d.ts +1 -1
  208. package/dist/chat/StatewireQueuedMessages.cjs +11 -4
  209. package/dist/chat/StatewireQueuedMessages.cjs.map +1 -1
  210. package/dist/chat/StatewireQueuedMessages.d.ts +1 -1
  211. package/dist/chat/StatewireQueuedMessages.js +11 -4
  212. package/dist/chat/StatewireQueuedMessages.js.map +1 -1
  213. package/dist/chat/chat-outbox-rows.cjs +223 -0
  214. package/dist/chat/chat-outbox-rows.cjs.map +1 -0
  215. package/dist/chat/chat-outbox-rows.d.ts +29 -0
  216. package/dist/chat/chat-outbox-rows.js +223 -0
  217. package/dist/chat/chat-outbox-rows.js.map +1 -0
  218. package/dist/chat/chat-voice-controls.cjs +128 -0
  219. package/dist/chat/chat-voice-controls.cjs.map +1 -0
  220. package/dist/chat/chat-voice-controls.d.ts +19 -0
  221. package/dist/chat/chat-voice-controls.js +128 -0
  222. package/dist/chat/chat-voice-controls.js.map +1 -0
  223. package/dist/chat/statewire-approval.d.ts +1 -1
  224. package/dist/chat/statewire-client-tools.d.ts +1 -1
  225. package/dist/chat/super-grouping/SuperGroupingCard.cjs +3 -1
  226. package/dist/chat/super-grouping/SuperGroupingCard.cjs.map +1 -1
  227. package/dist/chat/super-grouping/SuperGroupingCard.d.ts +7 -1
  228. package/dist/chat/super-grouping/SuperGroupingCard.js +3 -1
  229. package/dist/chat/super-grouping/SuperGroupingCard.js.map +1 -1
  230. package/dist/chat/super-grouping/SuperGroupingTranscript.cjs +7 -2
  231. package/dist/chat/super-grouping/SuperGroupingTranscript.cjs.map +1 -1
  232. package/dist/chat/super-grouping/SuperGroupingTranscript.d.ts +2 -2
  233. package/dist/chat/super-grouping/SuperGroupingTranscript.js +7 -2
  234. package/dist/chat/super-grouping/SuperGroupingTranscript.js.map +1 -1
  235. package/dist/chat/super-grouping/activity-timeline.cjs +15 -8
  236. package/dist/chat/super-grouping/activity-timeline.cjs.map +1 -1
  237. package/dist/chat/super-grouping/activity-timeline.d.ts +18 -8
  238. package/dist/chat/super-grouping/activity-timeline.js +15 -8
  239. package/dist/chat/super-grouping/activity-timeline.js.map +1 -1
  240. package/dist/chat/use-statewire-approval-request.cjs +36 -0
  241. package/dist/chat/use-statewire-approval-request.cjs.map +1 -1
  242. package/dist/chat/use-statewire-approval-request.d.ts +49 -1
  243. package/dist/chat/use-statewire-approval-request.js +39 -3
  244. package/dist/chat/use-statewire-approval-request.js.map +1 -1
  245. package/dist/chat-ui/composer/tiptap-composer.cjs +133 -14
  246. package/dist/chat-ui/composer/tiptap-composer.cjs.map +1 -1
  247. package/dist/chat-ui/composer/tiptap-composer.d.ts +33 -1
  248. package/dist/chat-ui/composer/tiptap-composer.js +135 -16
  249. package/dist/chat-ui/composer/tiptap-composer.js.map +1 -1
  250. package/dist/chat-ui/header/conversation-history-panel.d.ts +1 -1
  251. package/dist/chat-ui/index.d.ts +1 -1
  252. package/dist/chat-ui/mentions/suggestions/data/api-client.cjs +2 -1
  253. package/dist/chat-ui/mentions/suggestions/data/api-client.cjs.map +1 -1
  254. package/dist/chat-ui/mentions/suggestions/data/api-client.d.ts +3 -1
  255. package/dist/chat-ui/mentions/suggestions/data/api-client.js +2 -1
  256. package/dist/chat-ui/mentions/suggestions/data/api-client.js.map +1 -1
  257. package/dist/chat-ui/mentions/use-account-workspace-id.cjs +29 -51
  258. package/dist/chat-ui/mentions/use-account-workspace-id.cjs.map +1 -1
  259. package/dist/chat-ui/mentions/use-account-workspace-id.d.ts +2 -2
  260. package/dist/chat-ui/mentions/use-account-workspace-id.js +30 -52
  261. package/dist/chat-ui/mentions/use-account-workspace-id.js.map +1 -1
  262. package/dist/chat-ui/messages/message-components.cjs +15 -0
  263. package/dist/chat-ui/messages/message-components.cjs.map +1 -1
  264. package/dist/chat-ui/messages/message-components.js +15 -0
  265. package/dist/chat-ui/messages/message-components.js.map +1 -1
  266. package/dist/chat-ui/messages/runtime-message.d.ts +1 -1
  267. package/dist/chat-ui/messages/statewire-continue-run.d.ts +1 -1
  268. package/dist/chat-ui/messages/user-edit-composer.cjs +15 -2
  269. package/dist/chat-ui/messages/user-edit-composer.cjs.map +1 -1
  270. package/dist/chat-ui/messages/user-edit-composer.d.ts +4 -2
  271. package/dist/chat-ui/messages/user-edit-composer.js +15 -2
  272. package/dist/chat-ui/messages/user-edit-composer.js.map +1 -1
  273. package/dist/chat-ui/messages/wake-marker.d.ts +1 -1
  274. package/dist/chat-ui/rich-text/chat-text-schema.cjs +1 -0
  275. package/dist/chat-ui/rich-text/chat-text-schema.cjs.map +1 -1
  276. package/dist/chat-ui/rich-text/chat-text-schema.d.ts +3 -0
  277. package/dist/chat-ui/rich-text/chat-text-schema.js +1 -0
  278. package/dist/chat-ui/rich-text/chat-text-schema.js.map +1 -1
  279. package/dist/chat-ui/statewire.cjs +1 -0
  280. package/dist/chat-ui/statewire.cjs.map +1 -1
  281. package/dist/chat-ui/statewire.d.ts +2 -2
  282. package/dist/chat-ui/statewire.js +2 -1
  283. package/dist/chat-ui/thread/composer-send-or-stop.cjs +2 -1
  284. package/dist/chat-ui/thread/composer-send-or-stop.cjs.map +1 -1
  285. package/dist/chat-ui/thread/composer-send-or-stop.d.ts +2 -0
  286. package/dist/chat-ui/thread/composer-send-or-stop.js +2 -1
  287. package/dist/chat-ui/thread/composer-send-or-stop.js.map +1 -1
  288. package/dist/chat-ui/thread/statewire-history-edge.d.ts +1 -1
  289. package/dist/composer/AttachmentContext.cjs +8 -4
  290. package/dist/composer/AttachmentContext.cjs.map +1 -1
  291. package/dist/composer/AttachmentContext.d.ts +7 -0
  292. package/dist/composer/AttachmentContext.js +8 -4
  293. package/dist/composer/AttachmentContext.js.map +1 -1
  294. package/dist/composer/build-composed-message.cjs +34 -0
  295. package/dist/composer/build-composed-message.cjs.map +1 -1
  296. package/dist/composer/build-composed-message.d.ts +20 -0
  297. package/dist/composer/build-composed-message.js +35 -1
  298. package/dist/composer/build-composed-message.js.map +1 -1
  299. package/dist/composer/composer-handoff.cjs +39 -2
  300. package/dist/composer/composer-handoff.cjs.map +1 -1
  301. package/dist/composer/composer-handoff.d.ts +28 -3
  302. package/dist/composer/composer-handoff.js +39 -2
  303. package/dist/composer/composer-handoff.js.map +1 -1
  304. package/dist/composer/useAttachFiles.cjs +15 -2
  305. package/dist/composer/useAttachFiles.cjs.map +1 -1
  306. package/dist/composer/useAttachFiles.d.ts +11 -0
  307. package/dist/composer/useAttachFiles.js +15 -2
  308. package/dist/composer/useAttachFiles.js.map +1 -1
  309. package/dist/composer/useSendMessage.cjs.map +1 -1
  310. package/dist/composer/useSendMessage.d.ts +4 -3
  311. package/dist/composer/useSendMessage.js.map +1 -1
  312. package/dist/diagnostics/athena-diagnostics.cjs.map +1 -1
  313. package/dist/diagnostics/athena-diagnostics.d.ts +3 -1
  314. package/dist/diagnostics/athena-diagnostics.js.map +1 -1
  315. package/dist/index.cjs +13 -0
  316. package/dist/index.cjs.map +1 -1
  317. package/dist/index.d.ts +14 -7
  318. package/dist/index.js +14 -1
  319. package/dist/index.js.map +1 -1
  320. package/dist/offline/chat-outbox.cjs +57 -0
  321. package/dist/offline/chat-outbox.cjs.map +1 -0
  322. package/dist/offline/chat-outbox.d.ts +80 -0
  323. package/dist/offline/chat-outbox.js +57 -0
  324. package/dist/offline/chat-outbox.js.map +1 -0
  325. package/dist/offline/offline-history.d.ts +1 -1
  326. package/dist/provider/AthenaProvider.cjs +162 -8
  327. package/dist/provider/AthenaProvider.cjs.map +1 -1
  328. package/dist/provider/AthenaProvider.d.ts +15 -1
  329. package/dist/provider/AthenaProvider.js +163 -9
  330. package/dist/provider/AthenaProvider.js.map +1 -1
  331. package/dist/provider/statewire-window-context.d.ts +1 -1
  332. package/dist/react/package.json.cjs +1 -1
  333. package/dist/react/package.json.js +1 -1
  334. package/dist/references/src/anchors/file-line-range.d.ts +58 -0
  335. package/dist/references/src/anchors/format.d.ts +21 -0
  336. package/dist/references/src/anchors/message-anchors.d.ts +71 -0
  337. package/dist/references/src/anchors/parse.d.ts +8 -0
  338. package/dist/references/src/anchors/registry-contract.d.ts +24 -0
  339. package/dist/references/src/anchors/registry.d.ts +19 -0
  340. package/dist/references/src/anchors/schemas.d.ts +194 -0
  341. package/dist/references/src/anchors/serialize.d.ts +8 -0
  342. package/dist/references/src/anchors/time.d.ts +78 -0
  343. package/dist/references/src/anchors/types.d.ts +474 -0
  344. package/dist/references/src/asset-bounds.d.ts +27 -0
  345. package/dist/references/src/asset-links.d.ts +23 -0
  346. package/dist/references/src/asset-reference.d.ts +16 -0
  347. package/dist/references/src/formats/format-catalog.d.ts +79 -0
  348. package/dist/references/src/formats/markdown/parse-reference-markdown.d.ts +28 -0
  349. package/dist/references/src/formats/markdown/reference-display-name.d.ts +6 -0
  350. package/dist/references/src/formats/object/asset-object.d.ts +9 -0
  351. package/dist/references/src/formats/object/callable-object.d.ts +6 -0
  352. package/dist/references/src/formats/object/decode-reference-object-payload.d.ts +3 -0
  353. package/dist/references/src/formats/object/external-url-object.d.ts +9 -0
  354. package/dist/references/src/formats/object/group-object.d.ts +9 -0
  355. package/dist/references/src/formats/object/navigation-object.d.ts +9 -0
  356. package/dist/references/src/formats/object/parse-reference-object.d.ts +11 -0
  357. package/dist/references/src/formats/object/person-object.d.ts +9 -0
  358. package/dist/references/src/formats/uri/asset-mention-uri.d.ts +9 -0
  359. package/dist/references/src/formats/uri/asset-spaces-url.d.ts +9 -0
  360. package/dist/references/src/formats/uri/callable-mention-uris.d.ts +9 -0
  361. package/dist/references/src/formats/uri/detect-uri-wire.d.ts +9 -0
  362. package/dist/references/src/formats/uri/group-mention-uri.d.ts +12 -0
  363. package/dist/references/src/formats/uri/navigation-spaces-url.d.ts +14 -0
  364. package/dist/references/src/formats/uri/parse-reference-uri.d.ts +20 -0
  365. package/dist/references/src/formats/uri/person-mention-uri.d.ts +9 -0
  366. package/dist/references/src/formats/uri/template-placeholder.d.ts +12 -0
  367. package/dist/references/src/index.d.ts +47 -0
  368. package/dist/references/src/legacy/index.d.ts +14 -0
  369. package/dist/references/src/legacy/pre-reference-asset-url.d.ts +57 -0
  370. package/dist/references/src/legacy/pre-reference-citation-bridge.d.ts +22 -0
  371. package/dist/references/src/legacy/pre-reference-citation.d.ts +138 -0
  372. package/dist/references/src/legacy/pre-reference-external-url.d.ts +31 -0
  373. package/dist/references/src/legacy/pre-reference-format.d.ts +8 -0
  374. package/dist/references/src/legacy/pre-reference-mention.d.ts +27 -0
  375. package/dist/references/src/legacy/pre-reference-object.d.ts +8 -0
  376. package/dist/references/src/legacy/pre-reference-uri.d.ts +12 -0
  377. package/dist/references/src/legacy.d.ts +2 -0
  378. package/dist/references/src/mention-href-patterns.d.ts +19 -0
  379. package/dist/references/src/mention-node/index.d.ts +5 -0
  380. package/dist/references/src/mention-node/mention-node.d.ts +31 -0
  381. package/dist/references/src/mention-node/resolve-node-attrs.d.ts +27 -0
  382. package/dist/references/src/parse-reference.d.ts +23 -0
  383. package/dist/references/src/schemas.d.ts +463 -0
  384. package/dist/references/src/serialize-reference.d.ts +50 -0
  385. package/dist/references/src/sheet-name.d.ts +10 -0
  386. package/dist/references/src/tool-option-schemas.d.ts +597 -0
  387. package/dist/references/src/types.d.ts +125 -0
  388. package/dist/references/src/version-ref.d.ts +30 -0
  389. package/dist/runtime/statewire-lifecycle.d.ts +1 -1
  390. package/dist/runtime/statewire-model-lane.d.ts +1 -1
  391. package/dist/runtime/statewire-server-lane-context.d.ts +1 -1
  392. package/dist/runtime/statewire-session-key.cjs +7 -0
  393. package/dist/runtime/statewire-session-key.cjs.map +1 -1
  394. package/dist/runtime/statewire-session-key.d.ts +19 -0
  395. package/dist/runtime/statewire-session-key.js +8 -1
  396. package/dist/runtime/statewire-session-key.js.map +1 -1
  397. package/dist/runtime/statewire-session-lane.cjs +48 -0
  398. package/dist/runtime/statewire-session-lane.cjs.map +1 -0
  399. package/dist/runtime/statewire-session-lane.d.ts +29 -0
  400. package/dist/runtime/statewire-session-lane.js +48 -0
  401. package/dist/runtime/statewire-session-lane.js.map +1 -0
  402. package/dist/runtime/statewire-thread-config-lane.d.ts +1 -1
  403. package/dist/runtime/useAthenaStatewireRuntime.cjs +19 -5
  404. package/dist/runtime/useAthenaStatewireRuntime.cjs.map +1 -1
  405. package/dist/runtime/useAthenaStatewireRuntime.d.ts +15 -1
  406. package/dist/runtime/useAthenaStatewireRuntime.js +20 -6
  407. package/dist/runtime/useAthenaStatewireRuntime.js.map +1 -1
  408. package/dist/styles.css +1 -1
  409. package/dist/threads/api.d.ts +1 -1
  410. package/dist/threads/conversation-list-fetcher.d.ts +1 -1
  411. package/dist/threads/index-triggered-refresh.cjs +164 -0
  412. package/dist/threads/index-triggered-refresh.cjs.map +1 -0
  413. package/dist/threads/index-triggered-refresh.d.ts +70 -0
  414. package/dist/threads/index-triggered-refresh.js +164 -0
  415. package/dist/threads/index-triggered-refresh.js.map +1 -0
  416. package/dist/threads/offline-session-list.d.ts +1 -1
  417. package/dist/threads/pull-request-display.d.ts +1 -1
  418. package/dist/threads/session-list-model.d.ts +1 -1
  419. package/dist/threads/session-list-tab-share.cjs +150 -0
  420. package/dist/threads/session-list-tab-share.cjs.map +1 -0
  421. package/dist/threads/session-list-tab-share.d.ts +73 -0
  422. package/dist/threads/session-list-tab-share.js +150 -0
  423. package/dist/threads/session-list-tab-share.js.map +1 -0
  424. package/dist/threads/session-row-parts.d.ts +1 -1
  425. package/dist/threads/sessions-query.d.ts +1 -1
  426. package/dist/threads/statewire-thread-list.cjs +42 -16
  427. package/dist/threads/statewire-thread-list.cjs.map +1 -1
  428. package/dist/threads/statewire-thread-list.d.ts +11 -2
  429. package/dist/threads/statewire-thread-list.js +43 -17
  430. package/dist/threads/statewire-thread-list.js.map +1 -1
  431. package/dist/threads/thread-prefetcher.d.ts +1 -1
  432. package/dist/threads/use-athena-session-attention.d.ts +1 -1
  433. package/dist/threads/use-athena-sessions.cjs +32 -22
  434. package/dist/threads/use-athena-sessions.cjs.map +1 -1
  435. package/dist/threads/use-athena-sessions.js +33 -23
  436. package/dist/threads/use-athena-sessions.js.map +1 -1
  437. package/dist/threads/use-rest-conversation-history.d.ts +1 -1
  438. package/dist/threads/use-statewire-conversation-history.d.ts +5 -5
  439. package/dist/tiptap-markdown-table/src/markdown-table-serializer.d.ts +56 -0
  440. package/dist/tools/NestedPtcMessages.cjs +14 -9
  441. package/dist/tools/NestedPtcMessages.cjs.map +1 -1
  442. package/dist/tools/NestedPtcMessages.d.ts +9 -0
  443. package/dist/tools/NestedPtcMessages.js +6 -1
  444. package/dist/tools/NestedPtcMessages.js.map +1 -1
  445. package/dist/tools/index.d.ts +1 -1
  446. package/dist/tools/primitives.d.ts +1 -1
  447. package/dist/tools/subagent-task-tool-ui.cjs +494 -0
  448. package/dist/tools/subagent-task-tool-ui.cjs.map +1 -0
  449. package/dist/tools/subagent-task-tool-ui.d.ts +109 -0
  450. package/dist/tools/subagent-task-tool-ui.js +494 -0
  451. package/dist/tools/subagent-task-tool-ui.js.map +1 -0
  452. package/dist/tools/tool-fallback.d.ts +1 -1
  453. package/dist/tools/tool-icons.d.ts +1 -1
  454. package/dist/tools/tool-summary.d.ts +1 -1
  455. package/dist/tools/tool-uis.cjs +4 -0
  456. package/dist/tools/tool-uis.cjs.map +1 -1
  457. package/dist/tools/tool-uis.js +4 -0
  458. package/dist/tools/tool-uis.js.map +1 -1
  459. package/dist/voice/chat.cjs +6 -0
  460. package/dist/voice/chat.cjs.map +1 -0
  461. package/dist/voice/chat.d.ts +2 -0
  462. package/dist/voice/chat.js +6 -0
  463. package/dist/voice/chat.js.map +1 -0
  464. package/dist/voice/livekit-join.cjs +119 -0
  465. package/dist/voice/livekit-join.cjs.map +1 -0
  466. package/dist/voice/livekit-join.d.ts +8 -0
  467. package/dist/voice/livekit-join.js +119 -0
  468. package/dist/voice/livekit-join.js.map +1 -0
  469. package/dist/voice/livekit.cjs +32 -0
  470. package/dist/voice/livekit.cjs.map +1 -0
  471. package/dist/voice/livekit.d.ts +80 -0
  472. package/dist/voice/livekit.js +32 -0
  473. package/dist/voice/livekit.js.map +1 -0
  474. package/dist/voice/use-chat-voice-enabled.cjs +43 -0
  475. package/dist/voice/use-chat-voice-enabled.cjs.map +1 -0
  476. package/dist/voice/use-chat-voice-enabled.d.ts +9 -0
  477. package/dist/voice/use-chat-voice-enabled.js +43 -0
  478. package/dist/voice/use-chat-voice-enabled.js.map +1 -0
  479. package/package.json +22 -16
@@ -0,0 +1,343 @@
1
+ import type { QueryClient } from '@tanstack/react-query';
2
+ import type { ConversationIndexEntry } from './conversation-index';
3
+ /**
4
+ * What a session asks of the viewer, derived server-side from the run, the
5
+ * parked interrupt, the pull requests it opened, its termination and its last
6
+ * wake (the Devin-style session list). `needs_you` is the only state that
7
+ * demands the viewer act; `working` is live; `ready` finished with something
8
+ * to look at; `watching` waits on an external party (a review, a check);
9
+ * `done` and `error` are terminal. A backend newer than this client may report
10
+ * a value outside the union — render it as "no attention" rather than failing.
11
+ */
12
+ export type ConversationAttention = 'needs_you' | 'working' | 'ready' | 'watching' | 'done' | 'error';
13
+ export declare const CONVERSATION_ATTENTIONS: readonly ConversationAttention[];
14
+ /** Which signal produced the attention state (and the `nextAction` copy). */
15
+ export type ConversationAttentionSource = 'interrupt' | 'run' | 'pull_request' | 'termination' | 'wake' | 'handoff' | 'follow_up';
16
+ /** The last event that woke a resting session (a GitHub webhook, a schedule, a handoff). */
17
+ export interface ConversationWake {
18
+ source: string | null;
19
+ reason: string | null;
20
+ /** ISO 8601 timestamp of the wake. */
21
+ at: string | null;
22
+ }
23
+ /**
24
+ * Live GitHub state of a pull request the session opened, read by the server
25
+ * when the list renders. Never pushed by the conversation index — it comes
26
+ * from the list fetch only, so a fold keeps the fetched value.
27
+ */
28
+ export interface ConversationPullRequest {
29
+ /** `owner/repo` the pull request lives in. */
30
+ repoFullName: string;
31
+ number: number;
32
+ url: string;
33
+ title: string;
34
+ state: 'OPEN' | 'CLOSED' | 'MERGED';
35
+ isDraft: boolean;
36
+ /** GitHub's review decision (APPROVED, CHANGES_REQUESTED, REVIEW_REQUIRED) or null. */
37
+ reviewDecision: string | null;
38
+ /** Combined state of the checks on the head commit. */
39
+ checksState: 'SUCCESS' | 'FAILURE' | 'PENDING' | 'NONE';
40
+ /** ISO 8601 timestamp of the pull request's last update on GitHub. */
41
+ updatedAt: string;
42
+ }
43
+ /**
44
+ * Shared conversation/thread LIST contract (chat-stack unification —
45
+ * thread-list-contract-convergence).
46
+ *
47
+ * Every chat surface lists "my conversations" against the same underlying
48
+ * session assets, but historically each declared its own row shape, paging
49
+ * model, and filter set (Olympus GraphQL `listConversations`, the SDK/Chrome
50
+ * REST `/api/conversations/threads/list`, mobile's `/api/v0/sessions`). This
51
+ * module is the ONE contract those surfaces converge on:
52
+ *
53
+ * - **Row shape**: {@link ConversationSummary} — the canonical camelCase
54
+ * superset. Fields a transport cannot supply are `null`, never invented.
55
+ * - **Ordering**: newest first by `updatedAt`, always. Ordering is part of the
56
+ * contract, not a parameter — no surface sorts any other way.
57
+ * - **Paging**: offset/limit with a LIVE newest page and explicitly-fetched
58
+ * frozen history pages (see `useConversationList`). `hasMore` continues the
59
+ * scan; `totalCount` is advisory and may be `null` for transports that do
60
+ * not count.
61
+ * - **Filtering**: {@link ConversationListFilter}. `appId` follows
62
+ * `docs/SESSION_APP_ID_GUIDE.md`: exact match when set (legacy `null`
63
+ * sessions excluded), no filter when unset. A fetcher that cannot express a
64
+ * requested filter field MUST throw rather than silently ignore it — a
65
+ * dropped filter returns wrong rows under a cache key that claims otherwise.
66
+ * - **Freshness**: the per-user conversation-index statewire
67
+ * (`conversation-index.ts`) is the push signal; these queries are the data
68
+ * source. Push handlers call {@link invalidateConversationListCaches}.
69
+ */
70
+ export interface ConversationSummary {
71
+ /** LangGraph thread id — the cross-surface conversation identity. */
72
+ threadId: string;
73
+ title: string;
74
+ /** ISO 8601 timestamp of last update (the contract's sort key). */
75
+ updatedAt: string;
76
+ /** ISO 8601 creation timestamp, when the transport reports it. */
77
+ createdAt: string | null;
78
+ /** Session lifecycle state from athena_metadata (e.g. running, completed). */
79
+ state: string | null;
80
+ /** Agent runtime marker (e.g. 'athena_deep_agent'), when reported. */
81
+ runtime: string | null;
82
+ /** Channel the session was started from (e.g. agent_email, web). */
83
+ sourceChannel: string | null;
84
+ /** Asset type (session, video_session, desktop_session, mobile_session). */
85
+ assetType: string | null;
86
+ /** Session asset id (`asset_<uuid>`), when the transport reports it. */
87
+ assetId: string | null;
88
+ /** Client app that created the session (SESSION_APP_ID_GUIDE). */
89
+ appId: string | null;
90
+ /** Computer asset whose sandbox started the session (`sourceChannel` 'computer'); omitted by surfaces that don't carry it. */
91
+ computerAssetId?: string | null;
92
+ /**
93
+ * Collab agent (`asset_<uuid>`) and channel the session started on; `null`
94
+ * channel is the agent's default channel. The server refuses a run on another
95
+ * of the agent's channels, so a client shows the session's mode from these
96
+ * instead of remembering it. Omitted by surfaces that don't carry them.
97
+ */
98
+ collabAgentId?: string | null;
99
+ collabChannelId?: string | null;
100
+ /** Session asset id this row is a sub-session of; omitted by surfaces that don't carry it. */
101
+ parentSessionId?: string | null;
102
+ /** Sub-sessions of this row the viewer can see; omitted by surfaces that don't carry it. */
103
+ subSessionCount?: number;
104
+ /** Trigger marker (`manual` remains user-initiated; other values are automated). */
105
+ triggerType: string | null;
106
+ /** Last-message preview used when a legacy session has no useful title. */
107
+ preview: string | null;
108
+ messageCount: number | null;
109
+ /** Per-user unread flag derived server-side from the read receipt. */
110
+ isUnread: boolean;
111
+ /**
112
+ * Canonical session status (status_v2: idle | active | needs_input | error),
113
+ * or null when the transport does not report it.
114
+ */
115
+ sessionStatus: string | null;
116
+ /**
117
+ * Canonical status of the session's current run (status_v2: scheduled |
118
+ * queued | running | needs_input | completed | failed | canceled). Null when
119
+ * the transport does not report it — {@link isConversationRunning} then
120
+ * falls back to the legacy `state`. Running badges on every surface derive
121
+ * from this one helper so they cannot disagree.
122
+ */
123
+ runStatus: string | null;
124
+ /**
125
+ * Server-derived attention state. `undefined` when the transport (or an
126
+ * older server) does not report it — {@link deriveConversationAttention}
127
+ * then falls back to the status planes; `null` when the server reports none.
128
+ */
129
+ attention?: ConversationAttention | null;
130
+ /** One line (≤ 80 chars) of what the viewer should do next, when the server derives one. */
131
+ nextAction?: string | null;
132
+ /** Which signal produced `attention` / `nextAction`. */
133
+ attentionSource?: ConversationAttentionSource | null;
134
+ /** Whether the viewer pinned (favorited) the session; `undefined` when not reported. */
135
+ isFavorited?: boolean;
136
+ /**
137
+ * Whether the viewer started the session (`false`: it is shared with them);
138
+ * `undefined` when not reported. Never pushed by the conversation index, so
139
+ * a fold keeps the fetched value.
140
+ */
141
+ createdByMe?: boolean;
142
+ /** The last wake of a resting session; `undefined` when not reported. */
143
+ lastWake?: ConversationWake | null;
144
+ /**
145
+ * Pull requests the session opened with their live GitHub state. `[]` when
146
+ * it opened none, `null` when the state could not be read right now,
147
+ * `undefined` when the transport did not ask for (or report) it.
148
+ */
149
+ pullRequests?: ConversationPullRequest[] | null;
150
+ }
151
+ /**
152
+ * The canonical filter set. Semantics are defined here once; each fetcher
153
+ * translates the fields its transport supports and throws on the rest.
154
+ */
155
+ export interface ConversationListFilter {
156
+ /** Exact-match client app filter; unset = all apps (SESSION_APP_ID_GUIDE). */
157
+ appId?: string;
158
+ /**
159
+ * Sessions of any of these client apps too, a union with `appId` (REST thread
160
+ * list only today). A host lists an earlier app's sessions beside its own.
161
+ */
162
+ appIds?: readonly string[];
163
+ /** Asset types to include (e.g. ['session']); unset = all session types. */
164
+ assetTypes?: readonly string[];
165
+ /** Case-insensitive title search. */
166
+ search?: string;
167
+ /** Hide triggered/background sessions (REST thread list only today). */
168
+ excludeTriggered?: boolean;
169
+ /** Start-channel filter (v0 sessions / REST thread list only today). */
170
+ sourceChannels?: readonly string[];
171
+ /** Start channels to hide (e.g. ['api']); GraphQL `listConversations` only today. */
172
+ excludeSourceChannels?: readonly string[];
173
+ /** Exact computer asset whose sandbox started the session; GraphQL `listConversations` only today. */
174
+ computerAssetId?: string;
175
+ /** Only the sub-sessions of this session asset id; GraphQL `listConversations` only today. */
176
+ parentSessionId?: string;
177
+ /**
178
+ * Lifecycle-state filter (e.g. ['running'], ['completed']). Transports match
179
+ * it with the shared status_v2 rule (running carries a 12-hour recency cutoff).
180
+ */
181
+ states?: readonly string[];
182
+ /** Restrict to sessions run by any of these agents (athena_metadata.agent). */
183
+ agentIds?: readonly string[];
184
+ /**
185
+ * Include branched sub-sessions and orchestration children, which every list
186
+ * hides by default because they belong under their parent thread.
187
+ */
188
+ includeSubSessions?: boolean;
189
+ }
190
+ export interface ConversationListPage {
191
+ /** Rows in contract order (updatedAt desc). */
192
+ items: ConversationSummary[];
193
+ /** Whether another `offset + limit` scan would return more rows. */
194
+ hasMore: boolean;
195
+ /** Total matching rows, or null when the transport does not count. */
196
+ totalCount: number | null;
197
+ }
198
+ export interface ConversationListFetchParams {
199
+ limit: number;
200
+ offset: number;
201
+ filter: ConversationListFilter;
202
+ signal?: AbortSignal;
203
+ }
204
+ /**
205
+ * One page fetch against some transport (GraphQL `listConversations`, the
206
+ * REST thread list, …). Must reject on filter fields it cannot express.
207
+ */
208
+ export type ConversationListFetcher = (params: ConversationListFetchParams) => Promise<ConversationListPage>;
209
+ /** Root of every conversation-list query key (all surfaces, all filters). */
210
+ export declare const CONVERSATION_LIST_QUERY_KEY_ROOT = "athena-conversation-list";
211
+ /**
212
+ * Scope used by `useConversationList` when the caller passes no `scopeKey`.
213
+ * Exported so cache seeders (e.g. Olympus's spacesBootstrap adoption) can
214
+ * address the exact keys default-scoped hooks read from.
215
+ */
216
+ export declare const CONVERSATION_LIST_DEFAULT_SCOPE_KEY = "default";
217
+ /**
218
+ * Normalize a filter to its semantic content: unset/empty fields are dropped
219
+ * (so `{}` and `{ appId: undefined }` are the same filter) and array order is
220
+ * canonicalized. Fetchers receive the normalized form, so what a cache entry
221
+ * claims to hold is exactly what was fetched.
222
+ */
223
+ export declare function normalizeConversationListFilter(filter: ConversationListFilter): ConversationListFilter;
224
+ /**
225
+ * THE running rule for every conversation-list surface (sidebar pane, recent
226
+ * dropdown, workspace section, pushed index rows): the canonical status_v2 run
227
+ * status when the transport reports one, else the legacy `state`. A session
228
+ * paused on a human gate (`needs_input`) is not running.
229
+ */
230
+ export declare function isConversationRunning(summary: {
231
+ runStatus?: string | null;
232
+ state?: string | null;
233
+ }): boolean;
234
+ /**
235
+ * THE attention rule for every session-list surface: the server-derived
236
+ * `attention` when the transport reports one it knows, else a client fallback
237
+ * from the status planes so an older server still yields the two states a
238
+ * list cannot do without — a human gate reads as `needs_you`, a live run as
239
+ * `working`, a failed run as `error`. `null` when nothing applies.
240
+ */
241
+ export declare function deriveConversationAttention(summary: Pick<ConversationSummary, 'attention' | 'runStatus' | 'sessionStatus' | 'state'>): ConversationAttention | null;
242
+ /**
243
+ * Stable cache identity for a filter: the normalized fields serialized in
244
+ * sorted key order, so semantically equal filters share one cache entry.
245
+ */
246
+ export declare function conversationListFilterKey(filter: ConversationListFilter): string;
247
+ /**
248
+ * Query keys for the two-tier pager. `scopeKey` isolates caches beyond the
249
+ * filter — surfaces MUST include everything that changes whose list this is
250
+ * (principal/user id, backend base URL) so a credential swap can never read
251
+ * another identity's rows out of the cache.
252
+ *
253
+ * `pageSize` is part of the key because it is baked into every cached page's
254
+ * offset boundaries: two hooks sharing a scope and filter but paging by
255
+ * different sizes would otherwise reuse each other's incompatible boundaries
256
+ * and skip or duplicate rows.
257
+ */
258
+ export declare const conversationListQueryKeys: {
259
+ root: readonly ["athena-conversation-list"];
260
+ scope: (scopeKey: string) => readonly ["athena-conversation-list", string];
261
+ firstPage: (scopeKey: string, filterKey: string, pageSize: number) => readonly ["athena-conversation-list", string, string, number, 'first-page'];
262
+ history: (scopeKey: string, filterKey: string, pageSize: number) => readonly ["athena-conversation-list", string, string, number, 'history'];
263
+ };
264
+ /**
265
+ * Flatten pages into one newest-first list, deduplicating by `threadId`.
266
+ * The live first page wins over retained history copies of the same thread.
267
+ */
268
+ export declare function mergeConversationPages(pages: readonly ConversationListPage[]): ConversationSummary[];
269
+ /**
270
+ * Prepend a conversation to a page unless its thread is already present
271
+ * (optimistic "new thread appears at the top" write). Identity-preserving
272
+ * no-op when present, so equal writes never notify subscribers.
273
+ */
274
+ export declare function prependConversationToPage(page: ConversationListPage, item: ConversationSummary): ConversationListPage;
275
+ /** Remove a thread's row from a page; identity-preserving when absent. */
276
+ export declare function removeConversationFromPage(page: ConversationListPage, threadId: string): ConversationListPage;
277
+ /**
278
+ * Patch every row matching `match`; identity-preserving when nothing matches
279
+ * so cache writes cannot cause spurious re-renders.
280
+ */
281
+ export declare function patchConversationsInPage(page: ConversationListPage, match: (item: ConversationSummary) => boolean, patch: Partial<ConversationSummary>): ConversationListPage;
282
+ interface ConversationListCacheScope {
283
+ /** Restrict to one scope; omitted = every conversation-list cache. */
284
+ scopeKey?: string;
285
+ }
286
+ /**
287
+ * Invalidate conversation-list caches (all filters, first page + history).
288
+ * This is the hook for push signals — the conversation-index statewire, a
289
+ * finished run, an archive/restore — anything that changed the server list.
290
+ */
291
+ export declare function invalidateConversationListCaches(queryClient: QueryClient, options?: ConversationListCacheScope): Promise<void>;
292
+ /** Cancel in-flight list fetches so an optimistic write cannot be overwritten. */
293
+ export declare function cancelConversationListCaches(queryClient: QueryClient, options?: ConversationListCacheScope): Promise<void>;
294
+ /**
295
+ * Patch matching rows in every cached conversation list (first pages, history
296
+ * pages, searches) so per-row state (read receipts, titles) flips in the same
297
+ * frame as the interaction instead of after the next refetch.
298
+ */
299
+ export declare function patchConversationListCaches(queryClient: QueryClient, options: ConversationListCacheScope & {
300
+ match: (item: ConversationSummary) => boolean;
301
+ patch: Partial<ConversationSummary>;
302
+ }): void;
303
+ /** Remove a thread's row from every cached conversation list in scope. */
304
+ export declare function removeConversationFromListCaches(queryClient: QueryClient, options: ConversationListCacheScope & {
305
+ threadId: string;
306
+ }): void;
307
+ /**
308
+ * Project one replicated conversation-index row onto the shared summary shape.
309
+ * Fields the index never carries (`createdAt`) and viewer-specific fields a
310
+ * lifecycle publish cannot know (`is_unread: null`) keep the row's previous
311
+ * value. Canonical status is taken from the entry when the publishing pod
312
+ * reports it; a snapshot from a pod that predates the fields falls back to the
313
+ * legacy `state` (null status) rather than keeping a stale run status.
314
+ *
315
+ * Attention fields (`attention`, `next_action`, `attention_source`,
316
+ * `is_favorited`) are taken from the entry when the publishing pod reports
317
+ * them, so a live push flips a row to "needs you" the way it renames it; a
318
+ * pod that predates them leaves the row's previous values. Pull-request state,
319
+ * the last wake and `createdByMe` are never pushed and always keep the fetched
320
+ * value.
321
+ */
322
+ export declare function summaryFromConversationIndexEntry(entry: ConversationIndexEntry, previous?: ConversationSummary): ConversationSummary;
323
+ /**
324
+ * Fold the user's replicated conversation index (the newest-page window the
325
+ * per-user statewire pushes) into a cached live first page, so a thread
326
+ * created, renamed, finished, or read anywhere updates every list surface in
327
+ * the same frame — without refetching the page.
328
+ *
329
+ * - Rows in the window are upserted (new threads appear, existing rows take
330
+ * the pushed fields, see {@link summaryFromConversationIndexEntry}).
331
+ * - Rows NOT in the window but at least as new as the window's oldest row
332
+ * should have been in it, so they left the list (archived, hidden, shared
333
+ * away) and are dropped. Older rows are beyond the window and are kept.
334
+ * - When the index reports no further rows (`indexHasMore === false`) the
335
+ * window IS the whole list, so every row outside it is dropped.
336
+ *
337
+ * Newest-first ordering is restored and the page identity is preserved when
338
+ * nothing changed, so an equal push never notifies subscribers.
339
+ */
340
+ export declare function mergeConversationIndexIntoPage(page: ConversationListPage, entries: readonly ConversationIndexEntry[], options: {
341
+ indexHasMore: boolean;
342
+ }): ConversationListPage;
343
+ export {};
@@ -20,7 +20,8 @@ function createDeepAgentAttachTransport({
20
20
  onAuthResolve,
21
21
  onAttachTiming,
22
22
  retryGate = statewireAttachObserver.attachRetryGate,
23
- messageWindow: messageWindow$1
23
+ messageWindow: messageWindow$1,
24
+ laneHistory = false
24
25
  }) {
25
26
  const url = deepAgentThreadUrl({ baseUrl, threadId });
26
27
  const useSse = statewireTransport.resolveStatewireTransportKind({ sse }) === "sse";
@@ -37,7 +38,7 @@ function createDeepAgentAttachTransport({
37
38
  await retryGate.waitForDial(url);
38
39
  onAuthResolve == null ? void 0 : onAuthResolve(ctx);
39
40
  return messageWindow.withDeclaredMessageWindow(
40
- protocol.withDeclaredProtocolVersion(await headers(ctx)),
41
+ protocol.withDeclaredProtocolVersion(await headers(ctx), { laneHistory }),
41
42
  messageWindow$1
42
43
  );
43
44
  },
@@ -1 +1 @@
1
- {"version":3,"file":"deep-agent-transport-recipe.cjs","sources":["../../../../agent-runtime/src/deep-agent-transport-recipe.ts"],"sourcesContent":["import type { ResourceElement } from \"@assistant-ui/tap\";\nimport type { Statewire, StatewireClient } from \"statewire\";\nimport {\n type DeepAgentMessageWindowDeclaration,\n withDeclaredMessageWindow,\n} from \"./message-window\";\nimport { withDeclaredProtocolVersion } from \"./protocol\";\nimport {\n attachRetryGate,\n type AttachRetryGate,\n createAttachInstrumentation,\n type DeepAgentAttachTimingEvent,\n type DeepAgentWakeRefusal,\n parseRetryAfterHeaderMs,\n} from \"./statewire-attach-observer\";\nimport {\n resolveStatewireTransportKind,\n statewireTransport,\n type StatewireTransportOptions,\n} from \"./statewire-transport\";\n\n/** Auth-header resolver for the transport; `staleAuth` is true right after an\n * auth rejection, so resolvers that can force-renew should honor it. */\nexport type DeepAgentHeadersResolver = (ctx: {\n staleAuth: boolean;\n}) => Record<string, string> | Promise<Record<string, string>>;\n\n/** The statewire attach URL for a thread: the host's `…/v2/threads` mount plus the id. */\nexport function deepAgentThreadUrl({\n baseUrl,\n threadId,\n}: {\n baseUrl: string;\n threadId: string;\n}): string {\n return `${baseUrl.replace(/\\/+$/, \"\")}/${encodeURIComponent(threadId)}`;\n}\n\nexport interface DeepAgentAttachTransportOptions {\n /** Base URL of the deep-agent statewire host (the `…/v2/threads` mount). */\n baseUrl: string;\n threadId: string;\n headers: DeepAgentHeadersResolver;\n /** SSE when true, WebSocket otherwise (`resolveStatewireTransportKind`). */\n sse?: boolean;\n /** A never-started chat: the transport makes no network calls until the first command send. */\n isNew?: boolean;\n /** Host session store (mobile); browser hosts mount `storage.session` on the thread instead. */\n sessionStore?: StatewireClient.SessionStorage | undefined;\n /** Observes every headers resolve (the diagnostics recorder's stale-auth seam). */\n onAuthResolve?: ((ctx: { staleAuth: boolean }) => void) | undefined;\n /** Attach timing + retry hints (see `statewire-attach-observer`). */\n onAttachTiming?: ((event: DeepAgentAttachTimingEvent) => void) | undefined;\n /** Dial floors from server retry hints; the process-wide gate by default. */\n retryGate?: AttachRetryGate;\n /**\n * The head window declared on the attach (`x-athena-deep-agent-window`,\n * see `message-window.ts`): the hello of a client the host does not\n * remember carries the newest `size` messages. Part of the recipe so a\n * pooled dial asks for the same shape as the thread's own attach — a pooled\n * hello then seeds the very state the attach will reconcile. Omitted, the\n * shared default is declared.\n */\n messageWindow?: DeepAgentMessageWindowDeclaration | undefined;\n}\n\n/**\n * The ONE recipe for a deep-agent thread transport — shared by the mounted\n * thread (`useDeepAgentThread`) and the prewarm pool, so a pre-dialed\n * connection is byte-for-byte the connection the thread would have opened\n * itself: same URL, same auth + wire-contract headers, same session lane, same\n * instrumentation.\n *\n * Every attach declares this build's wire-contract version alongside the\n * host's auth headers (first WS frame / SSE request headers) — the server\n * half of version negotiation reads it in `authorize`. The headers resolve\n * also waits out any server `Retry-After` floor for the thread: both statewire\n * attach paths resolve headers before they dial, so this is the seam where a\n * hint can hold the next dial without touching the library's backoff.\n */\nexport function createDeepAgentAttachTransport<TState = unknown>({\n baseUrl,\n threadId,\n headers,\n sse = false,\n isNew = false,\n sessionStore,\n onAuthResolve,\n onAttachTiming,\n retryGate = attachRetryGate,\n messageWindow,\n}: DeepAgentAttachTransportOptions): ResourceElement<\n Statewire<TState | undefined>\n> {\n const url = deepAgentThreadUrl({ baseUrl, threadId });\n // The instrumentation wraps the transport actually built: SSE needs the\n // fetch wrapper that reads a refused attach's `Retry-After`.\n const useSse = resolveStatewireTransportKind({ sse }) === \"sse\";\n const instrumentation = createAttachInstrumentation({\n url,\n sse: useSse,\n onEvent: onAttachTiming,\n retryGate,\n });\n const options: StatewireTransportOptions = {\n url,\n ...(isNew && { isNew: true }),\n headers: async (ctx: { staleAuth: boolean }) => {\n await retryGate.waitForDial(url);\n onAuthResolve?.(ctx);\n return withDeclaredMessageWindow(\n withDeclaredProtocolVersion(await headers(ctx)),\n messageWindow,\n );\n },\n ...(sessionStore && { sessionStore }),\n // Structural types: this package compiles without the DOM lib, while\n // statewire's option types name the browser `WebSocket`/`fetch`.\n ...(instrumentation.webSocket && {\n webSocket:\n instrumentation.webSocket as unknown as StatewireTransportOptions[\"webSocket\"],\n }),\n ...(instrumentation.fetch && {\n fetch:\n instrumentation.fetch as unknown as StatewireTransportOptions[\"fetch\"],\n }),\n };\n return statewireTransport<TState>(options, { sse: useSse });\n}\n\n/** What `POST …/prewarm` answered. */\nexport interface DeepAgentWakeResult {\n status: number;\n /** The host activated the thread and its history is resident. */\n warm: boolean;\n /**\n * `'warm'` when the history was already memoized, `'fresh_load'` when this\n * call loaded it; `null` when the host did not say (a refusal, or a host\n * without the route).\n */\n history: \"fresh_load\" | \"warm\" | null;\n /**\n * The dial floor recorded for the thread off a 503/429 `Retry-After` — the\n * header's value, except a 503 `\"worker\"` refusal, capped at\n * {@link WAKE_WORKER_REFUSAL_FLOOR_MS}.\n */\n retryAfterMs: number | null;\n /** Who refused a 503/429 (see {@link DeepAgentWakeRefusal}); `null` for any other answer. */\n refusal: DeepAgentWakeRefusal;\n durationMs: number;\n}\n\n/**\n * Dial floor for a 503 the pinned worker produced about one instance's\n * lifecycle. Pinned answers every retriable 503 with a blanket\n * `Retry-After: 1`, but what those name — an instance record mid-teardown\n * (\"instance closing; retry\": fence release + placement release, ≈100 ms), a\n * full activation queue — clears far sooner than that, and the thread's own\n * attach is the request that carries the next activation. Holding it a full\n * second traded a ≈100 ms gap for a ≈1 s stall on every refused wake. A 429\n * is rate limiting and keeps its hint whatever the body says.\n */\nexport const WAKE_WORKER_REFUSAL_FLOOR_MS = 250;\n\n/**\n * The pinboard's own placement-refusal vocabulary — the `error` strings of\n * `@assistant-ui/pinboard` (`src/refusals.ts` plus the two inline refusals in\n * `src/server.ts`). Mirrors `PINBOARD_PLACEMENT_REFUSAL_ERRORS` in\n * `iris/scaler/src/v2AccessLog.ts`, whose test pins it to the installed\n * library; keep the two lists identical. A body with any other `error`\n * string is `\"unknown\"`, never `\"placement\"`.\n */\nexport const PINBOARD_PLACEMENT_REFUSAL_ERRORS: ReadonlySet<string> = new Set([\n \"no live backends for namespace\",\n \"registry cold start, retry\",\n \"not the serving fleet\",\n \"no live workers for hostname\",\n \"hostname binding displaced, retry\",\n \"hostname bindings inconsistent, retry\",\n \"takeover in progress, retry\",\n \"placement held by another hostname\",\n \"worker inflight cap exceeded, retry\",\n \"worker refused activation, retry\",\n]);\n\n/**\n * Pinned's instance-lifecycle refusals (`pinned/hosting/directory.py`,\n * `pinned/hosting/_records.py`): each names one instance on the worker the\n * thread is already placed on and clears in the time a teardown or an\n * activation slot takes. Anything else the worker answers 503 with — \"Thread\n * history load failed\", \"The regional conversation store is temporarily\n * unavailable\", a lease that expired — is not about one instance and keeps\n * the full hint.\n */\nexport const PINNED_TRANSIENT_WORKER_REFUSALS: ReadonlySet<string> = new Set([\n \"instance closing; retry\",\n \"instance aborted\",\n \"activation queue full; retry\",\n \"host draining; retry\",\n \"instance capacity reached; retry\",\n \"instance past its wind-down deadline; retry\",\n]);\n\n/**\n * Classify a 503/429 body (see {@link DeepAgentWakeRefusal}): a known pinboard\n * `error` is `\"placement\"`, a known pinned `detail` is `\"worker\"`, everything\n * else — including unfamiliar strings in either field — is `\"unknown\"`.\n */\nexport function classifyWakeRefusal(\n body: unknown,\n): Exclude<DeepAgentWakeRefusal, null> {\n if (typeof body === \"object\" && body !== null) {\n const record = body as Record<string, unknown>;\n if (\n typeof record.error === \"string\" &&\n PINBOARD_PLACEMENT_REFUSAL_ERRORS.has(record.error)\n ) {\n return \"placement\";\n }\n if (\n typeof record.detail === \"string\" &&\n PINNED_TRANSIENT_WORKER_REFUSALS.has(record.detail)\n ) {\n return \"worker\";\n }\n }\n return \"unknown\";\n}\n\n/** Structural `fetch` for the wake call — this package compiles without the DOM lib. */\nexport type DeepAgentWakeFetch = (\n input: string,\n init?: {\n method?: string;\n headers?: Record<string, string>;\n keepalive?: boolean;\n },\n) => Promise<{\n ok: boolean;\n status: number;\n headers: { get(name: string): string | null };\n json(): Promise<unknown>;\n}>;\n\nexport interface DeepAgentWakeOptions {\n /** Base URL of the deep-agent statewire host (the `…/v2/threads` mount). */\n baseUrl: string;\n threadId: string;\n headers: DeepAgentHeadersResolver;\n fetch?: DeepAgentWakeFetch | undefined;\n /** Dial floors from server retry hints; the process-wide gate by default. */\n retryGate?: AttachRetryGate;\n onAttachTiming?: ((event: DeepAgentAttachTimingEvent) => void) | undefined;\n now?: () => number;\n}\n\n/**\n * Wake a thread's server instance ahead of its attach. `POST …/prewarm` runs\n * the host's `authorize` and history load — the fence adopt, graph compile and\n * checkpoint read that make a cold attach's hello take ≈1 s — and answers with\n * no thread content, only whether the history was already resident. Fire it\n * on hover intent, before a pooled attach or the click's own dial, so the\n * activation overlaps the handshake and the attach that follows finds the\n * instance warm.\n *\n * Fire-and-forget by contract: every failure resolves `null`, and a host\n * without the route (404) is reported like any other non-OK answer. A 503/429\n * `Retry-After` is recorded as a dial floor for the thread, so the attach that\n * follows waits it out instead of bouncing — in full, except a 503 that names\n * one of pinned's instance-lifecycle refusals (one instance mid-teardown on\n * the worker the thread already has; see {@link DeepAgentWakeRefusal}), whose\n * floor is capped at {@link WAKE_WORKER_REFUSAL_FLOOR_MS}.\n */\nexport async function wakeDeepAgentThread({\n baseUrl,\n threadId,\n headers,\n fetch: fetchOverride,\n retryGate = attachRetryGate,\n onAttachTiming,\n now = () => Date.now(),\n}: DeepAgentWakeOptions): Promise<DeepAgentWakeResult | null> {\n const fetchImpl =\n fetchOverride ?? (globalThis as { fetch?: DeepAgentWakeFetch }).fetch;\n if (typeof fetchImpl !== \"function\") return null;\n const threadUrl = deepAgentThreadUrl({ baseUrl, threadId });\n const emit = (event: DeepAgentAttachTimingEvent): void => {\n try {\n onAttachTiming?.(event);\n } catch {\n // Observers are best-effort.\n }\n };\n const startedAt = now();\n try {\n const resolved = withDeclaredProtocolVersion(\n await headers({ staleAuth: false }),\n );\n const response = await fetchImpl(`${threadUrl}/prewarm`, {\n method: \"POST\",\n headers: resolved,\n keepalive: true,\n });\n const durationMs = now() - startedAt;\n let retryAfterMs: number | null = null;\n let refusal: DeepAgentWakeRefusal = null;\n if (response.status === 503 || response.status === 429) {\n let body: unknown = null;\n try {\n body = await response.json();\n } catch {\n // A refusal without a readable body is classified by nothing.\n }\n refusal = classifyWakeRefusal(body);\n const hinted = parseRetryAfterHeaderMs(\n response.headers.get(\"retry-after\"),\n now,\n );\n if (hinted !== null) {\n retryAfterMs =\n response.status === 503 && refusal === \"worker\"\n ? Math.min(hinted, WAKE_WORKER_REFUSAL_FLOOR_MS)\n : hinted;\n if (retryAfterMs > 0) {\n retryGate.noteRetryAfter(threadUrl, retryAfterMs);\n emit({\n type: \"retry-after\",\n url: threadUrl,\n delayMs: retryAfterMs,\n source: \"http-header\",\n });\n }\n }\n }\n let warm = false;\n let history: DeepAgentWakeResult[\"history\"] = null;\n if (response.ok) {\n try {\n const body = (await response.json()) as {\n warm?: unknown;\n history?: unknown;\n } | null;\n warm = body?.warm === true;\n history =\n body?.history === \"warm\" || body?.history === \"fresh_load\"\n ? body.history\n : null;\n } catch {\n // A 200 without a JSON body still means the instance is up.\n warm = true;\n }\n }\n emit({\n type: \"wake\",\n url: threadUrl,\n status: response.status,\n durationMs,\n history,\n refusal,\n });\n return {\n status: response.status,\n warm,\n history,\n retryAfterMs,\n refusal,\n durationMs,\n };\n } catch {\n return null;\n }\n}\n"],"names":["attachRetryGate","messageWindow","resolveStatewireTransportKind","createAttachInstrumentation","withDeclaredMessageWindow","withDeclaredProtocolVersion","statewireTransport"],"mappings":";;;;;;AA4BO,SAAS,mBAAmB;AAAA,EACjC;AAAA,EACA;AACF,GAGW;AACT,SAAO,GAAG,QAAQ,QAAQ,QAAQ,EAAE,CAAC,IAAI,mBAAmB,QAAQ,CAAC;AACvE;AA4CO,SAAS,+BAAiD;AAAA,EAC/D;AAAA,EACA;AAAA,EACA;AAAA,EACA,MAAM;AAAA,EACN,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAYA,wBAAAA;AAAAA,EAAA,eACZC;AACF,GAEE;AACA,QAAM,MAAM,mBAAmB,EAAE,SAAS,UAAU;AAGpD,QAAM,SAASC,mBAAAA,8BAA8B,EAAE,IAAA,CAAK,MAAM;AAC1D,QAAM,kBAAkBC,wBAAAA,4BAA4B;AAAA,IAClD;AAAA,IACA,KAAK;AAAA,IACL,SAAS;AAAA,IACT;AAAA,EAAA,CACD;AACD,QAAM,UAAqC;AAAA,IACzC;AAAA,IACA,GAAI,SAAS,EAAE,OAAO,KAAA;AAAA,IACtB,SAAS,OAAO,QAAgC;AAC9C,YAAM,UAAU,YAAY,GAAG;AAC/B,qDAAgB;AAChB,aAAOC,cAAAA;AAAAA,QACLC,qCAA4B,MAAM,QAAQ,GAAG,CAAC;AAAA,QAC9CJ;AAAAA,MAAA;AAAA,IAEJ;AAAA,IACA,GAAI,gBAAgB,EAAE,aAAA;AAAA;AAAA;AAAA,IAGtB,GAAI,gBAAgB,aAAa;AAAA,MAC/B,WACE,gBAAgB;AAAA,IAAA;AAAA,IAEpB,GAAI,gBAAgB,SAAS;AAAA,MAC3B,OACE,gBAAgB;AAAA,IAAA;AAAA,EACpB;AAEF,SAAOK,mBAAAA,mBAA2B,SAAS,EAAE,KAAK,QAAQ;AAC5D;;;"}
1
+ {"version":3,"file":"deep-agent-transport-recipe.cjs","sources":["../../../../agent-runtime/src/deep-agent-transport-recipe.ts"],"sourcesContent":["import type { ResourceElement } from \"@assistant-ui/tap\";\nimport type { Statewire, StatewireClient } from \"statewire\";\nimport {\n type DeepAgentMessageWindowDeclaration,\n withDeclaredMessageWindow,\n} from \"./message-window\";\nimport { withDeclaredProtocolVersion } from \"./protocol\";\nimport {\n attachRetryGate,\n type AttachRetryGate,\n createAttachInstrumentation,\n type DeepAgentAttachTimingEvent,\n type DeepAgentWakeRefusal,\n parseRetryAfterHeaderMs,\n} from \"./statewire-attach-observer\";\nimport {\n resolveStatewireTransportKind,\n statewireTransport,\n type StatewireTransportOptions,\n} from \"./statewire-transport\";\n\n/** Auth-header resolver for the transport; `staleAuth` is true right after an\n * auth rejection, so resolvers that can force-renew should honor it. */\nexport type DeepAgentHeadersResolver = (ctx: {\n staleAuth: boolean;\n}) => Record<string, string> | Promise<Record<string, string>>;\n\n/** The statewire attach URL for a thread: the host's `…/v2/threads` mount plus the id. */\nexport function deepAgentThreadUrl({\n baseUrl,\n threadId,\n}: {\n baseUrl: string;\n threadId: string;\n}): string {\n return `${baseUrl.replace(/\\/+$/, \"\")}/${encodeURIComponent(threadId)}`;\n}\n\nexport interface DeepAgentAttachTransportOptions {\n /** Base URL of the deep-agent statewire host (the `…/v2/threads` mount). */\n baseUrl: string;\n threadId: string;\n headers: DeepAgentHeadersResolver;\n /** SSE when true, WebSocket otherwise (`resolveStatewireTransportKind`). */\n sse?: boolean;\n /** A never-started chat: the transport makes no network calls until the first command send. */\n isNew?: boolean;\n /** Host session store (mobile); browser hosts mount `storage.session` on the thread instead. */\n sessionStore?: StatewireClient.SessionStorage | undefined;\n /** Observes every headers resolve (the diagnostics recorder's stale-auth seam). */\n onAuthResolve?: ((ctx: { staleAuth: boolean }) => void) | undefined;\n /** Attach timing + retry hints (see `statewire-attach-observer`). */\n onAttachTiming?: ((event: DeepAgentAttachTimingEvent) => void) | undefined;\n /** Dial floors from server retry hints; the process-wide gate by default. */\n retryGate?: AttachRetryGate;\n /**\n * The head window declared on the attach (`x-athena-deep-agent-window`,\n * see `message-window.ts`): the hello of a client the host does not\n * remember carries the newest `size` messages. Part of the recipe so a\n * pooled dial asks for the same shape as the thread's own attach — a pooled\n * hello then seeds the very state the attach will reconcile. Omitted, the\n * shared default is declared.\n */\n messageWindow?: DeepAgentMessageWindowDeclaration | undefined;\n /**\n * The surface pages cut lanes (see `DeepAgentProtocolDeclaration`), so its\n * attach declares the lane-cut contract version. Part of the recipe so a\n * pooled dial declares what the thread's own attach would; omitted, the\n * default version is declared.\n */\n laneHistory?: boolean | undefined;\n}\n\n/**\n * The ONE recipe for a deep-agent thread transport — shared by the mounted\n * thread (`useDeepAgentThread`) and the prewarm pool, so a pre-dialed\n * connection is byte-for-byte the connection the thread would have opened\n * itself: same URL, same auth + wire-contract headers, same session lane, same\n * instrumentation.\n *\n * Every attach declares the surface's wire-contract version alongside the\n * host's auth headers (first WS frame / SSE request headers) — the server\n * half of version negotiation reads it in `authorize`. The headers resolve\n * also waits out any server `Retry-After` floor for the thread: both statewire\n * attach paths resolve headers before they dial, so this is the seam where a\n * hint can hold the next dial without touching the library's backoff.\n */\nexport function createDeepAgentAttachTransport<TState = unknown>({\n baseUrl,\n threadId,\n headers,\n sse = false,\n isNew = false,\n sessionStore,\n onAuthResolve,\n onAttachTiming,\n retryGate = attachRetryGate,\n messageWindow,\n laneHistory = false,\n}: DeepAgentAttachTransportOptions): ResourceElement<\n Statewire<TState | undefined>\n> {\n const url = deepAgentThreadUrl({ baseUrl, threadId });\n // The instrumentation wraps the transport actually built: SSE needs the\n // fetch wrapper that reads a refused attach's `Retry-After`.\n const useSse = resolveStatewireTransportKind({ sse }) === \"sse\";\n const instrumentation = createAttachInstrumentation({\n url,\n sse: useSse,\n onEvent: onAttachTiming,\n retryGate,\n });\n const options: StatewireTransportOptions = {\n url,\n ...(isNew && { isNew: true }),\n headers: async (ctx: { staleAuth: boolean }) => {\n await retryGate.waitForDial(url);\n onAuthResolve?.(ctx);\n return withDeclaredMessageWindow(\n withDeclaredProtocolVersion(await headers(ctx), { laneHistory }),\n messageWindow,\n );\n },\n ...(sessionStore && { sessionStore }),\n // Structural types: this package compiles without the DOM lib, while\n // statewire's option types name the browser `WebSocket`/`fetch`.\n ...(instrumentation.webSocket && {\n webSocket:\n instrumentation.webSocket as unknown as StatewireTransportOptions[\"webSocket\"],\n }),\n ...(instrumentation.fetch && {\n fetch:\n instrumentation.fetch as unknown as StatewireTransportOptions[\"fetch\"],\n }),\n };\n return statewireTransport<TState>(options, { sse: useSse });\n}\n\n/** What `POST …/prewarm` answered. */\nexport interface DeepAgentWakeResult {\n status: number;\n /** The host activated the thread and its history is resident. */\n warm: boolean;\n /**\n * `'warm'` when the history was already memoized, `'fresh_load'` when this\n * call loaded it; `null` when the host did not say (a refusal, or a host\n * without the route).\n */\n history: \"fresh_load\" | \"warm\" | null;\n /**\n * The dial floor recorded for the thread off a 503/429 `Retry-After` — the\n * header's value, except a 503 `\"worker\"` refusal, capped at\n * {@link WAKE_WORKER_REFUSAL_FLOOR_MS}.\n */\n retryAfterMs: number | null;\n /** Who refused a 503/429 (see {@link DeepAgentWakeRefusal}); `null` for any other answer. */\n refusal: DeepAgentWakeRefusal;\n durationMs: number;\n}\n\n/**\n * Dial floor for a 503 the pinned worker produced about one instance's\n * lifecycle. Pinned answers every retriable 503 with a blanket\n * `Retry-After: 1`, but what those name — an instance record mid-teardown\n * (\"instance closing; retry\": fence release + placement release, ≈100 ms), a\n * full activation queue — clears far sooner than that, and the thread's own\n * attach is the request that carries the next activation. Holding it a full\n * second traded a ≈100 ms gap for a ≈1 s stall on every refused wake. A 429\n * is rate limiting and keeps its hint whatever the body says.\n */\nexport const WAKE_WORKER_REFUSAL_FLOOR_MS = 250;\n\n/**\n * The pinboard's own placement-refusal vocabulary — the `error` strings of\n * `@assistant-ui/pinboard` (`src/refusals.ts` plus the two inline refusals in\n * `src/server.ts`). Mirrors `PINBOARD_PLACEMENT_REFUSAL_ERRORS` in\n * `iris/scaler/src/v2AccessLog.ts`, whose test pins it to the installed\n * library; keep the two lists identical. A body with any other `error`\n * string is `\"unknown\"`, never `\"placement\"`.\n */\nexport const PINBOARD_PLACEMENT_REFUSAL_ERRORS: ReadonlySet<string> = new Set([\n \"no live backends for namespace\",\n \"registry cold start, retry\",\n \"not the serving fleet\",\n \"no live workers for hostname\",\n \"hostname binding displaced, retry\",\n \"hostname bindings inconsistent, retry\",\n \"takeover in progress, retry\",\n \"placement held by another hostname\",\n \"worker inflight cap exceeded, retry\",\n \"worker refused activation, retry\",\n]);\n\n/**\n * Pinned's instance-lifecycle refusals (`pinned/hosting/directory.py`,\n * `pinned/hosting/_records.py`): each names one instance on the worker the\n * thread is already placed on and clears in the time a teardown or an\n * activation slot takes. Anything else the worker answers 503 with — \"Thread\n * history load failed\", \"The regional conversation store is temporarily\n * unavailable\", a lease that expired — is not about one instance and keeps\n * the full hint.\n */\nexport const PINNED_TRANSIENT_WORKER_REFUSALS: ReadonlySet<string> = new Set([\n \"instance closing; retry\",\n \"instance aborted\",\n \"activation queue full; retry\",\n \"host draining; retry\",\n \"instance capacity reached; retry\",\n \"instance past its wind-down deadline; retry\",\n]);\n\n/**\n * Classify a 503/429 body (see {@link DeepAgentWakeRefusal}): a known pinboard\n * `error` is `\"placement\"`, a known pinned `detail` is `\"worker\"`, everything\n * else — including unfamiliar strings in either field — is `\"unknown\"`.\n */\nexport function classifyWakeRefusal(\n body: unknown,\n): Exclude<DeepAgentWakeRefusal, null> {\n if (typeof body === \"object\" && body !== null) {\n const record = body as Record<string, unknown>;\n if (\n typeof record.error === \"string\" &&\n PINBOARD_PLACEMENT_REFUSAL_ERRORS.has(record.error)\n ) {\n return \"placement\";\n }\n if (\n typeof record.detail === \"string\" &&\n PINNED_TRANSIENT_WORKER_REFUSALS.has(record.detail)\n ) {\n return \"worker\";\n }\n }\n return \"unknown\";\n}\n\n/** Structural `fetch` for the wake call — this package compiles without the DOM lib. */\nexport type DeepAgentWakeFetch = (\n input: string,\n init?: {\n method?: string;\n headers?: Record<string, string>;\n keepalive?: boolean;\n },\n) => Promise<{\n ok: boolean;\n status: number;\n headers: { get(name: string): string | null };\n json(): Promise<unknown>;\n}>;\n\nexport interface DeepAgentWakeOptions {\n /** Base URL of the deep-agent statewire host (the `…/v2/threads` mount). */\n baseUrl: string;\n threadId: string;\n headers: DeepAgentHeadersResolver;\n fetch?: DeepAgentWakeFetch | undefined;\n /** Dial floors from server retry hints; the process-wide gate by default. */\n retryGate?: AttachRetryGate;\n onAttachTiming?: ((event: DeepAgentAttachTimingEvent) => void) | undefined;\n now?: () => number;\n /** The surface pages cut lanes: declare what its attach declares (see `DeepAgentAttachTransportOptions`). */\n laneHistory?: boolean | undefined;\n}\n\n/**\n * Wake a thread's server instance ahead of its attach. `POST …/prewarm` runs\n * the host's `authorize` and history load — the fence adopt, graph compile and\n * checkpoint read that make a cold attach's hello take ≈1 s — and answers with\n * no thread content, only whether the history was already resident. Fire it\n * on hover intent, before a pooled attach or the click's own dial, so the\n * activation overlaps the handshake and the attach that follows finds the\n * instance warm.\n *\n * Fire-and-forget by contract: every failure resolves `null`, and a host\n * without the route (404) is reported like any other non-OK answer. A 503/429\n * `Retry-After` is recorded as a dial floor for the thread, so the attach that\n * follows waits it out instead of bouncing — in full, except a 503 that names\n * one of pinned's instance-lifecycle refusals (one instance mid-teardown on\n * the worker the thread already has; see {@link DeepAgentWakeRefusal}), whose\n * floor is capped at {@link WAKE_WORKER_REFUSAL_FLOOR_MS}.\n */\nexport async function wakeDeepAgentThread({\n baseUrl,\n threadId,\n headers,\n fetch: fetchOverride,\n retryGate = attachRetryGate,\n onAttachTiming,\n now = () => Date.now(),\n laneHistory = false,\n}: DeepAgentWakeOptions): Promise<DeepAgentWakeResult | null> {\n const fetchImpl =\n fetchOverride ?? (globalThis as { fetch?: DeepAgentWakeFetch }).fetch;\n if (typeof fetchImpl !== \"function\") return null;\n const threadUrl = deepAgentThreadUrl({ baseUrl, threadId });\n const emit = (event: DeepAgentAttachTimingEvent): void => {\n try {\n onAttachTiming?.(event);\n } catch {\n // Observers are best-effort.\n }\n };\n const startedAt = now();\n try {\n const resolved = withDeclaredProtocolVersion(\n await headers({ staleAuth: false }),\n { laneHistory },\n );\n const response = await fetchImpl(`${threadUrl}/prewarm`, {\n method: \"POST\",\n headers: resolved,\n keepalive: true,\n });\n const durationMs = now() - startedAt;\n let retryAfterMs: number | null = null;\n let refusal: DeepAgentWakeRefusal = null;\n if (response.status === 503 || response.status === 429) {\n let body: unknown = null;\n try {\n body = await response.json();\n } catch {\n // A refusal without a readable body is classified by nothing.\n }\n refusal = classifyWakeRefusal(body);\n const hinted = parseRetryAfterHeaderMs(\n response.headers.get(\"retry-after\"),\n now,\n );\n if (hinted !== null) {\n retryAfterMs =\n response.status === 503 && refusal === \"worker\"\n ? Math.min(hinted, WAKE_WORKER_REFUSAL_FLOOR_MS)\n : hinted;\n if (retryAfterMs > 0) {\n retryGate.noteRetryAfter(threadUrl, retryAfterMs);\n emit({\n type: \"retry-after\",\n url: threadUrl,\n delayMs: retryAfterMs,\n source: \"http-header\",\n });\n }\n }\n }\n let warm = false;\n let history: DeepAgentWakeResult[\"history\"] = null;\n if (response.ok) {\n try {\n const body = (await response.json()) as {\n warm?: unknown;\n history?: unknown;\n } | null;\n warm = body?.warm === true;\n history =\n body?.history === \"warm\" || body?.history === \"fresh_load\"\n ? body.history\n : null;\n } catch {\n // A 200 without a JSON body still means the instance is up.\n warm = true;\n }\n }\n emit({\n type: \"wake\",\n url: threadUrl,\n status: response.status,\n durationMs,\n history,\n refusal,\n });\n return {\n status: response.status,\n warm,\n history,\n retryAfterMs,\n refusal,\n durationMs,\n };\n } catch {\n return null;\n }\n}\n"],"names":["attachRetryGate","messageWindow","resolveStatewireTransportKind","createAttachInstrumentation","withDeclaredMessageWindow","withDeclaredProtocolVersion","statewireTransport"],"mappings":";;;;;;AA4BO,SAAS,mBAAmB;AAAA,EACjC;AAAA,EACA;AACF,GAGW;AACT,SAAO,GAAG,QAAQ,QAAQ,QAAQ,EAAE,CAAC,IAAI,mBAAmB,QAAQ,CAAC;AACvE;AAmDO,SAAS,+BAAiD;AAAA,EAC/D;AAAA,EACA;AAAA,EACA;AAAA,EACA,MAAM;AAAA,EACN,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAYA,wBAAAA;AAAAA,EAAA,eACZC;AAAAA,EACA,cAAc;AAChB,GAEE;AACA,QAAM,MAAM,mBAAmB,EAAE,SAAS,UAAU;AAGpD,QAAM,SAASC,mBAAAA,8BAA8B,EAAE,IAAA,CAAK,MAAM;AAC1D,QAAM,kBAAkBC,wBAAAA,4BAA4B;AAAA,IAClD;AAAA,IACA,KAAK;AAAA,IACL,SAAS;AAAA,IACT;AAAA,EAAA,CACD;AACD,QAAM,UAAqC;AAAA,IACzC;AAAA,IACA,GAAI,SAAS,EAAE,OAAO,KAAA;AAAA,IACtB,SAAS,OAAO,QAAgC;AAC9C,YAAM,UAAU,YAAY,GAAG;AAC/B,qDAAgB;AAChB,aAAOC,cAAAA;AAAAA,QACLC,SAAAA,4BAA4B,MAAM,QAAQ,GAAG,GAAG,EAAE,aAAa;AAAA,QAC/DJ;AAAAA,MAAA;AAAA,IAEJ;AAAA,IACA,GAAI,gBAAgB,EAAE,aAAA;AAAA;AAAA;AAAA,IAGtB,GAAI,gBAAgB,aAAa;AAAA,MAC/B,WACE,gBAAgB;AAAA,IAAA;AAAA,IAEpB,GAAI,gBAAgB,SAAS;AAAA,MAC3B,OACE,gBAAgB;AAAA,IAAA;AAAA,EACpB;AAEF,SAAOK,mBAAAA,mBAA2B,SAAS,EAAE,KAAK,QAAQ;AAC5D;;;"}
@@ -0,0 +1,166 @@
1
+ import type { ResourceElement } from "@assistant-ui/tap";
2
+ import type { Statewire, StatewireClient } from "statewire";
3
+ import { type DeepAgentMessageWindowDeclaration } from "./message-window";
4
+ import { type AttachRetryGate, type DeepAgentAttachTimingEvent, type DeepAgentWakeRefusal } from "./statewire-attach-observer";
5
+ /** Auth-header resolver for the transport; `staleAuth` is true right after an
6
+ * auth rejection, so resolvers that can force-renew should honor it. */
7
+ export type DeepAgentHeadersResolver = (ctx: {
8
+ staleAuth: boolean;
9
+ }) => Record<string, string> | Promise<Record<string, string>>;
10
+ /** The statewire attach URL for a thread: the host's `…/v2/threads` mount plus the id. */
11
+ export declare function deepAgentThreadUrl({ baseUrl, threadId, }: {
12
+ baseUrl: string;
13
+ threadId: string;
14
+ }): string;
15
+ export interface DeepAgentAttachTransportOptions {
16
+ /** Base URL of the deep-agent statewire host (the `…/v2/threads` mount). */
17
+ baseUrl: string;
18
+ threadId: string;
19
+ headers: DeepAgentHeadersResolver;
20
+ /** SSE when true, WebSocket otherwise (`resolveStatewireTransportKind`). */
21
+ sse?: boolean;
22
+ /** A never-started chat: the transport makes no network calls until the first command send. */
23
+ isNew?: boolean;
24
+ /** Host session store (mobile); browser hosts mount `storage.session` on the thread instead. */
25
+ sessionStore?: StatewireClient.SessionStorage | undefined;
26
+ /** Observes every headers resolve (the diagnostics recorder's stale-auth seam). */
27
+ onAuthResolve?: ((ctx: {
28
+ staleAuth: boolean;
29
+ }) => void) | undefined;
30
+ /** Attach timing + retry hints (see `statewire-attach-observer`). */
31
+ onAttachTiming?: ((event: DeepAgentAttachTimingEvent) => void) | undefined;
32
+ /** Dial floors from server retry hints; the process-wide gate by default. */
33
+ retryGate?: AttachRetryGate;
34
+ /**
35
+ * The head window declared on the attach (`x-athena-deep-agent-window`,
36
+ * see `message-window.ts`): the hello of a client the host does not
37
+ * remember carries the newest `size` messages. Part of the recipe so a
38
+ * pooled dial asks for the same shape as the thread's own attach — a pooled
39
+ * hello then seeds the very state the attach will reconcile. Omitted, the
40
+ * shared default is declared.
41
+ */
42
+ messageWindow?: DeepAgentMessageWindowDeclaration | undefined;
43
+ /**
44
+ * The surface pages cut lanes (see `DeepAgentProtocolDeclaration`), so its
45
+ * attach declares the lane-cut contract version. Part of the recipe so a
46
+ * pooled dial declares what the thread's own attach would; omitted, the
47
+ * default version is declared.
48
+ */
49
+ laneHistory?: boolean | undefined;
50
+ }
51
+ /**
52
+ * The ONE recipe for a deep-agent thread transport — shared by the mounted
53
+ * thread (`useDeepAgentThread`) and the prewarm pool, so a pre-dialed
54
+ * connection is byte-for-byte the connection the thread would have opened
55
+ * itself: same URL, same auth + wire-contract headers, same session lane, same
56
+ * instrumentation.
57
+ *
58
+ * Every attach declares the surface's wire-contract version alongside the
59
+ * host's auth headers (first WS frame / SSE request headers) — the server
60
+ * half of version negotiation reads it in `authorize`. The headers resolve
61
+ * also waits out any server `Retry-After` floor for the thread: both statewire
62
+ * attach paths resolve headers before they dial, so this is the seam where a
63
+ * hint can hold the next dial without touching the library's backoff.
64
+ */
65
+ export declare function createDeepAgentAttachTransport<TState = unknown>({ baseUrl, threadId, headers, sse, isNew, sessionStore, onAuthResolve, onAttachTiming, retryGate, messageWindow, laneHistory, }: DeepAgentAttachTransportOptions): ResourceElement<Statewire<TState | undefined>>;
66
+ /** What `POST …/prewarm` answered. */
67
+ export interface DeepAgentWakeResult {
68
+ status: number;
69
+ /** The host activated the thread and its history is resident. */
70
+ warm: boolean;
71
+ /**
72
+ * `'warm'` when the history was already memoized, `'fresh_load'` when this
73
+ * call loaded it; `null` when the host did not say (a refusal, or a host
74
+ * without the route).
75
+ */
76
+ history: "fresh_load" | "warm" | null;
77
+ /**
78
+ * The dial floor recorded for the thread off a 503/429 `Retry-After` — the
79
+ * header's value, except a 503 `"worker"` refusal, capped at
80
+ * {@link WAKE_WORKER_REFUSAL_FLOOR_MS}.
81
+ */
82
+ retryAfterMs: number | null;
83
+ /** Who refused a 503/429 (see {@link DeepAgentWakeRefusal}); `null` for any other answer. */
84
+ refusal: DeepAgentWakeRefusal;
85
+ durationMs: number;
86
+ }
87
+ /**
88
+ * Dial floor for a 503 the pinned worker produced about one instance's
89
+ * lifecycle. Pinned answers every retriable 503 with a blanket
90
+ * `Retry-After: 1`, but what those name — an instance record mid-teardown
91
+ * ("instance closing; retry": fence release + placement release, ≈100 ms), a
92
+ * full activation queue — clears far sooner than that, and the thread's own
93
+ * attach is the request that carries the next activation. Holding it a full
94
+ * second traded a ≈100 ms gap for a ≈1 s stall on every refused wake. A 429
95
+ * is rate limiting and keeps its hint whatever the body says.
96
+ */
97
+ export declare const WAKE_WORKER_REFUSAL_FLOOR_MS = 250;
98
+ /**
99
+ * The pinboard's own placement-refusal vocabulary — the `error` strings of
100
+ * `@assistant-ui/pinboard` (`src/refusals.ts` plus the two inline refusals in
101
+ * `src/server.ts`). Mirrors `PINBOARD_PLACEMENT_REFUSAL_ERRORS` in
102
+ * `iris/scaler/src/v2AccessLog.ts`, whose test pins it to the installed
103
+ * library; keep the two lists identical. A body with any other `error`
104
+ * string is `"unknown"`, never `"placement"`.
105
+ */
106
+ export declare const PINBOARD_PLACEMENT_REFUSAL_ERRORS: ReadonlySet<string>;
107
+ /**
108
+ * Pinned's instance-lifecycle refusals (`pinned/hosting/directory.py`,
109
+ * `pinned/hosting/_records.py`): each names one instance on the worker the
110
+ * thread is already placed on and clears in the time a teardown or an
111
+ * activation slot takes. Anything else the worker answers 503 with — "Thread
112
+ * history load failed", "The regional conversation store is temporarily
113
+ * unavailable", a lease that expired — is not about one instance and keeps
114
+ * the full hint.
115
+ */
116
+ export declare const PINNED_TRANSIENT_WORKER_REFUSALS: ReadonlySet<string>;
117
+ /**
118
+ * Classify a 503/429 body (see {@link DeepAgentWakeRefusal}): a known pinboard
119
+ * `error` is `"placement"`, a known pinned `detail` is `"worker"`, everything
120
+ * else — including unfamiliar strings in either field — is `"unknown"`.
121
+ */
122
+ export declare function classifyWakeRefusal(body: unknown): Exclude<DeepAgentWakeRefusal, null>;
123
+ /** Structural `fetch` for the wake call — this package compiles without the DOM lib. */
124
+ export type DeepAgentWakeFetch = (input: string, init?: {
125
+ method?: string;
126
+ headers?: Record<string, string>;
127
+ keepalive?: boolean;
128
+ }) => Promise<{
129
+ ok: boolean;
130
+ status: number;
131
+ headers: {
132
+ get(name: string): string | null;
133
+ };
134
+ json(): Promise<unknown>;
135
+ }>;
136
+ export interface DeepAgentWakeOptions {
137
+ /** Base URL of the deep-agent statewire host (the `…/v2/threads` mount). */
138
+ baseUrl: string;
139
+ threadId: string;
140
+ headers: DeepAgentHeadersResolver;
141
+ fetch?: DeepAgentWakeFetch | undefined;
142
+ /** Dial floors from server retry hints; the process-wide gate by default. */
143
+ retryGate?: AttachRetryGate;
144
+ onAttachTiming?: ((event: DeepAgentAttachTimingEvent) => void) | undefined;
145
+ now?: () => number;
146
+ /** The surface pages cut lanes: declare what its attach declares (see `DeepAgentAttachTransportOptions`). */
147
+ laneHistory?: boolean | undefined;
148
+ }
149
+ /**
150
+ * Wake a thread's server instance ahead of its attach. `POST …/prewarm` runs
151
+ * the host's `authorize` and history load — the fence adopt, graph compile and
152
+ * checkpoint read that make a cold attach's hello take ≈1 s — and answers with
153
+ * no thread content, only whether the history was already resident. Fire it
154
+ * on hover intent, before a pooled attach or the click's own dial, so the
155
+ * activation overlaps the handshake and the attach that follows finds the
156
+ * instance warm.
157
+ *
158
+ * Fire-and-forget by contract: every failure resolves `null`, and a host
159
+ * without the route (404) is reported like any other non-OK answer. A 503/429
160
+ * `Retry-After` is recorded as a dial floor for the thread, so the attach that
161
+ * follows waits it out instead of bouncing — in full, except a 503 that names
162
+ * one of pinned's instance-lifecycle refusals (one instance mid-teardown on
163
+ * the worker the thread already has; see {@link DeepAgentWakeRefusal}), whose
164
+ * floor is capped at {@link WAKE_WORKER_REFUSAL_FLOOR_MS}.
165
+ */
166
+ export declare function wakeDeepAgentThread({ baseUrl, threadId, headers, fetch: fetchOverride, retryGate, onAttachTiming, now, laneHistory, }: DeepAgentWakeOptions): Promise<DeepAgentWakeResult | null>;
@@ -18,7 +18,8 @@ function createDeepAgentAttachTransport({
18
18
  onAuthResolve,
19
19
  onAttachTiming,
20
20
  retryGate = attachRetryGate,
21
- messageWindow
21
+ messageWindow,
22
+ laneHistory = false
22
23
  }) {
23
24
  const url = deepAgentThreadUrl({ baseUrl, threadId });
24
25
  const useSse = resolveStatewireTransportKind({ sse }) === "sse";
@@ -35,7 +36,7 @@ function createDeepAgentAttachTransport({
35
36
  await retryGate.waitForDial(url);
36
37
  onAuthResolve == null ? void 0 : onAuthResolve(ctx);
37
38
  return withDeclaredMessageWindow(
38
- withDeclaredProtocolVersion(await headers(ctx)),
39
+ withDeclaredProtocolVersion(await headers(ctx), { laneHistory }),
39
40
  messageWindow
40
41
  );
41
42
  },