@opengeni/react 4.0.2 → 4.0.5-canary.39120434730001
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +787 -26
- package/dist/accounts.js +2 -0
- package/dist/accounts.js.map +1 -1
- package/dist/approvals.d.ts +2 -1
- package/dist/artifacts-document.js +6 -3
- package/dist/artifacts-presentation.js +6 -3
- package/dist/artifacts-spreadsheet.d.ts +1 -1
- package/dist/artifacts-spreadsheet.js +6 -3
- package/dist/artifacts.d.ts +5 -1
- package/dist/artifacts.js +542 -278
- package/dist/artifacts.js.map +1 -1
- package/dist/browser-viewer-GEHX3KYE.js +20 -0
- package/dist/capability-catalog-row.d.ts +20 -0
- package/dist/capability-logo-fallback.d.ts +3 -0
- package/dist/chat-interactive-block-5V3BGLXT.js +15 -0
- package/dist/chunk-2DDJ6YH6.js +41 -0
- package/dist/chunk-2DDJ6YH6.js.map +1 -0
- package/dist/chunk-2EGXXUG4.js +1161 -0
- package/dist/chunk-2EGXXUG4.js.map +1 -0
- package/dist/chunk-2XKRY4GF.js +302 -0
- package/dist/chunk-2XKRY4GF.js.map +1 -0
- package/dist/chunk-2ZUUIMBY.js +343 -0
- package/dist/chunk-2ZUUIMBY.js.map +1 -0
- package/dist/chunk-4F4FGCH2.js +34 -0
- package/dist/chunk-4F4FGCH2.js.map +1 -0
- package/dist/{chunk-Z7WBDB4E.js → chunk-4M2MJLY3.js} +848 -867
- package/dist/chunk-4M2MJLY3.js.map +1 -0
- package/dist/chunk-4U7SHFQ2.js +193 -0
- package/dist/chunk-4U7SHFQ2.js.map +1 -0
- package/dist/chunk-5I4VRWBB.js +56 -0
- package/dist/chunk-5I4VRWBB.js.map +1 -0
- package/dist/{chunk-24M4YBCL.js → chunk-62XZ3IX3.js} +1751 -845
- package/dist/chunk-62XZ3IX3.js.map +1 -0
- package/dist/chunk-77THWHSU.js +308 -0
- package/dist/chunk-77THWHSU.js.map +1 -0
- package/dist/chunk-7CZLTFXF.js +466 -0
- package/dist/chunk-7CZLTFXF.js.map +1 -0
- package/dist/chunk-7N5AD2TC.js +327 -0
- package/dist/chunk-7N5AD2TC.js.map +1 -0
- package/dist/chunk-7SZ7MMCY.js +325 -0
- package/dist/chunk-7SZ7MMCY.js.map +1 -0
- package/dist/chunk-7TG6KTR2.js +3153 -0
- package/dist/chunk-7TG6KTR2.js.map +1 -0
- package/dist/chunk-AIX25FIQ.js +409 -0
- package/dist/chunk-AIX25FIQ.js.map +1 -0
- package/dist/chunk-AT2HD6RQ.js +1936 -0
- package/dist/chunk-AT2HD6RQ.js.map +1 -0
- package/dist/chunk-B27E3V37.js +29 -0
- package/dist/chunk-B27E3V37.js.map +1 -0
- package/dist/{chunk-5M6VTFJ5.js → chunk-B4EDAXMC.js} +37 -13
- package/dist/chunk-B4EDAXMC.js.map +1 -0
- package/dist/chunk-BOG2FED3.js +35 -0
- package/dist/chunk-BOG2FED3.js.map +1 -0
- package/dist/chunk-BQYQU5QW.js +109 -0
- package/dist/chunk-BQYQU5QW.js.map +1 -0
- package/dist/{chunk-PAJU5KKL.js → chunk-BRIOXCLH.js} +68 -25
- package/dist/chunk-BRIOXCLH.js.map +1 -0
- package/dist/chunk-CM7LVUKC.js +35 -0
- package/dist/chunk-CM7LVUKC.js.map +1 -0
- package/dist/{chunk-KCGXPP5V.js → chunk-CXIGFHVL.js} +35 -23
- package/dist/chunk-CXIGFHVL.js.map +1 -0
- package/dist/chunk-DHXKEJBH.js +71 -0
- package/dist/chunk-DHXKEJBH.js.map +1 -0
- package/dist/{chunk-NOSYBS2D.js → chunk-DN3TKURW.js} +12 -9
- package/dist/chunk-DN3TKURW.js.map +1 -0
- package/dist/chunk-DNJ23AWQ.js +35 -0
- package/dist/chunk-DNJ23AWQ.js.map +1 -0
- package/dist/chunk-ESAMXNBZ.js +3237 -0
- package/dist/chunk-ESAMXNBZ.js.map +1 -0
- package/dist/{chunk-4MDLEHXL.js → chunk-EWATYP5L.js} +64 -44
- package/dist/chunk-EWATYP5L.js.map +1 -0
- package/dist/{chunk-YBM6CQRU.js → chunk-FQ5CXNUG.js} +65 -42
- package/dist/chunk-FQ5CXNUG.js.map +1 -0
- package/dist/chunk-FVROZ7HR.js +14396 -0
- package/dist/chunk-FVROZ7HR.js.map +1 -0
- package/dist/chunk-HEVQKE27.js +150 -0
- package/dist/chunk-HEVQKE27.js.map +1 -0
- package/dist/chunk-HZ47S3DP.js +1086 -0
- package/dist/chunk-HZ47S3DP.js.map +1 -0
- package/dist/chunk-I5BJ7ENY.js +174 -0
- package/dist/chunk-I5BJ7ENY.js.map +1 -0
- package/dist/chunk-IGFZFLI2.js +1390 -0
- package/dist/chunk-IGFZFLI2.js.map +1 -0
- package/dist/chunk-IGVL3ELX.js +46 -0
- package/dist/chunk-IGVL3ELX.js.map +1 -0
- package/dist/chunk-IOD24LGR.js +384 -0
- package/dist/chunk-IOD24LGR.js.map +1 -0
- package/dist/chunk-IOYHDEP3.js +38 -0
- package/dist/chunk-IOYHDEP3.js.map +1 -0
- package/dist/chunk-IQL77TMM.js +803 -0
- package/dist/chunk-IQL77TMM.js.map +1 -0
- package/dist/chunk-IZV5FTJC.js +55 -0
- package/dist/chunk-IZV5FTJC.js.map +1 -0
- package/dist/{chunk-H5YGYNXS.js → chunk-JAYYFOOB.js} +75 -28
- package/dist/chunk-JAYYFOOB.js.map +1 -0
- package/dist/chunk-KN2MYSCC.js +409 -0
- package/dist/chunk-KN2MYSCC.js.map +1 -0
- package/dist/{chunk-PEI6RANI.js → chunk-KYVJMTXL.js} +434 -145
- package/dist/chunk-KYVJMTXL.js.map +1 -0
- package/dist/{chunk-ZYRGEKWS.js → chunk-LJUMYUBO.js} +3 -1
- package/dist/{chunk-ZYRGEKWS.js.map → chunk-LJUMYUBO.js.map} +1 -1
- package/dist/{chunk-ICA6R6TW.js → chunk-LNUD3JNI.js} +1532 -395
- package/dist/chunk-LNUD3JNI.js.map +1 -0
- package/dist/chunk-M357MHH3.js +2 -0
- package/dist/{chunk-BV5A4OTE.js → chunk-MEL6PH2I.js} +1218 -537
- package/dist/chunk-MEL6PH2I.js.map +1 -0
- package/dist/chunk-MF6WS2XF.js +386 -0
- package/dist/chunk-MF6WS2XF.js.map +1 -0
- package/dist/chunk-MK2TQO4Y.js +24 -0
- package/dist/chunk-MK2TQO4Y.js.map +1 -0
- package/dist/chunk-N7S72EXK.js +25 -0
- package/dist/chunk-N7S72EXK.js.map +1 -0
- package/dist/{chunk-KZ73RL76.js → chunk-NAWXARTY.js} +58 -9
- package/dist/chunk-NAWXARTY.js.map +1 -0
- package/dist/chunk-NX4ADH73.js +14 -0
- package/dist/chunk-NX4ADH73.js.map +1 -0
- package/dist/chunk-OYQQJL3J.js +16 -0
- package/dist/chunk-OYQQJL3J.js.map +1 -0
- package/dist/chunk-P4MKPCTC.js +51 -0
- package/dist/chunk-P4MKPCTC.js.map +1 -0
- package/dist/{chunk-JVYQRRC4.js → chunk-PEHTX3V7.js} +21 -1
- package/dist/chunk-PEHTX3V7.js.map +1 -0
- package/dist/chunk-PMV53IMM.js +26 -0
- package/dist/chunk-PMV53IMM.js.map +1 -0
- package/dist/{chunk-HUIKIDM5.js → chunk-QOEWDOFW.js} +295 -156
- package/dist/chunk-QOEWDOFW.js.map +1 -0
- package/dist/chunk-QV3DJVRZ.js +11 -0
- package/dist/chunk-QV3DJVRZ.js.map +1 -0
- package/dist/{chunk-HUMIRRYI.js → chunk-QYUYVSNG.js} +1103 -1699
- package/dist/chunk-QYUYVSNG.js.map +1 -0
- package/dist/{chunk-6J56T3MG.js → chunk-RRAQ5FV5.js} +186 -60
- package/dist/chunk-RRAQ5FV5.js.map +1 -0
- package/dist/{chunk-5YK2ZDIG.js → chunk-TNEZNMSN.js} +4 -10
- package/dist/chunk-TNEZNMSN.js.map +1 -0
- package/dist/{chunk-22KP6LR5.js → chunk-TXS65BB2.js} +3 -1
- package/dist/{chunk-22KP6LR5.js.map → chunk-TXS65BB2.js.map} +1 -1
- package/dist/chunk-UIWIOB4U.js +2215 -0
- package/dist/chunk-UIWIOB4U.js.map +1 -0
- package/dist/chunk-UNJPZGNK.js +63 -0
- package/dist/chunk-UNJPZGNK.js.map +1 -0
- package/dist/chunk-V7UGCQHQ.js +86 -0
- package/dist/chunk-V7UGCQHQ.js.map +1 -0
- package/dist/chunk-VU4QUISJ.js +3405 -0
- package/dist/chunk-VU4QUISJ.js.map +1 -0
- package/dist/chunk-WEY5J52U.js +467 -0
- package/dist/chunk-WEY5J52U.js.map +1 -0
- package/dist/chunk-WH2CBESG.js +409 -0
- package/dist/chunk-WH2CBESG.js.map +1 -0
- package/dist/{chunk-VZTQ73XT.js → chunk-XEA5BCMA.js} +3 -1
- package/dist/{chunk-VZTQ73XT.js.map → chunk-XEA5BCMA.js.map} +1 -1
- package/dist/{chunk-NLTS7JHI.js → chunk-XEIHS3RN.js} +834 -403
- package/dist/chunk-XEIHS3RN.js.map +1 -0
- package/dist/chunk-YNXZRE3F.js +408 -0
- package/dist/chunk-YNXZRE3F.js.map +1 -0
- package/dist/chunk-YSRBFJMQ.js +43 -0
- package/dist/chunk-YSRBFJMQ.js.map +1 -0
- package/dist/{chunk-NEXLLTP4.js → chunk-ZGFU4LVW.js} +6 -5
- package/dist/chunk-ZGFU4LVW.js.map +1 -0
- package/dist/chunk-ZO35BAMO.js +172 -0
- package/dist/chunk-ZO35BAMO.js.map +1 -0
- package/dist/chunk-ZUWF4NF7.js +13 -0
- package/dist/chunk-ZUWF4NF7.js.map +1 -0
- package/dist/client.d.ts +15 -6
- package/dist/clipboard.js +3 -1
- package/dist/commands/registry.d.ts +2 -1
- package/dist/commands/types.d.ts +2 -0
- package/dist/components/anthropic-mark.d.ts +3 -0
- package/dist/components/approval-surface.d.ts +21 -7
- package/dist/components/artifacts/artifact-chrome.d.ts +121 -0
- package/dist/components/artifacts/artifact-sandbox.d.ts +30 -0
- package/dist/components/artifacts/artifact-surface.d.ts +4 -2
- package/dist/components/artifacts/chat-interactive-block.d.ts +29 -0
- package/dist/components/artifacts/deferred-chat-media.d.ts +15 -0
- package/dist/components/artifacts/document-editor.d.ts +4 -2
- package/dist/components/artifacts/editable-artifact-ui.d.ts +4 -2
- package/dist/components/artifacts/editable-artifact-view.d.ts +48 -0
- package/dist/components/artifacts/editable-document.d.ts +3 -2
- package/dist/components/artifacts/editable-presentation.d.ts +4 -3
- package/dist/components/artifacts/editable-spreadsheet.d.ts +8 -3
- package/dist/components/artifacts/index.d.ts +8 -1
- package/dist/components/artifacts/inline-html-document.d.ts +2 -0
- package/dist/components/artifacts/latest-task-runner.d.ts +15 -0
- package/dist/components/artifacts/presentation-editor.d.ts +6 -2
- package/dist/components/artifacts/published-html-artifact-frame.d.ts +17 -40
- package/dist/components/artifacts/session-artifact-viewer.d.ts +39 -0
- package/dist/components/artifacts/site-view.d.ts +26 -0
- package/dist/components/artifacts/spreadsheet-command-queue.d.ts +20 -0
- package/dist/components/artifacts/spreadsheet-download.d.ts +7 -0
- package/dist/components/artifacts/spreadsheet-general-display.d.ts +24 -0
- package/dist/components/artifacts/spreadsheet-grid.d.ts +11 -4
- package/dist/components/artifacts/spreadsheet-resize.d.ts +50 -0
- package/dist/components/artifacts/spreadsheet-submissions.d.ts +9 -0
- package/dist/components/artifacts/visualization-assets.gen.d.ts +2 -0
- package/dist/components/browser-select-control.d.ts +16 -0
- package/dist/components/browser-viewer.d.ts +11 -2
- package/dist/components/chat-composer.d.ts +21 -3
- package/dist/components/child-session-link.d.ts +5 -1
- package/dist/components/claude-mark.d.ts +3 -0
- package/dist/components/code-editor.d.ts +1 -4
- package/dist/components/command-palette.d.ts +1 -1
- package/dist/components/composer-transcription-control.d.ts +7 -0
- package/dist/components/composer.d.ts +30 -67
- package/dist/components/computer-viewer.d.ts +1 -1
- package/dist/components/copy-button.d.ts +3 -1
- package/dist/components/desktop-viewer.d.ts +1 -1
- package/dist/components/generated-video-player.d.ts +1 -1
- package/dist/components/grok-mark.d.ts +26 -0
- package/dist/components/human-input-form.d.ts +26 -32
- package/dist/components/human-input-surface.d.ts +5 -1
- package/dist/components/linkified-text.d.ts +18 -0
- package/dist/components/machine-input-display.d.ts +25 -3
- package/dist/components/machine-status-pill.d.ts +3 -2
- package/dist/components/machines/agent-status-icon.d.ts +6 -0
- package/dist/components/machines/health.d.ts +2 -1
- package/dist/components/machines/machine-detail.d.ts +7 -1
- package/dist/components/machines/machine-status.d.ts +49 -0
- package/dist/components/machines/metric-history-chart.d.ts +1 -1
- package/dist/components/machines/series.d.ts +3 -2
- package/dist/components/markdown-table-layout.d.ts +11 -2
- package/dist/components/markdown.d.ts +37 -4
- package/dist/components/message-timeline.d.ts +79 -7
- package/dist/components/model-mark.d.ts +29 -0
- package/dist/components/model-picker.d.ts +1 -1
- package/dist/components/model-policy-picker.d.ts +31 -22
- package/dist/components/new-conversation.d.ts +32 -0
- package/dist/components/open-geni-chat.d.ts +73 -0
- package/dist/components/open-geni-links.d.ts +69 -0
- package/dist/components/openrouter-mark.d.ts +6 -0
- package/dist/components/opper-mark.d.ts +7 -0
- package/dist/components/preview-loading.d.ts +2 -0
- package/dist/components/provider-recovery-notice.d.ts +17 -0
- package/dist/components/queue-item-content.d.ts +10 -0
- package/dist/components/rehype-secret-refs.d.ts +23 -0
- package/dist/components/remark-soft-line-breaks.d.ts +38 -0
- package/dist/components/sandbox-workspace.d.ts +18 -0
- package/dist/components/secret-question-field.d.ts +31 -0
- package/dist/components/secret-ref-chip.d.ts +35 -0
- package/dist/components/session-capability-frame.d.ts +37 -0
- package/dist/components/session-chrome.d.ts +20 -7
- package/dist/components/session-commands.d.ts +6 -0
- package/dist/components/session-connection-request.d.ts +8 -0
- package/dist/components/session-conversation.d.ts +147 -6
- package/dist/components/session-list.d.ts +39 -0
- package/dist/components/session-mcp-capability-card.d.ts +41 -0
- package/dist/components/session-proxy-scope.d.ts +35 -0
- package/dist/components/session-status.d.ts +6 -2
- package/dist/components/session-usage-limit-notice.d.ts +39 -0
- package/dist/components/this-computer/illustrations.d.ts +38 -0
- package/dist/components/this-computer/labels.d.ts +111 -0
- package/dist/components/this-computer/this-computer-card.d.ts +40 -0
- package/dist/components/this-computer/this-computer-setup.d.ts +35 -0
- package/dist/components/this-computer/this-computer-status.d.ts +42 -0
- package/dist/components/this-computer/use-this-computer.d.ts +29 -0
- package/dist/components/timeline-anchor.d.ts +3 -0
- package/dist/components/timeline-annotation-shared.d.ts +3 -2
- package/dist/components/timeline-annotations-dialog.d.ts +2 -1
- package/dist/components/timeline-annotations.d.ts +5 -1
- package/dist/components/timeline-reading-progress.d.ts +11 -0
- package/dist/components/timeline-search.d.ts +34 -0
- package/dist/components/timeline-settlement.d.ts +16 -0
- package/dist/components/tool-action-review.d.ts +48 -0
- package/dist/components/tool-review-history.d.ts +25 -0
- package/dist/components/usage-limit-notice.d.ts +50 -0
- package/dist/components/usage-member-list.d.ts +92 -0
- package/dist/components/usage-meter.d.ts +74 -0
- package/dist/components/use-viewer-menu-dismiss.d.ts +2 -0
- package/dist/components/user-message-body.d.ts +10 -1
- package/dist/components/workbench-changes.d.ts +2 -1
- package/dist/composer-messages.d.ts +75 -0
- package/dist/composer-messages.js +9 -0
- package/dist/composer-messages.js.map +1 -0
- package/dist/composer-voice-events.d.ts +8 -0
- package/dist/composer.d.ts +3 -3
- package/dist/composer.js +25 -12
- package/dist/computer-viewer-VOIOZGVZ.js +21 -0
- package/dist/computer-viewer-VOIOZGVZ.js.map +1 -0
- package/dist/connect-account-identity.d.ts +8 -0
- package/dist/connect-accounts.d.ts +15 -0
- package/dist/connect-chooser.d.ts +18 -0
- package/dist/connect-panel.d.ts +18 -0
- package/dist/connect-setup.d.ts +18 -0
- package/dist/connect.d.ts +21 -0
- package/dist/connect.js +2216 -0
- package/dist/connect.js.map +1 -0
- package/dist/connection-catalog.d.ts +38 -0
- package/dist/connection-discovery.d.ts +12 -0
- package/dist/connection-installed.d.ts +17 -0
- package/dist/connection-logo.d.ts +9 -0
- package/dist/connection-service-logo.d.ts +8 -0
- package/dist/connection-service-presentation.d.ts +13 -0
- package/dist/connection-skeleton.d.ts +5 -0
- package/dist/connection-type-picker.d.ts +6 -0
- package/dist/conversation-timeline.d.ts +1 -1
- package/dist/desktop.d.ts +7 -0
- package/dist/desktop.js +28 -0
- package/dist/desktop.js.map +1 -0
- package/dist/device-authorization.d.ts +23 -0
- package/dist/diffs.d.ts +8 -0
- package/dist/diffs.js +15 -0
- package/dist/diffs.js.map +1 -0
- package/dist/discovery-cache.d.ts +5 -0
- package/dist/editor.d.ts +7 -0
- package/dist/editor.js +23 -0
- package/dist/editor.js.map +1 -0
- package/dist/embedded-new-voice-KPLC5UJZ.js +19 -0
- package/dist/embedded-new-voice-KPLC5UJZ.js.map +1 -0
- package/dist/embedded-voice-V2RFSLIU.js +19 -0
- package/dist/embedded-voice-V2RFSLIU.js.map +1 -0
- package/dist/fleet-decision-row-FE73NSQ6.js +361 -0
- package/dist/fleet-decision-row-FE73NSQ6.js.map +1 -0
- package/dist/hooks/internal.d.ts +27 -2
- package/dist/hooks/latest-question.d.ts +26 -0
- package/dist/hooks/session-view-cache.d.ts +38 -0
- package/dist/hooks/shared-machines-list.d.ts +4 -0
- package/dist/hooks/shared-query.d.ts +123 -0
- package/dist/hooks/use-attached-browsers.d.ts +1 -1
- package/dist/hooks/use-auth-runs.d.ts +1 -4
- package/dist/hooks/use-available-models.d.ts +8 -3
- package/dist/hooks/use-browser-frame-stream.d.ts +1 -1
- package/dist/hooks/use-browser-session.d.ts +12 -1
- package/dist/hooks/use-client-config-flags.d.ts +49 -0
- package/dist/hooks/use-codex-accounts.d.ts +48 -9
- package/dist/hooks/use-composer.d.ts +24 -3
- package/dist/hooks/use-computer-frame-stream.d.ts +1 -1
- package/dist/hooks/use-computer-input-posture.d.ts +13 -0
- package/dist/hooks/use-computer-session.d.ts +5 -0
- package/dist/hooks/use-connect.d.ts +23 -0
- package/dist/hooks/use-desktop-stream.d.ts +1 -1
- package/dist/hooks/use-file-attachments.d.ts +4 -0
- package/dist/hooks/use-goal.d.ts +2 -1
- package/dist/hooks/use-last-started-turn-policy.d.ts +5 -1
- package/dist/hooks/use-machine-chip.d.ts +3 -2
- package/dist/hooks/use-new-conversation.d.ts +56 -0
- package/dist/hooks/use-new-session-draft.d.ts +74 -0
- package/dist/hooks/use-realtime-voice-models.d.ts +7 -0
- package/dist/hooks/use-sandbox-files.d.ts +3 -2
- package/dist/hooks/use-session-conversation.d.ts +49 -0
- package/dist/hooks/use-session-events.d.ts +21 -2
- package/dist/hooks/use-session-mcp-approval-policy.d.ts +2 -2
- package/dist/hooks/use-session-model-account.d.ts +48 -0
- package/dist/hooks/use-supergrok-accounts.d.ts +7 -1
- package/dist/hooks/use-terminal-stream.d.ts +11 -5
- package/dist/hooks/use-transcription.d.ts +2 -1
- package/dist/hooks/use-usage.d.ts +40 -0
- package/dist/hooks/use-vaults.d.ts +53 -0
- package/dist/hooks/use-voice-input.d.ts +8 -1
- package/dist/hooks/use-workspace-sessions.d.ts +24 -5
- package/dist/human-input-model.d.ts +123 -0
- package/dist/identity-link-accounts.d.ts +11 -0
- package/dist/identity-link-consent.d.ts +18 -0
- package/dist/index.d.ts +83 -18
- package/dist/index.js +2317 -6453
- package/dist/index.js.map +1 -1
- package/dist/interaction.d.ts +1 -1
- package/dist/interaction.js +20 -29
- package/dist/interaction.js.map +1 -1
- package/dist/latest-question-SXBXROBT.js +118 -0
- package/dist/latest-question-SXBXROBT.js.map +1 -0
- package/dist/lib/client-config-read.d.ts +31 -0
- package/dist/lib/clipboard.d.ts +7 -0
- package/dist/lib/error-message.d.ts +7 -0
- package/dist/lib/format.d.ts +59 -9
- package/dist/lib/host-theme.d.ts +77 -0
- package/dist/lib/interaction-errors.d.ts +3 -0
- package/dist/lib/menu-styles.d.ts +22 -0
- package/dist/lib/notify-observer.d.ts +2 -0
- package/dist/lib/pierre-diffs-loader.d.ts +20 -0
- package/dist/lib/provider-recovery.d.ts +56 -0
- package/dist/lib/scrollbars.d.ts +11 -0
- package/dist/lib/terminal-input-readiness.d.ts +11 -0
- package/dist/lib/transient-retry.d.ts +26 -0
- package/dist/lib/workbench-peers.d.ts +36 -0
- package/dist/lib/xterm-theme.d.ts +7 -5
- package/dist/machines.js +12 -6
- package/dist/{markdown-table-layout-3Z3AWBY7.js → markdown-table-layout-3PV2UAAH.js} +51 -9
- package/dist/markdown-table-layout-3PV2UAAH.js.map +1 -0
- package/dist/mcp-connection-status.d.ts +15 -0
- package/dist/messages/en.d.ts +3328 -0
- package/dist/messages/runtime.d.ts +69 -0
- package/dist/messages.d.ts +3 -0
- package/dist/messages.js +16 -0
- package/dist/messages.js.map +1 -0
- package/dist/model-mark-paths.d.ts +34 -0
- package/dist/model-mark-paths.js +16 -0
- package/dist/model-mark-paths.js.map +1 -0
- package/dist/model-picker-model.d.ts +112 -0
- package/dist/model-picker-model.js +25 -0
- package/dist/model-picker-model.js.map +1 -0
- package/dist/model-policy-picker-menu-NWIETWSR.js +18 -0
- package/dist/model-policy-picker-menu-NWIETWSR.js.map +1 -0
- package/dist/model-policy.d.ts +35 -10
- package/dist/model-policy.js +12 -1
- package/dist/native-previews.d.ts +29 -0
- package/dist/native-previews.js +82 -0
- package/dist/native-previews.js.map +1 -0
- package/dist/new-session-draft.d.ts +7 -0
- package/dist/new-session-draft.js +639 -0
- package/dist/new-session-draft.js.map +1 -0
- package/dist/notification-text.d.ts +27 -0
- package/dist/{noto-sans-arabic-loader-IA2T4X2A.js → noto-sans-arabic-loader-XSH2KYWJ.js} +3 -1
- package/dist/{noto-sans-arabic-loader-IA2T4X2A.js.map → noto-sans-arabic-loader-XSH2KYWJ.js.map} +1 -1
- package/dist/{noto-sans-jp-loader.generated-HFGLYBR3.js → noto-sans-jp-loader.generated-MR5L6V7K.js} +3 -1
- package/dist/{noto-sans-jp-loader.generated-HFGLYBR3.js.map → noto-sans-jp-loader.generated-MR5L6V7K.js.map} +1 -1
- package/dist/organization-model.d.ts +33 -0
- package/dist/organization-model.js +65 -0
- package/dist/organization-model.js.map +1 -0
- package/dist/platform-activity-row-VSQ2FZ5T.js +119 -0
- package/dist/platform-activity-row-VSQ2FZ5T.js.map +1 -0
- package/dist/plugin-details.d.ts +14 -0
- package/dist/plugin-discovery.d.ts +25 -0
- package/dist/preview-loading-paint.d.ts +20 -0
- package/dist/provider.d.ts +37 -2
- package/dist/queue-presentation-model.d.ts +73 -0
- package/dist/queue-presentation-model.js +38 -0
- package/dist/queue-presentation-model.js.map +1 -0
- package/dist/{queue-surface-implementation-LK3S4BIW.js → queue-surface-implementation-MEKXXWGR.js} +189 -343
- package/dist/queue-surface-implementation-MEKXXWGR.js.map +1 -0
- package/dist/realtime/embedded-new-voice.d.ts +1 -0
- package/dist/realtime/embedded-voice.d.ts +1 -0
- package/dist/realtime/realtime-control.d.ts +4 -65
- package/dist/realtime/session-realtime.d.ts +79 -0
- package/dist/realtime.js +26 -1333
- package/dist/realtime.js.map +1 -1
- package/dist/sandbox-files-5NRC2QUT.js +24 -0
- package/dist/sandbox-files-5NRC2QUT.js.map +1 -0
- package/dist/sandbox-label-model.d.ts +31 -0
- package/dist/sandbox-label-model.js +20 -0
- package/dist/sandbox-label-model.js.map +1 -0
- package/dist/scrollbars.d.ts +1 -0
- package/dist/scrollbars.js +10 -0
- package/dist/scrollbars.js.map +1 -0
- package/dist/secret-reference-label.d.ts +15 -0
- package/dist/secrets-ui.d.ts +57 -0
- package/dist/session-agents-model.d.ts +11 -0
- package/dist/session-agents-model.js +25 -0
- package/dist/session-agents-model.js.map +1 -0
- package/dist/session-attention-model.d.ts +8 -0
- package/dist/session-attention-model.js +47 -0
- package/dist/session-attention-model.js.map +1 -0
- package/dist/session-auth-recommendation.d.ts +6 -0
- package/dist/session-capability-policy.d.ts +32 -0
- package/dist/session-context.d.ts +9 -1
- package/dist/session-feedback-model.d.ts +21 -0
- package/dist/session-feedback-model.js +56 -0
- package/dist/session-feedback-model.js.map +1 -0
- package/dist/session-list-model.d.ts +139 -0
- package/dist/session-list-model.js +274 -0
- package/dist/session-list-model.js.map +1 -0
- package/dist/session-realtime-OZCE6IKP.js +22 -0
- package/dist/session-realtime-OZCE6IKP.js.map +1 -0
- package/dist/session-realtime.d.ts +7 -0
- package/dist/session-realtime.js +20 -0
- package/dist/session-realtime.js.map +1 -0
- package/dist/session-status-model.d.ts +37 -0
- package/dist/session-ui.d.ts +40 -3
- package/dist/session-ui.js +127 -21
- package/dist/session-ui.js.map +1 -1
- package/dist/session.d.ts +10 -2
- package/dist/session.js +44 -20
- package/dist/site-snapshot.d.ts +14 -0
- package/dist/sites-ui.d.ts +24 -0
- package/dist/sites.d.ts +3 -0
- package/dist/sites.js +15 -0
- package/dist/sites.js.map +1 -0
- package/dist/skill-discovery.d.ts +47 -0
- package/dist/terminal.d.ts +8 -0
- package/dist/terminal.js +33 -0
- package/dist/terminal.js.map +1 -0
- package/dist/testing/session-scenarios.d.ts +10 -0
- package/dist/testing/session-scenarios.js +367 -0
- package/dist/testing/session-scenarios.js.map +1 -0
- package/dist/this-computer.d.ts +8 -0
- package/dist/this-computer.js +1042 -0
- package/dist/this-computer.js.map +1 -0
- package/dist/timeline/activity-rail.d.ts +12 -2
- package/dist/timeline/agent-identity.d.ts +30 -0
- package/dist/timeline/agent-row.d.ts +31 -0
- package/dist/timeline/allowance-exhausted-row.d.ts +24 -0
- package/dist/timeline/compaction-copy.d.ts +47 -0
- package/dist/timeline/focus-sequence.d.ts +9 -0
- package/dist/timeline/genie-copy.d.ts +4 -0
- package/dist/timeline/genie-loading.d.ts +48 -0
- package/dist/timeline/index.d.ts +12 -5
- package/dist/timeline/invoked-tool.d.ts +6 -0
- package/dist/timeline/knowledge-receipt.d.ts +17 -0
- package/dist/timeline/learning-refusal-copy.d.ts +23 -0
- package/dist/timeline/learning-refusal-row.d.ts +19 -0
- package/dist/timeline/message-sender.d.ts +19 -0
- package/dist/timeline/notice-presentation.d.ts +14 -0
- package/dist/timeline/parsers.d.ts +11 -0
- package/dist/timeline/patch-apply-command.d.ts +19 -0
- package/dist/timeline/platform-activity-presentation.d.ts +26 -0
- package/dist/timeline/platform-activity-row.d.ts +1 -2
- package/dist/timeline/presented-image.d.ts +11 -0
- package/dist/timeline/projection.d.ts +32 -2
- package/dist/timeline/provider-logo.d.ts +15 -0
- package/dist/timeline/question-nav-model.d.ts +23 -0
- package/dist/timeline/registry.d.ts +10 -1
- package/dist/timeline/retained-image.d.ts +18 -0
- package/dist/timeline/retained-loaders.d.ts +27 -0
- package/dist/timeline/rolling-activity.d.ts +11 -0
- package/dist/timeline/screenshot-lightbox.d.ts +23 -1
- package/dist/timeline/session-usage-limit-row.d.ts +11 -0
- package/dist/timeline/shared.d.ts +8 -3
- package/dist/timeline/startup-dispatch-details.d.ts +5 -0
- package/dist/timeline/startup-preference.d.ts +3 -0
- package/dist/timeline/startup-timings.d.ts +4 -0
- package/dist/timeline/tool-display-name.d.ts +6 -2
- package/dist/timeline/tool-presentation.d.ts +185 -0
- package/dist/timeline/turn-summary-model.d.ts +102 -0
- package/dist/timeline/turn-summary.d.ts +20 -54
- package/dist/timeline/types.d.ts +184 -7
- package/dist/timeline/work-presentation.d.ts +61 -0
- package/dist/{timeline-annotation-markers-DRSTLEM6.js → timeline-annotation-markers-HYLRTT6S.js} +11 -6
- package/dist/timeline-annotation-markers-HYLRTT6S.js.map +1 -0
- package/dist/{timeline-annotation-selection-IHLUGVND.js → timeline-annotation-selection-LBKW5GHA.js} +15 -5
- package/dist/timeline-annotation-selection-LBKW5GHA.js.map +1 -0
- package/dist/{timeline-annotations-dialog-6Q53N5FG.js → timeline-annotations-dialog-JKVINC42.js} +34 -19
- package/dist/timeline-annotations-dialog-JKVINC42.js.map +1 -0
- package/dist/timeline-model.d.ts +29 -0
- package/dist/timeline-model.js +254 -0
- package/dist/timeline-model.js.map +1 -0
- package/dist/usage/allowance-copy.d.ts +26 -0
- package/dist/usage/session-usage-limit.d.ts +89 -0
- package/dist/usage/summary.d.ts +35 -0
- package/dist/usage.d.ts +17 -0
- package/dist/usage.js +1201 -0
- package/dist/usage.js.map +1 -0
- package/dist/voice-recording-owner.d.ts +7 -0
- package/package.json +119 -7
- package/src/approvals.ts +8 -1
- package/src/artifacts-spreadsheet.ts +1 -0
- package/src/artifacts.ts +41 -0
- package/src/assets/README.md +8 -0
- package/src/assets/gmail.ico +0 -0
- package/src/assets/outlook.ico +0 -0
- package/src/capability-catalog-row.tsx +96 -0
- package/src/capability-logo-fallback.ts +22 -0
- package/src/client.ts +18 -30
- package/src/commands/registry.ts +46 -36
- package/src/commands/types.ts +2 -0
- package/src/components/anthropic-mark.tsx +10 -0
- package/src/components/approval-surface.tsx +407 -142
- package/src/components/artifacts/artifact-chrome.tsx +425 -0
- package/src/components/artifacts/artifact-sandbox.tsx +193 -0
- package/src/components/artifacts/artifact-surface.tsx +48 -26
- package/src/components/artifacts/chat-interactive-block.tsx +260 -0
- package/src/components/artifacts/deferred-chat-media.tsx +72 -0
- package/src/components/artifacts/document-editor.tsx +193 -45
- package/src/components/artifacts/editable-artifact-ui.tsx +23 -11
- package/src/components/artifacts/editable-artifact-view.tsx +199 -0
- package/src/components/artifacts/editable-artifact-workbench.tsx +8 -3
- package/src/components/artifacts/editable-document.tsx +76 -54
- package/src/components/artifacts/editable-presentation.tsx +86 -40
- package/src/components/artifacts/editable-spreadsheet.tsx +581 -121
- package/src/components/artifacts/index.ts +42 -0
- package/src/components/artifacts/inline-html-document.ts +24 -0
- package/src/components/artifacts/latest-task-runner.ts +49 -0
- package/src/components/artifacts/presentation-editor.tsx +422 -122
- package/src/components/artifacts/published-html-artifact-frame.tsx +79 -265
- package/src/components/artifacts/session-artifact-viewer.tsx +381 -0
- package/src/components/artifacts/site-view.tsx +129 -0
- package/src/components/artifacts/spreadsheet-canvas.ts +5 -10
- package/src/components/artifacts/spreadsheet-command-queue.ts +190 -0
- package/src/components/artifacts/spreadsheet-download.tsx +117 -0
- package/src/components/artifacts/spreadsheet-general-display.ts +43 -0
- package/src/components/artifacts/spreadsheet-grid.tsx +390 -172
- package/src/components/artifacts/spreadsheet-resize.tsx +432 -0
- package/src/components/artifacts/spreadsheet-submissions.tsx +46 -0
- package/src/components/artifacts/visualization-assets/base.css +1015 -0
- package/src/components/artifacts/visualization-assets/helpers.html +349 -0
- package/src/components/artifacts/visualization-assets.gen.ts +3 -0
- package/src/components/browser-select-control.tsx +320 -0
- package/src/components/browser-viewer.tsx +1102 -505
- package/src/components/chat-composer.tsx +42 -3
- package/src/components/child-session-link.tsx +16 -5
- package/src/components/claude-mark.tsx +11 -0
- package/src/components/code-editor.tsx +38 -27
- package/src/components/command-palette.tsx +4 -1
- package/src/components/composer-transcription-control.tsx +151 -50
- package/src/components/composer.tsx +281 -176
- package/src/components/computer-viewer.tsx +1013 -341
- package/src/components/copy-button.tsx +17 -7
- package/src/components/desktop-viewer.tsx +42 -33
- package/src/components/diff-view.tsx +3 -1
- package/src/components/enrollment-consent.tsx +39 -34
- package/src/components/enrollment-device-flow.tsx +31 -19
- package/src/components/file-browser.tsx +47 -35
- package/src/components/fleet-tile.tsx +8 -4
- package/src/components/generated-video-player.tsx +10 -5
- package/src/components/grok-mark.tsx +34 -0
- package/src/components/human-input-form.tsx +438 -251
- package/src/components/human-input-surface.tsx +8 -0
- package/src/components/interaction-intervention-banner.tsx +15 -13
- package/src/components/linkified-text.tsx +79 -0
- package/src/components/machine-card.tsx +56 -89
- package/src/components/machine-dock-bar.tsx +10 -4
- package/src/components/machine-health-pill.tsx +4 -2
- package/src/components/machine-input-display.ts +309 -34
- package/src/components/machine-metrics.tsx +10 -7
- package/src/components/machine-status-pill.tsx +23 -15
- package/src/components/machines/agent-status-icon.tsx +31 -0
- package/src/components/machines/health.ts +53 -10
- package/src/components/machines/machine-detail.tsx +230 -42
- package/src/components/machines/machine-operation-policy.tsx +36 -29
- package/src/components/machines/machine-status.ts +264 -0
- package/src/components/machines/metric-history-chart.tsx +8 -2
- package/src/components/machines/series.ts +12 -11
- package/src/components/machines-dashboard.tsx +16 -9
- package/src/components/markdown-table-layout.ts +67 -9
- package/src/components/markdown.tsx +470 -133
- package/src/components/message-timeline.tsx +2290 -752
- package/src/components/model-mark.tsx +102 -0
- package/src/components/model-picker.tsx +27 -9
- package/src/components/model-policy-picker-menu.tsx +204 -100
- package/src/components/model-policy-picker.tsx +215 -152
- package/src/components/new-conversation.tsx +223 -0
- package/src/components/open-geni-chat.tsx +311 -0
- package/src/components/open-geni-links.tsx +183 -0
- package/src/components/openrouter-mark.tsx +13 -0
- package/src/components/opper-mark.tsx +18 -0
- package/src/components/pierre-diff.tsx +47 -19
- package/src/components/pierre-file.tsx +38 -11
- package/src/components/preview-loading.tsx +111 -0
- package/src/components/provider-recovery-notice.tsx +51 -0
- package/src/components/queue-item-content.ts +16 -0
- package/src/components/queue-surface-implementation.tsx +185 -420
- package/src/components/queue-surface-state.tsx +13 -8
- package/src/components/queue-surface.tsx +3 -1
- package/src/components/rehype-secret-refs.ts +98 -0
- package/src/components/remark-soft-line-breaks.ts +166 -0
- package/src/components/sandbox-files.tsx +75 -44
- package/src/components/sandbox-terminal.tsx +103 -22
- package/src/components/sandbox-workspace.tsx +168 -78
- package/src/components/secret-question-field.tsx +326 -0
- package/src/components/secret-ref-chip.tsx +187 -0
- package/src/components/session-capability-frame.tsx +203 -0
- package/src/components/session-chrome.tsx +559 -328
- package/src/components/session-commands-panel.tsx +34 -17
- package/src/components/session-commands.tsx +18 -0
- package/src/components/session-connection-request.tsx +99 -0
- package/src/components/session-conversation.tsx +853 -118
- package/src/components/session-list.tsx +259 -0
- package/src/components/session-mcp-capability-card.tsx +681 -0
- package/src/components/session-proxy-scope.tsx +160 -0
- package/src/components/session-status.tsx +35 -21
- package/src/components/session-usage-limit-notice.tsx +176 -0
- package/src/components/this-computer/illustrations.tsx +164 -0
- package/src/components/this-computer/labels.ts +234 -0
- package/src/components/this-computer/this-computer-card.tsx +203 -0
- package/src/components/this-computer/this-computer-setup.tsx +433 -0
- package/src/components/this-computer/this-computer-status.tsx +329 -0
- package/src/components/this-computer/use-this-computer.ts +183 -0
- package/src/components/timeline-anchor.tsx +43 -15
- package/src/components/timeline-annotation-chrome.tsx +33 -9
- package/src/components/timeline-annotation-markers.tsx +4 -2
- package/src/components/timeline-annotation-selection.tsx +11 -2
- package/src/components/timeline-annotation-shared.ts +9 -8
- package/src/components/timeline-annotations-dialog.tsx +30 -9
- package/src/components/timeline-annotations.tsx +24 -7
- package/src/components/timeline-reading-progress.ts +80 -0
- package/src/components/timeline-search.tsx +168 -0
- package/src/components/timeline-settlement.ts +60 -0
- package/src/components/tool-action-review.tsx +670 -0
- package/src/components/tool-review-history.tsx +88 -0
- package/src/components/usage-limit-notice.tsx +183 -0
- package/src/components/usage-member-list.tsx +797 -0
- package/src/components/usage-meter.tsx +386 -0
- package/src/components/use-viewer-menu-dismiss.ts +33 -0
- package/src/components/user-message-body.tsx +33 -2
- package/src/components/workbench-changes.tsx +28 -16
- package/src/components/workspace-dock.tsx +45 -13
- package/src/composer-messages.ts +153 -0
- package/src/composer-voice-events.ts +12 -0
- package/src/composer.ts +4 -0
- package/src/connect-account-identity.tsx +38 -0
- package/src/connect-accounts.tsx +233 -0
- package/src/connect-chooser.tsx +339 -0
- package/src/connect-panel.tsx +104 -0
- package/src/connect-setup.tsx +354 -0
- package/src/connect.ts +60 -0
- package/src/connection-assets.d.ts +4 -0
- package/src/connection-catalog.tsx +175 -0
- package/src/connection-discovery.tsx +251 -0
- package/src/connection-installed.tsx +56 -0
- package/src/connection-logo.tsx +37 -0
- package/src/connection-service-logo.tsx +55 -0
- package/src/connection-service-presentation.ts +46 -0
- package/src/connection-skeleton.tsx +16 -0
- package/src/connection-type-picker.tsx +38 -0
- package/src/conversation-timeline.ts +11 -2
- package/src/desktop.ts +24 -0
- package/src/device-authorization.tsx +111 -0
- package/src/diffs.ts +16 -0
- package/src/discovery-cache.ts +42 -0
- package/src/editor.ts +13 -0
- package/src/hooks/internal.ts +93 -10
- package/src/hooks/latest-question.ts +168 -0
- package/src/hooks/session-view-cache.ts +167 -0
- package/src/hooks/shared-machines-list.ts +34 -1
- package/src/hooks/shared-query.ts +744 -0
- package/src/hooks/use-attached-browsers.ts +1 -1
- package/src/hooks/use-auth-runs.ts +0 -27
- package/src/hooks/use-available-models.ts +20 -10
- package/src/hooks/use-browser-frame-stream.ts +23 -4
- package/src/hooks/use-browser-session.ts +684 -206
- package/src/hooks/use-browser-sessions.ts +32 -1
- package/src/hooks/use-client-config-flags.ts +102 -0
- package/src/hooks/use-codex-accounts.ts +216 -43
- package/src/hooks/use-composer.ts +240 -59
- package/src/hooks/use-computer-frame-stream.ts +29 -9
- package/src/hooks/use-computer-input-posture.ts +96 -0
- package/src/hooks/use-computer-session.ts +419 -100
- package/src/hooks/use-connect.ts +23 -0
- package/src/hooks/use-desktop-stream.ts +19 -28
- package/src/hooks/use-file-attachments.ts +19 -3
- package/src/hooks/use-goal.ts +172 -21
- package/src/hooks/use-human-input.ts +16 -2
- package/src/hooks/use-last-started-turn-policy.ts +37 -11
- package/src/hooks/use-machine-chip.ts +13 -8
- package/src/hooks/use-machines.ts +24 -10
- package/src/hooks/use-new-conversation.ts +377 -0
- package/src/hooks/use-new-session-draft.ts +813 -0
- package/src/hooks/use-realtime-voice-models.ts +46 -0
- package/src/hooks/use-sandbox-files.ts +22 -16
- package/src/hooks/use-session-background-commands.ts +2 -2
- package/src/hooks/use-session-capabilities.ts +3 -2
- package/src/hooks/use-session-conversation.ts +150 -0
- package/src/hooks/use-session-events.ts +403 -64
- package/src/hooks/use-session-lineage.ts +47 -9
- package/src/hooks/use-session-mcp-approval-policy.ts +13 -5
- package/src/hooks/use-session-model-account.ts +174 -0
- package/src/hooks/use-session.ts +19 -3
- package/src/hooks/use-slash-commands.ts +6 -11
- package/src/hooks/use-supergrok-accounts.ts +22 -8
- package/src/hooks/use-terminal-stream.ts +153 -27
- package/src/hooks/use-transcription.ts +45 -19
- package/src/hooks/use-turn-queue.ts +25 -5
- package/src/hooks/use-usage.ts +100 -0
- package/src/hooks/use-vaults.ts +153 -0
- package/src/hooks/use-video-artifact-playback.ts +1 -1
- package/src/hooks/use-voice-input.ts +127 -19
- package/src/hooks/use-workspace-capture.ts +3 -2
- package/src/hooks/use-workspace-sessions.ts +74 -7
- package/src/human-input-model.ts +374 -0
- package/src/identity-link-accounts.tsx +149 -0
- package/src/identity-link-consent.tsx +193 -0
- package/src/index.ts +282 -16
- package/src/interaction.ts +1 -0
- package/src/lib/client-config-read.ts +76 -0
- package/src/lib/clipboard.ts +29 -0
- package/src/lib/error-message.ts +37 -0
- package/src/lib/format.ts +231 -36
- package/src/lib/host-theme.ts +529 -0
- package/src/lib/interaction-errors.ts +15 -0
- package/src/lib/menu-styles.ts +44 -0
- package/src/lib/notify-observer.ts +15 -0
- package/src/lib/pierre-diffs-loader.ts +53 -0
- package/src/lib/provider-recovery.ts +255 -0
- package/src/lib/scrollbars.ts +30 -0
- package/src/lib/terminal-input-readiness.ts +51 -0
- package/src/lib/transient-retry.ts +101 -0
- package/src/lib/workbench-peers.ts +62 -0
- package/src/lib/xterm-theme.ts +23 -21
- package/src/mcp-connection-status.ts +39 -0
- package/src/messages/en.ts +3810 -0
- package/src/messages/runtime.tsx +175 -0
- package/src/messages.ts +19 -0
- package/src/model-mark-paths.ts +53 -0
- package/src/model-picker-model.ts +343 -0
- package/src/model-policy.ts +301 -79
- package/src/native-previews.ts +104 -0
- package/src/new-session-draft.ts +22 -0
- package/src/notification-text.ts +81 -0
- package/src/organization-model.ts +123 -0
- package/src/plugin-details.tsx +192 -0
- package/src/plugin-discovery.tsx +209 -0
- package/src/preview-loading-paint.ts +68 -0
- package/src/provider.tsx +105 -21
- package/src/queue-presentation-model.ts +475 -0
- package/src/realtime/dropdown-menu.tsx +19 -12
- package/src/realtime/embedded-new-voice.tsx +1 -0
- package/src/realtime/embedded-voice.tsx +3 -0
- package/src/realtime/realtime-control.tsx +240 -609
- package/src/realtime/session-realtime.ts +582 -0
- package/src/sandbox-label-model.ts +56 -0
- package/src/scrollbars.ts +3 -0
- package/src/secret-reference-label.ts +47 -0
- package/src/secrets-ui.tsx +59 -0
- package/src/session-agents-model.ts +40 -0
- package/src/session-attention-model.ts +62 -0
- package/src/session-auth-recommendation.ts +50 -0
- package/src/session-capability-policy.ts +200 -0
- package/src/session-context.ts +13 -5
- package/src/session-feedback-model.ts +101 -0
- package/src/session-list-model.ts +437 -0
- package/src/session-realtime.ts +18 -0
- package/src/session-status-model.ts +99 -0
- package/src/session-ui.ts +102 -3
- package/src/session.ts +19 -1
- package/src/site-snapshot.ts +74 -0
- package/src/sites-ui.tsx +350 -0
- package/src/sites.ts +3 -0
- package/src/skill-discovery.tsx +221 -0
- package/src/terminal.ts +26 -0
- package/src/testing/session-scenarios.ts +404 -0
- package/src/this-computer.ts +62 -0
- package/src/timeline/activity-rail.tsx +289 -119
- package/src/timeline/agent-identity.tsx +84 -0
- package/src/timeline/agent-row.tsx +235 -0
- package/src/timeline/allowance-exhausted-row.tsx +90 -0
- package/src/timeline/compaction-copy.ts +125 -0
- package/src/timeline/fleet-decision-row.tsx +120 -101
- package/src/timeline/focus-sequence.ts +44 -0
- package/src/timeline/genie-copy.ts +22 -0
- package/src/timeline/genie-loading.tsx +158 -0
- package/src/timeline/index.ts +37 -2
- package/src/timeline/invoked-tool.ts +15 -0
- package/src/timeline/knowledge-receipt.tsx +104 -0
- package/src/timeline/learning-refusal-copy.ts +67 -0
- package/src/timeline/learning-refusal-row.tsx +70 -0
- package/src/timeline/message-sender.tsx +71 -0
- package/src/timeline/notice-presentation.ts +67 -0
- package/src/timeline/parsers.ts +42 -2
- package/src/timeline/patch-apply-command.tsx +139 -0
- package/src/timeline/platform-activity-presentation.ts +219 -0
- package/src/timeline/platform-activity-row.tsx +34 -98
- package/src/timeline/presented-image.ts +63 -0
- package/src/timeline/projection.ts +1556 -71
- package/src/timeline/provider-logo.tsx +53 -0
- package/src/timeline/question-nav-model.ts +28 -0
- package/src/timeline/registry.ts +11 -1
- package/src/timeline/retained-image.ts +102 -0
- package/src/timeline/retained-loaders.ts +91 -0
- package/src/timeline/rolling-activity.tsx +84 -0
- package/src/timeline/screenshot-lightbox.tsx +250 -10
- package/src/timeline/session-usage-limit-row.tsx +44 -0
- package/src/timeline/shared.tsx +76 -29
- package/src/timeline/startup-dispatch-details.tsx +43 -0
- package/src/timeline/startup-preference.ts +33 -0
- package/src/timeline/startup-timings.tsx +164 -0
- package/src/timeline/tool-diff.tsx +3 -1
- package/src/timeline/tool-display-name.ts +38 -6
- package/src/timeline/tool-presentation.ts +1552 -0
- package/src/timeline/tool-renderers.tsx +1019 -1265
- package/src/timeline/turn-summary-model.ts +363 -0
- package/src/timeline/turn-summary.tsx +288 -367
- package/src/timeline/types.ts +191 -7
- package/src/timeline/work-presentation.ts +196 -0
- package/src/timeline-model.ts +143 -0
- package/src/usage/allowance-copy.ts +70 -0
- package/src/usage/session-usage-limit.ts +270 -0
- package/src/usage/summary.ts +93 -0
- package/src/usage.ts +70 -0
- package/src/voice-recording-owner.ts +22 -0
- package/styles/compiled.css +2010 -651
- package/styles/connect.css +290 -0
- package/styles/connect.d.ts +1 -0
- package/styles/effective-tokens.css +1 -0
- package/styles/index.css +286 -9
- package/styles/responsive.css +98 -6
- package/styles/session-capability.css +44 -0
- package/styles/this-computer.css +1042 -0
- package/styles/this-computer.d.ts +1 -0
- package/styles/tokens.css +132 -64
- package/dist/browser-viewer-NTD6UIPR.js +0 -14
- package/dist/chunk-24M4YBCL.js.map +0 -1
- package/dist/chunk-4MDLEHXL.js.map +0 -1
- package/dist/chunk-5M6VTFJ5.js.map +0 -1
- package/dist/chunk-5PQJOCX5.js +0 -902
- package/dist/chunk-5PQJOCX5.js.map +0 -1
- package/dist/chunk-5YK2ZDIG.js.map +0 -1
- package/dist/chunk-6J56T3MG.js.map +0 -1
- package/dist/chunk-BV5A4OTE.js.map +0 -1
- package/dist/chunk-CQG7YUJB.js +0 -10883
- package/dist/chunk-CQG7YUJB.js.map +0 -1
- package/dist/chunk-H5YGYNXS.js.map +0 -1
- package/dist/chunk-HUIKIDM5.js.map +0 -1
- package/dist/chunk-HUMIRRYI.js.map +0 -1
- package/dist/chunk-ICA6R6TW.js.map +0 -1
- package/dist/chunk-JVYQRRC4.js.map +0 -1
- package/dist/chunk-KCGXPP5V.js.map +0 -1
- package/dist/chunk-KZ73RL76.js.map +0 -1
- package/dist/chunk-NEXLLTP4.js.map +0 -1
- package/dist/chunk-NLTS7JHI.js.map +0 -1
- package/dist/chunk-NOSYBS2D.js.map +0 -1
- package/dist/chunk-PAJU5KKL.js.map +0 -1
- package/dist/chunk-PEI6RANI.js.map +0 -1
- package/dist/chunk-PLYRL5ER.js +0 -164
- package/dist/chunk-PLYRL5ER.js.map +0 -1
- package/dist/chunk-R4KRSFGA.js +0 -290
- package/dist/chunk-R4KRSFGA.js.map +0 -1
- package/dist/chunk-UMECRJRV.js +0 -223
- package/dist/chunk-UMECRJRV.js.map +0 -1
- package/dist/chunk-VRBL3F5E.js +0 -241
- package/dist/chunk-VRBL3F5E.js.map +0 -1
- package/dist/chunk-YBM6CQRU.js.map +0 -1
- package/dist/chunk-Z7WBDB4E.js.map +0 -1
- package/dist/computer-viewer-7TEZC6Y2.js +0 -16
- package/dist/fleet-decision-row-YZ3ZKWMM.js +0 -352
- package/dist/fleet-decision-row-YZ3ZKWMM.js.map +0 -1
- package/dist/hooks/use-environments.d.ts +0 -41
- package/dist/hooks/use-packs.d.ts +0 -32
- package/dist/markdown-table-layout-3Z3AWBY7.js.map +0 -1
- package/dist/model-policy-picker-menu-3R336DP2.js +0 -13
- package/dist/platform-activity-row-27LKAWZD.js +0 -169
- package/dist/platform-activity-row-27LKAWZD.js.map +0 -1
- package/dist/queue-surface-implementation-LK3S4BIW.js.map +0 -1
- package/dist/timeline-annotation-markers-DRSTLEM6.js.map +0 -1
- package/dist/timeline-annotation-selection-IHLUGVND.js.map +0 -1
- package/dist/timeline-annotations-dialog-6Q53N5FG.js.map +0 -1
- package/src/hooks/use-environments.ts +0 -182
- package/src/hooks/use-packs.ts +0 -157
- /package/dist/{browser-viewer-NTD6UIPR.js.map → browser-viewer-GEHX3KYE.js.map} +0 -0
- /package/dist/{computer-viewer-7TEZC6Y2.js.map → chat-interactive-block-5V3BGLXT.js.map} +0 -0
- /package/dist/{model-policy-picker-menu-3R336DP2.js.map → chunk-M357MHH3.js.map} +0 -0
|
@@ -1,130 +1,22 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
mcpToolLeaf,
|
|
4
|
+
toolMatchesLeaf
|
|
5
|
+
} from "./chunk-4F4FGCH2.js";
|
|
1
6
|
import {
|
|
2
7
|
CREDIT_EXHAUSTION_MESSAGE,
|
|
3
8
|
isCreditExhaustion,
|
|
4
9
|
presentFailure,
|
|
5
10
|
tryParseJson
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import {
|
|
8
|
-
useDebouncedCallback,
|
|
9
|
-
useMutationRunner,
|
|
10
|
-
usePageLiveActivity,
|
|
11
|
-
usePolledValue,
|
|
12
|
-
useSessionEventTrigger
|
|
13
|
-
} from "./chunk-KZ73RL76.js";
|
|
14
|
-
import {
|
|
15
|
-
useEmbeddedHumanInputSession,
|
|
16
|
-
useEmbeddedSession,
|
|
17
|
-
useEmbeddedSessionRead
|
|
18
|
-
} from "./chunk-NEXLLTP4.js";
|
|
19
|
-
|
|
20
|
-
// src/human-input.ts
|
|
21
|
-
function isActionableHumanInputRequest(request, nowMs = Date.now()) {
|
|
22
|
-
if (request.status !== "pending") return false;
|
|
23
|
-
if (!request.expiresAt) return true;
|
|
24
|
-
const deadline = Date.parse(request.expiresAt);
|
|
25
|
-
return Number.isFinite(deadline) && deadline > nowMs;
|
|
26
|
-
}
|
|
27
|
-
function humanInputRequestFromEvent(event) {
|
|
28
|
-
if (event.type !== "session.humanInput.requested" || !isRecord(event.payload)) return null;
|
|
29
|
-
const request = event.payload.request;
|
|
30
|
-
if (!isRecord(request) || typeof request.id !== "string" || !Array.isArray(request.questions)) {
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
return {
|
|
34
|
-
id: request.id,
|
|
35
|
-
turnId: event.turnId ?? null,
|
|
36
|
-
questions: request.questions,
|
|
37
|
-
allowSkip: request.allowSkip === true,
|
|
38
|
-
expiresAt: typeof request.expiresAt === "string" ? request.expiresAt : null
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
function projectPendingHumanInputRequests(events) {
|
|
42
|
-
const pending = /* @__PURE__ */ new Map();
|
|
43
|
-
for (const event of events) {
|
|
44
|
-
const requested = humanInputRequestFromEvent(event);
|
|
45
|
-
if (requested) {
|
|
46
|
-
pending.set(requested.id, requested);
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
if (event.type === "user.humanInputResponse" && isRecord(event.payload)) {
|
|
50
|
-
if (typeof event.payload.requestId === "string") pending.delete(event.payload.requestId);
|
|
51
|
-
continue;
|
|
52
|
-
}
|
|
53
|
-
if (event.type === "turn.completed" || event.type === "turn.failed" || event.type === "turn.cancelled") {
|
|
54
|
-
for (const [id, request] of pending) {
|
|
55
|
-
if (request.turnId === null || event.turnId === null || event.turnId === void 0 || request.turnId === event.turnId) {
|
|
56
|
-
pending.delete(id);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return [...pending.values()];
|
|
62
|
-
}
|
|
63
|
-
function isRecord(value) {
|
|
64
|
-
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// src/older-history.ts
|
|
68
|
-
var activeReceiptCapture;
|
|
69
|
-
var preserveTailForAutomaticLoad = false;
|
|
70
|
-
function invokeOlderHistoryLoaderWithReceiptCapture(load, capture, preserveTail = false) {
|
|
71
|
-
const previousCapture = activeReceiptCapture;
|
|
72
|
-
const previousPreserveTail = preserveTailForAutomaticLoad;
|
|
73
|
-
activeReceiptCapture = capture;
|
|
74
|
-
preserveTailForAutomaticLoad = preserveTail;
|
|
75
|
-
try {
|
|
76
|
-
return load();
|
|
77
|
-
} finally {
|
|
78
|
-
activeReceiptCapture = previousCapture;
|
|
79
|
-
preserveTailForAutomaticLoad = previousPreserveTail;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
function createOlderHistoryLoadReceipt(load) {
|
|
83
|
-
let resolveResult;
|
|
84
|
-
let rejectResult;
|
|
85
|
-
const result = new Promise((resolve, reject) => {
|
|
86
|
-
resolveResult = resolve;
|
|
87
|
-
rejectResult = reject;
|
|
88
|
-
});
|
|
89
|
-
result.committed = false;
|
|
90
|
-
result.tailPreserved = false;
|
|
91
|
-
activeReceiptCapture?.(result);
|
|
92
|
-
try {
|
|
93
|
-
const loaded = load(
|
|
94
|
-
() => {
|
|
95
|
-
result.committed = true;
|
|
96
|
-
},
|
|
97
|
-
preserveTailForAutomaticLoad,
|
|
98
|
-
() => {
|
|
99
|
-
result.tailPreserved = true;
|
|
100
|
-
}
|
|
101
|
-
);
|
|
102
|
-
Promise.resolve(loaded).then(resolveResult, rejectResult);
|
|
103
|
-
} catch (error) {
|
|
104
|
-
rejectResult(error);
|
|
105
|
-
}
|
|
106
|
-
return result;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// src/timeline/tool-display-name.ts
|
|
110
|
-
function mcpToolLeaf(name) {
|
|
111
|
-
const boundary = name.indexOf("__");
|
|
112
|
-
return boundary >= 0 ? name.slice(boundary + 2) : name;
|
|
113
|
-
}
|
|
114
|
-
function toolMatchesLeaf(wireName, leaf) {
|
|
115
|
-
return wireName === leaf || wireName.endsWith(`__${leaf}`);
|
|
116
|
-
}
|
|
117
|
-
function toolDisplayName(name) {
|
|
118
|
-
const phrase = mcpToolLeaf(name).replace(/[_-]+/g, " ").trim();
|
|
119
|
-
if (!phrase) {
|
|
120
|
-
return name;
|
|
121
|
-
}
|
|
122
|
-
return phrase.charAt(0).toUpperCase() + phrase.slice(1);
|
|
123
|
-
}
|
|
11
|
+
} from "./chunk-AIX25FIQ.js";
|
|
124
12
|
|
|
125
13
|
// src/timeline/projection.ts
|
|
126
14
|
import {
|
|
127
|
-
|
|
15
|
+
parseCustomMcpSetupRequest,
|
|
16
|
+
parseMediaGenerationResult,
|
|
17
|
+
parseToolDisplayMetadata,
|
|
18
|
+
EMPTY_FINAL_REPLY_NOTICE,
|
|
19
|
+
turnCompletedWithEmptyFinalReply
|
|
128
20
|
} from "@opengeni/sdk";
|
|
129
21
|
|
|
130
22
|
// src/timeline/fleet-decision-projection.ts
|
|
@@ -367,6 +259,118 @@ function asRecord(value) {
|
|
|
367
259
|
}
|
|
368
260
|
|
|
369
261
|
// src/timeline/projection.ts
|
|
262
|
+
import { learningRefusalFromToolOutput } from "@opengeni/sdk/learning-refusal";
|
|
263
|
+
|
|
264
|
+
// src/timeline/learning-refusal-copy.ts
|
|
265
|
+
function learningRefusalTitle(t, refusal) {
|
|
266
|
+
return refusal.destination === "skill" ? t("timeline.learningRefusal.notSavedToSkills") : refusal.destination === "instruction" ? t("timeline.learningRefusal.notSavedToWorkspaceInstructions") : t("timeline.learningRefusal.notSavedToKnowledge");
|
|
267
|
+
}
|
|
268
|
+
function learningRefusalBody(t, refusal) {
|
|
269
|
+
if (refusal.reason === "site_agent") return t("timeline.learningRefusal.siteAgent");
|
|
270
|
+
const off = refusal.reason === "learning_off";
|
|
271
|
+
switch (refusal.destination) {
|
|
272
|
+
case "skill":
|
|
273
|
+
return off ? t("timeline.learningRefusal.skillLearningOff") : t("timeline.learningRefusal.skillNotPermitted");
|
|
274
|
+
case "instruction":
|
|
275
|
+
return off ? t("timeline.learningRefusal.instructionLearningOff") : t("timeline.learningRefusal.instructionNotPermitted");
|
|
276
|
+
case "knowledge":
|
|
277
|
+
return off ? t("timeline.learningRefusal.knowledgeLearningOff") : t("timeline.learningRefusal.knowledgeNotPermitted");
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
function learningRefusalText(t, refusal) {
|
|
281
|
+
return `${learningRefusalTitle(t, refusal)}. ${learningRefusalBody(t, refusal)}`;
|
|
282
|
+
}
|
|
283
|
+
function learningRefusalPlace(refusal) {
|
|
284
|
+
if (refusal.reason === "site_agent") return null;
|
|
285
|
+
if (refusal.reason === "learning_off") return { kind: "learning-settings" };
|
|
286
|
+
if (refusal.destination === "instruction") return { kind: "instructions" };
|
|
287
|
+
if (refusal.destination === "knowledge") return { kind: "knowledge" };
|
|
288
|
+
return refusal.skillId ? { kind: "skill", skillId: refusal.skillId } : { kind: "skills" };
|
|
289
|
+
}
|
|
290
|
+
function learningRefusalPlaceLabel(t, place) {
|
|
291
|
+
switch (place.kind) {
|
|
292
|
+
case "skill":
|
|
293
|
+
return t("timeline.learningRefusal.openSkill");
|
|
294
|
+
case "skills":
|
|
295
|
+
return t("timeline.learningRefusal.openSkills");
|
|
296
|
+
case "instructions":
|
|
297
|
+
return t("timeline.learningRefusal.openWorkspaceInstructions");
|
|
298
|
+
case "knowledge":
|
|
299
|
+
return t("timeline.learningRefusal.openKnowledge");
|
|
300
|
+
case "learning-settings":
|
|
301
|
+
return t("timeline.learningRefusal.agentLearningSettings");
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// src/timeline/projection.ts
|
|
306
|
+
import {
|
|
307
|
+
allowanceExhaustedMessage,
|
|
308
|
+
parseAllowanceExhaustedRefusal
|
|
309
|
+
} from "@opengeni/sdk/allowance-refusal";
|
|
310
|
+
import {
|
|
311
|
+
parseSessionUsageLimitReachedRefusal,
|
|
312
|
+
SESSION_USAGE_LIMIT_SEGMENT,
|
|
313
|
+
sessionUsageLimitReachedMessage
|
|
314
|
+
} from "@opengeni/sdk/session-usage-limits";
|
|
315
|
+
|
|
316
|
+
// src/timeline/compaction-copy.ts
|
|
317
|
+
var COMPACTION_FAILURE_TITLE = (t) => t("timeline.compactionCopy.couldnTCompactConversationHistory");
|
|
318
|
+
var COMPACTION_INTERRUPTED_TITLE = (t) => t("timeline.compactionCopy.compactionInterrupted");
|
|
319
|
+
function compactionSkipTitle(t, reason) {
|
|
320
|
+
return reason === "interrupted" ? COMPACTION_INTERRUPTED_TITLE(t) : COMPACTION_FAILURE_TITLE(t);
|
|
321
|
+
}
|
|
322
|
+
var COMPACTION_REJECTION_NOTE = (t) => t("timeline.compactionCopy.theProviderRejectsThisRequest");
|
|
323
|
+
function compactionSkipSubtitle(t, reason, providerRejection = null) {
|
|
324
|
+
switch (reason) {
|
|
325
|
+
case "no_history":
|
|
326
|
+
return t("timeline.compactionCopy.noActiveHistoryToCompact");
|
|
327
|
+
case "replacement_not_smaller":
|
|
328
|
+
return t("timeline.compactionCopy.checkpointWouldNotReduceMemory");
|
|
329
|
+
case "replacement_exceeds_model_budget":
|
|
330
|
+
return t("timeline.compactionCopy.checkpointExceedsThisModelS");
|
|
331
|
+
case "replacement_unchanged":
|
|
332
|
+
return t("timeline.compactionCopy.checkpointMadeNoProgress");
|
|
333
|
+
case "interrupted":
|
|
334
|
+
return t("timeline.compactionCopy.itWillRetryIfStill");
|
|
335
|
+
case "summarization_failed":
|
|
336
|
+
return providerRejection ? t("timeline.compactionCopy.chatHistoryIsUnchangedIf") : t("timeline.compactionCopy.requestItAgainToRetry");
|
|
337
|
+
default:
|
|
338
|
+
return t("timeline.compactionCopy.compactionWasNotNeededChat");
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
function compactionFailureDetails(t, item) {
|
|
342
|
+
if (item.phase !== "skipped" || item.skipReason !== "summarization_failed") return null;
|
|
343
|
+
const rejection = item.providerRejection;
|
|
344
|
+
if (!rejection) {
|
|
345
|
+
const recorded = item.failureDetail?.trim();
|
|
346
|
+
return recorded ? { note: null, facts: [{ label: t("timeline.compactionCopy.error"), value: recorded }] } : null;
|
|
347
|
+
}
|
|
348
|
+
const facts = [
|
|
349
|
+
{
|
|
350
|
+
label: t("timeline.compactionCopy.response"),
|
|
351
|
+
value: [`HTTP ${rejection.httpStatus}`, rejection.type, rejection.code].filter((part) => Boolean(part)).join(" \xB7 ")
|
|
352
|
+
}
|
|
353
|
+
];
|
|
354
|
+
if (rejection.param)
|
|
355
|
+
facts.push({ label: t("timeline.compactionCopy.parameter"), value: rejection.param });
|
|
356
|
+
if (rejection.requestId)
|
|
357
|
+
facts.push({ label: t("timeline.compactionCopy.requestId"), value: rejection.requestId });
|
|
358
|
+
return { note: COMPACTION_REJECTION_NOTE(t), facts };
|
|
359
|
+
}
|
|
360
|
+
var COMPACTION_TURN_FAILURE_PREFIX = "compaction summarization failed:";
|
|
361
|
+
function presentTurnFailureText(t, failureText) {
|
|
362
|
+
const text = failureText?.trim();
|
|
363
|
+
if (!text) return null;
|
|
364
|
+
if (text.toLowerCase().startsWith(COMPACTION_TURN_FAILURE_PREFIX)) {
|
|
365
|
+
return { summary: COMPACTION_FAILURE_TITLE(t), detail: text };
|
|
366
|
+
}
|
|
367
|
+
return { summary: text };
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
// src/timeline/projection.ts
|
|
371
|
+
function isTimelineUserQuestion(event) {
|
|
372
|
+
return event.type === "user.message" && workerCompletionPayload(asRecord2(event.payload).childCompletion) === null;
|
|
373
|
+
}
|
|
370
374
|
var WORKER_SPAWN_TOOL = "session_create";
|
|
371
375
|
var WORKER_MESSAGE_TOOL = "session_send_message";
|
|
372
376
|
var WORKER_FAILURE_CODE_MAX_LENGTH = 128;
|
|
@@ -408,10 +412,42 @@ function timelineAnnotationToolOutputText(output) {
|
|
|
408
412
|
const text = (marker >= 0 ? raw.slice(marker + "\nOutput:\n".length) : raw.startsWith("Output:\n") ? raw.slice("Output:\n".length) : raw).replace(TIMELINE_ANNOTATION_ANSI_SEQUENCE, "");
|
|
409
413
|
return text.length > 0 ? text : null;
|
|
410
414
|
}
|
|
411
|
-
function buildTimeline(events) {
|
|
415
|
+
function buildTimeline(t, events, options = {}) {
|
|
412
416
|
const items = [];
|
|
417
|
+
const allowanceNotices = /* @__PURE__ */ new Set();
|
|
418
|
+
const learningRefusalNotices = /* @__PURE__ */ new Set();
|
|
419
|
+
const allowanceNotice = (event, turnId) => {
|
|
420
|
+
const refusal = parseAllowanceExhaustedRefusal(event.payload);
|
|
421
|
+
if (!refusal) return null;
|
|
422
|
+
const text = allowanceExhaustedMessage(refusal);
|
|
423
|
+
const key = JSON.stringify([
|
|
424
|
+
turnId,
|
|
425
|
+
event.turnAttemptId,
|
|
426
|
+
startupRecoveryRevisionByTurn.get(turnId ?? "") ?? 0,
|
|
427
|
+
refusal.scope,
|
|
428
|
+
refusal.subjectId,
|
|
429
|
+
refusal.resetsAt
|
|
430
|
+
]);
|
|
431
|
+
if (!allowanceNotices.has(key)) {
|
|
432
|
+
allowanceNotices.add(key);
|
|
433
|
+
items.push({
|
|
434
|
+
kind: "notice",
|
|
435
|
+
id: `${event.id}-allowance`,
|
|
436
|
+
tone: "failed",
|
|
437
|
+
text,
|
|
438
|
+
// The canonical sentence replaces upstream prose, so a host renderer
|
|
439
|
+
// reading `message` never shows a wrapper's private wording.
|
|
440
|
+
allowance: { ...refusal, message: text },
|
|
441
|
+
occurredAt: event.occurredAt
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
return text;
|
|
445
|
+
};
|
|
413
446
|
const prescan = prescanTurnAnchors(events);
|
|
414
447
|
const ordered = orderTimelineEvents(events, prescan);
|
|
448
|
+
let completeHistoryPrefix = options.partialStart !== true;
|
|
449
|
+
const knownMessagePrefixTurns = /* @__PURE__ */ new Set();
|
|
450
|
+
const incompleteMessageKeys = /* @__PURE__ */ new Set();
|
|
415
451
|
const pendingWaitOutcomeByTurn = /* @__PURE__ */ new Map();
|
|
416
452
|
const latestAgentResponseByTurn = /* @__PURE__ */ new Map();
|
|
417
453
|
const identifiedMessages = /* @__PURE__ */ new Map();
|
|
@@ -419,6 +455,38 @@ function buildTimeline(events) {
|
|
|
419
455
|
const humanInputToolCallIds = new Set(
|
|
420
456
|
[...humanInputRequests.values()].map((request) => stringValue(request.toolCallId)).filter(Boolean)
|
|
421
457
|
);
|
|
458
|
+
const workerSessions = /* @__PURE__ */ new Set();
|
|
459
|
+
const pendingWorkerSessions = /* @__PURE__ */ new Set();
|
|
460
|
+
let openWaitNotice = null;
|
|
461
|
+
const presentationWaits = /* @__PURE__ */ new Map();
|
|
462
|
+
let openAdmissionBlocks = [];
|
|
463
|
+
const presentationFailures = /* @__PURE__ */ new Map();
|
|
464
|
+
let presentationTurnId = null;
|
|
465
|
+
const rememberPresentationWait = (item, turnId) => {
|
|
466
|
+
const key = turnId ?? presentationTurnId;
|
|
467
|
+
const waits = presentationWaits.get(key) ?? [];
|
|
468
|
+
waits.push(item);
|
|
469
|
+
presentationWaits.set(key, waits);
|
|
470
|
+
items.push(item);
|
|
471
|
+
};
|
|
472
|
+
const resolvePresentationWait = (event, turnId) => {
|
|
473
|
+
if (event.duplicateOfEventId || event.turnAssociation && event.turnAssociation !== "current")
|
|
474
|
+
return;
|
|
475
|
+
const key = turnId ?? presentationTurnId;
|
|
476
|
+
for (const item of presentationWaits.get(key) ?? []) item.resolvedAt = event.occurredAt;
|
|
477
|
+
presentationWaits.delete(key);
|
|
478
|
+
};
|
|
479
|
+
let openCapacityWaits = [];
|
|
480
|
+
const resolveCapacityWaits = (event, payload) => {
|
|
481
|
+
if (openCapacityWaits.length === 0 || !endsCapacityWait(event, payload)) return;
|
|
482
|
+
const eventTurnId = event.turnId ?? null;
|
|
483
|
+
openCapacityWaits = openCapacityWaits.filter((item) => {
|
|
484
|
+
const waitTurnId = item.capacityWait?.turnId ?? null;
|
|
485
|
+
const ends = event.type === "session.status.changed" || eventTurnId === null || waitTurnId === null || eventTurnId === waitTurnId;
|
|
486
|
+
if (ends) item.resolvedAt = event.occurredAt;
|
|
487
|
+
return !ends;
|
|
488
|
+
});
|
|
489
|
+
};
|
|
422
490
|
const queuedAtByTurn = /* @__PURE__ */ new Map();
|
|
423
491
|
const startupRecoveryRevisionByTurn = /* @__PURE__ */ new Map();
|
|
424
492
|
const startupPhases = /* @__PURE__ */ new Map();
|
|
@@ -529,6 +597,19 @@ function buildTimeline(events) {
|
|
|
529
597
|
for (const event of ordered) {
|
|
530
598
|
const payload = asRecord2(event.payload);
|
|
531
599
|
const turnId = event.turnId ?? null;
|
|
600
|
+
resolveCapacityWaits(event, payload);
|
|
601
|
+
if (turnId && (event.type === "turn.started" || presentationTurnId === null && isAgentActivityEvent(event.type))) {
|
|
602
|
+
presentationTurnId = turnId;
|
|
603
|
+
}
|
|
604
|
+
if (openWaitNotice && (event.type === "user.message" || event.type === "system.update.delivered" || event.type === "turn.started" || event.type === "session.control.paused" || event.type === "session.status.changed" && (payload.status === "cancelled" || payload.status === "failed"))) {
|
|
605
|
+
openWaitNotice.waitEndedAt = event.occurredAt;
|
|
606
|
+
openWaitNotice = null;
|
|
607
|
+
}
|
|
608
|
+
if (event.type === "session.created") {
|
|
609
|
+
completeHistoryPrefix = true;
|
|
610
|
+
} else if (event.type === "turn.started" || event.type === "user.message" && payload.delivery !== "steer" && payload.routing !== "accepted_for_steering") {
|
|
611
|
+
knownMessagePrefixTurns.add(turnId);
|
|
612
|
+
}
|
|
532
613
|
startupEvent = event;
|
|
533
614
|
startupTurnId = turnId;
|
|
534
615
|
startupAttemptId = (typeof event.turnAttemptId === "string" ? event.turnAttemptId : null) ?? stringValue(payload.attemptId);
|
|
@@ -537,11 +618,24 @@ function buildTimeline(events) {
|
|
|
537
618
|
const setupStatus = event.type.endsWith(".started") ? "running" : event.type.endsWith(".failed") ? "failed" : event.type.endsWith(".completed") || event.type === "rig.setup.skipped" ? "complete" : null;
|
|
538
619
|
if (setupPhase && setupStatus) {
|
|
539
620
|
closeStreamingTail();
|
|
621
|
+
let blockedReason;
|
|
622
|
+
if (setupPhase === "model_preparation" && setupStatus === "failed") {
|
|
623
|
+
blockedReason = startupLifecycleWaitReason(payload);
|
|
624
|
+
const sandbox = startupPhases.get(`${startupTurnId}:sandbox`);
|
|
625
|
+
const sameAttempt = sandbox?.[1] || startupAttemptId ? Boolean(startupAttemptId && sandbox?.[1] === startupAttemptId) : sandbox?.[2] === startupRecoveryRevision;
|
|
626
|
+
if (!blockedReason && payload.expectedTransition === void 0 && payload.failureCode === void 0 && payload.failureStage === void 0 && payload.failureCategory === void 0 && payload.error === void 0 && startupTurnId && sameAttempt && sandbox?.[0].status === "cancelled") {
|
|
627
|
+
blockedReason = sandbox[0].blockedReason;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
540
630
|
settleStartupPhase(
|
|
541
631
|
setupPhase,
|
|
542
|
-
setupStatus,
|
|
632
|
+
blockedReason ? "cancelled" : setupStatus,
|
|
543
633
|
numberOrNull(payload.durationMs),
|
|
544
|
-
event.type === "rig.setup.skipped" ? "skipped" : null
|
|
634
|
+
event.type === "rig.setup.skipped" ? "skipped" : null,
|
|
635
|
+
0,
|
|
636
|
+
void 0,
|
|
637
|
+
void 0,
|
|
638
|
+
blockedReason
|
|
545
639
|
);
|
|
546
640
|
continue;
|
|
547
641
|
}
|
|
@@ -551,6 +645,8 @@ function buildTimeline(events) {
|
|
|
551
645
|
closeStreamingTail();
|
|
552
646
|
const childCompletion = workerCompletionPayload(payload.childCompletion);
|
|
553
647
|
if (childCompletion) {
|
|
648
|
+
workerSessions.add(childCompletion.childSessionId);
|
|
649
|
+
pendingWorkerSessions.delete(childCompletion.childSessionId);
|
|
554
650
|
items.push({
|
|
555
651
|
kind: "worker-completion",
|
|
556
652
|
id: event.id,
|
|
@@ -567,6 +663,7 @@ function buildTimeline(events) {
|
|
|
567
663
|
break;
|
|
568
664
|
}
|
|
569
665
|
const voiceMessage = realtimeVoiceMessage(payload);
|
|
666
|
+
const sender = messageSender(payload.initiator);
|
|
570
667
|
items.push({
|
|
571
668
|
kind: "user-message",
|
|
572
669
|
id: event.id,
|
|
@@ -584,6 +681,7 @@ function buildTimeline(events) {
|
|
|
584
681
|
...voiceMessage ? { presentation: voiceMessage.presentation } : {},
|
|
585
682
|
resources: resourceRefs(payload.resources),
|
|
586
683
|
tools: toolRefs(payload.tools),
|
|
684
|
+
...sender ? { sender } : {},
|
|
587
685
|
occurredAt: event.occurredAt
|
|
588
686
|
});
|
|
589
687
|
break;
|
|
@@ -595,10 +693,38 @@ function buildTimeline(events) {
|
|
|
595
693
|
items.push(item);
|
|
596
694
|
break;
|
|
597
695
|
}
|
|
696
|
+
case "system.update.settled": {
|
|
697
|
+
if (payload.notificationOnly !== true || payload.reason !== "operator_retirement") break;
|
|
698
|
+
const members = machineInputMembers(payload.members).filter(
|
|
699
|
+
(member) => member.kind === "child_terminal_result" && member.classification === "failure"
|
|
700
|
+
);
|
|
701
|
+
if (members.length === 0) break;
|
|
702
|
+
for (const member of members) {
|
|
703
|
+
workerSessions.add(member.sourceId);
|
|
704
|
+
pendingWorkerSessions.delete(member.sourceId);
|
|
705
|
+
}
|
|
706
|
+
items.push({
|
|
707
|
+
kind: "machine-input-batch",
|
|
708
|
+
id: event.id,
|
|
709
|
+
turnId: null,
|
|
710
|
+
members,
|
|
711
|
+
occurredAt: event.occurredAt
|
|
712
|
+
});
|
|
713
|
+
break;
|
|
714
|
+
}
|
|
598
715
|
case "system.update.delivered": {
|
|
599
716
|
const inputs = machineInputMembers(payload.members);
|
|
717
|
+
for (const input of inputs) {
|
|
718
|
+
if (input.kind === "child_terminal_result") {
|
|
719
|
+
workerSessions.add(input.sourceId);
|
|
720
|
+
pendingWorkerSessions.delete(input.sourceId);
|
|
721
|
+
}
|
|
722
|
+
}
|
|
600
723
|
if (inputs.length === 0) break;
|
|
601
|
-
|
|
724
|
+
const visibleInputs = inputs.filter(
|
|
725
|
+
(member) => member.kind !== "background_command_result"
|
|
726
|
+
);
|
|
727
|
+
if (visibleInputs.length === 0 || visibleInputs.every((member) => member.kind === "goal_continuation")) {
|
|
602
728
|
break;
|
|
603
729
|
}
|
|
604
730
|
closeStreamingTail();
|
|
@@ -606,7 +732,7 @@ function buildTimeline(events) {
|
|
|
606
732
|
kind: "machine-input-batch",
|
|
607
733
|
id: event.id,
|
|
608
734
|
turnId,
|
|
609
|
-
members:
|
|
735
|
+
members: visibleInputs,
|
|
610
736
|
occurredAt: event.occurredAt
|
|
611
737
|
});
|
|
612
738
|
break;
|
|
@@ -618,10 +744,16 @@ function buildTimeline(events) {
|
|
|
618
744
|
}
|
|
619
745
|
const messageId = stringValue(payload.messageId);
|
|
620
746
|
const messageKey = messageId ? JSON.stringify([turnId, messageId]) : null;
|
|
747
|
+
const phase = assistantMessagePhase(payload.phase);
|
|
748
|
+
if (!completeHistoryPrefix && !knownMessagePrefixTurns.has(turnId) || messageKey && incompleteMessageKeys.has(messageKey)) {
|
|
749
|
+
if (messageKey) incompleteMessageKeys.add(messageKey);
|
|
750
|
+
break;
|
|
751
|
+
}
|
|
621
752
|
const identified = messageKey ? identifiedMessages.get(messageKey) : void 0;
|
|
622
753
|
if (identified) {
|
|
623
754
|
if (identified.annotationSource?.eventType !== "agent.message.completed") {
|
|
624
755
|
identified.text += text;
|
|
756
|
+
if (phase && !identified.phase) identified.phase = phase;
|
|
625
757
|
rememberAgentResponse(turnId, identified, false);
|
|
626
758
|
}
|
|
627
759
|
break;
|
|
@@ -648,6 +780,7 @@ function buildTimeline(events) {
|
|
|
648
780
|
id: event.id,
|
|
649
781
|
turnId,
|
|
650
782
|
text,
|
|
783
|
+
...phase ? { phase } : {},
|
|
651
784
|
streaming: true,
|
|
652
785
|
occurredAt: event.occurredAt
|
|
653
786
|
};
|
|
@@ -657,6 +790,7 @@ function buildTimeline(events) {
|
|
|
657
790
|
break;
|
|
658
791
|
}
|
|
659
792
|
case "agent.message.completed": {
|
|
793
|
+
knownMessagePrefixTurns.add(turnId);
|
|
660
794
|
const text = stringValue(payload.text);
|
|
661
795
|
const messageId = stringValue(payload.messageId);
|
|
662
796
|
const messageKey = messageId ? JSON.stringify([turnId, messageId]) : null;
|
|
@@ -675,8 +809,11 @@ function buildTimeline(events) {
|
|
|
675
809
|
if (!open.text || text && (messageKey || text.startsWith(open.text))) {
|
|
676
810
|
open.text = text || open.text;
|
|
677
811
|
}
|
|
678
|
-
open.streaming = false;
|
|
679
812
|
if (phase) open.phase = phase;
|
|
813
|
+
if (open.startedAt === void 0 && open.occurredAt !== event.occurredAt) {
|
|
814
|
+
open.startedAt = open.occurredAt;
|
|
815
|
+
}
|
|
816
|
+
open.streaming = false;
|
|
680
817
|
open.occurredAt = event.occurredAt;
|
|
681
818
|
open.annotationSource = text && open.text === text ? {
|
|
682
819
|
kind: "assistant_message",
|
|
@@ -724,7 +861,7 @@ function buildTimeline(events) {
|
|
|
724
861
|
}
|
|
725
862
|
const open = last();
|
|
726
863
|
if (open?.kind === "reasoning" && open.streaming && open.turnId === turnId) {
|
|
727
|
-
open.text += text;
|
|
864
|
+
open.text += reasoningDeltaJoiner(open.text, text) + text;
|
|
728
865
|
break;
|
|
729
866
|
}
|
|
730
867
|
closeStreamingTail();
|
|
@@ -740,6 +877,7 @@ function buildTimeline(events) {
|
|
|
740
877
|
}
|
|
741
878
|
case "agent.toolCall.created": {
|
|
742
879
|
const name = typeof payload.name === "string" ? payload.name : "tool";
|
|
880
|
+
const display = parseToolDisplayMetadata(payload.display);
|
|
743
881
|
const callId = typeof payload.id === "string" ? payload.id : null;
|
|
744
882
|
const args = payload.arguments ?? null;
|
|
745
883
|
closeStreamingTail();
|
|
@@ -747,13 +885,16 @@ function buildTimeline(events) {
|
|
|
747
885
|
break;
|
|
748
886
|
}
|
|
749
887
|
if (toolMatchesLeaf(name, WORKER_SPAWN_TOOL) || toolMatchesLeaf(name, WORKER_MESSAGE_TOOL)) {
|
|
888
|
+
const spawn = toolMatchesLeaf(name, WORKER_SPAWN_TOOL);
|
|
889
|
+
const title = spawn ? workerTitle(args) : null;
|
|
750
890
|
items.push({
|
|
751
891
|
kind: "worker",
|
|
752
892
|
id: event.id,
|
|
753
893
|
turnId,
|
|
754
894
|
callId,
|
|
755
|
-
action:
|
|
895
|
+
action: spawn ? "spawn" : "message",
|
|
756
896
|
prompt: workerPrompt(args),
|
|
897
|
+
...title ? { title } : {},
|
|
757
898
|
workerSessionId: extractSessionRef(args),
|
|
758
899
|
failure: null,
|
|
759
900
|
status: "running",
|
|
@@ -769,6 +910,7 @@ function buildTimeline(events) {
|
|
|
769
910
|
(item) => item.kind === "tool-call" && item.callId === callId
|
|
770
911
|
);
|
|
771
912
|
if (existing) {
|
|
913
|
+
if (display) existing.display = display;
|
|
772
914
|
if (args != null) {
|
|
773
915
|
existing.arguments = args;
|
|
774
916
|
}
|
|
@@ -785,6 +927,7 @@ function buildTimeline(events) {
|
|
|
785
927
|
turnId,
|
|
786
928
|
callId,
|
|
787
929
|
name,
|
|
930
|
+
...display ? { display } : {},
|
|
788
931
|
arguments: args,
|
|
789
932
|
output: void 0,
|
|
790
933
|
truncation: null,
|
|
@@ -802,10 +945,17 @@ function buildTimeline(events) {
|
|
|
802
945
|
if (!target) {
|
|
803
946
|
break;
|
|
804
947
|
}
|
|
948
|
+
resolvePresentationWait(event, turnId ?? target.turnId);
|
|
805
949
|
if (target.kind === "worker") {
|
|
806
950
|
target.status = isErrorOutput(payload) ? "failed" : "complete";
|
|
807
951
|
target.workerSessionId = target.workerSessionId ?? extractSessionRef(payload.output);
|
|
808
952
|
target.failure = target.status === "failed" ? workerFailure(payload.output) : null;
|
|
953
|
+
if (target.status === "complete" && target.workerSessionId) {
|
|
954
|
+
if (target.action === "spawn") workerSessions.add(target.workerSessionId);
|
|
955
|
+
if (workerSessions.has(target.workerSessionId)) {
|
|
956
|
+
pendingWorkerSessions.add(target.workerSessionId);
|
|
957
|
+
}
|
|
958
|
+
}
|
|
809
959
|
break;
|
|
810
960
|
}
|
|
811
961
|
const truncation = toolCallTruncation(payload);
|
|
@@ -826,6 +976,27 @@ function buildTimeline(events) {
|
|
|
826
976
|
label: target.name
|
|
827
977
|
};
|
|
828
978
|
}
|
|
979
|
+
const learningRefusal = learningRefusalFromToolOutput(payload.output);
|
|
980
|
+
if (learningRefusal) {
|
|
981
|
+
const key = JSON.stringify([
|
|
982
|
+
turnId ?? target.turnId,
|
|
983
|
+
learningRefusal.destination,
|
|
984
|
+
learningRefusal.reason,
|
|
985
|
+
learningRefusal.skillId ?? null
|
|
986
|
+
]);
|
|
987
|
+
if (!learningRefusalNotices.has(key)) {
|
|
988
|
+
learningRefusalNotices.add(key);
|
|
989
|
+
closeStreamingTail();
|
|
990
|
+
items.push({
|
|
991
|
+
kind: "notice",
|
|
992
|
+
id: `${event.id}-learning-refusal`,
|
|
993
|
+
tone: "failed",
|
|
994
|
+
text: learningRefusalText(t, learningRefusal),
|
|
995
|
+
learningRefusal,
|
|
996
|
+
occurredAt: event.occurredAt
|
|
997
|
+
});
|
|
998
|
+
}
|
|
999
|
+
}
|
|
829
1000
|
break;
|
|
830
1001
|
}
|
|
831
1002
|
case "turn.queued": {
|
|
@@ -849,7 +1020,7 @@ function buildTimeline(events) {
|
|
|
849
1020
|
null,
|
|
850
1021
|
0,
|
|
851
1022
|
queuedAt,
|
|
852
|
-
`${
|
|
1023
|
+
`${turnId}-queue`
|
|
853
1024
|
);
|
|
854
1025
|
break;
|
|
855
1026
|
}
|
|
@@ -870,18 +1041,18 @@ function buildTimeline(events) {
|
|
|
870
1041
|
0,
|
|
871
1042
|
void 0,
|
|
872
1043
|
void 0,
|
|
873
|
-
status === "cancelled"
|
|
1044
|
+
status === "cancelled" ? startupLifecycleWaitReason(payload) ?? (payload.failureCode === "rotation_in_progress" ? "rotation_in_progress" : void 0) : void 0
|
|
874
1045
|
);
|
|
875
1046
|
break;
|
|
876
1047
|
}
|
|
877
|
-
if ((name === "repository-clone" || name === "file-resource-download") && status !== "failed") {
|
|
1048
|
+
if ((name === "repository-clone" || name === "file-resource-download" || name === "optional-repository-access") && status !== "failed") {
|
|
878
1049
|
break;
|
|
879
1050
|
}
|
|
880
1051
|
const existing = findOpenSandbox(items, name);
|
|
881
1052
|
if (existing && status !== "running") {
|
|
882
1053
|
existing.status = status;
|
|
883
1054
|
if (origin) existing.origin = origin;
|
|
884
|
-
const message = failureMessage(payload);
|
|
1055
|
+
const message = failureMessage(t, payload);
|
|
885
1056
|
if (message) {
|
|
886
1057
|
existing.output = existing.output ? `${existing.output}
|
|
887
1058
|
${message}` : message;
|
|
@@ -896,7 +1067,7 @@ ${message}` : message;
|
|
|
896
1067
|
turnId,
|
|
897
1068
|
name,
|
|
898
1069
|
command: typeof payload.command === "string" ? payload.command : null,
|
|
899
|
-
output: failureMessage(payload) ?? "",
|
|
1070
|
+
output: failureMessage(t, payload) ?? "",
|
|
900
1071
|
origin,
|
|
901
1072
|
status,
|
|
902
1073
|
occurredAt: event.occurredAt
|
|
@@ -937,40 +1108,89 @@ ${message}` : message;
|
|
|
937
1108
|
if (!isSessionStatus(status)) {
|
|
938
1109
|
break;
|
|
939
1110
|
}
|
|
1111
|
+
const blocked = status === "requires_action" && payload.code === "admission_blocked";
|
|
1112
|
+
if (!blocked && openAdmissionBlocks.length > 0) {
|
|
1113
|
+
for (const open of openAdmissionBlocks) open.resolvedAt = event.occurredAt;
|
|
1114
|
+
openAdmissionBlocks = [];
|
|
1115
|
+
}
|
|
1116
|
+
if (status === "running") resolvePresentationWait(event, turnId);
|
|
940
1117
|
if (!ATTENTION_STATUSES.has(status)) {
|
|
941
1118
|
break;
|
|
942
1119
|
}
|
|
943
|
-
const previous = [...items].reverse().find((
|
|
944
|
-
if (previous?.status === status) {
|
|
1120
|
+
const previous = [...items].reverse().find((item2) => item2.kind === "session-status");
|
|
1121
|
+
if (previous?.status === status && !previous.resolvedAt && Boolean(previous.blocked) === blocked) {
|
|
945
1122
|
break;
|
|
946
1123
|
}
|
|
947
|
-
|
|
1124
|
+
const item = {
|
|
948
1125
|
kind: "session-status",
|
|
949
1126
|
id: event.id,
|
|
950
1127
|
status,
|
|
951
|
-
occurredAt: event.occurredAt
|
|
952
|
-
|
|
1128
|
+
occurredAt: event.occurredAt,
|
|
1129
|
+
...blocked ? { blocked: true } : {}
|
|
1130
|
+
};
|
|
1131
|
+
if (blocked) {
|
|
1132
|
+
openAdmissionBlocks.push(item);
|
|
1133
|
+
items.push(item);
|
|
1134
|
+
} else if (status === "requires_action") rememberPresentationWait(item, turnId);
|
|
1135
|
+
else {
|
|
1136
|
+
items.push(item);
|
|
1137
|
+
if (status === "failed") {
|
|
1138
|
+
const key = turnId ?? presentationTurnId;
|
|
1139
|
+
const failures = presentationFailures.get(key) ?? [];
|
|
1140
|
+
failures.push(item);
|
|
1141
|
+
presentationFailures.set(key, failures);
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
953
1144
|
break;
|
|
954
1145
|
}
|
|
955
|
-
case "
|
|
1146
|
+
case "subscription.account.switched": {
|
|
1147
|
+
const text = payload.reason === "return_to_preferred" ? t("timeline.projection.returnedToYourPreferredModel") : payload.reason === "failover_cross_provider" ? t("timeline.projection.switchedToAFallbackModel") : t("timeline.projection.switchedToAnotherSubscriptionAccount");
|
|
956
1148
|
items.push({
|
|
957
1149
|
kind: "notice",
|
|
958
1150
|
id: event.id,
|
|
959
|
-
tone: "
|
|
960
|
-
text
|
|
1151
|
+
tone: "input",
|
|
1152
|
+
text,
|
|
961
1153
|
occurredAt: event.occurredAt
|
|
962
1154
|
});
|
|
963
1155
|
break;
|
|
964
1156
|
}
|
|
965
|
-
case "
|
|
966
|
-
|
|
967
|
-
|
|
1157
|
+
case "codex.capacity.waiting":
|
|
1158
|
+
case "turn.capacity_waiting": {
|
|
1159
|
+
const capacityWait = capacityWaitPresentation(t, event.type, payload, turnId);
|
|
1160
|
+
const item = {
|
|
968
1161
|
kind: "notice",
|
|
969
1162
|
id: event.id,
|
|
970
1163
|
tone: "waiting",
|
|
971
|
-
text:
|
|
1164
|
+
text: capacityWait.text,
|
|
1165
|
+
capacityWait: {
|
|
1166
|
+
turnId: capacityWait.turnId,
|
|
1167
|
+
label: capacityWait.label,
|
|
1168
|
+
detail: capacityWait.detail
|
|
1169
|
+
},
|
|
972
1170
|
occurredAt: event.occurredAt
|
|
1171
|
+
};
|
|
1172
|
+
openCapacityWaits = openCapacityWaits.filter((open) => {
|
|
1173
|
+
if ((open.capacityWait?.turnId ?? null) !== turnId) return true;
|
|
1174
|
+
open.resolvedAt = event.occurredAt;
|
|
1175
|
+
return false;
|
|
973
1176
|
});
|
|
1177
|
+
items.push(item);
|
|
1178
|
+
openCapacityWaits.push(item);
|
|
1179
|
+
break;
|
|
1180
|
+
}
|
|
1181
|
+
case "session.requiresAction": {
|
|
1182
|
+
finalizeOpen(turnId, "complete", event.occurredAt);
|
|
1183
|
+
rememberPresentationWait(
|
|
1184
|
+
{
|
|
1185
|
+
kind: "notice",
|
|
1186
|
+
id: event.id,
|
|
1187
|
+
tone: "waiting",
|
|
1188
|
+
text: t("timeline.projection.approvalNeededTheTurnIs"),
|
|
1189
|
+
approval: true,
|
|
1190
|
+
occurredAt: event.occurredAt
|
|
1191
|
+
},
|
|
1192
|
+
turnId
|
|
1193
|
+
);
|
|
974
1194
|
break;
|
|
975
1195
|
}
|
|
976
1196
|
case "session.context.compaction.requested":
|
|
@@ -984,6 +1204,7 @@ ${message}` : message;
|
|
|
984
1204
|
estimatedTokensBefore: numberOrNull(payload.estimatedTokensBefore),
|
|
985
1205
|
estimatedTokensAfter: null,
|
|
986
1206
|
skipReason: null,
|
|
1207
|
+
providerRejection: null,
|
|
987
1208
|
implementation: typeof payload.implementation === "string" ? payload.implementation : null,
|
|
988
1209
|
occurredAt: event.occurredAt
|
|
989
1210
|
});
|
|
@@ -999,6 +1220,7 @@ ${message}` : message;
|
|
|
999
1220
|
estimatedTokensBefore: numberOrNull(payload.estimatedTokensBefore),
|
|
1000
1221
|
estimatedTokensAfter: numberOrNull(payload.estimatedTokensAfter),
|
|
1001
1222
|
skipReason: null,
|
|
1223
|
+
providerRejection: null,
|
|
1002
1224
|
implementation: typeof payload.implementation === "string" ? payload.implementation : null,
|
|
1003
1225
|
occurredAt: event.occurredAt
|
|
1004
1226
|
});
|
|
@@ -1014,6 +1236,7 @@ ${message}` : message;
|
|
|
1014
1236
|
estimatedTokensBefore: numberOrNull(payload.estimatedTokensBefore),
|
|
1015
1237
|
estimatedTokensAfter: null,
|
|
1016
1238
|
skipReason: typeof payload.reason === "string" ? payload.reason : null,
|
|
1239
|
+
providerRejection: compactionProviderRejection(payload),
|
|
1017
1240
|
implementation: typeof payload.implementation === "string" ? payload.implementation : null,
|
|
1018
1241
|
occurredAt: event.occurredAt
|
|
1019
1242
|
});
|
|
@@ -1025,6 +1248,17 @@ ${message}` : message;
|
|
|
1025
1248
|
turnId,
|
|
1026
1249
|
(startupRecoveryRevisionByTurn.get(turnId) ?? 0) + 1
|
|
1027
1250
|
);
|
|
1251
|
+
if (!event.duplicateOfEventId && (!event.turnAssociation || event.turnAssociation === "current")) {
|
|
1252
|
+
for (const item of items) {
|
|
1253
|
+
if (item.kind === "turn-end" && item.turnId === turnId && item.outcome === "failed") {
|
|
1254
|
+
item.resumedAt ??= event.occurredAt;
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
for (const item of presentationFailures.get(turnId) ?? []) {
|
|
1258
|
+
item.resolvedAt = event.occurredAt;
|
|
1259
|
+
}
|
|
1260
|
+
presentationFailures.delete(turnId);
|
|
1261
|
+
}
|
|
1028
1262
|
}
|
|
1029
1263
|
break;
|
|
1030
1264
|
}
|
|
@@ -1034,6 +1268,7 @@ ${message}` : message;
|
|
|
1034
1268
|
case "tool.auth_needed":
|
|
1035
1269
|
case "credential.auth_needed": {
|
|
1036
1270
|
const capability = capabilityAuthorizationRequest(payload.capability);
|
|
1271
|
+
const setupRequest = customMcpSetupRequest(payload.setupRequest);
|
|
1037
1272
|
if (event.type === "tool.auth_needed" && !stringValue(payload.toolName) && stringValue(payload.serverId) !== "codex_apps") {
|
|
1038
1273
|
break;
|
|
1039
1274
|
}
|
|
@@ -1043,7 +1278,9 @@ ${message}` : message;
|
|
|
1043
1278
|
id: event.id,
|
|
1044
1279
|
turnId,
|
|
1045
1280
|
serverId: typeof payload.serverId === "string" ? payload.serverId : null,
|
|
1046
|
-
|
|
1281
|
+
canonicalServerId: typeof payload.canonicalServerId === "string" ? payload.canonicalServerId : null,
|
|
1282
|
+
connectionSubjectScope: payload.connectionSubjectScope === "subject" || payload.connectionSubjectScope === "workspace" ? payload.connectionSubjectScope : null,
|
|
1283
|
+
source: capability || setupRequest ? "capability" : event.type === "tool.auth_needed" ? "tool" : "credential",
|
|
1047
1284
|
providerDomain: stringValue(payload.providerDomain),
|
|
1048
1285
|
connectionId: typeof payload.connectionId === "string" ? payload.connectionId : null,
|
|
1049
1286
|
authoritySource: payload.authoritySource === "host" ? "host" : null,
|
|
@@ -1055,10 +1292,15 @@ ${message}` : message;
|
|
|
1055
1292
|
toolName: typeof payload.toolName === "string" ? payload.toolName : null,
|
|
1056
1293
|
authorizationUrl: typeof payload.authorizationUrl === "string" ? payload.authorizationUrl : null,
|
|
1057
1294
|
capability,
|
|
1295
|
+
setupRequest,
|
|
1058
1296
|
occurredAt: event.occurredAt
|
|
1059
1297
|
});
|
|
1060
1298
|
break;
|
|
1061
1299
|
}
|
|
1300
|
+
case "usage.exhausted": {
|
|
1301
|
+
allowanceNotice(event, turnId);
|
|
1302
|
+
break;
|
|
1303
|
+
}
|
|
1062
1304
|
case "turn.completed": {
|
|
1063
1305
|
if (payload.maintenance === "context_compaction") {
|
|
1064
1306
|
finalizeOpen(turnId, "complete", event.occurredAt);
|
|
@@ -1066,16 +1308,33 @@ ${message}` : message;
|
|
|
1066
1308
|
takePendingWaitOutcome(turnId);
|
|
1067
1309
|
break;
|
|
1068
1310
|
}
|
|
1311
|
+
const allowance = parseAllowanceExhaustedRefusal(payload);
|
|
1312
|
+
if (payload.segmentLimit === SESSION_USAGE_LIMIT_SEGMENT) {
|
|
1313
|
+
finalizeOpen(turnId, "complete", event.occurredAt);
|
|
1314
|
+
takeAgentResponse(turnId);
|
|
1315
|
+
takePendingWaitOutcome(turnId);
|
|
1316
|
+
items.push(turnEndItem(event, "complete", null));
|
|
1317
|
+
items.push(sessionUsageLimitNotice(t, event, payload));
|
|
1318
|
+
break;
|
|
1319
|
+
}
|
|
1320
|
+
if (allowance) {
|
|
1321
|
+
finalizeOpen(turnId, "complete", event.occurredAt);
|
|
1322
|
+
takeAgentResponse(turnId);
|
|
1323
|
+
takePendingWaitOutcome(turnId);
|
|
1324
|
+
items.push(turnEndItem(event, "failed", ALLOWANCE_TURN_END_TEXT(t)));
|
|
1325
|
+
allowanceNotice(event, turnId);
|
|
1326
|
+
break;
|
|
1327
|
+
}
|
|
1069
1328
|
if (isCreditExhaustionPayload(payload)) {
|
|
1070
1329
|
finalizeOpen(turnId, "complete", event.occurredAt);
|
|
1071
1330
|
takeAgentResponse(turnId);
|
|
1072
1331
|
takePendingWaitOutcome(turnId);
|
|
1073
|
-
items.push(turnEndItem(event, "failed", CREDIT_EXHAUSTION_MESSAGE));
|
|
1332
|
+
items.push(turnEndItem(event, "failed", CREDIT_EXHAUSTION_MESSAGE(t)));
|
|
1074
1333
|
items.push({
|
|
1075
1334
|
kind: "notice",
|
|
1076
1335
|
id: event.id,
|
|
1077
1336
|
tone: "failed",
|
|
1078
|
-
text: CREDIT_EXHAUSTION_MESSAGE,
|
|
1337
|
+
text: CREDIT_EXHAUSTION_MESSAGE(t),
|
|
1079
1338
|
occurredAt: event.occurredAt
|
|
1080
1339
|
});
|
|
1081
1340
|
break;
|
|
@@ -1093,6 +1352,9 @@ ${message}` : message;
|
|
|
1093
1352
|
if (latestAgentResponse && !latestAgentResponse.completed && finalOutput.startsWith(latestAgentResponse.item.text)) {
|
|
1094
1353
|
latestAgentResponse.item.text = finalOutput;
|
|
1095
1354
|
latestAgentResponse.item.streaming = false;
|
|
1355
|
+
if (latestAgentResponse.item.startedAt === void 0 && latestAgentResponse.item.occurredAt !== event.occurredAt) {
|
|
1356
|
+
latestAgentResponse.item.startedAt = latestAgentResponse.item.occurredAt;
|
|
1357
|
+
}
|
|
1096
1358
|
latestAgentResponse.item.occurredAt = event.occurredAt;
|
|
1097
1359
|
const responseIndex = items.indexOf(latestAgentResponse.item);
|
|
1098
1360
|
if (responseIndex >= 0 && responseIndex < items.length - 1) {
|
|
@@ -1113,19 +1375,32 @@ ${message}` : message;
|
|
|
1113
1375
|
finalizeOpen(turnId, "complete", event.occurredAt);
|
|
1114
1376
|
const completedTurn = turnEndItem(event, "complete", null);
|
|
1115
1377
|
items.push(completedTurn);
|
|
1378
|
+
if (turnCompletedWithEmptyFinalReply(payload)) {
|
|
1379
|
+
items.push({
|
|
1380
|
+
kind: "notice",
|
|
1381
|
+
id: `${event.id}-empty-final-reply`,
|
|
1382
|
+
tone: "input",
|
|
1383
|
+
text: EMPTY_FINAL_REPLY_NOTICE,
|
|
1384
|
+
recordedOutcome: true,
|
|
1385
|
+
occurredAt: event.occurredAt
|
|
1386
|
+
});
|
|
1387
|
+
}
|
|
1116
1388
|
const hasCompletedFinalResponse = latestAgentResponse?.completed === true && latestAgentResponse.item.phase !== "commentary" && Boolean(visibleTrackedResponse);
|
|
1117
1389
|
if (!hasAuthoritativeFinalOutput && pendingWaitOutcome) {
|
|
1118
1390
|
completedTurn.preserveWaitResponse = true;
|
|
1119
1391
|
}
|
|
1120
1392
|
if (!hasAuthoritativeFinalOutput && !hasCompletedFinalResponse && pendingWaitOutcome) {
|
|
1121
|
-
|
|
1393
|
+
const notice = {
|
|
1122
1394
|
kind: "notice",
|
|
1123
1395
|
id: `${pendingWaitOutcome.id}-visible-outcome`,
|
|
1124
1396
|
tone: "waiting",
|
|
1125
|
-
text: waitingOutcomeText(pendingWaitOutcome.reason),
|
|
1397
|
+
text: waitingOutcomeText(t, pendingWaitOutcome.reason),
|
|
1126
1398
|
recordedOutcome: true,
|
|
1399
|
+
...pendingWorkerSessions.size > 0 ? { waitingAgents: pendingWorkerSessions.size } : {},
|
|
1127
1400
|
occurredAt: pendingWaitOutcome.occurredAt
|
|
1128
|
-
}
|
|
1401
|
+
};
|
|
1402
|
+
items.push(notice);
|
|
1403
|
+
openWaitNotice = notice;
|
|
1129
1404
|
}
|
|
1130
1405
|
break;
|
|
1131
1406
|
}
|
|
@@ -1133,22 +1408,43 @@ ${message}` : message;
|
|
|
1133
1408
|
takeAgentResponse(turnId);
|
|
1134
1409
|
takePendingWaitOutcome(turnId);
|
|
1135
1410
|
const hadActivity = hasTurnActivity(items, turnId);
|
|
1136
|
-
const
|
|
1411
|
+
const allowance = parseAllowanceExhaustedRefusal(payload);
|
|
1412
|
+
const failureText = allowance ? ALLOWANCE_TURN_END_TEXT(t) : isCreditExhaustionPayload(payload) ? CREDIT_EXHAUSTION_MESSAGE(t) : failureMessage(t, payload);
|
|
1137
1413
|
finalizeOpen(turnId, "cancelled", event.occurredAt);
|
|
1138
1414
|
items.push(turnEndItem(event, "failed", failureText));
|
|
1139
|
-
|
|
1415
|
+
const failure = allowance ? null : presentTurnFailureText(t, failureText);
|
|
1416
|
+
let landmarkIndex = -1;
|
|
1417
|
+
if (failure?.detail !== void 0 && turnId !== null) {
|
|
1418
|
+
for (let index = items.length - 2; index >= 0; index -= 1) {
|
|
1419
|
+
const item = items[index];
|
|
1420
|
+
if (item?.kind === "turn-end" && item.turnId === turnId) break;
|
|
1421
|
+
if (item?.kind === "context-compaction" && item.turnId === turnId && item.phase === "skipped" && item.skipReason === "summarization_failed") {
|
|
1422
|
+
landmarkIndex = index;
|
|
1423
|
+
break;
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
const landmark = landmarkIndex >= 0 ? items[landmarkIndex] : void 0;
|
|
1428
|
+
if (landmark?.kind === "context-compaction" && failure?.detail !== void 0) {
|
|
1429
|
+
items[landmarkIndex] = { ...landmark, failureDetail: failure.detail };
|
|
1430
|
+
}
|
|
1431
|
+
if (allowance) {
|
|
1432
|
+
allowanceNotice(event, turnId);
|
|
1433
|
+
} else if (!hadActivity && !landmark) {
|
|
1140
1434
|
items.push({
|
|
1141
1435
|
kind: "notice",
|
|
1142
1436
|
id: event.id,
|
|
1143
1437
|
tone: "failed",
|
|
1144
|
-
text:
|
|
1438
|
+
text: failure?.summary ?? t("timeline.projection.theTurnFailed"),
|
|
1439
|
+
...failure?.detail ? { details: { label: t("timeline.projection.details"), value: failure.detail } } : {},
|
|
1145
1440
|
occurredAt: event.occurredAt
|
|
1146
1441
|
});
|
|
1147
1442
|
}
|
|
1148
1443
|
break;
|
|
1149
1444
|
}
|
|
1445
|
+
case "turn.superseded":
|
|
1150
1446
|
case "turn.cancelled": {
|
|
1151
|
-
if (turnId && !prescan.startedTurnIds.has(turnId)) {
|
|
1447
|
+
if (event.type === "turn.cancelled" && turnId && !prescan.startedTurnIds.has(turnId)) {
|
|
1152
1448
|
break;
|
|
1153
1449
|
}
|
|
1154
1450
|
takeAgentResponse(turnId);
|
|
@@ -1161,12 +1457,46 @@ ${message}` : message;
|
|
|
1161
1457
|
kind: "notice",
|
|
1162
1458
|
id: event.id,
|
|
1163
1459
|
tone: "cancelled",
|
|
1164
|
-
text: "
|
|
1460
|
+
text: t("timeline.projection.interrupted"),
|
|
1165
1461
|
occurredAt: event.occurredAt
|
|
1166
1462
|
});
|
|
1167
1463
|
}
|
|
1168
1464
|
break;
|
|
1169
1465
|
}
|
|
1466
|
+
case "instruction.confirmation.recovered": {
|
|
1467
|
+
const receipt = asRecord2(payload.receipt);
|
|
1468
|
+
if (receipt.outcome !== "published") break;
|
|
1469
|
+
closeStreamingTail();
|
|
1470
|
+
items.push({
|
|
1471
|
+
kind: "notice",
|
|
1472
|
+
id: event.id,
|
|
1473
|
+
tone: "input",
|
|
1474
|
+
text: t("timeline.projection.yourPreviouslyApprovedWorkspaceInstruction"),
|
|
1475
|
+
occurredAt: event.occurredAt
|
|
1476
|
+
});
|
|
1477
|
+
break;
|
|
1478
|
+
}
|
|
1479
|
+
case "knowledge.confirmation.recovered":
|
|
1480
|
+
case "knowledge.source.prepared":
|
|
1481
|
+
case "knowledge.source.failed": {
|
|
1482
|
+
const receipt = asRecord2(payload.receipt);
|
|
1483
|
+
const outcome = event.type === "knowledge.source.failed" ? "failed" : receipt.outcome;
|
|
1484
|
+
if (event.type !== "knowledge.confirmation.recovered" && typeof payload.fileId !== "string" || !["published", "pending", "rejected", "archived", "failed"].includes(String(outcome)))
|
|
1485
|
+
break;
|
|
1486
|
+
closeStreamingTail();
|
|
1487
|
+
items.push({
|
|
1488
|
+
kind: "knowledge",
|
|
1489
|
+
id: event.id,
|
|
1490
|
+
turnId,
|
|
1491
|
+
fileId: typeof payload.fileId === "string" ? payload.fileId : void 0,
|
|
1492
|
+
filename: typeof payload.filename === "string" ? payload.filename : void 0,
|
|
1493
|
+
entryId: typeof receipt.entryId === "string" ? receipt.entryId : void 0,
|
|
1494
|
+
status: outcome === "failed" ? "failed" : "complete",
|
|
1495
|
+
outcome,
|
|
1496
|
+
occurredAt: event.occurredAt
|
|
1497
|
+
});
|
|
1498
|
+
break;
|
|
1499
|
+
}
|
|
1170
1500
|
case "memory.saved":
|
|
1171
1501
|
case "memory.corrected": {
|
|
1172
1502
|
const memory = memoryItem(event.id, event.type, turnId, payload, event.occurredAt);
|
|
@@ -1217,7 +1547,14 @@ ${message}` : message;
|
|
|
1217
1547
|
break;
|
|
1218
1548
|
}
|
|
1219
1549
|
}
|
|
1550
|
+
const sourceEventsById = new Map(events.map((event) => [event.id, event]));
|
|
1220
1551
|
for (const item of items) {
|
|
1552
|
+
const source = sourceEventsById.get(item.id);
|
|
1553
|
+
const canonical = "annotationSource" in item ? item.annotationSource : void 0;
|
|
1554
|
+
item.sourceEvents = [
|
|
1555
|
+
...source ? [{ eventId: source.id, sequence: source.sequence }] : [],
|
|
1556
|
+
...canonical && canonical.eventId !== source?.id ? [{ eventId: canonical.eventId, sequence: canonical.sequence }] : []
|
|
1557
|
+
];
|
|
1221
1558
|
if (item.kind === "agent-message") {
|
|
1222
1559
|
item.text = stripOpaqueCitationTokens(item.text);
|
|
1223
1560
|
}
|
|
@@ -1277,9 +1614,11 @@ function humanInputQuestions(value) {
|
|
|
1277
1614
|
const id = stringValue(question.id);
|
|
1278
1615
|
const prompt = stringValue(question.prompt);
|
|
1279
1616
|
const kind = question.kind;
|
|
1280
|
-
if (!id || !prompt || kind !== "text" && kind !== "single_select" && kind !== "multi_select") {
|
|
1617
|
+
if (!id || !prompt || kind !== "text" && kind !== "single_select" && kind !== "multi_select" && kind !== "secret") {
|
|
1281
1618
|
return [];
|
|
1282
1619
|
}
|
|
1620
|
+
const secret = kind === "secret" ? humanInputSecretSpec(question.secret) : null;
|
|
1621
|
+
if (kind === "secret" && !secret) return [];
|
|
1283
1622
|
const options = Array.isArray(question.options) ? question.options.map(asRecord2).flatMap((option) => {
|
|
1284
1623
|
const optionId = stringValue(option.id);
|
|
1285
1624
|
const label = stringValue(option.label);
|
|
@@ -1294,18 +1633,45 @@ function humanInputQuestions(value) {
|
|
|
1294
1633
|
helpText: stringValue(question.helpText) || null,
|
|
1295
1634
|
options,
|
|
1296
1635
|
required: question.required === true,
|
|
1297
|
-
allowOther: question.allowOther === true
|
|
1636
|
+
allowOther: question.allowOther === true,
|
|
1637
|
+
...secret ? { secret } : {}
|
|
1298
1638
|
}
|
|
1299
1639
|
];
|
|
1300
1640
|
});
|
|
1301
1641
|
}
|
|
1642
|
+
function humanInputSecretSpec(value) {
|
|
1643
|
+
const spec = asRecord2(value);
|
|
1644
|
+
const item = stringValue(spec.item);
|
|
1645
|
+
if (!item) return null;
|
|
1646
|
+
return spec;
|
|
1647
|
+
}
|
|
1648
|
+
function humanInputSecretResult(value) {
|
|
1649
|
+
if (value === void 0 || value === null) return null;
|
|
1650
|
+
const result = asRecord2(value);
|
|
1651
|
+
const reference = stringValue(result.reference);
|
|
1652
|
+
const vaultName = stringValue(result.vaultName);
|
|
1653
|
+
const itemName = stringValue(result.itemName);
|
|
1654
|
+
const saveTo = result.saveTo;
|
|
1655
|
+
if (!reference || !vaultName || !itemName || saveTo !== "user" && saveTo !== "task" && saveTo !== "workspace") {
|
|
1656
|
+
return null;
|
|
1657
|
+
}
|
|
1658
|
+
return {
|
|
1659
|
+
reference,
|
|
1660
|
+
username: stringValue(result.username) || null,
|
|
1661
|
+
vaultName,
|
|
1662
|
+
itemName,
|
|
1663
|
+
saveTo
|
|
1664
|
+
};
|
|
1665
|
+
}
|
|
1302
1666
|
function humanInputAnswer(value) {
|
|
1303
1667
|
const questionId = stringValue(value.questionId);
|
|
1304
1668
|
if (!questionId) return null;
|
|
1669
|
+
const secret = humanInputSecretResult(value.secret);
|
|
1305
1670
|
return {
|
|
1306
1671
|
questionId,
|
|
1307
1672
|
values: Array.isArray(value.values) ? value.values.filter((answer) => typeof answer === "string") : [],
|
|
1308
|
-
...typeof value.other === "string" && value.other ? { other: value.other } : {}
|
|
1673
|
+
...typeof value.other === "string" && value.other ? { other: value.other } : {},
|
|
1674
|
+
...secret ? { secret } : {}
|
|
1309
1675
|
};
|
|
1310
1676
|
}
|
|
1311
1677
|
function humanInputAnswerSummary(answer, question) {
|
|
@@ -1317,7 +1683,8 @@ function humanInputAnswerSummary(answer, question) {
|
|
|
1317
1683
|
questionId: answer.questionId,
|
|
1318
1684
|
label: question?.label || question?.prompt || fallbackLabel,
|
|
1319
1685
|
prompt: question?.prompt || fallbackLabel,
|
|
1320
|
-
values
|
|
1686
|
+
values,
|
|
1687
|
+
...answer.secret ? { secret: answer.secret } : {}
|
|
1321
1688
|
};
|
|
1322
1689
|
}
|
|
1323
1690
|
function providerNativeToolStatus(rawValue) {
|
|
@@ -1361,7 +1728,9 @@ function mergeToolCallRaw(existingValue, nextValue) {
|
|
|
1361
1728
|
function stripOpaqueCitationTokens(text) {
|
|
1362
1729
|
return text.replace(/\s*cite(?:[^]+)+/gu, "");
|
|
1363
1730
|
}
|
|
1731
|
+
var ALLOWANCE_TURN_END_TEXT = (t) => t("timeline.projection.usageLimitReached");
|
|
1364
1732
|
function isCreditExhaustionPayload(payload) {
|
|
1733
|
+
if (payload.code === "allowance_exhausted") return false;
|
|
1365
1734
|
return isCreditExhaustion({
|
|
1366
1735
|
error: typeof payload.error === "string" ? payload.error : null,
|
|
1367
1736
|
detail: typeof payload.detail === "string" ? payload.detail : null,
|
|
@@ -1400,15 +1769,18 @@ function isActivityItem(item) {
|
|
|
1400
1769
|
case "sandbox":
|
|
1401
1770
|
case "startup-phase":
|
|
1402
1771
|
case "memory":
|
|
1772
|
+
case "knowledge":
|
|
1403
1773
|
case "fleet-decision":
|
|
1404
1774
|
return true;
|
|
1405
1775
|
default:
|
|
1406
1776
|
return false;
|
|
1407
1777
|
}
|
|
1408
1778
|
}
|
|
1409
|
-
function groupTimeline(items) {
|
|
1779
|
+
function groupTimeline(t, items, options = {}) {
|
|
1780
|
+
if (options.readableTurns || options.foldExchanges) return groupReadableTurns(t, items);
|
|
1410
1781
|
const groups = [];
|
|
1411
1782
|
for (const item of items) {
|
|
1783
|
+
if (item.kind === "notice" && item.capacityWait && item.resolvedAt) continue;
|
|
1412
1784
|
if (isActivityItem(item)) {
|
|
1413
1785
|
const open = groups[groups.length - 1];
|
|
1414
1786
|
if (open?.kind === "activity" && open.outcome === void 0) {
|
|
@@ -1431,6 +1803,417 @@ function groupTimeline(items) {
|
|
|
1431
1803
|
}
|
|
1432
1804
|
return groups;
|
|
1433
1805
|
}
|
|
1806
|
+
function groupReadableTurns(t, items) {
|
|
1807
|
+
let groups = [];
|
|
1808
|
+
const turns = /* @__PURE__ */ new Map();
|
|
1809
|
+
const seenTurns = /* @__PURE__ */ new Set();
|
|
1810
|
+
const settlements = /* @__PURE__ */ new Map();
|
|
1811
|
+
const compactionTurns = /* @__PURE__ */ new Map();
|
|
1812
|
+
const messages = /* @__PURE__ */ new Map();
|
|
1813
|
+
const capacityPauses = /* @__PURE__ */ new Map();
|
|
1814
|
+
const liveCapacityWaits = /* @__PURE__ */ new Map();
|
|
1815
|
+
const inputs = /* @__PURE__ */ new Map();
|
|
1816
|
+
const itemOrder = new Map(items.map((item, index) => [item.id, index]));
|
|
1817
|
+
const answersPerson = /* @__PURE__ */ new Set();
|
|
1818
|
+
let personAwaitingTurn = false;
|
|
1819
|
+
let steeredTurn;
|
|
1820
|
+
let legacyTurn = "start";
|
|
1821
|
+
let currentTurn = legacyTurn;
|
|
1822
|
+
for (const item of items) {
|
|
1823
|
+
if (item.kind === "user-message") {
|
|
1824
|
+
legacyTurn = item.id;
|
|
1825
|
+
personAwaitingTurn = true;
|
|
1826
|
+
steeredTurn = void 0;
|
|
1827
|
+
if (seenTurns.has(currentTurn) && !settlements.has(currentTurn)) {
|
|
1828
|
+
answersPerson.add(currentTurn);
|
|
1829
|
+
steeredTurn = currentTurn;
|
|
1830
|
+
}
|
|
1831
|
+
}
|
|
1832
|
+
const itemTurnId = item.kind === "notice" && item.capacityWait ? item.capacityWait.turnId : "turnId" in item ? item.turnId : null;
|
|
1833
|
+
const key = itemTurnId || legacyTurn;
|
|
1834
|
+
if (steeredTurn !== void 0 && key === steeredTurn && (isActivityItem(item) || item.kind === "agent-message" && item.text.trim())) {
|
|
1835
|
+
personAwaitingTurn = false;
|
|
1836
|
+
steeredTurn = void 0;
|
|
1837
|
+
}
|
|
1838
|
+
if (itemTurnId || isActivityItem(item) || item.kind === "agent-message" && item.text.trim()) {
|
|
1839
|
+
if (key !== currentTurn && !seenTurns.has(key)) {
|
|
1840
|
+
const previous = turns.get(currentTurn);
|
|
1841
|
+
if (!settlements.has(currentTurn)) {
|
|
1842
|
+
settlements.set(currentTurn, { endedAt: item.occurredAt });
|
|
1843
|
+
}
|
|
1844
|
+
if (previous?.work && !previous.work.endedAt) previous.work.endedAt = item.occurredAt;
|
|
1845
|
+
currentTurn = key;
|
|
1846
|
+
if (personAwaitingTurn) answersPerson.add(key);
|
|
1847
|
+
personAwaitingTurn = false;
|
|
1848
|
+
steeredTurn = void 0;
|
|
1849
|
+
}
|
|
1850
|
+
seenTurns.add(key);
|
|
1851
|
+
}
|
|
1852
|
+
const workForTurn = () => {
|
|
1853
|
+
let group = turns.get(key);
|
|
1854
|
+
const firstMessage = messages.get(key)?.[0];
|
|
1855
|
+
const messageStart = firstMessage?.startedAt ?? firstMessage?.occurredAt;
|
|
1856
|
+
const activityStart = item.kind === "startup-phase" ? item.loadingStartedAt ?? item.occurredAt : item.occurredAt;
|
|
1857
|
+
const startedAt = messageStart && Date.parse(messageStart) < Date.parse(activityStart) ? messageStart : activityStart;
|
|
1858
|
+
if (!group) {
|
|
1859
|
+
const settlement = settlements.get(key);
|
|
1860
|
+
group = {
|
|
1861
|
+
kind: "activity",
|
|
1862
|
+
id: `work-${key}`,
|
|
1863
|
+
items: [],
|
|
1864
|
+
work: { startedAt, details: [] }
|
|
1865
|
+
};
|
|
1866
|
+
if (settlement) {
|
|
1867
|
+
group.work.endedAt = settlement.endedAt;
|
|
1868
|
+
if (settlement.outcome) group.outcome = settlement.outcome;
|
|
1869
|
+
if (settlement.failureText) group.failureText = settlement.failureText;
|
|
1870
|
+
}
|
|
1871
|
+
turns.set(key, group);
|
|
1872
|
+
const firstMessageIndex = settlement && firstMessage ? groups.findIndex((entry) => entry.kind === "item" && entry.item === firstMessage) : -1;
|
|
1873
|
+
if (firstMessageIndex >= 0) groups.splice(firstMessageIndex, 0, group);
|
|
1874
|
+
else groups.push(group);
|
|
1875
|
+
} else if (Date.parse(startedAt) < Date.parse(group.work.startedAt)) {
|
|
1876
|
+
group.work.startedAt = startedAt;
|
|
1877
|
+
}
|
|
1878
|
+
return group;
|
|
1879
|
+
};
|
|
1880
|
+
if (isActivityItem(item)) {
|
|
1881
|
+
const group = workForTurn();
|
|
1882
|
+
group.items.push(item);
|
|
1883
|
+
const previous = group.work.details.at(-1);
|
|
1884
|
+
const preparing = (entry) => entry.kind === "startup-phase" || entry.kind === "reasoning" && !entry.text.trim();
|
|
1885
|
+
if (preparing(item) && previous?.kind === "activity" && previous.items.every(preparing) && previous.items.at(-1) === items[(itemOrder.get(item.id) ?? 0) - 1])
|
|
1886
|
+
previous.items.push(item);
|
|
1887
|
+
else
|
|
1888
|
+
group.work.details.push({ kind: "activity", id: `work-item-${item.id}`, items: [item] });
|
|
1889
|
+
delete group.work.waiting;
|
|
1890
|
+
} else if (item.kind === "notice" && item.capacityWait) {
|
|
1891
|
+
const pauses = capacityPauses.get(key) ?? [];
|
|
1892
|
+
pauses.push({
|
|
1893
|
+
startedAt: item.occurredAt,
|
|
1894
|
+
...item.resolvedAt ? { endedAt: item.resolvedAt } : {}
|
|
1895
|
+
});
|
|
1896
|
+
capacityPauses.set(key, pauses);
|
|
1897
|
+
if (!item.resolvedAt) {
|
|
1898
|
+
if (settlements.has(key)) groups.push({ kind: "item", item });
|
|
1899
|
+
else {
|
|
1900
|
+
workForTurn();
|
|
1901
|
+
liveCapacityWaits.set(key, item);
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1904
|
+
} else if (item.kind === "turn-end") {
|
|
1905
|
+
if (!item.resumedAt) {
|
|
1906
|
+
settlements.set(key, {
|
|
1907
|
+
endedAt: item.occurredAt,
|
|
1908
|
+
outcome: item.outcome,
|
|
1909
|
+
...item.failureText ? { failureText: item.failureText } : {}
|
|
1910
|
+
});
|
|
1911
|
+
}
|
|
1912
|
+
const group = turns.get(key);
|
|
1913
|
+
if (group?.work) {
|
|
1914
|
+
if (item.resumedAt) {
|
|
1915
|
+
group.work.details.push({
|
|
1916
|
+
kind: "item",
|
|
1917
|
+
item: {
|
|
1918
|
+
kind: "notice",
|
|
1919
|
+
id: item.id,
|
|
1920
|
+
tone: "failed",
|
|
1921
|
+
text: item.failureText ?? t("timeline.projection.theTurnFailedBeforeRetrying"),
|
|
1922
|
+
occurredAt: item.occurredAt
|
|
1923
|
+
}
|
|
1924
|
+
});
|
|
1925
|
+
continue;
|
|
1926
|
+
}
|
|
1927
|
+
group.outcome = item.outcome;
|
|
1928
|
+
if (item.failureText) group.failureText = item.failureText;
|
|
1929
|
+
group.work.endedAt = item.occurredAt;
|
|
1930
|
+
}
|
|
1931
|
+
} else if (item.kind === "context-compaction" && item.phase === "compacted") {
|
|
1932
|
+
compactionTurns.set(item, key);
|
|
1933
|
+
groups.push({ kind: "item", item });
|
|
1934
|
+
} else if (item.kind === "machine-input-batch" && item.members.every((member) => ROUTINE_MACHINE_INPUT_KINDS.has(member.kind))) {
|
|
1935
|
+
const previous = inputs.get(key);
|
|
1936
|
+
if (previous) {
|
|
1937
|
+
previous.members.push(
|
|
1938
|
+
...item.members.filter((member) => !previous.members.some((old) => old.id === member.id))
|
|
1939
|
+
);
|
|
1940
|
+
previous.sourceEvents = [...previous.sourceEvents ?? [], ...item.sourceEvents ?? []];
|
|
1941
|
+
} else {
|
|
1942
|
+
const batch = { ...item, compact: true, members: [...item.members] };
|
|
1943
|
+
inputs.set(key, batch);
|
|
1944
|
+
groups.push({ kind: "item", item: batch });
|
|
1945
|
+
}
|
|
1946
|
+
} else if (item.kind === "worker-completion" || item.kind === "goal" && item.action === "continuation") {
|
|
1947
|
+
const group = turns.get(currentTurn);
|
|
1948
|
+
if (group?.work) group.work.details.push({ kind: "item", item });
|
|
1949
|
+
else groups.push({ kind: "item", item });
|
|
1950
|
+
} else {
|
|
1951
|
+
const current = turns.get(currentTurn)?.work;
|
|
1952
|
+
const liveApprovalWait = item.kind === "notice" && item.tone === "waiting" && !item.recordedOutcome && !item.resolvedAt && item.approval === true && current !== void 0 && !current.endedAt;
|
|
1953
|
+
const liveStatusWait = item.kind === "session-status" && item.status === "requires_action" && !item.blocked && !item.resolvedAt && current !== void 0 && !current.endedAt;
|
|
1954
|
+
if (!liveApprovalWait && !liveStatusWait) groups.push({ kind: "item", item });
|
|
1955
|
+
if (current && !current.endedAt) {
|
|
1956
|
+
if (item.kind === "notice" && item.tone === "waiting" && !item.recordedOutcome && !item.resolvedAt) {
|
|
1957
|
+
current.waiting = {
|
|
1958
|
+
label: item.approval === true ? t("timeline.projection.waitingForYou") : t("timeline.projection.waiting"),
|
|
1959
|
+
since: item.occurredAt
|
|
1960
|
+
};
|
|
1961
|
+
} else if (item.kind === "session-status" && item.status === "requires_action" && !item.blocked && !item.resolvedAt) {
|
|
1962
|
+
current.waiting = {
|
|
1963
|
+
label: t("timeline.projection.waitingForYou"),
|
|
1964
|
+
since: item.occurredAt
|
|
1965
|
+
};
|
|
1966
|
+
} else if (item.kind === "session-status" && ["paused", "cancelled", "failed"].includes(item.status) && !item.resolvedAt) {
|
|
1967
|
+
current.endedAt = item.occurredAt;
|
|
1968
|
+
delete current.waiting;
|
|
1969
|
+
}
|
|
1970
|
+
}
|
|
1971
|
+
if (item.kind === "agent-message" && item.text.trim()) {
|
|
1972
|
+
const prose = messages.get(key) ?? [];
|
|
1973
|
+
prose.push(item);
|
|
1974
|
+
messages.set(key, prose);
|
|
1975
|
+
if ((item.phase !== "final_answer" || prose.length > 1) && (turns.has(key) || !settlements.has(key)))
|
|
1976
|
+
workForTurn();
|
|
1977
|
+
}
|
|
1978
|
+
}
|
|
1979
|
+
}
|
|
1980
|
+
for (const [key, group] of turns) {
|
|
1981
|
+
const work = group.work;
|
|
1982
|
+
const live = liveCapacityWaits.get(key);
|
|
1983
|
+
if (live?.capacityWait && !work.endedAt) {
|
|
1984
|
+
work.waiting = {
|
|
1985
|
+
label: live.capacityWait.label,
|
|
1986
|
+
since: live.occurredAt,
|
|
1987
|
+
detail: live.capacityWait.detail,
|
|
1988
|
+
// Its span is not work and may last until a quota resets: no clock.
|
|
1989
|
+
untimed: true
|
|
1990
|
+
};
|
|
1991
|
+
}
|
|
1992
|
+
const pausedMs = (capacityPauses.get(key) ?? []).reduce((total, pause) => {
|
|
1993
|
+
if (!pause.endedAt) return total;
|
|
1994
|
+
const start = Math.max(Date.parse(work.startedAt), Date.parse(pause.startedAt));
|
|
1995
|
+
const end = Math.min(
|
|
1996
|
+
work.endedAt ? Date.parse(work.endedAt) : Number.POSITIVE_INFINITY,
|
|
1997
|
+
Date.parse(pause.endedAt)
|
|
1998
|
+
);
|
|
1999
|
+
return Number.isFinite(start) && Number.isFinite(end) && end > start ? total + end - start : total;
|
|
2000
|
+
}, 0);
|
|
2001
|
+
if (pausedMs > 0) work.pausedMs = pausedMs;
|
|
2002
|
+
}
|
|
2003
|
+
groups = groups.filter((entry) => {
|
|
2004
|
+
if (entry.kind !== "item" || entry.item.kind !== "context-compaction") return true;
|
|
2005
|
+
const key = compactionTurns.get(entry.item);
|
|
2006
|
+
const work = key === void 0 ? void 0 : turns.get(key)?.work;
|
|
2007
|
+
if (!work) return true;
|
|
2008
|
+
work.details.push(entry);
|
|
2009
|
+
return false;
|
|
2010
|
+
});
|
|
2011
|
+
const beforeRows = /* @__PURE__ */ new Map();
|
|
2012
|
+
const afterRows = /* @__PURE__ */ new Map();
|
|
2013
|
+
const movedRows = /* @__PURE__ */ new Set();
|
|
2014
|
+
const foldedProse = /* @__PURE__ */ new Set();
|
|
2015
|
+
const positions = /* @__PURE__ */ new Map();
|
|
2016
|
+
const nextBoundary = /* @__PURE__ */ new Map();
|
|
2017
|
+
let boundary = groups.length;
|
|
2018
|
+
for (let index = groups.length - 1; index >= 0; index -= 1) {
|
|
2019
|
+
const entry = groups[index];
|
|
2020
|
+
positions.set(entry.kind === "item" ? entry.item : entry, index);
|
|
2021
|
+
if (entry.kind === "activity" && entry.work) {
|
|
2022
|
+
nextBoundary.set(entry, boundary);
|
|
2023
|
+
boundary = index;
|
|
2024
|
+
} else if (entry.kind === "item" && (entry.item.kind === "user-message" || entry.item.kind === "machine-input-batch")) {
|
|
2025
|
+
boundary = index;
|
|
2026
|
+
}
|
|
2027
|
+
}
|
|
2028
|
+
for (const [key, group] of turns) {
|
|
2029
|
+
const prose = messages.get(key) ?? [];
|
|
2030
|
+
const settledAt = group.work.endedAt;
|
|
2031
|
+
const responseCandidates = settledAt ? prose.filter(
|
|
2032
|
+
(message) => Date.parse(message.startedAt ?? message.occurredAt) <= Date.parse(settledAt)
|
|
2033
|
+
) : prose;
|
|
2034
|
+
const response = responseCandidates.filter((message) => message.phase === "final_answer").at(-1) ?? (settledAt ? responseCandidates.at(-1) ?? prose.filter((message) => message.phase === "final_answer").at(-1) : void 0);
|
|
2035
|
+
const responses = new Set(response ? [response] : []);
|
|
2036
|
+
const firstCandidate = responseCandidates[0];
|
|
2037
|
+
if (settledAt && firstCandidate && answersPerson.has(key) && responseCandidates.every((message) => message.phase === "commentary")) {
|
|
2038
|
+
responses.add(firstCandidate);
|
|
2039
|
+
}
|
|
2040
|
+
if (settledAt) {
|
|
2041
|
+
for (const message of responseCandidates) {
|
|
2042
|
+
if (responses.has(message) || message.text.includes("![")) continue;
|
|
2043
|
+
foldedProse.add(message);
|
|
2044
|
+
group.work.details.push({ kind: "item", item: message });
|
|
2045
|
+
}
|
|
2046
|
+
} else {
|
|
2047
|
+
for (const message of prose) {
|
|
2048
|
+
if (message.phase === "final_answer" || message.text.includes("![")) continue;
|
|
2049
|
+
group.work.details.push({ kind: "item", item: message });
|
|
2050
|
+
(group.work.liveNoteIds ??= []).push(message.id);
|
|
2051
|
+
}
|
|
2052
|
+
}
|
|
2053
|
+
group.work.details.sort((a, b) => {
|
|
2054
|
+
const first = (entry) => entry.kind === "item" ? entry.item.id : entry.kind === "activity" ? entry.items[0]?.id : void 0;
|
|
2055
|
+
return (itemOrder.get(first(a) ?? "") ?? 0) - (itemOrder.get(first(b) ?? "") ?? 0);
|
|
2056
|
+
});
|
|
2057
|
+
if (response) {
|
|
2058
|
+
const responseAt = response.startedAt ?? response.occurredAt;
|
|
2059
|
+
group.work.responseStartedAt = settledAt && Date.parse(responseAt) > Date.parse(settledAt) ? settledAt : responseAt;
|
|
2060
|
+
const anchor = Math.min(
|
|
2061
|
+
...[...responses].map((message) => positions.get(message) ?? groups.length)
|
|
2062
|
+
);
|
|
2063
|
+
if (settledAt && anchor < (nextBoundary.get(group) ?? groups.length)) {
|
|
2064
|
+
beforeRows.set(groups[anchor], group);
|
|
2065
|
+
movedRows.add(group);
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2068
|
+
if (!settledAt) {
|
|
2069
|
+
const lastProseIndex = Math.max(...prose.map((message) => positions.get(message) ?? -1));
|
|
2070
|
+
let tailIndex = groups.length - 1;
|
|
2071
|
+
for (let index = (positions.get(group) ?? 0) + 1; index <= tailIndex; index += 1) {
|
|
2072
|
+
const entry = groups[index];
|
|
2073
|
+
if (entry.kind === "activity" && entry.work || entry.kind === "item" && ("turnId" in entry.item && entry.item.turnId && entry.item.turnId !== key || index > lastProseIndex && (entry.item.kind === "user-message" || entry.item.kind === "machine-input-batch"))) {
|
|
2074
|
+
tailIndex = index - 1;
|
|
2075
|
+
break;
|
|
2076
|
+
}
|
|
2077
|
+
}
|
|
2078
|
+
const tail = groups[tailIndex];
|
|
2079
|
+
if (tail && tail !== group) {
|
|
2080
|
+
afterRows.set(tail, group);
|
|
2081
|
+
movedRows.add(group);
|
|
2082
|
+
}
|
|
2083
|
+
}
|
|
2084
|
+
}
|
|
2085
|
+
const personWork = new Set(
|
|
2086
|
+
[...answersPerson].flatMap((key) => {
|
|
2087
|
+
const work = turns.get(key);
|
|
2088
|
+
return work ? [work] : [];
|
|
2089
|
+
})
|
|
2090
|
+
);
|
|
2091
|
+
return compactQuietCycles(
|
|
2092
|
+
groups.flatMap((group) => {
|
|
2093
|
+
if (group.kind === "activity" && movedRows.has(group)) return [];
|
|
2094
|
+
const hidden = group.kind === "item" && group.item.kind === "agent-message" && foldedProse.has(group.item);
|
|
2095
|
+
const before = beforeRows.get(group);
|
|
2096
|
+
const after = afterRows.get(group);
|
|
2097
|
+
return [...before ? [before] : [], ...hidden ? [] : [group], ...after ? [after] : []];
|
|
2098
|
+
}),
|
|
2099
|
+
personWork
|
|
2100
|
+
);
|
|
2101
|
+
}
|
|
2102
|
+
function isQuietWork(group) {
|
|
2103
|
+
if (group.kind !== "activity" || !group.work?.endedAt || group.work.waiting) return false;
|
|
2104
|
+
if (group.work.cycles || group.outcome && group.outcome !== "complete") return false;
|
|
2105
|
+
if (group.items.some(
|
|
2106
|
+
(item) => item.kind === "startup-phase" && (item.status === "failed" || item.status === "cancelled")
|
|
2107
|
+
)) {
|
|
2108
|
+
return false;
|
|
2109
|
+
}
|
|
2110
|
+
const quiet = (entry) => entry.kind === "item" ? entry.item.kind !== "auth-needed" && entry.item.kind !== "context-compaction" && entry.item.kind !== "human-input" && !(entry.item.kind === "notice" && entry.item.tone !== "waiting") && !(entry.item.kind === "agent-message" && entry.item.text.includes("![")) : entry.kind === "activity" ? isQuietDetail(entry, quiet) : false;
|
|
2111
|
+
return !publishesOutput(group) && group.work.details.every(quiet);
|
|
2112
|
+
}
|
|
2113
|
+
function isQuietDetail(group, quiet) {
|
|
2114
|
+
return (!group.outcome || group.outcome === "complete") && (group.work?.details ?? []).every(quiet);
|
|
2115
|
+
}
|
|
2116
|
+
function publishesOutput(group) {
|
|
2117
|
+
if (group.kind !== "activity") return false;
|
|
2118
|
+
return group.items.some((item) => {
|
|
2119
|
+
if (item.kind !== "tool-call") return false;
|
|
2120
|
+
const name = mcpToolLeaf(item.name);
|
|
2121
|
+
return name === "generate_image" || name === "image_generation_call" || name === "sandbox_file_publish";
|
|
2122
|
+
}) || (group.work?.details ?? []).some(publishesOutput);
|
|
2123
|
+
}
|
|
2124
|
+
function answersPersonAt(groups, index) {
|
|
2125
|
+
for (let cursor = index - 1; cursor >= 0; cursor -= 1) {
|
|
2126
|
+
const group = groups[cursor];
|
|
2127
|
+
if (group.kind === "item" && (group.item.kind === "user-message" || group.item.kind === "human-input")) {
|
|
2128
|
+
return true;
|
|
2129
|
+
}
|
|
2130
|
+
if (!isRoutineInput(group)) return false;
|
|
2131
|
+
}
|
|
2132
|
+
return false;
|
|
2133
|
+
}
|
|
2134
|
+
function isRoutineInput(group) {
|
|
2135
|
+
return group.kind === "item" && group.item.kind === "machine-input-batch" && !!group.item.compact && group.item.members.every(
|
|
2136
|
+
(member) => member.kind !== "child_paused" && member.classification !== "failure" && // A parent's direction is always recorded as action_required for the
|
|
2137
|
+
// agent; it is routine orchestration, not something a person must do.
|
|
2138
|
+
(member.classification !== "action_required" || member.kind === "agent_steer_instruction")
|
|
2139
|
+
);
|
|
2140
|
+
}
|
|
2141
|
+
function isFinishedWait(group) {
|
|
2142
|
+
return group.kind === "item" && group.item.kind === "notice" && group.item.tone === "waiting" && !!group.item.recordedOutcome && !!group.item.waitEndedAt;
|
|
2143
|
+
}
|
|
2144
|
+
function compactQuietCycles(groups, personWork) {
|
|
2145
|
+
const result = [];
|
|
2146
|
+
let index = 0;
|
|
2147
|
+
while (index < groups.length) {
|
|
2148
|
+
let end = index;
|
|
2149
|
+
let lastCycleEnd = index;
|
|
2150
|
+
let cycles = 0;
|
|
2151
|
+
while (end < groups.length) {
|
|
2152
|
+
const input = isRoutineInput(groups[end]) ? end : -1;
|
|
2153
|
+
if (input < 0 && cycles === 0) break;
|
|
2154
|
+
const workIndex = input >= 0 ? end + 1 : end;
|
|
2155
|
+
const work = groups[workIndex];
|
|
2156
|
+
if (!work || !isQuietWork(work)) break;
|
|
2157
|
+
if (personWork.has(work) || answersPersonAt(groups, workIndex)) break;
|
|
2158
|
+
const next = groups[workIndex + 1];
|
|
2159
|
+
if (next?.kind === "item" && next.item.kind === "agent-message") break;
|
|
2160
|
+
if (!next || !isFinishedWait(next)) break;
|
|
2161
|
+
cycles += 1;
|
|
2162
|
+
end = workIndex + 2;
|
|
2163
|
+
lastCycleEnd = end;
|
|
2164
|
+
}
|
|
2165
|
+
if (cycles < 2) {
|
|
2166
|
+
result.push(groups[index]);
|
|
2167
|
+
index += 1;
|
|
2168
|
+
continue;
|
|
2169
|
+
}
|
|
2170
|
+
const run = groups.slice(index, lastCycleEnd);
|
|
2171
|
+
const works = run.filter((group) => isQuietWork(group));
|
|
2172
|
+
const waits = run.filter(isFinishedWait);
|
|
2173
|
+
const first = works[0];
|
|
2174
|
+
const lastWait = waits.at(-1);
|
|
2175
|
+
result.push({
|
|
2176
|
+
kind: "activity",
|
|
2177
|
+
id: `cycles-${first.id}`,
|
|
2178
|
+
items: works.flatMap((group) => group.items),
|
|
2179
|
+
outcome: "complete",
|
|
2180
|
+
work: {
|
|
2181
|
+
startedAt: first.work.startedAt,
|
|
2182
|
+
endedAt: lastWait.item.waitEndedAt,
|
|
2183
|
+
details: run,
|
|
2184
|
+
cycles: {
|
|
2185
|
+
count: cycles,
|
|
2186
|
+
...lastWait.item.text.trim() ? { summary: lastWait.item.text.trim() } : {}
|
|
2187
|
+
}
|
|
2188
|
+
}
|
|
2189
|
+
});
|
|
2190
|
+
index = lastCycleEnd;
|
|
2191
|
+
}
|
|
2192
|
+
return result;
|
|
2193
|
+
}
|
|
2194
|
+
var ROUTINE_MACHINE_INPUT_KINDS = /* @__PURE__ */ new Set([
|
|
2195
|
+
"goal_continuation",
|
|
2196
|
+
"background_command_result",
|
|
2197
|
+
"session_wait_timeout",
|
|
2198
|
+
"agent_message",
|
|
2199
|
+
"agent_steer_instruction",
|
|
2200
|
+
"child_terminal_result",
|
|
2201
|
+
"child_requires_action_resolved",
|
|
2202
|
+
"child_paused",
|
|
2203
|
+
"child_waiting_capacity",
|
|
2204
|
+
"child_progress"
|
|
2205
|
+
]);
|
|
2206
|
+
function timelineQuestionPlacement(question, evidence) {
|
|
2207
|
+
const anchors = prescanTurnAnchors([question, ...evidence]);
|
|
2208
|
+
const direct = anchors.directChatSequenceByTrigger.get(question.id);
|
|
2209
|
+
if (direct !== void 0) return { kind: "visible", sequence: direct };
|
|
2210
|
+
if (anchors.cancelledBeforeStartTriggers.has(question.id)) return { kind: "withdrawn" };
|
|
2211
|
+
const start = anchors.startSeqByTrigger.get(question.id);
|
|
2212
|
+
if (start !== void 0) return { kind: "visible", sequence: start };
|
|
2213
|
+
if (anchors.queuedTurnByTrigger.has(question.id) || anchors.explicitQueuedTriggers.has(question.id))
|
|
2214
|
+
return { kind: "pending" };
|
|
2215
|
+
return { kind: "visible", sequence: question.sequence };
|
|
2216
|
+
}
|
|
1434
2217
|
function prescanTurnAnchors(events) {
|
|
1435
2218
|
const ordered = [...events].sort((a, b) => a.sequence - b.sequence);
|
|
1436
2219
|
const queuedTurnByTrigger = /* @__PURE__ */ new Map();
|
|
@@ -1583,10 +2366,12 @@ function pushInsertion(insertions, sequence, event) {
|
|
|
1583
2366
|
}
|
|
1584
2367
|
}
|
|
1585
2368
|
function isAgentActivityEvent(type) {
|
|
1586
|
-
return type.startsWith("agent.") || type.startsWith("sandbox.");
|
|
2369
|
+
return type.startsWith("agent.") || type.startsWith("sandbox.") || type === "subscription.account.selected" || type === "subscription.account.switched";
|
|
1587
2370
|
}
|
|
1588
2371
|
function isTurnExecutionEvidence(type) {
|
|
1589
|
-
return isAgentActivityEvent(type) || type === "turn.completed" || type === "turn.failed" ||
|
|
2372
|
+
return isAgentActivityEvent(type) || type === "turn.completed" || type === "turn.failed" || // An admission refusal can settle a queued turn before it ever starts:
|
|
2373
|
+
// its prompt still belongs above the "usage limit reached" row.
|
|
2374
|
+
type === "usage.exhausted" || type === "turn.superseded" || type === "turn.recovery.requested" || type === "turn.capacity_waiting" || type === "session.requiresAction" || type === "tool.auth_needed" || type === "credential.auth_needed" || type.startsWith("turn.startup.phase.") || type.startsWith("rig.setup.") || type === "codex.capacity.waiting" || type === "codex.capacity.resumed" || type === "codex.fleet.decision";
|
|
1590
2375
|
}
|
|
1591
2376
|
function turnEndItem(event, outcome, failureText) {
|
|
1592
2377
|
return {
|
|
@@ -1598,6 +2383,23 @@ function turnEndItem(event, outcome, failureText) {
|
|
|
1598
2383
|
occurredAt: event.occurredAt
|
|
1599
2384
|
};
|
|
1600
2385
|
}
|
|
2386
|
+
var SESSION_USAGE_LIMIT_STOP_TEXT = (t) => t("timeline.projection.thisTaskSUsageLimit");
|
|
2387
|
+
function sessionUsageLimitNotice(t, event, payload) {
|
|
2388
|
+
const refusal = parseSessionUsageLimitReachedRefusal(payload);
|
|
2389
|
+
return {
|
|
2390
|
+
kind: "notice",
|
|
2391
|
+
id: `${event.id}-session-usage-limit`,
|
|
2392
|
+
// Neutral: not a failure, and not an open wait the turn header should claim.
|
|
2393
|
+
tone: "cancelled",
|
|
2394
|
+
text: refusal ? sessionUsageLimitReachedMessage(refusal) : SESSION_USAGE_LIMIT_STOP_TEXT(t),
|
|
2395
|
+
sessionUsageLimit: {
|
|
2396
|
+
rootSessionId: refusal?.rootSessionId ?? null,
|
|
2397
|
+
limitMicros: refusal?.limitMicros ?? null,
|
|
2398
|
+
usedMicros: refusal?.usedMicros ?? null
|
|
2399
|
+
},
|
|
2400
|
+
occurredAt: event.occurredAt
|
|
2401
|
+
};
|
|
2402
|
+
}
|
|
1601
2403
|
function hasTurnActivity(items, turnId) {
|
|
1602
2404
|
if (turnId) {
|
|
1603
2405
|
return items.some((item) => isActivityItem(item) && item.turnId === turnId);
|
|
@@ -1667,6 +2469,7 @@ function foldSettledTurn(groups, turnEnd) {
|
|
|
1667
2469
|
if (collected.length === 0) {
|
|
1668
2470
|
return;
|
|
1669
2471
|
}
|
|
2472
|
+
const collectedLength = collected.length;
|
|
1670
2473
|
const waitMessages = turnEnd.preserveWaitResponse ? collected.filter(
|
|
1671
2474
|
(group) => group.kind === "item" && group.item.kind === "agent-message" && !group.item.streaming && group.item.text.trim().length > 0 && belongsToTurn(group.item, turnEnd.turnId)
|
|
1672
2475
|
) : [];
|
|
@@ -1676,7 +2479,19 @@ function foldSettledTurn(groups, turnEnd) {
|
|
|
1676
2479
|
const finalMessage = waitResponse ?? extractFinalAgentMessage(collected, turnEnd);
|
|
1677
2480
|
const fallbackMessage = finalMessage || hasOrdinaryFinalAgentMessage(collected, turnEnd) ? null : extractLatestCompletedCommentary(collected, turnEnd);
|
|
1678
2481
|
const visibleMessage = finalMessage ?? fallbackMessage;
|
|
1679
|
-
const
|
|
2482
|
+
const visibleMessages = visibleMessage ? [visibleMessage] : [];
|
|
2483
|
+
if (visibleMessage && !hasOrdinaryFinalAgentMessage(collected, turnEnd) && turnAnswersPerson(groups, startIndex)) {
|
|
2484
|
+
const first = collected.find(
|
|
2485
|
+
(group) => group.kind === "item" && group.item.kind === "agent-message" && !group.item.streaming && group.item.text.trim().length > 0 && belongsToTurn(group.item, turnEnd.turnId)
|
|
2486
|
+
);
|
|
2487
|
+
if (first && first !== visibleMessage) visibleMessages.unshift(first);
|
|
2488
|
+
}
|
|
2489
|
+
const keptNotices = collected.filter(
|
|
2490
|
+
(group) => group.kind === "item" && group.item.kind === "notice" && !!group.item.learningRefusal
|
|
2491
|
+
);
|
|
2492
|
+
const body = collected.filter(
|
|
2493
|
+
(group) => !visibleMessages.includes(group) && !keptNotices.includes(group)
|
|
2494
|
+
);
|
|
1680
2495
|
if (body.length === 0) {
|
|
1681
2496
|
return;
|
|
1682
2497
|
}
|
|
@@ -1695,11 +2510,18 @@ function foldSettledTurn(groups, turnEnd) {
|
|
|
1695
2510
|
if (turnEnd.failureText) {
|
|
1696
2511
|
turnGroup.failureText = turnEnd.failureText;
|
|
1697
2512
|
}
|
|
1698
|
-
groups.splice(
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
2513
|
+
groups.splice(startIndex, collectedLength, turnGroup, ...keptNotices, ...visibleMessages);
|
|
2514
|
+
}
|
|
2515
|
+
function turnAnswersPerson(groups, startIndex) {
|
|
2516
|
+
for (let index = startIndex - 1; index >= 0; index -= 1) {
|
|
2517
|
+
const group = groups[index];
|
|
2518
|
+
if (group?.kind !== "item") return false;
|
|
2519
|
+
if (group.item.kind === "user-message") return true;
|
|
2520
|
+
if (group.item.kind !== "machine-input-batch" && group.item.kind !== "session-status" && group.item.kind !== "context-compaction" && !(group.item.kind === "notice" && group.item.tone === "input")) {
|
|
2521
|
+
return false;
|
|
2522
|
+
}
|
|
2523
|
+
}
|
|
2524
|
+
return false;
|
|
1703
2525
|
}
|
|
1704
2526
|
function isTurnBoundary(group) {
|
|
1705
2527
|
return group?.kind === "turn" || group?.kind === "item" && (group.item.kind === "user-message" || group.item.kind === "human-input" || group.item.kind === "context-compaction" || group.item.kind === "machine-input-batch" || group.item.kind === "notice" && group.item.tone === "input");
|
|
@@ -1772,9 +2594,23 @@ function assistantMessagePhase(value) {
|
|
|
1772
2594
|
function numberOrNull(value) {
|
|
1773
2595
|
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
1774
2596
|
}
|
|
1775
|
-
function
|
|
1776
|
-
const
|
|
1777
|
-
|
|
2597
|
+
function compactionProviderRejection(payload) {
|
|
2598
|
+
const record = asRecord2(payload.providerRejection);
|
|
2599
|
+
if (typeof record.httpStatus !== "number" || !Number.isFinite(record.httpStatus)) {
|
|
2600
|
+
return null;
|
|
2601
|
+
}
|
|
2602
|
+
const text = (value) => typeof value === "string" && value.trim() ? value : null;
|
|
2603
|
+
return {
|
|
2604
|
+
httpStatus: record.httpStatus,
|
|
2605
|
+
type: text(record.type),
|
|
2606
|
+
code: text(record.code),
|
|
2607
|
+
param: text(record.param),
|
|
2608
|
+
requestId: text(record.requestId)
|
|
2609
|
+
};
|
|
2610
|
+
}
|
|
2611
|
+
function compactionTrigger(payload) {
|
|
2612
|
+
const trigger = payload.trigger;
|
|
2613
|
+
return trigger === "auto" || trigger === "operator" || trigger === "proactive" || trigger === "overflow" ? trigger : null;
|
|
1778
2614
|
}
|
|
1779
2615
|
function settleOrPushContextCompaction(items, next) {
|
|
1780
2616
|
const openIndex = findOpenContextCompactionIndex(items, next.turnId);
|
|
@@ -1877,6 +2713,13 @@ function resourceRefs(value) {
|
|
|
1877
2713
|
return record.kind === "file" && typeof record.fileId === "string";
|
|
1878
2714
|
});
|
|
1879
2715
|
}
|
|
2716
|
+
function messageSender(value) {
|
|
2717
|
+
const record = asRecord2(value);
|
|
2718
|
+
if (record.kind !== "subject" || typeof record.subjectId !== "string" || !record.subjectId)
|
|
2719
|
+
return void 0;
|
|
2720
|
+
const label = typeof record.label === "string" && record.label.trim() ? record.label : null;
|
|
2721
|
+
return { subjectId: record.subjectId, label };
|
|
2722
|
+
}
|
|
1880
2723
|
function timelineAnnotations(value) {
|
|
1881
2724
|
if (!Array.isArray(value)) return [];
|
|
1882
2725
|
return value.filter((candidate) => {
|
|
@@ -1967,6 +2810,16 @@ function startupPhaseForSandboxOperation(name) {
|
|
|
1967
2810
|
function startupPhaseFromPayload(value) {
|
|
1968
2811
|
return typeof value === "string" && STARTUP_PHASES.has(value) ? value : null;
|
|
1969
2812
|
}
|
|
2813
|
+
function startupLifecycleWaitReason(payload) {
|
|
2814
|
+
if (payload.expectedTransition === true && payload.failureStage === "context_compaction" && payload.failureCategory === "context_compaction" && payload.failureCode === "compaction_required") {
|
|
2815
|
+
return "compaction_required";
|
|
2816
|
+
}
|
|
2817
|
+
if (payload.expectedTransition !== true || payload.failureStage !== "lifecycle_wait" || payload.failureCategory !== "drain_capture_wait") {
|
|
2818
|
+
return void 0;
|
|
2819
|
+
}
|
|
2820
|
+
const code = payload.failureCode;
|
|
2821
|
+
return code === "capture_in_progress" || code === "rotation_in_progress" || code === "provider_recovery_in_progress" ? code : void 0;
|
|
2822
|
+
}
|
|
1970
2823
|
var SANDBOX_STARTUP_PHASES = {
|
|
1971
2824
|
"sandbox.provision": "sandbox",
|
|
1972
2825
|
"repository-clone": "repository",
|
|
@@ -1987,8 +2840,8 @@ function elapsedDurationMs(startedAt, completedAt) {
|
|
|
1987
2840
|
const end = Date.parse(completedAt);
|
|
1988
2841
|
return Number.isFinite(start) && Number.isFinite(end) ? Math.max(0, end - start) : null;
|
|
1989
2842
|
}
|
|
1990
|
-
function failureMessage(payload) {
|
|
1991
|
-
return presentFailure(payload).reason;
|
|
2843
|
+
function failureMessage(t, payload) {
|
|
2844
|
+
return presentFailure(t, payload).reason;
|
|
1992
2845
|
}
|
|
1993
2846
|
function goalText(payload) {
|
|
1994
2847
|
if (typeof payload.text === "string" && payload.text) {
|
|
@@ -2009,8 +2862,53 @@ function rememberPendingWaitOutcome(pending, event, payload, eventTurnId) {
|
|
|
2009
2862
|
const turnId = eventTurnId || stringValue(payload.waitTurnId) || stringValue(payload.turnId) || null;
|
|
2010
2863
|
pending.set(turnId, { id: event.id, reason, occurredAt: event.occurredAt });
|
|
2011
2864
|
}
|
|
2012
|
-
|
|
2013
|
-
|
|
2865
|
+
var ACTION_CAPACITY_WAIT_REASONS = /* @__PURE__ */ new Set([
|
|
2866
|
+
"pinned_account_disabled",
|
|
2867
|
+
"pinned_account_ineligible",
|
|
2868
|
+
"model_not_allowed",
|
|
2869
|
+
// Only sending the work again ends it (design 5.3 decision 4).
|
|
2870
|
+
"accepted_authority_unavailable"
|
|
2871
|
+
]);
|
|
2872
|
+
var ACTION_CAPACITY_WAIT_CODE = /_(?:allocator_disabled|relogin_required|account_forbidden)$/;
|
|
2873
|
+
function capacityWaitPresentation(t, type, payload, turnId) {
|
|
2874
|
+
if (ACTION_CAPACITY_WAIT_REASONS.has(stringValue(payload.waitReason)) || ACTION_CAPACITY_WAIT_CODE.test(stringValue(payload.code))) {
|
|
2875
|
+
const [first, second] = type === "turn.capacity_waiting" ? [payload.error, payload.detail] : [payload.detail, payload.error];
|
|
2876
|
+
const detail = stringValue(first) || stringValue(second) || t("timeline.projection.waitingForAnAccount");
|
|
2877
|
+
return {
|
|
2878
|
+
turnId,
|
|
2879
|
+
label: stringValue(payload.waitReason) === "pinned_account_disabled" ? t("timeline.projection.needsYou") : t("timeline.projection.waiting"),
|
|
2880
|
+
detail,
|
|
2881
|
+
text: detail
|
|
2882
|
+
};
|
|
2883
|
+
}
|
|
2884
|
+
return {
|
|
2885
|
+
turnId,
|
|
2886
|
+
label: CAPACITY_LIMIT_LABEL(t),
|
|
2887
|
+
detail: CAPACITY_LIMIT_DETAIL(t),
|
|
2888
|
+
text: `${CAPACITY_LIMIT_LABEL(t)}. ${CAPACITY_LIMIT_DETAIL(t)}`
|
|
2889
|
+
};
|
|
2890
|
+
}
|
|
2891
|
+
var CAPACITY_LIMIT_LABEL = (t) => t("timeline.projection.usageLimitReached");
|
|
2892
|
+
var CAPACITY_LIMIT_DETAIL = (t) => t("timeline.projection.tryAgainAfterYourQuota");
|
|
2893
|
+
function endsCapacityWait(event, payload) {
|
|
2894
|
+
if (event.duplicateOfEventId || event.turnAssociation && event.turnAssociation !== "current")
|
|
2895
|
+
return false;
|
|
2896
|
+
switch (event.type) {
|
|
2897
|
+
case "codex.capacity.resumed":
|
|
2898
|
+
case "codex.capacity.superseded":
|
|
2899
|
+
case "turn.completed":
|
|
2900
|
+
case "turn.failed":
|
|
2901
|
+
case "turn.cancelled":
|
|
2902
|
+
case "turn.superseded":
|
|
2903
|
+
return true;
|
|
2904
|
+
case "session.status.changed":
|
|
2905
|
+
return isSessionStatus(payload.status) && payload.status !== "waiting_capacity";
|
|
2906
|
+
default:
|
|
2907
|
+
return false;
|
|
2908
|
+
}
|
|
2909
|
+
}
|
|
2910
|
+
function waitingOutcomeText(t, reason) {
|
|
2911
|
+
return /^waiting\b/i.test(reason) ? reason : t("timeline.projection.waitingReason", { reason });
|
|
2014
2912
|
}
|
|
2015
2913
|
function shouldSuppressAgentGoalLandmark(type, payload) {
|
|
2016
2914
|
if (type === "goal.completed") {
|
|
@@ -2051,7 +2949,8 @@ var AUTH_NEEDED_REASONS = /* @__PURE__ */ new Set([
|
|
|
2051
2949
|
"refresh_failed",
|
|
2052
2950
|
"personal_authority_unavailable",
|
|
2053
2951
|
"unsupported_auth",
|
|
2054
|
-
"resource_scope_unavailable"
|
|
2952
|
+
"resource_scope_unavailable",
|
|
2953
|
+
"designated_credential_unavailable"
|
|
2055
2954
|
]);
|
|
2056
2955
|
function authNeededReason(value) {
|
|
2057
2956
|
return typeof value === "string" && AUTH_NEEDED_REASONS.has(value) ? value : null;
|
|
@@ -2062,7 +2961,7 @@ function capabilityAuthorizationRequest(value) {
|
|
|
2062
2961
|
const kind = record.kind;
|
|
2063
2962
|
const source = record.source;
|
|
2064
2963
|
const action = record.action;
|
|
2065
|
-
if (typeof record.id !== "string" || typeof record.name !== "string" || !["
|
|
2964
|
+
if (typeof record.id !== "string" || typeof record.name !== "string" || !["mcp", "api", "skill", "plugin"].includes(String(kind)) || !["built_in", "library", "configured", "public_registry", "registry", "manual"].includes(
|
|
2066
2965
|
String(source)
|
|
2067
2966
|
) || !["connect", "add_credentials", "enable"].includes(String(action)) || typeof record.rationale !== "string") {
|
|
2068
2967
|
return null;
|
|
@@ -2077,9 +2976,15 @@ function capabilityAuthorizationRequest(value) {
|
|
|
2077
2976
|
requiredVariables: stringList(record.requiredVariables)
|
|
2078
2977
|
};
|
|
2079
2978
|
}
|
|
2979
|
+
function customMcpSetupRequest(value) {
|
|
2980
|
+
return parseCustomMcpSetupRequest(value);
|
|
2981
|
+
}
|
|
2080
2982
|
function stringList(value) {
|
|
2081
2983
|
return Array.isArray(value) ? value.filter((entry) => typeof entry === "string" && entry.trim().length > 0) : [];
|
|
2082
2984
|
}
|
|
2985
|
+
function reasoningDeltaJoiner(previous, next) {
|
|
2986
|
+
return previous.endsWith("**") && next.startsWith("**") ? "\n\n" : "";
|
|
2987
|
+
}
|
|
2083
2988
|
function reasoningText(payload) {
|
|
2084
2989
|
const record = asRecord2(payload);
|
|
2085
2990
|
if (typeof record.text === "string") {
|
|
@@ -2104,6 +3009,14 @@ function workerPrompt(args) {
|
|
|
2104
3009
|
}
|
|
2105
3010
|
return null;
|
|
2106
3011
|
}
|
|
3012
|
+
var WORKER_TITLE_MAX_LENGTH = 120;
|
|
3013
|
+
function workerTitle(args) {
|
|
3014
|
+
const record = asRecord2(typeof args === "string" ? tryParseJson(args) : args);
|
|
3015
|
+
if (typeof record.title !== "string") return null;
|
|
3016
|
+
const title = record.title.replace(/\s+/g, " ").trim();
|
|
3017
|
+
if (!title) return null;
|
|
3018
|
+
return title.length > WORKER_TITLE_MAX_LENGTH ? `${title.slice(0, WORKER_TITLE_MAX_LENGTH - 1).trimEnd()}\u2026` : title;
|
|
3019
|
+
}
|
|
2107
3020
|
function boundedWorkerFailureMessage(value) {
|
|
2108
3021
|
const normalized = value.replace(/[\u0000-\u001f\u007f]+/g, " ").trim();
|
|
2109
3022
|
if (!normalized) return null;
|
|
@@ -2194,1531 +3107,22 @@ function looksLikeId(value) {
|
|
|
2194
3107
|
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value);
|
|
2195
3108
|
}
|
|
2196
3109
|
|
|
2197
|
-
// src/hooks/use-session-events.ts
|
|
2198
|
-
import {
|
|
2199
|
-
sessionEventStreamCoveredThrough
|
|
2200
|
-
} from "@opengeni/sdk";
|
|
2201
|
-
import { startTransition, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
2202
|
-
var SESSION_HISTORY_PAGE_SIZE = 1e3;
|
|
2203
|
-
var INITIAL_FETCH_CAP = 1;
|
|
2204
|
-
var OLDER_GROUP_TARGET = 32;
|
|
2205
|
-
var OLDER_FETCH_CAP = 2;
|
|
2206
|
-
var NEWER_GROUP_TARGET = 32;
|
|
2207
|
-
var NEWER_FETCH_CAP = 2;
|
|
2208
|
-
var OLDEST_GROUP_TARGET = 32;
|
|
2209
|
-
var OLDEST_FETCH_CAP = 2;
|
|
2210
|
-
var BOUNDARY_PAGE_CAP = 1;
|
|
2211
|
-
var FOREGROUND_DIRECT_REPLAY_MAX_SEQUENCES = 16;
|
|
2212
|
-
var FOREGROUND_COMPACT_PROBE_MAX_SEQUENCES = SESSION_HISTORY_PAGE_SIZE;
|
|
2213
|
-
var FOREGROUND_COMPACT_CATCHUP_MAX_EVENTS = 128;
|
|
2214
|
-
var FOREGROUND_COMPACT_CATCHUP_MAX_GROUPS = 16;
|
|
2215
|
-
var FOREGROUND_COMPACT_CATCHUP_MAX_BYTES = 512 * 1024;
|
|
2216
|
-
var EMPTY_EVENTS = [];
|
|
2217
|
-
var encoder = new TextEncoder();
|
|
2218
|
-
var SESSION_EVENT_BROWSER_MAX_BYTES = 8 * 1024 * 1024;
|
|
2219
|
-
var SESSION_EVENT_BROWSER_MAX_COUNT = 1e4;
|
|
2220
|
-
var SESSION_EVENT_BROWSER_PENDING_MAX_BYTES = 1024 * 1024;
|
|
2221
|
-
var SESSION_EVENT_BROWSER_PENDING_MAX_COUNT = 256;
|
|
2222
|
-
var EMPTY_EVENT_WINDOW = {
|
|
2223
|
-
events: EMPTY_EVENTS,
|
|
2224
|
-
bytes: 2,
|
|
2225
|
-
truncated: false
|
|
2226
|
-
};
|
|
2227
|
-
function useSessionEvents(sessionId, options = {}) {
|
|
2228
|
-
const { client, workspaceId, reconcileSession } = useEmbeddedSession(options);
|
|
2229
|
-
const enabled = options.enabled ?? true;
|
|
2230
|
-
const pageLive = usePageLiveActivity();
|
|
2231
|
-
const streamEnabled = enabled && pageLive;
|
|
2232
|
-
const after = options.after ?? 0;
|
|
2233
|
-
const replay = options.replay ?? "windowed";
|
|
2234
|
-
const fullReplay = replay === "full" || after !== 0;
|
|
2235
|
-
const streamKey = `${workspaceId}\0${sessionId ?? ""}\0${after}\0${fullReplay ? "full" : "windowed"}`;
|
|
2236
|
-
const [eventWindow, setEventWindow] = useState(EMPTY_EVENT_WINDOW);
|
|
2237
|
-
const [connectionState, setConnectionState] = useState("idle");
|
|
2238
|
-
const [error, setError] = useState(null);
|
|
2239
|
-
const [hasOlder, setHasOlder] = useState(false);
|
|
2240
|
-
const [hasNewer, setHasNewer] = useState(false);
|
|
2241
|
-
const [sessionStatusProjection, setSessionStatusProjection] = useState(
|
|
2242
|
-
null
|
|
2243
|
-
);
|
|
2244
|
-
const [initialLoading, setInitialLoading] = useState(true);
|
|
2245
|
-
const [loadingOlder, setLoadingOlder] = useState(false);
|
|
2246
|
-
const [loadingNewer, setLoadingNewer] = useState(false);
|
|
2247
|
-
const [loadingOldest, setLoadingOldest] = useState(false);
|
|
2248
|
-
const [loadingLatest, setLoadingLatest] = useState(false);
|
|
2249
|
-
const [streamEpoch, setStreamEpoch] = useState(0);
|
|
2250
|
-
const [viewMode, setViewMode] = useState("live");
|
|
2251
|
-
const lastSequenceRef = useRef(after);
|
|
2252
|
-
const streamResumeSequenceRef = useRef(after);
|
|
2253
|
-
const oldestSequenceRef = useRef(null);
|
|
2254
|
-
const newestSequenceRef = useRef(null);
|
|
2255
|
-
const hasOlderRef = useRef(false);
|
|
2256
|
-
const hasNewerRef = useRef(false);
|
|
2257
|
-
const loadingOlderRef = useRef(false);
|
|
2258
|
-
const loadingNewerRef = useRef(false);
|
|
2259
|
-
const loadingOldestRef = useRef(false);
|
|
2260
|
-
const loadingLatestRef = useRef(false);
|
|
2261
|
-
const viewModeRef = useRef("live");
|
|
2262
|
-
const initialWindowLoadedRef = useRef(false);
|
|
2263
|
-
const reconcileAfterPageResumeRef = useRef(false);
|
|
2264
|
-
const streamAbortRef = useRef(null);
|
|
2265
|
-
const streamKeyRef = useRef(null);
|
|
2266
|
-
const generationRef = useRef(0);
|
|
2267
|
-
const navigationGenerationRef = useRef(0);
|
|
2268
|
-
const eventWindowRef = useRef(EMPTY_EVENT_WINDOW);
|
|
2269
|
-
const sessionStatusRef = useRef({
|
|
2270
|
-
sequence: after,
|
|
2271
|
-
status: null
|
|
2272
|
-
});
|
|
2273
|
-
const [stateStreamKey, setStateStreamKey] = useState(streamKey);
|
|
2274
|
-
useEffect(() => {
|
|
2275
|
-
navigationGenerationRef.current += 1;
|
|
2276
|
-
loadingOlderRef.current = false;
|
|
2277
|
-
loadingNewerRef.current = false;
|
|
2278
|
-
loadingOldestRef.current = false;
|
|
2279
|
-
setLoadingOlder(false);
|
|
2280
|
-
setLoadingNewer(false);
|
|
2281
|
-
setLoadingOldest(false);
|
|
2282
|
-
return () => {
|
|
2283
|
-
navigationGenerationRef.current += 1;
|
|
2284
|
-
};
|
|
2285
|
-
}, [client, workspaceId, sessionId, after, enabled, fullReplay]);
|
|
2286
|
-
useEffect(() => {
|
|
2287
|
-
if (streamKeyRef.current !== streamKey) {
|
|
2288
|
-
streamKeyRef.current = streamKey;
|
|
2289
|
-
setStateStreamKey(streamKey);
|
|
2290
|
-
eventWindowRef.current = EMPTY_EVENT_WINDOW;
|
|
2291
|
-
setEventWindow(EMPTY_EVENT_WINDOW);
|
|
2292
|
-
setError(null);
|
|
2293
|
-
setHasOlder(false);
|
|
2294
|
-
setHasNewer(false);
|
|
2295
|
-
sessionStatusRef.current = { sequence: after, status: null };
|
|
2296
|
-
setSessionStatusProjection(null);
|
|
2297
|
-
setLoadingOlder(false);
|
|
2298
|
-
setLoadingNewer(false);
|
|
2299
|
-
setLoadingOldest(false);
|
|
2300
|
-
setLoadingLatest(false);
|
|
2301
|
-
setInitialLoading(true);
|
|
2302
|
-
lastSequenceRef.current = after;
|
|
2303
|
-
streamResumeSequenceRef.current = after;
|
|
2304
|
-
oldestSequenceRef.current = null;
|
|
2305
|
-
newestSequenceRef.current = null;
|
|
2306
|
-
hasOlderRef.current = false;
|
|
2307
|
-
hasNewerRef.current = false;
|
|
2308
|
-
loadingOlderRef.current = false;
|
|
2309
|
-
loadingNewerRef.current = false;
|
|
2310
|
-
loadingOldestRef.current = false;
|
|
2311
|
-
loadingLatestRef.current = false;
|
|
2312
|
-
viewModeRef.current = "live";
|
|
2313
|
-
setViewMode("live");
|
|
2314
|
-
initialWindowLoadedRef.current = false;
|
|
2315
|
-
reconcileAfterPageResumeRef.current = false;
|
|
2316
|
-
}
|
|
2317
|
-
const generation = generationRef.current + 1;
|
|
2318
|
-
generationRef.current = generation;
|
|
2319
|
-
if (!sessionId || !streamEnabled) {
|
|
2320
|
-
if (sessionId && enabled && !pageLive && !fullReplay && viewModeRef.current === "live" && initialWindowLoadedRef.current) {
|
|
2321
|
-
reconcileAfterPageResumeRef.current = true;
|
|
2322
|
-
}
|
|
2323
|
-
setConnectionState("idle");
|
|
2324
|
-
return;
|
|
2325
|
-
}
|
|
2326
|
-
if (viewMode === "history") {
|
|
2327
|
-
reconcileAfterPageResumeRef.current = false;
|
|
2328
|
-
setConnectionState("idle");
|
|
2329
|
-
setInitialLoading(false);
|
|
2330
|
-
return;
|
|
2331
|
-
}
|
|
2332
|
-
const reconcileForegroundResume = reconcileAfterPageResumeRef.current && !fullReplay;
|
|
2333
|
-
reconcileAfterPageResumeRef.current = false;
|
|
2334
|
-
const controller = new AbortController();
|
|
2335
|
-
const isCurrent = () => generationRef.current === generation && !controller.signal.aborted;
|
|
2336
|
-
streamAbortRef.current = controller;
|
|
2337
|
-
let pending = [];
|
|
2338
|
-
let pendingBytes = 2;
|
|
2339
|
-
let flushTimer = null;
|
|
2340
|
-
const flush = () => {
|
|
2341
|
-
if (flushTimer !== null) {
|
|
2342
|
-
clearTimeout(flushTimer);
|
|
2343
|
-
flushTimer = null;
|
|
2344
|
-
}
|
|
2345
|
-
if (!isCurrent()) {
|
|
2346
|
-
pending = [];
|
|
2347
|
-
pendingBytes = 2;
|
|
2348
|
-
return;
|
|
2349
|
-
}
|
|
2350
|
-
if (pending.length === 0) {
|
|
2351
|
-
return;
|
|
2352
|
-
}
|
|
2353
|
-
const batch = pending;
|
|
2354
|
-
pending = [];
|
|
2355
|
-
pendingBytes = 2;
|
|
2356
|
-
const lastInBatch = batch[batch.length - 1];
|
|
2357
|
-
if (lastInBatch) {
|
|
2358
|
-
const batchResumeSequence = Math.max(...batch.map(eventResumeSequence));
|
|
2359
|
-
lastSequenceRef.current = Math.max(lastSequenceRef.current, batchResumeSequence);
|
|
2360
|
-
streamResumeSequenceRef.current = Math.max(
|
|
2361
|
-
streamResumeSequenceRef.current,
|
|
2362
|
-
batchResumeSequence
|
|
2363
|
-
);
|
|
2364
|
-
}
|
|
2365
|
-
const status = observeSessionStatus(batch, sessionStatusRef);
|
|
2366
|
-
if (status !== void 0) {
|
|
2367
|
-
setSessionStatusProjection(status);
|
|
2368
|
-
}
|
|
2369
|
-
const current = eventWindowRef.current;
|
|
2370
|
-
const next = boundBrowserSessionEventWindow([...current.events, ...batch]);
|
|
2371
|
-
const retained = {
|
|
2372
|
-
...next,
|
|
2373
|
-
truncated: current.truncated || next.truncated
|
|
2374
|
-
};
|
|
2375
|
-
eventWindowRef.current = retained;
|
|
2376
|
-
setEventWindow(retained);
|
|
2377
|
-
oldestSequenceRef.current = retained.events[0]?.sequence ?? null;
|
|
2378
|
-
newestSequenceRef.current = maxResumeSequenceOrNull(retained.events);
|
|
2379
|
-
if (retained.truncated) {
|
|
2380
|
-
hasOlderRef.current = true;
|
|
2381
|
-
setHasOlder(true);
|
|
2382
|
-
}
|
|
2383
|
-
};
|
|
2384
|
-
const scheduleFlush = () => {
|
|
2385
|
-
if (!isCurrent()) return;
|
|
2386
|
-
flushTimer ??= setTimeout(flush, 16);
|
|
2387
|
-
};
|
|
2388
|
-
void (async () => {
|
|
2389
|
-
try {
|
|
2390
|
-
if (reconcileForegroundResume) {
|
|
2391
|
-
setConnectionState("connecting");
|
|
2392
|
-
const cursor = streamResumeSequenceRef.current;
|
|
2393
|
-
let plan = { kind: "resume" };
|
|
2394
|
-
try {
|
|
2395
|
-
plan = await planForegroundCatchup(client, workspaceId, sessionId, cursor, {
|
|
2396
|
-
signal: controller.signal
|
|
2397
|
-
});
|
|
2398
|
-
} catch {
|
|
2399
|
-
if (controller.signal.aborted) return;
|
|
2400
|
-
plan = { kind: "resume" };
|
|
2401
|
-
}
|
|
2402
|
-
if (!isCurrent()) return;
|
|
2403
|
-
if (plan.kind === "append") {
|
|
2404
|
-
const current = eventWindowRef.current;
|
|
2405
|
-
assertAppendOrder(current.events, plan.events);
|
|
2406
|
-
const status = observeSessionStatus(plan.events, sessionStatusRef);
|
|
2407
|
-
const next = boundBrowserSessionEventWindow([...current.events, ...plan.events]);
|
|
2408
|
-
const retained = {
|
|
2409
|
-
...next,
|
|
2410
|
-
truncated: current.truncated || next.truncated
|
|
2411
|
-
};
|
|
2412
|
-
eventWindowRef.current = retained;
|
|
2413
|
-
oldestSequenceRef.current = retained.events[0]?.sequence ?? null;
|
|
2414
|
-
newestSequenceRef.current = maxResumeSequenceOrNull(retained.events);
|
|
2415
|
-
lastSequenceRef.current = Math.max(lastSequenceRef.current, plan.resumeSequence);
|
|
2416
|
-
streamResumeSequenceRef.current = Math.max(
|
|
2417
|
-
streamResumeSequenceRef.current,
|
|
2418
|
-
plan.resumeSequence
|
|
2419
|
-
);
|
|
2420
|
-
if (status !== void 0) {
|
|
2421
|
-
setSessionStatusProjection(status);
|
|
2422
|
-
}
|
|
2423
|
-
setEventWindow(retained);
|
|
2424
|
-
if (retained.truncated) {
|
|
2425
|
-
hasOlderRef.current = true;
|
|
2426
|
-
setHasOlder(true);
|
|
2427
|
-
}
|
|
2428
|
-
} else if (plan.kind === "reload") {
|
|
2429
|
-
initialWindowLoadedRef.current = false;
|
|
2430
|
-
setError(null);
|
|
2431
|
-
}
|
|
2432
|
-
}
|
|
2433
|
-
if (!fullReplay && !initialWindowLoadedRef.current) {
|
|
2434
|
-
setConnectionState("connecting");
|
|
2435
|
-
const window = await loadEventWindow(client, workspaceId, sessionId, {
|
|
2436
|
-
before: Number.MAX_SAFE_INTEGER,
|
|
2437
|
-
pageSize: SESSION_HISTORY_PAGE_SIZE,
|
|
2438
|
-
targetGroups: Number.POSITIVE_INFINITY,
|
|
2439
|
-
maxFetches: INITIAL_FETCH_CAP,
|
|
2440
|
-
boundaryPageCap: BOUNDARY_PAGE_CAP,
|
|
2441
|
-
signal: controller.signal
|
|
2442
|
-
});
|
|
2443
|
-
if (!isCurrent()) {
|
|
2444
|
-
return;
|
|
2445
|
-
}
|
|
2446
|
-
const status = observeSessionStatus(window.events, sessionStatusRef);
|
|
2447
|
-
const retained = boundBrowserSessionEventWindow(window.events);
|
|
2448
|
-
navigationGenerationRef.current += 1;
|
|
2449
|
-
loadingOlderRef.current = false;
|
|
2450
|
-
loadingNewerRef.current = false;
|
|
2451
|
-
loadingOldestRef.current = false;
|
|
2452
|
-
setLoadingOlder(false);
|
|
2453
|
-
setLoadingNewer(false);
|
|
2454
|
-
setLoadingOldest(false);
|
|
2455
|
-
eventWindowRef.current = retained;
|
|
2456
|
-
oldestSequenceRef.current = retained.events[0]?.sequence ?? window.oldestSequence;
|
|
2457
|
-
newestSequenceRef.current = maxResumeSequenceOrNull(retained.events) ?? window.newestSequence;
|
|
2458
|
-
hasOlderRef.current = window.hasOlder || retained.truncated;
|
|
2459
|
-
hasNewerRef.current = false;
|
|
2460
|
-
lastSequenceRef.current = window.newestSequence;
|
|
2461
|
-
streamResumeSequenceRef.current = window.newestSequence;
|
|
2462
|
-
initialWindowLoadedRef.current = true;
|
|
2463
|
-
if (status !== void 0) {
|
|
2464
|
-
setSessionStatusProjection(status);
|
|
2465
|
-
}
|
|
2466
|
-
setEventWindow(retained);
|
|
2467
|
-
setHasOlder(window.hasOlder || retained.truncated);
|
|
2468
|
-
setHasNewer(false);
|
|
2469
|
-
setInitialLoading(false);
|
|
2470
|
-
}
|
|
2471
|
-
if (fullReplay) {
|
|
2472
|
-
setInitialLoading(false);
|
|
2473
|
-
}
|
|
2474
|
-
const stream = client.streamEvents(workspaceId, sessionId, {
|
|
2475
|
-
after: streamResumeSequenceRef.current,
|
|
2476
|
-
signal: controller.signal,
|
|
2477
|
-
onOpen: () => {
|
|
2478
|
-
void Promise.resolve().then(() => reconcileSession(sessionId)).catch((cause) => {
|
|
2479
|
-
if (isCurrent()) {
|
|
2480
|
-
setError(cause instanceof Error ? cause : new Error(String(cause)));
|
|
2481
|
-
}
|
|
2482
|
-
});
|
|
2483
|
-
},
|
|
2484
|
-
onStateChange: (state) => {
|
|
2485
|
-
if (isCurrent()) {
|
|
2486
|
-
setConnectionState(state);
|
|
2487
|
-
}
|
|
2488
|
-
}
|
|
2489
|
-
});
|
|
2490
|
-
for await (const event of stream) {
|
|
2491
|
-
if (!isCurrent()) break;
|
|
2492
|
-
const boundedEvent = event;
|
|
2493
|
-
const boundedEventBytes = browserJsonBytes(boundedEvent);
|
|
2494
|
-
const separatorBytes = pending.length === 0 ? 0 : 1;
|
|
2495
|
-
if (pending.length > 0 && (pending.length >= SESSION_EVENT_BROWSER_PENDING_MAX_COUNT || pendingBytes + separatorBytes + boundedEventBytes > SESSION_EVENT_BROWSER_PENDING_MAX_BYTES)) {
|
|
2496
|
-
flush();
|
|
2497
|
-
}
|
|
2498
|
-
pending.push(boundedEvent);
|
|
2499
|
-
pendingBytes += (pending.length === 1 ? 0 : 1) + boundedEventBytes;
|
|
2500
|
-
if (pending.length >= SESSION_EVENT_BROWSER_PENDING_MAX_COUNT || pendingBytes >= SESSION_EVENT_BROWSER_PENDING_MAX_BYTES) {
|
|
2501
|
-
flush();
|
|
2502
|
-
} else {
|
|
2503
|
-
scheduleFlush();
|
|
2504
|
-
}
|
|
2505
|
-
}
|
|
2506
|
-
if (isCurrent()) {
|
|
2507
|
-
flush();
|
|
2508
|
-
setConnectionState("ended");
|
|
2509
|
-
}
|
|
2510
|
-
} catch (cause) {
|
|
2511
|
-
if (isCurrent()) {
|
|
2512
|
-
flush();
|
|
2513
|
-
setError(cause instanceof Error ? cause : new Error(String(cause)));
|
|
2514
|
-
setConnectionState("error");
|
|
2515
|
-
setInitialLoading(false);
|
|
2516
|
-
}
|
|
2517
|
-
}
|
|
2518
|
-
})();
|
|
2519
|
-
return () => {
|
|
2520
|
-
controller.abort();
|
|
2521
|
-
if (generationRef.current === generation) {
|
|
2522
|
-
generationRef.current = generation + 1;
|
|
2523
|
-
}
|
|
2524
|
-
if (streamAbortRef.current === controller) {
|
|
2525
|
-
streamAbortRef.current = null;
|
|
2526
|
-
}
|
|
2527
|
-
if (flushTimer !== null) {
|
|
2528
|
-
clearTimeout(flushTimer);
|
|
2529
|
-
}
|
|
2530
|
-
};
|
|
2531
|
-
}, [
|
|
2532
|
-
client,
|
|
2533
|
-
workspaceId,
|
|
2534
|
-
sessionId,
|
|
2535
|
-
after,
|
|
2536
|
-
enabled,
|
|
2537
|
-
pageLive,
|
|
2538
|
-
streamEnabled,
|
|
2539
|
-
fullReplay,
|
|
2540
|
-
streamKey,
|
|
2541
|
-
streamEpoch,
|
|
2542
|
-
viewMode,
|
|
2543
|
-
reconcileSession
|
|
2544
|
-
]);
|
|
2545
|
-
const navigationBusy = () => loadingOlderRef.current || loadingNewerRef.current || loadingOldestRef.current || loadingLatestRef.current;
|
|
2546
|
-
const loadOlder = useCallback(
|
|
2547
|
-
() => createOlderHistoryLoadReceipt(async (markCommitted, preserveTail, markTailPreserved) => {
|
|
2548
|
-
if (!sessionId || navigationBusy() || !hasOlderRef.current) {
|
|
2549
|
-
return false;
|
|
2550
|
-
}
|
|
2551
|
-
const before = oldestSequenceRef.current;
|
|
2552
|
-
if (before === null) {
|
|
2553
|
-
oldestSequenceRef.current = null;
|
|
2554
|
-
hasOlderRef.current = false;
|
|
2555
|
-
setHasOlder(false);
|
|
2556
|
-
return false;
|
|
2557
|
-
}
|
|
2558
|
-
const generation = navigationGenerationRef.current;
|
|
2559
|
-
loadingOlderRef.current = true;
|
|
2560
|
-
setLoadingOlder(true);
|
|
2561
|
-
let published = false;
|
|
2562
|
-
try {
|
|
2563
|
-
const window = await loadEventWindow(client, workspaceId, sessionId, {
|
|
2564
|
-
before,
|
|
2565
|
-
pageSize: SESSION_HISTORY_PAGE_SIZE,
|
|
2566
|
-
targetGroups: OLDER_GROUP_TARGET,
|
|
2567
|
-
maxFetches: OLDER_FETCH_CAP
|
|
2568
|
-
});
|
|
2569
|
-
if (navigationGenerationRef.current !== generation) {
|
|
2570
|
-
return false;
|
|
2571
|
-
}
|
|
2572
|
-
if (window.events.length === 0) {
|
|
2573
|
-
oldestSequenceRef.current = null;
|
|
2574
|
-
hasOlderRef.current = false;
|
|
2575
|
-
setHasOlder(false);
|
|
2576
|
-
return false;
|
|
2577
|
-
}
|
|
2578
|
-
const current = eventWindowRef.current;
|
|
2579
|
-
assertPrependOrder(current.events, window.events);
|
|
2580
|
-
const next = boundBrowserSessionEventWindow([...window.events, ...current.events], {
|
|
2581
|
-
direction: "oldest"
|
|
2582
|
-
});
|
|
2583
|
-
if (preserveTail && maxResumeSequence(next.events) < maxResumeSequence(current.events)) {
|
|
2584
|
-
markTailPreserved();
|
|
2585
|
-
return false;
|
|
2586
|
-
}
|
|
2587
|
-
streamAbortRef.current?.abort();
|
|
2588
|
-
const status = observeSessionStatus(window.events, sessionStatusRef);
|
|
2589
|
-
const retained = {
|
|
2590
|
-
...next,
|
|
2591
|
-
truncated: current.truncated || next.truncated
|
|
2592
|
-
};
|
|
2593
|
-
const retainedOldest = retained.events[0]?.sequence ?? null;
|
|
2594
|
-
if (retainedOldest === null || retainedOldest >= before) {
|
|
2595
|
-
throw new Error("@opengeni/react: loadOlder made no durable sequence progress");
|
|
2596
|
-
}
|
|
2597
|
-
const retainedNewest = maxResumeSequenceOrNull(retained.events);
|
|
2598
|
-
const previousNewest = maxResumeSequenceOrNull(current.events);
|
|
2599
|
-
eventWindowRef.current = retained;
|
|
2600
|
-
markCommitted();
|
|
2601
|
-
oldestSequenceRef.current = retainedOldest;
|
|
2602
|
-
newestSequenceRef.current = retainedNewest;
|
|
2603
|
-
streamResumeSequenceRef.current = maxResumeSequence(retained.events);
|
|
2604
|
-
const olderStillAvailable = window.hasOlder;
|
|
2605
|
-
hasOlderRef.current = olderStillAvailable;
|
|
2606
|
-
const evictedLiveTail = previousNewest !== null && retainedNewest !== null && retainedNewest < previousNewest;
|
|
2607
|
-
let newer = null;
|
|
2608
|
-
let enterHistory = false;
|
|
2609
|
-
let reconnectLive = false;
|
|
2610
|
-
if (viewModeRef.current === "history" || evictedLiveTail) {
|
|
2611
|
-
const highWater = lastSequenceRef.current;
|
|
2612
|
-
newer = retainedNewest !== null && (retainedNewest < highWater || retained.truncated);
|
|
2613
|
-
hasNewerRef.current = newer;
|
|
2614
|
-
if (evictedLiveTail) {
|
|
2615
|
-
viewModeRef.current = "history";
|
|
2616
|
-
enterHistory = true;
|
|
2617
|
-
}
|
|
2618
|
-
} else {
|
|
2619
|
-
reconnectLive = true;
|
|
2620
|
-
}
|
|
2621
|
-
loadingOlderRef.current = false;
|
|
2622
|
-
startTransition(() => {
|
|
2623
|
-
if (status !== void 0) {
|
|
2624
|
-
setSessionStatusProjection(status);
|
|
2625
|
-
}
|
|
2626
|
-
setEventWindow(retained);
|
|
2627
|
-
setHasOlder(olderStillAvailable);
|
|
2628
|
-
if (newer !== null) {
|
|
2629
|
-
setHasNewer(newer);
|
|
2630
|
-
}
|
|
2631
|
-
if (enterHistory) {
|
|
2632
|
-
setViewMode("history");
|
|
2633
|
-
} else if (reconnectLive) {
|
|
2634
|
-
setStreamEpoch((epoch) => epoch + 1);
|
|
2635
|
-
}
|
|
2636
|
-
setLoadingOlder(false);
|
|
2637
|
-
});
|
|
2638
|
-
published = true;
|
|
2639
|
-
return olderStillAvailable;
|
|
2640
|
-
} finally {
|
|
2641
|
-
if (!published && navigationGenerationRef.current === generation) {
|
|
2642
|
-
loadingOlderRef.current = false;
|
|
2643
|
-
setLoadingOlder(false);
|
|
2644
|
-
}
|
|
2645
|
-
}
|
|
2646
|
-
}),
|
|
2647
|
-
[client, workspaceId, sessionId]
|
|
2648
|
-
);
|
|
2649
|
-
const loadOldest = useCallback(async () => {
|
|
2650
|
-
if (!sessionId || navigationBusy() || !hasOlderRef.current) {
|
|
2651
|
-
return false;
|
|
2652
|
-
}
|
|
2653
|
-
const generation = navigationGenerationRef.current;
|
|
2654
|
-
loadingOldestRef.current = true;
|
|
2655
|
-
setLoadingOldest(true);
|
|
2656
|
-
let published = false;
|
|
2657
|
-
try {
|
|
2658
|
-
const window = await loadForwardEventWindow(client, workspaceId, sessionId, {
|
|
2659
|
-
after: 0,
|
|
2660
|
-
pageSize: SESSION_HISTORY_PAGE_SIZE,
|
|
2661
|
-
targetGroups: OLDEST_GROUP_TARGET,
|
|
2662
|
-
maxFetches: OLDEST_FETCH_CAP
|
|
2663
|
-
});
|
|
2664
|
-
if (navigationGenerationRef.current !== generation) {
|
|
2665
|
-
return false;
|
|
2666
|
-
}
|
|
2667
|
-
if (window.events.length === 0) {
|
|
2668
|
-
hasOlderRef.current = false;
|
|
2669
|
-
setHasOlder(false);
|
|
2670
|
-
return false;
|
|
2671
|
-
}
|
|
2672
|
-
streamAbortRef.current?.abort();
|
|
2673
|
-
const status = observeSessionStatus(window.events, sessionStatusRef);
|
|
2674
|
-
const retained = boundBrowserSessionEventWindow(window.events, { direction: "oldest" });
|
|
2675
|
-
const retainedOldest = retained.events[0]?.sequence ?? null;
|
|
2676
|
-
const retainedNewest = maxResumeSequenceOrNull(retained.events);
|
|
2677
|
-
eventWindowRef.current = retained;
|
|
2678
|
-
oldestSequenceRef.current = retainedOldest;
|
|
2679
|
-
newestSequenceRef.current = retainedNewest;
|
|
2680
|
-
hasOlderRef.current = false;
|
|
2681
|
-
const highWater = Math.max(lastSequenceRef.current, retainedNewest ?? 0);
|
|
2682
|
-
lastSequenceRef.current = highWater;
|
|
2683
|
-
const newer = window.hasNewer || retained.truncated || retainedNewest !== null && retainedNewest < highWater;
|
|
2684
|
-
hasNewerRef.current = newer;
|
|
2685
|
-
initialWindowLoadedRef.current = true;
|
|
2686
|
-
viewModeRef.current = "history";
|
|
2687
|
-
loadingOldestRef.current = false;
|
|
2688
|
-
startTransition(() => {
|
|
2689
|
-
if (status !== void 0) {
|
|
2690
|
-
setSessionStatusProjection(status);
|
|
2691
|
-
}
|
|
2692
|
-
setEventWindow(retained);
|
|
2693
|
-
setHasOlder(false);
|
|
2694
|
-
setHasNewer(newer);
|
|
2695
|
-
setViewMode("history");
|
|
2696
|
-
setLoadingOldest(false);
|
|
2697
|
-
});
|
|
2698
|
-
published = true;
|
|
2699
|
-
return newer;
|
|
2700
|
-
} finally {
|
|
2701
|
-
if (!published && navigationGenerationRef.current === generation) {
|
|
2702
|
-
loadingOldestRef.current = false;
|
|
2703
|
-
setLoadingOldest(false);
|
|
2704
|
-
}
|
|
2705
|
-
}
|
|
2706
|
-
}, [client, workspaceId, sessionId]);
|
|
2707
|
-
const loadNewer = useCallback(async () => {
|
|
2708
|
-
if (!sessionId || navigationBusy() || !hasNewerRef.current) {
|
|
2709
|
-
return false;
|
|
2710
|
-
}
|
|
2711
|
-
const afterSequence = newestSequenceRef.current;
|
|
2712
|
-
if (afterSequence === null) {
|
|
2713
|
-
hasNewerRef.current = false;
|
|
2714
|
-
setHasNewer(false);
|
|
2715
|
-
return false;
|
|
2716
|
-
}
|
|
2717
|
-
const generation = navigationGenerationRef.current;
|
|
2718
|
-
loadingNewerRef.current = true;
|
|
2719
|
-
setLoadingNewer(true);
|
|
2720
|
-
let published = false;
|
|
2721
|
-
try {
|
|
2722
|
-
const window = await loadForwardEventWindow(client, workspaceId, sessionId, {
|
|
2723
|
-
after: afterSequence,
|
|
2724
|
-
pageSize: SESSION_HISTORY_PAGE_SIZE,
|
|
2725
|
-
targetGroups: NEWER_GROUP_TARGET,
|
|
2726
|
-
maxFetches: NEWER_FETCH_CAP
|
|
2727
|
-
});
|
|
2728
|
-
if (navigationGenerationRef.current !== generation) {
|
|
2729
|
-
return false;
|
|
2730
|
-
}
|
|
2731
|
-
if (window.events.length === 0) {
|
|
2732
|
-
hasNewerRef.current = false;
|
|
2733
|
-
setHasNewer(false);
|
|
2734
|
-
streamResumeSequenceRef.current = afterSequence;
|
|
2735
|
-
viewModeRef.current = "live";
|
|
2736
|
-
setViewMode("live");
|
|
2737
|
-
setStreamEpoch((epoch) => epoch + 1);
|
|
2738
|
-
return false;
|
|
2739
|
-
}
|
|
2740
|
-
const current = eventWindowRef.current;
|
|
2741
|
-
assertAppendOrder(current.events, window.events);
|
|
2742
|
-
const status = observeSessionStatus(window.events, sessionStatusRef);
|
|
2743
|
-
const previousOldest = current.events[0]?.sequence ?? null;
|
|
2744
|
-
const next = boundBrowserSessionEventWindow([...current.events, ...window.events], {
|
|
2745
|
-
direction: "newest"
|
|
2746
|
-
});
|
|
2747
|
-
const retained = {
|
|
2748
|
-
...next,
|
|
2749
|
-
truncated: current.truncated || next.truncated || window.hasNewer
|
|
2750
|
-
};
|
|
2751
|
-
const retainedOldest = retained.events[0]?.sequence ?? null;
|
|
2752
|
-
const retainedNewest = maxResumeSequenceOrNull(retained.events);
|
|
2753
|
-
if (retainedNewest === null || retainedNewest <= afterSequence) {
|
|
2754
|
-
throw new Error("@opengeni/react: loadNewer made no durable sequence progress");
|
|
2755
|
-
}
|
|
2756
|
-
eventWindowRef.current = retained;
|
|
2757
|
-
oldestSequenceRef.current = retainedOldest;
|
|
2758
|
-
newestSequenceRef.current = retainedNewest;
|
|
2759
|
-
if (retainedOldest !== null && (previousOldest === null || retainedOldest > previousOldest || retained.truncated && retained.events[0]?.type !== "session.created" && retainedOldest > 1)) {
|
|
2760
|
-
hasOlderRef.current = true;
|
|
2761
|
-
}
|
|
2762
|
-
const rearmedOlder = hasOlderRef.current;
|
|
2763
|
-
const highWater = Math.max(lastSequenceRef.current, retainedNewest);
|
|
2764
|
-
lastSequenceRef.current = highWater;
|
|
2765
|
-
const newer = window.hasNewer || retainedNewest < highWater;
|
|
2766
|
-
hasNewerRef.current = newer;
|
|
2767
|
-
let resumeLive = false;
|
|
2768
|
-
if (!newer) {
|
|
2769
|
-
streamResumeSequenceRef.current = retainedNewest;
|
|
2770
|
-
viewModeRef.current = "live";
|
|
2771
|
-
resumeLive = true;
|
|
2772
|
-
}
|
|
2773
|
-
loadingNewerRef.current = false;
|
|
2774
|
-
startTransition(() => {
|
|
2775
|
-
if (status !== void 0) {
|
|
2776
|
-
setSessionStatusProjection(status);
|
|
2777
|
-
}
|
|
2778
|
-
setEventWindow(retained);
|
|
2779
|
-
setHasOlder(rearmedOlder);
|
|
2780
|
-
setHasNewer(newer);
|
|
2781
|
-
if (resumeLive) {
|
|
2782
|
-
setViewMode("live");
|
|
2783
|
-
setStreamEpoch((epoch) => epoch + 1);
|
|
2784
|
-
}
|
|
2785
|
-
setLoadingNewer(false);
|
|
2786
|
-
});
|
|
2787
|
-
published = true;
|
|
2788
|
-
return newer;
|
|
2789
|
-
} finally {
|
|
2790
|
-
if (!published && navigationGenerationRef.current === generation) {
|
|
2791
|
-
loadingNewerRef.current = false;
|
|
2792
|
-
setLoadingNewer(false);
|
|
2793
|
-
}
|
|
2794
|
-
}
|
|
2795
|
-
}, [client, workspaceId, sessionId]);
|
|
2796
|
-
const jumpToLatest = useCallback(async () => {
|
|
2797
|
-
if (!sessionId || navigationBusy()) {
|
|
2798
|
-
return;
|
|
2799
|
-
}
|
|
2800
|
-
loadingLatestRef.current = true;
|
|
2801
|
-
setLoadingLatest(true);
|
|
2802
|
-
let published = false;
|
|
2803
|
-
try {
|
|
2804
|
-
streamAbortRef.current?.abort();
|
|
2805
|
-
hasNewerRef.current = false;
|
|
2806
|
-
hasOlderRef.current = false;
|
|
2807
|
-
newestSequenceRef.current = null;
|
|
2808
|
-
oldestSequenceRef.current = null;
|
|
2809
|
-
eventWindowRef.current = EMPTY_EVENT_WINDOW;
|
|
2810
|
-
initialWindowLoadedRef.current = false;
|
|
2811
|
-
streamResumeSequenceRef.current = after;
|
|
2812
|
-
viewModeRef.current = "live";
|
|
2813
|
-
loadingLatestRef.current = false;
|
|
2814
|
-
startTransition(() => {
|
|
2815
|
-
setHasNewer(false);
|
|
2816
|
-
setHasOlder(false);
|
|
2817
|
-
setEventWindow(EMPTY_EVENT_WINDOW);
|
|
2818
|
-
setInitialLoading(true);
|
|
2819
|
-
setViewMode("live");
|
|
2820
|
-
setStreamEpoch((epoch) => epoch + 1);
|
|
2821
|
-
setLoadingLatest(false);
|
|
2822
|
-
});
|
|
2823
|
-
published = true;
|
|
2824
|
-
await Promise.resolve();
|
|
2825
|
-
} finally {
|
|
2826
|
-
if (!published) {
|
|
2827
|
-
loadingLatestRef.current = false;
|
|
2828
|
-
setLoadingLatest(false);
|
|
2829
|
-
}
|
|
2830
|
-
}
|
|
2831
|
-
}, [after, sessionId]);
|
|
2832
|
-
const identityMatches = stateStreamKey === streamKey;
|
|
2833
|
-
const visibleEvents = identityMatches ? eventWindow.events : EMPTY_EVENTS;
|
|
2834
|
-
const timeline = useMemo(() => buildTimeline(visibleEvents), [visibleEvents]);
|
|
2835
|
-
return {
|
|
2836
|
-
events: visibleEvents,
|
|
2837
|
-
timeline,
|
|
2838
|
-
sessionStatus: identityMatches ? sessionStatusProjection : null,
|
|
2839
|
-
sessionStatusSequence: identityMatches ? sessionStatusRef.current.sequence : 0,
|
|
2840
|
-
connectionState: identityMatches ? connectionState : "idle",
|
|
2841
|
-
lastSequence: identityMatches ? lastSequenceRef.current : after,
|
|
2842
|
-
windowBytes: identityMatches ? eventWindow.bytes : 2,
|
|
2843
|
-
windowTruncated: identityMatches ? eventWindow.truncated : false,
|
|
2844
|
-
initialLoading: fullReplay ? false : identityMatches ? initialLoading : true,
|
|
2845
|
-
hasOlder: !identityMatches ? false : hasOlder,
|
|
2846
|
-
loadingOlder: !identityMatches ? false : loadingOlder,
|
|
2847
|
-
loadOlder,
|
|
2848
|
-
hasNewer: !identityMatches ? false : hasNewer,
|
|
2849
|
-
loadingNewer: !identityMatches ? false : loadingNewer,
|
|
2850
|
-
loadNewer,
|
|
2851
|
-
loadingOldest: !identityMatches ? false : loadingOldest,
|
|
2852
|
-
loadOldest,
|
|
2853
|
-
loadingLatest: !identityMatches ? false : loadingLatest,
|
|
2854
|
-
jumpToLatest,
|
|
2855
|
-
error: identityMatches ? error : null
|
|
2856
|
-
};
|
|
2857
|
-
}
|
|
2858
|
-
function boundBrowserSessionEventWindow(events, options = {}) {
|
|
2859
|
-
const maxBytes = Math.max(1024, options.maxBytes ?? SESSION_EVENT_BROWSER_MAX_BYTES);
|
|
2860
|
-
const maxCount = Math.max(1, Math.floor(options.maxCount ?? SESSION_EVENT_BROWSER_MAX_COUNT));
|
|
2861
|
-
const safe = events;
|
|
2862
|
-
const selected = [];
|
|
2863
|
-
let bytes = 2;
|
|
2864
|
-
const direction = options.direction ?? "newest";
|
|
2865
|
-
const start = direction === "newest" ? safe.length - 1 : 0;
|
|
2866
|
-
const end = direction === "newest" ? Math.max(-1, safe.length - maxCount - 1) : safe.length;
|
|
2867
|
-
const step = direction === "newest" ? -1 : 1;
|
|
2868
|
-
for (let index = start; index !== end && selected.length < maxCount; index += step) {
|
|
2869
|
-
const event = safe[index];
|
|
2870
|
-
const eventBytes = browserJsonBytes(event);
|
|
2871
|
-
const separator = selected.length === 0 ? 0 : 1;
|
|
2872
|
-
if (selected.length > 0 && bytes + separator + eventBytes > maxBytes) break;
|
|
2873
|
-
selected.push(event);
|
|
2874
|
-
bytes += separator + eventBytes;
|
|
2875
|
-
}
|
|
2876
|
-
if (direction === "newest") selected.reverse();
|
|
2877
|
-
return {
|
|
2878
|
-
events: selected,
|
|
2879
|
-
bytes,
|
|
2880
|
-
truncated: selected.length < safe.length
|
|
2881
|
-
};
|
|
2882
|
-
}
|
|
2883
|
-
function browserJsonBytes(value) {
|
|
2884
|
-
return encoder.encode(JSON.stringify(value)).byteLength;
|
|
2885
|
-
}
|
|
2886
|
-
function observeSessionStatus(events, ref) {
|
|
2887
|
-
let latest = null;
|
|
2888
|
-
for (const event of events) {
|
|
2889
|
-
const status = sessionStatusFromEvents([event]);
|
|
2890
|
-
if (status && (!latest || event.sequence >= latest.sequence)) {
|
|
2891
|
-
latest = { sequence: event.sequence, status };
|
|
2892
|
-
}
|
|
2893
|
-
}
|
|
2894
|
-
if (!latest || latest.sequence < ref.current.sequence) return void 0;
|
|
2895
|
-
ref.current = latest;
|
|
2896
|
-
return latest.status;
|
|
2897
|
-
}
|
|
2898
|
-
async function planForegroundCatchup(client, workspaceId, sessionId, cursor, options = {}) {
|
|
2899
|
-
if (options.signal?.aborted) throw abortError();
|
|
2900
|
-
const session = await client.getSession(workspaceId, sessionId, {
|
|
2901
|
-
fresh: true,
|
|
2902
|
-
...options.signal ? { signal: options.signal } : {}
|
|
2903
|
-
});
|
|
2904
|
-
if (options.signal?.aborted) throw abortError();
|
|
2905
|
-
const durableHead = Math.max(cursor, session.lastSequence);
|
|
2906
|
-
const rawGap = durableHead - cursor;
|
|
2907
|
-
if (rawGap <= FOREGROUND_DIRECT_REPLAY_MAX_SEQUENCES) {
|
|
2908
|
-
return { kind: "resume" };
|
|
2909
|
-
}
|
|
2910
|
-
if (rawGap > FOREGROUND_COMPACT_PROBE_MAX_SEQUENCES) {
|
|
2911
|
-
return { kind: "reload" };
|
|
2912
|
-
}
|
|
2913
|
-
const page = await loadNextPage(client, workspaceId, sessionId, cursor, {
|
|
2914
|
-
pageSize: rawGap,
|
|
2915
|
-
...options.signal ? { signal: options.signal } : {}
|
|
2916
|
-
});
|
|
2917
|
-
const events = page.filter((event) => eventResumeSequence(event) > cursor);
|
|
2918
|
-
if (events.length === 0) {
|
|
2919
|
-
return { kind: "reload" };
|
|
2920
|
-
}
|
|
2921
|
-
assertAscending(events);
|
|
2922
|
-
const resumeSequence = maxResumeSequence(events);
|
|
2923
|
-
if (resumeSequence < durableHead) {
|
|
2924
|
-
return { kind: "reload" };
|
|
2925
|
-
}
|
|
2926
|
-
if (events.length > FOREGROUND_COMPACT_CATCHUP_MAX_EVENTS || groupCount(events) > FOREGROUND_COMPACT_CATCHUP_MAX_GROUPS || browserJsonBytes(events) > FOREGROUND_COMPACT_CATCHUP_MAX_BYTES) {
|
|
2927
|
-
return { kind: "reload" };
|
|
2928
|
-
}
|
|
2929
|
-
return { kind: "append", events, resumeSequence };
|
|
2930
|
-
}
|
|
2931
|
-
async function loadEventWindow(client, workspaceId, sessionId, options) {
|
|
2932
|
-
let cursor = options.before;
|
|
2933
|
-
let buffer = [];
|
|
2934
|
-
let reachedStart = false;
|
|
2935
|
-
let fetches = 0;
|
|
2936
|
-
while (fetches < options.maxFetches) {
|
|
2937
|
-
if (buffer.length > 0 && groupCount(buffer) >= options.targetGroups) {
|
|
2938
|
-
break;
|
|
2939
|
-
}
|
|
2940
|
-
const page = await loadPreviousPage(client, workspaceId, sessionId, cursor, {
|
|
2941
|
-
pageSize: options.pageSize,
|
|
2942
|
-
...options.signal ? { signal: options.signal } : {}
|
|
2943
|
-
});
|
|
2944
|
-
fetches += 1;
|
|
2945
|
-
if (page.length === 0) {
|
|
2946
|
-
reachedStart = true;
|
|
2947
|
-
break;
|
|
2948
|
-
}
|
|
2949
|
-
assertAscending(page);
|
|
2950
|
-
buffer = [...page, ...buffer];
|
|
2951
|
-
cursor = page[0].sequence;
|
|
2952
|
-
if (isLogStart(page[0])) {
|
|
2953
|
-
reachedStart = true;
|
|
2954
|
-
break;
|
|
2955
|
-
}
|
|
2956
|
-
}
|
|
2957
|
-
let snapPages = 0;
|
|
2958
|
-
while (!reachedStart && findBoundaryIndex(buffer) === -1 && snapPages < (options.boundaryPageCap ?? 0)) {
|
|
2959
|
-
const page = await loadPreviousPage(client, workspaceId, sessionId, cursor, {
|
|
2960
|
-
pageSize: options.pageSize,
|
|
2961
|
-
...options.signal ? { signal: options.signal } : {}
|
|
2962
|
-
});
|
|
2963
|
-
fetches += 1;
|
|
2964
|
-
snapPages += 1;
|
|
2965
|
-
if (page.length === 0) {
|
|
2966
|
-
reachedStart = true;
|
|
2967
|
-
break;
|
|
2968
|
-
}
|
|
2969
|
-
assertAscending(page);
|
|
2970
|
-
buffer = [...page, ...buffer];
|
|
2971
|
-
cursor = page[0].sequence;
|
|
2972
|
-
if (isLogStart(page[0])) {
|
|
2973
|
-
reachedStart = true;
|
|
2974
|
-
break;
|
|
2975
|
-
}
|
|
2976
|
-
}
|
|
2977
|
-
if (!reachedStart) {
|
|
2978
|
-
const boundary = findBoundaryIndex(buffer);
|
|
2979
|
-
if (boundary > 0) {
|
|
2980
|
-
buffer = buffer.slice(boundary);
|
|
2981
|
-
}
|
|
2982
|
-
}
|
|
2983
|
-
const densityWindow = trimBackwardToGroupTarget(buffer, options.targetGroups);
|
|
2984
|
-
buffer = densityWindow.events;
|
|
2985
|
-
const oldest = buffer[0] ?? null;
|
|
2986
|
-
const newest = buffer[buffer.length - 1] ?? null;
|
|
2987
|
-
return {
|
|
2988
|
-
events: buffer,
|
|
2989
|
-
oldestSequence: oldest?.sequence ?? null,
|
|
2990
|
-
newestSequence: newest ? maxResumeSequence(buffer) : 0,
|
|
2991
|
-
hasOlder: buffer.length > 0 && (densityWindow.trimmed || !reachedStart && oldest?.type !== "session.created")
|
|
2992
|
-
};
|
|
2993
|
-
}
|
|
2994
|
-
function findBoundaryIndex(events) {
|
|
2995
|
-
for (let index = 0; index < events.length; index += 1) {
|
|
2996
|
-
if (isTurnBoundary2(events[index])) {
|
|
2997
|
-
return index;
|
|
2998
|
-
}
|
|
2999
|
-
}
|
|
3000
|
-
return -1;
|
|
3001
|
-
}
|
|
3002
|
-
function isTurnBoundary2(event) {
|
|
3003
|
-
return event.type === "session.created" || event.type === "user.message";
|
|
3004
|
-
}
|
|
3005
|
-
async function loadForwardEventWindow(client, workspaceId, sessionId, options) {
|
|
3006
|
-
let cursor = options.after;
|
|
3007
|
-
let buffer = [];
|
|
3008
|
-
let fetches = 0;
|
|
3009
|
-
let reachedEnd = false;
|
|
3010
|
-
while (fetches < options.maxFetches) {
|
|
3011
|
-
if (buffer.length > 0 && groupCount(buffer) >= options.targetGroups) {
|
|
3012
|
-
break;
|
|
3013
|
-
}
|
|
3014
|
-
const page = await loadNextPage(client, workspaceId, sessionId, cursor, {
|
|
3015
|
-
pageSize: options.pageSize,
|
|
3016
|
-
...options.signal ? { signal: options.signal } : {}
|
|
3017
|
-
});
|
|
3018
|
-
fetches += 1;
|
|
3019
|
-
if (page.length === 0) {
|
|
3020
|
-
reachedEnd = true;
|
|
3021
|
-
break;
|
|
3022
|
-
}
|
|
3023
|
-
assertAscending(page);
|
|
3024
|
-
buffer = [...buffer, ...page];
|
|
3025
|
-
cursor = maxResumeSequence(page);
|
|
3026
|
-
}
|
|
3027
|
-
const densityWindow = trimForwardToGroupTarget(buffer, options.targetGroups);
|
|
3028
|
-
buffer = densityWindow.events;
|
|
3029
|
-
const oldest = buffer[0] ?? null;
|
|
3030
|
-
const newest = buffer[buffer.length - 1] ?? null;
|
|
3031
|
-
return {
|
|
3032
|
-
events: buffer,
|
|
3033
|
-
oldestSequence: oldest?.sequence ?? null,
|
|
3034
|
-
newestSequence: newest ? maxResumeSequence(buffer) : 0,
|
|
3035
|
-
hasNewer: buffer.length > 0 && (densityWindow.trimmed || !reachedEnd)
|
|
3036
|
-
};
|
|
3037
|
-
}
|
|
3038
|
-
function trimBackwardToGroupTarget(events, targetGroups) {
|
|
3039
|
-
if (!Number.isFinite(targetGroups) || targetGroups <= 0 || events.length === 0) {
|
|
3040
|
-
return { events, trimmed: false };
|
|
3041
|
-
}
|
|
3042
|
-
for (let index = events.length - 1; index > 0; index -= 1) {
|
|
3043
|
-
if (!isTurnBoundary2(events[index])) continue;
|
|
3044
|
-
const candidate = events.slice(index);
|
|
3045
|
-
if (groupCount(candidate) >= targetGroups) {
|
|
3046
|
-
return { events: candidate, trimmed: true };
|
|
3047
|
-
}
|
|
3048
|
-
}
|
|
3049
|
-
return { events, trimmed: false };
|
|
3050
|
-
}
|
|
3051
|
-
function trimForwardToGroupTarget(events, targetGroups) {
|
|
3052
|
-
if (!Number.isFinite(targetGroups) || targetGroups <= 0 || events.length === 0) {
|
|
3053
|
-
return { events, trimmed: false };
|
|
3054
|
-
}
|
|
3055
|
-
for (let index = 1; index < events.length; index += 1) {
|
|
3056
|
-
if (!isTurnBoundary2(events[index])) continue;
|
|
3057
|
-
const candidate = events.slice(0, index);
|
|
3058
|
-
if (groupCount(candidate) >= targetGroups) {
|
|
3059
|
-
return { events: candidate, trimmed: true };
|
|
3060
|
-
}
|
|
3061
|
-
}
|
|
3062
|
-
return { events, trimmed: false };
|
|
3063
|
-
}
|
|
3064
|
-
async function loadPreviousPage(client, workspaceId, sessionId, before, options) {
|
|
3065
|
-
if (options.signal?.aborted) {
|
|
3066
|
-
throw abortError();
|
|
3067
|
-
}
|
|
3068
|
-
const requested = options.pageSize;
|
|
3069
|
-
if (requested === 0) {
|
|
3070
|
-
return Object.assign([], { requested });
|
|
3071
|
-
}
|
|
3072
|
-
const page = await client.listEvents(workspaceId, sessionId, {
|
|
3073
|
-
before,
|
|
3074
|
-
limit: requested,
|
|
3075
|
-
compact: true,
|
|
3076
|
-
// Monitoring summaries omit correlation fields once a bounded durable
|
|
3077
|
-
// payload exceeds their preview threshold. The browser timeline needs the
|
|
3078
|
-
// exact stored payload so persisted tool outputs still match their
|
|
3079
|
-
// calls and expose truthful truncation telemetry after a reload.
|
|
3080
|
-
payloadMode: "full"
|
|
3081
|
-
});
|
|
3082
|
-
if (options.signal?.aborted) {
|
|
3083
|
-
throw abortError();
|
|
3084
|
-
}
|
|
3085
|
-
return Object.assign(page, { requested });
|
|
3086
|
-
}
|
|
3087
|
-
async function loadNextPage(client, workspaceId, sessionId, after, options) {
|
|
3088
|
-
if (options.signal?.aborted) {
|
|
3089
|
-
throw abortError();
|
|
3090
|
-
}
|
|
3091
|
-
const requested = options.pageSize;
|
|
3092
|
-
if (requested === 0) {
|
|
3093
|
-
return Object.assign([], { requested });
|
|
3094
|
-
}
|
|
3095
|
-
const page = await client.listEvents(workspaceId, sessionId, {
|
|
3096
|
-
after,
|
|
3097
|
-
limit: requested,
|
|
3098
|
-
compact: true,
|
|
3099
|
-
direction: "after",
|
|
3100
|
-
payloadMode: "full"
|
|
3101
|
-
});
|
|
3102
|
-
if (options.signal?.aborted) {
|
|
3103
|
-
throw abortError();
|
|
3104
|
-
}
|
|
3105
|
-
return Object.assign(page, { requested });
|
|
3106
|
-
}
|
|
3107
|
-
function groupCount(events) {
|
|
3108
|
-
if (events.length === 0) {
|
|
3109
|
-
return 0;
|
|
3110
|
-
}
|
|
3111
|
-
return groupTimeline(buildTimeline(events)).length;
|
|
3112
|
-
}
|
|
3113
|
-
function isLogStart(event) {
|
|
3114
|
-
return event.type === "session.created" || event.sequence <= 1;
|
|
3115
|
-
}
|
|
3116
|
-
function maxResumeSequence(events) {
|
|
3117
|
-
return events.reduce((max, event) => Math.max(max, eventResumeSequence(event)), 0);
|
|
3118
|
-
}
|
|
3119
|
-
function maxResumeSequenceOrNull(events) {
|
|
3120
|
-
return events.length > 0 ? maxResumeSequence(events) : null;
|
|
3121
|
-
}
|
|
3122
|
-
function eventResumeSequence(event) {
|
|
3123
|
-
const streamedCoverage = sessionEventStreamCoveredThrough(event);
|
|
3124
|
-
if (streamedCoverage !== null) return streamedCoverage;
|
|
3125
|
-
return typeof event.coveredThrough === "number" && Number.isSafeInteger(event.coveredThrough) && event.coveredThrough >= event.sequence ? event.coveredThrough : event.sequence;
|
|
3126
|
-
}
|
|
3127
|
-
function assertAscending(events) {
|
|
3128
|
-
for (let index = 1; index < events.length; index += 1) {
|
|
3129
|
-
if (events[index - 1].sequence >= events[index].sequence) {
|
|
3130
|
-
throw new Error("@opengeni/react: session events must be ordered by ascending sequence");
|
|
3131
|
-
}
|
|
3132
|
-
}
|
|
3133
|
-
}
|
|
3134
|
-
function assertPrependOrder(existing, older) {
|
|
3135
|
-
if (!shouldAssertDevelopment() || existing.length === 0 || older.length === 0) {
|
|
3136
|
-
return;
|
|
3137
|
-
}
|
|
3138
|
-
if (older[older.length - 1].sequence >= existing[0].sequence) {
|
|
3139
|
-
throw new Error("@opengeni/react: loadOlder returned overlapping session events");
|
|
3140
|
-
}
|
|
3141
|
-
}
|
|
3142
|
-
function assertAppendOrder(existing, newer) {
|
|
3143
|
-
if (!shouldAssertDevelopment() || existing.length === 0 || newer.length === 0) {
|
|
3144
|
-
return;
|
|
3145
|
-
}
|
|
3146
|
-
if (newer[0].sequence <= existing[existing.length - 1].sequence) {
|
|
3147
|
-
throw new Error("@opengeni/react: loadNewer returned overlapping session events");
|
|
3148
|
-
}
|
|
3149
|
-
}
|
|
3150
|
-
function shouldAssertDevelopment() {
|
|
3151
|
-
const processEnv = globalThis.process?.env;
|
|
3152
|
-
return processEnv !== void 0 && processEnv.NODE_ENV !== "production";
|
|
3153
|
-
}
|
|
3154
|
-
function abortError() {
|
|
3155
|
-
const error = new Error("The operation was aborted.");
|
|
3156
|
-
error.name = "AbortError";
|
|
3157
|
-
return error;
|
|
3158
|
-
}
|
|
3159
|
-
|
|
3160
|
-
// src/hooks/use-session.ts
|
|
3161
|
-
import { useCallback as useCallback2, useEffect as useEffect2, useMemo as useMemo2, useRef as useRef2, useState as useState2 } from "react";
|
|
3162
|
-
function isTitleEvent(event) {
|
|
3163
|
-
return event.type === "session.title_set";
|
|
3164
|
-
}
|
|
3165
|
-
function isSessionDetailEvent(event) {
|
|
3166
|
-
return isTitleEvent(event) || event.type.startsWith("session.command.") || event.type.startsWith("session.wait.") || event.type === "session.status.changed" || event.type === "system.update.pending";
|
|
3167
|
-
}
|
|
3168
|
-
function useSession(sessionId, options = {}) {
|
|
3169
|
-
const { client, workspaceId, workspaceControlEvent, registerSessionReconciler } = useEmbeddedSessionRead(options);
|
|
3170
|
-
const enabled = (options.enabled ?? true) && Boolean(sessionId);
|
|
3171
|
-
const [override, setOverride] = useState2(null);
|
|
3172
|
-
const nextReadRevision = useRef2(0);
|
|
3173
|
-
const nextReadGeneration = useRef2(0);
|
|
3174
|
-
const beginRead = options.beginRead;
|
|
3175
|
-
const { run, mutating, mutationError, clearMutationError } = useMutationRunner();
|
|
3176
|
-
const load = useCallback2(
|
|
3177
|
-
async (signal) => {
|
|
3178
|
-
if (!sessionId) {
|
|
3179
|
-
return null;
|
|
3180
|
-
}
|
|
3181
|
-
let readGeneration2 = 0;
|
|
3182
|
-
const fetched = await client.getSession(workspaceId, sessionId, {
|
|
3183
|
-
fresh: true,
|
|
3184
|
-
signal,
|
|
3185
|
-
onRequestStart: () => {
|
|
3186
|
-
readGeneration2 = beginRead?.() ?? ++nextReadGeneration.current;
|
|
3187
|
-
}
|
|
3188
|
-
});
|
|
3189
|
-
setOverride(null);
|
|
3190
|
-
return {
|
|
3191
|
-
session: fetched,
|
|
3192
|
-
revision: ++nextReadRevision.current,
|
|
3193
|
-
readGeneration: readGeneration2
|
|
3194
|
-
};
|
|
3195
|
-
},
|
|
3196
|
-
[beginRead, client, workspaceId, sessionId]
|
|
3197
|
-
);
|
|
3198
|
-
const { data, loading, error, refresh } = usePolledValue(load, {
|
|
3199
|
-
pollIntervalMs: options.pollIntervalMs,
|
|
3200
|
-
enabled
|
|
3201
|
-
});
|
|
3202
|
-
useEffect2(() => {
|
|
3203
|
-
if (enabled && workspaceControlEvent) void refresh();
|
|
3204
|
-
}, [enabled, refresh, workspaceControlEvent]);
|
|
3205
|
-
useEffect2(() => {
|
|
3206
|
-
if (!sessionId || !enabled) return;
|
|
3207
|
-
return registerSessionReconciler(sessionId, "session", refresh);
|
|
3208
|
-
}, [enabled, refresh, registerSessionReconciler, sessionId]);
|
|
3209
|
-
const base = data?.session ?? null;
|
|
3210
|
-
const readRevision = data?.revision ?? 0;
|
|
3211
|
-
const readGeneration = data?.readGeneration ?? 0;
|
|
3212
|
-
const session = useMemo2(
|
|
3213
|
-
() => base && override && override.id === base.id ? { ...base, title: override.title, titleSource: override.titleSource } : base,
|
|
3214
|
-
[base, override]
|
|
3215
|
-
);
|
|
3216
|
-
const sharedEvents = options.events;
|
|
3217
|
-
const onTitleEvent = useCallback2(
|
|
3218
|
-
(event) => {
|
|
3219
|
-
if (sharedEvents?.some(
|
|
3220
|
-
(item) => item.sessionId === sessionId && !isTitleEvent(item) && isSessionDetailEvent(item) && item.sequence > (base?.lastSequence ?? -1)
|
|
3221
|
-
)) {
|
|
3222
|
-
void refresh();
|
|
3223
|
-
} else if (!isTitleEvent(event)) {
|
|
3224
|
-
if (!base || event.sequence > base.lastSequence) void refresh();
|
|
3225
|
-
return;
|
|
3226
|
-
}
|
|
3227
|
-
if (!base || event.sequence <= base.lastSequence) {
|
|
3228
|
-
return;
|
|
3229
|
-
}
|
|
3230
|
-
const payload = event.payload ?? {};
|
|
3231
|
-
const title = payload.title;
|
|
3232
|
-
if (typeof title !== "string") {
|
|
3233
|
-
return;
|
|
3234
|
-
}
|
|
3235
|
-
const source = payload.source === "user" || payload.source === "agent" ? payload.source : null;
|
|
3236
|
-
setOverride((current) => {
|
|
3237
|
-
const next = current ?? base;
|
|
3238
|
-
return { ...next, title, titleSource: source };
|
|
3239
|
-
});
|
|
3240
|
-
},
|
|
3241
|
-
[base, refresh, sharedEvents, sessionId]
|
|
3242
|
-
);
|
|
3243
|
-
useSessionEventTrigger(client, workspaceId, sessionId, isSessionDetailEvent, onTitleEvent, {
|
|
3244
|
-
enabled,
|
|
3245
|
-
...options.events !== void 0 ? { events: options.events } : {}
|
|
3246
|
-
});
|
|
3247
|
-
const updateTitle = useCallback2(
|
|
3248
|
-
async (title) => {
|
|
3249
|
-
if (!sessionId) {
|
|
3250
|
-
return null;
|
|
3251
|
-
}
|
|
3252
|
-
const result = await run(() => client.updateSession(workspaceId, sessionId, { title }));
|
|
3253
|
-
if (result) {
|
|
3254
|
-
setOverride(result);
|
|
3255
|
-
}
|
|
3256
|
-
return result;
|
|
3257
|
-
},
|
|
3258
|
-
[client, workspaceId, sessionId, run]
|
|
3259
|
-
);
|
|
3260
|
-
return {
|
|
3261
|
-
session,
|
|
3262
|
-
loading,
|
|
3263
|
-
error,
|
|
3264
|
-
readRevision,
|
|
3265
|
-
readGeneration,
|
|
3266
|
-
refresh,
|
|
3267
|
-
updateTitle,
|
|
3268
|
-
updating: mutating,
|
|
3269
|
-
mutationError,
|
|
3270
|
-
clearMutationError
|
|
3271
|
-
};
|
|
3272
|
-
}
|
|
3273
|
-
|
|
3274
|
-
// src/hooks/use-turn-queue.ts
|
|
3275
|
-
import { useCallback as useCallback3, useEffect as useEffect3, useLayoutEffect, useMemo as useMemo3, useRef as useRef3, useState as useState3 } from "react";
|
|
3276
|
-
function isTurnQueueEvent(event) {
|
|
3277
|
-
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.");
|
|
3278
|
-
}
|
|
3279
|
-
function queueSnapshotCovers(candidate, observed) {
|
|
3280
|
-
return Boolean(
|
|
3281
|
-
candidate && candidate.version >= observed.version && candidate.effectiveControl.controlVersion >= observed.effectiveControl.controlVersion
|
|
3282
|
-
);
|
|
3283
|
-
}
|
|
3284
|
-
var EMPTY_PENDING_BY_TURN = {};
|
|
3285
|
-
function useTurnQueue(sessionId, options = {}) {
|
|
3286
|
-
const { client, workspaceId, workspaceControlEvent, registerSessionReconciler } = useEmbeddedSession(options);
|
|
3287
|
-
const enabled = (options.enabled ?? true) && Boolean(sessionId);
|
|
3288
|
-
const targetKey = `${workspaceId}\0${sessionId ?? ""}`;
|
|
3289
|
-
const pageLive = usePageLiveActivity();
|
|
3290
|
-
const [snapshot, setSnapshot] = useState3(null);
|
|
3291
|
-
const [stateTargetKey, setStateTargetKey] = useState3(targetKey);
|
|
3292
|
-
const [loading, setLoading] = useState3(enabled);
|
|
3293
|
-
const [error, setError] = useState3(null);
|
|
3294
|
-
const [mutationError, setMutationError] = useState3(null);
|
|
3295
|
-
const [pendingByTurn, setPendingByTurn] = useState3({});
|
|
3296
|
-
const [acceptedSteers, setAcceptedSteers] = useState3([]);
|
|
3297
|
-
const pendingRef = useRef3({});
|
|
3298
|
-
const readGeneration = useRef3(0);
|
|
3299
|
-
const targetKeyRef = useRef3(targetKey);
|
|
3300
|
-
const snapshotRef = useRef3(null);
|
|
3301
|
-
useLayoutEffect(() => {
|
|
3302
|
-
if (targetKeyRef.current === targetKey) return;
|
|
3303
|
-
targetKeyRef.current = targetKey;
|
|
3304
|
-
readGeneration.current += 1;
|
|
3305
|
-
snapshotRef.current = null;
|
|
3306
|
-
pendingRef.current = {};
|
|
3307
|
-
setStateTargetKey(targetKey);
|
|
3308
|
-
setSnapshot(null);
|
|
3309
|
-
setLoading(enabled);
|
|
3310
|
-
setError(null);
|
|
3311
|
-
setMutationError(null);
|
|
3312
|
-
setPendingByTurn({});
|
|
3313
|
-
setAcceptedSteers([]);
|
|
3314
|
-
}, [enabled, targetKey]);
|
|
3315
|
-
useEffect3(() => {
|
|
3316
|
-
if (acceptedSteers.length === 0 || options.events === void 0) return;
|
|
3317
|
-
const durablyStartedTurnIds = new Set(
|
|
3318
|
-
options.events.flatMap(
|
|
3319
|
-
(event) => event.type === "turn.started" && event.turnId ? [event.turnId] : []
|
|
3320
|
-
)
|
|
3321
|
-
);
|
|
3322
|
-
if (durablyStartedTurnIds.size === 0) return;
|
|
3323
|
-
setAcceptedSteers(
|
|
3324
|
-
(current) => current.filter((steer) => !durablyStartedTurnIds.has(steer.turnId))
|
|
3325
|
-
);
|
|
3326
|
-
}, [acceptedSteers.length, options.events]);
|
|
3327
|
-
const acceptSnapshot = useCallback3(
|
|
3328
|
-
(ownedTargetKey, next) => {
|
|
3329
|
-
if (targetKeyRef.current !== ownedTargetKey) return false;
|
|
3330
|
-
const current = snapshotRef.current;
|
|
3331
|
-
if (next && current && (next.version < current.version || next.effectiveControl.controlVersion < current.effectiveControl.controlVersion)) {
|
|
3332
|
-
return false;
|
|
3333
|
-
}
|
|
3334
|
-
snapshotRef.current = next;
|
|
3335
|
-
setStateTargetKey(ownedTargetKey);
|
|
3336
|
-
setSnapshot(next);
|
|
3337
|
-
return true;
|
|
3338
|
-
},
|
|
3339
|
-
[]
|
|
3340
|
-
);
|
|
3341
|
-
const load = useCallback3(
|
|
3342
|
-
async (rejectOnFailure = false) => {
|
|
3343
|
-
if (!sessionId) return;
|
|
3344
|
-
const ownedTargetKey = `${workspaceId}\0${sessionId}`;
|
|
3345
|
-
const ticket = ++readGeneration.current;
|
|
3346
|
-
try {
|
|
3347
|
-
const fetched = await client.getQueue(workspaceId, sessionId);
|
|
3348
|
-
if (targetKeyRef.current !== ownedTargetKey) return;
|
|
3349
|
-
const ownsLatestRead = ticket === readGeneration.current;
|
|
3350
|
-
if (rejectOnFailure) {
|
|
3351
|
-
const committed = acceptSnapshot(ownedTargetKey, fetched);
|
|
3352
|
-
if (!committed && !queueSnapshotCovers(snapshotRef.current, fetched)) {
|
|
3353
|
-
throw new TypeError("Queue reconciliation did not commit authoritative state");
|
|
3354
|
-
}
|
|
3355
|
-
setError(null);
|
|
3356
|
-
if (ownsLatestRead) setLoading(false);
|
|
3357
|
-
} else if (ownsLatestRead) {
|
|
3358
|
-
acceptSnapshot(ownedTargetKey, fetched);
|
|
3359
|
-
setError(null);
|
|
3360
|
-
setLoading(false);
|
|
3361
|
-
}
|
|
3362
|
-
} catch (cause) {
|
|
3363
|
-
if (targetKeyRef.current === ownedTargetKey && (ticket === readGeneration.current || rejectOnFailure)) {
|
|
3364
|
-
setError(asError(cause));
|
|
3365
|
-
if (ticket === readGeneration.current) setLoading(false);
|
|
3366
|
-
}
|
|
3367
|
-
if (rejectOnFailure) throw cause;
|
|
3368
|
-
}
|
|
3369
|
-
},
|
|
3370
|
-
[client, workspaceId, sessionId, acceptSnapshot]
|
|
3371
|
-
);
|
|
3372
|
-
useEffect3(() => {
|
|
3373
|
-
if (!enabled || !pageLive) {
|
|
3374
|
-
setLoading(false);
|
|
3375
|
-
return;
|
|
3376
|
-
}
|
|
3377
|
-
setLoading(true);
|
|
3378
|
-
const pollIntervalMs = options.pollIntervalMs;
|
|
3379
|
-
if (pollIntervalMs === void 0 || pollIntervalMs <= 0) {
|
|
3380
|
-
void load();
|
|
3381
|
-
return () => {
|
|
3382
|
-
readGeneration.current += 1;
|
|
3383
|
-
};
|
|
3384
|
-
}
|
|
3385
|
-
let cancelled = false;
|
|
3386
|
-
let timer = null;
|
|
3387
|
-
const schedule = () => {
|
|
3388
|
-
if (cancelled) return;
|
|
3389
|
-
timer = setTimeout(() => {
|
|
3390
|
-
timer = null;
|
|
3391
|
-
void load().finally(schedule);
|
|
3392
|
-
}, pollIntervalMs);
|
|
3393
|
-
};
|
|
3394
|
-
void load().finally(schedule);
|
|
3395
|
-
return () => {
|
|
3396
|
-
cancelled = true;
|
|
3397
|
-
if (timer !== null) clearTimeout(timer);
|
|
3398
|
-
readGeneration.current += 1;
|
|
3399
|
-
};
|
|
3400
|
-
}, [load, enabled, pageLive, options.pollIntervalMs]);
|
|
3401
|
-
useEffect3(() => {
|
|
3402
|
-
if (enabled && workspaceControlEvent) void load();
|
|
3403
|
-
}, [enabled, load, workspaceControlEvent]);
|
|
3404
|
-
useEffect3(() => {
|
|
3405
|
-
if (!sessionId || !enabled) return;
|
|
3406
|
-
return registerSessionReconciler(sessionId, "queue", load);
|
|
3407
|
-
}, [enabled, load, registerSessionReconciler, sessionId]);
|
|
3408
|
-
const scheduleRefresh = useDebouncedCallback(() => void load());
|
|
3409
|
-
useSessionEventTrigger(
|
|
3410
|
-
client,
|
|
3411
|
-
workspaceId,
|
|
3412
|
-
sessionId,
|
|
3413
|
-
isTurnQueueEvent,
|
|
3414
|
-
scheduleRefresh,
|
|
3415
|
-
{
|
|
3416
|
-
enabled,
|
|
3417
|
-
...options.events !== void 0 ? { events: options.events } : {}
|
|
3418
|
-
},
|
|
3419
|
-
async () => await load(true)
|
|
3420
|
-
);
|
|
3421
|
-
const mutate = useCallback3(
|
|
3422
|
-
async (turnId, kind, command) => {
|
|
3423
|
-
const ownedTargetKey = targetKey;
|
|
3424
|
-
if (!sessionId || targetKeyRef.current !== ownedTargetKey || pendingRef.current[turnId]) {
|
|
3425
|
-
return null;
|
|
3426
|
-
}
|
|
3427
|
-
const current = snapshotRef.current;
|
|
3428
|
-
const turn = current?.items.find((candidate) => candidate.id === turnId);
|
|
3429
|
-
if (!current || !turn) return null;
|
|
3430
|
-
pendingRef.current = { ...pendingRef.current, [turnId]: kind };
|
|
3431
|
-
setStateTargetKey(ownedTargetKey);
|
|
3432
|
-
setPendingByTurn(pendingRef.current);
|
|
3433
|
-
setMutationError(null);
|
|
3434
|
-
const clientEventId = operationKey();
|
|
3435
|
-
try {
|
|
3436
|
-
let result;
|
|
3437
|
-
try {
|
|
3438
|
-
result = await command(current, turn, clientEventId);
|
|
3439
|
-
} catch (cause) {
|
|
3440
|
-
if (!isOutcomeUnknownError(cause)) throw cause;
|
|
3441
|
-
result = await command(current, turn, clientEventId);
|
|
3442
|
-
}
|
|
3443
|
-
if (targetKeyRef.current !== ownedTargetKey) return null;
|
|
3444
|
-
acceptSnapshot(ownedTargetKey, result.snapshot);
|
|
3445
|
-
return result;
|
|
3446
|
-
} catch (cause) {
|
|
3447
|
-
if (targetKeyRef.current === ownedTargetKey) {
|
|
3448
|
-
setMutationError(asError(cause));
|
|
3449
|
-
await load();
|
|
3450
|
-
}
|
|
3451
|
-
return null;
|
|
3452
|
-
} finally {
|
|
3453
|
-
if (targetKeyRef.current === ownedTargetKey && turnId in pendingRef.current) {
|
|
3454
|
-
const next = { ...pendingRef.current };
|
|
3455
|
-
delete next[turnId];
|
|
3456
|
-
pendingRef.current = next;
|
|
3457
|
-
setPendingByTurn(next);
|
|
3458
|
-
}
|
|
3459
|
-
}
|
|
3460
|
-
},
|
|
3461
|
-
[acceptSnapshot, load, sessionId, targetKey]
|
|
3462
|
-
);
|
|
3463
|
-
const moveTurn = useCallback3(
|
|
3464
|
-
async (turnId, beforeTurnId) => {
|
|
3465
|
-
const result = await mutate(
|
|
3466
|
-
turnId,
|
|
3467
|
-
"move",
|
|
3468
|
-
(current, _turn, clientEventId) => client.moveQueueItem(workspaceId, sessionId, turnId, {
|
|
3469
|
-
clientEventId,
|
|
3470
|
-
expectedQueueVersion: current.version,
|
|
3471
|
-
beforeTurnId
|
|
3472
|
-
})
|
|
3473
|
-
);
|
|
3474
|
-
return result !== null;
|
|
3475
|
-
},
|
|
3476
|
-
[client, mutate, sessionId, workspaceId]
|
|
3477
|
-
);
|
|
3478
|
-
const editTurn = useCallback3(
|
|
3479
|
-
async (turnId, edit) => {
|
|
3480
|
-
const result = await mutate(
|
|
3481
|
-
turnId,
|
|
3482
|
-
"edit",
|
|
3483
|
-
(_current, turn, clientEventId) => client.editQueueItem(workspaceId, sessionId, turnId, {
|
|
3484
|
-
clientEventId,
|
|
3485
|
-
expectedTurnVersion: turn.version,
|
|
3486
|
-
expectedDraftRevision: edit.expectedDraftRevision,
|
|
3487
|
-
replaceDraft: edit.replaceDraft
|
|
3488
|
-
})
|
|
3489
|
-
);
|
|
3490
|
-
return result?.draft ?? null;
|
|
3491
|
-
},
|
|
3492
|
-
[client, mutate, sessionId, workspaceId]
|
|
3493
|
-
);
|
|
3494
|
-
const steerTurn = useCallback3(
|
|
3495
|
-
async (turnId) => {
|
|
3496
|
-
const ownedTargetKey = targetKey;
|
|
3497
|
-
const turn = snapshotRef.current?.items.find((candidate) => candidate.id === turnId);
|
|
3498
|
-
if (targetKeyRef.current !== ownedTargetKey) return false;
|
|
3499
|
-
if (!turn) {
|
|
3500
|
-
setMutationError(new Error("That queued prompt changed before Steer could be sent."));
|
|
3501
|
-
await load();
|
|
3502
|
-
return false;
|
|
3503
|
-
}
|
|
3504
|
-
const optimistic = {
|
|
3505
|
-
turnId: turn.id,
|
|
3506
|
-
triggerEventId: turn.triggerEventId,
|
|
3507
|
-
text: turn.prompt,
|
|
3508
|
-
annotations: turn.annotations ?? [],
|
|
3509
|
-
resources: turn.resources,
|
|
3510
|
-
tools: turn.tools,
|
|
3511
|
-
occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3512
|
-
state: "sending"
|
|
3513
|
-
};
|
|
3514
|
-
setAcceptedSteers((current) => [
|
|
3515
|
-
...current.filter((steer) => steer.turnId !== turnId),
|
|
3516
|
-
optimistic
|
|
3517
|
-
]);
|
|
3518
|
-
const result = await mutate(
|
|
3519
|
-
turnId,
|
|
3520
|
-
"steer",
|
|
3521
|
-
(current, queuedTurn, clientEventId) => client.steerQueueItem(workspaceId, sessionId, turnId, {
|
|
3522
|
-
clientEventId,
|
|
3523
|
-
expectedTurnVersion: queuedTurn.version,
|
|
3524
|
-
controlEtag: current.effectiveControl.controlEtag
|
|
3525
|
-
})
|
|
3526
|
-
);
|
|
3527
|
-
if (targetKeyRef.current !== ownedTargetKey) return false;
|
|
3528
|
-
const advancedWithoutSteer = result === null && snapshotRef.current !== null && !snapshotRef.current.items.some((candidate) => candidate.id === turnId);
|
|
3529
|
-
if (advancedWithoutSteer) {
|
|
3530
|
-
setMutationError(null);
|
|
3531
|
-
setAcceptedSteers((current) => current.filter((steer) => steer.turnId !== turnId));
|
|
3532
|
-
return true;
|
|
3533
|
-
}
|
|
3534
|
-
const accepted = result !== null || snapshotRef.current?.items.some(
|
|
3535
|
-
(candidate) => candidate.id === turnId && candidate.metadata.delivery === "steer"
|
|
3536
|
-
) === true;
|
|
3537
|
-
setAcceptedSteers(
|
|
3538
|
-
(current) => accepted ? current.map(
|
|
3539
|
-
(steer) => steer.turnId === turnId ? { ...steer, state: "queued" } : steer
|
|
3540
|
-
) : current.filter((steer) => steer.turnId !== turnId)
|
|
3541
|
-
);
|
|
3542
|
-
return accepted;
|
|
3543
|
-
},
|
|
3544
|
-
[client, load, mutate, sessionId, targetKey, workspaceId]
|
|
3545
|
-
);
|
|
3546
|
-
const removeTurn = useCallback3(
|
|
3547
|
-
async (turnId) => {
|
|
3548
|
-
const result = await mutate(
|
|
3549
|
-
turnId,
|
|
3550
|
-
"delete",
|
|
3551
|
-
(_current, turn, clientEventId) => client.deleteQueueItem(workspaceId, sessionId, turnId, {
|
|
3552
|
-
clientEventId,
|
|
3553
|
-
expectedTurnVersion: turn.version,
|
|
3554
|
-
reason: "Deleted from the prompt queue"
|
|
3555
|
-
})
|
|
3556
|
-
);
|
|
3557
|
-
return result !== null;
|
|
3558
|
-
},
|
|
3559
|
-
[client, mutate, sessionId, workspaceId]
|
|
3560
|
-
);
|
|
3561
|
-
const identityMatches = stateTargetKey === targetKey;
|
|
3562
|
-
const visibleSnapshot = identityMatches ? snapshot : null;
|
|
3563
|
-
const visiblePendingByTurn = identityMatches ? pendingByTurn : EMPTY_PENDING_BY_TURN;
|
|
3564
|
-
const mutating = useMemo3(
|
|
3565
|
-
() => Object.keys(visiblePendingByTurn).length > 0,
|
|
3566
|
-
[visiblePendingByTurn]
|
|
3567
|
-
);
|
|
3568
|
-
const mutationFor = useCallback3(
|
|
3569
|
-
(turnId) => visiblePendingByTurn[turnId] ?? null,
|
|
3570
|
-
[visiblePendingByTurn]
|
|
3571
|
-
);
|
|
3572
|
-
return {
|
|
3573
|
-
snapshot: visibleSnapshot,
|
|
3574
|
-
queue: visibleSnapshot?.items ?? [],
|
|
3575
|
-
pendingInputs: visibleSnapshot?.pendingInputs ?? [],
|
|
3576
|
-
pendingInputAttachment: visibleSnapshot?.pendingInputAttachment ?? null,
|
|
3577
|
-
activePersonalConnections: visibleSnapshot?.activePersonalConnections ?? [],
|
|
3578
|
-
effectiveControl: visibleSnapshot?.effectiveControl ?? null,
|
|
3579
|
-
stoppingPreviousAttempt: visibleSnapshot?.stoppingPreviousAttempt ?? false,
|
|
3580
|
-
loading: identityMatches ? loading : enabled,
|
|
3581
|
-
error: identityMatches ? error : null,
|
|
3582
|
-
refresh: load,
|
|
3583
|
-
moveTurn,
|
|
3584
|
-
editTurn,
|
|
3585
|
-
steerTurn,
|
|
3586
|
-
removeTurn,
|
|
3587
|
-
pendingByTurn: visiblePendingByTurn,
|
|
3588
|
-
mutationFor,
|
|
3589
|
-
mutating,
|
|
3590
|
-
mutationError: identityMatches ? mutationError : null,
|
|
3591
|
-
clearMutationError: useCallback3(() => {
|
|
3592
|
-
if (targetKeyRef.current === targetKey) setMutationError(null);
|
|
3593
|
-
}, [targetKey]),
|
|
3594
|
-
acceptedSteers: identityMatches ? acceptedSteers : []
|
|
3595
|
-
};
|
|
3596
|
-
}
|
|
3597
|
-
function operationKey() {
|
|
3598
|
-
return globalThis.crypto.randomUUID();
|
|
3599
|
-
}
|
|
3600
|
-
function asError(cause) {
|
|
3601
|
-
return cause instanceof Error ? cause : new Error(String(cause));
|
|
3602
|
-
}
|
|
3603
|
-
function isOutcomeUnknownError(cause) {
|
|
3604
|
-
return typeof cause === "object" && cause !== null && cause.outcomeUnknown === true;
|
|
3605
|
-
}
|
|
3606
|
-
|
|
3607
|
-
// src/hooks/use-human-input.ts
|
|
3608
|
-
import { useCallback as useCallback4, useEffect as useEffect4, useRef as useRef4, useState as useState4 } from "react";
|
|
3609
|
-
function isHumanInputEvent(event) {
|
|
3610
|
-
return event.type === "session.humanInput.requested" || event.type === "user.humanInputResponse" || event.type === "turn.completed" || event.type === "turn.failed" || event.type === "turn.cancelled";
|
|
3611
|
-
}
|
|
3612
|
-
function useHumanInputRequests(sessionId, options = {}) {
|
|
3613
|
-
const { client, workspaceId, registerSessionReconciler } = useEmbeddedHumanInputSession(options);
|
|
3614
|
-
const enabled = (options.enabled ?? true) && Boolean(sessionId);
|
|
3615
|
-
const load = useCallback4(
|
|
3616
|
-
async () => sessionId ? await client.listHumanInputRequests(workspaceId, sessionId, { status: "pending" }) : [],
|
|
3617
|
-
[client, sessionId, workspaceId]
|
|
3618
|
-
);
|
|
3619
|
-
const state = usePolledValue(load, {
|
|
3620
|
-
enabled,
|
|
3621
|
-
pollIntervalMs: options.pollIntervalMs
|
|
3622
|
-
});
|
|
3623
|
-
const loadedRequests = state.data;
|
|
3624
|
-
const refreshRequests = state.refresh;
|
|
3625
|
-
const mutation = useMutationRunner(`${workspaceId}\0${sessionId ?? ""}`);
|
|
3626
|
-
const [respondingRequestId, setRespondingRequestId] = useState4(null);
|
|
3627
|
-
const [deadlineVersion, setDeadlineVersion] = useState4(0);
|
|
3628
|
-
const respondingRequestRef = useRef4(null);
|
|
3629
|
-
useEffect4(() => {
|
|
3630
|
-
respondingRequestRef.current = null;
|
|
3631
|
-
setRespondingRequestId(null);
|
|
3632
|
-
}, [sessionId, workspaceId]);
|
|
3633
|
-
useEffect4(() => {
|
|
3634
|
-
if (!sessionId || !enabled) return;
|
|
3635
|
-
return registerSessionReconciler(sessionId, "human-input", state.refresh);
|
|
3636
|
-
}, [enabled, registerSessionReconciler, sessionId, state.refresh]);
|
|
3637
|
-
const scheduleRefresh = useDebouncedCallback(() => void state.refresh());
|
|
3638
|
-
useSessionEventTrigger(client, workspaceId, sessionId, isHumanInputEvent, scheduleRefresh, {
|
|
3639
|
-
enabled,
|
|
3640
|
-
...options.events !== void 0 ? { events: options.events } : {}
|
|
3641
|
-
});
|
|
3642
|
-
useEffect4(() => {
|
|
3643
|
-
const now2 = Date.now();
|
|
3644
|
-
const nextDeadline = (loadedRequests ?? []).reduce((next, request) => {
|
|
3645
|
-
if (request.status !== "pending" || !request.expiresAt) return next;
|
|
3646
|
-
const deadline = Date.parse(request.expiresAt);
|
|
3647
|
-
if (!Number.isFinite(deadline) || deadline <= now2) return next;
|
|
3648
|
-
return next === null ? deadline : Math.min(next, deadline);
|
|
3649
|
-
}, null);
|
|
3650
|
-
if (nextDeadline === null) return;
|
|
3651
|
-
const timer = globalThis.setTimeout(
|
|
3652
|
-
() => {
|
|
3653
|
-
setDeadlineVersion((current) => current + 1);
|
|
3654
|
-
void refreshRequests();
|
|
3655
|
-
},
|
|
3656
|
-
Math.min(2147483647, Math.max(0, nextDeadline - now2 + 1))
|
|
3657
|
-
);
|
|
3658
|
-
return () => globalThis.clearTimeout(timer);
|
|
3659
|
-
}, [loadedRequests, refreshRequests]);
|
|
3660
|
-
const respond = useCallback4(
|
|
3661
|
-
async (requestId, response) => {
|
|
3662
|
-
if (!sessionId || respondingRequestRef.current !== null) return null;
|
|
3663
|
-
respondingRequestRef.current = requestId;
|
|
3664
|
-
setRespondingRequestId(requestId);
|
|
3665
|
-
try {
|
|
3666
|
-
const event = await mutation.run(
|
|
3667
|
-
() => client.submitHumanInputResponse(workspaceId, sessionId, requestId, response, {
|
|
3668
|
-
clientEventId: globalThis.crypto.randomUUID()
|
|
3669
|
-
})
|
|
3670
|
-
);
|
|
3671
|
-
if (event) await state.refresh();
|
|
3672
|
-
return event;
|
|
3673
|
-
} finally {
|
|
3674
|
-
if (respondingRequestRef.current === requestId) {
|
|
3675
|
-
respondingRequestRef.current = null;
|
|
3676
|
-
setRespondingRequestId(null);
|
|
3677
|
-
}
|
|
3678
|
-
}
|
|
3679
|
-
},
|
|
3680
|
-
[client, mutation, sessionId, state, workspaceId]
|
|
3681
|
-
);
|
|
3682
|
-
const now = Date.now();
|
|
3683
|
-
void deadlineVersion;
|
|
3684
|
-
return {
|
|
3685
|
-
requests: [...state.data ?? []].filter((request) => isActionableHumanInputRequest(request, now)).sort(
|
|
3686
|
-
(left, right) => left.createdAt.localeCompare(right.createdAt) || left.id.localeCompare(right.id)
|
|
3687
|
-
),
|
|
3688
|
-
loading: state.loading,
|
|
3689
|
-
error: state.error,
|
|
3690
|
-
refresh: state.refresh,
|
|
3691
|
-
respond,
|
|
3692
|
-
respondingRequestId,
|
|
3693
|
-
mutationError: mutation.mutationError,
|
|
3694
|
-
clearMutationError: mutation.clearMutationError
|
|
3695
|
-
};
|
|
3696
|
-
}
|
|
3697
|
-
|
|
3698
3110
|
export {
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3111
|
+
compactionSkipTitle,
|
|
3112
|
+
compactionSkipSubtitle,
|
|
3113
|
+
compactionFailureDetails,
|
|
3114
|
+
presentTurnFailureText,
|
|
3115
|
+
learningRefusalTitle,
|
|
3116
|
+
learningRefusalBody,
|
|
3117
|
+
learningRefusalPlace,
|
|
3118
|
+
learningRefusalPlaceLabel,
|
|
3119
|
+
isTimelineUserQuestion,
|
|
3706
3120
|
buildTimeline,
|
|
3707
3121
|
creditExhaustedFromEvents,
|
|
3708
3122
|
sessionStatusFromEvents,
|
|
3709
3123
|
groupTimeline,
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
SESSION_EVENT_BROWSER_PENDING_MAX_BYTES,
|
|
3714
|
-
SESSION_EVENT_BROWSER_PENDING_MAX_COUNT,
|
|
3715
|
-
useSessionEvents,
|
|
3716
|
-
boundBrowserSessionEventWindow,
|
|
3717
|
-
isTitleEvent,
|
|
3718
|
-
useSession,
|
|
3719
|
-
isTurnQueueEvent,
|
|
3720
|
-
useTurnQueue,
|
|
3721
|
-
isHumanInputEvent,
|
|
3722
|
-
useHumanInputRequests
|
|
3124
|
+
timelineQuestionPlacement,
|
|
3125
|
+
isTurnExecutionEvidence,
|
|
3126
|
+
extractSessionRef
|
|
3723
3127
|
};
|
|
3724
|
-
//# sourceMappingURL=chunk-
|
|
3128
|
+
//# sourceMappingURL=chunk-QYUYVSNG.js.map
|