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