@athenaintel/react 0.57.2 → 0.60.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (852) hide show
  1. package/README.md +795 -12
  2. package/dist/agent-runtime/src/addressed-agents.cjs +16 -0
  3. package/dist/agent-runtime/src/addressed-agents.cjs.map +1 -0
  4. package/dist/agent-runtime/src/addressed-agents.d.ts +30 -0
  5. package/dist/agent-runtime/src/addressed-agents.js +16 -0
  6. package/dist/agent-runtime/src/addressed-agents.js.map +1 -0
  7. package/dist/agent-runtime/src/answer-label.cjs +4 -3
  8. package/dist/agent-runtime/src/answer-label.cjs.map +1 -1
  9. package/dist/agent-runtime/src/answer-label.d.ts +13 -6
  10. package/dist/agent-runtime/src/answer-label.js +4 -3
  11. package/dist/agent-runtime/src/answer-label.js.map +1 -1
  12. package/dist/agent-runtime/src/chat-outbox-attachments.cjs.map +1 -1
  13. package/dist/agent-runtime/src/chat-outbox-attachments.d.ts +1 -1
  14. package/dist/agent-runtime/src/chat-outbox-attachments.js.map +1 -1
  15. package/dist/agent-runtime/src/chat-outbox-entry.cjs +101 -0
  16. package/dist/agent-runtime/src/chat-outbox-entry.cjs.map +1 -0
  17. package/dist/agent-runtime/src/chat-outbox-entry.d.ts +99 -0
  18. package/dist/agent-runtime/src/chat-outbox-entry.js +101 -0
  19. package/dist/agent-runtime/src/chat-outbox-entry.js.map +1 -0
  20. package/dist/agent-runtime/src/chat-outbox-legacy.cjs +252 -0
  21. package/dist/agent-runtime/src/chat-outbox-legacy.cjs.map +1 -0
  22. package/dist/agent-runtime/src/chat-outbox-legacy.d.ts +96 -0
  23. package/dist/agent-runtime/src/chat-outbox-legacy.js +252 -0
  24. package/dist/agent-runtime/src/chat-outbox-legacy.js.map +1 -0
  25. package/dist/agent-runtime/src/chat-outbox-policy.cjs +30 -0
  26. package/dist/agent-runtime/src/chat-outbox-policy.cjs.map +1 -0
  27. package/dist/agent-runtime/src/chat-outbox-policy.d.ts +42 -0
  28. package/dist/agent-runtime/src/chat-outbox-policy.js +30 -0
  29. package/dist/agent-runtime/src/chat-outbox-policy.js.map +1 -0
  30. package/dist/agent-runtime/src/chat-outbox-storage.cjs +306 -0
  31. package/dist/agent-runtime/src/chat-outbox-storage.cjs.map +1 -0
  32. package/dist/agent-runtime/src/chat-outbox-storage.d.ts +194 -0
  33. package/dist/agent-runtime/src/chat-outbox-storage.js +306 -0
  34. package/dist/agent-runtime/src/chat-outbox-storage.js.map +1 -0
  35. package/dist/agent-runtime/src/chat-outbox-thread.cjs +21 -94
  36. package/dist/agent-runtime/src/chat-outbox-thread.cjs.map +1 -1
  37. package/dist/agent-runtime/src/chat-outbox-thread.d.ts +22 -18
  38. package/dist/agent-runtime/src/chat-outbox-thread.js +21 -94
  39. package/dist/agent-runtime/src/chat-outbox-thread.js.map +1 -1
  40. package/dist/agent-runtime/src/chat-outbox.cjs +492 -547
  41. package/dist/agent-runtime/src/chat-outbox.cjs.map +1 -1
  42. package/dist/agent-runtime/src/chat-outbox.d.ts +110 -142
  43. package/dist/agent-runtime/src/chat-outbox.js +492 -547
  44. package/dist/agent-runtime/src/chat-outbox.js.map +1 -1
  45. package/dist/agent-runtime/src/composer-markdown.cjs +0 -16
  46. package/dist/agent-runtime/src/composer-markdown.cjs.map +1 -1
  47. package/dist/agent-runtime/src/composer-markdown.d.ts +1 -1
  48. package/dist/agent-runtime/src/composer-markdown.js +1 -17
  49. package/dist/agent-runtime/src/composer-markdown.js.map +1 -1
  50. package/dist/agent-runtime/src/deep-agent-transport-recipe.cjs +3 -1
  51. package/dist/agent-runtime/src/deep-agent-transport-recipe.cjs.map +1 -1
  52. package/dist/agent-runtime/src/deep-agent-transport-recipe.d.ts +8 -1
  53. package/dist/agent-runtime/src/deep-agent-transport-recipe.js +3 -1
  54. package/dist/agent-runtime/src/deep-agent-transport-recipe.js.map +1 -1
  55. package/dist/agent-runtime/src/dictation-preferences.d.ts +356 -0
  56. package/dist/agent-runtime/src/dictation-record.d.ts +279 -0
  57. package/dist/agent-runtime/src/dictation-session.d.ts +106 -7
  58. package/dist/agent-runtime/src/dictation-snippets.d.ts +9 -0
  59. package/dist/agent-runtime/src/dictation-transfer.d.ts +142 -0
  60. package/dist/agent-runtime/src/edit-command.cjs.map +1 -1
  61. package/dist/agent-runtime/src/edit-command.d.ts +1 -1
  62. package/dist/agent-runtime/src/edit-command.js.map +1 -1
  63. package/dist/agent-runtime/src/errors.cjs +1 -0
  64. package/dist/agent-runtime/src/errors.cjs.map +1 -1
  65. package/dist/agent-runtime/src/errors.js +1 -0
  66. package/dist/agent-runtime/src/errors.js.map +1 -1
  67. package/dist/agent-runtime/src/generated/runconfig-contract.cjs +24 -0
  68. package/dist/agent-runtime/src/generated/runconfig-contract.cjs.map +1 -1
  69. package/dist/agent-runtime/src/generated/runconfig-contract.d.ts +3 -3
  70. package/dist/agent-runtime/src/generated/runconfig-contract.js +24 -0
  71. package/dist/agent-runtime/src/generated/runconfig-contract.js.map +1 -1
  72. package/dist/agent-runtime/src/index.d.ts +14 -8
  73. package/dist/agent-runtime/src/lane-follow.cjs +289 -0
  74. package/dist/agent-runtime/src/lane-follow.cjs.map +1 -0
  75. package/dist/agent-runtime/src/lane-follow.js +289 -0
  76. package/dist/agent-runtime/src/lane-follow.js.map +1 -0
  77. package/dist/agent-runtime/src/lane-images.cjs +387 -0
  78. package/dist/agent-runtime/src/lane-images.cjs.map +1 -0
  79. package/dist/agent-runtime/src/lane-images.js +387 -0
  80. package/dist/agent-runtime/src/lane-images.js.map +1 -0
  81. package/dist/agent-runtime/src/message-window.js +1 -1
  82. package/dist/agent-runtime/src/messages.cjs +19 -1
  83. package/dist/agent-runtime/src/messages.cjs.map +1 -1
  84. package/dist/agent-runtime/src/messages.d.ts +8 -0
  85. package/dist/agent-runtime/src/messages.js +21 -3
  86. package/dist/agent-runtime/src/messages.js.map +1 -1
  87. package/dist/agent-runtime/src/named-agents.cjs +301 -0
  88. package/dist/agent-runtime/src/named-agents.cjs.map +1 -0
  89. package/dist/agent-runtime/src/named-agents.d.ts +246 -0
  90. package/dist/agent-runtime/src/named-agents.js +301 -0
  91. package/dist/agent-runtime/src/named-agents.js.map +1 -0
  92. package/dist/agent-runtime/src/offline-status.cjs.map +1 -1
  93. package/dist/agent-runtime/src/offline-status.d.ts +93 -2
  94. package/dist/agent-runtime/src/offline-status.js.map +1 -1
  95. package/dist/agent-runtime/src/ptc-subcalls.cjs +41 -0
  96. package/dist/agent-runtime/src/ptc-subcalls.cjs.map +1 -0
  97. package/dist/agent-runtime/src/ptc-subcalls.js +41 -0
  98. package/dist/agent-runtime/src/ptc-subcalls.js.map +1 -0
  99. package/dist/agent-runtime/src/queue.cjs +2 -2
  100. package/dist/agent-runtime/src/queue.cjs.map +1 -1
  101. package/dist/agent-runtime/src/queue.d.ts +20 -25
  102. package/dist/agent-runtime/src/queue.js +2 -2
  103. package/dist/agent-runtime/src/queue.js.map +1 -1
  104. package/dist/agent-runtime/src/quota-safe-local-storage-session.cjs +314 -84
  105. package/dist/agent-runtime/src/quota-safe-local-storage-session.cjs.map +1 -1
  106. package/dist/agent-runtime/src/quota-safe-local-storage-session.d.ts +137 -40
  107. package/dist/agent-runtime/src/quota-safe-local-storage-session.js +318 -88
  108. package/dist/agent-runtime/src/quota-safe-local-storage-session.js.map +1 -1
  109. package/dist/agent-runtime/src/run-send.cjs +54 -0
  110. package/dist/agent-runtime/src/run-send.cjs.map +1 -0
  111. package/dist/agent-runtime/src/run-send.d.ts +51 -0
  112. package/dist/agent-runtime/src/run-send.js +54 -0
  113. package/dist/agent-runtime/src/run-send.js.map +1 -0
  114. package/dist/agent-runtime/src/running-tool-placeholder.cjs +6 -0
  115. package/dist/agent-runtime/src/running-tool-placeholder.cjs.map +1 -1
  116. package/dist/agent-runtime/src/running-tool-placeholder.js +6 -0
  117. package/dist/agent-runtime/src/running-tool-placeholder.js.map +1 -1
  118. package/dist/agent-runtime/src/runtime.d.ts +9 -5
  119. package/dist/agent-runtime/src/sealed-idb.cjs +64 -0
  120. package/dist/agent-runtime/src/sealed-idb.cjs.map +1 -1
  121. package/dist/agent-runtime/src/sealed-idb.d.ts +16 -0
  122. package/dist/agent-runtime/src/sealed-idb.js +64 -0
  123. package/dist/agent-runtime/src/sealed-idb.js.map +1 -1
  124. package/dist/agent-runtime/src/send-recovery.cjs +90 -118
  125. package/dist/agent-runtime/src/send-recovery.cjs.map +1 -1
  126. package/dist/agent-runtime/src/send-recovery.d.ts +25 -29
  127. package/dist/agent-runtime/src/send-recovery.js +90 -118
  128. package/dist/agent-runtime/src/send-recovery.js.map +1 -1
  129. package/dist/agent-runtime/src/statewire-diagnostics.d.ts +4 -1
  130. package/dist/agent-runtime/src/statewire-held-sends.cjs +191 -0
  131. package/dist/agent-runtime/src/statewire-held-sends.cjs.map +1 -0
  132. package/dist/agent-runtime/src/statewire-held-sends.d.ts +119 -0
  133. package/dist/agent-runtime/src/statewire-held-sends.js +191 -0
  134. package/dist/agent-runtime/src/statewire-held-sends.js.map +1 -0
  135. package/dist/agent-runtime/src/statewire-state.cjs +4 -0
  136. package/dist/agent-runtime/src/statewire-state.cjs.map +1 -1
  137. package/dist/agent-runtime/src/statewire-state.js +4 -0
  138. package/dist/agent-runtime/src/statewire-state.js.map +1 -1
  139. package/dist/agent-runtime/src/statewire-transport.cjs +8 -2
  140. package/dist/agent-runtime/src/statewire-transport.cjs.map +1 -1
  141. package/dist/agent-runtime/src/statewire-transport.d.ts +14 -5
  142. package/dist/agent-runtime/src/statewire-transport.js +8 -2
  143. package/dist/agent-runtime/src/statewire-transport.js.map +1 -1
  144. package/dist/agent-runtime/src/subagent-transcripts.cjs +1 -23
  145. package/dist/agent-runtime/src/subagent-transcripts.cjs.map +1 -1
  146. package/dist/agent-runtime/src/subagent-transcripts.js +3 -25
  147. package/dist/agent-runtime/src/subagent-transcripts.js.map +1 -1
  148. package/dist/agent-runtime/src/subagents.cjs +22 -29
  149. package/dist/agent-runtime/src/subagents.cjs.map +1 -1
  150. package/dist/agent-runtime/src/subagents.js +23 -30
  151. package/dist/agent-runtime/src/subagents.js.map +1 -1
  152. package/dist/agent-runtime/src/thread-extras.cjs +27 -19
  153. package/dist/agent-runtime/src/thread-extras.cjs.map +1 -1
  154. package/dist/agent-runtime/src/thread-extras.d.ts +19 -6
  155. package/dist/agent-runtime/src/thread-extras.js +27 -19
  156. package/dist/agent-runtime/src/thread-extras.js.map +1 -1
  157. package/dist/agent-runtime/src/thread-handoff-flow-machine.d.ts +8 -8
  158. package/dist/agent-runtime/src/tool-metadata.cjs +19 -0
  159. package/dist/agent-runtime/src/tool-metadata.cjs.map +1 -1
  160. package/dist/agent-runtime/src/tool-metadata.js +19 -0
  161. package/dist/agent-runtime/src/tool-metadata.js.map +1 -1
  162. package/dist/agent-runtime/src/tool-names.cjs +21 -0
  163. package/dist/agent-runtime/src/tool-names.cjs.map +1 -1
  164. package/dist/agent-runtime/src/tool-names.d.ts +8 -0
  165. package/dist/agent-runtime/src/tool-names.js +21 -0
  166. package/dist/agent-runtime/src/tool-names.js.map +1 -1
  167. package/dist/agent-runtime/src/typed-interrupt-kinds.cjs +247 -0
  168. package/dist/agent-runtime/src/typed-interrupt-kinds.cjs.map +1 -0
  169. package/dist/agent-runtime/src/typed-interrupt-kinds.d.ts +173 -0
  170. package/dist/agent-runtime/src/typed-interrupt-kinds.js +247 -0
  171. package/dist/agent-runtime/src/typed-interrupt-kinds.js.map +1 -0
  172. package/dist/agent-runtime/src/typed-interrupts.cjs +48 -0
  173. package/dist/agent-runtime/src/typed-interrupts.cjs.map +1 -0
  174. package/dist/agent-runtime/src/typed-interrupts.d.ts +75 -0
  175. package/dist/agent-runtime/src/typed-interrupts.js +48 -0
  176. package/dist/agent-runtime/src/typed-interrupts.js.map +1 -0
  177. package/dist/agent-runtime/src/types.d.ts +1 -1
  178. package/dist/agent-runtime/src/use-conversation-list.cjs +1 -0
  179. package/dist/agent-runtime/src/use-conversation-list.cjs.map +1 -1
  180. package/dist/agent-runtime/src/use-conversation-list.d.ts +7 -0
  181. package/dist/agent-runtime/src/use-conversation-list.js +1 -0
  182. package/dist/agent-runtime/src/use-conversation-list.js.map +1 -1
  183. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.cjs +46 -29
  184. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.cjs.map +1 -1
  185. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.d.ts +14 -22
  186. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.js +46 -29
  187. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.js.map +1 -1
  188. package/dist/agent-runtime/src/use-deep-agent-runtime.cjs +78 -14
  189. package/dist/agent-runtime/src/use-deep-agent-runtime.cjs.map +1 -1
  190. package/dist/agent-runtime/src/use-deep-agent-runtime.d.ts +34 -7
  191. package/dist/agent-runtime/src/use-deep-agent-runtime.js +79 -15
  192. package/dist/agent-runtime/src/use-deep-agent-runtime.js.map +1 -1
  193. package/dist/agent-runtime/src/use-deep-agent-thread.cjs +16 -1
  194. package/dist/agent-runtime/src/use-deep-agent-thread.cjs.map +1 -1
  195. package/dist/agent-runtime/src/use-deep-agent-thread.d.ts +7 -2
  196. package/dist/agent-runtime/src/use-deep-agent-thread.js +16 -1
  197. package/dist/agent-runtime/src/use-deep-agent-thread.js.map +1 -1
  198. package/dist/agent-runtime/src/use-deep-agent-voice.cjs +30 -4
  199. package/dist/agent-runtime/src/use-deep-agent-voice.cjs.map +1 -1
  200. package/dist/agent-runtime/src/use-deep-agent-voice.d.ts +22 -4
  201. package/dist/agent-runtime/src/use-deep-agent-voice.js +30 -4
  202. package/dist/agent-runtime/src/use-deep-agent-voice.js.map +1 -1
  203. package/dist/agent-runtime/src/withdrawn-turns.d.ts +5 -4
  204. package/dist/agent-runtime/src/word-device-fit.d.ts +174 -0
  205. package/dist/agent-runtime/src/work-in.d.ts +127 -0
  206. package/dist/assets/AthenaAssetEmbed.cjs.map +1 -1
  207. package/dist/assets/AthenaAssetEmbed.d.ts +6 -1
  208. package/dist/assets/AthenaAssetEmbed.js.map +1 -1
  209. package/dist/assets/asset-panel-store.cjs +13 -5
  210. package/dist/assets/asset-panel-store.cjs.map +1 -1
  211. package/dist/assets/asset-panel-store.d.ts +33 -2
  212. package/dist/assets/asset-panel-store.js +13 -5
  213. package/dist/assets/asset-panel-store.js.map +1 -1
  214. package/dist/auth/AthenaCredentialSourceContext.cjs +11 -0
  215. package/dist/auth/AthenaCredentialSourceContext.cjs.map +1 -1
  216. package/dist/auth/AthenaCredentialSourceContext.d.ts +6 -0
  217. package/dist/auth/AthenaCredentialSourceContext.js +11 -0
  218. package/dist/auth/AthenaCredentialSourceContext.js.map +1 -1
  219. package/dist/auth/account-identity.cjs +13 -2
  220. package/dist/auth/account-identity.cjs.map +1 -1
  221. package/dist/auth/account-identity.d.ts +9 -0
  222. package/dist/auth/account-identity.js +13 -2
  223. package/dist/auth/account-identity.js.map +1 -1
  224. package/dist/auth/credential-source.cjs +20 -4
  225. package/dist/auth/credential-source.cjs.map +1 -1
  226. package/dist/auth/credential-source.d.ts +9 -0
  227. package/dist/auth/credential-source.js +20 -4
  228. package/dist/auth/credential-source.js.map +1 -1
  229. package/dist/catalog/chat-pickers.cjs +31 -0
  230. package/dist/catalog/chat-pickers.cjs.map +1 -1
  231. package/dist/catalog/chat-pickers.d.ts +17 -0
  232. package/dist/catalog/chat-pickers.js +33 -2
  233. package/dist/catalog/chat-pickers.js.map +1 -1
  234. package/dist/catalog/runtime-catalog.cjs +63 -3
  235. package/dist/catalog/runtime-catalog.cjs.map +1 -1
  236. package/dist/catalog/runtime-catalog.d.ts +63 -3
  237. package/dist/catalog/runtime-catalog.js +64 -4
  238. package/dist/catalog/runtime-catalog.js.map +1 -1
  239. package/dist/chat/AthenaChat.cjs +301 -98
  240. package/dist/chat/AthenaChat.cjs.map +1 -1
  241. package/dist/chat/AthenaChat.d.ts +80 -4
  242. package/dist/chat/AthenaChat.js +302 -99
  243. package/dist/chat/AthenaChat.js.map +1 -1
  244. package/dist/chat/StatewireApprovalCard.cjs +35 -5
  245. package/dist/chat/StatewireApprovalCard.cjs.map +1 -1
  246. package/dist/chat/StatewireApprovalCard.d.ts +55 -2
  247. package/dist/chat/StatewireApprovalCard.js +37 -7
  248. package/dist/chat/StatewireApprovalCard.js.map +1 -1
  249. package/dist/chat/StatewireQueuedMessages.cjs +17 -2
  250. package/dist/chat/StatewireQueuedMessages.cjs.map +1 -1
  251. package/dist/chat/StatewireQueuedMessages.d.ts +8 -45
  252. package/dist/chat/StatewireQueuedMessages.js +18 -3
  253. package/dist/chat/StatewireQueuedMessages.js.map +1 -1
  254. package/dist/chat/chat-agent-mentions.cjs +70 -0
  255. package/dist/chat/chat-agent-mentions.cjs.map +1 -0
  256. package/dist/chat/chat-agent-mentions.d.ts +13 -0
  257. package/dist/chat/chat-agent-mentions.js +70 -0
  258. package/dist/chat/chat-agent-mentions.js.map +1 -0
  259. package/dist/chat/composer-actions.cjs +12 -0
  260. package/dist/chat/composer-actions.cjs.map +1 -0
  261. package/dist/chat/composer-actions.d.ts +22 -0
  262. package/dist/chat/composer-actions.js +12 -0
  263. package/dist/chat/composer-actions.js.map +1 -0
  264. package/dist/chat/follow-up-suggestions.cjs +185 -0
  265. package/dist/chat/follow-up-suggestions.cjs.map +1 -0
  266. package/dist/chat/follow-up-suggestions.d.ts +64 -0
  267. package/dist/chat/follow-up-suggestions.js +185 -0
  268. package/dist/chat/follow-up-suggestions.js.map +1 -0
  269. package/dist/chat/super-grouping/ToolTimeline.cjs +4 -3
  270. package/dist/chat/super-grouping/ToolTimeline.cjs.map +1 -1
  271. package/dist/chat/super-grouping/ToolTimeline.d.ts +7 -3
  272. package/dist/chat/super-grouping/ToolTimeline.js +4 -3
  273. package/dist/chat/super-grouping/ToolTimeline.js.map +1 -1
  274. package/dist/chat/turn-changes.cjs +284 -0
  275. package/dist/chat/turn-changes.cjs.map +1 -0
  276. package/dist/chat/turn-changes.d.ts +130 -0
  277. package/dist/chat/turn-changes.js +284 -0
  278. package/dist/chat/turn-changes.js.map +1 -0
  279. package/dist/chat/typed-interrupts/StatewireTypedInterruptCard.cjs +31 -0
  280. package/dist/chat/typed-interrupts/StatewireTypedInterruptCard.cjs.map +1 -0
  281. package/dist/chat/typed-interrupts/StatewireTypedInterruptCard.d.ts +31 -0
  282. package/dist/chat/typed-interrupts/StatewireTypedInterruptCard.js +31 -0
  283. package/dist/chat/typed-interrupts/StatewireTypedInterruptCard.js.map +1 -0
  284. package/dist/chat/typed-interrupts/approval-cards.cjs +250 -0
  285. package/dist/chat/typed-interrupts/approval-cards.cjs.map +1 -0
  286. package/dist/chat/typed-interrupts/approval-cards.d.ts +22 -0
  287. package/dist/chat/typed-interrupts/approval-cards.js +250 -0
  288. package/dist/chat/typed-interrupts/approval-cards.js.map +1 -0
  289. package/dist/chat/typed-interrupts/form-cards.cjs +289 -0
  290. package/dist/chat/typed-interrupts/form-cards.cjs.map +1 -0
  291. package/dist/chat/typed-interrupts/form-cards.d.ts +6 -0
  292. package/dist/chat/typed-interrupts/form-cards.js +289 -0
  293. package/dist/chat/typed-interrupts/form-cards.js.map +1 -0
  294. package/dist/chat/typed-interrupts/interrupt-card-shell.cjs +182 -0
  295. package/dist/chat/typed-interrupts/interrupt-card-shell.cjs.map +1 -0
  296. package/dist/chat/typed-interrupts/interrupt-card-shell.d.ts +47 -0
  297. package/dist/chat/typed-interrupts/interrupt-card-shell.js +182 -0
  298. package/dist/chat/typed-interrupts/interrupt-card-shell.js.map +1 -0
  299. package/dist/chat/typed-interrupts/json-schema-form.cjs +388 -0
  300. package/dist/chat/typed-interrupts/json-schema-form.cjs.map +1 -0
  301. package/dist/chat/typed-interrupts/json-schema-form.d.ts +33 -0
  302. package/dist/chat/typed-interrupts/json-schema-form.js +388 -0
  303. package/dist/chat/typed-interrupts/json-schema-form.js.map +1 -0
  304. package/dist/chat/typed-interrupts/questionnaire-card.cjs +449 -0
  305. package/dist/chat/typed-interrupts/questionnaire-card.cjs.map +1 -0
  306. package/dist/chat/typed-interrupts/questionnaire-card.d.ts +20 -0
  307. package/dist/chat/typed-interrupts/questionnaire-card.js +449 -0
  308. package/dist/chat/typed-interrupts/questionnaire-card.js.map +1 -0
  309. package/dist/chat/typed-interrupts/request-file-card.cjs +159 -0
  310. package/dist/chat/typed-interrupts/request-file-card.cjs.map +1 -0
  311. package/dist/chat/typed-interrupts/request-file-card.d.ts +2 -0
  312. package/dist/chat/typed-interrupts/request-file-card.js +159 -0
  313. package/dist/chat/typed-interrupts/request-file-card.js.map +1 -0
  314. package/dist/chat/typed-interrupts/toolkit-selection-card.cjs +189 -0
  315. package/dist/chat/typed-interrupts/toolkit-selection-card.cjs.map +1 -0
  316. package/dist/chat/typed-interrupts/toolkit-selection-card.d.ts +23 -0
  317. package/dist/chat/typed-interrupts/toolkit-selection-card.js +189 -0
  318. package/dist/chat/typed-interrupts/toolkit-selection-card.js.map +1 -0
  319. package/dist/chat/typed-interrupts/typed-interrupt-body.cjs +26 -0
  320. package/dist/chat/typed-interrupts/typed-interrupt-body.cjs.map +1 -0
  321. package/dist/chat/typed-interrupts/typed-interrupt-body.d.ts +3 -0
  322. package/dist/chat/typed-interrupts/typed-interrupt-body.js +26 -0
  323. package/dist/chat/typed-interrupts/typed-interrupt-body.js.map +1 -0
  324. package/dist/chat/typed-interrupts/typed-interrupt-graphql.cjs +105 -0
  325. package/dist/chat/typed-interrupts/typed-interrupt-graphql.cjs.map +1 -0
  326. package/dist/chat/typed-interrupts/typed-interrupt-graphql.d.ts +29 -0
  327. package/dist/chat/typed-interrupts/typed-interrupt-graphql.js +105 -0
  328. package/dist/chat/typed-interrupts/typed-interrupt-graphql.js.map +1 -0
  329. package/dist/chat/typed-interrupts/typed-interrupt-notice.cjs +70 -0
  330. package/dist/chat/typed-interrupts/typed-interrupt-notice.cjs.map +1 -0
  331. package/dist/chat/typed-interrupts/typed-interrupt-notice.d.ts +45 -0
  332. package/dist/chat/typed-interrupts/typed-interrupt-notice.js +70 -0
  333. package/dist/chat/typed-interrupts/typed-interrupt-notice.js.map +1 -0
  334. package/dist/chat/typed-interrupts/typed-interrupt-panel.cjs +76 -0
  335. package/dist/chat/typed-interrupts/typed-interrupt-panel.cjs.map +1 -0
  336. package/dist/chat/typed-interrupts/typed-interrupt-panel.d.ts +11 -0
  337. package/dist/chat/typed-interrupts/typed-interrupt-panel.js +76 -0
  338. package/dist/chat/typed-interrupts/typed-interrupt-panel.js.map +1 -0
  339. package/dist/chat/typed-interrupts/typed-interrupt-types.d.ts +46 -0
  340. package/dist/chat/typed-interrupts/use-interrupt-draft.cjs +106 -0
  341. package/dist/chat/typed-interrupts/use-interrupt-draft.cjs.map +1 -0
  342. package/dist/chat/typed-interrupts/use-interrupt-draft.d.ts +29 -0
  343. package/dist/chat/typed-interrupts/use-interrupt-draft.js +106 -0
  344. package/dist/chat/typed-interrupts/use-interrupt-draft.js.map +1 -0
  345. package/dist/chat/typed-interrupts/use-statewire-typed-interrupt.cjs +231 -0
  346. package/dist/chat/typed-interrupts/use-statewire-typed-interrupt.cjs.map +1 -0
  347. package/dist/chat/typed-interrupts/use-statewire-typed-interrupt.d.ts +66 -0
  348. package/dist/chat/typed-interrupts/use-statewire-typed-interrupt.js +231 -0
  349. package/dist/chat/typed-interrupts/use-statewire-typed-interrupt.js.map +1 -0
  350. package/dist/chat-ui/composer/composer-named-agents.cjs +13 -0
  351. package/dist/chat-ui/composer/composer-named-agents.cjs.map +1 -0
  352. package/dist/chat-ui/composer/composer-named-agents.d.ts +20 -0
  353. package/dist/chat-ui/composer/composer-named-agents.js +13 -0
  354. package/dist/chat-ui/composer/composer-named-agents.js.map +1 -0
  355. package/dist/chat-ui/composer/slash-command-menu.cjs +143 -0
  356. package/dist/chat-ui/composer/slash-command-menu.cjs.map +1 -0
  357. package/dist/chat-ui/composer/slash-command-menu.d.ts +19 -0
  358. package/dist/chat-ui/composer/slash-command-menu.js +143 -0
  359. package/dist/chat-ui/composer/slash-command-menu.js.map +1 -0
  360. package/dist/chat-ui/composer/slash-commands-extension.cjs +51 -0
  361. package/dist/chat-ui/composer/slash-commands-extension.cjs.map +1 -0
  362. package/dist/chat-ui/composer/slash-commands-extension.d.ts +39 -0
  363. package/dist/chat-ui/composer/slash-commands-extension.js +51 -0
  364. package/dist/chat-ui/composer/slash-commands-extension.js.map +1 -0
  365. package/dist/chat-ui/composer/slash-commands.cjs +74 -0
  366. package/dist/chat-ui/composer/slash-commands.cjs.map +1 -0
  367. package/dist/chat-ui/composer/slash-commands.d.ts +82 -0
  368. package/dist/chat-ui/composer/slash-commands.js +74 -0
  369. package/dist/chat-ui/composer/slash-commands.js.map +1 -0
  370. package/dist/chat-ui/composer/tiptap-composer.cjs +135 -9
  371. package/dist/chat-ui/composer/tiptap-composer.cjs.map +1 -1
  372. package/dist/chat-ui/composer/tiptap-composer.d.ts +61 -2
  373. package/dist/chat-ui/composer/tiptap-composer.js +135 -9
  374. package/dist/chat-ui/composer/tiptap-composer.js.map +1 -1
  375. package/dist/chat-ui/index.cjs +5 -0
  376. package/dist/chat-ui/index.cjs.map +1 -1
  377. package/dist/chat-ui/index.d.ts +4 -2
  378. package/dist/chat-ui/index.js +5 -0
  379. package/dist/chat-ui/index.js.map +1 -1
  380. package/dist/chat-ui/mentions/mention-chip.cjs +10 -4
  381. package/dist/chat-ui/mentions/mention-chip.cjs.map +1 -1
  382. package/dist/chat-ui/mentions/mention-chip.js +11 -5
  383. package/dist/chat-ui/mentions/mention-chip.js.map +1 -1
  384. package/dist/chat-ui/mentions/mention-extension.cjs +8 -1
  385. package/dist/chat-ui/mentions/mention-extension.cjs.map +1 -1
  386. package/dist/chat-ui/mentions/mention-extension.js +8 -1
  387. package/dist/chat-ui/mentions/mention-extension.js.map +1 -1
  388. package/dist/chat-ui/mentions/suggestions/components/get-scope-name.cjs +1 -0
  389. package/dist/chat-ui/mentions/suggestions/components/get-scope-name.cjs.map +1 -1
  390. package/dist/chat-ui/mentions/suggestions/components/get-scope-name.js +1 -0
  391. package/dist/chat-ui/mentions/suggestions/components/get-scope-name.js.map +1 -1
  392. package/dist/chat-ui/mentions/suggestions/components/mention-icon.cjs +20 -2
  393. package/dist/chat-ui/mentions/suggestions/components/mention-icon.cjs.map +1 -1
  394. package/dist/chat-ui/mentions/suggestions/components/mention-icon.d.ts +10 -1
  395. package/dist/chat-ui/mentions/suggestions/components/mention-icon.js +22 -4
  396. package/dist/chat-ui/mentions/suggestions/components/mention-icon.js.map +1 -1
  397. package/dist/chat-ui/mentions/suggestions/components/menu-item.cjs +1 -1
  398. package/dist/chat-ui/mentions/suggestions/components/menu-item.cjs.map +1 -1
  399. package/dist/chat-ui/mentions/suggestions/components/menu-item.js +1 -1
  400. package/dist/chat-ui/mentions/suggestions/components/menu-item.js.map +1 -1
  401. package/dist/chat-ui/mentions/suggestions/data/api-client.cjs +45 -0
  402. package/dist/chat-ui/mentions/suggestions/data/api-client.cjs.map +1 -1
  403. package/dist/chat-ui/mentions/suggestions/data/api-client.d.ts +48 -0
  404. package/dist/chat-ui/mentions/suggestions/data/api-client.js +45 -0
  405. package/dist/chat-ui/mentions/suggestions/data/api-client.js.map +1 -1
  406. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icon-names.generated.cjs +89 -0
  407. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icon-names.generated.cjs.map +1 -0
  408. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icon-names.generated.d.ts +8 -0
  409. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icon-names.generated.js +89 -0
  410. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icon-names.generated.js.map +1 -0
  411. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.cjs +140 -116
  412. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.cjs.map +1 -1
  413. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.d.ts +46 -12
  414. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.js +141 -117
  415. package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.js.map +1 -1
  416. package/dist/chat-ui/mentions/suggestions/data/sources/index.cjs +272 -25
  417. package/dist/chat-ui/mentions/suggestions/data/sources/index.cjs.map +1 -1
  418. package/dist/chat-ui/mentions/suggestions/data/sources/index.d.ts +88 -10
  419. package/dist/chat-ui/mentions/suggestions/data/sources/index.js +274 -27
  420. package/dist/chat-ui/mentions/suggestions/data/sources/index.js.map +1 -1
  421. package/dist/chat-ui/mentions/suggestions/data/types.cjs.map +1 -1
  422. package/dist/chat-ui/mentions/suggestions/data/types.d.ts +27 -1
  423. package/dist/chat-ui/mentions/suggestions/data/types.js.map +1 -1
  424. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.cjs +56 -5
  425. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.cjs.map +1 -1
  426. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.d.ts +26 -6
  427. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.js +57 -6
  428. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.js.map +1 -1
  429. package/dist/chat-ui/mentions/suggestions/mention-suggestions.extension.cjs +34 -17
  430. package/dist/chat-ui/mentions/suggestions/mention-suggestions.extension.cjs.map +1 -1
  431. package/dist/chat-ui/mentions/suggestions/mention-suggestions.extension.d.ts +19 -1
  432. package/dist/chat-ui/mentions/suggestions/mention-suggestions.extension.js +35 -18
  433. package/dist/chat-ui/mentions/suggestions/mention-suggestions.extension.js.map +1 -1
  434. package/dist/chat-ui/mentions/use-asset-icon-app-url.cjs +12 -0
  435. package/dist/chat-ui/mentions/use-asset-icon-app-url.cjs.map +1 -0
  436. package/dist/chat-ui/mentions/use-asset-icon-app-url.d.ts +8 -0
  437. package/dist/chat-ui/mentions/use-asset-icon-app-url.js +12 -0
  438. package/dist/chat-ui/mentions/use-asset-icon-app-url.js.map +1 -0
  439. package/dist/chat-ui/statewire.d.ts +1 -1
  440. package/dist/chat-ui/thread/statewire-history-edge.cjs +15 -0
  441. package/dist/chat-ui/thread/statewire-history-edge.cjs.map +1 -1
  442. package/dist/chat-ui/thread/statewire-history-edge.d.ts +4 -1
  443. package/dist/chat-ui/thread/statewire-history-edge.js +15 -0
  444. package/dist/chat-ui/thread/statewire-history-edge.js.map +1 -1
  445. package/dist/collab/client.cjs +41 -6
  446. package/dist/collab/client.cjs.map +1 -1
  447. package/dist/collab/client.d.ts +38 -7
  448. package/dist/collab/client.js +41 -6
  449. package/dist/collab/client.js.map +1 -1
  450. package/dist/composer/ComposerAttachedReferences.cjs +119 -0
  451. package/dist/composer/ComposerAttachedReferences.cjs.map +1 -0
  452. package/dist/composer/ComposerAttachedReferences.d.ts +26 -0
  453. package/dist/composer/ComposerAttachedReferences.js +119 -0
  454. package/dist/composer/ComposerAttachedReferences.js.map +1 -0
  455. package/dist/composer/ComposerNamedAgents.cjs +63 -0
  456. package/dist/composer/ComposerNamedAgents.cjs.map +1 -0
  457. package/dist/composer/ComposerNamedAgents.d.ts +16 -0
  458. package/dist/composer/ComposerNamedAgents.js +63 -0
  459. package/dist/composer/ComposerNamedAgents.js.map +1 -0
  460. package/dist/composer/attached-references.cjs +159 -0
  461. package/dist/composer/attached-references.cjs.map +1 -0
  462. package/dist/composer/attached-references.d.ts +86 -0
  463. package/dist/composer/attached-references.js +159 -0
  464. package/dist/composer/attached-references.js.map +1 -0
  465. package/dist/composer/build-composed-message.cjs +14 -7
  466. package/dist/composer/build-composed-message.cjs.map +1 -1
  467. package/dist/composer/build-composed-message.d.ts +6 -1
  468. package/dist/composer/build-composed-message.js +14 -7
  469. package/dist/composer/build-composed-message.js.map +1 -1
  470. package/dist/composer/composer-handoff.cjs +6 -2
  471. package/dist/composer/composer-handoff.cjs.map +1 -1
  472. package/dist/composer/composer-handoff.d.ts +7 -1
  473. package/dist/composer/composer-handoff.js +6 -2
  474. package/dist/composer/composer-handoff.js.map +1 -1
  475. package/dist/composer/folder-upload.cjs +149 -0
  476. package/dist/composer/folder-upload.cjs.map +1 -0
  477. package/dist/composer/folder-upload.d.ts +79 -0
  478. package/dist/composer/folder-upload.js +149 -0
  479. package/dist/composer/folder-upload.js.map +1 -0
  480. package/dist/composer/index.d.ts +1 -1
  481. package/dist/composer/staged-message-metadata.cjs +12 -0
  482. package/dist/composer/staged-message-metadata.cjs.map +1 -0
  483. package/dist/composer/staged-message-metadata.d.ts +15 -0
  484. package/dist/composer/staged-message-metadata.js +12 -0
  485. package/dist/composer/staged-message-metadata.js.map +1 -0
  486. package/dist/composer/useAttachToChat.cjs +35 -0
  487. package/dist/composer/useAttachToChat.cjs.map +1 -0
  488. package/dist/composer/useAttachToChat.d.ts +54 -0
  489. package/dist/composer/useAttachToChat.js +35 -0
  490. package/dist/composer/useAttachToChat.js.map +1 -0
  491. package/dist/composer/useAttachedReferencesComposerProps.cjs +19 -0
  492. package/dist/composer/useAttachedReferencesComposerProps.cjs.map +1 -0
  493. package/dist/composer/useAttachedReferencesComposerProps.d.ts +12 -0
  494. package/dist/composer/useAttachedReferencesComposerProps.js +19 -0
  495. package/dist/composer/useAttachedReferencesComposerProps.js.map +1 -0
  496. package/dist/composer/useFileUpload.cjs +95 -7
  497. package/dist/composer/useFileUpload.cjs.map +1 -1
  498. package/dist/composer/useFileUpload.d.ts +21 -2
  499. package/dist/composer/useFileUpload.js +95 -7
  500. package/dist/composer/useFileUpload.js.map +1 -1
  501. package/dist/data/athena-api-error.cjs +125 -0
  502. package/dist/data/athena-api-error.cjs.map +1 -0
  503. package/dist/data/athena-api-error.d.ts +96 -0
  504. package/dist/data/athena-api-error.js +125 -0
  505. package/dist/data/athena-api-error.js.map +1 -0
  506. package/dist/data/athena-data-client.cjs +106 -0
  507. package/dist/data/athena-data-client.cjs.map +1 -0
  508. package/dist/data/athena-data-client.d.ts +74 -0
  509. package/dist/data/athena-data-client.js +106 -0
  510. package/dist/data/athena-data-client.js.map +1 -0
  511. package/dist/data/athena-member.cjs +93 -0
  512. package/dist/data/athena-member.cjs.map +1 -0
  513. package/dist/data/athena-member.d.ts +125 -0
  514. package/dist/data/athena-member.js +93 -0
  515. package/dist/data/athena-member.js.map +1 -0
  516. package/dist/data/athena-request.cjs +460 -0
  517. package/dist/data/athena-request.cjs.map +1 -0
  518. package/dist/data/athena-request.d.ts +120 -0
  519. package/dist/data/athena-request.js +460 -0
  520. package/dist/data/athena-request.js.map +1 -0
  521. package/dist/data/use-athena-fetch.cjs +14 -0
  522. package/dist/data/use-athena-fetch.cjs.map +1 -0
  523. package/dist/data/use-athena-fetch.d.ts +19 -0
  524. package/dist/data/use-athena-fetch.js +14 -0
  525. package/dist/data/use-athena-fetch.js.map +1 -0
  526. package/dist/data/use-athena-graphql.cjs +66 -0
  527. package/dist/data/use-athena-graphql.cjs.map +1 -0
  528. package/dist/data/use-athena-graphql.d.ts +56 -0
  529. package/dist/data/use-athena-graphql.js +66 -0
  530. package/dist/data/use-athena-graphql.js.map +1 -0
  531. package/dist/data/use-athena-rest.cjs +33 -0
  532. package/dist/data/use-athena-rest.cjs.map +1 -0
  533. package/dist/data/use-athena-rest.d.ts +21 -0
  534. package/dist/data/use-athena-rest.js +33 -0
  535. package/dist/data/use-athena-rest.js.map +1 -0
  536. package/dist/data/use-semantic-query.cjs +44 -0
  537. package/dist/data/use-semantic-query.cjs.map +1 -0
  538. package/dist/data/use-semantic-query.d.ts +92 -0
  539. package/dist/data/use-semantic-query.js +44 -0
  540. package/dist/data/use-semantic-query.js.map +1 -0
  541. package/dist/diagnostics/athena-diagnostics.cjs.map +1 -1
  542. package/dist/diagnostics/athena-diagnostics.d.ts +5 -1
  543. package/dist/diagnostics/athena-diagnostics.js.map +1 -1
  544. package/dist/diagnostics/errors.cjs +7 -0
  545. package/dist/diagnostics/errors.cjs.map +1 -1
  546. package/dist/diagnostics/errors.d.ts +7 -0
  547. package/dist/diagnostics/errors.js +7 -0
  548. package/dist/diagnostics/errors.js.map +1 -1
  549. package/dist/index.cjs +155 -11
  550. package/dist/index.cjs.map +1 -1
  551. package/dist/index.d.ts +72 -13
  552. package/dist/index.js +148 -4
  553. package/dist/index.js.map +1 -1
  554. package/dist/keryx-http/src/initial-sync.cjs +64 -16
  555. package/dist/keryx-http/src/initial-sync.cjs.map +1 -1
  556. package/dist/keryx-http/src/initial-sync.d.ts +31 -1
  557. package/dist/keryx-http/src/initial-sync.js +64 -16
  558. package/dist/keryx-http/src/initial-sync.js.map +1 -1
  559. package/dist/keryx-http/src/own-awareness.cjs +20 -0
  560. package/dist/keryx-http/src/own-awareness.cjs.map +1 -0
  561. package/dist/keryx-http/src/own-awareness.d.ts +50 -0
  562. package/dist/keryx-http/src/own-awareness.js +20 -0
  563. package/dist/keryx-http/src/own-awareness.js.map +1 -0
  564. package/dist/keryx-http/src/update-attributions.cjs +26 -1
  565. package/dist/keryx-http/src/update-attributions.cjs.map +1 -1
  566. package/dist/keryx-http/src/update-attributions.d.ts +10 -1
  567. package/dist/keryx-http/src/update-attributions.js +26 -1
  568. package/dist/keryx-http/src/update-attributions.js.map +1 -1
  569. package/dist/offline/chat-outbox.cjs +262 -26
  570. package/dist/offline/chat-outbox.cjs.map +1 -1
  571. package/dist/offline/chat-outbox.d.ts +90 -12
  572. package/dist/offline/chat-outbox.js +263 -27
  573. package/dist/offline/chat-outbox.js.map +1 -1
  574. package/dist/provider/AthenaProvider.cjs +60 -22
  575. package/dist/provider/AthenaProvider.cjs.map +1 -1
  576. package/dist/provider/AthenaProvider.d.ts +24 -8
  577. package/dist/provider/AthenaProvider.js +61 -23
  578. package/dist/provider/AthenaProvider.js.map +1 -1
  579. package/dist/react/package.json.cjs +1 -1
  580. package/dist/react/package.json.js +1 -1
  581. package/dist/references/src/anchors/parse.cjs +11 -1
  582. package/dist/references/src/anchors/parse.cjs.map +1 -1
  583. package/dist/references/src/anchors/parse.js +11 -1
  584. package/dist/references/src/anchors/parse.js.map +1 -1
  585. package/dist/references/src/anchors/schemas.d.ts +1 -0
  586. package/dist/references/src/anchors/serialize.cjs +1 -0
  587. package/dist/references/src/anchors/serialize.cjs.map +1 -1
  588. package/dist/references/src/anchors/serialize.js +1 -0
  589. package/dist/references/src/anchors/serialize.js.map +1 -1
  590. package/dist/references/src/anchors/types.cjs +5 -0
  591. package/dist/references/src/anchors/types.cjs.map +1 -1
  592. package/dist/references/src/anchors/types.d.ts +9 -0
  593. package/dist/references/src/anchors/types.js +5 -0
  594. package/dist/references/src/anchors/types.js.map +1 -1
  595. package/dist/references/src/attachable.cjs +149 -0
  596. package/dist/references/src/attachable.cjs.map +1 -0
  597. package/dist/references/src/attachable.d.ts +87 -0
  598. package/dist/references/src/attachable.js +149 -0
  599. package/dist/references/src/attachable.js.map +1 -0
  600. package/dist/references/src/schemas.d.ts +2 -0
  601. package/dist/runtime/StatewirePlanModeLaneSync.cjs +93 -0
  602. package/dist/runtime/StatewirePlanModeLaneSync.cjs.map +1 -0
  603. package/dist/runtime/StatewirePlanModeLaneSync.d.ts +34 -0
  604. package/dist/runtime/StatewirePlanModeLaneSync.js +93 -0
  605. package/dist/runtime/StatewirePlanModeLaneSync.js.map +1 -0
  606. package/dist/runtime/StatewireThreadConfigLaneSync.cjs +2 -0
  607. package/dist/runtime/StatewireThreadConfigLaneSync.cjs.map +1 -1
  608. package/dist/runtime/StatewireThreadConfigLaneSync.d.ts +4 -0
  609. package/dist/runtime/StatewireThreadConfigLaneSync.js +2 -0
  610. package/dist/runtime/StatewireThreadConfigLaneSync.js.map +1 -1
  611. package/dist/runtime/statewire-plan-mode.cjs +71 -0
  612. package/dist/runtime/statewire-plan-mode.cjs.map +1 -0
  613. package/dist/runtime/statewire-plan-mode.d.ts +88 -0
  614. package/dist/runtime/statewire-plan-mode.js +71 -0
  615. package/dist/runtime/statewire-plan-mode.js.map +1 -0
  616. package/dist/runtime/statewire-run-config.cjs +3 -1
  617. package/dist/runtime/statewire-run-config.cjs.map +1 -1
  618. package/dist/runtime/statewire-run-config.d.ts +7 -0
  619. package/dist/runtime/statewire-run-config.js +3 -1
  620. package/dist/runtime/statewire-run-config.js.map +1 -1
  621. package/dist/runtime/statewire-session-key.cjs +11 -5
  622. package/dist/runtime/statewire-session-key.cjs.map +1 -1
  623. package/dist/runtime/statewire-session-key.d.ts +22 -10
  624. package/dist/runtime/statewire-session-key.js +11 -5
  625. package/dist/runtime/statewire-session-key.js.map +1 -1
  626. package/dist/runtime/useAthenaStatewireRuntime.cjs +64 -9
  627. package/dist/runtime/useAthenaStatewireRuntime.cjs.map +1 -1
  628. package/dist/runtime/useAthenaStatewireRuntime.d.ts +26 -10
  629. package/dist/runtime/useAthenaStatewireRuntime.js +66 -11
  630. package/dist/runtime/useAthenaStatewireRuntime.js.map +1 -1
  631. package/dist/search/useAthenaAssets.cjs +394 -0
  632. package/dist/search/useAthenaAssets.cjs.map +1 -0
  633. package/dist/search/useAthenaAssets.d.ts +186 -0
  634. package/dist/search/useAthenaAssets.js +394 -0
  635. package/dist/search/useAthenaAssets.js.map +1 -0
  636. package/dist/sheet-range/index.cjs +4 -0
  637. package/dist/sheet-range/index.cjs.map +1 -1
  638. package/dist/sheet-range/index.d.ts +4 -2
  639. package/dist/sheet-range/index.js +4 -0
  640. package/dist/sheet-range/index.js.map +1 -1
  641. package/dist/sheet-range/query-range.cjs +102 -0
  642. package/dist/sheet-range/query-range.cjs.map +1 -0
  643. package/dist/sheet-range/query-range.d.ts +46 -0
  644. package/dist/sheet-range/query-range.js +102 -0
  645. package/dist/sheet-range/query-range.js.map +1 -0
  646. package/dist/styles.css +1 -1
  647. package/dist/subagents/index.cjs +49 -0
  648. package/dist/subagents/index.cjs.map +1 -0
  649. package/dist/subagents/index.d.ts +16 -0
  650. package/dist/subagents/index.js +49 -0
  651. package/dist/subagents/index.js.map +1 -0
  652. package/dist/subagents/lane-follow.cjs +19 -0
  653. package/dist/subagents/lane-follow.cjs.map +1 -0
  654. package/dist/subagents/lane-follow.d.ts +9 -0
  655. package/dist/subagents/lane-follow.js +19 -0
  656. package/dist/subagents/lane-follow.js.map +1 -0
  657. package/dist/subagents/lane-model.cjs +178 -0
  658. package/dist/subagents/lane-model.cjs.map +1 -0
  659. package/dist/subagents/lane-model.d.ts +140 -0
  660. package/dist/subagents/lane-model.js +178 -0
  661. package/dist/subagents/lane-model.js.map +1 -0
  662. package/dist/subagents/lane-parts.cjs +517 -0
  663. package/dist/subagents/lane-parts.cjs.map +1 -0
  664. package/dist/subagents/lane-parts.d.ts +130 -0
  665. package/dist/subagents/lane-parts.js +517 -0
  666. package/dist/subagents/lane-parts.js.map +1 -0
  667. package/dist/subagents/subagent-lane-group.cjs +215 -0
  668. package/dist/subagents/subagent-lane-group.cjs.map +1 -0
  669. package/dist/subagents/subagent-lane-group.d.ts +67 -0
  670. package/dist/subagents/subagent-lane-group.js +215 -0
  671. package/dist/subagents/subagent-lane-group.js.map +1 -0
  672. package/dist/subagents/subagent-transcript-drawer.cjs +431 -0
  673. package/dist/subagents/subagent-transcript-drawer.cjs.map +1 -0
  674. package/dist/subagents/subagent-transcript-drawer.d.ts +78 -0
  675. package/dist/subagents/subagent-transcript-drawer.js +431 -0
  676. package/dist/subagents/subagent-transcript-drawer.js.map +1 -0
  677. package/dist/subagents/task-subagent-group.cjs +115 -0
  678. package/dist/subagents/task-subagent-group.cjs.map +1 -0
  679. package/dist/subagents/task-subagent-group.d.ts +36 -0
  680. package/dist/subagents/task-subagent-group.js +115 -0
  681. package/dist/subagents/task-subagent-group.js.map +1 -0
  682. package/dist/subagents/use-omitted-images-in-view.cjs +68 -0
  683. package/dist/subagents/use-omitted-images-in-view.cjs.map +1 -0
  684. package/dist/subagents/use-omitted-images-in-view.d.ts +21 -0
  685. package/dist/subagents/use-omitted-images-in-view.js +68 -0
  686. package/dist/subagents/use-omitted-images-in-view.js.map +1 -0
  687. package/dist/threads/Inbox.cjs +2 -2
  688. package/dist/threads/Inbox.cjs.map +1 -1
  689. package/dist/threads/SessionList.cjs +6 -6
  690. package/dist/threads/SessionList.cjs.map +1 -1
  691. package/dist/threads/SessionsPage.cjs +13 -7
  692. package/dist/threads/SessionsPage.cjs.map +1 -1
  693. package/dist/threads/SessionsPage.d.ts +10 -1
  694. package/dist/threads/SessionsPage.js +9 -3
  695. package/dist/threads/SessionsPage.js.map +1 -1
  696. package/dist/threads/session-list-model.cjs.map +1 -1
  697. package/dist/threads/session-list-model.d.ts +2 -1
  698. package/dist/threads/session-list-model.js.map +1 -1
  699. package/dist/threads/session-row-parts.cjs +3 -3
  700. package/dist/threads/session-row-parts.cjs.map +1 -1
  701. package/dist/threads/sessions-page-model.cjs +13 -5
  702. package/dist/threads/sessions-page-model.cjs.map +1 -1
  703. package/dist/threads/sessions-page-model.d.ts +7 -0
  704. package/dist/threads/sessions-page-model.js +11 -3
  705. package/dist/threads/sessions-page-model.js.map +1 -1
  706. package/dist/threads/sessions-page-storage.cjs +8 -8
  707. package/dist/threads/sessions-page-storage.cjs.map +1 -1
  708. package/dist/threads/sessions-page-storage.d.ts +5 -1
  709. package/dist/threads/sessions-page-storage.js +8 -8
  710. package/dist/threads/sessions-page-storage.js.map +1 -1
  711. package/dist/threads/statewire-thread-list.cjs +14 -2
  712. package/dist/threads/statewire-thread-list.cjs.map +1 -1
  713. package/dist/threads/statewire-thread-list.d.ts +11 -2
  714. package/dist/threads/statewire-thread-list.js +14 -2
  715. package/dist/threads/statewire-thread-list.js.map +1 -1
  716. package/dist/threads/use-athena-sessions.cjs +1 -0
  717. package/dist/threads/use-athena-sessions.cjs.map +1 -1
  718. package/dist/threads/use-athena-sessions.d.ts +7 -0
  719. package/dist/threads/use-athena-sessions.js +1 -0
  720. package/dist/threads/use-athena-sessions.js.map +1 -1
  721. package/dist/threads/use-athena-thread-agent.cjs +31 -0
  722. package/dist/threads/use-athena-thread-agent.cjs.map +1 -0
  723. package/dist/threads/use-athena-thread-agent.d.ts +38 -0
  724. package/dist/threads/use-athena-thread-agent.js +31 -0
  725. package/dist/threads/use-athena-thread-agent.js.map +1 -0
  726. package/dist/threads/use-athena-thread-plan-mode.cjs +18 -0
  727. package/dist/threads/use-athena-thread-plan-mode.cjs.map +1 -0
  728. package/dist/threads/use-athena-thread-plan-mode.d.ts +18 -0
  729. package/dist/threads/use-athena-thread-plan-mode.js +18 -0
  730. package/dist/threads/use-athena-thread-plan-mode.js.map +1 -0
  731. package/dist/threads/use-rest-conversation-history.d.ts +1 -0
  732. package/dist/tools/agent-creations.cjs +97 -0
  733. package/dist/tools/agent-creations.cjs.map +1 -0
  734. package/dist/tools/agent-creations.d.ts +38 -0
  735. package/dist/tools/agent-creations.js +97 -0
  736. package/dist/tools/agent-creations.js.map +1 -0
  737. package/dist/tools/agent-highlights.cjs +100 -0
  738. package/dist/tools/agent-highlights.cjs.map +1 -0
  739. package/dist/tools/agent-highlights.d.ts +57 -0
  740. package/dist/tools/agent-highlights.js +100 -0
  741. package/dist/tools/agent-highlights.js.map +1 -0
  742. package/dist/tools/append-document-tool-ui.cjs +1 -0
  743. package/dist/tools/append-document-tool-ui.cjs.map +1 -1
  744. package/dist/tools/append-document-tool-ui.d.ts +7 -0
  745. package/dist/tools/append-document-tool-ui.js +2 -1
  746. package/dist/tools/append-document-tool-ui.js.map +1 -1
  747. package/dist/tools/auto-open-tools.cjs +144 -71
  748. package/dist/tools/auto-open-tools.cjs.map +1 -1
  749. package/dist/tools/auto-open-tools.d.ts +131 -1
  750. package/dist/tools/auto-open-tools.js +145 -72
  751. package/dist/tools/auto-open-tools.js.map +1 -1
  752. package/dist/tools/browser-tool-uis.cjs +594 -0
  753. package/dist/tools/browser-tool-uis.cjs.map +1 -0
  754. package/dist/tools/browser-tool-uis.d.ts +8 -0
  755. package/dist/tools/browser-tool-uis.js +594 -0
  756. package/dist/tools/browser-tool-uis.js.map +1 -0
  757. package/dist/tools/computer-asset-tool-uis.cjs +313 -0
  758. package/dist/tools/computer-asset-tool-uis.cjs.map +1 -0
  759. package/dist/tools/computer-asset-tool-uis.d.ts +5 -0
  760. package/dist/tools/computer-asset-tool-uis.js +313 -0
  761. package/dist/tools/computer-asset-tool-uis.js.map +1 -0
  762. package/dist/tools/document-edit-tool-uis.cjs +218 -0
  763. package/dist/tools/document-edit-tool-uis.cjs.map +1 -0
  764. package/dist/tools/document-edit-tool-uis.d.ts +40 -0
  765. package/dist/tools/document-edit-tool-uis.js +218 -0
  766. package/dist/tools/document-edit-tool-uis.js.map +1 -0
  767. package/dist/tools/drive-tool-uis.cjs +429 -0
  768. package/dist/tools/drive-tool-uis.cjs.map +1 -0
  769. package/dist/tools/drive-tool-uis.d.ts +121 -0
  770. package/dist/tools/drive-tool-uis.js +429 -0
  771. package/dist/tools/drive-tool-uis.js.map +1 -0
  772. package/dist/tools/email-calendar-tool-uis.cjs +789 -0
  773. package/dist/tools/email-calendar-tool-uis.cjs.map +1 -0
  774. package/dist/tools/email-calendar-tool-uis.d.ts +129 -0
  775. package/dist/tools/email-calendar-tool-uis.js +789 -0
  776. package/dist/tools/email-calendar-tool-uis.js.map +1 -0
  777. package/dist/tools/ontology-tool-uis.cjs +83 -0
  778. package/dist/tools/ontology-tool-uis.cjs.map +1 -0
  779. package/dist/tools/ontology-tool-uis.d.ts +9 -0
  780. package/dist/tools/ontology-tool-uis.js +83 -0
  781. package/dist/tools/ontology-tool-uis.js.map +1 -0
  782. package/dist/tools/orchestration-tool-uis.cjs +586 -0
  783. package/dist/tools/orchestration-tool-uis.cjs.map +1 -0
  784. package/dist/tools/orchestration-tool-uis.d.ts +141 -0
  785. package/dist/tools/orchestration-tool-uis.js +586 -0
  786. package/dist/tools/orchestration-tool-uis.js.map +1 -0
  787. package/dist/tools/presentation-edit-tool-uis.cjs +516 -0
  788. package/dist/tools/presentation-edit-tool-uis.cjs.map +1 -0
  789. package/dist/tools/presentation-edit-tool-uis.d.ts +73 -0
  790. package/dist/tools/presentation-edit-tool-uis.js +516 -0
  791. package/dist/tools/presentation-edit-tool-uis.js.map +1 -0
  792. package/dist/tools/project-tool-uis.cjs +213 -0
  793. package/dist/tools/project-tool-uis.cjs.map +1 -0
  794. package/dist/tools/project-tool-uis.d.ts +14 -0
  795. package/dist/tools/project-tool-uis.js +213 -0
  796. package/dist/tools/project-tool-uis.js.map +1 -0
  797. package/dist/tools/sandbox-tool-uis.cjs +491 -0
  798. package/dist/tools/sandbox-tool-uis.cjs.map +1 -0
  799. package/dist/tools/sandbox-tool-uis.d.ts +116 -0
  800. package/dist/tools/sandbox-tool-uis.js +491 -0
  801. package/dist/tools/sandbox-tool-uis.js.map +1 -0
  802. package/dist/tools/sheet-query-tool-ui.cjs +138 -0
  803. package/dist/tools/sheet-query-tool-ui.cjs.map +1 -0
  804. package/dist/tools/sheet-query-tool-ui.d.ts +15 -0
  805. package/dist/tools/sheet-query-tool-ui.js +138 -0
  806. package/dist/tools/sheet-query-tool-ui.js.map +1 -0
  807. package/dist/tools/studio-screenshot-tool-uis.cjs +262 -0
  808. package/dist/tools/studio-screenshot-tool-uis.cjs.map +1 -0
  809. package/dist/tools/studio-screenshot-tool-uis.d.ts +52 -0
  810. package/dist/tools/studio-screenshot-tool-uis.js +262 -0
  811. package/dist/tools/studio-screenshot-tool-uis.js.map +1 -0
  812. package/dist/tools/subagent-task-tool-ui.cjs +24 -475
  813. package/dist/tools/subagent-task-tool-ui.cjs.map +1 -1
  814. package/dist/tools/subagent-task-tool-ui.d.ts +19 -103
  815. package/dist/tools/subagent-task-tool-ui.js +28 -479
  816. package/dist/tools/subagent-task-tool-ui.js.map +1 -1
  817. package/dist/tools/tool-summary.cjs +36 -0
  818. package/dist/tools/tool-summary.cjs.map +1 -1
  819. package/dist/tools/tool-summary.js +36 -0
  820. package/dist/tools/tool-summary.js.map +1 -1
  821. package/dist/tools/tool-uis.cjs +181 -53
  822. package/dist/tools/tool-uis.cjs.map +1 -1
  823. package/dist/tools/tool-uis.d.ts +40 -0
  824. package/dist/tools/tool-uis.js +183 -55
  825. package/dist/tools/tool-uis.js.map +1 -1
  826. package/dist/typed-interrupts/index.cjs +15 -0
  827. package/dist/typed-interrupts/index.cjs.map +1 -0
  828. package/dist/typed-interrupts/index.d.ts +20 -0
  829. package/dist/typed-interrupts/index.js +15 -0
  830. package/dist/typed-interrupts/index.js.map +1 -0
  831. package/dist/version.cjs +4 -0
  832. package/dist/version.cjs.map +1 -1
  833. package/dist/version.d.ts +9 -0
  834. package/dist/version.js +4 -0
  835. package/dist/version.js.map +1 -1
  836. package/dist/workbench/live-desktop-api.cjs +2 -1
  837. package/dist/workbench/live-desktop-api.cjs.map +1 -1
  838. package/dist/workbench/live-desktop-api.js +2 -1
  839. package/dist/workbench/live-desktop-api.js.map +1 -1
  840. package/dist/workbench/session-workbench-panes.cjs +6 -6
  841. package/dist/workbench/session-workbench-panes.cjs.map +1 -1
  842. package/dist/workbench/session-workspace-api.cjs +7 -2
  843. package/dist/workbench/session-workspace-api.cjs.map +1 -1
  844. package/dist/workbench/session-workspace-api.d.ts +10 -0
  845. package/dist/workbench/session-workspace-api.js +7 -2
  846. package/dist/workbench/session-workspace-api.js.map +1 -1
  847. package/package.json +28 -6
  848. package/dist/agent-runtime/src/chat-outbox-store.cjs +0 -510
  849. package/dist/agent-runtime/src/chat-outbox-store.cjs.map +0 -1
  850. package/dist/agent-runtime/src/chat-outbox-store.d.ts +0 -210
  851. package/dist/agent-runtime/src/chat-outbox-store.js +0 -510
  852. package/dist/agent-runtime/src/chat-outbox-store.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"subagents.js","sources":["../../../../agent-runtime/src/subagents.ts"],"sourcesContent":["/**\n * Subagent discovery: every subagent lane a deep-agent thread has spawned, as\n * the card view model the surfaces that draw subagent lanes render. Two\n * dispatch paths feed lanes keyed by dispatch id:\n *\n * - top-level `task` tool calls, read from the call's own tool-call part\n * ({@link taskSubagentsOfTurn}): the part's result and `isPreliminary` say\n * where the lane is, and its `messages` (the nested thread\n * `createSubagentTranscriptConversionCache` converts) are the transcript;\n * - in-eval `task()` dispatches ({@link deriveEvalSubagents}), whose only\n * signals are the live `ptc_subagents` state channel and the summaries a\n * finished `eval` ToolMessage persists in `artifact.ptc_subagents`.\n */\nimport {\n getExternalStoreMessages,\n type ThreadMessage,\n type ToolCallMessagePart,\n} from '@assistant-ui/core';\nimport type { LangChainMessage, LangChainToolCall } from '@assistant-ui/react-langgraph';\nimport { useAuiState } from '@assistant-ui/store';\nimport { useMemo } from 'react';\nimport {\n DEEP_AGENT_LANE_USAGE_KEY,\n DEEP_AGENT_TRUNCATED_LANE_KEY,\n} from './generated/runconfig-contract';\nimport type { PendingActionRequest } from './interrupts';\nimport { getMessageText } from './message-text';\nimport { convertSubagentTranscript, withRepeatedResult } from './subagent-transcripts';\nimport { EVAL_TOOL_NAME, TASK_TOOL_NAME } from './tool-names';\nimport type { PtcSubagentEntry, Todo } from './types';\n\n/**\n * Where a subagent lane is:\n *\n * - `queued` — the dispatch has not started: a `task` call with no result yet\n * (waiting for a dispatch slot or an approval; the backend shows the running\n * card once the dispatch holds its slot), or an in-eval dispatch waiting for\n * one of the bridge's concurrency slots.\n * - `running` — a `task` call's result is still the backend's running\n * placeholder (its part is `isPreliminary`), and the nested transcript fills\n * in live; or an in-eval dispatch's lifecycle says it runs.\n * - `complete` / `error` — the real result replaced the placeholder; `error`\n * when it is an error result.\n */\nexport type SubagentStatus = 'queued' | 'running' | 'complete' | 'error';\n\n/** True for the settled lifecycle states (`complete` / `error`). */\nexport function isTerminalSubagentStatus(status: SubagentStatus): boolean {\n return status === 'complete' || status === 'error';\n}\n\n/** Aggregate lane lifecycle counts for one fan-out (orchestration strip + header chip). */\nexport interface SubagentStatusCounts {\n total: number;\n queued: number;\n running: number;\n complete: number;\n failed: number;\n /** complete + failed — the settled count progress displays use. */\n terminal: number;\n}\n\nexport function countSubagentStatuses(\n snapshots: readonly SubagentDiscoverySnapshot[]\n): SubagentStatusCounts {\n const counts: SubagentStatusCounts = {\n total: snapshots.length,\n queued: 0,\n running: 0,\n complete: 0,\n failed: 0,\n terminal: 0,\n };\n for (const snapshot of snapshots) {\n if (snapshot.status === 'queued') counts.queued += 1;\n else if (snapshot.status === 'running') counts.running += 1;\n else if (snapshot.status === 'complete') counts.complete += 1;\n else counts.failed += 1;\n }\n counts.terminal = counts.complete + counts.failed;\n return counts;\n}\n\n/**\n * Discovery snapshot for one subagent invocation. Mirrors LangChain's\n * `SubagentDiscoverySnapshot`: `id` is the `task` tool-call id that spawned the\n * subagent (the dispatch id for an in-eval dispatch), so cards nest under the\n * coordinator turn that delegated the work.\n */\nexport interface SubagentDiscoverySnapshot {\n /** The `task` tool-call id that spawned the subagent. */\n id: string;\n /** Subagent type/name, from the `task` call's `subagent_type` arg. */\n name: string;\n /** The one-line task brief from the `task` call's `description` arg. */\n description: string;\n /** Lifecycle state — see {@link SubagentStatus}. */\n status: SubagentStatus;\n /** The call's result text (empty while it is the running placeholder). */\n output?: string;\n /** Number of nested tool calls the subagent made. */\n toolCallCount: number;\n /**\n * The subagent's transcript as a nested thread: a `task` part's native\n * `messages`, or an in-eval dispatch's live transcript converted the same way.\n */\n messages: readonly ThreadMessage[];\n /** Messages in the transcript as the wire carries them, before conversion joins a turn's steps. */\n messageCount: number;\n /**\n * Nested messages the wire left off: a cut card carries its newest steps\n * ({@link readTruncatedLane}) — a running card always, a finished one on a\n * version-2 view — and the rest pages in through `history/lane`; an in-eval\n * dispatch's streamed transcript is cut the same way, running or finished.\n * Absent when the transcript rides whole.\n */\n omittedMessageCount?: number;\n /**\n * Where the lane's steps ride, what `history/lane` pages the rest of the lane\n * under (`useDeepAgentLaneHistory`): a `task` lane's card, an in-eval lane's\n * registry entry while it streams its steps, or, once they no longer ride,\n * its subagent checkpoint (`checkpointed`), when agora recorded where that is\n * (`ns`). Absent for any other in-eval lane with no streamed steps (a summary\n * written before agora recorded the namespace, an older host).\n */\n source?: SubagentLaneSource;\n /** The subagent's own plan, nested by the backend on the task artifact (`subgraph_state.todos`). */\n todos?: Todo[];\n /** The newest tool call in the transcript — the card's \"last action\" ticker. */\n lastToolCall?: LangChainToolCall;\n /** The newest assistant text in the transcript — the card's thought preview. */\n currentText: string;\n /**\n * The `eval` tool-call id that dispatched this subagent, when it was spawned\n * from INSIDE the code interpreter (`task()` in the REPL) rather than by a\n * top-level `task` tool call. The eval card uses it to render lanes for its\n * own dispatches.\n */\n evalId?: string;\n /**\n * Backend-reported runtime for a finished in-eval dispatch (from the terminal\n * lifecycle event). Authoritative over client-side timing — it survives a page\n * refresh, where local first-seen timestamps are gone.\n */\n durationMs?: number;\n /** The model that produced the transcript, from its newest assistant turn's model stamp. */\n model?: string;\n /**\n * The lane's token use: the whole lane's as the host counts it\n * (`DEEP_AGENT_LANE_USAGE_KEY`), else the sum of the native step usage\n * (`metadata.steps[].usage`) of the steps the transcript holds. Absent while\n * no step reports any.\n */\n usage?: SubagentTokenUsage;\n}\n\n/** A subagent lane's token use. */\nexport interface SubagentTokenUsage {\n /** Input tokens, the prompt cache's reads and writes included. */\n readonly inputTokens: number;\n readonly outputTokens: number;\n /**\n * Less than the lane will have used: the lane still runs (its newest step may\n * not have reported yet), or no host total arrived and the sum covers only\n * the steps held of a lane cut to its newest ones.\n */\n readonly partial: boolean;\n}\n\n/** Input and output tokens of some model calls. */\nexport interface TokenCounts {\n readonly inputTokens: number;\n readonly outputTokens: number;\n}\n\nfunction subagentNameFromArgs(args: Readonly<Record<string, unknown>> | undefined): string {\n if (!args) return 'subagent';\n return String(args.subagent_type ?? args.subagentType ?? args.subagent ?? 'subagent');\n}\n\n/**\n * The subagent's streamed transcript as the wire carries it, read from a task\n * ToolMessage's `artifact.subgraph_state.messages` (the shape the backend nests\n * it under — see the route's `_subagent_subgraph_state`).\n */\nexport function nestedMessagesFromArtifact(artifact: unknown): LangChainMessage[] {\n const a = artifact as { subgraph_state?: { messages?: LangChainMessage[] } } | undefined;\n return a?.subgraph_state?.messages ?? [];\n}\n\n/** What the wire left off a cut `task` card's nested transcript. */\nexport interface TruncatedLane {\n /** Nested messages the host holds for the lane. */\n messages: number;\n /** Tool calls across all of them. */\n toolCalls: number;\n /**\n * The card is a finished lane's, cut for a version-2 view. Only a host that\n * serves `history/lane` cuts a finished card.\n */\n finished: boolean;\n}\n\n/**\n * Where a lane's steps ride, and what `history/lane` pages the rest of them\n * under: a `task` lane's card, by its message id, or an in-eval dispatch's\n * `ptc_subagents` registry entry, by its dispatch id.\n */\nexport type SubagentLaneSource = {\n /** The steps as the wire carries them (a card's report restored, {@link withRepeatedResult}). */\n readonly transcript: readonly LangChainMessage[];\n /** The cut marker; absent while every step rides. */\n readonly truncated?: TruncatedLane;\n /**\n * No steps ride, and `history/lane {lane}` pages the subagent's own steps\n * from its checkpoint: an in-eval lane a later run in this activation left\n * only its summary and `ns`, or a reopened session's lane (its registry gone,\n * the summary its eval persisted records `ns`).\n */\n readonly checkpointed?: true;\n} & (\n | {\n /** The card's message id: the running placeholder's, then the result's. */\n readonly messageId: string;\n readonly lane?: undefined;\n }\n | {\n /** The dispatch id: the in-eval lane's registry key. */\n readonly lane: string;\n readonly messageId?: undefined;\n }\n);\n\nconst isCount = (value: unknown): value is number =>\n typeof value === 'number' && Number.isInteger(value) && value >= 0;\n\n/**\n * The cut marker off a `task` card's raw wire message: the host carries only\n * the lane's newest nested steps and names the whole transcript here\n * (`DEEP_AGENT_TRUNCATED_LANE_KEY`), on a running card and, for a version-2\n * view, on a finished one. `null` when the transcript rides whole.\n */\nexport function readTruncatedLane(toolMessage: unknown): TruncatedLane | null {\n if (typeof toolMessage !== 'object' || toolMessage === null) return null;\n const marker = (toolMessage as Record<string, unknown>)[DEEP_AGENT_TRUNCATED_LANE_KEY];\n if (typeof marker !== 'object' || marker === null) return null;\n const { messages, tool_calls: toolCalls, finished } = marker as Record<string, unknown>;\n return isCount(messages) && isCount(toolCalls)\n ? { messages, toolCalls, finished: finished === true }\n : null;\n}\n\n/**\n * The whole lane's token use the host carries on a `task` card's raw wire\n * message or an in-eval lane's `ptc_subagents` entry\n * (`DEEP_AGENT_LANE_USAGE_KEY`), however much of the lane the wire carries.\n * `null` when it carries none (an older host, or no step reported usage).\n */\nexport function readLaneUsage(wire: unknown): TokenCounts | null {\n if (typeof wire !== 'object' || wire === null) return null;\n const usage = (wire as Record<string, unknown>)[DEEP_AGENT_LANE_USAGE_KEY];\n if (typeof usage !== 'object' || usage === null) return null;\n const { input_tokens: inputTokens, output_tokens: outputTokens } = usage as Record<\n string,\n unknown\n >;\n return isCount(inputTokens) && isCount(outputTokens) ? { inputTokens, outputTokens } : null;\n}\n\n/**\n * A lane's token use: the host's total when it sent one, else what the native\n * steps of the transcript held add up to, partial while the lane runs or when\n * that transcript is cut. `undefined` while neither counts anything.\n */\nfunction laneTokenUsage(\n wire: unknown,\n steps: TokenCounts | undefined,\n status: SubagentStatus,\n cut: boolean\n): SubagentTokenUsage | undefined {\n const settled = isTerminalSubagentStatus(status);\n const whole = readLaneUsage(wire);\n if (whole !== null) return { ...whole, partial: !settled };\n return steps === undefined ? undefined : { ...steps, partial: !settled || cut };\n}\n\nconst transcriptStepUsageCache = new WeakMap<readonly ThreadMessage[], TokenCounts | null>();\n\n/**\n * What the model calls of a converted transcript used, from assistant-ui's\n * native step usage (`metadata.steps[].usage`, one step per model call a turn\n * joined). `undefined` when no step reports usage. Memoized per transcript\n * array, which the conversion caches keep while the transcript is unchanged.\n */\nexport function transcriptStepUsage(messages: readonly ThreadMessage[]): TokenCounts | undefined {\n const cached = transcriptStepUsageCache.get(messages);\n if (cached !== undefined) return cached ?? undefined;\n let inputTokens = 0;\n let outputTokens = 0;\n let counted = false;\n for (const message of messages) {\n for (const step of message.metadata.steps ?? []) {\n if (step.usage === undefined) continue;\n inputTokens += step.usage.inputTokens;\n outputTokens += step.usage.outputTokens;\n counted = true;\n }\n }\n const usage = counted ? { inputTokens, outputTokens } : null;\n transcriptStepUsageCache.set(messages, usage);\n return usage ?? undefined;\n}\n\n/**\n * The subagent's own plan, read from a task ToolMessage's\n * `artifact.subgraph_state.todos` (the backend mirrors the subagent's isolated\n * `todos` state channel there — see the route's `_forward_subagent_todos`).\n * `undefined` (not `[]`) when the subagent never wrote a plan, so the UI can\n * distinguish \"no plan\" from \"plan with zero items\".\n */\nexport function nestedTodosFromArtifact(artifact: unknown): Todo[] | undefined {\n const a = artifact as { subgraph_state?: { todos?: unknown } } | undefined;\n const todos = a?.subgraph_state?.todos;\n return Array.isArray(todos) ? (todos as Todo[]) : undefined;\n}\n\n/**\n * The persisted in-eval dispatch summaries from an `eval` ToolMessage's\n * `artifact.ptc_subagents` (written by the backend when the eval ends). Unlike\n * the live `ptc_subagents` state channel — which dies with the stream — these\n * survive checkpoint reload, so reopened sessions can still render each\n * dispatch's terminal status, duration, output, and error.\n */\nexport function ptcSubagentsFromArtifact(artifact: unknown): PtcSubagentEntry[] {\n const a = artifact as { ptc_subagents?: unknown } | undefined;\n const entries = a?.ptc_subagents;\n if (!Array.isArray(entries)) return [];\n return entries.filter(\n (entry): entry is PtcSubagentEntry =>\n !!entry &&\n typeof entry === 'object' &&\n typeof (entry as { id?: unknown }).id === 'string' &&\n !!(entry as { id?: string }).id\n );\n}\n\nconst inEvalDispatchCounts = new WeakMap<object, number>();\n\n/**\n * How many subagents an `eval` call delegated to from inside the interpreter\n * (its `task()` dispatches), read off the call's own artifact: the persisted\n * dispatch summaries (`artifact.ptc_subagents`, one per dispatch id), else the\n * `task` sub-calls its PTC log records (a running call's placeholder, or a\n * backend that persists no summaries). Counted once per artifact object, so a\n * settled call's count costs nothing when its turn is read again.\n */\nexport function countInEvalDispatches(artifact: unknown): number {\n if (typeof artifact !== 'object' || artifact === null) return 0;\n const cached = inEvalDispatchCounts.get(artifact);\n if (cached !== undefined) return cached;\n const summaries = new Set(ptcSubagentsFromArtifact(artifact).map((entry) => entry.id));\n let count = summaries.size;\n if (count === 0) {\n const dispatches = new Set<string>();\n for (const message of nestedMessagesFromArtifact(artifact)) {\n if (message.type !== 'ai' || !message.tool_calls) continue;\n for (const call of message.tool_calls) {\n if (call.name === TASK_TOOL_NAME && call.id) dispatches.add(call.id);\n }\n }\n count = dispatches.size;\n }\n inEvalDispatchCounts.set(artifact, count);\n return count;\n}\n\n/**\n * What one transcript contributes to a lane: the newest assistant text\n * (thought preview), the newest tool call and the count (\"last action\"\n * ticker), the producing model, and the plan recovered from the newest\n * `write_todos` call — the fallback for in-eval lanes, whose isolated `todos`\n * state channel never reaches the wire (the task path nests todos on the\n * artifact instead); the call args carry the same list, so the progress ring\n * can still fill. A pure function of the transcript array.\n */\ninterface TranscriptDerivation {\n currentText: string;\n model: string | undefined;\n lastToolCall: LangChainToolCall | undefined;\n toolCallCount: number;\n todos: Todo[] | undefined;\n}\n\nconst EMPTY_TRANSCRIPT_DERIVATION: TranscriptDerivation = {\n currentText: '',\n model: undefined,\n lastToolCall: undefined,\n toolCallCount: 0,\n todos: undefined,\n};\n\n/**\n * Per-transcript cache for {@link deriveTranscript}: a lane's converted\n * transcript keeps its array while the lane does not change (the conversion\n * caches hand back the previous array), so only lanes still streaming are\n * read again.\n */\nconst transcriptDerivationCache = new WeakMap<readonly ThreadMessage[], TranscriptDerivation>();\n\nfunction deriveTranscript(transcript: readonly ThreadMessage[]): TranscriptDerivation {\n if (transcript.length === 0) return EMPTY_TRANSCRIPT_DERIVATION;\n const cached = transcriptDerivationCache.get(transcript);\n if (cached !== undefined) return cached;\n let currentText = '';\n let model: string | undefined;\n let lastToolCall: LangChainToolCall | undefined;\n let toolCallCount = 0;\n let todos: Todo[] | undefined;\n for (const message of transcript) {\n if (message.role !== 'assistant') continue;\n // A joined turn's `metadata.custom` merges its steps' stamps, the later\n // step's winning (`joinExternalMessages`), so this is the newest stamp.\n const turnModel: unknown = message.metadata?.custom?.model;\n if (typeof turnModel === 'string' && turnModel) model = turnModel;\n for (const part of message.content) {\n if (part.type === 'text') {\n if (part.text) currentText = part.text;\n continue;\n }\n if (part.type !== 'tool-call') continue;\n toolCallCount += 1;\n lastToolCall = { id: part.toolCallId, name: part.toolName, args: part.args };\n if (part.toolName !== 'write_todos') continue;\n const list: unknown = part.args.todos;\n if (Array.isArray(list)) todos = list as Todo[];\n }\n }\n const derivation: TranscriptDerivation = {\n currentText,\n model,\n lastToolCall,\n toolCallCount,\n todos,\n };\n transcriptDerivationCache.set(transcript, derivation);\n return derivation;\n}\n\nconst NO_TRANSCRIPT: readonly ThreadMessage[] = [];\n\n/**\n * The lane of one `task` tool-call part. `toolMessage` is the raw ToolMessage\n * answering it, which carries the wire's cut marker for a running lane.\n */\nfunction taskSubagent(\n part: ToolCallMessagePart,\n toolMessage: LangChainMessage | undefined\n): SubagentDiscoverySnapshot {\n const args: Readonly<Record<string, unknown>> = part.args;\n const transcript = part.messages ?? NO_TRANSCRIPT;\n const derived = deriveTranscript(transcript);\n const messageCount = nestedMessagesFromArtifact(part.artifact).length;\n const lane = readTruncatedLane(toolMessage);\n const todos = nestedTodosFromArtifact(part.artifact);\n const status: SubagentStatus =\n part.result === undefined\n ? 'queued'\n : part.isPreliminary === true\n ? 'running'\n : part.isError === true\n ? 'error'\n : 'complete';\n const usage = laneTokenUsage(\n toolMessage,\n transcriptStepUsage(transcript),\n status,\n lane !== null && lane.messages > messageCount\n );\n return {\n id: part.toolCallId,\n name: subagentNameFromArgs(args),\n description: typeof args.description === 'string' ? args.description : '',\n status,\n ...(part.result !== undefined && { output: getMessageText({ content: part.result }) }),\n toolCallCount: Math.max(derived.toolCallCount, lane?.toolCalls ?? 0),\n messages: transcript,\n messageCount,\n ...(lane !== null && { omittedMessageCount: Math.max(0, lane.messages - messageCount) }),\n ...(typeof toolMessage?.id === 'string' && {\n source: {\n messageId: toolMessage.id,\n transcript: withRepeatedResult(nestedMessagesFromArtifact(part.artifact), part.result),\n ...(lane !== null && { truncated: lane }),\n },\n }),\n ...(todos !== undefined && { todos }),\n ...(derived.lastToolCall !== undefined && { lastToolCall: derived.lastToolCall }),\n currentText: derived.currentText,\n ...(derived.model !== undefined && { model: derived.model }),\n ...(usage !== undefined && { usage }),\n };\n}\n\n/** The raw ToolMessage answering each tool call of a converted turn, from the sources bound to it. */\nfunction toolMessagesOfTurn(message: ThreadMessage): Map<string, LangChainMessage> {\n const byCall = new Map<string, LangChainMessage>();\n for (const source of getExternalStoreMessages<LangChainMessage>(message)) {\n if (source.type === 'tool') byCall.set(source.tool_call_id, source);\n }\n return byCall;\n}\n\n/**\n * Per-part lane cache: a re-converted turn keeps the part object of every call\n * whose ToolMessage did not change (the conversion cache's `keepUnchangedParts`),\n * so a streaming lane re-derives only itself.\n */\nconst taskSubagentByPart = new WeakMap<ToolCallMessagePart, SubagentDiscoverySnapshot>();\nconst taskSubagentsByTurn = new WeakMap<ThreadMessage, ReadonlyMap<string, SubagentDiscoverySnapshot>>();\n\n/**\n * The lane of every `task` call in one converted turn (a `ThreadMessage`, or the\n * message state assistant-ui publishes for it), keyed by tool-call id in call\n * order. Memoized per turn and per part.\n */\nexport function taskSubagentsOfTurn(\n message: ThreadMessage\n): ReadonlyMap<string, SubagentDiscoverySnapshot> {\n const cached = taskSubagentsByTurn.get(message);\n if (cached !== undefined) return cached;\n const lanes = new Map<string, SubagentDiscoverySnapshot>();\n if (message.role === 'assistant') {\n let toolMessages: Map<string, LangChainMessage> | null = null;\n for (const part of message.content) {\n if (part.type !== 'tool-call' || part.toolName !== TASK_TOOL_NAME) continue;\n let lane = taskSubagentByPart.get(part);\n if (lane === undefined) {\n toolMessages ??= toolMessagesOfTurn(message);\n lane = taskSubagent(part, toolMessages.get(part.toolCallId));\n taskSubagentByPart.set(part, lane);\n }\n lanes.set(part.toolCallId, lane);\n }\n }\n taskSubagentsByTurn.set(message, lanes);\n return lanes;\n}\n\n/** The lane of every `task` call in a converted thread, in transcript order. */\nexport function taskSubagentsOfThread(\n messages: readonly ThreadMessage[]\n): SubagentDiscoverySnapshot[] {\n return messages.flatMap((message) => [...taskSubagentsOfTurn(message).values()]);\n}\n\n/**\n * Point a lane at an in-eval dispatch's live transcript, converted into a nested\n * thread, with the live fields it derives. Never regresses a known tool-call\n * count: a countless later event must not reset a lane to \"0 tool calls\".\n */\nfunction applyLaneTranscript(\n snap: SubagentDiscoverySnapshot,\n transcript: readonly LangChainMessage[]\n): void {\n snap.messages = convertSubagentTranscript(transcript, snap.status === 'running');\n snap.messageCount = transcript.length;\n const derived = deriveTranscript(snap.messages);\n if (derived.currentText) snap.currentText = derived.currentText;\n if (derived.model) snap.model = derived.model;\n if (derived.lastToolCall) snap.lastToolCall = derived.lastToolCall;\n snap.toolCallCount = Math.max(snap.toolCallCount, derived.toolCallCount);\n // An in-eval lane has no artifact todos channel: recover the plan from its\n // `write_todos` calls.\n snap.todos = snap.todos ?? derived.todos;\n}\n\n/**\n * The lanes of in-eval dispatches, from two sources: the *persisted* summaries\n * each finished `eval` ToolMessage carries in `artifact.ptc_subagents`\n * (terminal truth; the only source after a session reopen), then the *live*\n * `ptc_subagents` state channel (`ptcSubagents`) for dispatches still\n * streaming. A live entry never downgrades a terminal snapshot back to\n * `running` — a stale lifecycle entry whose terminal event was lost must not\n * resurrect a perpetually-running lane the persisted summary already settled.\n * A lane whose steps no longer ride but whose subagent checkpoint namespace is\n * recorded (`ns`) is `checkpointed`, and `history/lane {lane}` pages its\n * steps: a live entry a later run stripped to its summary, or a persisted\n * summary with no live entry (the registry died with the activation that\n * streamed it). A live entry speaks for its lane over the summary.\n */\nexport function deriveEvalSubagents(\n messages: readonly LangChainMessage[],\n ptcSubagents?: Record<string, PtcSubagentEntry>\n): Map<string, SubagentDiscoverySnapshot> {\n const byDispatchId = new Map<string, SubagentDiscoverySnapshot>();\n // Persisted in-eval dispatch summaries (terminal truth; survives reopen).\n for (const m of messages) {\n if (m.type !== 'tool' || m.name !== EVAL_TOOL_NAME) continue;\n for (const entry of ptcSubagentsFromArtifact(m.artifact)) {\n mergePtcSubagentEntry(byDispatchId, entry, {\n // The eval ended when these summaries were written, so any lane the\n // backend could not settle is a cancelled dispatch, never \"running\".\n status: entry.status === 'complete' ? 'complete' : 'error',\n fallbackEvalId: m.tool_call_id,\n });\n noteCheckpointedLane(byDispatchId.get(entry.id), entry);\n }\n }\n // Live lifecycle entries (the only signal while an eval is still streaming).\n if (ptcSubagents) {\n for (const entry of Object.values(ptcSubagents)) {\n if (!entry || typeof entry !== 'object' || typeof entry.id !== 'string' || !entry.id) {\n continue;\n }\n // This activation's registry speaks for the lane: the steps it streams,\n // else its own namespace, else nothing to page.\n const existing = byDispatchId.get(entry.id);\n if (existing?.source?.checkpointed === true) existing.source = undefined;\n mergePtcSubagentEntry(byDispatchId, entry, {\n status:\n entry.status === 'complete'\n ? 'complete'\n : entry.status === 'error'\n ? 'error'\n : entry.status === 'queued'\n ? 'queued'\n : 'running',\n });\n noteCheckpointedLane(byDispatchId.get(entry.id), entry);\n }\n }\n return byDispatchId;\n}\n\n/** Lifecycle progression order — a merge may only move a lane forward. */\nfunction subagentStatusRank(status: SubagentStatus): number {\n if (status === 'queued') return 0;\n if (status === 'running') return 1;\n return 2;\n}\n\nfunction mergePtcSubagentEntry(\n byDispatchId: Map<string, SubagentDiscoverySnapshot>,\n entry: PtcSubagentEntry,\n options: { status: SubagentStatus; fallbackEvalId?: string }\n): void {\n const { status, fallbackEvalId } = options;\n const existing = byDispatchId.get(entry.id);\n if (existing) {\n // A lane only ever moves FORWARD (queued → running → terminal): a stale\n // entry whose later event was lost must not resurrect a running lane to\n // queued or a finished lane to running — and a settled terminal outcome\n // never flips to the other terminal (first settled source wins).\n if (\n status === existing.status ||\n subagentStatusRank(status) > subagentStatusRank(existing.status)\n ) {\n existing.status = status;\n }\n const evalId = entry.eval_id ?? fallbackEvalId;\n if (evalId) existing.evalId = evalId;\n if (typeof entry.duration_ms === 'number') existing.durationMs = entry.duration_ms;\n // A count only arrives on terminal events; never let a countless later\n // event (or an older backend) regress a known count.\n if (typeof entry.tool_call_count === 'number') {\n existing.toolCallCount = Math.max(existing.toolCallCount, entry.tool_call_count);\n }\n if (Array.isArray(entry.messages) && entry.messages.length > 0) {\n applyLaneTranscript(existing, entry.messages);\n }\n applyLaneCut(existing, entry);\n applyLaneUsage(existing, entry);\n // Prefer the real output (Athena's in-eval output bridge); fall back to the\n // error string only when no (non-empty) output was captured. Same\n // empty-string/nullish rule as the create branch below.\n if (entry.output) existing.output = entry.output;\n else if (entry.error && !existing.output) existing.output = entry.error;\n return;\n }\n // `||` (not `??`) so an empty-string output falls back to the error, matching\n // the merge branch's truthy check above.\n const initialOutput = entry.output || entry.error;\n const evalId = entry.eval_id ?? fallbackEvalId;\n const created: SubagentDiscoverySnapshot = {\n id: entry.id,\n name: String(entry.subagent_type ?? 'subagent'),\n description: entry.label ?? entry.description ?? '',\n status,\n toolCallCount: typeof entry.tool_call_count === 'number' ? entry.tool_call_count : 0,\n messages: NO_TRANSCRIPT,\n messageCount: 0,\n currentText: '',\n ...(evalId ? { evalId } : {}),\n ...(typeof entry.duration_ms === 'number' ? { durationMs: entry.duration_ms } : {}),\n ...(initialOutput ? { output: initialOutput } : {}),\n };\n if (Array.isArray(entry.messages) && entry.messages.length > 0) {\n applyLaneTranscript(created, entry.messages);\n }\n applyLaneCut(created, entry);\n applyLaneUsage(created, entry);\n byDispatchId.set(entry.id, created);\n}\n\n/**\n * Where an in-eval dispatch's streamed steps ride, and what the wire left off\n * them, read off its entry's cut marker (`DEEP_AGENT_TRUNCATED_LANE_KEY`) as a\n * `task` card's is: the steps left off, and the whole lane's tool calls.\n */\nfunction applyLaneCut(snap: SubagentDiscoverySnapshot, entry: PtcSubagentEntry): void {\n const lane = readTruncatedLane(entry);\n if (Array.isArray(entry.messages) && entry.messages.length > 0) {\n snap.source = {\n lane: entry.id,\n transcript: entry.messages,\n ...(lane !== null && { truncated: lane }),\n };\n }\n if (lane === null) return;\n snap.omittedMessageCount = Math.max(0, lane.messages - snap.messageCount);\n snap.toolCallCount = Math.max(snap.toolCallCount, lane.toolCalls);\n}\n\nconst NO_LANE_STEPS: readonly LangChainMessage[] = [];\n\n/**\n * An entry that recorded its subagent's checkpoint namespace (`ns`, a registry\n * entry or the summary an eval persisted, since agora writes it) pages its\n * lane from that checkpoint when no streamed steps carry it.\n */\nfunction noteCheckpointedLane(\n snap: SubagentDiscoverySnapshot | undefined,\n entry: PtcSubagentEntry\n): void {\n if (snap === undefined || snap.source !== undefined) return;\n if (typeof entry.ns !== 'string' || !entry.ns) return;\n snap.source = { lane: entry.id, transcript: NO_LANE_STEPS, checkpointed: true };\n}\n\n/**\n * An in-eval lane's token use, from its entry's host total or the native steps\n * of its live transcript. A merge that brings neither keeps what the lane has.\n */\nfunction applyLaneUsage(snap: SubagentDiscoverySnapshot, entry: PtcSubagentEntry): void {\n const usage = laneTokenUsage(\n entry,\n transcriptStepUsage(snap.messages),\n snap.status,\n (snap.omittedMessageCount ?? 0) > 0\n );\n if (usage !== undefined) snap.usage = usage;\n}\n\n/**\n * The first call of a nested thread with one of `toolCallIds`: the calls a\n * subagent made are the tool-call parts of its transcript, ids included.\n */\nfunction findToolCall({\n messages,\n toolCallIds,\n}: {\n messages: readonly ThreadMessage[] | undefined;\n toolCallIds: ReadonlySet<string>;\n}): ToolCallMessagePart | undefined {\n if (messages === undefined) return undefined;\n for (const message of messages) {\n if (message.role !== 'assistant') continue;\n for (const part of message.content) {\n if (part.type === 'tool-call' && toolCallIds.has(part.toolCallId)) return part;\n }\n }\n return undefined;\n}\n\n/**\n * Whether a subagent lane waits on a person's approval, given the gated calls\n * still waiting on one (`toolCallIdsAwaitingApproval`): its own dispatch is the\n * gated call (a per-dispatch `task` gate), or a call it made is (a gated tool\n * raised inside the delegated subagent). The approval names the gated call's\n * `tool_call_id` and never the lane, and a lane's transcript carries the calls\n * it made with their ids, so the call id is the join. A settled lane waits on\n * nobody.\n */\nexport function subagentAwaitingApproval({\n lane,\n toolCallIds,\n}: {\n lane: Pick<SubagentDiscoverySnapshot, 'id' | 'status' | 'messages'>;\n /** The gated calls still waiting on a decision (`toolCallIdsAwaitingApproval`). */\n toolCallIds: ReadonlySet<string>;\n}): boolean {\n if (toolCallIds.size === 0 || isTerminalSubagentStatus(lane.status)) return false;\n return (\n toolCallIds.has(lane.id) ||\n findToolCall({ messages: lane.messages, toolCallIds }) !== undefined\n );\n}\n\n/**\n * The call a subagent made that waits on a person's approval (a gated tool\n * raised inside the delegated subagent), read off its transcript — what the\n * lane card names while it waits. `undefined` when the lane made none, which\n * includes a lane whose own dispatch is the gated call.\n */\nexport function subagentToolCallAwaitingApproval({\n lane,\n toolCallIds,\n}: {\n lane: Pick<SubagentDiscoverySnapshot, 'status' | 'messages'>;\n /** The gated calls still waiting on a decision (`toolCallIdsAwaitingApproval`). */\n toolCallIds: ReadonlySet<string>;\n}): LangChainToolCall | undefined {\n if (toolCallIds.size === 0 || isTerminalSubagentStatus(lane.status)) return undefined;\n const part = findToolCall({ messages: lane.messages, toolCallIds });\n return part === undefined\n ? undefined\n : { id: part.toolCallId, name: part.toolName, args: part.args };\n}\n\n/** What {@link subagentLanesHoldingUnseenApproval} finds: the lanes, and the call if one holds it. */\nexport interface UnseenApprovalLanes {\n /** The lanes holding a gated call none of their transcripts shows. */\n laneIds: ReadonlySet<string>;\n /**\n * The gated call, when exactly one lane holds exactly one such call. With\n * several candidate lanes the approval holds them all (the run is parked, so\n * none of them runs), but which one made the call is unknown.\n */\n gatedCallId: string | undefined;\n}\n\nconst NO_UNSEEN_APPROVAL_LANES: UnseenApprovalLanes = {\n laneIds: new Set(),\n gatedCallId: undefined,\n};\n\n/**\n * The lanes of one turn that wait on a gated call no transcript shows. The\n * approval names a call raised inside a delegated subagent by its\n * `tool_call_id`, and the lane's transcript is what joins the two\n * ({@link subagentAwaitingApproval}). But a lane's steps ride only on the\n * backend's running placeholder, which is never checkpointed: a conversation\n * opened after its run parked (a reload, another device, a handover) shows the\n * lane with no steps at all, and the join finds nothing. A gated call that is\n * none of the turn's own calls and is in no lane's transcript was raised inside\n * one of the turn's unsettled lanes whose steps did not ride.\n *\n * Pass only the lanes of the turn the run is on now (the thread's newest\n * message, running or waiting on a person): an earlier turn's unsettled lane\n * was stopped, not parked, though its status still reads `requires-action`.\n */\nexport function subagentLanesHoldingUnseenApproval({\n lanes,\n turnToolCallIds,\n toolCallIds,\n}: {\n lanes: readonly Pick<SubagentDiscoverySnapshot, 'id' | 'status' | 'messages'>[];\n /** Every tool-call id of the turn itself (its `task` calls included). */\n turnToolCallIds: ReadonlySet<string>;\n /** The gated calls still waiting on a decision (`toolCallIdsAwaitingApproval`). */\n toolCallIds: ReadonlySet<string>;\n}): UnseenApprovalLanes {\n if (toolCallIds.size === 0) return NO_UNSEEN_APPROVAL_LANES;\n const shown = new Set<string>();\n for (const lane of lanes) {\n for (const message of lane.messages) {\n if (message.role !== 'assistant') continue;\n for (const part of message.content) {\n if (part.type === 'tool-call' && toolCallIds.has(part.toolCallId)) {\n shown.add(part.toolCallId);\n }\n }\n }\n }\n const unseen: string[] = [...toolCallIds].filter(\n (id) => !turnToolCallIds.has(id) && !shown.has(id)\n );\n if (unseen.length === 0) return NO_UNSEEN_APPROVAL_LANES;\n const holders = lanes.filter(\n (lane) => !isTerminalSubagentStatus(lane.status) && lane.messages.length === 0\n );\n if (holders.length === 0) return NO_UNSEEN_APPROVAL_LANES;\n return {\n laneIds: new Set(holders.map((lane) => lane.id)),\n gatedCallId: holders.length === 1 && unseen.length === 1 ? unseen[0] : undefined,\n };\n}\n\n/**\n * Every tool-call id of the turn the run is on now, else `undefined`: the\n * thread's newest message, still running or waiting on a person. An earlier\n * turn keeps `requires-action` for a call that never got its result (a stopped\n * run's lane), so its status alone never says it owns the run's approval.\n * Pass it to {@link subagentLanesHoldingUnseenApproval} as `turnToolCallIds`.\n */\nexport function openTurnToolCallIds(\n message: Pick<ThreadMessage, 'role' | 'content' | 'status'> & { isLast: boolean }\n): ReadonlySet<string> | undefined {\n if (message.role !== 'assistant' || !message.isLast) return undefined;\n const status = message.status?.type;\n if (status !== 'running' && status !== 'requires-action') return undefined;\n const ids = new Set<string>();\n for (const part of message.content) {\n if (part.type === 'tool-call') ids.add(part.toolCallId);\n }\n return ids;\n}\n\n/**\n * What a subagent lane parked on a person's approval reads in every app (the\n * lane's status, where it would say Running or Queued).\n */\nexport const SUBAGENT_AWAITING_APPROVAL_LABEL = 'Waiting for approval';\n\n/** What a lane waits on, from {@link subagentLaneApprovalWait}. */\nexport interface SubagentLaneApprovalWait {\n /** The lane is parked on an approval: its own dispatch or a call it made is the gated call. */\n awaitingApproval: boolean;\n /** The call inside the lane the approval gates, when it is known. */\n gatedCall: LangChainToolCall | undefined;\n /** The approval gates a call the lane made that its card cannot show (its steps did not ride). */\n insideLane?: boolean;\n}\n\nconst NOT_AWAITING_APPROVAL: SubagentLaneApprovalWait = {\n awaitingApproval: false,\n gatedCall: undefined,\n};\n\n/**\n * Whether a lane waits on a person's approval, and on what: the call it made,\n * read off its transcript; or, for a lane whose steps did not ride (a\n * conversation opened after its run parked: {@link\n * subagentLanesHoldingUnseenApproval}), the call the approval names when this\n * lane alone can hold it, else only that it waits on a call it made. A lane\n * whose own dispatch is the gated call waits with no `gatedCall`.\n */\nexport function subagentLaneApprovalWait({\n lane,\n toolCallIds,\n unseenApproval,\n actionRequests,\n}: {\n lane: Pick<SubagentDiscoverySnapshot, 'id' | 'status' | 'messages'>;\n /** The gated calls still waiting on a decision (`toolCallIdsAwaitingApproval`). */\n toolCallIds: ReadonlySet<string>;\n /** The open turn's step-less lanes holding a gated call, when the lane is on that turn. */\n unseenApproval: UnseenApprovalLanes | undefined;\n /** The parked approval's gated calls, which name an unseen call's tool and arguments. */\n actionRequests: readonly Pick<PendingActionRequest, 'toolCallId' | 'name' | 'args'>[] | undefined;\n}): SubagentLaneApprovalWait {\n const unseen: boolean =\n !isTerminalSubagentStatus(lane.status) && unseenApproval?.laneIds.has(lane.id) === true;\n if (!subagentAwaitingApproval({ lane, toolCallIds }) && !unseen) return NOT_AWAITING_APPROVAL;\n const shown = subagentToolCallAwaitingApproval({ lane, toolCallIds });\n if (shown !== undefined || !unseen) return { awaitingApproval: true, gatedCall: shown };\n const gatedCallId: string | undefined = unseenApproval?.gatedCallId;\n const request = gatedCallId\n ? actionRequests?.find((candidate) => candidate.toolCallId === gatedCallId)\n : undefined;\n return {\n awaitingApproval: true,\n gatedCall:\n request && gatedCallId\n ? // The approval's args crossed the wire as JSON, as a call's own do.\n { id: gatedCallId, name: request.name, args: request.args as LangChainToolCall['args'] }\n : undefined,\n insideLane: true,\n };\n}\n\n/**\n * Whether the lane of the `task` call `toolCallId` in this turn waits on a\n * person's approval, and on what ({@link subagentLaneApprovalWait}), for a\n * card that shows one lane (the SDK's, the phone's). The lanes are the turn's\n * own; a lane's steps are its converted `messages`, else (a host that doesn't\n * convert them, like the phone) the transcript its running placeholder\n * carries. On the turn the run is on now ({@link openTurnToolCallIds}), a\n * gated call no lane shows is held by its step-less lanes\n * ({@link subagentLanesHoldingUnseenApproval}), so a conversation opened after\n * its run parked still reads as waiting for approval.\n */\nexport function turnLaneApprovalWait({\n message,\n toolCallId,\n toolCallIds,\n actionRequests,\n}: {\n message: ThreadMessage & { isLast: boolean };\n toolCallId: string;\n /** The gated calls still waiting on a decision (`toolCallIdsAwaitingApproval`). */\n toolCallIds: ReadonlySet<string>;\n /** The parked approval's gated calls, which name an unseen call's tool and arguments. */\n actionRequests: readonly Pick<PendingActionRequest, 'toolCallId' | 'name' | 'args'>[] | undefined;\n}): SubagentLaneApprovalWait {\n if (toolCallIds.size === 0 || message.role !== 'assistant') return NOT_AWAITING_APPROVAL;\n const artifacts = new Map<string, unknown>();\n for (const part of message.content) {\n if (part.type === 'tool-call' && part.toolName === TASK_TOOL_NAME) {\n artifacts.set(part.toolCallId, part.artifact);\n }\n }\n const lanes = [...taskSubagentsOfTurn(message).values()].map((lane) => {\n if (lane.messages.length > 0) return lane;\n const carried = nestedMessagesFromArtifact(artifacts.get(lane.id));\n return carried.length === 0\n ? lane\n : { ...lane, messages: convertSubagentTranscript(carried, lane.status === 'running') };\n });\n const lane = lanes.find((candidate) => candidate.id === toolCallId);\n if (lane === undefined) return NOT_AWAITING_APPROVAL;\n const turnToolCallIds = openTurnToolCallIds(message);\n return subagentLaneApprovalWait({\n lane,\n toolCallIds,\n unseenApproval:\n turnToolCallIds === undefined\n ? undefined\n : subagentLanesHoldingUnseenApproval({ lanes, turnToolCallIds, toolCallIds }),\n actionRequests,\n });\n}\n\n/**\n * What a lane waiting for approval says it waits on, in every app: a call it\n * made (\"Needs approval to run\", then the call), a call it made that its card\n * cannot name (\"Needs approval to continue\"), or its own dispatch (\"Needs\n * approval to start\").\n */\nexport function subagentApprovalNoteLabel({\n gatedCall,\n insideLane = false,\n}: Pick<SubagentLaneApprovalWait, 'gatedCall' | 'insideLane'>): string {\n if (gatedCall !== undefined) return 'Needs approval to run';\n return insideLane ? 'Needs approval to continue' : 'Needs approval to start';\n}\n\n/**\n * The calls of one converted turn that wait on a person's approval, in turn\n * order: a gated call of the turn itself, or a `task` call not yet settled\n * (no result, or the running placeholder) whose lane holds a gated call — the\n * steps the turn's step list reads as waiting rather than running or done.\n */\nexport function turnToolCallsAwaitingApproval({\n message,\n toolCallIds,\n}: {\n message: ThreadMessage;\n /** The gated calls still waiting on a decision (`toolCallIdsAwaitingApproval`). */\n toolCallIds: ReadonlySet<string>;\n}): string[] {\n if (toolCallIds.size === 0 || message.role !== 'assistant') return [];\n const ids: string[] = [];\n for (const part of message.content) {\n if (part.type !== 'tool-call') continue;\n if (toolCallIds.has(part.toolCallId)) {\n ids.push(part.toolCallId);\n continue;\n }\n if (part.toolName !== TASK_TOOL_NAME) continue;\n const settled = part.result !== undefined && part.isPreliminary !== true;\n if (!settled && findToolCall({ messages: part.messages, toolCallIds }) !== undefined) {\n ids.push(part.toolCallId);\n }\n }\n return ids;\n}\n\nconst NO_WAITING_TOOL_CALLS: ReadonlySet<string> = new Set();\n/** Joins call ids into one selector value; an id never holds it. */\nconst TOOL_CALL_ID_SEPARATOR = '\\n';\n\n/**\n * {@link turnToolCallsAwaitingApproval} for the message in scope: what a\n * turn's step list takes as `waitingToolCallIds`, given the run's waiting\n * calls (`toolCallIdsAwaitingApproval`). Selected as a joined string, so a\n * streamed token re-renders the caller only when the waiting steps change, and\n * the set keeps its identity while they do not. Olympus's activity card and\n * the SDK chat's turns both read it.\n */\nexport function useTurnToolCallsAwaitingApproval(\n toolCallIds: ReadonlySet<string>\n): ReadonlySet<string> {\n const key = useAuiState((s) =>\n toolCallIds.size === 0\n ? ''\n : turnToolCallsAwaitingApproval({ message: s.message, toolCallIds }).join(\n TOOL_CALL_ID_SEPARATOR\n )\n );\n return useMemo(\n () => (key === '' ? NO_WAITING_TOOL_CALLS : new Set(key.split(TOOL_CALL_ID_SEPARATOR))),\n [key]\n );\n}\n\n/** Result text shown for a dispatch whose owning run ended before it finished. */\nexport const ORPHANED_SUBAGENT_OUTPUT =\n 'Interrupted — the run that dispatched this subagent ended before it finished.';\n\n/**\n * Settle snapshots orphaned by their dispatching context: once the owner (e.g.\n * the `eval` tool call whose in-eval `task()` issued them) is itself terminal,\n * nothing can ever deliver a `complete`/`error` lifecycle event for a lane still\n * `queued`/`running` — the dispatch coroutines were cancelled with the eval. Those\n * lanes are coerced to `error` with an interruption message so the UI can't show\n * perpetual \"Running · no activity\" ghosts. Returns the input array unchanged\n * (same reference) when there is nothing to settle.\n */\nexport function finalizeOrphanedSubagents(\n snapshots: readonly SubagentDiscoverySnapshot[],\n ownerTerminal: boolean\n): readonly SubagentDiscoverySnapshot[] {\n if (!ownerTerminal || snapshots.every((s) => isTerminalSubagentStatus(s.status))) {\n return snapshots;\n }\n return snapshots.map((s) =>\n isTerminalSubagentStatus(s.status)\n ? s\n : { ...s, status: 'error', output: s.output || ORPHANED_SUBAGENT_OUTPUT }\n );\n}\n\n/**\n * The `task` tool calls sharing `toolCallId`'s parent AI message — the parallel\n * fan-out siblings, in declaration order. Parallel `task` calls always live on ONE\n * AI message's `tool_calls`, so \"same parent message\" IS the parallelism boundary;\n * sequential delegations sit on separate AI messages and form singleton groups.\n * The FIRST sibling is the group's `anchorId`: its tool-part render draws the whole\n * side-by-side group and the other siblings render nothing, keeping the layout\n * change fully inside the `task` tool UI. Falls back to a singleton group when the\n * parent AI message isn't among `messages` (a turn's bound sources, or a raw\n * transcript).\n */\nexport interface TaskSiblingGroup {\n /** Sibling `task` tool-call ids in declaration order. */\n ids: string[];\n /** The first sibling — the one tool-part render that owns the group's UI. */\n anchorId: string;\n}\n\nexport function taskSiblingGroup(\n messages: readonly LangChainMessage[],\n toolCallId: string\n): TaskSiblingGroup {\n for (const m of messages) {\n if (m.type !== 'ai' || !m.tool_calls) continue;\n if (!m.tool_calls.some((tc) => tc.id === toolCallId)) continue;\n const ids = m.tool_calls\n .filter((tc) => tc.name === TASK_TOOL_NAME && tc.id)\n .map((tc) => tc.id as string);\n if (ids.length > 0) return { ids, anchorId: ids[0] ?? toolCallId };\n break;\n }\n return { ids: [toolCallId], anchorId: toolCallId };\n}\n"],"names":["lane"],"mappings":";;;;;;;AA+CO,SAAS,yBAAyB,QAAiC;AACxE,SAAO,WAAW,cAAc,WAAW;AAC7C;AA8HA,SAAS,qBAAqB,MAA6D;AACzF,MAAI,CAAC,KAAM,QAAO;AAClB,SAAO,OAAO,KAAK,iBAAiB,KAAK,gBAAgB,KAAK,YAAY,UAAU;AACtF;AAOO,SAAS,2BAA2B,UAAuC;;AAChF,QAAM,IAAI;AACV,WAAO,4BAAG,mBAAH,mBAAmB,aAAY,CAAA;AACxC;AA6CA,MAAM,UAAU,CAAC,UACf,OAAO,UAAU,YAAY,OAAO,UAAU,KAAK,KAAK,SAAS;AAQ5D,SAAS,kBAAkB,aAA4C;AAC5E,MAAI,OAAO,gBAAgB,YAAY,gBAAgB,KAAM,QAAO;AACpE,QAAM,SAAU,YAAwC,6BAA6B;AACrF,MAAI,OAAO,WAAW,YAAY,WAAW,KAAM,QAAO;AAC1D,QAAM,EAAE,UAAU,YAAY,WAAW,aAAa;AACtD,SAAO,QAAQ,QAAQ,KAAK,QAAQ,SAAS,IACzC,EAAE,UAAU,WAAW,UAAU,aAAa,KAAA,IAC9C;AACN;AAQO,SAAS,cAAc,MAAmC;AAC/D,MAAI,OAAO,SAAS,YAAY,SAAS,KAAM,QAAO;AACtD,QAAM,QAAS,KAAiC,yBAAyB;AACzE,MAAI,OAAO,UAAU,YAAY,UAAU,KAAM,QAAO;AACxD,QAAM,EAAE,cAAc,aAAa,eAAe,iBAAiB;AAInE,SAAO,QAAQ,WAAW,KAAK,Q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EACA,aAAa;AACf,GAAuE;AACrE,MAAI,cAAc,OAAW,QAAO;AACpC,SAAO,aAAa,+BAA+B;AACrD;AAQO,SAAS,8BAA8B;AAAA,EAC5C;AAAA,EACA;AACF,GAIa;AACX,MAAI,YAAY,SAAS,KAAK,QAAQ,SAAS,oBAAoB,CAAA;AACnE,QAAM,MAAgB,CAAA;AACtB,aAAW,QAAQ,QAAQ,SAAS;AAClC,QAAI,KAAK,SAAS,YAAa;AAC/B,QAAI,YAAY,IAAI,KAAK,UAAU,GAAG;AACpC,UAAI,KAAK,KAAK,UAAU;AACxB;AAAA,IACF;AACA,QAAI,KAAK,aAAa,eAAgB;AACtC,UAAM,UAAU,KAAK,WAAW,UAAa,KAAK,kBAAkB;AACpE,QAAI,CAAC,WAAW,aAAa,EAAE,UAAU,KAAK,UAAU,aAAa,MAAM,QAAW;AACpF,UAAI,KAAK,KAAK,UAAU;AAAA,IAC1B;AAAA,EACF;AACA,SAAO;AACT;AAEA,MAAM,4CAAiD,IAAA;AAEvD,MAAM,yBAAyB;AAUxB,SAAS,iCACd,aACqB;AACrB,QAAM,MAAM;AAAA,IAAY,CAAC,MACvB,YAAY,SAAS,IACjB,KACA,8BAA8B,EAAE,SAAS,EAAE,SAAS,YAAA,CAAa,EAAE;AAAA,MACjE;AAAA,IAAA;AAAA,EACF;AAEN,SAAO;AAAA,IACL,MAAO,QAAQ,KAAK,wBAAwB,IAAI,IAAI,IAAI,MAAM,sBAAsB,CAAC;AAAA,IACrF,CAAC,GAAG;AAAA,EAAA;AAER;"}
1
+ {"version":3,"file":"subagents.js","sources":["../../../../agent-runtime/src/subagents.ts"],"sourcesContent":["/**\n * Subagent discovery: every subagent lane a deep-agent thread has spawned, as\n * the card view model the surfaces that draw subagent lanes render. Two\n * dispatch paths feed lanes keyed by dispatch id:\n *\n * - top-level `task` tool calls, read from the call's own tool-call part\n * ({@link taskSubagentsOfTurn}): the part's result and `isPreliminary` say\n * where the lane is, and its `messages` (the nested thread\n * `createSubagentTranscriptConversionCache` converts) are the transcript;\n * - in-eval `task()` dispatches ({@link deriveEvalSubagents}), whose only\n * signals are the live `ptc_subagents` state channel and the summaries a\n * finished `eval` ToolMessage persists in `artifact.ptc_subagents`.\n */\nimport {\n getExternalStoreMessages,\n type ThreadMessage,\n type ToolCallMessagePart,\n} from '@assistant-ui/core';\nimport type { LangChainMessage, LangChainToolCall } from '@assistant-ui/react-langgraph';\nimport { useAuiState } from '@assistant-ui/store';\nimport { useMemo } from 'react';\nimport {\n DEEP_AGENT_LANE_USAGE_KEY,\n DEEP_AGENT_TRUNCATED_LANE_KEY,\n} from './generated/runconfig-contract';\nimport type { PendingActionRequest } from './interrupts';\nimport { getMessageText } from './message-text';\nimport { convertSubagentTranscript, withRepeatedResult } from './subagent-transcripts';\nimport { EVAL_TOOL_NAME, TASK_TOOL_NAME } from './tool-names';\nimport type { PtcSubagentEntry, Todo } from './types';\n\n/**\n * Where a subagent lane is:\n *\n * - `queued` — the dispatch has not started: a `task` call with no result yet\n * (waiting for a dispatch slot or an approval; the backend shows the running\n * card once the dispatch holds its slot), or an in-eval dispatch waiting for\n * one of the bridge's concurrency slots.\n * - `running` — a `task` call's result is still the backend's running\n * placeholder (its part is `isPreliminary`), and the nested transcript fills\n * in live; or an in-eval dispatch's lifecycle says it runs.\n * - `complete` / `error` — the real result replaced the placeholder; `error`\n * when it is an error result.\n */\nexport type SubagentStatus = 'queued' | 'running' | 'complete' | 'error';\n\n/** True for the settled lifecycle states (`complete` / `error`). */\nexport function isTerminalSubagentStatus(status: SubagentStatus): boolean {\n return status === 'complete' || status === 'error';\n}\n\n/** Aggregate lane lifecycle counts for one fan-out (orchestration strip + header chip). */\nexport interface SubagentStatusCounts {\n total: number;\n queued: number;\n running: number;\n complete: number;\n failed: number;\n /** complete + failed — the settled count progress displays use. */\n terminal: number;\n}\n\nexport function countSubagentStatuses(\n snapshots: readonly SubagentDiscoverySnapshot[]\n): SubagentStatusCounts {\n const counts: SubagentStatusCounts = {\n total: snapshots.length,\n queued: 0,\n running: 0,\n complete: 0,\n failed: 0,\n terminal: 0,\n };\n for (const snapshot of snapshots) {\n if (snapshot.status === 'queued') counts.queued += 1;\n else if (snapshot.status === 'running') counts.running += 1;\n else if (snapshot.status === 'complete') counts.complete += 1;\n else counts.failed += 1;\n }\n counts.terminal = counts.complete + counts.failed;\n return counts;\n}\n\n/**\n * Discovery snapshot for one subagent invocation. Mirrors LangChain's\n * `SubagentDiscoverySnapshot`: `id` is the `task` tool-call id that spawned the\n * subagent (the dispatch id for an in-eval dispatch), so cards nest under the\n * coordinator turn that delegated the work.\n */\nexport interface SubagentDiscoverySnapshot {\n /** The `task` tool-call id that spawned the subagent. */\n id: string;\n /** Subagent type/name, from the `task` call's `subagent_type` arg. */\n name: string;\n /** The one-line task brief from the `task` call's `description` arg. */\n description: string;\n /** Lifecycle state — see {@link SubagentStatus}. */\n status: SubagentStatus;\n /** The call's result text (empty while it is the running placeholder). */\n output?: string;\n /** Number of nested tool calls the subagent made. */\n toolCallCount: number;\n /**\n * The subagent's transcript as a nested thread: a `task` part's native\n * `messages`, or an in-eval dispatch's live transcript converted the same way.\n */\n messages: readonly ThreadMessage[];\n /** Messages in the transcript as the wire carries them, before conversion joins a turn's steps. */\n messageCount: number;\n /**\n * Nested messages the wire left off: a cut card carries its newest steps\n * ({@link readTruncatedLane}) — a running card always, a finished one on a\n * version-2 view — and the rest pages in through `history/lane`; an in-eval\n * dispatch's streamed transcript is cut the same way, running or finished.\n * Absent when the transcript rides whole.\n */\n omittedMessageCount?: number;\n /**\n * Where the lane's steps ride, what `history/lane` pages the rest of the lane\n * under (`useDeepAgentLaneHistory`): a `task` lane's card, an in-eval lane's\n * registry entry while it streams its steps, or, once they no longer ride,\n * its subagent checkpoint (`checkpointed`), when agora recorded where that is\n * (`ns`). Absent for any other in-eval lane with no streamed steps (a summary\n * written before agora recorded the namespace, an older host).\n */\n source?: SubagentLaneSource;\n /** The subagent's own plan, nested by the backend on the task artifact (`subgraph_state.todos`). */\n todos?: Todo[];\n /** The newest tool call in the transcript — the card's \"last action\" ticker. */\n lastToolCall?: LangChainToolCall;\n /** The newest assistant text in the transcript — the card's thought preview. */\n currentText: string;\n /**\n * The `eval` tool-call id that dispatched this subagent, when it was spawned\n * from INSIDE the code interpreter (`task()` in the REPL) rather than by a\n * top-level `task` tool call. The eval card uses it to render lanes for its\n * own dispatches.\n */\n evalId?: string;\n /**\n * Backend-reported runtime for a finished in-eval dispatch (from the terminal\n * lifecycle event). Authoritative over client-side timing — it survives a page\n * refresh, where local first-seen timestamps are gone.\n */\n durationMs?: number;\n /** The model that produced the transcript, from its newest assistant turn's model stamp. */\n model?: string;\n /**\n * The lane's token use: the whole lane's as the host counts it\n * (`DEEP_AGENT_LANE_USAGE_KEY`), else the sum of the native step usage\n * (`metadata.steps[].usage`) of the steps the transcript holds. Absent while\n * no step reports any.\n */\n usage?: SubagentTokenUsage;\n}\n\n/** A subagent lane's token use. */\nexport interface SubagentTokenUsage {\n /** Input tokens, the prompt cache's reads and writes included. */\n readonly inputTokens: number;\n readonly outputTokens: number;\n /**\n * Less than the lane will have used: the lane still runs (its newest step may\n * not have reported yet), or no host total arrived and the sum covers only\n * the steps held of a lane cut to its newest ones.\n */\n readonly partial: boolean;\n}\n\n/** Input and output tokens of some model calls. */\nexport interface TokenCounts {\n readonly inputTokens: number;\n readonly outputTokens: number;\n}\n\nfunction subagentNameFromArgs(args: Readonly<Record<string, unknown>> | undefined): string {\n if (!args) return 'subagent';\n return String(args.subagent_type ?? args.subagentType ?? args.subagent ?? 'subagent');\n}\n\n/**\n * The subagent's streamed transcript as the wire carries it, read from a task\n * ToolMessage's `artifact.subgraph_state.messages` (the shape the backend nests\n * it under — see the route's `_subagent_subgraph_state`).\n */\nexport function nestedMessagesFromArtifact(artifact: unknown): LangChainMessage[] {\n const a = artifact as { subgraph_state?: { messages?: LangChainMessage[] } } | undefined;\n return a?.subgraph_state?.messages ?? [];\n}\n\n/** What the wire left off a cut `task` card's nested transcript. */\nexport interface TruncatedLane {\n /** Nested messages the host holds for the lane. */\n messages: number;\n /** Tool calls across all of them. */\n toolCalls: number;\n /**\n * The card is a finished lane's, cut for a version-2 view. Only a host that\n * serves `history/lane` cuts a finished card.\n */\n finished: boolean;\n}\n\n/**\n * Where a lane's steps ride, and what `history/lane` pages the rest of them\n * under: a `task` lane's card, by its message id, or an in-eval dispatch's\n * `ptc_subagents` registry entry, by its dispatch id.\n */\nexport type SubagentLaneSource = {\n /** The steps as the wire carries them (a card's report restored, {@link withRepeatedResult}). */\n readonly transcript: readonly LangChainMessage[];\n /** The cut marker; absent while every step rides. */\n readonly truncated?: TruncatedLane;\n /**\n * No steps ride, and `history/lane {lane}` pages the subagent's own steps\n * from its checkpoint: an in-eval lane a later run in this activation left\n * only its summary and `ns`, or a reopened session's lane (its registry gone,\n * the summary its eval persisted records `ns`).\n */\n readonly checkpointed?: true;\n} & (\n | {\n /** The card's message id: the running placeholder's, then the result's. */\n readonly messageId: string;\n readonly lane?: undefined;\n }\n | {\n /** The dispatch id: the in-eval lane's registry key. */\n readonly lane: string;\n readonly messageId?: undefined;\n }\n);\n\nconst isCount = (value: unknown): value is number =>\n typeof value === 'number' && Number.isInteger(value) && value >= 0;\n\n/**\n * The cut marker off a `task` card's raw wire message: the host carries only\n * the lane's newest nested steps and names the whole transcript here\n * (`DEEP_AGENT_TRUNCATED_LANE_KEY`), on a running card and, for a version-2\n * view, on a finished one. `null` when the transcript rides whole.\n */\nexport function readTruncatedLane(toolMessage: unknown): TruncatedLane | null {\n if (typeof toolMessage !== 'object' || toolMessage === null) return null;\n const marker = (toolMessage as Record<string, unknown>)[DEEP_AGENT_TRUNCATED_LANE_KEY];\n if (typeof marker !== 'object' || marker === null) return null;\n const { messages, tool_calls: toolCalls, finished } = marker as Record<string, unknown>;\n return isCount(messages) && isCount(toolCalls)\n ? { messages, toolCalls, finished: finished === true }\n : null;\n}\n\n/**\n * The whole lane's token use the host carries on a `task` card's raw wire\n * message or an in-eval lane's `ptc_subagents` entry\n * (`DEEP_AGENT_LANE_USAGE_KEY`), however much of the lane the wire carries.\n * `null` when it carries none (an older host, or no step reported usage).\n */\nexport function readLaneUsage(wire: unknown): TokenCounts | null {\n if (typeof wire !== 'object' || wire === null) return null;\n const usage = (wire as Record<string, unknown>)[DEEP_AGENT_LANE_USAGE_KEY];\n if (typeof usage !== 'object' || usage === null) return null;\n const { input_tokens: inputTokens, output_tokens: outputTokens } = usage as Record<\n string,\n unknown\n >;\n return isCount(inputTokens) && isCount(outputTokens) ? { inputTokens, outputTokens } : null;\n}\n\n/**\n * A lane's token use: the host's total when it sent one, else what the native\n * steps of the transcript held add up to, partial while the lane runs or when\n * that transcript is cut. `undefined` while neither counts anything.\n */\nfunction laneTokenUsage(\n wire: unknown,\n steps: TokenCounts | undefined,\n status: SubagentStatus,\n cut: boolean\n): SubagentTokenUsage | undefined {\n const settled = isTerminalSubagentStatus(status);\n const whole = readLaneUsage(wire);\n if (whole !== null) return { ...whole, partial: !settled };\n return steps === undefined ? undefined : { ...steps, partial: !settled || cut };\n}\n\nconst transcriptStepUsageCache = new WeakMap<readonly ThreadMessage[], TokenCounts | null>();\n\n/**\n * What the model calls of a converted transcript used, from assistant-ui's\n * native step usage (`metadata.steps[].usage`, one step per model call a turn\n * joined). `undefined` when no step reports usage. Memoized per transcript\n * array, which the conversion caches keep while the transcript is unchanged.\n */\nexport function transcriptStepUsage(messages: readonly ThreadMessage[]): TokenCounts | undefined {\n const cached = transcriptStepUsageCache.get(messages);\n if (cached !== undefined) return cached ?? undefined;\n let inputTokens = 0;\n let outputTokens = 0;\n let counted = false;\n for (const message of messages) {\n for (const step of message.metadata.steps ?? []) {\n if (step.usage === undefined) continue;\n inputTokens += step.usage.inputTokens;\n outputTokens += step.usage.outputTokens;\n counted = true;\n }\n }\n const usage = counted ? { inputTokens, outputTokens } : null;\n transcriptStepUsageCache.set(messages, usage);\n return usage ?? undefined;\n}\n\n/**\n * The subagent's own plan, read from a task ToolMessage's\n * `artifact.subgraph_state.todos` (the backend mirrors the subagent's isolated\n * `todos` state channel there — see the route's `_forward_subagent_todos`).\n * `undefined` (not `[]`) when the subagent never wrote a plan, so the UI can\n * distinguish \"no plan\" from \"plan with zero items\".\n */\nexport function nestedTodosFromArtifact(artifact: unknown): Todo[] | undefined {\n const a = artifact as { subgraph_state?: { todos?: unknown } } | undefined;\n const todos = a?.subgraph_state?.todos;\n return Array.isArray(todos) ? (todos as Todo[]) : undefined;\n}\n\n/**\n * The persisted in-eval dispatch summaries from an `eval` ToolMessage's\n * `artifact.ptc_subagents` (written by the backend when the eval ends). Unlike\n * the live `ptc_subagents` state channel — which dies with the stream — these\n * survive checkpoint reload, so reopened sessions can still render each\n * dispatch's terminal status, duration, output, and error.\n */\nexport function ptcSubagentsFromArtifact(artifact: unknown): PtcSubagentEntry[] {\n const a = artifact as { ptc_subagents?: unknown } | undefined;\n const entries = a?.ptc_subagents;\n if (!Array.isArray(entries)) return [];\n return entries.filter(\n (entry): entry is PtcSubagentEntry =>\n !!entry &&\n typeof entry === 'object' &&\n typeof (entry as { id?: unknown }).id === 'string' &&\n !!(entry as { id?: string }).id\n );\n}\n\nconst inEvalDispatchCounts = new WeakMap<object, number>();\n\n/**\n * How many subagents an `eval` call delegated to from inside the interpreter\n * (its `task()` dispatches), read off the call's own artifact: the persisted\n * dispatch summaries (`artifact.ptc_subagents`, one per dispatch id), else the\n * `task` sub-calls its PTC log records (a running call's placeholder, or a\n * backend that persists no summaries). Counted once per artifact object, so a\n * settled call's count costs nothing when its turn is read again.\n */\nexport function countInEvalDispatches(artifact: unknown): number {\n if (typeof artifact !== 'object' || artifact === null) return 0;\n const cached = inEvalDispatchCounts.get(artifact);\n if (cached !== undefined) return cached;\n const summaries = new Set(ptcSubagentsFromArtifact(artifact).map((entry) => entry.id));\n let count = summaries.size;\n if (count === 0) {\n const dispatches = new Set<string>();\n for (const message of nestedMessagesFromArtifact(artifact)) {\n if (message.type !== 'ai' || !message.tool_calls) continue;\n for (const call of message.tool_calls) {\n if (call.name === TASK_TOOL_NAME && call.id) dispatches.add(call.id);\n }\n }\n count = dispatches.size;\n }\n inEvalDispatchCounts.set(artifact, count);\n return count;\n}\n\n/**\n * What one transcript contributes to a lane: the newest assistant text\n * (thought preview), the newest tool call and the count (\"last action\"\n * ticker), the producing model, and the plan recovered from the newest\n * `write_todos` call — the fallback for in-eval lanes, whose isolated `todos`\n * state channel never reaches the wire (the task path nests todos on the\n * artifact instead); the call args carry the same list, so the progress ring\n * can still fill. A pure function of the transcript array.\n */\ninterface TranscriptDerivation {\n currentText: string;\n model: string | undefined;\n lastToolCall: LangChainToolCall | undefined;\n toolCallCount: number;\n todos: Todo[] | undefined;\n}\n\nconst EMPTY_TRANSCRIPT_DERIVATION: TranscriptDerivation = {\n currentText: '',\n model: undefined,\n lastToolCall: undefined,\n toolCallCount: 0,\n todos: undefined,\n};\n\n/**\n * Per-transcript cache for {@link deriveTranscript}: a lane's converted\n * transcript keeps its array while the lane does not change (the conversion\n * caches hand back the previous array), so only lanes still streaming are\n * read again.\n */\nconst transcriptDerivationCache = new WeakMap<readonly ThreadMessage[], TranscriptDerivation>();\n\nfunction deriveTranscript(transcript: readonly ThreadMessage[]): TranscriptDerivation {\n if (transcript.length === 0) return EMPTY_TRANSCRIPT_DERIVATION;\n const cached = transcriptDerivationCache.get(transcript);\n if (cached !== undefined) return cached;\n let currentText = '';\n let model: string | undefined;\n let lastToolCall: LangChainToolCall | undefined;\n let toolCallCount = 0;\n let todos: Todo[] | undefined;\n for (const message of transcript) {\n if (message.role !== 'assistant') continue;\n // A joined turn's `metadata.custom` merges its steps' stamps, the later\n // step's winning (`joinExternalMessages`), so this is the newest stamp.\n const turnModel: unknown = message.metadata?.custom?.model;\n if (typeof turnModel === 'string' && turnModel) model = turnModel;\n for (const part of message.content) {\n if (part.type === 'text') {\n if (part.text) currentText = part.text;\n continue;\n }\n if (part.type !== 'tool-call') continue;\n toolCallCount += 1;\n lastToolCall = { id: part.toolCallId, name: part.toolName, args: part.args };\n if (part.toolName !== 'write_todos') continue;\n const list: unknown = part.args.todos;\n if (Array.isArray(list)) todos = list as Todo[];\n }\n }\n const derivation: TranscriptDerivation = {\n currentText,\n model,\n lastToolCall,\n toolCallCount,\n todos,\n };\n transcriptDerivationCache.set(transcript, derivation);\n return derivation;\n}\n\nconst NO_TRANSCRIPT: readonly ThreadMessage[] = [];\n\n/**\n * The lane of one `task` tool-call part. `toolMessage` is the raw ToolMessage\n * answering it, which carries the wire's cut marker for a running lane.\n */\nfunction taskSubagent(\n part: ToolCallMessagePart,\n toolMessage: LangChainMessage | undefined\n): SubagentDiscoverySnapshot {\n const args: Readonly<Record<string, unknown>> = part.args;\n const transcript = part.messages ?? NO_TRANSCRIPT;\n const derived = deriveTranscript(transcript);\n const messageCount = nestedMessagesFromArtifact(part.artifact).length;\n const lane = readTruncatedLane(toolMessage);\n const todos = nestedTodosFromArtifact(part.artifact);\n const status: SubagentStatus =\n part.result === undefined\n ? 'queued'\n : part.isPreliminary === true\n ? 'running'\n : part.isError === true\n ? 'error'\n : 'complete';\n const usage = laneTokenUsage(\n toolMessage,\n transcriptStepUsage(transcript),\n status,\n lane !== null && lane.messages > messageCount\n );\n return {\n id: part.toolCallId,\n name: subagentNameFromArgs(args),\n description: typeof args.description === 'string' ? args.description : '',\n status,\n ...(part.result !== undefined && { output: getMessageText({ content: part.result }) }),\n toolCallCount: Math.max(derived.toolCallCount, lane?.toolCalls ?? 0),\n messages: transcript,\n messageCount,\n ...(lane !== null && { omittedMessageCount: Math.max(0, lane.messages - messageCount) }),\n ...(typeof toolMessage?.id === 'string' && {\n source: {\n messageId: toolMessage.id,\n transcript: withRepeatedResult(nestedMessagesFromArtifact(part.artifact), part.result),\n ...(lane !== null && { truncated: lane }),\n },\n }),\n ...(todos !== undefined && { todos }),\n ...(derived.lastToolCall !== undefined && { lastToolCall: derived.lastToolCall }),\n currentText: derived.currentText,\n ...(derived.model !== undefined && { model: derived.model }),\n ...(usage !== undefined && { usage }),\n };\n}\n\n/** The raw ToolMessage answering each tool call of a converted turn, from the sources bound to it. */\nfunction toolMessagesOfTurn(message: ThreadMessage): Map<string, LangChainMessage> {\n const byCall = new Map<string, LangChainMessage>();\n for (const source of getExternalStoreMessages<LangChainMessage>(message)) {\n if (source.type === 'tool') byCall.set(source.tool_call_id, source);\n }\n return byCall;\n}\n\n/**\n * Per-part lane cache: a re-converted turn keeps the part object of every call\n * whose ToolMessage did not change (the conversion cache's `keepUnchangedParts`),\n * so a streaming lane re-derives only itself.\n */\nconst taskSubagentByPart = new WeakMap<ToolCallMessagePart, SubagentDiscoverySnapshot>();\nconst taskSubagentsByTurn = new WeakMap<ThreadMessage, ReadonlyMap<string, SubagentDiscoverySnapshot>>();\n\n/**\n * The lane of every `task` call in one converted turn (a `ThreadMessage`, or the\n * message state assistant-ui publishes for it), keyed by tool-call id in call\n * order. Memoized per turn and per part.\n */\nexport function taskSubagentsOfTurn(\n message: ThreadMessage\n): ReadonlyMap<string, SubagentDiscoverySnapshot> {\n const cached = taskSubagentsByTurn.get(message);\n if (cached !== undefined) return cached;\n const lanes = new Map<string, SubagentDiscoverySnapshot>();\n if (message.role === 'assistant') {\n let toolMessages: Map<string, LangChainMessage> | null = null;\n for (const part of message.content) {\n if (part.type !== 'tool-call' || part.toolName !== TASK_TOOL_NAME) continue;\n let lane = taskSubagentByPart.get(part);\n if (lane === undefined) {\n toolMessages ??= toolMessagesOfTurn(message);\n lane = taskSubagent(part, toolMessages.get(part.toolCallId));\n taskSubagentByPart.set(part, lane);\n }\n lanes.set(part.toolCallId, lane);\n }\n }\n taskSubagentsByTurn.set(message, lanes);\n return lanes;\n}\n\n/** The lane of every `task` call in a converted thread, in transcript order. */\nexport function taskSubagentsOfThread(\n messages: readonly ThreadMessage[]\n): SubagentDiscoverySnapshot[] {\n return messages.flatMap((message) => [...taskSubagentsOfTurn(message).values()]);\n}\n\n/**\n * Point a lane at an in-eval dispatch's live transcript, converted into a nested\n * thread, with the live fields it derives. Never regresses a known tool-call\n * count: a countless later event must not reset a lane to \"0 tool calls\".\n */\nfunction applyLaneTranscript(\n snap: SubagentDiscoverySnapshot,\n transcript: readonly LangChainMessage[]\n): void {\n snap.messages = convertSubagentTranscript(transcript, snap.status === 'running');\n snap.messageCount = transcript.length;\n const derived = deriveTranscript(snap.messages);\n if (derived.currentText) snap.currentText = derived.currentText;\n if (derived.model) snap.model = derived.model;\n if (derived.lastToolCall) snap.lastToolCall = derived.lastToolCall;\n snap.toolCallCount = Math.max(snap.toolCallCount, derived.toolCallCount);\n // An in-eval lane has no artifact todos channel: recover the plan from its\n // `write_todos` calls.\n snap.todos = snap.todos ?? derived.todos;\n}\n\n/**\n * The lanes of in-eval dispatches, from two sources: the *persisted* summaries\n * each finished `eval` ToolMessage carries in `artifact.ptc_subagents`\n * (terminal truth; the only source after a session reopen), then the *live*\n * `ptc_subagents` state channel (`ptcSubagents`) for dispatches still\n * streaming. A live entry never downgrades a terminal snapshot back to\n * `running` — a stale lifecycle entry whose terminal event was lost must not\n * resurrect a perpetually-running lane the persisted summary already settled.\n * A lane whose steps no longer ride but whose subagent checkpoint namespace is\n * recorded (`ns`) is `checkpointed`, and `history/lane {lane}` pages its\n * steps: a live entry a later run stripped to its summary, or a persisted\n * summary with no live entry (the registry died with the activation that\n * streamed it). A live entry speaks for its lane over the summary.\n */\nexport function deriveEvalSubagents(\n messages: readonly LangChainMessage[],\n ptcSubagents?: Record<string, PtcSubagentEntry>\n): Map<string, SubagentDiscoverySnapshot> {\n const byDispatchId = new Map<string, SubagentDiscoverySnapshot>();\n // Persisted in-eval dispatch summaries (terminal truth; survives reopen).\n for (const m of messages) {\n if (m.type !== 'tool' || m.name !== EVAL_TOOL_NAME) continue;\n for (const entry of ptcSubagentsFromArtifact(m.artifact)) {\n mergePtcSubagentEntry(byDispatchId, entry, {\n // The eval ended when these summaries were written, so any lane the\n // backend could not settle is a cancelled dispatch, never \"running\".\n status: entry.status === 'complete' ? 'complete' : 'error',\n fallbackEvalId: m.tool_call_id,\n });\n noteCheckpointedLane(byDispatchId.get(entry.id), entry);\n }\n }\n // Live lifecycle entries (the only signal while an eval is still streaming).\n if (ptcSubagents) {\n for (const entry of Object.values(ptcSubagents)) {\n if (!entry || typeof entry !== 'object' || typeof entry.id !== 'string' || !entry.id) {\n continue;\n }\n // This activation's registry speaks for the lane: the steps it streams,\n // else its own namespace, else nothing to page.\n const existing = byDispatchId.get(entry.id);\n if (existing?.source?.checkpointed === true) existing.source = undefined;\n mergePtcSubagentEntry(byDispatchId, entry, {\n status:\n entry.status === 'complete'\n ? 'complete'\n : entry.status === 'error'\n ? 'error'\n : entry.status === 'queued'\n ? 'queued'\n : 'running',\n });\n noteCheckpointedLane(byDispatchId.get(entry.id), entry);\n }\n }\n return byDispatchId;\n}\n\n/** Lifecycle progression order — a merge may only move a lane forward. */\nfunction subagentStatusRank(status: SubagentStatus): number {\n if (status === 'queued') return 0;\n if (status === 'running') return 1;\n return 2;\n}\n\nfunction mergePtcSubagentEntry(\n byDispatchId: Map<string, SubagentDiscoverySnapshot>,\n entry: PtcSubagentEntry,\n options: { status: SubagentStatus; fallbackEvalId?: string }\n): void {\n const { status, fallbackEvalId } = options;\n const existing = byDispatchId.get(entry.id);\n if (existing) {\n // A lane only ever moves FORWARD (queued → running → terminal): a stale\n // entry whose later event was lost must not resurrect a running lane to\n // queued or a finished lane to running — and a settled terminal outcome\n // never flips to the other terminal (first settled source wins).\n if (\n status === existing.status ||\n subagentStatusRank(status) > subagentStatusRank(existing.status)\n ) {\n existing.status = status;\n }\n const evalId = entry.eval_id ?? fallbackEvalId;\n if (evalId) existing.evalId = evalId;\n if (typeof entry.duration_ms === 'number') existing.durationMs = entry.duration_ms;\n // A count only arrives on terminal events; never let a countless later\n // event (or an older backend) regress a known count.\n if (typeof entry.tool_call_count === 'number') {\n existing.toolCallCount = Math.max(existing.toolCallCount, entry.tool_call_count);\n }\n if (Array.isArray(entry.messages) && entry.messages.length > 0) {\n applyLaneTranscript(existing, entry.messages);\n }\n applyLaneCut(existing, entry);\n applyLaneUsage(existing, entry);\n // Prefer the real output (Athena's in-eval output bridge); fall back to the\n // error string only when no (non-empty) output was captured. Same\n // empty-string/nullish rule as the create branch below.\n if (entry.output) existing.output = entry.output;\n else if (entry.error && !existing.output) existing.output = entry.error;\n return;\n }\n // `||` (not `??`) so an empty-string output falls back to the error, matching\n // the merge branch's truthy check above.\n const initialOutput = entry.output || entry.error;\n const evalId = entry.eval_id ?? fallbackEvalId;\n const created: SubagentDiscoverySnapshot = {\n id: entry.id,\n name: String(entry.subagent_type ?? 'subagent'),\n description: entry.label ?? entry.description ?? '',\n status,\n toolCallCount: typeof entry.tool_call_count === 'number' ? entry.tool_call_count : 0,\n messages: NO_TRANSCRIPT,\n messageCount: 0,\n currentText: '',\n ...(evalId ? { evalId } : {}),\n ...(typeof entry.duration_ms === 'number' ? { durationMs: entry.duration_ms } : {}),\n ...(initialOutput ? { output: initialOutput } : {}),\n };\n if (Array.isArray(entry.messages) && entry.messages.length > 0) {\n applyLaneTranscript(created, entry.messages);\n }\n applyLaneCut(created, entry);\n applyLaneUsage(created, entry);\n byDispatchId.set(entry.id, created);\n}\n\n/**\n * Where an in-eval dispatch's streamed steps ride, and what the wire left off\n * them, read off its entry's cut marker (`DEEP_AGENT_TRUNCATED_LANE_KEY`) as a\n * `task` card's is: the steps left off, and the whole lane's tool calls.\n */\nfunction applyLaneCut(snap: SubagentDiscoverySnapshot, entry: PtcSubagentEntry): void {\n const lane = readTruncatedLane(entry);\n if (Array.isArray(entry.messages) && entry.messages.length > 0) {\n snap.source = {\n lane: entry.id,\n transcript: entry.messages,\n ...(lane !== null && { truncated: lane }),\n };\n }\n if (lane === null) return;\n snap.omittedMessageCount = Math.max(0, lane.messages - snap.messageCount);\n snap.toolCallCount = Math.max(snap.toolCallCount, lane.toolCalls);\n}\n\nconst NO_LANE_STEPS: readonly LangChainMessage[] = [];\n\n/**\n * An entry that recorded its subagent's checkpoint namespace (`ns`, a registry\n * entry or the summary an eval persisted, since agora writes it) pages its\n * lane from that checkpoint when no streamed steps carry it.\n */\nfunction noteCheckpointedLane(\n snap: SubagentDiscoverySnapshot | undefined,\n entry: PtcSubagentEntry\n): void {\n if (snap === undefined || snap.source !== undefined) return;\n if (typeof entry.ns !== 'string' || !entry.ns) return;\n snap.source = { lane: entry.id, transcript: NO_LANE_STEPS, checkpointed: true };\n}\n\n/**\n * An in-eval lane's token use, from its entry's host total or the native steps\n * of its live transcript. A merge that brings neither keeps what the lane has.\n */\nfunction applyLaneUsage(snap: SubagentDiscoverySnapshot, entry: PtcSubagentEntry): void {\n const usage = laneTokenUsage(\n entry,\n transcriptStepUsage(snap.messages),\n snap.status,\n (snap.omittedMessageCount ?? 0) > 0\n );\n if (usage !== undefined) snap.usage = usage;\n}\n\n/**\n * The first call of a nested thread with one of `toolCallIds`: the calls a\n * subagent made are the tool-call parts of its transcript, ids included.\n */\nfunction findToolCall({\n messages,\n toolCallIds,\n}: {\n messages: readonly ThreadMessage[] | undefined;\n toolCallIds: ReadonlySet<string>;\n}): ToolCallMessagePart | undefined {\n if (messages === undefined) return undefined;\n for (const message of messages) {\n if (message.role !== 'assistant') continue;\n for (const part of message.content) {\n if (part.type === 'tool-call' && toolCallIds.has(part.toolCallId)) return part;\n }\n }\n return undefined;\n}\n\n/**\n * Whether a subagent lane waits on a person's approval, given the gated calls\n * still waiting on one (`toolCallIdsAwaitingApproval`): its own dispatch is the\n * gated call (a per-dispatch `task` gate), or a call it made is (a gated tool\n * raised inside the delegated subagent). The approval names the gated call's\n * `tool_call_id` and never the lane, and a lane's transcript carries the calls\n * it made with their ids, so the call id is the join. A settled lane waits on\n * nobody.\n */\nexport function subagentAwaitingApproval({\n lane,\n toolCallIds,\n}: {\n lane: Pick<SubagentDiscoverySnapshot, 'id' | 'status' | 'messages'>;\n /** The gated calls still waiting on a decision (`toolCallIdsAwaitingApproval`). */\n toolCallIds: ReadonlySet<string>;\n}): boolean {\n if (toolCallIds.size === 0 || isTerminalSubagentStatus(lane.status)) return false;\n return (\n toolCallIds.has(lane.id) ||\n findToolCall({ messages: lane.messages, toolCallIds }) !== undefined\n );\n}\n\n/**\n * The call a subagent made that waits on a person's approval (a gated tool\n * raised inside the delegated subagent), read off its transcript — what the\n * lane card names while it waits. `undefined` when the lane made none, which\n * includes a lane whose own dispatch is the gated call.\n */\nexport function subagentToolCallAwaitingApproval({\n lane,\n toolCallIds,\n}: {\n lane: Pick<SubagentDiscoverySnapshot, 'status' | 'messages'>;\n /** The gated calls still waiting on a decision (`toolCallIdsAwaitingApproval`). */\n toolCallIds: ReadonlySet<string>;\n}): LangChainToolCall | undefined {\n if (toolCallIds.size === 0 || isTerminalSubagentStatus(lane.status)) return undefined;\n const part = findToolCall({ messages: lane.messages, toolCallIds });\n return part === undefined\n ? undefined\n : { id: part.toolCallId, name: part.toolName, args: part.args };\n}\n\n/** What {@link subagentLanesHoldingUnseenApproval} finds: the lanes, and the call if one holds it. */\nexport interface UnseenApprovalLanes {\n /** The lanes holding a gated call none of their transcripts shows. */\n laneIds: ReadonlySet<string>;\n /**\n * The gated call, when exactly one lane holds exactly one such call. With\n * several candidate lanes the approval holds them all (the run is parked, so\n * none of them runs), but which one made the call is unknown.\n */\n gatedCallId: string | undefined;\n}\n\nconst NO_UNSEEN_APPROVAL_LANES: UnseenApprovalLanes = {\n laneIds: new Set(),\n gatedCallId: undefined,\n};\n\n/**\n * The lanes of one turn that wait on a gated call no transcript shows. The\n * approval names a call raised inside a delegated subagent by its\n * `tool_call_id`, and the lane's transcript is what joins the two\n * ({@link subagentAwaitingApproval}). But a lane's steps ride only on the\n * backend's running placeholder, which is never checkpointed: a conversation\n * opened after its run parked (a reload, another device, a handover) shows the\n * lane with no steps at all, and the join finds nothing. A gated call that is\n * none of the turn's own calls and is in no lane's transcript was raised inside\n * one of the turn's unsettled lanes whose steps did not ride.\n *\n * Pass only the lanes of the turn the run is on now (the thread's newest\n * message, running or waiting on a person): an earlier turn's unsettled lane\n * was stopped, not parked, though its status still reads `requires-action`.\n */\nexport function subagentLanesHoldingUnseenApproval({\n lanes,\n turnToolCallIds,\n toolCallIds,\n}: {\n lanes: readonly Pick<SubagentDiscoverySnapshot, 'id' | 'status' | 'messages'>[];\n /** Every tool-call id of the turn itself (its `task` calls included). */\n turnToolCallIds: ReadonlySet<string>;\n /** The gated calls still waiting on a decision (`toolCallIdsAwaitingApproval`). */\n toolCallIds: ReadonlySet<string>;\n}): UnseenApprovalLanes {\n if (toolCallIds.size === 0) return NO_UNSEEN_APPROVAL_LANES;\n const shown = new Set<string>();\n for (const lane of lanes) {\n for (const message of lane.messages) {\n if (message.role !== 'assistant') continue;\n for (const part of message.content) {\n if (part.type === 'tool-call' && toolCallIds.has(part.toolCallId)) {\n shown.add(part.toolCallId);\n }\n }\n }\n }\n const unseen: string[] = [...toolCallIds].filter(\n (id) => !turnToolCallIds.has(id) && !shown.has(id)\n );\n if (unseen.length === 0) return NO_UNSEEN_APPROVAL_LANES;\n const holders = lanes.filter(\n (lane) => !isTerminalSubagentStatus(lane.status) && lane.messages.length === 0\n );\n if (holders.length === 0) return NO_UNSEEN_APPROVAL_LANES;\n return {\n laneIds: new Set(holders.map((lane) => lane.id)),\n gatedCallId: holders.length === 1 && unseen.length === 1 ? unseen[0] : undefined,\n };\n}\n\n/**\n * Every tool-call id of the turn the run is on now, else `undefined`: the\n * thread's newest message, still running or waiting on a person. An earlier\n * turn keeps `requires-action` for a call that never got its result (a stopped\n * run's lane), so its status alone never says it owns the run's approval.\n * Pass it to {@link subagentLanesHoldingUnseenApproval} as `turnToolCallIds`.\n */\nexport function openTurnToolCallIds(\n message: Pick<ThreadMessage, 'role' | 'content' | 'status'> & { isLast: boolean }\n): ReadonlySet<string> | undefined {\n if (message.role !== 'assistant' || !message.isLast) return undefined;\n const status = message.status?.type;\n if (status !== 'running' && status !== 'requires-action') return undefined;\n const ids = new Set<string>();\n for (const part of message.content) {\n if (part.type === 'tool-call') ids.add(part.toolCallId);\n }\n return ids;\n}\n\n/**\n * What a subagent lane parked on a person's approval reads in every app (the\n * lane's status, where it would say Running or Queued).\n */\nexport const SUBAGENT_AWAITING_APPROVAL_LABEL = 'Waiting for approval';\n\n/** What a lane waits on, from {@link subagentLaneApprovalWait}. */\nexport interface SubagentLaneApprovalWait {\n /** The lane is parked on an approval: its own dispatch or a call it made is the gated call. */\n awaitingApproval: boolean;\n /** The call inside the lane the approval gates, when it is known. */\n gatedCall: LangChainToolCall | undefined;\n /** The approval gates a call the lane made that its card cannot show (its steps did not ride). */\n insideLane?: boolean;\n}\n\nconst NOT_AWAITING_APPROVAL: SubagentLaneApprovalWait = {\n awaitingApproval: false,\n gatedCall: undefined,\n};\n\n/**\n * Whether a lane waits on a person's approval, and on what: the call it made,\n * read off its transcript; or, for a lane whose steps did not ride (a\n * conversation opened after its run parked: {@link\n * subagentLanesHoldingUnseenApproval}), the call the approval names when this\n * lane alone can hold it, else only that it waits on a call it made. A lane\n * whose own dispatch is the gated call waits with no `gatedCall`.\n */\nexport function subagentLaneApprovalWait({\n lane,\n toolCallIds,\n unseenApproval,\n actionRequests,\n}: {\n lane: Pick<SubagentDiscoverySnapshot, 'id' | 'status' | 'messages'>;\n /** The gated calls still waiting on a decision (`toolCallIdsAwaitingApproval`). */\n toolCallIds: ReadonlySet<string>;\n /** The open turn's step-less lanes holding a gated call, when the lane is on that turn. */\n unseenApproval: UnseenApprovalLanes | undefined;\n /** The parked approval's gated calls, which name an unseen call's tool and arguments. */\n actionRequests: readonly Pick<PendingActionRequest, 'toolCallId' | 'name' | 'args'>[] | undefined;\n}): SubagentLaneApprovalWait {\n const unseen: boolean =\n !isTerminalSubagentStatus(lane.status) && unseenApproval?.laneIds.has(lane.id) === true;\n if (!subagentAwaitingApproval({ lane, toolCallIds }) && !unseen) return NOT_AWAITING_APPROVAL;\n const shown = subagentToolCallAwaitingApproval({ lane, toolCallIds });\n if (shown !== undefined || !unseen) return { awaitingApproval: true, gatedCall: shown };\n const gatedCallId: string | undefined = unseenApproval?.gatedCallId;\n const request = gatedCallId\n ? actionRequests?.find((candidate) => candidate.toolCallId === gatedCallId)\n : undefined;\n return {\n awaitingApproval: true,\n gatedCall:\n request && gatedCallId\n ? // The approval's args crossed the wire as JSON, as a call's own do.\n { id: gatedCallId, name: request.name, args: request.args as LangChainToolCall['args'] }\n : undefined,\n insideLane: true,\n };\n}\n\n/**\n * Whether the lane of the `task` call `toolCallId` in this turn waits on a\n * person's approval, and on what ({@link subagentLaneApprovalWait}), for a\n * card that shows one lane (the SDK's, the phone's). The lanes are the turn's\n * own; a lane's steps are its converted `messages`, else (a host that doesn't\n * convert them, like the phone) the transcript its running placeholder\n * carries. On the turn the run is on now ({@link openTurnToolCallIds}), a\n * gated call no lane shows is held by its step-less lanes\n * ({@link subagentLanesHoldingUnseenApproval}), so a conversation opened after\n * its run parked still reads as waiting for approval.\n */\nexport function turnLaneApprovalWait({\n message,\n toolCallId,\n toolCallIds,\n actionRequests,\n}: {\n message: ThreadMessage & { isLast: boolean };\n toolCallId: string;\n /** The gated calls still waiting on a decision (`toolCallIdsAwaitingApproval`). */\n toolCallIds: ReadonlySet<string>;\n /** The parked approval's gated calls, which name an unseen call's tool and arguments. */\n actionRequests: readonly Pick<PendingActionRequest, 'toolCallId' | 'name' | 'args'>[] | undefined;\n}): SubagentLaneApprovalWait {\n if (toolCallIds.size === 0 || message.role !== 'assistant') return NOT_AWAITING_APPROVAL;\n const artifacts = new Map<string, unknown>();\n for (const part of message.content) {\n if (part.type === 'tool-call' && part.toolName === TASK_TOOL_NAME) {\n artifacts.set(part.toolCallId, part.artifact);\n }\n }\n const lanes = [...taskSubagentsOfTurn(message).values()].map((lane) => {\n if (lane.messages.length > 0) return lane;\n const carried = nestedMessagesFromArtifact(artifacts.get(lane.id));\n return carried.length === 0\n ? lane\n : { ...lane, messages: convertSubagentTranscript(carried, lane.status === 'running') };\n });\n const lane = lanes.find((candidate) => candidate.id === toolCallId);\n if (lane === undefined) return NOT_AWAITING_APPROVAL;\n const turnToolCallIds = openTurnToolCallIds(message);\n return subagentLaneApprovalWait({\n lane,\n toolCallIds,\n unseenApproval:\n turnToolCallIds === undefined\n ? undefined\n : subagentLanesHoldingUnseenApproval({ lanes, turnToolCallIds, toolCallIds }),\n actionRequests,\n });\n}\n\n/**\n * What a lane waiting for approval says it waits on, in every app: a call it\n * made (\"Needs approval to run\", then the call), a call it made that its card\n * cannot name (\"Needs approval to continue\"), or its own dispatch (\"Needs\n * approval to start\").\n */\nexport function subagentApprovalNoteLabel({\n gatedCall,\n insideLane = false,\n}: Pick<SubagentLaneApprovalWait, 'gatedCall' | 'insideLane'>): string {\n if (gatedCall !== undefined) return 'Needs approval to run';\n return insideLane ? 'Needs approval to continue' : 'Needs approval to start';\n}\n\n/**\n * The calls of one converted turn that wait on a person's approval, in turn\n * order: a gated call of the turn itself, or a `task` call not yet settled\n * (no result, or the running placeholder) whose lane holds a gated call — the\n * steps the turn's step list reads as waiting rather than running or done.\n */\nexport function turnToolCallsAwaitingApproval({\n message,\n toolCallIds,\n}: {\n message: ThreadMessage;\n /** The gated calls still waiting on a decision (`toolCallIdsAwaitingApproval`). */\n toolCallIds: ReadonlySet<string>;\n}): string[] {\n if (toolCallIds.size === 0 || message.role !== 'assistant') return [];\n const ids: string[] = [];\n for (const part of message.content) {\n if (part.type !== 'tool-call') continue;\n if (toolCallIds.has(part.toolCallId)) {\n ids.push(part.toolCallId);\n continue;\n }\n if (part.toolName !== TASK_TOOL_NAME) continue;\n const settled = part.result !== undefined && part.isPreliminary !== true;\n if (!settled && findToolCall({ messages: part.messages, toolCallIds }) !== undefined) {\n ids.push(part.toolCallId);\n }\n }\n return ids;\n}\n\nconst NO_WAITING_TOOL_CALLS: ReadonlySet<string> = new Set();\n/** Joins call ids into one selector value; an id never holds it. */\nconst TOOL_CALL_ID_SEPARATOR = '\\n';\n\n/**\n * {@link turnToolCallsAwaitingApproval} for the message in scope: what a\n * turn's step list takes as `waitingToolCallIds`, given the run's waiting\n * calls (`toolCallIdsAwaitingApproval`). Selected as a joined string, so a\n * streamed token re-renders the caller only when the waiting steps change, and\n * the set keeps its identity while they do not. Olympus's activity card and\n * the SDK chat's turns both read it.\n */\nexport function useTurnToolCallsAwaitingApproval(\n toolCallIds: ReadonlySet<string>\n): ReadonlySet<string> {\n const key = useAuiState((s) =>\n toolCallIds.size === 0\n ? ''\n : turnToolCallsAwaitingApproval({ message: s.message, toolCallIds }).join(\n TOOL_CALL_ID_SEPARATOR\n )\n );\n return useMemo(\n () => (key === '' ? NO_WAITING_TOOL_CALLS : new Set(key.split(TOOL_CALL_ID_SEPARATOR))),\n [key]\n );\n}\n\n/** Result text shown for a dispatch whose owning run ended before it finished. */\nexport const ORPHANED_SUBAGENT_OUTPUT =\n 'Interrupted — the run that dispatched this subagent ended before it finished.';\n\n/**\n * Settle snapshots orphaned by their dispatching context: once the owner (e.g.\n * the `eval` tool call whose in-eval `task()` issued them) is itself terminal,\n * nothing can ever deliver a `complete`/`error` lifecycle event for a lane still\n * `queued`/`running` — the dispatch coroutines were cancelled with the eval. Those\n * lanes are coerced to `error` with an interruption message so the UI can't show\n * perpetual \"Running · no activity\" ghosts. Returns the input array unchanged\n * (same reference) when there is nothing to settle.\n */\nexport function finalizeOrphanedSubagents(\n snapshots: readonly SubagentDiscoverySnapshot[],\n ownerTerminal: boolean\n): readonly SubagentDiscoverySnapshot[] {\n if (!ownerTerminal || snapshots.every((s) => isTerminalSubagentStatus(s.status))) {\n return snapshots;\n }\n return snapshots.map((s) =>\n isTerminalSubagentStatus(s.status)\n ? s\n : { ...s, status: 'error', output: s.output || ORPHANED_SUBAGENT_OUTPUT }\n );\n}\n\n/**\n * The `task` tool calls sharing `toolCallId`'s parent AI message — the parallel\n * fan-out siblings, in declaration order. Parallel `task` calls always live on ONE\n * AI message's `tool_calls`, so \"same parent message\" IS the parallelism boundary;\n * sequential delegations sit on separate AI messages and form singleton groups.\n * The FIRST sibling is the group's `anchorId`: its tool-part render draws the whole\n * side-by-side group and the other siblings render nothing, keeping the layout\n * change fully inside the `task` tool UI. Falls back to a singleton group when the\n * parent AI message isn't among `messages` (a turn's bound sources, or a raw\n * transcript).\n */\nexport interface TaskSiblingGroup {\n /** Sibling `task` tool-call ids in declaration order. */\n ids: string[];\n /** The first sibling — the one tool-part render that owns the group's UI. */\n anchorId: string;\n}\n\nexport function taskSiblingGroup(\n messages: readonly LangChainMessage[],\n toolCallId: string\n): TaskSiblingGroup {\n for (const m of messages) {\n if (m.type !== 'ai' || !m.tool_calls) continue;\n if (!m.tool_calls.some((tc) => tc.id === toolCallId)) continue;\n const ids = m.tool_calls\n .filter((tc) => tc.name === TASK_TOOL_NAME && tc.id)\n .map((tc) => tc.id as string);\n if (ids.length > 0) return { ids, anchorId: ids[0] ?? toolCallId };\n break;\n }\n return { ids: [toolCallId], anchorId: toolCallId };\n}\n"],"names":[],"mappings":";;;;;;;AA+CO,SAAS,yBAAyB,QAAiC;AACxE,SAAO,WAAW,cAAc,WAAW;AAC7C;AA8HA,SAAS,qBAAqB,MAA6D;AACzF,MAAI,CAAC,KAAM,QAAO;AAClB,SAAO,OAAO,KAAK,iBAAiB,KAAK,gBAAgB,KAAK,YAAY,UAAU;AACtF;AAOO,SAAS,2BAA2B,UAAuC;;AAChF,QAAM,IAAI;AACV,WAAO,4BAAG,mBAAH,mBAAmB,aAAY,CAAA;AACxC;AA6CA,MAAM,UAAU,CAAC,UACf,OAAO,UAAU,YAAY,OAAO,UAAU,KAAK,KAAK,SAAS;AAQ5D,SAAS,kBAAkB,aAA4C;AAC5E,MAAI,OAAO,gBAAgB,YAAY,gBAAgB,KAAM,QAAO;AACpE,QAAM,SAAU,YAAwC,6BAA6B;AACrF,MAAI,OAAO,WAAW,YAAY,WAAW,KAAM,QAAO;AAC1D,QAAM,EAAE,UAAU,YAAY,WAAW,aAAa;AACtD,SAAO,QAAQ,QAAQ,KAAK,QAAQ,SAAS,IACzC,EAAE,UAAU,WAAW,UAAU,aAAa,KAAA,IAC9C;AACN;AAQO,SAAS,cAAc,MAAmC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AAM,MAAM;AAAA,IAAY,CAAC,MACvB,YAAY,SAAS,IACjB,KACA,8BAA8B,EAAE,SAAS,EAAE,SAAS,YAAA,CAAa,EAAE;AAAA,MACjE;AAAA,IAAA;AAAA,EACF;AAEN,SAAO;AAAA,IACL,MAAO,QAAQ,KAAK,wBAAwB,IAAI,IAAI,IAAI,MAAM,sBAAsB,CAAC;AAAA,IACrF,CAAC,GAAG;AAAA,EAAA;AAER;AAGO,MAAM,2BACX;AAWK,SAAS,0BACd,WACA,eACsC;AACtC,MAAI,CAAC,iBAAiB,UAAU,MAAM,CAAC,MAAM,yBAAyB,EAAE,MAAM,CAAC,GAAG;AAChF,WAAO;AAAA,EACT;AACA,SAAO,UAAU;AAAA,IAAI,CAAC,MACpB,yBAAyB,EAAE,MAAM,IAC7B,IACA,EAAE,GAAG,GAAG,QAAQ,SAAS,QAAQ,EAAE,UAAU,yBAAA;AAAA,EAAyB;AAE9E;AAoBO,SAAS,iBACd,UACA,YACkB;AAClB,aAAW,KAAK,UAAU;AACxB,QAAI,EAAE,SAAS,QAAQ,CAAC,EAAE,WAAY;AACtC,QAAI,CAAC,EAAE,WAAW,KAAK,CAAC,OAAO,GAAG,OAAO,UAAU,EAAG;AACtD,UAAM,MAAM,EAAE,WACX,OAAO,CAAC,OAAO,GAAG,SAAS,kBAAkB,GAAG,EAAE,EAClD,IAAI,CAAC,OAAO,GAAG,EAAY;AAC9B,QAAI,IAAI,SAAS,EAAG,QAAO,EAAE,KAAK,UAAU,IAAI,CAAC,KAAK,WAAA;AACtD;AAAA,EACF;AACA,SAAO,EAAE,KAAK,CAAC,UAAU,GAAG,UAAU,WAAA;AACxC;"}
@@ -1,38 +1,46 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const statewireHeldSends = require("./statewire-held-sends.cjs");
3
4
  function hasStatewireThreadExtras(extras) {
4
5
  if (!extras || typeof extras !== "object") return false;
5
6
  const candidate = extras;
6
7
  return typeof candidate.sendCommand === "function" && Array.isArray(candidate.inputRequests) && typeof candidate.runs === "object" && candidate.runs !== null;
7
8
  }
8
- function isFailedSendEntry(value) {
9
+ function readStatewireFailedSends(extras) {
9
10
  var _a;
10
- if (!value || typeof value !== "object") return false;
11
- const entry = value;
12
- return typeof entry.id === "string" && typeof ((_a = entry.sendFailure) == null ? void 0 : _a.fate) === "string";
11
+ if (!extras || typeof extras !== "object") return [];
12
+ const held = (_a = extras.runs) == null ? void 0 : _a.held;
13
+ if (!Array.isArray(held)) return [];
14
+ return held.flatMap((entry) => {
15
+ const candidate = entry;
16
+ if (typeof (candidate == null ? void 0 : candidate.id) !== "string" || !Array.isArray(candidate.parts)) return [];
17
+ const sendFailure = statewireHeldSends.heldSendFailure(candidate.localMeta);
18
+ return sendFailure === void 0 ? [] : [{ ...candidate, sendFailure }];
19
+ });
20
+ }
21
+ function failedActionsOf(extras) {
22
+ const outbox = statewireHeldSends.readStatewireOutbox(extras);
23
+ if (outbox === null) return null;
24
+ return {
25
+ retryFailed: (messageId) => statewireHeldSends.retryHeldRunSend({ outbox, messageId, thread: statewireHeldSends.runSendThreadOfExtras(extras) }),
26
+ discardFailed: (messageId) => statewireHeldSends.discardHeldRunSend({ outbox, messageId })
27
+ };
13
28
  }
14
29
  function readStatewireFailedSendLane(extras) {
15
- var _a;
16
- if (!extras || typeof extras !== "object") return null;
17
- const candidate = extras;
18
- const failed = (_a = candidate.runs) == null ? void 0 : _a.failed;
19
- if (!Array.isArray(failed) || typeof candidate.retryFailed !== "function") return null;
30
+ const actions = failedActionsOf(extras);
31
+ if (actions === null) return null;
20
32
  return {
21
- failed: failed.filter(isFailedSendEntry),
22
- retryFailed: candidate.retryFailed
33
+ failed: readStatewireFailedSends(extras).map(({ id, sendFailure }) => ({ id, sendFailure })),
34
+ retryFailed: actions.retryFailed
23
35
  };
24
36
  }
25
37
  function requireStatewireFailedActions(extras) {
26
- if (!extras || typeof extras !== "object") {
27
- throw new Error("Failed-send actions require a Statewire thread");
28
- }
29
- const candidate = extras;
30
- if (typeof candidate.retryFailed !== "function" || typeof candidate.discardFailed !== "function") {
31
- throw new Error("Failed-send actions require a Statewire thread");
32
- }
33
- return candidate;
38
+ const actions = failedActionsOf(extras);
39
+ if (actions === null) throw new Error("Failed-send actions require a Statewire thread");
40
+ return actions;
34
41
  }
35
42
  exports.hasStatewireThreadExtras = hasStatewireThreadExtras;
36
43
  exports.readStatewireFailedSendLane = readStatewireFailedSendLane;
44
+ exports.readStatewireFailedSends = readStatewireFailedSends;
37
45
  exports.requireStatewireFailedActions = requireStatewireFailedActions;
38
46
  //# sourceMappingURL=thread-extras.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"thread-extras.cjs","sources":["../../../../agent-runtime/src/thread-extras.ts"],"sourcesContent":["/**\n * The statewire hooks read the NEAREST aui thread's extras and throw when those\n * aren't statewire extras — which is the case inside nested read-only runtimes\n * (e.g. a transcript drawer) and on legacy (non-statewire) threads. Duck-type\n * the pieces the statewire components actually consume; a wider shape check\n * would silently hide live affordances if the library ever drops an unrelated\n * field.\n */\nexport function hasStatewireThreadExtras(extras: unknown): boolean {\n if (!extras || typeof extras !== 'object') return false;\n const candidate = extras as Record<string, unknown>;\n return (\n typeof candidate.sendCommand === 'function' &&\n Array.isArray(candidate.inputRequests) &&\n typeof candidate.runs === 'object' &&\n candidate.runs !== null\n );\n}\n\nexport interface StatewireFailedActions {\n retryFailed: (messageId: string) => void;\n discardFailed: (messageId: string) => void;\n}\n\n/** One projected failed run send: the message id plus the failure that\n * retained it (`runs.failed` entry, structurally). */\nexport interface StatewireFailedSendEntry {\n id: string;\n sendFailure: {\n fate: string;\n /**\n * Set on an `aborted` send that was never attempted because an earlier\n * send in the same detach batch WAS attempted and settled `lost`: the\n * library cannot know whether that predecessor ran, so the successor\n * must not be re-dispatched ahead of it (`StatewireClient.SendFailure`).\n */\n predecessorLost?: boolean;\n };\n}\n\n/** The failed-send lane surface the send-recovery controller consumes. */\nexport interface StatewireFailedSendLane {\n failed: readonly StatewireFailedSendEntry[];\n /** Re-dispatches the entry against the current thread — same message id,\n * re-anchored — and removes it from the lane. Throws for unknown ids. */\n retryFailed: (messageId: string) => void;\n}\n\nfunction isFailedSendEntry(value: unknown): value is StatewireFailedSendEntry {\n if (!value || typeof value !== 'object') return false;\n const entry = value as { id?: unknown; sendFailure?: { fate?: unknown } };\n return typeof entry.id === 'string' && typeof entry.sendFailure?.fate === 'string';\n}\n\n/**\n * The failed-send lane off a statewire thread's extras, or `null` when the\n * extras are not a statewire thread's (nested read-only runtimes, legacy\n * threads) — same duck-typing posture as {@link hasStatewireThreadExtras}.\n */\nexport function readStatewireFailedSendLane(extras: unknown): StatewireFailedSendLane | null {\n if (!extras || typeof extras !== 'object') return null;\n const candidate = extras as {\n runs?: { failed?: unknown };\n retryFailed?: unknown;\n };\n const failed = candidate.runs?.failed;\n if (!Array.isArray(failed) || typeof candidate.retryFailed !== 'function') return null;\n return {\n failed: failed.filter(isFailedSendEntry),\n retryFailed: candidate.retryFailed as StatewireFailedSendLane['retryFailed'],\n };\n}\n\n/** The failed-send lane actions off a statewire thread's extras, or throw. */\nexport function requireStatewireFailedActions(extras: unknown): StatewireFailedActions {\n if (!extras || typeof extras !== 'object') {\n throw new Error('Failed-send actions require a Statewire thread');\n }\n const candidate = extras as Record<string, unknown>;\n if (\n typeof candidate.retryFailed !== 'function' ||\n typeof candidate.discardFailed !== 'function'\n ) {\n throw new Error('Failed-send actions require a Statewire thread');\n }\n return candidate as unknown as StatewireFailedActions;\n}\n"],"names":[],"mappings":";;AAQO,SAAS,yBAAyB,QAA0B;AACjE,MAAI,CAAC,UAAU,OAAO,WAAW,SAAU,QAAO;AAClD,QAAM,YAAY;AAClB,SACE,OAAO,UAAU,gBAAgB,cACjC,MAAM,QAAQ,UAAU,aAAa,KACrC,OAAO,UAAU,SAAS,YAC1B,UAAU,SAAS;AAEvB;AA+BA,SAAS,kBAAkB,OAAmD;;AAC5E,MAAI,CAAC,SAAS,OAAO,UAAU,SAAU,QAAO;AAChD,QAAM,QAAQ;AACd,SAAO,OAAO,MAAM,OAAO,YAAY,SAAO,WAAM,gBAAN,mBAAmB,UAAS;AAC5E;AAOO,SAAS,4BAA4B,QAAiD;;AAC3F,MAAI,CAAC,UAAU,OAAO,WAAW,SAAU,QAAO;AAClD,QAAM,YAAY;AAIlB,QAAM,UAAS,eAAU,SAAV,mBAAgB;AAC/B,MAAI,CAAC,MAAM,QAAQ,MAAM,KAAK,OAAO,UAAU,gBAAgB,WAAY,QAAO;AAClF,SAAO;AAAA,IACL,QAAQ,OAAO,OAAO,iBAAiB;AAAA,IACvC,aAAa,UAAU;AAAA,EAAA;AAE3B;AAGO,SAAS,8BAA8B,QAAyC;AACrF,MAAI,CAAC,UAAU,OAAO,WAAW,UAAU;AACzC,UAAM,IAAI,MAAM,gDAAgD;AAAA,EAClE;AACA,QAAM,YAAY;AAClB,MACE,OAAO,UAAU,gBAAgB,cACjC,OAAO,UAAU,kBAAkB,YACnC;AACA,UAAM,IAAI,MAAM,gDAAgD;AAAA,EAClE;AACA,SAAO;AACT;;;;"}
1
+ {"version":3,"file":"thread-extras.cjs","sources":["../../../../agent-runtime/src/thread-extras.ts"],"sourcesContent":["import type { StatewireThread } from '@assistant-ui/react-statewire';\nimport {\n type DeepAgentSendFailure,\n discardHeldRunSend,\n readStatewireOutbox,\n heldSendFailure,\n retryHeldRunSend,\n runSendThreadOfExtras,\n} from './statewire-held-sends';\n\n/**\n * The statewire hooks read the NEAREST aui thread's extras and throw when those\n * aren't statewire extras — which is the case inside nested read-only runtimes\n * (e.g. a transcript drawer) and on legacy (non-statewire) threads. Duck-type\n * the pieces the statewire components actually consume; a wider shape check\n * would silently hide live affordances if the library ever drops an unrelated\n * field.\n */\nexport function hasStatewireThreadExtras(extras: unknown): boolean {\n if (!extras || typeof extras !== 'object') return false;\n const candidate = extras as Record<string, unknown>;\n return (\n typeof candidate.sendCommand === 'function' &&\n Array.isArray(candidate.inputRequests) &&\n typeof candidate.runs === 'object' &&\n candidate.runs !== null\n );\n}\n\nexport interface StatewireFailedActions {\n retryFailed: (messageId: string) => void;\n discardFailed: (messageId: string) => void;\n}\n\n/** One failed run send: the message id plus the failure its held outbox entry carries. */\nexport interface StatewireFailedSendEntry {\n id: string;\n sendFailure: {\n fate: string;\n cause?: string;\n /**\n * Set on an `aborted` send that was never attempted because an earlier\n * send in the same detach batch WAS attempted and settled `lost`: the\n * library cannot know whether that predecessor ran, so the successor\n * must not be re-dispatched ahead of it (`StatewireClient.SendFailure`).\n */\n predecessorLost?: boolean;\n };\n}\n\n/** A failed run send as a surface renders it: the held message plus its failure. */\nexport type StatewireFailedSend = StatewireThread.RunsHeldEntry & {\n readonly sendFailure: DeepAgentSendFailure;\n};\n\n/** The failed sends and the retry the send-recovery controller and the queue tray consume. */\nexport interface StatewireFailedSendLane {\n failed: readonly StatewireFailedSendEntry[];\n /** Sends the held entry again — same message id, re-anchored — and clears\n * its failure. Throws for unknown ids. */\n retryFailed: (messageId: string) => void;\n}\n\n/**\n * The failed run sends off a statewire thread's extras: the `runs.held`\n * entries whose outbox entry was held for a failure (`localMeta.error`, see\n * `statewire-held-sends.ts`), in queue order. Empty when the extras are not a\n * statewire thread's.\n */\nexport function readStatewireFailedSends(extras: unknown): StatewireFailedSend[] {\n if (!extras || typeof extras !== 'object') return [];\n const held = (extras as { runs?: { held?: unknown } }).runs?.held;\n if (!Array.isArray(held)) return [];\n return held.flatMap((entry: unknown): StatewireFailedSend[] => {\n const candidate = entry as Partial<StatewireThread.RunsHeldEntry> | null;\n if (typeof candidate?.id !== 'string' || !Array.isArray(candidate.parts)) return [];\n const sendFailure = heldSendFailure(candidate.localMeta);\n return sendFailure === undefined\n ? []\n : [{ ...(candidate as StatewireThread.RunsHeldEntry), sendFailure }];\n });\n}\n\nfunction failedActionsOf(extras: unknown): StatewireFailedActions | null {\n const outbox = readStatewireOutbox(extras);\n if (outbox === null) return null;\n return {\n retryFailed: (messageId) =>\n retryHeldRunSend({ outbox, messageId, thread: runSendThreadOfExtras(extras) }),\n discardFailed: (messageId) => discardHeldRunSend({ outbox, messageId }),\n };\n}\n\n/**\n * The failed-send lane off a statewire thread's extras, or `null` when the\n * extras are not a statewire thread's (nested read-only runtimes, legacy\n * threads) — same duck-typing posture as {@link hasStatewireThreadExtras}.\n */\nexport function readStatewireFailedSendLane(extras: unknown): StatewireFailedSendLane | null {\n const actions = failedActionsOf(extras);\n if (actions === null) return null;\n return {\n failed: readStatewireFailedSends(extras).map(({ id, sendFailure }) => ({ id, sendFailure })),\n retryFailed: actions.retryFailed,\n };\n}\n\n/** The failed-send actions off a statewire thread's extras, or throw. */\nexport function requireStatewireFailedActions(extras: unknown): StatewireFailedActions {\n const actions = failedActionsOf(extras);\n if (actions === null) throw new Error('Failed-send actions require a Statewire thread');\n return actions;\n}\n"],"names":["heldSendFailure","readStatewireOutbox","retryHeldRunSend","runSendThreadOfExtras","discardHeldRunSend"],"mappings":";;;AAkBO,SAAS,yBAAyB,QAA0B;AACjE,MAAI,CAAC,UAAU,OAAO,WAAW,SAAU,QAAO;AAClD,QAAM,YAAY;AAClB,SACE,OAAO,UAAU,gBAAgB,cACjC,MAAM,QAAQ,UAAU,aAAa,KACrC,OAAO,UAAU,SAAS,YAC1B,UAAU,SAAS;AAEvB;AA0CO,SAAS,yBAAyB,QAAwC;;AAC/E,MAAI,CAAC,UAAU,OAAO,WAAW,iBAAiB,CAAA;AAClD,QAAM,QAAQ,YAAyC,SAAzC,mBAA+C;AAC7D,MAAI,CAAC,MAAM,QAAQ,IAAI,UAAU,CAAA;AACjC,SAAO,KAAK,QAAQ,CAAC,UAA0C;AAC7D,UAAM,YAAY;AAClB,QAAI,QAAO,uCAAW,QAAO,YAAY,CAAC,MAAM,QAAQ,UAAU,KAAK,EAAG,QAAO,CAAA;AACjF,UAAM,cAAcA,mBAAAA,gBAAgB,UAAU,SAAS;AACvD,WAAO,gBAAgB,SACnB,CAAA,IACA,CAAC,EAAE,GAAI,WAA6C,aAAa;AAAA,EACvE,CAAC;AACH;AAEA,SAAS,gBAAgB,QAAgD;AACvE,QAAM,SAASC,mBAAAA,oBAAoB,MAAM;AACzC,MAAI,WAAW,KAAM,QAAO;AAC5B,SAAO;AAAA,IACL,aAAa,CAAC,cACZC,mBAAAA,iBAAiB,EAAE,QAAQ,WAAW,QAAQC,mBAAAA,sBAAsB,MAAM,GAAG;AAAA,IAC/E,eAAe,CAAC,cAAcC,mBAAAA,mBAAmB,EAAE,QAAQ,WAAW;AAAA,EAAA;AAE1E;AAOO,SAAS,4BAA4B,QAAiD;AAC3F,QAAM,UAAU,gBAAgB,MAAM;AACtC,MAAI,YAAY,KAAM,QAAO;AAC7B,SAAO;AAAA,IACL,QAAQ,yBAAyB,MAAM,EAAE,IAAI,CAAC,EAAE,IAAI,mBAAmB,EAAE,IAAI,cAAc;AAAA,IAC3F,aAAa,QAAQ;AAAA,EAAA;AAEzB;AAGO,SAAS,8BAA8B,QAAyC;AACrF,QAAM,UAAU,gBAAgB,MAAM;AACtC,MAAI,YAAY,KAAM,OAAM,IAAI,MAAM,gDAAgD;AACtF,SAAO;AACT;;;;;"}
@@ -1,3 +1,5 @@
1
+ import type { StatewireThread } from '@assistant-ui/react-statewire';
2
+ import { type DeepAgentSendFailure } from './statewire-held-sends';
1
3
  /**
2
4
  * The statewire hooks read the NEAREST aui thread's extras and throw when those
3
5
  * aren't statewire extras — which is the case inside nested read-only runtimes
@@ -11,12 +13,12 @@ export interface StatewireFailedActions {
11
13
  retryFailed: (messageId: string) => void;
12
14
  discardFailed: (messageId: string) => void;
13
15
  }
14
- /** One projected failed run send: the message id plus the failure that
15
- * retained it (`runs.failed` entry, structurally). */
16
+ /** One failed run send: the message id plus the failure its held outbox entry carries. */
16
17
  export interface StatewireFailedSendEntry {
17
18
  id: string;
18
19
  sendFailure: {
19
20
  fate: string;
21
+ cause?: string;
20
22
  /**
21
23
  * Set on an `aborted` send that was never attempted because an earlier
22
24
  * send in the same detach batch WAS attempted and settled `lost`: the
@@ -26,18 +28,29 @@ export interface StatewireFailedSendEntry {
26
28
  predecessorLost?: boolean;
27
29
  };
28
30
  }
29
- /** The failed-send lane surface the send-recovery controller consumes. */
31
+ /** A failed run send as a surface renders it: the held message plus its failure. */
32
+ export type StatewireFailedSend = StatewireThread.RunsHeldEntry & {
33
+ readonly sendFailure: DeepAgentSendFailure;
34
+ };
35
+ /** The failed sends and the retry the send-recovery controller and the queue tray consume. */
30
36
  export interface StatewireFailedSendLane {
31
37
  failed: readonly StatewireFailedSendEntry[];
32
- /** Re-dispatches the entry against the current thread — same message id,
33
- * re-anchored — and removes it from the lane. Throws for unknown ids. */
38
+ /** Sends the held entry again — same message id, re-anchored — and clears
39
+ * its failure. Throws for unknown ids. */
34
40
  retryFailed: (messageId: string) => void;
35
41
  }
42
+ /**
43
+ * The failed run sends off a statewire thread's extras: the `runs.held`
44
+ * entries whose outbox entry was held for a failure (`localMeta.error`, see
45
+ * `statewire-held-sends.ts`), in queue order. Empty when the extras are not a
46
+ * statewire thread's.
47
+ */
48
+ export declare function readStatewireFailedSends(extras: unknown): StatewireFailedSend[];
36
49
  /**
37
50
  * The failed-send lane off a statewire thread's extras, or `null` when the
38
51
  * extras are not a statewire thread's (nested read-only runtimes, legacy
39
52
  * threads) — same duck-typing posture as {@link hasStatewireThreadExtras}.
40
53
  */
41
54
  export declare function readStatewireFailedSendLane(extras: unknown): StatewireFailedSendLane | null;
42
- /** The failed-send lane actions off a statewire thread's extras, or throw. */
55
+ /** The failed-send actions off a statewire thread's extras, or throw. */
43
56
  export declare function requireStatewireFailedActions(extras: unknown): StatewireFailedActions;
@@ -1,38 +1,46 @@
1
+ import { heldSendFailure, readStatewireOutbox, discardHeldRunSend, retryHeldRunSend, runSendThreadOfExtras } from "./statewire-held-sends.js";
1
2
  function hasStatewireThreadExtras(extras) {
2
3
  if (!extras || typeof extras !== "object") return false;
3
4
  const candidate = extras;
4
5
  return typeof candidate.sendCommand === "function" && Array.isArray(candidate.inputRequests) && typeof candidate.runs === "object" && candidate.runs !== null;
5
6
  }
6
- function isFailedSendEntry(value) {
7
+ function readStatewireFailedSends(extras) {
7
8
  var _a;
8
- if (!value || typeof value !== "object") return false;
9
- const entry = value;
10
- return typeof entry.id === "string" && typeof ((_a = entry.sendFailure) == null ? void 0 : _a.fate) === "string";
9
+ if (!extras || typeof extras !== "object") return [];
10
+ const held = (_a = extras.runs) == null ? void 0 : _a.held;
11
+ if (!Array.isArray(held)) return [];
12
+ return held.flatMap((entry) => {
13
+ const candidate = entry;
14
+ if (typeof (candidate == null ? void 0 : candidate.id) !== "string" || !Array.isArray(candidate.parts)) return [];
15
+ const sendFailure = heldSendFailure(candidate.localMeta);
16
+ return sendFailure === void 0 ? [] : [{ ...candidate, sendFailure }];
17
+ });
18
+ }
19
+ function failedActionsOf(extras) {
20
+ const outbox = readStatewireOutbox(extras);
21
+ if (outbox === null) return null;
22
+ return {
23
+ retryFailed: (messageId) => retryHeldRunSend({ outbox, messageId, thread: runSendThreadOfExtras(extras) }),
24
+ discardFailed: (messageId) => discardHeldRunSend({ outbox, messageId })
25
+ };
11
26
  }
12
27
  function readStatewireFailedSendLane(extras) {
13
- var _a;
14
- if (!extras || typeof extras !== "object") return null;
15
- const candidate = extras;
16
- const failed = (_a = candidate.runs) == null ? void 0 : _a.failed;
17
- if (!Array.isArray(failed) || typeof candidate.retryFailed !== "function") return null;
28
+ const actions = failedActionsOf(extras);
29
+ if (actions === null) return null;
18
30
  return {
19
- failed: failed.filter(isFailedSendEntry),
20
- retryFailed: candidate.retryFailed
31
+ failed: readStatewireFailedSends(extras).map(({ id, sendFailure }) => ({ id, sendFailure })),
32
+ retryFailed: actions.retryFailed
21
33
  };
22
34
  }
23
35
  function requireStatewireFailedActions(extras) {
24
- if (!extras || typeof extras !== "object") {
25
- throw new Error("Failed-send actions require a Statewire thread");
26
- }
27
- const candidate = extras;
28
- if (typeof candidate.retryFailed !== "function" || typeof candidate.discardFailed !== "function") {
29
- throw new Error("Failed-send actions require a Statewire thread");
30
- }
31
- return candidate;
36
+ const actions = failedActionsOf(extras);
37
+ if (actions === null) throw new Error("Failed-send actions require a Statewire thread");
38
+ return actions;
32
39
  }
33
40
  export {
34
41
  hasStatewireThreadExtras,
35
42
  readStatewireFailedSendLane,
43
+ readStatewireFailedSends,
36
44
  requireStatewireFailedActions
37
45
  };
38
46
  //# sourceMappingURL=thread-extras.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"thread-extras.js","sources":["../../../../agent-runtime/src/thread-extras.ts"],"sourcesContent":["/**\n * The statewire hooks read the NEAREST aui thread's extras and throw when those\n * aren't statewire extras — which is the case inside nested read-only runtimes\n * (e.g. a transcript drawer) and on legacy (non-statewire) threads. Duck-type\n * the pieces the statewire components actually consume; a wider shape check\n * would silently hide live affordances if the library ever drops an unrelated\n * field.\n */\nexport function hasStatewireThreadExtras(extras: unknown): boolean {\n if (!extras || typeof extras !== 'object') return false;\n const candidate = extras as Record<string, unknown>;\n return (\n typeof candidate.sendCommand === 'function' &&\n Array.isArray(candidate.inputRequests) &&\n typeof candidate.runs === 'object' &&\n candidate.runs !== null\n );\n}\n\nexport interface StatewireFailedActions {\n retryFailed: (messageId: string) => void;\n discardFailed: (messageId: string) => void;\n}\n\n/** One projected failed run send: the message id plus the failure that\n * retained it (`runs.failed` entry, structurally). */\nexport interface StatewireFailedSendEntry {\n id: string;\n sendFailure: {\n fate: string;\n /**\n * Set on an `aborted` send that was never attempted because an earlier\n * send in the same detach batch WAS attempted and settled `lost`: the\n * library cannot know whether that predecessor ran, so the successor\n * must not be re-dispatched ahead of it (`StatewireClient.SendFailure`).\n */\n predecessorLost?: boolean;\n };\n}\n\n/** The failed-send lane surface the send-recovery controller consumes. */\nexport interface StatewireFailedSendLane {\n failed: readonly StatewireFailedSendEntry[];\n /** Re-dispatches the entry against the current thread — same message id,\n * re-anchored — and removes it from the lane. Throws for unknown ids. */\n retryFailed: (messageId: string) => void;\n}\n\nfunction isFailedSendEntry(value: unknown): value is StatewireFailedSendEntry {\n if (!value || typeof value !== 'object') return false;\n const entry = value as { id?: unknown; sendFailure?: { fate?: unknown } };\n return typeof entry.id === 'string' && typeof entry.sendFailure?.fate === 'string';\n}\n\n/**\n * The failed-send lane off a statewire thread's extras, or `null` when the\n * extras are not a statewire thread's (nested read-only runtimes, legacy\n * threads) — same duck-typing posture as {@link hasStatewireThreadExtras}.\n */\nexport function readStatewireFailedSendLane(extras: unknown): StatewireFailedSendLane | null {\n if (!extras || typeof extras !== 'object') return null;\n const candidate = extras as {\n runs?: { failed?: unknown };\n retryFailed?: unknown;\n };\n const failed = candidate.runs?.failed;\n if (!Array.isArray(failed) || typeof candidate.retryFailed !== 'function') return null;\n return {\n failed: failed.filter(isFailedSendEntry),\n retryFailed: candidate.retryFailed as StatewireFailedSendLane['retryFailed'],\n };\n}\n\n/** The failed-send lane actions off a statewire thread's extras, or throw. */\nexport function requireStatewireFailedActions(extras: unknown): StatewireFailedActions {\n if (!extras || typeof extras !== 'object') {\n throw new Error('Failed-send actions require a Statewire thread');\n }\n const candidate = extras as Record<string, unknown>;\n if (\n typeof candidate.retryFailed !== 'function' ||\n typeof candidate.discardFailed !== 'function'\n ) {\n throw new Error('Failed-send actions require a Statewire thread');\n }\n return candidate as unknown as StatewireFailedActions;\n}\n"],"names":[],"mappings":"AAQO,SAAS,yBAAyB,QAA0B;AACjE,MAAI,CAAC,UAAU,OAAO,WAAW,SAAU,QAAO;AAClD,QAAM,YAAY;AAClB,SACE,OAAO,UAAU,gBAAgB,cACjC,MAAM,QAAQ,UAAU,aAAa,KACrC,OAAO,UAAU,SAAS,YAC1B,UAAU,SAAS;AAEvB;AA+BA,SAAS,kBAAkB,OAAmD;AAxCvE;AAyCL,MAAI,CAAC,SAAS,OAAO,UAAU,SAAU,QAAO;AAChD,QAAM,QAAQ;AACd,SAAO,OAAO,MAAM,OAAO,YAAY,SAAO,WAAM,gBAAN,mBAAmB,UAAS;AAC5E;AAOO,SAAS,4BAA4B,QAAiD;AAnDtF;AAoDL,MAAI,CAAC,UAAU,OAAO,WAAW,SAAU,QAAO;AAClD,QAAM,YAAY;AAIlB,QAAM,UAAS,eAAU,SAAV,mBAAgB;AAC/B,MAAI,CAAC,MAAM,QAAQ,MAAM,KAAK,OAAO,UAAU,gBAAgB,WAAY,QAAO;AAClF,SAAO;AAAA,IACL,QAAQ,OAAO,OAAO,iBAAiB;AAAA,IACvC,aAAa,UAAU;AAAA,EAAA;AAE3B;AAGO,SAAS,8BAA8B,QAAyC;AACrF,MAAI,CAAC,UAAU,OAAO,WAAW,UAAU;AACzC,UAAM,IAAI,MAAM,gDAAgD;AAAA,EAClE;AACA,QAAM,YAAY;AAClB,MACE,OAAO,UAAU,gBAAgB,cACjC,OAAO,UAAU,kBAAkB,YACnC;AACA,UAAM,IAAI,MAAM,gDAAgD;AAAA,EAClE;AACA,SAAO;AACT;"}
1
+ {"version":3,"file":"thread-extras.js","sources":["../../../../agent-runtime/src/thread-extras.ts"],"sourcesContent":["import type { StatewireThread } from '@assistant-ui/react-statewire';\nimport {\n type DeepAgentSendFailure,\n discardHeldRunSend,\n readStatewireOutbox,\n heldSendFailure,\n retryHeldRunSend,\n runSendThreadOfExtras,\n} from './statewire-held-sends';\n\n/**\n * The statewire hooks read the NEAREST aui thread's extras and throw when those\n * aren't statewire extras — which is the case inside nested read-only runtimes\n * (e.g. a transcript drawer) and on legacy (non-statewire) threads. Duck-type\n * the pieces the statewire components actually consume; a wider shape check\n * would silently hide live affordances if the library ever drops an unrelated\n * field.\n */\nexport function hasStatewireThreadExtras(extras: unknown): boolean {\n if (!extras || typeof extras !== 'object') return false;\n const candidate = extras as Record<string, unknown>;\n return (\n typeof candidate.sendCommand === 'function' &&\n Array.isArray(candidate.inputRequests) &&\n typeof candidate.runs === 'object' &&\n candidate.runs !== null\n );\n}\n\nexport interface StatewireFailedActions {\n retryFailed: (messageId: string) => void;\n discardFailed: (messageId: string) => void;\n}\n\n/** One failed run send: the message id plus the failure its held outbox entry carries. */\nexport interface StatewireFailedSendEntry {\n id: string;\n sendFailure: {\n fate: string;\n cause?: string;\n /**\n * Set on an `aborted` send that was never attempted because an earlier\n * send in the same detach batch WAS attempted and settled `lost`: the\n * library cannot know whether that predecessor ran, so the successor\n * must not be re-dispatched ahead of it (`StatewireClient.SendFailure`).\n */\n predecessorLost?: boolean;\n };\n}\n\n/** A failed run send as a surface renders it: the held message plus its failure. */\nexport type StatewireFailedSend = StatewireThread.RunsHeldEntry & {\n readonly sendFailure: DeepAgentSendFailure;\n};\n\n/** The failed sends and the retry the send-recovery controller and the queue tray consume. */\nexport interface StatewireFailedSendLane {\n failed: readonly StatewireFailedSendEntry[];\n /** Sends the held entry again — same message id, re-anchored — and clears\n * its failure. Throws for unknown ids. */\n retryFailed: (messageId: string) => void;\n}\n\n/**\n * The failed run sends off a statewire thread's extras: the `runs.held`\n * entries whose outbox entry was held for a failure (`localMeta.error`, see\n * `statewire-held-sends.ts`), in queue order. Empty when the extras are not a\n * statewire thread's.\n */\nexport function readStatewireFailedSends(extras: unknown): StatewireFailedSend[] {\n if (!extras || typeof extras !== 'object') return [];\n const held = (extras as { runs?: { held?: unknown } }).runs?.held;\n if (!Array.isArray(held)) return [];\n return held.flatMap((entry: unknown): StatewireFailedSend[] => {\n const candidate = entry as Partial<StatewireThread.RunsHeldEntry> | null;\n if (typeof candidate?.id !== 'string' || !Array.isArray(candidate.parts)) return [];\n const sendFailure = heldSendFailure(candidate.localMeta);\n return sendFailure === undefined\n ? []\n : [{ ...(candidate as StatewireThread.RunsHeldEntry), sendFailure }];\n });\n}\n\nfunction failedActionsOf(extras: unknown): StatewireFailedActions | null {\n const outbox = readStatewireOutbox(extras);\n if (outbox === null) return null;\n return {\n retryFailed: (messageId) =>\n retryHeldRunSend({ outbox, messageId, thread: runSendThreadOfExtras(extras) }),\n discardFailed: (messageId) => discardHeldRunSend({ outbox, messageId }),\n };\n}\n\n/**\n * The failed-send lane off a statewire thread's extras, or `null` when the\n * extras are not a statewire thread's (nested read-only runtimes, legacy\n * threads) — same duck-typing posture as {@link hasStatewireThreadExtras}.\n */\nexport function readStatewireFailedSendLane(extras: unknown): StatewireFailedSendLane | null {\n const actions = failedActionsOf(extras);\n if (actions === null) return null;\n return {\n failed: readStatewireFailedSends(extras).map(({ id, sendFailure }) => ({ id, sendFailure })),\n retryFailed: actions.retryFailed,\n };\n}\n\n/** The failed-send actions off a statewire thread's extras, or throw. */\nexport function requireStatewireFailedActions(extras: unknown): StatewireFailedActions {\n const actions = failedActionsOf(extras);\n if (actions === null) throw new Error('Failed-send actions require a Statewire thread');\n return actions;\n}\n"],"names":[],"mappings":";AAkBO,SAAS,yBAAyB,QAA0B;AACjE,MAAI,CAAC,UAAU,OAAO,WAAW,SAAU,QAAO;AAClD,QAAM,YAAY;AAClB,SACE,OAAO,UAAU,gBAAgB,cACjC,MAAM,QAAQ,UAAU,aAAa,KACrC,OAAO,UAAU,SAAS,YAC1B,UAAU,SAAS;AAEvB;AA0CO,SAAS,yBAAyB,QAAwC;;AAC/E,MAAI,CAAC,UAAU,OAAO,WAAW,iBAAiB,CAAA;AAClD,QAAM,QAAQ,YAAyC,SAAzC,mBAA+C;AAC7D,MAAI,CAAC,MAAM,QAAQ,IAAI,UAAU,CAAA;AACjC,SAAO,KAAK,QAAQ,CAAC,UAA0C;AAC7D,UAAM,YAAY;AAClB,QAAI,QAAO,uCAAW,QAAO,YAAY,CAAC,MAAM,QAAQ,UAAU,KAAK,EAAG,QAAO,CAAA;AACjF,UAAM,cAAc,gBAAgB,UAAU,SAAS;AACvD,WAAO,gBAAgB,SACnB,CAAA,IACA,CAAC,EAAE,GAAI,WAA6C,aAAa;AAAA,EACvE,CAAC;AACH;AAEA,SAAS,gBAAgB,QAAgD;AACvE,QAAM,SAAS,oBAAoB,MAAM;AACzC,MAAI,WAAW,KAAM,QAAO;AAC5B,SAAO;AAAA,IACL,aAAa,CAAC,cACZ,iBAAiB,EAAE,QAAQ,WAAW,QAAQ,sBAAsB,MAAM,GAAG;AAAA,IAC/E,eAAe,CAAC,cAAc,mBAAmB,EAAE,QAAQ,WAAW;AAAA,EAAA;AAE1E;AAOO,SAAS,4BAA4B,QAAiD;AAC3F,QAAM,UAAU,gBAAgB,MAAM;AACtC,MAAI,YAAY,KAAM,QAAO;AAC7B,SAAO;AAAA,IACL,QAAQ,yBAAyB,MAAM,EAAE,IAAI,CAAC,EAAE,IAAI,mBAAmB,EAAE,IAAI,cAAc;AAAA,IAC3F,aAAa,QAAQ;AAAA,EAAA;AAEzB;AAGO,SAAS,8BAA8B,QAAyC;AACrF,QAAM,UAAU,gBAAgB,MAAM;AACtC,MAAI,YAAY,KAAM,OAAM,IAAI,MAAM,gDAAgD;AACtF,SAAO;AACT;"}
@@ -75,19 +75,19 @@ export declare const threadHandoffFlowMachine: import("xstate").StateMachine<Han
75
75
  } | {
76
76
  kind: "office_invitation";
77
77
  host: "excel" | "powerpoint" | "word";
78
+ } | {
79
+ kind: "chrome";
78
80
  } | {
79
81
  kind: "spaces";
80
82
  url: string;
83
+ } | {
84
+ kind: "next";
81
85
  } | {
82
86
  kind: "desktop";
83
87
  scheme_url: string;
84
88
  download_url: string;
85
89
  deployment_url: string;
86
90
  protocol_version: 1;
87
- } | {
88
- kind: "chrome";
89
- } | {
90
- kind: "next";
91
91
  };
92
92
  }, {
93
93
  run: ThreadHandoffRun;
@@ -138,19 +138,19 @@ export declare const threadHandoffFlowMachine: import("xstate").StateMachine<Han
138
138
  } | {
139
139
  kind: "office_invitation";
140
140
  host: "excel" | "powerpoint" | "word";
141
+ } | {
142
+ kind: "chrome";
141
143
  } | {
142
144
  kind: "spaces";
143
145
  url: string;
146
+ } | {
147
+ kind: "next";
144
148
  } | {
145
149
  kind: "desktop";
146
150
  scheme_url: string;
147
151
  download_url: string;
148
152
  deployment_url: string;
149
153
  protocol_version: 1;
150
- } | {
151
- kind: "chrome";
152
- } | {
153
- kind: "next";
154
154
  };
155
155
  }, {
156
156
  run: ThreadHandoffRun;