@opengeni/react 6.35.1-canary.45058281793001 → 6.36.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 (1124) hide show
  1. package/dist/app/app-state.js +34 -34
  2. package/dist/app/components/Composer.js +43 -43
  3. package/dist/app/components/add-card-dialog.js +1 -1
  4. package/dist/app/components/add-card.js +2 -2
  5. package/dist/app/components/agent/agent-capability-picker.js +9 -9
  6. package/dist/app/components/agents/agent-can-use.js +47 -47
  7. package/dist/app/components/agents/agent-form-page.js +140 -140
  8. package/dist/app/components/agents/agent-page.js +123 -123
  9. package/dist/app/components/agents/agent-setup-sections.js +74 -74
  10. package/dist/app/components/agents/agent-skills.js +13 -13
  11. package/dist/app/components/agents/agent-trigger-chat-field.js +6 -6
  12. package/dist/app/components/agents/agent-trigger-dialog.js +31 -31
  13. package/dist/app/components/agents/agent-trigger-picker.js +8 -8
  14. package/dist/app/components/agents/agents-page.js +90 -90
  15. package/dist/app/components/agents/composer-agent-chip.js +59 -59
  16. package/dist/app/components/agents/session-agent-chip.js +54 -54
  17. package/dist/app/components/artifacts/app-package.js +10 -10
  18. package/dist/app/components/artifacts/artifact-browse-controls.js +3 -3
  19. package/dist/app/components/artifacts/artifact-library.js +28 -28
  20. package/dist/app/components/artifacts/artifact-page-chrome.js +1 -1
  21. package/dist/app/components/artifacts/artifact-viewer.js +68 -68
  22. package/dist/app/components/artifacts/chat-interactive-block.js +27 -27
  23. package/dist/app/components/artifacts/copy-artifact-link.js +1 -1
  24. package/dist/app/components/artifacts/file-reach-dialog.js +11 -11
  25. package/dist/app/components/artifacts/inline-chat-image.js +51 -51
  26. package/dist/app/components/artifacts/retained-file-preview.js +57 -57
  27. package/dist/app/components/artifacts/retained-text-preview.js +8 -8
  28. package/dist/app/components/artifacts/site-actions.js +11 -11
  29. package/dist/app/components/artifacts/site-audience.js +7 -7
  30. package/dist/app/components/artifacts/site-conversations.js +33 -33
  31. package/dist/app/components/artifacts/site-data.js +28 -28
  32. package/dist/app/components/artifacts/site-public-link.js +3 -3
  33. package/dist/app/components/artifacts/site-publishing-page.js +66 -66
  34. package/dist/app/components/artifacts/site-publishing.js +51 -51
  35. package/dist/app/components/artifacts/site-settings.js +65 -65
  36. package/dist/app/components/artifacts/site-version-menu.js +9 -9
  37. package/dist/app/components/billing-class-mark.js +8 -8
  38. package/dist/app/components/capabilities/capability-detail-sheet.js +18 -18
  39. package/dist/app/components/capabilities/capability-logo-source.js +27 -27
  40. package/dist/app/components/capabilities/capability-logo.js +1 -1
  41. package/dist/app/components/capabilities/connection-account-picker.js +2 -2
  42. package/dist/app/components/capabilities/connector-tool-permissions.js +8 -8
  43. package/dist/app/components/capabilities/native-connect-setup.js +31 -31
  44. package/dist/app/components/capabilities/own-logins-shared-heads-up.js +6 -6
  45. package/dist/app/components/capabilities/perform-capability-action.js +2 -2
  46. package/dist/app/components/capabilities/prepared-mcp-setup-card.js +30 -30
  47. package/dist/app/components/capabilities/session-capability-card.js +142 -142
  48. package/dist/app/components/capabilities/session-chrome-card.js +49 -49
  49. package/dist/app/components/capabilities/session-connect-inputs-card.js +33 -33
  50. package/dist/app/components/capabilities/session-custom-mcp-card.js +37 -37
  51. package/dist/app/components/capabilities/session-github-card.js +46 -46
  52. package/dist/app/components/capabilities/session-machine-card.js +50 -50
  53. package/dist/app/components/capabilities/session-personal-github-card.js +31 -31
  54. package/dist/app/components/capabilities/session-plugin-card.js +20 -20
  55. package/dist/app/components/capabilities/use-capabilities-catalog.js +3 -3
  56. package/dist/app/components/capabilities/use-connection-accounts.js +2 -2
  57. package/dist/app/components/chat-payment-pages.js +2 -2
  58. package/dist/app/components/command-menu/chat-status.js +25 -25
  59. package/dist/app/components/command-menu/chat-switcher.js +84 -84
  60. package/dist/app/components/command-menu/command-menu.js +113 -113
  61. package/dist/app/components/command-menu/shortcut-sheet.js +25 -25
  62. package/dist/app/components/composer-capabilities-menu-body.js +6 -6
  63. package/dist/app/components/composer-mobile-plus-panel.js +31 -31
  64. package/dist/app/components/composer-mobile-plus.js +3 -3
  65. package/dist/app/components/credit-required-gate.js +6 -6
  66. package/dist/app/components/credit-required-prompt.js +19 -19
  67. package/dist/app/components/credits/checkout-credits-celebration.js +1 -1
  68. package/dist/app/components/credits/checkout-return.js +1 -1
  69. package/dist/app/components/credits/coupon-redeem.js +1 -1
  70. package/dist/app/components/credits/credit-refusal-notice.js +7 -7
  71. package/dist/app/components/credits/own-subscription-plan-notice.js +3 -3
  72. package/dist/app/components/desktop/app-shots.js +9 -9
  73. package/dist/app/components/desktop/app-update.js +3 -3
  74. package/dist/app/components/desktop/computer-use.js +3 -3
  75. package/dist/app/components/desktop/this-computer.js +6 -6
  76. package/dist/app/components/feedback.js +10 -10
  77. package/dist/app/components/follow-up-repository-menu-body.js +14 -14
  78. package/dist/app/components/follow-up-repository-picker.js +1 -1
  79. package/dist/app/components/github-app-connect-launcher.js +2 -2
  80. package/dist/app/components/in-app-help-link.js +3 -3
  81. package/dist/app/components/knowledge/agent-learning-settings.js +3 -3
  82. package/dist/app/components/machines/connect-machine-dialog.js +25 -25
  83. package/dist/app/components/manual-repository-editor.js +4 -4
  84. package/dist/app/components/markdown.js +15 -15
  85. package/dist/app/components/model-identity.js +3 -3
  86. package/dist/app/components/models/models-ui.js +16 -16
  87. package/dist/app/components/models/provider-mark.js +3 -3
  88. package/dist/app/components/models/subscription-usage.js +5 -5
  89. package/dist/app/components/my-things.js +16 -16
  90. package/dist/app/components/own-where-it-works.js +10 -10
  91. package/dist/app/components/personal-resource-attachment-surface.js +4 -4
  92. package/dist/app/components/pickers.js +11 -11
  93. package/dist/app/components/rail/channel-create-dialog.js +5 -5
  94. package/dist/app/components/rail/project-glyph.js +52 -52
  95. package/dist/app/components/rail/project-profile.js +74 -74
  96. package/dist/app/components/rail/rail-context.js +2 -2
  97. package/dist/app/components/rail/rail-sections.js +157 -157
  98. package/dist/app/components/rail/session-header.js +128 -128
  99. package/dist/app/components/rail/session-list.js +155 -155
  100. package/dist/app/components/rail/session-row-content.js +7 -7
  101. package/dist/app/components/rail/session-row-hover-details.js +34 -34
  102. package/dist/app/components/rail/session-shell.js +196 -196
  103. package/dist/app/components/rail/site-session-group-heading.js +37 -37
  104. package/dist/app/components/repository-picker.js +14 -14
  105. package/dist/app/components/repository-ref-input.js +2 -2
  106. package/dist/app/components/secrets/session-secrets-panel.js +4 -4
  107. package/dist/app/components/session/agent-configuration-panel.js +46 -46
  108. package/dist/app/components/session/artifact-session-page.js +6 -6
  109. package/dist/app/components/session/banners.js +19 -19
  110. package/dist/app/components/session/chat-avatar.js +52 -52
  111. package/dist/app/components/session/console-new-conversation.js +109 -109
  112. package/dist/app/components/session/conversation-find.js +3 -3
  113. package/dist/app/components/session/descendant-requests.js +109 -109
  114. package/dist/app/components/session/editable-artifacts-workspace.js +59 -59
  115. package/dist/app/components/session/failed-session-banner.js +22 -22
  116. package/dist/app/components/session/failure-recovery-boundary.js +3 -3
  117. package/dist/app/components/session/human-input-delegation-record.js +3 -3
  118. package/dist/app/components/session/human-input.js +87 -87
  119. package/dist/app/components/session/inspector.js +143 -143
  120. package/dist/app/components/session/linked-panel.js +3 -3
  121. package/dist/app/components/session/message-actions.js +10 -10
  122. package/dist/app/components/session/model-recovery-notice.js +4 -4
  123. package/dist/app/components/session/new-session-settings-menu.js +30 -30
  124. package/dist/app/components/session/new-session-setup-strip.js +55 -55
  125. package/dist/app/components/session/pull-request-panel.js +24 -24
  126. package/dist/app/components/session/sandbox-recovery-actions.js +3 -3
  127. package/dist/app/components/session/sandbox-switcher.js +23 -23
  128. package/dist/app/components/session/sandbox-workspace.js +119 -119
  129. package/dist/app/components/session/search-markdown-highlight.js +16 -16
  130. package/dist/app/components/session/search-results-view.js +17 -17
  131. package/dist/app/components/session/session-admin-access.js +11 -11
  132. package/dist/app/components/session/session-admission-notice.js +11 -11
  133. package/dist/app/components/session/session-avatar-picker.js +59 -59
  134. package/dist/app/components/session/session-avatar.js +54 -54
  135. package/dist/app/components/session/session-machine-access-notice.js +11 -11
  136. package/dist/app/components/session/session-profile-dialog.js +70 -70
  137. package/dist/app/components/session/session-profile-editor.js +71 -71
  138. package/dist/app/components/session/session-retention.js +7 -7
  139. package/dist/app/components/session/session-search-dialog.js +22 -22
  140. package/dist/app/components/session/session-skill-reviews.js +5 -5
  141. package/dist/app/components/session/session-tenancy-control.js +27 -27
  142. package/dist/app/components/session/session-unattended-setting.js +3 -3
  143. package/dist/app/components/session/session-usage-limit-section.js +14 -14
  144. package/dist/app/components/session/share-chat-dialog.js +9 -9
  145. package/dist/app/components/session/subagents.js +23 -23
  146. package/dist/app/components/session/subscription-account-indicator.js +25 -25
  147. package/dist/app/components/session/subscription-account-menu.js +7 -7
  148. package/dist/app/components/session-connectors-menu-body.js +7 -7
  149. package/dist/app/components/settings/row-select.js +6 -6
  150. package/dist/app/components/toaster.js +2 -2
  151. package/dist/app/components/transcription-settings.js +10 -10
  152. package/dist/app/components/ui/destructive-confirm.js +9 -9
  153. package/dist/app/components/usage/usage-entry.js +8 -8
  154. package/dist/app/components/window-bar.js +26 -26
  155. package/dist/app/components/workspace-composer-plus.js +41 -41
  156. package/dist/app/components/workspace-reach.js +6 -6
  157. package/dist/app/embed/session-app.js +406 -406
  158. package/dist/app/lib/actions/actions-provider.js +20 -20
  159. package/dist/app/lib/agent-capabilities.js +4 -4
  160. package/dist/app/lib/app-connect-card.js +14 -14
  161. package/dist/app/lib/app-shared-key-dialog.js +8 -8
  162. package/dist/app/lib/app-surfaces.js +1 -1
  163. package/dist/app/lib/app-sync-opt-in.js +4 -4
  164. package/dist/app/lib/codex-usage-query.js +3 -3
  165. package/dist/app/lib/composer-agent.js +2 -2
  166. package/dist/app/lib/composer-connectors.js +31 -31
  167. package/dist/app/lib/composer-send-blocking.js +3 -3
  168. package/dist/app/lib/console-site.js +6 -6
  169. package/dist/app/lib/console-text.js +2 -2
  170. package/dist/app/lib/deployment-free-model.js +2 -2
  171. package/dist/app/lib/events.js +29 -29
  172. package/dist/app/lib/failed-session-copy.js +6 -6
  173. package/dist/app/lib/feedback-capture.js +2 -2
  174. package/dist/app/lib/free-credit-gap.js +2 -2
  175. package/dist/app/lib/model-access-onboarding.js +5 -5
  176. package/dist/app/lib/model-policy.js +1 -1
  177. package/dist/app/lib/move-chat-to-machine.js +5 -5
  178. package/dist/app/lib/personal-resource-attachments.js +1 -1
  179. package/dist/app/lib/session-branch-cache.js +18 -18
  180. package/dist/app/lib/session-create.js +5 -5
  181. package/dist/app/lib/session-group-pagination.js +18 -18
  182. package/dist/app/lib/session-hover-facts.js +25 -25
  183. package/dist/app/lib/session-list-dirty-scopes.js +19 -19
  184. package/dist/app/lib/session-model.js +3 -3
  185. package/dist/app/lib/session-rail.js +16 -16
  186. package/dist/app/lib/session-rename.js +4 -4
  187. package/dist/app/lib/sessions-group.js +22 -22
  188. package/dist/app/lib/site-tool-consent-dialog.js +23 -23
  189. package/dist/app/lib/site-tool-consent.js +1 -1
  190. package/dist/app/lib/turn-failure-analytics.js +7 -7
  191. package/dist/app/lib/unavailable-session-model.js +2 -2
  192. package/dist/app/lib/use-artifact-catalog.js +2 -2
  193. package/dist/app/lib/use-duplicate-site.js +4 -4
  194. package/dist/app/lib/use-follow-up-repositories.js +6 -6
  195. package/dist/app/lib/use-personal-resource-attachment.js +2 -2
  196. package/dist/app/lib/use-workspace-machines.js +10 -10
  197. package/dist/app/lib/use-workspace-model-catalog.js +6 -6
  198. package/dist/app/lib/use-workspace-rigs.js +7 -7
  199. package/dist/app/lib/workspace-navigation-preference.js +5 -5
  200. package/dist/app/lib/workspace-scope-context.js +4 -4
  201. package/dist/app/routes/app-page-view.js +17 -17
  202. package/dist/app/routes/app-page.js +2 -2
  203. package/dist/app/routes/artifacts.js +158 -158
  204. package/dist/app/routes/retained-artifact.js +114 -114
  205. package/dist/app/routes/session-unavailable.js +5 -5
  206. package/dist/app/routes/session.js +247 -247
  207. package/dist/app/routes/sessions-index-hydration.js +6 -6
  208. package/dist/app/routes/sessions-index.js +203 -203
  209. package/dist/app/routes/site-view.js +200 -200
  210. package/dist/artifacts-document.js +4 -4
  211. package/dist/artifacts-presentation.js +7 -7
  212. package/dist/artifacts-spreadsheet.js +4 -4
  213. package/dist/artifacts.js +50 -50
  214. package/dist/automation-model.js +7 -7
  215. package/dist/automations.js +67 -67
  216. package/dist/browser-viewer-EIEMRVFF.js +23 -0
  217. package/dist/chat-interactive-block-FV37LWYZ.js +22 -0
  218. package/dist/chunk-2COBAJC7.js +818 -0
  219. package/dist/chunk-2HS3IUXE.js +170 -0
  220. package/dist/chunk-2JTMFYCT.js +296 -0
  221. package/dist/chunk-2JXKP4M6.js +114 -0
  222. package/dist/chunk-2P5K7CBH.js +269 -0
  223. package/dist/chunk-2XGRHMRI.js +250 -0
  224. package/dist/chunk-332BYSAZ.js +65 -0
  225. package/dist/chunk-3EM5GTP3.js +158 -0
  226. package/dist/chunk-3L5ATO4A.js +52 -0
  227. package/dist/chunk-3S3PJB7J.js +107 -0
  228. package/dist/chunk-3SBKYPNM.js +270 -0
  229. package/dist/chunk-3Z7VA6ET.js +114 -0
  230. package/dist/chunk-43BRJBEV.js +207 -0
  231. package/dist/chunk-46LZO4ZO.js +188 -0
  232. package/dist/chunk-46ZC5VNC.js +38 -0
  233. package/dist/chunk-4AH4EEHE.js +298 -0
  234. package/dist/chunk-4D3YJNVN.js +270 -0
  235. package/dist/chunk-4E5QVAT4.js +4480 -0
  236. package/dist/chunk-4E5QVAT4.js.map +1 -0
  237. package/dist/chunk-4I4RTI4D.js +37 -0
  238. package/dist/chunk-4KASGJTF.js +287 -0
  239. package/dist/chunk-4RUKLIOF.js +1263 -0
  240. package/dist/chunk-4UU7FN3I.js +650 -0
  241. package/dist/chunk-4VEIBNC2.js +427 -0
  242. package/dist/chunk-4VEIBNC2.js.map +1 -0
  243. package/dist/chunk-4ZRNASBF.js +2551 -0
  244. package/dist/chunk-5EJBPQI2.js +41 -0
  245. package/dist/chunk-5G4IGG7F.js +209 -0
  246. package/dist/chunk-5JAYZOAW.js +131 -0
  247. package/dist/chunk-5JOKVDSR.js +789 -0
  248. package/dist/chunk-5MP3G7ZV.js +1236 -0
  249. package/dist/chunk-5OVRMKP5.js +42 -0
  250. package/dist/chunk-5SGTRULO.js +1184 -0
  251. package/dist/chunk-5SOL4INY.js +572 -0
  252. package/dist/chunk-5Y34P32B.js +27 -0
  253. package/dist/chunk-62HIKJ5F.js +72 -0
  254. package/dist/chunk-62T2ZPD5.js +266 -0
  255. package/dist/chunk-63VNZRLY.js +386 -0
  256. package/dist/chunk-6CDBX3XG.js +33 -0
  257. package/dist/chunk-6D3D2JWY.js +278 -0
  258. package/dist/chunk-6DOIINY4.js +201 -0
  259. package/dist/chunk-6DQBUKGJ.js +112 -0
  260. package/dist/chunk-6SETNFNH.js +1399 -0
  261. package/dist/chunk-6XYFMHNT.js +56 -0
  262. package/dist/chunk-6YU3WV2P.js +33 -0
  263. package/dist/chunk-6YUHDFOZ.js +351 -0
  264. package/dist/chunk-72EOXOR7.js +1185 -0
  265. package/dist/chunk-72ND4ALI.js +532 -0
  266. package/dist/chunk-757LE32E.js +283 -0
  267. package/dist/chunk-7FDEV6XW.js +89 -0
  268. package/dist/chunk-7S2S4MXR.js +138 -0
  269. package/dist/chunk-7SYCHMXS.js +200 -0
  270. package/dist/chunk-7TVAPQOV.js +5089 -0
  271. package/dist/chunk-7UDLRDHK.js +214 -0
  272. package/dist/chunk-7YLQCMZP.js +357 -0
  273. package/dist/chunk-A5GX3CAE.js +849 -0
  274. package/dist/chunk-A7EBV2EB.js +318 -0
  275. package/dist/chunk-AB5SPXUR.js +114 -0
  276. package/dist/chunk-AHVQGL5A.js +202 -0
  277. package/dist/chunk-AI77ZKEV.js +26 -0
  278. package/dist/chunk-AIX2D6RB.js +1019 -0
  279. package/dist/chunk-AVSIHP7Q.js +192 -0
  280. package/dist/chunk-AWK23Q32.js +107 -0
  281. package/dist/chunk-AYVWA6KD.js +432 -0
  282. package/dist/chunk-AYZXE4IM.js +2553 -0
  283. package/dist/chunk-AZGGSPTE.js +124 -0
  284. package/dist/chunk-B45TB4HY.js +931 -0
  285. package/dist/chunk-BIUJHNVR.js +46 -0
  286. package/dist/chunk-BJUOKUE5.js +234 -0
  287. package/dist/chunk-BPEEVMKH.js +292 -0
  288. package/dist/chunk-BPHPAGYF.js +74 -0
  289. package/dist/chunk-BXMND6YU.js +307 -0
  290. package/dist/chunk-C6OM2SRG.js +117 -0
  291. package/dist/chunk-CIRCUDKF.js +1309 -0
  292. package/dist/chunk-CLKR4UG3.js +403 -0
  293. package/dist/chunk-CPX6BHER.js +554 -0
  294. package/dist/chunk-CVC4RO7D.js +155 -0
  295. package/dist/chunk-D3YJAQGK.js +103 -0
  296. package/dist/chunk-DFQ72BLS.js +1024 -0
  297. package/dist/chunk-DG65PJOZ.js +4564 -0
  298. package/dist/chunk-DNAXAS5R.js +406 -0
  299. package/dist/chunk-DO247ITS.js +175 -0
  300. package/dist/chunk-DONBARLL.js +154 -0
  301. package/dist/chunk-DTLXQ3ZU.js +373 -0
  302. package/dist/chunk-EAXTACI4.js +274 -0
  303. package/dist/chunk-EDPH7AJH.js +412 -0
  304. package/dist/chunk-EER3B3G5.js +10036 -0
  305. package/dist/chunk-EER3B3G5.js.map +1 -0
  306. package/dist/chunk-EFKQHCGJ.js +276 -0
  307. package/dist/chunk-EILSPMVD.js +133 -0
  308. package/dist/chunk-EK7KIETS.js +211 -0
  309. package/dist/chunk-EMWT6GOK.js +437 -0
  310. package/dist/chunk-EO22NST7.js +259 -0
  311. package/dist/chunk-ER5MYLIE.js +256 -0
  312. package/dist/chunk-ES5HKVQF.js +234 -0
  313. package/dist/chunk-EXRQ5ATC.js +738 -0
  314. package/dist/chunk-EXRQ5ATC.js.map +1 -0
  315. package/dist/chunk-F26YBYAZ.js +111 -0
  316. package/dist/chunk-F6QP4GSK.js +515 -0
  317. package/dist/chunk-F7QEO7M2.js +851 -0
  318. package/dist/chunk-FJFGDLXB.js +12 -0
  319. package/dist/chunk-FLLJ2WXW.js +113 -0
  320. package/dist/chunk-FMBJKMT4.js +107 -0
  321. package/dist/chunk-FPN4I4CG.js +3690 -0
  322. package/dist/chunk-FUXFJTXL.js +3070 -0
  323. package/dist/chunk-FZI4QOAV.js +3996 -0
  324. package/dist/chunk-FZI4QOAV.js.map +1 -0
  325. package/dist/chunk-G6SSSX5R.js +158 -0
  326. package/dist/chunk-GBGCMHBB.js +608 -0
  327. package/dist/chunk-GIHE7U3Y.js +174 -0
  328. package/dist/chunk-GJ4GTYOD.js +372 -0
  329. package/dist/chunk-GLSDWNFV.js +432 -0
  330. package/dist/chunk-GMGAW3T6.js +278 -0
  331. package/dist/chunk-GNGI6XFN.js +43 -0
  332. package/dist/chunk-GO5VIAA7.js +264 -0
  333. package/dist/chunk-GSW4YHZE.js +229 -0
  334. package/dist/chunk-GUC6IWEY.js +407 -0
  335. package/dist/chunk-GWAY3SO5.js +15 -0
  336. package/dist/chunk-GXOTNT5D.js +168 -0
  337. package/dist/chunk-GZZCVF76.js +3851 -0
  338. package/dist/chunk-H4VMHFOX.js +214 -0
  339. package/dist/chunk-HA5RFQAF.js +110 -0
  340. package/dist/chunk-HFROJDFQ.js +118 -0
  341. package/dist/chunk-HHFFPE67.js +220 -0
  342. package/dist/chunk-HJLHGXWL.js +103 -0
  343. package/dist/chunk-HKNMNL7B.js +2984 -0
  344. package/dist/chunk-HT7MBHLY.js +1021 -0
  345. package/dist/chunk-I5FSUZVW.js +584 -0
  346. package/dist/chunk-IINQO425.js +246 -0
  347. package/dist/chunk-IIXNEOK4.js +1022 -0
  348. package/dist/chunk-IM3WA5AL.js +311 -0
  349. package/dist/chunk-IX4P4OGR.js +399 -0
  350. package/dist/chunk-IX5VHZYS.js +129 -0
  351. package/dist/chunk-JB3TSUZO.js +263 -0
  352. package/dist/chunk-JIC6RLUB.js +27 -0
  353. package/dist/chunk-JNJIZCTN.js +172 -0
  354. package/dist/chunk-JNV5ZPUV.js +828 -0
  355. package/dist/chunk-JPQFVR24.js +50 -0
  356. package/dist/chunk-JPZVMXDP.js +1333 -0
  357. package/dist/chunk-JVPF34MX.js +215 -0
  358. package/dist/chunk-KED67KAF.js +85 -0
  359. package/dist/chunk-KJ72GMZ2.js +378 -0
  360. package/dist/chunk-KTGKGHEA.js +75 -0
  361. package/dist/chunk-KU77XHWB.js +285 -0
  362. package/dist/chunk-KVPQUADA.js +5915 -0
  363. package/dist/chunk-KVPQUADA.js.map +1 -0
  364. package/dist/chunk-KXBLLFOO.js +249 -0
  365. package/dist/chunk-L6WVCO6D.js +61 -0
  366. package/dist/chunk-LIOZ2MXJ.js +380 -0
  367. package/dist/chunk-LIOZ2MXJ.js.map +1 -0
  368. package/dist/chunk-LPEFULJY.js +73 -0
  369. package/dist/chunk-LRMGPO7E.js +98 -0
  370. package/dist/chunk-LVKTKORH.js +121 -0
  371. package/dist/chunk-MCPKUVMQ.js +99 -0
  372. package/dist/chunk-MFLU3466.js +99 -0
  373. package/dist/chunk-MIUJ3EH5.js +60 -0
  374. package/dist/chunk-MIUMNTIJ.js +175 -0
  375. package/dist/chunk-ML46TXRM.js +113 -0
  376. package/dist/chunk-MO3XJQN2.js +629 -0
  377. package/dist/chunk-MQRHTOQ2.js +218 -0
  378. package/dist/chunk-MVYQDBE6.js +79 -0
  379. package/dist/chunk-NE5P7LFQ.js +100 -0
  380. package/dist/chunk-NIPON7YB.js +850 -0
  381. package/dist/chunk-NIPON7YB.js.map +1 -0
  382. package/dist/chunk-NPBEUU22.js +196 -0
  383. package/dist/chunk-NSXKGS2K.js +178 -0
  384. package/dist/chunk-NUEFORM6.js +2317 -0
  385. package/dist/chunk-NZOFNQNC.js +176 -0
  386. package/dist/chunk-O664PL2U.js +47 -0
  387. package/dist/chunk-O664PL2U.js.map +1 -0
  388. package/dist/chunk-OATXCLTY.js +211 -0
  389. package/dist/chunk-OG3ELROW.js +538 -0
  390. package/dist/chunk-OI4WS7FW.js +162 -0
  391. package/dist/chunk-OITGZUDC.js +82 -0
  392. package/dist/chunk-OKD2LBMK.js +333 -0
  393. package/dist/chunk-OLFOGAWU.js +273 -0
  394. package/dist/chunk-OLFOGAWU.js.map +1 -0
  395. package/dist/chunk-OSA4CGST.js +134 -0
  396. package/dist/chunk-OXYAKUFU.js +401 -0
  397. package/dist/chunk-OYMSMU5O.js +396 -0
  398. package/dist/chunk-P4NZ72KY.js +162 -0
  399. package/dist/chunk-PBYL2VIM.js +379 -0
  400. package/dist/chunk-PDW3OOSZ.js +505 -0
  401. package/dist/chunk-PGRKTQIW.js +523 -0
  402. package/dist/chunk-PPQJIVGM.js +175 -0
  403. package/dist/chunk-PYMQM65Y.js +125 -0
  404. package/dist/chunk-Q273Q33U.js +166 -0
  405. package/dist/chunk-Q4CLS2HL.js +340 -0
  406. package/dist/chunk-QA5UNVHD.js +85 -0
  407. package/dist/chunk-QFOBUA2J.js +428 -0
  408. package/dist/chunk-QLIM4D56.js +1095 -0
  409. package/dist/chunk-QMQF5U2D.js +20 -0
  410. package/dist/chunk-QNOWKKZ4.js +40 -0
  411. package/dist/chunk-QPOUPVPD.js +144 -0
  412. package/dist/chunk-QTJAQ6DS.js +48 -0
  413. package/dist/chunk-QUOFP3G7.js +404 -0
  414. package/dist/chunk-QVOTPOXK.js +29 -0
  415. package/dist/chunk-QYZ5RVGM.js +184 -0
  416. package/dist/chunk-R7CVDKRN.js +2580 -0
  417. package/dist/chunk-RB7MXNZD.js +639 -0
  418. package/dist/chunk-RDZQFZOQ.js +187 -0
  419. package/dist/chunk-RIHKEGWS.js +194 -0
  420. package/dist/chunk-ROSB7GF6.js +57 -0
  421. package/dist/chunk-RP3YMYCX.js +723 -0
  422. package/dist/chunk-RPHXJHNX.js +271 -0
  423. package/dist/chunk-RVC3M66H.js +191 -0
  424. package/dist/chunk-S3OTJAAC.js +283 -0
  425. package/dist/chunk-SBWPMVRN.js +56 -0
  426. package/dist/chunk-SERECSAR.js +138 -0
  427. package/dist/chunk-SHSEF3GJ.js +187 -0
  428. package/dist/chunk-SMS2M3RG.js +772 -0
  429. package/dist/chunk-SRDHDIRQ.js +177 -0
  430. package/dist/chunk-SXRYA7NN.js +389 -0
  431. package/dist/chunk-SYA3WYG4.js +1187 -0
  432. package/dist/chunk-SYYFA7W7.js +23 -0
  433. package/dist/chunk-T2QDSTBH.js +371 -0
  434. package/dist/chunk-TFSCGFYV.js +251 -0
  435. package/dist/chunk-TGCKZOSX.js +246 -0
  436. package/dist/chunk-THILLYQM.js +132 -0
  437. package/dist/chunk-TI6LGUEZ.js +2412 -0
  438. package/dist/chunk-TSY6YZL2.js +366 -0
  439. package/dist/chunk-TW2RHTLH.js +3321 -0
  440. package/dist/chunk-TWA5G277.js +141 -0
  441. package/dist/chunk-TZZ2S4XI.js +247 -0
  442. package/dist/chunk-U5D3K53R.js +58 -0
  443. package/dist/chunk-UECD27LX.js +251 -0
  444. package/dist/chunk-UFJDETKG.js +108 -0
  445. package/dist/chunk-UHCFYX4I.js +570 -0
  446. package/dist/chunk-UHTURYJO.js +898 -0
  447. package/dist/chunk-UJH63JT3.js +67 -0
  448. package/dist/chunk-UOLDS6S5.js +1152 -0
  449. package/dist/chunk-UUE3OGXI.js +84 -0
  450. package/dist/chunk-UUNJ2E57.js +391 -0
  451. package/dist/chunk-UYQVWRAH.js +199 -0
  452. package/dist/chunk-UYWVK7JQ.js +234 -0
  453. package/dist/chunk-UYWWUEL4.js +126 -0
  454. package/dist/chunk-V4CQKX5H.js +48 -0
  455. package/dist/chunk-V4QM7GDQ.js +3176 -0
  456. package/dist/chunk-V5Y74WII.js +91 -0
  457. package/dist/chunk-VGGZLUQK.js +129 -0
  458. package/dist/chunk-VGX636MB.js +311 -0
  459. package/dist/chunk-VGZLFQO2.js +773 -0
  460. package/dist/chunk-VJWZATNF.js +137 -0
  461. package/dist/chunk-VMWCIC2N.js +50 -0
  462. package/dist/chunk-VPWKTIU5.js +227 -0
  463. package/dist/chunk-VXOLG6YB.js +469 -0
  464. package/dist/chunk-W2NAU5VB.js +1628 -0
  465. package/dist/chunk-WGORKMR3.js +353 -0
  466. package/dist/chunk-WMIDELSJ.js +391 -0
  467. package/dist/chunk-WSOSGL2G.js +383 -0
  468. package/dist/chunk-WXUUOM4X.js +400 -0
  469. package/dist/chunk-WZ74QHLE.js +4863 -0
  470. package/dist/chunk-X2OWM2ME.js +1870 -0
  471. package/dist/chunk-X6UMGG4T.js +68 -0
  472. package/dist/chunk-XDXKB25W.js +93 -0
  473. package/dist/chunk-XE4PHI74.js +231 -0
  474. package/dist/chunk-XHF2XNU5.js +73 -0
  475. package/dist/chunk-XLJ4SQFS.js +230 -0
  476. package/dist/chunk-XOD4FX6M.js +2434 -0
  477. package/dist/chunk-XODQ2GPF.js +3110 -0
  478. package/dist/chunk-XT54RTAM.js +441 -0
  479. package/dist/chunk-YAVW5OJ5.js +131 -0
  480. package/dist/chunk-YDQHFJM2.js +83 -0
  481. package/dist/chunk-YH6O6OQ6.js +1356 -0
  482. package/dist/chunk-YIKPC2QP.js +794 -0
  483. package/dist/chunk-ZD7PKYC4.js +335 -0
  484. package/dist/chunk-ZEQYHEWP.js +406 -0
  485. package/dist/chunk-ZMYL6DTE.js +225 -0
  486. package/dist/chunk-ZP3QCPYG.js +21 -0
  487. package/dist/chunk-ZRVUCTSI.js +265 -0
  488. package/dist/chunk-ZSI3ITRK.js +449 -0
  489. package/dist/chunk-ZZMEQCIZ.js +236 -0
  490. package/dist/composer.js +36 -36
  491. package/dist/computer-viewer-ZBY3BPYW.js +21 -0
  492. package/dist/connect.js +29 -29
  493. package/dist/connection-step-up-JQ4OFSQN.js +145 -0
  494. package/dist/desktop-dictation.js +24 -24
  495. package/dist/desktop.js +2 -2
  496. package/dist/editor.js +2 -2
  497. package/dist/embedded-new-voice-ZB5XLKLU.js +25 -0
  498. package/dist/embedded-voice-MZJISDCS.js +25 -0
  499. package/dist/fleet-decision-row-LG3SYVR3.js +361 -0
  500. package/dist/human-input-model.d.ts +2 -0
  501. package/dist/in-chat-connect-model.js +6 -6
  502. package/dist/index.js +298 -298
  503. package/dist/interaction.js +9 -9
  504. package/dist/latest-question-QWJTXMFA.js +1 -1
  505. package/dist/machine-request-model.js +1 -1
  506. package/dist/machines.js +8 -8
  507. package/dist/meetings-recorder.js +1 -1
  508. package/dist/meetings.js +122 -122
  509. package/dist/messages/en.d.ts +10 -0
  510. package/dist/messages.js +1 -1
  511. package/dist/model-levels.js +2 -2
  512. package/dist/model-picker-model.js +2 -2
  513. package/dist/model-policy-picker-menu-5Y72PLNF.js +23 -0
  514. package/dist/model-policy.js +1 -1
  515. package/dist/payment-page-card-YPSXRHBA.js +226 -0
  516. package/dist/platform-activity-row-ZU4MEBNK.js +156 -0
  517. package/dist/queue-surface-implementation-6Q25RPH6.js +932 -0
  518. package/dist/realtime.js +17 -17
  519. package/dist/recorder-host-JD4GWJ2Z.js +80 -0
  520. package/dist/recordings.js +3 -3
  521. package/dist/sandbox-files-HCLEEJMU.js +28 -0
  522. package/dist/session-app.js +406 -406
  523. package/dist/session-connect-cards-DRKEN3Z4.js +27 -0
  524. package/dist/session-list-model.js +3 -3
  525. package/dist/session-realtime-IZOTTRH6.js +30 -0
  526. package/dist/session-realtime.js +2 -2
  527. package/dist/session-ui.js +95 -95
  528. package/dist/session.js +42 -42
  529. package/dist/sites.js +3 -3
  530. package/dist/terminal.js +2 -2
  531. package/dist/this-computer.js +3 -3
  532. package/dist/timeline-annotation-markers-WWXNJOXI.js +157 -0
  533. package/dist/timeline-annotation-selection-ZKRIQFIQ.js +208 -0
  534. package/dist/timeline-annotations-dialog-4IMKTOXJ.js +283 -0
  535. package/dist/timeline-model.js +58 -58
  536. package/dist/ui/access-list.js +19 -19
  537. package/dist/ui/cadence-picker.js +7 -7
  538. package/dist/ui/choice-cards.js +3 -3
  539. package/dist/ui/confirm-dialog.js +2 -2
  540. package/dist/ui/copy-field.js +3 -3
  541. package/dist/ui/detail-page.js +6 -6
  542. package/dist/ui/detail-sheet.js +6 -6
  543. package/dist/ui/diff-view.js +2 -2
  544. package/dist/ui/disclosure.js +7 -7
  545. package/dist/ui/email-chips-input.js +3 -3
  546. package/dist/ui/field.js +2 -2
  547. package/dist/ui/flush-form-page.js +6 -6
  548. package/dist/ui/form-dialog.js +5 -5
  549. package/dist/ui/list-row.js +7 -7
  550. package/dist/ui/load-failure.js +3 -3
  551. package/dist/ui/relative-time.js +3 -3
  552. package/dist/ui/revision-history.js +10 -10
  553. package/dist/ui/role-select.js +10 -10
  554. package/dist/ui/select-menu.js +5 -5
  555. package/dist/ui/settings-nav.js +6 -6
  556. package/dist/ui/sheet.js +2 -2
  557. package/dist/ui/usage-meter.js +4 -4
  558. package/dist/usage.js +3 -3
  559. package/dist/workbench.js +11 -11
  560. package/package.json +5 -6
  561. package/src/components/secret-question-field.tsx +2 -1
  562. package/src/human-input-model.ts +53 -12
  563. package/src/messages/en.ts +10 -0
  564. package/src/model-policy.ts +3 -1
  565. package/dist/browser-viewer-WGRM3JME.js +0 -23
  566. package/dist/chat-interactive-block-5E3UQYHO.js +0 -22
  567. package/dist/chunk-26KK6DN5.js +0 -41
  568. package/dist/chunk-272XEENJ.js +0 -100
  569. package/dist/chunk-2AU2S5NP.js +0 -772
  570. package/dist/chunk-2L7TCAO4.js +0 -188
  571. package/dist/chunk-2MXP6ZRP.js +0 -1095
  572. package/dist/chunk-2Q4XBV3J.js +0 -113
  573. package/dist/chunk-2U5ZJMNP.js +0 -386
  574. package/dist/chunk-2VHPKSFK.js +0 -1236
  575. package/dist/chunk-2WF5XIPA.js +0 -48
  576. package/dist/chunk-2Y53MMGA.js +0 -56
  577. package/dist/chunk-2ZR75AUO.js +0 -225
  578. package/dist/chunk-33QC4RN7.js +0 -133
  579. package/dist/chunk-35LBFD5I.js +0 -311
  580. package/dist/chunk-37J3ZX2N.js +0 -270
  581. package/dist/chunk-37SXZVSY.js +0 -380
  582. package/dist/chunk-37SXZVSY.js.map +0 -1
  583. package/dist/chunk-3ITEAD3E.js +0 -639
  584. package/dist/chunk-3JBLX5BN.js +0 -629
  585. package/dist/chunk-3JYID53J.js +0 -432
  586. package/dist/chunk-3MZCXSC7.js +0 -723
  587. package/dist/chunk-3NRJ4Z3A.js +0 -3176
  588. package/dist/chunk-3UG2AJHR.js +0 -89
  589. package/dist/chunk-3XS3A6Y6.js +0 -162
  590. package/dist/chunk-3ZBQIZEM.js +0 -214
  591. package/dist/chunk-3ZVACRTK.js +0 -82
  592. package/dist/chunk-46USHCHK.js +0 -389
  593. package/dist/chunk-4IMVT7OU.js +0 -263
  594. package/dist/chunk-4J4IPUPZ.js +0 -103
  595. package/dist/chunk-4PG2BEQA.js +0 -175
  596. package/dist/chunk-4YQFDBKE.js +0 -532
  597. package/dist/chunk-5ERDSF2C.js +0 -79
  598. package/dist/chunk-5EZELID5.js +0 -789
  599. package/dist/chunk-5NGW5K2D.js +0 -1333
  600. package/dist/chunk-5SK5PYFN.js +0 -15
  601. package/dist/chunk-5UI3VPCY.js +0 -1152
  602. package/dist/chunk-5W4ZGFXZ.js +0 -373
  603. package/dist/chunk-64XZTYX4.js +0 -572
  604. package/dist/chunk-67MFNMGH.js +0 -200
  605. package/dist/chunk-6C55RLFY.js +0 -103
  606. package/dist/chunk-6DFHNNWJ.js +0 -121
  607. package/dist/chunk-6F34IWSA.js +0 -47
  608. package/dist/chunk-6F34IWSA.js.map +0 -1
  609. package/dist/chunk-6FWBGVFL.js +0 -5905
  610. package/dist/chunk-6FWBGVFL.js.map +0 -1
  611. package/dist/chunk-6GBJFFQL.js +0 -215
  612. package/dist/chunk-6H2OQ6XG.js +0 -318
  613. package/dist/chunk-6LUF4TOE.js +0 -91
  614. package/dist/chunk-6M2WXQX5.js +0 -523
  615. package/dist/chunk-6O6CHBD3.js +0 -29
  616. package/dist/chunk-6U3PE427.js +0 -794
  617. package/dist/chunk-6V2UH36U.js +0 -187
  618. package/dist/chunk-73YALMGG.js +0 -1022
  619. package/dist/chunk-7JNWIGM4.js +0 -1628
  620. package/dist/chunk-7QODDTOI.js +0 -554
  621. package/dist/chunk-7TEXZ5LW.js +0 -46
  622. package/dist/chunk-A4SKSSSS.js +0 -2553
  623. package/dist/chunk-A7Z65D33.js +0 -400
  624. package/dist/chunk-ACUDUVDJ.js +0 -231
  625. package/dist/chunk-AI7XM4MY.js +0 -194
  626. package/dist/chunk-AJEOTFQE.js +0 -234
  627. package/dist/chunk-AKQSOR4G.js +0 -538
  628. package/dist/chunk-AP4FMXAM.js +0 -353
  629. package/dist/chunk-AQHQUPEF.js +0 -202
  630. package/dist/chunk-ATVSG5CO.js +0 -296
  631. package/dist/chunk-B6YDINPE.js +0 -68
  632. package/dist/chunk-BMOYN4HY.js +0 -283
  633. package/dist/chunk-BMSMK7SA.js +0 -84
  634. package/dist/chunk-BY7AWWDB.js +0 -177
  635. package/dist/chunk-BZ4GSY44.js +0 -2412
  636. package/dist/chunk-CGYPX3HJ.js +0 -292
  637. package/dist/chunk-CHYAUIZ3.js +0 -2984
  638. package/dist/chunk-CJEQQBNZ.js +0 -818
  639. package/dist/chunk-CP53LM7W.js +0 -1021
  640. package/dist/chunk-CQW4ZPU4.js +0 -191
  641. package/dist/chunk-CTKUOOU4.js +0 -246
  642. package/dist/chunk-CWKFPDYB.js +0 -124
  643. package/dist/chunk-CYBRD5BP.js +0 -113
  644. package/dist/chunk-CYPMAJ75.js +0 -449
  645. package/dist/chunk-CYPNXHWM.js +0 -379
  646. package/dist/chunk-D45IDQBW.js +0 -114
  647. package/dist/chunk-D4RTU236.js +0 -230
  648. package/dist/chunk-DBGOJIMM.js +0 -399
  649. package/dist/chunk-DD3DT5MY.js +0 -3321
  650. package/dist/chunk-DG3GW325.js +0 -72
  651. package/dist/chunk-DHLGGANG.js +0 -50
  652. package/dist/chunk-DHZW6JXQ.js +0 -10035
  653. package/dist/chunk-DHZW6JXQ.js.map +0 -1
  654. package/dist/chunk-DLHR7HHS.js +0 -931
  655. package/dist/chunk-DM7JLUWN.js +0 -406
  656. package/dist/chunk-DMQY35LC.js +0 -98
  657. package/dist/chunk-EBVL3YJQ.js +0 -67
  658. package/dist/chunk-EIQQYUOT.js +0 -274
  659. package/dist/chunk-EMART4X3.js +0 -107
  660. package/dist/chunk-EMJSJTIE.js +0 -207
  661. package/dist/chunk-ES3JAYQJ.js +0 -214
  662. package/dist/chunk-EWJ7WEZT.js +0 -175
  663. package/dist/chunk-FC6MLU5C.js +0 -52
  664. package/dist/chunk-FD6F2OE5.js +0 -515
  665. package/dist/chunk-FE4HNBHF.js +0 -48
  666. package/dist/chunk-FFXJF5KU.js +0 -201
  667. package/dist/chunk-FN5UTQSL.js +0 -117
  668. package/dist/chunk-FT4ZKYTG.js +0 -138
  669. package/dist/chunk-FYOGQHCD.js +0 -209
  670. package/dist/chunk-FZOK37SC.js +0 -155
  671. package/dist/chunk-GA42NSDJ.js +0 -132
  672. package/dist/chunk-GDWKVSMK.js +0 -372
  673. package/dist/chunk-GH3Q5XW4.js +0 -2551
  674. package/dist/chunk-GHLUZSIB.js +0 -259
  675. package/dist/chunk-GISBCT5E.js +0 -366
  676. package/dist/chunk-GKA5LFYR.js +0 -21
  677. package/dist/chunk-GPRM5GYZ.js +0 -131
  678. package/dist/chunk-GWJLR55B.js +0 -333
  679. package/dist/chunk-GX3RAB4W.js +0 -357
  680. package/dist/chunk-GYNTJYWY.js +0 -166
  681. package/dist/chunk-GYWQ4KVM.js +0 -85
  682. package/dist/chunk-H2AOQJQP.js +0 -378
  683. package/dist/chunk-H35G5UHL.js +0 -111
  684. package/dist/chunk-H6PJEWZH.js +0 -170
  685. package/dist/chunk-HHUTU5EN.js +0 -108
  686. package/dist/chunk-HPH3MFFE.js +0 -3996
  687. package/dist/chunk-HPH3MFFE.js.map +0 -1
  688. package/dist/chunk-HQZ6NGUU.js +0 -114
  689. package/dist/chunk-HSEHIVAE.js +0 -4564
  690. package/dist/chunk-HTYDPAJL.js +0 -391
  691. package/dist/chunk-HUKGLWAY.js +0 -174
  692. package/dist/chunk-HUTQJY3F.js +0 -23
  693. package/dist/chunk-HUWJZRD3.js +0 -311
  694. package/dist/chunk-HVL7TCB5.js +0 -50
  695. package/dist/chunk-HWOYJOKK.js +0 -266
  696. package/dist/chunk-HXANXMPH.js +0 -3851
  697. package/dist/chunk-HZBPL4KB.js +0 -244
  698. package/dist/chunk-HZBPL4KB.js.map +0 -1
  699. package/dist/chunk-I4CXHN6E.js +0 -269
  700. package/dist/chunk-I6YOCSEP.js +0 -37
  701. package/dist/chunk-IAXF3IO6.js +0 -1399
  702. package/dist/chunk-IGUPUA3G.js +0 -403
  703. package/dist/chunk-IKAVNCO5.js +0 -112
  704. package/dist/chunk-IMWP2Q4W.js +0 -137
  705. package/dist/chunk-IXPLYZFO.js +0 -40
  706. package/dist/chunk-J3CHK7NH.js +0 -12
  707. package/dist/chunk-JAC5I2BN.js +0 -85
  708. package/dist/chunk-JK2WTBLD.js +0 -158
  709. package/dist/chunk-JOKNFHFU.js +0 -412
  710. package/dist/chunk-JOVCPP44.js +0 -441
  711. package/dist/chunk-JTRRMV7B.js +0 -469
  712. package/dist/chunk-K2WDXLZS.js +0 -134
  713. package/dist/chunk-K6JW7GB3.js +0 -828
  714. package/dist/chunk-KA5H2Z3E.js +0 -168
  715. package/dist/chunk-KQBVH5LN.js +0 -229
  716. package/dist/chunk-KQVHSEQQ.js +0 -20
  717. package/dist/chunk-KREVCOE7.js +0 -187
  718. package/dist/chunk-KYDLVMKA.js +0 -99
  719. package/dist/chunk-L4PIAAQB.js +0 -4863
  720. package/dist/chunk-L64LMYJD.js +0 -114
  721. package/dist/chunk-L7XVC27Z.js +0 -850
  722. package/dist/chunk-L7XVC27Z.js.map +0 -1
  723. package/dist/chunk-L7ZLPS37.js +0 -371
  724. package/dist/chunk-LDZSUY7K.js +0 -298
  725. package/dist/chunk-LK3AAMN7.js +0 -404
  726. package/dist/chunk-LLVJ3P2N.js +0 -428
  727. package/dist/chunk-LPHBZCCV.js +0 -1263
  728. package/dist/chunk-LT3MK2XP.js +0 -608
  729. package/dist/chunk-M72GFKDP.js +0 -335
  730. package/dist/chunk-M73QQXUQ.js +0 -270
  731. package/dist/chunk-M7NPDODK.js +0 -1870
  732. package/dist/chunk-MB5EK2PA.js +0 -211
  733. package/dist/chunk-MB5WRIYX.js +0 -33
  734. package/dist/chunk-MBYHDOTU.js +0 -42
  735. package/dist/chunk-MDIHQGPV.js +0 -276
  736. package/dist/chunk-MQFJPFL4.js +0 -5089
  737. package/dist/chunk-MU6IU4IH.js +0 -650
  738. package/dist/chunk-N7IOCNWK.js +0 -1019
  739. package/dist/chunk-NDJPEX7P.js +0 -1187
  740. package/dist/chunk-NLKHAZMG.js +0 -898
  741. package/dist/chunk-NLYAWFDY.js +0 -199
  742. package/dist/chunk-NNIUBJOE.js +0 -154
  743. package/dist/chunk-NSBOITEM.js +0 -175
  744. package/dist/chunk-NUZNJSL5.js +0 -285
  745. package/dist/chunk-NZFMEGPE.js +0 -287
  746. package/dist/chunk-O4UAH7WR.js +0 -427
  747. package/dist/chunk-O4UAH7WR.js.map +0 -1
  748. package/dist/chunk-O4VCJWKV.js +0 -176
  749. package/dist/chunk-OE4QJJ4C.js +0 -432
  750. package/dist/chunk-OQEAJGAJ.js +0 -65
  751. package/dist/chunk-ORSFNFNY.js +0 -1184
  752. package/dist/chunk-OU2J6K3L.js +0 -129
  753. package/dist/chunk-OVAT4PIR.js +0 -437
  754. package/dist/chunk-OWF2AVT6.js +0 -407
  755. package/dist/chunk-P2OHWZMB.js +0 -256
  756. package/dist/chunk-PCSRHFRF.js +0 -75
  757. package/dist/chunk-PH2FDKJE.js +0 -250
  758. package/dist/chunk-PMBZMVKE.js +0 -33
  759. package/dist/chunk-PNLVWZSM.js +0 -211
  760. package/dist/chunk-PQ7WJAKL.js +0 -74
  761. package/dist/chunk-PTSRBKQC.js +0 -118
  762. package/dist/chunk-PTUIF4TT.js +0 -144
  763. package/dist/chunk-PV7X4PRR.js +0 -570
  764. package/dist/chunk-Q35LFE7H.js +0 -26
  765. package/dist/chunk-QAHGGBL2.js +0 -1024
  766. package/dist/chunk-QI5RXPYP.js +0 -56
  767. package/dist/chunk-QODAMEOR.js +0 -2317
  768. package/dist/chunk-QXOO5U46.js +0 -172
  769. package/dist/chunk-R6OBJ7LF.js +0 -131
  770. package/dist/chunk-R6WQLIFX.js +0 -73
  771. package/dist/chunk-R7SBV5KD.js +0 -3690
  772. package/dist/chunk-R7ZIFQ7D.js +0 -738
  773. package/dist/chunk-R7ZIFQ7D.js.map +0 -1
  774. package/dist/chunk-RFBJ6TUL.js +0 -43
  775. package/dist/chunk-RLNJSAHP.js +0 -851
  776. package/dist/chunk-RMVKH4EE.js +0 -351
  777. package/dist/chunk-RO2UO3VN.js +0 -107
  778. package/dist/chunk-ROCQ3IDW.js +0 -184
  779. package/dist/chunk-RPWI6A3H.js +0 -849
  780. package/dist/chunk-RTJVIXH5.js +0 -141
  781. package/dist/chunk-RZ5IQ3SX.js +0 -278
  782. package/dist/chunk-S7NX6KSE.js +0 -406
  783. package/dist/chunk-SFWP4DNI.js +0 -218
  784. package/dist/chunk-SI2RFGQX.js +0 -158
  785. package/dist/chunk-SKHYIIH4.js +0 -107
  786. package/dist/chunk-SOC5IBQT.js +0 -383
  787. package/dist/chunk-SUMBC7BQ.js +0 -396
  788. package/dist/chunk-T4UTYGB2.js +0 -110
  789. package/dist/chunk-T6N33M46.js +0 -251
  790. package/dist/chunk-TD5EKKVD.js +0 -83
  791. package/dist/chunk-TGG3ODCS.js +0 -99
  792. package/dist/chunk-TGVTVLNI.js +0 -401
  793. package/dist/chunk-TLTE3QSX.js +0 -73
  794. package/dist/chunk-TXAMGOUG.js +0 -2580
  795. package/dist/chunk-U4OIE2MJ.js +0 -271
  796. package/dist/chunk-UBTDG6GC.js +0 -126
  797. package/dist/chunk-UFRXYZCJ.js +0 -125
  798. package/dist/chunk-UHU2WESP.js +0 -340
  799. package/dist/chunk-UKDLZ76A.js +0 -2434
  800. package/dist/chunk-UPRN4FBY.js +0 -38
  801. package/dist/chunk-UQDT3SM2.js +0 -27
  802. package/dist/chunk-UQFUI3KT.js +0 -3070
  803. package/dist/chunk-UXBW2TYH.js +0 -1356
  804. package/dist/chunk-UXZLTAJO.js +0 -227
  805. package/dist/chunk-UZAVFOZC.js +0 -505
  806. package/dist/chunk-V2A4I4GC.js +0 -265
  807. package/dist/chunk-VAN6CEAV.js +0 -234
  808. package/dist/chunk-VDHWFRTL.js +0 -58
  809. package/dist/chunk-VLDKWGHD.js +0 -61
  810. package/dist/chunk-W4ABZ6XO.js +0 -4480
  811. package/dist/chunk-W4ABZ6XO.js.map +0 -1
  812. package/dist/chunk-W4TOPPVT.js +0 -162
  813. package/dist/chunk-W7P44UAE.js +0 -278
  814. package/dist/chunk-WAVR3UIC.js +0 -773
  815. package/dist/chunk-WLRB74VH.js +0 -251
  816. package/dist/chunk-WOVGVEKP.js +0 -192
  817. package/dist/chunk-WQ35KUFP.js +0 -264
  818. package/dist/chunk-WSBUFP77.js +0 -391
  819. package/dist/chunk-X56NEOYY.js +0 -283
  820. package/dist/chunk-XET2K3TU.js +0 -138
  821. package/dist/chunk-XJPDGFVT.js +0 -307
  822. package/dist/chunk-XK4VFZHQ.js +0 -246
  823. package/dist/chunk-XVP23IJS.js +0 -236
  824. package/dist/chunk-YEU2JC3B.js +0 -27
  825. package/dist/chunk-YFU2VZXS.js +0 -249
  826. package/dist/chunk-YMY2OO3V.js +0 -584
  827. package/dist/chunk-YNRZN3TU.js +0 -57
  828. package/dist/chunk-YP4SNX4P.js +0 -220
  829. package/dist/chunk-YSZAX6WJ.js +0 -196
  830. package/dist/chunk-YTUVANLR.js +0 -93
  831. package/dist/chunk-YUEYZTBP.js +0 -1309
  832. package/dist/chunk-YUVS7HYN.js +0 -129
  833. package/dist/chunk-YVQUPHYL.js +0 -234
  834. package/dist/chunk-YW4YRCXI.js +0 -3110
  835. package/dist/chunk-YZ2G24VJ.js +0 -1185
  836. package/dist/chunk-ZBTYTG4E.js +0 -247
  837. package/dist/chunk-ZCQJUYDX.js +0 -178
  838. package/dist/chunk-ZD67RM6G.js +0 -60
  839. package/dist/computer-viewer-BWWVUD6J.js +0 -21
  840. package/dist/connection-step-up-7ICLBORD.js +0 -145
  841. package/dist/embedded-new-voice-VD6GR5JQ.js +0 -25
  842. package/dist/embedded-voice-J2B6J2QQ.js +0 -25
  843. package/dist/fleet-decision-row-B672XMNG.js +0 -361
  844. package/dist/model-policy-picker-menu-HT3TWGSS.js +0 -23
  845. package/dist/payment-page-card-4LZPJ3OK.js +0 -226
  846. package/dist/platform-activity-row-TWXWUCXD.js +0 -156
  847. package/dist/queue-surface-implementation-SQ7K2TM4.js +0 -932
  848. package/dist/recorder-host-N2S7G3CW.js +0 -80
  849. package/dist/sandbox-files-6CKWJ2CU.js +0 -28
  850. package/dist/session-connect-cards-VNQWMX7A.js +0 -27
  851. package/dist/session-realtime-CRG7DRV6.js +0 -30
  852. package/dist/timeline-annotation-markers-JXCNK4S6.js +0 -157
  853. package/dist/timeline-annotation-selection-5ZTVYJXT.js +0 -208
  854. package/dist/timeline-annotations-dialog-4QWVCZCF.js +0 -283
  855. /package/dist/{browser-viewer-WGRM3JME.js.map → browser-viewer-EIEMRVFF.js.map} +0 -0
  856. /package/dist/{chat-interactive-block-5E3UQYHO.js.map → chat-interactive-block-FV37LWYZ.js.map} +0 -0
  857. /package/dist/{chunk-CJEQQBNZ.js.map → chunk-2COBAJC7.js.map} +0 -0
  858. /package/dist/{chunk-H6PJEWZH.js.map → chunk-2HS3IUXE.js.map} +0 -0
  859. /package/dist/{chunk-ATVSG5CO.js.map → chunk-2JTMFYCT.js.map} +0 -0
  860. /package/dist/{chunk-L64LMYJD.js.map → chunk-2JXKP4M6.js.map} +0 -0
  861. /package/dist/{chunk-I4CXHN6E.js.map → chunk-2P5K7CBH.js.map} +0 -0
  862. /package/dist/{chunk-PH2FDKJE.js.map → chunk-2XGRHMRI.js.map} +0 -0
  863. /package/dist/{chunk-OQEAJGAJ.js.map → chunk-332BYSAZ.js.map} +0 -0
  864. /package/dist/{chunk-SI2RFGQX.js.map → chunk-3EM5GTP3.js.map} +0 -0
  865. /package/dist/{chunk-FC6MLU5C.js.map → chunk-3L5ATO4A.js.map} +0 -0
  866. /package/dist/{chunk-SKHYIIH4.js.map → chunk-3S3PJB7J.js.map} +0 -0
  867. /package/dist/{chunk-37J3ZX2N.js.map → chunk-3SBKYPNM.js.map} +0 -0
  868. /package/dist/{chunk-D45IDQBW.js.map → chunk-3Z7VA6ET.js.map} +0 -0
  869. /package/dist/{chunk-EMJSJTIE.js.map → chunk-43BRJBEV.js.map} +0 -0
  870. /package/dist/{chunk-2L7TCAO4.js.map → chunk-46LZO4ZO.js.map} +0 -0
  871. /package/dist/{chunk-UPRN4FBY.js.map → chunk-46ZC5VNC.js.map} +0 -0
  872. /package/dist/{chunk-LDZSUY7K.js.map → chunk-4AH4EEHE.js.map} +0 -0
  873. /package/dist/{chunk-M73QQXUQ.js.map → chunk-4D3YJNVN.js.map} +0 -0
  874. /package/dist/{chunk-I6YOCSEP.js.map → chunk-4I4RTI4D.js.map} +0 -0
  875. /package/dist/{chunk-NZFMEGPE.js.map → chunk-4KASGJTF.js.map} +0 -0
  876. /package/dist/{chunk-LPHBZCCV.js.map → chunk-4RUKLIOF.js.map} +0 -0
  877. /package/dist/{chunk-MU6IU4IH.js.map → chunk-4UU7FN3I.js.map} +0 -0
  878. /package/dist/{chunk-GH3Q5XW4.js.map → chunk-4ZRNASBF.js.map} +0 -0
  879. /package/dist/{chunk-26KK6DN5.js.map → chunk-5EJBPQI2.js.map} +0 -0
  880. /package/dist/{chunk-FYOGQHCD.js.map → chunk-5G4IGG7F.js.map} +0 -0
  881. /package/dist/{chunk-GPRM5GYZ.js.map → chunk-5JAYZOAW.js.map} +0 -0
  882. /package/dist/{chunk-5EZELID5.js.map → chunk-5JOKVDSR.js.map} +0 -0
  883. /package/dist/{chunk-2VHPKSFK.js.map → chunk-5MP3G7ZV.js.map} +0 -0
  884. /package/dist/{chunk-MBYHDOTU.js.map → chunk-5OVRMKP5.js.map} +0 -0
  885. /package/dist/{chunk-ORSFNFNY.js.map → chunk-5SGTRULO.js.map} +0 -0
  886. /package/dist/{chunk-64XZTYX4.js.map → chunk-5SOL4INY.js.map} +0 -0
  887. /package/dist/{chunk-YEU2JC3B.js.map → chunk-5Y34P32B.js.map} +0 -0
  888. /package/dist/{chunk-DG3GW325.js.map → chunk-62HIKJ5F.js.map} +0 -0
  889. /package/dist/{chunk-HWOYJOKK.js.map → chunk-62T2ZPD5.js.map} +0 -0
  890. /package/dist/{chunk-2U5ZJMNP.js.map → chunk-63VNZRLY.js.map} +0 -0
  891. /package/dist/{chunk-PMBZMVKE.js.map → chunk-6CDBX3XG.js.map} +0 -0
  892. /package/dist/{chunk-W7P44UAE.js.map → chunk-6D3D2JWY.js.map} +0 -0
  893. /package/dist/{chunk-FFXJF5KU.js.map → chunk-6DOIINY4.js.map} +0 -0
  894. /package/dist/{chunk-IKAVNCO5.js.map → chunk-6DQBUKGJ.js.map} +0 -0
  895. /package/dist/{chunk-IAXF3IO6.js.map → chunk-6SETNFNH.js.map} +0 -0
  896. /package/dist/{chunk-QI5RXPYP.js.map → chunk-6XYFMHNT.js.map} +0 -0
  897. /package/dist/{chunk-MB5WRIYX.js.map → chunk-6YU3WV2P.js.map} +0 -0
  898. /package/dist/{chunk-RMVKH4EE.js.map → chunk-6YUHDFOZ.js.map} +0 -0
  899. /package/dist/{chunk-YZ2G24VJ.js.map → chunk-72EOXOR7.js.map} +0 -0
  900. /package/dist/{chunk-4YQFDBKE.js.map → chunk-72ND4ALI.js.map} +0 -0
  901. /package/dist/{chunk-X56NEOYY.js.map → chunk-757LE32E.js.map} +0 -0
  902. /package/dist/{chunk-3UG2AJHR.js.map → chunk-7FDEV6XW.js.map} +0 -0
  903. /package/dist/{chunk-XET2K3TU.js.map → chunk-7S2S4MXR.js.map} +0 -0
  904. /package/dist/{chunk-67MFNMGH.js.map → chunk-7SYCHMXS.js.map} +0 -0
  905. /package/dist/{chunk-MQFJPFL4.js.map → chunk-7TVAPQOV.js.map} +0 -0
  906. /package/dist/{chunk-ES3JAYQJ.js.map → chunk-7UDLRDHK.js.map} +0 -0
  907. /package/dist/{chunk-GX3RAB4W.js.map → chunk-7YLQCMZP.js.map} +0 -0
  908. /package/dist/{chunk-RPWI6A3H.js.map → chunk-A5GX3CAE.js.map} +0 -0
  909. /package/dist/{chunk-6H2OQ6XG.js.map → chunk-A7EBV2EB.js.map} +0 -0
  910. /package/dist/{chunk-HQZ6NGUU.js.map → chunk-AB5SPXUR.js.map} +0 -0
  911. /package/dist/{chunk-AQHQUPEF.js.map → chunk-AHVQGL5A.js.map} +0 -0
  912. /package/dist/{chunk-Q35LFE7H.js.map → chunk-AI77ZKEV.js.map} +0 -0
  913. /package/dist/{chunk-N7IOCNWK.js.map → chunk-AIX2D6RB.js.map} +0 -0
  914. /package/dist/{chunk-WOVGVEKP.js.map → chunk-AVSIHP7Q.js.map} +0 -0
  915. /package/dist/{chunk-EMART4X3.js.map → chunk-AWK23Q32.js.map} +0 -0
  916. /package/dist/{chunk-3JYID53J.js.map → chunk-AYVWA6KD.js.map} +0 -0
  917. /package/dist/{chunk-A4SKSSSS.js.map → chunk-AYZXE4IM.js.map} +0 -0
  918. /package/dist/{chunk-CWKFPDYB.js.map → chunk-AZGGSPTE.js.map} +0 -0
  919. /package/dist/{chunk-DLHR7HHS.js.map → chunk-B45TB4HY.js.map} +0 -0
  920. /package/dist/{chunk-7TEXZ5LW.js.map → chunk-BIUJHNVR.js.map} +0 -0
  921. /package/dist/{chunk-AJEOTFQE.js.map → chunk-BJUOKUE5.js.map} +0 -0
  922. /package/dist/{chunk-CGYPX3HJ.js.map → chunk-BPEEVMKH.js.map} +0 -0
  923. /package/dist/{chunk-PQ7WJAKL.js.map → chunk-BPHPAGYF.js.map} +0 -0
  924. /package/dist/{chunk-XJPDGFVT.js.map → chunk-BXMND6YU.js.map} +0 -0
  925. /package/dist/{chunk-FN5UTQSL.js.map → chunk-C6OM2SRG.js.map} +0 -0
  926. /package/dist/{chunk-YUEYZTBP.js.map → chunk-CIRCUDKF.js.map} +0 -0
  927. /package/dist/{chunk-IGUPUA3G.js.map → chunk-CLKR4UG3.js.map} +0 -0
  928. /package/dist/{chunk-7QODDTOI.js.map → chunk-CPX6BHER.js.map} +0 -0
  929. /package/dist/{chunk-FZOK37SC.js.map → chunk-CVC4RO7D.js.map} +0 -0
  930. /package/dist/{chunk-6C55RLFY.js.map → chunk-D3YJAQGK.js.map} +0 -0
  931. /package/dist/{chunk-QAHGGBL2.js.map → chunk-DFQ72BLS.js.map} +0 -0
  932. /package/dist/{chunk-HSEHIVAE.js.map → chunk-DG65PJOZ.js.map} +0 -0
  933. /package/dist/{chunk-DM7JLUWN.js.map → chunk-DNAXAS5R.js.map} +0 -0
  934. /package/dist/{chunk-NSBOITEM.js.map → chunk-DO247ITS.js.map} +0 -0
  935. /package/dist/{chunk-NNIUBJOE.js.map → chunk-DONBARLL.js.map} +0 -0
  936. /package/dist/{chunk-5W4ZGFXZ.js.map → chunk-DTLXQ3ZU.js.map} +0 -0
  937. /package/dist/{chunk-EIQQYUOT.js.map → chunk-EAXTACI4.js.map} +0 -0
  938. /package/dist/{chunk-JOKNFHFU.js.map → chunk-EDPH7AJH.js.map} +0 -0
  939. /package/dist/{chunk-MDIHQGPV.js.map → chunk-EFKQHCGJ.js.map} +0 -0
  940. /package/dist/{chunk-33QC4RN7.js.map → chunk-EILSPMVD.js.map} +0 -0
  941. /package/dist/{chunk-PNLVWZSM.js.map → chunk-EK7KIETS.js.map} +0 -0
  942. /package/dist/{chunk-OVAT4PIR.js.map → chunk-EMWT6GOK.js.map} +0 -0
  943. /package/dist/{chunk-GHLUZSIB.js.map → chunk-EO22NST7.js.map} +0 -0
  944. /package/dist/{chunk-P2OHWZMB.js.map → chunk-ER5MYLIE.js.map} +0 -0
  945. /package/dist/{chunk-YVQUPHYL.js.map → chunk-ES5HKVQF.js.map} +0 -0
  946. /package/dist/{chunk-H35G5UHL.js.map → chunk-F26YBYAZ.js.map} +0 -0
  947. /package/dist/{chunk-FD6F2OE5.js.map → chunk-F6QP4GSK.js.map} +0 -0
  948. /package/dist/{chunk-RLNJSAHP.js.map → chunk-F7QEO7M2.js.map} +0 -0
  949. /package/dist/{chunk-J3CHK7NH.js.map → chunk-FJFGDLXB.js.map} +0 -0
  950. /package/dist/{chunk-CYBRD5BP.js.map → chunk-FLLJ2WXW.js.map} +0 -0
  951. /package/dist/{chunk-RO2UO3VN.js.map → chunk-FMBJKMT4.js.map} +0 -0
  952. /package/dist/{chunk-R7SBV5KD.js.map → chunk-FPN4I4CG.js.map} +0 -0
  953. /package/dist/{chunk-UQFUI3KT.js.map → chunk-FUXFJTXL.js.map} +0 -0
  954. /package/dist/{chunk-JK2WTBLD.js.map → chunk-G6SSSX5R.js.map} +0 -0
  955. /package/dist/{chunk-LT3MK2XP.js.map → chunk-GBGCMHBB.js.map} +0 -0
  956. /package/dist/{chunk-HUKGLWAY.js.map → chunk-GIHE7U3Y.js.map} +0 -0
  957. /package/dist/{chunk-GDWKVSMK.js.map → chunk-GJ4GTYOD.js.map} +0 -0
  958. /package/dist/{chunk-OE4QJJ4C.js.map → chunk-GLSDWNFV.js.map} +0 -0
  959. /package/dist/{chunk-RZ5IQ3SX.js.map → chunk-GMGAW3T6.js.map} +0 -0
  960. /package/dist/{chunk-RFBJ6TUL.js.map → chunk-GNGI6XFN.js.map} +0 -0
  961. /package/dist/{chunk-WQ35KUFP.js.map → chunk-GO5VIAA7.js.map} +0 -0
  962. /package/dist/{chunk-KQBVH5LN.js.map → chunk-GSW4YHZE.js.map} +0 -0
  963. /package/dist/{chunk-OWF2AVT6.js.map → chunk-GUC6IWEY.js.map} +0 -0
  964. /package/dist/{chunk-5SK5PYFN.js.map → chunk-GWAY3SO5.js.map} +0 -0
  965. /package/dist/{chunk-KA5H2Z3E.js.map → chunk-GXOTNT5D.js.map} +0 -0
  966. /package/dist/{chunk-HXANXMPH.js.map → chunk-GZZCVF76.js.map} +0 -0
  967. /package/dist/{chunk-3ZBQIZEM.js.map → chunk-H4VMHFOX.js.map} +0 -0
  968. /package/dist/{chunk-T4UTYGB2.js.map → chunk-HA5RFQAF.js.map} +0 -0
  969. /package/dist/{chunk-PTSRBKQC.js.map → chunk-HFROJDFQ.js.map} +0 -0
  970. /package/dist/{chunk-YP4SNX4P.js.map → chunk-HHFFPE67.js.map} +0 -0
  971. /package/dist/{chunk-4J4IPUPZ.js.map → chunk-HJLHGXWL.js.map} +0 -0
  972. /package/dist/{chunk-CHYAUIZ3.js.map → chunk-HKNMNL7B.js.map} +0 -0
  973. /package/dist/{chunk-CP53LM7W.js.map → chunk-HT7MBHLY.js.map} +0 -0
  974. /package/dist/{chunk-YMY2OO3V.js.map → chunk-I5FSUZVW.js.map} +0 -0
  975. /package/dist/{chunk-CTKUOOU4.js.map → chunk-IINQO425.js.map} +0 -0
  976. /package/dist/{chunk-73YALMGG.js.map → chunk-IIXNEOK4.js.map} +0 -0
  977. /package/dist/{chunk-HUWJZRD3.js.map → chunk-IM3WA5AL.js.map} +0 -0
  978. /package/dist/{chunk-DBGOJIMM.js.map → chunk-IX4P4OGR.js.map} +0 -0
  979. /package/dist/{chunk-OU2J6K3L.js.map → chunk-IX5VHZYS.js.map} +0 -0
  980. /package/dist/{chunk-4IMVT7OU.js.map → chunk-JB3TSUZO.js.map} +0 -0
  981. /package/dist/{chunk-UQDT3SM2.js.map → chunk-JIC6RLUB.js.map} +0 -0
  982. /package/dist/{chunk-QXOO5U46.js.map → chunk-JNJIZCTN.js.map} +0 -0
  983. /package/dist/{chunk-K6JW7GB3.js.map → chunk-JNV5ZPUV.js.map} +0 -0
  984. /package/dist/{chunk-HVL7TCB5.js.map → chunk-JPQFVR24.js.map} +0 -0
  985. /package/dist/{chunk-5NGW5K2D.js.map → chunk-JPZVMXDP.js.map} +0 -0
  986. /package/dist/{chunk-6GBJFFQL.js.map → chunk-JVPF34MX.js.map} +0 -0
  987. /package/dist/{chunk-JAC5I2BN.js.map → chunk-KED67KAF.js.map} +0 -0
  988. /package/dist/{chunk-H2AOQJQP.js.map → chunk-KJ72GMZ2.js.map} +0 -0
  989. /package/dist/{chunk-PCSRHFRF.js.map → chunk-KTGKGHEA.js.map} +0 -0
  990. /package/dist/{chunk-NUZNJSL5.js.map → chunk-KU77XHWB.js.map} +0 -0
  991. /package/dist/{chunk-YFU2VZXS.js.map → chunk-KXBLLFOO.js.map} +0 -0
  992. /package/dist/{chunk-VLDKWGHD.js.map → chunk-L6WVCO6D.js.map} +0 -0
  993. /package/dist/{chunk-TLTE3QSX.js.map → chunk-LPEFULJY.js.map} +0 -0
  994. /package/dist/{chunk-DMQY35LC.js.map → chunk-LRMGPO7E.js.map} +0 -0
  995. /package/dist/{chunk-6DFHNNWJ.js.map → chunk-LVKTKORH.js.map} +0 -0
  996. /package/dist/{chunk-TGG3ODCS.js.map → chunk-MCPKUVMQ.js.map} +0 -0
  997. /package/dist/{chunk-KYDLVMKA.js.map → chunk-MFLU3466.js.map} +0 -0
  998. /package/dist/{chunk-ZD67RM6G.js.map → chunk-MIUJ3EH5.js.map} +0 -0
  999. /package/dist/{chunk-EWJ7WEZT.js.map → chunk-MIUMNTIJ.js.map} +0 -0
  1000. /package/dist/{chunk-2Q4XBV3J.js.map → chunk-ML46TXRM.js.map} +0 -0
  1001. /package/dist/{chunk-3JBLX5BN.js.map → chunk-MO3XJQN2.js.map} +0 -0
  1002. /package/dist/{chunk-SFWP4DNI.js.map → chunk-MQRHTOQ2.js.map} +0 -0
  1003. /package/dist/{chunk-5ERDSF2C.js.map → chunk-MVYQDBE6.js.map} +0 -0
  1004. /package/dist/{chunk-272XEENJ.js.map → chunk-NE5P7LFQ.js.map} +0 -0
  1005. /package/dist/{chunk-YSZAX6WJ.js.map → chunk-NPBEUU22.js.map} +0 -0
  1006. /package/dist/{chunk-ZCQJUYDX.js.map → chunk-NSXKGS2K.js.map} +0 -0
  1007. /package/dist/{chunk-QODAMEOR.js.map → chunk-NUEFORM6.js.map} +0 -0
  1008. /package/dist/{chunk-O4VCJWKV.js.map → chunk-NZOFNQNC.js.map} +0 -0
  1009. /package/dist/{chunk-MB5EK2PA.js.map → chunk-OATXCLTY.js.map} +0 -0
  1010. /package/dist/{chunk-AKQSOR4G.js.map → chunk-OG3ELROW.js.map} +0 -0
  1011. /package/dist/{chunk-W4TOPPVT.js.map → chunk-OI4WS7FW.js.map} +0 -0
  1012. /package/dist/{chunk-3ZVACRTK.js.map → chunk-OITGZUDC.js.map} +0 -0
  1013. /package/dist/{chunk-GWJLR55B.js.map → chunk-OKD2LBMK.js.map} +0 -0
  1014. /package/dist/{chunk-K2WDXLZS.js.map → chunk-OSA4CGST.js.map} +0 -0
  1015. /package/dist/{chunk-TGVTVLNI.js.map → chunk-OXYAKUFU.js.map} +0 -0
  1016. /package/dist/{chunk-SUMBC7BQ.js.map → chunk-OYMSMU5O.js.map} +0 -0
  1017. /package/dist/{chunk-3XS3A6Y6.js.map → chunk-P4NZ72KY.js.map} +0 -0
  1018. /package/dist/{chunk-CYPNXHWM.js.map → chunk-PBYL2VIM.js.map} +0 -0
  1019. /package/dist/{chunk-UZAVFOZC.js.map → chunk-PDW3OOSZ.js.map} +0 -0
  1020. /package/dist/{chunk-6M2WXQX5.js.map → chunk-PGRKTQIW.js.map} +0 -0
  1021. /package/dist/{chunk-4PG2BEQA.js.map → chunk-PPQJIVGM.js.map} +0 -0
  1022. /package/dist/{chunk-UFRXYZCJ.js.map → chunk-PYMQM65Y.js.map} +0 -0
  1023. /package/dist/{chunk-GYNTJYWY.js.map → chunk-Q273Q33U.js.map} +0 -0
  1024. /package/dist/{chunk-UHU2WESP.js.map → chunk-Q4CLS2HL.js.map} +0 -0
  1025. /package/dist/{chunk-GYWQ4KVM.js.map → chunk-QA5UNVHD.js.map} +0 -0
  1026. /package/dist/{chunk-LLVJ3P2N.js.map → chunk-QFOBUA2J.js.map} +0 -0
  1027. /package/dist/{chunk-2MXP6ZRP.js.map → chunk-QLIM4D56.js.map} +0 -0
  1028. /package/dist/{chunk-KQVHSEQQ.js.map → chunk-QMQF5U2D.js.map} +0 -0
  1029. /package/dist/{chunk-IXPLYZFO.js.map → chunk-QNOWKKZ4.js.map} +0 -0
  1030. /package/dist/{chunk-PTUIF4TT.js.map → chunk-QPOUPVPD.js.map} +0 -0
  1031. /package/dist/{chunk-FE4HNBHF.js.map → chunk-QTJAQ6DS.js.map} +0 -0
  1032. /package/dist/{chunk-LK3AAMN7.js.map → chunk-QUOFP3G7.js.map} +0 -0
  1033. /package/dist/{chunk-6O6CHBD3.js.map → chunk-QVOTPOXK.js.map} +0 -0
  1034. /package/dist/{chunk-ROCQ3IDW.js.map → chunk-QYZ5RVGM.js.map} +0 -0
  1035. /package/dist/{chunk-TXAMGOUG.js.map → chunk-R7CVDKRN.js.map} +0 -0
  1036. /package/dist/{chunk-3ITEAD3E.js.map → chunk-RB7MXNZD.js.map} +0 -0
  1037. /package/dist/{chunk-KREVCOE7.js.map → chunk-RDZQFZOQ.js.map} +0 -0
  1038. /package/dist/{chunk-AI7XM4MY.js.map → chunk-RIHKEGWS.js.map} +0 -0
  1039. /package/dist/{chunk-YNRZN3TU.js.map → chunk-ROSB7GF6.js.map} +0 -0
  1040. /package/dist/{chunk-3MZCXSC7.js.map → chunk-RP3YMYCX.js.map} +0 -0
  1041. /package/dist/{chunk-U4OIE2MJ.js.map → chunk-RPHXJHNX.js.map} +0 -0
  1042. /package/dist/{chunk-CQW4ZPU4.js.map → chunk-RVC3M66H.js.map} +0 -0
  1043. /package/dist/{chunk-BMOYN4HY.js.map → chunk-S3OTJAAC.js.map} +0 -0
  1044. /package/dist/{chunk-2Y53MMGA.js.map → chunk-SBWPMVRN.js.map} +0 -0
  1045. /package/dist/{chunk-FT4ZKYTG.js.map → chunk-SERECSAR.js.map} +0 -0
  1046. /package/dist/{chunk-6V2UH36U.js.map → chunk-SHSEF3GJ.js.map} +0 -0
  1047. /package/dist/{chunk-2AU2S5NP.js.map → chunk-SMS2M3RG.js.map} +0 -0
  1048. /package/dist/{chunk-BY7AWWDB.js.map → chunk-SRDHDIRQ.js.map} +0 -0
  1049. /package/dist/{chunk-46USHCHK.js.map → chunk-SXRYA7NN.js.map} +0 -0
  1050. /package/dist/{chunk-NDJPEX7P.js.map → chunk-SYA3WYG4.js.map} +0 -0
  1051. /package/dist/{chunk-HUTQJY3F.js.map → chunk-SYYFA7W7.js.map} +0 -0
  1052. /package/dist/{chunk-L7ZLPS37.js.map → chunk-T2QDSTBH.js.map} +0 -0
  1053. /package/dist/{chunk-T6N33M46.js.map → chunk-TFSCGFYV.js.map} +0 -0
  1054. /package/dist/{chunk-XK4VFZHQ.js.map → chunk-TGCKZOSX.js.map} +0 -0
  1055. /package/dist/{chunk-GA42NSDJ.js.map → chunk-THILLYQM.js.map} +0 -0
  1056. /package/dist/{chunk-BZ4GSY44.js.map → chunk-TI6LGUEZ.js.map} +0 -0
  1057. /package/dist/{chunk-GISBCT5E.js.map → chunk-TSY6YZL2.js.map} +0 -0
  1058. /package/dist/{chunk-DD3DT5MY.js.map → chunk-TW2RHTLH.js.map} +0 -0
  1059. /package/dist/{chunk-RTJVIXH5.js.map → chunk-TWA5G277.js.map} +0 -0
  1060. /package/dist/{chunk-ZBTYTG4E.js.map → chunk-TZZ2S4XI.js.map} +0 -0
  1061. /package/dist/{chunk-VDHWFRTL.js.map → chunk-U5D3K53R.js.map} +0 -0
  1062. /package/dist/{chunk-WLRB74VH.js.map → chunk-UECD27LX.js.map} +0 -0
  1063. /package/dist/{chunk-HHUTU5EN.js.map → chunk-UFJDETKG.js.map} +0 -0
  1064. /package/dist/{chunk-PV7X4PRR.js.map → chunk-UHCFYX4I.js.map} +0 -0
  1065. /package/dist/{chunk-NLKHAZMG.js.map → chunk-UHTURYJO.js.map} +0 -0
  1066. /package/dist/{chunk-EBVL3YJQ.js.map → chunk-UJH63JT3.js.map} +0 -0
  1067. /package/dist/{chunk-5UI3VPCY.js.map → chunk-UOLDS6S5.js.map} +0 -0
  1068. /package/dist/{chunk-BMSMK7SA.js.map → chunk-UUE3OGXI.js.map} +0 -0
  1069. /package/dist/{chunk-WSBUFP77.js.map → chunk-UUNJ2E57.js.map} +0 -0
  1070. /package/dist/{chunk-NLYAWFDY.js.map → chunk-UYQVWRAH.js.map} +0 -0
  1071. /package/dist/{chunk-VAN6CEAV.js.map → chunk-UYWVK7JQ.js.map} +0 -0
  1072. /package/dist/{chunk-UBTDG6GC.js.map → chunk-UYWWUEL4.js.map} +0 -0
  1073. /package/dist/{chunk-2WF5XIPA.js.map → chunk-V4CQKX5H.js.map} +0 -0
  1074. /package/dist/{chunk-3NRJ4Z3A.js.map → chunk-V4QM7GDQ.js.map} +0 -0
  1075. /package/dist/{chunk-6LUF4TOE.js.map → chunk-V5Y74WII.js.map} +0 -0
  1076. /package/dist/{chunk-YUVS7HYN.js.map → chunk-VGGZLUQK.js.map} +0 -0
  1077. /package/dist/{chunk-35LBFD5I.js.map → chunk-VGX636MB.js.map} +0 -0
  1078. /package/dist/{chunk-WAVR3UIC.js.map → chunk-VGZLFQO2.js.map} +0 -0
  1079. /package/dist/{chunk-IMWP2Q4W.js.map → chunk-VJWZATNF.js.map} +0 -0
  1080. /package/dist/{chunk-DHLGGANG.js.map → chunk-VMWCIC2N.js.map} +0 -0
  1081. /package/dist/{chunk-UXZLTAJO.js.map → chunk-VPWKTIU5.js.map} +0 -0
  1082. /package/dist/{chunk-JTRRMV7B.js.map → chunk-VXOLG6YB.js.map} +0 -0
  1083. /package/dist/{chunk-7JNWIGM4.js.map → chunk-W2NAU5VB.js.map} +0 -0
  1084. /package/dist/{chunk-AP4FMXAM.js.map → chunk-WGORKMR3.js.map} +0 -0
  1085. /package/dist/{chunk-HTYDPAJL.js.map → chunk-WMIDELSJ.js.map} +0 -0
  1086. /package/dist/{chunk-SOC5IBQT.js.map → chunk-WSOSGL2G.js.map} +0 -0
  1087. /package/dist/{chunk-A7Z65D33.js.map → chunk-WXUUOM4X.js.map} +0 -0
  1088. /package/dist/{chunk-L4PIAAQB.js.map → chunk-WZ74QHLE.js.map} +0 -0
  1089. /package/dist/{chunk-M7NPDODK.js.map → chunk-X2OWM2ME.js.map} +0 -0
  1090. /package/dist/{chunk-B6YDINPE.js.map → chunk-X6UMGG4T.js.map} +0 -0
  1091. /package/dist/{chunk-YTUVANLR.js.map → chunk-XDXKB25W.js.map} +0 -0
  1092. /package/dist/{chunk-ACUDUVDJ.js.map → chunk-XE4PHI74.js.map} +0 -0
  1093. /package/dist/{chunk-R6WQLIFX.js.map → chunk-XHF2XNU5.js.map} +0 -0
  1094. /package/dist/{chunk-D4RTU236.js.map → chunk-XLJ4SQFS.js.map} +0 -0
  1095. /package/dist/{chunk-UKDLZ76A.js.map → chunk-XOD4FX6M.js.map} +0 -0
  1096. /package/dist/{chunk-YW4YRCXI.js.map → chunk-XODQ2GPF.js.map} +0 -0
  1097. /package/dist/{chunk-JOVCPP44.js.map → chunk-XT54RTAM.js.map} +0 -0
  1098. /package/dist/{chunk-R6OBJ7LF.js.map → chunk-YAVW5OJ5.js.map} +0 -0
  1099. /package/dist/{chunk-TD5EKKVD.js.map → chunk-YDQHFJM2.js.map} +0 -0
  1100. /package/dist/{chunk-UXBW2TYH.js.map → chunk-YH6O6OQ6.js.map} +0 -0
  1101. /package/dist/{chunk-6U3PE427.js.map → chunk-YIKPC2QP.js.map} +0 -0
  1102. /package/dist/{chunk-M72GFKDP.js.map → chunk-ZD7PKYC4.js.map} +0 -0
  1103. /package/dist/{chunk-S7NX6KSE.js.map → chunk-ZEQYHEWP.js.map} +0 -0
  1104. /package/dist/{chunk-2ZR75AUO.js.map → chunk-ZMYL6DTE.js.map} +0 -0
  1105. /package/dist/{chunk-GKA5LFYR.js.map → chunk-ZP3QCPYG.js.map} +0 -0
  1106. /package/dist/{chunk-V2A4I4GC.js.map → chunk-ZRVUCTSI.js.map} +0 -0
  1107. /package/dist/{chunk-CYPMAJ75.js.map → chunk-ZSI3ITRK.js.map} +0 -0
  1108. /package/dist/{chunk-XVP23IJS.js.map → chunk-ZZMEQCIZ.js.map} +0 -0
  1109. /package/dist/{computer-viewer-BWWVUD6J.js.map → computer-viewer-ZBY3BPYW.js.map} +0 -0
  1110. /package/dist/{connection-step-up-7ICLBORD.js.map → connection-step-up-JQ4OFSQN.js.map} +0 -0
  1111. /package/dist/{embedded-new-voice-VD6GR5JQ.js.map → embedded-new-voice-ZB5XLKLU.js.map} +0 -0
  1112. /package/dist/{embedded-voice-J2B6J2QQ.js.map → embedded-voice-MZJISDCS.js.map} +0 -0
  1113. /package/dist/{fleet-decision-row-B672XMNG.js.map → fleet-decision-row-LG3SYVR3.js.map} +0 -0
  1114. /package/dist/{model-policy-picker-menu-HT3TWGSS.js.map → model-policy-picker-menu-5Y72PLNF.js.map} +0 -0
  1115. /package/dist/{payment-page-card-4LZPJ3OK.js.map → payment-page-card-YPSXRHBA.js.map} +0 -0
  1116. /package/dist/{platform-activity-row-TWXWUCXD.js.map → platform-activity-row-ZU4MEBNK.js.map} +0 -0
  1117. /package/dist/{queue-surface-implementation-SQ7K2TM4.js.map → queue-surface-implementation-6Q25RPH6.js.map} +0 -0
  1118. /package/dist/{recorder-host-N2S7G3CW.js.map → recorder-host-JD4GWJ2Z.js.map} +0 -0
  1119. /package/dist/{sandbox-files-6CKWJ2CU.js.map → sandbox-files-HCLEEJMU.js.map} +0 -0
  1120. /package/dist/{session-connect-cards-VNQWMX7A.js.map → session-connect-cards-DRKEN3Z4.js.map} +0 -0
  1121. /package/dist/{session-realtime-CRG7DRV6.js.map → session-realtime-IZOTTRH6.js.map} +0 -0
  1122. /package/dist/{timeline-annotation-markers-JXCNK4S6.js.map → timeline-annotation-markers-WWXNJOXI.js.map} +0 -0
  1123. /package/dist/{timeline-annotation-selection-5ZTVYJXT.js.map → timeline-annotation-selection-ZKRIQFIQ.js.map} +0 -0
  1124. /package/dist/{timeline-annotations-dialog-4QWVCZCF.js.map → timeline-annotations-dialog-4IMKTOXJ.js.map} +0 -0
@@ -1,3110 +0,0 @@
1
- "use client";
2
- import {
3
- TRANSIENT_RECONNECT_INTERVAL_MS,
4
- isActionFailure,
5
- isCalmServiceFailure,
6
- isTransientServiceFailure,
7
- markActionFailure
8
- } from "./chunk-5AIMVW6Y.js";
9
- import {
10
- ComposerReconciliationRequiredError,
11
- ComposerStateError,
12
- ComposerWorkspaceControlUnavailableError,
13
- composerSubmissionCanRetry,
14
- composerSubmissionErrorMessage,
15
- isComposerSelectionRefusalMessage
16
- } from "./chunk-UIK52VL4.js";
17
- import {
18
- useSessionEventTrigger
19
- } from "./chunk-SW4S6I5E.js";
20
- import {
21
- normalizeError,
22
- useErrorMessage
23
- } from "./chunk-CM7LVUKC.js";
24
- import {
25
- useEmbeddedSession
26
- } from "./chunk-BVUAHAQX.js";
27
- import {
28
- useOpenGeniText
29
- } from "./chunk-6FWBGVFL.js";
30
-
31
- // src/hooks/use-composer.ts
32
- import {
33
- DEFAULT_FILE_RESOURCE_MOUNT_ROOT,
34
- OpenGeniApiError,
35
- isMaintenanceError
36
- } from "@opengeni/sdk";
37
- import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
38
-
39
- // src/lib/notify-observer.ts
40
- function notifyObserver(observer, ...args) {
41
- const report = (cause) => globalThis.reportError?.(cause);
42
- try {
43
- const result = observer?.(...args);
44
- if (result && typeof result.then === "function") {
45
- void Promise.resolve(result).catch(report);
46
- }
47
- } catch (cause) {
48
- report(cause);
49
- }
50
- }
51
-
52
- // src/hooks/use-composer.ts
53
- function initialComposerShadow(seed) {
54
- if (!seed || !seed.text && !seed.resources?.length && !seed.annotations?.length && !seed.policy)
55
- return void 0;
56
- return {
57
- text: seed.text,
58
- resources: [...seed.resources ?? []],
59
- annotations: cloneAnnotations(seed.annotations ?? []),
60
- ...seed.policy ? { policy: { ...seed.policy } } : {}
61
- };
62
- }
63
- var PENDING_COMPOSER_STORAGE_PREFIX = "opengeni.pending-composer.v1:";
64
- var OPTIMISTIC_SEND_STORAGE_PREFIX = "opengeni.optimistic-sends.v1:";
65
- var pendingComposerOperations = /* @__PURE__ */ new Map();
66
- var optimisticSendOperations = /* @__PURE__ */ new Map();
67
- function pendingComposerOperationKey(workspaceId, sessionId) {
68
- return sessionId ? `${workspaceId}\0${sessionId}` : null;
69
- }
70
- function pendingComposerStorage() {
71
- try {
72
- return typeof window === "undefined" ? null : window.sessionStorage;
73
- } catch {
74
- return null;
75
- }
76
- }
77
- function forgetAllComposerOperations() {
78
- pendingComposerOperations.clear();
79
- optimisticSendOperations.clear();
80
- const storage = pendingComposerStorage();
81
- if (!storage) return;
82
- try {
83
- const keys = [];
84
- for (let index = 0; index < storage.length; index += 1) {
85
- const key = storage.key(index);
86
- if (key?.startsWith(PENDING_COMPOSER_STORAGE_PREFIX) || key?.startsWith(OPTIMISTIC_SEND_STORAGE_PREFIX))
87
- keys.push(key);
88
- }
89
- for (const key of keys) storage.removeItem(key);
90
- } catch {
91
- }
92
- }
93
- function pendingComposerStorageKey(key) {
94
- return `${PENDING_COMPOSER_STORAGE_PREFIX}${encodeURIComponent(key)}`;
95
- }
96
- function optimisticSendStorageKey(key) {
97
- return `${OPTIMISTIC_SEND_STORAGE_PREFIX}${encodeURIComponent(key)}`;
98
- }
99
- function restoreOptimisticSendOperations(t, key, canBuyCredits = true) {
100
- if (!key) return [];
101
- let stored = optimisticSendOperations.get(key);
102
- if (!stored) {
103
- const storage = pendingComposerStorage();
104
- try {
105
- const parsed = JSON.parse(storage?.getItem(optimisticSendStorageKey(key)) ?? "[]");
106
- stored = Array.isArray(parsed) ? parsed.filter(
107
- (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"
108
- ) : [];
109
- } catch {
110
- stored = [];
111
- }
112
- }
113
- return stored.map(({ hasMcpCredentialUpdates, ...operation }) => ({
114
- ...operation,
115
- delivery: "send",
116
- steerOrSend: operation.steerOrSend === true,
117
- destination: operation.destination === "queue" ? "queue" : "chat",
118
- newerShadow: operation.newerShadow ?? { text: "", resources: [], annotations: [] },
119
- state: operation.state === "sending" || operation.state === "queued" ? "sending" : operation.state,
120
- outcomeUnknown: operation.state === "sending" || operation.state === "queued" ? true : operation.outcomeUnknown,
121
- correlationId: restoredCorrelationId(operation.correlationId),
122
- error: restoredErrorReference(
123
- t,
124
- operation.correlationId,
125
- 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
126
- ),
127
- retryable: operation.state === "sending" || operation.outcomeUnknown ? true : operation.retryable ?? (operation.error ? composerSubmissionCanRetry(new Error(operation.error)) : true),
128
- input: operation.input,
129
- canRetry: !hasMcpCredentialUpdates
130
- }));
131
- }
132
- function restoredCorrelationId(value) {
133
- return typeof value === "string" && /^[\w.:-]{1,128}$/u.test(value) ? value : void 0;
134
- }
135
- function rejectsSteerOrSend(error) {
136
- return error instanceof OpenGeniApiError && (error.status === 400 || error.status === 422) && /\bdelivery\b/u.test(`${error.message}
137
- ${error.body}`);
138
- }
139
- function restoredErrorReference(t, reference, message) {
140
- const correlationId = restoredCorrelationId(reference);
141
- return message && correlationId && !isComposerSelectionRefusalMessage(message) && message !== t("lib.format.modelUnavailable") && message !== t("lib.format.accountUnavailable") ? t("hooks.useComposer.messageReferenceCorrelationid", { message, correlationId }) : message;
142
- }
143
- function rememberOptimisticSendOperations(key, operations) {
144
- if (!key) return;
145
- const stored = operations.filter((operation) => operation.state !== "queued").map((operation) => {
146
- const { canRetry: _canRetry, input, ...rest } = operation;
147
- const { mcpCredentialUpdates: _credentials, ...safeInput } = input;
148
- return {
149
- ...rest,
150
- input: safeInput,
151
- hasMcpCredentialUpdates: input.mcpCredentialUpdates !== void 0
152
- };
153
- });
154
- if (stored.length === 0) {
155
- optimisticSendOperations.delete(key);
156
- try {
157
- pendingComposerStorage()?.removeItem(optimisticSendStorageKey(key));
158
- } catch {
159
- }
160
- return;
161
- }
162
- optimisticSendOperations.set(key, stored);
163
- try {
164
- pendingComposerStorage()?.setItem(optimisticSendStorageKey(key), JSON.stringify(stored));
165
- } catch {
166
- }
167
- }
168
- function resourceList(value) {
169
- return Array.isArray(value) && value.every((candidate) => {
170
- if (typeof candidate !== "object" || candidate === null) return false;
171
- const resource = candidate;
172
- return resource.kind === "file" ? typeof resource.fileId === "string" : resource.kind === "repository" && typeof resource.uri === "string" && typeof resource.ref === "string";
173
- });
174
- }
175
- function timelineAnnotationList(value) {
176
- return Array.isArray(value) && value.every((candidate) => {
177
- if (typeof candidate !== "object" || candidate === null) return false;
178
- const annotation = candidate;
179
- const source = annotation.source;
180
- if (typeof source !== "object" || source === null) return false;
181
- const sourceRecord = source;
182
- 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";
183
- });
184
- }
185
- function cloneAnnotations(annotations) {
186
- return annotations.map((annotation) => ({
187
- ...annotation,
188
- source: { ...annotation.source }
189
- }));
190
- }
191
- function readStoredPendingComposerOperation(key) {
192
- const storage = key ? pendingComposerStorage() : null;
193
- if (!storage || !key) return null;
194
- try {
195
- const parsed = JSON.parse(storage.getItem(pendingComposerStorageKey(key)) ?? "null");
196
- if (typeof parsed !== "object" || parsed === null) return null;
197
- const record = parsed;
198
- const input = record.input;
199
- const shadow = record.newerShadow;
200
- if (typeof input !== "object" || input === null || typeof shadow !== "object" || shadow === null) {
201
- return null;
202
- }
203
- const inputRecord = input;
204
- const shadowRecord = shadow;
205
- 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)) {
206
- return null;
207
- }
208
- return {
209
- ...record,
210
- steerOrSend: record.steerOrSend === true,
211
- annotationsAtSend: timelineAnnotationList(record.annotationsAtSend) ? record.annotationsAtSend : [],
212
- newerShadow: {
213
- ...shadow,
214
- annotations: timelineAnnotationList(shadowRecord.annotations) ? shadowRecord.annotations : []
215
- }
216
- };
217
- } catch {
218
- return null;
219
- }
220
- }
221
- function writePendingComposerOperation(key, operation) {
222
- const storage = pendingComposerStorage();
223
- if (!storage) return;
224
- try {
225
- storage.setItem(pendingComposerStorageKey(key), JSON.stringify(operation));
226
- } catch {
227
- }
228
- }
229
- function restorePendingComposerOperation(key) {
230
- const stored = (key && pendingComposerOperations.get(key)) ?? readStoredPendingComposerOperation(key);
231
- if (!stored) return null;
232
- return {
233
- ...stored,
234
- input: stored.input,
235
- newerShadow: stored.newerShadow ?? {
236
- text: stored.draftAtSend,
237
- resources: stored.resourcesAtSend,
238
- annotations: stored.annotationsAtSend
239
- },
240
- canRetry: !stored.hasMcpCredentialUpdates
241
- };
242
- }
243
- function rememberPendingComposerOperation(key, operation) {
244
- if (!key) return;
245
- const { canRetry: _retry, ...safeOperation } = operation;
246
- const { input: originalInput, ...withoutInput } = safeOperation;
247
- const { mcpCredentialUpdates: _storedMcp, ...safeInput } = originalInput;
248
- const stored = {
249
- ...withoutInput,
250
- input: safeInput,
251
- hasMcpCredentialUpdates: operation.input.mcpCredentialUpdates !== void 0,
252
- newerShadow: {
253
- text: operation.newerShadow.text,
254
- resources: [...operation.newerShadow.resources],
255
- annotations: cloneAnnotations(operation.newerShadow.annotations),
256
- ...operation.newerShadow.policy ? { policy: { ...operation.newerShadow.policy } } : {}
257
- }
258
- };
259
- pendingComposerOperations.set(key, stored);
260
- writePendingComposerOperation(key, stored);
261
- }
262
- function forgetPendingComposerOperation(key) {
263
- if (!key) return;
264
- pendingComposerOperations.delete(key);
265
- const storage = pendingComposerStorage();
266
- if (!storage) return;
267
- try {
268
- storage.removeItem(pendingComposerStorageKey(key));
269
- } catch {
270
- }
271
- }
272
- function updatePendingComposerShadow(key, operation, shadow) {
273
- if (!key || !operation) return operation;
274
- const next = {
275
- ...operation,
276
- newerShadow: {
277
- ...shadow,
278
- resources: [...shadow.resources],
279
- annotations: cloneAnnotations(shadow.annotations)
280
- }
281
- };
282
- rememberPendingComposerOperation(key, next);
283
- return next;
284
- }
285
- var SERVICE_SEND_RETRY_MAX_DELAY_MS = 8e3;
286
- var STEERING_SETTLEMENT_EVENT_TYPES = /* @__PURE__ */ new Set([
287
- "turn.started",
288
- "turn.completed",
289
- "turn.failed",
290
- "turn.cancelled",
291
- "turn.superseded"
292
- ]);
293
- function isSteeringSettlementEvent(event) {
294
- return STEERING_SETTLEMENT_EVENT_TYPES.has(event.type);
295
- }
296
- function steeringAcceptedEvent(steering, events) {
297
- return events.find(
298
- (event) => event.type === "user.message" && steering.clientEventId !== null && event.clientEventId === steering.clientEventId
299
- );
300
- }
301
- function promptTurnIdForTrigger(triggerEventId, events) {
302
- if (!triggerEventId) return null;
303
- const queued = events.find((event) => {
304
- if (event.type !== "turn.queued") return false;
305
- const payload2 = event.payload;
306
- return typeof payload2 === "object" && payload2 !== null && "triggerEventId" in payload2 && payload2.triggerEventId === triggerEventId;
307
- });
308
- if (!queued) return null;
309
- if (queued.turnId) return queued.turnId;
310
- const payload = queued.payload;
311
- return typeof payload === "object" && payload !== null && "turnId" in payload && typeof payload.turnId === "string" ? payload.turnId : null;
312
- }
313
- function steeringSettledByEvents(steering, events) {
314
- const acceptedEventId = steering.triggerEventId ?? steeringAcceptedEvent(steering, events)?.id ?? null;
315
- return events.some((event) => {
316
- if (steering.turnId && event.turnId === steering.turnId && isSteeringSettlementEvent(event)) {
317
- return true;
318
- }
319
- if (event.type !== "turn.started" || !acceptedEventId) return false;
320
- const payload = event.payload;
321
- return typeof payload === "object" && payload !== null && "triggerEventId" in payload && payload.triggerEventId === acceptedEventId;
322
- });
323
- }
324
- function reconcileOptimisticSendFromEvents(operation, events) {
325
- const accepted = events.find(
326
- (event) => event.type === "user.message" && event.clientEventId === operation.clientEventId
327
- );
328
- const triggerEventId = operation.triggerEventId ?? accepted?.id ?? null;
329
- const turnId = operation.turnId ?? promptTurnIdForTrigger(triggerEventId, events);
330
- const acceptedRouting = promptRoutingFromAcceptedEvent(accepted ?? null);
331
- const destination = acceptedRouting === "queued_for_execution" ? "queue" : acceptedRouting === "accepted_for_execution" || acceptedRouting === "accepted_for_steering" ? "chat" : operation.destination;
332
- const needsAdmissionUpdate = accepted !== void 0 && (operation.state !== "queued" || operation.destination !== destination || operation.triggerEventId !== triggerEventId || operation.turnId !== turnId || operation.error !== void 0 || operation.outcomeUnknown !== false);
333
- const reconciled = needsAdmissionUpdate ? {
334
- ...operation,
335
- state: "queued",
336
- destination,
337
- triggerEventId,
338
- turnId,
339
- error: void 0,
340
- outcomeUnknown: false
341
- } : operation;
342
- const withdrawnFromQueue = events.some((event) => {
343
- if (event.type !== "session.queue.changed" || !turnId) return false;
344
- const payload = event.payload;
345
- if (typeof payload !== "object" || payload === null || Array.isArray(payload)) return false;
346
- const record = payload;
347
- return record.turnId === turnId && (record.operation === "edit" || record.operation === "delete");
348
- });
349
- return {
350
- operation: reconciled,
351
- admitted: accepted !== void 0,
352
- // Edit/Delete atomically withdraw the queued turn. Keeping its optimistic
353
- // send alive after that point lets its old `newerShadow` become the newest
354
- // composer draft again when a later turn settles, duplicating submitted
355
- // text. The queue mutation is the durable terminal fact for this send.
356
- settled: withdrawnFromQueue || steeringSettledByEvents(
357
- {
358
- phase: "accepted",
359
- text: reconciled.text,
360
- clientEventId: reconciled.clientEventId,
361
- triggerEventId: reconciled.triggerEventId ?? null,
362
- turnId: reconciled.turnId ?? null
363
- },
364
- events
365
- )
366
- };
367
- }
368
- function useComposer(sessionId, options = {}) {
369
- const t = useOpenGeniText();
370
- const { client, workspaceId, registerSessionReconciler, workspaceDraftsEvent } = useEmbeddedSession(options);
371
- const formatError = useErrorMessage();
372
- const durableDrafts = options.draftPersistence !== "disabled";
373
- if (!durableDrafts && !options.initialPolicy) {
374
- throw new Error("useComposer requires initialPolicy when draft persistence is disabled");
375
- }
376
- const targetKey = `${workspaceId}\0${sessionId ?? ""}\0${durableDrafts ? "durable" : "disabled"}`;
377
- const pendingOperationKey = pendingComposerOperationKey(workspaceId, sessionId);
378
- const initialPendingOperation = restorePendingComposerOperation(pendingOperationKey);
379
- const initialOptimisticSends = restoreOptimisticSendOperations(
380
- t,
381
- pendingOperationKey,
382
- options.canBuyCredits ?? true
383
- );
384
- const initialShadow = initialPendingOperation?.newerShadow ?? initialOptimisticSends.at(-1)?.newerShadow ?? initialComposerShadow(options.initialDraft);
385
- const [value, setValue] = useState(() => initialShadow?.text ?? "");
386
- const [annotations, setAnnotations] = useState(
387
- () => initialShadow?.annotations ?? []
388
- );
389
- const [annotationReviewTargetId, setAnnotationReviewTargetId] = useState(null);
390
- const [stateTargetKey, setStateTargetKey] = useState(targetKey);
391
- const [sending, setSending] = useState(false);
392
- const [optimisticSends, setOptimisticSends] = useState(initialOptimisticSends);
393
- const [steering, setSteering] = useState(
394
- () => initialPendingOperation?.delivery === "steer" ? {
395
- phase: "failed",
396
- text: initialPendingOperation.input.text,
397
- clientEventId: initialPendingOperation.input.clientEventId ?? null,
398
- triggerEventId: null,
399
- turnId: null,
400
- error: t("hooks.useComposer.notConfirmedRetryToCheck"),
401
- outcomeUnknown: true
402
- } : null
403
- );
404
- const [pausing, setPausing] = useState(false);
405
- const [acceptedControl, setAcceptedControl] = useState(null);
406
- const [resuming, setResuming] = useState(false);
407
- const [error, setError] = useState(null);
408
- const [draftReadError, setDraftReadError] = useState(null);
409
- const [draftHydrationRetrying, setDraftHydrationRetrying] = useState(false);
410
- const [draft, setDraft] = useState(null);
411
- const [draftLoading, setDraftLoading] = useState(Boolean(sessionId) && durableDrafts);
412
- const [draftSaving, setDraftSaving] = useState(false);
413
- const [draftConflict, setDraftConflict] = useState(null);
414
- const [policy, setPolicy] = useState(
415
- () => initialShadow?.policy ?? options.initialPolicy ?? null
416
- );
417
- const [restoredResources, setRestoredResources] = useState(
418
- () => initialShadow?.resources ?? []
419
- );
420
- const pendingOperationRef = useRef(initialPendingOperation);
421
- const optimisticSendsRef = useRef(initialOptimisticSends);
422
- const optimisticProcessorBusyRef = useRef(false);
423
- const serviceWaitRef = useRef(
424
- /* @__PURE__ */ new Map()
425
- );
426
- const serviceRetryTimerRef = useRef(null);
427
- const processOptimisticSendsRef = useRef(() => void 0);
428
- const [serviceWaiting, setServiceWaiting] = useState(false);
429
- const [autosaveRetry, setAutosaveRetry] = useState(0);
430
- const optimisticCallbackIdsRef = useRef(/* @__PURE__ */ new Set());
431
- const steeringSettlementEventsRef = useRef([]);
432
- const steeringRef = useRef(steering);
433
- const steeringOccurredAtRef = useRef((/* @__PURE__ */ new Date()).toISOString());
434
- const pendingClientEventId = useRef(
435
- initialPendingOperation?.input.clientEventId ?? null
436
- );
437
- const valueRef = useRef(initialShadow?.text ?? "");
438
- const annotationsRef = useRef(initialShadow?.annotations ?? []);
439
- const policyRef = useRef(
440
- initialShadow?.policy ?? options.initialPolicy ?? null
441
- );
442
- const policyPickedRef = useRef(!durableDrafts || initialShadow?.policy !== void 0);
443
- const [policyPicked, setPolicyPicked] = useState(policyPickedRef.current);
444
- const draftRef = useRef(null);
445
- const restoredResourcesRef = useRef(initialShadow?.resources ?? []);
446
- const localEditRevision = useRef(initialShadow ? 1 : 0);
447
- const targetGeneration = useRef(0);
448
- const draftReadGeneration = useRef(0);
449
- const draftReadInFlightRef = useRef(null);
450
- const draftRereadPendingRef = useRef(null);
451
- const draftReadAbortRef = useRef(null);
452
- const draftReadRetryRef = useRef({ targetKey, failures: 0, timer: null });
453
- const lastSavedSignature = useRef(null);
454
- const sendBasisRef = useRef(null);
455
- const saveChain = useRef(Promise.resolve());
456
- const savePickPromptlyRef = useRef(false);
457
- const unsavedDraftRef = useRef(null);
458
- const settledWritesRef = useRef(/* @__PURE__ */ new Map());
459
- const draftFencedSendRef = useRef(false);
460
- const draftWriteUnconfirmedRef = useRef(false);
461
- const unkeptSendRef = useRef(null);
462
- const onSentRef = useRef(options.onSent);
463
- onSentRef.current = options.onSent;
464
- const onSubmittedRef = useRef(options.onSubmitted);
465
- onSubmittedRef.current = options.onSubmitted;
466
- const onSent = useCallback((text, input) => {
467
- notifyObserver(onSentRef.current, text, input);
468
- }, []);
469
- const onSubmitted = useCallback((text, input) => {
470
- notifyObserver(onSubmittedRef.current, text, input);
471
- }, []);
472
- const onDeliveryErrorRef = useRef(options.onDeliveryError);
473
- onDeliveryErrorRef.current = options.onDeliveryError;
474
- useLayoutEffect(() => {
475
- steeringRef.current = steering;
476
- }, [steering]);
477
- const sendExtrasRef = useRef(options.sendExtras);
478
- sendExtrasRef.current = options.sendExtras;
479
- const sendDestinationRef = useRef(options.sendDestination);
480
- sendDestinationRef.current = options.sendDestination;
481
- const busySend = options.busySend ?? "queue";
482
- const busySendRef = useRef(busySend);
483
- busySendRef.current = busySend;
484
- const steerOrSendUnsupportedRef = useRef(false);
485
- const singleSend = busySend === "steer" && options.offerQueue !== true;
486
- const sendBlockedRef = useRef(options.sendBlocked);
487
- sendBlockedRef.current = options.sendBlocked;
488
- const canBuyCreditsRef = useRef(options.canBuyCredits ?? true);
489
- canBuyCreditsRef.current = options.canBuyCredits ?? true;
490
- const effectiveControlRef = useRef(
491
- acceptedControl ?? options.effectiveControl ?? null
492
- );
493
- effectiveControlRef.current = acceptedControl ?? options.effectiveControl ?? null;
494
- const liveExtrasVersion = JSON.stringify(resolveSendExtras(options.sendExtras));
495
- const targetKeyRef = useRef(targetKey);
496
- useLayoutEffect(() => {
497
- if (targetKeyRef.current === targetKey) return;
498
- saveLeftDraft(unsavedDraftRef, settledWritesRef.current, saveChain.current);
499
- if (draftReadRetryRef.current.timer !== null) {
500
- clearTimeout(draftReadRetryRef.current.timer);
501
- }
502
- draftReadAbortRef.current?.abort();
503
- draftReadAbortRef.current = null;
504
- draftReadRetryRef.current = { targetKey, failures: 0, timer: null };
505
- targetKeyRef.current = targetKey;
506
- targetGeneration.current += 1;
507
- draftReadGeneration.current += 1;
508
- pendingOperationRef.current = restorePendingComposerOperation(pendingOperationKey);
509
- const restoredOptimisticSends = restoreOptimisticSendOperations(
510
- t,
511
- pendingOperationKey,
512
- canBuyCreditsRef.current
513
- );
514
- optimisticSendsRef.current = restoredOptimisticSends;
515
- optimisticProcessorBusyRef.current = false;
516
- serviceWaitRef.current = /* @__PURE__ */ new Map();
517
- if (serviceRetryTimerRef.current !== null) clearTimeout(serviceRetryTimerRef.current);
518
- serviceRetryTimerRef.current = null;
519
- setServiceWaiting(false);
520
- optimisticCallbackIdsRef.current = /* @__PURE__ */ new Set();
521
- steeringSettlementEventsRef.current = [];
522
- pendingClientEventId.current = pendingOperationRef.current?.input.clientEventId ?? null;
523
- const shadow = pendingOperationRef.current?.newerShadow ?? restoredOptimisticSends.at(-1)?.newerShadow ?? initialComposerShadow(options.initialDraft);
524
- localEditRevision.current = shadow ? 1 : 0;
525
- valueRef.current = shadow?.text ?? "";
526
- annotationsRef.current = shadow?.annotations ?? [];
527
- policyRef.current = shadow?.policy ?? options.initialPolicy ?? null;
528
- policyPickedRef.current = !durableDrafts || shadow?.policy !== void 0;
529
- setPolicyPicked(policyPickedRef.current);
530
- draftRef.current = null;
531
- sendBasisRef.current = null;
532
- draftWriteUnconfirmedRef.current = false;
533
- restoredResourcesRef.current = shadow?.resources ?? [];
534
- lastSavedSignature.current = null;
535
- savePickPromptlyRef.current = false;
536
- saveChain.current = Promise.resolve();
537
- setStateTargetKey(targetKey);
538
- setValue(shadow?.text ?? "");
539
- setAnnotations(shadow?.annotations ?? []);
540
- setPolicy(policyRef.current);
541
- setAnnotationReviewTargetId(null);
542
- setSending(false);
543
- setOptimisticSends(restoredOptimisticSends);
544
- setSteering(
545
- pendingOperationRef.current?.delivery === "steer" ? {
546
- phase: "failed",
547
- text: pendingOperationRef.current.input.text,
548
- clientEventId: pendingOperationRef.current.input.clientEventId ?? null,
549
- triggerEventId: null,
550
- turnId: null,
551
- error: t("hooks.useComposer.notConfirmedRetryToCheck"),
552
- outcomeUnknown: true
553
- } : null
554
- );
555
- setPausing(false);
556
- setAcceptedControl(null);
557
- setResuming(false);
558
- setError(null);
559
- setDraftReadError(null);
560
- setDraftHydrationRetrying(false);
561
- setDraft(null);
562
- setDraftLoading(Boolean(sessionId) && durableDrafts);
563
- setDraftSaving(false);
564
- setDraftConflict(null);
565
- setRestoredResources(shadow?.resources ?? []);
566
- }, [
567
- durableDrafts,
568
- options.initialPolicy,
569
- options.initialDraft,
570
- pendingOperationKey,
571
- sessionId,
572
- targetKey,
573
- t
574
- ]);
575
- useEffect(
576
- () => () => {
577
- saveLeftDraft(unsavedDraftRef, settledWritesRef.current, saveChain.current);
578
- if (draftReadRetryRef.current.timer !== null) {
579
- clearTimeout(draftReadRetryRef.current.timer);
580
- }
581
- if (serviceRetryTimerRef.current !== null) clearTimeout(serviceRetryTimerRef.current);
582
- serviceRetryTimerRef.current = null;
583
- targetGeneration.current += 1;
584
- draftReadGeneration.current += 1;
585
- draftReadInFlightRef.current = null;
586
- draftRereadPendingRef.current = null;
587
- draftReadAbortRef.current?.abort();
588
- draftReadAbortRef.current = null;
589
- },
590
- []
591
- );
592
- const setOptimisticDraftShadow = useCallback(
593
- (shadow) => {
594
- if (optimisticSendsRef.current.length === 0) return;
595
- const next = optimisticSendsRef.current.map((operation) => ({
596
- ...operation,
597
- newerShadow: {
598
- text: shadow.text,
599
- resources: [...shadow.resources],
600
- annotations: cloneAnnotations(shadow.annotations),
601
- ...shadow.policy ? { policy: { ...shadow.policy } } : {}
602
- }
603
- }));
604
- optimisticSendsRef.current = next;
605
- rememberOptimisticSendOperations(pendingOperationKey, next);
606
- setOptimisticSends(next);
607
- },
608
- [pendingOperationKey]
609
- );
610
- const applyDraft = useCallback(
611
- (next) => {
612
- if (targetKeyRef.current !== targetKey) return;
613
- if (!durableDrafts) {
614
- const nextPolicy2 = policyFromDraft(next);
615
- localEditRevision.current += 1;
616
- valueRef.current = next.text;
617
- annotationsRef.current = next.annotations ?? [];
618
- policyRef.current = nextPolicy2;
619
- restoredResourcesRef.current = next.resources;
620
- draftRef.current = null;
621
- sendBasisRef.current = null;
622
- lastSavedSignature.current = null;
623
- setDraft(null);
624
- setValue(next.text);
625
- setAnnotations(next.annotations ?? []);
626
- setPolicy(nextPolicy2);
627
- setRestoredResources(next.resources);
628
- pendingOperationRef.current = updatePendingComposerShadow(
629
- pendingOperationKey,
630
- pendingOperationRef.current,
631
- {
632
- text: next.text,
633
- resources: mergeResources(
634
- next.resources,
635
- resolveSendExtras(sendExtrasRef.current).resources ?? []
636
- ),
637
- annotations: next.annotations ?? [],
638
- policy: nextPolicy2
639
- }
640
- );
641
- setOptimisticDraftShadow({
642
- text: next.text,
643
- resources: mergeResources(
644
- next.resources,
645
- resolveSendExtras(sendExtrasRef.current).resources ?? []
646
- ),
647
- annotations: next.annotations ?? [],
648
- policy: nextPolicy2
649
- });
650
- setDraftConflict(null);
651
- return;
652
- }
653
- const nextPolicy = policyFromDraft(next);
654
- valueRef.current = next.text;
655
- annotationsRef.current = next.annotations ?? [];
656
- policyRef.current = nextPolicy;
657
- policyPickedRef.current = !next.policyFollowsSession;
658
- setPolicyPicked(policyPickedRef.current);
659
- draftRef.current = next;
660
- sendBasisRef.current = next.revision;
661
- restoredResourcesRef.current = next.resources;
662
- lastSavedSignature.current = draftSignature(draftPayload(next));
663
- localEditRevision.current += 1;
664
- setDraft(next);
665
- setValue(next.text);
666
- setAnnotations(next.annotations ?? []);
667
- setPolicy(nextPolicy);
668
- setRestoredResources(next.resources);
669
- pendingOperationRef.current = updatePendingComposerShadow(
670
- pendingOperationKey,
671
- pendingOperationRef.current,
672
- {
673
- text: next.text,
674
- resources: mergeResources(
675
- next.resources,
676
- resolveSendExtras(sendExtrasRef.current).resources ?? []
677
- ),
678
- annotations: next.annotations ?? [],
679
- policy: pickedPolicy(policyPickedRef, policyRef)
680
- }
681
- );
682
- setOptimisticDraftShadow({
683
- text: next.text,
684
- resources: mergeResources(
685
- next.resources,
686
- resolveSendExtras(sendExtrasRef.current).resources ?? []
687
- ),
688
- annotations: next.annotations ?? [],
689
- policy: pickedPolicy(policyPickedRef, policyRef)
690
- });
691
- setDraftConflict(null);
692
- },
693
- [durableDrafts, pendingOperationKey, setOptimisticDraftShadow, targetKey]
694
- );
695
- const keepNewerDraftAfterSend = useCallback(() => {
696
- const base = draftRef.current;
697
- if (!base || !policyRef.current || valueRef.current !== "" || restoredResourcesRef.current.length > 0 || annotationsRef.current.length > 0) {
698
- return;
699
- }
700
- lastSavedSignature.current = draftSignature(
701
- composerDraftPayload(
702
- base,
703
- valueRef.current,
704
- restoredResourcesRef.current,
705
- annotationsRef.current,
706
- pickedPolicy(policyPickedRef, policyRef),
707
- resolveSendExtras(sendExtrasRef.current).resources ?? []
708
- )
709
- );
710
- }, []);
711
- const loadDraft = useCallback(
712
- async (replaceLocal) => {
713
- if (targetKeyRef.current !== targetKey) return;
714
- if (!sessionId || !durableDrafts) {
715
- setDraftLoading(false);
716
- setDraftReadError(null);
717
- setDraftHydrationRetrying(false);
718
- return;
719
- }
720
- let retry = draftReadRetryRef.current;
721
- if (retry.targetKey !== targetKey) {
722
- if (retry.timer !== null) clearTimeout(retry.timer);
723
- retry = { targetKey, failures: 0, timer: null };
724
- draftReadRetryRef.current = retry;
725
- }
726
- const scheduleRetry = () => {
727
- if (retry.timer !== null) return;
728
- retry.timer = setTimeout(
729
- () => {
730
- if (draftReadRetryRef.current !== retry || targetKeyRef.current !== targetKey) return;
731
- retry.timer = null;
732
- void loadDraft(false);
733
- },
734
- Math.min(25e3, 1e3 * 2 ** (retry.failures - 1)) * (0.8 + Math.random() * 0.4)
735
- );
736
- };
737
- if (!replaceLocal && retry.timer !== null) return;
738
- if (draftReadInFlightRef.current === targetKey) {
739
- if (!replaceLocal) draftRereadPendingRef.current = targetKey;
740
- return;
741
- }
742
- if (retry.timer !== null) {
743
- clearTimeout(retry.timer);
744
- retry.timer = null;
745
- }
746
- draftReadInFlightRef.current = targetKey;
747
- const generation = targetGeneration.current;
748
- const readTicket = ++draftReadGeneration.current;
749
- const requestAbort = new AbortController();
750
- draftReadAbortRef.current?.abort();
751
- draftReadAbortRef.current = requestAbort;
752
- const localAtStart = localEditRevision.current;
753
- const baseAtStart = draftRef.current;
754
- const policyAtStart = policyRef.current;
755
- const localSignatureAtStart = baseAtStart ? policyAtStart ? draftSignature(
756
- composerDraftPayload(
757
- baseAtStart,
758
- valueRef.current,
759
- restoredResourcesRef.current,
760
- annotationsRef.current,
761
- pickedPolicy(policyPickedRef, policyRef),
762
- resolveSendExtras(sendExtrasRef.current).resources ?? []
763
- )
764
- ) : null : null;
765
- const localWasDirtyAtStart = localSignatureAtStart === null ? localAtStart !== 0 : localSignatureAtStart !== lastSavedSignature.current;
766
- const showLoading = replaceLocal || draftRef.current === null;
767
- if (showLoading) {
768
- setDraftLoading(true);
769
- }
770
- try {
771
- const leftSave = leftDraftSaves.get(`${workspaceId}\0${sessionId}`);
772
- if (leftSave) await Promise.race([leftSave, delay(LEFT_DRAFT_SAVE_WAIT_MS)]);
773
- const fetched = await client.getComposerDraft(workspaceId, sessionId, {
774
- signal: requestAbort.signal
775
- });
776
- if (generation !== targetGeneration.current || targetKeyRef.current !== targetKey || readTicket !== draftReadGeneration.current) {
777
- return;
778
- }
779
- if (retry.timer !== null) clearTimeout(retry.timer);
780
- retry.failures = 0;
781
- retry.timer = null;
782
- setDraftReadError(null);
783
- setDraftHydrationRetrying(false);
784
- const currentRevision = draftRef.current?.revision ?? -1;
785
- const adoptFetchedPolicy = () => {
786
- const fetchedPolicy = policyFromDraft(fetched);
787
- policyPickedRef.current = !fetched.policyFollowsSession;
788
- setPolicyPicked(policyPickedRef.current);
789
- if (samePolicy(policyRef.current, fetchedPolicy)) return;
790
- policyRef.current = fetchedPolicy;
791
- setPolicy(fetchedPolicy);
792
- };
793
- if (replaceLocal || fetched.revision > currentRevision) {
794
- const fetchedIsSendBasis = currentRevision === -1 || !composerDraftHasContent(fetched) || isPageDraftWrite(
795
- `${workspaceId}\0${sessionId}`,
796
- draftContentKey(draftPayload(fetched))
797
- );
798
- draftRef.current = fetched;
799
- setDraft(fetched);
800
- setDraftConflict(null);
801
- const shadow = pendingOperationRef.current?.newerShadow ?? optimisticSendsRef.current.at(-1)?.newerShadow;
802
- if (shadow) {
803
- if (fetchedIsSendBasis) sendBasisRef.current = fetched.revision;
804
- valueRef.current = shadow.text;
805
- restoredResourcesRef.current = shadow.resources;
806
- annotationsRef.current = shadow.annotations;
807
- if (shadow.policy) {
808
- policyRef.current = shadow.policy;
809
- policyPickedRef.current = true;
810
- setPolicyPicked(policyPickedRef.current);
811
- } else if (!policyPickedRef.current) {
812
- adoptFetchedPolicy();
813
- }
814
- localEditRevision.current ||= 1;
815
- setValue(shadow.text);
816
- setRestoredResources(shadow.resources);
817
- setAnnotations(shadow.annotations);
818
- if (shadow.policy) setPolicy(shadow.policy);
819
- const fetchedContent = draftContentKey(draftPayload(fetched));
820
- const fetchedKeepsSend = [
821
- pendingOperationRef.current?.draftPayload,
822
- ...optimisticSendsRef.current.map((operation) => operation.draftPayload)
823
- ].some((payload) => payload && draftContentKey(payload) === fetchedContent);
824
- if (!fetchedIsSendBasis || fetchedKeepsSend) keepNewerDraftAfterSend();
825
- } else if (replaceLocal || !localWasDirtyAtStart && localAtStart === localEditRevision.current) {
826
- sendBasisRef.current = fetched.revision;
827
- valueRef.current = fetched.text;
828
- restoredResourcesRef.current = fetched.resources;
829
- annotationsRef.current = fetched.annotations ?? [];
830
- policyRef.current = policyFromDraft(fetched);
831
- policyPickedRef.current = !fetched.policyFollowsSession;
832
- setPolicyPicked(policyPickedRef.current);
833
- lastSavedSignature.current = draftSignature(draftPayload(fetched));
834
- setValue(fetched.text);
835
- setRestoredResources(fetched.resources);
836
- setAnnotations(fetched.annotations ?? []);
837
- setPolicy(policyRef.current);
838
- } else {
839
- if (fetchedIsSendBasis) sendBasisRef.current = fetched.revision;
840
- lastSavedSignature.current = draftSignature(draftPayload(fetched));
841
- if (!policyRef.current || !policyPickedRef.current) adoptFetchedPolicy();
842
- if (!fetchedIsSendBasis) keepNewerDraftAfterSend();
843
- }
844
- } else if (fetched.revision === currentRevision && fetched.policyFollowsSession && !policyPickedRef.current && !samePolicy(policyRef.current, policyFromDraft(fetched))) {
845
- draftRef.current = fetched;
846
- setDraft(fetched);
847
- adoptFetchedPolicy();
848
- }
849
- } catch (cause) {
850
- if (!requestAbort.signal.aborted && generation === targetGeneration.current && targetKeyRef.current === targetKey && readTicket === draftReadGeneration.current) {
851
- const problem = asError(cause);
852
- const timedOut = problem.name === "TimeoutError";
853
- setDraftReadError(
854
- timedOut ? new ComposerStateError(t("hooks.useComposer.draftSyncTimedOutRetrying"), { cause }) : problem
855
- );
856
- if (timedOut || cause instanceof TypeError || cause && typeof cause === "object" && "retryable" in cause && cause.retryable === true) {
857
- retry.failures += 1;
858
- scheduleRetry();
859
- if (draftRef.current === null) setDraftHydrationRetrying(true);
860
- } else {
861
- if (retry.timer !== null) clearTimeout(retry.timer);
862
- retry.failures = 0;
863
- retry.timer = null;
864
- setDraftHydrationRetrying(false);
865
- }
866
- }
867
- } finally {
868
- if (generation === targetGeneration.current && targetKeyRef.current === targetKey && readTicket === draftReadGeneration.current) {
869
- setDraftLoading(false);
870
- }
871
- if (draftReadInFlightRef.current === targetKey) {
872
- draftReadInFlightRef.current = null;
873
- }
874
- if (draftReadAbortRef.current === requestAbort) {
875
- draftReadAbortRef.current = null;
876
- }
877
- if (draftRereadPendingRef.current === targetKey) {
878
- draftRereadPendingRef.current = null;
879
- if (targetKeyRef.current === targetKey && draftReadInFlightRef.current === null && retry.timer === null) {
880
- void loadDraft(false);
881
- }
882
- }
883
- }
884
- },
885
- [client, durableDrafts, keepNewerDraftAfterSend, sessionId, targetKey, workspaceId, t]
886
- );
887
- useEffect(() => {
888
- if (!sessionId || !durableDrafts) {
889
- setDraftLoading(false);
890
- return;
891
- }
892
- void loadDraft(false);
893
- }, [durableDrafts, loadDraft, sessionId]);
894
- useEffect(() => {
895
- if (!sessionId || !durableDrafts || !workspaceDraftsEvent || workspaceDraftsEvent.workspaceId !== workspaceId || !workspaceDraftsEvent.sessionIds.includes(sessionId)) {
896
- return;
897
- }
898
- void loadDraft(false);
899
- }, [durableDrafts, loadDraft, sessionId, workspaceDraftsEvent, workspaceId]);
900
- useEffect(() => {
901
- if (!sessionId || !durableDrafts) return;
902
- const onWake = () => {
903
- if (typeof document !== "undefined" && document.visibilityState === "hidden") return;
904
- void loadDraft(false);
905
- };
906
- document.addEventListener("visibilitychange", onWake);
907
- window.addEventListener("pageshow", onWake);
908
- return () => {
909
- document.removeEventListener("visibilitychange", onWake);
910
- window.removeEventListener("pageshow", onWake);
911
- };
912
- }, [durableDrafts, loadDraft, sessionId]);
913
- useEffect(() => {
914
- if (!sessionId || !durableDrafts) return;
915
- return registerSessionReconciler(sessionId, "composer", async () => await loadDraft(false));
916
- }, [durableDrafts, loadDraft, registerSessionReconciler, sessionId]);
917
- const reconcileSteering = useCallback(async () => {
918
- if (!sessionId || !steeringRef.current) return;
919
- const ownedTargetKey = targetKey;
920
- let events;
921
- try {
922
- events = await client.listEvents(workspaceId, sessionId, {
923
- includeTypes: [
924
- "user.message",
925
- "turn.started",
926
- "turn.completed",
927
- "turn.failed",
928
- "turn.cancelled",
929
- "turn.superseded"
930
- ],
931
- limit: 250,
932
- payloadMode: "full"
933
- });
934
- } catch {
935
- return;
936
- }
937
- if (targetKeyRef.current !== ownedTargetKey) return;
938
- setSteering((current) => {
939
- if (!current) return current;
940
- if (steeringSettledByEvents(current, events)) {
941
- steeringSettlementEventsRef.current = [];
942
- return null;
943
- }
944
- const accepted = steeringAcceptedEvent(current, events);
945
- if (!accepted || current.triggerEventId) return current;
946
- return {
947
- ...current,
948
- phase: "accepted",
949
- triggerEventId: accepted.id
950
- };
951
- });
952
- }, [client, sessionId, targetKey, workspaceId]);
953
- useSessionEventTrigger(
954
- client,
955
- workspaceId,
956
- sessionId,
957
- (event) => isComposerDraftEvent(event) || isSteeringSettlementEvent(event),
958
- (event) => {
959
- if (isComposerDraftEvent(event)) void loadDraft(false);
960
- if (!isSteeringSettlementEvent(event)) return;
961
- steeringSettlementEventsRef.current = [
962
- ...steeringSettlementEventsRef.current.slice(-15),
963
- event
964
- ];
965
- setSteering((current) => {
966
- if (!current || !steeringSettledByEvents(current, [event])) return current;
967
- steeringSettlementEventsRef.current = [];
968
- return null;
969
- });
970
- },
971
- {
972
- enabled: Boolean(sessionId) && (durableDrafts || steering !== null),
973
- ...options.events !== void 0 ? { events: options.events } : {}
974
- },
975
- reconcileSteering
976
- );
977
- useEffect(() => {
978
- if (!steering) return;
979
- const observed = [...options.events ?? [], ...steeringSettlementEventsRef.current];
980
- if (!steeringSettledByEvents(steering, observed)) return;
981
- steeringSettlementEventsRef.current = [];
982
- setSteering(null);
983
- }, [options.events, steering]);
984
- useEffect(() => {
985
- if (!acceptedControl) return;
986
- const effectiveControl = options.effectiveControl;
987
- if (!effectiveControl || effectiveControl.controlVersion < acceptedControl.controlVersion) {
988
- return;
989
- }
990
- setAcceptedControl((current) => current === acceptedControl ? null : current);
991
- }, [acceptedControl, options.effectiveControl]);
992
- const pendingAcceptedControl = acceptedControl && (!options.effectiveControl || options.effectiveControl.controlVersion < acceptedControl.controlVersion) ? acceptedControl : null;
993
- const currentDraftPayload = useCallback(() => {
994
- if (!durableDrafts || targetKeyRef.current !== targetKey) return null;
995
- const base = draftRef.current;
996
- const currentPolicy = policyRef.current;
997
- if (!base || !currentPolicy) return null;
998
- return composerDraftPayload(
999
- base,
1000
- value,
1001
- restoredResources,
1002
- annotations,
1003
- pickedPolicy(policyPickedRef, policyRef),
1004
- resolveSendExtras(sendExtrasRef.current).resources ?? []
1005
- );
1006
- }, [annotations, durableDrafts, restoredResources, targetKey, value]);
1007
- const adoptDraftBase = useCallback(
1008
- // `written` is false for a draft this page neither saved nor shows.
1009
- (next, written = true) => {
1010
- if (targetKeyRef.current !== targetKey) return;
1011
- draftRef.current = next;
1012
- if (written) sendBasisRef.current = next.revision;
1013
- setDraft(next);
1014
- const nextPolicy = policyFromDraft(next);
1015
- if (next.policyFollowsSession) {
1016
- if (samePolicy(policyRef.current, nextPolicy)) {
1017
- policyPickedRef.current = false;
1018
- setPolicyPicked(false);
1019
- }
1020
- if (!policyPickedRef.current && !samePolicy(policyRef.current, nextPolicy)) {
1021
- policyRef.current = nextPolicy;
1022
- setPolicy(nextPolicy);
1023
- }
1024
- }
1025
- lastSavedSignature.current = draftSignature(draftPayload(next));
1026
- setDraftConflict(null);
1027
- setError(null);
1028
- },
1029
- [targetKey]
1030
- );
1031
- const followAcceptedDraft = useCallback(
1032
- (next) => {
1033
- adoptDraftBase(next, !composerDraftHasContent(next));
1034
- if (!composerDraftHasContent(next)) return;
1035
- setTimeout(() => {
1036
- if (targetKeyRef.current !== targetKey || draftRef.current?.revision !== next.revision || valueRef.current !== "" || restoredResourcesRef.current.length > 0 || annotationsRef.current.length > 0) {
1037
- return;
1038
- }
1039
- applyDraft(next);
1040
- }, 0);
1041
- },
1042
- [adoptDraftBase, applyDraft, targetKey]
1043
- );
1044
- const acquireDraftSlot = useCallback(async () => {
1045
- let release;
1046
- const released = new Promise((resolve) => {
1047
- release = resolve;
1048
- });
1049
- const previous = saveChain.current;
1050
- saveChain.current = previous.then(
1051
- () => released,
1052
- () => released
1053
- );
1054
- await previous.catch(() => void 0);
1055
- return release;
1056
- }, []);
1057
- const saveDraftInSlot = useCallback(
1058
- async (payload, owner, onFailure, overNewer = true) => {
1059
- const owned = () => targetKeyRef.current === owner.targetKey && targetGeneration.current === owner.generation;
1060
- if (!sessionId || !durableDrafts || !owned()) return false;
1061
- const current = draftRef.current;
1062
- if (!current) return false;
1063
- const unsaved = unsavedDraftRef.current;
1064
- if (unsaved && draftContentKey(unsaved.payload) === draftContentKey(payload)) {
1065
- unsavedDraftRef.current = null;
1066
- }
1067
- let request = { ...payload, expectedRevision: current.revision };
1068
- if (draftSignature(request) === lastSavedSignature.current) return true;
1069
- const writesKey = `${workspaceId}\0${sessionId}`;
1070
- const fail = (problem) => {
1071
- if (owned()) {
1072
- if (isDraftConflictError(problem)) setDraftConflict(problem);
1073
- else setError(problem);
1074
- onFailure?.(problem);
1075
- }
1076
- return false;
1077
- };
1078
- setDraftSaving(true);
1079
- try {
1080
- for (let reread = 0; ; reread += 1) {
1081
- let problem;
1082
- try {
1083
- rememberPageDraftWrite(writesKey, draftContentKey(request));
1084
- const saved = await client.saveComposerDraft(workspaceId, sessionId, request);
1085
- draftWriteUnconfirmedRef.current = false;
1086
- settledWritesRef.current.set(writesKey, {
1087
- revision: saved.revision,
1088
- content: draftContentKey(request)
1089
- });
1090
- if (!owned()) return false;
1091
- adoptDraftBase(saved);
1092
- return true;
1093
- } catch (cause) {
1094
- problem = asError(cause);
1095
- if (isOutcomeUnknownError(cause) || isTransientServiceFailure(cause)) {
1096
- draftWriteUnconfirmedRef.current = true;
1097
- }
1098
- }
1099
- if (!owned()) return false;
1100
- if (!isDraftConflictError(problem) || reread >= DRAFT_CONFLICT_REREADS) {
1101
- return fail(problem);
1102
- }
1103
- let remote;
1104
- try {
1105
- remote = await client.getComposerDraft(workspaceId, sessionId);
1106
- } catch (cause) {
1107
- return fail(asError(cause));
1108
- }
1109
- if (!owned()) return false;
1110
- const remoteContent = draftContentKey(draftPayload(remote));
1111
- if (remoteContent === draftContentKey(request)) {
1112
- draftWriteUnconfirmedRef.current = false;
1113
- adoptDraftBase(remote);
1114
- return true;
1115
- }
1116
- if (!overNewer && !isPageDraftWrite(writesKey, remoteContent)) {
1117
- draftRef.current = remote;
1118
- setDraft(remote);
1119
- return true;
1120
- }
1121
- draftRef.current = remote;
1122
- setDraft(remote);
1123
- request = { ...request, expectedRevision: remote.revision };
1124
- }
1125
- } finally {
1126
- if (owned()) setDraftSaving(false);
1127
- }
1128
- },
1129
- [adoptDraftBase, client, durableDrafts, sessionId, workspaceId]
1130
- );
1131
- const resolveSendDraftRevision = useCallback(
1132
- async (payload, owner) => {
1133
- let saved = false;
1134
- if (payload && (draftFencedSendRef.current || draftWriteUnconfirmedRef.current || pickNotSaved(payload, draftRef.current)) && // A save base that is another device's draft this page never showed
1135
- // is not saved over: the send goes ahead from the send basis.
1136
- !sendDraftBasis(draftRef.current, sendBasisRef.current).behind) {
1137
- let failure = null;
1138
- saved = await saveDraftInSlot(
1139
- payload,
1140
- owner,
1141
- (problem) => {
1142
- failure = problem;
1143
- },
1144
- false
1145
- );
1146
- if (!saved && failure) {
1147
- if (isTransientServiceFailure(failure)) {
1148
- return { revision: void 0, saved, blocked: failure };
1149
- }
1150
- setError(null);
1151
- setDraftConflict(null);
1152
- }
1153
- }
1154
- const basis = sendDraftBasis(draftRef.current, sendBasisRef.current);
1155
- if (basis.behind) keepNewerDraftAfterSend();
1156
- return { revision: basis.revision, saved, blocked: null };
1157
- },
1158
- [keepNewerDraftAfterSend, saveDraftInSlot]
1159
- );
1160
- const keepUndeliveredSendInDraft = useCallback(
1161
- async (payload, basis, owner) => {
1162
- const owned = () => targetKeyRef.current === owner.targetKey && targetGeneration.current === owner.generation;
1163
- unkeptSendRef.current = null;
1164
- const current = draftRef.current;
1165
- if (!sessionId || !durableDrafts || !payload || basis === void 0 || !owned() || !current) {
1166
- return;
1167
- }
1168
- if (current.revision !== basis) {
1169
- keepNewerDraftAfterSend();
1170
- return;
1171
- }
1172
- const content = draftContentKey(payload);
1173
- if (draftContentKey(draftPayload(current)) === content) {
1174
- keepNewerDraftAfterSend();
1175
- return;
1176
- }
1177
- const writesKey = `${workspaceId}\0${sessionId}`;
1178
- try {
1179
- rememberPageDraftWrite(writesKey, content);
1180
- const saved = await client.saveComposerDraft(workspaceId, sessionId, {
1181
- ...payload,
1182
- expectedRevision: basis
1183
- });
1184
- settledWritesRef.current.set(writesKey, { revision: saved.revision, content });
1185
- if (!owned()) return;
1186
- adoptDraftBase(saved);
1187
- keepNewerDraftAfterSend();
1188
- } catch (cause) {
1189
- if (isOutcomeUnknownError(cause) || isTransientServiceFailure(cause)) {
1190
- draftWriteUnconfirmedRef.current = true;
1191
- if (owned()) unkeptSendRef.current = { payload, basis, owner };
1192
- }
1193
- if (owned()) keepNewerDraftAfterSend();
1194
- }
1195
- },
1196
- [adoptDraftBase, client, durableDrafts, keepNewerDraftAfterSend, sessionId, workspaceId]
1197
- );
1198
- const forgetRemovedSendDraft = useCallback(
1199
- async (payload) => {
1200
- if (!sessionId || !durableDrafts) return;
1201
- const owner = { targetKey, generation: targetGeneration.current };
1202
- const owned = () => targetKeyRef.current === owner.targetKey && targetGeneration.current === owner.generation;
1203
- const unkept = unkeptSendRef.current;
1204
- if (unkept && draftContentKey(unkept.payload) === draftContentKey(payload)) {
1205
- unkeptSendRef.current = null;
1206
- }
1207
- const release = await acquireDraftSlot();
1208
- try {
1209
- const base = draftRef.current;
1210
- if (!owned() || !base || !policyRef.current || valueRef.current !== "" || restoredResourcesRef.current.length > 0 || annotationsRef.current.length > 0 || draftContentKey(draftPayload(base)) !== draftContentKey(payload)) {
1211
- return;
1212
- }
1213
- const cleared = composerDraftPayload(
1214
- base,
1215
- "",
1216
- [],
1217
- [],
1218
- pickedPolicy(policyPickedRef, policyRef),
1219
- resolveSendExtras(sendExtrasRef.current).resources ?? []
1220
- );
1221
- const content = draftContentKey(cleared);
1222
- const writesKey = `${workspaceId}\0${sessionId}`;
1223
- rememberPageDraftWrite(writesKey, content);
1224
- const saved = await client.saveComposerDraft(workspaceId, sessionId, {
1225
- ...cleared,
1226
- expectedRevision: base.revision
1227
- });
1228
- settledWritesRef.current.set(writesKey, { revision: saved.revision, content });
1229
- if (owned()) adoptDraftBase(saved);
1230
- } catch {
1231
- } finally {
1232
- release();
1233
- }
1234
- },
1235
- [acquireDraftSlot, adoptDraftBase, client, durableDrafts, sessionId, targetKey, workspaceId]
1236
- );
1237
- useEffect(() => {
1238
- if (!sessionId || !durableDrafts) return;
1239
- const retry = () => {
1240
- const unkept = unkeptSendRef.current;
1241
- if (!unkept) return;
1242
- if (typeof document !== "undefined" && document.visibilityState === "hidden") return;
1243
- void (async () => {
1244
- const release = await acquireDraftSlot();
1245
- try {
1246
- if (unkeptSendRef.current === unkept) {
1247
- await keepUndeliveredSendInDraft(unkept.payload, unkept.basis, unkept.owner);
1248
- }
1249
- } finally {
1250
- release();
1251
- }
1252
- })();
1253
- };
1254
- window.addEventListener("online", retry);
1255
- document.addEventListener("visibilitychange", retry);
1256
- window.addEventListener("pageshow", retry);
1257
- return () => {
1258
- window.removeEventListener("online", retry);
1259
- document.removeEventListener("visibilitychange", retry);
1260
- window.removeEventListener("pageshow", retry);
1261
- };
1262
- }, [acquireDraftSlot, durableDrafts, keepUndeliveredSendInDraft, sessionId]);
1263
- const submitDurableSend = useCallback(
1264
- async (payload, owner, first, submit, onRevision) => {
1265
- try {
1266
- return await submit(first.revision);
1267
- } catch (cause) {
1268
- if (first.saved || !payload || !isDraftConflictError(asError(cause))) throw cause;
1269
- draftFencedSendRef.current = true;
1270
- const next = await resolveSendDraftRevision(payload, owner);
1271
- if (next.blocked) throw next.blocked;
1272
- if (!next.saved || next.revision === void 0) throw cause;
1273
- onRevision(next.revision);
1274
- return await submit(next.revision);
1275
- }
1276
- },
1277
- [resolveSendDraftRevision]
1278
- );
1279
- const persistPayload = useCallback(
1280
- async (payload, onFailure) => {
1281
- const owner = { targetKey, generation: targetGeneration.current };
1282
- if (!sessionId || !durableDrafts || targetKeyRef.current !== owner.targetKey) {
1283
- return false;
1284
- }
1285
- const release = await acquireDraftSlot();
1286
- try {
1287
- return await saveDraftInSlot(payload, owner, onFailure);
1288
- } finally {
1289
- release();
1290
- }
1291
- },
1292
- [acquireDraftSlot, durableDrafts, saveDraftInSlot, sessionId, targetKey]
1293
- );
1294
- const flushDraft = useCallback(async () => {
1295
- if (draftLoading || sending || draftConflict) return;
1296
- const payload = currentDraftPayload();
1297
- if (!payload || draftSignature(payload) === lastSavedSignature.current) return;
1298
- await persistPayload(payload);
1299
- }, [currentDraftPayload, draftConflict, draftLoading, persistPayload, sending]);
1300
- const replaceOptimisticSends = useCallback(
1301
- (update) => {
1302
- const next = update(optimisticSendsRef.current);
1303
- optimisticSendsRef.current = next;
1304
- rememberOptimisticSendOperations(pendingOperationKey, next);
1305
- setOptimisticSends(next);
1306
- return next;
1307
- },
1308
- [pendingOperationKey]
1309
- );
1310
- const markOptimisticAccepted = useCallback(
1311
- (operation) => {
1312
- if (!optimisticCallbackIdsRef.current.has(operation.clientEventId)) {
1313
- optimisticCallbackIdsRef.current.add(operation.clientEventId);
1314
- onSent?.(operation.input.text, operation.input);
1315
- }
1316
- replaceOptimisticSends(
1317
- (current) => current.filter((candidate) => candidate.clientEventId !== operation.clientEventId)
1318
- );
1319
- },
1320
- [onSent, replaceOptimisticSends]
1321
- );
1322
- useEffect(() => {
1323
- const events = options.events ?? [];
1324
- if (events.length === 0 || optimisticSendsRef.current.length === 0) return;
1325
- const reconciled = optimisticSendsRef.current.map(
1326
- (operation) => reconcileOptimisticSendFromEvents(operation, events)
1327
- );
1328
- const settledIds = new Set(
1329
- reconciled.filter((item) => item.settled).map((item) => item.operation.clientEventId)
1330
- );
1331
- const changed = reconciled.some(
1332
- (item, index) => item.operation !== optimisticSendsRef.current[index] && !settledIds.has(item.operation.clientEventId)
1333
- );
1334
- const newlyAdmitted = reconciled.some(
1335
- (item, index) => item.admitted && item.operation !== optimisticSendsRef.current[index]
1336
- );
1337
- for (const item of reconciled) {
1338
- if (item.admitted && !optimisticCallbackIdsRef.current.has(item.operation.clientEventId)) {
1339
- optimisticCallbackIdsRef.current.add(item.operation.clientEventId);
1340
- onSent?.(item.operation.input.text, item.operation.input);
1341
- }
1342
- if (item.settled) markOptimisticAccepted(item.operation);
1343
- }
1344
- if (changed) {
1345
- replaceOptimisticSends(
1346
- (current) => current.map(
1347
- (operation) => reconciled.find((item) => item.operation.clientEventId === operation.clientEventId)?.operation ?? operation
1348
- ).filter((operation) => !settledIds.has(operation.clientEventId))
1349
- );
1350
- }
1351
- if (durableDrafts && newlyAdmitted) void loadDraft(false);
1352
- }, [
1353
- durableDrafts,
1354
- loadDraft,
1355
- markOptimisticAccepted,
1356
- onSent,
1357
- options.events,
1358
- replaceOptimisticSends
1359
- ]);
1360
- const processOptimisticSends = useCallback(() => {
1361
- if (!sessionId || optimisticProcessorBusyRef.current) return;
1362
- const currentOperations = optimisticSendsRef.current;
1363
- const operationIndex = currentOperations.findIndex(
1364
- (candidate) => candidate.state === "sending"
1365
- );
1366
- const operation = operationIndex < 0 ? void 0 : currentOperations[operationIndex];
1367
- if (!operation) return;
1368
- const held = serviceWaitRef.current.get(operation.clientEventId);
1369
- if (held && held.retryAt > Date.now()) {
1370
- if (serviceRetryTimerRef.current === null) {
1371
- serviceRetryTimerRef.current = setTimeout(
1372
- () => {
1373
- serviceRetryTimerRef.current = null;
1374
- processOptimisticSendsRef.current();
1375
- },
1376
- Math.max(0, held.retryAt - Date.now())
1377
- );
1378
- }
1379
- return;
1380
- }
1381
- const ownedTargetKey = targetKey;
1382
- const ownedGeneration = targetGeneration.current;
1383
- optimisticProcessorBusyRef.current = true;
1384
- void (async () => {
1385
- let mutationFailureObserved = false;
1386
- let notSubmitted = false;
1387
- let holding = false;
1388
- let releaseDraftSlot = null;
1389
- const holdForService = (cause, outcomeUnknown) => {
1390
- if (outcomeUnknown && !operation.canRetry) return false;
1391
- const now = Date.now();
1392
- const previous = serviceWaitRef.current.get(operation.clientEventId);
1393
- const since = isMaintenanceError(cause) ? now : previous?.since ?? now;
1394
- if (!isCalmServiceFailure(cause, since, now)) return false;
1395
- const attempts = (previous?.attempts ?? 0) + 1;
1396
- const delayMs = Math.round(
1397
- Math.min(SERVICE_SEND_RETRY_MAX_DELAY_MS, 1e3 * 2 ** (attempts - 1)) * (0.8 + Math.random() * 0.4)
1398
- );
1399
- serviceWaitRef.current.set(operation.clientEventId, {
1400
- since,
1401
- attempts,
1402
- retryAt: now + delayMs
1403
- });
1404
- holding = true;
1405
- setServiceWaiting(true);
1406
- replaceOptimisticSends(
1407
- (current) => current.map(
1408
- (candidate) => candidate.clientEventId === operation.clientEventId ? { ...candidate, state: "sending", outcomeUnknown } : candidate
1409
- )
1410
- );
1411
- return true;
1412
- };
1413
- const markFailed = (cause, outcomeUnknown) => {
1414
- if (targetKeyRef.current !== ownedTargetKey || targetGeneration.current !== ownedGeneration) {
1415
- return false;
1416
- }
1417
- if (holdForService(cause, outcomeUnknown)) return true;
1418
- const problem = asError(cause);
1419
- replaceOptimisticSends(
1420
- (current) => current.map(
1421
- (candidate) => candidate.clientEventId === operation.clientEventId ? {
1422
- ...candidate,
1423
- state: "failed",
1424
- error: formatError(
1425
- cause,
1426
- outcomeUnknown && !isOutcomeUnknownError(problem) && !(problem instanceof ComposerReconciliationRequiredError) ? problem instanceof OpenGeniApiError && problem.correlationId ? t("hooks.useComposer.notConfirmedCheckStatusWithReference", {
1427
- reference: problem.correlationId
1428
- }) : t("hooks.useComposer.notConfirmedCheckStatus") : composerSubmissionErrorMessage(t, problem, canBuyCreditsRef.current)
1429
- ),
1430
- retryable: outcomeUnknown || composerSubmissionCanRetry(problem),
1431
- outcomeUnknown,
1432
- correlationId: problem instanceof OpenGeniApiError ? problem.correlationId : candidate.correlationId
1433
- } : candidate
1434
- )
1435
- );
1436
- return false;
1437
- };
1438
- try {
1439
- if (operation.outcomeUnknown) {
1440
- let events;
1441
- try {
1442
- events = await client.listEvents(workspaceId, sessionId, {
1443
- includeTypes: [
1444
- "user.message",
1445
- "turn.queued",
1446
- "turn.started",
1447
- "turn.completed",
1448
- "turn.failed",
1449
- "turn.cancelled",
1450
- "turn.superseded"
1451
- ],
1452
- limit: 250,
1453
- payloadMode: "full"
1454
- });
1455
- } catch (cause) {
1456
- const wasHeld = serviceWaitRef.current.has(operation.clientEventId);
1457
- if (!markFailed(cause, true) && wasHeld) {
1458
- notifyObserver(
1459
- onDeliveryErrorRef.current,
1460
- asError(cause),
1461
- operation.input,
1462
- "send"
1463
- );
1464
- }
1465
- return;
1466
- }
1467
- const reconciled = reconcileOptimisticSendFromEvents(operation, events);
1468
- if (reconciled.admitted) {
1469
- if (durableDrafts) await loadDraft(false);
1470
- if (reconciled.settled) {
1471
- markOptimisticAccepted(reconciled.operation);
1472
- } else {
1473
- replaceOptimisticSends(
1474
- (current) => current.map(
1475
- (candidate) => candidate.clientEventId === operation.clientEventId ? reconciled.operation : candidate
1476
- )
1477
- );
1478
- if (!optimisticCallbackIdsRef.current.has(operation.clientEventId)) {
1479
- optimisticCallbackIdsRef.current.add(operation.clientEventId);
1480
- onSent?.(reconciled.operation.input.text, reconciled.operation.input);
1481
- }
1482
- }
1483
- return;
1484
- }
1485
- if (!operation.canRetry) {
1486
- throw new ComposerReconciliationRequiredError();
1487
- }
1488
- }
1489
- let expectedDraftRevision;
1490
- let savedFirst = false;
1491
- if (durableDrafts && operation.draftPayload) {
1492
- releaseDraftSlot = await acquireDraftSlot();
1493
- expectedDraftRevision = operation.expectedDraftRevision;
1494
- if (expectedDraftRevision === void 0) {
1495
- const resolved = await resolveSendDraftRevision(operation.draftPayload, {
1496
- targetKey: ownedTargetKey,
1497
- generation: ownedGeneration
1498
- });
1499
- if (resolved.blocked) {
1500
- notSubmitted = true;
1501
- throw resolved.blocked;
1502
- }
1503
- expectedDraftRevision = resolved.revision;
1504
- savedFirst = resolved.saved;
1505
- } else if (sendDraftBasis(draftRef.current, sendBasisRef.current).behind) {
1506
- keepNewerDraftAfterSend();
1507
- }
1508
- if (expectedDraftRevision !== void 0 && operation.expectedDraftRevision !== expectedDraftRevision) {
1509
- const firstBasis = expectedDraftRevision;
1510
- replaceOptimisticSends(
1511
- (current) => current.map(
1512
- (candidate) => candidate.clientEventId === operation.clientEventId ? { ...candidate, expectedDraftRevision: firstBasis } : candidate
1513
- )
1514
- );
1515
- }
1516
- }
1517
- if (targetKeyRef.current !== ownedTargetKey || targetGeneration.current !== ownedGeneration) {
1518
- return;
1519
- }
1520
- let wireInput = {
1521
- ...operation.input,
1522
- ...expectedDraftRevision !== void 0 ? { expectedDraftRevision } : {}
1523
- };
1524
- let acceptedResult = null;
1525
- let acceptedEvent = null;
1526
- let steerOrSend = operation.steerOrSend === true;
1527
- const submit = async () => {
1528
- if (durableDrafts) {
1529
- const sendPayload = operation.draftPayload;
1530
- if (!sendPayload || expectedDraftRevision === void 0) {
1531
- throw new ComposerStateError(t("hooks.useComposer.theDurableComposerDraftIs"));
1532
- }
1533
- const result = await submitDurableSend(
1534
- sendPayload,
1535
- { targetKey: ownedTargetKey, generation: ownedGeneration },
1536
- { revision: expectedDraftRevision, saved: savedFirst },
1537
- (revision) => client.submitComposerDraft(workspaceId, sessionId, {
1538
- text: sendPayload.text,
1539
- annotations: sendPayload.annotations,
1540
- resources: sendPayload.resources,
1541
- // Absent while the draft follows the chat's settings.
1542
- ...sendPayload.model !== void 0 ? { model: sendPayload.model } : {},
1543
- ...sendPayload.reasoningEffort !== void 0 ? { reasoningEffort: sendPayload.reasoningEffort } : {},
1544
- ...sendPayload.latencyMode !== void 0 ? { latencyMode: sendPayload.latencyMode } : {},
1545
- expectedDraftRevision: revision,
1546
- clientEventId: operation.clientEventId,
1547
- delivery: steerOrSend ? "steer_or_send" : "send",
1548
- ...wireInput.controlEtag ? { controlEtag: wireInput.controlEtag } : {},
1549
- ...wireInput.modelContext ? { modelContext: wireInput.modelContext } : {},
1550
- ...wireInput.mcpCredentialUpdates ? { mcpCredentialUpdates: wireInput.mcpCredentialUpdates } : {},
1551
- ...wireInput.connectionAccounts ? { connectionAccounts: wireInput.connectionAccounts } : {},
1552
- ...wireInput.personalResourceAttachment ? { personalResourceAttachment: wireInput.personalResourceAttachment } : {}
1553
- }).catch((cause) => {
1554
- mutationFailureObserved = true;
1555
- throw cause;
1556
- }),
1557
- (revision) => {
1558
- expectedDraftRevision = revision;
1559
- savedFirst = true;
1560
- wireInput = { ...wireInput, expectedDraftRevision: revision };
1561
- replaceOptimisticSends(
1562
- (current) => current.map(
1563
- (candidate) => candidate.clientEventId === operation.clientEventId ? { ...candidate, expectedDraftRevision: revision } : candidate
1564
- )
1565
- );
1566
- }
1567
- );
1568
- acceptedResult = result;
1569
- followAcceptedDraft(result.draft);
1570
- releaseDraftSlot?.();
1571
- } else if (steerOrSend) {
1572
- acceptedResult = await client.steerMessage(workspaceId, sessionId, wireInput, { delivery: "steer_or_send" }).catch((cause) => {
1573
- mutationFailureObserved = true;
1574
- throw cause;
1575
- });
1576
- } else {
1577
- acceptedEvent = await client.sendMessage(workspaceId, sessionId, wireInput).catch((cause) => {
1578
- mutationFailureObserved = true;
1579
- throw cause;
1580
- });
1581
- }
1582
- };
1583
- try {
1584
- await submit();
1585
- } catch (cause) {
1586
- if (!steerOrSend || !rejectsSteerOrSend(cause)) throw cause;
1587
- steerOrSendUnsupportedRef.current = true;
1588
- steerOrSend = false;
1589
- replaceOptimisticSends(
1590
- (current) => current.map(
1591
- (candidate) => candidate.clientEventId === operation.clientEventId ? { ...candidate, steerOrSend: false } : candidate
1592
- )
1593
- );
1594
- await submit();
1595
- }
1596
- if (targetKeyRef.current !== ownedTargetKey || targetGeneration.current !== ownedGeneration) {
1597
- return;
1598
- }
1599
- const acceptedRouting = acceptedResult?.routing ?? promptRoutingFromAcceptedEvent(acceptedEvent);
1600
- const acceptedDestination = acceptedRouting === "queued_for_execution" ? "queue" : acceptedRouting === "accepted_for_execution" || acceptedRouting === "accepted_for_steering" ? "chat" : operation.destination;
1601
- if (options.events === void 0 && acceptedDestination === "chat") {
1602
- markOptimisticAccepted({ ...operation, input: wireInput });
1603
- } else {
1604
- replaceOptimisticSends(
1605
- (current) => current.map(
1606
- (candidate) => candidate.clientEventId === operation.clientEventId ? {
1607
- ...candidate,
1608
- input: wireInput,
1609
- destination: acceptedDestination,
1610
- turnId: acceptedResult?.turn.id ?? candidate.turnId,
1611
- triggerEventId: acceptedResult?.accepted.id ?? acceptedEvent?.id ?? candidate.triggerEventId,
1612
- appliedQueueVersion: acceptedResult?.receipt?.appliedQueueVersion ?? candidate.appliedQueueVersion,
1613
- state: "queued",
1614
- error: void 0
1615
- } : candidate
1616
- )
1617
- );
1618
- }
1619
- if (!optimisticCallbackIdsRef.current.has(operation.clientEventId)) {
1620
- optimisticCallbackIdsRef.current.add(operation.clientEventId);
1621
- onSent?.(wireInput.text, wireInput);
1622
- }
1623
- } catch (cause) {
1624
- const current = optimisticSendsRef.current.find(
1625
- (candidate) => candidate.clientEventId === operation.clientEventId
1626
- );
1627
- if (!current || current.state === "queued" && current.outcomeUnknown === false) {
1628
- return;
1629
- }
1630
- const problem = asError(cause);
1631
- const outcomeUnknown = operation.outcomeUnknown && !mutationFailureObserved ? true : !notSubmitted && isOutcomeUnknownError(cause);
1632
- const heldForService = markFailed(cause, outcomeUnknown);
1633
- if (!heldForService) {
1634
- notifyObserver(onDeliveryErrorRef.current, problem, operation.input, "send");
1635
- }
1636
- if (releaseDraftSlot) {
1637
- await keepUndeliveredSendInDraft(operation.draftPayload, current.expectedDraftRevision, {
1638
- targetKey: ownedTargetKey,
1639
- generation: ownedGeneration
1640
- });
1641
- }
1642
- } finally {
1643
- releaseDraftSlot?.();
1644
- optimisticProcessorBusyRef.current = false;
1645
- if (targetKeyRef.current === ownedTargetKey && targetGeneration.current === ownedGeneration) {
1646
- if (!holding) serviceWaitRef.current.delete(operation.clientEventId);
1647
- for (const id of serviceWaitRef.current.keys()) {
1648
- if (!optimisticSendsRef.current.some(
1649
- (candidate) => candidate.clientEventId === id && candidate.state === "sending"
1650
- )) {
1651
- serviceWaitRef.current.delete(id);
1652
- }
1653
- }
1654
- setServiceWaiting(serviceWaitRef.current.size > 0);
1655
- }
1656
- if (targetKeyRef.current === ownedTargetKey) {
1657
- setOptimisticSends([...optimisticSendsRef.current]);
1658
- }
1659
- }
1660
- })();
1661
- }, [
1662
- acquireDraftSlot,
1663
- followAcceptedDraft,
1664
- keepNewerDraftAfterSend,
1665
- keepUndeliveredSendInDraft,
1666
- client,
1667
- durableDrafts,
1668
- formatError,
1669
- markOptimisticAccepted,
1670
- loadDraft,
1671
- onSent,
1672
- options.events,
1673
- replaceOptimisticSends,
1674
- resolveSendDraftRevision,
1675
- sessionId,
1676
- submitDurableSend,
1677
- targetKey,
1678
- workspaceId,
1679
- t
1680
- ]);
1681
- processOptimisticSendsRef.current = processOptimisticSends;
1682
- useEffect(() => {
1683
- processOptimisticSends();
1684
- }, [optimisticSends, processOptimisticSends]);
1685
- useEffect(() => {
1686
- for (const id of serviceWaitRef.current.keys()) {
1687
- if (!optimisticSends.some(
1688
- (candidate) => candidate.clientEventId === id && candidate.state === "sending"
1689
- )) {
1690
- serviceWaitRef.current.delete(id);
1691
- }
1692
- }
1693
- setServiceWaiting(serviceWaitRef.current.size > 0);
1694
- }, [optimisticSends]);
1695
- useEffect(() => {
1696
- const savePromptly = savePickPromptlyRef.current;
1697
- savePickPromptlyRef.current = false;
1698
- unsavedDraftRef.current = null;
1699
- const pending = pendingOperationRef.current;
1700
- if (pending) {
1701
- const shadow = {
1702
- text: valueRef.current,
1703
- resources: mergeResources(
1704
- restoredResourcesRef.current,
1705
- resolveSendExtras(sendExtrasRef.current).resources ?? []
1706
- ),
1707
- annotations: annotationsRef.current,
1708
- ...pickedPolicy(policyPickedRef, policyRef) ? { policy: pickedPolicy(policyPickedRef, policyRef) } : {}
1709
- };
1710
- 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)) {
1711
- pendingOperationRef.current = updatePendingComposerShadow(
1712
- pendingOperationKey,
1713
- pending,
1714
- shadow
1715
- );
1716
- }
1717
- return;
1718
- }
1719
- const optimistic = optimisticSendsRef.current.at(-1);
1720
- if (optimistic) {
1721
- const shadow = {
1722
- text: valueRef.current,
1723
- resources: mergeResources(
1724
- restoredResourcesRef.current,
1725
- resolveSendExtras(sendExtrasRef.current).resources ?? []
1726
- ),
1727
- annotations: annotationsRef.current,
1728
- ...pickedPolicy(policyPickedRef, policyRef) ? { policy: pickedPolicy(policyPickedRef, policyRef) } : {}
1729
- };
1730
- 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)) {
1731
- setOptimisticDraftShadow(shadow);
1732
- }
1733
- }
1734
- if (optimisticSendsRef.current.some((operation) => operation.state === "sending")) {
1735
- return;
1736
- }
1737
- if (!durableDrafts || !sessionId || draftLoading || sending || !draftRef.current || draftConflict)
1738
- return;
1739
- const payload = currentDraftPayload();
1740
- if (!payload || draftSignature(payload) === lastSavedSignature.current) return;
1741
- unsavedDraftRef.current = { client, workspaceId, sessionId, payload };
1742
- savePickPromptlyRef.current = savePromptly;
1743
- const timer = window.setTimeout(
1744
- () => {
1745
- savePickPromptlyRef.current = false;
1746
- void persistPayload(payload);
1747
- },
1748
- savePromptly ? 0 : 500
1749
- );
1750
- return () => window.clearTimeout(timer);
1751
- }, [
1752
- autosaveRetry,
1753
- client,
1754
- currentDraftPayload,
1755
- durableDrafts,
1756
- draftConflict,
1757
- draftLoading,
1758
- liveExtrasVersion,
1759
- // A send settling lets an edit made while it ran be saved.
1760
- optimisticSends,
1761
- pendingOperationKey,
1762
- persistPayload,
1763
- // The pick is part of the draft like its text: a model, effort or speed
1764
- // chosen without typing is saved too, so it survives opening another
1765
- // chat or reloading before the next Send.
1766
- policy,
1767
- policyPicked,
1768
- setOptimisticDraftShadow,
1769
- sending,
1770
- sessionId,
1771
- workspaceId
1772
- ]);
1773
- useEffect(() => {
1774
- if (!error || !sessionId || !isTransientServiceFailure(error) || isActionFailure(error)) {
1775
- return;
1776
- }
1777
- const ownedTargetKey = targetKey;
1778
- const ownedError = error;
1779
- let cancelled = false;
1780
- let inFlight = false;
1781
- const timer = setInterval(() => {
1782
- if (inFlight) return;
1783
- inFlight = true;
1784
- const probe = durableDrafts ? client.getComposerDraft(workspaceId, sessionId) : client.listEvents(workspaceId, sessionId, { limit: 1, payloadMode: "none" });
1785
- probe.then(
1786
- () => {
1787
- inFlight = false;
1788
- if (cancelled || targetKeyRef.current !== ownedTargetKey) return;
1789
- setError((current) => current === ownedError ? null : current);
1790
- setAutosaveRetry((nonce) => nonce + 1);
1791
- },
1792
- () => {
1793
- inFlight = false;
1794
- }
1795
- );
1796
- }, TRANSIENT_RECONNECT_INTERVAL_MS);
1797
- return () => {
1798
- cancelled = true;
1799
- clearInterval(timer);
1800
- };
1801
- }, [client, durableDrafts, error, sessionId, targetKey, workspaceId]);
1802
- const dispatch = useCallback(
1803
- async (delivery, explicit, steerOrSend = false) => {
1804
- const ownedTargetKey = targetKey;
1805
- const ownedGeneration = targetGeneration.current;
1806
- const owner = { targetKey: ownedTargetKey, generation: ownedGeneration };
1807
- const operationKey = pendingComposerOperationKey(workspaceId, sessionId);
1808
- const pending = pendingOperationRef.current ?? restorePendingComposerOperation(operationKey);
1809
- if (pending && !pendingOperationRef.current) {
1810
- pendingOperationRef.current = pending;
1811
- pendingClientEventId.current = pending.input.clientEventId ?? null;
1812
- }
1813
- const draftAtSend = valueRef.current;
1814
- const annotationsAtSend = cloneAnnotations(annotationsRef.current);
1815
- const resourcesAtSend = [...restoredResourcesRef.current];
1816
- const rawText = explicit ?? draftAtSend;
1817
- const hasText = rawText.trim().length > 0;
1818
- const hasAnnotations = annotationsAtSend.length > 0;
1819
- const currentPolicy = policyRef.current;
1820
- const annotationsComplete2 = annotationsAtSend.every(
1821
- (annotation) => annotation.note.trim().length > 0
1822
- );
1823
- const extras = pending ? {} : resolveSendExtras(sendExtrasRef.current);
1824
- const hasResources = resourcesAtSend.length > 0 || (extras.resources?.length ?? 0) > 0;
1825
- if (!pending && (!annotationsComplete2 || !hasText && !hasResources && !hasAnnotations) || !sessionId || !currentPolicy || sending || sendBlockedRef.current?.() === true || targetKeyRef.current !== ownedTargetKey) {
1826
- return false;
1827
- }
1828
- const clearPending = () => {
1829
- pendingOperationRef.current = null;
1830
- pendingClientEventId.current = null;
1831
- forgetPendingComposerOperation(operationKey);
1832
- };
1833
- const owned = () => targetKeyRef.current === ownedTargetKey && targetGeneration.current === ownedGeneration;
1834
- const updatePending = (operation, update) => {
1835
- const current = pendingOperationRef.current;
1836
- const kept = current !== null && owned() && current.input.clientEventId === operation.input.clientEventId;
1837
- const next = update(kept ? current : operation);
1838
- if (kept) pendingOperationRef.current = next;
1839
- rememberPendingComposerOperation(operationKey, next);
1840
- return next;
1841
- };
1842
- let keepSteering = pending?.delivery === "steer";
1843
- let releaseDraftSlot = null;
1844
- const settleAccepted = (operation) => {
1845
- clearPending();
1846
- if (!operation.emptiedAtSend) {
1847
- const draftWasUnchanged = valueRef.current === operation.draftAtSend;
1848
- const resourcesWereUnchanged = JSON.stringify(restoredResourcesRef.current) === JSON.stringify(operation.resourcesAtSend);
1849
- const annotationsWereUnchanged = JSON.stringify(annotationsRef.current) === JSON.stringify(operation.annotationsAtSend);
1850
- if (resourcesWereUnchanged) {
1851
- restoredResourcesRef.current = [];
1852
- setRestoredResources([]);
1853
- }
1854
- if (annotationsWereUnchanged) {
1855
- annotationsRef.current = [];
1856
- setAnnotations([]);
1857
- setAnnotationReviewTargetId(null);
1858
- }
1859
- if (operation.clearDraftOnAccept && draftWasUnchanged) {
1860
- valueRef.current = "";
1861
- setValue("");
1862
- }
1863
- }
1864
- onSent?.(operation.input.text, operation.input);
1865
- };
1866
- const giveBack = (operation, cause) => {
1867
- const textTaken = operation.clearDraftOnAccept;
1868
- const boxUntouched = (!textTaken || valueRef.current === "") && annotationsRef.current.length === 0 && restoredResourcesRef.current.length === 0 && (resolveSendExtras(sendExtrasRef.current).resources?.length ?? 0) === 0;
1869
- if (owned() && boxUntouched) {
1870
- localEditRevision.current += 1;
1871
- if (textTaken) {
1872
- valueRef.current = operation.draftAtSend;
1873
- setValue(operation.draftAtSend);
1874
- }
1875
- restoredResourcesRef.current = [...operation.input.resources ?? []];
1876
- annotationsRef.current = cloneAnnotations(operation.annotationsAtSend);
1877
- setRestoredResources(restoredResourcesRef.current);
1878
- setAnnotations(annotationsRef.current);
1879
- return true;
1880
- }
1881
- const problem = asError(cause);
1882
- const failed = {
1883
- clientEventId: operation.input.clientEventId ?? generateClientEventId(),
1884
- delivery: operation.delivery,
1885
- // Retried, it still goes to the running turn when there is one.
1886
- ...operation.steerOrSend || operation.delivery === "steer" && !steerOrSendUnsupportedRef.current ? { steerOrSend: true } : {},
1887
- destination: "chat",
1888
- text: operation.input.text,
1889
- annotations: cloneAnnotations(operation.annotationsAtSend),
1890
- resources: [...operation.input.resources ?? []],
1891
- occurredAt: steeringOccurredAtRef.current,
1892
- state: "failed",
1893
- error: formatError(
1894
- cause,
1895
- composerSubmissionErrorMessage(t, problem, canBuyCreditsRef.current)
1896
- ),
1897
- retryable: composerSubmissionCanRetry(problem),
1898
- outcomeUnknown: false,
1899
- ...problem instanceof OpenGeniApiError && problem.correlationId ? { correlationId: problem.correlationId } : {},
1900
- input: operation.input,
1901
- draftPayload: operation.draftPayload ?? null,
1902
- newerShadow: operation.newerShadow,
1903
- canRetry: operation.canRetry
1904
- };
1905
- if (owned()) {
1906
- replaceOptimisticSends((current) => [...current, failed]);
1907
- } else {
1908
- rememberOptimisticSendOperations(operationKey, [
1909
- ...restoreOptimisticSendOperations(t, operationKey, canBuyCreditsRef.current),
1910
- failed
1911
- ]);
1912
- }
1913
- return false;
1914
- };
1915
- const resolveRevision = async (operation) => {
1916
- releaseDraftSlot = await acquireDraftSlot();
1917
- const resolved = await resolveSendDraftRevision(operation.draftPayload ?? null, owner);
1918
- if (resolved.blocked || resolved.revision === void 0) {
1919
- return { operation, saved: resolved.saved, blocked: resolved.blocked };
1920
- }
1921
- const revision = resolved.revision;
1922
- return {
1923
- operation: updatePending(operation, (current) => ({
1924
- ...current,
1925
- input: { ...current.input, expectedDraftRevision: revision }
1926
- })),
1927
- saved: resolved.saved,
1928
- blocked: null
1929
- };
1930
- };
1931
- const deliver = async (operation, savedFirst) => {
1932
- const wireDelivery = operation.steerOrSend ? "steer_or_send" : operation.delivery;
1933
- if (durableDrafts) {
1934
- const input = operation.input;
1935
- const clientEventId = input.clientEventId;
1936
- if (input.expectedDraftRevision === void 0 || clientEventId === void 0) {
1937
- throw new ComposerStateError(t("hooks.useComposer.theDurableComposerDraftIs"));
1938
- }
1939
- const result = await submitDurableSend(
1940
- operation.draftPayload ?? null,
1941
- owner,
1942
- { revision: input.expectedDraftRevision, saved: savedFirst },
1943
- async (revision) => await client.submitComposerDraft(workspaceId, sessionId, {
1944
- text: input.text,
1945
- annotations: input.annotations ?? [],
1946
- resources: input.resources ?? [],
1947
- // Absent while the draft follows the chat's settings.
1948
- ...input.model ? { model: input.model } : {},
1949
- ...input.reasoningEffort ? { reasoningEffort: input.reasoningEffort } : {},
1950
- ...input.latencyMode ? { latencyMode: input.latencyMode } : {},
1951
- expectedDraftRevision: revision,
1952
- clientEventId,
1953
- delivery: wireDelivery,
1954
- ...input.controlEtag ? { controlEtag: input.controlEtag } : {},
1955
- ...input.modelContext ? { modelContext: input.modelContext } : {},
1956
- ...input.mcpCredentialUpdates ? { mcpCredentialUpdates: input.mcpCredentialUpdates } : {},
1957
- ...input.connectionAccounts ? { connectionAccounts: input.connectionAccounts } : {},
1958
- ...input.personalResourceAttachment ? { personalResourceAttachment: input.personalResourceAttachment } : {}
1959
- }),
1960
- (revision) => {
1961
- updatePending(operation, (current) => ({
1962
- ...current,
1963
- input: { ...current.input, expectedDraftRevision: revision }
1964
- }));
1965
- }
1966
- );
1967
- followAcceptedDraft(result.draft);
1968
- return result;
1969
- }
1970
- if (operation.delivery === "steer") {
1971
- return await client.steerMessage(
1972
- workspaceId,
1973
- sessionId,
1974
- operation.input,
1975
- operation.steerOrSend ? { delivery: "steer_or_send" } : {}
1976
- );
1977
- }
1978
- await client.sendMessage(workspaceId, sessionId, operation.input);
1979
- return null;
1980
- };
1981
- const deliverOrFallBack = async (operation, savedFirst = false) => {
1982
- try {
1983
- return await deliver(operation, savedFirst);
1984
- } catch (cause) {
1985
- if (!operation.steerOrSend || !rejectsSteerOrSend(cause)) throw cause;
1986
- steerOrSendUnsupportedRef.current = true;
1987
- const chosen = updatePending(operation, (current) => ({
1988
- ...current,
1989
- steerOrSend: false
1990
- }));
1991
- return await deliver(chosen, true);
1992
- }
1993
- };
1994
- const steered = (operation, result) => result !== null && (!operation.steerOrSend || result.routing === "accepted_for_steering");
1995
- let fresh = null;
1996
- if (!pending) {
1997
- const sendText = hasText ? rawText : hasAnnotations ? "" : FILE_ONLY_MESSAGE_TEXT(t);
1998
- pendingClientEventId.current ??= generateClientEventId();
1999
- const effectiveControl = effectiveControlRef.current;
2000
- const policyPick = pickedPolicy(policyPickedRef, policyRef);
2001
- const input = composeSendInput(sendText, pendingClientEventId.current, extras, {
2002
- ...policyPick,
2003
- ...effectiveControl?.controlEtag ? { controlEtag: effectiveControl.controlEtag } : {},
2004
- resources: mergeResources(resourcesAtSend, extras.resources ?? []),
2005
- annotations: cloneAnnotations(annotationsAtSend)
2006
- });
2007
- const takesText = explicit === void 0;
2008
- const draftBase = draftRef.current;
2009
- fresh = {
2010
- delivery,
2011
- ...delivery === "steer" && steerOrSend && !steerOrSendUnsupportedRef.current ? { steerOrSend: true } : {},
2012
- input,
2013
- draftAtSend,
2014
- resourcesAtSend,
2015
- annotationsAtSend: cloneAnnotations(annotationsAtSend),
2016
- // What stays in the box while this send runs.
2017
- newerShadow: {
2018
- text: takesText ? "" : draftAtSend,
2019
- resources: [],
2020
- annotations: [],
2021
- ...policyPick ? { policy: policyPick } : {}
2022
- },
2023
- clearDraftOnAccept: takesText,
2024
- emptiedAtSend: true,
2025
- draftPayload: durableDrafts && draftBase && currentPolicy ? composerDraftPayload(
2026
- draftBase,
2027
- sendText,
2028
- resourcesAtSend,
2029
- annotationsAtSend,
2030
- policyPick,
2031
- extras.resources ?? []
2032
- ) : null,
2033
- canRetry: true
2034
- };
2035
- pendingOperationRef.current = fresh;
2036
- rememberPendingComposerOperation(operationKey, fresh);
2037
- localEditRevision.current += 1;
2038
- if (takesText) {
2039
- valueRef.current = "";
2040
- setValue("");
2041
- }
2042
- annotationsRef.current = [];
2043
- restoredResourcesRef.current = [];
2044
- setAnnotations([]);
2045
- setAnnotationReviewTargetId(null);
2046
- setRestoredResources([]);
2047
- }
2048
- const shown = pending ?? fresh;
2049
- if (delivery === "steer") {
2050
- if (steeringRef.current?.clientEventId !== pending?.input.clientEventId) {
2051
- steeringOccurredAtRef.current = (/* @__PURE__ */ new Date()).toISOString();
2052
- }
2053
- setSteering({
2054
- phase: "submitting",
2055
- text: shown?.input.text ?? rawText,
2056
- clientEventId: shown?.input.clientEventId ?? pendingClientEventId.current,
2057
- triggerEventId: null,
2058
- turnId: null
2059
- });
2060
- }
2061
- setSending(true);
2062
- setError(null);
2063
- if (fresh) onSubmitted?.(fresh.input.text, fresh.input);
2064
- try {
2065
- if (pending) {
2066
- let acceptedEvent = null;
2067
- try {
2068
- const events = await client.listEvents(workspaceId, sessionId, {
2069
- includeTypes: ["user.message"],
2070
- limit: 100,
2071
- payloadMode: "none"
2072
- });
2073
- acceptedEvent = events.find(
2074
- (event) => event.type === "user.message" && event.clientEventId === pending.input.clientEventId
2075
- ) ?? null;
2076
- } catch (cause) {
2077
- if (targetKeyRef.current === ownedTargetKey && targetGeneration.current === ownedGeneration) {
2078
- const problem = markActionFailure(asError(cause));
2079
- setError(problem);
2080
- if (pending.delivery === "steer") {
2081
- keepSteering = true;
2082
- setSteering({
2083
- phase: "failed",
2084
- text: pending.input.text,
2085
- clientEventId: pending.input.clientEventId ?? null,
2086
- triggerEventId: null,
2087
- turnId: null,
2088
- error: t("hooks.useComposer.notConfirmedRetry"),
2089
- outcomeUnknown: true
2090
- });
2091
- }
2092
- }
2093
- return false;
2094
- }
2095
- if (targetKeyRef.current !== ownedTargetKey || targetGeneration.current !== ownedGeneration) {
2096
- return false;
2097
- }
2098
- if (acceptedEvent) {
2099
- if (durableDrafts) await loadDraft(false);
2100
- if (pending.delivery === "steer") {
2101
- keepSteering = true;
2102
- setSteering({
2103
- phase: "accepted",
2104
- text: pending.input.text,
2105
- clientEventId: pending.input.clientEventId ?? null,
2106
- triggerEventId: acceptedEvent.id,
2107
- turnId: null
2108
- });
2109
- }
2110
- settleAccepted(pending);
2111
- return true;
2112
- }
2113
- if (!pending.canRetry) {
2114
- setError(new ComposerReconciliationRequiredError());
2115
- return false;
2116
- }
2117
- let retried = pending;
2118
- try {
2119
- let savedFirst2 = false;
2120
- if (durableDrafts && pending.input.expectedDraftRevision === void 0) {
2121
- const resolved = await resolveRevision(pending);
2122
- if (resolved.blocked) throw resolved.blocked;
2123
- retried = resolved.operation;
2124
- savedFirst2 = resolved.saved;
2125
- } else if (durableDrafts) {
2126
- releaseDraftSlot = await acquireDraftSlot();
2127
- }
2128
- const result = await deliverOrFallBack(retried, savedFirst2);
2129
- if (pending.delivery === "steer" && steered(pending, result)) {
2130
- keepSteering = true;
2131
- setSteering({
2132
- phase: "accepted",
2133
- text: pending.input.text,
2134
- clientEventId: pending.input.clientEventId ?? null,
2135
- triggerEventId: result.accepted.id,
2136
- turnId: result.turn.id,
2137
- stoppingPreviousAttempt: result.replay !== true && (result.interruptionCount ?? 0) > 0
2138
- });
2139
- } else {
2140
- keepSteering = false;
2141
- }
2142
- } catch (cause) {
2143
- const problem = asError(cause);
2144
- const outcomeUnknown = isOutcomeUnknownError(cause);
2145
- notifyObserver(
2146
- onDeliveryErrorRef.current,
2147
- problem,
2148
- pending.input,
2149
- pending.delivery
2150
- );
2151
- if (!outcomeUnknown) {
2152
- clearPending();
2153
- keepSteering = false;
2154
- if (retried.emptiedAtSend && !giveBack(retried, cause)) {
2155
- return false;
2156
- }
2157
- } else {
2158
- if (releaseDraftSlot && retried.emptiedAtSend) {
2159
- await keepUndeliveredSendInDraft(
2160
- retried.draftPayload,
2161
- retried.input.expectedDraftRevision,
2162
- owner
2163
- );
2164
- }
2165
- if (pending.delivery === "steer") {
2166
- keepSteering = true;
2167
- setSteering({
2168
- phase: "failed",
2169
- text: pending.input.text,
2170
- clientEventId: pending.input.clientEventId ?? null,
2171
- triggerEventId: null,
2172
- turnId: null,
2173
- error: t("hooks.useComposer.notConfirmedRetry"),
2174
- outcomeUnknown: true
2175
- });
2176
- }
2177
- }
2178
- if (targetKeyRef.current === ownedTargetKey && targetGeneration.current === ownedGeneration) {
2179
- setError(markActionFailure(problem));
2180
- }
2181
- return false;
2182
- }
2183
- if (targetKeyRef.current !== ownedTargetKey || targetGeneration.current !== ownedGeneration) {
2184
- return false;
2185
- }
2186
- settleAccepted(pending);
2187
- return true;
2188
- }
2189
- if (!fresh) return false;
2190
- let operation = fresh;
2191
- let savedFirst = false;
2192
- if (durableDrafts) {
2193
- const resolved = await resolveRevision(operation);
2194
- if (resolved.blocked) {
2195
- clearPending();
2196
- giveBack(operation, resolved.blocked);
2197
- return false;
2198
- }
2199
- operation = resolved.operation;
2200
- savedFirst = resolved.saved;
2201
- }
2202
- if (!owned()) return false;
2203
- try {
2204
- const result = await deliverOrFallBack(operation, savedFirst);
2205
- if (delivery === "steer" && steered(operation, result)) {
2206
- keepSteering = true;
2207
- setSteering({
2208
- phase: "accepted",
2209
- text: operation.input.text,
2210
- clientEventId: operation.input.clientEventId ?? null,
2211
- triggerEventId: result.accepted.id,
2212
- turnId: result.turn.id,
2213
- stoppingPreviousAttempt: result.replay !== true && (result.interruptionCount ?? 0) > 0
2214
- });
2215
- }
2216
- } catch (cause) {
2217
- notifyObserver(
2218
- onDeliveryErrorRef.current,
2219
- asError(cause),
2220
- operation.input,
2221
- operation.delivery
2222
- );
2223
- if (!isOutcomeUnknownError(cause)) {
2224
- clearPending();
2225
- if (!giveBack(operation, cause)) {
2226
- return false;
2227
- }
2228
- } else {
2229
- if (releaseDraftSlot && operation.emptiedAtSend) {
2230
- await keepUndeliveredSendInDraft(
2231
- operation.draftPayload,
2232
- operation.input.expectedDraftRevision,
2233
- owner
2234
- );
2235
- }
2236
- if (delivery === "steer") {
2237
- keepSteering = true;
2238
- setSteering({
2239
- phase: "failed",
2240
- text: operation.input.text,
2241
- clientEventId: operation.input.clientEventId ?? null,
2242
- triggerEventId: null,
2243
- turnId: null,
2244
- error: t("hooks.useComposer.notConfirmedRetry"),
2245
- outcomeUnknown: true
2246
- });
2247
- }
2248
- }
2249
- if (targetKeyRef.current === ownedTargetKey && targetGeneration.current === ownedGeneration) {
2250
- setError(markActionFailure(asError(cause)));
2251
- }
2252
- return false;
2253
- }
2254
- if (targetKeyRef.current !== ownedTargetKey || targetGeneration.current !== ownedGeneration) {
2255
- return false;
2256
- }
2257
- settleAccepted(operation);
2258
- return true;
2259
- } finally {
2260
- releaseDraftSlot?.();
2261
- if (targetKeyRef.current === ownedTargetKey && targetGeneration.current === ownedGeneration) {
2262
- setSending(false);
2263
- if (delivery === "steer" && !keepSteering) setSteering(null);
2264
- }
2265
- }
2266
- },
2267
- [
2268
- acquireDraftSlot,
2269
- client,
2270
- durableDrafts,
2271
- formatError,
2272
- onSent,
2273
- onSubmitted,
2274
- followAcceptedDraft,
2275
- keepUndeliveredSendInDraft,
2276
- replaceOptimisticSends,
2277
- resolveSendDraftRevision,
2278
- sending,
2279
- sessionId,
2280
- submitDurableSend,
2281
- targetKey,
2282
- workspaceId,
2283
- loadDraft,
2284
- t
2285
- ]
2286
- );
2287
- const sendToQueue = useCallback(
2288
- async (explicit, steerOrSend = false) => {
2289
- if (pendingOperationRef.current?.delivery === "send") {
2290
- return await dispatch("send", explicit);
2291
- }
2292
- const rawText = explicit ?? valueRef.current;
2293
- const annotationsAtSend = cloneAnnotations(annotationsRef.current);
2294
- const currentPolicy = policyRef.current;
2295
- const hasText = rawText.trim().length > 0;
2296
- const hasAnnotations = annotationsAtSend.length > 0;
2297
- const annotationsComplete2 = annotationsAtSend.every(
2298
- (annotation) => annotation.note.trim().length > 0
2299
- );
2300
- const extras = resolveSendExtras(sendExtrasRef.current);
2301
- const resources = mergeResources(restoredResourcesRef.current, extras.resources ?? []);
2302
- if (!sessionId || !currentPolicy || sending || !annotationsComplete2 || !hasText && !hasAnnotations && resources.length === 0 || sendBlockedRef.current?.() === true || targetKeyRef.current !== targetKey) {
2303
- return false;
2304
- }
2305
- const sendText = hasText ? rawText : hasAnnotations ? "" : FILE_ONLY_MESSAGE_TEXT(t);
2306
- const clientEventId = generateClientEventId();
2307
- const effectiveControl = effectiveControlRef.current;
2308
- const input = composeSendInput(sendText, clientEventId, extras, {
2309
- ...pickedPolicy(policyPickedRef, policyRef),
2310
- ...effectiveControl?.controlEtag ? { controlEtag: effectiveControl.controlEtag } : {},
2311
- resources,
2312
- annotations: annotationsAtSend
2313
- });
2314
- const currentPayload = currentDraftPayload();
2315
- const hasEarlierUnsettledSend = optimisticSendsRef.current.some(
2316
- (candidate) => candidate.state !== "failed" || candidate.outcomeUnknown === true
2317
- );
2318
- const operation = {
2319
- clientEventId,
2320
- delivery: "send",
2321
- ...steerOrSend && !steerOrSendUnsupportedRef.current ? { steerOrSend: true } : {},
2322
- destination: effectiveControl?.state === "paused" || hasEarlierUnsettledSend ? "queue" : sendDestinationRef.current?.() ?? "chat",
2323
- text: sendText,
2324
- annotations: annotationsAtSend,
2325
- resources,
2326
- occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
2327
- state: "sending",
2328
- input,
2329
- draftPayload: currentPayload ? { ...currentPayload, text: sendText } : null,
2330
- newerShadow: {
2331
- text: explicit === void 0 ? "" : valueRef.current,
2332
- resources: explicit === void 0 ? [] : [...restoredResourcesRef.current],
2333
- annotations: explicit === void 0 ? [] : cloneAnnotations(annotationsRef.current),
2334
- policy: pickedPolicy(policyPickedRef, policyRef)
2335
- },
2336
- canRetry: true
2337
- };
2338
- if (explicit === void 0) {
2339
- valueRef.current = "";
2340
- annotationsRef.current = [];
2341
- restoredResourcesRef.current = [];
2342
- localEditRevision.current += 1;
2343
- setValue("");
2344
- setAnnotations([]);
2345
- setAnnotationReviewTargetId(null);
2346
- setRestoredResources([]);
2347
- }
2348
- replaceOptimisticSends((current) => [...current, operation]);
2349
- queueMicrotask(processOptimisticSends);
2350
- setError(null);
2351
- onSubmitted?.(sendText, input);
2352
- return true;
2353
- },
2354
- [
2355
- currentDraftPayload,
2356
- dispatch,
2357
- onSubmitted,
2358
- processOptimisticSends,
2359
- replaceOptimisticSends,
2360
- sending,
2361
- sessionId,
2362
- targetKey,
2363
- t
2364
- ]
2365
- );
2366
- const steer = useCallback(async (text) => await dispatch("steer", text), [dispatch]);
2367
- const takesBusyPath = useCallback(
2368
- () => effectiveControlRef.current?.state !== "paused" && sendDestinationRef.current?.() === "queue",
2369
- []
2370
- );
2371
- const send = useCallback(
2372
- async (explicit) => {
2373
- if (busySendRef.current === "steer" && pendingOperationRef.current?.delivery !== "send" && takesBusyPath()) {
2374
- return await dispatch("steer", explicit, true);
2375
- }
2376
- return await sendToQueue(explicit, busySendRef.current === "steer");
2377
- },
2378
- [dispatch, sendToQueue, takesBusyPath]
2379
- );
2380
- const sendAlternate = useCallback(
2381
- async (explicit) => busySendRef.current === "steer" ? await sendToQueue(explicit) : await steer(explicit),
2382
- [sendToQueue, steer]
2383
- );
2384
- const alternateSend = !singleSend && takesBusyPath() ? busySend === "steer" ? "queue" : "steer" : null;
2385
- const retryOptimisticMessage = useCallback(
2386
- (clientEventId) => {
2387
- if (sendBlockedRef.current?.() === true) return;
2388
- const currentSteering = steeringRef.current;
2389
- if (currentSteering?.phase === "failed" && currentSteering.clientEventId === clientEventId) {
2390
- void dispatch("steer");
2391
- return;
2392
- }
2393
- replaceOptimisticSends(
2394
- (current) => current.map((operation) => {
2395
- if (operation.clientEventId !== clientEventId || operation.state !== "failed") {
2396
- return operation;
2397
- }
2398
- if (operation.outcomeUnknown) {
2399
- return { ...operation, state: "sending", error: void 0 };
2400
- }
2401
- if (operation.retryable === false) return operation;
2402
- const nextClientEventId = generateClientEventId();
2403
- const currentPersonalResourceAttachment = resolveSendExtras(
2404
- sendExtrasRef.current
2405
- ).personalResourceAttachment;
2406
- const retryInput = composeSendInput(
2407
- operation.text,
2408
- nextClientEventId,
2409
- {
2410
- ...operation.input,
2411
- ...currentPersonalResourceAttachment ? { personalResourceAttachment: currentPersonalResourceAttachment } : {}
2412
- },
2413
- {
2414
- ...effectiveControlRef.current?.controlEtag ? { controlEtag: effectiveControlRef.current.controlEtag } : {},
2415
- resources: operation.resources,
2416
- annotations: operation.annotations
2417
- }
2418
- );
2419
- return {
2420
- ...operation,
2421
- clientEventId: nextClientEventId,
2422
- input: retryInput,
2423
- draftPayload: operation.draftPayload,
2424
- // A new key goes ahead from the draft as it is now.
2425
- expectedDraftRevision: void 0,
2426
- occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
2427
- state: "sending",
2428
- error: void 0,
2429
- retryable: void 0,
2430
- outcomeUnknown: false,
2431
- canRetry: true
2432
- };
2433
- })
2434
- );
2435
- queueMicrotask(processOptimisticSends);
2436
- },
2437
- [dispatch, processOptimisticSends, replaceOptimisticSends]
2438
- );
2439
- const removeOptimisticMessage = useCallback(
2440
- (clientEventId) => {
2441
- if (steeringRef.current?.clientEventId === clientEventId) {
2442
- pendingOperationRef.current = null;
2443
- pendingClientEventId.current = null;
2444
- forgetPendingComposerOperation(pendingComposerOperationKey(workspaceId, sessionId));
2445
- setSteering(null);
2446
- setError(null);
2447
- return;
2448
- }
2449
- const removed = optimisticSendsRef.current.find(
2450
- (operation) => operation.clientEventId === clientEventId
2451
- );
2452
- replaceOptimisticSends(
2453
- (current) => current.filter((operation) => operation.clientEventId !== clientEventId)
2454
- );
2455
- if (removed?.state === "failed" && removed.draftPayload) {
2456
- void forgetRemovedSendDraft(removed.draftPayload);
2457
- }
2458
- },
2459
- [forgetRemovedSendDraft, replaceOptimisticSends, sessionId, workspaceId]
2460
- );
2461
- const hasReadyResources = restoredResources.length > 0 || (resolveSendExtras(sendExtrasRef.current).resources?.length ?? 0) > 0;
2462
- const hasPendingOperation = pendingOperationRef.current !== null;
2463
- const annotationsComplete = annotations.every((annotation) => annotation.note.trim().length > 0);
2464
- const pause = useCallback(
2465
- async (reason) => {
2466
- const ownedTargetKey = targetKey;
2467
- const ownedGeneration = targetGeneration.current;
2468
- if (!sessionId || pausing || targetKeyRef.current !== ownedTargetKey) {
2469
- return;
2470
- }
2471
- setPausing(true);
2472
- setError(null);
2473
- try {
2474
- const clientEventId = generateClientEventId();
2475
- const effectiveControl = effectiveControlRef.current;
2476
- const result = await replayOutcomeUnknown(
2477
- () => client.pauseSession(workspaceId, sessionId, {
2478
- clientEventId,
2479
- ...reason !== void 0 ? { reason } : {},
2480
- ...effectiveControl?.controlEtag ? { expectedControlEtag: effectiveControl.controlEtag } : {}
2481
- })
2482
- );
2483
- if (targetKeyRef.current === ownedTargetKey && targetGeneration.current === ownedGeneration) {
2484
- setAcceptedControl(result.effectiveControl);
2485
- }
2486
- } catch (cause) {
2487
- if (targetKeyRef.current === ownedTargetKey && targetGeneration.current === ownedGeneration) {
2488
- setError(markActionFailure(normalizeError(cause)));
2489
- }
2490
- } finally {
2491
- if (targetKeyRef.current === ownedTargetKey && targetGeneration.current === ownedGeneration) {
2492
- setPausing(false);
2493
- }
2494
- }
2495
- },
2496
- [client, workspaceId, sessionId, pausing, targetKey]
2497
- );
2498
- const resume = useCallback(
2499
- async (reason) => {
2500
- const ownedTargetKey = targetKey;
2501
- const ownedGeneration = targetGeneration.current;
2502
- if (!sessionId || resuming || targetKeyRef.current !== ownedTargetKey) return;
2503
- setResuming(true);
2504
- setError(null);
2505
- try {
2506
- const clientEventId = generateClientEventId();
2507
- const effectiveControl = effectiveControlRef.current;
2508
- const result = await replayOutcomeUnknown(
2509
- () => client.resumeSession(workspaceId, sessionId, {
2510
- clientEventId,
2511
- ...reason !== void 0 ? { reason } : {},
2512
- ...effectiveControl?.controlEtag ? { expectedControlEtag: effectiveControl.controlEtag } : {}
2513
- })
2514
- );
2515
- if (targetKeyRef.current === ownedTargetKey && targetGeneration.current === ownedGeneration) {
2516
- setAcceptedControl(result.effectiveControl);
2517
- }
2518
- } catch (cause) {
2519
- if (targetKeyRef.current === ownedTargetKey && targetGeneration.current === ownedGeneration) {
2520
- setError(markActionFailure(normalizeError(cause)));
2521
- }
2522
- } finally {
2523
- if (targetKeyRef.current === ownedTargetKey && targetGeneration.current === ownedGeneration) {
2524
- setResuming(false);
2525
- }
2526
- }
2527
- },
2528
- [client, workspaceId, sessionId, resuming, targetKey]
2529
- );
2530
- const resumeScope = useCallback(
2531
- async (option) => {
2532
- const ownedTargetKey = targetKey;
2533
- const ownedGeneration = targetGeneration.current;
2534
- if (!sessionId || resuming || targetKeyRef.current !== ownedTargetKey) return;
2535
- setResuming(true);
2536
- setError(null);
2537
- try {
2538
- if (option.scope === "workspace") {
2539
- const workspaceBlocker = effectiveControlRef.current?.blockers.find(
2540
- (blocker) => blocker.kind === "workspace"
2541
- );
2542
- if (!client.setWorkspaceInferenceState) {
2543
- throw new ComposerWorkspaceControlUnavailableError();
2544
- }
2545
- const clientEventId = generateClientEventId();
2546
- await replayOutcomeUnknown(
2547
- () => client.setWorkspaceInferenceState(workspaceId, {
2548
- action: "resume",
2549
- clientEventId,
2550
- ...workspaceBlocker ? { expectedRevision: workspaceBlocker.revision } : {}
2551
- })
2552
- );
2553
- } else if (option.scope === "session" && option.targetId) {
2554
- const target = await client.getQueue(workspaceId, option.targetId);
2555
- if (targetKeyRef.current !== ownedTargetKey || targetGeneration.current !== ownedGeneration) {
2556
- return;
2557
- }
2558
- const clientEventId = generateClientEventId();
2559
- await replayOutcomeUnknown(
2560
- () => client.resumeSession(workspaceId, option.targetId, {
2561
- clientEventId,
2562
- expectedControlEtag: target.effectiveControl.controlEtag
2563
- })
2564
- );
2565
- } else {
2566
- const clientEventId = generateClientEventId();
2567
- const effectiveControl = effectiveControlRef.current;
2568
- const result = await replayOutcomeUnknown(
2569
- () => client.resumeSession(workspaceId, sessionId, {
2570
- clientEventId,
2571
- ...effectiveControl?.controlEtag ? { expectedControlEtag: effectiveControl.controlEtag } : {}
2572
- })
2573
- );
2574
- if (targetKeyRef.current === ownedTargetKey && targetGeneration.current === ownedGeneration) {
2575
- setAcceptedControl(result.effectiveControl);
2576
- }
2577
- }
2578
- } catch (cause) {
2579
- if (targetKeyRef.current === ownedTargetKey && targetGeneration.current === ownedGeneration) {
2580
- setError(markActionFailure(asError(cause)));
2581
- }
2582
- } finally {
2583
- if (targetKeyRef.current === ownedTargetKey && targetGeneration.current === ownedGeneration) {
2584
- setResuming(false);
2585
- }
2586
- }
2587
- },
2588
- [client, resuming, sessionId, targetKey, workspaceId]
2589
- );
2590
- const updateValue = useCallback(
2591
- (next) => {
2592
- if (targetKeyRef.current !== targetKey) return;
2593
- localEditRevision.current += 1;
2594
- valueRef.current = next;
2595
- pendingOperationRef.current = updatePendingComposerShadow(
2596
- pendingOperationKey,
2597
- pendingOperationRef.current,
2598
- {
2599
- text: next,
2600
- resources: mergeResources(
2601
- restoredResourcesRef.current,
2602
- resolveSendExtras(sendExtrasRef.current).resources ?? []
2603
- ),
2604
- annotations: annotationsRef.current,
2605
- policy: pickedPolicy(policyPickedRef, policyRef)
2606
- }
2607
- );
2608
- setOptimisticDraftShadow({
2609
- text: next,
2610
- resources: mergeResources(
2611
- restoredResourcesRef.current,
2612
- resolveSendExtras(sendExtrasRef.current).resources ?? []
2613
- ),
2614
- annotations: annotationsRef.current,
2615
- policy: pickedPolicy(policyPickedRef, policyRef)
2616
- });
2617
- setValue(next);
2618
- },
2619
- [pendingOperationKey, setOptimisticDraftShadow, targetKey]
2620
- );
2621
- const updateAnnotations = useCallback(
2622
- (next, reviewTargetId = null) => {
2623
- if (targetKeyRef.current !== targetKey) return;
2624
- localEditRevision.current += 1;
2625
- annotationsRef.current = next;
2626
- pendingOperationRef.current = updatePendingComposerShadow(
2627
- pendingOperationKey,
2628
- pendingOperationRef.current,
2629
- {
2630
- text: valueRef.current,
2631
- resources: mergeResources(
2632
- restoredResourcesRef.current,
2633
- resolveSendExtras(sendExtrasRef.current).resources ?? []
2634
- ),
2635
- annotations: next,
2636
- policy: pickedPolicy(policyPickedRef, policyRef)
2637
- }
2638
- );
2639
- setOptimisticDraftShadow({
2640
- text: valueRef.current,
2641
- resources: mergeResources(
2642
- restoredResourcesRef.current,
2643
- resolveSendExtras(sendExtrasRef.current).resources ?? []
2644
- ),
2645
- annotations: next,
2646
- policy: pickedPolicy(policyPickedRef, policyRef)
2647
- });
2648
- setAnnotations(next);
2649
- setAnnotationReviewTargetId(reviewTargetId);
2650
- },
2651
- [pendingOperationKey, setOptimisticDraftShadow, targetKey]
2652
- );
2653
- const addAnnotation = useCallback(
2654
- (annotation) => {
2655
- const next = [...annotationsRef.current, annotation];
2656
- updateAnnotations(next, annotation.id);
2657
- },
2658
- [updateAnnotations]
2659
- );
2660
- const updateAnnotation = useCallback(
2661
- (id, note) => {
2662
- updateAnnotations(
2663
- annotationsRef.current.map(
2664
- (annotation) => annotation.id === id ? { ...annotation, note } : annotation
2665
- )
2666
- );
2667
- },
2668
- [updateAnnotations]
2669
- );
2670
- const removeAnnotation = useCallback(
2671
- (id) => {
2672
- updateAnnotations(annotationsRef.current.filter((annotation) => annotation.id !== id));
2673
- },
2674
- [updateAnnotations]
2675
- );
2676
- const clearAnnotationReviewTarget = useCallback(() => {
2677
- setAnnotationReviewTargetId(null);
2678
- }, []);
2679
- const requestAnnotationReview = useCallback((id) => {
2680
- const current = annotationsRef.current;
2681
- if (current.length === 0) {
2682
- setAnnotationReviewTargetId(null);
2683
- return;
2684
- }
2685
- if (id && current.some((annotation) => annotation.id === id)) {
2686
- setAnnotationReviewTargetId(id);
2687
- return;
2688
- }
2689
- const incomplete = current.find((annotation) => annotation.note.trim().length === 0);
2690
- setAnnotationReviewTargetId(incomplete?.id ?? current[0].id);
2691
- }, []);
2692
- const updatePolicy = useCallback(
2693
- (next) => {
2694
- if (targetKeyRef.current !== targetKey) return;
2695
- localEditRevision.current += 1;
2696
- policyRef.current = next;
2697
- policyPickedRef.current = true;
2698
- savePickPromptlyRef.current = true;
2699
- setPolicyPicked(policyPickedRef.current);
2700
- const shadow = {
2701
- text: valueRef.current,
2702
- resources: mergeResources(
2703
- restoredResourcesRef.current,
2704
- resolveSendExtras(sendExtrasRef.current).resources ?? []
2705
- ),
2706
- annotations: annotationsRef.current,
2707
- policy: next
2708
- };
2709
- pendingOperationRef.current = updatePendingComposerShadow(
2710
- pendingOperationKey,
2711
- pendingOperationRef.current,
2712
- shadow
2713
- );
2714
- setOptimisticDraftShadow(shadow);
2715
- setPolicy(next);
2716
- },
2717
- [pendingOperationKey, setOptimisticDraftShadow, targetKey]
2718
- );
2719
- const updateModel = useCallback(
2720
- (model) => {
2721
- const current = policyRef.current;
2722
- if (current) updatePolicy({ ...current, model });
2723
- },
2724
- [updatePolicy]
2725
- );
2726
- const updateReasoningEffort = useCallback(
2727
- (reasoningEffort) => {
2728
- const current = policyRef.current;
2729
- if (current) updatePolicy({ ...current, reasoningEffort });
2730
- },
2731
- [updatePolicy]
2732
- );
2733
- const updateLatencyMode = useCallback(
2734
- (latencyMode) => {
2735
- const current = policyRef.current;
2736
- if (current) updatePolicy({ ...current, latencyMode });
2737
- },
2738
- [updatePolicy]
2739
- );
2740
- const removeRestoredResource = useCallback(
2741
- (index) => {
2742
- if (targetKeyRef.current !== targetKey) return;
2743
- localEditRevision.current += 1;
2744
- const next = restoredResourcesRef.current.filter((_, candidate) => candidate !== index);
2745
- restoredResourcesRef.current = next;
2746
- pendingOperationRef.current = updatePendingComposerShadow(
2747
- pendingOperationKey,
2748
- pendingOperationRef.current,
2749
- {
2750
- text: valueRef.current,
2751
- resources: mergeResources(next, resolveSendExtras(sendExtrasRef.current).resources ?? []),
2752
- annotations: annotationsRef.current,
2753
- policy: pickedPolicy(policyPickedRef, policyRef)
2754
- }
2755
- );
2756
- setOptimisticDraftShadow({
2757
- text: valueRef.current,
2758
- resources: mergeResources(next, resolveSendExtras(sendExtrasRef.current).resources ?? []),
2759
- annotations: annotationsRef.current,
2760
- policy: pickedPolicy(policyPickedRef, policyRef)
2761
- });
2762
- setRestoredResources(next);
2763
- },
2764
- [pendingOperationKey, setOptimisticDraftShadow, targetKey]
2765
- );
2766
- const hasDraftContent = useCallback(() => {
2767
- const current = draftRef.current;
2768
- const extras = resolveSendExtras(sendExtrasRef.current);
2769
- 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;
2770
- }, []);
2771
- const restoreOptimisticMessage = useCallback(
2772
- (clientEventId) => {
2773
- if (targetKeyRef.current !== targetKey || draftLoading || pendingOperationRef.current || hasDraftContent())
2774
- return;
2775
- const operation = optimisticSendsRef.current.find(
2776
- (candidate) => candidate.clientEventId === clientEventId
2777
- );
2778
- if (!operation || operation.state !== "failed" || operation.outcomeUnknown) return;
2779
- localEditRevision.current += 1;
2780
- valueRef.current = operation.text;
2781
- restoredResourcesRef.current = [...operation.resources];
2782
- annotationsRef.current = cloneAnnotations(operation.annotations);
2783
- setValue(operation.text);
2784
- setRestoredResources(restoredResourcesRef.current);
2785
- setAnnotations(annotationsRef.current);
2786
- setError(null);
2787
- setOptimisticDraftShadow({
2788
- text: operation.text,
2789
- resources: restoredResourcesRef.current,
2790
- annotations: annotationsRef.current,
2791
- policy: pickedPolicy(policyPickedRef, policyRef)
2792
- });
2793
- replaceOptimisticSends(
2794
- (current) => current.filter((candidate) => candidate.clientEventId !== clientEventId)
2795
- );
2796
- },
2797
- [draftLoading, hasDraftContent, replaceOptimisticSends, setOptimisticDraftShadow, targetKey]
2798
- );
2799
- const resolveDraftConflict = useCallback(
2800
- async (choice) => {
2801
- const ownedTargetKey = targetKey;
2802
- const ownedGeneration = targetGeneration.current;
2803
- if (!sessionId || !durableDrafts || targetKeyRef.current !== ownedTargetKey) return;
2804
- const remote = await client.getComposerDraft(workspaceId, sessionId);
2805
- if (targetKeyRef.current !== ownedTargetKey || targetGeneration.current !== ownedGeneration) {
2806
- return;
2807
- }
2808
- if (choice === "use_remote") {
2809
- applyDraft(remote);
2810
- setError(null);
2811
- return;
2812
- }
2813
- draftRef.current = remote;
2814
- setDraft(remote);
2815
- setDraftConflict(null);
2816
- setError(null);
2817
- const payload = currentDraftPayload();
2818
- if (payload) {
2819
- await persistPayload({ ...payload, expectedRevision: remote.revision }, void 0);
2820
- }
2821
- },
2822
- [
2823
- applyDraft,
2824
- client,
2825
- currentDraftPayload,
2826
- durableDrafts,
2827
- persistPayload,
2828
- sessionId,
2829
- targetKey,
2830
- workspaceId
2831
- ]
2832
- );
2833
- const identityMatches = stateTargetKey === targetKey;
2834
- const visibleSteering = identityMatches ? steering : null;
2835
- const visibleOptimisticMessages = identityMatches ? [
2836
- ...optimisticSends.map(
2837
- ({ input: _input, draftPayload: _payload, canRetry: _retry, ...item }) => item
2838
- ),
2839
- ...visibleSteering?.clientEventId ? [
2840
- {
2841
- clientEventId: visibleSteering.clientEventId,
2842
- delivery: "steer",
2843
- destination: "chat",
2844
- text: visibleSteering.text,
2845
- annotations: pendingOperationRef.current?.delivery === "steer" ? pendingOperationRef.current.annotationsAtSend : [],
2846
- resources: pendingOperationRef.current?.delivery === "steer" ? pendingOperationRef.current.resourcesAtSend : [],
2847
- occurredAt: steeringOccurredAtRef.current,
2848
- state: visibleSteering.phase === "submitting" ? "sending" : visibleSteering.phase === "failed" ? "failed" : "queued",
2849
- turnId: visibleSteering.turnId,
2850
- triggerEventId: visibleSteering.triggerEventId,
2851
- ...visibleSteering.error ? { error: visibleSteering.error } : {},
2852
- ...visibleSteering.outcomeUnknown !== void 0 ? { outcomeUnknown: visibleSteering.outcomeUnknown } : {}
2853
- }
2854
- ] : []
2855
- ] : [];
2856
- const reloadDraft = useCallback(async () => await loadDraft(true), [loadDraft]);
2857
- const clearError = useCallback(() => {
2858
- if (targetKeyRef.current !== targetKey) return;
2859
- setError(null);
2860
- setDraftReadError(null);
2861
- setDraftConflict(null);
2862
- }, [targetKey]);
2863
- const visibleValue = identityMatches ? valueRef.current : "";
2864
- return {
2865
- value: visibleValue,
2866
- setValue: updateValue,
2867
- annotations: identityMatches ? annotations : [],
2868
- addAnnotation,
2869
- updateAnnotation,
2870
- removeAnnotation,
2871
- annotationReviewTargetId: identityMatches ? annotationReviewTargetId : null,
2872
- clearAnnotationReviewTarget,
2873
- requestAnnotationReview,
2874
- hasDraftContent,
2875
- send,
2876
- sendToQueue,
2877
- busySend,
2878
- singleSend,
2879
- alternateSend: identityMatches ? alternateSend : null,
2880
- working: identityMatches && takesBusyPath(),
2881
- sendAlternate: singleSend ? void 0 : sendAlternate,
2882
- optimisticMessages: visibleOptimisticMessages,
2883
- retryOptimisticMessage,
2884
- restoreOptimisticMessage: !draftLoading && !pendingOperationRef.current && !hasDraftContent() ? restoreOptimisticMessage : void 0,
2885
- removeOptimisticMessage,
2886
- steer,
2887
- steering: visibleSteering,
2888
- // Receipt-backed: an accepted Steer stops the previous attempt, and an
2889
- // accepted Pause whose receipt still reports physical settlement stops the
2890
- // current one. Once the authoritative control catches up, the queue
2891
- // snapshot owns this projection.
2892
- stoppingAttempt: identityMatches ? visibleSteering?.phase === "accepted" && visibleSteering.stoppingPreviousAttempt === true ? "previous" : pendingAcceptedControl?.state === "paused" && pendingAcceptedControl.settlement !== null ? "current" : null : null,
2893
- sending: identityMatches ? sending : false,
2894
- canSend: identityMatches && Boolean(sessionId) && !sending && !draftLoading && policy !== null && sendBlockedRef.current?.() !== true && annotationsComplete && (hasPendingOperation || visibleValue.trim().length > 0 || hasReadyResources || annotations.length > 0),
2895
- // The saved draft is still loading, or its first read is being retried:
2896
- // an early Send waits for it (the composer bounds how long).
2897
- preparing: identityMatches ? Boolean(sessionId) && (draftLoading || draftHydrationRetrying) : Boolean(sessionId) && durableDrafts,
2898
- pause,
2899
- pausing: identityMatches ? pausing : false,
2900
- resume,
2901
- resumeScope,
2902
- resuming: identityMatches ? resuming : false,
2903
- effectiveControl: identityMatches ? effectiveControlRef.current : null,
2904
- draft: identityMatches ? draft : null,
2905
- draftRevision: identityMatches ? draft?.revision ?? 0 : 0,
2906
- draftLoading: identityMatches ? draftLoading : Boolean(sessionId) && durableDrafts,
2907
- draftSaving: identityMatches ? draftSaving : false,
2908
- draftConflict: identityMatches ? draftConflict : null,
2909
- flushDraft,
2910
- policy: identityMatches ? policy : null,
2911
- sendPolicy: identityMatches && policyPicked ? policy : null,
2912
- setModel: updateModel,
2913
- setReasoningEffort: updateReasoningEffort,
2914
- setLatencyMode: updateLatencyMode,
2915
- draftPersistence: durableDrafts ? "durable" : "disabled",
2916
- applyDraft,
2917
- reloadDraft,
2918
- resolveDraftConflict,
2919
- restoredResources: identityMatches ? restoredResources : [],
2920
- removeRestoredResource,
2921
- ...sessionId ? {
2922
- fileSource: {
2923
- // The SDK client reads files; a narrower session proxy without
2924
- // those reads shows restored files as named chips.
2925
- client,
2926
- workspaceId,
2927
- sessionId
2928
- }
2929
- } : {},
2930
- error: identityMatches ? error ?? draftReadError : null,
2931
- clearError,
2932
- canBuyCredits: options.canBuyCredits ?? true,
2933
- reconnecting: identityMatches ? serviceWaiting : false
2934
- };
2935
- }
2936
- function isComposerDraftEvent(event) {
2937
- return event.type === "user.message" || event.type === "session.queue.changed" || // A following draft shows the chat's settings, which this event changes.
2938
- event.type === "session.model_settings.updated";
2939
- }
2940
- var FILE_ONLY_MESSAGE_TEXT = (t) => t("hooks.useComposer.seeAttachedContext");
2941
- function resolveSendExtras(extras) {
2942
- return (typeof extras === "function" ? extras() : extras) ?? {};
2943
- }
2944
- function composeSendInput(text, clientEventId, extras, bound = {}) {
2945
- return { ...resolveSendExtras(extras), ...bound, text, clientEventId };
2946
- }
2947
- function shouldSubmitOnKey(event) {
2948
- if (event.key !== "Enter" || event.shiftKey) {
2949
- return false;
2950
- }
2951
- return event.nativeEvent?.isComposing !== true;
2952
- }
2953
- function shouldSteerOnKey(event) {
2954
- return event.metaKey === true || event.ctrlKey === true;
2955
- }
2956
- function generateClientEventId() {
2957
- return globalThis.crypto.randomUUID();
2958
- }
2959
- function isOutcomeUnknownError(cause) {
2960
- return typeof cause === "object" && cause !== null && cause.outcomeUnknown === true;
2961
- }
2962
- async function replayOutcomeUnknown(command) {
2963
- try {
2964
- return await command();
2965
- } catch (cause) {
2966
- if (!isOutcomeUnknownError(cause)) throw cause;
2967
- return await command();
2968
- }
2969
- }
2970
- function asError(cause) {
2971
- return normalizeError(cause);
2972
- }
2973
- function promptRoutingFromAcceptedEvent(event) {
2974
- if (typeof event?.payload !== "object" || event.payload === null || Array.isArray(event.payload)) {
2975
- return null;
2976
- }
2977
- const routing = event.payload.routing;
2978
- return routing === "accepted_for_execution" || routing === "queued_for_execution" || routing === "accepted_for_steering" ? routing : null;
2979
- }
2980
- function isDraftConflictError(error) {
2981
- const apiError = error;
2982
- return apiError.status === 409 && apiError.outcomeUnknown !== true && apiError.code === "DRAFT_CHANGED";
2983
- }
2984
- function draftPayload(draft) {
2985
- return {
2986
- expectedRevision: draft.revision,
2987
- text: draft.text,
2988
- resources: draft.resources,
2989
- annotations: draft.annotations ?? [],
2990
- // A draft that follows the chat's settings is saved without them.
2991
- ...draft.policyFollowsSession ? {} : {
2992
- model: draft.model,
2993
- reasoningEffort: draft.reasoningEffort,
2994
- latencyMode: draft.latencyMode
2995
- }
2996
- };
2997
- }
2998
- function policyFromDraft(draft) {
2999
- return {
3000
- model: draft.model,
3001
- reasoningEffort: draft.reasoningEffort,
3002
- latencyMode: draft.latencyMode
3003
- };
3004
- }
3005
- function pickedPolicy(picked, policy) {
3006
- return picked.current ? policy.current ?? void 0 : void 0;
3007
- }
3008
- function samePolicy(a, b) {
3009
- return a !== null && a.model === b.model && a.reasoningEffort === b.reasoningEffort && a.latencyMode === b.latencyMode;
3010
- }
3011
- function composerDraftPayload(base, text, restoredResources, annotations, policy, additionalResources) {
3012
- return {
3013
- expectedRevision: base.revision,
3014
- text,
3015
- resources: mergeResources(restoredResources, additionalResources),
3016
- annotations,
3017
- ...policy ? {
3018
- model: policy.model,
3019
- reasoningEffort: policy.reasoningEffort,
3020
- latencyMode: policy.latencyMode
3021
- } : {}
3022
- };
3023
- }
3024
- function draftSignature(payload) {
3025
- const { expectedRevision: _revision, ...content } = payload;
3026
- return JSON.stringify(content);
3027
- }
3028
- function pickNotSaved(payload, saved) {
3029
- if (payload.model === void 0) return false;
3030
- return !saved || saved.policyFollowsSession || saved.model !== payload.model || saved.reasoningEffort !== payload.reasoningEffort || saved.latencyMode !== payload.latencyMode;
3031
- }
3032
- function composerDraftHasContent(draft) {
3033
- return draft.text.length > 0 || (draft.annotations ?? []).length > 0 || draft.resources.length > 0 || draft.sourceTurnId !== null;
3034
- }
3035
- var DRAFT_CONFLICT_REREADS = 3;
3036
- var leftDraftSaves = /* @__PURE__ */ new Map();
3037
- var pageDraftWrites = /* @__PURE__ */ new Map();
3038
- var PAGE_DRAFT_WRITES_PER_CHAT = 8;
3039
- var PAGE_DRAFT_WRITE_CHATS = 64;
3040
- function rememberPageDraftWrite(chatKey, content) {
3041
- const writes = (pageDraftWrites.get(chatKey) ?? []).filter((write) => write !== content);
3042
- writes.push(content);
3043
- pageDraftWrites.delete(chatKey);
3044
- pageDraftWrites.set(chatKey, writes.slice(-PAGE_DRAFT_WRITES_PER_CHAT));
3045
- if (pageDraftWrites.size > PAGE_DRAFT_WRITE_CHATS) {
3046
- const oldest = pageDraftWrites.keys().next().value;
3047
- if (oldest !== void 0) pageDraftWrites.delete(oldest);
3048
- }
3049
- }
3050
- function isPageDraftWrite(chatKey, content) {
3051
- return pageDraftWrites.get(chatKey)?.includes(content) ?? false;
3052
- }
3053
- function sendDraftBasis(base, basis) {
3054
- if (!base) return { revision: void 0, behind: false };
3055
- if (basis !== null && basis < base.revision) return { revision: basis, behind: true };
3056
- return { revision: base.revision, behind: false };
3057
- }
3058
- var LEFT_DRAFT_SAVE_WAIT_MS = 3e3;
3059
- function delay(ms) {
3060
- return new Promise((resolve) => setTimeout(resolve, ms));
3061
- }
3062
- function saveLeftDraft(unsaved, settledWrites, previousSaves) {
3063
- const left = unsaved.current;
3064
- unsaved.current = null;
3065
- if (!left) return;
3066
- const chatKey = `${left.workspaceId}\0${left.sessionId}`;
3067
- const content = draftContentKey(left.payload);
3068
- const save = previousSaves.catch(() => void 0).then(async () => {
3069
- const settled = settledWrites.get(chatKey);
3070
- const base = left.payload.expectedRevision;
3071
- if (settled && settled.revision >= base && settled.content === content) return;
3072
- const request = {
3073
- ...left.payload,
3074
- expectedRevision: Math.max(settled?.revision ?? base, base)
3075
- };
3076
- rememberPageDraftWrite(chatKey, content);
3077
- const saved = await left.client.saveComposerDraft(left.workspaceId, left.sessionId, request);
3078
- settledWrites.set(chatKey, { revision: saved.revision, content });
3079
- }).catch(() => void 0).finally(() => {
3080
- if (leftDraftSaves.get(chatKey) === save) leftDraftSaves.delete(chatKey);
3081
- });
3082
- leftDraftSaves.set(chatKey, save);
3083
- }
3084
- function draftContentKey(payload) {
3085
- const { expectedRevision: _revision, resources, ...content } = payload;
3086
- return JSON.stringify({ ...content, resources: resources.map(resourceIdentity) });
3087
- }
3088
- function resourceIdentity(resource) {
3089
- return resource.kind === "file" ? `file:${resource.fileId}\0${resource.mountPath ?? `${DEFAULT_FILE_RESOURCE_MOUNT_ROOT}/${resource.fileId}`}` : JSON.stringify(resource);
3090
- }
3091
- function mergeResources(base, additions) {
3092
- const seen = /* @__PURE__ */ new Set();
3093
- return [...base, ...additions].filter((resource) => {
3094
- const key = resourceIdentity(resource);
3095
- if (seen.has(key)) return false;
3096
- seen.add(key);
3097
- return true;
3098
- });
3099
- }
3100
-
3101
- export {
3102
- notifyObserver,
3103
- forgetAllComposerOperations,
3104
- useComposer,
3105
- FILE_ONLY_MESSAGE_TEXT,
3106
- composeSendInput,
3107
- shouldSubmitOnKey,
3108
- shouldSteerOnKey
3109
- };
3110
- //# sourceMappingURL=chunk-YW4YRCXI.js.map