@opengeni/react 6.40.0 → 6.41.1-canary.45704649926001

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