@athenaintel/react 0.57.1 → 0.59.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 (811) hide show
  1. package/README.md +778 -9
  2. package/dist/agent-runtime/src/addressed-agents.cjs +16 -0
  3. package/dist/agent-runtime/src/addressed-agents.cjs.map +1 -0
  4. package/dist/agent-runtime/src/addressed-agents.d.ts +30 -0
  5. package/dist/agent-runtime/src/addressed-agents.js +16 -0
  6. package/dist/agent-runtime/src/addressed-agents.js.map +1 -0
  7. package/dist/agent-runtime/src/answer-label.cjs +4 -3
  8. package/dist/agent-runtime/src/answer-label.cjs.map +1 -1
  9. package/dist/agent-runtime/src/answer-label.d.ts +13 -6
  10. package/dist/agent-runtime/src/answer-label.js +4 -3
  11. package/dist/agent-runtime/src/answer-label.js.map +1 -1
  12. package/dist/agent-runtime/src/chat-outbox-attachments.cjs.map +1 -1
  13. package/dist/agent-runtime/src/chat-outbox-attachments.d.ts +1 -1
  14. package/dist/agent-runtime/src/chat-outbox-attachments.js.map +1 -1
  15. package/dist/agent-runtime/src/chat-outbox-entry.cjs +101 -0
  16. package/dist/agent-runtime/src/chat-outbox-entry.cjs.map +1 -0
  17. package/dist/agent-runtime/src/chat-outbox-entry.d.ts +99 -0
  18. package/dist/agent-runtime/src/chat-outbox-entry.js +101 -0
  19. package/dist/agent-runtime/src/chat-outbox-entry.js.map +1 -0
  20. package/dist/agent-runtime/src/chat-outbox-legacy.cjs +252 -0
  21. package/dist/agent-runtime/src/chat-outbox-legacy.cjs.map +1 -0
  22. package/dist/agent-runtime/src/chat-outbox-legacy.d.ts +96 -0
  23. package/dist/agent-runtime/src/chat-outbox-legacy.js +252 -0
  24. package/dist/agent-runtime/src/chat-outbox-legacy.js.map +1 -0
  25. package/dist/agent-runtime/src/chat-outbox-policy.cjs +30 -0
  26. package/dist/agent-runtime/src/chat-outbox-policy.cjs.map +1 -0
  27. package/dist/agent-runtime/src/chat-outbox-policy.d.ts +42 -0
  28. package/dist/agent-runtime/src/chat-outbox-policy.js +30 -0
  29. package/dist/agent-runtime/src/chat-outbox-policy.js.map +1 -0
  30. package/dist/agent-runtime/src/chat-outbox-storage.cjs +306 -0
  31. package/dist/agent-runtime/src/chat-outbox-storage.cjs.map +1 -0
  32. package/dist/agent-runtime/src/chat-outbox-storage.d.ts +194 -0
  33. package/dist/agent-runtime/src/chat-outbox-storage.js +306 -0
  34. package/dist/agent-runtime/src/chat-outbox-storage.js.map +1 -0
  35. package/dist/agent-runtime/src/chat-outbox-thread.cjs +21 -94
  36. package/dist/agent-runtime/src/chat-outbox-thread.cjs.map +1 -1
  37. package/dist/agent-runtime/src/chat-outbox-thread.d.ts +22 -18
  38. package/dist/agent-runtime/src/chat-outbox-thread.js +21 -94
  39. package/dist/agent-runtime/src/chat-outbox-thread.js.map +1 -1
  40. package/dist/agent-runtime/src/chat-outbox.cjs +492 -547
  41. package/dist/agent-runtime/src/chat-outbox.cjs.map +1 -1
  42. package/dist/agent-runtime/src/chat-outbox.d.ts +110 -142
  43. package/dist/agent-runtime/src/chat-outbox.js +492 -547
  44. package/dist/agent-runtime/src/chat-outbox.js.map +1 -1
  45. package/dist/agent-runtime/src/composer-markdown.cjs.map +1 -1
  46. package/dist/agent-runtime/src/composer-markdown.d.ts +1 -1
  47. package/dist/agent-runtime/src/composer-markdown.js.map +1 -1
  48. package/dist/agent-runtime/src/deep-agent-transport-recipe.cjs +3 -1
  49. package/dist/agent-runtime/src/deep-agent-transport-recipe.cjs.map +1 -1
  50. package/dist/agent-runtime/src/deep-agent-transport-recipe.d.ts +8 -1
  51. package/dist/agent-runtime/src/deep-agent-transport-recipe.js +3 -1
  52. package/dist/agent-runtime/src/deep-agent-transport-recipe.js.map +1 -1
  53. package/dist/agent-runtime/src/dictation-preferences.d.ts +356 -0
  54. package/dist/agent-runtime/src/dictation-record.d.ts +279 -0
  55. package/dist/agent-runtime/src/dictation-session.d.ts +106 -7
  56. package/dist/agent-runtime/src/dictation-snippets.d.ts +9 -0
  57. package/dist/agent-runtime/src/dictation-transfer.d.ts +142 -0
  58. package/dist/agent-runtime/src/edit-command.cjs.map +1 -1
  59. package/dist/agent-runtime/src/edit-command.d.ts +1 -1
  60. package/dist/agent-runtime/src/edit-command.js.map +1 -1
  61. package/dist/agent-runtime/src/errors.cjs +1 -0
  62. package/dist/agent-runtime/src/errors.cjs.map +1 -1
  63. package/dist/agent-runtime/src/errors.js +1 -0
  64. package/dist/agent-runtime/src/errors.js.map +1 -1
  65. package/dist/agent-runtime/src/generated/runconfig-contract.cjs +24 -0
  66. package/dist/agent-runtime/src/generated/runconfig-contract.cjs.map +1 -1
  67. package/dist/agent-runtime/src/generated/runconfig-contract.d.ts +3 -3
  68. package/dist/agent-runtime/src/generated/runconfig-contract.js +24 -0
  69. package/dist/agent-runtime/src/generated/runconfig-contract.js.map +1 -1
  70. package/dist/agent-runtime/src/index.d.ts +14 -8
  71. package/dist/agent-runtime/src/lane-follow.cjs +289 -0
  72. package/dist/agent-runtime/src/lane-follow.cjs.map +1 -0
  73. package/dist/agent-runtime/src/lane-follow.js +289 -0
  74. package/dist/agent-runtime/src/lane-follow.js.map +1 -0
  75. package/dist/agent-runtime/src/lane-images.cjs +387 -0
  76. package/dist/agent-runtime/src/lane-images.cjs.map +1 -0
  77. package/dist/agent-runtime/src/lane-images.js +387 -0
  78. package/dist/agent-runtime/src/lane-images.js.map +1 -0
  79. package/dist/agent-runtime/src/message-window.js +1 -1
  80. package/dist/agent-runtime/src/messages.cjs +19 -1
  81. package/dist/agent-runtime/src/messages.cjs.map +1 -1
  82. package/dist/agent-runtime/src/messages.d.ts +8 -0
  83. package/dist/agent-runtime/src/messages.js +21 -3
  84. package/dist/agent-runtime/src/messages.js.map +1 -1
  85. package/dist/agent-runtime/src/named-agents.cjs +301 -0
  86. package/dist/agent-runtime/src/named-agents.cjs.map +1 -0
  87. package/dist/agent-runtime/src/named-agents.d.ts +246 -0
  88. package/dist/agent-runtime/src/named-agents.js +301 -0
  89. package/dist/agent-runtime/src/named-agents.js.map +1 -0
  90. package/dist/agent-runtime/src/offline-status.cjs.map +1 -1
  91. package/dist/agent-runtime/src/offline-status.d.ts +66 -2
  92. package/dist/agent-runtime/src/offline-status.js.map +1 -1
  93. package/dist/agent-runtime/src/ptc-subcalls.cjs +41 -0
  94. package/dist/agent-runtime/src/ptc-subcalls.cjs.map +1 -0
  95. package/dist/agent-runtime/src/ptc-subcalls.js +41 -0
  96. package/dist/agent-runtime/src/ptc-subcalls.js.map +1 -0
  97. package/dist/agent-runtime/src/queue.cjs +2 -2
  98. package/dist/agent-runtime/src/queue.cjs.map +1 -1
  99. package/dist/agent-runtime/src/queue.d.ts +20 -25
  100. package/dist/agent-runtime/src/queue.js +2 -2
  101. package/dist/agent-runtime/src/queue.js.map +1 -1
  102. package/dist/agent-runtime/src/quota-safe-local-storage-session.cjs +314 -84
  103. package/dist/agent-runtime/src/quota-safe-local-storage-session.cjs.map +1 -1
  104. package/dist/agent-runtime/src/quota-safe-local-storage-session.d.ts +137 -40
  105. package/dist/agent-runtime/src/quota-safe-local-storage-session.js +318 -88
  106. package/dist/agent-runtime/src/quota-safe-local-storage-session.js.map +1 -1
  107. package/dist/agent-runtime/src/run-send.cjs +54 -0
  108. package/dist/agent-runtime/src/run-send.cjs.map +1 -0
  109. package/dist/agent-runtime/src/run-send.d.ts +51 -0
  110. package/dist/agent-runtime/src/run-send.js +54 -0
  111. package/dist/agent-runtime/src/run-send.js.map +1 -0
  112. package/dist/agent-runtime/src/running-tool-placeholder.cjs +6 -0
  113. package/dist/agent-runtime/src/running-tool-placeholder.cjs.map +1 -1
  114. package/dist/agent-runtime/src/running-tool-placeholder.js +6 -0
  115. package/dist/agent-runtime/src/running-tool-placeholder.js.map +1 -1
  116. package/dist/agent-runtime/src/runtime.d.ts +9 -5
  117. package/dist/agent-runtime/src/sealed-idb.cjs +64 -0
  118. package/dist/agent-runtime/src/sealed-idb.cjs.map +1 -1
  119. package/dist/agent-runtime/src/sealed-idb.d.ts +16 -0
  120. package/dist/agent-runtime/src/sealed-idb.js +64 -0
  121. package/dist/agent-runtime/src/sealed-idb.js.map +1 -1
  122. package/dist/agent-runtime/src/send-recovery.cjs +90 -118
  123. package/dist/agent-runtime/src/send-recovery.cjs.map +1 -1
  124. package/dist/agent-runtime/src/send-recovery.d.ts +25 -29
  125. package/dist/agent-runtime/src/send-recovery.js +90 -118
  126. package/dist/agent-runtime/src/send-recovery.js.map +1 -1
  127. package/dist/agent-runtime/src/statewire-diagnostics.d.ts +4 -1
  128. package/dist/agent-runtime/src/statewire-held-sends.cjs +191 -0
  129. package/dist/agent-runtime/src/statewire-held-sends.cjs.map +1 -0
  130. package/dist/agent-runtime/src/statewire-held-sends.d.ts +119 -0
  131. package/dist/agent-runtime/src/statewire-held-sends.js +191 -0
  132. package/dist/agent-runtime/src/statewire-held-sends.js.map +1 -0
  133. package/dist/agent-runtime/src/statewire-state.cjs +4 -0
  134. package/dist/agent-runtime/src/statewire-state.cjs.map +1 -1
  135. package/dist/agent-runtime/src/statewire-state.js +4 -0
  136. package/dist/agent-runtime/src/statewire-state.js.map +1 -1
  137. package/dist/agent-runtime/src/statewire-transport.cjs +8 -2
  138. package/dist/agent-runtime/src/statewire-transport.cjs.map +1 -1
  139. package/dist/agent-runtime/src/statewire-transport.d.ts +14 -5
  140. package/dist/agent-runtime/src/statewire-transport.js +8 -2
  141. package/dist/agent-runtime/src/statewire-transport.js.map +1 -1
  142. package/dist/agent-runtime/src/subagent-transcripts.cjs +1 -23
  143. package/dist/agent-runtime/src/subagent-transcripts.cjs.map +1 -1
  144. package/dist/agent-runtime/src/subagent-transcripts.js +3 -25
  145. package/dist/agent-runtime/src/subagent-transcripts.js.map +1 -1
  146. package/dist/agent-runtime/src/subagents.cjs +22 -29
  147. package/dist/agent-runtime/src/subagents.cjs.map +1 -1
  148. package/dist/agent-runtime/src/subagents.js +23 -30
  149. package/dist/agent-runtime/src/subagents.js.map +1 -1
  150. package/dist/agent-runtime/src/thread-extras.cjs +27 -19
  151. package/dist/agent-runtime/src/thread-extras.cjs.map +1 -1
  152. package/dist/agent-runtime/src/thread-extras.d.ts +19 -6
  153. package/dist/agent-runtime/src/thread-extras.js +27 -19
  154. package/dist/agent-runtime/src/thread-extras.js.map +1 -1
  155. package/dist/agent-runtime/src/thread-handoff-flow-machine.d.ts +8 -8
  156. package/dist/agent-runtime/src/tool-metadata.cjs +12 -0
  157. package/dist/agent-runtime/src/tool-metadata.cjs.map +1 -1
  158. package/dist/agent-runtime/src/tool-metadata.js +12 -0
  159. package/dist/agent-runtime/src/tool-metadata.js.map +1 -1
  160. package/dist/agent-runtime/src/tool-names.cjs +21 -0
  161. package/dist/agent-runtime/src/tool-names.cjs.map +1 -1
  162. package/dist/agent-runtime/src/tool-names.d.ts +8 -0
  163. package/dist/agent-runtime/src/tool-names.js +21 -0
  164. package/dist/agent-runtime/src/tool-names.js.map +1 -1
  165. package/dist/agent-runtime/src/typed-interrupt-kinds.cjs +247 -0
  166. package/dist/agent-runtime/src/typed-interrupt-kinds.cjs.map +1 -0
  167. package/dist/agent-runtime/src/typed-interrupt-kinds.d.ts +173 -0
  168. package/dist/agent-runtime/src/typed-interrupt-kinds.js +247 -0
  169. package/dist/agent-runtime/src/typed-interrupt-kinds.js.map +1 -0
  170. package/dist/agent-runtime/src/typed-interrupts.cjs +48 -0
  171. package/dist/agent-runtime/src/typed-interrupts.cjs.map +1 -0
  172. package/dist/agent-runtime/src/typed-interrupts.d.ts +75 -0
  173. package/dist/agent-runtime/src/typed-interrupts.js +48 -0
  174. package/dist/agent-runtime/src/typed-interrupts.js.map +1 -0
  175. package/dist/agent-runtime/src/types.d.ts +1 -1
  176. package/dist/agent-runtime/src/use-conversation-list.cjs +1 -0
  177. package/dist/agent-runtime/src/use-conversation-list.cjs.map +1 -1
  178. package/dist/agent-runtime/src/use-conversation-list.d.ts +7 -0
  179. package/dist/agent-runtime/src/use-conversation-list.js +1 -0
  180. package/dist/agent-runtime/src/use-conversation-list.js.map +1 -1
  181. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.cjs +46 -29
  182. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.cjs.map +1 -1
  183. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.d.ts +14 -22
  184. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.js +46 -29
  185. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.js.map +1 -1
  186. package/dist/agent-runtime/src/use-deep-agent-runtime.cjs +78 -14
  187. package/dist/agent-runtime/src/use-deep-agent-runtime.cjs.map +1 -1
  188. package/dist/agent-runtime/src/use-deep-agent-runtime.d.ts +34 -7
  189. package/dist/agent-runtime/src/use-deep-agent-runtime.js +79 -15
  190. package/dist/agent-runtime/src/use-deep-agent-runtime.js.map +1 -1
  191. package/dist/agent-runtime/src/use-deep-agent-thread.cjs +16 -1
  192. package/dist/agent-runtime/src/use-deep-agent-thread.cjs.map +1 -1
  193. package/dist/agent-runtime/src/use-deep-agent-thread.d.ts +7 -2
  194. package/dist/agent-runtime/src/use-deep-agent-thread.js +16 -1
  195. package/dist/agent-runtime/src/use-deep-agent-thread.js.map +1 -1
  196. package/dist/agent-runtime/src/use-deep-agent-voice.cjs +30 -4
  197. package/dist/agent-runtime/src/use-deep-agent-voice.cjs.map +1 -1
  198. package/dist/agent-runtime/src/use-deep-agent-voice.d.ts +22 -4
  199. package/dist/agent-runtime/src/use-deep-agent-voice.js +30 -4
  200. package/dist/agent-runtime/src/use-deep-agent-voice.js.map +1 -1
  201. package/dist/agent-runtime/src/withdrawn-turns.d.ts +5 -4
  202. package/dist/agent-runtime/src/word-device-fit.d.ts +174 -0
  203. package/dist/agent-runtime/src/work-in.d.ts +127 -0
  204. package/dist/assets/AthenaAssetEmbed.cjs.map +1 -1
  205. package/dist/assets/AthenaAssetEmbed.d.ts +6 -1
  206. package/dist/assets/AthenaAssetEmbed.js.map +1 -1
  207. package/dist/assets/asset-panel-store.cjs +13 -5
  208. package/dist/assets/asset-panel-store.cjs.map +1 -1
  209. package/dist/assets/asset-panel-store.d.ts +33 -2
  210. package/dist/assets/asset-panel-store.js +13 -5
  211. package/dist/assets/asset-panel-store.js.map +1 -1
  212. package/dist/auth/AthenaCredentialSourceContext.cjs +11 -0
  213. package/dist/auth/AthenaCredentialSourceContext.cjs.map +1 -1
  214. package/dist/auth/AthenaCredentialSourceContext.d.ts +6 -0
  215. package/dist/auth/AthenaCredentialSourceContext.js +11 -0
  216. package/dist/auth/AthenaCredentialSourceContext.js.map +1 -1
  217. package/dist/auth/account-identity.cjs +13 -2
  218. package/dist/auth/account-identity.cjs.map +1 -1
  219. package/dist/auth/account-identity.d.ts +9 -0
  220. package/dist/auth/account-identity.js +13 -2
  221. package/dist/auth/account-identity.js.map +1 -1
  222. package/dist/auth/credential-source.cjs +20 -4
  223. package/dist/auth/credential-source.cjs.map +1 -1
  224. package/dist/auth/credential-source.d.ts +9 -0
  225. package/dist/auth/credential-source.js +20 -4
  226. package/dist/auth/credential-source.js.map +1 -1
  227. package/dist/catalog/chat-pickers.cjs +31 -0
  228. package/dist/catalog/chat-pickers.cjs.map +1 -1
  229. package/dist/catalog/chat-pickers.d.ts +17 -0
  230. package/dist/catalog/chat-pickers.js +33 -2
  231. package/dist/catalog/chat-pickers.js.map +1 -1
  232. package/dist/catalog/runtime-catalog.cjs +63 -3
  233. package/dist/catalog/runtime-catalog.cjs.map +1 -1
  234. package/dist/catalog/runtime-catalog.d.ts +63 -3
  235. package/dist/catalog/runtime-catalog.js +64 -4
  236. package/dist/catalog/runtime-catalog.js.map +1 -1
  237. package/dist/chat/AthenaChat.cjs +337 -99
  238. package/dist/chat/AthenaChat.cjs.map +1 -1
  239. package/dist/chat/AthenaChat.d.ts +80 -4
  240. package/dist/chat/AthenaChat.js +337 -99
  241. package/dist/chat/AthenaChat.js.map +1 -1
  242. package/dist/chat/StatewireApprovalCard.cjs +35 -5
  243. package/dist/chat/StatewireApprovalCard.cjs.map +1 -1
  244. package/dist/chat/StatewireApprovalCard.d.ts +55 -2
  245. package/dist/chat/StatewireApprovalCard.js +37 -7
  246. package/dist/chat/StatewireApprovalCard.js.map +1 -1
  247. package/dist/chat/StatewireQueuedMessages.cjs +17 -2
  248. package/dist/chat/StatewireQueuedMessages.cjs.map +1 -1
  249. package/dist/chat/StatewireQueuedMessages.d.ts +8 -45
  250. package/dist/chat/StatewireQueuedMessages.js +18 -3
  251. package/dist/chat/StatewireQueuedMessages.js.map +1 -1
  252. package/dist/chat/chat-agent-mentions.cjs +70 -0
  253. package/dist/chat/chat-agent-mentions.cjs.map +1 -0
  254. package/dist/chat/chat-agent-mentions.d.ts +13 -0
  255. package/dist/chat/chat-agent-mentions.js +70 -0
  256. package/dist/chat/chat-agent-mentions.js.map +1 -0
  257. package/dist/chat/composer-actions.cjs +12 -0
  258. package/dist/chat/composer-actions.cjs.map +1 -0
  259. package/dist/chat/composer-actions.d.ts +22 -0
  260. package/dist/chat/composer-actions.js +12 -0
  261. package/dist/chat/composer-actions.js.map +1 -0
  262. package/dist/chat/follow-up-suggestions.cjs +185 -0
  263. package/dist/chat/follow-up-suggestions.cjs.map +1 -0
  264. package/dist/chat/follow-up-suggestions.d.ts +64 -0
  265. package/dist/chat/follow-up-suggestions.js +185 -0
  266. package/dist/chat/follow-up-suggestions.js.map +1 -0
  267. package/dist/chat/super-grouping/ToolTimeline.cjs +4 -3
  268. package/dist/chat/super-grouping/ToolTimeline.cjs.map +1 -1
  269. package/dist/chat/super-grouping/ToolTimeline.d.ts +7 -3
  270. package/dist/chat/super-grouping/ToolTimeline.js +4 -3
  271. package/dist/chat/super-grouping/ToolTimeline.js.map +1 -1
  272. package/dist/chat/turn-changes.cjs +284 -0
  273. package/dist/chat/turn-changes.cjs.map +1 -0
  274. package/dist/chat/turn-changes.d.ts +130 -0
  275. package/dist/chat/turn-changes.js +284 -0
  276. package/dist/chat/turn-changes.js.map +1 -0
  277. package/dist/chat/typed-interrupts/StatewireTypedInterruptCard.cjs +31 -0
  278. package/dist/chat/typed-interrupts/StatewireTypedInterruptCard.cjs.map +1 -0
  279. package/dist/chat/typed-interrupts/StatewireTypedInterruptCard.d.ts +31 -0
  280. package/dist/chat/typed-interrupts/StatewireTypedInterruptCard.js +31 -0
  281. package/dist/chat/typed-interrupts/StatewireTypedInterruptCard.js.map +1 -0
  282. package/dist/chat/typed-interrupts/approval-cards.cjs +250 -0
  283. package/dist/chat/typed-interrupts/approval-cards.cjs.map +1 -0
  284. package/dist/chat/typed-interrupts/approval-cards.d.ts +22 -0
  285. package/dist/chat/typed-interrupts/approval-cards.js +250 -0
  286. package/dist/chat/typed-interrupts/approval-cards.js.map +1 -0
  287. package/dist/chat/typed-interrupts/form-cards.cjs +289 -0
  288. package/dist/chat/typed-interrupts/form-cards.cjs.map +1 -0
  289. package/dist/chat/typed-interrupts/form-cards.d.ts +6 -0
  290. package/dist/chat/typed-interrupts/form-cards.js +289 -0
  291. package/dist/chat/typed-interrupts/form-cards.js.map +1 -0
  292. package/dist/chat/typed-interrupts/interrupt-card-shell.cjs +182 -0
  293. package/dist/chat/typed-interrupts/interrupt-card-shell.cjs.map +1 -0
  294. package/dist/chat/typed-interrupts/interrupt-card-shell.d.ts +47 -0
  295. package/dist/chat/typed-interrupts/interrupt-card-shell.js +182 -0
  296. package/dist/chat/typed-interrupts/interrupt-card-shell.js.map +1 -0
  297. package/dist/chat/typed-interrupts/json-schema-form.cjs +388 -0
  298. package/dist/chat/typed-interrupts/json-schema-form.cjs.map +1 -0
  299. package/dist/chat/typed-interrupts/json-schema-form.d.ts +33 -0
  300. package/dist/chat/typed-interrupts/json-schema-form.js +388 -0
  301. package/dist/chat/typed-interrupts/json-schema-form.js.map +1 -0
  302. package/dist/chat/typed-interrupts/questionnaire-card.cjs +449 -0
  303. package/dist/chat/typed-interrupts/questionnaire-card.cjs.map +1 -0
  304. package/dist/chat/typed-interrupts/questionnaire-card.d.ts +20 -0
  305. package/dist/chat/typed-interrupts/questionnaire-card.js +449 -0
  306. package/dist/chat/typed-interrupts/questionnaire-card.js.map +1 -0
  307. package/dist/chat/typed-interrupts/request-file-card.cjs +159 -0
  308. package/dist/chat/typed-interrupts/request-file-card.cjs.map +1 -0
  309. package/dist/chat/typed-interrupts/request-file-card.d.ts +2 -0
  310. package/dist/chat/typed-interrupts/request-file-card.js +159 -0
  311. package/dist/chat/typed-interrupts/request-file-card.js.map +1 -0
  312. package/dist/chat/typed-interrupts/toolkit-selection-card.cjs +189 -0
  313. package/dist/chat/typed-interrupts/toolkit-selection-card.cjs.map +1 -0
  314. package/dist/chat/typed-interrupts/toolkit-selection-card.d.ts +23 -0
  315. package/dist/chat/typed-interrupts/toolkit-selection-card.js +189 -0
  316. package/dist/chat/typed-interrupts/toolkit-selection-card.js.map +1 -0
  317. package/dist/chat/typed-interrupts/typed-interrupt-body.cjs +26 -0
  318. package/dist/chat/typed-interrupts/typed-interrupt-body.cjs.map +1 -0
  319. package/dist/chat/typed-interrupts/typed-interrupt-body.d.ts +3 -0
  320. package/dist/chat/typed-interrupts/typed-interrupt-body.js +26 -0
  321. package/dist/chat/typed-interrupts/typed-interrupt-body.js.map +1 -0
  322. package/dist/chat/typed-interrupts/typed-interrupt-graphql.cjs +105 -0
  323. package/dist/chat/typed-interrupts/typed-interrupt-graphql.cjs.map +1 -0
  324. package/dist/chat/typed-interrupts/typed-interrupt-graphql.d.ts +29 -0
  325. package/dist/chat/typed-interrupts/typed-interrupt-graphql.js +105 -0
  326. package/dist/chat/typed-interrupts/typed-interrupt-graphql.js.map +1 -0
  327. package/dist/chat/typed-interrupts/typed-interrupt-notice.cjs +70 -0
  328. package/dist/chat/typed-interrupts/typed-interrupt-notice.cjs.map +1 -0
  329. package/dist/chat/typed-interrupts/typed-interrupt-notice.d.ts +45 -0
  330. package/dist/chat/typed-interrupts/typed-interrupt-notice.js +70 -0
  331. package/dist/chat/typed-interrupts/typed-interrupt-notice.js.map +1 -0
  332. package/dist/chat/typed-interrupts/typed-interrupt-panel.cjs +76 -0
  333. package/dist/chat/typed-interrupts/typed-interrupt-panel.cjs.map +1 -0
  334. package/dist/chat/typed-interrupts/typed-interrupt-panel.d.ts +11 -0
  335. package/dist/chat/typed-interrupts/typed-interrupt-panel.js +76 -0
  336. package/dist/chat/typed-interrupts/typed-interrupt-panel.js.map +1 -0
  337. package/dist/chat/typed-interrupts/typed-interrupt-types.d.ts +46 -0
  338. package/dist/chat/typed-interrupts/use-interrupt-draft.cjs +106 -0
  339. package/dist/chat/typed-interrupts/use-interrupt-draft.cjs.map +1 -0
  340. package/dist/chat/typed-interrupts/use-interrupt-draft.d.ts +29 -0
  341. package/dist/chat/typed-interrupts/use-interrupt-draft.js +106 -0
  342. package/dist/chat/typed-interrupts/use-interrupt-draft.js.map +1 -0
  343. package/dist/chat/typed-interrupts/use-statewire-typed-interrupt.cjs +231 -0
  344. package/dist/chat/typed-interrupts/use-statewire-typed-interrupt.cjs.map +1 -0
  345. package/dist/chat/typed-interrupts/use-statewire-typed-interrupt.d.ts +66 -0
  346. package/dist/chat/typed-interrupts/use-statewire-typed-interrupt.js +231 -0
  347. package/dist/chat/typed-interrupts/use-statewire-typed-interrupt.js.map +1 -0
  348. package/dist/chat-ui/composer/composer-named-agents.cjs +13 -0
  349. package/dist/chat-ui/composer/composer-named-agents.cjs.map +1 -0
  350. package/dist/chat-ui/composer/composer-named-agents.d.ts +20 -0
  351. package/dist/chat-ui/composer/composer-named-agents.js +13 -0
  352. package/dist/chat-ui/composer/composer-named-agents.js.map +1 -0
  353. package/dist/chat-ui/composer/slash-command-menu.cjs +143 -0
  354. package/dist/chat-ui/composer/slash-command-menu.cjs.map +1 -0
  355. package/dist/chat-ui/composer/slash-command-menu.d.ts +19 -0
  356. package/dist/chat-ui/composer/slash-command-menu.js +143 -0
  357. package/dist/chat-ui/composer/slash-command-menu.js.map +1 -0
  358. package/dist/chat-ui/composer/slash-commands-extension.cjs +51 -0
  359. package/dist/chat-ui/composer/slash-commands-extension.cjs.map +1 -0
  360. package/dist/chat-ui/composer/slash-commands-extension.d.ts +39 -0
  361. package/dist/chat-ui/composer/slash-commands-extension.js +51 -0
  362. package/dist/chat-ui/composer/slash-commands-extension.js.map +1 -0
  363. package/dist/chat-ui/composer/slash-commands.cjs +74 -0
  364. package/dist/chat-ui/composer/slash-commands.cjs.map +1 -0
  365. package/dist/chat-ui/composer/slash-commands.d.ts +82 -0
  366. package/dist/chat-ui/composer/slash-commands.js +74 -0
  367. package/dist/chat-ui/composer/slash-commands.js.map +1 -0
  368. package/dist/chat-ui/composer/tiptap-composer.cjs +135 -9
  369. package/dist/chat-ui/composer/tiptap-composer.cjs.map +1 -1
  370. package/dist/chat-ui/composer/tiptap-composer.d.ts +61 -2
  371. package/dist/chat-ui/composer/tiptap-composer.js +135 -9
  372. package/dist/chat-ui/composer/tiptap-composer.js.map +1 -1
  373. package/dist/chat-ui/index.cjs +3 -0
  374. package/dist/chat-ui/index.cjs.map +1 -1
  375. package/dist/chat-ui/index.d.ts +3 -2
  376. package/dist/chat-ui/index.js +3 -0
  377. package/dist/chat-ui/index.js.map +1 -1
  378. package/dist/chat-ui/mentions/mention-chip.cjs +1 -1
  379. package/dist/chat-ui/mentions/mention-chip.cjs.map +1 -1
  380. package/dist/chat-ui/mentions/mention-chip.js +2 -2
  381. package/dist/chat-ui/mentions/mention-chip.js.map +1 -1
  382. package/dist/chat-ui/mentions/mention-extension.cjs +8 -1
  383. package/dist/chat-ui/mentions/mention-extension.cjs.map +1 -1
  384. package/dist/chat-ui/mentions/mention-extension.js +8 -1
  385. package/dist/chat-ui/mentions/mention-extension.js.map +1 -1
  386. package/dist/chat-ui/mentions/suggestions/components/get-scope-name.cjs +1 -0
  387. package/dist/chat-ui/mentions/suggestions/components/get-scope-name.cjs.map +1 -1
  388. package/dist/chat-ui/mentions/suggestions/components/get-scope-name.js +1 -0
  389. package/dist/chat-ui/mentions/suggestions/components/get-scope-name.js.map +1 -1
  390. package/dist/chat-ui/mentions/suggestions/components/mention-icon.cjs +2 -0
  391. package/dist/chat-ui/mentions/suggestions/components/mention-icon.cjs.map +1 -1
  392. package/dist/chat-ui/mentions/suggestions/components/mention-icon.js +3 -1
  393. package/dist/chat-ui/mentions/suggestions/components/mention-icon.js.map +1 -1
  394. package/dist/chat-ui/mentions/suggestions/components/menu-item.cjs +1 -1
  395. package/dist/chat-ui/mentions/suggestions/components/menu-item.cjs.map +1 -1
  396. package/dist/chat-ui/mentions/suggestions/components/menu-item.js +1 -1
  397. package/dist/chat-ui/mentions/suggestions/components/menu-item.js.map +1 -1
  398. package/dist/chat-ui/mentions/suggestions/data/api-client.cjs +36 -0
  399. package/dist/chat-ui/mentions/suggestions/data/api-client.cjs.map +1 -1
  400. package/dist/chat-ui/mentions/suggestions/data/api-client.d.ts +42 -0
  401. package/dist/chat-ui/mentions/suggestions/data/api-client.js +36 -0
  402. package/dist/chat-ui/mentions/suggestions/data/api-client.js.map +1 -1
  403. package/dist/chat-ui/mentions/suggestions/data/sources/index.cjs +235 -19
  404. package/dist/chat-ui/mentions/suggestions/data/sources/index.cjs.map +1 -1
  405. package/dist/chat-ui/mentions/suggestions/data/sources/index.d.ts +88 -10
  406. package/dist/chat-ui/mentions/suggestions/data/sources/index.js +236 -20
  407. package/dist/chat-ui/mentions/suggestions/data/sources/index.js.map +1 -1
  408. package/dist/chat-ui/mentions/suggestions/data/types.cjs.map +1 -1
  409. package/dist/chat-ui/mentions/suggestions/data/types.d.ts +27 -1
  410. package/dist/chat-ui/mentions/suggestions/data/types.js.map +1 -1
  411. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.cjs +56 -5
  412. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.cjs.map +1 -1
  413. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.d.ts +26 -6
  414. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.js +57 -6
  415. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.js.map +1 -1
  416. package/dist/chat-ui/mentions/suggestions/mention-suggestions.extension.cjs +34 -17
  417. package/dist/chat-ui/mentions/suggestions/mention-suggestions.extension.cjs.map +1 -1
  418. package/dist/chat-ui/mentions/suggestions/mention-suggestions.extension.d.ts +19 -1
  419. package/dist/chat-ui/mentions/suggestions/mention-suggestions.extension.js +35 -18
  420. package/dist/chat-ui/mentions/suggestions/mention-suggestions.extension.js.map +1 -1
  421. package/dist/chat-ui/statewire.d.ts +1 -1
  422. package/dist/chat-ui/thread/statewire-history-edge.cjs +15 -0
  423. package/dist/chat-ui/thread/statewire-history-edge.cjs.map +1 -1
  424. package/dist/chat-ui/thread/statewire-history-edge.d.ts +4 -1
  425. package/dist/chat-ui/thread/statewire-history-edge.js +15 -0
  426. package/dist/chat-ui/thread/statewire-history-edge.js.map +1 -1
  427. package/dist/collab/client.cjs +17 -5
  428. package/dist/collab/client.cjs.map +1 -1
  429. package/dist/collab/client.d.ts +22 -7
  430. package/dist/collab/client.js +17 -5
  431. package/dist/collab/client.js.map +1 -1
  432. package/dist/composer/ComposerAttachedReferences.cjs +119 -0
  433. package/dist/composer/ComposerAttachedReferences.cjs.map +1 -0
  434. package/dist/composer/ComposerAttachedReferences.d.ts +26 -0
  435. package/dist/composer/ComposerAttachedReferences.js +119 -0
  436. package/dist/composer/ComposerAttachedReferences.js.map +1 -0
  437. package/dist/composer/ComposerNamedAgents.cjs +63 -0
  438. package/dist/composer/ComposerNamedAgents.cjs.map +1 -0
  439. package/dist/composer/ComposerNamedAgents.d.ts +16 -0
  440. package/dist/composer/ComposerNamedAgents.js +63 -0
  441. package/dist/composer/ComposerNamedAgents.js.map +1 -0
  442. package/dist/composer/attached-references.cjs +159 -0
  443. package/dist/composer/attached-references.cjs.map +1 -0
  444. package/dist/composer/attached-references.d.ts +86 -0
  445. package/dist/composer/attached-references.js +159 -0
  446. package/dist/composer/attached-references.js.map +1 -0
  447. package/dist/composer/build-composed-message.cjs +14 -7
  448. package/dist/composer/build-composed-message.cjs.map +1 -1
  449. package/dist/composer/build-composed-message.d.ts +6 -1
  450. package/dist/composer/build-composed-message.js +14 -7
  451. package/dist/composer/build-composed-message.js.map +1 -1
  452. package/dist/composer/composer-handoff.cjs +6 -2
  453. package/dist/composer/composer-handoff.cjs.map +1 -1
  454. package/dist/composer/composer-handoff.d.ts +7 -1
  455. package/dist/composer/composer-handoff.js +6 -2
  456. package/dist/composer/composer-handoff.js.map +1 -1
  457. package/dist/composer/folder-upload.cjs +149 -0
  458. package/dist/composer/folder-upload.cjs.map +1 -0
  459. package/dist/composer/folder-upload.d.ts +79 -0
  460. package/dist/composer/folder-upload.js +149 -0
  461. package/dist/composer/folder-upload.js.map +1 -0
  462. package/dist/composer/index.d.ts +1 -1
  463. package/dist/composer/useAttachToChat.cjs +35 -0
  464. package/dist/composer/useAttachToChat.cjs.map +1 -0
  465. package/dist/composer/useAttachToChat.d.ts +54 -0
  466. package/dist/composer/useAttachToChat.js +35 -0
  467. package/dist/composer/useAttachToChat.js.map +1 -0
  468. package/dist/composer/useAttachedReferencesComposerProps.cjs +19 -0
  469. package/dist/composer/useAttachedReferencesComposerProps.cjs.map +1 -0
  470. package/dist/composer/useAttachedReferencesComposerProps.d.ts +12 -0
  471. package/dist/composer/useAttachedReferencesComposerProps.js +19 -0
  472. package/dist/composer/useAttachedReferencesComposerProps.js.map +1 -0
  473. package/dist/composer/useFileUpload.cjs +95 -7
  474. package/dist/composer/useFileUpload.cjs.map +1 -1
  475. package/dist/composer/useFileUpload.d.ts +21 -2
  476. package/dist/composer/useFileUpload.js +95 -7
  477. package/dist/composer/useFileUpload.js.map +1 -1
  478. package/dist/data/athena-api-error.cjs +125 -0
  479. package/dist/data/athena-api-error.cjs.map +1 -0
  480. package/dist/data/athena-api-error.d.ts +96 -0
  481. package/dist/data/athena-api-error.js +125 -0
  482. package/dist/data/athena-api-error.js.map +1 -0
  483. package/dist/data/athena-data-client.cjs +106 -0
  484. package/dist/data/athena-data-client.cjs.map +1 -0
  485. package/dist/data/athena-data-client.d.ts +74 -0
  486. package/dist/data/athena-data-client.js +106 -0
  487. package/dist/data/athena-data-client.js.map +1 -0
  488. package/dist/data/athena-member.cjs +93 -0
  489. package/dist/data/athena-member.cjs.map +1 -0
  490. package/dist/data/athena-member.d.ts +125 -0
  491. package/dist/data/athena-member.js +93 -0
  492. package/dist/data/athena-member.js.map +1 -0
  493. package/dist/data/athena-request.cjs +458 -0
  494. package/dist/data/athena-request.cjs.map +1 -0
  495. package/dist/data/athena-request.d.ts +120 -0
  496. package/dist/data/athena-request.js +458 -0
  497. package/dist/data/athena-request.js.map +1 -0
  498. package/dist/data/use-athena-fetch.cjs +14 -0
  499. package/dist/data/use-athena-fetch.cjs.map +1 -0
  500. package/dist/data/use-athena-fetch.d.ts +19 -0
  501. package/dist/data/use-athena-fetch.js +14 -0
  502. package/dist/data/use-athena-fetch.js.map +1 -0
  503. package/dist/data/use-athena-graphql.cjs +66 -0
  504. package/dist/data/use-athena-graphql.cjs.map +1 -0
  505. package/dist/data/use-athena-graphql.d.ts +56 -0
  506. package/dist/data/use-athena-graphql.js +66 -0
  507. package/dist/data/use-athena-graphql.js.map +1 -0
  508. package/dist/data/use-athena-rest.cjs +33 -0
  509. package/dist/data/use-athena-rest.cjs.map +1 -0
  510. package/dist/data/use-athena-rest.d.ts +21 -0
  511. package/dist/data/use-athena-rest.js +33 -0
  512. package/dist/data/use-athena-rest.js.map +1 -0
  513. package/dist/data/use-semantic-query.cjs +44 -0
  514. package/dist/data/use-semantic-query.cjs.map +1 -0
  515. package/dist/data/use-semantic-query.d.ts +92 -0
  516. package/dist/data/use-semantic-query.js +44 -0
  517. package/dist/data/use-semantic-query.js.map +1 -0
  518. package/dist/diagnostics/athena-diagnostics.cjs.map +1 -1
  519. package/dist/diagnostics/athena-diagnostics.d.ts +5 -1
  520. package/dist/diagnostics/athena-diagnostics.js.map +1 -1
  521. package/dist/diagnostics/errors.cjs +7 -0
  522. package/dist/diagnostics/errors.cjs.map +1 -1
  523. package/dist/diagnostics/errors.d.ts +7 -0
  524. package/dist/diagnostics/errors.js +7 -0
  525. package/dist/diagnostics/errors.js.map +1 -1
  526. package/dist/index.cjs +155 -11
  527. package/dist/index.cjs.map +1 -1
  528. package/dist/index.d.ts +72 -13
  529. package/dist/index.js +148 -4
  530. package/dist/index.js.map +1 -1
  531. package/dist/keryx-http/src/initial-sync.cjs +64 -16
  532. package/dist/keryx-http/src/initial-sync.cjs.map +1 -1
  533. package/dist/keryx-http/src/initial-sync.d.ts +31 -1
  534. package/dist/keryx-http/src/initial-sync.js +64 -16
  535. package/dist/keryx-http/src/initial-sync.js.map +1 -1
  536. package/dist/keryx-http/src/own-awareness.cjs +20 -0
  537. package/dist/keryx-http/src/own-awareness.cjs.map +1 -0
  538. package/dist/keryx-http/src/own-awareness.d.ts +50 -0
  539. package/dist/keryx-http/src/own-awareness.js +20 -0
  540. package/dist/keryx-http/src/own-awareness.js.map +1 -0
  541. package/dist/keryx-http/src/update-attributions.cjs +26 -1
  542. package/dist/keryx-http/src/update-attributions.cjs.map +1 -1
  543. package/dist/keryx-http/src/update-attributions.d.ts +10 -1
  544. package/dist/keryx-http/src/update-attributions.js +26 -1
  545. package/dist/keryx-http/src/update-attributions.js.map +1 -1
  546. package/dist/offline/chat-outbox.cjs +262 -26
  547. package/dist/offline/chat-outbox.cjs.map +1 -1
  548. package/dist/offline/chat-outbox.d.ts +90 -12
  549. package/dist/offline/chat-outbox.js +263 -27
  550. package/dist/offline/chat-outbox.js.map +1 -1
  551. package/dist/provider/AthenaProvider.cjs +63 -19
  552. package/dist/provider/AthenaProvider.cjs.map +1 -1
  553. package/dist/provider/AthenaProvider.d.ts +24 -8
  554. package/dist/provider/AthenaProvider.js +66 -22
  555. package/dist/provider/AthenaProvider.js.map +1 -1
  556. package/dist/react/package.json.cjs +1 -1
  557. package/dist/react/package.json.js +1 -1
  558. package/dist/references/src/anchors/types.cjs +5 -0
  559. package/dist/references/src/anchors/types.cjs.map +1 -1
  560. package/dist/references/src/anchors/types.js +5 -0
  561. package/dist/references/src/anchors/types.js.map +1 -1
  562. package/dist/references/src/attachable.cjs +149 -0
  563. package/dist/references/src/attachable.cjs.map +1 -0
  564. package/dist/references/src/attachable.d.ts +87 -0
  565. package/dist/references/src/attachable.js +149 -0
  566. package/dist/references/src/attachable.js.map +1 -0
  567. package/dist/runtime/StatewirePlanModeLaneSync.cjs +93 -0
  568. package/dist/runtime/StatewirePlanModeLaneSync.cjs.map +1 -0
  569. package/dist/runtime/StatewirePlanModeLaneSync.d.ts +34 -0
  570. package/dist/runtime/StatewirePlanModeLaneSync.js +93 -0
  571. package/dist/runtime/StatewirePlanModeLaneSync.js.map +1 -0
  572. package/dist/runtime/StatewireThreadConfigLaneSync.cjs +2 -0
  573. package/dist/runtime/StatewireThreadConfigLaneSync.cjs.map +1 -1
  574. package/dist/runtime/StatewireThreadConfigLaneSync.d.ts +4 -0
  575. package/dist/runtime/StatewireThreadConfigLaneSync.js +2 -0
  576. package/dist/runtime/StatewireThreadConfigLaneSync.js.map +1 -1
  577. package/dist/runtime/statewire-plan-mode.cjs +71 -0
  578. package/dist/runtime/statewire-plan-mode.cjs.map +1 -0
  579. package/dist/runtime/statewire-plan-mode.d.ts +88 -0
  580. package/dist/runtime/statewire-plan-mode.js +71 -0
  581. package/dist/runtime/statewire-plan-mode.js.map +1 -0
  582. package/dist/runtime/statewire-run-config.cjs +18 -1
  583. package/dist/runtime/statewire-run-config.cjs.map +1 -1
  584. package/dist/runtime/statewire-run-config.d.ts +20 -0
  585. package/dist/runtime/statewire-run-config.js +18 -1
  586. package/dist/runtime/statewire-run-config.js.map +1 -1
  587. package/dist/runtime/statewire-session-key.cjs +11 -5
  588. package/dist/runtime/statewire-session-key.cjs.map +1 -1
  589. package/dist/runtime/statewire-session-key.d.ts +22 -10
  590. package/dist/runtime/statewire-session-key.js +11 -5
  591. package/dist/runtime/statewire-session-key.js.map +1 -1
  592. package/dist/runtime/useAthenaStatewireRuntime.cjs +65 -8
  593. package/dist/runtime/useAthenaStatewireRuntime.cjs.map +1 -1
  594. package/dist/runtime/useAthenaStatewireRuntime.d.ts +26 -10
  595. package/dist/runtime/useAthenaStatewireRuntime.js +67 -10
  596. package/dist/runtime/useAthenaStatewireRuntime.js.map +1 -1
  597. package/dist/search/useAthenaAssets.cjs +394 -0
  598. package/dist/search/useAthenaAssets.cjs.map +1 -0
  599. package/dist/search/useAthenaAssets.d.ts +186 -0
  600. package/dist/search/useAthenaAssets.js +394 -0
  601. package/dist/search/useAthenaAssets.js.map +1 -0
  602. package/dist/sheet-range/index.cjs +4 -0
  603. package/dist/sheet-range/index.cjs.map +1 -1
  604. package/dist/sheet-range/index.d.ts +4 -2
  605. package/dist/sheet-range/index.js +4 -0
  606. package/dist/sheet-range/index.js.map +1 -1
  607. package/dist/sheet-range/query-range.cjs +102 -0
  608. package/dist/sheet-range/query-range.cjs.map +1 -0
  609. package/dist/sheet-range/query-range.d.ts +46 -0
  610. package/dist/sheet-range/query-range.js +102 -0
  611. package/dist/sheet-range/query-range.js.map +1 -0
  612. package/dist/styles.css +1 -1
  613. package/dist/subagents/index.cjs +49 -0
  614. package/dist/subagents/index.cjs.map +1 -0
  615. package/dist/subagents/index.d.ts +16 -0
  616. package/dist/subagents/index.js +49 -0
  617. package/dist/subagents/index.js.map +1 -0
  618. package/dist/subagents/lane-follow.cjs +19 -0
  619. package/dist/subagents/lane-follow.cjs.map +1 -0
  620. package/dist/subagents/lane-follow.d.ts +9 -0
  621. package/dist/subagents/lane-follow.js +19 -0
  622. package/dist/subagents/lane-follow.js.map +1 -0
  623. package/dist/subagents/lane-model.cjs +178 -0
  624. package/dist/subagents/lane-model.cjs.map +1 -0
  625. package/dist/subagents/lane-model.d.ts +140 -0
  626. package/dist/subagents/lane-model.js +178 -0
  627. package/dist/subagents/lane-model.js.map +1 -0
  628. package/dist/subagents/lane-parts.cjs +517 -0
  629. package/dist/subagents/lane-parts.cjs.map +1 -0
  630. package/dist/subagents/lane-parts.d.ts +130 -0
  631. package/dist/subagents/lane-parts.js +517 -0
  632. package/dist/subagents/lane-parts.js.map +1 -0
  633. package/dist/subagents/subagent-lane-group.cjs +215 -0
  634. package/dist/subagents/subagent-lane-group.cjs.map +1 -0
  635. package/dist/subagents/subagent-lane-group.d.ts +67 -0
  636. package/dist/subagents/subagent-lane-group.js +215 -0
  637. package/dist/subagents/subagent-lane-group.js.map +1 -0
  638. package/dist/subagents/subagent-transcript-drawer.cjs +431 -0
  639. package/dist/subagents/subagent-transcript-drawer.cjs.map +1 -0
  640. package/dist/subagents/subagent-transcript-drawer.d.ts +78 -0
  641. package/dist/subagents/subagent-transcript-drawer.js +431 -0
  642. package/dist/subagents/subagent-transcript-drawer.js.map +1 -0
  643. package/dist/subagents/task-subagent-group.cjs +115 -0
  644. package/dist/subagents/task-subagent-group.cjs.map +1 -0
  645. package/dist/subagents/task-subagent-group.d.ts +36 -0
  646. package/dist/subagents/task-subagent-group.js +115 -0
  647. package/dist/subagents/task-subagent-group.js.map +1 -0
  648. package/dist/subagents/use-omitted-images-in-view.cjs +68 -0
  649. package/dist/subagents/use-omitted-images-in-view.cjs.map +1 -0
  650. package/dist/subagents/use-omitted-images-in-view.d.ts +21 -0
  651. package/dist/subagents/use-omitted-images-in-view.js +68 -0
  652. package/dist/subagents/use-omitted-images-in-view.js.map +1 -0
  653. package/dist/threads/Inbox.cjs +2 -2
  654. package/dist/threads/Inbox.cjs.map +1 -1
  655. package/dist/threads/SessionList.cjs +27 -24
  656. package/dist/threads/SessionList.cjs.map +1 -1
  657. package/dist/threads/SessionList.js +22 -19
  658. package/dist/threads/SessionList.js.map +1 -1
  659. package/dist/threads/SessionsPage.cjs +13 -7
  660. package/dist/threads/SessionsPage.cjs.map +1 -1
  661. package/dist/threads/SessionsPage.d.ts +10 -1
  662. package/dist/threads/SessionsPage.js +9 -3
  663. package/dist/threads/SessionsPage.js.map +1 -1
  664. package/dist/threads/live-session-rows.cjs +207 -0
  665. package/dist/threads/live-session-rows.cjs.map +1 -0
  666. package/dist/threads/live-session-rows.d.ts +175 -0
  667. package/dist/threads/live-session-rows.js +207 -0
  668. package/dist/threads/live-session-rows.js.map +1 -0
  669. package/dist/threads/session-list-model.cjs.map +1 -1
  670. package/dist/threads/session-list-model.d.ts +2 -1
  671. package/dist/threads/session-list-model.js.map +1 -1
  672. package/dist/threads/session-row-parts.cjs +3 -3
  673. package/dist/threads/session-row-parts.cjs.map +1 -1
  674. package/dist/threads/sessions-page-model.cjs +13 -5
  675. package/dist/threads/sessions-page-model.cjs.map +1 -1
  676. package/dist/threads/sessions-page-model.d.ts +7 -0
  677. package/dist/threads/sessions-page-model.js +11 -3
  678. package/dist/threads/sessions-page-model.js.map +1 -1
  679. package/dist/threads/sessions-page-storage.cjs +8 -8
  680. package/dist/threads/sessions-page-storage.cjs.map +1 -1
  681. package/dist/threads/sessions-page-storage.d.ts +5 -1
  682. package/dist/threads/sessions-page-storage.js +8 -8
  683. package/dist/threads/sessions-page-storage.js.map +1 -1
  684. package/dist/threads/statewire-thread-list.cjs +173 -20
  685. package/dist/threads/statewire-thread-list.cjs.map +1 -1
  686. package/dist/threads/statewire-thread-list.d.ts +44 -1
  687. package/dist/threads/statewire-thread-list.js +174 -21
  688. package/dist/threads/statewire-thread-list.js.map +1 -1
  689. package/dist/threads/use-athena-sessions.cjs +1 -0
  690. package/dist/threads/use-athena-sessions.cjs.map +1 -1
  691. package/dist/threads/use-athena-sessions.d.ts +7 -0
  692. package/dist/threads/use-athena-sessions.js +1 -0
  693. package/dist/threads/use-athena-sessions.js.map +1 -1
  694. package/dist/threads/use-athena-thread-agent.cjs +31 -0
  695. package/dist/threads/use-athena-thread-agent.cjs.map +1 -0
  696. package/dist/threads/use-athena-thread-agent.d.ts +38 -0
  697. package/dist/threads/use-athena-thread-agent.js +31 -0
  698. package/dist/threads/use-athena-thread-agent.js.map +1 -0
  699. package/dist/threads/use-athena-thread-plan-mode.cjs +18 -0
  700. package/dist/threads/use-athena-thread-plan-mode.cjs.map +1 -0
  701. package/dist/threads/use-athena-thread-plan-mode.d.ts +18 -0
  702. package/dist/threads/use-athena-thread-plan-mode.js +18 -0
  703. package/dist/threads/use-athena-thread-plan-mode.js.map +1 -0
  704. package/dist/threads/use-rest-conversation-history.d.ts +1 -0
  705. package/dist/tools/agent-creations.cjs +97 -0
  706. package/dist/tools/agent-creations.cjs.map +1 -0
  707. package/dist/tools/agent-creations.d.ts +38 -0
  708. package/dist/tools/agent-creations.js +97 -0
  709. package/dist/tools/agent-creations.js.map +1 -0
  710. package/dist/tools/agent-highlights.cjs +100 -0
  711. package/dist/tools/agent-highlights.cjs.map +1 -0
  712. package/dist/tools/agent-highlights.d.ts +57 -0
  713. package/dist/tools/agent-highlights.js +100 -0
  714. package/dist/tools/agent-highlights.js.map +1 -0
  715. package/dist/tools/append-document-tool-ui.cjs +1 -0
  716. package/dist/tools/append-document-tool-ui.cjs.map +1 -1
  717. package/dist/tools/append-document-tool-ui.d.ts +7 -0
  718. package/dist/tools/append-document-tool-ui.js +2 -1
  719. package/dist/tools/append-document-tool-ui.js.map +1 -1
  720. package/dist/tools/auto-open-tools.cjs +144 -71
  721. package/dist/tools/auto-open-tools.cjs.map +1 -1
  722. package/dist/tools/auto-open-tools.d.ts +131 -1
  723. package/dist/tools/auto-open-tools.js +145 -72
  724. package/dist/tools/auto-open-tools.js.map +1 -1
  725. package/dist/tools/browser-tool-uis.cjs +594 -0
  726. package/dist/tools/browser-tool-uis.cjs.map +1 -0
  727. package/dist/tools/browser-tool-uis.d.ts +8 -0
  728. package/dist/tools/browser-tool-uis.js +594 -0
  729. package/dist/tools/browser-tool-uis.js.map +1 -0
  730. package/dist/tools/computer-asset-tool-uis.cjs +313 -0
  731. package/dist/tools/computer-asset-tool-uis.cjs.map +1 -0
  732. package/dist/tools/computer-asset-tool-uis.d.ts +5 -0
  733. package/dist/tools/computer-asset-tool-uis.js +313 -0
  734. package/dist/tools/computer-asset-tool-uis.js.map +1 -0
  735. package/dist/tools/document-edit-tool-uis.cjs +218 -0
  736. package/dist/tools/document-edit-tool-uis.cjs.map +1 -0
  737. package/dist/tools/document-edit-tool-uis.d.ts +40 -0
  738. package/dist/tools/document-edit-tool-uis.js +218 -0
  739. package/dist/tools/document-edit-tool-uis.js.map +1 -0
  740. package/dist/tools/drive-tool-uis.cjs +425 -0
  741. package/dist/tools/drive-tool-uis.cjs.map +1 -0
  742. package/dist/tools/drive-tool-uis.d.ts +120 -0
  743. package/dist/tools/drive-tool-uis.js +425 -0
  744. package/dist/tools/drive-tool-uis.js.map +1 -0
  745. package/dist/tools/email-calendar-tool-uis.cjs +789 -0
  746. package/dist/tools/email-calendar-tool-uis.cjs.map +1 -0
  747. package/dist/tools/email-calendar-tool-uis.d.ts +129 -0
  748. package/dist/tools/email-calendar-tool-uis.js +789 -0
  749. package/dist/tools/email-calendar-tool-uis.js.map +1 -0
  750. package/dist/tools/ontology-tool-uis.cjs +83 -0
  751. package/dist/tools/ontology-tool-uis.cjs.map +1 -0
  752. package/dist/tools/ontology-tool-uis.d.ts +9 -0
  753. package/dist/tools/ontology-tool-uis.js +83 -0
  754. package/dist/tools/ontology-tool-uis.js.map +1 -0
  755. package/dist/tools/orchestration-tool-uis.cjs +586 -0
  756. package/dist/tools/orchestration-tool-uis.cjs.map +1 -0
  757. package/dist/tools/orchestration-tool-uis.d.ts +141 -0
  758. package/dist/tools/orchestration-tool-uis.js +586 -0
  759. package/dist/tools/orchestration-tool-uis.js.map +1 -0
  760. package/dist/tools/presentation-edit-tool-uis.cjs +516 -0
  761. package/dist/tools/presentation-edit-tool-uis.cjs.map +1 -0
  762. package/dist/tools/presentation-edit-tool-uis.d.ts +73 -0
  763. package/dist/tools/presentation-edit-tool-uis.js +516 -0
  764. package/dist/tools/presentation-edit-tool-uis.js.map +1 -0
  765. package/dist/tools/project-tool-uis.cjs +213 -0
  766. package/dist/tools/project-tool-uis.cjs.map +1 -0
  767. package/dist/tools/project-tool-uis.d.ts +14 -0
  768. package/dist/tools/project-tool-uis.js +213 -0
  769. package/dist/tools/project-tool-uis.js.map +1 -0
  770. package/dist/tools/sandbox-tool-uis.cjs +491 -0
  771. package/dist/tools/sandbox-tool-uis.cjs.map +1 -0
  772. package/dist/tools/sandbox-tool-uis.d.ts +116 -0
  773. package/dist/tools/sandbox-tool-uis.js +491 -0
  774. package/dist/tools/sandbox-tool-uis.js.map +1 -0
  775. package/dist/tools/sheet-query-tool-ui.cjs +138 -0
  776. package/dist/tools/sheet-query-tool-ui.cjs.map +1 -0
  777. package/dist/tools/sheet-query-tool-ui.d.ts +15 -0
  778. package/dist/tools/sheet-query-tool-ui.js +138 -0
  779. package/dist/tools/sheet-query-tool-ui.js.map +1 -0
  780. package/dist/tools/studio-screenshot-tool-uis.cjs +262 -0
  781. package/dist/tools/studio-screenshot-tool-uis.cjs.map +1 -0
  782. package/dist/tools/studio-screenshot-tool-uis.d.ts +52 -0
  783. package/dist/tools/studio-screenshot-tool-uis.js +262 -0
  784. package/dist/tools/studio-screenshot-tool-uis.js.map +1 -0
  785. package/dist/tools/subagent-task-tool-ui.cjs +24 -475
  786. package/dist/tools/subagent-task-tool-ui.cjs.map +1 -1
  787. package/dist/tools/subagent-task-tool-ui.d.ts +19 -103
  788. package/dist/tools/subagent-task-tool-ui.js +28 -479
  789. package/dist/tools/subagent-task-tool-ui.js.map +1 -1
  790. package/dist/tools/tool-summary.cjs +36 -0
  791. package/dist/tools/tool-summary.cjs.map +1 -1
  792. package/dist/tools/tool-summary.js +36 -0
  793. package/dist/tools/tool-summary.js.map +1 -1
  794. package/dist/tools/tool-uis.cjs +181 -53
  795. package/dist/tools/tool-uis.cjs.map +1 -1
  796. package/dist/tools/tool-uis.d.ts +40 -0
  797. package/dist/tools/tool-uis.js +183 -55
  798. package/dist/tools/tool-uis.js.map +1 -1
  799. package/dist/typed-interrupts/index.cjs +15 -0
  800. package/dist/typed-interrupts/index.cjs.map +1 -0
  801. package/dist/typed-interrupts/index.d.ts +20 -0
  802. package/dist/typed-interrupts/index.js +15 -0
  803. package/dist/typed-interrupts/index.js.map +1 -0
  804. package/dist/workbench/session-workbench-panes.cjs +6 -6
  805. package/dist/workbench/session-workbench-panes.cjs.map +1 -1
  806. package/package.json +28 -6
  807. package/dist/agent-runtime/src/chat-outbox-store.cjs +0 -510
  808. package/dist/agent-runtime/src/chat-outbox-store.cjs.map +0 -1
  809. package/dist/agent-runtime/src/chat-outbox-store.d.ts +0 -210
  810. package/dist/agent-runtime/src/chat-outbox-store.js +0 -510
  811. package/dist/agent-runtime/src/chat-outbox-store.js.map +0 -1
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const reactStatewire = require("@assistant-ui/react-statewire");
4
+ const require$$0 = require("react");
5
+ const athenaDiagnostics = require("../diagnostics/athena-diagnostics.cjs");
6
+ const statewirePlanMode = require("./statewire-plan-mode.cjs");
7
+ const StatewireThreadConfigLaneSync = require("./StatewireThreadConfigLaneSync.cjs");
8
+ const useDeepAgentConfig = require("../agent-runtime/src/use-deep-agent-config.cjs");
9
+ const errors = require("../agent-runtime/src/errors.cjs");
10
+ function StatewirePlanModeLaneSync({
11
+ threadId,
12
+ planMode,
13
+ lane,
14
+ channelLive
15
+ }) {
16
+ const send = reactStatewire.useStatewireSendCommand();
17
+ const sendCommand = (command) => Promise.resolve(send(command));
18
+ const { configVersion, custom, patchConfig } = useDeepAgentConfig.useDeepAgentConfigController({
19
+ serverConfig: lane.config,
20
+ sendCommand
21
+ });
22
+ const seenRef = require$$0.useRef(planMode);
23
+ const pendingRef = require$$0.useRef(false);
24
+ const attemptsRef = require$$0.useRef(0);
25
+ const closedRef = require$$0.useRef(false);
26
+ const patchConfigRef = require$$0.useRef(patchConfig);
27
+ patchConfigRef.current = patchConfig;
28
+ const [retryTick, setRetryTick] = require$$0.useState(0);
29
+ const retryTimerRef = require$$0.useRef(null);
30
+ require$$0.useEffect(
31
+ () => () => {
32
+ if (retryTimerRef.current !== null) clearTimeout(retryTimerRef.current);
33
+ },
34
+ []
35
+ );
36
+ const landed = lane.landed;
37
+ require$$0.useEffect(() => {
38
+ if (planMode !== seenRef.current) {
39
+ seenRef.current = planMode;
40
+ pendingRef.current = planMode !== null;
41
+ attemptsRef.current = 0;
42
+ }
43
+ if (!pendingRef.current || planMode === null || closedRef.current || !channelLive) return;
44
+ const decision = statewirePlanMode.decidePlanModeLanePatch({ planMode, landed, configVersion, custom });
45
+ if (decision.kind === "wait") return;
46
+ pendingRef.current = false;
47
+ if (decision.kind === "done") return;
48
+ const { patch } = decision;
49
+ attemptsRef.current += 1;
50
+ const data = { thread_id: threadId, plan_mode: planMode, config_keys: Object.keys(patch) };
51
+ patchConfigRef.current(patch).catch((error) => {
52
+ if (useDeepAgentConfig.isConfigWriteForbiddenRejection(error) || useDeepAgentConfig.isConfigSyncUnavailableRejection(error)) {
53
+ closedRef.current = true;
54
+ athenaDiagnostics.athenaDiagnostics.emit("statewire.config", {
55
+ level: "warn",
56
+ data: {
57
+ ...data,
58
+ reason: useDeepAgentConfig.isConfigWriteForbiddenRejection(error) ? "config_write_forbidden" : "config_sync_unavailable"
59
+ }
60
+ });
61
+ return;
62
+ }
63
+ const outcome = errors.statewireTransportOutcome(error);
64
+ if (outcome !== null) {
65
+ athenaDiagnostics.athenaDiagnostics.emit("statewire.config", { level: "debug", data: { ...data, outcome } });
66
+ if (outcome === "unmount") return;
67
+ if (seenRef.current !== planMode) return;
68
+ const written = attemptsRef.current;
69
+ if (written >= StatewireThreadConfigLaneSync.MAX_PATCH_ATTEMPTS_PER_CHANGE) return;
70
+ pendingRef.current = true;
71
+ const delay = StatewireThreadConfigLaneSync.RETRY_BACKOFF_MS[Math.min(written - 1, StatewireThreadConfigLaneSync.RETRY_BACKOFF_MS.length - 1)];
72
+ retryTimerRef.current = setTimeout(() => {
73
+ retryTimerRef.current = null;
74
+ setRetryTick((tick) => tick + 1);
75
+ }, delay);
76
+ return;
77
+ }
78
+ athenaDiagnostics.athenaDiagnostics.error(
79
+ "statewire.config",
80
+ error,
81
+ {
82
+ code: "statewire_rejected",
83
+ message: "The statewire host refused the plan mode change",
84
+ hint: "Inspect error.detail: agora rejections carry a structured {code, message}. The thread keeps running with the plan mode its server config holds."
85
+ },
86
+ data
87
+ );
88
+ });
89
+ }, [planMode, landed, configVersion, custom, channelLive, retryTick, threadId]);
90
+ return null;
91
+ }
92
+ exports.StatewirePlanModeLaneSync = StatewirePlanModeLaneSync;
93
+ //# sourceMappingURL=StatewirePlanModeLaneSync.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StatewirePlanModeLaneSync.cjs","sources":["../../src/runtime/StatewirePlanModeLaneSync.tsx"],"sourcesContent":["import { useStatewireSendCommand } from '@assistant-ui/react-statewire';\nimport {\n type DeepAgentConfigControllerInputs,\n isConfigSyncUnavailableRejection,\n isConfigWriteForbiddenRejection,\n statewireTransportOutcome,\n useDeepAgentConfigController,\n} from '@athenaintel/agent-runtime';\nimport { useEffect, useRef, useState } from 'react';\nimport { athenaDiagnostics } from '../diagnostics/athena-diagnostics';\nimport { decidePlanModeLanePatch } from './statewire-plan-mode';\nimport type { AthenaStatewireServerLane } from './statewire-server-lane-context';\nimport { MAX_PATCH_ATTEMPTS_PER_CHANGE, RETRY_BACKOFF_MS } from './StatewireThreadConfigLaneSync';\n\n/**\n * Writes the provider's `planMode` to the thread's server config lane when the\n * host changes it during an attach, under the contract\n * `StatewireThreadConfigLaneSync` keeps for `model` and the other\n * provider-owned keys:\n *\n * - Only a CHANGE is written. The value an attach starts with is never written:\n * a thread opened elsewhere keeps the plan mode its own config holds.\n * - A change waits for the attach's snapshot and for the lane (version > 0). A\n * thread without a lane needs no write (the next send carries plan mode); the\n * change stays pending until a lane exists, so a lane an earlier send seeded\n * is corrected once it lands.\n * - The write is one `config/patch` of the exclusion lists that change,\n * computed from the lane's own lists (this client's pending writes folded\n * over), so a tool or middleware another client excluded stays excluded.\n * - A refusal that can never succeed (a view-only collaborator, a workspace\n * without server config) stops the writes for the attach and is reported on\n * the diagnostics bus; a write the channel dropped is written again after a\n * backoff, at most {@link MAX_PATCH_ATTEMPTS_PER_CHANGE} times per change.\n *\n * agora gates every `config/*` write on EDIT on the thread's session asset\n * (`_authorize_config_write`). Mounted beside `StatewireThreadConfigLaneSync`\n * under the runtime's `AuiProvider`, keyed by the thread, so each attach starts\n * with nothing pending.\n */\nexport function StatewirePlanModeLaneSync({\n threadId,\n planMode,\n lane,\n channelLive,\n}: {\n threadId: string;\n /** The provider's `planMode`, published with the thread it applies to; `null`: it sets none. */\n planMode: boolean | null;\n lane: AthenaStatewireServerLane;\n /** Whether the channel can take a command now; writes wait for it. */\n channelLive: boolean;\n}): null {\n const send = useStatewireSendCommand();\n const sendCommand: DeepAgentConfigControllerInputs['sendCommand'] = (command) =>\n Promise.resolve(send(command));\n const { configVersion, custom, patchConfig } = useDeepAgentConfigController({\n serverConfig: lane.config,\n sendCommand,\n });\n\n const seenRef = useRef(planMode);\n const pendingRef = useRef(false);\n const attemptsRef = useRef(0);\n const closedRef = useRef(false);\n const patchConfigRef = useRef(patchConfig);\n patchConfigRef.current = patchConfig;\n // Bumped (after a backoff) to re-run the effect for a write the channel dropped.\n const [retryTick, setRetryTick] = useState(0);\n const retryTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n useEffect(\n () => () => {\n if (retryTimerRef.current !== null) clearTimeout(retryTimerRef.current);\n },\n [],\n );\n const landed = lane.landed;\n\n useEffect(() => {\n if (planMode !== seenRef.current) {\n seenRef.current = planMode;\n // A host that stops setting plan mode leaves the thread's own as it is.\n pendingRef.current = planMode !== null;\n attemptsRef.current = 0;\n }\n if (!pendingRef.current || planMode === null || closedRef.current || !channelLive) return;\n const decision = decidePlanModeLanePatch({ planMode, landed, configVersion, custom });\n if (decision.kind === 'wait') return;\n pendingRef.current = false;\n if (decision.kind === 'done') return;\n\n const { patch } = decision;\n attemptsRef.current += 1;\n const data = { thread_id: threadId, plan_mode: planMode, config_keys: Object.keys(patch) };\n patchConfigRef.current(patch).catch((error: unknown) => {\n if (isConfigWriteForbiddenRejection(error) || isConfigSyncUnavailableRejection(error)) {\n closedRef.current = true;\n athenaDiagnostics.emit('statewire.config', {\n level: 'warn',\n data: {\n ...data,\n reason: isConfigWriteForbiddenRejection(error)\n ? 'config_write_forbidden'\n : 'config_sync_unavailable',\n },\n });\n return;\n }\n const outcome = statewireTransportOutcome(error);\n if (outcome !== null) {\n // Channel weather (a dropped stream, the host's expired verdict): write\n // the change again after a backoff, once the channel is live, unless the\n // host has moved on, the attach is gone or it was written enough.\n athenaDiagnostics.emit('statewire.config', { level: 'debug', data: { ...data, outcome } });\n if (outcome === 'unmount') return;\n if (seenRef.current !== planMode) return;\n const written = attemptsRef.current;\n if (written >= MAX_PATCH_ATTEMPTS_PER_CHANGE) return;\n pendingRef.current = true;\n const delay = RETRY_BACKOFF_MS[Math.min(written - 1, RETRY_BACKOFF_MS.length - 1)];\n retryTimerRef.current = setTimeout(() => {\n retryTimerRef.current = null;\n setRetryTick((tick) => tick + 1);\n }, delay);\n return;\n }\n athenaDiagnostics.error(\n 'statewire.config',\n error,\n {\n code: 'statewire_rejected',\n message: 'The statewire host refused the plan mode change',\n hint: 'Inspect error.detail: agora rejections carry a structured {code, message}. The thread keeps running with the plan mode its server config holds.',\n },\n data,\n );\n });\n }, [planMode, landed, configVersion, custom, channelLive, retryTick, threadId]);\n\n return null;\n}\n"],"names":["useStatewireSendCommand","useDeepAgentConfigController","useRef","useState","useEffect","decidePlanModeLanePatch","isConfigWriteForbiddenRejection","isConfigSyncUnavailableRejection","athenaDiagnostics","statewireTransportOutcome","MAX_PATCH_ATTEMPTS_PER_CHANGE","RETRY_BACKOFF_MS"],"mappings":";;;;;;;;;AAuCO,SAAS,0BAA0B;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAOS;AACP,QAAM,OAAOA,eAAAA,wBAAA;AACb,QAAM,cAA8D,CAAC,YACnE,QAAQ,QAAQ,KAAK,OAAO,CAAC;AAC/B,QAAM,EAAE,eAAe,QAAQ,YAAA,IAAgBC,mBAAAA,6BAA6B;AAAA,IAC1E,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AQF,mBAAAA,gCAAgC,KAAK,IACzC,2BACA;AAAA,UAAA;AAAA,QACN,CACD;AACD;AAAA,MACF;AACA,YAAM,UAAUG,OAAAA,0BAA0B,KAAK;AAC/C,UAAI,YAAY,MAAM;AAIpBD,0BAAAA,kBAAkB,KAAK,oBAAoB,EAAE,OAAO,SAAS,MAAM,EAAE,GAAG,MAAM,QAAA,GAAW;AACzF,YAAI,YAAY,UAAW;AAC3B,YAAI,QAAQ,YAAY,SAAU;AAClC,cAAM,UAAU,YAAY;AAC5B,YAAI,WAAWE,8BAAAA,8BAA+B;AAC9C,mBAAW,UAAU;AACrB,cAAM,QAAQC,+CAAiB,KAAK,IAAI,UAAU,GAAGA,8BAAAA,iBAAiB,SAAS,CAAC,CAAC;AACjF,sBAAc,UAAU,WAAW,MAAM;AACvC,wBAAc,UAAU;AACxB,uBAAa,CAAC,SAAS,OAAO,CAAC;AAAA,QACjC,GAAG,KAAK;AACR;AAAA,MACF;AACAH,wBAAAA,kBAAkB;AAAA,QAChB;AAAA,QACA;AAAA,QACA;AAAA,UACE,MAAM;AAAA,UACN,SAAS;AAAA,UACT,MAAM;AAAA,QAAA;AAAA,QAER;AAAA,MAAA;AAAA,IAEJ,CAAC;AAAA,EACH,GAAG,CAAC,UAAU,QAAQ,eAAe,QAAQ,aAAa,WAAW,QAAQ,CAAC;AAE9E,SAAO;AACT;;"}
@@ -0,0 +1,34 @@
1
+ import type { AthenaStatewireServerLane } from './statewire-server-lane-context';
2
+ /**
3
+ * Writes the provider's `planMode` to the thread's server config lane when the
4
+ * host changes it during an attach, under the contract
5
+ * `StatewireThreadConfigLaneSync` keeps for `model` and the other
6
+ * provider-owned keys:
7
+ *
8
+ * - Only a CHANGE is written. The value an attach starts with is never written:
9
+ * a thread opened elsewhere keeps the plan mode its own config holds.
10
+ * - A change waits for the attach's snapshot and for the lane (version > 0). A
11
+ * thread without a lane needs no write (the next send carries plan mode); the
12
+ * change stays pending until a lane exists, so a lane an earlier send seeded
13
+ * is corrected once it lands.
14
+ * - The write is one `config/patch` of the exclusion lists that change,
15
+ * computed from the lane's own lists (this client's pending writes folded
16
+ * over), so a tool or middleware another client excluded stays excluded.
17
+ * - A refusal that can never succeed (a view-only collaborator, a workspace
18
+ * without server config) stops the writes for the attach and is reported on
19
+ * the diagnostics bus; a write the channel dropped is written again after a
20
+ * backoff, at most {@link MAX_PATCH_ATTEMPTS_PER_CHANGE} times per change.
21
+ *
22
+ * agora gates every `config/*` write on EDIT on the thread's session asset
23
+ * (`_authorize_config_write`). Mounted beside `StatewireThreadConfigLaneSync`
24
+ * under the runtime's `AuiProvider`, keyed by the thread, so each attach starts
25
+ * with nothing pending.
26
+ */
27
+ export declare function StatewirePlanModeLaneSync({ threadId, planMode, lane, channelLive, }: {
28
+ threadId: string;
29
+ /** The provider's `planMode`, published with the thread it applies to; `null`: it sets none. */
30
+ planMode: boolean | null;
31
+ lane: AthenaStatewireServerLane;
32
+ /** Whether the channel can take a command now; writes wait for it. */
33
+ channelLive: boolean;
34
+ }): null;
@@ -0,0 +1,93 @@
1
+ import { useStatewireSendCommand } from "@assistant-ui/react-statewire";
2
+ import { useRef, useState, useEffect } from "react";
3
+ import { athenaDiagnostics } from "../diagnostics/athena-diagnostics.js";
4
+ import { decidePlanModeLanePatch } from "./statewire-plan-mode.js";
5
+ import { MAX_PATCH_ATTEMPTS_PER_CHANGE, RETRY_BACKOFF_MS } from "./StatewireThreadConfigLaneSync.js";
6
+ import { useDeepAgentConfigController, isConfigWriteForbiddenRejection, isConfigSyncUnavailableRejection } from "../agent-runtime/src/use-deep-agent-config.js";
7
+ import { statewireTransportOutcome } from "../agent-runtime/src/errors.js";
8
+ function StatewirePlanModeLaneSync({
9
+ threadId,
10
+ planMode,
11
+ lane,
12
+ channelLive
13
+ }) {
14
+ const send = useStatewireSendCommand();
15
+ const sendCommand = (command) => Promise.resolve(send(command));
16
+ const { configVersion, custom, patchConfig } = useDeepAgentConfigController({
17
+ serverConfig: lane.config,
18
+ sendCommand
19
+ });
20
+ const seenRef = useRef(planMode);
21
+ const pendingRef = useRef(false);
22
+ const attemptsRef = useRef(0);
23
+ const closedRef = useRef(false);
24
+ const patchConfigRef = useRef(patchConfig);
25
+ patchConfigRef.current = patchConfig;
26
+ const [retryTick, setRetryTick] = useState(0);
27
+ const retryTimerRef = useRef(null);
28
+ useEffect(
29
+ () => () => {
30
+ if (retryTimerRef.current !== null) clearTimeout(retryTimerRef.current);
31
+ },
32
+ []
33
+ );
34
+ const landed = lane.landed;
35
+ useEffect(() => {
36
+ if (planMode !== seenRef.current) {
37
+ seenRef.current = planMode;
38
+ pendingRef.current = planMode !== null;
39
+ attemptsRef.current = 0;
40
+ }
41
+ if (!pendingRef.current || planMode === null || closedRef.current || !channelLive) return;
42
+ const decision = decidePlanModeLanePatch({ planMode, landed, configVersion, custom });
43
+ if (decision.kind === "wait") return;
44
+ pendingRef.current = false;
45
+ if (decision.kind === "done") return;
46
+ const { patch } = decision;
47
+ attemptsRef.current += 1;
48
+ const data = { thread_id: threadId, plan_mode: planMode, config_keys: Object.keys(patch) };
49
+ patchConfigRef.current(patch).catch((error) => {
50
+ if (isConfigWriteForbiddenRejection(error) || isConfigSyncUnavailableRejection(error)) {
51
+ closedRef.current = true;
52
+ athenaDiagnostics.emit("statewire.config", {
53
+ level: "warn",
54
+ data: {
55
+ ...data,
56
+ reason: isConfigWriteForbiddenRejection(error) ? "config_write_forbidden" : "config_sync_unavailable"
57
+ }
58
+ });
59
+ return;
60
+ }
61
+ const outcome = statewireTransportOutcome(error);
62
+ if (outcome !== null) {
63
+ athenaDiagnostics.emit("statewire.config", { level: "debug", data: { ...data, outcome } });
64
+ if (outcome === "unmount") return;
65
+ if (seenRef.current !== planMode) return;
66
+ const written = attemptsRef.current;
67
+ if (written >= MAX_PATCH_ATTEMPTS_PER_CHANGE) return;
68
+ pendingRef.current = true;
69
+ const delay = RETRY_BACKOFF_MS[Math.min(written - 1, RETRY_BACKOFF_MS.length - 1)];
70
+ retryTimerRef.current = setTimeout(() => {
71
+ retryTimerRef.current = null;
72
+ setRetryTick((tick) => tick + 1);
73
+ }, delay);
74
+ return;
75
+ }
76
+ athenaDiagnostics.error(
77
+ "statewire.config",
78
+ error,
79
+ {
80
+ code: "statewire_rejected",
81
+ message: "The statewire host refused the plan mode change",
82
+ hint: "Inspect error.detail: agora rejections carry a structured {code, message}. The thread keeps running with the plan mode its server config holds."
83
+ },
84
+ data
85
+ );
86
+ });
87
+ }, [planMode, landed, configVersion, custom, channelLive, retryTick, threadId]);
88
+ return null;
89
+ }
90
+ export {
91
+ StatewirePlanModeLaneSync
92
+ };
93
+ //# sourceMappingURL=StatewirePlanModeLaneSync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StatewirePlanModeLaneSync.js","sources":["../../src/runtime/StatewirePlanModeLaneSync.tsx"],"sourcesContent":["import { useStatewireSendCommand } from '@assistant-ui/react-statewire';\nimport {\n type DeepAgentConfigControllerInputs,\n isConfigSyncUnavailableRejection,\n isConfigWriteForbiddenRejection,\n statewireTransportOutcome,\n useDeepAgentConfigController,\n} from '@athenaintel/agent-runtime';\nimport { useEffect, useRef, useState } from 'react';\nimport { athenaDiagnostics } from '../diagnostics/athena-diagnostics';\nimport { decidePlanModeLanePatch } from './statewire-plan-mode';\nimport type { AthenaStatewireServerLane } from './statewire-server-lane-context';\nimport { MAX_PATCH_ATTEMPTS_PER_CHANGE, RETRY_BACKOFF_MS } from './StatewireThreadConfigLaneSync';\n\n/**\n * Writes the provider's `planMode` to the thread's server config lane when the\n * host changes it during an attach, under the contract\n * `StatewireThreadConfigLaneSync` keeps for `model` and the other\n * provider-owned keys:\n *\n * - Only a CHANGE is written. The value an attach starts with is never written:\n * a thread opened elsewhere keeps the plan mode its own config holds.\n * - A change waits for the attach's snapshot and for the lane (version > 0). A\n * thread without a lane needs no write (the next send carries plan mode); the\n * change stays pending until a lane exists, so a lane an earlier send seeded\n * is corrected once it lands.\n * - The write is one `config/patch` of the exclusion lists that change,\n * computed from the lane's own lists (this client's pending writes folded\n * over), so a tool or middleware another client excluded stays excluded.\n * - A refusal that can never succeed (a view-only collaborator, a workspace\n * without server config) stops the writes for the attach and is reported on\n * the diagnostics bus; a write the channel dropped is written again after a\n * backoff, at most {@link MAX_PATCH_ATTEMPTS_PER_CHANGE} times per change.\n *\n * agora gates every `config/*` write on EDIT on the thread's session asset\n * (`_authorize_config_write`). Mounted beside `StatewireThreadConfigLaneSync`\n * under the runtime's `AuiProvider`, keyed by the thread, so each attach starts\n * with nothing pending.\n */\nexport function StatewirePlanModeLaneSync({\n threadId,\n planMode,\n lane,\n channelLive,\n}: {\n threadId: string;\n /** The provider's `planMode`, published with the thread it applies to; `null`: it sets none. */\n planMode: boolean | null;\n lane: AthenaStatewireServerLane;\n /** Whether the channel can take a command now; writes wait for it. */\n channelLive: boolean;\n}): null {\n const send = useStatewireSendCommand();\n const sendCommand: DeepAgentConfigControllerInputs['sendCommand'] = (command) =>\n Promise.resolve(send(command));\n const { configVersion, custom, patchConfig } = useDeepAgentConfigController({\n serverConfig: lane.config,\n sendCommand,\n });\n\n const seenRef = useRef(planMode);\n const pendingRef = useRef(false);\n const attemptsRef = useRef(0);\n const closedRef = useRef(false);\n const patchConfigRef = useRef(patchConfig);\n patchConfigRef.current = patchConfig;\n // Bumped (after a backoff) to re-run the effect for a write the channel dropped.\n const [retryTick, setRetryTick] = useState(0);\n const retryTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n useEffect(\n () => () => {\n if (retryTimerRef.current !== null) clearTimeout(retryTimerRef.current);\n },\n [],\n );\n const landed = lane.landed;\n\n useEffect(() => {\n if (planMode !== seenRef.current) {\n seenRef.current = planMode;\n // A host that stops setting plan mode leaves the thread's own as it is.\n pendingRef.current = planMode !== null;\n attemptsRef.current = 0;\n }\n if (!pendingRef.current || planMode === null || closedRef.current || !channelLive) return;\n const decision = decidePlanModeLanePatch({ planMode, landed, configVersion, custom });\n if (decision.kind === 'wait') return;\n pendingRef.current = false;\n if (decision.kind === 'done') return;\n\n const { patch } = decision;\n attemptsRef.current += 1;\n const data = { thread_id: threadId, plan_mode: planMode, config_keys: Object.keys(patch) };\n patchConfigRef.current(patch).catch((error: unknown) => {\n if (isConfigWriteForbiddenRejection(error) || isConfigSyncUnavailableRejection(error)) {\n closedRef.current = true;\n athenaDiagnostics.emit('statewire.config', {\n level: 'warn',\n data: {\n ...data,\n reason: isConfigWriteForbiddenRejection(error)\n ? 'config_write_forbidden'\n : 'config_sync_unavailable',\n },\n });\n return;\n }\n const outcome = statewireTransportOutcome(error);\n if (outcome !== null) {\n // Channel weather (a dropped stream, the host's expired verdict): write\n // the change again after a backoff, once the channel is live, unless the\n // host has moved on, the attach is gone or it was written enough.\n athenaDiagnostics.emit('statewire.config', { level: 'debug', data: { ...data, outcome } });\n if (outcome === 'unmount') return;\n if (seenRef.current !== planMode) return;\n const written = attemptsRef.current;\n if (written >= MAX_PATCH_ATTEMPTS_PER_CHANGE) return;\n pendingRef.current = true;\n const delay = RETRY_BACKOFF_MS[Math.min(written - 1, RETRY_BACKOFF_MS.length - 1)];\n retryTimerRef.current = setTimeout(() => {\n retryTimerRef.current = null;\n setRetryTick((tick) => tick + 1);\n }, delay);\n return;\n }\n athenaDiagnostics.error(\n 'statewire.config',\n error,\n {\n code: 'statewire_rejected',\n message: 'The statewire host refused the plan mode change',\n hint: 'Inspect error.detail: agora rejections carry a structured {code, message}. The thread keeps running with the plan mode its server config holds.',\n },\n data,\n );\n });\n }, [planMode, landed, configVersion, custom, channelLive, retryTick, threadId]);\n\n return null;\n}\n"],"names":[],"mappings":";;;;;;;AAuCO,SAAS,0BAA0B;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAOS;AACP,QAAM,OAAO,wBAAA;AACb,QAAM,cAA8D,CAAC,YACnE,QAAQ,QAAQ,KAAK,OAAO,CAAC;AAC/B,QAAM,EAAE,eAAe,QAAQ,YAAA,IAAgB,6BAA6B;AAAA,IAC1E,cAAc,KAAK;AAAA,I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pB,0BAAkB,KAAK,oBAAoB,EAAE,OAAO,SAAS,MAAM,EAAE,GAAG,MAAM,QAAA,GAAW;AACzF,YAAI,YAAY,UAAW;AAC3B,YAAI,QAAQ,YAAY,SAAU;AAClC,cAAM,UAAU,YAAY;AAC5B,YAAI,WAAW,8BAA+B;AAC9C,mBAAW,UAAU;AACrB,cAAM,QAAQ,iBAAiB,KAAK,IAAI,UAAU,GAAG,iBAAiB,SAAS,CAAC,CAAC;AACjF,sBAAc,UAAU,WAAW,MAAM;AACvC,wBAAc,UAAU;AACxB,uBAAa,CAAC,SAAS,OAAO,CAAC;AAAA,QACjC,GAAG,KAAK;AACR;AAAA,MACF;AACA,wBAAkB;AAAA,QAChB;AAAA,QACA;AAAA,QACA;AAAA,UACE,MAAM;AAAA,UACN,SAAS;AAAA,UACT,MAAM;AAAA,QAAA;AAAA,QAER;AAAA,MAAA;AAAA,IAEJ,CAAC;AAAA,EACH,GAAG,CAAC,UAAU,QAAQ,eAAe,QAAQ,aAAa,WAAW,QAAQ,CAAC;AAE9E,SAAO;AACT;"}
@@ -121,5 +121,7 @@ function StatewireThreadConfigLaneSync({
121
121
  }, [config, landed, configVersion, custom, channelLive, retryTick, threadId]);
122
122
  return null;
123
123
  }
124
+ exports.MAX_PATCH_ATTEMPTS_PER_CHANGE = MAX_PATCH_ATTEMPTS_PER_CHANGE;
125
+ exports.RETRY_BACKOFF_MS = RETRY_BACKOFF_MS;
124
126
  exports.StatewireThreadConfigLaneSync = StatewireThreadConfigLaneSync;
125
127
  //# sourceMappingURL=StatewireThreadConfigLaneSync.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"StatewireThreadConfigLaneSync.cjs","sources":["../../src/runtime/StatewireThreadConfigLaneSync.tsx"],"sourcesContent":["import { useStatewireSendCommand } from '@assistant-ui/react-statewire';\nimport {\n type DeepAgentConfigControllerInputs,\n isConfigSyncUnavailableRejection,\n isConfigWriteForbiddenRejection,\n statewireTransportOutcome,\n useDeepAgentConfigController,\n} from '@athenaintel/agent-runtime';\nimport { useEffect, useRef, useState } from 'react';\nimport { athenaDiagnostics } from '../diagnostics/athena-diagnostics';\nimport type { AthenaStatewireServerLane } from './statewire-server-lane-context';\nimport {\n decideThreadConfigLanePatch,\n PROVIDER_THREAD_CONFIG_KEYS,\n type ProviderThreadConfig,\n type ProviderThreadConfigKey,\n type ProviderThreadConfigPatch,\n patchedThreadConfigKeys,\n sameThreadConfigValue,\n} from './statewire-thread-config-lane';\n\n/** Writes of one change, the first included, before the sync gives up on it. */\nconst MAX_PATCH_ATTEMPTS_PER_CHANGE = 3;\n\n/** Wait before re-writing a change the channel dropped: 1 s, then 4 s. */\nconst RETRY_BACKOFF_MS = [1_000, 4_000] as const;\n\n/**\n * What a `statewire.config` event says about a write: the thread, the model it\n * set (`null`: unset), and the other provider-owned keys it set\n * (`config_keys`), never their values (a system prompt is the host's text).\n */\nfunction configWriteData({\n threadId,\n patch,\n}: {\n threadId: string;\n patch: ProviderThreadConfigPatch;\n}): Record<string, unknown> {\n const otherKeys = patchedThreadConfigKeys(patch).filter((key) => key !== 'model');\n return {\n thread_id: threadId,\n ...(Object.hasOwn(patch, 'model') && { model: patch.model }),\n ...(otherKeys.length > 0 && { config_keys: otherKeys }),\n };\n}\n\n/**\n * Writes the provider-owned thread-config keys to the thread's server config\n * lane when the host changes the props that feed them during an attach:\n * `model`, `systemPrompt` (`system_prompt`), `tools` and `frontendTools`\n * (`enabled_tools`), `workbench` and `knowledgeBase` (`knowledge_base`).\n *\n * Once a thread has a lane (version > 0), agora composes every run from the\n * lane and drops the thread-config keys a send carries, so a model, prompt,\n * tool list or asset list changed after the thread's first turn would never\n * apply. A change of such a prop therefore becomes one `config/patch`\n * carrying exactly the changed keys, each with the value the send would carry\n * (`null` when the send carries none: the key is unset, so the collab agent's\n * own value, or the default, applies). An empty tool or asset list is `null`,\n * as the send omits it.\n *\n * Only a CHANGE is written. A prop's value when the attach starts is never\n * written, even when the lane holds another value: that value is another\n * client's (or an earlier session's) choice for this thread, and an SDK app's\n * global setting must not overwrite it just by opening the thread. Hosts that\n * want the picker to follow the thread read `useAthenaThreadModel`.\n *\n * Decisions read the lane the host itself sent on this attach (`lane`, from\n * the transport), never the rendered thread state: before the attach snapshot\n * lands that state is a placeholder without a lane, or a remembered snapshot\n * with an older one, and comparing a change against either would write over\n * the session's real config. A change made before the snapshot lands waits\n * for it.\n *\n * A version-0 thread needs no write: the next send carries the values and\n * agora's deferral seed persists them. A change stays pending until the lane\n * exists, so a lane an earlier send seeds with the previous values is\n * corrected when it lands. A refusal that can never succeed (a view-only\n * collaborator, a workspace without server config) stops the sync for the\n * attach and is reported on the diagnostics bus. A write the channel dropped\n * (a lost stream, the host's expired verdict) stays pending and is written\n * again after a backoff once the channel is live, at most\n * {@link MAX_PATCH_ATTEMPTS_PER_CHANGE} times per change.\n *\n * The writes go through the `config/*` command family, which agora gates on\n * EDIT on the thread's session asset (`_authorize_config_write`).\n *\n * Mounted under the runtime's `AuiProvider`, keyed by the thread, so each\n * attach starts with nothing pending.\n */\nexport function StatewireThreadConfigLaneSync({\n threadId,\n config,\n lane,\n channelLive,\n}: {\n threadId: string;\n /** The values this thread's sends carry, published with the thread (see the provider). */\n config: ProviderThreadConfig;\n lane: AthenaStatewireServerLane;\n /** Whether the channel can take a command now; writes wait for it. */\n channelLive: boolean;\n}): null {\n const send = useStatewireSendCommand();\n const sendCommand: DeepAgentConfigControllerInputs['sendCommand'] = (command) =>\n Promise.resolve(send(command));\n const { configVersion, custom, patchConfig } = useDeepAgentConfigController({\n serverConfig: lane.config,\n sendCommand,\n });\n\n const seenRef = useRef(config);\n const pendingRef = useRef(new Set<ProviderThreadConfigKey>());\n const attemptsRef = useRef(new Map<ProviderThreadConfigKey, number>());\n const closedRef = useRef(false);\n const patchConfigRef = useRef(patchConfig);\n patchConfigRef.current = patchConfig;\n // Bumped (after a backoff) to re-run the effect for a write the channel dropped.\n const [retryTick, setRetryTick] = useState(0);\n const retryTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n useEffect(\n () => () => {\n if (retryTimerRef.current !== null) clearTimeout(retryTimerRef.current);\n },\n [],\n );\n const landed = lane.landed;\n\n useEffect(() => {\n const pending = pendingRef.current;\n const attempts = attemptsRef.current;\n for (const key of PROVIDER_THREAD_CONFIG_KEYS) {\n if (sameThreadConfigValue(config[key], seenRef.current[key])) continue;\n pending.add(key);\n attempts.set(key, 0);\n }\n seenRef.current = config;\n if (pending.size === 0 || closedRef.current || !channelLive) return;\n const decision = decideThreadConfigLanePatch({\n desired: config,\n keys: pending,\n landed,\n configVersion,\n custom,\n });\n if (decision.kind === 'wait') return;\n pending.clear();\n if (decision.kind === 'done') return;\n\n const { patch } = decision;\n const patchKeys = patchedThreadConfigKeys(patch);\n for (const key of patchKeys) attempts.set(key, (attempts.get(key) ?? 0) + 1);\n const modelOnly = patchKeys.length === 1 && patchKeys[0] === 'model';\n patchConfigRef.current(patch).catch((error: unknown) => {\n const data = configWriteData({ threadId, patch });\n if (isConfigWriteForbiddenRejection(error) || isConfigSyncUnavailableRejection(error)) {\n closedRef.current = true;\n athenaDiagnostics.emit('statewire.config', {\n level: 'warn',\n data: {\n ...data,\n reason: isConfigWriteForbiddenRejection(error)\n ? 'config_write_forbidden'\n : 'config_sync_unavailable',\n },\n });\n return;\n }\n const outcome = statewireTransportOutcome(error);\n if (outcome !== null) {\n // Channel weather (a dropped stream, the host's expired verdict): keep\n // each change pending and write it again after a backoff, once the\n // channel is live, unless its prop has moved on or the attach is gone.\n athenaDiagnostics.emit('statewire.config', {\n level: 'debug',\n data: { ...data, outcome },\n });\n if (outcome === 'unmount') return;\n const retryKeys = patchKeys.filter(\n (key) =>\n sameThreadConfigValue(seenRef.current[key], patch[key] ?? null) &&\n (attempts.get(key) ?? 0) < MAX_PATCH_ATTEMPTS_PER_CHANGE,\n );\n if (retryKeys.length === 0) return;\n for (const key of retryKeys) pendingRef.current.add(key);\n const written = Math.max(...retryKeys.map((key) => attempts.get(key) ?? 1));\n const delay = RETRY_BACKOFF_MS[Math.min(written - 1, RETRY_BACKOFF_MS.length - 1)];\n retryTimerRef.current = setTimeout(() => {\n retryTimerRef.current = null;\n setRetryTick((tick) => tick + 1);\n }, delay);\n return;\n }\n athenaDiagnostics.error(\n 'statewire.config',\n error,\n modelOnly\n ? {\n code: 'statewire_rejected',\n message: 'The statewire host refused the model change',\n hint: 'Inspect error.detail: agora rejections carry a structured {code, message}. The thread keeps running with the model its server config holds.',\n }\n : {\n code: 'statewire_rejected',\n message: 'The statewire host refused the thread config change',\n hint: 'Inspect error.detail: agora rejections carry a structured {code, message}. The thread keeps running with the config its server config holds.',\n },\n data,\n );\n });\n }, [config, landed, configVersion, custom, channelLive, retryTick, threadId]);\n\n return null;\n}\n"],"names":["patchedThreadConfigKeys","useStatewireSendCommand","useDeepAgentConfigController","useRef","useState","useEffect","PROVIDER_THREAD_CONFIG_KEYS","sameThreadConfigValue","decideThreadConfigLanePatch","isConfigWriteForbiddenRejection","isConfigSyncUnavailableRejection","athenaDiagnostics","statewireTransportOutcome"],"mappings":";;;;;;;;AAsBA,MAAM,gCAAgC;AAGtC,MAAM,mBAAmB,CAAC,KAAO,GAAK;AAOtC,SAAS,gBAAgB;AAAA,EACvB;AAAA,EACA;AACF,GAG4B;AAC1B,QAAM,YAAYA,0BAAAA,wBAAwB,KAAK,EAAE,OAAO,CAAC,QAAQ,QAAQ,OAAO;AAChF,SAAO;AAAA,IACL,WAAW;AAAA,IACX,GAAI,OAAO,OAAO,OAAO,OAAO,KAAK,EAAE,OAAO,MAAM,MAAA;AAAA,IACpD,GAAI,UAAU,SAAS,KAAK,EAAE,aAAa,UAAA;AAAA,EAAU;AAEzD;AA8CO,SAAS,8BAA8B;AAAA,EAC5C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAOS;AACP,QAAM,OAAOC,eAAAA,wBAAA;AACb,QAAM,cAA8D,CAAC,YACnE,QAAQ,QAAQ,KAAK,OAAO,CAAC;AAC/B,QAAM,EAAE,eAAe,Q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BAAkB;AAAA,QAChB;AAAA,QACA;AAAA,QACA,YACI;AAAA,UACE,MAAM;AAAA,UACN,SAAS;AAAA,UACT,MAAM;AAAA,QAAA,IAER;AAAA,UACE,MAAM;AAAA,UACN,SAAS;AAAA,UACT,MAAM;AAAA,QAAA;AAAA,QAEZ;AAAA,MAAA;AAAA,IAEJ,CAAC;AAAA,EACH,GAAG,CAAC,QAAQ,QAAQ,eAAe,QAAQ,aAAa,WAAW,QAAQ,CAAC;AAE5E,SAAO;AACT;;"}
1
+ {"version":3,"file":"StatewireThreadConfigLaneSync.cjs","sources":["../../src/runtime/StatewireThreadConfigLaneSync.tsx"],"sourcesContent":["import { useStatewireSendCommand } from '@assistant-ui/react-statewire';\nimport {\n type DeepAgentConfigControllerInputs,\n isConfigSyncUnavailableRejection,\n isConfigWriteForbiddenRejection,\n statewireTransportOutcome,\n useDeepAgentConfigController,\n} from '@athenaintel/agent-runtime';\nimport { useEffect, useRef, useState } from 'react';\nimport { athenaDiagnostics } from '../diagnostics/athena-diagnostics';\nimport type { AthenaStatewireServerLane } from './statewire-server-lane-context';\nimport {\n decideThreadConfigLanePatch,\n PROVIDER_THREAD_CONFIG_KEYS,\n type ProviderThreadConfig,\n type ProviderThreadConfigKey,\n type ProviderThreadConfigPatch,\n patchedThreadConfigKeys,\n sameThreadConfigValue,\n} from './statewire-thread-config-lane';\n\n/** Writes of one change, the first included, before the sync gives up on it. */\nexport const MAX_PATCH_ATTEMPTS_PER_CHANGE = 3;\n\n/** Wait before re-writing a change the channel dropped: 1 s, then 4 s. */\nexport const RETRY_BACKOFF_MS = [1_000, 4_000] as const;\n\n/**\n * What a `statewire.config` event says about a write: the thread, the model it\n * set (`null`: unset), and the other provider-owned keys it set\n * (`config_keys`), never their values (a system prompt is the host's text).\n */\nfunction configWriteData({\n threadId,\n patch,\n}: {\n threadId: string;\n patch: ProviderThreadConfigPatch;\n}): Record<string, unknown> {\n const otherKeys = patchedThreadConfigKeys(patch).filter((key) => key !== 'model');\n return {\n thread_id: threadId,\n ...(Object.hasOwn(patch, 'model') && { model: patch.model }),\n ...(otherKeys.length > 0 && { config_keys: otherKeys }),\n };\n}\n\n/**\n * Writes the provider-owned thread-config keys to the thread's server config\n * lane when the host changes the props that feed them during an attach:\n * `model`, `systemPrompt` (`system_prompt`), `tools` and `frontendTools`\n * (`enabled_tools`), `workbench` and `knowledgeBase` (`knowledge_base`).\n *\n * Once a thread has a lane (version > 0), agora composes every run from the\n * lane and drops the thread-config keys a send carries, so a model, prompt,\n * tool list or asset list changed after the thread's first turn would never\n * apply. A change of such a prop therefore becomes one `config/patch`\n * carrying exactly the changed keys, each with the value the send would carry\n * (`null` when the send carries none: the key is unset, so the collab agent's\n * own value, or the default, applies). An empty tool or asset list is `null`,\n * as the send omits it.\n *\n * Only a CHANGE is written. A prop's value when the attach starts is never\n * written, even when the lane holds another value: that value is another\n * client's (or an earlier session's) choice for this thread, and an SDK app's\n * global setting must not overwrite it just by opening the thread. Hosts that\n * want the picker to follow the thread read `useAthenaThreadModel`.\n *\n * Decisions read the lane the host itself sent on this attach (`lane`, from\n * the transport), never the rendered thread state: before the attach snapshot\n * lands that state is a placeholder without a lane, or a remembered snapshot\n * with an older one, and comparing a change against either would write over\n * the session's real config. A change made before the snapshot lands waits\n * for it.\n *\n * A version-0 thread needs no write: the next send carries the values and\n * agora's deferral seed persists them. A change stays pending until the lane\n * exists, so a lane an earlier send seeds with the previous values is\n * corrected when it lands. A refusal that can never succeed (a view-only\n * collaborator, a workspace without server config) stops the sync for the\n * attach and is reported on the diagnostics bus. A write the channel dropped\n * (a lost stream, the host's expired verdict) stays pending and is written\n * again after a backoff once the channel is live, at most\n * {@link MAX_PATCH_ATTEMPTS_PER_CHANGE} times per change.\n *\n * The writes go through the `config/*` command family, which agora gates on\n * EDIT on the thread's session asset (`_authorize_config_write`).\n *\n * Mounted under the runtime's `AuiProvider`, keyed by the thread, so each\n * attach starts with nothing pending.\n */\nexport function StatewireThreadConfigLaneSync({\n threadId,\n config,\n lane,\n channelLive,\n}: {\n threadId: string;\n /** The values this thread's sends carry, published with the thread (see the provider). */\n config: ProviderThreadConfig;\n lane: AthenaStatewireServerLane;\n /** Whether the channel can take a command now; writes wait for it. */\n channelLive: boolean;\n}): null {\n const send = useStatewireSendCommand();\n const sendCommand: DeepAgentConfigControllerInputs['sendCommand'] = (command) =>\n Promise.resolve(send(command));\n const { configVersion, custom, patchConfig } = useDeepAgentConfigController({\n serverConfig: lane.config,\n sendCommand,\n });\n\n const seenRef = useRef(config);\n const pendingRef = useRef(new Set<ProviderThreadConfigKey>());\n const attemptsRef = useRef(new Map<ProviderThreadConfigKey, number>());\n const closedRef = useRef(false);\n const patchConfigRef = useRef(patchConfig);\n patchConfigRef.current = patchConfig;\n // Bumped (after a backoff) to re-run the effect for a write the channel dropped.\n const [retryTick, setRetryTick] = useState(0);\n const retryTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n useEffect(\n () => () => {\n if (retryTimerRef.current !== null) clearTimeout(retryTimerRef.current);\n },\n [],\n );\n const landed = lane.landed;\n\n useEffect(() => {\n const pending = pendingRef.current;\n const attempts = attemptsRef.current;\n for (const key of PROVIDER_THREAD_CONFIG_KEYS) {\n if (sameThreadConfigValue(config[key], seenRef.current[key])) continue;\n pending.add(key);\n attempts.set(key, 0);\n }\n seenRef.current = config;\n if (pending.size === 0 || closedRef.current || !channelLive) return;\n const decision = decideThreadConfigLanePatch({\n desired: config,\n keys: pending,\n landed,\n configVersion,\n custom,\n });\n if (decision.kind === 'wait') return;\n pending.clear();\n if (decision.kind === 'done') return;\n\n const { patch } = decision;\n const patchKeys = patchedThreadConfigKeys(patch);\n for (const key of patchKeys) attempts.set(key, (attempts.get(key) ?? 0) + 1);\n const modelOnly = patchKeys.length === 1 && patchKeys[0] === 'model';\n patchConfigRef.current(patch).catch((error: unknown) => {\n const data = configWriteData({ threadId, patch });\n if (isConfigWriteForbiddenRejection(error) || isConfigSyncUnavailableRejection(error)) {\n closedRef.current = true;\n athenaDiagnostics.emit('statewire.config', {\n level: 'warn',\n data: {\n ...data,\n reason: isConfigWriteForbiddenRejection(error)\n ? 'config_write_forbidden'\n : 'config_sync_unavailable',\n },\n });\n return;\n }\n const outcome = statewireTransportOutcome(error);\n if (outcome !== null) {\n // Channel weather (a dropped stream, the host's expired verdict): keep\n // each change pending and write it again after a backoff, once the\n // channel is live, unless its prop has moved on or the attach is gone.\n athenaDiagnostics.emit('statewire.config', {\n level: 'debug',\n data: { ...data, outcome },\n });\n if (outcome === 'unmount') return;\n const retryKeys = patchKeys.filter(\n (key) =>\n sameThreadConfigValue(seenRef.current[key], patch[key] ?? null) &&\n (attempts.get(key) ?? 0) < MAX_PATCH_ATTEMPTS_PER_CHANGE,\n );\n if (retryKeys.length === 0) return;\n for (const key of retryKeys) pendingRef.current.add(key);\n const written = Math.max(...retryKeys.map((key) => attempts.get(key) ?? 1));\n const delay = RETRY_BACKOFF_MS[Math.min(written - 1, RETRY_BACKOFF_MS.length - 1)];\n retryTimerRef.current = setTimeout(() => {\n retryTimerRef.current = null;\n setRetryTick((tick) => tick + 1);\n }, delay);\n return;\n }\n athenaDiagnostics.error(\n 'statewire.config',\n error,\n modelOnly\n ? {\n code: 'statewire_rejected',\n message: 'The statewire host refused the model change',\n hint: 'Inspect error.detail: agora rejections carry a structured {code, message}. The thread keeps running with the model its server config holds.',\n }\n : {\n code: 'statewire_rejected',\n message: 'The statewire host refused the thread config change',\n hint: 'Inspect error.detail: agora rejections carry a structured {code, message}. The thread keeps running with the config its server config holds.',\n },\n data,\n );\n });\n }, [config, landed, configVersion, custom, channelLive, retryTick, threadId]);\n\n return null;\n}\n"],"names":["patchedThreadConfigKeys","useStatewireSendCommand","useDeepAgentConfigController","useRef","useState","useEffect","PROVIDER_THREAD_CONFIG_KEYS","sameThreadConfigValue","decideThreadConfigLanePatch","isConfigWriteForbiddenRejection","isConfigSyncUnavailableRejection","athenaDiagnostics","statewireTransportOutcome"],"mappings":";;;;;;;;AAsBO,MAAM,gC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AAY,UAAU;AAAA,UAC1B,CAAC,QACCJ,0BAAAA,sBAAsB,QAAQ,QAAQ,GAAG,GAAG,MAAM,GAAG,KAAK,IAAI,MAC7D,SAAS,IAAI,GAAG,KAAK,KAAK;AAAA,QAAA;AAE/B,YAAI,UAAU,WAAW,EAAG;AAC5B,mBAAW,OAAO,UAAW,YAAW,QAAQ,IAAI,GAAG;AACvD,cAAM,UAAU,KAAK,IAAI,GAAG,UAAU,IAAI,CAAC,QAAQ,SAAS,IAAI,GAAG,KAAK,CAAC,CAAC;AAC1E,cAAM,QAAQ,iBAAiB,KAAK,IAAI,UAAU,GAAG,iBAAiB,SAAS,CAAC,CAAC;AACjF,sBAAc,UAAU,WAAW,MAAM;AACvC,wBAAc,UAAU;AACxB,uBAAa,CAAC,SAAS,OAAO,CAAC;AAAA,QACjC,GAAG,KAAK;AACR;AAAA,MACF;AACAI,wBAAAA,kBAAkB;AAAA,QAChB;AAAA,QACA;AAAA,QACA,YACI;AAAA,UACE,MAAM;AAAA,UACN,SAAS;AAAA,UACT,MAAM;AAAA,QAAA,IAER;AAAA,UACE,MAAM;AAAA,UACN,SAAS;AAAA,UACT,MAAM;AAAA,QAAA;AAAA,QAEZ;AAAA,MAAA;AAAA,IAEJ,CAAC;AAAA,EACH,GAAG,CAAC,QAAQ,QAAQ,eAAe,QAAQ,aAAa,WAAW,QAAQ,CAAC;AAE5E,SAAO;AACT;;;;"}
@@ -1,5 +1,9 @@
1
1
  import type { AthenaStatewireServerLane } from './statewire-server-lane-context';
2
2
  import { type ProviderThreadConfig } from './statewire-thread-config-lane';
3
+ /** Writes of one change, the first included, before the sync gives up on it. */
4
+ export declare const MAX_PATCH_ATTEMPTS_PER_CHANGE = 3;
5
+ /** Wait before re-writing a change the channel dropped: 1 s, then 4 s. */
6
+ export declare const RETRY_BACKOFF_MS: readonly [1000, 4000];
3
7
  /**
4
8
  * Writes the provider-owned thread-config keys to the thread's server config
5
9
  * lane when the host changes the props that feed them during an attach:
@@ -120,6 +120,8 @@ function StatewireThreadConfigLaneSync({
120
120
  return null;
121
121
  }
122
122
  export {
123
+ MAX_PATCH_ATTEMPTS_PER_CHANGE,
124
+ RETRY_BACKOFF_MS,
123
125
  StatewireThreadConfigLaneSync
124
126
  };
125
127
  //# sourceMappingURL=StatewireThreadConfigLaneSync.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"StatewireThreadConfigLaneSync.js","sources":["../../src/runtime/StatewireThreadConfigLaneSync.tsx"],"sourcesContent":["import { useStatewireSendCommand } from '@assistant-ui/react-statewire';\nimport {\n type DeepAgentConfigControllerInputs,\n isConfigSyncUnavailableRejection,\n isConfigWriteForbiddenRejection,\n statewireTransportOutcome,\n useDeepAgentConfigController,\n} from '@athenaintel/agent-runtime';\nimport { useEffect, useRef, useState } from 'react';\nimport { athenaDiagnostics } from '../diagnostics/athena-diagnostics';\nimport type { AthenaStatewireServerLane } from './statewire-server-lane-context';\nimport {\n decideThreadConfigLanePatch,\n PROVIDER_THREAD_CONFIG_KEYS,\n type ProviderThreadConfig,\n type ProviderThreadConfigKey,\n type ProviderThreadConfigPatch,\n patchedThreadConfigKeys,\n sameThreadConfigValue,\n} from './statewire-thread-config-lane';\n\n/** Writes of one change, the first included, before the sync gives up on it. */\nconst MAX_PATCH_ATTEMPTS_PER_CHANGE = 3;\n\n/** Wait before re-writing a change the channel dropped: 1 s, then 4 s. */\nconst RETRY_BACKOFF_MS = [1_000, 4_000] as const;\n\n/**\n * What a `statewire.config` event says about a write: the thread, the model it\n * set (`null`: unset), and the other provider-owned keys it set\n * (`config_keys`), never their values (a system prompt is the host's text).\n */\nfunction configWriteData({\n threadId,\n patch,\n}: {\n threadId: string;\n patch: ProviderThreadConfigPatch;\n}): Record<string, unknown> {\n const otherKeys = patchedThreadConfigKeys(patch).filter((key) => key !== 'model');\n return {\n thread_id: threadId,\n ...(Object.hasOwn(patch, 'model') && { model: patch.model }),\n ...(otherKeys.length > 0 && { config_keys: otherKeys }),\n };\n}\n\n/**\n * Writes the provider-owned thread-config keys to the thread's server config\n * lane when the host changes the props that feed them during an attach:\n * `model`, `systemPrompt` (`system_prompt`), `tools` and `frontendTools`\n * (`enabled_tools`), `workbench` and `knowledgeBase` (`knowledge_base`).\n *\n * Once a thread has a lane (version > 0), agora composes every run from the\n * lane and drops the thread-config keys a send carries, so a model, prompt,\n * tool list or asset list changed after the thread's first turn would never\n * apply. A change of such a prop therefore becomes one `config/patch`\n * carrying exactly the changed keys, each with the value the send would carry\n * (`null` when the send carries none: the key is unset, so the collab agent's\n * own value, or the default, applies). An empty tool or asset list is `null`,\n * as the send omits it.\n *\n * Only a CHANGE is written. A prop's value when the attach starts is never\n * written, even when the lane holds another value: that value is another\n * client's (or an earlier session's) choice for this thread, and an SDK app's\n * global setting must not overwrite it just by opening the thread. Hosts that\n * want the picker to follow the thread read `useAthenaThreadModel`.\n *\n * Decisions read the lane the host itself sent on this attach (`lane`, from\n * the transport), never the rendered thread state: before the attach snapshot\n * lands that state is a placeholder without a lane, or a remembered snapshot\n * with an older one, and comparing a change against either would write over\n * the session's real config. A change made before the snapshot lands waits\n * for it.\n *\n * A version-0 thread needs no write: the next send carries the values and\n * agora's deferral seed persists them. A change stays pending until the lane\n * exists, so a lane an earlier send seeds with the previous values is\n * corrected when it lands. A refusal that can never succeed (a view-only\n * collaborator, a workspace without server config) stops the sync for the\n * attach and is reported on the diagnostics bus. A write the channel dropped\n * (a lost stream, the host's expired verdict) stays pending and is written\n * again after a backoff once the channel is live, at most\n * {@link MAX_PATCH_ATTEMPTS_PER_CHANGE} times per change.\n *\n * The writes go through the `config/*` command family, which agora gates on\n * EDIT on the thread's session asset (`_authorize_config_write`).\n *\n * Mounted under the runtime's `AuiProvider`, keyed by the thread, so each\n * attach starts with nothing pending.\n */\nexport function StatewireThreadConfigLaneSync({\n threadId,\n config,\n lane,\n channelLive,\n}: {\n threadId: string;\n /** The values this thread's sends carry, published with the thread (see the provider). */\n config: ProviderThreadConfig;\n lane: AthenaStatewireServerLane;\n /** Whether the channel can take a command now; writes wait for it. */\n channelLive: boolean;\n}): null {\n const send = useStatewireSendCommand();\n const sendCommand: DeepAgentConfigControllerInputs['sendCommand'] = (command) =>\n Promise.resolve(send(command));\n const { configVersion, custom, patchConfig } = useDeepAgentConfigController({\n serverConfig: lane.config,\n sendCommand,\n });\n\n const seenRef = useRef(config);\n const pendingRef = useRef(new Set<ProviderThreadConfigKey>());\n const attemptsRef = useRef(new Map<ProviderThreadConfigKey, number>());\n const closedRef = useRef(false);\n const patchConfigRef = useRef(patchConfig);\n patchConfigRef.current = patchConfig;\n // Bumped (after a backoff) to re-run the effect for a write the channel dropped.\n const [retryTick, setRetryTick] = useState(0);\n const retryTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n useEffect(\n () => () => {\n if (retryTimerRef.current !== null) clearTimeout(retryTimerRef.current);\n },\n [],\n );\n const landed = lane.landed;\n\n useEffect(() => {\n const pending = pendingRef.current;\n const attempts = attemptsRef.current;\n for (const key of PROVIDER_THREAD_CONFIG_KEYS) {\n if (sameThreadConfigValue(config[key], seenRef.current[key])) continue;\n pending.add(key);\n attempts.set(key, 0);\n }\n seenRef.current = config;\n if (pending.size === 0 || closedRef.current || !channelLive) return;\n const decision = decideThreadConfigLanePatch({\n desired: config,\n keys: pending,\n landed,\n configVersion,\n custom,\n });\n if (decision.kind === 'wait') return;\n pending.clear();\n if (decision.kind === 'done') return;\n\n const { patch } = decision;\n const patchKeys = patchedThreadConfigKeys(patch);\n for (const key of patchKeys) attempts.set(key, (attempts.get(key) ?? 0) + 1);\n const modelOnly = patchKeys.length === 1 && patchKeys[0] === 'model';\n patchConfigRef.current(patch).catch((error: unknown) => {\n const data = configWriteData({ threadId, patch });\n if (isConfigWriteForbiddenRejection(error) || isConfigSyncUnavailableRejection(error)) {\n closedRef.current = true;\n athenaDiagnostics.emit('statewire.config', {\n level: 'warn',\n data: {\n ...data,\n reason: isConfigWriteForbiddenRejection(error)\n ? 'config_write_forbidden'\n : 'config_sync_unavailable',\n },\n });\n return;\n }\n const outcome = statewireTransportOutcome(error);\n if (outcome !== null) {\n // Channel weather (a dropped stream, the host's expired verdict): keep\n // each change pending and write it again after a backoff, once the\n // channel is live, unless its prop has moved on or the attach is gone.\n athenaDiagnostics.emit('statewire.config', {\n level: 'debug',\n data: { ...data, outcome },\n });\n if (outcome === 'unmount') return;\n const retryKeys = patchKeys.filter(\n (key) =>\n sameThreadConfigValue(seenRef.current[key], patch[key] ?? null) &&\n (attempts.get(key) ?? 0) < MAX_PATCH_ATTEMPTS_PER_CHANGE,\n );\n if (retryKeys.length === 0) return;\n for (const key of retryKeys) pendingRef.current.add(key);\n const written = Math.max(...retryKeys.map((key) => attempts.get(key) ?? 1));\n const delay = RETRY_BACKOFF_MS[Math.min(written - 1, RETRY_BACKOFF_MS.length - 1)];\n retryTimerRef.current = setTimeout(() => {\n retryTimerRef.current = null;\n setRetryTick((tick) => tick + 1);\n }, delay);\n return;\n }\n athenaDiagnostics.error(\n 'statewire.config',\n error,\n modelOnly\n ? {\n code: 'statewire_rejected',\n message: 'The statewire host refused the model change',\n hint: 'Inspect error.detail: agora rejections carry a structured {code, message}. The thread keeps running with the model its server config holds.',\n }\n : {\n code: 'statewire_rejected',\n message: 'The statewire host refused the thread config change',\n hint: 'Inspect error.detail: agora rejections carry a structured {code, message}. The thread keeps running with the config its server config holds.',\n },\n data,\n );\n });\n }, [config, landed, configVersion, custom, channelLive, retryTick, threadId]);\n\n return null;\n}\n"],"names":[],"mappings":";;;;;;AAsBA,MAAM,gCAAgC;AAGtC,MAAM,mBAAmB,CAAC,KAAO,GAAK;AAOtC,SAAS,gBAAgB;AAAA,EACvB;AAAA,EACA;AACF,GAG4B;AAC1B,QAAM,YAAY,wBAAwB,KAAK,EAAE,OAAO,CAAC,QAAQ,QAAQ,OAAO;AAChF,SAAO;AAAA,IACL,WAAW;AAAA,IACX,GAAI,OAAO,OAAO,OAAO,OAAO,KAAK,EAAE,OAAO,MAAM,MAAA;AAAA,IACpD,GAAI,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O,CAAC;AAAA,QACjC,GAAG,KAAK;AACR;AAAA,MACF;AACA,wBAAkB;AAAA,QAChB;AAAA,QACA;AAAA,QACA,YACI;AAAA,UACE,MAAM;AAAA,UACN,SAAS;AAAA,UACT,MAAM;AAAA,QAAA,IAER;AAAA,UACE,MAAM;AAAA,UACN,SAAS;AAAA,UACT,MAAM;AAAA,QAAA;AAAA,QAEZ;AAAA,MAAA;AAAA,IAEJ,CAAC;AAAA,EACH,GAAG,CAAC,QAAQ,QAAQ,eAAe,QAAQ,aAAa,WAAW,QAAQ,CAAC;AAE5E,SAAO;AACT;"}
1
+ {"version":3,"file":"StatewireThreadConfigLaneSync.js","sources":["../../src/runtime/StatewireThreadConfigLaneSync.tsx"],"sourcesContent":["import { useStatewireSendCommand } from '@assistant-ui/react-statewire';\nimport {\n type DeepAgentConfigControllerInputs,\n isConfigSyncUnavailableRejection,\n isConfigWriteForbiddenRejection,\n statewireTransportOutcome,\n useDeepAgentConfigController,\n} from '@athenaintel/agent-runtime';\nimport { useEffect, useRef, useState } from 'react';\nimport { athenaDiagnostics } from '../diagnostics/athena-diagnostics';\nimport type { AthenaStatewireServerLane } from './statewire-server-lane-context';\nimport {\n decideThreadConfigLanePatch,\n PROVIDER_THREAD_CONFIG_KEYS,\n type ProviderThreadConfig,\n type ProviderThreadConfigKey,\n type ProviderThreadConfigPatch,\n patchedThreadConfigKeys,\n sameThreadConfigValue,\n} from './statewire-thread-config-lane';\n\n/** Writes of one change, the first included, before the sync gives up on it. */\nexport const MAX_PATCH_ATTEMPTS_PER_CHANGE = 3;\n\n/** Wait before re-writing a change the channel dropped: 1 s, then 4 s. */\nexport const RETRY_BACKOFF_MS = [1_000, 4_000] as const;\n\n/**\n * What a `statewire.config` event says about a write: the thread, the model it\n * set (`null`: unset), and the other provider-owned keys it set\n * (`config_keys`), never their values (a system prompt is the host's text).\n */\nfunction configWriteData({\n threadId,\n patch,\n}: {\n threadId: string;\n patch: ProviderThreadConfigPatch;\n}): Record<string, unknown> {\n const otherKeys = patchedThreadConfigKeys(patch).filter((key) => key !== 'model');\n return {\n thread_id: threadId,\n ...(Object.hasOwn(patch, 'model') && { model: patch.model }),\n ...(otherKeys.length > 0 && { config_keys: otherKeys }),\n };\n}\n\n/**\n * Writes the provider-owned thread-config keys to the thread's server config\n * lane when the host changes the props that feed them during an attach:\n * `model`, `systemPrompt` (`system_prompt`), `tools` and `frontendTools`\n * (`enabled_tools`), `workbench` and `knowledgeBase` (`knowledge_base`).\n *\n * Once a thread has a lane (version > 0), agora composes every run from the\n * lane and drops the thread-config keys a send carries, so a model, prompt,\n * tool list or asset list changed after the thread's first turn would never\n * apply. A change of such a prop therefore becomes one `config/patch`\n * carrying exactly the changed keys, each with the value the send would carry\n * (`null` when the send carries none: the key is unset, so the collab agent's\n * own value, or the default, applies). An empty tool or asset list is `null`,\n * as the send omits it.\n *\n * Only a CHANGE is written. A prop's value when the attach starts is never\n * written, even when the lane holds another value: that value is another\n * client's (or an earlier session's) choice for this thread, and an SDK app's\n * global setting must not overwrite it just by opening the thread. Hosts that\n * want the picker to follow the thread read `useAthenaThreadModel`.\n *\n * Decisions read the lane the host itself sent on this attach (`lane`, from\n * the transport), never the rendered thread state: before the attach snapshot\n * lands that state is a placeholder without a lane, or a remembered snapshot\n * with an older one, and comparing a change against either would write over\n * the session's real config. A change made before the snapshot lands waits\n * for it.\n *\n * A version-0 thread needs no write: the next send carries the values and\n * agora's deferral seed persists them. A change stays pending until the lane\n * exists, so a lane an earlier send seeds with the previous values is\n * corrected when it lands. A refusal that can never succeed (a view-only\n * collaborator, a workspace without server config) stops the sync for the\n * attach and is reported on the diagnostics bus. A write the channel dropped\n * (a lost stream, the host's expired verdict) stays pending and is written\n * again after a backoff once the channel is live, at most\n * {@link MAX_PATCH_ATTEMPTS_PER_CHANGE} times per change.\n *\n * The writes go through the `config/*` command family, which agora gates on\n * EDIT on the thread's session asset (`_authorize_config_write`).\n *\n * Mounted under the runtime's `AuiProvider`, keyed by the thread, so each\n * attach starts with nothing pending.\n */\nexport function StatewireThreadConfigLaneSync({\n threadId,\n config,\n lane,\n channelLive,\n}: {\n threadId: string;\n /** The values this thread's sends carry, published with the thread (see the provider). */\n config: ProviderThreadConfig;\n lane: AthenaStatewireServerLane;\n /** Whether the channel can take a command now; writes wait for it. */\n channelLive: boolean;\n}): null {\n const send = useStatewireSendCommand();\n const sendCommand: DeepAgentConfigControllerInputs['sendCommand'] = (command) =>\n Promise.resolve(send(command));\n const { configVersion, custom, patchConfig } = useDeepAgentConfigController({\n serverConfig: lane.config,\n sendCommand,\n });\n\n const seenRef = useRef(config);\n const pendingRef = useRef(new Set<ProviderThreadConfigKey>());\n const attemptsRef = useRef(new Map<ProviderThreadConfigKey, number>());\n const closedRef = useRef(false);\n const patchConfigRef = useRef(patchConfig);\n patchConfigRef.current = patchConfig;\n // Bumped (after a backoff) to re-run the effect for a write the channel dropped.\n const [retryTick, setRetryTick] = useState(0);\n const retryTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n useEffect(\n () => () => {\n if (retryTimerRef.current !== null) clearTimeout(retryTimerRef.current);\n },\n [],\n );\n const landed = lane.landed;\n\n useEffect(() => {\n const pending = pendingRef.current;\n const attempts = attemptsRef.current;\n for (const key of PROVIDER_THREAD_CONFIG_KEYS) {\n if (sameThreadConfigValue(config[key], seenRef.current[key])) continue;\n pending.add(key);\n attempts.set(key, 0);\n }\n seenRef.current = config;\n if (pending.size === 0 || closedRef.current || !channelLive) return;\n const decision = decideThreadConfigLanePatch({\n desired: config,\n keys: pending,\n landed,\n configVersion,\n custom,\n });\n if (decision.kind === 'wait') return;\n pending.clear();\n if (decision.kind === 'done') return;\n\n const { patch } = decision;\n const patchKeys = patchedThreadConfigKeys(patch);\n for (const key of patchKeys) attempts.set(key, (attempts.get(key) ?? 0) + 1);\n const modelOnly = patchKeys.length === 1 && patchKeys[0] === 'model';\n patchConfigRef.current(patch).catch((error: unknown) => {\n const data = configWriteData({ threadId, patch });\n if (isConfigWriteForbiddenRejection(error) || isConfigSyncUnavailableRejection(error)) {\n closedRef.current = true;\n athenaDiagnostics.emit('statewire.config', {\n level: 'warn',\n data: {\n ...data,\n reason: isConfigWriteForbiddenRejection(error)\n ? 'config_write_forbidden'\n : 'config_sync_unavailable',\n },\n });\n return;\n }\n const outcome = statewireTransportOutcome(error);\n if (outcome !== null) {\n // Channel weather (a dropped stream, the host's expired verdict): keep\n // each change pending and write it again after a backoff, once the\n // channel is live, unless its prop has moved on or the attach is gone.\n athenaDiagnostics.emit('statewire.config', {\n level: 'debug',\n data: { ...data, outcome },\n });\n if (outcome === 'unmount') return;\n const retryKeys = patchKeys.filter(\n (key) =>\n sameThreadConfigValue(seenRef.current[key], patch[key] ?? null) &&\n (attempts.get(key) ?? 0) < MAX_PATCH_ATTEMPTS_PER_CHANGE,\n );\n if (retryKeys.length === 0) return;\n for (const key of retryKeys) pendingRef.current.add(key);\n const written = Math.max(...retryKeys.map((key) => attempts.get(key) ?? 1));\n const delay = RETRY_BACKOFF_MS[Math.min(written - 1, RETRY_BACKOFF_MS.length - 1)];\n retryTimerRef.current = setTimeout(() => {\n retryTimerRef.current = null;\n setRetryTick((tick) => tick + 1);\n }, delay);\n return;\n }\n athenaDiagnostics.error(\n 'statewire.config',\n error,\n modelOnly\n ? {\n code: 'statewire_rejected',\n message: 'The statewire host refused the model change',\n hint: 'Inspect error.detail: agora rejections carry a structured {code, message}. The thread keeps running with the model its server config holds.',\n }\n : {\n code: 'statewire_rejected',\n message: 'The statewire host refused the thread config change',\n hint: 'Inspect error.detail: agora rejections carry a structured {code, message}. The thread keeps running with the config its server config holds.',\n },\n data,\n );\n });\n }, [config, landed, configVersion, custom, channelLive, retryTick, threadId]);\n\n return null;\n}\n"],"names":[],"mappings":";;;;;;AAsBO,MAAM,gCAAgC;AAGtC,MAAM,mBAAmB,CAAC,KAAO,GAAK;AAO7C,SAAS,gBAAgB;AAAA,EACvB;AAAA,EACA;AACF,GAG4B;AAC1B,QAAM,YAAY,wBAAwB,K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C;AAC1E,cAAM,QAAQ,iBAAiB,KAAK,IAAI,UAAU,GAAG,iBAAiB,SAAS,CAAC,CAAC;AACjF,sBAAc,UAAU,WAAW,MAAM;AACvC,wBAAc,UAAU;AACxB,uBAAa,CAAC,SAAS,OAAO,CAAC;AAAA,QACjC,GAAG,KAAK;AACR;AAAA,MACF;AACA,wBAAkB;AAAA,QAChB;AAAA,QACA;AAAA,QACA,YACI;AAAA,UACE,MAAM;AAAA,UACN,SAAS;AAAA,UACT,MAAM;AAAA,QAAA,IAER;AAAA,UACE,MAAM;AAAA,UACN,SAAS;AAAA,UACT,MAAM;AAAA,QAAA;AAAA,QAEZ;AAAA,MAAA;AAAA,IAEJ,CAAC;AAAA,EACH,GAAG,CAAC,QAAQ,QAAQ,eAAe,QAAQ,aAAa,WAAW,QAAQ,CAAC;AAE5E,SAAO;AACT;"}
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const PLAN_MODE_TOOL = "write_todos";
4
+ const PLAN_MODE_MIDDLEWARE = "TodoListMiddleware";
5
+ const EXCLUDED_TOOLS = "excluded_tools";
6
+ const EXCLUDED_MIDDLEWARE = "excluded_middleware";
7
+ const PLAN_MODE_EXCLUSIONS = [
8
+ { key: EXCLUDED_TOOLS, name: PLAN_MODE_TOOL },
9
+ { key: EXCLUDED_MIDDLEWARE, name: PLAN_MODE_MIDDLEWARE }
10
+ ];
11
+ const stringItems = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
12
+ function planModeOf(custom) {
13
+ return PLAN_MODE_EXCLUSIONS.every(({ key, name }) => !stringItems(custom[key]).includes(name));
14
+ }
15
+ function planModeListEdits({
16
+ custom,
17
+ planMode
18
+ }) {
19
+ const edits = {};
20
+ if (planModeOf(custom) === planMode) return edits;
21
+ for (const { key, name } of PLAN_MODE_EXCLUSIONS) {
22
+ const items = stringItems(custom[key]);
23
+ const excluded = items.includes(name);
24
+ if (planMode && excluded) {
25
+ const kept = items.filter((item) => item !== name);
26
+ edits[key] = kept.length > 0 ? kept : null;
27
+ } else if (!planMode && !excluded) {
28
+ edits[key] = [...items, name];
29
+ }
30
+ }
31
+ return edits;
32
+ }
33
+ function withPlanMode({
34
+ custom,
35
+ planMode
36
+ }) {
37
+ if (planMode === void 0) return custom;
38
+ const edits = planModeListEdits({ custom, planMode });
39
+ if (Object.keys(edits).length === 0) return custom;
40
+ const next = { ...custom };
41
+ for (const [key, value] of Object.entries(edits)) {
42
+ if (value === null) delete next[key];
43
+ else next[key] = value;
44
+ }
45
+ return next;
46
+ }
47
+ function threadPlanModeFromLane({
48
+ lane,
49
+ ready
50
+ }) {
51
+ if (!ready || lane === null) return { planMode: null, configured: false, ready };
52
+ return { planMode: planModeOf(lane.custom), configured: true, ready };
53
+ }
54
+ function decidePlanModeLanePatch({
55
+ planMode,
56
+ landed,
57
+ configVersion,
58
+ custom
59
+ }) {
60
+ if (!landed || configVersion <= 0) return { kind: "wait" };
61
+ const patch = planModeListEdits({ custom, planMode });
62
+ return Object.keys(patch).length === 0 ? { kind: "done" } : { kind: "patch", patch };
63
+ }
64
+ exports.PLAN_MODE_MIDDLEWARE = PLAN_MODE_MIDDLEWARE;
65
+ exports.PLAN_MODE_TOOL = PLAN_MODE_TOOL;
66
+ exports.decidePlanModeLanePatch = decidePlanModeLanePatch;
67
+ exports.planModeListEdits = planModeListEdits;
68
+ exports.planModeOf = planModeOf;
69
+ exports.threadPlanModeFromLane = threadPlanModeFromLane;
70
+ exports.withPlanMode = withPlanMode;
71
+ //# sourceMappingURL=statewire-plan-mode.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"statewire-plan-mode.cjs","sources":["../../src/runtime/statewire-plan-mode.ts"],"sourcesContent":["import type {\n DeepAgentServerConfig,\n ThreadConfigCustom,\n ThreadConfigPatch,\n} from '@athenaintel/agent-runtime';\n\n/**\n * Plan mode: the deep agent keeps a to-do plan for multi-step work and checks\n * its steps off as it goes. That is the `write_todos` tool and the\n * `TodoListMiddleware` that provides it with its planning prompt, which agora\n * binds on every run unless the run's config excludes either one\n * (`excluded_tools`, `excluded_middleware`). The two go together, as Olympus's\n * Plan Mode switch flips them (`applyPlanningEnabled`): a config plans unless\n * it excludes either.\n */\nexport const PLAN_MODE_TOOL = 'write_todos';\n\n/** The middleware that provides {@link PLAN_MODE_TOOL} and its planning prompt. */\nexport const PLAN_MODE_MIDDLEWARE = 'TodoListMiddleware';\n\nconst EXCLUDED_TOOLS = 'excluded_tools';\nconst EXCLUDED_MIDDLEWARE = 'excluded_middleware';\n\n/** The two lists plan mode edits, each with the one name plan mode owns in it. */\nconst PLAN_MODE_EXCLUSIONS = [\n { key: EXCLUDED_TOOLS, name: PLAN_MODE_TOOL },\n { key: EXCLUDED_MIDDLEWARE, name: PLAN_MODE_MIDDLEWARE },\n] as const;\n\nconst stringItems = (value: unknown): string[] =>\n Array.isArray(value) ? value.filter((item): item is string => typeof item === 'string') : [];\n\n/** Whether a config (a send's `runConfig.custom`, or a thread's server config) plans. Pure. */\nexport function planModeOf(custom: ThreadConfigCustom): boolean {\n return PLAN_MODE_EXCLUSIONS.every(({ key, name }) => !stringItems(custom[key]).includes(name));\n}\n\n/**\n * The exclusion lists that put `custom` in plan mode `planMode`, keyed as a\n * config carries them, and only those that change: plan mode off adds\n * `write_todos` to `excluded_tools` and `TodoListMiddleware` to\n * `excluded_middleware` after what each already lists; on takes them out, and\n * a list left empty is `null` (a `config/patch` unsets it). Every other name in\n * either list stays where it is. `{}` when `custom` is in that plan mode\n * already (off: it excludes either one). Pure.\n */\nexport function planModeListEdits({\n custom,\n planMode,\n}: {\n custom: ThreadConfigCustom;\n planMode: boolean;\n}): ThreadConfigPatch {\n const edits: ThreadConfigPatch = {};\n if (planModeOf(custom) === planMode) return edits;\n for (const { key, name } of PLAN_MODE_EXCLUSIONS) {\n const items = stringItems(custom[key]);\n const excluded = items.includes(name);\n if (planMode && excluded) {\n const kept = items.filter((item) => item !== name);\n edits[key] = kept.length > 0 ? kept : null;\n } else if (!planMode && !excluded) {\n edits[key] = [...items, name];\n }\n }\n return edits;\n}\n\n/**\n * A send's `runConfig.custom` in plan mode `planMode`, after everything else\n * (the host's `extraRunConfig` included) is merged: `undefined` leaves it as it\n * is; otherwise {@link planModeListEdits}, an emptied list omitted. Pure.\n */\nexport function withPlanMode({\n custom,\n planMode,\n}: {\n custom: Record<string, unknown>;\n planMode: boolean | undefined;\n}): Record<string, unknown> {\n if (planMode === undefined) return custom;\n const edits = planModeListEdits({ custom, planMode });\n if (Object.keys(edits).length === 0) return custom;\n const next: Record<string, unknown> = { ...custom };\n for (const [key, value] of Object.entries(edits)) {\n if (value === null) delete next[key];\n else next[key] = value;\n }\n return next;\n}\n\n/** A thread's plan mode, read from its server config lane. */\nexport interface AthenaThreadPlanMode {\n /**\n * Whether the thread's server config plans (`true`) or not (`false`); `null`\n * while it has none, when every turn runs with what the send carries (the\n * provider's `planMode`, and a plan when the provider sets none).\n */\n planMode: boolean | null;\n /** `true` once the thread has a server config lane (version > 0). */\n configured: boolean;\n /**\n * `true` once the statewire host's snapshot of this thread has arrived (the\n * placeholder or remembered snapshot a thread shows while it loads may carry\n * no lane, or an older one). Before that `planMode` is `null`.\n */\n ready: boolean;\n}\n\n/** {@link AthenaThreadPlanMode} from the lane and the landed flag. Pure. */\nexport function threadPlanModeFromLane({\n lane,\n ready,\n}: {\n lane: DeepAgentServerConfig | null;\n ready: boolean;\n}): AthenaThreadPlanMode {\n if (!ready || lane === null) return { planMode: null, configured: false, ready };\n return { planMode: planModeOf(lane.custom), configured: true, ready };\n}\n\n/**\n * What to do with a `planMode` change the host made during an attach, decided\n * as every provider-owned thread-config key is (`decideThreadConfigLanePatch`):\n *\n * - `wait`: keep it pending. The thread's snapshot has not landed, or the\n * thread has no lane yet (version 0), where the next send carries plan mode.\n * It stays pending so that a lane an EARLIER send seeds is corrected once it\n * lands.\n * - `done`: the lane already plans that way (this client's own unacknowledged\n * writes folded over); nothing to write.\n * - `patch`: issue one `config/patch` carrying the exclusion lists that change,\n * computed from the lane's own, so a name another client excluded stays.\n */\nexport type PlanModeLaneDecision =\n | { kind: 'wait' }\n | { kind: 'done' }\n | { kind: 'patch'; patch: ThreadConfigPatch };\n\nexport function decidePlanModeLanePatch({\n planMode,\n landed,\n configVersion,\n custom,\n}: {\n /** The provider's `planMode` after the change. */\n planMode: boolean;\n landed: boolean;\n configVersion: number;\n /** The effective lane: the server config with this client's pending writes folded over. */\n custom: ThreadConfigCustom;\n}): PlanModeLaneDecision {\n if (!landed || configVersion <= 0) return { kind: 'wait' };\n const patch = planModeListEdits({ custom, planMode });\n return Object.keys(patch).length === 0 ? { kind: 'done' } : { kind: 'patch', patch };\n}\n"],"names":[],"mappings":";;AAeO,MAAM,iBAAiB;AAGvB,MAAM,uBAAuB;AAEpC,MAAM,iBAAiB;AACvB,MAAM,sBAAsB;AAG5B,MAAM,uBAAuB;AAAA,EAC3B,EAAE,KAAK,gBAAgB,MAAM,eAAA;AAAA,EAC7B,EAAE,KAAK,qBAAqB,MAAM,qBAAA;AACpC;AAEA,MAAM,cAAc,CAAC,UACnB,MAAM,QAAQ,KAAK,IAAI,MAAM,OAAO,CAAC,SAAyB,OAAO,SAAS,QAAQ,IAAI,CAAA;AAGrF,SAAS,WAAW,QAAqC;AAC9D,SAAO,qBAAqB,MAAM,CAAC,EAAE,KAAK,KAAA,MAAW,CAAC,YAAY,OAAO,GAAG,CAAC,EAAE,SAAS,IAAI,CAAC;AAC/F;AAWO,SAAS,kBAAkB;AAAA,EAChC;AAAA,EACA;AACF,GAGsB;AACpB,QAAM,QAA2B,CAAA;AACjC,MAAI,WAAW,MAAM,MAAM,SAAU,QAAO;AAC5C,aAAW,EAAE,KAAK,KAAA,KAAU,sBAAsB;AAChD,UAAM,QAAQ,YAAY,OAAO,GAAG,CAAC;AACrC,UAAM,WAAW,MAAM,SAAS,IAAI;AACpC,QAAI,YAAY,UAAU;AACxB,YAAM,OAAO,MAAM,OAAO,CAAC,SAAS,SAAS,IAAI;AACjD,YAAM,GAAG,IAAI,KAAK,SAAS,IAAI,OAAO;AAAA,IACxC,WAAW,CAAC,YAAY,CAAC,UAAU;AACjC,YAAM,GAAG,IAAI,CAAC,GAAG,OAAO,IAAI;AAAA,IAC9B;AAAA,EACF;AACA,SAAO;AACT;AAOO,SAAS,aAAa;AAAA,EAC3B;AAAA,EACA;AACF,GAG4B;AAC1B,MAAI,aAAa,OAAW,QAAO;AACnC,QAAM,QAAQ,kBAAkB,EAAE,QAAQ,UAAU;AACpD,MAAI,OAAO,KAAK,KAAK,EAAE,WAAW,EAAG,QAAO;AAC5C,QAAM,OAAgC,EAAE,GAAG,OAAA;AAC3C,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,KAAK,GAAG;AAChD,QAAI,UAAU,KAAM,QAAO,KAAK,GAAG;AAAA,QAC9B,MAAK,GAAG,IAAI;AAAA,EACnB;AACA,SAAO;AACT;AAqBO,SAAS,uBAAuB;AAAA,EACrC;AAAA,EACA;AACF,GAGyB;AACvB,MAAI,CAAC,SAAS,SAAS,KAAM,QAAO,EAAE,UAAU,MAAM,YAAY,OAAO,MAAA;AACzE,SAAO,EAAE,UAAU,WAAW,KAAK,MAAM,GAAG,YAAY,MAAM,MAAA;AAChE;AAoBO,SAAS,wBAAwB;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAOyB;AACvB,MAAI,CAAC,UAAU,iBAAiB,EAAG,QAAO,EAAE,MAAM,OAAA;AAClD,QAAM,QAAQ,kBAAkB,EAAE,QAAQ,UAAU;AACpD,SAAO,OAAO,KAAK,KAAK,EAAE,WAAW,IAAI,EAAE,MAAM,OAAA,IAAW,EAAE,MAAM,SAAS,MAAA;AAC/E;;;;;;;;"}
@@ -0,0 +1,88 @@
1
+ import type { DeepAgentServerConfig, ThreadConfigCustom, ThreadConfigPatch } from '../agent-runtime/src/index';
2
+ /**
3
+ * Plan mode: the deep agent keeps a to-do plan for multi-step work and checks
4
+ * its steps off as it goes. That is the `write_todos` tool and the
5
+ * `TodoListMiddleware` that provides it with its planning prompt, which agora
6
+ * binds on every run unless the run's config excludes either one
7
+ * (`excluded_tools`, `excluded_middleware`). The two go together, as Olympus's
8
+ * Plan Mode switch flips them (`applyPlanningEnabled`): a config plans unless
9
+ * it excludes either.
10
+ */
11
+ export declare const PLAN_MODE_TOOL = "write_todos";
12
+ /** The middleware that provides {@link PLAN_MODE_TOOL} and its planning prompt. */
13
+ export declare const PLAN_MODE_MIDDLEWARE = "TodoListMiddleware";
14
+ /** Whether a config (a send's `runConfig.custom`, or a thread's server config) plans. Pure. */
15
+ export declare function planModeOf(custom: ThreadConfigCustom): boolean;
16
+ /**
17
+ * The exclusion lists that put `custom` in plan mode `planMode`, keyed as a
18
+ * config carries them, and only those that change: plan mode off adds
19
+ * `write_todos` to `excluded_tools` and `TodoListMiddleware` to
20
+ * `excluded_middleware` after what each already lists; on takes them out, and
21
+ * a list left empty is `null` (a `config/patch` unsets it). Every other name in
22
+ * either list stays where it is. `{}` when `custom` is in that plan mode
23
+ * already (off: it excludes either one). Pure.
24
+ */
25
+ export declare function planModeListEdits({ custom, planMode, }: {
26
+ custom: ThreadConfigCustom;
27
+ planMode: boolean;
28
+ }): ThreadConfigPatch;
29
+ /**
30
+ * A send's `runConfig.custom` in plan mode `planMode`, after everything else
31
+ * (the host's `extraRunConfig` included) is merged: `undefined` leaves it as it
32
+ * is; otherwise {@link planModeListEdits}, an emptied list omitted. Pure.
33
+ */
34
+ export declare function withPlanMode({ custom, planMode, }: {
35
+ custom: Record<string, unknown>;
36
+ planMode: boolean | undefined;
37
+ }): Record<string, unknown>;
38
+ /** A thread's plan mode, read from its server config lane. */
39
+ export interface AthenaThreadPlanMode {
40
+ /**
41
+ * Whether the thread's server config plans (`true`) or not (`false`); `null`
42
+ * while it has none, when every turn runs with what the send carries (the
43
+ * provider's `planMode`, and a plan when the provider sets none).
44
+ */
45
+ planMode: boolean | null;
46
+ /** `true` once the thread has a server config lane (version > 0). */
47
+ configured: boolean;
48
+ /**
49
+ * `true` once the statewire host's snapshot of this thread has arrived (the
50
+ * placeholder or remembered snapshot a thread shows while it loads may carry
51
+ * no lane, or an older one). Before that `planMode` is `null`.
52
+ */
53
+ ready: boolean;
54
+ }
55
+ /** {@link AthenaThreadPlanMode} from the lane and the landed flag. Pure. */
56
+ export declare function threadPlanModeFromLane({ lane, ready, }: {
57
+ lane: DeepAgentServerConfig | null;
58
+ ready: boolean;
59
+ }): AthenaThreadPlanMode;
60
+ /**
61
+ * What to do with a `planMode` change the host made during an attach, decided
62
+ * as every provider-owned thread-config key is (`decideThreadConfigLanePatch`):
63
+ *
64
+ * - `wait`: keep it pending. The thread's snapshot has not landed, or the
65
+ * thread has no lane yet (version 0), where the next send carries plan mode.
66
+ * It stays pending so that a lane an EARLIER send seeds is corrected once it
67
+ * lands.
68
+ * - `done`: the lane already plans that way (this client's own unacknowledged
69
+ * writes folded over); nothing to write.
70
+ * - `patch`: issue one `config/patch` carrying the exclusion lists that change,
71
+ * computed from the lane's own, so a name another client excluded stays.
72
+ */
73
+ export type PlanModeLaneDecision = {
74
+ kind: 'wait';
75
+ } | {
76
+ kind: 'done';
77
+ } | {
78
+ kind: 'patch';
79
+ patch: ThreadConfigPatch;
80
+ };
81
+ export declare function decidePlanModeLanePatch({ planMode, landed, configVersion, custom, }: {
82
+ /** The provider's `planMode` after the change. */
83
+ planMode: boolean;
84
+ landed: boolean;
85
+ configVersion: number;
86
+ /** The effective lane: the server config with this client's pending writes folded over. */
87
+ custom: ThreadConfigCustom;
88
+ }): PlanModeLaneDecision;