@opengeni/react 6.37.0 → 6.37.1-canary.45137095157001
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.
- package/dist/app/app-state.js +29 -29
- package/dist/app/components/Composer.js +44 -44
- package/dist/app/components/add-card-dialog.js +1 -1
- package/dist/app/components/add-card.js +2 -2
- package/dist/app/components/agent/agent-capability-picker.js +6 -6
- package/dist/app/components/agents/agent-can-use.js +45 -45
- package/dist/app/components/agents/agent-form-page.js +135 -135
- package/dist/app/components/agents/agent-page.js +116 -116
- package/dist/app/components/agents/agent-setup-sections.js +70 -70
- package/dist/app/components/agents/agent-skills.js +11 -11
- package/dist/app/components/agents/agent-trigger-chat-field.js +2 -2
- package/dist/app/components/agents/agent-trigger-dialog.js +26 -26
- package/dist/app/components/agents/agent-trigger-picker.js +6 -6
- package/dist/app/components/agents/agent-trigger-repositories.js +8 -8
- package/dist/app/components/agents/agents-page.js +93 -93
- package/dist/app/components/agents/composer-agent-chip.js +57 -57
- package/dist/app/components/agents/session-agent-chip.js +53 -53
- package/dist/app/components/artifacts/app-package.js +10 -10
- package/dist/app/components/artifacts/artifact-browse-controls.js +3 -3
- package/dist/app/components/artifacts/artifact-library.js +27 -27
- package/dist/app/components/artifacts/artifact-page-chrome.js +1 -1
- package/dist/app/components/artifacts/artifact-viewer.js +63 -63
- package/dist/app/components/artifacts/chat-interactive-block.js +27 -27
- package/dist/app/components/artifacts/copy-artifact-link.js +1 -1
- package/dist/app/components/artifacts/file-reach-dialog.js +11 -11
- package/dist/app/components/artifacts/inline-chat-image.js +50 -50
- package/dist/app/components/artifacts/ready-made-apps.js +9 -9
- package/dist/app/components/artifacts/retained-file-preview.js +56 -56
- package/dist/app/components/artifacts/retained-text-preview.js +7 -7
- package/dist/app/components/artifacts/site-actions.js +12 -12
- package/dist/app/components/artifacts/site-audience.js +5 -5
- package/dist/app/components/artifacts/site-conversations.js +32 -32
- package/dist/app/components/artifacts/site-data.js +25 -25
- package/dist/app/components/artifacts/site-public-link.js +3 -3
- package/dist/app/components/artifacts/site-publishing-page.js +65 -65
- package/dist/app/components/artifacts/site-publishing.js +50 -50
- package/dist/app/components/artifacts/site-settings.js +64 -64
- package/dist/app/components/artifacts/site-version-menu.js +7 -7
- package/dist/app/components/billing-class-mark.js +6 -6
- package/dist/app/components/capabilities/capability-detail-sheet.js +16 -16
- package/dist/app/components/capabilities/capability-logo-source.js +26 -26
- package/dist/app/components/capabilities/capability-logo.js +1 -1
- package/dist/app/components/capabilities/connection-account-picker.js +2 -2
- package/dist/app/components/capabilities/connector-tool-permissions.js +5 -5
- package/dist/app/components/capabilities/native-connect-setup.js +29 -29
- package/dist/app/components/capabilities/own-logins-shared-heads-up.js +5 -5
- package/dist/app/components/capabilities/perform-capability-action.js +4 -4
- package/dist/app/components/capabilities/prepared-mcp-setup-card.js +29 -29
- package/dist/app/components/capabilities/session-capability-card.js +137 -137
- package/dist/app/components/capabilities/session-chrome-card.js +47 -47
- package/dist/app/components/capabilities/session-connect-inputs-card.js +32 -32
- package/dist/app/components/capabilities/session-custom-mcp-card.js +37 -37
- package/dist/app/components/capabilities/session-github-card.js +42 -42
- package/dist/app/components/capabilities/session-machine-card.js +48 -48
- package/dist/app/components/capabilities/session-personal-github-card.js +30 -30
- package/dist/app/components/capabilities/session-plugin-card.js +19 -19
- package/dist/app/components/capabilities/use-capabilities-catalog.js +1 -1
- package/dist/app/components/capabilities/use-connection-accounts.js +3 -3
- package/dist/app/components/chat-payment-pages.js +2 -2
- package/dist/app/components/command-menu/chat-status.js +23 -23
- package/dist/app/components/command-menu/chat-switcher.js +81 -81
- package/dist/app/components/command-menu/command-menu.js +102 -102
- package/dist/app/components/command-menu/shortcut-sheet.js +19 -19
- package/dist/app/components/composer-capabilities-menu-body.js +5 -5
- package/dist/app/components/composer-mobile-plus-panel.js +26 -26
- package/dist/app/components/composer-mobile-plus.js +3 -3
- package/dist/app/components/credit-required-gate.js +6 -6
- package/dist/app/components/credit-required-prompt.js +20 -20
- package/dist/app/components/credits/checkout-credits-celebration.js +1 -1
- package/dist/app/components/credits/checkout-return.js +1 -1
- package/dist/app/components/credits/coupon-redeem.js +1 -1
- package/dist/app/components/credits/credit-refusal-notice.js +8 -8
- package/dist/app/components/credits/own-subscription-plan-notice.js +3 -3
- package/dist/app/components/desktop/app-shots.js +8 -8
- package/dist/app/components/desktop/app-update.js +3 -3
- package/dist/app/components/desktop/computer-use.js +2 -2
- package/dist/app/components/desktop/this-computer.js +5 -5
- package/dist/app/components/feedback.js +9 -9
- package/dist/app/components/follow-up-repository-menu-body.js +14 -14
- package/dist/app/components/follow-up-repository-picker.js +1 -1
- package/dist/app/components/github-app-connect-launcher.js +2 -2
- package/dist/app/components/in-app-help-link.js +3 -3
- package/dist/app/components/knowledge/agent-learning-settings.js +3 -3
- package/dist/app/components/machines/connect-machine-dialog.js +23 -23
- package/dist/app/components/manual-repository-editor.js +3 -3
- package/dist/app/components/markdown.js +15 -15
- package/dist/app/components/model-identity.js +3 -3
- package/dist/app/components/models/models-ui.js +16 -16
- package/dist/app/components/models/provider-mark.js +3 -3
- package/dist/app/components/my-things.js +14 -14
- package/dist/app/components/own-where-it-works.js +9 -9
- package/dist/app/components/pickers.js +11 -11
- package/dist/app/components/rail/channel-create-dialog.js +5 -5
- package/dist/app/components/rail/project-glyph.js +50 -50
- package/dist/app/components/rail/project-profile.js +68 -68
- package/dist/app/components/rail/rail-context.js +2 -2
- package/dist/app/components/rail/rail-sections.js +152 -152
- package/dist/app/components/rail/session-header.js +120 -120
- package/dist/app/components/rail/session-list.js +150 -150
- package/dist/app/components/rail/session-row-content.js +4 -4
- package/dist/app/components/rail/session-row-hover-details.js +35 -35
- package/dist/app/components/rail/session-shell.js +190 -190
- package/dist/app/components/rail/site-session-group-heading.js +35 -35
- package/dist/app/components/repository-picker.js +14 -14
- package/dist/app/components/secrets/session-secrets-panel.js +4 -4
- package/dist/app/components/session/agent-configuration-panel.js +45 -45
- package/dist/app/components/session/artifact-session-page.js +7 -7
- package/dist/app/components/session/banners.js +20 -20
- package/dist/app/components/session/chat-avatar.js +50 -50
- package/dist/app/components/session/console-new-conversation.js +109 -109
- package/dist/app/components/session/descendant-requests.js +103 -103
- package/dist/app/components/session/editable-artifacts-workspace.js +58 -58
- package/dist/app/components/session/failed-session-banner.js +24 -24
- package/dist/app/components/session/human-input-delegation-record.js +2 -2
- package/dist/app/components/session/human-input.js +82 -82
- package/dist/app/components/session/inspector.js +140 -140
- package/dist/app/components/session/message-actions.js +9 -9
- package/dist/app/components/session/model-recovery-notice.js +3 -3
- package/dist/app/components/session/new-session-settings-menu.js +26 -26
- package/dist/app/components/session/new-session-setup-strip.js +53 -53
- package/dist/app/components/session/pull-request-panel.js +24 -24
- package/dist/app/components/session/sandbox-switcher.js +22 -22
- package/dist/app/components/session/sandbox-workspace.js +114 -114
- package/dist/app/components/session/search-markdown-highlight.js +16 -16
- package/dist/app/components/session/search-results-view.js +17 -17
- package/dist/app/components/session/session-admin-access.js +12 -12
- package/dist/app/components/session/session-admission-notice.js +10 -10
- package/dist/app/components/session/session-avatar-picker.js +57 -57
- package/dist/app/components/session/session-avatar.js +52 -52
- package/dist/app/components/session/session-machine-access-notice.js +10 -10
- package/dist/app/components/session/session-profile-dialog.js +65 -65
- package/dist/app/components/session/session-profile-editor.js +66 -66
- package/dist/app/components/session/session-retention.js +5 -5
- package/dist/app/components/session/session-search-dialog.js +20 -20
- package/dist/app/components/session/session-skill-reviews.js +5 -5
- package/dist/app/components/session/session-tenancy-control.js +24 -24
- package/dist/app/components/session/session-unattended-setting.js +1 -1
- package/dist/app/components/session/session-usage-limit-section.js +10 -10
- package/dist/app/components/session/share-chat-dialog.js +8 -8
- package/dist/app/components/session/subagents.js +21 -21
- package/dist/app/components/session/subscription-account-indicator.js +21 -21
- package/dist/app/components/session/subscription-account-menu.js +2 -2
- package/dist/app/components/session-connectors-menu-body.js +10 -10
- package/dist/app/components/settings/row-select.js +3 -3
- package/dist/app/components/toaster.js +2 -2
- package/dist/app/components/transcription-settings.js +5 -5
- package/dist/app/components/ui/destructive-confirm.js +9 -9
- package/dist/app/components/usage/usage-entry.js +7 -7
- package/dist/app/components/window-bar.js +22 -22
- package/dist/app/components/workspace-composer-plus.js +41 -41
- package/dist/app/components/workspace-reach.js +5 -5
- package/dist/app/embed/session-app.js +396 -396
- package/dist/app/lib/actions/actions-provider.js +16 -16
- package/dist/app/lib/agent-capabilities.js +1 -1
- package/dist/app/lib/app-connect-card.js +11 -11
- package/dist/app/lib/app-shared-key-dialog.js +5 -5
- package/dist/app/lib/app-surfaces.js +1 -1
- package/dist/app/lib/app-sync-opt-in.js +1 -1
- package/dist/app/lib/codex-usage-query.js +2 -2
- package/dist/app/lib/composer-agent.js +2 -2
- package/dist/app/lib/composer-connectors.js +30 -30
- package/dist/app/lib/composer-send-blocking.js +2 -2
- package/dist/app/lib/console-site.js +4 -4
- package/dist/app/lib/events.js +27 -27
- package/dist/app/lib/failed-session-copy.js +3 -3
- package/dist/app/lib/feedback-capture.js +2 -2
- package/dist/app/lib/model-access-onboarding.js +1 -1
- package/dist/app/lib/move-chat-to-machine.js +2 -2
- package/dist/app/lib/personal-resource-attachments.js +1 -1
- package/dist/app/lib/session-branch-cache.js +16 -16
- package/dist/app/lib/session-create.js +2 -2
- package/dist/app/lib/session-group-pagination.js +16 -16
- package/dist/app/lib/session-hover-facts.js +24 -24
- package/dist/app/lib/session-list-dirty-scopes.js +17 -17
- package/dist/app/lib/session-rail.js +14 -14
- package/dist/app/lib/sessions-group.js +19 -19
- package/dist/app/lib/site-tool-consent-dialog.js +20 -20
- package/dist/app/lib/site-tool-consent.js +1 -1
- package/dist/app/lib/turn-failure-analytics.js +4 -4
- package/dist/app/lib/use-artifact-catalog.js +2 -2
- package/dist/app/lib/use-duplicate-site.js +4 -4
- package/dist/app/lib/use-follow-up-repositories.js +2 -2
- package/dist/app/lib/use-personal-resource-attachment.js +2 -2
- package/dist/app/lib/use-workspace-machines.js +8 -8
- package/dist/app/lib/use-workspace-model-catalog.js +4 -4
- package/dist/app/lib/use-workspace-rigs.js +5 -5
- package/dist/app/lib/workspace-navigation-preference.js +1 -1
- package/dist/app/lib/workspace-scope-context.js +1 -1
- package/dist/app/routes/app-page-view.js +18 -18
- package/dist/app/routes/app-page.js +2 -2
- package/dist/app/routes/artifacts.js +147 -147
- package/dist/app/routes/retained-artifact.js +108 -108
- package/dist/app/routes/session-unavailable.js +5 -5
- package/dist/app/routes/session.js +244 -244
- package/dist/app/routes/sessions-index-hydration.js +2 -2
- package/dist/app/routes/sessions-index.js +201 -201
- package/dist/app/routes/site-view.js +195 -195
- package/dist/artifacts-presentation.js +5 -5
- package/dist/artifacts.js +47 -47
- package/dist/automation-model.js +1 -1
- package/dist/automations.js +61 -61
- package/dist/{browser-viewer-5JGSKIXX.js → browser-viewer-EPGAK2W6.js} +7 -7
- package/dist/{chat-interactive-block-NEDFTOGE.js → chat-interactive-block-65YU6TMO.js} +9 -9
- package/dist/{chunk-E7FNLQXM.js → chunk-266ZPUMH.js} +2 -2
- package/dist/{chunk-SN2QZSJU.js → chunk-2A7SB7UR.js} +10 -10
- package/dist/{chunk-VVLUVHF5.js → chunk-2F7VSGRS.js} +4 -4
- package/dist/{chunk-PKH6MYAK.js → chunk-2WGJQ4XK.js} +8 -8
- package/dist/{chunk-XZRMTHHW.js → chunk-2XSF44TY.js} +2 -2
- package/dist/{chunk-T2N6JC5H.js → chunk-352G4KMU.js} +2 -2
- package/dist/{chunk-7IR7EOTR.js → chunk-3ESOPD4L.js} +37 -37
- package/dist/{chunk-L2Q4HMVJ.js → chunk-3NFBAJVP.js} +4 -4
- package/dist/{chunk-KPTKQULD.js → chunk-3SDESU6U.js} +5 -5
- package/dist/{chunk-J5D5OCQF.js → chunk-3UJKCVZ3.js} +9 -9
- package/dist/{chunk-M4ZYHLFU.js → chunk-3VXZFBP6.js} +9 -9
- package/dist/{chunk-YL2NFFXW.js → chunk-3WDNCSVU.js} +2 -2
- package/dist/{chunk-YR7U2KDA.js → chunk-3YE4C3VF.js} +10 -10
- package/dist/{chunk-HYNTTDG6.js → chunk-3ZNOKD3S.js} +7 -7
- package/dist/{chunk-VIKXHP44.js → chunk-45SB4UK3.js} +5 -5
- package/dist/{chunk-UPRN4FBY.js → chunk-46ZC5VNC.js} +4 -4
- package/dist/{chunk-Z7UBLC6V.js → chunk-47BETTVA.js} +2 -2
- package/dist/{chunk-WUKLEDKK.js → chunk-4IZJZTYY.js} +44 -44
- package/dist/{chunk-PJ42LTJE.js → chunk-4JQRWJVR.js} +4 -4
- package/dist/{chunk-XCEHQ3SO.js → chunk-4NGIKV2W.js} +5 -5
- package/dist/{chunk-F23TR625.js → chunk-4WEPVL7X.js} +3 -3
- package/dist/{chunk-BVFOLLMQ.js → chunk-5HFITPHH.js} +2 -2
- package/dist/{chunk-UBM3IM6K.js → chunk-5PVXFVIT.js} +2 -2
- package/dist/{chunk-DNRVXHUW.js → chunk-5WFGW7B7.js} +8 -8
- package/dist/{chunk-2PTBF6GM.js → chunk-5YMSLKJP.js} +3 -3
- package/dist/{chunk-HZ5DTSAG.js → chunk-62EXH6FY.js} +2 -2
- package/dist/{chunk-HWOYJOKK.js → chunk-62T2ZPD5.js} +2 -2
- package/dist/{chunk-6ZJU2B3Z.js → chunk-634Q4QOS.js} +2 -2
- package/dist/{chunk-PMBZMVKE.js → chunk-6CDBX3XG.js} +2 -2
- package/dist/{chunk-R6CFPY3F.js → chunk-6D3D2JWY.js} +4 -4
- package/dist/{chunk-OEOLXODE.js → chunk-6ENO634Y.js} +6 -6
- package/dist/{chunk-IHX5BADQ.js → chunk-6LQ5KEMP.js} +2 -2
- package/dist/{chunk-JXIBVYRA.js → chunk-6RESVGHF.js} +11 -11
- package/dist/{chunk-EFBPHDPP.js → chunk-6WEDWD4N.js} +8 -8
- package/dist/{chunk-HYFNKXHR.js → chunk-76VXLTQF.js} +7 -7
- package/dist/{chunk-Y3ME7IF6.js → chunk-7MF6MFHS.js} +8 -8
- package/dist/{chunk-VJJKN675.js → chunk-7PDUH7OK.js} +7548 -7548
- package/dist/chunk-7PDUH7OK.js.map +1 -0
- package/dist/{chunk-5CEQ356Z.js → chunk-7VAILBP6.js} +5 -5
- package/dist/{chunk-GGIPEZLL.js → chunk-A5GX3CAE.js} +26 -26
- package/dist/{chunk-E45JRR3J.js → chunk-A7DS77WC.js} +7 -7
- package/dist/{chunk-EJ6IIEZX.js → chunk-ANWMRO2G.js} +4 -4
- package/dist/{chunk-EXBIL5BF.js → chunk-APGUIORF.js} +3 -3
- package/dist/{chunk-FT3AUAXE.js → chunk-ASCVQJB4.js} +15 -15
- package/dist/{chunk-4OGDD2EM.js → chunk-B6AH43UQ.js} +9 -9
- package/dist/{chunk-5ZTVBNMS.js → chunk-BRZCHOKU.js} +5 -5
- package/dist/{chunk-V6ZJKHVS.js → chunk-BUI7SHH6.js} +23 -23
- package/dist/{chunk-4NXQWXQY.js → chunk-BVWJEZXG.js} +3 -3
- package/dist/{chunk-BKJXUACP.js → chunk-BZ47G3VP.js} +7 -7
- package/dist/{chunk-22SXRKET.js → chunk-C6KI5P3H.js} +4 -4
- package/dist/{chunk-34LWIEIZ.js → chunk-CED3EPAV.js} +2 -2
- package/dist/{chunk-CC2IVNVR.js → chunk-CNRFFCAE.js} +10 -10
- package/dist/{chunk-WJ2STMQD.js → chunk-CPC6CYVW.js} +2 -2
- package/dist/{chunk-KZQDP2JM.js → chunk-CVC4RO7D.js} +7 -7
- package/dist/{chunk-754NH7T2.js → chunk-D4ADNM45.js} +5 -5
- package/dist/{chunk-RJZALNT5.js → chunk-DJQ6TKIP.js} +4 -4
- package/dist/{chunk-JY2UEPJP.js → chunk-DK2CDAMR.js} +2 -2
- package/dist/{chunk-IBHUF5BN.js → chunk-DPOB6MUS.js} +8 -8
- package/dist/{chunk-5H3SJHDT.js → chunk-DSO7S6PZ.js} +2 -2
- package/dist/{chunk-3F45ELUO.js → chunk-DW2IQRMB.js} +4 -4
- package/dist/{chunk-VHYDZMGS.js → chunk-DXMKECFR.js} +13 -13
- package/dist/{chunk-44MYJQ72.js → chunk-DZLWO73N.js} +8 -8
- package/dist/{chunk-J2GIGAVJ.js → chunk-E2GNUL64.js} +6 -6
- package/dist/{chunk-QD6A4G7Y.js → chunk-E5TVYXJJ.js} +6 -6
- package/dist/{chunk-YJYKB6ZT.js → chunk-E7XU2KHD.js} +3 -3
- package/dist/{chunk-OZGECHF5.js → chunk-EM2HA2SH.js} +2 -2
- package/dist/{chunk-N37BLJOI.js → chunk-EQQS6V5A.js} +18 -18
- package/dist/{chunk-KI2TGJVH.js → chunk-EWHQ3DFM.js} +2 -2
- package/dist/{chunk-4ST37B5I.js → chunk-F2T4J7CK.js} +14 -14
- package/dist/{chunk-D32VVOBJ.js → chunk-F3LIUDXN.js} +126 -126
- package/dist/chunk-F3LIUDXN.js.map +1 -0
- package/dist/{chunk-2NABGWXC.js → chunk-F5NFGBIN.js} +2 -2
- package/dist/{chunk-5AHIKB3O.js → chunk-FXFOKD7A.js} +4 -4
- package/dist/{chunk-4RGFBD4M.js → chunk-GCSUZGVC.js} +284 -284
- package/dist/{chunk-HUKGLWAY.js → chunk-GIHE7U3Y.js} +4 -4
- package/dist/{chunk-QD4J7AHU.js → chunk-GKDPNRQ4.js} +29 -29
- package/dist/{chunk-TGAKM3WX.js → chunk-GKWFQEO3.js} +2 -2
- package/dist/{chunk-Y6CNWBV3.js → chunk-GO5VIAA7.js} +4 -4
- package/dist/{chunk-E5EICKKB.js → chunk-GQJAMANY.js} +5 -5
- package/dist/{chunk-I2WTJMQF.js → chunk-HEPFJ3XQ.js} +9 -9
- package/dist/{chunk-PTSRBKQC.js → chunk-HFROJDFQ.js} +2 -2
- package/dist/{chunk-YP4SNX4P.js → chunk-HHFFPE67.js} +4 -4
- package/dist/{chunk-TWSO5S3E.js → chunk-HLRAQITA.js} +15 -15
- package/dist/{chunk-S2525GSA.js → chunk-HP7RE2U3.js} +16 -16
- package/dist/{chunk-WT37FEG3.js → chunk-HYEG7I3Y.js} +5 -5
- package/dist/{chunk-QEXHABRN.js → chunk-I7M5BYJU.js} +6 -6
- package/dist/{chunk-F45CPW3Y.js → chunk-IWPPGXUZ.js} +33 -33
- package/dist/{chunk-X7YUQ4WO.js → chunk-IZVXSAOJ.js} +203 -203
- package/dist/{chunk-X7YUQ4WO.js.map → chunk-IZVXSAOJ.js.map} +1 -1
- package/dist/{chunk-GHXIVKQH.js → chunk-JHSZSLVU.js} +5 -5
- package/dist/{chunk-5AXIZJX4.js → chunk-JNPCRNPA.js} +3 -3
- package/dist/{chunk-4R74CAIF.js → chunk-JPLHCRA7.js} +12 -12
- package/dist/{chunk-DRVT6TRP.js → chunk-K5XFZKK5.js} +4 -4
- package/dist/{chunk-QPA7ATJH.js → chunk-KA4PZU3Q.js} +6 -6
- package/dist/{chunk-3UA2SOK2.js → chunk-KGZ35ESO.js} +2 -2
- package/dist/{chunk-I7HYF6MQ.js → chunk-KNMM6WFD.js} +12 -12
- package/dist/{chunk-NL7VJGFZ.js → chunk-KRM4PW5N.js} +17 -17
- package/dist/{chunk-PCSRHFRF.js → chunk-KTGKGHEA.js} +4 -4
- package/dist/{chunk-NUZNJSL5.js → chunk-KU77XHWB.js} +4 -4
- package/dist/{chunk-XKJCFK2G.js → chunk-KYRHCY3I.js} +7 -7
- package/dist/{chunk-VLDKWGHD.js → chunk-L6WVCO6D.js} +2 -2
- package/dist/{chunk-F5C5T2PF.js → chunk-LLX4S6BI.js} +10 -10
- package/dist/{chunk-TGG3ODCS.js → chunk-MCPKUVMQ.js} +4 -4
- package/dist/{chunk-KYDLVMKA.js → chunk-MFLU3466.js} +4 -4
- package/dist/{chunk-ZLKHNJCQ.js → chunk-MGWVWPFC.js} +11 -11
- package/dist/{chunk-ZD67RM6G.js → chunk-MIUJ3EH5.js} +4 -4
- package/dist/{chunk-M5FX5KH5.js → chunk-MO3XJQN2.js} +6 -6
- package/dist/{chunk-THWN4STY.js → chunk-MRARVYKV.js} +68 -68
- package/dist/chunk-MRARVYKV.js.map +1 -0
- package/dist/{chunk-XKLXYIIT.js → chunk-MRKY2GL5.js} +2 -2
- package/dist/{chunk-4UAHTM3Q.js → chunk-MVE26JNL.js} +1 -1
- package/dist/{chunk-2JR7LEST.js → chunk-MVGU7BET.js} +2 -2
- package/dist/{chunk-5ERDSF2C.js → chunk-MVYQDBE6.js} +4 -4
- package/dist/{chunk-GP7MYBSX.js → chunk-NFV76UYK.js} +1 -1
- package/dist/{chunk-TMZ6RP3K.js → chunk-NGQCWCD6.js} +8 -8
- package/dist/{chunk-AML5X74C.js → chunk-NKXMIOYN.js} +18 -18
- package/dist/{chunk-VT5XHR5J.js → chunk-NMVRFFCR.js} +5 -5
- package/dist/{chunk-6IIJ4H4O.js → chunk-NNTDIKJP.js} +6 -6
- package/dist/{chunk-FARCOS2S.js → chunk-NOFZMGNM.js} +5 -5
- package/dist/{chunk-MM4NP5QA.js → chunk-NQXCPP4G.js} +9 -9
- package/dist/{chunk-UJNDUO7D.js → chunk-NRCZ3PSS.js} +13 -13
- package/dist/{chunk-7MH4TTVE.js → chunk-NYGS6FNV.js} +2 -2
- package/dist/{chunk-MIMSPOV4.js → chunk-O45WS2OY.js} +26 -26
- package/dist/{chunk-COCLT77F.js → chunk-O5HRZ2KG.js} +7 -7
- package/dist/{chunk-6F34IWSA.js → chunk-O664PL2U.js} +11 -11
- package/dist/chunk-O664PL2U.js.map +1 -0
- package/dist/{chunk-XMTBNLD2.js → chunk-O6QFY34B.js} +21 -21
- package/dist/{chunk-LCRYAD3X.js → chunk-OBKDRV2H.js} +10 -10
- package/dist/{chunk-PJ66EIWE.js → chunk-ODLFK2E4.js} +3 -3
- package/dist/{chunk-WSQ3TCOX.js → chunk-ORRACKLB.js} +4 -4
- package/dist/{chunk-BT5EOSQF.js → chunk-P3ODPHQW.js} +3 -3
- package/dist/{chunk-2X7I6LXY.js → chunk-PAFSIDM2.js} +5 -5
- package/dist/{chunk-F5RP42TL.js → chunk-PCSU2VOT.js} +20 -20
- package/dist/{chunk-ZGBMDDFR.js → chunk-PGSXT5OY.js} +9 -9
- package/dist/{chunk-LFQI2C46.js → chunk-PPQJIVGM.js} +4 -4
- package/dist/{chunk-UFRXYZCJ.js → chunk-PYMQM65Y.js} +4 -4
- package/dist/{chunk-T2IFOASN.js → chunk-PZQEBNWB.js} +1717 -1717
- package/dist/chunk-PZQEBNWB.js.map +1 -0
- package/dist/{chunk-PGMXITPB.js → chunk-QA5UNVHD.js} +3 -3
- package/dist/{chunk-NLJEDAKV.js → chunk-QDMGUTOU.js} +7 -7
- package/dist/{chunk-7456QZAA.js → chunk-QJ72YUT4.js} +1 -1
- package/dist/{chunk-UBR3CGJC.js → chunk-QJRPA2DV.js} +146 -146
- package/dist/{chunk-J4OOKDRV.js → chunk-QNOWKKZ4.js} +4 -4
- package/dist/{chunk-PEAJRZU3.js → chunk-QRQGMYGU.js} +2 -2
- package/dist/{chunk-WBNSC6RJ.js → chunk-QUFCZMHG.js} +4 -4
- package/dist/{chunk-R2T4IUNB.js → chunk-QVOTPOXK.js} +1 -1
- package/dist/{chunk-VRS6VNHP.js → chunk-QZE3KD34.js} +5 -5
- package/dist/{chunk-IPFSFSIK.js → chunk-RACDLUKT.js} +47 -47
- package/dist/{chunk-COIXX62I.js → chunk-RDLS6IZY.js} +11 -11
- package/dist/{chunk-MSHWYGCH.js → chunk-RKPETJDJ.js} +6 -6
- package/dist/{chunk-DKM3JBGJ.js → chunk-RLJ2LXXZ.js} +9 -9
- package/dist/{chunk-GLBILBET.js → chunk-RMFNSJQI.js} +7 -7
- package/dist/{chunk-RJWTAS4V.js → chunk-RR6DQN4X.js} +5 -5
- package/dist/{chunk-TNE7ZYGN.js → chunk-RRH6ZX3F.js} +61 -61
- package/dist/{chunk-7X443ZTQ.js → chunk-RVY5EZNU.js} +4 -4
- package/dist/{chunk-MCXTYDFG.js → chunk-S7EO77EE.js} +4 -4
- package/dist/{chunk-S3BLYPOG.js → chunk-SA4HJENC.js} +2 -2
- package/dist/{chunk-ZJICGGPI.js → chunk-SMNBTDDD.js} +2 -2
- package/dist/{chunk-SNACGK3Z.js → chunk-SRDHDIRQ.js} +8 -8
- package/dist/{chunk-HUTQJY3F.js → chunk-SYYFA7W7.js} +4 -4
- package/dist/{chunk-MAR5UYX4.js → chunk-T5BYEE66.js} +8 -8
- package/dist/{chunk-HGS5JWZR.js → chunk-TLWH4E3P.js} +6 -6
- package/dist/{chunk-7XZO4W76.js → chunk-TNHGSWG3.js} +8 -8
- package/dist/{chunk-QHYLEJP7.js → chunk-U26OWALV.js} +8 -8
- package/dist/{chunk-U2TOOZIY.js → chunk-U2CEPRDH.js} +4 -4
- package/dist/{chunk-4PSB2CK7.js → chunk-UHRGUMLJ.js} +12 -12
- package/dist/{chunk-CGVMECYX.js → chunk-UNDSD6UA.js} +10 -10
- package/dist/{chunk-O4ZXJ52Z.js → chunk-UR25OGGM.js} +26 -26
- package/dist/{chunk-SUXGKBCW.js → chunk-USU2SS4V.js} +4 -4
- package/dist/{chunk-QMRHY45R.js → chunk-V4QFPYCN.js} +8 -8
- package/dist/{chunk-FGHWU4LX.js → chunk-VALESBNH.js} +5 -5
- package/dist/{chunk-XZLNVFB4.js → chunk-VMSMVWCJ.js} +15 -15
- package/dist/{chunk-HRFAQYOA.js → chunk-VXPY2GF3.js} +1 -1
- package/dist/{chunk-JTSLGUVP.js → chunk-W5CNXRSF.js} +5 -5
- package/dist/{chunk-46UZ5ZYU.js → chunk-WEGZPK4I.js} +10 -10
- package/dist/{chunk-IL5ME4MQ.js → chunk-WPKY3BGG.js} +24 -24
- package/dist/chunk-WPKY3BGG.js.map +1 -0
- package/dist/{chunk-WEPL76AR.js → chunk-X4OGMBY6.js} +2 -2
- package/dist/{chunk-SXXWPTL7.js → chunk-X7HPRJM6.js} +3 -3
- package/dist/{chunk-R6WQLIFX.js → chunk-XHF2XNU5.js} +1 -1
- package/dist/{chunk-3PTEMOSW.js → chunk-XN6XMGMN.js} +4 -4
- package/dist/{chunk-5ZUARMG2.js → chunk-XV4ZFOOG.js} +16 -16
- package/dist/{chunk-3J6ENWZF.js → chunk-XVFRKZ3H.js} +3 -3
- package/dist/{chunk-FWIV2FTX.js → chunk-Y2QYPJDN.js} +2 -2
- package/dist/{chunk-GYHL6IRO.js → chunk-Y7PHZN5G.js} +26 -26
- package/dist/{chunk-R6OBJ7LF.js → chunk-YAVW5OJ5.js} +4 -4
- package/dist/{chunk-MXRCKJOQ.js → chunk-YLEMK4JY.js} +153 -153
- package/dist/{chunk-F6D6X5ZU.js → chunk-YQ6FP33X.js} +7 -7
- package/dist/{chunk-N556VQMT.js → chunk-YUA42N5A.js} +4 -4
- package/dist/{chunk-IL6PCX7K.js → chunk-YXFNW64N.js} +2 -2
- package/dist/{chunk-4SNYMZBC.js → chunk-Z76RJPZF.js} +5 -5
- package/dist/{chunk-RA3NTKSW.js → chunk-Z7GGAA4L.js} +67 -67
- package/dist/{chunk-YS6BQNHF.js → chunk-ZE4RD7U5.js} +8 -8
- package/dist/{chunk-FHNBUDXL.js → chunk-ZOUCHIUE.js} +9 -9
- package/dist/{chunk-F6LVPEBK.js → chunk-ZRNK6FK6.js} +2 -2
- package/dist/{chunk-DP4MGOBG.js → chunk-ZSIKF2R3.js} +8 -8
- package/dist/{chunk-MXSZQ6DP.js → chunk-ZVAIKQMC.js} +10 -10
- package/dist/{chunk-AVIOWKKJ.js → chunk-ZZ3KNGTJ.js} +5 -5
- package/dist/composer.js +34 -34
- package/dist/{computer-viewer-FHCBTSZH.js → computer-viewer-M5N3GWBR.js} +4 -4
- package/dist/connect.js +27 -27
- package/dist/{connection-step-up-JLORUM6D.js → connection-step-up-5ZUYASTH.js} +30 -30
- package/dist/desktop-dictation.js +21 -21
- package/dist/{embedded-new-voice-BFTQZPJK.js → embedded-new-voice-QZJG5DZ3.js} +12 -12
- package/dist/{embedded-voice-CQE2GO6Y.js → embedded-voice-7KOQNGKU.js} +12 -12
- package/dist/in-chat-connect-model.js +4 -4
- package/dist/index.js +308 -308
- package/dist/interaction.js +7 -7
- package/dist/latest-question-F3VPDR7U.js +1 -1
- package/dist/machine-request-model.js +1 -1
- package/dist/machines.js +7 -7
- package/dist/meetings.js +113 -113
- package/dist/{model-policy-picker-menu-PVBT2OZO.js → model-policy-picker-menu-UNI5B6N6.js} +8 -8
- package/dist/{payment-page-card-YPCRVFHE.js → payment-page-card-Q4BEOZVN.js} +6 -6
- package/dist/{platform-activity-row-ZWACJPNQ.js → platform-activity-row-NPEGG2VE.js} +4 -4
- package/dist/{queue-surface-implementation-C7ESPZW7.js → queue-surface-implementation-RTCTPF5T.js} +7 -7
- package/dist/realtime.js +15 -15
- package/dist/{sandbox-files-6L2GRNOG.js → sandbox-files-BJKCREOU.js} +12 -12
- package/dist/session-app.js +396 -396
- package/dist/{session-connect-cards-2TRJ5IWB.js → session-connect-cards-DK3UJZRY.js} +8 -8
- package/dist/session-ui.js +91 -91
- package/dist/session.js +41 -41
- package/dist/sites.js +2 -2
- package/dist/terminal.js +1 -1
- package/dist/timeline-model.js +58 -58
- package/dist/ui/access-list.js +22 -22
- package/dist/ui/cadence-picker.js +2 -2
- package/dist/ui/choice-cards.js +2 -2
- package/dist/ui/detail-page.js +4 -4
- package/dist/ui/detail-sheet.js +4 -4
- package/dist/ui/diff-view.js +3 -3
- package/dist/ui/disclosure.js +5 -5
- package/dist/ui/flush-form-page.js +6 -6
- package/dist/ui/form-dialog.js +5 -5
- package/dist/ui/list-row.js +5 -5
- package/dist/ui/load-failure.js +3 -3
- package/dist/ui/revision-history.js +10 -10
- package/dist/ui/role-select.js +9 -9
- package/dist/ui/select-menu.js +2 -2
- package/dist/ui/settings-nav.js +6 -6
- package/dist/ui/sheet.js +2 -2
- package/dist/usage.js +2 -2
- package/dist/workbench.js +10 -10
- package/package.json +6 -5
- package/dist/chunk-6F34IWSA.js.map +0 -1
- package/dist/chunk-D32VVOBJ.js.map +0 -1
- package/dist/chunk-IL5ME4MQ.js.map +0 -1
- package/dist/chunk-T2IFOASN.js.map +0 -1
- package/dist/chunk-THWN4STY.js.map +0 -1
- package/dist/chunk-VJJKN675.js.map +0 -1
- /package/dist/{browser-viewer-5JGSKIXX.js.map → browser-viewer-EPGAK2W6.js.map} +0 -0
- /package/dist/{chat-interactive-block-NEDFTOGE.js.map → chat-interactive-block-65YU6TMO.js.map} +0 -0
- /package/dist/{chunk-E7FNLQXM.js.map → chunk-266ZPUMH.js.map} +0 -0
- /package/dist/{chunk-SN2QZSJU.js.map → chunk-2A7SB7UR.js.map} +0 -0
- /package/dist/{chunk-VVLUVHF5.js.map → chunk-2F7VSGRS.js.map} +0 -0
- /package/dist/{chunk-PKH6MYAK.js.map → chunk-2WGJQ4XK.js.map} +0 -0
- /package/dist/{chunk-XZRMTHHW.js.map → chunk-2XSF44TY.js.map} +0 -0
- /package/dist/{chunk-T2N6JC5H.js.map → chunk-352G4KMU.js.map} +0 -0
- /package/dist/{chunk-7IR7EOTR.js.map → chunk-3ESOPD4L.js.map} +0 -0
- /package/dist/{chunk-L2Q4HMVJ.js.map → chunk-3NFBAJVP.js.map} +0 -0
- /package/dist/{chunk-KPTKQULD.js.map → chunk-3SDESU6U.js.map} +0 -0
- /package/dist/{chunk-J5D5OCQF.js.map → chunk-3UJKCVZ3.js.map} +0 -0
- /package/dist/{chunk-M4ZYHLFU.js.map → chunk-3VXZFBP6.js.map} +0 -0
- /package/dist/{chunk-YL2NFFXW.js.map → chunk-3WDNCSVU.js.map} +0 -0
- /package/dist/{chunk-YR7U2KDA.js.map → chunk-3YE4C3VF.js.map} +0 -0
- /package/dist/{chunk-HYNTTDG6.js.map → chunk-3ZNOKD3S.js.map} +0 -0
- /package/dist/{chunk-VIKXHP44.js.map → chunk-45SB4UK3.js.map} +0 -0
- /package/dist/{chunk-UPRN4FBY.js.map → chunk-46ZC5VNC.js.map} +0 -0
- /package/dist/{chunk-Z7UBLC6V.js.map → chunk-47BETTVA.js.map} +0 -0
- /package/dist/{chunk-WUKLEDKK.js.map → chunk-4IZJZTYY.js.map} +0 -0
- /package/dist/{chunk-PJ42LTJE.js.map → chunk-4JQRWJVR.js.map} +0 -0
- /package/dist/{chunk-XCEHQ3SO.js.map → chunk-4NGIKV2W.js.map} +0 -0
- /package/dist/{chunk-F23TR625.js.map → chunk-4WEPVL7X.js.map} +0 -0
- /package/dist/{chunk-BVFOLLMQ.js.map → chunk-5HFITPHH.js.map} +0 -0
- /package/dist/{chunk-UBM3IM6K.js.map → chunk-5PVXFVIT.js.map} +0 -0
- /package/dist/{chunk-DNRVXHUW.js.map → chunk-5WFGW7B7.js.map} +0 -0
- /package/dist/{chunk-2PTBF6GM.js.map → chunk-5YMSLKJP.js.map} +0 -0
- /package/dist/{chunk-HZ5DTSAG.js.map → chunk-62EXH6FY.js.map} +0 -0
- /package/dist/{chunk-HWOYJOKK.js.map → chunk-62T2ZPD5.js.map} +0 -0
- /package/dist/{chunk-6ZJU2B3Z.js.map → chunk-634Q4QOS.js.map} +0 -0
- /package/dist/{chunk-PMBZMVKE.js.map → chunk-6CDBX3XG.js.map} +0 -0
- /package/dist/{chunk-R6CFPY3F.js.map → chunk-6D3D2JWY.js.map} +0 -0
- /package/dist/{chunk-OEOLXODE.js.map → chunk-6ENO634Y.js.map} +0 -0
- /package/dist/{chunk-IHX5BADQ.js.map → chunk-6LQ5KEMP.js.map} +0 -0
- /package/dist/{chunk-JXIBVYRA.js.map → chunk-6RESVGHF.js.map} +0 -0
- /package/dist/{chunk-EFBPHDPP.js.map → chunk-6WEDWD4N.js.map} +0 -0
- /package/dist/{chunk-HYFNKXHR.js.map → chunk-76VXLTQF.js.map} +0 -0
- /package/dist/{chunk-Y3ME7IF6.js.map → chunk-7MF6MFHS.js.map} +0 -0
- /package/dist/{chunk-5CEQ356Z.js.map → chunk-7VAILBP6.js.map} +0 -0
- /package/dist/{chunk-GGIPEZLL.js.map → chunk-A5GX3CAE.js.map} +0 -0
- /package/dist/{chunk-E45JRR3J.js.map → chunk-A7DS77WC.js.map} +0 -0
- /package/dist/{chunk-EJ6IIEZX.js.map → chunk-ANWMRO2G.js.map} +0 -0
- /package/dist/{chunk-EXBIL5BF.js.map → chunk-APGUIORF.js.map} +0 -0
- /package/dist/{chunk-FT3AUAXE.js.map → chunk-ASCVQJB4.js.map} +0 -0
- /package/dist/{chunk-4OGDD2EM.js.map → chunk-B6AH43UQ.js.map} +0 -0
- /package/dist/{chunk-5ZTVBNMS.js.map → chunk-BRZCHOKU.js.map} +0 -0
- /package/dist/{chunk-V6ZJKHVS.js.map → chunk-BUI7SHH6.js.map} +0 -0
- /package/dist/{chunk-4NXQWXQY.js.map → chunk-BVWJEZXG.js.map} +0 -0
- /package/dist/{chunk-BKJXUACP.js.map → chunk-BZ47G3VP.js.map} +0 -0
- /package/dist/{chunk-22SXRKET.js.map → chunk-C6KI5P3H.js.map} +0 -0
- /package/dist/{chunk-34LWIEIZ.js.map → chunk-CED3EPAV.js.map} +0 -0
- /package/dist/{chunk-CC2IVNVR.js.map → chunk-CNRFFCAE.js.map} +0 -0
- /package/dist/{chunk-WJ2STMQD.js.map → chunk-CPC6CYVW.js.map} +0 -0
- /package/dist/{chunk-KZQDP2JM.js.map → chunk-CVC4RO7D.js.map} +0 -0
- /package/dist/{chunk-754NH7T2.js.map → chunk-D4ADNM45.js.map} +0 -0
- /package/dist/{chunk-RJZALNT5.js.map → chunk-DJQ6TKIP.js.map} +0 -0
- /package/dist/{chunk-JY2UEPJP.js.map → chunk-DK2CDAMR.js.map} +0 -0
- /package/dist/{chunk-IBHUF5BN.js.map → chunk-DPOB6MUS.js.map} +0 -0
- /package/dist/{chunk-5H3SJHDT.js.map → chunk-DSO7S6PZ.js.map} +0 -0
- /package/dist/{chunk-3F45ELUO.js.map → chunk-DW2IQRMB.js.map} +0 -0
- /package/dist/{chunk-VHYDZMGS.js.map → chunk-DXMKECFR.js.map} +0 -0
- /package/dist/{chunk-44MYJQ72.js.map → chunk-DZLWO73N.js.map} +0 -0
- /package/dist/{chunk-J2GIGAVJ.js.map → chunk-E2GNUL64.js.map} +0 -0
- /package/dist/{chunk-QD6A4G7Y.js.map → chunk-E5TVYXJJ.js.map} +0 -0
- /package/dist/{chunk-YJYKB6ZT.js.map → chunk-E7XU2KHD.js.map} +0 -0
- /package/dist/{chunk-OZGECHF5.js.map → chunk-EM2HA2SH.js.map} +0 -0
- /package/dist/{chunk-N37BLJOI.js.map → chunk-EQQS6V5A.js.map} +0 -0
- /package/dist/{chunk-KI2TGJVH.js.map → chunk-EWHQ3DFM.js.map} +0 -0
- /package/dist/{chunk-4ST37B5I.js.map → chunk-F2T4J7CK.js.map} +0 -0
- /package/dist/{chunk-2NABGWXC.js.map → chunk-F5NFGBIN.js.map} +0 -0
- /package/dist/{chunk-5AHIKB3O.js.map → chunk-FXFOKD7A.js.map} +0 -0
- /package/dist/{chunk-4RGFBD4M.js.map → chunk-GCSUZGVC.js.map} +0 -0
- /package/dist/{chunk-HUKGLWAY.js.map → chunk-GIHE7U3Y.js.map} +0 -0
- /package/dist/{chunk-QD4J7AHU.js.map → chunk-GKDPNRQ4.js.map} +0 -0
- /package/dist/{chunk-TGAKM3WX.js.map → chunk-GKWFQEO3.js.map} +0 -0
- /package/dist/{chunk-Y6CNWBV3.js.map → chunk-GO5VIAA7.js.map} +0 -0
- /package/dist/{chunk-E5EICKKB.js.map → chunk-GQJAMANY.js.map} +0 -0
- /package/dist/{chunk-I2WTJMQF.js.map → chunk-HEPFJ3XQ.js.map} +0 -0
- /package/dist/{chunk-PTSRBKQC.js.map → chunk-HFROJDFQ.js.map} +0 -0
- /package/dist/{chunk-YP4SNX4P.js.map → chunk-HHFFPE67.js.map} +0 -0
- /package/dist/{chunk-TWSO5S3E.js.map → chunk-HLRAQITA.js.map} +0 -0
- /package/dist/{chunk-S2525GSA.js.map → chunk-HP7RE2U3.js.map} +0 -0
- /package/dist/{chunk-WT37FEG3.js.map → chunk-HYEG7I3Y.js.map} +0 -0
- /package/dist/{chunk-QEXHABRN.js.map → chunk-I7M5BYJU.js.map} +0 -0
- /package/dist/{chunk-F45CPW3Y.js.map → chunk-IWPPGXUZ.js.map} +0 -0
- /package/dist/{chunk-GHXIVKQH.js.map → chunk-JHSZSLVU.js.map} +0 -0
- /package/dist/{chunk-5AXIZJX4.js.map → chunk-JNPCRNPA.js.map} +0 -0
- /package/dist/{chunk-4R74CAIF.js.map → chunk-JPLHCRA7.js.map} +0 -0
- /package/dist/{chunk-DRVT6TRP.js.map → chunk-K5XFZKK5.js.map} +0 -0
- /package/dist/{chunk-QPA7ATJH.js.map → chunk-KA4PZU3Q.js.map} +0 -0
- /package/dist/{chunk-3UA2SOK2.js.map → chunk-KGZ35ESO.js.map} +0 -0
- /package/dist/{chunk-I7HYF6MQ.js.map → chunk-KNMM6WFD.js.map} +0 -0
- /package/dist/{chunk-NL7VJGFZ.js.map → chunk-KRM4PW5N.js.map} +0 -0
- /package/dist/{chunk-PCSRHFRF.js.map → chunk-KTGKGHEA.js.map} +0 -0
- /package/dist/{chunk-NUZNJSL5.js.map → chunk-KU77XHWB.js.map} +0 -0
- /package/dist/{chunk-XKJCFK2G.js.map → chunk-KYRHCY3I.js.map} +0 -0
- /package/dist/{chunk-VLDKWGHD.js.map → chunk-L6WVCO6D.js.map} +0 -0
- /package/dist/{chunk-F5C5T2PF.js.map → chunk-LLX4S6BI.js.map} +0 -0
- /package/dist/{chunk-TGG3ODCS.js.map → chunk-MCPKUVMQ.js.map} +0 -0
- /package/dist/{chunk-KYDLVMKA.js.map → chunk-MFLU3466.js.map} +0 -0
- /package/dist/{chunk-ZLKHNJCQ.js.map → chunk-MGWVWPFC.js.map} +0 -0
- /package/dist/{chunk-ZD67RM6G.js.map → chunk-MIUJ3EH5.js.map} +0 -0
- /package/dist/{chunk-M5FX5KH5.js.map → chunk-MO3XJQN2.js.map} +0 -0
- /package/dist/{chunk-XKLXYIIT.js.map → chunk-MRKY2GL5.js.map} +0 -0
- /package/dist/{chunk-4UAHTM3Q.js.map → chunk-MVE26JNL.js.map} +0 -0
- /package/dist/{chunk-2JR7LEST.js.map → chunk-MVGU7BET.js.map} +0 -0
- /package/dist/{chunk-5ERDSF2C.js.map → chunk-MVYQDBE6.js.map} +0 -0
- /package/dist/{chunk-GP7MYBSX.js.map → chunk-NFV76UYK.js.map} +0 -0
- /package/dist/{chunk-TMZ6RP3K.js.map → chunk-NGQCWCD6.js.map} +0 -0
- /package/dist/{chunk-AML5X74C.js.map → chunk-NKXMIOYN.js.map} +0 -0
- /package/dist/{chunk-VT5XHR5J.js.map → chunk-NMVRFFCR.js.map} +0 -0
- /package/dist/{chunk-6IIJ4H4O.js.map → chunk-NNTDIKJP.js.map} +0 -0
- /package/dist/{chunk-FARCOS2S.js.map → chunk-NOFZMGNM.js.map} +0 -0
- /package/dist/{chunk-MM4NP5QA.js.map → chunk-NQXCPP4G.js.map} +0 -0
- /package/dist/{chunk-UJNDUO7D.js.map → chunk-NRCZ3PSS.js.map} +0 -0
- /package/dist/{chunk-7MH4TTVE.js.map → chunk-NYGS6FNV.js.map} +0 -0
- /package/dist/{chunk-MIMSPOV4.js.map → chunk-O45WS2OY.js.map} +0 -0
- /package/dist/{chunk-COCLT77F.js.map → chunk-O5HRZ2KG.js.map} +0 -0
- /package/dist/{chunk-XMTBNLD2.js.map → chunk-O6QFY34B.js.map} +0 -0
- /package/dist/{chunk-LCRYAD3X.js.map → chunk-OBKDRV2H.js.map} +0 -0
- /package/dist/{chunk-PJ66EIWE.js.map → chunk-ODLFK2E4.js.map} +0 -0
- /package/dist/{chunk-WSQ3TCOX.js.map → chunk-ORRACKLB.js.map} +0 -0
- /package/dist/{chunk-BT5EOSQF.js.map → chunk-P3ODPHQW.js.map} +0 -0
- /package/dist/{chunk-2X7I6LXY.js.map → chunk-PAFSIDM2.js.map} +0 -0
- /package/dist/{chunk-F5RP42TL.js.map → chunk-PCSU2VOT.js.map} +0 -0
- /package/dist/{chunk-ZGBMDDFR.js.map → chunk-PGSXT5OY.js.map} +0 -0
- /package/dist/{chunk-LFQI2C46.js.map → chunk-PPQJIVGM.js.map} +0 -0
- /package/dist/{chunk-UFRXYZCJ.js.map → chunk-PYMQM65Y.js.map} +0 -0
- /package/dist/{chunk-PGMXITPB.js.map → chunk-QA5UNVHD.js.map} +0 -0
- /package/dist/{chunk-NLJEDAKV.js.map → chunk-QDMGUTOU.js.map} +0 -0
- /package/dist/{chunk-7456QZAA.js.map → chunk-QJ72YUT4.js.map} +0 -0
- /package/dist/{chunk-UBR3CGJC.js.map → chunk-QJRPA2DV.js.map} +0 -0
- /package/dist/{chunk-J4OOKDRV.js.map → chunk-QNOWKKZ4.js.map} +0 -0
- /package/dist/{chunk-PEAJRZU3.js.map → chunk-QRQGMYGU.js.map} +0 -0
- /package/dist/{chunk-WBNSC6RJ.js.map → chunk-QUFCZMHG.js.map} +0 -0
- /package/dist/{chunk-R2T4IUNB.js.map → chunk-QVOTPOXK.js.map} +0 -0
- /package/dist/{chunk-VRS6VNHP.js.map → chunk-QZE3KD34.js.map} +0 -0
- /package/dist/{chunk-IPFSFSIK.js.map → chunk-RACDLUKT.js.map} +0 -0
- /package/dist/{chunk-COIXX62I.js.map → chunk-RDLS6IZY.js.map} +0 -0
- /package/dist/{chunk-MSHWYGCH.js.map → chunk-RKPETJDJ.js.map} +0 -0
- /package/dist/{chunk-DKM3JBGJ.js.map → chunk-RLJ2LXXZ.js.map} +0 -0
- /package/dist/{chunk-GLBILBET.js.map → chunk-RMFNSJQI.js.map} +0 -0
- /package/dist/{chunk-RJWTAS4V.js.map → chunk-RR6DQN4X.js.map} +0 -0
- /package/dist/{chunk-TNE7ZYGN.js.map → chunk-RRH6ZX3F.js.map} +0 -0
- /package/dist/{chunk-7X443ZTQ.js.map → chunk-RVY5EZNU.js.map} +0 -0
- /package/dist/{chunk-MCXTYDFG.js.map → chunk-S7EO77EE.js.map} +0 -0
- /package/dist/{chunk-S3BLYPOG.js.map → chunk-SA4HJENC.js.map} +0 -0
- /package/dist/{chunk-ZJICGGPI.js.map → chunk-SMNBTDDD.js.map} +0 -0
- /package/dist/{chunk-SNACGK3Z.js.map → chunk-SRDHDIRQ.js.map} +0 -0
- /package/dist/{chunk-HUTQJY3F.js.map → chunk-SYYFA7W7.js.map} +0 -0
- /package/dist/{chunk-MAR5UYX4.js.map → chunk-T5BYEE66.js.map} +0 -0
- /package/dist/{chunk-HGS5JWZR.js.map → chunk-TLWH4E3P.js.map} +0 -0
- /package/dist/{chunk-7XZO4W76.js.map → chunk-TNHGSWG3.js.map} +0 -0
- /package/dist/{chunk-QHYLEJP7.js.map → chunk-U26OWALV.js.map} +0 -0
- /package/dist/{chunk-U2TOOZIY.js.map → chunk-U2CEPRDH.js.map} +0 -0
- /package/dist/{chunk-4PSB2CK7.js.map → chunk-UHRGUMLJ.js.map} +0 -0
- /package/dist/{chunk-CGVMECYX.js.map → chunk-UNDSD6UA.js.map} +0 -0
- /package/dist/{chunk-O4ZXJ52Z.js.map → chunk-UR25OGGM.js.map} +0 -0
- /package/dist/{chunk-SUXGKBCW.js.map → chunk-USU2SS4V.js.map} +0 -0
- /package/dist/{chunk-QMRHY45R.js.map → chunk-V4QFPYCN.js.map} +0 -0
- /package/dist/{chunk-FGHWU4LX.js.map → chunk-VALESBNH.js.map} +0 -0
- /package/dist/{chunk-XZLNVFB4.js.map → chunk-VMSMVWCJ.js.map} +0 -0
- /package/dist/{chunk-HRFAQYOA.js.map → chunk-VXPY2GF3.js.map} +0 -0
- /package/dist/{chunk-JTSLGUVP.js.map → chunk-W5CNXRSF.js.map} +0 -0
- /package/dist/{chunk-46UZ5ZYU.js.map → chunk-WEGZPK4I.js.map} +0 -0
- /package/dist/{chunk-WEPL76AR.js.map → chunk-X4OGMBY6.js.map} +0 -0
- /package/dist/{chunk-SXXWPTL7.js.map → chunk-X7HPRJM6.js.map} +0 -0
- /package/dist/{chunk-R6WQLIFX.js.map → chunk-XHF2XNU5.js.map} +0 -0
- /package/dist/{chunk-3PTEMOSW.js.map → chunk-XN6XMGMN.js.map} +0 -0
- /package/dist/{chunk-5ZUARMG2.js.map → chunk-XV4ZFOOG.js.map} +0 -0
- /package/dist/{chunk-3J6ENWZF.js.map → chunk-XVFRKZ3H.js.map} +0 -0
- /package/dist/{chunk-FWIV2FTX.js.map → chunk-Y2QYPJDN.js.map} +0 -0
- /package/dist/{chunk-GYHL6IRO.js.map → chunk-Y7PHZN5G.js.map} +0 -0
- /package/dist/{chunk-R6OBJ7LF.js.map → chunk-YAVW5OJ5.js.map} +0 -0
- /package/dist/{chunk-MXRCKJOQ.js.map → chunk-YLEMK4JY.js.map} +0 -0
- /package/dist/{chunk-F6D6X5ZU.js.map → chunk-YQ6FP33X.js.map} +0 -0
- /package/dist/{chunk-N556VQMT.js.map → chunk-YUA42N5A.js.map} +0 -0
- /package/dist/{chunk-IL6PCX7K.js.map → chunk-YXFNW64N.js.map} +0 -0
- /package/dist/{chunk-4SNYMZBC.js.map → chunk-Z76RJPZF.js.map} +0 -0
- /package/dist/{chunk-RA3NTKSW.js.map → chunk-Z7GGAA4L.js.map} +0 -0
- /package/dist/{chunk-YS6BQNHF.js.map → chunk-ZE4RD7U5.js.map} +0 -0
- /package/dist/{chunk-FHNBUDXL.js.map → chunk-ZOUCHIUE.js.map} +0 -0
- /package/dist/{chunk-F6LVPEBK.js.map → chunk-ZRNK6FK6.js.map} +0 -0
- /package/dist/{chunk-DP4MGOBG.js.map → chunk-ZSIKF2R3.js.map} +0 -0
- /package/dist/{chunk-MXSZQ6DP.js.map → chunk-ZVAIKQMC.js.map} +0 -0
- /package/dist/{chunk-AVIOWKKJ.js.map → chunk-ZZ3KNGTJ.js.map} +0 -0
- /package/dist/{computer-viewer-FHCBTSZH.js.map → computer-viewer-M5N3GWBR.js.map} +0 -0
- /package/dist/{connection-step-up-JLORUM6D.js.map → connection-step-up-5ZUYASTH.js.map} +0 -0
- /package/dist/{embedded-new-voice-BFTQZPJK.js.map → embedded-new-voice-QZJG5DZ3.js.map} +0 -0
- /package/dist/{embedded-voice-CQE2GO6Y.js.map → embedded-voice-7KOQNGKU.js.map} +0 -0
- /package/dist/{model-policy-picker-menu-PVBT2OZO.js.map → model-policy-picker-menu-UNI5B6N6.js.map} +0 -0
- /package/dist/{payment-page-card-YPCRVFHE.js.map → payment-page-card-Q4BEOZVN.js.map} +0 -0
- /package/dist/{platform-activity-row-ZWACJPNQ.js.map → platform-activity-row-NPEGG2VE.js.map} +0 -0
- /package/dist/{queue-surface-implementation-C7ESPZW7.js.map → queue-surface-implementation-RTCTPF5T.js.map} +0 -0
- /package/dist/{sandbox-files-6L2GRNOG.js.map → sandbox-files-BJKCREOU.js.map} +0 -0
- /package/dist/{session-connect-cards-2TRJ5IWB.js.map → session-connect-cards-DK3UJZRY.js.map} +0 -0
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import {
|
|
3
|
+
useSessionStartupState
|
|
4
|
+
} from "./chunk-D6LH6JPE.js";
|
|
2
5
|
import {
|
|
3
6
|
deniesRetainedView,
|
|
4
7
|
useRetainedSessionView
|
|
5
8
|
} from "./chunk-6CKSMBLT.js";
|
|
6
9
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
10
|
+
forgetSessionHumanInputDrafts,
|
|
11
|
+
pruneHumanInputDrafts
|
|
12
|
+
} from "./chunk-UYWVK7JQ.js";
|
|
9
13
|
import {
|
|
10
14
|
uploadScopeForSession,
|
|
11
15
|
useFileAttachments
|
|
@@ -20,39 +24,35 @@ import {
|
|
|
20
24
|
sessionStatusFromEvents,
|
|
21
25
|
useToolOutputReads
|
|
22
26
|
} from "./chunk-IYKO6BBK.js";
|
|
23
|
-
import {
|
|
24
|
-
forgetSessionHumanInputDrafts,
|
|
25
|
-
pruneHumanInputDrafts
|
|
26
|
-
} from "./chunk-UYWVK7JQ.js";
|
|
27
27
|
import {
|
|
28
28
|
useSharedQuery
|
|
29
29
|
} from "./chunk-DSQNSLQW.js";
|
|
30
30
|
import {
|
|
31
31
|
isActionableHumanInputRequest
|
|
32
32
|
} from "./chunk-57MB2QGY.js";
|
|
33
|
-
import {
|
|
34
|
-
admissionRecheckControl
|
|
35
|
-
} from "./chunk-MRNAHGBL.js";
|
|
36
33
|
import {
|
|
37
34
|
readAcknowledgementFrontier,
|
|
38
35
|
sessionAttentionReadThroughSequence
|
|
39
36
|
} from "./chunk-IOBL5KYR.js";
|
|
37
|
+
import {
|
|
38
|
+
useClientConfigFlags
|
|
39
|
+
} from "./chunk-XESA3B7W.js";
|
|
40
40
|
import {
|
|
41
41
|
promptSendDestination,
|
|
42
42
|
sessionArchived,
|
|
43
43
|
sessionTurnKeepsRunControl
|
|
44
44
|
} from "./chunk-DG5DQFS4.js";
|
|
45
45
|
import {
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
FILE_ONLY_MESSAGE_TEXT,
|
|
47
|
+
notifyObserver,
|
|
48
|
+
useComposer
|
|
49
|
+
} from "./chunk-HEPFJ3XQ.js";
|
|
48
50
|
import {
|
|
49
51
|
joinClientConfigRead
|
|
50
52
|
} from "./chunk-IGVL3ELX.js";
|
|
51
53
|
import {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
useComposer
|
|
55
|
-
} from "./chunk-I2WTJMQF.js";
|
|
54
|
+
admissionRecheckControl
|
|
55
|
+
} from "./chunk-MRNAHGBL.js";
|
|
56
56
|
import {
|
|
57
57
|
DEFAULT_TRANSIENT_READ_RETRY,
|
|
58
58
|
projectionReadThrough,
|
|
@@ -66,6 +66,13 @@ import {
|
|
|
66
66
|
import {
|
|
67
67
|
normalizeError
|
|
68
68
|
} from "./chunk-CM7LVUKC.js";
|
|
69
|
+
import {
|
|
70
|
+
coerceReasoningEffortForModel,
|
|
71
|
+
defaultEffortForModel,
|
|
72
|
+
projectPickerRows,
|
|
73
|
+
runnableLatencyModesForModel,
|
|
74
|
+
sortPickerRows
|
|
75
|
+
} from "./chunk-4VEIBNC2.js";
|
|
69
76
|
import {
|
|
70
77
|
useEmbeddedGoal,
|
|
71
78
|
useEmbeddedHumanInputSession,
|
|
@@ -74,88 +81,10 @@ import {
|
|
|
74
81
|
useOpenGeni,
|
|
75
82
|
useOpenGeniClient
|
|
76
83
|
} from "./chunk-BVUAHAQX.js";
|
|
77
|
-
import {
|
|
78
|
-
coerceReasoningEffortForModel,
|
|
79
|
-
defaultEffortForModel,
|
|
80
|
-
projectPickerRows,
|
|
81
|
-
runnableLatencyModesForModel,
|
|
82
|
-
sortPickerRows
|
|
83
|
-
} from "./chunk-4VEIBNC2.js";
|
|
84
84
|
import {
|
|
85
85
|
useOpenGeniText
|
|
86
86
|
} from "./chunk-2L6B6766.js";
|
|
87
87
|
|
|
88
|
-
// src/conversation-timeline.ts
|
|
89
|
-
function conversationTimeline(items, queue, composer) {
|
|
90
|
-
const queued = new Set(
|
|
91
|
-
queue.queue.filter((turn) => turn.metadata.delivery !== "steer").map((turn) => turn.triggerEventId)
|
|
92
|
-
);
|
|
93
|
-
const pending = composer.optimisticMessages ?? [];
|
|
94
|
-
const pendingQueue = new Set(
|
|
95
|
-
pending.filter(
|
|
96
|
-
(message) => message.destination === "queue" && !(message.turnId && message.appliedQueueVersion != null && queue.snapshot && queue.snapshot.version >= message.appliedQueueVersion && !queue.queue.some((turn) => turn.id === message.turnId))
|
|
97
|
-
).map((message) => `user-message:${message.clientEventId}`)
|
|
98
|
-
);
|
|
99
|
-
const visible = items.filter(
|
|
100
|
-
(item) => item.kind !== "user-message" || !queued.has(item.id) && !pendingQueue.has(item.reconciliationKey ?? "")
|
|
101
|
-
);
|
|
102
|
-
const keys = new Set(
|
|
103
|
-
visible.flatMap((item) => item.kind === "user-message" ? [item.reconciliationKey] : [])
|
|
104
|
-
);
|
|
105
|
-
const optimistic = pending.filter(
|
|
106
|
-
(message) => (message.destination === "chat" || message.state === "failed") && !keys.has(`user-message:${message.clientEventId}`) && !queue.queue.some((turn) => turn.id === message.turnId)
|
|
107
|
-
).map((message) => ({
|
|
108
|
-
kind: "user-message",
|
|
109
|
-
id: `optimistic:${message.clientEventId}`,
|
|
110
|
-
reconciliationKey: `user-message:${message.clientEventId}`,
|
|
111
|
-
text: message.text,
|
|
112
|
-
annotations: message.annotations.map((annotation, ordinal) => ({ ...annotation, ordinal })),
|
|
113
|
-
resources: message.resources,
|
|
114
|
-
tools: [],
|
|
115
|
-
occurredAt: message.occurredAt,
|
|
116
|
-
delivery: {
|
|
117
|
-
state: message.state,
|
|
118
|
-
...message.error ? { error: message.error } : {},
|
|
119
|
-
...message.state === "failed" ? {
|
|
120
|
-
...message.retryable !== false && composer.retryOptimisticMessage ? { onRetry: () => composer.retryOptimisticMessage?.(message.clientEventId) } : {},
|
|
121
|
-
...message.retryable === false && composer.restoreOptimisticMessage ? { onEdit: () => composer.restoreOptimisticMessage?.(message.clientEventId) } : {},
|
|
122
|
-
onRemove: () => composer.removeOptimisticMessage?.(message.clientEventId)
|
|
123
|
-
} : {}
|
|
124
|
-
}
|
|
125
|
-
}));
|
|
126
|
-
const failed = optimistic.filter((message) => message.delivery?.state === "failed");
|
|
127
|
-
const unsent = optimistic.filter((message) => message.delivery?.state !== "failed");
|
|
128
|
-
const ids = new Set(visible.map((item) => item.id));
|
|
129
|
-
const steers = (queue.acceptedSteers ?? []).filter((steer) => !ids.has(steer.triggerEventId)).map((steer) => ({
|
|
130
|
-
kind: "user-message",
|
|
131
|
-
id: steer.triggerEventId,
|
|
132
|
-
text: steer.text,
|
|
133
|
-
annotations: steer.annotations,
|
|
134
|
-
resources: steer.resources,
|
|
135
|
-
tools: steer.tools,
|
|
136
|
-
occurredAt: steer.occurredAt,
|
|
137
|
-
delivery: { state: steer.state }
|
|
138
|
-
}));
|
|
139
|
-
return [...placeFailedSends(visible, failed), ...unsent, ...steers];
|
|
140
|
-
}
|
|
141
|
-
function placeFailedSends(items, failed) {
|
|
142
|
-
if (failed.length === 0) return items;
|
|
143
|
-
const before = /* @__PURE__ */ new Map();
|
|
144
|
-
const last = [];
|
|
145
|
-
for (const message of failed) {
|
|
146
|
-
const sentAt = Date.parse(message.occurredAt);
|
|
147
|
-
const newer = items.findIndex(
|
|
148
|
-
(item) => item.kind === "user-message" && Date.parse(item.occurredAt) > sentAt
|
|
149
|
-
);
|
|
150
|
-
if (newer === -1) {
|
|
151
|
-
last.push(message);
|
|
152
|
-
} else {
|
|
153
|
-
before.set(newer, [...before.get(newer) ?? [], message]);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
return [...items.flatMap((item, index) => [...before.get(index) ?? [], item]), ...last];
|
|
157
|
-
}
|
|
158
|
-
|
|
159
88
|
// src/hooks/use-session.ts
|
|
160
89
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
161
90
|
|
|
@@ -316,882 +245,386 @@ function useSession(sessionId, options = {}) {
|
|
|
316
245
|
};
|
|
317
246
|
}
|
|
318
247
|
|
|
319
|
-
// src/
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
248
|
+
// src/older-history.ts
|
|
249
|
+
var activeReceiptCapture;
|
|
250
|
+
var preserveTailForAutomaticLoad = false;
|
|
251
|
+
function invokeOlderHistoryLoaderWithReceiptCapture(load, capture, preserveTail = false) {
|
|
252
|
+
const previousCapture = activeReceiptCapture;
|
|
253
|
+
const previousPreserveTail = preserveTailForAutomaticLoad;
|
|
254
|
+
activeReceiptCapture = capture;
|
|
255
|
+
preserveTailForAutomaticLoad = preserveTail;
|
|
256
|
+
try {
|
|
257
|
+
return load();
|
|
258
|
+
} finally {
|
|
259
|
+
activeReceiptCapture = previousCapture;
|
|
260
|
+
preserveTailForAutomaticLoad = previousPreserveTail;
|
|
261
|
+
}
|
|
325
262
|
}
|
|
326
|
-
function
|
|
327
|
-
|
|
263
|
+
function createOlderHistoryLoadReceipt(load) {
|
|
264
|
+
let resolveResult;
|
|
265
|
+
let rejectResult;
|
|
266
|
+
const result = new Promise((resolve, reject) => {
|
|
267
|
+
resolveResult = resolve;
|
|
268
|
+
rejectResult = reject;
|
|
269
|
+
});
|
|
270
|
+
result.committed = false;
|
|
271
|
+
result.tailPreserved = false;
|
|
272
|
+
activeReceiptCapture?.(result);
|
|
273
|
+
try {
|
|
274
|
+
const loaded = load(
|
|
275
|
+
() => {
|
|
276
|
+
result.committed = true;
|
|
277
|
+
},
|
|
278
|
+
preserveTailForAutomaticLoad,
|
|
279
|
+
() => {
|
|
280
|
+
result.tailPreserved = true;
|
|
281
|
+
}
|
|
282
|
+
);
|
|
283
|
+
Promise.resolve(loaded).then(resolveResult, rejectResult);
|
|
284
|
+
} catch (error) {
|
|
285
|
+
rejectResult(error);
|
|
286
|
+
}
|
|
287
|
+
return result;
|
|
328
288
|
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
if (
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
289
|
+
|
|
290
|
+
// src/hooks/use-session-events.ts
|
|
291
|
+
import {
|
|
292
|
+
isPresentedSessionToolCall,
|
|
293
|
+
isRetryableStreamError,
|
|
294
|
+
isSessionModelResponsePhase,
|
|
295
|
+
isTransientRequestError,
|
|
296
|
+
SESSION_EVENT_COMPAT_EXCLUDED_STEP_TYPES,
|
|
297
|
+
SESSION_EVENT_CONTENT_STEP_TYPES,
|
|
298
|
+
SESSION_EVENT_CONVERSATION_FILTER_VERSION,
|
|
299
|
+
SESSION_EVENT_STEP_TYPES,
|
|
300
|
+
sessionEventStreamCoveredThrough
|
|
301
|
+
} from "@opengeni/sdk";
|
|
302
|
+
import { startTransition, useCallback as useCallback3, useEffect as useEffect2, useMemo as useMemo2, useRef as useRef2, useState as useState2 } from "react";
|
|
303
|
+
|
|
304
|
+
// src/hooks/page-wake.ts
|
|
305
|
+
var PAGE_WAKE_CHECK_INTERVAL_MS = 2e3;
|
|
306
|
+
var PAGE_WAKE_GAP_MS = 15e3;
|
|
307
|
+
var listeners = /* @__PURE__ */ new Set();
|
|
308
|
+
var stopDetector = null;
|
|
309
|
+
function subscribePageWake(listener) {
|
|
310
|
+
listeners.add(listener);
|
|
311
|
+
stopDetector ??= startDetector();
|
|
312
|
+
return () => {
|
|
313
|
+
listeners.delete(listener);
|
|
314
|
+
if (listeners.size === 0 && stopDetector) {
|
|
315
|
+
stopDetector();
|
|
316
|
+
stopDetector = null;
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
function emitPageWake() {
|
|
321
|
+
for (const listener of [...listeners]) {
|
|
322
|
+
try {
|
|
323
|
+
listener();
|
|
324
|
+
} catch {
|
|
359
325
|
}
|
|
360
|
-
if ([
|
|
361
|
-
"turn.started",
|
|
362
|
-
"turn.completed",
|
|
363
|
-
"turn.failed",
|
|
364
|
-
"turn.cancelled",
|
|
365
|
-
"turn.superseded"
|
|
366
|
-
].includes(event.type) || event.type === "session.queue.changed" && ["edit", "delete"].includes(String(payload.operation)))
|
|
367
|
-
claimed.add(turnId2);
|
|
368
|
-
if ((event.type === "turn.queued" || event.type === "user.message") && payload.routing === "accepted_for_execution" && (session.status !== "idle" || event.sequence > session.lastSequence))
|
|
369
|
-
pending.set(turnId2, event.occurredAt);
|
|
370
|
-
}
|
|
371
|
-
for (const message of optimisticMessages ?? []) {
|
|
372
|
-
if (message.state === "queued" && message.destination === "chat" && message.delivery === "send" && message.turnId && !pending.has(message.turnId) && (session.status !== "idle" || message.appliedQueueVersion != null && message.appliedQueueVersion > session.queueVersion))
|
|
373
|
-
pending.set(message.turnId, message.occurredAt);
|
|
374
326
|
}
|
|
375
|
-
const head = input.queue && input.queue.version >= queueVersion ? input.queue.items[0] : null;
|
|
376
|
-
if (session.status === "queued" && !session.activeTurnId && head && !pending.has(head.id))
|
|
377
|
-
pending.set(
|
|
378
|
-
head.id,
|
|
379
|
-
previousTurnEndedAt && previousTurnEndedAt > head.createdAt ? previousTurnEndedAt : head.createdAt
|
|
380
|
-
);
|
|
381
|
-
const candidate = [...pending].find(
|
|
382
|
-
([turnId2]) => !claimed.has(turnId2) && (!session.activeTurnId || session.activeTurnId === turnId2) && (!observedActiveTurn || observedActiveTurn === turnId2) && !items.some((item) => "turnId" in item && item.turnId === turnId2)
|
|
383
|
-
);
|
|
384
|
-
const fallback = !candidate && !newerProgress && session.status === "queued" && !session.activeTurnId && input.fallbackStartedAt;
|
|
385
|
-
if (!candidate && !fallback) return items;
|
|
386
|
-
const [turnId, startedAt] = candidate ?? [
|
|
387
|
-
`pending-startup:${session.id}`,
|
|
388
|
-
input.fallbackStartedAt
|
|
389
|
-
];
|
|
390
|
-
return [
|
|
391
|
-
...items,
|
|
392
|
-
{
|
|
393
|
-
kind: "startup-phase",
|
|
394
|
-
id: `${turnId}-queue`,
|
|
395
|
-
turnId,
|
|
396
|
-
phase: "queue",
|
|
397
|
-
status: "running",
|
|
398
|
-
startedAt,
|
|
399
|
-
occurredAt: startedAt,
|
|
400
|
-
completedAt: null,
|
|
401
|
-
durationMs: null,
|
|
402
|
-
outcome: null,
|
|
403
|
-
...session.activeTurnId ? {} : { dispatchWait: session.status === "queued" ? session.dispatchWait ?? null : null }
|
|
404
|
-
}
|
|
405
|
-
];
|
|
406
327
|
}
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
328
|
+
function startDetector() {
|
|
329
|
+
if (typeof window === "undefined" || typeof document === "undefined") return () => {
|
|
330
|
+
};
|
|
331
|
+
let lastTick = Date.now();
|
|
332
|
+
const check = () => {
|
|
333
|
+
const now = Date.now();
|
|
334
|
+
const elapsed = now - lastTick;
|
|
335
|
+
lastTick = now;
|
|
336
|
+
if (elapsed > PAGE_WAKE_GAP_MS) emitPageWake();
|
|
337
|
+
};
|
|
338
|
+
const onVisibility = () => {
|
|
339
|
+
if (document.visibilityState !== "hidden") check();
|
|
340
|
+
};
|
|
341
|
+
const onPageShow = (event) => {
|
|
342
|
+
lastTick = Date.now();
|
|
343
|
+
if (event?.persisted === true) emitPageWake();
|
|
344
|
+
};
|
|
345
|
+
const onResume = () => {
|
|
346
|
+
lastTick = Date.now();
|
|
347
|
+
emitPageWake();
|
|
348
|
+
};
|
|
349
|
+
const timer = setInterval(check, PAGE_WAKE_CHECK_INTERVAL_MS);
|
|
350
|
+
document.addEventListener("visibilitychange", onVisibility);
|
|
351
|
+
document.addEventListener("resume", onResume);
|
|
352
|
+
window.addEventListener("pageshow", onPageShow);
|
|
353
|
+
window.addEventListener("online", onResume);
|
|
354
|
+
return () => {
|
|
355
|
+
clearInterval(timer);
|
|
356
|
+
document.removeEventListener("visibilitychange", onVisibility);
|
|
357
|
+
document.removeEventListener("resume", onResume);
|
|
358
|
+
window.removeEventListener("pageshow", onPageShow);
|
|
359
|
+
window.removeEventListener("online", onResume);
|
|
360
|
+
};
|
|
432
361
|
}
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
};
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
}
|
|
451
|
-
const scope = `${input.session.workspaceId}:${input.session.id}`;
|
|
452
|
-
if (bridgeRef.current?.scope === PENDING_SCOPE)
|
|
453
|
-
bridgeRef.current = { ...bridgeRef.current, scope };
|
|
454
|
-
if (bridgeRef.current?.scope !== scope || input.hasNewer || input.session.effectiveControl.state !== "active" || !["queued", "running", "idle"].includes(input.session.status))
|
|
455
|
-
bridgeRef.current = null;
|
|
456
|
-
const boundTurn = bridgeRef.current?.turnId;
|
|
457
|
-
const settled = boundTurn && currentEvents(input.events).find(
|
|
458
|
-
(event) => event.turnId === boundTurn && ["turn.completed", "turn.failed", "turn.cancelled", "turn.superseded"].includes(event.type)
|
|
459
|
-
);
|
|
460
|
-
let fallbackStartedAt = bridgeRef.current?.turnId === null ? bridgeRef.current.since : startup?.startedAt;
|
|
461
|
-
if (settled) {
|
|
462
|
-
bridgeRef.current = null;
|
|
463
|
-
fallbackStartedAt = input.session.status === "queued" && input.session.lastSequence >= settled.sequence ? input.session.updatedAt : void 0;
|
|
464
|
-
}
|
|
465
|
-
const projected = sessionStartupTimeline(items, {
|
|
466
|
-
...input,
|
|
467
|
-
session: input.session,
|
|
468
|
-
fallbackStartedAt
|
|
469
|
-
});
|
|
470
|
-
if (projected !== items) {
|
|
471
|
-
const phase2 = projected.at(-1);
|
|
472
|
-
if (phase2.kind !== "startup-phase") return projected;
|
|
473
|
-
const turnId2 = phase2.turnId === `pending-startup:${input.session.id}` ? null : phase2.turnId;
|
|
474
|
-
let bridge2 = bridgeRef.current;
|
|
475
|
-
if (!bridge2 || bridge2.turnId && turnId2 && bridge2.turnId !== turnId2) {
|
|
476
|
-
bridge2 = {
|
|
477
|
-
scope,
|
|
478
|
-
id: phase2.id,
|
|
479
|
-
turnId: turnId2,
|
|
480
|
-
since: phase2.startedAt,
|
|
481
|
-
sequence: input.session.lastSequence
|
|
482
|
-
};
|
|
483
|
-
} else
|
|
484
|
-
bridge2 = {
|
|
485
|
-
...bridge2,
|
|
486
|
-
turnId: turnId2 ?? bridge2.turnId,
|
|
487
|
-
since: bridge2.since < phase2.startedAt ? bridge2.since : phase2.startedAt
|
|
488
|
-
};
|
|
489
|
-
bridgeRef.current = bridge2;
|
|
490
|
-
return [
|
|
491
|
-
...projected.slice(0, -1),
|
|
492
|
-
{ ...phase2, id: bridge2.id, startedAt: bridge2.since, occurredAt: bridge2.since }
|
|
493
|
-
];
|
|
494
|
-
}
|
|
495
|
-
const bridge = bridgeRef.current;
|
|
496
|
-
if (!bridge) return items;
|
|
497
|
-
if (input.session.status === "idle") {
|
|
498
|
-
bridgeRef.current = null;
|
|
499
|
-
return items;
|
|
500
|
-
}
|
|
501
|
-
const started = currentEvents(input.events).find(
|
|
502
|
-
(event) => event.type === "turn.started" && (bridge.turnId ? event.turnId === bridge.turnId : event.sequence > bridge.sequence)
|
|
503
|
-
);
|
|
504
|
-
const turnId = bridge.turnId ?? started?.turnId ?? input.session.activeTurnId;
|
|
505
|
-
const phase = items.find((item) => item.kind === "startup-phase" && item.turnId === turnId);
|
|
506
|
-
if (phase?.kind === "startup-phase") {
|
|
507
|
-
bridgeRef.current = { ...bridge, turnId };
|
|
508
|
-
return items.map(
|
|
509
|
-
(item) => item === phase ? {
|
|
510
|
-
...phase,
|
|
511
|
-
id: bridge.id,
|
|
512
|
-
loadingStartedAt: bridge.since < phase.startedAt ? bridge.since : phase.startedAt
|
|
513
|
-
} : item
|
|
514
|
-
);
|
|
515
|
-
}
|
|
516
|
-
if (turnId && (started || input.session.activeTurnId === turnId)) {
|
|
517
|
-
bridgeRef.current = { ...bridge, turnId };
|
|
518
|
-
return [
|
|
519
|
-
...items,
|
|
520
|
-
{
|
|
521
|
-
kind: "startup-phase",
|
|
522
|
-
id: bridge.id,
|
|
523
|
-
turnId,
|
|
524
|
-
phase: "queue",
|
|
525
|
-
status: "complete",
|
|
526
|
-
startedAt: bridge.since,
|
|
527
|
-
occurredAt: bridge.since,
|
|
528
|
-
completedAt: started?.occurredAt ?? input.session.updatedAt,
|
|
529
|
-
durationMs: null,
|
|
530
|
-
outcome: null
|
|
362
|
+
|
|
363
|
+
// src/hooks/turnless-output-gaps.ts
|
|
364
|
+
import { useCallback as useCallback2, useSyncExternalStore } from "react";
|
|
365
|
+
var MAX_IDLE_ENTRIES = 256;
|
|
366
|
+
var entries = /* @__PURE__ */ new Map();
|
|
367
|
+
function gapKey(workspaceId, sessionId) {
|
|
368
|
+
return `${workspaceId}\0${sessionId}`;
|
|
369
|
+
}
|
|
370
|
+
function gapEntry(key) {
|
|
371
|
+
let entry = entries.get(key);
|
|
372
|
+
if (!entry) {
|
|
373
|
+
entry = { generation: 0, listeners: /* @__PURE__ */ new Set() };
|
|
374
|
+
entries.set(key, entry);
|
|
375
|
+
if (entries.size > MAX_IDLE_ENTRIES) {
|
|
376
|
+
for (const [candidate, held] of entries) {
|
|
377
|
+
if (entries.size <= MAX_IDLE_ENTRIES) break;
|
|
378
|
+
if (candidate !== key && held.listeners.size === 0) entries.delete(candidate);
|
|
531
379
|
}
|
|
532
|
-
|
|
380
|
+
}
|
|
533
381
|
}
|
|
534
|
-
|
|
535
|
-
return items;
|
|
382
|
+
return entry;
|
|
536
383
|
}
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
const client = useOpenGeniClient(options);
|
|
542
|
-
const load = useCallback2(
|
|
543
|
-
async (signal) => await client.getClientConfig({ signal }),
|
|
544
|
-
[client]
|
|
545
|
-
);
|
|
546
|
-
const state = useSharedQuery(client, ["available-models"], load, {
|
|
547
|
-
pollIntervalMs: options.pollIntervalMs,
|
|
548
|
-
enabled: options.enabled
|
|
549
|
-
});
|
|
550
|
-
return {
|
|
551
|
-
models: state.data?.models ?? [],
|
|
552
|
-
defaultModel: state.data?.defaultModel ?? null,
|
|
553
|
-
loading: state.loading,
|
|
554
|
-
error: state.error,
|
|
555
|
-
refresh: state.refresh
|
|
556
|
-
};
|
|
384
|
+
function markTurnlessOutputGap(workspaceId, sessionId) {
|
|
385
|
+
const entry = gapEntry(gapKey(workspaceId, sessionId));
|
|
386
|
+
entry.generation += 1;
|
|
387
|
+
for (const listener of [...entry.listeners]) listener();
|
|
557
388
|
}
|
|
558
|
-
function
|
|
559
|
-
const
|
|
560
|
-
const
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
// Joins the same workspace's config read already in flight (for
|
|
569
|
-
// example the composer's voice availability).
|
|
570
|
-
joinClientConfigRead(client, options.workspaceId)
|
|
571
|
-
]);
|
|
572
|
-
return {
|
|
573
|
-
models: catalog.models,
|
|
574
|
-
defaultModel: config.defaultModel
|
|
389
|
+
function useTurnlessOutputGap(workspaceId, sessionId) {
|
|
390
|
+
const key = sessionId ? gapKey(workspaceId, sessionId) : null;
|
|
391
|
+
const subscribe = useCallback2(
|
|
392
|
+
(listener) => {
|
|
393
|
+
if (!key) return () => {
|
|
394
|
+
};
|
|
395
|
+
const entry = gapEntry(key);
|
|
396
|
+
entry.listeners.add(listener);
|
|
397
|
+
return () => {
|
|
398
|
+
entry.listeners.delete(listener);
|
|
575
399
|
};
|
|
576
400
|
},
|
|
577
|
-
[
|
|
401
|
+
[key]
|
|
578
402
|
);
|
|
579
|
-
const
|
|
580
|
-
|
|
581
|
-
enabled: options.enabled !== false && Boolean(options.workspaceId)
|
|
582
|
-
});
|
|
583
|
-
const rows = sortPickerRows(projectPickerRows(t, state.data?.models ?? []));
|
|
584
|
-
return {
|
|
585
|
-
models: state.data?.models ?? [],
|
|
586
|
-
rows,
|
|
587
|
-
defaultModel: state.data?.defaultModel ?? null,
|
|
588
|
-
loading: state.loading,
|
|
589
|
-
error: state.error,
|
|
590
|
-
refresh: state.refresh
|
|
591
|
-
};
|
|
403
|
+
const read = useCallback2(() => key ? entries.get(key)?.generation ?? 0 : 0, [key]);
|
|
404
|
+
return useSyncExternalStore(subscribe, read, read);
|
|
592
405
|
}
|
|
593
406
|
|
|
594
|
-
// src/hooks/use-
|
|
595
|
-
import {
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
const
|
|
628
|
-
const
|
|
629
|
-
const
|
|
630
|
-
const
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
const
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
...options.events !== void 0 ? { events: options.events } : {},
|
|
643
|
-
readThrough: projectionReadThrough(state.data, state.loading),
|
|
644
|
-
refresh: scheduleRefresh
|
|
645
|
-
});
|
|
646
|
-
const retainedRequests = useRetainedSessionView(
|
|
647
|
-
client,
|
|
648
|
-
workspaceId,
|
|
649
|
-
sessionId,
|
|
650
|
-
"human-input",
|
|
651
|
-
state.data,
|
|
652
|
-
{ enabled, discard: deniesRetainedView(state.error) }
|
|
407
|
+
// src/hooks/use-session-events.ts
|
|
408
|
+
import { errorMessage } from "@opengeni/contracts/values";
|
|
409
|
+
var SESSION_FIRST_WINDOW_PAGE_SIZE = 255;
|
|
410
|
+
var SESSION_HISTORY_PAGE_SIZE = 1e3;
|
|
411
|
+
var INITIAL_FETCH_CAP = 1;
|
|
412
|
+
var OLDER_GROUP_TARGET = 32;
|
|
413
|
+
var OLDER_FETCH_CAP = 2;
|
|
414
|
+
var NEWER_GROUP_TARGET = 32;
|
|
415
|
+
var NEWER_FETCH_CAP = 2;
|
|
416
|
+
var OLDEST_GROUP_TARGET = 32;
|
|
417
|
+
var OLDEST_FETCH_CAP = 2;
|
|
418
|
+
var BOUNDARY_PAGE_CAP = 1;
|
|
419
|
+
var FILTERED_PAGE_CAP = 32;
|
|
420
|
+
var DIRECT_REPLAY_MAX_SEQUENCES = 16;
|
|
421
|
+
var CATCHUP_MAX_PAGES = 2;
|
|
422
|
+
var STRICT_REJOIN_ATTEMPTS = 5;
|
|
423
|
+
var REJOIN_STALL_TIMEOUT_MS = 3e4;
|
|
424
|
+
var FOREGROUND_REJOIN_RETRY_MS = 500;
|
|
425
|
+
var FOREGROUND_REJOIN_RETRY_MAX_MS = 8e3;
|
|
426
|
+
var EMPTY_EVENTS = [];
|
|
427
|
+
var encoder = new TextEncoder();
|
|
428
|
+
var SESSION_EVENT_BROWSER_MAX_BYTES = 16 * 1024 * 1024;
|
|
429
|
+
var SESSION_EVENT_BROWSER_MAX_COUNT = 2e4;
|
|
430
|
+
var SESSION_EVENT_BROWSER_PENDING_MAX_BYTES = 1024 * 1024;
|
|
431
|
+
var SESSION_EVENT_BROWSER_PENDING_MAX_COUNT = 256;
|
|
432
|
+
var EMPTY_EVENT_WINDOW = {
|
|
433
|
+
events: EMPTY_EVENTS,
|
|
434
|
+
bytes: 2,
|
|
435
|
+
truncated: false
|
|
436
|
+
};
|
|
437
|
+
function useSessionEvents(sessionId, options = {}) {
|
|
438
|
+
const t = useOpenGeniText();
|
|
439
|
+
const { client, workspaceId, reconcileSession } = useEmbeddedSession(options);
|
|
440
|
+
const enabled = options.enabled ?? true;
|
|
441
|
+
const pageLive = usePageLiveActivity();
|
|
442
|
+
const streamEnabled = enabled && pageLive;
|
|
443
|
+
const after = options.after ?? 0;
|
|
444
|
+
const replay = options.replay ?? "windowed";
|
|
445
|
+
const fullReplay = replay === "full" || after !== 0;
|
|
446
|
+
const streamKey = `${workspaceId}\0${sessionId ?? ""}\0${after}\0${fullReplay ? "full" : "windowed"}`;
|
|
447
|
+
const navigationIdentityRef = useRef2({ client, streamKey, enabled });
|
|
448
|
+
if (navigationIdentityRef.current.client !== client || navigationIdentityRef.current.streamKey !== streamKey || navigationIdentityRef.current.enabled !== enabled) {
|
|
449
|
+
navigationIdentityRef.current = { client, streamKey, enabled };
|
|
450
|
+
}
|
|
451
|
+
const navigationIdentity = navigationIdentityRef.current;
|
|
452
|
+
const ownsNavigation = useCallback3(
|
|
453
|
+
() => navigationIdentityRef.current === navigationIdentity,
|
|
454
|
+
[navigationIdentity]
|
|
653
455
|
);
|
|
456
|
+
const [eventWindow, setEventWindow] = useState2(EMPTY_EVENT_WINDOW);
|
|
457
|
+
const [questionEvidence, setQuestionEvidence] = useState2(null);
|
|
458
|
+
const [connectionState, setConnectionState] = useState2("idle");
|
|
459
|
+
const [error, setError] = useState2(null);
|
|
460
|
+
const [newerError, setNewerError] = useState2(null);
|
|
461
|
+
const [hasOlder, setHasOlder] = useState2(false);
|
|
462
|
+
const [hasNewer, setHasNewer] = useState2(false);
|
|
463
|
+
const [sessionStatusProjection, setSessionStatusProjection] = useState2(
|
|
464
|
+
null
|
|
465
|
+
);
|
|
466
|
+
const [initialLoading, setInitialLoading] = useState2(true);
|
|
467
|
+
const [initialHistoryReady, setInitialHistoryReady] = useState2(false);
|
|
468
|
+
const [loadingOlder, setLoadingOlder] = useState2(false);
|
|
469
|
+
const [loadingNewer, setLoadingNewer] = useState2(false);
|
|
470
|
+
const [loadingOldest, setLoadingOldest] = useState2(false);
|
|
471
|
+
const [loadingLatest, setLoadingLatest] = useState2(false);
|
|
472
|
+
const [loadingTarget, setLoadingTarget] = useState2(false);
|
|
473
|
+
const loadingTargetRef = useRef2(false);
|
|
474
|
+
const [streamEpoch, setStreamEpoch] = useState2(0);
|
|
475
|
+
const [viewMode, setViewMode] = useState2("live");
|
|
476
|
+
const lastSequenceRef = useRef2(after);
|
|
477
|
+
const streamResumeSequenceRef = useRef2(after);
|
|
478
|
+
const skippedStepsThroughRef = useRef2(null);
|
|
479
|
+
const oldestSequenceRef = useRef2(null);
|
|
480
|
+
const newestSequenceRef = useRef2(null);
|
|
481
|
+
const hasOlderRef = useRef2(false);
|
|
482
|
+
const hasNewerRef = useRef2(false);
|
|
483
|
+
const loadingOlderRef = useRef2(false);
|
|
484
|
+
const loadingNewerRef = useRef2(false);
|
|
485
|
+
const loadingOldestRef = useRef2(false);
|
|
486
|
+
const loadingLatestRef = useRef2(false);
|
|
487
|
+
const viewModeRef = useRef2("live");
|
|
488
|
+
const initialWindowLoadedRef = useRef2(false);
|
|
489
|
+
const openedStreamKeyRef = useRef2(null);
|
|
490
|
+
const reconcileAfterPageResumeRef = useRef2(false);
|
|
491
|
+
const streamAbortRef = useRef2(null);
|
|
492
|
+
const streamKeyRef = useRef2(null);
|
|
493
|
+
const generationRef = useRef2(0);
|
|
494
|
+
const navigationGenerationRef = useRef2(0);
|
|
495
|
+
const eventWindowRef = useRef2(EMPTY_EVENT_WINDOW);
|
|
496
|
+
const sessionStatusRef = useRef2({
|
|
497
|
+
sequence: after,
|
|
498
|
+
status: null
|
|
499
|
+
});
|
|
500
|
+
const [stateStreamKey, setStateStreamKey] = useState2(streamKey);
|
|
501
|
+
const historyFilter = fullReplay ? void 0 : CONVERSATION_FILTER;
|
|
502
|
+
const [stepStores, setStepStores] = useState2(EMPTY_STEP_STORES);
|
|
503
|
+
const stepStoresRef = useRef2(EMPTY_STEP_STORES);
|
|
504
|
+
const [turnlessSteps, setTurnlessSteps] = useState2(EMPTY_TURNLESS_STEPS);
|
|
505
|
+
const turnlessStepsRef = useRef2(EMPTY_TURNLESS_STEPS);
|
|
506
|
+
const renderedTurnlessRef = useRef2({ appended: 0, marked: false });
|
|
654
507
|
useEffect2(() => {
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
if (event) await state.refresh();
|
|
684
|
-
return event;
|
|
685
|
-
} finally {
|
|
686
|
-
if (respondingRequestRef.current === requestId) {
|
|
687
|
-
respondingRequestRef.current = null;
|
|
688
|
-
setRespondingRequestId(null);
|
|
508
|
+
renderedTurnlessRef.current = { appended: turnlessSteps.appended, marked: false };
|
|
509
|
+
}, [turnlessSteps]);
|
|
510
|
+
const liveThroughRef = useRef2(0);
|
|
511
|
+
const stepGenerationRef = useRef2(0);
|
|
512
|
+
const stepRequestRef = useRef2(0);
|
|
513
|
+
const retainedTurnsRef = useRef2(/* @__PURE__ */ new Map());
|
|
514
|
+
const turnStepHandlesRef = useRef2(/* @__PURE__ */ new Map());
|
|
515
|
+
const presentedCallIdsRef = useRef2(/* @__PURE__ */ new Set());
|
|
516
|
+
const presentedScanRef = useRef2(null);
|
|
517
|
+
const startupRef = useRef2(emptyStartupTurns());
|
|
518
|
+
const [presentedOutputs, setPresentedOutputs] = useState2(EMPTY_PRESENTED_OUTPUTS);
|
|
519
|
+
const presentedRequestedRef = useRef2(/* @__PURE__ */ new Map());
|
|
520
|
+
const presentedFailuresRef = useRef2(/* @__PURE__ */ new Map());
|
|
521
|
+
const [presentedPass, setPresentedPass] = useState2(0);
|
|
522
|
+
const rejoinPendingRef = useRef2(false);
|
|
523
|
+
const streamTransientStreakRef = useRef2(null);
|
|
524
|
+
const commitStepStores = useCallback3((next) => {
|
|
525
|
+
stepStoresRef.current = next;
|
|
526
|
+
setStepStores(next);
|
|
527
|
+
}, []);
|
|
528
|
+
const pruneStepStores = useCallback3(
|
|
529
|
+
(window2, sealedBy, rereading = null) => {
|
|
530
|
+
const present = windowTurns(window2);
|
|
531
|
+
const settled = sealedBy ? settledTurns(sealedBy) : null;
|
|
532
|
+
const next = /* @__PURE__ */ new Map();
|
|
533
|
+
for (const [turnId, store] of stepStoresRef.current) {
|
|
534
|
+
if (present.has(turnId) && (!settled || settled.has(turnId) || turnId === rereading)) {
|
|
535
|
+
next.set(turnId, store);
|
|
689
536
|
}
|
|
690
537
|
}
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
loading: state.loading && retainedRequests === null,
|
|
701
|
-
error: state.error,
|
|
702
|
-
refresh: state.refresh,
|
|
703
|
-
respond,
|
|
704
|
-
respondingRequestId,
|
|
705
|
-
mutationError: mutation.mutationError,
|
|
706
|
-
clearMutationError: mutation.clearMutationError
|
|
707
|
-
};
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
// src/hooks/use-session-control.ts
|
|
711
|
-
import { useCallback as useCallback4, useLayoutEffect, useRef as useRef4 } from "react";
|
|
712
|
-
function useSessionControl(sessionId, options = {}) {
|
|
713
|
-
const { client, workspaceId } = useEmbeddedSession(options);
|
|
714
|
-
const approvalTargetKey = `${workspaceId}\0${sessionId ?? ""}`;
|
|
715
|
-
const pendingApproval = useRef4(null);
|
|
716
|
-
useLayoutEffect(() => {
|
|
717
|
-
if (pendingApproval.current?.targetKey !== approvalTargetKey) {
|
|
718
|
-
pendingApproval.current = null;
|
|
719
|
-
}
|
|
720
|
-
}, [approvalTargetKey]);
|
|
721
|
-
const {
|
|
722
|
-
run: runControl,
|
|
723
|
-
mutating: controlling,
|
|
724
|
-
mutationError: controlError,
|
|
725
|
-
clearMutationError: clearControlError
|
|
726
|
-
} = useMutationRunner(approvalTargetKey);
|
|
727
|
-
const {
|
|
728
|
-
run: runApproval,
|
|
729
|
-
mutating: responding,
|
|
730
|
-
mutationError: approvalError,
|
|
731
|
-
clearMutationError: clearApprovalError
|
|
732
|
-
} = useMutationRunner(approvalTargetKey);
|
|
733
|
-
const pause = useCallback4(
|
|
734
|
-
async (reason) => {
|
|
735
|
-
if (!sessionId) {
|
|
736
|
-
return null;
|
|
737
|
-
}
|
|
738
|
-
return await runControl(
|
|
739
|
-
() => client.pauseSession(workspaceId, sessionId, reason !== void 0 ? { reason } : {})
|
|
740
|
-
);
|
|
741
|
-
},
|
|
742
|
-
[client, workspaceId, sessionId, runControl]
|
|
743
|
-
);
|
|
744
|
-
const resume = useCallback4(
|
|
745
|
-
async (reason) => {
|
|
746
|
-
if (!sessionId) return null;
|
|
747
|
-
return await runControl(
|
|
748
|
-
() => client.resumeSession(workspaceId, sessionId, reason !== void 0 ? { reason } : {})
|
|
749
|
-
);
|
|
750
|
-
},
|
|
751
|
-
[client, workspaceId, sessionId, runControl]
|
|
752
|
-
);
|
|
753
|
-
const decide = useCallback4(
|
|
754
|
-
async (approvalId, decision, message, answer, decisionOptions = {}) => {
|
|
755
|
-
if (!sessionId) {
|
|
756
|
-
return null;
|
|
757
|
-
}
|
|
758
|
-
const decisionKey = JSON.stringify([approvalId, decision, message ?? null, answer ?? null]);
|
|
759
|
-
if (pendingApproval.current?.decisionKey !== decisionKey) {
|
|
760
|
-
pendingApproval.current = {
|
|
761
|
-
targetKey: approvalTargetKey,
|
|
762
|
-
decisionKey,
|
|
763
|
-
clientEventId: crypto.randomUUID()
|
|
764
|
-
};
|
|
538
|
+
if (next.size !== stepStoresRef.current.size) commitStepStores(next);
|
|
539
|
+
if (sealedBy) {
|
|
540
|
+
presentedRequestedRef.current = /* @__PURE__ */ new Map();
|
|
541
|
+
} else {
|
|
542
|
+
for (const [callId, request] of presentedRequestedRef.current) {
|
|
543
|
+
if (request.turnId && !present.has(request.turnId)) {
|
|
544
|
+
presentedRequestedRef.current.delete(callId);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
765
547
|
}
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
decision,
|
|
773
|
-
...message !== void 0 ? { message } : {},
|
|
774
|
-
...answer !== void 0 ? answer : {},
|
|
775
|
-
clientEventId
|
|
776
|
-
});
|
|
777
|
-
} catch (cause) {
|
|
778
|
-
refusal = { cause };
|
|
779
|
-
throw cause;
|
|
548
|
+
setPresentedOutputs((current) => {
|
|
549
|
+
let kept = null;
|
|
550
|
+
for (const [callId, output] of current) {
|
|
551
|
+
if (output.turnId && present.has(output.turnId)) continue;
|
|
552
|
+
kept ??= new Map(current);
|
|
553
|
+
kept.delete(callId);
|
|
780
554
|
}
|
|
555
|
+
return kept ?? current;
|
|
781
556
|
});
|
|
782
|
-
if (decisionOptions.throwOnError && refusal) throw refusal.cause;
|
|
783
|
-
if (accepted !== null && pendingApproval.current?.targetKey === approvalTargetKey && pendingApproval.current.clientEventId === clientEventId) {
|
|
784
|
-
pendingApproval.current = null;
|
|
785
|
-
}
|
|
786
|
-
return accepted;
|
|
787
557
|
},
|
|
788
|
-
[
|
|
789
|
-
);
|
|
790
|
-
const approve = useCallback4(
|
|
791
|
-
async (approvalId, message, answer, decisionOptions) => await decide(approvalId, "approve", message, answer, decisionOptions),
|
|
792
|
-
[decide]
|
|
558
|
+
[commitStepStores]
|
|
793
559
|
);
|
|
794
|
-
const
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
pause,
|
|
805
|
-
resume,
|
|
806
|
-
controlling,
|
|
807
|
-
approve,
|
|
808
|
-
reject,
|
|
809
|
-
responding,
|
|
810
|
-
error,
|
|
811
|
-
clearError
|
|
812
|
-
};
|
|
813
|
-
}
|
|
814
|
-
|
|
815
|
-
// src/older-history.ts
|
|
816
|
-
var activeReceiptCapture;
|
|
817
|
-
var preserveTailForAutomaticLoad = false;
|
|
818
|
-
function invokeOlderHistoryLoaderWithReceiptCapture(load, capture, preserveTail = false) {
|
|
819
|
-
const previousCapture = activeReceiptCapture;
|
|
820
|
-
const previousPreserveTail = preserveTailForAutomaticLoad;
|
|
821
|
-
activeReceiptCapture = capture;
|
|
822
|
-
preserveTailForAutomaticLoad = preserveTail;
|
|
823
|
-
try {
|
|
824
|
-
return load();
|
|
825
|
-
} finally {
|
|
826
|
-
activeReceiptCapture = previousCapture;
|
|
827
|
-
preserveTailForAutomaticLoad = previousPreserveTail;
|
|
828
|
-
}
|
|
829
|
-
}
|
|
830
|
-
function createOlderHistoryLoadReceipt(load) {
|
|
831
|
-
let resolveResult;
|
|
832
|
-
let rejectResult;
|
|
833
|
-
const result = new Promise((resolve, reject) => {
|
|
834
|
-
resolveResult = resolve;
|
|
835
|
-
rejectResult = reject;
|
|
836
|
-
});
|
|
837
|
-
result.committed = false;
|
|
838
|
-
result.tailPreserved = false;
|
|
839
|
-
activeReceiptCapture?.(result);
|
|
840
|
-
try {
|
|
841
|
-
const loaded = load(
|
|
842
|
-
() => {
|
|
843
|
-
result.committed = true;
|
|
844
|
-
},
|
|
845
|
-
preserveTailForAutomaticLoad,
|
|
846
|
-
() => {
|
|
847
|
-
result.tailPreserved = true;
|
|
560
|
+
const presentedCallIds = useCallback3((event) => {
|
|
561
|
+
const ids = presentedCallIdsRef.current;
|
|
562
|
+
if (event.type === "agent.toolCall.created") {
|
|
563
|
+
notePresentedCalls([event], ids);
|
|
564
|
+
} else if (event.type === "agent.toolCall.output") {
|
|
565
|
+
const payload = event.payload;
|
|
566
|
+
const windowEvents = eventWindowRef.current.events;
|
|
567
|
+
if (typeof payload?.id === "string" && !ids.has(payload.id) && presentedScanRef.current !== windowEvents) {
|
|
568
|
+
presentedScanRef.current = windowEvents;
|
|
569
|
+
notePresentedCalls(windowEvents, ids);
|
|
848
570
|
}
|
|
849
|
-
);
|
|
850
|
-
Promise.resolve(loaded).then(resolveResult, rejectResult);
|
|
851
|
-
} catch (error) {
|
|
852
|
-
rejectResult(error);
|
|
853
|
-
}
|
|
854
|
-
return result;
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
// src/hooks/use-session-events.ts
|
|
858
|
-
import {
|
|
859
|
-
isPresentedSessionToolCall,
|
|
860
|
-
isRetryableStreamError,
|
|
861
|
-
isSessionModelResponsePhase,
|
|
862
|
-
isTransientRequestError,
|
|
863
|
-
SESSION_EVENT_COMPAT_EXCLUDED_STEP_TYPES,
|
|
864
|
-
SESSION_EVENT_CONTENT_STEP_TYPES,
|
|
865
|
-
SESSION_EVENT_CONVERSATION_FILTER_VERSION,
|
|
866
|
-
SESSION_EVENT_STEP_TYPES,
|
|
867
|
-
sessionEventStreamCoveredThrough
|
|
868
|
-
} from "@opengeni/sdk";
|
|
869
|
-
import { startTransition, useCallback as useCallback6, useEffect as useEffect3, useMemo as useMemo2, useRef as useRef5, useState as useState3 } from "react";
|
|
870
|
-
|
|
871
|
-
// src/hooks/page-wake.ts
|
|
872
|
-
var PAGE_WAKE_CHECK_INTERVAL_MS = 2e3;
|
|
873
|
-
var PAGE_WAKE_GAP_MS = 15e3;
|
|
874
|
-
var listeners = /* @__PURE__ */ new Set();
|
|
875
|
-
var stopDetector = null;
|
|
876
|
-
function subscribePageWake(listener) {
|
|
877
|
-
listeners.add(listener);
|
|
878
|
-
stopDetector ??= startDetector();
|
|
879
|
-
return () => {
|
|
880
|
-
listeners.delete(listener);
|
|
881
|
-
if (listeners.size === 0 && stopDetector) {
|
|
882
|
-
stopDetector();
|
|
883
|
-
stopDetector = null;
|
|
884
571
|
}
|
|
885
|
-
|
|
886
|
-
}
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
572
|
+
return ids;
|
|
573
|
+
}, []);
|
|
574
|
+
const startupTurns = useCallback3(() => {
|
|
575
|
+
const windowEvents = eventWindowRef.current.events;
|
|
576
|
+
if (startupRef.current.window !== windowEvents) {
|
|
577
|
+
const state = emptyStartupTurns();
|
|
578
|
+
noteStartupTurns(windowEvents, state);
|
|
579
|
+
state.window = windowEvents;
|
|
580
|
+
startupRef.current = state;
|
|
892
581
|
}
|
|
893
|
-
|
|
894
|
-
}
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
};
|
|
908
|
-
const onPageShow = (event) => {
|
|
909
|
-
lastTick = Date.now();
|
|
910
|
-
if (event?.persisted === true) emitPageWake();
|
|
911
|
-
};
|
|
912
|
-
const onResume = () => {
|
|
913
|
-
lastTick = Date.now();
|
|
914
|
-
emitPageWake();
|
|
915
|
-
};
|
|
916
|
-
const timer = setInterval(check, PAGE_WAKE_CHECK_INTERVAL_MS);
|
|
917
|
-
document.addEventListener("visibilitychange", onVisibility);
|
|
918
|
-
document.addEventListener("resume", onResume);
|
|
919
|
-
window.addEventListener("pageshow", onPageShow);
|
|
920
|
-
window.addEventListener("online", onResume);
|
|
921
|
-
return () => {
|
|
922
|
-
clearInterval(timer);
|
|
923
|
-
document.removeEventListener("visibilitychange", onVisibility);
|
|
924
|
-
document.removeEventListener("resume", onResume);
|
|
925
|
-
window.removeEventListener("pageshow", onPageShow);
|
|
926
|
-
window.removeEventListener("online", onResume);
|
|
927
|
-
};
|
|
928
|
-
}
|
|
929
|
-
|
|
930
|
-
// src/hooks/turnless-output-gaps.ts
|
|
931
|
-
import { useCallback as useCallback5, useSyncExternalStore } from "react";
|
|
932
|
-
var MAX_IDLE_ENTRIES = 256;
|
|
933
|
-
var entries = /* @__PURE__ */ new Map();
|
|
934
|
-
function gapKey(workspaceId, sessionId) {
|
|
935
|
-
return `${workspaceId}\0${sessionId}`;
|
|
936
|
-
}
|
|
937
|
-
function gapEntry(key) {
|
|
938
|
-
let entry = entries.get(key);
|
|
939
|
-
if (!entry) {
|
|
940
|
-
entry = { generation: 0, listeners: /* @__PURE__ */ new Set() };
|
|
941
|
-
entries.set(key, entry);
|
|
942
|
-
if (entries.size > MAX_IDLE_ENTRIES) {
|
|
943
|
-
for (const [candidate, held] of entries) {
|
|
944
|
-
if (entries.size <= MAX_IDLE_ENTRIES) break;
|
|
945
|
-
if (candidate !== key && held.listeners.size === 0) entries.delete(candidate);
|
|
582
|
+
return startupRef.current;
|
|
583
|
+
}, []);
|
|
584
|
+
const appendLiveSteps = useCallback3(
|
|
585
|
+
(steps) => {
|
|
586
|
+
if (steps.some((event) => !event.turnId)) {
|
|
587
|
+
const incoming = steps.filter((event) => !event.turnId);
|
|
588
|
+
const turnless = appendTurnlessSteps(turnlessStepsRef.current, incoming);
|
|
589
|
+
const rendered = renderedTurnlessRef.current;
|
|
590
|
+
if (!rendered.marked && turnless.appended - rendered.appended > turnless.events.length) {
|
|
591
|
+
rendered.marked = true;
|
|
592
|
+
if (sessionId) markTurnlessOutputGap(workspaceId, sessionId);
|
|
593
|
+
}
|
|
594
|
+
turnlessStepsRef.current = turnless;
|
|
595
|
+
setTurnlessSteps(turnless);
|
|
946
596
|
}
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
597
|
+
const windowEvents = withTurnlessSteps(
|
|
598
|
+
eventWindowRef.current.events,
|
|
599
|
+
turnlessStepsRef.current
|
|
600
|
+
);
|
|
601
|
+
const next = new Map(stepStoresRef.current);
|
|
602
|
+
const now = Date.now();
|
|
603
|
+
for (const [turnId, events] of groupByTurn(steps)) {
|
|
604
|
+
const existing = next.get(turnId);
|
|
605
|
+
const store = existing ?? {
|
|
606
|
+
events: [],
|
|
607
|
+
bytes: 2,
|
|
608
|
+
// Earlier steps exist when the window skips sequences between the
|
|
609
|
+
// turn's start and this first live step.
|
|
610
|
+
hasOlder: turnHasHiddenSequences(windowEvents, turnId, events[0].sequence),
|
|
611
|
+
cursor: null,
|
|
612
|
+
floor: null,
|
|
613
|
+
pinned: null,
|
|
614
|
+
loading: false,
|
|
615
|
+
error: false,
|
|
616
|
+
touched: now,
|
|
617
|
+
requestId: 0
|
|
618
|
+
};
|
|
619
|
+
let updated = { ...store, ...appendStepEvents(store, events), touched: now };
|
|
620
|
+
if (!retainedTurnsRef.current.get(turnId)) updated = trimLiveStepTail(updated);
|
|
621
|
+
next.set(turnId, updated);
|
|
622
|
+
}
|
|
623
|
+
commitStepStores(boundStepStores(next, retainedTurnsRef.current));
|
|
967
624
|
},
|
|
968
|
-
[
|
|
625
|
+
[commitStepStores, workspaceId, sessionId]
|
|
969
626
|
);
|
|
970
|
-
const
|
|
971
|
-
return useSyncExternalStore(subscribe, read, read);
|
|
972
|
-
}
|
|
973
|
-
|
|
974
|
-
// src/hooks/use-session-events.ts
|
|
975
|
-
import { errorMessage } from "@opengeni/contracts/values";
|
|
976
|
-
var SESSION_FIRST_WINDOW_PAGE_SIZE = 255;
|
|
977
|
-
var SESSION_HISTORY_PAGE_SIZE = 1e3;
|
|
978
|
-
var INITIAL_FETCH_CAP = 1;
|
|
979
|
-
var OLDER_GROUP_TARGET = 32;
|
|
980
|
-
var OLDER_FETCH_CAP = 2;
|
|
981
|
-
var NEWER_GROUP_TARGET = 32;
|
|
982
|
-
var NEWER_FETCH_CAP = 2;
|
|
983
|
-
var OLDEST_GROUP_TARGET = 32;
|
|
984
|
-
var OLDEST_FETCH_CAP = 2;
|
|
985
|
-
var BOUNDARY_PAGE_CAP = 1;
|
|
986
|
-
var FILTERED_PAGE_CAP = 32;
|
|
987
|
-
var DIRECT_REPLAY_MAX_SEQUENCES = 16;
|
|
988
|
-
var CATCHUP_MAX_PAGES = 2;
|
|
989
|
-
var STRICT_REJOIN_ATTEMPTS = 5;
|
|
990
|
-
var REJOIN_STALL_TIMEOUT_MS = 3e4;
|
|
991
|
-
var FOREGROUND_REJOIN_RETRY_MS = 500;
|
|
992
|
-
var FOREGROUND_REJOIN_RETRY_MAX_MS = 8e3;
|
|
993
|
-
var EMPTY_EVENTS = [];
|
|
994
|
-
var encoder = new TextEncoder();
|
|
995
|
-
var SESSION_EVENT_BROWSER_MAX_BYTES = 16 * 1024 * 1024;
|
|
996
|
-
var SESSION_EVENT_BROWSER_MAX_COUNT = 2e4;
|
|
997
|
-
var SESSION_EVENT_BROWSER_PENDING_MAX_BYTES = 1024 * 1024;
|
|
998
|
-
var SESSION_EVENT_BROWSER_PENDING_MAX_COUNT = 256;
|
|
999
|
-
var EMPTY_EVENT_WINDOW = {
|
|
1000
|
-
events: EMPTY_EVENTS,
|
|
1001
|
-
bytes: 2,
|
|
1002
|
-
truncated: false
|
|
1003
|
-
};
|
|
1004
|
-
function useSessionEvents(sessionId, options = {}) {
|
|
1005
|
-
const t = useOpenGeniText();
|
|
1006
|
-
const { client, workspaceId, reconcileSession } = useEmbeddedSession(options);
|
|
1007
|
-
const enabled = options.enabled ?? true;
|
|
1008
|
-
const pageLive = usePageLiveActivity();
|
|
1009
|
-
const streamEnabled = enabled && pageLive;
|
|
1010
|
-
const after = options.after ?? 0;
|
|
1011
|
-
const replay = options.replay ?? "windowed";
|
|
1012
|
-
const fullReplay = replay === "full" || after !== 0;
|
|
1013
|
-
const streamKey = `${workspaceId}\0${sessionId ?? ""}\0${after}\0${fullReplay ? "full" : "windowed"}`;
|
|
1014
|
-
const navigationIdentityRef = useRef5({ client, streamKey, enabled });
|
|
1015
|
-
if (navigationIdentityRef.current.client !== client || navigationIdentityRef.current.streamKey !== streamKey || navigationIdentityRef.current.enabled !== enabled) {
|
|
1016
|
-
navigationIdentityRef.current = { client, streamKey, enabled };
|
|
1017
|
-
}
|
|
1018
|
-
const navigationIdentity = navigationIdentityRef.current;
|
|
1019
|
-
const ownsNavigation = useCallback6(
|
|
1020
|
-
() => navigationIdentityRef.current === navigationIdentity,
|
|
1021
|
-
[navigationIdentity]
|
|
1022
|
-
);
|
|
1023
|
-
const [eventWindow, setEventWindow] = useState3(EMPTY_EVENT_WINDOW);
|
|
1024
|
-
const [questionEvidence, setQuestionEvidence] = useState3(null);
|
|
1025
|
-
const [connectionState, setConnectionState] = useState3("idle");
|
|
1026
|
-
const [error, setError] = useState3(null);
|
|
1027
|
-
const [newerError, setNewerError] = useState3(null);
|
|
1028
|
-
const [hasOlder, setHasOlder] = useState3(false);
|
|
1029
|
-
const [hasNewer, setHasNewer] = useState3(false);
|
|
1030
|
-
const [sessionStatusProjection, setSessionStatusProjection] = useState3(
|
|
1031
|
-
null
|
|
1032
|
-
);
|
|
1033
|
-
const [initialLoading, setInitialLoading] = useState3(true);
|
|
1034
|
-
const [initialHistoryReady, setInitialHistoryReady] = useState3(false);
|
|
1035
|
-
const [loadingOlder, setLoadingOlder] = useState3(false);
|
|
1036
|
-
const [loadingNewer, setLoadingNewer] = useState3(false);
|
|
1037
|
-
const [loadingOldest, setLoadingOldest] = useState3(false);
|
|
1038
|
-
const [loadingLatest, setLoadingLatest] = useState3(false);
|
|
1039
|
-
const [loadingTarget, setLoadingTarget] = useState3(false);
|
|
1040
|
-
const loadingTargetRef = useRef5(false);
|
|
1041
|
-
const [streamEpoch, setStreamEpoch] = useState3(0);
|
|
1042
|
-
const [viewMode, setViewMode] = useState3("live");
|
|
1043
|
-
const lastSequenceRef = useRef5(after);
|
|
1044
|
-
const streamResumeSequenceRef = useRef5(after);
|
|
1045
|
-
const skippedStepsThroughRef = useRef5(null);
|
|
1046
|
-
const oldestSequenceRef = useRef5(null);
|
|
1047
|
-
const newestSequenceRef = useRef5(null);
|
|
1048
|
-
const hasOlderRef = useRef5(false);
|
|
1049
|
-
const hasNewerRef = useRef5(false);
|
|
1050
|
-
const loadingOlderRef = useRef5(false);
|
|
1051
|
-
const loadingNewerRef = useRef5(false);
|
|
1052
|
-
const loadingOldestRef = useRef5(false);
|
|
1053
|
-
const loadingLatestRef = useRef5(false);
|
|
1054
|
-
const viewModeRef = useRef5("live");
|
|
1055
|
-
const initialWindowLoadedRef = useRef5(false);
|
|
1056
|
-
const openedStreamKeyRef = useRef5(null);
|
|
1057
|
-
const reconcileAfterPageResumeRef = useRef5(false);
|
|
1058
|
-
const streamAbortRef = useRef5(null);
|
|
1059
|
-
const streamKeyRef = useRef5(null);
|
|
1060
|
-
const generationRef = useRef5(0);
|
|
1061
|
-
const navigationGenerationRef = useRef5(0);
|
|
1062
|
-
const eventWindowRef = useRef5(EMPTY_EVENT_WINDOW);
|
|
1063
|
-
const sessionStatusRef = useRef5({
|
|
1064
|
-
sequence: after,
|
|
1065
|
-
status: null
|
|
1066
|
-
});
|
|
1067
|
-
const [stateStreamKey, setStateStreamKey] = useState3(streamKey);
|
|
1068
|
-
const historyFilter = fullReplay ? void 0 : CONVERSATION_FILTER;
|
|
1069
|
-
const [stepStores, setStepStores] = useState3(EMPTY_STEP_STORES);
|
|
1070
|
-
const stepStoresRef = useRef5(EMPTY_STEP_STORES);
|
|
1071
|
-
const [turnlessSteps, setTurnlessSteps] = useState3(EMPTY_TURNLESS_STEPS);
|
|
1072
|
-
const turnlessStepsRef = useRef5(EMPTY_TURNLESS_STEPS);
|
|
1073
|
-
const renderedTurnlessRef = useRef5({ appended: 0, marked: false });
|
|
1074
|
-
useEffect3(() => {
|
|
1075
|
-
renderedTurnlessRef.current = { appended: turnlessSteps.appended, marked: false };
|
|
1076
|
-
}, [turnlessSteps]);
|
|
1077
|
-
const liveThroughRef = useRef5(0);
|
|
1078
|
-
const stepGenerationRef = useRef5(0);
|
|
1079
|
-
const stepRequestRef = useRef5(0);
|
|
1080
|
-
const retainedTurnsRef = useRef5(/* @__PURE__ */ new Map());
|
|
1081
|
-
const turnStepHandlesRef = useRef5(/* @__PURE__ */ new Map());
|
|
1082
|
-
const presentedCallIdsRef = useRef5(/* @__PURE__ */ new Set());
|
|
1083
|
-
const presentedScanRef = useRef5(null);
|
|
1084
|
-
const startupRef = useRef5(emptyStartupTurns());
|
|
1085
|
-
const [presentedOutputs, setPresentedOutputs] = useState3(EMPTY_PRESENTED_OUTPUTS);
|
|
1086
|
-
const presentedRequestedRef = useRef5(/* @__PURE__ */ new Map());
|
|
1087
|
-
const presentedFailuresRef = useRef5(/* @__PURE__ */ new Map());
|
|
1088
|
-
const [presentedPass, setPresentedPass] = useState3(0);
|
|
1089
|
-
const rejoinPendingRef = useRef5(false);
|
|
1090
|
-
const streamTransientStreakRef = useRef5(null);
|
|
1091
|
-
const commitStepStores = useCallback6((next) => {
|
|
1092
|
-
stepStoresRef.current = next;
|
|
1093
|
-
setStepStores(next);
|
|
1094
|
-
}, []);
|
|
1095
|
-
const pruneStepStores = useCallback6(
|
|
1096
|
-
(window2, sealedBy, rereading = null) => {
|
|
1097
|
-
const present = windowTurns(window2);
|
|
1098
|
-
const settled = sealedBy ? settledTurns(sealedBy) : null;
|
|
1099
|
-
const next = /* @__PURE__ */ new Map();
|
|
1100
|
-
for (const [turnId, store] of stepStoresRef.current) {
|
|
1101
|
-
if (present.has(turnId) && (!settled || settled.has(turnId) || turnId === rereading)) {
|
|
1102
|
-
next.set(turnId, store);
|
|
1103
|
-
}
|
|
1104
|
-
}
|
|
1105
|
-
if (next.size !== stepStoresRef.current.size) commitStepStores(next);
|
|
1106
|
-
if (sealedBy) {
|
|
1107
|
-
presentedRequestedRef.current = /* @__PURE__ */ new Map();
|
|
1108
|
-
} else {
|
|
1109
|
-
for (const [callId, request] of presentedRequestedRef.current) {
|
|
1110
|
-
if (request.turnId && !present.has(request.turnId)) {
|
|
1111
|
-
presentedRequestedRef.current.delete(callId);
|
|
1112
|
-
}
|
|
1113
|
-
}
|
|
1114
|
-
}
|
|
1115
|
-
setPresentedOutputs((current) => {
|
|
1116
|
-
let kept = null;
|
|
1117
|
-
for (const [callId, output] of current) {
|
|
1118
|
-
if (output.turnId && present.has(output.turnId)) continue;
|
|
1119
|
-
kept ??= new Map(current);
|
|
1120
|
-
kept.delete(callId);
|
|
1121
|
-
}
|
|
1122
|
-
return kept ?? current;
|
|
1123
|
-
});
|
|
1124
|
-
},
|
|
1125
|
-
[commitStepStores]
|
|
1126
|
-
);
|
|
1127
|
-
const presentedCallIds = useCallback6((event) => {
|
|
1128
|
-
const ids = presentedCallIdsRef.current;
|
|
1129
|
-
if (event.type === "agent.toolCall.created") {
|
|
1130
|
-
notePresentedCalls([event], ids);
|
|
1131
|
-
} else if (event.type === "agent.toolCall.output") {
|
|
1132
|
-
const payload = event.payload;
|
|
1133
|
-
const windowEvents = eventWindowRef.current.events;
|
|
1134
|
-
if (typeof payload?.id === "string" && !ids.has(payload.id) && presentedScanRef.current !== windowEvents) {
|
|
1135
|
-
presentedScanRef.current = windowEvents;
|
|
1136
|
-
notePresentedCalls(windowEvents, ids);
|
|
1137
|
-
}
|
|
1138
|
-
}
|
|
1139
|
-
return ids;
|
|
1140
|
-
}, []);
|
|
1141
|
-
const startupTurns = useCallback6(() => {
|
|
1142
|
-
const windowEvents = eventWindowRef.current.events;
|
|
1143
|
-
if (startupRef.current.window !== windowEvents) {
|
|
1144
|
-
const state = emptyStartupTurns();
|
|
1145
|
-
noteStartupTurns(windowEvents, state);
|
|
1146
|
-
state.window = windowEvents;
|
|
1147
|
-
startupRef.current = state;
|
|
1148
|
-
}
|
|
1149
|
-
return startupRef.current;
|
|
1150
|
-
}, []);
|
|
1151
|
-
const appendLiveSteps = useCallback6(
|
|
1152
|
-
(steps) => {
|
|
1153
|
-
if (steps.some((event) => !event.turnId)) {
|
|
1154
|
-
const incoming = steps.filter((event) => !event.turnId);
|
|
1155
|
-
const turnless = appendTurnlessSteps(turnlessStepsRef.current, incoming);
|
|
1156
|
-
const rendered = renderedTurnlessRef.current;
|
|
1157
|
-
if (!rendered.marked && turnless.appended - rendered.appended > turnless.events.length) {
|
|
1158
|
-
rendered.marked = true;
|
|
1159
|
-
if (sessionId) markTurnlessOutputGap(workspaceId, sessionId);
|
|
1160
|
-
}
|
|
1161
|
-
turnlessStepsRef.current = turnless;
|
|
1162
|
-
setTurnlessSteps(turnless);
|
|
1163
|
-
}
|
|
1164
|
-
const windowEvents = withTurnlessSteps(
|
|
1165
|
-
eventWindowRef.current.events,
|
|
1166
|
-
turnlessStepsRef.current
|
|
1167
|
-
);
|
|
1168
|
-
const next = new Map(stepStoresRef.current);
|
|
1169
|
-
const now = Date.now();
|
|
1170
|
-
for (const [turnId, events] of groupByTurn(steps)) {
|
|
1171
|
-
const existing = next.get(turnId);
|
|
1172
|
-
const store = existing ?? {
|
|
1173
|
-
events: [],
|
|
1174
|
-
bytes: 2,
|
|
1175
|
-
// Earlier steps exist when the window skips sequences between the
|
|
1176
|
-
// turn's start and this first live step.
|
|
1177
|
-
hasOlder: turnHasHiddenSequences(windowEvents, turnId, events[0].sequence),
|
|
1178
|
-
cursor: null,
|
|
1179
|
-
floor: null,
|
|
1180
|
-
pinned: null,
|
|
1181
|
-
loading: false,
|
|
1182
|
-
error: false,
|
|
1183
|
-
touched: now,
|
|
1184
|
-
requestId: 0
|
|
1185
|
-
};
|
|
1186
|
-
let updated = { ...store, ...appendStepEvents(store, events), touched: now };
|
|
1187
|
-
if (!retainedTurnsRef.current.get(turnId)) updated = trimLiveStepTail(updated);
|
|
1188
|
-
next.set(turnId, updated);
|
|
1189
|
-
}
|
|
1190
|
-
commitStepStores(boundStepStores(next, retainedTurnsRef.current));
|
|
1191
|
-
},
|
|
1192
|
-
[commitStepStores, workspaceId, sessionId]
|
|
1193
|
-
);
|
|
1194
|
-
const loadTurnSteps = useCallback6(
|
|
627
|
+
const loadTurnSteps = useCallback3(
|
|
1195
628
|
(turnId, before) => {
|
|
1196
629
|
if (!ownsNavigation() || !sessionId || fullReplay) return;
|
|
1197
630
|
const current = stepStoresRef.current.get(turnId);
|
|
@@ -1287,11 +720,11 @@ function useSessionEvents(sessionId, options = {}) {
|
|
|
1287
720
|
},
|
|
1288
721
|
[client, workspaceId, sessionId, fullReplay, ownsNavigation, commitStepStores]
|
|
1289
722
|
);
|
|
1290
|
-
const loadTurnStepsRef =
|
|
1291
|
-
|
|
723
|
+
const loadTurnStepsRef = useRef2(loadTurnSteps);
|
|
724
|
+
useEffect2(() => {
|
|
1292
725
|
loadTurnStepsRef.current = loadTurnSteps;
|
|
1293
726
|
}, [loadTurnSteps]);
|
|
1294
|
-
const turnStepHandle =
|
|
727
|
+
const turnStepHandle = useCallback3((turnId) => {
|
|
1295
728
|
let handle = turnStepHandlesRef.current.get(turnId);
|
|
1296
729
|
if (!handle) {
|
|
1297
730
|
const retained = retainedTurnsRef.current;
|
|
@@ -1313,7 +746,7 @@ function useSessionEvents(sessionId, options = {}) {
|
|
|
1313
746
|
}
|
|
1314
747
|
return handle;
|
|
1315
748
|
}, []);
|
|
1316
|
-
|
|
749
|
+
useEffect2(() => {
|
|
1317
750
|
navigationGenerationRef.current += 1;
|
|
1318
751
|
setNewerError(null);
|
|
1319
752
|
loadingOlderRef.current = false;
|
|
@@ -1329,7 +762,7 @@ function useSessionEvents(sessionId, options = {}) {
|
|
|
1329
762
|
navigationGenerationRef.current += 1;
|
|
1330
763
|
};
|
|
1331
764
|
}, [client, workspaceId, sessionId, after, enabled, fullReplay]);
|
|
1332
|
-
|
|
765
|
+
useEffect2(() => {
|
|
1333
766
|
if (streamKeyRef.current !== streamKey) {
|
|
1334
767
|
streamKeyRef.current = streamKey;
|
|
1335
768
|
setStateStreamKey(streamKey);
|
|
@@ -1857,7 +1290,7 @@ function useSessionEvents(sessionId, options = {}) {
|
|
|
1857
1290
|
presentedCallIds,
|
|
1858
1291
|
startupTurns
|
|
1859
1292
|
]);
|
|
1860
|
-
|
|
1293
|
+
useEffect2(() => {
|
|
1861
1294
|
if (!sessionId || !streamEnabled) return;
|
|
1862
1295
|
return subscribePageWake(() => {
|
|
1863
1296
|
const stream = streamAbortRef.current;
|
|
@@ -1869,7 +1302,7 @@ function useSessionEvents(sessionId, options = {}) {
|
|
|
1869
1302
|
});
|
|
1870
1303
|
}, [sessionId, streamEnabled, fullReplay]);
|
|
1871
1304
|
const navigationBusy = () => loadingTargetRef.current || loadingOlderRef.current || loadingNewerRef.current || loadingOldestRef.current || loadingLatestRef.current;
|
|
1872
|
-
const loadOlder =
|
|
1305
|
+
const loadOlder = useCallback3(
|
|
1873
1306
|
() => createOlderHistoryLoadReceipt(async (markCommitted, preserveTail, markTailPreserved) => {
|
|
1874
1307
|
if (!ownsNavigation() || !sessionId || navigationBusy() || !hasOlderRef.current) {
|
|
1875
1308
|
return false;
|
|
@@ -1996,7 +1429,7 @@ function useSessionEvents(sessionId, options = {}) {
|
|
|
1996
1429
|
}),
|
|
1997
1430
|
[client, workspaceId, sessionId, ownsNavigation, t, historyFilter, pruneStepStores]
|
|
1998
1431
|
);
|
|
1999
|
-
const loadOldest =
|
|
1432
|
+
const loadOldest = useCallback3(async () => {
|
|
2000
1433
|
if (!ownsNavigation() || !sessionId || navigationBusy() || !hasOlderRef.current) {
|
|
2001
1434
|
return false;
|
|
2002
1435
|
}
|
|
@@ -2067,7 +1500,7 @@ function useSessionEvents(sessionId, options = {}) {
|
|
|
2067
1500
|
}
|
|
2068
1501
|
}
|
|
2069
1502
|
}, [client, workspaceId, sessionId, ownsNavigation, t, historyFilter, pruneStepStores]);
|
|
2070
|
-
const loadNewer =
|
|
1503
|
+
const loadNewer = useCallback3(async () => {
|
|
2071
1504
|
if (!ownsNavigation() || !sessionId || navigationBusy() || !hasNewerRef.current) {
|
|
2072
1505
|
return false;
|
|
2073
1506
|
}
|
|
@@ -2173,7 +1606,7 @@ function useSessionEvents(sessionId, options = {}) {
|
|
|
2173
1606
|
}
|
|
2174
1607
|
}
|
|
2175
1608
|
}, [client, workspaceId, sessionId, ownsNavigation, t, historyFilter, pruneStepStores]);
|
|
2176
|
-
const jumpToSequence =
|
|
1609
|
+
const jumpToSequence = useCallback3(
|
|
2177
1610
|
async (sequence, navigationOptions) => {
|
|
2178
1611
|
const signal = navigationOptions?.signal;
|
|
2179
1612
|
if (!ownsNavigation() || !sessionId || !Number.isSafeInteger(sequence) || sequence < 1)
|
|
@@ -2258,7 +1691,7 @@ function useSessionEvents(sessionId, options = {}) {
|
|
|
2258
1691
|
},
|
|
2259
1692
|
[client, workspaceId, sessionId, ownsNavigation, historyFilter, pruneStepStores]
|
|
2260
1693
|
);
|
|
2261
|
-
const jumpToLatestQuestion =
|
|
1694
|
+
const jumpToLatestQuestion = useCallback3(
|
|
2262
1695
|
async (questionOptions) => {
|
|
2263
1696
|
if (!sessionId || !ownsNavigation()) return null;
|
|
2264
1697
|
let generation = navigationGenerationRef.current;
|
|
@@ -2294,7 +1727,7 @@ function useSessionEvents(sessionId, options = {}) {
|
|
|
2294
1727
|
},
|
|
2295
1728
|
[client, workspaceId, sessionId, streamKey, ownsNavigation, jumpToSequence, t]
|
|
2296
1729
|
);
|
|
2297
|
-
const jumpToLatest =
|
|
1730
|
+
const jumpToLatest = useCallback3(async () => {
|
|
2298
1731
|
if (!ownsNavigation()) return;
|
|
2299
1732
|
if (loadingTargetRef.current) {
|
|
2300
1733
|
navigationGenerationRef.current += 1;
|
|
@@ -2362,7 +1795,7 @@ function useSessionEvents(sessionId, options = {}) {
|
|
|
2362
1795
|
const visibleStepStores = liveSteps ? stepStores : EMPTY_STEP_STORES;
|
|
2363
1796
|
const visiblePresentedOutputs = liveSteps ? presentedOutputs : EMPTY_PRESENTED_OUTPUTS;
|
|
2364
1797
|
const visibleTurnless = liveSteps ? turnlessSteps : EMPTY_TURNLESS_STEPS;
|
|
2365
|
-
const readToolOutput =
|
|
1798
|
+
const readToolOutput = useCallback3(
|
|
2366
1799
|
async (sequence) => sessionId ? (await readEventPage(client, workspaceId, sessionId, {
|
|
2367
1800
|
includeTypes: ["agent.toolCall.output"],
|
|
2368
1801
|
after: Math.max(0, sequence - 1),
|
|
@@ -2434,7 +1867,7 @@ function useSessionEvents(sessionId, options = {}) {
|
|
|
2434
1867
|
toolOutputs.reader,
|
|
2435
1868
|
t
|
|
2436
1869
|
]);
|
|
2437
|
-
|
|
1870
|
+
useEffect2(() => {
|
|
2438
1871
|
if (fullReplay || !sessionId || !identityMatches || !initialHistoryReady) return;
|
|
2439
1872
|
const resolved = new Set(presentedOutputs.keys());
|
|
2440
1873
|
const collect = (events) => {
|
|
@@ -3250,7 +2683,7 @@ async function readEventPage(client, workspaceId, sessionId, options) {
|
|
|
3250
2683
|
|
|
3251
2684
|
// src/hooks/use-turn-queue.ts
|
|
3252
2685
|
import { isTransientRequestError as isTransientRequestError2 } from "@opengeni/sdk";
|
|
3253
|
-
import { useCallback as
|
|
2686
|
+
import { useCallback as useCallback4, useEffect as useEffect3, useLayoutEffect, useMemo as useMemo3, useRef as useRef3, useState as useState3 } from "react";
|
|
3254
2687
|
function isTurnQueueEvent(event) {
|
|
3255
2688
|
return event.type.startsWith("turn.") || event.type.startsWith("session.queue.") || event.type.startsWith("session.control.") || event.type.startsWith("system.update.") || event.type.startsWith("workspace.inference.");
|
|
3256
2689
|
}
|
|
@@ -3266,30 +2699,30 @@ function useTurnQueue(sessionId, options = {}) {
|
|
|
3266
2699
|
const enabled = (options.enabled ?? true) && Boolean(sessionId);
|
|
3267
2700
|
const targetKey = `${workspaceId}\0${sessionId ?? ""}`;
|
|
3268
2701
|
const pageLive = usePageLiveActivity();
|
|
3269
|
-
const pageLiveRef =
|
|
2702
|
+
const pageLiveRef = useRef3(pageLive);
|
|
3270
2703
|
pageLiveRef.current = pageLive;
|
|
3271
|
-
const [snapshot, setSnapshot] =
|
|
3272
|
-
const [stateTargetKey, setStateTargetKey] =
|
|
3273
|
-
const [loading, setLoading] =
|
|
3274
|
-
const [error, setError] =
|
|
3275
|
-
const [mutationError, setMutationError] =
|
|
3276
|
-
const [pendingByTurn, setPendingByTurn] =
|
|
3277
|
-
const [acceptedSteers, setAcceptedSteers] =
|
|
3278
|
-
const pendingRef =
|
|
3279
|
-
const readGeneration =
|
|
3280
|
-
const targetKeyRef =
|
|
3281
|
-
const snapshotRef =
|
|
3282
|
-
const transientStreakRef =
|
|
2704
|
+
const [snapshot, setSnapshot] = useState3(null);
|
|
2705
|
+
const [stateTargetKey, setStateTargetKey] = useState3(targetKey);
|
|
2706
|
+
const [loading, setLoading] = useState3(enabled);
|
|
2707
|
+
const [error, setError] = useState3(null);
|
|
2708
|
+
const [mutationError, setMutationError] = useState3(null);
|
|
2709
|
+
const [pendingByTurn, setPendingByTurn] = useState3({});
|
|
2710
|
+
const [acceptedSteers, setAcceptedSteers] = useState3([]);
|
|
2711
|
+
const pendingRef = useRef3({});
|
|
2712
|
+
const readGeneration = useRef3(0);
|
|
2713
|
+
const targetKeyRef = useRef3(targetKey);
|
|
2714
|
+
const snapshotRef = useRef3(null);
|
|
2715
|
+
const transientStreakRef = useRef3(
|
|
3283
2716
|
null
|
|
3284
2717
|
);
|
|
3285
|
-
const transientRetryTimerRef =
|
|
3286
|
-
const cancelTransientRetry =
|
|
2718
|
+
const transientRetryTimerRef = useRef3(null);
|
|
2719
|
+
const cancelTransientRetry = useCallback4(() => {
|
|
3287
2720
|
if (transientRetryTimerRef.current !== null) {
|
|
3288
2721
|
clearTimeout(transientRetryTimerRef.current);
|
|
3289
2722
|
transientRetryTimerRef.current = null;
|
|
3290
2723
|
}
|
|
3291
2724
|
}, []);
|
|
3292
|
-
|
|
2725
|
+
useLayoutEffect(() => {
|
|
3293
2726
|
if (targetKeyRef.current === targetKey) return;
|
|
3294
2727
|
targetKeyRef.current = targetKey;
|
|
3295
2728
|
readGeneration.current += 1;
|
|
@@ -3305,7 +2738,7 @@ function useTurnQueue(sessionId, options = {}) {
|
|
|
3305
2738
|
setPendingByTurn({});
|
|
3306
2739
|
setAcceptedSteers([]);
|
|
3307
2740
|
}, [cancelTransientRetry, enabled, targetKey]);
|
|
3308
|
-
|
|
2741
|
+
useEffect3(() => {
|
|
3309
2742
|
if (acceptedSteers.length === 0 || options.events === void 0) return;
|
|
3310
2743
|
const durablyConsumedTurnIds = new Set(
|
|
3311
2744
|
options.events.flatMap(
|
|
@@ -3323,7 +2756,7 @@ function useTurnQueue(sessionId, options = {}) {
|
|
|
3323
2756
|
(current) => current.filter((steer) => !durablyConsumedTurnIds.has(steer.turnId))
|
|
3324
2757
|
);
|
|
3325
2758
|
}, [acceptedSteers.length, options.events]);
|
|
3326
|
-
const acceptSnapshot =
|
|
2759
|
+
const acceptSnapshot = useCallback4(
|
|
3327
2760
|
(ownedTargetKey, next) => {
|
|
3328
2761
|
if (targetKeyRef.current !== ownedTargetKey) return false;
|
|
3329
2762
|
const current = snapshotRef.current;
|
|
@@ -3337,7 +2770,7 @@ function useTurnQueue(sessionId, options = {}) {
|
|
|
3337
2770
|
},
|
|
3338
2771
|
[]
|
|
3339
2772
|
);
|
|
3340
|
-
const load =
|
|
2773
|
+
const load = useCallback4(
|
|
3341
2774
|
async (rejectOnFailure = false, fresh = false) => {
|
|
3342
2775
|
if (!sessionId) return;
|
|
3343
2776
|
const ownedTargetKey = `${workspaceId}\0${sessionId}`;
|
|
@@ -3393,10 +2826,10 @@ function useTurnQueue(sessionId, options = {}) {
|
|
|
3393
2826
|
},
|
|
3394
2827
|
[client, workspaceId, sessionId, acceptSnapshot, cancelTransientRetry]
|
|
3395
2828
|
);
|
|
3396
|
-
const loadRef =
|
|
2829
|
+
const loadRef = useRef3(load);
|
|
3397
2830
|
loadRef.current = load;
|
|
3398
|
-
|
|
3399
|
-
|
|
2831
|
+
useEffect3(() => cancelTransientRetry, [cancelTransientRetry]);
|
|
2832
|
+
useEffect3(() => {
|
|
3400
2833
|
if (!enabled || !pageLive) {
|
|
3401
2834
|
cancelTransientRetry();
|
|
3402
2835
|
setLoading(false);
|
|
@@ -3426,11 +2859,11 @@ function useTurnQueue(sessionId, options = {}) {
|
|
|
3426
2859
|
readGeneration.current += 1;
|
|
3427
2860
|
};
|
|
3428
2861
|
}, [cancelTransientRetry, load, enabled, pageLive, options.pollIntervalMs]);
|
|
3429
|
-
const loadFresh =
|
|
3430
|
-
|
|
2862
|
+
const loadFresh = useCallback4(() => load(false, true), [load]);
|
|
2863
|
+
useEffect3(() => {
|
|
3431
2864
|
if (enabled && workspaceControlEvent) void loadFresh();
|
|
3432
2865
|
}, [enabled, loadFresh, workspaceControlEvent]);
|
|
3433
|
-
|
|
2866
|
+
useEffect3(() => {
|
|
3434
2867
|
if (!sessionId || !enabled) return;
|
|
3435
2868
|
return registerSessionReconciler(sessionId, "queue", loadFresh);
|
|
3436
2869
|
}, [enabled, loadFresh, registerSessionReconciler, sessionId]);
|
|
@@ -3459,7 +2892,7 @@ function useTurnQueue(sessionId, options = {}) {
|
|
|
3459
2892
|
freshSnapshot,
|
|
3460
2893
|
{ enabled, discard: stateTargetKey === targetKey && deniesRetainedView(error) }
|
|
3461
2894
|
);
|
|
3462
|
-
const mutate =
|
|
2895
|
+
const mutate = useCallback4(
|
|
3463
2896
|
async (turnId, kind, command, failure = {}) => {
|
|
3464
2897
|
const ownedTargetKey = targetKey;
|
|
3465
2898
|
if (!sessionId || targetKeyRef.current !== ownedTargetKey || pendingRef.current[turnId]) {
|
|
@@ -3511,7 +2944,7 @@ function useTurnQueue(sessionId, options = {}) {
|
|
|
3511
2944
|
},
|
|
3512
2945
|
[acceptSnapshot, loadFresh, sessionId, targetKey]
|
|
3513
2946
|
);
|
|
3514
|
-
const moveTurn =
|
|
2947
|
+
const moveTurn = useCallback4(
|
|
3515
2948
|
async (turnId, beforeTurnId) => {
|
|
3516
2949
|
const result = await mutate(
|
|
3517
2950
|
turnId,
|
|
@@ -3526,7 +2959,7 @@ function useTurnQueue(sessionId, options = {}) {
|
|
|
3526
2959
|
},
|
|
3527
2960
|
[client, mutate, sessionId, workspaceId]
|
|
3528
2961
|
);
|
|
3529
|
-
const editTurn =
|
|
2962
|
+
const editTurn = useCallback4(
|
|
3530
2963
|
async (turnId, edit) => {
|
|
3531
2964
|
const result = await mutate(
|
|
3532
2965
|
turnId,
|
|
@@ -3542,7 +2975,7 @@ function useTurnQueue(sessionId, options = {}) {
|
|
|
3542
2975
|
},
|
|
3543
2976
|
[client, mutate, sessionId, workspaceId]
|
|
3544
2977
|
);
|
|
3545
|
-
const recallTurn =
|
|
2978
|
+
const recallTurn = useCallback4(
|
|
3546
2979
|
async (turnId, recall) => {
|
|
3547
2980
|
const ownedTargetKey = targetKey;
|
|
3548
2981
|
const known = snapshotRef.current?.items.some((candidate) => candidate.id === turnId);
|
|
@@ -3565,7 +2998,7 @@ function useTurnQueue(sessionId, options = {}) {
|
|
|
3565
2998
|
},
|
|
3566
2999
|
[client, mutate, sessionId, targetKey, workspaceId]
|
|
3567
3000
|
);
|
|
3568
|
-
const steerTurn =
|
|
3001
|
+
const steerTurn = useCallback4(
|
|
3569
3002
|
async (turnId) => {
|
|
3570
3003
|
const ownedTargetKey = targetKey;
|
|
3571
3004
|
const turn = snapshotRef.current?.items.find((candidate) => candidate.id === turnId);
|
|
@@ -3617,7 +3050,7 @@ function useTurnQueue(sessionId, options = {}) {
|
|
|
3617
3050
|
},
|
|
3618
3051
|
[client, loadFresh, mutate, sessionId, targetKey, workspaceId, t]
|
|
3619
3052
|
);
|
|
3620
|
-
const removeTurn =
|
|
3053
|
+
const removeTurn = useCallback4(
|
|
3621
3054
|
async (turnId) => {
|
|
3622
3055
|
const result = await mutate(
|
|
3623
3056
|
turnId,
|
|
@@ -3639,7 +3072,7 @@ function useTurnQueue(sessionId, options = {}) {
|
|
|
3639
3072
|
() => Object.keys(visiblePendingByTurn).length > 0,
|
|
3640
3073
|
[visiblePendingByTurn]
|
|
3641
3074
|
);
|
|
3642
|
-
const mutationFor =
|
|
3075
|
+
const mutationFor = useCallback4(
|
|
3643
3076
|
(turnId) => visiblePendingByTurn[turnId] ?? null,
|
|
3644
3077
|
[visiblePendingByTurn]
|
|
3645
3078
|
);
|
|
@@ -3663,7 +3096,7 @@ function useTurnQueue(sessionId, options = {}) {
|
|
|
3663
3096
|
mutationFor,
|
|
3664
3097
|
mutating,
|
|
3665
3098
|
mutationError: identityMatches ? mutationError : null,
|
|
3666
|
-
clearMutationError:
|
|
3099
|
+
clearMutationError: useCallback4(() => {
|
|
3667
3100
|
if (targetKeyRef.current === targetKey) setMutationError(null);
|
|
3668
3101
|
}, [targetKey]),
|
|
3669
3102
|
acceptedSteers: identityMatches ? acceptedSteers : []
|
|
@@ -3679,787 +3112,1347 @@ function isOutcomeUnknownError(cause) {
|
|
|
3679
3112
|
return typeof cause === "object" && cause !== null && cause.outcomeUnknown === true;
|
|
3680
3113
|
}
|
|
3681
3114
|
|
|
3682
|
-
// src/hooks/use-
|
|
3683
|
-
import {
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
const catalog = useWorkspaceModelCatalog({ ...scope, enabled: showModelPicker });
|
|
3691
|
-
const feed = useSessionEvents(sessionId, scope);
|
|
3692
|
-
const pendingPrompt = usePendingPrompt(initialPrompt, sessionId, feed.initialHistoryReady);
|
|
3693
|
-
const eventOptions = { ...scope, events: feed.events };
|
|
3694
|
-
const detail = useSession(sessionId, eventOptions);
|
|
3695
|
-
const queue = useTurnQueue(sessionId, eventOptions);
|
|
3696
|
-
const human = useHumanInputRequests(sessionId, eventOptions);
|
|
3697
|
-
const control = useSessionControl(sessionId, scope);
|
|
3698
|
-
const approvals = useMemo4(() => projectPendingApprovals(feed.events), [feed.events]);
|
|
3699
|
-
const files = useFileAttachments({ ...scope, scope: uploadScopeForSession(detail.session) });
|
|
3700
|
-
const clearFiles = files.clear;
|
|
3701
|
-
const attachmentSession = useRef7(sessionId);
|
|
3702
|
-
useLayoutEffect3(() => {
|
|
3703
|
-
if (attachmentSession.current === sessionId) return;
|
|
3704
|
-
const created = attachmentSession.current === null;
|
|
3705
|
-
attachmentSession.current = sessionId;
|
|
3706
|
-
if (created) return;
|
|
3707
|
-
clearFiles();
|
|
3708
|
-
}, [clearFiles, sessionId]);
|
|
3709
|
-
const uploadsEnabled = (options.attachments ?? true) && config.uploads;
|
|
3710
|
-
const status = feed.sessionStatus ?? detail.session?.status;
|
|
3711
|
-
const terminal = status === "cancelled" || (detail.session ? sessionArchived(detail.session) : false);
|
|
3712
|
-
const importedArchive = detail.session?.importedArchive?.readOnly === true;
|
|
3713
|
-
const host = options.composerOptions;
|
|
3714
|
-
const resolveExtras = () => typeof host?.sendExtras === "function" ? host.sendExtras() : host?.sendExtras;
|
|
3715
|
-
const releaseSentFiles = (input) => files.removeReadyFiles(
|
|
3716
|
-
(input.resources ?? []).flatMap(
|
|
3717
|
-
(resource) => resource.kind === "file" ? [resource.fileId] : []
|
|
3718
|
-
)
|
|
3719
|
-
);
|
|
3720
|
-
const composer = useComposer(sessionId, {
|
|
3721
|
-
...eventOptions,
|
|
3722
|
-
initialDraft: host?.initialDraft,
|
|
3723
|
-
busySend: host?.busySend,
|
|
3724
|
-
offerQueue: host?.offerQueue,
|
|
3725
|
-
effectiveControl: queue.effectiveControl ?? detail.session?.effectiveControl,
|
|
3726
|
-
// As in the console and the native screen: a turn that is still current
|
|
3727
|
-
// (running or recovering) means a Send waits. A turn parked on provider
|
|
3728
|
-
// capacity does not: the Send replaces it and starts right away.
|
|
3729
|
-
sendDestination: () => promptSendDestination({
|
|
3730
|
-
status,
|
|
3731
|
-
activeTurnId: detail.session?.activeTurnId,
|
|
3732
|
-
queuedPrompts: queue.queue.length,
|
|
3733
|
-
admissionBlock: detail.session?.admissionBlock
|
|
3734
|
-
}),
|
|
3735
|
-
sendExtras: () => {
|
|
3736
|
-
const extras = resolveExtras();
|
|
3737
|
-
return {
|
|
3738
|
-
...extras,
|
|
3739
|
-
resources: [...extras?.resources ?? [], ...uploadsEnabled ? files.readyResources : []]
|
|
3740
|
-
};
|
|
3741
|
-
},
|
|
3742
|
-
sendBlocked: () => sessionId === null || terminal || importedArchive || uploadsEnabled && files.hasUnresolved || host?.sendBlocked?.() === true,
|
|
3743
|
-
onSubmitted: (text, input) => {
|
|
3744
|
-
releaseSentFiles(input);
|
|
3745
|
-
return host?.onSubmitted?.(text, input);
|
|
3746
|
-
},
|
|
3747
|
-
onSent: (text, input) => {
|
|
3748
|
-
releaseSentFiles(input);
|
|
3749
|
-
return host?.onSent?.(text, input);
|
|
3750
|
-
},
|
|
3751
|
-
onDeliveryError: host?.onDeliveryError
|
|
3752
|
-
});
|
|
3753
|
-
const conversation = useMemo4(
|
|
3754
|
-
() => conversationTimeline(feed.timeline, queue, composer),
|
|
3755
|
-
[feed.timeline, queue, composer]
|
|
3756
|
-
);
|
|
3757
|
-
const session = detail.session;
|
|
3758
|
-
const sessionControl = session?.effectiveControl;
|
|
3759
|
-
const timeline = useSessionStartupTimeline(conversation, {
|
|
3760
|
-
session: session && sessionControl ? {
|
|
3761
|
-
...session,
|
|
3762
|
-
effectiveControl: admissionRecheckControl(
|
|
3763
|
-
sessionControl,
|
|
3764
|
-
queue.effectiveControl,
|
|
3765
|
-
composer.effectiveControl
|
|
3766
|
-
)
|
|
3767
|
-
} : null,
|
|
3768
|
-
events: feed.events,
|
|
3769
|
-
optimisticMessages: composer.optimisticMessages,
|
|
3770
|
-
hasNewer: feed.hasNewer,
|
|
3771
|
-
queue: queue.snapshot,
|
|
3772
|
-
pendingPrompt,
|
|
3773
|
-
historyReady: sessionId !== null && feed.initialHistoryReady
|
|
3774
|
-
});
|
|
3775
|
-
const error = detail.error ?? feed.error ?? human.error;
|
|
3776
|
-
const loadFailed = Boolean(feed.error) && !feed.initialHistoryReady;
|
|
3777
|
-
const retry = async () => {
|
|
3778
|
-
await Promise.all([
|
|
3779
|
-
...detail.error ? [detail.refresh()] : [],
|
|
3780
|
-
...human.error ? [human.refresh()] : [],
|
|
3781
|
-
...feed.error ? [feed.jumpToLatest()] : []
|
|
3782
|
-
]);
|
|
3783
|
-
};
|
|
3784
|
-
return {
|
|
3785
|
-
...scope,
|
|
3786
|
-
sessionId,
|
|
3787
|
-
config,
|
|
3788
|
-
catalog,
|
|
3789
|
-
showModelPicker,
|
|
3790
|
-
feed,
|
|
3791
|
-
detail,
|
|
3792
|
-
queue,
|
|
3793
|
-
human,
|
|
3794
|
-
control,
|
|
3795
|
-
approvals,
|
|
3796
|
-
files,
|
|
3797
|
-
uploadsEnabled,
|
|
3798
|
-
composer,
|
|
3799
|
-
/** The same live application context for text and durable voice messages. */
|
|
3800
|
-
getModelContext: () => resolveExtras()?.modelContext,
|
|
3801
|
-
timeline,
|
|
3802
|
-
status,
|
|
3803
|
-
terminal,
|
|
3804
|
-
importedArchive,
|
|
3805
|
-
running: sessionTurnKeepsRunControl(status),
|
|
3806
|
-
error,
|
|
3807
|
-
loadFailed,
|
|
3808
|
-
retry
|
|
3809
|
-
};
|
|
3115
|
+
// src/hooks/use-goal.ts
|
|
3116
|
+
import {
|
|
3117
|
+
OpenGeniApiError,
|
|
3118
|
+
observedSessionSequence
|
|
3119
|
+
} from "@opengeni/sdk";
|
|
3120
|
+
import { useCallback as useCallback5, useEffect as useEffect4, useLayoutEffect as useLayoutEffect2, useRef as useRef4, useState as useState4 } from "react";
|
|
3121
|
+
function isGoalEvent(event) {
|
|
3122
|
+
return event.type.startsWith("goal.");
|
|
3810
3123
|
}
|
|
3811
|
-
function
|
|
3812
|
-
const
|
|
3124
|
+
function isGoalRefreshEvent(event) {
|
|
3125
|
+
const type = event.type;
|
|
3126
|
+
return isGoalEvent(event) || type.startsWith("turn.") || type.startsWith("session.") || type.startsWith("system.update.") || type.startsWith("workspace.inference.") || type.startsWith("user.");
|
|
3127
|
+
}
|
|
3128
|
+
function useGoal(sessionId, options = {}) {
|
|
3129
|
+
const { client, workspaceId } = useEmbeddedGoal(options);
|
|
3130
|
+
const enabled = (options.enabled ?? true) && Boolean(sessionId);
|
|
3131
|
+
const sharedEvents = options.events;
|
|
3132
|
+
const sharedFeed = sharedEvents !== void 0;
|
|
3133
|
+
const pageLive = usePageLiveActivity();
|
|
3134
|
+
const [goal, setGoal] = useState4(null);
|
|
3135
|
+
const [loading, setLoading] = useState4(enabled);
|
|
3136
|
+
const [error, setError] = useState4(null);
|
|
3137
|
+
const [readAbsent, setReadAbsent] = useState4(false);
|
|
3138
|
+
const { run, mutating, mutationError, clearMutationError } = useMutationRunner();
|
|
3139
|
+
const generation = useRef4(0);
|
|
3140
|
+
const targetKeyRef = useRef4(null);
|
|
3141
|
+
const goalAbsentRef = useRef4(false);
|
|
3142
|
+
const pendingRefreshRef = useRef4("none");
|
|
3143
|
+
const sharedEventsRef = useRef4(sharedEvents);
|
|
3144
|
+
useLayoutEffect2(() => {
|
|
3145
|
+
sharedEventsRef.current = sharedEvents;
|
|
3146
|
+
}, [sharedEvents]);
|
|
3147
|
+
const loadAbort = useRef4(null);
|
|
3148
|
+
const scheduleRefreshRef = useRef4(() => void 0);
|
|
3149
|
+
const retireLoads = useCallback5(() => {
|
|
3150
|
+
generation.current += 1;
|
|
3151
|
+
loadAbort.current?.abort();
|
|
3152
|
+
loadAbort.current = null;
|
|
3153
|
+
}, []);
|
|
3154
|
+
const load = useCallback5(async () => {
|
|
3155
|
+
if (!sessionId) {
|
|
3156
|
+
return;
|
|
3157
|
+
}
|
|
3158
|
+
const ticket = ++generation.current;
|
|
3159
|
+
pendingRefreshRef.current = "none";
|
|
3160
|
+
loadAbort.current?.abort();
|
|
3161
|
+
const controller = new AbortController();
|
|
3162
|
+
loadAbort.current = controller;
|
|
3163
|
+
let fetchedGoal = null;
|
|
3164
|
+
try {
|
|
3165
|
+
const fetched = typeof client.findGoal === "function" ? await client.findGoal(workspaceId, sessionId, { signal: controller.signal }) : await client.getGoal(workspaceId, sessionId, { signal: controller.signal });
|
|
3166
|
+
fetchedGoal = fetched;
|
|
3167
|
+
if (ticket === generation.current) {
|
|
3168
|
+
goalAbsentRef.current = fetched === null;
|
|
3169
|
+
setReadAbsent(fetched === null);
|
|
3170
|
+
setGoal(fetched);
|
|
3171
|
+
setError(null);
|
|
3172
|
+
setLoading(false);
|
|
3173
|
+
}
|
|
3174
|
+
} catch (cause) {
|
|
3175
|
+
if (ticket !== generation.current) {
|
|
3176
|
+
return;
|
|
3177
|
+
}
|
|
3178
|
+
if (cause instanceof OpenGeniApiError && cause.status === 404) {
|
|
3179
|
+
goalAbsentRef.current = true;
|
|
3180
|
+
setReadAbsent(true);
|
|
3181
|
+
setGoal(null);
|
|
3182
|
+
setError(null);
|
|
3183
|
+
} else {
|
|
3184
|
+
setError(normalizeError(cause));
|
|
3185
|
+
}
|
|
3186
|
+
setLoading(false);
|
|
3187
|
+
} finally {
|
|
3188
|
+
if (loadAbort.current === controller) loadAbort.current = null;
|
|
3189
|
+
}
|
|
3190
|
+
if (ticket !== generation.current || pendingRefreshRef.current === "none") {
|
|
3191
|
+
return;
|
|
3192
|
+
}
|
|
3193
|
+
const readThrough = fetchedGoal ? observedSessionSequence(fetchedGoal) : void 0;
|
|
3194
|
+
if (readThrough !== void 0 && sharedEventsRef.current !== void 0) {
|
|
3195
|
+
const events = sharedEventsRef.current;
|
|
3196
|
+
const newest = events[events.length - 1];
|
|
3197
|
+
if (!newest || newest.sequence <= readThrough) {
|
|
3198
|
+
pendingRefreshRef.current = "none";
|
|
3199
|
+
return;
|
|
3200
|
+
}
|
|
3201
|
+
}
|
|
3202
|
+
if (goalAbsentRef.current && pendingRefreshRef.current === "refresh") {
|
|
3203
|
+
const events = sharedEventsRef.current ?? [];
|
|
3204
|
+
let latestGoalEvent;
|
|
3205
|
+
for (let index = events.length - 1; index >= 0 && !latestGoalEvent; index -= 1) {
|
|
3206
|
+
const event = events[index];
|
|
3207
|
+
if (event && isGoalEvent(event)) latestGoalEvent = event;
|
|
3208
|
+
}
|
|
3209
|
+
if (!latestGoalEvent || latestGoalEvent.type === "goal.cleared") {
|
|
3210
|
+
pendingRefreshRef.current = "none";
|
|
3211
|
+
return;
|
|
3212
|
+
}
|
|
3213
|
+
pendingRefreshRef.current = "goal";
|
|
3214
|
+
}
|
|
3215
|
+
scheduleRefreshRef.current();
|
|
3216
|
+
}, [client, workspaceId, sessionId]);
|
|
3217
|
+
useEffect4(() => {
|
|
3218
|
+
const targetKey = `${workspaceId} ${sessionId ?? ""}`;
|
|
3219
|
+
if (targetKeyRef.current !== targetKey) {
|
|
3220
|
+
targetKeyRef.current = targetKey;
|
|
3221
|
+
goalAbsentRef.current = false;
|
|
3222
|
+
pendingRefreshRef.current = "none";
|
|
3223
|
+
setReadAbsent(false);
|
|
3224
|
+
setGoal(null);
|
|
3225
|
+
setError(null);
|
|
3226
|
+
}
|
|
3227
|
+
if (!enabled || !pageLive) {
|
|
3228
|
+
retireLoads();
|
|
3229
|
+
setLoading(false);
|
|
3230
|
+
return;
|
|
3231
|
+
}
|
|
3232
|
+
if (sharedFeed) {
|
|
3233
|
+
setLoading(true);
|
|
3234
|
+
void load();
|
|
3235
|
+
return () => {
|
|
3236
|
+
retireLoads();
|
|
3237
|
+
};
|
|
3238
|
+
}
|
|
3239
|
+
setLoading(true);
|
|
3240
|
+
const pollIntervalMs = options.pollIntervalMs;
|
|
3241
|
+
if (pollIntervalMs === void 0 || pollIntervalMs <= 0) {
|
|
3242
|
+
void load();
|
|
3243
|
+
return () => {
|
|
3244
|
+
retireLoads();
|
|
3245
|
+
};
|
|
3246
|
+
}
|
|
3247
|
+
let cancelled = false;
|
|
3248
|
+
let timer = null;
|
|
3249
|
+
const schedule = () => {
|
|
3250
|
+
if (cancelled) return;
|
|
3251
|
+
timer = setTimeout(() => {
|
|
3252
|
+
timer = null;
|
|
3253
|
+
void load().finally(schedule);
|
|
3254
|
+
}, pollIntervalMs);
|
|
3255
|
+
};
|
|
3256
|
+
void load().finally(schedule);
|
|
3257
|
+
return () => {
|
|
3258
|
+
cancelled = true;
|
|
3259
|
+
if (timer !== null) clearTimeout(timer);
|
|
3260
|
+
retireLoads();
|
|
3261
|
+
};
|
|
3262
|
+
}, [
|
|
3263
|
+
load,
|
|
3264
|
+
enabled,
|
|
3265
|
+
pageLive,
|
|
3266
|
+
workspaceId,
|
|
3813
3267
|
sessionId,
|
|
3814
|
-
|
|
3268
|
+
options.pollIntervalMs,
|
|
3269
|
+
retireLoads,
|
|
3270
|
+
sharedFeed
|
|
3271
|
+
]);
|
|
3272
|
+
const scheduleRefresh = useDebouncedCallback(() => {
|
|
3273
|
+
const pending = pendingRefreshRef.current;
|
|
3274
|
+
if (pending === "none" || loadAbort.current !== null) return;
|
|
3275
|
+
if (pending === "refresh" && goalAbsentRef.current) {
|
|
3276
|
+
pendingRefreshRef.current = "none";
|
|
3277
|
+
return;
|
|
3278
|
+
}
|
|
3279
|
+
void load();
|
|
3815
3280
|
});
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3281
|
+
useLayoutEffect2(() => {
|
|
3282
|
+
scheduleRefreshRef.current = scheduleRefresh;
|
|
3283
|
+
}, [scheduleRefresh]);
|
|
3284
|
+
const isRefreshEvent = useCallback5(
|
|
3285
|
+
(event) => goalAbsentRef.current ? isGoalEvent(event) : isGoalRefreshEvent(event),
|
|
3286
|
+
[]
|
|
3287
|
+
);
|
|
3288
|
+
const refreshGoal = useCallback5(() => {
|
|
3289
|
+
pendingRefreshRef.current = "goal";
|
|
3290
|
+
scheduleRefresh();
|
|
3291
|
+
}, [scheduleRefresh]);
|
|
3292
|
+
const onRefreshEvent = useCallback5(
|
|
3293
|
+
(event) => {
|
|
3294
|
+
if (isGoalEvent(event)) pendingRefreshRef.current = "goal";
|
|
3295
|
+
else if (pendingRefreshRef.current === "none") pendingRefreshRef.current = "refresh";
|
|
3296
|
+
scheduleRefresh();
|
|
3297
|
+
},
|
|
3298
|
+
[scheduleRefresh]
|
|
3299
|
+
);
|
|
3300
|
+
useSessionEventTrigger(client, workspaceId, sessionId, isRefreshEvent, onRefreshEvent, {
|
|
3301
|
+
enabled,
|
|
3302
|
+
...sharedEvents !== void 0 ? { events: sharedEvents } : {},
|
|
3303
|
+
// The load settles events that arrive during its read itself (above).
|
|
3304
|
+
readThrough: projectionReadThrough(goal, false),
|
|
3305
|
+
refresh: refreshGoal
|
|
3306
|
+
});
|
|
3307
|
+
const retainedGoal = useRetainedSessionView(
|
|
3308
|
+
client,
|
|
3309
|
+
workspaceId,
|
|
3310
|
+
sessionId,
|
|
3311
|
+
"goal",
|
|
3312
|
+
loading ? null : goal,
|
|
3313
|
+
{ enabled, discard: readAbsent || deniesRetainedView(error) }
|
|
3314
|
+
);
|
|
3315
|
+
const visibleGoal = loading ? goal ?? retainedGoal : goal;
|
|
3316
|
+
const goalRef = useRef4(goal);
|
|
3317
|
+
const shownRetainedRef = useRef4(null);
|
|
3318
|
+
const readWaitersRef = useRef4([]);
|
|
3319
|
+
useLayoutEffect2(() => {
|
|
3320
|
+
goalRef.current = goal;
|
|
3321
|
+
shownRetainedRef.current = loading && goal === null ? retainedGoal : null;
|
|
3322
|
+
});
|
|
3323
|
+
useEffect4(() => {
|
|
3324
|
+
if (loading) return;
|
|
3325
|
+
const waiters = readWaitersRef.current;
|
|
3326
|
+
readWaitersRef.current = [];
|
|
3327
|
+
for (const resolve of waiters) resolve();
|
|
3328
|
+
}, [loading]);
|
|
3329
|
+
useEffect4(
|
|
3842
3330
|
() => () => {
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3331
|
+
goalRef.current = null;
|
|
3332
|
+
const waiters = readWaitersRef.current;
|
|
3333
|
+
readWaitersRef.current = [];
|
|
3334
|
+
for (const resolve of waiters) resolve();
|
|
3846
3335
|
},
|
|
3847
|
-
[]
|
|
3336
|
+
[workspaceId, sessionId]
|
|
3848
3337
|
);
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
if (!
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3338
|
+
const aimedAtCurrentGoal = useCallback5(async () => {
|
|
3339
|
+
const shown = shownRetainedRef.current;
|
|
3340
|
+
if (!shown) return true;
|
|
3341
|
+
await new Promise((resolve) => readWaitersRef.current.push(resolve));
|
|
3342
|
+
const fresh = goalRef.current;
|
|
3343
|
+
return fresh !== null && fresh.id === shown.id && fresh.objectiveRevision === shown.objectiveRevision;
|
|
3344
|
+
}, []);
|
|
3345
|
+
const pause = useCallback5(
|
|
3346
|
+
async (rationale) => {
|
|
3347
|
+
if (!sessionId || !await aimedAtCurrentGoal()) {
|
|
3348
|
+
return null;
|
|
3349
|
+
}
|
|
3350
|
+
const result = await run(
|
|
3351
|
+
() => client.updateGoal(workspaceId, sessionId, {
|
|
3352
|
+
status: "paused",
|
|
3353
|
+
...rationale !== void 0 ? { rationale } : {}
|
|
3864
3354
|
})
|
|
3865
|
-
)
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3355
|
+
);
|
|
3356
|
+
if (result) {
|
|
3357
|
+
setGoal(result);
|
|
3358
|
+
}
|
|
3359
|
+
return result;
|
|
3360
|
+
},
|
|
3361
|
+
[client, workspaceId, sessionId, run, aimedAtCurrentGoal]
|
|
3362
|
+
);
|
|
3363
|
+
const resume = useCallback5(async () => {
|
|
3364
|
+
if (!sessionId || !await aimedAtCurrentGoal()) {
|
|
3365
|
+
return null;
|
|
3366
|
+
}
|
|
3367
|
+
const result = await run(() => client.updateGoal(workspaceId, sessionId, { status: "active" }));
|
|
3368
|
+
if (result) {
|
|
3369
|
+
setGoal(result);
|
|
3370
|
+
}
|
|
3371
|
+
return result;
|
|
3372
|
+
}, [client, workspaceId, sessionId, run, aimedAtCurrentGoal]);
|
|
3373
|
+
const clearGoal = useCallback5(async () => {
|
|
3374
|
+
if (!sessionId || !await aimedAtCurrentGoal()) {
|
|
3375
|
+
return;
|
|
3376
|
+
}
|
|
3377
|
+
const ok = await run(async () => {
|
|
3378
|
+
await client.deleteGoal(workspaceId, sessionId);
|
|
3379
|
+
return true;
|
|
3380
|
+
});
|
|
3381
|
+
if (ok) {
|
|
3382
|
+
retireLoads();
|
|
3383
|
+
setReadAbsent(true);
|
|
3384
|
+
setGoal(null);
|
|
3385
|
+
setError(null);
|
|
3386
|
+
}
|
|
3387
|
+
}, [client, workspaceId, sessionId, run, retireLoads, aimedAtCurrentGoal]);
|
|
3388
|
+
return {
|
|
3389
|
+
goal: visibleGoal,
|
|
3390
|
+
isActive: visibleGoal?.status === "active",
|
|
3391
|
+
isPaused: visibleGoal?.status === "paused",
|
|
3392
|
+
isCompleted: visibleGoal?.status === "completed",
|
|
3393
|
+
loading: loading && retainedGoal === null,
|
|
3394
|
+
error,
|
|
3395
|
+
refresh: load,
|
|
3396
|
+
pause,
|
|
3397
|
+
resume,
|
|
3398
|
+
clearGoal,
|
|
3399
|
+
deleteGoal: clearGoal,
|
|
3400
|
+
updating: mutating,
|
|
3401
|
+
mutationError,
|
|
3402
|
+
clearMutationError
|
|
3403
|
+
};
|
|
3404
|
+
}
|
|
3405
|
+
|
|
3406
|
+
// src/hooks/use-session-control.ts
|
|
3407
|
+
import { useCallback as useCallback6, useLayoutEffect as useLayoutEffect3, useRef as useRef5 } from "react";
|
|
3408
|
+
function useSessionControl(sessionId, options = {}) {
|
|
3409
|
+
const { client, workspaceId } = useEmbeddedSession(options);
|
|
3410
|
+
const approvalTargetKey = `${workspaceId}\0${sessionId ?? ""}`;
|
|
3411
|
+
const pendingApproval = useRef5(null);
|
|
3412
|
+
useLayoutEffect3(() => {
|
|
3413
|
+
if (pendingApproval.current?.targetKey !== approvalTargetKey) {
|
|
3414
|
+
pendingApproval.current = null;
|
|
3415
|
+
}
|
|
3416
|
+
}, [approvalTargetKey]);
|
|
3417
|
+
const {
|
|
3418
|
+
run: runControl,
|
|
3419
|
+
mutating: controlling,
|
|
3420
|
+
mutationError: controlError,
|
|
3421
|
+
clearMutationError: clearControlError
|
|
3422
|
+
} = useMutationRunner(approvalTargetKey);
|
|
3423
|
+
const {
|
|
3424
|
+
run: runApproval,
|
|
3425
|
+
mutating: responding,
|
|
3426
|
+
mutationError: approvalError,
|
|
3427
|
+
clearMutationError: clearApprovalError
|
|
3428
|
+
} = useMutationRunner(approvalTargetKey);
|
|
3429
|
+
const pause = useCallback6(
|
|
3430
|
+
async (reason) => {
|
|
3431
|
+
if (!sessionId) {
|
|
3432
|
+
return null;
|
|
3433
|
+
}
|
|
3434
|
+
return await runControl(
|
|
3435
|
+
() => client.pauseSession(workspaceId, sessionId, reason !== void 0 ? { reason } : {})
|
|
3436
|
+
);
|
|
3437
|
+
},
|
|
3438
|
+
[client, workspaceId, sessionId, runControl]
|
|
3439
|
+
);
|
|
3440
|
+
const resume = useCallback6(
|
|
3441
|
+
async (reason) => {
|
|
3442
|
+
if (!sessionId) return null;
|
|
3443
|
+
return await runControl(
|
|
3444
|
+
() => client.resumeSession(workspaceId, sessionId, reason !== void 0 ? { reason } : {})
|
|
3445
|
+
);
|
|
3446
|
+
},
|
|
3447
|
+
[client, workspaceId, sessionId, runControl]
|
|
3448
|
+
);
|
|
3449
|
+
const decide = useCallback6(
|
|
3450
|
+
async (approvalId, decision, message, answer, decisionOptions = {}) => {
|
|
3451
|
+
if (!sessionId) {
|
|
3452
|
+
return null;
|
|
3453
|
+
}
|
|
3454
|
+
const decisionKey = JSON.stringify([approvalId, decision, message ?? null, answer ?? null]);
|
|
3455
|
+
if (pendingApproval.current?.decisionKey !== decisionKey) {
|
|
3456
|
+
pendingApproval.current = {
|
|
3457
|
+
targetKey: approvalTargetKey,
|
|
3458
|
+
decisionKey,
|
|
3459
|
+
clientEventId: crypto.randomUUID()
|
|
3460
|
+
};
|
|
3461
|
+
}
|
|
3462
|
+
const clientEventId = pendingApproval.current.clientEventId;
|
|
3463
|
+
let refusal = null;
|
|
3464
|
+
const accepted = await runApproval(async () => {
|
|
3465
|
+
try {
|
|
3466
|
+
return await client.sendApprovalDecision(workspaceId, sessionId, {
|
|
3467
|
+
approvalId,
|
|
3468
|
+
decision,
|
|
3469
|
+
...message !== void 0 ? { message } : {},
|
|
3470
|
+
...answer !== void 0 ? answer : {},
|
|
3471
|
+
clientEventId
|
|
3472
|
+
});
|
|
3473
|
+
} catch (cause) {
|
|
3474
|
+
refusal = { cause };
|
|
3475
|
+
throw cause;
|
|
3877
3476
|
}
|
|
3878
|
-
receipt.current = null;
|
|
3879
3477
|
});
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3478
|
+
if (decisionOptions.throwOnError && refusal) throw refusal.cause;
|
|
3479
|
+
if (accepted !== null && pendingApproval.current?.targetKey === approvalTargetKey && pendingApproval.current.clientEventId === clientEventId) {
|
|
3480
|
+
pendingApproval.current = null;
|
|
3481
|
+
}
|
|
3482
|
+
return accepted;
|
|
3483
|
+
},
|
|
3484
|
+
[approvalTargetKey, client, workspaceId, sessionId, runApproval]
|
|
3485
|
+
);
|
|
3486
|
+
const approve = useCallback6(
|
|
3487
|
+
async (approvalId, message, answer, decisionOptions) => await decide(approvalId, "approve", message, answer, decisionOptions),
|
|
3488
|
+
[decide]
|
|
3489
|
+
);
|
|
3490
|
+
const reject = useCallback6(
|
|
3491
|
+
async (approvalId, message, decisionOptions) => await decide(approvalId, "reject", message, void 0, decisionOptions),
|
|
3492
|
+
[decide]
|
|
3493
|
+
);
|
|
3494
|
+
const error = approvalError ?? controlError;
|
|
3495
|
+
const clearError = useCallback6(() => {
|
|
3496
|
+
clearControlError();
|
|
3497
|
+
clearApprovalError();
|
|
3498
|
+
}, [clearControlError, clearApprovalError]);
|
|
3499
|
+
return {
|
|
3500
|
+
pause,
|
|
3501
|
+
resume,
|
|
3502
|
+
controlling,
|
|
3503
|
+
approve,
|
|
3504
|
+
reject,
|
|
3505
|
+
responding,
|
|
3506
|
+
error,
|
|
3507
|
+
clearError
|
|
3508
|
+
};
|
|
3883
3509
|
}
|
|
3884
3510
|
|
|
3885
|
-
// src/hooks/use-
|
|
3886
|
-
import {
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
function useNewConversation(options = {}) {
|
|
3893
|
-
const t = useOpenGeniText();
|
|
3894
|
-
const context = useOpenGeni(options);
|
|
3895
|
-
const scope = { client: context.client, workspaceId: context.workspaceId };
|
|
3896
|
-
const config = useClientConfigFlags(context.client);
|
|
3897
|
-
const showModelPicker = options.modelPicker ?? config.modelSelection;
|
|
3898
|
-
const catalog = useWorkspaceModelCatalog({ ...scope, enabled: showModelPicker });
|
|
3899
|
-
const preferredModel = options.defaultModel && catalog.models.some(
|
|
3900
|
-
(row) => row.id === options.defaultModel && row.availability?.selectable !== false
|
|
3901
|
-
) ? options.defaultModel : void 0;
|
|
3902
|
-
const defaultModel = preferredModel ?? catalog.defaultModel;
|
|
3903
|
-
const files = useFileAttachments(scope);
|
|
3904
|
-
const uploadsEnabled = (options.attachments ?? true) && config.uploads;
|
|
3905
|
-
const available = options.enabled !== false && (options.createSession !== void 0 || config.sessionCreation);
|
|
3906
|
-
const [text, setText] = useState6("");
|
|
3907
|
-
const [choice, setChoice] = useState6({});
|
|
3908
|
-
const [sending, setSending] = useState6(false);
|
|
3909
|
-
const [error, setError] = useState6(null);
|
|
3910
|
-
const [pending, setPending] = useState6(null);
|
|
3911
|
-
const [completion, setCompletion] = useState6(null);
|
|
3912
|
-
const textRef = useRef9(text);
|
|
3913
|
-
const textRevision = useRef9(0);
|
|
3914
|
-
const choiceRef = useRef9(choice);
|
|
3915
|
-
const filesRef = useRef9(files);
|
|
3916
|
-
filesRef.current = files;
|
|
3917
|
-
const pendingRef = useRef9(null);
|
|
3918
|
-
const completionRef = useRef9(null);
|
|
3919
|
-
const inFlight = useRef9(false);
|
|
3920
|
-
const lifetime = useRef9({ mounted: true, generation: 0 }).current;
|
|
3921
|
-
const identity = useMemo6(
|
|
3922
|
-
() => ({
|
|
3923
|
-
client: context.client,
|
|
3924
|
-
workspaceId: context.workspaceId,
|
|
3925
|
-
scopeKey: options.scopeKey
|
|
3926
|
-
}),
|
|
3927
|
-
[context.client, context.workspaceId, options.scopeKey]
|
|
3511
|
+
// src/hooks/use-available-models.ts
|
|
3512
|
+
import { useCallback as useCallback7 } from "react";
|
|
3513
|
+
function useAvailableModels(options = {}) {
|
|
3514
|
+
const client = useOpenGeniClient(options);
|
|
3515
|
+
const load = useCallback7(
|
|
3516
|
+
async (signal) => await client.getClientConfig({ signal }),
|
|
3517
|
+
[client]
|
|
3928
3518
|
);
|
|
3929
|
-
const
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
committedIdentity.current = identity;
|
|
3940
|
-
lifetime.generation++;
|
|
3941
|
-
inFlight.current = false;
|
|
3942
|
-
pendingRef.current = null;
|
|
3943
|
-
completionRef.current = null;
|
|
3944
|
-
textRef.current = "";
|
|
3945
|
-
textRevision.current = 0;
|
|
3946
|
-
choiceRef.current = {};
|
|
3947
|
-
setText("");
|
|
3948
|
-
setChoice({});
|
|
3949
|
-
setSending(false);
|
|
3950
|
-
setError(null);
|
|
3951
|
-
setPending(null);
|
|
3952
|
-
setCompletion(null);
|
|
3953
|
-
filesRef.current.clear();
|
|
3954
|
-
}, [identity, lifetime]);
|
|
3955
|
-
const ownsScope = () => lifetime.mounted && committedIdentity.current === identity;
|
|
3956
|
-
const updateText = (value) => {
|
|
3957
|
-
if (!ownsScope()) return;
|
|
3958
|
-
if (value !== textRef.current) textRevision.current++;
|
|
3959
|
-
textRef.current = value;
|
|
3960
|
-
setText(value);
|
|
3519
|
+
const state = useSharedQuery(client, ["available-models"], load, {
|
|
3520
|
+
pollIntervalMs: options.pollIntervalMs,
|
|
3521
|
+
enabled: options.enabled
|
|
3522
|
+
});
|
|
3523
|
+
return {
|
|
3524
|
+
models: state.data?.models ?? [],
|
|
3525
|
+
defaultModel: state.data?.defaultModel ?? null,
|
|
3526
|
+
loading: state.loading,
|
|
3527
|
+
error: state.error,
|
|
3528
|
+
refresh: state.refresh
|
|
3961
3529
|
};
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3530
|
+
}
|
|
3531
|
+
function useWorkspaceModelCatalog(options) {
|
|
3532
|
+
const t = useOpenGeniText();
|
|
3533
|
+
const client = useOpenGeniClient(options);
|
|
3534
|
+
const load = useCallback7(
|
|
3535
|
+
async (signal) => {
|
|
3536
|
+
if (!options.workspaceId) {
|
|
3537
|
+
return { models: [], defaultModel: null };
|
|
3538
|
+
}
|
|
3539
|
+
const [catalog, config] = await Promise.all([
|
|
3540
|
+
client.getWorkspaceModelCatalog(options.workspaceId, { signal }),
|
|
3541
|
+
// Joins the same workspace's config read already in flight (for
|
|
3542
|
+
// example the composer's voice availability).
|
|
3543
|
+
joinClientConfigRead(client, options.workspaceId)
|
|
3544
|
+
]);
|
|
3545
|
+
return {
|
|
3546
|
+
models: catalog.models,
|
|
3547
|
+
defaultModel: config.defaultModel
|
|
3548
|
+
};
|
|
3549
|
+
},
|
|
3550
|
+
[client, options.workspaceId]
|
|
3551
|
+
);
|
|
3552
|
+
const state = useSharedQuery(client, ["workspace-model-catalog", options.workspaceId], load, {
|
|
3553
|
+
pollIntervalMs: options.pollIntervalMs,
|
|
3554
|
+
enabled: options.enabled !== false && Boolean(options.workspaceId)
|
|
3555
|
+
});
|
|
3556
|
+
const rows = sortPickerRows(projectPickerRows(t, state.data?.models ?? []));
|
|
3557
|
+
return {
|
|
3558
|
+
models: state.data?.models ?? [],
|
|
3559
|
+
rows,
|
|
3560
|
+
defaultModel: state.data?.defaultModel ?? null,
|
|
3561
|
+
loading: state.loading,
|
|
3562
|
+
error: state.error,
|
|
3563
|
+
refresh: state.refresh
|
|
3986
3564
|
};
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3565
|
+
}
|
|
3566
|
+
|
|
3567
|
+
// src/hooks/use-human-input.ts
|
|
3568
|
+
import { useCallback as useCallback8, useEffect as useEffect5, useRef as useRef6, useState as useState5 } from "react";
|
|
3569
|
+
function isHumanInputEvent(event) {
|
|
3570
|
+
return event.type === "session.humanInput.requested" || event.type === "user.humanInputResponse" || event.type === "turn.completed" || event.type === "turn.failed" || event.type === "turn.cancelled";
|
|
3571
|
+
}
|
|
3572
|
+
function useHumanInputRequests(sessionId, options = {}) {
|
|
3573
|
+
const { client, workspaceId, registerSessionReconciler } = useEmbeddedHumanInputSession(options);
|
|
3574
|
+
const enabled = (options.enabled ?? true) && Boolean(sessionId);
|
|
3575
|
+
const load = useCallback8(async () => {
|
|
3576
|
+
if (!sessionId) return [];
|
|
3577
|
+
const readStartedAt = Date.now();
|
|
3578
|
+
const requests = await client.listHumanInputRequests(workspaceId, sessionId, {
|
|
3579
|
+
status: "pending"
|
|
3995
3580
|
});
|
|
3996
|
-
|
|
3581
|
+
const now2 = Date.now();
|
|
3582
|
+
pruneHumanInputDrafts(
|
|
3583
|
+
workspaceId,
|
|
3584
|
+
sessionId,
|
|
3585
|
+
requests.filter((request) => isActionableHumanInputRequest(request, now2)).map((request) => request.id),
|
|
3586
|
+
readStartedAt
|
|
3587
|
+
);
|
|
3588
|
+
return requests;
|
|
3589
|
+
}, [client, sessionId, workspaceId]);
|
|
3590
|
+
const state = usePolledValue(load, {
|
|
3591
|
+
enabled,
|
|
3592
|
+
pollIntervalMs: options.pollIntervalMs
|
|
3997
3593
|
});
|
|
3998
|
-
const
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
3594
|
+
const loadedRequests = state.data;
|
|
3595
|
+
const refreshRequests = state.refresh;
|
|
3596
|
+
const readDenied = enabled && Boolean(sessionId) && deniesRetainedView(state.error);
|
|
3597
|
+
useEffect5(() => {
|
|
3598
|
+
if (readDenied && sessionId) forgetSessionHumanInputDrafts(workspaceId, sessionId);
|
|
3599
|
+
}, [readDenied, sessionId, workspaceId]);
|
|
3600
|
+
const mutation = useMutationRunner(`${workspaceId}\0${sessionId ?? ""}`);
|
|
3601
|
+
const [respondingRequestId, setRespondingRequestId] = useState5(null);
|
|
3602
|
+
const [deadlineVersion, setDeadlineVersion] = useState5(0);
|
|
3603
|
+
const respondingRequestRef = useRef6(null);
|
|
3604
|
+
useEffect5(() => {
|
|
3605
|
+
respondingRequestRef.current = null;
|
|
3606
|
+
setRespondingRequestId(null);
|
|
3607
|
+
}, [sessionId, workspaceId]);
|
|
3608
|
+
useEffect5(() => {
|
|
3609
|
+
if (!sessionId || !enabled) return;
|
|
3610
|
+
return registerSessionReconciler(sessionId, "human-input", state.refresh);
|
|
3611
|
+
}, [enabled, registerSessionReconciler, sessionId, state.refresh]);
|
|
3612
|
+
const scheduleRefresh = useDebouncedCallback(() => void state.refresh());
|
|
3613
|
+
useSessionEventTrigger(client, workspaceId, sessionId, isHumanInputEvent, scheduleRefresh, {
|
|
3614
|
+
enabled,
|
|
3615
|
+
...options.events !== void 0 ? { events: options.events } : {},
|
|
3616
|
+
readThrough: projectionReadThrough(state.data, state.loading),
|
|
3617
|
+
refresh: scheduleRefresh
|
|
3618
|
+
});
|
|
3619
|
+
const retainedRequests = useRetainedSessionView(
|
|
3620
|
+
client,
|
|
3621
|
+
workspaceId,
|
|
3622
|
+
sessionId,
|
|
3623
|
+
"human-input",
|
|
3624
|
+
state.data,
|
|
3625
|
+
{ enabled, discard: deniesRetainedView(state.error) }
|
|
3626
|
+
);
|
|
3627
|
+
useEffect5(() => {
|
|
3628
|
+
const now2 = Date.now();
|
|
3629
|
+
const nextDeadline = (loadedRequests ?? []).reduce((next, request) => {
|
|
3630
|
+
if (request.status !== "pending" || !request.expiresAt) return next;
|
|
3631
|
+
const deadline = Date.parse(request.expiresAt);
|
|
3632
|
+
if (!Number.isFinite(deadline) || deadline <= now2) return next;
|
|
3633
|
+
return next === null ? deadline : Math.min(next, deadline);
|
|
3634
|
+
}, null);
|
|
3635
|
+
if (nextDeadline === null) return;
|
|
3636
|
+
const timer = globalThis.setTimeout(
|
|
3637
|
+
() => {
|
|
3638
|
+
setDeadlineVersion((current) => current + 1);
|
|
3639
|
+
void refreshRequests();
|
|
3640
|
+
},
|
|
3641
|
+
Math.min(2147483647, Math.max(0, nextDeadline - now2 + 1))
|
|
4004
3642
|
);
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
)
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
...attempt.realtimeModel ? { realtimeModel: attempt.realtimeModel } : {}
|
|
4026
|
-
});
|
|
4027
|
-
};
|
|
4028
|
-
const finishRef = useRef9(finishCreation);
|
|
4029
|
-
finishRef.current = finishCreation;
|
|
4030
|
-
useLayoutEffect4(() => {
|
|
4031
|
-
if (completion && !files.hasUnresolved) finishRef.current(completion);
|
|
4032
|
-
}, [completion, files.hasUnresolved]);
|
|
4033
|
-
const deliver = async (attempt) => {
|
|
4034
|
-
if (!ownsScope() || inFlight.current || completionRef.current || !available) return false;
|
|
4035
|
-
const ownedGeneration = lifetime.generation;
|
|
4036
|
-
inFlight.current = true;
|
|
4037
|
-
pendingRef.current = attempt;
|
|
4038
|
-
setSending(true);
|
|
4039
|
-
setError(null);
|
|
4040
|
-
setPending(null);
|
|
4041
|
-
try {
|
|
4042
|
-
const sessionId = await attempt.create(
|
|
4043
|
-
attempt.initialMessage,
|
|
4044
|
-
attempt.key,
|
|
4045
|
-
structuredClone(attempt.options)
|
|
4046
|
-
);
|
|
4047
|
-
if (!lifetime.mounted || lifetime.generation !== ownedGeneration) return true;
|
|
4048
|
-
const accepted = { sessionId, attempt, generation: ownedGeneration };
|
|
4049
|
-
completionRef.current = accepted;
|
|
4050
|
-
if (filesRef.current.hasUnresolved) setCompletion(accepted);
|
|
4051
|
-
else finishCreation(accepted);
|
|
4052
|
-
return true;
|
|
4053
|
-
} catch (cause) {
|
|
4054
|
-
if (!lifetime.mounted || lifetime.generation !== ownedGeneration) return false;
|
|
4055
|
-
setError({ cause });
|
|
4056
|
-
if (cause instanceof OpenGeniApiError && cause.outcomeUnknown === false) {
|
|
4057
|
-
pendingRef.current = null;
|
|
4058
|
-
} else {
|
|
4059
|
-
setPending(attempt);
|
|
4060
|
-
}
|
|
4061
|
-
return false;
|
|
4062
|
-
} finally {
|
|
4063
|
-
if (lifetime.mounted && lifetime.generation === ownedGeneration) {
|
|
4064
|
-
inFlight.current = false;
|
|
4065
|
-
setSending(false);
|
|
3643
|
+
return () => globalThis.clearTimeout(timer);
|
|
3644
|
+
}, [loadedRequests, refreshRequests]);
|
|
3645
|
+
const respond = useCallback8(
|
|
3646
|
+
async (requestId, response) => {
|
|
3647
|
+
if (!sessionId || respondingRequestRef.current !== null) return null;
|
|
3648
|
+
respondingRequestRef.current = requestId;
|
|
3649
|
+
setRespondingRequestId(requestId);
|
|
3650
|
+
try {
|
|
3651
|
+
const event = await mutation.run(
|
|
3652
|
+
() => client.submitHumanInputResponse(workspaceId, sessionId, requestId, response, {
|
|
3653
|
+
clientEventId: globalThis.crypto.randomUUID()
|
|
3654
|
+
})
|
|
3655
|
+
);
|
|
3656
|
+
if (event) await state.refresh();
|
|
3657
|
+
return event;
|
|
3658
|
+
} finally {
|
|
3659
|
+
if (respondingRequestRef.current === requestId) {
|
|
3660
|
+
respondingRequestRef.current = null;
|
|
3661
|
+
setRespondingRequestId(null);
|
|
3662
|
+
}
|
|
4066
3663
|
}
|
|
4067
|
-
}
|
|
3664
|
+
},
|
|
3665
|
+
[client, mutation, sessionId, state, workspaceId]
|
|
3666
|
+
);
|
|
3667
|
+
const now = Date.now();
|
|
3668
|
+
void deadlineVersion;
|
|
3669
|
+
return {
|
|
3670
|
+
requests: [...state.data ?? retainedRequests ?? []].filter((request) => isActionableHumanInputRequest(request, now)).sort(
|
|
3671
|
+
(left, right) => left.createdAt.localeCompare(right.createdAt) || left.id.localeCompare(right.id)
|
|
3672
|
+
),
|
|
3673
|
+
loading: state.loading && retainedRequests === null,
|
|
3674
|
+
error: state.error,
|
|
3675
|
+
refresh: state.refresh,
|
|
3676
|
+
respond,
|
|
3677
|
+
respondingRequestId,
|
|
3678
|
+
mutationError: mutation.mutationError,
|
|
3679
|
+
clearMutationError: mutation.clearMutationError
|
|
4068
3680
|
};
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
3681
|
+
}
|
|
3682
|
+
|
|
3683
|
+
// src/conversation-timeline.ts
|
|
3684
|
+
function conversationTimeline(items, queue, composer) {
|
|
3685
|
+
const queued = new Set(
|
|
3686
|
+
queue.queue.filter((turn) => turn.metadata.delivery !== "steer").map((turn) => turn.triggerEventId)
|
|
3687
|
+
);
|
|
3688
|
+
const pending = composer.optimisticMessages ?? [];
|
|
3689
|
+
const pendingQueue = new Set(
|
|
3690
|
+
pending.filter(
|
|
3691
|
+
(message) => message.destination === "queue" && !(message.turnId && message.appliedQueueVersion != null && queue.snapshot && queue.snapshot.version >= message.appliedQueueVersion && !queue.queue.some((turn) => turn.id === message.turnId))
|
|
3692
|
+
).map((message) => `user-message:${message.clientEventId}`)
|
|
3693
|
+
);
|
|
3694
|
+
const visible = items.filter(
|
|
3695
|
+
(item) => item.kind !== "user-message" || !queued.has(item.id) && !pendingQueue.has(item.reconciliationKey ?? "")
|
|
3696
|
+
);
|
|
3697
|
+
const keys = new Set(
|
|
3698
|
+
visible.flatMap((item) => item.kind === "user-message" ? [item.reconciliationKey] : [])
|
|
3699
|
+
);
|
|
3700
|
+
const optimistic = pending.filter(
|
|
3701
|
+
(message) => (message.destination === "chat" || message.state === "failed") && !keys.has(`user-message:${message.clientEventId}`) && !queue.queue.some((turn) => turn.id === message.turnId)
|
|
3702
|
+
).map((message) => ({
|
|
3703
|
+
kind: "user-message",
|
|
3704
|
+
id: `optimistic:${message.clientEventId}`,
|
|
3705
|
+
reconciliationKey: `user-message:${message.clientEventId}`,
|
|
3706
|
+
text: message.text,
|
|
3707
|
+
annotations: message.annotations.map((annotation, ordinal) => ({ ...annotation, ordinal })),
|
|
3708
|
+
resources: message.resources,
|
|
3709
|
+
tools: [],
|
|
3710
|
+
occurredAt: message.occurredAt,
|
|
3711
|
+
delivery: {
|
|
3712
|
+
state: message.state,
|
|
3713
|
+
...message.error ? { error: message.error } : {},
|
|
3714
|
+
...message.state === "failed" ? {
|
|
3715
|
+
...message.retryable !== false && composer.retryOptimisticMessage ? { onRetry: () => composer.retryOptimisticMessage?.(message.clientEventId) } : {},
|
|
3716
|
+
...message.retryable === false && composer.restoreOptimisticMessage ? { onEdit: () => composer.restoreOptimisticMessage?.(message.clientEventId) } : {},
|
|
3717
|
+
onRemove: () => composer.removeOptimisticMessage?.(message.clientEventId)
|
|
3718
|
+
} : {}
|
|
3719
|
+
}
|
|
3720
|
+
}));
|
|
3721
|
+
const failed = optimistic.filter((message) => message.delivery?.state === "failed");
|
|
3722
|
+
const unsent = optimistic.filter((message) => message.delivery?.state !== "failed");
|
|
3723
|
+
const ids = new Set(visible.map((item) => item.id));
|
|
3724
|
+
const steers = (queue.acceptedSteers ?? []).filter((steer) => !ids.has(steer.triggerEventId)).map((steer) => ({
|
|
3725
|
+
kind: "user-message",
|
|
3726
|
+
id: steer.triggerEventId,
|
|
3727
|
+
text: steer.text,
|
|
3728
|
+
annotations: steer.annotations,
|
|
3729
|
+
resources: steer.resources,
|
|
3730
|
+
tools: steer.tools,
|
|
3731
|
+
occurredAt: steer.occurredAt,
|
|
3732
|
+
delivery: { state: steer.state }
|
|
3733
|
+
}));
|
|
3734
|
+
return [...placeFailedSends(visible, failed), ...unsent, ...steers];
|
|
3735
|
+
}
|
|
3736
|
+
function placeFailedSends(items, failed) {
|
|
3737
|
+
if (failed.length === 0) return items;
|
|
3738
|
+
const before = /* @__PURE__ */ new Map();
|
|
3739
|
+
const last = [];
|
|
3740
|
+
for (const message of failed) {
|
|
3741
|
+
const sentAt = Date.parse(message.occurredAt);
|
|
3742
|
+
const newer = items.findIndex(
|
|
3743
|
+
(item) => item.kind === "user-message" && Date.parse(item.occurredAt) > sentAt
|
|
3744
|
+
);
|
|
3745
|
+
if (newer === -1) {
|
|
3746
|
+
last.push(message);
|
|
3747
|
+
} else {
|
|
3748
|
+
before.set(newer, [...before.get(newer) ?? [], message]);
|
|
3749
|
+
}
|
|
3750
|
+
}
|
|
3751
|
+
return [...items.flatMap((item, index) => [...before.get(index) ?? [], item]), ...last];
|
|
3752
|
+
}
|
|
3753
|
+
|
|
3754
|
+
// src/lib/session-startup-timeline.tsx
|
|
3755
|
+
import { useRef as useRef7 } from "react";
|
|
3756
|
+
function currentEvents(events) {
|
|
3757
|
+
return events.filter(
|
|
3758
|
+
(event) => !event.duplicateOfEventId && (!event.turnAssociation || event.turnAssociation === "current")
|
|
3759
|
+
).sort((a, b) => a.sequence - b.sequence);
|
|
3760
|
+
}
|
|
3761
|
+
function payloadOf(event) {
|
|
3762
|
+
return event.payload && typeof event.payload === "object" ? event.payload : {};
|
|
3763
|
+
}
|
|
3764
|
+
function sessionStartupTimeline(items, input) {
|
|
3765
|
+
const { session, optimisticMessages, hasNewer } = input;
|
|
3766
|
+
if (hasNewer || session.effectiveControl.state !== "active" || !["idle", "queued", "running"].includes(session.status) || session.status === "idle" && session.inputWait)
|
|
3767
|
+
return items;
|
|
3768
|
+
const claimed = /* @__PURE__ */ new Set();
|
|
3769
|
+
const pending = /* @__PURE__ */ new Map();
|
|
3770
|
+
let queueVersion = session.queueVersion;
|
|
3771
|
+
let newerProgress = false;
|
|
3772
|
+
let observedActiveTurn = null;
|
|
3773
|
+
let previousTurnEndedAt = null;
|
|
3774
|
+
for (const event of currentEvents(input.events)) {
|
|
3775
|
+
const payload = payloadOf(event);
|
|
3776
|
+
if (event.turnId && ["turn.completed", "turn.failed", "turn.cancelled", "turn.superseded"].includes(event.type))
|
|
3777
|
+
previousTurnEndedAt = event.occurredAt;
|
|
3778
|
+
if (event.sequence > session.lastSequence && ([
|
|
3779
|
+
"turn.started",
|
|
3780
|
+
"turn.completed",
|
|
3781
|
+
"turn.failed",
|
|
3782
|
+
"turn.cancelled",
|
|
3783
|
+
"turn.superseded"
|
|
3784
|
+
].includes(event.type) || event.type === "session.status.changed" && payload.status !== "queued" || event.type === "session.queue.changed" && ["edit", "delete"].includes(String(payload.operation))))
|
|
3785
|
+
newerProgress = true;
|
|
3786
|
+
if (event.type === "session.queue.changed" && typeof payload.queueVersion === "number")
|
|
3787
|
+
queueVersion = Math.max(queueVersion, payload.queueVersion);
|
|
3788
|
+
const turnId2 = event.turnId ?? (typeof payload.turnId === "string" ? payload.turnId : null);
|
|
3789
|
+
if (!turnId2) continue;
|
|
3790
|
+
if (event.sequence > session.lastSequence) {
|
|
3791
|
+
if (event.type === "turn.started") observedActiveTurn = turnId2;
|
|
3792
|
+
else if (observedActiveTurn === turnId2 && ["turn.completed", "turn.failed", "turn.cancelled", "turn.superseded"].includes(event.type))
|
|
3793
|
+
observedActiveTurn = null;
|
|
3794
|
+
}
|
|
3795
|
+
if ([
|
|
3796
|
+
"turn.started",
|
|
3797
|
+
"turn.completed",
|
|
3798
|
+
"turn.failed",
|
|
3799
|
+
"turn.cancelled",
|
|
3800
|
+
"turn.superseded"
|
|
3801
|
+
].includes(event.type) || event.type === "session.queue.changed" && ["edit", "delete"].includes(String(payload.operation)))
|
|
3802
|
+
claimed.add(turnId2);
|
|
3803
|
+
if ((event.type === "turn.queued" || event.type === "user.message") && payload.routing === "accepted_for_execution" && (session.status !== "idle" || event.sequence > session.lastSequence))
|
|
3804
|
+
pending.set(turnId2, event.occurredAt);
|
|
3805
|
+
}
|
|
3806
|
+
for (const message of optimisticMessages ?? []) {
|
|
3807
|
+
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))
|
|
3808
|
+
pending.set(message.turnId, message.occurredAt);
|
|
3809
|
+
}
|
|
3810
|
+
const head = input.queue && input.queue.version >= queueVersion ? input.queue.items[0] : null;
|
|
3811
|
+
if (session.status === "queued" && !session.activeTurnId && head && !pending.has(head.id))
|
|
3812
|
+
pending.set(
|
|
3813
|
+
head.id,
|
|
3814
|
+
previousTurnEndedAt && previousTurnEndedAt > head.createdAt ? previousTurnEndedAt : head.createdAt
|
|
3815
|
+
);
|
|
3816
|
+
const candidate = [...pending].find(
|
|
3817
|
+
([turnId2]) => !claimed.has(turnId2) && (!session.activeTurnId || session.activeTurnId === turnId2) && (!observedActiveTurn || observedActiveTurn === turnId2) && !items.some((item) => "turnId" in item && item.turnId === turnId2)
|
|
3818
|
+
);
|
|
3819
|
+
const fallback = !candidate && !newerProgress && session.status === "queued" && !session.activeTurnId && input.fallbackStartedAt;
|
|
3820
|
+
if (!candidate && !fallback) return items;
|
|
3821
|
+
const [turnId, startedAt] = candidate ?? [
|
|
3822
|
+
`pending-startup:${session.id}`,
|
|
3823
|
+
input.fallbackStartedAt
|
|
3824
|
+
];
|
|
3825
|
+
return [
|
|
3826
|
+
...items,
|
|
3827
|
+
{
|
|
3828
|
+
kind: "startup-phase",
|
|
3829
|
+
id: `${turnId}-queue`,
|
|
3830
|
+
turnId,
|
|
3831
|
+
phase: "queue",
|
|
3832
|
+
status: "running",
|
|
3833
|
+
startedAt,
|
|
3834
|
+
occurredAt: startedAt,
|
|
3835
|
+
completedAt: null,
|
|
3836
|
+
durationMs: null,
|
|
3837
|
+
outcome: null,
|
|
3838
|
+
...session.activeTurnId ? {} : { dispatchWait: session.status === "queued" ? session.dispatchWait ?? null : null }
|
|
3839
|
+
}
|
|
3840
|
+
];
|
|
3841
|
+
}
|
|
3842
|
+
var PENDING_SCOPE = "pending-prompt";
|
|
3843
|
+
var PENDING_PROMPT_STARTUP_ID = "pending-prompt-startup";
|
|
3844
|
+
function pendingPromptItems(prompt) {
|
|
3845
|
+
return [
|
|
3846
|
+
{
|
|
3847
|
+
kind: "user-message",
|
|
3848
|
+
id: "pending-prompt-message",
|
|
3849
|
+
text: prompt.text,
|
|
3850
|
+
resources: prompt.resources ?? [],
|
|
3851
|
+
tools: [],
|
|
3852
|
+
occurredAt: prompt.sentAt
|
|
3853
|
+
},
|
|
3854
|
+
{
|
|
3855
|
+
kind: "startup-phase",
|
|
3856
|
+
id: PENDING_PROMPT_STARTUP_ID,
|
|
3857
|
+
turnId: PENDING_SCOPE,
|
|
3858
|
+
phase: "queue",
|
|
3859
|
+
status: "running",
|
|
3860
|
+
startedAt: prompt.sentAt,
|
|
3861
|
+
occurredAt: prompt.sentAt,
|
|
3862
|
+
completedAt: null,
|
|
3863
|
+
durationMs: null,
|
|
3864
|
+
outcome: null
|
|
3865
|
+
}
|
|
3866
|
+
];
|
|
3867
|
+
}
|
|
3868
|
+
function useSessionStartupTimeline(items, input) {
|
|
3869
|
+
const startup = useSessionStartupState(input.session);
|
|
3870
|
+
const bridgeRef = useRef7(null);
|
|
3871
|
+
const { pendingPrompt } = input;
|
|
3872
|
+
if (pendingPrompt && (!input.session || input.historyReady === false)) {
|
|
3873
|
+
bridgeRef.current = {
|
|
3874
|
+
scope: PENDING_SCOPE,
|
|
3875
|
+
id: PENDING_PROMPT_STARTUP_ID,
|
|
3876
|
+
turnId: null,
|
|
3877
|
+
since: pendingPrompt.sentAt,
|
|
3878
|
+
sequence: 0
|
|
3879
|
+
};
|
|
3880
|
+
return [...items, ...pendingPromptItems(pendingPrompt)];
|
|
3881
|
+
}
|
|
3882
|
+
if (!input.session) {
|
|
3883
|
+
bridgeRef.current = null;
|
|
3884
|
+
return items;
|
|
3885
|
+
}
|
|
3886
|
+
const scope = `${input.session.workspaceId}:${input.session.id}`;
|
|
3887
|
+
if (bridgeRef.current?.scope === PENDING_SCOPE)
|
|
3888
|
+
bridgeRef.current = { ...bridgeRef.current, scope };
|
|
3889
|
+
if (bridgeRef.current?.scope !== scope || input.hasNewer || input.session.effectiveControl.state !== "active" || !["queued", "running", "idle"].includes(input.session.status))
|
|
3890
|
+
bridgeRef.current = null;
|
|
3891
|
+
const boundTurn = bridgeRef.current?.turnId;
|
|
3892
|
+
const settled = boundTurn && currentEvents(input.events).find(
|
|
3893
|
+
(event) => event.turnId === boundTurn && ["turn.completed", "turn.failed", "turn.cancelled", "turn.superseded"].includes(event.type)
|
|
3894
|
+
);
|
|
3895
|
+
let fallbackStartedAt = bridgeRef.current?.turnId === null ? bridgeRef.current.since : startup?.startedAt;
|
|
3896
|
+
if (settled) {
|
|
3897
|
+
bridgeRef.current = null;
|
|
3898
|
+
fallbackStartedAt = input.session.status === "queued" && input.session.lastSequence >= settled.sequence ? input.session.updatedAt : void 0;
|
|
3899
|
+
}
|
|
3900
|
+
const projected = sessionStartupTimeline(items, {
|
|
3901
|
+
...input,
|
|
3902
|
+
session: input.session,
|
|
3903
|
+
fallbackStartedAt
|
|
3904
|
+
});
|
|
3905
|
+
if (projected !== items) {
|
|
3906
|
+
const phase2 = projected.at(-1);
|
|
3907
|
+
if (phase2.kind !== "startup-phase") return projected;
|
|
3908
|
+
const turnId2 = phase2.turnId === `pending-startup:${input.session.id}` ? null : phase2.turnId;
|
|
3909
|
+
let bridge2 = bridgeRef.current;
|
|
3910
|
+
if (!bridge2 || bridge2.turnId && turnId2 && bridge2.turnId !== turnId2) {
|
|
3911
|
+
bridge2 = {
|
|
3912
|
+
scope,
|
|
3913
|
+
id: phase2.id,
|
|
3914
|
+
turnId: turnId2,
|
|
3915
|
+
since: phase2.startedAt,
|
|
3916
|
+
sequence: input.session.lastSequence
|
|
3917
|
+
};
|
|
3918
|
+
} else
|
|
3919
|
+
bridge2 = {
|
|
3920
|
+
...bridge2,
|
|
3921
|
+
turnId: turnId2 ?? bridge2.turnId,
|
|
3922
|
+
since: bridge2.since < phase2.startedAt ? bridge2.since : phase2.startedAt
|
|
3923
|
+
};
|
|
3924
|
+
bridgeRef.current = bridge2;
|
|
3925
|
+
return [
|
|
3926
|
+
...projected.slice(0, -1),
|
|
3927
|
+
{ ...phase2, id: bridge2.id, startedAt: bridge2.since, occurredAt: bridge2.since }
|
|
3928
|
+
];
|
|
3929
|
+
}
|
|
3930
|
+
const bridge = bridgeRef.current;
|
|
3931
|
+
if (!bridge) return items;
|
|
3932
|
+
if (input.session.status === "idle") {
|
|
3933
|
+
bridgeRef.current = null;
|
|
3934
|
+
return items;
|
|
3935
|
+
}
|
|
3936
|
+
const started = currentEvents(input.events).find(
|
|
3937
|
+
(event) => event.type === "turn.started" && (bridge.turnId ? event.turnId === bridge.turnId : event.sequence > bridge.sequence)
|
|
3938
|
+
);
|
|
3939
|
+
const turnId = bridge.turnId ?? started?.turnId ?? input.session.activeTurnId;
|
|
3940
|
+
const phase = items.find((item) => item.kind === "startup-phase" && item.turnId === turnId);
|
|
3941
|
+
if (phase?.kind === "startup-phase") {
|
|
3942
|
+
bridgeRef.current = { ...bridge, turnId };
|
|
3943
|
+
return items.map(
|
|
3944
|
+
(item) => item === phase ? {
|
|
3945
|
+
...phase,
|
|
3946
|
+
id: bridge.id,
|
|
3947
|
+
loadingStartedAt: bridge.since < phase.startedAt ? bridge.since : phase.startedAt
|
|
3948
|
+
} : item
|
|
3949
|
+
);
|
|
3950
|
+
}
|
|
3951
|
+
if (turnId && (started || input.session.activeTurnId === turnId)) {
|
|
3952
|
+
bridgeRef.current = { ...bridge, turnId };
|
|
3953
|
+
return [
|
|
3954
|
+
...items,
|
|
3955
|
+
{
|
|
3956
|
+
kind: "startup-phase",
|
|
3957
|
+
id: bridge.id,
|
|
3958
|
+
turnId,
|
|
3959
|
+
phase: "queue",
|
|
3960
|
+
status: "complete",
|
|
3961
|
+
startedAt: bridge.since,
|
|
3962
|
+
occurredAt: bridge.since,
|
|
3963
|
+
completedAt: started?.occurredAt ?? input.session.updatedAt,
|
|
3964
|
+
durationMs: null,
|
|
3965
|
+
outcome: null
|
|
4086
3966
|
}
|
|
4087
|
-
|
|
4088
|
-
}
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
const
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
3967
|
+
];
|
|
3968
|
+
}
|
|
3969
|
+
if (turnId) bridgeRef.current = null;
|
|
3970
|
+
return items;
|
|
3971
|
+
}
|
|
3972
|
+
|
|
3973
|
+
// src/hooks/use-session-conversation.ts
|
|
3974
|
+
import { useLayoutEffect as useLayoutEffect4, useMemo as useMemo4, useRef as useRef8, useState as useState6 } from "react";
|
|
3975
|
+
function useSessionConversation(sessionId, options = {}) {
|
|
3976
|
+
const [initialPrompt] = useState6(() => options.pendingPrompt ?? null);
|
|
3977
|
+
const context = useOpenGeni(options);
|
|
3978
|
+
const scope = { client: context.client, workspaceId: context.workspaceId };
|
|
3979
|
+
const config = useClientConfigFlags(context.client);
|
|
3980
|
+
const showModelPicker = options.modelPicker ?? config.modelSelection;
|
|
3981
|
+
const catalog = useWorkspaceModelCatalog({ ...scope, enabled: showModelPicker });
|
|
3982
|
+
const feed = useSessionEvents(sessionId, scope);
|
|
3983
|
+
const pendingPrompt = usePendingPrompt(initialPrompt, sessionId, feed.initialHistoryReady);
|
|
3984
|
+
const eventOptions = { ...scope, events: feed.events };
|
|
3985
|
+
const detail = useSession(sessionId, eventOptions);
|
|
3986
|
+
const queue = useTurnQueue(sessionId, eventOptions);
|
|
3987
|
+
const human = useHumanInputRequests(sessionId, eventOptions);
|
|
3988
|
+
const control = useSessionControl(sessionId, scope);
|
|
3989
|
+
const approvals = useMemo4(() => projectPendingApprovals(feed.events), [feed.events]);
|
|
3990
|
+
const files = useFileAttachments({ ...scope, scope: uploadScopeForSession(detail.session) });
|
|
3991
|
+
const clearFiles = files.clear;
|
|
3992
|
+
const attachmentSession = useRef8(sessionId);
|
|
3993
|
+
useLayoutEffect4(() => {
|
|
3994
|
+
if (attachmentSession.current === sessionId) return;
|
|
3995
|
+
const created = attachmentSession.current === null;
|
|
3996
|
+
attachmentSession.current = sessionId;
|
|
3997
|
+
if (created) return;
|
|
3998
|
+
clearFiles();
|
|
3999
|
+
}, [clearFiles, sessionId]);
|
|
4000
|
+
const uploadsEnabled = (options.attachments ?? true) && config.uploads;
|
|
4001
|
+
const status = feed.sessionStatus ?? detail.session?.status;
|
|
4002
|
+
const terminal = status === "cancelled" || (detail.session ? sessionArchived(detail.session) : false);
|
|
4003
|
+
const importedArchive = detail.session?.importedArchive?.readOnly === true;
|
|
4004
|
+
const host = options.composerOptions;
|
|
4005
|
+
const resolveExtras = () => typeof host?.sendExtras === "function" ? host.sendExtras() : host?.sendExtras;
|
|
4006
|
+
const releaseSentFiles = (input) => files.removeReadyFiles(
|
|
4007
|
+
(input.resources ?? []).flatMap(
|
|
4008
|
+
(resource) => resource.kind === "file" ? [resource.fileId] : []
|
|
4009
|
+
)
|
|
4010
|
+
);
|
|
4011
|
+
const composer = useComposer(sessionId, {
|
|
4012
|
+
...eventOptions,
|
|
4013
|
+
initialDraft: host?.initialDraft,
|
|
4014
|
+
busySend: host?.busySend,
|
|
4015
|
+
offerQueue: host?.offerQueue,
|
|
4016
|
+
effectiveControl: queue.effectiveControl ?? detail.session?.effectiveControl,
|
|
4017
|
+
// As in the console and the native screen: a turn that is still current
|
|
4018
|
+
// (running or recovering) means a Send waits. A turn parked on provider
|
|
4019
|
+
// capacity does not: the Send replaces it and starts right away.
|
|
4020
|
+
sendDestination: () => promptSendDestination({
|
|
4021
|
+
status,
|
|
4022
|
+
activeTurnId: detail.session?.activeTurnId,
|
|
4023
|
+
queuedPrompts: queue.queue.length,
|
|
4024
|
+
admissionBlock: detail.session?.admissionBlock
|
|
4025
|
+
}),
|
|
4026
|
+
sendExtras: () => {
|
|
4027
|
+
const extras = resolveExtras();
|
|
4028
|
+
return {
|
|
4029
|
+
...extras,
|
|
4030
|
+
resources: [...extras?.resources ?? [], ...uploadsEnabled ? files.readyResources : []]
|
|
4031
|
+
};
|
|
4133
4032
|
},
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4033
|
+
sendBlocked: () => sessionId === null || terminal || importedArchive || uploadsEnabled && files.hasUnresolved || host?.sendBlocked?.() === true,
|
|
4034
|
+
onSubmitted: (text, input) => {
|
|
4035
|
+
releaseSentFiles(input);
|
|
4036
|
+
return host?.onSubmitted?.(text, input);
|
|
4138
4037
|
},
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
}
|
|
4038
|
+
onSent: (text, input) => {
|
|
4039
|
+
releaseSentFiles(input);
|
|
4040
|
+
return host?.onSent?.(text, input);
|
|
4041
|
+
},
|
|
4042
|
+
onDeliveryError: host?.onDeliveryError
|
|
4043
|
+
});
|
|
4044
|
+
const conversation = useMemo4(
|
|
4045
|
+
() => conversationTimeline(feed.timeline, queue, composer),
|
|
4046
|
+
[feed.timeline, queue, composer]
|
|
4047
|
+
);
|
|
4048
|
+
const session = detail.session;
|
|
4049
|
+
const sessionControl = session?.effectiveControl;
|
|
4050
|
+
const timeline = useSessionStartupTimeline(conversation, {
|
|
4051
|
+
session: session && sessionControl ? {
|
|
4052
|
+
...session,
|
|
4053
|
+
effectiveControl: admissionRecheckControl(
|
|
4054
|
+
sessionControl,
|
|
4055
|
+
queue.effectiveControl,
|
|
4056
|
+
composer.effectiveControl
|
|
4057
|
+
)
|
|
4058
|
+
} : null,
|
|
4059
|
+
events: feed.events,
|
|
4060
|
+
optimisticMessages: composer.optimisticMessages,
|
|
4061
|
+
hasNewer: feed.hasNewer,
|
|
4062
|
+
queue: queue.snapshot,
|
|
4063
|
+
pendingPrompt,
|
|
4064
|
+
historyReady: sessionId !== null && feed.initialHistoryReady
|
|
4065
|
+
});
|
|
4066
|
+
const error = detail.error ?? feed.error ?? human.error;
|
|
4067
|
+
const loadFailed = Boolean(feed.error) && !feed.initialHistoryReady;
|
|
4068
|
+
const retry = async () => {
|
|
4069
|
+
await Promise.all([
|
|
4070
|
+
...detail.error ? [detail.refresh()] : [],
|
|
4071
|
+
...human.error ? [human.refresh()] : [],
|
|
4072
|
+
...feed.error ? [feed.jumpToLatest()] : []
|
|
4073
|
+
]);
|
|
4143
4074
|
};
|
|
4144
4075
|
return {
|
|
4145
4076
|
...scope,
|
|
4077
|
+
sessionId,
|
|
4146
4078
|
config,
|
|
4079
|
+
catalog,
|
|
4080
|
+
showModelPicker,
|
|
4081
|
+
feed,
|
|
4082
|
+
detail,
|
|
4083
|
+
queue,
|
|
4084
|
+
human,
|
|
4085
|
+
control,
|
|
4086
|
+
approvals,
|
|
4147
4087
|
files,
|
|
4148
4088
|
uploadsEnabled,
|
|
4149
|
-
available,
|
|
4150
|
-
showModelPicker,
|
|
4151
|
-
catalog,
|
|
4152
4089
|
composer,
|
|
4153
|
-
|
|
4090
|
+
/** The same live application context for text and durable voice messages. */
|
|
4091
|
+
getModelContext: () => resolveExtras()?.modelContext,
|
|
4092
|
+
timeline,
|
|
4093
|
+
status,
|
|
4094
|
+
terminal,
|
|
4095
|
+
importedArchive,
|
|
4096
|
+
running: sessionTurnKeepsRunControl(status),
|
|
4154
4097
|
error,
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
retry: () => pendingRef.current ? deliver(pendingRef.current) : Promise.resolve(false),
|
|
4158
|
-
startRealtime
|
|
4098
|
+
loadFailed,
|
|
4099
|
+
retry
|
|
4159
4100
|
};
|
|
4160
4101
|
}
|
|
4102
|
+
function usePendingPrompt(prompt, sessionId, historyReady) {
|
|
4103
|
+
const owner = useRef8({
|
|
4104
|
+
sessionId,
|
|
4105
|
+
retired: prompt === null
|
|
4106
|
+
});
|
|
4107
|
+
const current = owner.current;
|
|
4108
|
+
if (!current.retired && current.sessionId !== sessionId) {
|
|
4109
|
+
if (current.sessionId === null) current.sessionId = sessionId;
|
|
4110
|
+
else current.retired = true;
|
|
4111
|
+
}
|
|
4112
|
+
if (!current.retired && sessionId !== null && historyReady) current.retired = true;
|
|
4113
|
+
return current.retired ? null : prompt;
|
|
4114
|
+
}
|
|
4115
|
+
|
|
4116
|
+
// src/hooks/use-session-read-acknowledgement.ts
|
|
4117
|
+
import { useEffect as useEffect6, useMemo as useMemo5, useRef as useRef9 } from "react";
|
|
4118
|
+
var SESSION_READ_ACKNOWLEDGEMENT_RETRY_MS = 1e3;
|
|
4119
|
+
function isPermanentRejection(error) {
|
|
4120
|
+
const status = error && typeof error === "object" ? error.status : void 0;
|
|
4121
|
+
return typeof status === "number" && status >= 400 && status < 500 && status !== 408 && status !== 429;
|
|
4122
|
+
}
|
|
4123
|
+
function useSessionReadAcknowledgement(input) {
|
|
4124
|
+
const { client, workspaceId, sessionId, events, active } = input;
|
|
4125
|
+
const session = input.session && (input.session.id ?? sessionId) === sessionId ? input.session : null;
|
|
4126
|
+
const attentionThrough = useMemo5(() => sessionAttentionReadThroughSequence(events), [events]);
|
|
4127
|
+
const { readThrough, unread } = readAcknowledgementFrontier(session, attentionThrough);
|
|
4128
|
+
const hasSession = session !== null;
|
|
4129
|
+
const receipt = useRef9(null);
|
|
4130
|
+
const refused = useRef9(/* @__PURE__ */ new Set());
|
|
4131
|
+
const retryTimer = useRef9(null);
|
|
4132
|
+
useEffect6(
|
|
4133
|
+
() => () => {
|
|
4134
|
+
if (retryTimer.current !== null) clearTimeout(retryTimer.current);
|
|
4135
|
+
retryTimer.current = null;
|
|
4136
|
+
receipt.current = null;
|
|
4137
|
+
},
|
|
4138
|
+
[]
|
|
4139
|
+
);
|
|
4140
|
+
useEffect6(() => {
|
|
4141
|
+
if (!active || !hasSession || !unread || readThrough <= 0) return;
|
|
4142
|
+
if (!workspaceId || !sessionId || typeof client.updateSessionAttention !== "function") return;
|
|
4143
|
+
const scope = `${workspaceId}:${sessionId}`;
|
|
4144
|
+
if (refused.current.has(scope)) return;
|
|
4145
|
+
const key = `${scope}:${readThrough}`;
|
|
4146
|
+
if (receipt.current === key) return;
|
|
4147
|
+
receipt.current = key;
|
|
4148
|
+
if (retryTimer.current !== null) clearTimeout(retryTimer.current);
|
|
4149
|
+
retryTimer.current = null;
|
|
4150
|
+
const attempt = (retried) => {
|
|
4151
|
+
void Promise.resolve().then(
|
|
4152
|
+
() => client.updateSessionAttention(workspaceId, sessionId, {
|
|
4153
|
+
unread: false,
|
|
4154
|
+
acknowledgedThroughSequence: readThrough
|
|
4155
|
+
})
|
|
4156
|
+
).catch((error) => {
|
|
4157
|
+
if (receipt.current !== key) return;
|
|
4158
|
+
if (isPermanentRejection(error)) {
|
|
4159
|
+
refused.current.add(scope);
|
|
4160
|
+
return;
|
|
4161
|
+
}
|
|
4162
|
+
if (!retried) {
|
|
4163
|
+
retryTimer.current = setTimeout(() => {
|
|
4164
|
+
retryTimer.current = null;
|
|
4165
|
+
if (receipt.current === key) attempt(true);
|
|
4166
|
+
}, SESSION_READ_ACKNOWLEDGEMENT_RETRY_MS);
|
|
4167
|
+
return;
|
|
4168
|
+
}
|
|
4169
|
+
receipt.current = null;
|
|
4170
|
+
});
|
|
4171
|
+
};
|
|
4172
|
+
attempt(false);
|
|
4173
|
+
}, [active, client, hasSession, readThrough, sessionId, unread, workspaceId]);
|
|
4174
|
+
}
|
|
4161
4175
|
|
|
4162
|
-
// src/hooks/use-
|
|
4176
|
+
// src/hooks/use-new-conversation.ts
|
|
4163
4177
|
import {
|
|
4164
|
-
OpenGeniApiError as OpenGeniApiError2
|
|
4165
|
-
observedSessionSequence
|
|
4178
|
+
OpenGeniApiError as OpenGeniApiError2
|
|
4166
4179
|
} from "@opengeni/sdk";
|
|
4167
|
-
import {
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
}
|
|
4171
|
-
|
|
4172
|
-
const
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
const {
|
|
4177
|
-
const
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
const
|
|
4181
|
-
const
|
|
4182
|
-
const
|
|
4180
|
+
import { useLayoutEffect as useLayoutEffect5, useMemo as useMemo6, useRef as useRef10, useState as useState7 } from "react";
|
|
4181
|
+
var NOOP_ASYNC = async () => {
|
|
4182
|
+
};
|
|
4183
|
+
function useNewConversation(options = {}) {
|
|
4184
|
+
const t = useOpenGeniText();
|
|
4185
|
+
const context = useOpenGeni(options);
|
|
4186
|
+
const scope = { client: context.client, workspaceId: context.workspaceId };
|
|
4187
|
+
const config = useClientConfigFlags(context.client);
|
|
4188
|
+
const showModelPicker = options.modelPicker ?? config.modelSelection;
|
|
4189
|
+
const catalog = useWorkspaceModelCatalog({ ...scope, enabled: showModelPicker });
|
|
4190
|
+
const preferredModel = options.defaultModel && catalog.models.some(
|
|
4191
|
+
(row) => row.id === options.defaultModel && row.availability?.selectable !== false
|
|
4192
|
+
) ? options.defaultModel : void 0;
|
|
4193
|
+
const defaultModel = preferredModel ?? catalog.defaultModel;
|
|
4194
|
+
const files = useFileAttachments(scope);
|
|
4195
|
+
const uploadsEnabled = (options.attachments ?? true) && config.uploads;
|
|
4196
|
+
const available = options.enabled !== false && (options.createSession !== void 0 || config.sessionCreation);
|
|
4197
|
+
const [text, setText] = useState7("");
|
|
4198
|
+
const [choice, setChoice] = useState7({});
|
|
4199
|
+
const [sending, setSending] = useState7(false);
|
|
4183
4200
|
const [error, setError] = useState7(null);
|
|
4184
|
-
const [
|
|
4185
|
-
const
|
|
4186
|
-
const
|
|
4187
|
-
const
|
|
4188
|
-
const
|
|
4189
|
-
const
|
|
4190
|
-
|
|
4201
|
+
const [pending, setPending] = useState7(null);
|
|
4202
|
+
const [completion, setCompletion] = useState7(null);
|
|
4203
|
+
const textRef = useRef10(text);
|
|
4204
|
+
const textRevision = useRef10(0);
|
|
4205
|
+
const choiceRef = useRef10(choice);
|
|
4206
|
+
const filesRef = useRef10(files);
|
|
4207
|
+
filesRef.current = files;
|
|
4208
|
+
const pendingRef = useRef10(null);
|
|
4209
|
+
const completionRef = useRef10(null);
|
|
4210
|
+
const inFlight = useRef10(false);
|
|
4211
|
+
const lifetime = useRef10({ mounted: true, generation: 0 }).current;
|
|
4212
|
+
const identity = useMemo6(
|
|
4213
|
+
() => ({
|
|
4214
|
+
client: context.client,
|
|
4215
|
+
workspaceId: context.workspaceId,
|
|
4216
|
+
scopeKey: options.scopeKey
|
|
4217
|
+
}),
|
|
4218
|
+
[context.client, context.workspaceId, options.scopeKey]
|
|
4219
|
+
);
|
|
4220
|
+
const committedIdentity = useRef10(identity);
|
|
4191
4221
|
useLayoutEffect5(() => {
|
|
4192
|
-
|
|
4193
|
-
}, [sharedEvents]);
|
|
4194
|
-
const loadAbort = useRef10(null);
|
|
4195
|
-
const scheduleRefreshRef = useRef10(() => void 0);
|
|
4196
|
-
const retireLoads = useCallback8(() => {
|
|
4197
|
-
generation.current += 1;
|
|
4198
|
-
loadAbort.current?.abort();
|
|
4199
|
-
loadAbort.current = null;
|
|
4200
|
-
}, []);
|
|
4201
|
-
const load = useCallback8(async () => {
|
|
4202
|
-
if (!sessionId) {
|
|
4203
|
-
return;
|
|
4204
|
-
}
|
|
4205
|
-
const ticket = ++generation.current;
|
|
4206
|
-
pendingRefreshRef.current = "none";
|
|
4207
|
-
loadAbort.current?.abort();
|
|
4208
|
-
const controller = new AbortController();
|
|
4209
|
-
loadAbort.current = controller;
|
|
4210
|
-
let fetchedGoal = null;
|
|
4211
|
-
try {
|
|
4212
|
-
const fetched = typeof client.findGoal === "function" ? await client.findGoal(workspaceId, sessionId, { signal: controller.signal }) : await client.getGoal(workspaceId, sessionId, { signal: controller.signal });
|
|
4213
|
-
fetchedGoal = fetched;
|
|
4214
|
-
if (ticket === generation.current) {
|
|
4215
|
-
goalAbsentRef.current = fetched === null;
|
|
4216
|
-
setReadAbsent(fetched === null);
|
|
4217
|
-
setGoal(fetched);
|
|
4218
|
-
setError(null);
|
|
4219
|
-
setLoading(false);
|
|
4220
|
-
}
|
|
4221
|
-
} catch (cause) {
|
|
4222
|
-
if (ticket !== generation.current) {
|
|
4223
|
-
return;
|
|
4224
|
-
}
|
|
4225
|
-
if (cause instanceof OpenGeniApiError2 && cause.status === 404) {
|
|
4226
|
-
goalAbsentRef.current = true;
|
|
4227
|
-
setReadAbsent(true);
|
|
4228
|
-
setGoal(null);
|
|
4229
|
-
setError(null);
|
|
4230
|
-
} else {
|
|
4231
|
-
setError(normalizeError(cause));
|
|
4232
|
-
}
|
|
4233
|
-
setLoading(false);
|
|
4234
|
-
} finally {
|
|
4235
|
-
if (loadAbort.current === controller) loadAbort.current = null;
|
|
4236
|
-
}
|
|
4237
|
-
if (ticket !== generation.current || pendingRefreshRef.current === "none") {
|
|
4238
|
-
return;
|
|
4239
|
-
}
|
|
4240
|
-
const readThrough = fetchedGoal ? observedSessionSequence(fetchedGoal) : void 0;
|
|
4241
|
-
if (readThrough !== void 0 && sharedEventsRef.current !== void 0) {
|
|
4242
|
-
const events = sharedEventsRef.current;
|
|
4243
|
-
const newest = events[events.length - 1];
|
|
4244
|
-
if (!newest || newest.sequence <= readThrough) {
|
|
4245
|
-
pendingRefreshRef.current = "none";
|
|
4246
|
-
return;
|
|
4247
|
-
}
|
|
4248
|
-
}
|
|
4249
|
-
if (goalAbsentRef.current && pendingRefreshRef.current === "refresh") {
|
|
4250
|
-
const events = sharedEventsRef.current ?? [];
|
|
4251
|
-
let latestGoalEvent;
|
|
4252
|
-
for (let index = events.length - 1; index >= 0 && !latestGoalEvent; index -= 1) {
|
|
4253
|
-
const event = events[index];
|
|
4254
|
-
if (event && isGoalEvent(event)) latestGoalEvent = event;
|
|
4255
|
-
}
|
|
4256
|
-
if (!latestGoalEvent || latestGoalEvent.type === "goal.cleared") {
|
|
4257
|
-
pendingRefreshRef.current = "none";
|
|
4258
|
-
return;
|
|
4259
|
-
}
|
|
4260
|
-
pendingRefreshRef.current = "goal";
|
|
4261
|
-
}
|
|
4262
|
-
scheduleRefreshRef.current();
|
|
4263
|
-
}, [client, workspaceId, sessionId]);
|
|
4264
|
-
useEffect6(() => {
|
|
4265
|
-
const targetKey = `${workspaceId} ${sessionId ?? ""}`;
|
|
4266
|
-
if (targetKeyRef.current !== targetKey) {
|
|
4267
|
-
targetKeyRef.current = targetKey;
|
|
4268
|
-
goalAbsentRef.current = false;
|
|
4269
|
-
pendingRefreshRef.current = "none";
|
|
4270
|
-
setReadAbsent(false);
|
|
4271
|
-
setGoal(null);
|
|
4272
|
-
setError(null);
|
|
4273
|
-
}
|
|
4274
|
-
if (!enabled || !pageLive) {
|
|
4275
|
-
retireLoads();
|
|
4276
|
-
setLoading(false);
|
|
4277
|
-
return;
|
|
4278
|
-
}
|
|
4279
|
-
if (sharedFeed) {
|
|
4280
|
-
setLoading(true);
|
|
4281
|
-
void load();
|
|
4282
|
-
return () => {
|
|
4283
|
-
retireLoads();
|
|
4284
|
-
};
|
|
4285
|
-
}
|
|
4286
|
-
setLoading(true);
|
|
4287
|
-
const pollIntervalMs = options.pollIntervalMs;
|
|
4288
|
-
if (pollIntervalMs === void 0 || pollIntervalMs <= 0) {
|
|
4289
|
-
void load();
|
|
4290
|
-
return () => {
|
|
4291
|
-
retireLoads();
|
|
4292
|
-
};
|
|
4293
|
-
}
|
|
4294
|
-
let cancelled = false;
|
|
4295
|
-
let timer = null;
|
|
4296
|
-
const schedule = () => {
|
|
4297
|
-
if (cancelled) return;
|
|
4298
|
-
timer = setTimeout(() => {
|
|
4299
|
-
timer = null;
|
|
4300
|
-
void load().finally(schedule);
|
|
4301
|
-
}, pollIntervalMs);
|
|
4302
|
-
};
|
|
4303
|
-
void load().finally(schedule);
|
|
4222
|
+
lifetime.mounted = true;
|
|
4304
4223
|
return () => {
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
retireLoads();
|
|
4224
|
+
lifetime.mounted = false;
|
|
4225
|
+
lifetime.generation++;
|
|
4308
4226
|
};
|
|
4309
|
-
}, [
|
|
4310
|
-
load,
|
|
4311
|
-
enabled,
|
|
4312
|
-
pageLive,
|
|
4313
|
-
workspaceId,
|
|
4314
|
-
sessionId,
|
|
4315
|
-
options.pollIntervalMs,
|
|
4316
|
-
retireLoads,
|
|
4317
|
-
sharedFeed
|
|
4318
|
-
]);
|
|
4319
|
-
const scheduleRefresh = useDebouncedCallback(() => {
|
|
4320
|
-
const pending = pendingRefreshRef.current;
|
|
4321
|
-
if (pending === "none" || loadAbort.current !== null) return;
|
|
4322
|
-
if (pending === "refresh" && goalAbsentRef.current) {
|
|
4323
|
-
pendingRefreshRef.current = "none";
|
|
4324
|
-
return;
|
|
4325
|
-
}
|
|
4326
|
-
void load();
|
|
4327
|
-
});
|
|
4227
|
+
}, [lifetime]);
|
|
4328
4228
|
useLayoutEffect5(() => {
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
(
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
);
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
|
|
4229
|
+
if (committedIdentity.current === identity) return;
|
|
4230
|
+
committedIdentity.current = identity;
|
|
4231
|
+
lifetime.generation++;
|
|
4232
|
+
inFlight.current = false;
|
|
4233
|
+
pendingRef.current = null;
|
|
4234
|
+
completionRef.current = null;
|
|
4235
|
+
textRef.current = "";
|
|
4236
|
+
textRevision.current = 0;
|
|
4237
|
+
choiceRef.current = {};
|
|
4238
|
+
setText("");
|
|
4239
|
+
setChoice({});
|
|
4240
|
+
setSending(false);
|
|
4241
|
+
setError(null);
|
|
4242
|
+
setPending(null);
|
|
4243
|
+
setCompletion(null);
|
|
4244
|
+
filesRef.current.clear();
|
|
4245
|
+
}, [identity, lifetime]);
|
|
4246
|
+
const ownsScope = () => lifetime.mounted && committedIdentity.current === identity;
|
|
4247
|
+
const updateText = (value) => {
|
|
4248
|
+
if (!ownsScope()) return;
|
|
4249
|
+
if (value !== textRef.current) textRevision.current++;
|
|
4250
|
+
textRef.current = value;
|
|
4251
|
+
setText(value);
|
|
4252
|
+
};
|
|
4253
|
+
const updateChoice = (patch) => {
|
|
4254
|
+
if (!ownsScope()) return;
|
|
4255
|
+
const next = { ...choiceRef.current, ...patch };
|
|
4256
|
+
const model = catalog.models.find((row) => row.id === (next.model ?? defaultModel));
|
|
4257
|
+
if (model) {
|
|
4258
|
+
if (next.reasoningEffort)
|
|
4259
|
+
next.reasoningEffort = coerceReasoningEffortForModel(model, next.reasoningEffort);
|
|
4260
|
+
if (next.latencyMode && !runnableLatencyModesForModel(model).includes(next.latencyMode))
|
|
4261
|
+
next.latencyMode = "standard";
|
|
4262
|
+
}
|
|
4263
|
+
choiceRef.current = next;
|
|
4264
|
+
setChoice(choiceRef.current);
|
|
4265
|
+
if (!pendingRef.current) setError(null);
|
|
4266
|
+
};
|
|
4267
|
+
const preferredChoice = () => preferredModel ? { model: preferredModel } : {};
|
|
4268
|
+
const effectivePolicy = () => {
|
|
4269
|
+
const model = choiceRef.current.model ?? defaultModel;
|
|
4270
|
+
const definition = catalog.models.find((row) => row.id === model);
|
|
4271
|
+
const effort = choiceRef.current.reasoningEffort ?? (definition ? defaultEffortForModel(definition) : config.defaultReasoningEffort ?? "medium");
|
|
4272
|
+
return showModelPicker && model ? {
|
|
4273
|
+
model,
|
|
4274
|
+
reasoningEffort: definition ? coerceReasoningEffortForModel(definition, effort) : effort,
|
|
4275
|
+
latencyMode: choiceRef.current.latencyMode ?? "standard"
|
|
4276
|
+
} : void 0;
|
|
4277
|
+
};
|
|
4278
|
+
const create = options.createSession ?? (async (initialMessage, idempotencyKey, input) => {
|
|
4279
|
+
const creator = context.client.createSession;
|
|
4280
|
+
if (typeof creator !== "function")
|
|
4281
|
+
throw new Error(t("hooks.useNewConversation.newChatsAreNotEnabled"));
|
|
4282
|
+
const created = await creator.call(context.client, context.workspaceId, {
|
|
4283
|
+
...input.startMode === "realtime" ? {} : { initialMessage },
|
|
4284
|
+
idempotencyKey,
|
|
4285
|
+
...input
|
|
4286
|
+
});
|
|
4287
|
+
return created.id;
|
|
4353
4288
|
});
|
|
4354
|
-
const
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
"
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4289
|
+
const finishCreation = (accepted) => {
|
|
4290
|
+
if (!lifetime.mounted || lifetime.generation !== accepted.generation) return;
|
|
4291
|
+
const { attempt, sessionId } = accepted;
|
|
4292
|
+
const sentFiles = new Set(attempt.options.resources?.map((resource) => resource.fileId) ?? []);
|
|
4293
|
+
const policyChanged = ["model", "reasoningEffort", "latencyMode"].some(
|
|
4294
|
+
(field) => choiceRef.current[field] !== attempt.options[field]
|
|
4295
|
+
);
|
|
4296
|
+
const draft = {
|
|
4297
|
+
text: attempt.clearDraft && textRevision.current === attempt.textRevision ? "" : textRef.current,
|
|
4298
|
+
resources: filesRef.current.readyResources.filter(
|
|
4299
|
+
(resource) => !sentFiles.has(resource.fileId)
|
|
4300
|
+
),
|
|
4301
|
+
// Unchanged choices are already part of the created session. Do not
|
|
4302
|
+
// replace server-owned defaults with a browser's catalog estimate.
|
|
4303
|
+
...policyChanged ? { policy: effectivePolicy() } : {}
|
|
4304
|
+
};
|
|
4305
|
+
pendingRef.current = null;
|
|
4306
|
+
completionRef.current = null;
|
|
4307
|
+
setPending(null);
|
|
4308
|
+
setCompletion(null);
|
|
4309
|
+
updateText(draft.text);
|
|
4310
|
+
filesRef.current.removeReadyFiles(sentFiles);
|
|
4311
|
+
notifyObserver(options.onCreated, {
|
|
4312
|
+
sessionId,
|
|
4313
|
+
initialMessage: attempt.initialMessage,
|
|
4314
|
+
sentAt: attempt.sentAt,
|
|
4315
|
+
draft,
|
|
4316
|
+
...attempt.realtimeModel ? { realtimeModel: attempt.realtimeModel } : {}
|
|
4317
|
+
});
|
|
4318
|
+
};
|
|
4319
|
+
const finishRef = useRef10(finishCreation);
|
|
4320
|
+
finishRef.current = finishCreation;
|
|
4366
4321
|
useLayoutEffect5(() => {
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
},
|
|
4383
|
-
[workspaceId, sessionId]
|
|
4384
|
-
);
|
|
4385
|
-
const aimedAtCurrentGoal = useCallback8(async () => {
|
|
4386
|
-
const shown = shownRetainedRef.current;
|
|
4387
|
-
if (!shown) return true;
|
|
4388
|
-
await new Promise((resolve) => readWaitersRef.current.push(resolve));
|
|
4389
|
-
const fresh = goalRef.current;
|
|
4390
|
-
return fresh !== null && fresh.id === shown.id && fresh.objectiveRevision === shown.objectiveRevision;
|
|
4391
|
-
}, []);
|
|
4392
|
-
const pause = useCallback8(
|
|
4393
|
-
async (rationale) => {
|
|
4394
|
-
if (!sessionId || !await aimedAtCurrentGoal()) {
|
|
4395
|
-
return null;
|
|
4396
|
-
}
|
|
4397
|
-
const result = await run(
|
|
4398
|
-
() => client.updateGoal(workspaceId, sessionId, {
|
|
4399
|
-
status: "paused",
|
|
4400
|
-
...rationale !== void 0 ? { rationale } : {}
|
|
4401
|
-
})
|
|
4322
|
+
if (completion && !files.hasUnresolved) finishRef.current(completion);
|
|
4323
|
+
}, [completion, files.hasUnresolved]);
|
|
4324
|
+
const deliver = async (attempt) => {
|
|
4325
|
+
if (!ownsScope() || inFlight.current || completionRef.current || !available) return false;
|
|
4326
|
+
const ownedGeneration = lifetime.generation;
|
|
4327
|
+
inFlight.current = true;
|
|
4328
|
+
pendingRef.current = attempt;
|
|
4329
|
+
setSending(true);
|
|
4330
|
+
setError(null);
|
|
4331
|
+
setPending(null);
|
|
4332
|
+
try {
|
|
4333
|
+
const sessionId = await attempt.create(
|
|
4334
|
+
attempt.initialMessage,
|
|
4335
|
+
attempt.key,
|
|
4336
|
+
structuredClone(attempt.options)
|
|
4402
4337
|
);
|
|
4403
|
-
if (
|
|
4404
|
-
|
|
4338
|
+
if (!lifetime.mounted || lifetime.generation !== ownedGeneration) return true;
|
|
4339
|
+
const accepted = { sessionId, attempt, generation: ownedGeneration };
|
|
4340
|
+
completionRef.current = accepted;
|
|
4341
|
+
if (filesRef.current.hasUnresolved) setCompletion(accepted);
|
|
4342
|
+
else finishCreation(accepted);
|
|
4343
|
+
return true;
|
|
4344
|
+
} catch (cause) {
|
|
4345
|
+
if (!lifetime.mounted || lifetime.generation !== ownedGeneration) return false;
|
|
4346
|
+
setError({ cause });
|
|
4347
|
+
if (cause instanceof OpenGeniApiError2 && cause.outcomeUnknown === false) {
|
|
4348
|
+
pendingRef.current = null;
|
|
4349
|
+
} else {
|
|
4350
|
+
setPending(attempt);
|
|
4351
|
+
}
|
|
4352
|
+
return false;
|
|
4353
|
+
} finally {
|
|
4354
|
+
if (lifetime.mounted && lifetime.generation === ownedGeneration) {
|
|
4355
|
+
inFlight.current = false;
|
|
4356
|
+
setSending(false);
|
|
4405
4357
|
}
|
|
4406
|
-
return result;
|
|
4407
|
-
},
|
|
4408
|
-
[client, workspaceId, sessionId, run, aimedAtCurrentGoal]
|
|
4409
|
-
);
|
|
4410
|
-
const resume = useCallback8(async () => {
|
|
4411
|
-
if (!sessionId || !await aimedAtCurrentGoal()) {
|
|
4412
|
-
return null;
|
|
4413
|
-
}
|
|
4414
|
-
const result = await run(() => client.updateGoal(workspaceId, sessionId, { status: "active" }));
|
|
4415
|
-
if (result) {
|
|
4416
|
-
setGoal(result);
|
|
4417
|
-
}
|
|
4418
|
-
return result;
|
|
4419
|
-
}, [client, workspaceId, sessionId, run, aimedAtCurrentGoal]);
|
|
4420
|
-
const clearGoal = useCallback8(async () => {
|
|
4421
|
-
if (!sessionId || !await aimedAtCurrentGoal()) {
|
|
4422
|
-
return;
|
|
4423
4358
|
}
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4359
|
+
};
|
|
4360
|
+
const submit = async (explicit) => {
|
|
4361
|
+
if (!ownsScope() || !available || inFlight.current || pendingRef.current || uploadsEnabled && filesRef.current.hasUnresolved)
|
|
4362
|
+
return false;
|
|
4363
|
+
const resources = uploadsEnabled ? filesRef.current.readyResources : [];
|
|
4364
|
+
const draftText = explicit ?? textRef.current;
|
|
4365
|
+
const initialMessage = draftText.trim() || (resources.length > 0 ? FILE_ONLY_MESSAGE_TEXT(t) : "");
|
|
4366
|
+
if (!initialMessage) return false;
|
|
4367
|
+
return deliver({
|
|
4368
|
+
key: crypto.randomUUID(),
|
|
4369
|
+
initialMessage,
|
|
4370
|
+
sentAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4371
|
+
textRevision: textRevision.current,
|
|
4372
|
+
clearDraft: explicit === void 0,
|
|
4373
|
+
create,
|
|
4374
|
+
options: {
|
|
4375
|
+
...resources.length ? { resources: structuredClone(resources) } : {},
|
|
4376
|
+
...showModelPicker ? { ...preferredChoice(), ...choiceRef.current } : {}
|
|
4377
|
+
}
|
|
4427
4378
|
});
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4379
|
+
};
|
|
4380
|
+
const startRealtime = async (model) => {
|
|
4381
|
+
if (!ownsScope() || !available || inFlight.current || pendingRef.current || !config.realtimeVoice || !(options.realtimeVoice ?? config.realtimeVoiceOffered))
|
|
4382
|
+
return false;
|
|
4383
|
+
if (filesRef.current.hasUnresolved) return false;
|
|
4384
|
+
return deliver({
|
|
4385
|
+
key: crypto.randomUUID(),
|
|
4386
|
+
initialMessage: "",
|
|
4387
|
+
sentAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4388
|
+
textRevision: textRevision.current,
|
|
4389
|
+
clearDraft: false,
|
|
4390
|
+
create,
|
|
4391
|
+
options: {
|
|
4392
|
+
...showModelPicker ? { ...preferredChoice(), ...choiceRef.current } : {},
|
|
4393
|
+
startMode: "realtime"
|
|
4394
|
+
},
|
|
4395
|
+
realtimeModel: model
|
|
4396
|
+
});
|
|
4397
|
+
};
|
|
4398
|
+
const composer = {
|
|
4399
|
+
value: text,
|
|
4400
|
+
setValue: updateText,
|
|
4401
|
+
hasDraftContent: () => textRef.current.length > 0 || filesRef.current.attachments.length > 0,
|
|
4402
|
+
send: submit,
|
|
4403
|
+
steer: submit,
|
|
4404
|
+
// Nothing runs before the conversation exists: Send just sends.
|
|
4405
|
+
working: false,
|
|
4406
|
+
sending,
|
|
4407
|
+
canSend: available && !sending && !pending && !completion && (text.trim().length > 0 || uploadsEnabled && files.readyResources.length > 0) && !(uploadsEnabled && files.hasUnresolved),
|
|
4408
|
+
pause: NOOP_ASYNC,
|
|
4409
|
+
pausing: false,
|
|
4410
|
+
resume: NOOP_ASYNC,
|
|
4411
|
+
resumeScope: NOOP_ASYNC,
|
|
4412
|
+
resuming: false,
|
|
4413
|
+
draft: null,
|
|
4414
|
+
draftRevision: 0,
|
|
4415
|
+
draftLoading: false,
|
|
4416
|
+
draftSaving: false,
|
|
4417
|
+
draftConflict: null,
|
|
4418
|
+
policy: effectivePolicy() ?? null,
|
|
4419
|
+
setModel: (model) => updateChoice({ model }),
|
|
4420
|
+
setReasoningEffort: (reasoningEffort) => updateChoice({ reasoningEffort }),
|
|
4421
|
+
setLatencyMode: (latencyMode) => updateChoice({ latencyMode }),
|
|
4422
|
+
draftPersistence: "disabled",
|
|
4423
|
+
applyDraft: () => {
|
|
4424
|
+
},
|
|
4425
|
+
reloadDraft: NOOP_ASYNC,
|
|
4426
|
+
resolveDraftConflict: NOOP_ASYNC,
|
|
4427
|
+
restoredResources: [],
|
|
4428
|
+
removeRestoredResource: () => {
|
|
4429
|
+
},
|
|
4430
|
+
error: null,
|
|
4431
|
+
clearError: () => {
|
|
4432
|
+
if (ownsScope()) setError(null);
|
|
4433
4433
|
}
|
|
4434
|
-
}
|
|
4434
|
+
};
|
|
4435
4435
|
return {
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4436
|
+
...scope,
|
|
4437
|
+
config,
|
|
4438
|
+
files,
|
|
4439
|
+
uploadsEnabled,
|
|
4440
|
+
available,
|
|
4441
|
+
showModelPicker,
|
|
4442
|
+
catalog,
|
|
4443
|
+
composer,
|
|
4444
|
+
realtimeVoiceEnabled: config.realtimeVoice && (options.realtimeVoice ?? config.realtimeVoiceOffered),
|
|
4441
4445
|
error,
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
deleteGoal: clearGoal,
|
|
4447
|
-
updating: mutating,
|
|
4448
|
-
mutationError,
|
|
4449
|
-
clearMutationError
|
|
4446
|
+
finishingUploads: completion !== null,
|
|
4447
|
+
pending: pending ? { idempotencyKey: pending.key, realtimeModel: pending.realtimeModel } : null,
|
|
4448
|
+
retry: () => pendingRef.current ? deliver(pendingRef.current) : Promise.resolve(false),
|
|
4449
|
+
startRealtime
|
|
4450
4450
|
};
|
|
4451
4451
|
}
|
|
4452
4452
|
|
|
4453
4453
|
export {
|
|
4454
|
-
conversationTimeline,
|
|
4455
4454
|
isTitleEvent,
|
|
4456
4455
|
useSession,
|
|
4457
|
-
useSessionStartupTimeline,
|
|
4458
|
-
useAvailableModels,
|
|
4459
|
-
useWorkspaceModelCatalog,
|
|
4460
|
-
isHumanInputEvent,
|
|
4461
|
-
useHumanInputRequests,
|
|
4462
|
-
useSessionControl,
|
|
4463
4456
|
invokeOlderHistoryLoaderWithReceiptCapture,
|
|
4464
4457
|
createOlderHistoryLoadReceipt,
|
|
4465
4458
|
useTurnlessOutputGap,
|
|
@@ -4471,10 +4464,17 @@ export {
|
|
|
4471
4464
|
boundBrowserSessionEventWindow,
|
|
4472
4465
|
isTurnQueueEvent,
|
|
4473
4466
|
useTurnQueue,
|
|
4467
|
+
isGoalEvent,
|
|
4468
|
+
useGoal,
|
|
4469
|
+
useSessionControl,
|
|
4470
|
+
useAvailableModels,
|
|
4471
|
+
useWorkspaceModelCatalog,
|
|
4472
|
+
isHumanInputEvent,
|
|
4473
|
+
useHumanInputRequests,
|
|
4474
|
+
conversationTimeline,
|
|
4475
|
+
useSessionStartupTimeline,
|
|
4474
4476
|
useSessionConversation,
|
|
4475
4477
|
useSessionReadAcknowledgement,
|
|
4476
|
-
useNewConversation
|
|
4477
|
-
isGoalEvent,
|
|
4478
|
-
useGoal
|
|
4478
|
+
useNewConversation
|
|
4479
4479
|
};
|
|
4480
|
-
//# sourceMappingURL=chunk-
|
|
4480
|
+
//# sourceMappingURL=chunk-PZQEBNWB.js.map
|