@athenaintel/react 0.41.3 → 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 (439) hide show
  1. package/README.md +102 -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.d.ts +60 -0
  48. package/dist/agent-runtime/src/edit-command.d.ts +156 -0
  49. package/dist/agent-runtime/src/errors.d.ts +174 -0
  50. package/dist/agent-runtime/src/execute-output.d.ts +31 -0
  51. package/dist/agent-runtime/src/generated/runconfig-contract.cjs +16 -2
  52. package/dist/agent-runtime/src/generated/runconfig-contract.cjs.map +1 -1
  53. package/dist/agent-runtime/src/generated/runconfig-contract.d.ts +202 -0
  54. package/dist/agent-runtime/src/generated/runconfig-contract.js +16 -2
  55. package/dist/agent-runtime/src/generated/runconfig-contract.js.map +1 -1
  56. package/dist/agent-runtime/src/github-wake-event.d.ts +77 -0
  57. package/dist/agent-runtime/src/index.d.ts +74 -0
  58. package/dist/agent-runtime/src/interrupts.cjs +17 -0
  59. package/dist/agent-runtime/src/interrupts.cjs.map +1 -1
  60. package/dist/agent-runtime/src/interrupts.d.ts +348 -0
  61. package/dist/agent-runtime/src/interrupts.js +17 -0
  62. package/dist/agent-runtime/src/interrupts.js.map +1 -1
  63. package/dist/agent-runtime/src/lane-follow.d.ts +121 -0
  64. package/dist/agent-runtime/src/lane-history.cjs +209 -0
  65. package/dist/agent-runtime/src/lane-history.cjs.map +1 -0
  66. package/dist/agent-runtime/src/lane-history.d.ts +175 -0
  67. package/dist/agent-runtime/src/lane-history.js +209 -0
  68. package/dist/agent-runtime/src/lane-history.js.map +1 -0
  69. package/dist/agent-runtime/src/lane-images.d.ts +184 -0
  70. package/dist/agent-runtime/src/message-author.d.ts +43 -0
  71. package/dist/agent-runtime/src/message-text.cjs +15 -0
  72. package/dist/agent-runtime/src/message-text.cjs.map +1 -0
  73. package/dist/agent-runtime/src/message-text.d.ts +47 -0
  74. package/dist/agent-runtime/src/message-text.js +15 -0
  75. package/dist/agent-runtime/src/message-text.js.map +1 -0
  76. package/dist/agent-runtime/src/message-window.cjs +15 -1
  77. package/dist/agent-runtime/src/message-window.cjs.map +1 -1
  78. package/dist/agent-runtime/src/message-window.d.ts +159 -0
  79. package/dist/agent-runtime/src/message-window.js +16 -2
  80. package/dist/agent-runtime/src/message-window.js.map +1 -1
  81. package/dist/agent-runtime/src/messages.cjs +88 -4
  82. package/dist/agent-runtime/src/messages.cjs.map +1 -1
  83. package/dist/agent-runtime/src/messages.d.ts +603 -0
  84. package/dist/agent-runtime/src/messages.js +88 -4
  85. package/dist/agent-runtime/src/messages.js.map +1 -1
  86. package/dist/agent-runtime/src/model-context.d.ts +22 -0
  87. package/dist/agent-runtime/src/offline-status.d.ts +157 -0
  88. package/dist/agent-runtime/src/optimistic-content.d.ts +21 -0
  89. package/dist/agent-runtime/src/protocol.cjs +12 -4
  90. package/dist/agent-runtime/src/protocol.cjs.map +1 -1
  91. package/dist/agent-runtime/src/protocol.d.ts +119 -0
  92. package/dist/agent-runtime/src/protocol.js +13 -5
  93. package/dist/agent-runtime/src/protocol.js.map +1 -1
  94. package/dist/agent-runtime/src/ptc-subcalls.d.ts +51 -0
  95. package/dist/agent-runtime/src/queue.d.ts +138 -0
  96. package/dist/agent-runtime/src/quota-safe-local-storage-session.d.ts +154 -0
  97. package/dist/agent-runtime/src/running-tool-placeholder.cjs +11 -0
  98. package/dist/agent-runtime/src/running-tool-placeholder.cjs.map +1 -0
  99. package/dist/agent-runtime/src/running-tool-placeholder.d.ts +25 -0
  100. package/dist/agent-runtime/src/running-tool-placeholder.js +11 -0
  101. package/dist/agent-runtime/src/running-tool-placeholder.js.map +1 -0
  102. package/dist/agent-runtime/src/runtime-messages.d.ts +104 -0
  103. package/dist/agent-runtime/src/screen-point.d.ts +151 -0
  104. package/dist/agent-runtime/src/sealed-idb.cjs +112 -0
  105. package/dist/agent-runtime/src/sealed-idb.cjs.map +1 -0
  106. package/dist/agent-runtime/src/sealed-idb.d.ts +106 -0
  107. package/dist/agent-runtime/src/sealed-idb.js +112 -0
  108. package/dist/agent-runtime/src/sealed-idb.js.map +1 -0
  109. package/dist/agent-runtime/src/send-recovery.d.ts +40 -0
  110. package/dist/agent-runtime/src/statewire-attach-observer.d.ts +194 -0
  111. package/dist/agent-runtime/src/statewire-diagnostics.d.ts +74 -0
  112. package/dist/agent-runtime/src/statewire-state.d.ts +29 -0
  113. package/dist/agent-runtime/src/statewire-suspended.cjs.map +1 -1
  114. package/dist/agent-runtime/src/statewire-suspended.d.ts +27 -0
  115. package/dist/agent-runtime/src/statewire-suspended.js.map +1 -1
  116. package/dist/agent-runtime/src/statewire-transport.d.ts +40 -0
  117. package/dist/agent-runtime/src/streaming-markdown.d.ts +46 -0
  118. package/dist/agent-runtime/src/subagent-transcripts.cjs +209 -0
  119. package/dist/agent-runtime/src/subagent-transcripts.cjs.map +1 -0
  120. package/dist/agent-runtime/src/subagent-transcripts.d.ts +71 -0
  121. package/dist/agent-runtime/src/subagent-transcripts.js +209 -0
  122. package/dist/agent-runtime/src/subagent-transcripts.js.map +1 -0
  123. package/dist/agent-runtime/src/subagents.cjs +253 -0
  124. package/dist/agent-runtime/src/subagents.cjs.map +1 -0
  125. package/dist/agent-runtime/src/subagents.d.ts +311 -0
  126. package/dist/agent-runtime/src/subagents.js +253 -0
  127. package/dist/agent-runtime/src/subagents.js.map +1 -0
  128. package/dist/agent-runtime/src/subscription-wake-event.d.ts +111 -0
  129. package/dist/agent-runtime/src/thread-extras.d.ts +43 -0
  130. package/dist/agent-runtime/src/thread-handoff.d.ts +364 -0
  131. package/dist/agent-runtime/src/thread-prewarm-controller.d.ts +76 -0
  132. package/dist/agent-runtime/src/thread-prewarm.d.ts +118 -0
  133. package/dist/agent-runtime/src/thread-snapshot-cache.d.ts +99 -0
  134. package/dist/agent-runtime/src/thread-snapshot-mirror.cjs +46 -117
  135. package/dist/agent-runtime/src/thread-snapshot-mirror.cjs.map +1 -1
  136. package/dist/agent-runtime/src/thread-snapshot-mirror.d.ts +101 -0
  137. package/dist/agent-runtime/src/thread-snapshot-mirror.js +17 -88
  138. package/dist/agent-runtime/src/thread-snapshot-mirror.js.map +1 -1
  139. package/dist/agent-runtime/src/thread-status.d.ts +53 -0
  140. package/dist/agent-runtime/src/tool-metadata.d.ts +146 -0
  141. package/dist/agent-runtime/src/tool-names.cjs +67 -0
  142. package/dist/agent-runtime/src/tool-names.cjs.map +1 -1
  143. package/dist/agent-runtime/src/tool-names.d.ts +60 -0
  144. package/dist/agent-runtime/src/tool-names.js +68 -1
  145. package/dist/agent-runtime/src/tool-names.js.map +1 -1
  146. package/dist/agent-runtime/src/tool-outputs.d.ts +35 -0
  147. package/dist/agent-runtime/src/tool-result.cjs +1 -0
  148. package/dist/agent-runtime/src/tool-result.cjs.map +1 -1
  149. package/dist/agent-runtime/src/tool-result.d.ts +126 -0
  150. package/dist/agent-runtime/src/tool-result.js +1 -0
  151. package/dist/agent-runtime/src/tool-result.js.map +1 -1
  152. package/dist/agent-runtime/src/types.d.ts +159 -0
  153. package/dist/agent-runtime/src/use-conversation-list.d.ts +76 -0
  154. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.cjs +136 -0
  155. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.cjs.map +1 -0
  156. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.d.ts +64 -0
  157. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.js +136 -0
  158. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.js.map +1 -0
  159. package/dist/agent-runtime/src/use-deep-agent-config.d.ts +169 -0
  160. package/dist/agent-runtime/src/use-deep-agent-edit-submit.cjs +13 -0
  161. package/dist/agent-runtime/src/use-deep-agent-edit-submit.cjs.map +1 -1
  162. package/dist/agent-runtime/src/use-deep-agent-edit-submit.d.ts +22 -0
  163. package/dist/agent-runtime/src/use-deep-agent-edit-submit.js +13 -0
  164. package/dist/agent-runtime/src/use-deep-agent-edit-submit.js.map +1 -1
  165. package/dist/agent-runtime/src/use-deep-agent-runtime.cjs +20 -2
  166. package/dist/agent-runtime/src/use-deep-agent-runtime.cjs.map +1 -1
  167. package/dist/agent-runtime/src/use-deep-agent-runtime.d.ts +168 -0
  168. package/dist/agent-runtime/src/use-deep-agent-runtime.js +20 -2
  169. package/dist/agent-runtime/src/use-deep-agent-runtime.js.map +1 -1
  170. package/dist/agent-runtime/src/use-deep-agent-thread.cjs +12 -4
  171. package/dist/agent-runtime/src/use-deep-agent-thread.cjs.map +1 -1
  172. package/dist/agent-runtime/src/use-deep-agent-thread.d.ts +320 -0
  173. package/dist/agent-runtime/src/use-deep-agent-thread.js +12 -4
  174. package/dist/agent-runtime/src/use-deep-agent-thread.js.map +1 -1
  175. package/dist/agent-runtime/src/use-deep-agent-voice.cjs +999 -0
  176. package/dist/agent-runtime/src/use-deep-agent-voice.cjs.map +1 -0
  177. package/dist/agent-runtime/src/use-deep-agent-voice.d.ts +409 -0
  178. package/dist/agent-runtime/src/use-deep-agent-voice.js +999 -0
  179. package/dist/agent-runtime/src/use-deep-agent-voice.js.map +1 -0
  180. package/dist/agent-runtime/src/use-deep-agent-window-sync.d.ts +102 -0
  181. package/dist/agent-runtime/src/use-historical-edit-attachments.d.ts +2 -0
  182. package/dist/agent-runtime/src/use-thread-handoff-flow.d.ts +84 -0
  183. package/dist/agent-runtime/src/voice-presentation.d.ts +80 -0
  184. package/dist/agent-runtime/src/voice-turn-grouping.d.ts +28 -0
  185. package/dist/agent-runtime/src/voice-wire-types.d.ts +15 -0
  186. package/dist/agent-runtime/src/withdrawn-turns.d.ts +97 -0
  187. package/dist/chat/AthenaChat.cjs +72 -5
  188. package/dist/chat/AthenaChat.cjs.map +1 -1
  189. package/dist/chat/AthenaChat.js +73 -6
  190. package/dist/chat/AthenaChat.js.map +1 -1
  191. package/dist/chat/StatewireApprovalCard.d.ts +1 -1
  192. package/dist/chat/StatewireClientToolBridge.d.ts +1 -1
  193. package/dist/chat/StatewireQueuedMessages.cjs +11 -4
  194. package/dist/chat/StatewireQueuedMessages.cjs.map +1 -1
  195. package/dist/chat/StatewireQueuedMessages.d.ts +1 -1
  196. package/dist/chat/StatewireQueuedMessages.js +11 -4
  197. package/dist/chat/StatewireQueuedMessages.js.map +1 -1
  198. package/dist/chat/chat-outbox-rows.cjs +223 -0
  199. package/dist/chat/chat-outbox-rows.cjs.map +1 -0
  200. package/dist/chat/chat-outbox-rows.d.ts +29 -0
  201. package/dist/chat/chat-outbox-rows.js +223 -0
  202. package/dist/chat/chat-outbox-rows.js.map +1 -0
  203. package/dist/chat/statewire-approval.d.ts +1 -1
  204. package/dist/chat/statewire-client-tools.d.ts +1 -1
  205. package/dist/chat/super-grouping/SuperGroupingCard.cjs +3 -1
  206. package/dist/chat/super-grouping/SuperGroupingCard.cjs.map +1 -1
  207. package/dist/chat/super-grouping/SuperGroupingCard.d.ts +7 -1
  208. package/dist/chat/super-grouping/SuperGroupingCard.js +3 -1
  209. package/dist/chat/super-grouping/SuperGroupingCard.js.map +1 -1
  210. package/dist/chat/super-grouping/SuperGroupingTranscript.cjs +7 -2
  211. package/dist/chat/super-grouping/SuperGroupingTranscript.cjs.map +1 -1
  212. package/dist/chat/super-grouping/SuperGroupingTranscript.d.ts +2 -2
  213. package/dist/chat/super-grouping/SuperGroupingTranscript.js +7 -2
  214. package/dist/chat/super-grouping/SuperGroupingTranscript.js.map +1 -1
  215. package/dist/chat/super-grouping/activity-timeline.cjs +15 -8
  216. package/dist/chat/super-grouping/activity-timeline.cjs.map +1 -1
  217. package/dist/chat/super-grouping/activity-timeline.d.ts +18 -8
  218. package/dist/chat/super-grouping/activity-timeline.js +15 -8
  219. package/dist/chat/super-grouping/activity-timeline.js.map +1 -1
  220. package/dist/chat/use-statewire-approval-request.cjs +36 -0
  221. package/dist/chat/use-statewire-approval-request.cjs.map +1 -1
  222. package/dist/chat/use-statewire-approval-request.d.ts +49 -1
  223. package/dist/chat/use-statewire-approval-request.js +39 -3
  224. package/dist/chat/use-statewire-approval-request.js.map +1 -1
  225. package/dist/chat-ui/composer/tiptap-composer.cjs +102 -3
  226. package/dist/chat-ui/composer/tiptap-composer.cjs.map +1 -1
  227. package/dist/chat-ui/composer/tiptap-composer.d.ts +32 -1
  228. package/dist/chat-ui/composer/tiptap-composer.js +103 -4
  229. package/dist/chat-ui/composer/tiptap-composer.js.map +1 -1
  230. package/dist/chat-ui/header/conversation-history-panel.d.ts +1 -1
  231. package/dist/chat-ui/index.d.ts +1 -1
  232. package/dist/chat-ui/messages/message-components.cjs +15 -0
  233. package/dist/chat-ui/messages/message-components.cjs.map +1 -1
  234. package/dist/chat-ui/messages/message-components.js +15 -0
  235. package/dist/chat-ui/messages/message-components.js.map +1 -1
  236. package/dist/chat-ui/messages/runtime-message.d.ts +1 -1
  237. package/dist/chat-ui/messages/statewire-continue-run.d.ts +1 -1
  238. package/dist/chat-ui/messages/user-edit-composer.cjs +15 -2
  239. package/dist/chat-ui/messages/user-edit-composer.cjs.map +1 -1
  240. package/dist/chat-ui/messages/user-edit-composer.d.ts +4 -2
  241. package/dist/chat-ui/messages/user-edit-composer.js +15 -2
  242. package/dist/chat-ui/messages/user-edit-composer.js.map +1 -1
  243. package/dist/chat-ui/messages/wake-marker.d.ts +1 -1
  244. package/dist/chat-ui/rich-text/chat-text-schema.cjs +1 -0
  245. package/dist/chat-ui/rich-text/chat-text-schema.cjs.map +1 -1
  246. package/dist/chat-ui/rich-text/chat-text-schema.d.ts +3 -0
  247. package/dist/chat-ui/rich-text/chat-text-schema.js +1 -0
  248. package/dist/chat-ui/rich-text/chat-text-schema.js.map +1 -1
  249. package/dist/chat-ui/statewire.cjs +1 -0
  250. package/dist/chat-ui/statewire.cjs.map +1 -1
  251. package/dist/chat-ui/statewire.d.ts +2 -2
  252. package/dist/chat-ui/statewire.js +2 -1
  253. package/dist/chat-ui/thread/statewire-history-edge.d.ts +1 -1
  254. package/dist/composer/AttachmentContext.cjs +8 -4
  255. package/dist/composer/AttachmentContext.cjs.map +1 -1
  256. package/dist/composer/AttachmentContext.d.ts +7 -0
  257. package/dist/composer/AttachmentContext.js +8 -4
  258. package/dist/composer/AttachmentContext.js.map +1 -1
  259. package/dist/composer/build-composed-message.cjs +34 -0
  260. package/dist/composer/build-composed-message.cjs.map +1 -1
  261. package/dist/composer/build-composed-message.d.ts +20 -0
  262. package/dist/composer/build-composed-message.js +35 -1
  263. package/dist/composer/build-composed-message.js.map +1 -1
  264. package/dist/composer/composer-handoff.cjs +39 -2
  265. package/dist/composer/composer-handoff.cjs.map +1 -1
  266. package/dist/composer/composer-handoff.d.ts +28 -3
  267. package/dist/composer/composer-handoff.js +39 -2
  268. package/dist/composer/composer-handoff.js.map +1 -1
  269. package/dist/composer/useAttachFiles.cjs +15 -2
  270. package/dist/composer/useAttachFiles.cjs.map +1 -1
  271. package/dist/composer/useAttachFiles.d.ts +11 -0
  272. package/dist/composer/useAttachFiles.js +15 -2
  273. package/dist/composer/useAttachFiles.js.map +1 -1
  274. package/dist/composer/useSendMessage.cjs.map +1 -1
  275. package/dist/composer/useSendMessage.d.ts +4 -3
  276. package/dist/composer/useSendMessage.js.map +1 -1
  277. package/dist/diagnostics/athena-diagnostics.cjs.map +1 -1
  278. package/dist/diagnostics/athena-diagnostics.d.ts +3 -1
  279. package/dist/diagnostics/athena-diagnostics.js.map +1 -1
  280. package/dist/index.cjs +13 -0
  281. package/dist/index.cjs.map +1 -1
  282. package/dist/index.d.ts +13 -6
  283. package/dist/index.js +14 -1
  284. package/dist/index.js.map +1 -1
  285. package/dist/offline/chat-outbox.cjs +57 -0
  286. package/dist/offline/chat-outbox.cjs.map +1 -0
  287. package/dist/offline/chat-outbox.d.ts +80 -0
  288. package/dist/offline/chat-outbox.js +57 -0
  289. package/dist/offline/chat-outbox.js.map +1 -0
  290. package/dist/offline/offline-history.d.ts +1 -1
  291. package/dist/provider/AthenaProvider.cjs +162 -8
  292. package/dist/provider/AthenaProvider.cjs.map +1 -1
  293. package/dist/provider/AthenaProvider.d.ts +15 -1
  294. package/dist/provider/AthenaProvider.js +163 -9
  295. package/dist/provider/AthenaProvider.js.map +1 -1
  296. package/dist/provider/statewire-window-context.d.ts +1 -1
  297. package/dist/react/package.json.cjs +1 -1
  298. package/dist/react/package.json.js +1 -1
  299. package/dist/references/src/anchors/file-line-range.d.ts +58 -0
  300. package/dist/references/src/anchors/format.d.ts +21 -0
  301. package/dist/references/src/anchors/message-anchors.d.ts +71 -0
  302. package/dist/references/src/anchors/parse.d.ts +8 -0
  303. package/dist/references/src/anchors/registry-contract.d.ts +24 -0
  304. package/dist/references/src/anchors/registry.d.ts +19 -0
  305. package/dist/references/src/anchors/schemas.d.ts +194 -0
  306. package/dist/references/src/anchors/serialize.d.ts +8 -0
  307. package/dist/references/src/anchors/time.d.ts +78 -0
  308. package/dist/references/src/anchors/types.d.ts +474 -0
  309. package/dist/references/src/asset-bounds.d.ts +27 -0
  310. package/dist/references/src/asset-links.d.ts +23 -0
  311. package/dist/references/src/asset-reference.d.ts +16 -0
  312. package/dist/references/src/formats/format-catalog.d.ts +79 -0
  313. package/dist/references/src/formats/markdown/parse-reference-markdown.d.ts +28 -0
  314. package/dist/references/src/formats/markdown/reference-display-name.d.ts +6 -0
  315. package/dist/references/src/formats/object/asset-object.d.ts +9 -0
  316. package/dist/references/src/formats/object/callable-object.d.ts +6 -0
  317. package/dist/references/src/formats/object/decode-reference-object-payload.d.ts +3 -0
  318. package/dist/references/src/formats/object/external-url-object.d.ts +9 -0
  319. package/dist/references/src/formats/object/group-object.d.ts +9 -0
  320. package/dist/references/src/formats/object/navigation-object.d.ts +9 -0
  321. package/dist/references/src/formats/object/parse-reference-object.d.ts +11 -0
  322. package/dist/references/src/formats/object/person-object.d.ts +9 -0
  323. package/dist/references/src/formats/uri/asset-mention-uri.d.ts +9 -0
  324. package/dist/references/src/formats/uri/asset-spaces-url.d.ts +9 -0
  325. package/dist/references/src/formats/uri/callable-mention-uris.d.ts +9 -0
  326. package/dist/references/src/formats/uri/detect-uri-wire.d.ts +9 -0
  327. package/dist/references/src/formats/uri/group-mention-uri.d.ts +12 -0
  328. package/dist/references/src/formats/uri/navigation-spaces-url.d.ts +14 -0
  329. package/dist/references/src/formats/uri/parse-reference-uri.d.ts +20 -0
  330. package/dist/references/src/formats/uri/person-mention-uri.d.ts +9 -0
  331. package/dist/references/src/formats/uri/template-placeholder.d.ts +12 -0
  332. package/dist/references/src/index.d.ts +47 -0
  333. package/dist/references/src/legacy/index.d.ts +14 -0
  334. package/dist/references/src/legacy/pre-reference-asset-url.d.ts +57 -0
  335. package/dist/references/src/legacy/pre-reference-citation-bridge.d.ts +22 -0
  336. package/dist/references/src/legacy/pre-reference-citation.d.ts +138 -0
  337. package/dist/references/src/legacy/pre-reference-external-url.d.ts +31 -0
  338. package/dist/references/src/legacy/pre-reference-format.d.ts +8 -0
  339. package/dist/references/src/legacy/pre-reference-mention.d.ts +27 -0
  340. package/dist/references/src/legacy/pre-reference-object.d.ts +8 -0
  341. package/dist/references/src/legacy/pre-reference-uri.d.ts +12 -0
  342. package/dist/references/src/legacy.d.ts +2 -0
  343. package/dist/references/src/mention-href-patterns.d.ts +19 -0
  344. package/dist/references/src/mention-node/index.d.ts +5 -0
  345. package/dist/references/src/mention-node/mention-node.d.ts +31 -0
  346. package/dist/references/src/mention-node/resolve-node-attrs.d.ts +27 -0
  347. package/dist/references/src/parse-reference.d.ts +23 -0
  348. package/dist/references/src/schemas.d.ts +463 -0
  349. package/dist/references/src/serialize-reference.d.ts +50 -0
  350. package/dist/references/src/sheet-name.d.ts +10 -0
  351. package/dist/references/src/tool-option-schemas.d.ts +597 -0
  352. package/dist/references/src/types.d.ts +125 -0
  353. package/dist/references/src/version-ref.d.ts +30 -0
  354. package/dist/runtime/statewire-lifecycle.d.ts +1 -1
  355. package/dist/runtime/statewire-model-lane.d.ts +1 -1
  356. package/dist/runtime/statewire-server-lane-context.d.ts +1 -1
  357. package/dist/runtime/statewire-session-key.cjs +7 -0
  358. package/dist/runtime/statewire-session-key.cjs.map +1 -1
  359. package/dist/runtime/statewire-session-key.d.ts +16 -0
  360. package/dist/runtime/statewire-session-key.js +8 -1
  361. package/dist/runtime/statewire-session-key.js.map +1 -1
  362. package/dist/runtime/statewire-session-lane.cjs +48 -0
  363. package/dist/runtime/statewire-session-lane.cjs.map +1 -0
  364. package/dist/runtime/statewire-session-lane.d.ts +29 -0
  365. package/dist/runtime/statewire-session-lane.js +48 -0
  366. package/dist/runtime/statewire-session-lane.js.map +1 -0
  367. package/dist/runtime/statewire-thread-config-lane.d.ts +1 -1
  368. package/dist/runtime/useAthenaStatewireRuntime.cjs +16 -5
  369. package/dist/runtime/useAthenaStatewireRuntime.cjs.map +1 -1
  370. package/dist/runtime/useAthenaStatewireRuntime.d.ts +15 -1
  371. package/dist/runtime/useAthenaStatewireRuntime.js +17 -6
  372. package/dist/runtime/useAthenaStatewireRuntime.js.map +1 -1
  373. package/dist/styles.css +1 -1
  374. package/dist/threads/api.d.ts +1 -1
  375. package/dist/threads/conversation-list-fetcher.d.ts +1 -1
  376. package/dist/threads/index-triggered-refresh.cjs +164 -0
  377. package/dist/threads/index-triggered-refresh.cjs.map +1 -0
  378. package/dist/threads/index-triggered-refresh.d.ts +70 -0
  379. package/dist/threads/index-triggered-refresh.js +164 -0
  380. package/dist/threads/index-triggered-refresh.js.map +1 -0
  381. package/dist/threads/offline-session-list.d.ts +1 -1
  382. package/dist/threads/pull-request-display.d.ts +1 -1
  383. package/dist/threads/session-list-model.d.ts +1 -1
  384. package/dist/threads/session-list-tab-share.cjs +150 -0
  385. package/dist/threads/session-list-tab-share.cjs.map +1 -0
  386. package/dist/threads/session-list-tab-share.d.ts +73 -0
  387. package/dist/threads/session-list-tab-share.js +150 -0
  388. package/dist/threads/session-list-tab-share.js.map +1 -0
  389. package/dist/threads/session-row-parts.d.ts +1 -1
  390. package/dist/threads/sessions-query.d.ts +1 -1
  391. package/dist/threads/statewire-thread-list.cjs +42 -16
  392. package/dist/threads/statewire-thread-list.cjs.map +1 -1
  393. package/dist/threads/statewire-thread-list.d.ts +11 -2
  394. package/dist/threads/statewire-thread-list.js +43 -17
  395. package/dist/threads/statewire-thread-list.js.map +1 -1
  396. package/dist/threads/thread-prefetcher.d.ts +1 -1
  397. package/dist/threads/use-athena-session-attention.d.ts +1 -1
  398. package/dist/threads/use-athena-sessions.cjs +32 -22
  399. package/dist/threads/use-athena-sessions.cjs.map +1 -1
  400. package/dist/threads/use-athena-sessions.js +33 -23
  401. package/dist/threads/use-athena-sessions.js.map +1 -1
  402. package/dist/threads/use-rest-conversation-history.d.ts +1 -1
  403. package/dist/threads/use-statewire-conversation-history.d.ts +5 -5
  404. package/dist/tiptap-markdown-table/src/markdown-table-serializer.d.ts +56 -0
  405. package/dist/tools/NestedPtcMessages.cjs +14 -9
  406. package/dist/tools/NestedPtcMessages.cjs.map +1 -1
  407. package/dist/tools/NestedPtcMessages.d.ts +9 -0
  408. package/dist/tools/NestedPtcMessages.js +6 -1
  409. package/dist/tools/NestedPtcMessages.js.map +1 -1
  410. package/dist/tools/index.d.ts +1 -1
  411. package/dist/tools/primitives.d.ts +1 -1
  412. package/dist/tools/subagent-task-tool-ui.cjs +494 -0
  413. package/dist/tools/subagent-task-tool-ui.cjs.map +1 -0
  414. package/dist/tools/subagent-task-tool-ui.d.ts +109 -0
  415. package/dist/tools/subagent-task-tool-ui.js +494 -0
  416. package/dist/tools/subagent-task-tool-ui.js.map +1 -0
  417. package/dist/tools/tool-fallback.d.ts +1 -1
  418. package/dist/tools/tool-icons.d.ts +1 -1
  419. package/dist/tools/tool-summary.d.ts +1 -1
  420. package/dist/tools/tool-uis.cjs +4 -0
  421. package/dist/tools/tool-uis.cjs.map +1 -1
  422. package/dist/tools/tool-uis.js +4 -0
  423. package/dist/tools/tool-uis.js.map +1 -1
  424. package/dist/voice/chat.cjs +6 -0
  425. package/dist/voice/chat.cjs.map +1 -0
  426. package/dist/voice/chat.d.ts +2 -0
  427. package/dist/voice/chat.js +6 -0
  428. package/dist/voice/chat.js.map +1 -0
  429. package/dist/voice/livekit-join.cjs +119 -0
  430. package/dist/voice/livekit-join.cjs.map +1 -0
  431. package/dist/voice/livekit-join.d.ts +8 -0
  432. package/dist/voice/livekit-join.js +119 -0
  433. package/dist/voice/livekit-join.js.map +1 -0
  434. package/dist/voice/livekit.cjs +32 -0
  435. package/dist/voice/livekit.cjs.map +1 -0
  436. package/dist/voice/livekit.d.ts +80 -0
  437. package/dist/voice/livekit.js +32 -0
  438. package/dist/voice/livekit.js.map +1 -0
  439. package/package.json +20 -10
@@ -0,0 +1,74 @@
1
+ import type { StatewireClient } from 'statewire';
2
+ /**
3
+ * Allocation-light lifecycle recorder for the deep-agent statewire transport.
4
+ *
5
+ * `useDeepAgentThread` feeds it from the seams it already owns — the raw
6
+ * connection each converter pass, every command-lifecycle update, transport
7
+ * errors, and stale-auth header resolves — and it distills them into a small
8
+ * ring buffer of transition events:
9
+ *
10
+ * - `connection/dialing` · `connection/connected` (with attach latency + attempts)
11
+ * - `connection/retrying` (cause, attempt, lastError) · `connection/gone` · `connection/idle` · `connection/deferred`
12
+ * - `command/settled` (fate: `durable` or the failure fate, with settle latency)
13
+ * - `auth/stale-renewal` (a header resolve forced by a refused credential)
14
+ * - `transport/error`
15
+ *
16
+ * The recorder itself persists nothing: the host passes `onRecord` to mirror
17
+ * entries into its own persistence (Olympus wires it into the persisted
18
+ * diagnostics framework). Hosts should only construct one when their
19
+ * diagnostics channel is enabled — an absent recorder costs a single optional
20
+ * call at each seam. When present, the hot paths (`observeConnection` runs on
21
+ * every converter pass) compare plain fields and allocate only on an actual
22
+ * transition.
23
+ */
24
+ export interface StatewireDiagnosticsEntry {
25
+ /** ms since page navigation start (`performance.now()`), or epoch ms fallback. */
26
+ at: number;
27
+ event: string;
28
+ data?: Record<string, unknown>;
29
+ }
30
+ /** The command-lifecycle fields the recorder reads; structural subset of `Statewire.CommandUpdate`. */
31
+ export interface StatewireDiagnosticsCommandUpdate {
32
+ method: string;
33
+ /** The wire statement's params (a run send carries its message first). */
34
+ params?: readonly unknown[];
35
+ seq: number;
36
+ status: 'queued' | 'posted' | 'applied' | 'settled';
37
+ failure?: {
38
+ fate: string;
39
+ cause?: string;
40
+ code?: string;
41
+ message?: string;
42
+ };
43
+ }
44
+ export interface StatewireDiagnosticsRecorderOptions {
45
+ /** Ring-buffer capacity; oldest entries are overwritten. */
46
+ maxEntries?: number;
47
+ /** Injectable clock (tests). Defaults to `performance.now()`. */
48
+ now?: () => number;
49
+ /** Persistence sink, invoked once per recorded entry (exceptions swallowed). */
50
+ onRecord?: (entry: StatewireDiagnosticsEntry) => void;
51
+ }
52
+ export interface StatewireDiagnosticsRecorder {
53
+ /** Record an arbitrary host event (outbox replays, boundary crashes, …). */
54
+ record(event: string, data?: Record<string, unknown>): void;
55
+ /**
56
+ * Fold a connection into the transition log; call as often as you like —
57
+ * unchanged states are free. Takes the raw statewire connection so any host
58
+ * observer can feed it, and reads it only through
59
+ * `projectDeepAgentConnection` — the one seam over the wire vocabulary.
60
+ */
61
+ observeConnection(connection: StatewireClient.ConnectionState): void;
62
+ /** Fold a command-lifecycle update; records settle fates with latency. */
63
+ observeCommand(update: StatewireDiagnosticsCommandUpdate): void;
64
+ /** Fold a headers resolve; records only stale-auth renewals. */
65
+ observeAuthResolve(ctx: {
66
+ staleAuth: boolean;
67
+ }): void;
68
+ /** Record a transport error surfaced through `onError`. */
69
+ observeError(error: unknown): void;
70
+ /** Entries in arrival order (oldest first). */
71
+ getEntries(): StatewireDiagnosticsEntry[];
72
+ clear(): void;
73
+ }
74
+ export declare function createStatewireDiagnosticsRecorder(options?: StatewireDiagnosticsRecorderOptions): StatewireDiagnosticsRecorder;
@@ -0,0 +1,29 @@
1
+ import type { DeepAgentStreamValues } from './types';
2
+ export declare const DEEP_AGENT_PRE_STREAM_STATE: DeepAgentStreamValues;
3
+ /**
4
+ * Read the deep-agent stream values off a raw statewire state, substituting
5
+ * {@link DEEP_AGENT_PRE_STREAM_STATE} while the state is not an object yet
6
+ * (pre-attach, or a replay boundary republishing `undefined`).
7
+ *
8
+ * Identity-preserving: a hydrated state returns the same object reference it
9
+ * was given and the pre-stream branch always returns the same module constant,
10
+ * so this is safe to call inside `useStatewireState` selectors.
11
+ */
12
+ export declare function readDeepAgentStreamValues(state: unknown): DeepAgentStreamValues;
13
+ /**
14
+ * Whether a state (raw, or already normalized through
15
+ * {@link readDeepAgentStreamValues}) carries a real wire payload. `false`
16
+ * exactly while the pre-stream default stands in — the explicit signal for
17
+ * code that must distinguish "empty thread" from "no snapshot yet".
18
+ */
19
+ export declare function isDeepAgentStateHydrated(state: unknown): boolean;
20
+ /** Record that `threadId`'s attach produced `state` (the converter's output). */
21
+ export declare function pairDeepAgentStateWithThread({ state, threadId, }: {
22
+ state: object;
23
+ threadId: string;
24
+ }): void;
25
+ /**
26
+ * The thread whose attach produced `state`, or `null` for a state no deep-agent
27
+ * converter published (the pre-stream default, a state built elsewhere).
28
+ */
29
+ export declare function readDeepAgentStateThreadId(state: unknown): string | null;
@@ -1 +1 @@
1
- {"version":3,"file":"statewire-suspended.cjs","sources":["../../../../agent-runtime/src/statewire-suspended.ts"],"sourcesContent":["import { resource } from '@assistant-ui/tap';\nimport type { ResourceElement } from '@assistant-ui/tap';\nimport { useRef, useState } from 'react';\nimport type { Statewire, StatewireClient } from 'statewire';\nimport { StatewireSendError } from 'statewire';\n\nexport interface SuspendedStatewireOptions {\n /** Why the transport is parked; surfaced as the connection message. */\n message: string;\n /**\n * Invoked when a surface asks the parked connection to `reconnect()` (the\n * connection indicator's retry affordance). Hosts that park for a reason\n * only they can clear (e.g. the user has no workspace) omit it.\n */\n onReconnectRequested?: (() => void) | undefined;\n}\n\nconst suspendedCommands = <\n TCommands extends Statewire.Commands,\n>(): Statewire.CommandsProxy<TCommands> =>\n new Proxy({} as Statewire.CommandsProxy<TCommands>, {\n get: (_target, method) => {\n if (typeof method !== 'string') return undefined;\n // Settle like a locally-dead channel: hosts already classify\n // non-\"server\" causes as channel teardown (quiet log, no user error).\n return () =>\n Promise.reject(new StatewireSendError({ fate: 'aborted', cause: 'stream-gone' }));\n },\n });\n\nconst useSuspendedStatewire = <TCommands extends Statewire.Commands = Statewire.Commands>(\n options: SuspendedStatewireOptions\n): Statewire<undefined, TCommands> => {\n const latest = useRef(options);\n latest.current = options;\n // `state` stays undefined so the thread keeps serving its `initialState`\n // (the same contract a live transport has before its attach snapshot).\n const [value] = useState((): Statewire<undefined, TCommands> => {\n const connection: StatewireClient.Connection & { readonly message: string } = {\n status: 'standby',\n reason: 'deferred',\n get message() {\n return latest.current.message;\n },\n reconnect: () => latest.current.onReconnectRequested?.(),\n degraded: false,\n };\n return {\n state: undefined,\n commands: suspendedCommands<TCommands>(),\n connection,\n // Context updates while parked are local and must never start a dial.\n // The live transport receives the current snapshot when it replaces us.\n setContext: () => {},\n isBusy: false,\n };\n });\n return value;\n};\n\n/**\n * A statewire transport that never dials.\n *\n * Swapped in for the live WS/SSE transport when attaching is known to be\n * pointless — the host gates it (no workspace) or repeated `unauthorized`\n * denials parked it — so the thread element stays mounted for assistant-ui\n * consumers while the reconnect loop stops entirely.\n */\nexport const StatewireSuspended = resource(useSuspendedStatewire) as <\n TCommands extends Statewire.Commands = Statewire.Commands,\n>(\n options: SuspendedStatewireOptions\n) => ResourceElement<Statewire<undefined, TCommands>>;\n"],"names":["StatewireSendError","useRef","useState","resource"],"mappings":";;;;;AAiBA,MAAM,oBAAoB,MAGxB,IAAI,MAAM,IAA0C;AAAA,EAClD,KAAK,CAAC,SAAS,WAAW;AACxB,QAAI,OAAO,WAAW,SAAU,QAAO;AAGvC,WAAO,MACL,QAAQ,OAAO,IAAIA,UAAAA,mBAAmB,EAAE,MAAM,WAAW,OAAO,cAAA,CAAe,CAAC;AAAA,EACpF;AACF,CAAC;AAEH,MAAM,wBAAwB,CAC5B,YACoC;AACpC,QAAM,SAASC,MAAAA,OAAO,OAAO;AAC7B,SAAO,UAAU;AAGjB,QAAM,CAAC,KAAK,IAAIC,MAAAA,SAAS,MAAuC;AAC9D,UAAM,aAAwE;AAAA,MAC5E,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,IAAI,UAAU;AACZ,eAAO,OAAO,QAAQ;AAAA,MACxB;AAAA,MACA,WAAW,MAAA;;AAAM,kCAAO,SAAQ,yBAAf;AAAA;AAAA,MACjB,UAAU;AAAA,IAAA;AAEZ,WAAO;AAAA,MACL,OAAO;AAAA,MACP,UAAU,kBAAA;AAAA,MACV;AAAA;AAAA;AAAA,MAGA,YAAY,MAAM;AAAA,MAAC;AAAA,MACnB,QAAQ;AAAA,IAAA;AAAA,EAEZ,CAAC;AACD,SAAO;AACT;AAUO,MAAM,qBAAqBC,IAAAA,SAAS,qBAAqB;;"}
1
+ {"version":3,"file":"statewire-suspended.cjs","sources":["../../../../agent-runtime/src/statewire-suspended.ts"],"sourcesContent":["import { resource } from '@assistant-ui/tap';\nimport type { ResourceElement } from '@assistant-ui/tap';\nimport { useRef, useState } from 'react';\nimport type { Statewire, StatewireClient } from 'statewire';\nimport { StatewireSendError } from 'statewire';\n\nexport interface SuspendedStatewireOptions {\n /**\n * Why the transport is parked; surfaced as the connection message. Omitted\n * for a park that is part of normal startup rather than a refusal (a\n * `pending` session lane, whose principal is still loading): the connection\n * then carries no message and reads like a never-started chat, which hosts\n * render as ready rather than paused.\n */\n message?: string | undefined;\n /**\n * Invoked when a surface asks the parked connection to `reconnect()` (the\n * connection indicator's retry affordance). Hosts that park for a reason\n * only they can clear (e.g. the user has no workspace) omit it.\n */\n onReconnectRequested?: (() => void) | undefined;\n}\n\nconst suspendedCommands = <\n TCommands extends Statewire.Commands,\n>(): Statewire.CommandsProxy<TCommands> =>\n new Proxy({} as Statewire.CommandsProxy<TCommands>, {\n get: (_target, method) => {\n if (typeof method !== 'string') return undefined;\n // Settle like a locally-dead channel: hosts already classify\n // non-\"server\" causes as channel teardown (quiet log, no user error).\n return () =>\n Promise.reject(new StatewireSendError({ fate: 'aborted', cause: 'stream-gone' }));\n },\n });\n\nconst useSuspendedStatewire = <TCommands extends Statewire.Commands = Statewire.Commands>(\n options: SuspendedStatewireOptions\n): Statewire<undefined, TCommands> => {\n const latest = useRef(options);\n latest.current = options;\n // `state` stays undefined so the thread keeps serving its `initialState`\n // (the same contract a live transport has before its attach snapshot).\n const [value] = useState((): Statewire<undefined, TCommands> => {\n const connection: StatewireClient.Connection & { readonly message: string | undefined } = {\n status: 'standby',\n reason: 'deferred',\n get message() {\n return latest.current.message;\n },\n reconnect: () => latest.current.onReconnectRequested?.(),\n degraded: false,\n };\n return {\n state: undefined,\n commands: suspendedCommands<TCommands>(),\n connection,\n // Context updates while parked are local and must never start a dial.\n // The live transport receives the current snapshot when it replaces us.\n setContext: () => {},\n isBusy: false,\n };\n });\n return value;\n};\n\n/**\n * A statewire transport that never dials.\n *\n * Swapped in for the live WS/SSE transport when attaching is known to be\n * pointless — the host gates it (no workspace) or repeated `unauthorized`\n * denials parked it — so the thread element stays mounted for assistant-ui\n * consumers while the reconnect loop stops entirely.\n */\nexport const StatewireSuspended = resource(useSuspendedStatewire) as <\n TCommands extends Statewire.Commands = Statewire.Commands,\n>(\n options: SuspendedStatewireOptions\n) => ResourceElement<Statewire<undefined, TCommands>>;\n"],"names":["StatewireSendError","useRef","useState","resource"],"mappings":";;;;;AAuBA,MAAM,oBAAoB,MAGxB,IAAI,MAAM,IAA0C;AAAA,EAClD,KAAK,CAAC,SAAS,WAAW;AACxB,QAAI,OAAO,WAAW,SAAU,QAAO;AAGvC,WAAO,MACL,QAAQ,OAAO,IAAIA,UAAAA,mBAAmB,EAAE,MAAM,WAAW,OAAO,cAAA,CAAe,CAAC;AAAA,EACpF;AACF,CAAC;AAEH,MAAM,wBAAwB,CAC5B,YACoC;AACpC,QAAM,SAASC,MAAAA,OAAO,OAAO;AAC7B,SAAO,UAAU;AAGjB,QAAM,CAAC,KAAK,IAAIC,MAAAA,SAAS,MAAuC;AAC9D,UAAM,aAAoF;AAAA,MACxF,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,IAAI,UAAU;AACZ,eAAO,OAAO,QAAQ;AAAA,MACxB;AAAA,MACA,WAAW,MAAA;;AAAM,kCAAO,SAAQ,yBAAf;AAAA;AAAA,MACjB,UAAU;AAAA,IAAA;AAEZ,WAAO;AAAA,MACL,OAAO;AAAA,MACP,UAAU,kBAAA;AAAA,MACV;AAAA;AAAA;AAAA,MAGA,YAAY,MAAM;AAAA,MAAC;AAAA,MACnB,QAAQ;AAAA,IAAA;AAAA,EAEZ,CAAC;AACD,SAAO;AACT;AAUO,MAAM,qBAAqBC,IAAAA,SAAS,qBAAqB;;"}
@@ -0,0 +1,27 @@
1
+ import type { ResourceElement } from '@assistant-ui/tap';
2
+ import type { Statewire } from 'statewire';
3
+ export interface SuspendedStatewireOptions {
4
+ /**
5
+ * Why the transport is parked; surfaced as the connection message. Omitted
6
+ * for a park that is part of normal startup rather than a refusal (a
7
+ * `pending` session lane, whose principal is still loading): the connection
8
+ * then carries no message and reads like a never-started chat, which hosts
9
+ * render as ready rather than paused.
10
+ */
11
+ message?: string | undefined;
12
+ /**
13
+ * Invoked when a surface asks the parked connection to `reconnect()` (the
14
+ * connection indicator's retry affordance). Hosts that park for a reason
15
+ * only they can clear (e.g. the user has no workspace) omit it.
16
+ */
17
+ onReconnectRequested?: (() => void) | undefined;
18
+ }
19
+ /**
20
+ * A statewire transport that never dials.
21
+ *
22
+ * Swapped in for the live WS/SSE transport when attaching is known to be
23
+ * pointless — the host gates it (no workspace) or repeated `unauthorized`
24
+ * denials parked it — so the thread element stays mounted for assistant-ui
25
+ * consumers while the reconnect loop stops entirely.
26
+ */
27
+ export declare const StatewireSuspended: <TCommands extends Statewire.Commands = Statewire.Commands>(options: SuspendedStatewireOptions) => ResourceElement<Statewire<undefined, TCommands>>;
@@ -1 +1 @@
1
- {"version":3,"file":"statewire-suspended.js","sources":["../../../../agent-runtime/src/statewire-suspended.ts"],"sourcesContent":["import { resource } from '@assistant-ui/tap';\nimport type { ResourceElement } from '@assistant-ui/tap';\nimport { useRef, useState } from 'react';\nimport type { Statewire, StatewireClient } from 'statewire';\nimport { StatewireSendError } from 'statewire';\n\nexport interface SuspendedStatewireOptions {\n /** Why the transport is parked; surfaced as the connection message. */\n message: string;\n /**\n * Invoked when a surface asks the parked connection to `reconnect()` (the\n * connection indicator's retry affordance). Hosts that park for a reason\n * only they can clear (e.g. the user has no workspace) omit it.\n */\n onReconnectRequested?: (() => void) | undefined;\n}\n\nconst suspendedCommands = <\n TCommands extends Statewire.Commands,\n>(): Statewire.CommandsProxy<TCommands> =>\n new Proxy({} as Statewire.CommandsProxy<TCommands>, {\n get: (_target, method) => {\n if (typeof method !== 'string') return undefined;\n // Settle like a locally-dead channel: hosts already classify\n // non-\"server\" causes as channel teardown (quiet log, no user error).\n return () =>\n Promise.reject(new StatewireSendError({ fate: 'aborted', cause: 'stream-gone' }));\n },\n });\n\nconst useSuspendedStatewire = <TCommands extends Statewire.Commands = Statewire.Commands>(\n options: SuspendedStatewireOptions\n): Statewire<undefined, TCommands> => {\n const latest = useRef(options);\n latest.current = options;\n // `state` stays undefined so the thread keeps serving its `initialState`\n // (the same contract a live transport has before its attach snapshot).\n const [value] = useState((): Statewire<undefined, TCommands> => {\n const connection: StatewireClient.Connection & { readonly message: string } = {\n status: 'standby',\n reason: 'deferred',\n get message() {\n return latest.current.message;\n },\n reconnect: () => latest.current.onReconnectRequested?.(),\n degraded: false,\n };\n return {\n state: undefined,\n commands: suspendedCommands<TCommands>(),\n connection,\n // Context updates while parked are local and must never start a dial.\n // The live transport receives the current snapshot when it replaces us.\n setContext: () => {},\n isBusy: false,\n };\n });\n return value;\n};\n\n/**\n * A statewire transport that never dials.\n *\n * Swapped in for the live WS/SSE transport when attaching is known to be\n * pointless — the host gates it (no workspace) or repeated `unauthorized`\n * denials parked it — so the thread element stays mounted for assistant-ui\n * consumers while the reconnect loop stops entirely.\n */\nexport const StatewireSuspended = resource(useSuspendedStatewire) as <\n TCommands extends Statewire.Commands = Statewire.Commands,\n>(\n options: SuspendedStatewireOptions\n) => ResourceElement<Statewire<undefined, TCommands>>;\n"],"names":[],"mappings":";;;AAiBA,MAAM,oBAAoB,MAGxB,IAAI,MAAM,IAA0C;AAAA,EAClD,KAAK,CAAC,SAAS,WAAW;AACxB,QAAI,OAAO,WAAW,SAAU,QAAO;AAGvC,WAAO,MACL,QAAQ,OAAO,IAAI,mBAAmB,EAAE,MAAM,WAAW,OAAO,cAAA,CAAe,CAAC;AAAA,EACpF;AACF,CAAC;AAEH,MAAM,wBAAwB,CAC5B,YACoC;AACpC,QAAM,SAAS,OAAO,OAAO;AAC7B,SAAO,UAAU;AAGjB,QAAM,CAAC,KAAK,IAAI,SAAS,MAAuC;AAC9D,UAAM,aAAwE;AAAA,MAC5E,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,IAAI,UAAU;AACZ,eAAO,OAAO,QAAQ;AAAA,MACxB;AAAA,MACA,WAAW,MAAA;;AAAM,kCAAO,SAAQ,yBAAf;AAAA;AAAA,MACjB,UAAU;AAAA,IAAA;AAEZ,WAAO;AAAA,MACL,OAAO;AAAA,MACP,UAAU,kBAAA;AAAA,MACV;AAAA;AAAA;AAAA,MAGA,YAAY,MAAM;AAAA,MAAC;AAAA,MACnB,QAAQ;AAAA,IAAA;AAAA,EAEZ,CAAC;AACD,SAAO;AACT;AAUO,MAAM,qBAAqB,SAAS,qBAAqB;"}
1
+ {"version":3,"file":"statewire-suspended.js","sources":["../../../../agent-runtime/src/statewire-suspended.ts"],"sourcesContent":["import { resource } from '@assistant-ui/tap';\nimport type { ResourceElement } from '@assistant-ui/tap';\nimport { useRef, useState } from 'react';\nimport type { Statewire, StatewireClient } from 'statewire';\nimport { StatewireSendError } from 'statewire';\n\nexport interface SuspendedStatewireOptions {\n /**\n * Why the transport is parked; surfaced as the connection message. Omitted\n * for a park that is part of normal startup rather than a refusal (a\n * `pending` session lane, whose principal is still loading): the connection\n * then carries no message and reads like a never-started chat, which hosts\n * render as ready rather than paused.\n */\n message?: string | undefined;\n /**\n * Invoked when a surface asks the parked connection to `reconnect()` (the\n * connection indicator's retry affordance). Hosts that park for a reason\n * only they can clear (e.g. the user has no workspace) omit it.\n */\n onReconnectRequested?: (() => void) | undefined;\n}\n\nconst suspendedCommands = <\n TCommands extends Statewire.Commands,\n>(): Statewire.CommandsProxy<TCommands> =>\n new Proxy({} as Statewire.CommandsProxy<TCommands>, {\n get: (_target, method) => {\n if (typeof method !== 'string') return undefined;\n // Settle like a locally-dead channel: hosts already classify\n // non-\"server\" causes as channel teardown (quiet log, no user error).\n return () =>\n Promise.reject(new StatewireSendError({ fate: 'aborted', cause: 'stream-gone' }));\n },\n });\n\nconst useSuspendedStatewire = <TCommands extends Statewire.Commands = Statewire.Commands>(\n options: SuspendedStatewireOptions\n): Statewire<undefined, TCommands> => {\n const latest = useRef(options);\n latest.current = options;\n // `state` stays undefined so the thread keeps serving its `initialState`\n // (the same contract a live transport has before its attach snapshot).\n const [value] = useState((): Statewire<undefined, TCommands> => {\n const connection: StatewireClient.Connection & { readonly message: string | undefined } = {\n status: 'standby',\n reason: 'deferred',\n get message() {\n return latest.current.message;\n },\n reconnect: () => latest.current.onReconnectRequested?.(),\n degraded: false,\n };\n return {\n state: undefined,\n commands: suspendedCommands<TCommands>(),\n connection,\n // Context updates while parked are local and must never start a dial.\n // The live transport receives the current snapshot when it replaces us.\n setContext: () => {},\n isBusy: false,\n };\n });\n return value;\n};\n\n/**\n * A statewire transport that never dials.\n *\n * Swapped in for the live WS/SSE transport when attaching is known to be\n * pointless — the host gates it (no workspace) or repeated `unauthorized`\n * denials parked it — so the thread element stays mounted for assistant-ui\n * consumers while the reconnect loop stops entirely.\n */\nexport const StatewireSuspended = resource(useSuspendedStatewire) as <\n TCommands extends Statewire.Commands = Statewire.Commands,\n>(\n options: SuspendedStatewireOptions\n) => ResourceElement<Statewire<undefined, TCommands>>;\n"],"names":[],"mappings":";;;AAuBA,MAAM,oBAAoB,MAGxB,IAAI,MAAM,IAA0C;AAAA,EAClD,KAAK,CAAC,SAAS,WAAW;AACxB,QAAI,OAAO,WAAW,SAAU,QAAO;AAGvC,WAAO,MACL,QAAQ,OAAO,IAAI,mBAAmB,EAAE,MAAM,WAAW,OAAO,cAAA,CAAe,CAAC;AAAA,EACpF;AACF,CAAC;AAEH,MAAM,wBAAwB,CAC5B,YACoC;AACpC,QAAM,SAAS,OAAO,OAAO;AAC7B,SAAO,UAAU;AAGjB,QAAM,CAAC,KAAK,IAAI,SAAS,MAAuC;AAC9D,UAAM,aAAoF;AAAA,MACxF,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,IAAI,UAAU;AACZ,eAAO,OAAO,QAAQ;AAAA,MACxB;AAAA,MACA,WAAW,MAAA;;AAAM,kCAAO,SAAQ,yBAAf;AAAA;AAAA,MACjB,UAAU;AAAA,IAAA;AAEZ,WAAO;AAAA,MACL,OAAO;AAAA,MACP,UAAU,kBAAA;AAAA,MACV;AAAA;AAAA;AAAA,MAGA,YAAY,MAAM;AAAA,MAAC;AAAA,MACnB,QAAQ;AAAA,IAAA;AAAA,EAEZ,CAAC;AACD,SAAO;AACT;AAUO,MAAM,qBAAqB,SAAS,qBAAqB;"}
@@ -0,0 +1,40 @@
1
+ import { type Statewire, type StatewireClient } from 'statewire';
2
+ import type { DeepAgentStreamValues } from './types';
3
+ export type StatewireTransportOptions = StatewireClient.HttpOptions & StatewireClient.WebsocketOptions;
4
+ /**
5
+ * The application protocol the deep-agent transport stamps on every command.
6
+ * The thread client must declare the same protocol: statewire's core applies
7
+ * its optimistic folds only to commands of its own protocol, so a mismatch
8
+ * leaves a send invisible until the server's frame lands.
9
+ */
10
+ export declare const DEEP_AGENT_STATEWIRE_PROTOCOL = "athena";
11
+ /** Durable Athena commands keep their schema version across wire upgrades. */
12
+ export declare const DEEP_AGENT_STATEWIRE_PROTOCOL_VERSION = "2026-09-13";
13
+ /**
14
+ * The wire contract every deep-agent transport offers. Athena's hosts (Python
15
+ * statewire 0.20) speak 2026-09-30 natively, so no legacy context range is
16
+ * advertised.
17
+ */
18
+ export declare const DEEP_AGENT_STATEWIRE_WIRE_VERSION: NonNullable<StatewireTransportOptions['wireVersion']>;
19
+ export type StatewireTransportKind = 'sse' | 'websocket';
20
+ /**
21
+ * The transport a host gets: SSE when it asks for SSE, WebSocket otherwise.
22
+ * Whatever instruments the transport must read this too, so it matches the
23
+ * transport actually built.
24
+ */
25
+ export declare function resolveStatewireTransportKind({ sse }: {
26
+ sse: boolean;
27
+ }): StatewireTransportKind;
28
+ /**
29
+ * Build the deep-agent statewire transport: WebSocket by default, SSE when the
30
+ * host app's toggle asks for it ({@link resolveStatewireTransportKind}). The
31
+ * toggle source is host-specific (env var, extension flag, config store), so
32
+ * the caller resolves it to a boolean.
33
+ *
34
+ * `TState` defaults to the deep-agent wire shape: the thread mounts that make
35
+ * up nearly every caller get a typed state without naming it, and the other
36
+ * mounts (the conversation index) name theirs.
37
+ */
38
+ export declare const statewireTransport: <TState = DeepAgentStreamValues, TCommands extends Statewire.Commands = Statewire.Commands>(options: StatewireTransportOptions, { sse }?: {
39
+ sse?: boolean;
40
+ }) => import("@assistant-ui/tap").ResourceElement<Statewire<TState | undefined, TCommands>>;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Hide a markdown link the stream has not finished writing.
3
+ *
4
+ * The agent mentions and cites assets as markdown links —
5
+ * `[@Considerations/Notes](https://…/dashboard/spaces/?asset_ids=asset_…&type=document&anchor=pm_node&node_id=…&excerpt=…)`
6
+ * — which every chat surface renders as a mention chip once the link is
7
+ * complete. While it is still arriving, a markdown parser sees a bracketed
8
+ * label followed by a bare URL: the label shows as raw text and the half URL
9
+ * linkifies into a live link whose target changes with every batch, for as
10
+ * long as the destination takes to stream (an `excerpt` parameter can run to
11
+ * hundreds of characters). Then the closing `)` lands and the run is rebuilt
12
+ * as a chip.
13
+ *
14
+ * While a part is streaming, cut the text at the start of a trailing link
15
+ * whose `)` has not arrived; it reappears whole, as a chip, in the batch that
16
+ * closes it. Every link and image destination is held — a web citation
17
+ * flickers the same way — and so is every bracket still undecided on the
18
+ * line: an unfinished `[label`, and a closed `[label]` at the very end of the
19
+ * text, which waits one batch for its `(`. Holding the label too is what
20
+ * makes the visible text only ever grow — a link never shows as a label and
21
+ * then retracts when its destination starts — and that append-only property
22
+ * is what keeps Olympus's incremental streaming apply on its cheap path.
23
+ * Brackets match innermost-first, as CommonMark does, and the hold starts at
24
+ * the outermost undecided bracket the size bound allows, so an unmatched
25
+ * bracket in prose hides at most a phrase, briefly, and never masks a later
26
+ * mention. A construct that crosses a line break or runs past its bound is
27
+ * released so a malformed link cannot hide the rest of the message; fenced
28
+ * code (including fences inside blockquotes), indented code and inline code
29
+ * are left untouched; and settled text is never passed through this
30
+ * function, so a link the model genuinely left open shows raw once the part
31
+ * completes.
32
+ *
33
+ * Shared by every chat surface (Olympus, the React SDK hosts, mobile) so the
34
+ * hold behaves identically wherever a transcript streams. Pure string work,
35
+ * linear in the text.
36
+ */
37
+ /** An open bracket further back than this is prose, not a label being streamed. */
38
+ export declare const UNTERMINATED_LABEL_HOLD_LIMIT = 200;
39
+ /** A link (label and destination) longer than this is broken, not streaming. */
40
+ export declare const UNTERMINATED_LINK_HOLD_LIMIT = 1500;
41
+ /**
42
+ * The streamed text with a trailing, still-undecided markdown link or image
43
+ * removed. Text without such a construct is returned as is, and the result is
44
+ * always a prefix of `text`.
45
+ */
46
+ export declare function hideUnterminatedMarkdownLink(text: string): string;
@@ -0,0 +1,209 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const react = require("@assistant-ui/core/react");
4
+ const runconfigContract = require("./generated/runconfig-contract.cjs");
5
+ const messageText = require("./message-text.cjs");
6
+ const messages = require("./messages.cjs");
7
+ const toolNames = require("./tool-names.cjs");
8
+ function laneTranscriptOf(artifact) {
9
+ if (typeof artifact !== "object" || artifact === null) return void 0;
10
+ const state = artifact.subgraph_state;
11
+ if (typeof state !== "object" || state === null) return void 0;
12
+ const messages2 = state.messages;
13
+ return Array.isArray(messages2) ? messages2 : void 0;
14
+ }
15
+ const restoredTranscripts = /* @__PURE__ */ new WeakMap();
16
+ function withRepeatedResult(transcript, content) {
17
+ const last = transcript[transcript.length - 1];
18
+ if (last === void 0 || last[runconfigContract.DEEP_AGENT_REPEATS_RESULT_KEY] !== true || typeof content !== "string" && !Array.isArray(content)) {
19
+ return transcript;
20
+ }
21
+ const cached = restoredTranscripts.get(transcript);
22
+ if (cached !== void 0 && cached.content === content) return cached.transcript;
23
+ const restored = [...transcript.slice(0, -1), { ...last, content }];
24
+ restoredTranscripts.set(transcript, { content, transcript: restored });
25
+ return restored;
26
+ }
27
+ const convertibleChunkTurns = /* @__PURE__ */ new WeakMap();
28
+ function asConvertibleTurn(message) {
29
+ const type = message.type;
30
+ if (type !== "AIMessageChunk") return message;
31
+ const cached = convertibleChunkTurns.get(message);
32
+ if (cached !== void 0) return cached;
33
+ const turn = { ...message, type: "ai" };
34
+ convertibleChunkTurns.set(message, turn);
35
+ return turn;
36
+ }
37
+ function answeringTurn(step) {
38
+ var _a;
39
+ const turn = asConvertibleTurn(step);
40
+ return turn.type === "ai" && (((_a = turn.tool_calls) == null ? void 0 : _a.length) ?? 0) === 0 ? turn : null;
41
+ }
42
+ const isTextBlock = (block) => typeof block === "object" && block !== null && "type" in block && block.type === "text";
43
+ function shownText(content) {
44
+ if (typeof content === "string") return content;
45
+ if (!Array.isArray(content)) return "";
46
+ let text = "";
47
+ for (const block of content) {
48
+ if (isTextBlock(block) && typeof block.text === "string") text += block.text;
49
+ }
50
+ return text;
51
+ }
52
+ function blankTurn(step) {
53
+ const turn = answeringTurn(step);
54
+ if (turn === null || shownText(turn.content).trim() !== "") return null;
55
+ return typeof turn.content === "string" || turn.content.every(isTextBlock) ? turn : null;
56
+ }
57
+ const reportedLanes = /* @__PURE__ */ new WeakMap();
58
+ function withLaneReport(transcript, report) {
59
+ if (report === void 0 || report.trim() === "" || transcript.length === 0) return transcript;
60
+ let at = transcript.length - 1;
61
+ let closing = transcript[at];
62
+ while (closing !== void 0 && blankTurn(closing) !== null) {
63
+ at -= 1;
64
+ closing = transcript[at];
65
+ }
66
+ const answered = closing !== void 0 && answeringTurn(closing) !== null && shownText(closing.content).trim() !== "";
67
+ if (answered) return transcript;
68
+ const cached = reportedLanes.get(transcript);
69
+ if (cached !== void 0 && cached.report === report) return cached.transcript;
70
+ const last = transcript[transcript.length - 1];
71
+ const blank = last === void 0 ? null : blankTurn(last);
72
+ const closed = blank !== null ? [...transcript.slice(0, -1), { ...blank, content: report }] : [...transcript, { id: `${(last == null ? void 0 : last.id) ?? "lane"}:report`, type: "ai", content: report }];
73
+ reportedLanes.set(transcript, { report, transcript: closed });
74
+ return closed;
75
+ }
76
+ function transcriptSources(transcript) {
77
+ return messages.sanitizeLangChainMessages(transcript.map(asConvertibleTurn));
78
+ }
79
+ const reportedTranscripts = /* @__PURE__ */ new WeakSet();
80
+ function reportUnconvertibleTranscript(transcript, error) {
81
+ if (reportedTranscripts.has(transcript)) return;
82
+ reportedTranscripts.add(transcript);
83
+ console.warn("[agent-runtime] a subagent transcript could not be converted", error);
84
+ }
85
+ function sameJson(a, b) {
86
+ if (Object.is(a, b)) return true;
87
+ if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) return false;
88
+ if (Array.isArray(a) || Array.isArray(b)) {
89
+ return Array.isArray(a) && Array.isArray(b) && a.length === b.length && a.every((item, index) => sameJson(item, b[index]));
90
+ }
91
+ const left = a;
92
+ const right = b;
93
+ const keys = Object.keys(left);
94
+ return keys.length === Object.keys(right).length && keys.every(
95
+ (key) => Object.prototype.hasOwnProperty.call(right, key) && sameJson(left[key], right[key])
96
+ );
97
+ }
98
+ function steadyStepObjects() {
99
+ let held = /* @__PURE__ */ new Map();
100
+ return (transcript) => {
101
+ const next = /* @__PURE__ */ new Map();
102
+ let kept = false;
103
+ const steadied = transcript.map((entry) => {
104
+ const id = entry.id;
105
+ if (typeof id !== "string") return entry;
106
+ const before = held.get(id);
107
+ const step = before !== void 0 && sameJson(before, entry) ? before : entry;
108
+ next.set(id, step);
109
+ if (step !== entry) kept = true;
110
+ return step;
111
+ });
112
+ held = next;
113
+ return kept ? steadied : transcript;
114
+ };
115
+ }
116
+ function createSubagentLaneConversion() {
117
+ const memory = createSubagentTranscriptConversionCache();
118
+ const steady = steadyStepObjects();
119
+ let last = null;
120
+ return (transcript, running) => {
121
+ if (last !== null && last.transcript === transcript && last.running === running) {
122
+ return last.messages;
123
+ }
124
+ let messages2;
125
+ try {
126
+ messages2 = memory.convert(transcriptSources(steady(transcript)), running);
127
+ } catch (error) {
128
+ reportUnconvertibleTranscript(transcript, error);
129
+ }
130
+ last = { transcript, running, messages: messages2 };
131
+ return messages2;
132
+ };
133
+ }
134
+ function subagentTranscriptAttacher() {
135
+ const lanes = /* @__PURE__ */ new Map();
136
+ const attachedRows = /* @__PURE__ */ new WeakMap();
137
+ const attachedParts = /* @__PURE__ */ new WeakMap();
138
+ const laneMessages = (toolCallId, transcript, running) => {
139
+ let lane = lanes.get(toolCallId);
140
+ if (lane === void 0) {
141
+ lane = createSubagentLaneConversion();
142
+ lanes.set(toolCallId, lane);
143
+ }
144
+ return lane(transcript, running);
145
+ };
146
+ const attach = (row) => {
147
+ if (row.role !== "assistant") return row;
148
+ const cached = attachedRows.get(row);
149
+ if (cached !== void 0) return cached;
150
+ let content = null;
151
+ for (const [index, part] of row.content.entries()) {
152
+ if (part.type !== "tool-call" || part.toolName !== toolNames.TASK_TOOL_NAME) continue;
153
+ const nested = laneTranscriptOf(part.artifact);
154
+ if (nested === void 0) continue;
155
+ const running = part.isPreliminary === true;
156
+ const restored = withRepeatedResult(nested, part.result);
157
+ const transcript = running || part.isError === true ? restored : withLaneReport(restored, messageText.getMessageText({ content: part.result }));
158
+ const messages2 = laneMessages(part.toolCallId, transcript, running);
159
+ if (messages2 === void 0) continue;
160
+ const kept = attachedParts.get(part);
161
+ const attached = kept !== void 0 && kept.messages === messages2 ? kept.part : { ...part, messages: messages2 };
162
+ attachedParts.set(part, { messages: messages2, part: attached });
163
+ content ?? (content = [...row.content]);
164
+ content[index] = attached;
165
+ }
166
+ const attachedRow = content === null ? row : { ...row, content };
167
+ attachedRows.set(row, attachedRow);
168
+ return attachedRow;
169
+ };
170
+ return (rows) => {
171
+ const attached = rows.map(attach);
172
+ if (lanes.size === 0) return attached;
173
+ const held = /* @__PURE__ */ new Set();
174
+ for (const row of rows) {
175
+ if (row.role !== "assistant") continue;
176
+ for (const part of row.content) {
177
+ if (part.type !== "tool-call" || part.toolName !== toolNames.TASK_TOOL_NAME) continue;
178
+ held.add(part.toolCallId);
179
+ }
180
+ }
181
+ for (const toolCallId of lanes.keys()) {
182
+ if (!held.has(toolCallId)) lanes.delete(toolCallId);
183
+ }
184
+ return attached;
185
+ };
186
+ }
187
+ function createSubagentTranscriptConversionCache() {
188
+ const thread = messages.createDeepAgentMessageConversionCache();
189
+ const attach = subagentTranscriptAttacher();
190
+ let previousRows = null;
191
+ let previous = [];
192
+ return {
193
+ convert(messages2, isRunning) {
194
+ const rows = thread.convert(messages2, isRunning);
195
+ if (rows === previousRows) return previous;
196
+ previousRows = rows;
197
+ const next = attach(rows);
198
+ const unchanged = next.length === previous.length && next.every((row, index) => row === previous[index]);
199
+ if (!unchanged) previous = next;
200
+ return previous;
201
+ }
202
+ };
203
+ }
204
+ react.createExternalMessageConversionCache();
205
+ exports.createSubagentLaneConversion = createSubagentLaneConversion;
206
+ exports.createSubagentTranscriptConversionCache = createSubagentTranscriptConversionCache;
207
+ exports.withLaneReport = withLaneReport;
208
+ exports.withRepeatedResult = withRepeatedResult;
209
+ //# sourceMappingURL=subagent-transcripts.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subagent-transcripts.cjs","sources":["../../../../agent-runtime/src/subagent-transcripts.ts"],"sourcesContent":["/**\n * A subagent's transcript as assistant-ui's native nested thread.\n *\n * The backend nests a `task` subagent's transcript in its card's ToolMessage,\n * at `artifact.subgraph_state.messages`: the newest steps on the running\n * placeholder, the whole transcript on the real result. The conversion cache\n * built here converts that transcript through the thread's own pipeline and\n * sets it as the `task` tool-call part's `messages`, assistant-ui's channel for\n * a tool call's nested conversation. `ReadonlyThreadProvider` (the provider\n * under `MessagePartPrimitive.Messages`) renders it as a read-only thread under\n * the parent's tool UIs, and `thread.tasks` derives child work from it.\n *\n * Hosts opt in (`useDeepAgentThread({ createConversionCache })`). It builds on\n * the shared conversion memory from outside, so the shared converter, which\n * ships in every surface's startup bundle (the Office pane's startup and total\n * budgets have no room to spare), stays as it is, and a surface that draws no\n * subagent transcript pays nothing for it.\n */\nimport type {\n ThreadAssistantMessagePart,\n ThreadMessage,\n ToolCallMessagePart,\n} from '@assistant-ui/core';\nimport {\n convertExternalMessages,\n createExternalMessageConversionCache,\n} from '@assistant-ui/core/react';\nimport type { LangChainMessage } from '@assistant-ui/react-langgraph';\nimport { DEEP_AGENT_REPEATS_RESULT_KEY } from './generated/runconfig-contract';\nimport { getMessageText } from './message-text';\nimport {\n convertDeepAgentLangChainMessage,\n createDeepAgentMessageConversionCache,\n type DeepAgentConversionMemory,\n markPreliminaryToolResults,\n sanitizeLangChainMessages,\n} from './messages';\nimport { TASK_TOOL_NAME } from './tool-names';\n\n/** The transcript nested on a `task` card's artifact, or `undefined` when it carries none. */\nfunction laneTranscriptOf(artifact: unknown): readonly LangChainMessage[] | undefined {\n if (typeof artifact !== 'object' || artifact === null) return undefined;\n const state: unknown = (artifact as { subgraph_state?: unknown }).subgraph_state;\n if (typeof state !== 'object' || state === null) return undefined;\n const messages: unknown = (state as { messages?: unknown }).messages;\n return Array.isArray(messages) ? (messages as LangChainMessage[]) : undefined;\n}\n\nconst restoredTranscripts = new WeakMap<\n readonly LangChainMessage[],\n { readonly content: unknown; readonly transcript: readonly LangChainMessage[] }\n>();\n\n/**\n * A card's nested transcript with its report restored. On a cut finished card\n * the last step can ride with empty content and `DEEP_AGENT_REPEATS_RESULT_KEY`:\n * its text is the subagent's report, the card's own `content`, which the card\n * carries anyway. The step gets that content back. Any other transcript comes\n * back as it is. Memoized per transcript, so a lane's conversion sees one array.\n */\nexport function withRepeatedResult(\n transcript: readonly LangChainMessage[],\n content: unknown\n): readonly LangChainMessage[] {\n const last = transcript[transcript.length - 1];\n if (\n last === undefined ||\n (last as Record<string, unknown>)[DEEP_AGENT_REPEATS_RESULT_KEY] !== true ||\n (typeof content !== 'string' && !Array.isArray(content))\n ) {\n return transcript;\n }\n const cached = restoredTranscripts.get(transcript);\n if (cached !== undefined && cached.content === content) return cached.transcript;\n const restored = [...transcript.slice(0, -1), { ...last, content } as LangChainMessage];\n restoredTranscripts.set(transcript, { content, transcript: restored });\n return restored;\n}\n\ntype AssistantLangChainMessage = Extract<LangChainMessage, { type: 'ai' }>;\n\nconst convertibleChunkTurns = new WeakMap<LangChainMessage, LangChainMessage>();\n\n/**\n * A nested assistant turn stored under the chunk class name (the legacy\n * assistant-stream fold keeps `AIMessageChunk`) as the `ai` message it is: the\n * shipped converter maps only `ai`, and would drop the turn.\n */\nfunction asConvertibleTurn(message: LangChainMessage): LangChainMessage {\n const type: string = message.type;\n if (type !== 'AIMessageChunk') return message;\n const cached = convertibleChunkTurns.get(message);\n if (cached !== undefined) return cached;\n const turn: LangChainMessage = { ...(message as AssistantLangChainMessage), type: 'ai' };\n convertibleChunkTurns.set(message, turn);\n return turn;\n}\n\n/** A lane step as the assistant turn it is when it calls nothing; `null` for any other step. */\nfunction answeringTurn(step: LangChainMessage): AssistantLangChainMessage | null {\n const turn = asConvertibleTurn(step);\n return turn.type === 'ai' && (turn.tool_calls?.length ?? 0) === 0 ? turn : null;\n}\n\nconst isTextBlock = (block: unknown): block is { type: 'text'; text?: unknown } =>\n typeof block === 'object' && block !== null && 'type' in block && block.type === 'text';\n\n/** The text a step's content shows: the string, or its text blocks joined. */\nfunction shownText(content: unknown): string {\n if (typeof content === 'string') return content;\n if (!Array.isArray(content)) return '';\n let text = '';\n for (const block of content) {\n if (isTextBlock(block) && typeof block.text === 'string') text += block.text;\n }\n return text;\n}\n\n/** A turn that calls nothing and shows nothing: no text, and no block of another kind. */\nfunction blankTurn(step: LangChainMessage): AssistantLangChainMessage | null {\n const turn = answeringTurn(step);\n if (turn === null || shownText(turn.content).trim() !== '') return null;\n return typeof turn.content === 'string' || turn.content.every(isTextBlock) ? turn : null;\n}\n\nconst reportedLanes = new WeakMap<\n readonly LangChainMessage[],\n { readonly report: string; readonly transcript: readonly LangChainMessage[] }\n>();\n\n/**\n * A finished lane's transcript, closed by its report. A `task` card's content\n * is its subagent's report, the text of the lane's last turn. A transcript\n * that ends on that turn (an assistant step that calls nothing and says\n * something, which {@link withRepeatedResult} restores when it rides marked)\n * comes back as it is, even when blank steps follow it. A lane stored without\n * it shows the report as its closing answer: a lane whose last step is a blank\n * assistant step (lanes that finished before the host marked a repeated\n * report) gets the report in that step, its id and stamps kept, and a lane\n * that ends on a tool result or a turn that calls tools gets a closing step\n * after its last one. An empty report or transcript changes nothing. For\n * display only: the wire and the stored lane are untouched. Memoized per\n * transcript, so a lane's conversion sees one array.\n */\nexport function withLaneReport(\n transcript: readonly LangChainMessage[],\n report: string | undefined\n): readonly LangChainMessage[] {\n if (report === undefined || report.trim() === '' || transcript.length === 0) return transcript;\n // The lane's closing turn: its last step past any blank ones.\n let at = transcript.length - 1;\n let closing = transcript[at];\n while (closing !== undefined && blankTurn(closing) !== null) {\n at -= 1;\n closing = transcript[at];\n }\n const answered =\n closing !== undefined &&\n answeringTurn(closing) !== null &&\n shownText(closing.content).trim() !== '';\n if (answered) return transcript;\n const cached = reportedLanes.get(transcript);\n if (cached !== undefined && cached.report === report) return cached.transcript;\n const last = transcript[transcript.length - 1];\n const blank = last === undefined ? null : blankTurn(last);\n const closed: readonly LangChainMessage[] =\n blank !== null\n ? [...transcript.slice(0, -1), { ...blank, content: report }]\n : [...transcript, { id: `${last?.id ?? 'lane'}:report`, type: 'ai', content: report }];\n reportedLanes.set(transcript, { report, transcript: closed });\n return closed;\n}\n\n/** A nested transcript as the thread's own pipeline reads it (see {@link sanitizeLangChainMessages}). */\nfunction transcriptSources(transcript: readonly LangChainMessage[]): LangChainMessage[] {\n return sanitizeLangChainMessages(transcript.map(asConvertibleTurn));\n}\n\nconst reportedTranscripts = new WeakSet<readonly LangChainMessage[]>();\n\n/**\n * A nested transcript the shipped converter refused (it throws on, e.g., a\n * result whose tool name differs from its call's): reported once, and its card\n * goes without a nested thread instead of taking the whole thread down.\n */\nfunction reportUnconvertibleTranscript(\n transcript: readonly LangChainMessage[],\n error: unknown\n): void {\n if (reportedTranscripts.has(transcript)) return;\n reportedTranscripts.add(transcript);\n console.warn('[agent-runtime] a subagent transcript could not be converted', error);\n}\n\n/** Whether two values the wire carries (JSON: no functions, no cycles) are equal. */\nfunction sameJson(a: unknown, b: unknown): boolean {\n if (Object.is(a, b)) return true;\n if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null) return false;\n if (Array.isArray(a) || Array.isArray(b)) {\n return (\n Array.isArray(a) &&\n Array.isArray(b) &&\n a.length === b.length &&\n a.every((item, index) => sameJson(item, b[index]))\n );\n }\n const left = a as Record<string, unknown>;\n const right = b as Record<string, unknown>;\n const keys = Object.keys(left);\n return (\n keys.length === Object.keys(right).length &&\n keys.every(\n (key) =>\n Object.prototype.hasOwnProperty.call(right, key) && sameJson(left[key], right[key])\n )\n );\n}\n\n/**\n * Keeps a lane's unchanged steps as the objects it already converted. The host\n * replaces a card's whole document whenever the card changes, so every step it\n * carries arrives as a new object, and the conversion memory, which tells the\n * steps a turn continues by object, would see a new turn each time the card's\n * cut drops its oldest step and the turn's first step changes. A step whose id\n * and content are unchanged is the object held for that id. O(the steps' size).\n */\nfunction steadyStepObjects(): (\n transcript: readonly LangChainMessage[]\n) => readonly LangChainMessage[] {\n let held = new Map<string, LangChainMessage>();\n return (transcript) => {\n const next = new Map<string, LangChainMessage>();\n let kept = false;\n const steadied = transcript.map((entry) => {\n const id = entry.id;\n if (typeof id !== 'string') return entry;\n const before = held.get(id);\n const step = before !== undefined && sameJson(before, entry) ? before : entry;\n next.set(id, step);\n if (step !== entry) kept = true;\n return step;\n });\n held = next;\n return kept ? steadied : transcript;\n };\n}\n\n/** One lane's transcript, converted: `undefined` when the converter refused it. */\nexport type SubagentLaneConversion = (\n transcript: readonly LangChainMessage[],\n running: boolean\n) => readonly ThreadMessage[] | undefined;\n\n/**\n * One `task` lane's own conversion memory, for whatever converts that lane:\n * its unchanged steps keep their converted objects while it streams (a step the\n * wire sends again unchanged included, see {@link steadyStepObjects}), and its\n * turn keeps its row key (`deepAgentRowKey`) and part keys when the turn's head\n * moves — the oldest steps of a cut card falling off as the lane runs, or older\n * steps a transcript drawer pages in. A surface that keeps its disclosures under\n * that key keeps them open through both. A transcript array converted last time\n * is not converted again.\n */\nexport function createSubagentLaneConversion(): SubagentLaneConversion {\n const memory = createSubagentTranscriptConversionCache();\n const steady = steadyStepObjects();\n let last: {\n readonly transcript: readonly LangChainMessage[];\n readonly running: boolean;\n readonly messages: readonly ThreadMessage[] | undefined;\n } | null = null;\n return (transcript, running) => {\n if (last !== null && last.transcript === transcript && last.running === running) {\n return last.messages;\n }\n let messages: readonly ThreadMessage[] | undefined;\n try {\n messages = memory.convert(transcriptSources(steady(transcript)), running);\n } catch (error) {\n reportUnconvertibleTranscript(transcript, error);\n }\n last = { transcript, running, messages };\n return messages;\n };\n}\n\n/**\n * Sets each `task` part of a pass's converted rows to carry its nested\n * transcript as `messages`, for one attach. Each lane has its own conversion\n * memory, so its unchanged steps keep their converted objects while it\n * streams, as the thread's own messages do, and a lane whose transcript array\n * did not change is not converted again. A row, and a part whose lane did not\n * change, keep their identity: the same row always comes back as the same\n * object. A lane's memory lives only while a row of the pass holds its `task`\n * call: a lane a rewind removes, a branch switch hides or the window leaves\n * behind is let go with its transcript, and converted afresh if it returns.\n */\nfunction subagentTranscriptAttacher(): (rows: readonly ThreadMessage[]) => ThreadMessage[] {\n const lanes = new Map<string, SubagentLaneConversion>();\n const attachedRows = new WeakMap<ThreadMessage, ThreadMessage>();\n const attachedParts = new WeakMap<\n ToolCallMessagePart,\n { readonly messages: readonly ThreadMessage[]; readonly part: ToolCallMessagePart }\n >();\n\n const laneMessages = (\n toolCallId: string,\n transcript: readonly LangChainMessage[],\n running: boolean\n ): readonly ThreadMessage[] | undefined => {\n let lane = lanes.get(toolCallId);\n if (lane === undefined) {\n lane = createSubagentLaneConversion();\n lanes.set(toolCallId, lane);\n }\n return lane(transcript, running);\n };\n\n const attach = (row: ThreadMessage): ThreadMessage => {\n if (row.role !== 'assistant') return row;\n const cached = attachedRows.get(row);\n if (cached !== undefined) return cached;\n let content: ThreadAssistantMessagePart[] | null = null;\n for (const [index, part] of row.content.entries()) {\n if (part.type !== 'tool-call' || part.toolName !== TASK_TOOL_NAME) continue;\n const nested = laneTranscriptOf(part.artifact);\n if (nested === undefined) continue;\n // A running lane's placeholder is preliminary: its newest nested turn streams.\n const running = part.isPreliminary === true;\n const restored = withRepeatedResult(nested, part.result);\n const transcript =\n running || part.isError === true\n ? restored\n : withLaneReport(restored, getMessageText({ content: part.result }));\n const messages = laneMessages(part.toolCallId, transcript, running);\n if (messages === undefined) continue;\n const kept = attachedParts.get(part);\n const attached =\n kept !== undefined && kept.messages === messages ? kept.part : { ...part, messages };\n attachedParts.set(part, { messages, part: attached });\n content ??= [...row.content];\n content[index] = attached;\n }\n const attachedRow: ThreadMessage = content === null ? row : { ...row, content };\n attachedRows.set(row, attachedRow);\n return attachedRow;\n };\n\n return (rows) => {\n const attached = rows.map(attach);\n if (lanes.size === 0) return attached;\n const held = new Set<string>();\n for (const row of rows) {\n if (row.role !== 'assistant') continue;\n for (const part of row.content) {\n if (part.type !== 'tool-call' || part.toolName !== TASK_TOOL_NAME) continue;\n held.add(part.toolCallId);\n }\n }\n for (const toolCallId of lanes.keys()) {\n if (!held.has(toolCallId)) lanes.delete(toolCallId);\n }\n return attached;\n };\n}\n\n/**\n * A conversion memory for one attach (see\n * `useDeepAgentThread({ createConversionCache })`): the shared one's rows, with\n * each `task` tool-call part carrying its subagent's converted transcript as\n * `messages`. A pass that changes no row hands back the previous list itself.\n */\nexport function createSubagentTranscriptConversionCache(): DeepAgentConversionMemory {\n const thread = createDeepAgentMessageConversionCache();\n const attach = subagentTranscriptAttacher();\n let previousRows: ThreadMessage[] | null = null;\n let previous: ThreadMessage[] = [];\n return {\n convert(messages, isRunning) {\n const rows = thread.convert(messages, isRunning);\n if (rows === previousRows) return previous;\n previousRows = rows;\n const next = attach(rows);\n const unchanged =\n next.length === previous.length && next.every((row, index) => row === previous[index]);\n if (!unchanged) previous = next;\n return previous;\n },\n };\n}\n\n/**\n * Shared by every in-eval transcript: entries are keyed by source message, so\n * none outlives the wire state holding it and threads cannot collide.\n */\nconst inEvalTranscriptCache = createExternalMessageConversionCache();\nconst IN_EVAL_TRANSCRIPT_METADATA = {};\nconst inEvalTranscripts = new WeakMap<\n readonly LangChainMessage[],\n { readonly running: boolean; readonly messages: readonly ThreadMessage[] }\n>();\n\nconst NO_MESSAGES: readonly ThreadMessage[] = [];\n\n/**\n * An in-eval dispatch's live transcript (a `ptc_subagents` entry's `messages`)\n * as a nested thread, converted like a `task` lane's. Memoized per transcript\n * array; a step the lane did not change keeps its converted object. A\n * transcript the converter refuses reads as empty.\n */\nexport function convertSubagentTranscript(\n transcript: readonly LangChainMessage[],\n running: boolean\n): readonly ThreadMessage[] {\n const cached = inEvalTranscripts.get(transcript);\n if (cached !== undefined && cached.running === running) return cached.messages;\n let messages: readonly ThreadMessage[] = NO_MESSAGES;\n try {\n messages = convertExternalMessages(\n transcriptSources(transcript),\n convertDeepAgentLangChainMessage,\n running,\n IN_EVAL_TRANSCRIPT_METADATA,\n inEvalTranscriptCache\n ).map(markPreliminaryToolResults);\n } catch (error) {\n reportUnconvertibleTranscript(transcript, error);\n }\n inEvalTranscripts.set(transcript, { running, messages });\n return messages;\n}\n"],"names":["messages","DEEP_AGENT_REPEATS_RESULT_KEY","sanitizeLangChainMessages","TASK_TOOL_NAME","getMessageText","createDeepAgentMessageConversionCache","createExternalMessageConversionCache"],"mappings":"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"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * A subagent's transcript as assistant-ui's native nested thread.
3
+ *
4
+ * The backend nests a `task` subagent's transcript in its card's ToolMessage,
5
+ * at `artifact.subgraph_state.messages`: the newest steps on the running
6
+ * placeholder, the whole transcript on the real result. The conversion cache
7
+ * built here converts that transcript through the thread's own pipeline and
8
+ * sets it as the `task` tool-call part's `messages`, assistant-ui's channel for
9
+ * a tool call's nested conversation. `ReadonlyThreadProvider` (the provider
10
+ * under `MessagePartPrimitive.Messages`) renders it as a read-only thread under
11
+ * the parent's tool UIs, and `thread.tasks` derives child work from it.
12
+ *
13
+ * Hosts opt in (`useDeepAgentThread({ createConversionCache })`). It builds on
14
+ * the shared conversion memory from outside, so the shared converter, which
15
+ * ships in every surface's startup bundle (the Office pane's startup and total
16
+ * budgets have no room to spare), stays as it is, and a surface that draws no
17
+ * subagent transcript pays nothing for it.
18
+ */
19
+ import type { ThreadMessage } from '@assistant-ui/core';
20
+ import type { LangChainMessage } from '@assistant-ui/react-langgraph';
21
+ import { type DeepAgentConversionMemory } from './messages';
22
+ /**
23
+ * A card's nested transcript with its report restored. On a cut finished card
24
+ * the last step can ride with empty content and `DEEP_AGENT_REPEATS_RESULT_KEY`:
25
+ * its text is the subagent's report, the card's own `content`, which the card
26
+ * carries anyway. The step gets that content back. Any other transcript comes
27
+ * back as it is. Memoized per transcript, so a lane's conversion sees one array.
28
+ */
29
+ export declare function withRepeatedResult(transcript: readonly LangChainMessage[], content: unknown): readonly LangChainMessage[];
30
+ /**
31
+ * A finished lane's transcript, closed by its report. A `task` card's content
32
+ * is its subagent's report, the text of the lane's last turn. A transcript
33
+ * that ends on that turn (an assistant step that calls nothing and says
34
+ * something, which {@link withRepeatedResult} restores when it rides marked)
35
+ * comes back as it is, even when blank steps follow it. A lane stored without
36
+ * it shows the report as its closing answer: a lane whose last step is a blank
37
+ * assistant step (lanes that finished before the host marked a repeated
38
+ * report) gets the report in that step, its id and stamps kept, and a lane
39
+ * that ends on a tool result or a turn that calls tools gets a closing step
40
+ * after its last one. An empty report or transcript changes nothing. For
41
+ * display only: the wire and the stored lane are untouched. Memoized per
42
+ * transcript, so a lane's conversion sees one array.
43
+ */
44
+ export declare function withLaneReport(transcript: readonly LangChainMessage[], report: string | undefined): readonly LangChainMessage[];
45
+ /** One lane's transcript, converted: `undefined` when the converter refused it. */
46
+ export type SubagentLaneConversion = (transcript: readonly LangChainMessage[], running: boolean) => readonly ThreadMessage[] | undefined;
47
+ /**
48
+ * One `task` lane's own conversion memory, for whatever converts that lane:
49
+ * its unchanged steps keep their converted objects while it streams (a step the
50
+ * wire sends again unchanged included, see {@link steadyStepObjects}), and its
51
+ * turn keeps its row key (`deepAgentRowKey`) and part keys when the turn's head
52
+ * moves — the oldest steps of a cut card falling off as the lane runs, or older
53
+ * steps a transcript drawer pages in. A surface that keeps its disclosures under
54
+ * that key keeps them open through both. A transcript array converted last time
55
+ * is not converted again.
56
+ */
57
+ export declare function createSubagentLaneConversion(): SubagentLaneConversion;
58
+ /**
59
+ * A conversion memory for one attach (see
60
+ * `useDeepAgentThread({ createConversionCache })`): the shared one's rows, with
61
+ * each `task` tool-call part carrying its subagent's converted transcript as
62
+ * `messages`. A pass that changes no row hands back the previous list itself.
63
+ */
64
+ export declare function createSubagentTranscriptConversionCache(): DeepAgentConversionMemory;
65
+ /**
66
+ * An in-eval dispatch's live transcript (a `ptc_subagents` entry's `messages`)
67
+ * as a nested thread, converted like a `task` lane's. Memoized per transcript
68
+ * array; a step the lane did not change keeps its converted object. A
69
+ * transcript the converter refuses reads as empty.
70
+ */
71
+ export declare function convertSubagentTranscript(transcript: readonly LangChainMessage[], running: boolean): readonly ThreadMessage[];