@opengeni/react 6.37.3 → 6.37.4-canary.45279257475001

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