@opengeni/react 6.37.0 → 6.37.1-canary.45151322135001
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/README.md +5 -4
- 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 +71 -71
- 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 +66 -66
- 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 +135 -135
- 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 +105 -105
- package/dist/app/components/command-menu/shortcut-sheet.js +22 -22
- 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 +153 -153
- package/dist/app/components/rail/session-header.js +120 -120
- package/dist/app/components/rail/session-list.js +149 -149
- 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 +192 -192
- 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 +113 -113
- 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 +145 -145
- package/dist/app/routes/retained-artifact.js +108 -108
- package/dist/app/routes/session-unavailable.js +5 -5
- package/dist/app/routes/session.js +243 -243
- 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-PJ66EIWE.js → chunk-2LIDFNPL.js} +3 -3
- 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-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-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-YJYKB6ZT.js → chunk-55UOLOEE.js} +5 -5
- 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-4RGFBD4M.js → chunk-7DLBLNFA.js} +284 -284
- package/dist/{chunk-Y3ME7IF6.js → chunk-7MF6MFHS.js} +8 -8
- package/dist/{chunk-T2IFOASN.js → chunk-7T7TPJL2.js} +1754 -1717
- package/dist/chunk-7T7TPJL2.js.map +1 -0
- package/dist/{chunk-5CEQ356Z.js → chunk-7VAILBP6.js} +5 -5
- package/dist/{chunk-DKM3JBGJ.js → chunk-7YKUIKGH.js} +8 -8
- package/dist/{chunk-GGIPEZLL.js → chunk-A5GX3CAE.js} +26 -26
- package/dist/{chunk-E45JRR3J.js → chunk-A7DS77WC.js} +7 -7
- 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-QD4J7AHU.js → chunk-BHKRV3ZB.js} +29 -29
- 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-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-UBR3CGJC.js → chunk-FIKMVWFE.js} +142 -142
- package/dist/{chunk-5AHIKB3O.js → chunk-FXFOKD7A.js} +4 -4
- package/dist/{chunk-HUKGLWAY.js → chunk-GIHE7U3Y.js} +4 -4
- 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-3PTEMOSW.js → chunk-GQYC5UKV.js} +4 -4
- package/dist/{chunk-UJNDUO7D.js → chunk-H7F4ANJQ.js} +13 -13
- 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-THWN4STY.js → chunk-HSPNU52D.js} +68 -68
- package/dist/chunk-HSPNU52D.js.map +1 -0
- package/dist/{chunk-FARCOS2S.js → chunk-I6NVPBMB.js} +7 -7
- package/dist/{chunk-QEXHABRN.js → chunk-I7M5BYJU.js} +6 -6
- package/dist/{chunk-IPFSFSIK.js → chunk-ISFO6OYL.js} +47 -47
- 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-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-MM4NP5QA.js → chunk-NQXCPP4G.js} +9 -9
- package/dist/{chunk-7MH4TTVE.js → chunk-NYGS6FNV.js} +2 -2
- 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-F5RP42TL.js → chunk-OO7N6APA.js} +23 -23
- 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-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-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-J4OOKDRV.js → chunk-QNOWKKZ4.js} +4 -4
- package/dist/{chunk-QMRHY45R.js → chunk-QO3ZGK4X.js} +8 -8
- 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-S2525GSA.js → chunk-QXQASDKT.js} +13 -13
- package/dist/{chunk-VRS6VNHP.js → chunk-QZE3KD34.js} +5 -5
- package/dist/{chunk-COIXX62I.js → chunk-RDLS6IZY.js} +11 -11
- package/dist/{chunk-MSHWYGCH.js → chunk-RKPETJDJ.js} +6 -6
- 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-MIMSPOV4.js → chunk-SGLQ7ZZ7.js} +28 -28
- 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-VJJKN675.js → chunk-THNAEUJV.js} +7561 -7552
- package/dist/chunk-THNAEUJV.js.map +1 -0
- 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-MXRCKJOQ.js → chunk-V6LYW2ZN.js} +154 -154
- package/dist/{chunk-RA3NTKSW.js → chunk-V7YGDHX2.js} +66 -66
- 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-WT37FEG3.js → chunk-WFTPSXUK.js} +8 -8
- package/dist/{chunk-IL5ME4MQ.js → chunk-WPKY3BGG.js} +24 -24
- package/dist/chunk-WPKY3BGG.js.map +1 -0
- package/dist/{chunk-GYHL6IRO.js → chunk-WTSF6HSN.js} +26 -26
- 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-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-R6OBJ7LF.js → chunk-YAVW5OJ5.js} +4 -4
- package/dist/{chunk-WUKLEDKK.js → chunk-YDMV2NJZ.js} +48 -48
- package/dist/{chunk-7IR7EOTR.js → chunk-YMKKZFKH.js} +37 -37
- 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-YS6BQNHF.js → chunk-ZE4RD7U5.js} +8 -8
- package/dist/{chunk-EJ6IIEZX.js → chunk-ZLBGIMKD.js} +19 -7
- package/dist/chunk-ZLBGIMKD.js.map +1 -0
- 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/components/model-level-picker.d.ts +7 -7
- package/dist/composer.js +35 -35
- 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/hooks/use-new-conversation.d.ts +5 -0
- 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 +42 -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/src/components/model-level-picker.tsx +19 -9
- package/src/components/new-conversation.tsx +18 -4
- package/src/hooks/use-new-conversation.ts +62 -17
- package/dist/chunk-6F34IWSA.js.map +0 -1
- package/dist/chunk-D32VVOBJ.js.map +0 -1
- package/dist/chunk-EJ6IIEZX.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-PJ66EIWE.js.map → chunk-2LIDFNPL.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-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-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-YJYKB6ZT.js.map → chunk-55UOLOEE.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-4RGFBD4M.js.map → chunk-7DLBLNFA.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-DKM3JBGJ.js.map → chunk-7YKUIKGH.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-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-QD4J7AHU.js.map → chunk-BHKRV3ZB.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-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-UBR3CGJC.js.map → chunk-FIKMVWFE.js.map} +0 -0
- /package/dist/{chunk-5AHIKB3O.js.map → chunk-FXFOKD7A.js.map} +0 -0
- /package/dist/{chunk-HUKGLWAY.js.map → chunk-GIHE7U3Y.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-3PTEMOSW.js.map → chunk-GQYC5UKV.js.map} +0 -0
- /package/dist/{chunk-UJNDUO7D.js.map → chunk-H7F4ANJQ.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-FARCOS2S.js.map → chunk-I6NVPBMB.js.map} +0 -0
- /package/dist/{chunk-QEXHABRN.js.map → chunk-I7M5BYJU.js.map} +0 -0
- /package/dist/{chunk-IPFSFSIK.js.map → chunk-ISFO6OYL.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-MM4NP5QA.js.map → chunk-NQXCPP4G.js.map} +0 -0
- /package/dist/{chunk-7MH4TTVE.js.map → chunk-NYGS6FNV.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-F5RP42TL.js.map → chunk-OO7N6APA.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-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-J4OOKDRV.js.map → chunk-QNOWKKZ4.js.map} +0 -0
- /package/dist/{chunk-QMRHY45R.js.map → chunk-QO3ZGK4X.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-S2525GSA.js.map → chunk-QXQASDKT.js.map} +0 -0
- /package/dist/{chunk-VRS6VNHP.js.map → chunk-QZE3KD34.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-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-MIMSPOV4.js.map → chunk-SGLQ7ZZ7.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-MXRCKJOQ.js.map → chunk-V6LYW2ZN.js.map} +0 -0
- /package/dist/{chunk-RA3NTKSW.js.map → chunk-V7YGDHX2.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-WT37FEG3.js.map → chunk-WFTPSXUK.js.map} +0 -0
- /package/dist/{chunk-GYHL6IRO.js.map → chunk-WTSF6HSN.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-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-R6OBJ7LF.js.map → chunk-YAVW5OJ5.js.map} +0 -0
- /package/dist/{chunk-WUKLEDKK.js.map → chunk-YDMV2NJZ.js.map} +0 -0
- /package/dist/{chunk-7IR7EOTR.js.map → chunk-YMKKZFKH.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-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,39 @@ 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";
|
|
50
|
+
import {
|
|
51
|
+
modelLevelChoice,
|
|
52
|
+
modelLevelsView
|
|
53
|
+
} from "./chunk-X6UMGG4T.js";
|
|
48
54
|
import {
|
|
49
55
|
joinClientConfigRead
|
|
50
56
|
} from "./chunk-IGVL3ELX.js";
|
|
51
57
|
import {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
useComposer
|
|
55
|
-
} from "./chunk-I2WTJMQF.js";
|
|
58
|
+
admissionRecheckControl
|
|
59
|
+
} from "./chunk-MRNAHGBL.js";
|
|
56
60
|
import {
|
|
57
61
|
DEFAULT_TRANSIENT_READ_RETRY,
|
|
58
62
|
projectionReadThrough,
|
|
@@ -66,6 +70,13 @@ import {
|
|
|
66
70
|
import {
|
|
67
71
|
normalizeError
|
|
68
72
|
} from "./chunk-CM7LVUKC.js";
|
|
73
|
+
import {
|
|
74
|
+
coerceReasoningEffortForModel,
|
|
75
|
+
defaultEffortForModel,
|
|
76
|
+
projectPickerRows,
|
|
77
|
+
runnableLatencyModesForModel,
|
|
78
|
+
sortPickerRows
|
|
79
|
+
} from "./chunk-4VEIBNC2.js";
|
|
69
80
|
import {
|
|
70
81
|
useEmbeddedGoal,
|
|
71
82
|
useEmbeddedHumanInputSession,
|
|
@@ -74,88 +85,10 @@ import {
|
|
|
74
85
|
useOpenGeni,
|
|
75
86
|
useOpenGeniClient
|
|
76
87
|
} from "./chunk-BVUAHAQX.js";
|
|
77
|
-
import {
|
|
78
|
-
coerceReasoningEffortForModel,
|
|
79
|
-
defaultEffortForModel,
|
|
80
|
-
projectPickerRows,
|
|
81
|
-
runnableLatencyModesForModel,
|
|
82
|
-
sortPickerRows
|
|
83
|
-
} from "./chunk-4VEIBNC2.js";
|
|
84
88
|
import {
|
|
85
89
|
useOpenGeniText
|
|
86
90
|
} from "./chunk-2L6B6766.js";
|
|
87
91
|
|
|
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
92
|
// src/hooks/use-session.ts
|
|
160
93
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
161
94
|
|
|
@@ -316,882 +249,386 @@ function useSession(sessionId, options = {}) {
|
|
|
316
249
|
};
|
|
317
250
|
}
|
|
318
251
|
|
|
319
|
-
// src/
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
252
|
+
// src/older-history.ts
|
|
253
|
+
var activeReceiptCapture;
|
|
254
|
+
var preserveTailForAutomaticLoad = false;
|
|
255
|
+
function invokeOlderHistoryLoaderWithReceiptCapture(load, capture, preserveTail = false) {
|
|
256
|
+
const previousCapture = activeReceiptCapture;
|
|
257
|
+
const previousPreserveTail = preserveTailForAutomaticLoad;
|
|
258
|
+
activeReceiptCapture = capture;
|
|
259
|
+
preserveTailForAutomaticLoad = preserveTail;
|
|
260
|
+
try {
|
|
261
|
+
return load();
|
|
262
|
+
} finally {
|
|
263
|
+
activeReceiptCapture = previousCapture;
|
|
264
|
+
preserveTailForAutomaticLoad = previousPreserveTail;
|
|
265
|
+
}
|
|
325
266
|
}
|
|
326
|
-
function
|
|
327
|
-
|
|
267
|
+
function createOlderHistoryLoadReceipt(load) {
|
|
268
|
+
let resolveResult;
|
|
269
|
+
let rejectResult;
|
|
270
|
+
const result = new Promise((resolve, reject) => {
|
|
271
|
+
resolveResult = resolve;
|
|
272
|
+
rejectResult = reject;
|
|
273
|
+
});
|
|
274
|
+
result.committed = false;
|
|
275
|
+
result.tailPreserved = false;
|
|
276
|
+
activeReceiptCapture?.(result);
|
|
277
|
+
try {
|
|
278
|
+
const loaded = load(
|
|
279
|
+
() => {
|
|
280
|
+
result.committed = true;
|
|
281
|
+
},
|
|
282
|
+
preserveTailForAutomaticLoad,
|
|
283
|
+
() => {
|
|
284
|
+
result.tailPreserved = true;
|
|
285
|
+
}
|
|
286
|
+
);
|
|
287
|
+
Promise.resolve(loaded).then(resolveResult, rejectResult);
|
|
288
|
+
} catch (error) {
|
|
289
|
+
rejectResult(error);
|
|
290
|
+
}
|
|
291
|
+
return result;
|
|
328
292
|
}
|
|
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
|
-
|
|
293
|
+
|
|
294
|
+
// src/hooks/use-session-events.ts
|
|
295
|
+
import {
|
|
296
|
+
isPresentedSessionToolCall,
|
|
297
|
+
isRetryableStreamError,
|
|
298
|
+
isSessionModelResponsePhase,
|
|
299
|
+
isTransientRequestError,
|
|
300
|
+
SESSION_EVENT_COMPAT_EXCLUDED_STEP_TYPES,
|
|
301
|
+
SESSION_EVENT_CONTENT_STEP_TYPES,
|
|
302
|
+
SESSION_EVENT_CONVERSATION_FILTER_VERSION,
|
|
303
|
+
SESSION_EVENT_STEP_TYPES,
|
|
304
|
+
sessionEventStreamCoveredThrough
|
|
305
|
+
} from "@opengeni/sdk";
|
|
306
|
+
import { startTransition, useCallback as useCallback3, useEffect as useEffect2, useMemo as useMemo2, useRef as useRef2, useState as useState2 } from "react";
|
|
307
|
+
|
|
308
|
+
// src/hooks/page-wake.ts
|
|
309
|
+
var PAGE_WAKE_CHECK_INTERVAL_MS = 2e3;
|
|
310
|
+
var PAGE_WAKE_GAP_MS = 15e3;
|
|
311
|
+
var listeners = /* @__PURE__ */ new Set();
|
|
312
|
+
var stopDetector = null;
|
|
313
|
+
function subscribePageWake(listener) {
|
|
314
|
+
listeners.add(listener);
|
|
315
|
+
stopDetector ??= startDetector();
|
|
316
|
+
return () => {
|
|
317
|
+
listeners.delete(listener);
|
|
318
|
+
if (listeners.size === 0 && stopDetector) {
|
|
319
|
+
stopDetector();
|
|
320
|
+
stopDetector = null;
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
function emitPageWake() {
|
|
325
|
+
for (const listener of [...listeners]) {
|
|
326
|
+
try {
|
|
327
|
+
listener();
|
|
328
|
+
} catch {
|
|
359
329
|
}
|
|
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
330
|
}
|
|
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
331
|
}
|
|
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
|
-
|
|
332
|
+
function startDetector() {
|
|
333
|
+
if (typeof window === "undefined" || typeof document === "undefined") return () => {
|
|
334
|
+
};
|
|
335
|
+
let lastTick = Date.now();
|
|
336
|
+
const check = () => {
|
|
337
|
+
const now = Date.now();
|
|
338
|
+
const elapsed = now - lastTick;
|
|
339
|
+
lastTick = now;
|
|
340
|
+
if (elapsed > PAGE_WAKE_GAP_MS) emitPageWake();
|
|
341
|
+
};
|
|
342
|
+
const onVisibility = () => {
|
|
343
|
+
if (document.visibilityState !== "hidden") check();
|
|
344
|
+
};
|
|
345
|
+
const onPageShow = (event) => {
|
|
346
|
+
lastTick = Date.now();
|
|
347
|
+
if (event?.persisted === true) emitPageWake();
|
|
348
|
+
};
|
|
349
|
+
const onResume = () => {
|
|
350
|
+
lastTick = Date.now();
|
|
351
|
+
emitPageWake();
|
|
352
|
+
};
|
|
353
|
+
const timer = setInterval(check, PAGE_WAKE_CHECK_INTERVAL_MS);
|
|
354
|
+
document.addEventListener("visibilitychange", onVisibility);
|
|
355
|
+
document.addEventListener("resume", onResume);
|
|
356
|
+
window.addEventListener("pageshow", onPageShow);
|
|
357
|
+
window.addEventListener("online", onResume);
|
|
358
|
+
return () => {
|
|
359
|
+
clearInterval(timer);
|
|
360
|
+
document.removeEventListener("visibilitychange", onVisibility);
|
|
361
|
+
document.removeEventListener("resume", onResume);
|
|
362
|
+
window.removeEventListener("pageshow", onPageShow);
|
|
363
|
+
window.removeEventListener("online", onResume);
|
|
364
|
+
};
|
|
432
365
|
}
|
|
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
|
|
366
|
+
|
|
367
|
+
// src/hooks/turnless-output-gaps.ts
|
|
368
|
+
import { useCallback as useCallback2, useSyncExternalStore } from "react";
|
|
369
|
+
var MAX_IDLE_ENTRIES = 256;
|
|
370
|
+
var entries = /* @__PURE__ */ new Map();
|
|
371
|
+
function gapKey(workspaceId, sessionId) {
|
|
372
|
+
return `${workspaceId}\0${sessionId}`;
|
|
373
|
+
}
|
|
374
|
+
function gapEntry(key) {
|
|
375
|
+
let entry = entries.get(key);
|
|
376
|
+
if (!entry) {
|
|
377
|
+
entry = { generation: 0, listeners: /* @__PURE__ */ new Set() };
|
|
378
|
+
entries.set(key, entry);
|
|
379
|
+
if (entries.size > MAX_IDLE_ENTRIES) {
|
|
380
|
+
for (const [candidate, held] of entries) {
|
|
381
|
+
if (entries.size <= MAX_IDLE_ENTRIES) break;
|
|
382
|
+
if (candidate !== key && held.listeners.size === 0) entries.delete(candidate);
|
|
531
383
|
}
|
|
532
|
-
|
|
384
|
+
}
|
|
533
385
|
}
|
|
534
|
-
|
|
535
|
-
return items;
|
|
386
|
+
return entry;
|
|
536
387
|
}
|
|
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
|
-
};
|
|
388
|
+
function markTurnlessOutputGap(workspaceId, sessionId) {
|
|
389
|
+
const entry = gapEntry(gapKey(workspaceId, sessionId));
|
|
390
|
+
entry.generation += 1;
|
|
391
|
+
for (const listener of [...entry.listeners]) listener();
|
|
557
392
|
}
|
|
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
|
|
393
|
+
function useTurnlessOutputGap(workspaceId, sessionId) {
|
|
394
|
+
const key = sessionId ? gapKey(workspaceId, sessionId) : null;
|
|
395
|
+
const subscribe = useCallback2(
|
|
396
|
+
(listener) => {
|
|
397
|
+
if (!key) return () => {
|
|
398
|
+
};
|
|
399
|
+
const entry = gapEntry(key);
|
|
400
|
+
entry.listeners.add(listener);
|
|
401
|
+
return () => {
|
|
402
|
+
entry.listeners.delete(listener);
|
|
575
403
|
};
|
|
576
404
|
},
|
|
577
|
-
[
|
|
405
|
+
[key]
|
|
578
406
|
);
|
|
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
|
-
};
|
|
407
|
+
const read = useCallback2(() => key ? entries.get(key)?.generation ?? 0 : 0, [key]);
|
|
408
|
+
return useSyncExternalStore(subscribe, read, read);
|
|
592
409
|
}
|
|
593
410
|
|
|
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
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
const
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
{ enabled, discard: deniesRetainedView(state.error) }
|
|
411
|
+
// src/hooks/use-session-events.ts
|
|
412
|
+
import { errorMessage } from "@opengeni/contracts/values";
|
|
413
|
+
var SESSION_FIRST_WINDOW_PAGE_SIZE = 255;
|
|
414
|
+
var SESSION_HISTORY_PAGE_SIZE = 1e3;
|
|
415
|
+
var INITIAL_FETCH_CAP = 1;
|
|
416
|
+
var OLDER_GROUP_TARGET = 32;
|
|
417
|
+
var OLDER_FETCH_CAP = 2;
|
|
418
|
+
var NEWER_GROUP_TARGET = 32;
|
|
419
|
+
var NEWER_FETCH_CAP = 2;
|
|
420
|
+
var OLDEST_GROUP_TARGET = 32;
|
|
421
|
+
var OLDEST_FETCH_CAP = 2;
|
|
422
|
+
var BOUNDARY_PAGE_CAP = 1;
|
|
423
|
+
var FILTERED_PAGE_CAP = 32;
|
|
424
|
+
var DIRECT_REPLAY_MAX_SEQUENCES = 16;
|
|
425
|
+
var CATCHUP_MAX_PAGES = 2;
|
|
426
|
+
var STRICT_REJOIN_ATTEMPTS = 5;
|
|
427
|
+
var REJOIN_STALL_TIMEOUT_MS = 3e4;
|
|
428
|
+
var FOREGROUND_REJOIN_RETRY_MS = 500;
|
|
429
|
+
var FOREGROUND_REJOIN_RETRY_MAX_MS = 8e3;
|
|
430
|
+
var EMPTY_EVENTS = [];
|
|
431
|
+
var encoder = new TextEncoder();
|
|
432
|
+
var SESSION_EVENT_BROWSER_MAX_BYTES = 16 * 1024 * 1024;
|
|
433
|
+
var SESSION_EVENT_BROWSER_MAX_COUNT = 2e4;
|
|
434
|
+
var SESSION_EVENT_BROWSER_PENDING_MAX_BYTES = 1024 * 1024;
|
|
435
|
+
var SESSION_EVENT_BROWSER_PENDING_MAX_COUNT = 256;
|
|
436
|
+
var EMPTY_EVENT_WINDOW = {
|
|
437
|
+
events: EMPTY_EVENTS,
|
|
438
|
+
bytes: 2,
|
|
439
|
+
truncated: false
|
|
440
|
+
};
|
|
441
|
+
function useSessionEvents(sessionId, options = {}) {
|
|
442
|
+
const t = useOpenGeniText();
|
|
443
|
+
const { client, workspaceId, reconcileSession } = useEmbeddedSession(options);
|
|
444
|
+
const enabled = options.enabled ?? true;
|
|
445
|
+
const pageLive = usePageLiveActivity();
|
|
446
|
+
const streamEnabled = enabled && pageLive;
|
|
447
|
+
const after = options.after ?? 0;
|
|
448
|
+
const replay = options.replay ?? "windowed";
|
|
449
|
+
const fullReplay = replay === "full" || after !== 0;
|
|
450
|
+
const streamKey = `${workspaceId}\0${sessionId ?? ""}\0${after}\0${fullReplay ? "full" : "windowed"}`;
|
|
451
|
+
const navigationIdentityRef = useRef2({ client, streamKey, enabled });
|
|
452
|
+
if (navigationIdentityRef.current.client !== client || navigationIdentityRef.current.streamKey !== streamKey || navigationIdentityRef.current.enabled !== enabled) {
|
|
453
|
+
navigationIdentityRef.current = { client, streamKey, enabled };
|
|
454
|
+
}
|
|
455
|
+
const navigationIdentity = navigationIdentityRef.current;
|
|
456
|
+
const ownsNavigation = useCallback3(
|
|
457
|
+
() => navigationIdentityRef.current === navigationIdentity,
|
|
458
|
+
[navigationIdentity]
|
|
459
|
+
);
|
|
460
|
+
const [eventWindow, setEventWindow] = useState2(EMPTY_EVENT_WINDOW);
|
|
461
|
+
const [questionEvidence, setQuestionEvidence] = useState2(null);
|
|
462
|
+
const [connectionState, setConnectionState] = useState2("idle");
|
|
463
|
+
const [error, setError] = useState2(null);
|
|
464
|
+
const [newerError, setNewerError] = useState2(null);
|
|
465
|
+
const [hasOlder, setHasOlder] = useState2(false);
|
|
466
|
+
const [hasNewer, setHasNewer] = useState2(false);
|
|
467
|
+
const [sessionStatusProjection, setSessionStatusProjection] = useState2(
|
|
468
|
+
null
|
|
653
469
|
);
|
|
470
|
+
const [initialLoading, setInitialLoading] = useState2(true);
|
|
471
|
+
const [initialHistoryReady, setInitialHistoryReady] = useState2(false);
|
|
472
|
+
const [loadingOlder, setLoadingOlder] = useState2(false);
|
|
473
|
+
const [loadingNewer, setLoadingNewer] = useState2(false);
|
|
474
|
+
const [loadingOldest, setLoadingOldest] = useState2(false);
|
|
475
|
+
const [loadingLatest, setLoadingLatest] = useState2(false);
|
|
476
|
+
const [loadingTarget, setLoadingTarget] = useState2(false);
|
|
477
|
+
const loadingTargetRef = useRef2(false);
|
|
478
|
+
const [streamEpoch, setStreamEpoch] = useState2(0);
|
|
479
|
+
const [viewMode, setViewMode] = useState2("live");
|
|
480
|
+
const lastSequenceRef = useRef2(after);
|
|
481
|
+
const streamResumeSequenceRef = useRef2(after);
|
|
482
|
+
const skippedStepsThroughRef = useRef2(null);
|
|
483
|
+
const oldestSequenceRef = useRef2(null);
|
|
484
|
+
const newestSequenceRef = useRef2(null);
|
|
485
|
+
const hasOlderRef = useRef2(false);
|
|
486
|
+
const hasNewerRef = useRef2(false);
|
|
487
|
+
const loadingOlderRef = useRef2(false);
|
|
488
|
+
const loadingNewerRef = useRef2(false);
|
|
489
|
+
const loadingOldestRef = useRef2(false);
|
|
490
|
+
const loadingLatestRef = useRef2(false);
|
|
491
|
+
const viewModeRef = useRef2("live");
|
|
492
|
+
const initialWindowLoadedRef = useRef2(false);
|
|
493
|
+
const openedStreamKeyRef = useRef2(null);
|
|
494
|
+
const reconcileAfterPageResumeRef = useRef2(false);
|
|
495
|
+
const streamAbortRef = useRef2(null);
|
|
496
|
+
const streamKeyRef = useRef2(null);
|
|
497
|
+
const generationRef = useRef2(0);
|
|
498
|
+
const navigationGenerationRef = useRef2(0);
|
|
499
|
+
const eventWindowRef = useRef2(EMPTY_EVENT_WINDOW);
|
|
500
|
+
const sessionStatusRef = useRef2({
|
|
501
|
+
sequence: after,
|
|
502
|
+
status: null
|
|
503
|
+
});
|
|
504
|
+
const [stateStreamKey, setStateStreamKey] = useState2(streamKey);
|
|
505
|
+
const historyFilter = fullReplay ? void 0 : CONVERSATION_FILTER;
|
|
506
|
+
const [stepStores, setStepStores] = useState2(EMPTY_STEP_STORES);
|
|
507
|
+
const stepStoresRef = useRef2(EMPTY_STEP_STORES);
|
|
508
|
+
const [turnlessSteps, setTurnlessSteps] = useState2(EMPTY_TURNLESS_STEPS);
|
|
509
|
+
const turnlessStepsRef = useRef2(EMPTY_TURNLESS_STEPS);
|
|
510
|
+
const renderedTurnlessRef = useRef2({ appended: 0, marked: false });
|
|
654
511
|
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);
|
|
512
|
+
renderedTurnlessRef.current = { appended: turnlessSteps.appended, marked: false };
|
|
513
|
+
}, [turnlessSteps]);
|
|
514
|
+
const liveThroughRef = useRef2(0);
|
|
515
|
+
const stepGenerationRef = useRef2(0);
|
|
516
|
+
const stepRequestRef = useRef2(0);
|
|
517
|
+
const retainedTurnsRef = useRef2(/* @__PURE__ */ new Map());
|
|
518
|
+
const turnStepHandlesRef = useRef2(/* @__PURE__ */ new Map());
|
|
519
|
+
const presentedCallIdsRef = useRef2(/* @__PURE__ */ new Set());
|
|
520
|
+
const presentedScanRef = useRef2(null);
|
|
521
|
+
const startupRef = useRef2(emptyStartupTurns());
|
|
522
|
+
const [presentedOutputs, setPresentedOutputs] = useState2(EMPTY_PRESENTED_OUTPUTS);
|
|
523
|
+
const presentedRequestedRef = useRef2(/* @__PURE__ */ new Map());
|
|
524
|
+
const presentedFailuresRef = useRef2(/* @__PURE__ */ new Map());
|
|
525
|
+
const [presentedPass, setPresentedPass] = useState2(0);
|
|
526
|
+
const rejoinPendingRef = useRef2(false);
|
|
527
|
+
const streamTransientStreakRef = useRef2(null);
|
|
528
|
+
const commitStepStores = useCallback3((next) => {
|
|
529
|
+
stepStoresRef.current = next;
|
|
530
|
+
setStepStores(next);
|
|
531
|
+
}, []);
|
|
532
|
+
const pruneStepStores = useCallback3(
|
|
533
|
+
(window2, sealedBy, rereading = null) => {
|
|
534
|
+
const present = windowTurns(window2);
|
|
535
|
+
const settled = sealedBy ? settledTurns(sealedBy) : null;
|
|
536
|
+
const next = /* @__PURE__ */ new Map();
|
|
537
|
+
for (const [turnId, store] of stepStoresRef.current) {
|
|
538
|
+
if (present.has(turnId) && (!settled || settled.has(turnId) || turnId === rereading)) {
|
|
539
|
+
next.set(turnId, store);
|
|
689
540
|
}
|
|
690
541
|
}
|
|
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
|
-
};
|
|
542
|
+
if (next.size !== stepStoresRef.current.size) commitStepStores(next);
|
|
543
|
+
if (sealedBy) {
|
|
544
|
+
presentedRequestedRef.current = /* @__PURE__ */ new Map();
|
|
545
|
+
} else {
|
|
546
|
+
for (const [callId, request] of presentedRequestedRef.current) {
|
|
547
|
+
if (request.turnId && !present.has(request.turnId)) {
|
|
548
|
+
presentedRequestedRef.current.delete(callId);
|
|
549
|
+
}
|
|
550
|
+
}
|
|
765
551
|
}
|
|
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;
|
|
552
|
+
setPresentedOutputs((current) => {
|
|
553
|
+
let kept = null;
|
|
554
|
+
for (const [callId, output] of current) {
|
|
555
|
+
if (output.turnId && present.has(output.turnId)) continue;
|
|
556
|
+
kept ??= new Map(current);
|
|
557
|
+
kept.delete(callId);
|
|
780
558
|
}
|
|
559
|
+
return kept ?? current;
|
|
781
560
|
});
|
|
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
561
|
},
|
|
788
|
-
[
|
|
562
|
+
[commitStepStores]
|
|
789
563
|
);
|
|
790
|
-
const
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
clearControlError();
|
|
801
|
-
clearApprovalError();
|
|
802
|
-
}, [clearControlError, clearApprovalError]);
|
|
803
|
-
return {
|
|
804
|
-
pause,
|
|
805
|
-
resume,
|
|
806
|
-
controlling,
|
|
807
|
-
approve,
|
|
808
|
-
reject,
|
|
809
|
-
responding,
|
|
810
|
-
error,
|
|
811
|
-
clearError
|
|
812
|
-
};
|
|
813
|
-
}
|
|
814
|
-
|
|
815
|
-
// src/older-history.ts
|
|
816
|
-
var activeReceiptCapture;
|
|
817
|
-
var preserveTailForAutomaticLoad = false;
|
|
818
|
-
function invokeOlderHistoryLoaderWithReceiptCapture(load, capture, preserveTail = false) {
|
|
819
|
-
const previousCapture = activeReceiptCapture;
|
|
820
|
-
const previousPreserveTail = preserveTailForAutomaticLoad;
|
|
821
|
-
activeReceiptCapture = capture;
|
|
822
|
-
preserveTailForAutomaticLoad = preserveTail;
|
|
823
|
-
try {
|
|
824
|
-
return load();
|
|
825
|
-
} finally {
|
|
826
|
-
activeReceiptCapture = previousCapture;
|
|
827
|
-
preserveTailForAutomaticLoad = previousPreserveTail;
|
|
828
|
-
}
|
|
829
|
-
}
|
|
830
|
-
function createOlderHistoryLoadReceipt(load) {
|
|
831
|
-
let resolveResult;
|
|
832
|
-
let rejectResult;
|
|
833
|
-
const result = new Promise((resolve, reject) => {
|
|
834
|
-
resolveResult = resolve;
|
|
835
|
-
rejectResult = reject;
|
|
836
|
-
});
|
|
837
|
-
result.committed = false;
|
|
838
|
-
result.tailPreserved = false;
|
|
839
|
-
activeReceiptCapture?.(result);
|
|
840
|
-
try {
|
|
841
|
-
const loaded = load(
|
|
842
|
-
() => {
|
|
843
|
-
result.committed = true;
|
|
844
|
-
},
|
|
845
|
-
preserveTailForAutomaticLoad,
|
|
846
|
-
() => {
|
|
847
|
-
result.tailPreserved = true;
|
|
564
|
+
const presentedCallIds = useCallback3((event) => {
|
|
565
|
+
const ids = presentedCallIdsRef.current;
|
|
566
|
+
if (event.type === "agent.toolCall.created") {
|
|
567
|
+
notePresentedCalls([event], ids);
|
|
568
|
+
} else if (event.type === "agent.toolCall.output") {
|
|
569
|
+
const payload = event.payload;
|
|
570
|
+
const windowEvents = eventWindowRef.current.events;
|
|
571
|
+
if (typeof payload?.id === "string" && !ids.has(payload.id) && presentedScanRef.current !== windowEvents) {
|
|
572
|
+
presentedScanRef.current = windowEvents;
|
|
573
|
+
notePresentedCalls(windowEvents, ids);
|
|
848
574
|
}
|
|
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
575
|
}
|
|
885
|
-
|
|
886
|
-
}
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
576
|
+
return ids;
|
|
577
|
+
}, []);
|
|
578
|
+
const startupTurns = useCallback3(() => {
|
|
579
|
+
const windowEvents = eventWindowRef.current.events;
|
|
580
|
+
if (startupRef.current.window !== windowEvents) {
|
|
581
|
+
const state = emptyStartupTurns();
|
|
582
|
+
noteStartupTurns(windowEvents, state);
|
|
583
|
+
state.window = windowEvents;
|
|
584
|
+
startupRef.current = state;
|
|
892
585
|
}
|
|
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);
|
|
586
|
+
return startupRef.current;
|
|
587
|
+
}, []);
|
|
588
|
+
const appendLiveSteps = useCallback3(
|
|
589
|
+
(steps) => {
|
|
590
|
+
if (steps.some((event) => !event.turnId)) {
|
|
591
|
+
const incoming = steps.filter((event) => !event.turnId);
|
|
592
|
+
const turnless = appendTurnlessSteps(turnlessStepsRef.current, incoming);
|
|
593
|
+
const rendered = renderedTurnlessRef.current;
|
|
594
|
+
if (!rendered.marked && turnless.appended - rendered.appended > turnless.events.length) {
|
|
595
|
+
rendered.marked = true;
|
|
596
|
+
if (sessionId) markTurnlessOutputGap(workspaceId, sessionId);
|
|
597
|
+
}
|
|
598
|
+
turnlessStepsRef.current = turnless;
|
|
599
|
+
setTurnlessSteps(turnless);
|
|
946
600
|
}
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
601
|
+
const windowEvents = withTurnlessSteps(
|
|
602
|
+
eventWindowRef.current.events,
|
|
603
|
+
turnlessStepsRef.current
|
|
604
|
+
);
|
|
605
|
+
const next = new Map(stepStoresRef.current);
|
|
606
|
+
const now = Date.now();
|
|
607
|
+
for (const [turnId, events] of groupByTurn(steps)) {
|
|
608
|
+
const existing = next.get(turnId);
|
|
609
|
+
const store = existing ?? {
|
|
610
|
+
events: [],
|
|
611
|
+
bytes: 2,
|
|
612
|
+
// Earlier steps exist when the window skips sequences between the
|
|
613
|
+
// turn's start and this first live step.
|
|
614
|
+
hasOlder: turnHasHiddenSequences(windowEvents, turnId, events[0].sequence),
|
|
615
|
+
cursor: null,
|
|
616
|
+
floor: null,
|
|
617
|
+
pinned: null,
|
|
618
|
+
loading: false,
|
|
619
|
+
error: false,
|
|
620
|
+
touched: now,
|
|
621
|
+
requestId: 0
|
|
622
|
+
};
|
|
623
|
+
let updated = { ...store, ...appendStepEvents(store, events), touched: now };
|
|
624
|
+
if (!retainedTurnsRef.current.get(turnId)) updated = trimLiveStepTail(updated);
|
|
625
|
+
next.set(turnId, updated);
|
|
626
|
+
}
|
|
627
|
+
commitStepStores(boundStepStores(next, retainedTurnsRef.current));
|
|
967
628
|
},
|
|
968
|
-
[
|
|
629
|
+
[commitStepStores, workspaceId, sessionId]
|
|
969
630
|
);
|
|
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(
|
|
631
|
+
const loadTurnSteps = useCallback3(
|
|
1195
632
|
(turnId, before) => {
|
|
1196
633
|
if (!ownsNavigation() || !sessionId || fullReplay) return;
|
|
1197
634
|
const current = stepStoresRef.current.get(turnId);
|
|
@@ -1287,11 +724,11 @@ function useSessionEvents(sessionId, options = {}) {
|
|
|
1287
724
|
},
|
|
1288
725
|
[client, workspaceId, sessionId, fullReplay, ownsNavigation, commitStepStores]
|
|
1289
726
|
);
|
|
1290
|
-
const loadTurnStepsRef =
|
|
1291
|
-
|
|
727
|
+
const loadTurnStepsRef = useRef2(loadTurnSteps);
|
|
728
|
+
useEffect2(() => {
|
|
1292
729
|
loadTurnStepsRef.current = loadTurnSteps;
|
|
1293
730
|
}, [loadTurnSteps]);
|
|
1294
|
-
const turnStepHandle =
|
|
731
|
+
const turnStepHandle = useCallback3((turnId) => {
|
|
1295
732
|
let handle = turnStepHandlesRef.current.get(turnId);
|
|
1296
733
|
if (!handle) {
|
|
1297
734
|
const retained = retainedTurnsRef.current;
|
|
@@ -1313,7 +750,7 @@ function useSessionEvents(sessionId, options = {}) {
|
|
|
1313
750
|
}
|
|
1314
751
|
return handle;
|
|
1315
752
|
}, []);
|
|
1316
|
-
|
|
753
|
+
useEffect2(() => {
|
|
1317
754
|
navigationGenerationRef.current += 1;
|
|
1318
755
|
setNewerError(null);
|
|
1319
756
|
loadingOlderRef.current = false;
|
|
@@ -1329,7 +766,7 @@ function useSessionEvents(sessionId, options = {}) {
|
|
|
1329
766
|
navigationGenerationRef.current += 1;
|
|
1330
767
|
};
|
|
1331
768
|
}, [client, workspaceId, sessionId, after, enabled, fullReplay]);
|
|
1332
|
-
|
|
769
|
+
useEffect2(() => {
|
|
1333
770
|
if (streamKeyRef.current !== streamKey) {
|
|
1334
771
|
streamKeyRef.current = streamKey;
|
|
1335
772
|
setStateStreamKey(streamKey);
|
|
@@ -1857,7 +1294,7 @@ function useSessionEvents(sessionId, options = {}) {
|
|
|
1857
1294
|
presentedCallIds,
|
|
1858
1295
|
startupTurns
|
|
1859
1296
|
]);
|
|
1860
|
-
|
|
1297
|
+
useEffect2(() => {
|
|
1861
1298
|
if (!sessionId || !streamEnabled) return;
|
|
1862
1299
|
return subscribePageWake(() => {
|
|
1863
1300
|
const stream = streamAbortRef.current;
|
|
@@ -1869,7 +1306,7 @@ function useSessionEvents(sessionId, options = {}) {
|
|
|
1869
1306
|
});
|
|
1870
1307
|
}, [sessionId, streamEnabled, fullReplay]);
|
|
1871
1308
|
const navigationBusy = () => loadingTargetRef.current || loadingOlderRef.current || loadingNewerRef.current || loadingOldestRef.current || loadingLatestRef.current;
|
|
1872
|
-
const loadOlder =
|
|
1309
|
+
const loadOlder = useCallback3(
|
|
1873
1310
|
() => createOlderHistoryLoadReceipt(async (markCommitted, preserveTail, markTailPreserved) => {
|
|
1874
1311
|
if (!ownsNavigation() || !sessionId || navigationBusy() || !hasOlderRef.current) {
|
|
1875
1312
|
return false;
|
|
@@ -1996,7 +1433,7 @@ function useSessionEvents(sessionId, options = {}) {
|
|
|
1996
1433
|
}),
|
|
1997
1434
|
[client, workspaceId, sessionId, ownsNavigation, t, historyFilter, pruneStepStores]
|
|
1998
1435
|
);
|
|
1999
|
-
const loadOldest =
|
|
1436
|
+
const loadOldest = useCallback3(async () => {
|
|
2000
1437
|
if (!ownsNavigation() || !sessionId || navigationBusy() || !hasOlderRef.current) {
|
|
2001
1438
|
return false;
|
|
2002
1439
|
}
|
|
@@ -2067,7 +1504,7 @@ function useSessionEvents(sessionId, options = {}) {
|
|
|
2067
1504
|
}
|
|
2068
1505
|
}
|
|
2069
1506
|
}, [client, workspaceId, sessionId, ownsNavigation, t, historyFilter, pruneStepStores]);
|
|
2070
|
-
const loadNewer =
|
|
1507
|
+
const loadNewer = useCallback3(async () => {
|
|
2071
1508
|
if (!ownsNavigation() || !sessionId || navigationBusy() || !hasNewerRef.current) {
|
|
2072
1509
|
return false;
|
|
2073
1510
|
}
|
|
@@ -2173,7 +1610,7 @@ function useSessionEvents(sessionId, options = {}) {
|
|
|
2173
1610
|
}
|
|
2174
1611
|
}
|
|
2175
1612
|
}, [client, workspaceId, sessionId, ownsNavigation, t, historyFilter, pruneStepStores]);
|
|
2176
|
-
const jumpToSequence =
|
|
1613
|
+
const jumpToSequence = useCallback3(
|
|
2177
1614
|
async (sequence, navigationOptions) => {
|
|
2178
1615
|
const signal = navigationOptions?.signal;
|
|
2179
1616
|
if (!ownsNavigation() || !sessionId || !Number.isSafeInteger(sequence) || sequence < 1)
|
|
@@ -2258,7 +1695,7 @@ function useSessionEvents(sessionId, options = {}) {
|
|
|
2258
1695
|
},
|
|
2259
1696
|
[client, workspaceId, sessionId, ownsNavigation, historyFilter, pruneStepStores]
|
|
2260
1697
|
);
|
|
2261
|
-
const jumpToLatestQuestion =
|
|
1698
|
+
const jumpToLatestQuestion = useCallback3(
|
|
2262
1699
|
async (questionOptions) => {
|
|
2263
1700
|
if (!sessionId || !ownsNavigation()) return null;
|
|
2264
1701
|
let generation = navigationGenerationRef.current;
|
|
@@ -2294,7 +1731,7 @@ function useSessionEvents(sessionId, options = {}) {
|
|
|
2294
1731
|
},
|
|
2295
1732
|
[client, workspaceId, sessionId, streamKey, ownsNavigation, jumpToSequence, t]
|
|
2296
1733
|
);
|
|
2297
|
-
const jumpToLatest =
|
|
1734
|
+
const jumpToLatest = useCallback3(async () => {
|
|
2298
1735
|
if (!ownsNavigation()) return;
|
|
2299
1736
|
if (loadingTargetRef.current) {
|
|
2300
1737
|
navigationGenerationRef.current += 1;
|
|
@@ -2362,7 +1799,7 @@ function useSessionEvents(sessionId, options = {}) {
|
|
|
2362
1799
|
const visibleStepStores = liveSteps ? stepStores : EMPTY_STEP_STORES;
|
|
2363
1800
|
const visiblePresentedOutputs = liveSteps ? presentedOutputs : EMPTY_PRESENTED_OUTPUTS;
|
|
2364
1801
|
const visibleTurnless = liveSteps ? turnlessSteps : EMPTY_TURNLESS_STEPS;
|
|
2365
|
-
const readToolOutput =
|
|
1802
|
+
const readToolOutput = useCallback3(
|
|
2366
1803
|
async (sequence) => sessionId ? (await readEventPage(client, workspaceId, sessionId, {
|
|
2367
1804
|
includeTypes: ["agent.toolCall.output"],
|
|
2368
1805
|
after: Math.max(0, sequence - 1),
|
|
@@ -2434,7 +1871,7 @@ function useSessionEvents(sessionId, options = {}) {
|
|
|
2434
1871
|
toolOutputs.reader,
|
|
2435
1872
|
t
|
|
2436
1873
|
]);
|
|
2437
|
-
|
|
1874
|
+
useEffect2(() => {
|
|
2438
1875
|
if (fullReplay || !sessionId || !identityMatches || !initialHistoryReady) return;
|
|
2439
1876
|
const resolved = new Set(presentedOutputs.keys());
|
|
2440
1877
|
const collect = (events) => {
|
|
@@ -3250,7 +2687,7 @@ async function readEventPage(client, workspaceId, sessionId, options) {
|
|
|
3250
2687
|
|
|
3251
2688
|
// src/hooks/use-turn-queue.ts
|
|
3252
2689
|
import { isTransientRequestError as isTransientRequestError2 } from "@opengeni/sdk";
|
|
3253
|
-
import { useCallback as
|
|
2690
|
+
import { useCallback as useCallback4, useEffect as useEffect3, useLayoutEffect, useMemo as useMemo3, useRef as useRef3, useState as useState3 } from "react";
|
|
3254
2691
|
function isTurnQueueEvent(event) {
|
|
3255
2692
|
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
2693
|
}
|
|
@@ -3266,30 +2703,30 @@ function useTurnQueue(sessionId, options = {}) {
|
|
|
3266
2703
|
const enabled = (options.enabled ?? true) && Boolean(sessionId);
|
|
3267
2704
|
const targetKey = `${workspaceId}\0${sessionId ?? ""}`;
|
|
3268
2705
|
const pageLive = usePageLiveActivity();
|
|
3269
|
-
const pageLiveRef =
|
|
2706
|
+
const pageLiveRef = useRef3(pageLive);
|
|
3270
2707
|
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 =
|
|
2708
|
+
const [snapshot, setSnapshot] = useState3(null);
|
|
2709
|
+
const [stateTargetKey, setStateTargetKey] = useState3(targetKey);
|
|
2710
|
+
const [loading, setLoading] = useState3(enabled);
|
|
2711
|
+
const [error, setError] = useState3(null);
|
|
2712
|
+
const [mutationError, setMutationError] = useState3(null);
|
|
2713
|
+
const [pendingByTurn, setPendingByTurn] = useState3({});
|
|
2714
|
+
const [acceptedSteers, setAcceptedSteers] = useState3([]);
|
|
2715
|
+
const pendingRef = useRef3({});
|
|
2716
|
+
const readGeneration = useRef3(0);
|
|
2717
|
+
const targetKeyRef = useRef3(targetKey);
|
|
2718
|
+
const snapshotRef = useRef3(null);
|
|
2719
|
+
const transientStreakRef = useRef3(
|
|
3283
2720
|
null
|
|
3284
2721
|
);
|
|
3285
|
-
const transientRetryTimerRef =
|
|
3286
|
-
const cancelTransientRetry =
|
|
2722
|
+
const transientRetryTimerRef = useRef3(null);
|
|
2723
|
+
const cancelTransientRetry = useCallback4(() => {
|
|
3287
2724
|
if (transientRetryTimerRef.current !== null) {
|
|
3288
2725
|
clearTimeout(transientRetryTimerRef.current);
|
|
3289
2726
|
transientRetryTimerRef.current = null;
|
|
3290
2727
|
}
|
|
3291
2728
|
}, []);
|
|
3292
|
-
|
|
2729
|
+
useLayoutEffect(() => {
|
|
3293
2730
|
if (targetKeyRef.current === targetKey) return;
|
|
3294
2731
|
targetKeyRef.current = targetKey;
|
|
3295
2732
|
readGeneration.current += 1;
|
|
@@ -3305,7 +2742,7 @@ function useTurnQueue(sessionId, options = {}) {
|
|
|
3305
2742
|
setPendingByTurn({});
|
|
3306
2743
|
setAcceptedSteers([]);
|
|
3307
2744
|
}, [cancelTransientRetry, enabled, targetKey]);
|
|
3308
|
-
|
|
2745
|
+
useEffect3(() => {
|
|
3309
2746
|
if (acceptedSteers.length === 0 || options.events === void 0) return;
|
|
3310
2747
|
const durablyConsumedTurnIds = new Set(
|
|
3311
2748
|
options.events.flatMap(
|
|
@@ -3323,7 +2760,7 @@ function useTurnQueue(sessionId, options = {}) {
|
|
|
3323
2760
|
(current) => current.filter((steer) => !durablyConsumedTurnIds.has(steer.turnId))
|
|
3324
2761
|
);
|
|
3325
2762
|
}, [acceptedSteers.length, options.events]);
|
|
3326
|
-
const acceptSnapshot =
|
|
2763
|
+
const acceptSnapshot = useCallback4(
|
|
3327
2764
|
(ownedTargetKey, next) => {
|
|
3328
2765
|
if (targetKeyRef.current !== ownedTargetKey) return false;
|
|
3329
2766
|
const current = snapshotRef.current;
|
|
@@ -3337,7 +2774,7 @@ function useTurnQueue(sessionId, options = {}) {
|
|
|
3337
2774
|
},
|
|
3338
2775
|
[]
|
|
3339
2776
|
);
|
|
3340
|
-
const load =
|
|
2777
|
+
const load = useCallback4(
|
|
3341
2778
|
async (rejectOnFailure = false, fresh = false) => {
|
|
3342
2779
|
if (!sessionId) return;
|
|
3343
2780
|
const ownedTargetKey = `${workspaceId}\0${sessionId}`;
|
|
@@ -3393,10 +2830,10 @@ function useTurnQueue(sessionId, options = {}) {
|
|
|
3393
2830
|
},
|
|
3394
2831
|
[client, workspaceId, sessionId, acceptSnapshot, cancelTransientRetry]
|
|
3395
2832
|
);
|
|
3396
|
-
const loadRef =
|
|
2833
|
+
const loadRef = useRef3(load);
|
|
3397
2834
|
loadRef.current = load;
|
|
3398
|
-
|
|
3399
|
-
|
|
2835
|
+
useEffect3(() => cancelTransientRetry, [cancelTransientRetry]);
|
|
2836
|
+
useEffect3(() => {
|
|
3400
2837
|
if (!enabled || !pageLive) {
|
|
3401
2838
|
cancelTransientRetry();
|
|
3402
2839
|
setLoading(false);
|
|
@@ -3426,11 +2863,11 @@ function useTurnQueue(sessionId, options = {}) {
|
|
|
3426
2863
|
readGeneration.current += 1;
|
|
3427
2864
|
};
|
|
3428
2865
|
}, [cancelTransientRetry, load, enabled, pageLive, options.pollIntervalMs]);
|
|
3429
|
-
const loadFresh =
|
|
3430
|
-
|
|
2866
|
+
const loadFresh = useCallback4(() => load(false, true), [load]);
|
|
2867
|
+
useEffect3(() => {
|
|
3431
2868
|
if (enabled && workspaceControlEvent) void loadFresh();
|
|
3432
2869
|
}, [enabled, loadFresh, workspaceControlEvent]);
|
|
3433
|
-
|
|
2870
|
+
useEffect3(() => {
|
|
3434
2871
|
if (!sessionId || !enabled) return;
|
|
3435
2872
|
return registerSessionReconciler(sessionId, "queue", loadFresh);
|
|
3436
2873
|
}, [enabled, loadFresh, registerSessionReconciler, sessionId]);
|
|
@@ -3459,7 +2896,7 @@ function useTurnQueue(sessionId, options = {}) {
|
|
|
3459
2896
|
freshSnapshot,
|
|
3460
2897
|
{ enabled, discard: stateTargetKey === targetKey && deniesRetainedView(error) }
|
|
3461
2898
|
);
|
|
3462
|
-
const mutate =
|
|
2899
|
+
const mutate = useCallback4(
|
|
3463
2900
|
async (turnId, kind, command, failure = {}) => {
|
|
3464
2901
|
const ownedTargetKey = targetKey;
|
|
3465
2902
|
if (!sessionId || targetKeyRef.current !== ownedTargetKey || pendingRef.current[turnId]) {
|
|
@@ -3511,7 +2948,7 @@ function useTurnQueue(sessionId, options = {}) {
|
|
|
3511
2948
|
},
|
|
3512
2949
|
[acceptSnapshot, loadFresh, sessionId, targetKey]
|
|
3513
2950
|
);
|
|
3514
|
-
const moveTurn =
|
|
2951
|
+
const moveTurn = useCallback4(
|
|
3515
2952
|
async (turnId, beforeTurnId) => {
|
|
3516
2953
|
const result = await mutate(
|
|
3517
2954
|
turnId,
|
|
@@ -3526,7 +2963,7 @@ function useTurnQueue(sessionId, options = {}) {
|
|
|
3526
2963
|
},
|
|
3527
2964
|
[client, mutate, sessionId, workspaceId]
|
|
3528
2965
|
);
|
|
3529
|
-
const editTurn =
|
|
2966
|
+
const editTurn = useCallback4(
|
|
3530
2967
|
async (turnId, edit) => {
|
|
3531
2968
|
const result = await mutate(
|
|
3532
2969
|
turnId,
|
|
@@ -3542,7 +2979,7 @@ function useTurnQueue(sessionId, options = {}) {
|
|
|
3542
2979
|
},
|
|
3543
2980
|
[client, mutate, sessionId, workspaceId]
|
|
3544
2981
|
);
|
|
3545
|
-
const recallTurn =
|
|
2982
|
+
const recallTurn = useCallback4(
|
|
3546
2983
|
async (turnId, recall) => {
|
|
3547
2984
|
const ownedTargetKey = targetKey;
|
|
3548
2985
|
const known = snapshotRef.current?.items.some((candidate) => candidate.id === turnId);
|
|
@@ -3565,7 +3002,7 @@ function useTurnQueue(sessionId, options = {}) {
|
|
|
3565
3002
|
},
|
|
3566
3003
|
[client, mutate, sessionId, targetKey, workspaceId]
|
|
3567
3004
|
);
|
|
3568
|
-
const steerTurn =
|
|
3005
|
+
const steerTurn = useCallback4(
|
|
3569
3006
|
async (turnId) => {
|
|
3570
3007
|
const ownedTargetKey = targetKey;
|
|
3571
3008
|
const turn = snapshotRef.current?.items.find((candidate) => candidate.id === turnId);
|
|
@@ -3617,7 +3054,7 @@ function useTurnQueue(sessionId, options = {}) {
|
|
|
3617
3054
|
},
|
|
3618
3055
|
[client, loadFresh, mutate, sessionId, targetKey, workspaceId, t]
|
|
3619
3056
|
);
|
|
3620
|
-
const removeTurn =
|
|
3057
|
+
const removeTurn = useCallback4(
|
|
3621
3058
|
async (turnId) => {
|
|
3622
3059
|
const result = await mutate(
|
|
3623
3060
|
turnId,
|
|
@@ -3639,7 +3076,7 @@ function useTurnQueue(sessionId, options = {}) {
|
|
|
3639
3076
|
() => Object.keys(visiblePendingByTurn).length > 0,
|
|
3640
3077
|
[visiblePendingByTurn]
|
|
3641
3078
|
);
|
|
3642
|
-
const mutationFor =
|
|
3079
|
+
const mutationFor = useCallback4(
|
|
3643
3080
|
(turnId) => visiblePendingByTurn[turnId] ?? null,
|
|
3644
3081
|
[visiblePendingByTurn]
|
|
3645
3082
|
);
|
|
@@ -3663,7 +3100,7 @@ function useTurnQueue(sessionId, options = {}) {
|
|
|
3663
3100
|
mutationFor,
|
|
3664
3101
|
mutating,
|
|
3665
3102
|
mutationError: identityMatches ? mutationError : null,
|
|
3666
|
-
clearMutationError:
|
|
3103
|
+
clearMutationError: useCallback4(() => {
|
|
3667
3104
|
if (targetKeyRef.current === targetKey) setMutationError(null);
|
|
3668
3105
|
}, [targetKey]),
|
|
3669
3106
|
acceptedSteers: identityMatches ? acceptedSteers : []
|
|
@@ -3679,787 +3116,1380 @@ function isOutcomeUnknownError(cause) {
|
|
|
3679
3116
|
return typeof cause === "object" && cause !== null && cause.outcomeUnknown === true;
|
|
3680
3117
|
}
|
|
3681
3118
|
|
|
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
|
-
};
|
|
3119
|
+
// src/hooks/use-goal.ts
|
|
3120
|
+
import {
|
|
3121
|
+
OpenGeniApiError,
|
|
3122
|
+
observedSessionSequence
|
|
3123
|
+
} from "@opengeni/sdk";
|
|
3124
|
+
import { useCallback as useCallback5, useEffect as useEffect4, useLayoutEffect as useLayoutEffect2, useRef as useRef4, useState as useState4 } from "react";
|
|
3125
|
+
function isGoalEvent(event) {
|
|
3126
|
+
return event.type.startsWith("goal.");
|
|
3810
3127
|
}
|
|
3811
|
-
function
|
|
3812
|
-
const
|
|
3128
|
+
function isGoalRefreshEvent(event) {
|
|
3129
|
+
const type = event.type;
|
|
3130
|
+
return isGoalEvent(event) || type.startsWith("turn.") || type.startsWith("session.") || type.startsWith("system.update.") || type.startsWith("workspace.inference.") || type.startsWith("user.");
|
|
3131
|
+
}
|
|
3132
|
+
function useGoal(sessionId, options = {}) {
|
|
3133
|
+
const { client, workspaceId } = useEmbeddedGoal(options);
|
|
3134
|
+
const enabled = (options.enabled ?? true) && Boolean(sessionId);
|
|
3135
|
+
const sharedEvents = options.events;
|
|
3136
|
+
const sharedFeed = sharedEvents !== void 0;
|
|
3137
|
+
const pageLive = usePageLiveActivity();
|
|
3138
|
+
const [goal, setGoal] = useState4(null);
|
|
3139
|
+
const [loading, setLoading] = useState4(enabled);
|
|
3140
|
+
const [error, setError] = useState4(null);
|
|
3141
|
+
const [readAbsent, setReadAbsent] = useState4(false);
|
|
3142
|
+
const { run, mutating, mutationError, clearMutationError } = useMutationRunner();
|
|
3143
|
+
const generation = useRef4(0);
|
|
3144
|
+
const targetKeyRef = useRef4(null);
|
|
3145
|
+
const goalAbsentRef = useRef4(false);
|
|
3146
|
+
const pendingRefreshRef = useRef4("none");
|
|
3147
|
+
const sharedEventsRef = useRef4(sharedEvents);
|
|
3148
|
+
useLayoutEffect2(() => {
|
|
3149
|
+
sharedEventsRef.current = sharedEvents;
|
|
3150
|
+
}, [sharedEvents]);
|
|
3151
|
+
const loadAbort = useRef4(null);
|
|
3152
|
+
const scheduleRefreshRef = useRef4(() => void 0);
|
|
3153
|
+
const retireLoads = useCallback5(() => {
|
|
3154
|
+
generation.current += 1;
|
|
3155
|
+
loadAbort.current?.abort();
|
|
3156
|
+
loadAbort.current = null;
|
|
3157
|
+
}, []);
|
|
3158
|
+
const load = useCallback5(async () => {
|
|
3159
|
+
if (!sessionId) {
|
|
3160
|
+
return;
|
|
3161
|
+
}
|
|
3162
|
+
const ticket = ++generation.current;
|
|
3163
|
+
pendingRefreshRef.current = "none";
|
|
3164
|
+
loadAbort.current?.abort();
|
|
3165
|
+
const controller = new AbortController();
|
|
3166
|
+
loadAbort.current = controller;
|
|
3167
|
+
let fetchedGoal = null;
|
|
3168
|
+
try {
|
|
3169
|
+
const fetched = typeof client.findGoal === "function" ? await client.findGoal(workspaceId, sessionId, { signal: controller.signal }) : await client.getGoal(workspaceId, sessionId, { signal: controller.signal });
|
|
3170
|
+
fetchedGoal = fetched;
|
|
3171
|
+
if (ticket === generation.current) {
|
|
3172
|
+
goalAbsentRef.current = fetched === null;
|
|
3173
|
+
setReadAbsent(fetched === null);
|
|
3174
|
+
setGoal(fetched);
|
|
3175
|
+
setError(null);
|
|
3176
|
+
setLoading(false);
|
|
3177
|
+
}
|
|
3178
|
+
} catch (cause) {
|
|
3179
|
+
if (ticket !== generation.current) {
|
|
3180
|
+
return;
|
|
3181
|
+
}
|
|
3182
|
+
if (cause instanceof OpenGeniApiError && cause.status === 404) {
|
|
3183
|
+
goalAbsentRef.current = true;
|
|
3184
|
+
setReadAbsent(true);
|
|
3185
|
+
setGoal(null);
|
|
3186
|
+
setError(null);
|
|
3187
|
+
} else {
|
|
3188
|
+
setError(normalizeError(cause));
|
|
3189
|
+
}
|
|
3190
|
+
setLoading(false);
|
|
3191
|
+
} finally {
|
|
3192
|
+
if (loadAbort.current === controller) loadAbort.current = null;
|
|
3193
|
+
}
|
|
3194
|
+
if (ticket !== generation.current || pendingRefreshRef.current === "none") {
|
|
3195
|
+
return;
|
|
3196
|
+
}
|
|
3197
|
+
const readThrough = fetchedGoal ? observedSessionSequence(fetchedGoal) : void 0;
|
|
3198
|
+
if (readThrough !== void 0 && sharedEventsRef.current !== void 0) {
|
|
3199
|
+
const events = sharedEventsRef.current;
|
|
3200
|
+
const newest = events[events.length - 1];
|
|
3201
|
+
if (!newest || newest.sequence <= readThrough) {
|
|
3202
|
+
pendingRefreshRef.current = "none";
|
|
3203
|
+
return;
|
|
3204
|
+
}
|
|
3205
|
+
}
|
|
3206
|
+
if (goalAbsentRef.current && pendingRefreshRef.current === "refresh") {
|
|
3207
|
+
const events = sharedEventsRef.current ?? [];
|
|
3208
|
+
let latestGoalEvent;
|
|
3209
|
+
for (let index = events.length - 1; index >= 0 && !latestGoalEvent; index -= 1) {
|
|
3210
|
+
const event = events[index];
|
|
3211
|
+
if (event && isGoalEvent(event)) latestGoalEvent = event;
|
|
3212
|
+
}
|
|
3213
|
+
if (!latestGoalEvent || latestGoalEvent.type === "goal.cleared") {
|
|
3214
|
+
pendingRefreshRef.current = "none";
|
|
3215
|
+
return;
|
|
3216
|
+
}
|
|
3217
|
+
pendingRefreshRef.current = "goal";
|
|
3218
|
+
}
|
|
3219
|
+
scheduleRefreshRef.current();
|
|
3220
|
+
}, [client, workspaceId, sessionId]);
|
|
3221
|
+
useEffect4(() => {
|
|
3222
|
+
const targetKey = `${workspaceId} ${sessionId ?? ""}`;
|
|
3223
|
+
if (targetKeyRef.current !== targetKey) {
|
|
3224
|
+
targetKeyRef.current = targetKey;
|
|
3225
|
+
goalAbsentRef.current = false;
|
|
3226
|
+
pendingRefreshRef.current = "none";
|
|
3227
|
+
setReadAbsent(false);
|
|
3228
|
+
setGoal(null);
|
|
3229
|
+
setError(null);
|
|
3230
|
+
}
|
|
3231
|
+
if (!enabled || !pageLive) {
|
|
3232
|
+
retireLoads();
|
|
3233
|
+
setLoading(false);
|
|
3234
|
+
return;
|
|
3235
|
+
}
|
|
3236
|
+
if (sharedFeed) {
|
|
3237
|
+
setLoading(true);
|
|
3238
|
+
void load();
|
|
3239
|
+
return () => {
|
|
3240
|
+
retireLoads();
|
|
3241
|
+
};
|
|
3242
|
+
}
|
|
3243
|
+
setLoading(true);
|
|
3244
|
+
const pollIntervalMs = options.pollIntervalMs;
|
|
3245
|
+
if (pollIntervalMs === void 0 || pollIntervalMs <= 0) {
|
|
3246
|
+
void load();
|
|
3247
|
+
return () => {
|
|
3248
|
+
retireLoads();
|
|
3249
|
+
};
|
|
3250
|
+
}
|
|
3251
|
+
let cancelled = false;
|
|
3252
|
+
let timer = null;
|
|
3253
|
+
const schedule = () => {
|
|
3254
|
+
if (cancelled) return;
|
|
3255
|
+
timer = setTimeout(() => {
|
|
3256
|
+
timer = null;
|
|
3257
|
+
void load().finally(schedule);
|
|
3258
|
+
}, pollIntervalMs);
|
|
3259
|
+
};
|
|
3260
|
+
void load().finally(schedule);
|
|
3261
|
+
return () => {
|
|
3262
|
+
cancelled = true;
|
|
3263
|
+
if (timer !== null) clearTimeout(timer);
|
|
3264
|
+
retireLoads();
|
|
3265
|
+
};
|
|
3266
|
+
}, [
|
|
3267
|
+
load,
|
|
3268
|
+
enabled,
|
|
3269
|
+
pageLive,
|
|
3270
|
+
workspaceId,
|
|
3813
3271
|
sessionId,
|
|
3814
|
-
|
|
3272
|
+
options.pollIntervalMs,
|
|
3273
|
+
retireLoads,
|
|
3274
|
+
sharedFeed
|
|
3275
|
+
]);
|
|
3276
|
+
const scheduleRefresh = useDebouncedCallback(() => {
|
|
3277
|
+
const pending = pendingRefreshRef.current;
|
|
3278
|
+
if (pending === "none" || loadAbort.current !== null) return;
|
|
3279
|
+
if (pending === "refresh" && goalAbsentRef.current) {
|
|
3280
|
+
pendingRefreshRef.current = "none";
|
|
3281
|
+
return;
|
|
3282
|
+
}
|
|
3283
|
+
void load();
|
|
3815
3284
|
});
|
|
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
|
-
|
|
3285
|
+
useLayoutEffect2(() => {
|
|
3286
|
+
scheduleRefreshRef.current = scheduleRefresh;
|
|
3287
|
+
}, [scheduleRefresh]);
|
|
3288
|
+
const isRefreshEvent = useCallback5(
|
|
3289
|
+
(event) => goalAbsentRef.current ? isGoalEvent(event) : isGoalRefreshEvent(event),
|
|
3290
|
+
[]
|
|
3291
|
+
);
|
|
3292
|
+
const refreshGoal = useCallback5(() => {
|
|
3293
|
+
pendingRefreshRef.current = "goal";
|
|
3294
|
+
scheduleRefresh();
|
|
3295
|
+
}, [scheduleRefresh]);
|
|
3296
|
+
const onRefreshEvent = useCallback5(
|
|
3297
|
+
(event) => {
|
|
3298
|
+
if (isGoalEvent(event)) pendingRefreshRef.current = "goal";
|
|
3299
|
+
else if (pendingRefreshRef.current === "none") pendingRefreshRef.current = "refresh";
|
|
3300
|
+
scheduleRefresh();
|
|
3301
|
+
},
|
|
3302
|
+
[scheduleRefresh]
|
|
3303
|
+
);
|
|
3304
|
+
useSessionEventTrigger(client, workspaceId, sessionId, isRefreshEvent, onRefreshEvent, {
|
|
3305
|
+
enabled,
|
|
3306
|
+
...sharedEvents !== void 0 ? { events: sharedEvents } : {},
|
|
3307
|
+
// The load settles events that arrive during its read itself (above).
|
|
3308
|
+
readThrough: projectionReadThrough(goal, false),
|
|
3309
|
+
refresh: refreshGoal
|
|
3310
|
+
});
|
|
3311
|
+
const retainedGoal = useRetainedSessionView(
|
|
3312
|
+
client,
|
|
3313
|
+
workspaceId,
|
|
3314
|
+
sessionId,
|
|
3315
|
+
"goal",
|
|
3316
|
+
loading ? null : goal,
|
|
3317
|
+
{ enabled, discard: readAbsent || deniesRetainedView(error) }
|
|
3318
|
+
);
|
|
3319
|
+
const visibleGoal = loading ? goal ?? retainedGoal : goal;
|
|
3320
|
+
const goalRef = useRef4(goal);
|
|
3321
|
+
const shownRetainedRef = useRef4(null);
|
|
3322
|
+
const readWaitersRef = useRef4([]);
|
|
3323
|
+
useLayoutEffect2(() => {
|
|
3324
|
+
goalRef.current = goal;
|
|
3325
|
+
shownRetainedRef.current = loading && goal === null ? retainedGoal : null;
|
|
3326
|
+
});
|
|
3327
|
+
useEffect4(() => {
|
|
3328
|
+
if (loading) return;
|
|
3329
|
+
const waiters = readWaitersRef.current;
|
|
3330
|
+
readWaitersRef.current = [];
|
|
3331
|
+
for (const resolve of waiters) resolve();
|
|
3332
|
+
}, [loading]);
|
|
3333
|
+
useEffect4(
|
|
3842
3334
|
() => () => {
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3335
|
+
goalRef.current = null;
|
|
3336
|
+
const waiters = readWaitersRef.current;
|
|
3337
|
+
readWaitersRef.current = [];
|
|
3338
|
+
for (const resolve of waiters) resolve();
|
|
3846
3339
|
},
|
|
3847
|
-
[]
|
|
3340
|
+
[workspaceId, sessionId]
|
|
3848
3341
|
);
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
if (!
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3342
|
+
const aimedAtCurrentGoal = useCallback5(async () => {
|
|
3343
|
+
const shown = shownRetainedRef.current;
|
|
3344
|
+
if (!shown) return true;
|
|
3345
|
+
await new Promise((resolve) => readWaitersRef.current.push(resolve));
|
|
3346
|
+
const fresh = goalRef.current;
|
|
3347
|
+
return fresh !== null && fresh.id === shown.id && fresh.objectiveRevision === shown.objectiveRevision;
|
|
3348
|
+
}, []);
|
|
3349
|
+
const pause = useCallback5(
|
|
3350
|
+
async (rationale) => {
|
|
3351
|
+
if (!sessionId || !await aimedAtCurrentGoal()) {
|
|
3352
|
+
return null;
|
|
3353
|
+
}
|
|
3354
|
+
const result = await run(
|
|
3355
|
+
() => client.updateGoal(workspaceId, sessionId, {
|
|
3356
|
+
status: "paused",
|
|
3357
|
+
...rationale !== void 0 ? { rationale } : {}
|
|
3864
3358
|
})
|
|
3865
|
-
)
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3359
|
+
);
|
|
3360
|
+
if (result) {
|
|
3361
|
+
setGoal(result);
|
|
3362
|
+
}
|
|
3363
|
+
return result;
|
|
3364
|
+
},
|
|
3365
|
+
[client, workspaceId, sessionId, run, aimedAtCurrentGoal]
|
|
3366
|
+
);
|
|
3367
|
+
const resume = useCallback5(async () => {
|
|
3368
|
+
if (!sessionId || !await aimedAtCurrentGoal()) {
|
|
3369
|
+
return null;
|
|
3370
|
+
}
|
|
3371
|
+
const result = await run(() => client.updateGoal(workspaceId, sessionId, { status: "active" }));
|
|
3372
|
+
if (result) {
|
|
3373
|
+
setGoal(result);
|
|
3374
|
+
}
|
|
3375
|
+
return result;
|
|
3376
|
+
}, [client, workspaceId, sessionId, run, aimedAtCurrentGoal]);
|
|
3377
|
+
const clearGoal = useCallback5(async () => {
|
|
3378
|
+
if (!sessionId || !await aimedAtCurrentGoal()) {
|
|
3379
|
+
return;
|
|
3380
|
+
}
|
|
3381
|
+
const ok = await run(async () => {
|
|
3382
|
+
await client.deleteGoal(workspaceId, sessionId);
|
|
3383
|
+
return true;
|
|
3384
|
+
});
|
|
3385
|
+
if (ok) {
|
|
3386
|
+
retireLoads();
|
|
3387
|
+
setReadAbsent(true);
|
|
3388
|
+
setGoal(null);
|
|
3389
|
+
setError(null);
|
|
3390
|
+
}
|
|
3391
|
+
}, [client, workspaceId, sessionId, run, retireLoads, aimedAtCurrentGoal]);
|
|
3392
|
+
return {
|
|
3393
|
+
goal: visibleGoal,
|
|
3394
|
+
isActive: visibleGoal?.status === "active",
|
|
3395
|
+
isPaused: visibleGoal?.status === "paused",
|
|
3396
|
+
isCompleted: visibleGoal?.status === "completed",
|
|
3397
|
+
loading: loading && retainedGoal === null,
|
|
3398
|
+
error,
|
|
3399
|
+
refresh: load,
|
|
3400
|
+
pause,
|
|
3401
|
+
resume,
|
|
3402
|
+
clearGoal,
|
|
3403
|
+
deleteGoal: clearGoal,
|
|
3404
|
+
updating: mutating,
|
|
3405
|
+
mutationError,
|
|
3406
|
+
clearMutationError
|
|
3407
|
+
};
|
|
3408
|
+
}
|
|
3409
|
+
|
|
3410
|
+
// src/hooks/use-session-control.ts
|
|
3411
|
+
import { useCallback as useCallback6, useLayoutEffect as useLayoutEffect3, useRef as useRef5 } from "react";
|
|
3412
|
+
function useSessionControl(sessionId, options = {}) {
|
|
3413
|
+
const { client, workspaceId } = useEmbeddedSession(options);
|
|
3414
|
+
const approvalTargetKey = `${workspaceId}\0${sessionId ?? ""}`;
|
|
3415
|
+
const pendingApproval = useRef5(null);
|
|
3416
|
+
useLayoutEffect3(() => {
|
|
3417
|
+
if (pendingApproval.current?.targetKey !== approvalTargetKey) {
|
|
3418
|
+
pendingApproval.current = null;
|
|
3419
|
+
}
|
|
3420
|
+
}, [approvalTargetKey]);
|
|
3421
|
+
const {
|
|
3422
|
+
run: runControl,
|
|
3423
|
+
mutating: controlling,
|
|
3424
|
+
mutationError: controlError,
|
|
3425
|
+
clearMutationError: clearControlError
|
|
3426
|
+
} = useMutationRunner(approvalTargetKey);
|
|
3427
|
+
const {
|
|
3428
|
+
run: runApproval,
|
|
3429
|
+
mutating: responding,
|
|
3430
|
+
mutationError: approvalError,
|
|
3431
|
+
clearMutationError: clearApprovalError
|
|
3432
|
+
} = useMutationRunner(approvalTargetKey);
|
|
3433
|
+
const pause = useCallback6(
|
|
3434
|
+
async (reason) => {
|
|
3435
|
+
if (!sessionId) {
|
|
3436
|
+
return null;
|
|
3437
|
+
}
|
|
3438
|
+
return await runControl(
|
|
3439
|
+
() => client.pauseSession(workspaceId, sessionId, reason !== void 0 ? { reason } : {})
|
|
3440
|
+
);
|
|
3441
|
+
},
|
|
3442
|
+
[client, workspaceId, sessionId, runControl]
|
|
3443
|
+
);
|
|
3444
|
+
const resume = useCallback6(
|
|
3445
|
+
async (reason) => {
|
|
3446
|
+
if (!sessionId) return null;
|
|
3447
|
+
return await runControl(
|
|
3448
|
+
() => client.resumeSession(workspaceId, sessionId, reason !== void 0 ? { reason } : {})
|
|
3449
|
+
);
|
|
3450
|
+
},
|
|
3451
|
+
[client, workspaceId, sessionId, runControl]
|
|
3452
|
+
);
|
|
3453
|
+
const decide = useCallback6(
|
|
3454
|
+
async (approvalId, decision, message, answer, decisionOptions = {}) => {
|
|
3455
|
+
if (!sessionId) {
|
|
3456
|
+
return null;
|
|
3457
|
+
}
|
|
3458
|
+
const decisionKey = JSON.stringify([approvalId, decision, message ?? null, answer ?? null]);
|
|
3459
|
+
if (pendingApproval.current?.decisionKey !== decisionKey) {
|
|
3460
|
+
pendingApproval.current = {
|
|
3461
|
+
targetKey: approvalTargetKey,
|
|
3462
|
+
decisionKey,
|
|
3463
|
+
clientEventId: crypto.randomUUID()
|
|
3464
|
+
};
|
|
3465
|
+
}
|
|
3466
|
+
const clientEventId = pendingApproval.current.clientEventId;
|
|
3467
|
+
let refusal = null;
|
|
3468
|
+
const accepted = await runApproval(async () => {
|
|
3469
|
+
try {
|
|
3470
|
+
return await client.sendApprovalDecision(workspaceId, sessionId, {
|
|
3471
|
+
approvalId,
|
|
3472
|
+
decision,
|
|
3473
|
+
...message !== void 0 ? { message } : {},
|
|
3474
|
+
...answer !== void 0 ? answer : {},
|
|
3475
|
+
clientEventId
|
|
3476
|
+
});
|
|
3477
|
+
} catch (cause) {
|
|
3478
|
+
refusal = { cause };
|
|
3479
|
+
throw cause;
|
|
3877
3480
|
}
|
|
3878
|
-
receipt.current = null;
|
|
3879
3481
|
});
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3482
|
+
if (decisionOptions.throwOnError && refusal) throw refusal.cause;
|
|
3483
|
+
if (accepted !== null && pendingApproval.current?.targetKey === approvalTargetKey && pendingApproval.current.clientEventId === clientEventId) {
|
|
3484
|
+
pendingApproval.current = null;
|
|
3485
|
+
}
|
|
3486
|
+
return accepted;
|
|
3487
|
+
},
|
|
3488
|
+
[approvalTargetKey, client, workspaceId, sessionId, runApproval]
|
|
3489
|
+
);
|
|
3490
|
+
const approve = useCallback6(
|
|
3491
|
+
async (approvalId, message, answer, decisionOptions) => await decide(approvalId, "approve", message, answer, decisionOptions),
|
|
3492
|
+
[decide]
|
|
3493
|
+
);
|
|
3494
|
+
const reject = useCallback6(
|
|
3495
|
+
async (approvalId, message, decisionOptions) => await decide(approvalId, "reject", message, void 0, decisionOptions),
|
|
3496
|
+
[decide]
|
|
3497
|
+
);
|
|
3498
|
+
const error = approvalError ?? controlError;
|
|
3499
|
+
const clearError = useCallback6(() => {
|
|
3500
|
+
clearControlError();
|
|
3501
|
+
clearApprovalError();
|
|
3502
|
+
}, [clearControlError, clearApprovalError]);
|
|
3503
|
+
return {
|
|
3504
|
+
pause,
|
|
3505
|
+
resume,
|
|
3506
|
+
controlling,
|
|
3507
|
+
approve,
|
|
3508
|
+
reject,
|
|
3509
|
+
responding,
|
|
3510
|
+
error,
|
|
3511
|
+
clearError
|
|
3512
|
+
};
|
|
3883
3513
|
}
|
|
3884
3514
|
|
|
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]
|
|
3515
|
+
// src/hooks/use-available-models.ts
|
|
3516
|
+
import { useCallback as useCallback7 } from "react";
|
|
3517
|
+
function useAvailableModels(options = {}) {
|
|
3518
|
+
const client = useOpenGeniClient(options);
|
|
3519
|
+
const load = useCallback7(
|
|
3520
|
+
async (signal) => await client.getClientConfig({ signal }),
|
|
3521
|
+
[client]
|
|
3928
3522
|
);
|
|
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);
|
|
3523
|
+
const state = useSharedQuery(client, ["available-models"], load, {
|
|
3524
|
+
pollIntervalMs: options.pollIntervalMs,
|
|
3525
|
+
enabled: options.enabled
|
|
3526
|
+
});
|
|
3527
|
+
return {
|
|
3528
|
+
models: state.data?.models ?? [],
|
|
3529
|
+
defaultModel: state.data?.defaultModel ?? null,
|
|
3530
|
+
loading: state.loading,
|
|
3531
|
+
error: state.error,
|
|
3532
|
+
refresh: state.refresh
|
|
3961
3533
|
};
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3534
|
+
}
|
|
3535
|
+
function useWorkspaceModelCatalog(options) {
|
|
3536
|
+
const t = useOpenGeniText();
|
|
3537
|
+
const client = useOpenGeniClient(options);
|
|
3538
|
+
const load = useCallback7(
|
|
3539
|
+
async (signal) => {
|
|
3540
|
+
if (!options.workspaceId) {
|
|
3541
|
+
return { models: [], defaultModel: null };
|
|
3542
|
+
}
|
|
3543
|
+
const [catalog, config] = await Promise.all([
|
|
3544
|
+
client.getWorkspaceModelCatalog(options.workspaceId, { signal }),
|
|
3545
|
+
// Joins the same workspace's config read already in flight (for
|
|
3546
|
+
// example the composer's voice availability).
|
|
3547
|
+
joinClientConfigRead(client, options.workspaceId)
|
|
3548
|
+
]);
|
|
3549
|
+
return {
|
|
3550
|
+
models: catalog.models,
|
|
3551
|
+
defaultModel: config.defaultModel
|
|
3552
|
+
};
|
|
3553
|
+
},
|
|
3554
|
+
[client, options.workspaceId]
|
|
3555
|
+
);
|
|
3556
|
+
const state = useSharedQuery(client, ["workspace-model-catalog", options.workspaceId], load, {
|
|
3557
|
+
pollIntervalMs: options.pollIntervalMs,
|
|
3558
|
+
enabled: options.enabled !== false && Boolean(options.workspaceId)
|
|
3559
|
+
});
|
|
3560
|
+
const rows = sortPickerRows(projectPickerRows(t, state.data?.models ?? []));
|
|
3561
|
+
return {
|
|
3562
|
+
models: state.data?.models ?? [],
|
|
3563
|
+
rows,
|
|
3564
|
+
defaultModel: state.data?.defaultModel ?? null,
|
|
3565
|
+
loading: state.loading,
|
|
3566
|
+
error: state.error,
|
|
3567
|
+
refresh: state.refresh
|
|
3986
3568
|
};
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3569
|
+
}
|
|
3570
|
+
|
|
3571
|
+
// src/hooks/use-human-input.ts
|
|
3572
|
+
import { useCallback as useCallback8, useEffect as useEffect5, useRef as useRef6, useState as useState5 } from "react";
|
|
3573
|
+
function isHumanInputEvent(event) {
|
|
3574
|
+
return event.type === "session.humanInput.requested" || event.type === "user.humanInputResponse" || event.type === "turn.completed" || event.type === "turn.failed" || event.type === "turn.cancelled";
|
|
3575
|
+
}
|
|
3576
|
+
function useHumanInputRequests(sessionId, options = {}) {
|
|
3577
|
+
const { client, workspaceId, registerSessionReconciler } = useEmbeddedHumanInputSession(options);
|
|
3578
|
+
const enabled = (options.enabled ?? true) && Boolean(sessionId);
|
|
3579
|
+
const load = useCallback8(async () => {
|
|
3580
|
+
if (!sessionId) return [];
|
|
3581
|
+
const readStartedAt = Date.now();
|
|
3582
|
+
const requests = await client.listHumanInputRequests(workspaceId, sessionId, {
|
|
3583
|
+
status: "pending"
|
|
3995
3584
|
});
|
|
3996
|
-
|
|
3585
|
+
const now2 = Date.now();
|
|
3586
|
+
pruneHumanInputDrafts(
|
|
3587
|
+
workspaceId,
|
|
3588
|
+
sessionId,
|
|
3589
|
+
requests.filter((request) => isActionableHumanInputRequest(request, now2)).map((request) => request.id),
|
|
3590
|
+
readStartedAt
|
|
3591
|
+
);
|
|
3592
|
+
return requests;
|
|
3593
|
+
}, [client, sessionId, workspaceId]);
|
|
3594
|
+
const state = usePolledValue(load, {
|
|
3595
|
+
enabled,
|
|
3596
|
+
pollIntervalMs: options.pollIntervalMs
|
|
3997
3597
|
});
|
|
3998
|
-
const
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
3598
|
+
const loadedRequests = state.data;
|
|
3599
|
+
const refreshRequests = state.refresh;
|
|
3600
|
+
const readDenied = enabled && Boolean(sessionId) && deniesRetainedView(state.error);
|
|
3601
|
+
useEffect5(() => {
|
|
3602
|
+
if (readDenied && sessionId) forgetSessionHumanInputDrafts(workspaceId, sessionId);
|
|
3603
|
+
}, [readDenied, sessionId, workspaceId]);
|
|
3604
|
+
const mutation = useMutationRunner(`${workspaceId}\0${sessionId ?? ""}`);
|
|
3605
|
+
const [respondingRequestId, setRespondingRequestId] = useState5(null);
|
|
3606
|
+
const [deadlineVersion, setDeadlineVersion] = useState5(0);
|
|
3607
|
+
const respondingRequestRef = useRef6(null);
|
|
3608
|
+
useEffect5(() => {
|
|
3609
|
+
respondingRequestRef.current = null;
|
|
3610
|
+
setRespondingRequestId(null);
|
|
3611
|
+
}, [sessionId, workspaceId]);
|
|
3612
|
+
useEffect5(() => {
|
|
3613
|
+
if (!sessionId || !enabled) return;
|
|
3614
|
+
return registerSessionReconciler(sessionId, "human-input", state.refresh);
|
|
3615
|
+
}, [enabled, registerSessionReconciler, sessionId, state.refresh]);
|
|
3616
|
+
const scheduleRefresh = useDebouncedCallback(() => void state.refresh());
|
|
3617
|
+
useSessionEventTrigger(client, workspaceId, sessionId, isHumanInputEvent, scheduleRefresh, {
|
|
3618
|
+
enabled,
|
|
3619
|
+
...options.events !== void 0 ? { events: options.events } : {},
|
|
3620
|
+
readThrough: projectionReadThrough(state.data, state.loading),
|
|
3621
|
+
refresh: scheduleRefresh
|
|
3622
|
+
});
|
|
3623
|
+
const retainedRequests = useRetainedSessionView(
|
|
3624
|
+
client,
|
|
3625
|
+
workspaceId,
|
|
3626
|
+
sessionId,
|
|
3627
|
+
"human-input",
|
|
3628
|
+
state.data,
|
|
3629
|
+
{ enabled, discard: deniesRetainedView(state.error) }
|
|
3630
|
+
);
|
|
3631
|
+
useEffect5(() => {
|
|
3632
|
+
const now2 = Date.now();
|
|
3633
|
+
const nextDeadline = (loadedRequests ?? []).reduce((next, request) => {
|
|
3634
|
+
if (request.status !== "pending" || !request.expiresAt) return next;
|
|
3635
|
+
const deadline = Date.parse(request.expiresAt);
|
|
3636
|
+
if (!Number.isFinite(deadline) || deadline <= now2) return next;
|
|
3637
|
+
return next === null ? deadline : Math.min(next, deadline);
|
|
3638
|
+
}, null);
|
|
3639
|
+
if (nextDeadline === null) return;
|
|
3640
|
+
const timer = globalThis.setTimeout(
|
|
3641
|
+
() => {
|
|
3642
|
+
setDeadlineVersion((current) => current + 1);
|
|
3643
|
+
void refreshRequests();
|
|
3644
|
+
},
|
|
3645
|
+
Math.min(2147483647, Math.max(0, nextDeadline - now2 + 1))
|
|
4004
3646
|
);
|
|
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);
|
|
3647
|
+
return () => globalThis.clearTimeout(timer);
|
|
3648
|
+
}, [loadedRequests, refreshRequests]);
|
|
3649
|
+
const respond = useCallback8(
|
|
3650
|
+
async (requestId, response) => {
|
|
3651
|
+
if (!sessionId || respondingRequestRef.current !== null) return null;
|
|
3652
|
+
respondingRequestRef.current = requestId;
|
|
3653
|
+
setRespondingRequestId(requestId);
|
|
3654
|
+
try {
|
|
3655
|
+
const event = await mutation.run(
|
|
3656
|
+
() => client.submitHumanInputResponse(workspaceId, sessionId, requestId, response, {
|
|
3657
|
+
clientEventId: globalThis.crypto.randomUUID()
|
|
3658
|
+
})
|
|
3659
|
+
);
|
|
3660
|
+
if (event) await state.refresh();
|
|
3661
|
+
return event;
|
|
3662
|
+
} finally {
|
|
3663
|
+
if (respondingRequestRef.current === requestId) {
|
|
3664
|
+
respondingRequestRef.current = null;
|
|
3665
|
+
setRespondingRequestId(null);
|
|
3666
|
+
}
|
|
4066
3667
|
}
|
|
4067
|
-
}
|
|
3668
|
+
},
|
|
3669
|
+
[client, mutation, sessionId, state, workspaceId]
|
|
3670
|
+
);
|
|
3671
|
+
const now = Date.now();
|
|
3672
|
+
void deadlineVersion;
|
|
3673
|
+
return {
|
|
3674
|
+
requests: [...state.data ?? retainedRequests ?? []].filter((request) => isActionableHumanInputRequest(request, now)).sort(
|
|
3675
|
+
(left, right) => left.createdAt.localeCompare(right.createdAt) || left.id.localeCompare(right.id)
|
|
3676
|
+
),
|
|
3677
|
+
loading: state.loading && retainedRequests === null,
|
|
3678
|
+
error: state.error,
|
|
3679
|
+
refresh: state.refresh,
|
|
3680
|
+
respond,
|
|
3681
|
+
respondingRequestId,
|
|
3682
|
+
mutationError: mutation.mutationError,
|
|
3683
|
+
clearMutationError: mutation.clearMutationError
|
|
4068
3684
|
};
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
3685
|
+
}
|
|
3686
|
+
|
|
3687
|
+
// src/conversation-timeline.ts
|
|
3688
|
+
function conversationTimeline(items, queue, composer) {
|
|
3689
|
+
const queued = new Set(
|
|
3690
|
+
queue.queue.filter((turn) => turn.metadata.delivery !== "steer").map((turn) => turn.triggerEventId)
|
|
3691
|
+
);
|
|
3692
|
+
const pending = composer.optimisticMessages ?? [];
|
|
3693
|
+
const pendingQueue = new Set(
|
|
3694
|
+
pending.filter(
|
|
3695
|
+
(message) => message.destination === "queue" && !(message.turnId && message.appliedQueueVersion != null && queue.snapshot && queue.snapshot.version >= message.appliedQueueVersion && !queue.queue.some((turn) => turn.id === message.turnId))
|
|
3696
|
+
).map((message) => `user-message:${message.clientEventId}`)
|
|
3697
|
+
);
|
|
3698
|
+
const visible = items.filter(
|
|
3699
|
+
(item) => item.kind !== "user-message" || !queued.has(item.id) && !pendingQueue.has(item.reconciliationKey ?? "")
|
|
3700
|
+
);
|
|
3701
|
+
const keys = new Set(
|
|
3702
|
+
visible.flatMap((item) => item.kind === "user-message" ? [item.reconciliationKey] : [])
|
|
3703
|
+
);
|
|
3704
|
+
const optimistic = pending.filter(
|
|
3705
|
+
(message) => (message.destination === "chat" || message.state === "failed") && !keys.has(`user-message:${message.clientEventId}`) && !queue.queue.some((turn) => turn.id === message.turnId)
|
|
3706
|
+
).map((message) => ({
|
|
3707
|
+
kind: "user-message",
|
|
3708
|
+
id: `optimistic:${message.clientEventId}`,
|
|
3709
|
+
reconciliationKey: `user-message:${message.clientEventId}`,
|
|
3710
|
+
text: message.text,
|
|
3711
|
+
annotations: message.annotations.map((annotation, ordinal) => ({ ...annotation, ordinal })),
|
|
3712
|
+
resources: message.resources,
|
|
3713
|
+
tools: [],
|
|
3714
|
+
occurredAt: message.occurredAt,
|
|
3715
|
+
delivery: {
|
|
3716
|
+
state: message.state,
|
|
3717
|
+
...message.error ? { error: message.error } : {},
|
|
3718
|
+
...message.state === "failed" ? {
|
|
3719
|
+
...message.retryable !== false && composer.retryOptimisticMessage ? { onRetry: () => composer.retryOptimisticMessage?.(message.clientEventId) } : {},
|
|
3720
|
+
...message.retryable === false && composer.restoreOptimisticMessage ? { onEdit: () => composer.restoreOptimisticMessage?.(message.clientEventId) } : {},
|
|
3721
|
+
onRemove: () => composer.removeOptimisticMessage?.(message.clientEventId)
|
|
3722
|
+
} : {}
|
|
3723
|
+
}
|
|
3724
|
+
}));
|
|
3725
|
+
const failed = optimistic.filter((message) => message.delivery?.state === "failed");
|
|
3726
|
+
const unsent = optimistic.filter((message) => message.delivery?.state !== "failed");
|
|
3727
|
+
const ids = new Set(visible.map((item) => item.id));
|
|
3728
|
+
const steers = (queue.acceptedSteers ?? []).filter((steer) => !ids.has(steer.triggerEventId)).map((steer) => ({
|
|
3729
|
+
kind: "user-message",
|
|
3730
|
+
id: steer.triggerEventId,
|
|
3731
|
+
text: steer.text,
|
|
3732
|
+
annotations: steer.annotations,
|
|
3733
|
+
resources: steer.resources,
|
|
3734
|
+
tools: steer.tools,
|
|
3735
|
+
occurredAt: steer.occurredAt,
|
|
3736
|
+
delivery: { state: steer.state }
|
|
3737
|
+
}));
|
|
3738
|
+
return [...placeFailedSends(visible, failed), ...unsent, ...steers];
|
|
3739
|
+
}
|
|
3740
|
+
function placeFailedSends(items, failed) {
|
|
3741
|
+
if (failed.length === 0) return items;
|
|
3742
|
+
const before = /* @__PURE__ */ new Map();
|
|
3743
|
+
const last = [];
|
|
3744
|
+
for (const message of failed) {
|
|
3745
|
+
const sentAt = Date.parse(message.occurredAt);
|
|
3746
|
+
const newer = items.findIndex(
|
|
3747
|
+
(item) => item.kind === "user-message" && Date.parse(item.occurredAt) > sentAt
|
|
3748
|
+
);
|
|
3749
|
+
if (newer === -1) {
|
|
3750
|
+
last.push(message);
|
|
3751
|
+
} else {
|
|
3752
|
+
before.set(newer, [...before.get(newer) ?? [], message]);
|
|
3753
|
+
}
|
|
3754
|
+
}
|
|
3755
|
+
return [...items.flatMap((item, index) => [...before.get(index) ?? [], item]), ...last];
|
|
3756
|
+
}
|
|
3757
|
+
|
|
3758
|
+
// src/lib/session-startup-timeline.tsx
|
|
3759
|
+
import { useRef as useRef7 } from "react";
|
|
3760
|
+
function currentEvents(events) {
|
|
3761
|
+
return events.filter(
|
|
3762
|
+
(event) => !event.duplicateOfEventId && (!event.turnAssociation || event.turnAssociation === "current")
|
|
3763
|
+
).sort((a, b) => a.sequence - b.sequence);
|
|
3764
|
+
}
|
|
3765
|
+
function payloadOf(event) {
|
|
3766
|
+
return event.payload && typeof event.payload === "object" ? event.payload : {};
|
|
3767
|
+
}
|
|
3768
|
+
function sessionStartupTimeline(items, input) {
|
|
3769
|
+
const { session, optimisticMessages, hasNewer } = input;
|
|
3770
|
+
if (hasNewer || session.effectiveControl.state !== "active" || !["idle", "queued", "running"].includes(session.status) || session.status === "idle" && session.inputWait)
|
|
3771
|
+
return items;
|
|
3772
|
+
const claimed = /* @__PURE__ */ new Set();
|
|
3773
|
+
const pending = /* @__PURE__ */ new Map();
|
|
3774
|
+
let queueVersion = session.queueVersion;
|
|
3775
|
+
let newerProgress = false;
|
|
3776
|
+
let observedActiveTurn = null;
|
|
3777
|
+
let previousTurnEndedAt = null;
|
|
3778
|
+
for (const event of currentEvents(input.events)) {
|
|
3779
|
+
const payload = payloadOf(event);
|
|
3780
|
+
if (event.turnId && ["turn.completed", "turn.failed", "turn.cancelled", "turn.superseded"].includes(event.type))
|
|
3781
|
+
previousTurnEndedAt = event.occurredAt;
|
|
3782
|
+
if (event.sequence > session.lastSequence && ([
|
|
3783
|
+
"turn.started",
|
|
3784
|
+
"turn.completed",
|
|
3785
|
+
"turn.failed",
|
|
3786
|
+
"turn.cancelled",
|
|
3787
|
+
"turn.superseded"
|
|
3788
|
+
].includes(event.type) || event.type === "session.status.changed" && payload.status !== "queued" || event.type === "session.queue.changed" && ["edit", "delete"].includes(String(payload.operation))))
|
|
3789
|
+
newerProgress = true;
|
|
3790
|
+
if (event.type === "session.queue.changed" && typeof payload.queueVersion === "number")
|
|
3791
|
+
queueVersion = Math.max(queueVersion, payload.queueVersion);
|
|
3792
|
+
const turnId2 = event.turnId ?? (typeof payload.turnId === "string" ? payload.turnId : null);
|
|
3793
|
+
if (!turnId2) continue;
|
|
3794
|
+
if (event.sequence > session.lastSequence) {
|
|
3795
|
+
if (event.type === "turn.started") observedActiveTurn = turnId2;
|
|
3796
|
+
else if (observedActiveTurn === turnId2 && ["turn.completed", "turn.failed", "turn.cancelled", "turn.superseded"].includes(event.type))
|
|
3797
|
+
observedActiveTurn = null;
|
|
3798
|
+
}
|
|
3799
|
+
if ([
|
|
3800
|
+
"turn.started",
|
|
3801
|
+
"turn.completed",
|
|
3802
|
+
"turn.failed",
|
|
3803
|
+
"turn.cancelled",
|
|
3804
|
+
"turn.superseded"
|
|
3805
|
+
].includes(event.type) || event.type === "session.queue.changed" && ["edit", "delete"].includes(String(payload.operation)))
|
|
3806
|
+
claimed.add(turnId2);
|
|
3807
|
+
if ((event.type === "turn.queued" || event.type === "user.message") && payload.routing === "accepted_for_execution" && (session.status !== "idle" || event.sequence > session.lastSequence))
|
|
3808
|
+
pending.set(turnId2, event.occurredAt);
|
|
3809
|
+
}
|
|
3810
|
+
for (const message of optimisticMessages ?? []) {
|
|
3811
|
+
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))
|
|
3812
|
+
pending.set(message.turnId, message.occurredAt);
|
|
3813
|
+
}
|
|
3814
|
+
const head = input.queue && input.queue.version >= queueVersion ? input.queue.items[0] : null;
|
|
3815
|
+
if (session.status === "queued" && !session.activeTurnId && head && !pending.has(head.id))
|
|
3816
|
+
pending.set(
|
|
3817
|
+
head.id,
|
|
3818
|
+
previousTurnEndedAt && previousTurnEndedAt > head.createdAt ? previousTurnEndedAt : head.createdAt
|
|
3819
|
+
);
|
|
3820
|
+
const candidate = [...pending].find(
|
|
3821
|
+
([turnId2]) => !claimed.has(turnId2) && (!session.activeTurnId || session.activeTurnId === turnId2) && (!observedActiveTurn || observedActiveTurn === turnId2) && !items.some((item) => "turnId" in item && item.turnId === turnId2)
|
|
3822
|
+
);
|
|
3823
|
+
const fallback = !candidate && !newerProgress && session.status === "queued" && !session.activeTurnId && input.fallbackStartedAt;
|
|
3824
|
+
if (!candidate && !fallback) return items;
|
|
3825
|
+
const [turnId, startedAt] = candidate ?? [
|
|
3826
|
+
`pending-startup:${session.id}`,
|
|
3827
|
+
input.fallbackStartedAt
|
|
3828
|
+
];
|
|
3829
|
+
return [
|
|
3830
|
+
...items,
|
|
3831
|
+
{
|
|
3832
|
+
kind: "startup-phase",
|
|
3833
|
+
id: `${turnId}-queue`,
|
|
3834
|
+
turnId,
|
|
3835
|
+
phase: "queue",
|
|
3836
|
+
status: "running",
|
|
3837
|
+
startedAt,
|
|
3838
|
+
occurredAt: startedAt,
|
|
3839
|
+
completedAt: null,
|
|
3840
|
+
durationMs: null,
|
|
3841
|
+
outcome: null,
|
|
3842
|
+
...session.activeTurnId ? {} : { dispatchWait: session.status === "queued" ? session.dispatchWait ?? null : null }
|
|
3843
|
+
}
|
|
3844
|
+
];
|
|
3845
|
+
}
|
|
3846
|
+
var PENDING_SCOPE = "pending-prompt";
|
|
3847
|
+
var PENDING_PROMPT_STARTUP_ID = "pending-prompt-startup";
|
|
3848
|
+
function pendingPromptItems(prompt) {
|
|
3849
|
+
return [
|
|
3850
|
+
{
|
|
3851
|
+
kind: "user-message",
|
|
3852
|
+
id: "pending-prompt-message",
|
|
3853
|
+
text: prompt.text,
|
|
3854
|
+
resources: prompt.resources ?? [],
|
|
3855
|
+
tools: [],
|
|
3856
|
+
occurredAt: prompt.sentAt
|
|
3857
|
+
},
|
|
3858
|
+
{
|
|
3859
|
+
kind: "startup-phase",
|
|
3860
|
+
id: PENDING_PROMPT_STARTUP_ID,
|
|
3861
|
+
turnId: PENDING_SCOPE,
|
|
3862
|
+
phase: "queue",
|
|
3863
|
+
status: "running",
|
|
3864
|
+
startedAt: prompt.sentAt,
|
|
3865
|
+
occurredAt: prompt.sentAt,
|
|
3866
|
+
completedAt: null,
|
|
3867
|
+
durationMs: null,
|
|
3868
|
+
outcome: null
|
|
3869
|
+
}
|
|
3870
|
+
];
|
|
3871
|
+
}
|
|
3872
|
+
function useSessionStartupTimeline(items, input) {
|
|
3873
|
+
const startup = useSessionStartupState(input.session);
|
|
3874
|
+
const bridgeRef = useRef7(null);
|
|
3875
|
+
const { pendingPrompt } = input;
|
|
3876
|
+
if (pendingPrompt && (!input.session || input.historyReady === false)) {
|
|
3877
|
+
bridgeRef.current = {
|
|
3878
|
+
scope: PENDING_SCOPE,
|
|
3879
|
+
id: PENDING_PROMPT_STARTUP_ID,
|
|
3880
|
+
turnId: null,
|
|
3881
|
+
since: pendingPrompt.sentAt,
|
|
3882
|
+
sequence: 0
|
|
3883
|
+
};
|
|
3884
|
+
return [...items, ...pendingPromptItems(pendingPrompt)];
|
|
3885
|
+
}
|
|
3886
|
+
if (!input.session) {
|
|
3887
|
+
bridgeRef.current = null;
|
|
3888
|
+
return items;
|
|
3889
|
+
}
|
|
3890
|
+
const scope = `${input.session.workspaceId}:${input.session.id}`;
|
|
3891
|
+
if (bridgeRef.current?.scope === PENDING_SCOPE)
|
|
3892
|
+
bridgeRef.current = { ...bridgeRef.current, scope };
|
|
3893
|
+
if (bridgeRef.current?.scope !== scope || input.hasNewer || input.session.effectiveControl.state !== "active" || !["queued", "running", "idle"].includes(input.session.status))
|
|
3894
|
+
bridgeRef.current = null;
|
|
3895
|
+
const boundTurn = bridgeRef.current?.turnId;
|
|
3896
|
+
const settled = boundTurn && currentEvents(input.events).find(
|
|
3897
|
+
(event) => event.turnId === boundTurn && ["turn.completed", "turn.failed", "turn.cancelled", "turn.superseded"].includes(event.type)
|
|
3898
|
+
);
|
|
3899
|
+
let fallbackStartedAt = bridgeRef.current?.turnId === null ? bridgeRef.current.since : startup?.startedAt;
|
|
3900
|
+
if (settled) {
|
|
3901
|
+
bridgeRef.current = null;
|
|
3902
|
+
fallbackStartedAt = input.session.status === "queued" && input.session.lastSequence >= settled.sequence ? input.session.updatedAt : void 0;
|
|
3903
|
+
}
|
|
3904
|
+
const projected = sessionStartupTimeline(items, {
|
|
3905
|
+
...input,
|
|
3906
|
+
session: input.session,
|
|
3907
|
+
fallbackStartedAt
|
|
3908
|
+
});
|
|
3909
|
+
if (projected !== items) {
|
|
3910
|
+
const phase2 = projected.at(-1);
|
|
3911
|
+
if (phase2.kind !== "startup-phase") return projected;
|
|
3912
|
+
const turnId2 = phase2.turnId === `pending-startup:${input.session.id}` ? null : phase2.turnId;
|
|
3913
|
+
let bridge2 = bridgeRef.current;
|
|
3914
|
+
if (!bridge2 || bridge2.turnId && turnId2 && bridge2.turnId !== turnId2) {
|
|
3915
|
+
bridge2 = {
|
|
3916
|
+
scope,
|
|
3917
|
+
id: phase2.id,
|
|
3918
|
+
turnId: turnId2,
|
|
3919
|
+
since: phase2.startedAt,
|
|
3920
|
+
sequence: input.session.lastSequence
|
|
3921
|
+
};
|
|
3922
|
+
} else
|
|
3923
|
+
bridge2 = {
|
|
3924
|
+
...bridge2,
|
|
3925
|
+
turnId: turnId2 ?? bridge2.turnId,
|
|
3926
|
+
since: bridge2.since < phase2.startedAt ? bridge2.since : phase2.startedAt
|
|
3927
|
+
};
|
|
3928
|
+
bridgeRef.current = bridge2;
|
|
3929
|
+
return [
|
|
3930
|
+
...projected.slice(0, -1),
|
|
3931
|
+
{ ...phase2, id: bridge2.id, startedAt: bridge2.since, occurredAt: bridge2.since }
|
|
3932
|
+
];
|
|
3933
|
+
}
|
|
3934
|
+
const bridge = bridgeRef.current;
|
|
3935
|
+
if (!bridge) return items;
|
|
3936
|
+
if (input.session.status === "idle") {
|
|
3937
|
+
bridgeRef.current = null;
|
|
3938
|
+
return items;
|
|
3939
|
+
}
|
|
3940
|
+
const started = currentEvents(input.events).find(
|
|
3941
|
+
(event) => event.type === "turn.started" && (bridge.turnId ? event.turnId === bridge.turnId : event.sequence > bridge.sequence)
|
|
3942
|
+
);
|
|
3943
|
+
const turnId = bridge.turnId ?? started?.turnId ?? input.session.activeTurnId;
|
|
3944
|
+
const phase = items.find((item) => item.kind === "startup-phase" && item.turnId === turnId);
|
|
3945
|
+
if (phase?.kind === "startup-phase") {
|
|
3946
|
+
bridgeRef.current = { ...bridge, turnId };
|
|
3947
|
+
return items.map(
|
|
3948
|
+
(item) => item === phase ? {
|
|
3949
|
+
...phase,
|
|
3950
|
+
id: bridge.id,
|
|
3951
|
+
loadingStartedAt: bridge.since < phase.startedAt ? bridge.since : phase.startedAt
|
|
3952
|
+
} : item
|
|
3953
|
+
);
|
|
3954
|
+
}
|
|
3955
|
+
if (turnId && (started || input.session.activeTurnId === turnId)) {
|
|
3956
|
+
bridgeRef.current = { ...bridge, turnId };
|
|
3957
|
+
return [
|
|
3958
|
+
...items,
|
|
3959
|
+
{
|
|
3960
|
+
kind: "startup-phase",
|
|
3961
|
+
id: bridge.id,
|
|
3962
|
+
turnId,
|
|
3963
|
+
phase: "queue",
|
|
3964
|
+
status: "complete",
|
|
3965
|
+
startedAt: bridge.since,
|
|
3966
|
+
occurredAt: bridge.since,
|
|
3967
|
+
completedAt: started?.occurredAt ?? input.session.updatedAt,
|
|
3968
|
+
durationMs: null,
|
|
3969
|
+
outcome: null
|
|
4086
3970
|
}
|
|
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
|
-
|
|
3971
|
+
];
|
|
3972
|
+
}
|
|
3973
|
+
if (turnId) bridgeRef.current = null;
|
|
3974
|
+
return items;
|
|
3975
|
+
}
|
|
3976
|
+
|
|
3977
|
+
// src/hooks/use-session-conversation.ts
|
|
3978
|
+
import { useLayoutEffect as useLayoutEffect4, useMemo as useMemo4, useRef as useRef8, useState as useState6 } from "react";
|
|
3979
|
+
function useSessionConversation(sessionId, options = {}) {
|
|
3980
|
+
const [initialPrompt] = useState6(() => options.pendingPrompt ?? null);
|
|
3981
|
+
const context = useOpenGeni(options);
|
|
3982
|
+
const scope = { client: context.client, workspaceId: context.workspaceId };
|
|
3983
|
+
const config = useClientConfigFlags(context.client);
|
|
3984
|
+
const showModelPicker = options.modelPicker ?? config.modelSelection;
|
|
3985
|
+
const catalog = useWorkspaceModelCatalog({ ...scope, enabled: showModelPicker });
|
|
3986
|
+
const feed = useSessionEvents(sessionId, scope);
|
|
3987
|
+
const pendingPrompt = usePendingPrompt(initialPrompt, sessionId, feed.initialHistoryReady);
|
|
3988
|
+
const eventOptions = { ...scope, events: feed.events };
|
|
3989
|
+
const detail = useSession(sessionId, eventOptions);
|
|
3990
|
+
const queue = useTurnQueue(sessionId, eventOptions);
|
|
3991
|
+
const human = useHumanInputRequests(sessionId, eventOptions);
|
|
3992
|
+
const control = useSessionControl(sessionId, scope);
|
|
3993
|
+
const approvals = useMemo4(() => projectPendingApprovals(feed.events), [feed.events]);
|
|
3994
|
+
const files = useFileAttachments({ ...scope, scope: uploadScopeForSession(detail.session) });
|
|
3995
|
+
const clearFiles = files.clear;
|
|
3996
|
+
const attachmentSession = useRef8(sessionId);
|
|
3997
|
+
useLayoutEffect4(() => {
|
|
3998
|
+
if (attachmentSession.current === sessionId) return;
|
|
3999
|
+
const created = attachmentSession.current === null;
|
|
4000
|
+
attachmentSession.current = sessionId;
|
|
4001
|
+
if (created) return;
|
|
4002
|
+
clearFiles();
|
|
4003
|
+
}, [clearFiles, sessionId]);
|
|
4004
|
+
const uploadsEnabled = (options.attachments ?? true) && config.uploads;
|
|
4005
|
+
const status = feed.sessionStatus ?? detail.session?.status;
|
|
4006
|
+
const terminal = status === "cancelled" || (detail.session ? sessionArchived(detail.session) : false);
|
|
4007
|
+
const importedArchive = detail.session?.importedArchive?.readOnly === true;
|
|
4008
|
+
const host = options.composerOptions;
|
|
4009
|
+
const resolveExtras = () => typeof host?.sendExtras === "function" ? host.sendExtras() : host?.sendExtras;
|
|
4010
|
+
const releaseSentFiles = (input) => files.removeReadyFiles(
|
|
4011
|
+
(input.resources ?? []).flatMap(
|
|
4012
|
+
(resource) => resource.kind === "file" ? [resource.fileId] : []
|
|
4013
|
+
)
|
|
4014
|
+
);
|
|
4015
|
+
const composer = useComposer(sessionId, {
|
|
4016
|
+
...eventOptions,
|
|
4017
|
+
initialDraft: host?.initialDraft,
|
|
4018
|
+
busySend: host?.busySend,
|
|
4019
|
+
offerQueue: host?.offerQueue,
|
|
4020
|
+
effectiveControl: queue.effectiveControl ?? detail.session?.effectiveControl,
|
|
4021
|
+
// As in the console and the native screen: a turn that is still current
|
|
4022
|
+
// (running or recovering) means a Send waits. A turn parked on provider
|
|
4023
|
+
// capacity does not: the Send replaces it and starts right away.
|
|
4024
|
+
sendDestination: () => promptSendDestination({
|
|
4025
|
+
status,
|
|
4026
|
+
activeTurnId: detail.session?.activeTurnId,
|
|
4027
|
+
queuedPrompts: queue.queue.length,
|
|
4028
|
+
admissionBlock: detail.session?.admissionBlock
|
|
4029
|
+
}),
|
|
4030
|
+
sendExtras: () => {
|
|
4031
|
+
const extras = resolveExtras();
|
|
4032
|
+
return {
|
|
4033
|
+
...extras,
|
|
4034
|
+
resources: [...extras?.resources ?? [], ...uploadsEnabled ? files.readyResources : []]
|
|
4035
|
+
};
|
|
4133
4036
|
},
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4037
|
+
sendBlocked: () => sessionId === null || terminal || importedArchive || uploadsEnabled && files.hasUnresolved || host?.sendBlocked?.() === true,
|
|
4038
|
+
onSubmitted: (text, input) => {
|
|
4039
|
+
releaseSentFiles(input);
|
|
4040
|
+
return host?.onSubmitted?.(text, input);
|
|
4138
4041
|
},
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
}
|
|
4042
|
+
onSent: (text, input) => {
|
|
4043
|
+
releaseSentFiles(input);
|
|
4044
|
+
return host?.onSent?.(text, input);
|
|
4045
|
+
},
|
|
4046
|
+
onDeliveryError: host?.onDeliveryError
|
|
4047
|
+
});
|
|
4048
|
+
const conversation = useMemo4(
|
|
4049
|
+
() => conversationTimeline(feed.timeline, queue, composer),
|
|
4050
|
+
[feed.timeline, queue, composer]
|
|
4051
|
+
);
|
|
4052
|
+
const session = detail.session;
|
|
4053
|
+
const sessionControl = session?.effectiveControl;
|
|
4054
|
+
const timeline = useSessionStartupTimeline(conversation, {
|
|
4055
|
+
session: session && sessionControl ? {
|
|
4056
|
+
...session,
|
|
4057
|
+
effectiveControl: admissionRecheckControl(
|
|
4058
|
+
sessionControl,
|
|
4059
|
+
queue.effectiveControl,
|
|
4060
|
+
composer.effectiveControl
|
|
4061
|
+
)
|
|
4062
|
+
} : null,
|
|
4063
|
+
events: feed.events,
|
|
4064
|
+
optimisticMessages: composer.optimisticMessages,
|
|
4065
|
+
hasNewer: feed.hasNewer,
|
|
4066
|
+
queue: queue.snapshot,
|
|
4067
|
+
pendingPrompt,
|
|
4068
|
+
historyReady: sessionId !== null && feed.initialHistoryReady
|
|
4069
|
+
});
|
|
4070
|
+
const error = detail.error ?? feed.error ?? human.error;
|
|
4071
|
+
const loadFailed = Boolean(feed.error) && !feed.initialHistoryReady;
|
|
4072
|
+
const retry = async () => {
|
|
4073
|
+
await Promise.all([
|
|
4074
|
+
...detail.error ? [detail.refresh()] : [],
|
|
4075
|
+
...human.error ? [human.refresh()] : [],
|
|
4076
|
+
...feed.error ? [feed.jumpToLatest()] : []
|
|
4077
|
+
]);
|
|
4143
4078
|
};
|
|
4144
4079
|
return {
|
|
4145
4080
|
...scope,
|
|
4081
|
+
sessionId,
|
|
4146
4082
|
config,
|
|
4083
|
+
catalog,
|
|
4084
|
+
showModelPicker,
|
|
4085
|
+
feed,
|
|
4086
|
+
detail,
|
|
4087
|
+
queue,
|
|
4088
|
+
human,
|
|
4089
|
+
control,
|
|
4090
|
+
approvals,
|
|
4147
4091
|
files,
|
|
4148
4092
|
uploadsEnabled,
|
|
4149
|
-
available,
|
|
4150
|
-
showModelPicker,
|
|
4151
|
-
catalog,
|
|
4152
4093
|
composer,
|
|
4153
|
-
|
|
4094
|
+
/** The same live application context for text and durable voice messages. */
|
|
4095
|
+
getModelContext: () => resolveExtras()?.modelContext,
|
|
4096
|
+
timeline,
|
|
4097
|
+
status,
|
|
4098
|
+
terminal,
|
|
4099
|
+
importedArchive,
|
|
4100
|
+
running: sessionTurnKeepsRunControl(status),
|
|
4154
4101
|
error,
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
retry: () => pendingRef.current ? deliver(pendingRef.current) : Promise.resolve(false),
|
|
4158
|
-
startRealtime
|
|
4102
|
+
loadFailed,
|
|
4103
|
+
retry
|
|
4159
4104
|
};
|
|
4160
4105
|
}
|
|
4106
|
+
function usePendingPrompt(prompt, sessionId, historyReady) {
|
|
4107
|
+
const owner = useRef8({
|
|
4108
|
+
sessionId,
|
|
4109
|
+
retired: prompt === null
|
|
4110
|
+
});
|
|
4111
|
+
const current = owner.current;
|
|
4112
|
+
if (!current.retired && current.sessionId !== sessionId) {
|
|
4113
|
+
if (current.sessionId === null) current.sessionId = sessionId;
|
|
4114
|
+
else current.retired = true;
|
|
4115
|
+
}
|
|
4116
|
+
if (!current.retired && sessionId !== null && historyReady) current.retired = true;
|
|
4117
|
+
return current.retired ? null : prompt;
|
|
4118
|
+
}
|
|
4119
|
+
|
|
4120
|
+
// src/hooks/use-session-read-acknowledgement.ts
|
|
4121
|
+
import { useEffect as useEffect6, useMemo as useMemo5, useRef as useRef9 } from "react";
|
|
4122
|
+
var SESSION_READ_ACKNOWLEDGEMENT_RETRY_MS = 1e3;
|
|
4123
|
+
function isPermanentRejection(error) {
|
|
4124
|
+
const status = error && typeof error === "object" ? error.status : void 0;
|
|
4125
|
+
return typeof status === "number" && status >= 400 && status < 500 && status !== 408 && status !== 429;
|
|
4126
|
+
}
|
|
4127
|
+
function useSessionReadAcknowledgement(input) {
|
|
4128
|
+
const { client, workspaceId, sessionId, events, active } = input;
|
|
4129
|
+
const session = input.session && (input.session.id ?? sessionId) === sessionId ? input.session : null;
|
|
4130
|
+
const attentionThrough = useMemo5(() => sessionAttentionReadThroughSequence(events), [events]);
|
|
4131
|
+
const { readThrough, unread } = readAcknowledgementFrontier(session, attentionThrough);
|
|
4132
|
+
const hasSession = session !== null;
|
|
4133
|
+
const receipt = useRef9(null);
|
|
4134
|
+
const refused = useRef9(/* @__PURE__ */ new Set());
|
|
4135
|
+
const retryTimer = useRef9(null);
|
|
4136
|
+
useEffect6(
|
|
4137
|
+
() => () => {
|
|
4138
|
+
if (retryTimer.current !== null) clearTimeout(retryTimer.current);
|
|
4139
|
+
retryTimer.current = null;
|
|
4140
|
+
receipt.current = null;
|
|
4141
|
+
},
|
|
4142
|
+
[]
|
|
4143
|
+
);
|
|
4144
|
+
useEffect6(() => {
|
|
4145
|
+
if (!active || !hasSession || !unread || readThrough <= 0) return;
|
|
4146
|
+
if (!workspaceId || !sessionId || typeof client.updateSessionAttention !== "function") return;
|
|
4147
|
+
const scope = `${workspaceId}:${sessionId}`;
|
|
4148
|
+
if (refused.current.has(scope)) return;
|
|
4149
|
+
const key = `${scope}:${readThrough}`;
|
|
4150
|
+
if (receipt.current === key) return;
|
|
4151
|
+
receipt.current = key;
|
|
4152
|
+
if (retryTimer.current !== null) clearTimeout(retryTimer.current);
|
|
4153
|
+
retryTimer.current = null;
|
|
4154
|
+
const attempt = (retried) => {
|
|
4155
|
+
void Promise.resolve().then(
|
|
4156
|
+
() => client.updateSessionAttention(workspaceId, sessionId, {
|
|
4157
|
+
unread: false,
|
|
4158
|
+
acknowledgedThroughSequence: readThrough
|
|
4159
|
+
})
|
|
4160
|
+
).catch((error) => {
|
|
4161
|
+
if (receipt.current !== key) return;
|
|
4162
|
+
if (isPermanentRejection(error)) {
|
|
4163
|
+
refused.current.add(scope);
|
|
4164
|
+
return;
|
|
4165
|
+
}
|
|
4166
|
+
if (!retried) {
|
|
4167
|
+
retryTimer.current = setTimeout(() => {
|
|
4168
|
+
retryTimer.current = null;
|
|
4169
|
+
if (receipt.current === key) attempt(true);
|
|
4170
|
+
}, SESSION_READ_ACKNOWLEDGEMENT_RETRY_MS);
|
|
4171
|
+
return;
|
|
4172
|
+
}
|
|
4173
|
+
receipt.current = null;
|
|
4174
|
+
});
|
|
4175
|
+
};
|
|
4176
|
+
attempt(false);
|
|
4177
|
+
}, [active, client, hasSession, readThrough, sessionId, unread, workspaceId]);
|
|
4178
|
+
}
|
|
4161
4179
|
|
|
4162
|
-
// src/hooks/use-
|
|
4180
|
+
// src/hooks/use-new-conversation.ts
|
|
4163
4181
|
import {
|
|
4164
|
-
OpenGeniApiError as OpenGeniApiError2
|
|
4165
|
-
observedSessionSequence
|
|
4182
|
+
OpenGeniApiError as OpenGeniApiError2
|
|
4166
4183
|
} from "@opengeni/sdk";
|
|
4167
|
-
import { useCallback as
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
}
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
const
|
|
4177
|
-
const
|
|
4178
|
-
const
|
|
4179
|
-
const
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
const
|
|
4184
|
+
import { useCallback as useCallback9, useLayoutEffect as useLayoutEffect5, useMemo as useMemo6, useRef as useRef10, useState as useState7 } from "react";
|
|
4185
|
+
var NOOP_ASYNC = async () => {
|
|
4186
|
+
};
|
|
4187
|
+
var EMPTY_CHOICE = {};
|
|
4188
|
+
var NO_LEVELS = [];
|
|
4189
|
+
function useNewConversation(options = {}) {
|
|
4190
|
+
const t = useOpenGeniText();
|
|
4191
|
+
const context = useOpenGeni(options);
|
|
4192
|
+
const scope = { client: context.client, workspaceId: context.workspaceId };
|
|
4193
|
+
const config = useClientConfigFlags(context.client);
|
|
4194
|
+
const showModelPicker = options.modelPicker ?? config.modelSelection;
|
|
4195
|
+
const catalog = useWorkspaceModelCatalog({ ...scope, enabled: showModelPicker });
|
|
4196
|
+
const preferredModel = options.defaultModel && catalog.models.some(
|
|
4197
|
+
(row) => row.id === options.defaultModel && row.availability?.selectable !== false
|
|
4198
|
+
) ? options.defaultModel : void 0;
|
|
4199
|
+
const defaultModel = preferredModel ?? catalog.defaultModel;
|
|
4200
|
+
const files = useFileAttachments(scope);
|
|
4201
|
+
const uploadsEnabled = (options.attachments ?? true) && config.uploads;
|
|
4202
|
+
const available = options.enabled !== false && (options.createSession !== void 0 || config.sessionCreation);
|
|
4203
|
+
const [text, setText] = useState7("");
|
|
4204
|
+
const [choice, setChoice] = useState7(EMPTY_CHOICE);
|
|
4205
|
+
const [, setLevels] = useState7(NO_LEVELS);
|
|
4206
|
+
const [sending, setSending] = useState7(false);
|
|
4183
4207
|
const [error, setError] = useState7(null);
|
|
4184
|
-
const [
|
|
4185
|
-
const
|
|
4186
|
-
const
|
|
4187
|
-
const
|
|
4188
|
-
const
|
|
4189
|
-
const
|
|
4190
|
-
const
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
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);
|
|
4208
|
+
const [pending, setPending] = useState7(null);
|
|
4209
|
+
const [completion, setCompletion] = useState7(null);
|
|
4210
|
+
const textRef = useRef10(text);
|
|
4211
|
+
const textRevision = useRef10(0);
|
|
4212
|
+
const choiceRef = useRef10(choice);
|
|
4213
|
+
const levelsRef = useRef10(NO_LEVELS);
|
|
4214
|
+
const setModelLevels = useCallback9((levels = NO_LEVELS) => {
|
|
4215
|
+
const previous = levelsRef.current;
|
|
4216
|
+
if (previous.length === levels.length && previous.every((level, index) => {
|
|
4217
|
+
const next = levels[index];
|
|
4218
|
+
return next?.model === level.model && next.effort === level.effort;
|
|
4219
|
+
}))
|
|
4277
4220
|
return;
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
timer = setTimeout(() => {
|
|
4299
|
-
timer = null;
|
|
4300
|
-
void load().finally(schedule);
|
|
4301
|
-
}, pollIntervalMs);
|
|
4302
|
-
};
|
|
4303
|
-
void load().finally(schedule);
|
|
4221
|
+
levelsRef.current = levels;
|
|
4222
|
+
setLevels(levels);
|
|
4223
|
+
}, []);
|
|
4224
|
+
const filesRef = useRef10(files);
|
|
4225
|
+
filesRef.current = files;
|
|
4226
|
+
const pendingRef = useRef10(null);
|
|
4227
|
+
const completionRef = useRef10(null);
|
|
4228
|
+
const inFlight = useRef10(false);
|
|
4229
|
+
const lifetime = useRef10({ mounted: true, generation: 0 }).current;
|
|
4230
|
+
const identity = useMemo6(
|
|
4231
|
+
() => ({
|
|
4232
|
+
client: context.client,
|
|
4233
|
+
workspaceId: context.workspaceId,
|
|
4234
|
+
scopeKey: options.scopeKey
|
|
4235
|
+
}),
|
|
4236
|
+
[context.client, context.workspaceId, options.scopeKey]
|
|
4237
|
+
);
|
|
4238
|
+
const committedIdentity = useRef10(identity);
|
|
4239
|
+
useLayoutEffect5(() => {
|
|
4240
|
+
lifetime.mounted = true;
|
|
4304
4241
|
return () => {
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
retireLoads();
|
|
4242
|
+
lifetime.mounted = false;
|
|
4243
|
+
lifetime.generation++;
|
|
4308
4244
|
};
|
|
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
|
-
});
|
|
4245
|
+
}, [lifetime]);
|
|
4328
4246
|
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
|
-
|
|
4247
|
+
if (committedIdentity.current === identity) return;
|
|
4248
|
+
committedIdentity.current = identity;
|
|
4249
|
+
lifetime.generation++;
|
|
4250
|
+
inFlight.current = false;
|
|
4251
|
+
pendingRef.current = null;
|
|
4252
|
+
completionRef.current = null;
|
|
4253
|
+
textRef.current = "";
|
|
4254
|
+
textRevision.current = 0;
|
|
4255
|
+
choiceRef.current = EMPTY_CHOICE;
|
|
4256
|
+
setText("");
|
|
4257
|
+
setChoice(EMPTY_CHOICE);
|
|
4258
|
+
setSending(false);
|
|
4259
|
+
setError(null);
|
|
4260
|
+
setPending(null);
|
|
4261
|
+
setCompletion(null);
|
|
4262
|
+
filesRef.current.clear();
|
|
4263
|
+
}, [identity, lifetime]);
|
|
4264
|
+
const ownsScope = () => lifetime.mounted && committedIdentity.current === identity;
|
|
4265
|
+
const updateText = (value) => {
|
|
4266
|
+
if (!ownsScope()) return;
|
|
4267
|
+
if (value !== textRef.current) textRevision.current++;
|
|
4268
|
+
textRef.current = value;
|
|
4269
|
+
setText(value);
|
|
4270
|
+
};
|
|
4271
|
+
const updateChoice = (patch) => {
|
|
4272
|
+
if (!ownsScope()) return;
|
|
4273
|
+
const base = patch.model === void 0 ? creationChoice() : choiceRef.current;
|
|
4274
|
+
const next = { ...base, ...patch };
|
|
4275
|
+
const model = catalog.models.find((row) => row.id === (next.model ?? defaultModel));
|
|
4276
|
+
if (model) {
|
|
4277
|
+
if (next.reasoningEffort)
|
|
4278
|
+
next.reasoningEffort = coerceReasoningEffortForModel(model, next.reasoningEffort);
|
|
4279
|
+
if (next.latencyMode && !runnableLatencyModesForModel(model).includes(next.latencyMode))
|
|
4280
|
+
next.latencyMode = "standard";
|
|
4281
|
+
}
|
|
4282
|
+
choiceRef.current = next;
|
|
4283
|
+
setChoice(choiceRef.current);
|
|
4284
|
+
if (!pendingRef.current) setError(null);
|
|
4285
|
+
};
|
|
4286
|
+
const displayPolicy = (selected) => {
|
|
4287
|
+
const model = selected.model ?? defaultModel;
|
|
4288
|
+
const definition = catalog.models.find((row) => row.id === model);
|
|
4289
|
+
const effort = selected.reasoningEffort ?? (definition ? defaultEffortForModel(definition) : config.defaultReasoningEffort ?? "medium");
|
|
4290
|
+
return showModelPicker && model ? {
|
|
4291
|
+
model,
|
|
4292
|
+
reasoningEffort: definition ? coerceReasoningEffortForModel(definition, effort) : effort,
|
|
4293
|
+
latencyMode: selected.latencyMode ?? "standard"
|
|
4294
|
+
} : void 0;
|
|
4295
|
+
};
|
|
4296
|
+
const creationChoice = () => {
|
|
4297
|
+
const selected = choiceRef.current;
|
|
4298
|
+
if (preferredModel) return { model: preferredModel, ...selected };
|
|
4299
|
+
if (selected !== EMPTY_CHOICE || !showModelPicker || catalog.loading || !levelsRef.current.length)
|
|
4300
|
+
return selected;
|
|
4301
|
+
const workspace = displayPolicy(EMPTY_CHOICE);
|
|
4302
|
+
const view = modelLevelsView(t, {
|
|
4303
|
+
levels: levelsRef.current,
|
|
4304
|
+
rows: catalog.rows,
|
|
4305
|
+
model: workspace?.model ?? "",
|
|
4306
|
+
effort: workspace?.reasoningEffort ?? "medium",
|
|
4307
|
+
latencyMode: "standard"
|
|
4308
|
+
});
|
|
4309
|
+
const first = view && view.index < 0 ? modelLevelChoice(view, 0, false) : null;
|
|
4310
|
+
return first ? { model: first.model, reasoningEffort: first.effort } : selected;
|
|
4311
|
+
};
|
|
4312
|
+
const create = options.createSession ?? (async (initialMessage, idempotencyKey, input) => {
|
|
4313
|
+
const creator = context.client.createSession;
|
|
4314
|
+
if (typeof creator !== "function")
|
|
4315
|
+
throw new Error(t("hooks.useNewConversation.newChatsAreNotEnabled"));
|
|
4316
|
+
const created = await creator.call(context.client, context.workspaceId, {
|
|
4317
|
+
...input.startMode === "realtime" ? {} : { initialMessage },
|
|
4318
|
+
idempotencyKey,
|
|
4319
|
+
...input
|
|
4320
|
+
});
|
|
4321
|
+
return created.id;
|
|
4353
4322
|
});
|
|
4354
|
-
const
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4323
|
+
const finishCreation = (accepted) => {
|
|
4324
|
+
if (!lifetime.mounted || lifetime.generation !== accepted.generation) return;
|
|
4325
|
+
const { attempt, sessionId } = accepted;
|
|
4326
|
+
const sentFiles = new Set(attempt.options.resources?.map((resource) => resource.fileId) ?? []);
|
|
4327
|
+
const selected = showModelPicker ? creationChoice() : EMPTY_CHOICE;
|
|
4328
|
+
const policyChanged = ["model", "reasoningEffort", "latencyMode"].some(
|
|
4329
|
+
(field) => selected[field] !== attempt.options[field]
|
|
4330
|
+
);
|
|
4331
|
+
const draft = {
|
|
4332
|
+
text: attempt.clearDraft && textRevision.current === attempt.textRevision ? "" : textRef.current,
|
|
4333
|
+
resources: filesRef.current.readyResources.filter(
|
|
4334
|
+
(resource) => !sentFiles.has(resource.fileId)
|
|
4335
|
+
),
|
|
4336
|
+
// Unchanged choices are already part of the created session. Do not
|
|
4337
|
+
// replace server-owned defaults with a browser's catalog estimate.
|
|
4338
|
+
...policyChanged ? { policy: displayPolicy(selected) } : {}
|
|
4339
|
+
};
|
|
4340
|
+
pendingRef.current = null;
|
|
4341
|
+
completionRef.current = null;
|
|
4342
|
+
setPending(null);
|
|
4343
|
+
setCompletion(null);
|
|
4344
|
+
updateText(draft.text);
|
|
4345
|
+
filesRef.current.removeReadyFiles(sentFiles);
|
|
4346
|
+
notifyObserver(options.onCreated, {
|
|
4347
|
+
sessionId,
|
|
4348
|
+
initialMessage: attempt.initialMessage,
|
|
4349
|
+
sentAt: attempt.sentAt,
|
|
4350
|
+
draft,
|
|
4351
|
+
...attempt.realtimeModel ? { realtimeModel: attempt.realtimeModel } : {}
|
|
4352
|
+
});
|
|
4353
|
+
};
|
|
4354
|
+
const finishRef = useRef10(finishCreation);
|
|
4355
|
+
finishRef.current = finishCreation;
|
|
4366
4356
|
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
|
-
})
|
|
4357
|
+
if (completion && !files.hasUnresolved) finishRef.current(completion);
|
|
4358
|
+
}, [completion, files.hasUnresolved]);
|
|
4359
|
+
const deliver = async (attempt) => {
|
|
4360
|
+
if (!ownsScope() || inFlight.current || completionRef.current || !available) return false;
|
|
4361
|
+
const ownedGeneration = lifetime.generation;
|
|
4362
|
+
inFlight.current = true;
|
|
4363
|
+
pendingRef.current = attempt;
|
|
4364
|
+
setSending(true);
|
|
4365
|
+
setError(null);
|
|
4366
|
+
setPending(null);
|
|
4367
|
+
try {
|
|
4368
|
+
const sessionId = await attempt.create(
|
|
4369
|
+
attempt.initialMessage,
|
|
4370
|
+
attempt.key,
|
|
4371
|
+
structuredClone(attempt.options)
|
|
4402
4372
|
);
|
|
4403
|
-
if (
|
|
4404
|
-
|
|
4373
|
+
if (!lifetime.mounted || lifetime.generation !== ownedGeneration) return true;
|
|
4374
|
+
const accepted = { sessionId, attempt, generation: ownedGeneration };
|
|
4375
|
+
completionRef.current = accepted;
|
|
4376
|
+
if (filesRef.current.hasUnresolved) setCompletion(accepted);
|
|
4377
|
+
else finishCreation(accepted);
|
|
4378
|
+
return true;
|
|
4379
|
+
} catch (cause) {
|
|
4380
|
+
if (!lifetime.mounted || lifetime.generation !== ownedGeneration) return false;
|
|
4381
|
+
setError({ cause });
|
|
4382
|
+
if (cause instanceof OpenGeniApiError2 && cause.outcomeUnknown === false) {
|
|
4383
|
+
pendingRef.current = null;
|
|
4384
|
+
} else {
|
|
4385
|
+
setPending(attempt);
|
|
4386
|
+
}
|
|
4387
|
+
return false;
|
|
4388
|
+
} finally {
|
|
4389
|
+
if (lifetime.mounted && lifetime.generation === ownedGeneration) {
|
|
4390
|
+
inFlight.current = false;
|
|
4391
|
+
setSending(false);
|
|
4405
4392
|
}
|
|
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
4393
|
}
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4394
|
+
};
|
|
4395
|
+
const submit = async (explicit) => {
|
|
4396
|
+
if (!ownsScope() || !available || inFlight.current || pendingRef.current || uploadsEnabled && filesRef.current.hasUnresolved)
|
|
4397
|
+
return false;
|
|
4398
|
+
const resources = uploadsEnabled ? filesRef.current.readyResources : [];
|
|
4399
|
+
const draftText = explicit ?? textRef.current;
|
|
4400
|
+
const initialMessage = draftText.trim() || (resources.length > 0 ? FILE_ONLY_MESSAGE_TEXT(t) : "");
|
|
4401
|
+
if (!initialMessage) return false;
|
|
4402
|
+
return deliver({
|
|
4403
|
+
key: crypto.randomUUID(),
|
|
4404
|
+
initialMessage,
|
|
4405
|
+
sentAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4406
|
+
textRevision: textRevision.current,
|
|
4407
|
+
clearDraft: explicit === void 0,
|
|
4408
|
+
create,
|
|
4409
|
+
options: {
|
|
4410
|
+
...resources.length ? { resources: structuredClone(resources) } : {},
|
|
4411
|
+
...showModelPicker ? creationChoice() : {}
|
|
4412
|
+
}
|
|
4427
4413
|
});
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4414
|
+
};
|
|
4415
|
+
const startRealtime = async (model) => {
|
|
4416
|
+
if (!ownsScope() || !available || inFlight.current || pendingRef.current || !config.realtimeVoice || !(options.realtimeVoice ?? config.realtimeVoiceOffered))
|
|
4417
|
+
return false;
|
|
4418
|
+
if (filesRef.current.hasUnresolved) return false;
|
|
4419
|
+
return deliver({
|
|
4420
|
+
key: crypto.randomUUID(),
|
|
4421
|
+
initialMessage: "",
|
|
4422
|
+
sentAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4423
|
+
textRevision: textRevision.current,
|
|
4424
|
+
clearDraft: false,
|
|
4425
|
+
create,
|
|
4426
|
+
options: {
|
|
4427
|
+
...showModelPicker ? creationChoice() : {},
|
|
4428
|
+
startMode: "realtime"
|
|
4429
|
+
},
|
|
4430
|
+
realtimeModel: model
|
|
4431
|
+
});
|
|
4432
|
+
};
|
|
4433
|
+
const composer = {
|
|
4434
|
+
value: text,
|
|
4435
|
+
setValue: updateText,
|
|
4436
|
+
hasDraftContent: () => textRef.current.length > 0 || filesRef.current.attachments.length > 0,
|
|
4437
|
+
send: submit,
|
|
4438
|
+
steer: submit,
|
|
4439
|
+
// Nothing runs before the conversation exists: Send just sends.
|
|
4440
|
+
working: false,
|
|
4441
|
+
sending,
|
|
4442
|
+
canSend: available && !sending && !pending && !completion && (text.trim().length > 0 || uploadsEnabled && files.readyResources.length > 0) && !(uploadsEnabled && files.hasUnresolved),
|
|
4443
|
+
pause: NOOP_ASYNC,
|
|
4444
|
+
pausing: false,
|
|
4445
|
+
resume: NOOP_ASYNC,
|
|
4446
|
+
resumeScope: NOOP_ASYNC,
|
|
4447
|
+
resuming: false,
|
|
4448
|
+
draft: null,
|
|
4449
|
+
draftRevision: 0,
|
|
4450
|
+
draftLoading: false,
|
|
4451
|
+
draftSaving: false,
|
|
4452
|
+
draftConflict: null,
|
|
4453
|
+
policy: displayPolicy(creationChoice()) ?? null,
|
|
4454
|
+
setModel: (model) => updateChoice({ model }),
|
|
4455
|
+
setReasoningEffort: (reasoningEffort) => updateChoice({ reasoningEffort }),
|
|
4456
|
+
setLatencyMode: (latencyMode) => updateChoice({ latencyMode }),
|
|
4457
|
+
draftPersistence: "disabled",
|
|
4458
|
+
applyDraft: () => {
|
|
4459
|
+
},
|
|
4460
|
+
reloadDraft: NOOP_ASYNC,
|
|
4461
|
+
resolveDraftConflict: NOOP_ASYNC,
|
|
4462
|
+
restoredResources: [],
|
|
4463
|
+
removeRestoredResource: () => {
|
|
4464
|
+
},
|
|
4465
|
+
error: null,
|
|
4466
|
+
clearError: () => {
|
|
4467
|
+
if (ownsScope()) setError(null);
|
|
4433
4468
|
}
|
|
4434
|
-
}
|
|
4469
|
+
};
|
|
4435
4470
|
return {
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4471
|
+
...scope,
|
|
4472
|
+
config,
|
|
4473
|
+
files,
|
|
4474
|
+
uploadsEnabled,
|
|
4475
|
+
available,
|
|
4476
|
+
showModelPicker,
|
|
4477
|
+
setModelLevels,
|
|
4478
|
+
setModelPolicy: updateChoice,
|
|
4479
|
+
catalog,
|
|
4480
|
+
composer,
|
|
4481
|
+
realtimeVoiceEnabled: config.realtimeVoice && (options.realtimeVoice ?? config.realtimeVoiceOffered),
|
|
4441
4482
|
error,
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
deleteGoal: clearGoal,
|
|
4447
|
-
updating: mutating,
|
|
4448
|
-
mutationError,
|
|
4449
|
-
clearMutationError
|
|
4483
|
+
finishingUploads: completion !== null,
|
|
4484
|
+
pending: pending ? { idempotencyKey: pending.key, realtimeModel: pending.realtimeModel } : null,
|
|
4485
|
+
retry: () => pendingRef.current ? deliver(pendingRef.current) : Promise.resolve(false),
|
|
4486
|
+
startRealtime
|
|
4450
4487
|
};
|
|
4451
4488
|
}
|
|
4452
4489
|
|
|
4453
4490
|
export {
|
|
4454
|
-
conversationTimeline,
|
|
4455
4491
|
isTitleEvent,
|
|
4456
4492
|
useSession,
|
|
4457
|
-
useSessionStartupTimeline,
|
|
4458
|
-
useAvailableModels,
|
|
4459
|
-
useWorkspaceModelCatalog,
|
|
4460
|
-
isHumanInputEvent,
|
|
4461
|
-
useHumanInputRequests,
|
|
4462
|
-
useSessionControl,
|
|
4463
4493
|
invokeOlderHistoryLoaderWithReceiptCapture,
|
|
4464
4494
|
createOlderHistoryLoadReceipt,
|
|
4465
4495
|
useTurnlessOutputGap,
|
|
@@ -4471,10 +4501,17 @@ export {
|
|
|
4471
4501
|
boundBrowserSessionEventWindow,
|
|
4472
4502
|
isTurnQueueEvent,
|
|
4473
4503
|
useTurnQueue,
|
|
4504
|
+
isGoalEvent,
|
|
4505
|
+
useGoal,
|
|
4506
|
+
useSessionControl,
|
|
4507
|
+
useAvailableModels,
|
|
4508
|
+
useWorkspaceModelCatalog,
|
|
4509
|
+
isHumanInputEvent,
|
|
4510
|
+
useHumanInputRequests,
|
|
4511
|
+
conversationTimeline,
|
|
4512
|
+
useSessionStartupTimeline,
|
|
4474
4513
|
useSessionConversation,
|
|
4475
4514
|
useSessionReadAcknowledgement,
|
|
4476
|
-
useNewConversation
|
|
4477
|
-
isGoalEvent,
|
|
4478
|
-
useGoal
|
|
4515
|
+
useNewConversation
|
|
4479
4516
|
};
|
|
4480
|
-
//# sourceMappingURL=chunk-
|
|
4517
|
+
//# sourceMappingURL=chunk-7T7TPJL2.js.map
|