@xopcai/xopc 0.0.474 → 0.0.476
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/server/chunks.bin +1103 -1067
- package/dist/gateway/server/chunks.json +1 -1
- package/dist/gateway/server/schema.sql +13 -0
- package/dist/gateway/server/upgrades/281_session_agent_reactions.sql +13 -0
- package/dist/gateway/static/root/assets/{activity-store-nD2NH0C7.js → activity-store-BK11iD5x.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-D0JEEj2L.js → agent-avatar-dicebear-DZlgZHm9.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-display-BxHA8hEW.js → agent-avatar-display-BDHjRaTK.js} +2 -2
- package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-C7O0Aaq3.js → agent-defaults-settings-panel-Bicuh10_.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-plugin-dialog--H7-gWL7.js → agent-plugin-dialog-hRZYhcLp.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-CIcUUuaE.js → agents-C2DH8M4z.js} +3 -3
- package/dist/gateway/static/root/assets/{agents-admin-api-DyeFg0yq.js → agents-admin-api-_mp_Ew1u.js} +1 -1
- package/dist/gateway/static/root/assets/{api-DAWXH9Wf.js → api-D0r-2gWQ.js} +1 -1
- package/dist/gateway/static/root/assets/{api-LSz0L9gc.js → api-oA0NOKLI.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-CjXfqaEA.js → app-management-settings-panel-BrO0gY6b.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-0Zl5M7iV.js → appearance-settings-h82Or0g-.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-DDVJnHlm.js → apps-page-B9Ho8S53.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-CMqJbzQ-.js → archive-plugin-Co_oRPj1.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-api-DHGtNfOT.js → automation-api-CxLFngqe.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-result-state-DUBlVnPg.js → automation-result-state-CjiuyW-C.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-run-list-CuWKRWy0.js → automation-run-list-CLjSIujK.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-task-card-Y4vC_7qq.js → automation-task-card-BS-RT312.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-DBQyHgFW.js → automations-page-BL6ASYrU.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-workspace-DRCt4lq0.js → automations-workspace-BFk-AF43.js} +2 -2
- package/dist/gateway/static/root/assets/{binary-plugins-CMKEp-IB.js → binary-plugins-5GVlyrXg.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-CQwjLxA9.js → block-editor-Dtz8JtrO.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-BA0i0h3v.js → browser-settings-page-CDUHHu0n.js} +1 -1
- package/dist/gateway/static/root/assets/capabilities-Clwtvm7F.js +1 -0
- package/dist/gateway/static/root/assets/{capabilities--EoyYsa8.js → capabilities-DFRrPT_I.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-page-B5Ja0Knr.js → capabilities-page-D9EpUcuB.js} +2 -2
- package/dist/gateway/static/root/assets/{capabilities-settings-panel-C5WmcgqD.js → capabilities-settings-panel-ComYXaP1.js} +2 -2
- package/dist/gateway/static/root/assets/{channels-BQPomrMC.js → channels-Aa2Iun4r.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-agents-api-DI0TksSO.js → chat-agents-api-B-47bqbd.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-chart-block-CNm3uFNf.js → chat-chart-block-DA2S21y2.js} +1 -1
- package/dist/gateway/static/root/assets/chat-page-BbahuZ59.js +72 -0
- package/dist/gateway/static/root/assets/{chat-terminal-dock-D1DkoN9Y.js → chat-terminal-dock-BALrP7_l.js} +1 -1
- package/dist/gateway/static/root/assets/{chunk-KS7C4IRE-CiwuuyV8.js → chunk-KS7C4IRE-BPb7KheU.js} +2 -2
- package/dist/gateway/static/root/assets/{command-palette-api-DZt3IZKz.js → command-palette-api-BbSsGD48.js} +1 -1
- package/dist/gateway/static/root/assets/{composer-model-config-control-_doimXGR.js → composer-model-config-control-BFC8jNyK.js} +1 -1
- package/dist/gateway/static/root/assets/{composer-notifications-BE40dFxM.js → composer-notifications-Drbl5lKS.js} +1 -1
- package/dist/gateway/static/root/assets/{composer-payload-handoff-DMWTIrnl.js → composer-payload-handoff-DKLokix8.js} +1 -1
- package/dist/gateway/static/root/assets/{computer-settings-page-DJiToD0s.js → computer-settings-page-CVWaJ3L8.js} +1 -1
- package/dist/gateway/static/root/assets/{connected-providers-grid-CYWTW8cv.js → connected-providers-grid-NZP4qb6S.js} +1 -1
- package/dist/gateway/static/root/assets/{connection-usage-guide-QgwPzjZb.js → connection-usage-guide-BNoFtMol.js} +1 -1
- package/dist/gateway/static/root/assets/{connector-service-page-DkQsU_yu.js → connector-service-page-CzrdJ4JY.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-api-Bqac6cVg.js → connectors-api-KA6rkOJX.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-DSCQw53B.js → connectors-page-BUqNvStL.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-B0J_jDfr.js → date-picker-DgTDENzF.js} +1 -1
- package/dist/gateway/static/root/assets/{date-time-picker-Zr3u7nL1.js → date-time-picker-Gw4oSOk9.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-CLD0xbpi.js → dependency-picker-BJDpQtKY.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-CfQHdCjf.js → desktop-pet-BbIPYbvc.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-wlYidCpI.js → desktop-pet-settings-Cqzplufb.js} +1 -1
- package/dist/gateway/static/root/assets/{dev-view-store-DM2X7oYZ.js → dev-view-store-CXE5-Egp.js} +1 -1
- package/dist/gateway/static/root/assets/{device-pairing-wizard-DIjBN08k.js → device-pairing-wizard-DXFZiWMi.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-BJj6gT1z.js → directory-picker-path-field-DVFEzTAJ.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-authoritative-grants-DC9q_s91.js → extension-authoritative-grants-DAfeCx4B.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-DBLJqOJ2.js → extension-debug-page-gW4GEEcj.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-iframe-host-DCdjl257.js → extension-iframe-host-DOPywUKI.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-marketplace-api-BEulqVpr.js → extension-marketplace-api-Bo_chffY.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-message-router-DhEyQZWI.js → extension-message-router-TTAx3dPv.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-BpY2ZrxI.js → extension-page-Iq7vFC-g.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-provider-YdavG8wv.js → extension-provider-BNnLkq95.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-BKvG-hJa.js → extension-settings-page-C0oLjaz6.js} +1 -1
- package/dist/gateway/static/root/assets/{file-preview-surface-D71-xhLL.js → file-preview-surface-BSrIpn5C.js} +1 -1
- package/dist/gateway/static/root/assets/files-GdwDamkp.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-config-swr-C-cx4ObA.js → gateway-config-swr-2VOPSLSq.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-realtime-Dh23j5Jx.js → gateway-realtime-CfceJ5WX.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-Ca42Wsk6.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-restart-F1q8XY7Y.js → gateway-restart-Dsg95Dwt.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-WQ42gfHY.js → gateway-settings-CMgry8RK.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-Dx1dmgnX.js → gateway-startup-retry-D0i7dt51.js} +1 -1
- package/dist/gateway/static/root/assets/{global-defaults-api-C_Sn41rn.js → global-defaults-api-u-ado9kz.js} +1 -1
- package/dist/gateway/static/root/assets/{home-page-A3VCyEO8.js → home-page-pT-lEQsu.js} +4 -4
- package/dist/gateway/static/root/assets/{image-generation-api-CvRiMNIJ.js → image-generation-api-DDHOD0Nx.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-DJ2wJ2QG.js → imports-page-BxRXNvQx.js} +1 -1
- package/dist/gateway/static/root/assets/index-BtHMU5k4.css +1 -0
- package/dist/gateway/static/root/assets/index-DdEh8KeB.js +11 -0
- package/dist/gateway/static/root/assets/{install-connector-dialog-CyHz1Nys.js → install-connector-dialog-Rox2_5eU.js} +1 -1
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-Byb_rqj4.js → keyboard-shortcuts-settings-D7xlV7xT.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-D58zzTUZ.js → local-app-workbench-page-ReBczGac.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-L6ODN66C.js → local-apps-page-Ct07GT0V.js} +1 -1
- package/dist/gateway/static/root/assets/{local-session-drafts-UN3vioSr.js → local-session-drafts-8PozABVy.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-CnHhWsDP.js → locale-store-B4o4aDCg.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-2rOEUxHs.js → logs-page-CtEv5J4C.js} +1 -1
- package/dist/gateway/static/root/assets/{management-api-CSkXaCjk.js → management-api-BBLUlEXt.js} +1 -1
- package/dist/gateway/static/root/assets/{management-settings-B1Enr-fL.js → management-settings-BjvQ4WiZ.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-CWhAtI1O.js → markdown-view-C7kqotD-.js} +1 -1
- package/dist/gateway/static/root/assets/mcp-conversation-setup-page-DfbMmlmC.js +1 -0
- package/dist/gateway/static/root/assets/{media-plugins-DVrn3x6D.js → media-plugins-B5XMcW5S.js} +1 -1
- package/dist/gateway/static/root/assets/{messages-CZCXd6Pj.js → messages-hlOsXkQ7.js} +2 -2
- package/dist/gateway/static/root/assets/{model-selector-D-9SUwg2.js → model-selector-BP-t33vd.js} +1 -1
- package/dist/gateway/static/root/assets/{models-hub-cache-qgre89p2.js → models-hub-cache-B0z5Ptmt.js} +1 -1
- package/dist/gateway/static/root/assets/{new-chat-navigation-DXYDldT_.js → new-chat-navigation-BA1IB3hy.js} +1 -1
- package/dist/gateway/static/root/assets/{note-detail-panel-4Pd0mAhL.js → note-detail-panel-DAhIT6xP.js} +3 -3
- package/dist/gateway/static/root/assets/note-image-lightbox-DrVGs1eQ.js +1 -0
- package/dist/gateway/static/root/assets/{notes-api-_jYkMe8e.js → notes-api-B3Kc4909.js} +1 -1
- package/dist/gateway/static/root/assets/notes-page-zAJJ2OiQ.js +8 -0
- package/dist/gateway/static/root/assets/{oauth-api-CaWkle-J.js → oauth-api-CW1XhW42.js} +1 -1
- package/dist/gateway/static/root/assets/{oauth-provider-connect-DTsztbWi.js → oauth-provider-connect-3QGibJMl.js} +1 -1
- package/dist/gateway/static/root/assets/{page-context-capture-button-CYMb3IZu.js → page-context-capture-button-Bd__UBi9.js} +1 -1
- package/dist/gateway/static/root/assets/{page-context-draft-D441lgCD.js → page-context-draft-DpDsGHtl.js} +1 -1
- package/dist/gateway/static/root/assets/{page-header-store-7jhoVGK_.js → page-header-store-D_2QZ6Ps.js} +1 -1
- package/dist/gateway/static/root/assets/page-tabs-DoYMKhVO.js +1 -0
- package/dist/gateway/static/root/assets/{personal-avatar-CAATciod.js → personal-avatar-D5VUVQGE.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-page-DCcipmsB.js → personal-page-DHik8uj6.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-profile-settings-CZhQ4fwt.js → personal-profile-settings-Cd2xUVbw.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-settings-panel-CMaFnp1G.js → personal-settings-panel-CHRra9hc.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-dependencies-card-BlFgKeRz.js → phone-dependencies-card-CREmmRxI.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-model-connection-DF_E69Sv.js → phone-model-connection-BDzr9jXL.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-model-picker-D3O3vql4.js → phone-model-picker-DSQF-RxW.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-settings-page-d2OEqR-2.js → phone-settings-page-gP5kr3VO.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-workspace-store-BrXIdz55.js → phone-workspace-store-B0mF8oMk.js} +1 -1
- package/dist/gateway/static/root/assets/{plugin-details-dialog-tpugwKl1.js → plugin-details-dialog-43jCnG5n.js} +1 -1
- package/dist/gateway/static/root/assets/{preference-select-fields-DXMfKUtD.js → preference-select-fields-VqtR_pOy.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-runtime-Bd9e2ent.js → preview-runtime-MJUo7XlD.js} +3 -3
- package/dist/gateway/static/root/assets/{product-automation-feedback-DmdIebRg.js → product-automation-feedback-D43XiQq6.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-DnPJLzt7.js → product-open-page-CQMoDCO1.js} +1 -1
- package/dist/gateway/static/root/assets/{product-preview-content-hChoKYQM.js → product-preview-content-CkQebfi-.js} +1 -1
- package/dist/gateway/static/root/assets/{product-preview-modal-CwAjfaEd.js → product-preview-modal-DToUA1EF.js} +2 -2
- package/dist/gateway/static/root/assets/{project-detail-page-BYZdStns.js → project-detail-page-BBF8eVJa.js} +2 -2
- package/dist/gateway/static/root/assets/{project-understanding-CeZ3CW6E.js → project-understanding-BScfv1pD.js} +1 -1
- package/dist/gateway/static/root/assets/{projects-page-BpARg2mt.js → projects-page-BCMWrLGf.js} +1 -1
- package/dist/gateway/static/root/assets/{providers-api-DjHMmSNk.js → providers-api-BIA2IARN.js} +1 -1
- package/dist/gateway/static/root/assets/{recording-upload-CxcMaBPr.js → recording-upload-Yy9r6kHe.js} +1 -1
- package/dist/gateway/static/root/assets/{registry-api-x3kjVVzC.js → registry-api-CmLu4MA9.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-Cuyfg5gz.js → remote-access-hub-BeG8Bgy0.js} +1 -1
- package/dist/gateway/static/root/assets/{resource-unavailable-ClTyW1KO.js → resource-unavailable-Dccp_uis.js} +1 -1
- package/dist/gateway/static/root/assets/{right-workspace-store-BgVMF75g.js → right-workspace-store-CFf15f36.js} +1 -1
- package/dist/gateway/static/root/assets/{route-preload-BPMOD0qt.js → route-preload-Bl10PwKS.js} +2 -2
- package/dist/gateway/static/root/assets/{routine-panel-DqCzH4o9.js → routine-panel-BjqenuXU.js} +2 -2
- package/dist/gateway/static/root/assets/{runtime-tools-api-ZKJq8Y1c.js → runtime-tools-api-CFvov9Uy.js} +1 -1
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-CSVS-0w1.js → runtime-tools-settings-panel-C7sHr-Lm.js} +1 -1
- package/dist/gateway/static/root/assets/{service-recommendation-list-Jbg55MsH.js → service-recommendation-list-Bz9QWUZc.js} +1 -1
- package/dist/gateway/static/root/assets/{session-api-JAcSuzXh.js → session-api-7-TPnKv0.js} +1 -1
- package/dist/gateway/static/root/assets/{session-manager-CvC5uo-A.js → session-manager-fvJusKsK.js} +2 -2
- package/dist/gateway/static/root/assets/{sessions-page-itpuSflW.js → sessions-page-DS-OExY1.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-DHfrm0Zj.js +1 -0
- package/dist/gateway/static/root/assets/{settings-advanced-section-C-Rq-g2w.js → settings-advanced-section-BsqgVQL3.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-mode-store-DWWvnHvd.js → settings-mode-store-BtwrUOdQ.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-DppkfISC.js → settings-page-B_8kxJQW.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-header-BnBbewrE.js → settings-page-header-DKgbD0Bc.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-DgRq0a-W.js → settings-page-layout-BE3vLWp_.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-interaction-page-_UOcgWMs.js → setup-interaction-page-DLpGv0yp.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-fXdj1EOR.js → setup-status-panel-BMaFUPnt.js} +1 -1
- package/dist/gateway/static/root/assets/{share-link-dialog-BUzVn5kX.js → share-link-dialog-3RNzFIH3.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-CIdxsC9i.js → share-preview-page-C49EIXte.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-api-DNlL_AwP.js → shares-api-B532SLIU.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-R2H0pdNK.js → shares-settings-C_ITdQqP.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-api-D3iuvyp7.js → skill-api-x-ENFv-9.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-list-api-K8n_AYMV.js → skill-list-api-CqmglPCz.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-reload-api-BqxHK3K0.js → skill-reload-api-YeoxO91w.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-BHciTWaw.js → skills-page-B30SsJL6.js} +1 -1
- package/dist/gateway/static/root/assets/space-page-DmvjU1jc.js +2 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-BPyQzKf8.js → system-settings-panel-KXLPpyOW.js} +1 -1
- package/dist/gateway/static/root/assets/{task-detail-page-By5vozgo.js → task-detail-page-DHYm_bsg.js} +3 -3
- package/dist/gateway/static/root/assets/{task-header-title-lUJ0ls3u.js → task-header-title-Buwr7WTV.js} +1 -1
- package/dist/gateway/static/root/assets/{task-result-evidence-CWpAUoNq.js → task-result-evidence-DpV1mZJA.js} +1 -1
- package/dist/gateway/static/root/assets/{terminal-panel-store-D24y7GIK.js → terminal-panel-store-Ch8lOYIq.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-VVHRSdNZ.js → theme-store-C7t81hG7.js} +1 -1
- package/dist/gateway/static/root/assets/{tracing-settings-page-D3tu_G8X.js → tracing-settings-page-CcyPoojp.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-DwTTVUxp.js → tunnel-api-D713CJ9R.js} +1 -1
- package/dist/gateway/static/root/assets/{understanding-activity-store-BOIGCSnz.js → understanding-activity-store-mSawFpIz.js} +1 -1
- package/dist/gateway/static/root/assets/{understanding-refresh-store-mKqdZVjW.js → understanding-refresh-store-4M0xrc88.js} +1 -1
- package/dist/gateway/static/root/assets/{usage-page-B4MqbLKR.js → usage-page-DN1TcxWS.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-BcgfZd3f.js → use-autosave-BkVX6SyB.js} +1 -1
- package/dist/gateway/static/root/assets/{use-composer-attachments-Ca1eE6iV.js → use-composer-attachments-4FKbf6PB.js} +1 -1
- package/dist/gateway/static/root/assets/{use-file-preview-expanded-BwB7VH_A.js → use-file-preview-expanded-CRBn6UTd.js} +1 -1
- package/dist/gateway/static/root/assets/use-generated-media-CEJ5BBxX.js +1 -0
- package/dist/gateway/static/root/assets/{use-personal-profile-BDLuMaWC.js → use-personal-profile-DdjQjf9I.js} +1 -1
- package/dist/gateway/static/root/assets/{use-personal-work-Dfbs6S75.js → use-personal-work-srLCZOam.js} +1 -1
- package/dist/gateway/static/root/assets/{use-realtime-voice-BrM12ktL.js → use-realtime-voice-tyo85cre.js} +1 -1
- package/dist/gateway/static/root/assets/{use-workspace-tree-AL4BVZhS.js → use-workspace-tree-VwHdfiR8.js} +1 -1
- package/dist/gateway/static/root/assets/{user-model-page-CqTB0BIf.js → user-model-page-D-F5GO3T.js} +2 -2
- package/dist/gateway/static/root/assets/{voice-api-key-field-BbVCvQrE.js → voice-api-key-field-gWJ6bx-H.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-vtmTs-mq.js → voice-config-api-B1RtxiRq.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-input-shortcut-events-BhmaEWvI.js → voice-input-shortcut-events-C-8Ts1gq.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-player-store-IVeW1g9y.js → voice-player-store-DyuAAbk0.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-settings-JJfxv-lj.js → voice-settings-DOajN2ay.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-Bl2qHC88.js → work-discovery-overlay-CTLp1-tu.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-page-ChvUHm0f.js → work-discovery-page-B-UzFKIr.js} +1 -1
- package/dist/gateway/static/root/assets/{working-directory-picker-modal-BxeoaS6d.js → working-directory-picker-modal-DvVtUxHW.js} +1 -1
- package/dist/gateway/static/root/assets/{workspace-api-D_dxOn8W.js → workspace-api-CIfedJeG.js} +2 -2
- package/dist/gateway/static/root/assets/workspace-editor-agent-store-Bh4FYwVq.js +1 -0
- package/dist/gateway/static/root/assets/{workspace-file-preview-dialog-D0GxWvAv.js → workspace-file-preview-dialog-Xi5feqPq.js} +1 -1
- package/dist/gateway/static/root/assets/{workspace-open-location-menu-CCJISdeq.js → workspace-open-location-menu-sbOva_RI.js} +1 -1
- package/dist/gateway/static/root/assets/{workspace-preview-store-DKZ6gVL4.js → workspace-preview-store-DYd8E5bV.js} +1 -1
- package/dist/gateway/static/root/assets/{xopc-cloud-account-card-Cxt6wEom.js → xopc-cloud-account-card-BYuMOGaK.js} +1 -1
- package/dist/gateway/static/root/index.html +96 -96
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/files.js +17 -3
- package/dist/packages/gateway-contract/src/home.js +1 -0
- package/dist/src/agent/agent-manager.d.ts +1 -0
- package/dist/src/agent/agent-manager.js +2 -1
- package/dist/src/agent/commands/command-registry.d.ts +1 -1
- package/dist/src/agent/commands/command-registry.js +10 -1
- package/dist/src/agent/embedded/index.js +1 -1
- package/dist/src/agent/embedded/run-for-session.js +1 -1
- package/dist/src/agent/embedded/run-turn.js +3 -2
- package/dist/src/agent/embedded/runs.d.ts +3 -0
- package/dist/src/agent/embedded/runs.js +20 -2
- package/dist/src/agent/embedded/tool-search-extension.js +2 -0
- package/dist/src/agent/embedded/xopc-tools-bridge.js +1 -1
- package/dist/src/agent/external-tools/discovery.js +1 -1
- package/dist/src/agent/external-tools/endpoint-provider.js +1 -1
- package/dist/src/agent/mcp/continuation-guard.js +1 -1
- package/dist/src/agent/mcp/conversation-setup.d.ts +221 -4
- package/dist/src/agent/mcp/conversation-setup.js +66 -27
- package/dist/src/agent/mcp/discovery.d.ts +5 -0
- package/dist/src/agent/mcp/discovery.js +47 -6
- package/dist/src/agent/prompt/conversational-configuration-guide.js +3 -2
- package/dist/src/agent/prompt/sections/tooling.js +1 -1
- package/dist/src/agent/service.js +1 -0
- package/dist/src/agent/service.types.d.ts +1 -0
- package/dist/src/agent/tool-manuals/browser.d.ts +1 -1
- package/dist/src/agent/tool-manuals/browser.js +3 -1
- package/dist/src/agent/tool-manuals/xopc-configuration.d.ts +2 -2
- package/dist/src/agent/tool-manuals/xopc-configuration.js +10 -9
- package/dist/src/agent/tools/browser/tool/browser-use-tool.js +1 -1
- package/dist/src/agent/tools/capability-catalog-tool.d.ts +10 -0
- package/dist/src/agent/tools/capability-catalog-tool.js +63 -0
- package/dist/src/agent/tools/exec-command.d.ts +1 -0
- package/dist/src/agent/tools/exec-command.js +11 -5
- package/dist/src/agent/tools/factory.d.ts +1 -0
- package/dist/src/agent/tools/factory.js +32 -1
- package/dist/src/agent/tools/language-diagnostics.js +4 -1
- package/dist/src/agent/tools/managed-job-tool.js +3 -2
- package/dist/src/agent/tools/mcp-setup-tool.js +2 -2
- package/dist/src/agent/tools/phone-use-tool.js +1 -1
- package/dist/src/agent/tools/xopc-use-tool.d.ts +2 -0
- package/dist/src/agent/tools/xopc-use-tool.js +5 -3
- package/dist/src/agent-config/schema.d.ts +3 -0
- package/dist/src/agent-config/schema.js +1 -0
- package/dist/src/automations/api/routes.js +17 -5
- package/dist/src/automations/capabilities/write.js +32 -4
- package/dist/src/automations/configuration-conversation.d.ts +7 -0
- package/dist/src/automations/configuration-conversation.js +13 -5
- package/dist/src/capabilities/capability-catalog.d.ts +47 -0
- package/dist/src/capabilities/capability-catalog.js +162 -0
- package/dist/src/capabilities/runtime/product.js +1 -1
- package/dist/src/capabilities/store-connector.d.ts +1 -0
- package/dist/src/capabilities/store-connector.js +6 -3
- package/dist/src/chat-commands/builtins/config.js +1 -1
- package/dist/src/chat-commands/context.js +1 -1
- package/dist/src/cli/commands/agent.js +1 -1
- package/dist/src/cli/commands/doctor/checks/channel-plugins.js +1 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +5 -5
- package/dist/src/cli/commands/extension-dev.js +1 -1
- package/dist/src/cli/commands/extension-marketplace.js +1 -1
- package/dist/src/cli/commands/extension.js +1 -1
- package/dist/src/cli/commands/onboard/channels/registry.js +1 -1
- package/dist/src/cli/commands/platform.js +2 -2
- package/dist/src/cli/commands/skills.js +1 -1
- package/dist/src/cli/extension-cli-register.js +1 -1
- package/dist/src/cli/utils/session.js +1 -1
- package/dist/src/config/index.js +1 -1
- package/dist/src/config/schema.d.ts +2 -0
- package/dist/src/config/schema.js +6 -3
- package/dist/src/extensions/index.js +2 -2
- package/dist/src/extensions/loader.js +1 -1
- package/dist/src/extensions/update.js +1 -1
- package/dist/src/files/file-service.js +1 -0
- package/dist/src/files/file-versions.d.ts +15 -0
- package/dist/src/files/file-versions.js +87 -0
- package/dist/src/gateway/agent-reactions/reaction.d.ts +27 -0
- package/dist/src/gateway/agent-reactions/reaction.js +186 -0
- package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
- package/dist/src/gateway/hono/routes/capabilities.js +27 -0
- package/dist/src/gateway/hono/routes/connectors.js +1 -1
- package/dist/src/gateway/hono/routes/files.js +39 -0
- package/dist/src/gateway/hono/routes/home.js +1 -1
- package/dist/src/gateway/hono/routes/mobile-capability-actions.d.ts +4 -0
- package/dist/src/gateway/hono/routes/mobile-capability-actions.js +290 -0
- package/dist/src/gateway/hono/routes/music-generation.js +1 -0
- package/dist/src/gateway/hono/routes/personal-agent.js +23 -43
- package/dist/src/gateway/hono/routes/sessions.js +41 -2
- package/dist/src/gateway/security/gateway-principal.d.ts +1 -0
- package/dist/src/gateway/security/gateway-principal.js +9 -1
- package/dist/src/gateway/security/gateway-scopes.js +3 -0
- package/dist/src/gateway/service/agent-runner.d.ts +2 -0
- package/dist/src/gateway/service/agent-runner.js +5 -1
- package/dist/src/gateway/service/config-coordinator.d.ts +1 -0
- package/dist/src/gateway/service/config-coordinator.js +1 -1
- package/dist/src/gateway/service/run-gateway-agent.d.ts +3 -0
- package/dist/src/gateway/service/run-gateway-agent.js +43 -1
- package/dist/src/gateway/service/task-conversation-query-service.d.ts +4 -0
- package/dist/src/gateway/service.js +20 -11
- package/dist/src/home-intelligence/host.js +5 -5
- package/dist/src/personal-agent/repository.d.ts +1 -0
- package/dist/src/personal-agent/repository.js +1 -0
- package/dist/src/personal-agent/schedules.d.ts +9 -1
- package/dist/src/personal-agent/schedules.js +32 -1
- package/dist/src/personal-agent/service.d.ts +2 -2
- package/dist/src/personal-agent/service.js +6 -3
- package/dist/src/projects/index.js +1 -1
- package/dist/src/providers/model-call.js +1 -0
- package/dist/src/realtime/runtime.js +1 -0
- package/dist/src/session/client-history.d.ts +1 -0
- package/dist/src/session/client-history.js +2 -0
- package/dist/src/session/types.d.ts +4 -0
- package/dist/src/storage/sqlite/agent-reaction-repository.d.ts +15 -0
- package/dist/src/storage/sqlite/agent-reaction-repository.js +73 -0
- package/dist/src/storage/sqlite/row-mappers.js +1 -1
- package/dist/src/storage/sqlite/schema.d.ts +2 -2
- package/dist/src/storage/sqlite/schema.js +7 -7
- package/dist/src/storage/sqlite/schema.sql +13 -0
- package/dist/src/storage/sqlite/upgrades/281_session_agent_reactions.sql +13 -0
- package/dist/src/tasks/home-query-service.js +1 -0
- package/dist/src/tui/backends/embedded-backend.js +5 -4
- package/dist/src/tui/extension-host/load-extensions.js +1 -1
- package/dist/src/tui/tui-commands.js +1 -1
- package/dist/src/tui/tui-management.js +1 -1
- package/dist/src/tui/tui.js +1 -1
- package/dist/src/usage/recorder.js +6 -2
- package/dist/src/usage/types.d.ts +1 -0
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/capabilities-DG-WesBp.js +0 -1
- package/dist/gateway/static/root/assets/chat-page-DO060oe9.js +0 -72
- package/dist/gateway/static/root/assets/files-BNL4kkSB.js +0 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-D_ZITqDi.js +0 -1
- package/dist/gateway/static/root/assets/index-Ca939klV.js +0 -11
- package/dist/gateway/static/root/assets/index-DrWdNdP4.css +0 -1
- package/dist/gateway/static/root/assets/mcp-conversation-setup-page-lOOFtIXe.js +0 -1
- package/dist/gateway/static/root/assets/note-image-lightbox-C1w4X0T6.js +0 -1
- package/dist/gateway/static/root/assets/notes-page-strWZLkP.js +0 -8
- package/dist/gateway/static/root/assets/page-tabs-oeTY7z3_.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BEDT8_0u.js +0 -1
- package/dist/gateway/static/root/assets/space-api-C302hvkG.js +0 -1
- package/dist/gateway/static/root/assets/space-page-sfc82o9O.js +0 -2
- package/dist/gateway/static/root/assets/workspace-editor-agent-store-D5wq8Kme.js +0 -1
package/dist/gateway/static/root/assets/{session-manager-CvC5uo-A.js → session-manager-fvJusKsK.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./diagnostics-Bo0Z42P_.js";import{a as r,i,l as a,n as o,p as s,u as c}from"./locale-store-
|
|
1
|
+
import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./diagnostics-Bo0Z42P_.js";import{a as r,i,l as a,n as o,p as s,u as c}from"./locale-store-B4o4aDCg.js";import{t as l}from"./messages-hlOsXkQ7.js";import{_ as u,a as d,c as f,d as p,f as ee,g as m,i as h,m as g,n as _,u as v}from"./schemas-CCWMleym.js";import{i as y,n as b}from"./turn-outcome-BSbEJx8h.js";import{_ as te,b as ne,g as re,h as x,m as S,s as C,v as w,y as ie}from"./session-api-7-TPnKv0.js";import{b as T,c as ae,d as oe,f as se,h as E,i as D,l as O,m as ce,o as k,p as le,r as ue,s as de,t as fe,u as pe,v as A,x as me,y as he}from"./local-session-drafts-8PozABVy.js";import{t as j}from"./tool-activity-BtJkgjFf.js";import{t as M}from"./gateway-startup-retry-D0i7dt51.js";import{o as ge}from"./attachment-utils-core-BPYdUI6y.js";import{o as _e}from"./gateway-realtime-CfceJ5WX.js";import{n as ve}from"./registry-api-CmLu4MA9.js";import{a as ye}from"./agents-admin-api-_mp_Ew1u.js";var be=[0,500,1500],xe=1e4;function Se(e){let t=[e.content,e.thinking??null,e.attachments??null,e.contextRefs??null,e.browserContexts??null];e.appContext!==void 0&&t.push(e.appContext);let n=JSON.stringify(t),r=2166136261,i=5381;for(let e=0;e<n.length;e++){let t=n.charCodeAt(e);r^=t,r=Math.imul(r,16777619),i=Math.imul(i,33)^t}return`${n.length.toString(36)}:${(r>>>0).toString(36)}:${(i>>>0).toString(36)}`}function N(e){return e===408||e===429||e>=500}var Ce=/^\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}[^\]]*\]\s*/u,we=[`user-profile`,`active-focuses`,`collaboration-contract`,`user-context`];function Te(e,t){let n=`<${t}>`;if(!e.startsWith(n))return null;let r=`</${t}>`,i=e.indexOf(r,n.length);return i<0?null:e.slice(i+r.length).trimStart()}function Ee(e){return Ce.test(e)||e.startsWith(`<source_contexts>`)||we.some(t=>e.startsWith(`<${t}>`))}function De(e){if(!e.includes(`<source_contexts>`))return e;let t=e.replace(/^\s*<source_contexts>[\s\S]*?<\/source_contexts>\s*/u,``).trimStart();return t.match(/^<user_message>\r?\n([\s\S]*)\r?\n<\/user_message>\s*$/u)?.[1]??t}function Oe(e){let t=e,n=Te(t.trimStart(),`xopc_task_execution`);n!==null&&Ee(n)&&(t=n),t=De(t);let r=t,i=!1;for(t=t.trimStart();;){let e=we.find(e=>t.startsWith(`<${e}>`));if(!e)break;let n=Te(t,e);if(n===null){t=r,i=!1;break}t=n,i=!0}return i&&!Ce.test(t)&&(t=r),t.replace(Ce,``)}function ke(e){return!e.includes(`[media attached:`)&&!e.includes(`xopc-media-uri:`)?e:e.replace(/\s*\[media attached:[^\]]+\]\s*\r?\nxopc-media-uri:[^\r\n]+\r?\n\s*xopc-media-path:[^\r\n]+(?:\r?\n\s*Use the read_media tool[^\r\n]*)?/g,``).replace(/\s*\[media attached:[^\]]+\]\s*/g,` `).replace(/\s*xopc-media-uri:[^\r\n]+/g,``).replace(/\s*xopc-media-path:[^\r\n]+/g,``).replace(/\s*Use the read_media tool[^\r\n]*/g,``).replace(/\n{3,}/g,`
|
|
2
2
|
|
|
3
3
|
`).trim()}var Ae=`@xopc-ref:`,je=`[A-Za-z0-9_-]{1,64}`,Me=RegExp(`${Ae}(${je})`,`g`);function Ne(e){if(!RegExp(`^${je}$`).test(e))throw Error(`Invalid context reference id`);return`${Ae}${e}`}function Pe(){return new RegExp(Me.source,`g`)}function Fe(e){let t=[],n=Pe(),r=0,i;for(;(i=n.exec(e))!==null;)i.index>r&&t.push({type:`text`,text:e.slice(r,i.index)}),t.push({type:`context_ref`,refId:i[1]??``}),r=i.index+i[0].length;return t.length===0?null:(r<e.length&&t.push({type:`text`,text:e.slice(r)}),{version:1,parts:t})}function Ie(e){return e.parts.flatMap(e=>e.type===`context_ref`?[e.refId]:[])}function Le(e,t){return e.parts.map(e=>{if(e.type===`text`)return e.text;let n=t(e.refId)?.trim();return n?`@${n}`:``}).join(``)}function Re(e){return e.parts.map(e=>e.type===`text`?e.text:Ne(e.refId)).join(``)}function ze(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return t.version!==1||!Array.isArray(t.parts)?!1:t.parts.every(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return t.type===`text`?typeof t.text==`string`:t.type===`context_ref`&&typeof t.refId==`string`&&RegExp(`^${je}$`).test(t.refId)})}var Be=8e3,Ve=p({schemaVersion:m([f(1),f(2)]).optional(),questions:T.optional(),interactionMode:_([`quick`,`compose`]).optional(),choiceDetails:h(p({id:g().min(1).max(160),label:g().trim().min(1).max(1e3),description:g().max(2e3).optional()}).strict()).min(1).max(10).optional(),recommendedChoiceId:g().min(1).max(160).optional(),approval:p({operation:g().min(1).max(1e3),target:g().max(2e3).optional(),impact:g().max(4e3).optional(),argumentsPreview:ee(g(),u()).optional()}).strict().optional()}),He=p({question:g(),choiceId:g(),choices:Ve.shape.choiceDetails.unwrap()});function Ue(e,t){if(e.kind!==`input`)return;let n=e.schemaVersion===2&&e.questions?.length===1?e.questions[0]:void 0;if(e.schemaVersion===2&&n?.type!==`single_choice`)return;let r=n?t?.answers?.find(e=>e.questionId===n.id):t?.response,i=n?.type===`single_choice`?n.choices:e.choiceDetails;if(!(!r?.choiceId||r.text?.trim()||!i?.some(e=>e.id===r.choiceId)))return{question:n?.question??e.question,choiceId:r.choiceId,choices:i}}var We=p({schemaVersion:m([f(1),f(2)]).optional(),answers:he.optional(),response:p({choiceId:g().min(1).max(160).optional(),text:g().trim().max(Be).optional()}).strict().optional(),decision:_([`approve`,`deny`]).optional()}).strict();We.extend({action:_([`answer`,`agent_decide`,`cancel`]),expectedVersion:v().int().positive(),idempotencyKey:g().trim().min(1).max(256)}).strict();function Ge(e){let t=Ve.safeParse(e);return t.success?t.data:{}}function Ke(e,t){let n=We.parse(t);if(e.schemaVersion===2){if(e.kind===`approval`||n.schemaVersion!==2||n.response||n.decision||!e.questions)throw Error(`Multi-question response requires schemaVersion 2`);return{schemaVersion:2,...me(e.questions,n.answers)}}if(n.schemaVersion===2||n.answers!==void 0)throw Error(`Unexpected multi-question response`);if(e.kind===`approval`){if(n.response||!n.decision)throw Error(`An explicit approval decision is required`);return{answer:n.decision,decision:n.decision}}if(n.decision||!n.response)throw Error(`A structured response is required`);let r=n.response.choiceId?e.choiceDetails?.find(e=>e.id===n.response.choiceId):void 0;if(n.response.choiceId&&!r)throw Error(`Unknown clarification choice`);let i=n.response.text?.trim()??``;if(!r&&!i)throw Error(`Answer is required`);return{answer:r&&i?`Choice: ${r.label}\nAdditional information: ${i}`:r?.label??i,response:{...r?{choiceId:r.id}:{},...i?{text:i}:{}}}}var qe=p({version:f(1),deliveryId:g().min(1),taskId:g().min(1),taskRunId:g().min(1),taskResultId:g().min(1).optional(),taskTitle:g().min(1).max(500),conversationId:g().min(1),originTranscriptId:g().min(1),requestInputId:g().optional(),assignmentEpoch:v().int().nonnegative(),resultRevision:v().int().positive().optional(),previousResultId:g().optional(),contractVersion:v().int().positive().optional(),instructionSequence:v().int().nonnegative().optional(),adoption:h(p({entryId:g(),sequence:v().int(),status:_([`applied`,`partially_applied`,`not_applied`,`superseded`]),verification:_([`passed`,`failed`,`unverified`]),claimIds:h(g()),note:g()})).optional(),outcome:b,text:g().optional(),createdAt:v()});function Je(e){let t=qe.safeParse(e);return t.success?t.data:void 0}var Ye=p({outreachId:g().uuid(),reasonKind:_([`follow_up`,`discussion`,`change`,`prepared`]),authority:_([`user_explicit`,`inferred`])}).strict();p({version:f(1),outreachId:g().uuid(),threadId:g().uuid(),conversationId:g().uuid(),originTranscriptId:g().min(1),text:g().trim().min(1).max(12e3),provenance:Ye,createdAt:v().int().nonnegative()}).strict();var Xe=p({revision:v().int().positive().default(1),mode:_([`off`,`follow_up`,`balanced`]).default(`balanced`),timezone:g().max(100).default(`Asia/Shanghai`).refine(e=>{try{return new Intl.DateTimeFormat(`en`,{timeZone:e}),!0}catch{return!1}},`Invalid timezone`),quietStart:v().int().min(0).max(23).default(22),quietEnd:v().int().min(0).max(23).default(8),dailyMessages:v().int().min(0).max(10).default(2),dailyModelCalls:v().int().min(0).max(100).default(12)}).strict();p({idempotencyKey:g().min(1).max(200),kind:_([`helpful`,`irrelevant`,`stop`,`defer`,`adjust`]),scope:_([`message`,`thread`]).default(`message`),until:v().int().positive().optional(),preparation:_([`brief`,`thorough`]).optional()}).strict().superRefine((e,t)=>{e.kind===`defer`&&!e.until&&t.addIssue({code:`custom`,message:`A defer time is required`}),e.kind===`adjust`&&!e.preparation&&t.addIssue({code:`custom`,message:`A preparation preference is required`}),(e.kind===`stop`||e.kind===`adjust`)&&e.scope!==`thread`&&t.addIssue({code:`custom`,message:`A lasting change requires thread scope`})}),p({versionId:g().uuid(),revision:v().int().positive(),idempotencyKey:g().min(1).max(200)}).strict();var Ze=p({preparation:_([`brief`,`thorough`]).nullable(),versions:h(p({id:g().uuid(),revision:v().int().positive(),kind:_([`stop`,`defer`,`adjust`,`rollback`]),createdAt:v(),preparation:_([`brief`,`thorough`]).nullable()}))});p({id:g().uuid(),subject:g(),summary:g(),status:_([`candidate`,`completed`,`expired`]),confidence:v().min(0).max(1),independentStatements:v().int(),independentDays:v().int(),lastSupportedAt:v(),expiresAt:v(),sources:h(p({entryId:g(),excerpt:g(),observedAt:v()}))});var Qe=p({provenance:Ye,thread:p({id:g(),subject:g(),status:g(),revision:v(),nextCheckAt:v().nullable()}),whyNow:g(),sources:h(p({conversationId:g(),transcriptId:g(),entryId:g(),excerpt:g()})),sourcesAvailable:d(),strategy:Ze.optional()}),$e=[`## Result for the originating conversation`,`For ordinary Tasks when publish_task_result is available, use it before completion to review the actual result. Connected Requests use their own structured result tool instead. When files were published, finalArtifactIds must select the exact final artifact IDs from publication receipts, including [] for a text-only result. Exclude intermediate, obsolete and failed files; publication history is not the final delivery manifest.`,`Provide a complete, evidence-grounded result for the originating conversation. The personal assistant may synthesize its final reply from your report. Match the user’s language and requested depth; preserve requested content, relevant sources, verified data cutoffs, uncertainty, and partial failures. Distinguish reported findings from verified facts. Do not invent a friendly opening or assume a new user request.`,`Keep internal planning, Agent names, tool logs, and task progress links out of the result unless the user specifically requested them or they are necessary to explain a blocker. Never substitute a progress page, a plan, or a promise for the requested result. Publish required files through the available artifact tools; do not repeat the same attachments or send the user to a Task page to collect them.`].join(`
|
|
4
4
|
`),et=`Before finishing, call personal_request_result with the verified summary and, for mail, message items and coverage. The host composes the final explanation and preserves structured items in the main chat.`;function tt(e){let t=e.replace(/\r\n/g,`
|
|
@@ -14,7 +14,7 @@ import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./d
|
|
|
14
14
|
`)}function Mt(e){return e.filter(e=>e.type===`thinking`).map(e=>(e.text??``).trim()).filter(Boolean).join(`
|
|
15
15
|
`)}function Nt(e){return e.filter(e=>e.type===`tool_use`).map(e=>{let t=typeof e.result==`string`?e.result.trim():JSON.stringify(e.result??``);return`${e.name}|${e.status}|${t}`}).join(`
|
|
16
16
|
`)}function Pt(e){return e.filter(e=>e.type===`review`).map(e=>JSON.stringify(e)).join(`
|
|
17
|
-
`)}function Ft(e,t){return e.role!==`assistant`||t.role!==`assistant`?!1:jt(e.content)===jt(t.content)&&Mt(e.content)===Mt(t.content)&&Nt(e.content)===Nt(t.content)&&Pt(e.content)===Pt(t.content)&&JSON.stringify(e.outcome??null)===JSON.stringify(t.outcome??null)}function It(e){let t=[];for(let n of e){if(!nt(n))continue;let e=n,r=String(e.role??``);if(r!==`system`){if(r===`task`){let n=Lt(e.taskTrigger);n&&t.push({role:`task`,content:[],taskTrigger:n,...e.turnId?{turnId:e.turnId}:{},timestamp:typeof e.timestamp==`number`?e.timestamp:ct(e.timestamp)});continue}if(r===`toolResult`||r===`tool`){Jt(t,e);continue}if(r===`user`){t.push(Bt(e));continue}if(r===`assistant`){t.push(Wt(e,e.id??`history:${t.length}`));continue}}}let n=F(Dt(t));for(let e=1;e<n.length;e++){let t=n[e],r=n[e-1];t.role===`user`&&t.clientMessageId&&r.role===`assistant`&&r.turnId===t.turnId&&(n[e-1]={...r,beforeSteer:!0})}return n}function Lt(e){let t=I(e);return!t||typeof t.entryId!=`string`||typeof t.taskId!=`string`||typeof t.taskTitle!=`string`||!t.taskTitle.trim()||![`progress`,`question`,`result`,`failure`].includes(String(t.kind))?null:{entryId:t.entryId,taskId:t.taskId,taskTitle:t.taskTitle,kind:t.kind}}function Rt(e){return e.filter(e=>e.type===`text`).map(e=>({...e,text:P(e.text)})).filter(e=>!!e.text?.trim())}function zt(e){return gt([...ut(e.media)??[],...ut(e.attachments)??[]])}function Bt(e){let t=e.content,n=I(e.metadata),r=n?.steered===!0?n.clientMessageId:void 0,i=He.safeParse(n?.clarificationChoice),
|
|
17
|
+
`)}function Ft(e,t){return e.role!==`assistant`||t.role!==`assistant`?!1:jt(e.content)===jt(t.content)&&Mt(e.content)===Mt(t.content)&&Nt(e.content)===Nt(t.content)&&Pt(e.content)===Pt(t.content)&&JSON.stringify(e.outcome??null)===JSON.stringify(t.outcome??null)}function It(e){let t=[];for(let n of e){if(!nt(n))continue;let e=n,r=String(e.role??``);if(r!==`system`){if(r===`task`){let n=Lt(e.taskTrigger);n&&t.push({role:`task`,content:[],taskTrigger:n,...e.turnId?{turnId:e.turnId}:{},timestamp:typeof e.timestamp==`number`?e.timestamp:ct(e.timestamp)});continue}if(r===`toolResult`||r===`tool`){Jt(t,e);continue}if(r===`user`){t.push(Bt(e));continue}if(r===`assistant`){t.push(Wt(e,e.id??`history:${t.length}`));continue}}}let n=F(Dt(t));for(let e=1;e<n.length;e++){let t=n[e],r=n[e-1];t.role===`user`&&t.clientMessageId&&r.role===`assistant`&&r.turnId===t.turnId&&(n[e-1]={...r,beforeSteer:!0})}return n}function Lt(e){let t=I(e);return!t||typeof t.entryId!=`string`||typeof t.taskId!=`string`||typeof t.taskTitle!=`string`||!t.taskTitle.trim()||![`progress`,`question`,`result`,`failure`].includes(String(t.kind))?null:{entryId:t.entryId,taskId:t.taskId,taskTitle:t.taskTitle,kind:t.kind}}function Rt(e){return e.filter(e=>e.type===`text`).map(e=>({...e,text:P(e.text)})).filter(e=>!!e.text?.trim())}function zt(e){return gt([...ut(e.media)??[],...ut(e.attachments)??[]])}function Bt(e){let t=e.content,n=I(e.metadata),r=n?.steered===!0?n.clientMessageId:void 0,i=I(e.agentReaction),a=i&&typeof i.emoji==`string`&&i.emoji.length<=32&&typeof i.actorName==`string`&&typeof i.entryId==`string`&&typeof i.clientMessageId==`string`&&e.transcriptEntryId===i.entryId?{emoji:i.emoji,actorName:i.actorName,entryId:i.entryId,clientMessageId:i.clientMessageId}:void 0,o=He.safeParse(n?.clarificationChoice),s=typeof t==`string`?(()=>{let e=P(t);return e.trim()?[{type:`text`,text:e}]:[]})():Rt(Qt(t));return{role:`user`,transcriptEntryId:e.transcriptEntryId,agentReaction:a,...o.success?{clarificationChoice:o.data}:{},...e.turnId?{turnId:e.turnId}:{},...typeof r==`string`?{clientMessageId:r}:{},content:s,attachments:zt(e),contextRefs:Ht(e.metadata),sourceDevice:Vt(e.metadata),userTurnDocument:Ut(e.metadata),timestamp:typeof e.timestamp==`number`?e.timestamp:ct(e.timestamp),usage:e.usage}}function Vt(e){let t=I(e)?.sourceContexts;if(!Array.isArray(t))return;let n=t.map(I).find(e=>e?.kind===`device_context`);return n&&typeof n.sourceId==`string`&&typeof n.title==`string`?{endpointId:n.sourceId,name:n.title}:void 0}function Ht(e){let t=I(e)?.sourceContexts;if(!Array.isArray(t))return;let n=t.flatMap(e=>{let t=I(e);return!t||t.kind!==`note`&&t.kind!==`file`&&t.kind!==`session`&&t.kind!==`browser_tab`&&t.kind!==`mcp_resource`||typeof t.sourceId!=`string`||typeof t.version!=`string`||typeof t.title!=`string`?[]:[{...typeof t.refId==`string`?{refId:t.refId}:{},kind:t.kind,sourceId:t.sourceId,version:t.version,title:t.title,...typeof t.tokenEstimate==`number`?{tokenEstimate:t.tokenEstimate}:{},...t.truncated===!0?{truncated:!0}:{},...t.kind===`file`&&(t.fileKind===`file`||t.fileKind===`directory`)?{fileKind:t.fileKind}:{}}]});return n.length>0?n:void 0}function Ut(e){let t=I(e)?.userTurnDocument;if(!ze(t))return;let n=!1;return{...t,parts:t.parts.map(e=>n||e.type!==`text`?{...e}:(n=!0,{...e,text:P(e.text)}))}}function Wt(e,t){let n=qt(e),r=e.stopReason===`aborted`||e.stopReason===`error`;for(let e of n)e.type===`text`&&!e.segmentId&&(e.segmentId=t,e.hydrated=!0),e.type===`text`&&e.presentation!==`narration`&&r&&(e.presentation=`pending`);Kt(n,e.metadata);let i=y(I(e.metadata)?.turnOutcome),a=Ye.safeParse(I(e.metadata)?.personalProvenance),o=Je(I(e.metadata)?.taskResultDelivery);return{role:`assistant`,fromHistory:!0,...e.transcriptEntryId?{transcriptEntryId:e.transcriptEntryId}:{},...r?{runStatus:e.stopReason===`aborted`?`cancelled`:`error`}:{},...e.turnId?{turnId:e.turnId}:{},...e.startsNewBubble?{startsNewBubble:!0}:{},content:n,attachments:zt(e),...i?{outcome:i}:{},...o?{taskResultDelivery:o}:{},...a.success?{personalProvenance:a.data,startsNewBubble:!0}:{},timestamp:typeof e.timestamp==`number`?e.timestamp:ct(e.timestamp),usage:e.usage}}function I(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function Gt(e){let t=I(e);if(!t||t.type!==`review`)return null;let n=Array.isArray(t.findings)?t.findings:[],r={type:`review`,target:typeof t.target==`string`?t.target:`working tree changes`,summary:typeof t.summary==`string`?t.summary:``,findings:n.map(e=>{let t=I(e);if(!t)return null;let n=t.priority===0||t.priority===1||t.priority===2||t.priority===3?t.priority:2,r=typeof t.title==`string`?t.title:``,i=typeof t.body==`string`?t.body:``;if(!r&&!i)return null;let a={title:r,body:i,priority:n};return typeof t.confidenceScore==`number`&&(a.confidenceScore=t.confidenceScore),typeof t.filePath==`string`&&(a.filePath=t.filePath),typeof t.lineStart==`number`&&(a.lineStart=t.lineStart),typeof t.lineEnd==`number`&&(a.lineEnd=t.lineEnd),a}).filter(e=>e!=null),overallCorrectness:t.overallCorrectness===`patch is correct`||t.overallCorrectness===`patch is incorrect`?t.overallCorrectness:`unknown`,overallExplanation:typeof t.overallExplanation==`string`?t.overallExplanation:``};return typeof t.overallConfidenceScore==`number`&&(r.overallConfidenceScore=t.overallConfidenceScore),typeof t.generatedAt==`number`&&(r.generatedAt=t.generatedAt),(t.source===`model`||t.source===`local`)&&(r.source=t.source),r}function Kt(e,t){let n=Gt(I(t)?.review);n&&(e.some(e=>e.type===`review`&&e.target===n.target)||e.push(n))}function qt(e){let t=lt(e.timestamp),n=Qt(e.rawContent,t),r=n.length>0?n:Qt(e.content,t),i=e.tool_calls;if(Array.isArray(i))for(let e of i){if(!e?.id||r.some(t=>t.type===`tool_use`&&t.id===e.id))continue;let n=e.function?.arguments;if(typeof n==`string`)try{n=JSON.parse(n)}catch{}r.push({type:`tool_use`,id:e.id,name:e.function?.name||`tool`,input:n,status:`running`,startedAt:t})}let a=e.toolCalls;if(Array.isArray(a))for(let e=0;e<a.length;e+=1){let n=a[e],i=typeof n.id==`string`&&n.id?n.id:`tool-call-${e}-${n.name||`tool`}`,o=typeof n.result==`string`,s=r.find(e=>e.type===`tool_use`&&e.id===i);if(s){s.status=o?n.isError?`error`:`done`:s.status,s.result=o?n.result:s.result,s.details=n.details??s.details,o&&(s.completedAt=t,s.durationMs=s.startedAt!=null&&t!=null?Math.max(0,t-s.startedAt):s.durationMs);continue}r.push({type:`tool_use`,id:i,name:n.name||`tool`,input:n.args,status:o?n.isError?`error`:`done`:`running`,result:o?n.result:void 0,details:n.details,startedAt:t,completedAt:o?t:void 0,durationMs:o&&t!=null?0:void 0})}for(let e of r){if(e.type!==`tool_use`)continue;let t=e.details===void 0?e.result:{details:e.details,result:e.result};e.activity=j(e.name,e.status===`running`?`running`:e.status===`error`?`failed`:`completed`,t)}let o=r.some(e=>e.type===`tool_use`)?`narration`:`answer`;for(let e of r)e.type===`text`&&!e.presentation&&(e.presentation=o);return r}function Jt(e,t){let n=Yt(e);if(!n)return;let r=String(t.tool_call_id??t.toolCallId??``),i=Xt(t.content),a=!!t.isError,o=lt(t.timestamp),s=t.nestedCalls;for(let e of s?.calls??[]){if(!e||typeof e!=`object`)continue;let t=e;typeof t.id!=`string`||typeof t.name!=`string`||n.content.some(e=>e.type===`tool_use`&&e.toolCallId===t.id)||n.content.push({type:`tool_use`,id:t.id,toolCallId:t.id,parentToolCallId:r,name:t.name,input:t.arguments,status:t.status===`ok`?`done`:`error`,...typeof t.durationMs==`number`?{durationMs:t.durationMs}:{},...typeof t.error==`string`?{result:t.error}:{},completedAt:o})}let c=r?n.content.find(e=>e.type===`tool_use`&&e.id===r):void 0;if(c){c.status=a?`error`:`done`,c.result=i,c.details=t.details,c.activity=j(c.name,a?`failed`:`completed`,{details:t.details,result:i}),c.completedAt=o,c.startedAt!=null&&o!=null&&(c.durationMs=Math.max(0,o-c.startedAt)),typeof t.durationMs==`number`&&(c.durationMs=t.durationMs);return}let l=n.content.filter(e=>e.type===`tool_use`&&e.status===`running`);l.length===1&&(l[0].status=a?`error`:`done`,l[0].result=i,l[0].details=t.details,l[0].activity=j(l[0].name,a?`failed`:`completed`,{details:t.details,result:i}),l[0].completedAt=o,l[0].startedAt!=null&&o!=null&&(l[0].durationMs=Math.max(0,o-l[0].startedAt)))}function Yt(e){for(let t=e.length-1;t>=0;t--)if(e[t].role===`assistant`)return e[t];return null}function Xt(e){return typeof e==`string`?e:Array.isArray(e)?e.filter(e=>it(e)&&e.type===`text`).map(e=>String(e.text??``)).join(`
|
|
18
18
|
`):String(e??``)}function Zt(e){let t=e.source?.data;if(typeof t==`string`&&t.length>0)return{type:`image`,source:{data:t}};let n=e.data;if(typeof n!=`string`||n.length===0)return null;let r=n.trim();return r.startsWith(`data:`)?{type:`image`,source:{data:r}}:{type:`image`,source:{data:`data:${typeof e.mimeType==`string`&&e.mimeType.includes(`/`)?e.mimeType:`image/png`};base64,${r.replace(/\s/g,``)}`}}}function Qt(e,t){if(e==null)return[];if(typeof e==`string`)return e.trim()?[{type:`text`,text:e}]:[];if(!Array.isArray(e))return[{type:`text`,text:String(e)}];let n=[];for(let r of e){if(!it(r))continue;let e=r.type;if(e===`text`&&typeof r.text==`string`){let e=r.presentation===`pending`||r.presentation===`narration`||r.presentation===`answer`?r.presentation:void 0;n.push({type:`text`,text:r.text,...r.segmentId?{segmentId:r.segmentId}:{},...e?{presentation:e}:{}})}else if(e===`thinking`){let e=typeof r.thinking==`string`?r.thinking:typeof r.text==`string`?r.text:``;n.push({type:`thinking`,text:e,streaming:!1})}else if(e===`image`){let e=Zt(r);e&&n.push(e)}else if(e===`review`){let e=Gt(r);e&&n.push(e)}else if(e===`tool_use`||e===`tool_call`){if(!rt(r))continue;let e=at(r),i=String(r.name??r.function?.name??`tool`),a=r.input??r.function?.arguments;n.push({type:`tool_use`,id:e,toolCallId:e,name:i,input:a,status:r.status===`error`?`error`:`done`,startedAt:t,result:typeof r.result==`string`?r.result:void 0,details:r.details})}else if(e===`toolCall`){if(!rt(r))continue;let e=at(r),i=String(r.name??r.function?.name??`tool`);n.push({type:`tool_use`,id:e,toolCallId:e,name:i,input:st(r),status:`done`,startedAt:t,result:typeof r.result==`string`?r.result:void 0,details:r.details})}}return n}var $t=new Map,en=new Map,tn=e=>`${a.getState().conversationId}:${e}`;function nn(e){return $t.get(tn(e))??{paused:!1,version:0,phase:`idle`,reviewRequired:!1}}function rn(e,t,n){let r=tn(e),i=en.get(r);return n!==void 0&&i!==void 0&&n<i?!1:(n===void 0?en.delete(r):en.set(r,n),$t.set(r,t),!0)}async function an(e,t){let n=a.getState().conversationId,o=i(`/api/sessions/${encodeURIComponent(e)}/input-control`),s=!1,c=()=>{if(s||n!==a.getState().conversationId)throw new DOMException(`Gateway changed`,`AbortError`)},l;for(let e=0;e<2;e++){c();let e=new AbortController,i=a.subscribe(t=>{t.conversationId!==n&&(s=!0,e.abort())}),u=setTimeout(()=>e.abort(),1e4);try{let n=await r(o,{method:`POST`,signal:e.signal,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}),i=await n.json();if(c(),!n.ok)throw Object.assign(Error(i.error?.message??`Input control failed`),{definitive:n.status<500});return i.payload}catch(e){if(c(),l=e,e.definitive)throw e}finally{clearTimeout(u),i()}}throw l}async function on(){try{let e=await fetch(i(`/api/health`),{credentials:`same-origin`,redirect:`error`,signal:AbortSignal.timeout(3e3)});if(!e.ok)return;let t=await e.json();return Array.isArray(t.clarificationVersions)&&t.clarificationVersions.includes(2)?{clarificationVersions:[1,2]}:void 0}catch{return}}var sn;function cn(e){sn=e?a.getState().conversationId:void 0}async function ln(){if(!sn||sn!==a.getState().conversationId)return;let e=le.safeParse({version:1,capturedAt:Date.now(),timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,locale:navigator.language});return e.success?e.data:void 0}var un=Symbol.for(`immer-nothing`),dn=Symbol.for(`immer-draftable`),L=Symbol.for(`immer-state`);function R(e,...t){throw Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var z=Object,B=z.getPrototypeOf,fn=`constructor`,pn=`prototype`,mn=`configurable`,hn=`enumerable`,gn=`writable`,_n=`value`,V=e=>!!e&&!!e[L];function H(e){return e?bn(e)||Dn(e)||!!e[dn]||!!e[fn]?.[dn]||On(e)||kn(e):!1}var vn=z[pn][fn].toString(),yn=new WeakMap;function bn(e){if(!e||!An(e))return!1;let t=B(e);if(t===null||t===z[pn])return!0;let n=z.hasOwnProperty.call(t,fn)&&t[fn];if(n===Object)return!0;if(!jn(n))return!1;let r=yn.get(n);return r===void 0&&(r=Function.toString.call(n),yn.set(n,r)),r===vn}function xn(e,t,n=!0){Sn(e)===0?(n?Reflect.ownKeys(e):z.keys(e)).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function Sn(e){let t=e[L];return t?t.type_:Dn(e)?1:On(e)?2:kn(e)?3:0}var Cn=(e,t,n=Sn(e))=>n===2?e.has(t):z[pn].hasOwnProperty.call(e,t),wn=(e,t,n=Sn(e))=>n===2?e.get(t):e[t],Tn=(e,t,n,r=Sn(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function En(e,t){return e===t?e!==0||1/e==1/t:e!==e&&t!==t}var Dn=Array.isArray,On=e=>e instanceof Map,kn=e=>e instanceof Set,An=e=>typeof e==`object`,jn=e=>typeof e==`function`,Mn=e=>typeof e==`boolean`;function Nn(e){let t=+e;return Number.isInteger(t)&&String(t)===e}var U=e=>e.copy_||e.base_,Pn=e=>e.modified_?e.copy_:e.base_;function Fn(e,t){if(On(e))return new Map(e);if(kn(e))return new Set(e);if(Dn(e))return Array[pn].slice.call(e);let n=bn(e);if(t===!0||t===`class_only`&&!n){let t=z.getOwnPropertyDescriptors(e);delete t[L];let n=Reflect.ownKeys(t);for(let r=0;r<n.length;r++){let i=n[r],a=t[i];a[gn]===!1&&(a[gn]=!0,a[mn]=!0),(a.get||a.set)&&(t[i]={[mn]:!0,[gn]:!0,[hn]:a[hn],[_n]:e[i]})}return z.create(B(e),t)}else{let t=B(e);if(t!==null&&n)return{...e};let r=z.create(t);return z.assign(r,e)}}function In(e,t=!1){return zn(e)||V(e)||!H(e)?e:(Sn(e)>1&&z.defineProperties(e,{set:Rn,add:Rn,clear:Rn,delete:Rn}),z.freeze(e),t&&xn(e,(e,t)=>{In(t,!0)},!1),e)}function Ln(){R(2)}var Rn={[_n]:Ln};function zn(e){return e===null||!An(e)||z.isFrozen(e)}var Bn=`MapSet`,Vn=`Patches`,Hn=`ArrayMethods`,Un={};function W(e){let t=Un[e];return t||R(0,e),t}var Wn=e=>!!Un[e],Gn,Kn=()=>Gn,qn=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Wn(Bn)?W(Bn):void 0,arrayMethodsPlugin_:Wn(Hn)?W(Hn):void 0});function Jn(e,t){t&&(e.patchPlugin_=W(Vn),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Yn(e){Xn(e),e.drafts_.forEach(Qn),e.drafts_=null}function Xn(e){e===Gn&&(Gn=e.parent_)}var Zn=e=>Gn=qn(Gn,e);function Qn(e){let t=e[L];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function $n(e,t){t.unfinalizedDrafts_=t.drafts_.length;let n=t.drafts_[0];if(e!==void 0&&e!==n){n[L].modified_&&(Yn(t),R(4)),H(e)&&(e=er(t,e));let{patchPlugin_:r}=t;r&&r.generateReplacementPatches_(n[L].base_,e,t)}else e=er(t,n);return tr(t,e,!0),Yn(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e===un?void 0:e}function er(e,t){if(zn(t))return t;let n=t[L];if(!n)return lr(t,e.handledSet_,e);if(!rr(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){let{callbacks_:t}=n;if(t)for(;t.length>0;)t.pop()(e);sr(n,e)}return n.copy_}function tr(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&In(t,n)}function nr(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var rr=(e,t)=>e.scope_===t,ir=[];function ar(e,t,n,r){let i=U(e),a=e.type_;if(r!==void 0&&wn(i,r,a)===t){Tn(i,r,n,a);return}if(!e.draftLocations_){let t=e.draftLocations_=new Map;xn(i,(e,n)=>{if(V(n)){let r=t.get(n)||[];r.push(e),t.set(n,r)}})}let o=e.draftLocations_.get(t)??ir;for(let e of o)Tn(i,e,n,a)}function or(e,t,n){e.callbacks_.push(function(r){let i=t;if(!i||!rr(i,r))return;r.mapSetPlugin_?.fixSetContents(i);let a=Pn(i);ar(e,i.draft_??i,a,n),sr(i,r)})}function sr(e,t){if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(e.assigned_?.size??0)>0)){let{patchPlugin_:n}=t;if(n){let r=n.getPath(e);r&&n.generatePatches_(e,r,t)}nr(e)}}function cr(e,t,n){let{scope_:r}=e;if(V(n)){let i=n[L];rr(i,r)&&i.callbacks_.push(function(){vr(e),ar(e,n,Pn(i),t)})}else H(n)&&e.callbacks_.push(function(){let i=U(e);e.type_===3?i.has(n)&&lr(n,r.handledSet_,r):wn(i,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&lr(wn(e.copy_,t,e.type_),r.handledSet_,r)})}function lr(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||V(e)||t.has(e)||!H(e)||zn(e)?e:(t.add(e),xn(e,(r,i)=>{if(V(i)){let t=i[L];rr(t,n)&&(Tn(e,r,Pn(t),e.type_),nr(t))}else H(i)&&lr(i,t,n)}),e)}function ur(e,t){let n=Dn(e),r={type_:+!!n,scope_:t?t.scope_:Kn(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0},i=r,a=dr;n&&(i=[r],a=fr);let{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,[s,r]}var dr={get(e,t){if(t===L)return e;let n=e.scope_.arrayMethodsPlugin_,r=e.type_===1&&typeof t==`string`;if(r&&n?.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);let i=U(e);if(!Cn(i,t,e.type_))return hr(e,i,t);let a=i[t];if(e.finalized_||!H(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&Nn(t))return a;if(a===pr(e.base_,t)||mr(e,t,a)){vr(e);let n=e.type_===1?+t:t,r=br(e.scope_,a,e,n);return e.copy_[n]=r}return a},has(e,t){return t in U(e)},ownKeys(e){return Reflect.ownKeys(U(e))},set(e,t,n){let r=gr(U(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){let r=pr(U(e),t),i=r?.[L];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_.delete(t),!0;if(En(n,r)&&(n!==void 0||Cn(e.base_,t,e.type_)))return!0;vr(e),_r(e)}return e.copy_[t]===n&&(n!==void 0||Cn(e.copy_,t,e.type_))||Number.isNaN(n)&&Number.isNaN(e.copy_[t])?!0:(e.copy_[t]=n,e.assigned_.set(t,!0),cr(e,t,n),!0)},deleteProperty(e,t){return vr(e),pr(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),_r(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let n=U(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[gn]:!0,[mn]:e.type_!==1||t!==`length`,[hn]:r[hn],[_n]:n[t]}},defineProperty(){R(11)},getPrototypeOf(e){return B(e.base_)},setPrototypeOf(){R(12)}},fr={};for(let e in dr){let t=dr[e];fr[e]=function(){let e=arguments;return e[0]=e[0][0],t.apply(this,e)}}fr.deleteProperty=function(e,t){return fr.set.call(this,e,t,void 0)},fr.set=function(e,t,n){return dr.set.call(this,e[0],t,n,e[0])};function pr(e,t){let n=e[L];return(n?U(n):e)[t]}function mr(e,t,n){return e.type_!==1||!e.allIndicesReassigned_||e.assigned_?.get(t)||!H(n)||n[L]?!1:e.baseRefs_.has(n)}function hr(e,t,n){let r=gr(t,n);return r?_n in r?r[_n]:r.get?.call(e.draft_):void 0}function gr(e,t){if(!(t in e))return;let n=B(e);for(;n;){let e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=B(n)}}function _r(e){e.modified_||(e.modified_=!0,e.parent_&&_r(e.parent_))}function vr(e){e.copy_||=(e.assigned_=new Map,Fn(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var yr=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(e,t,n)=>{if(jn(e)&&!jn(t)){let n=t;t=e;let r=this;return function(e=n,...i){return r.produce(e,e=>t.call(this,e,...i))}}jn(t)||R(6),n!==void 0&&!jn(n)&&R(7);let r;if(H(e)){let i=Zn(this),a=br(i,e,void 0),o=!0;try{r=t(a),o=!1}finally{o?Yn(i):Xn(i)}return Jn(i,n),$n(r,i)}else if(!e||!An(e)){if(r=t(e),r===void 0&&(r=e),r===un&&(r=void 0),this.autoFreeze_&&In(r,!0),n){let t=[],i=[];W(Vn).generateReplacementPatches_(e,r,{patches_:t,inversePatches_:i}),n(t,i)}return r}else R(1,e)},this.produceWithPatches=(e,t)=>{if(jn(e))return(t,...n)=>this.produceWithPatches(t,t=>e(t,...n));let n,r;return[this.produce(e,t,(e,t)=>{n=e,r=t}),n,r]},Mn(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),Mn(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),Mn(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){H(e)||R(8),V(e)&&(e=xr(e));let t=Zn(this),n=br(t,e,void 0);return n[L].isManual_=!0,Xn(t),n}finishDraft(e,t){let n=e&&e[L];(!n||!n.isManual_)&&R(9);let{scope_:r}=n;return Jn(r,t),$n(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){let r=t[n];if(r.path.length===0&&r.op===`replace`){e=r.value;break}}n>-1&&(t=t.slice(n+1));let r=W(Vn).applyPatches_;return V(e)?r(e,t):this.produce(e,e=>r(e,t))}};function br(e,t,n,r){let[i,a]=On(t)?W(Bn).proxyMap_(t,n):kn(t)?W(Bn).proxySet_(t,n):ur(t,n);return(n?.scope_??Kn()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?or(n,a,r):a.callbacks_.push(function(e){e.mapSetPlugin_?.fixSetContents(a);let{patchPlugin_:t}=e;a.modified_&&t&&t.generatePatches_(a,[],e)}),i}function xr(e){return V(e)||R(10,e),Sr(e)}function Sr(e){if(!H(e)||zn(e))return e;let t=e[L],n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Fn(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=Fn(e,!0);return xn(n,(e,t)=>{Tn(n,e,Sr(t))},r),t&&(t.finalized_=!1),n}globalThis.Iterator?.from;var Cr=new yr().produce,wr=new WeakMap,Tr=0;function Er(e){return wr.get(e)}function Dr(e){let t=wr.get(e);if(t)return t;let n=`chat-part:${++Tr}`;return wr.set(e,n),n}function Or(e,t){wr.set(t,Dr(e))}function kr(e,t){let n=-1,r;for(let t=0;t<e.length;t++){let i=e[t];(i.type===`tool_use`||i.type===`thinking`)&&(n=t),i.type===`text`&&i.text.trim()&&(r=i)}return e.filter((e,i)=>e.type===`review`||e.type===`text`&&i>n&&(t?.includePending||e.presentation!==`pending`)&&e.presentation!==`narration`&&(!r?.segmentId||!e.segmentId||e.segmentId===r.segmentId))}function G(e){return e===`user`}function Ar(e){if(!(e.role!==`user`||e.pendingSteer))return e.clientMessageId?`steer:${e.clientMessageId}`:e.turnId}function jr(e,t){if(t<0||t>=e.length)return null;let n=e[t];if(!n||!G(n.role))return null;let r=0;for(let n=0;n<=t;n++){let t=e[n];t&&G(t.role)&&(r+=1)}return r-1}function Mr(e,t){let n=1;for(let r=t+1;r<e.length;r++){let t=e[r];if(t&&G(t.role))break;n+=1}return n}function Nr(e,t){return e.length===t.length&&e.every((e,n)=>{let r=t[n];return!r||e.role!==r.role?!1:!e.turnId||!r.turnId||e.turnId===r.turnId})}function Pr(e){return e.role===`assistant`&&kr(e.content,{includePending:!0}).some(e=>{if(e.type===`review`)return!0;let t=e.type===`text`&&e.text.trim();return!!(t&&t!==`NO_REPLY`)})}function Fr(e,t){let n=e.filter(Pr),r=0;for(let e of t){let t=n[r];if(!t)return!0;Pr(e)&&(t.turnId&&e.turnId?t.turnId===e.turnId&&!!t.startsNewBubble==!!e.startsNewBubble:t.timestamp!==void 0&&t.timestamp===e.timestamp||Ft(t,e))&&r++}return r===n.length}function Ir(e,t,n){let r=e=>G(e.role);if(n){let i=t.findIndex(e=>r(e)&&e.turnId===n);if(i>=0){let a=e.findLastIndex(e=>r(e)&&e.turnId===n);if(a>=0&&e.slice(a+1).some(r))return e;let o=t.slice(0,i+1);return o.length<e.length||Nr(e,o)?e:Fr(e,o)?F(o):e}}let i=e.filter(r).length;if(t.filter(r).length<=i)return e;let a=t.filter(r).slice(i);return a.length===0?e:F([...e,...a])}function Lr(e){return e.replace(/^\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}[^\]]*\]\s+/,``)}function Rr(e){return(e??[]).filter(e=>e.type===`text`&&!!e.text).map(e=>P(Lr(e.text))).join(`
|
|
19
19
|
|
|
20
20
|
`).trim()}function zr(e){if(e?.length)return e.map(e=>{let t=e.data??e.content;return{id:e.id,type:e.type??(e.mimeType?.startsWith(`image/`)?`image`:`document`),mimeType:e.mimeType,...t?{data:t}:{},name:e.name,size:e.size,...e.uri?{uri:e.uri}:{},...e.bucket?{bucket:e.bucket}:{},...e.path?{path:e.path}:{},durationSeconds:e.durationSeconds}})}function Br(e){let t=typeof e.timestamp==`number`&&Number.isFinite(e.timestamp)?e.timestamp:Date.now();if(Array.isArray(e.content)||typeof e.content==`string`){let[n]=It([{role:`user`,turnId:typeof e.turnId==`string`?e.turnId:void 0,content:e.content,media:e.media,attachments:e.attachments,metadata:e.metadata,timestamp:t}]);return n??null}let n=typeof e.text==`string`?P(e.text.trim()):``,r=ut(e.media);return!n&&!r?.length?null:{role:`user`,turnId:typeof e.turnId==`string`?e.turnId:void 0,content:n?[{type:`text`,text:n}]:[],attachments:r,timestamp:t}}var Vr=12e4;function Hr(e,t){return!!(e.userTurnDocument&&t.userTurnDocument&&Re(e.userTurnDocument)===Re(t.userTurnDocument))}function Ur(e,t){if(!G(e.role)||!G(t.role))return!1;if(e.clientMessageId||t.clientMessageId)return e.clientMessageId===t.clientMessageId;if(e.turnId&&t.turnId&&e.turnId!==t.turnId)return!1;let n=Rr(e.content).trim(),r=Rr(t.content).trim(),i=e.attachments?.length??0,a=t.attachments?.length??0,o=i===0||a>=i;return!!(o&&Hr(e,t)||o&&n&&r&&(n===r||r.startsWith(n))||i>0&&o&&Math.abs((t.timestamp??0)-(e.timestamp??0))<=Vr)}function Wr(e,t){return!G(e.role)||!G(t.role)?!1:e.clientMessageId||t.clientMessageId?e.clientMessageId===t.clientMessageId:e.turnId&&t.turnId?e.turnId===t.turnId:e.timestamp===t.timestamp||Hr(e,t)?!0:Rr(e.content)===Rr(t.content)}function Gr(e,t){let n=e.length-1,r=e[n];if(!r||!G(r.role)||r.turnId)return e;let i=[...e];return i[n]={...r,turnId:t},i}var Kr=`medium`;function qr(){return{name:null,model:``,thinkingLevel:Kr,reasoningLevel:`on`,modelSupportsThinking:!1,effectiveWorkspacePath:``,workspaceSource:`agent_default_root`,userContextMode:`enabled`}}var Jr=class e{static instance;senders=new Map;resumeRunIds=new Map;generations=new Map;userAbortedSessions=new Set;static get(){return e.instance||=new e,e.instance}getGeneration(e){return this.generations.get(e)??0}advanceGeneration(e){let t=this.getGeneration(e)+1;return this.generations.set(e,t),t}senderFor(e){let t=this.senders.get(e);return t||(t=new ja,this.senders.set(e,t)),t}isStreamingFor(e){return this.senders.get(e)?.isStreamingFor(e)??!1}isSubmittingFor(e){let t=this.senders.get(e);return!!(t?.isStreamingFor(e)&&!t.trackedRunId)}isTrackingRun(e,t){return this.senders.get(e)?.isTrackingRun(e,t)??!1}retireOtherRun(e,t){let n=this.senders.get(e);!n?.trackedRunId||n.trackedRunId===t||(this.advanceGeneration(e),n.abort(!1),this.senders.get(e)===n&&this.senders.delete(e))}getResumeRunId(e){return this.resumeRunIds.get(e)??null}setResumeRunId(e,t){t?this.resumeRunIds.set(e,t):this.resumeRunIds.delete(e)}setUserAborted(e,t){t?this.userAbortedSessions.add(e):this.userAbortedSessions.delete(e)}takeUserAborted(e){return this.userAbortedSessions.delete(e)}resetRunTracking(e){this.resumeRunIds.delete(e),this.userAbortedSessions.delete(e)}abort(e,t=!0){this.advanceGeneration(e),this.senders.get(e)?.abort(t),this.senders.delete(e),this.resetRunTracking(e)}reconcileTerminal(e,t,n){let r=this.senders.get(e)?.reconcileTerminal(e,t,n)??!1;return this.resumeRunIds.get(e)===t&&this.resumeRunIds.delete(e),r}reconcileInactive(e,t,n=!1){let r=this.senders.get(e)?.reconcileInactive(e,t,n)??!1;return this.resumeRunIds.get(e)===t&&this.resumeRunIds.delete(e),r}releaseIdleSender(e){let t=this.senders.get(e);t&&!t.isSending&&this.senders.delete(e)}}.get();function Yr(e,t){let n=new Set(kr(e,{includePending:!0}));for(let r of e)r.type!==`text`||r.presentation!==`pending`||(n.has(r)?t&&(r.presentation=`answer`):r.presentation=`narration`)}function Xr(e){for(let t of e)t.type===`text`&&t.presentation===`pending`&&(t.presentation=`narration`)}function Zr(e){if(e.type!==`thinking`)return``;let t=e;return(typeof t.text==`string`&&t.text.length>0?t.text:typeof t.thinking==`string`?t.thinking:``).trim()}function Qr(e){if(e.role!==`assistant`)return!1;for(let t of e.content)if(t.type===`text`&&(t.text||``).trim().length>0||t.type===`thinking`&&Zr(t).length>0||t.type===`tool_use`||t.type===`review`)return!0;return!1}function $r(e,t){return e&&e.role===`assistant`?{...e,content:[...e.content]}:{role:`assistant`,content:[],timestamp:t}}function ei(e){return{...e,content:e.content.map(e=>{let t={...e};return Or(e,t),t}),attachments:e.attachments?e.attachments.map(e=>({...e})):void 0,contextRefs:e.contextRefs?e.contextRefs.map(e=>({...e})):void 0,userTurnDocument:e.userTurnDocument?{...e.userTurnDocument,parts:e.userTurnDocument.parts.map(e=>({...e}))}:void 0}}function ti(e,t){return`${e??``}${t}`}function ni(e,t){if(!t)return e;if(!e)return t;if(e.endsWith(t))return e;let n=Math.min(e.length,t.length,512);for(let r=n;r>0;r--)if(e.slice(-r)===t.slice(0,r))return e+t.slice(r);return e+t}function ri(e,t,n){let r=e??``;return!Number.isInteger(n)||n==null||n<0?null:r.slice(n,n+t.length)===t?r:r.length===n?ti(r,t):null}function ii(e){let t=e[e.length-1];t?.type===`thinking`&&t.streaming&&(t.streaming=!1)}function ai(e){Xr(e);let t=e[e.length-1];t?.type===`thinking`&&t.streaming||e.push({type:`thinking`,text:``,streaming:!0})}function oi(e,t,n,r){let i=e[e.length-1];if(i?.type===`thinking`&&i.segmentId===r&&i.streaming){n?i.text=ti(i.text,t):i.text=t,i.streaming=!0;return}ii(e),e.push({type:`thinking`,text:t,streaming:!0,...r?{segmentId:r}:{}})}function si(e,t){for(let n of e)n.type===`thinking`&&(!t||n.segmentId===t)&&(n.streaming=!1,n.text=n.text.trim())}function ci(e,t=!0){for(let n of e)n.type===`tool_use`&&n.status===`running`&&(n.status=t?`done`:`error`,n.activity=j(n.name,t?`completed`:`failed`,n.result))}function li(e,t){return e.trim().toLowerCase()===t.trim().toLowerCase()}function ui(e,t,n,r){ii(e);let i=e[e.length-1];if(i?.type===`text`&&i.segmentId===n){i.text=ri(i.text,t,r?.offset)??ti(i.text,t);return}if(r?.reconcileHydratedSegment&&n&&i?.type===`text`&&(!i.segmentId||i.hydrated)){let e=ri(i.text,t,r.offset);if(e!==null){i.text=e,i.segmentId=n,delete i.hydrated,i.presentation=`pending`;return}}e.push({type:`text`,text:t,...n?{segmentId:n,presentation:`pending`}:{}})}function di(e,t,n){for(let r=e.length-1;r>=0;r--){let i=e[r];if(i.type===`text`&&i.segmentId===t){i.presentation=n;return}}}function fi(e){let t=xi(e);if(!t||t.type!==`review`)return null;let n=Array.isArray(t.findings)?t.findings:[],r={type:`review`,target:typeof t.target==`string`?t.target:`working tree changes`,summary:typeof t.summary==`string`?t.summary:``,findings:n.map(e=>{let t=xi(e);if(!t)return null;let n=t.priority===0||t.priority===1||t.priority===2||t.priority===3?t.priority:2,r=typeof t.title==`string`?t.title:``,i=typeof t.body==`string`?t.body:``;if(!r&&!i)return null;let a={title:r,body:i,priority:n};return typeof t.confidenceScore==`number`&&(a.confidenceScore=t.confidenceScore),typeof t.filePath==`string`&&(a.filePath=t.filePath),typeof t.lineStart==`number`&&(a.lineStart=t.lineStart),typeof t.lineEnd==`number`&&(a.lineEnd=t.lineEnd),a}).filter(e=>e!=null),overallCorrectness:t.overallCorrectness===`patch is correct`||t.overallCorrectness===`patch is incorrect`?t.overallCorrectness:`unknown`,overallExplanation:typeof t.overallExplanation==`string`?t.overallExplanation:``};return typeof t.overallConfidenceScore==`number`&&(r.overallConfidenceScore=t.overallConfidenceScore),typeof t.generatedAt==`number`&&(r.generatedAt=t.generatedAt),(t.source===`model`||t.source===`local`)&&(r.source=t.source),r}function pi(e,t){ii(e);let n=fi(t);if(!n)return;let r=e.findIndex(e=>e.type===`review`&&e.target===n.target);if(r>=0){let t=e[r];if(!t||t.type!==`review`)return;e[r]={...n,reviewId:t.reviewId,status:t.status===`error`?`error`:`complete`,analysisMarkdown:t.analysisMarkdown,errorMessage:t.errorMessage};return}e.push(n)}function mi(e){for(let t of e)t.type===`review`&&(t.status!==`preparing`&&t.status!==`reviewing`||(t.status=`error`,t.errorMessage??=`The review stream ended before a conclusion was returned.`))}function hi(e,t){ii(e);let n=e.find(e=>e.type===`review`&&e.reviewId===t.reviewId);if(n){n.target=t.target||n.target,n.status=t.stage;return}e.push({type:`review`,reviewId:t.reviewId,target:t.target||`working tree changes`,summary:``,findings:[],overallCorrectness:`unknown`,overallExplanation:``,status:t.stage})}function gi(e,t,n){if(!n)return;let r=e.find(e=>e.type===`review`&&e.reviewId===t);r&&(r.status=`reviewing`,r.analysisMarkdown=ni(r.analysisMarkdown??``,n))}function _i(e,t,n,r){let i=e.find(e=>e.type===`review`&&e.reviewId===t);i&&(i.status=n,i.errorMessage=n===`error`?r:void 0)}function vi(e,t,n,r,i,a,o){if(r&&e.some(e=>e.type===`tool_use`&&(e.toolCallId===r||e.id===r)))return;Xr(e),ii(e);let s={type:`tool_use`,id:r??crypto.randomUUID(),toolCallId:r,...o,name:t,activity:a??j(t,`running`),input:n,status:`running`,startedAt:i};e.push(s)}function yi(e,t,n,r,i,a,o,s){for(let c=e.length-1;c>=0;c--){let l=e[c];if(l.type===`tool_use`&&!(i&&l.toolCallId!==i&&l.id!==i)&&!(!i&&(l.status!==`running`||!li(l.name,t)))){l.status=n?`error`:`done`,l.result=r,l.activity=o??j(t,n?`failed`:`completed`,r),l.completedAt=a,s?.parentToolCallId&&(l.parentToolCallId=s.parentToolCallId),l.startedAt!=null&&(l.durationMs=Math.max(0,a-l.startedAt)),s?.durationMs!=null&&(l.durationMs=s.durationMs);return}}}function bi(e,t,n,r){for(let i=e.length-1;i>=0;i--){let a=e[i];if(a.type===`tool_use`&&a.status===`running`){if(n&&a.toolCallId===n){a.details=Si(a.details,r);return}if(!n&&li(a.name,t)){a.details=Si(a.details,r);return}}}}function xi(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function Si(e,t){let n=xi(t);if(typeof n?.textDelta==`string`){let t=xi(e)??{};return{...t,text:ni(String(t.text??``),n.textDelta)}}if(n?.kind!==`command_output_delta`)return t;let r=xi(e)??{},i=n.stream===`stderr`?`stderr`:`stdout`,a=typeof n.delta==`string`?n.delta:``,o=i===`stdout`?`${String(r.stdout??``)}${a}`:String(r.stdout??``),s=i===`stderr`?`${String(r.stderr??``)}${a}`:String(r.stderr??``);return{...r,command:typeof n.command==`string`?n.command:r.command,cwd:typeof n.cwd==`string`?n.cwd:r.cwd,stdout:o,stderr:s,aggregatedOutput:`${String(r.aggregatedOutput??``)}${a}`}}function Ci(e){return e!==`ready`}var K={streamingMsg:null,progress:null,taskPlan:null,sending:!1,streaming:!1};function wi(e){return{...qr(),historyStatus:e,messages:[],hasMore:!1,...K}}var Ti=0;function Ei(e){let t=ei(e);return t.renderKey??=`chat-row:${++Ti}`,t}function q(e){return e.map(Ei)}function Di(e,t){return e===t?!0:e.role!==t.role||e.timestamp!==t.timestamp||t.renderKey!==void 0&&e.renderKey!==t.renderKey?!1:JSON.stringify({...e,renderKey:void 0})===JSON.stringify({...t,renderKey:void 0})}function Oi(e,t){if(e.turnId&&t.turnId&&e.turnId!==t.turnId||!Wr(e,t)&&!Ur(e,t))return t;let n=t.attachments?.length?t.attachments:e.attachments,r=t.contextRefs?.length?t.contextRefs:e.contextRefs,i=t.userTurnDocument??e.userTurnDocument;return{...t,attachments:n,contextRefs:r,userTurnDocument:i,renderKey:e.renderKey,clientSubmissionId:e.clientSubmissionId}}function ki(e,t){return e.role===t.role?e.clientMessageId||t.clientMessageId?e.clientMessageId===t.clientMessageId:e.turnId&&t.turnId?e.turnId===t.turnId&&e.startsNewBubble===t.startsNewBubble:e.timestamp!==void 0&&e.timestamp===t.timestamp:!1}function J(e,t){let n=e.length!==t.length,r=0,i=new Map(e.flatMap((e,t)=>e.clientMessageId?[[e.clientMessageId,t]]:[])),a=t.map((t,a)=>{let o=(t.clientMessageId?i.get(t.clientMessageId):void 0)??e.findIndex((e,n)=>n>=r&&ki(e,t)),s=a>=r?e[a]:void 0,c=s&&(Ur(s,t)||(!s.turnId||!t.turnId||s.turnId===t.turnId)&&Ft(s,t)),l=o>=0?o:c?a:-1,u=e[l];u&&(r=Math.max(r,l+1));let d=u&&G(u.role)&&G(t.role)?Oi(u,t):t;if(u&&Di(u,d))return l!==a&&(n=!0),u;n=!0;let f=Ei(d);if(u?.renderKey&&u.role===d.role&&(ki(u,d)||d.role===`assistant`&&Ft(u,d))){f.renderKey=u.renderKey;let e=e=>kr(e.content).flatMap(e=>e.type===`text`?[e.text]:[]).join(`
|
package/dist/gateway/static/root/assets/{sessions-page-itpuSflW.js → sessions-page-DS-OExY1.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{m as i}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{i as a,l as o,n as s,o as c}from"./locale-store-CnHhWsDP.js";import{t as l}from"./messages-CZCXd6Pj.js";import{a as u,n as d,o as f,r as p,s as m,t as h}from"./dist-CY7CS_D3.js";import{n as g,r as _,t as v}from"./session-identity-label-DCIZvqbN.js";import{t as y}from"./archive-Dz0hferG.js";import{n as b,r as x}from"./popover-select-CLsphyzA.js";import{t as S}from"./circle-BoO4YvTx.js";import{t as C}from"./coins-DjP27vUx.js";import{t as w}from"./database-CjjeZfRG.js";import{t as T}from"./download-Dk-ZjtO6.js";import{t as E}from"./folder-open-CyzJ19I9.js";import{t as D}from"./layers-mJW7JJKm.js";import{t as O}from"./layout-grid-CEVZdVFU.js";import{t as k}from"./message-square-fVE7Ghj1.js";import{t as A}from"./minimize-2-DtOGrlpo.js";import{n as ee,t as j}from"./pin-off-BMRv-Kxr.js";import{t as M}from"./plus-Q2yW6OE7.js";import{t as N}from"./search-DA7gz22f.js";import{t as P}from"./settings-uiTATseT.js";import{t as F}from"./trash-2-DusmjVPV.js";import{t as te}from"./x-B_N4OPjy.js";import{t as I}from"./cn-0WouolD0.js";import{t as L}from"./skeleton-DzdOeGYz.js";import{a as R,c as z,f as B,n as V,o as ne,p as re,r as ie,s as ae,t as oe}from"./session-api-JAcSuzXh.js";import{t as se}from"./session-channel-icon-COynhpeK.js";import{i as ce}from"./vendor-swr-CdRzEUwF.js";import{n as H,r as le}from"./gateway-config-swr-C-cx4ObA.js";import{t as ue}from"./chat-agents-api-DI0TksSO.js";import{n as de,t as U}from"./registry-api-x3kjVVzC.js";import{t as W}from"./button-ChmVQg9O.js";import{i as fe,o as pe}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{n as G,t as me}from"./interaction-BdhHBbYa.js";import{s as K}from"./form-field-width-DJw_jULe.js";import{t as he}from"./page-tabs-oeTY7z3_.js";import{t as ge}from"./agent-avatar-display-BxHA8hEW.js";import{n as _e,r as ve}from"./segmented-styles-Cqb91xsn.js";import{n as ye,r as be,t as q}from"./settings-form-draft-Dy10ldo8.js";import{t as xe}from"./sliding-tab-list-CmcrqRzN.js";import{n as Se}from"./model-selector-D-9SUwg2.js";import{t as J}from"./settings-advanced-section-C-Rq-g2w.js";import{t as Y}from"./number-input-El7Szeln.js";import{n as Ce,t as we}from"./settings-page-header-BnBbewrE.js";import"./settings-page-layout-DgRq0a-W.js";import{n as Te,t as X}from"./settings-form-section-num14vSv.js";import{n as Ee,t as De}from"./use-autosave-BcgfZd3f.js";import{t as Oe}from"./settings-advanced-gate-BEDT8_0u.js";var Z=e(t(),1),ke=n(),Q=r();function Ae(e){let t=new Date(e),n=Math.floor((new Date().getTime()-t.getTime())/(1e3*60*60*24));return n===0?t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):n===1?`Yesterday`:n<7?t.toLocaleDateString([],{weekday:`short`}):t.toLocaleDateString([],{month:`short`,day:`numeric`})}function je(e,t){return new Intl.NumberFormat(t===`zh`?`zh-CN`:`en-US`).format(e)}function Me(e){return`$${Number(e).toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:6})}`}function Ne(e){let t=(0,ke.c)(124),{session:n,variant:r,labels:i,sessionAgentId:a,sessionAgentAvatar:o,onOpen:c,onAction:u}=e,d;t[0]!==i.unnamedSession||t[1]!==n.name?(d=n.name?.trim()||i.unnamedSession,t[0]=i.unnamedSession,t[1]=n.name,t[2]=d):d=t[2];let f=d,p=s(Le),m;t[3]!==p||t[4]!==n?(m=v(n,l(p).sidebar.sessionFilters),t[3]=p,t[4]=n,t[5]=m):m=t[5];let h=m,g;t[6]===n.name?g=t[7]:(g=n.name?.trim(),t[6]=n.name,t[7]=g);let b=!!g,x=n.status===`archived`,S=n.status===`pinned`,E=n.usage,D;t[8]!==i.costUnknown||t[9]!==i.noUsage||t[10]!==E?(D=E?.calls?E.costCompleteness===`unknown`?i.costUnknown:`${E.costCompleteness===`partial`?`≥ `:`≈ `}${Me(E.knownCostUsd)}`:i.noUsage,t[8]=i.costUnknown,t[9]=i.noUsage,t[10]=E,t[11]=D):D=t[11];let O=D,A=E?.calls?E.costCompleteness===`partial`?i.costPartial:E.costCompleteness===`unknown`?i.costUnknown:i.cost:i.noUsage,M=r===`list`&&`sm:flex-row sm:items-center sm:gap-4`,N;t[12]===M?N=t[13]:(N=I(`group flex min-w-0 w-full max-w-full cursor-pointer flex-col rounded-xl bg-surface-base text-left transition-colors duration-150 ease-out`,`hover:bg-surface-hover active:scale-[0.99]`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,M),t[12]=M,t[13]=N);let P;t[14]===c?P=t[15]:(P=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())},t[14]=c,t[15]=P);let te=r===`list`&&`sm:py-3`,L;t[16]===te?L=t[17]:(L=I(`flex min-w-0 items-start justify-between gap-2 bg-surface-hover/35 px-3 py-2 dark:bg-surface-hover/25`,te),t[16]=te,t[17]=L);let R;t[18]===n?R=t[19]:(R=(0,Q.jsx)(se,{sourceChannel:n.sourceChannel,session:n,className:`size-3.5`}),t[18]=n,t[19]=R);let z;t[20]===h?z=t[21]:(z=(0,Q.jsx)(`span`,{className:`truncate text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:h}),t[20]=h,t[21]=z);let B;t[22]!==R||t[23]!==z?(B=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[R,z]}),t[22]=R,t[23]=z,t[24]=B):B=t[24];let V;t[25]===S?V=t[26]:(V=S?(0,Q.jsx)(ee,{className:`size-3.5 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}):null,t[25]=S,t[26]=V);let ne;t[27]===n.updatedAt?ne=t[28]:(ne=Ae(n.updatedAt),t[27]=n.updatedAt,t[28]=ne);let re;t[29]===ne?re=t[30]:(re=(0,Q.jsx)(`span`,{children:ne}),t[29]=ne,t[30]=re);let ie;t[31]!==V||t[32]!==re?(ie=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-muted`,children:[V,re]}),t[31]=V,t[32]=re,t[33]=ie):ie=t[33];let ae;t[34]!==B||t[35]!==ie||t[36]!==L?(ae=(0,Q.jsxs)(`div`,{className:L,children:[B,ie]}),t[34]=B,t[35]=ie,t[36]=L,t[37]=ae):ae=t[37];let oe=r===`list`&&`sm:py-3`,ce;t[38]===oe?ce=t[39]:(ce=I(`min-w-0 flex-1 px-3 py-2`,oe),t[38]=oe,t[39]=ce);let H=r===`list`&&`sm:items-start`,le;t[40]===H?le=t[41]:(le=I(`flex gap-3`,H),t[40]=H,t[41]=le);let ue;t[42]!==o||t[43]!==a?(ue=(0,Q.jsx)(ge,{agentId:a,avatar:o,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}),t[42]=o,t[43]=a,t[44]=ue):ue=t[44];let de;t[45]===f?de=t[46]:(de=(0,Q.jsx)(`div`,{className:`min-w-0 max-w-full truncate text-sm font-semibold text-fg`,title:f,children:f}),t[45]=f,t[46]=de);let U;t[47]!==n.key||t[48]!==b?(U=b?(0,Q.jsx)(`div`,{className:`mt-0.5 min-w-0 max-w-full truncate font-mono text-[11px] text-fg-subtle`,title:n.key,children:n.key}):null,t[47]=n.key,t[48]=b,t[49]=U):U=t[49];let W;t[50]!==de||t[51]!==U?(W=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[de,U]}),t[50]=de,t[51]=U,t[52]=W):W=t[52];let fe;t[53]!==le||t[54]!==ue||t[55]!==W?(fe=(0,Q.jsxs)(`div`,{className:le,children:[ue,W]}),t[53]=le,t[54]=ue,t[55]=W,t[56]=fe):fe=t[56];let pe;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,Q.jsx)(k,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[57]=pe):pe=t[57];let G;t[58]===n.messageCount?G=t[59]:(G=(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[pe,n.messageCount]}),t[58]=n.messageCount,t[59]=G);let K;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,Q.jsx)(w,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[60]=K):K=t[60];let he=E?.totalTokens??0,_e;t[61]!==p||t[62]!==he?(_e=je(he,p),t[61]=p,t[62]=he,t[63]=_e):_e=t[63];let ve;t[64]!==i.tokens||t[65]!==_e?(ve=(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[K,_e,` `,i.tokens]}),t[64]=i.tokens,t[65]=_e,t[66]=ve):ve=t[66];let ye;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(ye=(0,Q.jsx)(C,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[67]=ye):ye=t[67];let be;t[68]!==O||t[69]!==A?(be=(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,title:A,children:[ye,O]}),t[68]=O,t[69]=A,t[70]=be):be=t[70];let q;t[71]!==G||t[72]!==ve||t[73]!==be?(q=(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3 text-xs text-fg-muted`,children:[G,ve,be]}),t[71]=G,t[72]=ve,t[73]=be,t[74]=q):q=t[74];let xe;t[75]===n.tags?xe=t[76]:(xe=n.tags.length>0?(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[n.tags.slice(0,3).map(Ie),n.tags.length>3?(0,Q.jsxs)(`span`,{className:`text-[11px] text-fg-disabled`,children:[`+`,n.tags.length-3]}):null]}):null,t[75]=n.tags,t[76]=xe);let Se;t[77]!==ce||t[78]!==fe||t[79]!==q||t[80]!==xe?(Se=(0,Q.jsxs)(`div`,{className:ce,children:[fe,q,xe]}),t[77]=ce,t[78]=fe,t[79]=q,t[80]=xe,t[81]=Se):Se=t[81];let J;t[82]===u?J=t[83]:(J=()=>u(`continue`),t[82]=u,t[83]=J);let Y;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(Y=(0,Q.jsx)(k,{className:`size-4`,strokeWidth:1.75}),t[84]=Y):Y=t[84];let Ce;t[85]!==i.continueChat||t[86]!==J?(Ce=(0,Q.jsx)(`button`,{type:`button`,className:me,title:i.continueChat,"aria-label":i.continueChat,onClick:J,children:Y}),t[85]=i.continueChat,t[86]=J,t[87]=Ce):Ce=t[87];let we;t[88]!==x||t[89]!==i.archive||t[90]!==i.unarchive||t[91]!==u?(we=x?(0,Q.jsx)(`button`,{type:`button`,className:me,title:i.unarchive,"aria-label":i.unarchive,onClick:()=>u(`unarchive`),children:(0,Q.jsx)(_,{className:`size-4`,strokeWidth:1.75})}):(0,Q.jsx)(`button`,{type:`button`,className:me,title:i.archive,"aria-label":i.archive,onClick:()=>u(`archive`),children:(0,Q.jsx)(y,{className:`size-4`,strokeWidth:1.75})}),t[88]=x,t[89]=i.archive,t[90]=i.unarchive,t[91]=u,t[92]=we):we=t[92];let Te;t[93]!==S||t[94]!==i.pin||t[95]!==i.unpin||t[96]!==u?(Te=S?(0,Q.jsx)(`button`,{type:`button`,className:me,title:i.unpin,"aria-label":i.unpin,onClick:()=>u(`unpin`),children:(0,Q.jsx)(j,{className:`size-4`,strokeWidth:1.75})}):(0,Q.jsx)(`button`,{type:`button`,className:me,title:i.pin,"aria-label":i.pin,onClick:()=>u(`pin`),children:(0,Q.jsx)(ee,{className:`size-4`,strokeWidth:1.75})}),t[93]=S,t[94]=i.pin,t[95]=i.unpin,t[96]=u,t[97]=Te):Te=t[97];let X;t[98]===u?X=t[99]:(X=()=>u(`export`),t[98]=u,t[99]=X);let Ee;t[100]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=(0,Q.jsx)(T,{className:`size-4`,strokeWidth:1.75}),t[100]=Ee):Ee=t[100];let De;t[101]!==i.export||t[102]!==X?(De=(0,Q.jsx)(`button`,{type:`button`,className:me,title:i.export,"aria-label":i.export,onClick:X,children:Ee}),t[101]=i.export,t[102]=X,t[103]=De):De=t[103];let Oe;t[104]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=I(me,`text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`),t[104]=Oe):Oe=t[104];let Z;t[105]===u?Z=t[106]:(Z=()=>u(`delete`),t[105]=u,t[106]=Z);let Ne;t[107]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=(0,Q.jsx)(F,{className:`size-4`,strokeWidth:1.75}),t[107]=Ne):Ne=t[107];let Re;t[108]!==i.delete||t[109]!==Z?(Re=(0,Q.jsx)(`button`,{type:`button`,className:Oe,title:i.delete,"aria-label":i.delete,onClick:Z,children:Ne}),t[108]=i.delete,t[109]=Z,t[110]=Re):Re=t[110];let ze;t[111]!==Ce||t[112]!==we||t[113]!==Te||t[114]!==De||t[115]!==Re?(ze=(0,Q.jsxs)(`div`,{role:`group`,className:`m-1 mt-0 flex flex-wrap items-center gap-0.5 rounded-lg bg-surface-hover/35 p-1.5`,onClick:Fe,onKeyDown:Pe,children:[Ce,we,Te,De,Re]}),t[111]=Ce,t[112]=we,t[113]=Te,t[114]=De,t[115]=Re,t[116]=ze):ze=t[116];let Be;return t[117]!==c||t[118]!==ae||t[119]!==Se||t[120]!==ze||t[121]!==N||t[122]!==P?(Be=(0,Q.jsxs)(`div`,{role:`button`,tabIndex:0,className:N,onClick:c,onKeyDown:P,children:[ae,Se,ze]}),t[117]=c,t[118]=ae,t[119]=Se,t[120]=ze,t[121]=N,t[122]=P,t[123]=Be):Be=t[123],Be}function Pe(e){return e.stopPropagation()}function Fe(e){return e.stopPropagation()}function Ie(e){return(0,Q.jsx)(`span`,{className:`max-w-full break-words rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:e},e)}function Le(e){return e.language}function Re(e,t){return e.routing?.agentId?.trim().toLowerCase()||t.trim().toLowerCase()||`main`}function ze(e,t){return t.find(t=>t.id===e)?.avatar}var Be={enabled:!0,triggerThreshold:.8,reserveTokens:8192,minMessagesBeforeCompact:10,keepRecentTokens:2e4,recentTurnsPreserve:3,summaryMaxTokens:16e3,summaryChunkTokens:24e3,summaryTimeoutMs:18e4,summaryRetries:2,qualityGuard:!0,gapAudit:!0,minToolResultKeepChars:1e3,maxActiveTranscriptBytes:2e6,postCompactionSections:[`Session Startup`,`Red Lines`]};function Ve(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function He(e,t,n,r=1/0){return typeof e==`number`&&Number.isFinite(e)&&e>=n&&e<=r?e:t}function Ue(e,t,n,r=1/0){return Number.isInteger(e)&&e>=n&&e<=r?e:t}function We(e){let t=Ve(e)?e:{},n=Ve(t.userContext)?t.userContext:{},r=Ve(n.contextPlanning)?n.contextPlanning:{},i=Ve(r.compaction)?r.compaction:{},a=Be,o=typeof i.model==`string`&&i.model.trim()?i.model.trim():void 0,s=Array.isArray(i.postCompactionSections)&&i.postCompactionSections.length<=12&&i.postCompactionSections.every(e=>typeof e==`string`&&e.trim())?[...new Set(i.postCompactionSections.map(e=>e.trim()))]:[...a.postCompactionSections];return{enabled:typeof i.enabled==`boolean`?i.enabled:a.enabled,triggerThreshold:He(i.triggerThreshold,a.triggerThreshold,.1,.98),reserveTokens:Ue(i.reserveTokens,a.reserveTokens,1024),minMessagesBeforeCompact:Ue(i.minMessagesBeforeCompact,a.minMessagesBeforeCompact,2),keepRecentTokens:Ue(i.keepRecentTokens,a.keepRecentTokens,1e3),recentTurnsPreserve:Ue(i.recentTurnsPreserve,a.recentTurnsPreserve,1,12),summaryMaxTokens:Ue(i.summaryMaxTokens,a.summaryMaxTokens,256),summaryChunkTokens:Ue(i.summaryChunkTokens,a.summaryChunkTokens,1e3),summaryTimeoutMs:Ue(i.summaryTimeoutMs,a.summaryTimeoutMs,1e3,6e5),summaryRetries:Ue(i.summaryRetries,a.summaryRetries,0,5),qualityGuard:typeof i.qualityGuard==`boolean`?i.qualityGuard:a.qualityGuard,gapAudit:typeof i.gapAudit==`boolean`?i.gapAudit:a.gapAudit,...o?{model:o}:{},minToolResultKeepChars:Ue(i.minToolResultKeepChars,a.minToolResultKeepChars,200),maxActiveTranscriptBytes:Ue(i.maxActiveTranscriptBytes,a.maxActiveTranscriptBytes,64e3),postCompactionSections:s}}function Ge(e){return e.triggerThreshold<.1||e.triggerThreshold>.98?`triggerThreshold`:!Number.isInteger(e.reserveTokens)||e.reserveTokens<1024?`reserveTokens`:!Number.isInteger(e.minMessagesBeforeCompact)||e.minMessagesBeforeCompact<2?`minMessagesBeforeCompact`:!Number.isInteger(e.keepRecentTokens)||e.keepRecentTokens<1e3?`keepRecentTokens`:!Number.isInteger(e.recentTurnsPreserve)||e.recentTurnsPreserve<1||e.recentTurnsPreserve>12?`recentTurnsPreserve`:!Number.isInteger(e.summaryMaxTokens)||e.summaryMaxTokens<256?`summaryMaxTokens`:!Number.isInteger(e.summaryChunkTokens)||e.summaryChunkTokens<1e3?`summaryChunkTokens`:!Number.isInteger(e.summaryTimeoutMs)||e.summaryTimeoutMs<1e3||e.summaryTimeoutMs>6e5?`summaryTimeoutMs`:!Number.isInteger(e.summaryRetries)||e.summaryRetries<0||e.summaryRetries>5?`summaryRetries`:e.model!==void 0&&!e.model.trim()?`model`:!Number.isInteger(e.minToolResultKeepChars)||e.minToolResultKeepChars<200?`minToolResultKeepChars`:!Number.isInteger(e.maxActiveTranscriptBytes)||e.maxActiveTranscriptBytes<64e3?`maxActiveTranscriptBytes`:e.postCompactionSections.length>12||e.postCompactionSections.some(e=>!e.trim())?`postCompactionSections`:null}function Ke(e){let t={...e,...e.model?.trim()?{model:e.model.trim()}:{}};return e.model?.trim()||delete t.model,{userContext:{contextPlanning:{compaction:t}}}}async function qe(e){await c(a(`/api/config`),{method:`PATCH`,body:JSON.stringify(Ke(e))}),await H()}var Je=128e3,Ye={balanced:Be,preserve:{...Be,triggerThreshold:.88,keepRecentTokens:32e3,recentTurnsPreserve:5,maxActiveTranscriptBytes:4e6},early:{...Be,triggerThreshold:.65,reserveTokens:12e3,minMessagesBeforeCompact:6,keepRecentTokens:12e3,recentTurnsPreserve:2}},Xe=q();function Ze(){return I(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg disabled:cursor-not-allowed disabled:opacity-55`,K,`dark:border-edge`)}function Qe(e){let{enabled:t,model:n,postCompactionSections:r,...i}=e;return JSON.stringify(i)}function $e(e){let t=Qe(e);for(let[e,n]of Object.entries(Ye))if(t===Qe(n))return e;return`custom`}function et(e){return e>=1e6?`${(e/1e6).toFixed(e%1e6==0?0:1)}m`:e>=1e3?`${(e/1e3).toFixed(e%1e3==0?0:1)}k`:String(e)}function $(e){let t=(0,ke.c)(20),{id:n,label:r,hint:i,value:a,min:o,max:s,step:c,disabled:l,onChange:u}=e,d=c===void 0?1:c,f;t[0]!==n||t[1]!==r?(f=(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:n,children:r}),t[0]=n,t[1]=r,t[2]=f):f=t[2];let p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=Ze(),t[3]=p):p=t[3];let m;t[4]===u?m=t[5]:(m=e=>{if(!e.target.value.trim())return;let t=Number(e.target.value);Number.isFinite(t)&&u(t)},t[4]=u,t[5]=m);let h;t[6]!==l||t[7]!==n||t[8]!==s||t[9]!==o||t[10]!==d||t[11]!==m||t[12]!==a?(h=(0,Q.jsx)(Y,{id:n,type:`number`,min:o,max:s,step:d,disabled:l,className:p,value:a,onChange:m}),t[6]=l,t[7]=n,t[8]=s,t[9]=o,t[10]=d,t[11]=m,t[12]=a,t[13]=h):h=t[13];let g;t[14]===i?g=t[15]:(g=i?(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i}):null,t[14]=i,t[15]=g);let _;return t[16]!==f||t[17]!==h||t[18]!==g?(_=(0,Q.jsxs)(`div`,{children:[f,h,g]}),t[16]=f,t[17]=h,t[18]=g,t[19]=_):_=t[19],_}function tt(e){let t=(0,ke.c)(19),{label:n,hint:r,checked:i,disabled:a,onChange:o}=e,s=a?`cursor-not-allowed opacity-55`:`cursor-pointer`,c;t[0]===s?c=t[1]:(c=I(`flex items-start gap-2 text-sm text-fg`,s),t[0]=s,t[1]=c);let l;t[2]===o?l=t[3]:(l=e=>o(e.target.checked),t[2]=o,t[3]=l);let u;t[4]!==i||t[5]!==a||t[6]!==l?(u=(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:i,disabled:a,onChange:l}),t[4]=i,t[5]=a,t[6]=l,t[7]=u):u=t[7];let d;t[8]===n?d=t[9]:(d=(0,Q.jsx)(`span`,{className:`font-medium`,children:n}),t[8]=n,t[9]=d);let f;t[10]===r?f=t[11]:(f=(0,Q.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:r}),t[10]=r,t[11]=f);let p;t[12]!==d||t[13]!==f?(p=(0,Q.jsxs)(`span`,{children:[d,f]}),t[12]=d,t[13]=f,t[14]=p):p=t[14];let m;return t[15]!==c||t[16]!==u||t[17]!==p?(m=(0,Q.jsxs)(`label`,{className:c,children:[u,p]}),t[15]=c,t[16]=u,t[17]=p,t[18]=m):m=t[18],m}function nt({hasToken:e}){let t=l(s(e=>e.language)).sessions.compaction,{data:n,isLoading:r}=le(e),{data:i=[],isLoading:a}=ce(e?U:null,de,{revalidateOnFocus:!1}),o=(0,Z.useMemo)(()=>n?.payload?.config===void 0?null:We(n.payload.config),[n]),[c,u]=(0,Z.useReducer)(Xe,{form:null,baseline:null}),[d,f]=(0,Z.useState)(``),p=(0,Z.useRef)(!1),m=(0,Z.useRef)(c.form);m.current=c.form;let h=(0,Z.useRef)(null);ye({enabled:e,parsed:o,dirty:p.current,trackedParsedRef:h,dispatch:u,onResetDirty:()=>{p.current=!1}});let g=c.form,_=c.baseline,v=!!(g&&_&&JSON.stringify(g)!==JSON.stringify(_)),y=(0,Z.useCallback)(e=>{p.current=!0,u({type:`patch`,patch:e})},[]),b=(0,Z.useCallback)(e=>({enabled:t.enabled,triggerThreshold:t.triggerThreshold,reserveTokens:t.reserveTokens,minMessagesBeforeCompact:t.minMessagesBeforeCompact,keepRecentTokens:t.keepRecentTokens,recentTurnsPreserve:t.recentTurnsPreserve,summaryMaxTokens:t.summaryMaxTokens,summaryChunkTokens:t.summaryChunkTokens,summaryTimeoutMs:t.summaryTimeoutSeconds,summaryRetries:t.summaryRetries,qualityGuard:t.qualityGuard,gapAudit:t.gapAudit,model:t.summaryModel,minToolResultKeepChars:t.minToolResultKeepChars,maxActiveTranscriptBytes:t.maxActiveTranscriptMb,postCompactionSections:t.postCompactionSections})[e],[t]),x=De({value:g,dirty:v,onSave:(0,Z.useCallback)(async e=>{try{await qe(e),u({type:`saved`,value:e}),p.current=!!(m.current&&JSON.stringify(m.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError]),validate:e=>{let n=Ge(e);return n?t.invalidValue.replace(`{{field}}`,b(n)):null}});if(!e||!g)return r?(0,Q.jsx)(X,{children:(0,Q.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Q.jsx)(L,{className:`h-5 w-48`}),(0,Q.jsx)(L,{className:`h-20 w-full rounded-xl`}),(0,Q.jsx)(L,{className:`h-36 w-full rounded-xl`})]})}):null;let S=$e(g),C=Math.max(0,Je-g.reserveTokens),w=Math.min(Math.floor(Je*g.triggerThreshold),C),T=Math.min(100,w/Je*100),E=Math.min(100,C/Je*100),D=g.model?i.find(e=>e.id===g.model):void 0,O=D?.contextWindow&&g.summaryChunkTokens+g.summaryMaxTokens+4096>D.contextWindow,k=g.keepRecentTokens+g.reserveTokens>w,ee=Math.round(g.summaryTimeoutMs*(g.summaryRetries+1)/1e3),j=e=>{let t=Ye[e];y({...t,...g.model?{model:g.model}:{model:void 0},postCompactionSections:g.postCompactionSections})},N={balanced:{title:t.presetBalanced,hint:t.presetBalancedHint},preserve:{title:t.presetPreserve,hint:t.presetPreserveHint},early:{title:t.presetEarly,hint:t.presetEarlyHint}},P=()=>{let e=d.trim();!e||g.postCompactionSections.includes(e)||g.postCompactionSections.length>=12||(y({postCompactionSections:[...g.postCompactionSections,e]}),f(``))};return(0,Q.jsxs)(X,{onBlurCapture:x.onBlurCapture,children:[(0,Q.jsx)(Te,{icon:A,title:t.title,subtitle:t.hint,trailing:(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(Ee,{status:x.status,error:x.error}),(0,Q.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm font-medium text-fg`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:g.enabled,onChange:e=>y({enabled:e.target.checked})}),g.enabled?t.enabled:t.disabled]})]})}),x.error?(0,Q.jsx)(`p`,{className:`mb-4 rounded-lg bg-red-50 px-3 py-2 text-sm text-red-700 dark:bg-red-950/40 dark:text-red-300`,role:`alert`,children:x.error}):null,g.enabled?null:(0,Q.jsx)(`p`,{className:`mb-4 rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.disabledWarning}),(0,Q.jsxs)(`fieldset`,{disabled:!g.enabled,className:`space-y-5 disabled:opacity-60`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.presetTitle}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.presetHint})]}),S===`custom`?(0,Q.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-1 text-[11px] font-medium text-fg-muted`,children:t.presetCustom}):null]}),(0,Q.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[`balanced`,`preserve`,`early`].map(e=>(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":S===e,className:I(`rounded-xl bg-surface-base/55 px-3 py-3 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,G.transition,G.focusRingPanel,S===e?`bg-accent-soft text-accent-fg shadow-surface`:`text-fg hover:bg-surface-hover`),onClick:()=>j(e),children:[(0,Q.jsx)(`span`,{className:`block text-sm font-medium`,children:N[e].title}),(0,Q.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:N[e].hint})]},e))})]}),(0,Q.jsxs)(J,{title:t.advancedTitle,summary:S===`custom`?t.presetCustom:t.presetHint,children:[(0,Q.jsxs)(`div`,{className:`rounded-xl bg-surface-base/45 p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.budgetPreview}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.budgetPreviewHint})]}),(0,Q.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2.5 py-1 font-mono text-xs text-fg-muted`,children:t.previewModel128k})]}),(0,Q.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`mb-1 flex justify-between gap-3 text-xs text-fg-muted`,children:[(0,Q.jsx)(`span`,{children:t.compactionTrigger}),(0,Q.jsx)(`span`,{className:`font-mono text-fg`,children:et(w)})]}),(0,Q.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,Q.jsx)(`div`,{className:`h-full rounded-full bg-accent`,style:{width:`${T}%`}})})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`mb-1 flex justify-between gap-3 text-xs text-fg-muted`,children:[(0,Q.jsx)(`span`,{children:t.hardInputLimit}),(0,Q.jsx)(`span`,{className:`font-mono text-fg`,children:et(C)})]}),(0,Q.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,Q.jsx)(`div`,{className:`h-full rounded-full bg-fg-subtle`,style:{width:`${E}%`}})})]})]}),(0,Q.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:t.budgetFormula})]}),(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Q.jsx)($,{id:`compaction-trigger-threshold`,label:t.triggerThreshold,hint:t.triggerThresholdHint,value:Number((g.triggerThreshold*100).toFixed(2)),min:10,max:98,step:.1,onChange:e=>y({triggerThreshold:e/100})}),(0,Q.jsx)($,{id:`compaction-reserve-tokens`,label:t.reserveTokens,hint:t.reserveTokensHint.replace(`{{tokens}}`,et(g.reserveTokens)),value:g.reserveTokens,min:1024,step:1024,onChange:e=>y({reserveTokens:Math.floor(e)})}),(0,Q.jsx)($,{id:`compaction-recent-turns`,label:t.recentTurnsPreserve,hint:t.recentTurnsPreserveHint,value:g.recentTurnsPreserve,min:1,max:12,onChange:e=>y({recentTurnsPreserve:Math.floor(e)})}),(0,Q.jsx)($,{id:`compaction-keep-recent-tokens`,label:t.keepRecentTokens,hint:t.keepRecentTokensHint.replace(`{{tokens}}`,et(g.keepRecentTokens)),value:g.keepRecentTokens,min:1e3,step:1e3,onChange:e=>y({keepRecentTokens:Math.floor(e)})})]}),k?(0,Q.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.retentionWarning}):null,(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.summaryModel}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 gap-2`,children:[(0,Q.jsx)(Se,{value:g.model??``,disabled:!g.enabled,placeholder:t.summaryModelInherited,searchPlaceholder:t.summaryModelSearch,noMatches:t.summaryModelNoMatches,models:i,modelsLoading:a,className:`min-w-0 flex-1 justify-between`,contentAlign:`start`,showProviderSettingsFooter:!0,onChange:e=>y({model:e})}),g.model?(0,Q.jsx)(W,{type:`button`,variant:`secondary`,onClick:()=>y({model:void 0}),children:t.summaryModelUseSession}):null]}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.summaryModelHint})]}),(0,Q.jsx)(tt,{label:t.qualityGuard,hint:t.qualityGuardHint,checked:g.qualityGuard,onChange:e=>y({qualityGuard:e})}),(0,Q.jsx)(tt,{label:t.gapAudit,hint:t.gapAuditHint,checked:g.gapAudit,onChange:e=>y({gapAudit:e})})]}),g.qualityGuard?null:(0,Q.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.qualityGuardWarning})]}),(0,Q.jsx)(Oe,{children:(0,Q.jsxs)(`div`,{className:`space-y-5 rounded-xl bg-surface-base/45 p-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:t.advancedTitle}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.advancedHint})]}),(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Q.jsx)($,{id:`compaction-min-messages`,label:t.minMessagesBeforeCompact,hint:t.minMessagesBeforeCompactHint,value:g.minMessagesBeforeCompact,min:2,onChange:e=>y({minMessagesBeforeCompact:Math.floor(e)})}),(0,Q.jsx)($,{id:`compaction-max-transcript-mb`,label:t.maxActiveTranscriptMb,hint:t.maxActiveTranscriptMbHint,value:Number((g.maxActiveTranscriptBytes/1e6).toFixed(3)),min:.064,step:.1,onChange:e=>y({maxActiveTranscriptBytes:Math.max(64e3,Math.round(e*1e6))})}),(0,Q.jsx)($,{id:`compaction-summary-max-tokens`,label:t.summaryMaxTokens,hint:t.summaryMaxTokensHint,value:g.summaryMaxTokens,min:256,step:256,onChange:e=>y({summaryMaxTokens:Math.floor(e)})}),(0,Q.jsx)($,{id:`compaction-summary-chunk-tokens`,label:t.summaryChunkTokens,hint:t.summaryChunkTokensHint,value:g.summaryChunkTokens,min:1e3,step:1e3,onChange:e=>y({summaryChunkTokens:Math.floor(e)})}),(0,Q.jsx)($,{id:`compaction-summary-timeout`,label:t.summaryTimeoutSeconds,hint:t.summaryTimeoutSecondsHint.replace(`{{seconds}}`,String(ee)),value:g.summaryTimeoutMs/1e3,min:1,max:600,onChange:e=>y({summaryTimeoutMs:Math.round(e*1e3)})}),(0,Q.jsx)($,{id:`compaction-summary-retries`,label:t.summaryRetries,hint:t.summaryRetriesHint,value:g.summaryRetries,min:0,max:5,onChange:e=>y({summaryRetries:Math.floor(e)})}),(0,Q.jsx)($,{id:`compaction-min-tool-result-chars`,label:t.minToolResultKeepChars,hint:t.minToolResultKeepCharsHint,value:g.minToolResultKeepChars,min:200,step:100,onChange:e=>y({minToolResultKeepChars:Math.floor(e)})})]}),O?(0,Q.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.summaryBudgetWarning}):null,(0,Q.jsxs)(`div`,{className:`rounded-xl bg-surface-base/45 p-4`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.postCompactionSections}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.postCompactionSectionsHint}),g.postCompactionSections.length>0?(0,Q.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:g.postCompactionSections.map(e=>(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs text-fg`,children:[e,(0,Q.jsx)(`button`,{type:`button`,className:I(`text-fg-muted hover:text-fg`,G.press),"aria-label":t.removeSection.replace(`{{section}}`,e),onClick:()=>y({postCompactionSections:g.postCompactionSections.filter(t=>t!==e)}),children:(0,Q.jsx)(te,{className:`size-3.5`,"aria-hidden":!0})})]},e))}):(0,Q.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.postCompactionSectionsEmpty}),(0,Q.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,Q.jsx)(`input`,{className:Ze(),value:d,maxLength:120,disabled:g.postCompactionSections.length>=12,placeholder:t.postCompactionSectionsPlaceholder,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),P())}}),(0,Q.jsxs)(W,{type:`button`,variant:`secondary`,disabled:!d.trim()||g.postCompactionSections.length>=12,onClick:P,children:[(0,Q.jsx)(M,{className:`size-4`,"aria-hidden":!0}),t.addSection]})]})]})]})})]})]})}function rt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function it(e){return e===`main`||e===`per-peer`||e===`per-channel-peer`||e===`per-account-channel-peer`?e:`main`}function at(e){let t=rt(e)?e:{},n=rt(t.session)?t.session:{},r=rt(n.storage)?n.storage:{},i=typeof r.pruneAfterDays==`number`&&Number.isFinite(r.pruneAfterDays)?Math.max(0,Math.floor(r.pruneAfterDays)):typeof r.pruneAfterMs==`number`&&Number.isFinite(r.pruneAfterMs)?Math.max(0,Math.round(r.pruneAfterMs/864e5)):null,a=typeof r.maxEntries==`number`&&Number.isFinite(r.maxEntries)?Math.max(1,Math.floor(r.maxEntries)):null;return{dmScope:it(n.dmScope),pruneAfterDays:i,maxEntries:a}}async function ot(e){await c(a(`/api/config`),{method:`PATCH`,body:JSON.stringify({session:{dmScope:e.dmScope,storage:{pruneAfterMs:e.pruneAfterDays===null?null:e.pruneAfterDays*864e5,maxEntries:e.maxEntries}}})}),H()}function st(){return I(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,K,`dark:border-edge`)}var ct=q();function lt({hasToken:e}){let t=l(s(e=>e.language)).sessions.config,{data:n,isLoading:r}=le(e),i=(0,Z.useMemo)(()=>n?.payload?.config===void 0?null:at(n.payload.config),[n]),[a,o]=(0,Z.useReducer)(ct,{form:null,baseline:null}),c=a.form,u=a.baseline,d=(0,Z.useRef)(!1),f=(0,Z.useRef)(c);f.current=c;let p=(0,Z.useRef)(null);ye({enabled:e,parsed:i,dirty:d.current,trackedParsedRef:p,dispatch:o,onResetDirty:()=>{d.current=!1}});let m=!!(c&&u&&JSON.stringify(c)!==JSON.stringify(u)),h=(0,Z.useCallback)(e=>{d.current=!0,o({type:`patch`,patch:e})},[]),g=De({value:c,dirty:m,onSave:(0,Z.useCallback)(async e=>{try{await ot(e),o({type:`saved`,value:e}),d.current=!!(f.current&&JSON.stringify(f.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError])});return!e||!c?r?(0,Q.jsx)(X,{children:(0,Q.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Q.jsx)(L,{className:`h-5 w-40`}),(0,Q.jsx)(L,{className:`h-24 w-full rounded-xl`})]})}):null:(0,Q.jsxs)(X,{onBlurCapture:g.onBlurCapture,children:[(0,Q.jsx)(Te,{icon:w,title:t.title,subtitle:t.hint,trailing:(0,Q.jsx)(Ee,{status:g.status,error:g.error})}),(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Q.jsx)(J,{title:t.dmScope,summary:c.dmScope,children:(0,Q.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.dmScope}),(0,Q.jsxs)(b,{className:st(),value:c.dmScope,onChange:e=>h({dmScope:e.target.value}),children:[(0,Q.jsx)(x,{value:`main`,children:t.dmScopeMain}),(0,Q.jsx)(x,{value:`per-peer`,children:t.dmScopePerPeer}),(0,Q.jsx)(x,{value:`per-channel-peer`,children:t.dmScopePerChannelPeer}),(0,Q.jsx)(x,{value:`per-account-channel-peer`,children:t.dmScopePerAccountChannelPeer})]}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.dmScopeHint})]})}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.pruneAfterDays}),(0,Q.jsx)(Y,{allowEmpty:!0,type:`number`,min:0,className:st(),value:c.pruneAfterDays??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();h({pruneAfterDays:t===``?null:Math.max(0,Math.floor(Number(t)||0))})}})]}),(0,Q.jsx)(J,{title:t.maxEntries,summary:c.maxEntries??t.unsetPlaceholder,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.maxEntries}),(0,Q.jsx)(Y,{allowEmpty:!0,type:`number`,min:1,className:st(),value:c.maxEntries??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();h({maxEntries:t===``?null:Math.max(1,Math.floor(Number(t)||1))})}})]})})]})]})}function ut(e){if(typeof e==`string`)return e.length>2e3?`${e.slice(0,2e3)}…`:e;try{let t=JSON.stringify(e,null,2);return t.length>2e3?`${t.slice(0,2e3)}…`:t}catch{return String(e)}}function dt(e){let t=(0,ke.c)(60),{open:n,loading:r,session:i,sessionAgentId:a,sessionAgentAvatar:o,labels:s,onClose:c,onArchive:l,onUnarchive:g,onPin:_,onUnpin:v,onExport:y,onDelete:b}=e,x=i?.status===`archived`,S=i?.status===`pinned`,C;t[0]===c?C=t[1]:(C=e=>!e&&c(),t[0]=c,t[1]=C);let w;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Q.jsx)(u,{className:I(`xopc-dialog-overlay fixed inset-0 bg-scrim`,pe)}),t[2]=w):w=t[2];let T;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(T=I(`xopc-drawer-right fixed right-0 top-0 flex size-full max-w-lg flex-col border-l border-edge bg-surface-overlay shadow-popover outline-none`,fe,`dark:border-edge`),t[3]=T):T=t[3];let E;t[4]!==i||t[5]!==o||t[6]!==a?(E=i&&a?(0,Q.jsx)(ge,{agentId:a,avatar:o,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}):null,t[4]=i,t[5]=o,t[6]=a,t[7]=E):E=t[7];let D;t[8]!==s.unnamedSession||t[9]!==i?.name?(D=i?.name?.trim()||s.unnamedSession,t[8]=s.unnamedSession,t[9]=i?.name,t[10]=D):D=t[10];let O;t[11]===D?O=t[12]:(O=(0,Q.jsx)(m,{className:`min-w-0 flex-1 truncate text-base font-semibold tracking-tight text-fg`,children:D}),t[11]=D,t[12]=O);let k;t[13]!==E||t[14]!==O?(k=(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[E,O]}),t[13]=E,t[14]=O,t[15]=k):k=t[15];let A;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Q.jsx)(te,{className:`size-5`,strokeWidth:1.75}),t[16]=A):A=t[16];let ee;t[17]===s.close?ee=t[18]:(ee=(0,Q.jsx)(d,{asChild:!0,children:(0,Q.jsx)(W,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":s.close,children:A})}),t[17]=s.close,t[18]=ee);let j;t[19]!==k||t[20]!==ee?(j=(0,Q.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3 dark:border-edge`,children:[k,ee]}),t[19]=k,t[20]=ee,t[21]=j):j=t[21];let M;t[22]!==s.detailLoading||t[23]!==s.detailMessages||t[24]!==r||t[25]!==i?(M=r?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:s.detailLoading}):i?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`dl`,{className:`mb-4 grid gap-2 text-xs text-fg-muted`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-fg-disabled`,children:`Key`}),(0,Q.jsx)(`dd`,{className:`mt-0.5 break-all font-mono text-fg`,children:i.key})]}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-4`,children:(0,Q.jsxs)(`span`,{children:[i.messageCount,` msgs · `,i.estimatedTokens,` tok`]})})]}),(0,Q.jsx)(`h3`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:s.detailMessages}),(0,Q.jsx)(`ul`,{className:`space-y-3`,children:i.messages.map(ft)})]}):null,t[22]=s.detailLoading,t[23]=s.detailMessages,t[24]=r,t[25]=i,t[26]=M):M=t[26];let N;t[27]===M?N=t[28]:(N=(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:M}),t[27]=M,t[28]=N);let P;t[29]!==s.detailExport||t[30]!==y?(P=(0,Q.jsx)(W,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:y,children:s.detailExport}),t[29]=s.detailExport,t[30]=y,t[31]=P):P=t[31];let F;t[32]!==x||t[33]!==s.archive||t[34]!==s.unarchive||t[35]!==l||t[36]!==g?(F=x?(0,Q.jsx)(W,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:g,children:s.unarchive}):(0,Q.jsx)(W,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:l,children:s.archive}),t[32]=x,t[33]=s.archive,t[34]=s.unarchive,t[35]=l,t[36]=g,t[37]=F):F=t[37];let L;t[38]!==S||t[39]!==s.pin||t[40]!==s.unpin||t[41]!==_||t[42]!==v?(L=S?(0,Q.jsx)(W,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:v,children:s.unpin}):(0,Q.jsx)(W,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:_,children:s.pin}),t[38]=S,t[39]=s.pin,t[40]=s.unpin,t[41]=_,t[42]=v,t[43]=L):L=t[43];let R;t[44]!==s.delete||t[45]!==b?(R=(0,Q.jsx)(W,{type:`button`,variant:`secondary`,className:`text-sm text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`,onClick:b,children:s.delete}),t[44]=s.delete,t[45]=b,t[46]=R):R=t[46];let z;t[47]!==P||t[48]!==F||t[49]!==L||t[50]!==R?(z=(0,Q.jsx)(`div`,{className:`shrink-0 border-t border-edge px-4 py-3 dark:border-edge`,children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[P,F,L,R]})}),t[47]=P,t[48]=F,t[49]=L,t[50]=R,t[51]=z):z=t[51];let B;t[52]!==j||t[53]!==N||t[54]!==z?(B=(0,Q.jsxs)(f,{children:[w,(0,Q.jsxs)(p,{className:T,"aria-describedby":void 0,children:[j,N,z]})]}),t[52]=j,t[53]=N,t[54]=z,t[55]=B):B=t[55];let V;return t[56]!==n||t[57]!==C||t[58]!==B?(V=(0,Q.jsx)(h,{open:n,onOpenChange:C,children:B}),t[56]=n,t[57]=C,t[58]=B,t[59]=V):V=t[59],V}function ft(e){return(0,Q.jsxs)(`li`,{className:`rounded-lg border border-edge-subtle bg-surface-hover/50 p-2 dark:border-edge`,children:[(0,Q.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase text-fg-subtle`,children:e.role}),(0,Q.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed text-fg-muted`,children:ut(e.content)})]},`${e.timestamp??``}-${e.role}-${ut(e.content).slice(0,24)}`)}var pt=20;function mt(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}var ht=new Set([`all`,`active`,`pinned`,`archived`]),gt=new Set([`grid`,`list`]),_t=[`sessions`,`settings`];function vt(e){return e&&_t.includes(e)?e:`sessions`}function yt(e,t){return t===`sessions`?e.tabsSessions:e.tabsSettings}function bt(e,t){return t===`sessions`?e.tabsSessionsHint:e.tabsSettingsHint}function xt(e){let t=(0,ke.c)(7),{s:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=_t.map(e=>({id:e,label:yt(n,e),icon:e===`sessions`?D:P})),t[0]=n,t[1]=a);let o=a,s;return t[2]!==r||t[3]!==o||t[4]!==i||t[5]!==n.tabsAriaLabel?(s=(0,Q.jsx)(he,{items:o,activeTab:r,onChange:i,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`sessions-tab`,panelIdPrefix:`sessions-panel`}),t[2]=r,t[3]=o,t[4]=i,t[5]=n.tabsAriaLabel,t[6]=s):s=t[6],s}function St(e){let t=(0,ke.c)(10),{s:n,id:r,activeTab:i,plain:a,children:o}=e,s=a!==void 0&&a;if(i!==r)return null;let c=`sessions-panel-${r}`,l=`sessions-tab-${r}`,u=s?`contents`:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,d;t[0]!==o||t[1]!==r||t[2]!==s||t[3]!==n?(d=s?o:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`mb-5`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:yt(n,r)}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:bt(n,r)})]}),(0,Q.jsx)(`div`,{className:`space-y-4`,children:o})]}),t[0]=o,t[1]=r,t[2]=s,t[3]=n,t[4]=d):d=t[4];let f;return t[5]!==c||t[6]!==l||t[7]!==u||t[8]!==d?(f=(0,Q.jsx)(`section`,{id:c,role:`tabpanel`,"aria-labelledby":l,className:u,children:d}),t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f):f=t[9],f}function Ct(e){let t=e.get(`status`),n=e.get(`view`);return{searchInput:e.get(`q`)??``,debouncedSearch:(e.get(`q`)??``).trim(),statusFilter:ht.has(t)?t:`all`,viewMode:gt.has(n)?n:`grid`,channelFilter:(e.get(`channel`)??``).trim(),sessions:[],loading:!1,error:null,hasMore:!1,stats:null,detailOpen:!1,detailLoading:!1,detailSession:null,confirmOpen:!1,confirmKey:null}}function wt(){let e=l(s(e=>e.language)),t=e.sessions,n=o(e=>e.conversationId),r=!!n,{data:a,mutate:c}=ce(r?[`gateway-chat-agents`,n]:null,ue,{revalidateOnFocus:!1}),d=a?.defaultId??`main`,_=a?.items??[],[v,b]=i(),x=vt(v.get(`tab`)),C=(0,Z.useCallback)(e=>{let t=new URLSearchParams(v);e===`sessions`?t.delete(`tab`):t.set(`tab`,e),b(t,{replace:!0})},[v,b]),[w,T]=(0,Z.useReducer)(be,v,Ct),{searchInput:k,debouncedSearch:A,statusFilter:j,viewMode:M,channelFilter:P,sessions:F,loading:te,error:L,hasMore:se,stats:H,detailOpen:le,detailLoading:de,detailSession:U,confirmOpen:me,confirmKey:K}=w;(0,Z.useEffect)(()=>{let e=setTimeout(()=>{let e=k.trim();A!==e&&T({type:`patch`,patch:{debouncedSearch:e}})},300);return()=>clearTimeout(e)},[k,A]);let he=v.toString(),ge=(0,Z.useRef)(he);if(ge.current!==he){ge.current=he;let e=v.get(`q`)??``,t=v.get(`status`),n=v.get(`view`),r=(v.get(`channel`)??``).trim(),i=ht.has(t)?t:`all`,a=gt.has(n)?n:`grid`,o=e.trim();T({type:`patch`,patch:{...k===e?{}:{searchInput:e},...A===o?{}:{debouncedSearch:o},...j===i?{}:{statusFilter:i},...M===a?{}:{viewMode:a},...P===r?{}:{channelFilter:r}}})}(0,Z.useEffect)(()=>{let e=new URLSearchParams(v),t=A.trim();t?e.set(`q`,t):e.delete(`q`),j===`all`?e.delete(`status`):e.set(`status`,j),M===`grid`?e.delete(`view`):e.set(`view`,M),P?e.set(`channel`,P):e.delete(`channel`),e.toString()!==v.toString()&&b(e,{replace:!0})},[A,v,b,j,M,P]),(0,Z.useEffect)(()=>{if(!r||x!==`sessions`)return;let e=!1;return(async()=>{T({type:`patch`,patch:{loading:!0,error:null}});try{let t=await ae({limit:pt,offset:0,...A?{search:A}:{},...j===`all`?{}:{status:j},...P?{channel:P}:{}});if(e)return;T({type:`patch`,patch:{sessions:t.items,hasMore:t.hasMore}})}catch(n){e||T({type:`patch`,patch:{error:n instanceof Error?n.message:t.loadError}})}finally{e||T({type:`patch`,patch:{loading:!1}})}})(),()=>{e=!0}},[r,x,A,j,P,t.loadError]),(0,Z.useEffect)(()=>{!r||x!==`sessions`||ne().then(e=>T({type:`patch`,patch:{stats:e}})).catch(()=>{})},[r,x]),(0,Z.useEffect)(()=>{if(!r||x!==`sessions`)return;let e=()=>void c();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[r,x,c]),(0,Z.useEffect)(()=>{if(!r||x!==`sessions`)return;let e=e=>{let t=e.detail;!t?.key||t.name===void 0||T({type:`patch`,patch:{sessions:F.map(e=>e.key===t.key?{...e,name:t.name}:e),detailSession:U&&U.key===t.key?{...U,name:t.name}:U}})};return window.addEventListener(`session-updated`,e),()=>{window.removeEventListener(`session-updated`,e)}},[r,x,F,U]);let ye=(0,Z.useCallback)(async()=>{if(!(!r||te||!se)){T({type:`patch`,patch:{loading:!0,error:null}});try{let e=await ae({limit:pt,offset:F.length,...A?{search:A}:{},...j===`all`?{}:{status:j},...P?{channel:P}:{}});T({type:`patch`,patch:{sessions:[...F,...e.items],hasMore:e.hasMore}})}catch(e){T({type:`patch`,patch:{error:e instanceof Error?e.message:t.loadError}})}finally{T({type:`patch`,patch:{loading:!1}})}}},[r,te,se,F.length,A,j,P,t.loadError]),q=(0,Z.useCallback)((e,t)=>{T({type:`patch`,patch:{sessions:F.map(n=>n.key===e?{...n,status:t}:n),detailSession:U&&U.key===e?{...U,status:t}:U}})},[F,U]),Se=(0,Z.useCallback)(async e=>{T({type:`patch`,patch:{detailOpen:!0,detailLoading:!0,detailSession:null}});try{let t=await R(e);T({type:`patch`,patch:{detailSession:t}})}catch{T({type:`patch`,patch:{detailOpen:!1}})}finally{T({type:`patch`,patch:{detailLoading:!1}})}},[]),J=e=>{Se(e)},Y=async(e,t)=>{if(t===`continue`){window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{conversationId:e},bubbles:!0}));return}if(t===`delete`){T({type:`patch`,patch:{confirmKey:e,confirmOpen:!0}});return}try{switch(t){case`archive`:await oe(e),q(e,`archived`);break;case`unarchive`:await B(e),q(e,`active`);break;case`pin`:await z(e),q(e,`pinned`);break;case`unpin`:await re(e),q(e,`active`);break;case`export`:{let t=await ie(e),n=new Blob([t],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`session-${e.replace(/[^a-z0-9]/gi,`_`)}.json`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r);break}default:break}ne().then(e=>T({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},Te=async e=>{try{await V(e),T({type:`patch`,patch:{sessions:F.filter(t=>t.key!==e),detailSession:U?.key===e?null:U,...U?.key===e?{detailOpen:!1}:{}}}),ne().then(e=>T({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},X={continueChat:t.continueChat,archive:t.archive,unarchive:t.unarchive,pin:t.pin,unpin:t.unpin,export:t.export,delete:t.delete,tokens:t.tokens,cost:t.cost,costPartial:t.costPartial,costUnknown:t.costUnknown,noUsage:t.noUsage,unnamedSession:e.chat.newSession},Ee={close:t.close,detailLoading:t.detailLoading,detailMessages:t.detailMessages,detailExport:t.detailExport,archive:t.archive,unarchive:t.unarchive,pin:t.pin,unpin:t.unpin,delete:t.delete,unnamedSession:e.chat.newSession},De=[{key:`all`,label:t.filterAll,icon:D},{key:`active`,label:t.filterActive,icon:S},{key:`pinned`,label:t.filterPinned,icon:ee},{key:`archived`,label:t.filterArchived,icon:y}],Oe=(()=>{let e=Object.entries(H?.byChannel??{}).sort((e,t)=>t[1]-e[1]).slice(0,6).map(([e])=>e),t=new Set(e);for(let n of[`telegram`,`weixin`,`feishu`])t.has(n)||(e.push(n),t.add(n));return e.slice(0,8)})();return r?(0,Q.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden bg-surface-panel`,children:[(0,Q.jsxs)(Ce,{gap:`gap-6`,children:[(0,Q.jsx)(we,{title:t.title}),(0,Q.jsx)(xt,{s:t,activeTab:x,onChange:C}),(0,Q.jsx)(St,{s:t,id:`settings`,activeTab:x,plain:!0,children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(nt,{hasToken:r}),(0,Q.jsx)(lt,{hasToken:r})]})}),(0,Q.jsxs)(St,{s:t,id:`sessions`,activeTab:x,plain:!0,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between`,children:[(0,Q.jsx)(xe,{className:`flex flex-wrap gap-2`,role:`group`,"aria-label":t.tabsSessions,indicatorClassName:`rounded-xl bg-accent-soft`,children:De.map(({key:e,label:t,icon:n})=>(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":j===e,onClick:()=>T({type:`patch`,patch:{statusFilter:e}}),className:I(`inline-flex items-center gap-1.5 rounded-xl px-3 py-2 text-sm font-medium`,G.transition,G.focusRingPanel,j===e?`bg-accent-soft text-accent-fg`:`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`),children:[(0,Q.jsx)(n,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t]},e))}),(0,Q.jsxs)(`div`,{className:`flex min-h-11 w-full min-w-0 items-center gap-2 rounded-xl bg-surface-base focus-within:ring-2 focus-within:ring-accent px-3 py-2 transition-colors lg:max-w-md dark:bg-surface-hover/40`,children:[(0,Q.jsx)(N,{className:`size-4 shrink-0 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`input`,{type:`search`,value:k,onChange:e=>T({type:`patch`,patch:{searchInput:e.target.value}}),placeholder:t.searchPlaceholder,"aria-label":t.searchPlaceholder,"data-debounced-query":A||void 0,className:`min-w-0 flex-1 border-0 bg-transparent text-base sm:text-sm text-fg placeholder:text-fg-disabled focus:outline-none focus:ring-0`})]})]}),(0,Q.jsxs)(xe,{className:`flex flex-wrap items-center gap-2`,role:`group`,"aria-label":t.filterChannelLabel,indicatorClassName:`rounded-xl bg-accent-soft`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg-subtle`,children:t.filterChannelLabel}),(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":!P,onClick:()=>T({type:`patch`,patch:{channelFilter:``}}),className:I(`touch-target inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,G.transition,G.focusRingPanel,P?`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`:`bg-accent-soft text-accent-fg`),children:t.filterChannelAll}),Oe.map(e=>(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":P===e,onClick:()=>T({type:`patch`,patch:{channelFilter:e}}),className:I(`touch-target inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,G.transition,G.focusRingPanel,P===e?`bg-accent-soft text-accent-fg`:`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`),children:[e,H?.byChannel?.[e]==null?null:(0,Q.jsx)(`span`,{className:`ml-2 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] text-fg-subtle`,children:H.byChannel[e]})]},e))]}),H?(0,Q.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[[H.totalSessions,t.totalSessions],[H.activeSessions,t.activeSessions],[H.pinnedSessions,t.pinnedSessions],[H.archivedSessions,t.archivedSessions]].map(([e,t])=>(0,Q.jsxs)(`div`,{className:`rounded-xl bg-surface-base p-3 dark:bg-surface-hover/30`,children:[(0,Q.jsx)(`div`,{className:`text-lg font-semibold tabular-nums text-fg`,children:e}),(0,Q.jsx)(`div`,{className:`text-xs text-fg-muted`,children:t})]},t))}):null,L?(0,Q.jsx)(`div`,{className:`rounded-lg bg-red-50 px-3 py-2 text-sm text-red-700 dark:bg-red-950/40 dark:text-red-300`,children:L}):null,(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:mt(t.sessionCount,{count:F.length})}),(0,Q.jsxs)(xe,{className:ve,role:`group`,"aria-label":t.layoutToggleGroup,indicatorClassName:`rounded-pill bg-surface-panel shadow-sm dark:ring-1 dark:ring-edge-strong/40`,children:[(0,Q.jsx)(W,{type:`button`,variant:`segmented`,title:t.gridView,"aria-pressed":M===`grid`,onClick:()=>T({type:`patch`,patch:{viewMode:`grid`}}),className:I(_e,`size-7 p-0`,M===`grid`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,M===`grid`&&`text-accent-fg`),children:(0,Q.jsx)(O,{className:`size-3.5`,strokeWidth:1.5})}),(0,Q.jsx)(W,{type:`button`,variant:`segmented`,title:t.listView,"aria-pressed":M===`list`,onClick:()=>T({type:`patch`,patch:{viewMode:`list`}}),className:I(_e,`size-9 p-0`,M===`list`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,M===`list`&&`text-accent-fg`),children:(0,Q.jsx)(g,{className:`size-3.5`,strokeWidth:1.5})})]})]}),te&&F.length===0?(0,Q.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:Array.from({length:6}).map((e,t)=>(0,Q.jsx)(`div`,{className:`h-40 animate-pulse rounded-xl bg-surface-hover/60 dark:bg-surface-hover/40`},t))}):F.length===0?(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-2xl bg-surface-base py-16 text-center dark:bg-surface-hover/25`,children:[(0,Q.jsx)(E,{className:`mb-3 size-12 text-fg-disabled`,strokeWidth:1.25,"aria-hidden":!0}),(0,Q.jsx)(`p`,{className:`text-base font-semibold text-fg`,children:t.noSessions}),(0,Q.jsx)(`p`,{className:`mt-1 max-w-sm text-sm text-fg-muted`,children:t.noSessionsDescription}),(0,Q.jsx)(W,{variant:`primary`,className:`mt-6`,onClick:()=>{window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{conversationId:``},bubbles:!0}))},children:t.startNewChat})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:I(`grid min-w-0 gap-3`,M===`grid`?`sm:grid-cols-2 lg:grid-cols-3`:`grid-cols-1`),"data-debounced-query":A||void 0,children:F.map(e=>{let t=Re(e,d);return(0,Q.jsx)(Ne,{session:e,variant:M,labels:X,sessionAgentId:t,sessionAgentAvatar:ze(t,_),onOpen:()=>J(e.key),onAction:t=>void Y(e.key,t)},e.key)})}),se?(0,Q.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Q.jsx)(W,{type:`button`,variant:`secondary`,disabled:te,onClick:()=>void ye(),children:t.loadMore})}):null]})]})]}),(0,Q.jsx)(dt,{open:le,loading:de,session:U,sessionAgentId:U?Re(U,d):void 0,sessionAgentAvatar:U?ze(Re(U,d),_):void 0,labels:Ee,onClose:()=>{T({type:`patch`,patch:{detailOpen:!1,detailSession:null}})},onArchive:()=>U&&void Y(U.key,`archive`),onUnarchive:()=>U&&void Y(U.key,`unarchive`),onPin:()=>U&&void Y(U.key,`pin`),onUnpin:()=>U&&void Y(U.key,`unpin`),onExport:()=>U&&void Y(U.key,`export`),onDelete:()=>U&&T({type:`patch`,patch:{confirmKey:U.key,confirmOpen:!0}})}),(0,Q.jsx)(h,{open:me,onOpenChange:e=>T({type:`patch`,patch:{confirmOpen:e}}),children:(0,Q.jsxs)(f,{children:[(0,Q.jsx)(u,{className:I(`xopc-dialog-overlay fixed inset-0 bg-scrim`,pe)}),(0,Q.jsxs)(p,{className:I(`xopc-dialog-content fixed left-1/2 top-1/2 w-[min(100%-2rem,24rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover dark:border-edge`,fe),children:[(0,Q.jsx)(m,{className:`text-base font-semibold text-fg`,children:t.deleteSessionTitle}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:K?mt(t.deleteSessionMessage,{name:F.find(e=>e.key===K)?.name?.trim()||e.chat.newSession}):``}),(0,Q.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Q.jsx)(W,{type:`button`,variant:`secondary`,onClick:()=>T({type:`patch`,patch:{confirmOpen:!1}}),children:t.cancel}),(0,Q.jsx)(W,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{K&&Te(K),T({type:`patch`,patch:{confirmOpen:!1,confirmKey:null}})},children:t.delete})]})]})]})})]}):(0,Q.jsx)(`div`,{className:`w-full px-3 py-16 text-center text-sm text-fg-muted sm:px-5 xl:px-6`,children:t.needToken})}export{wt as SessionsPage};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{h as i}from"./chunk-KS7C4IRE-BPb7KheU.js";import{i as a,l as o,n as s,o as c}from"./locale-store-B4o4aDCg.js";import{t as l}from"./messages-hlOsXkQ7.js";import{a as u,n as d,o as f,r as p,s as m,t as h}from"./dist-CY7CS_D3.js";import{n as g,r as _,t as v}from"./session-identity-label-DCIZvqbN.js";import{t as y}from"./archive-Dz0hferG.js";import{n as b,r as x}from"./popover-select-CLsphyzA.js";import{t as S}from"./circle-BoO4YvTx.js";import{t as C}from"./coins-DjP27vUx.js";import{t as w}from"./database-CjjeZfRG.js";import{t as T}from"./download-Dk-ZjtO6.js";import{t as E}from"./folder-open-CyzJ19I9.js";import{t as D}from"./layers-mJW7JJKm.js";import{t as O}from"./layout-grid-CEVZdVFU.js";import{t as k}from"./message-square-fVE7Ghj1.js";import{t as A}from"./minimize-2-DtOGrlpo.js";import{n as ee,t as j}from"./pin-off-BMRv-Kxr.js";import{t as M}from"./plus-Q2yW6OE7.js";import{t as N}from"./search-DA7gz22f.js";import{t as P}from"./settings-uiTATseT.js";import{t as F}from"./trash-2-DusmjVPV.js";import{t as te}from"./x-B_N4OPjy.js";import{t as I}from"./cn-0WouolD0.js";import{t as L}from"./skeleton-DzdOeGYz.js";import{a as R,c as z,f as B,n as V,o as ne,p as re,r as ie,s as ae,t as oe}from"./session-api-7-TPnKv0.js";import{t as se}from"./session-channel-icon-COynhpeK.js";import{i as ce}from"./vendor-swr-CdRzEUwF.js";import{n as H,r as le}from"./gateway-config-swr-2VOPSLSq.js";import{t as ue}from"./chat-agents-api-B-47bqbd.js";import{n as de,t as U}from"./registry-api-CmLu4MA9.js";import{t as W}from"./button-ChmVQg9O.js";import{i as fe,o as pe}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{n as G,t as me}from"./interaction-BdhHBbYa.js";import{s as K}from"./form-field-width-DJw_jULe.js";import{t as he}from"./page-tabs-DoYMKhVO.js";import{t as ge}from"./agent-avatar-display-BDHjRaTK.js";import{n as _e,r as ve}from"./segmented-styles-Cqb91xsn.js";import{n as ye,r as be,t as q}from"./settings-form-draft-Dy10ldo8.js";import{t as xe}from"./sliding-tab-list-CmcrqRzN.js";import{n as Se}from"./model-selector-BP-t33vd.js";import{t as J}from"./settings-advanced-section-BsqgVQL3.js";import{t as Y}from"./number-input-El7Szeln.js";import{n as Ce,t as we}from"./settings-page-header-DKgbD0Bc.js";import"./settings-page-layout-BE3vLWp_.js";import{n as Te,t as X}from"./settings-form-section-num14vSv.js";import{n as Ee,t as De}from"./use-autosave-BkVX6SyB.js";import{t as Oe}from"./settings-advanced-gate-DHfrm0Zj.js";var Z=e(t(),1),ke=n(),Q=r();function Ae(e){let t=new Date(e),n=Math.floor((new Date().getTime()-t.getTime())/(1e3*60*60*24));return n===0?t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):n===1?`Yesterday`:n<7?t.toLocaleDateString([],{weekday:`short`}):t.toLocaleDateString([],{month:`short`,day:`numeric`})}function je(e,t){return new Intl.NumberFormat(t===`zh`?`zh-CN`:`en-US`).format(e)}function Me(e){return`$${Number(e).toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:6})}`}function Ne(e){let t=(0,ke.c)(124),{session:n,variant:r,labels:i,sessionAgentId:a,sessionAgentAvatar:o,onOpen:c,onAction:u}=e,d;t[0]!==i.unnamedSession||t[1]!==n.name?(d=n.name?.trim()||i.unnamedSession,t[0]=i.unnamedSession,t[1]=n.name,t[2]=d):d=t[2];let f=d,p=s(Le),m;t[3]!==p||t[4]!==n?(m=v(n,l(p).sidebar.sessionFilters),t[3]=p,t[4]=n,t[5]=m):m=t[5];let h=m,g;t[6]===n.name?g=t[7]:(g=n.name?.trim(),t[6]=n.name,t[7]=g);let b=!!g,x=n.status===`archived`,S=n.status===`pinned`,E=n.usage,D;t[8]!==i.costUnknown||t[9]!==i.noUsage||t[10]!==E?(D=E?.calls?E.costCompleteness===`unknown`?i.costUnknown:`${E.costCompleteness===`partial`?`≥ `:`≈ `}${Me(E.knownCostUsd)}`:i.noUsage,t[8]=i.costUnknown,t[9]=i.noUsage,t[10]=E,t[11]=D):D=t[11];let O=D,A=E?.calls?E.costCompleteness===`partial`?i.costPartial:E.costCompleteness===`unknown`?i.costUnknown:i.cost:i.noUsage,M=r===`list`&&`sm:flex-row sm:items-center sm:gap-4`,N;t[12]===M?N=t[13]:(N=I(`group flex min-w-0 w-full max-w-full cursor-pointer flex-col rounded-xl bg-surface-base text-left transition-colors duration-150 ease-out`,`hover:bg-surface-hover active:scale-[0.99]`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,M),t[12]=M,t[13]=N);let P;t[14]===c?P=t[15]:(P=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())},t[14]=c,t[15]=P);let te=r===`list`&&`sm:py-3`,L;t[16]===te?L=t[17]:(L=I(`flex min-w-0 items-start justify-between gap-2 bg-surface-hover/35 px-3 py-2 dark:bg-surface-hover/25`,te),t[16]=te,t[17]=L);let R;t[18]===n?R=t[19]:(R=(0,Q.jsx)(se,{sourceChannel:n.sourceChannel,session:n,className:`size-3.5`}),t[18]=n,t[19]=R);let z;t[20]===h?z=t[21]:(z=(0,Q.jsx)(`span`,{className:`truncate text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:h}),t[20]=h,t[21]=z);let B;t[22]!==R||t[23]!==z?(B=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[R,z]}),t[22]=R,t[23]=z,t[24]=B):B=t[24];let V;t[25]===S?V=t[26]:(V=S?(0,Q.jsx)(ee,{className:`size-3.5 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}):null,t[25]=S,t[26]=V);let ne;t[27]===n.updatedAt?ne=t[28]:(ne=Ae(n.updatedAt),t[27]=n.updatedAt,t[28]=ne);let re;t[29]===ne?re=t[30]:(re=(0,Q.jsx)(`span`,{children:ne}),t[29]=ne,t[30]=re);let ie;t[31]!==V||t[32]!==re?(ie=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-muted`,children:[V,re]}),t[31]=V,t[32]=re,t[33]=ie):ie=t[33];let ae;t[34]!==B||t[35]!==ie||t[36]!==L?(ae=(0,Q.jsxs)(`div`,{className:L,children:[B,ie]}),t[34]=B,t[35]=ie,t[36]=L,t[37]=ae):ae=t[37];let oe=r===`list`&&`sm:py-3`,ce;t[38]===oe?ce=t[39]:(ce=I(`min-w-0 flex-1 px-3 py-2`,oe),t[38]=oe,t[39]=ce);let H=r===`list`&&`sm:items-start`,le;t[40]===H?le=t[41]:(le=I(`flex gap-3`,H),t[40]=H,t[41]=le);let ue;t[42]!==o||t[43]!==a?(ue=(0,Q.jsx)(ge,{agentId:a,avatar:o,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}),t[42]=o,t[43]=a,t[44]=ue):ue=t[44];let de;t[45]===f?de=t[46]:(de=(0,Q.jsx)(`div`,{className:`min-w-0 max-w-full truncate text-sm font-semibold text-fg`,title:f,children:f}),t[45]=f,t[46]=de);let U;t[47]!==n.key||t[48]!==b?(U=b?(0,Q.jsx)(`div`,{className:`mt-0.5 min-w-0 max-w-full truncate font-mono text-[11px] text-fg-subtle`,title:n.key,children:n.key}):null,t[47]=n.key,t[48]=b,t[49]=U):U=t[49];let W;t[50]!==de||t[51]!==U?(W=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[de,U]}),t[50]=de,t[51]=U,t[52]=W):W=t[52];let fe;t[53]!==le||t[54]!==ue||t[55]!==W?(fe=(0,Q.jsxs)(`div`,{className:le,children:[ue,W]}),t[53]=le,t[54]=ue,t[55]=W,t[56]=fe):fe=t[56];let pe;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,Q.jsx)(k,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[57]=pe):pe=t[57];let G;t[58]===n.messageCount?G=t[59]:(G=(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[pe,n.messageCount]}),t[58]=n.messageCount,t[59]=G);let K;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,Q.jsx)(w,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[60]=K):K=t[60];let he=E?.totalTokens??0,_e;t[61]!==p||t[62]!==he?(_e=je(he,p),t[61]=p,t[62]=he,t[63]=_e):_e=t[63];let ve;t[64]!==i.tokens||t[65]!==_e?(ve=(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[K,_e,` `,i.tokens]}),t[64]=i.tokens,t[65]=_e,t[66]=ve):ve=t[66];let ye;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(ye=(0,Q.jsx)(C,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[67]=ye):ye=t[67];let be;t[68]!==O||t[69]!==A?(be=(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,title:A,children:[ye,O]}),t[68]=O,t[69]=A,t[70]=be):be=t[70];let q;t[71]!==G||t[72]!==ve||t[73]!==be?(q=(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3 text-xs text-fg-muted`,children:[G,ve,be]}),t[71]=G,t[72]=ve,t[73]=be,t[74]=q):q=t[74];let xe;t[75]===n.tags?xe=t[76]:(xe=n.tags.length>0?(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[n.tags.slice(0,3).map(Ie),n.tags.length>3?(0,Q.jsxs)(`span`,{className:`text-[11px] text-fg-disabled`,children:[`+`,n.tags.length-3]}):null]}):null,t[75]=n.tags,t[76]=xe);let Se;t[77]!==ce||t[78]!==fe||t[79]!==q||t[80]!==xe?(Se=(0,Q.jsxs)(`div`,{className:ce,children:[fe,q,xe]}),t[77]=ce,t[78]=fe,t[79]=q,t[80]=xe,t[81]=Se):Se=t[81];let J;t[82]===u?J=t[83]:(J=()=>u(`continue`),t[82]=u,t[83]=J);let Y;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(Y=(0,Q.jsx)(k,{className:`size-4`,strokeWidth:1.75}),t[84]=Y):Y=t[84];let Ce;t[85]!==i.continueChat||t[86]!==J?(Ce=(0,Q.jsx)(`button`,{type:`button`,className:me,title:i.continueChat,"aria-label":i.continueChat,onClick:J,children:Y}),t[85]=i.continueChat,t[86]=J,t[87]=Ce):Ce=t[87];let we;t[88]!==x||t[89]!==i.archive||t[90]!==i.unarchive||t[91]!==u?(we=x?(0,Q.jsx)(`button`,{type:`button`,className:me,title:i.unarchive,"aria-label":i.unarchive,onClick:()=>u(`unarchive`),children:(0,Q.jsx)(_,{className:`size-4`,strokeWidth:1.75})}):(0,Q.jsx)(`button`,{type:`button`,className:me,title:i.archive,"aria-label":i.archive,onClick:()=>u(`archive`),children:(0,Q.jsx)(y,{className:`size-4`,strokeWidth:1.75})}),t[88]=x,t[89]=i.archive,t[90]=i.unarchive,t[91]=u,t[92]=we):we=t[92];let Te;t[93]!==S||t[94]!==i.pin||t[95]!==i.unpin||t[96]!==u?(Te=S?(0,Q.jsx)(`button`,{type:`button`,className:me,title:i.unpin,"aria-label":i.unpin,onClick:()=>u(`unpin`),children:(0,Q.jsx)(j,{className:`size-4`,strokeWidth:1.75})}):(0,Q.jsx)(`button`,{type:`button`,className:me,title:i.pin,"aria-label":i.pin,onClick:()=>u(`pin`),children:(0,Q.jsx)(ee,{className:`size-4`,strokeWidth:1.75})}),t[93]=S,t[94]=i.pin,t[95]=i.unpin,t[96]=u,t[97]=Te):Te=t[97];let X;t[98]===u?X=t[99]:(X=()=>u(`export`),t[98]=u,t[99]=X);let Ee;t[100]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=(0,Q.jsx)(T,{className:`size-4`,strokeWidth:1.75}),t[100]=Ee):Ee=t[100];let De;t[101]!==i.export||t[102]!==X?(De=(0,Q.jsx)(`button`,{type:`button`,className:me,title:i.export,"aria-label":i.export,onClick:X,children:Ee}),t[101]=i.export,t[102]=X,t[103]=De):De=t[103];let Oe;t[104]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=I(me,`text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`),t[104]=Oe):Oe=t[104];let Z;t[105]===u?Z=t[106]:(Z=()=>u(`delete`),t[105]=u,t[106]=Z);let Ne;t[107]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=(0,Q.jsx)(F,{className:`size-4`,strokeWidth:1.75}),t[107]=Ne):Ne=t[107];let Re;t[108]!==i.delete||t[109]!==Z?(Re=(0,Q.jsx)(`button`,{type:`button`,className:Oe,title:i.delete,"aria-label":i.delete,onClick:Z,children:Ne}),t[108]=i.delete,t[109]=Z,t[110]=Re):Re=t[110];let ze;t[111]!==Ce||t[112]!==we||t[113]!==Te||t[114]!==De||t[115]!==Re?(ze=(0,Q.jsxs)(`div`,{role:`group`,className:`m-1 mt-0 flex flex-wrap items-center gap-0.5 rounded-lg bg-surface-hover/35 p-1.5`,onClick:Fe,onKeyDown:Pe,children:[Ce,we,Te,De,Re]}),t[111]=Ce,t[112]=we,t[113]=Te,t[114]=De,t[115]=Re,t[116]=ze):ze=t[116];let Be;return t[117]!==c||t[118]!==ae||t[119]!==Se||t[120]!==ze||t[121]!==N||t[122]!==P?(Be=(0,Q.jsxs)(`div`,{role:`button`,tabIndex:0,className:N,onClick:c,onKeyDown:P,children:[ae,Se,ze]}),t[117]=c,t[118]=ae,t[119]=Se,t[120]=ze,t[121]=N,t[122]=P,t[123]=Be):Be=t[123],Be}function Pe(e){return e.stopPropagation()}function Fe(e){return e.stopPropagation()}function Ie(e){return(0,Q.jsx)(`span`,{className:`max-w-full break-words rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:e},e)}function Le(e){return e.language}function Re(e,t){return e.routing?.agentId?.trim().toLowerCase()||t.trim().toLowerCase()||`main`}function ze(e,t){return t.find(t=>t.id===e)?.avatar}var Be={enabled:!0,triggerThreshold:.8,reserveTokens:8192,minMessagesBeforeCompact:10,keepRecentTokens:2e4,recentTurnsPreserve:3,summaryMaxTokens:16e3,summaryChunkTokens:24e3,summaryTimeoutMs:18e4,summaryRetries:2,qualityGuard:!0,gapAudit:!0,minToolResultKeepChars:1e3,maxActiveTranscriptBytes:2e6,postCompactionSections:[`Session Startup`,`Red Lines`]};function Ve(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function He(e,t,n,r=1/0){return typeof e==`number`&&Number.isFinite(e)&&e>=n&&e<=r?e:t}function Ue(e,t,n,r=1/0){return Number.isInteger(e)&&e>=n&&e<=r?e:t}function We(e){let t=Ve(e)?e:{},n=Ve(t.userContext)?t.userContext:{},r=Ve(n.contextPlanning)?n.contextPlanning:{},i=Ve(r.compaction)?r.compaction:{},a=Be,o=typeof i.model==`string`&&i.model.trim()?i.model.trim():void 0,s=Array.isArray(i.postCompactionSections)&&i.postCompactionSections.length<=12&&i.postCompactionSections.every(e=>typeof e==`string`&&e.trim())?[...new Set(i.postCompactionSections.map(e=>e.trim()))]:[...a.postCompactionSections];return{enabled:typeof i.enabled==`boolean`?i.enabled:a.enabled,triggerThreshold:He(i.triggerThreshold,a.triggerThreshold,.1,.98),reserveTokens:Ue(i.reserveTokens,a.reserveTokens,1024),minMessagesBeforeCompact:Ue(i.minMessagesBeforeCompact,a.minMessagesBeforeCompact,2),keepRecentTokens:Ue(i.keepRecentTokens,a.keepRecentTokens,1e3),recentTurnsPreserve:Ue(i.recentTurnsPreserve,a.recentTurnsPreserve,1,12),summaryMaxTokens:Ue(i.summaryMaxTokens,a.summaryMaxTokens,256),summaryChunkTokens:Ue(i.summaryChunkTokens,a.summaryChunkTokens,1e3),summaryTimeoutMs:Ue(i.summaryTimeoutMs,a.summaryTimeoutMs,1e3,6e5),summaryRetries:Ue(i.summaryRetries,a.summaryRetries,0,5),qualityGuard:typeof i.qualityGuard==`boolean`?i.qualityGuard:a.qualityGuard,gapAudit:typeof i.gapAudit==`boolean`?i.gapAudit:a.gapAudit,...o?{model:o}:{},minToolResultKeepChars:Ue(i.minToolResultKeepChars,a.minToolResultKeepChars,200),maxActiveTranscriptBytes:Ue(i.maxActiveTranscriptBytes,a.maxActiveTranscriptBytes,64e3),postCompactionSections:s}}function Ge(e){return e.triggerThreshold<.1||e.triggerThreshold>.98?`triggerThreshold`:!Number.isInteger(e.reserveTokens)||e.reserveTokens<1024?`reserveTokens`:!Number.isInteger(e.minMessagesBeforeCompact)||e.minMessagesBeforeCompact<2?`minMessagesBeforeCompact`:!Number.isInteger(e.keepRecentTokens)||e.keepRecentTokens<1e3?`keepRecentTokens`:!Number.isInteger(e.recentTurnsPreserve)||e.recentTurnsPreserve<1||e.recentTurnsPreserve>12?`recentTurnsPreserve`:!Number.isInteger(e.summaryMaxTokens)||e.summaryMaxTokens<256?`summaryMaxTokens`:!Number.isInteger(e.summaryChunkTokens)||e.summaryChunkTokens<1e3?`summaryChunkTokens`:!Number.isInteger(e.summaryTimeoutMs)||e.summaryTimeoutMs<1e3||e.summaryTimeoutMs>6e5?`summaryTimeoutMs`:!Number.isInteger(e.summaryRetries)||e.summaryRetries<0||e.summaryRetries>5?`summaryRetries`:e.model!==void 0&&!e.model.trim()?`model`:!Number.isInteger(e.minToolResultKeepChars)||e.minToolResultKeepChars<200?`minToolResultKeepChars`:!Number.isInteger(e.maxActiveTranscriptBytes)||e.maxActiveTranscriptBytes<64e3?`maxActiveTranscriptBytes`:e.postCompactionSections.length>12||e.postCompactionSections.some(e=>!e.trim())?`postCompactionSections`:null}function Ke(e){let t={...e,...e.model?.trim()?{model:e.model.trim()}:{}};return e.model?.trim()||delete t.model,{userContext:{contextPlanning:{compaction:t}}}}async function qe(e){await c(a(`/api/config`),{method:`PATCH`,body:JSON.stringify(Ke(e))}),await H()}var Je=128e3,Ye={balanced:Be,preserve:{...Be,triggerThreshold:.88,keepRecentTokens:32e3,recentTurnsPreserve:5,maxActiveTranscriptBytes:4e6},early:{...Be,triggerThreshold:.65,reserveTokens:12e3,minMessagesBeforeCompact:6,keepRecentTokens:12e3,recentTurnsPreserve:2}},Xe=q();function Ze(){return I(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg disabled:cursor-not-allowed disabled:opacity-55`,K,`dark:border-edge`)}function Qe(e){let{enabled:t,model:n,postCompactionSections:r,...i}=e;return JSON.stringify(i)}function $e(e){let t=Qe(e);for(let[e,n]of Object.entries(Ye))if(t===Qe(n))return e;return`custom`}function et(e){return e>=1e6?`${(e/1e6).toFixed(e%1e6==0?0:1)}m`:e>=1e3?`${(e/1e3).toFixed(e%1e3==0?0:1)}k`:String(e)}function $(e){let t=(0,ke.c)(20),{id:n,label:r,hint:i,value:a,min:o,max:s,step:c,disabled:l,onChange:u}=e,d=c===void 0?1:c,f;t[0]!==n||t[1]!==r?(f=(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:n,children:r}),t[0]=n,t[1]=r,t[2]=f):f=t[2];let p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=Ze(),t[3]=p):p=t[3];let m;t[4]===u?m=t[5]:(m=e=>{if(!e.target.value.trim())return;let t=Number(e.target.value);Number.isFinite(t)&&u(t)},t[4]=u,t[5]=m);let h;t[6]!==l||t[7]!==n||t[8]!==s||t[9]!==o||t[10]!==d||t[11]!==m||t[12]!==a?(h=(0,Q.jsx)(Y,{id:n,type:`number`,min:o,max:s,step:d,disabled:l,className:p,value:a,onChange:m}),t[6]=l,t[7]=n,t[8]=s,t[9]=o,t[10]=d,t[11]=m,t[12]=a,t[13]=h):h=t[13];let g;t[14]===i?g=t[15]:(g=i?(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i}):null,t[14]=i,t[15]=g);let _;return t[16]!==f||t[17]!==h||t[18]!==g?(_=(0,Q.jsxs)(`div`,{children:[f,h,g]}),t[16]=f,t[17]=h,t[18]=g,t[19]=_):_=t[19],_}function tt(e){let t=(0,ke.c)(19),{label:n,hint:r,checked:i,disabled:a,onChange:o}=e,s=a?`cursor-not-allowed opacity-55`:`cursor-pointer`,c;t[0]===s?c=t[1]:(c=I(`flex items-start gap-2 text-sm text-fg`,s),t[0]=s,t[1]=c);let l;t[2]===o?l=t[3]:(l=e=>o(e.target.checked),t[2]=o,t[3]=l);let u;t[4]!==i||t[5]!==a||t[6]!==l?(u=(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:i,disabled:a,onChange:l}),t[4]=i,t[5]=a,t[6]=l,t[7]=u):u=t[7];let d;t[8]===n?d=t[9]:(d=(0,Q.jsx)(`span`,{className:`font-medium`,children:n}),t[8]=n,t[9]=d);let f;t[10]===r?f=t[11]:(f=(0,Q.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:r}),t[10]=r,t[11]=f);let p;t[12]!==d||t[13]!==f?(p=(0,Q.jsxs)(`span`,{children:[d,f]}),t[12]=d,t[13]=f,t[14]=p):p=t[14];let m;return t[15]!==c||t[16]!==u||t[17]!==p?(m=(0,Q.jsxs)(`label`,{className:c,children:[u,p]}),t[15]=c,t[16]=u,t[17]=p,t[18]=m):m=t[18],m}function nt({hasToken:e}){let t=l(s(e=>e.language)).sessions.compaction,{data:n,isLoading:r}=le(e),{data:i=[],isLoading:a}=ce(e?U:null,de,{revalidateOnFocus:!1}),o=(0,Z.useMemo)(()=>n?.payload?.config===void 0?null:We(n.payload.config),[n]),[c,u]=(0,Z.useReducer)(Xe,{form:null,baseline:null}),[d,f]=(0,Z.useState)(``),p=(0,Z.useRef)(!1),m=(0,Z.useRef)(c.form);m.current=c.form;let h=(0,Z.useRef)(null);ye({enabled:e,parsed:o,dirty:p.current,trackedParsedRef:h,dispatch:u,onResetDirty:()=>{p.current=!1}});let g=c.form,_=c.baseline,v=!!(g&&_&&JSON.stringify(g)!==JSON.stringify(_)),y=(0,Z.useCallback)(e=>{p.current=!0,u({type:`patch`,patch:e})},[]),b=(0,Z.useCallback)(e=>({enabled:t.enabled,triggerThreshold:t.triggerThreshold,reserveTokens:t.reserveTokens,minMessagesBeforeCompact:t.minMessagesBeforeCompact,keepRecentTokens:t.keepRecentTokens,recentTurnsPreserve:t.recentTurnsPreserve,summaryMaxTokens:t.summaryMaxTokens,summaryChunkTokens:t.summaryChunkTokens,summaryTimeoutMs:t.summaryTimeoutSeconds,summaryRetries:t.summaryRetries,qualityGuard:t.qualityGuard,gapAudit:t.gapAudit,model:t.summaryModel,minToolResultKeepChars:t.minToolResultKeepChars,maxActiveTranscriptBytes:t.maxActiveTranscriptMb,postCompactionSections:t.postCompactionSections})[e],[t]),x=De({value:g,dirty:v,onSave:(0,Z.useCallback)(async e=>{try{await qe(e),u({type:`saved`,value:e}),p.current=!!(m.current&&JSON.stringify(m.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError]),validate:e=>{let n=Ge(e);return n?t.invalidValue.replace(`{{field}}`,b(n)):null}});if(!e||!g)return r?(0,Q.jsx)(X,{children:(0,Q.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Q.jsx)(L,{className:`h-5 w-48`}),(0,Q.jsx)(L,{className:`h-20 w-full rounded-xl`}),(0,Q.jsx)(L,{className:`h-36 w-full rounded-xl`})]})}):null;let S=$e(g),C=Math.max(0,Je-g.reserveTokens),w=Math.min(Math.floor(Je*g.triggerThreshold),C),T=Math.min(100,w/Je*100),E=Math.min(100,C/Je*100),D=g.model?i.find(e=>e.id===g.model):void 0,O=D?.contextWindow&&g.summaryChunkTokens+g.summaryMaxTokens+4096>D.contextWindow,k=g.keepRecentTokens+g.reserveTokens>w,ee=Math.round(g.summaryTimeoutMs*(g.summaryRetries+1)/1e3),j=e=>{let t=Ye[e];y({...t,...g.model?{model:g.model}:{model:void 0},postCompactionSections:g.postCompactionSections})},N={balanced:{title:t.presetBalanced,hint:t.presetBalancedHint},preserve:{title:t.presetPreserve,hint:t.presetPreserveHint},early:{title:t.presetEarly,hint:t.presetEarlyHint}},P=()=>{let e=d.trim();!e||g.postCompactionSections.includes(e)||g.postCompactionSections.length>=12||(y({postCompactionSections:[...g.postCompactionSections,e]}),f(``))};return(0,Q.jsxs)(X,{onBlurCapture:x.onBlurCapture,children:[(0,Q.jsx)(Te,{icon:A,title:t.title,subtitle:t.hint,trailing:(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(Ee,{status:x.status,error:x.error}),(0,Q.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm font-medium text-fg`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:g.enabled,onChange:e=>y({enabled:e.target.checked})}),g.enabled?t.enabled:t.disabled]})]})}),x.error?(0,Q.jsx)(`p`,{className:`mb-4 rounded-lg bg-red-50 px-3 py-2 text-sm text-red-700 dark:bg-red-950/40 dark:text-red-300`,role:`alert`,children:x.error}):null,g.enabled?null:(0,Q.jsx)(`p`,{className:`mb-4 rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.disabledWarning}),(0,Q.jsxs)(`fieldset`,{disabled:!g.enabled,className:`space-y-5 disabled:opacity-60`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.presetTitle}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.presetHint})]}),S===`custom`?(0,Q.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-1 text-[11px] font-medium text-fg-muted`,children:t.presetCustom}):null]}),(0,Q.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[`balanced`,`preserve`,`early`].map(e=>(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":S===e,className:I(`rounded-xl bg-surface-base/55 px-3 py-3 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,G.transition,G.focusRingPanel,S===e?`bg-accent-soft text-accent-fg shadow-surface`:`text-fg hover:bg-surface-hover`),onClick:()=>j(e),children:[(0,Q.jsx)(`span`,{className:`block text-sm font-medium`,children:N[e].title}),(0,Q.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:N[e].hint})]},e))})]}),(0,Q.jsxs)(J,{title:t.advancedTitle,summary:S===`custom`?t.presetCustom:t.presetHint,children:[(0,Q.jsxs)(`div`,{className:`rounded-xl bg-surface-base/45 p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.budgetPreview}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.budgetPreviewHint})]}),(0,Q.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2.5 py-1 font-mono text-xs text-fg-muted`,children:t.previewModel128k})]}),(0,Q.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`mb-1 flex justify-between gap-3 text-xs text-fg-muted`,children:[(0,Q.jsx)(`span`,{children:t.compactionTrigger}),(0,Q.jsx)(`span`,{className:`font-mono text-fg`,children:et(w)})]}),(0,Q.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,Q.jsx)(`div`,{className:`h-full rounded-full bg-accent`,style:{width:`${T}%`}})})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`mb-1 flex justify-between gap-3 text-xs text-fg-muted`,children:[(0,Q.jsx)(`span`,{children:t.hardInputLimit}),(0,Q.jsx)(`span`,{className:`font-mono text-fg`,children:et(C)})]}),(0,Q.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,Q.jsx)(`div`,{className:`h-full rounded-full bg-fg-subtle`,style:{width:`${E}%`}})})]})]}),(0,Q.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:t.budgetFormula})]}),(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Q.jsx)($,{id:`compaction-trigger-threshold`,label:t.triggerThreshold,hint:t.triggerThresholdHint,value:Number((g.triggerThreshold*100).toFixed(2)),min:10,max:98,step:.1,onChange:e=>y({triggerThreshold:e/100})}),(0,Q.jsx)($,{id:`compaction-reserve-tokens`,label:t.reserveTokens,hint:t.reserveTokensHint.replace(`{{tokens}}`,et(g.reserveTokens)),value:g.reserveTokens,min:1024,step:1024,onChange:e=>y({reserveTokens:Math.floor(e)})}),(0,Q.jsx)($,{id:`compaction-recent-turns`,label:t.recentTurnsPreserve,hint:t.recentTurnsPreserveHint,value:g.recentTurnsPreserve,min:1,max:12,onChange:e=>y({recentTurnsPreserve:Math.floor(e)})}),(0,Q.jsx)($,{id:`compaction-keep-recent-tokens`,label:t.keepRecentTokens,hint:t.keepRecentTokensHint.replace(`{{tokens}}`,et(g.keepRecentTokens)),value:g.keepRecentTokens,min:1e3,step:1e3,onChange:e=>y({keepRecentTokens:Math.floor(e)})})]}),k?(0,Q.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.retentionWarning}):null,(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.summaryModel}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 gap-2`,children:[(0,Q.jsx)(Se,{value:g.model??``,disabled:!g.enabled,placeholder:t.summaryModelInherited,searchPlaceholder:t.summaryModelSearch,noMatches:t.summaryModelNoMatches,models:i,modelsLoading:a,className:`min-w-0 flex-1 justify-between`,contentAlign:`start`,showProviderSettingsFooter:!0,onChange:e=>y({model:e})}),g.model?(0,Q.jsx)(W,{type:`button`,variant:`secondary`,onClick:()=>y({model:void 0}),children:t.summaryModelUseSession}):null]}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.summaryModelHint})]}),(0,Q.jsx)(tt,{label:t.qualityGuard,hint:t.qualityGuardHint,checked:g.qualityGuard,onChange:e=>y({qualityGuard:e})}),(0,Q.jsx)(tt,{label:t.gapAudit,hint:t.gapAuditHint,checked:g.gapAudit,onChange:e=>y({gapAudit:e})})]}),g.qualityGuard?null:(0,Q.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.qualityGuardWarning})]}),(0,Q.jsx)(Oe,{children:(0,Q.jsxs)(`div`,{className:`space-y-5 rounded-xl bg-surface-base/45 p-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:t.advancedTitle}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.advancedHint})]}),(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Q.jsx)($,{id:`compaction-min-messages`,label:t.minMessagesBeforeCompact,hint:t.minMessagesBeforeCompactHint,value:g.minMessagesBeforeCompact,min:2,onChange:e=>y({minMessagesBeforeCompact:Math.floor(e)})}),(0,Q.jsx)($,{id:`compaction-max-transcript-mb`,label:t.maxActiveTranscriptMb,hint:t.maxActiveTranscriptMbHint,value:Number((g.maxActiveTranscriptBytes/1e6).toFixed(3)),min:.064,step:.1,onChange:e=>y({maxActiveTranscriptBytes:Math.max(64e3,Math.round(e*1e6))})}),(0,Q.jsx)($,{id:`compaction-summary-max-tokens`,label:t.summaryMaxTokens,hint:t.summaryMaxTokensHint,value:g.summaryMaxTokens,min:256,step:256,onChange:e=>y({summaryMaxTokens:Math.floor(e)})}),(0,Q.jsx)($,{id:`compaction-summary-chunk-tokens`,label:t.summaryChunkTokens,hint:t.summaryChunkTokensHint,value:g.summaryChunkTokens,min:1e3,step:1e3,onChange:e=>y({summaryChunkTokens:Math.floor(e)})}),(0,Q.jsx)($,{id:`compaction-summary-timeout`,label:t.summaryTimeoutSeconds,hint:t.summaryTimeoutSecondsHint.replace(`{{seconds}}`,String(ee)),value:g.summaryTimeoutMs/1e3,min:1,max:600,onChange:e=>y({summaryTimeoutMs:Math.round(e*1e3)})}),(0,Q.jsx)($,{id:`compaction-summary-retries`,label:t.summaryRetries,hint:t.summaryRetriesHint,value:g.summaryRetries,min:0,max:5,onChange:e=>y({summaryRetries:Math.floor(e)})}),(0,Q.jsx)($,{id:`compaction-min-tool-result-chars`,label:t.minToolResultKeepChars,hint:t.minToolResultKeepCharsHint,value:g.minToolResultKeepChars,min:200,step:100,onChange:e=>y({minToolResultKeepChars:Math.floor(e)})})]}),O?(0,Q.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.summaryBudgetWarning}):null,(0,Q.jsxs)(`div`,{className:`rounded-xl bg-surface-base/45 p-4`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.postCompactionSections}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.postCompactionSectionsHint}),g.postCompactionSections.length>0?(0,Q.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:g.postCompactionSections.map(e=>(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs text-fg`,children:[e,(0,Q.jsx)(`button`,{type:`button`,className:I(`text-fg-muted hover:text-fg`,G.press),"aria-label":t.removeSection.replace(`{{section}}`,e),onClick:()=>y({postCompactionSections:g.postCompactionSections.filter(t=>t!==e)}),children:(0,Q.jsx)(te,{className:`size-3.5`,"aria-hidden":!0})})]},e))}):(0,Q.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.postCompactionSectionsEmpty}),(0,Q.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,Q.jsx)(`input`,{className:Ze(),value:d,maxLength:120,disabled:g.postCompactionSections.length>=12,placeholder:t.postCompactionSectionsPlaceholder,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),P())}}),(0,Q.jsxs)(W,{type:`button`,variant:`secondary`,disabled:!d.trim()||g.postCompactionSections.length>=12,onClick:P,children:[(0,Q.jsx)(M,{className:`size-4`,"aria-hidden":!0}),t.addSection]})]})]})]})})]})]})}function rt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function it(e){return e===`main`||e===`per-peer`||e===`per-channel-peer`||e===`per-account-channel-peer`?e:`main`}function at(e){let t=rt(e)?e:{},n=rt(t.session)?t.session:{},r=rt(n.storage)?n.storage:{},i=typeof r.pruneAfterDays==`number`&&Number.isFinite(r.pruneAfterDays)?Math.max(0,Math.floor(r.pruneAfterDays)):typeof r.pruneAfterMs==`number`&&Number.isFinite(r.pruneAfterMs)?Math.max(0,Math.round(r.pruneAfterMs/864e5)):null,a=typeof r.maxEntries==`number`&&Number.isFinite(r.maxEntries)?Math.max(1,Math.floor(r.maxEntries)):null;return{dmScope:it(n.dmScope),pruneAfterDays:i,maxEntries:a}}async function ot(e){await c(a(`/api/config`),{method:`PATCH`,body:JSON.stringify({session:{dmScope:e.dmScope,storage:{pruneAfterMs:e.pruneAfterDays===null?null:e.pruneAfterDays*864e5,maxEntries:e.maxEntries}}})}),H()}function st(){return I(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,K,`dark:border-edge`)}var ct=q();function lt({hasToken:e}){let t=l(s(e=>e.language)).sessions.config,{data:n,isLoading:r}=le(e),i=(0,Z.useMemo)(()=>n?.payload?.config===void 0?null:at(n.payload.config),[n]),[a,o]=(0,Z.useReducer)(ct,{form:null,baseline:null}),c=a.form,u=a.baseline,d=(0,Z.useRef)(!1),f=(0,Z.useRef)(c);f.current=c;let p=(0,Z.useRef)(null);ye({enabled:e,parsed:i,dirty:d.current,trackedParsedRef:p,dispatch:o,onResetDirty:()=>{d.current=!1}});let m=!!(c&&u&&JSON.stringify(c)!==JSON.stringify(u)),h=(0,Z.useCallback)(e=>{d.current=!0,o({type:`patch`,patch:e})},[]),g=De({value:c,dirty:m,onSave:(0,Z.useCallback)(async e=>{try{await ot(e),o({type:`saved`,value:e}),d.current=!!(f.current&&JSON.stringify(f.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError])});return!e||!c?r?(0,Q.jsx)(X,{children:(0,Q.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Q.jsx)(L,{className:`h-5 w-40`}),(0,Q.jsx)(L,{className:`h-24 w-full rounded-xl`})]})}):null:(0,Q.jsxs)(X,{onBlurCapture:g.onBlurCapture,children:[(0,Q.jsx)(Te,{icon:w,title:t.title,subtitle:t.hint,trailing:(0,Q.jsx)(Ee,{status:g.status,error:g.error})}),(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Q.jsx)(J,{title:t.dmScope,summary:c.dmScope,children:(0,Q.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.dmScope}),(0,Q.jsxs)(b,{className:st(),value:c.dmScope,onChange:e=>h({dmScope:e.target.value}),children:[(0,Q.jsx)(x,{value:`main`,children:t.dmScopeMain}),(0,Q.jsx)(x,{value:`per-peer`,children:t.dmScopePerPeer}),(0,Q.jsx)(x,{value:`per-channel-peer`,children:t.dmScopePerChannelPeer}),(0,Q.jsx)(x,{value:`per-account-channel-peer`,children:t.dmScopePerAccountChannelPeer})]}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.dmScopeHint})]})}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.pruneAfterDays}),(0,Q.jsx)(Y,{allowEmpty:!0,type:`number`,min:0,className:st(),value:c.pruneAfterDays??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();h({pruneAfterDays:t===``?null:Math.max(0,Math.floor(Number(t)||0))})}})]}),(0,Q.jsx)(J,{title:t.maxEntries,summary:c.maxEntries??t.unsetPlaceholder,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.maxEntries}),(0,Q.jsx)(Y,{allowEmpty:!0,type:`number`,min:1,className:st(),value:c.maxEntries??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();h({maxEntries:t===``?null:Math.max(1,Math.floor(Number(t)||1))})}})]})})]})]})}function ut(e){if(typeof e==`string`)return e.length>2e3?`${e.slice(0,2e3)}…`:e;try{let t=JSON.stringify(e,null,2);return t.length>2e3?`${t.slice(0,2e3)}…`:t}catch{return String(e)}}function dt(e){let t=(0,ke.c)(60),{open:n,loading:r,session:i,sessionAgentId:a,sessionAgentAvatar:o,labels:s,onClose:c,onArchive:l,onUnarchive:g,onPin:_,onUnpin:v,onExport:y,onDelete:b}=e,x=i?.status===`archived`,S=i?.status===`pinned`,C;t[0]===c?C=t[1]:(C=e=>!e&&c(),t[0]=c,t[1]=C);let w;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Q.jsx)(u,{className:I(`xopc-dialog-overlay fixed inset-0 bg-scrim`,pe)}),t[2]=w):w=t[2];let T;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(T=I(`xopc-drawer-right fixed right-0 top-0 flex size-full max-w-lg flex-col border-l border-edge bg-surface-overlay shadow-popover outline-none`,fe,`dark:border-edge`),t[3]=T):T=t[3];let E;t[4]!==i||t[5]!==o||t[6]!==a?(E=i&&a?(0,Q.jsx)(ge,{agentId:a,avatar:o,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}):null,t[4]=i,t[5]=o,t[6]=a,t[7]=E):E=t[7];let D;t[8]!==s.unnamedSession||t[9]!==i?.name?(D=i?.name?.trim()||s.unnamedSession,t[8]=s.unnamedSession,t[9]=i?.name,t[10]=D):D=t[10];let O;t[11]===D?O=t[12]:(O=(0,Q.jsx)(m,{className:`min-w-0 flex-1 truncate text-base font-semibold tracking-tight text-fg`,children:D}),t[11]=D,t[12]=O);let k;t[13]!==E||t[14]!==O?(k=(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[E,O]}),t[13]=E,t[14]=O,t[15]=k):k=t[15];let A;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Q.jsx)(te,{className:`size-5`,strokeWidth:1.75}),t[16]=A):A=t[16];let ee;t[17]===s.close?ee=t[18]:(ee=(0,Q.jsx)(d,{asChild:!0,children:(0,Q.jsx)(W,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":s.close,children:A})}),t[17]=s.close,t[18]=ee);let j;t[19]!==k||t[20]!==ee?(j=(0,Q.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3 dark:border-edge`,children:[k,ee]}),t[19]=k,t[20]=ee,t[21]=j):j=t[21];let M;t[22]!==s.detailLoading||t[23]!==s.detailMessages||t[24]!==r||t[25]!==i?(M=r?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:s.detailLoading}):i?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`dl`,{className:`mb-4 grid gap-2 text-xs text-fg-muted`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-fg-disabled`,children:`Key`}),(0,Q.jsx)(`dd`,{className:`mt-0.5 break-all font-mono text-fg`,children:i.key})]}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-4`,children:(0,Q.jsxs)(`span`,{children:[i.messageCount,` msgs · `,i.estimatedTokens,` tok`]})})]}),(0,Q.jsx)(`h3`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:s.detailMessages}),(0,Q.jsx)(`ul`,{className:`space-y-3`,children:i.messages.map(ft)})]}):null,t[22]=s.detailLoading,t[23]=s.detailMessages,t[24]=r,t[25]=i,t[26]=M):M=t[26];let N;t[27]===M?N=t[28]:(N=(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:M}),t[27]=M,t[28]=N);let P;t[29]!==s.detailExport||t[30]!==y?(P=(0,Q.jsx)(W,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:y,children:s.detailExport}),t[29]=s.detailExport,t[30]=y,t[31]=P):P=t[31];let F;t[32]!==x||t[33]!==s.archive||t[34]!==s.unarchive||t[35]!==l||t[36]!==g?(F=x?(0,Q.jsx)(W,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:g,children:s.unarchive}):(0,Q.jsx)(W,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:l,children:s.archive}),t[32]=x,t[33]=s.archive,t[34]=s.unarchive,t[35]=l,t[36]=g,t[37]=F):F=t[37];let L;t[38]!==S||t[39]!==s.pin||t[40]!==s.unpin||t[41]!==_||t[42]!==v?(L=S?(0,Q.jsx)(W,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:v,children:s.unpin}):(0,Q.jsx)(W,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:_,children:s.pin}),t[38]=S,t[39]=s.pin,t[40]=s.unpin,t[41]=_,t[42]=v,t[43]=L):L=t[43];let R;t[44]!==s.delete||t[45]!==b?(R=(0,Q.jsx)(W,{type:`button`,variant:`secondary`,className:`text-sm text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`,onClick:b,children:s.delete}),t[44]=s.delete,t[45]=b,t[46]=R):R=t[46];let z;t[47]!==P||t[48]!==F||t[49]!==L||t[50]!==R?(z=(0,Q.jsx)(`div`,{className:`shrink-0 border-t border-edge px-4 py-3 dark:border-edge`,children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[P,F,L,R]})}),t[47]=P,t[48]=F,t[49]=L,t[50]=R,t[51]=z):z=t[51];let B;t[52]!==j||t[53]!==N||t[54]!==z?(B=(0,Q.jsxs)(f,{children:[w,(0,Q.jsxs)(p,{className:T,"aria-describedby":void 0,children:[j,N,z]})]}),t[52]=j,t[53]=N,t[54]=z,t[55]=B):B=t[55];let V;return t[56]!==n||t[57]!==C||t[58]!==B?(V=(0,Q.jsx)(h,{open:n,onOpenChange:C,children:B}),t[56]=n,t[57]=C,t[58]=B,t[59]=V):V=t[59],V}function ft(e){return(0,Q.jsxs)(`li`,{className:`rounded-lg border border-edge-subtle bg-surface-hover/50 p-2 dark:border-edge`,children:[(0,Q.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase text-fg-subtle`,children:e.role}),(0,Q.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed text-fg-muted`,children:ut(e.content)})]},`${e.timestamp??``}-${e.role}-${ut(e.content).slice(0,24)}`)}var pt=20;function mt(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}var ht=new Set([`all`,`active`,`pinned`,`archived`]),gt=new Set([`grid`,`list`]),_t=[`sessions`,`settings`];function vt(e){return e&&_t.includes(e)?e:`sessions`}function yt(e,t){return t===`sessions`?e.tabsSessions:e.tabsSettings}function bt(e,t){return t===`sessions`?e.tabsSessionsHint:e.tabsSettingsHint}function xt(e){let t=(0,ke.c)(7),{s:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=_t.map(e=>({id:e,label:yt(n,e),icon:e===`sessions`?D:P})),t[0]=n,t[1]=a);let o=a,s;return t[2]!==r||t[3]!==o||t[4]!==i||t[5]!==n.tabsAriaLabel?(s=(0,Q.jsx)(he,{items:o,activeTab:r,onChange:i,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`sessions-tab`,panelIdPrefix:`sessions-panel`}),t[2]=r,t[3]=o,t[4]=i,t[5]=n.tabsAriaLabel,t[6]=s):s=t[6],s}function St(e){let t=(0,ke.c)(10),{s:n,id:r,activeTab:i,plain:a,children:o}=e,s=a!==void 0&&a;if(i!==r)return null;let c=`sessions-panel-${r}`,l=`sessions-tab-${r}`,u=s?`contents`:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,d;t[0]!==o||t[1]!==r||t[2]!==s||t[3]!==n?(d=s?o:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`mb-5`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:yt(n,r)}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:bt(n,r)})]}),(0,Q.jsx)(`div`,{className:`space-y-4`,children:o})]}),t[0]=o,t[1]=r,t[2]=s,t[3]=n,t[4]=d):d=t[4];let f;return t[5]!==c||t[6]!==l||t[7]!==u||t[8]!==d?(f=(0,Q.jsx)(`section`,{id:c,role:`tabpanel`,"aria-labelledby":l,className:u,children:d}),t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f):f=t[9],f}function Ct(e){let t=e.get(`status`),n=e.get(`view`);return{searchInput:e.get(`q`)??``,debouncedSearch:(e.get(`q`)??``).trim(),statusFilter:ht.has(t)?t:`all`,viewMode:gt.has(n)?n:`grid`,channelFilter:(e.get(`channel`)??``).trim(),sessions:[],loading:!1,error:null,hasMore:!1,stats:null,detailOpen:!1,detailLoading:!1,detailSession:null,confirmOpen:!1,confirmKey:null}}function wt(){let e=l(s(e=>e.language)),t=e.sessions,n=o(e=>e.conversationId),r=!!n,{data:a,mutate:c}=ce(r?[`gateway-chat-agents`,n]:null,ue,{revalidateOnFocus:!1}),d=a?.defaultId??`main`,_=a?.items??[],[v,b]=i(),x=vt(v.get(`tab`)),C=(0,Z.useCallback)(e=>{let t=new URLSearchParams(v);e===`sessions`?t.delete(`tab`):t.set(`tab`,e),b(t,{replace:!0})},[v,b]),[w,T]=(0,Z.useReducer)(be,v,Ct),{searchInput:k,debouncedSearch:A,statusFilter:j,viewMode:M,channelFilter:P,sessions:F,loading:te,error:L,hasMore:se,stats:H,detailOpen:le,detailLoading:de,detailSession:U,confirmOpen:me,confirmKey:K}=w;(0,Z.useEffect)(()=>{let e=setTimeout(()=>{let e=k.trim();A!==e&&T({type:`patch`,patch:{debouncedSearch:e}})},300);return()=>clearTimeout(e)},[k,A]);let he=v.toString(),ge=(0,Z.useRef)(he);if(ge.current!==he){ge.current=he;let e=v.get(`q`)??``,t=v.get(`status`),n=v.get(`view`),r=(v.get(`channel`)??``).trim(),i=ht.has(t)?t:`all`,a=gt.has(n)?n:`grid`,o=e.trim();T({type:`patch`,patch:{...k===e?{}:{searchInput:e},...A===o?{}:{debouncedSearch:o},...j===i?{}:{statusFilter:i},...M===a?{}:{viewMode:a},...P===r?{}:{channelFilter:r}}})}(0,Z.useEffect)(()=>{let e=new URLSearchParams(v),t=A.trim();t?e.set(`q`,t):e.delete(`q`),j===`all`?e.delete(`status`):e.set(`status`,j),M===`grid`?e.delete(`view`):e.set(`view`,M),P?e.set(`channel`,P):e.delete(`channel`),e.toString()!==v.toString()&&b(e,{replace:!0})},[A,v,b,j,M,P]),(0,Z.useEffect)(()=>{if(!r||x!==`sessions`)return;let e=!1;return(async()=>{T({type:`patch`,patch:{loading:!0,error:null}});try{let t=await ae({limit:pt,offset:0,...A?{search:A}:{},...j===`all`?{}:{status:j},...P?{channel:P}:{}});if(e)return;T({type:`patch`,patch:{sessions:t.items,hasMore:t.hasMore}})}catch(n){e||T({type:`patch`,patch:{error:n instanceof Error?n.message:t.loadError}})}finally{e||T({type:`patch`,patch:{loading:!1}})}})(),()=>{e=!0}},[r,x,A,j,P,t.loadError]),(0,Z.useEffect)(()=>{!r||x!==`sessions`||ne().then(e=>T({type:`patch`,patch:{stats:e}})).catch(()=>{})},[r,x]),(0,Z.useEffect)(()=>{if(!r||x!==`sessions`)return;let e=()=>void c();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[r,x,c]),(0,Z.useEffect)(()=>{if(!r||x!==`sessions`)return;let e=e=>{let t=e.detail;!t?.key||t.name===void 0||T({type:`patch`,patch:{sessions:F.map(e=>e.key===t.key?{...e,name:t.name}:e),detailSession:U&&U.key===t.key?{...U,name:t.name}:U}})};return window.addEventListener(`session-updated`,e),()=>{window.removeEventListener(`session-updated`,e)}},[r,x,F,U]);let ye=(0,Z.useCallback)(async()=>{if(!(!r||te||!se)){T({type:`patch`,patch:{loading:!0,error:null}});try{let e=await ae({limit:pt,offset:F.length,...A?{search:A}:{},...j===`all`?{}:{status:j},...P?{channel:P}:{}});T({type:`patch`,patch:{sessions:[...F,...e.items],hasMore:e.hasMore}})}catch(e){T({type:`patch`,patch:{error:e instanceof Error?e.message:t.loadError}})}finally{T({type:`patch`,patch:{loading:!1}})}}},[r,te,se,F.length,A,j,P,t.loadError]),q=(0,Z.useCallback)((e,t)=>{T({type:`patch`,patch:{sessions:F.map(n=>n.key===e?{...n,status:t}:n),detailSession:U&&U.key===e?{...U,status:t}:U}})},[F,U]),Se=(0,Z.useCallback)(async e=>{T({type:`patch`,patch:{detailOpen:!0,detailLoading:!0,detailSession:null}});try{let t=await R(e);T({type:`patch`,patch:{detailSession:t}})}catch{T({type:`patch`,patch:{detailOpen:!1}})}finally{T({type:`patch`,patch:{detailLoading:!1}})}},[]),J=e=>{Se(e)},Y=async(e,t)=>{if(t===`continue`){window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{conversationId:e},bubbles:!0}));return}if(t===`delete`){T({type:`patch`,patch:{confirmKey:e,confirmOpen:!0}});return}try{switch(t){case`archive`:await oe(e),q(e,`archived`);break;case`unarchive`:await B(e),q(e,`active`);break;case`pin`:await z(e),q(e,`pinned`);break;case`unpin`:await re(e),q(e,`active`);break;case`export`:{let t=await ie(e),n=new Blob([t],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`session-${e.replace(/[^a-z0-9]/gi,`_`)}.json`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r);break}default:break}ne().then(e=>T({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},Te=async e=>{try{await V(e),T({type:`patch`,patch:{sessions:F.filter(t=>t.key!==e),detailSession:U?.key===e?null:U,...U?.key===e?{detailOpen:!1}:{}}}),ne().then(e=>T({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},X={continueChat:t.continueChat,archive:t.archive,unarchive:t.unarchive,pin:t.pin,unpin:t.unpin,export:t.export,delete:t.delete,tokens:t.tokens,cost:t.cost,costPartial:t.costPartial,costUnknown:t.costUnknown,noUsage:t.noUsage,unnamedSession:e.chat.newSession},Ee={close:t.close,detailLoading:t.detailLoading,detailMessages:t.detailMessages,detailExport:t.detailExport,archive:t.archive,unarchive:t.unarchive,pin:t.pin,unpin:t.unpin,delete:t.delete,unnamedSession:e.chat.newSession},De=[{key:`all`,label:t.filterAll,icon:D},{key:`active`,label:t.filterActive,icon:S},{key:`pinned`,label:t.filterPinned,icon:ee},{key:`archived`,label:t.filterArchived,icon:y}],Oe=(()=>{let e=Object.entries(H?.byChannel??{}).sort((e,t)=>t[1]-e[1]).slice(0,6).map(([e])=>e),t=new Set(e);for(let n of[`telegram`,`weixin`,`feishu`])t.has(n)||(e.push(n),t.add(n));return e.slice(0,8)})();return r?(0,Q.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden bg-surface-panel`,children:[(0,Q.jsxs)(Ce,{gap:`gap-6`,children:[(0,Q.jsx)(we,{title:t.title}),(0,Q.jsx)(xt,{s:t,activeTab:x,onChange:C}),(0,Q.jsx)(St,{s:t,id:`settings`,activeTab:x,plain:!0,children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(nt,{hasToken:r}),(0,Q.jsx)(lt,{hasToken:r})]})}),(0,Q.jsxs)(St,{s:t,id:`sessions`,activeTab:x,plain:!0,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between`,children:[(0,Q.jsx)(xe,{className:`flex flex-wrap gap-2`,role:`group`,"aria-label":t.tabsSessions,indicatorClassName:`rounded-xl bg-accent-soft`,children:De.map(({key:e,label:t,icon:n})=>(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":j===e,onClick:()=>T({type:`patch`,patch:{statusFilter:e}}),className:I(`inline-flex items-center gap-1.5 rounded-xl px-3 py-2 text-sm font-medium`,G.transition,G.focusRingPanel,j===e?`bg-accent-soft text-accent-fg`:`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`),children:[(0,Q.jsx)(n,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t]},e))}),(0,Q.jsxs)(`div`,{className:`flex min-h-11 w-full min-w-0 items-center gap-2 rounded-xl bg-surface-base focus-within:ring-2 focus-within:ring-accent px-3 py-2 transition-colors lg:max-w-md dark:bg-surface-hover/40`,children:[(0,Q.jsx)(N,{className:`size-4 shrink-0 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`input`,{type:`search`,value:k,onChange:e=>T({type:`patch`,patch:{searchInput:e.target.value}}),placeholder:t.searchPlaceholder,"aria-label":t.searchPlaceholder,"data-debounced-query":A||void 0,className:`min-w-0 flex-1 border-0 bg-transparent text-base sm:text-sm text-fg placeholder:text-fg-disabled focus:outline-none focus:ring-0`})]})]}),(0,Q.jsxs)(xe,{className:`flex flex-wrap items-center gap-2`,role:`group`,"aria-label":t.filterChannelLabel,indicatorClassName:`rounded-xl bg-accent-soft`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg-subtle`,children:t.filterChannelLabel}),(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":!P,onClick:()=>T({type:`patch`,patch:{channelFilter:``}}),className:I(`touch-target inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,G.transition,G.focusRingPanel,P?`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`:`bg-accent-soft text-accent-fg`),children:t.filterChannelAll}),Oe.map(e=>(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":P===e,onClick:()=>T({type:`patch`,patch:{channelFilter:e}}),className:I(`touch-target inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,G.transition,G.focusRingPanel,P===e?`bg-accent-soft text-accent-fg`:`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`),children:[e,H?.byChannel?.[e]==null?null:(0,Q.jsx)(`span`,{className:`ml-2 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] text-fg-subtle`,children:H.byChannel[e]})]},e))]}),H?(0,Q.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[[H.totalSessions,t.totalSessions],[H.activeSessions,t.activeSessions],[H.pinnedSessions,t.pinnedSessions],[H.archivedSessions,t.archivedSessions]].map(([e,t])=>(0,Q.jsxs)(`div`,{className:`rounded-xl bg-surface-base p-3 dark:bg-surface-hover/30`,children:[(0,Q.jsx)(`div`,{className:`text-lg font-semibold tabular-nums text-fg`,children:e}),(0,Q.jsx)(`div`,{className:`text-xs text-fg-muted`,children:t})]},t))}):null,L?(0,Q.jsx)(`div`,{className:`rounded-lg bg-red-50 px-3 py-2 text-sm text-red-700 dark:bg-red-950/40 dark:text-red-300`,children:L}):null,(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:mt(t.sessionCount,{count:F.length})}),(0,Q.jsxs)(xe,{className:ve,role:`group`,"aria-label":t.layoutToggleGroup,indicatorClassName:`rounded-pill bg-surface-panel shadow-sm dark:ring-1 dark:ring-edge-strong/40`,children:[(0,Q.jsx)(W,{type:`button`,variant:`segmented`,title:t.gridView,"aria-pressed":M===`grid`,onClick:()=>T({type:`patch`,patch:{viewMode:`grid`}}),className:I(_e,`size-7 p-0`,M===`grid`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,M===`grid`&&`text-accent-fg`),children:(0,Q.jsx)(O,{className:`size-3.5`,strokeWidth:1.5})}),(0,Q.jsx)(W,{type:`button`,variant:`segmented`,title:t.listView,"aria-pressed":M===`list`,onClick:()=>T({type:`patch`,patch:{viewMode:`list`}}),className:I(_e,`size-9 p-0`,M===`list`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,M===`list`&&`text-accent-fg`),children:(0,Q.jsx)(g,{className:`size-3.5`,strokeWidth:1.5})})]})]}),te&&F.length===0?(0,Q.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:Array.from({length:6}).map((e,t)=>(0,Q.jsx)(`div`,{className:`h-40 animate-pulse rounded-xl bg-surface-hover/60 dark:bg-surface-hover/40`},t))}):F.length===0?(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-2xl bg-surface-base py-16 text-center dark:bg-surface-hover/25`,children:[(0,Q.jsx)(E,{className:`mb-3 size-12 text-fg-disabled`,strokeWidth:1.25,"aria-hidden":!0}),(0,Q.jsx)(`p`,{className:`text-base font-semibold text-fg`,children:t.noSessions}),(0,Q.jsx)(`p`,{className:`mt-1 max-w-sm text-sm text-fg-muted`,children:t.noSessionsDescription}),(0,Q.jsx)(W,{variant:`primary`,className:`mt-6`,onClick:()=>{window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{conversationId:``},bubbles:!0}))},children:t.startNewChat})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:I(`grid min-w-0 gap-3`,M===`grid`?`sm:grid-cols-2 lg:grid-cols-3`:`grid-cols-1`),"data-debounced-query":A||void 0,children:F.map(e=>{let t=Re(e,d);return(0,Q.jsx)(Ne,{session:e,variant:M,labels:X,sessionAgentId:t,sessionAgentAvatar:ze(t,_),onOpen:()=>J(e.key),onAction:t=>void Y(e.key,t)},e.key)})}),se?(0,Q.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Q.jsx)(W,{type:`button`,variant:`secondary`,disabled:te,onClick:()=>void ye(),children:t.loadMore})}):null]})]})]}),(0,Q.jsx)(dt,{open:le,loading:de,session:U,sessionAgentId:U?Re(U,d):void 0,sessionAgentAvatar:U?ze(Re(U,d),_):void 0,labels:Ee,onClose:()=>{T({type:`patch`,patch:{detailOpen:!1,detailSession:null}})},onArchive:()=>U&&void Y(U.key,`archive`),onUnarchive:()=>U&&void Y(U.key,`unarchive`),onPin:()=>U&&void Y(U.key,`pin`),onUnpin:()=>U&&void Y(U.key,`unpin`),onExport:()=>U&&void Y(U.key,`export`),onDelete:()=>U&&T({type:`patch`,patch:{confirmKey:U.key,confirmOpen:!0}})}),(0,Q.jsx)(h,{open:me,onOpenChange:e=>T({type:`patch`,patch:{confirmOpen:e}}),children:(0,Q.jsxs)(f,{children:[(0,Q.jsx)(u,{className:I(`xopc-dialog-overlay fixed inset-0 bg-scrim`,pe)}),(0,Q.jsxs)(p,{className:I(`xopc-dialog-content fixed left-1/2 top-1/2 w-[min(100%-2rem,24rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover dark:border-edge`,fe),children:[(0,Q.jsx)(m,{className:`text-base font-semibold text-fg`,children:t.deleteSessionTitle}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:K?mt(t.deleteSessionMessage,{name:F.find(e=>e.key===K)?.name?.trim()||e.chat.newSession}):``}),(0,Q.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Q.jsx)(W,{type:`button`,variant:`secondary`,onClick:()=>T({type:`patch`,patch:{confirmOpen:!1}}),children:t.cancel}),(0,Q.jsx)(W,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{K&&Te(K),T({type:`patch`,patch:{confirmOpen:!1,confirmKey:null}})},children:t.delete})]})]})]})})]}):(0,Q.jsx)(`div`,{className:`w-full px-3 py-16 text-center text-sm text-fg-muted sm:px-5 xl:px-6`,children:t.needToken})}export{wt as SessionsPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./settings-mode-store-BtwrUOdQ.js";function t(t){let{children:n,fallback:r}=t,i=r===void 0?null:r;return e()?n:i}export{t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{n}from"./locale-store-
|
|
1
|
+
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{n}from"./locale-store-B4o4aDCg.js";import{t as r}from"./button-ChmVQg9O.js";import{t as i}from"./settings-mode-store-BtwrUOdQ.js";var a=e(),o=t();function s(e){let t=(0,a.c)(15),{title:s,summary:d,children:f}=e,p=i(u),m=i(l),h=n(c)===`zh`;if(p)return f;let g;t[0]===s?g=t[1]:(g=(0,o.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:s}),t[0]=s,t[1]=g);let _;t[2]===d?_=t[3]:(_=(0,o.jsx)(`div`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:d}),t[2]=d,t[3]=_);let v;t[4]!==g||t[5]!==_?(v=(0,o.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[g,_]}),t[4]=g,t[5]=_,t[6]=v):v=t[6];let y;t[7]===m?y=t[8]:(y=()=>m(`advanced`),t[7]=m,t[8]=y);let b=h?`查看高级设置`:`Show advanced settings`,x;t[9]!==y||t[10]!==b?(x=(0,o.jsx)(r,{type:`button`,variant:`ghost`,onClick:y,children:b}),t[9]=y,t[10]=b,t[11]=x):x=t[11];let S;return t[12]!==v||t[13]!==x?(S=(0,o.jsxs)(`section`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-xl bg-surface-hover/20 p-4`,children:[v,x]}),t[12]=v,t[13]=x,t[14]=S):S=t[14],S}function c(e){return e.language}function l(e){return e.setMode}function u(e){return e.mode===`advanced`}export{s as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as e}from"./locale-store-
|
|
1
|
+
import{p as e}from"./locale-store-B4o4aDCg.js";import{t}from"./middleware-Pd0e8Igk.js";var n=e(t(e=>({mode:`simple`,setMode:t=>e({mode:t}),setShowAdvanced:t=>e({mode:t?`advanced`:`simple`})}),{name:`xopc-web-settings-mode`}));function r(){return n(i)}function i(e){return e.mode===`advanced`}export{r as n,n as t};
|
package/dist/gateway/static/root/assets/{settings-page-DppkfISC.js → settings-page-B_8kxJQW.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{p as i,r as a}from"./chunk-KS7C4IRE-BPb7KheU.js";import{n as o}from"./locale-store-B4o4aDCg.js";import{t as s}from"./messages-hlOsXkQ7.js";import{E as c,M as l,T as u,b as d,c as f,h as p,i as m,j as h,k as g,l as _,n as v,p as y,r as b}from"./route-preload-Bl10PwKS.js";var x=n(),S=e(t(),1),C=r(),w=[`overview`,`appearance`,`keyboard-shortcuts`,`personal`,`system`,`desktop-pet`,`desktop-app`,`agent-defaults`,`gateway`,`runtimes`,`devices`,`remote-access`,`shares`],T=(0,S.lazy)(()=>g().then(e=>({default:e.SetupStatusPanel}))),E=(0,S.lazy)(()=>m().then(e=>({default:e.AppearanceSettingsPanel}))),D=(0,S.lazy)(()=>p().then(e=>({default:e.KeyboardShortcutsSettingsPanel}))),O=(0,S.lazy)(()=>d().then(e=>({default:e.PersonalSettingsPanel}))),k=(0,S.lazy)(()=>l().then(e=>({default:e.SystemSettingsPanel}))),A=(0,S.lazy)(()=>f().then(e=>({default:e.DesktopPetSettings}))),j=(0,S.lazy)(()=>b().then(e=>({default:e.AppManagementSettingsPanel}))),M=(0,S.lazy)(()=>y().then(e=>({default:e.GatewaySettingsPanel}))),N=(0,S.lazy)(()=>c().then(e=>({default:e.RuntimeToolsSettingsPanel}))),P=(0,S.lazy)(()=>u().then(e=>({default:e.RemoteAccessHub}))),F=(0,S.lazy)(()=>h().then(e=>({default:e.SharesSettingsPanel}))),I=(0,S.lazy)(()=>v().then(e=>({default:e.AgentDefaultsSettingsPanel}))),L=(0,S.lazy)(()=>_().then(e=>({default:e.EndpointToolsManagementSettings})));function R(){let e=(0,x.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,C.jsxs)(`div`,{className:`w-full flex-1 px-3 py-8 sm:px-5 xl:px-6`,"aria-busy":!0,children:[(0,C.jsx)(`div`,{className:`h-8 w-48 max-w-full animate-pulse rounded-md bg-surface-hover`}),(0,C.jsx)(`div`,{className:`mt-6 h-36 animate-pulse rounded-xl bg-surface-hover`}),(0,C.jsx)(`div`,{className:`mt-4 h-24 animate-pulse rounded-xl bg-surface-hover`})]}),e[0]=t):t=e[0],t}function z(e){return(0,C.jsx)(S.Suspense,{fallback:(0,C.jsx)(R,{}),children:(0,C.jsx)(e,{})})}function B(){let e=(0,x.c)(28),{section:t}=i(),n=o(V),r,c,l,u,d;if(e[0]!==n||e[1]!==t){d=Symbol.for(`react.early_return_sentinel`);bb0:{let i=s(n);if(!t||!w.includes(t)){let t;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,C.jsx)(a,{to:`/settings/overview`,replace:!0}),e[7]=t):t=e[7],d=t;break bb0}let o=t;if(o===`overview`){let t;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(T),e[8]=t):t=e[8],d=t;break bb0}let f=i.settingsSections[o];if(o===`appearance`){let t;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(E),e[9]=t):t=e[9],d=t;break bb0}if(o===`keyboard-shortcuts`){let t;e[10]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(D),e[10]=t):t=e[10],d=t;break bb0}if(o===`personal`){let t;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(O),e[11]=t):t=e[11],d=t;break bb0}if(o===`system`){let t;e[12]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(k),e[12]=t):t=e[12],d=t;break bb0}if(o===`desktop-pet`){let t;e[13]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(A),e[13]=t):t=e[13],d=t;break bb0}if(o===`desktop-app`){let t;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(j),e[14]=t):t=e[14],d=t;break bb0}if(o===`agent-defaults`){let t;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(I),e[15]=t):t=e[15],d=t;break bb0}if(o===`gateway`){let t;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(M),e[16]=t):t=e[16],d=t;break bb0}if(o===`runtimes`){let t;e[17]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(N),e[17]=t):t=e[17],d=t;break bb0}if(o===`devices`){let t;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(L),e[18]=t):t=e[18],d=t;break bb0}if(o===`remote-access`){let t;e[19]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(P),e[19]=t):t=e[19],d=t;break bb0}if(o===`shares`){let t;e[20]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(F),e[20]=t):t=e[20],d=t;break bb0}l=`flex w-full flex-col gap-3 px-3 py-8 sm:px-5 xl:px-6`,u=(0,C.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:f}),r=`text-sm text-fg-muted`,c=i.settingsPage.comingSoon.replace(`{{title}}`,f)}e[0]=n,e[1]=t,e[2]=r,e[3]=c,e[4]=l,e[5]=u,e[6]=d}else r=e[2],c=e[3],l=e[4],u=e[5],d=e[6];if(d!==Symbol.for(`react.early_return_sentinel`))return d;let f;e[21]!==r||e[22]!==c?(f=(0,C.jsx)(`p`,{className:r,children:c}),e[21]=r,e[22]=c,e[23]=f):f=e[23];let p;return e[24]!==l||e[25]!==u||e[26]!==f?(p=(0,C.jsxs)(`div`,{className:l,children:[u,f]}),e[24]=l,e[25]=u,e[26]=f,e[27]=p):p=e[27],p}function V(e){return e.language}export{B as SettingsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./chunk-KS7C4IRE-
|
|
1
|
+
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./chunk-KS7C4IRE-BPb7KheU.js";import{n as r}from"./locale-store-B4o4aDCg.js";import{t as i}from"./external-link-DjqjBmc3.js";import{t as a}from"./sparkles-DHlfQFAF.js";import{t as o}from"./cn-0WouolD0.js";import{t as s}from"./button-ChmVQg9O.js";var c=e(),l=t();function u(e){let t=(0,c.c)(14),n,r,i,a,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],s=t[5]):({children:n,className:r,gap:a,padding:s,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=s);let u=a===void 0?`gap-5`:a,d=s===void 0?`px-4 py-6 sm:px-5 xl:px-6`:s,f;t[6]!==r||t[7]!==u||t[8]!==d?(f=o(`settings-page-frame mx-auto flex min-h-full w-full max-w-[56rem] flex-col`,u,d,r),t[6]=r,t[7]=u,t[8]=d,t[9]=f):f=t[9];let p;return t[10]!==n||t[11]!==i||t[12]!==f?(p=(0,l.jsx)(`div`,{className:f,...i,children:n}),t[10]=n,t[11]=i,t[12]=f,t[13]=p):p=t[13],p}var d={phone:{scene:`configure-phone`,zh:`帮我配置 Phone Use,从模型、依赖、手机连接到验收。`,en:`Help configure Phone Use: model, dependencies, phone connection and verification.`},browser:{scene:`configure-xopc`,zh:`帮我配置 Browser Use,连接本机 Chrome 并完成验收。`,en:`Help me configure Browser Use with local Chrome and verify it.`}};function f(e){let t=(0,c.c)(8),{target:i}=e,o=r(p)===`zh`,u=d[i],f=o?u.zh:u.en,m;t[0]!==u.scene||t[1]!==f?(m=new URLSearchParams({skill:`configure-xopc`,scene:u.scene,draft:f,autoSend:`1`}),t[0]=u.scene,t[1]=f,t[2]=m):m=t[2];let h=`/chat/new?${m}`,g=o?`让 AI 帮我配置`:`Set up with AI`,_;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,l.jsx)(a,{className:`size-4 shrink-0`,"aria-hidden":!0}),t[3]=_):_=t[3];let v=o?`AI 配置`:`AI setup`,y;return t[4]!==h||t[5]!==g||t[6]!==v?(y=(0,l.jsx)(s,{asChild:!0,className:`order-first whitespace-nowrap sm:order-last text-accent-fg shadow-none sm:shadow-none`,children:(0,l.jsxs)(n,{to:h,title:g,children:[_,v]})}),t[4]=h,t[5]=g,t[6]=v,t[7]=y):y=t[7],y}function p(e){return e.language}function m(e){let t=(0,c.c)(22),{title:n,subtitle:r,docsLink:a,docsLabel:s,meta:u,actions:d,aiSetup:p,className:m}=e,h=p?`grid grid-cols-[minmax(0,1fr)_auto] items-start gap-3`:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,g;t[0]!==m||t[1]!==h?(g=o(h,m),t[0]=m,t[1]=h,t[2]=g):g=t[2];let _;t[3]===n?_=t[4]:(_=(0,l.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight sm:text-lg text-fg`,children:n}),t[3]=n,t[4]=_);let v;t[5]===r?v=t[6]:(v=r?(0,l.jsx)(`p`,{className:`mt-2 text-sm leading-relaxed text-fg-muted sm:mt-1`,children:r}):null,t[5]=r,t[6]=v);let y;t[7]!==s||t[8]!==a?(y=a&&s?(0,l.jsxs)(`a`,{href:a,target:`_blank`,rel:`noreferrer`,className:`touch-target mt-1 inline-flex items-center gap-1 text-sm text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[s,(0,l.jsx)(i,{className:`size-3.5`,"aria-hidden":!0})]}):null,t[7]=s,t[8]=a,t[9]=y):y=t[9];let b;t[10]!==u||t[11]!==_||t[12]!==v||t[13]!==y?(b=(0,l.jsxs)(`div`,{className:`min-w-0`,children:[_,v,y,u]}),t[10]=u,t[11]=_,t[12]=v,t[13]=y,t[14]=b):b=t[14];let x;t[15]!==d||t[16]!==p?(x=d||p?(0,l.jsxs)(`div`,{className:o(`flex shrink-0 items-center gap-2`,p?`min-w-0 max-w-[50vw] flex-col items-end sm:flex-row sm:justify-end`:`flex-wrap justify-start sm:justify-end`),children:[d,p&&(0,l.jsx)(f,{target:p})]}):null,t[15]=d,t[16]=p,t[17]=x):x=t[17];let S;return t[18]!==g||t[19]!==b||t[20]!==x?(S=(0,l.jsxs)(`header`,{className:g,children:[b,x]}),t[18]=g,t[19]=b,t[20]=x,t[21]=S):S=t[21],S}export{u as n,m as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-0WouolD0.js";import"./settings-page-header-
|
|
1
|
+
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-0WouolD0.js";import"./settings-page-header-DKgbD0Bc.js";var r=e(),i=t();function a(e){let t=(0,r.c)(13),{id:a,activeTab:o,tabIdPrefix:s,panelIdPrefix:c,title:l,hint:u,showHeading:d,framed:f,children:p,className:m}=e,h=d===void 0||d,g=f===void 0||f;if(o!==a)return null;let _=`${c}-${a}`,v=`${s}-${a}`,y=g&&`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,b;t[0]!==m||t[1]!==y?(b=n(`min-w-0`,y,m),t[0]=m,t[1]=y,t[2]=b):b=t[2];let x;t[3]!==u||t[4]!==h||t[5]!==l?(x=h&&(l||u)?(0,i.jsxs)(`div`,{className:`mb-5`,children:[l?(0,i.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:l}):null,u?(0,i.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:u}):null]}):null,t[3]=u,t[4]=h,t[5]=l,t[6]=x):x=t[6];let S;return t[7]!==p||t[8]!==_||t[9]!==v||t[10]!==b||t[11]!==x?(S=(0,i.jsxs)(`section`,{id:_,role:`tabpanel`,"aria-labelledby":v,className:b,children:[x,p]}),t[7]=p,t[8]=_,t[9]=v,t[10]=b,t[11]=x,t[12]=S):S=t[12],S}export{a as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{h as r,p as i,u as a}from"./chunk-KS7C4IRE-BPb7KheU.js";import{i as o,n as s,o as c}from"./locale-store-B4o4aDCg.js";import{a as l,i as u,o as d,r as f,s as p,t as m}from"./dist-CY7CS_D3.js";import{n as h,r as g}from"./popover-select-CLsphyzA.js";import{t as _}from"./lock-keyhole-DEK5kH0u.js";import{t as v}from"./x-B_N4OPjy.js";import{t as y}from"./skeleton-DzdOeGYz.js";import{i as b}from"./vendor-swr-CdRzEUwF.js";import{t as x}from"./button-ChmVQg9O.js";import{n as S,t as C}from"./phone-model-connection-BDzr9jXL.js";var w=e(t(),1),T=n();function E(){let{scene:e,setupId:t}=i(),[n]=r(),E=n.get(`conversationId`)??``,D=n.get(`step`),O=s(e=>e.language)===`zh`,k=a(),[A,j]=(0,w.useState)(!1),M=(0,w.useRef)(null),[N,P]=(0,w.useState)(!1),[F,I]=(0,w.useState)(``),[L,R]=(0,w.useState)(``),z=(0,w.useRef)(!1);(0,w.useEffect)(()=>{z.current=!1,j(!1),R(``),I(``)},[e,t,E]);let B=[`browser`,`phone`].includes(e??``)&&!!(t&&E),V=async(n,r={})=>(await c(o(`/api/${e}/setup`),{method:`POST`,body:JSON.stringify({conversationId:E,setupId:t,action:n,...r})})).payload,{data:H,error:U,mutate:W}=b(B?[`setup-interaction`,e,t,E]:null,()=>V(`get`),{refreshInterval:2e3}),G=e=>e.id===t&&e.conversationId===E&&!e.stale&&![`cancelled`,`completed`].includes(e.state),K=()=>{!N&&!z.current&&k(`/chat/${encodeURIComponent(E)}`,{replace:!0})},q=async(t=``)=>{if(!z.current){z.current=!0,P(!0),I(``);try{let n=await V(`recheck`);if(!G(n))throw Error(`changed`);if(e===`browser`&&!n.endpoints?.some(e=>e.endpointId===t))throw Error(`not-connected`);let r=e===`browser`?O?`允许仅在独立测试页进行读取、点击和示例输入的有界验收,完成后关闭并确认释放,不操作业务网页。`:`I authorize bounded read, click and sample input on the isolated test page only; close and confirm release afterwards. Do not operate business pages.`:``,i=O?`人工配置步骤已完成。${r}请先重新检查本对话 ${e===`browser`?`Browser Use`:`Phone Use`} 的配置进度,继续此前已授权的流程。${t?`本次选择:${t}。`:``}不要扩大设备、权限或任务范围;取消或过期的授权不能恢复。`:`The manual setup step is complete. ${r} Recheck this conversation’s ${e===`browser`?`Browser Use`:`Phone Use`} setup before continuing the previously authorized flow.${t?` Selected target: ${t}.`:``} Do not widen device, permission or task scope, or revive cancelled or expired grants.`,a=new URLSearchParams({draft:i,autoSend:`1`});k(`/chat/${encodeURIComponent(E)}?${a}`,{replace:!0})}catch{z.current=!1,I(O?`尚未检测到有效配置,或原请求已变更。请检查后重试。`:`The setup is not ready or the original request changed. Check and try again.`)}finally{P(!1)}}},J=H&&G(H);if(J&&e===`phone`&&D===`connection`&&H.source===`aliyun`&&!A)return(0,T.jsx)(S,{zh:O,initialMethod:`aliyun`,onClose:K,onSelect:()=>{I(O?`请在原对话确认本机设备。`:`Confirm the local device in the original chat.`)},onAdded:()=>{j(!0),q()}});let Y=e===`browser`?O?`完成浏览器连接`:`Finish browser connection`:D===`model`?O?`配置手机模型`:`Set up Phone model`:O?`完成手机连接`:`Finish phone connection`;return(0,T.jsx)(`main`,{className:`h-full bg-surface-base`,children:(0,T.jsx)(m,{open:!0,onOpenChange:e=>{e||K()},children:(0,T.jsxs)(d,{children:[(0,T.jsx)(l,{className:`fixed inset-0 z-[70] bg-scrim backdrop-blur-sm`}),(0,T.jsxs)(f,{onOpenAutoFocus:e=>{e.preventDefault(),M.current?.focus()},className:`fixed inset-x-0 bottom-0 z-[70] flex h-[min(36rem,calc(100dvh-1rem))] flex-col overflow-hidden rounded-t-3xl border border-edge bg-surface-overlay text-fg sm:inset-x-auto sm:bottom-auto sm:left-1/2 sm:top-1/2 sm:w-[30rem] sm:-translate-x-1/2 sm:-translate-y-1/2 sm:rounded-3xl`,children:[(0,T.jsxs)(`header`,{className:`relative shrink-0 px-6 pb-5 pt-8 text-center`,children:[(0,T.jsx)(x,{variant:`ghost`,className:`absolute right-2 top-2 size-11 p-0`,disabled:N,"aria-label":O?`暂时关闭`:`Close for now`,onClick:K,children:(0,T.jsx)(v,{className:`size-4`,"aria-hidden":!0})}),(0,T.jsx)(_,{className:`mx-auto mb-4 size-6 text-accent-fg`,"aria-hidden":!0}),(0,T.jsx)(p,{ref:M,tabIndex:-1,className:`text-xl font-semibold focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:Y}),(0,T.jsx)(u,{className:`mt-3 text-sm text-fg-muted`,children:O?`只完成需要你操作的一步,密钥不会进入对话。`:`Complete only the step that needs you. Secrets never enter the conversation.`})]}),(0,T.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-6 pb-5`,children:[!H&&!U&&B?(0,T.jsx)(y,{className:`h-32 w-full rounded-xl`}):J?e===`phone`&&D===`model`?(0,T.jsx)(C,{zh:O,value:H.readiness?.model.ref??``,disabled:N,onSave:async e=>{P(!0);try{await V(`set_model`,{modelRef:e,expectedRevision:H.revision,replaceExisting:!0}),await W()}finally{P(!1)}await q()}}):(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:e===`browser`?O?`在 Gateway 所在电脑的 Chrome 加载已准备的扩展,并接受你同意的原生权限。随后选择这个 Chrome,系统会在独立测试页验证读取、点击和输入,再释放控制。`:`Load the prepared extension in Chrome on the Gateway computer and accept the native permissions you agree to. Select that Chrome to verify read, click and fill on an isolated test page, then release control.`:O?`连接并解锁 Gateway 所在电脑上的测试手机,按手机提示确认 USB 调试。返回后会重新检查设备,只继续此前授权的设置页测试。`:`Connect and unlock the test phone on the Gateway computer and confirm USB debugging on the phone. The device will be rechecked before the previously authorized Settings test continues.`}),e===`browser`?(0,T.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[(0,T.jsx)(`span`,{children:O?`用于验收的 Chrome`:`Chrome to verify`}),(0,T.jsxs)(h,{"aria-label":O?`用于验收的 Chrome`:`Chrome to verify`,value:L,onChange:e=>R(e.target.value),children:[(0,T.jsx)(g,{value:``,children:O?`选择 Chrome`:`Choose Chrome`}),H.endpoints?.map(e=>(0,T.jsx)(g,{value:e.endpointId,children:e.displayName},e.endpointId))]})]}):null]}):(0,T.jsx)(`p`,{role:`alert`,className:`text-sm text-fg-muted`,children:O?`此配置请求已失效或无法读取,请返回原对话重新检查。`:`This setup is no longer valid or could not be loaded. Return to the original chat to recheck.`}),F?(0,T.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:F}):null]}),(0,T.jsxs)(`footer`,{className:`shrink-0 space-y-2 border-t border-edge p-5 pb-[max(1.25rem,env(safe-area-inset-bottom))]`,children:[J&&!(e===`phone`&&D===`model`)?(0,T.jsx)(x,{variant:`primary`,className:`min-h-12 w-full`,disabled:N||e===`browser`&&!L,onClick:()=>{q(L)},children:e===`browser`?O?`核对并开始安全验收`:`Recheck and start safe test`:O?`检查并继续原对话`:`Recheck and continue in chat`}):null,(0,T.jsx)(x,{variant:`ghost`,className:`min-h-11 w-full`,disabled:N,onClick:K,children:O?`返回原对话`:`Return to original chat`})]})]})]})})})}export{E as SetupInteractionPage};
|