@opengeni/react 6.37.2 → 6.37.3-canary.45212185968001
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/app-state.js +28 -28
- package/dist/app/components/Composer.js +42 -42
- 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 +133 -133
- package/dist/app/components/agents/agent-page.js +115 -115
- 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 +27 -27
- 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 +94 -94
- package/dist/app/components/agents/composer-agent-chip.js +55 -55
- package/dist/app/components/agents/session-agent-chip.js +52 -52
- 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 +26 -26
- 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 +49 -49
- package/dist/app/components/artifacts/ready-made-apps.js +10 -10
- 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 +11 -11
- 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 +63 -63
- package/dist/app/components/artifacts/site-publishing.js +49 -49
- package/dist/app/components/artifacts/site-settings.js +62 -62
- 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 +14 -14
- package/dist/app/components/capabilities/capability-logo-source.js +25 -25
- 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 +28 -28
- package/dist/app/components/capabilities/own-logins-shared-heads-up.js +5 -5
- package/dist/app/components/capabilities/perform-capability-action.js +1 -1
- package/dist/app/components/capabilities/prepared-mcp-setup-card.js +28 -28
- package/dist/app/components/capabilities/session-capability-card.js +128 -128
- package/dist/app/components/capabilities/session-chrome-card.js +48 -48
- package/dist/app/components/capabilities/session-connect-inputs-card.js +31 -31
- package/dist/app/components/capabilities/session-custom-mcp-card.js +36 -36
- package/dist/app/components/capabilities/session-github-card.js +42 -42
- package/dist/app/components/capabilities/session-machine-card.js +49 -49
- package/dist/app/components/capabilities/session-personal-github-card.js +29 -29
- package/dist/app/components/capabilities/session-plugin-card.js +18 -18
- package/dist/app/components/capabilities/use-capabilities-catalog.js +1 -1
- package/dist/app/components/capabilities/use-connection-accounts.js +2 -2
- 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 +80 -80
- package/dist/app/components/command-menu/command-menu.js +101 -101
- package/dist/app/components/command-menu/shortcut-sheet.js +17 -17
- package/dist/app/components/composer-capabilities-menu-body.js +5 -5
- package/dist/app/components/composer-mobile-plus-panel.js +25 -25
- 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 +25 -25
- 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 +7 -7
- 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 +13 -13
- 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 +24 -24
- package/dist/app/components/manual-repository-editor.js +3 -3
- package/dist/app/components/markdown.js +14 -14
- 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 +10 -10
- package/dist/app/components/rail/channel-create-dialog.js +5 -5
- package/dist/app/components/rail/project-glyph.js +48 -48
- package/dist/app/components/rail/project-profile.js +66 -66
- package/dist/app/components/rail/rail-context.js +2 -2
- package/dist/app/components/rail/rail-sections.js +150 -150
- package/dist/app/components/rail/session-header.js +117 -117
- package/dist/app/components/rail/session-list.js +147 -147
- 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 +188 -188
- package/dist/app/components/rail/site-session-group-heading.js +34 -34
- package/dist/app/components/repository-picker.js +13 -13
- package/dist/app/components/secrets/session-secrets-panel.js +4 -4
- package/dist/app/components/session/agent-configuration-panel.js +40 -40
- package/dist/app/components/session/artifact-session-page.js +6 -6
- package/dist/app/components/session/banners.js +19 -19
- package/dist/app/components/session/chat-avatar.js +48 -48
- package/dist/app/components/session/console-new-conversation.js +105 -105
- package/dist/app/components/session/descendant-requests.js +101 -101
- package/dist/app/components/session/editable-artifacts-workspace.js +57 -57
- package/dist/app/components/session/failed-session-banner.js +25 -25
- package/dist/app/components/session/human-input-delegation-record.js +2 -2
- package/dist/app/components/session/human-input.js +80 -80
- package/dist/app/components/session/inspector.js +132 -132
- 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 +25 -25
- package/dist/app/components/session/new-session-setup-strip.js +51 -51
- package/dist/app/components/session/pull-request-panel.js +23 -23
- package/dist/app/components/session/sandbox-switcher.js +21 -21
- package/dist/app/components/session/sandbox-workspace.js +112 -112
- package/dist/app/components/session/search-markdown-highlight.js +15 -15
- package/dist/app/components/session/search-results-view.js +16 -16
- 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 +55 -55
- package/dist/app/components/session/session-avatar.js +50 -50
- package/dist/app/components/session/session-machine-access-notice.js +10 -10
- package/dist/app/components/session/session-profile-dialog.js +63 -63
- package/dist/app/components/session/session-profile-editor.js +64 -64
- package/dist/app/components/session/session-retention.js +5 -5
- package/dist/app/components/session/session-search-dialog.js +19 -19
- package/dist/app/components/session/session-skill-reviews.js +5 -5
- package/dist/app/components/session/session-tenancy-control.js +23 -23
- 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 +22 -22
- 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 +21 -21
- package/dist/app/components/workspace-composer-plus.js +39 -39
- package/dist/app/components/workspace-reach.js +5 -5
- package/dist/app/embed/session-app.js +371 -371
- package/dist/app/lib/actions/actions-provider.js +14 -14
- package/dist/app/lib/agent-capabilities.js +1 -1
- package/dist/app/lib/app-connect-card.js +10 -10
- 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 +29 -29
- package/dist/app/lib/composer-send-blocking.js +2 -2
- package/dist/app/lib/console-site.js +3 -3
- package/dist/app/lib/events.js +25 -25
- 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 +1 -1
- 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 +5 -5
- 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 +3 -3
- 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 +17 -17
- package/dist/app/routes/app-page.js +2 -2
- package/dist/app/routes/artifacts.js +144 -144
- package/dist/app/routes/retained-artifact.js +107 -107
- package/dist/app/routes/session-unavailable.js +4 -4
- package/dist/app/routes/session.js +230 -230
- package/dist/app/routes/sessions-index-hydration.js +1 -1
- package/dist/app/routes/sessions-index.js +190 -190
- package/dist/app/routes/site-view.js +186 -186
- 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-J6O65JXH.js → browser-viewer-DWLNDPHZ.js} +7 -7
- package/dist/{chat-interactive-block-R5JEJYMR.js → chat-interactive-block-KUDPTS4Z.js} +9 -9
- package/dist/{chunk-YPM3T3UM.js → chunk-2E25T36N.js} +24 -24
- package/dist/{chunk-VXOB3OM6.js → chunk-2MN4ECC6.js} +2 -2
- package/dist/{chunk-NY5DX43C.js → chunk-2SM3NPVF.js} +2 -2
- package/dist/{chunk-UJDTQJ34.js → chunk-2Y4LDCRD.js} +3 -3
- package/dist/{chunk-UVZ5FMM7.js → chunk-3AIXQ3BF.js} +2 -2
- package/dist/{chunk-4PGKQ7WM.js → chunk-3BI43BIS.js} +2 -2
- package/dist/{chunk-KQY4P4EO.js → chunk-3BYVKJ7U.js} +6 -6
- package/dist/{chunk-KZTBTQG2.js → chunk-3EEUD7YO.js} +1764 -1764
- package/dist/chunk-3EEUD7YO.js.map +1 -0
- package/dist/{chunk-ERKXCRO5.js → chunk-3IHXVJAT.js} +2 -2
- package/dist/{chunk-J3F65ZVP.js → chunk-3VS6PNSI.js} +10 -10
- package/dist/{chunk-UPRN4FBY.js → chunk-46ZC5VNC.js} +4 -4
- package/dist/{chunk-4XEPZARK.js → chunk-4JZW6TIM.js} +4 -4
- package/dist/{chunk-CV7AG34M.js → chunk-4NNNF3I2.js} +9 -9
- package/dist/{chunk-O5JDQZGV.js → chunk-4PFXNHD3.js} +4 -4
- package/dist/{chunk-L3X7BO66.js → chunk-4UADNWV6.js} +27 -27
- package/dist/{chunk-SQJQVTHA.js → chunk-4W6SOOFS.js} +4 -4
- package/dist/{chunk-EVJ42E62.js → chunk-52HGZH7K.js} +2 -2
- package/dist/{chunk-LC5E7CVA.js → chunk-55RKBOO7.js} +8 -8
- package/dist/{chunk-FFWVFU6S.js → chunk-57KVMXSC.js} +2 -2
- package/dist/{chunk-DECSYLBP.js → chunk-5BPYSQXD.js} +10 -10
- package/dist/{chunk-BTWAGWLS.js → chunk-5GAHDYDT.js} +69 -69
- package/dist/{chunk-W7UFWXZ6.js → chunk-5MHUB47C.js} +4 -4
- package/dist/{chunk-JOZFVEBN.js → chunk-5QJ7BTBF.js} +7 -7
- package/dist/{chunk-OSQ6YGZW.js → chunk-5YHTSSIW.js} +12 -12
- package/dist/{chunk-HWOYJOKK.js → chunk-62T2ZPD5.js} +2 -2
- package/dist/{chunk-XGUBIE35.js → chunk-6BKV6G3M.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-NHJW5MC4.js → chunk-6HRRR5BF.js} +8 -8
- package/dist/{chunk-CAV3CWZN.js → chunk-6I7GCTD4.js} +13 -13
- package/dist/{chunk-H2D5ITLG.js → chunk-6MVWD5XT.js} +5 -5
- package/dist/{chunk-DW7QMMQM.js → chunk-6NAHUCXN.js} +2 -2
- package/dist/{chunk-4GUPD7CJ.js → chunk-6T3JRN4Z.js} +15 -15
- package/dist/{chunk-TVYKIJEQ.js → chunk-6UM4QPGH.js} +2 -2
- package/dist/{chunk-JTPP7WMH.js → chunk-6X2C66OI.js} +5 -5
- package/dist/{chunk-ZLY7M463.js → chunk-7B6RHDNQ.js} +2 -2
- package/dist/{chunk-6OMREP52.js → chunk-7WLEOZ3M.js} +8 -8
- package/dist/{chunk-D2VP4C5B.js → chunk-7Z7VIYIJ.js} +15 -15
- package/dist/{chunk-PBKG2OPJ.js → chunk-A5GX3CAE.js} +23 -23
- package/dist/{chunk-AX65L6QV.js → chunk-AJ4ZC4HY.js} +5 -5
- package/dist/{chunk-AQXWOQPQ.js → chunk-AOXSW6AQ.js} +5 -5
- package/dist/{chunk-ZWEVJPXC.js → chunk-AQ7KXETX.js} +7 -7
- package/dist/{chunk-NFZAMHSR.js → chunk-AQQDS5TA.js} +10 -10
- package/dist/{chunk-4OGDD2EM.js → chunk-B6AH43UQ.js} +9 -9
- package/dist/{chunk-J6YVN3W7.js → chunk-B6AXGNIL.js} +7 -7
- package/dist/{chunk-EFYA6GKK.js → chunk-BTJIU33Y.js} +9 -9
- package/dist/{chunk-3EG5MTQF.js → chunk-BUD2HCFN.js} +196 -196
- package/dist/{chunk-3EG5MTQF.js.map → chunk-BUD2HCFN.js.map} +1 -1
- package/dist/{chunk-LFMTPBET.js → chunk-BWZTWR2E.js} +6 -6
- package/dist/{chunk-I46F7LUI.js → chunk-C5XZMAHL.js} +2 -2
- package/dist/{chunk-RQAE6DI7.js → chunk-CGWVYEYA.js} +10 -10
- package/dist/{chunk-RAUWORZV.js → chunk-CGZQEZLS.js} +4 -4
- package/dist/{chunk-BVMP6N2Q.js → chunk-CIVFETJ6.js} +5 -5
- package/dist/{chunk-KMLELG4O.js → chunk-CQVXEZJT.js} +4 -4
- package/dist/{chunk-HE4WRNSL.js → chunk-CROKAGNV.js} +4 -4
- package/dist/{chunk-3MB7EFUH.js → chunk-CVC4RO7D.js} +4 -4
- package/dist/{chunk-UBSHJB6M.js → chunk-CYDC3R6H.js} +2 -2
- package/dist/{chunk-Z6DC4BYH.js → chunk-D3ZIXSAF.js} +34 -34
- package/dist/{chunk-DGQ36WCE.js → chunk-DALQXWAO.js} +1 -1
- package/dist/{chunk-BPCI4ZGR.js → chunk-DIDHQFRR.js} +14 -14
- package/dist/{chunk-QJRM2S5K.js → chunk-DPKQCFK2.js} +52 -52
- package/dist/{chunk-5EZUHCPU.js → chunk-DPYQ7UOQ.js} +1 -1
- package/dist/{chunk-QOD7BN5A.js → chunk-DRILEPI2.js} +2 -2
- package/dist/{chunk-UNOJ5PNN.js → chunk-E47FJJVS.js} +31 -31
- package/dist/{chunk-N4TJ7A7I.js → chunk-EDUUTFCL.js} +2 -2
- package/dist/{chunk-5K3VZUXC.js → chunk-EEVZ52EB.js} +8 -8
- package/dist/{chunk-ZWFLYN7T.js → chunk-EICYIASC.js} +25 -25
- package/dist/{chunk-QHF4B7R4.js → chunk-EIMK4OBO.js} +7 -7
- package/dist/{chunk-RFXCROFB.js → chunk-EU3RGXCU.js} +12 -12
- package/dist/{chunk-D32VVOBJ.js → chunk-F3LIUDXN.js} +126 -126
- package/dist/chunk-F3LIUDXN.js.map +1 -0
- package/dist/{chunk-CBSBNUGV.js → chunk-FTFUNEFJ.js} +5 -5
- package/dist/{chunk-IHLF7R6Q.js → chunk-FWFGK5WP.js} +15 -15
- package/dist/{chunk-L3GNEC6B.js → chunk-GCNOG3W3.js} +7 -7
- package/dist/{chunk-6WTDGMQN.js → chunk-GH5II7CP.js} +6 -6
- package/dist/{chunk-HUKGLWAY.js → chunk-GIHE7U3Y.js} +4 -4
- package/dist/{chunk-SRLYSVOM.js → chunk-GLYOEWRG.js} +3 -3
- package/dist/{chunk-Y6CNWBV3.js → chunk-GO5VIAA7.js} +4 -4
- package/dist/{chunk-PTQNZEHT.js → chunk-H26NFDN6.js} +9 -9
- package/dist/{chunk-PIPD74PT.js → chunk-H2GRSK4I.js} +25 -25
- package/dist/{chunk-QSG6FWOK.js → chunk-H3VYP5OR.js} +6 -6
- package/dist/{chunk-KW4OJ3RS.js → chunk-HBICYTNN.js} +6 -6
- package/dist/{chunk-QJ4YC4PM.js → chunk-HCNRWXWG.js} +5 -5
- package/dist/{chunk-PTSRBKQC.js → chunk-HFROJDFQ.js} +2 -2
- package/dist/{chunk-PYWLD4ZA.js → chunk-HFY7YQTM.js} +2 -2
- package/dist/{chunk-6VD5GNWW.js → chunk-HGDOBAHM.js} +1 -1
- package/dist/{chunk-YP4SNX4P.js → chunk-HHFFPE67.js} +4 -4
- package/dist/{chunk-PHNHJKEL.js → chunk-HP3PL5EY.js} +5 -5
- package/dist/{chunk-BM6DC3VN.js → chunk-HTV7GCZO.js} +13 -13
- package/dist/{chunk-B36N6XFA.js → chunk-I2PIDEO6.js} +7 -7
- package/dist/{chunk-IEUZ4ASX.js → chunk-I3RHHR27.js} +9 -9
- package/dist/{chunk-P5VPF627.js → chunk-IDSB7ZVK.js} +272 -272
- package/dist/{chunk-34XCK43K.js → chunk-IOFEA7OF.js} +2 -2
- package/dist/{chunk-AAD3YUI4.js → chunk-IPV2SYLD.js} +3 -3
- package/dist/{chunk-ZNIG3CPB.js → chunk-J65NMU3P.js} +9 -9
- package/dist/{chunk-GCURVP5U.js → chunk-JBNQEW5E.js} +15 -15
- package/dist/{chunk-B22JRYAD.js → chunk-JIBWPQYV.js} +3 -3
- package/dist/{chunk-QCJ6SNCP.js → chunk-JMLK5YFU.js} +10 -10
- package/dist/{chunk-36YTBVYF.js → chunk-JPGM5HMF.js} +2 -2
- package/dist/{chunk-QOFF4MGF.js → chunk-JQ6VLCBQ.js} +161 -161
- package/dist/{chunk-NBZLCMVR.js → chunk-JQW6MDUD.js} +7548 -7548
- package/dist/chunk-JQW6MDUD.js.map +1 -0
- package/dist/{chunk-24S44WBL.js → chunk-K2S32GRS.js} +2 -2
- package/dist/{chunk-LNXPQHZX.js → chunk-K6XPCJ4E.js} +4 -4
- package/dist/{chunk-KZYQNVXE.js → chunk-KEOHT7JK.js} +4 -4
- package/dist/{chunk-54NTSBQO.js → chunk-KF2TX3MG.js} +2 -2
- package/dist/{chunk-Q3KQQKH6.js → chunk-KIS4FWC5.js} +11 -11
- package/dist/{chunk-67BMBRTK.js → chunk-KKZKXQLQ.js} +4 -4
- package/dist/{chunk-PCSRHFRF.js → chunk-KTGKGHEA.js} +4 -4
- package/dist/{chunk-NUZNJSL5.js → chunk-KU77XHWB.js} +4 -4
- package/dist/{chunk-UD3ZEMKU.js → chunk-KWI66TJR.js} +25 -25
- package/dist/{chunk-VLDKWGHD.js → chunk-L6WVCO6D.js} +2 -2
- package/dist/{chunk-3X4HTUUR.js → chunk-LMXPFXUT.js} +18 -18
- package/dist/{chunk-J45WTHTL.js → chunk-LRJAXTLQ.js} +2 -2
- package/dist/{chunk-TGG3ODCS.js → chunk-MCPKUVMQ.js} +4 -4
- package/dist/{chunk-KYDLVMKA.js → chunk-MFLU3466.js} +4 -4
- package/dist/{chunk-U4EMW7RP.js → chunk-MIE5HOBX.js} +4 -4
- package/dist/{chunk-ZD67RM6G.js → chunk-MIUJ3EH5.js} +4 -4
- package/dist/{chunk-M5FX5KH5.js → chunk-MO3XJQN2.js} +6 -6
- package/dist/{chunk-U5Y3TTQT.js → chunk-MPKQAQPC.js} +3 -3
- package/dist/{chunk-7GSU3VWR.js → chunk-MS5ITMW6.js} +5 -5
- package/dist/{chunk-5ERDSF2C.js → chunk-MVYQDBE6.js} +4 -4
- package/dist/{chunk-72PGXQDN.js → chunk-N2U4BGS2.js} +2 -2
- package/dist/{chunk-XSR6J5LY.js → chunk-NCBDFV52.js} +8 -8
- package/dist/{chunk-5ORXRVXV.js → chunk-NLOJY45T.js} +5 -5
- package/dist/{chunk-MRZFJPM5.js → chunk-NMFECSTW.js} +10 -10
- package/dist/{chunk-4FFDNEQU.js → chunk-NPV7UTP5.js} +10 -10
- package/dist/{chunk-O6CIGYTK.js → chunk-NS2NMGJS.js} +46 -46
- package/dist/{chunk-UTFX46TK.js → chunk-O37MMAYZ.js} +4 -4
- package/dist/{chunk-6F34IWSA.js → chunk-O664PL2U.js} +11 -11
- package/dist/chunk-O664PL2U.js.map +1 -0
- package/dist/{chunk-JQYG7XBW.js → chunk-ODCM2LRA.js} +5 -5
- package/dist/{chunk-3NF7W5AQ.js → chunk-OITKZ5CF.js} +6 -6
- package/dist/{chunk-CU7M24ME.js → chunk-OMDHLJMQ.js} +52 -52
- package/dist/{chunk-UQQUMT5P.js → chunk-ON2HXTZS.js} +2 -2
- package/dist/{chunk-2NOT2LRQ.js → chunk-OPYDKW53.js} +2 -2
- package/dist/{chunk-ADFUTR45.js → chunk-ORYCDC57.js} +7 -7
- package/dist/{chunk-IYPH5D66.js → chunk-OT33BB76.js} +2 -2
- package/dist/{chunk-TU6FW6IJ.js → chunk-P57OLDBC.js} +4 -4
- package/dist/{chunk-W6JCGHKK.js → chunk-PCI7756C.js} +13 -13
- package/dist/{chunk-LFQI2C46.js → chunk-PPQJIVGM.js} +4 -4
- package/dist/{chunk-HLZY7VV6.js → chunk-PQPWLY47.js} +8 -8
- package/dist/{chunk-UFRXYZCJ.js → chunk-PYMQM65Y.js} +4 -4
- package/dist/{chunk-ETWYHIZ6.js → chunk-Q7KHUZ3T.js} +4 -4
- package/dist/{chunk-PGMXITPB.js → chunk-QA5UNVHD.js} +3 -3
- package/dist/{chunk-GXYS6BI3.js → chunk-QCDEBOHL.js} +8 -8
- package/dist/{chunk-VMJN6YQL.js → chunk-QD4T2J2I.js} +2 -2
- package/dist/{chunk-J4OOKDRV.js → chunk-QNOWKKZ4.js} +4 -4
- package/dist/{chunk-PJYPFGXS.js → chunk-QOXEMEDH.js} +10 -10
- package/dist/{chunk-DGS62JWP.js → chunk-QTOYKOH6.js} +7 -7
- package/dist/{chunk-AU2DT7O2.js → chunk-QVOTPOXK.js} +1 -1
- package/dist/{chunk-FFYTV4QA.js → chunk-R5ZK5A5I.js} +6 -6
- package/dist/{chunk-K7GGLL2U.js → chunk-RKO326MX.js} +8 -8
- package/dist/{chunk-6MSTIFAL.js → chunk-RWNC3IGU.js} +8 -8
- package/dist/{chunk-HQ6MV2NT.js → chunk-RYC732VO.js} +8 -8
- package/dist/{chunk-PCP5GF77.js → chunk-SLINGGRD.js} +7 -7
- package/dist/{chunk-C4NWV4PL.js → chunk-SQWQOUJG.js} +3 -3
- package/dist/{chunk-BY7AWWDB.js → chunk-SRDHDIRQ.js} +6 -6
- package/dist/{chunk-HUTQJY3F.js → chunk-SYYFA7W7.js} +4 -4
- package/dist/{chunk-YPIOAMHD.js → chunk-TIGCQYSI.js} +5 -5
- package/dist/{chunk-AQDHBR5S.js → chunk-U2ST5MFT.js} +27 -27
- package/dist/{chunk-B57G2C45.js → chunk-U35WJ3OB.js} +2 -2
- package/dist/{chunk-XDWW2DLJ.js → chunk-UQNOKKEE.js} +6 -6
- package/dist/{chunk-SVG5U7UN.js → chunk-V7UUHMDU.js} +4 -4
- package/dist/{chunk-3XHPCZ6N.js → chunk-VN2PJHNY.js} +24 -24
- package/dist/chunk-VN2PJHNY.js.map +1 -0
- package/dist/{chunk-YZM3Q3ZG.js → chunk-VPHVF6B2.js} +29 -29
- package/dist/{chunk-5Y33TVEB.js → chunk-VTMLWOFB.js} +18 -18
- package/dist/{chunk-7ZQVRVNI.js → chunk-W53LBFT6.js} +4 -4
- package/dist/{chunk-2CJE3CHW.js → chunk-WRHH3S6V.js} +1 -1
- package/dist/{chunk-CD3A4K3O.js → chunk-XCULPKCE.js} +137 -137
- package/dist/{chunk-54BKTCTE.js → chunk-XEWQU35M.js} +5 -5
- package/dist/{chunk-GH4VY3H5.js → chunk-XF2FMRK6.js} +9 -9
- package/dist/{chunk-KDFYHNSM.js → chunk-XFMQBHDV.js} +68 -68
- package/dist/chunk-XFMQBHDV.js.map +1 -0
- package/dist/{chunk-R6WQLIFX.js → chunk-XHF2XNU5.js} +1 -1
- package/dist/{chunk-TCA5SHE6.js → chunk-XHTJ4U2I.js} +8 -8
- package/dist/{chunk-Q5AQJQXU.js → chunk-XKBUIJCB.js} +4 -4
- package/dist/{chunk-67JCL67N.js → chunk-XQ3OEFMZ.js} +3 -3
- package/dist/{chunk-GJFTPSGN.js → chunk-XQODHW6K.js} +8 -8
- package/dist/{chunk-HKIU3FUV.js → chunk-Y7LFTLGQ.js} +8 -8
- package/dist/{chunk-R6OBJ7LF.js → chunk-YAVW5OJ5.js} +4 -4
- package/dist/{chunk-ZAGLLXX5.js → chunk-YD3LROO2.js} +6 -6
- package/dist/{chunk-RPZXGD5W.js → chunk-YIYH5WKY.js} +4 -4
- package/dist/{chunk-VWJ7GI5O.js → chunk-YMWT5UZA.js} +12 -12
- package/dist/{chunk-CYXDT4CX.js → chunk-YQ25GY4V.js} +8 -8
- package/dist/{chunk-M47MKLW2.js → chunk-YTPQ4XZD.js} +3 -3
- package/dist/{chunk-F7NV3EL5.js → chunk-YW4CA4GO.js} +5 -5
- package/dist/{chunk-TXSZR2SB.js → chunk-YXP62OER.js} +2 -2
- package/dist/{chunk-FUJ6DWRZ.js → chunk-YYUIJQCD.js} +9 -9
- package/dist/{chunk-2SH6CLOR.js → chunk-Z26KIZF7.js} +7 -7
- package/dist/{chunk-SKAVBZ3M.js → chunk-ZD7QRVDC.js} +2 -2
- package/dist/{chunk-KDHWX7XH.js → chunk-ZHRGOYEC.js} +9 -9
- package/dist/{chunk-A2QOUEU3.js → chunk-ZIKLGN6B.js} +5 -5
- package/dist/{chunk-5I6CWDA6.js → chunk-ZNQNNKOD.js} +13 -13
- package/dist/{chunk-DJ4X4U4A.js → chunk-ZQX33EV5.js} +15 -15
- package/dist/{chunk-WE3COHRR.js → chunk-ZXASGAEP.js} +8 -8
- package/dist/composer.js +34 -34
- package/dist/{computer-viewer-ZISZUM4L.js → computer-viewer-PIYSJ2NG.js} +4 -4
- package/dist/connect.js +27 -27
- package/dist/{connection-step-up-LLRWITKR.js → connection-step-up-I4FIKSTA.js} +29 -29
- package/dist/desktop-dictation.js +21 -21
- package/dist/{embedded-new-voice-UWSSA7AB.js → embedded-new-voice-6G7K4GHG.js} +12 -12
- package/dist/{embedded-voice-T34K465A.js → embedded-voice-YKGPFUHJ.js} +12 -12
- package/dist/in-chat-connect-model.js +4 -4
- package/dist/index.js +292 -292
- 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-2CTRKSDJ.js → model-policy-picker-menu-G753RA3K.js} +8 -8
- package/dist/{payment-page-card-OOOFGIMH.js → payment-page-card-JINQVM53.js} +5 -5
- package/dist/{platform-activity-row-EZYTZPYR.js → platform-activity-row-5TC3EFFS.js} +4 -4
- package/dist/{queue-surface-implementation-HDZ42LN7.js → queue-surface-implementation-I7LCCROK.js} +7 -7
- package/dist/realtime.js +15 -15
- package/dist/{sandbox-files-6JY7WVMO.js → sandbox-files-YEX3NTYN.js} +12 -12
- package/dist/session-app.js +371 -371
- package/dist/{session-connect-cards-676HULDD.js → session-connect-cards-Y7IZXBG3.js} +8 -8
- package/dist/session-ui.js +86 -86
- package/dist/session.js +41 -41
- package/dist/sites.js +2 -2
- package/dist/terminal.js +1 -1
- package/dist/timeline-model.js +58 -58
- package/dist/ui/access-list.js +22 -22
- package/dist/ui/cadence-picker.js +2 -2
- package/dist/ui/choice-cards.js +2 -2
- package/dist/ui/detail-page.js +4 -4
- package/dist/ui/detail-sheet.js +4 -4
- package/dist/ui/diff-view.js +3 -3
- package/dist/ui/disclosure.js +5 -5
- package/dist/ui/flush-form-page.js +6 -6
- package/dist/ui/form-dialog.js +5 -5
- package/dist/ui/list-row.js +5 -5
- package/dist/ui/load-failure.js +3 -3
- package/dist/ui/revision-history.js +10 -10
- package/dist/ui/role-select.js +9 -9
- package/dist/ui/select-menu.js +2 -2
- package/dist/ui/settings-nav.js +6 -6
- package/dist/ui/sheet.js +2 -2
- package/dist/usage.js +2 -2
- package/dist/workbench.js +10 -10
- package/package.json +6 -5
- package/dist/chunk-3XHPCZ6N.js.map +0 -1
- package/dist/chunk-6F34IWSA.js.map +0 -1
- package/dist/chunk-D32VVOBJ.js.map +0 -1
- package/dist/chunk-KDFYHNSM.js.map +0 -1
- package/dist/chunk-KZTBTQG2.js.map +0 -1
- package/dist/chunk-NBZLCMVR.js.map +0 -1
- /package/dist/{browser-viewer-J6O65JXH.js.map → browser-viewer-DWLNDPHZ.js.map} +0 -0
- /package/dist/{chat-interactive-block-R5JEJYMR.js.map → chat-interactive-block-KUDPTS4Z.js.map} +0 -0
- /package/dist/{chunk-YPM3T3UM.js.map → chunk-2E25T36N.js.map} +0 -0
- /package/dist/{chunk-VXOB3OM6.js.map → chunk-2MN4ECC6.js.map} +0 -0
- /package/dist/{chunk-NY5DX43C.js.map → chunk-2SM3NPVF.js.map} +0 -0
- /package/dist/{chunk-UJDTQJ34.js.map → chunk-2Y4LDCRD.js.map} +0 -0
- /package/dist/{chunk-UVZ5FMM7.js.map → chunk-3AIXQ3BF.js.map} +0 -0
- /package/dist/{chunk-4PGKQ7WM.js.map → chunk-3BI43BIS.js.map} +0 -0
- /package/dist/{chunk-KQY4P4EO.js.map → chunk-3BYVKJ7U.js.map} +0 -0
- /package/dist/{chunk-ERKXCRO5.js.map → chunk-3IHXVJAT.js.map} +0 -0
- /package/dist/{chunk-J3F65ZVP.js.map → chunk-3VS6PNSI.js.map} +0 -0
- /package/dist/{chunk-UPRN4FBY.js.map → chunk-46ZC5VNC.js.map} +0 -0
- /package/dist/{chunk-4XEPZARK.js.map → chunk-4JZW6TIM.js.map} +0 -0
- /package/dist/{chunk-CV7AG34M.js.map → chunk-4NNNF3I2.js.map} +0 -0
- /package/dist/{chunk-O5JDQZGV.js.map → chunk-4PFXNHD3.js.map} +0 -0
- /package/dist/{chunk-L3X7BO66.js.map → chunk-4UADNWV6.js.map} +0 -0
- /package/dist/{chunk-SQJQVTHA.js.map → chunk-4W6SOOFS.js.map} +0 -0
- /package/dist/{chunk-EVJ42E62.js.map → chunk-52HGZH7K.js.map} +0 -0
- /package/dist/{chunk-LC5E7CVA.js.map → chunk-55RKBOO7.js.map} +0 -0
- /package/dist/{chunk-FFWVFU6S.js.map → chunk-57KVMXSC.js.map} +0 -0
- /package/dist/{chunk-DECSYLBP.js.map → chunk-5BPYSQXD.js.map} +0 -0
- /package/dist/{chunk-BTWAGWLS.js.map → chunk-5GAHDYDT.js.map} +0 -0
- /package/dist/{chunk-W7UFWXZ6.js.map → chunk-5MHUB47C.js.map} +0 -0
- /package/dist/{chunk-JOZFVEBN.js.map → chunk-5QJ7BTBF.js.map} +0 -0
- /package/dist/{chunk-OSQ6YGZW.js.map → chunk-5YHTSSIW.js.map} +0 -0
- /package/dist/{chunk-HWOYJOKK.js.map → chunk-62T2ZPD5.js.map} +0 -0
- /package/dist/{chunk-XGUBIE35.js.map → chunk-6BKV6G3M.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-NHJW5MC4.js.map → chunk-6HRRR5BF.js.map} +0 -0
- /package/dist/{chunk-CAV3CWZN.js.map → chunk-6I7GCTD4.js.map} +0 -0
- /package/dist/{chunk-H2D5ITLG.js.map → chunk-6MVWD5XT.js.map} +0 -0
- /package/dist/{chunk-DW7QMMQM.js.map → chunk-6NAHUCXN.js.map} +0 -0
- /package/dist/{chunk-4GUPD7CJ.js.map → chunk-6T3JRN4Z.js.map} +0 -0
- /package/dist/{chunk-TVYKIJEQ.js.map → chunk-6UM4QPGH.js.map} +0 -0
- /package/dist/{chunk-JTPP7WMH.js.map → chunk-6X2C66OI.js.map} +0 -0
- /package/dist/{chunk-ZLY7M463.js.map → chunk-7B6RHDNQ.js.map} +0 -0
- /package/dist/{chunk-6OMREP52.js.map → chunk-7WLEOZ3M.js.map} +0 -0
- /package/dist/{chunk-D2VP4C5B.js.map → chunk-7Z7VIYIJ.js.map} +0 -0
- /package/dist/{chunk-PBKG2OPJ.js.map → chunk-A5GX3CAE.js.map} +0 -0
- /package/dist/{chunk-AX65L6QV.js.map → chunk-AJ4ZC4HY.js.map} +0 -0
- /package/dist/{chunk-AQXWOQPQ.js.map → chunk-AOXSW6AQ.js.map} +0 -0
- /package/dist/{chunk-ZWEVJPXC.js.map → chunk-AQ7KXETX.js.map} +0 -0
- /package/dist/{chunk-NFZAMHSR.js.map → chunk-AQQDS5TA.js.map} +0 -0
- /package/dist/{chunk-4OGDD2EM.js.map → chunk-B6AH43UQ.js.map} +0 -0
- /package/dist/{chunk-J6YVN3W7.js.map → chunk-B6AXGNIL.js.map} +0 -0
- /package/dist/{chunk-EFYA6GKK.js.map → chunk-BTJIU33Y.js.map} +0 -0
- /package/dist/{chunk-LFMTPBET.js.map → chunk-BWZTWR2E.js.map} +0 -0
- /package/dist/{chunk-I46F7LUI.js.map → chunk-C5XZMAHL.js.map} +0 -0
- /package/dist/{chunk-RQAE6DI7.js.map → chunk-CGWVYEYA.js.map} +0 -0
- /package/dist/{chunk-RAUWORZV.js.map → chunk-CGZQEZLS.js.map} +0 -0
- /package/dist/{chunk-BVMP6N2Q.js.map → chunk-CIVFETJ6.js.map} +0 -0
- /package/dist/{chunk-KMLELG4O.js.map → chunk-CQVXEZJT.js.map} +0 -0
- /package/dist/{chunk-HE4WRNSL.js.map → chunk-CROKAGNV.js.map} +0 -0
- /package/dist/{chunk-3MB7EFUH.js.map → chunk-CVC4RO7D.js.map} +0 -0
- /package/dist/{chunk-UBSHJB6M.js.map → chunk-CYDC3R6H.js.map} +0 -0
- /package/dist/{chunk-Z6DC4BYH.js.map → chunk-D3ZIXSAF.js.map} +0 -0
- /package/dist/{chunk-DGQ36WCE.js.map → chunk-DALQXWAO.js.map} +0 -0
- /package/dist/{chunk-BPCI4ZGR.js.map → chunk-DIDHQFRR.js.map} +0 -0
- /package/dist/{chunk-QJRM2S5K.js.map → chunk-DPKQCFK2.js.map} +0 -0
- /package/dist/{chunk-5EZUHCPU.js.map → chunk-DPYQ7UOQ.js.map} +0 -0
- /package/dist/{chunk-QOD7BN5A.js.map → chunk-DRILEPI2.js.map} +0 -0
- /package/dist/{chunk-UNOJ5PNN.js.map → chunk-E47FJJVS.js.map} +0 -0
- /package/dist/{chunk-N4TJ7A7I.js.map → chunk-EDUUTFCL.js.map} +0 -0
- /package/dist/{chunk-5K3VZUXC.js.map → chunk-EEVZ52EB.js.map} +0 -0
- /package/dist/{chunk-ZWFLYN7T.js.map → chunk-EICYIASC.js.map} +0 -0
- /package/dist/{chunk-QHF4B7R4.js.map → chunk-EIMK4OBO.js.map} +0 -0
- /package/dist/{chunk-RFXCROFB.js.map → chunk-EU3RGXCU.js.map} +0 -0
- /package/dist/{chunk-CBSBNUGV.js.map → chunk-FTFUNEFJ.js.map} +0 -0
- /package/dist/{chunk-IHLF7R6Q.js.map → chunk-FWFGK5WP.js.map} +0 -0
- /package/dist/{chunk-L3GNEC6B.js.map → chunk-GCNOG3W3.js.map} +0 -0
- /package/dist/{chunk-6WTDGMQN.js.map → chunk-GH5II7CP.js.map} +0 -0
- /package/dist/{chunk-HUKGLWAY.js.map → chunk-GIHE7U3Y.js.map} +0 -0
- /package/dist/{chunk-SRLYSVOM.js.map → chunk-GLYOEWRG.js.map} +0 -0
- /package/dist/{chunk-Y6CNWBV3.js.map → chunk-GO5VIAA7.js.map} +0 -0
- /package/dist/{chunk-PTQNZEHT.js.map → chunk-H26NFDN6.js.map} +0 -0
- /package/dist/{chunk-PIPD74PT.js.map → chunk-H2GRSK4I.js.map} +0 -0
- /package/dist/{chunk-QSG6FWOK.js.map → chunk-H3VYP5OR.js.map} +0 -0
- /package/dist/{chunk-KW4OJ3RS.js.map → chunk-HBICYTNN.js.map} +0 -0
- /package/dist/{chunk-QJ4YC4PM.js.map → chunk-HCNRWXWG.js.map} +0 -0
- /package/dist/{chunk-PTSRBKQC.js.map → chunk-HFROJDFQ.js.map} +0 -0
- /package/dist/{chunk-PYWLD4ZA.js.map → chunk-HFY7YQTM.js.map} +0 -0
- /package/dist/{chunk-6VD5GNWW.js.map → chunk-HGDOBAHM.js.map} +0 -0
- /package/dist/{chunk-YP4SNX4P.js.map → chunk-HHFFPE67.js.map} +0 -0
- /package/dist/{chunk-PHNHJKEL.js.map → chunk-HP3PL5EY.js.map} +0 -0
- /package/dist/{chunk-BM6DC3VN.js.map → chunk-HTV7GCZO.js.map} +0 -0
- /package/dist/{chunk-B36N6XFA.js.map → chunk-I2PIDEO6.js.map} +0 -0
- /package/dist/{chunk-IEUZ4ASX.js.map → chunk-I3RHHR27.js.map} +0 -0
- /package/dist/{chunk-P5VPF627.js.map → chunk-IDSB7ZVK.js.map} +0 -0
- /package/dist/{chunk-34XCK43K.js.map → chunk-IOFEA7OF.js.map} +0 -0
- /package/dist/{chunk-AAD3YUI4.js.map → chunk-IPV2SYLD.js.map} +0 -0
- /package/dist/{chunk-ZNIG3CPB.js.map → chunk-J65NMU3P.js.map} +0 -0
- /package/dist/{chunk-GCURVP5U.js.map → chunk-JBNQEW5E.js.map} +0 -0
- /package/dist/{chunk-B22JRYAD.js.map → chunk-JIBWPQYV.js.map} +0 -0
- /package/dist/{chunk-QCJ6SNCP.js.map → chunk-JMLK5YFU.js.map} +0 -0
- /package/dist/{chunk-36YTBVYF.js.map → chunk-JPGM5HMF.js.map} +0 -0
- /package/dist/{chunk-QOFF4MGF.js.map → chunk-JQ6VLCBQ.js.map} +0 -0
- /package/dist/{chunk-24S44WBL.js.map → chunk-K2S32GRS.js.map} +0 -0
- /package/dist/{chunk-LNXPQHZX.js.map → chunk-K6XPCJ4E.js.map} +0 -0
- /package/dist/{chunk-KZYQNVXE.js.map → chunk-KEOHT7JK.js.map} +0 -0
- /package/dist/{chunk-54NTSBQO.js.map → chunk-KF2TX3MG.js.map} +0 -0
- /package/dist/{chunk-Q3KQQKH6.js.map → chunk-KIS4FWC5.js.map} +0 -0
- /package/dist/{chunk-67BMBRTK.js.map → chunk-KKZKXQLQ.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-UD3ZEMKU.js.map → chunk-KWI66TJR.js.map} +0 -0
- /package/dist/{chunk-VLDKWGHD.js.map → chunk-L6WVCO6D.js.map} +0 -0
- /package/dist/{chunk-3X4HTUUR.js.map → chunk-LMXPFXUT.js.map} +0 -0
- /package/dist/{chunk-J45WTHTL.js.map → chunk-LRJAXTLQ.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-U4EMW7RP.js.map → chunk-MIE5HOBX.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-U5Y3TTQT.js.map → chunk-MPKQAQPC.js.map} +0 -0
- /package/dist/{chunk-7GSU3VWR.js.map → chunk-MS5ITMW6.js.map} +0 -0
- /package/dist/{chunk-5ERDSF2C.js.map → chunk-MVYQDBE6.js.map} +0 -0
- /package/dist/{chunk-72PGXQDN.js.map → chunk-N2U4BGS2.js.map} +0 -0
- /package/dist/{chunk-XSR6J5LY.js.map → chunk-NCBDFV52.js.map} +0 -0
- /package/dist/{chunk-5ORXRVXV.js.map → chunk-NLOJY45T.js.map} +0 -0
- /package/dist/{chunk-MRZFJPM5.js.map → chunk-NMFECSTW.js.map} +0 -0
- /package/dist/{chunk-4FFDNEQU.js.map → chunk-NPV7UTP5.js.map} +0 -0
- /package/dist/{chunk-O6CIGYTK.js.map → chunk-NS2NMGJS.js.map} +0 -0
- /package/dist/{chunk-UTFX46TK.js.map → chunk-O37MMAYZ.js.map} +0 -0
- /package/dist/{chunk-JQYG7XBW.js.map → chunk-ODCM2LRA.js.map} +0 -0
- /package/dist/{chunk-3NF7W5AQ.js.map → chunk-OITKZ5CF.js.map} +0 -0
- /package/dist/{chunk-CU7M24ME.js.map → chunk-OMDHLJMQ.js.map} +0 -0
- /package/dist/{chunk-UQQUMT5P.js.map → chunk-ON2HXTZS.js.map} +0 -0
- /package/dist/{chunk-2NOT2LRQ.js.map → chunk-OPYDKW53.js.map} +0 -0
- /package/dist/{chunk-ADFUTR45.js.map → chunk-ORYCDC57.js.map} +0 -0
- /package/dist/{chunk-IYPH5D66.js.map → chunk-OT33BB76.js.map} +0 -0
- /package/dist/{chunk-TU6FW6IJ.js.map → chunk-P57OLDBC.js.map} +0 -0
- /package/dist/{chunk-W6JCGHKK.js.map → chunk-PCI7756C.js.map} +0 -0
- /package/dist/{chunk-LFQI2C46.js.map → chunk-PPQJIVGM.js.map} +0 -0
- /package/dist/{chunk-HLZY7VV6.js.map → chunk-PQPWLY47.js.map} +0 -0
- /package/dist/{chunk-UFRXYZCJ.js.map → chunk-PYMQM65Y.js.map} +0 -0
- /package/dist/{chunk-ETWYHIZ6.js.map → chunk-Q7KHUZ3T.js.map} +0 -0
- /package/dist/{chunk-PGMXITPB.js.map → chunk-QA5UNVHD.js.map} +0 -0
- /package/dist/{chunk-GXYS6BI3.js.map → chunk-QCDEBOHL.js.map} +0 -0
- /package/dist/{chunk-VMJN6YQL.js.map → chunk-QD4T2J2I.js.map} +0 -0
- /package/dist/{chunk-J4OOKDRV.js.map → chunk-QNOWKKZ4.js.map} +0 -0
- /package/dist/{chunk-PJYPFGXS.js.map → chunk-QOXEMEDH.js.map} +0 -0
- /package/dist/{chunk-DGS62JWP.js.map → chunk-QTOYKOH6.js.map} +0 -0
- /package/dist/{chunk-AU2DT7O2.js.map → chunk-QVOTPOXK.js.map} +0 -0
- /package/dist/{chunk-FFYTV4QA.js.map → chunk-R5ZK5A5I.js.map} +0 -0
- /package/dist/{chunk-K7GGLL2U.js.map → chunk-RKO326MX.js.map} +0 -0
- /package/dist/{chunk-6MSTIFAL.js.map → chunk-RWNC3IGU.js.map} +0 -0
- /package/dist/{chunk-HQ6MV2NT.js.map → chunk-RYC732VO.js.map} +0 -0
- /package/dist/{chunk-PCP5GF77.js.map → chunk-SLINGGRD.js.map} +0 -0
- /package/dist/{chunk-C4NWV4PL.js.map → chunk-SQWQOUJG.js.map} +0 -0
- /package/dist/{chunk-BY7AWWDB.js.map → chunk-SRDHDIRQ.js.map} +0 -0
- /package/dist/{chunk-HUTQJY3F.js.map → chunk-SYYFA7W7.js.map} +0 -0
- /package/dist/{chunk-YPIOAMHD.js.map → chunk-TIGCQYSI.js.map} +0 -0
- /package/dist/{chunk-AQDHBR5S.js.map → chunk-U2ST5MFT.js.map} +0 -0
- /package/dist/{chunk-B57G2C45.js.map → chunk-U35WJ3OB.js.map} +0 -0
- /package/dist/{chunk-XDWW2DLJ.js.map → chunk-UQNOKKEE.js.map} +0 -0
- /package/dist/{chunk-SVG5U7UN.js.map → chunk-V7UUHMDU.js.map} +0 -0
- /package/dist/{chunk-YZM3Q3ZG.js.map → chunk-VPHVF6B2.js.map} +0 -0
- /package/dist/{chunk-5Y33TVEB.js.map → chunk-VTMLWOFB.js.map} +0 -0
- /package/dist/{chunk-7ZQVRVNI.js.map → chunk-W53LBFT6.js.map} +0 -0
- /package/dist/{chunk-2CJE3CHW.js.map → chunk-WRHH3S6V.js.map} +0 -0
- /package/dist/{chunk-CD3A4K3O.js.map → chunk-XCULPKCE.js.map} +0 -0
- /package/dist/{chunk-54BKTCTE.js.map → chunk-XEWQU35M.js.map} +0 -0
- /package/dist/{chunk-GH4VY3H5.js.map → chunk-XF2FMRK6.js.map} +0 -0
- /package/dist/{chunk-R6WQLIFX.js.map → chunk-XHF2XNU5.js.map} +0 -0
- /package/dist/{chunk-TCA5SHE6.js.map → chunk-XHTJ4U2I.js.map} +0 -0
- /package/dist/{chunk-Q5AQJQXU.js.map → chunk-XKBUIJCB.js.map} +0 -0
- /package/dist/{chunk-67JCL67N.js.map → chunk-XQ3OEFMZ.js.map} +0 -0
- /package/dist/{chunk-GJFTPSGN.js.map → chunk-XQODHW6K.js.map} +0 -0
- /package/dist/{chunk-HKIU3FUV.js.map → chunk-Y7LFTLGQ.js.map} +0 -0
- /package/dist/{chunk-R6OBJ7LF.js.map → chunk-YAVW5OJ5.js.map} +0 -0
- /package/dist/{chunk-ZAGLLXX5.js.map → chunk-YD3LROO2.js.map} +0 -0
- /package/dist/{chunk-RPZXGD5W.js.map → chunk-YIYH5WKY.js.map} +0 -0
- /package/dist/{chunk-VWJ7GI5O.js.map → chunk-YMWT5UZA.js.map} +0 -0
- /package/dist/{chunk-CYXDT4CX.js.map → chunk-YQ25GY4V.js.map} +0 -0
- /package/dist/{chunk-M47MKLW2.js.map → chunk-YTPQ4XZD.js.map} +0 -0
- /package/dist/{chunk-F7NV3EL5.js.map → chunk-YW4CA4GO.js.map} +0 -0
- /package/dist/{chunk-TXSZR2SB.js.map → chunk-YXP62OER.js.map} +0 -0
- /package/dist/{chunk-FUJ6DWRZ.js.map → chunk-YYUIJQCD.js.map} +0 -0
- /package/dist/{chunk-2SH6CLOR.js.map → chunk-Z26KIZF7.js.map} +0 -0
- /package/dist/{chunk-SKAVBZ3M.js.map → chunk-ZD7QRVDC.js.map} +0 -0
- /package/dist/{chunk-KDHWX7XH.js.map → chunk-ZHRGOYEC.js.map} +0 -0
- /package/dist/{chunk-A2QOUEU3.js.map → chunk-ZIKLGN6B.js.map} +0 -0
- /package/dist/{chunk-5I6CWDA6.js.map → chunk-ZNQNNKOD.js.map} +0 -0
- /package/dist/{chunk-DJ4X4U4A.js.map → chunk-ZQX33EV5.js.map} +0 -0
- /package/dist/{chunk-WE3COHRR.js.map → chunk-ZXASGAEP.js.map} +0 -0
- /package/dist/{computer-viewer-ZISZUM4L.js.map → computer-viewer-PIYSJ2NG.js.map} +0 -0
- /package/dist/{connection-step-up-LLRWITKR.js.map → connection-step-up-I4FIKSTA.js.map} +0 -0
- /package/dist/{embedded-new-voice-UWSSA7AB.js.map → embedded-new-voice-6G7K4GHG.js.map} +0 -0
- /package/dist/{embedded-voice-T34K465A.js.map → embedded-voice-YKGPFUHJ.js.map} +0 -0
- /package/dist/{model-policy-picker-menu-2CTRKSDJ.js.map → model-policy-picker-menu-G753RA3K.js.map} +0 -0
- /package/dist/{payment-page-card-OOOFGIMH.js.map → payment-page-card-JINQVM53.js.map} +0 -0
- /package/dist/{platform-activity-row-EZYTZPYR.js.map → platform-activity-row-5TC3EFFS.js.map} +0 -0
- /package/dist/{queue-surface-implementation-HDZ42LN7.js.map → queue-surface-implementation-I7LCCROK.js.map} +0 -0
- /package/dist/{sandbox-files-6JY7WVMO.js.map → sandbox-files-YEX3NTYN.js.map} +0 -0
- /package/dist/{session-connect-cards-676HULDD.js.map → session-connect-cards-Y7IZXBG3.js.map} +0 -0
|
@@ -6,6 +6,10 @@ import {
|
|
|
6
6
|
deniesRetainedView,
|
|
7
7
|
useRetainedSessionView
|
|
8
8
|
} from "./chunk-6CKSMBLT.js";
|
|
9
|
+
import {
|
|
10
|
+
forgetSessionHumanInputDrafts,
|
|
11
|
+
pruneHumanInputDrafts
|
|
12
|
+
} from "./chunk-UYWVK7JQ.js";
|
|
9
13
|
import {
|
|
10
14
|
uploadScopeForSession,
|
|
11
15
|
useFileAttachments
|
|
@@ -20,43 +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
|
-
import {
|
|
46
|
-
useClientConfigFlags
|
|
47
|
-
} from "./chunk-XESA3B7W.js";
|
|
48
|
-
import {
|
|
49
|
-
joinClientConfigRead
|
|
50
|
-
} from "./chunk-IGVL3ELX.js";
|
|
51
45
|
import {
|
|
52
46
|
FILE_ONLY_MESSAGE_TEXT,
|
|
53
47
|
notifyObserver,
|
|
54
48
|
useComposer
|
|
55
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-I3RHHR27.js";
|
|
56
50
|
import {
|
|
57
51
|
modelLevelChoice,
|
|
58
52
|
modelLevelsView
|
|
59
53
|
} from "./chunk-X6UMGG4T.js";
|
|
54
|
+
import {
|
|
55
|
+
joinClientConfigRead
|
|
56
|
+
} from "./chunk-IGVL3ELX.js";
|
|
57
|
+
import {
|
|
58
|
+
admissionRecheckControl
|
|
59
|
+
} from "./chunk-MRNAHGBL.js";
|
|
60
60
|
import {
|
|
61
61
|
DEFAULT_TRANSIENT_READ_RETRY,
|
|
62
62
|
projectionReadThrough,
|
|
@@ -70,6 +70,13 @@ import {
|
|
|
70
70
|
import {
|
|
71
71
|
normalizeError
|
|
72
72
|
} from "./chunk-CM7LVUKC.js";
|
|
73
|
+
import {
|
|
74
|
+
coerceReasoningEffortForModel,
|
|
75
|
+
defaultEffortForModel,
|
|
76
|
+
projectPickerRows,
|
|
77
|
+
runnableLatencyModesForModel,
|
|
78
|
+
sortPickerRows
|
|
79
|
+
} from "./chunk-4VEIBNC2.js";
|
|
73
80
|
import {
|
|
74
81
|
useEmbeddedGoal,
|
|
75
82
|
useEmbeddedHumanInputSession,
|
|
@@ -78,88 +85,10 @@ import {
|
|
|
78
85
|
useOpenGeni,
|
|
79
86
|
useOpenGeniClient
|
|
80
87
|
} from "./chunk-BVUAHAQX.js";
|
|
81
|
-
import {
|
|
82
|
-
coerceReasoningEffortForModel,
|
|
83
|
-
defaultEffortForModel,
|
|
84
|
-
projectPickerRows,
|
|
85
|
-
runnableLatencyModesForModel,
|
|
86
|
-
sortPickerRows
|
|
87
|
-
} from "./chunk-4VEIBNC2.js";
|
|
88
88
|
import {
|
|
89
89
|
useOpenGeniText
|
|
90
90
|
} from "./chunk-4ZRGFCSP.js";
|
|
91
91
|
|
|
92
|
-
// src/conversation-timeline.ts
|
|
93
|
-
function conversationTimeline(items, queue, composer) {
|
|
94
|
-
const queued = new Set(
|
|
95
|
-
queue.queue.filter((turn) => turn.metadata.delivery !== "steer").map((turn) => turn.triggerEventId)
|
|
96
|
-
);
|
|
97
|
-
const pending = composer.optimisticMessages ?? [];
|
|
98
|
-
const pendingQueue = new Set(
|
|
99
|
-
pending.filter(
|
|
100
|
-
(message) => message.destination === "queue" && !(message.turnId && message.appliedQueueVersion != null && queue.snapshot && queue.snapshot.version >= message.appliedQueueVersion && !queue.queue.some((turn) => turn.id === message.turnId))
|
|
101
|
-
).map((message) => `user-message:${message.clientEventId}`)
|
|
102
|
-
);
|
|
103
|
-
const visible = items.filter(
|
|
104
|
-
(item) => item.kind !== "user-message" || !queued.has(item.id) && !pendingQueue.has(item.reconciliationKey ?? "")
|
|
105
|
-
);
|
|
106
|
-
const keys = new Set(
|
|
107
|
-
visible.flatMap((item) => item.kind === "user-message" ? [item.reconciliationKey] : [])
|
|
108
|
-
);
|
|
109
|
-
const optimistic = pending.filter(
|
|
110
|
-
(message) => (message.destination === "chat" || message.state === "failed") && !keys.has(`user-message:${message.clientEventId}`) && !queue.queue.some((turn) => turn.id === message.turnId)
|
|
111
|
-
).map((message) => ({
|
|
112
|
-
kind: "user-message",
|
|
113
|
-
id: `optimistic:${message.clientEventId}`,
|
|
114
|
-
reconciliationKey: `user-message:${message.clientEventId}`,
|
|
115
|
-
text: message.text,
|
|
116
|
-
annotations: message.annotations.map((annotation, ordinal) => ({ ...annotation, ordinal })),
|
|
117
|
-
resources: message.resources,
|
|
118
|
-
tools: [],
|
|
119
|
-
occurredAt: message.occurredAt,
|
|
120
|
-
delivery: {
|
|
121
|
-
state: message.state,
|
|
122
|
-
...message.error ? { error: message.error } : {},
|
|
123
|
-
...message.state === "failed" ? {
|
|
124
|
-
...message.retryable !== false && composer.retryOptimisticMessage ? { onRetry: () => composer.retryOptimisticMessage?.(message.clientEventId) } : {},
|
|
125
|
-
...message.retryable === false && composer.restoreOptimisticMessage ? { onEdit: () => composer.restoreOptimisticMessage?.(message.clientEventId) } : {},
|
|
126
|
-
onRemove: () => composer.removeOptimisticMessage?.(message.clientEventId)
|
|
127
|
-
} : {}
|
|
128
|
-
}
|
|
129
|
-
}));
|
|
130
|
-
const failed = optimistic.filter((message) => message.delivery?.state === "failed");
|
|
131
|
-
const unsent = optimistic.filter((message) => message.delivery?.state !== "failed");
|
|
132
|
-
const ids = new Set(visible.map((item) => item.id));
|
|
133
|
-
const steers = (queue.acceptedSteers ?? []).filter((steer) => !ids.has(steer.triggerEventId)).map((steer) => ({
|
|
134
|
-
kind: "user-message",
|
|
135
|
-
id: steer.triggerEventId,
|
|
136
|
-
text: steer.text,
|
|
137
|
-
annotations: steer.annotations,
|
|
138
|
-
resources: steer.resources,
|
|
139
|
-
tools: steer.tools,
|
|
140
|
-
occurredAt: steer.occurredAt,
|
|
141
|
-
delivery: { state: steer.state }
|
|
142
|
-
}));
|
|
143
|
-
return [...placeFailedSends(visible, failed), ...unsent, ...steers];
|
|
144
|
-
}
|
|
145
|
-
function placeFailedSends(items, failed) {
|
|
146
|
-
if (failed.length === 0) return items;
|
|
147
|
-
const before = /* @__PURE__ */ new Map();
|
|
148
|
-
const last = [];
|
|
149
|
-
for (const message of failed) {
|
|
150
|
-
const sentAt = Date.parse(message.occurredAt);
|
|
151
|
-
const newer = items.findIndex(
|
|
152
|
-
(item) => item.kind === "user-message" && Date.parse(item.occurredAt) > sentAt
|
|
153
|
-
);
|
|
154
|
-
if (newer === -1) {
|
|
155
|
-
last.push(message);
|
|
156
|
-
} else {
|
|
157
|
-
before.set(newer, [...before.get(newer) ?? [], message]);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
return [...items.flatMap((item, index) => [...before.get(index) ?? [], item]), ...last];
|
|
161
|
-
}
|
|
162
|
-
|
|
163
92
|
// src/hooks/use-session.ts
|
|
164
93
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
165
94
|
|
|
@@ -320,882 +249,386 @@ function useSession(sessionId, options = {}) {
|
|
|
320
249
|
};
|
|
321
250
|
}
|
|
322
251
|
|
|
323
|
-
// src/
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
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
|
+
}
|
|
329
266
|
}
|
|
330
|
-
function
|
|
331
|
-
|
|
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;
|
|
332
292
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
if (
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
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 {
|
|
363
329
|
}
|
|
364
|
-
if ([
|
|
365
|
-
"turn.started",
|
|
366
|
-
"turn.completed",
|
|
367
|
-
"turn.failed",
|
|
368
|
-
"turn.cancelled",
|
|
369
|
-
"turn.superseded"
|
|
370
|
-
].includes(event.type) || event.type === "session.queue.changed" && ["edit", "delete"].includes(String(payload.operation)))
|
|
371
|
-
claimed.add(turnId2);
|
|
372
|
-
if ((event.type === "turn.queued" || event.type === "user.message") && payload.routing === "accepted_for_execution" && (session.status !== "idle" || event.sequence > session.lastSequence))
|
|
373
|
-
pending.set(turnId2, event.occurredAt);
|
|
374
|
-
}
|
|
375
|
-
for (const message of optimisticMessages ?? []) {
|
|
376
|
-
if (message.state === "queued" && message.destination === "chat" && message.delivery === "send" && message.turnId && !pending.has(message.turnId) && (session.status !== "idle" || message.appliedQueueVersion != null && message.appliedQueueVersion > session.queueVersion))
|
|
377
|
-
pending.set(message.turnId, message.occurredAt);
|
|
378
330
|
}
|
|
379
|
-
const head = input.queue && input.queue.version >= queueVersion ? input.queue.items[0] : null;
|
|
380
|
-
if (session.status === "queued" && !session.activeTurnId && head && !pending.has(head.id))
|
|
381
|
-
pending.set(
|
|
382
|
-
head.id,
|
|
383
|
-
previousTurnEndedAt && previousTurnEndedAt > head.createdAt ? previousTurnEndedAt : head.createdAt
|
|
384
|
-
);
|
|
385
|
-
const candidate = [...pending].find(
|
|
386
|
-
([turnId2]) => !claimed.has(turnId2) && (!session.activeTurnId || session.activeTurnId === turnId2) && (!observedActiveTurn || observedActiveTurn === turnId2) && !items.some((item) => "turnId" in item && item.turnId === turnId2)
|
|
387
|
-
);
|
|
388
|
-
const fallback = !candidate && !newerProgress && session.status === "queued" && !session.activeTurnId && input.fallbackStartedAt;
|
|
389
|
-
if (!candidate && !fallback) return items;
|
|
390
|
-
const [turnId, startedAt] = candidate ?? [
|
|
391
|
-
`pending-startup:${session.id}`,
|
|
392
|
-
input.fallbackStartedAt
|
|
393
|
-
];
|
|
394
|
-
return [
|
|
395
|
-
...items,
|
|
396
|
-
{
|
|
397
|
-
kind: "startup-phase",
|
|
398
|
-
id: `${turnId}-queue`,
|
|
399
|
-
turnId,
|
|
400
|
-
phase: "queue",
|
|
401
|
-
status: "running",
|
|
402
|
-
startedAt,
|
|
403
|
-
occurredAt: startedAt,
|
|
404
|
-
completedAt: null,
|
|
405
|
-
durationMs: null,
|
|
406
|
-
outcome: null,
|
|
407
|
-
...session.activeTurnId ? {} : { dispatchWait: session.status === "queued" ? session.dispatchWait ?? null : null }
|
|
408
|
-
}
|
|
409
|
-
];
|
|
410
331
|
}
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
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
|
+
};
|
|
436
365
|
}
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
};
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
}
|
|
455
|
-
const scope = `${input.session.workspaceId}:${input.session.id}`;
|
|
456
|
-
if (bridgeRef.current?.scope === PENDING_SCOPE)
|
|
457
|
-
bridgeRef.current = { ...bridgeRef.current, scope };
|
|
458
|
-
if (bridgeRef.current?.scope !== scope || input.hasNewer || input.session.effectiveControl.state !== "active" || !["queued", "running", "idle"].includes(input.session.status))
|
|
459
|
-
bridgeRef.current = null;
|
|
460
|
-
const boundTurn = bridgeRef.current?.turnId;
|
|
461
|
-
const settled = boundTurn && currentEvents(input.events).find(
|
|
462
|
-
(event) => event.turnId === boundTurn && ["turn.completed", "turn.failed", "turn.cancelled", "turn.superseded"].includes(event.type)
|
|
463
|
-
);
|
|
464
|
-
let fallbackStartedAt = bridgeRef.current?.turnId === null ? bridgeRef.current.since : startup?.startedAt;
|
|
465
|
-
if (settled) {
|
|
466
|
-
bridgeRef.current = null;
|
|
467
|
-
fallbackStartedAt = input.session.status === "queued" && input.session.lastSequence >= settled.sequence ? input.session.updatedAt : void 0;
|
|
468
|
-
}
|
|
469
|
-
const projected = sessionStartupTimeline(items, {
|
|
470
|
-
...input,
|
|
471
|
-
session: input.session,
|
|
472
|
-
fallbackStartedAt
|
|
473
|
-
});
|
|
474
|
-
if (projected !== items) {
|
|
475
|
-
const phase2 = projected.at(-1);
|
|
476
|
-
if (phase2.kind !== "startup-phase") return projected;
|
|
477
|
-
const turnId2 = phase2.turnId === `pending-startup:${input.session.id}` ? null : phase2.turnId;
|
|
478
|
-
let bridge2 = bridgeRef.current;
|
|
479
|
-
if (!bridge2 || bridge2.turnId && turnId2 && bridge2.turnId !== turnId2) {
|
|
480
|
-
bridge2 = {
|
|
481
|
-
scope,
|
|
482
|
-
id: phase2.id,
|
|
483
|
-
turnId: turnId2,
|
|
484
|
-
since: phase2.startedAt,
|
|
485
|
-
sequence: input.session.lastSequence
|
|
486
|
-
};
|
|
487
|
-
} else
|
|
488
|
-
bridge2 = {
|
|
489
|
-
...bridge2,
|
|
490
|
-
turnId: turnId2 ?? bridge2.turnId,
|
|
491
|
-
since: bridge2.since < phase2.startedAt ? bridge2.since : phase2.startedAt
|
|
492
|
-
};
|
|
493
|
-
bridgeRef.current = bridge2;
|
|
494
|
-
return [
|
|
495
|
-
...projected.slice(0, -1),
|
|
496
|
-
{ ...phase2, id: bridge2.id, startedAt: bridge2.since, occurredAt: bridge2.since }
|
|
497
|
-
];
|
|
498
|
-
}
|
|
499
|
-
const bridge = bridgeRef.current;
|
|
500
|
-
if (!bridge) return items;
|
|
501
|
-
if (input.session.status === "idle") {
|
|
502
|
-
bridgeRef.current = null;
|
|
503
|
-
return items;
|
|
504
|
-
}
|
|
505
|
-
const started = currentEvents(input.events).find(
|
|
506
|
-
(event) => event.type === "turn.started" && (bridge.turnId ? event.turnId === bridge.turnId : event.sequence > bridge.sequence)
|
|
507
|
-
);
|
|
508
|
-
const turnId = bridge.turnId ?? started?.turnId ?? input.session.activeTurnId;
|
|
509
|
-
const phase = items.find((item) => item.kind === "startup-phase" && item.turnId === turnId);
|
|
510
|
-
if (phase?.kind === "startup-phase") {
|
|
511
|
-
bridgeRef.current = { ...bridge, turnId };
|
|
512
|
-
return items.map(
|
|
513
|
-
(item) => item === phase ? {
|
|
514
|
-
...phase,
|
|
515
|
-
id: bridge.id,
|
|
516
|
-
loadingStartedAt: bridge.since < phase.startedAt ? bridge.since : phase.startedAt
|
|
517
|
-
} : item
|
|
518
|
-
);
|
|
519
|
-
}
|
|
520
|
-
if (turnId && (started || input.session.activeTurnId === turnId)) {
|
|
521
|
-
bridgeRef.current = { ...bridge, turnId };
|
|
522
|
-
return [
|
|
523
|
-
...items,
|
|
524
|
-
{
|
|
525
|
-
kind: "startup-phase",
|
|
526
|
-
id: bridge.id,
|
|
527
|
-
turnId,
|
|
528
|
-
phase: "queue",
|
|
529
|
-
status: "complete",
|
|
530
|
-
startedAt: bridge.since,
|
|
531
|
-
occurredAt: bridge.since,
|
|
532
|
-
completedAt: started?.occurredAt ?? input.session.updatedAt,
|
|
533
|
-
durationMs: null,
|
|
534
|
-
outcome: null
|
|
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);
|
|
535
383
|
}
|
|
536
|
-
|
|
384
|
+
}
|
|
537
385
|
}
|
|
538
|
-
|
|
539
|
-
return items;
|
|
386
|
+
return entry;
|
|
540
387
|
}
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
const client = useOpenGeniClient(options);
|
|
546
|
-
const load = useCallback2(
|
|
547
|
-
async (signal) => await client.getClientConfig({ signal }),
|
|
548
|
-
[client]
|
|
549
|
-
);
|
|
550
|
-
const state = useSharedQuery(client, ["available-models"], load, {
|
|
551
|
-
pollIntervalMs: options.pollIntervalMs,
|
|
552
|
-
enabled: options.enabled
|
|
553
|
-
});
|
|
554
|
-
return {
|
|
555
|
-
models: state.data?.models ?? [],
|
|
556
|
-
defaultModel: state.data?.defaultModel ?? null,
|
|
557
|
-
loading: state.loading,
|
|
558
|
-
error: state.error,
|
|
559
|
-
refresh: state.refresh
|
|
560
|
-
};
|
|
388
|
+
function markTurnlessOutputGap(workspaceId, sessionId) {
|
|
389
|
+
const entry = gapEntry(gapKey(workspaceId, sessionId));
|
|
390
|
+
entry.generation += 1;
|
|
391
|
+
for (const listener of [...entry.listeners]) listener();
|
|
561
392
|
}
|
|
562
|
-
function
|
|
563
|
-
const
|
|
564
|
-
const
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
// Joins the same workspace's config read already in flight (for
|
|
573
|
-
// example the composer's voice availability).
|
|
574
|
-
joinClientConfigRead(client, options.workspaceId)
|
|
575
|
-
]);
|
|
576
|
-
return {
|
|
577
|
-
models: catalog.models,
|
|
578
|
-
defaultModel: config.defaultModel
|
|
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);
|
|
579
403
|
};
|
|
580
404
|
},
|
|
581
|
-
[
|
|
405
|
+
[key]
|
|
582
406
|
);
|
|
583
|
-
const
|
|
584
|
-
|
|
585
|
-
enabled: options.enabled !== false && Boolean(options.workspaceId)
|
|
586
|
-
});
|
|
587
|
-
const rows = sortPickerRows(projectPickerRows(t, state.data?.models ?? []));
|
|
588
|
-
return {
|
|
589
|
-
models: state.data?.models ?? [],
|
|
590
|
-
rows,
|
|
591
|
-
defaultModel: state.data?.defaultModel ?? null,
|
|
592
|
-
loading: state.loading,
|
|
593
|
-
error: state.error,
|
|
594
|
-
refresh: state.refresh
|
|
595
|
-
};
|
|
407
|
+
const read = useCallback2(() => key ? entries.get(key)?.generation ?? 0 : 0, [key]);
|
|
408
|
+
return useSyncExternalStore(subscribe, read, read);
|
|
596
409
|
}
|
|
597
410
|
|
|
598
|
-
// src/hooks/use-
|
|
599
|
-
import {
|
|
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
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
const
|
|
632
|
-
const
|
|
633
|
-
const
|
|
634
|
-
const
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
const
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
const
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
{ 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
|
|
657
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 });
|
|
658
511
|
useEffect2(() => {
|
|
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
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
if (event) await state.refresh();
|
|
688
|
-
return event;
|
|
689
|
-
} finally {
|
|
690
|
-
if (respondingRequestRef.current === requestId) {
|
|
691
|
-
respondingRequestRef.current = null;
|
|
692
|
-
setRespondingRequestId(null);
|
|
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);
|
|
693
540
|
}
|
|
694
541
|
}
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
loading: state.loading && retainedRequests === null,
|
|
705
|
-
error: state.error,
|
|
706
|
-
refresh: state.refresh,
|
|
707
|
-
respond,
|
|
708
|
-
respondingRequestId,
|
|
709
|
-
mutationError: mutation.mutationError,
|
|
710
|
-
clearMutationError: mutation.clearMutationError
|
|
711
|
-
};
|
|
712
|
-
}
|
|
713
|
-
|
|
714
|
-
// src/hooks/use-session-control.ts
|
|
715
|
-
import { useCallback as useCallback4, useLayoutEffect, useRef as useRef4 } from "react";
|
|
716
|
-
function useSessionControl(sessionId, options = {}) {
|
|
717
|
-
const { client, workspaceId } = useEmbeddedSession(options);
|
|
718
|
-
const approvalTargetKey = `${workspaceId}\0${sessionId ?? ""}`;
|
|
719
|
-
const pendingApproval = useRef4(null);
|
|
720
|
-
useLayoutEffect(() => {
|
|
721
|
-
if (pendingApproval.current?.targetKey !== approvalTargetKey) {
|
|
722
|
-
pendingApproval.current = null;
|
|
723
|
-
}
|
|
724
|
-
}, [approvalTargetKey]);
|
|
725
|
-
const {
|
|
726
|
-
run: runControl,
|
|
727
|
-
mutating: controlling,
|
|
728
|
-
mutationError: controlError,
|
|
729
|
-
clearMutationError: clearControlError
|
|
730
|
-
} = useMutationRunner(approvalTargetKey);
|
|
731
|
-
const {
|
|
732
|
-
run: runApproval,
|
|
733
|
-
mutating: responding,
|
|
734
|
-
mutationError: approvalError,
|
|
735
|
-
clearMutationError: clearApprovalError
|
|
736
|
-
} = useMutationRunner(approvalTargetKey);
|
|
737
|
-
const pause = useCallback4(
|
|
738
|
-
async (reason) => {
|
|
739
|
-
if (!sessionId) {
|
|
740
|
-
return null;
|
|
741
|
-
}
|
|
742
|
-
return await runControl(
|
|
743
|
-
() => client.pauseSession(workspaceId, sessionId, reason !== void 0 ? { reason } : {})
|
|
744
|
-
);
|
|
745
|
-
},
|
|
746
|
-
[client, workspaceId, sessionId, runControl]
|
|
747
|
-
);
|
|
748
|
-
const resume = useCallback4(
|
|
749
|
-
async (reason) => {
|
|
750
|
-
if (!sessionId) return null;
|
|
751
|
-
return await runControl(
|
|
752
|
-
() => client.resumeSession(workspaceId, sessionId, reason !== void 0 ? { reason } : {})
|
|
753
|
-
);
|
|
754
|
-
},
|
|
755
|
-
[client, workspaceId, sessionId, runControl]
|
|
756
|
-
);
|
|
757
|
-
const decide = useCallback4(
|
|
758
|
-
async (approvalId, decision, message, answer, decisionOptions = {}) => {
|
|
759
|
-
if (!sessionId) {
|
|
760
|
-
return null;
|
|
761
|
-
}
|
|
762
|
-
const decisionKey = JSON.stringify([approvalId, decision, message ?? null, answer ?? null]);
|
|
763
|
-
if (pendingApproval.current?.decisionKey !== decisionKey) {
|
|
764
|
-
pendingApproval.current = {
|
|
765
|
-
targetKey: approvalTargetKey,
|
|
766
|
-
decisionKey,
|
|
767
|
-
clientEventId: crypto.randomUUID()
|
|
768
|
-
};
|
|
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
|
+
}
|
|
769
551
|
}
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
decision,
|
|
777
|
-
...message !== void 0 ? { message } : {},
|
|
778
|
-
...answer !== void 0 ? answer : {},
|
|
779
|
-
clientEventId
|
|
780
|
-
});
|
|
781
|
-
} catch (cause) {
|
|
782
|
-
refusal = { cause };
|
|
783
|
-
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);
|
|
784
558
|
}
|
|
559
|
+
return kept ?? current;
|
|
785
560
|
});
|
|
786
|
-
if (decisionOptions.throwOnError && refusal) throw refusal.cause;
|
|
787
|
-
if (accepted !== null && pendingApproval.current?.targetKey === approvalTargetKey && pendingApproval.current.clientEventId === clientEventId) {
|
|
788
|
-
pendingApproval.current = null;
|
|
789
|
-
}
|
|
790
|
-
return accepted;
|
|
791
561
|
},
|
|
792
|
-
[
|
|
793
|
-
);
|
|
794
|
-
const approve = useCallback4(
|
|
795
|
-
async (approvalId, message, answer, decisionOptions) => await decide(approvalId, "approve", message, answer, decisionOptions),
|
|
796
|
-
[decide]
|
|
562
|
+
[commitStepStores]
|
|
797
563
|
);
|
|
798
|
-
const
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
pause,
|
|
809
|
-
resume,
|
|
810
|
-
controlling,
|
|
811
|
-
approve,
|
|
812
|
-
reject,
|
|
813
|
-
responding,
|
|
814
|
-
error,
|
|
815
|
-
clearError
|
|
816
|
-
};
|
|
817
|
-
}
|
|
818
|
-
|
|
819
|
-
// src/older-history.ts
|
|
820
|
-
var activeReceiptCapture;
|
|
821
|
-
var preserveTailForAutomaticLoad = false;
|
|
822
|
-
function invokeOlderHistoryLoaderWithReceiptCapture(load, capture, preserveTail = false) {
|
|
823
|
-
const previousCapture = activeReceiptCapture;
|
|
824
|
-
const previousPreserveTail = preserveTailForAutomaticLoad;
|
|
825
|
-
activeReceiptCapture = capture;
|
|
826
|
-
preserveTailForAutomaticLoad = preserveTail;
|
|
827
|
-
try {
|
|
828
|
-
return load();
|
|
829
|
-
} finally {
|
|
830
|
-
activeReceiptCapture = previousCapture;
|
|
831
|
-
preserveTailForAutomaticLoad = previousPreserveTail;
|
|
832
|
-
}
|
|
833
|
-
}
|
|
834
|
-
function createOlderHistoryLoadReceipt(load) {
|
|
835
|
-
let resolveResult;
|
|
836
|
-
let rejectResult;
|
|
837
|
-
const result = new Promise((resolve, reject) => {
|
|
838
|
-
resolveResult = resolve;
|
|
839
|
-
rejectResult = reject;
|
|
840
|
-
});
|
|
841
|
-
result.committed = false;
|
|
842
|
-
result.tailPreserved = false;
|
|
843
|
-
activeReceiptCapture?.(result);
|
|
844
|
-
try {
|
|
845
|
-
const loaded = load(
|
|
846
|
-
() => {
|
|
847
|
-
result.committed = true;
|
|
848
|
-
},
|
|
849
|
-
preserveTailForAutomaticLoad,
|
|
850
|
-
() => {
|
|
851
|
-
result.tailPreserved = true;
|
|
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);
|
|
852
574
|
}
|
|
853
|
-
);
|
|
854
|
-
Promise.resolve(loaded).then(resolveResult, rejectResult);
|
|
855
|
-
} catch (error) {
|
|
856
|
-
rejectResult(error);
|
|
857
|
-
}
|
|
858
|
-
return result;
|
|
859
|
-
}
|
|
860
|
-
|
|
861
|
-
// src/hooks/use-session-events.ts
|
|
862
|
-
import {
|
|
863
|
-
isPresentedSessionToolCall,
|
|
864
|
-
isRetryableStreamError,
|
|
865
|
-
isSessionModelResponsePhase,
|
|
866
|
-
isTransientRequestError,
|
|
867
|
-
SESSION_EVENT_COMPAT_EXCLUDED_STEP_TYPES,
|
|
868
|
-
SESSION_EVENT_CONTENT_STEP_TYPES,
|
|
869
|
-
SESSION_EVENT_CONVERSATION_FILTER_VERSION,
|
|
870
|
-
SESSION_EVENT_STEP_TYPES,
|
|
871
|
-
sessionEventStreamCoveredThrough
|
|
872
|
-
} from "@opengeni/sdk";
|
|
873
|
-
import { startTransition, useCallback as useCallback6, useEffect as useEffect3, useMemo as useMemo2, useRef as useRef5, useState as useState3 } from "react";
|
|
874
|
-
|
|
875
|
-
// src/hooks/page-wake.ts
|
|
876
|
-
var PAGE_WAKE_CHECK_INTERVAL_MS = 2e3;
|
|
877
|
-
var PAGE_WAKE_GAP_MS = 15e3;
|
|
878
|
-
var listeners = /* @__PURE__ */ new Set();
|
|
879
|
-
var stopDetector = null;
|
|
880
|
-
function subscribePageWake(listener) {
|
|
881
|
-
listeners.add(listener);
|
|
882
|
-
stopDetector ??= startDetector();
|
|
883
|
-
return () => {
|
|
884
|
-
listeners.delete(listener);
|
|
885
|
-
if (listeners.size === 0 && stopDetector) {
|
|
886
|
-
stopDetector();
|
|
887
|
-
stopDetector = null;
|
|
888
575
|
}
|
|
889
|
-
|
|
890
|
-
}
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
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;
|
|
896
585
|
}
|
|
897
|
-
|
|
898
|
-
}
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
};
|
|
912
|
-
const onPageShow = (event) => {
|
|
913
|
-
lastTick = Date.now();
|
|
914
|
-
if (event?.persisted === true) emitPageWake();
|
|
915
|
-
};
|
|
916
|
-
const onResume = () => {
|
|
917
|
-
lastTick = Date.now();
|
|
918
|
-
emitPageWake();
|
|
919
|
-
};
|
|
920
|
-
const timer = setInterval(check, PAGE_WAKE_CHECK_INTERVAL_MS);
|
|
921
|
-
document.addEventListener("visibilitychange", onVisibility);
|
|
922
|
-
document.addEventListener("resume", onResume);
|
|
923
|
-
window.addEventListener("pageshow", onPageShow);
|
|
924
|
-
window.addEventListener("online", onResume);
|
|
925
|
-
return () => {
|
|
926
|
-
clearInterval(timer);
|
|
927
|
-
document.removeEventListener("visibilitychange", onVisibility);
|
|
928
|
-
document.removeEventListener("resume", onResume);
|
|
929
|
-
window.removeEventListener("pageshow", onPageShow);
|
|
930
|
-
window.removeEventListener("online", onResume);
|
|
931
|
-
};
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
// src/hooks/turnless-output-gaps.ts
|
|
935
|
-
import { useCallback as useCallback5, useSyncExternalStore } from "react";
|
|
936
|
-
var MAX_IDLE_ENTRIES = 256;
|
|
937
|
-
var entries = /* @__PURE__ */ new Map();
|
|
938
|
-
function gapKey(workspaceId, sessionId) {
|
|
939
|
-
return `${workspaceId}\0${sessionId}`;
|
|
940
|
-
}
|
|
941
|
-
function gapEntry(key) {
|
|
942
|
-
let entry = entries.get(key);
|
|
943
|
-
if (!entry) {
|
|
944
|
-
entry = { generation: 0, listeners: /* @__PURE__ */ new Set() };
|
|
945
|
-
entries.set(key, entry);
|
|
946
|
-
if (entries.size > MAX_IDLE_ENTRIES) {
|
|
947
|
-
for (const [candidate, held] of entries) {
|
|
948
|
-
if (entries.size <= MAX_IDLE_ENTRIES) break;
|
|
949
|
-
if (candidate !== key && held.listeners.size === 0) entries.delete(candidate);
|
|
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);
|
|
950
600
|
}
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
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));
|
|
971
628
|
},
|
|
972
|
-
[
|
|
629
|
+
[commitStepStores, workspaceId, sessionId]
|
|
973
630
|
);
|
|
974
|
-
const
|
|
975
|
-
return useSyncExternalStore(subscribe, read, read);
|
|
976
|
-
}
|
|
977
|
-
|
|
978
|
-
// src/hooks/use-session-events.ts
|
|
979
|
-
import { errorMessage } from "@opengeni/contracts/values";
|
|
980
|
-
var SESSION_FIRST_WINDOW_PAGE_SIZE = 255;
|
|
981
|
-
var SESSION_HISTORY_PAGE_SIZE = 1e3;
|
|
982
|
-
var INITIAL_FETCH_CAP = 1;
|
|
983
|
-
var OLDER_GROUP_TARGET = 32;
|
|
984
|
-
var OLDER_FETCH_CAP = 2;
|
|
985
|
-
var NEWER_GROUP_TARGET = 32;
|
|
986
|
-
var NEWER_FETCH_CAP = 2;
|
|
987
|
-
var OLDEST_GROUP_TARGET = 32;
|
|
988
|
-
var OLDEST_FETCH_CAP = 2;
|
|
989
|
-
var BOUNDARY_PAGE_CAP = 1;
|
|
990
|
-
var FILTERED_PAGE_CAP = 32;
|
|
991
|
-
var DIRECT_REPLAY_MAX_SEQUENCES = 16;
|
|
992
|
-
var CATCHUP_MAX_PAGES = 2;
|
|
993
|
-
var STRICT_REJOIN_ATTEMPTS = 5;
|
|
994
|
-
var REJOIN_STALL_TIMEOUT_MS = 3e4;
|
|
995
|
-
var FOREGROUND_REJOIN_RETRY_MS = 500;
|
|
996
|
-
var FOREGROUND_REJOIN_RETRY_MAX_MS = 8e3;
|
|
997
|
-
var EMPTY_EVENTS = [];
|
|
998
|
-
var encoder = new TextEncoder();
|
|
999
|
-
var SESSION_EVENT_BROWSER_MAX_BYTES = 16 * 1024 * 1024;
|
|
1000
|
-
var SESSION_EVENT_BROWSER_MAX_COUNT = 2e4;
|
|
1001
|
-
var SESSION_EVENT_BROWSER_PENDING_MAX_BYTES = 1024 * 1024;
|
|
1002
|
-
var SESSION_EVENT_BROWSER_PENDING_MAX_COUNT = 256;
|
|
1003
|
-
var EMPTY_EVENT_WINDOW = {
|
|
1004
|
-
events: EMPTY_EVENTS,
|
|
1005
|
-
bytes: 2,
|
|
1006
|
-
truncated: false
|
|
1007
|
-
};
|
|
1008
|
-
function useSessionEvents(sessionId, options = {}) {
|
|
1009
|
-
const t = useOpenGeniText();
|
|
1010
|
-
const { client, workspaceId, reconcileSession } = useEmbeddedSession(options);
|
|
1011
|
-
const enabled = options.enabled ?? true;
|
|
1012
|
-
const pageLive = usePageLiveActivity();
|
|
1013
|
-
const streamEnabled = enabled && pageLive;
|
|
1014
|
-
const after = options.after ?? 0;
|
|
1015
|
-
const replay = options.replay ?? "windowed";
|
|
1016
|
-
const fullReplay = replay === "full" || after !== 0;
|
|
1017
|
-
const streamKey = `${workspaceId}\0${sessionId ?? ""}\0${after}\0${fullReplay ? "full" : "windowed"}`;
|
|
1018
|
-
const navigationIdentityRef = useRef5({ client, streamKey, enabled });
|
|
1019
|
-
if (navigationIdentityRef.current.client !== client || navigationIdentityRef.current.streamKey !== streamKey || navigationIdentityRef.current.enabled !== enabled) {
|
|
1020
|
-
navigationIdentityRef.current = { client, streamKey, enabled };
|
|
1021
|
-
}
|
|
1022
|
-
const navigationIdentity = navigationIdentityRef.current;
|
|
1023
|
-
const ownsNavigation = useCallback6(
|
|
1024
|
-
() => navigationIdentityRef.current === navigationIdentity,
|
|
1025
|
-
[navigationIdentity]
|
|
1026
|
-
);
|
|
1027
|
-
const [eventWindow, setEventWindow] = useState3(EMPTY_EVENT_WINDOW);
|
|
1028
|
-
const [questionEvidence, setQuestionEvidence] = useState3(null);
|
|
1029
|
-
const [connectionState, setConnectionState] = useState3("idle");
|
|
1030
|
-
const [error, setError] = useState3(null);
|
|
1031
|
-
const [newerError, setNewerError] = useState3(null);
|
|
1032
|
-
const [hasOlder, setHasOlder] = useState3(false);
|
|
1033
|
-
const [hasNewer, setHasNewer] = useState3(false);
|
|
1034
|
-
const [sessionStatusProjection, setSessionStatusProjection] = useState3(
|
|
1035
|
-
null
|
|
1036
|
-
);
|
|
1037
|
-
const [initialLoading, setInitialLoading] = useState3(true);
|
|
1038
|
-
const [initialHistoryReady, setInitialHistoryReady] = useState3(false);
|
|
1039
|
-
const [loadingOlder, setLoadingOlder] = useState3(false);
|
|
1040
|
-
const [loadingNewer, setLoadingNewer] = useState3(false);
|
|
1041
|
-
const [loadingOldest, setLoadingOldest] = useState3(false);
|
|
1042
|
-
const [loadingLatest, setLoadingLatest] = useState3(false);
|
|
1043
|
-
const [loadingTarget, setLoadingTarget] = useState3(false);
|
|
1044
|
-
const loadingTargetRef = useRef5(false);
|
|
1045
|
-
const [streamEpoch, setStreamEpoch] = useState3(0);
|
|
1046
|
-
const [viewMode, setViewMode] = useState3("live");
|
|
1047
|
-
const lastSequenceRef = useRef5(after);
|
|
1048
|
-
const streamResumeSequenceRef = useRef5(after);
|
|
1049
|
-
const skippedStepsThroughRef = useRef5(null);
|
|
1050
|
-
const oldestSequenceRef = useRef5(null);
|
|
1051
|
-
const newestSequenceRef = useRef5(null);
|
|
1052
|
-
const hasOlderRef = useRef5(false);
|
|
1053
|
-
const hasNewerRef = useRef5(false);
|
|
1054
|
-
const loadingOlderRef = useRef5(false);
|
|
1055
|
-
const loadingNewerRef = useRef5(false);
|
|
1056
|
-
const loadingOldestRef = useRef5(false);
|
|
1057
|
-
const loadingLatestRef = useRef5(false);
|
|
1058
|
-
const viewModeRef = useRef5("live");
|
|
1059
|
-
const initialWindowLoadedRef = useRef5(false);
|
|
1060
|
-
const openedStreamKeyRef = useRef5(null);
|
|
1061
|
-
const reconcileAfterPageResumeRef = useRef5(false);
|
|
1062
|
-
const streamAbortRef = useRef5(null);
|
|
1063
|
-
const streamKeyRef = useRef5(null);
|
|
1064
|
-
const generationRef = useRef5(0);
|
|
1065
|
-
const navigationGenerationRef = useRef5(0);
|
|
1066
|
-
const eventWindowRef = useRef5(EMPTY_EVENT_WINDOW);
|
|
1067
|
-
const sessionStatusRef = useRef5({
|
|
1068
|
-
sequence: after,
|
|
1069
|
-
status: null
|
|
1070
|
-
});
|
|
1071
|
-
const [stateStreamKey, setStateStreamKey] = useState3(streamKey);
|
|
1072
|
-
const historyFilter = fullReplay ? void 0 : CONVERSATION_FILTER;
|
|
1073
|
-
const [stepStores, setStepStores] = useState3(EMPTY_STEP_STORES);
|
|
1074
|
-
const stepStoresRef = useRef5(EMPTY_STEP_STORES);
|
|
1075
|
-
const [turnlessSteps, setTurnlessSteps] = useState3(EMPTY_TURNLESS_STEPS);
|
|
1076
|
-
const turnlessStepsRef = useRef5(EMPTY_TURNLESS_STEPS);
|
|
1077
|
-
const renderedTurnlessRef = useRef5({ appended: 0, marked: false });
|
|
1078
|
-
useEffect3(() => {
|
|
1079
|
-
renderedTurnlessRef.current = { appended: turnlessSteps.appended, marked: false };
|
|
1080
|
-
}, [turnlessSteps]);
|
|
1081
|
-
const liveThroughRef = useRef5(0);
|
|
1082
|
-
const stepGenerationRef = useRef5(0);
|
|
1083
|
-
const stepRequestRef = useRef5(0);
|
|
1084
|
-
const retainedTurnsRef = useRef5(/* @__PURE__ */ new Map());
|
|
1085
|
-
const turnStepHandlesRef = useRef5(/* @__PURE__ */ new Map());
|
|
1086
|
-
const presentedCallIdsRef = useRef5(/* @__PURE__ */ new Set());
|
|
1087
|
-
const presentedScanRef = useRef5(null);
|
|
1088
|
-
const startupRef = useRef5(emptyStartupTurns());
|
|
1089
|
-
const [presentedOutputs, setPresentedOutputs] = useState3(EMPTY_PRESENTED_OUTPUTS);
|
|
1090
|
-
const presentedRequestedRef = useRef5(/* @__PURE__ */ new Map());
|
|
1091
|
-
const presentedFailuresRef = useRef5(/* @__PURE__ */ new Map());
|
|
1092
|
-
const [presentedPass, setPresentedPass] = useState3(0);
|
|
1093
|
-
const rejoinPendingRef = useRef5(false);
|
|
1094
|
-
const streamTransientStreakRef = useRef5(null);
|
|
1095
|
-
const commitStepStores = useCallback6((next) => {
|
|
1096
|
-
stepStoresRef.current = next;
|
|
1097
|
-
setStepStores(next);
|
|
1098
|
-
}, []);
|
|
1099
|
-
const pruneStepStores = useCallback6(
|
|
1100
|
-
(window2, sealedBy, rereading = null) => {
|
|
1101
|
-
const present = windowTurns(window2);
|
|
1102
|
-
const settled = sealedBy ? settledTurns(sealedBy) : null;
|
|
1103
|
-
const next = /* @__PURE__ */ new Map();
|
|
1104
|
-
for (const [turnId, store] of stepStoresRef.current) {
|
|
1105
|
-
if (present.has(turnId) && (!settled || settled.has(turnId) || turnId === rereading)) {
|
|
1106
|
-
next.set(turnId, store);
|
|
1107
|
-
}
|
|
1108
|
-
}
|
|
1109
|
-
if (next.size !== stepStoresRef.current.size) commitStepStores(next);
|
|
1110
|
-
if (sealedBy) {
|
|
1111
|
-
presentedRequestedRef.current = /* @__PURE__ */ new Map();
|
|
1112
|
-
} else {
|
|
1113
|
-
for (const [callId, request] of presentedRequestedRef.current) {
|
|
1114
|
-
if (request.turnId && !present.has(request.turnId)) {
|
|
1115
|
-
presentedRequestedRef.current.delete(callId);
|
|
1116
|
-
}
|
|
1117
|
-
}
|
|
1118
|
-
}
|
|
1119
|
-
setPresentedOutputs((current) => {
|
|
1120
|
-
let kept = null;
|
|
1121
|
-
for (const [callId, output] of current) {
|
|
1122
|
-
if (output.turnId && present.has(output.turnId)) continue;
|
|
1123
|
-
kept ??= new Map(current);
|
|
1124
|
-
kept.delete(callId);
|
|
1125
|
-
}
|
|
1126
|
-
return kept ?? current;
|
|
1127
|
-
});
|
|
1128
|
-
},
|
|
1129
|
-
[commitStepStores]
|
|
1130
|
-
);
|
|
1131
|
-
const presentedCallIds = useCallback6((event) => {
|
|
1132
|
-
const ids = presentedCallIdsRef.current;
|
|
1133
|
-
if (event.type === "agent.toolCall.created") {
|
|
1134
|
-
notePresentedCalls([event], ids);
|
|
1135
|
-
} else if (event.type === "agent.toolCall.output") {
|
|
1136
|
-
const payload = event.payload;
|
|
1137
|
-
const windowEvents = eventWindowRef.current.events;
|
|
1138
|
-
if (typeof payload?.id === "string" && !ids.has(payload.id) && presentedScanRef.current !== windowEvents) {
|
|
1139
|
-
presentedScanRef.current = windowEvents;
|
|
1140
|
-
notePresentedCalls(windowEvents, ids);
|
|
1141
|
-
}
|
|
1142
|
-
}
|
|
1143
|
-
return ids;
|
|
1144
|
-
}, []);
|
|
1145
|
-
const startupTurns = useCallback6(() => {
|
|
1146
|
-
const windowEvents = eventWindowRef.current.events;
|
|
1147
|
-
if (startupRef.current.window !== windowEvents) {
|
|
1148
|
-
const state = emptyStartupTurns();
|
|
1149
|
-
noteStartupTurns(windowEvents, state);
|
|
1150
|
-
state.window = windowEvents;
|
|
1151
|
-
startupRef.current = state;
|
|
1152
|
-
}
|
|
1153
|
-
return startupRef.current;
|
|
1154
|
-
}, []);
|
|
1155
|
-
const appendLiveSteps = useCallback6(
|
|
1156
|
-
(steps) => {
|
|
1157
|
-
if (steps.some((event) => !event.turnId)) {
|
|
1158
|
-
const incoming = steps.filter((event) => !event.turnId);
|
|
1159
|
-
const turnless = appendTurnlessSteps(turnlessStepsRef.current, incoming);
|
|
1160
|
-
const rendered = renderedTurnlessRef.current;
|
|
1161
|
-
if (!rendered.marked && turnless.appended - rendered.appended > turnless.events.length) {
|
|
1162
|
-
rendered.marked = true;
|
|
1163
|
-
if (sessionId) markTurnlessOutputGap(workspaceId, sessionId);
|
|
1164
|
-
}
|
|
1165
|
-
turnlessStepsRef.current = turnless;
|
|
1166
|
-
setTurnlessSteps(turnless);
|
|
1167
|
-
}
|
|
1168
|
-
const windowEvents = withTurnlessSteps(
|
|
1169
|
-
eventWindowRef.current.events,
|
|
1170
|
-
turnlessStepsRef.current
|
|
1171
|
-
);
|
|
1172
|
-
const next = new Map(stepStoresRef.current);
|
|
1173
|
-
const now = Date.now();
|
|
1174
|
-
for (const [turnId, events] of groupByTurn(steps)) {
|
|
1175
|
-
const existing = next.get(turnId);
|
|
1176
|
-
const store = existing ?? {
|
|
1177
|
-
events: [],
|
|
1178
|
-
bytes: 2,
|
|
1179
|
-
// Earlier steps exist when the window skips sequences between the
|
|
1180
|
-
// turn's start and this first live step.
|
|
1181
|
-
hasOlder: turnHasHiddenSequences(windowEvents, turnId, events[0].sequence),
|
|
1182
|
-
cursor: null,
|
|
1183
|
-
floor: null,
|
|
1184
|
-
pinned: null,
|
|
1185
|
-
loading: false,
|
|
1186
|
-
error: false,
|
|
1187
|
-
touched: now,
|
|
1188
|
-
requestId: 0
|
|
1189
|
-
};
|
|
1190
|
-
let updated = { ...store, ...appendStepEvents(store, events), touched: now };
|
|
1191
|
-
if (!retainedTurnsRef.current.get(turnId)) updated = trimLiveStepTail(updated);
|
|
1192
|
-
next.set(turnId, updated);
|
|
1193
|
-
}
|
|
1194
|
-
commitStepStores(boundStepStores(next, retainedTurnsRef.current));
|
|
1195
|
-
},
|
|
1196
|
-
[commitStepStores, workspaceId, sessionId]
|
|
1197
|
-
);
|
|
1198
|
-
const loadTurnSteps = useCallback6(
|
|
631
|
+
const loadTurnSteps = useCallback3(
|
|
1199
632
|
(turnId, before) => {
|
|
1200
633
|
if (!ownsNavigation() || !sessionId || fullReplay) return;
|
|
1201
634
|
const current = stepStoresRef.current.get(turnId);
|
|
@@ -1291,11 +724,11 @@ function useSessionEvents(sessionId, options = {}) {
|
|
|
1291
724
|
},
|
|
1292
725
|
[client, workspaceId, sessionId, fullReplay, ownsNavigation, commitStepStores]
|
|
1293
726
|
);
|
|
1294
|
-
const loadTurnStepsRef =
|
|
1295
|
-
|
|
727
|
+
const loadTurnStepsRef = useRef2(loadTurnSteps);
|
|
728
|
+
useEffect2(() => {
|
|
1296
729
|
loadTurnStepsRef.current = loadTurnSteps;
|
|
1297
730
|
}, [loadTurnSteps]);
|
|
1298
|
-
const turnStepHandle =
|
|
731
|
+
const turnStepHandle = useCallback3((turnId) => {
|
|
1299
732
|
let handle = turnStepHandlesRef.current.get(turnId);
|
|
1300
733
|
if (!handle) {
|
|
1301
734
|
const retained = retainedTurnsRef.current;
|
|
@@ -1317,7 +750,7 @@ function useSessionEvents(sessionId, options = {}) {
|
|
|
1317
750
|
}
|
|
1318
751
|
return handle;
|
|
1319
752
|
}, []);
|
|
1320
|
-
|
|
753
|
+
useEffect2(() => {
|
|
1321
754
|
navigationGenerationRef.current += 1;
|
|
1322
755
|
setNewerError(null);
|
|
1323
756
|
loadingOlderRef.current = false;
|
|
@@ -1333,7 +766,7 @@ function useSessionEvents(sessionId, options = {}) {
|
|
|
1333
766
|
navigationGenerationRef.current += 1;
|
|
1334
767
|
};
|
|
1335
768
|
}, [client, workspaceId, sessionId, after, enabled, fullReplay]);
|
|
1336
|
-
|
|
769
|
+
useEffect2(() => {
|
|
1337
770
|
if (streamKeyRef.current !== streamKey) {
|
|
1338
771
|
streamKeyRef.current = streamKey;
|
|
1339
772
|
setStateStreamKey(streamKey);
|
|
@@ -1861,7 +1294,7 @@ function useSessionEvents(sessionId, options = {}) {
|
|
|
1861
1294
|
presentedCallIds,
|
|
1862
1295
|
startupTurns
|
|
1863
1296
|
]);
|
|
1864
|
-
|
|
1297
|
+
useEffect2(() => {
|
|
1865
1298
|
if (!sessionId || !streamEnabled) return;
|
|
1866
1299
|
return subscribePageWake(() => {
|
|
1867
1300
|
const stream = streamAbortRef.current;
|
|
@@ -1873,7 +1306,7 @@ function useSessionEvents(sessionId, options = {}) {
|
|
|
1873
1306
|
});
|
|
1874
1307
|
}, [sessionId, streamEnabled, fullReplay]);
|
|
1875
1308
|
const navigationBusy = () => loadingTargetRef.current || loadingOlderRef.current || loadingNewerRef.current || loadingOldestRef.current || loadingLatestRef.current;
|
|
1876
|
-
const loadOlder =
|
|
1309
|
+
const loadOlder = useCallback3(
|
|
1877
1310
|
() => createOlderHistoryLoadReceipt(async (markCommitted, preserveTail, markTailPreserved) => {
|
|
1878
1311
|
if (!ownsNavigation() || !sessionId || navigationBusy() || !hasOlderRef.current) {
|
|
1879
1312
|
return false;
|
|
@@ -2000,7 +1433,7 @@ function useSessionEvents(sessionId, options = {}) {
|
|
|
2000
1433
|
}),
|
|
2001
1434
|
[client, workspaceId, sessionId, ownsNavigation, t, historyFilter, pruneStepStores]
|
|
2002
1435
|
);
|
|
2003
|
-
const loadOldest =
|
|
1436
|
+
const loadOldest = useCallback3(async () => {
|
|
2004
1437
|
if (!ownsNavigation() || !sessionId || navigationBusy() || !hasOlderRef.current) {
|
|
2005
1438
|
return false;
|
|
2006
1439
|
}
|
|
@@ -2071,7 +1504,7 @@ function useSessionEvents(sessionId, options = {}) {
|
|
|
2071
1504
|
}
|
|
2072
1505
|
}
|
|
2073
1506
|
}, [client, workspaceId, sessionId, ownsNavigation, t, historyFilter, pruneStepStores]);
|
|
2074
|
-
const loadNewer =
|
|
1507
|
+
const loadNewer = useCallback3(async () => {
|
|
2075
1508
|
if (!ownsNavigation() || !sessionId || navigationBusy() || !hasNewerRef.current) {
|
|
2076
1509
|
return false;
|
|
2077
1510
|
}
|
|
@@ -2177,7 +1610,7 @@ function useSessionEvents(sessionId, options = {}) {
|
|
|
2177
1610
|
}
|
|
2178
1611
|
}
|
|
2179
1612
|
}, [client, workspaceId, sessionId, ownsNavigation, t, historyFilter, pruneStepStores]);
|
|
2180
|
-
const jumpToSequence =
|
|
1613
|
+
const jumpToSequence = useCallback3(
|
|
2181
1614
|
async (sequence, navigationOptions) => {
|
|
2182
1615
|
const signal = navigationOptions?.signal;
|
|
2183
1616
|
if (!ownsNavigation() || !sessionId || !Number.isSafeInteger(sequence) || sequence < 1)
|
|
@@ -2262,7 +1695,7 @@ function useSessionEvents(sessionId, options = {}) {
|
|
|
2262
1695
|
},
|
|
2263
1696
|
[client, workspaceId, sessionId, ownsNavigation, historyFilter, pruneStepStores]
|
|
2264
1697
|
);
|
|
2265
|
-
const jumpToLatestQuestion =
|
|
1698
|
+
const jumpToLatestQuestion = useCallback3(
|
|
2266
1699
|
async (questionOptions) => {
|
|
2267
1700
|
if (!sessionId || !ownsNavigation()) return null;
|
|
2268
1701
|
let generation = navigationGenerationRef.current;
|
|
@@ -2298,7 +1731,7 @@ function useSessionEvents(sessionId, options = {}) {
|
|
|
2298
1731
|
},
|
|
2299
1732
|
[client, workspaceId, sessionId, streamKey, ownsNavigation, jumpToSequence, t]
|
|
2300
1733
|
);
|
|
2301
|
-
const jumpToLatest =
|
|
1734
|
+
const jumpToLatest = useCallback3(async () => {
|
|
2302
1735
|
if (!ownsNavigation()) return;
|
|
2303
1736
|
if (loadingTargetRef.current) {
|
|
2304
1737
|
navigationGenerationRef.current += 1;
|
|
@@ -2366,7 +1799,7 @@ function useSessionEvents(sessionId, options = {}) {
|
|
|
2366
1799
|
const visibleStepStores = liveSteps ? stepStores : EMPTY_STEP_STORES;
|
|
2367
1800
|
const visiblePresentedOutputs = liveSteps ? presentedOutputs : EMPTY_PRESENTED_OUTPUTS;
|
|
2368
1801
|
const visibleTurnless = liveSteps ? turnlessSteps : EMPTY_TURNLESS_STEPS;
|
|
2369
|
-
const readToolOutput =
|
|
1802
|
+
const readToolOutput = useCallback3(
|
|
2370
1803
|
async (sequence) => sessionId ? (await readEventPage(client, workspaceId, sessionId, {
|
|
2371
1804
|
includeTypes: ["agent.toolCall.output"],
|
|
2372
1805
|
after: Math.max(0, sequence - 1),
|
|
@@ -2438,7 +1871,7 @@ function useSessionEvents(sessionId, options = {}) {
|
|
|
2438
1871
|
toolOutputs.reader,
|
|
2439
1872
|
t
|
|
2440
1873
|
]);
|
|
2441
|
-
|
|
1874
|
+
useEffect2(() => {
|
|
2442
1875
|
if (fullReplay || !sessionId || !identityMatches || !initialHistoryReady) return;
|
|
2443
1876
|
const resolved = new Set(presentedOutputs.keys());
|
|
2444
1877
|
const collect = (events) => {
|
|
@@ -3254,7 +2687,7 @@ async function readEventPage(client, workspaceId, sessionId, options) {
|
|
|
3254
2687
|
|
|
3255
2688
|
// src/hooks/use-turn-queue.ts
|
|
3256
2689
|
import { isTransientRequestError as isTransientRequestError2 } from "@opengeni/sdk";
|
|
3257
|
-
import { useCallback as
|
|
2690
|
+
import { useCallback as useCallback4, useEffect as useEffect3, useLayoutEffect, useMemo as useMemo3, useRef as useRef3, useState as useState3 } from "react";
|
|
3258
2691
|
function isTurnQueueEvent(event) {
|
|
3259
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.");
|
|
3260
2693
|
}
|
|
@@ -3270,30 +2703,30 @@ function useTurnQueue(sessionId, options = {}) {
|
|
|
3270
2703
|
const enabled = (options.enabled ?? true) && Boolean(sessionId);
|
|
3271
2704
|
const targetKey = `${workspaceId}\0${sessionId ?? ""}`;
|
|
3272
2705
|
const pageLive = usePageLiveActivity();
|
|
3273
|
-
const pageLiveRef =
|
|
2706
|
+
const pageLiveRef = useRef3(pageLive);
|
|
3274
2707
|
pageLiveRef.current = pageLive;
|
|
3275
|
-
const [snapshot, setSnapshot] =
|
|
3276
|
-
const [stateTargetKey, setStateTargetKey] =
|
|
3277
|
-
const [loading, setLoading] =
|
|
3278
|
-
const [error, setError] =
|
|
3279
|
-
const [mutationError, setMutationError] =
|
|
3280
|
-
const [pendingByTurn, setPendingByTurn] =
|
|
3281
|
-
const [acceptedSteers, setAcceptedSteers] =
|
|
3282
|
-
const pendingRef =
|
|
3283
|
-
const readGeneration =
|
|
3284
|
-
const targetKeyRef =
|
|
3285
|
-
const snapshotRef =
|
|
3286
|
-
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(
|
|
3287
2720
|
null
|
|
3288
2721
|
);
|
|
3289
|
-
const transientRetryTimerRef =
|
|
3290
|
-
const cancelTransientRetry =
|
|
2722
|
+
const transientRetryTimerRef = useRef3(null);
|
|
2723
|
+
const cancelTransientRetry = useCallback4(() => {
|
|
3291
2724
|
if (transientRetryTimerRef.current !== null) {
|
|
3292
2725
|
clearTimeout(transientRetryTimerRef.current);
|
|
3293
2726
|
transientRetryTimerRef.current = null;
|
|
3294
2727
|
}
|
|
3295
2728
|
}, []);
|
|
3296
|
-
|
|
2729
|
+
useLayoutEffect(() => {
|
|
3297
2730
|
if (targetKeyRef.current === targetKey) return;
|
|
3298
2731
|
targetKeyRef.current = targetKey;
|
|
3299
2732
|
readGeneration.current += 1;
|
|
@@ -3309,7 +2742,7 @@ function useTurnQueue(sessionId, options = {}) {
|
|
|
3309
2742
|
setPendingByTurn({});
|
|
3310
2743
|
setAcceptedSteers([]);
|
|
3311
2744
|
}, [cancelTransientRetry, enabled, targetKey]);
|
|
3312
|
-
|
|
2745
|
+
useEffect3(() => {
|
|
3313
2746
|
if (acceptedSteers.length === 0 || options.events === void 0) return;
|
|
3314
2747
|
const durablyConsumedTurnIds = new Set(
|
|
3315
2748
|
options.events.flatMap(
|
|
@@ -3327,7 +2760,7 @@ function useTurnQueue(sessionId, options = {}) {
|
|
|
3327
2760
|
(current) => current.filter((steer) => !durablyConsumedTurnIds.has(steer.turnId))
|
|
3328
2761
|
);
|
|
3329
2762
|
}, [acceptedSteers.length, options.events]);
|
|
3330
|
-
const acceptSnapshot =
|
|
2763
|
+
const acceptSnapshot = useCallback4(
|
|
3331
2764
|
(ownedTargetKey, next) => {
|
|
3332
2765
|
if (targetKeyRef.current !== ownedTargetKey) return false;
|
|
3333
2766
|
const current = snapshotRef.current;
|
|
@@ -3341,7 +2774,7 @@ function useTurnQueue(sessionId, options = {}) {
|
|
|
3341
2774
|
},
|
|
3342
2775
|
[]
|
|
3343
2776
|
);
|
|
3344
|
-
const load =
|
|
2777
|
+
const load = useCallback4(
|
|
3345
2778
|
async (rejectOnFailure = false, fresh = false) => {
|
|
3346
2779
|
if (!sessionId) return;
|
|
3347
2780
|
const ownedTargetKey = `${workspaceId}\0${sessionId}`;
|
|
@@ -3397,10 +2830,10 @@ function useTurnQueue(sessionId, options = {}) {
|
|
|
3397
2830
|
},
|
|
3398
2831
|
[client, workspaceId, sessionId, acceptSnapshot, cancelTransientRetry]
|
|
3399
2832
|
);
|
|
3400
|
-
const loadRef =
|
|
2833
|
+
const loadRef = useRef3(load);
|
|
3401
2834
|
loadRef.current = load;
|
|
3402
|
-
|
|
3403
|
-
|
|
2835
|
+
useEffect3(() => cancelTransientRetry, [cancelTransientRetry]);
|
|
2836
|
+
useEffect3(() => {
|
|
3404
2837
|
if (!enabled || !pageLive) {
|
|
3405
2838
|
cancelTransientRetry();
|
|
3406
2839
|
setLoading(false);
|
|
@@ -3430,11 +2863,11 @@ function useTurnQueue(sessionId, options = {}) {
|
|
|
3430
2863
|
readGeneration.current += 1;
|
|
3431
2864
|
};
|
|
3432
2865
|
}, [cancelTransientRetry, load, enabled, pageLive, options.pollIntervalMs]);
|
|
3433
|
-
const loadFresh =
|
|
3434
|
-
|
|
2866
|
+
const loadFresh = useCallback4(() => load(false, true), [load]);
|
|
2867
|
+
useEffect3(() => {
|
|
3435
2868
|
if (enabled && workspaceControlEvent) void loadFresh();
|
|
3436
2869
|
}, [enabled, loadFresh, workspaceControlEvent]);
|
|
3437
|
-
|
|
2870
|
+
useEffect3(() => {
|
|
3438
2871
|
if (!sessionId || !enabled) return;
|
|
3439
2872
|
return registerSessionReconciler(sessionId, "queue", loadFresh);
|
|
3440
2873
|
}, [enabled, loadFresh, registerSessionReconciler, sessionId]);
|
|
@@ -3463,7 +2896,7 @@ function useTurnQueue(sessionId, options = {}) {
|
|
|
3463
2896
|
freshSnapshot,
|
|
3464
2897
|
{ enabled, discard: stateTargetKey === targetKey && deniesRetainedView(error) }
|
|
3465
2898
|
);
|
|
3466
|
-
const mutate =
|
|
2899
|
+
const mutate = useCallback4(
|
|
3467
2900
|
async (turnId, kind, command, failure = {}) => {
|
|
3468
2901
|
const ownedTargetKey = targetKey;
|
|
3469
2902
|
if (!sessionId || targetKeyRef.current !== ownedTargetKey || pendingRef.current[turnId]) {
|
|
@@ -3515,7 +2948,7 @@ function useTurnQueue(sessionId, options = {}) {
|
|
|
3515
2948
|
},
|
|
3516
2949
|
[acceptSnapshot, loadFresh, sessionId, targetKey]
|
|
3517
2950
|
);
|
|
3518
|
-
const moveTurn =
|
|
2951
|
+
const moveTurn = useCallback4(
|
|
3519
2952
|
async (turnId, beforeTurnId) => {
|
|
3520
2953
|
const result = await mutate(
|
|
3521
2954
|
turnId,
|
|
@@ -3530,7 +2963,7 @@ function useTurnQueue(sessionId, options = {}) {
|
|
|
3530
2963
|
},
|
|
3531
2964
|
[client, mutate, sessionId, workspaceId]
|
|
3532
2965
|
);
|
|
3533
|
-
const editTurn =
|
|
2966
|
+
const editTurn = useCallback4(
|
|
3534
2967
|
async (turnId, edit) => {
|
|
3535
2968
|
const result = await mutate(
|
|
3536
2969
|
turnId,
|
|
@@ -3546,7 +2979,7 @@ function useTurnQueue(sessionId, options = {}) {
|
|
|
3546
2979
|
},
|
|
3547
2980
|
[client, mutate, sessionId, workspaceId]
|
|
3548
2981
|
);
|
|
3549
|
-
const recallTurn =
|
|
2982
|
+
const recallTurn = useCallback4(
|
|
3550
2983
|
async (turnId, recall) => {
|
|
3551
2984
|
const ownedTargetKey = targetKey;
|
|
3552
2985
|
const known = snapshotRef.current?.items.some((candidate) => candidate.id === turnId);
|
|
@@ -3569,7 +3002,7 @@ function useTurnQueue(sessionId, options = {}) {
|
|
|
3569
3002
|
},
|
|
3570
3003
|
[client, mutate, sessionId, targetKey, workspaceId]
|
|
3571
3004
|
);
|
|
3572
|
-
const steerTurn =
|
|
3005
|
+
const steerTurn = useCallback4(
|
|
3573
3006
|
async (turnId) => {
|
|
3574
3007
|
const ownedTargetKey = targetKey;
|
|
3575
3008
|
const turn = snapshotRef.current?.items.find((candidate) => candidate.id === turnId);
|
|
@@ -3621,7 +3054,7 @@ function useTurnQueue(sessionId, options = {}) {
|
|
|
3621
3054
|
},
|
|
3622
3055
|
[client, loadFresh, mutate, sessionId, targetKey, workspaceId, t]
|
|
3623
3056
|
);
|
|
3624
|
-
const removeTurn =
|
|
3057
|
+
const removeTurn = useCallback4(
|
|
3625
3058
|
async (turnId) => {
|
|
3626
3059
|
const result = await mutate(
|
|
3627
3060
|
turnId,
|
|
@@ -3643,7 +3076,7 @@ function useTurnQueue(sessionId, options = {}) {
|
|
|
3643
3076
|
() => Object.keys(visiblePendingByTurn).length > 0,
|
|
3644
3077
|
[visiblePendingByTurn]
|
|
3645
3078
|
);
|
|
3646
|
-
const mutationFor =
|
|
3079
|
+
const mutationFor = useCallback4(
|
|
3647
3080
|
(turnId) => visiblePendingByTurn[turnId] ?? null,
|
|
3648
3081
|
[visiblePendingByTurn]
|
|
3649
3082
|
);
|
|
@@ -3667,7 +3100,7 @@ function useTurnQueue(sessionId, options = {}) {
|
|
|
3667
3100
|
mutationFor,
|
|
3668
3101
|
mutating,
|
|
3669
3102
|
mutationError: identityMatches ? mutationError : null,
|
|
3670
|
-
clearMutationError:
|
|
3103
|
+
clearMutationError: useCallback4(() => {
|
|
3671
3104
|
if (targetKeyRef.current === targetKey) setMutationError(null);
|
|
3672
3105
|
}, [targetKey]),
|
|
3673
3106
|
acceptedSteers: identityMatches ? acceptedSteers : []
|
|
@@ -3683,820 +3116,1380 @@ function isOutcomeUnknownError(cause) {
|
|
|
3683
3116
|
return typeof cause === "object" && cause !== null && cause.outcomeUnknown === true;
|
|
3684
3117
|
}
|
|
3685
3118
|
|
|
3686
|
-
// src/hooks/use-
|
|
3687
|
-
import {
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
const catalog = useWorkspaceModelCatalog({ ...scope, enabled: showModelPicker });
|
|
3695
|
-
const feed = useSessionEvents(sessionId, scope);
|
|
3696
|
-
const pendingPrompt = usePendingPrompt(initialPrompt, sessionId, feed.initialHistoryReady);
|
|
3697
|
-
const eventOptions = { ...scope, events: feed.events };
|
|
3698
|
-
const detail = useSession(sessionId, eventOptions);
|
|
3699
|
-
const queue = useTurnQueue(sessionId, eventOptions);
|
|
3700
|
-
const human = useHumanInputRequests(sessionId, eventOptions);
|
|
3701
|
-
const control = useSessionControl(sessionId, scope);
|
|
3702
|
-
const approvals = useMemo4(() => projectPendingApprovals(feed.events), [feed.events]);
|
|
3703
|
-
const files = useFileAttachments({ ...scope, scope: uploadScopeForSession(detail.session) });
|
|
3704
|
-
const clearFiles = files.clear;
|
|
3705
|
-
const attachmentSession = useRef7(sessionId);
|
|
3706
|
-
useLayoutEffect3(() => {
|
|
3707
|
-
if (attachmentSession.current === sessionId) return;
|
|
3708
|
-
const created = attachmentSession.current === null;
|
|
3709
|
-
attachmentSession.current = sessionId;
|
|
3710
|
-
if (created) return;
|
|
3711
|
-
clearFiles();
|
|
3712
|
-
}, [clearFiles, sessionId]);
|
|
3713
|
-
const uploadsEnabled = (options.attachments ?? true) && config.uploads;
|
|
3714
|
-
const status = feed.sessionStatus ?? detail.session?.status;
|
|
3715
|
-
const terminal = status === "cancelled" || (detail.session ? sessionArchived(detail.session) : false);
|
|
3716
|
-
const importedArchive = detail.session?.importedArchive?.readOnly === true;
|
|
3717
|
-
const host = options.composerOptions;
|
|
3718
|
-
const resolveExtras = () => typeof host?.sendExtras === "function" ? host.sendExtras() : host?.sendExtras;
|
|
3719
|
-
const releaseSentFiles = (input) => files.removeReadyFiles(
|
|
3720
|
-
(input.resources ?? []).flatMap(
|
|
3721
|
-
(resource) => resource.kind === "file" ? [resource.fileId] : []
|
|
3722
|
-
)
|
|
3723
|
-
);
|
|
3724
|
-
const composer = useComposer(sessionId, {
|
|
3725
|
-
...eventOptions,
|
|
3726
|
-
initialDraft: host?.initialDraft,
|
|
3727
|
-
busySend: host?.busySend,
|
|
3728
|
-
offerQueue: host?.offerQueue,
|
|
3729
|
-
effectiveControl: queue.effectiveControl ?? detail.session?.effectiveControl,
|
|
3730
|
-
// As in the console and the native screen: a turn that is still current
|
|
3731
|
-
// (running or recovering) means a Send waits. A turn parked on provider
|
|
3732
|
-
// capacity does not: the Send replaces it and starts right away.
|
|
3733
|
-
sendDestination: () => promptSendDestination({
|
|
3734
|
-
status,
|
|
3735
|
-
activeTurnId: detail.session?.activeTurnId,
|
|
3736
|
-
queuedPrompts: queue.queue.length,
|
|
3737
|
-
admissionBlock: detail.session?.admissionBlock
|
|
3738
|
-
}),
|
|
3739
|
-
sendExtras: () => {
|
|
3740
|
-
const extras = resolveExtras();
|
|
3741
|
-
return {
|
|
3742
|
-
...extras,
|
|
3743
|
-
resources: [...extras?.resources ?? [], ...uploadsEnabled ? files.readyResources : []]
|
|
3744
|
-
};
|
|
3745
|
-
},
|
|
3746
|
-
sendBlocked: () => sessionId === null || terminal || importedArchive || uploadsEnabled && files.hasUnresolved || host?.sendBlocked?.() === true,
|
|
3747
|
-
onSubmitted: (text, input) => {
|
|
3748
|
-
releaseSentFiles(input);
|
|
3749
|
-
return host?.onSubmitted?.(text, input);
|
|
3750
|
-
},
|
|
3751
|
-
onSent: (text, input) => {
|
|
3752
|
-
releaseSentFiles(input);
|
|
3753
|
-
return host?.onSent?.(text, input);
|
|
3754
|
-
},
|
|
3755
|
-
onDeliveryError: host?.onDeliveryError
|
|
3756
|
-
});
|
|
3757
|
-
const conversation = useMemo4(
|
|
3758
|
-
() => conversationTimeline(feed.timeline, queue, composer),
|
|
3759
|
-
[feed.timeline, queue, composer]
|
|
3760
|
-
);
|
|
3761
|
-
const session = detail.session;
|
|
3762
|
-
const sessionControl = session?.effectiveControl;
|
|
3763
|
-
const timeline = useSessionStartupTimeline(conversation, {
|
|
3764
|
-
session: session && sessionControl ? {
|
|
3765
|
-
...session,
|
|
3766
|
-
effectiveControl: admissionRecheckControl(
|
|
3767
|
-
sessionControl,
|
|
3768
|
-
queue.effectiveControl,
|
|
3769
|
-
composer.effectiveControl
|
|
3770
|
-
)
|
|
3771
|
-
} : null,
|
|
3772
|
-
events: feed.events,
|
|
3773
|
-
optimisticMessages: composer.optimisticMessages,
|
|
3774
|
-
hasNewer: feed.hasNewer,
|
|
3775
|
-
queue: queue.snapshot,
|
|
3776
|
-
pendingPrompt,
|
|
3777
|
-
historyReady: sessionId !== null && feed.initialHistoryReady
|
|
3778
|
-
});
|
|
3779
|
-
const error = detail.error ?? feed.error ?? human.error;
|
|
3780
|
-
const loadFailed = Boolean(feed.error) && !feed.initialHistoryReady;
|
|
3781
|
-
const retry = async () => {
|
|
3782
|
-
await Promise.all([
|
|
3783
|
-
...detail.error ? [detail.refresh()] : [],
|
|
3784
|
-
...human.error ? [human.refresh()] : [],
|
|
3785
|
-
...feed.error ? [feed.jumpToLatest()] : []
|
|
3786
|
-
]);
|
|
3787
|
-
};
|
|
3788
|
-
return {
|
|
3789
|
-
...scope,
|
|
3790
|
-
sessionId,
|
|
3791
|
-
config,
|
|
3792
|
-
catalog,
|
|
3793
|
-
showModelPicker,
|
|
3794
|
-
feed,
|
|
3795
|
-
detail,
|
|
3796
|
-
queue,
|
|
3797
|
-
human,
|
|
3798
|
-
control,
|
|
3799
|
-
approvals,
|
|
3800
|
-
files,
|
|
3801
|
-
uploadsEnabled,
|
|
3802
|
-
composer,
|
|
3803
|
-
/** The same live application context for text and durable voice messages. */
|
|
3804
|
-
getModelContext: () => resolveExtras()?.modelContext,
|
|
3805
|
-
timeline,
|
|
3806
|
-
status,
|
|
3807
|
-
terminal,
|
|
3808
|
-
importedArchive,
|
|
3809
|
-
running: sessionTurnKeepsRunControl(status),
|
|
3810
|
-
error,
|
|
3811
|
-
loadFailed,
|
|
3812
|
-
retry
|
|
3813
|
-
};
|
|
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.");
|
|
3814
3127
|
}
|
|
3815
|
-
function
|
|
3816
|
-
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,
|
|
3817
3271
|
sessionId,
|
|
3818
|
-
|
|
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();
|
|
3819
3284
|
});
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
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(
|
|
3846
3334
|
() => () => {
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3335
|
+
goalRef.current = null;
|
|
3336
|
+
const waiters = readWaitersRef.current;
|
|
3337
|
+
readWaitersRef.current = [];
|
|
3338
|
+
for (const resolve of waiters) resolve();
|
|
3850
3339
|
},
|
|
3851
|
-
[]
|
|
3340
|
+
[workspaceId, sessionId]
|
|
3852
3341
|
);
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
if (!
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
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 } : {}
|
|
3358
|
+
})
|
|
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;
|
|
3881
3480
|
}
|
|
3882
|
-
receipt.current = null;
|
|
3883
3481
|
});
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
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
|
+
};
|
|
3887
3513
|
}
|
|
3888
3514
|
|
|
3889
|
-
// src/hooks/use-
|
|
3890
|
-
import {
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
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]
|
|
3522
|
+
);
|
|
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
|
|
3533
|
+
};
|
|
3534
|
+
}
|
|
3535
|
+
function useWorkspaceModelCatalog(options) {
|
|
3899
3536
|
const t = useOpenGeniText();
|
|
3900
|
-
const
|
|
3901
|
-
const
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
const [completion, setCompletion] = useState6(null);
|
|
3919
|
-
const textRef = useRef9(text);
|
|
3920
|
-
const textRevision = useRef9(0);
|
|
3921
|
-
const choiceRef = useRef9(choice);
|
|
3922
|
-
const levelsRef = useRef9(NO_LEVELS);
|
|
3923
|
-
const setModelLevels = useCallback8((levels = NO_LEVELS) => {
|
|
3924
|
-
const previous = levelsRef.current;
|
|
3925
|
-
if (previous.length === levels.length && previous.every((level, index) => {
|
|
3926
|
-
const next = levels[index];
|
|
3927
|
-
return next?.model === level.model && next.effort === level.effort;
|
|
3928
|
-
}))
|
|
3929
|
-
return;
|
|
3930
|
-
levelsRef.current = levels;
|
|
3931
|
-
setLevels(levels);
|
|
3932
|
-
}, []);
|
|
3933
|
-
const filesRef = useRef9(files);
|
|
3934
|
-
filesRef.current = files;
|
|
3935
|
-
const pendingRef = useRef9(null);
|
|
3936
|
-
const completionRef = useRef9(null);
|
|
3937
|
-
const inFlight = useRef9(false);
|
|
3938
|
-
const lifetime = useRef9({ mounted: true, generation: 0 }).current;
|
|
3939
|
-
const identity = useMemo6(
|
|
3940
|
-
() => ({
|
|
3941
|
-
client: context.client,
|
|
3942
|
-
workspaceId: context.workspaceId,
|
|
3943
|
-
scopeKey: options.scopeKey
|
|
3944
|
-
}),
|
|
3945
|
-
[context.client, context.workspaceId, options.scopeKey]
|
|
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]
|
|
3946
3555
|
);
|
|
3947
|
-
const
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
return () => {
|
|
3951
|
-
lifetime.mounted = false;
|
|
3952
|
-
lifetime.generation++;
|
|
3953
|
-
};
|
|
3954
|
-
}, [lifetime]);
|
|
3955
|
-
useLayoutEffect4(() => {
|
|
3956
|
-
if (committedIdentity.current === identity) return;
|
|
3957
|
-
committedIdentity.current = identity;
|
|
3958
|
-
lifetime.generation++;
|
|
3959
|
-
inFlight.current = false;
|
|
3960
|
-
pendingRef.current = null;
|
|
3961
|
-
completionRef.current = null;
|
|
3962
|
-
textRef.current = "";
|
|
3963
|
-
textRevision.current = 0;
|
|
3964
|
-
choiceRef.current = EMPTY_CHOICE;
|
|
3965
|
-
setText("");
|
|
3966
|
-
setChoice(EMPTY_CHOICE);
|
|
3967
|
-
setSending(false);
|
|
3968
|
-
setError(null);
|
|
3969
|
-
setPending(null);
|
|
3970
|
-
setCompletion(null);
|
|
3971
|
-
filesRef.current.clear();
|
|
3972
|
-
}, [identity, lifetime]);
|
|
3973
|
-
const ownsScope = () => lifetime.mounted && committedIdentity.current === identity;
|
|
3974
|
-
const updateText = (value) => {
|
|
3975
|
-
if (!ownsScope()) return;
|
|
3976
|
-
if (value !== textRef.current) textRevision.current++;
|
|
3977
|
-
textRef.current = value;
|
|
3978
|
-
setText(value);
|
|
3979
|
-
};
|
|
3980
|
-
const updateChoice = (patch) => {
|
|
3981
|
-
if (!ownsScope()) return;
|
|
3982
|
-
const base = patch.model === void 0 ? creationChoice() : choiceRef.current;
|
|
3983
|
-
const next = { ...base, ...patch };
|
|
3984
|
-
const model = catalog.models.find((row) => row.id === (next.model ?? defaultModel));
|
|
3985
|
-
if (model) {
|
|
3986
|
-
if (next.reasoningEffort)
|
|
3987
|
-
next.reasoningEffort = coerceReasoningEffortForModel(model, next.reasoningEffort);
|
|
3988
|
-
if (next.latencyMode && !runnableLatencyModesForModel(model).includes(next.latencyMode))
|
|
3989
|
-
next.latencyMode = "standard";
|
|
3990
|
-
}
|
|
3991
|
-
choiceRef.current = next;
|
|
3992
|
-
setChoice(choiceRef.current);
|
|
3993
|
-
if (!pendingRef.current) setError(null);
|
|
3994
|
-
};
|
|
3995
|
-
const displayPolicy = (selected) => {
|
|
3996
|
-
const model = selected.model ?? defaultModel;
|
|
3997
|
-
const definition = catalog.models.find((row) => row.id === model);
|
|
3998
|
-
const effort = selected.reasoningEffort ?? (definition ? defaultEffortForModel(definition) : config.defaultReasoningEffort ?? "medium");
|
|
3999
|
-
return showModelPicker && model ? {
|
|
4000
|
-
model,
|
|
4001
|
-
reasoningEffort: definition ? coerceReasoningEffortForModel(definition, effort) : effort,
|
|
4002
|
-
latencyMode: selected.latencyMode ?? "standard"
|
|
4003
|
-
} : void 0;
|
|
4004
|
-
};
|
|
4005
|
-
const creationChoice = () => {
|
|
4006
|
-
const selected = choiceRef.current;
|
|
4007
|
-
if (preferredModel) return { model: preferredModel, ...selected };
|
|
4008
|
-
if (selected !== EMPTY_CHOICE || !showModelPicker || catalog.loading || !levelsRef.current.length)
|
|
4009
|
-
return selected;
|
|
4010
|
-
const workspace = displayPolicy(EMPTY_CHOICE);
|
|
4011
|
-
const view = modelLevelsView(t, {
|
|
4012
|
-
levels: levelsRef.current,
|
|
4013
|
-
rows: catalog.rows,
|
|
4014
|
-
model: workspace?.model ?? "",
|
|
4015
|
-
effort: workspace?.reasoningEffort ?? "medium",
|
|
4016
|
-
latencyMode: "standard"
|
|
4017
|
-
});
|
|
4018
|
-
const first = view && view.index < 0 ? modelLevelChoice(view, 0, false) : null;
|
|
4019
|
-
return first ? { model: first.model, reasoningEffort: first.effort } : selected;
|
|
4020
|
-
};
|
|
4021
|
-
const create = options.createSession ?? (async (initialMessage, idempotencyKey, input) => {
|
|
4022
|
-
const creator = context.client.createSession;
|
|
4023
|
-
if (typeof creator !== "function")
|
|
4024
|
-
throw new Error(t("hooks.useNewConversation.newChatsAreNotEnabled"));
|
|
4025
|
-
const created = await creator.call(context.client, context.workspaceId, {
|
|
4026
|
-
...input.startMode === "realtime" ? {} : { initialMessage },
|
|
4027
|
-
idempotencyKey,
|
|
4028
|
-
...input
|
|
4029
|
-
});
|
|
4030
|
-
return created.id;
|
|
3556
|
+
const state = useSharedQuery(client, ["workspace-model-catalog", options.workspaceId], load, {
|
|
3557
|
+
pollIntervalMs: options.pollIntervalMs,
|
|
3558
|
+
enabled: options.enabled !== false && Boolean(options.workspaceId)
|
|
4031
3559
|
});
|
|
4032
|
-
const
|
|
4033
|
-
if (!lifetime.mounted || lifetime.generation !== accepted.generation) return;
|
|
4034
|
-
const { attempt, sessionId } = accepted;
|
|
4035
|
-
const sentFiles = new Set(attempt.options.resources?.map((resource) => resource.fileId) ?? []);
|
|
4036
|
-
const selected = showModelPicker ? creationChoice() : EMPTY_CHOICE;
|
|
4037
|
-
const policyChanged = ["model", "reasoningEffort", "latencyMode"].some(
|
|
4038
|
-
(field) => selected[field] !== attempt.options[field]
|
|
4039
|
-
);
|
|
4040
|
-
const draft = {
|
|
4041
|
-
text: attempt.clearDraft && textRevision.current === attempt.textRevision ? "" : textRef.current,
|
|
4042
|
-
resources: filesRef.current.readyResources.filter(
|
|
4043
|
-
(resource) => !sentFiles.has(resource.fileId)
|
|
4044
|
-
),
|
|
4045
|
-
// Unchanged choices are already part of the created session. Do not
|
|
4046
|
-
// replace server-owned defaults with a browser's catalog estimate.
|
|
4047
|
-
...policyChanged ? { policy: displayPolicy(selected) } : {}
|
|
4048
|
-
};
|
|
4049
|
-
pendingRef.current = null;
|
|
4050
|
-
completionRef.current = null;
|
|
4051
|
-
setPending(null);
|
|
4052
|
-
setCompletion(null);
|
|
4053
|
-
updateText(draft.text);
|
|
4054
|
-
filesRef.current.removeReadyFiles(sentFiles);
|
|
4055
|
-
notifyObserver(options.onCreated, {
|
|
4056
|
-
sessionId,
|
|
4057
|
-
initialMessage: attempt.initialMessage,
|
|
4058
|
-
sentAt: attempt.sentAt,
|
|
4059
|
-
draft,
|
|
4060
|
-
...attempt.realtimeModel ? { realtimeModel: attempt.realtimeModel } : {}
|
|
4061
|
-
});
|
|
4062
|
-
};
|
|
4063
|
-
const finishRef = useRef9(finishCreation);
|
|
4064
|
-
finishRef.current = finishCreation;
|
|
4065
|
-
useLayoutEffect4(() => {
|
|
4066
|
-
if (completion && !files.hasUnresolved) finishRef.current(completion);
|
|
4067
|
-
}, [completion, files.hasUnresolved]);
|
|
4068
|
-
const deliver = async (attempt) => {
|
|
4069
|
-
if (!ownsScope() || inFlight.current || completionRef.current || !available) return false;
|
|
4070
|
-
const ownedGeneration = lifetime.generation;
|
|
4071
|
-
inFlight.current = true;
|
|
4072
|
-
pendingRef.current = attempt;
|
|
4073
|
-
setSending(true);
|
|
4074
|
-
setError(null);
|
|
4075
|
-
setPending(null);
|
|
4076
|
-
try {
|
|
4077
|
-
const sessionId = await attempt.create(
|
|
4078
|
-
attempt.initialMessage,
|
|
4079
|
-
attempt.key,
|
|
4080
|
-
structuredClone(attempt.options)
|
|
4081
|
-
);
|
|
4082
|
-
if (!lifetime.mounted || lifetime.generation !== ownedGeneration) return true;
|
|
4083
|
-
const accepted = { sessionId, attempt, generation: ownedGeneration };
|
|
4084
|
-
completionRef.current = accepted;
|
|
4085
|
-
if (filesRef.current.hasUnresolved) setCompletion(accepted);
|
|
4086
|
-
else finishCreation(accepted);
|
|
4087
|
-
return true;
|
|
4088
|
-
} catch (cause) {
|
|
4089
|
-
if (!lifetime.mounted || lifetime.generation !== ownedGeneration) return false;
|
|
4090
|
-
setError({ cause });
|
|
4091
|
-
if (cause instanceof OpenGeniApiError && cause.outcomeUnknown === false) {
|
|
4092
|
-
pendingRef.current = null;
|
|
4093
|
-
} else {
|
|
4094
|
-
setPending(attempt);
|
|
4095
|
-
}
|
|
4096
|
-
return false;
|
|
4097
|
-
} finally {
|
|
4098
|
-
if (lifetime.mounted && lifetime.generation === ownedGeneration) {
|
|
4099
|
-
inFlight.current = false;
|
|
4100
|
-
setSending(false);
|
|
4101
|
-
}
|
|
4102
|
-
}
|
|
4103
|
-
};
|
|
4104
|
-
const submit = async (explicit) => {
|
|
4105
|
-
if (!ownsScope() || !available || inFlight.current || pendingRef.current || uploadsEnabled && filesRef.current.hasUnresolved)
|
|
4106
|
-
return false;
|
|
4107
|
-
const resources = uploadsEnabled ? filesRef.current.readyResources : [];
|
|
4108
|
-
const draftText = explicit ?? textRef.current;
|
|
4109
|
-
const initialMessage = draftText.trim() || (resources.length > 0 ? FILE_ONLY_MESSAGE_TEXT(t) : "");
|
|
4110
|
-
if (!initialMessage) return false;
|
|
4111
|
-
return deliver({
|
|
4112
|
-
key: crypto.randomUUID(),
|
|
4113
|
-
initialMessage,
|
|
4114
|
-
sentAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4115
|
-
textRevision: textRevision.current,
|
|
4116
|
-
clearDraft: explicit === void 0,
|
|
4117
|
-
create,
|
|
4118
|
-
options: {
|
|
4119
|
-
...resources.length ? { resources: structuredClone(resources) } : {},
|
|
4120
|
-
...showModelPicker ? creationChoice() : {}
|
|
4121
|
-
}
|
|
4122
|
-
});
|
|
4123
|
-
};
|
|
4124
|
-
const startRealtime = async (model) => {
|
|
4125
|
-
if (!ownsScope() || !available || inFlight.current || pendingRef.current || !config.realtimeVoice || !(options.realtimeVoice ?? config.realtimeVoiceOffered))
|
|
4126
|
-
return false;
|
|
4127
|
-
if (filesRef.current.hasUnresolved) return false;
|
|
4128
|
-
return deliver({
|
|
4129
|
-
key: crypto.randomUUID(),
|
|
4130
|
-
initialMessage: "",
|
|
4131
|
-
sentAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4132
|
-
textRevision: textRevision.current,
|
|
4133
|
-
clearDraft: false,
|
|
4134
|
-
create,
|
|
4135
|
-
options: {
|
|
4136
|
-
...showModelPicker ? creationChoice() : {},
|
|
4137
|
-
startMode: "realtime"
|
|
4138
|
-
},
|
|
4139
|
-
realtimeModel: model
|
|
4140
|
-
});
|
|
4141
|
-
};
|
|
4142
|
-
const composer = {
|
|
4143
|
-
value: text,
|
|
4144
|
-
setValue: updateText,
|
|
4145
|
-
hasDraftContent: () => textRef.current.length > 0 || filesRef.current.attachments.length > 0,
|
|
4146
|
-
send: submit,
|
|
4147
|
-
steer: submit,
|
|
4148
|
-
// Nothing runs before the conversation exists: Send just sends.
|
|
4149
|
-
working: false,
|
|
4150
|
-
sending,
|
|
4151
|
-
canSend: available && !sending && !pending && !completion && (text.trim().length > 0 || uploadsEnabled && files.readyResources.length > 0) && !(uploadsEnabled && files.hasUnresolved),
|
|
4152
|
-
pause: NOOP_ASYNC,
|
|
4153
|
-
pausing: false,
|
|
4154
|
-
resume: NOOP_ASYNC,
|
|
4155
|
-
resumeScope: NOOP_ASYNC,
|
|
4156
|
-
resuming: false,
|
|
4157
|
-
draft: null,
|
|
4158
|
-
draftRevision: 0,
|
|
4159
|
-
draftLoading: false,
|
|
4160
|
-
draftSaving: false,
|
|
4161
|
-
draftConflict: null,
|
|
4162
|
-
policy: displayPolicy(creationChoice()) ?? null,
|
|
4163
|
-
setModel: (model) => updateChoice({ model }),
|
|
4164
|
-
setReasoningEffort: (reasoningEffort) => updateChoice({ reasoningEffort }),
|
|
4165
|
-
setLatencyMode: (latencyMode) => updateChoice({ latencyMode }),
|
|
4166
|
-
draftPersistence: "disabled",
|
|
4167
|
-
applyDraft: () => {
|
|
4168
|
-
},
|
|
4169
|
-
reloadDraft: NOOP_ASYNC,
|
|
4170
|
-
resolveDraftConflict: NOOP_ASYNC,
|
|
4171
|
-
restoredResources: [],
|
|
4172
|
-
removeRestoredResource: () => {
|
|
4173
|
-
},
|
|
4174
|
-
error: null,
|
|
4175
|
-
clearError: () => {
|
|
4176
|
-
if (ownsScope()) setError(null);
|
|
4177
|
-
}
|
|
4178
|
-
};
|
|
3560
|
+
const rows = sortPickerRows(projectPickerRows(t, state.data?.models ?? []));
|
|
4179
3561
|
return {
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
setModelLevels,
|
|
4187
|
-
setModelPolicy: updateChoice,
|
|
4188
|
-
catalog,
|
|
4189
|
-
composer,
|
|
4190
|
-
realtimeVoiceEnabled: config.realtimeVoice && (options.realtimeVoice ?? config.realtimeVoiceOffered),
|
|
4191
|
-
error,
|
|
4192
|
-
finishingUploads: completion !== null,
|
|
4193
|
-
pending: pending ? { idempotencyKey: pending.key, realtimeModel: pending.realtimeModel } : null,
|
|
4194
|
-
retry: () => pendingRef.current ? deliver(pendingRef.current) : Promise.resolve(false),
|
|
4195
|
-
startRealtime
|
|
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
|
|
4196
3568
|
};
|
|
4197
3569
|
}
|
|
4198
3570
|
|
|
4199
|
-
// src/hooks/use-
|
|
4200
|
-
import {
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
} from "@opengeni/sdk";
|
|
4204
|
-
import { useCallback as useCallback9, useEffect as useEffect6, useLayoutEffect as useLayoutEffect5, useRef as useRef10, useState as useState7 } from "react";
|
|
4205
|
-
function isGoalEvent(event) {
|
|
4206
|
-
return event.type.startsWith("goal.");
|
|
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";
|
|
4207
3575
|
}
|
|
4208
|
-
function
|
|
4209
|
-
const
|
|
4210
|
-
return isGoalEvent(event) || type.startsWith("turn.") || type.startsWith("session.") || type.startsWith("system.update.") || type.startsWith("workspace.inference.") || type.startsWith("user.");
|
|
4211
|
-
}
|
|
4212
|
-
function useGoal(sessionId, options = {}) {
|
|
4213
|
-
const { client, workspaceId } = useEmbeddedGoal(options);
|
|
3576
|
+
function useHumanInputRequests(sessionId, options = {}) {
|
|
3577
|
+
const { client, workspaceId, registerSessionReconciler } = useEmbeddedHumanInputSession(options);
|
|
4214
3578
|
const enabled = (options.enabled ?? true) && Boolean(sessionId);
|
|
4215
|
-
const
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
const loadAbort = useRef10(null);
|
|
4232
|
-
const scheduleRefreshRef = useRef10(() => void 0);
|
|
4233
|
-
const retireLoads = useCallback9(() => {
|
|
4234
|
-
generation.current += 1;
|
|
4235
|
-
loadAbort.current?.abort();
|
|
4236
|
-
loadAbort.current = null;
|
|
4237
|
-
}, []);
|
|
4238
|
-
const load = useCallback9(async () => {
|
|
4239
|
-
if (!sessionId) {
|
|
4240
|
-
return;
|
|
4241
|
-
}
|
|
4242
|
-
const ticket = ++generation.current;
|
|
4243
|
-
pendingRefreshRef.current = "none";
|
|
4244
|
-
loadAbort.current?.abort();
|
|
4245
|
-
const controller = new AbortController();
|
|
4246
|
-
loadAbort.current = controller;
|
|
4247
|
-
let fetchedGoal = null;
|
|
4248
|
-
try {
|
|
4249
|
-
const fetched = typeof client.findGoal === "function" ? await client.findGoal(workspaceId, sessionId, { signal: controller.signal }) : await client.getGoal(workspaceId, sessionId, { signal: controller.signal });
|
|
4250
|
-
fetchedGoal = fetched;
|
|
4251
|
-
if (ticket === generation.current) {
|
|
4252
|
-
goalAbsentRef.current = fetched === null;
|
|
4253
|
-
setReadAbsent(fetched === null);
|
|
4254
|
-
setGoal(fetched);
|
|
4255
|
-
setError(null);
|
|
4256
|
-
setLoading(false);
|
|
4257
|
-
}
|
|
4258
|
-
} catch (cause) {
|
|
4259
|
-
if (ticket !== generation.current) {
|
|
4260
|
-
return;
|
|
4261
|
-
}
|
|
4262
|
-
if (cause instanceof OpenGeniApiError2 && cause.status === 404) {
|
|
4263
|
-
goalAbsentRef.current = true;
|
|
4264
|
-
setReadAbsent(true);
|
|
4265
|
-
setGoal(null);
|
|
4266
|
-
setError(null);
|
|
4267
|
-
} else {
|
|
4268
|
-
setError(normalizeError(cause));
|
|
4269
|
-
}
|
|
4270
|
-
setLoading(false);
|
|
4271
|
-
} finally {
|
|
4272
|
-
if (loadAbort.current === controller) loadAbort.current = null;
|
|
4273
|
-
}
|
|
4274
|
-
if (ticket !== generation.current || pendingRefreshRef.current === "none") {
|
|
4275
|
-
return;
|
|
4276
|
-
}
|
|
4277
|
-
const readThrough = fetchedGoal ? observedSessionSequence(fetchedGoal) : void 0;
|
|
4278
|
-
if (readThrough !== void 0 && sharedEventsRef.current !== void 0) {
|
|
4279
|
-
const events = sharedEventsRef.current;
|
|
4280
|
-
const newest = events[events.length - 1];
|
|
4281
|
-
if (!newest || newest.sequence <= readThrough) {
|
|
4282
|
-
pendingRefreshRef.current = "none";
|
|
4283
|
-
return;
|
|
4284
|
-
}
|
|
4285
|
-
}
|
|
4286
|
-
if (goalAbsentRef.current && pendingRefreshRef.current === "refresh") {
|
|
4287
|
-
const events = sharedEventsRef.current ?? [];
|
|
4288
|
-
let latestGoalEvent;
|
|
4289
|
-
for (let index = events.length - 1; index >= 0 && !latestGoalEvent; index -= 1) {
|
|
4290
|
-
const event = events[index];
|
|
4291
|
-
if (event && isGoalEvent(event)) latestGoalEvent = event;
|
|
4292
|
-
}
|
|
4293
|
-
if (!latestGoalEvent || latestGoalEvent.type === "goal.cleared") {
|
|
4294
|
-
pendingRefreshRef.current = "none";
|
|
4295
|
-
return;
|
|
4296
|
-
}
|
|
4297
|
-
pendingRefreshRef.current = "goal";
|
|
4298
|
-
}
|
|
4299
|
-
scheduleRefreshRef.current();
|
|
4300
|
-
}, [client, workspaceId, sessionId]);
|
|
4301
|
-
useEffect6(() => {
|
|
4302
|
-
const targetKey = `${workspaceId} ${sessionId ?? ""}`;
|
|
4303
|
-
if (targetKeyRef.current !== targetKey) {
|
|
4304
|
-
targetKeyRef.current = targetKey;
|
|
4305
|
-
goalAbsentRef.current = false;
|
|
4306
|
-
pendingRefreshRef.current = "none";
|
|
4307
|
-
setReadAbsent(false);
|
|
4308
|
-
setGoal(null);
|
|
4309
|
-
setError(null);
|
|
4310
|
-
}
|
|
4311
|
-
if (!enabled || !pageLive) {
|
|
4312
|
-
retireLoads();
|
|
4313
|
-
setLoading(false);
|
|
4314
|
-
return;
|
|
4315
|
-
}
|
|
4316
|
-
if (sharedFeed) {
|
|
4317
|
-
setLoading(true);
|
|
4318
|
-
void load();
|
|
4319
|
-
return () => {
|
|
4320
|
-
retireLoads();
|
|
4321
|
-
};
|
|
4322
|
-
}
|
|
4323
|
-
setLoading(true);
|
|
4324
|
-
const pollIntervalMs = options.pollIntervalMs;
|
|
4325
|
-
if (pollIntervalMs === void 0 || pollIntervalMs <= 0) {
|
|
4326
|
-
void load();
|
|
4327
|
-
return () => {
|
|
4328
|
-
retireLoads();
|
|
4329
|
-
};
|
|
4330
|
-
}
|
|
4331
|
-
let cancelled = false;
|
|
4332
|
-
let timer = null;
|
|
4333
|
-
const schedule = () => {
|
|
4334
|
-
if (cancelled) return;
|
|
4335
|
-
timer = setTimeout(() => {
|
|
4336
|
-
timer = null;
|
|
4337
|
-
void load().finally(schedule);
|
|
4338
|
-
}, pollIntervalMs);
|
|
4339
|
-
};
|
|
4340
|
-
void load().finally(schedule);
|
|
4341
|
-
return () => {
|
|
4342
|
-
cancelled = true;
|
|
4343
|
-
if (timer !== null) clearTimeout(timer);
|
|
4344
|
-
retireLoads();
|
|
4345
|
-
};
|
|
4346
|
-
}, [
|
|
4347
|
-
load,
|
|
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"
|
|
3584
|
+
});
|
|
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, {
|
|
4348
3595
|
enabled,
|
|
4349
|
-
|
|
3596
|
+
pollIntervalMs: options.pollIntervalMs
|
|
3597
|
+
});
|
|
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,
|
|
4350
3625
|
workspaceId,
|
|
4351
3626
|
sessionId,
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
]);
|
|
4356
|
-
const scheduleRefresh = useDebouncedCallback(() => {
|
|
4357
|
-
const pending = pendingRefreshRef.current;
|
|
4358
|
-
if (pending === "none" || loadAbort.current !== null) return;
|
|
4359
|
-
if (pending === "refresh" && goalAbsentRef.current) {
|
|
4360
|
-
pendingRefreshRef.current = "none";
|
|
4361
|
-
return;
|
|
4362
|
-
}
|
|
4363
|
-
void load();
|
|
4364
|
-
});
|
|
4365
|
-
useLayoutEffect5(() => {
|
|
4366
|
-
scheduleRefreshRef.current = scheduleRefresh;
|
|
4367
|
-
}, [scheduleRefresh]);
|
|
4368
|
-
const isRefreshEvent = useCallback9(
|
|
4369
|
-
(event) => goalAbsentRef.current ? isGoalEvent(event) : isGoalRefreshEvent(event),
|
|
4370
|
-
[]
|
|
3627
|
+
"human-input",
|
|
3628
|
+
state.data,
|
|
3629
|
+
{ enabled, discard: deniesRetainedView(state.error) }
|
|
4371
3630
|
);
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
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))
|
|
3646
|
+
);
|
|
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
|
+
}
|
|
3667
|
+
}
|
|
4381
3668
|
},
|
|
4382
|
-
[
|
|
3669
|
+
[client, mutation, sessionId, state, workspaceId]
|
|
4383
3670
|
);
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
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
|
|
3684
|
+
};
|
|
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
|
|
3970
|
+
}
|
|
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
|
+
};
|
|
4036
|
+
},
|
|
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);
|
|
4041
|
+
},
|
|
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
|
+
]);
|
|
4078
|
+
};
|
|
4079
|
+
return {
|
|
4080
|
+
...scope,
|
|
4081
|
+
sessionId,
|
|
4082
|
+
config,
|
|
4083
|
+
catalog,
|
|
4084
|
+
showModelPicker,
|
|
4085
|
+
feed,
|
|
4086
|
+
detail,
|
|
4087
|
+
queue,
|
|
4088
|
+
human,
|
|
4089
|
+
control,
|
|
4090
|
+
approvals,
|
|
4091
|
+
files,
|
|
4092
|
+
uploadsEnabled,
|
|
4093
|
+
composer,
|
|
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),
|
|
4101
|
+
error,
|
|
4102
|
+
loadFailed,
|
|
4103
|
+
retry
|
|
4104
|
+
};
|
|
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
|
+
}
|
|
4179
|
+
|
|
4180
|
+
// src/hooks/use-new-conversation.ts
|
|
4181
|
+
import {
|
|
4182
|
+
OpenGeniApiError as OpenGeniApiError2
|
|
4183
|
+
} from "@opengeni/sdk";
|
|
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);
|
|
4207
|
+
const [error, setError] = useState7(null);
|
|
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
|
+
}))
|
|
4220
|
+
return;
|
|
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;
|
|
4241
|
+
return () => {
|
|
4242
|
+
lifetime.mounted = false;
|
|
4243
|
+
lifetime.generation++;
|
|
4244
|
+
};
|
|
4245
|
+
}, [lifetime]);
|
|
4246
|
+
useLayoutEffect5(() => {
|
|
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;
|
|
4390
4322
|
});
|
|
4391
|
-
const
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
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;
|
|
4403
4356
|
useLayoutEffect5(() => {
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
},
|
|
4420
|
-
[workspaceId, sessionId]
|
|
4421
|
-
);
|
|
4422
|
-
const aimedAtCurrentGoal = useCallback9(async () => {
|
|
4423
|
-
const shown = shownRetainedRef.current;
|
|
4424
|
-
if (!shown) return true;
|
|
4425
|
-
await new Promise((resolve) => readWaitersRef.current.push(resolve));
|
|
4426
|
-
const fresh = goalRef.current;
|
|
4427
|
-
return fresh !== null && fresh.id === shown.id && fresh.objectiveRevision === shown.objectiveRevision;
|
|
4428
|
-
}, []);
|
|
4429
|
-
const pause = useCallback9(
|
|
4430
|
-
async (rationale) => {
|
|
4431
|
-
if (!sessionId || !await aimedAtCurrentGoal()) {
|
|
4432
|
-
return null;
|
|
4433
|
-
}
|
|
4434
|
-
const result = await run(
|
|
4435
|
-
() => client.updateGoal(workspaceId, sessionId, {
|
|
4436
|
-
status: "paused",
|
|
4437
|
-
...rationale !== void 0 ? { rationale } : {}
|
|
4438
|
-
})
|
|
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)
|
|
4439
4372
|
);
|
|
4440
|
-
if (
|
|
4441
|
-
|
|
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);
|
|
4442
4392
|
}
|
|
4443
|
-
return result;
|
|
4444
|
-
},
|
|
4445
|
-
[client, workspaceId, sessionId, run, aimedAtCurrentGoal]
|
|
4446
|
-
);
|
|
4447
|
-
const resume = useCallback9(async () => {
|
|
4448
|
-
if (!sessionId || !await aimedAtCurrentGoal()) {
|
|
4449
|
-
return null;
|
|
4450
|
-
}
|
|
4451
|
-
const result = await run(() => client.updateGoal(workspaceId, sessionId, { status: "active" }));
|
|
4452
|
-
if (result) {
|
|
4453
|
-
setGoal(result);
|
|
4454
|
-
}
|
|
4455
|
-
return result;
|
|
4456
|
-
}, [client, workspaceId, sessionId, run, aimedAtCurrentGoal]);
|
|
4457
|
-
const clearGoal = useCallback9(async () => {
|
|
4458
|
-
if (!sessionId || !await aimedAtCurrentGoal()) {
|
|
4459
|
-
return;
|
|
4460
4393
|
}
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
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
|
+
}
|
|
4464
4413
|
});
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
|
|
4469
|
-
|
|
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);
|
|
4470
4468
|
}
|
|
4471
|
-
}
|
|
4469
|
+
};
|
|
4472
4470
|
return {
|
|
4473
|
-
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
|
|
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),
|
|
4478
4482
|
error,
|
|
4479
|
-
|
|
4480
|
-
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
deleteGoal: clearGoal,
|
|
4484
|
-
updating: mutating,
|
|
4485
|
-
mutationError,
|
|
4486
|
-
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
|
|
4487
4487
|
};
|
|
4488
4488
|
}
|
|
4489
4489
|
|
|
4490
4490
|
export {
|
|
4491
|
-
conversationTimeline,
|
|
4492
4491
|
isTitleEvent,
|
|
4493
4492
|
useSession,
|
|
4494
|
-
useSessionStartupTimeline,
|
|
4495
|
-
useAvailableModels,
|
|
4496
|
-
useWorkspaceModelCatalog,
|
|
4497
|
-
isHumanInputEvent,
|
|
4498
|
-
useHumanInputRequests,
|
|
4499
|
-
useSessionControl,
|
|
4500
4493
|
invokeOlderHistoryLoaderWithReceiptCapture,
|
|
4501
4494
|
createOlderHistoryLoadReceipt,
|
|
4502
4495
|
useTurnlessOutputGap,
|
|
@@ -4508,10 +4501,17 @@ export {
|
|
|
4508
4501
|
boundBrowserSessionEventWindow,
|
|
4509
4502
|
isTurnQueueEvent,
|
|
4510
4503
|
useTurnQueue,
|
|
4504
|
+
isGoalEvent,
|
|
4505
|
+
useGoal,
|
|
4506
|
+
useSessionControl,
|
|
4507
|
+
useAvailableModels,
|
|
4508
|
+
useWorkspaceModelCatalog,
|
|
4509
|
+
isHumanInputEvent,
|
|
4510
|
+
useHumanInputRequests,
|
|
4511
|
+
conversationTimeline,
|
|
4512
|
+
useSessionStartupTimeline,
|
|
4511
4513
|
useSessionConversation,
|
|
4512
4514
|
useSessionReadAcknowledgement,
|
|
4513
|
-
useNewConversation
|
|
4514
|
-
isGoalEvent,
|
|
4515
|
-
useGoal
|
|
4515
|
+
useNewConversation
|
|
4516
4516
|
};
|
|
4517
|
-
//# sourceMappingURL=chunk-
|
|
4517
|
+
//# sourceMappingURL=chunk-3EEUD7YO.js.map
|