@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,4480 +0,0 @@
1
- "use client";
2
- import {
3
- useSessionStartupState
4
- } from "./chunk-D6LH6JPE.js";
5
- import {
6
- deniesRetainedView,
7
- useRetainedSessionView
8
- } from "./chunk-6CKSMBLT.js";
9
- import {
10
- uploadScopeForSession,
11
- useFileAttachments
12
- } from "./chunk-IE5MZEOM.js";
13
- import {
14
- projectPendingApprovals
15
- } from "./chunk-BC7PTVXW.js";
16
- import {
17
- buildTimeline,
18
- groupTimeline,
19
- isToolOutputPreviewEvent,
20
- sessionStatusFromEvents,
21
- useToolOutputReads
22
- } from "./chunk-JD6LHU26.js";
23
- import {
24
- forgetSessionHumanInputDrafts,
25
- pruneHumanInputDrafts
26
- } from "./chunk-VAN6CEAV.js";
27
- import {
28
- useSharedQuery
29
- } from "./chunk-DSQNSLQW.js";
30
- import {
31
- isActionableHumanInputRequest
32
- } from "./chunk-57MB2QGY.js";
33
- import {
34
- admissionRecheckControl
35
- } from "./chunk-MRNAHGBL.js";
36
- import {
37
- readAcknowledgementFrontier,
38
- sessionAttentionReadThroughSequence
39
- } from "./chunk-IOBL5KYR.js";
40
- import {
41
- promptSendDestination,
42
- sessionArchived,
43
- sessionTurnKeepsRunControl
44
- } from "./chunk-DG5DQFS4.js";
45
- import {
46
- useClientConfigFlags
47
- } from "./chunk-XESA3B7W.js";
48
- import {
49
- joinClientConfigRead
50
- } from "./chunk-IGVL3ELX.js";
51
- import {
52
- FILE_ONLY_MESSAGE_TEXT,
53
- notifyObserver,
54
- useComposer
55
- } from "./chunk-YW4YRCXI.js";
56
- import {
57
- DEFAULT_TRANSIENT_READ_RETRY,
58
- projectionReadThrough,
59
- transientReadRetryStep,
60
- useDebouncedCallback,
61
- useMutationRunner,
62
- usePageLiveActivity,
63
- usePolledValue,
64
- useSessionEventTrigger
65
- } from "./chunk-SW4S6I5E.js";
66
- import {
67
- normalizeError
68
- } from "./chunk-CM7LVUKC.js";
69
- import {
70
- useEmbeddedGoal,
71
- useEmbeddedHumanInputSession,
72
- useEmbeddedSession,
73
- useEmbeddedSessionRead,
74
- useOpenGeni,
75
- useOpenGeniClient
76
- } from "./chunk-BVUAHAQX.js";
77
- import {
78
- coerceReasoningEffortForModel,
79
- defaultEffortForModel,
80
- projectPickerRows,
81
- runnableLatencyModesForModel,
82
- sortPickerRows
83
- } from "./chunk-O4UAH7WR.js";
84
- import {
85
- useOpenGeniText
86
- } from "./chunk-6FWBGVFL.js";
87
-
88
- // src/conversation-timeline.ts
89
- function conversationTimeline(items, queue, composer) {
90
- const queued = new Set(
91
- queue.queue.filter((turn) => turn.metadata.delivery !== "steer").map((turn) => turn.triggerEventId)
92
- );
93
- const pending = composer.optimisticMessages ?? [];
94
- const pendingQueue = new Set(
95
- pending.filter(
96
- (message) => message.destination === "queue" && !(message.turnId && message.appliedQueueVersion != null && queue.snapshot && queue.snapshot.version >= message.appliedQueueVersion && !queue.queue.some((turn) => turn.id === message.turnId))
97
- ).map((message) => `user-message:${message.clientEventId}`)
98
- );
99
- const visible = items.filter(
100
- (item) => item.kind !== "user-message" || !queued.has(item.id) && !pendingQueue.has(item.reconciliationKey ?? "")
101
- );
102
- const keys = new Set(
103
- visible.flatMap((item) => item.kind === "user-message" ? [item.reconciliationKey] : [])
104
- );
105
- const optimistic = pending.filter(
106
- (message) => (message.destination === "chat" || message.state === "failed") && !keys.has(`user-message:${message.clientEventId}`) && !queue.queue.some((turn) => turn.id === message.turnId)
107
- ).map((message) => ({
108
- kind: "user-message",
109
- id: `optimistic:${message.clientEventId}`,
110
- reconciliationKey: `user-message:${message.clientEventId}`,
111
- text: message.text,
112
- annotations: message.annotations.map((annotation, ordinal) => ({ ...annotation, ordinal })),
113
- resources: message.resources,
114
- tools: [],
115
- occurredAt: message.occurredAt,
116
- delivery: {
117
- state: message.state,
118
- ...message.error ? { error: message.error } : {},
119
- ...message.state === "failed" ? {
120
- ...message.retryable !== false && composer.retryOptimisticMessage ? { onRetry: () => composer.retryOptimisticMessage?.(message.clientEventId) } : {},
121
- ...message.retryable === false && composer.restoreOptimisticMessage ? { onEdit: () => composer.restoreOptimisticMessage?.(message.clientEventId) } : {},
122
- onRemove: () => composer.removeOptimisticMessage?.(message.clientEventId)
123
- } : {}
124
- }
125
- }));
126
- const failed = optimistic.filter((message) => message.delivery?.state === "failed");
127
- const unsent = optimistic.filter((message) => message.delivery?.state !== "failed");
128
- const ids = new Set(visible.map((item) => item.id));
129
- const steers = (queue.acceptedSteers ?? []).filter((steer) => !ids.has(steer.triggerEventId)).map((steer) => ({
130
- kind: "user-message",
131
- id: steer.triggerEventId,
132
- text: steer.text,
133
- annotations: steer.annotations,
134
- resources: steer.resources,
135
- tools: steer.tools,
136
- occurredAt: steer.occurredAt,
137
- delivery: { state: steer.state }
138
- }));
139
- return [...placeFailedSends(visible, failed), ...unsent, ...steers];
140
- }
141
- function placeFailedSends(items, failed) {
142
- if (failed.length === 0) return items;
143
- const before = /* @__PURE__ */ new Map();
144
- const last = [];
145
- for (const message of failed) {
146
- const sentAt = Date.parse(message.occurredAt);
147
- const newer = items.findIndex(
148
- (item) => item.kind === "user-message" && Date.parse(item.occurredAt) > sentAt
149
- );
150
- if (newer === -1) {
151
- last.push(message);
152
- } else {
153
- before.set(newer, [...before.get(newer) ?? [], message]);
154
- }
155
- }
156
- return [...items.flatMap((item, index) => [...before.get(index) ?? [], item]), ...last];
157
- }
158
-
159
- // src/hooks/use-session.ts
160
- import { useCallback, useEffect, useMemo, useRef, useState } from "react";
161
-
162
- // src/lib/session-detail-read.ts
163
- var lastOrdinal = 0;
164
- var reads = /* @__PURE__ */ new WeakMap();
165
- function readKey(workspaceId, sessionId) {
166
- return `${workspaceId}\0${sessionId}`;
167
- }
168
- function sessionDetailReadMark() {
169
- return lastOrdinal;
170
- }
171
- function readFreshSessionDetail(client, workspaceId, sessionId, options = {}) {
172
- const promise = client.getSession(workspaceId, sessionId, { ...options, fresh: true });
173
- const read = { promise, ordinal: ++lastOrdinal };
174
- let scoped = reads.get(client);
175
- if (!scoped) {
176
- scoped = /* @__PURE__ */ new Map();
177
- reads.set(client, scoped);
178
- }
179
- const key = readKey(workspaceId, sessionId);
180
- scoped.set(key, read);
181
- promise.catch(() => {
182
- if (scoped.get(key) === read) scoped.delete(key);
183
- });
184
- return promise;
185
- }
186
- function joinSessionDetailRead(client, workspaceId, sessionId, mark) {
187
- const read = reads.get(client)?.get(readKey(workspaceId, sessionId));
188
- return read && read.ordinal > mark ? read.promise : null;
189
- }
190
-
191
- // src/hooks/use-session.ts
192
- function isTitleEvent(event) {
193
- return event.type === "session.title_set";
194
- }
195
- function isSessionDetailEvent(event) {
196
- return isTitleEvent(event) || // Description or avatar edits (by a person or the agent) refresh the header.
197
- event.type === "session.profile_set" || // The agent said it waits on a person, or stopped waiting.
198
- event.type === "session.waiting_on.changed" || // The chat's model, effort or speed changed (for example by the agent).
199
- event.type === "session.model_settings.updated" || event.type.startsWith("session.command.") || event.type.startsWith("session.wait.") || event.type === "session.status.changed" || event.type === "system.update.pending";
200
- }
201
- function useSession(sessionId, options = {}) {
202
- const { client, workspaceId, workspaceControlEvent, registerSessionReconciler } = useEmbeddedSessionRead(options);
203
- const enabled = (options.enabled ?? true) && Boolean(sessionId);
204
- const [override, setOverride] = useState(null);
205
- const nextReadRevision = useRef(0);
206
- const nextReadGeneration = useRef(0);
207
- const beginRead = options.beginRead;
208
- const { run, mutating, mutationError, clearMutationError } = useMutationRunner();
209
- const load = useCallback(
210
- async (signal) => {
211
- if (!sessionId) {
212
- return null;
213
- }
214
- let readGeneration2 = 0;
215
- const fetched = await readFreshSessionDetail(client, workspaceId, sessionId, {
216
- signal,
217
- onRequestStart: () => {
218
- readGeneration2 = beginRead?.() ?? ++nextReadGeneration.current;
219
- }
220
- });
221
- setOverride(null);
222
- return {
223
- session: fetched,
224
- revision: ++nextReadRevision.current,
225
- readGeneration: readGeneration2
226
- };
227
- },
228
- [beginRead, client, workspaceId, sessionId]
229
- );
230
- const { data, loading, error, refresh } = usePolledValue(load, {
231
- pollIntervalMs: options.pollIntervalMs,
232
- enabled
233
- });
234
- useEffect(() => {
235
- if (enabled && workspaceControlEvent) void refresh();
236
- }, [enabled, refresh, workspaceControlEvent]);
237
- useEffect(() => {
238
- if (!sessionId || !enabled) return;
239
- return registerSessionReconciler(sessionId, "session", refresh);
240
- }, [enabled, refresh, registerSessionReconciler, sessionId]);
241
- const retained = useRetainedSessionView(
242
- client,
243
- workspaceId,
244
- sessionId,
245
- "detail",
246
- data?.session ?? null,
247
- { enabled, discard: deniesRetainedView(error) }
248
- );
249
- const base = data?.session ?? null;
250
- const readRevision = data?.revision ?? 0;
251
- const readGeneration = data?.readGeneration ?? 0;
252
- const session = useMemo(
253
- () => base && override && override.id === base.id ? { ...base, title: override.title, titleSource: override.titleSource } : base ?? retained,
254
- [base, override, retained]
255
- );
256
- const sharedEvents = options.events;
257
- const refreshDetail = useCallback(() => void refresh(), [refresh]);
258
- const onTitleEvent = useCallback(
259
- (event) => {
260
- if (sharedEvents?.some(
261
- (item) => item.sessionId === sessionId && !isTitleEvent(item) && isSessionDetailEvent(item) && item.sequence > (base?.lastSequence ?? -1)
262
- )) {
263
- void refresh();
264
- } else if (!isTitleEvent(event)) {
265
- if (!base || event.sequence > base.lastSequence) void refresh();
266
- return;
267
- }
268
- if (!base || event.sequence <= base.lastSequence) {
269
- return;
270
- }
271
- const payload = event.payload ?? {};
272
- const title = payload.title;
273
- if (typeof title !== "string") {
274
- return;
275
- }
276
- const source = payload.source === "user" || payload.source === "agent" ? payload.source : null;
277
- setOverride((current) => {
278
- const next = current ?? base;
279
- return { ...next, title, titleSource: source };
280
- });
281
- },
282
- [base, refresh, sharedEvents, sessionId]
283
- );
284
- useSessionEventTrigger(client, workspaceId, sessionId, isSessionDetailEvent, onTitleEvent, {
285
- enabled,
286
- ...options.events !== void 0 ? { events: options.events } : {},
287
- // The detail row is authoritative through its lastSequence: only a later
288
- // event can make it stale, and one that arrives first waits for the read.
289
- readThrough: base ? base.lastSequence : loading ? "reading" : null,
290
- refresh: refreshDetail
291
- });
292
- const updateTitle = useCallback(
293
- async (title) => {
294
- if (!sessionId) {
295
- return null;
296
- }
297
- const result = await run(() => client.updateSession(workspaceId, sessionId, { title }));
298
- if (result) {
299
- setOverride(result);
300
- }
301
- return result;
302
- },
303
- [client, workspaceId, sessionId, run]
304
- );
305
- return {
306
- session,
307
- loading: loading && retained === null,
308
- error,
309
- readRevision,
310
- readGeneration,
311
- refresh,
312
- updateTitle,
313
- updating: mutating,
314
- mutationError,
315
- clearMutationError
316
- };
317
- }
318
-
319
- // src/lib/session-startup-timeline.tsx
320
- import { useRef as useRef2 } from "react";
321
- function currentEvents(events) {
322
- return events.filter(
323
- (event) => !event.duplicateOfEventId && (!event.turnAssociation || event.turnAssociation === "current")
324
- ).sort((a, b) => a.sequence - b.sequence);
325
- }
326
- function payloadOf(event) {
327
- return event.payload && typeof event.payload === "object" ? event.payload : {};
328
- }
329
- function sessionStartupTimeline(items, input) {
330
- const { session, optimisticMessages, hasNewer } = input;
331
- if (hasNewer || session.effectiveControl.state !== "active" || !["idle", "queued", "running"].includes(session.status) || session.status === "idle" && session.inputWait)
332
- return items;
333
- const claimed = /* @__PURE__ */ new Set();
334
- const pending = /* @__PURE__ */ new Map();
335
- let queueVersion = session.queueVersion;
336
- let newerProgress = false;
337
- let observedActiveTurn = null;
338
- let previousTurnEndedAt = null;
339
- for (const event of currentEvents(input.events)) {
340
- const payload = payloadOf(event);
341
- if (event.turnId && ["turn.completed", "turn.failed", "turn.cancelled", "turn.superseded"].includes(event.type))
342
- previousTurnEndedAt = event.occurredAt;
343
- if (event.sequence > session.lastSequence && ([
344
- "turn.started",
345
- "turn.completed",
346
- "turn.failed",
347
- "turn.cancelled",
348
- "turn.superseded"
349
- ].includes(event.type) || event.type === "session.status.changed" && payload.status !== "queued" || event.type === "session.queue.changed" && ["edit", "delete"].includes(String(payload.operation))))
350
- newerProgress = true;
351
- if (event.type === "session.queue.changed" && typeof payload.queueVersion === "number")
352
- queueVersion = Math.max(queueVersion, payload.queueVersion);
353
- const turnId2 = event.turnId ?? (typeof payload.turnId === "string" ? payload.turnId : null);
354
- if (!turnId2) continue;
355
- if (event.sequence > session.lastSequence) {
356
- if (event.type === "turn.started") observedActiveTurn = turnId2;
357
- else if (observedActiveTurn === turnId2 && ["turn.completed", "turn.failed", "turn.cancelled", "turn.superseded"].includes(event.type))
358
- observedActiveTurn = null;
359
- }
360
- if ([
361
- "turn.started",
362
- "turn.completed",
363
- "turn.failed",
364
- "turn.cancelled",
365
- "turn.superseded"
366
- ].includes(event.type) || event.type === "session.queue.changed" && ["edit", "delete"].includes(String(payload.operation)))
367
- claimed.add(turnId2);
368
- if ((event.type === "turn.queued" || event.type === "user.message") && payload.routing === "accepted_for_execution" && (session.status !== "idle" || event.sequence > session.lastSequence))
369
- pending.set(turnId2, event.occurredAt);
370
- }
371
- for (const message of optimisticMessages ?? []) {
372
- if (message.state === "queued" && message.destination === "chat" && message.delivery === "send" && message.turnId && !pending.has(message.turnId) && (session.status !== "idle" || message.appliedQueueVersion != null && message.appliedQueueVersion > session.queueVersion))
373
- pending.set(message.turnId, message.occurredAt);
374
- }
375
- const head = input.queue && input.queue.version >= queueVersion ? input.queue.items[0] : null;
376
- if (session.status === "queued" && !session.activeTurnId && head && !pending.has(head.id))
377
- pending.set(
378
- head.id,
379
- previousTurnEndedAt && previousTurnEndedAt > head.createdAt ? previousTurnEndedAt : head.createdAt
380
- );
381
- const candidate = [...pending].find(
382
- ([turnId2]) => !claimed.has(turnId2) && (!session.activeTurnId || session.activeTurnId === turnId2) && (!observedActiveTurn || observedActiveTurn === turnId2) && !items.some((item) => "turnId" in item && item.turnId === turnId2)
383
- );
384
- const fallback = !candidate && !newerProgress && session.status === "queued" && !session.activeTurnId && input.fallbackStartedAt;
385
- if (!candidate && !fallback) return items;
386
- const [turnId, startedAt] = candidate ?? [
387
- `pending-startup:${session.id}`,
388
- input.fallbackStartedAt
389
- ];
390
- return [
391
- ...items,
392
- {
393
- kind: "startup-phase",
394
- id: `${turnId}-queue`,
395
- turnId,
396
- phase: "queue",
397
- status: "running",
398
- startedAt,
399
- occurredAt: startedAt,
400
- completedAt: null,
401
- durationMs: null,
402
- outcome: null,
403
- ...session.activeTurnId ? {} : { dispatchWait: session.status === "queued" ? session.dispatchWait ?? null : null }
404
- }
405
- ];
406
- }
407
- var PENDING_SCOPE = "pending-prompt";
408
- var PENDING_PROMPT_STARTUP_ID = "pending-prompt-startup";
409
- function pendingPromptItems(prompt) {
410
- return [
411
- {
412
- kind: "user-message",
413
- id: "pending-prompt-message",
414
- text: prompt.text,
415
- resources: prompt.resources ?? [],
416
- tools: [],
417
- occurredAt: prompt.sentAt
418
- },
419
- {
420
- kind: "startup-phase",
421
- id: PENDING_PROMPT_STARTUP_ID,
422
- turnId: PENDING_SCOPE,
423
- phase: "queue",
424
- status: "running",
425
- startedAt: prompt.sentAt,
426
- occurredAt: prompt.sentAt,
427
- completedAt: null,
428
- durationMs: null,
429
- outcome: null
430
- }
431
- ];
432
- }
433
- function useSessionStartupTimeline(items, input) {
434
- const startup = useSessionStartupState(input.session);
435
- const bridgeRef = useRef2(null);
436
- const { pendingPrompt } = input;
437
- if (pendingPrompt && (!input.session || input.historyReady === false)) {
438
- bridgeRef.current = {
439
- scope: PENDING_SCOPE,
440
- id: PENDING_PROMPT_STARTUP_ID,
441
- turnId: null,
442
- since: pendingPrompt.sentAt,
443
- sequence: 0
444
- };
445
- return [...items, ...pendingPromptItems(pendingPrompt)];
446
- }
447
- if (!input.session) {
448
- bridgeRef.current = null;
449
- return items;
450
- }
451
- const scope = `${input.session.workspaceId}:${input.session.id}`;
452
- if (bridgeRef.current?.scope === PENDING_SCOPE)
453
- bridgeRef.current = { ...bridgeRef.current, scope };
454
- if (bridgeRef.current?.scope !== scope || input.hasNewer || input.session.effectiveControl.state !== "active" || !["queued", "running", "idle"].includes(input.session.status))
455
- bridgeRef.current = null;
456
- const boundTurn = bridgeRef.current?.turnId;
457
- const settled = boundTurn && currentEvents(input.events).find(
458
- (event) => event.turnId === boundTurn && ["turn.completed", "turn.failed", "turn.cancelled", "turn.superseded"].includes(event.type)
459
- );
460
- let fallbackStartedAt = bridgeRef.current?.turnId === null ? bridgeRef.current.since : startup?.startedAt;
461
- if (settled) {
462
- bridgeRef.current = null;
463
- fallbackStartedAt = input.session.status === "queued" && input.session.lastSequence >= settled.sequence ? input.session.updatedAt : void 0;
464
- }
465
- const projected = sessionStartupTimeline(items, {
466
- ...input,
467
- session: input.session,
468
- fallbackStartedAt
469
- });
470
- if (projected !== items) {
471
- const phase2 = projected.at(-1);
472
- if (phase2.kind !== "startup-phase") return projected;
473
- const turnId2 = phase2.turnId === `pending-startup:${input.session.id}` ? null : phase2.turnId;
474
- let bridge2 = bridgeRef.current;
475
- if (!bridge2 || bridge2.turnId && turnId2 && bridge2.turnId !== turnId2) {
476
- bridge2 = {
477
- scope,
478
- id: phase2.id,
479
- turnId: turnId2,
480
- since: phase2.startedAt,
481
- sequence: input.session.lastSequence
482
- };
483
- } else
484
- bridge2 = {
485
- ...bridge2,
486
- turnId: turnId2 ?? bridge2.turnId,
487
- since: bridge2.since < phase2.startedAt ? bridge2.since : phase2.startedAt
488
- };
489
- bridgeRef.current = bridge2;
490
- return [
491
- ...projected.slice(0, -1),
492
- { ...phase2, id: bridge2.id, startedAt: bridge2.since, occurredAt: bridge2.since }
493
- ];
494
- }
495
- const bridge = bridgeRef.current;
496
- if (!bridge) return items;
497
- if (input.session.status === "idle") {
498
- bridgeRef.current = null;
499
- return items;
500
- }
501
- const started = currentEvents(input.events).find(
502
- (event) => event.type === "turn.started" && (bridge.turnId ? event.turnId === bridge.turnId : event.sequence > bridge.sequence)
503
- );
504
- const turnId = bridge.turnId ?? started?.turnId ?? input.session.activeTurnId;
505
- const phase = items.find((item) => item.kind === "startup-phase" && item.turnId === turnId);
506
- if (phase?.kind === "startup-phase") {
507
- bridgeRef.current = { ...bridge, turnId };
508
- return items.map(
509
- (item) => item === phase ? {
510
- ...phase,
511
- id: bridge.id,
512
- loadingStartedAt: bridge.since < phase.startedAt ? bridge.since : phase.startedAt
513
- } : item
514
- );
515
- }
516
- if (turnId && (started || input.session.activeTurnId === turnId)) {
517
- bridgeRef.current = { ...bridge, turnId };
518
- return [
519
- ...items,
520
- {
521
- kind: "startup-phase",
522
- id: bridge.id,
523
- turnId,
524
- phase: "queue",
525
- status: "complete",
526
- startedAt: bridge.since,
527
- occurredAt: bridge.since,
528
- completedAt: started?.occurredAt ?? input.session.updatedAt,
529
- durationMs: null,
530
- outcome: null
531
- }
532
- ];
533
- }
534
- if (turnId) bridgeRef.current = null;
535
- return items;
536
- }
537
-
538
- // src/hooks/use-available-models.ts
539
- import { useCallback as useCallback2 } from "react";
540
- function useAvailableModels(options = {}) {
541
- const client = useOpenGeniClient(options);
542
- const load = useCallback2(
543
- async (signal) => await client.getClientConfig({ signal }),
544
- [client]
545
- );
546
- const state = useSharedQuery(client, ["available-models"], load, {
547
- pollIntervalMs: options.pollIntervalMs,
548
- enabled: options.enabled
549
- });
550
- return {
551
- models: state.data?.models ?? [],
552
- defaultModel: state.data?.defaultModel ?? null,
553
- loading: state.loading,
554
- error: state.error,
555
- refresh: state.refresh
556
- };
557
- }
558
- function useWorkspaceModelCatalog(options) {
559
- const t = useOpenGeniText();
560
- const client = useOpenGeniClient(options);
561
- const load = useCallback2(
562
- async (signal) => {
563
- if (!options.workspaceId) {
564
- return { models: [], defaultModel: null };
565
- }
566
- const [catalog, config] = await Promise.all([
567
- client.getWorkspaceModelCatalog(options.workspaceId, { signal }),
568
- // Joins the same workspace's config read already in flight (for
569
- // example the composer's voice availability).
570
- joinClientConfigRead(client, options.workspaceId)
571
- ]);
572
- return {
573
- models: catalog.models,
574
- defaultModel: config.defaultModel
575
- };
576
- },
577
- [client, options.workspaceId]
578
- );
579
- const state = useSharedQuery(client, ["workspace-model-catalog", options.workspaceId], load, {
580
- pollIntervalMs: options.pollIntervalMs,
581
- enabled: options.enabled !== false && Boolean(options.workspaceId)
582
- });
583
- const rows = sortPickerRows(projectPickerRows(t, state.data?.models ?? []));
584
- return {
585
- models: state.data?.models ?? [],
586
- rows,
587
- defaultModel: state.data?.defaultModel ?? null,
588
- loading: state.loading,
589
- error: state.error,
590
- refresh: state.refresh
591
- };
592
- }
593
-
594
- // src/hooks/use-human-input.ts
595
- import { useCallback as useCallback3, useEffect as useEffect2, useRef as useRef3, useState as useState2 } from "react";
596
- function isHumanInputEvent(event) {
597
- return event.type === "session.humanInput.requested" || event.type === "user.humanInputResponse" || event.type === "turn.completed" || event.type === "turn.failed" || event.type === "turn.cancelled";
598
- }
599
- function useHumanInputRequests(sessionId, options = {}) {
600
- const { client, workspaceId, registerSessionReconciler } = useEmbeddedHumanInputSession(options);
601
- const enabled = (options.enabled ?? true) && Boolean(sessionId);
602
- const load = useCallback3(async () => {
603
- if (!sessionId) return [];
604
- const readStartedAt = Date.now();
605
- const requests = await client.listHumanInputRequests(workspaceId, sessionId, {
606
- status: "pending"
607
- });
608
- const now2 = Date.now();
609
- pruneHumanInputDrafts(
610
- workspaceId,
611
- sessionId,
612
- requests.filter((request) => isActionableHumanInputRequest(request, now2)).map((request) => request.id),
613
- readStartedAt
614
- );
615
- return requests;
616
- }, [client, sessionId, workspaceId]);
617
- const state = usePolledValue(load, {
618
- enabled,
619
- pollIntervalMs: options.pollIntervalMs
620
- });
621
- const loadedRequests = state.data;
622
- const refreshRequests = state.refresh;
623
- const readDenied = enabled && Boolean(sessionId) && deniesRetainedView(state.error);
624
- useEffect2(() => {
625
- if (readDenied && sessionId) forgetSessionHumanInputDrafts(workspaceId, sessionId);
626
- }, [readDenied, sessionId, workspaceId]);
627
- const mutation = useMutationRunner(`${workspaceId}\0${sessionId ?? ""}`);
628
- const [respondingRequestId, setRespondingRequestId] = useState2(null);
629
- const [deadlineVersion, setDeadlineVersion] = useState2(0);
630
- const respondingRequestRef = useRef3(null);
631
- useEffect2(() => {
632
- respondingRequestRef.current = null;
633
- setRespondingRequestId(null);
634
- }, [sessionId, workspaceId]);
635
- useEffect2(() => {
636
- if (!sessionId || !enabled) return;
637
- return registerSessionReconciler(sessionId, "human-input", state.refresh);
638
- }, [enabled, registerSessionReconciler, sessionId, state.refresh]);
639
- const scheduleRefresh = useDebouncedCallback(() => void state.refresh());
640
- useSessionEventTrigger(client, workspaceId, sessionId, isHumanInputEvent, scheduleRefresh, {
641
- enabled,
642
- ...options.events !== void 0 ? { events: options.events } : {},
643
- readThrough: projectionReadThrough(state.data, state.loading),
644
- refresh: scheduleRefresh
645
- });
646
- const retainedRequests = useRetainedSessionView(
647
- client,
648
- workspaceId,
649
- sessionId,
650
- "human-input",
651
- state.data,
652
- { enabled, discard: deniesRetainedView(state.error) }
653
- );
654
- useEffect2(() => {
655
- const now2 = Date.now();
656
- const nextDeadline = (loadedRequests ?? []).reduce((next, request) => {
657
- if (request.status !== "pending" || !request.expiresAt) return next;
658
- const deadline = Date.parse(request.expiresAt);
659
- if (!Number.isFinite(deadline) || deadline <= now2) return next;
660
- return next === null ? deadline : Math.min(next, deadline);
661
- }, null);
662
- if (nextDeadline === null) return;
663
- const timer = globalThis.setTimeout(
664
- () => {
665
- setDeadlineVersion((current) => current + 1);
666
- void refreshRequests();
667
- },
668
- Math.min(2147483647, Math.max(0, nextDeadline - now2 + 1))
669
- );
670
- return () => globalThis.clearTimeout(timer);
671
- }, [loadedRequests, refreshRequests]);
672
- const respond = useCallback3(
673
- async (requestId, response) => {
674
- if (!sessionId || respondingRequestRef.current !== null) return null;
675
- respondingRequestRef.current = requestId;
676
- setRespondingRequestId(requestId);
677
- try {
678
- const event = await mutation.run(
679
- () => client.submitHumanInputResponse(workspaceId, sessionId, requestId, response, {
680
- clientEventId: globalThis.crypto.randomUUID()
681
- })
682
- );
683
- if (event) await state.refresh();
684
- return event;
685
- } finally {
686
- if (respondingRequestRef.current === requestId) {
687
- respondingRequestRef.current = null;
688
- setRespondingRequestId(null);
689
- }
690
- }
691
- },
692
- [client, mutation, sessionId, state, workspaceId]
693
- );
694
- const now = Date.now();
695
- void deadlineVersion;
696
- return {
697
- requests: [...state.data ?? retainedRequests ?? []].filter((request) => isActionableHumanInputRequest(request, now)).sort(
698
- (left, right) => left.createdAt.localeCompare(right.createdAt) || left.id.localeCompare(right.id)
699
- ),
700
- loading: state.loading && retainedRequests === null,
701
- error: state.error,
702
- refresh: state.refresh,
703
- respond,
704
- respondingRequestId,
705
- mutationError: mutation.mutationError,
706
- clearMutationError: mutation.clearMutationError
707
- };
708
- }
709
-
710
- // src/hooks/use-session-control.ts
711
- import { useCallback as useCallback4, useLayoutEffect, useRef as useRef4 } from "react";
712
- function useSessionControl(sessionId, options = {}) {
713
- const { client, workspaceId } = useEmbeddedSession(options);
714
- const approvalTargetKey = `${workspaceId}\0${sessionId ?? ""}`;
715
- const pendingApproval = useRef4(null);
716
- useLayoutEffect(() => {
717
- if (pendingApproval.current?.targetKey !== approvalTargetKey) {
718
- pendingApproval.current = null;
719
- }
720
- }, [approvalTargetKey]);
721
- const {
722
- run: runControl,
723
- mutating: controlling,
724
- mutationError: controlError,
725
- clearMutationError: clearControlError
726
- } = useMutationRunner(approvalTargetKey);
727
- const {
728
- run: runApproval,
729
- mutating: responding,
730
- mutationError: approvalError,
731
- clearMutationError: clearApprovalError
732
- } = useMutationRunner(approvalTargetKey);
733
- const pause = useCallback4(
734
- async (reason) => {
735
- if (!sessionId) {
736
- return null;
737
- }
738
- return await runControl(
739
- () => client.pauseSession(workspaceId, sessionId, reason !== void 0 ? { reason } : {})
740
- );
741
- },
742
- [client, workspaceId, sessionId, runControl]
743
- );
744
- const resume = useCallback4(
745
- async (reason) => {
746
- if (!sessionId) return null;
747
- return await runControl(
748
- () => client.resumeSession(workspaceId, sessionId, reason !== void 0 ? { reason } : {})
749
- );
750
- },
751
- [client, workspaceId, sessionId, runControl]
752
- );
753
- const decide = useCallback4(
754
- async (approvalId, decision, message, answer, decisionOptions = {}) => {
755
- if (!sessionId) {
756
- return null;
757
- }
758
- const decisionKey = JSON.stringify([approvalId, decision, message ?? null, answer ?? null]);
759
- if (pendingApproval.current?.decisionKey !== decisionKey) {
760
- pendingApproval.current = {
761
- targetKey: approvalTargetKey,
762
- decisionKey,
763
- clientEventId: crypto.randomUUID()
764
- };
765
- }
766
- const clientEventId = pendingApproval.current.clientEventId;
767
- let refusal = null;
768
- const accepted = await runApproval(async () => {
769
- try {
770
- return await client.sendApprovalDecision(workspaceId, sessionId, {
771
- approvalId,
772
- decision,
773
- ...message !== void 0 ? { message } : {},
774
- ...answer !== void 0 ? answer : {},
775
- clientEventId
776
- });
777
- } catch (cause) {
778
- refusal = { cause };
779
- throw cause;
780
- }
781
- });
782
- if (decisionOptions.throwOnError && refusal) throw refusal.cause;
783
- if (accepted !== null && pendingApproval.current?.targetKey === approvalTargetKey && pendingApproval.current.clientEventId === clientEventId) {
784
- pendingApproval.current = null;
785
- }
786
- return accepted;
787
- },
788
- [approvalTargetKey, client, workspaceId, sessionId, runApproval]
789
- );
790
- const approve = useCallback4(
791
- async (approvalId, message, answer, decisionOptions) => await decide(approvalId, "approve", message, answer, decisionOptions),
792
- [decide]
793
- );
794
- const reject = useCallback4(
795
- async (approvalId, message, decisionOptions) => await decide(approvalId, "reject", message, void 0, decisionOptions),
796
- [decide]
797
- );
798
- const error = approvalError ?? controlError;
799
- const clearError = useCallback4(() => {
800
- clearControlError();
801
- clearApprovalError();
802
- }, [clearControlError, clearApprovalError]);
803
- return {
804
- pause,
805
- resume,
806
- controlling,
807
- approve,
808
- reject,
809
- responding,
810
- error,
811
- clearError
812
- };
813
- }
814
-
815
- // src/older-history.ts
816
- var activeReceiptCapture;
817
- var preserveTailForAutomaticLoad = false;
818
- function invokeOlderHistoryLoaderWithReceiptCapture(load, capture, preserveTail = false) {
819
- const previousCapture = activeReceiptCapture;
820
- const previousPreserveTail = preserveTailForAutomaticLoad;
821
- activeReceiptCapture = capture;
822
- preserveTailForAutomaticLoad = preserveTail;
823
- try {
824
- return load();
825
- } finally {
826
- activeReceiptCapture = previousCapture;
827
- preserveTailForAutomaticLoad = previousPreserveTail;
828
- }
829
- }
830
- function createOlderHistoryLoadReceipt(load) {
831
- let resolveResult;
832
- let rejectResult;
833
- const result = new Promise((resolve, reject) => {
834
- resolveResult = resolve;
835
- rejectResult = reject;
836
- });
837
- result.committed = false;
838
- result.tailPreserved = false;
839
- activeReceiptCapture?.(result);
840
- try {
841
- const loaded = load(
842
- () => {
843
- result.committed = true;
844
- },
845
- preserveTailForAutomaticLoad,
846
- () => {
847
- result.tailPreserved = true;
848
- }
849
- );
850
- Promise.resolve(loaded).then(resolveResult, rejectResult);
851
- } catch (error) {
852
- rejectResult(error);
853
- }
854
- return result;
855
- }
856
-
857
- // src/hooks/use-session-events.ts
858
- import {
859
- isPresentedSessionToolCall,
860
- isRetryableStreamError,
861
- isSessionModelResponsePhase,
862
- isTransientRequestError,
863
- SESSION_EVENT_COMPAT_EXCLUDED_STEP_TYPES,
864
- SESSION_EVENT_CONTENT_STEP_TYPES,
865
- SESSION_EVENT_CONVERSATION_FILTER_VERSION,
866
- SESSION_EVENT_STEP_TYPES,
867
- sessionEventStreamCoveredThrough
868
- } from "@opengeni/sdk";
869
- import { startTransition, useCallback as useCallback6, useEffect as useEffect3, useMemo as useMemo2, useRef as useRef5, useState as useState3 } from "react";
870
-
871
- // src/hooks/page-wake.ts
872
- var PAGE_WAKE_CHECK_INTERVAL_MS = 2e3;
873
- var PAGE_WAKE_GAP_MS = 15e3;
874
- var listeners = /* @__PURE__ */ new Set();
875
- var stopDetector = null;
876
- function subscribePageWake(listener) {
877
- listeners.add(listener);
878
- stopDetector ??= startDetector();
879
- return () => {
880
- listeners.delete(listener);
881
- if (listeners.size === 0 && stopDetector) {
882
- stopDetector();
883
- stopDetector = null;
884
- }
885
- };
886
- }
887
- function emitPageWake() {
888
- for (const listener of [...listeners]) {
889
- try {
890
- listener();
891
- } catch {
892
- }
893
- }
894
- }
895
- function startDetector() {
896
- if (typeof window === "undefined" || typeof document === "undefined") return () => {
897
- };
898
- let lastTick = Date.now();
899
- const check = () => {
900
- const now = Date.now();
901
- const elapsed = now - lastTick;
902
- lastTick = now;
903
- if (elapsed > PAGE_WAKE_GAP_MS) emitPageWake();
904
- };
905
- const onVisibility = () => {
906
- if (document.visibilityState !== "hidden") check();
907
- };
908
- const onPageShow = (event) => {
909
- lastTick = Date.now();
910
- if (event?.persisted === true) emitPageWake();
911
- };
912
- const onResume = () => {
913
- lastTick = Date.now();
914
- emitPageWake();
915
- };
916
- const timer = setInterval(check, PAGE_WAKE_CHECK_INTERVAL_MS);
917
- document.addEventListener("visibilitychange", onVisibility);
918
- document.addEventListener("resume", onResume);
919
- window.addEventListener("pageshow", onPageShow);
920
- window.addEventListener("online", onResume);
921
- return () => {
922
- clearInterval(timer);
923
- document.removeEventListener("visibilitychange", onVisibility);
924
- document.removeEventListener("resume", onResume);
925
- window.removeEventListener("pageshow", onPageShow);
926
- window.removeEventListener("online", onResume);
927
- };
928
- }
929
-
930
- // src/hooks/turnless-output-gaps.ts
931
- import { useCallback as useCallback5, useSyncExternalStore } from "react";
932
- var MAX_IDLE_ENTRIES = 256;
933
- var entries = /* @__PURE__ */ new Map();
934
- function gapKey(workspaceId, sessionId) {
935
- return `${workspaceId}\0${sessionId}`;
936
- }
937
- function gapEntry(key) {
938
- let entry = entries.get(key);
939
- if (!entry) {
940
- entry = { generation: 0, listeners: /* @__PURE__ */ new Set() };
941
- entries.set(key, entry);
942
- if (entries.size > MAX_IDLE_ENTRIES) {
943
- for (const [candidate, held] of entries) {
944
- if (entries.size <= MAX_IDLE_ENTRIES) break;
945
- if (candidate !== key && held.listeners.size === 0) entries.delete(candidate);
946
- }
947
- }
948
- }
949
- return entry;
950
- }
951
- function markTurnlessOutputGap(workspaceId, sessionId) {
952
- const entry = gapEntry(gapKey(workspaceId, sessionId));
953
- entry.generation += 1;
954
- for (const listener of [...entry.listeners]) listener();
955
- }
956
- function useTurnlessOutputGap(workspaceId, sessionId) {
957
- const key = sessionId ? gapKey(workspaceId, sessionId) : null;
958
- const subscribe = useCallback5(
959
- (listener) => {
960
- if (!key) return () => {
961
- };
962
- const entry = gapEntry(key);
963
- entry.listeners.add(listener);
964
- return () => {
965
- entry.listeners.delete(listener);
966
- };
967
- },
968
- [key]
969
- );
970
- const read = useCallback5(() => key ? entries.get(key)?.generation ?? 0 : 0, [key]);
971
- return useSyncExternalStore(subscribe, read, read);
972
- }
973
-
974
- // src/hooks/use-session-events.ts
975
- import { errorMessage } from "@opengeni/contracts/values";
976
- var SESSION_FIRST_WINDOW_PAGE_SIZE = 255;
977
- var SESSION_HISTORY_PAGE_SIZE = 1e3;
978
- var INITIAL_FETCH_CAP = 1;
979
- var OLDER_GROUP_TARGET = 32;
980
- var OLDER_FETCH_CAP = 2;
981
- var NEWER_GROUP_TARGET = 32;
982
- var NEWER_FETCH_CAP = 2;
983
- var OLDEST_GROUP_TARGET = 32;
984
- var OLDEST_FETCH_CAP = 2;
985
- var BOUNDARY_PAGE_CAP = 1;
986
- var FILTERED_PAGE_CAP = 32;
987
- var DIRECT_REPLAY_MAX_SEQUENCES = 16;
988
- var CATCHUP_MAX_PAGES = 2;
989
- var STRICT_REJOIN_ATTEMPTS = 5;
990
- var REJOIN_STALL_TIMEOUT_MS = 3e4;
991
- var FOREGROUND_REJOIN_RETRY_MS = 500;
992
- var FOREGROUND_REJOIN_RETRY_MAX_MS = 8e3;
993
- var EMPTY_EVENTS = [];
994
- var encoder = new TextEncoder();
995
- var SESSION_EVENT_BROWSER_MAX_BYTES = 16 * 1024 * 1024;
996
- var SESSION_EVENT_BROWSER_MAX_COUNT = 2e4;
997
- var SESSION_EVENT_BROWSER_PENDING_MAX_BYTES = 1024 * 1024;
998
- var SESSION_EVENT_BROWSER_PENDING_MAX_COUNT = 256;
999
- var EMPTY_EVENT_WINDOW = {
1000
- events: EMPTY_EVENTS,
1001
- bytes: 2,
1002
- truncated: false
1003
- };
1004
- function useSessionEvents(sessionId, options = {}) {
1005
- const t = useOpenGeniText();
1006
- const { client, workspaceId, reconcileSession } = useEmbeddedSession(options);
1007
- const enabled = options.enabled ?? true;
1008
- const pageLive = usePageLiveActivity();
1009
- const streamEnabled = enabled && pageLive;
1010
- const after = options.after ?? 0;
1011
- const replay = options.replay ?? "windowed";
1012
- const fullReplay = replay === "full" || after !== 0;
1013
- const streamKey = `${workspaceId}\0${sessionId ?? ""}\0${after}\0${fullReplay ? "full" : "windowed"}`;
1014
- const navigationIdentityRef = useRef5({ client, streamKey, enabled });
1015
- if (navigationIdentityRef.current.client !== client || navigationIdentityRef.current.streamKey !== streamKey || navigationIdentityRef.current.enabled !== enabled) {
1016
- navigationIdentityRef.current = { client, streamKey, enabled };
1017
- }
1018
- const navigationIdentity = navigationIdentityRef.current;
1019
- const ownsNavigation = useCallback6(
1020
- () => navigationIdentityRef.current === navigationIdentity,
1021
- [navigationIdentity]
1022
- );
1023
- const [eventWindow, setEventWindow] = useState3(EMPTY_EVENT_WINDOW);
1024
- const [questionEvidence, setQuestionEvidence] = useState3(null);
1025
- const [connectionState, setConnectionState] = useState3("idle");
1026
- const [error, setError] = useState3(null);
1027
- const [newerError, setNewerError] = useState3(null);
1028
- const [hasOlder, setHasOlder] = useState3(false);
1029
- const [hasNewer, setHasNewer] = useState3(false);
1030
- const [sessionStatusProjection, setSessionStatusProjection] = useState3(
1031
- null
1032
- );
1033
- const [initialLoading, setInitialLoading] = useState3(true);
1034
- const [initialHistoryReady, setInitialHistoryReady] = useState3(false);
1035
- const [loadingOlder, setLoadingOlder] = useState3(false);
1036
- const [loadingNewer, setLoadingNewer] = useState3(false);
1037
- const [loadingOldest, setLoadingOldest] = useState3(false);
1038
- const [loadingLatest, setLoadingLatest] = useState3(false);
1039
- const [loadingTarget, setLoadingTarget] = useState3(false);
1040
- const loadingTargetRef = useRef5(false);
1041
- const [streamEpoch, setStreamEpoch] = useState3(0);
1042
- const [viewMode, setViewMode] = useState3("live");
1043
- const lastSequenceRef = useRef5(after);
1044
- const streamResumeSequenceRef = useRef5(after);
1045
- const skippedStepsThroughRef = useRef5(null);
1046
- const oldestSequenceRef = useRef5(null);
1047
- const newestSequenceRef = useRef5(null);
1048
- const hasOlderRef = useRef5(false);
1049
- const hasNewerRef = useRef5(false);
1050
- const loadingOlderRef = useRef5(false);
1051
- const loadingNewerRef = useRef5(false);
1052
- const loadingOldestRef = useRef5(false);
1053
- const loadingLatestRef = useRef5(false);
1054
- const viewModeRef = useRef5("live");
1055
- const initialWindowLoadedRef = useRef5(false);
1056
- const openedStreamKeyRef = useRef5(null);
1057
- const reconcileAfterPageResumeRef = useRef5(false);
1058
- const streamAbortRef = useRef5(null);
1059
- const streamKeyRef = useRef5(null);
1060
- const generationRef = useRef5(0);
1061
- const navigationGenerationRef = useRef5(0);
1062
- const eventWindowRef = useRef5(EMPTY_EVENT_WINDOW);
1063
- const sessionStatusRef = useRef5({
1064
- sequence: after,
1065
- status: null
1066
- });
1067
- const [stateStreamKey, setStateStreamKey] = useState3(streamKey);
1068
- const historyFilter = fullReplay ? void 0 : CONVERSATION_FILTER;
1069
- const [stepStores, setStepStores] = useState3(EMPTY_STEP_STORES);
1070
- const stepStoresRef = useRef5(EMPTY_STEP_STORES);
1071
- const [turnlessSteps, setTurnlessSteps] = useState3(EMPTY_TURNLESS_STEPS);
1072
- const turnlessStepsRef = useRef5(EMPTY_TURNLESS_STEPS);
1073
- const renderedTurnlessRef = useRef5({ appended: 0, marked: false });
1074
- useEffect3(() => {
1075
- renderedTurnlessRef.current = { appended: turnlessSteps.appended, marked: false };
1076
- }, [turnlessSteps]);
1077
- const liveThroughRef = useRef5(0);
1078
- const stepGenerationRef = useRef5(0);
1079
- const stepRequestRef = useRef5(0);
1080
- const retainedTurnsRef = useRef5(/* @__PURE__ */ new Map());
1081
- const turnStepHandlesRef = useRef5(/* @__PURE__ */ new Map());
1082
- const presentedCallIdsRef = useRef5(/* @__PURE__ */ new Set());
1083
- const presentedScanRef = useRef5(null);
1084
- const startupRef = useRef5(emptyStartupTurns());
1085
- const [presentedOutputs, setPresentedOutputs] = useState3(EMPTY_PRESENTED_OUTPUTS);
1086
- const presentedRequestedRef = useRef5(/* @__PURE__ */ new Map());
1087
- const presentedFailuresRef = useRef5(/* @__PURE__ */ new Map());
1088
- const [presentedPass, setPresentedPass] = useState3(0);
1089
- const rejoinPendingRef = useRef5(false);
1090
- const streamTransientStreakRef = useRef5(null);
1091
- const commitStepStores = useCallback6((next) => {
1092
- stepStoresRef.current = next;
1093
- setStepStores(next);
1094
- }, []);
1095
- const pruneStepStores = useCallback6(
1096
- (window2, sealedBy, rereading = null) => {
1097
- const present = windowTurns(window2);
1098
- const settled = sealedBy ? settledTurns(sealedBy) : null;
1099
- const next = /* @__PURE__ */ new Map();
1100
- for (const [turnId, store] of stepStoresRef.current) {
1101
- if (present.has(turnId) && (!settled || settled.has(turnId) || turnId === rereading)) {
1102
- next.set(turnId, store);
1103
- }
1104
- }
1105
- if (next.size !== stepStoresRef.current.size) commitStepStores(next);
1106
- if (sealedBy) {
1107
- presentedRequestedRef.current = /* @__PURE__ */ new Map();
1108
- } else {
1109
- for (const [callId, request] of presentedRequestedRef.current) {
1110
- if (request.turnId && !present.has(request.turnId)) {
1111
- presentedRequestedRef.current.delete(callId);
1112
- }
1113
- }
1114
- }
1115
- setPresentedOutputs((current) => {
1116
- let kept = null;
1117
- for (const [callId, output] of current) {
1118
- if (output.turnId && present.has(output.turnId)) continue;
1119
- kept ??= new Map(current);
1120
- kept.delete(callId);
1121
- }
1122
- return kept ?? current;
1123
- });
1124
- },
1125
- [commitStepStores]
1126
- );
1127
- const presentedCallIds = useCallback6((event) => {
1128
- const ids = presentedCallIdsRef.current;
1129
- if (event.type === "agent.toolCall.created") {
1130
- notePresentedCalls([event], ids);
1131
- } else if (event.type === "agent.toolCall.output") {
1132
- const payload = event.payload;
1133
- const windowEvents = eventWindowRef.current.events;
1134
- if (typeof payload?.id === "string" && !ids.has(payload.id) && presentedScanRef.current !== windowEvents) {
1135
- presentedScanRef.current = windowEvents;
1136
- notePresentedCalls(windowEvents, ids);
1137
- }
1138
- }
1139
- return ids;
1140
- }, []);
1141
- const startupTurns = useCallback6(() => {
1142
- const windowEvents = eventWindowRef.current.events;
1143
- if (startupRef.current.window !== windowEvents) {
1144
- const state = emptyStartupTurns();
1145
- noteStartupTurns(windowEvents, state);
1146
- state.window = windowEvents;
1147
- startupRef.current = state;
1148
- }
1149
- return startupRef.current;
1150
- }, []);
1151
- const appendLiveSteps = useCallback6(
1152
- (steps) => {
1153
- if (steps.some((event) => !event.turnId)) {
1154
- const incoming = steps.filter((event) => !event.turnId);
1155
- const turnless = appendTurnlessSteps(turnlessStepsRef.current, incoming);
1156
- const rendered = renderedTurnlessRef.current;
1157
- if (!rendered.marked && turnless.appended - rendered.appended > turnless.events.length) {
1158
- rendered.marked = true;
1159
- if (sessionId) markTurnlessOutputGap(workspaceId, sessionId);
1160
- }
1161
- turnlessStepsRef.current = turnless;
1162
- setTurnlessSteps(turnless);
1163
- }
1164
- const windowEvents = withTurnlessSteps(
1165
- eventWindowRef.current.events,
1166
- turnlessStepsRef.current
1167
- );
1168
- const next = new Map(stepStoresRef.current);
1169
- const now = Date.now();
1170
- for (const [turnId, events] of groupByTurn(steps)) {
1171
- const existing = next.get(turnId);
1172
- const store = existing ?? {
1173
- events: [],
1174
- bytes: 2,
1175
- // Earlier steps exist when the window skips sequences between the
1176
- // turn's start and this first live step.
1177
- hasOlder: turnHasHiddenSequences(windowEvents, turnId, events[0].sequence),
1178
- cursor: null,
1179
- floor: null,
1180
- pinned: null,
1181
- loading: false,
1182
- error: false,
1183
- touched: now,
1184
- requestId: 0
1185
- };
1186
- let updated = { ...store, ...appendStepEvents(store, events), touched: now };
1187
- if (!retainedTurnsRef.current.get(turnId)) updated = trimLiveStepTail(updated);
1188
- next.set(turnId, updated);
1189
- }
1190
- commitStepStores(boundStepStores(next, retainedTurnsRef.current));
1191
- },
1192
- [commitStepStores, workspaceId, sessionId]
1193
- );
1194
- const loadTurnSteps = useCallback6(
1195
- (turnId, before) => {
1196
- if (!ownsNavigation() || !sessionId || fullReplay) return;
1197
- const current = stepStoresRef.current.get(turnId);
1198
- const pinnedUpper = before ?? (current?.error && current.pinned !== null ? current.pinned : void 0);
1199
- const pinned = pinnedUpper !== void 0;
1200
- if (!pinned && current?.loading) return;
1201
- const bounds = conversationTurnBounds(eventWindowRef.current.events).get(turnId);
1202
- if (!bounds) return;
1203
- if (!pinned && current && !stepStoreHasOlder(current, bounds) && !current.error) return;
1204
- const upper = pinnedUpper ?? current?.cursor ?? current?.events[0]?.sequence ?? (bounds.terminal !== null ? bounds.terminal + 1 : Number.MAX_SAFE_INTEGER);
1205
- const exactStart = bounds.started !== null;
1206
- const lower = turnStepLowerBound(bounds);
1207
- const generation = stepGenerationRef.current;
1208
- const requestId = ++stepRequestRef.current;
1209
- const isCurrent = () => ownsNavigation() && generation === stepGenerationRef.current && stepStoresRef.current.get(turnId)?.requestId === requestId;
1210
- const base = current ?? {
1211
- events: [],
1212
- bytes: 2,
1213
- hasOlder: true,
1214
- cursor: null,
1215
- floor: null,
1216
- pinned: null,
1217
- loading: false,
1218
- error: false,
1219
- touched: 0,
1220
- requestId
1221
- };
1222
- commitStepStores(
1223
- new Map(stepStoresRef.current).set(turnId, {
1224
- ...base,
1225
- pinned: pinned ? upper : null,
1226
- loading: true,
1227
- error: false,
1228
- touched: Date.now(),
1229
- requestId
1230
- })
1231
- );
1232
- void readEventPage(client, workspaceId, sessionId, {
1233
- // Bookkeeping too, whichever read built this window: rows it already
1234
- // holds (a fallback read keeps them) merge once by id.
1235
- includeTypes: [...TURN_STEP_READ_TYPES],
1236
- after: Math.max(0, lower),
1237
- before: upper,
1238
- direction: "before",
1239
- limit: SESSION_TURN_STEP_PAGE_SIZE,
1240
- compact: true,
1241
- payloadMode: "full",
1242
- // Large tool outputs arrive as bounded previews; a row reads its
1243
- // exact output when the reader needs it (see useToolOutputReads).
1244
- toolOutputs: "preview"
1245
- }).then(
1246
- (page) => {
1247
- if (!isCurrent()) return;
1248
- const own = page.events.filter((event) => event.turnId === turnId);
1249
- const latest = stepStoresRef.current.get(turnId);
1250
- const merged = pinned ? appendStepEvents(
1251
- { events: [], bytes: 2 },
1252
- [...own, ...latest.events.filter((event) => event.sequence >= upper)].sort(
1253
- (left, right) => left.sequence - right.sequence
1254
- )
1255
- ) : appendStepEvents(latest, own);
1256
- const oldestOwn = merged.events[0]?.sequence ?? upper;
1257
- const passedStart = !exactStart && page.events.some(
1258
- (event) => !!event.turnId && event.turnId !== turnId && event.sequence < oldestOwn
1259
- );
1260
- const moreBelow = !passedStart && (page.hasMore ?? page.events.length > 0);
1261
- const reachedFloor = !moreBelow && !passedStart && !exactStart;
1262
- const next = new Map(stepStoresRef.current).set(turnId, {
1263
- ...merged,
1264
- // A page read without a continuation fact (a client without
1265
- // listEventPage) offers one more page until a read comes back empty.
1266
- hasOlder: moreBelow,
1267
- // The next page continues below this page's oldest row, even when
1268
- // the page held only other turns' rows, or below the floor.
1269
- cursor: reachedFloor ? lower + 1 : page.events.reduce((oldest, event) => Math.min(oldest, event.sequence), upper),
1270
- floor: reachedFloor ? lower : null,
1271
- pinned: null,
1272
- loading: false,
1273
- error: false,
1274
- touched: Date.now(),
1275
- requestId
1276
- });
1277
- commitStepStores(boundStepStores(next, retainedTurnsRef.current));
1278
- },
1279
- () => {
1280
- if (!isCurrent()) return;
1281
- const latest = stepStoresRef.current.get(turnId);
1282
- commitStepStores(
1283
- new Map(stepStoresRef.current).set(turnId, { ...latest, loading: false, error: true })
1284
- );
1285
- }
1286
- );
1287
- },
1288
- [client, workspaceId, sessionId, fullReplay, ownsNavigation, commitStepStores]
1289
- );
1290
- const loadTurnStepsRef = useRef5(loadTurnSteps);
1291
- useEffect3(() => {
1292
- loadTurnStepsRef.current = loadTurnSteps;
1293
- }, [loadTurnSteps]);
1294
- const turnStepHandle = useCallback6((turnId) => {
1295
- let handle = turnStepHandlesRef.current.get(turnId);
1296
- if (!handle) {
1297
- const retained = retainedTurnsRef.current;
1298
- handle = {
1299
- load: () => loadTurnStepsRef.current(turnId),
1300
- retain: () => {
1301
- retained.set(turnId, (retained.get(turnId) ?? 0) + 1);
1302
- let released = false;
1303
- return () => {
1304
- if (released) return;
1305
- released = true;
1306
- const count = (retained.get(turnId) ?? 1) - 1;
1307
- if (count > 0) retained.set(turnId, count);
1308
- else retained.delete(turnId);
1309
- };
1310
- }
1311
- };
1312
- turnStepHandlesRef.current.set(turnId, handle);
1313
- }
1314
- return handle;
1315
- }, []);
1316
- useEffect3(() => {
1317
- navigationGenerationRef.current += 1;
1318
- setNewerError(null);
1319
- loadingOlderRef.current = false;
1320
- loadingNewerRef.current = false;
1321
- loadingOldestRef.current = false;
1322
- loadingTargetRef.current = false;
1323
- setQuestionEvidence(null);
1324
- setLoadingTarget(false);
1325
- setLoadingOlder(false);
1326
- setLoadingNewer(false);
1327
- setLoadingOldest(false);
1328
- return () => {
1329
- navigationGenerationRef.current += 1;
1330
- };
1331
- }, [client, workspaceId, sessionId, after, enabled, fullReplay]);
1332
- useEffect3(() => {
1333
- if (streamKeyRef.current !== streamKey) {
1334
- streamKeyRef.current = streamKey;
1335
- setStateStreamKey(streamKey);
1336
- eventWindowRef.current = EMPTY_EVENT_WINDOW;
1337
- setEventWindow(EMPTY_EVENT_WINDOW);
1338
- setError(null);
1339
- setHasOlder(false);
1340
- setHasNewer(false);
1341
- sessionStatusRef.current = { sequence: after, status: null };
1342
- setSessionStatusProjection(null);
1343
- setLoadingOlder(false);
1344
- setLoadingNewer(false);
1345
- setLoadingOldest(false);
1346
- setLoadingLatest(false);
1347
- setInitialLoading(true);
1348
- setInitialHistoryReady(false);
1349
- lastSequenceRef.current = after;
1350
- streamResumeSequenceRef.current = after;
1351
- liveThroughRef.current = after;
1352
- skippedStepsThroughRef.current = null;
1353
- oldestSequenceRef.current = null;
1354
- newestSequenceRef.current = null;
1355
- hasOlderRef.current = false;
1356
- hasNewerRef.current = false;
1357
- loadingOlderRef.current = false;
1358
- loadingNewerRef.current = false;
1359
- loadingOldestRef.current = false;
1360
- loadingLatestRef.current = false;
1361
- viewModeRef.current = "live";
1362
- setViewMode("live");
1363
- initialWindowLoadedRef.current = false;
1364
- reconcileAfterPageResumeRef.current = false;
1365
- rejoinPendingRef.current = false;
1366
- streamTransientStreakRef.current = null;
1367
- stepGenerationRef.current += 1;
1368
- stepStoresRef.current = EMPTY_STEP_STORES;
1369
- setStepStores(EMPTY_STEP_STORES);
1370
- turnlessStepsRef.current = EMPTY_TURNLESS_STEPS;
1371
- setTurnlessSteps(EMPTY_TURNLESS_STEPS);
1372
- turnStepHandlesRef.current = /* @__PURE__ */ new Map();
1373
- presentedCallIdsRef.current = /* @__PURE__ */ new Set();
1374
- presentedScanRef.current = null;
1375
- startupRef.current = emptyStartupTurns();
1376
- presentedRequestedRef.current = /* @__PURE__ */ new Map();
1377
- presentedFailuresRef.current = /* @__PURE__ */ new Map();
1378
- setPresentedOutputs(EMPTY_PRESENTED_OUTPUTS);
1379
- }
1380
- const generation = generationRef.current + 1;
1381
- generationRef.current = generation;
1382
- if (!sessionId || !streamEnabled) {
1383
- streamTransientStreakRef.current = null;
1384
- if (sessionId && enabled && !pageLive && !fullReplay && viewModeRef.current === "live" && initialWindowLoadedRef.current) {
1385
- reconcileAfterPageResumeRef.current = true;
1386
- }
1387
- setConnectionState("idle");
1388
- return;
1389
- }
1390
- if (viewMode === "history") {
1391
- reconcileAfterPageResumeRef.current = false;
1392
- setConnectionState("idle");
1393
- setInitialLoading(false);
1394
- return;
1395
- }
1396
- const reconcileForegroundResume = reconcileAfterPageResumeRef.current && !fullReplay;
1397
- reconcileAfterPageResumeRef.current = false;
1398
- const controller = new AbortController();
1399
- const detailReadMark = sessionDetailReadMark();
1400
- const isCurrent = () => generationRef.current === generation && !controller.signal.aborted && navigationIdentityRef.current.client === client && navigationIdentityRef.current.streamKey === streamKey && navigationIdentityRef.current.enabled === enabled;
1401
- streamAbortRef.current = controller;
1402
- let transientRetryTimer = null;
1403
- const scheduleTransientRetry = (delayMs, retry) => {
1404
- if (transientRetryTimer !== null) clearTimeout(transientRetryTimer);
1405
- transientRetryTimer = setTimeout(() => {
1406
- transientRetryTimer = null;
1407
- if (isCurrent()) retry();
1408
- }, delayMs);
1409
- };
1410
- let pending = [];
1411
- let pendingBytes = 2;
1412
- let flushTimer = null;
1413
- const flush = () => {
1414
- if (flushTimer !== null) {
1415
- clearTimeout(flushTimer);
1416
- flushTimer = null;
1417
- }
1418
- if (!isCurrent()) {
1419
- pending = [];
1420
- pendingBytes = 2;
1421
- return;
1422
- }
1423
- if (pending.length === 0) {
1424
- return;
1425
- }
1426
- const batch = pending;
1427
- pending = [];
1428
- pendingBytes = 2;
1429
- const lastInBatch = batch[batch.length - 1];
1430
- if (lastInBatch) {
1431
- const batchResumeSequence = Math.max(...batch.map(eventResumeSequence));
1432
- lastSequenceRef.current = Math.max(lastSequenceRef.current, batchResumeSequence);
1433
- streamResumeSequenceRef.current = Math.max(
1434
- streamResumeSequenceRef.current,
1435
- batchResumeSequence
1436
- );
1437
- liveThroughRef.current = Math.max(liveThroughRef.current, batchResumeSequence);
1438
- }
1439
- const status = observeSessionStatus(batch, sessionStatusRef);
1440
- if (status !== void 0) {
1441
- setSessionStatusProjection(status);
1442
- }
1443
- let conversation = batch;
1444
- const steps = [];
1445
- if (!fullReplay) {
1446
- const windowNewest = newestSequenceRef.current ?? 0;
1447
- const startup = startupTurns();
1448
- conversation = [];
1449
- for (const event of batch) {
1450
- if (!isConversationHistoryEvent(event, presentedCallIds(event), startup.open)) {
1451
- steps.push(event);
1452
- } else if (event.sequence > windowNewest) conversation.push(event);
1453
- noteStartupTurns([event], startup);
1454
- }
1455
- }
1456
- if (conversation.length > 0) {
1457
- const current = eventWindowRef.current;
1458
- const next = appendBrowserSessionEventWindow(current, conversation);
1459
- const retained = {
1460
- ...next,
1461
- truncated: current.truncated || next.truncated
1462
- };
1463
- eventWindowRef.current = retained;
1464
- setEventWindow(retained);
1465
- if (!fullReplay) startupRef.current.window = retained.events;
1466
- oldestSequenceRef.current = retained.events[0]?.sequence ?? null;
1467
- newestSequenceRef.current = maxResumeSequenceOrNull(retained.events);
1468
- if (retained.truncated) {
1469
- hasOlderRef.current = true;
1470
- setHasOlder(true);
1471
- }
1472
- }
1473
- if (steps.length > 0) appendLiveSteps(steps);
1474
- };
1475
- const scheduleFlush = () => {
1476
- if (!isCurrent()) return;
1477
- flushTimer ??= setTimeout(flush, 16);
1478
- };
1479
- const installCatchup = (events, head) => {
1480
- const current = eventWindowRef.current;
1481
- const windowNewest = newestSequenceRef.current ?? 0;
1482
- const fresh = events.filter((event) => event.sequence > windowNewest);
1483
- const status = observeSessionStatus(fresh, sessionStatusRef);
1484
- const next = appendBrowserSessionEventWindow(current, fresh);
1485
- const retained = { ...next, truncated: current.truncated || next.truncated };
1486
- eventWindowRef.current = retained;
1487
- oldestSequenceRef.current = retained.events[0]?.sequence ?? oldestSequenceRef.current;
1488
- newestSequenceRef.current = maxResumeSequenceOrNull(retained.events) ?? newestSequenceRef.current;
1489
- lastSequenceRef.current = Math.max(lastSequenceRef.current, head);
1490
- streamResumeSequenceRef.current = Math.max(streamResumeSequenceRef.current, head);
1491
- if (skippedStepsThroughRef.current !== null) {
1492
- skippedStepsThroughRef.current = Math.max(skippedStepsThroughRef.current, head);
1493
- }
1494
- if (status !== void 0) setSessionStatusProjection(status);
1495
- if (fresh.length > 0) setEventWindow(retained);
1496
- if (retained.truncated) {
1497
- hasOlderRef.current = true;
1498
- setHasOlder(true);
1499
- }
1500
- };
1501
- const effectScope = { signal: controller.signal, isCurrent };
1502
- const readSessionHead = async (mark, scope) => {
1503
- const joined = joinSessionDetailRead(client, workspaceId, sessionId, mark);
1504
- if (joined) {
1505
- try {
1506
- return await joined;
1507
- } catch (cause) {
1508
- if (scope.signal.aborted) throw cause;
1509
- }
1510
- }
1511
- return await client.getSession(workspaceId, sessionId, {
1512
- fresh: true,
1513
- signal: scope.signal
1514
- });
1515
- };
1516
- const rejoinLive = async (force, {
1517
- strict = false,
1518
- mark = detailReadMark,
1519
- scope = effectScope
1520
- } = {}) => {
1521
- const activeTurn = activeConversationTurn(eventWindowRef.current.events);
1522
- if (!force && !activeTurn) return "joined";
1523
- const cursor = streamResumeSequenceRef.current;
1524
- let head;
1525
- let sessionActiveTurn = null;
1526
- try {
1527
- const session = await readSessionHead(mark, scope);
1528
- scope.progress?.();
1529
- head = session.lastSequence;
1530
- sessionActiveTurn = session.activeTurnId;
1531
- } catch (cause) {
1532
- if (!scope.isCurrent() || strict && isRetryableStreamError(cause)) throw cause;
1533
- return "joined";
1534
- }
1535
- if (!scope.isCurrent()) throw abortError();
1536
- if (!Number.isSafeInteger(head) || head - cursor <= DIRECT_REPLAY_MAX_SEQUENCES) {
1537
- return "joined";
1538
- }
1539
- let catchup;
1540
- try {
1541
- catchup = await loadConversationCatchup(
1542
- client,
1543
- workspaceId,
1544
- sessionId,
1545
- cursor,
1546
- head,
1547
- scope
1548
- );
1549
- } catch (cause) {
1550
- if (!scope.isCurrent() || strict && isRetryableStreamError(cause)) throw cause;
1551
- return "joined";
1552
- }
1553
- if (!scope.isCurrent()) throw abortError();
1554
- if (catchup === null) return "reload";
1555
- const previous = eventWindowRef.current.events;
1556
- installCatchup(catchup, head);
1557
- const working = sessionActiveTurn ?? activeConversationTurn(eventWindowRef.current.events);
1558
- pruneStepStores(eventWindowRef.current.events, previous, working);
1559
- if (working) loadTurnStepsRef.current(working, head + 1);
1560
- if (working && conversationTurnBounds(eventWindowRef.current.events).has(working)) {
1561
- skippedStepsThroughRef.current = null;
1562
- }
1563
- return "joined";
1564
- };
1565
- const loadLatestWindow = async (scope = effectScope) => {
1566
- const window2 = await loadEventWindow(t, client, workspaceId, sessionId, {
1567
- before: Number.MAX_SAFE_INTEGER,
1568
- pageSize: SESSION_FIRST_WINDOW_PAGE_SIZE,
1569
- targetGroups: Number.POSITIVE_INFINITY,
1570
- maxFetches: INITIAL_FETCH_CAP,
1571
- boundaryPageCap: BOUNDARY_PAGE_CAP,
1572
- signal: scope.signal,
1573
- ...scope.progress ? { progress: scope.progress } : {},
1574
- filter: CONVERSATION_FILTER
1575
- });
1576
- if (!scope.isCurrent()) {
1577
- return false;
1578
- }
1579
- const status = observeSessionStatus(window2.events, sessionStatusRef);
1580
- const retained = boundBrowserSessionEventWindow(window2.events);
1581
- navigationGenerationRef.current += 1;
1582
- loadingOlderRef.current = false;
1583
- loadingNewerRef.current = false;
1584
- loadingOldestRef.current = false;
1585
- setLoadingOlder(false);
1586
- setLoadingNewer(false);
1587
- setLoadingOldest(false);
1588
- const previous = eventWindowRef.current.events;
1589
- eventWindowRef.current = retained;
1590
- pruneStepStores(retained.events, previous);
1591
- oldestSequenceRef.current = retained.events[0]?.sequence ?? window2.oldestSequence ?? window2.scanCursor;
1592
- newestSequenceRef.current = maxResumeSequenceOrNull(retained.events) ?? window2.newestSequence;
1593
- hasOlderRef.current = window2.hasOlder || retained.truncated;
1594
- hasNewerRef.current = false;
1595
- lastSequenceRef.current = Math.max(lastSequenceRef.current, window2.newestSequence);
1596
- streamResumeSequenceRef.current = window2.newestSequence;
1597
- skippedStepsThroughRef.current = retained.events.length === 0 && window2.newestSequence > 0 ? window2.newestSequence : null;
1598
- initialWindowLoadedRef.current = true;
1599
- streamTransientStreakRef.current = null;
1600
- setInitialHistoryReady(true);
1601
- setError(null);
1602
- if (status !== void 0) {
1603
- setSessionStatusProjection(status);
1604
- }
1605
- setEventWindow(retained);
1606
- setHasOlder(window2.hasOlder || retained.truncated);
1607
- setHasNewer(false);
1608
- setInitialLoading(false);
1609
- return true;
1610
- };
1611
- const noteStreamResume = () => {
1612
- if (!fullReplay && streamResumeSequenceRef.current > liveThroughRef.current) {
1613
- markTurnlessOutputGap(workspaceId, sessionId);
1614
- }
1615
- liveThroughRef.current = Math.max(liveThroughRef.current, streamResumeSequenceRef.current);
1616
- };
1617
- const reconcileAfterOpen = (initialOpen, streak = null) => {
1618
- void Promise.resolve().then(() => reconcileSession(sessionId, { initialOpen })).catch((cause) => {
1619
- if (!isCurrent()) return;
1620
- if (isTransientRequestError(cause)) {
1621
- const now = Date.now();
1622
- const current = streak ?? { since: now, attempts: 0, surfaced: false };
1623
- const step = transientReadRetryStep(current, now, DEFAULT_TRANSIENT_READ_RETRY, cause);
1624
- if (step.quiet) {
1625
- scheduleTransientRetry(step.delayMs, () => reconcileAfterOpen(initialOpen, current));
1626
- return;
1627
- }
1628
- }
1629
- setError(normalizeError(cause));
1630
- });
1631
- };
1632
- const boundedRejoin = async (strict, join) => {
1633
- if (!isCurrent()) throw abortError();
1634
- const attempt = new AbortController();
1635
- let timedOut = false;
1636
- const abortAttempt = () => attempt.abort();
1637
- controller.signal.addEventListener("abort", abortAttempt, { once: true });
1638
- const stalled = () => {
1639
- timedOut = true;
1640
- attempt.abort();
1641
- };
1642
- let timer = setTimeout(stalled, REJOIN_STALL_TIMEOUT_MS);
1643
- let stopWaiting;
1644
- const stopped = new Promise((_resolve, reject) => {
1645
- stopWaiting = () => reject(abortError());
1646
- attempt.signal.addEventListener("abort", stopWaiting, { once: true });
1647
- });
1648
- const scope = {
1649
- signal: attempt.signal,
1650
- isCurrent: () => isCurrent() && !attempt.signal.aborted,
1651
- progress: () => {
1652
- if (attempt.signal.aborted) return;
1653
- clearTimeout(timer);
1654
- timer = setTimeout(stalled, REJOIN_STALL_TIMEOUT_MS);
1655
- }
1656
- };
1657
- try {
1658
- return await Promise.race([join(scope), stopped]);
1659
- } catch (cause) {
1660
- if (!isCurrent()) throw cause;
1661
- if (timedOut) {
1662
- return strict ? {
1663
- retry: new TypeError(
1664
- `rejoining the live session stalled for ${REJOIN_STALL_TIMEOUT_MS}ms`
1665
- )
1666
- } : "joined";
1667
- }
1668
- if (strict && isRetryableStreamError(cause)) return { retry: cause };
1669
- throw cause;
1670
- } finally {
1671
- clearTimeout(timer);
1672
- controller.signal.removeEventListener("abort", abortAttempt);
1673
- if (stopWaiting) attempt.signal.removeEventListener("abort", stopWaiting);
1674
- }
1675
- };
1676
- const leniently = async (join) => {
1677
- const result = await boundedRejoin(false, join);
1678
- return typeof result === "string" ? result : "joined";
1679
- };
1680
- let strictFailures = 0;
1681
- const beforeReconnect = async (cursor) => {
1682
- flush();
1683
- if (!isCurrent()) throw abortError();
1684
- const strict = strictFailures < STRICT_REJOIN_ATTEMPTS;
1685
- const mark = sessionDetailReadMark();
1686
- let result;
1687
- try {
1688
- result = await boundedRejoin(strict, async (scope) => {
1689
- if (await rejoinLive(true, { strict, mark, scope }) === "joined") return "joined";
1690
- let loaded;
1691
- try {
1692
- loaded = await loadLatestWindow(scope);
1693
- } catch (cause) {
1694
- if (!scope.isCurrent() || strict && isRetryableStreamError(cause)) throw cause;
1695
- return "joined";
1696
- }
1697
- if (!loaded) throw abortError();
1698
- if (await rejoinLive(true, { strict, mark, scope }) === "reload" && strict) {
1699
- throw new TypeError("the session outran a fresh window while rejoining it");
1700
- }
1701
- return "joined";
1702
- });
1703
- } catch (cause) {
1704
- if (!isCurrent()) throw abortError();
1705
- if (!isRetryableStreamError(cause)) throw cause;
1706
- throw new Error(`rejoining the live session failed: ${errorMessage(cause)}`, { cause });
1707
- }
1708
- if (!isCurrent()) throw abortError();
1709
- if (typeof result === "object") {
1710
- strictFailures += 1;
1711
- throw result.retry;
1712
- }
1713
- noteStreamResume();
1714
- return Math.max(cursor, streamResumeSequenceRef.current);
1715
- };
1716
- void (async () => {
1717
- try {
1718
- if (reconcileForegroundResume) {
1719
- setConnectionState("connecting");
1720
- let outcome;
1721
- for (let attempt = 0; ; attempt += 1) {
1722
- const strict = attempt < STRICT_REJOIN_ATTEMPTS;
1723
- const result = await boundedRejoin(
1724
- strict,
1725
- (scope) => rejoinLive(true, { strict, scope })
1726
- );
1727
- if (typeof result === "string") {
1728
- outcome = result;
1729
- break;
1730
- }
1731
- await abortableDelay(
1732
- Math.min(FOREGROUND_REJOIN_RETRY_MS * 2 ** attempt, FOREGROUND_REJOIN_RETRY_MAX_MS),
1733
- controller.signal
1734
- );
1735
- }
1736
- if (outcome === "reload") {
1737
- initialWindowLoadedRef.current = false;
1738
- setError(null);
1739
- }
1740
- } else if (!fullReplay && initialWindowLoadedRef.current && rejoinPendingRef.current) {
1741
- rejoinPendingRef.current = false;
1742
- if (await leniently((scope) => rejoinLive(false, { scope })) === "reload") {
1743
- initialWindowLoadedRef.current = false;
1744
- }
1745
- }
1746
- rejoinPendingRef.current = false;
1747
- const windowPasses = fullReplay ? 0 : 2;
1748
- for (let attempt = 0; attempt < windowPasses && !initialWindowLoadedRef.current; attempt += 1) {
1749
- setConnectionState("connecting");
1750
- if (!await loadLatestWindow()) {
1751
- return;
1752
- }
1753
- if (await leniently((scope) => rejoinLive(true, { scope })) === "reload" && attempt === 0) {
1754
- initialWindowLoadedRef.current = false;
1755
- }
1756
- }
1757
- if (fullReplay) {
1758
- setInitialLoading(false);
1759
- }
1760
- noteStreamResume();
1761
- const stream = client.streamEvents(workspaceId, sessionId, {
1762
- after: streamResumeSequenceRef.current,
1763
- signal: controller.signal,
1764
- // Full replay keeps the SDK's exactly-once reconnects.
1765
- ...fullReplay ? {} : { beforeReconnect },
1766
- onOpen: () => {
1767
- const initialOpen = openedStreamKeyRef.current !== streamKey;
1768
- openedStreamKeyRef.current = streamKey;
1769
- strictFailures = 0;
1770
- if (streamTransientStreakRef.current?.surfaced) setError(null);
1771
- streamTransientStreakRef.current = null;
1772
- reconcileAfterOpen(initialOpen);
1773
- },
1774
- onStateChange: (state) => {
1775
- if (isCurrent()) {
1776
- setConnectionState(state);
1777
- }
1778
- }
1779
- });
1780
- for await (const event of stream) {
1781
- if (!isCurrent()) break;
1782
- const boundedEvent = event;
1783
- const boundedEventBytes = browserJsonBytes(boundedEvent);
1784
- const separatorBytes = pending.length === 0 ? 0 : 1;
1785
- if (pending.length > 0 && (pending.length >= SESSION_EVENT_BROWSER_PENDING_MAX_COUNT || pendingBytes + separatorBytes + boundedEventBytes > SESSION_EVENT_BROWSER_PENDING_MAX_BYTES)) {
1786
- flush();
1787
- }
1788
- pending.push(boundedEvent);
1789
- pendingBytes += (pending.length === 1 ? 0 : 1) + boundedEventBytes;
1790
- if (pending.length >= SESSION_EVENT_BROWSER_PENDING_MAX_COUNT || pendingBytes >= SESSION_EVENT_BROWSER_PENDING_MAX_BYTES) {
1791
- flush();
1792
- } else {
1793
- scheduleFlush();
1794
- }
1795
- }
1796
- if (isCurrent()) {
1797
- flush();
1798
- setConnectionState("ended");
1799
- }
1800
- } catch (cause) {
1801
- if (isCurrent()) {
1802
- flush();
1803
- let announce = true;
1804
- if (isTransientRequestError(cause)) {
1805
- const now = Date.now();
1806
- const streak = streamTransientStreakRef.current ??= {
1807
- since: now,
1808
- attempts: 0,
1809
- surfaced: false
1810
- };
1811
- const step = transientReadRetryStep(streak, now, DEFAULT_TRANSIENT_READ_RETRY, cause);
1812
- scheduleTransientRetry(step.delayMs, () => setStreamEpoch((epoch) => epoch + 1));
1813
- if (step.quiet) {
1814
- setConnectionState("connecting");
1815
- return;
1816
- }
1817
- announce = !streak.surfaced;
1818
- streak.surfaced = true;
1819
- } else {
1820
- streamTransientStreakRef.current = null;
1821
- }
1822
- if (announce) setError(normalizeError(cause));
1823
- setConnectionState("error");
1824
- setInitialLoading(false);
1825
- }
1826
- }
1827
- })();
1828
- return () => {
1829
- controller.abort();
1830
- if (transientRetryTimer !== null) clearTimeout(transientRetryTimer);
1831
- if (generationRef.current === generation) {
1832
- generationRef.current = generation + 1;
1833
- }
1834
- if (streamAbortRef.current === controller) {
1835
- streamAbortRef.current = null;
1836
- }
1837
- if (flushTimer !== null) {
1838
- clearTimeout(flushTimer);
1839
- }
1840
- };
1841
- }, [
1842
- client,
1843
- workspaceId,
1844
- sessionId,
1845
- after,
1846
- enabled,
1847
- pageLive,
1848
- streamEnabled,
1849
- fullReplay,
1850
- streamKey,
1851
- streamEpoch,
1852
- viewMode,
1853
- reconcileSession,
1854
- t,
1855
- pruneStepStores,
1856
- appendLiveSteps,
1857
- presentedCallIds,
1858
- startupTurns
1859
- ]);
1860
- useEffect3(() => {
1861
- if (!sessionId || !streamEnabled) return;
1862
- return subscribePageWake(() => {
1863
- const stream = streamAbortRef.current;
1864
- if (!stream || stream.signal.aborted || viewModeRef.current !== "live") return;
1865
- if (!fullReplay && initialWindowLoadedRef.current) {
1866
- reconcileAfterPageResumeRef.current = true;
1867
- }
1868
- setStreamEpoch((epoch) => epoch + 1);
1869
- });
1870
- }, [sessionId, streamEnabled, fullReplay]);
1871
- const navigationBusy = () => loadingTargetRef.current || loadingOlderRef.current || loadingNewerRef.current || loadingOldestRef.current || loadingLatestRef.current;
1872
- const loadOlder = useCallback6(
1873
- () => createOlderHistoryLoadReceipt(async (markCommitted, preserveTail, markTailPreserved) => {
1874
- if (!ownsNavigation() || !sessionId || navigationBusy() || !hasOlderRef.current) {
1875
- return false;
1876
- }
1877
- const before = oldestSequenceRef.current;
1878
- if (before === null) {
1879
- oldestSequenceRef.current = null;
1880
- hasOlderRef.current = false;
1881
- setHasOlder(false);
1882
- return false;
1883
- }
1884
- const generation = navigationGenerationRef.current;
1885
- const isCurrent = () => ownsNavigation() && navigationGenerationRef.current === generation;
1886
- loadingOlderRef.current = true;
1887
- setLoadingOlder(true);
1888
- let published = false;
1889
- try {
1890
- const window2 = await loadEventWindow(t, client, workspaceId, sessionId, {
1891
- before,
1892
- pageSize: SESSION_HISTORY_PAGE_SIZE,
1893
- targetGroups: OLDER_GROUP_TARGET,
1894
- maxFetches: OLDER_FETCH_CAP,
1895
- filteredPageCap: FILTERED_PAGE_CAP,
1896
- isCurrent,
1897
- filter: historyFilter
1898
- });
1899
- if (!isCurrent()) {
1900
- return false;
1901
- }
1902
- if (window2.events.length === 0) {
1903
- if (window2.hasOlder && window2.scanCursor < before) {
1904
- oldestSequenceRef.current = window2.scanCursor;
1905
- return true;
1906
- }
1907
- oldestSequenceRef.current = null;
1908
- hasOlderRef.current = false;
1909
- setHasOlder(false);
1910
- return false;
1911
- }
1912
- const current = eventWindowRef.current;
1913
- assertPrependOrder(current.events, window2.events);
1914
- const next = boundBrowserSessionEventWindow([...window2.events, ...current.events], {
1915
- direction: "oldest"
1916
- });
1917
- if (preserveTail && maxResumeSequence(next.events) < maxResumeSequence(current.events)) {
1918
- markTailPreserved();
1919
- return false;
1920
- }
1921
- const status = observeSessionStatus(window2.events, sessionStatusRef);
1922
- const retained = {
1923
- ...next,
1924
- truncated: current.truncated || next.truncated
1925
- };
1926
- const retainedOldest = retained.events[0]?.sequence ?? null;
1927
- if (retainedOldest === null || retainedOldest >= before) {
1928
- throw new Error("@opengeni/react: loadOlder made no durable sequence progress");
1929
- }
1930
- const retainedNewest = maxResumeSequenceOrNull(retained.events);
1931
- const previousNewest = maxResumeSequenceOrNull(current.events);
1932
- const evictedLiveTail = previousNewest !== null && retainedNewest !== null && retainedNewest < previousNewest;
1933
- if (evictedLiveTail && viewModeRef.current === "live") {
1934
- streamAbortRef.current?.abort();
1935
- }
1936
- eventWindowRef.current = retained;
1937
- if (evictedLiveTail) {
1938
- skippedStepsThroughRef.current = null;
1939
- pruneStepStores(retained.events, current.events);
1940
- } else {
1941
- const skippedThrough = skippedStepsThroughRef.current;
1942
- if (skippedThrough !== null && windowTurns(window2.events).size > 0) {
1943
- skippedStepsThroughRef.current = null;
1944
- const working = activeConversationTurn(retained.events);
1945
- const bounds = working ? conversationTurnBounds(retained.events).get(working) : void 0;
1946
- if (working && bounds && bounds.first <= skippedThrough) {
1947
- loadTurnStepsRef.current(working, skippedThrough + 1);
1948
- }
1949
- }
1950
- }
1951
- markCommitted();
1952
- oldestSequenceRef.current = retainedOldest;
1953
- newestSequenceRef.current = retainedNewest;
1954
- if (evictedLiveTail) {
1955
- streamResumeSequenceRef.current = maxResumeSequence(retained.events);
1956
- }
1957
- const olderStillAvailable = window2.hasOlder;
1958
- hasOlderRef.current = olderStillAvailable;
1959
- let newer = null;
1960
- let enterHistory = false;
1961
- if (viewModeRef.current === "history" || evictedLiveTail) {
1962
- const highWater = lastSequenceRef.current;
1963
- newer = retainedNewest !== null && (retainedNewest < highWater || retained.truncated);
1964
- hasNewerRef.current = newer;
1965
- if (evictedLiveTail) {
1966
- viewModeRef.current = "history";
1967
- enterHistory = true;
1968
- }
1969
- }
1970
- loadingOlderRef.current = false;
1971
- startTransition(() => {
1972
- if (status !== void 0) {
1973
- setSessionStatusProjection(status);
1974
- }
1975
- setEventWindow(retained);
1976
- setHasOlder(olderStillAvailable);
1977
- if (newer !== null) {
1978
- setHasNewer(newer);
1979
- }
1980
- if (enterHistory) {
1981
- setViewMode("history");
1982
- }
1983
- setLoadingOlder(false);
1984
- });
1985
- published = true;
1986
- return olderStillAvailable;
1987
- } catch (reason) {
1988
- if (!isCurrent()) return false;
1989
- throw reason;
1990
- } finally {
1991
- if (!published && isCurrent()) {
1992
- loadingOlderRef.current = false;
1993
- setLoadingOlder(false);
1994
- }
1995
- }
1996
- }),
1997
- [client, workspaceId, sessionId, ownsNavigation, t, historyFilter, pruneStepStores]
1998
- );
1999
- const loadOldest = useCallback6(async () => {
2000
- if (!ownsNavigation() || !sessionId || navigationBusy() || !hasOlderRef.current) {
2001
- return false;
2002
- }
2003
- const generation = ++navigationGenerationRef.current;
2004
- const isCurrent = () => ownsNavigation() && navigationGenerationRef.current === generation;
2005
- setQuestionEvidence(null);
2006
- loadingOldestRef.current = true;
2007
- setLoadingOldest(true);
2008
- let published = false;
2009
- try {
2010
- const window2 = await loadForwardEventWindow(t, client, workspaceId, sessionId, {
2011
- after: 0,
2012
- pageSize: SESSION_HISTORY_PAGE_SIZE,
2013
- targetGroups: OLDEST_GROUP_TARGET,
2014
- maxFetches: OLDEST_FETCH_CAP,
2015
- isCurrent,
2016
- filter: historyFilter
2017
- });
2018
- if (!isCurrent()) {
2019
- return false;
2020
- }
2021
- if (window2.events.length === 0) {
2022
- hasOlderRef.current = false;
2023
- setHasOlder(false);
2024
- return false;
2025
- }
2026
- streamAbortRef.current?.abort();
2027
- const status = observeSessionStatus(window2.events, sessionStatusRef);
2028
- const retained = boundBrowserSessionEventWindow(window2.events, { direction: "oldest" });
2029
- const retainedOldest = retained.events[0]?.sequence ?? null;
2030
- const retainedNewest = maxResumeSequenceOrNull(retained.events);
2031
- const previous = eventWindowRef.current.events;
2032
- eventWindowRef.current = retained;
2033
- skippedStepsThroughRef.current = null;
2034
- pruneStepStores(retained.events, previous);
2035
- oldestSequenceRef.current = retainedOldest;
2036
- newestSequenceRef.current = retainedNewest;
2037
- hasOlderRef.current = false;
2038
- const highWater = Math.max(lastSequenceRef.current, retainedNewest ?? 0);
2039
- lastSequenceRef.current = highWater;
2040
- const newer = window2.hasNewer || retained.truncated || retainedNewest !== null && retainedNewest < highWater;
2041
- hasNewerRef.current = newer;
2042
- initialWindowLoadedRef.current = true;
2043
- setInitialHistoryReady(true);
2044
- setError(null);
2045
- viewModeRef.current = "history";
2046
- loadingOldestRef.current = false;
2047
- setNewerError(null);
2048
- startTransition(() => {
2049
- if (status !== void 0) {
2050
- setSessionStatusProjection(status);
2051
- }
2052
- setEventWindow(retained);
2053
- setHasOlder(false);
2054
- setHasNewer(newer);
2055
- setViewMode("history");
2056
- setLoadingOldest(false);
2057
- });
2058
- published = true;
2059
- return newer;
2060
- } catch (reason) {
2061
- if (!isCurrent()) return false;
2062
- throw reason;
2063
- } finally {
2064
- if (!published && isCurrent()) {
2065
- loadingOldestRef.current = false;
2066
- setLoadingOldest(false);
2067
- }
2068
- }
2069
- }, [client, workspaceId, sessionId, ownsNavigation, t, historyFilter, pruneStepStores]);
2070
- const loadNewer = useCallback6(async () => {
2071
- if (!ownsNavigation() || !sessionId || navigationBusy() || !hasNewerRef.current) {
2072
- return false;
2073
- }
2074
- const afterSequence = newestSequenceRef.current;
2075
- if (afterSequence === null) {
2076
- hasNewerRef.current = false;
2077
- setHasNewer(false);
2078
- return false;
2079
- }
2080
- const generation = navigationGenerationRef.current;
2081
- const isCurrent = () => ownsNavigation() && navigationGenerationRef.current === generation;
2082
- loadingNewerRef.current = true;
2083
- setLoadingNewer(true);
2084
- let published = false;
2085
- try {
2086
- const window2 = await loadForwardEventWindow(t, client, workspaceId, sessionId, {
2087
- after: afterSequence,
2088
- pageSize: SESSION_HISTORY_PAGE_SIZE,
2089
- targetGroups: NEWER_GROUP_TARGET,
2090
- maxFetches: NEWER_FETCH_CAP,
2091
- filteredPageCap: FILTERED_PAGE_CAP,
2092
- isCurrent,
2093
- filter: historyFilter
2094
- });
2095
- if (!isCurrent()) {
2096
- return false;
2097
- }
2098
- if (window2.events.length === 0) {
2099
- if (window2.hasNewer && window2.scanCursor > afterSequence) {
2100
- newestSequenceRef.current = window2.scanCursor;
2101
- return true;
2102
- }
2103
- setNewerError(null);
2104
- hasNewerRef.current = false;
2105
- setHasNewer(false);
2106
- streamResumeSequenceRef.current = afterSequence;
2107
- rejoinPendingRef.current = true;
2108
- viewModeRef.current = "live";
2109
- setViewMode("live");
2110
- setStreamEpoch((epoch) => epoch + 1);
2111
- return false;
2112
- }
2113
- const current = eventWindowRef.current;
2114
- assertAppendOrder(current.events, window2.events);
2115
- const status = observeSessionStatus(window2.events, sessionStatusRef);
2116
- const previousOldest = current.events[0]?.sequence ?? null;
2117
- const next = appendBrowserSessionEventWindow(current, window2.events);
2118
- const retained = {
2119
- ...next,
2120
- truncated: current.truncated || next.truncated || window2.hasNewer
2121
- };
2122
- const retainedOldest = retained.events[0]?.sequence ?? null;
2123
- const retainedNewest = maxResumeSequenceOrNull(retained.events);
2124
- if (retainedNewest === null || retainedNewest <= afterSequence) {
2125
- throw new Error("@opengeni/react: loadNewer made no durable sequence progress");
2126
- }
2127
- eventWindowRef.current = retained;
2128
- pruneStepStores(retained.events, null);
2129
- oldestSequenceRef.current = retainedOldest;
2130
- newestSequenceRef.current = retainedNewest;
2131
- if (retainedOldest !== null && (previousOldest === null || retainedOldest > previousOldest || retained.truncated && retained.events[0]?.type !== "session.created" && retainedOldest > 1)) {
2132
- hasOlderRef.current = true;
2133
- }
2134
- const rearmedOlder = hasOlderRef.current;
2135
- const highWater = Math.max(lastSequenceRef.current, retainedNewest);
2136
- lastSequenceRef.current = highWater;
2137
- const newer = window2.hasNewer || retainedNewest < highWater;
2138
- hasNewerRef.current = newer;
2139
- let resumeLive = false;
2140
- if (!newer) {
2141
- streamResumeSequenceRef.current = retainedNewest;
2142
- rejoinPendingRef.current = true;
2143
- viewModeRef.current = "live";
2144
- resumeLive = true;
2145
- }
2146
- loadingNewerRef.current = false;
2147
- setNewerError(null);
2148
- startTransition(() => {
2149
- if (status !== void 0) {
2150
- setSessionStatusProjection(status);
2151
- }
2152
- setEventWindow(retained);
2153
- setHasOlder(rearmedOlder);
2154
- setHasNewer(newer);
2155
- if (resumeLive) {
2156
- setViewMode("live");
2157
- setStreamEpoch((epoch) => epoch + 1);
2158
- }
2159
- setLoadingNewer(false);
2160
- });
2161
- published = true;
2162
- return newer;
2163
- } catch (reason) {
2164
- if (!isCurrent()) {
2165
- return false;
2166
- }
2167
- setNewerError(normalizeError(reason));
2168
- throw reason;
2169
- } finally {
2170
- if (!published && isCurrent()) {
2171
- loadingNewerRef.current = false;
2172
- setLoadingNewer(false);
2173
- }
2174
- }
2175
- }, [client, workspaceId, sessionId, ownsNavigation, t, historyFilter, pruneStepStores]);
2176
- const jumpToSequence = useCallback6(
2177
- async (sequence, navigationOptions) => {
2178
- const signal = navigationOptions?.signal;
2179
- if (!ownsNavigation() || !sessionId || !Number.isSafeInteger(sequence) || sequence < 1)
2180
- return false;
2181
- if (signal?.aborted) return false;
2182
- const generation = ++navigationGenerationRef.current;
2183
- setQuestionEvidence(null);
2184
- const current = () => generation === navigationGenerationRef.current && ownsNavigation();
2185
- const previousMode = viewModeRef.current;
2186
- streamAbortRef.current?.abort();
2187
- generationRef.current += 1;
2188
- viewModeRef.current = "history";
2189
- setViewMode("history");
2190
- loadingOlderRef.current = loadingNewerRef.current = loadingOldestRef.current = false;
2191
- setLoadingOlder(false);
2192
- setLoadingNewer(false);
2193
- setLoadingOldest(false);
2194
- loadingTargetRef.current = true;
2195
- setLoadingTarget(true);
2196
- let published = false;
2197
- try {
2198
- const around = (filter) => Promise.all([
2199
- loadPreviousPage(client, workspaceId, sessionId, sequence + 1, {
2200
- pageSize: 128,
2201
- filter
2202
- }),
2203
- loadNextPage(client, workspaceId, sessionId, sequence, { pageSize: 128, filter })
2204
- ]);
2205
- let [before, following] = await around(historyFilter);
2206
- if (historyFilter && current() && !before.some((event) => event.sequence === sequence)) {
2207
- [before, following] = await around(void 0);
2208
- }
2209
- if (signal?.aborted) return false;
2210
- if (!current()) return false;
2211
- if (!before.some((event) => event.sequence === sequence)) return false;
2212
- const prefix = boundBrowserSessionEventWindow(before, {
2213
- direction: "newest",
2214
- maxBytes: SESSION_EVENT_BROWSER_MAX_BYTES / 2
2215
- });
2216
- const retained = boundBrowserSessionEventWindow([...prefix.events, ...following], {
2217
- direction: "oldest"
2218
- });
2219
- if (!retained.events.some((event) => event.sequence === sequence)) return false;
2220
- streamAbortRef.current?.abort();
2221
- generationRef.current += 1;
2222
- const status = observeSessionStatus(retained.events, sessionStatusRef);
2223
- const previous = eventWindowRef.current.events;
2224
- eventWindowRef.current = retained;
2225
- pruneStepStores(retained.events, previous);
2226
- oldestSequenceRef.current = retained.events[0].sequence;
2227
- newestSequenceRef.current = maxResumeSequenceOrNull(retained.events);
2228
- lastSequenceRef.current = Math.max(lastSequenceRef.current, newestSequenceRef.current ?? 0);
2229
- hasOlderRef.current = !isLogStart(retained.events[0]);
2230
- hasNewerRef.current = following.length > 0 || retained.truncated || (newestSequenceRef.current ?? 0) < lastSequenceRef.current;
2231
- initialWindowLoadedRef.current = true;
2232
- setInitialHistoryReady(true);
2233
- setError(null);
2234
- viewModeRef.current = "history";
2235
- setEventWindow(retained);
2236
- setHasOlder(hasOlderRef.current);
2237
- setHasNewer(hasNewerRef.current);
2238
- setInitialLoading(false);
2239
- setViewMode("history");
2240
- setNewerError(null);
2241
- if (status !== void 0) setSessionStatusProjection(status);
2242
- published = true;
2243
- return true;
2244
- } catch (reason) {
2245
- if (!current() || signal?.aborted) return false;
2246
- throw reason;
2247
- } finally {
2248
- if (current()) {
2249
- loadingTargetRef.current = false;
2250
- setLoadingTarget(false);
2251
- if (!published && previousMode === "live") {
2252
- viewModeRef.current = "live";
2253
- setViewMode("live");
2254
- setStreamEpoch((epoch) => epoch + 1);
2255
- }
2256
- }
2257
- }
2258
- },
2259
- [client, workspaceId, sessionId, ownsNavigation, historyFilter, pruneStepStores]
2260
- );
2261
- const jumpToLatestQuestion = useCallback6(
2262
- async (questionOptions) => {
2263
- if (!sessionId || !ownsNavigation()) return null;
2264
- let generation = navigationGenerationRef.current;
2265
- const current = () => ownsNavigation() && generation === navigationGenerationRef.current;
2266
- try {
2267
- const { resolveLatestQuestion } = await import("./latest-question-QWJTXMFA.js");
2268
- if (!current()) return null;
2269
- const destination = await resolveLatestQuestion(t, {
2270
- client,
2271
- workspaceId,
2272
- sessionId,
2273
- isCurrent: current,
2274
- resumeSequence: maxResumeSequence,
2275
- options: questionOptions
2276
- });
2277
- if (!destination || !current()) return null;
2278
- if (!eventWindowRef.current.events.some((event) => event.sequence === destination.anchor)) {
2279
- const navigation = jumpToSequence(destination.anchor);
2280
- generation = navigationGenerationRef.current;
2281
- if (!await navigation || !current()) return null;
2282
- }
2283
- setQuestionEvidence({
2284
- client,
2285
- streamKey,
2286
- anchor: destination.anchor,
2287
- events: destination.events
2288
- });
2289
- return destination.questionSequence;
2290
- } catch (reason) {
2291
- if (!current()) return null;
2292
- throw reason;
2293
- }
2294
- },
2295
- [client, workspaceId, sessionId, streamKey, ownsNavigation, jumpToSequence, t]
2296
- );
2297
- const jumpToLatest = useCallback6(async () => {
2298
- if (!ownsNavigation()) return;
2299
- if (loadingTargetRef.current) {
2300
- navigationGenerationRef.current += 1;
2301
- loadingTargetRef.current = false;
2302
- setLoadingTarget(false);
2303
- }
2304
- if (!sessionId || navigationBusy()) {
2305
- return;
2306
- }
2307
- navigationGenerationRef.current += 1;
2308
- setQuestionEvidence(null);
2309
- loadingLatestRef.current = true;
2310
- setLoadingLatest(true);
2311
- setNewerError(null);
2312
- setError(null);
2313
- let published = false;
2314
- try {
2315
- streamAbortRef.current?.abort();
2316
- hasNewerRef.current = false;
2317
- hasOlderRef.current = false;
2318
- newestSequenceRef.current = null;
2319
- oldestSequenceRef.current = null;
2320
- eventWindowRef.current = EMPTY_EVENT_WINDOW;
2321
- initialWindowLoadedRef.current = false;
2322
- streamResumeSequenceRef.current = after;
2323
- viewModeRef.current = "live";
2324
- loadingLatestRef.current = false;
2325
- startTransition(() => {
2326
- setHasNewer(false);
2327
- setHasOlder(false);
2328
- setEventWindow(EMPTY_EVENT_WINDOW);
2329
- setInitialLoading(true);
2330
- setViewMode("live");
2331
- setStreamEpoch((epoch) => epoch + 1);
2332
- setLoadingLatest(false);
2333
- });
2334
- published = true;
2335
- await Promise.resolve();
2336
- } finally {
2337
- if (!published) {
2338
- loadingLatestRef.current = false;
2339
- setLoadingLatest(false);
2340
- }
2341
- }
2342
- }, [after, sessionId, ownsNavigation]);
2343
- const identityMatches = stateStreamKey === streamKey;
2344
- const freshTail = identityMatches && initialHistoryReady && viewMode === "live" && !fullReplay ? {
2345
- events: eventWindow.events,
2346
- hasOlder,
2347
- truncated: eventWindow.truncated,
2348
- bytes: eventWindow.bytes,
2349
- sessionStatus: sessionStatusProjection
2350
- } : null;
2351
- const retainedTail = useRetainedSessionView(client, workspaceId, sessionId, "events", freshTail, {
2352
- enabled: !fullReplay,
2353
- bytes: (tail) => tail.bytes,
2354
- budgetBytes: SESSION_EVENT_BROWSER_MAX_BYTES,
2355
- discard: identityMatches && deniesRetainedView(error)
2356
- });
2357
- const showRetained = retainedTail !== null && !(identityMatches && initialHistoryReady);
2358
- const visibleEvents = showRetained ? retainedTail.events : identityMatches ? eventWindow.events : EMPTY_EVENTS;
2359
- const visibleHasOlder = showRetained ? retainedTail.hasOlder : identityMatches && hasOlder;
2360
- const visibleTruncated = showRetained ? retainedTail.truncated : eventWindow.truncated;
2361
- const liveSteps = identityMatches && !showRetained;
2362
- const visibleStepStores = liveSteps ? stepStores : EMPTY_STEP_STORES;
2363
- const visiblePresentedOutputs = liveSteps ? presentedOutputs : EMPTY_PRESENTED_OUTPUTS;
2364
- const visibleTurnless = liveSteps ? turnlessSteps : EMPTY_TURNLESS_STEPS;
2365
- const readToolOutput = useCallback6(
2366
- async (sequence) => sessionId ? (await readEventPage(client, workspaceId, sessionId, {
2367
- includeTypes: ["agent.toolCall.output"],
2368
- after: Math.max(0, sequence - 1),
2369
- before: sequence + 1,
2370
- direction: "after",
2371
- limit: 1,
2372
- payloadMode: "full"
2373
- })).events : [],
2374
- [client, workspaceId, sessionId]
2375
- );
2376
- const toolOutputs = useToolOutputReads(readToolOutput, stepStores);
2377
- const visibleToolOutputs = liveSteps ? toolOutputs.exact : EMPTY_PRESENTED_OUTPUTS;
2378
- const loadedEvents = useMemo2(
2379
- () => mergeLoadedEvents(
2380
- visibleEvents,
2381
- visibleStepStores,
2382
- visiblePresentedOutputs,
2383
- visibleTurnless.events,
2384
- visibleToolOutputs
2385
- ),
2386
- [
2387
- visibleEvents,
2388
- visibleStepStores,
2389
- visiblePresentedOutputs,
2390
- visibleTurnless,
2391
- visibleToolOutputs
2392
- ]
2393
- );
2394
- const turnSteps = useMemo2(() => {
2395
- if (fullReplay) return void 0;
2396
- const markers = /* @__PURE__ */ new Map();
2397
- const bounded = withTurnlessSteps(visibleEvents, visibleTurnless);
2398
- for (const [turnId, bounds] of conversationTurnBounds(bounded)) {
2399
- const store = visibleStepStores.get(turnId);
2400
- if (store && !store.loading && !store.error && !stepStoreHasOlder(store, bounds)) {
2401
- if (!store.events.some((event) => CONTENT_STEP_TYPES.has(event.type))) continue;
2402
- }
2403
- const state = store ? store.loading ? "loading" : store.error ? "error" : stepStoreHasOlder(store, bounds) ? "partial" : "complete" : bounds.hidden ? "idle" : null;
2404
- if (state === null) continue;
2405
- markers.set(turnId, { state, ...liveSteps ? turnStepHandle(turnId) : RETAINED_VIEW_STEPS });
2406
- }
2407
- return markers;
2408
- }, [fullReplay, visibleEvents, visibleTurnless, visibleStepStores, liveSteps, turnStepHandle]);
2409
- const timeline = useMemo2(() => {
2410
- const witness = questionEvidence?.client === client && questionEvidence.streamKey === streamKey && visibleEvents.some((event) => event.sequence === questionEvidence.anchor) ? questionEvidence.events : EMPTY_EVENTS;
2411
- const timelineOptions = {
2412
- partialStart: visibleHasOlder || visibleTruncated || after > 0,
2413
- ...turnSteps ? { turnSteps } : {},
2414
- ...liveSteps ? { toolOutputs: toolOutputs.reader } : {}
2415
- };
2416
- if (witness.length === 0) return buildTimeline(t, loadedEvents, timelineOptions);
2417
- const ids = new Set(loadedEvents.map((event) => event.id));
2418
- return buildTimeline(
2419
- t,
2420
- [...loadedEvents, ...witness.filter((event) => !ids.has(event.id))],
2421
- timelineOptions
2422
- );
2423
- }, [
2424
- loadedEvents,
2425
- visibleEvents,
2426
- visibleHasOlder,
2427
- visibleTruncated,
2428
- after,
2429
- questionEvidence,
2430
- client,
2431
- streamKey,
2432
- turnSteps,
2433
- liveSteps,
2434
- toolOutputs.reader,
2435
- t
2436
- ]);
2437
- useEffect3(() => {
2438
- if (fullReplay || !sessionId || !identityMatches || !initialHistoryReady) return;
2439
- const resolved = new Set(presentedOutputs.keys());
2440
- const collect = (events) => {
2441
- for (const event of events) {
2442
- if (event.type !== "agent.toolCall.output" || isToolOutputPreviewEvent(event)) continue;
2443
- const id = event.payload?.id;
2444
- if (typeof id === "string") resolved.add(id);
2445
- }
2446
- };
2447
- collect(eventWindow.events);
2448
- for (const store of stepStores.values()) collect(store.events);
2449
- const requested = presentedRequestedRef.current;
2450
- let inFlight = 0;
2451
- for (const request of requested.values()) if (request.pending) inFlight += 1;
2452
- const room = PRESENTED_OUTPUT_READS_PER_PASS - inFlight;
2453
- if (room <= 0) return;
2454
- const missing = [];
2455
- for (const event of eventWindow.events) {
2456
- if (event.type !== "agent.toolCall.created") continue;
2457
- const payload = event.payload;
2458
- const callId = payload?.id;
2459
- if (typeof callId !== "string" || resolved.has(callId) || requested.has(callId) || !isPresentedSessionToolCall(payload)) {
2460
- continue;
2461
- }
2462
- missing.push({ callId, sequence: event.sequence, turnId: event.turnId ?? null });
2463
- }
2464
- if (missing.length === 0) return;
2465
- const bounds = conversationTurnBounds(eventWindow.events);
2466
- for (const { callId, sequence, turnId } of missing.slice(-room)) {
2467
- const request = { turnId, pending: true };
2468
- requested.set(callId, request);
2469
- const isCurrent = () => presentedRequestedRef.current === requested && requested.get(callId) === request;
2470
- const terminal = turnId ? bounds.get(turnId)?.terminal ?? null : null;
2471
- void findPresentedOutput(client, workspaceId, sessionId, callId, sequence, terminal).then(
2472
- (output) => {
2473
- if (!ownsNavigation() || !isCurrent()) return;
2474
- request.pending = false;
2475
- if (output) setPresentedOutputs((current) => new Map(current).set(callId, output));
2476
- setPresentedPass((pass) => pass + 1);
2477
- },
2478
- () => {
2479
- if (!isCurrent()) return;
2480
- requested.delete(callId);
2481
- const failures = (presentedFailuresRef.current.get(callId) ?? 0) + 1;
2482
- presentedFailuresRef.current.set(callId, failures);
2483
- if (failures > PRESENTED_OUTPUT_RETRIES) return;
2484
- setTimeout(() => {
2485
- if (ownsNavigation()) setPresentedPass((pass) => pass + 1);
2486
- }, PRESENTED_OUTPUT_RETRY_MS * failures);
2487
- }
2488
- );
2489
- }
2490
- }, [
2491
- fullReplay,
2492
- sessionId,
2493
- identityMatches,
2494
- initialHistoryReady,
2495
- eventWindow,
2496
- stepStores,
2497
- presentedOutputs,
2498
- presentedPass,
2499
- client,
2500
- workspaceId,
2501
- ownsNavigation
2502
- ]);
2503
- return {
2504
- events: loadedEvents,
2505
- timeline,
2506
- sessionStatus: showRetained ? retainedTail.sessionStatus : identityMatches ? sessionStatusProjection : null,
2507
- sessionStatusSequence: identityMatches ? sessionStatusRef.current.sequence : 0,
2508
- connectionState: identityMatches ? connectionState : "idle",
2509
- lastSequence: identityMatches ? lastSequenceRef.current : after,
2510
- windowBytes: identityMatches ? eventWindow.bytes : 2,
2511
- windowTruncated: identityMatches ? eventWindow.truncated : false,
2512
- initialLoading: fullReplay || showRetained ? false : identityMatches ? initialLoading : true,
2513
- initialHistoryReady: identityMatches && initialHistoryReady,
2514
- hasOlder: visibleHasOlder,
2515
- loadingOlder: !identityMatches ? false : loadingOlder,
2516
- loadOlder,
2517
- hasNewer: !identityMatches ? false : hasNewer,
2518
- loadingNewer: !identityMatches ? false : loadingNewer,
2519
- loadNewer,
2520
- loadingOldest: !identityMatches ? false : loadingOldest,
2521
- loadOldest,
2522
- loadingLatest: !identityMatches ? false : loadingLatest,
2523
- jumpToLatest,
2524
- jumpToLatestQuestion,
2525
- jumpToSequence,
2526
- loadingTarget: identityMatches && loadingTarget,
2527
- error: identityMatches ? newerError ?? error : null
2528
- };
2529
- }
2530
- function boundBrowserSessionEventWindow(events, options = {}) {
2531
- const maxBytes = Math.max(1024, options.maxBytes ?? SESSION_EVENT_BROWSER_MAX_BYTES);
2532
- const maxCount = Math.max(1, Math.floor(options.maxCount ?? SESSION_EVENT_BROWSER_MAX_COUNT));
2533
- const safe = events;
2534
- const selected = [];
2535
- let bytes = 2;
2536
- const direction = options.direction ?? "newest";
2537
- const start = direction === "newest" ? safe.length - 1 : 0;
2538
- const end = direction === "newest" ? Math.max(-1, safe.length - maxCount - 1) : safe.length;
2539
- const step = direction === "newest" ? -1 : 1;
2540
- for (let index = start; index !== end && selected.length < maxCount; index += step) {
2541
- const event = safe[index];
2542
- const eventBytes = browserJsonBytes(event);
2543
- const separator = selected.length === 0 ? 0 : 1;
2544
- if (selected.length > 0 && bytes + separator + eventBytes > maxBytes) break;
2545
- selected.push(event);
2546
- bytes += separator + eventBytes;
2547
- }
2548
- if (direction === "newest") selected.reverse();
2549
- return {
2550
- events: selected,
2551
- bytes,
2552
- truncated: selected.length < safe.length
2553
- };
2554
- }
2555
- function appendBrowserSessionEventWindow(current, batch, options = {}) {
2556
- const maxBytes = Math.max(1024, options.maxBytes ?? SESSION_EVENT_BROWSER_MAX_BYTES);
2557
- const maxCount = Math.max(1, Math.floor(options.maxCount ?? SESSION_EVENT_BROWSER_MAX_COUNT));
2558
- const events = [...current.events, ...batch];
2559
- let bytes = current.bytes;
2560
- for (let index = 0; index < batch.length; index += 1) {
2561
- bytes += browserJsonBytes(batch[index]) + (current.events.length + index > 0 ? 1 : 0);
2562
- }
2563
- let start = 0;
2564
- while (events.length - start > 1 && (bytes > maxBytes || events.length - start > maxCount)) {
2565
- bytes -= browserJsonBytes(events[start]) + 1;
2566
- start += 1;
2567
- }
2568
- return {
2569
- events: start === 0 ? events : events.slice(start),
2570
- bytes,
2571
- truncated: current.truncated || start > 0
2572
- };
2573
- }
2574
- function browserJsonBytes(value) {
2575
- return encoder.encode(JSON.stringify(value)).byteLength;
2576
- }
2577
- function observeSessionStatus(events, ref) {
2578
- let latest = null;
2579
- for (const event of events) {
2580
- const status = sessionStatusFromEvents([event]);
2581
- if (status && (!latest || event.sequence >= latest.sequence)) {
2582
- latest = { sequence: event.sequence, status };
2583
- }
2584
- }
2585
- if (!latest || latest.sequence < ref.current.sequence) return void 0;
2586
- ref.current = latest;
2587
- return latest.status;
2588
- }
2589
- async function loadConversationCatchup(client, workspaceId, sessionId, cursor, head, options) {
2590
- const events = [];
2591
- let after = cursor;
2592
- for (let fetch = 0; fetch < CATCHUP_MAX_PAGES; fetch += 1) {
2593
- if (options.signal?.aborted) throw abortError();
2594
- const page = await readConversationPage(client, workspaceId, sessionId, {
2595
- after,
2596
- before: head + 1,
2597
- direction: "after",
2598
- limit: SESSION_HISTORY_PAGE_SIZE,
2599
- compact: true,
2600
- payloadMode: "full"
2601
- });
2602
- if (!options.isCurrent()) throw abortError();
2603
- options.progress?.();
2604
- const fresh = page.filter((event) => eventResumeSequence(event) > after);
2605
- assertAscending(fresh);
2606
- events.push(...fresh);
2607
- if (page.raw.newest === null || page.raw.newest <= after) return events;
2608
- after = page.raw.newest;
2609
- if (after >= head || page.hasMore === false) return events;
2610
- }
2611
- return null;
2612
- }
2613
- async function loadEventWindow(t, client, workspaceId, sessionId, options) {
2614
- let cursor = options.before;
2615
- let buffer = [];
2616
- let reachedStart = false;
2617
- let fetches = 0;
2618
- let filteredPages = 0;
2619
- let rawNewest = 0;
2620
- const counts = (page) => {
2621
- rawNewest = Math.max(rawNewest, page.raw.newest ?? 0);
2622
- return page.length > 0 || (filteredPages += 1) > (options.filteredPageCap ?? 0);
2623
- };
2624
- while (fetches < options.maxFetches) {
2625
- if (buffer.length > 0 && groupCount(t, buffer) >= options.targetGroups) {
2626
- break;
2627
- }
2628
- const page = await loadPreviousPage(client, workspaceId, sessionId, cursor, {
2629
- pageSize: options.pageSize,
2630
- filter: options.filter,
2631
- ...options.signal ? { signal: options.signal } : {}
2632
- });
2633
- if (options.isCurrent?.() === false) throw abortError();
2634
- options.progress?.();
2635
- if (page.raw.oldest === null) {
2636
- reachedStart = true;
2637
- break;
2638
- }
2639
- if (counts(page)) fetches += 1;
2640
- assertAscending(page);
2641
- buffer = [...page, ...buffer];
2642
- cursor = page.raw.oldest;
2643
- if (page.raw.oldest <= 1 || page[0] !== void 0 && isLogStart(page[0])) {
2644
- reachedStart = true;
2645
- break;
2646
- }
2647
- }
2648
- let snapPages = 0;
2649
- while (!reachedStart && findBoundaryIndex(buffer) === -1 && snapPages < (options.boundaryPageCap ?? 0)) {
2650
- const page = await loadPreviousPage(client, workspaceId, sessionId, cursor, {
2651
- pageSize: options.pageSize,
2652
- filter: options.filter,
2653
- ...options.signal ? { signal: options.signal } : {}
2654
- });
2655
- if (options.isCurrent?.() === false) throw abortError();
2656
- options.progress?.();
2657
- if (page.raw.oldest === null) {
2658
- reachedStart = true;
2659
- break;
2660
- }
2661
- if (counts(page)) {
2662
- fetches += 1;
2663
- snapPages += 1;
2664
- }
2665
- assertAscending(page);
2666
- buffer = [...page, ...buffer];
2667
- cursor = page.raw.oldest;
2668
- if (page.raw.oldest <= 1 || page[0] !== void 0 && isLogStart(page[0])) {
2669
- reachedStart = true;
2670
- break;
2671
- }
2672
- }
2673
- if (!reachedStart) {
2674
- const boundary = findBoundaryIndex(buffer);
2675
- if (boundary > 0) {
2676
- buffer = buffer.slice(boundary);
2677
- }
2678
- }
2679
- const densityWindow = trimBackwardToGroupTarget(t, buffer, options.targetGroups);
2680
- buffer = densityWindow.events;
2681
- const oldest = buffer[0] ?? null;
2682
- const newest = buffer[buffer.length - 1] ?? null;
2683
- return {
2684
- events: buffer,
2685
- oldestSequence: oldest?.sequence ?? null,
2686
- // A window that kept nothing resumes a live stream above the rows it read,
2687
- // not at the start of history. Otherwise rows dropped above its newest
2688
- // kept row are replayed (or caught up) into their turn's steps, so a
2689
- // working turn's latest tool calls still show.
2690
- newestSequence: newest ? maxResumeSequence(buffer) : rawNewest,
2691
- // An empty window that stopped before the start is still pageable.
2692
- hasOlder: buffer.length > 0 ? densityWindow.trimmed || !reachedStart && oldest?.type !== "session.created" : !reachedStart,
2693
- scanCursor: cursor
2694
- };
2695
- }
2696
- function findBoundaryIndex(events) {
2697
- for (let index = 0; index < events.length; index += 1) {
2698
- if (isTurnBoundary(events[index])) {
2699
- return index;
2700
- }
2701
- }
2702
- return -1;
2703
- }
2704
- function isTurnBoundary(event) {
2705
- return event.type === "session.created" || event.type === "user.message";
2706
- }
2707
- async function loadForwardEventWindow(t, client, workspaceId, sessionId, options) {
2708
- let cursor = options.after;
2709
- let buffer = [];
2710
- let fetches = 0;
2711
- let reachedEnd = false;
2712
- let filteredPages = 0;
2713
- while (fetches < options.maxFetches) {
2714
- if (buffer.length > 0 && groupCount(t, buffer) >= options.targetGroups) {
2715
- break;
2716
- }
2717
- const page = await loadNextPage(client, workspaceId, sessionId, cursor, {
2718
- pageSize: options.pageSize,
2719
- filter: options.filter,
2720
- ...options.signal ? { signal: options.signal } : {}
2721
- });
2722
- if (options.isCurrent?.() === false) throw abortError();
2723
- if (page.raw.newest === null) {
2724
- reachedEnd = true;
2725
- break;
2726
- }
2727
- if (page.length > 0 || (filteredPages += 1) > (options.filteredPageCap ?? 0)) fetches += 1;
2728
- assertAscending(page);
2729
- buffer = [...buffer, ...page];
2730
- cursor = page.raw.newest;
2731
- }
2732
- const densityWindow = trimForwardToGroupTarget(t, buffer, options.targetGroups);
2733
- buffer = densityWindow.events;
2734
- const oldest = buffer[0] ?? null;
2735
- const newest = buffer[buffer.length - 1] ?? null;
2736
- return {
2737
- events: buffer,
2738
- oldestSequence: oldest?.sequence ?? null,
2739
- newestSequence: newest ? maxResumeSequence(buffer) : 0,
2740
- // An empty window that stopped before the end is still pageable.
2741
- hasNewer: buffer.length > 0 ? densityWindow.trimmed || !reachedEnd : !reachedEnd,
2742
- scanCursor: cursor
2743
- };
2744
- }
2745
- function trimBackwardToGroupTarget(t, events, targetGroups) {
2746
- if (!Number.isFinite(targetGroups) || targetGroups <= 0 || events.length === 0) {
2747
- return { events, trimmed: false };
2748
- }
2749
- for (let index = events.length - 1; index > 0; index -= 1) {
2750
- if (!isTurnBoundary(events[index])) continue;
2751
- const candidate = events.slice(index);
2752
- if (groupCount(t, candidate) >= targetGroups) {
2753
- return { events: candidate, trimmed: true };
2754
- }
2755
- }
2756
- return { events, trimmed: false };
2757
- }
2758
- function trimForwardToGroupTarget(t, events, targetGroups) {
2759
- if (!Number.isFinite(targetGroups) || targetGroups <= 0 || events.length === 0) {
2760
- return { events, trimmed: false };
2761
- }
2762
- for (let index = 1; index < events.length; index += 1) {
2763
- if (!isTurnBoundary(events[index])) continue;
2764
- const candidate = events.slice(0, index);
2765
- if (groupCount(t, candidate) >= targetGroups) {
2766
- return { events: candidate, trimmed: true };
2767
- }
2768
- }
2769
- return { events, trimmed: false };
2770
- }
2771
- function rawPageExtent(events) {
2772
- return events.length === 0 ? { oldest: null, newest: null } : { oldest: events[0].sequence, newest: maxResumeSequence(events) };
2773
- }
2774
- function historyPage(events, requested, raw = rawPageExtent(events)) {
2775
- return Object.assign(events, { requested, raw });
2776
- }
2777
- async function loadPreviousPage(client, workspaceId, sessionId, before, options) {
2778
- if (options.signal?.aborted) {
2779
- throw abortError();
2780
- }
2781
- const requested = options.pageSize;
2782
- if (requested === 0) {
2783
- return historyPage([], requested);
2784
- }
2785
- const read = {
2786
- before,
2787
- limit: requested,
2788
- compact: true,
2789
- // Monitoring summaries omit correlation fields once a bounded durable
2790
- // payload exceeds their preview threshold. The browser timeline needs the
2791
- // exact stored payload so persisted tool outputs still match their
2792
- // calls and expose truthful truncation telemetry after a reload.
2793
- payloadMode: "full"
2794
- };
2795
- const page = options.filter ? await readConversationPage(client, workspaceId, sessionId, read) : historyPage(await client.listEvents(workspaceId, sessionId, read), requested);
2796
- if (options.signal?.aborted) {
2797
- throw abortError();
2798
- }
2799
- return Object.assign(page, { requested });
2800
- }
2801
- async function loadNextPage(client, workspaceId, sessionId, after, options) {
2802
- if (options.signal?.aborted) {
2803
- throw abortError();
2804
- }
2805
- const requested = options.pageSize;
2806
- if (requested === 0) {
2807
- return historyPage([], requested);
2808
- }
2809
- const read = {
2810
- ...options.before !== void 0 ? { before: options.before } : {},
2811
- after,
2812
- limit: requested,
2813
- compact: true,
2814
- direction: "after",
2815
- payloadMode: "full"
2816
- };
2817
- const page = options.filter ? await readConversationPage(client, workspaceId, sessionId, read) : historyPage(await client.listEvents(workspaceId, sessionId, read), requested);
2818
- if (options.signal?.aborted) {
2819
- throw abortError();
2820
- }
2821
- return Object.assign(page, { requested });
2822
- }
2823
- function groupCount(t, events) {
2824
- if (events.length === 0) {
2825
- return 0;
2826
- }
2827
- return groupTimeline(t, buildTimeline(t, events)).length;
2828
- }
2829
- function isLogStart(event) {
2830
- return event.type === "session.created" || event.sequence <= 1;
2831
- }
2832
- function maxResumeSequence(events) {
2833
- return events.reduce((max, event) => Math.max(max, eventResumeSequence(event)), 0);
2834
- }
2835
- function maxResumeSequenceOrNull(events) {
2836
- return events.length > 0 ? maxResumeSequence(events) : null;
2837
- }
2838
- function eventResumeSequence(event) {
2839
- const streamedCoverage = sessionEventStreamCoveredThrough(event);
2840
- if (streamedCoverage !== null) return streamedCoverage;
2841
- return typeof event.coveredThrough === "number" && Number.isSafeInteger(event.coveredThrough) && event.coveredThrough >= event.sequence ? event.coveredThrough : event.sequence;
2842
- }
2843
- function assertAscending(events) {
2844
- for (let index = 1; index < events.length; index += 1) {
2845
- if (events[index - 1].sequence >= events[index].sequence) {
2846
- throw new Error("@opengeni/react: session events must be ordered by ascending sequence");
2847
- }
2848
- }
2849
- }
2850
- function assertPrependOrder(existing, older) {
2851
- if (!shouldAssertDevelopment() || existing.length === 0 || older.length === 0) {
2852
- return;
2853
- }
2854
- if (older[older.length - 1].sequence >= existing[0].sequence) {
2855
- throw new Error("@opengeni/react: loadOlder returned overlapping session events");
2856
- }
2857
- }
2858
- function assertAppendOrder(existing, newer) {
2859
- if (!shouldAssertDevelopment() || existing.length === 0 || newer.length === 0) {
2860
- return;
2861
- }
2862
- if (newer[0].sequence <= existing[existing.length - 1].sequence) {
2863
- throw new Error("@opengeni/react: loadNewer returned overlapping session events");
2864
- }
2865
- }
2866
- function shouldAssertDevelopment() {
2867
- const processEnv = globalThis.process?.env;
2868
- return processEnv !== void 0 && processEnv.NODE_ENV !== "production";
2869
- }
2870
- function abortError() {
2871
- const error = new Error("The operation was aborted.");
2872
- error.name = "AbortError";
2873
- return error;
2874
- }
2875
- function abortableDelay(ms, signal) {
2876
- return new Promise((resolve, reject) => {
2877
- if (signal.aborted) {
2878
- reject(abortError());
2879
- return;
2880
- }
2881
- const onAbort = () => {
2882
- clearTimeout(timer);
2883
- reject(abortError());
2884
- };
2885
- const timer = setTimeout(() => {
2886
- signal.removeEventListener("abort", onAbort);
2887
- resolve();
2888
- }, ms);
2889
- signal.addEventListener("abort", onAbort, { once: true });
2890
- });
2891
- }
2892
- var CONTENT_STEP_TYPES = new Set(SESSION_EVENT_CONTENT_STEP_TYPES);
2893
- var COMPAT_EXCLUDED_TYPES = new Set(
2894
- SESSION_EVENT_COMPAT_EXCLUDED_STEP_TYPES
2895
- );
2896
- var CONVERSATION_FILTER = "conversation";
2897
- var SESSION_TURN_STEP_PAGE_SIZE = 200;
2898
- var SESSION_TURN_LIVE_STEP_TAIL = 200;
2899
- var SESSION_TURN_LIVE_STEP_TAIL_BYTES = 2 * 1024 * 1024;
2900
- var TURNLESS_STEP_TAIL = 1e3;
2901
- var TURNLESS_STEP_TAIL_BYTES = 4 * 1024 * 1024;
2902
- var TURN_STEP_READ_TYPES = SESSION_EVENT_STEP_TYPES.filter(
2903
- (type) => type !== "terminal.pty.output.delta"
2904
- );
2905
- var SESSION_STEP_BROWSER_MAX_BYTES = 16 * 1024 * 1024;
2906
- var TERMINAL_TURN_TYPES = /* @__PURE__ */ new Set([
2907
- "turn.completed",
2908
- "turn.failed",
2909
- "turn.cancelled",
2910
- "turn.superseded"
2911
- ]);
2912
- var EMPTY_STEP_STORES = /* @__PURE__ */ new Map();
2913
- var EMPTY_TURNLESS_STEPS = { events: [], bytes: 2, ranges: [], appended: 0 };
2914
- var TURNLESS_STEP_MAX_RANGES = 4096;
2915
- function appendTurnlessSteps(current, incoming) {
2916
- const ranges = current.ranges.map((range) => [range[0], range[1]]);
2917
- for (const event of incoming) {
2918
- const sequence = event.sequence;
2919
- const last = ranges.at(-1);
2920
- if (last && sequence >= last[0] && sequence <= last[1]) continue;
2921
- if (last && sequence === last[1] + 1) last[1] = sequence;
2922
- else if (!last || sequence > last[1]) ranges.push([sequence, sequence]);
2923
- else if (!ranges.some(([first, end]) => sequence >= first && sequence <= end)) {
2924
- ranges.push([sequence, sequence]);
2925
- ranges.sort((left, right) => left[0] - right[0]);
2926
- }
2927
- }
2928
- if (ranges.length > TURNLESS_STEP_MAX_RANGES) {
2929
- ranges.splice(0, ranges.length - TURNLESS_STEP_MAX_RANGES);
2930
- }
2931
- const next = appendStepEvents(current, incoming);
2932
- const appended = current.appended + incoming.length;
2933
- if (next.events.length <= TURNLESS_STEP_TAIL && next.bytes <= TURNLESS_STEP_TAIL_BYTES) {
2934
- return { ...next, ranges, appended };
2935
- }
2936
- const kept = boundBrowserSessionEventWindow(next.events, {
2937
- maxCount: TURNLESS_STEP_TAIL,
2938
- maxBytes: TURNLESS_STEP_TAIL_BYTES
2939
- });
2940
- return { events: kept.events, bytes: kept.bytes, ranges, appended };
2941
- }
2942
- function withTurnlessSteps(window2, turnless) {
2943
- const first = window2[0]?.sequence;
2944
- if (first === void 0 || turnless.ranges.length === 0) return window2;
2945
- const placeholders = [];
2946
- for (const [start, end] of turnless.ranges) {
2947
- if (end < first) continue;
2948
- placeholders.push({
2949
- id: `turnless-steps-${start}`,
2950
- workspaceId: window2[0].workspaceId,
2951
- sessionId: window2[0].sessionId,
2952
- sequence: start,
2953
- coveredThrough: end,
2954
- type: "terminal.pty.output.delta",
2955
- payload: null,
2956
- occurredAt: window2[0].occurredAt,
2957
- turnId: null
2958
- });
2959
- }
2960
- if (placeholders.length === 0) return window2;
2961
- return [...window2, ...placeholders].sort((left, right) => left.sequence - right.sequence);
2962
- }
2963
- function turnStepLowerBound(bounds) {
2964
- return bounds.started !== null ? bounds.started - 1 : bounds.previous;
2965
- }
2966
- function stepStoreHasOlder(store, bounds) {
2967
- return store.hasOlder || store.floor !== null && turnStepLowerBound(bounds) < store.floor;
2968
- }
2969
- function isConversationHistoryEvent(event, presentedCallIds, startupTurns) {
2970
- if (event.turnId) {
2971
- if (event.type === "agent.model.usage") return startupTurns === void 0;
2972
- if (event.type === "agent.model.request") {
2973
- return startupTurns === void 0 || startupTurns.has(event.turnId);
2974
- }
2975
- }
2976
- if (!CONTENT_STEP_TYPES.has(event.type)) return true;
2977
- const payload = event.payload;
2978
- if (event.type === "agent.toolCall.created") return isPresentedSessionToolCall(payload);
2979
- if (event.type === "agent.toolCall.output") {
2980
- return typeof payload?.id === "string" && presentedCallIds.has(payload.id);
2981
- }
2982
- return false;
2983
- }
2984
- function emptyStartupTurns() {
2985
- return { window: null, open: /* @__PURE__ */ new Set(), responded: /* @__PURE__ */ new Set() };
2986
- }
2987
- function noteStartupTurns(events, state) {
2988
- for (const event of events) {
2989
- const turnId = event.turnId;
2990
- if (!turnId) continue;
2991
- if (event.type === "turn.started") {
2992
- if (!state.responded.has(turnId)) state.open.add(turnId);
2993
- } else if (event.type === "agent.model.request" && isSessionModelResponsePhase(event.payload?.phase)) {
2994
- state.open.delete(turnId);
2995
- state.responded.add(turnId);
2996
- }
2997
- }
2998
- }
2999
- var conversationFilterModes = /* @__PURE__ */ new WeakMap();
3000
- var CONVERSATION_READS = {
3001
- v2: { excludeTypes: [...SESSION_EVENT_STEP_TYPES], presentedToolCalls: "include" },
3002
- compat: {
3003
- excludeTypes: [...SESSION_EVENT_COMPAT_EXCLUDED_STEP_TYPES],
3004
- presentedToolCalls: "include"
3005
- }
3006
- };
3007
- function conversationFilterMode(client) {
3008
- if (typeof client.listEventPage !== "function") {
3009
- return "compat";
3010
- }
3011
- return conversationFilterModes.get(client) ?? "v2";
3012
- }
3013
- async function readConversationPage(client, workspaceId, sessionId, options) {
3014
- let mode = conversationFilterMode(client);
3015
- for (; ; ) {
3016
- const read = await readEventPage(client, workspaceId, sessionId, {
3017
- ...CONVERSATION_READS[mode],
3018
- ...options
3019
- });
3020
- const announced = (read.conversationFilter ?? 0) >= SESSION_EVENT_CONVERSATION_FILTER_VERSION;
3021
- if (read.conversationFilter !== void 0) {
3022
- conversationFilterModes.set(client, announced ? "v2" : "compat");
3023
- }
3024
- if (mode === "v2" && !announced) {
3025
- mode = "compat";
3026
- continue;
3027
- }
3028
- const events = mode === "compat" ? read.events.filter(isCompatConversationEvent) : read.events;
3029
- return Object.assign(events === read.events ? [...events] : events, {
3030
- requested: options.limit,
3031
- raw: rawPageExtent(read.events),
3032
- hasMore: read.hasMore
3033
- });
3034
- }
3035
- }
3036
- function isCompatConversationEvent(event) {
3037
- if (COMPAT_EXCLUDED_TYPES.has(event.type)) return false;
3038
- if (event.type !== "agent.toolCall.created") return true;
3039
- return isPresentedSessionToolCall(event.payload);
3040
- }
3041
- function notePresentedCalls(events, ids) {
3042
- for (const event of events) {
3043
- if (event.type !== "agent.toolCall.created") continue;
3044
- const payload = event.payload;
3045
- if (typeof payload?.id === "string" && isPresentedSessionToolCall(payload)) {
3046
- ids.add(payload.id);
3047
- }
3048
- }
3049
- }
3050
- function conversationTurnBounds(events) {
3051
- const bounds = /* @__PURE__ */ new Map();
3052
- const gaps = [];
3053
- let expected = null;
3054
- let previous = 0;
3055
- for (const event of events) {
3056
- if (expected !== null && event.sequence > expected) gaps.push(expected);
3057
- const resume = eventResumeSequence(event);
3058
- expected = Math.max(expected ?? 0, resume + 1);
3059
- const turnId = event.turnId;
3060
- if (!turnId) continue;
3061
- const current = bounds.get(turnId);
3062
- if (!current) {
3063
- bounds.set(turnId, {
3064
- first: event.sequence,
3065
- started: event.type === "turn.started" ? event.sequence : null,
3066
- previous,
3067
- last: resume,
3068
- terminal: TERMINAL_TURN_TYPES.has(event.type) ? event.sequence : null,
3069
- hidden: false
3070
- });
3071
- } else {
3072
- current.last = Math.max(current.last, resume);
3073
- if (event.type === "turn.started" && current.started === null) {
3074
- current.started = event.sequence;
3075
- }
3076
- if (TERMINAL_TURN_TYPES.has(event.type)) current.terminal = event.sequence;
3077
- }
3078
- if (!PRE_START_TURN_TYPES.has(event.type)) previous = resume;
3079
- }
3080
- for (const turn of bounds.values()) {
3081
- let low = 0;
3082
- let high = gaps.length;
3083
- while (low < high) {
3084
- const middle = low + high >> 1;
3085
- if (gaps[middle] <= turn.first) low = middle + 1;
3086
- else high = middle;
3087
- }
3088
- turn.hidden = low < gaps.length && gaps[low] < turn.last;
3089
- }
3090
- return bounds;
3091
- }
3092
- function activeConversationTurn(events) {
3093
- for (let index = events.length - 1; index >= 0; index -= 1) {
3094
- const event = events[index];
3095
- if (!event.turnId) continue;
3096
- if (TERMINAL_TURN_TYPES.has(event.type)) return null;
3097
- if (event.type === "turn.started") return event.turnId;
3098
- }
3099
- return null;
3100
- }
3101
- function settledTurns(events) {
3102
- const settled = /* @__PURE__ */ new Set();
3103
- for (const event of events) {
3104
- if (event.turnId && TERMINAL_TURN_TYPES.has(event.type)) settled.add(event.turnId);
3105
- }
3106
- return settled;
3107
- }
3108
- function windowTurns(events) {
3109
- const turns = /* @__PURE__ */ new Set();
3110
- for (const event of events) if (event.turnId) turns.add(event.turnId);
3111
- return turns;
3112
- }
3113
- var EMPTY_PRESENTED_OUTPUTS = /* @__PURE__ */ new Map();
3114
- var PRE_START_TURN_TYPES = /* @__PURE__ */ new Set(["turn.queued", "turn.capacity_waiting"]);
3115
- var PRESENTED_OUTPUT_READS_PER_PASS = 8;
3116
- var PRESENTED_OUTPUT_PAGE_SIZE = 16;
3117
- var PRESENTED_OUTPUT_MAX_PAGES = 16;
3118
- var PRESENTED_OUTPUT_RETRIES = 3;
3119
- var PRESENTED_OUTPUT_RETRY_MS = 2e3;
3120
- var RETAINED_VIEW_STEPS = {
3121
- load: () => {
3122
- },
3123
- retain: () => () => {
3124
- }
3125
- };
3126
- function mergeLoadedEvents(conversation, stores, presented, turnless, exactOutputs = EMPTY_PRESENTED_OUTPUTS) {
3127
- if (stores.size === 0 && presented.size === 0 && turnless.length === 0 && exactOutputs.size === 0) {
3128
- return conversation;
3129
- }
3130
- const turns = windowTurns(conversation);
3131
- const ids = new Set(conversation.map((event) => event.id));
3132
- const extra = [];
3133
- const add = (event) => {
3134
- if (ids.has(event.id) || !event.turnId || !turns.has(event.turnId)) return;
3135
- ids.add(event.id);
3136
- extra.push(event);
3137
- };
3138
- presented.forEach(add);
3139
- exactOutputs.forEach(add);
3140
- for (const [turnId, store] of stores) if (turns.has(turnId)) store.events.forEach(add);
3141
- for (const event of turnless) {
3142
- if (ids.has(event.id)) continue;
3143
- ids.add(event.id);
3144
- extra.push(event);
3145
- }
3146
- if (extra.length === 0) return conversation;
3147
- return [...conversation, ...extra].sort((left, right) => left.sequence - right.sequence);
3148
- }
3149
- function groupByTurn(events) {
3150
- const turns = /* @__PURE__ */ new Map();
3151
- for (const event of events) {
3152
- if (!event.turnId) continue;
3153
- const list = turns.get(event.turnId);
3154
- if (list) list.push(event);
3155
- else turns.set(event.turnId, [event]);
3156
- }
3157
- return turns;
3158
- }
3159
- function appendStepEvents(store, incoming) {
3160
- if (incoming.length === 0) return { events: store.events, bytes: store.bytes };
3161
- const ids = new Set(store.events.map((event) => event.id));
3162
- let bytes = store.bytes;
3163
- const fresh = [];
3164
- for (const event of incoming) {
3165
- if (ids.has(event.id)) continue;
3166
- ids.add(event.id);
3167
- fresh.push(event);
3168
- bytes += browserJsonBytes(event) + (store.events.length + fresh.length > 1 ? 1 : 0);
3169
- }
3170
- if (fresh.length === 0) return { events: store.events, bytes: store.bytes };
3171
- const last = store.events[store.events.length - 1];
3172
- const events = [...store.events, ...fresh];
3173
- if (last && fresh.some((event) => event.sequence < last.sequence)) {
3174
- events.sort((left, right) => left.sequence - right.sequence);
3175
- } else if (!last) {
3176
- events.sort((left, right) => left.sequence - right.sequence);
3177
- }
3178
- return { events, bytes };
3179
- }
3180
- function turnHasHiddenSequences(events, turnId, before) {
3181
- const start = events.findIndex((event) => event.turnId === turnId);
3182
- if (start < 0) return true;
3183
- let expected = eventResumeSequence(events[start]) + 1;
3184
- for (let index = start + 1; index < events.length; index += 1) {
3185
- const event = events[index];
3186
- if (event.sequence >= before) break;
3187
- if (event.sequence > expected) return true;
3188
- expected = Math.max(expected, eventResumeSequence(event) + 1);
3189
- }
3190
- return expected < before;
3191
- }
3192
- function trimLiveStepTail(store) {
3193
- if (store.events.length <= SESSION_TURN_LIVE_STEP_TAIL && store.bytes <= SESSION_TURN_LIVE_STEP_TAIL_BYTES) {
3194
- return store;
3195
- }
3196
- const kept = boundBrowserSessionEventWindow(store.events, {
3197
- maxCount: SESSION_TURN_LIVE_STEP_TAIL,
3198
- maxBytes: SESSION_TURN_LIVE_STEP_TAIL_BYTES
3199
- });
3200
- return { ...store, events: kept.events, bytes: kept.bytes, hasOlder: true, cursor: null };
3201
- }
3202
- function boundStepStores(stores, retained) {
3203
- let total = 0;
3204
- for (const [turnId, store] of stores) {
3205
- if (!retained.get(turnId)) total += store.bytes;
3206
- }
3207
- if (total <= SESSION_STEP_BROWSER_MAX_BYTES) return stores;
3208
- const candidates = [...stores].filter(([turnId, store]) => !retained.get(turnId) && !store.loading).sort((left, right) => left[1].touched - right[1].touched);
3209
- for (const [turnId, store] of candidates) {
3210
- if (total <= SESSION_STEP_BROWSER_MAX_BYTES) break;
3211
- stores.delete(turnId);
3212
- total -= store.bytes;
3213
- }
3214
- return stores;
3215
- }
3216
- async function findPresentedOutput(client, workspaceId, sessionId, callId, after, terminal) {
3217
- let cursor = after;
3218
- for (let page = 0; page < PRESENTED_OUTPUT_MAX_PAGES; page += 1) {
3219
- const read = await readEventPage(client, workspaceId, sessionId, {
3220
- includeTypes: ["agent.toolCall.output"],
3221
- after: cursor,
3222
- ...terminal !== null ? { before: terminal + 1 } : {},
3223
- direction: "after",
3224
- limit: PRESENTED_OUTPUT_PAGE_SIZE,
3225
- payloadMode: "full"
3226
- });
3227
- const output = read.events.find(
3228
- (event) => event.payload?.id === callId
3229
- );
3230
- if (output) return output;
3231
- const last = read.events.at(-1);
3232
- if (!last || !(read.hasMore ?? read.events.length >= PRESENTED_OUTPUT_PAGE_SIZE)) return null;
3233
- cursor = last.sequence;
3234
- }
3235
- return null;
3236
- }
3237
- async function readEventPage(client, workspaceId, sessionId, options) {
3238
- const pageClient = client;
3239
- if (typeof pageClient.listEventPage === "function") {
3240
- const page = await pageClient.listEventPage(workspaceId, sessionId, options);
3241
- return {
3242
- events: page.events,
3243
- hasMore: page.hasMore,
3244
- // An SDK that predates the announcement reports nothing: treat it as none.
3245
- conversationFilter: page.conversationFilter ?? null
3246
- };
3247
- }
3248
- return { events: await client.listEvents(workspaceId, sessionId, options), hasMore: null };
3249
- }
3250
-
3251
- // src/hooks/use-turn-queue.ts
3252
- import { isTransientRequestError as isTransientRequestError2 } from "@opengeni/sdk";
3253
- import { useCallback as useCallback7, useEffect as useEffect4, useLayoutEffect as useLayoutEffect2, useMemo as useMemo3, useRef as useRef6, useState as useState4 } from "react";
3254
- function isTurnQueueEvent(event) {
3255
- return event.type.startsWith("turn.") || event.type.startsWith("session.queue.") || event.type.startsWith("session.control.") || event.type.startsWith("system.update.") || event.type.startsWith("workspace.inference.");
3256
- }
3257
- function queueSnapshotCovers(candidate, observed) {
3258
- return Boolean(
3259
- candidate && candidate.version >= observed.version && candidate.effectiveControl.controlVersion >= observed.effectiveControl.controlVersion
3260
- );
3261
- }
3262
- var EMPTY_PENDING_BY_TURN = {};
3263
- function useTurnQueue(sessionId, options = {}) {
3264
- const t = useOpenGeniText();
3265
- const { client, workspaceId, workspaceControlEvent, registerSessionReconciler } = useEmbeddedSession(options);
3266
- const enabled = (options.enabled ?? true) && Boolean(sessionId);
3267
- const targetKey = `${workspaceId}\0${sessionId ?? ""}`;
3268
- const pageLive = usePageLiveActivity();
3269
- const pageLiveRef = useRef6(pageLive);
3270
- pageLiveRef.current = pageLive;
3271
- const [snapshot, setSnapshot] = useState4(null);
3272
- const [stateTargetKey, setStateTargetKey] = useState4(targetKey);
3273
- const [loading, setLoading] = useState4(enabled);
3274
- const [error, setError] = useState4(null);
3275
- const [mutationError, setMutationError] = useState4(null);
3276
- const [pendingByTurn, setPendingByTurn] = useState4({});
3277
- const [acceptedSteers, setAcceptedSteers] = useState4([]);
3278
- const pendingRef = useRef6({});
3279
- const readGeneration = useRef6(0);
3280
- const targetKeyRef = useRef6(targetKey);
3281
- const snapshotRef = useRef6(null);
3282
- const transientStreakRef = useRef6(
3283
- null
3284
- );
3285
- const transientRetryTimerRef = useRef6(null);
3286
- const cancelTransientRetry = useCallback7(() => {
3287
- if (transientRetryTimerRef.current !== null) {
3288
- clearTimeout(transientRetryTimerRef.current);
3289
- transientRetryTimerRef.current = null;
3290
- }
3291
- }, []);
3292
- useLayoutEffect2(() => {
3293
- if (targetKeyRef.current === targetKey) return;
3294
- targetKeyRef.current = targetKey;
3295
- readGeneration.current += 1;
3296
- snapshotRef.current = null;
3297
- pendingRef.current = {};
3298
- setStateTargetKey(targetKey);
3299
- setSnapshot(null);
3300
- setLoading(enabled);
3301
- setError(null);
3302
- transientStreakRef.current = null;
3303
- cancelTransientRetry();
3304
- setMutationError(null);
3305
- setPendingByTurn({});
3306
- setAcceptedSteers([]);
3307
- }, [cancelTransientRetry, enabled, targetKey]);
3308
- useEffect4(() => {
3309
- if (acceptedSteers.length === 0 || options.events === void 0) return;
3310
- const durablyConsumedTurnIds = new Set(
3311
- options.events.flatMap(
3312
- (event) => [
3313
- "turn.started",
3314
- "turn.superseded",
3315
- "turn.cancelled",
3316
- "turn.failed",
3317
- "turn.completed"
3318
- ].includes(event.type) && event.turnId ? [event.turnId] : []
3319
- )
3320
- );
3321
- if (durablyConsumedTurnIds.size === 0) return;
3322
- setAcceptedSteers(
3323
- (current) => current.filter((steer) => !durablyConsumedTurnIds.has(steer.turnId))
3324
- );
3325
- }, [acceptedSteers.length, options.events]);
3326
- const acceptSnapshot = useCallback7(
3327
- (ownedTargetKey, next) => {
3328
- if (targetKeyRef.current !== ownedTargetKey) return false;
3329
- const current = snapshotRef.current;
3330
- if (next && current && (next.version < current.version || next.effectiveControl.controlVersion < current.effectiveControl.controlVersion)) {
3331
- return false;
3332
- }
3333
- snapshotRef.current = next;
3334
- setStateTargetKey(ownedTargetKey);
3335
- setSnapshot(next);
3336
- return true;
3337
- },
3338
- []
3339
- );
3340
- const load = useCallback7(
3341
- async (rejectOnFailure = false, fresh = false) => {
3342
- if (!sessionId) return;
3343
- const ownedTargetKey = `${workspaceId}\0${sessionId}`;
3344
- const ticket = ++readGeneration.current;
3345
- try {
3346
- const fetched = fresh ? await client.getQueue(workspaceId, sessionId, { fresh: true }) : await client.getQueue(workspaceId, sessionId);
3347
- if (targetKeyRef.current !== ownedTargetKey) return;
3348
- transientStreakRef.current = null;
3349
- cancelTransientRetry();
3350
- const ownsLatestRead = ticket === readGeneration.current;
3351
- if (rejectOnFailure) {
3352
- const committed = acceptSnapshot(ownedTargetKey, fetched);
3353
- if (!committed && !queueSnapshotCovers(snapshotRef.current, fetched)) {
3354
- throw new TypeError("Queue reconciliation did not commit authoritative state");
3355
- }
3356
- setError(null);
3357
- if (ownsLatestRead) setLoading(false);
3358
- } else if (ownsLatestRead) {
3359
- acceptSnapshot(ownedTargetKey, fetched);
3360
- setError(null);
3361
- setLoading(false);
3362
- }
3363
- } catch (cause) {
3364
- if (targetKeyRef.current === ownedTargetKey && (ticket === readGeneration.current || rejectOnFailure)) {
3365
- if (isTransientRequestError2(cause)) {
3366
- const now = Date.now();
3367
- const streak = transientStreakRef.current ??= {
3368
- since: now,
3369
- attempts: 0,
3370
- surfaced: false
3371
- };
3372
- const step = transientReadRetryStep(streak, now, DEFAULT_TRANSIENT_READ_RETRY, cause);
3373
- if (!step.quiet) {
3374
- if (!streak.surfaced) setError(asError(cause));
3375
- streak.surfaced = true;
3376
- if (ticket === readGeneration.current) setLoading(false);
3377
- }
3378
- if (!rejectOnFailure && pageLiveRef.current) {
3379
- cancelTransientRetry();
3380
- transientRetryTimerRef.current = setTimeout(() => {
3381
- transientRetryTimerRef.current = null;
3382
- if (targetKeyRef.current === ownedTargetKey) void loadRef.current(false, fresh);
3383
- }, step.delayMs);
3384
- }
3385
- } else {
3386
- transientStreakRef.current = null;
3387
- setError(asError(cause));
3388
- if (ticket === readGeneration.current) setLoading(false);
3389
- }
3390
- }
3391
- if (rejectOnFailure) throw cause;
3392
- }
3393
- },
3394
- [client, workspaceId, sessionId, acceptSnapshot, cancelTransientRetry]
3395
- );
3396
- const loadRef = useRef6(load);
3397
- loadRef.current = load;
3398
- useEffect4(() => cancelTransientRetry, [cancelTransientRetry]);
3399
- useEffect4(() => {
3400
- if (!enabled || !pageLive) {
3401
- cancelTransientRetry();
3402
- setLoading(false);
3403
- return;
3404
- }
3405
- setLoading(true);
3406
- const pollIntervalMs = options.pollIntervalMs;
3407
- if (pollIntervalMs === void 0 || pollIntervalMs <= 0) {
3408
- void load();
3409
- return () => {
3410
- readGeneration.current += 1;
3411
- };
3412
- }
3413
- let cancelled = false;
3414
- let timer = null;
3415
- const schedule = () => {
3416
- if (cancelled) return;
3417
- timer = setTimeout(() => {
3418
- timer = null;
3419
- void load().finally(schedule);
3420
- }, pollIntervalMs);
3421
- };
3422
- void load().finally(schedule);
3423
- return () => {
3424
- cancelled = true;
3425
- if (timer !== null) clearTimeout(timer);
3426
- readGeneration.current += 1;
3427
- };
3428
- }, [cancelTransientRetry, load, enabled, pageLive, options.pollIntervalMs]);
3429
- const loadFresh = useCallback7(() => load(false, true), [load]);
3430
- useEffect4(() => {
3431
- if (enabled && workspaceControlEvent) void loadFresh();
3432
- }, [enabled, loadFresh, workspaceControlEvent]);
3433
- useEffect4(() => {
3434
- if (!sessionId || !enabled) return;
3435
- return registerSessionReconciler(sessionId, "queue", loadFresh);
3436
- }, [enabled, loadFresh, registerSessionReconciler, sessionId]);
3437
- const scheduleRefresh = useDebouncedCallback(() => void loadFresh());
3438
- const freshSnapshot = stateTargetKey === targetKey ? snapshot : null;
3439
- const freshLoading = stateTargetKey === targetKey ? loading : enabled;
3440
- useSessionEventTrigger(
3441
- client,
3442
- workspaceId,
3443
- sessionId,
3444
- isTurnQueueEvent,
3445
- scheduleRefresh,
3446
- {
3447
- enabled,
3448
- ...options.events !== void 0 ? { events: options.events } : {},
3449
- readThrough: projectionReadThrough(freshSnapshot, freshLoading),
3450
- refresh: scheduleRefresh
3451
- },
3452
- async () => await load(true, true)
3453
- );
3454
- const retainedSnapshot = useRetainedSessionView(
3455
- client,
3456
- workspaceId,
3457
- sessionId,
3458
- "queue",
3459
- freshSnapshot,
3460
- { enabled, discard: stateTargetKey === targetKey && deniesRetainedView(error) }
3461
- );
3462
- const mutate = useCallback7(
3463
- async (turnId, kind, command, failure = {}) => {
3464
- const ownedTargetKey = targetKey;
3465
- if (!sessionId || targetKeyRef.current !== ownedTargetKey || pendingRef.current[turnId]) {
3466
- return null;
3467
- }
3468
- const current = snapshotRef.current;
3469
- const turn = current?.items.find((candidate) => candidate.id === turnId);
3470
- if (!current || !turn) return null;
3471
- pendingRef.current = { ...pendingRef.current, [turnId]: kind };
3472
- setStateTargetKey(ownedTargetKey);
3473
- setPendingByTurn(pendingRef.current);
3474
- setMutationError(null);
3475
- const clientEventId = operationKey();
3476
- try {
3477
- let result;
3478
- try {
3479
- result = await command(current, turn, clientEventId);
3480
- } catch (cause) {
3481
- if (!isOutcomeUnknownError(cause)) throw cause;
3482
- result = await command(current, turn, clientEventId);
3483
- }
3484
- if (targetKeyRef.current !== ownedTargetKey) return null;
3485
- acceptSnapshot(ownedTargetKey, result.snapshot);
3486
- return result;
3487
- } catch (cause) {
3488
- if (targetKeyRef.current === ownedTargetKey) {
3489
- if (failure.quietWhenGone) {
3490
- await loadFresh();
3491
- const stillWaiting = snapshotRef.current?.items.some(
3492
- (candidate) => candidate.id === turnId
3493
- );
3494
- if (stillWaiting !== false && targetKeyRef.current === ownedTargetKey) {
3495
- setMutationError(asError(cause));
3496
- }
3497
- } else {
3498
- setMutationError(asError(cause));
3499
- await loadFresh();
3500
- }
3501
- }
3502
- return null;
3503
- } finally {
3504
- if (targetKeyRef.current === ownedTargetKey && turnId in pendingRef.current) {
3505
- const next = { ...pendingRef.current };
3506
- delete next[turnId];
3507
- pendingRef.current = next;
3508
- setPendingByTurn(next);
3509
- }
3510
- }
3511
- },
3512
- [acceptSnapshot, loadFresh, sessionId, targetKey]
3513
- );
3514
- const moveTurn = useCallback7(
3515
- async (turnId, beforeTurnId) => {
3516
- const result = await mutate(
3517
- turnId,
3518
- "move",
3519
- (current, _turn, clientEventId) => client.moveQueueItem(workspaceId, sessionId, turnId, {
3520
- clientEventId,
3521
- expectedQueueVersion: current.version,
3522
- beforeTurnId
3523
- })
3524
- );
3525
- return result !== null;
3526
- },
3527
- [client, mutate, sessionId, workspaceId]
3528
- );
3529
- const editTurn = useCallback7(
3530
- async (turnId, edit) => {
3531
- const result = await mutate(
3532
- turnId,
3533
- "edit",
3534
- (_current, turn, clientEventId) => client.editQueueItem(workspaceId, sessionId, turnId, {
3535
- clientEventId,
3536
- expectedTurnVersion: turn.version,
3537
- expectedDraftRevision: edit.expectedDraftRevision,
3538
- replaceDraft: edit.replaceDraft
3539
- })
3540
- );
3541
- return result?.draft ?? null;
3542
- },
3543
- [client, mutate, sessionId, workspaceId]
3544
- );
3545
- const recallTurn = useCallback7(
3546
- async (turnId, recall) => {
3547
- const ownedTargetKey = targetKey;
3548
- const known = snapshotRef.current?.items.some((candidate) => candidate.id === turnId);
3549
- if (known === false) return { status: "already_sent" };
3550
- const result = await mutate(
3551
- turnId,
3552
- "edit",
3553
- (_current, turn, clientEventId) => client.editQueueItem(workspaceId, sessionId, turnId, {
3554
- clientEventId,
3555
- expectedTurnVersion: turn.version,
3556
- expectedDraftRevision: recall.expectedDraftRevision,
3557
- replaceDraft: false
3558
- }),
3559
- { quietWhenGone: true }
3560
- );
3561
- if (targetKeyRef.current !== ownedTargetKey) return { status: "failed" };
3562
- if (result?.draft) return { status: "recalled", draft: result.draft };
3563
- const stillWaiting = snapshotRef.current?.items.some((candidate) => candidate.id === turnId);
3564
- return result === null && stillWaiting === false ? { status: "already_sent" } : { status: "failed" };
3565
- },
3566
- [client, mutate, sessionId, targetKey, workspaceId]
3567
- );
3568
- const steerTurn = useCallback7(
3569
- async (turnId) => {
3570
- const ownedTargetKey = targetKey;
3571
- const turn = snapshotRef.current?.items.find((candidate) => candidate.id === turnId);
3572
- if (targetKeyRef.current !== ownedTargetKey) return false;
3573
- if (!turn) {
3574
- setMutationError(new Error(t("hooks.useTurnQueue.thatQueuedPromptChangedBefore")));
3575
- await loadFresh();
3576
- return false;
3577
- }
3578
- const optimistic = {
3579
- turnId: turn.id,
3580
- triggerEventId: turn.triggerEventId,
3581
- text: turn.prompt,
3582
- annotations: turn.annotations ?? [],
3583
- resources: turn.resources,
3584
- tools: turn.tools,
3585
- occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
3586
- state: "sending"
3587
- };
3588
- setAcceptedSteers((current) => [
3589
- ...current.filter((steer) => steer.turnId !== turnId),
3590
- optimistic
3591
- ]);
3592
- const result = await mutate(
3593
- turnId,
3594
- "steer",
3595
- (current, queuedTurn, clientEventId) => client.steerQueueItem(workspaceId, sessionId, turnId, {
3596
- clientEventId,
3597
- expectedTurnVersion: queuedTurn.version,
3598
- controlEtag: current.effectiveControl.controlEtag
3599
- })
3600
- );
3601
- if (targetKeyRef.current !== ownedTargetKey) return false;
3602
- const advancedWithoutSteer = result === null && snapshotRef.current !== null && !snapshotRef.current.items.some((candidate) => candidate.id === turnId);
3603
- if (advancedWithoutSteer) {
3604
- setMutationError(null);
3605
- setAcceptedSteers((current) => current.filter((steer) => steer.turnId !== turnId));
3606
- return true;
3607
- }
3608
- const accepted = result !== null || snapshotRef.current?.items.some(
3609
- (candidate) => candidate.id === turnId && candidate.metadata.delivery === "steer"
3610
- ) === true;
3611
- setAcceptedSteers(
3612
- (current) => accepted ? current.map(
3613
- (steer) => steer.turnId === turnId ? { ...steer, state: "queued" } : steer
3614
- ) : current.filter((steer) => steer.turnId !== turnId)
3615
- );
3616
- return accepted;
3617
- },
3618
- [client, loadFresh, mutate, sessionId, targetKey, workspaceId, t]
3619
- );
3620
- const removeTurn = useCallback7(
3621
- async (turnId) => {
3622
- const result = await mutate(
3623
- turnId,
3624
- "delete",
3625
- (_current, turn, clientEventId) => client.deleteQueueItem(workspaceId, sessionId, turnId, {
3626
- clientEventId,
3627
- expectedTurnVersion: turn.version,
3628
- reason: "Deleted from the prompt queue"
3629
- })
3630
- );
3631
- return result !== null;
3632
- },
3633
- [client, mutate, sessionId, workspaceId]
3634
- );
3635
- const identityMatches = stateTargetKey === targetKey;
3636
- const visibleSnapshot = freshSnapshot ?? retainedSnapshot;
3637
- const visiblePendingByTurn = identityMatches ? pendingByTurn : EMPTY_PENDING_BY_TURN;
3638
- const mutating = useMemo3(
3639
- () => Object.keys(visiblePendingByTurn).length > 0,
3640
- [visiblePendingByTurn]
3641
- );
3642
- const mutationFor = useCallback7(
3643
- (turnId) => visiblePendingByTurn[turnId] ?? null,
3644
- [visiblePendingByTurn]
3645
- );
3646
- return {
3647
- snapshot: visibleSnapshot,
3648
- queue: visibleSnapshot?.items ?? [],
3649
- pendingInputs: visibleSnapshot?.pendingInputs ?? [],
3650
- pendingInputAttachment: visibleSnapshot?.pendingInputAttachment ?? null,
3651
- activePersonalConnections: visibleSnapshot?.activePersonalConnections ?? [],
3652
- effectiveControl: visibleSnapshot?.effectiveControl ?? null,
3653
- stoppingPreviousAttempt: visibleSnapshot?.stoppingPreviousAttempt ?? false,
3654
- loading: freshLoading && retainedSnapshot === null,
3655
- error: identityMatches ? error : null,
3656
- refresh: load,
3657
- moveTurn,
3658
- editTurn,
3659
- recallTurn,
3660
- steerTurn,
3661
- removeTurn,
3662
- pendingByTurn: visiblePendingByTurn,
3663
- mutationFor,
3664
- mutating,
3665
- mutationError: identityMatches ? mutationError : null,
3666
- clearMutationError: useCallback7(() => {
3667
- if (targetKeyRef.current === targetKey) setMutationError(null);
3668
- }, [targetKey]),
3669
- acceptedSteers: identityMatches ? acceptedSteers : []
3670
- };
3671
- }
3672
- function operationKey() {
3673
- return globalThis.crypto.randomUUID();
3674
- }
3675
- function asError(cause) {
3676
- return normalizeError(cause);
3677
- }
3678
- function isOutcomeUnknownError(cause) {
3679
- return typeof cause === "object" && cause !== null && cause.outcomeUnknown === true;
3680
- }
3681
-
3682
- // src/hooks/use-session-conversation.ts
3683
- import { useLayoutEffect as useLayoutEffect3, useMemo as useMemo4, useRef as useRef7, useState as useState5 } from "react";
3684
- function useSessionConversation(sessionId, options = {}) {
3685
- const [initialPrompt] = useState5(() => options.pendingPrompt ?? null);
3686
- const context = useOpenGeni(options);
3687
- const scope = { client: context.client, workspaceId: context.workspaceId };
3688
- const config = useClientConfigFlags(context.client);
3689
- const showModelPicker = options.modelPicker ?? config.modelSelection;
3690
- const catalog = useWorkspaceModelCatalog({ ...scope, enabled: showModelPicker });
3691
- const feed = useSessionEvents(sessionId, scope);
3692
- const pendingPrompt = usePendingPrompt(initialPrompt, sessionId, feed.initialHistoryReady);
3693
- const eventOptions = { ...scope, events: feed.events };
3694
- const detail = useSession(sessionId, eventOptions);
3695
- const queue = useTurnQueue(sessionId, eventOptions);
3696
- const human = useHumanInputRequests(sessionId, eventOptions);
3697
- const control = useSessionControl(sessionId, scope);
3698
- const approvals = useMemo4(() => projectPendingApprovals(feed.events), [feed.events]);
3699
- const files = useFileAttachments({ ...scope, scope: uploadScopeForSession(detail.session) });
3700
- const clearFiles = files.clear;
3701
- const attachmentSession = useRef7(sessionId);
3702
- useLayoutEffect3(() => {
3703
- if (attachmentSession.current === sessionId) return;
3704
- const created = attachmentSession.current === null;
3705
- attachmentSession.current = sessionId;
3706
- if (created) return;
3707
- clearFiles();
3708
- }, [clearFiles, sessionId]);
3709
- const uploadsEnabled = (options.attachments ?? true) && config.uploads;
3710
- const status = feed.sessionStatus ?? detail.session?.status;
3711
- const terminal = status === "cancelled" || (detail.session ? sessionArchived(detail.session) : false);
3712
- const importedArchive = detail.session?.importedArchive?.readOnly === true;
3713
- const host = options.composerOptions;
3714
- const resolveExtras = () => typeof host?.sendExtras === "function" ? host.sendExtras() : host?.sendExtras;
3715
- const releaseSentFiles = (input) => files.removeReadyFiles(
3716
- (input.resources ?? []).flatMap(
3717
- (resource) => resource.kind === "file" ? [resource.fileId] : []
3718
- )
3719
- );
3720
- const composer = useComposer(sessionId, {
3721
- ...eventOptions,
3722
- initialDraft: host?.initialDraft,
3723
- busySend: host?.busySend,
3724
- offerQueue: host?.offerQueue,
3725
- effectiveControl: queue.effectiveControl ?? detail.session?.effectiveControl,
3726
- // As in the console and the native screen: a turn that is still current
3727
- // (running or recovering) means a Send waits. A turn parked on provider
3728
- // capacity does not: the Send replaces it and starts right away.
3729
- sendDestination: () => promptSendDestination({
3730
- status,
3731
- activeTurnId: detail.session?.activeTurnId,
3732
- queuedPrompts: queue.queue.length,
3733
- admissionBlock: detail.session?.admissionBlock
3734
- }),
3735
- sendExtras: () => {
3736
- const extras = resolveExtras();
3737
- return {
3738
- ...extras,
3739
- resources: [...extras?.resources ?? [], ...uploadsEnabled ? files.readyResources : []]
3740
- };
3741
- },
3742
- sendBlocked: () => sessionId === null || terminal || importedArchive || uploadsEnabled && files.hasUnresolved || host?.sendBlocked?.() === true,
3743
- onSubmitted: (text, input) => {
3744
- releaseSentFiles(input);
3745
- return host?.onSubmitted?.(text, input);
3746
- },
3747
- onSent: (text, input) => {
3748
- releaseSentFiles(input);
3749
- return host?.onSent?.(text, input);
3750
- },
3751
- onDeliveryError: host?.onDeliveryError
3752
- });
3753
- const conversation = useMemo4(
3754
- () => conversationTimeline(feed.timeline, queue, composer),
3755
- [feed.timeline, queue, composer]
3756
- );
3757
- const session = detail.session;
3758
- const sessionControl = session?.effectiveControl;
3759
- const timeline = useSessionStartupTimeline(conversation, {
3760
- session: session && sessionControl ? {
3761
- ...session,
3762
- effectiveControl: admissionRecheckControl(
3763
- sessionControl,
3764
- queue.effectiveControl,
3765
- composer.effectiveControl
3766
- )
3767
- } : null,
3768
- events: feed.events,
3769
- optimisticMessages: composer.optimisticMessages,
3770
- hasNewer: feed.hasNewer,
3771
- queue: queue.snapshot,
3772
- pendingPrompt,
3773
- historyReady: sessionId !== null && feed.initialHistoryReady
3774
- });
3775
- const error = detail.error ?? feed.error ?? human.error;
3776
- const loadFailed = Boolean(feed.error) && !feed.initialHistoryReady;
3777
- const retry = async () => {
3778
- await Promise.all([
3779
- ...detail.error ? [detail.refresh()] : [],
3780
- ...human.error ? [human.refresh()] : [],
3781
- ...feed.error ? [feed.jumpToLatest()] : []
3782
- ]);
3783
- };
3784
- return {
3785
- ...scope,
3786
- sessionId,
3787
- config,
3788
- catalog,
3789
- showModelPicker,
3790
- feed,
3791
- detail,
3792
- queue,
3793
- human,
3794
- control,
3795
- approvals,
3796
- files,
3797
- uploadsEnabled,
3798
- composer,
3799
- /** The same live application context for text and durable voice messages. */
3800
- getModelContext: () => resolveExtras()?.modelContext,
3801
- timeline,
3802
- status,
3803
- terminal,
3804
- importedArchive,
3805
- running: sessionTurnKeepsRunControl(status),
3806
- error,
3807
- loadFailed,
3808
- retry
3809
- };
3810
- }
3811
- function usePendingPrompt(prompt, sessionId, historyReady) {
3812
- const owner = useRef7({
3813
- sessionId,
3814
- retired: prompt === null
3815
- });
3816
- const current = owner.current;
3817
- if (!current.retired && current.sessionId !== sessionId) {
3818
- if (current.sessionId === null) current.sessionId = sessionId;
3819
- else current.retired = true;
3820
- }
3821
- if (!current.retired && sessionId !== null && historyReady) current.retired = true;
3822
- return current.retired ? null : prompt;
3823
- }
3824
-
3825
- // src/hooks/use-session-read-acknowledgement.ts
3826
- import { useEffect as useEffect5, useMemo as useMemo5, useRef as useRef8 } from "react";
3827
- var SESSION_READ_ACKNOWLEDGEMENT_RETRY_MS = 1e3;
3828
- function isPermanentRejection(error) {
3829
- const status = error && typeof error === "object" ? error.status : void 0;
3830
- return typeof status === "number" && status >= 400 && status < 500 && status !== 408 && status !== 429;
3831
- }
3832
- function useSessionReadAcknowledgement(input) {
3833
- const { client, workspaceId, sessionId, events, active } = input;
3834
- const session = input.session && (input.session.id ?? sessionId) === sessionId ? input.session : null;
3835
- const attentionThrough = useMemo5(() => sessionAttentionReadThroughSequence(events), [events]);
3836
- const { readThrough, unread } = readAcknowledgementFrontier(session, attentionThrough);
3837
- const hasSession = session !== null;
3838
- const receipt = useRef8(null);
3839
- const refused = useRef8(/* @__PURE__ */ new Set());
3840
- const retryTimer = useRef8(null);
3841
- useEffect5(
3842
- () => () => {
3843
- if (retryTimer.current !== null) clearTimeout(retryTimer.current);
3844
- retryTimer.current = null;
3845
- receipt.current = null;
3846
- },
3847
- []
3848
- );
3849
- useEffect5(() => {
3850
- if (!active || !hasSession || !unread || readThrough <= 0) return;
3851
- if (!workspaceId || !sessionId || typeof client.updateSessionAttention !== "function") return;
3852
- const scope = `${workspaceId}:${sessionId}`;
3853
- if (refused.current.has(scope)) return;
3854
- const key = `${scope}:${readThrough}`;
3855
- if (receipt.current === key) return;
3856
- receipt.current = key;
3857
- if (retryTimer.current !== null) clearTimeout(retryTimer.current);
3858
- retryTimer.current = null;
3859
- const attempt = (retried) => {
3860
- void Promise.resolve().then(
3861
- () => client.updateSessionAttention(workspaceId, sessionId, {
3862
- unread: false,
3863
- acknowledgedThroughSequence: readThrough
3864
- })
3865
- ).catch((error) => {
3866
- if (receipt.current !== key) return;
3867
- if (isPermanentRejection(error)) {
3868
- refused.current.add(scope);
3869
- return;
3870
- }
3871
- if (!retried) {
3872
- retryTimer.current = setTimeout(() => {
3873
- retryTimer.current = null;
3874
- if (receipt.current === key) attempt(true);
3875
- }, SESSION_READ_ACKNOWLEDGEMENT_RETRY_MS);
3876
- return;
3877
- }
3878
- receipt.current = null;
3879
- });
3880
- };
3881
- attempt(false);
3882
- }, [active, client, hasSession, readThrough, sessionId, unread, workspaceId]);
3883
- }
3884
-
3885
- // src/hooks/use-new-conversation.ts
3886
- import {
3887
- OpenGeniApiError
3888
- } from "@opengeni/sdk";
3889
- import { useLayoutEffect as useLayoutEffect4, useMemo as useMemo6, useRef as useRef9, useState as useState6 } from "react";
3890
- var NOOP_ASYNC = async () => {
3891
- };
3892
- function useNewConversation(options = {}) {
3893
- const t = useOpenGeniText();
3894
- const context = useOpenGeni(options);
3895
- const scope = { client: context.client, workspaceId: context.workspaceId };
3896
- const config = useClientConfigFlags(context.client);
3897
- const showModelPicker = options.modelPicker ?? config.modelSelection;
3898
- const catalog = useWorkspaceModelCatalog({ ...scope, enabled: showModelPicker });
3899
- const preferredModel = options.defaultModel && catalog.models.some(
3900
- (row) => row.id === options.defaultModel && row.availability?.selectable !== false
3901
- ) ? options.defaultModel : void 0;
3902
- const defaultModel = preferredModel ?? catalog.defaultModel;
3903
- const files = useFileAttachments(scope);
3904
- const uploadsEnabled = (options.attachments ?? true) && config.uploads;
3905
- const available = options.enabled !== false && (options.createSession !== void 0 || config.sessionCreation);
3906
- const [text, setText] = useState6("");
3907
- const [choice, setChoice] = useState6({});
3908
- const [sending, setSending] = useState6(false);
3909
- const [error, setError] = useState6(null);
3910
- const [pending, setPending] = useState6(null);
3911
- const [completion, setCompletion] = useState6(null);
3912
- const textRef = useRef9(text);
3913
- const textRevision = useRef9(0);
3914
- const choiceRef = useRef9(choice);
3915
- const filesRef = useRef9(files);
3916
- filesRef.current = files;
3917
- const pendingRef = useRef9(null);
3918
- const completionRef = useRef9(null);
3919
- const inFlight = useRef9(false);
3920
- const lifetime = useRef9({ mounted: true, generation: 0 }).current;
3921
- const identity = useMemo6(
3922
- () => ({
3923
- client: context.client,
3924
- workspaceId: context.workspaceId,
3925
- scopeKey: options.scopeKey
3926
- }),
3927
- [context.client, context.workspaceId, options.scopeKey]
3928
- );
3929
- const committedIdentity = useRef9(identity);
3930
- useLayoutEffect4(() => {
3931
- lifetime.mounted = true;
3932
- return () => {
3933
- lifetime.mounted = false;
3934
- lifetime.generation++;
3935
- };
3936
- }, [lifetime]);
3937
- useLayoutEffect4(() => {
3938
- if (committedIdentity.current === identity) return;
3939
- committedIdentity.current = identity;
3940
- lifetime.generation++;
3941
- inFlight.current = false;
3942
- pendingRef.current = null;
3943
- completionRef.current = null;
3944
- textRef.current = "";
3945
- textRevision.current = 0;
3946
- choiceRef.current = {};
3947
- setText("");
3948
- setChoice({});
3949
- setSending(false);
3950
- setError(null);
3951
- setPending(null);
3952
- setCompletion(null);
3953
- filesRef.current.clear();
3954
- }, [identity, lifetime]);
3955
- const ownsScope = () => lifetime.mounted && committedIdentity.current === identity;
3956
- const updateText = (value) => {
3957
- if (!ownsScope()) return;
3958
- if (value !== textRef.current) textRevision.current++;
3959
- textRef.current = value;
3960
- setText(value);
3961
- };
3962
- const updateChoice = (patch) => {
3963
- if (!ownsScope()) return;
3964
- const next = { ...choiceRef.current, ...patch };
3965
- const model = catalog.models.find((row) => row.id === (next.model ?? defaultModel));
3966
- if (model) {
3967
- if (next.reasoningEffort)
3968
- next.reasoningEffort = coerceReasoningEffortForModel(model, next.reasoningEffort);
3969
- if (next.latencyMode && !runnableLatencyModesForModel(model).includes(next.latencyMode))
3970
- next.latencyMode = "standard";
3971
- }
3972
- choiceRef.current = next;
3973
- setChoice(choiceRef.current);
3974
- if (!pendingRef.current) setError(null);
3975
- };
3976
- const preferredChoice = () => preferredModel ? { model: preferredModel } : {};
3977
- const effectivePolicy = () => {
3978
- const model = choiceRef.current.model ?? defaultModel;
3979
- const definition = catalog.models.find((row) => row.id === model);
3980
- const effort = choiceRef.current.reasoningEffort ?? (definition ? defaultEffortForModel(definition) : config.defaultReasoningEffort ?? "medium");
3981
- return showModelPicker && model ? {
3982
- model,
3983
- reasoningEffort: definition ? coerceReasoningEffortForModel(definition, effort) : effort,
3984
- latencyMode: choiceRef.current.latencyMode ?? "standard"
3985
- } : void 0;
3986
- };
3987
- const create = options.createSession ?? (async (initialMessage, idempotencyKey, input) => {
3988
- const creator = context.client.createSession;
3989
- if (typeof creator !== "function")
3990
- throw new Error(t("hooks.useNewConversation.newChatsAreNotEnabled"));
3991
- const created = await creator.call(context.client, context.workspaceId, {
3992
- ...input.startMode === "realtime" ? {} : { initialMessage },
3993
- idempotencyKey,
3994
- ...input
3995
- });
3996
- return created.id;
3997
- });
3998
- const finishCreation = (accepted) => {
3999
- if (!lifetime.mounted || lifetime.generation !== accepted.generation) return;
4000
- const { attempt, sessionId } = accepted;
4001
- const sentFiles = new Set(attempt.options.resources?.map((resource) => resource.fileId) ?? []);
4002
- const policyChanged = ["model", "reasoningEffort", "latencyMode"].some(
4003
- (field) => choiceRef.current[field] !== attempt.options[field]
4004
- );
4005
- const draft = {
4006
- text: attempt.clearDraft && textRevision.current === attempt.textRevision ? "" : textRef.current,
4007
- resources: filesRef.current.readyResources.filter(
4008
- (resource) => !sentFiles.has(resource.fileId)
4009
- ),
4010
- // Unchanged choices are already part of the created session. Do not
4011
- // replace server-owned defaults with a browser's catalog estimate.
4012
- ...policyChanged ? { policy: effectivePolicy() } : {}
4013
- };
4014
- pendingRef.current = null;
4015
- completionRef.current = null;
4016
- setPending(null);
4017
- setCompletion(null);
4018
- updateText(draft.text);
4019
- filesRef.current.removeReadyFiles(sentFiles);
4020
- notifyObserver(options.onCreated, {
4021
- sessionId,
4022
- initialMessage: attempt.initialMessage,
4023
- sentAt: attempt.sentAt,
4024
- draft,
4025
- ...attempt.realtimeModel ? { realtimeModel: attempt.realtimeModel } : {}
4026
- });
4027
- };
4028
- const finishRef = useRef9(finishCreation);
4029
- finishRef.current = finishCreation;
4030
- useLayoutEffect4(() => {
4031
- if (completion && !files.hasUnresolved) finishRef.current(completion);
4032
- }, [completion, files.hasUnresolved]);
4033
- const deliver = async (attempt) => {
4034
- if (!ownsScope() || inFlight.current || completionRef.current || !available) return false;
4035
- const ownedGeneration = lifetime.generation;
4036
- inFlight.current = true;
4037
- pendingRef.current = attempt;
4038
- setSending(true);
4039
- setError(null);
4040
- setPending(null);
4041
- try {
4042
- const sessionId = await attempt.create(
4043
- attempt.initialMessage,
4044
- attempt.key,
4045
- structuredClone(attempt.options)
4046
- );
4047
- if (!lifetime.mounted || lifetime.generation !== ownedGeneration) return true;
4048
- const accepted = { sessionId, attempt, generation: ownedGeneration };
4049
- completionRef.current = accepted;
4050
- if (filesRef.current.hasUnresolved) setCompletion(accepted);
4051
- else finishCreation(accepted);
4052
- return true;
4053
- } catch (cause) {
4054
- if (!lifetime.mounted || lifetime.generation !== ownedGeneration) return false;
4055
- setError({ cause });
4056
- if (cause instanceof OpenGeniApiError && cause.outcomeUnknown === false) {
4057
- pendingRef.current = null;
4058
- } else {
4059
- setPending(attempt);
4060
- }
4061
- return false;
4062
- } finally {
4063
- if (lifetime.mounted && lifetime.generation === ownedGeneration) {
4064
- inFlight.current = false;
4065
- setSending(false);
4066
- }
4067
- }
4068
- };
4069
- const submit = async (explicit) => {
4070
- if (!ownsScope() || !available || inFlight.current || pendingRef.current || uploadsEnabled && filesRef.current.hasUnresolved)
4071
- return false;
4072
- const resources = uploadsEnabled ? filesRef.current.readyResources : [];
4073
- const draftText = explicit ?? textRef.current;
4074
- const initialMessage = draftText.trim() || (resources.length > 0 ? FILE_ONLY_MESSAGE_TEXT(t) : "");
4075
- if (!initialMessage) return false;
4076
- return deliver({
4077
- key: crypto.randomUUID(),
4078
- initialMessage,
4079
- sentAt: (/* @__PURE__ */ new Date()).toISOString(),
4080
- textRevision: textRevision.current,
4081
- clearDraft: explicit === void 0,
4082
- create,
4083
- options: {
4084
- ...resources.length ? { resources: structuredClone(resources) } : {},
4085
- ...showModelPicker ? { ...preferredChoice(), ...choiceRef.current } : {}
4086
- }
4087
- });
4088
- };
4089
- const startRealtime = async (model) => {
4090
- if (!ownsScope() || !available || inFlight.current || pendingRef.current || !config.realtimeVoice || !(options.realtimeVoice ?? config.realtimeVoiceOffered))
4091
- return false;
4092
- if (filesRef.current.hasUnresolved) return false;
4093
- return deliver({
4094
- key: crypto.randomUUID(),
4095
- initialMessage: "",
4096
- sentAt: (/* @__PURE__ */ new Date()).toISOString(),
4097
- textRevision: textRevision.current,
4098
- clearDraft: false,
4099
- create,
4100
- options: {
4101
- ...showModelPicker ? { ...preferredChoice(), ...choiceRef.current } : {},
4102
- startMode: "realtime"
4103
- },
4104
- realtimeModel: model
4105
- });
4106
- };
4107
- const composer = {
4108
- value: text,
4109
- setValue: updateText,
4110
- hasDraftContent: () => textRef.current.length > 0 || filesRef.current.attachments.length > 0,
4111
- send: submit,
4112
- steer: submit,
4113
- // Nothing runs before the conversation exists: Send just sends.
4114
- working: false,
4115
- sending,
4116
- canSend: available && !sending && !pending && !completion && (text.trim().length > 0 || uploadsEnabled && files.readyResources.length > 0) && !(uploadsEnabled && files.hasUnresolved),
4117
- pause: NOOP_ASYNC,
4118
- pausing: false,
4119
- resume: NOOP_ASYNC,
4120
- resumeScope: NOOP_ASYNC,
4121
- resuming: false,
4122
- draft: null,
4123
- draftRevision: 0,
4124
- draftLoading: false,
4125
- draftSaving: false,
4126
- draftConflict: null,
4127
- policy: effectivePolicy() ?? null,
4128
- setModel: (model) => updateChoice({ model }),
4129
- setReasoningEffort: (reasoningEffort) => updateChoice({ reasoningEffort }),
4130
- setLatencyMode: (latencyMode) => updateChoice({ latencyMode }),
4131
- draftPersistence: "disabled",
4132
- applyDraft: () => {
4133
- },
4134
- reloadDraft: NOOP_ASYNC,
4135
- resolveDraftConflict: NOOP_ASYNC,
4136
- restoredResources: [],
4137
- removeRestoredResource: () => {
4138
- },
4139
- error: null,
4140
- clearError: () => {
4141
- if (ownsScope()) setError(null);
4142
- }
4143
- };
4144
- return {
4145
- ...scope,
4146
- config,
4147
- files,
4148
- uploadsEnabled,
4149
- available,
4150
- showModelPicker,
4151
- catalog,
4152
- composer,
4153
- realtimeVoiceEnabled: config.realtimeVoice && (options.realtimeVoice ?? config.realtimeVoiceOffered),
4154
- error,
4155
- finishingUploads: completion !== null,
4156
- pending: pending ? { idempotencyKey: pending.key, realtimeModel: pending.realtimeModel } : null,
4157
- retry: () => pendingRef.current ? deliver(pendingRef.current) : Promise.resolve(false),
4158
- startRealtime
4159
- };
4160
- }
4161
-
4162
- // src/hooks/use-goal.ts
4163
- import {
4164
- OpenGeniApiError as OpenGeniApiError2,
4165
- observedSessionSequence
4166
- } from "@opengeni/sdk";
4167
- import { useCallback as useCallback8, useEffect as useEffect6, useLayoutEffect as useLayoutEffect5, useRef as useRef10, useState as useState7 } from "react";
4168
- function isGoalEvent(event) {
4169
- return event.type.startsWith("goal.");
4170
- }
4171
- function isGoalRefreshEvent(event) {
4172
- const type = event.type;
4173
- return isGoalEvent(event) || type.startsWith("turn.") || type.startsWith("session.") || type.startsWith("system.update.") || type.startsWith("workspace.inference.") || type.startsWith("user.");
4174
- }
4175
- function useGoal(sessionId, options = {}) {
4176
- const { client, workspaceId } = useEmbeddedGoal(options);
4177
- const enabled = (options.enabled ?? true) && Boolean(sessionId);
4178
- const sharedEvents = options.events;
4179
- const sharedFeed = sharedEvents !== void 0;
4180
- const pageLive = usePageLiveActivity();
4181
- const [goal, setGoal] = useState7(null);
4182
- const [loading, setLoading] = useState7(enabled);
4183
- const [error, setError] = useState7(null);
4184
- const [readAbsent, setReadAbsent] = useState7(false);
4185
- const { run, mutating, mutationError, clearMutationError } = useMutationRunner();
4186
- const generation = useRef10(0);
4187
- const targetKeyRef = useRef10(null);
4188
- const goalAbsentRef = useRef10(false);
4189
- const pendingRefreshRef = useRef10("none");
4190
- const sharedEventsRef = useRef10(sharedEvents);
4191
- useLayoutEffect5(() => {
4192
- sharedEventsRef.current = sharedEvents;
4193
- }, [sharedEvents]);
4194
- const loadAbort = useRef10(null);
4195
- const scheduleRefreshRef = useRef10(() => void 0);
4196
- const retireLoads = useCallback8(() => {
4197
- generation.current += 1;
4198
- loadAbort.current?.abort();
4199
- loadAbort.current = null;
4200
- }, []);
4201
- const load = useCallback8(async () => {
4202
- if (!sessionId) {
4203
- return;
4204
- }
4205
- const ticket = ++generation.current;
4206
- pendingRefreshRef.current = "none";
4207
- loadAbort.current?.abort();
4208
- const controller = new AbortController();
4209
- loadAbort.current = controller;
4210
- let fetchedGoal = null;
4211
- try {
4212
- const fetched = typeof client.findGoal === "function" ? await client.findGoal(workspaceId, sessionId, { signal: controller.signal }) : await client.getGoal(workspaceId, sessionId, { signal: controller.signal });
4213
- fetchedGoal = fetched;
4214
- if (ticket === generation.current) {
4215
- goalAbsentRef.current = fetched === null;
4216
- setReadAbsent(fetched === null);
4217
- setGoal(fetched);
4218
- setError(null);
4219
- setLoading(false);
4220
- }
4221
- } catch (cause) {
4222
- if (ticket !== generation.current) {
4223
- return;
4224
- }
4225
- if (cause instanceof OpenGeniApiError2 && cause.status === 404) {
4226
- goalAbsentRef.current = true;
4227
- setReadAbsent(true);
4228
- setGoal(null);
4229
- setError(null);
4230
- } else {
4231
- setError(normalizeError(cause));
4232
- }
4233
- setLoading(false);
4234
- } finally {
4235
- if (loadAbort.current === controller) loadAbort.current = null;
4236
- }
4237
- if (ticket !== generation.current || pendingRefreshRef.current === "none") {
4238
- return;
4239
- }
4240
- const readThrough = fetchedGoal ? observedSessionSequence(fetchedGoal) : void 0;
4241
- if (readThrough !== void 0 && sharedEventsRef.current !== void 0) {
4242
- const events = sharedEventsRef.current;
4243
- const newest = events[events.length - 1];
4244
- if (!newest || newest.sequence <= readThrough) {
4245
- pendingRefreshRef.current = "none";
4246
- return;
4247
- }
4248
- }
4249
- if (goalAbsentRef.current && pendingRefreshRef.current === "refresh") {
4250
- const events = sharedEventsRef.current ?? [];
4251
- let latestGoalEvent;
4252
- for (let index = events.length - 1; index >= 0 && !latestGoalEvent; index -= 1) {
4253
- const event = events[index];
4254
- if (event && isGoalEvent(event)) latestGoalEvent = event;
4255
- }
4256
- if (!latestGoalEvent || latestGoalEvent.type === "goal.cleared") {
4257
- pendingRefreshRef.current = "none";
4258
- return;
4259
- }
4260
- pendingRefreshRef.current = "goal";
4261
- }
4262
- scheduleRefreshRef.current();
4263
- }, [client, workspaceId, sessionId]);
4264
- useEffect6(() => {
4265
- const targetKey = `${workspaceId} ${sessionId ?? ""}`;
4266
- if (targetKeyRef.current !== targetKey) {
4267
- targetKeyRef.current = targetKey;
4268
- goalAbsentRef.current = false;
4269
- pendingRefreshRef.current = "none";
4270
- setReadAbsent(false);
4271
- setGoal(null);
4272
- setError(null);
4273
- }
4274
- if (!enabled || !pageLive) {
4275
- retireLoads();
4276
- setLoading(false);
4277
- return;
4278
- }
4279
- if (sharedFeed) {
4280
- setLoading(true);
4281
- void load();
4282
- return () => {
4283
- retireLoads();
4284
- };
4285
- }
4286
- setLoading(true);
4287
- const pollIntervalMs = options.pollIntervalMs;
4288
- if (pollIntervalMs === void 0 || pollIntervalMs <= 0) {
4289
- void load();
4290
- return () => {
4291
- retireLoads();
4292
- };
4293
- }
4294
- let cancelled = false;
4295
- let timer = null;
4296
- const schedule = () => {
4297
- if (cancelled) return;
4298
- timer = setTimeout(() => {
4299
- timer = null;
4300
- void load().finally(schedule);
4301
- }, pollIntervalMs);
4302
- };
4303
- void load().finally(schedule);
4304
- return () => {
4305
- cancelled = true;
4306
- if (timer !== null) clearTimeout(timer);
4307
- retireLoads();
4308
- };
4309
- }, [
4310
- load,
4311
- enabled,
4312
- pageLive,
4313
- workspaceId,
4314
- sessionId,
4315
- options.pollIntervalMs,
4316
- retireLoads,
4317
- sharedFeed
4318
- ]);
4319
- const scheduleRefresh = useDebouncedCallback(() => {
4320
- const pending = pendingRefreshRef.current;
4321
- if (pending === "none" || loadAbort.current !== null) return;
4322
- if (pending === "refresh" && goalAbsentRef.current) {
4323
- pendingRefreshRef.current = "none";
4324
- return;
4325
- }
4326
- void load();
4327
- });
4328
- useLayoutEffect5(() => {
4329
- scheduleRefreshRef.current = scheduleRefresh;
4330
- }, [scheduleRefresh]);
4331
- const isRefreshEvent = useCallback8(
4332
- (event) => goalAbsentRef.current ? isGoalEvent(event) : isGoalRefreshEvent(event),
4333
- []
4334
- );
4335
- const refreshGoal = useCallback8(() => {
4336
- pendingRefreshRef.current = "goal";
4337
- scheduleRefresh();
4338
- }, [scheduleRefresh]);
4339
- const onRefreshEvent = useCallback8(
4340
- (event) => {
4341
- if (isGoalEvent(event)) pendingRefreshRef.current = "goal";
4342
- else if (pendingRefreshRef.current === "none") pendingRefreshRef.current = "refresh";
4343
- scheduleRefresh();
4344
- },
4345
- [scheduleRefresh]
4346
- );
4347
- useSessionEventTrigger(client, workspaceId, sessionId, isRefreshEvent, onRefreshEvent, {
4348
- enabled,
4349
- ...sharedEvents !== void 0 ? { events: sharedEvents } : {},
4350
- // The load settles events that arrive during its read itself (above).
4351
- readThrough: projectionReadThrough(goal, false),
4352
- refresh: refreshGoal
4353
- });
4354
- const retainedGoal = useRetainedSessionView(
4355
- client,
4356
- workspaceId,
4357
- sessionId,
4358
- "goal",
4359
- loading ? null : goal,
4360
- { enabled, discard: readAbsent || deniesRetainedView(error) }
4361
- );
4362
- const visibleGoal = loading ? goal ?? retainedGoal : goal;
4363
- const goalRef = useRef10(goal);
4364
- const shownRetainedRef = useRef10(null);
4365
- const readWaitersRef = useRef10([]);
4366
- useLayoutEffect5(() => {
4367
- goalRef.current = goal;
4368
- shownRetainedRef.current = loading && goal === null ? retainedGoal : null;
4369
- });
4370
- useEffect6(() => {
4371
- if (loading) return;
4372
- const waiters = readWaitersRef.current;
4373
- readWaitersRef.current = [];
4374
- for (const resolve of waiters) resolve();
4375
- }, [loading]);
4376
- useEffect6(
4377
- () => () => {
4378
- goalRef.current = null;
4379
- const waiters = readWaitersRef.current;
4380
- readWaitersRef.current = [];
4381
- for (const resolve of waiters) resolve();
4382
- },
4383
- [workspaceId, sessionId]
4384
- );
4385
- const aimedAtCurrentGoal = useCallback8(async () => {
4386
- const shown = shownRetainedRef.current;
4387
- if (!shown) return true;
4388
- await new Promise((resolve) => readWaitersRef.current.push(resolve));
4389
- const fresh = goalRef.current;
4390
- return fresh !== null && fresh.id === shown.id && fresh.objectiveRevision === shown.objectiveRevision;
4391
- }, []);
4392
- const pause = useCallback8(
4393
- async (rationale) => {
4394
- if (!sessionId || !await aimedAtCurrentGoal()) {
4395
- return null;
4396
- }
4397
- const result = await run(
4398
- () => client.updateGoal(workspaceId, sessionId, {
4399
- status: "paused",
4400
- ...rationale !== void 0 ? { rationale } : {}
4401
- })
4402
- );
4403
- if (result) {
4404
- setGoal(result);
4405
- }
4406
- return result;
4407
- },
4408
- [client, workspaceId, sessionId, run, aimedAtCurrentGoal]
4409
- );
4410
- const resume = useCallback8(async () => {
4411
- if (!sessionId || !await aimedAtCurrentGoal()) {
4412
- return null;
4413
- }
4414
- const result = await run(() => client.updateGoal(workspaceId, sessionId, { status: "active" }));
4415
- if (result) {
4416
- setGoal(result);
4417
- }
4418
- return result;
4419
- }, [client, workspaceId, sessionId, run, aimedAtCurrentGoal]);
4420
- const clearGoal = useCallback8(async () => {
4421
- if (!sessionId || !await aimedAtCurrentGoal()) {
4422
- return;
4423
- }
4424
- const ok = await run(async () => {
4425
- await client.deleteGoal(workspaceId, sessionId);
4426
- return true;
4427
- });
4428
- if (ok) {
4429
- retireLoads();
4430
- setReadAbsent(true);
4431
- setGoal(null);
4432
- setError(null);
4433
- }
4434
- }, [client, workspaceId, sessionId, run, retireLoads, aimedAtCurrentGoal]);
4435
- return {
4436
- goal: visibleGoal,
4437
- isActive: visibleGoal?.status === "active",
4438
- isPaused: visibleGoal?.status === "paused",
4439
- isCompleted: visibleGoal?.status === "completed",
4440
- loading: loading && retainedGoal === null,
4441
- error,
4442
- refresh: load,
4443
- pause,
4444
- resume,
4445
- clearGoal,
4446
- deleteGoal: clearGoal,
4447
- updating: mutating,
4448
- mutationError,
4449
- clearMutationError
4450
- };
4451
- }
4452
-
4453
- export {
4454
- conversationTimeline,
4455
- isTitleEvent,
4456
- useSession,
4457
- useSessionStartupTimeline,
4458
- useAvailableModels,
4459
- useWorkspaceModelCatalog,
4460
- isHumanInputEvent,
4461
- useHumanInputRequests,
4462
- useSessionControl,
4463
- invokeOlderHistoryLoaderWithReceiptCapture,
4464
- createOlderHistoryLoadReceipt,
4465
- useTurnlessOutputGap,
4466
- SESSION_EVENT_BROWSER_MAX_BYTES,
4467
- SESSION_EVENT_BROWSER_MAX_COUNT,
4468
- SESSION_EVENT_BROWSER_PENDING_MAX_BYTES,
4469
- SESSION_EVENT_BROWSER_PENDING_MAX_COUNT,
4470
- useSessionEvents,
4471
- boundBrowserSessionEventWindow,
4472
- isTurnQueueEvent,
4473
- useTurnQueue,
4474
- useSessionConversation,
4475
- useSessionReadAcknowledgement,
4476
- useNewConversation,
4477
- isGoalEvent,
4478
- useGoal
4479
- };
4480
- //# sourceMappingURL=chunk-W4ABZ6XO.js.map