@opengeni/react 6.5.2-canary.41607687019001 → 6.7.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 (1154) hide show
  1. package/dist/app/app-state.d.ts +4 -0
  2. package/dist/app/app-state.js +19 -14
  3. package/dist/app/components/Composer.js +25 -23
  4. package/dist/app/components/agent/agent-capability-picker.js +10 -8
  5. package/dist/app/components/artifacts/artifact-browse-controls.js +4 -4
  6. package/dist/app/components/artifacts/artifact-library.js +21 -19
  7. package/dist/app/components/artifacts/artifact-page-chrome.js +3 -3
  8. package/dist/app/components/artifacts/artifact-viewer.js +23 -22
  9. package/dist/app/components/artifacts/artifact-viewer.js.map +1 -1
  10. package/dist/app/components/artifacts/chat-interactive-block.js +12 -12
  11. package/dist/app/components/artifacts/copy-artifact-link.js +7 -5
  12. package/dist/app/components/artifacts/file-reach-dialog.js +11 -9
  13. package/dist/app/components/artifacts/inline-chat-image.js +18 -18
  14. package/dist/app/components/artifacts/retained-file-preview.js +24 -23
  15. package/dist/app/components/artifacts/retained-text-preview.js +3 -3
  16. package/dist/app/components/artifacts/site-audience.js +6 -5
  17. package/dist/app/components/artifacts/site-conversations.js +16 -14
  18. package/dist/app/components/artifacts/site-data.js +18 -16
  19. package/dist/app/components/artifacts/site-public-link.js +3 -2
  20. package/dist/app/components/artifacts/site-publishing-page.js +39 -37
  21. package/dist/app/components/artifacts/site-publishing.js +34 -32
  22. package/dist/app/components/artifacts/site-settings.js +38 -36
  23. package/dist/app/components/artifacts/site-version-menu.js +8 -7
  24. package/dist/app/components/billing-class-mark.js +3 -3
  25. package/dist/app/components/bots/bot-launch-strip.js +17 -17
  26. package/dist/app/components/bots/bot-template-dialog.js +30 -28
  27. package/dist/app/components/bots/bot-template-shortcuts.js +19 -19
  28. package/dist/app/components/bots/bot-templates-page.js +38 -36
  29. package/dist/app/components/bots/bot-templates-page.js.map +1 -1
  30. package/dist/app/components/capabilities/capability-detail-sheet.js +13 -11
  31. package/dist/app/components/capabilities/capability-logo-source.js +13 -13
  32. package/dist/app/components/capabilities/capability-logo.js +4 -3
  33. package/dist/app/components/capabilities/connector-tool-permissions.js +8 -6
  34. package/dist/app/components/capabilities/native-connect-setup.js +14 -14
  35. package/dist/app/components/capabilities/own-logins-shared-heads-up.js +7 -6
  36. package/dist/app/components/capabilities/perform-capability-action.js +7 -6
  37. package/dist/app/components/capabilities/prepared-mcp-setup-card.js +17 -17
  38. package/dist/app/components/capabilities/session-capability-card.js +72 -70
  39. package/dist/app/components/capabilities/session-capability-card.js.map +1 -1
  40. package/dist/app/components/capabilities/session-chrome-card.js +28 -26
  41. package/dist/app/components/capabilities/session-connection-accounts.js +4 -3
  42. package/dist/app/components/capabilities/session-custom-mcp-card.js +20 -19
  43. package/dist/app/components/capabilities/session-github-card.js +22 -20
  44. package/dist/app/components/capabilities/session-machine-card.js +27 -25
  45. package/dist/app/components/capabilities/session-personal-github-card.js +16 -16
  46. package/dist/app/components/capabilities/session-plugin-card.js +10 -9
  47. package/dist/app/components/capabilities/use-capabilities-catalog.js +4 -3
  48. package/dist/app/components/capabilities/use-connection-accounts.js +5 -4
  49. package/dist/app/components/command-menu/chat-status.js +15 -13
  50. package/dist/app/components/command-menu/chat-switcher.js +35 -33
  51. package/dist/app/components/command-menu/chat-switcher.js.map +1 -1
  52. package/dist/app/components/command-menu/command-menu.js +53 -50
  53. package/dist/app/components/command-menu/command-menu.js.map +1 -1
  54. package/dist/app/components/command-menu/shortcut-sheet.js +18 -16
  55. package/dist/app/components/command-menu/shortcut-sheet.js.map +1 -1
  56. package/dist/app/components/common.js +4 -3
  57. package/dist/app/components/composer-capabilities-menu-body.js +4 -4
  58. package/dist/app/components/composer-mobile-plus-panel.js +8 -8
  59. package/dist/app/components/composer-mobile-plus.js +1 -1
  60. package/dist/app/components/credit-required-gate.js +3 -3
  61. package/dist/app/components/credit-required-prompt.js +10 -8
  62. package/dist/app/components/credit-required-prompt.js.map +1 -1
  63. package/dist/app/components/credits/checkout-credits-celebration.js +3 -2
  64. package/dist/app/components/credits/checkout-return.js +3 -2
  65. package/dist/app/components/credits/checkout-return.js.map +1 -1
  66. package/dist/app/components/credits/coupon-redeem.js +5 -4
  67. package/dist/app/components/credits/credit-refusal-notice.js +7 -5
  68. package/dist/app/components/cross-slot-deep-link-recovery.js +5 -4
  69. package/dist/app/components/desktop/app-shots.js +13 -11
  70. package/dist/app/components/desktop/computer-use.js +6 -4
  71. package/dist/app/components/desktop/this-computer.js +9 -7
  72. package/dist/app/components/feedback.js +5 -4
  73. package/dist/app/components/follow-up-repository-menu-body.js +8 -6
  74. package/dist/app/components/follow-up-repository-menu-body.js.map +1 -1
  75. package/dist/app/components/follow-up-repository-picker.js +1 -1
  76. package/dist/app/components/github-app-connect-launcher.js +5 -4
  77. package/dist/app/components/in-app-help-link.js +3 -3
  78. package/dist/app/components/knowledge/agent-learning-settings.js +3 -2
  79. package/dist/app/components/knowledge/agent-learning-settings.js.map +1 -1
  80. package/dist/app/components/machines/connect-machine-dialog.js +18 -16
  81. package/dist/app/components/manual-repository-editor.js +3 -2
  82. package/dist/app/components/markdown.js +6 -6
  83. package/dist/app/components/models/models-ui.js +12 -10
  84. package/dist/app/components/my-things.js +12 -10
  85. package/dist/app/components/my-things.js.map +1 -1
  86. package/dist/app/components/new-session-starters.js +3 -3
  87. package/dist/app/components/own-where-it-works.js +9 -7
  88. package/dist/app/components/personal-resource-attachment-surface.js +4 -4
  89. package/dist/app/components/pickers.js +5 -5
  90. package/dist/app/components/rail/channel-create-dialog.js +7 -5
  91. package/dist/app/components/rail/project-glyph.js +17 -17
  92. package/dist/app/components/rail/project-profile.js +31 -29
  93. package/dist/app/components/rail/rail-context.js +3 -3
  94. package/dist/app/components/rail/rail-sections.js +68 -66
  95. package/dist/app/components/rail/session-header.js +59 -57
  96. package/dist/app/components/rail/session-list.js +66 -64
  97. package/dist/app/components/rail/session-row-content.js +4 -4
  98. package/dist/app/components/rail/session-row-hover-details.js +14 -12
  99. package/dist/app/components/rail/session-shell.js +90 -88
  100. package/dist/app/components/rail/site-session-group-heading.js +8 -8
  101. package/dist/app/components/repository-picker.js +8 -6
  102. package/dist/app/components/secrets/session-secrets-panel.js +4 -3
  103. package/dist/app/components/secrets/vault-model.js +3 -2
  104. package/dist/app/components/session/agent-configuration-panel.js +25 -23
  105. package/dist/app/components/session/agent-configuration-panel.js.map +1 -1
  106. package/dist/app/components/session/artifact-link-boundary.js +3 -3
  107. package/dist/app/components/session/artifact-session-page.js +11 -9
  108. package/dist/app/components/session/banners.js +8 -8
  109. package/dist/app/components/session/codex-usage-notice.js +5 -3
  110. package/dist/app/components/session/console-new-conversation.js +42 -40
  111. package/dist/app/components/session/context-text-reader.js +3 -2
  112. package/dist/app/components/session/descendant-requests.js +39 -37
  113. package/dist/app/components/session/descendant-requests.js.map +1 -1
  114. package/dist/app/components/session/editable-artifacts-workspace.js +36 -34
  115. package/dist/app/components/session/editable-artifacts-workspace.js.map +1 -1
  116. package/dist/app/components/session/failed-session-banner.js +13 -11
  117. package/dist/app/components/session/failed-session-banner.js.map +1 -1
  118. package/dist/app/components/session/failure-recovery-boundary.js +3 -3
  119. package/dist/app/components/session/human-input-delegation-record.js +2 -2
  120. package/dist/app/components/session/human-input.js +33 -31
  121. package/dist/app/components/session/inspector.js +57 -55
  122. package/dist/app/components/session/inspector.js.map +1 -1
  123. package/dist/app/components/session/message-actions.js +5 -4
  124. package/dist/app/components/session/message-actions.js.map +1 -1
  125. package/dist/app/components/session/message-resource-attachments.js +12 -11
  126. package/dist/app/components/session/message-resource-attachments.js.map +1 -1
  127. package/dist/app/components/session/model-context-inspector.js +6 -4
  128. package/dist/app/components/session/model-recovery-notice.js +3 -3
  129. package/dist/app/components/session/new-session-settings-menu.js +11 -9
  130. package/dist/app/components/session/new-session-setup-strip.js +18 -18
  131. package/dist/app/components/session/sandbox-recovery-actions.js +3 -3
  132. package/dist/app/components/session/sandbox-switcher.js +10 -9
  133. package/dist/app/components/session/sandbox-workspace.js +47 -46
  134. package/dist/app/components/session/search-markdown-highlight.js +7 -7
  135. package/dist/app/components/session/search-results-view.js +8 -8
  136. package/dist/app/components/session/session-admin-access.js +13 -11
  137. package/dist/app/components/session/session-admission-notice.js +7 -5
  138. package/dist/app/components/session/session-avatar-picker.js +22 -20
  139. package/dist/app/components/session/session-avatar.js +16 -16
  140. package/dist/app/components/session/session-machine-access-notice.js +7 -5
  141. package/dist/app/components/session/session-profile-dialog.js +29 -27
  142. package/dist/app/components/session/session-profile-editor.js +30 -28
  143. package/dist/app/components/session/session-retention.js +10 -8
  144. package/dist/app/components/session/session-search-dialog.js +10 -10
  145. package/dist/app/components/session/session-skill-reviews.js +2 -1
  146. package/dist/app/components/session/session-skill-reviews.js.map +1 -1
  147. package/dist/app/components/session/session-tenancy-control.js +13 -11
  148. package/dist/app/components/session/session-tenancy-control.js.map +1 -1
  149. package/dist/app/components/session/session-unattended-setting.js +7 -5
  150. package/dist/app/components/session/session-usage-limit-section.js +11 -9
  151. package/dist/app/components/session/share-chat-dialog.js +9 -7
  152. package/dist/app/components/session/site-origin-link.js +3 -3
  153. package/dist/app/components/session/subagents.js +8 -8
  154. package/dist/app/components/session/subscription-account-indicator.js +6 -6
  155. package/dist/app/components/session-connectors-menu-body.js +4 -3
  156. package/dist/app/components/session-connectors-menu-body.js.map +1 -1
  157. package/dist/app/components/settings/row-select.js +7 -5
  158. package/dist/app/components/toaster.js +3 -2
  159. package/dist/app/components/transcription-settings.js +11 -9
  160. package/dist/app/components/ui/destructive-confirm.js +11 -9
  161. package/dist/app/components/usage/usage-entry.js +5 -5
  162. package/dist/app/components/window-bar.js +16 -14
  163. package/dist/app/components/workspace-composer-plus.js +22 -21
  164. package/dist/app/components/workspace-reach.js +6 -4
  165. package/dist/app/components/workspace-tenant-boundary.js +5 -4
  166. package/dist/app/embed/memory-navigation.js +3 -3
  167. package/dist/app/embed/session-app.js +211 -209
  168. package/dist/app/lib/actions/actions-provider.js +15 -13
  169. package/dist/app/lib/agent-capabilities.js +3 -3
  170. package/dist/app/lib/app-surfaces.js +7 -6
  171. package/dist/app/lib/archive-session.d.ts +9 -4
  172. package/dist/app/lib/archive-session.js +4 -2
  173. package/dist/app/lib/bot-templates.js +3 -2
  174. package/dist/app/lib/capabilities.js +3 -2
  175. package/dist/app/lib/codex-usage-query.js +2 -2
  176. package/dist/app/lib/composer-connectors.js +17 -16
  177. package/dist/app/lib/console-site.js +2 -2
  178. package/dist/app/lib/console-text.js +2 -2
  179. package/dist/app/lib/events.js +9 -9
  180. package/dist/app/lib/failed-session-copy.js +3 -3
  181. package/dist/app/lib/inbox.js +4 -2
  182. package/dist/app/lib/model-access-onboarding.js +3 -3
  183. package/dist/app/lib/move-chat-to-machine.js +3 -3
  184. package/dist/app/lib/navigation.js +2 -2
  185. package/dist/app/lib/session-branch-cache.js +6 -6
  186. package/dist/app/lib/session-create.js +4 -4
  187. package/dist/app/lib/session-group-pagination.js +6 -6
  188. package/dist/app/lib/session-hover-facts.js +13 -11
  189. package/dist/app/lib/session-model.js +2 -2
  190. package/dist/app/lib/session-rail.js +3 -3
  191. package/dist/app/lib/session-rename.js +3 -3
  192. package/dist/app/lib/session-restart-operation-controller.js +4 -3
  193. package/dist/app/lib/session-tenancy.js +3 -2
  194. package/dist/app/lib/session-usage-limit.js +3 -2
  195. package/dist/app/lib/sessions-group.js +5 -5
  196. package/dist/app/lib/site-publishing.js +3 -2
  197. package/dist/app/lib/site-tool-consent-dialog.js +9 -7
  198. package/dist/app/lib/site-tool-consent-dialog.js.map +1 -1
  199. package/dist/app/lib/site-tool-consent.js +1 -1
  200. package/dist/app/lib/subscription-plans.js +3 -2
  201. package/dist/app/lib/toast.js +2 -1
  202. package/dist/app/lib/turn-failure-analytics.js +4 -4
  203. package/dist/app/lib/use-duplicate-site.js +6 -5
  204. package/dist/app/lib/use-follow-up-repositories.js +6 -5
  205. package/dist/app/lib/use-workspace-integrations.js +4 -3
  206. package/dist/app/lib/use-workspace-machines.js +4 -4
  207. package/dist/app/lib/use-workspace-model-catalog.js +5 -4
  208. package/dist/app/lib/use-workspace-rigs.js +2 -2
  209. package/dist/app/lib/workspace-navigation-preference.js +4 -4
  210. package/dist/app/lib/workspace-scope-context.js +3 -3
  211. package/dist/app/routes/artifacts.js +67 -66
  212. package/dist/app/routes/artifacts.js.map +1 -1
  213. package/dist/app/routes/retained-artifact.js +42 -40
  214. package/dist/app/routes/retained-artifact.js.map +1 -1
  215. package/dist/app/routes/session-unavailable.js +8 -7
  216. package/dist/app/routes/session.js +119 -117
  217. package/dist/app/routes/sessions-index-hydration.js +5 -5
  218. package/dist/app/routes/sessions-index.js +104 -102
  219. package/dist/app/routes/site-view.js +67 -65
  220. package/dist/app/routes/site-view.js.map +1 -1
  221. package/dist/artifacts-document.js +4 -4
  222. package/dist/artifacts-presentation.js +4 -4
  223. package/dist/artifacts-spreadsheet.js +4 -4
  224. package/dist/artifacts.js +10 -10
  225. package/dist/automations.js +17 -15
  226. package/dist/automations.js.map +1 -1
  227. package/dist/browser-viewer-TC27OCIP.js +23 -0
  228. package/dist/chat-interactive-block-RWPQBHVS.js +18 -0
  229. package/dist/chunk-2BDT3UZQ.js +229 -0
  230. package/dist/chunk-2CLNIEK4.js +373 -0
  231. package/dist/chunk-2FSBSCZJ.js +451 -0
  232. package/dist/chunk-2I7HDP53.js +199 -0
  233. package/dist/chunk-2INLDVK3.js +15 -0
  234. package/dist/chunk-2KALVELR.js +126 -0
  235. package/dist/chunk-2M3J7ZWQ.js +418 -0
  236. package/dist/chunk-2OP6WLGV.js +708 -0
  237. package/dist/chunk-2RG7NIAS.js +2936 -0
  238. package/dist/chunk-2STUPWEL.js +135 -0
  239. package/dist/chunk-2YUOVM3G.js +271 -0
  240. package/dist/chunk-2Z3NQNTM.js +3670 -0
  241. package/dist/chunk-3CPWWGNK.js +920 -0
  242. package/dist/chunk-3ED2U6XE.js +37 -0
  243. package/dist/chunk-3GZA4BUW.js +216 -0
  244. package/dist/chunk-3IK6UYO6.js +1022 -0
  245. package/dist/chunk-3PZ7JZI2.js +431 -0
  246. package/dist/chunk-4DVJ6ONS.js +50 -0
  247. package/dist/chunk-4DVNUCRR.js +2386 -0
  248. package/dist/chunk-4DVNUCRR.js.map +1 -0
  249. package/dist/chunk-4E3ZJRTZ.js +41 -0
  250. package/dist/chunk-4SAWSRAA.js +141 -0
  251. package/dist/chunk-53AGXXZM.js +307 -0
  252. package/dist/chunk-54YW6SZZ.js +818 -0
  253. package/dist/chunk-57AZS3IE.js +2317 -0
  254. package/dist/chunk-5CPEEAFD.js +143 -0
  255. package/dist/chunk-5EWSRZ2Y.js +340 -0
  256. package/dist/chunk-5IE76VCY.js +387 -0
  257. package/dist/chunk-5NWEKLDZ.js +170 -0
  258. package/dist/chunk-5O2FCCHZ.js +198 -0
  259. package/dist/chunk-5QAY6K77.js +399 -0
  260. package/dist/chunk-5YKW2K6I.js +625 -0
  261. package/dist/chunk-5YKW2K6I.js.map +1 -0
  262. package/dist/chunk-6BCXNDEI.js +4116 -0
  263. package/dist/chunk-6BCXNDEI.js.map +1 -0
  264. package/dist/chunk-6DK6Z4UN.js +2599 -0
  265. package/dist/chunk-6DVCC7QS.js +702 -0
  266. package/dist/chunk-6JHU2UBS.js +2058 -0
  267. package/dist/chunk-6PZ7OBYU.js +490 -0
  268. package/dist/chunk-6WD2INST.js +539 -0
  269. package/dist/chunk-6WD2INST.js.map +1 -0
  270. package/dist/chunk-6WGRDRMA.js +163 -0
  271. package/dist/chunk-77WAKEAH.js +186 -0
  272. package/dist/chunk-7T2ZE3VT.js +5558 -0
  273. package/dist/chunk-7T2ZE3VT.js.map +1 -0
  274. package/dist/chunk-7TDO3CUM.js +393 -0
  275. package/dist/chunk-7TIX2UAR.js +247 -0
  276. package/dist/chunk-7V5REBCP.js +148 -0
  277. package/dist/chunk-7VMZGLYI.js +339 -0
  278. package/dist/chunk-7W37NS3I.js +236 -0
  279. package/dist/chunk-7X6SDK2C.js +111 -0
  280. package/dist/chunk-7ZNUHRP5.js +95 -0
  281. package/dist/chunk-A36PZALD.js +84 -0
  282. package/dist/chunk-AUI6VA63.js +107 -0
  283. package/dist/chunk-AW2MQB37.js +24 -0
  284. package/dist/chunk-AWKES45Y.js +198 -0
  285. package/dist/chunk-AXHZYXUV.js +132 -0
  286. package/dist/chunk-BHNSJVBC.js +129 -0
  287. package/dist/chunk-BJEJFISW.js +50 -0
  288. package/dist/chunk-BJFH6JI5.js +422 -0
  289. package/dist/chunk-BMICEQZQ.js +960 -0
  290. package/dist/chunk-BTLBYBLU.js +29 -0
  291. package/dist/chunk-BXBDYNRP.js +89 -0
  292. package/dist/chunk-C372BFOV.js +357 -0
  293. package/dist/chunk-C43KRXGA.js +234 -0
  294. package/dist/chunk-C43KRXGA.js.map +1 -0
  295. package/dist/chunk-CMKGILJK.js +4824 -0
  296. package/dist/chunk-CRAOSVHC.js +50 -0
  297. package/dist/chunk-CRU35QQH.js +281 -0
  298. package/dist/chunk-CUIWCGMA.js +172 -0
  299. package/dist/chunk-D5TWNFFE.js +38 -0
  300. package/dist/chunk-DF5EAHDN.js +4461 -0
  301. package/dist/chunk-DJAXC5OK.js +56 -0
  302. package/dist/chunk-DXBYWSL5.js +3550 -0
  303. package/dist/chunk-DXR5PDFP.js +84 -0
  304. package/dist/chunk-DZWARC4M.js +267 -0
  305. package/dist/chunk-DZXEDSQI.js +106 -0
  306. package/dist/chunk-E7XERZWC.js +48 -0
  307. package/dist/chunk-ECJBYNLJ.js +79 -0
  308. package/dist/chunk-EDI6SJ2N.js +43 -0
  309. package/dist/chunk-EWSOC6WF.js +114 -0
  310. package/dist/chunk-F2OPHAUN.js +103 -0
  311. package/dist/chunk-F4ISQGGM.js +81 -0
  312. package/dist/chunk-FO4LYKJL.js +197 -0
  313. package/dist/chunk-FPXASDG5.js +73 -0
  314. package/dist/chunk-FSOQDUCG.js +117 -0
  315. package/dist/chunk-FSOQDUCG.js.map +1 -0
  316. package/dist/chunk-FVXBNBHO.js +157 -0
  317. package/dist/chunk-FYWT2O76.js +34 -0
  318. package/dist/chunk-FYWT2O76.js.map +1 -0
  319. package/dist/chunk-FZC5N55X.js +981 -0
  320. package/dist/chunk-GAVYGBFI.js +99 -0
  321. package/dist/chunk-GFIMOUDT.js +846 -0
  322. package/dist/chunk-GFIMOUDT.js.map +1 -0
  323. package/dist/chunk-GKVJIDHF.js +33 -0
  324. package/dist/chunk-GVN5SZLX.js +212 -0
  325. package/dist/chunk-H3T7IWNA.js +134 -0
  326. package/dist/chunk-HAX4LCR5.js +261 -0
  327. package/dist/chunk-HC4JFZVU.js +121 -0
  328. package/dist/chunk-HEFPPMBQ.js +581 -0
  329. package/dist/chunk-HGKTHF2U.js +1356 -0
  330. package/dist/chunk-HGKTHF2U.js.map +1 -0
  331. package/dist/chunk-HNLR7Q4Z.js +83 -0
  332. package/dist/chunk-HSOXMJOT.js +12 -0
  333. package/dist/chunk-I4MRDSUF.js +281 -0
  334. package/dist/chunk-I4QEJ62Y.js +202 -0
  335. package/dist/chunk-I5B5L6Q4.js +56 -0
  336. package/dist/chunk-I5QZJODL.js +264 -0
  337. package/dist/chunk-I7ITSXSJ.js +603 -0
  338. package/dist/chunk-I7XIZRFD.js +390 -0
  339. package/dist/chunk-IDANQPRH.js +82 -0
  340. package/dist/chunk-IFB3WJ36.js +212 -0
  341. package/dist/chunk-IHTAKKTK.js +264 -0
  342. package/dist/chunk-IKXNLWAL.js +205 -0
  343. package/dist/chunk-IKXNLWAL.js.map +1 -0
  344. package/dist/chunk-ILDXWY37.js +173 -0
  345. package/dist/chunk-IMDQUHBJ.js +570 -0
  346. package/dist/chunk-IMZCQBOT.js +119 -0
  347. package/dist/chunk-IXPTECSC.js +403 -0
  348. package/dist/chunk-J255A3N5.js +71 -0
  349. package/dist/chunk-J5F5HPPW.js +141 -0
  350. package/dist/chunk-JDTGRRNU.js +5045 -0
  351. package/dist/chunk-JDTGRRNU.js.map +1 -0
  352. package/dist/chunk-JEA3QDX7.js +2469 -0
  353. package/dist/chunk-JEUPAVYY.js +156 -0
  354. package/dist/chunk-JKHKLL5W.js +194 -0
  355. package/dist/chunk-JQL7ZH6C.js +650 -0
  356. package/dist/chunk-JWB44UGJ.js +57 -0
  357. package/dist/chunk-JZ4NLCAP.js +333 -0
  358. package/dist/chunk-K2A5PXQ5.js +412 -0
  359. package/dist/chunk-K56XV3C3.js +623 -0
  360. package/dist/chunk-K6GAXXVA.js +23 -0
  361. package/dist/chunk-KCBMFSMS.js +199 -0
  362. package/dist/chunk-KF2FV3ZJ.js +268 -0
  363. package/dist/chunk-KJD65EJP.js +278 -0
  364. package/dist/chunk-KLEUWIMZ.js +386 -0
  365. package/dist/chunk-KODELWYT.js +309 -0
  366. package/dist/chunk-KRDR5RJD.js +83 -0
  367. package/dist/chunk-KUDGXAF7.js +914 -0
  368. package/dist/chunk-KY2R73CG.js +171 -0
  369. package/dist/chunk-KY2R73CG.js.map +1 -0
  370. package/dist/chunk-KYS77RPN.js +85 -0
  371. package/dist/chunk-L7YTNTIK.js +368 -0
  372. package/dist/chunk-LHPNABDH.js +686 -0
  373. package/dist/chunk-MFROMEKA.js +401 -0
  374. package/dist/chunk-MIHN76LX.js +2656 -0
  375. package/dist/chunk-MIYFS2XN.js +42 -0
  376. package/dist/chunk-MJUCFQMS.js +65 -0
  377. package/dist/chunk-MM4FNWI4.js +3064 -0
  378. package/dist/chunk-MNZG4OHU.js +790 -0
  379. package/dist/chunk-MVW6HNPI.js +250 -0
  380. package/dist/chunk-MVW6HNPI.js.map +1 -0
  381. package/dist/chunk-N6AACDUW.js +200 -0
  382. package/dist/chunk-NC55IFN3.js +781 -0
  383. package/dist/chunk-NC7PVOEK.js +98 -0
  384. package/dist/chunk-NCYMNCJO.js +70 -0
  385. package/dist/chunk-ND2BXV3P.js +259 -0
  386. package/dist/chunk-NDBTFUO6.js +272 -0
  387. package/dist/chunk-NDQJZ7HF.js +206 -0
  388. package/dist/chunk-NGJJJPZZ.js +162 -0
  389. package/dist/chunk-NJTSNNE7.js +251 -0
  390. package/dist/chunk-NPGISCU6.js +4159 -0
  391. package/dist/chunk-NPGISCU6.js.map +1 -0
  392. package/dist/chunk-NRTE7DNV.js +1270 -0
  393. package/dist/chunk-NULUNM7H.js +290 -0
  394. package/dist/chunk-NUNZS36W.js +227 -0
  395. package/dist/chunk-NW53H5RW.js +2424 -0
  396. package/dist/chunk-NXCMHIKI.js +263 -0
  397. package/dist/chunk-O3LKCBP5.js +159 -0
  398. package/dist/chunk-O4EA4F3W.js +103 -0
  399. package/dist/chunk-O4EA4F3W.js.map +1 -0
  400. package/dist/chunk-O4OOG3D6.js +116 -0
  401. package/dist/chunk-O4OOG3D6.js.map +1 -0
  402. package/dist/chunk-O6N4ABCA.js +376 -0
  403. package/dist/chunk-O732GAFC.js +112 -0
  404. package/dist/chunk-OF4TIKYC.js +690 -0
  405. package/dist/chunk-OMPVOMPP.js +70 -0
  406. package/dist/chunk-OPJJSKUK.js +118 -0
  407. package/dist/chunk-OPWCMA4D.js +196 -0
  408. package/dist/chunk-ORJPS5VN.js +1193 -0
  409. package/dist/chunk-OSY5K7L7.js +187 -0
  410. package/dist/chunk-OV6QJRT4.js +45 -0
  411. package/dist/chunk-OVKYVZMW.js +108 -0
  412. package/dist/chunk-OZCBM3UC.js +171 -0
  413. package/dist/chunk-P3A2EINJ.js +61 -0
  414. package/dist/chunk-PTAG4PDC.js +27 -0
  415. package/dist/chunk-PTF5B7TJ.js +298 -0
  416. package/dist/chunk-Q3DPEYX4.js +848 -0
  417. package/dist/chunk-Q6CGOPJD.js +215 -0
  418. package/dist/chunk-Q6CGOPJD.js.map +1 -0
  419. package/dist/chunk-QB2KMIDP.js +100 -0
  420. package/dist/chunk-QCSJ4CWE.js +1067 -0
  421. package/dist/chunk-QIOQ2NPQ.js +414 -0
  422. package/dist/chunk-QK5EFEUT.js +353 -0
  423. package/dist/chunk-QPQBLYQJ.js +41 -0
  424. package/dist/chunk-QPSGCC5D.js +184 -0
  425. package/dist/chunk-QZAAUQRN.js +474 -0
  426. package/dist/chunk-QZM6YDJW.js +489 -0
  427. package/dist/chunk-QZM6YDJW.js.map +1 -0
  428. package/dist/chunk-RGBI63KJ.js +188 -0
  429. package/dist/chunk-RLBKLAEY.js +138 -0
  430. package/dist/chunk-RMFKVOM7.js +304 -0
  431. package/dist/chunk-ROKQU7WG.js +258 -0
  432. package/dist/chunk-RPVREAU7.js +251 -0
  433. package/dist/chunk-RQKLF42C.js +723 -0
  434. package/dist/chunk-SC6RRD2D.js +38 -0
  435. package/dist/chunk-SC6RRD2D.js.map +1 -0
  436. package/dist/chunk-SEO7TICN.js +94 -0
  437. package/dist/chunk-SHHJCL7X.js +432 -0
  438. package/dist/chunk-SIRLACNZ.js +114 -0
  439. package/dist/chunk-SKPHMYAA.js +237 -0
  440. package/dist/chunk-SODC7T6L.js +1583 -0
  441. package/dist/chunk-SQJIKMN3.js +366 -0
  442. package/dist/chunk-SVINDKVW.js +26 -0
  443. package/dist/chunk-SYCDHPZF.js +335 -0
  444. package/dist/chunk-T2QX3FDP.js +133 -0
  445. package/dist/chunk-T3OWFVMS.js +1187 -0
  446. package/dist/chunk-T6XI5FLY.js +61 -0
  447. package/dist/chunk-T7OXJZCX.js +62 -0
  448. package/dist/chunk-TAT5USZN.js +353 -0
  449. package/dist/chunk-TPQTRNER.js +172 -0
  450. package/dist/chunk-TUIN4MB7.js +266 -0
  451. package/dist/chunk-TX3VECZU.js +71 -0
  452. package/dist/chunk-TXLIEOJX.js +9624 -0
  453. package/dist/chunk-U3DN4HEY.js +27 -0
  454. package/dist/chunk-U7XM7CB4.js +191 -0
  455. package/dist/chunk-UJK53QFL.js +140 -0
  456. package/dist/chunk-UMTXA2TH.js +319 -0
  457. package/dist/chunk-UPDSXFK5.js +199 -0
  458. package/dist/chunk-UTIAXH52.js +269 -0
  459. package/dist/chunk-UVN5TMHU.js +1184 -0
  460. package/dist/chunk-V4Z4B2E3.js +52 -0
  461. package/dist/chunk-V4Z4B2E3.js.map +1 -0
  462. package/dist/chunk-VGYXW3VG.js +246 -0
  463. package/dist/chunk-VS7AHPCZ.js +255 -0
  464. package/dist/chunk-VTTAJOQ7.js +121 -0
  465. package/dist/chunk-VWPOLUAO.js +99 -0
  466. package/dist/chunk-X3MWB2QU.js +3851 -0
  467. package/dist/chunk-X6KAJI3V.js +211 -0
  468. package/dist/chunk-XBLRHV5R.js +50 -0
  469. package/dist/chunk-XDFP2LMW.js +605 -0
  470. package/dist/chunk-XEQMZB3C.js +525 -0
  471. package/dist/chunk-XEYLT5VA.js +223 -0
  472. package/dist/chunk-XHIQ5I6N.js +918 -0
  473. package/dist/chunk-XLH7QY2R.js +378 -0
  474. package/dist/chunk-XWFAMUZQ.js +113 -0
  475. package/dist/chunk-Y4BB2KS2.js +294 -0
  476. package/dist/chunk-Y4BB2KS2.js.map +1 -0
  477. package/dist/chunk-Y4OBB2VN.js +84 -0
  478. package/dist/chunk-YCVD6CI3.js +234 -0
  479. package/dist/chunk-YENLNISG.js +270 -0
  480. package/dist/chunk-YIRVLKAX.js +351 -0
  481. package/dist/chunk-YL73CVNK.js +390 -0
  482. package/dist/chunk-YLS6QE5G.js +288 -0
  483. package/dist/chunk-YNF2OC54.js +366 -0
  484. package/dist/chunk-YNF2OC54.js.map +1 -0
  485. package/dist/chunk-YPWU5KPE.js +147 -0
  486. package/dist/chunk-YQXTDZSU.js +2984 -0
  487. package/dist/chunk-YSJEAAOL.js +178 -0
  488. package/dist/chunk-YWIFM7D7.js +499 -0
  489. package/dist/chunk-YWVI6ZMK.js +103 -0
  490. package/dist/chunk-Z4FMAFNH.js +847 -0
  491. package/dist/chunk-Z654FWNU.js +136 -0
  492. package/dist/chunk-Z7Y523PS.js +130 -0
  493. package/dist/chunk-ZD67RM6G.js +60 -0
  494. package/dist/chunk-ZEG4VPBL.js +187 -0
  495. package/dist/chunk-ZHDFQITM.js +283 -0
  496. package/dist/chunk-ZHDFQITM.js.map +1 -0
  497. package/dist/chunk-ZLYCOBHW.js +75 -0
  498. package/dist/chunk-ZNJ5MTXV.js +89 -0
  499. package/dist/chunk-ZSGY3H53.js +155 -0
  500. package/dist/chunk-ZTPXACWB.js +1788 -0
  501. package/dist/chunk-ZUA3JMI6.js +107 -0
  502. package/dist/chunk-ZYAZUPPV.js +559 -0
  503. package/dist/composer.js +8 -8
  504. package/dist/computer-viewer-TDDO25AV.js +21 -0
  505. package/dist/connect.js +12 -12
  506. package/dist/desktop-dictation.js +12 -10
  507. package/dist/desktop-dictation.js.map +1 -1
  508. package/dist/desktop.js +2 -2
  509. package/dist/editor.js +2 -2
  510. package/dist/embedded-new-voice-2G3VLPVQ.js +24 -0
  511. package/dist/embedded-voice-T5IWOWGD.js +24 -0
  512. package/dist/fleet-decision-row-WM64KXP3.js +361 -0
  513. package/dist/in-chat-connect-model.js +5 -5
  514. package/dist/index.js +51 -51
  515. package/dist/interaction.js +5 -5
  516. package/dist/machines.js +3 -3
  517. package/dist/meetings-recorder.js +1 -1
  518. package/dist/meetings.js +40 -32
  519. package/dist/meetings.js.map +1 -1
  520. package/dist/messages/en.d.ts +3 -0
  521. package/dist/messages.js +1 -1
  522. package/dist/model-policy-picker-menu-SMC6J6QN.js +22 -0
  523. package/dist/payment-page-card-G4U63KUV.js +223 -0
  524. package/dist/platform-activity-row-BUZGZAKZ.js +128 -0
  525. package/dist/queue-surface-implementation-4KUZ4PJV.js +908 -0
  526. package/dist/realtime.js +4 -4
  527. package/dist/recorder-host-WF2RRR56.js +69 -0
  528. package/dist/recorder-host-WF2RRR56.js.map +1 -0
  529. package/dist/recordings.js +3 -3
  530. package/dist/sandbox-files-ESDMOFSD.js +27 -0
  531. package/dist/session-app.js +211 -209
  532. package/dist/session-connect-cards-Q53KMMYY.js +25 -0
  533. package/dist/session-list-model.js +2 -2
  534. package/dist/session-realtime-CF3I35WJ.js +30 -0
  535. package/dist/session-realtime.js +2 -2
  536. package/dist/session-ui.js +33 -31
  537. package/dist/session.js +5 -5
  538. package/dist/sites.js +2 -2
  539. package/dist/terminal.js +2 -2
  540. package/dist/this-computer.js +3 -3
  541. package/dist/timeline-annotation-markers-CJK4RYZ4.js +157 -0
  542. package/dist/timeline-annotation-selection-67GF5H26.js +208 -0
  543. package/dist/timeline-annotations-dialog-ONJPQDJQ.js +283 -0
  544. package/dist/ui/access-list.js +11 -9
  545. package/dist/ui/access-list.js.map +1 -1
  546. package/dist/ui/api-error.d.ts +6 -3
  547. package/dist/ui/api-error.js +2 -1
  548. package/dist/ui/cadence-picker.js +6 -4
  549. package/dist/ui/choice-cards.js +5 -3
  550. package/dist/ui/confirm-dialog.js +2 -2
  551. package/dist/ui/copy-field.js +5 -3
  552. package/dist/ui/detail-page.js +2 -2
  553. package/dist/ui/detail-sheet.js +2 -2
  554. package/dist/ui/diff-view.js +4 -3
  555. package/dist/ui/disclosure.js +3 -3
  556. package/dist/ui/email-chips-input.js +5 -3
  557. package/dist/ui/error-message.js +2 -1
  558. package/dist/ui/error-reference.d.ts +15 -0
  559. package/dist/ui/error-text.d.ts +10 -0
  560. package/dist/ui/error-text.js +9 -0
  561. package/dist/ui/error-text.js.map +1 -0
  562. package/dist/ui/field.js +4 -2
  563. package/dist/ui/flush-form-page.js +8 -6
  564. package/dist/ui/form-dialog.js +7 -5
  565. package/dist/ui/list-row.js +3 -3
  566. package/dist/ui/load-failure.js +3 -2
  567. package/dist/ui/load-failure.js.map +1 -1
  568. package/dist/ui/notice.js +3 -1
  569. package/dist/ui/relative-time.js +2 -2
  570. package/dist/ui/revision-history.js +9 -7
  571. package/dist/ui/revision-history.js.map +1 -1
  572. package/dist/ui/role-select.js +10 -8
  573. package/dist/ui/segmented-control.js +4 -2
  574. package/dist/ui/select-menu.js +5 -3
  575. package/dist/ui/setting-row.js +3 -1
  576. package/dist/ui/switch.js +4 -2
  577. package/dist/ui/usage-meter.js +3 -3
  578. package/dist/ui/word-list-row.js +4 -2
  579. package/dist/usage.js +2 -2
  580. package/dist/workbench.js +4 -4
  581. package/package.json +5 -6
  582. package/src/app/app-state.tsx +126 -14
  583. package/src/app/components/artifacts/site-data.tsx +2 -2
  584. package/src/app/components/artifacts/site-settings.tsx +2 -2
  585. package/src/app/components/rail/session-list.tsx +7 -8
  586. package/src/app/components/rail/session-shell.tsx +3 -3
  587. package/src/app/components/repository-picker.tsx +8 -1
  588. package/src/app/components/session/model-context-inspector.tsx +2 -1
  589. package/src/app/components/session/session-admin-access.tsx +2 -2
  590. package/src/app/lib/actions/chat-operations.ts +4 -4
  591. package/src/app/lib/archive-session.test.tsx +265 -2
  592. package/src/app/lib/archive-session.tsx +175 -9
  593. package/src/app/lib/copy-link.ts +2 -2
  594. package/src/app/lib/inbox.tsx +2 -2
  595. package/src/app/lib/session-failure-toasts.ts +3 -2
  596. package/src/app/lib/toast.test.tsx +215 -0
  597. package/src/app/lib/toast.tsx +67 -2
  598. package/src/app/personal-github-reconnect.test.tsx +356 -0
  599. package/src/app/routes/artifacts.tsx +1 -2
  600. package/src/components/tool-action-review.tsx +14 -1
  601. package/src/meetings/delete-meeting-dialog.tsx +2 -1
  602. package/src/meetings/meeting-ask.tsx +2 -1
  603. package/src/meetings/meeting-detail-page.tsx +2 -1
  604. package/src/meetings/meeting-notes.tsx +2 -1
  605. package/src/meetings/meeting-settings.tsx +4 -1
  606. package/src/meetings/meeting-transcript.tsx +4 -1
  607. package/src/meetings/recorder-context.tsx +10 -0
  608. package/src/meetings/recorder-host.test.tsx +60 -2
  609. package/src/meetings/recorder-host.tsx +16 -3
  610. package/src/meetings/recorder-panel.tsx +2 -1
  611. package/src/meetings/recorder-workspace.test.tsx +26 -1
  612. package/src/messages/en.ts +6 -0
  613. package/src/ui/api-error.test.ts +29 -5
  614. package/src/ui/api-error.tsx +10 -4
  615. package/src/ui/error-message.tsx +8 -0
  616. package/src/ui/error-reference.test.ts +54 -0
  617. package/src/ui/error-reference.ts +51 -0
  618. package/src/ui/error-text.test.tsx +66 -0
  619. package/src/ui/error-text.tsx +49 -0
  620. package/src/ui/field.tsx +4 -1
  621. package/src/ui/notice.tsx +7 -2
  622. package/src/ui/setting-row.tsx +4 -1
  623. package/styles/app.css +12 -0
  624. package/styles/compiled.css +9 -0
  625. package/dist/browser-viewer-NOP5EAUO.js +0 -23
  626. package/dist/chat-interactive-block-G7O44JHR.js +0 -18
  627. package/dist/chunk-26RWVLRD.js +0 -135
  628. package/dist/chunk-2AHTY7OT.js +0 -247
  629. package/dist/chunk-2GDNWKSC.js +0 -3670
  630. package/dist/chunk-2JENKGCE.js +0 -339
  631. package/dist/chunk-2KYQC4T5.js +0 -155
  632. package/dist/chunk-2RREGDQH.js +0 -708
  633. package/dist/chunk-2T7DX6KR.js +0 -353
  634. package/dist/chunk-2VB2O4FQ.js +0 -920
  635. package/dist/chunk-2VTTKH23.js +0 -94
  636. package/dist/chunk-2XNG2KNT.js +0 -172
  637. package/dist/chunk-2YC6JQRO.js +0 -399
  638. package/dist/chunk-2ZVRJRXC.js +0 -27
  639. package/dist/chunk-35737UT4.js +0 -162
  640. package/dist/chunk-366XZ4PM.js +0 -41
  641. package/dist/chunk-36MIDGAH.js +0 -199
  642. package/dist/chunk-3FD76LXM.js +0 -212
  643. package/dist/chunk-3OVIXY4O.js +0 -213
  644. package/dist/chunk-3OVIXY4O.js.map +0 -1
  645. package/dist/chunk-3QNRBEYH.js +0 -432
  646. package/dist/chunk-3QX55WLC.js +0 -15
  647. package/dist/chunk-3USJPT2S.js +0 -1022
  648. package/dist/chunk-42CMQ5VR.js +0 -251
  649. package/dist/chunk-4LPOWQJY.js +0 -42
  650. package/dist/chunk-4NBTZRKT.js +0 -79
  651. package/dist/chunk-4OXI6HCV.js +0 -118
  652. package/dist/chunk-4SZZAFYQ.js +0 -2317
  653. package/dist/chunk-4TQL3WP2.js +0 -140
  654. package/dist/chunk-4Y6BK7IU.js +0 -196
  655. package/dist/chunk-4YD7YZC5.js +0 -373
  656. package/dist/chunk-5DTST3TP.js +0 -81
  657. package/dist/chunk-5FH5LQVS.js +0 -130
  658. package/dist/chunk-5KWMYPJV.js +0 -847
  659. package/dist/chunk-5MUJDC6C.js +0 -84
  660. package/dist/chunk-5QM2WPKV.js +0 -41
  661. package/dist/chunk-5WUN7XPD.js +0 -1184
  662. package/dist/chunk-64PO2WXU.js +0 -1067
  663. package/dist/chunk-6AHATAAY.js +0 -431
  664. package/dist/chunk-6ED2YWBT.js +0 -56
  665. package/dist/chunk-6GXVYAGR.js +0 -170
  666. package/dist/chunk-6H4SJBPE.js +0 -85
  667. package/dist/chunk-6MT3HHUB.js +0 -84
  668. package/dist/chunk-6UHCBH4G.js +0 -198
  669. package/dist/chunk-6WLX3NR3.js +0 -198
  670. package/dist/chunk-73NXYYWE.js +0 -112
  671. package/dist/chunk-76ERNKIZ.js +0 -603
  672. package/dist/chunk-776QZ573.js +0 -57
  673. package/dist/chunk-7BYWOFVH.js +0 -171
  674. package/dist/chunk-7O5CGGIQ.js +0 -108
  675. package/dist/chunk-7QOHRZ67.js +0 -251
  676. package/dist/chunk-7WIDB4PL.js +0 -2058
  677. package/dist/chunk-7WKP3DYJ.js +0 -37
  678. package/dist/chunk-7XOVTPDI.js +0 -227
  679. package/dist/chunk-AB5MBIXY.js +0 -281
  680. package/dist/chunk-ADNMXBCX.js +0 -1193
  681. package/dist/chunk-AFBJTUFK.js +0 -202
  682. package/dist/chunk-ALVRWCXE.js +0 -61
  683. package/dist/chunk-AOHU6O3M.js +0 -247
  684. package/dist/chunk-AOHU6O3M.js.map +0 -1
  685. package/dist/chunk-APW4T4SW.js +0 -270
  686. package/dist/chunk-AXBSYWKX.js +0 -2656
  687. package/dist/chunk-B2I5ZW35.js +0 -422
  688. package/dist/chunk-B3LMRTRF.js +0 -223
  689. package/dist/chunk-BE2XENG2.js +0 -292
  690. package/dist/chunk-BE2XENG2.js.map +0 -1
  691. package/dist/chunk-BF4SADKX.js +0 -29
  692. package/dist/chunk-BKP43KK4.js +0 -1788
  693. package/dist/chunk-BM3NEZ6X.js +0 -781
  694. package/dist/chunk-BT3BAGB5.js +0 -216
  695. package/dist/chunk-BTSYDIVJ.js +0 -357
  696. package/dist/chunk-BUBNGKWG.js +0 -70
  697. package/dist/chunk-BVUJV5WR.js +0 -126
  698. package/dist/chunk-BZO5ZMUP.js +0 -27
  699. package/dist/chunk-C3HUF3M2.js +0 -157
  700. package/dist/chunk-C5QCAOES.js +0 -264
  701. package/dist/chunk-CGK6ALQU.js +0 -159
  702. package/dist/chunk-CPYGO76Q.js +0 -335
  703. package/dist/chunk-CQH4FWYA.js +0 -490
  704. package/dist/chunk-CZP5QXNB.js +0 -234
  705. package/dist/chunk-D2TOWEYH.js +0 -266
  706. package/dist/chunk-D6L4GHRH.js +0 -340
  707. package/dist/chunk-DKT3N37I.js +0 -50
  708. package/dist/chunk-DMMJIFKA.js +0 -84
  709. package/dist/chunk-DO74DQC7.js +0 -26
  710. package/dist/chunk-DOFJZ2JU.js +0 -83
  711. package/dist/chunk-DSXVY5WZ.js +0 -119
  712. package/dist/chunk-E337C2VK.js +0 -82
  713. package/dist/chunk-E6NRSRBE.js +0 -114
  714. package/dist/chunk-E6SQKHAU.js +0 -114
  715. package/dist/chunk-E7UIVD7F.js +0 -236
  716. package/dist/chunk-EGBII4CP.js +0 -229
  717. package/dist/chunk-EILSAQVJ.js +0 -200
  718. package/dist/chunk-ELL6HSYR.js +0 -307
  719. package/dist/chunk-EUBGLFFR.js +0 -73
  720. package/dist/chunk-EW6RNWSH.js +0 -212
  721. package/dist/chunk-EYUT5Y6V.js +0 -2599
  722. package/dist/chunk-F7U3QPZ3.js +0 -304
  723. package/dist/chunk-FBTJKSTM.js +0 -1270
  724. package/dist/chunk-FC2FTSK3.js +0 -2424
  725. package/dist/chunk-FOGNA3BU.js +0 -148
  726. package/dist/chunk-FQFKHNC7.js +0 -650
  727. package/dist/chunk-FTCHM755.js +0 -50
  728. package/dist/chunk-FXSHP4JZ.js +0 -3550
  729. package/dist/chunk-G6ZZC543.js +0 -818
  730. package/dist/chunk-G7FU6PUA.js +0 -100
  731. package/dist/chunk-GA4YEAMX.js +0 -3851
  732. package/dist/chunk-GE33BGB7.js +0 -12
  733. package/dist/chunk-GQ67HSJY.js +0 -570
  734. package/dist/chunk-GXXZ3WAK.js +0 -106
  735. package/dist/chunk-H2TCRX3H.js +0 -237
  736. package/dist/chunk-HLL4PBO7.js +0 -60
  737. package/dist/chunk-HLOEPV5C.js +0 -259
  738. package/dist/chunk-HUAGBS4O.js +0 -56
  739. package/dist/chunk-I36GSRUJ.js +0 -211
  740. package/dist/chunk-I6VBHT7S.js +0 -261
  741. package/dist/chunk-ICNNNOXE.js +0 -333
  742. package/dist/chunk-ICX64J4U.js +0 -172
  743. package/dist/chunk-ID36Y46W.js +0 -5046
  744. package/dist/chunk-ID36Y46W.js.map +0 -1
  745. package/dist/chunk-IGVVXLKJ.js +0 -559
  746. package/dist/chunk-IKJLSBUI.js +0 -2984
  747. package/dist/chunk-IKMUFDVS.js +0 -50
  748. package/dist/chunk-IKUNOX7F.js +0 -255
  749. package/dist/chunk-ILKDYBON.js +0 -288
  750. package/dist/chunk-IVYJX3OY.js +0 -187
  751. package/dist/chunk-JCY4CMDH.js +0 -107
  752. package/dist/chunk-JJZPLGIP.js +0 -474
  753. package/dist/chunk-JW33RV4V.js +0 -143
  754. package/dist/chunk-JWPA6ZPZ.js +0 -351
  755. package/dist/chunk-JZ4QXS6D.js +0 -50
  756. package/dist/chunk-K42OUZQ3.js +0 -386
  757. package/dist/chunk-K5TOVX5A.js +0 -206
  758. package/dist/chunk-K63HGHZX.js +0 -99
  759. package/dist/chunk-K6R5T44I.js +0 -75
  760. package/dist/chunk-KHJ5PXFM.js +0 -914
  761. package/dist/chunk-KJZRQ55O.js +0 -2319
  762. package/dist/chunk-KJZRQ55O.js.map +0 -1
  763. package/dist/chunk-KKI55ZMW.js +0 -65
  764. package/dist/chunk-KRPLAAFP.js +0 -199
  765. package/dist/chunk-KVFEZDBO.js +0 -134
  766. package/dist/chunk-L4I665WK.js +0 -45
  767. package/dist/chunk-L4OF77LE.js +0 -110
  768. package/dist/chunk-L4OF77LE.js.map +0 -1
  769. package/dist/chunk-LA5T52RM.js +0 -70
  770. package/dist/chunk-LM2W5YAT.js +0 -401
  771. package/dist/chunk-LQ62ECE6.js +0 -390
  772. package/dist/chunk-LQDUHU3Y.js +0 -71
  773. package/dist/chunk-LRJIYTZW.js +0 -4157
  774. package/dist/chunk-LRJIYTZW.js.map +0 -1
  775. package/dist/chunk-LRN6GYAZ.js +0 -138
  776. package/dist/chunk-M4SDVTKJ.js +0 -790
  777. package/dist/chunk-MA6O7CM6.js +0 -99
  778. package/dist/chunk-MBIBB6GI.js +0 -197
  779. package/dist/chunk-MF3ZFB4H.js +0 -199
  780. package/dist/chunk-MJJGJMYJ.js +0 -98
  781. package/dist/chunk-MLJADQFI.js +0 -4824
  782. package/dist/chunk-MQG7RV3B.js +0 -62
  783. package/dist/chunk-MTTGSQA5.js +0 -186
  784. package/dist/chunk-MW7Y3T55.js +0 -525
  785. package/dist/chunk-MYUFMVCH.js +0 -121
  786. package/dist/chunk-N3OARGH2.js +0 -61
  787. package/dist/chunk-NB2HMRT2.js +0 -353
  788. package/dist/chunk-NFDFYWMV.js +0 -141
  789. package/dist/chunk-NWGNFN3N.js +0 -1187
  790. package/dist/chunk-NWJRPDIO.js +0 -840
  791. package/dist/chunk-NWJRPDIO.js.map +0 -1
  792. package/dist/chunk-NXWBBZJV.js +0 -267
  793. package/dist/chunk-NY2QWROL.js +0 -71
  794. package/dist/chunk-O2IOPP3R.js +0 -848
  795. package/dist/chunk-O2UWH5RG.js +0 -141
  796. package/dist/chunk-O5YWDLYF.js +0 -393
  797. package/dist/chunk-OBMCZO7E.js +0 -121
  798. package/dist/chunk-OD3DCCCB.js +0 -132
  799. package/dist/chunk-OMH7R6I3.js +0 -390
  800. package/dist/chunk-OSA5EQG5.js +0 -113
  801. package/dist/chunk-OSJ3MUTZ.js +0 -2936
  802. package/dist/chunk-OWAYJ2OV.js +0 -368
  803. package/dist/chunk-OYXBFSGK.js +0 -269
  804. package/dist/chunk-PC2EBA5G.js +0 -4116
  805. package/dist/chunk-PC2EBA5G.js.map +0 -1
  806. package/dist/chunk-PC2MVXIP.js +0 -363
  807. package/dist/chunk-PC2MVXIP.js.map +0 -1
  808. package/dist/chunk-PENGLDR5.js +0 -309
  809. package/dist/chunk-PSMAWRPL.js +0 -191
  810. package/dist/chunk-PW4IMTYR.js +0 -702
  811. package/dist/chunk-PW54V7T5.js +0 -387
  812. package/dist/chunk-Q2EXYSMO.js +0 -24
  813. package/dist/chunk-Q2XJK5I4.js +0 -51
  814. package/dist/chunk-Q2XJK5I4.js.map +0 -1
  815. package/dist/chunk-Q4EFRI6X.js +0 -258
  816. package/dist/chunk-Q52CXW6C.js +0 -48
  817. package/dist/chunk-Q6XQ2R37.js +0 -184
  818. package/dist/chunk-QAJ53XBW.js +0 -23
  819. package/dist/chunk-QDTKECT4.js +0 -129
  820. package/dist/chunk-QE3ZFGI3.js +0 -43
  821. package/dist/chunk-QHHSUR2Y.js +0 -298
  822. package/dist/chunk-QHNVNR7B.js +0 -173
  823. package/dist/chunk-QIK2Q6N5.js +0 -376
  824. package/dist/chunk-QWL4L366.js +0 -38
  825. package/dist/chunk-R3J2PTVQ.js +0 -690
  826. package/dist/chunk-RBRX5ZS3.js +0 -319
  827. package/dist/chunk-REX6JIC7.js +0 -33
  828. package/dist/chunk-RGZ7EEC3.js +0 -537
  829. package/dist/chunk-RGZ7EEC3.js.map +0 -1
  830. package/dist/chunk-RIPS7GFR.js +0 -960
  831. package/dist/chunk-RTBZNFNV.js +0 -1354
  832. package/dist/chunk-RTBZNFNV.js.map +0 -1
  833. package/dist/chunk-SKMNW4SW.js +0 -187
  834. package/dist/chunk-SRFARKXC.js +0 -623
  835. package/dist/chunk-SWIHWCTW.js +0 -4461
  836. package/dist/chunk-TA5CFTO4.js +0 -103
  837. package/dist/chunk-TF4ZVJLI.js +0 -156
  838. package/dist/chunk-TG7DADJR.js +0 -9624
  839. package/dist/chunk-TI4R2ZD5.js +0 -623
  840. package/dist/chunk-TI4R2ZD5.js.map +0 -1
  841. package/dist/chunk-TNKWOUWP.js +0 -412
  842. package/dist/chunk-TNUSPXPW.js +0 -5555
  843. package/dist/chunk-TNUSPXPW.js.map +0 -1
  844. package/dist/chunk-TNYFHKVV.js +0 -366
  845. package/dist/chunk-TPMZBOFH.js +0 -178
  846. package/dist/chunk-TW3LKRJF.js +0 -263
  847. package/dist/chunk-TZAO65I4.js +0 -83
  848. package/dist/chunk-U5EFEMYU.js +0 -89
  849. package/dist/chunk-U6M4LS3M.js +0 -378
  850. package/dist/chunk-UI4HI5QK.js +0 -918
  851. package/dist/chunk-UJDOWCQ3.js +0 -272
  852. package/dist/chunk-UJUQ2QOX.js +0 -581
  853. package/dist/chunk-UQ3IM6FY.js +0 -133
  854. package/dist/chunk-UYE47LO6.js +0 -246
  855. package/dist/chunk-VADHIT26.js +0 -89
  856. package/dist/chunk-VFQ3H6CO.js +0 -163
  857. package/dist/chunk-VGUN6VB2.js +0 -188
  858. package/dist/chunk-VGWWEVSD.js +0 -723
  859. package/dist/chunk-VIEFJ2DM.js +0 -2469
  860. package/dist/chunk-VLXM36VS.js +0 -268
  861. package/dist/chunk-W3BFRR2G.js +0 -499
  862. package/dist/chunk-W5MPXR3A.js +0 -981
  863. package/dist/chunk-W5OWKVZG.js +0 -136
  864. package/dist/chunk-W6FRORMX.js +0 -486
  865. package/dist/chunk-W6FRORMX.js.map +0 -1
  866. package/dist/chunk-W7XROSZO.js +0 -232
  867. package/dist/chunk-W7XROSZO.js.map +0 -1
  868. package/dist/chunk-WEZ5PXZP.js +0 -403
  869. package/dist/chunk-WHWUWN2X.js +0 -197
  870. package/dist/chunk-WHWUWN2X.js.map +0 -1
  871. package/dist/chunk-WLEDGIVS.js +0 -114
  872. package/dist/chunk-WLEDGIVS.js.map +0 -1
  873. package/dist/chunk-WNDAKLHG.js +0 -281
  874. package/dist/chunk-WTJ4PLMU.js +0 -103
  875. package/dist/chunk-WV2KPJUW.js +0 -107
  876. package/dist/chunk-X3VY5EGY.js +0 -277
  877. package/dist/chunk-X3VY5EGY.js.map +0 -1
  878. package/dist/chunk-XDBYWVCW.js +0 -418
  879. package/dist/chunk-XF7MA4U5.js +0 -36
  880. package/dist/chunk-XF7MA4U5.js.map +0 -1
  881. package/dist/chunk-XOSQP3YA.js +0 -605
  882. package/dist/chunk-XYBV4ZJQ.js +0 -271
  883. package/dist/chunk-YBKVGLQR.js +0 -147
  884. package/dist/chunk-YDCUBUWH.js +0 -1583
  885. package/dist/chunk-YG6NARQY.js +0 -51
  886. package/dist/chunk-YG6NARQY.js.map +0 -1
  887. package/dist/chunk-YSVD5HI4.js +0 -278
  888. package/dist/chunk-YT3WGNG6.js +0 -290
  889. package/dist/chunk-YYICQDK4.js +0 -414
  890. package/dist/chunk-YYLMZLI6.js +0 -686
  891. package/dist/chunk-ZAMTKG5U.js +0 -95
  892. package/dist/chunk-ZDLYSXKN.js +0 -111
  893. package/dist/chunk-ZG447FSS.js +0 -194
  894. package/dist/chunk-ZIT5KD4Q.js +0 -264
  895. package/dist/chunk-ZUDOVDKR.js +0 -3064
  896. package/dist/chunk-ZW2ECJ3A.js +0 -451
  897. package/dist/computer-viewer-LPZ763KF.js +0 -21
  898. package/dist/embedded-new-voice-YVMKSLKJ.js +0 -24
  899. package/dist/embedded-voice-BJPQFXSU.js +0 -24
  900. package/dist/fleet-decision-row-AA4H5CDT.js +0 -361
  901. package/dist/model-policy-picker-menu-HSMWVO4P.js +0 -22
  902. package/dist/payment-page-card-3LTSFJGN.js +0 -223
  903. package/dist/platform-activity-row-5VYV6TX4.js +0 -128
  904. package/dist/queue-surface-implementation-NXHZUKD2.js +0 -908
  905. package/dist/recorder-host-ZKRWTDBM.js +0 -57
  906. package/dist/recorder-host-ZKRWTDBM.js.map +0 -1
  907. package/dist/sandbox-files-YCMLQUFU.js +0 -27
  908. package/dist/session-connect-cards-KSQLMRM5.js +0 -25
  909. package/dist/session-realtime-ZR6JLG3Y.js +0 -30
  910. package/dist/timeline-annotation-markers-YAHDPWVG.js +0 -157
  911. package/dist/timeline-annotation-selection-KHXNCEJP.js +0 -208
  912. package/dist/timeline-annotations-dialog-Y4XD3N7B.js +0 -283
  913. /package/dist/{browser-viewer-NOP5EAUO.js.map → browser-viewer-TC27OCIP.js.map} +0 -0
  914. /package/dist/{chat-interactive-block-G7O44JHR.js.map → chat-interactive-block-RWPQBHVS.js.map} +0 -0
  915. /package/dist/{chunk-EGBII4CP.js.map → chunk-2BDT3UZQ.js.map} +0 -0
  916. /package/dist/{chunk-4YD7YZC5.js.map → chunk-2CLNIEK4.js.map} +0 -0
  917. /package/dist/{chunk-ZW2ECJ3A.js.map → chunk-2FSBSCZJ.js.map} +0 -0
  918. /package/dist/{chunk-KRPLAAFP.js.map → chunk-2I7HDP53.js.map} +0 -0
  919. /package/dist/{chunk-3QX55WLC.js.map → chunk-2INLDVK3.js.map} +0 -0
  920. /package/dist/{chunk-BVUJV5WR.js.map → chunk-2KALVELR.js.map} +0 -0
  921. /package/dist/{chunk-XDBYWVCW.js.map → chunk-2M3J7ZWQ.js.map} +0 -0
  922. /package/dist/{chunk-2RREGDQH.js.map → chunk-2OP6WLGV.js.map} +0 -0
  923. /package/dist/{chunk-OSJ3MUTZ.js.map → chunk-2RG7NIAS.js.map} +0 -0
  924. /package/dist/{chunk-26RWVLRD.js.map → chunk-2STUPWEL.js.map} +0 -0
  925. /package/dist/{chunk-XYBV4ZJQ.js.map → chunk-2YUOVM3G.js.map} +0 -0
  926. /package/dist/{chunk-2GDNWKSC.js.map → chunk-2Z3NQNTM.js.map} +0 -0
  927. /package/dist/{chunk-2VB2O4FQ.js.map → chunk-3CPWWGNK.js.map} +0 -0
  928. /package/dist/{chunk-7WKP3DYJ.js.map → chunk-3ED2U6XE.js.map} +0 -0
  929. /package/dist/{chunk-BT3BAGB5.js.map → chunk-3GZA4BUW.js.map} +0 -0
  930. /package/dist/{chunk-3USJPT2S.js.map → chunk-3IK6UYO6.js.map} +0 -0
  931. /package/dist/{chunk-6AHATAAY.js.map → chunk-3PZ7JZI2.js.map} +0 -0
  932. /package/dist/{chunk-JZ4QXS6D.js.map → chunk-4DVJ6ONS.js.map} +0 -0
  933. /package/dist/{chunk-5QM2WPKV.js.map → chunk-4E3ZJRTZ.js.map} +0 -0
  934. /package/dist/{chunk-NFDFYWMV.js.map → chunk-4SAWSRAA.js.map} +0 -0
  935. /package/dist/{chunk-ELL6HSYR.js.map → chunk-53AGXXZM.js.map} +0 -0
  936. /package/dist/{chunk-G6ZZC543.js.map → chunk-54YW6SZZ.js.map} +0 -0
  937. /package/dist/{chunk-4SZZAFYQ.js.map → chunk-57AZS3IE.js.map} +0 -0
  938. /package/dist/{chunk-JW33RV4V.js.map → chunk-5CPEEAFD.js.map} +0 -0
  939. /package/dist/{chunk-D6L4GHRH.js.map → chunk-5EWSRZ2Y.js.map} +0 -0
  940. /package/dist/{chunk-PW54V7T5.js.map → chunk-5IE76VCY.js.map} +0 -0
  941. /package/dist/{chunk-6GXVYAGR.js.map → chunk-5NWEKLDZ.js.map} +0 -0
  942. /package/dist/{chunk-6UHCBH4G.js.map → chunk-5O2FCCHZ.js.map} +0 -0
  943. /package/dist/{chunk-2YC6JQRO.js.map → chunk-5QAY6K77.js.map} +0 -0
  944. /package/dist/{chunk-EYUT5Y6V.js.map → chunk-6DK6Z4UN.js.map} +0 -0
  945. /package/dist/{chunk-PW4IMTYR.js.map → chunk-6DVCC7QS.js.map} +0 -0
  946. /package/dist/{chunk-7WIDB4PL.js.map → chunk-6JHU2UBS.js.map} +0 -0
  947. /package/dist/{chunk-CQH4FWYA.js.map → chunk-6PZ7OBYU.js.map} +0 -0
  948. /package/dist/{chunk-VFQ3H6CO.js.map → chunk-6WGRDRMA.js.map} +0 -0
  949. /package/dist/{chunk-MTTGSQA5.js.map → chunk-77WAKEAH.js.map} +0 -0
  950. /package/dist/{chunk-O5YWDLYF.js.map → chunk-7TDO3CUM.js.map} +0 -0
  951. /package/dist/{chunk-2AHTY7OT.js.map → chunk-7TIX2UAR.js.map} +0 -0
  952. /package/dist/{chunk-FOGNA3BU.js.map → chunk-7V5REBCP.js.map} +0 -0
  953. /package/dist/{chunk-2JENKGCE.js.map → chunk-7VMZGLYI.js.map} +0 -0
  954. /package/dist/{chunk-E7UIVD7F.js.map → chunk-7W37NS3I.js.map} +0 -0
  955. /package/dist/{chunk-ZDLYSXKN.js.map → chunk-7X6SDK2C.js.map} +0 -0
  956. /package/dist/{chunk-ZAMTKG5U.js.map → chunk-7ZNUHRP5.js.map} +0 -0
  957. /package/dist/{chunk-DMMJIFKA.js.map → chunk-A36PZALD.js.map} +0 -0
  958. /package/dist/{chunk-WV2KPJUW.js.map → chunk-AUI6VA63.js.map} +0 -0
  959. /package/dist/{chunk-Q2EXYSMO.js.map → chunk-AW2MQB37.js.map} +0 -0
  960. /package/dist/{chunk-6WLX3NR3.js.map → chunk-AWKES45Y.js.map} +0 -0
  961. /package/dist/{chunk-OD3DCCCB.js.map → chunk-AXHZYXUV.js.map} +0 -0
  962. /package/dist/{chunk-QDTKECT4.js.map → chunk-BHNSJVBC.js.map} +0 -0
  963. /package/dist/{chunk-FTCHM755.js.map → chunk-BJEJFISW.js.map} +0 -0
  964. /package/dist/{chunk-B2I5ZW35.js.map → chunk-BJFH6JI5.js.map} +0 -0
  965. /package/dist/{chunk-RIPS7GFR.js.map → chunk-BMICEQZQ.js.map} +0 -0
  966. /package/dist/{chunk-BF4SADKX.js.map → chunk-BTLBYBLU.js.map} +0 -0
  967. /package/dist/{chunk-U5EFEMYU.js.map → chunk-BXBDYNRP.js.map} +0 -0
  968. /package/dist/{chunk-BTSYDIVJ.js.map → chunk-C372BFOV.js.map} +0 -0
  969. /package/dist/{chunk-MLJADQFI.js.map → chunk-CMKGILJK.js.map} +0 -0
  970. /package/dist/{chunk-DKT3N37I.js.map → chunk-CRAOSVHC.js.map} +0 -0
  971. /package/dist/{chunk-WNDAKLHG.js.map → chunk-CRU35QQH.js.map} +0 -0
  972. /package/dist/{chunk-2XNG2KNT.js.map → chunk-CUIWCGMA.js.map} +0 -0
  973. /package/dist/{chunk-QWL4L366.js.map → chunk-D5TWNFFE.js.map} +0 -0
  974. /package/dist/{chunk-SWIHWCTW.js.map → chunk-DF5EAHDN.js.map} +0 -0
  975. /package/dist/{chunk-HUAGBS4O.js.map → chunk-DJAXC5OK.js.map} +0 -0
  976. /package/dist/{chunk-FXSHP4JZ.js.map → chunk-DXBYWSL5.js.map} +0 -0
  977. /package/dist/{chunk-5MUJDC6C.js.map → chunk-DXR5PDFP.js.map} +0 -0
  978. /package/dist/{chunk-NXWBBZJV.js.map → chunk-DZWARC4M.js.map} +0 -0
  979. /package/dist/{chunk-GXXZ3WAK.js.map → chunk-DZXEDSQI.js.map} +0 -0
  980. /package/dist/{chunk-Q52CXW6C.js.map → chunk-E7XERZWC.js.map} +0 -0
  981. /package/dist/{chunk-4NBTZRKT.js.map → chunk-ECJBYNLJ.js.map} +0 -0
  982. /package/dist/{chunk-QE3ZFGI3.js.map → chunk-EDI6SJ2N.js.map} +0 -0
  983. /package/dist/{chunk-E6NRSRBE.js.map → chunk-EWSOC6WF.js.map} +0 -0
  984. /package/dist/{chunk-TA5CFTO4.js.map → chunk-F2OPHAUN.js.map} +0 -0
  985. /package/dist/{chunk-5DTST3TP.js.map → chunk-F4ISQGGM.js.map} +0 -0
  986. /package/dist/{chunk-MBIBB6GI.js.map → chunk-FO4LYKJL.js.map} +0 -0
  987. /package/dist/{chunk-EUBGLFFR.js.map → chunk-FPXASDG5.js.map} +0 -0
  988. /package/dist/{chunk-C3HUF3M2.js.map → chunk-FVXBNBHO.js.map} +0 -0
  989. /package/dist/{chunk-W5MPXR3A.js.map → chunk-FZC5N55X.js.map} +0 -0
  990. /package/dist/{chunk-MA6O7CM6.js.map → chunk-GAVYGBFI.js.map} +0 -0
  991. /package/dist/{chunk-REX6JIC7.js.map → chunk-GKVJIDHF.js.map} +0 -0
  992. /package/dist/{chunk-EW6RNWSH.js.map → chunk-GVN5SZLX.js.map} +0 -0
  993. /package/dist/{chunk-KVFEZDBO.js.map → chunk-H3T7IWNA.js.map} +0 -0
  994. /package/dist/{chunk-I6VBHT7S.js.map → chunk-HAX4LCR5.js.map} +0 -0
  995. /package/dist/{chunk-OBMCZO7E.js.map → chunk-HC4JFZVU.js.map} +0 -0
  996. /package/dist/{chunk-UJUQ2QOX.js.map → chunk-HEFPPMBQ.js.map} +0 -0
  997. /package/dist/{chunk-DOFJZ2JU.js.map → chunk-HNLR7Q4Z.js.map} +0 -0
  998. /package/dist/{chunk-GE33BGB7.js.map → chunk-HSOXMJOT.js.map} +0 -0
  999. /package/dist/{chunk-AB5MBIXY.js.map → chunk-I4MRDSUF.js.map} +0 -0
  1000. /package/dist/{chunk-AFBJTUFK.js.map → chunk-I4QEJ62Y.js.map} +0 -0
  1001. /package/dist/{chunk-6ED2YWBT.js.map → chunk-I5B5L6Q4.js.map} +0 -0
  1002. /package/dist/{chunk-C5QCAOES.js.map → chunk-I5QZJODL.js.map} +0 -0
  1003. /package/dist/{chunk-76ERNKIZ.js.map → chunk-I7ITSXSJ.js.map} +0 -0
  1004. /package/dist/{chunk-OMH7R6I3.js.map → chunk-I7XIZRFD.js.map} +0 -0
  1005. /package/dist/{chunk-E337C2VK.js.map → chunk-IDANQPRH.js.map} +0 -0
  1006. /package/dist/{chunk-3FD76LXM.js.map → chunk-IFB3WJ36.js.map} +0 -0
  1007. /package/dist/{chunk-ZIT5KD4Q.js.map → chunk-IHTAKKTK.js.map} +0 -0
  1008. /package/dist/{chunk-QHNVNR7B.js.map → chunk-ILDXWY37.js.map} +0 -0
  1009. /package/dist/{chunk-GQ67HSJY.js.map → chunk-IMDQUHBJ.js.map} +0 -0
  1010. /package/dist/{chunk-DSXVY5WZ.js.map → chunk-IMZCQBOT.js.map} +0 -0
  1011. /package/dist/{chunk-WEZ5PXZP.js.map → chunk-IXPTECSC.js.map} +0 -0
  1012. /package/dist/{chunk-NY2QWROL.js.map → chunk-J255A3N5.js.map} +0 -0
  1013. /package/dist/{chunk-O2UWH5RG.js.map → chunk-J5F5HPPW.js.map} +0 -0
  1014. /package/dist/{chunk-VIEFJ2DM.js.map → chunk-JEA3QDX7.js.map} +0 -0
  1015. /package/dist/{chunk-TF4ZVJLI.js.map → chunk-JEUPAVYY.js.map} +0 -0
  1016. /package/dist/{chunk-ZG447FSS.js.map → chunk-JKHKLL5W.js.map} +0 -0
  1017. /package/dist/{chunk-FQFKHNC7.js.map → chunk-JQL7ZH6C.js.map} +0 -0
  1018. /package/dist/{chunk-776QZ573.js.map → chunk-JWB44UGJ.js.map} +0 -0
  1019. /package/dist/{chunk-ICNNNOXE.js.map → chunk-JZ4NLCAP.js.map} +0 -0
  1020. /package/dist/{chunk-TNKWOUWP.js.map → chunk-K2A5PXQ5.js.map} +0 -0
  1021. /package/dist/{chunk-SRFARKXC.js.map → chunk-K56XV3C3.js.map} +0 -0
  1022. /package/dist/{chunk-QAJ53XBW.js.map → chunk-K6GAXXVA.js.map} +0 -0
  1023. /package/dist/{chunk-MF3ZFB4H.js.map → chunk-KCBMFSMS.js.map} +0 -0
  1024. /package/dist/{chunk-VLXM36VS.js.map → chunk-KF2FV3ZJ.js.map} +0 -0
  1025. /package/dist/{chunk-YSVD5HI4.js.map → chunk-KJD65EJP.js.map} +0 -0
  1026. /package/dist/{chunk-K42OUZQ3.js.map → chunk-KLEUWIMZ.js.map} +0 -0
  1027. /package/dist/{chunk-PENGLDR5.js.map → chunk-KODELWYT.js.map} +0 -0
  1028. /package/dist/{chunk-TZAO65I4.js.map → chunk-KRDR5RJD.js.map} +0 -0
  1029. /package/dist/{chunk-KHJ5PXFM.js.map → chunk-KUDGXAF7.js.map} +0 -0
  1030. /package/dist/{chunk-6H4SJBPE.js.map → chunk-KYS77RPN.js.map} +0 -0
  1031. /package/dist/{chunk-OWAYJ2OV.js.map → chunk-L7YTNTIK.js.map} +0 -0
  1032. /package/dist/{chunk-YYLMZLI6.js.map → chunk-LHPNABDH.js.map} +0 -0
  1033. /package/dist/{chunk-LM2W5YAT.js.map → chunk-MFROMEKA.js.map} +0 -0
  1034. /package/dist/{chunk-AXBSYWKX.js.map → chunk-MIHN76LX.js.map} +0 -0
  1035. /package/dist/{chunk-4LPOWQJY.js.map → chunk-MIYFS2XN.js.map} +0 -0
  1036. /package/dist/{chunk-KKI55ZMW.js.map → chunk-MJUCFQMS.js.map} +0 -0
  1037. /package/dist/{chunk-ZUDOVDKR.js.map → chunk-MM4FNWI4.js.map} +0 -0
  1038. /package/dist/{chunk-M4SDVTKJ.js.map → chunk-MNZG4OHU.js.map} +0 -0
  1039. /package/dist/{chunk-EILSAQVJ.js.map → chunk-N6AACDUW.js.map} +0 -0
  1040. /package/dist/{chunk-BM3NEZ6X.js.map → chunk-NC55IFN3.js.map} +0 -0
  1041. /package/dist/{chunk-MJJGJMYJ.js.map → chunk-NC7PVOEK.js.map} +0 -0
  1042. /package/dist/{chunk-LA5T52RM.js.map → chunk-NCYMNCJO.js.map} +0 -0
  1043. /package/dist/{chunk-HLOEPV5C.js.map → chunk-ND2BXV3P.js.map} +0 -0
  1044. /package/dist/{chunk-UJDOWCQ3.js.map → chunk-NDBTFUO6.js.map} +0 -0
  1045. /package/dist/{chunk-K5TOVX5A.js.map → chunk-NDQJZ7HF.js.map} +0 -0
  1046. /package/dist/{chunk-35737UT4.js.map → chunk-NGJJJPZZ.js.map} +0 -0
  1047. /package/dist/{chunk-42CMQ5VR.js.map → chunk-NJTSNNE7.js.map} +0 -0
  1048. /package/dist/{chunk-FBTJKSTM.js.map → chunk-NRTE7DNV.js.map} +0 -0
  1049. /package/dist/{chunk-YT3WGNG6.js.map → chunk-NULUNM7H.js.map} +0 -0
  1050. /package/dist/{chunk-7XOVTPDI.js.map → chunk-NUNZS36W.js.map} +0 -0
  1051. /package/dist/{chunk-FC2FTSK3.js.map → chunk-NW53H5RW.js.map} +0 -0
  1052. /package/dist/{chunk-TW3LKRJF.js.map → chunk-NXCMHIKI.js.map} +0 -0
  1053. /package/dist/{chunk-CGK6ALQU.js.map → chunk-O3LKCBP5.js.map} +0 -0
  1054. /package/dist/{chunk-QIK2Q6N5.js.map → chunk-O6N4ABCA.js.map} +0 -0
  1055. /package/dist/{chunk-73NXYYWE.js.map → chunk-O732GAFC.js.map} +0 -0
  1056. /package/dist/{chunk-R3J2PTVQ.js.map → chunk-OF4TIKYC.js.map} +0 -0
  1057. /package/dist/{chunk-BUBNGKWG.js.map → chunk-OMPVOMPP.js.map} +0 -0
  1058. /package/dist/{chunk-4OXI6HCV.js.map → chunk-OPJJSKUK.js.map} +0 -0
  1059. /package/dist/{chunk-4Y6BK7IU.js.map → chunk-OPWCMA4D.js.map} +0 -0
  1060. /package/dist/{chunk-ADNMXBCX.js.map → chunk-ORJPS5VN.js.map} +0 -0
  1061. /package/dist/{chunk-SKMNW4SW.js.map → chunk-OSY5K7L7.js.map} +0 -0
  1062. /package/dist/{chunk-L4I665WK.js.map → chunk-OV6QJRT4.js.map} +0 -0
  1063. /package/dist/{chunk-7O5CGGIQ.js.map → chunk-OVKYVZMW.js.map} +0 -0
  1064. /package/dist/{chunk-7BYWOFVH.js.map → chunk-OZCBM3UC.js.map} +0 -0
  1065. /package/dist/{chunk-ALVRWCXE.js.map → chunk-P3A2EINJ.js.map} +0 -0
  1066. /package/dist/{chunk-BZO5ZMUP.js.map → chunk-PTAG4PDC.js.map} +0 -0
  1067. /package/dist/{chunk-QHHSUR2Y.js.map → chunk-PTF5B7TJ.js.map} +0 -0
  1068. /package/dist/{chunk-O2IOPP3R.js.map → chunk-Q3DPEYX4.js.map} +0 -0
  1069. /package/dist/{chunk-G7FU6PUA.js.map → chunk-QB2KMIDP.js.map} +0 -0
  1070. /package/dist/{chunk-64PO2WXU.js.map → chunk-QCSJ4CWE.js.map} +0 -0
  1071. /package/dist/{chunk-YYICQDK4.js.map → chunk-QIOQ2NPQ.js.map} +0 -0
  1072. /package/dist/{chunk-NB2HMRT2.js.map → chunk-QK5EFEUT.js.map} +0 -0
  1073. /package/dist/{chunk-366XZ4PM.js.map → chunk-QPQBLYQJ.js.map} +0 -0
  1074. /package/dist/{chunk-Q6XQ2R37.js.map → chunk-QPSGCC5D.js.map} +0 -0
  1075. /package/dist/{chunk-JJZPLGIP.js.map → chunk-QZAAUQRN.js.map} +0 -0
  1076. /package/dist/{chunk-VGUN6VB2.js.map → chunk-RGBI63KJ.js.map} +0 -0
  1077. /package/dist/{chunk-LRN6GYAZ.js.map → chunk-RLBKLAEY.js.map} +0 -0
  1078. /package/dist/{chunk-F7U3QPZ3.js.map → chunk-RMFKVOM7.js.map} +0 -0
  1079. /package/dist/{chunk-Q4EFRI6X.js.map → chunk-ROKQU7WG.js.map} +0 -0
  1080. /package/dist/{chunk-7QOHRZ67.js.map → chunk-RPVREAU7.js.map} +0 -0
  1081. /package/dist/{chunk-VGWWEVSD.js.map → chunk-RQKLF42C.js.map} +0 -0
  1082. /package/dist/{chunk-2VTTKH23.js.map → chunk-SEO7TICN.js.map} +0 -0
  1083. /package/dist/{chunk-3QNRBEYH.js.map → chunk-SHHJCL7X.js.map} +0 -0
  1084. /package/dist/{chunk-E6SQKHAU.js.map → chunk-SIRLACNZ.js.map} +0 -0
  1085. /package/dist/{chunk-H2TCRX3H.js.map → chunk-SKPHMYAA.js.map} +0 -0
  1086. /package/dist/{chunk-YDCUBUWH.js.map → chunk-SODC7T6L.js.map} +0 -0
  1087. /package/dist/{chunk-TNYFHKVV.js.map → chunk-SQJIKMN3.js.map} +0 -0
  1088. /package/dist/{chunk-DO74DQC7.js.map → chunk-SVINDKVW.js.map} +0 -0
  1089. /package/dist/{chunk-CPYGO76Q.js.map → chunk-SYCDHPZF.js.map} +0 -0
  1090. /package/dist/{chunk-UQ3IM6FY.js.map → chunk-T2QX3FDP.js.map} +0 -0
  1091. /package/dist/{chunk-NWGNFN3N.js.map → chunk-T3OWFVMS.js.map} +0 -0
  1092. /package/dist/{chunk-N3OARGH2.js.map → chunk-T6XI5FLY.js.map} +0 -0
  1093. /package/dist/{chunk-MQG7RV3B.js.map → chunk-T7OXJZCX.js.map} +0 -0
  1094. /package/dist/{chunk-2T7DX6KR.js.map → chunk-TAT5USZN.js.map} +0 -0
  1095. /package/dist/{chunk-ICX64J4U.js.map → chunk-TPQTRNER.js.map} +0 -0
  1096. /package/dist/{chunk-D2TOWEYH.js.map → chunk-TUIN4MB7.js.map} +0 -0
  1097. /package/dist/{chunk-LQDUHU3Y.js.map → chunk-TX3VECZU.js.map} +0 -0
  1098. /package/dist/{chunk-TG7DADJR.js.map → chunk-TXLIEOJX.js.map} +0 -0
  1099. /package/dist/{chunk-2ZVRJRXC.js.map → chunk-U3DN4HEY.js.map} +0 -0
  1100. /package/dist/{chunk-PSMAWRPL.js.map → chunk-U7XM7CB4.js.map} +0 -0
  1101. /package/dist/{chunk-4TQL3WP2.js.map → chunk-UJK53QFL.js.map} +0 -0
  1102. /package/dist/{chunk-RBRX5ZS3.js.map → chunk-UMTXA2TH.js.map} +0 -0
  1103. /package/dist/{chunk-36MIDGAH.js.map → chunk-UPDSXFK5.js.map} +0 -0
  1104. /package/dist/{chunk-OYXBFSGK.js.map → chunk-UTIAXH52.js.map} +0 -0
  1105. /package/dist/{chunk-5WUN7XPD.js.map → chunk-UVN5TMHU.js.map} +0 -0
  1106. /package/dist/{chunk-UYE47LO6.js.map → chunk-VGYXW3VG.js.map} +0 -0
  1107. /package/dist/{chunk-IKUNOX7F.js.map → chunk-VS7AHPCZ.js.map} +0 -0
  1108. /package/dist/{chunk-MYUFMVCH.js.map → chunk-VTTAJOQ7.js.map} +0 -0
  1109. /package/dist/{chunk-K63HGHZX.js.map → chunk-VWPOLUAO.js.map} +0 -0
  1110. /package/dist/{chunk-GA4YEAMX.js.map → chunk-X3MWB2QU.js.map} +0 -0
  1111. /package/dist/{chunk-I36GSRUJ.js.map → chunk-X6KAJI3V.js.map} +0 -0
  1112. /package/dist/{chunk-IKMUFDVS.js.map → chunk-XBLRHV5R.js.map} +0 -0
  1113. /package/dist/{chunk-XOSQP3YA.js.map → chunk-XDFP2LMW.js.map} +0 -0
  1114. /package/dist/{chunk-MW7Y3T55.js.map → chunk-XEQMZB3C.js.map} +0 -0
  1115. /package/dist/{chunk-B3LMRTRF.js.map → chunk-XEYLT5VA.js.map} +0 -0
  1116. /package/dist/{chunk-UI4HI5QK.js.map → chunk-XHIQ5I6N.js.map} +0 -0
  1117. /package/dist/{chunk-U6M4LS3M.js.map → chunk-XLH7QY2R.js.map} +0 -0
  1118. /package/dist/{chunk-OSA5EQG5.js.map → chunk-XWFAMUZQ.js.map} +0 -0
  1119. /package/dist/{chunk-6MT3HHUB.js.map → chunk-Y4OBB2VN.js.map} +0 -0
  1120. /package/dist/{chunk-CZP5QXNB.js.map → chunk-YCVD6CI3.js.map} +0 -0
  1121. /package/dist/{chunk-APW4T4SW.js.map → chunk-YENLNISG.js.map} +0 -0
  1122. /package/dist/{chunk-JWPA6ZPZ.js.map → chunk-YIRVLKAX.js.map} +0 -0
  1123. /package/dist/{chunk-LQ62ECE6.js.map → chunk-YL73CVNK.js.map} +0 -0
  1124. /package/dist/{chunk-ILKDYBON.js.map → chunk-YLS6QE5G.js.map} +0 -0
  1125. /package/dist/{chunk-YBKVGLQR.js.map → chunk-YPWU5KPE.js.map} +0 -0
  1126. /package/dist/{chunk-IKJLSBUI.js.map → chunk-YQXTDZSU.js.map} +0 -0
  1127. /package/dist/{chunk-TPMZBOFH.js.map → chunk-YSJEAAOL.js.map} +0 -0
  1128. /package/dist/{chunk-W3BFRR2G.js.map → chunk-YWIFM7D7.js.map} +0 -0
  1129. /package/dist/{chunk-WTJ4PLMU.js.map → chunk-YWVI6ZMK.js.map} +0 -0
  1130. /package/dist/{chunk-5KWMYPJV.js.map → chunk-Z4FMAFNH.js.map} +0 -0
  1131. /package/dist/{chunk-W5OWKVZG.js.map → chunk-Z654FWNU.js.map} +0 -0
  1132. /package/dist/{chunk-5FH5LQVS.js.map → chunk-Z7Y523PS.js.map} +0 -0
  1133. /package/dist/{chunk-HLL4PBO7.js.map → chunk-ZD67RM6G.js.map} +0 -0
  1134. /package/dist/{chunk-IVYJX3OY.js.map → chunk-ZEG4VPBL.js.map} +0 -0
  1135. /package/dist/{chunk-K6R5T44I.js.map → chunk-ZLYCOBHW.js.map} +0 -0
  1136. /package/dist/{chunk-VADHIT26.js.map → chunk-ZNJ5MTXV.js.map} +0 -0
  1137. /package/dist/{chunk-2KYQC4T5.js.map → chunk-ZSGY3H53.js.map} +0 -0
  1138. /package/dist/{chunk-BKP43KK4.js.map → chunk-ZTPXACWB.js.map} +0 -0
  1139. /package/dist/{chunk-JCY4CMDH.js.map → chunk-ZUA3JMI6.js.map} +0 -0
  1140. /package/dist/{chunk-IGVVXLKJ.js.map → chunk-ZYAZUPPV.js.map} +0 -0
  1141. /package/dist/{computer-viewer-LPZ763KF.js.map → computer-viewer-TDDO25AV.js.map} +0 -0
  1142. /package/dist/{embedded-new-voice-YVMKSLKJ.js.map → embedded-new-voice-2G3VLPVQ.js.map} +0 -0
  1143. /package/dist/{embedded-voice-BJPQFXSU.js.map → embedded-voice-T5IWOWGD.js.map} +0 -0
  1144. /package/dist/{fleet-decision-row-AA4H5CDT.js.map → fleet-decision-row-WM64KXP3.js.map} +0 -0
  1145. /package/dist/{model-policy-picker-menu-HSMWVO4P.js.map → model-policy-picker-menu-SMC6J6QN.js.map} +0 -0
  1146. /package/dist/{payment-page-card-3LTSFJGN.js.map → payment-page-card-G4U63KUV.js.map} +0 -0
  1147. /package/dist/{platform-activity-row-5VYV6TX4.js.map → platform-activity-row-BUZGZAKZ.js.map} +0 -0
  1148. /package/dist/{queue-surface-implementation-NXHZUKD2.js.map → queue-surface-implementation-4KUZ4PJV.js.map} +0 -0
  1149. /package/dist/{sandbox-files-YCMLQUFU.js.map → sandbox-files-ESDMOFSD.js.map} +0 -0
  1150. /package/dist/{session-connect-cards-KSQLMRM5.js.map → session-connect-cards-Q53KMMYY.js.map} +0 -0
  1151. /package/dist/{session-realtime-ZR6JLG3Y.js.map → session-realtime-CF3I35WJ.js.map} +0 -0
  1152. /package/dist/{timeline-annotation-markers-YAHDPWVG.js.map → timeline-annotation-markers-CJK4RYZ4.js.map} +0 -0
  1153. /package/dist/{timeline-annotation-selection-KHXNCEJP.js.map → timeline-annotation-selection-67GF5H26.js.map} +0 -0
  1154. /package/dist/{timeline-annotations-dialog-Y4XD3N7B.js.map → timeline-annotations-dialog-ONJPQDJQ.js.map} +0 -0
@@ -0,0 +1,2656 @@
1
+ "use client";
2
+ import {
3
+ useSessionEventTrigger
4
+ } from "./chunk-RV3O5OCQ.js";
5
+ import {
6
+ normalizeError,
7
+ useErrorMessage
8
+ } from "./chunk-CM7LVUKC.js";
9
+ import {
10
+ COMPOSER_ACCOUNT_UNAVAILABLE_MESSAGE,
11
+ COMPOSER_MODEL_UNAVAILABLE_MESSAGE,
12
+ ComposerReconciliationRequiredError,
13
+ ComposerStateError,
14
+ ComposerWorkspaceControlUnavailableError,
15
+ composerSubmissionCanRetry,
16
+ composerSubmissionErrorMessage
17
+ } from "./chunk-5MOJZORA.js";
18
+ import {
19
+ TRANSIENT_RECONNECT_INTERVAL_MS,
20
+ isActionFailure,
21
+ isCalmServiceFailure,
22
+ isTransientServiceFailure,
23
+ markActionFailure
24
+ } from "./chunk-5AIMVW6Y.js";
25
+ import {
26
+ useEmbeddedSession
27
+ } from "./chunk-TVQCDDSZ.js";
28
+ import {
29
+ useOpenGeniText
30
+ } from "./chunk-7T2ZE3VT.js";
31
+
32
+ // src/hooks/use-composer.ts
33
+ import {
34
+ DEFAULT_FILE_RESOURCE_MOUNT_ROOT,
35
+ OpenGeniApiError,
36
+ isMaintenanceError
37
+ } from "@opengeni/sdk";
38
+ import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
39
+
40
+ // src/lib/notify-observer.ts
41
+ function notifyObserver(observer, ...args) {
42
+ const report = (cause) => globalThis.reportError?.(cause);
43
+ try {
44
+ const result = observer?.(...args);
45
+ if (result && typeof result.then === "function") {
46
+ void Promise.resolve(result).catch(report);
47
+ }
48
+ } catch (cause) {
49
+ report(cause);
50
+ }
51
+ }
52
+
53
+ // src/hooks/use-composer.ts
54
+ function initialComposerShadow(seed) {
55
+ if (!seed || !seed.text && !seed.resources?.length && !seed.annotations?.length && !seed.policy)
56
+ return void 0;
57
+ return {
58
+ text: seed.text,
59
+ resources: [...seed.resources ?? []],
60
+ annotations: cloneAnnotations(seed.annotations ?? []),
61
+ ...seed.policy ? { policy: { ...seed.policy } } : {}
62
+ };
63
+ }
64
+ var PENDING_COMPOSER_STORAGE_PREFIX = "opengeni.pending-composer.v1:";
65
+ var OPTIMISTIC_SEND_STORAGE_PREFIX = "opengeni.optimistic-sends.v1:";
66
+ var pendingComposerOperations = /* @__PURE__ */ new Map();
67
+ var optimisticSendOperations = /* @__PURE__ */ new Map();
68
+ function pendingComposerOperationKey(workspaceId, sessionId) {
69
+ return sessionId ? `${workspaceId}\0${sessionId}` : null;
70
+ }
71
+ function pendingComposerStorage() {
72
+ try {
73
+ return typeof window === "undefined" ? null : window.sessionStorage;
74
+ } catch {
75
+ return null;
76
+ }
77
+ }
78
+ function pendingComposerStorageKey(key) {
79
+ return `${PENDING_COMPOSER_STORAGE_PREFIX}${encodeURIComponent(key)}`;
80
+ }
81
+ function optimisticSendStorageKey(key) {
82
+ return `${OPTIMISTIC_SEND_STORAGE_PREFIX}${encodeURIComponent(key)}`;
83
+ }
84
+ function restoreOptimisticSendOperations(t, key, canBuyCredits = true) {
85
+ if (!key) return [];
86
+ let stored = optimisticSendOperations.get(key);
87
+ if (!stored) {
88
+ const storage = pendingComposerStorage();
89
+ try {
90
+ const parsed = JSON.parse(storage?.getItem(optimisticSendStorageKey(key)) ?? "[]");
91
+ stored = Array.isArray(parsed) ? parsed.filter(
92
+ (candidate) => typeof candidate === "object" && candidate !== null && typeof candidate.clientEventId === "string" && typeof candidate.text === "string" && typeof candidate.occurredAt === "string" && (candidate.state === "sending" || candidate.state === "failed") && typeof candidate.input === "object" && candidate.input !== null && typeof candidate.input.text === "string" && typeof candidate.hasMcpCredentialUpdates === "boolean"
93
+ ) : [];
94
+ } catch {
95
+ stored = [];
96
+ }
97
+ }
98
+ return stored.map(({ hasMcpCredentialUpdates, ...operation }) => ({
99
+ ...operation,
100
+ delivery: "send",
101
+ destination: operation.destination === "queue" ? "queue" : "chat",
102
+ newerShadow: operation.newerShadow ?? { text: "", resources: [], annotations: [] },
103
+ state: operation.state === "sending" || operation.state === "queued" ? "sending" : operation.state,
104
+ outcomeUnknown: operation.state === "sending" || operation.state === "queued" ? true : operation.outcomeUnknown,
105
+ correlationId: restoredCorrelationId(operation.correlationId),
106
+ error: restoredErrorReference(
107
+ t,
108
+ operation.correlationId,
109
+ hasMcpCredentialUpdates && (operation.state === "sending" || operation.outcomeUnknown) ? composerSubmissionErrorMessage(t, new ComposerReconciliationRequiredError()) : operation.state === "sending" ? t("hooks.useComposer.deliveryWasInterruptedRetryTo") : operation.outcomeUnknown ? t("hooks.useComposer.theRequestCouldNotBe") : operation.error ? composerSubmissionErrorMessage(t, new Error(operation.error), canBuyCredits) : void 0
110
+ ),
111
+ retryable: operation.state === "sending" || operation.outcomeUnknown ? true : operation.retryable ?? (operation.error ? composerSubmissionCanRetry(new Error(operation.error)) : true),
112
+ input: operation.input,
113
+ canRetry: !hasMcpCredentialUpdates
114
+ }));
115
+ }
116
+ function restoredCorrelationId(value) {
117
+ return typeof value === "string" && /^[\w.:-]{1,128}$/u.test(value) ? value : void 0;
118
+ }
119
+ function restoredErrorReference(t, reference, message) {
120
+ const correlationId = restoredCorrelationId(reference);
121
+ return message && correlationId && message !== COMPOSER_MODEL_UNAVAILABLE_MESSAGE && message !== t("lib.format.modelUnavailable") && message !== COMPOSER_ACCOUNT_UNAVAILABLE_MESSAGE && message !== t("lib.format.accountUnavailable") ? t("hooks.useComposer.messageReferenceCorrelationid", { message, correlationId }) : message;
122
+ }
123
+ function rememberOptimisticSendOperations(key, operations) {
124
+ if (!key) return;
125
+ const stored = operations.filter((operation) => operation.state !== "queued").map((operation) => {
126
+ const { canRetry: _canRetry, input, ...rest } = operation;
127
+ const { mcpCredentialUpdates: _credentials, ...safeInput } = input;
128
+ return {
129
+ ...rest,
130
+ input: safeInput,
131
+ hasMcpCredentialUpdates: input.mcpCredentialUpdates !== void 0
132
+ };
133
+ });
134
+ if (stored.length === 0) {
135
+ optimisticSendOperations.delete(key);
136
+ try {
137
+ pendingComposerStorage()?.removeItem(optimisticSendStorageKey(key));
138
+ } catch {
139
+ }
140
+ return;
141
+ }
142
+ optimisticSendOperations.set(key, stored);
143
+ try {
144
+ pendingComposerStorage()?.setItem(optimisticSendStorageKey(key), JSON.stringify(stored));
145
+ } catch {
146
+ }
147
+ }
148
+ function resourceList(value) {
149
+ return Array.isArray(value) && value.every((candidate) => {
150
+ if (typeof candidate !== "object" || candidate === null) return false;
151
+ const resource = candidate;
152
+ return resource.kind === "file" ? typeof resource.fileId === "string" : resource.kind === "repository" && typeof resource.uri === "string" && typeof resource.ref === "string";
153
+ });
154
+ }
155
+ function timelineAnnotationList(value) {
156
+ return Array.isArray(value) && value.every((candidate) => {
157
+ if (typeof candidate !== "object" || candidate === null) return false;
158
+ const annotation = candidate;
159
+ const source = annotation.source;
160
+ if (typeof source !== "object" || source === null) return false;
161
+ const sourceRecord = source;
162
+ return typeof annotation.id === "string" && typeof annotation.quote === "string" && typeof annotation.note === "string" && typeof sourceRecord.eventId === "string" && typeof sourceRecord.eventType === "string" && typeof sourceRecord.sequence === "number" && (typeof sourceRecord.turnId === "string" || sourceRecord.turnId === null) && typeof sourceRecord.startOffset === "number" && typeof sourceRecord.endOffset === "number" && typeof sourceRecord.contextBefore === "string" && typeof sourceRecord.contextAfter === "string";
163
+ });
164
+ }
165
+ function cloneAnnotations(annotations) {
166
+ return annotations.map((annotation) => ({
167
+ ...annotation,
168
+ source: { ...annotation.source }
169
+ }));
170
+ }
171
+ function readStoredPendingComposerOperation(key) {
172
+ const storage = key ? pendingComposerStorage() : null;
173
+ if (!storage || !key) return null;
174
+ try {
175
+ const parsed = JSON.parse(storage.getItem(pendingComposerStorageKey(key)) ?? "null");
176
+ if (typeof parsed !== "object" || parsed === null) return null;
177
+ const record = parsed;
178
+ const input = record.input;
179
+ const shadow = record.newerShadow;
180
+ if (typeof input !== "object" || input === null || typeof shadow !== "object" || shadow === null) {
181
+ return null;
182
+ }
183
+ const inputRecord = input;
184
+ const shadowRecord = shadow;
185
+ if (record.delivery !== "send" && record.delivery !== "steer" || typeof record.draftAtSend !== "string" || !resourceList(record.resourcesAtSend) || record.annotationsAtSend !== void 0 && !timelineAnnotationList(record.annotationsAtSend) || typeof shadowRecord.text !== "string" || !resourceList(shadowRecord.resources) || shadowRecord.annotations !== void 0 && !timelineAnnotationList(shadowRecord.annotations) || typeof record.clearDraftOnAccept !== "boolean" || typeof record.hasMcpCredentialUpdates !== "boolean" || typeof inputRecord.text !== "string" || typeof inputRecord.clientEventId !== "string" || "mcpCredentialUpdates" in inputRecord || "resources" in inputRecord && !resourceList(inputRecord.resources) || "annotations" in inputRecord && !timelineAnnotationList(inputRecord.annotations)) {
186
+ return null;
187
+ }
188
+ return {
189
+ ...record,
190
+ annotationsAtSend: timelineAnnotationList(record.annotationsAtSend) ? record.annotationsAtSend : [],
191
+ newerShadow: {
192
+ ...shadow,
193
+ annotations: timelineAnnotationList(shadowRecord.annotations) ? shadowRecord.annotations : []
194
+ }
195
+ };
196
+ } catch {
197
+ return null;
198
+ }
199
+ }
200
+ function writePendingComposerOperation(key, operation) {
201
+ const storage = pendingComposerStorage();
202
+ if (!storage) return;
203
+ try {
204
+ storage.setItem(pendingComposerStorageKey(key), JSON.stringify(operation));
205
+ } catch {
206
+ }
207
+ }
208
+ function restorePendingComposerOperation(key) {
209
+ const stored = (key && pendingComposerOperations.get(key)) ?? readStoredPendingComposerOperation(key);
210
+ if (!stored) return null;
211
+ return {
212
+ ...stored,
213
+ input: stored.input,
214
+ newerShadow: stored.newerShadow ?? {
215
+ text: stored.draftAtSend,
216
+ resources: stored.resourcesAtSend,
217
+ annotations: stored.annotationsAtSend
218
+ },
219
+ canRetry: !stored.hasMcpCredentialUpdates
220
+ };
221
+ }
222
+ function rememberPendingComposerOperation(key, operation) {
223
+ if (!key) return;
224
+ const { canRetry: _retry, ...safeOperation } = operation;
225
+ const { input: originalInput, ...withoutInput } = safeOperation;
226
+ const { mcpCredentialUpdates: _storedMcp, ...safeInput } = originalInput;
227
+ const stored = {
228
+ ...withoutInput,
229
+ input: safeInput,
230
+ hasMcpCredentialUpdates: operation.input.mcpCredentialUpdates !== void 0,
231
+ newerShadow: {
232
+ text: operation.newerShadow.text,
233
+ resources: [...operation.newerShadow.resources],
234
+ annotations: cloneAnnotations(operation.newerShadow.annotations),
235
+ ...operation.newerShadow.policy ? { policy: { ...operation.newerShadow.policy } } : {}
236
+ }
237
+ };
238
+ pendingComposerOperations.set(key, stored);
239
+ writePendingComposerOperation(key, stored);
240
+ }
241
+ function forgetPendingComposerOperation(key) {
242
+ if (!key) return;
243
+ pendingComposerOperations.delete(key);
244
+ const storage = pendingComposerStorage();
245
+ if (!storage) return;
246
+ try {
247
+ storage.removeItem(pendingComposerStorageKey(key));
248
+ } catch {
249
+ }
250
+ }
251
+ function updatePendingComposerShadow(key, operation, shadow) {
252
+ if (!key || !operation) return operation;
253
+ const next = {
254
+ ...operation,
255
+ newerShadow: {
256
+ ...shadow,
257
+ resources: [...shadow.resources],
258
+ annotations: cloneAnnotations(shadow.annotations)
259
+ }
260
+ };
261
+ rememberPendingComposerOperation(key, next);
262
+ return next;
263
+ }
264
+ var SERVICE_SEND_RETRY_MAX_DELAY_MS = 8e3;
265
+ var STEERING_SETTLEMENT_EVENT_TYPES = /* @__PURE__ */ new Set([
266
+ "turn.started",
267
+ "turn.completed",
268
+ "turn.failed",
269
+ "turn.cancelled",
270
+ "turn.superseded"
271
+ ]);
272
+ function isSteeringSettlementEvent(event) {
273
+ return STEERING_SETTLEMENT_EVENT_TYPES.has(event.type);
274
+ }
275
+ function steeringAcceptedEvent(steering, events) {
276
+ return events.find(
277
+ (event) => event.type === "user.message" && steering.clientEventId !== null && event.clientEventId === steering.clientEventId
278
+ );
279
+ }
280
+ function promptTurnIdForTrigger(triggerEventId, events) {
281
+ if (!triggerEventId) return null;
282
+ const queued = events.find((event) => {
283
+ if (event.type !== "turn.queued") return false;
284
+ const payload2 = event.payload;
285
+ return typeof payload2 === "object" && payload2 !== null && "triggerEventId" in payload2 && payload2.triggerEventId === triggerEventId;
286
+ });
287
+ if (!queued) return null;
288
+ if (queued.turnId) return queued.turnId;
289
+ const payload = queued.payload;
290
+ return typeof payload === "object" && payload !== null && "turnId" in payload && typeof payload.turnId === "string" ? payload.turnId : null;
291
+ }
292
+ function steeringSettledByEvents(steering, events) {
293
+ const acceptedEventId = steering.triggerEventId ?? steeringAcceptedEvent(steering, events)?.id ?? null;
294
+ return events.some((event) => {
295
+ if (steering.turnId && event.turnId === steering.turnId && isSteeringSettlementEvent(event)) {
296
+ return true;
297
+ }
298
+ if (event.type !== "turn.started" || !acceptedEventId) return false;
299
+ const payload = event.payload;
300
+ return typeof payload === "object" && payload !== null && "triggerEventId" in payload && payload.triggerEventId === acceptedEventId;
301
+ });
302
+ }
303
+ function reconcileOptimisticSendFromEvents(operation, events) {
304
+ const accepted = events.find(
305
+ (event) => event.type === "user.message" && event.clientEventId === operation.clientEventId
306
+ );
307
+ const triggerEventId = operation.triggerEventId ?? accepted?.id ?? null;
308
+ const turnId = operation.turnId ?? promptTurnIdForTrigger(triggerEventId, events);
309
+ const acceptedRouting = promptRoutingFromAcceptedEvent(accepted ?? null);
310
+ const destination = acceptedRouting === "queued_for_execution" ? "queue" : acceptedRouting === "accepted_for_execution" || acceptedRouting === "accepted_for_steering" ? "chat" : operation.destination;
311
+ const needsAdmissionUpdate = accepted !== void 0 && (operation.state !== "queued" || operation.destination !== destination || operation.triggerEventId !== triggerEventId || operation.turnId !== turnId || operation.error !== void 0 || operation.outcomeUnknown !== false);
312
+ const reconciled = needsAdmissionUpdate ? {
313
+ ...operation,
314
+ state: "queued",
315
+ destination,
316
+ triggerEventId,
317
+ turnId,
318
+ error: void 0,
319
+ outcomeUnknown: false
320
+ } : operation;
321
+ const withdrawnFromQueue = events.some((event) => {
322
+ if (event.type !== "session.queue.changed" || !turnId) return false;
323
+ const payload = event.payload;
324
+ if (typeof payload !== "object" || payload === null || Array.isArray(payload)) return false;
325
+ const record = payload;
326
+ return record.turnId === turnId && (record.operation === "edit" || record.operation === "delete");
327
+ });
328
+ return {
329
+ operation: reconciled,
330
+ admitted: accepted !== void 0,
331
+ // Edit/Delete atomically withdraw the queued turn. Keeping its optimistic
332
+ // send alive after that point lets its old `newerShadow` become the newest
333
+ // composer draft again when a later turn settles, duplicating submitted
334
+ // text. The queue mutation is the durable terminal fact for this send.
335
+ settled: withdrawnFromQueue || steeringSettledByEvents(
336
+ {
337
+ phase: "accepted",
338
+ text: reconciled.text,
339
+ clientEventId: reconciled.clientEventId,
340
+ triggerEventId: reconciled.triggerEventId ?? null,
341
+ turnId: reconciled.turnId ?? null
342
+ },
343
+ events
344
+ )
345
+ };
346
+ }
347
+ function useComposer(sessionId, options = {}) {
348
+ const t = useOpenGeniText();
349
+ const { client, workspaceId, registerSessionReconciler } = useEmbeddedSession(options);
350
+ const formatError = useErrorMessage();
351
+ const durableDrafts = options.draftPersistence !== "disabled";
352
+ if (!durableDrafts && !options.initialPolicy) {
353
+ throw new Error("useComposer requires initialPolicy when draft persistence is disabled");
354
+ }
355
+ const targetKey = `${workspaceId}\0${sessionId ?? ""}\0${durableDrafts ? "durable" : "disabled"}`;
356
+ const pendingOperationKey = pendingComposerOperationKey(workspaceId, sessionId);
357
+ const initialPendingOperation = restorePendingComposerOperation(pendingOperationKey);
358
+ const initialOptimisticSends = restoreOptimisticSendOperations(
359
+ t,
360
+ pendingOperationKey,
361
+ options.canBuyCredits ?? true
362
+ );
363
+ const initialShadow = initialPendingOperation?.newerShadow ?? initialOptimisticSends.at(-1)?.newerShadow ?? initialComposerShadow(options.initialDraft);
364
+ const [value, setValue] = useState(() => initialShadow?.text ?? "");
365
+ const [annotations, setAnnotations] = useState(
366
+ () => initialShadow?.annotations ?? []
367
+ );
368
+ const [annotationReviewTargetId, setAnnotationReviewTargetId] = useState(null);
369
+ const [stateTargetKey, setStateTargetKey] = useState(targetKey);
370
+ const [sending, setSending] = useState(false);
371
+ const [optimisticSends, setOptimisticSends] = useState(initialOptimisticSends);
372
+ const [steering, setSteering] = useState(
373
+ () => initialPendingOperation?.delivery === "steer" ? {
374
+ phase: "failed",
375
+ text: initialPendingOperation.input.text,
376
+ clientEventId: initialPendingOperation.input.clientEventId ?? null,
377
+ triggerEventId: null,
378
+ turnId: null,
379
+ error: t("hooks.useComposer.notConfirmedRetryToCheck"),
380
+ outcomeUnknown: true
381
+ } : null
382
+ );
383
+ const [pausing, setPausing] = useState(false);
384
+ const [acceptedControl, setAcceptedControl] = useState(null);
385
+ const [resuming, setResuming] = useState(false);
386
+ const [error, setError] = useState(null);
387
+ const [draftReadError, setDraftReadError] = useState(null);
388
+ const [draftHydrationRetrying, setDraftHydrationRetrying] = useState(false);
389
+ const [draft, setDraft] = useState(null);
390
+ const [draftLoading, setDraftLoading] = useState(Boolean(sessionId) && durableDrafts);
391
+ const [draftSaving, setDraftSaving] = useState(false);
392
+ const [draftConflict, setDraftConflict] = useState(null);
393
+ const [policy, setPolicy] = useState(
394
+ () => initialShadow?.policy ?? options.initialPolicy ?? null
395
+ );
396
+ const [restoredResources, setRestoredResources] = useState(
397
+ () => initialShadow?.resources ?? []
398
+ );
399
+ const pendingOperationRef = useRef(initialPendingOperation);
400
+ const optimisticSendsRef = useRef(initialOptimisticSends);
401
+ const optimisticProcessorBusyRef = useRef(false);
402
+ const serviceWaitRef = useRef(
403
+ /* @__PURE__ */ new Map()
404
+ );
405
+ const serviceRetryTimerRef = useRef(null);
406
+ const processOptimisticSendsRef = useRef(() => void 0);
407
+ const [serviceWaiting, setServiceWaiting] = useState(false);
408
+ const [autosaveRetry, setAutosaveRetry] = useState(0);
409
+ const optimisticCallbackIdsRef = useRef(/* @__PURE__ */ new Set());
410
+ const steeringSettlementEventsRef = useRef([]);
411
+ const steeringRef = useRef(steering);
412
+ const steeringOccurredAtRef = useRef((/* @__PURE__ */ new Date()).toISOString());
413
+ const pendingClientEventId = useRef(
414
+ initialPendingOperation?.input.clientEventId ?? null
415
+ );
416
+ const valueRef = useRef(initialShadow?.text ?? "");
417
+ const annotationsRef = useRef(initialShadow?.annotations ?? []);
418
+ const policyRef = useRef(
419
+ initialShadow?.policy ?? options.initialPolicy ?? null
420
+ );
421
+ const policyPickedRef = useRef(!durableDrafts || initialShadow?.policy !== void 0);
422
+ const [policyPicked, setPolicyPicked] = useState(policyPickedRef.current);
423
+ const draftRef = useRef(null);
424
+ const restoredResourcesRef = useRef(initialShadow?.resources ?? []);
425
+ const localEditRevision = useRef(initialShadow ? 1 : 0);
426
+ const targetGeneration = useRef(0);
427
+ const draftReadGeneration = useRef(0);
428
+ const draftReadInFlightRef = useRef(null);
429
+ const draftReadAbortRef = useRef(null);
430
+ const draftReadRetryRef = useRef({ targetKey, failures: 0, timer: null });
431
+ const lastSavedSignature = useRef(null);
432
+ const saveChain = useRef(Promise.resolve());
433
+ const onSent = useCallback(
434
+ (text, input) => {
435
+ notifyObserver(options.onSent, text, input);
436
+ },
437
+ [options.onSent]
438
+ );
439
+ const onSubmitted = useCallback(
440
+ (text, input) => {
441
+ notifyObserver(options.onSubmitted, text, input);
442
+ },
443
+ [options.onSubmitted]
444
+ );
445
+ const onDeliveryErrorRef = useRef(options.onDeliveryError);
446
+ onDeliveryErrorRef.current = options.onDeliveryError;
447
+ useLayoutEffect(() => {
448
+ steeringRef.current = steering;
449
+ }, [steering]);
450
+ const sendExtrasRef = useRef(options.sendExtras);
451
+ sendExtrasRef.current = options.sendExtras;
452
+ const sendDestinationRef = useRef(options.sendDestination);
453
+ sendDestinationRef.current = options.sendDestination;
454
+ const busySend = options.busySend ?? "queue";
455
+ const busySendRef = useRef(busySend);
456
+ busySendRef.current = busySend;
457
+ const singleSend = busySend === "steer" && options.offerQueue !== true;
458
+ const sendBlockedRef = useRef(options.sendBlocked);
459
+ sendBlockedRef.current = options.sendBlocked;
460
+ const canBuyCreditsRef = useRef(options.canBuyCredits ?? true);
461
+ canBuyCreditsRef.current = options.canBuyCredits ?? true;
462
+ const effectiveControlRef = useRef(
463
+ acceptedControl ?? options.effectiveControl ?? null
464
+ );
465
+ effectiveControlRef.current = acceptedControl ?? options.effectiveControl ?? null;
466
+ const liveExtrasVersion = JSON.stringify(resolveSendExtras(options.sendExtras));
467
+ const targetKeyRef = useRef(targetKey);
468
+ useLayoutEffect(() => {
469
+ if (targetKeyRef.current === targetKey) return;
470
+ if (draftReadRetryRef.current.timer !== null) {
471
+ clearTimeout(draftReadRetryRef.current.timer);
472
+ }
473
+ draftReadAbortRef.current?.abort();
474
+ draftReadAbortRef.current = null;
475
+ draftReadRetryRef.current = { targetKey, failures: 0, timer: null };
476
+ targetKeyRef.current = targetKey;
477
+ targetGeneration.current += 1;
478
+ draftReadGeneration.current += 1;
479
+ pendingOperationRef.current = restorePendingComposerOperation(pendingOperationKey);
480
+ const restoredOptimisticSends = restoreOptimisticSendOperations(
481
+ t,
482
+ pendingOperationKey,
483
+ canBuyCreditsRef.current
484
+ );
485
+ optimisticSendsRef.current = restoredOptimisticSends;
486
+ optimisticProcessorBusyRef.current = false;
487
+ serviceWaitRef.current = /* @__PURE__ */ new Map();
488
+ if (serviceRetryTimerRef.current !== null) clearTimeout(serviceRetryTimerRef.current);
489
+ serviceRetryTimerRef.current = null;
490
+ setServiceWaiting(false);
491
+ optimisticCallbackIdsRef.current = /* @__PURE__ */ new Set();
492
+ steeringSettlementEventsRef.current = [];
493
+ pendingClientEventId.current = pendingOperationRef.current?.input.clientEventId ?? null;
494
+ const shadow = pendingOperationRef.current?.newerShadow ?? restoredOptimisticSends.at(-1)?.newerShadow ?? initialComposerShadow(options.initialDraft);
495
+ localEditRevision.current = shadow ? 1 : 0;
496
+ valueRef.current = shadow?.text ?? "";
497
+ annotationsRef.current = shadow?.annotations ?? [];
498
+ policyRef.current = shadow?.policy ?? options.initialPolicy ?? null;
499
+ policyPickedRef.current = !durableDrafts || shadow?.policy !== void 0;
500
+ setPolicyPicked(policyPickedRef.current);
501
+ draftRef.current = null;
502
+ restoredResourcesRef.current = shadow?.resources ?? [];
503
+ lastSavedSignature.current = null;
504
+ saveChain.current = Promise.resolve();
505
+ setStateTargetKey(targetKey);
506
+ setValue(shadow?.text ?? "");
507
+ setAnnotations(shadow?.annotations ?? []);
508
+ setPolicy(policyRef.current);
509
+ setAnnotationReviewTargetId(null);
510
+ setSending(false);
511
+ setOptimisticSends(restoredOptimisticSends);
512
+ setSteering(
513
+ pendingOperationRef.current?.delivery === "steer" ? {
514
+ phase: "failed",
515
+ text: pendingOperationRef.current.input.text,
516
+ clientEventId: pendingOperationRef.current.input.clientEventId ?? null,
517
+ triggerEventId: null,
518
+ turnId: null,
519
+ error: t("hooks.useComposer.notConfirmedRetryToCheck"),
520
+ outcomeUnknown: true
521
+ } : null
522
+ );
523
+ setPausing(false);
524
+ setAcceptedControl(null);
525
+ setResuming(false);
526
+ setError(null);
527
+ setDraftReadError(null);
528
+ setDraftHydrationRetrying(false);
529
+ setDraft(null);
530
+ setDraftLoading(Boolean(sessionId) && durableDrafts);
531
+ setDraftSaving(false);
532
+ setDraftConflict(null);
533
+ setRestoredResources(shadow?.resources ?? []);
534
+ }, [
535
+ durableDrafts,
536
+ options.initialPolicy,
537
+ options.initialDraft,
538
+ pendingOperationKey,
539
+ sessionId,
540
+ targetKey,
541
+ t
542
+ ]);
543
+ useEffect(
544
+ () => () => {
545
+ if (draftReadRetryRef.current.timer !== null) {
546
+ clearTimeout(draftReadRetryRef.current.timer);
547
+ }
548
+ if (serviceRetryTimerRef.current !== null) clearTimeout(serviceRetryTimerRef.current);
549
+ serviceRetryTimerRef.current = null;
550
+ targetGeneration.current += 1;
551
+ draftReadGeneration.current += 1;
552
+ draftReadInFlightRef.current = null;
553
+ draftReadAbortRef.current?.abort();
554
+ draftReadAbortRef.current = null;
555
+ },
556
+ []
557
+ );
558
+ const setOptimisticDraftShadow = useCallback(
559
+ (shadow) => {
560
+ if (optimisticSendsRef.current.length === 0) return;
561
+ const next = optimisticSendsRef.current.map((operation) => ({
562
+ ...operation,
563
+ newerShadow: {
564
+ text: shadow.text,
565
+ resources: [...shadow.resources],
566
+ annotations: cloneAnnotations(shadow.annotations),
567
+ ...shadow.policy ? { policy: { ...shadow.policy } } : {}
568
+ }
569
+ }));
570
+ optimisticSendsRef.current = next;
571
+ rememberOptimisticSendOperations(pendingOperationKey, next);
572
+ setOptimisticSends(next);
573
+ },
574
+ [pendingOperationKey]
575
+ );
576
+ const applyDraft = useCallback(
577
+ (next) => {
578
+ if (targetKeyRef.current !== targetKey) return;
579
+ if (!durableDrafts) {
580
+ const nextPolicy2 = policyFromDraft(next);
581
+ localEditRevision.current += 1;
582
+ valueRef.current = next.text;
583
+ annotationsRef.current = next.annotations ?? [];
584
+ policyRef.current = nextPolicy2;
585
+ restoredResourcesRef.current = next.resources;
586
+ draftRef.current = null;
587
+ lastSavedSignature.current = null;
588
+ setDraft(null);
589
+ setValue(next.text);
590
+ setAnnotations(next.annotations ?? []);
591
+ setPolicy(nextPolicy2);
592
+ setRestoredResources(next.resources);
593
+ pendingOperationRef.current = updatePendingComposerShadow(
594
+ pendingOperationKey,
595
+ pendingOperationRef.current,
596
+ {
597
+ text: next.text,
598
+ resources: mergeResources(
599
+ next.resources,
600
+ resolveSendExtras(sendExtrasRef.current).resources ?? []
601
+ ),
602
+ annotations: next.annotations ?? [],
603
+ policy: nextPolicy2
604
+ }
605
+ );
606
+ setOptimisticDraftShadow({
607
+ text: next.text,
608
+ resources: mergeResources(
609
+ next.resources,
610
+ resolveSendExtras(sendExtrasRef.current).resources ?? []
611
+ ),
612
+ annotations: next.annotations ?? [],
613
+ policy: nextPolicy2
614
+ });
615
+ setDraftConflict(null);
616
+ return;
617
+ }
618
+ const nextPolicy = policyFromDraft(next);
619
+ valueRef.current = next.text;
620
+ annotationsRef.current = next.annotations ?? [];
621
+ policyRef.current = nextPolicy;
622
+ policyPickedRef.current = !next.policyFollowsSession;
623
+ setPolicyPicked(policyPickedRef.current);
624
+ draftRef.current = next;
625
+ restoredResourcesRef.current = next.resources;
626
+ lastSavedSignature.current = draftSignature(draftPayload(next));
627
+ localEditRevision.current += 1;
628
+ setDraft(next);
629
+ setValue(next.text);
630
+ setAnnotations(next.annotations ?? []);
631
+ setPolicy(nextPolicy);
632
+ setRestoredResources(next.resources);
633
+ pendingOperationRef.current = updatePendingComposerShadow(
634
+ pendingOperationKey,
635
+ pendingOperationRef.current,
636
+ {
637
+ text: next.text,
638
+ resources: mergeResources(
639
+ next.resources,
640
+ resolveSendExtras(sendExtrasRef.current).resources ?? []
641
+ ),
642
+ annotations: next.annotations ?? [],
643
+ policy: pickedPolicy(policyPickedRef, policyRef)
644
+ }
645
+ );
646
+ setOptimisticDraftShadow({
647
+ text: next.text,
648
+ resources: mergeResources(
649
+ next.resources,
650
+ resolveSendExtras(sendExtrasRef.current).resources ?? []
651
+ ),
652
+ annotations: next.annotations ?? [],
653
+ policy: pickedPolicy(policyPickedRef, policyRef)
654
+ });
655
+ setDraftConflict(null);
656
+ },
657
+ [durableDrafts, pendingOperationKey, setOptimisticDraftShadow, targetKey]
658
+ );
659
+ const loadDraft = useCallback(
660
+ async (replaceLocal) => {
661
+ if (targetKeyRef.current !== targetKey) return;
662
+ if (!sessionId || !durableDrafts) {
663
+ setDraftLoading(false);
664
+ setDraftReadError(null);
665
+ setDraftHydrationRetrying(false);
666
+ return;
667
+ }
668
+ let retry = draftReadRetryRef.current;
669
+ if (retry.targetKey !== targetKey) {
670
+ if (retry.timer !== null) clearTimeout(retry.timer);
671
+ retry = { targetKey, failures: 0, timer: null };
672
+ draftReadRetryRef.current = retry;
673
+ }
674
+ const scheduleRetry = () => {
675
+ if (retry.timer !== null) return;
676
+ retry.timer = setTimeout(
677
+ () => {
678
+ if (draftReadRetryRef.current !== retry || targetKeyRef.current !== targetKey) return;
679
+ retry.timer = null;
680
+ void loadDraft(false);
681
+ },
682
+ Math.min(25e3, 1e3 * 2 ** (retry.failures - 1)) * (0.8 + Math.random() * 0.4)
683
+ );
684
+ };
685
+ if (!replaceLocal && retry.timer !== null) return;
686
+ if (draftReadInFlightRef.current === targetKey) return;
687
+ if (retry.timer !== null) {
688
+ clearTimeout(retry.timer);
689
+ retry.timer = null;
690
+ }
691
+ draftReadInFlightRef.current = targetKey;
692
+ const generation = targetGeneration.current;
693
+ const readTicket = ++draftReadGeneration.current;
694
+ const requestAbort = new AbortController();
695
+ draftReadAbortRef.current?.abort();
696
+ draftReadAbortRef.current = requestAbort;
697
+ const localAtStart = localEditRevision.current;
698
+ const baseAtStart = draftRef.current;
699
+ const policyAtStart = policyRef.current;
700
+ const localSignatureAtStart = baseAtStart ? policyAtStart ? draftSignature(
701
+ composerDraftPayload(
702
+ baseAtStart,
703
+ valueRef.current,
704
+ restoredResourcesRef.current,
705
+ annotationsRef.current,
706
+ pickedPolicy(policyPickedRef, policyRef),
707
+ resolveSendExtras(sendExtrasRef.current).resources ?? []
708
+ )
709
+ ) : null : null;
710
+ const localWasDirtyAtStart = localSignatureAtStart === null ? localAtStart !== 0 : localSignatureAtStart !== lastSavedSignature.current;
711
+ const showLoading = replaceLocal || draftRef.current === null;
712
+ if (showLoading) {
713
+ setDraftLoading(true);
714
+ }
715
+ try {
716
+ const fetched = await client.getComposerDraft(workspaceId, sessionId, {
717
+ signal: requestAbort.signal
718
+ });
719
+ if (generation !== targetGeneration.current || targetKeyRef.current !== targetKey || readTicket !== draftReadGeneration.current) {
720
+ return;
721
+ }
722
+ if (retry.timer !== null) clearTimeout(retry.timer);
723
+ retry.failures = 0;
724
+ retry.timer = null;
725
+ setDraftReadError(null);
726
+ setDraftHydrationRetrying(false);
727
+ const currentRevision = draftRef.current?.revision ?? -1;
728
+ const adoptFetchedPolicy = () => {
729
+ const fetchedPolicy = policyFromDraft(fetched);
730
+ policyPickedRef.current = !fetched.policyFollowsSession;
731
+ setPolicyPicked(policyPickedRef.current);
732
+ if (samePolicy(policyRef.current, fetchedPolicy)) return;
733
+ policyRef.current = fetchedPolicy;
734
+ setPolicy(fetchedPolicy);
735
+ };
736
+ if (replaceLocal || fetched.revision > currentRevision) {
737
+ draftRef.current = fetched;
738
+ setDraft(fetched);
739
+ setDraftConflict(null);
740
+ const shadow = pendingOperationRef.current?.newerShadow ?? optimisticSendsRef.current.at(-1)?.newerShadow;
741
+ if (shadow) {
742
+ valueRef.current = shadow.text;
743
+ restoredResourcesRef.current = shadow.resources;
744
+ annotationsRef.current = shadow.annotations;
745
+ if (shadow.policy) {
746
+ policyRef.current = shadow.policy;
747
+ policyPickedRef.current = true;
748
+ setPolicyPicked(policyPickedRef.current);
749
+ } else if (!policyPickedRef.current) {
750
+ adoptFetchedPolicy();
751
+ }
752
+ localEditRevision.current ||= 1;
753
+ setValue(shadow.text);
754
+ setRestoredResources(shadow.resources);
755
+ setAnnotations(shadow.annotations);
756
+ if (shadow.policy) setPolicy(shadow.policy);
757
+ } else if (replaceLocal || !localWasDirtyAtStart && localAtStart === localEditRevision.current) {
758
+ valueRef.current = fetched.text;
759
+ restoredResourcesRef.current = fetched.resources;
760
+ annotationsRef.current = fetched.annotations ?? [];
761
+ policyRef.current = policyFromDraft(fetched);
762
+ policyPickedRef.current = !fetched.policyFollowsSession;
763
+ setPolicyPicked(policyPickedRef.current);
764
+ lastSavedSignature.current = draftSignature(draftPayload(fetched));
765
+ setValue(fetched.text);
766
+ setRestoredResources(fetched.resources);
767
+ setAnnotations(fetched.annotations ?? []);
768
+ setPolicy(policyRef.current);
769
+ } else {
770
+ lastSavedSignature.current = draftSignature(draftPayload(fetched));
771
+ if (!policyRef.current || !policyPickedRef.current) adoptFetchedPolicy();
772
+ }
773
+ } else if (fetched.revision === currentRevision && fetched.policyFollowsSession && !policyPickedRef.current && !samePolicy(policyRef.current, policyFromDraft(fetched))) {
774
+ draftRef.current = fetched;
775
+ setDraft(fetched);
776
+ adoptFetchedPolicy();
777
+ }
778
+ } catch (cause) {
779
+ if (!requestAbort.signal.aborted && generation === targetGeneration.current && targetKeyRef.current === targetKey && readTicket === draftReadGeneration.current) {
780
+ const problem = asError(cause);
781
+ const timedOut = problem.name === "TimeoutError";
782
+ setDraftReadError(
783
+ timedOut ? new ComposerStateError(t("hooks.useComposer.draftSyncTimedOutRetrying"), { cause }) : problem
784
+ );
785
+ if (timedOut || cause instanceof TypeError || cause && typeof cause === "object" && "retryable" in cause && cause.retryable === true) {
786
+ retry.failures += 1;
787
+ scheduleRetry();
788
+ if (draftRef.current === null) setDraftHydrationRetrying(true);
789
+ } else {
790
+ if (retry.timer !== null) clearTimeout(retry.timer);
791
+ retry.failures = 0;
792
+ retry.timer = null;
793
+ setDraftHydrationRetrying(false);
794
+ }
795
+ }
796
+ } finally {
797
+ if (generation === targetGeneration.current && targetKeyRef.current === targetKey && readTicket === draftReadGeneration.current) {
798
+ setDraftLoading(false);
799
+ }
800
+ if (draftReadInFlightRef.current === targetKey) {
801
+ draftReadInFlightRef.current = null;
802
+ }
803
+ if (draftReadAbortRef.current === requestAbort) {
804
+ draftReadAbortRef.current = null;
805
+ }
806
+ }
807
+ },
808
+ [client, durableDrafts, sessionId, targetKey, workspaceId, t]
809
+ );
810
+ useEffect(() => {
811
+ if (!sessionId || !durableDrafts) {
812
+ setDraftLoading(false);
813
+ return;
814
+ }
815
+ void loadDraft(false);
816
+ }, [durableDrafts, loadDraft, sessionId]);
817
+ useEffect(() => {
818
+ if (!sessionId || !durableDrafts) return;
819
+ const onWake = () => {
820
+ if (typeof document !== "undefined" && document.visibilityState === "hidden") return;
821
+ void loadDraft(false);
822
+ };
823
+ document.addEventListener("visibilitychange", onWake);
824
+ window.addEventListener("pageshow", onWake);
825
+ return () => {
826
+ document.removeEventListener("visibilitychange", onWake);
827
+ window.removeEventListener("pageshow", onWake);
828
+ };
829
+ }, [durableDrafts, loadDraft, sessionId]);
830
+ useEffect(() => {
831
+ if (!sessionId || !durableDrafts) return;
832
+ return registerSessionReconciler(sessionId, "composer", async () => await loadDraft(false));
833
+ }, [durableDrafts, loadDraft, registerSessionReconciler, sessionId]);
834
+ const reconcileSteering = useCallback(async () => {
835
+ if (!sessionId || !steeringRef.current) return;
836
+ const ownedTargetKey = targetKey;
837
+ let events;
838
+ try {
839
+ events = await client.listEvents(workspaceId, sessionId, {
840
+ includeTypes: [
841
+ "user.message",
842
+ "turn.started",
843
+ "turn.completed",
844
+ "turn.failed",
845
+ "turn.cancelled",
846
+ "turn.superseded"
847
+ ],
848
+ limit: 250,
849
+ payloadMode: "full"
850
+ });
851
+ } catch {
852
+ return;
853
+ }
854
+ if (targetKeyRef.current !== ownedTargetKey) return;
855
+ setSteering((current) => {
856
+ if (!current) return current;
857
+ if (steeringSettledByEvents(current, events)) {
858
+ steeringSettlementEventsRef.current = [];
859
+ return null;
860
+ }
861
+ const accepted = steeringAcceptedEvent(current, events);
862
+ if (!accepted || current.triggerEventId) return current;
863
+ return {
864
+ ...current,
865
+ phase: "accepted",
866
+ triggerEventId: accepted.id
867
+ };
868
+ });
869
+ }, [client, sessionId, targetKey, workspaceId]);
870
+ useSessionEventTrigger(
871
+ client,
872
+ workspaceId,
873
+ sessionId,
874
+ (event) => isComposerDraftEvent(event) || isSteeringSettlementEvent(event),
875
+ (event) => {
876
+ if (isComposerDraftEvent(event)) void loadDraft(false);
877
+ if (!isSteeringSettlementEvent(event)) return;
878
+ steeringSettlementEventsRef.current = [
879
+ ...steeringSettlementEventsRef.current.slice(-15),
880
+ event
881
+ ];
882
+ setSteering((current) => {
883
+ if (!current || !steeringSettledByEvents(current, [event])) return current;
884
+ steeringSettlementEventsRef.current = [];
885
+ return null;
886
+ });
887
+ },
888
+ {
889
+ enabled: Boolean(sessionId) && (durableDrafts || steering !== null),
890
+ ...options.events !== void 0 ? { events: options.events } : {}
891
+ },
892
+ reconcileSteering
893
+ );
894
+ useEffect(() => {
895
+ if (!steering) return;
896
+ const observed = [...options.events ?? [], ...steeringSettlementEventsRef.current];
897
+ if (!steeringSettledByEvents(steering, observed)) return;
898
+ steeringSettlementEventsRef.current = [];
899
+ setSteering(null);
900
+ }, [options.events, steering]);
901
+ useEffect(() => {
902
+ if (!acceptedControl) return;
903
+ const effectiveControl = options.effectiveControl;
904
+ if (!effectiveControl || effectiveControl.controlVersion < acceptedControl.controlVersion) {
905
+ return;
906
+ }
907
+ setAcceptedControl((current) => current === acceptedControl ? null : current);
908
+ }, [acceptedControl, options.effectiveControl]);
909
+ const pendingAcceptedControl = acceptedControl && (!options.effectiveControl || options.effectiveControl.controlVersion < acceptedControl.controlVersion) ? acceptedControl : null;
910
+ const currentDraftPayload = useCallback(() => {
911
+ if (!durableDrafts || targetKeyRef.current !== targetKey) return null;
912
+ const base = draftRef.current;
913
+ const currentPolicy = policyRef.current;
914
+ if (!base || !currentPolicy) return null;
915
+ return composerDraftPayload(
916
+ base,
917
+ value,
918
+ restoredResources,
919
+ annotations,
920
+ pickedPolicy(policyPickedRef, policyRef),
921
+ resolveSendExtras(sendExtrasRef.current).resources ?? []
922
+ );
923
+ }, [annotations, durableDrafts, restoredResources, targetKey, value]);
924
+ const adoptDraftBase = useCallback(
925
+ (next) => {
926
+ if (targetKeyRef.current !== targetKey) return;
927
+ draftRef.current = next;
928
+ setDraft(next);
929
+ const nextPolicy = policyFromDraft(next);
930
+ if (next.policyFollowsSession) {
931
+ if (samePolicy(policyRef.current, nextPolicy)) {
932
+ policyPickedRef.current = false;
933
+ setPolicyPicked(false);
934
+ }
935
+ if (!policyPickedRef.current && !samePolicy(policyRef.current, nextPolicy)) {
936
+ policyRef.current = nextPolicy;
937
+ setPolicy(nextPolicy);
938
+ }
939
+ }
940
+ lastSavedSignature.current = draftSignature(draftPayload(next));
941
+ setDraftConflict(null);
942
+ setError(null);
943
+ },
944
+ [targetKey]
945
+ );
946
+ const acquireDraftSlot = useCallback(async () => {
947
+ let release;
948
+ const released = new Promise((resolve) => {
949
+ release = resolve;
950
+ });
951
+ const previous = saveChain.current;
952
+ saveChain.current = previous.then(
953
+ () => released,
954
+ () => released
955
+ );
956
+ await previous.catch(() => void 0);
957
+ return release;
958
+ }, []);
959
+ const saveDraftInSlot = useCallback(
960
+ async (payload, owner, onFailure) => {
961
+ const owned = () => targetKeyRef.current === owner.targetKey && targetGeneration.current === owner.generation;
962
+ if (!sessionId || !durableDrafts || !owned()) return false;
963
+ const current = draftRef.current;
964
+ if (!current) return false;
965
+ const request = { ...payload, expectedRevision: current.revision };
966
+ if (draftSignature(request) === lastSavedSignature.current) return true;
967
+ setDraftSaving(true);
968
+ try {
969
+ const saved = await client.saveComposerDraft(workspaceId, sessionId, request);
970
+ if (!owned()) return false;
971
+ adoptDraftBase(saved);
972
+ return true;
973
+ } catch (cause) {
974
+ if (owned()) {
975
+ const problem = asError(cause);
976
+ if (isDraftConflictError(problem)) setDraftConflict(problem);
977
+ setError(problem);
978
+ onFailure?.(problem);
979
+ }
980
+ return false;
981
+ } finally {
982
+ if (owned()) setDraftSaving(false);
983
+ }
984
+ },
985
+ [adoptDraftBase, client, durableDrafts, sessionId, workspaceId]
986
+ );
987
+ const persistPayload = useCallback(
988
+ async (payload, onFailure) => {
989
+ const owner = { targetKey, generation: targetGeneration.current };
990
+ if (!sessionId || !durableDrafts || targetKeyRef.current !== owner.targetKey) {
991
+ return false;
992
+ }
993
+ const release = await acquireDraftSlot();
994
+ try {
995
+ return await saveDraftInSlot(payload, owner, onFailure);
996
+ } finally {
997
+ release();
998
+ }
999
+ },
1000
+ [acquireDraftSlot, durableDrafts, saveDraftInSlot, sessionId, targetKey]
1001
+ );
1002
+ const flushDraft = useCallback(async () => {
1003
+ if (draftLoading || sending || draftConflict) return;
1004
+ const payload = currentDraftPayload();
1005
+ if (!payload || draftSignature(payload) === lastSavedSignature.current) return;
1006
+ await persistPayload(payload);
1007
+ }, [currentDraftPayload, draftConflict, draftLoading, persistPayload, sending]);
1008
+ const replaceOptimisticSends = useCallback(
1009
+ (update) => {
1010
+ const next = update(optimisticSendsRef.current);
1011
+ optimisticSendsRef.current = next;
1012
+ rememberOptimisticSendOperations(pendingOperationKey, next);
1013
+ setOptimisticSends(next);
1014
+ return next;
1015
+ },
1016
+ [pendingOperationKey]
1017
+ );
1018
+ const markOptimisticAccepted = useCallback(
1019
+ (operation) => {
1020
+ if (!optimisticCallbackIdsRef.current.has(operation.clientEventId)) {
1021
+ optimisticCallbackIdsRef.current.add(operation.clientEventId);
1022
+ onSent?.(operation.input.text, operation.input);
1023
+ }
1024
+ replaceOptimisticSends(
1025
+ (current) => current.filter((candidate) => candidate.clientEventId !== operation.clientEventId)
1026
+ );
1027
+ },
1028
+ [onSent, replaceOptimisticSends]
1029
+ );
1030
+ useEffect(() => {
1031
+ const events = options.events ?? [];
1032
+ if (events.length === 0 || optimisticSendsRef.current.length === 0) return;
1033
+ const reconciled = optimisticSendsRef.current.map(
1034
+ (operation) => reconcileOptimisticSendFromEvents(operation, events)
1035
+ );
1036
+ const settledIds = new Set(
1037
+ reconciled.filter((item) => item.settled).map((item) => item.operation.clientEventId)
1038
+ );
1039
+ const changed = reconciled.some(
1040
+ (item, index) => item.operation !== optimisticSendsRef.current[index] && !settledIds.has(item.operation.clientEventId)
1041
+ );
1042
+ for (const item of reconciled) {
1043
+ if (item.admitted && !optimisticCallbackIdsRef.current.has(item.operation.clientEventId)) {
1044
+ optimisticCallbackIdsRef.current.add(item.operation.clientEventId);
1045
+ onSent?.(item.operation.input.text, item.operation.input);
1046
+ }
1047
+ if (item.settled) markOptimisticAccepted(item.operation);
1048
+ }
1049
+ if (changed) {
1050
+ replaceOptimisticSends(
1051
+ (current) => current.map(
1052
+ (operation) => reconciled.find((item) => item.operation.clientEventId === operation.clientEventId)?.operation ?? operation
1053
+ ).filter((operation) => !settledIds.has(operation.clientEventId))
1054
+ );
1055
+ }
1056
+ if (durableDrafts && reconciled.some((item) => item.admitted)) void loadDraft(false);
1057
+ }, [
1058
+ durableDrafts,
1059
+ loadDraft,
1060
+ markOptimisticAccepted,
1061
+ onSent,
1062
+ options.events,
1063
+ replaceOptimisticSends
1064
+ ]);
1065
+ const processOptimisticSends = useCallback(() => {
1066
+ if (!sessionId || optimisticProcessorBusyRef.current) return;
1067
+ const currentOperations = optimisticSendsRef.current;
1068
+ const operationIndex = currentOperations.findIndex(
1069
+ (candidate) => candidate.state === "sending"
1070
+ );
1071
+ const operation = operationIndex < 0 ? void 0 : currentOperations[operationIndex];
1072
+ if (!operation) return;
1073
+ const held = serviceWaitRef.current.get(operation.clientEventId);
1074
+ if (held && held.retryAt > Date.now()) {
1075
+ if (serviceRetryTimerRef.current === null) {
1076
+ serviceRetryTimerRef.current = setTimeout(
1077
+ () => {
1078
+ serviceRetryTimerRef.current = null;
1079
+ processOptimisticSendsRef.current();
1080
+ },
1081
+ Math.max(0, held.retryAt - Date.now())
1082
+ );
1083
+ }
1084
+ return;
1085
+ }
1086
+ const ownedTargetKey = targetKey;
1087
+ const ownedGeneration = targetGeneration.current;
1088
+ optimisticProcessorBusyRef.current = true;
1089
+ void (async () => {
1090
+ let mutationFailureObserved = false;
1091
+ let notSubmitted = false;
1092
+ let holding = false;
1093
+ let releaseDraftSlot = null;
1094
+ const holdForService = (cause, outcomeUnknown) => {
1095
+ if (outcomeUnknown && !operation.canRetry) return false;
1096
+ const now = Date.now();
1097
+ const previous = serviceWaitRef.current.get(operation.clientEventId);
1098
+ const since = isMaintenanceError(cause) ? now : previous?.since ?? now;
1099
+ if (!isCalmServiceFailure(cause, since, now)) return false;
1100
+ const attempts = (previous?.attempts ?? 0) + 1;
1101
+ const delayMs = Math.round(
1102
+ Math.min(SERVICE_SEND_RETRY_MAX_DELAY_MS, 1e3 * 2 ** (attempts - 1)) * (0.8 + Math.random() * 0.4)
1103
+ );
1104
+ serviceWaitRef.current.set(operation.clientEventId, {
1105
+ since,
1106
+ attempts,
1107
+ retryAt: now + delayMs
1108
+ });
1109
+ holding = true;
1110
+ setServiceWaiting(true);
1111
+ replaceOptimisticSends(
1112
+ (current) => current.map(
1113
+ (candidate) => candidate.clientEventId === operation.clientEventId ? { ...candidate, state: "sending", outcomeUnknown } : candidate
1114
+ )
1115
+ );
1116
+ return true;
1117
+ };
1118
+ const markFailed = (cause, outcomeUnknown) => {
1119
+ if (targetKeyRef.current !== ownedTargetKey || targetGeneration.current !== ownedGeneration) {
1120
+ return false;
1121
+ }
1122
+ if (holdForService(cause, outcomeUnknown)) return true;
1123
+ const problem = asError(cause);
1124
+ replaceOptimisticSends(
1125
+ (current) => current.map(
1126
+ (candidate) => candidate.clientEventId === operation.clientEventId ? {
1127
+ ...candidate,
1128
+ state: "failed",
1129
+ error: formatError(
1130
+ cause,
1131
+ outcomeUnknown && !isOutcomeUnknownError(problem) && !(problem instanceof ComposerReconciliationRequiredError) ? problem instanceof OpenGeniApiError && problem.correlationId ? t("hooks.useComposer.notConfirmedCheckStatusWithReference", {
1132
+ reference: problem.correlationId
1133
+ }) : t("hooks.useComposer.notConfirmedCheckStatus") : composerSubmissionErrorMessage(t, problem, canBuyCreditsRef.current)
1134
+ ),
1135
+ retryable: outcomeUnknown || composerSubmissionCanRetry(problem),
1136
+ outcomeUnknown,
1137
+ correlationId: problem instanceof OpenGeniApiError ? problem.correlationId : candidate.correlationId
1138
+ } : candidate
1139
+ )
1140
+ );
1141
+ return false;
1142
+ };
1143
+ try {
1144
+ if (operation.outcomeUnknown) {
1145
+ let events;
1146
+ try {
1147
+ events = await client.listEvents(workspaceId, sessionId, {
1148
+ includeTypes: [
1149
+ "user.message",
1150
+ "turn.queued",
1151
+ "turn.started",
1152
+ "turn.completed",
1153
+ "turn.failed",
1154
+ "turn.cancelled",
1155
+ "turn.superseded"
1156
+ ],
1157
+ limit: 250,
1158
+ payloadMode: "full"
1159
+ });
1160
+ } catch (cause) {
1161
+ const wasHeld = serviceWaitRef.current.has(operation.clientEventId);
1162
+ if (!markFailed(cause, true) && wasHeld) {
1163
+ notifyObserver(
1164
+ onDeliveryErrorRef.current,
1165
+ asError(cause),
1166
+ operation.input,
1167
+ "send"
1168
+ );
1169
+ }
1170
+ return;
1171
+ }
1172
+ const reconciled = reconcileOptimisticSendFromEvents(operation, events);
1173
+ if (reconciled.admitted) {
1174
+ if (durableDrafts) await loadDraft(false);
1175
+ if (reconciled.settled) {
1176
+ markOptimisticAccepted(reconciled.operation);
1177
+ } else {
1178
+ replaceOptimisticSends(
1179
+ (current) => current.map(
1180
+ (candidate) => candidate.clientEventId === operation.clientEventId ? reconciled.operation : candidate
1181
+ )
1182
+ );
1183
+ if (!optimisticCallbackIdsRef.current.has(operation.clientEventId)) {
1184
+ optimisticCallbackIdsRef.current.add(operation.clientEventId);
1185
+ onSent?.(reconciled.operation.input.text, reconciled.operation.input);
1186
+ }
1187
+ }
1188
+ return;
1189
+ }
1190
+ if (!operation.canRetry) {
1191
+ throw new ComposerReconciliationRequiredError();
1192
+ }
1193
+ }
1194
+ let expectedDraftRevision;
1195
+ if (durableDrafts && operation.draftPayload) {
1196
+ releaseDraftSlot = await acquireDraftSlot();
1197
+ let persistFailure = null;
1198
+ if (!await saveDraftInSlot(
1199
+ operation.draftPayload,
1200
+ { targetKey: ownedTargetKey, generation: ownedGeneration },
1201
+ (problem) => {
1202
+ persistFailure = problem;
1203
+ }
1204
+ )) {
1205
+ if (persistFailure && isTransientServiceFailure(persistFailure)) {
1206
+ notSubmitted = true;
1207
+ throw persistFailure;
1208
+ }
1209
+ throw new ComposerStateError(t("hooks.useComposer.theMessageDraftCouldNot"));
1210
+ }
1211
+ expectedDraftRevision = draftRef.current?.revision;
1212
+ }
1213
+ if (targetKeyRef.current !== ownedTargetKey || targetGeneration.current !== ownedGeneration) {
1214
+ return;
1215
+ }
1216
+ const wireInput = {
1217
+ ...operation.input,
1218
+ ...expectedDraftRevision !== void 0 ? { expectedDraftRevision } : {}
1219
+ };
1220
+ let acceptedResult = null;
1221
+ let acceptedEvent = null;
1222
+ if (durableDrafts) {
1223
+ if (!operation.draftPayload || expectedDraftRevision === void 0) {
1224
+ throw new ComposerStateError(t("hooks.useComposer.theDurableComposerDraftIs"));
1225
+ }
1226
+ const result = await client.submitComposerDraft(workspaceId, sessionId, {
1227
+ text: operation.draftPayload.text,
1228
+ annotations: operation.draftPayload.annotations,
1229
+ resources: operation.draftPayload.resources,
1230
+ // Absent while the draft follows the chat's settings.
1231
+ ...operation.draftPayload.model !== void 0 ? { model: operation.draftPayload.model } : {},
1232
+ ...operation.draftPayload.reasoningEffort !== void 0 ? { reasoningEffort: operation.draftPayload.reasoningEffort } : {},
1233
+ ...operation.draftPayload.latencyMode !== void 0 ? { latencyMode: operation.draftPayload.latencyMode } : {},
1234
+ expectedDraftRevision,
1235
+ clientEventId: operation.clientEventId,
1236
+ delivery: "send",
1237
+ ...wireInput.controlEtag ? { controlEtag: wireInput.controlEtag } : {},
1238
+ ...wireInput.modelContext ? { modelContext: wireInput.modelContext } : {},
1239
+ ...wireInput.mcpCredentialUpdates ? { mcpCredentialUpdates: wireInput.mcpCredentialUpdates } : {},
1240
+ ...wireInput.connectionAccounts ? { connectionAccounts: wireInput.connectionAccounts } : {},
1241
+ ...wireInput.personalResourceAttachment ? { personalResourceAttachment: wireInput.personalResourceAttachment } : {}
1242
+ }).catch((cause) => {
1243
+ mutationFailureObserved = true;
1244
+ throw cause;
1245
+ });
1246
+ acceptedResult = result;
1247
+ adoptDraftBase(result.draft);
1248
+ releaseDraftSlot?.();
1249
+ } else {
1250
+ acceptedEvent = await client.sendMessage(workspaceId, sessionId, wireInput).catch((cause) => {
1251
+ mutationFailureObserved = true;
1252
+ throw cause;
1253
+ });
1254
+ }
1255
+ if (targetKeyRef.current !== ownedTargetKey || targetGeneration.current !== ownedGeneration) {
1256
+ return;
1257
+ }
1258
+ const acceptedRouting = acceptedResult?.routing ?? promptRoutingFromAcceptedEvent(acceptedEvent);
1259
+ const acceptedDestination = acceptedRouting === "queued_for_execution" ? "queue" : acceptedRouting === "accepted_for_execution" || acceptedRouting === "accepted_for_steering" ? "chat" : operation.destination;
1260
+ if (options.events === void 0 && acceptedDestination === "chat") {
1261
+ markOptimisticAccepted({ ...operation, input: wireInput });
1262
+ } else {
1263
+ replaceOptimisticSends(
1264
+ (current) => current.map(
1265
+ (candidate) => candidate.clientEventId === operation.clientEventId ? {
1266
+ ...candidate,
1267
+ input: wireInput,
1268
+ destination: acceptedDestination,
1269
+ turnId: acceptedResult?.turn.id ?? candidate.turnId,
1270
+ triggerEventId: acceptedResult?.accepted.id ?? acceptedEvent?.id ?? candidate.triggerEventId,
1271
+ appliedQueueVersion: acceptedResult?.receipt?.appliedQueueVersion ?? candidate.appliedQueueVersion,
1272
+ state: "queued",
1273
+ error: void 0
1274
+ } : candidate
1275
+ )
1276
+ );
1277
+ }
1278
+ if (!optimisticCallbackIdsRef.current.has(operation.clientEventId)) {
1279
+ optimisticCallbackIdsRef.current.add(operation.clientEventId);
1280
+ onSent?.(wireInput.text, wireInput);
1281
+ }
1282
+ } catch (cause) {
1283
+ const current = optimisticSendsRef.current.find(
1284
+ (candidate) => candidate.clientEventId === operation.clientEventId
1285
+ );
1286
+ if (!current || current.state === "queued" && current.outcomeUnknown === false) {
1287
+ return;
1288
+ }
1289
+ const problem = asError(cause);
1290
+ const outcomeUnknown = operation.outcomeUnknown && !mutationFailureObserved ? true : !notSubmitted && isOutcomeUnknownError(cause);
1291
+ if (!markFailed(cause, outcomeUnknown)) {
1292
+ notifyObserver(onDeliveryErrorRef.current, problem, operation.input, "send");
1293
+ }
1294
+ } finally {
1295
+ releaseDraftSlot?.();
1296
+ optimisticProcessorBusyRef.current = false;
1297
+ if (targetKeyRef.current === ownedTargetKey && targetGeneration.current === ownedGeneration) {
1298
+ if (!holding) serviceWaitRef.current.delete(operation.clientEventId);
1299
+ for (const id of serviceWaitRef.current.keys()) {
1300
+ if (!optimisticSendsRef.current.some(
1301
+ (candidate) => candidate.clientEventId === id && candidate.state === "sending"
1302
+ )) {
1303
+ serviceWaitRef.current.delete(id);
1304
+ }
1305
+ }
1306
+ setServiceWaiting(serviceWaitRef.current.size > 0);
1307
+ }
1308
+ if (targetKeyRef.current === ownedTargetKey) {
1309
+ setOptimisticSends([...optimisticSendsRef.current]);
1310
+ }
1311
+ }
1312
+ })();
1313
+ }, [
1314
+ acquireDraftSlot,
1315
+ adoptDraftBase,
1316
+ client,
1317
+ durableDrafts,
1318
+ formatError,
1319
+ markOptimisticAccepted,
1320
+ loadDraft,
1321
+ onSent,
1322
+ options.events,
1323
+ replaceOptimisticSends,
1324
+ saveDraftInSlot,
1325
+ sessionId,
1326
+ targetKey,
1327
+ workspaceId,
1328
+ t
1329
+ ]);
1330
+ processOptimisticSendsRef.current = processOptimisticSends;
1331
+ useEffect(() => {
1332
+ processOptimisticSends();
1333
+ }, [optimisticSends, processOptimisticSends]);
1334
+ useEffect(() => {
1335
+ for (const id of serviceWaitRef.current.keys()) {
1336
+ if (!optimisticSends.some(
1337
+ (candidate) => candidate.clientEventId === id && candidate.state === "sending"
1338
+ )) {
1339
+ serviceWaitRef.current.delete(id);
1340
+ }
1341
+ }
1342
+ setServiceWaiting(serviceWaitRef.current.size > 0);
1343
+ }, [optimisticSends]);
1344
+ useEffect(() => {
1345
+ const pending = pendingOperationRef.current;
1346
+ if (pending) {
1347
+ const shadow = {
1348
+ text: valueRef.current,
1349
+ resources: mergeResources(
1350
+ restoredResourcesRef.current,
1351
+ resolveSendExtras(sendExtrasRef.current).resources ?? []
1352
+ ),
1353
+ annotations: annotationsRef.current,
1354
+ ...pickedPolicy(policyPickedRef, policyRef) ? { policy: pickedPolicy(policyPickedRef, policyRef) } : {}
1355
+ };
1356
+ if (pending.newerShadow.text !== shadow.text || JSON.stringify(pending.newerShadow.resources) !== JSON.stringify(shadow.resources) || JSON.stringify(pending.newerShadow.annotations) !== JSON.stringify(shadow.annotations) || JSON.stringify(pending.newerShadow.policy) !== JSON.stringify(shadow.policy)) {
1357
+ pendingOperationRef.current = updatePendingComposerShadow(
1358
+ pendingOperationKey,
1359
+ pending,
1360
+ shadow
1361
+ );
1362
+ }
1363
+ return;
1364
+ }
1365
+ const optimistic = optimisticSendsRef.current.at(-1);
1366
+ if (optimistic) {
1367
+ const shadow = {
1368
+ text: valueRef.current,
1369
+ resources: mergeResources(
1370
+ restoredResourcesRef.current,
1371
+ resolveSendExtras(sendExtrasRef.current).resources ?? []
1372
+ ),
1373
+ annotations: annotationsRef.current,
1374
+ ...pickedPolicy(policyPickedRef, policyRef) ? { policy: pickedPolicy(policyPickedRef, policyRef) } : {}
1375
+ };
1376
+ if (optimistic.newerShadow.text !== shadow.text || JSON.stringify(optimistic.newerShadow.resources) !== JSON.stringify(shadow.resources) || JSON.stringify(optimistic.newerShadow.annotations) !== JSON.stringify(shadow.annotations) || JSON.stringify(optimistic.newerShadow.policy) !== JSON.stringify(shadow.policy)) {
1377
+ setOptimisticDraftShadow(shadow);
1378
+ }
1379
+ }
1380
+ if (optimisticSendsRef.current.some((operation) => operation.state === "sending")) {
1381
+ return;
1382
+ }
1383
+ if (!durableDrafts || !sessionId || draftLoading || sending || !draftRef.current || draftConflict)
1384
+ return;
1385
+ const payload = currentDraftPayload();
1386
+ if (!payload || draftSignature(payload) === lastSavedSignature.current) return;
1387
+ const timer = window.setTimeout(() => void persistPayload(payload), 500);
1388
+ return () => window.clearTimeout(timer);
1389
+ }, [
1390
+ autosaveRetry,
1391
+ currentDraftPayload,
1392
+ durableDrafts,
1393
+ draftConflict,
1394
+ draftLoading,
1395
+ liveExtrasVersion,
1396
+ pendingOperationKey,
1397
+ persistPayload,
1398
+ setOptimisticDraftShadow,
1399
+ sending,
1400
+ sessionId
1401
+ ]);
1402
+ useEffect(() => {
1403
+ if (!error || !sessionId || !isTransientServiceFailure(error) || isActionFailure(error)) {
1404
+ return;
1405
+ }
1406
+ const ownedTargetKey = targetKey;
1407
+ const ownedError = error;
1408
+ let cancelled = false;
1409
+ let inFlight = false;
1410
+ const timer = setInterval(() => {
1411
+ if (inFlight) return;
1412
+ inFlight = true;
1413
+ const probe = durableDrafts ? client.getComposerDraft(workspaceId, sessionId) : client.listEvents(workspaceId, sessionId, { limit: 1, payloadMode: "none" });
1414
+ probe.then(
1415
+ () => {
1416
+ inFlight = false;
1417
+ if (cancelled || targetKeyRef.current !== ownedTargetKey) return;
1418
+ setError((current) => current === ownedError ? null : current);
1419
+ setAutosaveRetry((nonce) => nonce + 1);
1420
+ },
1421
+ () => {
1422
+ inFlight = false;
1423
+ }
1424
+ );
1425
+ }, TRANSIENT_RECONNECT_INTERVAL_MS);
1426
+ return () => {
1427
+ cancelled = true;
1428
+ clearInterval(timer);
1429
+ };
1430
+ }, [client, durableDrafts, error, sessionId, targetKey, workspaceId]);
1431
+ const dispatch = useCallback(
1432
+ async (delivery, explicit) => {
1433
+ const ownedTargetKey = targetKey;
1434
+ const ownedGeneration = targetGeneration.current;
1435
+ const operationKey = pendingComposerOperationKey(workspaceId, sessionId);
1436
+ const pending = pendingOperationRef.current ?? restorePendingComposerOperation(operationKey);
1437
+ if (pending && !pendingOperationRef.current) {
1438
+ pendingOperationRef.current = pending;
1439
+ pendingClientEventId.current = pending.input.clientEventId ?? null;
1440
+ }
1441
+ const draftAtSend = value;
1442
+ const annotationsAtSend = annotations;
1443
+ const rawText = explicit ?? draftAtSend;
1444
+ const hasText = rawText.trim().length > 0;
1445
+ const hasAnnotations = annotationsAtSend.length > 0;
1446
+ const currentPolicy = policyRef.current;
1447
+ const annotationsComplete2 = annotationsAtSend.every(
1448
+ (annotation) => annotation.note.trim().length > 0
1449
+ );
1450
+ const extras = pending ? {} : resolveSendExtras(sendExtrasRef.current);
1451
+ const hasResources = restoredResources.length > 0 || (extras.resources?.length ?? 0) > 0;
1452
+ if (!pending && (!annotationsComplete2 || !hasText && !hasResources && !hasAnnotations) || !sessionId || !currentPolicy || sending || sendBlockedRef.current?.() === true || targetKeyRef.current !== ownedTargetKey) {
1453
+ return false;
1454
+ }
1455
+ const clearPending = () => {
1456
+ pendingOperationRef.current = null;
1457
+ pendingClientEventId.current = null;
1458
+ forgetPendingComposerOperation(operationKey);
1459
+ };
1460
+ let keepSteering = pending?.delivery === "steer";
1461
+ let releaseDraftSlot = null;
1462
+ const settleAccepted = (operation) => {
1463
+ clearPending();
1464
+ const draftWasUnchanged = valueRef.current === operation.draftAtSend;
1465
+ const resourcesWereUnchanged = JSON.stringify(restoredResourcesRef.current) === JSON.stringify(operation.resourcesAtSend);
1466
+ const annotationsWereUnchanged = JSON.stringify(annotationsRef.current) === JSON.stringify(operation.annotationsAtSend);
1467
+ if (resourcesWereUnchanged) {
1468
+ restoredResourcesRef.current = [];
1469
+ setRestoredResources([]);
1470
+ }
1471
+ if (annotationsWereUnchanged) {
1472
+ annotationsRef.current = [];
1473
+ setAnnotations([]);
1474
+ setAnnotationReviewTargetId(null);
1475
+ }
1476
+ if (operation.clearDraftOnAccept && draftWasUnchanged) {
1477
+ valueRef.current = "";
1478
+ setValue("");
1479
+ }
1480
+ onSent?.(operation.input.text, operation.input);
1481
+ };
1482
+ const deliver = async (operation) => {
1483
+ if (durableDrafts) {
1484
+ const input = operation.input;
1485
+ if (input.expectedDraftRevision === void 0 || input.clientEventId === void 0) {
1486
+ throw new ComposerStateError(t("hooks.useComposer.theDurableComposerDraftIs"));
1487
+ }
1488
+ const result = await client.submitComposerDraft(workspaceId, sessionId, {
1489
+ text: input.text,
1490
+ annotations: input.annotations ?? [],
1491
+ resources: input.resources ?? [],
1492
+ // Absent while the draft follows the chat's settings.
1493
+ ...input.model ? { model: input.model } : {},
1494
+ ...input.reasoningEffort ? { reasoningEffort: input.reasoningEffort } : {},
1495
+ ...input.latencyMode ? { latencyMode: input.latencyMode } : {},
1496
+ expectedDraftRevision: input.expectedDraftRevision,
1497
+ clientEventId: input.clientEventId,
1498
+ delivery: operation.delivery,
1499
+ ...input.controlEtag ? { controlEtag: input.controlEtag } : {},
1500
+ ...input.modelContext ? { modelContext: input.modelContext } : {},
1501
+ ...input.mcpCredentialUpdates ? { mcpCredentialUpdates: input.mcpCredentialUpdates } : {},
1502
+ ...input.connectionAccounts ? { connectionAccounts: input.connectionAccounts } : {},
1503
+ ...input.personalResourceAttachment ? { personalResourceAttachment: input.personalResourceAttachment } : {}
1504
+ });
1505
+ adoptDraftBase(result.draft);
1506
+ return result;
1507
+ }
1508
+ if (operation.delivery === "steer") {
1509
+ return await client.steerMessage(workspaceId, sessionId, operation.input);
1510
+ }
1511
+ await client.sendMessage(workspaceId, sessionId, operation.input);
1512
+ return null;
1513
+ };
1514
+ if (delivery === "steer") {
1515
+ if (steeringRef.current?.clientEventId !== pending?.input.clientEventId) {
1516
+ steeringOccurredAtRef.current = (/* @__PURE__ */ new Date()).toISOString();
1517
+ }
1518
+ setSteering({
1519
+ phase: "submitting",
1520
+ text: rawText,
1521
+ clientEventId: pending?.input.clientEventId ?? pendingClientEventId.current,
1522
+ triggerEventId: null,
1523
+ turnId: null
1524
+ });
1525
+ }
1526
+ setSending(true);
1527
+ setError(null);
1528
+ try {
1529
+ if (pending) {
1530
+ let acceptedEvent = null;
1531
+ try {
1532
+ const events = await client.listEvents(workspaceId, sessionId, {
1533
+ includeTypes: ["user.message"],
1534
+ limit: 100,
1535
+ payloadMode: "none"
1536
+ });
1537
+ acceptedEvent = events.find(
1538
+ (event) => event.type === "user.message" && event.clientEventId === pending.input.clientEventId
1539
+ ) ?? null;
1540
+ } catch (cause) {
1541
+ if (targetKeyRef.current === ownedTargetKey && targetGeneration.current === ownedGeneration) {
1542
+ const problem = markActionFailure(asError(cause));
1543
+ setError(problem);
1544
+ if (pending.delivery === "steer") {
1545
+ keepSteering = true;
1546
+ setSteering({
1547
+ phase: "failed",
1548
+ text: pending.input.text,
1549
+ clientEventId: pending.input.clientEventId ?? null,
1550
+ triggerEventId: null,
1551
+ turnId: null,
1552
+ error: t("hooks.useComposer.notConfirmedRetry"),
1553
+ outcomeUnknown: true
1554
+ });
1555
+ }
1556
+ }
1557
+ return false;
1558
+ }
1559
+ if (targetKeyRef.current !== ownedTargetKey || targetGeneration.current !== ownedGeneration) {
1560
+ return false;
1561
+ }
1562
+ if (acceptedEvent) {
1563
+ if (durableDrafts) await loadDraft(false);
1564
+ if (pending.delivery === "steer") {
1565
+ keepSteering = true;
1566
+ setSteering({
1567
+ phase: "accepted",
1568
+ text: pending.input.text,
1569
+ clientEventId: pending.input.clientEventId ?? null,
1570
+ triggerEventId: acceptedEvent.id,
1571
+ turnId: null
1572
+ });
1573
+ }
1574
+ settleAccepted(pending);
1575
+ return true;
1576
+ }
1577
+ if (!pending.canRetry) {
1578
+ setError(new ComposerReconciliationRequiredError());
1579
+ return false;
1580
+ }
1581
+ try {
1582
+ if (durableDrafts) releaseDraftSlot = await acquireDraftSlot();
1583
+ const result = await deliver(pending);
1584
+ if (pending.delivery === "steer" && result) {
1585
+ keepSteering = true;
1586
+ setSteering({
1587
+ phase: "accepted",
1588
+ text: pending.input.text,
1589
+ clientEventId: pending.input.clientEventId ?? null,
1590
+ triggerEventId: result.accepted.id,
1591
+ turnId: result.turn.id,
1592
+ stoppingPreviousAttempt: result.replay !== true && (result.interruptionCount ?? 0) > 0
1593
+ });
1594
+ }
1595
+ } catch (cause) {
1596
+ const problem = asError(cause);
1597
+ const outcomeUnknown = isOutcomeUnknownError(cause);
1598
+ notifyObserver(
1599
+ onDeliveryErrorRef.current,
1600
+ problem,
1601
+ pending.input,
1602
+ pending.delivery
1603
+ );
1604
+ if (!outcomeUnknown) {
1605
+ clearPending();
1606
+ keepSteering = false;
1607
+ } else if (pending.delivery === "steer") {
1608
+ keepSteering = true;
1609
+ setSteering({
1610
+ phase: "failed",
1611
+ text: pending.input.text,
1612
+ clientEventId: pending.input.clientEventId ?? null,
1613
+ triggerEventId: null,
1614
+ turnId: null,
1615
+ error: t("hooks.useComposer.notConfirmedRetry"),
1616
+ outcomeUnknown: true
1617
+ });
1618
+ }
1619
+ if (targetKeyRef.current === ownedTargetKey && targetGeneration.current === ownedGeneration) {
1620
+ setError(markActionFailure(problem));
1621
+ }
1622
+ return false;
1623
+ }
1624
+ if (targetKeyRef.current !== ownedTargetKey || targetGeneration.current !== ownedGeneration) {
1625
+ return false;
1626
+ }
1627
+ settleAccepted(pending);
1628
+ return true;
1629
+ }
1630
+ const sendText = hasText ? rawText : hasAnnotations ? "" : FILE_ONLY_MESSAGE_TEXT(t);
1631
+ const currentPayload = currentDraftPayload();
1632
+ const payload = currentPayload ? { ...currentPayload, text: sendText } : null;
1633
+ if (payload) {
1634
+ releaseDraftSlot = await acquireDraftSlot();
1635
+ if (!await saveDraftInSlot(payload, {
1636
+ targetKey: ownedTargetKey,
1637
+ generation: ownedGeneration
1638
+ })) {
1639
+ return false;
1640
+ }
1641
+ }
1642
+ if (targetKeyRef.current !== ownedTargetKey || targetGeneration.current !== ownedGeneration) {
1643
+ return false;
1644
+ }
1645
+ pendingClientEventId.current ??= generateClientEventId();
1646
+ const effectiveControl = effectiveControlRef.current;
1647
+ const input = composeSendInput(sendText, pendingClientEventId.current, extras, {
1648
+ ...pickedPolicy(policyPickedRef, policyRef),
1649
+ ...effectiveControl?.controlEtag ? { controlEtag: effectiveControl.controlEtag } : {},
1650
+ ...durableDrafts && draftRef.current ? { expectedDraftRevision: draftRef.current.revision } : {},
1651
+ resources: mergeResources(restoredResources, extras.resources ?? []),
1652
+ annotations: cloneAnnotations(annotationsAtSend)
1653
+ });
1654
+ const operation = {
1655
+ delivery,
1656
+ input,
1657
+ draftAtSend,
1658
+ resourcesAtSend: [...restoredResources],
1659
+ annotationsAtSend: cloneAnnotations(annotationsAtSend),
1660
+ newerShadow: {
1661
+ text: draftAtSend,
1662
+ resources: mergeResources(restoredResources, extras.resources ?? []),
1663
+ annotations: cloneAnnotations(annotationsAtSend),
1664
+ policy: pickedPolicy(policyPickedRef, policyRef)
1665
+ },
1666
+ clearDraftOnAccept: explicit === void 0,
1667
+ canRetry: true
1668
+ };
1669
+ pendingOperationRef.current = operation;
1670
+ rememberPendingComposerOperation(operationKey, operation);
1671
+ if (delivery === "steer") {
1672
+ setSteering({
1673
+ phase: "submitting",
1674
+ text: sendText,
1675
+ clientEventId: input.clientEventId ?? null,
1676
+ triggerEventId: null,
1677
+ turnId: null
1678
+ });
1679
+ }
1680
+ try {
1681
+ const result = await deliver(operation);
1682
+ if (delivery === "steer" && result) {
1683
+ keepSteering = true;
1684
+ setSteering({
1685
+ phase: "accepted",
1686
+ text: sendText,
1687
+ clientEventId: input.clientEventId ?? null,
1688
+ triggerEventId: result.accepted.id,
1689
+ turnId: result.turn.id,
1690
+ stoppingPreviousAttempt: result.replay !== true && (result.interruptionCount ?? 0) > 0
1691
+ });
1692
+ }
1693
+ } catch (cause) {
1694
+ notifyObserver(
1695
+ onDeliveryErrorRef.current,
1696
+ asError(cause),
1697
+ operation.input,
1698
+ operation.delivery
1699
+ );
1700
+ if (!isOutcomeUnknownError(cause)) {
1701
+ clearPending();
1702
+ } else if (delivery === "steer") {
1703
+ keepSteering = true;
1704
+ setSteering({
1705
+ phase: "failed",
1706
+ text: operation.input.text,
1707
+ clientEventId: operation.input.clientEventId ?? null,
1708
+ triggerEventId: null,
1709
+ turnId: null,
1710
+ error: t("hooks.useComposer.notConfirmedRetry"),
1711
+ outcomeUnknown: true
1712
+ });
1713
+ }
1714
+ if (targetKeyRef.current === ownedTargetKey && targetGeneration.current === ownedGeneration) {
1715
+ setError(markActionFailure(asError(cause)));
1716
+ }
1717
+ return false;
1718
+ }
1719
+ if (targetKeyRef.current !== ownedTargetKey || targetGeneration.current !== ownedGeneration) {
1720
+ return false;
1721
+ }
1722
+ settleAccepted(operation);
1723
+ return true;
1724
+ } finally {
1725
+ releaseDraftSlot?.();
1726
+ if (targetKeyRef.current === ownedTargetKey && targetGeneration.current === ownedGeneration) {
1727
+ setSending(false);
1728
+ if (delivery === "steer" && !keepSteering) setSteering(null);
1729
+ }
1730
+ }
1731
+ },
1732
+ [
1733
+ acquireDraftSlot,
1734
+ client,
1735
+ currentDraftPayload,
1736
+ durableDrafts,
1737
+ onSent,
1738
+ restoredResources,
1739
+ annotations,
1740
+ adoptDraftBase,
1741
+ saveDraftInSlot,
1742
+ sending,
1743
+ sessionId,
1744
+ targetKey,
1745
+ value,
1746
+ workspaceId,
1747
+ loadDraft,
1748
+ t
1749
+ ]
1750
+ );
1751
+ const sendToQueue = useCallback(
1752
+ async (explicit) => {
1753
+ if (pendingOperationRef.current?.delivery === "send") {
1754
+ return await dispatch("send", explicit);
1755
+ }
1756
+ const rawText = explicit ?? valueRef.current;
1757
+ const annotationsAtSend = cloneAnnotations(annotationsRef.current);
1758
+ const currentPolicy = policyRef.current;
1759
+ const hasText = rawText.trim().length > 0;
1760
+ const hasAnnotations = annotationsAtSend.length > 0;
1761
+ const annotationsComplete2 = annotationsAtSend.every(
1762
+ (annotation) => annotation.note.trim().length > 0
1763
+ );
1764
+ const extras = resolveSendExtras(sendExtrasRef.current);
1765
+ const resources = mergeResources(restoredResourcesRef.current, extras.resources ?? []);
1766
+ if (!sessionId || !currentPolicy || sending || !annotationsComplete2 || !hasText && !hasAnnotations && resources.length === 0 || sendBlockedRef.current?.() === true || targetKeyRef.current !== targetKey) {
1767
+ return false;
1768
+ }
1769
+ const sendText = hasText ? rawText : hasAnnotations ? "" : FILE_ONLY_MESSAGE_TEXT(t);
1770
+ const clientEventId = generateClientEventId();
1771
+ const effectiveControl = effectiveControlRef.current;
1772
+ const input = composeSendInput(sendText, clientEventId, extras, {
1773
+ ...pickedPolicy(policyPickedRef, policyRef),
1774
+ ...effectiveControl?.controlEtag ? { controlEtag: effectiveControl.controlEtag } : {},
1775
+ resources,
1776
+ annotations: annotationsAtSend
1777
+ });
1778
+ const currentPayload = currentDraftPayload();
1779
+ const hasEarlierUnsettledSend = optimisticSendsRef.current.some(
1780
+ (candidate) => candidate.state !== "failed" || candidate.outcomeUnknown === true
1781
+ );
1782
+ const operation = {
1783
+ clientEventId,
1784
+ delivery: "send",
1785
+ destination: effectiveControl?.state === "paused" || hasEarlierUnsettledSend ? "queue" : sendDestinationRef.current?.() ?? "chat",
1786
+ text: sendText,
1787
+ annotations: annotationsAtSend,
1788
+ resources,
1789
+ occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
1790
+ state: "sending",
1791
+ input,
1792
+ draftPayload: currentPayload ? { ...currentPayload, text: sendText } : null,
1793
+ newerShadow: {
1794
+ text: explicit === void 0 ? "" : valueRef.current,
1795
+ resources: explicit === void 0 ? [] : [...restoredResourcesRef.current],
1796
+ annotations: explicit === void 0 ? [] : cloneAnnotations(annotationsRef.current),
1797
+ policy: pickedPolicy(policyPickedRef, policyRef)
1798
+ },
1799
+ canRetry: true
1800
+ };
1801
+ if (explicit === void 0) {
1802
+ valueRef.current = "";
1803
+ annotationsRef.current = [];
1804
+ restoredResourcesRef.current = [];
1805
+ localEditRevision.current += 1;
1806
+ setValue("");
1807
+ setAnnotations([]);
1808
+ setAnnotationReviewTargetId(null);
1809
+ setRestoredResources([]);
1810
+ }
1811
+ replaceOptimisticSends((current) => [...current, operation]);
1812
+ queueMicrotask(processOptimisticSends);
1813
+ setError(null);
1814
+ onSubmitted?.(sendText, input);
1815
+ return true;
1816
+ },
1817
+ [
1818
+ currentDraftPayload,
1819
+ dispatch,
1820
+ onSubmitted,
1821
+ processOptimisticSends,
1822
+ replaceOptimisticSends,
1823
+ sending,
1824
+ sessionId,
1825
+ targetKey,
1826
+ t
1827
+ ]
1828
+ );
1829
+ const steer = useCallback(async (text) => await dispatch("steer", text), [dispatch]);
1830
+ const takesBusyPath = useCallback(
1831
+ () => effectiveControlRef.current?.state !== "paused" && sendDestinationRef.current?.() === "queue",
1832
+ []
1833
+ );
1834
+ const send = useCallback(
1835
+ async (explicit) => {
1836
+ if (busySendRef.current === "steer" && pendingOperationRef.current?.delivery !== "send" && takesBusyPath()) {
1837
+ return await steer(explicit);
1838
+ }
1839
+ return await sendToQueue(explicit);
1840
+ },
1841
+ [sendToQueue, steer, takesBusyPath]
1842
+ );
1843
+ const sendAlternate = useCallback(
1844
+ async (explicit) => busySendRef.current === "steer" ? await sendToQueue(explicit) : await steer(explicit),
1845
+ [sendToQueue, steer]
1846
+ );
1847
+ const alternateSend = !singleSend && takesBusyPath() ? busySend === "steer" ? "queue" : "steer" : null;
1848
+ const retryOptimisticMessage = useCallback(
1849
+ (clientEventId) => {
1850
+ if (sendBlockedRef.current?.() === true) return;
1851
+ const currentSteering = steeringRef.current;
1852
+ if (currentSteering?.phase === "failed" && currentSteering.clientEventId === clientEventId) {
1853
+ void dispatch("steer");
1854
+ return;
1855
+ }
1856
+ replaceOptimisticSends(
1857
+ (current) => current.map((operation) => {
1858
+ if (operation.clientEventId !== clientEventId || operation.state !== "failed") {
1859
+ return operation;
1860
+ }
1861
+ if (operation.outcomeUnknown) {
1862
+ return { ...operation, state: "sending", error: void 0 };
1863
+ }
1864
+ if (operation.retryable === false) return operation;
1865
+ const nextClientEventId = generateClientEventId();
1866
+ const currentPersonalResourceAttachment = resolveSendExtras(
1867
+ sendExtrasRef.current
1868
+ ).personalResourceAttachment;
1869
+ const retryInput = composeSendInput(
1870
+ operation.text,
1871
+ nextClientEventId,
1872
+ {
1873
+ ...operation.input,
1874
+ ...currentPersonalResourceAttachment ? { personalResourceAttachment: currentPersonalResourceAttachment } : {}
1875
+ },
1876
+ {
1877
+ ...effectiveControlRef.current?.controlEtag ? { controlEtag: effectiveControlRef.current.controlEtag } : {},
1878
+ resources: operation.resources,
1879
+ annotations: operation.annotations
1880
+ }
1881
+ );
1882
+ return {
1883
+ ...operation,
1884
+ clientEventId: nextClientEventId,
1885
+ input: retryInput,
1886
+ draftPayload: operation.draftPayload,
1887
+ occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
1888
+ state: "sending",
1889
+ error: void 0,
1890
+ retryable: void 0,
1891
+ outcomeUnknown: false,
1892
+ canRetry: true
1893
+ };
1894
+ })
1895
+ );
1896
+ queueMicrotask(processOptimisticSends);
1897
+ },
1898
+ [dispatch, processOptimisticSends, replaceOptimisticSends]
1899
+ );
1900
+ const removeOptimisticMessage = useCallback(
1901
+ (clientEventId) => {
1902
+ if (steeringRef.current?.clientEventId === clientEventId) {
1903
+ pendingOperationRef.current = null;
1904
+ pendingClientEventId.current = null;
1905
+ forgetPendingComposerOperation(pendingComposerOperationKey(workspaceId, sessionId));
1906
+ setSteering(null);
1907
+ setError(null);
1908
+ return;
1909
+ }
1910
+ replaceOptimisticSends(
1911
+ (current) => current.filter((operation) => operation.clientEventId !== clientEventId)
1912
+ );
1913
+ },
1914
+ [replaceOptimisticSends, sessionId, workspaceId]
1915
+ );
1916
+ const hasReadyResources = restoredResources.length > 0 || (resolveSendExtras(sendExtrasRef.current).resources?.length ?? 0) > 0;
1917
+ const hasPendingOperation = pendingOperationRef.current !== null;
1918
+ const annotationsComplete = annotations.every((annotation) => annotation.note.trim().length > 0);
1919
+ const pause = useCallback(
1920
+ async (reason) => {
1921
+ const ownedTargetKey = targetKey;
1922
+ const ownedGeneration = targetGeneration.current;
1923
+ if (!sessionId || pausing || targetKeyRef.current !== ownedTargetKey) {
1924
+ return;
1925
+ }
1926
+ setPausing(true);
1927
+ setError(null);
1928
+ try {
1929
+ const clientEventId = generateClientEventId();
1930
+ const effectiveControl = effectiveControlRef.current;
1931
+ const result = await replayOutcomeUnknown(
1932
+ () => client.pauseSession(workspaceId, sessionId, {
1933
+ clientEventId,
1934
+ ...reason !== void 0 ? { reason } : {},
1935
+ ...effectiveControl?.controlEtag ? { expectedControlEtag: effectiveControl.controlEtag } : {}
1936
+ })
1937
+ );
1938
+ if (targetKeyRef.current === ownedTargetKey && targetGeneration.current === ownedGeneration) {
1939
+ setAcceptedControl(result.effectiveControl);
1940
+ }
1941
+ } catch (cause) {
1942
+ if (targetKeyRef.current === ownedTargetKey && targetGeneration.current === ownedGeneration) {
1943
+ setError(markActionFailure(normalizeError(cause)));
1944
+ }
1945
+ } finally {
1946
+ if (targetKeyRef.current === ownedTargetKey && targetGeneration.current === ownedGeneration) {
1947
+ setPausing(false);
1948
+ }
1949
+ }
1950
+ },
1951
+ [client, workspaceId, sessionId, pausing, targetKey]
1952
+ );
1953
+ const resume = useCallback(
1954
+ async (reason) => {
1955
+ const ownedTargetKey = targetKey;
1956
+ const ownedGeneration = targetGeneration.current;
1957
+ if (!sessionId || resuming || targetKeyRef.current !== ownedTargetKey) return;
1958
+ setResuming(true);
1959
+ setError(null);
1960
+ try {
1961
+ const clientEventId = generateClientEventId();
1962
+ const effectiveControl = effectiveControlRef.current;
1963
+ const result = await replayOutcomeUnknown(
1964
+ () => client.resumeSession(workspaceId, sessionId, {
1965
+ clientEventId,
1966
+ ...reason !== void 0 ? { reason } : {},
1967
+ ...effectiveControl?.controlEtag ? { expectedControlEtag: effectiveControl.controlEtag } : {}
1968
+ })
1969
+ );
1970
+ if (targetKeyRef.current === ownedTargetKey && targetGeneration.current === ownedGeneration) {
1971
+ setAcceptedControl(result.effectiveControl);
1972
+ }
1973
+ } catch (cause) {
1974
+ if (targetKeyRef.current === ownedTargetKey && targetGeneration.current === ownedGeneration) {
1975
+ setError(markActionFailure(normalizeError(cause)));
1976
+ }
1977
+ } finally {
1978
+ if (targetKeyRef.current === ownedTargetKey && targetGeneration.current === ownedGeneration) {
1979
+ setResuming(false);
1980
+ }
1981
+ }
1982
+ },
1983
+ [client, workspaceId, sessionId, resuming, targetKey]
1984
+ );
1985
+ const resumeScope = useCallback(
1986
+ async (option) => {
1987
+ const ownedTargetKey = targetKey;
1988
+ const ownedGeneration = targetGeneration.current;
1989
+ if (!sessionId || resuming || targetKeyRef.current !== ownedTargetKey) return;
1990
+ setResuming(true);
1991
+ setError(null);
1992
+ try {
1993
+ if (option.scope === "workspace") {
1994
+ const workspaceBlocker = effectiveControlRef.current?.blockers.find(
1995
+ (blocker) => blocker.kind === "workspace"
1996
+ );
1997
+ if (!client.setWorkspaceInferenceState) {
1998
+ throw new ComposerWorkspaceControlUnavailableError();
1999
+ }
2000
+ const clientEventId = generateClientEventId();
2001
+ await replayOutcomeUnknown(
2002
+ () => client.setWorkspaceInferenceState(workspaceId, {
2003
+ action: "resume",
2004
+ clientEventId,
2005
+ ...workspaceBlocker ? { expectedRevision: workspaceBlocker.revision } : {}
2006
+ })
2007
+ );
2008
+ } else if (option.scope === "session" && option.targetId) {
2009
+ const target = await client.getQueue(workspaceId, option.targetId);
2010
+ if (targetKeyRef.current !== ownedTargetKey || targetGeneration.current !== ownedGeneration) {
2011
+ return;
2012
+ }
2013
+ const clientEventId = generateClientEventId();
2014
+ await replayOutcomeUnknown(
2015
+ () => client.resumeSession(workspaceId, option.targetId, {
2016
+ clientEventId,
2017
+ expectedControlEtag: target.effectiveControl.controlEtag
2018
+ })
2019
+ );
2020
+ } else {
2021
+ const clientEventId = generateClientEventId();
2022
+ const effectiveControl = effectiveControlRef.current;
2023
+ const result = await replayOutcomeUnknown(
2024
+ () => client.resumeSession(workspaceId, sessionId, {
2025
+ clientEventId,
2026
+ ...effectiveControl?.controlEtag ? { expectedControlEtag: effectiveControl.controlEtag } : {}
2027
+ })
2028
+ );
2029
+ if (targetKeyRef.current === ownedTargetKey && targetGeneration.current === ownedGeneration) {
2030
+ setAcceptedControl(result.effectiveControl);
2031
+ }
2032
+ }
2033
+ } catch (cause) {
2034
+ if (targetKeyRef.current === ownedTargetKey && targetGeneration.current === ownedGeneration) {
2035
+ setError(markActionFailure(asError(cause)));
2036
+ }
2037
+ } finally {
2038
+ if (targetKeyRef.current === ownedTargetKey && targetGeneration.current === ownedGeneration) {
2039
+ setResuming(false);
2040
+ }
2041
+ }
2042
+ },
2043
+ [client, resuming, sessionId, targetKey, workspaceId]
2044
+ );
2045
+ const updateValue = useCallback(
2046
+ (next) => {
2047
+ if (targetKeyRef.current !== targetKey) return;
2048
+ localEditRevision.current += 1;
2049
+ valueRef.current = next;
2050
+ pendingOperationRef.current = updatePendingComposerShadow(
2051
+ pendingOperationKey,
2052
+ pendingOperationRef.current,
2053
+ {
2054
+ text: next,
2055
+ resources: mergeResources(
2056
+ restoredResourcesRef.current,
2057
+ resolveSendExtras(sendExtrasRef.current).resources ?? []
2058
+ ),
2059
+ annotations: annotationsRef.current,
2060
+ policy: pickedPolicy(policyPickedRef, policyRef)
2061
+ }
2062
+ );
2063
+ setOptimisticDraftShadow({
2064
+ text: next,
2065
+ resources: mergeResources(
2066
+ restoredResourcesRef.current,
2067
+ resolveSendExtras(sendExtrasRef.current).resources ?? []
2068
+ ),
2069
+ annotations: annotationsRef.current,
2070
+ policy: pickedPolicy(policyPickedRef, policyRef)
2071
+ });
2072
+ setValue(next);
2073
+ },
2074
+ [pendingOperationKey, setOptimisticDraftShadow, targetKey]
2075
+ );
2076
+ const updateAnnotations = useCallback(
2077
+ (next, reviewTargetId = null) => {
2078
+ if (targetKeyRef.current !== targetKey) return;
2079
+ localEditRevision.current += 1;
2080
+ annotationsRef.current = next;
2081
+ pendingOperationRef.current = updatePendingComposerShadow(
2082
+ pendingOperationKey,
2083
+ pendingOperationRef.current,
2084
+ {
2085
+ text: valueRef.current,
2086
+ resources: mergeResources(
2087
+ restoredResourcesRef.current,
2088
+ resolveSendExtras(sendExtrasRef.current).resources ?? []
2089
+ ),
2090
+ annotations: next,
2091
+ policy: pickedPolicy(policyPickedRef, policyRef)
2092
+ }
2093
+ );
2094
+ setOptimisticDraftShadow({
2095
+ text: valueRef.current,
2096
+ resources: mergeResources(
2097
+ restoredResourcesRef.current,
2098
+ resolveSendExtras(sendExtrasRef.current).resources ?? []
2099
+ ),
2100
+ annotations: next,
2101
+ policy: pickedPolicy(policyPickedRef, policyRef)
2102
+ });
2103
+ setAnnotations(next);
2104
+ setAnnotationReviewTargetId(reviewTargetId);
2105
+ },
2106
+ [pendingOperationKey, setOptimisticDraftShadow, targetKey]
2107
+ );
2108
+ const addAnnotation = useCallback(
2109
+ (annotation) => {
2110
+ const next = [...annotationsRef.current, annotation];
2111
+ updateAnnotations(next, annotation.id);
2112
+ },
2113
+ [updateAnnotations]
2114
+ );
2115
+ const updateAnnotation = useCallback(
2116
+ (id, note) => {
2117
+ updateAnnotations(
2118
+ annotationsRef.current.map(
2119
+ (annotation) => annotation.id === id ? { ...annotation, note } : annotation
2120
+ )
2121
+ );
2122
+ },
2123
+ [updateAnnotations]
2124
+ );
2125
+ const removeAnnotation = useCallback(
2126
+ (id) => {
2127
+ updateAnnotations(annotationsRef.current.filter((annotation) => annotation.id !== id));
2128
+ },
2129
+ [updateAnnotations]
2130
+ );
2131
+ const clearAnnotationReviewTarget = useCallback(() => {
2132
+ setAnnotationReviewTargetId(null);
2133
+ }, []);
2134
+ const requestAnnotationReview = useCallback((id) => {
2135
+ const current = annotationsRef.current;
2136
+ if (current.length === 0) {
2137
+ setAnnotationReviewTargetId(null);
2138
+ return;
2139
+ }
2140
+ if (id && current.some((annotation) => annotation.id === id)) {
2141
+ setAnnotationReviewTargetId(id);
2142
+ return;
2143
+ }
2144
+ const incomplete = current.find((annotation) => annotation.note.trim().length === 0);
2145
+ setAnnotationReviewTargetId(incomplete?.id ?? current[0].id);
2146
+ }, []);
2147
+ const updatePolicy = useCallback(
2148
+ (next) => {
2149
+ if (targetKeyRef.current !== targetKey) return;
2150
+ localEditRevision.current += 1;
2151
+ policyRef.current = next;
2152
+ policyPickedRef.current = true;
2153
+ setPolicyPicked(policyPickedRef.current);
2154
+ const shadow = {
2155
+ text: valueRef.current,
2156
+ resources: mergeResources(
2157
+ restoredResourcesRef.current,
2158
+ resolveSendExtras(sendExtrasRef.current).resources ?? []
2159
+ ),
2160
+ annotations: annotationsRef.current,
2161
+ policy: next
2162
+ };
2163
+ pendingOperationRef.current = updatePendingComposerShadow(
2164
+ pendingOperationKey,
2165
+ pendingOperationRef.current,
2166
+ shadow
2167
+ );
2168
+ setOptimisticDraftShadow(shadow);
2169
+ setPolicy(next);
2170
+ },
2171
+ [pendingOperationKey, setOptimisticDraftShadow, targetKey]
2172
+ );
2173
+ const updateModel = useCallback(
2174
+ (model) => {
2175
+ const current = policyRef.current;
2176
+ if (current) updatePolicy({ ...current, model });
2177
+ },
2178
+ [updatePolicy]
2179
+ );
2180
+ const updateReasoningEffort = useCallback(
2181
+ (reasoningEffort) => {
2182
+ const current = policyRef.current;
2183
+ if (current) updatePolicy({ ...current, reasoningEffort });
2184
+ },
2185
+ [updatePolicy]
2186
+ );
2187
+ const updateLatencyMode = useCallback(
2188
+ (latencyMode) => {
2189
+ const current = policyRef.current;
2190
+ if (current) updatePolicy({ ...current, latencyMode });
2191
+ },
2192
+ [updatePolicy]
2193
+ );
2194
+ const removeRestoredResource = useCallback(
2195
+ (index) => {
2196
+ if (targetKeyRef.current !== targetKey) return;
2197
+ localEditRevision.current += 1;
2198
+ const next = restoredResourcesRef.current.filter((_, candidate) => candidate !== index);
2199
+ restoredResourcesRef.current = next;
2200
+ pendingOperationRef.current = updatePendingComposerShadow(
2201
+ pendingOperationKey,
2202
+ pendingOperationRef.current,
2203
+ {
2204
+ text: valueRef.current,
2205
+ resources: mergeResources(next, resolveSendExtras(sendExtrasRef.current).resources ?? []),
2206
+ annotations: annotationsRef.current,
2207
+ policy: pickedPolicy(policyPickedRef, policyRef)
2208
+ }
2209
+ );
2210
+ setOptimisticDraftShadow({
2211
+ text: valueRef.current,
2212
+ resources: mergeResources(next, resolveSendExtras(sendExtrasRef.current).resources ?? []),
2213
+ annotations: annotationsRef.current,
2214
+ policy: pickedPolicy(policyPickedRef, policyRef)
2215
+ });
2216
+ setRestoredResources(next);
2217
+ },
2218
+ [pendingOperationKey, setOptimisticDraftShadow, targetKey]
2219
+ );
2220
+ const hasDraftContent = useCallback(() => {
2221
+ const current = draftRef.current;
2222
+ const extras = resolveSendExtras(sendExtrasRef.current);
2223
+ return valueRef.current.length > 0 || annotationsRef.current.length > 0 || restoredResourcesRef.current.length > 0 || (extras.resources?.length ?? 0) > 0 || current?.sourceTurnId !== null && current?.sourceTurnId !== void 0;
2224
+ }, []);
2225
+ const restoreOptimisticMessage = useCallback(
2226
+ (clientEventId) => {
2227
+ if (targetKeyRef.current !== targetKey || draftLoading || pendingOperationRef.current || hasDraftContent())
2228
+ return;
2229
+ const operation = optimisticSendsRef.current.find(
2230
+ (candidate) => candidate.clientEventId === clientEventId
2231
+ );
2232
+ if (!operation || operation.state !== "failed" || operation.outcomeUnknown) return;
2233
+ localEditRevision.current += 1;
2234
+ valueRef.current = operation.text;
2235
+ restoredResourcesRef.current = [...operation.resources];
2236
+ annotationsRef.current = cloneAnnotations(operation.annotations);
2237
+ setValue(operation.text);
2238
+ setRestoredResources(restoredResourcesRef.current);
2239
+ setAnnotations(annotationsRef.current);
2240
+ setError(null);
2241
+ setOptimisticDraftShadow({
2242
+ text: operation.text,
2243
+ resources: restoredResourcesRef.current,
2244
+ annotations: annotationsRef.current,
2245
+ policy: pickedPolicy(policyPickedRef, policyRef)
2246
+ });
2247
+ replaceOptimisticSends(
2248
+ (current) => current.filter((candidate) => candidate.clientEventId !== clientEventId)
2249
+ );
2250
+ },
2251
+ [draftLoading, hasDraftContent, replaceOptimisticSends, setOptimisticDraftShadow, targetKey]
2252
+ );
2253
+ const resolveDraftConflict = useCallback(
2254
+ async (choice) => {
2255
+ const ownedTargetKey = targetKey;
2256
+ const ownedGeneration = targetGeneration.current;
2257
+ if (!sessionId || !durableDrafts || targetKeyRef.current !== ownedTargetKey) return;
2258
+ const remote = await client.getComposerDraft(workspaceId, sessionId);
2259
+ if (targetKeyRef.current !== ownedTargetKey || targetGeneration.current !== ownedGeneration) {
2260
+ return;
2261
+ }
2262
+ if (choice === "use_remote") {
2263
+ applyDraft(remote);
2264
+ setError(null);
2265
+ return;
2266
+ }
2267
+ draftRef.current = remote;
2268
+ setDraft(remote);
2269
+ setDraftConflict(null);
2270
+ setError(null);
2271
+ const payload = currentDraftPayload();
2272
+ if (payload) await persistPayload({ ...payload, expectedRevision: remote.revision });
2273
+ },
2274
+ [
2275
+ applyDraft,
2276
+ client,
2277
+ currentDraftPayload,
2278
+ durableDrafts,
2279
+ persistPayload,
2280
+ sessionId,
2281
+ targetKey,
2282
+ workspaceId
2283
+ ]
2284
+ );
2285
+ const identityMatches = stateTargetKey === targetKey;
2286
+ const visibleSteering = identityMatches ? steering : null;
2287
+ const visibleOptimisticMessages = identityMatches ? [
2288
+ ...optimisticSends.map(
2289
+ ({ input: _input, draftPayload: _payload, canRetry: _retry, ...item }) => item
2290
+ ),
2291
+ ...visibleSteering?.clientEventId ? [
2292
+ {
2293
+ clientEventId: visibleSteering.clientEventId,
2294
+ delivery: "steer",
2295
+ destination: "chat",
2296
+ text: visibleSteering.text,
2297
+ annotations: pendingOperationRef.current?.delivery === "steer" ? pendingOperationRef.current.annotationsAtSend : [],
2298
+ resources: pendingOperationRef.current?.delivery === "steer" ? pendingOperationRef.current.resourcesAtSend : [],
2299
+ occurredAt: steeringOccurredAtRef.current,
2300
+ state: visibleSteering.phase === "submitting" ? "sending" : visibleSteering.phase === "failed" ? "failed" : "queued",
2301
+ turnId: visibleSteering.turnId,
2302
+ triggerEventId: visibleSteering.triggerEventId,
2303
+ ...visibleSteering.error ? { error: visibleSteering.error } : {},
2304
+ ...visibleSteering.outcomeUnknown !== void 0 ? { outcomeUnknown: visibleSteering.outcomeUnknown } : {}
2305
+ }
2306
+ ] : []
2307
+ ] : [];
2308
+ const reloadDraft = useCallback(async () => await loadDraft(true), [loadDraft]);
2309
+ const clearError = useCallback(() => {
2310
+ if (targetKeyRef.current !== targetKey) return;
2311
+ setError(null);
2312
+ setDraftReadError(null);
2313
+ setDraftConflict(null);
2314
+ }, [targetKey]);
2315
+ const visibleValue = identityMatches ? valueRef.current : "";
2316
+ return {
2317
+ value: visibleValue,
2318
+ setValue: updateValue,
2319
+ annotations: identityMatches ? annotations : [],
2320
+ addAnnotation,
2321
+ updateAnnotation,
2322
+ removeAnnotation,
2323
+ annotationReviewTargetId: identityMatches ? annotationReviewTargetId : null,
2324
+ clearAnnotationReviewTarget,
2325
+ requestAnnotationReview,
2326
+ hasDraftContent,
2327
+ send,
2328
+ sendToQueue,
2329
+ busySend,
2330
+ singleSend,
2331
+ alternateSend: identityMatches ? alternateSend : null,
2332
+ working: identityMatches && takesBusyPath(),
2333
+ sendAlternate: singleSend ? void 0 : sendAlternate,
2334
+ optimisticMessages: visibleOptimisticMessages,
2335
+ retryOptimisticMessage,
2336
+ restoreOptimisticMessage: !draftLoading && !pendingOperationRef.current && !hasDraftContent() ? restoreOptimisticMessage : void 0,
2337
+ removeOptimisticMessage,
2338
+ steer,
2339
+ steering: visibleSteering,
2340
+ // Receipt-backed: an accepted Steer stops the previous attempt, and an
2341
+ // accepted Pause whose receipt still reports physical settlement stops the
2342
+ // current one. Once the authoritative control catches up, the queue
2343
+ // snapshot owns this projection.
2344
+ stoppingAttempt: identityMatches ? visibleSteering?.phase === "accepted" && visibleSteering.stoppingPreviousAttempt === true ? "previous" : pendingAcceptedControl?.state === "paused" && pendingAcceptedControl.settlement !== null ? "current" : null : null,
2345
+ sending: identityMatches ? sending : false,
2346
+ canSend: identityMatches && Boolean(sessionId) && !sending && !draftLoading && policy !== null && sendBlockedRef.current?.() !== true && annotationsComplete && (hasPendingOperation || visibleValue.trim().length > 0 || hasReadyResources || annotations.length > 0),
2347
+ // The saved draft is still loading, or its first read is being retried:
2348
+ // an early Send waits for it (the composer bounds how long).
2349
+ preparing: identityMatches ? Boolean(sessionId) && (draftLoading || draftHydrationRetrying) : Boolean(sessionId) && durableDrafts,
2350
+ pause,
2351
+ pausing: identityMatches ? pausing : false,
2352
+ resume,
2353
+ resumeScope,
2354
+ resuming: identityMatches ? resuming : false,
2355
+ effectiveControl: identityMatches ? effectiveControlRef.current : null,
2356
+ draft: identityMatches ? draft : null,
2357
+ draftRevision: identityMatches ? draft?.revision ?? 0 : 0,
2358
+ draftLoading: identityMatches ? draftLoading : Boolean(sessionId) && durableDrafts,
2359
+ draftSaving: identityMatches ? draftSaving : false,
2360
+ draftConflict: identityMatches ? draftConflict : null,
2361
+ flushDraft,
2362
+ policy: identityMatches ? policy : null,
2363
+ sendPolicy: identityMatches && policyPicked ? policy : null,
2364
+ setModel: updateModel,
2365
+ setReasoningEffort: updateReasoningEffort,
2366
+ setLatencyMode: updateLatencyMode,
2367
+ draftPersistence: durableDrafts ? "durable" : "disabled",
2368
+ applyDraft,
2369
+ reloadDraft,
2370
+ resolveDraftConflict,
2371
+ restoredResources: identityMatches ? restoredResources : [],
2372
+ removeRestoredResource,
2373
+ error: identityMatches ? error ?? draftReadError : null,
2374
+ clearError,
2375
+ canBuyCredits: options.canBuyCredits ?? true,
2376
+ reconnecting: identityMatches ? serviceWaiting : false
2377
+ };
2378
+ }
2379
+ function isComposerDraftEvent(event) {
2380
+ return event.type === "user.message" || event.type === "session.queue.changed" || // A following draft shows the chat's settings, which this event changes.
2381
+ event.type === "session.model_settings.updated";
2382
+ }
2383
+ var FILE_ONLY_MESSAGE_TEXT = (t) => t("hooks.useComposer.seeAttachedContext");
2384
+ function resolveSendExtras(extras) {
2385
+ return (typeof extras === "function" ? extras() : extras) ?? {};
2386
+ }
2387
+ function composeSendInput(text, clientEventId, extras, bound = {}) {
2388
+ return { ...resolveSendExtras(extras), ...bound, text, clientEventId };
2389
+ }
2390
+ function shouldSubmitOnKey(event) {
2391
+ if (event.key !== "Enter" || event.shiftKey) {
2392
+ return false;
2393
+ }
2394
+ return event.nativeEvent?.isComposing !== true;
2395
+ }
2396
+ function shouldSteerOnKey(event) {
2397
+ return event.metaKey === true || event.ctrlKey === true;
2398
+ }
2399
+ function generateClientEventId() {
2400
+ return globalThis.crypto.randomUUID();
2401
+ }
2402
+ function isOutcomeUnknownError(cause) {
2403
+ return typeof cause === "object" && cause !== null && cause.outcomeUnknown === true;
2404
+ }
2405
+ async function replayOutcomeUnknown(command) {
2406
+ try {
2407
+ return await command();
2408
+ } catch (cause) {
2409
+ if (!isOutcomeUnknownError(cause)) throw cause;
2410
+ return await command();
2411
+ }
2412
+ }
2413
+ function asError(cause) {
2414
+ return normalizeError(cause);
2415
+ }
2416
+ function promptRoutingFromAcceptedEvent(event) {
2417
+ if (typeof event?.payload !== "object" || event.payload === null || Array.isArray(event.payload)) {
2418
+ return null;
2419
+ }
2420
+ const routing = event.payload.routing;
2421
+ return routing === "accepted_for_execution" || routing === "queued_for_execution" || routing === "accepted_for_steering" ? routing : null;
2422
+ }
2423
+ function isDraftConflictError(error) {
2424
+ const apiError = error;
2425
+ return apiError.status === 409 && apiError.outcomeUnknown !== true && apiError.code === "DRAFT_CHANGED";
2426
+ }
2427
+ function draftPayload(draft) {
2428
+ return {
2429
+ expectedRevision: draft.revision,
2430
+ text: draft.text,
2431
+ resources: draft.resources,
2432
+ annotations: draft.annotations ?? [],
2433
+ // A draft that follows the chat's settings is saved without them.
2434
+ ...draft.policyFollowsSession ? {} : {
2435
+ model: draft.model,
2436
+ reasoningEffort: draft.reasoningEffort,
2437
+ latencyMode: draft.latencyMode
2438
+ }
2439
+ };
2440
+ }
2441
+ function policyFromDraft(draft) {
2442
+ return {
2443
+ model: draft.model,
2444
+ reasoningEffort: draft.reasoningEffort,
2445
+ latencyMode: draft.latencyMode
2446
+ };
2447
+ }
2448
+ function pickedPolicy(picked, policy) {
2449
+ return picked.current ? policy.current ?? void 0 : void 0;
2450
+ }
2451
+ function samePolicy(a, b) {
2452
+ return a !== null && a.model === b.model && a.reasoningEffort === b.reasoningEffort && a.latencyMode === b.latencyMode;
2453
+ }
2454
+ function composerDraftPayload(base, text, restoredResources, annotations, policy, additionalResources) {
2455
+ return {
2456
+ expectedRevision: base.revision,
2457
+ text,
2458
+ resources: mergeResources(restoredResources, additionalResources),
2459
+ annotations,
2460
+ ...policy ? {
2461
+ model: policy.model,
2462
+ reasoningEffort: policy.reasoningEffort,
2463
+ latencyMode: policy.latencyMode
2464
+ } : {}
2465
+ };
2466
+ }
2467
+ function draftSignature(payload) {
2468
+ const { expectedRevision: _revision, ...content } = payload;
2469
+ return JSON.stringify(content);
2470
+ }
2471
+ function mergeResources(base, additions) {
2472
+ const seen = /* @__PURE__ */ new Set();
2473
+ return [...base, ...additions].filter((resource) => {
2474
+ const key = resource.kind === "file" ? `file:${resource.fileId}\0${resource.mountPath ?? `${DEFAULT_FILE_RESOURCE_MOUNT_ROOT}/${resource.fileId}`}` : JSON.stringify(resource);
2475
+ if (seen.has(key)) return false;
2476
+ seen.add(key);
2477
+ return true;
2478
+ });
2479
+ }
2480
+
2481
+ // src/hooks/use-queued-prompt-recall.ts
2482
+ import { useCallback as useCallback2, useEffect as useEffect2, useMemo, useRef as useRef2 } from "react";
2483
+ var QUEUED_RECALL_SETTLE_TIMEOUT_MS = 1e4;
2484
+ function shouldRecallQueuedOnKey(event, field) {
2485
+ if (event.key !== "ArrowUp") return false;
2486
+ if (event.shiftKey || event.altKey || event.metaKey || event.ctrlKey) return false;
2487
+ if (event.nativeEvent?.isComposing === true) return false;
2488
+ if (event.keyCode === 229 || event.nativeEvent?.keyCode === 229) return false;
2489
+ if (field.popupOpen || field.hasOtherContent) return false;
2490
+ if (field.value.length > 0) return false;
2491
+ return (field.selectionStart ?? 0) === 0 && (field.selectionEnd ?? 0) === 0;
2492
+ }
2493
+ function latestRecallableQueuedTurn(turns, mutationFor, subjectId) {
2494
+ for (let index = turns.length - 1; index >= 0; index -= 1) {
2495
+ const turn = turns[index];
2496
+ if (turn.status !== "queued") continue;
2497
+ if (turn.source !== "user" && turn.source !== "api") continue;
2498
+ if (mutationFor(turn.id) !== null) continue;
2499
+ if (turn.personalResources?.mode === "once") continue;
2500
+ if (subjectId && turn.initiator?.subjectId !== subjectId) continue;
2501
+ return turn;
2502
+ }
2503
+ return null;
2504
+ }
2505
+ function hasQueuedSendInFlight(messages, queuedTurnIds, queueVersion) {
2506
+ return (messages ?? []).some(
2507
+ (message) => isQueuedSendInFlight(message, queuedTurnIds, queueVersion)
2508
+ );
2509
+ }
2510
+ function isQueuedSendInFlight(message, queuedTurnIds, queueVersion) {
2511
+ return message.delivery === "send" && message.destination === "queue" && message.state !== "failed" && (!message.turnId || !queuedTurnIds.has(message.turnId)) && !(message.turnId && message.appliedQueueVersion != null && queueVersion != null && queueVersion >= message.appliedQueueVersion);
2512
+ }
2513
+ function useQueuedPromptRecall({
2514
+ queue,
2515
+ composer,
2516
+ subjectId,
2517
+ enabled = true
2518
+ }) {
2519
+ const candidate = latestRecallableQueuedTurn(queue.queue, queue.mutationFor, subjectId);
2520
+ const settling = composer ? recallSettling(composer, queue) : false;
2521
+ const queueSendInFlight = composer ? hasQueuedSendInFlight(
2522
+ composer.optimisticMessages,
2523
+ new Set(queue.queue.map((turn) => turn.id)),
2524
+ queue.snapshot?.version
2525
+ ) : false;
2526
+ const live = useRef2({ queue, composer, subjectId });
2527
+ live.current = { queue, composer, subjectId };
2528
+ const settleWaiters = useRef2(/* @__PURE__ */ new Set());
2529
+ useEffect2(() => {
2530
+ for (const waiter of [...settleWaiters.current]) waiter.check();
2531
+ });
2532
+ useEffect2(() => {
2533
+ const waiters = settleWaiters.current;
2534
+ return () => {
2535
+ for (const waiter of [...waiters]) waiter.cancel();
2536
+ };
2537
+ }, []);
2538
+ const supported = enabled && composer !== void 0 && composer.draftPersistence !== "disabled" && queue.recallTurn !== void 0;
2539
+ const recall = useCallback2(async () => {
2540
+ let current = live.current;
2541
+ let target = current.composer;
2542
+ if (!target || target.draftPersistence === "disabled" || !current.queue.recallTurn) {
2543
+ return "unavailable";
2544
+ }
2545
+ if (target.draftLoading || target.hasDraftContent()) return "unavailable";
2546
+ let queued = current.queue.queue;
2547
+ const tracked = inFlightQueueSends(target, current.queue);
2548
+ if (tracked.size > 0) {
2549
+ const settled = await waitForTrackedSends(settleWaiters.current, live, tracked);
2550
+ if (!settled) return "unavailable";
2551
+ current = live.current;
2552
+ target = current.composer;
2553
+ if (!target || target.draftPersistence === "disabled") return "unavailable";
2554
+ if (target.draftLoading || target.hasDraftContent()) return "unavailable";
2555
+ const trackedTurnIds = new Set(
2556
+ [...tracked.values()].filter((turnId) => turnId !== null)
2557
+ );
2558
+ queued = current.queue.queue.filter((turn2) => trackedTurnIds.has(turn2.id));
2559
+ if (latestRecallableQueuedTurn(queued, current.queue.mutationFor, current.subjectId) === null) {
2560
+ const waitingIds = new Set(current.queue.queue.map((turn2) => turn2.id));
2561
+ return [...trackedTurnIds].some((turnId) => !waitingIds.has(turnId)) ? "already_sent" : "unavailable";
2562
+ }
2563
+ } else if (recallSettling(target, current.queue)) {
2564
+ return "unavailable";
2565
+ }
2566
+ const recallTurn = current.queue.recallTurn;
2567
+ if (!recallTurn) return "unavailable";
2568
+ const turn = latestRecallableQueuedTurn(queued, current.queue.mutationFor, current.subjectId);
2569
+ if (!turn) return "unavailable";
2570
+ const result = await recallTurn(turn.id, { expectedDraftRevision: target.draftRevision });
2571
+ if (result.status === "recalled") {
2572
+ const latest = live.current.composer ?? target;
2573
+ const typedMeanwhile = latest.value;
2574
+ latest.applyDraft(result.draft);
2575
+ if (typedMeanwhile.length > 0) {
2576
+ latest.setValue(
2577
+ result.draft.text.length > 0 ? `${result.draft.text}
2578
+ ${typedMeanwhile}` : typedMeanwhile
2579
+ );
2580
+ }
2581
+ return "recalled";
2582
+ }
2583
+ return result.status === "already_sent" ? "already_sent" : "unavailable";
2584
+ }, []);
2585
+ return useMemo(
2586
+ () => supported ? {
2587
+ // The row already shows a send on its way as queued, so Up is
2588
+ // taken now and `recall` waits for it to land.
2589
+ available: candidate !== null && !settling || queueSendInFlight,
2590
+ turnId: settling ? null : candidate?.id ?? null,
2591
+ recall
2592
+ } : void 0,
2593
+ [candidate, queueSendInFlight, recall, settling, supported]
2594
+ );
2595
+ }
2596
+ function recallSettling(composer, queue) {
2597
+ if (composer.sending) return true;
2598
+ if (!composer.optimisticMessages?.length) return false;
2599
+ return hasQueuedSendInFlight(
2600
+ composer.optimisticMessages,
2601
+ new Set(queue.queue.map((turn) => turn.id)),
2602
+ queue.snapshot?.version
2603
+ );
2604
+ }
2605
+ function inFlightQueueSends(composer, queue) {
2606
+ const queuedTurnIds = new Set(queue.queue.map((turn) => turn.id));
2607
+ return new Map(
2608
+ (composer.optimisticMessages ?? []).filter((message) => isQueuedSendInFlight(message, queuedTurnIds, queue.snapshot?.version)).map((message) => [message.clientEventId, message.turnId ?? null])
2609
+ );
2610
+ }
2611
+ function waitForTrackedSends(waiters, live, tracked) {
2612
+ const known = new Set(
2613
+ (live.current.composer?.optimisticMessages ?? []).map((message) => message.clientEventId)
2614
+ );
2615
+ return new Promise((resolve) => {
2616
+ const finish = (settled) => {
2617
+ clearTimeout(timer);
2618
+ waiters.delete(waiter);
2619
+ resolve(settled);
2620
+ };
2621
+ const waiter = {
2622
+ cancel: () => finish(false),
2623
+ check: () => {
2624
+ const { composer, queue } = live.current;
2625
+ if (!composer || composer.hasDraftContent()) return finish(false);
2626
+ const messages = composer.optimisticMessages ?? [];
2627
+ if (messages.some((message) => !known.has(message.clientEventId))) return finish(false);
2628
+ const queuedTurnIds = new Set(queue.queue.map((turn) => turn.id));
2629
+ let pending = false;
2630
+ for (const clientEventId of tracked.keys()) {
2631
+ const message = messages.find((candidate) => candidate.clientEventId === clientEventId);
2632
+ if (message?.turnId) tracked.set(clientEventId, message.turnId);
2633
+ if (message && isQueuedSendInFlight(message, queuedTurnIds, queue.snapshot?.version)) {
2634
+ pending = true;
2635
+ }
2636
+ }
2637
+ if (!pending) finish(true);
2638
+ }
2639
+ };
2640
+ const timer = setTimeout(() => finish(false), QUEUED_RECALL_SETTLE_TIMEOUT_MS);
2641
+ waiters.add(waiter);
2642
+ });
2643
+ }
2644
+
2645
+ export {
2646
+ notifyObserver,
2647
+ useComposer,
2648
+ FILE_ONLY_MESSAGE_TEXT,
2649
+ composeSendInput,
2650
+ shouldSubmitOnKey,
2651
+ shouldSteerOnKey,
2652
+ shouldRecallQueuedOnKey,
2653
+ latestRecallableQueuedTurn,
2654
+ useQueuedPromptRecall
2655
+ };
2656
+ //# sourceMappingURL=chunk-MIHN76LX.js.map