@athenaintel/react 0.41.2 → 0.42.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (451) hide show
  1. package/README.md +108 -9
  2. package/dist/agent-runtime/src/asset-attachment.d.ts +98 -0
  3. package/dist/agent-runtime/src/athena-asset-drag.d.ts +32 -0
  4. package/dist/agent-runtime/src/auth-denial.d.ts +29 -0
  5. package/dist/agent-runtime/src/chat-outbox-attachments.cjs +41 -0
  6. package/dist/agent-runtime/src/chat-outbox-attachments.cjs.map +1 -0
  7. package/dist/agent-runtime/src/chat-outbox-attachments.d.ts +38 -0
  8. package/dist/agent-runtime/src/chat-outbox-attachments.js +41 -0
  9. package/dist/agent-runtime/src/chat-outbox-attachments.js.map +1 -0
  10. package/dist/agent-runtime/src/chat-outbox-signals.cjs +63 -0
  11. package/dist/agent-runtime/src/chat-outbox-signals.cjs.map +1 -0
  12. package/dist/agent-runtime/src/chat-outbox-signals.d.ts +12 -0
  13. package/dist/agent-runtime/src/chat-outbox-signals.js +63 -0
  14. package/dist/agent-runtime/src/chat-outbox-signals.js.map +1 -0
  15. package/dist/agent-runtime/src/chat-outbox-store.cjs +509 -0
  16. package/dist/agent-runtime/src/chat-outbox-store.cjs.map +1 -0
  17. package/dist/agent-runtime/src/chat-outbox-store.d.ts +203 -0
  18. package/dist/agent-runtime/src/chat-outbox-store.js +509 -0
  19. package/dist/agent-runtime/src/chat-outbox-store.js.map +1 -0
  20. package/dist/agent-runtime/src/chat-outbox-thread.cjs +136 -0
  21. package/dist/agent-runtime/src/chat-outbox-thread.cjs.map +1 -0
  22. package/dist/agent-runtime/src/chat-outbox-thread.d.ts +118 -0
  23. package/dist/agent-runtime/src/chat-outbox-thread.js +136 -0
  24. package/dist/agent-runtime/src/chat-outbox-thread.js.map +1 -0
  25. package/dist/agent-runtime/src/chat-outbox.cjs +696 -0
  26. package/dist/agent-runtime/src/chat-outbox.cjs.map +1 -0
  27. package/dist/agent-runtime/src/chat-outbox.d.ts +285 -0
  28. package/dist/agent-runtime/src/chat-outbox.js +696 -0
  29. package/dist/agent-runtime/src/chat-outbox.js.map +1 -0
  30. package/dist/agent-runtime/src/chat-socket-reachability.d.ts +45 -0
  31. package/dist/agent-runtime/src/client-tool-bridge.d.ts +152 -0
  32. package/dist/agent-runtime/src/client-tools.d.ts +133 -0
  33. package/dist/agent-runtime/src/composer-markdown.cjs +10 -0
  34. package/dist/agent-runtime/src/composer-markdown.cjs.map +1 -1
  35. package/dist/agent-runtime/src/composer-markdown.d.ts +108 -0
  36. package/dist/agent-runtime/src/composer-markdown.js +10 -0
  37. package/dist/agent-runtime/src/composer-markdown.js.map +1 -1
  38. package/dist/agent-runtime/src/config-mutations.d.ts +51 -0
  39. package/dist/agent-runtime/src/conversation-index.d.ts +110 -0
  40. package/dist/agent-runtime/src/conversation-list.d.ts +343 -0
  41. package/dist/agent-runtime/src/deep-agent-transport-recipe.cjs +3 -2
  42. package/dist/agent-runtime/src/deep-agent-transport-recipe.cjs.map +1 -1
  43. package/dist/agent-runtime/src/deep-agent-transport-recipe.d.ts +166 -0
  44. package/dist/agent-runtime/src/deep-agent-transport-recipe.js +3 -2
  45. package/dist/agent-runtime/src/deep-agent-transport-recipe.js.map +1 -1
  46. package/dist/agent-runtime/src/desktop-handoff.d.ts +139 -0
  47. package/dist/agent-runtime/src/durable-thread-snapshot-cache.cjs +158 -0
  48. package/dist/agent-runtime/src/durable-thread-snapshot-cache.cjs.map +1 -0
  49. package/dist/agent-runtime/src/durable-thread-snapshot-cache.d.ts +60 -0
  50. package/dist/agent-runtime/src/durable-thread-snapshot-cache.js +158 -0
  51. package/dist/agent-runtime/src/durable-thread-snapshot-cache.js.map +1 -0
  52. package/dist/agent-runtime/src/edit-command.d.ts +156 -0
  53. package/dist/agent-runtime/src/errors.d.ts +174 -0
  54. package/dist/agent-runtime/src/execute-output.d.ts +31 -0
  55. package/dist/agent-runtime/src/generated/runconfig-contract.cjs +16 -2
  56. package/dist/agent-runtime/src/generated/runconfig-contract.cjs.map +1 -1
  57. package/dist/agent-runtime/src/generated/runconfig-contract.d.ts +202 -0
  58. package/dist/agent-runtime/src/generated/runconfig-contract.js +16 -2
  59. package/dist/agent-runtime/src/generated/runconfig-contract.js.map +1 -1
  60. package/dist/agent-runtime/src/github-wake-event.d.ts +77 -0
  61. package/dist/agent-runtime/src/index.d.ts +74 -0
  62. package/dist/agent-runtime/src/interrupts.cjs +17 -0
  63. package/dist/agent-runtime/src/interrupts.cjs.map +1 -1
  64. package/dist/agent-runtime/src/interrupts.d.ts +348 -0
  65. package/dist/agent-runtime/src/interrupts.js +17 -0
  66. package/dist/agent-runtime/src/interrupts.js.map +1 -1
  67. package/dist/agent-runtime/src/lane-follow.d.ts +121 -0
  68. package/dist/agent-runtime/src/lane-history.cjs +209 -0
  69. package/dist/agent-runtime/src/lane-history.cjs.map +1 -0
  70. package/dist/agent-runtime/src/lane-history.d.ts +175 -0
  71. package/dist/agent-runtime/src/lane-history.js +209 -0
  72. package/dist/agent-runtime/src/lane-history.js.map +1 -0
  73. package/dist/agent-runtime/src/lane-images.d.ts +184 -0
  74. package/dist/agent-runtime/src/message-author.d.ts +43 -0
  75. package/dist/agent-runtime/src/message-text.cjs +15 -0
  76. package/dist/agent-runtime/src/message-text.cjs.map +1 -0
  77. package/dist/agent-runtime/src/message-text.d.ts +47 -0
  78. package/dist/agent-runtime/src/message-text.js +15 -0
  79. package/dist/agent-runtime/src/message-text.js.map +1 -0
  80. package/dist/agent-runtime/src/message-window.cjs +15 -1
  81. package/dist/agent-runtime/src/message-window.cjs.map +1 -1
  82. package/dist/agent-runtime/src/message-window.d.ts +159 -0
  83. package/dist/agent-runtime/src/message-window.js +16 -2
  84. package/dist/agent-runtime/src/message-window.js.map +1 -1
  85. package/dist/agent-runtime/src/messages.cjs +88 -4
  86. package/dist/agent-runtime/src/messages.cjs.map +1 -1
  87. package/dist/agent-runtime/src/messages.d.ts +603 -0
  88. package/dist/agent-runtime/src/messages.js +88 -4
  89. package/dist/agent-runtime/src/messages.js.map +1 -1
  90. package/dist/agent-runtime/src/model-context.d.ts +22 -0
  91. package/dist/agent-runtime/src/offline-status.d.ts +157 -0
  92. package/dist/agent-runtime/src/optimistic-content.d.ts +21 -0
  93. package/dist/agent-runtime/src/protocol.cjs +12 -4
  94. package/dist/agent-runtime/src/protocol.cjs.map +1 -1
  95. package/dist/agent-runtime/src/protocol.d.ts +119 -0
  96. package/dist/agent-runtime/src/protocol.js +13 -5
  97. package/dist/agent-runtime/src/protocol.js.map +1 -1
  98. package/dist/agent-runtime/src/ptc-subcalls.d.ts +51 -0
  99. package/dist/agent-runtime/src/queue.d.ts +138 -0
  100. package/dist/agent-runtime/src/quota-safe-local-storage-session.d.ts +154 -0
  101. package/dist/agent-runtime/src/running-tool-placeholder.cjs +11 -0
  102. package/dist/agent-runtime/src/running-tool-placeholder.cjs.map +1 -0
  103. package/dist/agent-runtime/src/running-tool-placeholder.d.ts +25 -0
  104. package/dist/agent-runtime/src/running-tool-placeholder.js +11 -0
  105. package/dist/agent-runtime/src/running-tool-placeholder.js.map +1 -0
  106. package/dist/agent-runtime/src/runtime-messages.d.ts +104 -0
  107. package/dist/agent-runtime/src/screen-point.d.ts +151 -0
  108. package/dist/agent-runtime/src/sealed-idb.cjs +112 -0
  109. package/dist/agent-runtime/src/sealed-idb.cjs.map +1 -0
  110. package/dist/agent-runtime/src/sealed-idb.d.ts +106 -0
  111. package/dist/agent-runtime/src/sealed-idb.js +112 -0
  112. package/dist/agent-runtime/src/sealed-idb.js.map +1 -0
  113. package/dist/agent-runtime/src/send-recovery.d.ts +40 -0
  114. package/dist/agent-runtime/src/statewire-attach-observer.d.ts +194 -0
  115. package/dist/agent-runtime/src/statewire-diagnostics.d.ts +74 -0
  116. package/dist/agent-runtime/src/statewire-state.d.ts +29 -0
  117. package/dist/agent-runtime/src/statewire-suspended.cjs.map +1 -1
  118. package/dist/agent-runtime/src/statewire-suspended.d.ts +27 -0
  119. package/dist/agent-runtime/src/statewire-suspended.js.map +1 -1
  120. package/dist/agent-runtime/src/statewire-transport.d.ts +40 -0
  121. package/dist/agent-runtime/src/streaming-markdown.d.ts +46 -0
  122. package/dist/agent-runtime/src/subagent-transcripts.cjs +209 -0
  123. package/dist/agent-runtime/src/subagent-transcripts.cjs.map +1 -0
  124. package/dist/agent-runtime/src/subagent-transcripts.d.ts +71 -0
  125. package/dist/agent-runtime/src/subagent-transcripts.js +209 -0
  126. package/dist/agent-runtime/src/subagent-transcripts.js.map +1 -0
  127. package/dist/agent-runtime/src/subagents.cjs +253 -0
  128. package/dist/agent-runtime/src/subagents.cjs.map +1 -0
  129. package/dist/agent-runtime/src/subagents.d.ts +311 -0
  130. package/dist/agent-runtime/src/subagents.js +253 -0
  131. package/dist/agent-runtime/src/subagents.js.map +1 -0
  132. package/dist/agent-runtime/src/subscription-wake-event.d.ts +111 -0
  133. package/dist/agent-runtime/src/thread-extras.d.ts +43 -0
  134. package/dist/agent-runtime/src/thread-handoff.d.ts +364 -0
  135. package/dist/agent-runtime/src/thread-prewarm-controller.d.ts +76 -0
  136. package/dist/agent-runtime/src/thread-prewarm.d.ts +118 -0
  137. package/dist/agent-runtime/src/thread-snapshot-cache.d.ts +99 -0
  138. package/dist/agent-runtime/src/thread-snapshot-mirror.cjs +329 -0
  139. package/dist/agent-runtime/src/thread-snapshot-mirror.cjs.map +1 -0
  140. package/dist/agent-runtime/src/thread-snapshot-mirror.d.ts +101 -0
  141. package/dist/agent-runtime/src/thread-snapshot-mirror.js +329 -0
  142. package/dist/agent-runtime/src/thread-snapshot-mirror.js.map +1 -0
  143. package/dist/agent-runtime/src/thread-status.d.ts +53 -0
  144. package/dist/agent-runtime/src/tool-metadata.d.ts +146 -0
  145. package/dist/agent-runtime/src/tool-names.cjs +67 -0
  146. package/dist/agent-runtime/src/tool-names.cjs.map +1 -1
  147. package/dist/agent-runtime/src/tool-names.d.ts +60 -0
  148. package/dist/agent-runtime/src/tool-names.js +68 -1
  149. package/dist/agent-runtime/src/tool-names.js.map +1 -1
  150. package/dist/agent-runtime/src/tool-outputs.d.ts +35 -0
  151. package/dist/agent-runtime/src/tool-result.cjs +1 -0
  152. package/dist/agent-runtime/src/tool-result.cjs.map +1 -1
  153. package/dist/agent-runtime/src/tool-result.d.ts +126 -0
  154. package/dist/agent-runtime/src/tool-result.js +1 -0
  155. package/dist/agent-runtime/src/tool-result.js.map +1 -1
  156. package/dist/agent-runtime/src/types.d.ts +159 -0
  157. package/dist/agent-runtime/src/use-conversation-list.d.ts +76 -0
  158. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.cjs +136 -0
  159. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.cjs.map +1 -0
  160. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.d.ts +64 -0
  161. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.js +136 -0
  162. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.js.map +1 -0
  163. package/dist/agent-runtime/src/use-deep-agent-config.d.ts +169 -0
  164. package/dist/agent-runtime/src/use-deep-agent-edit-submit.cjs +13 -0
  165. package/dist/agent-runtime/src/use-deep-agent-edit-submit.cjs.map +1 -1
  166. package/dist/agent-runtime/src/use-deep-agent-edit-submit.d.ts +22 -0
  167. package/dist/agent-runtime/src/use-deep-agent-edit-submit.js +13 -0
  168. package/dist/agent-runtime/src/use-deep-agent-edit-submit.js.map +1 -1
  169. package/dist/agent-runtime/src/use-deep-agent-runtime.cjs +20 -2
  170. package/dist/agent-runtime/src/use-deep-agent-runtime.cjs.map +1 -1
  171. package/dist/agent-runtime/src/use-deep-agent-runtime.d.ts +168 -0
  172. package/dist/agent-runtime/src/use-deep-agent-runtime.js +20 -2
  173. package/dist/agent-runtime/src/use-deep-agent-runtime.js.map +1 -1
  174. package/dist/agent-runtime/src/use-deep-agent-thread.cjs +12 -4
  175. package/dist/agent-runtime/src/use-deep-agent-thread.cjs.map +1 -1
  176. package/dist/agent-runtime/src/use-deep-agent-thread.d.ts +320 -0
  177. package/dist/agent-runtime/src/use-deep-agent-thread.js +12 -4
  178. package/dist/agent-runtime/src/use-deep-agent-thread.js.map +1 -1
  179. package/dist/agent-runtime/src/use-deep-agent-voice.cjs +999 -0
  180. package/dist/agent-runtime/src/use-deep-agent-voice.cjs.map +1 -0
  181. package/dist/agent-runtime/src/use-deep-agent-voice.d.ts +409 -0
  182. package/dist/agent-runtime/src/use-deep-agent-voice.js +999 -0
  183. package/dist/agent-runtime/src/use-deep-agent-voice.js.map +1 -0
  184. package/dist/agent-runtime/src/use-deep-agent-window-sync.d.ts +102 -0
  185. package/dist/agent-runtime/src/use-historical-edit-attachments.d.ts +2 -0
  186. package/dist/agent-runtime/src/use-thread-handoff-flow.d.ts +84 -0
  187. package/dist/agent-runtime/src/voice-presentation.d.ts +80 -0
  188. package/dist/agent-runtime/src/voice-turn-grouping.d.ts +28 -0
  189. package/dist/agent-runtime/src/voice-wire-types.d.ts +15 -0
  190. package/dist/agent-runtime/src/withdrawn-turns.d.ts +97 -0
  191. package/dist/chat/AthenaChat.cjs +77 -6
  192. package/dist/chat/AthenaChat.cjs.map +1 -1
  193. package/dist/chat/AthenaChat.js +78 -7
  194. package/dist/chat/AthenaChat.js.map +1 -1
  195. package/dist/chat/StatewireApprovalCard.d.ts +1 -1
  196. package/dist/chat/StatewireClientToolBridge.d.ts +1 -1
  197. package/dist/chat/StatewireQueuedMessages.cjs +11 -4
  198. package/dist/chat/StatewireQueuedMessages.cjs.map +1 -1
  199. package/dist/chat/StatewireQueuedMessages.d.ts +1 -1
  200. package/dist/chat/StatewireQueuedMessages.js +11 -4
  201. package/dist/chat/StatewireQueuedMessages.js.map +1 -1
  202. package/dist/chat/chat-outbox-rows.cjs +223 -0
  203. package/dist/chat/chat-outbox-rows.cjs.map +1 -0
  204. package/dist/chat/chat-outbox-rows.d.ts +29 -0
  205. package/dist/chat/chat-outbox-rows.js +223 -0
  206. package/dist/chat/chat-outbox-rows.js.map +1 -0
  207. package/dist/chat/statewire-approval.d.ts +1 -1
  208. package/dist/chat/statewire-client-tools.d.ts +1 -1
  209. package/dist/chat/super-grouping/SuperGroupingCard.cjs +3 -1
  210. package/dist/chat/super-grouping/SuperGroupingCard.cjs.map +1 -1
  211. package/dist/chat/super-grouping/SuperGroupingCard.d.ts +7 -1
  212. package/dist/chat/super-grouping/SuperGroupingCard.js +3 -1
  213. package/dist/chat/super-grouping/SuperGroupingCard.js.map +1 -1
  214. package/dist/chat/super-grouping/SuperGroupingTranscript.cjs +7 -2
  215. package/dist/chat/super-grouping/SuperGroupingTranscript.cjs.map +1 -1
  216. package/dist/chat/super-grouping/SuperGroupingTranscript.d.ts +2 -2
  217. package/dist/chat/super-grouping/SuperGroupingTranscript.js +7 -2
  218. package/dist/chat/super-grouping/SuperGroupingTranscript.js.map +1 -1
  219. package/dist/chat/super-grouping/activity-timeline.cjs +19 -11
  220. package/dist/chat/super-grouping/activity-timeline.cjs.map +1 -1
  221. package/dist/chat/super-grouping/activity-timeline.d.ts +25 -9
  222. package/dist/chat/super-grouping/activity-timeline.js +19 -11
  223. package/dist/chat/super-grouping/activity-timeline.js.map +1 -1
  224. package/dist/chat/use-statewire-approval-request.cjs +36 -0
  225. package/dist/chat/use-statewire-approval-request.cjs.map +1 -1
  226. package/dist/chat/use-statewire-approval-request.d.ts +49 -1
  227. package/dist/chat/use-statewire-approval-request.js +39 -3
  228. package/dist/chat/use-statewire-approval-request.js.map +1 -1
  229. package/dist/chat-ui/composer/tiptap-composer.cjs +102 -3
  230. package/dist/chat-ui/composer/tiptap-composer.cjs.map +1 -1
  231. package/dist/chat-ui/composer/tiptap-composer.d.ts +32 -1
  232. package/dist/chat-ui/composer/tiptap-composer.js +103 -4
  233. package/dist/chat-ui/composer/tiptap-composer.js.map +1 -1
  234. package/dist/chat-ui/header/conversation-history-panel.d.ts +1 -1
  235. package/dist/chat-ui/index.d.ts +1 -1
  236. package/dist/chat-ui/messages/message-components.cjs +15 -0
  237. package/dist/chat-ui/messages/message-components.cjs.map +1 -1
  238. package/dist/chat-ui/messages/message-components.js +15 -0
  239. package/dist/chat-ui/messages/message-components.js.map +1 -1
  240. package/dist/chat-ui/messages/runtime-message.d.ts +1 -1
  241. package/dist/chat-ui/messages/statewire-continue-run.d.ts +1 -1
  242. package/dist/chat-ui/messages/user-edit-composer.cjs +15 -2
  243. package/dist/chat-ui/messages/user-edit-composer.cjs.map +1 -1
  244. package/dist/chat-ui/messages/user-edit-composer.d.ts +4 -2
  245. package/dist/chat-ui/messages/user-edit-composer.js +15 -2
  246. package/dist/chat-ui/messages/user-edit-composer.js.map +1 -1
  247. package/dist/chat-ui/messages/wake-marker.d.ts +1 -1
  248. package/dist/chat-ui/rich-text/chat-text-schema.cjs +1 -0
  249. package/dist/chat-ui/rich-text/chat-text-schema.cjs.map +1 -1
  250. package/dist/chat-ui/rich-text/chat-text-schema.d.ts +3 -0
  251. package/dist/chat-ui/rich-text/chat-text-schema.js +1 -0
  252. package/dist/chat-ui/rich-text/chat-text-schema.js.map +1 -1
  253. package/dist/chat-ui/statewire.cjs +1 -0
  254. package/dist/chat-ui/statewire.cjs.map +1 -1
  255. package/dist/chat-ui/statewire.d.ts +2 -2
  256. package/dist/chat-ui/statewire.js +2 -1
  257. package/dist/chat-ui/thread/statewire-history-edge.d.ts +1 -1
  258. package/dist/composer/AttachmentContext.cjs +8 -4
  259. package/dist/composer/AttachmentContext.cjs.map +1 -1
  260. package/dist/composer/AttachmentContext.d.ts +7 -0
  261. package/dist/composer/AttachmentContext.js +8 -4
  262. package/dist/composer/AttachmentContext.js.map +1 -1
  263. package/dist/composer/build-composed-message.cjs +34 -0
  264. package/dist/composer/build-composed-message.cjs.map +1 -1
  265. package/dist/composer/build-composed-message.d.ts +20 -0
  266. package/dist/composer/build-composed-message.js +35 -1
  267. package/dist/composer/build-composed-message.js.map +1 -1
  268. package/dist/composer/composer-handoff.cjs +39 -2
  269. package/dist/composer/composer-handoff.cjs.map +1 -1
  270. package/dist/composer/composer-handoff.d.ts +28 -3
  271. package/dist/composer/composer-handoff.js +39 -2
  272. package/dist/composer/composer-handoff.js.map +1 -1
  273. package/dist/composer/useAttachFiles.cjs +15 -2
  274. package/dist/composer/useAttachFiles.cjs.map +1 -1
  275. package/dist/composer/useAttachFiles.d.ts +11 -0
  276. package/dist/composer/useAttachFiles.js +15 -2
  277. package/dist/composer/useAttachFiles.js.map +1 -1
  278. package/dist/composer/useSendMessage.cjs.map +1 -1
  279. package/dist/composer/useSendMessage.d.ts +4 -3
  280. package/dist/composer/useSendMessage.js.map +1 -1
  281. package/dist/diagnostics/athena-diagnostics.cjs.map +1 -1
  282. package/dist/diagnostics/athena-diagnostics.d.ts +3 -1
  283. package/dist/diagnostics/athena-diagnostics.js.map +1 -1
  284. package/dist/index.cjs +18 -0
  285. package/dist/index.cjs.map +1 -1
  286. package/dist/index.d.ts +15 -6
  287. package/dist/index.js +19 -1
  288. package/dist/index.js.map +1 -1
  289. package/dist/offline/chat-outbox.cjs +57 -0
  290. package/dist/offline/chat-outbox.cjs.map +1 -0
  291. package/dist/offline/chat-outbox.d.ts +80 -0
  292. package/dist/offline/chat-outbox.js +57 -0
  293. package/dist/offline/chat-outbox.js.map +1 -0
  294. package/dist/offline/offline-history.cjs +77 -0
  295. package/dist/offline/offline-history.cjs.map +1 -0
  296. package/dist/offline/offline-history.d.ts +60 -0
  297. package/dist/offline/offline-history.js +77 -0
  298. package/dist/offline/offline-history.js.map +1 -0
  299. package/dist/provider/AthenaProvider.cjs +206 -9
  300. package/dist/provider/AthenaProvider.cjs.map +1 -1
  301. package/dist/provider/AthenaProvider.d.ts +22 -1
  302. package/dist/provider/AthenaProvider.js +207 -10
  303. package/dist/provider/AthenaProvider.js.map +1 -1
  304. package/dist/provider/statewire-window-context.d.ts +1 -1
  305. package/dist/react/package.json.cjs +1 -1
  306. package/dist/react/package.json.js +1 -1
  307. package/dist/references/src/anchors/file-line-range.d.ts +58 -0
  308. package/dist/references/src/anchors/format.d.ts +21 -0
  309. package/dist/references/src/anchors/message-anchors.d.ts +71 -0
  310. package/dist/references/src/anchors/parse.d.ts +8 -0
  311. package/dist/references/src/anchors/registry-contract.d.ts +24 -0
  312. package/dist/references/src/anchors/registry.d.ts +19 -0
  313. package/dist/references/src/anchors/schemas.d.ts +194 -0
  314. package/dist/references/src/anchors/serialize.d.ts +8 -0
  315. package/dist/references/src/anchors/time.d.ts +78 -0
  316. package/dist/references/src/anchors/types.d.ts +474 -0
  317. package/dist/references/src/asset-bounds.d.ts +27 -0
  318. package/dist/references/src/asset-links.d.ts +23 -0
  319. package/dist/references/src/asset-reference.d.ts +16 -0
  320. package/dist/references/src/formats/format-catalog.d.ts +79 -0
  321. package/dist/references/src/formats/markdown/parse-reference-markdown.d.ts +28 -0
  322. package/dist/references/src/formats/markdown/reference-display-name.d.ts +6 -0
  323. package/dist/references/src/formats/object/asset-object.d.ts +9 -0
  324. package/dist/references/src/formats/object/callable-object.d.ts +6 -0
  325. package/dist/references/src/formats/object/decode-reference-object-payload.d.ts +3 -0
  326. package/dist/references/src/formats/object/external-url-object.d.ts +9 -0
  327. package/dist/references/src/formats/object/group-object.d.ts +9 -0
  328. package/dist/references/src/formats/object/navigation-object.d.ts +9 -0
  329. package/dist/references/src/formats/object/parse-reference-object.d.ts +11 -0
  330. package/dist/references/src/formats/object/person-object.d.ts +9 -0
  331. package/dist/references/src/formats/uri/asset-mention-uri.d.ts +9 -0
  332. package/dist/references/src/formats/uri/asset-spaces-url.d.ts +9 -0
  333. package/dist/references/src/formats/uri/callable-mention-uris.d.ts +9 -0
  334. package/dist/references/src/formats/uri/detect-uri-wire.d.ts +9 -0
  335. package/dist/references/src/formats/uri/group-mention-uri.d.ts +12 -0
  336. package/dist/references/src/formats/uri/navigation-spaces-url.d.ts +14 -0
  337. package/dist/references/src/formats/uri/parse-reference-uri.d.ts +20 -0
  338. package/dist/references/src/formats/uri/person-mention-uri.d.ts +9 -0
  339. package/dist/references/src/formats/uri/template-placeholder.d.ts +12 -0
  340. package/dist/references/src/index.d.ts +47 -0
  341. package/dist/references/src/legacy/index.d.ts +14 -0
  342. package/dist/references/src/legacy/pre-reference-asset-url.d.ts +57 -0
  343. package/dist/references/src/legacy/pre-reference-citation-bridge.d.ts +22 -0
  344. package/dist/references/src/legacy/pre-reference-citation.d.ts +138 -0
  345. package/dist/references/src/legacy/pre-reference-external-url.d.ts +31 -0
  346. package/dist/references/src/legacy/pre-reference-format.d.ts +8 -0
  347. package/dist/references/src/legacy/pre-reference-mention.d.ts +27 -0
  348. package/dist/references/src/legacy/pre-reference-object.d.ts +8 -0
  349. package/dist/references/src/legacy/pre-reference-uri.d.ts +12 -0
  350. package/dist/references/src/legacy.d.ts +2 -0
  351. package/dist/references/src/mention-href-patterns.d.ts +19 -0
  352. package/dist/references/src/mention-node/index.d.ts +5 -0
  353. package/dist/references/src/mention-node/mention-node.d.ts +31 -0
  354. package/dist/references/src/mention-node/resolve-node-attrs.d.ts +27 -0
  355. package/dist/references/src/parse-reference.d.ts +23 -0
  356. package/dist/references/src/schemas.d.ts +463 -0
  357. package/dist/references/src/serialize-reference.d.ts +50 -0
  358. package/dist/references/src/sheet-name.d.ts +10 -0
  359. package/dist/references/src/tool-option-schemas.d.ts +597 -0
  360. package/dist/references/src/types.d.ts +125 -0
  361. package/dist/references/src/version-ref.d.ts +30 -0
  362. package/dist/runtime/statewire-lifecycle.d.ts +1 -1
  363. package/dist/runtime/statewire-model-lane.d.ts +1 -1
  364. package/dist/runtime/statewire-server-lane-context.d.ts +1 -1
  365. package/dist/runtime/statewire-session-key.cjs +7 -0
  366. package/dist/runtime/statewire-session-key.cjs.map +1 -1
  367. package/dist/runtime/statewire-session-key.d.ts +16 -0
  368. package/dist/runtime/statewire-session-key.js +8 -1
  369. package/dist/runtime/statewire-session-key.js.map +1 -1
  370. package/dist/runtime/statewire-session-lane.cjs +48 -0
  371. package/dist/runtime/statewire-session-lane.cjs.map +1 -0
  372. package/dist/runtime/statewire-session-lane.d.ts +29 -0
  373. package/dist/runtime/statewire-session-lane.js +48 -0
  374. package/dist/runtime/statewire-session-lane.js.map +1 -0
  375. package/dist/runtime/statewire-thread-config-lane.d.ts +1 -1
  376. package/dist/runtime/useAthenaStatewireRuntime.cjs +16 -5
  377. package/dist/runtime/useAthenaStatewireRuntime.cjs.map +1 -1
  378. package/dist/runtime/useAthenaStatewireRuntime.d.ts +15 -1
  379. package/dist/runtime/useAthenaStatewireRuntime.js +17 -6
  380. package/dist/runtime/useAthenaStatewireRuntime.js.map +1 -1
  381. package/dist/styles.css +1 -1
  382. package/dist/threads/api.d.ts +1 -1
  383. package/dist/threads/conversation-list-fetcher.d.ts +1 -1
  384. package/dist/threads/index-triggered-refresh.cjs +164 -0
  385. package/dist/threads/index-triggered-refresh.cjs.map +1 -0
  386. package/dist/threads/index-triggered-refresh.d.ts +70 -0
  387. package/dist/threads/index-triggered-refresh.js +164 -0
  388. package/dist/threads/index-triggered-refresh.js.map +1 -0
  389. package/dist/threads/offline-session-list.cjs +75 -0
  390. package/dist/threads/offline-session-list.cjs.map +1 -0
  391. package/dist/threads/offline-session-list.d.ts +27 -0
  392. package/dist/threads/offline-session-list.js +75 -0
  393. package/dist/threads/offline-session-list.js.map +1 -0
  394. package/dist/threads/pull-request-display.d.ts +1 -1
  395. package/dist/threads/session-list-model.d.ts +1 -1
  396. package/dist/threads/session-list-tab-share.cjs +150 -0
  397. package/dist/threads/session-list-tab-share.cjs.map +1 -0
  398. package/dist/threads/session-list-tab-share.d.ts +73 -0
  399. package/dist/threads/session-list-tab-share.js +150 -0
  400. package/dist/threads/session-list-tab-share.js.map +1 -0
  401. package/dist/threads/session-row-parts.d.ts +1 -1
  402. package/dist/threads/sessions-query.d.ts +1 -1
  403. package/dist/threads/statewire-thread-list.cjs +105 -20
  404. package/dist/threads/statewire-thread-list.cjs.map +1 -1
  405. package/dist/threads/statewire-thread-list.d.ts +31 -3
  406. package/dist/threads/statewire-thread-list.js +107 -22
  407. package/dist/threads/statewire-thread-list.js.map +1 -1
  408. package/dist/threads/thread-prefetcher.d.ts +1 -1
  409. package/dist/threads/use-athena-session-attention.d.ts +1 -1
  410. package/dist/threads/use-athena-sessions.cjs +32 -22
  411. package/dist/threads/use-athena-sessions.cjs.map +1 -1
  412. package/dist/threads/use-athena-sessions.js +33 -23
  413. package/dist/threads/use-athena-sessions.js.map +1 -1
  414. package/dist/threads/use-rest-conversation-history.d.ts +1 -1
  415. package/dist/threads/use-statewire-conversation-history.d.ts +5 -5
  416. package/dist/tiptap-markdown-table/src/markdown-table-serializer.d.ts +56 -0
  417. package/dist/tools/NestedPtcMessages.cjs +14 -9
  418. package/dist/tools/NestedPtcMessages.cjs.map +1 -1
  419. package/dist/tools/NestedPtcMessages.d.ts +9 -0
  420. package/dist/tools/NestedPtcMessages.js +6 -1
  421. package/dist/tools/NestedPtcMessages.js.map +1 -1
  422. package/dist/tools/index.d.ts +1 -1
  423. package/dist/tools/primitives.d.ts +1 -1
  424. package/dist/tools/subagent-task-tool-ui.cjs +494 -0
  425. package/dist/tools/subagent-task-tool-ui.cjs.map +1 -0
  426. package/dist/tools/subagent-task-tool-ui.d.ts +109 -0
  427. package/dist/tools/subagent-task-tool-ui.js +494 -0
  428. package/dist/tools/subagent-task-tool-ui.js.map +1 -0
  429. package/dist/tools/tool-fallback.d.ts +1 -1
  430. package/dist/tools/tool-icons.d.ts +1 -1
  431. package/dist/tools/tool-summary.d.ts +1 -1
  432. package/dist/tools/tool-uis.cjs +4 -0
  433. package/dist/tools/tool-uis.cjs.map +1 -1
  434. package/dist/tools/tool-uis.js +4 -0
  435. package/dist/tools/tool-uis.js.map +1 -1
  436. package/dist/voice/chat.cjs +6 -0
  437. package/dist/voice/chat.cjs.map +1 -0
  438. package/dist/voice/chat.d.ts +2 -0
  439. package/dist/voice/chat.js +6 -0
  440. package/dist/voice/chat.js.map +1 -0
  441. package/dist/voice/livekit-join.cjs +119 -0
  442. package/dist/voice/livekit-join.cjs.map +1 -0
  443. package/dist/voice/livekit-join.d.ts +8 -0
  444. package/dist/voice/livekit-join.js +119 -0
  445. package/dist/voice/livekit-join.js.map +1 -0
  446. package/dist/voice/livekit.cjs +32 -0
  447. package/dist/voice/livekit.cjs.map +1 -0
  448. package/dist/voice/livekit.d.ts +80 -0
  449. package/dist/voice/livekit.js +32 -0
  450. package/dist/voice/livekit.js.map +1 -0
  451. package/package.json +20 -10
@@ -0,0 +1,125 @@
1
+ /**
2
+ * Reference types — Level 1 + Level 2 + Level 3 of the reference system.
3
+ *
4
+ * Six top-level types discriminated by `referenced`:
5
+ * - asset → files, documents, videos, spreadsheets
6
+ * - callable → tools, toolkits, workspace items
7
+ * - person → workspace members
8
+ * - group → workspace groups (a reference only — never a share or a notification)
9
+ * - external_url → arbitrary URLs (also the fallback)
10
+ * - navigation → in-app routes (Spaces, Drive tab state, etc.)
11
+ */
12
+ import type { Anchor } from './anchors/types';
13
+ export declare const Referenced: {
14
+ readonly Asset: 'asset';
15
+ readonly Callable: 'callable';
16
+ readonly Person: 'person';
17
+ readonly Group: 'group';
18
+ readonly ExternalUrl: 'external_url';
19
+ readonly Navigation: 'navigation';
20
+ };
21
+ export type Referenced = (typeof Referenced)[keyof typeof Referenced];
22
+ export declare const CallableKind: {
23
+ readonly Tool: 'tool';
24
+ readonly Toolkit: 'toolkit';
25
+ readonly WorkspaceItem: 'workspace_item';
26
+ };
27
+ export type CallableKind = (typeof CallableKind)[keyof typeof CallableKind];
28
+ export type AssetMeta = {
29
+ title?: string;
30
+ excerpt?: string;
31
+ assetType?: string;
32
+ provider?: string;
33
+ providerLocation?: string;
34
+ sheetName?: string;
35
+ };
36
+ export type CallableMeta = {
37
+ title?: string;
38
+ description?: string;
39
+ icon?: string;
40
+ };
41
+ export type PersonMeta = {
42
+ name?: string;
43
+ avatar?: string;
44
+ phone?: string;
45
+ };
46
+ export type GroupMeta = {
47
+ name?: string;
48
+ };
49
+ export type ExternalUrlMeta = {
50
+ title?: string;
51
+ description?: string;
52
+ excerpt?: string;
53
+ thumbnailUrl?: string;
54
+ };
55
+ export type NavigationMeta = {
56
+ title?: string;
57
+ description?: string;
58
+ };
59
+ /**
60
+ * Which state of the source the reference points at (Level 2, alongside the
61
+ * anchor's *where*). Absent means `latest` — the historical default.
62
+ *
63
+ * Discriminated by `kind` to match `VersionPolicy` in `@athenaintel/source-binding`.
64
+ */
65
+ export type AssetVersionRef = {
66
+ kind: 'latest';
67
+ } | {
68
+ kind: 'pinned';
69
+ versionId: string;
70
+ }
71
+ /** Point in time; `keryxClock` makes reconstruction exact rather than approximate. */
72
+ | {
73
+ kind: 'as_of';
74
+ at: string;
75
+ keryxClock?: number;
76
+ };
77
+ export type AssetReference = {
78
+ referenced: 'asset';
79
+ id: string;
80
+ anchor?: Anchor;
81
+ version?: AssetVersionRef;
82
+ meta?: AssetMeta;
83
+ };
84
+ export type CallableReference = {
85
+ referenced: 'callable';
86
+ kind: CallableKind;
87
+ name: string;
88
+ config?: Record<string, unknown>;
89
+ meta?: CallableMeta;
90
+ };
91
+ export type PersonReference = {
92
+ referenced: 'person';
93
+ id: string;
94
+ email: string;
95
+ meta?: PersonMeta;
96
+ };
97
+ /**
98
+ * A workspace group (`group_<uuid>`). Mentioning one is a reference to the
99
+ * group, not to its members: it grants nothing and notifies nobody.
100
+ */
101
+ export type GroupReference = {
102
+ referenced: 'group';
103
+ id: string;
104
+ meta?: GroupMeta;
105
+ };
106
+ export type ExternalUrlReference = {
107
+ referenced: 'external_url';
108
+ url: string;
109
+ meta?: ExternalUrlMeta;
110
+ };
111
+ export type NavigationReference = {
112
+ referenced: 'navigation';
113
+ /** Relative app path, e.g. `/dashboard/spaces?asset_ids=drive&drive=folder_id` */
114
+ path: string;
115
+ meta?: NavigationMeta;
116
+ };
117
+ export type Reference = AssetReference | CallableReference | PersonReference | GroupReference | ExternalUrlReference | NavigationReference;
118
+ export declare function isAssetReference(ref: Reference): ref is AssetReference;
119
+ export declare function isCallableReference(ref: Reference): ref is CallableReference;
120
+ export declare function isPersonReference(ref: Reference): ref is PersonReference;
121
+ export declare function isGroupReference(ref: Reference): ref is GroupReference;
122
+ export declare function isExternalUrlReference(ref: Reference): ref is ExternalUrlReference;
123
+ export declare function isNavigationReference(ref: Reference): ref is NavigationReference;
124
+ /** True when the asset reference includes an anchor (i.e., it's a citation). */
125
+ export declare function isCitation(ref: AssetReference): boolean;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Asset version references — *which state* of a source a reference points at.
3
+ *
4
+ * An anchor says *where* in a document a reference points; a version ref says
5
+ * *when*. Without one, an anchor silently re-resolves against whatever the
6
+ * source says today, which is the drift problem versioned citations solve.
7
+ *
8
+ * The discriminator is `kind`, matching the shipped `VersionPolicy` in
9
+ * `@athenaintel/source-binding` so the two stay one concept.
10
+ */
11
+ import type { AssetReference, AssetVersionRef } from './types';
12
+ /** Split a legacy versioned asset id into its base id and version segment. */
13
+ export declare function splitVersionedAssetId(assetId: string): {
14
+ baseId: string;
15
+ version: string;
16
+ } | undefined;
17
+ /** Decode a version ref from URL params, or `undefined` when unversioned. */
18
+ export declare function parseVersionRefFromParams(params: URLSearchParams): AssetVersionRef | undefined;
19
+ /** Encode a version ref to URL params. `latest` is the default, so it is a no-op. */
20
+ export declare function serializeVersionRefToParams(version: AssetVersionRef): URLSearchParams;
21
+ /**
22
+ * Move a legacy `id@versionId` into the `version` field, leaving `id` a plain
23
+ * asset id. Callers can then read `ref.version` instead of re-deriving it with
24
+ * `id.split('@')`, which is how versions got silently dropped.
25
+ *
26
+ * Already-normalized references and unversioned ids pass through untouched.
27
+ */
28
+ export declare function normalizeAssetReference(ref: AssetReference): AssetReference;
29
+ /** The pinned version id a reference resolves to, if it names a fixed state. */
30
+ export declare function getPinnedVersionId(ref: AssetReference): string | undefined;
@@ -1,4 +1,4 @@
1
- import type { DeepAgentConnectionState } from '@athenaintel/agent-runtime';
1
+ import type { DeepAgentConnectionState } from '../agent-runtime/src/index';
2
2
  /** A user-visible notice mapped from a statewire transport error. */
3
3
  export interface AthenaStatewireErrorNotice {
4
4
  kind: 'paywall' | 'read-only' | 'command';
@@ -1,4 +1,4 @@
1
- import type { DeepAgentServerConfig, ThreadConfigCustom } from '@athenaintel/agent-runtime';
1
+ import type { DeepAgentServerConfig, ThreadConfigCustom } from '../agent-runtime/src/index';
2
2
  /**
3
3
  * The model a thread's server config lane (`state.config.custom`) pins, as the
4
4
  * host app should read it, plus whether there is a lane at all.
@@ -1,4 +1,4 @@
1
- import type { DeepAgentServerConfig } from '@athenaintel/agent-runtime';
1
+ import type { DeepAgentServerConfig } from '../agent-runtime/src/index';
2
2
  /**
3
3
  * The thread's server config lane as the statewire host last sent it on this
4
4
  * attach, read off the transport's own state (`onStateChange`) rather than the
@@ -7,5 +7,12 @@ function statewireSessionKey({
7
7
  }) {
8
8
  return `${syncUrl}:${principal || "anon"}:${threadId}`;
9
9
  }
10
+ function statewireSessionPrincipal(auth) {
11
+ var _a;
12
+ const userId = (_a = auth == null ? void 0 : auth.user) == null ? void 0 : _a.userId;
13
+ if (userId) return userId;
14
+ return (auth == null ? void 0 : auth.isLoading) ? null : "";
15
+ }
10
16
  exports.statewireSessionKey = statewireSessionKey;
17
+ exports.statewireSessionPrincipal = statewireSessionPrincipal;
11
18
  //# sourceMappingURL=statewire-session-key.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"statewire-session-key.cjs","sources":["../../src/runtime/statewire-session-key.ts"],"sourcesContent":["/**\n * Scope of the persisted statewire command lane: the sync host, the signed-in\n * principal, and the thread. A thread id is only meaningful against the\n * backend that minted it, and a shared browser must never resend one user's\n * un-settled commands under the next user's token — so the key carries WHO is\n * signed in as well as where. The principal is a non-secret user id;\n * API-key-only hosts (no auth provider above) share one anonymous scope.\n */\nexport function statewireSessionKey({\n syncUrl,\n principal,\n threadId,\n}: {\n syncUrl: string;\n principal: string;\n threadId: string;\n}): string {\n return `${syncUrl}:${principal || 'anon'}:${threadId}`;\n}\n"],"names":[],"mappings":";;AAQO,SAAS,oBAAoB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AACF,GAIW;AACT,SAAO,GAAG,OAAO,IAAI,aAAa,MAAM,IAAI,QAAQ;AACtD;;"}
1
+ {"version":3,"file":"statewire-session-key.cjs","sources":["../../src/runtime/statewire-session-key.ts"],"sourcesContent":["import type { AthenaAuthState } from '../auth/types';\n\n/**\n * Scope of the persisted statewire command lane: the sync host, the signed-in\n * principal, and the thread. A thread id is only meaningful against the\n * backend that minted it, and a shared browser must never resend one user's\n * un-settled commands under the next user's token — so the key carries WHO is\n * signed in as well as where. The principal is a non-secret user id;\n * API-key-only hosts (no auth provider above) share one anonymous scope.\n */\nexport function statewireSessionKey({\n syncUrl,\n principal,\n threadId,\n}: {\n syncUrl: string;\n principal: string;\n threadId: string;\n}): string {\n return `${syncUrl}:${principal || 'anon'}:${threadId}`;\n}\n\n/**\n * The principal a thread's persisted command lane is scoped by\n * ({@link statewireSessionKey}): the signed-in user's id (also while the\n * sign-in provider refreshes and still names them), `''` (the one anonymous\n * scope) with no sign-in provider above or none signed in, and `null` while\n * the sign-in provider is still resolving who is signed in.\n *\n * A lane belongs to one principal for the life of the thread's mount: a\n * session mounted on a stand-in key keeps its client id, clock and journal when\n * the key changes, and leaves that record behind with the same client id, so a\n * later page load resends its journal below the server's watermark for the id\n * (`expired`). The lane therefore stays `pending` while this is `null` (see\n * `useAthenaStatewireRuntime`).\n */\nexport function statewireSessionPrincipal(\n auth: Pick<AthenaAuthState, 'isLoading' | 'user'> | null,\n): string | null {\n const userId = auth?.user?.userId;\n if (userId) return userId;\n return auth?.isLoading ? null : '';\n}\n"],"names":[],"mappings":";;AAUO,SAAS,oBAAoB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AACF,GAIW;AACT,SAAO,GAAG,OAAO,IAAI,aAAa,MAAM,IAAI,QAAQ;AACtD;AAgBO,SAAS,0BACd,MACe;;AACf,QAAM,UAAS,kCAAM,SAAN,mBAAY;AAC3B,MAAI,OAAQ,QAAO;AACnB,UAAO,6BAAM,aAAY,OAAO;AAClC;;;"}
@@ -1,3 +1,4 @@
1
+ import type { AthenaAuthState } from '../auth/types';
1
2
  /**
2
3
  * Scope of the persisted statewire command lane: the sync host, the signed-in
3
4
  * principal, and the thread. A thread id is only meaningful against the
@@ -11,3 +12,18 @@ export declare function statewireSessionKey({ syncUrl, principal, threadId, }: {
11
12
  principal: string;
12
13
  threadId: string;
13
14
  }): string;
15
+ /**
16
+ * The principal a thread's persisted command lane is scoped by
17
+ * ({@link statewireSessionKey}): the signed-in user's id (also while the
18
+ * sign-in provider refreshes and still names them), `''` (the one anonymous
19
+ * scope) with no sign-in provider above or none signed in, and `null` while
20
+ * the sign-in provider is still resolving who is signed in.
21
+ *
22
+ * A lane belongs to one principal for the life of the thread's mount: a
23
+ * session mounted on a stand-in key keeps its client id, clock and journal when
24
+ * the key changes, and leaves that record behind with the same client id, so a
25
+ * later page load resends its journal below the server's watermark for the id
26
+ * (`expired`). The lane therefore stays `pending` while this is `null` (see
27
+ * `useAthenaStatewireRuntime`).
28
+ */
29
+ export declare function statewireSessionPrincipal(auth: Pick<AthenaAuthState, 'isLoading' | 'user'> | null): string | null;
@@ -5,7 +5,14 @@ function statewireSessionKey({
5
5
  }) {
6
6
  return `${syncUrl}:${principal || "anon"}:${threadId}`;
7
7
  }
8
+ function statewireSessionPrincipal(auth) {
9
+ var _a;
10
+ const userId = (_a = auth == null ? void 0 : auth.user) == null ? void 0 : _a.userId;
11
+ if (userId) return userId;
12
+ return (auth == null ? void 0 : auth.isLoading) ? null : "";
13
+ }
8
14
  export {
9
- statewireSessionKey
15
+ statewireSessionKey,
16
+ statewireSessionPrincipal
10
17
  };
11
18
  //# sourceMappingURL=statewire-session-key.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"statewire-session-key.js","sources":["../../src/runtime/statewire-session-key.ts"],"sourcesContent":["/**\n * Scope of the persisted statewire command lane: the sync host, the signed-in\n * principal, and the thread. A thread id is only meaningful against the\n * backend that minted it, and a shared browser must never resend one user's\n * un-settled commands under the next user's token — so the key carries WHO is\n * signed in as well as where. The principal is a non-secret user id;\n * API-key-only hosts (no auth provider above) share one anonymous scope.\n */\nexport function statewireSessionKey({\n syncUrl,\n principal,\n threadId,\n}: {\n syncUrl: string;\n principal: string;\n threadId: string;\n}): string {\n return `${syncUrl}:${principal || 'anon'}:${threadId}`;\n}\n"],"names":[],"mappings":"AAQO,SAAS,oBAAoB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AACF,GAIW;AACT,SAAO,GAAG,OAAO,IAAI,aAAa,MAAM,IAAI,QAAQ;AACtD;"}
1
+ {"version":3,"file":"statewire-session-key.js","sources":["../../src/runtime/statewire-session-key.ts"],"sourcesContent":["import type { AthenaAuthState } from '../auth/types';\n\n/**\n * Scope of the persisted statewire command lane: the sync host, the signed-in\n * principal, and the thread. A thread id is only meaningful against the\n * backend that minted it, and a shared browser must never resend one user's\n * un-settled commands under the next user's token — so the key carries WHO is\n * signed in as well as where. The principal is a non-secret user id;\n * API-key-only hosts (no auth provider above) share one anonymous scope.\n */\nexport function statewireSessionKey({\n syncUrl,\n principal,\n threadId,\n}: {\n syncUrl: string;\n principal: string;\n threadId: string;\n}): string {\n return `${syncUrl}:${principal || 'anon'}:${threadId}`;\n}\n\n/**\n * The principal a thread's persisted command lane is scoped by\n * ({@link statewireSessionKey}): the signed-in user's id (also while the\n * sign-in provider refreshes and still names them), `''` (the one anonymous\n * scope) with no sign-in provider above or none signed in, and `null` while\n * the sign-in provider is still resolving who is signed in.\n *\n * A lane belongs to one principal for the life of the thread's mount: a\n * session mounted on a stand-in key keeps its client id, clock and journal when\n * the key changes, and leaves that record behind with the same client id, so a\n * later page load resends its journal below the server's watermark for the id\n * (`expired`). The lane therefore stays `pending` while this is `null` (see\n * `useAthenaStatewireRuntime`).\n */\nexport function statewireSessionPrincipal(\n auth: Pick<AthenaAuthState, 'isLoading' | 'user'> | null,\n): string | null {\n const userId = auth?.user?.userId;\n if (userId) return userId;\n return auth?.isLoading ? null : '';\n}\n"],"names":[],"mappings":"AAUO,SAAS,oBAAoB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AACF,GAIW;AACT,SAAO,GAAG,OAAO,IAAI,aAAa,MAAM,IAAI,QAAQ;AACtD;AAgBO,SAAS,0BACd,MACe;AA5BV;AA6BL,QAAM,UAAS,kCAAM,SAAN,mBAAY;AAC3B,MAAI,OAAQ,QAAO;AACnB,UAAO,6BAAM,aAAY,OAAO;AAClC;"}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const react = require("react");
4
+ function createStatewireSessionLaneGate({
5
+ pending
6
+ }) {
7
+ let current = pending;
8
+ let waiters = [];
9
+ const listeners = /* @__PURE__ */ new Set();
10
+ return {
11
+ isPending: () => current,
12
+ whenKnown: () => current ? new Promise((resolve) => {
13
+ waiters.push(resolve);
14
+ }) : Promise.resolve(),
15
+ subscribe: (listener) => {
16
+ listeners.add(listener);
17
+ return () => {
18
+ listeners.delete(listener);
19
+ };
20
+ },
21
+ setPending: (next) => {
22
+ if (next === current) return;
23
+ current = next;
24
+ if (!next) {
25
+ const known = waiters;
26
+ waiters = [];
27
+ for (const resolve of known) resolve();
28
+ }
29
+ for (const listener of [...listeners]) listener();
30
+ }
31
+ };
32
+ }
33
+ const StatewireSessionLaneContext = react.createContext(null);
34
+ function useStatewireSessionLane() {
35
+ return react.useContext(StatewireSessionLaneContext);
36
+ }
37
+ const subscribeToNothing = () => () => {
38
+ };
39
+ function useStatewireSessionLanePending() {
40
+ const lane = useStatewireSessionLane();
41
+ const read = () => (lane == null ? void 0 : lane.isPending()) ?? false;
42
+ return react.useSyncExternalStore((lane == null ? void 0 : lane.subscribe) ?? subscribeToNothing, read, read);
43
+ }
44
+ exports.StatewireSessionLaneContext = StatewireSessionLaneContext;
45
+ exports.createStatewireSessionLaneGate = createStatewireSessionLaneGate;
46
+ exports.useStatewireSessionLane = useStatewireSessionLane;
47
+ exports.useStatewireSessionLanePending = useStatewireSessionLanePending;
48
+ //# sourceMappingURL=statewire-session-lane.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"statewire-session-lane.cjs","sources":["../../src/runtime/statewire-session-lane.ts"],"sourcesContent":["import { createContext, useContext, useSyncExternalStore } from 'react';\n\n/**\n * Whether the chat's persisted command lane is known. The lane is scoped by the\n * signed-in principal (`statewireSessionPrincipal`), so while the sign-in\n * provider above is still resolving who is signed in the lane is pending: the\n * thread's transport is parked and a command dispatched into it is refused\n * unsent. A send made meanwhile waits on this instead and goes out on the\n * signed-in user's lane once it is known.\n */\nexport interface StatewireSessionLane {\n /** True while the lane waits for the signed-in principal. */\n isPending: () => boolean;\n /** Resolves once the lane is known (at once when it already is). */\n whenKnown: () => Promise<void>;\n /** Called whenever `isPending()` changes. */\n subscribe: (listener: () => void) => () => void;\n}\n\n/** The provider's side of {@link StatewireSessionLane}: the mounted runtime reports its lane. */\nexport interface StatewireSessionLaneGate extends StatewireSessionLane {\n /** Report the lane of the runtime that has just committed it. */\n setPending: (pending: boolean) => void;\n}\n\nexport function createStatewireSessionLaneGate({\n pending,\n}: {\n pending: boolean;\n}): StatewireSessionLaneGate {\n let current = pending;\n let waiters: Array<() => void> = [];\n const listeners = new Set<() => void>();\n return {\n isPending: () => current,\n whenKnown: () =>\n current\n ? new Promise<void>((resolve) => {\n waiters.push(resolve);\n })\n : Promise.resolve(),\n subscribe: (listener) => {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n setPending: (next) => {\n if (next === current) return;\n current = next;\n if (!next) {\n const known = waiters;\n waiters = [];\n for (const resolve of known) resolve();\n }\n for (const listener of [...listeners]) listener();\n },\n };\n}\n\nexport const StatewireSessionLaneContext = createContext<StatewireSessionLane | null>(null);\n\n/** The provider's session lane, or `null` outside `AthenaProvider` (no lane to wait for). */\nexport function useStatewireSessionLane(): StatewireSessionLane | null {\n return useContext(StatewireSessionLaneContext);\n}\n\nconst subscribeToNothing = (): (() => void) => () => {};\n\n/** Whether the provider's session lane still waits for the signed-in principal (`false` outside one). */\nexport function useStatewireSessionLanePending(): boolean {\n const lane = useStatewireSessionLane();\n const read = () => lane?.isPending() ?? false;\n return useSyncExternalStore(lane?.subscribe ?? subscribeToNothing, read, read);\n}\n"],"names":["createContext","useContext","useSyncExternalStore"],"mappings":";;;AAyBO,SAAS,+BAA+B;AAAA,EAC7C;AACF,GAE6B;AAC3B,MAAI,UAAU;AACd,MAAI,UAA6B,CAAA;AACjC,QAAM,gCAAgB,IAAA;AACtB,SAAO;AAAA,IACL,WAAW,MAAM;AAAA,IACjB,WAAW,MACT,UACI,IAAI,QAAc,CAAC,YAAY;AAC7B,cAAQ,KAAK,OAAO;AAAA,IACtB,CAAC,IACD,QAAQ,QAAA;AAAA,IACd,WAAW,CAAC,aAAa;AACvB,gBAAU,IAAI,QAAQ;AACtB,aAAO,MAAM;AACX,kBAAU,OAAO,QAAQ;AAAA,MAC3B;AAAA,IACF;AAAA,IACA,YAAY,CAAC,SAAS;AACpB,UAAI,SAAS,QAAS;AACtB,gBAAU;AACV,UAAI,CAAC,MAAM;AACT,cAAM,QAAQ;AACd,kBAAU,CAAA;AACV,mBAAW,WAAW,MAAO,SAAA;AAAA,MAC/B;AACA,iBAAW,YAAY,CAAC,GAAG,SAAS,EAAG,UAAA;AAAA,IACzC;AAAA,EAAA;AAEJ;AAEO,MAAM,8BAA8BA,MAAAA,cAA2C,IAAI;AAGnF,SAAS,0BAAuD;AACrE,SAAOC,MAAAA,WAAW,2BAA2B;AAC/C;AAEA,MAAM,qBAAqB,MAAoB,MAAM;AAAC;AAG/C,SAAS,iCAA0C;AACxD,QAAM,OAAO,wBAAA;AACb,QAAM,OAAO,OAAM,6BAAM,gBAAe;AACxC,SAAOC,MAAAA,sBAAqB,6BAAM,cAAa,oBAAoB,MAAM,IAAI;AAC/E;;;;;"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Whether the chat's persisted command lane is known. The lane is scoped by the
3
+ * signed-in principal (`statewireSessionPrincipal`), so while the sign-in
4
+ * provider above is still resolving who is signed in the lane is pending: the
5
+ * thread's transport is parked and a command dispatched into it is refused
6
+ * unsent. A send made meanwhile waits on this instead and goes out on the
7
+ * signed-in user's lane once it is known.
8
+ */
9
+ export interface StatewireSessionLane {
10
+ /** True while the lane waits for the signed-in principal. */
11
+ isPending: () => boolean;
12
+ /** Resolves once the lane is known (at once when it already is). */
13
+ whenKnown: () => Promise<void>;
14
+ /** Called whenever `isPending()` changes. */
15
+ subscribe: (listener: () => void) => () => void;
16
+ }
17
+ /** The provider's side of {@link StatewireSessionLane}: the mounted runtime reports its lane. */
18
+ export interface StatewireSessionLaneGate extends StatewireSessionLane {
19
+ /** Report the lane of the runtime that has just committed it. */
20
+ setPending: (pending: boolean) => void;
21
+ }
22
+ export declare function createStatewireSessionLaneGate({ pending, }: {
23
+ pending: boolean;
24
+ }): StatewireSessionLaneGate;
25
+ export declare const StatewireSessionLaneContext: import("react").Context<StatewireSessionLane | null>;
26
+ /** The provider's session lane, or `null` outside `AthenaProvider` (no lane to wait for). */
27
+ export declare function useStatewireSessionLane(): StatewireSessionLane | null;
28
+ /** Whether the provider's session lane still waits for the signed-in principal (`false` outside one). */
29
+ export declare function useStatewireSessionLanePending(): boolean;
@@ -0,0 +1,48 @@
1
+ import { createContext, useSyncExternalStore, useContext } from "react";
2
+ function createStatewireSessionLaneGate({
3
+ pending
4
+ }) {
5
+ let current = pending;
6
+ let waiters = [];
7
+ const listeners = /* @__PURE__ */ new Set();
8
+ return {
9
+ isPending: () => current,
10
+ whenKnown: () => current ? new Promise((resolve) => {
11
+ waiters.push(resolve);
12
+ }) : Promise.resolve(),
13
+ subscribe: (listener) => {
14
+ listeners.add(listener);
15
+ return () => {
16
+ listeners.delete(listener);
17
+ };
18
+ },
19
+ setPending: (next) => {
20
+ if (next === current) return;
21
+ current = next;
22
+ if (!next) {
23
+ const known = waiters;
24
+ waiters = [];
25
+ for (const resolve of known) resolve();
26
+ }
27
+ for (const listener of [...listeners]) listener();
28
+ }
29
+ };
30
+ }
31
+ const StatewireSessionLaneContext = createContext(null);
32
+ function useStatewireSessionLane() {
33
+ return useContext(StatewireSessionLaneContext);
34
+ }
35
+ const subscribeToNothing = () => () => {
36
+ };
37
+ function useStatewireSessionLanePending() {
38
+ const lane = useStatewireSessionLane();
39
+ const read = () => (lane == null ? void 0 : lane.isPending()) ?? false;
40
+ return useSyncExternalStore((lane == null ? void 0 : lane.subscribe) ?? subscribeToNothing, read, read);
41
+ }
42
+ export {
43
+ StatewireSessionLaneContext,
44
+ createStatewireSessionLaneGate,
45
+ useStatewireSessionLane,
46
+ useStatewireSessionLanePending
47
+ };
48
+ //# sourceMappingURL=statewire-session-lane.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"statewire-session-lane.js","sources":["../../src/runtime/statewire-session-lane.ts"],"sourcesContent":["import { createContext, useContext, useSyncExternalStore } from 'react';\n\n/**\n * Whether the chat's persisted command lane is known. The lane is scoped by the\n * signed-in principal (`statewireSessionPrincipal`), so while the sign-in\n * provider above is still resolving who is signed in the lane is pending: the\n * thread's transport is parked and a command dispatched into it is refused\n * unsent. A send made meanwhile waits on this instead and goes out on the\n * signed-in user's lane once it is known.\n */\nexport interface StatewireSessionLane {\n /** True while the lane waits for the signed-in principal. */\n isPending: () => boolean;\n /** Resolves once the lane is known (at once when it already is). */\n whenKnown: () => Promise<void>;\n /** Called whenever `isPending()` changes. */\n subscribe: (listener: () => void) => () => void;\n}\n\n/** The provider's side of {@link StatewireSessionLane}: the mounted runtime reports its lane. */\nexport interface StatewireSessionLaneGate extends StatewireSessionLane {\n /** Report the lane of the runtime that has just committed it. */\n setPending: (pending: boolean) => void;\n}\n\nexport function createStatewireSessionLaneGate({\n pending,\n}: {\n pending: boolean;\n}): StatewireSessionLaneGate {\n let current = pending;\n let waiters: Array<() => void> = [];\n const listeners = new Set<() => void>();\n return {\n isPending: () => current,\n whenKnown: () =>\n current\n ? new Promise<void>((resolve) => {\n waiters.push(resolve);\n })\n : Promise.resolve(),\n subscribe: (listener) => {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n setPending: (next) => {\n if (next === current) return;\n current = next;\n if (!next) {\n const known = waiters;\n waiters = [];\n for (const resolve of known) resolve();\n }\n for (const listener of [...listeners]) listener();\n },\n };\n}\n\nexport const StatewireSessionLaneContext = createContext<StatewireSessionLane | null>(null);\n\n/** The provider's session lane, or `null` outside `AthenaProvider` (no lane to wait for). */\nexport function useStatewireSessionLane(): StatewireSessionLane | null {\n return useContext(StatewireSessionLaneContext);\n}\n\nconst subscribeToNothing = (): (() => void) => () => {};\n\n/** Whether the provider's session lane still waits for the signed-in principal (`false` outside one). */\nexport function useStatewireSessionLanePending(): boolean {\n const lane = useStatewireSessionLane();\n const read = () => lane?.isPending() ?? false;\n return useSyncExternalStore(lane?.subscribe ?? subscribeToNothing, read, read);\n}\n"],"names":[],"mappings":";AAyBO,SAAS,+BAA+B;AAAA,EAC7C;AACF,GAE6B;AAC3B,MAAI,UAAU;AACd,MAAI,UAA6B,CAAA;AACjC,QAAM,gCAAgB,IAAA;AACtB,SAAO;AAAA,IACL,WAAW,MAAM;AAAA,IACjB,WAAW,MACT,UACI,IAAI,QAAc,CAAC,YAAY;AAC7B,cAAQ,KAAK,OAAO;AAAA,IACtB,CAAC,IACD,QAAQ,QAAA;AAAA,IACd,WAAW,CAAC,aAAa;AACvB,gBAAU,IAAI,QAAQ;AACtB,aAAO,MAAM;AACX,kBAAU,OAAO,QAAQ;AAAA,MAC3B;AAAA,IACF;AAAA,IACA,YAAY,CAAC,SAAS;AACpB,UAAI,SAAS,QAAS;AACtB,gBAAU;AACV,UAAI,CAAC,MAAM;AACT,cAAM,QAAQ;AACd,kBAAU,CAAA;AACV,mBAAW,WAAW,MAAO,SAAA;AAAA,MAC/B;AACA,iBAAW,YAAY,CAAC,GAAG,SAAS,EAAG,UAAA;AAAA,IACzC;AAAA,EAAA;AAEJ;AAEO,MAAM,8BAA8B,cAA2C,IAAI;AAGnF,SAAS,0BAAuD;AACrE,SAAO,WAAW,2BAA2B;AAC/C;AAEA,MAAM,qBAAqB,MAAoB,MAAM;AAAC;AAG/C,SAAS,iCAA0C;AACxD,QAAM,OAAO,wBAAA;AACb,QAAM,OAAO,OAAM,6BAAM,gBAAe;AACxC,SAAO,sBAAqB,6BAAM,cAAa,oBAAoB,MAAM,IAAI;AAC/E;"}
@@ -1,4 +1,4 @@
1
- import type { ThreadConfigCustom } from '@athenaintel/agent-runtime';
1
+ import type { ThreadConfigCustom } from '../agent-runtime/src/index';
2
2
  /**
3
3
  * The thread-config keys the provider's props own, in the order a
4
4
  * `config/patch` lists them.
@@ -10,6 +10,7 @@ const statewireSessionKey = require("./statewire-session-key.cjs");
10
10
  const statewireRunConfig = require("./statewire-run-config.cjs");
11
11
  const runconfigContract = require("../agent-runtime/src/generated/runconfig-contract.cjs");
12
12
  const useDeepAgentRuntime = require("../agent-runtime/src/use-deep-agent-runtime.cjs");
13
+ const subagentTranscripts = require("../agent-runtime/src/subagent-transcripts.cjs");
13
14
  const errors = require("../agent-runtime/src/errors.cjs");
14
15
  const protocol = require("../agent-runtime/src/protocol.cjs");
15
16
  const composerMarkdown = require("../agent-runtime/src/composer-markdown.cjs");
@@ -25,7 +26,6 @@ function useStatewireClientTools(frontendToolkit) {
25
26
  );
26
27
  }
27
28
  function useAthenaStatewireRuntime(config) {
28
- var _a;
29
29
  const {
30
30
  syncUrl,
31
31
  threadId,
@@ -47,17 +47,18 @@ function useAthenaStatewireRuntime(config) {
47
47
  extraRunConfig,
48
48
  snapshotCache,
49
49
  messageWindow = ATHENA_SDK_MESSAGE_WINDOW,
50
+ subagentLaneHistory = false,
50
51
  toolOutputs,
51
52
  onError,
52
53
  onConnectionChange,
53
54
  onRawConnectionChange,
54
55
  onRunningChange,
56
+ onCommandChange,
55
57
  onServerState
56
58
  } = config;
57
59
  statewireRunConfig.resolveAgentProp({ agent });
58
60
  const clientTools = useStatewireClientTools(frontendToolkit);
59
- const authContext = react.useContext(AthenaAuthContext.AthenaAuthContext);
60
- const principal = ((_a = authContext == null ? void 0 : authContext.user) == null ? void 0 : _a.userId) ?? "";
61
+ const principal = statewireSessionKey.statewireSessionPrincipal(react.useContext(AthenaAuthContext.AthenaAuthContext));
61
62
  const attachSpanRef = react.useRef(null);
62
63
  const attachThreadRef = react.useRef(null);
63
64
  if (attachThreadRef.current !== threadId) {
@@ -103,8 +104,11 @@ function useAthenaStatewireRuntime(config) {
103
104
  // id is only meaningful against the backend that minted it, and a stored
104
105
  // lane must never resend against another signed-in user. (Consumers
105
106
  // server-render this SDK; the core's availability probe keeps those
106
- // sessions process-local, as before the seam existed.)
107
- session: {
107
+ // sessions process-local, as before the seam existed.) Until the sign-in
108
+ // provider knows who is signed in, the lane is pending: the transport
109
+ // stays parked and nothing is mounted on a stand-in key the session could
110
+ // not move off (`statewireSessionPrincipal`).
111
+ session: principal === null ? { kind: "pending" } : {
108
112
  kind: "local-storage",
109
113
  key: (id) => statewireSessionKey.statewireSessionKey({ syncUrl, principal, threadId: id })
110
114
  },
@@ -114,6 +118,12 @@ function useAthenaStatewireRuntime(config) {
114
118
  // older ranges in and fetches cut tool outputs into `toolOutputs`.
115
119
  messageWindow,
116
120
  toolOutputs,
121
+ // Each `task` card's nested transcript becomes its tool-call part's
122
+ // `messages` (assistant-ui's nested-thread channel), which the subagent
123
+ // card (`SubagentTaskToolUI`) shows.
124
+ createConversionCache: subagentTranscripts.createSubagentTranscriptConversionCache,
125
+ // The lane-cut contract only where the chat pages lanes (see `subagentLaneHistory`).
126
+ laneHistory: subagentLaneHistory,
117
127
  capabilities: { edit: true, reload: true, continue: true },
118
128
  // The composer stages the draft each send came from right before it
119
129
  // sends; the message carries it as its composer markdown, so its bubble
@@ -145,6 +155,7 @@ function useAthenaStatewireRuntime(config) {
145
155
  },
146
156
  onRawConnectionChange,
147
157
  onRunningChange,
158
+ ...onCommandChange && { onCommandChange },
148
159
  // Each model-context notification pulls the latest getter through the
149
160
  // core's per-render ref; the value-stable key re-registers (and so
150
161
  // notifies) only when the built runConfig actually changed. On a thread
@@ -1 +1 @@
1
- {"version":3,"file":"useAthenaStatewireRuntime.cjs","sources":["../../src/runtime/useAthenaStatewireRuntime.ts"],"sourcesContent":["import type { AssistantClient, Toolkit } from '@assistant-ui/react';\nimport { Tools, useAui } from '@assistant-ui/react';\nimport {\n DEEP_AGENT_DEFAULT_MESSAGE_WINDOW,\n type DeepAgentMessageWindowDeclaration,\n type DeepAgentStreamValues,\n type DeepAgentThreadElement,\n type DeepAgentThreadSnapshotCache,\n type DeepAgentToolOutputStore,\n isDeepAgentHostState,\n isStatewireChannelTeardown,\n logUnhandledStatewireError,\n type RegisteredClientTool,\n useDeepAgentRuntime,\n type UseDeepAgentThreadOptions,\n withStagedComposerMarkdown,\n} from '@athenaintel/agent-runtime';\nimport { useContext, useMemo, useRef } from 'react';\nimport { AthenaAuthContext } from '../auth/AthenaAuthContext';\nimport {\n collectStatewireClientTools,\n statewireClientToolWireEntries,\n} from '../chat/statewire-client-tools';\nimport { athenaDiagnostics } from '../diagnostics/athena-diagnostics';\nimport {\n type AthenaStatewireTokenGetter,\n resolveStatewireAuthHeaders,\n} from './statewire-auth-headers';\nimport { statewireSessionKey } from './statewire-session-key';\n\ntype AthenaDiagnosticsSpanStarter = typeof athenaDiagnostics.span;\nimport {\n buildStatewireRunConfig,\n DEFAULT_STATEWIRE_MODEL,\n resolveAgentProp,\n} from './statewire-run-config';\n\nexport { DEFAULT_STATEWIRE_MODEL };\n\n/**\n * The head interest every SDK attach states (`athena/interest`): the host\n * mounts the transcript's tail as message documents instead of every message\n * — megabytes on long threads, over the 1 MiB frame limit of stock websocket\n * clients. Older pages load from the `StatewireHistoryEdge` row the chat UI\n * mounts above the messages, and cut tool outputs are fetched back for the\n * cards that show them.\n */\nexport const ATHENA_SDK_MESSAGE_WINDOW: DeepAgentMessageWindowDeclaration = {\n size: DEEP_AGENT_DEFAULT_MESSAGE_WINDOW,\n};\n\nexport interface AthenaStatewireRuntimeConfig {\n /** Base URL of the statewire sync host (the `…/v2/threads` mount). */\n syncUrl: string;\n /** Thread ID the statewire session attaches to. */\n threadId: string;\n /** True only for a never-started local chat. Existing (or pre-assigned)\n * threads load until their server snapshot arrives. */\n isNewChat?: boolean;\n /** API key for authentication. Used when no auth token is provided. */\n apiKey?: string;\n /** Auth token. Takes priority over apiKey. */\n token?: string | null;\n /** Resolve the latest token immediately before a request (for expiring\n * clients). Called with `{ force: true }` right after the host refused the\n * previous credential (the transport's `staleAuth`), so a caching getter\n * mints a fresh token instead of returning the refused one. */\n getToken?: AthenaStatewireTokenGetter;\n /**\n * Per-provider LRU of each thread's last wire state. A switch back to a\n * remembered thread mounts with that snapshot and projects ready on the\n * first frame instead of a loading treatment; the attach snapshot then\n * replaces it. Owned above the per-thread mount so it survives switches.\n */\n snapshotCache?: DeepAgentThreadSnapshotCache;\n /** The head interest stated on the attach (see {@link ATHENA_SDK_MESSAGE_WINDOW}, the default). */\n messageWindow?: DeepAgentMessageWindowDeclaration;\n /**\n * Full tool outputs fetched back for a windowed wire's cut tool messages;\n * the thread re-converts when one lands. `AthenaProvider` owns one per\n * provider and hands the same store to `StatewireHistoryEdge`.\n */\n toolOutputs?: DeepAgentToolOutputStore;\n /** LLM model identifier. Defaults to the deep-agent default model. */\n model?: string;\n /** Agent selector: only `collab_agent:<asset_id>` refs are accepted (the run\n * executes AS that published collab agent). Any other non-empty value\n * throws — see `resolveAgentProp`. */\n agent?: string;\n /** Collab-agent channel id selecting that channel's overrides. */\n channel?: string;\n /** The agent's mode picked for this thread (`AthenaProvider` `modes`). */\n mode?: string;\n /** Backend toolkit IDs to enable. */\n tools?: string[];\n /** Frontend tool IDs to include in enabled_tools. */\n frontendToolIds?: string[];\n /** Frontend tools registered on the assistant client. Tools with a local\n * `execute` are also declared as `client_tools` and executed through the\n * statewire client-tool bridge. */\n frontendToolkit?: Toolkit;\n /** Asset IDs to include in the workbench. */\n workbench?: string[];\n /** Knowledge base IDs for RAG context. */\n knowledgeBase?: string[];\n /** System prompt override. */\n systemPrompt?: string;\n /** Client app identifier for session filtering. Sent as app_id in runConfig.custom. */\n appId?: string;\n /** Additional fields merged into runConfig.custom. */\n extraRunConfig?: Record<string, unknown>;\n /** Called on statewire transport errors (send rejections, stream failures). */\n onError?: (error: Error) => void;\n /** Projected connection status changes (deduped; null on unmount). */\n onConnectionChange?: UseDeepAgentThreadOptions['onConnectionChange'];\n /** Raw connection observer — carries the transport's reconnect handle. */\n onRawConnectionChange?: UseDeepAgentThreadOptions['onRawConnectionChange'];\n /** Notified when a run starts/stops. */\n onRunningChange?: UseDeepAgentThreadOptions['onRunningChange'];\n /**\n * Observes the host's own state: called with the attach snapshot and then on\n * every later frame (`isDeepAgentHostState`) — never with the placeholder or\n * remembered snapshot a thread renders before its snapshot applies, which\n * can be after the connection reports `connected`. Called per streamed\n * token, so keep it cheap.\n */\n onServerState?: (state: DeepAgentStreamValues) => void;\n}\n\nconst EMPTY_TOOLKIT: Toolkit = {};\nconst EMPTY_TOOL_IDS: string[] = [];\n\n/** The client tools derived from the runtime's frontend toolkit — exposed so\n * the provider can mount the client-tool bridge with the same set. */\nexport function useStatewireClientTools(\n frontendToolkit: Toolkit | undefined,\n): RegisteredClientTool[] {\n return useMemo(\n () => collectStatewireClientTools(frontendToolkit ?? EMPTY_TOOLKIT),\n [frontendToolkit],\n );\n}\n\n/**\n * Statewire runtime for the Athena SDK — a thin shim over the shared\n * `@athenaintel/agent-runtime` `useDeepAgentRuntime`: it attaches to the\n * agora-hosted deep-agent thread at `${syncUrl}/${threadId}` and returns the\n * `AssistantClient` to mount via `AuiProvider` — the same integration shape as\n * the Olympus, Chrome extension, Office, and mobile statewire hosts.\n *\n * Auth: a token (resolved live through `getToken` when provided) rides\n * `Authorization: Bearer`, and an API key falls back to `X-API-KEY` — both\n * accepted by the statewire host.\n */\nexport function useAthenaStatewireRuntime(\n config: AthenaStatewireRuntimeConfig,\n): AssistantClient {\n const {\n syncUrl,\n threadId,\n isNewChat = false,\n apiKey,\n token,\n getToken,\n model,\n agent,\n channel,\n mode,\n tools = EMPTY_TOOL_IDS,\n frontendToolIds = EMPTY_TOOL_IDS,\n frontendToolkit = EMPTY_TOOLKIT,\n workbench,\n knowledgeBase,\n systemPrompt,\n appId,\n extraRunConfig,\n snapshotCache,\n messageWindow = ATHENA_SDK_MESSAGE_WINDOW,\n toolOutputs,\n onError,\n onConnectionChange,\n onRawConnectionChange,\n onRunningChange,\n onServerState,\n } = config;\n\n // Fail loud at mount, not at first send: the statewire host always runs the\n // Athena deep agent, so an `agent` outside the collab_agent namespace can\n // never apply. Throwing here (render time) is what makes a misconfigured\n // integration visible instead of quietly answering as the wrong agent.\n resolveAgentProp({ agent });\n\n const clientTools = useStatewireClientTools(frontendToolkit);\n\n // The persisted command lane is keyed by WHO is signed in as well as by host\n // and thread (see `statewireSessionKey`).\n const authContext = useContext(AthenaAuthContext);\n const principal = authContext?.user?.userId ?? '';\n\n // Attach → first server snapshot span, keyed per thread attach.\n const attachSpanRef = useRef<ReturnType<AthenaDiagnosticsSpanStarter> | null>(null);\n const attachThreadRef = useRef<string | null>(null);\n if (attachThreadRef.current !== threadId) {\n attachThreadRef.current = threadId;\n attachSpanRef.current = athenaDiagnostics.span(\n `statewire.attach:${threadId}`,\n 'statewire.attach.start',\n { thread_id: threadId, is_new_chat: isNewChat },\n );\n }\n\n // Built every render so its JSON signature can key the model-context\n // registration below: consumers commonly pass fresh array literals per\n // render, which must not thrash registration, while a changed value (a new\n // `model`, channel, tool list, system prompt, …) must re-sync the context\n // before the next send. The core pulls this value only on model-context\n // notifications, which a key change triggers.\n const runConfigValue = buildStatewireRunConfig({\n model,\n agent,\n channel,\n mode,\n tools,\n frontendToolIds,\n workbench,\n knowledgeBase,\n systemPrompt,\n appId,\n extraRunConfig,\n clientTools: statewireClientToolWireEntries(clientTools),\n });\n const runConfigKey = JSON.stringify(runConfigValue);\n\n const auiTools = useMemo(() => Tools({ toolkit: frontendToolkit }), [frontendToolkit]);\n // Web client for the shared runtime core (a `use*` name so the\n // rules-of-hooks lint sees the `useAui` call inside a custom hook; the core\n // invokes it unconditionally every render).\n const useSdkClient = (thread: DeepAgentThreadElement) => useAui({ thread, tools: auiTools });\n\n return useDeepAgentRuntime({\n surface: 'AthenaSDK',\n threadId,\n baseUrl: syncUrl,\n // Option closures are re-read per render by the core, so credential\n // rotation (new `token`/`getToken`/`apiKey` props) reaches the next\n // request without remounting the thread. The transport's `staleAuth`\n // (true right after a refused credential) is forwarded as `force`.\n headers: (ctx) => resolveStatewireAuthHeaders({ apiKey, token, getToken }, ctx),\n isNewChat,\n // Queued entries render in the SDK's queue panel, so only the steer lane\n // projects into the message tail.\n laneProjection: 'steer-only',\n // Durable session: a reload resumes the lane and resends whatever the\n // server has not marked durable. Scoped by host AND principal — a thread\n // id is only meaningful against the backend that minted it, and a stored\n // lane must never resend against another signed-in user. (Consumers\n // server-render this SDK; the core's availability probe keeps those\n // sessions process-local, as before the seam existed.)\n session: {\n kind: 'local-storage',\n key: (id) => statewireSessionKey({ syncUrl, principal, threadId: id }),\n },\n snapshotCache,\n // Head interest (see `ATHENA_SDK_MESSAGE_WINDOW`): the tail of the\n // transcript instead of every message; the chat UI's history edge pages\n // older ranges in and fetches cut tool outputs into `toolOutputs`.\n messageWindow,\n toolOutputs,\n capabilities: { edit: true, reload: true, continue: true },\n // The composer stages the draft each send came from right before it\n // sends; the message carries it as its composer markdown, so its bubble\n // shows the text exactly as typed (`UserMessageText`).\n getMessageMetadata: withStagedComposerMarkdown({ threadId }),\n useClient: useSdkClient,\n onStateChange: (state) => {\n // Statewire publishes what the thread renders before its attach snapshot\n // through here too (the placeholder, a remembered snapshot, and a replay\n // boundary's pre-stream default), and on a thread mid-run it reports\n // `connected` before the snapshot applies: only a state the host sent\n // counts, whatever the connection says.\n if (!isDeepAgentHostState(state)) return;\n // The attach's first one ends the attach span (time-to-history).\n const endSpan = attachSpanRef.current;\n if (endSpan) {\n attachSpanRef.current = null;\n endSpan('statewire.snapshot', { data: { thread_id: threadId } });\n }\n onServerState?.(state);\n },\n onConnectionChange: (connection) => {\n athenaDiagnostics.gauge('statewire.connection', connection?.status ?? null);\n if (connection?.status === 'stopped') {\n athenaDiagnostics.emit('statewire.connection', {\n level: 'warn',\n data: {\n status: connection.status,\n reason: connection.reason,\n message: connection.message,\n },\n });\n }\n onConnectionChange?.(connection);\n },\n onRawConnectionChange,\n onRunningChange,\n // Each model-context notification pulls the latest getter through the\n // core's per-render ref; the value-stable key re-registers (and so\n // notifies) only when the built runConfig actually changed. On a thread\n // with a server config lane, agora keeps only the per-send keys of what\n // this carries; `StatewireThreadConfigLaneSync` writes a changed model,\n // system prompt, tool list, workbench or knowledge base to the lane itself.\n runConfig: {\n get: () => runConfigValue,\n key: runConfigKey,\n },\n onError: (error) => {\n if (!isStatewireChannelTeardown(error)) {\n athenaDiagnostics.error(\n 'statewire.error',\n error,\n {\n code: 'statewire_rejected',\n message: 'The statewire host rejected a command',\n hint: 'Inspect error.detail — agora rejections carry a structured {code, message}.',\n },\n { thread_id: threadId },\n );\n }\n if (onError) {\n onError(error);\n return;\n }\n logUnhandledStatewireError('AthenaSDK', error);\n },\n });\n}\n"],"names":["DEEP_AGENT_DEFAULT_MESSAGE_WINDOW","useMemo","collectStatewireClientTools","resolveAgentProp","useContext","AthenaAuthContext","useRef","athenaDiagnostics","buildStatewireRunConfig","statewireClientToolWireEntries","Tools","useAui","useDeepAgentRuntime","resolveStatewireAuthHeaders","statewireSessionKey","withStagedComposerMarkdown","isDeepAgentHostState","isStatewireChannelTeardown","logUnhandledStatewireError"],"mappings":";;;;;;;;;;;;;;;AA+CO,MAAM,4BAA+D;AAAA,EAC1E,MAAMA,kBAAAA;AACR;AAgFA,MAAM,gBAAyB,CAAA;AAC/B,MAAM,iBAA2B,CAAA;AAI1B,SAAS,wBACd,iBACwB;AACxB,SAAOC,MAAAA;AAAAA,IACL,MAAMC,qBAAAA,4BAA4B,mBAAmB,aAAa;AAAA,IAClE,CAAC,eAAe;AAAA,EAAA;AAEpB;AAaO,SAAS,0BACd,QACiB;;AACjB,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,YAAY;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR,kBAAkB;AAAA,IAClB,kBAAkB;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,gBAAgB;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,IACE;AAMJC,qBAAAA,iBAAiB,EAAE,OAAO;AAE1B,QAAM,cAAc,wBAAwB,eAAe;AAI3D,QAAM,cAAcC,MAAAA,WAAWC,mCAAiB;AAChD,QAAM,cAAY,gDAAa,SAAb,mBAAmB,WAAU;AAG/C,QAAM,gBAAgBC,MAAAA,OAAwD,IAAI;AAClF,QAAM,kBAAkBA,MAAAA,OAAsB,IAAI;AAClD,MAAI,gBAAgB,YAAY,UAAU;AACxC,oBAAgB,UAAU;AAC1B,kBAAc,UAAUC,kBAAAA,kBAAkB;AAAA,MACxC,oBAAoB,QAAQ;AAAA,MAC5B;AAAA,MACA,EAAE,WAAW,UAAU,aAAa,UAAA;AAAA,IAAU;AAAA,EAElD;AAQA,QAAM,iBAAiBC,mBAAAA,wBAAwB;AAAA,IAC7C;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,aAAaC,qBAAAA,+BAA+B,WAAW;AAAA,EAAA,CACxD;AACD,QAAM,eAAe,KAAK,UAAU,cAAc;AAElD,QAAM,WAAWR,cAAQ,MAAMS,cAAM,EAAE,SAAS,gBAAA,CAAiB,GAAG,CAAC,eAAe,CAAC;AAIrF,QAAM,eAAe,CAAC,WAAmCC,QAAAA,OAAO,EAAE,QAAQ,OAAO,UAAU;AAE3F,SAAOC,wCAAoB;AAAA,IACzB,SAAS;AAAA,IACT;AAAA,IACA,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA,IAKT,SAAS,CAAC,QAAQC,iDAA4B,EAAE,QAAQ,OAAO,SAAA,GAAY,GAAG;AAAA,IAC9E;AAAA;AAAA;AAAA,IAGA,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOhB,SAAS;AAAA,MACP,MAAM;AAAA,MACN,KAAK,CAAC,OAAOC,oBAAAA,oBAAoB,EAAE,SAAS,WAAW,UAAU,GAAA,CAAI;AAAA,IAAA;AAAA,IAEvE;AAAA;AAAA;AAAA;AAAA,IAIA;AAAA,IACA;AAAA,IACA,cAAc,EAAE,MAAM,MAAM,QAAQ,MAAM,UAAU,KAAA;AAAA;AAAA;AAAA;AAAA,IAIpD,oBAAoBC,iBAAAA,2BAA2B,EAAE,UAAU;AAAA,IAC3D,WAAW;AAAA,IACX,eAAe,CAAC,UAAU;AAMxB,UAAI,CAACC,SAAAA,qBAAqB,KAAK,EAAG;AAElC,YAAM,UAAU,cAAc;AAC9B,UAAI,SAAS;AACX,sBAAc,UAAU;AACxB,gBAAQ,sBAAsB,EAAE,MAAM,EAAE,WAAW,SAAA,GAAY;AAAA,MACjE;AACA,qDAAgB;AAAA,IAClB;AAAA,IACA,oBAAoB,CAAC,eAAe;AAClCT,wBAAAA,kBAAkB,MAAM,yBAAwB,yCAAY,WAAU,IAAI;AAC1E,WAAI,yCAAY,YAAW,WAAW;AACpCA,0BAAAA,kBAAkB,KAAK,wBAAwB;AAAA,UAC7C,OAAO;AAAA,UACP,MAAM;AAAA,YACJ,QAAQ,WAAW;AAAA,YACnB,QAAQ,WAAW;AAAA,YACnB,SAAS,WAAW;AAAA,UAAA;AAAA,QACtB,CACD;AAAA,MACH;AACA,+DAAqB;AAAA,IACvB;AAAA,IACA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOA,WAAW;AAAA,MACT,KAAK,MAAM;AAAA,MACX,KAAK;AAAA,IAAA;AAAA,IAEP,SAAS,CAAC,UAAU;AAClB,UAAI,CAACU,OAAAA,2BAA2B,KAAK,GAAG;AACtCV,0BAAAA,kBAAkB;AAAA,UAChB;AAAA,UACA;AAAA,UACA;AAAA,YACE,MAAM;AAAA,YACN,SAAS;AAAA,YACT,MAAM;AAAA,UAAA;AAAA,UAER,EAAE,WAAW,SAAA;AAAA,QAAS;AAAA,MAE1B;AACA,UAAI,SAAS;AACX,gBAAQ,KAAK;AACb;AAAA,MACF;AACAW,0BAAAA,2BAA2B,aAAa,KAAK;AAAA,IAC/C;AAAA,EAAA,CACD;AACH;;;;;"}
1
+ {"version":3,"file":"useAthenaStatewireRuntime.cjs","sources":["../../src/runtime/useAthenaStatewireRuntime.ts"],"sourcesContent":["import type { AssistantClient, Toolkit } from '@assistant-ui/react';\nimport { Tools, useAui } from '@assistant-ui/react';\nimport {\n createSubagentTranscriptConversionCache,\n DEEP_AGENT_DEFAULT_MESSAGE_WINDOW,\n type DeepAgentMessageWindowDeclaration,\n type DeepAgentStreamValues,\n type DeepAgentThreadElement,\n type DeepAgentThreadSnapshotCache,\n type DeepAgentToolOutputStore,\n isDeepAgentHostState,\n isStatewireChannelTeardown,\n logUnhandledStatewireError,\n type RegisteredClientTool,\n useDeepAgentRuntime,\n type UseDeepAgentThreadOptions,\n withStagedComposerMarkdown,\n} from '@athenaintel/agent-runtime';\nimport { useContext, useMemo, useRef } from 'react';\nimport { AthenaAuthContext } from '../auth/AthenaAuthContext';\nimport {\n collectStatewireClientTools,\n statewireClientToolWireEntries,\n} from '../chat/statewire-client-tools';\nimport { athenaDiagnostics } from '../diagnostics/athena-diagnostics';\nimport {\n type AthenaStatewireTokenGetter,\n resolveStatewireAuthHeaders,\n} from './statewire-auth-headers';\nimport { statewireSessionKey, statewireSessionPrincipal } from './statewire-session-key';\n\ntype AthenaDiagnosticsSpanStarter = typeof athenaDiagnostics.span;\nimport {\n buildStatewireRunConfig,\n DEFAULT_STATEWIRE_MODEL,\n resolveAgentProp,\n} from './statewire-run-config';\n\nexport { DEFAULT_STATEWIRE_MODEL };\n\n/**\n * The head interest every SDK attach states (`athena/interest`): the host\n * mounts the transcript's tail as message documents instead of every message\n * — megabytes on long threads, over the 1 MiB frame limit of stock websocket\n * clients. Older pages load from the `StatewireHistoryEdge` row the chat UI\n * mounts above the messages, and cut tool outputs are fetched back for the\n * cards that show them.\n */\nexport const ATHENA_SDK_MESSAGE_WINDOW: DeepAgentMessageWindowDeclaration = {\n size: DEEP_AGENT_DEFAULT_MESSAGE_WINDOW,\n};\n\nexport interface AthenaStatewireRuntimeConfig {\n /** Base URL of the statewire sync host (the `…/v2/threads` mount). */\n syncUrl: string;\n /** Thread ID the statewire session attaches to. */\n threadId: string;\n /** True only for a never-started local chat. Existing (or pre-assigned)\n * threads load until their server snapshot arrives. */\n isNewChat?: boolean;\n /** API key for authentication. Used when no auth token is provided. */\n apiKey?: string;\n /** Auth token. Takes priority over apiKey. */\n token?: string | null;\n /** Resolve the latest token immediately before a request (for expiring\n * clients). Called with `{ force: true }` right after the host refused the\n * previous credential (the transport's `staleAuth`), so a caching getter\n * mints a fresh token instead of returning the refused one. */\n getToken?: AthenaStatewireTokenGetter;\n /**\n * Per-provider LRU of each thread's last wire state. A switch back to a\n * remembered thread mounts with that snapshot and projects ready on the\n * first frame instead of a loading treatment; the attach snapshot then\n * replaces it. Owned above the per-thread mount so it survives switches.\n */\n snapshotCache?: DeepAgentThreadSnapshotCache;\n /** The head interest stated on the attach (see {@link ATHENA_SDK_MESSAGE_WINDOW}, the default). */\n messageWindow?: DeepAgentMessageWindowDeclaration;\n /**\n * Whether the chat this runtime serves loads a subagent lane's earlier steps\n * on request, as `AthenaChat`'s subagent card does (\"Load earlier steps\").\n * When true, its attaches declare the deep-agent lane-cut contract\n * (protocol 2): the host sends a finished subagent's card cut to its newest\n * steps, as it sends a running one, and the card reads the rest. Default\n * `false`, so a chat that does not page lanes declares the default contract\n * and finished lanes arrive whole; a host whose `AthenaChat` renders every\n * `task` call in the subagent card turns it on through `AthenaProvider`'s\n * `subagentLaneHistory`. Read once per attach.\n */\n subagentLaneHistory?: boolean;\n /**\n * Full tool outputs fetched back for a windowed wire's cut tool messages;\n * the thread re-converts when one lands. `AthenaProvider` owns one per\n * provider and hands the same store to `StatewireHistoryEdge`.\n */\n toolOutputs?: DeepAgentToolOutputStore;\n /** LLM model identifier. Defaults to the deep-agent default model. */\n model?: string;\n /** Agent selector: only `collab_agent:<asset_id>` refs are accepted (the run\n * executes AS that published collab agent). Any other non-empty value\n * throws — see `resolveAgentProp`. */\n agent?: string;\n /** Collab-agent channel id selecting that channel's overrides. */\n channel?: string;\n /** The agent's mode picked for this thread (`AthenaProvider` `modes`). */\n mode?: string;\n /** Backend toolkit IDs to enable. */\n tools?: string[];\n /** Frontend tool IDs to include in enabled_tools. */\n frontendToolIds?: string[];\n /** Frontend tools registered on the assistant client. Tools with a local\n * `execute` are also declared as `client_tools` and executed through the\n * statewire client-tool bridge. */\n frontendToolkit?: Toolkit;\n /** Asset IDs to include in the workbench. */\n workbench?: string[];\n /** Knowledge base IDs for RAG context. */\n knowledgeBase?: string[];\n /** System prompt override. */\n systemPrompt?: string;\n /** Client app identifier for session filtering. Sent as app_id in runConfig.custom. */\n appId?: string;\n /** Additional fields merged into runConfig.custom. */\n extraRunConfig?: Record<string, unknown>;\n /** Called on statewire transport errors (send rejections, stream failures). */\n onError?: (error: Error) => void;\n /** Projected connection status changes (deduped; null on unmount). */\n onConnectionChange?: UseDeepAgentThreadOptions['onConnectionChange'];\n /** Raw connection observer — carries the transport's reconnect handle. */\n onRawConnectionChange?: UseDeepAgentThreadOptions['onRawConnectionChange'];\n /** Notified when a run starts/stops. */\n onRunningChange?: UseDeepAgentThreadOptions['onRunningChange'];\n /** Every statewire command-lifecycle update (the chat outbox lets a handed-over message go on it). */\n onCommandChange?: UseDeepAgentThreadOptions['onCommandChange'];\n /**\n * Observes the host's own state: called with the attach snapshot and then on\n * every later frame (`isDeepAgentHostState`) — never with the placeholder or\n * remembered snapshot a thread renders before its snapshot applies, which\n * can be after the connection reports `connected`. Called per streamed\n * token, so keep it cheap.\n */\n onServerState?: (state: DeepAgentStreamValues) => void;\n}\n\nconst EMPTY_TOOLKIT: Toolkit = {};\nconst EMPTY_TOOL_IDS: string[] = [];\n\n/** The client tools derived from the runtime's frontend toolkit — exposed so\n * the provider can mount the client-tool bridge with the same set. */\nexport function useStatewireClientTools(\n frontendToolkit: Toolkit | undefined,\n): RegisteredClientTool[] {\n return useMemo(\n () => collectStatewireClientTools(frontendToolkit ?? EMPTY_TOOLKIT),\n [frontendToolkit],\n );\n}\n\n/**\n * Statewire runtime for the Athena SDK — a thin shim over the shared\n * `@athenaintel/agent-runtime` `useDeepAgentRuntime`: it attaches to the\n * agora-hosted deep-agent thread at `${syncUrl}/${threadId}` and returns the\n * `AssistantClient` to mount via `AuiProvider` — the same integration shape as\n * the Olympus, Chrome extension, Office, and mobile statewire hosts.\n *\n * Auth: a token (resolved live through `getToken` when provided) rides\n * `Authorization: Bearer`, and an API key falls back to `X-API-KEY` — both\n * accepted by the statewire host.\n */\nexport function useAthenaStatewireRuntime(\n config: AthenaStatewireRuntimeConfig,\n): AssistantClient {\n const {\n syncUrl,\n threadId,\n isNewChat = false,\n apiKey,\n token,\n getToken,\n model,\n agent,\n channel,\n mode,\n tools = EMPTY_TOOL_IDS,\n frontendToolIds = EMPTY_TOOL_IDS,\n frontendToolkit = EMPTY_TOOLKIT,\n workbench,\n knowledgeBase,\n systemPrompt,\n appId,\n extraRunConfig,\n snapshotCache,\n messageWindow = ATHENA_SDK_MESSAGE_WINDOW,\n subagentLaneHistory = false,\n toolOutputs,\n onError,\n onConnectionChange,\n onRawConnectionChange,\n onRunningChange,\n onCommandChange,\n onServerState,\n } = config;\n\n // Fail loud at mount, not at first send: the statewire host always runs the\n // Athena deep agent, so an `agent` outside the collab_agent namespace can\n // never apply. Throwing here (render time) is what makes a misconfigured\n // integration visible instead of quietly answering as the wrong agent.\n resolveAgentProp({ agent });\n\n const clientTools = useStatewireClientTools(frontendToolkit);\n\n // The persisted command lane is keyed by WHO is signed in as well as by host\n // and thread (see `statewireSessionKey`); `null` while the sign-in provider\n // above is still resolving who that is.\n const principal = statewireSessionPrincipal(useContext(AthenaAuthContext));\n\n // Attach → first server snapshot span, keyed per thread attach.\n const attachSpanRef = useRef<ReturnType<AthenaDiagnosticsSpanStarter> | null>(null);\n const attachThreadRef = useRef<string | null>(null);\n if (attachThreadRef.current !== threadId) {\n attachThreadRef.current = threadId;\n attachSpanRef.current = athenaDiagnostics.span(\n `statewire.attach:${threadId}`,\n 'statewire.attach.start',\n { thread_id: threadId, is_new_chat: isNewChat },\n );\n }\n\n // Built every render so its JSON signature can key the model-context\n // registration below: consumers commonly pass fresh array literals per\n // render, which must not thrash registration, while a changed value (a new\n // `model`, channel, tool list, system prompt, …) must re-sync the context\n // before the next send. The core pulls this value only on model-context\n // notifications, which a key change triggers.\n const runConfigValue = buildStatewireRunConfig({\n model,\n agent,\n channel,\n mode,\n tools,\n frontendToolIds,\n workbench,\n knowledgeBase,\n systemPrompt,\n appId,\n extraRunConfig,\n clientTools: statewireClientToolWireEntries(clientTools),\n });\n const runConfigKey = JSON.stringify(runConfigValue);\n\n const auiTools = useMemo(() => Tools({ toolkit: frontendToolkit }), [frontendToolkit]);\n // Web client for the shared runtime core (a `use*` name so the\n // rules-of-hooks lint sees the `useAui` call inside a custom hook; the core\n // invokes it unconditionally every render).\n const useSdkClient = (thread: DeepAgentThreadElement) => useAui({ thread, tools: auiTools });\n\n return useDeepAgentRuntime({\n surface: 'AthenaSDK',\n threadId,\n baseUrl: syncUrl,\n // Option closures are re-read per render by the core, so credential\n // rotation (new `token`/`getToken`/`apiKey` props) reaches the next\n // request without remounting the thread. The transport's `staleAuth`\n // (true right after a refused credential) is forwarded as `force`.\n headers: (ctx) => resolveStatewireAuthHeaders({ apiKey, token, getToken }, ctx),\n isNewChat,\n // Queued entries render in the SDK's queue panel, so only the steer lane\n // projects into the message tail.\n laneProjection: 'steer-only',\n // Durable session: a reload resumes the lane and resends whatever the\n // server has not marked durable. Scoped by host AND principal — a thread\n // id is only meaningful against the backend that minted it, and a stored\n // lane must never resend against another signed-in user. (Consumers\n // server-render this SDK; the core's availability probe keeps those\n // sessions process-local, as before the seam existed.) Until the sign-in\n // provider knows who is signed in, the lane is pending: the transport\n // stays parked and nothing is mounted on a stand-in key the session could\n // not move off (`statewireSessionPrincipal`).\n session:\n principal === null\n ? { kind: 'pending' }\n : {\n kind: 'local-storage',\n key: (id) => statewireSessionKey({ syncUrl, principal, threadId: id }),\n },\n snapshotCache,\n // Head interest (see `ATHENA_SDK_MESSAGE_WINDOW`): the tail of the\n // transcript instead of every message; the chat UI's history edge pages\n // older ranges in and fetches cut tool outputs into `toolOutputs`.\n messageWindow,\n toolOutputs,\n // Each `task` card's nested transcript becomes its tool-call part's\n // `messages` (assistant-ui's nested-thread channel), which the subagent\n // card (`SubagentTaskToolUI`) shows.\n createConversionCache: createSubagentTranscriptConversionCache,\n // The lane-cut contract only where the chat pages lanes (see `subagentLaneHistory`).\n laneHistory: subagentLaneHistory,\n capabilities: { edit: true, reload: true, continue: true },\n // The composer stages the draft each send came from right before it\n // sends; the message carries it as its composer markdown, so its bubble\n // shows the text exactly as typed (`UserMessageText`).\n getMessageMetadata: withStagedComposerMarkdown({ threadId }),\n useClient: useSdkClient,\n onStateChange: (state) => {\n // Statewire publishes what the thread renders before its attach snapshot\n // through here too (the placeholder, a remembered snapshot, and a replay\n // boundary's pre-stream default), and on a thread mid-run it reports\n // `connected` before the snapshot applies: only a state the host sent\n // counts, whatever the connection says.\n if (!isDeepAgentHostState(state)) return;\n // The attach's first one ends the attach span (time-to-history).\n const endSpan = attachSpanRef.current;\n if (endSpan) {\n attachSpanRef.current = null;\n endSpan('statewire.snapshot', { data: { thread_id: threadId } });\n }\n onServerState?.(state);\n },\n onConnectionChange: (connection) => {\n athenaDiagnostics.gauge('statewire.connection', connection?.status ?? null);\n if (connection?.status === 'stopped') {\n athenaDiagnostics.emit('statewire.connection', {\n level: 'warn',\n data: {\n status: connection.status,\n reason: connection.reason,\n message: connection.message,\n },\n });\n }\n onConnectionChange?.(connection);\n },\n onRawConnectionChange,\n onRunningChange,\n ...(onCommandChange && { onCommandChange }),\n // Each model-context notification pulls the latest getter through the\n // core's per-render ref; the value-stable key re-registers (and so\n // notifies) only when the built runConfig actually changed. On a thread\n // with a server config lane, agora keeps only the per-send keys of what\n // this carries; `StatewireThreadConfigLaneSync` writes a changed model,\n // system prompt, tool list, workbench or knowledge base to the lane itself.\n runConfig: {\n get: () => runConfigValue,\n key: runConfigKey,\n },\n onError: (error) => {\n if (!isStatewireChannelTeardown(error)) {\n athenaDiagnostics.error(\n 'statewire.error',\n error,\n {\n code: 'statewire_rejected',\n message: 'The statewire host rejected a command',\n hint: 'Inspect error.detail — agora rejections carry a structured {code, message}.',\n },\n { thread_id: threadId },\n );\n }\n if (onError) {\n onError(error);\n return;\n }\n logUnhandledStatewireError('AthenaSDK', error);\n },\n });\n}\n"],"names":["DEEP_AGENT_DEFAULT_MESSAGE_WINDOW","useMemo","collectStatewireClientTools","resolveAgentProp","statewireSessionPrincipal","useContext","AthenaAuthContext","useRef","athenaDiagnostics","buildStatewireRunConfig","statewireClientToolWireEntries","Tools","useAui","useDeepAgentRuntime","resolveStatewireAuthHeaders","statewireSessionKey","createSubagentTranscriptConversionCache","withStagedComposerMarkdown","isDeepAgentHostState","isStatewireChannelTeardown","logUnhandledStatewireError"],"mappings":"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"}
@@ -1,5 +1,5 @@
1
1
  import type { AssistantClient, Toolkit } from '@assistant-ui/react';
2
- import { type DeepAgentMessageWindowDeclaration, type DeepAgentStreamValues, type DeepAgentThreadSnapshotCache, type DeepAgentToolOutputStore, type RegisteredClientTool, type UseDeepAgentThreadOptions } from '@athenaintel/agent-runtime';
2
+ import { type DeepAgentMessageWindowDeclaration, type DeepAgentStreamValues, type DeepAgentThreadSnapshotCache, type DeepAgentToolOutputStore, type RegisteredClientTool, type UseDeepAgentThreadOptions } from '../agent-runtime/src/index';
3
3
  import { type AthenaStatewireTokenGetter } from './statewire-auth-headers';
4
4
  import { DEFAULT_STATEWIRE_MODEL } from './statewire-run-config';
5
5
  export { DEFAULT_STATEWIRE_MODEL };
@@ -38,6 +38,18 @@ export interface AthenaStatewireRuntimeConfig {
38
38
  snapshotCache?: DeepAgentThreadSnapshotCache;
39
39
  /** The head interest stated on the attach (see {@link ATHENA_SDK_MESSAGE_WINDOW}, the default). */
40
40
  messageWindow?: DeepAgentMessageWindowDeclaration;
41
+ /**
42
+ * Whether the chat this runtime serves loads a subagent lane's earlier steps
43
+ * on request, as `AthenaChat`'s subagent card does ("Load earlier steps").
44
+ * When true, its attaches declare the deep-agent lane-cut contract
45
+ * (protocol 2): the host sends a finished subagent's card cut to its newest
46
+ * steps, as it sends a running one, and the card reads the rest. Default
47
+ * `false`, so a chat that does not page lanes declares the default contract
48
+ * and finished lanes arrive whole; a host whose `AthenaChat` renders every
49
+ * `task` call in the subagent card turns it on through `AthenaProvider`'s
50
+ * `subagentLaneHistory`. Read once per attach.
51
+ */
52
+ subagentLaneHistory?: boolean;
41
53
  /**
42
54
  * Full tool outputs fetched back for a windowed wire's cut tool messages;
43
55
  * the thread re-converts when one lands. `AthenaProvider` owns one per
@@ -80,6 +92,8 @@ export interface AthenaStatewireRuntimeConfig {
80
92
  onRawConnectionChange?: UseDeepAgentThreadOptions['onRawConnectionChange'];
81
93
  /** Notified when a run starts/stops. */
82
94
  onRunningChange?: UseDeepAgentThreadOptions['onRunningChange'];
95
+ /** Every statewire command-lifecycle update (the chat outbox lets a handed-over message go on it). */
96
+ onCommandChange?: UseDeepAgentThreadOptions['onCommandChange'];
83
97
  /**
84
98
  * Observes the host's own state: called with the attach snapshot and then on
85
99
  * every later frame (`isDeepAgentHostState`) — never with the placeholder or