@athenaintel/react 0.28.1 → 0.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (817) hide show
  1. package/README.md +479 -10
  2. package/dist/agent-runtime/src/asset-attachment.cjs.map +1 -0
  3. package/dist/agent-runtime/src/asset-attachment.js.map +1 -0
  4. package/dist/agent-runtime/src/athena-asset-drag.cjs +44 -0
  5. package/dist/agent-runtime/src/athena-asset-drag.cjs.map +1 -0
  6. package/dist/agent-runtime/src/athena-asset-drag.js +44 -0
  7. package/dist/agent-runtime/src/athena-asset-drag.js.map +1 -0
  8. package/dist/agent-runtime/src/auth-denial.cjs.map +1 -0
  9. package/dist/agent-runtime/src/auth-denial.js.map +1 -0
  10. package/dist/agent-runtime/src/client-tool-bridge.cjs.map +1 -0
  11. package/dist/agent-runtime/src/client-tool-bridge.js.map +1 -0
  12. package/dist/agent-runtime/src/client-tools.cjs.map +1 -0
  13. package/dist/agent-runtime/src/client-tools.js.map +1 -0
  14. package/dist/agent-runtime/src/composer-markdown.cjs +124 -0
  15. package/dist/agent-runtime/src/composer-markdown.cjs.map +1 -0
  16. package/dist/agent-runtime/src/composer-markdown.js +124 -0
  17. package/dist/agent-runtime/src/composer-markdown.js.map +1 -0
  18. package/dist/agent-runtime/src/config-mutations.cjs +59 -0
  19. package/dist/agent-runtime/src/config-mutations.cjs.map +1 -0
  20. package/dist/agent-runtime/src/config-mutations.js +59 -0
  21. package/dist/agent-runtime/src/config-mutations.js.map +1 -0
  22. package/dist/agent-runtime/src/conversation-index.cjs.map +1 -0
  23. package/dist/agent-runtime/src/conversation-index.js.map +1 -0
  24. package/dist/{packages/agent-runtime → agent-runtime}/src/conversation-list.cjs +36 -0
  25. package/dist/agent-runtime/src/conversation-list.cjs.map +1 -0
  26. package/dist/{packages/agent-runtime → agent-runtime}/src/conversation-list.js +36 -0
  27. package/dist/agent-runtime/src/conversation-list.js.map +1 -0
  28. package/dist/{packages/agent-runtime → agent-runtime}/src/deep-agent-transport-recipe.cjs +5 -3
  29. package/dist/agent-runtime/src/deep-agent-transport-recipe.cjs.map +1 -0
  30. package/dist/{packages/agent-runtime → agent-runtime}/src/deep-agent-transport-recipe.js +6 -4
  31. package/dist/agent-runtime/src/deep-agent-transport-recipe.js.map +1 -0
  32. package/dist/agent-runtime/src/edit-command.cjs.map +1 -0
  33. package/dist/agent-runtime/src/edit-command.js.map +1 -0
  34. package/dist/{packages/agent-runtime → agent-runtime}/src/errors.cjs +23 -0
  35. package/dist/agent-runtime/src/errors.cjs.map +1 -0
  36. package/dist/{packages/agent-runtime → agent-runtime}/src/errors.js +23 -0
  37. package/dist/agent-runtime/src/errors.js.map +1 -0
  38. package/dist/agent-runtime/src/execute-output.cjs +41 -0
  39. package/dist/agent-runtime/src/execute-output.cjs.map +1 -0
  40. package/dist/agent-runtime/src/execute-output.js +41 -0
  41. package/dist/agent-runtime/src/execute-output.js.map +1 -0
  42. package/dist/{packages/agent-runtime → agent-runtime}/src/generated/runconfig-contract.cjs +16 -2
  43. package/dist/agent-runtime/src/generated/runconfig-contract.cjs.map +1 -0
  44. package/dist/{packages/agent-runtime → agent-runtime}/src/generated/runconfig-contract.js +16 -2
  45. package/dist/agent-runtime/src/generated/runconfig-contract.js.map +1 -0
  46. package/dist/agent-runtime/src/github-wake-event.cjs.map +1 -0
  47. package/dist/agent-runtime/src/github-wake-event.js.map +1 -0
  48. package/dist/{packages/agent-runtime → agent-runtime}/src/interrupts.cjs +24 -1
  49. package/dist/agent-runtime/src/interrupts.cjs.map +1 -0
  50. package/dist/{packages/agent-runtime → agent-runtime}/src/interrupts.js +24 -1
  51. package/dist/agent-runtime/src/interrupts.js.map +1 -0
  52. package/dist/agent-runtime/src/message-author.cjs.map +1 -0
  53. package/dist/agent-runtime/src/message-author.js.map +1 -0
  54. package/dist/agent-runtime/src/message-window.cjs.map +1 -0
  55. package/dist/agent-runtime/src/message-window.js.map +1 -0
  56. package/dist/{packages/agent-runtime → agent-runtime}/src/messages.cjs +8 -4
  57. package/dist/agent-runtime/src/messages.cjs.map +1 -0
  58. package/dist/{packages/agent-runtime → agent-runtime}/src/messages.js +6 -2
  59. package/dist/agent-runtime/src/messages.js.map +1 -0
  60. package/dist/agent-runtime/src/model-context.cjs.map +1 -0
  61. package/dist/agent-runtime/src/model-context.js.map +1 -0
  62. package/dist/agent-runtime/src/optimistic-content.cjs.map +1 -0
  63. package/dist/agent-runtime/src/optimistic-content.js.map +1 -0
  64. package/dist/agent-runtime/src/protocol.cjs.map +1 -0
  65. package/dist/agent-runtime/src/protocol.js.map +1 -0
  66. package/dist/{packages/agent-runtime → agent-runtime}/src/queue.cjs +23 -2
  67. package/dist/agent-runtime/src/queue.cjs.map +1 -0
  68. package/dist/{packages/agent-runtime → agent-runtime}/src/queue.js +23 -2
  69. package/dist/agent-runtime/src/queue.js.map +1 -0
  70. package/dist/{packages/agent-runtime → agent-runtime}/src/quota-safe-local-storage-session.cjs +71 -13
  71. package/dist/agent-runtime/src/quota-safe-local-storage-session.cjs.map +1 -0
  72. package/dist/{packages/agent-runtime → agent-runtime}/src/quota-safe-local-storage-session.js +73 -15
  73. package/dist/agent-runtime/src/quota-safe-local-storage-session.js.map +1 -0
  74. package/dist/agent-runtime/src/runtime-messages.cjs.map +1 -0
  75. package/dist/agent-runtime/src/runtime-messages.js.map +1 -0
  76. package/dist/agent-runtime/src/screen-point.cjs.map +1 -0
  77. package/dist/agent-runtime/src/screen-point.js.map +1 -0
  78. package/dist/agent-runtime/src/send-recovery.cjs.map +1 -0
  79. package/dist/agent-runtime/src/send-recovery.js.map +1 -0
  80. package/dist/agent-runtime/src/statewire-attach-observer.cjs.map +1 -0
  81. package/dist/agent-runtime/src/statewire-attach-observer.js.map +1 -0
  82. package/dist/{packages/agent-runtime → agent-runtime}/src/statewire-state.cjs +8 -0
  83. package/dist/agent-runtime/src/statewire-state.cjs.map +1 -0
  84. package/dist/{packages/agent-runtime → agent-runtime}/src/statewire-state.js +8 -0
  85. package/dist/agent-runtime/src/statewire-state.js.map +1 -0
  86. package/dist/{packages/agent-runtime → agent-runtime}/src/statewire-suspended.cjs +4 -0
  87. package/dist/agent-runtime/src/statewire-suspended.cjs.map +1 -0
  88. package/dist/{packages/agent-runtime → agent-runtime}/src/statewire-suspended.js +4 -0
  89. package/dist/agent-runtime/src/statewire-suspended.js.map +1 -0
  90. package/dist/agent-runtime/src/statewire-transport.cjs +43 -0
  91. package/dist/agent-runtime/src/statewire-transport.cjs.map +1 -0
  92. package/dist/agent-runtime/src/statewire-transport.js +43 -0
  93. package/dist/agent-runtime/src/statewire-transport.js.map +1 -0
  94. package/dist/agent-runtime/src/streaming-markdown.cjs.map +1 -0
  95. package/dist/agent-runtime/src/streaming-markdown.js.map +1 -0
  96. package/dist/agent-runtime/src/subscription-wake-event.cjs +252 -0
  97. package/dist/agent-runtime/src/subscription-wake-event.cjs.map +1 -0
  98. package/dist/agent-runtime/src/subscription-wake-event.js +252 -0
  99. package/dist/agent-runtime/src/subscription-wake-event.js.map +1 -0
  100. package/dist/agent-runtime/src/thread-extras.cjs.map +1 -0
  101. package/dist/agent-runtime/src/thread-extras.js.map +1 -0
  102. package/dist/agent-runtime/src/thread-snapshot-cache.cjs.map +1 -0
  103. package/dist/agent-runtime/src/thread-snapshot-cache.js.map +1 -0
  104. package/dist/agent-runtime/src/thread-status.cjs.map +1 -0
  105. package/dist/agent-runtime/src/thread-status.js.map +1 -0
  106. package/dist/{packages/agent-runtime → agent-runtime}/src/tool-metadata.cjs +304 -9
  107. package/dist/agent-runtime/src/tool-metadata.cjs.map +1 -0
  108. package/dist/{packages/agent-runtime → agent-runtime}/src/tool-metadata.js +304 -9
  109. package/dist/agent-runtime/src/tool-metadata.js.map +1 -0
  110. package/dist/agent-runtime/src/tool-names.cjs +5 -0
  111. package/dist/agent-runtime/src/tool-names.cjs.map +1 -0
  112. package/dist/agent-runtime/src/tool-names.js +5 -0
  113. package/dist/agent-runtime/src/tool-names.js.map +1 -0
  114. package/dist/agent-runtime/src/tool-outputs.cjs.map +1 -0
  115. package/dist/agent-runtime/src/tool-outputs.js.map +1 -0
  116. package/dist/agent-runtime/src/tool-result.cjs.map +1 -0
  117. package/dist/agent-runtime/src/tool-result.js.map +1 -0
  118. package/dist/{packages/agent-runtime → agent-runtime}/src/use-conversation-list.cjs +33 -22
  119. package/dist/agent-runtime/src/use-conversation-list.cjs.map +1 -0
  120. package/dist/{packages/agent-runtime → agent-runtime}/src/use-conversation-list.js +34 -23
  121. package/dist/agent-runtime/src/use-conversation-list.js.map +1 -0
  122. package/dist/agent-runtime/src/use-deep-agent-config.cjs +129 -0
  123. package/dist/agent-runtime/src/use-deep-agent-config.cjs.map +1 -0
  124. package/dist/agent-runtime/src/use-deep-agent-config.js +129 -0
  125. package/dist/agent-runtime/src/use-deep-agent-config.js.map +1 -0
  126. package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-edit-submit.cjs +2 -0
  127. package/dist/agent-runtime/src/use-deep-agent-edit-submit.cjs.map +1 -0
  128. package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-edit-submit.js +2 -0
  129. package/dist/agent-runtime/src/use-deep-agent-edit-submit.js.map +1 -0
  130. package/dist/agent-runtime/src/use-deep-agent-runtime.cjs.map +1 -0
  131. package/dist/agent-runtime/src/use-deep-agent-runtime.js.map +1 -0
  132. package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-thread.cjs +1 -0
  133. package/dist/agent-runtime/src/use-deep-agent-thread.cjs.map +1 -0
  134. package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-thread.js +2 -1
  135. package/dist/agent-runtime/src/use-deep-agent-thread.js.map +1 -0
  136. package/dist/agent-runtime/src/use-deep-agent-window-sync.cjs.map +1 -0
  137. package/dist/agent-runtime/src/use-deep-agent-window-sync.js.map +1 -0
  138. package/dist/agent-runtime/src/use-historical-edit-attachments.cjs +52 -0
  139. package/dist/agent-runtime/src/use-historical-edit-attachments.cjs.map +1 -0
  140. package/dist/agent-runtime/src/use-historical-edit-attachments.js +52 -0
  141. package/dist/agent-runtime/src/use-historical-edit-attachments.js.map +1 -0
  142. package/dist/{packages/agent-runtime → agent-runtime}/src/voice-presentation.cjs +14 -0
  143. package/dist/agent-runtime/src/voice-presentation.cjs.map +1 -0
  144. package/dist/{packages/agent-runtime → agent-runtime}/src/voice-presentation.js +14 -0
  145. package/dist/agent-runtime/src/voice-presentation.js.map +1 -0
  146. package/dist/agent-runtime/src/voice-turn-grouping.cjs.map +1 -0
  147. package/dist/agent-runtime/src/voice-turn-grouping.js.map +1 -0
  148. package/dist/assets/AthenaAssetEmbed.cjs +13 -2
  149. package/dist/assets/AthenaAssetEmbed.cjs.map +1 -1
  150. package/dist/assets/AthenaAssetEmbed.d.ts +10 -0
  151. package/dist/assets/AthenaAssetEmbed.js +14 -3
  152. package/dist/assets/AthenaAssetEmbed.js.map +1 -1
  153. package/dist/assets/AthenaLayout.cjs +97 -31
  154. package/dist/assets/AthenaLayout.cjs.map +1 -1
  155. package/dist/assets/AthenaLayout.d.ts +13 -0
  156. package/dist/assets/AthenaLayout.js +98 -32
  157. package/dist/assets/AthenaLayout.js.map +1 -1
  158. package/dist/assets/asset-embed-messages.cjs +6 -0
  159. package/dist/assets/asset-embed-messages.cjs.map +1 -1
  160. package/dist/assets/asset-embed-messages.d.ts +13 -0
  161. package/dist/assets/asset-embed-messages.js +6 -0
  162. package/dist/assets/asset-embed-messages.js.map +1 -1
  163. package/dist/assets/asset-panel-store.cjs +68 -32
  164. package/dist/assets/asset-panel-store.cjs.map +1 -1
  165. package/dist/assets/asset-panel-store.d.ts +47 -1
  166. package/dist/assets/asset-panel-store.js +68 -32
  167. package/dist/assets/asset-panel-store.js.map +1 -1
  168. package/dist/assets/use-asset-embed.cjs +29 -8
  169. package/dist/assets/use-asset-embed.cjs.map +1 -1
  170. package/dist/assets/use-asset-embed.d.ts +7 -0
  171. package/dist/assets/use-asset-embed.js +29 -8
  172. package/dist/assets/use-asset-embed.js.map +1 -1
  173. package/dist/catalog/chat-pickers.cjs +152 -0
  174. package/dist/catalog/chat-pickers.cjs.map +1 -0
  175. package/dist/catalog/chat-pickers.d.ts +22 -0
  176. package/dist/catalog/chat-pickers.js +152 -0
  177. package/dist/catalog/chat-pickers.js.map +1 -0
  178. package/dist/catalog/runtime-catalog.cjs +181 -0
  179. package/dist/catalog/runtime-catalog.cjs.map +1 -0
  180. package/dist/catalog/runtime-catalog.d.ts +100 -0
  181. package/dist/catalog/runtime-catalog.js +181 -0
  182. package/dist/catalog/runtime-catalog.js.map +1 -0
  183. package/dist/chat/AthenaChat.cjs +122 -67
  184. package/dist/chat/AthenaChat.cjs.map +1 -1
  185. package/dist/chat/AthenaChat.d.ts +21 -4
  186. package/dist/chat/AthenaChat.js +124 -69
  187. package/dist/chat/AthenaChat.js.map +1 -1
  188. package/dist/chat/StatewireApprovalCard.cjs +38 -37
  189. package/dist/chat/StatewireApprovalCard.cjs.map +1 -1
  190. package/dist/chat/StatewireApprovalCard.d.ts +2 -0
  191. package/dist/chat/StatewireApprovalCard.js +39 -38
  192. package/dist/chat/StatewireApprovalCard.js.map +1 -1
  193. package/dist/chat/StatewireClientToolBridge.cjs +2 -2
  194. package/dist/chat/StatewireClientToolBridge.js +2 -2
  195. package/dist/chat/StatewireQueuedMessages.cjs +15 -12
  196. package/dist/chat/StatewireQueuedMessages.cjs.map +1 -1
  197. package/dist/chat/StatewireQueuedMessages.d.ts +22 -2
  198. package/dist/chat/StatewireQueuedMessages.js +15 -12
  199. package/dist/chat/StatewireQueuedMessages.js.map +1 -1
  200. package/dist/chat/StatewireRunRefusalNotice.cjs +48 -0
  201. package/dist/chat/StatewireRunRefusalNotice.cjs.map +1 -0
  202. package/dist/chat/StatewireRunRefusalNotice.d.ts +25 -0
  203. package/dist/chat/StatewireRunRefusalNotice.js +48 -0
  204. package/dist/chat/StatewireRunRefusalNotice.js.map +1 -0
  205. package/dist/chat/WaitingOnYouBanner.cjs +2 -2
  206. package/dist/chat/WaitingOnYouBanner.js +2 -2
  207. package/dist/chat/athena-citation-links.cjs +19 -15
  208. package/dist/chat/athena-citation-links.cjs.map +1 -1
  209. package/dist/chat/athena-citation-links.js +19 -15
  210. package/dist/chat/athena-citation-links.js.map +1 -1
  211. package/dist/chat/run-activity.cjs +9 -1
  212. package/dist/chat/run-activity.cjs.map +1 -1
  213. package/dist/chat/run-activity.d.ts +6 -0
  214. package/dist/chat/run-activity.js +10 -2
  215. package/dist/chat/run-activity.js.map +1 -1
  216. package/dist/chat/statewire-banners.cjs +30 -1
  217. package/dist/chat/statewire-banners.cjs.map +1 -1
  218. package/dist/chat/statewire-banners.d.ts +20 -1
  219. package/dist/chat/statewire-banners.js +32 -3
  220. package/dist/chat/statewire-banners.js.map +1 -1
  221. package/dist/chat/statewire-client-tools.cjs +1 -1
  222. package/dist/chat/statewire-client-tools.js +1 -1
  223. package/dist/chat/super-grouping/CollapsibleGroup.cjs +1 -1
  224. package/dist/chat/super-grouping/CollapsibleGroup.cjs.map +1 -1
  225. package/dist/chat/super-grouping/CollapsibleGroup.js +1 -1
  226. package/dist/chat/super-grouping/CollapsibleGroup.js.map +1 -1
  227. package/dist/chat/super-grouping/SuperGroupingCard.cjs +38 -16
  228. package/dist/chat/super-grouping/SuperGroupingCard.cjs.map +1 -1
  229. package/dist/chat/super-grouping/SuperGroupingCard.d.ts +21 -4
  230. package/dist/chat/super-grouping/SuperGroupingCard.js +39 -17
  231. package/dist/chat/super-grouping/SuperGroupingCard.js.map +1 -1
  232. package/dist/chat/super-grouping/SuperGroupingTranscript.cjs +377 -0
  233. package/dist/chat/super-grouping/SuperGroupingTranscript.cjs.map +1 -0
  234. package/dist/chat/super-grouping/SuperGroupingTranscript.d.ts +31 -0
  235. package/dist/chat/super-grouping/SuperGroupingTranscript.js +377 -0
  236. package/dist/chat/super-grouping/SuperGroupingTranscript.js.map +1 -0
  237. package/dist/chat/super-grouping/ToolTimeline.cjs +13 -2
  238. package/dist/chat/super-grouping/ToolTimeline.cjs.map +1 -1
  239. package/dist/chat/super-grouping/ToolTimeline.d.ts +10 -3
  240. package/dist/chat/super-grouping/ToolTimeline.js +13 -2
  241. package/dist/chat/super-grouping/ToolTimeline.js.map +1 -1
  242. package/dist/chat/super-grouping/activity-timeline.cjs +69 -29
  243. package/dist/chat/super-grouping/activity-timeline.cjs.map +1 -1
  244. package/dist/chat/super-grouping/activity-timeline.d.ts +60 -9
  245. package/dist/chat/super-grouping/activity-timeline.js +70 -30
  246. package/dist/chat/super-grouping/activity-timeline.js.map +1 -1
  247. package/dist/chat/super-grouping/index.cjs +14 -0
  248. package/dist/chat/super-grouping/index.cjs.map +1 -1
  249. package/dist/chat/super-grouping/index.d.ts +7 -2
  250. package/dist/chat/super-grouping/index.js +16 -2
  251. package/dist/chat/super-grouping/index.js.map +1 -1
  252. package/dist/chat/super-grouping/timeline-step.cjs +14 -5
  253. package/dist/chat/super-grouping/timeline-step.cjs.map +1 -1
  254. package/dist/chat/super-grouping/timeline-step.d.ts +10 -1
  255. package/dist/chat/super-grouping/timeline-step.js +15 -6
  256. package/dist/chat/super-grouping/timeline-step.js.map +1 -1
  257. package/dist/chat/super-grouping/toolkit-map.cjs +1 -0
  258. package/dist/chat/super-grouping/toolkit-map.cjs.map +1 -1
  259. package/dist/chat/super-grouping/toolkit-map.js +1 -0
  260. package/dist/chat/super-grouping/toolkit-map.js.map +1 -1
  261. package/dist/chat/super-grouping/turn-segments.cjs +82 -0
  262. package/dist/chat/super-grouping/turn-segments.cjs.map +1 -0
  263. package/dist/chat/super-grouping/turn-segments.d.ts +69 -0
  264. package/dist/chat/super-grouping/turn-segments.js +82 -0
  265. package/dist/chat/super-grouping/turn-segments.js.map +1 -0
  266. package/dist/chat/super-grouping/turn-timing.cjs +110 -0
  267. package/dist/chat/super-grouping/turn-timing.cjs.map +1 -0
  268. package/dist/chat/super-grouping/turn-timing.d.ts +52 -0
  269. package/dist/chat/super-grouping/turn-timing.js +110 -0
  270. package/dist/chat/super-grouping/turn-timing.js.map +1 -0
  271. package/dist/chat/tiptap-text.cjs +1 -1
  272. package/dist/chat/tiptap-text.js +1 -1
  273. package/dist/chat/use-athena-run-live.cjs +1 -1
  274. package/dist/chat/use-athena-run-live.js +1 -1
  275. package/dist/chat/use-statewire-approval-request.cjs +73 -4
  276. package/dist/chat/use-statewire-approval-request.cjs.map +1 -1
  277. package/dist/chat/use-statewire-approval-request.js +74 -5
  278. package/dist/chat/use-statewire-approval-request.js.map +1 -1
  279. package/dist/chat-ui/composer/composer-message.cjs +284 -0
  280. package/dist/chat-ui/composer/composer-message.cjs.map +1 -0
  281. package/dist/chat-ui/composer/composer-message.d.ts +152 -0
  282. package/dist/chat-ui/composer/composer-message.js +284 -0
  283. package/dist/chat-ui/composer/composer-message.js.map +1 -0
  284. package/dist/chat-ui/composer/tiptap-composer.cjs +97 -15
  285. package/dist/chat-ui/composer/tiptap-composer.cjs.map +1 -1
  286. package/dist/chat-ui/composer/tiptap-composer.d.ts +34 -6
  287. package/dist/chat-ui/composer/tiptap-composer.js +97 -15
  288. package/dist/chat-ui/composer/tiptap-composer.js.map +1 -1
  289. package/dist/chat-ui/index.cjs +4 -1
  290. package/dist/chat-ui/index.cjs.map +1 -1
  291. package/dist/chat-ui/index.d.ts +3 -2
  292. package/dist/chat-ui/index.js +5 -2
  293. package/dist/chat-ui/index.js.map +1 -1
  294. package/dist/chat-ui/mentions/mention-chip.cjs +31 -3
  295. package/dist/chat-ui/mentions/mention-chip.cjs.map +1 -1
  296. package/dist/chat-ui/mentions/mention-chip.d.ts +2 -5
  297. package/dist/chat-ui/mentions/mention-chip.js +33 -5
  298. package/dist/chat-ui/mentions/mention-chip.js.map +1 -1
  299. package/dist/chat-ui/mentions/mention-extension.cjs +9 -3
  300. package/dist/chat-ui/mentions/mention-extension.cjs.map +1 -1
  301. package/dist/chat-ui/mentions/mention-extension.js +9 -3
  302. package/dist/chat-ui/mentions/mention-extension.js.map +1 -1
  303. package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-popup.cjs +3 -1
  304. package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-popup.cjs.map +1 -1
  305. package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-popup.js +3 -1
  306. package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-popup.js.map +1 -1
  307. package/dist/chat-ui/mentions/suggestions/data/sources/index.cjs +65 -19
  308. package/dist/chat-ui/mentions/suggestions/data/sources/index.cjs.map +1 -1
  309. package/dist/chat-ui/mentions/suggestions/data/sources/index.d.ts +15 -0
  310. package/dist/chat-ui/mentions/suggestions/data/sources/index.js +67 -21
  311. package/dist/chat-ui/mentions/suggestions/data/sources/index.js.map +1 -1
  312. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.cjs +4 -2
  313. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.cjs.map +1 -1
  314. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.d.ts +2 -1
  315. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.js +5 -3
  316. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.js.map +1 -1
  317. package/dist/chat-ui/mentions/use-account-workspace-id.cjs +61 -0
  318. package/dist/chat-ui/mentions/use-account-workspace-id.cjs.map +1 -0
  319. package/dist/chat-ui/mentions/use-account-workspace-id.d.ts +3 -0
  320. package/dist/chat-ui/mentions/use-account-workspace-id.js +61 -0
  321. package/dist/chat-ui/mentions/use-account-workspace-id.js.map +1 -0
  322. package/dist/chat-ui/mentions/use-member-avatar.cjs +75 -0
  323. package/dist/chat-ui/mentions/use-member-avatar.cjs.map +1 -0
  324. package/dist/chat-ui/mentions/use-member-avatar.d.ts +2 -0
  325. package/dist/chat-ui/mentions/use-member-avatar.js +75 -0
  326. package/dist/chat-ui/mentions/use-member-avatar.js.map +1 -0
  327. package/dist/chat-ui/messages/message-components.cjs +30 -10
  328. package/dist/chat-ui/messages/message-components.cjs.map +1 -1
  329. package/dist/chat-ui/messages/message-components.d.ts +21 -1
  330. package/dist/chat-ui/messages/message-components.js +30 -10
  331. package/dist/chat-ui/messages/message-components.js.map +1 -1
  332. package/dist/chat-ui/messages/runtime-message.cjs +1 -1
  333. package/dist/chat-ui/messages/runtime-message.js +1 -1
  334. package/dist/chat-ui/messages/statewire-continue-run.cjs +5 -5
  335. package/dist/chat-ui/messages/statewire-continue-run.js +5 -5
  336. package/dist/chat-ui/messages/user-edit-composer.cjs +1 -1
  337. package/dist/chat-ui/messages/user-edit-composer.js +1 -1
  338. package/dist/chat-ui/messages/wake-marker.cjs +39 -4
  339. package/dist/chat-ui/messages/wake-marker.cjs.map +1 -1
  340. package/dist/chat-ui/messages/wake-marker.d.ts +16 -5
  341. package/dist/chat-ui/messages/wake-marker.js +40 -5
  342. package/dist/chat-ui/messages/wake-marker.js.map +1 -1
  343. package/dist/chat-ui/rich-text/chat-message-body.cjs +12 -8
  344. package/dist/chat-ui/rich-text/chat-message-body.cjs.map +1 -1
  345. package/dist/chat-ui/rich-text/chat-message-body.d.ts +6 -1
  346. package/dist/chat-ui/rich-text/chat-message-body.js +13 -9
  347. package/dist/chat-ui/rich-text/chat-message-body.js.map +1 -1
  348. package/dist/chat-ui/rich-text/chat-text-schema.cjs +64 -6
  349. package/dist/chat-ui/rich-text/chat-text-schema.cjs.map +1 -1
  350. package/dist/chat-ui/rich-text/chat-text-schema.d.ts +5 -0
  351. package/dist/chat-ui/rich-text/chat-text-schema.js +66 -8
  352. package/dist/chat-ui/rich-text/chat-text-schema.js.map +1 -1
  353. package/dist/chat-ui/statewire.cjs +1 -1
  354. package/dist/chat-ui/statewire.d.ts +1 -1
  355. package/dist/chat-ui/statewire.js +1 -1
  356. package/dist/chat-ui/thread/statewire-history-edge.cjs +2 -2
  357. package/dist/chat-ui/thread/statewire-history-edge.js +2 -2
  358. package/dist/collab/client.cjs +282 -16
  359. package/dist/collab/client.cjs.map +1 -1
  360. package/dist/collab/client.d.ts +127 -2
  361. package/dist/collab/client.js +285 -20
  362. package/dist/collab/client.js.map +1 -1
  363. package/dist/collab/index.cjs +2 -0
  364. package/dist/collab/index.cjs.map +1 -1
  365. package/dist/collab/index.d.ts +1 -1
  366. package/dist/collab/index.js +3 -1
  367. package/dist/composer/AttachmentContext.cjs +38 -12
  368. package/dist/composer/AttachmentContext.cjs.map +1 -1
  369. package/dist/composer/AttachmentContext.d.ts +22 -1
  370. package/dist/composer/AttachmentContext.js +40 -14
  371. package/dist/composer/AttachmentContext.js.map +1 -1
  372. package/dist/composer/QuoteContext.cjs +80 -28
  373. package/dist/composer/QuoteContext.cjs.map +1 -1
  374. package/dist/composer/QuoteContext.d.ts +35 -6
  375. package/dist/composer/QuoteContext.js +82 -30
  376. package/dist/composer/QuoteContext.js.map +1 -1
  377. package/dist/composer/build-composed-message.cjs +27 -0
  378. package/dist/composer/build-composed-message.cjs.map +1 -1
  379. package/dist/composer/build-composed-message.d.ts +21 -0
  380. package/dist/composer/build-composed-message.js +28 -1
  381. package/dist/composer/build-composed-message.js.map +1 -1
  382. package/dist/composer/composer-handoff.cjs +13 -1
  383. package/dist/composer/composer-handoff.cjs.map +1 -1
  384. package/dist/composer/composer-handoff.d.ts +12 -0
  385. package/dist/composer/composer-handoff.js +15 -3
  386. package/dist/composer/composer-handoff.js.map +1 -1
  387. package/dist/composer/index.d.ts +6 -3
  388. package/dist/composer/useReadComposerDraft.cjs +16 -0
  389. package/dist/composer/useReadComposerDraft.cjs.map +1 -0
  390. package/dist/composer/useReadComposerDraft.d.ts +6 -0
  391. package/dist/composer/useReadComposerDraft.js +16 -0
  392. package/dist/composer/useReadComposerDraft.js.map +1 -0
  393. package/dist/diagnostics/athena-diagnostics.cjs.map +1 -1
  394. package/dist/diagnostics/athena-diagnostics.d.ts +3 -1
  395. package/dist/diagnostics/athena-diagnostics.js.map +1 -1
  396. package/dist/diagnostics/errors.cjs +6 -0
  397. package/dist/diagnostics/errors.cjs.map +1 -1
  398. package/dist/diagnostics/errors.d.ts +6 -0
  399. package/dist/diagnostics/errors.js +6 -0
  400. package/dist/diagnostics/errors.js.map +1 -1
  401. package/dist/index.cjs +163 -7
  402. package/dist/index.cjs.map +1 -1
  403. package/dist/index.d.ts +55 -12
  404. package/dist/index.js +170 -14
  405. package/dist/index.js.map +1 -1
  406. package/dist/lib/owner-document.cjs +32 -0
  407. package/dist/lib/owner-document.cjs.map +1 -0
  408. package/dist/lib/owner-document.d.ts +17 -0
  409. package/dist/lib/owner-document.js +32 -0
  410. package/dist/lib/owner-document.js.map +1 -0
  411. package/dist/lib/portal-surface.cjs +55 -0
  412. package/dist/lib/portal-surface.cjs.map +1 -0
  413. package/dist/lib/portal-surface.d.ts +37 -0
  414. package/dist/lib/portal-surface.js +55 -0
  415. package/dist/lib/portal-surface.js.map +1 -0
  416. package/dist/lib/use-athena-rest-query.cjs +34 -0
  417. package/dist/lib/use-athena-rest-query.cjs.map +1 -0
  418. package/dist/lib/use-athena-rest-query.d.ts +31 -0
  419. package/dist/lib/use-athena-rest-query.js +34 -0
  420. package/dist/lib/use-athena-rest-query.js.map +1 -0
  421. package/dist/provider/AthenaProvider.cjs +70 -10
  422. package/dist/provider/AthenaProvider.cjs.map +1 -1
  423. package/dist/provider/AthenaProvider.d.ts +27 -2
  424. package/dist/provider/AthenaProvider.js +74 -14
  425. package/dist/provider/AthenaProvider.js.map +1 -1
  426. package/dist/provider/citation-links.d.ts +10 -2
  427. package/dist/{packages/react → react}/package.json.cjs +1 -1
  428. package/dist/{packages/react → react}/package.json.js +1 -1
  429. package/dist/runtime/StatewireModelLaneSync.cjs +96 -0
  430. package/dist/runtime/StatewireModelLaneSync.cjs.map +1 -0
  431. package/dist/runtime/StatewireModelLaneSync.d.ts +45 -0
  432. package/dist/runtime/StatewireModelLaneSync.js +96 -0
  433. package/dist/runtime/StatewireModelLaneSync.js.map +1 -0
  434. package/dist/runtime/statewire-lifecycle.cjs +20 -5
  435. package/dist/runtime/statewire-lifecycle.cjs.map +1 -1
  436. package/dist/runtime/statewire-lifecycle.d.ts +11 -0
  437. package/dist/runtime/statewire-lifecycle.js +20 -5
  438. package/dist/runtime/statewire-lifecycle.js.map +1 -1
  439. package/dist/runtime/statewire-model-lane.cjs +28 -0
  440. package/dist/runtime/statewire-model-lane.cjs.map +1 -0
  441. package/dist/runtime/statewire-model-lane.d.ts +64 -0
  442. package/dist/runtime/statewire-model-lane.js +28 -0
  443. package/dist/runtime/statewire-model-lane.js.map +1 -0
  444. package/dist/runtime/statewire-run-config.cjs +16 -2
  445. package/dist/runtime/statewire-run-config.cjs.map +1 -1
  446. package/dist/runtime/statewire-run-config.d.ts +10 -0
  447. package/dist/runtime/statewire-run-config.js +16 -2
  448. package/dist/runtime/statewire-run-config.js.map +1 -1
  449. package/dist/runtime/statewire-server-lane-context.cjs +24 -0
  450. package/dist/runtime/statewire-server-lane-context.cjs.map +1 -0
  451. package/dist/runtime/statewire-server-lane-context.d.ts +30 -0
  452. package/dist/runtime/statewire-server-lane-context.js +24 -0
  453. package/dist/runtime/statewire-server-lane-context.js.map +1 -0
  454. package/dist/runtime/useAthenaStatewireRuntime.cjs +47 -23
  455. package/dist/runtime/useAthenaStatewireRuntime.cjs.map +1 -1
  456. package/dist/runtime/useAthenaStatewireRuntime.d.ts +8 -1
  457. package/dist/runtime/useAthenaStatewireRuntime.js +48 -24
  458. package/dist/runtime/useAthenaStatewireRuntime.js.map +1 -1
  459. package/dist/search/useAthenaRepoSearch.cjs +5 -13
  460. package/dist/search/useAthenaRepoSearch.cjs.map +1 -1
  461. package/dist/search/useAthenaRepoSearch.d.ts +3 -3
  462. package/dist/search/useAthenaRepoSearch.js +6 -14
  463. package/dist/search/useAthenaRepoSearch.js.map +1 -1
  464. package/dist/sheet-range/a1.cjs +162 -0
  465. package/dist/sheet-range/a1.cjs.map +1 -0
  466. package/dist/sheet-range/a1.d.ts +91 -0
  467. package/dist/sheet-range/a1.js +162 -0
  468. package/dist/sheet-range/a1.js.map +1 -0
  469. package/dist/sheet-range/index.cjs +22 -0
  470. package/dist/sheet-range/index.cjs.map +1 -0
  471. package/dist/sheet-range/index.d.ts +12 -0
  472. package/dist/sheet-range/index.js +22 -0
  473. package/dist/sheet-range/index.js.map +1 -0
  474. package/dist/sheet-range/range-preview-table.cjs +75 -0
  475. package/dist/sheet-range/range-preview-table.cjs.map +1 -0
  476. package/dist/sheet-range/range-preview-table.d.ts +20 -0
  477. package/dist/sheet-range/range-preview-table.js +75 -0
  478. package/dist/sheet-range/range-preview-table.js.map +1 -0
  479. package/dist/sheet-range/range-preview.cjs +116 -0
  480. package/dist/sheet-range/range-preview.cjs.map +1 -0
  481. package/dist/sheet-range/range-preview.d.ts +67 -0
  482. package/dist/sheet-range/range-preview.js +116 -0
  483. package/dist/sheet-range/range-preview.js.map +1 -0
  484. package/dist/styles.css +1 -1
  485. package/dist/threads/Inbox.cjs +289 -0
  486. package/dist/threads/Inbox.cjs.map +1 -0
  487. package/dist/threads/Inbox.d.ts +46 -0
  488. package/dist/threads/Inbox.js +289 -0
  489. package/dist/threads/Inbox.js.map +1 -0
  490. package/dist/threads/SessionList.cjs +51 -126
  491. package/dist/threads/SessionList.cjs.map +1 -1
  492. package/dist/threads/SessionList.d.ts +26 -1
  493. package/dist/threads/SessionList.js +45 -120
  494. package/dist/threads/SessionList.js.map +1 -1
  495. package/dist/threads/SessionsPage.cjs +753 -0
  496. package/dist/threads/SessionsPage.cjs.map +1 -0
  497. package/dist/threads/SessionsPage.d.ts +35 -0
  498. package/dist/threads/SessionsPage.js +753 -0
  499. package/dist/threads/SessionsPage.js.map +1 -0
  500. package/dist/threads/api.cjs +23 -2
  501. package/dist/threads/api.cjs.map +1 -1
  502. package/dist/threads/api.d.ts +60 -0
  503. package/dist/threads/api.js +23 -2
  504. package/dist/threads/api.js.map +1 -1
  505. package/dist/threads/conversation-list-fetcher.cjs +9 -2
  506. package/dist/threads/conversation-list-fetcher.cjs.map +1 -1
  507. package/dist/threads/conversation-list-fetcher.d.ts +14 -1
  508. package/dist/threads/conversation-list-fetcher.js +9 -2
  509. package/dist/threads/conversation-list-fetcher.js.map +1 -1
  510. package/dist/threads/index.d.ts +2 -1
  511. package/dist/threads/pull-request-display.cjs +25 -0
  512. package/dist/threads/pull-request-display.cjs.map +1 -0
  513. package/dist/threads/pull-request-display.d.ts +15 -0
  514. package/dist/threads/pull-request-display.js +25 -0
  515. package/dist/threads/pull-request-display.js.map +1 -0
  516. package/dist/threads/session-list-model.cjs +16 -2
  517. package/dist/threads/session-list-model.cjs.map +1 -1
  518. package/dist/threads/session-list-model.d.ts +10 -0
  519. package/dist/threads/session-list-model.js +16 -2
  520. package/dist/threads/session-list-model.js.map +1 -1
  521. package/dist/threads/session-row-parts.cjs +152 -0
  522. package/dist/threads/session-row-parts.cjs.map +1 -0
  523. package/dist/threads/session-row-parts.d.ts +50 -0
  524. package/dist/threads/session-row-parts.js +152 -0
  525. package/dist/threads/session-row-parts.js.map +1 -0
  526. package/dist/threads/sessions-page-model.cjs +305 -0
  527. package/dist/threads/sessions-page-model.cjs.map +1 -0
  528. package/dist/threads/sessions-page-model.d.ts +86 -0
  529. package/dist/threads/sessions-page-model.js +305 -0
  530. package/dist/threads/sessions-page-model.js.map +1 -0
  531. package/dist/threads/sessions-page-storage.cjs +93 -0
  532. package/dist/threads/sessions-page-storage.cjs.map +1 -0
  533. package/dist/threads/sessions-page-storage.d.ts +23 -0
  534. package/dist/threads/sessions-page-storage.js +93 -0
  535. package/dist/threads/sessions-page-storage.js.map +1 -0
  536. package/dist/threads/sessions-query.cjs +235 -0
  537. package/dist/threads/sessions-query.cjs.map +1 -0
  538. package/dist/threads/sessions-query.d.ts +119 -0
  539. package/dist/threads/sessions-query.js +235 -0
  540. package/dist/threads/sessions-query.js.map +1 -0
  541. package/dist/threads/statewire-thread-list.cjs +133 -40
  542. package/dist/threads/statewire-thread-list.cjs.map +1 -1
  543. package/dist/threads/statewire-thread-list.d.ts +83 -2
  544. package/dist/threads/statewire-thread-list.js +134 -41
  545. package/dist/threads/statewire-thread-list.js.map +1 -1
  546. package/dist/threads/use-athena-sessions.cjs +198 -0
  547. package/dist/threads/use-athena-sessions.cjs.map +1 -0
  548. package/dist/threads/use-athena-sessions.d.ts +81 -0
  549. package/dist/threads/use-athena-sessions.js +198 -0
  550. package/dist/threads/use-athena-sessions.js.map +1 -0
  551. package/dist/threads/use-athena-thread-model.cjs +14 -0
  552. package/dist/threads/use-athena-thread-model.cjs.map +1 -0
  553. package/dist/threads/use-athena-thread-model.d.ts +22 -0
  554. package/dist/threads/use-athena-thread-model.js +14 -0
  555. package/dist/threads/use-athena-thread-model.js.map +1 -0
  556. package/dist/threads/use-rest-conversation-history.cjs +1 -1
  557. package/dist/threads/use-rest-conversation-history.js +1 -1
  558. package/dist/threads/use-statewire-conversation-history.cjs +1 -1
  559. package/dist/threads/use-statewire-conversation-history.d.ts +3 -0
  560. package/dist/threads/use-statewire-conversation-history.js +1 -1
  561. package/dist/threads/use-thread-read-state.cjs +73 -0
  562. package/dist/threads/use-thread-read-state.cjs.map +1 -0
  563. package/dist/threads/use-thread-read-state.d.ts +51 -0
  564. package/dist/threads/use-thread-read-state.js +73 -0
  565. package/dist/threads/use-thread-read-state.js.map +1 -0
  566. package/dist/tiptap-markdown-table/src/markdown-table-serializer.cjs.map +1 -0
  567. package/dist/tiptap-markdown-table/src/markdown-table-serializer.js.map +1 -0
  568. package/dist/tools/auto-open-tools.cjs +2 -0
  569. package/dist/tools/auto-open-tools.cjs.map +1 -1
  570. package/dist/tools/auto-open-tools.js +2 -0
  571. package/dist/tools/auto-open-tools.js.map +1 -1
  572. package/dist/tools/file-tool-uis.cjs +18 -43
  573. package/dist/tools/file-tool-uis.cjs.map +1 -1
  574. package/dist/tools/file-tool-uis.d.ts +1 -2
  575. package/dist/tools/file-tool-uis.js +18 -42
  576. package/dist/tools/file-tool-uis.js.map +1 -1
  577. package/dist/tools/index.cjs +6 -2
  578. package/dist/tools/index.cjs.map +1 -1
  579. package/dist/tools/index.d.ts +1 -0
  580. package/dist/tools/index.js +6 -2
  581. package/dist/tools/index.js.map +1 -1
  582. package/dist/tools/misc-tool-uis.cjs +2 -2
  583. package/dist/tools/misc-tool-uis.js +2 -2
  584. package/dist/tools/primitives.cjs +1 -1
  585. package/dist/tools/primitives.js +1 -1
  586. package/dist/tools/read-asset-tool-ui.cjs +21 -70
  587. package/dist/tools/read-asset-tool-ui.cjs.map +1 -1
  588. package/dist/tools/read-asset-tool-ui.js +21 -70
  589. package/dist/tools/read-asset-tool-ui.js.map +1 -1
  590. package/dist/tools/step-text.cjs +21 -0
  591. package/dist/tools/step-text.cjs.map +1 -0
  592. package/dist/tools/step-text.d.ts +10 -0
  593. package/dist/tools/step-text.js +21 -0
  594. package/dist/tools/step-text.js.map +1 -0
  595. package/dist/tools/tool-fallback.cjs +24 -5
  596. package/dist/tools/tool-fallback.cjs.map +1 -1
  597. package/dist/tools/tool-fallback.d.ts +3 -1
  598. package/dist/tools/tool-fallback.js +24 -5
  599. package/dist/tools/tool-fallback.js.map +1 -1
  600. package/dist/tools/tool-summary.cjs +661 -0
  601. package/dist/tools/tool-summary.cjs.map +1 -0
  602. package/dist/tools/tool-summary.d.ts +99 -0
  603. package/dist/tools/tool-summary.js +661 -0
  604. package/dist/tools/tool-summary.js.map +1 -0
  605. package/dist/tools/tool-uis.cjs +37 -95
  606. package/dist/tools/tool-uis.cjs.map +1 -1
  607. package/dist/tools/tool-uis.js +37 -95
  608. package/dist/tools/tool-uis.js.map +1 -1
  609. package/dist/tools/voice-update-tool-ui.cjs +1 -1
  610. package/dist/tools/voice-update-tool-ui.js +1 -1
  611. package/dist/tools/write-todos-tool-ui.cjs +3 -2
  612. package/dist/tools/write-todos-tool-ui.cjs.map +1 -1
  613. package/dist/tools/write-todos-tool-ui.d.ts +5 -0
  614. package/dist/tools/write-todos-tool-ui.js +5 -4
  615. package/dist/tools/write-todos-tool-ui.js.map +1 -1
  616. package/dist/ui/popover.cjs +6 -6
  617. package/dist/ui/popover.cjs.map +1 -1
  618. package/dist/ui/popover.js +6 -6
  619. package/dist/ui/popover.js.map +1 -1
  620. package/dist/ui/tooltip.cjs +16 -2
  621. package/dist/ui/tooltip.cjs.map +1 -1
  622. package/dist/ui/tooltip.d.ts +1 -1
  623. package/dist/ui/tooltip.js +16 -2
  624. package/dist/ui/tooltip.js.map +1 -1
  625. package/dist/version.cjs +1 -1
  626. package/dist/version.js +1 -1
  627. package/dist/voice/use-athena-voice-session.cjs.map +1 -1
  628. package/dist/voice/use-athena-voice-session.d.ts +3 -3
  629. package/dist/voice/use-athena-voice-session.js.map +1 -1
  630. package/dist/workbench/SessionWorkbench.cjs +378 -0
  631. package/dist/workbench/SessionWorkbench.cjs.map +1 -0
  632. package/dist/workbench/SessionWorkbench.d.ts +30 -0
  633. package/dist/workbench/SessionWorkbench.js +378 -0
  634. package/dist/workbench/SessionWorkbench.js.map +1 -0
  635. package/dist/workbench/session-workbench-context.cjs +26 -0
  636. package/dist/workbench/session-workbench-context.cjs.map +1 -0
  637. package/dist/workbench/session-workbench-context.d.ts +55 -0
  638. package/dist/workbench/session-workbench-context.js +26 -0
  639. package/dist/workbench/session-workbench-context.js.map +1 -0
  640. package/dist/workbench/session-workbench-model.cjs +288 -0
  641. package/dist/workbench/session-workbench-model.cjs.map +1 -0
  642. package/dist/workbench/session-workbench-model.d.ts +168 -0
  643. package/dist/workbench/session-workbench-model.js +288 -0
  644. package/dist/workbench/session-workbench-model.js.map +1 -0
  645. package/dist/workbench/session-workbench-panes.cjs +580 -0
  646. package/dist/workbench/session-workbench-panes.cjs.map +1 -0
  647. package/dist/workbench/session-workbench-panes.d.ts +16 -0
  648. package/dist/workbench/session-workbench-panes.js +580 -0
  649. package/dist/workbench/session-workbench-panes.js.map +1 -0
  650. package/dist/workbench/session-workspace-api.cjs +157 -0
  651. package/dist/workbench/session-workspace-api.cjs.map +1 -0
  652. package/dist/workbench/session-workspace-api.d.ts +70 -0
  653. package/dist/workbench/session-workspace-api.js +157 -0
  654. package/dist/workbench/session-workspace-api.js.map +1 -0
  655. package/dist/workbench/use-session-workspace.cjs +100 -0
  656. package/dist/workbench/use-session-workspace.cjs.map +1 -0
  657. package/dist/workbench/use-session-workspace.d.ts +45 -0
  658. package/dist/workbench/use-session-workspace.js +100 -0
  659. package/dist/workbench/use-session-workspace.js.map +1 -0
  660. package/dist/workbench/workbench-layout-context.cjs +10 -0
  661. package/dist/workbench/workbench-layout-context.cjs.map +1 -0
  662. package/dist/workbench/workbench-layout-context.d.ts +17 -0
  663. package/dist/workbench/workbench-layout-context.js +10 -0
  664. package/dist/workbench/workbench-layout-context.js.map +1 -0
  665. package/package.json +21 -10
  666. package/dist/node_modules/@assistant-ui/react-langchain/dist/converter.cjs +0 -77
  667. package/dist/node_modules/@assistant-ui/react-langchain/dist/converter.cjs.map +0 -1
  668. package/dist/node_modules/@assistant-ui/react-langchain/dist/converter.js +0 -77
  669. package/dist/node_modules/@assistant-ui/react-langchain/dist/converter.js.map +0 -1
  670. package/dist/node_modules/@assistant-ui/react-langgraph/dist/convertLangChainMessages.cjs +0 -181
  671. package/dist/node_modules/@assistant-ui/react-langgraph/dist/convertLangChainMessages.cjs.map +0 -1
  672. package/dist/node_modules/@assistant-ui/react-langgraph/dist/convertLangChainMessages.js +0 -181
  673. package/dist/node_modules/@assistant-ui/react-langgraph/dist/convertLangChainMessages.js.map +0 -1
  674. package/dist/packages/agent-runtime/src/asset-attachment.cjs.map +0 -1
  675. package/dist/packages/agent-runtime/src/asset-attachment.js.map +0 -1
  676. package/dist/packages/agent-runtime/src/auth-denial.cjs.map +0 -1
  677. package/dist/packages/agent-runtime/src/auth-denial.js.map +0 -1
  678. package/dist/packages/agent-runtime/src/client-tool-bridge.cjs.map +0 -1
  679. package/dist/packages/agent-runtime/src/client-tool-bridge.js.map +0 -1
  680. package/dist/packages/agent-runtime/src/client-tools.cjs.map +0 -1
  681. package/dist/packages/agent-runtime/src/client-tools.js.map +0 -1
  682. package/dist/packages/agent-runtime/src/conversation-index.cjs.map +0 -1
  683. package/dist/packages/agent-runtime/src/conversation-index.js.map +0 -1
  684. package/dist/packages/agent-runtime/src/conversation-list.cjs.map +0 -1
  685. package/dist/packages/agent-runtime/src/conversation-list.js.map +0 -1
  686. package/dist/packages/agent-runtime/src/deep-agent-transport-recipe.cjs.map +0 -1
  687. package/dist/packages/agent-runtime/src/deep-agent-transport-recipe.js.map +0 -1
  688. package/dist/packages/agent-runtime/src/edit-command.cjs.map +0 -1
  689. package/dist/packages/agent-runtime/src/edit-command.js.map +0 -1
  690. package/dist/packages/agent-runtime/src/errors.cjs.map +0 -1
  691. package/dist/packages/agent-runtime/src/errors.js.map +0 -1
  692. package/dist/packages/agent-runtime/src/generated/runconfig-contract.cjs.map +0 -1
  693. package/dist/packages/agent-runtime/src/generated/runconfig-contract.js.map +0 -1
  694. package/dist/packages/agent-runtime/src/github-wake-event.cjs.map +0 -1
  695. package/dist/packages/agent-runtime/src/github-wake-event.js.map +0 -1
  696. package/dist/packages/agent-runtime/src/interrupts.cjs.map +0 -1
  697. package/dist/packages/agent-runtime/src/interrupts.js.map +0 -1
  698. package/dist/packages/agent-runtime/src/message-author.cjs.map +0 -1
  699. package/dist/packages/agent-runtime/src/message-author.js.map +0 -1
  700. package/dist/packages/agent-runtime/src/message-window.cjs.map +0 -1
  701. package/dist/packages/agent-runtime/src/message-window.js.map +0 -1
  702. package/dist/packages/agent-runtime/src/messages.cjs.map +0 -1
  703. package/dist/packages/agent-runtime/src/messages.js.map +0 -1
  704. package/dist/packages/agent-runtime/src/model-context.cjs.map +0 -1
  705. package/dist/packages/agent-runtime/src/model-context.js.map +0 -1
  706. package/dist/packages/agent-runtime/src/optimistic-content.cjs.map +0 -1
  707. package/dist/packages/agent-runtime/src/optimistic-content.js.map +0 -1
  708. package/dist/packages/agent-runtime/src/protocol.cjs.map +0 -1
  709. package/dist/packages/agent-runtime/src/protocol.js.map +0 -1
  710. package/dist/packages/agent-runtime/src/queue.cjs.map +0 -1
  711. package/dist/packages/agent-runtime/src/queue.js.map +0 -1
  712. package/dist/packages/agent-runtime/src/quota-safe-local-storage-session.cjs.map +0 -1
  713. package/dist/packages/agent-runtime/src/quota-safe-local-storage-session.js.map +0 -1
  714. package/dist/packages/agent-runtime/src/runtime-messages.cjs.map +0 -1
  715. package/dist/packages/agent-runtime/src/runtime-messages.js.map +0 -1
  716. package/dist/packages/agent-runtime/src/screen-point.cjs.map +0 -1
  717. package/dist/packages/agent-runtime/src/screen-point.js.map +0 -1
  718. package/dist/packages/agent-runtime/src/send-recovery.cjs.map +0 -1
  719. package/dist/packages/agent-runtime/src/send-recovery.js.map +0 -1
  720. package/dist/packages/agent-runtime/src/statewire-attach-observer.cjs.map +0 -1
  721. package/dist/packages/agent-runtime/src/statewire-attach-observer.js.map +0 -1
  722. package/dist/packages/agent-runtime/src/statewire-state.cjs.map +0 -1
  723. package/dist/packages/agent-runtime/src/statewire-state.js.map +0 -1
  724. package/dist/packages/agent-runtime/src/statewire-suspended.cjs.map +0 -1
  725. package/dist/packages/agent-runtime/src/statewire-suspended.js.map +0 -1
  726. package/dist/packages/agent-runtime/src/statewire-transport.cjs +0 -11
  727. package/dist/packages/agent-runtime/src/statewire-transport.cjs.map +0 -1
  728. package/dist/packages/agent-runtime/src/statewire-transport.js +0 -11
  729. package/dist/packages/agent-runtime/src/statewire-transport.js.map +0 -1
  730. package/dist/packages/agent-runtime/src/streaming-markdown.cjs.map +0 -1
  731. package/dist/packages/agent-runtime/src/streaming-markdown.js.map +0 -1
  732. package/dist/packages/agent-runtime/src/thread-extras.cjs.map +0 -1
  733. package/dist/packages/agent-runtime/src/thread-extras.js.map +0 -1
  734. package/dist/packages/agent-runtime/src/thread-snapshot-cache.cjs.map +0 -1
  735. package/dist/packages/agent-runtime/src/thread-snapshot-cache.js.map +0 -1
  736. package/dist/packages/agent-runtime/src/thread-status.cjs.map +0 -1
  737. package/dist/packages/agent-runtime/src/thread-status.js.map +0 -1
  738. package/dist/packages/agent-runtime/src/tool-metadata.cjs.map +0 -1
  739. package/dist/packages/agent-runtime/src/tool-metadata.js.map +0 -1
  740. package/dist/packages/agent-runtime/src/tool-outputs.cjs.map +0 -1
  741. package/dist/packages/agent-runtime/src/tool-outputs.js.map +0 -1
  742. package/dist/packages/agent-runtime/src/tool-result.cjs.map +0 -1
  743. package/dist/packages/agent-runtime/src/tool-result.js.map +0 -1
  744. package/dist/packages/agent-runtime/src/use-conversation-list.cjs.map +0 -1
  745. package/dist/packages/agent-runtime/src/use-conversation-list.js.map +0 -1
  746. package/dist/packages/agent-runtime/src/use-deep-agent-config.cjs +0 -13
  747. package/dist/packages/agent-runtime/src/use-deep-agent-config.cjs.map +0 -1
  748. package/dist/packages/agent-runtime/src/use-deep-agent-config.js +0 -13
  749. package/dist/packages/agent-runtime/src/use-deep-agent-config.js.map +0 -1
  750. package/dist/packages/agent-runtime/src/use-deep-agent-edit-submit.cjs.map +0 -1
  751. package/dist/packages/agent-runtime/src/use-deep-agent-edit-submit.js.map +0 -1
  752. package/dist/packages/agent-runtime/src/use-deep-agent-runtime.cjs.map +0 -1
  753. package/dist/packages/agent-runtime/src/use-deep-agent-runtime.js.map +0 -1
  754. package/dist/packages/agent-runtime/src/use-deep-agent-thread.cjs.map +0 -1
  755. package/dist/packages/agent-runtime/src/use-deep-agent-thread.js.map +0 -1
  756. package/dist/packages/agent-runtime/src/use-deep-agent-window-sync.cjs.map +0 -1
  757. package/dist/packages/agent-runtime/src/use-deep-agent-window-sync.js.map +0 -1
  758. package/dist/packages/agent-runtime/src/voice-presentation.cjs.map +0 -1
  759. package/dist/packages/agent-runtime/src/voice-presentation.js.map +0 -1
  760. package/dist/packages/agent-runtime/src/voice-turn-grouping.cjs.map +0 -1
  761. package/dist/packages/agent-runtime/src/voice-turn-grouping.js.map +0 -1
  762. package/dist/packages/tiptap-markdown-table/src/markdown-table-serializer.cjs.map +0 -1
  763. package/dist/packages/tiptap-markdown-table/src/markdown-table-serializer.js.map +0 -1
  764. /package/dist/{packages/agent-runtime → agent-runtime}/src/asset-attachment.cjs +0 -0
  765. /package/dist/{packages/agent-runtime → agent-runtime}/src/asset-attachment.js +0 -0
  766. /package/dist/{packages/agent-runtime → agent-runtime}/src/auth-denial.cjs +0 -0
  767. /package/dist/{packages/agent-runtime → agent-runtime}/src/auth-denial.js +0 -0
  768. /package/dist/{packages/agent-runtime → agent-runtime}/src/client-tool-bridge.cjs +0 -0
  769. /package/dist/{packages/agent-runtime → agent-runtime}/src/client-tool-bridge.js +0 -0
  770. /package/dist/{packages/agent-runtime → agent-runtime}/src/client-tools.cjs +0 -0
  771. /package/dist/{packages/agent-runtime → agent-runtime}/src/client-tools.js +0 -0
  772. /package/dist/{packages/agent-runtime → agent-runtime}/src/conversation-index.cjs +0 -0
  773. /package/dist/{packages/agent-runtime → agent-runtime}/src/conversation-index.js +0 -0
  774. /package/dist/{packages/agent-runtime → agent-runtime}/src/edit-command.cjs +0 -0
  775. /package/dist/{packages/agent-runtime → agent-runtime}/src/edit-command.js +0 -0
  776. /package/dist/{packages/agent-runtime → agent-runtime}/src/github-wake-event.cjs +0 -0
  777. /package/dist/{packages/agent-runtime → agent-runtime}/src/github-wake-event.js +0 -0
  778. /package/dist/{packages/agent-runtime → agent-runtime}/src/message-author.cjs +0 -0
  779. /package/dist/{packages/agent-runtime → agent-runtime}/src/message-author.js +0 -0
  780. /package/dist/{packages/agent-runtime → agent-runtime}/src/message-window.cjs +0 -0
  781. /package/dist/{packages/agent-runtime → agent-runtime}/src/message-window.js +0 -0
  782. /package/dist/{packages/agent-runtime → agent-runtime}/src/model-context.cjs +0 -0
  783. /package/dist/{packages/agent-runtime → agent-runtime}/src/model-context.js +0 -0
  784. /package/dist/{packages/agent-runtime → agent-runtime}/src/optimistic-content.cjs +0 -0
  785. /package/dist/{packages/agent-runtime → agent-runtime}/src/optimistic-content.js +0 -0
  786. /package/dist/{packages/agent-runtime → agent-runtime}/src/protocol.cjs +0 -0
  787. /package/dist/{packages/agent-runtime → agent-runtime}/src/protocol.js +0 -0
  788. /package/dist/{packages/agent-runtime → agent-runtime}/src/runtime-messages.cjs +0 -0
  789. /package/dist/{packages/agent-runtime → agent-runtime}/src/runtime-messages.js +0 -0
  790. /package/dist/{packages/agent-runtime → agent-runtime}/src/screen-point.cjs +0 -0
  791. /package/dist/{packages/agent-runtime → agent-runtime}/src/screen-point.js +0 -0
  792. /package/dist/{packages/agent-runtime → agent-runtime}/src/send-recovery.cjs +0 -0
  793. /package/dist/{packages/agent-runtime → agent-runtime}/src/send-recovery.js +0 -0
  794. /package/dist/{packages/agent-runtime → agent-runtime}/src/statewire-attach-observer.cjs +0 -0
  795. /package/dist/{packages/agent-runtime → agent-runtime}/src/statewire-attach-observer.js +0 -0
  796. /package/dist/{packages/agent-runtime → agent-runtime}/src/streaming-markdown.cjs +0 -0
  797. /package/dist/{packages/agent-runtime → agent-runtime}/src/streaming-markdown.js +0 -0
  798. /package/dist/{packages/agent-runtime → agent-runtime}/src/thread-extras.cjs +0 -0
  799. /package/dist/{packages/agent-runtime → agent-runtime}/src/thread-extras.js +0 -0
  800. /package/dist/{packages/agent-runtime → agent-runtime}/src/thread-snapshot-cache.cjs +0 -0
  801. /package/dist/{packages/agent-runtime → agent-runtime}/src/thread-snapshot-cache.js +0 -0
  802. /package/dist/{packages/agent-runtime → agent-runtime}/src/thread-status.cjs +0 -0
  803. /package/dist/{packages/agent-runtime → agent-runtime}/src/thread-status.js +0 -0
  804. /package/dist/{packages/agent-runtime → agent-runtime}/src/tool-outputs.cjs +0 -0
  805. /package/dist/{packages/agent-runtime → agent-runtime}/src/tool-outputs.js +0 -0
  806. /package/dist/{packages/agent-runtime → agent-runtime}/src/tool-result.cjs +0 -0
  807. /package/dist/{packages/agent-runtime → agent-runtime}/src/tool-result.js +0 -0
  808. /package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-runtime.cjs +0 -0
  809. /package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-runtime.js +0 -0
  810. /package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-window-sync.cjs +0 -0
  811. /package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-window-sync.js +0 -0
  812. /package/dist/{packages/agent-runtime → agent-runtime}/src/voice-turn-grouping.cjs +0 -0
  813. /package/dist/{packages/agent-runtime → agent-runtime}/src/voice-turn-grouping.js +0 -0
  814. /package/dist/{packages/react → react}/package.json.cjs.map +0 -0
  815. /package/dist/{packages/react → react}/package.json.js.map +0 -0
  816. /package/dist/{packages/tiptap-markdown-table → tiptap-markdown-table}/src/markdown-table-serializer.cjs +0 -0
  817. /package/dist/{packages/tiptap-markdown-table → tiptap-markdown-table}/src/markdown-table-serializer.js +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.js","sources":["../../../../../agent-runtime/src/errors.ts"],"sourcesContent":["import type { StatewireClient } from 'statewire';\nimport type { DeepAgentConnectionState } from './types';\n\n/** Structured payload attached to a server-rejected Statewire command. */\nexport interface StatewireRejectionPayload {\n status: number;\n detail: unknown;\n}\n\n/** Return a rejected command's structured `{ status, detail }` payload. */\nexport function statewireRejectionPayload(error: unknown): StatewireRejectionPayload | null {\n const failure = (error as { failure?: { fate?: unknown; payload?: unknown } } | null)?.failure;\n if (failure?.fate !== 'rejected') return null;\n\n const payload = failure.payload as { status?: unknown; detail?: unknown } | undefined;\n if (typeof payload?.status !== 'number') return null;\n return { status: payload.status, detail: payload.detail };\n}\n\n/**\n * The server's human-readable reason for a rejected command — `detail.message`\n * (or a plain-string `detail`) — else `null`. Hosts surface it as send\n * feedback so the user sees the actionable cause instead of the generic\n * client-side `command rejected (<status>)`.\n */\nexport function statewireRejectionDetailMessage(error: unknown): string | null {\n const detail = statewireRejectionPayload(error)?.detail;\n if (typeof detail === 'string') return detail.length > 0 ? detail : null;\n if (detail === null || typeof detail !== 'object' || Array.isArray(detail)) return null;\n const message = (detail as { message?: unknown }).message;\n return typeof message === 'string' && message.length > 0 ? message : null;\n}\n\n/**\n * A structured, retryable refusal the host recorded as the run error\n * (`runs.error`): the dispatch never started — the pod or instance was\n * closing (`pod_draining`) — and the entries stayed in their lanes for the\n * thread's next placement. Distinct from a rejected COMMAND\n * ({@link statewireRejectionPayload}): this is the shape harness-sdk writes\n * when the run executor raises the rejection, so it lives on the replicated\n * run entry, not on a command settle.\n */\nexport interface RetryableRunRefusal {\n /** The structured `detail.code` (`pod_draining`). */\n code: string;\n /** The server's human-readable reason, when it sent one. */\n message: string | null;\n}\n\n/** The `{ code, message, retryable: true }` detail of a structured refusal, or `null`. */\nfunction readRetryableDetail(detail: unknown): { code: string; message: string | null } | null {\n if (detail === null || typeof detail !== 'object' || Array.isArray(detail)) return null;\n const { code, message, retryable } = detail as {\n code?: unknown;\n message?: unknown;\n retryable?: unknown;\n };\n if (retryable !== true || typeof code !== 'string' || code.length === 0) return null;\n return { code, message: typeof message === 'string' && message.length > 0 ? message : null };\n}\n\nexport function readRetryableRunRefusal(error: unknown): RetryableRunRefusal | null {\n if (error === null || typeof error !== 'object' || Array.isArray(error)) return null;\n return readRetryableDetail((error as { detail?: unknown }).detail);\n}\n\n/**\n * A structured, retryable refusal of a COMMAND, read off its rejection\n * ({@link statewireRejectionPayload}): the host's `_structured_reject(...,\n * retryable=True)` envelope — `command_auth_context_expired` when a pod\n * replacement dropped the socket-scoped auth a replayed command needed,\n * `pod_draining` when the host was closing. The command never ran, and the\n * host itself says a resend after the reconnect will; `detail.code` is the\n * wire-frozen contract clients classify on. Same shape as\n * {@link readRetryableRunRefusal}, which reads it off a replicated run entry.\n */\nexport interface RetryableCommandRejection {\n /** The structured `detail.code`. */\n code: string;\n /** The server's human-readable reason, when it sent one. */\n message: string | null;\n}\n\nexport function readRetryableCommandRejection(error: unknown): RetryableCommandRejection | null {\n const payload = statewireRejectionPayload(error);\n return payload === null ? null : readRetryableDetail(payload.detail);\n}\n\n/** The host's `detail.code` for a command replayed onto a pod that could not restore its auth context. */\nexport const STATEWIRE_COMMAND_AUTH_CONTEXT_EXPIRED = 'command_auth_context_expired';\n\n/**\n * Whether a rejected command hit the host's fail-closed auth recovery: the\n * command was replayed onto a replacement pod that could not restore the\n * attach's auth context, so it was refused unrun (503, retryable). The\n * reconnect already under way restores the context; a single resend after it\n * is the recovery, not a failure to report.\n */\nexport function isStatewireCommandAuthContextExpired(error: unknown): boolean {\n const payload = statewireRejectionPayload(error);\n return (\n payload?.status === 503 &&\n readRetryableDetail(payload.detail)?.code === STATEWIRE_COMMAND_AUTH_CONTEXT_EXPIRED\n );\n}\n\n/**\n * Whether a rejected command hit the legacy-thread dispatch fence: the\n * structured 409 the server answers when an out-of-band run is writing a\n * pre-cutover thread (or its adoption failed). A per-send failure — the\n * snapshot never carries a standing read-only flag.\n */\nexport function isLegacyThreadReadOnlyRejection(error: unknown): boolean {\n const payload = statewireRejectionPayload(error);\n if (payload?.status !== 409) return false;\n\n const detail = payload.detail as { code?: unknown } | undefined;\n return detail?.code === 'legacy_thread_read_only';\n}\n\n/**\n * Whether a rejected command was refused because its rewind anchor no longer\n * matches the host's parent for the edited message (`wrong-anchor`).\n *\n * A retry/edit resubmit is dispatched optimistically, so this rejection lands\n * after the UI already cleared its edit affordances: the turn simply never\n * re-runs. Callers use this to tell the user the resubmit was dropped instead\n * of leaving a console-only failure.\n */\nexport function isStatewireRewindAnchorRejection(error: unknown): boolean {\n const failure = (error as { failure?: { fate?: unknown; payload?: unknown } } | null | undefined)\n ?.failure;\n if (failure?.fate !== 'rejected') return false;\n return (failure.payload as { reason?: unknown } | undefined)?.reason === 'wrong-anchor';\n}\n\n/**\n * Whether a statewire send failure is the host's `expired` verdict\n * (`result-unavailable`): the command's seq was at or below the host's\n * admitted watermark and no retained result was left for it. Either the\n * command ran and settled but the client re-asked for the answer (a resend\n * after the stream came back) only after the host had let the retained result\n * go, or the seq was already admitted and the command was absorbed as a\n * duplicate without ever running — a client whose shared session record fell\n * behind the watermark stays there until a reconnect re-syncs it. The library\n * never reruns the command on replay, so for an idempotent read the answer is\n * simply gone — asking again is the correct reaction, not reporting a failure;\n * a write cannot assume it was applied.\n */\nexport function isStatewireExpiredVerdict(error: unknown): boolean {\n const failure = (error as { failure?: { fate?: unknown; cause?: unknown } | null | undefined })\n ?.failure;\n return failure?.fate === 'expired' && failure.cause === 'server';\n}\n\n/**\n * Whether a statewire send failure is a local channel death rather than a\n * command error.\n *\n * The library's contract for `SendFailure.cause`: `\"server\"` is the server's\n * own answer; every other cause is \"a channel death the client settled\n * locally\" — `unmount`, `stream-gone`, and `session-lost`. A thread switch\n * settles every in-flight command that way, so logging these at error level\n * reports two failures for an ordinary switch and buries the ones that mean\n * something.\n *\n * Channel health is already surfaced where it belongs: the connection\n * indicator renders the connection state. This\n * predicate only decides the log level.\n */\nexport function isStatewireChannelTeardown(error: unknown): boolean {\n const cause = (error as { failure?: { cause?: unknown } } | null | undefined)?.failure?.cause;\n return typeof cause === 'string' && cause !== 'server';\n}\n\n/**\n * The low-cardinality reason a statewire send settled as transport weather\n * rather than a defect, or `null` when the failure is a real error.\n *\n * Three families qualify: a channel death the client settled locally\n * ({@link isStatewireChannelTeardown} — the cause: `unmount`, `stream-gone`,\n * `session-lost`), the host's `expired` verdict\n * ({@link isStatewireExpiredVerdict} — the answer outlived the host's\n * retention before the post-reconnect resend collected it), and a retryable\n * structured rejection ({@link readRetryableCommandRejection} — its code: the\n * host asked for a resend). In every case the sender's own retry or poll is\n * the recovery and the connection indicator already shows the channel, so\n * error reporting counts the outcome instead of paging on it. Handler\n * failures, crashes, and non-retryable rejections stay `null`: those are\n * defects to page on.\n */\nexport function statewireTransportOutcome(error: unknown): string | null {\n const cause = (error as { failure?: { cause?: unknown } } | null | undefined)?.failure?.cause;\n if (typeof cause === 'string' && cause !== 'server') return cause;\n if (isStatewireExpiredVerdict(error)) return 'expired';\n return readRetryableCommandRejection(error)?.code ?? null;\n}\n\nconst sanitizeConnectionMessage = (message: string): string | undefined => {\n const printable = Array.from(message, (character) => {\n const code = character.charCodeAt(0);\n return code < 32 || code === 127 ? ' ' : character;\n })\n .join('')\n .replace(/\\s+/g, ' ')\n .trim();\n return printable ? printable.slice(0, 200) : undefined;\n};\n\n/** Preserve the Statewire lifecycle and sanitize host detail for display. */\nexport function projectDeepAgentConnection(\n connection: StatewireClient.ConnectionState\n): DeepAgentConnectionState {\n const message =\n 'message' in connection && typeof connection.message === 'string'\n ? sanitizeConnectionMessage(connection.message)\n : undefined;\n switch (connection.status) {\n case 'standby':\n return {\n status: connection.status,\n reason: connection.reason,\n degraded: connection.degraded,\n ...(message !== undefined && { message }),\n };\n case 'connecting':\n case 'connected':\n return { status: connection.status, degraded: connection.degraded };\n case 'retrying':\n return {\n status: connection.status,\n degraded: connection.degraded,\n attempt: connection.attempt,\n ...(connection.cause !== undefined && { cause: connection.cause }),\n ...(connection.code !== undefined && { code: connection.code }),\n ...(connection.nextRetryAt !== undefined && { nextRetryAt: connection.nextRetryAt }),\n ...(connection.lastError !== undefined && { lastError: connection.lastError }),\n ...(message !== undefined && { message }),\n };\n case 'stopped':\n return {\n status: connection.status,\n degraded: connection.degraded,\n reason: connection.reason,\n ...(connection.payload !== undefined && { payload: connection.payload }),\n ...(message !== undefined && { message }),\n };\n default:\n return unknownConnectionStatus(connection);\n }\n}\n\n/** Compile-time exhaustiveness: reachable only when the library grows a status this build does not project. */\nfunction unknownConnectionStatus(connection: never): never {\n throw new Error(\n `statewire: unknown connection status ${JSON.stringify(\n (connection as { status?: unknown }).status\n )}`\n );\n}\n"],"names":[],"mappings":"AAUO,SAAS,0BAA0B,OAAkD;AAC1F,QAAM,UAAW,+BAAsE;AACvF,OAAI,mCAAS,UAAS,WAAY,QAAO;AAEzC,QAAM,UAAU,QAAQ;AACxB,MAAI,QAAO,mCAAS,YAAW,SAAU,QAAO;AAChD,SAAO,EAAE,QAAQ,QAAQ,QAAQ,QAAQ,QAAQ,OAAA;AACnD;AAQO,SAAS,gCAAgC,OAA+B;AAfxE;AAgBL,QAAM,UAAS,+BAA0B,KAAK,MAA/B,mBAAkC;AACjD,MAAI,OAAO,WAAW,iBAAiB,OAAO,SAAS,IAAI,SAAS;AACpE,MAAI,WAAW,QAAQ,OAAO,WAA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AAQ,WAAW;AAAA,QACnB,GAAI,WAAW,YAAY,UAAa,EAAE,SAAS,WAAW,QAAA;AAAA,QAC9D,GAAI,YAAY,UAAa,EAAE,QAAA;AAAA,MAAQ;AAAA,IAE3C;AACE,aAAO,wBAAwB,UAAU;AAAA,EAAA;AAE/C;AAGA,SAAS,wBAAwB,YAA0B;AACzD,QAAM,IAAI;AAAA,IACR,wCAAwC,KAAK;AAAA,MAC1C,WAAoC;AAAA,IAAA,CACtC;AAAA,EAAA;AAEL;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"runconfig-contract.cjs","sources":["../../../../../../agent-runtime/src/generated/runconfig-contract.ts"],"sourcesContent":["// GENERATED FILE — DO NOT EDIT BY HAND.\n//\n// Source of truth (agora):\n// agora/agora/graphs/athena_deep_agent/run_config.py (_PARSED_CUSTOM_KEYS / _COMPANION_CUSTOM_KEYS / PER_SEND_CUSTOM_KEYS)\n// agora/agora/graphs/athena_deep_agent/thread_config.py (server config lane + config/* command names)\n// agora/agora/graphs/athena_deep_agent/session_asset.py (KNOWN_START_CHANNELS / DEEP_AGENT_RUNTIME_MARKER)\n// agora/agora/graphs/athena_deep_agent/client_tools.py (client-tool interrupt + result-envelope literals)\n// agora/agora/graphs/athena_deep_agent/protocol_version.py (wire-contract version negotiation)\n// agora/agora/graphs/athena_deep_agent/message_window.py (interest windows + history commands)\n// agora/agora/type_definitions/collab_agent.py (CAPABILITIES ladder: absent mode + new-agent default)\n//\n// Regenerate:\n// cd agora && mise exec -- infisical run --command 'uv run python scripts/export_runconfig_contract.py'\n//\n// CI verifies this file matches the Python source (agora-check runs the\n// exporter with --check), so hand edits and un-regenerated key changes fail.\n\n/** `runConfig.custom` keys parsed by agora's `parse_deep_agent_run_config`. */\nexport const RUN_CONFIG_PARSED_CUSTOM_KEYS = [\n \"agent_catalog_asset_ids\",\n \"approve_changes\",\n \"async_subagents\",\n \"catalog_asset_ids\",\n \"coding_worker_asset_id\",\n \"coding_workers\",\n \"compiled_subagents\",\n \"declined_toolkit_ids\",\n \"drive_mounts\",\n \"enable_interpreter\",\n \"enable_persistent_fs\",\n \"enable_sandbox\",\n \"enable_skills\",\n \"enabled_tools\",\n \"environment\",\n \"environment_id\",\n \"environment_name\",\n \"excluded_middleware\",\n \"excluded_tools\",\n \"extra_middleware\",\n \"include_citation_instructions\",\n \"interpreter_max_ptc_calls\",\n \"interpreter_mode\",\n \"interpreter_ptc\",\n \"interpreter_ptc_exclusive\",\n \"interpreter_runtime\",\n \"interpreter_subagents\",\n \"interpreter_timeout_seconds\",\n \"interrupt_on\",\n \"knowledge_base\",\n \"mcp_server_configs\",\n \"mcp_servers\",\n \"memory\",\n \"outbound_approval_allowlist\",\n \"permissions\",\n \"project_id\",\n \"recursion_limit\",\n \"run_label\",\n \"sandbox_runtime\",\n \"secret_asset_ids\",\n \"session_machine\",\n \"session_vm_retention\",\n \"skill_asset_ids\",\n \"skills\",\n \"subagents\",\n \"system_prompt\",\n \"tool_description_overrides\",\n \"voice_update_handle\",\n \"workbench\",\n] as const;\n\n/** `runConfig.custom` keys consumed by the surrounding deep-agent request machinery rather than the capability parser. */\nexport const RUN_CONFIG_COMPANION_CUSTOM_KEYS = [\n \"agent\",\n \"allowed_tab_ids\",\n \"app_id\",\n \"channel\",\n \"client_tools\",\n \"collab_agent_id\",\n \"collab_channel_id\",\n \"custom_tool_configs\",\n \"deterministic\",\n \"device_id\",\n \"dry_run\",\n \"enabled_toolkits\",\n \"entry_point\",\n \"frontend_available\",\n \"github_identity\",\n \"max_tokens\",\n \"middleware\",\n \"model\",\n \"muses_enabled\",\n \"muses_recall_enabled\",\n \"office_context\",\n \"panel_config\",\n \"run_budget\",\n \"runtime\",\n \"session_id\",\n \"session_origin_kind\",\n \"session_tab_id\",\n \"skip_title_generation\",\n \"source_aop_id\",\n \"start_channel\",\n \"structured_output\",\n \"temperature\",\n \"tool_limit_override\",\n \"trigger_type\",\n \"workspace_id\",\n] as const;\n\n/** Every `runConfig.custom` key some deep-agent request consumer reads. A key outside this set is invisible to the run and trips agora's unknown-key telemetry. */\nexport const RUN_CONFIG_CUSTOM_KEYS = [\n \"agent\",\n \"agent_catalog_asset_ids\",\n \"allowed_tab_ids\",\n \"app_id\",\n \"approve_changes\",\n \"async_subagents\",\n \"catalog_asset_ids\",\n \"channel\",\n \"client_tools\",\n \"coding_worker_asset_id\",\n \"coding_workers\",\n \"collab_agent_id\",\n \"collab_channel_id\",\n \"compiled_subagents\",\n \"custom_tool_configs\",\n \"declined_toolkit_ids\",\n \"deterministic\",\n \"device_id\",\n \"drive_mounts\",\n \"dry_run\",\n \"enable_interpreter\",\n \"enable_persistent_fs\",\n \"enable_sandbox\",\n \"enable_skills\",\n \"enabled_toolkits\",\n \"enabled_tools\",\n \"entry_point\",\n \"environment\",\n \"environment_id\",\n \"environment_name\",\n \"excluded_middleware\",\n \"excluded_tools\",\n \"extra_middleware\",\n \"frontend_available\",\n \"github_identity\",\n \"include_citation_instructions\",\n \"interpreter_max_ptc_calls\",\n \"interpreter_mode\",\n \"interpreter_ptc\",\n \"interpreter_ptc_exclusive\",\n \"interpreter_runtime\",\n \"interpreter_subagents\",\n \"interpreter_timeout_seconds\",\n \"interrupt_on\",\n \"knowledge_base\",\n \"max_tokens\",\n \"mcp_server_configs\",\n \"mcp_servers\",\n \"memory\",\n \"middleware\",\n \"model\",\n \"muses_enabled\",\n \"muses_recall_enabled\",\n \"office_context\",\n \"outbound_approval_allowlist\",\n \"panel_config\",\n \"permissions\",\n \"project_id\",\n \"recursion_limit\",\n \"run_budget\",\n \"run_label\",\n \"runtime\",\n \"sandbox_runtime\",\n \"secret_asset_ids\",\n \"session_id\",\n \"session_machine\",\n \"session_origin_kind\",\n \"session_tab_id\",\n \"session_vm_retention\",\n \"skill_asset_ids\",\n \"skills\",\n \"skip_title_generation\",\n \"source_aop_id\",\n \"start_channel\",\n \"structured_output\",\n \"subagents\",\n \"system_prompt\",\n \"temperature\",\n \"tool_description_overrides\",\n \"tool_limit_override\",\n \"trigger_type\",\n \"voice_update_handle\",\n \"workbench\",\n \"workspace_id\",\n] as const;\n\nexport type RunConfigCustomKey = (typeof RUN_CONFIG_CUSTOM_KEYS)[number];\n\n/** Fast membership checks for builder/test assertions. */\nexport const RUN_CONFIG_CUSTOM_KEY_SET: ReadonlySet<string> = new Set(\n RUN_CONFIG_CUSTOM_KEYS,\n);\n\n/** `runConfig.custom` keys a client still carries per send on a thread with server config; every other key is dropped at dispatch. */\nexport const RUN_CONFIG_PER_SEND_CUSTOM_KEYS = [\n \"agent\",\n \"allowed_tab_ids\",\n \"app_id\",\n \"channel\",\n \"client_tools\",\n \"collab_channel_id\",\n \"deterministic\",\n \"device_id\",\n \"dry_run\",\n \"entry_point\",\n \"frontend_available\",\n \"github_identity\",\n \"muses_enabled\",\n \"muses_recall_enabled\",\n \"office_context\",\n \"project_id\",\n \"run_budget\",\n \"runtime\",\n \"session_id\",\n \"session_origin_kind\",\n \"session_tab_id\",\n \"skip_title_generation\",\n \"source_aop_id\",\n \"start_channel\",\n \"structured_output\",\n \"tool_limit_override\",\n \"trigger_type\",\n \"voice_update_handle\",\n \"workspace_id\",\n] as const;\n\nexport type RunConfigPerSendCustomKey =\n (typeof RUN_CONFIG_PER_SEND_CUSTOM_KEYS)[number];\n\n/** Fast membership checks for builder/test assertions. */\nexport const RUN_CONFIG_PER_SEND_CUSTOM_KEY_SET: ReadonlySet<string> = new Set(\n RUN_CONFIG_PER_SEND_CUSTOM_KEYS,\n);\n\n/** Keys the thread's server config lane owns — changed only through the `config/*` commands, never per send. */\nexport const THREAD_CONFIG_CUSTOM_KEYS = [\n \"agent_catalog_asset_ids\",\n \"approve_changes\",\n \"async_subagents\",\n \"catalog_asset_ids\",\n \"coding_worker_asset_id\",\n \"coding_workers\",\n \"collab_agent_id\",\n \"compiled_subagents\",\n \"custom_tool_configs\",\n \"declined_toolkit_ids\",\n \"drive_mounts\",\n \"enable_interpreter\",\n \"enable_persistent_fs\",\n \"enable_sandbox\",\n \"enable_skills\",\n \"enabled_toolkits\",\n \"enabled_tools\",\n \"environment\",\n \"environment_id\",\n \"environment_name\",\n \"excluded_middleware\",\n \"excluded_tools\",\n \"extra_middleware\",\n \"include_citation_instructions\",\n \"interpreter_max_ptc_calls\",\n \"interpreter_mode\",\n \"interpreter_ptc\",\n \"interpreter_ptc_exclusive\",\n \"interpreter_runtime\",\n \"interpreter_subagents\",\n \"interpreter_timeout_seconds\",\n \"interrupt_on\",\n \"knowledge_base\",\n \"max_tokens\",\n \"mcp_server_configs\",\n \"mcp_servers\",\n \"memory\",\n \"middleware\",\n \"model\",\n \"outbound_approval_allowlist\",\n \"permissions\",\n \"recursion_limit\",\n \"run_label\",\n \"sandbox_runtime\",\n \"secret_asset_ids\",\n \"session_machine\",\n \"session_vm_retention\",\n \"skill_asset_ids\",\n \"skills\",\n \"subagents\",\n \"system_prompt\",\n \"temperature\",\n \"tool_description_overrides\",\n \"workbench\",\n] as const;\n\nexport type ThreadConfigCustomKey = (typeof THREAD_CONFIG_CUSTOM_KEYS)[number];\n\n/** Fast membership checks for builder/test assertions. */\nexport const THREAD_CONFIG_CUSTOM_KEY_SET: ReadonlySet<string> = new Set(\n THREAD_CONFIG_CUSTOM_KEYS,\n);\n\n/** Replicated-state key of the server config lane (`{ version, custom }`). */\nexport const DEEP_AGENT_CONFIG_STATE_KEY = \"config\";\n\n/** The statewire commands that mutate the server config lane. */\nexport const DEEP_AGENT_CONFIG_COMMANDS = {\n patch: \"config/patch\",\n toolsEnable: \"config/tools/enable\",\n toolsDisable: \"config/tools/disable\",\n} as const;\n\n/** `start_channel` values the session substrate stamps as provenance; anything else clamps to \"web\". */\nexport const KNOWN_START_CHANNELS = [\n \"agent_orchestration\",\n \"api\",\n \"automation\",\n \"chrome_extension\",\n \"cli\",\n \"comment_agent\",\n \"default_voice\",\n \"desktop_app\",\n \"email\",\n \"mobile_app\",\n \"office_addin\",\n \"orchestration\",\n \"programmatic\",\n \"slack\",\n \"sms\",\n \"task\",\n \"teams\",\n \"voice\",\n \"voice_memo\",\n \"web\",\n] as const;\n\nexport type KnownStartChannel = (typeof KNOWN_START_CHANNELS)[number];\n\n/** Fast membership checks for builder/test assertions. */\nexport const KNOWN_START_CHANNEL_SET: ReadonlySet<string> = new Set(\n KNOWN_START_CHANNELS,\n);\n\n/** `runConfig.custom.runtime` marker selecting the deep-agent runtime. */\nexport const DEEP_AGENT_RUNTIME_MARKER = \"athena_deep_agent\";\n\n/**\n * Collab-agent capability ladder (agent schema v3): per explicit\n * capability field, what an ABSENT value means and the value stamped on\n * a new agent. Resolved by agora's `capability_decoder` and the one agent\n * compiler on every run: `passthrough` — explicit only, absent means off;\n * `off` — absent means off under every `runtime` marker; `runtime` —\n * absent derives from the `runtime` marker (`athena_deep_agent` on, any\n * other or missing marker off).\n */\nexport const COLLAB_AGENT_CAPABILITIES = {\n deepAgentBuiltinsEnabled: { absent: \"runtime\", default: true },\n interpreterEnabled: { absent: \"off\", default: false },\n sandboxEnabled: { absent: \"passthrough\", default: false },\n skillsEnabled: { absent: \"runtime\", default: true },\n} as const;\n\nexport type CollabAgentCapabilityField = keyof typeof COLLAB_AGENT_CAPABILITIES;\n\nexport type CollabAgentCapabilityAbsentMode =\n (typeof COLLAB_AGENT_CAPABILITIES)[CollabAgentCapabilityField][\"absent\"];\n\n/** `source`/`type` stamped on client-tool interrupt payloads by agora. */\nexport const CLIENT_TOOL_INTERRUPT_SOURCE = \"client_tool\";\n\n/** `status` literals of the result envelope a client resumes a parked client-tool call with. */\nexport const CLIENT_TOOL_RESULT_STATUSES = [\"error\", \"success\"] as const;\n\nexport type ClientToolResultStatus =\n (typeof CLIENT_TOOL_RESULT_STATUSES)[number];\n\nexport const CLIENT_TOOL_RESULT_STATUS_SUCCESS = \"success\";\n\nexport const CLIENT_TOOL_RESULT_STATUS_ERROR = \"error\";\n\n/**\n * Result envelope a client resumes a parked client-tool call with,\n * keyed by interrupt id:\n * `{ client_tool_results: { <interrupt_id>: <envelope> } }`.\n * Agora relays the envelope to the model verbatim.\n */\nexport type ClientToolResultEnvelopeContract =\n | { status: typeof CLIENT_TOOL_RESULT_STATUS_SUCCESS; result: unknown }\n | { status: typeof CLIENT_TOOL_RESULT_STATUS_ERROR; error: string };\n\n/**\n * The deep-agent wire-contract version this client build speaks,\n * declared on every attach. The host records it for attach telemetry\n * and per-version behaviour; it has no minimum client version, so no\n * build is refused for the version it declares (the `protocol` state\n * lane's `minClientVersion` is the constant 1).\n */\nexport const DEEP_AGENT_PROTOCOL_VERSION = 1;\n\n/** Attach header carrying the client's declared contract version. */\nexport const DEEP_AGENT_PROTOCOL_VERSION_HEADER =\n \"x-athena-deep-agent-protocol-version\";\n\n/** Attach header declaring the head window a fresh client wants in its hello (host-clamped). */\nexport const DEEP_AGENT_MESSAGE_WINDOW_HEADER = \"x-athena-deep-agent-window\";\n\n/** Replicated-state key of the server-advertised version lane. */\nexport const DEEP_AGENT_PROTOCOL_STATE_KEY = \"protocol\";\n\n/** Ephemeral subprotocol carrying a client's message-window interests. */\nexport const DEEP_AGENT_INTEREST_PROTOCOL = \"athena/interest\";\n\n/** Ephemeral subprotocol carrying a client's synced context document. */\nexport const DEEP_AGENT_CONTEXT_PROTOCOL = \"athena/context\";\n\n/** The only interest namespace the host resolves (the linear transcript). */\nexport const DEEP_AGENT_MAIN_NS = \"main\";\n\n/** Window size (interest `before`) a client asks for by default. */\nexport const DEEP_AGENT_DEFAULT_MESSAGE_WINDOW = 40;\n\n/** Bounds on a window size. */\nexport const DEEP_AGENT_MIN_MESSAGE_WINDOW = 8;\n\nexport const DEEP_AGENT_MAX_MESSAGE_WINDOW = 200;\n\n/** Interests one attach may hold at once (the head plus its pages). */\nexport const DEEP_AGENT_MAX_INTERESTS = 16;\n\n/** Command returning a truncated tool output whole. */\nexport const DEEP_AGENT_HISTORY_TOOL_OUTPUT_COMMAND = \"history/tool_output\";\n\n/** Command returning one stored message whole (provenance and full tool output included). */\nexport const DEEP_AGENT_HISTORY_MESSAGE_COMMAND = \"history/message\";\n\n/** Wire key marking a tool message whose content was truncated. */\nexport const DEEP_AGENT_TRUNCATED_CONTENT_KEY = \"athena_content_truncated\";\n\n/** Most inline-image payload characters one message carries whole on the wire. */\nexport const DEEP_AGENT_INLINE_IMAGE_WIRE_BUDGET = 4194304;\n\n/** Wire key on an image block left off the wire: `{ index, chars, mediaType }`. */\nexport const DEEP_AGENT_OMITTED_IMAGE_KEY = \"athena_image_omitted\";\n\n/** The image an omitted block carries instead of its own (a neutral PNG tile). */\nexport const DEEP_AGENT_OMITTED_IMAGE_PLACEHOLDER_URL =\n \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAAB4AQMAAABPbGssAAAABlBMVEXi6PCUo7jao11HAAAA6ElEQVR42u2UyW3DMBBF3wxogEd2EJbCElKQDRCwC3MpSRc5eLuYokgNLEUxctK/CHyanQts2vRO3QdlALVsXsBvecqxxr1ob0A5GlDJU+hICxN54p/qXAx/+FpoeeE8hTerzfvByn7ifzpaBtWCOwv6bMVMBgzRgNGKmUL9McDs4XOSyEHuoKCI76AiqOugg+y0gx6SN+YQg3QwALGk19pQSKV/reOocyoww27oU5sxhAbKUNgIqrVxrvnovJ80MFgxYy23wtTss44tmL+bAuOE2p2o0fJa3iW/6iR/lEfx8kv3TZtW6AFk5Sf3k+GTswAAAABJRU5ErkJggg==\";\n\n/**\n * Command returning one inline image of a stored message in chunks:\n * `{ messageId, index, offset? }` answers\n * `{ messageId, index, mediaType, offset, total, chunk, next }`; the\n * chunks joined in order are the image's `data:` URL, and `next` is\n * the offset to ask for next (`null` after the last chunk).\n */\nexport const DEEP_AGENT_HISTORY_IMAGE_COMMAND = \"history/image\";\n"],"names":[],"mappings":";;AA8GO,MAAM,yBAAyB;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAK8D,IAAI;AAAA,EAChE;AACF;AAGO,MAAM,kCAAkC;AAAA,EAC7C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAMuE,IAAI;AAAA,EACzE;AACF;AAGO,MAAM,4BAA4B;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAKiE,IAAI;AAAA,EACnE;AACF;AAaO,MAAM,uBAAuB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAK4D,IAAI;AAAA,EAC9D;AACF;AA2BO,MAAM,+BAA+B;AAQrC,MAAM,oCAAoC;AAE1C,MAAM,kCAAkC;AAmBxC,MAAM,8BAA8B;AAGpC,MAAM,qCACX;AAGK,MAAM,mCAAmC;AAGzC,MAAM,gCAAgC;AAGtC,MAAM,+BAA+B;AAMrC,MAAM,qBAAqB;AAG3B,MAAM,oCAAoC;AAG1C,MAAM,gCAAgC;AAEtC,MAAM,gCAAgC;AAGtC,MAAM,2BAA2B;AAGjC,MAAM,yCAAyC;AAM/C,MAAM,mCAAmC;;;;;;;;;;;;;;;;;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"runconfig-contract.js","sources":["../../../../../../agent-runtime/src/generated/runconfig-contract.ts"],"sourcesContent":["// GENERATED FILE — DO NOT EDIT BY HAND.\n//\n// Source of truth (agora):\n// agora/agora/graphs/athena_deep_agent/run_config.py (_PARSED_CUSTOM_KEYS / _COMPANION_CUSTOM_KEYS / PER_SEND_CUSTOM_KEYS)\n// agora/agora/graphs/athena_deep_agent/thread_config.py (server config lane + config/* command names)\n// agora/agora/graphs/athena_deep_agent/session_asset.py (KNOWN_START_CHANNELS / DEEP_AGENT_RUNTIME_MARKER)\n// agora/agora/graphs/athena_deep_agent/client_tools.py (client-tool interrupt + result-envelope literals)\n// agora/agora/graphs/athena_deep_agent/protocol_version.py (wire-contract version negotiation)\n// agora/agora/graphs/athena_deep_agent/message_window.py (interest windows + history commands)\n// agora/agora/type_definitions/collab_agent.py (CAPABILITIES ladder: absent mode + new-agent default)\n//\n// Regenerate:\n// cd agora && mise exec -- infisical run --command 'uv run python scripts/export_runconfig_contract.py'\n//\n// CI verifies this file matches the Python source (agora-check runs the\n// exporter with --check), so hand edits and un-regenerated key changes fail.\n\n/** `runConfig.custom` keys parsed by agora's `parse_deep_agent_run_config`. */\nexport const RUN_CONFIG_PARSED_CUSTOM_KEYS = [\n \"agent_catalog_asset_ids\",\n \"approve_changes\",\n \"async_subagents\",\n \"catalog_asset_ids\",\n \"coding_worker_asset_id\",\n \"coding_workers\",\n \"compiled_subagents\",\n \"declined_toolkit_ids\",\n \"drive_mounts\",\n \"enable_interpreter\",\n \"enable_persistent_fs\",\n \"enable_sandbox\",\n \"enable_skills\",\n \"enabled_tools\",\n \"environment\",\n \"environment_id\",\n \"environment_name\",\n \"excluded_middleware\",\n \"excluded_tools\",\n \"extra_middleware\",\n \"include_citation_instructions\",\n \"interpreter_max_ptc_calls\",\n \"interpreter_mode\",\n \"interpreter_ptc\",\n \"interpreter_ptc_exclusive\",\n \"interpreter_runtime\",\n \"interpreter_subagents\",\n \"interpreter_timeout_seconds\",\n \"interrupt_on\",\n \"knowledge_base\",\n \"mcp_server_configs\",\n \"mcp_servers\",\n \"memory\",\n \"outbound_approval_allowlist\",\n \"permissions\",\n \"project_id\",\n \"recursion_limit\",\n \"run_label\",\n \"sandbox_runtime\",\n \"secret_asset_ids\",\n \"session_machine\",\n \"session_vm_retention\",\n \"skill_asset_ids\",\n \"skills\",\n \"subagents\",\n \"system_prompt\",\n \"tool_description_overrides\",\n \"voice_update_handle\",\n \"workbench\",\n] as const;\n\n/** `runConfig.custom` keys consumed by the surrounding deep-agent request machinery rather than the capability parser. */\nexport const RUN_CONFIG_COMPANION_CUSTOM_KEYS = [\n \"agent\",\n \"allowed_tab_ids\",\n \"app_id\",\n \"channel\",\n \"client_tools\",\n \"collab_agent_id\",\n \"collab_channel_id\",\n \"custom_tool_configs\",\n \"deterministic\",\n \"device_id\",\n \"dry_run\",\n \"enabled_toolkits\",\n \"entry_point\",\n \"frontend_available\",\n \"github_identity\",\n \"max_tokens\",\n \"middleware\",\n \"model\",\n \"muses_enabled\",\n \"muses_recall_enabled\",\n \"office_context\",\n \"panel_config\",\n \"run_budget\",\n \"runtime\",\n \"session_id\",\n \"session_origin_kind\",\n \"session_tab_id\",\n \"skip_title_generation\",\n \"source_aop_id\",\n \"start_channel\",\n \"structured_output\",\n \"temperature\",\n \"tool_limit_override\",\n \"trigger_type\",\n \"workspace_id\",\n] as const;\n\n/** Every `runConfig.custom` key some deep-agent request consumer reads. A key outside this set is invisible to the run and trips agora's unknown-key telemetry. */\nexport const RUN_CONFIG_CUSTOM_KEYS = [\n \"agent\",\n \"agent_catalog_asset_ids\",\n \"allowed_tab_ids\",\n \"app_id\",\n \"approve_changes\",\n \"async_subagents\",\n \"catalog_asset_ids\",\n \"channel\",\n \"client_tools\",\n \"coding_worker_asset_id\",\n \"coding_workers\",\n \"collab_agent_id\",\n \"collab_channel_id\",\n \"compiled_subagents\",\n \"custom_tool_configs\",\n \"declined_toolkit_ids\",\n \"deterministic\",\n \"device_id\",\n \"drive_mounts\",\n \"dry_run\",\n \"enable_interpreter\",\n \"enable_persistent_fs\",\n \"enable_sandbox\",\n \"enable_skills\",\n \"enabled_toolkits\",\n \"enabled_tools\",\n \"entry_point\",\n \"environment\",\n \"environment_id\",\n \"environment_name\",\n \"excluded_middleware\",\n \"excluded_tools\",\n \"extra_middleware\",\n \"frontend_available\",\n \"github_identity\",\n \"include_citation_instructions\",\n \"interpreter_max_ptc_calls\",\n \"interpreter_mode\",\n \"interpreter_ptc\",\n \"interpreter_ptc_exclusive\",\n \"interpreter_runtime\",\n \"interpreter_subagents\",\n \"interpreter_timeout_seconds\",\n \"interrupt_on\",\n \"knowledge_base\",\n \"max_tokens\",\n \"mcp_server_configs\",\n \"mcp_servers\",\n \"memory\",\n \"middleware\",\n \"model\",\n \"muses_enabled\",\n \"muses_recall_enabled\",\n \"office_context\",\n \"outbound_approval_allowlist\",\n \"panel_config\",\n \"permissions\",\n \"project_id\",\n \"recursion_limit\",\n \"run_budget\",\n \"run_label\",\n \"runtime\",\n \"sandbox_runtime\",\n \"secret_asset_ids\",\n \"session_id\",\n \"session_machine\",\n \"session_origin_kind\",\n \"session_tab_id\",\n \"session_vm_retention\",\n \"skill_asset_ids\",\n \"skills\",\n \"skip_title_generation\",\n \"source_aop_id\",\n \"start_channel\",\n \"structured_output\",\n \"subagents\",\n \"system_prompt\",\n \"temperature\",\n \"tool_description_overrides\",\n \"tool_limit_override\",\n \"trigger_type\",\n \"voice_update_handle\",\n \"workbench\",\n \"workspace_id\",\n] as const;\n\nexport type RunConfigCustomKey = (typeof RUN_CONFIG_CUSTOM_KEYS)[number];\n\n/** Fast membership checks for builder/test assertions. */\nexport const RUN_CONFIG_CUSTOM_KEY_SET: ReadonlySet<string> = new Set(\n RUN_CONFIG_CUSTOM_KEYS,\n);\n\n/** `runConfig.custom` keys a client still carries per send on a thread with server config; every other key is dropped at dispatch. */\nexport const RUN_CONFIG_PER_SEND_CUSTOM_KEYS = [\n \"agent\",\n \"allowed_tab_ids\",\n \"app_id\",\n \"channel\",\n \"client_tools\",\n \"collab_channel_id\",\n \"deterministic\",\n \"device_id\",\n \"dry_run\",\n \"entry_point\",\n \"frontend_available\",\n \"github_identity\",\n \"muses_enabled\",\n \"muses_recall_enabled\",\n \"office_context\",\n \"project_id\",\n \"run_budget\",\n \"runtime\",\n \"session_id\",\n \"session_origin_kind\",\n \"session_tab_id\",\n \"skip_title_generation\",\n \"source_aop_id\",\n \"start_channel\",\n \"structured_output\",\n \"tool_limit_override\",\n \"trigger_type\",\n \"voice_update_handle\",\n \"workspace_id\",\n] as const;\n\nexport type RunConfigPerSendCustomKey =\n (typeof RUN_CONFIG_PER_SEND_CUSTOM_KEYS)[number];\n\n/** Fast membership checks for builder/test assertions. */\nexport const RUN_CONFIG_PER_SEND_CUSTOM_KEY_SET: ReadonlySet<string> = new Set(\n RUN_CONFIG_PER_SEND_CUSTOM_KEYS,\n);\n\n/** Keys the thread's server config lane owns — changed only through the `config/*` commands, never per send. */\nexport const THREAD_CONFIG_CUSTOM_KEYS = [\n \"agent_catalog_asset_ids\",\n \"approve_changes\",\n \"async_subagents\",\n \"catalog_asset_ids\",\n \"coding_worker_asset_id\",\n \"coding_workers\",\n \"collab_agent_id\",\n \"compiled_subagents\",\n \"custom_tool_configs\",\n \"declined_toolkit_ids\",\n \"drive_mounts\",\n \"enable_interpreter\",\n \"enable_persistent_fs\",\n \"enable_sandbox\",\n \"enable_skills\",\n \"enabled_toolkits\",\n \"enabled_tools\",\n \"environment\",\n \"environment_id\",\n \"environment_name\",\n \"excluded_middleware\",\n \"excluded_tools\",\n \"extra_middleware\",\n \"include_citation_instructions\",\n \"interpreter_max_ptc_calls\",\n \"interpreter_mode\",\n \"interpreter_ptc\",\n \"interpreter_ptc_exclusive\",\n \"interpreter_runtime\",\n \"interpreter_subagents\",\n \"interpreter_timeout_seconds\",\n \"interrupt_on\",\n \"knowledge_base\",\n \"max_tokens\",\n \"mcp_server_configs\",\n \"mcp_servers\",\n \"memory\",\n \"middleware\",\n \"model\",\n \"outbound_approval_allowlist\",\n \"permissions\",\n \"recursion_limit\",\n \"run_label\",\n \"sandbox_runtime\",\n \"secret_asset_ids\",\n \"session_machine\",\n \"session_vm_retention\",\n \"skill_asset_ids\",\n \"skills\",\n \"subagents\",\n \"system_prompt\",\n \"temperature\",\n \"tool_description_overrides\",\n \"workbench\",\n] as const;\n\nexport type ThreadConfigCustomKey = (typeof THREAD_CONFIG_CUSTOM_KEYS)[number];\n\n/** Fast membership checks for builder/test assertions. */\nexport const THREAD_CONFIG_CUSTOM_KEY_SET: ReadonlySet<string> = new Set(\n THREAD_CONFIG_CUSTOM_KEYS,\n);\n\n/** Replicated-state key of the server config lane (`{ version, custom }`). */\nexport const DEEP_AGENT_CONFIG_STATE_KEY = \"config\";\n\n/** The statewire commands that mutate the server config lane. */\nexport const DEEP_AGENT_CONFIG_COMMANDS = {\n patch: \"config/patch\",\n toolsEnable: \"config/tools/enable\",\n toolsDisable: \"config/tools/disable\",\n} as const;\n\n/** `start_channel` values the session substrate stamps as provenance; anything else clamps to \"web\". */\nexport const KNOWN_START_CHANNELS = [\n \"agent_orchestration\",\n \"api\",\n \"automation\",\n \"chrome_extension\",\n \"cli\",\n \"comment_agent\",\n \"default_voice\",\n \"desktop_app\",\n \"email\",\n \"mobile_app\",\n \"office_addin\",\n \"orchestration\",\n \"programmatic\",\n \"slack\",\n \"sms\",\n \"task\",\n \"teams\",\n \"voice\",\n \"voice_memo\",\n \"web\",\n] as const;\n\nexport type KnownStartChannel = (typeof KNOWN_START_CHANNELS)[number];\n\n/** Fast membership checks for builder/test assertions. */\nexport const KNOWN_START_CHANNEL_SET: ReadonlySet<string> = new Set(\n KNOWN_START_CHANNELS,\n);\n\n/** `runConfig.custom.runtime` marker selecting the deep-agent runtime. */\nexport const DEEP_AGENT_RUNTIME_MARKER = \"athena_deep_agent\";\n\n/**\n * Collab-agent capability ladder (agent schema v3): per explicit\n * capability field, what an ABSENT value means and the value stamped on\n * a new agent. Resolved by agora's `capability_decoder` and the one agent\n * compiler on every run: `passthrough` — explicit only, absent means off;\n * `off` — absent means off under every `runtime` marker; `runtime` —\n * absent derives from the `runtime` marker (`athena_deep_agent` on, any\n * other or missing marker off).\n */\nexport const COLLAB_AGENT_CAPABILITIES = {\n deepAgentBuiltinsEnabled: { absent: \"runtime\", default: true },\n interpreterEnabled: { absent: \"off\", default: false },\n sandboxEnabled: { absent: \"passthrough\", default: false },\n skillsEnabled: { absent: \"runtime\", default: true },\n} as const;\n\nexport type CollabAgentCapabilityField = keyof typeof COLLAB_AGENT_CAPABILITIES;\n\nexport type CollabAgentCapabilityAbsentMode =\n (typeof COLLAB_AGENT_CAPABILITIES)[CollabAgentCapabilityField][\"absent\"];\n\n/** `source`/`type` stamped on client-tool interrupt payloads by agora. */\nexport const CLIENT_TOOL_INTERRUPT_SOURCE = \"client_tool\";\n\n/** `status` literals of the result envelope a client resumes a parked client-tool call with. */\nexport const CLIENT_TOOL_RESULT_STATUSES = [\"error\", \"success\"] as const;\n\nexport type ClientToolResultStatus =\n (typeof CLIENT_TOOL_RESULT_STATUSES)[number];\n\nexport const CLIENT_TOOL_RESULT_STATUS_SUCCESS = \"success\";\n\nexport const CLIENT_TOOL_RESULT_STATUS_ERROR = \"error\";\n\n/**\n * Result envelope a client resumes a parked client-tool call with,\n * keyed by interrupt id:\n * `{ client_tool_results: { <interrupt_id>: <envelope> } }`.\n * Agora relays the envelope to the model verbatim.\n */\nexport type ClientToolResultEnvelopeContract =\n | { status: typeof CLIENT_TOOL_RESULT_STATUS_SUCCESS; result: unknown }\n | { status: typeof CLIENT_TOOL_RESULT_STATUS_ERROR; error: string };\n\n/**\n * The deep-agent wire-contract version this client build speaks,\n * declared on every attach. The host records it for attach telemetry\n * and per-version behaviour; it has no minimum client version, so no\n * build is refused for the version it declares (the `protocol` state\n * lane's `minClientVersion` is the constant 1).\n */\nexport const DEEP_AGENT_PROTOCOL_VERSION = 1;\n\n/** Attach header carrying the client's declared contract version. */\nexport const DEEP_AGENT_PROTOCOL_VERSION_HEADER =\n \"x-athena-deep-agent-protocol-version\";\n\n/** Attach header declaring the head window a fresh client wants in its hello (host-clamped). */\nexport const DEEP_AGENT_MESSAGE_WINDOW_HEADER = \"x-athena-deep-agent-window\";\n\n/** Replicated-state key of the server-advertised version lane. */\nexport const DEEP_AGENT_PROTOCOL_STATE_KEY = \"protocol\";\n\n/** Ephemeral subprotocol carrying a client's message-window interests. */\nexport const DEEP_AGENT_INTEREST_PROTOCOL = \"athena/interest\";\n\n/** Ephemeral subprotocol carrying a client's synced context document. */\nexport const DEEP_AGENT_CONTEXT_PROTOCOL = \"athena/context\";\n\n/** The only interest namespace the host resolves (the linear transcript). */\nexport const DEEP_AGENT_MAIN_NS = \"main\";\n\n/** Window size (interest `before`) a client asks for by default. */\nexport const DEEP_AGENT_DEFAULT_MESSAGE_WINDOW = 40;\n\n/** Bounds on a window size. */\nexport const DEEP_AGENT_MIN_MESSAGE_WINDOW = 8;\n\nexport const DEEP_AGENT_MAX_MESSAGE_WINDOW = 200;\n\n/** Interests one attach may hold at once (the head plus its pages). */\nexport const DEEP_AGENT_MAX_INTERESTS = 16;\n\n/** Command returning a truncated tool output whole. */\nexport const DEEP_AGENT_HISTORY_TOOL_OUTPUT_COMMAND = \"history/tool_output\";\n\n/** Command returning one stored message whole (provenance and full tool output included). */\nexport const DEEP_AGENT_HISTORY_MESSAGE_COMMAND = \"history/message\";\n\n/** Wire key marking a tool message whose content was truncated. */\nexport const DEEP_AGENT_TRUNCATED_CONTENT_KEY = \"athena_content_truncated\";\n\n/** Most inline-image payload characters one message carries whole on the wire. */\nexport const DEEP_AGENT_INLINE_IMAGE_WIRE_BUDGET = 4194304;\n\n/** Wire key on an image block left off the wire: `{ index, chars, mediaType }`. */\nexport const DEEP_AGENT_OMITTED_IMAGE_KEY = \"athena_image_omitted\";\n\n/** The image an omitted block carries instead of its own (a neutral PNG tile). */\nexport const DEEP_AGENT_OMITTED_IMAGE_PLACEHOLDER_URL =\n \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAAB4AQMAAABPbGssAAAABlBMVEXi6PCUo7jao11HAAAA6ElEQVR42u2UyW3DMBBF3wxogEd2EJbCElKQDRCwC3MpSRc5eLuYokgNLEUxctK/CHyanQts2vRO3QdlALVsXsBvecqxxr1ob0A5GlDJU+hICxN54p/qXAx/+FpoeeE8hTerzfvByn7ifzpaBtWCOwv6bMVMBgzRgNGKmUL9McDs4XOSyEHuoKCI76AiqOugg+y0gx6SN+YQg3QwALGk19pQSKV/reOocyoww27oU5sxhAbKUNgIqrVxrvnovJ80MFgxYy23wtTss44tmL+bAuOE2p2o0fJa3iW/6iR/lEfx8kv3TZtW6AFk5Sf3k+GTswAAAABJRU5ErkJggg==\";\n\n/**\n * Command returning one inline image of a stored message in chunks:\n * `{ messageId, index, offset? }` answers\n * `{ messageId, index, mediaType, offset, total, chunk, next }`; the\n * chunks joined in order are the image's `data:` URL, and `next` is\n * the offset to ask for next (`null` after the last chunk).\n */\nexport const DEEP_AGENT_HISTORY_IMAGE_COMMAND = \"history/image\";\n"],"names":[],"mappings":"AA8GO,MAAM,yBAAyB;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAK8D,IAAI;AAAA,EAChE;AACF;AAGO,MAAM,kCAAkC;AAAA,EAC7C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAMuE,IAAI;AAAA,EACzE;AACF;AAGO,MAAM,4BAA4B;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAKiE,IAAI;AAAA,EACnE;AACF;AAaO,MAAM,uBAAuB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAK4D,IAAI;AAAA,EAC9D;AACF;AA2BO,MAAM,+BAA+B;AAQrC,MAAM,oCAAoC;AAE1C,MAAM,kCAAkC;AAmBxC,MAAM,8BAA8B;AAGpC,MAAM,qCACX;AAGK,MAAM,mCAAmC;AAGzC,MAAM,gCAAgC;AAGtC,MAAM,+BAA+B;AAMrC,MAAM,qBAAqB;AAG3B,MAAM,oCAAoC;AAG1C,MAAM,gCAAgC;AAEtC,MAAM,gCAAgC;AAGtC,MAAM,2BAA2B;AAGjC,MAAM,yCAAyC;AAM/C,MAAM,mCAAmC;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"github-wake-event.cjs","sources":["../../../../../agent-runtime/src/github-wake-event.ts"],"sourcesContent":["/**\n * The GitHub event that woke a resting session, read from the user turn the\n * wake injected.\n *\n * When a GitHub webhook wakes a linked session (agora\n * `trigger_engine/actions/handlers/github_thread_wake.py`), the injected user\n * turn carries a provenance envelope under `github_event_source` in its\n * message metadata (`services/channels/github_event_source.py`). The shipped\n * converter exposes that metadata as the thread message's `metadata.custom`,\n * so every surface reads the envelope from there and renders the turn as a\n * compact runtime marker (\"Woke: review comment on #36337\") instead of a user\n * bubble quoting the whole wake text. The envelope is provenance for RENDERING\n * only: the model still receives the full composed text, so a surface that\n * ignores it degrades to a plain bubble, never to a lost instruction.\n */\n\n/** `metadata.custom` key the wake handler stamps on the injected user turn. */\nexport const GITHUB_EVENT_SOURCE_KEY = 'github_event_source';\n\n/**\n * `owner/name`, the only repository shape the wake handler stamps. The\n * envelope is message metadata, which a collaborator with write access to\n * the thread can also author, so a marker is only rendered for an envelope\n * of the real shape and only links back into the named repository on\n * github.com (see {@link githubWakeEventUrl}) — a forged envelope can at\n * most point at its own repository, never at an arbitrary host.\n */\nconst REPO_FULL_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]*\\/[A-Za-z0-9._-]+$/;\n\nconst GITHUB_HOSTS: ReadonlySet<string> = new Set(['github.com', 'www.github.com']);\n\nexport interface GithubWakeEvent {\n /** `owner/repo` the event came from. */\n repo: string;\n /** The pull request number, when the event names one. */\n number: number | null;\n /** The webhook event name (`pull_request_review_comment`, `check_run`, …). */\n githubEvent: string | null;\n /** The event's `action` (`created`, `submitted`, `completed`, …). */\n action: string | null;\n /** GitHub login of who caused the event. */\n sender: string | null;\n /** The pull request title, when the payload carried one. */\n title: string | null;\n /**\n * Link to the pull request (or the repository for repo-level events),\n * kept only when it points into `repo` on github.com\n * ({@link githubWakeEventUrl}); any other value reads as `null`.\n */\n url: string | null;\n /** A review's state (`approved`, `changes_requested`, `commented`). */\n reviewState: string | null;\n /** A check's name and conclusion, for check events. */\n checkName: string | null;\n checkConclusion: string | null;\n /** The comment or review body, cut to the card budget by the backend. */\n bodyExcerpt: string | null;\n /** ISO 8601 receipt time stamped by the backend. */\n receivedAt: string | null;\n}\n\nfunction readString(record: Record<string, unknown>, key: string): string | null {\n const value = record[key];\n return typeof value === 'string' && value.trim().length > 0 ? value : null;\n}\n\nfunction readNumber(record: Record<string, unknown>, key: string): number | null {\n const value = record[key];\n if (typeof value === 'number' && Number.isFinite(value)) return value;\n if (typeof value === 'string' && /^\\d+$/.test(value.trim())) return Number(value.trim());\n return null;\n}\n\n/**\n * The envelope's link when it is an `https://github.com/<repo>/…` URL for the\n * envelope's own repository, else `null`. The marker never renders a link\n * that could lead anywhere else, whatever the metadata claims.\n */\nexport function githubWakeEventUrl(repo: string, url: string | null): string | null {\n if (url === null) return null;\n let parsed: URL;\n try {\n parsed = new URL(url);\n } catch {\n return null;\n }\n if (parsed.protocol !== 'https:' || !GITHUB_HOSTS.has(parsed.hostname.toLowerCase())) {\n return null;\n }\n const path = parsed.pathname.toLowerCase();\n const prefix = `/${repo.toLowerCase()}`;\n return path === prefix || path.startsWith(`${prefix}/`) ? parsed.toString() : null;\n}\n\n/**\n * The wake envelope behind a thread message's `metadata.custom`, or\n * `undefined` when the message is an ordinary user turn (or the envelope is\n * not of the shape the wake handler stamps — a missing or malformed\n * repository is not a wake worth rendering).\n */\nexport function readGithubWakeEvent(\n custom: Record<string, unknown> | null | undefined\n): GithubWakeEvent | undefined {\n const raw = custom?.[GITHUB_EVENT_SOURCE_KEY];\n if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) return undefined;\n const record = raw as Record<string, unknown>;\n const repo = readString(record, 'repo');\n if (repo === null || !REPO_FULL_NAME.test(repo)) return undefined;\n return {\n repo,\n number: readNumber(record, 'number'),\n githubEvent: readString(record, 'github_event'),\n action: readString(record, 'action'),\n sender: readString(record, 'sender'),\n title: readString(record, 'title'),\n url: githubWakeEventUrl(repo, readString(record, 'url')),\n reviewState: readString(record, 'review_state'),\n checkName: readString(record, 'check_name'),\n checkConclusion: readString(record, 'check_conclusion'),\n bodyExcerpt: readString(record, 'body_excerpt'),\n receivedAt: readString(record, 'received_at'),\n };\n}\n\n/**\n * Whether a thread message is a GitHub wake turn. Returns a primitive, so it\n * is safe as a `useAuiState` selector (the reader above builds a fresh object\n * per call; an object snapshot would loop the render under `Object.is`).\n */\nexport function isGithubWakeMessage(custom: Record<string, unknown> | null | undefined): boolean {\n return readGithubWakeEvent(custom) !== undefined;\n}\n\nfunction humanize(value: string): string {\n return value.replace(/[._]/g, ' ').trim();\n}\n\n/**\n * The event in a few words, in sentence position (\"review comment\",\n * \"review: changes requested\", \"check CI: failure\", \"pull request opened\").\n */\nexport function githubWakeEventLabel(event: GithubWakeEvent): string {\n const name = event.githubEvent ?? '';\n if (name.includes('review_comment')) return 'review comment';\n if (name.includes('review')) {\n return event.reviewState ? `review: ${humanize(event.reviewState)}` : 'review';\n }\n if (name.includes('comment')) return 'comment';\n if (name.includes('check')) {\n const check = event.checkName ? `check ${event.checkName}` : 'check';\n return event.checkConclusion ? `${check}: ${humanize(event.checkConclusion)}` : check;\n }\n if (event.action) return `${humanize(name) || 'event'} ${humanize(event.action)}`.trim();\n return humanize(name) || 'GitHub event';\n}\n\n/** `owner/repo#123`, or `owner/repo` for a repository-level event. */\nexport function githubWakeReference(event: GithubWakeEvent): string {\n return event.number !== null ? `${event.repo}#${event.number}` : event.repo;\n}\n\n/**\n * The marker line every surface renders for a wake turn:\n * \"Woke: review comment on #36337\" (the repository when there is no number).\n */\nexport function githubWakeMarkerText(event: GithubWakeEvent): string {\n const target = event.number !== null ? `#${event.number}` : event.repo;\n return `Woke: ${githubWakeEventLabel(event)} on ${target}`;\n}\n"],"names":[],"mappings":";;AAiBO,MAAM,0BAA0B;AAUvC,MAAM,iBAAiB;AAEvB,MAAM,eAAoC,oBAAI,IAAI,CAAC,cAAc,gBAAgB,CAAC;AAgClF,SAAS,WAAW,QAAiC,KAA4B;AAC/E,QAAM,QAAQ,OAAO,GAAG;AACxB,SAAO,OAAO,UAAU,YAAY,MAAM,OAAO,SAAS,IAAI,QAAQ;AACxE;AAEA,SAAS,WAAW,QAAiC,KAA4B;AAC/E,QAAM,QAAQ,OAAO,GAAG;AACxB,MAAI,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,EAAG,QAAO;AAChE,MAAI,OAAO,UAAU,YAAY,QAAQ,KAAK,MAAM,KAAA,CAAM,EAAG,QAAO,OAAO,MAAM,MAAM;AACvF,SAAO;AACT;AAOO,SAAS,mBAAmB,MAAc,KAAmC;AAClF,MAAI,QAAQ,KAAM,QAAO;AACzB,MAAI;AACJ,MAAI;AACF,aAAS,IAAI,IAAI,GA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O,MAAM,eAAe;AAClC,MAAI,KAAK,SAAS,gBAAgB,EAAG,QAAO;AAC5C,MAAI,KAAK,SAAS,QAAQ,GAAG;AAC3B,WAAO,MAAM,cAAc,WAAW,SAAS,MAAM,WAAW,CAAC,KAAK;AAAA,EACxE;AACA,MAAI,KAAK,SAAS,SAAS,EAAG,QAAO;AACrC,MAAI,KAAK,SAAS,OAAO,GAAG;AAC1B,UAAM,QAAQ,MAAM,YAAY,SAAS,MAAM,SAAS,KAAK;AAC7D,WAAO,MAAM,kBAAkB,GAAG,KAAK,KAAK,SAAS,MAAM,eAAe,CAAC,KAAK;AAAA,EAClF;AACA,MAAI,MAAM,OAAQ,QAAO,GAAG,SAAS,IAAI,KAAK,OAAO,IAAI,SAAS,MAAM,MAAM,CAAC,GAAG,KAAA;AAClF,SAAO,SAAS,IAAI,KAAK;AAC3B;AAGO,SAAS,oBAAoB,OAAgC;AAClE,SAAO,MAAM,WAAW,OAAO,GAAG,MAAM,IAAI,IAAI,MAAM,MAAM,KAAK,MAAM;AACzE;AAMO,SAAS,qBAAqB,OAAgC;AACnE,QAAM,SAAS,MAAM,WAAW,OAAO,IAAI,MAAM,MAAM,KAAK,MAAM;AAClE,SAAO,SAAS,qBAAqB,KAAK,CAAC,OAAO,MAAM;AAC1D;;;;;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"github-wake-event.js","sources":["../../../../../agent-runtime/src/github-wake-event.ts"],"sourcesContent":["/**\n * The GitHub event that woke a resting session, read from the user turn the\n * wake injected.\n *\n * When a GitHub webhook wakes a linked session (agora\n * `trigger_engine/actions/handlers/github_thread_wake.py`), the injected user\n * turn carries a provenance envelope under `github_event_source` in its\n * message metadata (`services/channels/github_event_source.py`). The shipped\n * converter exposes that metadata as the thread message's `metadata.custom`,\n * so every surface reads the envelope from there and renders the turn as a\n * compact runtime marker (\"Woke: review comment on #36337\") instead of a user\n * bubble quoting the whole wake text. The envelope is provenance for RENDERING\n * only: the model still receives the full composed text, so a surface that\n * ignores it degrades to a plain bubble, never to a lost instruction.\n */\n\n/** `metadata.custom` key the wake handler stamps on the injected user turn. */\nexport const GITHUB_EVENT_SOURCE_KEY = 'github_event_source';\n\n/**\n * `owner/name`, the only repository shape the wake handler stamps. The\n * envelope is message metadata, which a collaborator with write access to\n * the thread can also author, so a marker is only rendered for an envelope\n * of the real shape and only links back into the named repository on\n * github.com (see {@link githubWakeEventUrl}) — a forged envelope can at\n * most point at its own repository, never at an arbitrary host.\n */\nconst REPO_FULL_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]*\\/[A-Za-z0-9._-]+$/;\n\nconst GITHUB_HOSTS: ReadonlySet<string> = new Set(['github.com', 'www.github.com']);\n\nexport interface GithubWakeEvent {\n /** `owner/repo` the event came from. */\n repo: string;\n /** The pull request number, when the event names one. */\n number: number | null;\n /** The webhook event name (`pull_request_review_comment`, `check_run`, …). */\n githubEvent: string | null;\n /** The event's `action` (`created`, `submitted`, `completed`, …). */\n action: string | null;\n /** GitHub login of who caused the event. */\n sender: string | null;\n /** The pull request title, when the payload carried one. */\n title: string | null;\n /**\n * Link to the pull request (or the repository for repo-level events),\n * kept only when it points into `repo` on github.com\n * ({@link githubWakeEventUrl}); any other value reads as `null`.\n */\n url: string | null;\n /** A review's state (`approved`, `changes_requested`, `commented`). */\n reviewState: string | null;\n /** A check's name and conclusion, for check events. */\n checkName: string | null;\n checkConclusion: string | null;\n /** The comment or review body, cut to the card budget by the backend. */\n bodyExcerpt: string | null;\n /** ISO 8601 receipt time stamped by the backend. */\n receivedAt: string | null;\n}\n\nfunction readString(record: Record<string, unknown>, key: string): string | null {\n const value = record[key];\n return typeof value === 'string' && value.trim().length > 0 ? value : null;\n}\n\nfunction readNumber(record: Record<string, unknown>, key: string): number | null {\n const value = record[key];\n if (typeof value === 'number' && Number.isFinite(value)) return value;\n if (typeof value === 'string' && /^\\d+$/.test(value.trim())) return Number(value.trim());\n return null;\n}\n\n/**\n * The envelope's link when it is an `https://github.com/<repo>/…` URL for the\n * envelope's own repository, else `null`. The marker never renders a link\n * that could lead anywhere else, whatever the metadata claims.\n */\nexport function githubWakeEventUrl(repo: string, url: string | null): string | null {\n if (url === null) return null;\n let parsed: URL;\n try {\n parsed = new URL(url);\n } catch {\n return null;\n }\n if (parsed.protocol !== 'https:' || !GITHUB_HOSTS.has(parsed.hostname.toLowerCase())) {\n return null;\n }\n const path = parsed.pathname.toLowerCase();\n const prefix = `/${repo.toLowerCase()}`;\n return path === prefix || path.startsWith(`${prefix}/`) ? parsed.toString() : null;\n}\n\n/**\n * The wake envelope behind a thread message's `metadata.custom`, or\n * `undefined` when the message is an ordinary user turn (or the envelope is\n * not of the shape the wake handler stamps — a missing or malformed\n * repository is not a wake worth rendering).\n */\nexport function readGithubWakeEvent(\n custom: Record<string, unknown> | null | undefined\n): GithubWakeEvent | undefined {\n const raw = custom?.[GITHUB_EVENT_SOURCE_KEY];\n if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) return undefined;\n const record = raw as Record<string, unknown>;\n const repo = readString(record, 'repo');\n if (repo === null || !REPO_FULL_NAME.test(repo)) return undefined;\n return {\n repo,\n number: readNumber(record, 'number'),\n githubEvent: readString(record, 'github_event'),\n action: readString(record, 'action'),\n sender: readString(record, 'sender'),\n title: readString(record, 'title'),\n url: githubWakeEventUrl(repo, readString(record, 'url')),\n reviewState: readString(record, 'review_state'),\n checkName: readString(record, 'check_name'),\n checkConclusion: readString(record, 'check_conclusion'),\n bodyExcerpt: readString(record, 'body_excerpt'),\n receivedAt: readString(record, 'received_at'),\n };\n}\n\n/**\n * Whether a thread message is a GitHub wake turn. Returns a primitive, so it\n * is safe as a `useAuiState` selector (the reader above builds a fresh object\n * per call; an object snapshot would loop the render under `Object.is`).\n */\nexport function isGithubWakeMessage(custom: Record<string, unknown> | null | undefined): boolean {\n return readGithubWakeEvent(custom) !== undefined;\n}\n\nfunction humanize(value: string): string {\n return value.replace(/[._]/g, ' ').trim();\n}\n\n/**\n * The event in a few words, in sentence position (\"review comment\",\n * \"review: changes requested\", \"check CI: failure\", \"pull request opened\").\n */\nexport function githubWakeEventLabel(event: GithubWakeEvent): string {\n const name = event.githubEvent ?? '';\n if (name.includes('review_comment')) return 'review comment';\n if (name.includes('review')) {\n return event.reviewState ? `review: ${humanize(event.reviewState)}` : 'review';\n }\n if (name.includes('comment')) return 'comment';\n if (name.includes('check')) {\n const check = event.checkName ? `check ${event.checkName}` : 'check';\n return event.checkConclusion ? `${check}: ${humanize(event.checkConclusion)}` : check;\n }\n if (event.action) return `${humanize(name) || 'event'} ${humanize(event.action)}`.trim();\n return humanize(name) || 'GitHub event';\n}\n\n/** `owner/repo#123`, or `owner/repo` for a repository-level event. */\nexport function githubWakeReference(event: GithubWakeEvent): string {\n return event.number !== null ? `${event.repo}#${event.number}` : event.repo;\n}\n\n/**\n * The marker line every surface renders for a wake turn:\n * \"Woke: review comment on #36337\" (the repository when there is no number).\n */\nexport function githubWakeMarkerText(event: GithubWakeEvent): string {\n const target = event.number !== null ? `#${event.number}` : event.repo;\n return `Woke: ${githubWakeEventLabel(event)} on ${target}`;\n}\n"],"names":[],"mappings":"AAiBO,MAAM,0BAA0B;AAUvC,MAAM,iBAAiB;AAEvB,MAAM,eAAoC,oBAAI,IAAI,CAAC,cAAc,gBAAgB,CAAC;AAgClF,SAAS,WAAW,QAAiC,KAA4B;AAC/E,QAAM,QAAQ,OAAO,GAAG;AACxB,SAAO,OAAO,UAAU,YAAY,MAAM,OAAO,SAAS,IAAI,QAAQ;AACxE;AAEA,SAAS,WAAW,QAAiC,KAA4B;AAC/E,QAAM,QAAQ,OAAO,GAAG;AACxB,MAAI,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,EAAG,QAAO;AAChE,MAAI,OAAO,UAAU,YAAY,QAAQ,KAAK,MAAM,KAAA,CAAM,EAAG,QAAO,OAAO,MAAM,MAAM;AACvF,SAAO;AACT;AAOO,SAAS,mBAAmB,MAAc,KAAmC;AAClF,MAAI,QAAQ,KAAM,QAAO;AACzB,MAAI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,SAAS,qBAAqB,OAAgC;AACnE,QAAM,OAAO,MAAM,eAAe;AAClC,MAAI,KAAK,SAAS,gBAAgB,EAAG,QAAO;AAC5C,MAAI,KAAK,SAAS,QAAQ,GAAG;AAC3B,WAAO,MAAM,cAAc,WAAW,SAAS,MAAM,WAAW,CAAC,KAAK;AAAA,EACxE;AACA,MAAI,KAAK,SAAS,SAAS,EAAG,QAAO;AACrC,MAAI,KAAK,SAAS,OAAO,GAAG;AAC1B,UAAM,QAAQ,MAAM,YAAY,SAAS,MAAM,SAAS,KAAK;AAC7D,WAAO,MAAM,kBAAkB,GAAG,KAAK,KAAK,SAAS,MAAM,eAAe,CAAC,KAAK;AAAA,EAClF;AACA,MAAI,MAAM,OAAQ,QAAO,GAAG,SAAS,IAAI,KAAK,OAAO,IAAI,SAAS,MAAM,MAAM,CAAC,GAAG,KAAA;AAClF,SAAO,SAAS,IAAI,KAAK;AAC3B;AAGO,SAAS,oBAAoB,OAAgC;AAClE,SAAO,MAAM,WAAW,OAAO,GAAG,MAAM,IAAI,IAAI,MAAM,MAAM,KAAK,MAAM;AACzE;AAMO,SAAS,qBAAqB,OAAgC;AACnE,QAAM,SAAS,MAAM,WAAW,OAAO,IAAI,MAAM,MAAM,KAAK,MAAM;AAClE,SAAO,SAAS,qBAAqB,KAAK,CAAC,OAAO,MAAM;AAC1D;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"interrupts.cjs","sources":["../../../../../agent-runtime/src/interrupts.ts"],"sourcesContent":["/**\n * Human-in-the-loop interrupt primitives shared by every statewire chat\n * surface (Olympus, the React SDK, the Office add-in, the Chrome extension,\n * mobile).\n *\n * The agora deep-agent runtime parks a gated run on an `interrupt` input\n * request whose payload carries the Athena `hitl_approval` shape\n * (`athena_deep_agent/hitl_bridge.py`). A surface answers it with\n * `{ type: 'run/input', requestId, response: { type: 'resume', value } }` —\n * the exact command the backend's resume path consumes. This module holds the\n * payload contract (narrowing, resume values) and the shared resume-lock state\n * machine; rendering stays with each surface.\n *\n * Deliberately parameterized rather than self-wiring: these helpers never call\n * `useStatewireRuns`/`useAuiState` themselves. Each surface reads its own\n * statewire hooks (which its tests already mock) and passes the values in, so\n * the shared semantics cannot drift while per-surface wiring stays testable.\n */\n\nimport type { StatewireThread } from '@assistant-ui/react-statewire';\nimport { useCallback, useEffect, useRef, useState } from 'react';\nimport { hasClientToolInterruptSource } from './client-tools';\nimport { statewireTransportOutcome } from './errors';\nimport { readDeepAgentStreamValues } from './statewire-state';\n\n/** Human-in-the-loop approval payload the agora deep-agent runtime parks a run\n * on (shaped by `athena_deep_agent/hitl_bridge.py`). */\nexport interface HitlApprovalPayload {\n source: string;\n type: string;\n message: string;\n /** Risk headline/facts/warnings, when the host includes them. */\n approval_context?: unknown;\n context?: {\n tool_name?: string;\n tool_id?: string;\n tool_call_id?: string;\n tool_args?: Record<string, unknown>;\n pending_action_count?: number;\n approval_context?: unknown;\n /**\n * Every pending gated call (name + args), in decision order. Absent on\n * older backends — fall back to the single `tool_name`/`tool_args` pair.\n * Per-dispatch payloads also carry each lane's `tool_call_id` (the lane\n * card key) and `interrupt_id` (the lane resume key).\n */\n action_requests?: {\n name?: string;\n args?: Record<string, unknown>;\n tool_call_id?: string;\n interrupt_id?: string;\n /**\n * True when \"approve all for this session\" would take effect for this\n * tool (the workspace allows overriding its approval). Absent on older\n * backends and on non-overridable tools: the option is not offered.\n */\n session_approval_allowed?: boolean;\n /**\n * The decision types the parked gate accepts for this call (`approve`,\n * `reject`, `edit`). Absent on older backends: only approve / reject\n * are known to be accepted.\n */\n allowed_decisions?: string[];\n /** What the backend resolved about this call before asking (display-only). */\n approval_context?: unknown;\n }[];\n /**\n * True when each dispatch parked on its own interrupt: decisions submit\n * per lane via `lane_decisions` and each approved lane starts immediately,\n * instead of the legacy batch where one resume must answer every lane.\n */\n per_dispatch?: boolean;\n };\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n/** A pending `interrupt` input request; a present `response` key marks it answered. */\nexport function isPendingInterrupt(\n request: StatewireThread.InputRequestState,\n): request is StatewireThread.CustomInputRequest {\n return request.type === 'interrupt' && !('response' in request);\n}\n\n/**\n * Interrupt sources that were system pauses before the host stamped\n * `requires_user_action: false` on them (a background deep-research wait). Kept\n * only for the deploy skew between an older agora and a newer client; delete\n * once every deployment's raiser stamps the flag.\n */\nconst LEGACY_SYSTEM_PAUSE_INTERRUPT_SOURCES: ReadonlySet<string> = new Set(['deep_research_pending']);\n\n/**\n * A park nobody answers: the agent is still working (a background research\n * wait) and the backend resumes it itself. The raiser stamps\n * `requires_user_action: false`; older raisers are recognised by source.\n */\nexport function isSystemPauseInterrupt(payload: unknown): boolean {\n if (!isRecord(payload)) return false;\n if (payload.requires_user_action === false) return true;\n return (\n typeof payload.source === 'string' && LEGACY_SYSTEM_PAUSE_INTERRUPT_SOURCES.has(payload.source)\n );\n}\n\n/**\n * A pending interrupt an approval card may answer. Two kinds are excluded —\n * client-tool parks (the client-tool bridge owns those, and a generic resume\n * would corrupt the parked tool call) and system pauses (nothing to answer; the\n * backend resumes them). The source checks are deliberately loose so a skewed\n * deploy can never route one here.\n */\nexport function isApprovalCardInterrupt(\n request: StatewireThread.InputRequestState,\n): request is StatewireThread.CustomInputRequest {\n if (!isPendingInterrupt(request)) return false;\n const payload = (request as { payload?: unknown }).payload;\n return !hasClientToolInterruptSource(payload) && !isSystemPauseInterrupt(payload);\n}\n\n/** Narrow an interrupt payload to the Athena HITL approval shape. */\nexport function asHitlApproval(value: unknown): HitlApprovalPayload | null {\n if (!isRecord(value)) return null;\n return value.type === 'hitl' &&\n value.source === 'hitl_approval' &&\n typeof value.message === 'string'\n ? (value as unknown as HitlApprovalPayload)\n : null;\n}\n\n/** Default paused-run copy when an interrupt payload carries no message. */\nexport const DEFAULT_INTERRUPT_PAUSED_MESSAGE =\n 'The agent is paused and waiting for input.';\n\n/** Best-effort human-readable message from any interrupt payload. */\nexport function readInterruptMessage(\n value: unknown,\n fallback: string = DEFAULT_INTERRUPT_PAUSED_MESSAGE,\n): string {\n if (isRecord(value) && typeof value.message === 'string' && value.message.length > 0) {\n return value.message;\n }\n return fallback;\n}\n\n/** One label/value row of a call's resolved approval facts. */\nexport interface PendingApprovalFact {\n label: string;\n value: string;\n}\n\n/** One caution of a call's resolved approval facts. */\nexport interface PendingApprovalWarning {\n severity: 'info' | 'warning' | 'critical';\n message: string;\n}\n\n/**\n * What the backend resolved about a gated call before asking — e.g. where a\n * Slack write goes and as whom (agora `services/interrupts/approval_context.py`).\n * Display-only; the decision still answers the parked call.\n */\nexport interface PendingApprovalContext {\n facts: PendingApprovalFact[];\n warnings: PendingApprovalWarning[];\n}\n\nconst APPROVAL_WARNING_SEVERITIES = new Set(['info', 'warning', 'critical']);\n\n/** A call's `approval_context`, or `undefined` when absent or empty. */\nexport function parsePendingApprovalContext(value: unknown): PendingApprovalContext | undefined {\n if (!isRecord(value)) return undefined;\n const facts: PendingApprovalFact[] = Array.isArray(value.facts)\n ? value.facts.flatMap((fact) =>\n isRecord(fact) && typeof fact.label === 'string' && typeof fact.value === 'string'\n ? [{ label: fact.label, value: fact.value }]\n : [],\n )\n : [];\n const warnings: PendingApprovalWarning[] = Array.isArray(value.warnings)\n ? value.warnings.flatMap((warning) => {\n if (!isRecord(warning) || typeof warning.message !== 'string') return [];\n const severity =\n typeof warning.severity === 'string' && APPROVAL_WARNING_SEVERITIES.has(warning.severity)\n ? (warning.severity as PendingApprovalWarning['severity'])\n : 'info';\n return [{ severity, message: warning.message }];\n })\n : [];\n return facts.length > 0 || warnings.length > 0 ? { facts, warnings } : undefined;\n}\n\nexport interface PendingActionRequest {\n name: string;\n args: Record<string, unknown>;\n /** The lane's `task` tool-call id (present on per-dispatch payloads). */\n toolCallId?: string;\n /** The lane's langgraph interrupt id — the `lane_decisions` resume key. */\n interruptId?: string;\n /** Present (true) when a session-wide approval would cover later calls of this tool. */\n sessionApprovalAllowed?: true;\n /** Present (true) when the gate accepts an `edit` decision for this call. */\n editAllowed?: true;\n /** Present when the backend resolved facts about this call before asking. */\n approvalContext?: PendingApprovalContext;\n}\n\n/**\n * Every gated call this approval covers, in decision order. One resume answers\n * ALL of them, so every entry must stay reviewable somewhere. Falls back to\n * the single first-call fields on older backends without `action_requests`.\n */\nexport function pendingActionRequests(hitl: HitlApprovalPayload | null): PendingActionRequest[] {\n const context = hitl?.context;\n if (!context) return [];\n // The payload crosses the wire with only its top-level shape narrowed\n // (`asHitlApproval`), so the nested collection must be validated before any\n // array/property access: a malformed host value must degrade to \"no\n // reviewable entries\", never crash the approval surface.\n const requests: Record<string, unknown>[] = Array.isArray(context.action_requests)\n ? context.action_requests.filter(isRecord)\n : context.tool_name && context.tool_args\n ? [{ name: context.tool_name, args: context.tool_args, tool_call_id: context.tool_call_id }]\n : [];\n return requests.map((request) => {\n const approvalContext = parsePendingApprovalContext(request.approval_context);\n return {\n name: typeof request.name === 'string' ? request.name : 'tool',\n args: isRecord(request.args) ? request.args : {},\n ...(typeof request.tool_call_id === 'string' && { toolCallId: request.tool_call_id }),\n ...(typeof request.interrupt_id === 'string' && { interruptId: request.interrupt_id }),\n ...(request.session_approval_allowed === true && { sessionApprovalAllowed: true }),\n ...(Array.isArray(request.allowed_decisions) &&\n request.allowed_decisions.includes('edit') && { editAllowed: true }),\n ...(approvalContext && { approvalContext }),\n };\n });\n}\n\n/**\n * Whether the card may offer \"approve all for this session\": every pending\n * call must be one the backend stamped as session-approvable, so a batch that\n * mixes in a tool the workspace pinned as always-prompt only offers the\n * one-time answer.\n */\nexport function canApproveForSession(actionRequests: readonly PendingActionRequest[]): boolean {\n return (\n actionRequests.length > 0 &&\n actionRequests.every((request) => request.sessionApprovalAllowed === true)\n );\n}\n\n/** An interrupt a non-resume dispatch dropped, published by the host. */\nexport interface AbandonedInputRequest {\n id: string;\n type: string;\n}\n\n/**\n * `useStatewireState` selector body for the host-published abandoned input\n * requests. Reads through {@link readDeepAgentStreamValues} so the selector is\n * safe on the pre-attach (`undefined`) wire state, and returns the raw array\n * reference so the subscription stays shallow-stable — derive (`.find`) on the\n * result, never inside the selector.\n */\nexport function readAbandonedInputRequests(\n state: unknown,\n): readonly AbandonedInputRequest[] | undefined {\n const abandoned = readDeepAgentStreamValues(state).abandonedInputRequests;\n // Wire value: anything non-array (including a malformed host publication)\n // reads as \"none\" rather than crashing the consuming surface. Identity-\n // preserving for the valid case, so it stays selector-safe.\n return Array.isArray(abandoned)\n ? (abandoned as readonly AbandonedInputRequest[])\n : undefined;\n}\n\n/**\n * `useStatewireState` selector body for the host's mirrored interrupt\n * (`__interrupt__`, the LangGraph `{value, resumable}` wrapper). The mirror\n * is published the moment a lane parks on its gate — while sibling lanes are\n * still streaming and the run manager has NOT yet published an answerable\n * input request. Raw reference, selector-safe; unwrap with\n * {@link interruptMirrorPayload}.\n */\nexport function readInterruptMirror(state: unknown): unknown {\n return readDeepAgentStreamValues(state).__interrupt__;\n}\n\n/** The payload of a mirrored interrupt wrapper, or `undefined` for anything else. */\nexport function interruptMirrorPayload(mirror: unknown): unknown {\n return isRecord(mirror) ? mirror.value : undefined;\n}\n\n/**\n * `useStatewireState` selector body for the per-dispatch lane decisions the\n * host accepted through `run/lane-input` while the run was still streaming\n * (`queuedLaneDecisions`, keyed by langgraph interrupt id). Held until the\n * run parks, then answered as a native `lane_decisions` resume; every attached\n * client reads a queued lane as decided. Raw reference, selector-safe.\n */\nexport function readQueuedLaneDecisions(\n state: unknown,\n): Readonly<Record<string, unknown>> | undefined {\n const queued = readDeepAgentStreamValues(state).queuedLaneDecisions;\n return isRecord(queued) ? queued : undefined;\n}\n\n/**\n * The distinct langgraph interrupt ids a `lane_decisions` resume answers for\n * these gated calls, in first-seen order — or `null` when any call lacks its\n * stamp (a legacy batch payload only a positional resume can answer). A\n * nested HITL request gating several calls contributes one id: the lane is\n * the interrupt, and one decision fans across its calls server-side.\n */\nexport function laneInterruptIds(actionRequests: readonly PendingActionRequest[]): string[] | null {\n if (actionRequests.length === 0) return null;\n const ids: string[] = [];\n for (const request of actionRequests) {\n if (request.interruptId === undefined) return null;\n if (!ids.includes(request.interruptId)) ids.push(request.interruptId);\n }\n return ids;\n}\n\n/** One decision for every lane — the `lane_decisions` map a run-wide approve or reject sends. */\nexport function fanLaneDecision<T>({\n interruptIds,\n decision,\n}: {\n interruptIds: readonly string[];\n decision: T;\n}): Record<string, T> {\n return Object.fromEntries(interruptIds.map((id) => [id, decision]));\n}\n\n/** The abandoned `interrupt` entry, if any — the \"approval was cancelled\" notice. */\nexport function findAbandonedInterrupt(\n abandoned: readonly AbandonedInputRequest[] | undefined,\n): AbandonedInputRequest | undefined {\n return abandoned?.find(\n (request) => isRecord(request) && request.type === 'interrupt' && typeof request.id === 'string',\n );\n}\n\n/** Canonical reason string carried by a user rejection. */\nexport const HITL_REJECT_REASON = 'User rejected the action.';\n\n/**\n * Default {@link UseApprovalResumeLockOptions.pendingResumeGraceMs} for every\n * approval surface: how long a clicked decision waits for its resume run to\n * start before the actions unlock again. Covers a `run/input` the host\n * rejected or a disconnected transport swallowed before any run began — the\n * one failure neither identity-change nor observed-run recovery can detect.\n */\nexport const HITL_PENDING_RESUME_GRACE_MS = 15_000;\n\n/**\n * Default {@link UseApprovalResumeLockOptions.maxTransportRetries}: how many\n * times a decision the transport lost (the websocket dropped or the statewire\n * session reset while the `run/input` was in flight) is re-sent on its own\n * before the user is asked to click again.\n */\nexport const HITL_RESUME_TRANSPORT_RETRIES = 3;\n\n/**\n * The dispatch died client-side without the host ever seeing it — a proven\n * session loss or a gone stream. Safe to re-send the same decision for the\n * same still-parked request. The complement (a server verdict, or the surface\n * unmounting) is not.\n */\nexport function isResumeTransportLoss(error: unknown): boolean {\n const outcome = statewireTransportOutcome(error);\n return outcome === 'session-lost' || outcome === 'stream-gone';\n}\n\n/** `run/input` resume value approving the gated call(s). */\nexport function hitlResumeApprove(): Record<string, string> {\n return { action: 'approve' };\n}\n\n/**\n * `run/input` resume value approving the gated call(s) AND every later call of\n * the same tool(s) on this thread. The backend records the tools from its own\n * parked interrupt (never from this payload), so the value carries no names.\n */\nexport function hitlResumeApproveForSession(): Record<string, string> {\n return { action: 'approve', scope: 'session' };\n}\n\n/** `run/input` resume value rejecting the gated call(s). */\nexport function hitlResumeReject(reason: string = HITL_REJECT_REASON): Record<string, string> {\n return { action: 'reject', reason };\n}\n\n/** One gated call's own answer inside a per-action resume ({@link hitlResumeActionDecisions}). */\nexport type HitlActionDecision =\n | { action: 'approve' }\n | { action: 'reject'; reason: string }\n | { action: 'edit'; edited_args: Record<string, unknown> };\n\n/**\n * The `tool_call_id` of every gated call, in decision order — or `null` when\n * any call lacks one or two calls share one, in which case no per-action\n * resume can be bound to the batch and only the batch answers above apply.\n */\nexport function actionRequestToolCallIds(\n actionRequests: readonly PendingActionRequest[],\n): string[] | null {\n if (actionRequests.length === 0) return null;\n const ids: string[] = [];\n for (const request of actionRequests) {\n if (request.toolCallId === undefined || ids.includes(request.toolCallId)) return null;\n ids.push(request.toolCallId);\n }\n return ids;\n}\n\n/**\n * `run/input` resume value deciding each gated call by its `tool_call_id` —\n * the only channel that carries an edited call. The backend binds every entry\n * to the parked request with that id, takes the tool NAME from its own\n * request (an edit can change a call's arguments, never which tool runs), and\n * refuses the whole answer — nothing runs — unless the map names exactly the\n * parked calls. `edited_args` is the complete argument set the call runs\n * with, not a patch. The envelope `action` mirrors the first entry for hosts\n * that only read the envelope; `action_decisions` is authoritative.\n */\nexport function hitlResumeActionDecisions(\n decisions: Readonly<Record<string, HitlActionDecision>>,\n): Record<string, unknown> {\n const [anchorId, anchor] = Object.entries(decisions)[0] ?? [];\n return {\n action: anchor?.action === 'reject' ? 'reject' : 'approve',\n ...(anchorId !== undefined && { tool_call_id: anchorId }),\n action_decisions: decisions,\n };\n}\n\n/** Canonical reason string carried by a user declining a non-HITL park. */\nexport const INTERRUPT_DECLINE_REASON = 'User declined the request.';\n\n/**\n * `run/input` resume value declining a non-HITL park. `{ action: 'reject' }`\n * is the one value every typed raiser treats as a clean user decline\n * (`FormCancelledError` / `ToolRejectedError`); a generic `continue` would be\n * rejected by their resume schemas and surface as a tool error the agent then\n * improvises around.\n */\nexport function interruptResumeDecline(\n reason: string = INTERRUPT_DECLINE_REASON,\n): Record<string, string> {\n return { action: 'reject', reason };\n}\n\nexport interface UseApprovalResumeLockOptions<TValue> {\n /** The pending interrupt's request id (`undefined` when nothing is parked). */\n requestId: string | undefined;\n /** The surface's thread `isRunning` read (mockable per surface). */\n isRunning: boolean;\n /**\n * Dispatch the `run/input` resume for `requestId` on the surface's transport.\n * Return the dispatch promise so a refused or lost command releases the lock\n * at once and reaches `onResumeRejected`; a `void` return leaves the\n * recovery paths below as the only release.\n */\n sendResume: (requestId: string, value: TValue) => void | Promise<unknown>;\n /**\n * The dispatch `sendResume` returned rejected — the host refused the\n * `run/input` or the transport lost it. The lock is already released when\n * this fires; the surface tells the user, since the request is back on\n * screen with nothing else saying why.\n */\n onResumeRejected?: (error: unknown, requestId: string) => void;\n /**\n * A dispatch the transport lost is being re-sent for the still-parked\n * request; `attempt` counts the retries so far (1-based). Diagnostics only —\n * the lock stays held across the retry.\n */\n onResumeRetry?: (error: unknown, requestId: string, attempt: number) => void;\n /**\n * Automatic re-sends of a decision the transport lost\n * ({@link isResumeTransportLoss}) while the request is still parked. `0`\n * disables retries. Defaults to {@link HITL_RESUME_TRANSPORT_RETRIES}.\n */\n maxTransportRetries?: number;\n /**\n * Re-enable the actions when no resume run started within this window —\n * covers a `run/input` that was rejected or lost before any run began, so\n * neither reset path below can fire. Omit to keep the pre-existing surface\n * behavior of staying locked until a resume run is observed.\n */\n pendingResumeGraceMs?: number;\n}\n\nexport interface ApprovalResumeLock<TValue> {\n /** True after a resume until the request identity changes (or recovery fires). */\n pending: boolean;\n /**\n * Send the resume value, locking the actions. No-op (returns `undefined`)\n * while pending or unparked. Returns the dispatch promise when `sendResume`\n * produced one, so a surface can hold its own state until the host settles.\n */\n resume: (value: TValue) => Promise<unknown> | undefined;\n}\n\n/**\n * Optimistic action lock shared by every approval surface: disable the\n * decision buttons the moment one is clicked, until the request identity\n * changes (it clears after the resume, or a fresh interrupt arrives). This\n * closes the double-click → duplicate-resume window.\n *\n * Recovery paths, in order of specificity:\n * 0. The dispatch itself rejected (a `sendResume` that returned a promise) —\n * released at once, and reported through `onResumeRejected`. A rejection\n * that is a transport loss (the socket dropped mid-flight) is re-sent up to\n * `maxTransportRetries` times first, the lock held throughout, so a flaky\n * connection does not hand the card back to the user for another click.\n * The returned promise settles with the final attempt.\n * 1. Identity change — the resume landed (or a new interrupt replaced the\n * request). Reset during render via React's \"previous value\" pattern.\n * 2. A resume run was observed starting and then settling with the request\n * still pending (failed/cancelled resume) — clear the lock so the user can\n * answer again.\n * 3. Optional grace window ({@link UseApprovalResumeLockOptions.pendingResumeGraceMs})\n * for a `run/input` that never started a run at all.\n */\nexport function useApprovalResumeLock<TValue = Record<string, string>>(\n options: UseApprovalResumeLockOptions<TValue>,\n): ApprovalResumeLock<TValue> {\n const {\n requestId,\n isRunning,\n sendResume,\n pendingResumeGraceMs,\n onResumeRejected,\n onResumeRetry,\n maxTransportRetries = HITL_RESUME_TRANSPORT_RETRIES,\n } = options;\n\n const [pending, setPending] = useState(false);\n // Bumped per re-send so the grace window restarts with each attempt.\n const [attempt, setAttempt] = useState(0);\n const prevRequestIdRef = useRef(requestId);\n if (prevRequestIdRef.current !== requestId) {\n prevRequestIdRef.current = requestId;\n if (pending) setPending(false);\n }\n\n // Track the resume run we kicked off (isRunning observed true→false while\n // pending) and clear `pending` when it ends with the request unresolved.\n const sawResumeRunRef = useRef(false);\n useEffect(() => {\n if (!pending) {\n sawResumeRunRef.current = false;\n return;\n }\n if (isRunning) {\n sawResumeRunRef.current = true;\n return;\n }\n if (sawResumeRunRef.current) {\n sawResumeRunRef.current = false;\n setPending(false);\n }\n }, [pending, isRunning]);\n\n // Pre-start failure recovery: re-enable after the grace window when no\n // resume run began; answering the still-parked request again is exactly\n // what the user needs to be able to do.\n useEffect(() => {\n if (!pending || pendingResumeGraceMs === undefined) return;\n const timer = setTimeout(() => {\n if (!sawResumeRunRef.current) setPending(false);\n }, pendingResumeGraceMs);\n return () => clearTimeout(timer);\n }, [pending, requestId, pendingResumeGraceMs, attempt]);\n\n const sendResumeRef = useRef(sendResume);\n sendResumeRef.current = sendResume;\n const onResumeRejectedRef = useRef(onResumeRejected);\n onResumeRejectedRef.current = onResumeRejected;\n const onResumeRetryRef = useRef(onResumeRetry);\n onResumeRetryRef.current = onResumeRetry;\n const maxTransportRetriesRef = useRef(maxTransportRetries);\n maxTransportRetriesRef.current = maxTransportRetries;\n const currentRequestIdRef = useRef(requestId);\n currentRequestIdRef.current = requestId;\n const pendingRef = useRef(pending);\n pendingRef.current = pending;\n // One token per `resume` call: a settle from an earlier submission must not\n // retry over, or release, a newer one for the same request.\n const submissionRef = useRef(0);\n\n const resume = useCallback(\n (value: TValue): Promise<unknown> | undefined => {\n if (requestId === undefined || pendingRef.current) return undefined;\n const submission = ++submissionRef.current;\n setPending(true);\n pendingRef.current = true;\n setAttempt(0);\n const first: unknown = sendResumeRef.current(requestId, value);\n if (!(first instanceof Promise)) return undefined;\n // The final failure is already reported through `onResumeRejected`;\n // callers that drop the promise must not get an unhandled rejection.\n const outcome = new Promise<unknown>((resolve, reject) => {\n const settle = (dispatched: Promise<unknown>, retries: number) => {\n dispatched.then(resolve, (error: unknown) => {\n // A late refusal for a request the lock has since moved past (the\n // park was re-keyed, or a newer answer is in flight) must neither\n // release that answer's lock nor be reported as a failure of it.\n // The optimistic fold hides the answered request until the fold\n // rolls back, so `undefined` here is not a departure.\n const current = currentRequestIdRef.current;\n if (\n submission !== submissionRef.current ||\n (current !== undefined && current !== requestId)\n ) {\n reject(error);\n return;\n }\n if (retries < maxTransportRetriesRef.current && isResumeTransportLoss(error)) {\n const next = retries + 1;\n onResumeRetryRef.current?.(error, requestId, next);\n setPending(true);\n pendingRef.current = true;\n setAttempt(next);\n const resent: unknown = sendResumeRef.current(requestId, value);\n if (resent instanceof Promise) {\n settle(resent, next);\n return;\n }\n resolve(undefined);\n return;\n }\n setPending(false);\n pendingRef.current = false;\n onResumeRejectedRef.current?.(error, requestId);\n reject(error);\n });\n };\n settle(first, 0);\n });\n outcome.catch(() => {});\n return outcome;\n },\n [requestId],\n );\n\n return { pending, resume };\n}\n"],"names":["hasClientToolInterruptSource","readDeepAgentStreamValues","statewireTransportOutcome","useState","useRef","useEffect","useCallback"],"mappings":";;;;;;AA2EA,SAAS,SAAS,OAAkD;AAClE,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAGO,SAAS,mBACd,SAC+C;AAC/C,SAAO,QAAQ,SAAS,eAAe,EAAE,cAAc;AACzD;AAQA,MAAM,wCAA6D,oBAAI,IAAI,CAAC,uBAAuB,CAAC;AAO7F,SAAS,uBAAuB,SAA2B;AAChE,MAAI,CAAC,SAAS,OAAO,EAAG,QAAO;AAC/B,MAAI,QAAQ,yBAAyB,MAAO,QAAO;AACnD,SACE,OAAO,QAAQ,WAAW,YAAY,sCAAsC,IAAI,QAAQ,MAAM;AAElG;AASO,SAAS,wBACd,SAC+C;AAC/C,MAAI,CAAC,mBAAmB,OAAO,EAAG,QAAO;AACzC,QAAM,UAAW,QAAkC;AACnD,SAAO,CAACA,YAAAA,6BAA6B,OAAO,KAAK,CAAC,uBAAuB,OAAO;AAClF;AAGO,SAAS,eAAe,OAA4C;AACzE,MAAI,CAAC,SAAS,KAAK,EAAG,QAAO;AAC7B,SAAO,MAAM,SAAS,UACpB,MAAM,WAAW,mBACjB,OAAO,MAAM,YAAY,WACtB,QACD;AACN;AAGO,MAAM,mCACX;AAGK,SAAS,qBACd,OACA,WAAmB,kCACX;AACR,MAAI,SAAS,KAAK,KAAK,OAAO,MAAM,YAAY,YAAY,MAAM,QAAQ,SAAS,GAAG;AACpF,WAAO,MAAM;AAAA,EACf;AACA,SAAO;AACT;AAwBA,MAAM,8BAA8B,oBAAI,IAAI,CAAC,QAAQ,WAAW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;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"interrupts.js","sources":["../../../../../agent-runtime/src/interrupts.ts"],"sourcesContent":["/**\n * Human-in-the-loop interrupt primitives shared by every statewire chat\n * surface (Olympus, the React SDK, the Office add-in, the Chrome extension,\n * mobile).\n *\n * The agora deep-agent runtime parks a gated run on an `interrupt` input\n * request whose payload carries the Athena `hitl_approval` shape\n * (`athena_deep_agent/hitl_bridge.py`). A surface answers it with\n * `{ type: 'run/input', requestId, response: { type: 'resume', value } }` —\n * the exact command the backend's resume path consumes. This module holds the\n * payload contract (narrowing, resume values) and the shared resume-lock state\n * machine; rendering stays with each surface.\n *\n * Deliberately parameterized rather than self-wiring: these helpers never call\n * `useStatewireRuns`/`useAuiState` themselves. Each surface reads its own\n * statewire hooks (which its tests already mock) and passes the values in, so\n * the shared semantics cannot drift while per-surface wiring stays testable.\n */\n\nimport type { StatewireThread } from '@assistant-ui/react-statewire';\nimport { useCallback, useEffect, useRef, useState } from 'react';\nimport { hasClientToolInterruptSource } from './client-tools';\nimport { statewireTransportOutcome } from './errors';\nimport { readDeepAgentStreamValues } from './statewire-state';\n\n/** Human-in-the-loop approval payload the agora deep-agent runtime parks a run\n * on (shaped by `athena_deep_agent/hitl_bridge.py`). */\nexport interface HitlApprovalPayload {\n source: string;\n type: string;\n message: string;\n /** Risk headline/facts/warnings, when the host includes them. */\n approval_context?: unknown;\n context?: {\n tool_name?: string;\n tool_id?: string;\n tool_call_id?: string;\n tool_args?: Record<string, unknown>;\n pending_action_count?: number;\n approval_context?: unknown;\n /**\n * Every pending gated call (name + args), in decision order. Absent on\n * older backends — fall back to the single `tool_name`/`tool_args` pair.\n * Per-dispatch payloads also carry each lane's `tool_call_id` (the lane\n * card key) and `interrupt_id` (the lane resume key).\n */\n action_requests?: {\n name?: string;\n args?: Record<string, unknown>;\n tool_call_id?: string;\n interrupt_id?: string;\n /**\n * True when \"approve all for this session\" would take effect for this\n * tool (the workspace allows overriding its approval). Absent on older\n * backends and on non-overridable tools: the option is not offered.\n */\n session_approval_allowed?: boolean;\n /**\n * The decision types the parked gate accepts for this call (`approve`,\n * `reject`, `edit`). Absent on older backends: only approve / reject\n * are known to be accepted.\n */\n allowed_decisions?: string[];\n /** What the backend resolved about this call before asking (display-only). */\n approval_context?: unknown;\n }[];\n /**\n * True when each dispatch parked on its own interrupt: decisions submit\n * per lane via `lane_decisions` and each approved lane starts immediately,\n * instead of the legacy batch where one resume must answer every lane.\n */\n per_dispatch?: boolean;\n };\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n/** A pending `interrupt` input request; a present `response` key marks it answered. */\nexport function isPendingInterrupt(\n request: StatewireThread.InputRequestState,\n): request is StatewireThread.CustomInputRequest {\n return request.type === 'interrupt' && !('response' in request);\n}\n\n/**\n * Interrupt sources that were system pauses before the host stamped\n * `requires_user_action: false` on them (a background deep-research wait). Kept\n * only for the deploy skew between an older agora and a newer client; delete\n * once every deployment's raiser stamps the flag.\n */\nconst LEGACY_SYSTEM_PAUSE_INTERRUPT_SOURCES: ReadonlySet<string> = new Set(['deep_research_pending']);\n\n/**\n * A park nobody answers: the agent is still working (a background research\n * wait) and the backend resumes it itself. The raiser stamps\n * `requires_user_action: false`; older raisers are recognised by source.\n */\nexport function isSystemPauseInterrupt(payload: unknown): boolean {\n if (!isRecord(payload)) return false;\n if (payload.requires_user_action === false) return true;\n return (\n typeof payload.source === 'string' && LEGACY_SYSTEM_PAUSE_INTERRUPT_SOURCES.has(payload.source)\n );\n}\n\n/**\n * A pending interrupt an approval card may answer. Two kinds are excluded —\n * client-tool parks (the client-tool bridge owns those, and a generic resume\n * would corrupt the parked tool call) and system pauses (nothing to answer; the\n * backend resumes them). The source checks are deliberately loose so a skewed\n * deploy can never route one here.\n */\nexport function isApprovalCardInterrupt(\n request: StatewireThread.InputRequestState,\n): request is StatewireThread.CustomInputRequest {\n if (!isPendingInterrupt(request)) return false;\n const payload = (request as { payload?: unknown }).payload;\n return !hasClientToolInterruptSource(payload) && !isSystemPauseInterrupt(payload);\n}\n\n/** Narrow an interrupt payload to the Athena HITL approval shape. */\nexport function asHitlApproval(value: unknown): HitlApprovalPayload | null {\n if (!isRecord(value)) return null;\n return value.type === 'hitl' &&\n value.source === 'hitl_approval' &&\n typeof value.message === 'string'\n ? (value as unknown as HitlApprovalPayload)\n : null;\n}\n\n/** Default paused-run copy when an interrupt payload carries no message. */\nexport const DEFAULT_INTERRUPT_PAUSED_MESSAGE =\n 'The agent is paused and waiting for input.';\n\n/** Best-effort human-readable message from any interrupt payload. */\nexport function readInterruptMessage(\n value: unknown,\n fallback: string = DEFAULT_INTERRUPT_PAUSED_MESSAGE,\n): string {\n if (isRecord(value) && typeof value.message === 'string' && value.message.length > 0) {\n return value.message;\n }\n return fallback;\n}\n\n/** One label/value row of a call's resolved approval facts. */\nexport interface PendingApprovalFact {\n label: string;\n value: string;\n}\n\n/** One caution of a call's resolved approval facts. */\nexport interface PendingApprovalWarning {\n severity: 'info' | 'warning' | 'critical';\n message: string;\n}\n\n/**\n * What the backend resolved about a gated call before asking — e.g. where a\n * Slack write goes and as whom (agora `services/interrupts/approval_context.py`).\n * Display-only; the decision still answers the parked call.\n */\nexport interface PendingApprovalContext {\n facts: PendingApprovalFact[];\n warnings: PendingApprovalWarning[];\n}\n\nconst APPROVAL_WARNING_SEVERITIES = new Set(['info', 'warning', 'critical']);\n\n/** A call's `approval_context`, or `undefined` when absent or empty. */\nexport function parsePendingApprovalContext(value: unknown): PendingApprovalContext | undefined {\n if (!isRecord(value)) return undefined;\n const facts: PendingApprovalFact[] = Array.isArray(value.facts)\n ? value.facts.flatMap((fact) =>\n isRecord(fact) && typeof fact.label === 'string' && typeof fact.value === 'string'\n ? [{ label: fact.label, value: fact.value }]\n : [],\n )\n : [];\n const warnings: PendingApprovalWarning[] = Array.isArray(value.warnings)\n ? value.warnings.flatMap((warning) => {\n if (!isRecord(warning) || typeof warning.message !== 'string') return [];\n const severity =\n typeof warning.severity === 'string' && APPROVAL_WARNING_SEVERITIES.has(warning.severity)\n ? (warning.severity as PendingApprovalWarning['severity'])\n : 'info';\n return [{ severity, message: warning.message }];\n })\n : [];\n return facts.length > 0 || warnings.length > 0 ? { facts, warnings } : undefined;\n}\n\nexport interface PendingActionRequest {\n name: string;\n args: Record<string, unknown>;\n /** The lane's `task` tool-call id (present on per-dispatch payloads). */\n toolCallId?: string;\n /** The lane's langgraph interrupt id — the `lane_decisions` resume key. */\n interruptId?: string;\n /** Present (true) when a session-wide approval would cover later calls of this tool. */\n sessionApprovalAllowed?: true;\n /** Present (true) when the gate accepts an `edit` decision for this call. */\n editAllowed?: true;\n /** Present when the backend resolved facts about this call before asking. */\n approvalContext?: PendingApprovalContext;\n}\n\n/**\n * Every gated call this approval covers, in decision order. One resume answers\n * ALL of them, so every entry must stay reviewable somewhere. Falls back to\n * the single first-call fields on older backends without `action_requests`.\n */\nexport function pendingActionRequests(hitl: HitlApprovalPayload | null): PendingActionRequest[] {\n const context = hitl?.context;\n if (!context) return [];\n // The payload crosses the wire with only its top-level shape narrowed\n // (`asHitlApproval`), so the nested collection must be validated before any\n // array/property access: a malformed host value must degrade to \"no\n // reviewable entries\", never crash the approval surface.\n const requests: Record<string, unknown>[] = Array.isArray(context.action_requests)\n ? context.action_requests.filter(isRecord)\n : context.tool_name && context.tool_args\n ? [{ name: context.tool_name, args: context.tool_args, tool_call_id: context.tool_call_id }]\n : [];\n return requests.map((request) => {\n const approvalContext = parsePendingApprovalContext(request.approval_context);\n return {\n name: typeof request.name === 'string' ? request.name : 'tool',\n args: isRecord(request.args) ? request.args : {},\n ...(typeof request.tool_call_id === 'string' && { toolCallId: request.tool_call_id }),\n ...(typeof request.interrupt_id === 'string' && { interruptId: request.interrupt_id }),\n ...(request.session_approval_allowed === true && { sessionApprovalAllowed: true }),\n ...(Array.isArray(request.allowed_decisions) &&\n request.allowed_decisions.includes('edit') && { editAllowed: true }),\n ...(approvalContext && { approvalContext }),\n };\n });\n}\n\n/**\n * Whether the card may offer \"approve all for this session\": every pending\n * call must be one the backend stamped as session-approvable, so a batch that\n * mixes in a tool the workspace pinned as always-prompt only offers the\n * one-time answer.\n */\nexport function canApproveForSession(actionRequests: readonly PendingActionRequest[]): boolean {\n return (\n actionRequests.length > 0 &&\n actionRequests.every((request) => request.sessionApprovalAllowed === true)\n );\n}\n\n/** An interrupt a non-resume dispatch dropped, published by the host. */\nexport interface AbandonedInputRequest {\n id: string;\n type: string;\n}\n\n/**\n * `useStatewireState` selector body for the host-published abandoned input\n * requests. Reads through {@link readDeepAgentStreamValues} so the selector is\n * safe on the pre-attach (`undefined`) wire state, and returns the raw array\n * reference so the subscription stays shallow-stable — derive (`.find`) on the\n * result, never inside the selector.\n */\nexport function readAbandonedInputRequests(\n state: unknown,\n): readonly AbandonedInputRequest[] | undefined {\n const abandoned = readDeepAgentStreamValues(state).abandonedInputRequests;\n // Wire value: anything non-array (including a malformed host publication)\n // reads as \"none\" rather than crashing the consuming surface. Identity-\n // preserving for the valid case, so it stays selector-safe.\n return Array.isArray(abandoned)\n ? (abandoned as readonly AbandonedInputRequest[])\n : undefined;\n}\n\n/**\n * `useStatewireState` selector body for the host's mirrored interrupt\n * (`__interrupt__`, the LangGraph `{value, resumable}` wrapper). The mirror\n * is published the moment a lane parks on its gate — while sibling lanes are\n * still streaming and the run manager has NOT yet published an answerable\n * input request. Raw reference, selector-safe; unwrap with\n * {@link interruptMirrorPayload}.\n */\nexport function readInterruptMirror(state: unknown): unknown {\n return readDeepAgentStreamValues(state).__interrupt__;\n}\n\n/** The payload of a mirrored interrupt wrapper, or `undefined` for anything else. */\nexport function interruptMirrorPayload(mirror: unknown): unknown {\n return isRecord(mirror) ? mirror.value : undefined;\n}\n\n/**\n * `useStatewireState` selector body for the per-dispatch lane decisions the\n * host accepted through `run/lane-input` while the run was still streaming\n * (`queuedLaneDecisions`, keyed by langgraph interrupt id). Held until the\n * run parks, then answered as a native `lane_decisions` resume; every attached\n * client reads a queued lane as decided. Raw reference, selector-safe.\n */\nexport function readQueuedLaneDecisions(\n state: unknown,\n): Readonly<Record<string, unknown>> | undefined {\n const queued = readDeepAgentStreamValues(state).queuedLaneDecisions;\n return isRecord(queued) ? queued : undefined;\n}\n\n/**\n * The distinct langgraph interrupt ids a `lane_decisions` resume answers for\n * these gated calls, in first-seen order — or `null` when any call lacks its\n * stamp (a legacy batch payload only a positional resume can answer). A\n * nested HITL request gating several calls contributes one id: the lane is\n * the interrupt, and one decision fans across its calls server-side.\n */\nexport function laneInterruptIds(actionRequests: readonly PendingActionRequest[]): string[] | null {\n if (actionRequests.length === 0) return null;\n const ids: string[] = [];\n for (const request of actionRequests) {\n if (request.interruptId === undefined) return null;\n if (!ids.includes(request.interruptId)) ids.push(request.interruptId);\n }\n return ids;\n}\n\n/** One decision for every lane — the `lane_decisions` map a run-wide approve or reject sends. */\nexport function fanLaneDecision<T>({\n interruptIds,\n decision,\n}: {\n interruptIds: readonly string[];\n decision: T;\n}): Record<string, T> {\n return Object.fromEntries(interruptIds.map((id) => [id, decision]));\n}\n\n/** The abandoned `interrupt` entry, if any — the \"approval was cancelled\" notice. */\nexport function findAbandonedInterrupt(\n abandoned: readonly AbandonedInputRequest[] | undefined,\n): AbandonedInputRequest | undefined {\n return abandoned?.find(\n (request) => isRecord(request) && request.type === 'interrupt' && typeof request.id === 'string',\n );\n}\n\n/** Canonical reason string carried by a user rejection. */\nexport const HITL_REJECT_REASON = 'User rejected the action.';\n\n/**\n * Default {@link UseApprovalResumeLockOptions.pendingResumeGraceMs} for every\n * approval surface: how long a clicked decision waits for its resume run to\n * start before the actions unlock again. Covers a `run/input` the host\n * rejected or a disconnected transport swallowed before any run began — the\n * one failure neither identity-change nor observed-run recovery can detect.\n */\nexport const HITL_PENDING_RESUME_GRACE_MS = 15_000;\n\n/**\n * Default {@link UseApprovalResumeLockOptions.maxTransportRetries}: how many\n * times a decision the transport lost (the websocket dropped or the statewire\n * session reset while the `run/input` was in flight) is re-sent on its own\n * before the user is asked to click again.\n */\nexport const HITL_RESUME_TRANSPORT_RETRIES = 3;\n\n/**\n * The dispatch died client-side without the host ever seeing it — a proven\n * session loss or a gone stream. Safe to re-send the same decision for the\n * same still-parked request. The complement (a server verdict, or the surface\n * unmounting) is not.\n */\nexport function isResumeTransportLoss(error: unknown): boolean {\n const outcome = statewireTransportOutcome(error);\n return outcome === 'session-lost' || outcome === 'stream-gone';\n}\n\n/** `run/input` resume value approving the gated call(s). */\nexport function hitlResumeApprove(): Record<string, string> {\n return { action: 'approve' };\n}\n\n/**\n * `run/input` resume value approving the gated call(s) AND every later call of\n * the same tool(s) on this thread. The backend records the tools from its own\n * parked interrupt (never from this payload), so the value carries no names.\n */\nexport function hitlResumeApproveForSession(): Record<string, string> {\n return { action: 'approve', scope: 'session' };\n}\n\n/** `run/input` resume value rejecting the gated call(s). */\nexport function hitlResumeReject(reason: string = HITL_REJECT_REASON): Record<string, string> {\n return { action: 'reject', reason };\n}\n\n/** One gated call's own answer inside a per-action resume ({@link hitlResumeActionDecisions}). */\nexport type HitlActionDecision =\n | { action: 'approve' }\n | { action: 'reject'; reason: string }\n | { action: 'edit'; edited_args: Record<string, unknown> };\n\n/**\n * The `tool_call_id` of every gated call, in decision order — or `null` when\n * any call lacks one or two calls share one, in which case no per-action\n * resume can be bound to the batch and only the batch answers above apply.\n */\nexport function actionRequestToolCallIds(\n actionRequests: readonly PendingActionRequest[],\n): string[] | null {\n if (actionRequests.length === 0) return null;\n const ids: string[] = [];\n for (const request of actionRequests) {\n if (request.toolCallId === undefined || ids.includes(request.toolCallId)) return null;\n ids.push(request.toolCallId);\n }\n return ids;\n}\n\n/**\n * `run/input` resume value deciding each gated call by its `tool_call_id` —\n * the only channel that carries an edited call. The backend binds every entry\n * to the parked request with that id, takes the tool NAME from its own\n * request (an edit can change a call's arguments, never which tool runs), and\n * refuses the whole answer — nothing runs — unless the map names exactly the\n * parked calls. `edited_args` is the complete argument set the call runs\n * with, not a patch. The envelope `action` mirrors the first entry for hosts\n * that only read the envelope; `action_decisions` is authoritative.\n */\nexport function hitlResumeActionDecisions(\n decisions: Readonly<Record<string, HitlActionDecision>>,\n): Record<string, unknown> {\n const [anchorId, anchor] = Object.entries(decisions)[0] ?? [];\n return {\n action: anchor?.action === 'reject' ? 'reject' : 'approve',\n ...(anchorId !== undefined && { tool_call_id: anchorId }),\n action_decisions: decisions,\n };\n}\n\n/** Canonical reason string carried by a user declining a non-HITL park. */\nexport const INTERRUPT_DECLINE_REASON = 'User declined the request.';\n\n/**\n * `run/input` resume value declining a non-HITL park. `{ action: 'reject' }`\n * is the one value every typed raiser treats as a clean user decline\n * (`FormCancelledError` / `ToolRejectedError`); a generic `continue` would be\n * rejected by their resume schemas and surface as a tool error the agent then\n * improvises around.\n */\nexport function interruptResumeDecline(\n reason: string = INTERRUPT_DECLINE_REASON,\n): Record<string, string> {\n return { action: 'reject', reason };\n}\n\nexport interface UseApprovalResumeLockOptions<TValue> {\n /** The pending interrupt's request id (`undefined` when nothing is parked). */\n requestId: string | undefined;\n /** The surface's thread `isRunning` read (mockable per surface). */\n isRunning: boolean;\n /**\n * Dispatch the `run/input` resume for `requestId` on the surface's transport.\n * Return the dispatch promise so a refused or lost command releases the lock\n * at once and reaches `onResumeRejected`; a `void` return leaves the\n * recovery paths below as the only release.\n */\n sendResume: (requestId: string, value: TValue) => void | Promise<unknown>;\n /**\n * The dispatch `sendResume` returned rejected — the host refused the\n * `run/input` or the transport lost it. The lock is already released when\n * this fires; the surface tells the user, since the request is back on\n * screen with nothing else saying why.\n */\n onResumeRejected?: (error: unknown, requestId: string) => void;\n /**\n * A dispatch the transport lost is being re-sent for the still-parked\n * request; `attempt` counts the retries so far (1-based). Diagnostics only —\n * the lock stays held across the retry.\n */\n onResumeRetry?: (error: unknown, requestId: string, attempt: number) => void;\n /**\n * Automatic re-sends of a decision the transport lost\n * ({@link isResumeTransportLoss}) while the request is still parked. `0`\n * disables retries. Defaults to {@link HITL_RESUME_TRANSPORT_RETRIES}.\n */\n maxTransportRetries?: number;\n /**\n * Re-enable the actions when no resume run started within this window —\n * covers a `run/input` that was rejected or lost before any run began, so\n * neither reset path below can fire. Omit to keep the pre-existing surface\n * behavior of staying locked until a resume run is observed.\n */\n pendingResumeGraceMs?: number;\n}\n\nexport interface ApprovalResumeLock<TValue> {\n /** True after a resume until the request identity changes (or recovery fires). */\n pending: boolean;\n /**\n * Send the resume value, locking the actions. No-op (returns `undefined`)\n * while pending or unparked. Returns the dispatch promise when `sendResume`\n * produced one, so a surface can hold its own state until the host settles.\n */\n resume: (value: TValue) => Promise<unknown> | undefined;\n}\n\n/**\n * Optimistic action lock shared by every approval surface: disable the\n * decision buttons the moment one is clicked, until the request identity\n * changes (it clears after the resume, or a fresh interrupt arrives). This\n * closes the double-click → duplicate-resume window.\n *\n * Recovery paths, in order of specificity:\n * 0. The dispatch itself rejected (a `sendResume` that returned a promise) —\n * released at once, and reported through `onResumeRejected`. A rejection\n * that is a transport loss (the socket dropped mid-flight) is re-sent up to\n * `maxTransportRetries` times first, the lock held throughout, so a flaky\n * connection does not hand the card back to the user for another click.\n * The returned promise settles with the final attempt.\n * 1. Identity change — the resume landed (or a new interrupt replaced the\n * request). Reset during render via React's \"previous value\" pattern.\n * 2. A resume run was observed starting and then settling with the request\n * still pending (failed/cancelled resume) — clear the lock so the user can\n * answer again.\n * 3. Optional grace window ({@link UseApprovalResumeLockOptions.pendingResumeGraceMs})\n * for a `run/input` that never started a run at all.\n */\nexport function useApprovalResumeLock<TValue = Record<string, string>>(\n options: UseApprovalResumeLockOptions<TValue>,\n): ApprovalResumeLock<TValue> {\n const {\n requestId,\n isRunning,\n sendResume,\n pendingResumeGraceMs,\n onResumeRejected,\n onResumeRetry,\n maxTransportRetries = HITL_RESUME_TRANSPORT_RETRIES,\n } = options;\n\n const [pending, setPending] = useState(false);\n // Bumped per re-send so the grace window restarts with each attempt.\n const [attempt, setAttempt] = useState(0);\n const prevRequestIdRef = useRef(requestId);\n if (prevRequestIdRef.current !== requestId) {\n prevRequestIdRef.current = requestId;\n if (pending) setPending(false);\n }\n\n // Track the resume run we kicked off (isRunning observed true→false while\n // pending) and clear `pending` when it ends with the request unresolved.\n const sawResumeRunRef = useRef(false);\n useEffect(() => {\n if (!pending) {\n sawResumeRunRef.current = false;\n return;\n }\n if (isRunning) {\n sawResumeRunRef.current = true;\n return;\n }\n if (sawResumeRunRef.current) {\n sawResumeRunRef.current = false;\n setPending(false);\n }\n }, [pending, isRunning]);\n\n // Pre-start failure recovery: re-enable after the grace window when no\n // resume run began; answering the still-parked request again is exactly\n // what the user needs to be able to do.\n useEffect(() => {\n if (!pending || pendingResumeGraceMs === undefined) return;\n const timer = setTimeout(() => {\n if (!sawResumeRunRef.current) setPending(false);\n }, pendingResumeGraceMs);\n return () => clearTimeout(timer);\n }, [pending, requestId, pendingResumeGraceMs, attempt]);\n\n const sendResumeRef = useRef(sendResume);\n sendResumeRef.current = sendResume;\n const onResumeRejectedRef = useRef(onResumeRejected);\n onResumeRejectedRef.current = onResumeRejected;\n const onResumeRetryRef = useRef(onResumeRetry);\n onResumeRetryRef.current = onResumeRetry;\n const maxTransportRetriesRef = useRef(maxTransportRetries);\n maxTransportRetriesRef.current = maxTransportRetries;\n const currentRequestIdRef = useRef(requestId);\n currentRequestIdRef.current = requestId;\n const pendingRef = useRef(pending);\n pendingRef.current = pending;\n // One token per `resume` call: a settle from an earlier submission must not\n // retry over, or release, a newer one for the same request.\n const submissionRef = useRef(0);\n\n const resume = useCallback(\n (value: TValue): Promise<unknown> | undefined => {\n if (requestId === undefined || pendingRef.current) return undefined;\n const submission = ++submissionRef.current;\n setPending(true);\n pendingRef.current = true;\n setAttempt(0);\n const first: unknown = sendResumeRef.current(requestId, value);\n if (!(first instanceof Promise)) return undefined;\n // The final failure is already reported through `onResumeRejected`;\n // callers that drop the promise must not get an unhandled rejection.\n const outcome = new Promise<unknown>((resolve, reject) => {\n const settle = (dispatched: Promise<unknown>, retries: number) => {\n dispatched.then(resolve, (error: unknown) => {\n // A late refusal for a request the lock has since moved past (the\n // park was re-keyed, or a newer answer is in flight) must neither\n // release that answer's lock nor be reported as a failure of it.\n // The optimistic fold hides the answered request until the fold\n // rolls back, so `undefined` here is not a departure.\n const current = currentRequestIdRef.current;\n if (\n submission !== submissionRef.current ||\n (current !== undefined && current !== requestId)\n ) {\n reject(error);\n return;\n }\n if (retries < maxTransportRetriesRef.current && isResumeTransportLoss(error)) {\n const next = retries + 1;\n onResumeRetryRef.current?.(error, requestId, next);\n setPending(true);\n pendingRef.current = true;\n setAttempt(next);\n const resent: unknown = sendResumeRef.current(requestId, value);\n if (resent instanceof Promise) {\n settle(resent, next);\n return;\n }\n resolve(undefined);\n return;\n }\n setPending(false);\n pendingRef.current = false;\n onResumeRejectedRef.current?.(error, requestId);\n reject(error);\n });\n };\n settle(first, 0);\n });\n outcome.catch(() => {});\n return outcome;\n },\n [requestId],\n );\n\n return { pending, resume };\n}\n"],"names":[],"mappings":";;;;AA2EA,SAAS,SAAS,OAAkD;AAClE,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAGO,SAAS,mBACd,SAC+C;AAC/C,SAAO,QAAQ,SAAS,eAAe,EAAE,cAAc;AACzD;AAQA,MAAM,wCAA6D,oBAAI,IAAI,CAAC,uBAAuB,CAAC;AAO7F,SAAS,uBAAuB,SAA2B;AAChE,MAAI,CAAC,SAAS,OAAO,EAAG,QAAO;AAC/B,MAAI,QAAQ,yBAAyB,MAAO,QAAO;AACnD,SACE,OAAO,QAAQ,WAAW,YAAY,sCAAsC,IAAI,QAAQ,MAAM;AAElG;AASO,SAAS,wBACd,SAC+C;AAC/C,MAAI,CAAC,mBAAmB,OAAO,EAAG,QAAO;AACzC,QAAM,UAAW,QAAkC;AACnD,SAAO,CAAC,6BAA6B,OAAO,KAAK,CAAC,uBAAuB,OAAO;AAClF;AAGO,SAAS,eAAe,OAA4C;AACzE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d,CAAC;AAAA,QACH;AACA,eAAO,OAAO,CAAC;AAAA,MACjB,CAAC;AACD,cAAQ,MAAM,MAAM;AAAA,MAAC,CAAC;AACtB,aAAO;AAAA,IACT;AAAA,IACA,CAAC,SAAS;AAAA,EAAA;AAGZ,SAAO,EAAE,SAAS,OAAA;AACpB;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"message-author.cjs","sources":["../../../../../agent-runtime/src/message-author.ts"],"sourcesContent":["import type { StatewireThread } from '@assistant-ui/react-statewire';\n\n/**\n * `metadata.custom` key carrying who sent a human turn.\n *\n * The backend stamps it on every persisted human turn from the authenticated\n * sender (`agora/.../message_author.py`), and on the host `meta` of every\n * run-lane entry it admits (`statewire_host._op_meta`), so a queued or\n * just-sent bubble is attributable before the turn is materialised — on every\n * client on the thread, not only the sender's.\n */\nexport const ATHENA_MESSAGE_AUTHOR_KEY = 'author';\n\n/** Identity of the human who sent a message, as the backend stamps it. */\nexport interface DeepAgentMessageAuthor {\n user_id: string;\n name: string | null;\n email: string | null;\n avatar_url: string | null;\n}\n\nconst optionalString = (value: unknown): string | null =>\n typeof value === 'string' && value.length > 0 ? value : null;\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\n/**\n * Parse an author envelope off a wire value.\n *\n * Tolerates absent optional fields (a principal without a name or picture);\n * an envelope without a string `user_id` is no author at all — an\n * identity-less stamp would only mislead the gate that decides whether a\n * transcript has several human participants.\n */\nexport function readMessageAuthor(value: unknown): DeepAgentMessageAuthor | null {\n if (!isRecord(value)) return null;\n const userId = value.user_id;\n if (typeof userId !== 'string' || userId.length === 0) return null;\n return {\n user_id: userId,\n name: optionalString(value.name),\n email: optionalString(value.email),\n avatar_url: optionalString(value.avatar_url),\n };\n}\n\n/** Field-wise equality, so hosts can hold a stable identity across renders. */\nexport function isSameMessageAuthor(\n a: DeepAgentMessageAuthor | null,\n b: DeepAgentMessageAuthor | null\n): boolean {\n if (a === b) return true;\n if (a === null || b === null) return false;\n return (\n a.user_id === b.user_id &&\n a.name === b.name &&\n a.email === b.email &&\n a.avatar_url === b.avatar_url\n );\n}\n\n/**\n * Who sent a run-lane entry, for its optimistic bubble.\n *\n * Only two sources are trusted. The host stamps `meta` on every entry it\n * admits, so `meta.author` is the server's word on the submitter and is what\n * every OTHER client on the thread renders. An entry with no `meta` at all is\n * this client's own optimistic fold — the send is still in flight — so it is\n * the viewer's (`selfAuthor`), matching what the host stamps on\n * acknowledgment. The entry's client-supplied `metadata` is never consulted:\n * a client that could set it could attribute its words to another\n * collaborator. A host-stamped entry without an author (a host predating the\n * stamp) yields none, so the surface falls back to its own attribution rule.\n */\nexport function laneEntryAuthor(\n entry: StatewireThread.RunsQueueEntry,\n selfAuthor: DeepAgentMessageAuthor | null | undefined\n): DeepAgentMessageAuthor | null {\n if (entry.meta === undefined) return selfAuthor ?? null;\n if (!isRecord(entry.meta)) return null;\n return readMessageAuthor(entry.meta[ATHENA_MESSAGE_AUTHOR_KEY]);\n}\n"],"names":[],"mappings":";;AAWO,MAAM,4BAA4B;AAUzC,MAAM,iBAAiB,CAAC,UACtB,OAAO,UAAU,YAAY,MAAM,SAAS,IAAI,QAAQ;AAE1D,MAAM,WAAW,CAAC,UAChB,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAU9D,SAAS,kBAAkB,OAA+C;AAC/E,MAAI,CAAC,SAAS,KAAK,EAAG,QAAO;AAC7B,QAAM,SAAS,MAAM;AACrB,MAAI,OAAO,WAAW,YAAY,OAAO,WAAW,EAAG,QAAO;AAC9D,SAAO;AAAA,IACL,SAAS;AAAA,IACT,MAAM,eAAe,MAAM,IAAI;AAAA,IAC/B,OAAO,eAAe,MAAM,KAAK;AAAA,IACjC,YAAY,eAAe,MAAM,UAAU;AAAA,EAAA;AAE/C;AAGO,SAAS,oBACd,GACA,GACS;AACT,MAAI,MAAM,EAAG,QAAO;AACpB,MAAI,MAAM,QAAQ,MAAM,KAAM,QAAO;AACrC,SACE,EAAE,YAAY,EAAE,WAChB,EAAE,SAAS,EAAE,QACb,EAAE,UAAU,EAAE,SACd,EAAE,eAAe,EAAE;AAEvB;AAeO,SAAS,gBACd,OACA,YAC+B;AAC/B,MAAI,MAAM,SAAS,OAAW,QAAO,cAAc;AACnD,MAAI,CAAC,SAAS,MAAM,IAAI,EAAG,QAAO;AAClC,SAAO,kBAAkB,MAAM,KAAK,yBAAyB,CAAC;AAChE;;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"message-author.js","sources":["../../../../../agent-runtime/src/message-author.ts"],"sourcesContent":["import type { StatewireThread } from '@assistant-ui/react-statewire';\n\n/**\n * `metadata.custom` key carrying who sent a human turn.\n *\n * The backend stamps it on every persisted human turn from the authenticated\n * sender (`agora/.../message_author.py`), and on the host `meta` of every\n * run-lane entry it admits (`statewire_host._op_meta`), so a queued or\n * just-sent bubble is attributable before the turn is materialised — on every\n * client on the thread, not only the sender's.\n */\nexport const ATHENA_MESSAGE_AUTHOR_KEY = 'author';\n\n/** Identity of the human who sent a message, as the backend stamps it. */\nexport interface DeepAgentMessageAuthor {\n user_id: string;\n name: string | null;\n email: string | null;\n avatar_url: string | null;\n}\n\nconst optionalString = (value: unknown): string | null =>\n typeof value === 'string' && value.length > 0 ? value : null;\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\n/**\n * Parse an author envelope off a wire value.\n *\n * Tolerates absent optional fields (a principal without a name or picture);\n * an envelope without a string `user_id` is no author at all — an\n * identity-less stamp would only mislead the gate that decides whether a\n * transcript has several human participants.\n */\nexport function readMessageAuthor(value: unknown): DeepAgentMessageAuthor | null {\n if (!isRecord(value)) return null;\n const userId = value.user_id;\n if (typeof userId !== 'string' || userId.length === 0) return null;\n return {\n user_id: userId,\n name: optionalString(value.name),\n email: optionalString(value.email),\n avatar_url: optionalString(value.avatar_url),\n };\n}\n\n/** Field-wise equality, so hosts can hold a stable identity across renders. */\nexport function isSameMessageAuthor(\n a: DeepAgentMessageAuthor | null,\n b: DeepAgentMessageAuthor | null\n): boolean {\n if (a === b) return true;\n if (a === null || b === null) return false;\n return (\n a.user_id === b.user_id &&\n a.name === b.name &&\n a.email === b.email &&\n a.avatar_url === b.avatar_url\n );\n}\n\n/**\n * Who sent a run-lane entry, for its optimistic bubble.\n *\n * Only two sources are trusted. The host stamps `meta` on every entry it\n * admits, so `meta.author` is the server's word on the submitter and is what\n * every OTHER client on the thread renders. An entry with no `meta` at all is\n * this client's own optimistic fold — the send is still in flight — so it is\n * the viewer's (`selfAuthor`), matching what the host stamps on\n * acknowledgment. The entry's client-supplied `metadata` is never consulted:\n * a client that could set it could attribute its words to another\n * collaborator. A host-stamped entry without an author (a host predating the\n * stamp) yields none, so the surface falls back to its own attribution rule.\n */\nexport function laneEntryAuthor(\n entry: StatewireThread.RunsQueueEntry,\n selfAuthor: DeepAgentMessageAuthor | null | undefined\n): DeepAgentMessageAuthor | null {\n if (entry.meta === undefined) return selfAuthor ?? null;\n if (!isRecord(entry.meta)) return null;\n return readMessageAuthor(entry.meta[ATHENA_MESSAGE_AUTHOR_KEY]);\n}\n"],"names":[],"mappings":"AAWO,MAAM,4BAA4B;AAUzC,MAAM,iBAAiB,CAAC,UACtB,OAAO,UAAU,YAAY,MAAM,SAAS,IAAI,QAAQ;AAE1D,MAAM,WAAW,CAAC,UAChB,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAU9D,SAAS,kBAAkB,OAA+C;AAC/E,MAAI,CAAC,SAAS,KAAK,EAAG,QAAO;AAC7B,QAAM,SAAS,MAAM;AACrB,MAAI,OAAO,WAAW,YAAY,OAAO,WAAW,EAAG,QAAO;AAC9D,SAAO;AAAA,IACL,SAAS;AAAA,IACT,MAAM,eAAe,MAAM,IAAI;AAAA,IAC/B,OAAO,eAAe,MAAM,KAAK;AAAA,IACjC,YAAY,eAAe,MAAM,UAAU;AAAA,EAAA;AAE/C;AAGO,SAAS,oBACd,GACA,GACS;AACT,MAAI,MAAM,EAAG,QAAO;AACpB,MAAI,MAAM,QAAQ,MAAM,KAAM,QAAO;AACrC,SACE,EAAE,YAAY,EAAE,WAChB,EAAE,SAAS,EAAE,QACb,EAAE,UAAU,EAAE,SACd,EAAE,eAAe,EAAE;AAEvB;AAeO,SAAS,gBACd,OACA,YAC+B;AAC/B,MAAI,MAAM,SAAS,OAAW,QAAO,cAAc;AACnD,MAAI,CAAC,SAAS,MAAM,IAAI,EAAG,QAAO;AAClC,SAAO,kBAAkB,MAAM,KAAK,yBAAyB,CAAC;AAChE;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"message-window.cjs","sources":["../../../../../agent-runtime/src/message-window.ts"],"sourcesContent":["import type { LangChainMessage } from '@assistant-ui/react-langgraph';\nimport type { StatewireDocuments } from 'statewire';\nimport {\n DEEP_AGENT_DEFAULT_MESSAGE_WINDOW,\n DEEP_AGENT_HISTORY_MESSAGE_COMMAND,\n DEEP_AGENT_HISTORY_TOOL_OUTPUT_COMMAND,\n DEEP_AGENT_INTEREST_PROTOCOL,\n DEEP_AGENT_MAIN_NS,\n DEEP_AGENT_MAX_INTERESTS,\n DEEP_AGENT_MAX_MESSAGE_WINDOW,\n DEEP_AGENT_MESSAGE_WINDOW_HEADER,\n DEEP_AGENT_MIN_MESSAGE_WINDOW,\n DEEP_AGENT_TRUNCATED_CONTENT_KEY,\n} from './generated/runconfig-contract';\nimport { DEEP_AGENT_STATEWIRE_PROTOCOL } from './statewire-transport';\n\n/**\n * The interest window — the client half of agora's\n * `agora/graphs/athena_deep_agent/message_window.py`.\n *\n * The wire main document carries no `messages`. A client states its interests\n * on the `athena/interest` lane as one array (`set(requests)`): the first is\n * the head (the newest `before` messages of the `main` namespace), the rest\n * are pages anchored `at` the first message of the window they extend. The\n * host holds one ephemeral main document per attach, `{ windows }`, one\n * resolution per request in order (the request echoed plus the covered\n * `chain` and `more` flags; an anchor that vanished leaves an empty window in\n * place), and one shared `athena` document per covered message, keyed\n * `[threadId, \"main\", messageId]`. {@link readDeepAgentMessageWindow} joins\n * them into the transcript the converter renders.\n *\n * Two host rules shape the client half. The head window never drops below\n * the oldest message it has carried on an attach (a run's appends grow the\n * view, nothing loaded slides out), so a page stays anchored at the head's\n * first message while the transcript grows; and the host remembers a client\n * id's interests across its attaches, so a reconnect's hello carries the\n * view the client held. A fresh client's hello carries the head it declared\n * on the attach headers ({@link withDeclaredMessageWindow}) — a statement\n * cannot ride the first attach, the hello negotiates the lanes.\n *\n * Pages are appended one per load until the host's interest cap, then the\n * loaded range is restated in as few maximal requests as it takes\n * ({@link pageInterestRequests}); the whole transcript stays reachable up to\n * `MAX_INTERESTS × MAX_MESSAGE_WINDOW` messages. A truncated tool output\n * comes back whole through `history/tool_output` ({@link buildToolOutputCommand});\n * a message's stored form — provenance blobs and all — through\n * `history/message` ({@link buildHistoryMessageCommand}).\n */\n\nconst isIndex = (value: unknown): value is number =>\n typeof value === 'number' && Number.isInteger(value) && value >= 0;\n\n/** What a surface declares for its window: the interest size (the host clamps to its bounds). */\nexport interface DeepAgentMessageWindowDeclaration {\n size?: number;\n}\n\nexport function clampMessageWindowSize(size?: number): number {\n if (size === undefined || !Number.isFinite(size)) return DEEP_AGENT_DEFAULT_MESSAGE_WINDOW;\n return Math.max(\n DEEP_AGENT_MIN_MESSAGE_WINDOW,\n Math.min(DEEP_AGENT_MAX_MESSAGE_WINDOW, Math.trunc(size))\n );\n}\n\n/** An `athena/interest` request over the linear transcript. */\nexport interface DeepAgentInterestRequest {\n readonly ns: typeof DEEP_AGENT_MAIN_NS;\n /** Messages ending at the anchor (the tail without `at`). */\n readonly before: number;\n /** Anchor message id; a page's is the first message of the window it extends. */\n readonly at?: string;\n /** Messages past the anchor (requires `at`). */\n readonly after?: number;\n}\n\nexport function headInterestRequest(size?: number): DeepAgentInterestRequest {\n return { ns: DEEP_AGENT_MAIN_NS, before: clampMessageWindowSize(size) };\n}\n\nexport function pageInterestRequest(at: string, size?: number): DeepAgentInterestRequest {\n return { ns: DEEP_AGENT_MAIN_NS, before: clampMessageWindowSize(size), at };\n}\n\n/**\n * Attach headers with the head window declared (`x-athena-deep-agent-window`):\n * the hello of a client the host does not remember carries the newest `size`\n * messages. Part of the one attach recipe, so a pooled dial asks for the shape\n * the thread's own attach would. An explicit entry (tests, overrides) wins.\n */\nexport function withDeclaredMessageWindow(\n headers: Record<string, string>,\n declaration: DeepAgentMessageWindowDeclaration = {}\n): Record<string, string> {\n if (DEEP_AGENT_MESSAGE_WINDOW_HEADER in headers) return headers;\n return {\n ...headers,\n [DEEP_AGENT_MESSAGE_WINDOW_HEADER]: String(clampMessageWindowSize(declaration.size)),\n };\n}\n\nexport interface DeepAgentInterestChainEntry {\n id: string;\n siblings: string[];\n}\n\n/** The host's resolution document of one interest: the request echoed plus its coverage. */\nexport interface DeepAgentInterestResolution extends DeepAgentInterestRequest {\n /** Covered message ids, oldest first (a page ends at its anchor). */\n chain: DeepAgentInterestChainEntry[];\n more: { before: boolean; after: boolean };\n}\n\nexport function readDeepAgentInterestResolution(value: unknown): DeepAgentInterestResolution | null {\n if (typeof value !== 'object' || value === null) return null;\n const { ns, before, at, after, chain, more } = value as Record<string, unknown>;\n if (ns !== DEEP_AGENT_MAIN_NS || !isIndex(before) || !Array.isArray(chain)) return null;\n if (at !== undefined && typeof at !== 'string') return null;\n if (after !== undefined && !isIndex(after)) return null;\n if (typeof more !== 'object' || more === null) return null;\n const { before: moreBefore, after: moreAfter } = more as Record<string, unknown>;\n if (typeof moreBefore !== 'boolean' || typeof moreAfter !== 'boolean') return null;\n const entries: DeepAgentInterestChainEntry[] = [];\n for (const entry of chain) {\n const { id, siblings } = (entry ?? {}) as Record<string, unknown>;\n if (typeof id !== 'string') return null;\n entries.push({\n id,\n siblings: Array.isArray(siblings) ? siblings.filter((s) => typeof s === 'string') : [id],\n });\n }\n return {\n ns: DEEP_AGENT_MAIN_NS,\n before,\n ...(at !== undefined && { at }),\n ...(after !== undefined && { after }),\n chain: entries,\n more: { before: moreBefore, after: moreAfter },\n };\n}\n\n/** The attach's interest document: one resolution per stated request, in order. */\nexport interface DeepAgentInterestDocument {\n windows: DeepAgentInterestResolution[];\n}\n\nexport function readDeepAgentInterestDocument(value: unknown): DeepAgentInterestDocument | null {\n if (typeof value !== 'object' || value === null) return null;\n const { windows } = value as Record<string, unknown>;\n if (!Array.isArray(windows)) return null;\n const resolutions: DeepAgentInterestResolution[] = [];\n for (const window of windows) {\n const resolution = readDeepAgentInterestResolution(window);\n if (resolution === null) return null;\n resolutions.push(resolution);\n }\n return { windows: resolutions };\n}\n\nconst interestRequest = ({ ns, before, at, after }: DeepAgentInterestRequest): DeepAgentInterestRequest => ({\n ns,\n before,\n ...(at !== undefined && { at }),\n ...(after !== undefined && { after }),\n});\n\n/** The loaded transcript window, joined from the head interest and its anchored pages. */\nexport interface DeepAgentMessageWindow {\n /** The requests the joined view stands on, in order (the head first): what a `set` restates. A stale page (its anchor gone) or one the head already covers is left out. */\n requests: DeepAgentInterestRequest[];\n /** Covered chain, oldest first. */\n chain: DeepAgentInterestChainEntry[];\n /** The chain's message documents, in chain order (an unmounted one is skipped). */\n messages: LangChainMessage[];\n /** Whether the host holds messages older than the window. */\n hasOlder: boolean;\n /** Pages joined onto the head. */\n pages: number;\n}\n\n/**\n * The loaded chain plus `grow` older messages, restated in as few requests as\n * it takes: a maximal head, then maximal pages each anchored at the first\n * message of the window above it. `null` once even that exceeds the host's\n * interest cap — the reachable depth is `MAX_INTERESTS × MAX_MESSAGE_WINDOW`.\n */\nfunction coalescedInterestRequests(\n chain: readonly DeepAgentInterestChainEntry[],\n grow: number\n): DeepAgentInterestRequest[] | null {\n const loaded = chain.length;\n const requests: DeepAgentInterestRequest[] = [\n { ns: DEEP_AGENT_MAIN_NS, before: Math.min(DEEP_AGENT_MAX_MESSAGE_WINDOW, loaded) },\n ];\n // `low` is the chain index of the lowest message the plan covers so far.\n let low = loaded - (requests[0] as DeepAgentInterestRequest).before;\n while (low > 0) {\n const before = Math.min(DEEP_AGENT_MAX_MESSAGE_WINDOW, low + 1);\n requests.push({\n ns: DEEP_AGENT_MAIN_NS,\n before,\n at: (chain[low] as DeepAgentInterestChainEntry).id,\n });\n low = low + 1 - before;\n }\n // The plan covers the chain; the new messages extend its lowest request\n // when that stays within one window, else they are a page of their own.\n const last = requests[requests.length - 1] as DeepAgentInterestRequest;\n if (last.before + grow <= DEEP_AGENT_MAX_MESSAGE_WINDOW) {\n requests[requests.length - 1] = { ...last, before: last.before + grow };\n } else {\n requests.push({\n ns: DEEP_AGENT_MAIN_NS,\n before: grow + 1,\n at: (chain[0] as DeepAgentInterestChainEntry).id,\n });\n }\n return requests.length > DEEP_AGENT_MAX_INTERESTS ? null : requests;\n}\n\n/**\n * The requests to state for one more page of older history, or `null` when\n * there is nothing to load (no anchor, the beginning reached) or the host's\n * interest cap is spent. One page is appended, anchored at the window's first\n * message, while the cap allows; at the cap the loaded range is coalesced\n * into maximal requests first (see {@link coalescedInterestRequests}).\n */\nexport function pageInterestRequests(\n window: DeepAgentMessageWindow,\n size?: number\n): DeepAgentInterestRequest[] | null {\n const anchor = window.chain[0]?.id;\n if (anchor === undefined || !window.hasOlder) return null;\n const page = pageInterestRequest(anchor, size);\n const appended = [...window.requests, page];\n if (appended.length <= DEEP_AGENT_MAX_INTERESTS) return appended;\n // A page's `before` counts its anchor: it adds `before - 1` older messages.\n return coalescedInterestRequests(window.chain, page.before - 1);\n}\n\n/**\n * Whether every `stated` request is carried by `carried` (the same anchor, at\n * least as wide): a reconnect's hello that carries what the client last\n * stated — the host remembers a client id's interests — needs no restatement.\n */\nexport function interestsCovered(\n carried: readonly DeepAgentInterestRequest[],\n stated: readonly DeepAgentInterestRequest[]\n): boolean {\n return stated.every((request) =>\n carried.some((have) => have.at === request.at && have.before >= request.before)\n );\n}\n\n/**\n * The window off the mounted documents, or `null` while the head interest has\n * not resolved (pre-attach, before the first `set` answer, a wire without\n * documents). A page joins wherever its anchor sits in the chain so far — at\n * the first message it extends the view, inside the head (the head widened\n * past it) it adds nothing and is left out of `requests`; a page whose anchor\n * left the transcript (a rewind emptied it in place) is left out too. A\n * malformed document reads as absent.\n */\nexport function readDeepAgentMessageWindow(\n mounted: ReadonlyMap<number, StatewireDocuments.Document> | undefined\n): DeepAgentMessageWindow | null {\n if (mounted === undefined) return null;\n let windows: DeepAgentInterestResolution[] | undefined;\n const documents = new Map<string, LangChainMessage>();\n for (const document of mounted.values()) {\n const key = document.key;\n if (document.protocol === DEEP_AGENT_INTEREST_PROTOCOL && document.main === true) {\n windows = readDeepAgentInterestDocument(document.value)?.windows;\n } else if (\n document.protocol === DEEP_AGENT_STATEWIRE_PROTOCOL &&\n key !== null &&\n key.length === 3 &&\n key[1] === DEEP_AGENT_MAIN_NS\n ) {\n documents.set(key[2] as string, document.value as LangChainMessage);\n }\n }\n const head = windows?.[0];\n if (windows === undefined || head === undefined) return null;\n let chain = head.chain;\n let hasOlder = head.more.before;\n const requests = [interestRequest(head)];\n const loaded = new Set(chain.map((entry) => entry.id));\n let pages = 0;\n for (const page of windows.slice(1)) {\n if (page.at === undefined || !loaded.has(page.at)) continue;\n const anchorAt = page.chain.findIndex((entry) => entry.id === page.at);\n if (anchorAt < 0) continue;\n // Both windows are ranges of one linear transcript sharing the anchor:\n // what the page holds below it and the chain does not is a prefix.\n const fresh = page.chain.slice(0, anchorAt).filter((entry) => !loaded.has(entry.id));\n if (fresh.length === 0) {\n // Nothing new, but a page that starts where the loaded chain starts\n // has looked below it: its `more.before` is the answer for the edge.\n if (page.chain[0]?.id === chain[0]?.id) hasOlder = page.more.before;\n continue;\n }\n chain = [...fresh, ...chain];\n for (const entry of fresh) loaded.add(entry.id);\n hasOlder = page.more.before;\n requests.push(interestRequest(page));\n pages += 1;\n }\n const messages: LangChainMessage[] = [];\n for (const entry of chain) {\n const message = documents.get(entry.id);\n if (message !== undefined) messages.push(message);\n }\n return { requests, chain, messages, hasOlder, pages };\n}\n\n/**\n * The windowed wire's read command on the statewire command union, so\n * `sendCommand({ type: 'history/tool_output', … })` typechecks wherever the\n * deep-agent host is driven (`DeepAgentThread.history_tool_output`, an\n * attach-ACL read).\n */\ndeclare module '@assistant-ui/core' {\n namespace Assistant {\n interface Commands {\n /** A tool output the windowed wire carried cut, whole. */\n historyToolOutput: ToolOutputCommand;\n /** One stored message whole — the per-client shape, by command. */\n historyMessage: HistoryMessageCommand;\n }\n }\n}\n\n/** The `history/tool_output` command: a truncated tool output, whole. */\nexport interface ToolOutputCommand {\n readonly type: typeof DEEP_AGENT_HISTORY_TOOL_OUTPUT_COMMAND;\n readonly messageId: string;\n}\n\nexport function buildToolOutputCommand({ messageId }: { messageId: string }): ToolOutputCommand {\n return { type: DEEP_AGENT_HISTORY_TOOL_OUTPUT_COMMAND, messageId };\n}\n\nexport interface ToolOutputResult {\n messageId: string;\n content: unknown;\n}\n\nexport function readToolOutputResult(payload: unknown): ToolOutputResult | null {\n if (typeof payload !== 'object' || payload === null) return null;\n const { messageId, content } = payload as Record<string, unknown>;\n if (typeof messageId !== 'string' || !messageId) return null;\n return { messageId, content };\n}\n\n/**\n * The `history/message` command: a message as the host stores it — the\n * model-provenance blobs the wire strips and an untruncated tool output\n * included. Every client receives one projected wire form; this is the one\n * per-client shape, fetched on demand like `history/tool_output`.\n */\nexport interface HistoryMessageCommand {\n readonly type: typeof DEEP_AGENT_HISTORY_MESSAGE_COMMAND;\n readonly messageId: string;\n}\n\nexport function buildHistoryMessageCommand({\n messageId,\n}: {\n messageId: string;\n}): HistoryMessageCommand {\n return { type: DEEP_AGENT_HISTORY_MESSAGE_COMMAND, messageId };\n}\n\nexport interface HistoryMessageResult {\n messageId: string;\n message: LangChainMessage;\n}\n\nexport function readHistoryMessageResult(payload: unknown): HistoryMessageResult | null {\n if (typeof payload !== 'object' || payload === null) return null;\n const { messageId, message } = payload as Record<string, unknown>;\n if (typeof messageId !== 'string' || !messageId) return null;\n if (typeof message !== 'object' || message === null) return null;\n return { messageId, message: message as LangChainMessage };\n}\n\n/** The wire marker on a tool message whose content the host cut. */\nexport interface TruncatedToolContent {\n /** Length of the full output, in characters. */\n chars: number;\n}\n\n/**\n * The truncation marker off a raw wire message, or `null` when the message's\n * content is whole. Pure and selector-safe on the marker object.\n */\nexport function readTruncatedToolContent(message: unknown): TruncatedToolContent | null {\n if (typeof message !== 'object' || message === null) return null;\n const marker = (message as Record<string, unknown>)[DEEP_AGENT_TRUNCATED_CONTENT_KEY];\n if (typeof marker !== 'object' || marker === null) return null;\n const chars = (marker as Record<string, unknown>).chars;\n return isIndex(chars) ? { chars } : null;\n}\n\n/**\n * `artifact` key the shared converter lifts a truncated tool output's marker\n * into (with the tool message id), so a tool card can ask for the full output\n * — the converter joins the ToolMessage into its tool-call part and would\n * otherwise drop the wire marker.\n */\nexport const ATHENA_TRUNCATED_TOOL_OUTPUT_ARTIFACT_KEY = '_athena_content_truncated';\n\nexport interface TruncatedToolOutputArtifact extends TruncatedToolContent {\n /** The tool message to name in `history/tool_output`. */\n messageId: string;\n}\n\n/**\n * The lifted truncation marker off a tool-call part's `artifact`, or `null`.\n */\nexport function readTruncatedToolOutputArtifact(\n artifact: unknown\n): TruncatedToolOutputArtifact | null {\n if (typeof artifact !== 'object' || artifact === null) return null;\n const lifted = (artifact as Record<string, unknown>)[ATHENA_TRUNCATED_TOOL_OUTPUT_ARTIFACT_KEY];\n if (typeof lifted !== 'object' || lifted === null) return null;\n const { chars, messageId } = lifted as Record<string, unknown>;\n if (!isIndex(chars) || typeof messageId !== 'string' || !messageId) return null;\n return { chars, messageId };\n}\n"],"names":["DEEP_AGENT_DEFAULT_MESSAGE_WINDOW","DEEP_AGENT_MIN_MESSAGE_WINDOW","DEEP_AGENT_MAX_MESSAGE_WINDOW","DEEP_AGENT_MAIN_NS","DEEP_AGENT_MESSAGE_WINDOW_HEADER","DEEP_AGENT_MAX_INTERESTS","DEEP_AGENT_INTEREST_PROTOCOL","DEEP_AGENT_STATEWIRE_PROTOCOL","DEEP_AGENT_HISTOR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AACnC,aAAS;AAAA,EACX;AACA,QAAM,WAA+B,CAAA;AACrC,aAAW,SAAS,OAAO;AACzB,UAAM,UAAU,UAAU,IAAI,MAAM,EAAE;AACtC,QAAI,YAAY,OAAW,UAAS,KAAK,OAAO;AAAA,EAClD;AACA,SAAO,EAAE,UAAU,OAAO,UAAU,UAAU,MAAA;AAChD;AAyBO,SAAS,uBAAuB,EAAE,aAAuD;AAC9F,SAAO,EAAE,MAAMK,kBAAAA,wCAAwC,UAAA;AACzD;AAOO,SAAS,qBAAqB,SAA2C;AAC9E,MAAI,OAAO,YAAY,YAAY,YAAY,KAAM,QAAO;AAC5D,QAAM,EAAE,WAAW,QAAA,IAAY;AAC/B,MAAI,OAAO,cAAc,YAAY,CAAC,UAAW,QAAO;AACxD,SAAO,EAAE,WAAW,QAAA;AACtB;AA4CO,SAAS,yBAAyB,SAA+C;AACtF,MAAI,OAAO,YAAY,YAAY,YAAY,KAAM,QAAO;AAC5D,QAAM,SAAU,QAAoCC,kDAAgC;AACpF,MAAI,OAAO,WAAW,YAAY,WAAW,KAAM,QAAO;AAC1D,QAAM,QAAS,OAAmC;AAClD,SAAO,QAAQ,KAAK,IAAI,EAAE,UAAU;AACtC;AAQO,MAAM,4CAA4C;AAUlD,SAAS,gCACd,UACoC;AACpC,MAAI,OAAO,aAAa,YAAY,aAAa,KAAM,QAAO;AAC9D,QAAM,SAAU,SAAqC,yCAAyC;AAC9F,MAAI,OAAO,WAAW,YAAY,WAAW,KAAM,QAAO;AAC1D,QAAM,EAAE,OAAO,UAAA,IAAc;AAC7B,MAAI,CAAC,QAAQ,KAAK,KAAK,OAAO,cAAc,YAAY,CAAC,UAAW,QAAO;AAC3E,SAAO,EAAE,OAAO,UAAA;AAClB;;;;;;;;;;;;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"message-window.js","sources":["../../../../../agent-runtime/src/message-window.ts"],"sourcesContent":["import type { LangChainMessage } from '@assistant-ui/react-langgraph';\nimport type { StatewireDocuments } from 'statewire';\nimport {\n DEEP_AGENT_DEFAULT_MESSAGE_WINDOW,\n DEEP_AGENT_HISTORY_MESSAGE_COMMAND,\n DEEP_AGENT_HISTORY_TOOL_OUTPUT_COMMAND,\n DEEP_AGENT_INTEREST_PROTOCOL,\n DEEP_AGENT_MAIN_NS,\n DEEP_AGENT_MAX_INTERESTS,\n DEEP_AGENT_MAX_MESSAGE_WINDOW,\n DEEP_AGENT_MESSAGE_WINDOW_HEADER,\n DEEP_AGENT_MIN_MESSAGE_WINDOW,\n DEEP_AGENT_TRUNCATED_CONTENT_KEY,\n} from './generated/runconfig-contract';\nimport { DEEP_AGENT_STATEWIRE_PROTOCOL } from './statewire-transport';\n\n/**\n * The interest window — the client half of agora's\n * `agora/graphs/athena_deep_agent/message_window.py`.\n *\n * The wire main document carries no `messages`. A client states its interests\n * on the `athena/interest` lane as one array (`set(requests)`): the first is\n * the head (the newest `before` messages of the `main` namespace), the rest\n * are pages anchored `at` the first message of the window they extend. The\n * host holds one ephemeral main document per attach, `{ windows }`, one\n * resolution per request in order (the request echoed plus the covered\n * `chain` and `more` flags; an anchor that vanished leaves an empty window in\n * place), and one shared `athena` document per covered message, keyed\n * `[threadId, \"main\", messageId]`. {@link readDeepAgentMessageWindow} joins\n * them into the transcript the converter renders.\n *\n * Two host rules shape the client half. The head window never drops below\n * the oldest message it has carried on an attach (a run's appends grow the\n * view, nothing loaded slides out), so a page stays anchored at the head's\n * first message while the transcript grows; and the host remembers a client\n * id's interests across its attaches, so a reconnect's hello carries the\n * view the client held. A fresh client's hello carries the head it declared\n * on the attach headers ({@link withDeclaredMessageWindow}) — a statement\n * cannot ride the first attach, the hello negotiates the lanes.\n *\n * Pages are appended one per load until the host's interest cap, then the\n * loaded range is restated in as few maximal requests as it takes\n * ({@link pageInterestRequests}); the whole transcript stays reachable up to\n * `MAX_INTERESTS × MAX_MESSAGE_WINDOW` messages. A truncated tool output\n * comes back whole through `history/tool_output` ({@link buildToolOutputCommand});\n * a message's stored form — provenance blobs and all — through\n * `history/message` ({@link buildHistoryMessageCommand}).\n */\n\nconst isIndex = (value: unknown): value is number =>\n typeof value === 'number' && Number.isInteger(value) && value >= 0;\n\n/** What a surface declares for its window: the interest size (the host clamps to its bounds). */\nexport interface DeepAgentMessageWindowDeclaration {\n size?: number;\n}\n\nexport function clampMessageWindowSize(size?: number): number {\n if (size === undefined || !Number.isFinite(size)) return DEEP_AGENT_DEFAULT_MESSAGE_WINDOW;\n return Math.max(\n DEEP_AGENT_MIN_MESSAGE_WINDOW,\n Math.min(DEEP_AGENT_MAX_MESSAGE_WINDOW, Math.trunc(size))\n );\n}\n\n/** An `athena/interest` request over the linear transcript. */\nexport interface DeepAgentInterestRequest {\n readonly ns: typeof DEEP_AGENT_MAIN_NS;\n /** Messages ending at the anchor (the tail without `at`). */\n readonly before: number;\n /** Anchor message id; a page's is the first message of the window it extends. */\n readonly at?: string;\n /** Messages past the anchor (requires `at`). */\n readonly after?: number;\n}\n\nexport function headInterestRequest(size?: number): DeepAgentInterestRequest {\n return { ns: DEEP_AGENT_MAIN_NS, before: clampMessageWindowSize(size) };\n}\n\nexport function pageInterestRequest(at: string, size?: number): DeepAgentInterestRequest {\n return { ns: DEEP_AGENT_MAIN_NS, before: clampMessageWindowSize(size), at };\n}\n\n/**\n * Attach headers with the head window declared (`x-athena-deep-agent-window`):\n * the hello of a client the host does not remember carries the newest `size`\n * messages. Part of the one attach recipe, so a pooled dial asks for the shape\n * the thread's own attach would. An explicit entry (tests, overrides) wins.\n */\nexport function withDeclaredMessageWindow(\n headers: Record<string, string>,\n declaration: DeepAgentMessageWindowDeclaration = {}\n): Record<string, string> {\n if (DEEP_AGENT_MESSAGE_WINDOW_HEADER in headers) return headers;\n return {\n ...headers,\n [DEEP_AGENT_MESSAGE_WINDOW_HEADER]: String(clampMessageWindowSize(declaration.size)),\n };\n}\n\nexport interface DeepAgentInterestChainEntry {\n id: string;\n siblings: string[];\n}\n\n/** The host's resolution document of one interest: the request echoed plus its coverage. */\nexport interface DeepAgentInterestResolution extends DeepAgentInterestRequest {\n /** Covered message ids, oldest first (a page ends at its anchor). */\n chain: DeepAgentInterestChainEntry[];\n more: { before: boolean; after: boolean };\n}\n\nexport function readDeepAgentInterestResolution(value: unknown): DeepAgentInterestResolution | null {\n if (typeof value !== 'object' || value === null) return null;\n const { ns, before, at, after, chain, more } = value as Record<string, unknown>;\n if (ns !== DEEP_AGENT_MAIN_NS || !isIndex(before) || !Array.isArray(chain)) return null;\n if (at !== undefined && typeof at !== 'string') return null;\n if (after !== undefined && !isIndex(after)) return null;\n if (typeof more !== 'object' || more === null) return null;\n const { before: moreBefore, after: moreAfter } = more as Record<string, unknown>;\n if (typeof moreBefore !== 'boolean' || typeof moreAfter !== 'boolean') return null;\n const entries: DeepAgentInterestChainEntry[] = [];\n for (const entry of chain) {\n const { id, siblings } = (entry ?? {}) as Record<string, unknown>;\n if (typeof id !== 'string') return null;\n entries.push({\n id,\n siblings: Array.isArray(siblings) ? siblings.filter((s) => typeof s === 'string') : [id],\n });\n }\n return {\n ns: DEEP_AGENT_MAIN_NS,\n before,\n ...(at !== undefined && { at }),\n ...(after !== undefined && { after }),\n chain: entries,\n more: { before: moreBefore, after: moreAfter },\n };\n}\n\n/** The attach's interest document: one resolution per stated request, in order. */\nexport interface DeepAgentInterestDocument {\n windows: DeepAgentInterestResolution[];\n}\n\nexport function readDeepAgentInterestDocument(value: unknown): DeepAgentInterestDocument | null {\n if (typeof value !== 'object' || value === null) return null;\n const { windows } = value as Record<string, unknown>;\n if (!Array.isArray(windows)) return null;\n const resolutions: DeepAgentInterestResolution[] = [];\n for (const window of windows) {\n const resolution = readDeepAgentInterestResolution(window);\n if (resolution === null) return null;\n resolutions.push(resolution);\n }\n return { windows: resolutions };\n}\n\nconst interestRequest = ({ ns, before, at, after }: DeepAgentInterestRequest): DeepAgentInterestRequest => ({\n ns,\n before,\n ...(at !== undefined && { at }),\n ...(after !== undefined && { after }),\n});\n\n/** The loaded transcript window, joined from the head interest and its anchored pages. */\nexport interface DeepAgentMessageWindow {\n /** The requests the joined view stands on, in order (the head first): what a `set` restates. A stale page (its anchor gone) or one the head already covers is left out. */\n requests: DeepAgentInterestRequest[];\n /** Covered chain, oldest first. */\n chain: DeepAgentInterestChainEntry[];\n /** The chain's message documents, in chain order (an unmounted one is skipped). */\n messages: LangChainMessage[];\n /** Whether the host holds messages older than the window. */\n hasOlder: boolean;\n /** Pages joined onto the head. */\n pages: number;\n}\n\n/**\n * The loaded chain plus `grow` older messages, restated in as few requests as\n * it takes: a maximal head, then maximal pages each anchored at the first\n * message of the window above it. `null` once even that exceeds the host's\n * interest cap — the reachable depth is `MAX_INTERESTS × MAX_MESSAGE_WINDOW`.\n */\nfunction coalescedInterestRequests(\n chain: readonly DeepAgentInterestChainEntry[],\n grow: number\n): DeepAgentInterestRequest[] | null {\n const loaded = chain.length;\n const requests: DeepAgentInterestRequest[] = [\n { ns: DEEP_AGENT_MAIN_NS, before: Math.min(DEEP_AGENT_MAX_MESSAGE_WINDOW, loaded) },\n ];\n // `low` is the chain index of the lowest message the plan covers so far.\n let low = loaded - (requests[0] as DeepAgentInterestRequest).before;\n while (low > 0) {\n const before = Math.min(DEEP_AGENT_MAX_MESSAGE_WINDOW, low + 1);\n requests.push({\n ns: DEEP_AGENT_MAIN_NS,\n before,\n at: (chain[low] as DeepAgentInterestChainEntry).id,\n });\n low = low + 1 - before;\n }\n // The plan covers the chain; the new messages extend its lowest request\n // when that stays within one window, else they are a page of their own.\n const last = requests[requests.length - 1] as DeepAgentInterestRequest;\n if (last.before + grow <= DEEP_AGENT_MAX_MESSAGE_WINDOW) {\n requests[requests.length - 1] = { ...last, before: last.before + grow };\n } else {\n requests.push({\n ns: DEEP_AGENT_MAIN_NS,\n before: grow + 1,\n at: (chain[0] as DeepAgentInterestChainEntry).id,\n });\n }\n return requests.length > DEEP_AGENT_MAX_INTERESTS ? null : requests;\n}\n\n/**\n * The requests to state for one more page of older history, or `null` when\n * there is nothing to load (no anchor, the beginning reached) or the host's\n * interest cap is spent. One page is appended, anchored at the window's first\n * message, while the cap allows; at the cap the loaded range is coalesced\n * into maximal requests first (see {@link coalescedInterestRequests}).\n */\nexport function pageInterestRequests(\n window: DeepAgentMessageWindow,\n size?: number\n): DeepAgentInterestRequest[] | null {\n const anchor = window.chain[0]?.id;\n if (anchor === undefined || !window.hasOlder) return null;\n const page = pageInterestRequest(anchor, size);\n const appended = [...window.requests, page];\n if (appended.length <= DEEP_AGENT_MAX_INTERESTS) return appended;\n // A page's `before` counts its anchor: it adds `before - 1` older messages.\n return coalescedInterestRequests(window.chain, page.before - 1);\n}\n\n/**\n * Whether every `stated` request is carried by `carried` (the same anchor, at\n * least as wide): a reconnect's hello that carries what the client last\n * stated — the host remembers a client id's interests — needs no restatement.\n */\nexport function interestsCovered(\n carried: readonly DeepAgentInterestRequest[],\n stated: readonly DeepAgentInterestRequest[]\n): boolean {\n return stated.every((request) =>\n carried.some((have) => have.at === request.at && have.before >= request.before)\n );\n}\n\n/**\n * The window off the mounted documents, or `null` while the head interest has\n * not resolved (pre-attach, before the first `set` answer, a wire without\n * documents). A page joins wherever its anchor sits in the chain so far — at\n * the first message it extends the view, inside the head (the head widened\n * past it) it adds nothing and is left out of `requests`; a page whose anchor\n * left the transcript (a rewind emptied it in place) is left out too. A\n * malformed document reads as absent.\n */\nexport function readDeepAgentMessageWindow(\n mounted: ReadonlyMap<number, StatewireDocuments.Document> | undefined\n): DeepAgentMessageWindow | null {\n if (mounted === undefined) return null;\n let windows: DeepAgentInterestResolution[] | undefined;\n const documents = new Map<string, LangChainMessage>();\n for (const document of mounted.values()) {\n const key = document.key;\n if (document.protocol === DEEP_AGENT_INTEREST_PROTOCOL && document.main === true) {\n windows = readDeepAgentInterestDocument(document.value)?.windows;\n } else if (\n document.protocol === DEEP_AGENT_STATEWIRE_PROTOCOL &&\n key !== null &&\n key.length === 3 &&\n key[1] === DEEP_AGENT_MAIN_NS\n ) {\n documents.set(key[2] as string, document.value as LangChainMessage);\n }\n }\n const head = windows?.[0];\n if (windows === undefined || head === undefined) return null;\n let chain = head.chain;\n let hasOlder = head.more.before;\n const requests = [interestRequest(head)];\n const loaded = new Set(chain.map((entry) => entry.id));\n let pages = 0;\n for (const page of windows.slice(1)) {\n if (page.at === undefined || !loaded.has(page.at)) continue;\n const anchorAt = page.chain.findIndex((entry) => entry.id === page.at);\n if (anchorAt < 0) continue;\n // Both windows are ranges of one linear transcript sharing the anchor:\n // what the page holds below it and the chain does not is a prefix.\n const fresh = page.chain.slice(0, anchorAt).filter((entry) => !loaded.has(entry.id));\n if (fresh.length === 0) {\n // Nothing new, but a page that starts where the loaded chain starts\n // has looked below it: its `more.before` is the answer for the edge.\n if (page.chain[0]?.id === chain[0]?.id) hasOlder = page.more.before;\n continue;\n }\n chain = [...fresh, ...chain];\n for (const entry of fresh) loaded.add(entry.id);\n hasOlder = page.more.before;\n requests.push(interestRequest(page));\n pages += 1;\n }\n const messages: LangChainMessage[] = [];\n for (const entry of chain) {\n const message = documents.get(entry.id);\n if (message !== undefined) messages.push(message);\n }\n return { requests, chain, messages, hasOlder, pages };\n}\n\n/**\n * The windowed wire's read command on the statewire command union, so\n * `sendCommand({ type: 'history/tool_output', … })` typechecks wherever the\n * deep-agent host is driven (`DeepAgentThread.history_tool_output`, an\n * attach-ACL read).\n */\ndeclare module '@assistant-ui/core' {\n namespace Assistant {\n interface Commands {\n /** A tool output the windowed wire carried cut, whole. */\n historyToolOutput: ToolOutputCommand;\n /** One stored message whole — the per-client shape, by command. */\n historyMessage: HistoryMessageCommand;\n }\n }\n}\n\n/** The `history/tool_output` command: a truncated tool output, whole. */\nexport interface ToolOutputCommand {\n readonly type: typeof DEEP_AGENT_HISTORY_TOOL_OUTPUT_COMMAND;\n readonly messageId: string;\n}\n\nexport function buildToolOutputCommand({ messageId }: { messageId: string }): ToolOutputCommand {\n return { type: DEEP_AGENT_HISTORY_TOOL_OUTPUT_COMMAND, messageId };\n}\n\nexport interface ToolOutputResult {\n messageId: string;\n content: unknown;\n}\n\nexport function readToolOutputResult(payload: unknown): ToolOutputResult | null {\n if (typeof payload !== 'object' || payload === null) return null;\n const { messageId, content } = payload as Record<string, unknown>;\n if (typeof messageId !== 'string' || !messageId) return null;\n return { messageId, content };\n}\n\n/**\n * The `history/message` command: a message as the host stores it — the\n * model-provenance blobs the wire strips and an untruncated tool output\n * included. Every client receives one projected wire form; this is the one\n * per-client shape, fetched on demand like `history/tool_output`.\n */\nexport interface HistoryMessageCommand {\n readonly type: typeof DEEP_AGENT_HISTORY_MESSAGE_COMMAND;\n readonly messageId: string;\n}\n\nexport function buildHistoryMessageCommand({\n messageId,\n}: {\n messageId: string;\n}): HistoryMessageCommand {\n return { type: DEEP_AGENT_HISTORY_MESSAGE_COMMAND, messageId };\n}\n\nexport interface HistoryMessageResult {\n messageId: string;\n message: LangChainMessage;\n}\n\nexport function readHistoryMessageResult(payload: unknown): HistoryMessageResult | null {\n if (typeof payload !== 'object' || payload === null) return null;\n const { messageId, message } = payload as Record<string, unknown>;\n if (typeof messageId !== 'string' || !messageId) return null;\n if (typeof message !== 'object' || message === null) return null;\n return { messageId, message: message as LangChainMessage };\n}\n\n/** The wire marker on a tool message whose content the host cut. */\nexport interface TruncatedToolContent {\n /** Length of the full output, in characters. */\n chars: number;\n}\n\n/**\n * The truncation marker off a raw wire message, or `null` when the message's\n * content is whole. Pure and selector-safe on the marker object.\n */\nexport function readTruncatedToolContent(message: unknown): TruncatedToolContent | null {\n if (typeof message !== 'object' || message === null) return null;\n const marker = (message as Record<string, unknown>)[DEEP_AGENT_TRUNCATED_CONTENT_KEY];\n if (typeof marker !== 'object' || marker === null) return null;\n const chars = (marker as Record<string, unknown>).chars;\n return isIndex(chars) ? { chars } : null;\n}\n\n/**\n * `artifact` key the shared converter lifts a truncated tool output's marker\n * into (with the tool message id), so a tool card can ask for the full output\n * — the converter joins the ToolMessage into its tool-call part and would\n * otherwise drop the wire marker.\n */\nexport const ATHENA_TRUNCATED_TOOL_OUTPUT_ARTIFACT_KEY = '_athena_content_truncated';\n\nexport interface TruncatedToolOutputArtifact extends TruncatedToolContent {\n /** The tool message to name in `history/tool_output`. */\n messageId: string;\n}\n\n/**\n * The lifted truncation marker off a tool-call part's `artifact`, or `null`.\n */\nexport function readTruncatedToolOutputArtifact(\n artifact: unknown\n): TruncatedToolOutputArtifact | null {\n if (typeof artifact !== 'object' || artifact === null) return null;\n const lifted = (artifact as Record<string, unknown>)[ATHENA_TRUNCATED_TOOL_OUTPUT_ARTIFACT_KEY];\n if (typeof lifted !== 'object' || lifted === null) return null;\n const { chars, messageId } = lifted as Record<string, unknown>;\n if (!isIndex(chars) || typeof messageId !== 'string' || !messageId) return null;\n return { chars, messageId };\n}\n"],"names":[],"mappings":";;AAiDA,MAAM,UAAU,CAAC,UACf,OAAO,UAAU,YAAY,OAAO,UAAU,KAAK,KAAK,SAAS;AAO5D,SAAS,uBAAuB,MAAuB;AAC5D,MAAI,SAAS,UAAa,CAAC,OAAO,SAAS,IAAI,EAAG,QAAO;AACzD,SAAO,KAAK;AAAA,IACV;AAAA,IACA,KAAK,IAAI,+BAA+B,KAAK,MAAM,IAAI,CAAC;AAAA,EAAA;AAE5D;AAaO,SAAS,oBAAoB,MAAyC;AAC3E,SAAO,EAAE,IAAI,oBAAoB,QAAQ,uBAAuB,IAAI,EAAA;AACtE;AAEO,SAAS,oBAAoB,IAAY,MAAyC;AACvF,SAAO,EAAE,IAAI,oBAAoB,QAAQ,uBAAuB,IAAI,GAAG,GAAA;AACzE;AAQO,SAAS,0BACd,SACA,cAAiD,IACzB;AACxB,MAAI,oCAAoC,QAAS,QAAO;AACxD,SAAO;AAAA,IACL,GAAG;AAAA,IACH,CAAC,gCAAgC,GAAG,OAAO,uBAAuB,YAAY,IAAI,CAAC;AAAA,EAAA;AAEvF;AAcO,SAAS,gCAAgC,OAAoD;AAClG,MAAI,OAAO,UAAU,YAAY,UAAU,KAAM,QAAO;AACxD,QAAM,EAAE,IAAI,QAAQ,IAAI,OAAO,OAA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