@athenaintel/react 0.28.1 → 0.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (817) hide show
  1. package/README.md +479 -10
  2. package/dist/agent-runtime/src/asset-attachment.cjs.map +1 -0
  3. package/dist/agent-runtime/src/asset-attachment.js.map +1 -0
  4. package/dist/agent-runtime/src/athena-asset-drag.cjs +44 -0
  5. package/dist/agent-runtime/src/athena-asset-drag.cjs.map +1 -0
  6. package/dist/agent-runtime/src/athena-asset-drag.js +44 -0
  7. package/dist/agent-runtime/src/athena-asset-drag.js.map +1 -0
  8. package/dist/agent-runtime/src/auth-denial.cjs.map +1 -0
  9. package/dist/agent-runtime/src/auth-denial.js.map +1 -0
  10. package/dist/agent-runtime/src/client-tool-bridge.cjs.map +1 -0
  11. package/dist/agent-runtime/src/client-tool-bridge.js.map +1 -0
  12. package/dist/agent-runtime/src/client-tools.cjs.map +1 -0
  13. package/dist/agent-runtime/src/client-tools.js.map +1 -0
  14. package/dist/agent-runtime/src/composer-markdown.cjs +124 -0
  15. package/dist/agent-runtime/src/composer-markdown.cjs.map +1 -0
  16. package/dist/agent-runtime/src/composer-markdown.js +124 -0
  17. package/dist/agent-runtime/src/composer-markdown.js.map +1 -0
  18. package/dist/agent-runtime/src/config-mutations.cjs +59 -0
  19. package/dist/agent-runtime/src/config-mutations.cjs.map +1 -0
  20. package/dist/agent-runtime/src/config-mutations.js +59 -0
  21. package/dist/agent-runtime/src/config-mutations.js.map +1 -0
  22. package/dist/agent-runtime/src/conversation-index.cjs.map +1 -0
  23. package/dist/agent-runtime/src/conversation-index.js.map +1 -0
  24. package/dist/{packages/agent-runtime → agent-runtime}/src/conversation-list.cjs +36 -0
  25. package/dist/agent-runtime/src/conversation-list.cjs.map +1 -0
  26. package/dist/{packages/agent-runtime → agent-runtime}/src/conversation-list.js +36 -0
  27. package/dist/agent-runtime/src/conversation-list.js.map +1 -0
  28. package/dist/{packages/agent-runtime → agent-runtime}/src/deep-agent-transport-recipe.cjs +5 -3
  29. package/dist/agent-runtime/src/deep-agent-transport-recipe.cjs.map +1 -0
  30. package/dist/{packages/agent-runtime → agent-runtime}/src/deep-agent-transport-recipe.js +6 -4
  31. package/dist/agent-runtime/src/deep-agent-transport-recipe.js.map +1 -0
  32. package/dist/agent-runtime/src/edit-command.cjs.map +1 -0
  33. package/dist/agent-runtime/src/edit-command.js.map +1 -0
  34. package/dist/{packages/agent-runtime → agent-runtime}/src/errors.cjs +23 -0
  35. package/dist/agent-runtime/src/errors.cjs.map +1 -0
  36. package/dist/{packages/agent-runtime → agent-runtime}/src/errors.js +23 -0
  37. package/dist/agent-runtime/src/errors.js.map +1 -0
  38. package/dist/agent-runtime/src/execute-output.cjs +41 -0
  39. package/dist/agent-runtime/src/execute-output.cjs.map +1 -0
  40. package/dist/agent-runtime/src/execute-output.js +41 -0
  41. package/dist/agent-runtime/src/execute-output.js.map +1 -0
  42. package/dist/{packages/agent-runtime → agent-runtime}/src/generated/runconfig-contract.cjs +16 -2
  43. package/dist/agent-runtime/src/generated/runconfig-contract.cjs.map +1 -0
  44. package/dist/{packages/agent-runtime → agent-runtime}/src/generated/runconfig-contract.js +16 -2
  45. package/dist/agent-runtime/src/generated/runconfig-contract.js.map +1 -0
  46. package/dist/agent-runtime/src/github-wake-event.cjs.map +1 -0
  47. package/dist/agent-runtime/src/github-wake-event.js.map +1 -0
  48. package/dist/{packages/agent-runtime → agent-runtime}/src/interrupts.cjs +24 -1
  49. package/dist/agent-runtime/src/interrupts.cjs.map +1 -0
  50. package/dist/{packages/agent-runtime → agent-runtime}/src/interrupts.js +24 -1
  51. package/dist/agent-runtime/src/interrupts.js.map +1 -0
  52. package/dist/agent-runtime/src/message-author.cjs.map +1 -0
  53. package/dist/agent-runtime/src/message-author.js.map +1 -0
  54. package/dist/agent-runtime/src/message-window.cjs.map +1 -0
  55. package/dist/agent-runtime/src/message-window.js.map +1 -0
  56. package/dist/{packages/agent-runtime → agent-runtime}/src/messages.cjs +8 -4
  57. package/dist/agent-runtime/src/messages.cjs.map +1 -0
  58. package/dist/{packages/agent-runtime → agent-runtime}/src/messages.js +6 -2
  59. package/dist/agent-runtime/src/messages.js.map +1 -0
  60. package/dist/agent-runtime/src/model-context.cjs.map +1 -0
  61. package/dist/agent-runtime/src/model-context.js.map +1 -0
  62. package/dist/agent-runtime/src/optimistic-content.cjs.map +1 -0
  63. package/dist/agent-runtime/src/optimistic-content.js.map +1 -0
  64. package/dist/agent-runtime/src/protocol.cjs.map +1 -0
  65. package/dist/agent-runtime/src/protocol.js.map +1 -0
  66. package/dist/{packages/agent-runtime → agent-runtime}/src/queue.cjs +23 -2
  67. package/dist/agent-runtime/src/queue.cjs.map +1 -0
  68. package/dist/{packages/agent-runtime → agent-runtime}/src/queue.js +23 -2
  69. package/dist/agent-runtime/src/queue.js.map +1 -0
  70. package/dist/{packages/agent-runtime → agent-runtime}/src/quota-safe-local-storage-session.cjs +71 -13
  71. package/dist/agent-runtime/src/quota-safe-local-storage-session.cjs.map +1 -0
  72. package/dist/{packages/agent-runtime → agent-runtime}/src/quota-safe-local-storage-session.js +73 -15
  73. package/dist/agent-runtime/src/quota-safe-local-storage-session.js.map +1 -0
  74. package/dist/agent-runtime/src/runtime-messages.cjs.map +1 -0
  75. package/dist/agent-runtime/src/runtime-messages.js.map +1 -0
  76. package/dist/agent-runtime/src/screen-point.cjs.map +1 -0
  77. package/dist/agent-runtime/src/screen-point.js.map +1 -0
  78. package/dist/agent-runtime/src/send-recovery.cjs.map +1 -0
  79. package/dist/agent-runtime/src/send-recovery.js.map +1 -0
  80. package/dist/agent-runtime/src/statewire-attach-observer.cjs.map +1 -0
  81. package/dist/agent-runtime/src/statewire-attach-observer.js.map +1 -0
  82. package/dist/{packages/agent-runtime → agent-runtime}/src/statewire-state.cjs +8 -0
  83. package/dist/agent-runtime/src/statewire-state.cjs.map +1 -0
  84. package/dist/{packages/agent-runtime → agent-runtime}/src/statewire-state.js +8 -0
  85. package/dist/agent-runtime/src/statewire-state.js.map +1 -0
  86. package/dist/{packages/agent-runtime → agent-runtime}/src/statewire-suspended.cjs +4 -0
  87. package/dist/agent-runtime/src/statewire-suspended.cjs.map +1 -0
  88. package/dist/{packages/agent-runtime → agent-runtime}/src/statewire-suspended.js +4 -0
  89. package/dist/agent-runtime/src/statewire-suspended.js.map +1 -0
  90. package/dist/agent-runtime/src/statewire-transport.cjs +43 -0
  91. package/dist/agent-runtime/src/statewire-transport.cjs.map +1 -0
  92. package/dist/agent-runtime/src/statewire-transport.js +43 -0
  93. package/dist/agent-runtime/src/statewire-transport.js.map +1 -0
  94. package/dist/agent-runtime/src/streaming-markdown.cjs.map +1 -0
  95. package/dist/agent-runtime/src/streaming-markdown.js.map +1 -0
  96. package/dist/agent-runtime/src/subscription-wake-event.cjs +252 -0
  97. package/dist/agent-runtime/src/subscription-wake-event.cjs.map +1 -0
  98. package/dist/agent-runtime/src/subscription-wake-event.js +252 -0
  99. package/dist/agent-runtime/src/subscription-wake-event.js.map +1 -0
  100. package/dist/agent-runtime/src/thread-extras.cjs.map +1 -0
  101. package/dist/agent-runtime/src/thread-extras.js.map +1 -0
  102. package/dist/agent-runtime/src/thread-snapshot-cache.cjs.map +1 -0
  103. package/dist/agent-runtime/src/thread-snapshot-cache.js.map +1 -0
  104. package/dist/agent-runtime/src/thread-status.cjs.map +1 -0
  105. package/dist/agent-runtime/src/thread-status.js.map +1 -0
  106. package/dist/{packages/agent-runtime → agent-runtime}/src/tool-metadata.cjs +304 -9
  107. package/dist/agent-runtime/src/tool-metadata.cjs.map +1 -0
  108. package/dist/{packages/agent-runtime → agent-runtime}/src/tool-metadata.js +304 -9
  109. package/dist/agent-runtime/src/tool-metadata.js.map +1 -0
  110. package/dist/agent-runtime/src/tool-names.cjs +5 -0
  111. package/dist/agent-runtime/src/tool-names.cjs.map +1 -0
  112. package/dist/agent-runtime/src/tool-names.js +5 -0
  113. package/dist/agent-runtime/src/tool-names.js.map +1 -0
  114. package/dist/agent-runtime/src/tool-outputs.cjs.map +1 -0
  115. package/dist/agent-runtime/src/tool-outputs.js.map +1 -0
  116. package/dist/agent-runtime/src/tool-result.cjs.map +1 -0
  117. package/dist/agent-runtime/src/tool-result.js.map +1 -0
  118. package/dist/{packages/agent-runtime → agent-runtime}/src/use-conversation-list.cjs +33 -22
  119. package/dist/agent-runtime/src/use-conversation-list.cjs.map +1 -0
  120. package/dist/{packages/agent-runtime → agent-runtime}/src/use-conversation-list.js +34 -23
  121. package/dist/agent-runtime/src/use-conversation-list.js.map +1 -0
  122. package/dist/agent-runtime/src/use-deep-agent-config.cjs +129 -0
  123. package/dist/agent-runtime/src/use-deep-agent-config.cjs.map +1 -0
  124. package/dist/agent-runtime/src/use-deep-agent-config.js +129 -0
  125. package/dist/agent-runtime/src/use-deep-agent-config.js.map +1 -0
  126. package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-edit-submit.cjs +2 -0
  127. package/dist/agent-runtime/src/use-deep-agent-edit-submit.cjs.map +1 -0
  128. package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-edit-submit.js +2 -0
  129. package/dist/agent-runtime/src/use-deep-agent-edit-submit.js.map +1 -0
  130. package/dist/agent-runtime/src/use-deep-agent-runtime.cjs.map +1 -0
  131. package/dist/agent-runtime/src/use-deep-agent-runtime.js.map +1 -0
  132. package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-thread.cjs +1 -0
  133. package/dist/agent-runtime/src/use-deep-agent-thread.cjs.map +1 -0
  134. package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-thread.js +2 -1
  135. package/dist/agent-runtime/src/use-deep-agent-thread.js.map +1 -0
  136. package/dist/agent-runtime/src/use-deep-agent-window-sync.cjs.map +1 -0
  137. package/dist/agent-runtime/src/use-deep-agent-window-sync.js.map +1 -0
  138. package/dist/agent-runtime/src/use-historical-edit-attachments.cjs +52 -0
  139. package/dist/agent-runtime/src/use-historical-edit-attachments.cjs.map +1 -0
  140. package/dist/agent-runtime/src/use-historical-edit-attachments.js +52 -0
  141. package/dist/agent-runtime/src/use-historical-edit-attachments.js.map +1 -0
  142. package/dist/{packages/agent-runtime → agent-runtime}/src/voice-presentation.cjs +14 -0
  143. package/dist/agent-runtime/src/voice-presentation.cjs.map +1 -0
  144. package/dist/{packages/agent-runtime → agent-runtime}/src/voice-presentation.js +14 -0
  145. package/dist/agent-runtime/src/voice-presentation.js.map +1 -0
  146. package/dist/agent-runtime/src/voice-turn-grouping.cjs.map +1 -0
  147. package/dist/agent-runtime/src/voice-turn-grouping.js.map +1 -0
  148. package/dist/assets/AthenaAssetEmbed.cjs +13 -2
  149. package/dist/assets/AthenaAssetEmbed.cjs.map +1 -1
  150. package/dist/assets/AthenaAssetEmbed.d.ts +10 -0
  151. package/dist/assets/AthenaAssetEmbed.js +14 -3
  152. package/dist/assets/AthenaAssetEmbed.js.map +1 -1
  153. package/dist/assets/AthenaLayout.cjs +97 -31
  154. package/dist/assets/AthenaLayout.cjs.map +1 -1
  155. package/dist/assets/AthenaLayout.d.ts +13 -0
  156. package/dist/assets/AthenaLayout.js +98 -32
  157. package/dist/assets/AthenaLayout.js.map +1 -1
  158. package/dist/assets/asset-embed-messages.cjs +6 -0
  159. package/dist/assets/asset-embed-messages.cjs.map +1 -1
  160. package/dist/assets/asset-embed-messages.d.ts +13 -0
  161. package/dist/assets/asset-embed-messages.js +6 -0
  162. package/dist/assets/asset-embed-messages.js.map +1 -1
  163. package/dist/assets/asset-panel-store.cjs +68 -32
  164. package/dist/assets/asset-panel-store.cjs.map +1 -1
  165. package/dist/assets/asset-panel-store.d.ts +47 -1
  166. package/dist/assets/asset-panel-store.js +68 -32
  167. package/dist/assets/asset-panel-store.js.map +1 -1
  168. package/dist/assets/use-asset-embed.cjs +29 -8
  169. package/dist/assets/use-asset-embed.cjs.map +1 -1
  170. package/dist/assets/use-asset-embed.d.ts +7 -0
  171. package/dist/assets/use-asset-embed.js +29 -8
  172. package/dist/assets/use-asset-embed.js.map +1 -1
  173. package/dist/catalog/chat-pickers.cjs +152 -0
  174. package/dist/catalog/chat-pickers.cjs.map +1 -0
  175. package/dist/catalog/chat-pickers.d.ts +22 -0
  176. package/dist/catalog/chat-pickers.js +152 -0
  177. package/dist/catalog/chat-pickers.js.map +1 -0
  178. package/dist/catalog/runtime-catalog.cjs +181 -0
  179. package/dist/catalog/runtime-catalog.cjs.map +1 -0
  180. package/dist/catalog/runtime-catalog.d.ts +100 -0
  181. package/dist/catalog/runtime-catalog.js +181 -0
  182. package/dist/catalog/runtime-catalog.js.map +1 -0
  183. package/dist/chat/AthenaChat.cjs +122 -67
  184. package/dist/chat/AthenaChat.cjs.map +1 -1
  185. package/dist/chat/AthenaChat.d.ts +21 -4
  186. package/dist/chat/AthenaChat.js +124 -69
  187. package/dist/chat/AthenaChat.js.map +1 -1
  188. package/dist/chat/StatewireApprovalCard.cjs +38 -37
  189. package/dist/chat/StatewireApprovalCard.cjs.map +1 -1
  190. package/dist/chat/StatewireApprovalCard.d.ts +2 -0
  191. package/dist/chat/StatewireApprovalCard.js +39 -38
  192. package/dist/chat/StatewireApprovalCard.js.map +1 -1
  193. package/dist/chat/StatewireClientToolBridge.cjs +2 -2
  194. package/dist/chat/StatewireClientToolBridge.js +2 -2
  195. package/dist/chat/StatewireQueuedMessages.cjs +15 -12
  196. package/dist/chat/StatewireQueuedMessages.cjs.map +1 -1
  197. package/dist/chat/StatewireQueuedMessages.d.ts +22 -2
  198. package/dist/chat/StatewireQueuedMessages.js +15 -12
  199. package/dist/chat/StatewireQueuedMessages.js.map +1 -1
  200. package/dist/chat/StatewireRunRefusalNotice.cjs +48 -0
  201. package/dist/chat/StatewireRunRefusalNotice.cjs.map +1 -0
  202. package/dist/chat/StatewireRunRefusalNotice.d.ts +25 -0
  203. package/dist/chat/StatewireRunRefusalNotice.js +48 -0
  204. package/dist/chat/StatewireRunRefusalNotice.js.map +1 -0
  205. package/dist/chat/WaitingOnYouBanner.cjs +2 -2
  206. package/dist/chat/WaitingOnYouBanner.js +2 -2
  207. package/dist/chat/athena-citation-links.cjs +19 -15
  208. package/dist/chat/athena-citation-links.cjs.map +1 -1
  209. package/dist/chat/athena-citation-links.js +19 -15
  210. package/dist/chat/athena-citation-links.js.map +1 -1
  211. package/dist/chat/run-activity.cjs +9 -1
  212. package/dist/chat/run-activity.cjs.map +1 -1
  213. package/dist/chat/run-activity.d.ts +6 -0
  214. package/dist/chat/run-activity.js +10 -2
  215. package/dist/chat/run-activity.js.map +1 -1
  216. package/dist/chat/statewire-banners.cjs +30 -1
  217. package/dist/chat/statewire-banners.cjs.map +1 -1
  218. package/dist/chat/statewire-banners.d.ts +20 -1
  219. package/dist/chat/statewire-banners.js +32 -3
  220. package/dist/chat/statewire-banners.js.map +1 -1
  221. package/dist/chat/statewire-client-tools.cjs +1 -1
  222. package/dist/chat/statewire-client-tools.js +1 -1
  223. package/dist/chat/super-grouping/CollapsibleGroup.cjs +1 -1
  224. package/dist/chat/super-grouping/CollapsibleGroup.cjs.map +1 -1
  225. package/dist/chat/super-grouping/CollapsibleGroup.js +1 -1
  226. package/dist/chat/super-grouping/CollapsibleGroup.js.map +1 -1
  227. package/dist/chat/super-grouping/SuperGroupingCard.cjs +38 -16
  228. package/dist/chat/super-grouping/SuperGroupingCard.cjs.map +1 -1
  229. package/dist/chat/super-grouping/SuperGroupingCard.d.ts +21 -4
  230. package/dist/chat/super-grouping/SuperGroupingCard.js +39 -17
  231. package/dist/chat/super-grouping/SuperGroupingCard.js.map +1 -1
  232. package/dist/chat/super-grouping/SuperGroupingTranscript.cjs +377 -0
  233. package/dist/chat/super-grouping/SuperGroupingTranscript.cjs.map +1 -0
  234. package/dist/chat/super-grouping/SuperGroupingTranscript.d.ts +31 -0
  235. package/dist/chat/super-grouping/SuperGroupingTranscript.js +377 -0
  236. package/dist/chat/super-grouping/SuperGroupingTranscript.js.map +1 -0
  237. package/dist/chat/super-grouping/ToolTimeline.cjs +13 -2
  238. package/dist/chat/super-grouping/ToolTimeline.cjs.map +1 -1
  239. package/dist/chat/super-grouping/ToolTimeline.d.ts +10 -3
  240. package/dist/chat/super-grouping/ToolTimeline.js +13 -2
  241. package/dist/chat/super-grouping/ToolTimeline.js.map +1 -1
  242. package/dist/chat/super-grouping/activity-timeline.cjs +69 -29
  243. package/dist/chat/super-grouping/activity-timeline.cjs.map +1 -1
  244. package/dist/chat/super-grouping/activity-timeline.d.ts +60 -9
  245. package/dist/chat/super-grouping/activity-timeline.js +70 -30
  246. package/dist/chat/super-grouping/activity-timeline.js.map +1 -1
  247. package/dist/chat/super-grouping/index.cjs +14 -0
  248. package/dist/chat/super-grouping/index.cjs.map +1 -1
  249. package/dist/chat/super-grouping/index.d.ts +7 -2
  250. package/dist/chat/super-grouping/index.js +16 -2
  251. package/dist/chat/super-grouping/index.js.map +1 -1
  252. package/dist/chat/super-grouping/timeline-step.cjs +14 -5
  253. package/dist/chat/super-grouping/timeline-step.cjs.map +1 -1
  254. package/dist/chat/super-grouping/timeline-step.d.ts +10 -1
  255. package/dist/chat/super-grouping/timeline-step.js +15 -6
  256. package/dist/chat/super-grouping/timeline-step.js.map +1 -1
  257. package/dist/chat/super-grouping/toolkit-map.cjs +1 -0
  258. package/dist/chat/super-grouping/toolkit-map.cjs.map +1 -1
  259. package/dist/chat/super-grouping/toolkit-map.js +1 -0
  260. package/dist/chat/super-grouping/toolkit-map.js.map +1 -1
  261. package/dist/chat/super-grouping/turn-segments.cjs +82 -0
  262. package/dist/chat/super-grouping/turn-segments.cjs.map +1 -0
  263. package/dist/chat/super-grouping/turn-segments.d.ts +69 -0
  264. package/dist/chat/super-grouping/turn-segments.js +82 -0
  265. package/dist/chat/super-grouping/turn-segments.js.map +1 -0
  266. package/dist/chat/super-grouping/turn-timing.cjs +110 -0
  267. package/dist/chat/super-grouping/turn-timing.cjs.map +1 -0
  268. package/dist/chat/super-grouping/turn-timing.d.ts +52 -0
  269. package/dist/chat/super-grouping/turn-timing.js +110 -0
  270. package/dist/chat/super-grouping/turn-timing.js.map +1 -0
  271. package/dist/chat/tiptap-text.cjs +1 -1
  272. package/dist/chat/tiptap-text.js +1 -1
  273. package/dist/chat/use-athena-run-live.cjs +1 -1
  274. package/dist/chat/use-athena-run-live.js +1 -1
  275. package/dist/chat/use-statewire-approval-request.cjs +73 -4
  276. package/dist/chat/use-statewire-approval-request.cjs.map +1 -1
  277. package/dist/chat/use-statewire-approval-request.js +74 -5
  278. package/dist/chat/use-statewire-approval-request.js.map +1 -1
  279. package/dist/chat-ui/composer/composer-message.cjs +284 -0
  280. package/dist/chat-ui/composer/composer-message.cjs.map +1 -0
  281. package/dist/chat-ui/composer/composer-message.d.ts +152 -0
  282. package/dist/chat-ui/composer/composer-message.js +284 -0
  283. package/dist/chat-ui/composer/composer-message.js.map +1 -0
  284. package/dist/chat-ui/composer/tiptap-composer.cjs +97 -15
  285. package/dist/chat-ui/composer/tiptap-composer.cjs.map +1 -1
  286. package/dist/chat-ui/composer/tiptap-composer.d.ts +34 -6
  287. package/dist/chat-ui/composer/tiptap-composer.js +97 -15
  288. package/dist/chat-ui/composer/tiptap-composer.js.map +1 -1
  289. package/dist/chat-ui/index.cjs +4 -1
  290. package/dist/chat-ui/index.cjs.map +1 -1
  291. package/dist/chat-ui/index.d.ts +3 -2
  292. package/dist/chat-ui/index.js +5 -2
  293. package/dist/chat-ui/index.js.map +1 -1
  294. package/dist/chat-ui/mentions/mention-chip.cjs +31 -3
  295. package/dist/chat-ui/mentions/mention-chip.cjs.map +1 -1
  296. package/dist/chat-ui/mentions/mention-chip.d.ts +2 -5
  297. package/dist/chat-ui/mentions/mention-chip.js +33 -5
  298. package/dist/chat-ui/mentions/mention-chip.js.map +1 -1
  299. package/dist/chat-ui/mentions/mention-extension.cjs +9 -3
  300. package/dist/chat-ui/mentions/mention-extension.cjs.map +1 -1
  301. package/dist/chat-ui/mentions/mention-extension.js +9 -3
  302. package/dist/chat-ui/mentions/mention-extension.js.map +1 -1
  303. package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-popup.cjs +3 -1
  304. package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-popup.cjs.map +1 -1
  305. package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-popup.js +3 -1
  306. package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-popup.js.map +1 -1
  307. package/dist/chat-ui/mentions/suggestions/data/sources/index.cjs +65 -19
  308. package/dist/chat-ui/mentions/suggestions/data/sources/index.cjs.map +1 -1
  309. package/dist/chat-ui/mentions/suggestions/data/sources/index.d.ts +15 -0
  310. package/dist/chat-ui/mentions/suggestions/data/sources/index.js +67 -21
  311. package/dist/chat-ui/mentions/suggestions/data/sources/index.js.map +1 -1
  312. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.cjs +4 -2
  313. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.cjs.map +1 -1
  314. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.d.ts +2 -1
  315. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.js +5 -3
  316. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.js.map +1 -1
  317. package/dist/chat-ui/mentions/use-account-workspace-id.cjs +61 -0
  318. package/dist/chat-ui/mentions/use-account-workspace-id.cjs.map +1 -0
  319. package/dist/chat-ui/mentions/use-account-workspace-id.d.ts +3 -0
  320. package/dist/chat-ui/mentions/use-account-workspace-id.js +61 -0
  321. package/dist/chat-ui/mentions/use-account-workspace-id.js.map +1 -0
  322. package/dist/chat-ui/mentions/use-member-avatar.cjs +75 -0
  323. package/dist/chat-ui/mentions/use-member-avatar.cjs.map +1 -0
  324. package/dist/chat-ui/mentions/use-member-avatar.d.ts +2 -0
  325. package/dist/chat-ui/mentions/use-member-avatar.js +75 -0
  326. package/dist/chat-ui/mentions/use-member-avatar.js.map +1 -0
  327. package/dist/chat-ui/messages/message-components.cjs +30 -10
  328. package/dist/chat-ui/messages/message-components.cjs.map +1 -1
  329. package/dist/chat-ui/messages/message-components.d.ts +21 -1
  330. package/dist/chat-ui/messages/message-components.js +30 -10
  331. package/dist/chat-ui/messages/message-components.js.map +1 -1
  332. package/dist/chat-ui/messages/runtime-message.cjs +1 -1
  333. package/dist/chat-ui/messages/runtime-message.js +1 -1
  334. package/dist/chat-ui/messages/statewire-continue-run.cjs +5 -5
  335. package/dist/chat-ui/messages/statewire-continue-run.js +5 -5
  336. package/dist/chat-ui/messages/user-edit-composer.cjs +1 -1
  337. package/dist/chat-ui/messages/user-edit-composer.js +1 -1
  338. package/dist/chat-ui/messages/wake-marker.cjs +39 -4
  339. package/dist/chat-ui/messages/wake-marker.cjs.map +1 -1
  340. package/dist/chat-ui/messages/wake-marker.d.ts +16 -5
  341. package/dist/chat-ui/messages/wake-marker.js +40 -5
  342. package/dist/chat-ui/messages/wake-marker.js.map +1 -1
  343. package/dist/chat-ui/rich-text/chat-message-body.cjs +12 -8
  344. package/dist/chat-ui/rich-text/chat-message-body.cjs.map +1 -1
  345. package/dist/chat-ui/rich-text/chat-message-body.d.ts +6 -1
  346. package/dist/chat-ui/rich-text/chat-message-body.js +13 -9
  347. package/dist/chat-ui/rich-text/chat-message-body.js.map +1 -1
  348. package/dist/chat-ui/rich-text/chat-text-schema.cjs +64 -6
  349. package/dist/chat-ui/rich-text/chat-text-schema.cjs.map +1 -1
  350. package/dist/chat-ui/rich-text/chat-text-schema.d.ts +5 -0
  351. package/dist/chat-ui/rich-text/chat-text-schema.js +66 -8
  352. package/dist/chat-ui/rich-text/chat-text-schema.js.map +1 -1
  353. package/dist/chat-ui/statewire.cjs +1 -1
  354. package/dist/chat-ui/statewire.d.ts +1 -1
  355. package/dist/chat-ui/statewire.js +1 -1
  356. package/dist/chat-ui/thread/statewire-history-edge.cjs +2 -2
  357. package/dist/chat-ui/thread/statewire-history-edge.js +2 -2
  358. package/dist/collab/client.cjs +282 -16
  359. package/dist/collab/client.cjs.map +1 -1
  360. package/dist/collab/client.d.ts +127 -2
  361. package/dist/collab/client.js +285 -20
  362. package/dist/collab/client.js.map +1 -1
  363. package/dist/collab/index.cjs +2 -0
  364. package/dist/collab/index.cjs.map +1 -1
  365. package/dist/collab/index.d.ts +1 -1
  366. package/dist/collab/index.js +3 -1
  367. package/dist/composer/AttachmentContext.cjs +38 -12
  368. package/dist/composer/AttachmentContext.cjs.map +1 -1
  369. package/dist/composer/AttachmentContext.d.ts +22 -1
  370. package/dist/composer/AttachmentContext.js +40 -14
  371. package/dist/composer/AttachmentContext.js.map +1 -1
  372. package/dist/composer/QuoteContext.cjs +80 -28
  373. package/dist/composer/QuoteContext.cjs.map +1 -1
  374. package/dist/composer/QuoteContext.d.ts +35 -6
  375. package/dist/composer/QuoteContext.js +82 -30
  376. package/dist/composer/QuoteContext.js.map +1 -1
  377. package/dist/composer/build-composed-message.cjs +27 -0
  378. package/dist/composer/build-composed-message.cjs.map +1 -1
  379. package/dist/composer/build-composed-message.d.ts +21 -0
  380. package/dist/composer/build-composed-message.js +28 -1
  381. package/dist/composer/build-composed-message.js.map +1 -1
  382. package/dist/composer/composer-handoff.cjs +13 -1
  383. package/dist/composer/composer-handoff.cjs.map +1 -1
  384. package/dist/composer/composer-handoff.d.ts +12 -0
  385. package/dist/composer/composer-handoff.js +15 -3
  386. package/dist/composer/composer-handoff.js.map +1 -1
  387. package/dist/composer/index.d.ts +6 -3
  388. package/dist/composer/useReadComposerDraft.cjs +16 -0
  389. package/dist/composer/useReadComposerDraft.cjs.map +1 -0
  390. package/dist/composer/useReadComposerDraft.d.ts +6 -0
  391. package/dist/composer/useReadComposerDraft.js +16 -0
  392. package/dist/composer/useReadComposerDraft.js.map +1 -0
  393. package/dist/diagnostics/athena-diagnostics.cjs.map +1 -1
  394. package/dist/diagnostics/athena-diagnostics.d.ts +3 -1
  395. package/dist/diagnostics/athena-diagnostics.js.map +1 -1
  396. package/dist/diagnostics/errors.cjs +6 -0
  397. package/dist/diagnostics/errors.cjs.map +1 -1
  398. package/dist/diagnostics/errors.d.ts +6 -0
  399. package/dist/diagnostics/errors.js +6 -0
  400. package/dist/diagnostics/errors.js.map +1 -1
  401. package/dist/index.cjs +163 -7
  402. package/dist/index.cjs.map +1 -1
  403. package/dist/index.d.ts +55 -12
  404. package/dist/index.js +170 -14
  405. package/dist/index.js.map +1 -1
  406. package/dist/lib/owner-document.cjs +32 -0
  407. package/dist/lib/owner-document.cjs.map +1 -0
  408. package/dist/lib/owner-document.d.ts +17 -0
  409. package/dist/lib/owner-document.js +32 -0
  410. package/dist/lib/owner-document.js.map +1 -0
  411. package/dist/lib/portal-surface.cjs +55 -0
  412. package/dist/lib/portal-surface.cjs.map +1 -0
  413. package/dist/lib/portal-surface.d.ts +37 -0
  414. package/dist/lib/portal-surface.js +55 -0
  415. package/dist/lib/portal-surface.js.map +1 -0
  416. package/dist/lib/use-athena-rest-query.cjs +34 -0
  417. package/dist/lib/use-athena-rest-query.cjs.map +1 -0
  418. package/dist/lib/use-athena-rest-query.d.ts +31 -0
  419. package/dist/lib/use-athena-rest-query.js +34 -0
  420. package/dist/lib/use-athena-rest-query.js.map +1 -0
  421. package/dist/provider/AthenaProvider.cjs +70 -10
  422. package/dist/provider/AthenaProvider.cjs.map +1 -1
  423. package/dist/provider/AthenaProvider.d.ts +27 -2
  424. package/dist/provider/AthenaProvider.js +74 -14
  425. package/dist/provider/AthenaProvider.js.map +1 -1
  426. package/dist/provider/citation-links.d.ts +10 -2
  427. package/dist/{packages/react → react}/package.json.cjs +1 -1
  428. package/dist/{packages/react → react}/package.json.js +1 -1
  429. package/dist/runtime/StatewireModelLaneSync.cjs +96 -0
  430. package/dist/runtime/StatewireModelLaneSync.cjs.map +1 -0
  431. package/dist/runtime/StatewireModelLaneSync.d.ts +45 -0
  432. package/dist/runtime/StatewireModelLaneSync.js +96 -0
  433. package/dist/runtime/StatewireModelLaneSync.js.map +1 -0
  434. package/dist/runtime/statewire-lifecycle.cjs +20 -5
  435. package/dist/runtime/statewire-lifecycle.cjs.map +1 -1
  436. package/dist/runtime/statewire-lifecycle.d.ts +11 -0
  437. package/dist/runtime/statewire-lifecycle.js +20 -5
  438. package/dist/runtime/statewire-lifecycle.js.map +1 -1
  439. package/dist/runtime/statewire-model-lane.cjs +28 -0
  440. package/dist/runtime/statewire-model-lane.cjs.map +1 -0
  441. package/dist/runtime/statewire-model-lane.d.ts +64 -0
  442. package/dist/runtime/statewire-model-lane.js +28 -0
  443. package/dist/runtime/statewire-model-lane.js.map +1 -0
  444. package/dist/runtime/statewire-run-config.cjs +16 -2
  445. package/dist/runtime/statewire-run-config.cjs.map +1 -1
  446. package/dist/runtime/statewire-run-config.d.ts +10 -0
  447. package/dist/runtime/statewire-run-config.js +16 -2
  448. package/dist/runtime/statewire-run-config.js.map +1 -1
  449. package/dist/runtime/statewire-server-lane-context.cjs +24 -0
  450. package/dist/runtime/statewire-server-lane-context.cjs.map +1 -0
  451. package/dist/runtime/statewire-server-lane-context.d.ts +30 -0
  452. package/dist/runtime/statewire-server-lane-context.js +24 -0
  453. package/dist/runtime/statewire-server-lane-context.js.map +1 -0
  454. package/dist/runtime/useAthenaStatewireRuntime.cjs +47 -23
  455. package/dist/runtime/useAthenaStatewireRuntime.cjs.map +1 -1
  456. package/dist/runtime/useAthenaStatewireRuntime.d.ts +8 -1
  457. package/dist/runtime/useAthenaStatewireRuntime.js +48 -24
  458. package/dist/runtime/useAthenaStatewireRuntime.js.map +1 -1
  459. package/dist/search/useAthenaRepoSearch.cjs +5 -13
  460. package/dist/search/useAthenaRepoSearch.cjs.map +1 -1
  461. package/dist/search/useAthenaRepoSearch.d.ts +3 -3
  462. package/dist/search/useAthenaRepoSearch.js +6 -14
  463. package/dist/search/useAthenaRepoSearch.js.map +1 -1
  464. package/dist/sheet-range/a1.cjs +162 -0
  465. package/dist/sheet-range/a1.cjs.map +1 -0
  466. package/dist/sheet-range/a1.d.ts +91 -0
  467. package/dist/sheet-range/a1.js +162 -0
  468. package/dist/sheet-range/a1.js.map +1 -0
  469. package/dist/sheet-range/index.cjs +22 -0
  470. package/dist/sheet-range/index.cjs.map +1 -0
  471. package/dist/sheet-range/index.d.ts +12 -0
  472. package/dist/sheet-range/index.js +22 -0
  473. package/dist/sheet-range/index.js.map +1 -0
  474. package/dist/sheet-range/range-preview-table.cjs +75 -0
  475. package/dist/sheet-range/range-preview-table.cjs.map +1 -0
  476. package/dist/sheet-range/range-preview-table.d.ts +20 -0
  477. package/dist/sheet-range/range-preview-table.js +75 -0
  478. package/dist/sheet-range/range-preview-table.js.map +1 -0
  479. package/dist/sheet-range/range-preview.cjs +116 -0
  480. package/dist/sheet-range/range-preview.cjs.map +1 -0
  481. package/dist/sheet-range/range-preview.d.ts +67 -0
  482. package/dist/sheet-range/range-preview.js +116 -0
  483. package/dist/sheet-range/range-preview.js.map +1 -0
  484. package/dist/styles.css +1 -1
  485. package/dist/threads/Inbox.cjs +289 -0
  486. package/dist/threads/Inbox.cjs.map +1 -0
  487. package/dist/threads/Inbox.d.ts +46 -0
  488. package/dist/threads/Inbox.js +289 -0
  489. package/dist/threads/Inbox.js.map +1 -0
  490. package/dist/threads/SessionList.cjs +51 -126
  491. package/dist/threads/SessionList.cjs.map +1 -1
  492. package/dist/threads/SessionList.d.ts +26 -1
  493. package/dist/threads/SessionList.js +45 -120
  494. package/dist/threads/SessionList.js.map +1 -1
  495. package/dist/threads/SessionsPage.cjs +753 -0
  496. package/dist/threads/SessionsPage.cjs.map +1 -0
  497. package/dist/threads/SessionsPage.d.ts +35 -0
  498. package/dist/threads/SessionsPage.js +753 -0
  499. package/dist/threads/SessionsPage.js.map +1 -0
  500. package/dist/threads/api.cjs +23 -2
  501. package/dist/threads/api.cjs.map +1 -1
  502. package/dist/threads/api.d.ts +60 -0
  503. package/dist/threads/api.js +23 -2
  504. package/dist/threads/api.js.map +1 -1
  505. package/dist/threads/conversation-list-fetcher.cjs +9 -2
  506. package/dist/threads/conversation-list-fetcher.cjs.map +1 -1
  507. package/dist/threads/conversation-list-fetcher.d.ts +14 -1
  508. package/dist/threads/conversation-list-fetcher.js +9 -2
  509. package/dist/threads/conversation-list-fetcher.js.map +1 -1
  510. package/dist/threads/index.d.ts +2 -1
  511. package/dist/threads/pull-request-display.cjs +25 -0
  512. package/dist/threads/pull-request-display.cjs.map +1 -0
  513. package/dist/threads/pull-request-display.d.ts +15 -0
  514. package/dist/threads/pull-request-display.js +25 -0
  515. package/dist/threads/pull-request-display.js.map +1 -0
  516. package/dist/threads/session-list-model.cjs +16 -2
  517. package/dist/threads/session-list-model.cjs.map +1 -1
  518. package/dist/threads/session-list-model.d.ts +10 -0
  519. package/dist/threads/session-list-model.js +16 -2
  520. package/dist/threads/session-list-model.js.map +1 -1
  521. package/dist/threads/session-row-parts.cjs +152 -0
  522. package/dist/threads/session-row-parts.cjs.map +1 -0
  523. package/dist/threads/session-row-parts.d.ts +50 -0
  524. package/dist/threads/session-row-parts.js +152 -0
  525. package/dist/threads/session-row-parts.js.map +1 -0
  526. package/dist/threads/sessions-page-model.cjs +305 -0
  527. package/dist/threads/sessions-page-model.cjs.map +1 -0
  528. package/dist/threads/sessions-page-model.d.ts +86 -0
  529. package/dist/threads/sessions-page-model.js +305 -0
  530. package/dist/threads/sessions-page-model.js.map +1 -0
  531. package/dist/threads/sessions-page-storage.cjs +93 -0
  532. package/dist/threads/sessions-page-storage.cjs.map +1 -0
  533. package/dist/threads/sessions-page-storage.d.ts +23 -0
  534. package/dist/threads/sessions-page-storage.js +93 -0
  535. package/dist/threads/sessions-page-storage.js.map +1 -0
  536. package/dist/threads/sessions-query.cjs +235 -0
  537. package/dist/threads/sessions-query.cjs.map +1 -0
  538. package/dist/threads/sessions-query.d.ts +119 -0
  539. package/dist/threads/sessions-query.js +235 -0
  540. package/dist/threads/sessions-query.js.map +1 -0
  541. package/dist/threads/statewire-thread-list.cjs +133 -40
  542. package/dist/threads/statewire-thread-list.cjs.map +1 -1
  543. package/dist/threads/statewire-thread-list.d.ts +83 -2
  544. package/dist/threads/statewire-thread-list.js +134 -41
  545. package/dist/threads/statewire-thread-list.js.map +1 -1
  546. package/dist/threads/use-athena-sessions.cjs +198 -0
  547. package/dist/threads/use-athena-sessions.cjs.map +1 -0
  548. package/dist/threads/use-athena-sessions.d.ts +81 -0
  549. package/dist/threads/use-athena-sessions.js +198 -0
  550. package/dist/threads/use-athena-sessions.js.map +1 -0
  551. package/dist/threads/use-athena-thread-model.cjs +14 -0
  552. package/dist/threads/use-athena-thread-model.cjs.map +1 -0
  553. package/dist/threads/use-athena-thread-model.d.ts +22 -0
  554. package/dist/threads/use-athena-thread-model.js +14 -0
  555. package/dist/threads/use-athena-thread-model.js.map +1 -0
  556. package/dist/threads/use-rest-conversation-history.cjs +1 -1
  557. package/dist/threads/use-rest-conversation-history.js +1 -1
  558. package/dist/threads/use-statewire-conversation-history.cjs +1 -1
  559. package/dist/threads/use-statewire-conversation-history.d.ts +3 -0
  560. package/dist/threads/use-statewire-conversation-history.js +1 -1
  561. package/dist/threads/use-thread-read-state.cjs +73 -0
  562. package/dist/threads/use-thread-read-state.cjs.map +1 -0
  563. package/dist/threads/use-thread-read-state.d.ts +51 -0
  564. package/dist/threads/use-thread-read-state.js +73 -0
  565. package/dist/threads/use-thread-read-state.js.map +1 -0
  566. package/dist/tiptap-markdown-table/src/markdown-table-serializer.cjs.map +1 -0
  567. package/dist/tiptap-markdown-table/src/markdown-table-serializer.js.map +1 -0
  568. package/dist/tools/auto-open-tools.cjs +2 -0
  569. package/dist/tools/auto-open-tools.cjs.map +1 -1
  570. package/dist/tools/auto-open-tools.js +2 -0
  571. package/dist/tools/auto-open-tools.js.map +1 -1
  572. package/dist/tools/file-tool-uis.cjs +18 -43
  573. package/dist/tools/file-tool-uis.cjs.map +1 -1
  574. package/dist/tools/file-tool-uis.d.ts +1 -2
  575. package/dist/tools/file-tool-uis.js +18 -42
  576. package/dist/tools/file-tool-uis.js.map +1 -1
  577. package/dist/tools/index.cjs +6 -2
  578. package/dist/tools/index.cjs.map +1 -1
  579. package/dist/tools/index.d.ts +1 -0
  580. package/dist/tools/index.js +6 -2
  581. package/dist/tools/index.js.map +1 -1
  582. package/dist/tools/misc-tool-uis.cjs +2 -2
  583. package/dist/tools/misc-tool-uis.js +2 -2
  584. package/dist/tools/primitives.cjs +1 -1
  585. package/dist/tools/primitives.js +1 -1
  586. package/dist/tools/read-asset-tool-ui.cjs +21 -70
  587. package/dist/tools/read-asset-tool-ui.cjs.map +1 -1
  588. package/dist/tools/read-asset-tool-ui.js +21 -70
  589. package/dist/tools/read-asset-tool-ui.js.map +1 -1
  590. package/dist/tools/step-text.cjs +21 -0
  591. package/dist/tools/step-text.cjs.map +1 -0
  592. package/dist/tools/step-text.d.ts +10 -0
  593. package/dist/tools/step-text.js +21 -0
  594. package/dist/tools/step-text.js.map +1 -0
  595. package/dist/tools/tool-fallback.cjs +24 -5
  596. package/dist/tools/tool-fallback.cjs.map +1 -1
  597. package/dist/tools/tool-fallback.d.ts +3 -1
  598. package/dist/tools/tool-fallback.js +24 -5
  599. package/dist/tools/tool-fallback.js.map +1 -1
  600. package/dist/tools/tool-summary.cjs +661 -0
  601. package/dist/tools/tool-summary.cjs.map +1 -0
  602. package/dist/tools/tool-summary.d.ts +99 -0
  603. package/dist/tools/tool-summary.js +661 -0
  604. package/dist/tools/tool-summary.js.map +1 -0
  605. package/dist/tools/tool-uis.cjs +37 -95
  606. package/dist/tools/tool-uis.cjs.map +1 -1
  607. package/dist/tools/tool-uis.js +37 -95
  608. package/dist/tools/tool-uis.js.map +1 -1
  609. package/dist/tools/voice-update-tool-ui.cjs +1 -1
  610. package/dist/tools/voice-update-tool-ui.js +1 -1
  611. package/dist/tools/write-todos-tool-ui.cjs +3 -2
  612. package/dist/tools/write-todos-tool-ui.cjs.map +1 -1
  613. package/dist/tools/write-todos-tool-ui.d.ts +5 -0
  614. package/dist/tools/write-todos-tool-ui.js +5 -4
  615. package/dist/tools/write-todos-tool-ui.js.map +1 -1
  616. package/dist/ui/popover.cjs +6 -6
  617. package/dist/ui/popover.cjs.map +1 -1
  618. package/dist/ui/popover.js +6 -6
  619. package/dist/ui/popover.js.map +1 -1
  620. package/dist/ui/tooltip.cjs +16 -2
  621. package/dist/ui/tooltip.cjs.map +1 -1
  622. package/dist/ui/tooltip.d.ts +1 -1
  623. package/dist/ui/tooltip.js +16 -2
  624. package/dist/ui/tooltip.js.map +1 -1
  625. package/dist/version.cjs +1 -1
  626. package/dist/version.js +1 -1
  627. package/dist/voice/use-athena-voice-session.cjs.map +1 -1
  628. package/dist/voice/use-athena-voice-session.d.ts +3 -3
  629. package/dist/voice/use-athena-voice-session.js.map +1 -1
  630. package/dist/workbench/SessionWorkbench.cjs +378 -0
  631. package/dist/workbench/SessionWorkbench.cjs.map +1 -0
  632. package/dist/workbench/SessionWorkbench.d.ts +30 -0
  633. package/dist/workbench/SessionWorkbench.js +378 -0
  634. package/dist/workbench/SessionWorkbench.js.map +1 -0
  635. package/dist/workbench/session-workbench-context.cjs +26 -0
  636. package/dist/workbench/session-workbench-context.cjs.map +1 -0
  637. package/dist/workbench/session-workbench-context.d.ts +55 -0
  638. package/dist/workbench/session-workbench-context.js +26 -0
  639. package/dist/workbench/session-workbench-context.js.map +1 -0
  640. package/dist/workbench/session-workbench-model.cjs +288 -0
  641. package/dist/workbench/session-workbench-model.cjs.map +1 -0
  642. package/dist/workbench/session-workbench-model.d.ts +168 -0
  643. package/dist/workbench/session-workbench-model.js +288 -0
  644. package/dist/workbench/session-workbench-model.js.map +1 -0
  645. package/dist/workbench/session-workbench-panes.cjs +580 -0
  646. package/dist/workbench/session-workbench-panes.cjs.map +1 -0
  647. package/dist/workbench/session-workbench-panes.d.ts +16 -0
  648. package/dist/workbench/session-workbench-panes.js +580 -0
  649. package/dist/workbench/session-workbench-panes.js.map +1 -0
  650. package/dist/workbench/session-workspace-api.cjs +157 -0
  651. package/dist/workbench/session-workspace-api.cjs.map +1 -0
  652. package/dist/workbench/session-workspace-api.d.ts +70 -0
  653. package/dist/workbench/session-workspace-api.js +157 -0
  654. package/dist/workbench/session-workspace-api.js.map +1 -0
  655. package/dist/workbench/use-session-workspace.cjs +100 -0
  656. package/dist/workbench/use-session-workspace.cjs.map +1 -0
  657. package/dist/workbench/use-session-workspace.d.ts +45 -0
  658. package/dist/workbench/use-session-workspace.js +100 -0
  659. package/dist/workbench/use-session-workspace.js.map +1 -0
  660. package/dist/workbench/workbench-layout-context.cjs +10 -0
  661. package/dist/workbench/workbench-layout-context.cjs.map +1 -0
  662. package/dist/workbench/workbench-layout-context.d.ts +17 -0
  663. package/dist/workbench/workbench-layout-context.js +10 -0
  664. package/dist/workbench/workbench-layout-context.js.map +1 -0
  665. package/package.json +21 -10
  666. package/dist/node_modules/@assistant-ui/react-langchain/dist/converter.cjs +0 -77
  667. package/dist/node_modules/@assistant-ui/react-langchain/dist/converter.cjs.map +0 -1
  668. package/dist/node_modules/@assistant-ui/react-langchain/dist/converter.js +0 -77
  669. package/dist/node_modules/@assistant-ui/react-langchain/dist/converter.js.map +0 -1
  670. package/dist/node_modules/@assistant-ui/react-langgraph/dist/convertLangChainMessages.cjs +0 -181
  671. package/dist/node_modules/@assistant-ui/react-langgraph/dist/convertLangChainMessages.cjs.map +0 -1
  672. package/dist/node_modules/@assistant-ui/react-langgraph/dist/convertLangChainMessages.js +0 -181
  673. package/dist/node_modules/@assistant-ui/react-langgraph/dist/convertLangChainMessages.js.map +0 -1
  674. package/dist/packages/agent-runtime/src/asset-attachment.cjs.map +0 -1
  675. package/dist/packages/agent-runtime/src/asset-attachment.js.map +0 -1
  676. package/dist/packages/agent-runtime/src/auth-denial.cjs.map +0 -1
  677. package/dist/packages/agent-runtime/src/auth-denial.js.map +0 -1
  678. package/dist/packages/agent-runtime/src/client-tool-bridge.cjs.map +0 -1
  679. package/dist/packages/agent-runtime/src/client-tool-bridge.js.map +0 -1
  680. package/dist/packages/agent-runtime/src/client-tools.cjs.map +0 -1
  681. package/dist/packages/agent-runtime/src/client-tools.js.map +0 -1
  682. package/dist/packages/agent-runtime/src/conversation-index.cjs.map +0 -1
  683. package/dist/packages/agent-runtime/src/conversation-index.js.map +0 -1
  684. package/dist/packages/agent-runtime/src/conversation-list.cjs.map +0 -1
  685. package/dist/packages/agent-runtime/src/conversation-list.js.map +0 -1
  686. package/dist/packages/agent-runtime/src/deep-agent-transport-recipe.cjs.map +0 -1
  687. package/dist/packages/agent-runtime/src/deep-agent-transport-recipe.js.map +0 -1
  688. package/dist/packages/agent-runtime/src/edit-command.cjs.map +0 -1
  689. package/dist/packages/agent-runtime/src/edit-command.js.map +0 -1
  690. package/dist/packages/agent-runtime/src/errors.cjs.map +0 -1
  691. package/dist/packages/agent-runtime/src/errors.js.map +0 -1
  692. package/dist/packages/agent-runtime/src/generated/runconfig-contract.cjs.map +0 -1
  693. package/dist/packages/agent-runtime/src/generated/runconfig-contract.js.map +0 -1
  694. package/dist/packages/agent-runtime/src/github-wake-event.cjs.map +0 -1
  695. package/dist/packages/agent-runtime/src/github-wake-event.js.map +0 -1
  696. package/dist/packages/agent-runtime/src/interrupts.cjs.map +0 -1
  697. package/dist/packages/agent-runtime/src/interrupts.js.map +0 -1
  698. package/dist/packages/agent-runtime/src/message-author.cjs.map +0 -1
  699. package/dist/packages/agent-runtime/src/message-author.js.map +0 -1
  700. package/dist/packages/agent-runtime/src/message-window.cjs.map +0 -1
  701. package/dist/packages/agent-runtime/src/message-window.js.map +0 -1
  702. package/dist/packages/agent-runtime/src/messages.cjs.map +0 -1
  703. package/dist/packages/agent-runtime/src/messages.js.map +0 -1
  704. package/dist/packages/agent-runtime/src/model-context.cjs.map +0 -1
  705. package/dist/packages/agent-runtime/src/model-context.js.map +0 -1
  706. package/dist/packages/agent-runtime/src/optimistic-content.cjs.map +0 -1
  707. package/dist/packages/agent-runtime/src/optimistic-content.js.map +0 -1
  708. package/dist/packages/agent-runtime/src/protocol.cjs.map +0 -1
  709. package/dist/packages/agent-runtime/src/protocol.js.map +0 -1
  710. package/dist/packages/agent-runtime/src/queue.cjs.map +0 -1
  711. package/dist/packages/agent-runtime/src/queue.js.map +0 -1
  712. package/dist/packages/agent-runtime/src/quota-safe-local-storage-session.cjs.map +0 -1
  713. package/dist/packages/agent-runtime/src/quota-safe-local-storage-session.js.map +0 -1
  714. package/dist/packages/agent-runtime/src/runtime-messages.cjs.map +0 -1
  715. package/dist/packages/agent-runtime/src/runtime-messages.js.map +0 -1
  716. package/dist/packages/agent-runtime/src/screen-point.cjs.map +0 -1
  717. package/dist/packages/agent-runtime/src/screen-point.js.map +0 -1
  718. package/dist/packages/agent-runtime/src/send-recovery.cjs.map +0 -1
  719. package/dist/packages/agent-runtime/src/send-recovery.js.map +0 -1
  720. package/dist/packages/agent-runtime/src/statewire-attach-observer.cjs.map +0 -1
  721. package/dist/packages/agent-runtime/src/statewire-attach-observer.js.map +0 -1
  722. package/dist/packages/agent-runtime/src/statewire-state.cjs.map +0 -1
  723. package/dist/packages/agent-runtime/src/statewire-state.js.map +0 -1
  724. package/dist/packages/agent-runtime/src/statewire-suspended.cjs.map +0 -1
  725. package/dist/packages/agent-runtime/src/statewire-suspended.js.map +0 -1
  726. package/dist/packages/agent-runtime/src/statewire-transport.cjs +0 -11
  727. package/dist/packages/agent-runtime/src/statewire-transport.cjs.map +0 -1
  728. package/dist/packages/agent-runtime/src/statewire-transport.js +0 -11
  729. package/dist/packages/agent-runtime/src/statewire-transport.js.map +0 -1
  730. package/dist/packages/agent-runtime/src/streaming-markdown.cjs.map +0 -1
  731. package/dist/packages/agent-runtime/src/streaming-markdown.js.map +0 -1
  732. package/dist/packages/agent-runtime/src/thread-extras.cjs.map +0 -1
  733. package/dist/packages/agent-runtime/src/thread-extras.js.map +0 -1
  734. package/dist/packages/agent-runtime/src/thread-snapshot-cache.cjs.map +0 -1
  735. package/dist/packages/agent-runtime/src/thread-snapshot-cache.js.map +0 -1
  736. package/dist/packages/agent-runtime/src/thread-status.cjs.map +0 -1
  737. package/dist/packages/agent-runtime/src/thread-status.js.map +0 -1
  738. package/dist/packages/agent-runtime/src/tool-metadata.cjs.map +0 -1
  739. package/dist/packages/agent-runtime/src/tool-metadata.js.map +0 -1
  740. package/dist/packages/agent-runtime/src/tool-outputs.cjs.map +0 -1
  741. package/dist/packages/agent-runtime/src/tool-outputs.js.map +0 -1
  742. package/dist/packages/agent-runtime/src/tool-result.cjs.map +0 -1
  743. package/dist/packages/agent-runtime/src/tool-result.js.map +0 -1
  744. package/dist/packages/agent-runtime/src/use-conversation-list.cjs.map +0 -1
  745. package/dist/packages/agent-runtime/src/use-conversation-list.js.map +0 -1
  746. package/dist/packages/agent-runtime/src/use-deep-agent-config.cjs +0 -13
  747. package/dist/packages/agent-runtime/src/use-deep-agent-config.cjs.map +0 -1
  748. package/dist/packages/agent-runtime/src/use-deep-agent-config.js +0 -13
  749. package/dist/packages/agent-runtime/src/use-deep-agent-config.js.map +0 -1
  750. package/dist/packages/agent-runtime/src/use-deep-agent-edit-submit.cjs.map +0 -1
  751. package/dist/packages/agent-runtime/src/use-deep-agent-edit-submit.js.map +0 -1
  752. package/dist/packages/agent-runtime/src/use-deep-agent-runtime.cjs.map +0 -1
  753. package/dist/packages/agent-runtime/src/use-deep-agent-runtime.js.map +0 -1
  754. package/dist/packages/agent-runtime/src/use-deep-agent-thread.cjs.map +0 -1
  755. package/dist/packages/agent-runtime/src/use-deep-agent-thread.js.map +0 -1
  756. package/dist/packages/agent-runtime/src/use-deep-agent-window-sync.cjs.map +0 -1
  757. package/dist/packages/agent-runtime/src/use-deep-agent-window-sync.js.map +0 -1
  758. package/dist/packages/agent-runtime/src/voice-presentation.cjs.map +0 -1
  759. package/dist/packages/agent-runtime/src/voice-presentation.js.map +0 -1
  760. package/dist/packages/agent-runtime/src/voice-turn-grouping.cjs.map +0 -1
  761. package/dist/packages/agent-runtime/src/voice-turn-grouping.js.map +0 -1
  762. package/dist/packages/tiptap-markdown-table/src/markdown-table-serializer.cjs.map +0 -1
  763. package/dist/packages/tiptap-markdown-table/src/markdown-table-serializer.js.map +0 -1
  764. /package/dist/{packages/agent-runtime → agent-runtime}/src/asset-attachment.cjs +0 -0
  765. /package/dist/{packages/agent-runtime → agent-runtime}/src/asset-attachment.js +0 -0
  766. /package/dist/{packages/agent-runtime → agent-runtime}/src/auth-denial.cjs +0 -0
  767. /package/dist/{packages/agent-runtime → agent-runtime}/src/auth-denial.js +0 -0
  768. /package/dist/{packages/agent-runtime → agent-runtime}/src/client-tool-bridge.cjs +0 -0
  769. /package/dist/{packages/agent-runtime → agent-runtime}/src/client-tool-bridge.js +0 -0
  770. /package/dist/{packages/agent-runtime → agent-runtime}/src/client-tools.cjs +0 -0
  771. /package/dist/{packages/agent-runtime → agent-runtime}/src/client-tools.js +0 -0
  772. /package/dist/{packages/agent-runtime → agent-runtime}/src/conversation-index.cjs +0 -0
  773. /package/dist/{packages/agent-runtime → agent-runtime}/src/conversation-index.js +0 -0
  774. /package/dist/{packages/agent-runtime → agent-runtime}/src/edit-command.cjs +0 -0
  775. /package/dist/{packages/agent-runtime → agent-runtime}/src/edit-command.js +0 -0
  776. /package/dist/{packages/agent-runtime → agent-runtime}/src/github-wake-event.cjs +0 -0
  777. /package/dist/{packages/agent-runtime → agent-runtime}/src/github-wake-event.js +0 -0
  778. /package/dist/{packages/agent-runtime → agent-runtime}/src/message-author.cjs +0 -0
  779. /package/dist/{packages/agent-runtime → agent-runtime}/src/message-author.js +0 -0
  780. /package/dist/{packages/agent-runtime → agent-runtime}/src/message-window.cjs +0 -0
  781. /package/dist/{packages/agent-runtime → agent-runtime}/src/message-window.js +0 -0
  782. /package/dist/{packages/agent-runtime → agent-runtime}/src/model-context.cjs +0 -0
  783. /package/dist/{packages/agent-runtime → agent-runtime}/src/model-context.js +0 -0
  784. /package/dist/{packages/agent-runtime → agent-runtime}/src/optimistic-content.cjs +0 -0
  785. /package/dist/{packages/agent-runtime → agent-runtime}/src/optimistic-content.js +0 -0
  786. /package/dist/{packages/agent-runtime → agent-runtime}/src/protocol.cjs +0 -0
  787. /package/dist/{packages/agent-runtime → agent-runtime}/src/protocol.js +0 -0
  788. /package/dist/{packages/agent-runtime → agent-runtime}/src/runtime-messages.cjs +0 -0
  789. /package/dist/{packages/agent-runtime → agent-runtime}/src/runtime-messages.js +0 -0
  790. /package/dist/{packages/agent-runtime → agent-runtime}/src/screen-point.cjs +0 -0
  791. /package/dist/{packages/agent-runtime → agent-runtime}/src/screen-point.js +0 -0
  792. /package/dist/{packages/agent-runtime → agent-runtime}/src/send-recovery.cjs +0 -0
  793. /package/dist/{packages/agent-runtime → agent-runtime}/src/send-recovery.js +0 -0
  794. /package/dist/{packages/agent-runtime → agent-runtime}/src/statewire-attach-observer.cjs +0 -0
  795. /package/dist/{packages/agent-runtime → agent-runtime}/src/statewire-attach-observer.js +0 -0
  796. /package/dist/{packages/agent-runtime → agent-runtime}/src/streaming-markdown.cjs +0 -0
  797. /package/dist/{packages/agent-runtime → agent-runtime}/src/streaming-markdown.js +0 -0
  798. /package/dist/{packages/agent-runtime → agent-runtime}/src/thread-extras.cjs +0 -0
  799. /package/dist/{packages/agent-runtime → agent-runtime}/src/thread-extras.js +0 -0
  800. /package/dist/{packages/agent-runtime → agent-runtime}/src/thread-snapshot-cache.cjs +0 -0
  801. /package/dist/{packages/agent-runtime → agent-runtime}/src/thread-snapshot-cache.js +0 -0
  802. /package/dist/{packages/agent-runtime → agent-runtime}/src/thread-status.cjs +0 -0
  803. /package/dist/{packages/agent-runtime → agent-runtime}/src/thread-status.js +0 -0
  804. /package/dist/{packages/agent-runtime → agent-runtime}/src/tool-outputs.cjs +0 -0
  805. /package/dist/{packages/agent-runtime → agent-runtime}/src/tool-outputs.js +0 -0
  806. /package/dist/{packages/agent-runtime → agent-runtime}/src/tool-result.cjs +0 -0
  807. /package/dist/{packages/agent-runtime → agent-runtime}/src/tool-result.js +0 -0
  808. /package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-runtime.cjs +0 -0
  809. /package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-runtime.js +0 -0
  810. /package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-window-sync.cjs +0 -0
  811. /package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-window-sync.js +0 -0
  812. /package/dist/{packages/agent-runtime → agent-runtime}/src/voice-turn-grouping.cjs +0 -0
  813. /package/dist/{packages/agent-runtime → agent-runtime}/src/voice-turn-grouping.js +0 -0
  814. /package/dist/{packages/react → react}/package.json.cjs.map +0 -0
  815. /package/dist/{packages/react → react}/package.json.js.map +0 -0
  816. /package/dist/{packages/tiptap-markdown-table → tiptap-markdown-table}/src/markdown-table-serializer.cjs +0 -0
  817. /package/dist/{packages/tiptap-markdown-table → tiptap-markdown-table}/src/markdown-table-serializer.js +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"statewire-thread-list.js","sources":["../../src/threads/statewire-thread-list.tsx"],"sourcesContent":["import {\n type ConversationAttention,\n type ConversationAttentionSource,\n type ConversationIndexEntry,\n type ConversationListFilter,\n type ConversationPullRequest,\n type ConversationSummary,\n type ConversationWake,\n conversationIndexUrlFromStatewireUrl,\n type DeepAgentHeadersResolver,\n type DeepAgentThreadSnapshotCache,\n deriveConversationAttention,\n summaryFromConversationIndexEntry,\n useConversationIndex,\n useConversationList,\n} from '@athenaintel/agent-runtime';\nimport { QueryClient, QueryClientProvider, useQuery } from '@tanstack/react-query';\nimport { useAuiState } from '@assistant-ui/react';\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n} from 'react';\nimport { AthenaAuthContext } from '../auth/AthenaAuthContext';\nimport {\n type AthenaStatewireTokenGetter,\n resolveStatewireAuthHeaders,\n resolveStatewireAuthToken,\n} from '../runtime/statewire-auth-headers';\nimport { fetchAccountIdentity, getThreadState } from './api';\nimport { createRestConversationListFetcher } from './conversation-list-fetcher';\nimport { credentialShape, sameCredentialShape } from './credential-shape';\nimport { mintThreadId } from './mint-thread-id';\nimport { useAthenaStatewireThreadId } from './thread-id-context';\nimport { createThreadPrefetcher } from './thread-prefetcher';\nimport { isSerializedContentPartsTitle, normalizeThreadTitle } from './title';\nimport { useRestartAfterAuthRefusal } from '../runtime/auth-refusal-restart';\nimport { withCredentialRenewal } from '../runtime/credential-renewal';\nimport { useThreadArchive } from './use-thread-archive';\nimport {\n type ThreadFavoriteTarget,\n useThreadFavorite,\n withFavoriteOverride,\n withFavoriteOverrides,\n} from './use-thread-favorite';\nimport {\n type ThreadRenameTarget,\n useThreadRename,\n withTitleOverride,\n withTitleOverrides,\n} from './use-thread-rename';\n\n/**\n * One row of the thread list — the fields a Devin-style session list renders\n * (`SessionList`), all read from the shared conversation-list contract. The\n * attention fields are `null` on a server that does not derive them; the\n * pull-request state is `null` until the list has fetched it (or when the\n * provider opted out of it).\n */\nexport interface AthenaStatewireThreadSummary {\n id: string;\n title: string | null;\n /**\n * What the session asks of the viewer: the server-derived state when\n * reported, else the client fallback from the status planes\n * (`deriveConversationAttention`).\n */\n attention: ConversationAttention | null;\n /** One line (≤ 80 chars) of what the viewer should do next, when the server derives one. */\n nextAction: string | null;\n attentionSource: ConversationAttentionSource | null;\n /**\n * Whether the viewer pinned the session. Toggled through\n * `AthenaStatewireThreadListState.setFavorited`; a toggle in flight is\n * reflected here at once and held until the list sources report it.\n */\n isFavorited: boolean;\n isUnread: boolean;\n /** Canonical status_v2 planes, or `null` on an older server. */\n sessionStatus: string | null;\n runStatus: string | null;\n /** Channel the session was started from (e.g. `web`, `github`, `api`). */\n startChannel: string | null;\n /** Client app that created the session (SESSION_APP_ID_GUIDE). */\n appId: string | null;\n /** Trigger marker (`manual` remains user-initiated; other values are automated). */\n triggerType: string | null;\n /** Pull requests the session opened with their live GitHub state. */\n pullRequests: ConversationPullRequest[] | null;\n /** The last wake of a resting session. */\n lastWake: ConversationWake | null;\n /** ISO 8601 timestamp of the last update (the list's sort key). */\n updatedAt: string;\n}\n\n/**\n * Thread-list state. The list is the persisted Agora session list; the ACTIVE\n * thread is a plain id the statewire runtime attaches to — switching threads\n * remounts the statewire session against the new `…/v2/threads/{id}` URL\n * (the same model the mobile app uses).\n */\nexport interface AthenaStatewireThreadListState {\n /** The rows the current `search` lists, newest first. */\n threads: AthenaStatewireThreadSummary[];\n isLoading: boolean;\n /** True while the live first page (or a history page) is being fetched. */\n isFetching: boolean;\n /**\n * True once the live first page has answered at least once for the current\n * search and identity. Until then an empty `threads` means \"not known\n * yet\" (no credential resolved, first page in flight), not \"no sessions\":\n * `SessionList` shows skeleton rows, never the empty state.\n */\n hasResolvedFirstPage: boolean;\n activeThreadId: string;\n /**\n * The active thread's row, independent of what `threads` currently lists:\n * a search that hides the row, or a page that has not fetched it, must not\n * make the active chat's attention disappear. Resolved from the listed row,\n * else the pushed index entry folded over the last row seen, else that\n * last row; `null` for a never-started chat the backend does not know yet.\n */\n activeThread: AthenaStatewireThreadSummary | null;\n /** True while the active thread is a locally-minted chat with no server history. */\n isNewChat: boolean;\n selectThread: (threadId: string) => void;\n /**\n * Warm the provider's snapshot cache with a thread's REST state ahead of a\n * `selectThread`, so the switch paints the transcript on its first frame\n * instead of the loading scrim while the statewire attach lands.\n * `SessionList` calls it after a 120 ms hover dwell and on row focus.\n * Fetches once per thread per identity, deduplicates requests in flight,\n * runs at most two at a time and ignores failures; a no-op for the active\n * thread, a thread the cache already holds, or a provider without a cache.\n */\n prefetchThread: (threadId: string) => void;\n newThread: () => void;\n refresh: () => void;\n /**\n * Server-side title search (`search` on the REST thread list). An empty\n * string lists everything; the search covers the viewer's whole authorized\n * history, not just the live page.\n */\n search: string;\n setSearch: (search: string) => void;\n /** Whether another page of older sessions can be fetched. */\n hasNextPage: boolean;\n isFetchingNextPage: boolean;\n /** Fetch the next page of older sessions (frozen history pages, never replayed). */\n fetchNextPage: () => void;\n /**\n * Pin or unpin a session (`POST /api/conversations/threads/favorite`). The\n * row flips at once and moves between the `Pinned` and `Recent` groups; the\n * server's answer is written back, and a failure restores the previous\n * state. Writes for one thread are serialized: a toggle while that\n * thread's write is in flight records the value and sends at most one\n * follow-up write once the first has answered.\n */\n setFavorited: (target: ThreadFavoriteTarget) => void;\n /** True while any pin toggle is in flight. */\n favoritePending: boolean;\n /** The sessions whose pin toggle is in flight; `SessionList` disables their pin control. */\n favoritePendingThreadIds: ReadonlySet<string>;\n /**\n * Whether the backend offers the favorite route. `false` once it answered\n * 404 / 405 (an agora that predates the route): `SessionList` then shows\n * the read-only pin and no toggle, and `setFavorited` keeps failing.\n */\n favoriteToggleAvailable: boolean;\n /**\n * Rename a session for every viewer (`POST /api/conversations/threads/rename`).\n * The row shows the new title at once; the server's stored title is\n * written back, and a failure restores the previous one. Same-thread\n * writes are serialized like the pin's.\n */\n renameThread: (target: ThreadRenameTarget) => void;\n /** The sessions whose rename is in flight; `SessionList` keeps their editor closed. */\n renamePendingThreadIds: ReadonlySet<string>;\n /**\n * Whether the backend offers the rename route. `false` once it answered\n * 404 / 405 (an agora that predates the route): `SessionList` then offers\n * no Rename action, and `renameThread` keeps failing.\n */\n renameAvailable: boolean;\n /**\n * Archive a session (`POST /api/conversations/threads/archive`). The row\n * leaves the list at once and stays hidden until both list sources stop\n * reporting it; a failure brings it back. Archiving the active session\n * moves the chat to a new one once the server has confirmed.\n */\n archiveThread: (threadId: string) => void;\n /** The sessions whose archive is in flight. */\n archivePendingThreadIds: ReadonlySet<string>;\n /** True while any archive is in flight. */\n archivePending: boolean;\n /**\n * Whether the backend offers the archive route. `false` once it answered\n * 404 / 405: `SessionList` then offers no Archive action.\n */\n archiveAvailable: boolean;\n /**\n * Where titles come from. `'index'` once the signed-in user's live\n * conversation index has replicated — titles and newly created threads then\n * arrive as pushed updates; `'poll'` while it has not (no signed-in\n * principal, e.g. API-key mode, or before its snapshot), when a\n * freshly-started thread's title is picked up by the bounded REST poll.\n */\n titleSource: 'index' | 'poll';\n}\n\nexport const AthenaStatewireThreadListContext =\n createContext<AthenaStatewireThreadListState | null>(null);\n\n/** Read the statewire thread-list state, or null outside that mode. */\nexport function useAthenaStatewireThreadList(): AthenaStatewireThreadListState | null {\n return useContext(AthenaStatewireThreadListContext);\n}\n\n/** Trigger a re-fetch of the thread list. `null` outside `enableThreadList` mode. */\nexport function useRefreshThreadList(): (() => void) | null {\n return useAthenaStatewireThreadList()?.refresh ?? null;\n}\n\n/**\n * Project one contract row onto the thread-list row. Exported for hosts (and\n * tests) that build rows from a `ConversationSummary` of their own.\n */\nexport function threadSummaryFromConversation(\n conversation: ConversationSummary,\n): AthenaStatewireThreadSummary {\n return {\n id: conversation.threadId,\n title: normalizeThreadTitle(conversation.title) ?? null,\n attention: deriveConversationAttention(conversation),\n nextAction: conversation.nextAction ?? null,\n attentionSource: conversation.attentionSource ?? null,\n isFavorited: conversation.isFavorited ?? false,\n isUnread: conversation.isUnread,\n sessionStatus: conversation.sessionStatus,\n runStatus: conversation.runStatus,\n startChannel: conversation.sourceChannel,\n appId: conversation.appId,\n triggerType: conversation.triggerType,\n pullRequests: conversation.pullRequests ?? null,\n lastWake: conversation.lastWake ?? null,\n updatedAt: conversation.updatedAt,\n };\n}\n\n/**\n * The statewire thread list reads one live page through the shared\n * conversation-list contract; the REST default page size predates the shared\n * pager and is preserved here.\n */\nconst THREAD_LIST_PAGE_SIZE = 50;\n\nfunction StatewireThreadListState({\n backendUrl,\n syncUrl,\n apiKey,\n token,\n getToken,\n appId,\n initialThreadId,\n includePullRequests,\n snapshotCache,\n children,\n}: {\n backendUrl: string;\n syncUrl?: string;\n apiKey?: string;\n token?: string | null;\n getToken?: AthenaStatewireTokenGetter;\n appId?: string;\n initialThreadId?: string;\n includePullRequests: boolean;\n snapshotCache?: DeepAgentThreadSnapshotCache;\n children: ReactNode;\n}) {\n const [active, setActive] = useState<{ id: string; isNew: boolean }>(() =>\n initialThreadId\n ? { id: initialThreadId, isNew: false }\n : { id: mintThreadId(), isNew: true },\n );\n const [search, setSearch] = useState('');\n\n const tokenRef = useRef(token);\n tokenRef.current = token;\n const apiKeyRef = useRef(apiKey);\n apiKeyRef.current = apiKey;\n const getTokenRef = useRef(getToken);\n getTokenRef.current = getToken;\n\n // The cache must be keyed by WHO is asking. Keying on `backendUrl`/`appId`\n // alone let a token swap to a different user read the previous user's thread\n // titles out of the cache. The principal is a non-secret user id, so no\n // credential enters the key (or React Query's devtools). The shared pager\n // never serves placeholder rows across keys, so another principal's list is\n // never shown while the new one loads.\n const authContext = useContext(AthenaAuthContext);\n const principal = authContext?.user?.userId ?? '';\n // A live token getter is a credential too: a `getToken`-only host\n // authenticates its chat, so its list must not stay empty.\n const hasAuth = !!(apiKey || token || getToken);\n\n // Resolved per request with the attach's token semantics (getter first,\n // host-held token as the fallback) so a rotated token is never stale;\n // `force` renews a token the host just refused (`withCredentialRenewal`).\n const getAuth = useCallback(\n async (options?: { force?: boolean }) => ({\n apiKey: apiKeyRef.current,\n token: await resolveStatewireAuthToken(\n { apiKey: apiKeyRef.current, token: tokenRef.current, getToken: getTokenRef.current },\n { staleAuth: options?.force ?? false },\n ),\n }),\n [],\n );\n const fetchPage = useMemo(\n () => createRestConversationListFetcher({ backendUrl, includePullRequests, getAuth }),\n [backendUrl, includePullRequests, getAuth],\n );\n const trimmedSearch = search.trim();\n const filter = useMemo<ConversationListFilter>(\n () => ({\n ...(appId ? { appId } : {}),\n ...(trimmedSearch ? { search: trimmedSearch } : {}),\n }),\n [appId, trimmedSearch],\n );\n const list = useConversationList({\n fetchPage,\n filter,\n pageSize: THREAD_LIST_PAGE_SIZE,\n // Pull-request opt-in changes what a cached row holds, so it is part of\n // the cache identity.\n scopeKey: `${backendUrl}::${principal}::${hasAuth ? 'auth' : 'anon'}::${\n includePullRequests ? 'prs' : 'no-prs'\n }`,\n enabled: hasAuth,\n });\n\n // Live rows ride the signed-in user's conversation index — the same push\n // channel the conversation-history panel renders from: the host replicates\n // title, lifecycle, attention and creation changes as ops, so a\n // freshly-started thread's server-generated title (or a session flipping to\n // \"needs you\") lands without polling. The index is one instance per\n // `(workspace, user)` in agora's ids, so the pair is resolved from the\n // backend once a principal is known and the index only attaches once both\n // halves are; API-key-only hosts keep the bounded REST poll\n // (`titleSource: 'poll'`).\n const indexHeaders = useCallback<DeepAgentHeadersResolver>(\n (ctx) =>\n resolveStatewireAuthHeaders(\n { apiKey: apiKeyRef.current, token: tokenRef.current, getToken: getTokenRef.current },\n ctx,\n ),\n [],\n );\n // The workspace half is the CREDENTIAL's: a scoped credential (sandbox,\n // preview, Office session) pins its own workspace, so swapping one for\n // another under the same principal must re-resolve the pair. The query is\n // therefore keyed by a credential generation — a counter that advances\n // whenever the host's credentials change — so no secret enters the key.\n const credentialsRef = useRef(credentialShape({ apiKey, token, getToken }));\n const credentialGenerationRef = useRef(0);\n const currentCredentials = credentialShape({ apiKey, token, getToken });\n if (!sameCredentialShape(credentialsRef.current, currentCredentials)) {\n credentialsRef.current = currentCredentials;\n credentialGenerationRef.current += 1;\n }\n const credentialGeneration = credentialGenerationRef.current;\n const identityEnabled = syncUrl !== undefined && principal.length > 0 && hasAuth;\n const identity = useQuery({\n // Keyed by the non-secret principal and credential generation, never the\n // credential itself.\n queryKey: ['athena-sdk', 'account-identity', backendUrl, principal, credentialGeneration],\n queryFn: ({ signal }) =>\n withCredentialRenewal(getAuth, (auth) => fetchAccountIdentity(backendUrl, auth, { signal })),\n enabled: identityEnabled,\n staleTime: Number.POSITIVE_INFINITY,\n });\n const indexWorkspaceId = identity.data?.workspaceId ?? '';\n const indexUserId = identity.data?.userId ?? '';\n const indexEnabled = identityEnabled && indexWorkspaceId.length > 0 && indexUserId.length > 0;\n const index = useConversationIndex({\n baseUrl: syncUrl === undefined ? '' : conversationIndexUrlFromStatewireUrl(syncUrl),\n workspaceId: indexWorkspaceId || 'pending-workspace',\n userId: indexUserId || 'pending-user',\n headers: indexHeaders,\n enabled: indexEnabled,\n });\n // The index parks after repeated credential refusals; re-arm it as soon as\n // a new token exists so live rows resume without a reload.\n useRestartAfterAuthRefusal({\n connection: index.connection,\n reconnect: index.connection.reconnect,\n });\n const indexByThread = useMemo(() => {\n const entries = new Map<string, ConversationIndexEntry>();\n for (const entry of index.entries ?? []) entries.set(entry.thread_id, entry);\n return entries;\n }, [index.entries]);\n\n // Each fetched row folds its pushed index entry through the shared\n // `summaryFromConversationIndexEntry`, so titles, lifecycle and attention\n // update live while the fields the index never carries (pull requests,\n // the last wake) keep their fetched values. A pushed title that normalizes\n // to nothing falls back to the fetched one.\n const mergedConversations = useMemo(\n () =>\n list.conversations.map((conversation) => {\n const entry = indexByThread.get(conversation.threadId);\n if (!entry) return conversation;\n const merged = summaryFromConversationIndexEntry(entry, conversation);\n return normalizeThreadTitle(merged.title) === undefined\n ? { ...merged, title: conversation.title }\n : merged;\n }),\n [list.conversations, indexByThread],\n );\n // A pin toggle sits over the fold: the row flips at once, and a pushed\n // index entry that predates the write cannot clobber it. The override drops\n // once both sources report the toggled value.\n const listPatchConversation = list.patchConversation;\n const favorite = useThreadFavorite({\n backendUrl,\n principalId: principal,\n getAuth,\n rows: mergedConversations,\n onServerTruth: ({ threadId, isFavorited }) =>\n listPatchConversation(threadId, { isFavorited }),\n });\n const favoriteOverrides = favorite.overrides;\n // A rename sits over the fold the same way: the row shows the new title\n // at once, and a pushed index entry that predates the write cannot restore\n // the old one. The override drops once both sources report the new title.\n const rename = useThreadRename({\n backendUrl,\n principalId: principal,\n getAuth,\n rows: mergedConversations,\n onServerTruth: ({ threadId, title }) => listPatchConversation(threadId, { title }),\n });\n const titleOverrides = rename.overrides;\n\n // An archive hides the row at once and keeps it hidden until neither list\n // source reports it any more — the cached page is patched on the server's\n // answer, but the pushed index may still carry the row until the publish\n // that follows the commit lands. A failure drops the id and the row comes\n // back from the still-cached page: no refetch needed. Scoping, the\n // one-write-per-thread guard and the route-missing fallback live in the hook.\n const listRemoveConversation = list.removeConversation;\n const archive = useThreadArchive({\n backendUrl,\n principalId: principal,\n getAuth,\n onArchived: (threadId) => {\n listRemoveConversation(threadId);\n // The archived session cannot stay the active chat: the server no\n // longer lists it, so the chat moves to a fresh one.\n setActive((current) =>\n current.id === threadId ? { id: mintThreadId(), isNew: true } : current,\n );\n },\n });\n const hiddenThreadIds = archive.hiddenThreadIds;\n const archiveRelease = archive.release;\n // A hidden row is released once both sources have forgotten it, so a\n // session archived elsewhere and then restored is never masked here.\n useEffect(() => {\n if (hiddenThreadIds.size === 0) return;\n const forgotten = [...hiddenThreadIds].filter(\n (threadId) =>\n !mergedConversations.some((conversation) => conversation.threadId === threadId) &&\n !indexByThread.has(threadId),\n );\n if (forgotten.length > 0) archiveRelease(forgotten);\n }, [hiddenThreadIds, mergedConversations, indexByThread, archiveRelease]);\n\n const data = useMemo(\n () =>\n withTitleOverrides(\n withFavoriteOverrides(mergedConversations, favoriteOverrides),\n titleOverrides,\n )\n .filter((conversation) => !hiddenThreadIds.has(conversation.threadId))\n .map(threadSummaryFromConversation),\n [mergedConversations, favoriteOverrides, titleOverrides, hiddenThreadIds],\n );\n const isLoading = list.isLoading;\n\n // The active thread's row must survive a search that filters it out of\n // the page (the banner above the chat reads it): the listed row when there\n // is one, else the pushed index entry folded over the last row seen for\n // this thread (so pull requests survive the fold), else that last row.\n const lastActiveConversationRef = useRef<ConversationSummary | null>(null);\n const activeConversation = useMemo<ConversationSummary | null>(() => {\n const listed = mergedConversations.find((conversation) => conversation.threadId === active.id);\n if (listed) return listed;\n const remembered =\n lastActiveConversationRef.current?.threadId === active.id\n ? lastActiveConversationRef.current\n : undefined;\n const entry = indexByThread.get(active.id);\n if (entry) return summaryFromConversationIndexEntry(entry, remembered);\n return remembered ?? null;\n }, [mergedConversations, indexByThread, active.id]);\n if (activeConversation !== null) lastActiveConversationRef.current = activeConversation;\n const activeThread = useMemo(\n () =>\n activeConversation\n ? threadSummaryFromConversation(\n withTitleOverride(\n withFavoriteOverride(activeConversation, favoriteOverrides),\n titleOverrides,\n ),\n )\n : null,\n [activeConversation, favoriteOverrides, titleOverrides],\n );\n\n const listRefresh = list.refresh;\n const refresh = useCallback(() => {\n void listRefresh();\n }, [listRefresh]);\n const listFetchNextPage = list.fetchNextPage;\n const fetchNextPage = useCallback(() => {\n void listFetchNextPage();\n }, [listFetchNextPage]);\n\n // A thread the index knows — created here on first send, or elsewhere —\n // that the REST page does not list yet: refresh once per such id so the row\n // appears without the user pressing refresh. Rows for other app ids belong\n // to other lists and never trigger one.\n const refreshedForRef = useRef<Set<string>>(new Set());\n useEffect(() => {\n if (index.entries === null) return;\n const listed = new Set(list.conversations.map((conversation) => conversation.threadId));\n let pending = false;\n for (const entry of index.entries) {\n if (appId && entry.app_id !== appId) continue;\n if (listed.has(entry.thread_id) || refreshedForRef.current.has(entry.thread_id)) continue;\n refreshedForRef.current.add(entry.thread_id);\n pending = true;\n }\n if (pending) void listRefresh();\n }, [index.entries, list.conversations, appId, listRefresh]);\n\n const selectThread = useCallback((threadId: string) => {\n if (!threadId) return;\n setActive((current) =>\n current.id === threadId ? current : { id: threadId, isNew: false },\n );\n }, []);\n\n // The hover prefetcher is one per (backend, principal, credential\n // generation): a credential swap clears the provider's snapshot cache, so\n // the attempt ledger resets with it and a late answer from the previous\n // identity is never remembered under the new one.\n const prefetchScope = `${backendUrl}::${principal}::${credentialGeneration}`;\n const prefetchScopeRef = useRef(prefetchScope);\n prefetchScopeRef.current = prefetchScope;\n const prefetcher = useMemo(() => {\n if (!snapshotCache) return null;\n const scope = prefetchScope;\n return createThreadPrefetcher({\n cache: snapshotCache,\n fetchState: async (threadId) =>\n withCredentialRenewal(getAuth, (auth) =>\n getThreadState(backendUrl, auth, threadId, { skipCache: false }),\n ),\n isCurrent: () => prefetchScopeRef.current === scope,\n });\n }, [snapshotCache, prefetchScope, backendUrl, getAuth]);\n const activeIdRef = useRef(active.id);\n activeIdRef.current = active.id;\n const prefetchThread = useCallback(\n (threadId: string) => {\n if (!prefetcher || !threadId || threadId === activeIdRef.current) return;\n prefetcher.prefetch(threadId);\n },\n [prefetcher],\n );\n\n const newThread = useCallback(() => {\n setActive({ id: mintThreadId(), isNew: true });\n }, []);\n\n // A minted thread stops being \"new\" once the backend lists it — on the\n // fetched page or in the pushed index (a search may keep it off the page):\n // until then `useAthenaThreadManager` reports a null id, so URL sync cannot\n // name it.\n const isPersisted =\n data.some((thread) => thread.id === active.id) || indexByThread.has(active.id);\n useEffect(() => {\n if (isPersisted) {\n setActive((current) => (current.isNew ? { ...current, isNew: false } : current));\n }\n }, [isPersisted]);\n\n const titleSource: AthenaStatewireThreadListState['titleSource'] =\n index.entries !== null ? 'index' : 'poll';\n\n const value = useMemo<AthenaStatewireThreadListState>(\n () => ({\n threads: data,\n isLoading,\n isFetching: list.isFetching,\n hasResolvedFirstPage: list.hasResolvedFirstPage,\n activeThreadId: active.id,\n activeThread,\n isNewChat: active.isNew,\n selectThread,\n prefetchThread,\n newThread,\n refresh,\n search,\n setSearch,\n hasNextPage: list.hasNextPage,\n isFetchingNextPage: list.isFetchingNextPage,\n fetchNextPage,\n setFavorited: favorite.setFavorited,\n favoritePending: favorite.isPending,\n favoritePendingThreadIds: favorite.pendingThreadIds,\n favoriteToggleAvailable: favorite.isAvailable,\n renameThread: rename.rename,\n renamePendingThreadIds: rename.pendingThreadIds,\n renameAvailable: rename.isAvailable,\n archiveThread: archive.archive,\n archivePendingThreadIds: archive.pendingThreadIds,\n archivePending: archive.isPending,\n archiveAvailable: archive.isAvailable,\n titleSource,\n }),\n [\n data,\n isLoading,\n list.isFetching,\n list.hasResolvedFirstPage,\n active.id,\n activeThread,\n active.isNew,\n selectThread,\n prefetchThread,\n newThread,\n refresh,\n search,\n list.hasNextPage,\n list.isFetchingNextPage,\n fetchNextPage,\n favorite.setFavorited,\n favorite.isPending,\n favorite.pendingThreadIds,\n favorite.isAvailable,\n rename.rename,\n rename.pendingThreadIds,\n rename.isAvailable,\n archive.archive,\n archive.pendingThreadIds,\n archive.isPending,\n archive.isAvailable,\n titleSource,\n ],\n );\n\n return (\n <AthenaStatewireThreadListContext.Provider value={value}>\n {children}\n </AthenaStatewireThreadListContext.Provider>\n );\n}\n\n/**\n * Provides the statewire thread-list state, with an SDK-scoped QueryClient so\n * consumers do not need their own QueryClientProvider. `syncUrl` (the\n * `…/v2/threads` mount) locates the conversation index beside it; without it\n * titles fall back to the REST poll. `includePullRequests` (default `true`)\n * asks the list for live pull-request state so `SessionList` can render its\n * chips; a host that never shows them turns it off to spare the server the\n * lookup. `snapshotCache` is the provider's thread snapshot cache — the one\n * the runtime seeds a switched-to thread from — which `prefetchThread` warms;\n * without it prefetching is a no-op.\n */\nexport function AthenaStatewireThreadListProvider({\n backendUrl,\n syncUrl,\n apiKey,\n token,\n getToken,\n appId,\n initialThreadId,\n includePullRequests = true,\n snapshotCache,\n children,\n}: {\n backendUrl: string;\n syncUrl?: string;\n apiKey?: string;\n token?: string | null;\n getToken?: AthenaStatewireTokenGetter;\n appId?: string;\n initialThreadId?: string;\n includePullRequests?: boolean;\n snapshotCache?: DeepAgentThreadSnapshotCache;\n children: ReactNode;\n}) {\n const [queryClient] = useState(() => new QueryClient());\n return (\n <QueryClientProvider client={queryClient}>\n <StatewireThreadListState\n backendUrl={backendUrl}\n syncUrl={syncUrl}\n apiKey={apiKey}\n token={token}\n getToken={getToken}\n appId={appId}\n initialThreadId={initialThreadId}\n includePullRequests={includePullRequests}\n snapshotCache={snapshotCache}\n >\n {children}\n </StatewireThreadListState>\n </QueryClientProvider>\n );\n}\n\n/** How long after a thread's first message the title poll starts (exported for tests). */\nexport const TITLE_POLL_DELAY_MS = 5000;\nconst TITLE_POLL_INTERVAL_MS = 2000;\nconst TITLE_POLL_MAX_DURATION_MS = 60_000;\n\n/**\n * Fallback for hosts without a live conversation index (`titleSource: 'poll'`,\n * i.e. no signed-in principal): refreshes the thread list until a\n * freshly-started thread's server-generated title appears. Idle while the\n * index carries titles. Mount inside the statewire runtime scope (needs aui\n * state).\n *\n * The thread is read from the statewire scope, not the list: the scope\n * publishes the id together with the client it belongs to, so the messages\n * observed here are always the named thread's (the list's selection moves\n * one commit ahead of the client during a switch).\n */\nexport function StatewireThreadTitlePoller(): null {\n const list = useAthenaStatewireThreadList();\n const activeThreadId = useAthenaStatewireThreadId();\n const hasMessages = useAuiState((s) => (s.optional.thread?.messages.length ?? 0) > 0);\n\n const titleSource = list?.titleSource ?? 'poll';\n const entry = list?.threads.find((thread) => thread.id === activeThreadId);\n const title = entry?.title?.trim() ?? '';\n const hasTitle = title.length > 0 && !isSerializedContentPartsTitle(title);\n\n // The poller stays mounted across thread switches, so the visit is tracked\n // by hand: one poll per visit — no restart when the visited thread's\n // messages or title flip underneath it — and a re-selected thread polls\n // again, as it did when every switch remounted the poller. The record is\n // replaced whenever the attached thread changes, whether or not a poll\n // started for it, so a visit to a thread that needs no poll can never make\n // the next visit to a previous thread look already polled.\n const visitRef = useRef<{ threadId: string; polled: boolean } | null>(null);\n const refreshRef = useRef(list?.refresh);\n refreshRef.current = list?.refresh;\n\n useEffect(() => {\n if (visitRef.current?.threadId !== activeThreadId) {\n visitRef.current = { threadId: activeThreadId, polled: false };\n }\n const visit = visitRef.current;\n if (!hasMessages || hasTitle || titleSource === 'index') return;\n if (visit.polled) return;\n visit.polled = true;\n\n let intervalId: ReturnType<typeof setInterval> | null = null;\n const startId = setTimeout(() => {\n intervalId = setInterval(() => refreshRef.current?.(), TITLE_POLL_INTERVAL_MS);\n }, TITLE_POLL_DELAY_MS);\n const stopId = setTimeout(() => {\n if (intervalId !== null) clearInterval(intervalId);\n }, TITLE_POLL_MAX_DURATION_MS);\n\n return () => {\n clearTimeout(startId);\n clearTimeout(stopId);\n if (intervalId !== null) clearInterval(intervalId);\n };\n }, [activeThreadId, hasMessages, hasTitle, titleSource]);\n\n return null;\n}\n"],"names":["_a"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAuNO,MAAM,mCACX,cAAqD,IAAI;AAGpD,SAAS,+BAAsE;AACpF,SAAO,WAAW,gCAAgC;AACpD;AAGO,SAAS,uBAA4C;;AAC1D,WAAO,kCAAA,MAAA,mBAAgC,YAAW;AACpD;AAMO,SAAS,8BACd,cAC8B;AAC9B,SAAO;AAAA,IACL,IAAI,aAAa;AAAA,IACjB,OAAO,qBAAqB,aAAa,KAAK,KAAK;AAAA,IACnD,WAAW,4BAA4B,YAAY;AAAA,IACnD,YAAY,aAAa,cAAc;AAAA,IACvC,i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AM,SAAS;AAEf,QAAI,aAAoD;AACxD,UAAM,UAAU,WAAW,MAAM;AAC/B,mBAAa,YAAY,MAAA;;AAAM,gBAAAA,MAAA,WAAW,YAAX,gBAAAA,IAAA;AAAA,SAAwB,sBAAsB;AAAA,IAC/E,GAAG,mBAAmB;AACtB,UAAM,SAAS,WAAW,MAAM;AAC9B,UAAI,eAAe,KAAM,eAAc,UAAU;AAAA,IACnD,GAAG,0BAA0B;AAE7B,WAAO,MAAM;AACX,mBAAa,OAAO;AACpB,mBAAa,MAAM;AACnB,UAAI,eAAe,KAAM,eAAc,UAAU;AAAA,IACnD;AAAA,EACF,GAAG,CAAC,gBAAgB,aAAa,UAAU,WAAW,CAAC;AAEvD,SAAO;AACT;"}
1
+ {"version":3,"file":"statewire-thread-list.js","sources":["../../src/threads/statewire-thread-list.tsx"],"sourcesContent":["import {\n type ConversationAttention,\n type ConversationAttentionSource,\n type ConversationIndexEntry,\n type ConversationListFilter,\n type ConversationPullRequest,\n type ConversationSummary,\n type ConversationWake,\n conversationIndexUrlFromStatewireUrl,\n type DeepAgentHeadersResolver,\n type DeepAgentThreadSnapshotCache,\n deriveConversationAttention,\n patchConversationListCaches,\n removeConversationFromListCaches,\n summaryFromConversationIndexEntry,\n useConversationIndex,\n useConversationList,\n} from '@athenaintel/agent-runtime';\nimport { QueryClient, QueryClientProvider, useQuery, useQueryClient } from '@tanstack/react-query';\nimport { useAuiState } from '@assistant-ui/react';\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n} from 'react';\nimport { AthenaAuthContext } from '../auth/AthenaAuthContext';\nimport {\n type AthenaStatewireTokenGetter,\n resolveStatewireAuthHeaders,\n resolveStatewireAuthToken,\n} from '../runtime/statewire-auth-headers';\nimport { fetchAccountIdentity, getThreadState } from './api';\nimport { createRestConversationListFetcher } from './conversation-list-fetcher';\nimport { credentialShape, sameCredentialShape } from './credential-shape';\nimport { mintThreadId } from './mint-thread-id';\nimport { useAthenaStatewireThreadId } from './thread-id-context';\nimport { createThreadPrefetcher } from './thread-prefetcher';\nimport { isSerializedContentPartsTitle, normalizeThreadTitle } from './title';\nimport { useRestartAfterAuthRefusal } from '../runtime/auth-refusal-restart';\nimport { type CredentialResolver, withCredentialRenewal } from '../runtime/credential-renewal';\nimport { useThreadArchive } from './use-thread-archive';\nimport {\n type ThreadFavoriteTarget,\n useThreadFavorite,\n withFavoriteOverride,\n withFavoriteOverrides,\n} from './use-thread-favorite';\nimport {\n type ThreadReadStateTarget,\n useThreadReadState,\n withReadStateOverrides,\n} from './use-thread-read-state';\nimport {\n type ThreadRenameTarget,\n useThreadRename,\n withTitleOverride,\n withTitleOverrides,\n} from './use-thread-rename';\n\n/**\n * One row of the thread list — the fields a Devin-style session list renders\n * (`SessionList`), all read from the shared conversation-list contract. The\n * attention fields are `null` on a server that does not derive them; the\n * pull-request state is `null` until the list has fetched it (or when the\n * provider opted out of it).\n */\nexport interface AthenaStatewireThreadSummary {\n id: string;\n title: string | null;\n /**\n * What the session asks of the viewer: the server-derived state when\n * reported, else the client fallback from the status planes\n * (`deriveConversationAttention`).\n */\n attention: ConversationAttention | null;\n /** One line (≤ 80 chars) of what the viewer should do next, when the server derives one. */\n nextAction: string | null;\n attentionSource: ConversationAttentionSource | null;\n /**\n * Whether the viewer pinned the session. Toggled through\n * `AthenaStatewireThreadListState.setFavorited`; a toggle in flight is\n * reflected here at once and held until the list sources report it.\n */\n isFavorited: boolean;\n isUnread: boolean;\n /** Canonical status_v2 planes, or `null` on an older server. */\n sessionStatus: string | null;\n runStatus: string | null;\n /** Channel the session was started from (e.g. `web`, `github`, `api`). */\n startChannel: string | null;\n /** Client app that created the session (SESSION_APP_ID_GUIDE). */\n appId: string | null;\n /** Trigger marker (`manual` remains user-initiated; other values are automated). */\n triggerType: string | null;\n /** Pull requests the session opened with their live GitHub state. */\n pullRequests: ConversationPullRequest[] | null;\n /** The last wake of a resting session. */\n lastWake: ConversationWake | null;\n /** ISO 8601 timestamp of the last update (the list's sort key). */\n updatedAt: string;\n /** ISO 8601 creation time; `null` when the list did not report it. */\n createdAt?: string | null;\n /** The session's last message, for a preview line (the inbox excerpt). */\n preview?: string | null;\n /** The collab agent the session started as, and its channel (`null`: the default channel). */\n collabAgentId?: string | null;\n collabChannelId?: string | null;\n /** Whether the viewer started the session (`false`: shared with them); `null` when not reported. */\n createdByMe?: boolean | null;\n}\n\n/**\n * Thread-list state. The list is the persisted Agora session list; the ACTIVE\n * thread is a plain id the statewire runtime attaches to — switching threads\n * remounts the statewire session against the new `…/v2/threads/{id}` URL\n * (the same model the mobile app uses).\n */\nexport interface AthenaStatewireThreadListState {\n /** The rows the current `search` lists, newest first. */\n threads: AthenaStatewireThreadSummary[];\n isLoading: boolean;\n /** True while the live first page (or a history page) is being fetched. */\n isFetching: boolean;\n /**\n * True once the live first page has answered at least once for the current\n * search and identity. Until then an empty `threads` means \"not known\n * yet\" (no credential resolved, first page in flight), not \"no sessions\":\n * `SessionList` shows skeleton rows, never the empty state.\n */\n hasResolvedFirstPage: boolean;\n activeThreadId: string;\n /**\n * The active thread's row, independent of what `threads` currently lists:\n * a search that hides the row, or a page that has not fetched it, must not\n * make the active chat's attention disappear. Resolved from the listed row,\n * else the pushed index entry folded over the last row seen, else that\n * last row; `null` for a never-started chat the backend does not know yet.\n */\n activeThread: AthenaStatewireThreadSummary | null;\n /** True while the active thread is a locally-minted chat with no server history. */\n isNewChat: boolean;\n selectThread: (threadId: string) => void;\n /**\n * Warm the provider's snapshot cache with a thread's REST state ahead of a\n * `selectThread`, so the switch paints the transcript on its first frame\n * instead of the loading scrim while the statewire attach lands.\n * `SessionList` calls it after a 120 ms hover dwell and on row focus.\n * Fetches once per thread per identity, deduplicates requests in flight,\n * runs at most two at a time and ignores failures; a no-op for the active\n * thread, a thread the cache already holds, or a provider without a cache.\n */\n prefetchThread: (threadId: string) => void;\n newThread: () => void;\n refresh: () => void;\n /**\n * Server-side title search (`search` on the REST thread list). An empty\n * string lists everything; the search covers the viewer's whole authorized\n * history, not just the live page.\n */\n search: string;\n setSearch: (search: string) => void;\n /** Whether another page of older sessions can be fetched. */\n hasNextPage: boolean;\n isFetchingNextPage: boolean;\n /** Fetch the next page of older sessions (frozen history pages, never replayed). */\n fetchNextPage: () => void;\n /**\n * Pin or unpin a session (`POST /api/conversations/threads/favorite`). The\n * row flips at once and moves between the `Pinned` and `Recent` groups; the\n * server's answer is written back, and a failure restores the previous\n * state. Writes for one thread are serialized: a toggle while that\n * thread's write is in flight records the value and sends at most one\n * follow-up write once the first has answered.\n */\n setFavorited: (target: ThreadFavoriteTarget) => void;\n /** True while any pin toggle is in flight. */\n favoritePending: boolean;\n /** The sessions whose pin toggle is in flight; `SessionList` disables their pin control. */\n favoritePendingThreadIds: ReadonlySet<string>;\n /**\n * Whether the backend offers the favorite route. `false` once it answered\n * 404 / 405 (an agora that predates the route): `SessionList` then shows\n * the read-only pin and no toggle, and `setFavorited` keeps failing.\n */\n favoriteToggleAvailable: boolean;\n /**\n * Rename a session for every viewer (`POST /api/conversations/threads/rename`).\n * The row shows the new title at once; the server's stored title is\n * written back, and a failure restores the previous one. Same-thread\n * writes are serialized like the pin's.\n */\n renameThread: (target: ThreadRenameTarget) => void;\n /** The sessions whose rename is in flight; `SessionList` keeps their editor closed. */\n renamePendingThreadIds: ReadonlySet<string>;\n /**\n * Whether the backend offers the rename route. `false` once it answered\n * 404 / 405 (an agora that predates the route): `SessionList` then offers\n * no Rename action, and `renameThread` keeps failing.\n */\n renameAvailable: boolean;\n /**\n * Archive a session (`POST /api/conversations/threads/archive`). The row\n * leaves the list at once and stays hidden until both list sources stop\n * reporting it; a failure brings it back. Archiving the active session\n * moves the chat to a new one once the server has confirmed.\n */\n archiveThread: (threadId: string) => void;\n /** The sessions whose archive is in flight. */\n archivePendingThreadIds: ReadonlySet<string>;\n /** True while any archive is in flight. */\n archivePending: boolean;\n /**\n * Whether the backend offers the archive route. `false` once it answered\n * 404 / 405: `SessionList` then offers no Archive action.\n */\n archiveAvailable: boolean;\n /**\n * Mark a session read or unread for the viewer\n * (`POST /api/conversations/threads/read-state`). The row flips at once in\n * every list under the provider (`SessionList`, `SessionsPage`, `Inbox`);\n * the server's answer is written back, and a failure restores the previous\n * state. Same-thread writes are serialized like the pin's.\n */\n setReadState: (target: ThreadReadStateTarget) => void;\n /** The sessions whose read-state write is in flight. */\n readStatePendingThreadIds: ReadonlySet<string>;\n /**\n * Where titles come from. `'index'` once the signed-in user's live\n * conversation index has replicated — titles and newly created threads then\n * arrive as pushed updates; `'poll'` while it has not (no signed-in\n * principal, e.g. API-key mode, or before its snapshot), when a\n * freshly-started thread's title is picked up by the bounded REST poll.\n */\n titleSource: 'index' | 'poll';\n}\n\nexport const AthenaStatewireThreadListContext =\n createContext<AthenaStatewireThreadListState | null>(null);\n\n/** Read the statewire thread-list state, or null outside that mode. */\nexport function useAthenaStatewireThreadList(): AthenaStatewireThreadListState | null {\n return useContext(AthenaStatewireThreadListContext);\n}\n\n/** Trigger a re-fetch of the thread list. `null` outside `enableThreadList` mode. */\nexport function useRefreshThreadList(): (() => void) | null {\n return useAthenaStatewireThreadList()?.refresh ?? null;\n}\n\n/**\n * Project one contract row onto the thread-list row. Exported for hosts (and\n * tests) that build rows from a `ConversationSummary` of their own.\n */\n/**\n * The threads the conversation index knows that the fetched list does not show yet, and that have\n * not prompted a refresh before: each warrants one refresh of the list. Only threads of the apps\n * the list shows count (its `appId` and `additionalAppIds`); with neither, every app's do.\n * Exported for tests.\n */\nexport function indexedThreadsToRefreshFor({\n entries,\n listedThreadIds,\n refreshedThreadIds,\n appId,\n additionalAppIds,\n}: {\n entries: ReadonlyArray<{ thread_id: string; app_id: string | null }>;\n listedThreadIds: ReadonlySet<string>;\n refreshedThreadIds: ReadonlySet<string>;\n appId: string | undefined;\n additionalAppIds: readonly string[];\n}): string[] {\n const shownAppIds =\n appId || additionalAppIds.length > 0\n ? new Set([...(appId ? [appId] : []), ...additionalAppIds])\n : null;\n return entries\n .filter((entry) => !shownAppIds || shownAppIds.has(entry.app_id ?? ''))\n .map((entry) => entry.thread_id)\n .filter((threadId) => !listedThreadIds.has(threadId) && !refreshedThreadIds.has(threadId));\n}\n\nexport function threadSummaryFromConversation(\n conversation: ConversationSummary,\n): AthenaStatewireThreadSummary {\n return {\n id: conversation.threadId,\n title: normalizeThreadTitle(conversation.title) ?? null,\n attention: deriveConversationAttention(conversation),\n nextAction: conversation.nextAction ?? null,\n attentionSource: conversation.attentionSource ?? null,\n isFavorited: conversation.isFavorited ?? false,\n isUnread: conversation.isUnread,\n sessionStatus: conversation.sessionStatus,\n runStatus: conversation.runStatus,\n startChannel: conversation.sourceChannel,\n appId: conversation.appId,\n triggerType: conversation.triggerType,\n pullRequests: conversation.pullRequests ?? null,\n lastWake: conversation.lastWake ?? null,\n updatedAt: conversation.updatedAt,\n createdAt: conversation.createdAt,\n preview: conversation.preview,\n collabAgentId: conversation.collabAgentId ?? null,\n collabChannelId: conversation.collabChannelId ?? null,\n createdByMe: conversation.createdByMe ?? null,\n };\n}\n\n/**\n * Fold the pushed conversation index into fetched rows: each row with an\n * index entry takes its pushed fields through the shared\n * `summaryFromConversationIndexEntry` (titles, lifecycle, attention), while\n * what the index never carries (pull requests, the last wake, who started\n * it) keeps the fetched value. A pushed title that normalizes to nothing\n * falls back to the fetched one. Exported for tests.\n */\nexport function foldConversationIndex(\n conversations: readonly ConversationSummary[],\n indexByThread: ReadonlyMap<string, ConversationIndexEntry>,\n): ConversationSummary[] {\n return conversations.map((conversation) => {\n const entry = indexByThread.get(conversation.threadId);\n if (!entry) return conversation;\n const merged = summaryFromConversationIndexEntry(entry, conversation);\n return normalizeThreadTitle(merged.title) === undefined\n ? { ...merged, title: conversation.title }\n : merged;\n });\n}\n\n/**\n * What the thread-list provider shares with the other lists mounted under it\n * (`SessionsPage`, `Inbox`): the credential, the live conversation index and\n * the optimistic overrides (pin, title, read state, archived rows), so every\n * list folds the same pushes and shows the same in-flight writes. Internal —\n * hosts use `useAthenaSessions`.\n */\nexport interface AthenaSessionsLiveState {\n backendUrl: string;\n getAuth: CredentialResolver<{ apiKey?: string; token?: string | null }>;\n principal: string;\n hasAuth: boolean;\n includePullRequests: boolean;\n /** The provider list's cache scope (backend, principal, auth, PR opt-in). */\n scopeKey: string;\n /**\n * Advances whenever the host's credential changes (a swapped API key or\n * token, a scoped credential for another workspace under the same\n * principal), so caches keyed on it are never read with another credential.\n */\n credentialGeneration: number;\n /** The app scope the provider lists (`appId` / `additionalListAppIds`). */\n baseFilter: ConversationListFilter;\n indexByThread: ReadonlyMap<string, ConversationIndexEntry>;\n /** `null` until the index has replicated (or without one). */\n indexEntries: readonly ConversationIndexEntry[] | null;\n /** Layer the in-flight writes over rows and drop archived ones. */\n applyOverrides: (rows: readonly ConversationSummary[]) => ConversationSummary[];\n}\n\nexport const AthenaSessionsLiveContext = createContext<AthenaSessionsLiveState | null>(null);\n\n/**\n * The statewire thread list reads one live page through the shared\n * conversation-list contract; the REST default page size predates the shared\n * pager and is preserved here.\n */\nconst THREAD_LIST_PAGE_SIZE = 50;\n\nfunction StatewireThreadListState({\n backendUrl,\n syncUrl,\n apiKey,\n token,\n getToken,\n appId,\n additionalListAppIds,\n initialThreadId,\n includePullRequests,\n snapshotCache,\n children,\n}: {\n backendUrl: string;\n syncUrl?: string;\n apiKey?: string;\n token?: string | null;\n getToken?: AthenaStatewireTokenGetter;\n appId?: string;\n additionalListAppIds?: readonly string[];\n initialThreadId?: string;\n includePullRequests: boolean;\n snapshotCache?: DeepAgentThreadSnapshotCache;\n children: ReactNode;\n}) {\n const [active, setActive] = useState<{ id: string; isNew: boolean }>(() =>\n initialThreadId\n ? { id: initialThreadId, isNew: false }\n : { id: mintThreadId(), isNew: true },\n );\n const [search, setSearch] = useState('');\n\n const tokenRef = useRef(token);\n tokenRef.current = token;\n const apiKeyRef = useRef(apiKey);\n apiKeyRef.current = apiKey;\n const getTokenRef = useRef(getToken);\n getTokenRef.current = getToken;\n\n // The cache must be keyed by WHO is asking. Keying on `backendUrl`/`appId`\n // alone let a token swap to a different user read the previous user's thread\n // titles out of the cache. The principal is a non-secret user id, so no\n // credential enters the key (or React Query's devtools). The shared pager\n // never serves placeholder rows across keys, so another principal's list is\n // never shown while the new one loads.\n const authContext = useContext(AthenaAuthContext);\n const principal = authContext?.user?.userId ?? '';\n // A live token getter is a credential too: a `getToken`-only host\n // authenticates its chat, so its list must not stay empty.\n const hasAuth = !!(apiKey || token || getToken);\n\n // Resolved per request with the attach's token semantics (getter first,\n // host-held token as the fallback) so a rotated token is never stale;\n // `force` renews a token the host just refused (`withCredentialRenewal`).\n const getAuth = useCallback(\n async (options?: { force?: boolean }) => ({\n apiKey: apiKeyRef.current,\n token: await resolveStatewireAuthToken(\n { apiKey: apiKeyRef.current, token: tokenRef.current, getToken: getTokenRef.current },\n { staleAuth: options?.force ?? false },\n ),\n }),\n [],\n );\n const fetchPage = useMemo(\n () => createRestConversationListFetcher({ backendUrl, includePullRequests, getAuth }),\n [backendUrl, includePullRequests, getAuth],\n );\n const trimmedSearch = search.trim();\n // A stable key, so a host passing a fresh array each render does not refetch; JSON keeps each\n // id exact (no separator an id could contain).\n const additionalListAppIdsKey = JSON.stringify(additionalListAppIds ?? []);\n const listedAppIds = useMemo<readonly string[]>(\n () => JSON.parse(additionalListAppIdsKey) as string[],\n [additionalListAppIdsKey],\n );\n const filter = useMemo<ConversationListFilter>(\n () => ({\n ...(appId ? { appId } : {}),\n ...(listedAppIds.length > 0 ? { appIds: listedAppIds } : {}),\n ...(trimmedSearch ? { search: trimmedSearch } : {}),\n }),\n [appId, listedAppIds, trimmedSearch],\n );\n // Pull-request opt-in changes what a cached row holds, so it is part of\n // the cache identity.\n const listScopeKey = `${backendUrl}::${principal}::${hasAuth ? 'auth' : 'anon'}::${\n includePullRequests ? 'prs' : 'no-prs'\n }`;\n const list = useConversationList({\n fetchPage,\n filter,\n pageSize: THREAD_LIST_PAGE_SIZE,\n scopeKey: listScopeKey,\n enabled: hasAuth,\n });\n\n // Live rows ride the signed-in user's conversation index — the same push\n // channel the conversation-history panel renders from: the host replicates\n // title, lifecycle, attention and creation changes as ops, so a\n // freshly-started thread's server-generated title (or a session flipping to\n // \"needs you\") lands without polling. The index is one instance per\n // `(workspace, user)` in agora's ids, so the pair is resolved from the\n // backend once a principal is known and the index only attaches once both\n // halves are; API-key-only hosts keep the bounded REST poll\n // (`titleSource: 'poll'`).\n const indexHeaders = useCallback<DeepAgentHeadersResolver>(\n (ctx) =>\n resolveStatewireAuthHeaders(\n { apiKey: apiKeyRef.current, token: tokenRef.current, getToken: getTokenRef.current },\n ctx,\n ),\n [],\n );\n // The workspace half is the CREDENTIAL's: a scoped credential (sandbox,\n // preview, Office session) pins its own workspace, so swapping one for\n // another under the same principal must re-resolve the pair. The query is\n // therefore keyed by a credential generation — a counter that advances\n // whenever the host's credentials change — so no secret enters the key.\n const credentialsRef = useRef(credentialShape({ apiKey, token, getToken }));\n const credentialGenerationRef = useRef(0);\n const currentCredentials = credentialShape({ apiKey, token, getToken });\n if (!sameCredentialShape(credentialsRef.current, currentCredentials)) {\n credentialsRef.current = currentCredentials;\n credentialGenerationRef.current += 1;\n }\n const credentialGeneration = credentialGenerationRef.current;\n const identityEnabled = syncUrl !== undefined && principal.length > 0 && hasAuth;\n const identity = useQuery({\n // Keyed by the non-secret principal and credential generation, never the\n // credential itself.\n queryKey: ['athena-sdk', 'account-identity', backendUrl, principal, credentialGeneration],\n queryFn: ({ signal }) =>\n withCredentialRenewal(getAuth, (auth) => fetchAccountIdentity(backendUrl, auth, { signal })),\n enabled: identityEnabled,\n staleTime: Number.POSITIVE_INFINITY,\n });\n const indexWorkspaceId = identity.data?.workspaceId ?? '';\n const indexUserId = identity.data?.userId ?? '';\n const indexEnabled = identityEnabled && indexWorkspaceId.length > 0 && indexUserId.length > 0;\n const index = useConversationIndex({\n baseUrl: syncUrl === undefined ? '' : conversationIndexUrlFromStatewireUrl(syncUrl),\n workspaceId: indexWorkspaceId || 'pending-workspace',\n userId: indexUserId || 'pending-user',\n headers: indexHeaders,\n enabled: indexEnabled,\n });\n // The index parks after repeated credential refusals; re-arm it as soon as\n // a new token exists so live rows resume without a reload.\n useRestartAfterAuthRefusal({\n connection: index.connection,\n reconnect: index.connection.reconnect,\n });\n const indexByThread = useMemo(() => {\n const entries = new Map<string, ConversationIndexEntry>();\n for (const entry of index.entries ?? []) entries.set(entry.thread_id, entry);\n return entries;\n }, [index.entries]);\n\n // Each fetched row folds its pushed index entry through the shared\n // `summaryFromConversationIndexEntry`, so titles, lifecycle and attention\n // update live while the fields the index never carries (pull requests,\n // the last wake) keep their fetched values. A pushed title that normalizes\n // to nothing falls back to the fetched one.\n const mergedConversations = useMemo(\n () => foldConversationIndex(list.conversations, indexByThread),\n [list.conversations, indexByThread],\n );\n // The server's answer to a write is patched into EVERY conversation list\n // cached under this provider (its own page, and any `SessionsPage` /\n // `Inbox` view) — the client is the provider's own, so nothing outside it\n // is touched.\n const queryClient = useQueryClient();\n const patchEveryList = useCallback(\n (threadId: string, patch: Partial<ConversationSummary>) =>\n patchConversationListCaches(queryClient, {\n match: (item) => item.threadId === threadId,\n patch,\n }),\n [queryClient],\n );\n // A pin toggle sits over the fold: the row flips at once, and a pushed\n // index entry that predates the write cannot clobber it. The override drops\n // once both sources report the toggled value.\n const favorite = useThreadFavorite({\n backendUrl,\n principalId: principal,\n getAuth,\n rows: mergedConversations,\n onServerTruth: ({ threadId, isFavorited }) => patchEveryList(threadId, { isFavorited }),\n });\n const favoriteOverrides = favorite.overrides;\n // A rename sits over the fold the same way: the row shows the new title\n // at once, and a pushed index entry that predates the write cannot restore\n // the old one. The override drops once both sources report the new title.\n const rename = useThreadRename({\n backendUrl,\n principalId: principal,\n getAuth,\n rows: mergedConversations,\n onServerTruth: ({ threadId, title }) => patchEveryList(threadId, { title }),\n });\n const titleOverrides = rename.overrides;\n // Read state likewise; the read-state route publishes no index update, so\n // the override is what keeps a stale pushed `is_unread` from flipping the\n // row back until the index's next rebuild agrees.\n const readState = useThreadReadState({\n backendUrl,\n principalId: principal,\n getAuth,\n rows: mergedConversations,\n onServerTruth: ({ threadId, isUnread }) => patchEveryList(threadId, { isUnread }),\n });\n const readOverrides = readState.overrides;\n const readCoveredUpdatedAt = readState.coveredUpdatedAt;\n\n // An archive hides the row at once and keeps it hidden until neither list\n // source reports it any more — the cached page is patched on the server's\n // answer, but the pushed index may still carry the row until the publish\n // that follows the commit lands. A failure drops the id and the row comes\n // back from the still-cached page: no refetch needed. Scoping, the\n // one-write-per-thread guard and the route-missing fallback live in the hook.\n const archive = useThreadArchive({\n backendUrl,\n principalId: principal,\n getAuth,\n onArchived: (threadId) => {\n removeConversationFromListCaches(queryClient, { threadId });\n // The archived session cannot stay the active chat: the server no\n // longer lists it, so the chat moves to a fresh one.\n setActive((current) =>\n current.id === threadId ? { id: mintThreadId(), isNew: true } : current,\n );\n },\n });\n const hiddenThreadIds = archive.hiddenThreadIds;\n const archiveRelease = archive.release;\n // A hidden row is released once both sources have forgotten it, so a\n // session archived elsewhere and then restored is never masked here.\n useEffect(() => {\n if (hiddenThreadIds.size === 0) return;\n const forgotten = [...hiddenThreadIds].filter(\n (threadId) =>\n !mergedConversations.some((conversation) => conversation.threadId === threadId) &&\n !indexByThread.has(threadId),\n );\n if (forgotten.length > 0) archiveRelease(forgotten);\n }, [hiddenThreadIds, mergedConversations, indexByThread, archiveRelease]);\n\n const applyOverrides = useCallback(\n (rows: readonly ConversationSummary[]) =>\n withReadStateOverrides(\n withTitleOverrides(withFavoriteOverrides(rows, favoriteOverrides), titleOverrides),\n readOverrides,\n readCoveredUpdatedAt,\n ).filter((conversation) => !hiddenThreadIds.has(conversation.threadId)),\n [favoriteOverrides, titleOverrides, readOverrides, readCoveredUpdatedAt, hiddenThreadIds],\n );\n const data = useMemo(\n () => applyOverrides(mergedConversations).map(threadSummaryFromConversation),\n [applyOverrides, mergedConversations],\n );\n const isLoading = list.isLoading;\n\n // The active thread's row must survive a search that filters it out of\n // the page (the banner above the chat reads it): the listed row when there\n // is one, else the pushed index entry folded over the last row seen for\n // this thread (so pull requests survive the fold), else that last row.\n const lastActiveConversationRef = useRef<ConversationSummary | null>(null);\n const activeConversation = useMemo<ConversationSummary | null>(() => {\n const listed = mergedConversations.find((conversation) => conversation.threadId === active.id);\n if (listed) return listed;\n const remembered =\n lastActiveConversationRef.current?.threadId === active.id\n ? lastActiveConversationRef.current\n : undefined;\n const entry = indexByThread.get(active.id);\n if (entry) return summaryFromConversationIndexEntry(entry, remembered);\n return remembered ?? null;\n }, [mergedConversations, indexByThread, active.id]);\n if (activeConversation !== null) lastActiveConversationRef.current = activeConversation;\n const activeThread = useMemo(\n () =>\n activeConversation\n ? threadSummaryFromConversation(\n withReadStateOverrides(\n [\n withTitleOverride(\n withFavoriteOverride(activeConversation, favoriteOverrides),\n titleOverrides,\n ),\n ],\n readOverrides,\n readCoveredUpdatedAt,\n )[0] ?? activeConversation,\n )\n : null,\n [activeConversation, favoriteOverrides, titleOverrides, readOverrides, readCoveredUpdatedAt],\n );\n\n const listRefresh = list.refresh;\n const refresh = useCallback(() => {\n void listRefresh();\n }, [listRefresh]);\n const listFetchNextPage = list.fetchNextPage;\n const fetchNextPage = useCallback(() => {\n void listFetchNextPage();\n }, [listFetchNextPage]);\n\n // A thread the index knows — created here on first send, or elsewhere —\n // that the REST page does not list yet: refresh once per such id so the row\n // appears without the user pressing refresh. Rows for apps this list does\n // not show (its `appId` and `additionalListAppIds`) never trigger one.\n const refreshedForRef = useRef<Set<string>>(new Set());\n useEffect(() => {\n if (index.entries === null) return;\n const unlisted = indexedThreadsToRefreshFor({\n entries: index.entries,\n listedThreadIds: new Set(list.conversations.map((conversation) => conversation.threadId)),\n refreshedThreadIds: refreshedForRef.current,\n appId,\n additionalAppIds: listedAppIds,\n });\n for (const threadId of unlisted) refreshedForRef.current.add(threadId);\n if (unlisted.length > 0) void listRefresh();\n }, [index.entries, list.conversations, appId, listedAppIds, listRefresh]);\n\n const selectThread = useCallback((threadId: string) => {\n if (!threadId) return;\n setActive((current) =>\n current.id === threadId ? current : { id: threadId, isNew: false },\n );\n }, []);\n\n // The hover prefetcher is one per (backend, principal, credential\n // generation): a credential swap clears the provider's snapshot cache, so\n // the attempt ledger resets with it and a late answer from the previous\n // identity is never remembered under the new one.\n const prefetchScope = `${backendUrl}::${principal}::${credentialGeneration}`;\n const prefetchScopeRef = useRef(prefetchScope);\n prefetchScopeRef.current = prefetchScope;\n const prefetcher = useMemo(() => {\n if (!snapshotCache) return null;\n const scope = prefetchScope;\n return createThreadPrefetcher({\n cache: snapshotCache,\n fetchState: async (threadId) =>\n withCredentialRenewal(getAuth, (auth) =>\n getThreadState(backendUrl, auth, threadId, { skipCache: false }),\n ),\n isCurrent: () => prefetchScopeRef.current === scope,\n });\n }, [snapshotCache, prefetchScope, backendUrl, getAuth]);\n const activeIdRef = useRef(active.id);\n activeIdRef.current = active.id;\n const prefetchThread = useCallback(\n (threadId: string) => {\n if (!prefetcher || !threadId || threadId === activeIdRef.current) return;\n prefetcher.prefetch(threadId);\n },\n [prefetcher],\n );\n\n const newThread = useCallback(() => {\n setActive({ id: mintThreadId(), isNew: true });\n }, []);\n\n // A minted thread stops being \"new\" once the backend lists it — on the\n // fetched page or in the pushed index (a search may keep it off the page):\n // until then `useAthenaThreadManager` reports a null id, so URL sync cannot\n // name it.\n const isPersisted =\n data.some((thread) => thread.id === active.id) || indexByThread.has(active.id);\n useEffect(() => {\n if (isPersisted) {\n setActive((current) => (current.isNew ? { ...current, isNew: false } : current));\n }\n }, [isPersisted]);\n\n const titleSource: AthenaStatewireThreadListState['titleSource'] =\n index.entries !== null ? 'index' : 'poll';\n\n const value = useMemo<AthenaStatewireThreadListState>(\n () => ({\n threads: data,\n isLoading,\n isFetching: list.isFetching,\n hasResolvedFirstPage: list.hasResolvedFirstPage,\n activeThreadId: active.id,\n activeThread,\n isNewChat: active.isNew,\n selectThread,\n prefetchThread,\n newThread,\n refresh,\n search,\n setSearch,\n hasNextPage: list.hasNextPage,\n isFetchingNextPage: list.isFetchingNextPage,\n fetchNextPage,\n setFavorited: favorite.setFavorited,\n favoritePending: favorite.isPending,\n favoritePendingThreadIds: favorite.pendingThreadIds,\n favoriteToggleAvailable: favorite.isAvailable,\n renameThread: rename.rename,\n renamePendingThreadIds: rename.pendingThreadIds,\n renameAvailable: rename.isAvailable,\n archiveThread: archive.archive,\n archivePendingThreadIds: archive.pendingThreadIds,\n archivePending: archive.isPending,\n archiveAvailable: archive.isAvailable,\n setReadState: readState.setReadState,\n readStatePendingThreadIds: readState.pendingThreadIds,\n titleSource,\n }),\n [\n data,\n isLoading,\n list.isFetching,\n list.hasResolvedFirstPage,\n active.id,\n activeThread,\n active.isNew,\n selectThread,\n prefetchThread,\n newThread,\n refresh,\n search,\n list.hasNextPage,\n list.isFetchingNextPage,\n fetchNextPage,\n favorite.setFavorited,\n favorite.isPending,\n favorite.pendingThreadIds,\n favorite.isAvailable,\n rename.rename,\n rename.pendingThreadIds,\n rename.isAvailable,\n archive.archive,\n archive.pendingThreadIds,\n archive.isPending,\n archive.isAvailable,\n readState.setReadState,\n readState.pendingThreadIds,\n titleSource,\n ],\n );\n\n const live = useMemo<AthenaSessionsLiveState>(\n () => ({\n backendUrl,\n getAuth,\n principal,\n hasAuth,\n includePullRequests,\n scopeKey: listScopeKey,\n credentialGeneration,\n baseFilter: {\n ...(appId ? { appId } : {}),\n ...(listedAppIds.length > 0 ? { appIds: listedAppIds } : {}),\n },\n indexByThread,\n indexEntries: index.entries,\n applyOverrides,\n }),\n [\n backendUrl,\n getAuth,\n principal,\n hasAuth,\n includePullRequests,\n listScopeKey,\n credentialGeneration,\n appId,\n listedAppIds,\n indexByThread,\n index.entries,\n applyOverrides,\n ],\n );\n\n return (\n <AthenaStatewireThreadListContext.Provider value={value}>\n <AthenaSessionsLiveContext.Provider value={live}>{children}</AthenaSessionsLiveContext.Provider>\n </AthenaStatewireThreadListContext.Provider>\n );\n}\n\n/**\n * Provides the statewire thread-list state, with an SDK-scoped QueryClient so\n * consumers do not need their own QueryClientProvider. `syncUrl` (the\n * `…/v2/threads` mount) locates the conversation index beside it; without it\n * titles fall back to the REST poll. `includePullRequests` (default `true`)\n * asks the list for live pull-request state so `SessionList` can render its\n * chips; a host that never shows them turns it off to spare the server the\n * lookup. `snapshotCache` is the provider's thread snapshot cache — the one\n * the runtime seeds a switched-to thread from — which `prefetchThread` warms;\n * without it prefetching is a no-op.\n */\nexport function AthenaStatewireThreadListProvider({\n backendUrl,\n syncUrl,\n apiKey,\n token,\n getToken,\n appId,\n additionalListAppIds,\n initialThreadId,\n includePullRequests = true,\n snapshotCache,\n children,\n}: {\n backendUrl: string;\n syncUrl?: string;\n apiKey?: string;\n token?: string | null;\n getToken?: AthenaStatewireTokenGetter;\n appId?: string;\n /** Other client apps whose sessions the list shows too (a union with `appId`). */\n additionalListAppIds?: readonly string[];\n initialThreadId?: string;\n includePullRequests?: boolean;\n snapshotCache?: DeepAgentThreadSnapshotCache;\n children: ReactNode;\n}) {\n const [queryClient] = useState(() => new QueryClient());\n return (\n <QueryClientProvider client={queryClient}>\n <StatewireThreadListState\n backendUrl={backendUrl}\n syncUrl={syncUrl}\n apiKey={apiKey}\n token={token}\n getToken={getToken}\n appId={appId}\n additionalListAppIds={additionalListAppIds}\n initialThreadId={initialThreadId}\n includePullRequests={includePullRequests}\n snapshotCache={snapshotCache}\n >\n {children}\n </StatewireThreadListState>\n </QueryClientProvider>\n );\n}\n\n/** How long after a thread's first message the title poll starts (exported for tests). */\nexport const TITLE_POLL_DELAY_MS = 5000;\nconst TITLE_POLL_INTERVAL_MS = 2000;\nconst TITLE_POLL_MAX_DURATION_MS = 60_000;\n\n/**\n * Fallback for hosts without a live conversation index (`titleSource: 'poll'`,\n * i.e. no signed-in principal): refreshes the thread list until a\n * freshly-started thread's server-generated title appears. Idle while the\n * index carries titles. Mount inside the statewire runtime scope (needs aui\n * state).\n *\n * The thread is read from the statewire scope, not the list: the scope\n * publishes the id together with the client it belongs to, so the messages\n * observed here are always the named thread's (the list's selection moves\n * one commit ahead of the client during a switch).\n */\nexport function StatewireThreadTitlePoller(): null {\n const list = useAthenaStatewireThreadList();\n const activeThreadId = useAthenaStatewireThreadId();\n const hasMessages = useAuiState((s) => (s.optional.thread?.messages.length ?? 0) > 0);\n\n const titleSource = list?.titleSource ?? 'poll';\n const entry = list?.threads.find((thread) => thread.id === activeThreadId);\n const title = entry?.title?.trim() ?? '';\n const hasTitle = title.length > 0 && !isSerializedContentPartsTitle(title);\n\n // The poller stays mounted across thread switches, so the visit is tracked\n // by hand: one poll per visit — no restart when the visited thread's\n // messages or title flip underneath it — and a re-selected thread polls\n // again, as it did when every switch remounted the poller. The record is\n // replaced whenever the attached thread changes, whether or not a poll\n // started for it, so a visit to a thread that needs no poll can never make\n // the next visit to a previous thread look already polled.\n const visitRef = useRef<{ threadId: string; polled: boolean } | null>(null);\n const refreshRef = useRef(list?.refresh);\n refreshRef.current = list?.refresh;\n\n useEffect(() => {\n if (visitRef.current?.threadId !== activeThreadId) {\n visitRef.current = { threadId: activeThreadId, polled: false };\n }\n const visit = visitRef.current;\n if (!hasMessages || hasTitle || titleSource === 'index') return;\n if (visit.polled) return;\n visit.polled = true;\n\n let intervalId: ReturnType<typeof setInterval> | null = null;\n const startId = setTimeout(() => {\n intervalId = setInterval(() => refreshRef.current?.(), TITLE_POLL_INTERVAL_MS);\n }, TITLE_POLL_DELAY_MS);\n const stopId = setTimeout(() => {\n if (intervalId !== null) clearInterval(intervalId);\n }, TITLE_POLL_MAX_DURATION_MS);\n\n return () => {\n clearTimeout(startId);\n clearTimeout(stopId);\n if (intervalId !== null) clearInterval(intervalId);\n };\n }, [activeThreadId, hasMessages, hasTitle, titleSource]);\n\n return null;\n}\n"],"names":["_a"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAiPO,MAAM,mCACX,cAAqD,IAAI;AAGpD,SAAS,+BAAsE;AACpF,SAAO,WAAW,gCAAgC;AACpD;AAGO,SAAS,uBAA4C;;AAC1D,WAAO,kC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AAC/B,mBAAa,YAAY,MAAA;;AAAM,gBAAAA,MAAA,WAAW,YAAX,gBAAAA,IAAA;AAAA,SAAwB,sBAAsB;AAAA,IAC/E,GAAG,mBAAmB;AACtB,UAAM,SAAS,WAAW,MAAM;AAC9B,UAAI,eAAe,KAAM,eAAc,UAAU;AAAA,IACnD,GAAG,0BAA0B;AAE7B,WAAO,MAAM;AACX,mBAAa,OAAO;AACpB,mBAAa,MAAM;AACnB,UAAI,eAAe,KAAM,eAAc,UAAU;AAAA,IACnD;AAAA,EACF,GAAG,CAAC,gBAAgB,aAAa,UAAU,WAAW,CAAC;AAEvD,SAAO;AACT;"}
@@ -0,0 +1,198 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const reactQuery = require("@tanstack/react-query");
4
+ const react = require("react");
5
+ const useAthenaRestQuery = require("../lib/use-athena-rest-query.cjs");
6
+ const credentialRenewal = require("../runtime/credential-renewal.cjs");
7
+ const api = require("./api.cjs");
8
+ const conversationListFetcher = require("./conversation-list-fetcher.cjs");
9
+ const sessionsQuery = require("./sessions-query.cjs");
10
+ const statewireThreadList = require("./statewire-thread-list.cjs");
11
+ const useConversationList = require("../agent-runtime/src/use-conversation-list.cjs");
12
+ const DEFAULT_PAGE_SIZE = 50;
13
+ const THREAD_LIST_CAPABILITIES_QUERY_KEY = [
14
+ "athena-sdk",
15
+ "thread-list-capabilities"
16
+ ];
17
+ const EMPTY_ROWS = [];
18
+ const NOOP = () => void 0;
19
+ const NOOP_ASYNC = async () => void 0;
20
+ function useAthenaSessions({
21
+ query,
22
+ pageSize = DEFAULT_PAGE_SIZE,
23
+ enabled = true
24
+ }) {
25
+ const live = react.useContext(statewireThreadList.AthenaSessionsLiveContext);
26
+ const isAvailable = live !== null;
27
+ const backendUrl = (live == null ? void 0 : live.backendUrl) ?? "";
28
+ const principal = (live == null ? void 0 : live.principal) ?? "";
29
+ const hasAuth = (live == null ? void 0 : live.hasAuth) ?? false;
30
+ const includePullRequests = (live == null ? void 0 : live.includePullRequests) ?? false;
31
+ const getAuth = live == null ? void 0 : live.getAuth;
32
+ const active = isAvailable && enabled && hasAuth;
33
+ const identityScope = `${(live == null ? void 0 : live.scopeKey) ?? "unavailable"}::credential-${(live == null ? void 0 : live.credentialGeneration) ?? 0}`;
34
+ const queryClient = useAthenaRestQuery.useAthenaQueryClient();
35
+ const capabilities = reactQuery.useQuery(
36
+ {
37
+ queryKey: [
38
+ ...THREAD_LIST_CAPABILITIES_QUERY_KEY,
39
+ backendUrl,
40
+ principal,
41
+ (live == null ? void 0 : live.credentialGeneration) ?? 0
42
+ ],
43
+ queryFn: async ({ signal }) => {
44
+ if (!getAuth) return null;
45
+ const response = await credentialRenewal.withCredentialRenewal(
46
+ getAuth,
47
+ (auth) => api.listThreads(backendUrl, auth, { limit: 1, signal })
48
+ );
49
+ return sessionsQuery.supportedFiltersFromResponse(response.supported_filters);
50
+ },
51
+ enabled: active,
52
+ staleTime: Number.POSITIVE_INFINITY,
53
+ retry: 1
54
+ },
55
+ queryClient
56
+ );
57
+ const capabilitiesSettled = capabilities.isSuccess || capabilities.isError;
58
+ const supportedFilters = capabilities.data ?? null;
59
+ const queryKey = sessionsQuery.sessionsQueryKey(query);
60
+ const plan = react.useMemo(
61
+ () => sessionsQuery.planSessionsQuery(sessionsQuery.sessionsQueryFromKey(queryKey), {
62
+ supportedFilters,
63
+ includePullRequests
64
+ }),
65
+ [queryKey, supportedFilters, includePullRequests]
66
+ );
67
+ const planRef = react.useRef(plan);
68
+ planRef.current = plan;
69
+ const unsupportedFields = react.useMemo(
70
+ () => capabilitiesSettled ? sessionsQuery.unavailableSessionsQueryFields({ supportedFilters, includePullRequests }) : [],
71
+ [capabilitiesSettled, supportedFilters, includePullRequests]
72
+ );
73
+ const fetchPage = react.useMemo(
74
+ () => getAuth ? conversationListFetcher.createRestConversationListFetcher({
75
+ backendUrl,
76
+ getAuth,
77
+ includePullRequests,
78
+ extraFilters: plan.body,
79
+ keepRow: (row) => sessionsQuery.matchesSessionsQuery(row, planRef.current.local)
80
+ }) : async () => ({ items: [], hasMore: false, totalCount: null }),
81
+ [backendUrl, getAuth, includePullRequests, plan.body]
82
+ );
83
+ const baseFilter = (live == null ? void 0 : live.baseFilter) ?? {};
84
+ const capabilityKey = supportedFilters ? [...supportedFilters].sort().join(",") : "legacy";
85
+ const list = useConversationList.useConversationList({
86
+ fetchPage,
87
+ filter: baseFilter,
88
+ pageSize,
89
+ // The query's server filters are not part of the shared filter contract,
90
+ // so they — and what this backend applies of them — key the cache here.
91
+ scopeKey: `${identityScope}::sessions::${queryKey}::${capabilityKey}`,
92
+ enabled: active && capabilitiesSettled,
93
+ queryClient
94
+ });
95
+ const lastResolvedRef = react.useRef({
96
+ scope: "",
97
+ conversations: []
98
+ });
99
+ if (list.hasResolvedFirstPage) {
100
+ lastResolvedRef.current = { scope: identityScope, conversations: list.conversations };
101
+ }
102
+ const standIn = !list.hasResolvedFirstPage && lastResolvedRef.current.scope === identityScope ? lastResolvedRef.current.conversations : null;
103
+ const source = standIn ?? list.conversations;
104
+ const isPlaceholderData = standIn !== null && standIn.length > 0;
105
+ const indexByThread = live == null ? void 0 : live.indexByThread;
106
+ const applyOverrides = live == null ? void 0 : live.applyOverrides;
107
+ const rows = react.useMemo(() => {
108
+ if (!indexByThread || !applyOverrides) return EMPTY_ROWS;
109
+ const folded = applyOverrides(
110
+ statewireThreadList.foldConversationIndex(source, indexByThread)
111
+ ).filter((row) => sessionsQuery.matchesSessionsQuery(row, plan.local));
112
+ return sessionsQuery.sortSessions(folded, plan.local).map(statewireThreadList.threadSummaryFromConversation);
113
+ }, [source, indexByThread, applyOverrides, plan.local]);
114
+ const refreshedForRef = react.useRef(/* @__PURE__ */ new Set());
115
+ const indexEntries = (live == null ? void 0 : live.indexEntries) ?? null;
116
+ const listRefresh = list.refresh;
117
+ const baseAppId = baseFilter.appId;
118
+ const baseAppIds = baseFilter.appIds;
119
+ react.useEffect(() => {
120
+ if (!active || indexEntries === null || !list.hasResolvedFirstPage) return;
121
+ const unlisted = indexEntryVersionsToRefresh({
122
+ entries: indexEntries,
123
+ listedThreadIds: new Set(list.conversations.map((conversation) => conversation.threadId)),
124
+ refreshedVersions: refreshedForRef.current,
125
+ appId: baseAppId,
126
+ additionalAppIds: baseAppIds ?? [],
127
+ query: plan.local
128
+ });
129
+ for (const version of unlisted) refreshedForRef.current.add(version);
130
+ if (unlisted.length > 0) void listRefresh();
131
+ }, [
132
+ active,
133
+ indexEntries,
134
+ list.hasResolvedFirstPage,
135
+ list.conversations,
136
+ baseAppId,
137
+ baseAppIds,
138
+ listRefresh,
139
+ plan.local
140
+ ]);
141
+ const listFetchNextPage = list.fetchNextPage;
142
+ return {
143
+ rows: isAvailable ? rows : EMPTY_ROWS,
144
+ isAvailable,
145
+ isLoading: active && (!capabilitiesSettled || list.isLoading),
146
+ isFetching: list.isFetching || capabilities.isFetching,
147
+ hasResolvedFirstPage: list.hasResolvedFirstPage,
148
+ isPlaceholderData,
149
+ hasNextPage: list.hasNextPage,
150
+ isFetchingNextPage: list.isFetchingNextPage,
151
+ fetchNextPage: isAvailable ? () => void listFetchNextPage() : NOOP,
152
+ refresh: isAvailable ? async () => void await listRefresh() : NOOP_ASYNC,
153
+ isFetchNextPageError: list.isFetchNextPageError,
154
+ supportedFilters,
155
+ degradedFields: plan.degraded,
156
+ unavailableFields: plan.unavailable,
157
+ unsupportedFields
158
+ };
159
+ }
160
+ function indexEntryVersionsToRefresh({
161
+ entries,
162
+ listedThreadIds,
163
+ refreshedVersions,
164
+ appId,
165
+ additionalAppIds,
166
+ query
167
+ }) {
168
+ const versionOf = (entry) => `${entry.thread_id}@${entry.updated_at}`;
169
+ const byVersion = new Map(entries.map((entry) => [versionOf(entry), entry]));
170
+ return statewireThreadList.indexedThreadsToRefreshFor({
171
+ entries: entries.map((entry) => ({ thread_id: versionOf(entry), app_id: entry.app_id })),
172
+ listedThreadIds: new Set(
173
+ entries.filter((entry) => listedThreadIds.has(entry.thread_id)).map(versionOf)
174
+ ),
175
+ refreshedThreadIds: refreshedVersions,
176
+ appId,
177
+ additionalAppIds
178
+ }).filter((version) => {
179
+ const entry = byVersion.get(version);
180
+ return entry === void 0 || entryCouldMatch(entry, query);
181
+ });
182
+ }
183
+ function entryCouldMatch(entry, query) {
184
+ if (query.unreadOnly && entry.is_unread === false) return false;
185
+ if (query.favoritesOnly && entry.is_favorited === false) return false;
186
+ if (query.runStatuses && typeof entry.run_status === "string" && !query.runStatuses.includes(entry.run_status)) {
187
+ return false;
188
+ }
189
+ if (query.sessionStatuses && typeof entry.session_status === "string" && !query.sessionStatuses.includes(entry.session_status)) {
190
+ return false;
191
+ }
192
+ return true;
193
+ }
194
+ exports.THREAD_LIST_CAPABILITIES_QUERY_KEY = THREAD_LIST_CAPABILITIES_QUERY_KEY;
195
+ exports.entryCouldMatch = entryCouldMatch;
196
+ exports.indexEntryVersionsToRefresh = indexEntryVersionsToRefresh;
197
+ exports.useAthenaSessions = useAthenaSessions;
198
+ //# sourceMappingURL=use-athena-sessions.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-athena-sessions.cjs","sources":["../../src/threads/use-athena-sessions.ts"],"sourcesContent":["/**\n * `useAthenaSessions(query)` — one filtered, sorted, live session list under\n * `<AthenaProvider enableThreadList>`: the data layer of `SessionsPage` and\n * `Inbox`, for hosts drawing their own.\n *\n * - **Server-side.** The query travels to `POST /api/conversations/threads/list`\n * as filters of the server's one page statement (`planSessionsQuery`), over\n * the shared two-tier pager (`useConversationList`: a live first page and\n * frozen history pages) in the thread-list provider's query client.\n * - **Live.** Rows fold the same conversation-index pushes the sidebar folds\n * (titles, lifecycle, attention flip in place), carry the provider's\n * in-flight writes (pin, rename, read state, archive), and a thread the\n * index learns about that the list does not show yet refreshes the list\n * once.\n * - **Degraded, not wrong.** A server that cannot apply part of the query is\n * detected from its `supported_filters` echo (one `limit: 1` probe per\n * identity). Fields the loaded rows can be tested on are applied to them\n * (`degradedFields`: exact per page, a page can come back short); fields\n * they cannot are reported in `unavailableFields` and not applied, so a\n * control for them can be disabled rather than lie.\n */\nimport {\n type ConversationListFilter,\n type ConversationSummary,\n useConversationList,\n} from '@athenaintel/agent-runtime';\nimport { useQuery } from '@tanstack/react-query';\nimport { useContext, useEffect, useMemo, useRef } from 'react';\nimport { useAthenaQueryClient } from '../lib/use-athena-rest-query';\nimport { withCredentialRenewal } from '../runtime/credential-renewal';\nimport { listThreads } from './api';\nimport { createRestConversationListFetcher } from './conversation-list-fetcher';\nimport {\n type AthenaSessionsQuery,\n type AthenaSessionsQueryField,\n matchesSessionsQuery,\n planSessionsQuery,\n sessionsQueryFromKey,\n sessionsQueryKey,\n sortSessions,\n supportedFiltersFromResponse,\n unavailableSessionsQueryFields,\n} from './sessions-query';\nimport {\n AthenaSessionsLiveContext,\n type AthenaStatewireThreadSummary,\n foldConversationIndex,\n indexedThreadsToRefreshFor,\n threadSummaryFromConversation,\n} from './statewire-thread-list';\n\nexport interface UseAthenaSessionsOptions {\n /** What to list. A new object with the same content does not refetch. */\n query: AthenaSessionsQuery;\n /** Rows per page (default 50). */\n pageSize?: number;\n /** `false` holds the list idle. Default `true`. */\n enabled?: boolean;\n}\n\nexport interface AthenaSessionsList {\n /** The rows, in the query's order, with live pushes and in-flight writes applied. */\n rows: AthenaStatewireThreadSummary[];\n /** `false` outside `enableThreadList` mode: nothing is fetched and `rows` stays empty. */\n isAvailable: boolean;\n /** True until the first page has answered (or while no credential has resolved). */\n isLoading: boolean;\n isFetching: boolean;\n hasResolvedFirstPage: boolean;\n /**\n * True while the rows are the previous query's (checked against this\n * query's local part) because this query's first page is still in flight.\n */\n isPlaceholderData: boolean;\n hasNextPage: boolean;\n isFetchingNextPage: boolean;\n fetchNextPage: () => void;\n /** Refetch the first page; resolves once it has answered. */\n refresh: () => Promise<void>;\n /** True while the last \"load more\" request failed. */\n isFetchNextPageError: boolean;\n /**\n * The server fields this backend applies (`supported_filters`), `null`\n * while unknown or on a backend that predates the list.\n */\n supportedFilters: ReadonlySet<string> | null;\n /** Fields applied to the loaded rows because the backend cannot. */\n degradedFields: AthenaSessionsQueryField[];\n /** Fields of this query that cannot be applied on this backend at all (and are not). */\n unavailableFields: AthenaSessionsQueryField[];\n /**\n * Every field this backend cannot apply anywhere, selected or not — what a\n * filter UI disables. Empty until the capabilities probe has answered.\n */\n unsupportedFields: AthenaSessionsQueryField[];\n}\n\nconst DEFAULT_PAGE_SIZE = 50;\n\n/** The capabilities probe's key prefix. */\nexport const THREAD_LIST_CAPABILITIES_QUERY_KEY = [\n 'athena-sdk',\n 'thread-list-capabilities',\n] as const;\n\nconst EMPTY_ROWS: AthenaStatewireThreadSummary[] = [];\nconst NOOP = () => undefined;\nconst NOOP_ASYNC = async () => undefined;\n\nexport function useAthenaSessions({\n query,\n pageSize = DEFAULT_PAGE_SIZE,\n enabled = true,\n}: UseAthenaSessionsOptions): AthenaSessionsList {\n const live = useContext(AthenaSessionsLiveContext);\n const isAvailable = live !== null;\n const backendUrl = live?.backendUrl ?? '';\n const principal = live?.principal ?? '';\n const hasAuth = live?.hasAuth ?? false;\n const includePullRequests = live?.includePullRequests ?? false;\n const getAuth = live?.getAuth;\n const active = isAvailable && enabled && hasAuth;\n // Every cache below is keyed by WHO reads (principal) and WITH WHAT (the\n // credential generation): a scoped credential for another workspace under\n // the same principal must never read this one's cached rows.\n const identityScope = `${live?.scopeKey ?? 'unavailable'}::credential-${\n live?.credentialGeneration ?? 0\n }`;\n\n // Outside thread-list mode there may be no `QueryClientProvider`; every\n // query below is disabled there, on a client of this hook's own.\n const queryClient = useAthenaQueryClient();\n\n // Which filters this backend applies: one tiny page per identity. The\n // answer is a property of the deployed agora, so it never goes stale.\n const capabilities = useQuery(\n {\n queryKey: [\n ...THREAD_LIST_CAPABILITIES_QUERY_KEY,\n backendUrl,\n principal,\n live?.credentialGeneration ?? 0,\n ],\n queryFn: async ({ signal }) => {\n if (!getAuth) return null;\n const response = await withCredentialRenewal(getAuth, (auth) =>\n listThreads(backendUrl, auth, { limit: 1, signal }),\n );\n return supportedFiltersFromResponse(response.supported_filters);\n },\n enabled: active,\n staleTime: Number.POSITIVE_INFINITY,\n retry: 1,\n },\n queryClient,\n );\n // A failed probe is treated as an older backend: the query degrades\n // instead of the list staying empty.\n const capabilitiesSettled = capabilities.isSuccess || capabilities.isError;\n const supportedFilters = capabilities.data ?? null;\n\n // `query` may be a fresh object every render; its normalized key is what\n // identifies it, so the plan is built from the key and recomputed only\n // when the content changes.\n const queryKey = sessionsQueryKey(query);\n const plan = useMemo(\n () =>\n planSessionsQuery(sessionsQueryFromKey(queryKey), {\n supportedFilters,\n includePullRequests,\n }),\n [queryKey, supportedFilters, includePullRequests],\n );\n const planRef = useRef(plan);\n planRef.current = plan;\n const unsupportedFields = useMemo(\n () =>\n capabilitiesSettled\n ? unavailableSessionsQueryFields({ supportedFilters, includePullRequests })\n : [],\n [capabilitiesSettled, supportedFilters, includePullRequests],\n );\n\n const fetchPage = useMemo(\n () =>\n getAuth\n ? createRestConversationListFetcher({\n backendUrl,\n getAuth,\n includePullRequests,\n extraFilters: plan.body,\n keepRow: (row) => matchesSessionsQuery(row, planRef.current.local),\n })\n : async () => ({ items: [], hasMore: false, totalCount: null }),\n [backendUrl, getAuth, includePullRequests, plan.body],\n );\n const baseFilter: ConversationListFilter = live?.baseFilter ?? {};\n const capabilityKey = supportedFilters ? [...supportedFilters].sort().join(',') : 'legacy';\n const list = useConversationList({\n fetchPage,\n filter: baseFilter,\n pageSize,\n // The query's server filters are not part of the shared filter contract,\n // so they — and what this backend applies of them — key the cache here.\n scopeKey: `${identityScope}::sessions::${queryKey}::${capabilityKey}`,\n enabled: active && capabilitiesSettled,\n queryClient,\n });\n\n // While a changed query's first page is in flight, the previous query's\n // rows stand in, checked against the new query's local part — the list\n // narrows at once instead of blanking to skeletons. Only rows read as the\n // same identity and credential ever stand in.\n const lastResolvedRef = useRef<{ scope: string; conversations: ConversationSummary[] }>({\n scope: '',\n conversations: [],\n });\n if (list.hasResolvedFirstPage) {\n lastResolvedRef.current = { scope: identityScope, conversations: list.conversations };\n }\n const standIn =\n !list.hasResolvedFirstPage && lastResolvedRef.current.scope === identityScope\n ? lastResolvedRef.current.conversations\n : null;\n const source = standIn ?? list.conversations;\n const isPlaceholderData = standIn !== null && standIn.length > 0;\n\n const indexByThread = live?.indexByThread;\n const applyOverrides = live?.applyOverrides;\n const rows = useMemo(() => {\n if (!indexByThread || !applyOverrides) return EMPTY_ROWS;\n const folded: ConversationSummary[] = applyOverrides(\n foldConversationIndex(source, indexByThread),\n ).filter((row) => matchesSessionsQuery(row, plan.local));\n return sortSessions(folded, plan.local).map(threadSummaryFromConversation);\n }, [source, indexByThread, applyOverrides, plan.local]);\n\n // A thread the index knows that this list does not show yet refreshes the\n // list — it may be new, or may have just come to match. Once per VERSION of\n // the entry (its id and `updated_at`): an unchanged entry the server keeps\n // leaving out never refreshes twice, and a later change to it (a PR opened,\n // a run now needing input) gets its own refresh.\n const refreshedForRef = useRef<Set<string>>(new Set());\n const indexEntries = live?.indexEntries ?? null;\n const listRefresh = list.refresh;\n const baseAppId = baseFilter.appId;\n const baseAppIds = baseFilter.appIds;\n useEffect(() => {\n if (!active || indexEntries === null || !list.hasResolvedFirstPage) return;\n const unlisted = indexEntryVersionsToRefresh({\n entries: indexEntries,\n listedThreadIds: new Set(list.conversations.map((conversation) => conversation.threadId)),\n refreshedVersions: refreshedForRef.current,\n appId: baseAppId,\n additionalAppIds: baseAppIds ?? [],\n query: plan.local,\n });\n for (const version of unlisted) refreshedForRef.current.add(version);\n if (unlisted.length > 0) void listRefresh();\n }, [\n active,\n indexEntries,\n list.hasResolvedFirstPage,\n list.conversations,\n baseAppId,\n baseAppIds,\n listRefresh,\n plan.local,\n ]);\n\n const listFetchNextPage = list.fetchNextPage;\n return {\n rows: isAvailable ? rows : EMPTY_ROWS,\n isAvailable,\n isLoading: active && (!capabilitiesSettled || list.isLoading),\n isFetching: list.isFetching || capabilities.isFetching,\n hasResolvedFirstPage: list.hasResolvedFirstPage,\n isPlaceholderData,\n hasNextPage: list.hasNextPage,\n isFetchingNextPage: list.isFetchingNextPage,\n fetchNextPage: isAvailable ? () => void listFetchNextPage() : NOOP,\n refresh: isAvailable ? async () => void (await listRefresh()) : NOOP_ASYNC,\n isFetchNextPageError: list.isFetchNextPageError,\n supportedFilters,\n degradedFields: plan.degraded,\n unavailableFields: plan.unavailable,\n unsupportedFields,\n };\n}\n\ntype IndexEntryLike = Parameters<typeof entryCouldMatch>[0] & {\n thread_id: string;\n updated_at: string;\n app_id: string | null;\n};\n\n/**\n * The index entries that warrant one refresh of a filtered list, as\n * `<thread_id>@<updated_at>` versions: entries the list does not show, of\n * the apps it lists, that the query could match on what the entry carries,\n * and whose version has not prompted a refresh before. An unchanged entry the\n * server keeps leaving out refreshes once; any later change to it refreshes\n * again. Exported for tests.\n */\nexport function indexEntryVersionsToRefresh({\n entries,\n listedThreadIds,\n refreshedVersions,\n appId,\n additionalAppIds,\n query,\n}: {\n entries: readonly IndexEntryLike[];\n listedThreadIds: ReadonlySet<string>;\n refreshedVersions: ReadonlySet<string>;\n appId: string | undefined;\n additionalAppIds: readonly string[];\n query: AthenaSessionsQuery;\n}): string[] {\n const versionOf = (entry: IndexEntryLike) => `${entry.thread_id}@${entry.updated_at}`;\n const byVersion = new Map(entries.map((entry) => [versionOf(entry), entry]));\n return indexedThreadsToRefreshFor({\n entries: entries.map((entry) => ({ thread_id: versionOf(entry), app_id: entry.app_id })),\n listedThreadIds: new Set(\n entries.filter((entry) => listedThreadIds.has(entry.thread_id)).map(versionOf),\n ),\n refreshedThreadIds: refreshedVersions,\n appId,\n additionalAppIds,\n }).filter((version) => {\n const entry = byVersion.get(version);\n return entry === undefined || entryCouldMatch(entry, query);\n });\n}\n\n/**\n * Whether a pushed index entry could belong to a list with this local query:\n * the fields the entry carries are checked, the rest pass.\n */\nexport function entryCouldMatch(\n entry: {\n is_unread?: boolean | null;\n is_favorited?: boolean | null;\n run_status?: string | null;\n session_status?: string | null;\n },\n query: AthenaSessionsQuery,\n): boolean {\n if (query.unreadOnly && entry.is_unread === false) return false;\n if (query.favoritesOnly && entry.is_favorited === false) return false;\n if (\n query.runStatuses &&\n typeof entry.run_status === 'string' &&\n !(query.runStatuses as readonly string[]).includes(entry.run_status)\n ) {\n return false;\n }\n if (\n query.sessionStatuses &&\n typeof entry.session_status === 'string' &&\n !(query.sessionStatuses as readonly string[]).includes(entry.session_status)\n ) {\n return false;\n }\n return true;\n}\n"],"names":["useContext","AthenaSessionsLiveContext","useAthenaQueryClient","useQuery","withCredentialRenewal","listThreads","supportedFiltersFromResponse","sessionsQueryKey","useMemo","planSessionsQuery","sessionsQueryFromKey","useRef","unavailableSessionsQueryFields","createRestConversationListFetcher","matchesSessionsQuery","useConversationList","foldConversationIndex","sortSessions","threadSummaryFromConversation","useEffect","indexedThreadsToRefreshFor"],"mappings":";;;;;;;;;;;AAiGA,MAAM,oBAAoB;AAGnB,MAAM,qCAAqC;AAAA,EAChD;AAAA,EACA;AACF;AAEA,MAAM,aAA6C,CAAA;AACnD,MAAM,OAAO,MAAM;AACnB,MAAM,aAAa,YAAY;AAExB,SAAS,kBAAkB;AAAA,EAChC;AAAA,EACA,WAAW;AAAA,EACX,UAAU;AACZ,GAAiD;AAC/C,QAAM,OAAOA,MAAAA,WAAWC,6CAAyB;AACjD,QAAM,cAAc,SAAS;AAC7B,QAAM,cAAa,6BAAM,eAAc;AACvC,QAAM,aAAY,6BAAM,cAAa;AACrC,QAAM,WAAU,6BAAM,YAAW;AACjC,QAAM,uBAAsB,6BAAM,wBAAuB;AACzD,QAAM,UAAU,6BAAM;AACtB,QAAM,SAAS,eAAe,WAAW;AAIzC,QAAM,gBAAgB,IAAG,6BAAM,aAAY,aAAa,iBACtD,6BAAM,yBAAwB,CAChC;AAIA,QAAM,cAAcC,mBAAAA,qBAAA;AAIpB,QAAM,eAAeC,WAAAA;AAAAA,IACnB;AAAA,MACE,UAAU;AAAA,QACR,GAAG;AAAA,QAC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AI,MAAM,UAAU;AACnF,QAAM,YAAY,IAAI,IAAI,QAAQ,IAAI,CAAC,UAAU,CAAC,UAAU,KAAK,GAAG,KAAK,CAAC,CAAC;AAC3E,SAAOC,+CAA2B;AAAA,IAChC,SAAS,QAAQ,IAAI,CAAC,WAAW,EAAE,WAAW,UAAU,KAAK,GAAG,QAAQ,MAAM,SAAS;AAAA,IACvF,iBAAiB,IAAI;AAAA,MACnB,QAAQ,OAAO,CAAC,UAAU,gBAAgB,IAAI,MAAM,SAAS,CAAC,EAAE,IAAI,SAAS;AAAA,IAAA;AAAA,IAE/E,oBAAoB;AAAA,IACpB;AAAA,IACA;AAAA,EAAA,CACD,EAAE,OAAO,CAAC,YAAY;AACrB,UAAM,QAAQ,UAAU,IAAI,OAAO;AACnC,WAAO,UAAU,UAAa,gBAAgB,OAAO,KAAK;AAAA,EAC5D,CAAC;AACH;AAMO,SAAS,gBACd,OAMA,OACS;AACT,MAAI,MAAM,cAAc,MAAM,cAAc,MAAO,QAAO;AAC1D,MAAI,MAAM,iBAAiB,MAAM,iBAAiB,MAAO,QAAO;AAChE,MACE,MAAM,eACN,OAAO,MAAM,eAAe,YAC5B,CAAE,MAAM,YAAkC,SAAS,MAAM,UAAU,GACnE;AACA,WAAO;AAAA,EACT;AACA,MACE,MAAM,mBACN,OAAO,MAAM,mBAAmB,YAChC,CAAE,MAAM,gBAAsC,SAAS,MAAM,cAAc,GAC3E;AACA,WAAO;AAAA,EACT;AACA,SAAO;AACT;;;;;"}
@@ -0,0 +1,81 @@
1
+ import { type AthenaSessionsQuery, type AthenaSessionsQueryField } from './sessions-query';
2
+ import { type AthenaStatewireThreadSummary } from './statewire-thread-list';
3
+ export interface UseAthenaSessionsOptions {
4
+ /** What to list. A new object with the same content does not refetch. */
5
+ query: AthenaSessionsQuery;
6
+ /** Rows per page (default 50). */
7
+ pageSize?: number;
8
+ /** `false` holds the list idle. Default `true`. */
9
+ enabled?: boolean;
10
+ }
11
+ export interface AthenaSessionsList {
12
+ /** The rows, in the query's order, with live pushes and in-flight writes applied. */
13
+ rows: AthenaStatewireThreadSummary[];
14
+ /** `false` outside `enableThreadList` mode: nothing is fetched and `rows` stays empty. */
15
+ isAvailable: boolean;
16
+ /** True until the first page has answered (or while no credential has resolved). */
17
+ isLoading: boolean;
18
+ isFetching: boolean;
19
+ hasResolvedFirstPage: boolean;
20
+ /**
21
+ * True while the rows are the previous query's (checked against this
22
+ * query's local part) because this query's first page is still in flight.
23
+ */
24
+ isPlaceholderData: boolean;
25
+ hasNextPage: boolean;
26
+ isFetchingNextPage: boolean;
27
+ fetchNextPage: () => void;
28
+ /** Refetch the first page; resolves once it has answered. */
29
+ refresh: () => Promise<void>;
30
+ /** True while the last "load more" request failed. */
31
+ isFetchNextPageError: boolean;
32
+ /**
33
+ * The server fields this backend applies (`supported_filters`), `null`
34
+ * while unknown or on a backend that predates the list.
35
+ */
36
+ supportedFilters: ReadonlySet<string> | null;
37
+ /** Fields applied to the loaded rows because the backend cannot. */
38
+ degradedFields: AthenaSessionsQueryField[];
39
+ /** Fields of this query that cannot be applied on this backend at all (and are not). */
40
+ unavailableFields: AthenaSessionsQueryField[];
41
+ /**
42
+ * Every field this backend cannot apply anywhere, selected or not — what a
43
+ * filter UI disables. Empty until the capabilities probe has answered.
44
+ */
45
+ unsupportedFields: AthenaSessionsQueryField[];
46
+ }
47
+ /** The capabilities probe's key prefix. */
48
+ export declare const THREAD_LIST_CAPABILITIES_QUERY_KEY: readonly ['athena-sdk', 'thread-list-capabilities'];
49
+ export declare function useAthenaSessions({ query, pageSize, enabled, }: UseAthenaSessionsOptions): AthenaSessionsList;
50
+ type IndexEntryLike = Parameters<typeof entryCouldMatch>[0] & {
51
+ thread_id: string;
52
+ updated_at: string;
53
+ app_id: string | null;
54
+ };
55
+ /**
56
+ * The index entries that warrant one refresh of a filtered list, as
57
+ * `<thread_id>@<updated_at>` versions: entries the list does not show, of
58
+ * the apps it lists, that the query could match on what the entry carries,
59
+ * and whose version has not prompted a refresh before. An unchanged entry the
60
+ * server keeps leaving out refreshes once; any later change to it refreshes
61
+ * again. Exported for tests.
62
+ */
63
+ export declare function indexEntryVersionsToRefresh({ entries, listedThreadIds, refreshedVersions, appId, additionalAppIds, query, }: {
64
+ entries: readonly IndexEntryLike[];
65
+ listedThreadIds: ReadonlySet<string>;
66
+ refreshedVersions: ReadonlySet<string>;
67
+ appId: string | undefined;
68
+ additionalAppIds: readonly string[];
69
+ query: AthenaSessionsQuery;
70
+ }): string[];
71
+ /**
72
+ * Whether a pushed index entry could belong to a list with this local query:
73
+ * the fields the entry carries are checked, the rest pass.
74
+ */
75
+ export declare function entryCouldMatch(entry: {
76
+ is_unread?: boolean | null;
77
+ is_favorited?: boolean | null;
78
+ run_status?: string | null;
79
+ session_status?: string | null;
80
+ }, query: AthenaSessionsQuery): boolean;
81
+ export {};