@xopcai/xopc 0.0.421 → 0.0.422
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/dist/background.js +184 -2
- package/dist/browser-ext/dist/sidepanel.js +9 -0
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-CKrylgib.js → activity-store-CvJ9rdwP.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-Dv5Rda4y.js → agent-avatar-dicebear-CFP6g4w7.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-display-B1ycycx2.js → agent-avatar-display-BHBe88Gu.js} +2 -2
- package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-D285zy0S.js → agent-defaults-settings-panel-DlGRuKMv.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-plugin-dialog-D3yCqVan.js → agent-plugin-dialog-C_Dm-u6_.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-DyAuR3rG.js → agents-BdVJHOiK.js} +3 -3
- package/dist/gateway/static/root/assets/{agents-admin-api-CASGzvkW.js → agents-admin-api-Do1Pza0R.js} +1 -1
- package/dist/gateway/static/root/assets/{api-Uk05lF9i.js → api-BQv5dLcH.js} +1 -1
- package/dist/gateway/static/root/assets/{api-C4LxuNzq.js → api-ONg37_fH.js} +1 -1
- package/dist/gateway/static/root/assets/app-link-1j40sJ-z.js +1 -0
- package/dist/gateway/static/root/assets/{app-management-settings-panel-CDnZNKHt.js → app-management-settings-panel-B4Wqhf4J.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-CmCF7PZ5.js → appearance-settings-Dm1kRzKL.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-BR9qoA2P.js → apps-page-D1MMk1P7.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-nuHYYVty.js → archive-plugin-p_yLkyaC.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-api-DtJfd1QM.js → automation-api-DQaWBR03.js} +1 -1
- package/dist/gateway/static/root/assets/automation-result-state-CO_243JM.js +1 -0
- package/dist/gateway/static/root/assets/automation-task-card-D2p9qlYE.js +3 -0
- package/dist/gateway/static/root/assets/{automations-page-DM4IdUJh.js → automations-page-Ba64H37d.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-BkzC3oIM.js +9 -0
- package/dist/gateway/static/root/assets/{binary-plugins-CHCAr8jt.js → binary-plugins-B-6kyqtt.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-B0v8KxsO.js → block-editor-B5ysJ96n.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automation-inputs-DjUW7PEB.js → browser-automation-inputs-C2A3NIt3.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page-Cf8AoQz1.js → browser-automations-page-CnbXFw1_.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-control-api-C6NZgaA1.js → browser-control-api-Aj_seKE9.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-DV2FNEDf.js → browser-settings-page-C7fxPq_z.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-CwdjWz2r.js → capabilities-BgtCwC_E.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-D0-HCZ5J.js → capabilities-DOTgaSgA.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-page-DwDkritH.js → capabilities-page-m3b9sLFG.js} +2 -2
- package/dist/gateway/static/root/assets/{capabilities-settings-panel-mme16Fbp.js → capabilities-settings-panel-pYWZtPeU.js} +3 -3
- package/dist/gateway/static/root/assets/{channels-lKFLu8p-.js → channels-DGpRM6pj.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-agents-api-l80cvSac.js → chat-agents-api-EvJ_Wvuc.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-chart-block-BwP5QXEk.js → chat-chart-block-BQDbHLcw.js} +1 -1
- package/dist/gateway/static/root/assets/chat-page-GF9NIuZN.js +72 -0
- package/dist/gateway/static/root/assets/{chat-terminal-dock-D2bV9YUL.js → chat-terminal-dock-DHFTGoEp.js} +2 -2
- package/dist/gateway/static/root/assets/{command-palette-api-CtapG8ck.js → command-palette-api-DPA_yEuy.js} +1 -1
- package/dist/gateway/static/root/assets/{composer-payload-handoff-DYuhKZRC.js → composer-payload-handoff-BTjauSNp.js} +1 -1
- package/dist/gateway/static/root/assets/{computer-settings-page-DZtMuihL.js → computer-settings-page-BFSSQfcx.js} +1 -1
- package/dist/gateway/static/root/assets/{connected-providers-grid-BQH5k3iC.js → connected-providers-grid-DM2glQN3.js} +1 -1
- package/dist/gateway/static/root/assets/{connector-service-page-DrvFdP3G.js → connector-service-page-CFvg58qa.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-api-BzkgVBYC.js → connectors-api-CbC6Yht5.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-BtRNVCFy.js → connectors-page-D7pipFHA.js} +1 -1
- package/dist/gateway/static/root/assets/date-picker-Dd3MbG0x.js +1 -0
- package/dist/gateway/static/root/assets/{dependency-picker-Dh8hPmsT.js → dependency-picker-DcsHg2ml.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-CFz8bqyI.js → desktop-pet-DldzQT2h.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-COaboNn1.js → desktop-pet-settings-CYdI4KxB.js} +1 -1
- package/dist/gateway/static/root/assets/{dev-view-store-D8XYHVqG.js → dev-view-store-JiJv585f.js} +1 -1
- package/dist/gateway/static/root/assets/device-pairing-wizard-D8cLc41G.js +1 -0
- package/dist/gateway/static/root/assets/{directory-picker-path-field-Cjv7rdo3.js → directory-picker-path-field-8WOXv8zw.js} +1 -1
- package/dist/gateway/static/root/assets/{discussion-annotation-sync-YvlVw17j.js → discussion-annotation-sync-B-grSe0w.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-CXx3m5-B.js → extension-debug-page-EEQkTNEu.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-iframe-host-CnOdNwbo.js → extension-iframe-host-vlZVeMCY.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-marketplace-api-BABmUY2s.js → extension-marketplace-api-_o2In_al.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-C1nGr4DD.js → extension-page-CPrT111s.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-provider-BA0Y2Rvs.js → extension-provider-B2Mf3FBu.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-QIPI8e7k.js → extension-settings-page-CznJEgWV.js} +1 -1
- package/dist/gateway/static/root/assets/{file-preview-surface-BsB7bnFH.js → file-preview-surface-7h8_fZul.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-Bt8w0Iio.js → gateway-config-swr-DbbNEOKj.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-realtime-CyCCNUxm.js → gateway-realtime-D20ZrAuM.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-C6sMzYDT.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-restart-Ty4AzDxa.js → gateway-restart-5ut-lhJm.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-BvKq7vuz.js → gateway-settings-BCf_cibp.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-N3k-C7c2.js → gateway-startup-retry-DlHL0DpH.js} +1 -1
- package/dist/gateway/static/root/assets/{global-defaults-api-D8EB2vfY.js → global-defaults-api-CmODomcV.js} +1 -1
- package/dist/gateway/static/root/assets/{home-page-eRuAzi58.js → home-page-uz22TRB-.js} +2 -2
- package/dist/gateway/static/root/assets/{image-generation-api-C99Fsofm.js → image-generation-api-dzPnpUFu.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-Cp9RquVb.js → imports-page-ChBoNMyE.js} +1 -1
- package/dist/gateway/static/root/assets/index-CSIg7V1A.js +11 -0
- package/dist/gateway/static/root/assets/index-Dv8mUlNN.css +1 -0
- package/dist/gateway/static/root/assets/{install-connector-dialog-CsoAidXp.js → install-connector-dialog-CNcdQDX0.js} +1 -1
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-DFhOP2aD.js → keyboard-shortcuts-settings-CRbYq2_g.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-DbtU_A-l.js → local-app-workbench-page-04cX5TJu.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-rjhHfLpe.js → local-apps-page-fWM0FEhN.js} +1 -1
- package/dist/gateway/static/root/assets/{local-session-drafts-DHM4vWDO.js → local-session-drafts-ClrSe5mH.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-5Hf8J8-_.js → locale-store-VNjH18Dj.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-Dx_JIOpF.js → logs-page-6GanGLrm.js} +1 -1
- package/dist/gateway/static/root/assets/management-settings-BxD_lc4E.js +1 -0
- package/dist/gateway/static/root/assets/{markdown-view-pzSRu7av.js → markdown-view-DLCBYWtx.js} +2 -2
- package/dist/gateway/static/root/assets/{media-plugins-3cJuHbO7.js → media-plugins-BvtNwKFb.js} +1 -1
- package/dist/gateway/static/root/assets/{messages-uXxg5p54.js → messages-Btr7C0hF.js} +2 -2
- package/dist/gateway/static/root/assets/{model-selector-ksLo-5B_.js → model-selector-DYUnp917.js} +1 -1
- package/dist/gateway/static/root/assets/{models-hub-cache-DhZng2nF.js → models-hub-cache-_qE7L-_H.js} +1 -1
- package/dist/gateway/static/root/assets/{note-detail-panel-B6RbjwJq.js → note-detail-panel-bjRZesmS.js} +3 -3
- package/dist/gateway/static/root/assets/note-image-lightbox-D7Jqb75C.js +1 -0
- package/dist/gateway/static/root/assets/{notes-api-DocbsBbT.js → notes-api-Bxa11X3a.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-page-B7889s6-.js → notes-page-D2QpJ3WZ.js} +1 -1
- package/dist/gateway/static/root/assets/{oauth-api-CCFIPbA0.js → oauth-api-DIE4UpP7.js} +1 -1
- package/dist/gateway/static/root/assets/{oauth-provider-connect-GxkF0vWJ.js → oauth-provider-connect-B95tiddN.js} +1 -1
- package/dist/gateway/static/root/assets/{page-context-capture-button-CvWLVeRA.js → page-context-capture-button-C-QbbwmN.js} +1 -1
- package/dist/gateway/static/root/assets/{page-context-draft-CMRDNv4d.js → page-context-draft-BHmOfksL.js} +1 -1
- package/dist/gateway/static/root/assets/page-header-store-bPV8_tKL.js +1 -0
- package/dist/gateway/static/root/assets/{personal-avatar-CqNJ48Ge.js → personal-avatar-nXrmMfrV.js} +1 -1
- package/dist/gateway/static/root/assets/personal-page-BCwlYT3F.js +1 -0
- package/dist/gateway/static/root/assets/{personal-settings-panel-DAcl8DU4.js → personal-settings-panel-vkYmXK8h.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-dependencies-card-DLWblGj7.js → phone-dependencies-card-CZDAxTWv.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-model-picker-ugrT9GJu.js → phone-model-picker-4Snfs8Hq.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-settings-page-DIIt7JOE.js → phone-settings-page-D8HperfA.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-workspace-store-mawKT5kV.js → phone-workspace-store-Di9R9Ux5.js} +1 -1
- package/dist/gateway/static/root/assets/{plugin-details-dialog-BdueMT3q.js → plugin-details-dialog-DJsDu-_8.js} +1 -1
- package/dist/gateway/static/root/assets/{preference-select-fields-CmLZNwbm.js → preference-select-fields-C6abaM3k.js} +1 -1
- package/dist/gateway/static/root/assets/{product-automation-feedback-DYwhL37Y.js → product-automation-feedback-C74s9Mjz.js} +1 -1
- package/dist/gateway/static/root/assets/product-delivery-DRyD9_Xq.js +1 -0
- package/dist/gateway/static/root/assets/{product-open-page-B5G4X71t.js → product-open-page-AbDP5w1c.js} +1 -1
- package/dist/gateway/static/root/assets/product-preview-content-CktjvFbc.js +1 -0
- package/dist/gateway/static/root/assets/product-preview-modal-CzsqLwB4.js +2 -0
- package/dist/gateway/static/root/assets/{project-detail-page-CRJb69vP.js → project-detail-page-Cf3tggGP.js} +2 -2
- package/dist/gateway/static/root/assets/{project-understanding-D3w8cZEm.js → project-understanding-jmhFbHch.js} +1 -1
- package/dist/gateway/static/root/assets/{projects-page-CkifzKjz.js → projects-page-jMgZiFnO.js} +1 -1
- package/dist/gateway/static/root/assets/{providers-api-CKFg2PZQ.js → providers-api-CJBYFKAK.js} +1 -1
- package/dist/gateway/static/root/assets/{recording-upload-ZkmRf0GR.js → recording-upload-Dl9a5yOV.js} +1 -1
- package/dist/gateway/static/root/assets/{registry-api-B1Mh3bNo.js → registry-api-BwkbPUYu.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-Dw5rG-aA.js → remote-access-hub-CBQ_bOy9.js} +1 -1
- package/dist/gateway/static/root/assets/{resource-unavailable-BUWsH3fp.js → resource-unavailable-35wBZxmz.js} +1 -1
- package/dist/gateway/static/root/assets/route-preload-BcA6SPeC.js +2 -0
- package/dist/gateway/static/root/assets/{runtime-tools-api-BXvn5ImA.js → runtime-tools-api-BF28JDAO.js} +1 -1
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-BALcypHp.js → runtime-tools-settings-panel-Bq2xQ2qd.js} +1 -1
- package/dist/gateway/static/root/assets/{service-recommendation-list-CpVUnz89.js → service-recommendation-list-CdaS4MPF.js} +1 -1
- package/dist/gateway/static/root/assets/{session-api-VquhIBHI.js → session-api-zJXYlRPt.js} +1 -1
- package/dist/gateway/static/root/assets/session-manager-wWxpzSo0.js +23 -0
- package/dist/gateway/static/root/assets/{sessions-page-DlvPkE5Y.js → sessions-page-BkjD_dUD.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BUMCEtA_.js +1 -0
- package/dist/gateway/static/root/assets/{settings-advanced-section-c9_iZ-46.js → settings-advanced-section-C84IghdL.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-mode-store-Dem6-TBe.js → settings-mode-store-CtQBJvbO.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-B_wNfFQe.js → settings-page-eEIz9InP.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-header-C8a_oOyw.js → settings-page-header-CsPAYlqV.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-CTSRWljG.js → settings-page-layout-lPLeJQoV.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-BNZoqF40.js → setup-status-panel-BSU5WpaE.js} +1 -1
- package/dist/gateway/static/root/assets/{share-link-dialog-C5JTTxsy.js → share-link-dialog-NaM6jvIz.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-D-KxzXgm.js → share-preview-page-CHjZn27s.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-api-CztKbxdd.js → shares-api-B9rVcV1y.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-CzR21j6e.js → shares-settings-5sB15V5v.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-api-B7kWl6LK.js → skill-api-D6zVfEuK.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-list-api-Cn07P6qZ.js → skill-list-api-SLmTBYF5.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-reload-api-Bhl0u16_.js → skill-reload-api-UQkq2orI.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-BmkuxHZe.js → skills-page-Ca0pYZ4i.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-Ce6zIcki.js → system-settings-panel-BARWbjRN.js} +1 -1
- package/dist/gateway/static/root/assets/{task-detail-page-CysJhG3B.js → task-detail-page-roqAsGue.js} +2 -2
- package/dist/gateway/static/root/assets/{task-result-evidence-CGZKMnNo.js → task-result-evidence-Bb1F7nAM.js} +1 -1
- package/dist/gateway/static/root/assets/{terminal-panel-store-YwLUkuyV.js → terminal-panel-store-DYDeXXAg.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-DOJ9tu-j.js → theme-store-DbStcH89.js} +1 -1
- package/dist/gateway/static/root/assets/{tracing-settings-page-BplBpTdL.js → tracing-settings-page-YfkNCxbP.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-B5-Ypvqa.js → tunnel-api-BK_ivyIb.js} +1 -1
- package/dist/gateway/static/root/assets/{understanding-activity-store-CmwtE8Kd.js → understanding-activity-store-p7Z7oq8z.js} +1 -1
- package/dist/gateway/static/root/assets/{understanding-refresh-store-9apSmAVL.js → understanding-refresh-store-D-U6rcwZ.js} +1 -1
- package/dist/gateway/static/root/assets/{usage-page-cPbirpXX.js → usage-page-URFSiswS.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-B3p2QWaF.js → use-autosave-B7cbumro.js} +1 -1
- package/dist/gateway/static/root/assets/{use-composer-attachments-D-AEYC85.js → use-composer-attachments-DAtiwLsE.js} +1 -1
- package/dist/gateway/static/root/assets/{use-file-preview-expanded-CO4SC-LX.js → use-file-preview-expanded-B8erpWsX.js} +2 -2
- package/dist/gateway/static/root/assets/{use-personal-profile-DocmhC9I.js → use-personal-profile-DDW29nm-.js} +1 -1
- package/dist/gateway/static/root/assets/{use-workspace-tree-VraTGKx-.js → use-workspace-tree-DCoTf22f.js} +1 -1
- package/dist/gateway/static/root/assets/{user-model-page-DuRALzhe.js → user-model-page-DSV5NkNj.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-DbSQHZZW.js → voice-api-key-field-DzYdJZN4.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-D9iNJSvm.js → voice-config-api-wotvT6Hw.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-input-shortcut-events-hso9_VvT.js → voice-input-shortcut-events-BI6PuiIB.js} +1 -1
- package/dist/gateway/static/root/assets/voice-transcribe-api-DAK9eLRr.js +1 -0
- package/dist/gateway/static/root/assets/{work-discovery-overlay-fsL9RJqB.js → work-discovery-overlay-BzmB9Rub.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-page-DAQPKVDs.js → work-discovery-page-CmGjxUIT.js} +1 -1
- package/dist/gateway/static/root/assets/{working-directory-picker-modal-Ta73QrNw.js → working-directory-picker-modal-B-EHm52-.js} +1 -1
- package/dist/gateway/static/root/assets/{workspace-api-CgrcNyBc.js → workspace-api-uhiEMPpK.js} +2 -2
- package/dist/gateway/static/root/assets/workspace-editor-agent-store-DrPVyikA.js +1 -0
- package/dist/gateway/static/root/assets/{workspace-file-preview-dialog-B7uBuPtA.js → workspace-file-preview-dialog-BDm06MZm.js} +1 -1
- package/dist/gateway/static/root/assets/{workspace-open-location-menu-Bi2vRvaQ.js → workspace-open-location-menu-Bv83uoqu.js} +1 -1
- package/dist/gateway/static/root/assets/{xopc-cloud-account-card-CCOOBG-7.js → xopc-cloud-account-card-Cd5GdpGL.js} +1 -1
- package/dist/gateway/static/root/index.html +84 -84
- package/dist/gateway/static/root/notification-sw.js +21 -7
- package/dist/package.js +1 -1
- package/dist/packages/endpoint-tools-protocol/src/context.js +115 -0
- package/dist/packages/endpoint-tools-protocol/src/index.js +4 -0
- package/dist/packages/endpoint-tools-protocol/src/location-sharing.js +51 -0
- package/dist/packages/gateway-contract/src/gateway-scopes.js +5 -1
- package/dist/packages/gateway-contract/src/index.js +2 -0
- package/dist/packages/gateway-contract/src/phone-workspace.js +6 -0
- package/dist/packages/gateway-contract/src/product-delivery.js +9 -3
- package/dist/src/agent/embedded/external-tool-discovery.js +1 -1
- package/dist/src/agent/embedded/run-for-session.js +2 -2
- package/dist/src/agent/embedded/run-turn.js +72 -9
- package/dist/src/agent/embedded/session-runner.js +2 -1
- package/dist/src/agent/embedded/types.d.ts +1 -1
- package/dist/src/agent/prompt/system-prompt.js +1 -0
- package/dist/src/agent/service/direct-turn-helpers.d.ts +0 -7
- package/dist/src/agent/service/direct-turn-helpers.js +3 -2
- package/dist/src/agent/service/process-direct-streaming.js +2 -1
- package/dist/src/agent/source-context/device-environment.d.ts +3 -0
- package/dist/src/agent/source-context/device-environment.js +38 -0
- package/dist/src/agent/source-context/injector.js +2 -1
- package/dist/src/agent/tool-manuals/phone.d.ts +1 -1
- package/dist/src/agent/tool-manuals/phone.js +1 -1
- package/dist/src/agent/tools/automation-tool.js +3 -2
- package/dist/src/agent/tools/factory.js +1 -1
- package/dist/src/agent/tools/personal-read-tool.js +1 -1
- package/dist/src/agent/tools/phone-use-tool.js +46 -2
- package/dist/src/agent/tools/xopc-use-tool.js +1 -0
- package/dist/src/computer/runtime.d.ts +1 -1
- package/dist/src/config/schema.d.ts +1 -0
- package/dist/src/endpoint-tools/context-store.d.ts +29 -0
- package/dist/src/endpoint-tools/context-store.js +138 -0
- package/dist/src/endpoint-tools/location-sharing.d.ts +42 -0
- package/dist/src/endpoint-tools/location-sharing.js +203 -0
- package/dist/src/endpoint-tools/runtime.d.ts +4 -0
- package/dist/src/endpoint-tools/runtime.js +8 -0
- package/dist/src/endpoint-tools/turn-context.d.ts +2 -1
- package/dist/src/endpoint-tools/turn-context.js +4 -2
- package/dist/src/gateway/hono/middleware/auth.js +1 -1
- package/dist/src/gateway/hono/routes/devices.js +1 -0
- package/dist/src/gateway/hono/routes/endpoint-compatibility.js +4 -0
- package/dist/src/gateway/hono/routes/endpoint-environment.d.ts +3 -0
- package/dist/src/gateway/hono/routes/endpoint-environment.js +98 -0
- package/dist/src/gateway/hono/routes/endpoint-tools.js +1 -0
- package/dist/src/gateway/hono/routes/lazy-bundles.js +16 -0
- package/dist/src/gateway/hono/routes/location-sharing.d.ts +3 -0
- package/dist/src/gateway/hono/routes/location-sharing.js +164 -0
- package/dist/src/gateway/hono/routes/phone.js +246 -34
- package/dist/src/gateway/hono/routes/session-command-handler.js +1 -1
- package/dist/src/gateway/hono/routes/session-input-handler.js +2 -1
- package/dist/src/gateway/hono/routes/tunnel.js +10 -0
- package/dist/src/gateway/security/gateway-scopes.js +6 -0
- package/dist/src/gateway/security/phone-access.d.ts +4 -0
- package/dist/src/gateway/security/phone-access.js +20 -0
- package/dist/src/gateway/service/agent-runner.js +3 -1
- package/dist/src/gateway/service/config-coordinator.d.ts +1 -0
- package/dist/src/gateway/service/run-gateway-agent.js +2 -1
- package/dist/src/gateway/service/session-input-coordinator.d.ts +3 -0
- package/dist/src/gateway/service/session-input-coordinator.js +50 -2
- package/dist/src/gateway/service.d.ts +1 -0
- package/dist/src/gateway/service.js +8 -0
- package/dist/src/gateway/session-reset-service.js +4 -0
- package/dist/src/notifications/planner.js +6 -6
- package/dist/src/phone/assistance-service.d.ts +6 -0
- package/dist/src/phone/assistance-service.js +32 -0
- package/dist/src/phone/assistance.d.ts +40 -0
- package/dist/src/phone/assistance.js +273 -0
- package/dist/src/phone/cloud-phones.d.ts +5 -0
- package/dist/src/phone/cloud-phones.js +14 -0
- package/dist/src/phone/contracts.d.ts +7 -1
- package/dist/src/phone/contracts.js +5 -0
- package/dist/src/phone/environment-adapter.d.ts +3 -0
- package/dist/src/phone/environment-adapter.js +11 -0
- package/dist/src/phone/location-baseline-store.d.ts +9 -0
- package/dist/src/phone/location-baseline-store.js +61 -0
- package/dist/src/phone/location-environment.d.ts +61 -0
- package/dist/src/phone/location-environment.js +157 -0
- package/dist/src/phone/model-adapter.js +16 -5
- package/dist/src/phone/runtime.d.ts +17 -2
- package/dist/src/phone/runtime.js +203 -20
- package/dist/src/phone/stream-gateway.d.ts +5 -0
- package/dist/src/phone/stream-gateway.js +85 -51
- package/dist/src/phone/wuying-location.d.ts +18 -0
- package/dist/src/phone/wuying-location.js +86 -0
- package/dist/src/storage/sqlite/device-access-repository.d.ts +4 -0
- package/dist/src/storage/sqlite/device-access-repository.js +18 -1
- package/dist/src/tunnel/broker-client.d.ts +8 -0
- package/dist/src/tunnel/broker-client.js +18 -1
- package/dist/src/voice/realtime/runtime.js +1 -1
- package/package.json +4 -3
- package/dist/gateway/static/root/assets/app-link-CytZ5zkp.js +0 -1
- package/dist/gateway/static/root/assets/automation-display-BlGt8MAC.js +0 -2
- package/dist/gateway/static/root/assets/automation-task-card-Cp3RIw5d.js +0 -2
- package/dist/gateway/static/root/assets/automations-workspace-CXLu04I-.js +0 -9
- package/dist/gateway/static/root/assets/chat-page-CT3K7lFT.js +0 -71
- package/dist/gateway/static/root/assets/date-picker-ByTasrfl.js +0 -1
- package/dist/gateway/static/root/assets/device-pairing-wizard-BKMpLdIA.js +0 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-0gmDfPeP.js +0 -1
- package/dist/gateway/static/root/assets/index-6vVrWfwM.js +0 -11
- package/dist/gateway/static/root/assets/index-DDGK6klk.css +0 -1
- package/dist/gateway/static/root/assets/management-settings-CuSzixOw.js +0 -1
- package/dist/gateway/static/root/assets/note-image-lightbox-BCjvBqwy.js +0 -1
- package/dist/gateway/static/root/assets/page-header-store-reh1es-3.js +0 -1
- package/dist/gateway/static/root/assets/personal-page-D95FHaw9.js +0 -1
- package/dist/gateway/static/root/assets/product-delivery-BU_H84jL.js +0 -1
- package/dist/gateway/static/root/assets/product-preview-content-BUheyLqt.js +0 -1
- package/dist/gateway/static/root/assets/product-preview-modal-Cj_Zxu4G.js +0 -2
- package/dist/gateway/static/root/assets/route-preload-CRKbVwQ1.js +0 -2
- package/dist/gateway/static/root/assets/session-manager-DNMosCtW.js +0 -23
- package/dist/gateway/static/root/assets/settings-advanced-gate-Ckc1aCLG.js +0 -1
- package/dist/gateway/static/root/assets/voice-transcribe-api-BqIs0jgv.js +0 -1
- package/dist/gateway/static/root/assets/workspace-editor-agent-store-Dw6wtadX.js +0 -1
|
@@ -0,0 +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{n as i}from"./locale-store-VNjH18Dj.js";import{t as a}from"./calendar-days-hw_Y-g-s.js";import{t as ee}from"./chevron-left-DqFhpbvK.js";import{t as te}from"./chevron-right-BweFrslA.js";import{c as ne,l as re,u as ie}from"./popover-select-DD8fmrxH.js";import{t as ae}from"./cn-0WouolD0.js";import{c as oe,n as se,s as ce}from"./dist-CaUuvp8-.js";var o=e(t(),1),le=n();function s(e){return String(e).padStart(2,`0`)}function ue(e){return`${e.getFullYear()}-${s(e.getMonth()+1)}-${s(e.getDate())}`}function de(e){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)return null;let n=Number(t[1]),r=Number(t[2])-1,i=Number(t[3]),a=new Date(n,r,i,12);return a.getFullYear()===n&&a.getMonth()===r&&a.getDate()===i?a:null}function fe(e,t){let n=de(e);return n?t===`zh`?`${n.getFullYear()}/${s(n.getMonth()+1)}/${s(n.getDate())}`:new Intl.DateTimeFormat(`en`,{year:`numeric`,month:`short`,day:`numeric`}).format(n):``}var c=r();function pe(e,t){let n=new Date(e.getFullYear(),e.getMonth(),1,12),r=(n.getDay()-t+7)%7;return Array.from({length:42},(e,t)=>new Date(n.getFullYear(),n.getMonth(),1-r+t,12))}function l(e){let t=(0,le.c)(106),{value:n,onChange:r,disabled:s,className:l,ariaLabel:ve,placeholder:ye,min:u,max:d}=e,f=i(_e),p=f===`zh`?`zh-CN`:`en`,be;t[0]===n?be=t[1]:(be=de(n),t[0]=n,t[1]=be);let m=be,[h,xe]=(0,o.useState)(!1),[Se,Ce]=(0,o.useState)(null),g;t[2]===m?g=t[3]:(g=()=>m??new Date,t[2]=m,t[3]=g);let[_,we]=(0,o.useState)(g),Te=ne(Se),Ee=ie(re(),Te!==null),v=+(f===`zh`),y,b;t[4]!==h||t[5]!==n?(y=()=>{if(!h)return;let e=de(n);e&&we(e)},b=[h,n],t[4]=h,t[5]=n,t[6]=y,t[7]=b):(y=t[6],b=t[7]),(0,o.useEffect)(y,b);let x;t[8]!==_||t[9]!==v?(x=pe(_,v),t[8]=_,t[9]=v,t[10]=x):x=t[10];let De=x,S;if(t[11]!==p||t[12]!==v){let e=new Date(2026,7,23,12);S=Array.from({length:7},(t,n)=>{let r=new Date(e);return r.setDate(e.getDate()+v+n),new Intl.DateTimeFormat(p,{weekday:`narrow`}).format(r)}),t[11]=p,t[12]=v,t[13]=S}else S=t[13];let Oe=S,C;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(C=ue(new Date),t[14]=C):C=t[14];let w=C,T;t[15]===m?T=t[16]:(T=m?ue(m):``,t[15]=m,t[16]=T);let E=T,D;t[17]!==p||t[18]!==_?(D=new Intl.DateTimeFormat(p,{year:`numeric`,month:`long`}).format(_),t[17]=p,t[18]=_,t[19]=D):D=t[19];let ke=D,O;t[20]===r?O=t[21]:(O=e=>{r(e),xe(!1)},t[20]=r,t[21]=O);let k=O,Ae=oe,je=s&&`cursor-not-allowed opacity-50`,A;t[22]!==l||t[23]!==je?(A=ae(`flex h-10 w-full min-w-0 items-center justify-between gap-3 rounded-lg bg-surface-hover px-3 text-left text-sm text-fg outline-none transition-colors`,`hover:bg-surface-active focus-visible:ring-2 focus-visible:ring-accent/40`,je,l),t[22]=l,t[23]=je,t[24]=A):A=t[24];let Me=!n&&`text-fg-subtle`,j;t[25]===Me?j=t[26]:(j=ae(`min-w-0 truncate tabular-nums`,Me),t[25]=Me,t[26]=j);let M;t[27]!==f||t[28]!==ye||t[29]!==n?(M=fe(n,f)||ye||(f===`zh`?`选择日期`:`Select date`),t[27]=f,t[28]=ye,t[29]=n,t[30]=M):M=t[30];let N;t[31]!==j||t[32]!==M?(N=(0,c.jsx)(`span`,{className:j,children:M}),t[31]=j,t[32]=M,t[33]=N):N=t[33];let P;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,c.jsx)(a,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[34]=P):P=t[34];let F;t[35]!==ve||t[36]!==s||t[37]!==A||t[38]!==N?(F=(0,c.jsx)(ce,{asChild:!0,children:(0,c.jsxs)(`button`,{ref:Ce,type:`button`,disabled:s,"aria-label":ve,className:A,children:[N,P]})}),t[35]=ve,t[36]=s,t[37]=A,t[38]=N,t[39]=F):F=t[39];let Ne=oe,Pe=Te??void 0,Fe=oe,Ie=Te??void 0,Le=ae(Ee,`max-h-[var(--radix-popover-content-available-height)] w-[19rem] overflow-y-auto rounded-2xl border border-edge bg-surface-overlay p-3 shadow-float outline-none`),Re=f===`zh`?`上个月`:`Previous month`,I,L;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(I=()=>we(ge),L=(0,c.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),t[40]=I,t[41]=L):(I=t[40],L=t[41]);let R;t[42]===Re?R=t[43]:(R=(0,c.jsx)(`button`,{type:`button`,className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":Re,onClick:I,children:L}),t[42]=Re,t[43]=R);let z;t[44]===ke?z=t[45]:(z=(0,c.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:ke}),t[44]=ke,t[45]=z);let ze=f===`zh`?`下个月`:`Next month`,B,V;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(B=()=>we(he),V=(0,c.jsx)(te,{className:`size-4`,"aria-hidden":!0}),t[46]=B,t[47]=V):(B=t[46],V=t[47]);let H;t[48]===ze?H=t[49]:(H=(0,c.jsx)(`button`,{type:`button`,className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":ze,onClick:B,children:V}),t[48]=ze,t[49]=H);let U;t[50]!==R||t[51]!==z||t[52]!==H?(U=(0,c.jsxs)(`div`,{className:`flex h-10 items-center justify-between gap-2 px-1`,children:[R,z,H]}),t[50]=R,t[51]=z,t[52]=H,t[53]=U):U=t[53];let W;t[54]===Oe?W=t[55]:(W=(0,c.jsx)(`div`,{className:`mt-2 grid grid-cols-7`,"aria-hidden":!0,children:Oe.map(me)}),t[54]=Oe,t[55]=W);let G;if(t[56]!==De||t[57]!==p||t[58]!==d||t[59]!==u||t[60]!==k||t[61]!==E||t[62]!==_){let e;t[64]!==p||t[65]!==d||t[66]!==u||t[67]!==k||t[68]!==E||t[69]!==_?(e=e=>{let t=ue(e),n=t===E,r=t===w,i=e.getMonth()!==_.getMonth(),a=!!(u&&t<u||d&&t>d);return(0,c.jsx)(`button`,{type:`button`,role:`gridcell`,"aria-selected":n,"aria-disabled":a,disabled:a,"aria-label":new Intl.DateTimeFormat(p,{dateStyle:`full`}).format(e),className:ae(`mx-auto flex size-9 items-center justify-center rounded-xl text-sm tabular-nums text-fg transition-colors`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,i&&`text-fg-disabled`,a&&`cursor-not-allowed opacity-35 hover:bg-transparent`,r&&!n&&`bg-accent-soft font-semibold text-accent-fg`,n&&`bg-accent font-semibold text-on-accent hover:bg-accent-hover`),onClick:()=>k(t),children:e.getDate()},t)},t[64]=p,t[65]=d,t[66]=u,t[67]=k,t[68]=E,t[69]=_,t[70]=e):e=t[70],G=De.map(e),t[56]=De,t[57]=p,t[58]=d,t[59]=u,t[60]=k,t[61]=E,t[62]=_,t[63]=G}else G=t[63];let K;t[71]===G?K=t[72]:(K=(0,c.jsx)(`div`,{className:`grid grid-cols-7 gap-y-1`,role:`grid`,children:G}),t[71]=G,t[72]=K);let Be=!n,q;t[73]===k?q=t[74]:(q=()=>k(``),t[73]=k,t[74]=q);let Ve=f===`zh`?`清除`:`Clear`,J;t[75]!==Be||t[76]!==q||t[77]!==Ve?(J=(0,c.jsx)(`button`,{type:`button`,disabled:Be,className:`rounded-lg px-2.5 py-1.5 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg disabled:pointer-events-none disabled:opacity-35`,onClick:q,children:Ve}),t[75]=Be,t[76]=q,t[77]=Ve,t[78]=J):J=t[78];let He=!!(u&&w<u||d&&w>d),Y;t[79]===k?Y=t[80]:(Y=()=>k(w),t[79]=k,t[80]=Y);let Ue=f===`zh`?`今天`:`Today`,X;t[81]!==He||t[82]!==Y||t[83]!==Ue?(X=(0,c.jsx)(`button`,{type:`button`,disabled:He,className:`rounded-lg bg-accent-soft px-2.5 py-1.5 text-xs font-medium text-accent-fg hover:bg-accent-soft/80 disabled:pointer-events-none disabled:opacity-35`,onClick:Y,children:Ue}),t[81]=He,t[82]=Y,t[83]=Ue,t[84]=X):X=t[84];let Z;t[85]!==J||t[86]!==X?(Z=(0,c.jsxs)(`div`,{className:`mt-2 flex items-center justify-between px-1 pt-1`,children:[J,X]}),t[85]=J,t[86]=X,t[87]=Z):Z=t[87];let We;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(We=(0,c.jsx)(se,{className:`fill-surface-overlay`}),t[88]=We):We=t[88];let Q;t[89]!==Fe.Content||t[90]!==Ie||t[91]!==Le||t[92]!==U||t[93]!==W||t[94]!==K||t[95]!==Z?(Q=(0,c.jsxs)(Fe.Content,{align:`start`,sideOffset:6,collisionPadding:12,collisionBoundary:Ie,className:Le,children:[U,W,K,Z,We]}),t[89]=Fe.Content,t[90]=Ie,t[91]=Le,t[92]=U,t[93]=W,t[94]=K,t[95]=Z,t[96]=Q):Q=t[96];let $;t[97]!==Ne.Portal||t[98]!==Pe||t[99]!==Q?($=(0,c.jsx)(Ne.Portal,{container:Pe,children:Q}),t[97]=Ne.Portal,t[98]=Pe,t[99]=Q,t[100]=$):$=t[100];let Ge;return t[101]!==h||t[102]!==Ae.Root||t[103]!==F||t[104]!==$?(Ge=(0,c.jsxs)(Ae.Root,{open:h,onOpenChange:xe,children:[F,$]}),t[101]=h,t[102]=Ae.Root,t[103]=F,t[104]=$,t[105]=Ge):Ge=t[105],Ge}function me(e,t){return(0,c.jsx)(`div`,{className:`flex h-8 items-center justify-center text-[11px] font-medium text-fg-subtle`,children:e},`${e}-${t}`)}function he(e){return new Date(e.getFullYear(),e.getMonth()+1,1,12)}function ge(e){return new Date(e.getFullYear(),e.getMonth()-1,1,12)}function _e(e){return e.language}export{l as t};
|
|
@@ -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{t as i}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./chevron-down-ccbiQQz_.js";import{T as s}from"./use-file-preview-expanded-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./chevron-down-ccbiQQz_.js";import{T as s}from"./use-file-preview-expanded-B8erpWsX.js";import{t as c}from"./search-DA7gz22f.js";import{t as l}from"./x-B_N4OPjy.js";import{t as u}from"./cn-0WouolD0.js";import{t as d}from"./button-CnRSIP6m.js";import{a as f,i as p,o as m,r as h,s as g}from"./copy-text-row-CYIv7RfP.js";var _=n(),v=e(t(),1),y=r(),b=`!z-[10000] max-w-[min(28rem,90vw)] rounded-md border border-edge bg-surface-overlay px-2.5 py-2 text-left text-xs leading-relaxed text-fg shadow-lg`;function x(e){let t=(0,_.c)(31),{candidates:n,selectedIds:r,labels:x,disabled:C,borderless:w,getTaskHref:T,onChange:E}=e,D=w!==void 0&&w,[O,k]=(0,v.useState)(!1),[A,j]=(0,v.useState)(``),M;t[0]===A?M=t[1]:(M=A.trim().toLocaleLowerCase(),t[0]=A,t[1]=M);let N=M,P;if(t[2]!==n||t[3]!==N){let e;t[5]===N?e=t[6]:(e=e=>!N||e.title.toLocaleLowerCase().includes(N),t[5]=N,t[6]=e),P=n.filter(e).slice(0,20),t[2]=n,t[3]=N,t[4]=P}else P=t[4];let F=P,I;t[7]!==n||t[8]!==C||t[9]!==T||t[10]!==x.remove||t[11]!==E||t[12]!==r?(I=r.length>0?(0,y.jsx)(`div`,{className:`flex min-w-0 flex-wrap gap-2`,children:r.map(e=>{let t=n.find(t=>t.id===e);return t?(0,y.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-lg bg-surface-hover px-2.5 py-1.5 text-xs text-fg-muted`,children:[(0,y.jsxs)(m,{children:[(0,y.jsx)(g,{asChild:!0,children:T?(0,y.jsx)(i,{to:T(t.id),className:`min-w-0 whitespace-normal break-words [overflow-wrap:anywhere] rounded-sm outline-none transition-colors hover:text-fg hover:underline focus-visible:ring-2 focus-visible:ring-accent/50`,children:t.title}):(0,y.jsx)(`span`,{className:`min-w-0 whitespace-normal break-words [overflow-wrap:anywhere]`,children:t.title})}),(0,y.jsx)(p,{children:(0,y.jsx)(h,{side:`top`,sideOffset:6,collisionPadding:12,className:b,children:(0,y.jsx)(`span`,{className:`break-words`,children:t.title})})})]}),(0,y.jsx)(`button`,{type:`button`,className:`shrink-0 rounded text-fg-subtle transition-colors hover:text-fg`,"aria-label":x.remove.replace(`{{task}}`,t.title),disabled:C,onClick:()=>E(r.filter(e=>e!==t.id)),children:(0,y.jsx)(l,{className:`size-3.5`,"aria-hidden":!0})})]},t.id):null})}):null,t[7]=n,t[8]=C,t[9]=T,t[10]=x.remove,t[11]=E,t[12]=r,t[13]=I):I=t[13];let L;t[14]!==D||t[15]!==n.length||t[16]!==C||t[17]!==x.link||t[18]!==x.linked||t[19]!==x.noCandidates||t[20]!==x.noMatches||t[21]!==x.searchPlaceholder||t[22]!==F||t[23]!==E||t[24]!==O||t[25]!==A||t[26]!==r?(L=n.length>0?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(d,{type:`button`,variant:`secondary`,className:u(`w-fit rounded-lg`,D&&`border-0 bg-surface-hover shadow-none`),disabled:C,"aria-expanded":O,onClick:()=>k(S),children:[(0,y.jsx)(s,{className:`size-4`,"aria-hidden":!0}),r.length>0?x.linked.replace(`{{count}}`,String(r.length)):x.link,(0,y.jsx)(o,{className:u(`size-3.5 transition-transform`,O&&`rotate-180`),"aria-hidden":!0})]}),O?(0,y.jsxs)(`div`,{className:u(`grid gap-2 rounded-lg p-2`,D?`bg-surface-hover`:`border border-edge bg-surface-base`),children:[(0,y.jsxs)(`label`,{className:`relative block`,children:[(0,y.jsx)(c,{className:`pointer-events-none absolute left-2.5 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,y.jsx)(`input`,{value:A,onChange:e=>j(e.target.value),placeholder:x.searchPlaceholder,className:u(`h-9 w-full rounded-md bg-surface-panel pl-8 pr-3 text-sm text-fg outline-none placeholder:text-fg-subtle`,D?`focus:ring-2 focus:ring-accent/30`:`border border-edge focus:border-accent`),autoFocus:!0})]}),F.length>0?(0,y.jsx)(`div`,{className:`grid max-h-52 gap-1 overflow-y-auto`,children:F.map(e=>{let t=r.includes(e.id);return(0,y.jsxs)(`button`,{type:`button`,"aria-pressed":t,disabled:C,onClick:()=>E(t?r.filter(t=>t!==e.id):[...r,e.id]),className:u(`flex items-center gap-2 rounded-md px-2.5 py-2 text-left text-sm transition-colors`,t?`bg-accent-soft text-accent-fg`:`text-fg hover:bg-surface-hover`),children:[(0,y.jsx)(`span`,{className:u(`flex size-4 shrink-0 items-center justify-center rounded`,D?t?`bg-accent text-on-accent`:`bg-surface-active`:t?`border border-accent bg-accent text-on-accent`:`border border-edge`),children:t?(0,y.jsx)(a,{className:`size-3`,"aria-hidden":!0}):null}),(0,y.jsx)(`span`,{className:`min-w-0 flex-1 whitespace-normal break-words [overflow-wrap:anywhere]`,children:e.title})]},e.id)})}):(0,y.jsx)(`p`,{className:`px-2 py-3 text-center text-sm text-fg-subtle`,children:x.noMatches})]}):null]}):(0,y.jsx)(`p`,{className:`text-sm text-fg-subtle`,children:x.noCandidates}),t[14]=D,t[15]=n.length,t[16]=C,t[17]=x.link,t[18]=x.linked,t[19]=x.noCandidates,t[20]=x.noMatches,t[21]=x.searchPlaceholder,t[22]=F,t[23]=E,t[24]=O,t[25]=A,t[26]=r,t[27]=L):L=t[27];let R;return t[28]!==I||t[29]!==L?(R=(0,y.jsx)(f,{delayDuration:300,children:(0,y.jsxs)(`div`,{className:`min-w-0 grid gap-2`,children:[I,L]})}),t[28]=I,t[29]=L,t[30]=R):R=t[30],R}function S(e){return!e}export{x as t};
|
|
@@ -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{n as i}from"./locale-store-5Hf8J8-_.js";import{t as a}from"./messages-uXxg5p54.js";import{t as o}from"./resource-unavailable-BUWsH3fp.js";import{t as s}from"./chevron-down-ccbiQQz_.js";import{t as c}from"./x-B_N4OPjy.js";import{t as l}from"./desktop-pet-narrative-CS8qJpNO.js";import{t as u}from"./desktop-pet-sprite-D5YYq2zC.js";var d=e(t(),1),f=n(),p=9e4,m=3e4,h=20*6e4,g=45e3,_=45*6e4,v=58;function y(e,t){return e.state===`running`&&t-(e.startedAt??e.timestamp)>=p}function b(e,t){return e.state===`running`&&t-e.timestamp>=m}function x(e,t,n){if(e.progress){let t=`${e.progress.completed}/${e.progress.total}`;return e.action.includes(t)?``:` · ${t}`}return e.detail&&!e.action.includes(e.detail)?n.replace(/\{\{detail\}\}/g,e.detail):e.state===`running`?` · ${Math.max(1,Math.floor((t-e.timestamp)/1e3))}s`:``}function S(e,t){if(e.state!==`success`||!e.publicSummary)return;let n=e.publicSummary.replace(/\s+/g,` `).trim(),r=n.length>v?`${n.slice(0,v-1)}…`:n;return t.replace(/\{\{summary\}\}/g,r)}function C(e,t,n){if(b(e,t))return n.stale;if(y(e,t))return n.longRunning}function w(e,t){let n=e.feedback?.reassurance;return n?t[n]:void 0}function ee(e){let t=e.now-e.lastActivityAt,n=t>=h?(t-h)%_:1/0;return e.bubbleEnabled&&e.behaviorMode!==`focus`&&e.proactiveTipsEnabled&&(!e.remindersPausedUntil||e.now>=e.remindersPausedUntil)&&!e.collapsed&&e.queuedCount===0&&e.activeCount===0&&n<=g&&e.now>=e.dismissedUntil}function T(e,t,n){return e.state===`waiting`||e.state===`error`?`action_required`:e.state===`success`?t===`focus`?`ambient`:`notice`:b(e,n)||t===`playful`||t===`companion`&&y(e,n)?`notice`:`ambient`}function E(e,t,n,r){let i=T(e,t,n);return i===`action_required`?!0:r&&n<r?!1:i===`notice`}var D=8e3;function O(e,t){let n=e?.runId===t.runId,r=t.feedback?.sensitivity===`private`;return{...n?e:void 0,...t,startedAt:n?e.startedAt??e.timestamp:t.timestamp,publicSummary:r?void 0:t.publicSummary??(n?e.publicSummary:void 0),feedback:t.feedback??(n?e.feedback:void 0),expiresAt:t.state===`success`?t.timestamp+D:void 0}}function k(e,t){let n={...e};for(let e of t){let t=n[e.conversationId];t?.runId===e.runId&&e.sequence<=t.sequence||(n[e.conversationId]=O(t,e))}return n}function A(e,t){return t?.runId===e.runId&&t.state===e.state}function j(e,t){let n={error:0,waiting:1,running:2,success:3};return e.filter(e=>!e.expiresAt||e.expiresAt>t).sort((e,t)=>n[e.state]-n[t.state]||t.timestamp-e.timestamp).slice(0,3)}function M(e){return e?`/chat/${e.conversationId}`:void 0}var N=r();function P(e){return e?e.state===`error`?`concern`:e.state===`success`?`success`:e.animation??l(e.phase):`idle`}function F(e,t){if(!e?.length)return;let n=t.sequence;for(let e of`${t.conversationId}:${t.runId}`)n=n*31+e.charCodeAt(0)>>>0;return e[n%e.length]}function I(e,t,n){let r=e.persona?.phrases??n;if(t.state===`success`)return F(r?.success,t);if(t.state===`waiting`)return F(r?.waiting,t);if(t.state===`error`)return F(r?.error,t)}function L(e,t,n){return e?n?`${e} · ${t}`:e:t}function R(e,t){let n=e.feedback?.nextAction?.type;if(n===`confirm`)return t.needsInput;if(n===`review_error`)return t.reviewIssue;if(n===`open_session`)return t.open;if(e.state===`waiting`)return t.needsInput;if(e.state===`error`)return t.reviewIssue;if(e.state===`success`)return t.open}function z(){let e=Date.now();return{prefs:{enabled:!0,showOnStartup:!1,selectedPetId:`loopi`,alwaysOnTop:!0,bubbleEnabled:!0,clickThroughWhenIdle:!1,muted:!1,behaviorMode:`companion`,proactiveTipsEnabled:!0,interactionEnabled:!0,reducedMotion:!1,sizePercent:100,collapsed:!1},relationship:{firstMetAt:e,lastSeenAt:e,completedTaskCount:0,unlockedReactions:[],recentCompletedRunIds:[]},pets:[],visible:!0,customPetsDir:``,petIssues:[],activities:[]}}function B(){let e=a(i(e=>e.language)).desktopPet,[t,n]=(0,d.useState)(z),[r,o]=(0,d.useState)({}),[l,f]=(0,d.useState)({}),[p,m]=(0,d.useState)(Date.now()),[h,g]=(0,d.useState)(()=>Date.now()),[v,y]=(0,d.useState)(0),[b,T]=(0,d.useState)(null),D=(0,d.useRef)(null),O=(0,d.useRef)(!1),B=(0,d.useRef)(null),V=(0,d.useRef)(null),H=(0,d.useRef)(null),U=(0,d.useMemo)(()=>t.pets.find(e=>e.id===t.prefs.selectedPetId)??t.pets[0],[t]),W=Math.min(1.4,Math.max(.7,t.prefs.sizePercent/100)),G=(0,d.useMemo)(()=>j(Object.values(r),p),[r,p]),K=(0,d.useMemo)(()=>t.prefs.bubbleEnabled?G.filter(e=>!A(e,l[e.conversationId])&&E(e,t.prefs.behaviorMode,p,t.prefs.remindersPausedUntil)):[],[G,l,p,t.prefs.behaviorMode,t.prefs.bubbleEnabled,t.prefs.remindersPausedUntil]),q=(0,d.useMemo)(()=>t.prefs.bubbleEnabled?G.filter(e=>A(e,l[e.conversationId])&&E(e,t.prefs.behaviorMode,p,t.prefs.remindersPausedUntil)).length:0,[G,l,p,t.prefs.behaviorMode,t.prefs.bubbleEnabled,t.prefs.remindersPausedUntil]),J=K[0]??G[0],te=p-h>20*6e4&&(new Date(p).getHours()>=23||new Date(p).getHours()<7)?`sleep`:`idle`,ne=b??(J?P(J):te),Y=e.personaPhrases[U?.persona?.tone??`calm`],X=ee({bubbleEnabled:t.prefs.bubbleEnabled,behaviorMode:t.prefs.behaviorMode,proactiveTipsEnabled:t.prefs.proactiveTipsEnabled,remindersPausedUntil:t.prefs.remindersPausedUntil,collapsed:t.prefs.collapsed,queuedCount:K.length,activeCount:G.length,now:p,lastActivityAt:h,dismissedUntil:v});(0,d.useEffect)(()=>{document.documentElement.dataset.desktopPet=`true`;let e=window.electronAPI?.pet;if(!e)return;let t=e=>{n(e),o(t=>k(t,e.activities))};e.getState().then(t).catch(()=>{});let r=e.onStateChanged(t),i=e.onEvent(e=>o(t=>(g(Date.now()),k(t,[e])))),a=window.setInterval(()=>m(Date.now()),1e3);return()=>{delete document.documentElement.dataset.desktopPet,r(),i(),window.clearInterval(a)}},[]),(0,d.useEffect)(()=>{if(!t.relationshipMoment)return;T(t.relationshipMoment===`first_meeting`?`wake`:`greet`);let e=window.setTimeout(()=>T(null),1400);return()=>window.clearTimeout(e)},[t.relationshipMoment]),(0,d.useLayoutEffect)(()=>{let e=B.current,t=window.electronAPI?.pet;if(!e||!t)return;let n=()=>{let e=[V.current,H.current].filter(e=>e!==null).map(e=>({left:e.offsetLeft,top:e.offsetTop,right:e.offsetLeft+e.offsetWidth,bottom:e.offsetTop+e.offsetHeight}));if(!e.length)return;let n=Math.min(...e.map(e=>e.left)),r=Math.min(...e.map(e=>e.top)),i=Math.max(...e.map(e=>e.right)),a=Math.max(...e.map(e=>e.bottom)),o=Math.round(132*W),s=o+(V.current?8+V.current.offsetHeight:0);t.setContentSize({width:Math.ceil(Math.max(i-n,o)),height:Math.ceil(Math.max(a-r,s))})},r=new ResizeObserver(n);return r.observe(e),V.current&&r.observe(V.current),H.current&&r.observe(H.current),n(),()=>r.disconnect()},[X,K.length,t.prefs.collapsed,W]);let Z=(e=J)=>{e&&e.state!==`running`&&(window.electronAPI?.pet?.acknowledgeEvent(e.conversationId,e.runId),o(t=>{let{[e.conversationId]:n,...r}=t;return r})),window.electronAPI?.pet?.openMainWindow(M(e))},re=async()=>{if(Object.keys(l).length>0&&(f({}),!t.prefs.collapsed))return;let e=await window.electronAPI?.pet?.setPrefs({collapsed:!t.prefs.collapsed});e&&n(e)},ie=(0,d.useCallback)(e=>{e.button===0&&(D.current={pointerId:e.pointerId,x:e.screenX,y:e.screenY,moved:!1},e.currentTarget.setPointerCapture(e.pointerId),window.electronAPI?.pet?.startDrag({screenX:e.screenX,screenY:e.screenY}))},[]),ae=(0,d.useCallback)(e=>{let t=D.current;!t||t.pointerId!==e.pointerId||(t.moved||Math.abs(e.screenX-t.x)+Math.abs(e.screenY-t.y)>4)&&(t.moved=!0,T(`pickedUp`),window.electronAPI?.pet?.drag({screenX:e.screenX,screenY:e.screenY}))},[]),Q=(0,d.useCallback)(e=>{let t=D.current;if(!t||e&&t.pointerId!==e.pointerId)return;D.current=null;let n=e?.type===`pointerup`&&Number.isFinite(e.screenX)&&Number.isFinite(e.screenY),r=t.moved||n&&Math.abs(e.screenX-t.x)+Math.abs(e.screenY-t.y)>4;r&&n&&window.electronAPI?.pet?.drag({screenX:e.screenX,screenY:e.screenY}),window.electronAPI?.pet?.endDrag(),r&&(T(`released`),window.setTimeout(()=>T(null),700),O.current=!0,window.setTimeout(()=>{O.current=!1},0))},[]);(0,d.useEffect)(()=>{let e=e=>Q(e),t=()=>Q();return window.addEventListener(`pointerup`,e),window.addEventListener(`pointercancel`,e),window.addEventListener(`blur`,t),()=>{window.removeEventListener(`pointerup`,e),window.removeEventListener(`pointercancel`,e),window.removeEventListener(`blur`,t)}},[Q]);let oe=()=>{O.current||Z()};if(!U)return null;let se={"--desktop-pet-stage-size":`${Math.round(132*W)}px`,"--desktop-pet-menu-size":`${Math.round(28*W)}px`,"--desktop-pet-menu-left":`0px`,"--desktop-pet-menu-bottom":`${Math.round(12*W)}px`},$=t.prefs.collapsed?K.length:q;return(0,N.jsxs)(`div`,{ref:B,className:`desktop-pet-window`,"data-reduced-motion":t.prefs.reducedMotion,style:se,children:[!t.prefs.collapsed&&K.length>0?(0,N.jsx)(`div`,{ref:V,className:`desktop-pet-bubble desktop-pet-queue`,children:K.map(t=>{let n=C(t,p,{longRunning:e.tipLongRunning,stale:e.tipStaleSignal}),r=S(t,e.tipCompleteSummary),i=w(t,{making_progress:e.petReassuranceMakingProgress,waiting_safely:e.petReassuranceWaitingSafely,completed:e.petReassuranceCompleted,work_preserved:e.petReassuranceWorkPreserved,details_available:e.petReassuranceDetailsAvailable}),a=r??n??i??t.action,o=L(I(U,t,Y),a,!!(r||n||i)),s=R(t,{open:e.viewSession,needsInput:e.petCtaNeedsInput,reviewIssue:e.petCtaReviewIssue});return(0,N.jsxs)(`div`,{className:`desktop-pet-session desktop-pet-session--${t.state}${n?` desktop-pet-session--health`:``}`,children:[(0,N.jsxs)(`button`,{type:`button`,className:`desktop-pet-session-open`,onClick:()=>Z(t),children:[(0,N.jsx)(`span`,{className:`desktop-pet-session-dot`}),(0,N.jsxs)(`span`,{className:`desktop-pet-session-main`,children:[(0,N.jsx)(`strong`,{children:t.sessionLabel}),(0,N.jsxs)(`span`,{children:[o,r||n?``:x(t,p,e.tipTargetSuffix)]})]}),s?(0,N.jsx)(`span`,{className:`desktop-pet-session-cta`,children:s}):null]}),(0,N.jsx)(`button`,{type:`button`,className:`desktop-pet-session-close`,"aria-label":e.dismissSession,onClick:()=>{window.electronAPI?.pet?.acknowledgeEvent(t.conversationId,t.runId),f(e=>({...e,[t.conversationId]:{runId:t.runId,state:t.state}}))},children:(0,N.jsx)(c,{size:12})})]},t.conversationId)})}):null,X?(0,N.jsx)(`div`,{ref:V,className:`desktop-pet-bubble desktop-pet-queue desktop-pet-idle-tip`,children:(0,N.jsxs)(`div`,{className:`desktop-pet-session desktop-pet-session--idle`,children:[(0,N.jsxs)(`button`,{type:`button`,className:`desktop-pet-session-open`,onClick:()=>Z(),children:[(0,N.jsx)(`span`,{className:`desktop-pet-session-dot`}),(0,N.jsxs)(`span`,{className:`desktop-pet-session-main`,children:[(0,N.jsx)(`strong`,{children:e.idleTipTitle}),(0,N.jsx)(`span`,{children:F(U.persona?.phrases?.greeting??Y.greeting,{conversationId:`idle`,runId:`idle`,sessionLabel:``,sequence:0,timestamp:h,state:`running`,phase:`waiting`,action:e.idleTipBody})??e.idleTipBody})]})]}),(0,N.jsx)(`button`,{type:`button`,className:`desktop-pet-session-close`,"aria-label":e.dismissSession,onClick:()=>y(p+_),children:(0,N.jsx)(c,{size:12})})]})}):null,(0,N.jsxs)(`div`,{ref:H,className:`desktop-pet-stage`,children:[(0,N.jsx)(`button`,{type:`button`,className:`desktop-pet-menu-button`,onClick:()=>void re(),"aria-label":e.menu,children:$>0?(0,N.jsx)(`span`,{className:`desktop-pet-tip-count`,children:Math.min(99,$)}):(0,N.jsx)(s,{className:`desktop-pet-menu-chevron size-4`})}),(0,N.jsx)(`button`,{type:`button`,className:`desktop-pet-hit-area`,onClick:oe,onPointerEnter:()=>{!J&&t.prefs.interactionEnabled&&t.prefs.behaviorMode===`playful`&&T(`greet`)},onPointerLeave:()=>{D.current||T(null)},onPointerDown:ie,onPointerMove:ae,onPointerUp:Q,onPointerCancel:Q,onLostPointerCapture:Q,title:e.openApp,children:(0,N.jsx)(u,{animationKey:J?.runId,pet:U,action:ne,reducedMotion:t.prefs.reducedMotion,displayHeight:Math.round(112*W)},U.id)})]})]})}function V(){let e=(0,f.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=window.electronAPI?.pet?(0,N.jsx)(B,{}):(0,N.jsx)(o,{kind:`desktop`,backTo:`/`}),e[0]=t):t=e[0],t}export{V as DesktopPetPage};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{n as i}from"./locale-store-VNjH18Dj.js";import{t as a}from"./messages-Btr7C0hF.js";import{t as o}from"./resource-unavailable-35wBZxmz.js";import{t as s}from"./chevron-down-ccbiQQz_.js";import{t as c}from"./x-B_N4OPjy.js";import{t as l}from"./desktop-pet-narrative-CS8qJpNO.js";import{t as u}from"./desktop-pet-sprite-D5YYq2zC.js";var d=e(t(),1),f=n(),p=9e4,m=3e4,h=20*6e4,g=45e3,_=45*6e4,v=58;function y(e,t){return e.state===`running`&&t-(e.startedAt??e.timestamp)>=p}function b(e,t){return e.state===`running`&&t-e.timestamp>=m}function x(e,t,n){if(e.progress){let t=`${e.progress.completed}/${e.progress.total}`;return e.action.includes(t)?``:` · ${t}`}return e.detail&&!e.action.includes(e.detail)?n.replace(/\{\{detail\}\}/g,e.detail):e.state===`running`?` · ${Math.max(1,Math.floor((t-e.timestamp)/1e3))}s`:``}function S(e,t){if(e.state!==`success`||!e.publicSummary)return;let n=e.publicSummary.replace(/\s+/g,` `).trim(),r=n.length>v?`${n.slice(0,v-1)}…`:n;return t.replace(/\{\{summary\}\}/g,r)}function C(e,t,n){if(b(e,t))return n.stale;if(y(e,t))return n.longRunning}function w(e,t){let n=e.feedback?.reassurance;return n?t[n]:void 0}function ee(e){let t=e.now-e.lastActivityAt,n=t>=h?(t-h)%_:1/0;return e.bubbleEnabled&&e.behaviorMode!==`focus`&&e.proactiveTipsEnabled&&(!e.remindersPausedUntil||e.now>=e.remindersPausedUntil)&&!e.collapsed&&e.queuedCount===0&&e.activeCount===0&&n<=g&&e.now>=e.dismissedUntil}function T(e,t,n){return e.state===`waiting`||e.state===`error`?`action_required`:e.state===`success`?t===`focus`?`ambient`:`notice`:b(e,n)||t===`playful`||t===`companion`&&y(e,n)?`notice`:`ambient`}function E(e,t,n,r){let i=T(e,t,n);return i===`action_required`?!0:r&&n<r?!1:i===`notice`}var D=8e3;function O(e,t){let n=e?.runId===t.runId,r=t.feedback?.sensitivity===`private`;return{...n?e:void 0,...t,startedAt:n?e.startedAt??e.timestamp:t.timestamp,publicSummary:r?void 0:t.publicSummary??(n?e.publicSummary:void 0),feedback:t.feedback??(n?e.feedback:void 0),expiresAt:t.state===`success`?t.timestamp+D:void 0}}function k(e,t){let n={...e};for(let e of t){let t=n[e.conversationId];t?.runId===e.runId&&e.sequence<=t.sequence||(n[e.conversationId]=O(t,e))}return n}function A(e,t){return t?.runId===e.runId&&t.state===e.state}function j(e,t){let n={error:0,waiting:1,running:2,success:3};return e.filter(e=>!e.expiresAt||e.expiresAt>t).sort((e,t)=>n[e.state]-n[t.state]||t.timestamp-e.timestamp).slice(0,3)}function M(e){return e?`/chat/${e.conversationId}`:void 0}var N=r();function P(e){return e?e.state===`error`?`concern`:e.state===`success`?`success`:e.animation??l(e.phase):`idle`}function F(e,t){if(!e?.length)return;let n=t.sequence;for(let e of`${t.conversationId}:${t.runId}`)n=n*31+e.charCodeAt(0)>>>0;return e[n%e.length]}function I(e,t,n){let r=e.persona?.phrases??n;if(t.state===`success`)return F(r?.success,t);if(t.state===`waiting`)return F(r?.waiting,t);if(t.state===`error`)return F(r?.error,t)}function L(e,t,n){return e?n?`${e} · ${t}`:e:t}function R(e,t){let n=e.feedback?.nextAction?.type;if(n===`confirm`)return t.needsInput;if(n===`review_error`)return t.reviewIssue;if(n===`open_session`)return t.open;if(e.state===`waiting`)return t.needsInput;if(e.state===`error`)return t.reviewIssue;if(e.state===`success`)return t.open}function z(){let e=Date.now();return{prefs:{enabled:!0,showOnStartup:!1,selectedPetId:`loopi`,alwaysOnTop:!0,bubbleEnabled:!0,clickThroughWhenIdle:!1,muted:!1,behaviorMode:`companion`,proactiveTipsEnabled:!0,interactionEnabled:!0,reducedMotion:!1,sizePercent:100,collapsed:!1},relationship:{firstMetAt:e,lastSeenAt:e,completedTaskCount:0,unlockedReactions:[],recentCompletedRunIds:[]},pets:[],visible:!0,customPetsDir:``,petIssues:[],activities:[]}}function B(){let e=a(i(e=>e.language)).desktopPet,[t,n]=(0,d.useState)(z),[r,o]=(0,d.useState)({}),[l,f]=(0,d.useState)({}),[p,m]=(0,d.useState)(Date.now()),[h,g]=(0,d.useState)(()=>Date.now()),[v,y]=(0,d.useState)(0),[b,T]=(0,d.useState)(null),D=(0,d.useRef)(null),O=(0,d.useRef)(!1),B=(0,d.useRef)(null),V=(0,d.useRef)(null),H=(0,d.useRef)(null),U=(0,d.useMemo)(()=>t.pets.find(e=>e.id===t.prefs.selectedPetId)??t.pets[0],[t]),W=Math.min(1.4,Math.max(.7,t.prefs.sizePercent/100)),G=(0,d.useMemo)(()=>j(Object.values(r),p),[r,p]),K=(0,d.useMemo)(()=>t.prefs.bubbleEnabled?G.filter(e=>!A(e,l[e.conversationId])&&E(e,t.prefs.behaviorMode,p,t.prefs.remindersPausedUntil)):[],[G,l,p,t.prefs.behaviorMode,t.prefs.bubbleEnabled,t.prefs.remindersPausedUntil]),q=(0,d.useMemo)(()=>t.prefs.bubbleEnabled?G.filter(e=>A(e,l[e.conversationId])&&E(e,t.prefs.behaviorMode,p,t.prefs.remindersPausedUntil)).length:0,[G,l,p,t.prefs.behaviorMode,t.prefs.bubbleEnabled,t.prefs.remindersPausedUntil]),J=K[0]??G[0],te=p-h>20*6e4&&(new Date(p).getHours()>=23||new Date(p).getHours()<7)?`sleep`:`idle`,ne=b??(J?P(J):te),Y=e.personaPhrases[U?.persona?.tone??`calm`],X=ee({bubbleEnabled:t.prefs.bubbleEnabled,behaviorMode:t.prefs.behaviorMode,proactiveTipsEnabled:t.prefs.proactiveTipsEnabled,remindersPausedUntil:t.prefs.remindersPausedUntil,collapsed:t.prefs.collapsed,queuedCount:K.length,activeCount:G.length,now:p,lastActivityAt:h,dismissedUntil:v});(0,d.useEffect)(()=>{document.documentElement.dataset.desktopPet=`true`;let e=window.electronAPI?.pet;if(!e)return;let t=e=>{n(e),o(t=>k(t,e.activities))};e.getState().then(t).catch(()=>{});let r=e.onStateChanged(t),i=e.onEvent(e=>o(t=>(g(Date.now()),k(t,[e])))),a=window.setInterval(()=>m(Date.now()),1e3);return()=>{delete document.documentElement.dataset.desktopPet,r(),i(),window.clearInterval(a)}},[]),(0,d.useEffect)(()=>{if(!t.relationshipMoment)return;T(t.relationshipMoment===`first_meeting`?`wake`:`greet`);let e=window.setTimeout(()=>T(null),1400);return()=>window.clearTimeout(e)},[t.relationshipMoment]),(0,d.useLayoutEffect)(()=>{let e=B.current,t=window.electronAPI?.pet;if(!e||!t)return;let n=()=>{let e=[V.current,H.current].filter(e=>e!==null).map(e=>({left:e.offsetLeft,top:e.offsetTop,right:e.offsetLeft+e.offsetWidth,bottom:e.offsetTop+e.offsetHeight}));if(!e.length)return;let n=Math.min(...e.map(e=>e.left)),r=Math.min(...e.map(e=>e.top)),i=Math.max(...e.map(e=>e.right)),a=Math.max(...e.map(e=>e.bottom)),o=Math.round(132*W),s=o+(V.current?8+V.current.offsetHeight:0);t.setContentSize({width:Math.ceil(Math.max(i-n,o)),height:Math.ceil(Math.max(a-r,s))})},r=new ResizeObserver(n);return r.observe(e),V.current&&r.observe(V.current),H.current&&r.observe(H.current),n(),()=>r.disconnect()},[X,K.length,t.prefs.collapsed,W]);let Z=(e=J)=>{e&&e.state!==`running`&&(window.electronAPI?.pet?.acknowledgeEvent(e.conversationId,e.runId),o(t=>{let{[e.conversationId]:n,...r}=t;return r})),window.electronAPI?.pet?.openMainWindow(M(e))},re=async()=>{if(Object.keys(l).length>0&&(f({}),!t.prefs.collapsed))return;let e=await window.electronAPI?.pet?.setPrefs({collapsed:!t.prefs.collapsed});e&&n(e)},ie=(0,d.useCallback)(e=>{e.button===0&&(D.current={pointerId:e.pointerId,x:e.screenX,y:e.screenY,moved:!1},e.currentTarget.setPointerCapture(e.pointerId),window.electronAPI?.pet?.startDrag({screenX:e.screenX,screenY:e.screenY}))},[]),ae=(0,d.useCallback)(e=>{let t=D.current;!t||t.pointerId!==e.pointerId||(t.moved||Math.abs(e.screenX-t.x)+Math.abs(e.screenY-t.y)>4)&&(t.moved=!0,T(`pickedUp`),window.electronAPI?.pet?.drag({screenX:e.screenX,screenY:e.screenY}))},[]),Q=(0,d.useCallback)(e=>{let t=D.current;if(!t||e&&t.pointerId!==e.pointerId)return;D.current=null;let n=e?.type===`pointerup`&&Number.isFinite(e.screenX)&&Number.isFinite(e.screenY),r=t.moved||n&&Math.abs(e.screenX-t.x)+Math.abs(e.screenY-t.y)>4;r&&n&&window.electronAPI?.pet?.drag({screenX:e.screenX,screenY:e.screenY}),window.electronAPI?.pet?.endDrag(),r&&(T(`released`),window.setTimeout(()=>T(null),700),O.current=!0,window.setTimeout(()=>{O.current=!1},0))},[]);(0,d.useEffect)(()=>{let e=e=>Q(e),t=()=>Q();return window.addEventListener(`pointerup`,e),window.addEventListener(`pointercancel`,e),window.addEventListener(`blur`,t),()=>{window.removeEventListener(`pointerup`,e),window.removeEventListener(`pointercancel`,e),window.removeEventListener(`blur`,t)}},[Q]);let oe=()=>{O.current||Z()};if(!U)return null;let se={"--desktop-pet-stage-size":`${Math.round(132*W)}px`,"--desktop-pet-menu-size":`${Math.round(28*W)}px`,"--desktop-pet-menu-left":`0px`,"--desktop-pet-menu-bottom":`${Math.round(12*W)}px`},$=t.prefs.collapsed?K.length:q;return(0,N.jsxs)(`div`,{ref:B,className:`desktop-pet-window`,"data-reduced-motion":t.prefs.reducedMotion,style:se,children:[!t.prefs.collapsed&&K.length>0?(0,N.jsx)(`div`,{ref:V,className:`desktop-pet-bubble desktop-pet-queue`,children:K.map(t=>{let n=C(t,p,{longRunning:e.tipLongRunning,stale:e.tipStaleSignal}),r=S(t,e.tipCompleteSummary),i=w(t,{making_progress:e.petReassuranceMakingProgress,waiting_safely:e.petReassuranceWaitingSafely,completed:e.petReassuranceCompleted,work_preserved:e.petReassuranceWorkPreserved,details_available:e.petReassuranceDetailsAvailable}),a=r??n??i??t.action,o=L(I(U,t,Y),a,!!(r||n||i)),s=R(t,{open:e.viewSession,needsInput:e.petCtaNeedsInput,reviewIssue:e.petCtaReviewIssue});return(0,N.jsxs)(`div`,{className:`desktop-pet-session desktop-pet-session--${t.state}${n?` desktop-pet-session--health`:``}`,children:[(0,N.jsxs)(`button`,{type:`button`,className:`desktop-pet-session-open`,onClick:()=>Z(t),children:[(0,N.jsx)(`span`,{className:`desktop-pet-session-dot`}),(0,N.jsxs)(`span`,{className:`desktop-pet-session-main`,children:[(0,N.jsx)(`strong`,{children:t.sessionLabel}),(0,N.jsxs)(`span`,{children:[o,r||n?``:x(t,p,e.tipTargetSuffix)]})]}),s?(0,N.jsx)(`span`,{className:`desktop-pet-session-cta`,children:s}):null]}),(0,N.jsx)(`button`,{type:`button`,className:`desktop-pet-session-close`,"aria-label":e.dismissSession,onClick:()=>{window.electronAPI?.pet?.acknowledgeEvent(t.conversationId,t.runId),f(e=>({...e,[t.conversationId]:{runId:t.runId,state:t.state}}))},children:(0,N.jsx)(c,{size:12})})]},t.conversationId)})}):null,X?(0,N.jsx)(`div`,{ref:V,className:`desktop-pet-bubble desktop-pet-queue desktop-pet-idle-tip`,children:(0,N.jsxs)(`div`,{className:`desktop-pet-session desktop-pet-session--idle`,children:[(0,N.jsxs)(`button`,{type:`button`,className:`desktop-pet-session-open`,onClick:()=>Z(),children:[(0,N.jsx)(`span`,{className:`desktop-pet-session-dot`}),(0,N.jsxs)(`span`,{className:`desktop-pet-session-main`,children:[(0,N.jsx)(`strong`,{children:e.idleTipTitle}),(0,N.jsx)(`span`,{children:F(U.persona?.phrases?.greeting??Y.greeting,{conversationId:`idle`,runId:`idle`,sessionLabel:``,sequence:0,timestamp:h,state:`running`,phase:`waiting`,action:e.idleTipBody})??e.idleTipBody})]})]}),(0,N.jsx)(`button`,{type:`button`,className:`desktop-pet-session-close`,"aria-label":e.dismissSession,onClick:()=>y(p+_),children:(0,N.jsx)(c,{size:12})})]})}):null,(0,N.jsxs)(`div`,{ref:H,className:`desktop-pet-stage`,children:[(0,N.jsx)(`button`,{type:`button`,className:`desktop-pet-menu-button`,onClick:()=>void re(),"aria-label":e.menu,children:$>0?(0,N.jsx)(`span`,{className:`desktop-pet-tip-count`,children:Math.min(99,$)}):(0,N.jsx)(s,{className:`desktop-pet-menu-chevron size-4`})}),(0,N.jsx)(`button`,{type:`button`,className:`desktop-pet-hit-area`,onClick:oe,onPointerEnter:()=>{!J&&t.prefs.interactionEnabled&&t.prefs.behaviorMode===`playful`&&T(`greet`)},onPointerLeave:()=>{D.current||T(null)},onPointerDown:ie,onPointerMove:ae,onPointerUp:Q,onPointerCancel:Q,onLostPointerCapture:Q,title:e.openApp,children:(0,N.jsx)(u,{animationKey:J?.runId,pet:U,action:ne,reducedMotion:t.prefs.reducedMotion,displayHeight:Math.round(112*W)},U.id)})]})]})}function V(){let e=(0,f.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=window.electronAPI?.pet?(0,N.jsx)(B,{}):(0,N.jsx)(o,{kind:`desktop`,backTo:`/`}),e[0]=t):t=e[0],t}export{V as DesktopPetPage};
|
|
@@ -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{u as i}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{n as a}from"./locale-store-5Hf8J8-_.js";import{t as o}from"./messages-uXxg5p54.js";import{t as s}from"./resource-unavailable-BUWsH3fp.js";import{t as c}from"./chevron-down-ccbiQQz_.js";import{n as l,r as u}from"./popover-select-DD8fmrxH.js";import{t as d}from"./circle-alert-BEjgurr2.js";import{t as f}from"./external-link-DjqjBmc3.js";import{t as p}from"./message-square-plus-XP0tGdlV.js";import{n as m,t as h}from"./wand-sparkles-CkSL-3Fy.js";import{t as g}from"./rotate-ccw-JM1TBLpp.js";import{t as _}from"./cn-0WouolD0.js";import{t as v}from"./skeleton-BI5TyibZ.js";import{n as y}from"./interaction-BdhHBbYa.js";import{n as b}from"./electron-env-DHOGevH3.js";import{t as x}from"./refresh-button-bU_0NarN.js";import{t as S}from"./desktop-pet-sprite-D5YYq2zC.js";import{n as C,t as w}from"./settings-page-header-C8a_oOyw.js";import"./settings-page-layout-CTSRWljG.js";var T=n(),E=e(t(),1),D=r();function O(e){let t=(0,T.c)(16),{title:n,desc:r,checked:i,disabled:a,onChange:o}=e,s;t[0]===n?s=t[1]:(s=(0,D.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=s);let c;t[2]===r?c=t[3]:(c=r?(0,D.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:r}):null,t[2]=r,t[3]=c);let l;t[4]!==s||t[5]!==c?(l=(0,D.jsxs)(`span`,{className:`min-w-0`,children:[s,c]}),t[4]=s,t[5]=c,t[6]=l):l=t[6];let u;t[7]===o?u=t[8]:(u=e=>o(e.target.checked),t[7]=o,t[8]=u);let d;t[9]!==i||t[10]!==a||t[11]!==u?(d=(0,D.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":i,className:`ui-checkbox`,disabled:a,checked:i,onChange:u}),t[9]=i,t[10]=a,t[11]=u,t[12]=d):d=t[12];let f;return t[13]!==l||t[14]!==d?(f=(0,D.jsxs)(`label`,{className:`flex min-h-12 cursor-pointer items-center justify-between gap-3 py-3`,children:[l,d]}),t[13]=l,t[14]=d,t[15]=f):f=t[15],f}function k(){let e=o(a(e=>e.language)).desktopPetSettings,t=i(),[n,r]=(0,E.useState)(null),[T,k]=(0,E.useState)(!1),[A,j]=(0,E.useState)(null),M=typeof window<`u`?window.electronAPI?.pet:void 0,N=(0,E.useMemo)(()=>n?.pets.find(e=>e.id===n.prefs.selectedPetId)??n?.pets[0],[n]),P=(0,E.useCallback)(async()=>{if(M){k(!0);try{r(await M.getState())}finally{k(!1)}}},[M]);if((0,E.useEffect)(()=>{if(M)return P(),M.onStateChanged(r)},[M,P]),!b()||!M)return(0,D.jsx)(s,{kind:`desktop`,backTo:`/settings/overview`});if(!n)return(0,D.jsxs)(C,{gap:`gap-4`,children:[(0,D.jsx)(w,{title:e.title,subtitle:e.subtitle}),(0,D.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4`,"aria-busy":!0,"aria-label":e.loading,children:(0,D.jsxs)(`div`,{className:`space-y-3`,children:[(0,D.jsx)(v,{className:`h-14 rounded-xl`}),(0,D.jsx)(v,{className:`h-14 rounded-xl`}),(0,D.jsx)(v,{className:`h-24 rounded-xl`}),(0,D.jsx)(`div`,{className:`space-y-2 pt-2`,children:Array.from({length:3}).map((e,t)=>(0,D.jsx)(v,{className:`h-16 rounded-xl`},t))})]})})]});let F=async e=>{k(!0);try{r(await M.setPrefs(e))}finally{k(!1)}},I=async e=>{e?(await M.show(),r(await M.getState())):r(await M.setPrefs({enabled:!1}))},L=e=>{F({selectedPetId:e})},R=t=>{if(t.builtin&&t.i18nKey){let n=e.builtinPets[t.i18nKey];if(n)return n}return{name:t.name,description:t.description}},z=e=>{t({pathname:`/chat/new`,search:`?draft=${encodeURIComponent(e)}`})},B=e=>{if(e.sourcePrompt?.trim())return e.sourcePrompt.trim();let{description:t}=R(e);return t.replace(/^Custom pet generated from:\s*/i,``).trim()||t},V=(e,t)=>Object.entries(t).reduce((e,[t,n])=>e.split(`{${t}}`).join(n),e),H=()=>{z(e.createChatDraft)},U=t=>{let n=V(e.optimizeChatDraft,{id:t.id,name:R(t).name,description:R(t).description,sourcePrompt:B(t)});z(n)},W=t=>{let n=V(e.fixChatDraft,{dir:t.dir,reason:t.reason,details:t.details?.join(`; `)||e.noIssueDetails});z(n)},G=A??n.prefs.sizePercent,K=Math.max(1,Math.floor((Date.now()-n.relationship.firstMetAt)/864e5)+1),q=async(e=G)=>{let t=Math.min(140,Math.max(70,Math.round(e/5)*5));j(null),t!==n.prefs.sizePercent&&await F({sizePercent:t})};return(0,D.jsxs)(C,{gap:`gap-5`,children:[(0,D.jsx)(w,{title:e.title,subtitle:e.subtitle,actions:(0,D.jsx)(x,{className:`size-9 shrink-0 p-0`,disabled:T,label:e.refresh,onClick:P})}),(0,D.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,D.jsxs)(`div`,{className:`flex flex-col gap-4 p-5 sm:flex-row sm:items-center sm:gap-6`,children:[(0,D.jsx)(`div`,{className:`grid h-40 w-40 shrink-0 place-items-center self-center rounded-xl bg-surface-hover/35`,children:N?(0,D.jsx)(S,{pet:N,action:`idle`,displayHeight:Math.round(104*G/100),reducedMotion:n.prefs.reducedMotion}):null}),(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-6 gap-y-2`,children:[(0,D.jsx)(`h2`,{className:`break-words text-xl font-semibold text-fg`,children:N?R(N).name:e.title}),(0,D.jsx)(O,{title:e.enable,checked:n.prefs.enabled,disabled:T,onChange:e=>void I(e)})]}),(0,D.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.bondSummary.replace(`{days}`,String(K)).replace(`{tasks}`,String(n.relationship.completedTaskCount))}),n.pets.length>1?(0,D.jsx)(`div`,{className:`mt-4 max-w-56`,children:(0,D.jsx)(l,{"aria-label":e.petList,value:N?.id??``,onChange:e=>L(e.target.value),disabled:T,children:n.pets.map(e=>(0,D.jsx)(u,{value:e.id,children:R(e).name},e.id))})}):null,N&&!N.builtin?(0,D.jsxs)(`button`,{type:`button`,onClick:()=>U(N),className:`mt-3 inline-flex min-h-9 items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg`,children:[(0,D.jsx)(m,{className:`size-3.5`}),e.optimizeInChat]}):null]})]}),(0,D.jsx)(`div`,{className:`border-t border-edge px-5 py-2`,children:(0,D.jsxs)(`button`,{type:`button`,onClick:H,className:_(`inline-flex min-h-10 items-center gap-2 text-xs font-medium text-fg-muted hover:text-accent-fg`,y.press),children:[(0,D.jsx)(h,{className:`size-4`}),e.createTitle]})})]}),n.petIssues.length>0?(0,D.jsxs)(`section`,{className:`rounded-xl border border-danger/20 bg-danger/5 p-4`,children:[(0,D.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-medium text-danger`,children:[(0,D.jsx)(d,{className:`size-4`}),e.invalidPets]}),(0,D.jsx)(`div`,{className:`mt-3 space-y-3`,children:n.petIssues.map(t=>(0,D.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,D.jsxs)(`div`,{className:`min-w-0 text-xs text-fg-muted`,children:[(0,D.jsx)(`p`,{className:`break-words`,children:t.reason}),(0,D.jsxs)(`details`,{className:`mt-1`,children:[(0,D.jsx)(`summary`,{className:`cursor-pointer`,children:e.issueDetails}),(0,D.jsx)(`p`,{className:`mt-2 break-all font-mono`,children:t.dir}),t.details?.length?(0,D.jsx)(`p`,{className:`mt-1 break-words`,children:t.details.join(`; `)}):null]})]}),(0,D.jsxs)(`button`,{type:`button`,onClick:()=>W(t),className:`inline-flex min-h-9 shrink-0 items-center gap-1.5 text-xs font-medium text-danger`,children:[(0,D.jsx)(p,{className:`size-3.5`}),e.fixInChat]})]},`${t.dir}-${t.reason}`))})]}):null,(0,D.jsxs)(`section`,{"aria-label":e.displayGroup,children:[(0,D.jsx)(`h3`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:e.displayGroup}),(0,D.jsxs)(`div`,{className:`divide-y divide-edge rounded-xl border border-edge bg-surface-panel px-4`,children:[(0,D.jsx)(O,{title:e.showOnStartup,checked:n.prefs.showOnStartup,disabled:T,onChange:e=>void F({showOnStartup:e})}),(0,D.jsx)(O,{title:e.alwaysOnTop,checked:n.prefs.alwaysOnTop,disabled:T,onChange:e=>void F({alwaysOnTop:e})}),(0,D.jsx)(O,{title:e.bubbles,checked:n.prefs.bubbleEnabled,disabled:T,onChange:e=>void F({bubbleEnabled:e})}),(0,D.jsxs)(`div`,{className:`py-3`,children:[(0,D.jsxs)(`label`,{htmlFor:`desktop-pet-size`,className:`flex items-center justify-between gap-3 text-sm font-medium text-fg`,children:[e.size,(0,D.jsxs)(`span`,{className:`text-xs tabular-nums text-fg-muted`,children:[G,`%`]})]}),(0,D.jsx)(`input`,{id:`desktop-pet-size`,type:`range`,min:70,max:140,step:5,className:`mt-3 w-full accent-accent`,value:G,disabled:T,onChange:e=>j(Number(e.target.value)),onBlur:()=>void q(),onKeyUp:e=>{(e.key===`Enter`||e.key===` `||e.key.startsWith(`Arrow`))&&q()},onPointerUp:()=>void q()})]})]})]}),(0,D.jsxs)(`section`,{"aria-label":e.interactionGroup,children:[(0,D.jsx)(`h3`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:e.interactionGroup}),(0,D.jsxs)(`div`,{className:`divide-y divide-edge rounded-xl border border-edge bg-surface-panel px-4`,children:[(0,D.jsx)(O,{title:e.proactiveTips,checked:n.prefs.proactiveTipsEnabled,disabled:T,onChange:e=>void F({proactiveTipsEnabled:e})}),(0,D.jsx)(O,{title:e.interactions,desc:e.interactionsDesc,checked:n.prefs.interactionEnabled,disabled:T,onChange:e=>void F({interactionEnabled:e})}),(0,D.jsx)(O,{title:e.reducedMotion,checked:n.prefs.reducedMotion,disabled:T,onChange:e=>void F({reducedMotion:e})}),(0,D.jsxs)(`div`,{className:`flex min-h-12 flex-wrap items-center justify-between gap-3 py-3`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.behaviorMode}),(0,D.jsxs)(l,{"aria-label":e.behaviorMode,className:`w-36`,triggerClassName:`h-9 bg-surface-panel`,value:n.prefs.behaviorMode,disabled:T,onChange:e=>void F({behaviorMode:e.target.value}),children:[(0,D.jsx)(u,{value:`focus`,children:e.behaviorFocus}),(0,D.jsx)(u,{value:`companion`,children:e.behaviorCompanion}),(0,D.jsx)(u,{value:`playful`,children:e.behaviorPlayful})]})]})]})]}),(0,D.jsxs)(`details`,{className:`group rounded-xl border border-edge bg-surface-panel`,children:[(0,D.jsxs)(`summary`,{className:`flex min-h-12 cursor-pointer list-none items-center justify-between gap-3 px-4 text-sm font-medium text-fg [&::-webkit-details-marker]:hidden`,children:[e.advanced,(0,D.jsx)(c,{className:`size-4 text-fg-muted transition-transform group-open:rotate-180`})]}),(0,D.jsxs)(`div`,{className:`space-y-3 border-t border-edge px-4 pb-4`,children:[(0,D.jsx)(O,{title:e.clickThrough,desc:e.clickThroughDesc,checked:n.prefs.clickThroughWhenIdle,disabled:T,onChange:e=>void F({clickThroughWhenIdle:e})}),(0,D.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-edge pt-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.customPets}),(0,D.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs text-fg-muted`,children:n.customPetsDir})]}),(0,D.jsxs)(`button`,{type:`button`,onClick:()=>void M.openCustomPetsDir(),className:`inline-flex min-h-10 shrink-0 items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg`,children:[(0,D.jsx)(f,{className:`size-3.5`}),e.openFolder]})]}),(0,D.jsxs)(`button`,{type:`button`,className:_(`inline-flex min-h-10 items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg disabled:opacity-50`,y.press),disabled:T,onClick:()=>void M.resetPosition().then(r),children:[(0,D.jsx)(g,{className:`size-3.5`}),e.resetPosition]})]})]})]})}export{k as DesktopPetSettings};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{u as i}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{n as a}from"./locale-store-VNjH18Dj.js";import{t as o}from"./messages-Btr7C0hF.js";import{t as s}from"./resource-unavailable-35wBZxmz.js";import{t as c}from"./chevron-down-ccbiQQz_.js";import{n as l,r as u}from"./popover-select-DD8fmrxH.js";import{t as d}from"./circle-alert-BEjgurr2.js";import{t as f}from"./external-link-DjqjBmc3.js";import{t as p}from"./message-square-plus-XP0tGdlV.js";import{n as m,t as h}from"./wand-sparkles-CkSL-3Fy.js";import{t as g}from"./rotate-ccw-JM1TBLpp.js";import{t as _}from"./cn-0WouolD0.js";import{t as v}from"./skeleton-BI5TyibZ.js";import{n as y}from"./interaction-BdhHBbYa.js";import{n as b}from"./electron-env-DHOGevH3.js";import{t as x}from"./refresh-button-bU_0NarN.js";import{t as S}from"./desktop-pet-sprite-D5YYq2zC.js";import{n as C,t as w}from"./settings-page-header-CsPAYlqV.js";import"./settings-page-layout-lPLeJQoV.js";var T=n(),E=e(t(),1),D=r();function O(e){let t=(0,T.c)(16),{title:n,desc:r,checked:i,disabled:a,onChange:o}=e,s;t[0]===n?s=t[1]:(s=(0,D.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=s);let c;t[2]===r?c=t[3]:(c=r?(0,D.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:r}):null,t[2]=r,t[3]=c);let l;t[4]!==s||t[5]!==c?(l=(0,D.jsxs)(`span`,{className:`min-w-0`,children:[s,c]}),t[4]=s,t[5]=c,t[6]=l):l=t[6];let u;t[7]===o?u=t[8]:(u=e=>o(e.target.checked),t[7]=o,t[8]=u);let d;t[9]!==i||t[10]!==a||t[11]!==u?(d=(0,D.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":i,className:`ui-checkbox`,disabled:a,checked:i,onChange:u}),t[9]=i,t[10]=a,t[11]=u,t[12]=d):d=t[12];let f;return t[13]!==l||t[14]!==d?(f=(0,D.jsxs)(`label`,{className:`flex min-h-12 cursor-pointer items-center justify-between gap-3 py-3`,children:[l,d]}),t[13]=l,t[14]=d,t[15]=f):f=t[15],f}function k(){let e=o(a(e=>e.language)).desktopPetSettings,t=i(),[n,r]=(0,E.useState)(null),[T,k]=(0,E.useState)(!1),[A,j]=(0,E.useState)(null),M=typeof window<`u`?window.electronAPI?.pet:void 0,N=(0,E.useMemo)(()=>n?.pets.find(e=>e.id===n.prefs.selectedPetId)??n?.pets[0],[n]),P=(0,E.useCallback)(async()=>{if(M){k(!0);try{r(await M.getState())}finally{k(!1)}}},[M]);if((0,E.useEffect)(()=>{if(M)return P(),M.onStateChanged(r)},[M,P]),!b()||!M)return(0,D.jsx)(s,{kind:`desktop`,backTo:`/settings/overview`});if(!n)return(0,D.jsxs)(C,{gap:`gap-4`,children:[(0,D.jsx)(w,{title:e.title,subtitle:e.subtitle}),(0,D.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4`,"aria-busy":!0,"aria-label":e.loading,children:(0,D.jsxs)(`div`,{className:`space-y-3`,children:[(0,D.jsx)(v,{className:`h-14 rounded-xl`}),(0,D.jsx)(v,{className:`h-14 rounded-xl`}),(0,D.jsx)(v,{className:`h-24 rounded-xl`}),(0,D.jsx)(`div`,{className:`space-y-2 pt-2`,children:Array.from({length:3}).map((e,t)=>(0,D.jsx)(v,{className:`h-16 rounded-xl`},t))})]})})]});let F=async e=>{k(!0);try{r(await M.setPrefs(e))}finally{k(!1)}},I=async e=>{e?(await M.show(),r(await M.getState())):r(await M.setPrefs({enabled:!1}))},L=e=>{F({selectedPetId:e})},R=t=>{if(t.builtin&&t.i18nKey){let n=e.builtinPets[t.i18nKey];if(n)return n}return{name:t.name,description:t.description}},z=e=>{t({pathname:`/chat/new`,search:`?draft=${encodeURIComponent(e)}`})},B=e=>{if(e.sourcePrompt?.trim())return e.sourcePrompt.trim();let{description:t}=R(e);return t.replace(/^Custom pet generated from:\s*/i,``).trim()||t},V=(e,t)=>Object.entries(t).reduce((e,[t,n])=>e.split(`{${t}}`).join(n),e),H=()=>{z(e.createChatDraft)},U=t=>{let n=V(e.optimizeChatDraft,{id:t.id,name:R(t).name,description:R(t).description,sourcePrompt:B(t)});z(n)},W=t=>{let n=V(e.fixChatDraft,{dir:t.dir,reason:t.reason,details:t.details?.join(`; `)||e.noIssueDetails});z(n)},G=A??n.prefs.sizePercent,K=Math.max(1,Math.floor((Date.now()-n.relationship.firstMetAt)/864e5)+1),q=async(e=G)=>{let t=Math.min(140,Math.max(70,Math.round(e/5)*5));j(null),t!==n.prefs.sizePercent&&await F({sizePercent:t})};return(0,D.jsxs)(C,{gap:`gap-5`,children:[(0,D.jsx)(w,{title:e.title,subtitle:e.subtitle,actions:(0,D.jsx)(x,{className:`size-9 shrink-0 p-0`,disabled:T,label:e.refresh,onClick:P})}),(0,D.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,D.jsxs)(`div`,{className:`flex flex-col gap-4 p-5 sm:flex-row sm:items-center sm:gap-6`,children:[(0,D.jsx)(`div`,{className:`grid h-40 w-40 shrink-0 place-items-center self-center rounded-xl bg-surface-hover/35`,children:N?(0,D.jsx)(S,{pet:N,action:`idle`,displayHeight:Math.round(104*G/100),reducedMotion:n.prefs.reducedMotion}):null}),(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-6 gap-y-2`,children:[(0,D.jsx)(`h2`,{className:`break-words text-xl font-semibold text-fg`,children:N?R(N).name:e.title}),(0,D.jsx)(O,{title:e.enable,checked:n.prefs.enabled,disabled:T,onChange:e=>void I(e)})]}),(0,D.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.bondSummary.replace(`{days}`,String(K)).replace(`{tasks}`,String(n.relationship.completedTaskCount))}),n.pets.length>1?(0,D.jsx)(`div`,{className:`mt-4 max-w-56`,children:(0,D.jsx)(l,{"aria-label":e.petList,value:N?.id??``,onChange:e=>L(e.target.value),disabled:T,children:n.pets.map(e=>(0,D.jsx)(u,{value:e.id,children:R(e).name},e.id))})}):null,N&&!N.builtin?(0,D.jsxs)(`button`,{type:`button`,onClick:()=>U(N),className:`mt-3 inline-flex min-h-9 items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg`,children:[(0,D.jsx)(m,{className:`size-3.5`}),e.optimizeInChat]}):null]})]}),(0,D.jsx)(`div`,{className:`border-t border-edge px-5 py-2`,children:(0,D.jsxs)(`button`,{type:`button`,onClick:H,className:_(`inline-flex min-h-10 items-center gap-2 text-xs font-medium text-fg-muted hover:text-accent-fg`,y.press),children:[(0,D.jsx)(h,{className:`size-4`}),e.createTitle]})})]}),n.petIssues.length>0?(0,D.jsxs)(`section`,{className:`rounded-xl border border-danger/20 bg-danger/5 p-4`,children:[(0,D.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-medium text-danger`,children:[(0,D.jsx)(d,{className:`size-4`}),e.invalidPets]}),(0,D.jsx)(`div`,{className:`mt-3 space-y-3`,children:n.petIssues.map(t=>(0,D.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,D.jsxs)(`div`,{className:`min-w-0 text-xs text-fg-muted`,children:[(0,D.jsx)(`p`,{className:`break-words`,children:t.reason}),(0,D.jsxs)(`details`,{className:`mt-1`,children:[(0,D.jsx)(`summary`,{className:`cursor-pointer`,children:e.issueDetails}),(0,D.jsx)(`p`,{className:`mt-2 break-all font-mono`,children:t.dir}),t.details?.length?(0,D.jsx)(`p`,{className:`mt-1 break-words`,children:t.details.join(`; `)}):null]})]}),(0,D.jsxs)(`button`,{type:`button`,onClick:()=>W(t),className:`inline-flex min-h-9 shrink-0 items-center gap-1.5 text-xs font-medium text-danger`,children:[(0,D.jsx)(p,{className:`size-3.5`}),e.fixInChat]})]},`${t.dir}-${t.reason}`))})]}):null,(0,D.jsxs)(`section`,{"aria-label":e.displayGroup,children:[(0,D.jsx)(`h3`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:e.displayGroup}),(0,D.jsxs)(`div`,{className:`divide-y divide-edge rounded-xl border border-edge bg-surface-panel px-4`,children:[(0,D.jsx)(O,{title:e.showOnStartup,checked:n.prefs.showOnStartup,disabled:T,onChange:e=>void F({showOnStartup:e})}),(0,D.jsx)(O,{title:e.alwaysOnTop,checked:n.prefs.alwaysOnTop,disabled:T,onChange:e=>void F({alwaysOnTop:e})}),(0,D.jsx)(O,{title:e.bubbles,checked:n.prefs.bubbleEnabled,disabled:T,onChange:e=>void F({bubbleEnabled:e})}),(0,D.jsxs)(`div`,{className:`py-3`,children:[(0,D.jsxs)(`label`,{htmlFor:`desktop-pet-size`,className:`flex items-center justify-between gap-3 text-sm font-medium text-fg`,children:[e.size,(0,D.jsxs)(`span`,{className:`text-xs tabular-nums text-fg-muted`,children:[G,`%`]})]}),(0,D.jsx)(`input`,{id:`desktop-pet-size`,type:`range`,min:70,max:140,step:5,className:`mt-3 w-full accent-accent`,value:G,disabled:T,onChange:e=>j(Number(e.target.value)),onBlur:()=>void q(),onKeyUp:e=>{(e.key===`Enter`||e.key===` `||e.key.startsWith(`Arrow`))&&q()},onPointerUp:()=>void q()})]})]})]}),(0,D.jsxs)(`section`,{"aria-label":e.interactionGroup,children:[(0,D.jsx)(`h3`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:e.interactionGroup}),(0,D.jsxs)(`div`,{className:`divide-y divide-edge rounded-xl border border-edge bg-surface-panel px-4`,children:[(0,D.jsx)(O,{title:e.proactiveTips,checked:n.prefs.proactiveTipsEnabled,disabled:T,onChange:e=>void F({proactiveTipsEnabled:e})}),(0,D.jsx)(O,{title:e.interactions,desc:e.interactionsDesc,checked:n.prefs.interactionEnabled,disabled:T,onChange:e=>void F({interactionEnabled:e})}),(0,D.jsx)(O,{title:e.reducedMotion,checked:n.prefs.reducedMotion,disabled:T,onChange:e=>void F({reducedMotion:e})}),(0,D.jsxs)(`div`,{className:`flex min-h-12 flex-wrap items-center justify-between gap-3 py-3`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.behaviorMode}),(0,D.jsxs)(l,{"aria-label":e.behaviorMode,className:`w-36`,triggerClassName:`h-9 bg-surface-panel`,value:n.prefs.behaviorMode,disabled:T,onChange:e=>void F({behaviorMode:e.target.value}),children:[(0,D.jsx)(u,{value:`focus`,children:e.behaviorFocus}),(0,D.jsx)(u,{value:`companion`,children:e.behaviorCompanion}),(0,D.jsx)(u,{value:`playful`,children:e.behaviorPlayful})]})]})]})]}),(0,D.jsxs)(`details`,{className:`group rounded-xl border border-edge bg-surface-panel`,children:[(0,D.jsxs)(`summary`,{className:`flex min-h-12 cursor-pointer list-none items-center justify-between gap-3 px-4 text-sm font-medium text-fg [&::-webkit-details-marker]:hidden`,children:[e.advanced,(0,D.jsx)(c,{className:`size-4 text-fg-muted transition-transform group-open:rotate-180`})]}),(0,D.jsxs)(`div`,{className:`space-y-3 border-t border-edge px-4 pb-4`,children:[(0,D.jsx)(O,{title:e.clickThrough,desc:e.clickThroughDesc,checked:n.prefs.clickThroughWhenIdle,disabled:T,onChange:e=>void F({clickThroughWhenIdle:e})}),(0,D.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-edge pt-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.customPets}),(0,D.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs text-fg-muted`,children:n.customPetsDir})]}),(0,D.jsxs)(`button`,{type:`button`,onClick:()=>void M.openCustomPetsDir(),className:`inline-flex min-h-10 shrink-0 items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg`,children:[(0,D.jsx)(f,{className:`size-3.5`}),e.openFolder]})]}),(0,D.jsxs)(`button`,{type:`button`,className:_(`inline-flex min-h-10 items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg disabled:opacity-50`,y.press),disabled:T,onClick:()=>void M.resetPosition().then(r),children:[(0,D.jsx)(g,{className:`size-3.5`}),e.resetPosition]})]})]})]})}export{k as DesktopPetSettings};
|
package/dist/gateway/static/root/assets/{dev-view-store-D8XYHVqG.js → dev-view-store-JiJv585f.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as e}from"./locale-store-
|
|
1
|
+
import{p as e}from"./locale-store-VNjH18Dj.js";import{t}from"./middleware-Pd0e8Igk.js";var n=e(t(e=>({showRawToolData:!1,setShowRawToolData:t=>e({showRawToolData:t})}),{name:`xopc-web-dev-view`}));export{n as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e,n as t}from"./rolldown-runtime-aKtaBQYM.js";import{a as n,n as r,t as i}from"./vendor-react-BOUWij0V.js";import{u as a}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{n as o}from"./locale-store-VNjH18Dj.js";import{t as s}from"./messages-Btr7C0hF.js";import{t as c}from"./chevron-right-BweFrslA.js";import{t as l}from"./circle-check-C23XjkUj.js";import{t as u}from"./clock-3-DnrAnuyZ.js";import{t as d}from"./download-Dk-ZjtO6.js";import{t as f}from"./external-link-DjqjBmc3.js";import{t as p}from"./laptop-CI3hBVrl.js";import{t as m}from"./panel-right-CFGrHTsD.js";import{t as h}from"./smartphone-DSSsQFqA.js";import{t as g}from"./x-B_N4OPjy.js";import{t as _}from"./cn-0WouolD0.js";import{i as v}from"./vendor-swr-CdRzEUwF.js";import{t as y}from"./button-CnRSIP6m.js";import{t as b}from"./skeleton-BI5TyibZ.js";import{a as x,i as ee,o as S,r as C,s as w,t as T}from"./dist-DfWfZ9iu.js";import{i as E,o as te}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{n as D}from"./app-link-1j40sJ-z.js";import{t as O}from"./use-async-resource-BHFGZCY2.js";import{t as k}from"./copy-text-row-CYIv7RfP.js";import{a as A,n as j,r as M}from"./oauth-api-DIE4UpP7.js";import{n as N,r as P,t as F}from"./oauth-authorization-window-o6URRos4.js";import{_ as I,a as ne,b as re,d as ie,f as L,g as ae,h as oe,i as R,l as z,m as se,n as B,p as ce,r as V,s as le,t as H,u as U,v as ue,y as de}from"./tunnel-api-BK_ivyIb.js";import{t as fe}from"./mobile-pair-qr-CuIbmw5x.js";var W=r(),G=e(n(),1),K=i();function pe(){let e=s(o(e=>e.language)),t=e.endpointToolsSettings.deviceAccess.flow,n=e.tunnelSettings,{data:r,error:i,mutate:a}=v(`tunnel-status`,B,{refreshInterval:1500}),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(!1),[p,m]=(0,G.useState)(!0),[h,g]=(0,G.useState)(`idle`),[_,x]=(0,G.useState)(null),[ee,S]=(0,G.useState)(``),[C,w]=(0,G.useState)(``),T=(0,G.useRef)(!0);(0,G.useEffect)(()=>(T.current=!0,()=>{T.current=!1}),[]);let E=_?_===`registration-rejected`:r?.state===`error`&&L(Error(r.lastError??``)),te=_?_===`recovery-rejected`:r?.state===`error`&&ie(Error(r.lastError??``)),O=async()=>{if(!r)return;if(r.consentRequired&&!c){d(!0);return}let e=E||!r.registrationSecret?.configured,t=e?P():null,n,i=!1;x(null),S(``);try{if(r.consentRequired&&await ne(),e){g(`provisioning`),E&&await V({registrationSecret:null});let e=!1;try{await R()}catch(t){if(!U(t))throw t;e=!0}if(e){g(`authorizing`);let e=sessionStorage.getItem(`device-pairing-oauth`),r=e?JSON.parse(e):null;n=r&&r.expiresAt>Date.now()?r.sessionId:(await A(`xopc-tunnel`)).sessionId,sessionStorage.setItem(`device-pairing-oauth`,JSON.stringify({sessionId:n,expiresAt:r&&r.expiresAt>Date.now()?r.expiresAt:Date.now()+5*6e4}));let a=``,o=Date.now()+5*6e4,s=!1;for(;T.current&&Date.now()<o;){let e=await M(n);if(e.authUrl&&e.authUrl!==a&&(a=e.authUrl,await N(a,t)||w(a)),e.status===`completed`){s=!0,i=!0;break}if(e.status===`failed`||e.status===`cancelled`)throw Error(`Authorization cancelled`);await new Promise(e=>setTimeout(e,1e3))}if(!T.current)return;if(!s)throw Error(`Authorization expired`);await R()}await a()}if(!T.current)return;g(`starting`),await le(),p&&await V({autoStart:!0}),await a(),i=!0}catch(e){i=!0,T.current&&(x(z(e)===`tunnel_key_limit_reached`?`key-limit`:L(e)?`registration-rejected`:ie(e)?`recovery-rejected`:`failed`),S(e instanceof Error?e.message:``))}finally{F(t),i&&(sessionStorage.removeItem(`device-pairing-oauth`),n&&j(n).catch(()=>{})),T.current&&(g(`idle`),w(``))}};if(!r&&!i)return(0,K.jsxs)(`div`,{className:`space-y-5`,children:[(0,K.jsx)(b,{className:`h-5 w-4/5`}),(0,K.jsx)(b,{className:`h-24 w-full`})]});let k=h===`provisioning`||h===`starting`||r?.state===`connecting`||r?.state===`reconnecting`,I=h===`idle`&&!k&&(_||i||r?.state===`error`),re=ee||(i instanceof Error?i.message:``)||(r?.state===`error`?r.lastError:``);return(0,K.jsxs)(`div`,{className:`flex flex-col`,children:[(0,K.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:k?t.preparingHint:h===`authorizing`?t.authorizing:t.enableHint}),C&&h===`authorizing`?(0,K.jsx)(`a`,{href:C,target:`_blank`,rel:`noopener noreferrer`,className:`mt-4 inline-flex min-h-11 items-center text-sm text-accent`,children:t.openAuthorization}):null,k?(0,K.jsxs)(`div`,{className:`mt-8 space-y-3`,"aria-label":t.preparing,children:[(0,K.jsx)(b,{className:`h-2 w-full`}),(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.preparing})]}):null,(u||r?.consentRequired)&&h===`idle`?(0,K.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[(0,K.jsxs)(`details`,{open:u,className:`text-sm text-fg-muted`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer py-2`,children:t.details}),(0,K.jsx)(`p`,{className:`mt-2`,children:n.consentIntro}),(0,K.jsx)(`ul`,{className:`mt-3 list-disc space-y-2 pl-5`,children:[n.consentBullet1,n.consentBullet2,n.consentBullet3].map(e=>(0,K.jsx)(`li`,{children:e},e))})]}),(0,K.jsxs)(`label`,{className:`flex items-start gap-3 text-sm text-fg`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:c,onChange:e=>l(e.target.checked),className:`mt-1 size-4 accent-accent`}),n.consentCheckbox]})]}):null,I&&_===`key-limit`?(0,K.jsxs)(`div`,{role:`alert`,className:`mt-4 rounded-lg border border-warning/30 bg-warning/5 p-4`,children:[(0,K.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.routeKeyLimitTitle}),(0,K.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.routeKeyLimitHint}),(0,K.jsxs)(y,{variant:`secondary`,className:`mt-3`,onClick:()=>void D(H),children:[t.manageTunnelKeys,(0,K.jsx)(f,{className:`size-3`})]})]}):I?(0,K.jsxs)(`div`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:[(0,K.jsx)(`p`,{children:i&&!r?t.readinessFailed:E?t.routeAuthorizationRequired:te?t.routeRecoveryRequired:t.routeSetupFailed}),re?(0,K.jsxs)(`details`,{className:`mt-2 text-xs text-fg-muted`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer py-2`,children:t.details}),(0,K.jsx)(`p`,{className:`break-words whitespace-pre-wrap`,children:re})]}):null]}):null,(0,K.jsxs)(`label`,{className:`my-5 flex items-center gap-3 text-sm text-fg-muted`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:p,disabled:h!==`idle`,onChange:e=>m(e.target.checked),className:`size-4 accent-accent`}),t.autoStart]}),i&&!r?(0,K.jsx)(y,{className:`w-full`,variant:`primary`,onClick:()=>void a().catch(()=>{}),children:t.retry}):(0,K.jsx)(y,{className:`w-full`,variant:`primary`,disabled:!r||h!==`idle`||k||u&&!c,onClick:()=>void O(),children:h===`authorizing`?t.authorizing:k?t.preparing:E?t.authorize:I?t.retry:t.enable})]})}var q=t({DevicePairingWizard:()=>J});function J(e){let t=(0,W.c)(16),{open:n,onOpenChange:r,onPaired:i,targetKind:o}=e,s=a(),[c,l]=(0,G.useState)(o),u,d;t[0]===o?(u=t[1],d=t[2]):(u=()=>{l(o)},d=[o],t[0]=o,t[1]=u,t[2]=d),(0,G.useEffect)(u,d);let f;t[3]!==r||t[4]!==o?(f=e=>{e||l(o),r(e)},t[3]=r,t[4]=o,t[5]=f):f=t[5];let p=f,m;t[6]!==p||t[7]!==s||t[8]!==i||t[9]!==n||t[10]!==c?(m=n?c?(0,K.jsx)(me,{targetKind:c,onClose:()=>p(!1),onPaired:i}):(0,K.jsx)(X,{onChoose:l,onChooseLocalBrowser:()=>{p(!1),s(`/settings/agent-browser?driver=extension`)},onClose:()=>p(!1)}):null,t[6]=p,t[7]=s,t[8]=i,t[9]=n,t[10]=c,t[11]=m):m=t[11];let h;return t[12]!==p||t[13]!==n||t[14]!==m?(h=(0,K.jsx)(T,{open:n,onOpenChange:p,children:m}),t[12]=p,t[13]=n,t[14]=m,t[15]=h):h=t[15],h}function Y(e){let t=(0,W.c)(14),{icon:n,title:r,hint:i,onClick:a}=e,o;t[0]===n?o=t[1]:(o=(0,K.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,K.jsx)(n,{className:`size-5`,"aria-hidden":`true`})}),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,K.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:r}),t[2]=r,t[3]=s);let l;t[4]===i?l=t[5]:(l=(0,K.jsx)(`span`,{className:`mt-0.5 block text-xs leading-5 text-fg-muted`,children:i}),t[4]=i,t[5]=l);let u;t[6]!==s||t[7]!==l?(u=(0,K.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[s,l]}),t[6]=s,t[7]=l,t[8]=u):u=t[8];let d;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,K.jsx)(c,{className:`size-4 shrink-0 text-fg-disabled transition-transform group-hover:translate-x-0.5 group-hover:text-fg-muted`,"aria-hidden":`true`}),t[9]=d):d=t[9];let f;return t[10]!==a||t[11]!==o||t[12]!==u?(f=(0,K.jsxs)(`button`,{type:`button`,className:`group flex min-h-18 w-full cursor-pointer items-center gap-4 rounded-xl border border-edge bg-surface-panel px-4 py-3.5 text-left shadow-surface transition-[background-color,border-color,box-shadow,transform] hover:border-edge-strong hover:bg-surface-active hover:shadow-elevated active:translate-y-px active:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel motion-reduce:active:translate-y-0`,onClick:a,children:[o,u,d]}),t[10]=a,t[11]=o,t[12]=u,t[13]=f):f=t[13],f}function X(e){let t=(0,W.c)(40),{onChoose:n,onChooseLocalBrowser:r,onClose:i}=e,a=o(Z),c;t[0]===a?c=t[1]:(c=s(a),t[0]=a,t[1]=c);let l=c.endpointToolsSettings.deviceAccess,u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,K.jsx)(x,{className:_(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,te)}),t[2]=u):u=t[2];let d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=_(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(28rem,calc(100dvh-2rem))] w-[min(40rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay`,E),t[3]=d):d=t[3];let f;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,K.jsx)(`span`,{className:`text-lg font-semibold tracking-tight text-fg`,children:`xopc`}),t[4]=f):f=t[4];let v;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,K.jsx)(g,{className:`size-4`}),t[5]=v):v=t[5];let y;t[6]!==l.cancel||t[7]!==i?(y=(0,K.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b border-edge-subtle px-6 py-3`,children:[f,(0,K.jsx)(`button`,{type:`button`,className:`flex size-10 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":l.cancel,onClick:i,children:v})]}),t[6]=l.cancel,t[7]=i,t[8]=y):y=t[8];let b;t[9]===l.chooseTitle?b=t[10]:(b=(0,K.jsx)(w,{className:`text-lg font-semibold tracking-tight text-fg sm:text-xl`,children:l.chooseTitle}),t[9]=l.chooseTitle,t[10]=b);let T;t[11]===l.chooseHint?T=t[12]:(T=(0,K.jsx)(ee,{className:`mt-1.5 text-sm leading-6 text-fg-muted`,children:l.chooseHint}),t[11]=l.chooseHint,t[12]=T);let D;t[13]!==l.localBrowserHint||t[14]!==l.localBrowserTitle||t[15]!==r?(D=(0,K.jsx)(Y,{icon:p,title:l.localBrowserTitle,hint:l.localBrowserHint,onClick:r}),t[13]=l.localBrowserHint,t[14]=l.localBrowserTitle,t[15]=r,t[16]=D):D=t[16];let O;t[17]===n?O=t[18]:(O=()=>n(`mobile`),t[17]=n,t[18]=O);let k;t[19]!==l.mobileHint||t[20]!==l.mobileTitle||t[21]!==O?(k=(0,K.jsx)(Y,{icon:h,title:l.mobileTitle,hint:l.mobileHint,onClick:O}),t[19]=l.mobileHint,t[20]=l.mobileTitle,t[21]=O,t[22]=k):k=t[22];let A;t[23]===n?A=t[24]:(A=()=>n(`browser`),t[23]=n,t[24]=A);let j;t[25]!==l.remoteBrowserHint||t[26]!==l.remoteBrowserTitle||t[27]!==A?(j=(0,K.jsx)(Y,{icon:m,title:l.remoteBrowserTitle,hint:l.remoteBrowserHint,onClick:A}),t[25]=l.remoteBrowserHint,t[26]=l.remoteBrowserTitle,t[27]=A,t[28]=j):j=t[28];let M;t[29]!==k||t[30]!==j||t[31]!==D?(M=(0,K.jsxs)(`div`,{className:`mt-5 flex flex-col gap-2.5`,children:[D,k,j]}),t[29]=k,t[30]=j,t[31]=D,t[32]=M):M=t[32];let N;t[33]!==M||t[34]!==b||t[35]!==T?(N=(0,K.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-6 sm:px-8`,children:[b,T,M]}),t[33]=M,t[34]=b,t[35]=T,t[36]=N):N=t[36];let P;return t[37]!==N||t[38]!==y?(P=(0,K.jsxs)(S,{children:[u,(0,K.jsxs)(C,{className:d,children:[y,N]})]}),t[37]=N,t[38]=y,t[39]=P):P=t[39],P}function Z(e){return e.language}function me({targetKind:e,onClose:t,onPaired:n}){let r=o(e=>e.language),i=s(r),a=i.endpointToolsSettings.deviceAccess,p=a.flow,[m,h]=(0,G.useState)(!1),T=v(m?`device-pairing-readiness`:null,I,{refreshInterval:1500}),[A,j]=(0,G.useState)(),[M,N]=(0,G.useState)(null),[P,F]=(0,G.useState)(!1),[ne,ie]=(0,G.useState)(Date.now()),[L,R]=(0,G.useState)(null),z=(0,G.useRef)(!0),B=(0,G.useRef)(null),V=(0,G.useRef)(!1),le=(0,G.useRef)(!1),H=v(A?[`device-pairing-setup`,A.id]:null,()=>ue(A.id),{refreshInterval:1500}),U=H.data?.request,W=U?.status===`completed`,q=W&&U.connectedAt!==void 0,J=v(q&&window.electronAPI?.system?`system-behavior`:null,()=>window.electronAPI.system.getBehavior()),Y=A?.targetKind===`mobile`?A.universalLink:``,X=O(()=>fe(Y),[Y],{enabled:!!Y,initial:null,errorData:null}),Z=r===`zh`?`https://xopc.ai/zh#download`:`https://xopc.ai/en#download`,me=r===`zh`?`https://xopcai.github.io/xopc/zh/browser-extension`:`https://xopcai.github.io/xopc/browser-extension`,he=O(()=>fe(Z),[Z],{enabled:!m&&e===`mobile`,initial:null,errorData:null});(0,G.useEffect)(()=>{z.current=!0;let e=setInterval(()=>ie(Date.now()),1e3);return()=>{z.current=!1,clearInterval(e),B.current&&ce(B.current).catch(()=>{})}},[]);let ge=(0,G.useCallback)(async()=>{if(!V.current){V.current=!0,F(!0),N(null);try{B.current&&await ce(B.current),B.current=null,j(void 0);let t=await se(e);if(t.kind===`ready`){if(!z.current){await ce(t.setup.id);return}B.current=t.setup.id,j(t.setup)}else await T.mutate()}catch{z.current&&N(`create`)}finally{V.current=!1,z.current&&F(!1)}}},[T,e]);(0,G.useEffect)(()=>{T.data?.ready&&!A&&M!==`create`&&!V.current&&ge()},[T.data,A,M,ge]),(0,G.useEffect)(()=>{q&&!le.current&&(le.current=!0,n?.())},[q,n]);let _e=async e=>{if(U){F(!0),N(null);try{await oe(U,e),await H.mutate()}catch{N(`decision`),await H.mutate()}finally{z.current&&F(!1)}}},ve=(0,G.useRef)(0);(0,G.useEffect)(()=>{H.data&&(ve.current=H.data.serverTime-Date.now())},[H.data]);let Q=ne+ve.current,ye=A&&Q>=A.expiresAt&&!U,be=U&&[`expired`,`rejected`,`cancelled`].includes(U.status),xe=A?A.expiresAt-Q<6e4:!1,Se=A?xe?`${Math.max(0,Math.ceil((A.expiresAt-Q)/1e3))}s`:p.valid:``,$=e===`mobile`?{connect:a.mobileScan,connectHint:a.mobileScanHint,allowTitle:a.mobileAllowTitle,success:a.mobileSuccess,successHint:a.mobileSuccessHint}:{connect:a.browserConnect,connectHint:a.browserConnectHint,allowTitle:a.browserAllowTitle,success:a.browserSuccess,successHint:a.browserSuccessHint},Ce=e===`mobile`?a.mobilePrepareTitle:a.browserPrepareTitle,we=e===`mobile`?a.mobilePrepareHint:a.browserPrepareHint,Te=m?q?$.success:U?.status===`pending`?$.allowTitle:W||U?.status===`approved`?p.waiting:A?$.connect:p.title:Ce,Ee=M===`create`?p.createFailed:M===`decision`?p.decisionFailed:M===`background`?p.backgroundFailed:M===`download`?a.browserDownloadFailed:null,De=async()=>{F(!0),N(null);try{await ae()}catch{N(`download`)}finally{z.current&&F(!1)}};return(0,K.jsxs)(S,{children:[(0,K.jsx)(x,{className:_(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,te)}),(0,K.jsxs)(C,{className:_(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(600px,calc(100dvh-48px))] w-[min(560px,calc(100vw-32px))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay`,E),children:[(0,K.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b border-edge-subtle px-6 py-3`,children:[(0,K.jsx)(`span`,{className:`text-lg font-semibold tracking-tight text-fg`,children:`xopc`}),(0,K.jsx)(`button`,{type:`button`,className:`flex size-10 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":p.cancel,onClick:t,children:(0,K.jsx)(g,{className:`size-4`})})]}),(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto px-8 py-7`,children:[q?(0,K.jsx)(l,{className:`mb-5 size-7 text-success`}):null,(0,K.jsx)(w,{className:`text-xl font-semibold tracking-tight text-fg`,children:Te}),(0,K.jsx)(ee,{className:`mt-2 text-sm leading-relaxed text-fg-muted`,children:m?q?$.successHint:W?p.waitingForDevice:U?U.displayName:A?$.connectHint:p.intro:we}),Ee?(0,K.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:Ee}):null,m&&T.error?(0,K.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:p.readinessFailed}):null,m&&H.error?(0,K.jsx)(`p`,{role:`status`,className:`mt-4 text-sm text-warning`,children:p.statusUnavailable}):null,m?T.data?q?(0,K.jsxs)(K.Fragment,{children:[J.data?(0,K.jsxs)(`label`,{className:`mt-8 flex items-center justify-between gap-4 border-y border-edge-subtle py-5 text-sm text-fg`,children:[a.background,(0,K.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":J.data.runInBackground??!1,disabled:!J.data.backgroundSupported,checked:J.data.runInBackground??!1,className:`size-5 accent-accent`,onChange:e=>{window.electronAPI.system.setBehavior({runInBackground:e.target.checked}).then(e=>J.mutate(e.behavior)).catch(()=>N(`background`))}})]}):null,(0,K.jsx)(`p`,{className:`mt-4 text-xs text-fg-muted`,children:a.sleep})]}):be||ye?(0,K.jsxs)(`div`,{className:`mt-10 space-y-5`,children:[(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:ye||U?.status===`expired`?p.expired:p.declined}),(0,K.jsx)(y,{variant:`primary`,onClick:()=>void ge(),disabled:P,children:p.refresh})]}):U?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:p.scope}),(0,K.jsxs)(`p`,{className:`mt-10 font-mono text-4xl tracking-[0.16em] text-fg`,"aria-live":`polite`,children:[U.confirmationCode.slice(0,3),` `,U.confirmationCode.slice(3)]}),(0,K.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:p.compare}),(0,K.jsxs)(`details`,{className:`mt-6 text-xs text-fg-muted`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer py-2`,children:p.access}),(0,K.jsx)(`p`,{children:p.accessHint})]})]}):A?.targetKind===`mobile`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`my-6 flex flex-col items-center`,children:[(0,K.jsx)(`div`,{className:`rounded-[1.75rem] border border-edge bg-surface-hover/55 p-2.5 shadow-surface`,children:(0,K.jsx)(`div`,{className:`rounded-[1.25rem] bg-white p-2 shadow-sm ring-1 ring-black/5`,children:X.data?(0,K.jsx)(`img`,{src:X.data,alt:a.qrAlt,width:240,height:240,className:`size-[240px] max-w-full rounded-xl bg-white`}):X.error?null:(0,K.jsx)(b,{className:`size-[240px] rounded-xl`})})}),X.error?null:(0,K.jsxs)(`p`,{className:_(`mt-4 inline-flex min-h-8 items-center gap-1.5 rounded-full px-3 text-xs font-medium`,xe?`bg-warning-soft text-warning`:`bg-surface-hover text-fg-muted`),"aria-live":`polite`,children:[(0,K.jsx)(u,{className:`size-3.5`,"aria-hidden":`true`}),Se]})]}),X.error?(0,K.jsx)(`p`,{role:`status`,className:`text-center text-sm text-warning`,children:p.qrFailed}):null,X.error?(0,K.jsx)(`div`,{className:`mt-5`,children:(0,K.jsx)(k,{text:A.universalLink,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})}):(0,K.jsxs)(`details`,{className:`group mx-auto mt-1 w-full max-w-sm rounded-xl border border-edge bg-surface-panel text-xs text-fg-muted`,children:[(0,K.jsxs)(`summary`,{className:`flex min-h-11 cursor-pointer list-none items-center justify-between gap-3 rounded-xl px-3.5 transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent [&::-webkit-details-marker]:hidden`,children:[(0,K.jsx)(`span`,{children:p.fallback}),(0,K.jsx)(c,{className:`size-3.5 shrink-0 transition-transform group-open:rotate-90`,"aria-hidden":`true`})]}),(0,K.jsx)(`div`,{className:`border-t border-edge-subtle p-3`,children:(0,K.jsx)(k,{text:A.universalLink,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})})]})]}):A?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`ol`,{className:`mt-7 space-y-2 text-sm leading-6 text-fg-muted`,children:[(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`1.`}),a.browserConnectStep1]}),(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`2.`}),a.browserConnectStep2]}),(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`3.`}),a.browserConnectStep3]})]}),(0,K.jsx)(`div`,{className:`mt-6`,children:(0,K.jsx)(k,{text:A.browserInvitation,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})}),(0,K.jsx)(`p`,{className:`mt-3 text-center text-xs text-fg-muted`,children:A.expiresAt-Q<6e4?`${Math.max(0,Math.ceil((A.expiresAt-Q)/1e3))}s`:p.valid})]}):T.data.ready?(0,K.jsx)(`div`,{className:`mt-8`,children:(0,K.jsx)(b,{className:`mx-auto size-[216px]`})}):(0,K.jsxs)(`div`,{className:`mt-6 flex flex-1 flex-col`,children:[L===`tailscale`?(0,K.jsx)(re,{embedded:!0}):L===`https`?(0,K.jsx)(de,{}):L===`choices`?(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsx)(y,{variant:`secondary`,className:`w-full`,onClick:()=>R(`tailscale`),children:a.useTailscale}),(0,K.jsx)(y,{variant:`secondary`,className:`w-full`,onClick:()=>R(`https`),children:a.useOwnHttps})]}):(0,K.jsx)(pe,{}),(0,K.jsx)(y,{variant:`ghost`,className:`mt-3 w-full`,onClick:()=>R(L?null:`choices`),children:L?p.back:p.existing})]}):(0,K.jsxs)(`div`,{className:`mt-8 space-y-4`,children:[(0,K.jsx)(b,{className:`h-5 w-3/4`}),(0,K.jsx)(b,{className:`h-40 w-full`})]}):e===`mobile`?(0,K.jsxs)(`div`,{className:`mt-7 flex flex-col items-center`,children:[he.data?(0,K.jsx)(`img`,{src:he.data,alt:a.mobileDownloadQrAlt,width:144,height:144,className:`size-36 rounded-lg bg-white`}):(0,K.jsx)(b,{className:`size-36`}),(0,K.jsxs)(y,{variant:`secondary`,className:`mt-5 w-full`,onClick:()=>void D(Z),children:[(0,K.jsx)(f,{className:`size-4`}),a.mobileDownload]}),(0,K.jsx)(`p`,{className:`mt-3 text-center text-xs leading-5 text-fg-muted`,children:a.mobileDownloadHint})]}):(0,K.jsxs)(`div`,{className:`mt-7`,children:[(0,K.jsxs)(y,{variant:`secondary`,className:`w-full`,disabled:P,onClick:()=>void De(),children:[(0,K.jsx)(d,{className:`size-4`}),a.browserDownload]}),(0,K.jsxs)(`ol`,{className:`mt-5 space-y-3 text-sm leading-6 text-fg-muted`,children:[(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`1.`}),a.browserInstallStep1]}),(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`2.`}),a.browserInstallStep2]}),(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`3.`}),a.browserInstallStep3]})]}),(0,K.jsxs)(`button`,{type:`button`,className:`mt-5 inline-flex items-center gap-1 text-xs text-accent hover:underline`,onClick:()=>void D(me),children:[a.browserInstallHelp,(0,K.jsx)(f,{className:`size-3`})]})]})]}),!m||T.error||q||U?.status===`pending`||M===`create`||M===`decision`?(0,K.jsx)(`footer`,{className:`shrink-0 px-8 pb-6`,children:m?q?(0,K.jsx)(y,{className:`w-full`,variant:`primary`,onClick:t,children:p.done}):U?.status===`pending`?(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(y,{className:`w-full`,variant:`primary`,disabled:P,onClick:()=>void _e(`approve`),children:p.allow}),(0,K.jsx)(y,{className:`w-full`,variant:`ghost`,disabled:P,onClick:()=>void _e(`reject`),children:p.cancel})]}):T.error?(0,K.jsx)(y,{className:`w-full`,variant:`primary`,onClick:()=>void T.mutate(),children:p.retry}):(0,K.jsx)(y,{className:`w-full`,variant:`primary`,disabled:P,onClick:()=>void ge(),children:p.retry}):(0,K.jsx)(y,{className:`w-full`,variant:`primary`,onClick:()=>{N(null),h(!0)},children:e===`mobile`?a.mobileReady:a.browserReady})}):null]})]})}export{q as n,J as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{r as n,t as r}from"./working-directory-picker-modal-
|
|
1
|
+
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{r as n,t as r}from"./working-directory-picker-modal-B-EHm52-.js";import{t as i}from"./cn-0WouolD0.js";import{n as a}from"./interaction-BdhHBbYa.js";import{n as o,t as s}from"./use-directory-picker-C4p7AgWY.js";var c=e(),l=t();function u(e){let t=(0,c.c)(27),{value:r,onPick:s,disabled:u,placeholder:d,title:f,className:p,maxWidthClass:m,compact:h,"aria-label":g}=e,_=m===void 0?`max-w-[min(12rem,40vw)]`:m,v=h!==void 0&&h,y,b;t[0]!==d||t[1]!==r?(b=r.trim(),y=b?o(b):d??``,t[0]=d,t[1]=r,t[2]=y,t[3]=b):(y=t[2],b=t[3]);let x=y,S=f??(b||void 0),C=g??f??x,w=v?`inline-flex size-9 shrink-0 items-center justify-center rounded-lg p-0`:`inline-flex min-h-8 min-w-0 shrink-0 items-center gap-1 rounded-lg px-2 py-1 text-xs`,T=!v&&_,E=u&&`cursor-not-allowed opacity-60`,D;t[4]!==p||t[5]!==w||t[6]!==T||t[7]!==E?(D=i(w,`border border-edge-subtle/80 bg-surface-hover/40 dark:border-edge-subtle`,a.transition,a.focusRingPanel,`cursor-pointer hover:bg-surface-hover/70 dark:hover:bg-surface-hover/50`,T,E,p),t[4]=p,t[5]=w,t[6]=T,t[7]=E,t[8]=D):D=t[8];let O;t[9]!==u||t[10]!==s?(O=e=>{e.stopPropagation(),u||s()},t[9]=u,t[10]=s,t[11]=O):O=t[11];let k=v?`size-4`:`size-3.5`,A;t[12]===k?A=t[13]:(A=i(`shrink-0 text-fg-muted`,k),t[12]=k,t[13]=A);let j;t[14]===A?j=t[15]:(j=(0,l.jsx)(n,{className:A,"aria-hidden":!0}),t[14]=A,t[15]=j);let M;t[16]!==v||t[17]!==x?(M=v?null:(0,l.jsx)(`span`,{className:`min-w-0 truncate text-left font-medium text-fg`,children:x}),t[16]=v,t[17]=x,t[18]=M):M=t[18];let N;return t[19]!==u||t[20]!==O||t[21]!==j||t[22]!==M||t[23]!==S||t[24]!==C||t[25]!==D?(N=(0,l.jsxs)(`button`,{type:`button`,disabled:u,title:S,"aria-label":C,className:D,onClick:O,children:[j,M]}),t[19]=u,t[20]=O,t[21]=j,t[22]=M,t[23]=S,t[24]=C,t[25]=D,t[26]=N):N=t[26],N}function d(e){let t=(0,c.c)(39),{value:n,onChange:a,disabled:o,wd:d,placeholder:f,inputAriaLabel:p,inputClassName:m,autoFocus:h,trailing:g}=e,_;t[0]!==a||t[1]!==n?(_={initialPath:n,onPicked:a},t[0]=a,t[1]=n,t[2]=_):_=t[2];let v=s(_),y;t[3]===n?y=t[4]:(y=n.trim(),t[3]=n,t[4]=y);let b=y,x=b?`${b}\n${d.chooseFolder}`:`${f??d.notSet}\n${d.selectWorkingDirectory}`,S;t[5]===m?S=t[6]:(S=i(`min-w-0 flex-1`,m),t[5]=m,t[6]=S);let C=o||v.picking,w;t[7]===a?w=t[8]:(w=e=>void a(e.target.value),t[7]=a,t[8]=w);let T=f??d.pathInputPlaceholder,E;t[9]!==h||t[10]!==p||t[11]!==S||t[12]!==C||t[13]!==w||t[14]!==T||t[15]!==n?(E=(0,l.jsx)(`input`,{type:`text`,className:S,value:n,disabled:C,onChange:w,placeholder:T,"aria-label":p,autoFocus:h,autoComplete:`off`,spellCheck:!1}),t[9]=h,t[10]=p,t[11]=S,t[12]=C,t[13]=w,t[14]=T,t[15]=n,t[16]=E):E=t[16];let D=o||v.picking,O;t[17]!==x||t[18]!==v.pick||t[19]!==D||t[20]!==n||t[21]!==d.selectWorkingDirectory?(O=(0,l.jsx)(u,{compact:!0,value:n,onPick:v.pick,disabled:D,title:x,"aria-label":d.selectWorkingDirectory}),t[17]=x,t[18]=v.pick,t[19]=D,t[20]=n,t[21]=d.selectWorkingDirectory,t[22]=O):O=t[22];let k;t[23]!==O||t[24]!==g?(k=(0,l.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[O,g]}),t[23]=O,t[24]=g,t[25]=k):k=t[25];let A;t[26]!==k||t[27]!==E?(A=(0,l.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[E,k]}),t[26]=k,t[27]=E,t[28]=A):A=t[28];let j;t[29]!==v.confirmPick||t[30]!==v.hasNativePicker||t[31]!==v.modalOpen||t[32]!==v.setModalOpen||t[33]!==b||t[34]!==d?(j=v.hasNativePicker?null:(0,l.jsx)(r,{open:v.modalOpen,onOpenChange:v.setModalOpen,initialAbsolutePath:b||void 0,onConfirm:v.confirmPick,wd:d}),t[29]=v.confirmPick,t[30]=v.hasNativePicker,t[31]=v.modalOpen,t[32]=v.setModalOpen,t[33]=b,t[34]=d,t[35]=j):j=t[35];let M;return t[36]!==A||t[37]!==j?(M=(0,l.jsxs)(l.Fragment,{children:[A,j]}),t[36]=A,t[37]=j,t[38]=M):M=t[38],M}export{d as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{i as n,o as r}from"./locale-store-5Hf8J8-_.js";import{t as i}from"./createLucideIcon-DPHK1VkS.js";import{t as a}from"./chevron-down-ccbiQQz_.js";import{t as o}from"./button-CnRSIP6m.js";var s=i(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),c=i(`bookmark`,[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]),l=i(`lightbulb`,[[`path`,{d:`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`,key:`1gvzjb`}],[`path`,{d:`M9 18h6`,key:`x1upvd`}],[`path`,{d:`M10 22h4`,key:`ceow96`}]]);function u(e){let t=e.audioAvailable&&!e.audioDeleted,n=`sync_pending`,r=`none`;return e.audioDeleted?n=`audio_deleted`:e.localSave===`saving`?n=`local_saving`:e.localSave===`failed`?n=`save_failed`:e.localSave===`partial`?(n=`local_partial`,r=`recover`):t?e.serverStatus===`cancelled`?n=`cancelled`:e.serverStatus===`needs_attention`?(n=e.failureStage===`organization`?`analysis_failed`:`transcription_failed`,r=`pipeline`):e.serverStatus===`completed`?e.noteAvailable?e.analysisStale?(n=`analysis_stale`,r=`analyze`):n=`ready`:(n=`analysis_missing`,r=`regenerate`):n=e.serverStatus===`organizing`?e.retryScheduled?`analysis_retrying`:`organizing`:e.retryScheduled?`transcription_retrying`:`transcribing`:e.jobState===`failed`?(n=`verify_failed`,r=`pipeline`):e.jobState===`queued`||e.jobState===`running`||e.sync===`verifying`?n=`verifying`:e.sync===`offline`||e.sync===`failed`?(n=`sync_failed`,r=e.localSave===`complete`?`sync`:`none`):e.localSave!==`complete`&&e.serverStatus===`needs_attention`&&(n=`source_missing`),{stage:n,leave:e.localSave===`saving`?`hold`:t?`cloud`:e.localSave===`complete`?`local`:`hold`,retry:r,audio:t,text:e.textAvailable,note:e.noteAvailable,stale:e.analysisStale}}var d=`open-discussion-capture`;function f(e){window.dispatchEvent(new CustomEvent(d,{detail:e?{projectId:e}:{}}))}var p=e(),m={save_failed:[`录音未能保存`,`Recording could not be saved`,`尚未确认可恢复的原音。请检查麦克风权限和可用存储空间后重新录制。`,`No recoverable audio has been confirmed. Check microphone permission and available storage before recording again.`],cancelled:[`已停止整理`,`Processing stopped`,`已有原音、文字和笔记仍可使用。`,`Existing audio, text and notes remain available.`],local_saving:[`正在保存录音`,`Saving recording`,`请稍候,确认保存完成前请留在此页面。`,`Please stay on this page until saving is confirmed.`],local_partial:[`已保留部分录音`,`Part of the recording was retained`,`本次录音未完整保存。请先恢复或导出已保存部分,确认缺失范围。`,`This recording was not saved completely. Recover or export the saved portion and review the missing parts.`],sync_pending:[`正在同步原音`,`Syncing original audio`,`已完成的文字和笔记可先使用。原音确认可用后,会继续整理。`,`Available text and notes can be used now. Processing continues once the original audio is confirmed.`],sync_failed:[`原音同步未完成`,`Audio sync incomplete`,`已保存的内容仍保留在录制设备。连接网络后可重试同步,无需重新录音。`,`Saved content remains on the recording device. Reconnect and retry sync without recording again.`],verifying:[`原音已上传,正在确认`,`Confirming uploaded audio`,`上传完成后,还需确认原音可用。已有文字可以先查看。`,`Uploaded audio is being checked. Existing text can be read now.`],verify_failed:[`原音确认未完成`,`Audio confirmation incomplete`,`上传内容已保留,可重试确认原音。已有文字和笔记仍可使用。`,`Uploaded content is retained. Retry audio confirmation; existing text and notes remain available.`],transcribing:[`正在整理文字`,`Preparing transcript`,`原音已可回听,已完成的文字可先搜索和查看。文字完成后继续生成笔记。`,`Play the original audio and search available text now. Notes will follow the transcript.`],transcription_retrying:[`正在重试整理文字`,`Retrying transcription`,`原音和处理进度已保留,系统稍后自动重试。已有文字仍可使用。`,`Audio and progress are retained. An automatic retry is scheduled; existing text remains available.`],transcription_failed:[`文字整理未完成`,`Transcription incomplete`,`原音和已有文字均保留。重试会从已保存进度继续,无需重新录音。`,`Audio and existing text are retained. Retry from saved progress without recording again.`],organizing:[`正在生成笔记`,`Preparing notes`,`可以先回听原音、查找原话。笔记完成后可查看重点、结论和行动建议。`,`Play audio and find original statements now. Highlights, conclusions and suggested actions will follow.`],analysis_retrying:[`正在重试生成笔记`,`Retrying notes`,`原音、文字和已有笔记均保留,系统稍后自动重试。`,`Audio, text and existing notes are retained. An automatic retry is scheduled.`],analysis_failed:[`笔记生成未完成`,`Notes incomplete`,`原音、文字和已有笔记均保留。重试只继续整理,不会重新录音或创建重复笔记。`,`Audio, text and existing notes are retained. Retry continues processing without recording again or creating another note.`],ready:[`录音与笔记已就绪`,`Recording and notes are ready`,`现在可以回听原音、查找原话,并回顾重要信息。`,`Play the audio, find original statements and review important information.`],analysis_missing:[`暂未生成笔记`,`Notes are not available yet`,`原音和已有文字仍可使用,可以从原音重新生成文字与笔记。`,`Audio and existing text remain available. Regenerate text and notes from the original audio.`],analysis_stale:[`原文已更新`,`Transcript updated`,`当前笔记基于修改前的原文,可保留查看,也可按新版原文重新整理。`,`Existing notes use an earlier transcript. Keep them or generate notes from the updated text.`],source_missing:[`原音尚不可用`,`Original audio is not available yet`,`请到录制设备的待恢复录音中继续同步。已有文字和笔记仍可查看。`,`Continue sync from recoverable recordings on the recording device. Existing text and notes remain readable.`],audio_deleted:[`原音已删除`,`Original audio was deleted`,`已有文字和笔记仍可查看;重新生成需要重新导入原音。`,`Existing text and notes remain readable. Import the original audio again to regenerate.`]},h={leave_local:[`录音已在本机保存,可以离开当前页面。`,`Recording saved on this device. You can leave this page.`],leave_cloud:[`原音已同步,可以离开当前页面。`,`Original audio synced. You can leave this page.`],leave_hold:[`请先确认保存结果,再离开当前页面。`,`Confirm the recording is saved before leaving this page.`],local_hint:[`关闭应用后,可在待恢复录音中继续同步。请保留本机录音数据。`,`After closing the app, continue sync from recoverable recordings. Keep the recording data on this device.`],cloud_hint:[`后续转写与笔记整理在后台继续;失败时可在这条笔记中重试。`,`Transcription and notes continue on the server. Retry here if processing fails.`],retry_sync:[`重试同步`,`Retry sync`],retry_pipeline:[`继续处理`,`Resume processing`],retry_analysis_failed:[`重试生成笔记`,`Retry notes`],retry_transcription_failed:[`继续整理文字`,`Resume transcription`],retry_verify_failed:[`重试确认原音`,`Retry audio confirmation`],retry_recover:[`恢复已录内容`,`Recover saved audio`],retry_regenerate:[`从原音重新生成`,`Regenerate from audio`],retry_analyze:[`按新版原文整理`,`Update notes from transcript`],audio:[`原音`,`Audio`],text:[`文字`,`Transcript`],note:[`笔记`,`Notes`],available:[`可用`,`Available`],pending:[`尚未完成`,`Not ready`],old_note:[`旧版可用`,`Earlier version available`],open:[`打开笔记`,`Open note`],recover:[`待恢复录音`,`Recoverable recordings`],export:[`导出已录内容`,`Export saved audio`],close:[`稍后查看`,`View later`],annotation_failed:[`重点同步未完成,原音和笔记处理不受影响。`,`Highlights are not synced yet. Audio and note processing are unaffected.`],retry_annotation:[`重试重点同步`,`Retry highlights`]},g=t();function _(e,t=`unknown`,n=`pending`){return{localSave:t,sync:n,serverStatus:e?.discussion.status??``,failureStage:e?.discussion.failureStage??``,jobState:e?.recordingJob?.state??``,retryScheduled:!!e?.processing?.nextAttemptAt,audioAvailable:!!e?.discussion.audioAttachmentId,audioDeleted:!!e?.discussion.audioDeletedAt,textAvailable:!!e?.transcript?.text?.trim()||!!e?.discussion.canonicalTranscript?.trim(),noteAvailable:!!e?.organization?.organization,analysisStale:!!e?.organization&&e.organization.transcriptRevision!==e.transcript?.revision}}function v(e){let t=(0,p.c)(58),{input:n,zh:r,compact:i,busy:s,onRetry:c,children:l,context:d}=e,f=i!==void 0&&i,_=s!==void 0&&s,v=d===void 0?`capture`:d,y,b,x,S,C,w,T,E,D,O,k,A;if(t[0]!==v||t[1]!==n||t[2]!==r){S=u(n),x=m[S.stage];let e;t[15]===r?e=t[16]:(e=e=>h[e][+!r],t[15]=r,t[16]=e),y=e,b=`retry_${[`analysis_failed`,`transcription_failed`,`verify_failed`].includes(S.stage)?S.stage:S.retry}`,k=`polite`,A=S.stage,C=v===`note`?`text-fg`:`rounded-xl bg-surface-inset p-3 text-fg`,w=v===`capture`?(0,g.jsx)(`p`,{className:`mb-1 text-sm font-medium`,children:y(`leave_${S.leave}`)}):null,D=`group`,O=v,E=`flex min-h-11 cursor-pointer list-none items-center gap-2 rounded-lg text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent [&::-webkit-details-marker]:hidden`,T=S.stage.endsWith(`_failed`)||S.stage===`local_partial`?`bg-danger`:`bg-accent`,t[0]=v,t[1]=n,t[2]=r,t[3]=y,t[4]=b,t[5]=x,t[6]=S,t[7]=C,t[8]=w,t[9]=T,t[10]=E,t[11]=D,t[12]=O,t[13]=k,t[14]=A}else y=t[3],b=t[4],x=t[5],S=t[6],C=t[7],w=t[8],T=t[9],E=t[10],D=t[11],O=t[12],k=t[13],A=t[14];let j=`size-1.5 shrink-0 rounded-full ${T}`,M;t[17]===j?M=t[18]:(M=(0,g.jsx)(`span`,{className:j,"aria-hidden":!0}),t[17]=j,t[18]=M);let N=x[+!r],P;t[19]===N?P=t[20]:(P=(0,g.jsx)(`span`,{className:`min-w-0 flex-1`,children:N}),t[19]=N,t[20]=P);let F;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,g.jsx)(a,{className:`size-3.5 shrink-0 text-fg-muted transition-transform group-open:rotate-180 motion-reduce:transition-none`,"aria-hidden":!0}),t[21]=F):F=t[21];let I;t[22]!==M||t[23]!==P||t[24]!==E?(I=(0,g.jsxs)(`summary`,{className:E,children:[M,P,F]}),t[22]=M,t[23]=P,t[24]=E,t[25]=I):I=t[25];let L;t[26]!==v||t[27]!==y||t[28]!==S.leave?(L=v===`note`?(0,g.jsx)(`p`,{children:y(`leave_${S.leave}`)}):null,t[26]=v,t[27]=y,t[28]=S.leave,t[29]=L):L=t[29];let R;t[30]!==f||t[31]!==y||t[32]!==x||t[33]!==S||t[34]!==r?(R=f?null:(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`p`,{children:x[r?2:3]}),S.leave===`local`?(0,g.jsx)(`p`,{children:y(`local_hint`)}):null,(0,g.jsx)(`ul`,{className:`flex flex-wrap gap-x-4 gap-y-1`,"aria-label":r?`已可用内容`:`Available content`,children:[`audio`,`text`,`note`].map(e=>(0,g.jsxs)(`li`,{children:[y(e),` · `,e===`note`&&S.note&&S.stale?y(`old_note`):y(S[e]?`available`:`pending`)]},e))})]}),t[30]=f,t[31]=y,t[32]=x,t[33]=S,t[34]=r,t[35]=R):R=t[35];let z;t[36]!==L||t[37]!==R?(z=(0,g.jsxs)(`div`,{className:`space-y-2 pb-3 text-xs leading-5 text-fg-muted`,children:[L,R]}),t[36]=L,t[37]=R,t[38]=z):z=t[38];let B;t[39]!==I||t[40]!==z||t[41]!==D||t[42]!==O?(B=(0,g.jsxs)(`details`,{className:D,children:[I,z]},O),t[39]=I,t[40]=z,t[41]=D,t[42]=O,t[43]=B):B=t[43];let V;t[44]!==_||t[45]!==c||t[46]!==y||t[47]!==b||t[48]!==S.retry?(V=S.retry!==`none`&&c?(0,g.jsx)(o,{className:`min-h-11`,disabled:_,onClick:()=>c(S.retry),children:y(b)}):null,t[44]=_,t[45]=c,t[46]=y,t[47]=b,t[48]=S.retry,t[49]=V):V=t[49];let H;return t[50]!==l||t[51]!==C||t[52]!==w||t[53]!==B||t[54]!==V||t[55]!==k||t[56]!==A?(H=(0,g.jsxs)(`section`,{"aria-live":k,"data-recording-outcome":A,className:C,children:[w,B,V,l]}),t[50]=l,t[51]=C,t[52]=w,t[53]=B,t[54]=V,t[55]=k,t[56]=A,t[57]=H):H=t[57],H}function y(){return r(n(`/api/discussion-capture/settings`))}function b(e){return r(n(`/api/discussion-capture/settings`),{method:`PUT`,body:JSON.stringify({consentPolicyVersion:e})})}async function x(e){return r(n(`/api/discussions`),{method:`POST`,body:JSON.stringify(e)})}function S(e){return r(n(`/api/discussions/${encodeURIComponent(e)}`))}async function C(e){try{return await r(n(`/api/discussions/by-note/${encodeURIComponent(e)}`))}catch(e){if(e.status===404)return null;throw e}}function w(e){return r(n(`/api/discussions/${encodeURIComponent(e)}/transcript`))}function T(e,t,i){let a=new FormData;return a.set(`file`,i.blob,`segment-${t}.wav`),a.set(`startedAtMs`,String(i.startedAtMs)),a.set(`endedAtMs`,String(i.endedAtMs)),a.set(`sha256`,i.sha256),r(n(`/api/discussions/${encodeURIComponent(e)}/segments/${t}`),{method:`PUT`,body:a})}function E(e,t=`resume`){return r(n(`/api/discussions/${encodeURIComponent(e)}/retry`),{method:`POST`,body:JSON.stringify({mode:t})})}function D(e){return r(n(`/api/discussions/${encodeURIComponent(e)}/project`),{method:`DELETE`})}function O(e){return r(n(`/api/discussions/${encodeURIComponent(e)}/recording/chunks`))}function k(e,t,i,a){return r(n(`/api/discussions/${encodeURIComponent(e)}/recording/chunks/${t}`),{method:`PUT`,headers:{"Content-Type":`application/octet-stream`,"x-audio-sha256":a},body:i})}function A(e,t){return r(n(`/api/discussions/${encodeURIComponent(e)}/capture/seal`),{method:`POST`,body:JSON.stringify(t)})}function j(e){return r(n(`/api/discussions/${encodeURIComponent(e)}/recording/job`))}var M=()=>window.dispatchEvent(new Event(`discussion-annotations-changed`));async function N(){return new Promise((e,t)=>{let n=indexedDB.open(`xopc-note-annotations`,1);n.onupgradeneeded=()=>{n.result.createObjectStore(`annotations`,{keyPath:[`recordingId`,`annotation.id`]}).createIndex(`recordingId`,`recordingId`)},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}async function P(e,t){let n=await N();try{return await new Promise((r,i)=>{let a=n.transaction(`annotations`,e?`readwrite`:`readonly`,{durability:`strict`}),o,s;a.oncomplete=()=>r(o),a.onabort=()=>i(s??a.error??Error(`Annotation save failed`)),a.onerror=()=>i(a.error);try{t(a.objectStore(`annotations`),e=>{o=e},e=>{s=e,a.abort()})}catch(e){a.abort(),i(e)}})}finally{n.close()}}async function F(e){return P(!1,(t,n)=>{let r=t.index(`recordingId`).getAll(e);r.onsuccess=()=>n(r.result)})}async function I(e,t,n){await P(!0,(r,i,a)=>{let o=r.get([e,t.id]);o.onsuccess=()=>{let s=o.result;if(n!==void 0&&(n===null?s&&s.state!==`synced`:s?.nonce!==n)){a(Error(`Annotation changed in another tab. Your editor content is retained; reload before saving.`));return}r.put({recordingId:e,annotation:t,nonce:crypto.randomUUID(),state:`pending`}),i()}}),M()}function L(e,t=`highlight`){let n=Date.now();return{id:crypto.randomUUID(),kind:t,text:``,anchor:e,revision:0,deleted:!1,createdAt:n,updatedAt:n}}async function R(e,t,n){await P(!0,(r,i)=>{let a=r.get([e,t]);a.onsuccess=()=>{let e=a.result;e&&e.annotation.anchor.offsetMs===void 0&&r.put({...e,nonce:crypto.randomUUID(),state:`pending`,annotation:{...e.annotation,anchor:{...e.annotation.anchor,offsetMs:n}}}),i()}}),M()}async function z(e,t,n=!1){await P(!0,(r,i)=>{let a=r.get([e.recordingId,e.annotation.id]);a.onsuccess=()=>{let o=a.result;o&&(o.nonce===e.nonce?r.put({...o,annotation:t??o.annotation,state:n?`conflict`:`synced`}):t&&o.annotation.revision===e.annotation.revision&&r.put({...o,annotation:{...o.annotation,revision:t.revision}})),i()}}),M()}var B=new Map;function V(e,t){let i=`${e}:${t}`;if(B.has(i))return B.get(i);let a=(async()=>{for(let i=0;i<5;i++){let i=(await F(e)).filter(e=>e.state===`pending`);if(!i.length)return;for(let e of i){if(e.state!==`pending`)continue;let i=e.annotation;try{await z(e,await r(n(`/api/discussions/${encodeURIComponent(t)}/annotations/${encodeURIComponent(i.id)}`),{method:`PUT`,signal:AbortSignal.timeout(15e3),body:JSON.stringify({id:i.id,kind:i.kind,text:i.text,anchor:i.anchor,expectedRevision:i.revision,deleted:i.deleted})}))}catch(t){throw t.status===409&&await z(e,void 0,!0),t}}}throw Error(`Highlights are still being updated. Saved local changes will sync on retry.`)})().finally(()=>B.delete(i));return B.set(i,a),a}export{f as C,s as E,d as S,c as T,D as _,R as a,v as b,x as c,C as d,w as f,A as g,E as h,L as i,S as l,j as m,z as n,I as o,O as p,F as r,b as s,V as t,y as u,T as v,l as w,_ as x,k as y};
|
|
1
|
+
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{i as n,o as r}from"./locale-store-VNjH18Dj.js";import{t as i}from"./createLucideIcon-DPHK1VkS.js";import{t as a}from"./chevron-down-ccbiQQz_.js";import{t as o}from"./button-CnRSIP6m.js";var s=i(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),c=i(`bookmark`,[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]),l=i(`lightbulb`,[[`path`,{d:`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`,key:`1gvzjb`}],[`path`,{d:`M9 18h6`,key:`x1upvd`}],[`path`,{d:`M10 22h4`,key:`ceow96`}]]);function u(e){let t=e.audioAvailable&&!e.audioDeleted,n=`sync_pending`,r=`none`;return e.audioDeleted?n=`audio_deleted`:e.localSave===`saving`?n=`local_saving`:e.localSave===`failed`?n=`save_failed`:e.localSave===`partial`?(n=`local_partial`,r=`recover`):t?e.serverStatus===`cancelled`?n=`cancelled`:e.serverStatus===`needs_attention`?(n=e.failureStage===`organization`?`analysis_failed`:`transcription_failed`,r=`pipeline`):e.serverStatus===`completed`?e.noteAvailable?e.analysisStale?(n=`analysis_stale`,r=`analyze`):n=`ready`:(n=`analysis_missing`,r=`regenerate`):n=e.serverStatus===`organizing`?e.retryScheduled?`analysis_retrying`:`organizing`:e.retryScheduled?`transcription_retrying`:`transcribing`:e.jobState===`failed`?(n=`verify_failed`,r=`pipeline`):e.jobState===`queued`||e.jobState===`running`||e.sync===`verifying`?n=`verifying`:e.sync===`offline`||e.sync===`failed`?(n=`sync_failed`,r=e.localSave===`complete`?`sync`:`none`):e.localSave!==`complete`&&e.serverStatus===`needs_attention`&&(n=`source_missing`),{stage:n,leave:e.localSave===`saving`?`hold`:t?`cloud`:e.localSave===`complete`?`local`:`hold`,retry:r,audio:t,text:e.textAvailable,note:e.noteAvailable,stale:e.analysisStale}}var d=`open-discussion-capture`;function f(e){window.dispatchEvent(new CustomEvent(d,{detail:e?{projectId:e}:{}}))}var p=e(),m={save_failed:[`录音未能保存`,`Recording could not be saved`,`尚未确认可恢复的原音。请检查麦克风权限和可用存储空间后重新录制。`,`No recoverable audio has been confirmed. Check microphone permission and available storage before recording again.`],cancelled:[`已停止整理`,`Processing stopped`,`已有原音、文字和笔记仍可使用。`,`Existing audio, text and notes remain available.`],local_saving:[`正在保存录音`,`Saving recording`,`请稍候,确认保存完成前请留在此页面。`,`Please stay on this page until saving is confirmed.`],local_partial:[`已保留部分录音`,`Part of the recording was retained`,`本次录音未完整保存。请先恢复或导出已保存部分,确认缺失范围。`,`This recording was not saved completely. Recover or export the saved portion and review the missing parts.`],sync_pending:[`正在同步原音`,`Syncing original audio`,`已完成的文字和笔记可先使用。原音确认可用后,会继续整理。`,`Available text and notes can be used now. Processing continues once the original audio is confirmed.`],sync_failed:[`原音同步未完成`,`Audio sync incomplete`,`已保存的内容仍保留在录制设备。连接网络后可重试同步,无需重新录音。`,`Saved content remains on the recording device. Reconnect and retry sync without recording again.`],verifying:[`原音已上传,正在确认`,`Confirming uploaded audio`,`上传完成后,还需确认原音可用。已有文字可以先查看。`,`Uploaded audio is being checked. Existing text can be read now.`],verify_failed:[`原音确认未完成`,`Audio confirmation incomplete`,`上传内容已保留,可重试确认原音。已有文字和笔记仍可使用。`,`Uploaded content is retained. Retry audio confirmation; existing text and notes remain available.`],transcribing:[`正在整理文字`,`Preparing transcript`,`原音已可回听,已完成的文字可先搜索和查看。文字完成后继续生成笔记。`,`Play the original audio and search available text now. Notes will follow the transcript.`],transcription_retrying:[`正在重试整理文字`,`Retrying transcription`,`原音和处理进度已保留,系统稍后自动重试。已有文字仍可使用。`,`Audio and progress are retained. An automatic retry is scheduled; existing text remains available.`],transcription_failed:[`文字整理未完成`,`Transcription incomplete`,`原音和已有文字均保留。重试会从已保存进度继续,无需重新录音。`,`Audio and existing text are retained. Retry from saved progress without recording again.`],organizing:[`正在生成笔记`,`Preparing notes`,`可以先回听原音、查找原话。笔记完成后可查看重点、结论和行动建议。`,`Play audio and find original statements now. Highlights, conclusions and suggested actions will follow.`],analysis_retrying:[`正在重试生成笔记`,`Retrying notes`,`原音、文字和已有笔记均保留,系统稍后自动重试。`,`Audio, text and existing notes are retained. An automatic retry is scheduled.`],analysis_failed:[`笔记生成未完成`,`Notes incomplete`,`原音、文字和已有笔记均保留。重试只继续整理,不会重新录音或创建重复笔记。`,`Audio, text and existing notes are retained. Retry continues processing without recording again or creating another note.`],ready:[`录音与笔记已就绪`,`Recording and notes are ready`,`现在可以回听原音、查找原话,并回顾重要信息。`,`Play the audio, find original statements and review important information.`],analysis_missing:[`暂未生成笔记`,`Notes are not available yet`,`原音和已有文字仍可使用,可以从原音重新生成文字与笔记。`,`Audio and existing text remain available. Regenerate text and notes from the original audio.`],analysis_stale:[`原文已更新`,`Transcript updated`,`当前笔记基于修改前的原文,可保留查看,也可按新版原文重新整理。`,`Existing notes use an earlier transcript. Keep them or generate notes from the updated text.`],source_missing:[`原音尚不可用`,`Original audio is not available yet`,`请到录制设备的待恢复录音中继续同步。已有文字和笔记仍可查看。`,`Continue sync from recoverable recordings on the recording device. Existing text and notes remain readable.`],audio_deleted:[`原音已删除`,`Original audio was deleted`,`已有文字和笔记仍可查看;重新生成需要重新导入原音。`,`Existing text and notes remain readable. Import the original audio again to regenerate.`]},h={leave_local:[`录音已在本机保存,可以离开当前页面。`,`Recording saved on this device. You can leave this page.`],leave_cloud:[`原音已同步,可以离开当前页面。`,`Original audio synced. You can leave this page.`],leave_hold:[`请先确认保存结果,再离开当前页面。`,`Confirm the recording is saved before leaving this page.`],local_hint:[`关闭应用后,可在待恢复录音中继续同步。请保留本机录音数据。`,`After closing the app, continue sync from recoverable recordings. Keep the recording data on this device.`],cloud_hint:[`后续转写与笔记整理在后台继续;失败时可在这条笔记中重试。`,`Transcription and notes continue on the server. Retry here if processing fails.`],retry_sync:[`重试同步`,`Retry sync`],retry_pipeline:[`继续处理`,`Resume processing`],retry_analysis_failed:[`重试生成笔记`,`Retry notes`],retry_transcription_failed:[`继续整理文字`,`Resume transcription`],retry_verify_failed:[`重试确认原音`,`Retry audio confirmation`],retry_recover:[`恢复已录内容`,`Recover saved audio`],retry_regenerate:[`从原音重新生成`,`Regenerate from audio`],retry_analyze:[`按新版原文整理`,`Update notes from transcript`],audio:[`原音`,`Audio`],text:[`文字`,`Transcript`],note:[`笔记`,`Notes`],available:[`可用`,`Available`],pending:[`尚未完成`,`Not ready`],old_note:[`旧版可用`,`Earlier version available`],open:[`打开笔记`,`Open note`],recover:[`待恢复录音`,`Recoverable recordings`],export:[`导出已录内容`,`Export saved audio`],close:[`稍后查看`,`View later`],annotation_failed:[`重点同步未完成,原音和笔记处理不受影响。`,`Highlights are not synced yet. Audio and note processing are unaffected.`],retry_annotation:[`重试重点同步`,`Retry highlights`]},g=t();function _(e,t=`unknown`,n=`pending`){return{localSave:t,sync:n,serverStatus:e?.discussion.status??``,failureStage:e?.discussion.failureStage??``,jobState:e?.recordingJob?.state??``,retryScheduled:!!e?.processing?.nextAttemptAt,audioAvailable:!!e?.discussion.audioAttachmentId,audioDeleted:!!e?.discussion.audioDeletedAt,textAvailable:!!e?.transcript?.text?.trim()||!!e?.discussion.canonicalTranscript?.trim(),noteAvailable:!!e?.organization?.organization,analysisStale:!!e?.organization&&e.organization.transcriptRevision!==e.transcript?.revision}}function v(e){let t=(0,p.c)(58),{input:n,zh:r,compact:i,busy:s,onRetry:c,children:l,context:d}=e,f=i!==void 0&&i,_=s!==void 0&&s,v=d===void 0?`capture`:d,y,b,x,S,C,w,T,E,D,O,k,A;if(t[0]!==v||t[1]!==n||t[2]!==r){S=u(n),x=m[S.stage];let e;t[15]===r?e=t[16]:(e=e=>h[e][+!r],t[15]=r,t[16]=e),y=e,b=`retry_${[`analysis_failed`,`transcription_failed`,`verify_failed`].includes(S.stage)?S.stage:S.retry}`,k=`polite`,A=S.stage,C=v===`note`?`text-fg`:`rounded-xl bg-surface-inset p-3 text-fg`,w=v===`capture`?(0,g.jsx)(`p`,{className:`mb-1 text-sm font-medium`,children:y(`leave_${S.leave}`)}):null,D=`group`,O=v,E=`flex min-h-11 cursor-pointer list-none items-center gap-2 rounded-lg text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent [&::-webkit-details-marker]:hidden`,T=S.stage.endsWith(`_failed`)||S.stage===`local_partial`?`bg-danger`:`bg-accent`,t[0]=v,t[1]=n,t[2]=r,t[3]=y,t[4]=b,t[5]=x,t[6]=S,t[7]=C,t[8]=w,t[9]=T,t[10]=E,t[11]=D,t[12]=O,t[13]=k,t[14]=A}else y=t[3],b=t[4],x=t[5],S=t[6],C=t[7],w=t[8],T=t[9],E=t[10],D=t[11],O=t[12],k=t[13],A=t[14];let j=`size-1.5 shrink-0 rounded-full ${T}`,M;t[17]===j?M=t[18]:(M=(0,g.jsx)(`span`,{className:j,"aria-hidden":!0}),t[17]=j,t[18]=M);let N=x[+!r],P;t[19]===N?P=t[20]:(P=(0,g.jsx)(`span`,{className:`min-w-0 flex-1`,children:N}),t[19]=N,t[20]=P);let F;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,g.jsx)(a,{className:`size-3.5 shrink-0 text-fg-muted transition-transform group-open:rotate-180 motion-reduce:transition-none`,"aria-hidden":!0}),t[21]=F):F=t[21];let I;t[22]!==M||t[23]!==P||t[24]!==E?(I=(0,g.jsxs)(`summary`,{className:E,children:[M,P,F]}),t[22]=M,t[23]=P,t[24]=E,t[25]=I):I=t[25];let L;t[26]!==v||t[27]!==y||t[28]!==S.leave?(L=v===`note`?(0,g.jsx)(`p`,{children:y(`leave_${S.leave}`)}):null,t[26]=v,t[27]=y,t[28]=S.leave,t[29]=L):L=t[29];let R;t[30]!==f||t[31]!==y||t[32]!==x||t[33]!==S||t[34]!==r?(R=f?null:(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`p`,{children:x[r?2:3]}),S.leave===`local`?(0,g.jsx)(`p`,{children:y(`local_hint`)}):null,(0,g.jsx)(`ul`,{className:`flex flex-wrap gap-x-4 gap-y-1`,"aria-label":r?`已可用内容`:`Available content`,children:[`audio`,`text`,`note`].map(e=>(0,g.jsxs)(`li`,{children:[y(e),` · `,e===`note`&&S.note&&S.stale?y(`old_note`):y(S[e]?`available`:`pending`)]},e))})]}),t[30]=f,t[31]=y,t[32]=x,t[33]=S,t[34]=r,t[35]=R):R=t[35];let z;t[36]!==L||t[37]!==R?(z=(0,g.jsxs)(`div`,{className:`space-y-2 pb-3 text-xs leading-5 text-fg-muted`,children:[L,R]}),t[36]=L,t[37]=R,t[38]=z):z=t[38];let B;t[39]!==I||t[40]!==z||t[41]!==D||t[42]!==O?(B=(0,g.jsxs)(`details`,{className:D,children:[I,z]},O),t[39]=I,t[40]=z,t[41]=D,t[42]=O,t[43]=B):B=t[43];let V;t[44]!==_||t[45]!==c||t[46]!==y||t[47]!==b||t[48]!==S.retry?(V=S.retry!==`none`&&c?(0,g.jsx)(o,{className:`min-h-11`,disabled:_,onClick:()=>c(S.retry),children:y(b)}):null,t[44]=_,t[45]=c,t[46]=y,t[47]=b,t[48]=S.retry,t[49]=V):V=t[49];let H;return t[50]!==l||t[51]!==C||t[52]!==w||t[53]!==B||t[54]!==V||t[55]!==k||t[56]!==A?(H=(0,g.jsxs)(`section`,{"aria-live":k,"data-recording-outcome":A,className:C,children:[w,B,V,l]}),t[50]=l,t[51]=C,t[52]=w,t[53]=B,t[54]=V,t[55]=k,t[56]=A,t[57]=H):H=t[57],H}function y(){return r(n(`/api/discussion-capture/settings`))}function b(e){return r(n(`/api/discussion-capture/settings`),{method:`PUT`,body:JSON.stringify({consentPolicyVersion:e})})}async function x(e){return r(n(`/api/discussions`),{method:`POST`,body:JSON.stringify(e)})}function S(e){return r(n(`/api/discussions/${encodeURIComponent(e)}`))}async function C(e){try{return await r(n(`/api/discussions/by-note/${encodeURIComponent(e)}`))}catch(e){if(e.status===404)return null;throw e}}function w(e){return r(n(`/api/discussions/${encodeURIComponent(e)}/transcript`))}function T(e,t,i){let a=new FormData;return a.set(`file`,i.blob,`segment-${t}.wav`),a.set(`startedAtMs`,String(i.startedAtMs)),a.set(`endedAtMs`,String(i.endedAtMs)),a.set(`sha256`,i.sha256),r(n(`/api/discussions/${encodeURIComponent(e)}/segments/${t}`),{method:`PUT`,body:a})}function E(e,t=`resume`){return r(n(`/api/discussions/${encodeURIComponent(e)}/retry`),{method:`POST`,body:JSON.stringify({mode:t})})}function D(e){return r(n(`/api/discussions/${encodeURIComponent(e)}/project`),{method:`DELETE`})}function O(e){return r(n(`/api/discussions/${encodeURIComponent(e)}/recording/chunks`))}function k(e,t,i,a){return r(n(`/api/discussions/${encodeURIComponent(e)}/recording/chunks/${t}`),{method:`PUT`,headers:{"Content-Type":`application/octet-stream`,"x-audio-sha256":a},body:i})}function A(e,t){return r(n(`/api/discussions/${encodeURIComponent(e)}/capture/seal`),{method:`POST`,body:JSON.stringify(t)})}function j(e){return r(n(`/api/discussions/${encodeURIComponent(e)}/recording/job`))}var M=()=>window.dispatchEvent(new Event(`discussion-annotations-changed`));async function N(){return new Promise((e,t)=>{let n=indexedDB.open(`xopc-note-annotations`,1);n.onupgradeneeded=()=>{n.result.createObjectStore(`annotations`,{keyPath:[`recordingId`,`annotation.id`]}).createIndex(`recordingId`,`recordingId`)},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}async function P(e,t){let n=await N();try{return await new Promise((r,i)=>{let a=n.transaction(`annotations`,e?`readwrite`:`readonly`,{durability:`strict`}),o,s;a.oncomplete=()=>r(o),a.onabort=()=>i(s??a.error??Error(`Annotation save failed`)),a.onerror=()=>i(a.error);try{t(a.objectStore(`annotations`),e=>{o=e},e=>{s=e,a.abort()})}catch(e){a.abort(),i(e)}})}finally{n.close()}}async function F(e){return P(!1,(t,n)=>{let r=t.index(`recordingId`).getAll(e);r.onsuccess=()=>n(r.result)})}async function I(e,t,n){await P(!0,(r,i,a)=>{let o=r.get([e,t.id]);o.onsuccess=()=>{let s=o.result;if(n!==void 0&&(n===null?s&&s.state!==`synced`:s?.nonce!==n)){a(Error(`Annotation changed in another tab. Your editor content is retained; reload before saving.`));return}r.put({recordingId:e,annotation:t,nonce:crypto.randomUUID(),state:`pending`}),i()}}),M()}function L(e,t=`highlight`){let n=Date.now();return{id:crypto.randomUUID(),kind:t,text:``,anchor:e,revision:0,deleted:!1,createdAt:n,updatedAt:n}}async function R(e,t,n){await P(!0,(r,i)=>{let a=r.get([e,t]);a.onsuccess=()=>{let e=a.result;e&&e.annotation.anchor.offsetMs===void 0&&r.put({...e,nonce:crypto.randomUUID(),state:`pending`,annotation:{...e.annotation,anchor:{...e.annotation.anchor,offsetMs:n}}}),i()}}),M()}async function z(e,t,n=!1){await P(!0,(r,i)=>{let a=r.get([e.recordingId,e.annotation.id]);a.onsuccess=()=>{let o=a.result;o&&(o.nonce===e.nonce?r.put({...o,annotation:t??o.annotation,state:n?`conflict`:`synced`}):t&&o.annotation.revision===e.annotation.revision&&r.put({...o,annotation:{...o.annotation,revision:t.revision}})),i()}}),M()}var B=new Map;function V(e,t){let i=`${e}:${t}`;if(B.has(i))return B.get(i);let a=(async()=>{for(let i=0;i<5;i++){let i=(await F(e)).filter(e=>e.state===`pending`);if(!i.length)return;for(let e of i){if(e.state!==`pending`)continue;let i=e.annotation;try{await z(e,await r(n(`/api/discussions/${encodeURIComponent(t)}/annotations/${encodeURIComponent(i.id)}`),{method:`PUT`,signal:AbortSignal.timeout(15e3),body:JSON.stringify({id:i.id,kind:i.kind,text:i.text,anchor:i.anchor,expectedRevision:i.revision,deleted:i.deleted})}))}catch(t){throw t.status===409&&await z(e,void 0,!0),t}}}throw Error(`Highlights are still being updated. Saved local changes will sync on retry.`)})().finally(()=>B.delete(i));return B.set(i,a),a}export{f as C,s as E,d as S,c as T,D as _,R as a,v as b,x as c,C as d,w as f,A as g,E as h,L as i,S as l,j as m,z as n,I as o,O as p,F as r,b as s,V as t,y as u,T as v,l as w,_ as x,k as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime-aKtaBQYM.js";import{a as e,n as t,t as n}from"./vendor-react-BOUWij0V.js";import{n as r}from"./locale-store-
|
|
1
|
+
import"./rolldown-runtime-aKtaBQYM.js";import{a as e,n as t,t as n}from"./vendor-react-BOUWij0V.js";import{n as r}from"./locale-store-VNjH18Dj.js";import{t as i}from"./messages-Btr7C0hF.js";import{r as a}from"./extension-provider-B2Mf3FBu.js";import{n as o,t as s}from"./settings-page-header-CsPAYlqV.js";import"./settings-page-layout-lPLeJQoV.js";var c=t();e();var l=n();function u(){let e=(0,c.c)(40),t=r(p),n;e[0]===t?n=e[1]:(n=i(t),e[0]=t,e[1]=n);let u=n.extensionDebug,m=a(),h;e[2]===m?h=e[3]:(h=m.toSorted(f),e[2]=m,e[3]=h);let g=h,_;e[4]!==u.subtitle||e[5]!==u.title?(_=(0,l.jsx)(s,{title:u.title,subtitle:u.subtitle}),e[4]=u.subtitle,e[5]=u.title,e[6]=_):_=e[6];let v;e[7]===u.listHeading?v=e[8]:(v=(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:u.listHeading}),e[7]=u.listHeading,e[8]=v);let y;e[9]===u.colId?y=e[10]:(y=(0,l.jsx)(`th`,{className:`px-3 py-2`,children:u.colId}),e[9]=u.colId,e[10]=y);let b;e[11]===u.colName?b=e[12]:(b=(0,l.jsx)(`th`,{className:`px-3 py-2`,children:u.colName}),e[11]=u.colName,e[12]=b);let x;e[13]===u.colPermissions?x=e[14]:(x=(0,l.jsx)(`th`,{className:`px-3 py-2`,children:u.colPermissions}),e[13]=u.colPermissions,e[14]=x);let S;e[15]!==y||e[16]!==b||e[17]!==x?(S=(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{className:`text-xs uppercase text-fg-muted`,children:[y,b,x]})}),e[15]=y,e[16]=b,e[17]=x,e[18]=S):S=e[18];let C;e[19]===g?C=e[20]:(C=g.map(d),e[19]=g,e[20]=C);let w;e[21]===C?w=e[22]:(w=(0,l.jsx)(`tbody`,{children:C}),e[21]=C,e[22]=w);let T;e[23]!==S||e[24]!==w?(T=(0,l.jsx)(`div`,{className:`mt-3 overflow-x-auto`,children:(0,l.jsxs)(`table`,{className:`w-full min-w-[32rem] border-separate border-spacing-y-1 text-left text-sm`,children:[S,w]})}),e[23]=S,e[24]=w,e[25]=T):T=e[25];let E;e[26]!==T||e[27]!==v?(E=(0,l.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4`,children:[v,T]}),e[26]=T,e[27]=v,e[28]=E):E=e[28];let D;e[29]===u.futureHeading?D=e[30]:(D=(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:u.futureHeading}),e[29]=u.futureHeading,e[30]=D);let O;e[31]===u.futureBody?O=e[32]:(O=(0,l.jsx)(`p`,{className:`mt-2`,children:u.futureBody}),e[31]=u.futureBody,e[32]=O);let k;e[33]!==D||e[34]!==O?(k=(0,l.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4 text-sm text-fg-muted`,children:[D,O]}),e[33]=D,e[34]=O,e[35]=k):k=e[35];let A;return e[36]!==E||e[37]!==k||e[38]!==_?(A=(0,l.jsxs)(o,{gap:`gap-5`,children:[_,E,k]}),e[36]=E,e[37]=k,e[38]=_,e[39]=A):A=e[39],A}function d(e){return(0,l.jsxs)(`tr`,{className:`bg-surface-base/55`,children:[(0,l.jsx)(`td`,{className:`rounded-l-lg px-3 py-2 font-mono text-xs text-fg`,children:e.id}),(0,l.jsx)(`td`,{className:`px-3 py-2 text-fg`,children:e.name}),(0,l.jsx)(`td`,{className:`rounded-r-lg px-3 py-2 font-mono text-xs text-fg-muted`,children:(e.ui?.permissions??[]).join(`, `)||`—`})]},e.id)}function f(e,t){return e.id.localeCompare(t.id)}function p(e){return e.language}export{u as ExtensionDebugPage};
|
|
@@ -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{i,l as a,n as ee,o}from"./locale-store-5Hf8J8-_.js";import{t as te}from"./messages-uXxg5p54.js";import{a as s,n as c,o as l,r as ne,s as re,t as u}from"./dist-DfWfZ9iu.js";import{c as d,n as f}from"./extension-provider-BA0Y2Rvs.js";import{i as p}from"./theme-store-DOJ9tu-j.js";import{r as m}from"./settings-form-draft-Dy10ldo8.js";var h=e(t(),1),ie=n();function g(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function _(e,t){let n=g(t);return i(`/api/extensions/${encodeURIComponent(e)}/assets/${n}`)}var v={"capability:xopc.notes.create":`Create notes in this workspace`,"capability:xopc.notes.update":`Change notes in this workspace at an exact revision`,"capability:xopc.notes.append":`Append content to notes in this workspace`,"capability:xopc.notes.get":`Read notes in this workspace by ID`,"capability:xopc.notes.list":`Search and list notes in this workspace`,"capability:xopc.tasks.get":`Read tasks and their context in this workspace`,"capability:xopc.tasks.list":`Search and list tasks in this workspace`,theme:`Read theme (light / dark)`,"agent.send":`Send messages to the assistant`,"agent.subscribe":`Receive live agent stream events for a chat`,"session.read":`List and open chat sessions`,"config.read":`Read plugin configuration`,"config.write":`Write plugin configuration`,storage:`Read and write plugin storage`,notification:`Show in-app notifications`},y={"capability:xopc.notes.create":`在当前工作区创建笔记`,"capability:xopc.notes.update":`按精确版本修改当前工作区的笔记`,"capability:xopc.notes.append":`向当前工作区的笔记追加内容`,"capability:xopc.notes.get":`按 ID 读取当前工作区的笔记`,"capability:xopc.notes.list":`搜索和列出当前工作区的笔记`,"capability:xopc.tasks.get":`读取当前工作区的任务及其上下文`,"capability:xopc.tasks.list":`搜索和列出当前工作区的任务`,theme:`读取主题(浅色/深色)`,"agent.send":`向助手发送消息`,"agent.subscribe":`接收会话的实时助手流式事件`,"session.read":`列出并打开聊天会话`,"config.read":`读取插件配置`,"config.write":`写入插件配置`,storage:`读写插件存储`,notification:`显示应用内通知`};function b(e,t){let n=v[e];return t===`zh`&&y[e]?y[e]:n??e}var x=r();function S(e){let t=(0,ie.c)(59),{open:n,onOpenChange:r,extensionId:i,extensionName:a,permissions:o,onConfirm:d,confirmDisabled:f}=e,p=ee(w),m,h,g,_,v,y,S,T,E,D,O,k;t[0]!==a||t[1]!==p||t[2]!==r||t[3]!==n?(v=te(p).extensionUi,_=u,O=n,k=r,g=l,t[16]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,x.jsx)(s,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[16]=D):D=t[16],h=ne,T=`xopc-dialog-content fixed left-1/2 top-1/2 z-[131] w-[min(28rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-5`,E=C,m=re,y=`text-base font-semibold text-fg`,S=v.permissionTitle.replace(`{{name}}`,a),t[0]=a,t[1]=p,t[2]=r,t[3]=n,t[4]=m,t[5]=h,t[6]=g,t[7]=_,t[8]=v,t[9]=y,t[10]=S,t[11]=T,t[12]=E,t[13]=D,t[14]=O,t[15]=k):(m=t[4],h=t[5],g=t[6],_=t[7],v=t[8],y=t[9],S=t[10],T=t[11],E=t[12],D=t[13],O=t[14],k=t[15]);let A;t[17]!==m||t[18]!==y||t[19]!==S?(A=(0,x.jsx)(m,{className:y,children:S}),t[17]=m,t[18]=y,t[19]=S,t[20]=A):A=t[20];let j;t[21]===i?j=t[22]:(j=(0,x.jsxs)(`span`,{className:`font-mono text-xs text-fg-muted`,title:i,children:[`(`,i,`)`]}),t[21]=i,t[22]=j);let M;t[23]!==v.permissionSubtitle||t[24]!==j?(M=(0,x.jsxs)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:[v.permissionSubtitle,` `,j]}),t[23]=v.permissionSubtitle,t[24]=j,t[25]=M):M=t[25];let N;t[26]!==p||t[27]!==o||t[28]!==v.permissionsNone?(N=o.length===0?(0,x.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:v.permissionsNone}):(0,x.jsx)(`ul`,{className:`mt-4 max-h-48 list-inside list-disc space-y-1 overflow-y-auto text-sm text-fg`,children:o.map(e=>(0,x.jsx)(`li`,{children:b(e,p)},e))}),t[26]=p,t[27]=o,t[28]=v.permissionsNone,t[29]=N):N=t[29];let P;t[30]===v.deny?P=t[31]:(P=(0,x.jsx)(c,{asChild:!0,children:(0,x.jsx)(`button`,{type:`button`,className:`rounded-lg border border-edge px-3 py-2 text-sm text-fg hover:bg-surface-inset`,children:v.deny})}),t[30]=v.deny,t[31]=P);let F;t[32]!==d||t[33]!==r?(F=()=>{d(),r(!1)},t[32]=d,t[33]=r,t[34]=F):F=t[34];let I;t[35]!==f||t[36]!==v.allow||t[37]!==F?(I=(0,x.jsx)(`button`,{type:`button`,disabled:f,className:`rounded-lg bg-accent px-3 py-2 text-sm font-medium text-on-accent hover:opacity-90`,onClick:F,children:v.allow}),t[35]=f,t[36]=v.allow,t[37]=F,t[38]=I):I=t[38];let L;t[39]!==P||t[40]!==I?(L=(0,x.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[P,I]}),t[39]=P,t[40]=I,t[41]=L):L=t[41];let R;t[42]!==h||t[43]!==M||t[44]!==N||t[45]!==L||t[46]!==T||t[47]!==E||t[48]!==A?(R=(0,x.jsxs)(h,{className:T,onOpenAutoFocus:E,children:[A,M,N,L]}),t[42]=h,t[43]=M,t[44]=N,t[45]=L,t[46]=T,t[47]=E,t[48]=A,t[49]=R):R=t[49];let z;t[50]!==g||t[51]!==R||t[52]!==D?(z=(0,x.jsxs)(g,{children:[D,R]}),t[50]=g,t[51]=R,t[52]=D,t[53]=z):z=t[53];let B;return t[54]!==_||t[55]!==z||t[56]!==O||t[57]!==k?(B=(0,x.jsx)(_,{open:O,onOpenChange:k,children:z}),t[54]=_,t[55]=z,t[56]=O,t[57]=k,t[58]=B):B=t[58],B}function C(e){return e.preventDefault()}function w(e){return e.language}async function T(e){let{grant:t}=await o(i(`/api/extensions/${encodeURIComponent(e)}/ui-grant`));return t}async function E(e,t){return(await o(i(`/api/extensions/${encodeURIComponent(e)}/ui-grant`),{method:`POST`,body:JSON.stringify({manifestDigest:t})})).grant}var D=48,O=2e3,k=`allow-scripts allow-forms allow-popups`;function A(e){let t=(0,ie.c)(98),{extensionId:n,extensionName:r,entrypoint:i,permissions:o,title:s,className:c,fixedHeight:l,maxHeight:ne,minHeight:re,initialData:u}=e,g=ne===void 0?O:ne,v=re===void 0?D:re,y=ee(P),b;t[0]===y?b=t[1]:(b=te(y),t[0]=y,t[1]=b);let C=b.extensionUi,w=f(),A=a(N),F=a(M),I=(0,h.useRef)(0),L=(0,h.useRef)(!1),R=(0,h.useRef)(null),z=p(j),B;t[2]!==n||t[3]!==r?(B=r?.trim()||n,t[2]=n,t[3]=r,t[4]=B):B=t[4];let ae=B,oe;t[5]!==n||t[6]!==s?(oe=s?.trim()||`Extension ${n}`,t[5]=n,t[6]=s,t[7]=oe):oe=t[7];let se=oe,V;t[8]===o?V=t[9]:(V=JSON.stringify(Array.from(o??[]).toSorted()),t[8]=o,t[9]=V);let ce=V,H;t[10]===ce?H=t[11]:(H=JSON.parse(ce),t[10]=ce,t[11]=H);let le=H,ue=l??Math.min(g,Math.max(v,320)),U;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(U=[],t[12]=U):U=t[12];let W;t[13]===ue?W=t[14]:(W={allowed:!1,dialogOpen:!1,reloadKey:0,loadError:!1,dynamicHeight:ue,grantResolved:!1,grantError:null,manifestDigest:null,grantedPermissions:U},t[13]=ue,t[14]=W);let[G,K]=(0,h.useReducer)(m,W),{allowed:q,dialogOpen:J,reloadKey:Y,loadError:de,dynamicHeight:fe,grantResolved:pe,grantError:X}=G,me;t[15]===n?me=t[16]:(me=()=>{let e=!0;return L.current=!1,K({type:`patch`,patch:{allowed:!1,dialogOpen:!1,grantResolved:!1,grantError:null,manifestDigest:null,grantedPermissions:[]}}),T(n).then(t=>{if(e){if(t.extensionId!==n||!t.manifestDigest)throw Error(`Could not verify plugin permissions`);K({type:`patch`,patch:{allowed:t.granted,dialogOpen:!t.granted,grantResolved:!0,manifestDigest:t.manifestDigest,grantedPermissions:t.permissions}})}}).catch(t=>{e&&K({type:`patch`,patch:{allowed:!1,dialogOpen:!0,grantResolved:!0,grantError:t instanceof Error?t.message:String(t)}})}),()=>{e=!1,I.current+=1}},t[15]=n,t[16]=me);let he;t[17]!==n||t[18]!==A||t[19]!==F||t[20]!==le||t[21]!==Y?(he=[n,le,A,F,Y],t[17]=n,t[18]=A,t[19]=F,t[20]=le,t[21]=Y,t[22]=he):he=t[22],(0,h.useEffect)(me,he);let ge;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(ge=e=>K({type:`patch`,patch:{dialogOpen:e}}),t[23]=ge):ge=t[23];let _e=ge,ve;t[24]!==i||t[25]!==n?(ve=_(n,i),t[24]=i,t[25]=n,t[26]=ve):ve=t[26];let ye=ve,be;t[27]!==q||t[28]!==n||t[29]!==l||t[30]!==g||t[31]!==v||t[32]!==w||t[33]!==G.grantedPermissions||t[34]!==G.manifestDigest?(be=()=>{if(!q)return;let e=R.current;if(!e)return;w.registerIframe(n,e,G.grantedPermissions,G.manifestDigest??void 0);let t=w.subscribeExtensionEvents(n,e=>{if(e.event!==`ui.resize`||!e.data||typeof e.data!=`object`||e.data===null)return;let t=Number(e.data.height);Number.isFinite(t)&&l===void 0&&K({type:`patch`,patch:{dynamicHeight:Math.min(g,Math.max(v,t))}})});return()=>{t(),w.unregisterIframe(n)}},t[27]=q,t[28]=n,t[29]=l,t[30]=g,t[31]=v,t[32]=w,t[33]=G.grantedPermissions,t[34]=G.manifestDigest,t[35]=be):be=t[35];let xe;t[36]!==q||t[37]!==n||t[38]!==l||t[39]!==g||t[40]!==v||t[41]!==Y||t[42]!==w||t[43]!==G.grantedPermissions||t[44]!==G.manifestDigest?(xe=[q,n,l,g,v,G.grantedPermissions,G.manifestDigest,w,Y],t[36]=q,t[37]=n,t[38]=l,t[39]=g,t[40]=v,t[41]=Y,t[42]=w,t[43]=G.grantedPermissions,t[44]=G.manifestDigest,t[45]=xe):xe=t[45],(0,h.useLayoutEffect)(be,xe);let Se,Ce;t[46]!==q||t[47]!==n||t[48]!==z||t[49]!==w?(Se=()=>{if(!q)return;let e=d(z);w.sendEvent(n,`theme.changed`,e)},Ce=[q,n,z,w],t[46]=q,t[47]=n,t[48]=z,t[49]=w,t[50]=Se,t[51]=Ce):(Se=t[50],Ce=t[51]),(0,h.useEffect)(Se,Ce);let we;t[52]!==fe||t[53]!==l?(we=l===void 0?{width:`100%`,height:fe,border:`none`}:{width:`100%`,height:l,border:`none`},t[52]=fe,t[53]=l,t[54]=we):we=t[54];let Te=we,Ee;t[55]!==n||t[56]!==A||t[57]!==F||t[58]!==G.manifestDigest?(Ee=()=>{if(L.current||!G.manifestDigest)return;L.current=!0;let e=I.current,t=()=>I.current===e&&a.getState().baseUrl===A&&a.getState().conversationId===F;E(n,G.manifestDigest).then(e=>{if(t()){if(!e.granted||e.extensionId!==n||e.manifestDigest!==G.manifestDigest)throw Error(`Permission grant was not persisted`);K({type:`patch`,patch:{allowed:!0,grantError:null}})}}).catch(e=>{t()&&K({type:`patch`,patch:{allowed:!1,manifestDigest:null,grantError:e instanceof Error?e.message:String(e)}})}).finally(()=>{t()&&(L.current=!1)})},t[55]=n,t[56]=A,t[57]=F,t[58]=G.manifestDigest,t[59]=Ee):Ee=t[59];let De=Ee;if(!pe){let e=`${c??``} min-h-32 animate-pulse rounded-lg bg-surface-inset`,n;return t[60]===e?n=t[61]:(n=(0,x.jsx)(`div`,{className:e}),t[60]=e,t[61]=n),n}if(!q){let e=!G.manifestDigest,r;t[62]!==J||t[63]!==ae||t[64]!==n||t[65]!==De||t[66]!==e||t[67]!==G.grantedPermissions?(r=(0,x.jsx)(S,{open:J,onOpenChange:_e,extensionId:n,extensionName:ae,permissions:G.grantedPermissions,confirmDisabled:e,onConfirm:De}),t[62]=J,t[63]=ae,t[64]=n,t[65]=De,t[66]=e,t[67]=G.grantedPermissions,t[68]=r):r=t[68];let i;t[69]!==c||t[70]!==J||t[71]!==X||t[72]!==Y||t[73]!==C?(i=J?null:(0,x.jsxs)(`div`,{className:c?`${c} rounded-lg border border-edge border-dashed bg-surface-base p-4 text-sm text-fg-muted`:`rounded-lg border border-edge border-dashed bg-surface-base p-4 text-sm text-fg-muted`,children:[X?(0,x.jsx)(`p`,{className:`mb-2 text-danger`,children:X}):null,(0,x.jsx)(`p`,{children:C.deniedHint}),(0,x.jsx)(`button`,{type:`button`,className:`mt-2 text-sm font-medium text-accent underline-offset-2 hover:underline`,onClick:()=>K({type:`patch`,patch:{reloadKey:Y+1}}),children:C.reviewPermissions})]}),t[69]=c,t[70]=J,t[71]=X,t[72]=Y,t[73]=C,t[74]=i):i=t[74];let a;return t[75]!==r||t[76]!==i?(a=(0,x.jsxs)(x.Fragment,{children:[r,i]}),t[75]=r,t[76]=i,t[77]=a):a=t[77],a}let Z;t[78]!==de||t[79]!==Y||t[80]!==C?(Z=de?(0,x.jsxs)(`div`,{className:`mb-2 rounded-lg border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-sm text-fg`,children:[(0,x.jsx)(`p`,{children:C.loadFailed}),(0,x.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:C.loadFailedConnectionHint}),(0,x.jsx)(`button`,{type:`button`,className:`mt-2 font-medium text-accent underline-offset-2 hover:underline`,onClick:()=>{K({type:`patch`,patch:{loadError:!1,reloadKey:Y+1}})},children:C.retryLoad})]}):null,t[78]=de,t[79]=Y,t[80]=C,t[81]=Z):Z=t[81];let Oe=`${n}-${i}-${Y}`,ke;t[82]===Symbol.for(`react.memo_cache_sentinel`)?(ke=()=>K({type:`patch`,patch:{loadError:!0}}),t[82]=ke):ke=t[82];let Q;t[83]!==n||t[84]!==u||t[85]!==y||t[86]!==w?(Q=()=>{K({type:`patch`,patch:{loadError:!1}}),w.sendInit(n,d(p.getState().resolved),y),u!==void 0&&w.sendEvent(n,`widget.data`,u)},t[83]=n,t[84]=u,t[85]=y,t[86]=w,t[87]=Q):Q=t[87];let $;t[88]!==c||t[89]!==se||t[90]!==ye||t[91]!==Te||t[92]!==Oe||t[93]!==Q?($=(0,x.jsx)(`iframe`,{ref:R,className:c,title:se,src:ye,style:Te,sandbox:k,referrerPolicy:`no-referrer`,onError:ke,onLoad:Q},Oe),t[88]=c,t[89]=se,t[90]=ye,t[91]=Te,t[92]=Oe,t[93]=Q,t[94]=$):$=t[94];let Ae;return t[95]!==Z||t[96]!==$?(Ae=(0,x.jsxs)(`div`,{className:`flex flex-1 min-h-0 min-w-0 flex-col`,children:[Z,$]}),t[95]=Z,t[96]=$,t[97]=Ae):Ae=t[97],Ae}function j(e){return e.resolved}function M(e){return e.conversationId}function N(e){return e.baseUrl}function P(e){return e.language}export{A as t};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{i,l as a,n as ee,o}from"./locale-store-VNjH18Dj.js";import{t as te}from"./messages-Btr7C0hF.js";import{a as s,n as c,o as l,r as ne,s as re,t as u}from"./dist-DfWfZ9iu.js";import{c as d,n as f}from"./extension-provider-B2Mf3FBu.js";import{i as p}from"./theme-store-DbStcH89.js";import{r as m}from"./settings-form-draft-Dy10ldo8.js";var h=e(t(),1),ie=n();function g(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function _(e,t){let n=g(t);return i(`/api/extensions/${encodeURIComponent(e)}/assets/${n}`)}var v={"capability:xopc.notes.create":`Create notes in this workspace`,"capability:xopc.notes.update":`Change notes in this workspace at an exact revision`,"capability:xopc.notes.append":`Append content to notes in this workspace`,"capability:xopc.notes.get":`Read notes in this workspace by ID`,"capability:xopc.notes.list":`Search and list notes in this workspace`,"capability:xopc.tasks.get":`Read tasks and their context in this workspace`,"capability:xopc.tasks.list":`Search and list tasks in this workspace`,theme:`Read theme (light / dark)`,"agent.send":`Send messages to the assistant`,"agent.subscribe":`Receive live agent stream events for a chat`,"session.read":`List and open chat sessions`,"config.read":`Read plugin configuration`,"config.write":`Write plugin configuration`,storage:`Read and write plugin storage`,notification:`Show in-app notifications`},y={"capability:xopc.notes.create":`在当前工作区创建笔记`,"capability:xopc.notes.update":`按精确版本修改当前工作区的笔记`,"capability:xopc.notes.append":`向当前工作区的笔记追加内容`,"capability:xopc.notes.get":`按 ID 读取当前工作区的笔记`,"capability:xopc.notes.list":`搜索和列出当前工作区的笔记`,"capability:xopc.tasks.get":`读取当前工作区的任务及其上下文`,"capability:xopc.tasks.list":`搜索和列出当前工作区的任务`,theme:`读取主题(浅色/深色)`,"agent.send":`向助手发送消息`,"agent.subscribe":`接收会话的实时助手流式事件`,"session.read":`列出并打开聊天会话`,"config.read":`读取插件配置`,"config.write":`写入插件配置`,storage:`读写插件存储`,notification:`显示应用内通知`};function b(e,t){let n=v[e];return t===`zh`&&y[e]?y[e]:n??e}var x=r();function S(e){let t=(0,ie.c)(59),{open:n,onOpenChange:r,extensionId:i,extensionName:a,permissions:o,onConfirm:d,confirmDisabled:f}=e,p=ee(w),m,h,g,_,v,y,S,T,E,D,O,k;t[0]!==a||t[1]!==p||t[2]!==r||t[3]!==n?(v=te(p).extensionUi,_=u,O=n,k=r,g=l,t[16]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,x.jsx)(s,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[16]=D):D=t[16],h=ne,T=`xopc-dialog-content fixed left-1/2 top-1/2 z-[131] w-[min(28rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-5`,E=C,m=re,y=`text-base font-semibold text-fg`,S=v.permissionTitle.replace(`{{name}}`,a),t[0]=a,t[1]=p,t[2]=r,t[3]=n,t[4]=m,t[5]=h,t[6]=g,t[7]=_,t[8]=v,t[9]=y,t[10]=S,t[11]=T,t[12]=E,t[13]=D,t[14]=O,t[15]=k):(m=t[4],h=t[5],g=t[6],_=t[7],v=t[8],y=t[9],S=t[10],T=t[11],E=t[12],D=t[13],O=t[14],k=t[15]);let A;t[17]!==m||t[18]!==y||t[19]!==S?(A=(0,x.jsx)(m,{className:y,children:S}),t[17]=m,t[18]=y,t[19]=S,t[20]=A):A=t[20];let j;t[21]===i?j=t[22]:(j=(0,x.jsxs)(`span`,{className:`font-mono text-xs text-fg-muted`,title:i,children:[`(`,i,`)`]}),t[21]=i,t[22]=j);let M;t[23]!==v.permissionSubtitle||t[24]!==j?(M=(0,x.jsxs)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:[v.permissionSubtitle,` `,j]}),t[23]=v.permissionSubtitle,t[24]=j,t[25]=M):M=t[25];let N;t[26]!==p||t[27]!==o||t[28]!==v.permissionsNone?(N=o.length===0?(0,x.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:v.permissionsNone}):(0,x.jsx)(`ul`,{className:`mt-4 max-h-48 list-inside list-disc space-y-1 overflow-y-auto text-sm text-fg`,children:o.map(e=>(0,x.jsx)(`li`,{children:b(e,p)},e))}),t[26]=p,t[27]=o,t[28]=v.permissionsNone,t[29]=N):N=t[29];let P;t[30]===v.deny?P=t[31]:(P=(0,x.jsx)(c,{asChild:!0,children:(0,x.jsx)(`button`,{type:`button`,className:`rounded-lg border border-edge px-3 py-2 text-sm text-fg hover:bg-surface-inset`,children:v.deny})}),t[30]=v.deny,t[31]=P);let F;t[32]!==d||t[33]!==r?(F=()=>{d(),r(!1)},t[32]=d,t[33]=r,t[34]=F):F=t[34];let I;t[35]!==f||t[36]!==v.allow||t[37]!==F?(I=(0,x.jsx)(`button`,{type:`button`,disabled:f,className:`rounded-lg bg-accent px-3 py-2 text-sm font-medium text-on-accent hover:opacity-90`,onClick:F,children:v.allow}),t[35]=f,t[36]=v.allow,t[37]=F,t[38]=I):I=t[38];let L;t[39]!==P||t[40]!==I?(L=(0,x.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[P,I]}),t[39]=P,t[40]=I,t[41]=L):L=t[41];let R;t[42]!==h||t[43]!==M||t[44]!==N||t[45]!==L||t[46]!==T||t[47]!==E||t[48]!==A?(R=(0,x.jsxs)(h,{className:T,onOpenAutoFocus:E,children:[A,M,N,L]}),t[42]=h,t[43]=M,t[44]=N,t[45]=L,t[46]=T,t[47]=E,t[48]=A,t[49]=R):R=t[49];let z;t[50]!==g||t[51]!==R||t[52]!==D?(z=(0,x.jsxs)(g,{children:[D,R]}),t[50]=g,t[51]=R,t[52]=D,t[53]=z):z=t[53];let B;return t[54]!==_||t[55]!==z||t[56]!==O||t[57]!==k?(B=(0,x.jsx)(_,{open:O,onOpenChange:k,children:z}),t[54]=_,t[55]=z,t[56]=O,t[57]=k,t[58]=B):B=t[58],B}function C(e){return e.preventDefault()}function w(e){return e.language}async function T(e){let{grant:t}=await o(i(`/api/extensions/${encodeURIComponent(e)}/ui-grant`));return t}async function E(e,t){return(await o(i(`/api/extensions/${encodeURIComponent(e)}/ui-grant`),{method:`POST`,body:JSON.stringify({manifestDigest:t})})).grant}var D=48,O=2e3,k=`allow-scripts allow-forms allow-popups`;function A(e){let t=(0,ie.c)(98),{extensionId:n,extensionName:r,entrypoint:i,permissions:o,title:s,className:c,fixedHeight:l,maxHeight:ne,minHeight:re,initialData:u}=e,g=ne===void 0?O:ne,v=re===void 0?D:re,y=ee(P),b;t[0]===y?b=t[1]:(b=te(y),t[0]=y,t[1]=b);let C=b.extensionUi,w=f(),A=a(N),F=a(M),I=(0,h.useRef)(0),L=(0,h.useRef)(!1),R=(0,h.useRef)(null),z=p(j),B;t[2]!==n||t[3]!==r?(B=r?.trim()||n,t[2]=n,t[3]=r,t[4]=B):B=t[4];let ae=B,oe;t[5]!==n||t[6]!==s?(oe=s?.trim()||`Extension ${n}`,t[5]=n,t[6]=s,t[7]=oe):oe=t[7];let se=oe,V;t[8]===o?V=t[9]:(V=JSON.stringify(Array.from(o??[]).toSorted()),t[8]=o,t[9]=V);let ce=V,H;t[10]===ce?H=t[11]:(H=JSON.parse(ce),t[10]=ce,t[11]=H);let le=H,ue=l??Math.min(g,Math.max(v,320)),U;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(U=[],t[12]=U):U=t[12];let W;t[13]===ue?W=t[14]:(W={allowed:!1,dialogOpen:!1,reloadKey:0,loadError:!1,dynamicHeight:ue,grantResolved:!1,grantError:null,manifestDigest:null,grantedPermissions:U},t[13]=ue,t[14]=W);let[G,K]=(0,h.useReducer)(m,W),{allowed:q,dialogOpen:J,reloadKey:Y,loadError:de,dynamicHeight:fe,grantResolved:pe,grantError:X}=G,me;t[15]===n?me=t[16]:(me=()=>{let e=!0;return L.current=!1,K({type:`patch`,patch:{allowed:!1,dialogOpen:!1,grantResolved:!1,grantError:null,manifestDigest:null,grantedPermissions:[]}}),T(n).then(t=>{if(e){if(t.extensionId!==n||!t.manifestDigest)throw Error(`Could not verify plugin permissions`);K({type:`patch`,patch:{allowed:t.granted,dialogOpen:!t.granted,grantResolved:!0,manifestDigest:t.manifestDigest,grantedPermissions:t.permissions}})}}).catch(t=>{e&&K({type:`patch`,patch:{allowed:!1,dialogOpen:!0,grantResolved:!0,grantError:t instanceof Error?t.message:String(t)}})}),()=>{e=!1,I.current+=1}},t[15]=n,t[16]=me);let he;t[17]!==n||t[18]!==A||t[19]!==F||t[20]!==le||t[21]!==Y?(he=[n,le,A,F,Y],t[17]=n,t[18]=A,t[19]=F,t[20]=le,t[21]=Y,t[22]=he):he=t[22],(0,h.useEffect)(me,he);let ge;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(ge=e=>K({type:`patch`,patch:{dialogOpen:e}}),t[23]=ge):ge=t[23];let _e=ge,ve;t[24]!==i||t[25]!==n?(ve=_(n,i),t[24]=i,t[25]=n,t[26]=ve):ve=t[26];let ye=ve,be;t[27]!==q||t[28]!==n||t[29]!==l||t[30]!==g||t[31]!==v||t[32]!==w||t[33]!==G.grantedPermissions||t[34]!==G.manifestDigest?(be=()=>{if(!q)return;let e=R.current;if(!e)return;w.registerIframe(n,e,G.grantedPermissions,G.manifestDigest??void 0);let t=w.subscribeExtensionEvents(n,e=>{if(e.event!==`ui.resize`||!e.data||typeof e.data!=`object`||e.data===null)return;let t=Number(e.data.height);Number.isFinite(t)&&l===void 0&&K({type:`patch`,patch:{dynamicHeight:Math.min(g,Math.max(v,t))}})});return()=>{t(),w.unregisterIframe(n)}},t[27]=q,t[28]=n,t[29]=l,t[30]=g,t[31]=v,t[32]=w,t[33]=G.grantedPermissions,t[34]=G.manifestDigest,t[35]=be):be=t[35];let xe;t[36]!==q||t[37]!==n||t[38]!==l||t[39]!==g||t[40]!==v||t[41]!==Y||t[42]!==w||t[43]!==G.grantedPermissions||t[44]!==G.manifestDigest?(xe=[q,n,l,g,v,G.grantedPermissions,G.manifestDigest,w,Y],t[36]=q,t[37]=n,t[38]=l,t[39]=g,t[40]=v,t[41]=Y,t[42]=w,t[43]=G.grantedPermissions,t[44]=G.manifestDigest,t[45]=xe):xe=t[45],(0,h.useLayoutEffect)(be,xe);let Se,Ce;t[46]!==q||t[47]!==n||t[48]!==z||t[49]!==w?(Se=()=>{if(!q)return;let e=d(z);w.sendEvent(n,`theme.changed`,e)},Ce=[q,n,z,w],t[46]=q,t[47]=n,t[48]=z,t[49]=w,t[50]=Se,t[51]=Ce):(Se=t[50],Ce=t[51]),(0,h.useEffect)(Se,Ce);let we;t[52]!==fe||t[53]!==l?(we=l===void 0?{width:`100%`,height:fe,border:`none`}:{width:`100%`,height:l,border:`none`},t[52]=fe,t[53]=l,t[54]=we):we=t[54];let Te=we,Ee;t[55]!==n||t[56]!==A||t[57]!==F||t[58]!==G.manifestDigest?(Ee=()=>{if(L.current||!G.manifestDigest)return;L.current=!0;let e=I.current,t=()=>I.current===e&&a.getState().baseUrl===A&&a.getState().conversationId===F;E(n,G.manifestDigest).then(e=>{if(t()){if(!e.granted||e.extensionId!==n||e.manifestDigest!==G.manifestDigest)throw Error(`Permission grant was not persisted`);K({type:`patch`,patch:{allowed:!0,grantError:null}})}}).catch(e=>{t()&&K({type:`patch`,patch:{allowed:!1,manifestDigest:null,grantError:e instanceof Error?e.message:String(e)}})}).finally(()=>{t()&&(L.current=!1)})},t[55]=n,t[56]=A,t[57]=F,t[58]=G.manifestDigest,t[59]=Ee):Ee=t[59];let De=Ee;if(!pe){let e=`${c??``} min-h-32 animate-pulse rounded-lg bg-surface-inset`,n;return t[60]===e?n=t[61]:(n=(0,x.jsx)(`div`,{className:e}),t[60]=e,t[61]=n),n}if(!q){let e=!G.manifestDigest,r;t[62]!==J||t[63]!==ae||t[64]!==n||t[65]!==De||t[66]!==e||t[67]!==G.grantedPermissions?(r=(0,x.jsx)(S,{open:J,onOpenChange:_e,extensionId:n,extensionName:ae,permissions:G.grantedPermissions,confirmDisabled:e,onConfirm:De}),t[62]=J,t[63]=ae,t[64]=n,t[65]=De,t[66]=e,t[67]=G.grantedPermissions,t[68]=r):r=t[68];let i;t[69]!==c||t[70]!==J||t[71]!==X||t[72]!==Y||t[73]!==C?(i=J?null:(0,x.jsxs)(`div`,{className:c?`${c} rounded-lg border border-edge border-dashed bg-surface-base p-4 text-sm text-fg-muted`:`rounded-lg border border-edge border-dashed bg-surface-base p-4 text-sm text-fg-muted`,children:[X?(0,x.jsx)(`p`,{className:`mb-2 text-danger`,children:X}):null,(0,x.jsx)(`p`,{children:C.deniedHint}),(0,x.jsx)(`button`,{type:`button`,className:`mt-2 text-sm font-medium text-accent underline-offset-2 hover:underline`,onClick:()=>K({type:`patch`,patch:{reloadKey:Y+1}}),children:C.reviewPermissions})]}),t[69]=c,t[70]=J,t[71]=X,t[72]=Y,t[73]=C,t[74]=i):i=t[74];let a;return t[75]!==r||t[76]!==i?(a=(0,x.jsxs)(x.Fragment,{children:[r,i]}),t[75]=r,t[76]=i,t[77]=a):a=t[77],a}let Z;t[78]!==de||t[79]!==Y||t[80]!==C?(Z=de?(0,x.jsxs)(`div`,{className:`mb-2 rounded-lg border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-sm text-fg`,children:[(0,x.jsx)(`p`,{children:C.loadFailed}),(0,x.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:C.loadFailedConnectionHint}),(0,x.jsx)(`button`,{type:`button`,className:`mt-2 font-medium text-accent underline-offset-2 hover:underline`,onClick:()=>{K({type:`patch`,patch:{loadError:!1,reloadKey:Y+1}})},children:C.retryLoad})]}):null,t[78]=de,t[79]=Y,t[80]=C,t[81]=Z):Z=t[81];let Oe=`${n}-${i}-${Y}`,ke;t[82]===Symbol.for(`react.memo_cache_sentinel`)?(ke=()=>K({type:`patch`,patch:{loadError:!0}}),t[82]=ke):ke=t[82];let Q;t[83]!==n||t[84]!==u||t[85]!==y||t[86]!==w?(Q=()=>{K({type:`patch`,patch:{loadError:!1}}),w.sendInit(n,d(p.getState().resolved),y),u!==void 0&&w.sendEvent(n,`widget.data`,u)},t[83]=n,t[84]=u,t[85]=y,t[86]=w,t[87]=Q):Q=t[87];let $;t[88]!==c||t[89]!==se||t[90]!==ye||t[91]!==Te||t[92]!==Oe||t[93]!==Q?($=(0,x.jsx)(`iframe`,{ref:R,className:c,title:se,src:ye,style:Te,sandbox:k,referrerPolicy:`no-referrer`,onError:ke,onLoad:Q},Oe),t[88]=c,t[89]=se,t[90]=ye,t[91]=Te,t[92]=Oe,t[93]=Q,t[94]=$):$=t[94];let Ae;return t[95]!==Z||t[96]!==$?(Ae=(0,x.jsxs)(`div`,{className:`flex flex-1 min-h-0 min-w-0 flex-col`,children:[Z,$]}),t[95]=Z,t[96]=$,t[97]=Ae):Ae=t[97],Ae}function j(e){return e.resolved}function M(e){return e.conversationId}function N(e){return e.baseUrl}function P(e){return e.language}export{A as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,i as t}from"./locale-store-
|
|
1
|
+
import{a as e,i as t}from"./locale-store-VNjH18Dj.js";async function n(n=``){let i=await e(t(`/api/marketplace${n.trim()?`?q=${encodeURIComponent(n.trim())}`:``}`),{cache:`no-store`});if(!i.ok)throw Error(await r(i));let a=await i.json();if(!a.ok||!Array.isArray(a.extensions))throw Error(a.error??`Invalid response`);return a.extensions}async function r(e){try{let t=await e.json();if(typeof t.error==`string`)return t.error;if(t.error&&typeof t.error==`object`&&typeof t.error.message==`string`)return t.error.message;if(typeof t.message==`string`)return t.message}catch{}return e.statusText||`HTTP ${e.status}`}async function i(n){let i=await e(t(`/api/marketplace/packages/${encodeURIComponent(n.trim())}`),{cache:`no-store`});if(!i.ok)throw Error(await r(i));let a=await i.json();if(!a.ok||!a.payload?.id)throw Error(a.error??`Invalid response`);return a.payload}async function a(n){let i=await e(t(`/api/marketplace/install`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});if(!i.ok)throw Error(await r(i));let a=await i.json();if(!a.ok||!a.payload?.extensionId)throw Error(a.error??`Invalid response`);return a.payload}async function o(n){let i=await e(t(`/api/extensions/${encodeURIComponent(n.extensionId.trim())}/activation`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:n.enabled})});if(!i.ok)throw Error(await r(i));let a=await i.json();if(!a.ok||!a.payload)throw Error(a.error?.message??`Invalid response`);return a.payload}async function s(n){let i=await e(t(`/api/marketplace/uninstall`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({extensionId:n})});if(!i.ok)throw Error(await r(i));let a=await i.json();if(!a.ok||!a.payload)throw Error(a.error??`Invalid response`);return a.payload}export{s as a,o as i,i as n,a as r,n as t};
|
package/dist/gateway/static/root/assets/{extension-page-C1nGr4DD.js → extension-page-CPrT111s.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{f as i}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{t as a}from"./resource-unavailable-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{t as a}from"./resource-unavailable-35wBZxmz.js";import{r as o,s}from"./extension-provider-B2Mf3FBu.js";import{t as c}from"./page-header-store-bPV8_tKL.js";import{t as l}from"./extension-iframe-host-vlZVeMCY.js";var u=n(),d=e(t(),1),f=r();function p(){let e=(0,u.c)(24),{extensionId:t,pageId:n}=i(),r=o(),p=c(h),g=c(m),_,v,y;e[0]!==t||e[1]!==r||e[2]!==n?(_=t?r.find(e=>e.id===t&&s(e)):void 0,v=_?.ui?.contributions?.pages,y=t&&v?.length?n?v.find(e=>e.id===n||e.id===`${t}.${n}`):v[0]:void 0,e[0]=t,e[1]=r,e[2]=n,e[3]=_,e[4]=v,e[5]=y):(_=e[3],v=e[4],y=e[5]);let b=y,x,S;if(e[6]!==g||e[7]!==_||e[8]!==t||e[9]!==b||e[10]!==p?(x=()=>{if(!t||!_||!b)return g(),()=>g();let e=b.title?.trim()||_.name||t;return p({startExtra:null,main:(0,f.jsx)(`div`,{className:`w-full min-w-0 px-3 sm:px-5 xl:px-6`,children:(0,f.jsx)(`h1`,{className:`min-w-0 truncate text-base font-semibold tracking-tight text-fg`,title:e,children:e})}),end:null}),()=>g()},S=[g,_,t,b,p],e[6]=g,e[7]=_,e[8]=t,e[9]=b,e[10]=p,e[11]=x,e[12]=S):(x=e[11],S=e[12]),(0,d.useLayoutEffect)(x,S),!t){let t;return e[13]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,f.jsx)(a,{kind:`plugin`,backTo:`/capabilities/extensions`}),e[13]=t):t=e[13],t}if(!_){let n=r.some(e=>e.id===t)?`plugin-page`:`plugin`,i;return e[14]===n?i=e[15]:(i=(0,f.jsx)(a,{kind:n,backTo:`/capabilities/extensions`}),e[14]=n,e[15]=i),i}if(!v?.length){let t;return e[16]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,f.jsx)(a,{kind:`plugin-page`,backTo:`/capabilities/extensions`}),e[16]=t):t=e[16],t}if(!b){let t;return e[17]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,f.jsx)(a,{kind:`plugin`,backTo:`/capabilities/extensions`}),e[17]=t):t=e[17],t}let C=_.ui?.permissions,w;return e[18]!==_.name||e[19]!==t||e[20]!==b.entrypoint||e[21]!==b.title||e[22]!==C?(w=(0,f.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,f.jsx)(l,{extensionId:t,extensionName:_.name,entrypoint:b.entrypoint,permissions:C,title:b.title,className:`min-h-0 flex-1`,fixedHeight:void 0,maxHeight:99999})}),e[18]=_.name,e[19]=t,e[20]=b.entrypoint,e[21]=b.title,e[22]=C,e[23]=w):w=e[23],w}function m(e){return e.clearPageHeader}function h(e){return e.setPageHeader}export{p as ExtensionPage};
|
|
@@ -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{a as i,i as a,l as o,o as s}from"./locale-store-5Hf8J8-_.js";import{i as c}from"./vendor-swr-CdRzEUwF.js";import{i as l,m as u,n as d,p as f,u as p}from"./schemas-CCWMleym.js";import{d as m,i as h,t as g}from"./session-manager-DNMosCtW.js";import{t as _}from"./capabilities-D0-HCZ5J.js";import{t as v}from"./activity-store-CKrylgib.js";import{a as y}from"./gateway-realtime-CyCCNUxm.js";import{i as b}from"./theme-store-DOJ9tu-j.js";var x=f({id:d([`xopc.notes.get`,`xopc.notes.list`,`xopc.tasks.get`,`xopc.tasks.list`,`xopc.notes.create`,`xopc.notes.update`,`xopc.notes.append`]),majorVersion:p().int().positive(),descriptorDigest:u().regex(/^[a-f0-9]{64}$/)});l(x).max(7).refine(e=>new Set(e.map(e=>e.id)).size===e.length,`Duplicate capability binding`);var S=e(t(),1),C=n(),w=`agent-stream-event`;function T(e){return e===`off`||e===`on`||e===`stream`}function E(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e,n=typeof t.conversationId==`string`?t.conversationId.trim():``,r=typeof t.runId==`string`?t.runId.trim():``;return n&&r?{conversationId:n,runId:r}:null}function D(e,t,n){return t&&typeof t==`object`&&!Array.isArray(t)?{...t,seq:n}:{type:e,seq:n,payload:t}}async function O(e){try{let t=await i(a(`/api/sessions/${encodeURIComponent(e)}/agent-config`));if(!t.ok)return`on`;let n=await t.json(),r=n.payload?.activityDetail?.effective;if(T(r))return r;let o=n.payload?.activityDetail?.default;return T(o)?o:`on`}catch{return`on`}}function k(e){window.dispatchEvent(new CustomEvent(w,{detail:e}))}function A(e={}){let t=e.subscribe??y,n=e.loadActivityDetailLevel??O,r=e.dispatch??k,i=new Map,a=!1,o=e=>{let o=E(e.detail);if(!o||i.has(o.runId))return;let s=`on`,c=!1,l,u=!1,d=!1,f=()=>{},p=()=>{u||(u=!0,f(),i.get(o.runId)===p&&i.delete(o.runId))},m=e=>{a||u||r({conversationId:o.conversationId,event:e,activityDetailLevel:s})};n(o.conversationId).then(e=>{s=e,c=!0,e===`stream`&&l&&!d&&m(l),l=void 0}),f=t(`run:${o.runId}`,{onEvent:e=>{if(u||d)return;let t=D(e.event,e.data,e.seq);e.event===`thinking_delta`&&!c?l=t:m(t),e.event===`run_end`&&(d=!0,l=void 0,queueMicrotask(p))},onGap:e=>{e.recoverable||p()}},0),i.set(o.runId,p)},s=e=>{let t=E(e.detail);t&&i.get(t.runId)?.()};return window.addEventListener(`run-started`,o),window.addEventListener(`run-completed`,s),window.addEventListener(`agent-run-ended`,s),()=>{a=!0,window.removeEventListener(`run-started`,o),window.removeEventListener(`run-completed`,s),window.removeEventListener(`agent-run-ended`,s);for(let e of[...i.values()])e()}}var j=function(e){return e[e.PermissionDenied=4001]=`PermissionDenied`,e[e.InvalidRequest=4002]=`InvalidRequest`,e[e.MethodNotFound=4003]=`MethodNotFound`,e[e.InternalError=4004]=`InternalError`,e[e.Timeout=4005]=`Timeout`,e[e.ExtensionNotFound=4006]=`ExtensionNotFound`,e[e.RateLimited=4007]=`RateLimited`,e}({});async function M(e,t,n){let r=new g,i=await r.loadSessionAgentConfig(e);await r.loadSession(e),m(e,i),await new h().send(t,e,n,i.thinkingLevel)}var N=[`--color-surface-base`,`--color-surface-panel`,`--color-surface-hover`,`--color-fg`,`--color-fg-muted`,`--color-fg-subtle`,`--color-accent`,`--color-accent-hover`,`--color-accent-soft`,`--color-edge`,`--color-edge-subtle`,`--color-danger`,`--color-success`,`--color-warning`,`--radius-sm`,`--radius-lg`,`--radius-xl`];function P(e){let t=getComputedStyle(document.documentElement),n={};for(let e of N){let r=t.getPropertyValue(e).trim();r&&(n[e]=r)}return{mode:e,tokens:n,fontFamily:t.getPropertyValue(`font-family`).trim(),fontFamilyMono:t.getPropertyValue(`--font-mono`).trim()}}var F={"agent.sendMessage":`agent.send`,"session.list":`session.read`,"session.navigate":`session.read`,"config.get":`config.read`,"config.set":`config.write`,"storage.get":`storage`,"storage.set":`storage`,"storage.remove":`storage`,"storage.keys":`storage`,"ui.notification":`notification`,"theme.get":`theme`},I=class{iframes=new Map;byContentWindow=new WeakMap;handlers=new Map;extensionPermissions=new Map;releaseBindings=new Map;eventSubscribers=new Map;agentStreamSubscriptions=new Map;boundListener=e=>{this.onWindowMessage(e)};constructor(){window.addEventListener(`message`,this.boundListener)}dispose(){window.removeEventListener(`message`,this.boundListener),this.iframes.clear(),this.handlers.clear(),this.extensionPermissions.clear(),this.releaseBindings.clear(),this.eventSubscribers.clear(),this.agentStreamSubscriptions.clear()}registerIframe(e,t,n,r){let i=this.iframes.get(e);if(i&&i!==t&&i.contentWindow&&this.byContentWindow.delete(i.contentWindow),this.iframes.set(e,t),this.extensionPermissions.set(e,new Set(n)),this.releaseBindings.delete(e),r){let t=o.getState();this.releaseBindings.set(e,{digest:r,baseUrl:t.baseUrl,namespace:t.conversationId})}this.rememberIframeWindow(e,t)}unregisterIframe(e){let t=this.iframes.get(e);this.sendEvent(e,`panel.dispose`),t?.contentWindow&&this.byContentWindow.delete(t.contentWindow),this.iframes.delete(e),this.extensionPermissions.delete(e),this.releaseBindings.delete(e),this.agentStreamSubscriptions.delete(e)}rememberIframeWindow(e,t){let n=t.contentWindow;n&&this.byContentWindow.set(n,{extensionId:e,iframe:t})}subscribeAgentStream(e,t){let n=this.agentStreamSubscriptions.get(e);n||(n=new Set,this.agentStreamSubscriptions.set(e,n)),n.add(t)}unsubscribeAgentStream(e,t){this.agentStreamSubscriptions.get(e)?.delete(t)}forwardAgentStreamEvent(e,t){for(let[n,r]of this.agentStreamSubscriptions)r.has(e)&&this.sendEvent(n,`agent.stream.${e}`,t)}broadcastExtensionEvent(e,t,n){let r=t.startsWith(`ext.`)?t:`ext.${t}`;for(let[t]of this.iframes)t!==e&&this.sendEvent(t,r,n)}handleExtensionEvent(e,t,n){if(t.startsWith(`ext.`)){let r=t.slice(4);this.broadcastExtensionEvent(e,r,n);return}if(t===`agent.subscribe`||t===`agent.unsubscribe`){if(!(this.extensionPermissions.get(e)??new Set).has(`agent.subscribe`))return;let{conversationId:r}=n??{};if(typeof r!=`string`||!r.trim())return;let i=r.trim();t===`agent.subscribe`?this.subscribeAgentStream(e,i):this.unsubscribeAgentStream(e,i)}}registerMethod(e,t){this.handlers.set(e,t)}getReleaseDigest(e){let t=this.releaseBindings.get(e),n=o.getState();if(!t||t.baseUrl!==n.baseUrl||t.namespace!==n.conversationId)throw Error(`Extension release authorization is unavailable`);return t.digest}subscribeExtensionEvents(e,t){let n=this.eventSubscribers.get(e);return n||(n=new Set,this.eventSubscribers.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&this.eventSubscribers.delete(e)}}sendInit(e,t,n){let r=this.iframes.get(e);if(!r?.contentWindow)return;this.rememberIframeWindow(e,r);let i=[...this.extensionPermissions.get(e)??[]];r.contentWindow.postMessage({source:`xopc-host`,type:`init`,extensionId:e,permissions:i,theme:t,locale:n},`*`)}sendEvent(e,t,n){let r=this.iframes.get(e);r?.contentWindow&&r.contentWindow.postMessage({source:`xopc-host`,type:`event`,event:t,data:n},`*`)}broadcastEvent(e,t){for(let[,n]of this.iframes)n.contentWindow?.postMessage({source:`xopc-host`,type:`event`,event:e,data:t},`*`)}postResponse(e,t,n,r,i){let a=e.contentWindow,o={source:`xopc-host`,type:`response`,requestId:n,result:r,error:i};!a||a!==t?.source||a.postMessage(o,`*`)}async onWindowMessage(e){let t=e.data;if(!t||t.source!==`xopc-extension`||!e.source)return;let n=this.byContentWindow.get(e.source);if(!n)return;let{iframe:r,extensionId:i}=n;if(this.iframes.get(i)!==r||r.contentWindow!==e.source)return;if(t.type===`event`){this.handleExtensionEvent(i,t.event,t.data);let e=this.eventSubscribers.get(i);if(e){let n={event:t.event,data:t.data};for(let t of e)try{t(n)}catch{}}return}if(t.type!==`request`)return;let{requestId:a,method:s,params:c}=t;if(typeof a!=`string`||a.length>200||typeof s!=`string`||s.length>200)return;let l=this.handlers.get(s);if(!l){this.postResponse(r,e,a,void 0,{code:j.MethodNotFound,message:`Unknown method: ${s}`});return}let u=c&&typeof c==`object`&&`id`in c?c.id:void 0,d=s===`capability.describe`||s===`capability.call`?`capability:${typeof u==`string`?u:``}`:F[s],f=this.extensionPermissions.get(i)??new Set;if(d&&!f.has(d)){this.postResponse(r,e,a,void 0,{code:j.PermissionDenied,message:`Missing permission: ${d}`});return}let p=o.getState(),m=()=>this.iframes.get(i)===r&&r.contentWindow===e.source&&this.extensionPermissions.get(i)===f&&o.getState().baseUrl===p.baseUrl&&o.getState().conversationId===p.conversationId;try{let t=await l(i,c);if(!m())return;this.postResponse(r,e,a,t)}catch(t){if(!m())return;let n=t instanceof Error?t.message:String(t);this.postResponse(r,e,a,void 0,{code:j.InternalError,message:n})}}};function L(e){let t=f({id:x.shape.id}),n=t.extend({call:_});e.registerMethod(`capability.describe`,async(n,r)=>{let{id:i}=t.parse(r),o=e.getReleaseDigest(n),c=(await s(a(`/api/local-app-capabilities/${encodeURIComponent(n)}?manifestDigest=${encodeURIComponent(o)}`))).capabilities.find(e=>e.id===i);if(!c)throw Error(`Capability is unavailable for this release`);return c}),e.registerMethod(`capability.call`,async(t,r)=>{let{id:i,call:o}=n.parse(r),c=e.getReleaseDigest(t);return s(a(`/api/local-app-capabilities/${encodeURIComponent(t)}/${encodeURIComponent(i)}/invocations`),{method:`POST`,body:JSON.stringify({manifestDigest:c,call:o})})}),e.registerMethod(`theme.get`,async()=>P(b.getState().resolved)),e.registerMethod(`ui.navigate`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`path`in t?String(t.path??``):``;if(n){let e=n.startsWith(`/`)?n:`/${n}`;window.location.hash=`#${e}`}}),e.registerMethod(`ui.notification`,async(e,t)=>{if(!t||typeof t!=`object`)return;let n=t,r=typeof n.title==`string`?n.title.trim():``;r&&v({tone:n.type===`success`||n.type===`warning`||n.type===`error`||n.type===`info`?n.type:`info`,title:r,message:typeof n.message==`string`?n.message:void 0,source:e,dedupeKey:`extension:${e}:${r}`})}),e.registerMethod(`session.navigate`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`conversationId`in t?String(t.conversationId??``):``;n&&window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{conversationId:n},bubbles:!0}))}),e.registerMethod(`session.list`,async()=>{let e=await i(a(`/api/sessions`));if(!e.ok)throw Error(`Failed to list sessions: ${e.status}`);return((await e.json()).items??[]).map(e=>({conversationId:e.key,title:e.name,lastMessageAt:e.updatedAt??e.lastAccessedAt,messageCount:e.messageCount}))}),e.registerMethod(`agent.sendMessage`,async(e,t)=>{let{message:n,conversationId:r,newSession:i}=t,a=r?.trim()||``;return(i||!a)&&(a=(await new g().createSession()).key),await M(a,n),{conversationId:a}}),e.registerMethod(`config.get`,async e=>{let t=await i(a(`/api/extensions/${encodeURIComponent(e)}/config`));if(!t.ok)throw Error(`Failed to get config: ${t.status}`);return t.json()}),e.registerMethod(`config.set`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&!Array.isArray(t)?t:{},r=await i(a(`/api/extensions/${encodeURIComponent(e)}/config`),{method:`PATCH`,body:JSON.stringify(n)});if(!r.ok)throw Error(`Failed to set config: ${r.status}`)}),e.registerMethod(`storage.get`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`key`in t?String(t.key??``):``,r=await i(a(`/api/extensions/${encodeURIComponent(e)}/storage/${encodeURIComponent(n)}`));if(r.status!==404){if(!r.ok)throw Error(`Failed to get storage key: ${r.status}`);return(await r.json()).value}}),e.registerMethod(`storage.set`,async(e,t)=>{let n=t,r=n&&typeof n.key==`string`?n.key:``,o=await i(a(`/api/extensions/${encodeURIComponent(e)}/storage/${encodeURIComponent(r)}`),{method:`PUT`,body:JSON.stringify({value:n?.value})});if(!o.ok)throw Error(`Failed to set storage key: ${o.status}`)}),e.registerMethod(`storage.remove`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`key`in t?String(t.key??``):``,r=await i(a(`/api/extensions/${encodeURIComponent(e)}/storage/${encodeURIComponent(n)}`),{method:`DELETE`});if(r.status!==404&&!r.ok)throw Error(`Failed to remove storage key: ${r.status}`)}),e.registerMethod(`storage.keys`,async e=>{let t=await i(a(`/api/extensions/${encodeURIComponent(e)}/storage`));if(!t.ok)throw Error(`Failed to list storage keys: ${t.status}`);return(await t.json()).keys??[]})}function R(e){return e.active||e.activationEligible===!0}function z(e){let t=e.ui?.contributions;return t?Array.isArray(t.pages)&&t.pages.length>0||Array.isArray(t.settingsPanels)&&t.settingsPanels.length>0||Array.isArray(t.chatWidgets)&&t.chatWidgets.length>0:!1}function B(e){return e.source===`bundled`&&e.hasUi===!0&&z(e)}function V(e){return e.kind===`image-generation`||e.kind===`media-provider`}function H(e){return R(e)?e.hasConfigSchema||V(e)?!0:e.hasUi?z(e):!1:!1}function U(e){return H(e)||B(e)}var W=r(),G=(0,S.createContext)(null);function K({children:e}){let t=(0,S.useRef)(null);if(!t.current){let e=new I;L(e),t.current=e}let n=t.current,{data:r,isLoading:i,mutate:l}=c(o(e=>!!e.conversationId)?`gateway-extensions-list`:null,()=>s(a(`/api/extensions`)),{revalidateOnFocus:!1}),u=r?.extensions??[],d=b(e=>e.resolved);(0,S.useEffect)(()=>{let e=()=>{l()};return window.addEventListener(`config-reload`,e),window.addEventListener(`registry-updated`,e),()=>{window.removeEventListener(`config-reload`,e),window.removeEventListener(`registry-updated`,e)}},[l]);let f=(0,S.useCallback)(e=>{let t=e.detail;t?.conversationId&&n.forwardAgentStreamEvent(t.conversationId,t.event??t)},[n]),p=(0,S.useRef)(f);p.current=f,(0,S.useEffect)(()=>{let e=e=>{p.current(e)};return window.addEventListener(w,e),()=>{window.removeEventListener(w,e)}},[]),(0,S.useEffect)(()=>{let e=P(d);n.broadcastEvent(`theme.changed`,e)},[d,n]);let m=(0,S.useRef)(n);m.current=n,(0,S.useEffect)(()=>()=>{m.current.dispose(),t.current=null},[]);let h=(0,S.useMemo)(()=>({router:n,extensions:u,loading:i}),[n,u,i]);return(0,W.jsx)(G.Provider,{value:h,children:e})}function q(){let e=(0,S.useContext)(G);if(!e)throw Error(`useExtensionRouter must be used within ExtensionProvider`);return e.router}function J(){let e=(0,S.useContext)(G);if(!e)throw Error(`useExtensions must be used within ExtensionProvider`);return e.extensions}function Y(){let e=(0,C.c)(2),t=J(),n;return e[0]===t?n=e[1]:(n=t.filter(H),e[0]=t,e[1]=n),n}function X(){let e=(0,S.useContext)(G);if(!e)throw Error(`useExtensionsLoading must be used within ExtensionProvider`);return e.loading}export{Y as a,P as c,A as d,X as i,M as l,q as n,V as o,J as r,U as s,K as t,w as u};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{a as i,i as a,l as o,o as s}from"./locale-store-VNjH18Dj.js";import{i as c}from"./vendor-swr-CdRzEUwF.js";import{d as l,i as u,t as d}from"./session-manager-wWxpzSo0.js";import{i as f,m as p,n as m,p as h,u as g}from"./schemas-CCWMleym.js";import{a as _}from"./gateway-realtime-D20ZrAuM.js";import{t as v}from"./capabilities-DOTgaSgA.js";import{t as y}from"./activity-store-CvJ9rdwP.js";import{i as b}from"./theme-store-DbStcH89.js";var x=h({id:m([`xopc.notes.get`,`xopc.notes.list`,`xopc.tasks.get`,`xopc.tasks.list`,`xopc.notes.create`,`xopc.notes.update`,`xopc.notes.append`]),majorVersion:g().int().positive(),descriptorDigest:p().regex(/^[a-f0-9]{64}$/)});f(x).max(7).refine(e=>new Set(e.map(e=>e.id)).size===e.length,`Duplicate capability binding`);var S=e(t(),1),C=n(),w=`agent-stream-event`;function T(e){return e===`off`||e===`on`||e===`stream`}function E(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e,n=typeof t.conversationId==`string`?t.conversationId.trim():``,r=typeof t.runId==`string`?t.runId.trim():``;return n&&r?{conversationId:n,runId:r}:null}function D(e,t,n){return t&&typeof t==`object`&&!Array.isArray(t)?{...t,seq:n}:{type:e,seq:n,payload:t}}async function O(e){try{let t=await i(a(`/api/sessions/${encodeURIComponent(e)}/agent-config`));if(!t.ok)return`on`;let n=await t.json(),r=n.payload?.activityDetail?.effective;if(T(r))return r;let o=n.payload?.activityDetail?.default;return T(o)?o:`on`}catch{return`on`}}function k(e){window.dispatchEvent(new CustomEvent(w,{detail:e}))}function A(e={}){let t=e.subscribe??_,n=e.loadActivityDetailLevel??O,r=e.dispatch??k,i=new Map,a=!1,o=e=>{let o=E(e.detail);if(!o||i.has(o.runId))return;let s=`on`,c=!1,l,u=!1,d=!1,f=()=>{},p=()=>{u||(u=!0,f(),i.get(o.runId)===p&&i.delete(o.runId))},m=e=>{a||u||r({conversationId:o.conversationId,event:e,activityDetailLevel:s})};n(o.conversationId).then(e=>{s=e,c=!0,e===`stream`&&l&&!d&&m(l),l=void 0}),f=t(`run:${o.runId}`,{onEvent:e=>{if(u||d)return;let t=D(e.event,e.data,e.seq);e.event===`thinking_delta`&&!c?l=t:m(t),e.event===`run_end`&&(d=!0,l=void 0,queueMicrotask(p))},onGap:e=>{e.recoverable||p()}},0),i.set(o.runId,p)},s=e=>{let t=E(e.detail);t&&i.get(t.runId)?.()};return window.addEventListener(`run-started`,o),window.addEventListener(`run-completed`,s),window.addEventListener(`agent-run-ended`,s),()=>{a=!0,window.removeEventListener(`run-started`,o),window.removeEventListener(`run-completed`,s),window.removeEventListener(`agent-run-ended`,s);for(let e of[...i.values()])e()}}var j=function(e){return e[e.PermissionDenied=4001]=`PermissionDenied`,e[e.InvalidRequest=4002]=`InvalidRequest`,e[e.MethodNotFound=4003]=`MethodNotFound`,e[e.InternalError=4004]=`InternalError`,e[e.Timeout=4005]=`Timeout`,e[e.ExtensionNotFound=4006]=`ExtensionNotFound`,e[e.RateLimited=4007]=`RateLimited`,e}({});async function M(e,t,n){let r=new d,i=await r.loadSessionAgentConfig(e);await r.loadSession(e),l(e,i),await new u().send(t,e,n,i.thinkingLevel)}var N=[`--color-surface-base`,`--color-surface-panel`,`--color-surface-hover`,`--color-fg`,`--color-fg-muted`,`--color-fg-subtle`,`--color-accent`,`--color-accent-hover`,`--color-accent-soft`,`--color-edge`,`--color-edge-subtle`,`--color-danger`,`--color-success`,`--color-warning`,`--radius-sm`,`--radius-lg`,`--radius-xl`];function P(e){let t=getComputedStyle(document.documentElement),n={};for(let e of N){let r=t.getPropertyValue(e).trim();r&&(n[e]=r)}return{mode:e,tokens:n,fontFamily:t.getPropertyValue(`font-family`).trim(),fontFamilyMono:t.getPropertyValue(`--font-mono`).trim()}}var F={"agent.sendMessage":`agent.send`,"session.list":`session.read`,"session.navigate":`session.read`,"config.get":`config.read`,"config.set":`config.write`,"storage.get":`storage`,"storage.set":`storage`,"storage.remove":`storage`,"storage.keys":`storage`,"ui.notification":`notification`,"theme.get":`theme`},I=class{iframes=new Map;byContentWindow=new WeakMap;handlers=new Map;extensionPermissions=new Map;releaseBindings=new Map;eventSubscribers=new Map;agentStreamSubscriptions=new Map;boundListener=e=>{this.onWindowMessage(e)};constructor(){window.addEventListener(`message`,this.boundListener)}dispose(){window.removeEventListener(`message`,this.boundListener),this.iframes.clear(),this.handlers.clear(),this.extensionPermissions.clear(),this.releaseBindings.clear(),this.eventSubscribers.clear(),this.agentStreamSubscriptions.clear()}registerIframe(e,t,n,r){let i=this.iframes.get(e);if(i&&i!==t&&i.contentWindow&&this.byContentWindow.delete(i.contentWindow),this.iframes.set(e,t),this.extensionPermissions.set(e,new Set(n)),this.releaseBindings.delete(e),r){let t=o.getState();this.releaseBindings.set(e,{digest:r,baseUrl:t.baseUrl,namespace:t.conversationId})}this.rememberIframeWindow(e,t)}unregisterIframe(e){let t=this.iframes.get(e);this.sendEvent(e,`panel.dispose`),t?.contentWindow&&this.byContentWindow.delete(t.contentWindow),this.iframes.delete(e),this.extensionPermissions.delete(e),this.releaseBindings.delete(e),this.agentStreamSubscriptions.delete(e)}rememberIframeWindow(e,t){let n=t.contentWindow;n&&this.byContentWindow.set(n,{extensionId:e,iframe:t})}subscribeAgentStream(e,t){let n=this.agentStreamSubscriptions.get(e);n||(n=new Set,this.agentStreamSubscriptions.set(e,n)),n.add(t)}unsubscribeAgentStream(e,t){this.agentStreamSubscriptions.get(e)?.delete(t)}forwardAgentStreamEvent(e,t){for(let[n,r]of this.agentStreamSubscriptions)r.has(e)&&this.sendEvent(n,`agent.stream.${e}`,t)}broadcastExtensionEvent(e,t,n){let r=t.startsWith(`ext.`)?t:`ext.${t}`;for(let[t]of this.iframes)t!==e&&this.sendEvent(t,r,n)}handleExtensionEvent(e,t,n){if(t.startsWith(`ext.`)){let r=t.slice(4);this.broadcastExtensionEvent(e,r,n);return}if(t===`agent.subscribe`||t===`agent.unsubscribe`){if(!(this.extensionPermissions.get(e)??new Set).has(`agent.subscribe`))return;let{conversationId:r}=n??{};if(typeof r!=`string`||!r.trim())return;let i=r.trim();t===`agent.subscribe`?this.subscribeAgentStream(e,i):this.unsubscribeAgentStream(e,i)}}registerMethod(e,t){this.handlers.set(e,t)}getReleaseDigest(e){let t=this.releaseBindings.get(e),n=o.getState();if(!t||t.baseUrl!==n.baseUrl||t.namespace!==n.conversationId)throw Error(`Extension release authorization is unavailable`);return t.digest}subscribeExtensionEvents(e,t){let n=this.eventSubscribers.get(e);return n||(n=new Set,this.eventSubscribers.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&this.eventSubscribers.delete(e)}}sendInit(e,t,n){let r=this.iframes.get(e);if(!r?.contentWindow)return;this.rememberIframeWindow(e,r);let i=[...this.extensionPermissions.get(e)??[]];r.contentWindow.postMessage({source:`xopc-host`,type:`init`,extensionId:e,permissions:i,theme:t,locale:n},`*`)}sendEvent(e,t,n){let r=this.iframes.get(e);r?.contentWindow&&r.contentWindow.postMessage({source:`xopc-host`,type:`event`,event:t,data:n},`*`)}broadcastEvent(e,t){for(let[,n]of this.iframes)n.contentWindow?.postMessage({source:`xopc-host`,type:`event`,event:e,data:t},`*`)}postResponse(e,t,n,r,i){let a=e.contentWindow,o={source:`xopc-host`,type:`response`,requestId:n,result:r,error:i};!a||a!==t?.source||a.postMessage(o,`*`)}async onWindowMessage(e){let t=e.data;if(!t||t.source!==`xopc-extension`||!e.source)return;let n=this.byContentWindow.get(e.source);if(!n)return;let{iframe:r,extensionId:i}=n;if(this.iframes.get(i)!==r||r.contentWindow!==e.source)return;if(t.type===`event`){this.handleExtensionEvent(i,t.event,t.data);let e=this.eventSubscribers.get(i);if(e){let n={event:t.event,data:t.data};for(let t of e)try{t(n)}catch{}}return}if(t.type!==`request`)return;let{requestId:a,method:s,params:c}=t;if(typeof a!=`string`||a.length>200||typeof s!=`string`||s.length>200)return;let l=this.handlers.get(s);if(!l){this.postResponse(r,e,a,void 0,{code:j.MethodNotFound,message:`Unknown method: ${s}`});return}let u=c&&typeof c==`object`&&`id`in c?c.id:void 0,d=s===`capability.describe`||s===`capability.call`?`capability:${typeof u==`string`?u:``}`:F[s],f=this.extensionPermissions.get(i)??new Set;if(d&&!f.has(d)){this.postResponse(r,e,a,void 0,{code:j.PermissionDenied,message:`Missing permission: ${d}`});return}let p=o.getState(),m=()=>this.iframes.get(i)===r&&r.contentWindow===e.source&&this.extensionPermissions.get(i)===f&&o.getState().baseUrl===p.baseUrl&&o.getState().conversationId===p.conversationId;try{let t=await l(i,c);if(!m())return;this.postResponse(r,e,a,t)}catch(t){if(!m())return;let n=t instanceof Error?t.message:String(t);this.postResponse(r,e,a,void 0,{code:j.InternalError,message:n})}}};function L(e){let t=h({id:x.shape.id}),n=t.extend({call:v});e.registerMethod(`capability.describe`,async(n,r)=>{let{id:i}=t.parse(r),o=e.getReleaseDigest(n),c=(await s(a(`/api/local-app-capabilities/${encodeURIComponent(n)}?manifestDigest=${encodeURIComponent(o)}`))).capabilities.find(e=>e.id===i);if(!c)throw Error(`Capability is unavailable for this release`);return c}),e.registerMethod(`capability.call`,async(t,r)=>{let{id:i,call:o}=n.parse(r),c=e.getReleaseDigest(t);return s(a(`/api/local-app-capabilities/${encodeURIComponent(t)}/${encodeURIComponent(i)}/invocations`),{method:`POST`,body:JSON.stringify({manifestDigest:c,call:o})})}),e.registerMethod(`theme.get`,async()=>P(b.getState().resolved)),e.registerMethod(`ui.navigate`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`path`in t?String(t.path??``):``;if(n){let e=n.startsWith(`/`)?n:`/${n}`;window.location.hash=`#${e}`}}),e.registerMethod(`ui.notification`,async(e,t)=>{if(!t||typeof t!=`object`)return;let n=t,r=typeof n.title==`string`?n.title.trim():``;r&&y({tone:n.type===`success`||n.type===`warning`||n.type===`error`||n.type===`info`?n.type:`info`,title:r,message:typeof n.message==`string`?n.message:void 0,source:e,dedupeKey:`extension:${e}:${r}`})}),e.registerMethod(`session.navigate`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`conversationId`in t?String(t.conversationId??``):``;n&&window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{conversationId:n},bubbles:!0}))}),e.registerMethod(`session.list`,async()=>{let e=await i(a(`/api/sessions`));if(!e.ok)throw Error(`Failed to list sessions: ${e.status}`);return((await e.json()).items??[]).map(e=>({conversationId:e.key,title:e.name,lastMessageAt:e.updatedAt??e.lastAccessedAt,messageCount:e.messageCount}))}),e.registerMethod(`agent.sendMessage`,async(e,t)=>{let{message:n,conversationId:r,newSession:i}=t,a=r?.trim()||``;return(i||!a)&&(a=(await new d().createSession()).key),await M(a,n),{conversationId:a}}),e.registerMethod(`config.get`,async e=>{let t=await i(a(`/api/extensions/${encodeURIComponent(e)}/config`));if(!t.ok)throw Error(`Failed to get config: ${t.status}`);return t.json()}),e.registerMethod(`config.set`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&!Array.isArray(t)?t:{},r=await i(a(`/api/extensions/${encodeURIComponent(e)}/config`),{method:`PATCH`,body:JSON.stringify(n)});if(!r.ok)throw Error(`Failed to set config: ${r.status}`)}),e.registerMethod(`storage.get`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`key`in t?String(t.key??``):``,r=await i(a(`/api/extensions/${encodeURIComponent(e)}/storage/${encodeURIComponent(n)}`));if(r.status!==404){if(!r.ok)throw Error(`Failed to get storage key: ${r.status}`);return(await r.json()).value}}),e.registerMethod(`storage.set`,async(e,t)=>{let n=t,r=n&&typeof n.key==`string`?n.key:``,o=await i(a(`/api/extensions/${encodeURIComponent(e)}/storage/${encodeURIComponent(r)}`),{method:`PUT`,body:JSON.stringify({value:n?.value})});if(!o.ok)throw Error(`Failed to set storage key: ${o.status}`)}),e.registerMethod(`storage.remove`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`key`in t?String(t.key??``):``,r=await i(a(`/api/extensions/${encodeURIComponent(e)}/storage/${encodeURIComponent(n)}`),{method:`DELETE`});if(r.status!==404&&!r.ok)throw Error(`Failed to remove storage key: ${r.status}`)}),e.registerMethod(`storage.keys`,async e=>{let t=await i(a(`/api/extensions/${encodeURIComponent(e)}/storage`));if(!t.ok)throw Error(`Failed to list storage keys: ${t.status}`);return(await t.json()).keys??[]})}function R(e){return e.active||e.activationEligible===!0}function z(e){let t=e.ui?.contributions;return t?Array.isArray(t.pages)&&t.pages.length>0||Array.isArray(t.settingsPanels)&&t.settingsPanels.length>0||Array.isArray(t.chatWidgets)&&t.chatWidgets.length>0:!1}function B(e){return e.source===`bundled`&&e.hasUi===!0&&z(e)}function V(e){return e.kind===`image-generation`||e.kind===`media-provider`}function H(e){return R(e)?e.hasConfigSchema||V(e)?!0:e.hasUi?z(e):!1:!1}function U(e){return H(e)||B(e)}var W=r(),G=(0,S.createContext)(null);function K({children:e}){let t=(0,S.useRef)(null);if(!t.current){let e=new I;L(e),t.current=e}let n=t.current,{data:r,isLoading:i,mutate:l}=c(o(e=>!!e.conversationId)?`gateway-extensions-list`:null,()=>s(a(`/api/extensions`)),{revalidateOnFocus:!1}),u=r?.extensions??[],d=b(e=>e.resolved);(0,S.useEffect)(()=>{let e=()=>{l()};return window.addEventListener(`config-reload`,e),window.addEventListener(`registry-updated`,e),()=>{window.removeEventListener(`config-reload`,e),window.removeEventListener(`registry-updated`,e)}},[l]);let f=(0,S.useCallback)(e=>{let t=e.detail;t?.conversationId&&n.forwardAgentStreamEvent(t.conversationId,t.event??t)},[n]),p=(0,S.useRef)(f);p.current=f,(0,S.useEffect)(()=>{let e=e=>{p.current(e)};return window.addEventListener(w,e),()=>{window.removeEventListener(w,e)}},[]),(0,S.useEffect)(()=>{let e=P(d);n.broadcastEvent(`theme.changed`,e)},[d,n]);let m=(0,S.useRef)(n);m.current=n,(0,S.useEffect)(()=>()=>{m.current.dispose(),t.current=null},[]);let h=(0,S.useMemo)(()=>({router:n,extensions:u,loading:i}),[n,u,i]);return(0,W.jsx)(G.Provider,{value:h,children:e})}function q(){let e=(0,S.useContext)(G);if(!e)throw Error(`useExtensionRouter must be used within ExtensionProvider`);return e.router}function J(){let e=(0,S.useContext)(G);if(!e)throw Error(`useExtensions must be used within ExtensionProvider`);return e.extensions}function Y(){let e=(0,C.c)(2),t=J(),n;return e[0]===t?n=e[1]:(n=t.filter(H),e[0]=t,e[1]=n),n}function X(){let e=(0,S.useContext)(G);if(!e)throw Error(`useExtensionsLoading must be used within ExtensionProvider`);return e.loading}export{Y as a,P as c,A as d,X as i,M as l,q as n,V as o,J as r,U as s,K as t,w as u};
|
|
@@ -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{f as i,t as a}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{a as o,i as s,l as c,n as l,o as u}from"./locale-store-5Hf8J8-_.js";import{t as d}from"./messages-uXxg5p54.js";import{t as f}from"./resource-unavailable-BUWsH3fp.js";import{n as p,r as m}from"./popover-select-DD8fmrxH.js";import{t as h}from"./cn-0WouolD0.js";import{i as g}from"./vendor-swr-CdRzEUwF.js";import{t as _}from"./button-CnRSIP6m.js";import{r as v}from"./extension-provider-BA0Y2Rvs.js";import{a as y,o as b,s as x}from"./form-field-width-DJw_jULe.js";import{t as S}from"./extension-iframe-host-CnOdNwbo.js";import{t as C}from"./settings-loading-skeleton-BTqvr_Fw.js";import{n as w,t as T}from"./settings-page-header-C8a_oOyw.js";import"./settings-page-layout-CTSRWljG.js";import{n as E,t as D}from"./use-autosave-B3p2QWaF.js";import{a as O,c as k,o as A}from"./voice-config-api-D9iNJSvm.js";import{t as j}from"./voice-api-key-field-DbSQHZZW.js";import{t as M}from"./schema-form-BKeP5G7b.js";var N=e(t(),1),P=n(),F=r();function I(e){let t=(0,P.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,F.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}function L(e){let t=e?.manifest?.mediaUnderstandingProviders?.[0];if(typeof t==`string`&&t.trim())return t.trim();let n=e?.manifest?.contracts?.mediaUnderstandingProviders?.[0];if(typeof n==`string`&&n.trim())return n.trim()}function R(){return h(b,y)}function z(){return h(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,x,`dark:border-edge`)}function B(e,t,n){if(!e||!t)return{apiKey:``,model:n};let r=e.stt.providers?.[t];return{apiKey:typeof r?.apiKey==`string`?r.apiKey:``,model:typeof r?.model==`string`?r.model:n}}function V({providerId:e,voiceSettings:t,mutateVoice:n}){let r=d(l(e=>e.language)),i=r.voiceSettings,a=r.extensionSttMedia,o={maskedHelp:i.apiKeyMaskedHelp,copy:i.apiKeyCopy,copied:i.apiKeyCopied,show:i.apiKeyShow,hide:i.apiKeyHide,notInConfigFile:i.apiKeyNotInConfigFile,loadFailed:i.apiKeyRevealFailed},{data:c}=g(s(`/api/voice/stt-providers`),A,{revalidateOnFocus:!1}),u=(0,N.useMemo)(()=>c?.providers.find(t=>t.id===e),[e,c]),f=u?.configured??!1,_=u?.models??[],v=_[0]?.id??u?.fields.find(e=>e.key===`model`)?.defaultValue??``,b=(0,N.useMemo)(()=>B(t,e,v),[v,e,t]),x=(0,N.useRef)(!1),[S,C]=(0,N.useState)(null),w=S??b,T=(0,N.useRef)(w);T.current=w;let O=b,M=D({value:w,dirty:w.apiKey!==O.apiKey||w.model!==O.model,onSave:(0,N.useCallback)(async r=>{let i=structuredClone(t);i.stt.enabled=!0,i.stt.provider=e,i.stt.providers={...i.stt.providers??{},[e]:{...i.stt.providers?.[e]??{},apiKey:r.apiKey,model:r.model}},await k(i,`transcription`),await n(i,!1),x.current=JSON.stringify(T.current)!==JSON.stringify(r),C(e=>e&&JSON.stringify(e)===JSON.stringify(r)?null:e)},[n,e,t])}),P=_.length>0?_:w.model?[{id:w.model,name:w.model}]:[];return(0,F.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-xl bg-surface-base p-4`,onBlurCapture:M.onBlurCapture,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:a.credentialsTitle}),(0,F.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a.credentialsHint.replace(`{providerId}`,e)})]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(E,{status:M.status,error:M.error}),(0,F.jsx)(`span`,{className:h(`rounded-full px-2 py-0.5 text-xs font-medium`,f?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-800 dark:text-amber-200`),children:f?a.configured:a.notConfigured})]})]}),(0,F.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,F.jsxs)(`div`,{className:h(`flex flex-col gap-1.5`,y),children:[(0,F.jsx)(I,{children:i.stt.apiKey}),(0,F.jsx)(j,{kind:`stt`,providerId:e,fieldId:`ext-stt-${e}-api-key`,value:w.apiKey,onChange:e=>{x.current=!0,C(t=>({...t??b,apiKey:e}))},labels:o,placeholder:e===`groq`?`gsk_...`:`sk-...`}),(0,F.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[i.stt.apiKeyDesc,e===`groq`?` (GROQ_API_KEY)`:``]})]}),(0,F.jsxs)(`div`,{className:h(`flex flex-col gap-1.5`,y),children:[(0,F.jsx)(I,{children:i.stt.model}),P.length>0?(0,F.jsx)(p,{className:R(),value:w.model,onChange:e=>{x.current=!0,C(t=>({...t??b,model:e.target.value})),M.saveNow({...w,model:e.target.value})},children:P.map(e=>(0,F.jsx)(m,{value:e.id,children:e.name},e.id))}):(0,F.jsx)(`input`,{className:z(),value:w.model,onChange:e=>{x.current=!0,C(t=>({...t??b,model:e.target.value}))}})]})]})]})}function H(e){let t=(0,P.c)(13),{extensionId:n}=e,r=l(W),i=c(U),a;t[0]===n?a=t[1]:(a=()=>u(s(`/api/extensions/${encodeURIComponent(n)}`)),t[0]=n,t[1]=a);let{data:o,isLoading:d}=g(i&&n?`ext-stt-detail-${n}`:null,a),f;t[2]===o?f=t[3]:(f=L(o),t[2]=o,t[3]=f);let p=f,m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m={revalidateOnFocus:!1},t[4]=m):m=t[4];let{data:h,mutate:_,isLoading:v}=g(i?`voice-settings-ext-stt`:null,O,m);if(!i)return null;if(d||v){let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,F.jsx)(C,{rows:2}),t[5]=e):e=t[5],e}if(!p){let e=r===`zh`?`该插件未声明 mediaUnderstandingProviders。`:`This plugin does not declare mediaUnderstandingProviders.`,n;return t[6]===e?n=t[7]:(n=(0,F.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[6]=e,t[7]=n),n}if(!h)return null;let y=`${n}:${p}`,b;return t[8]!==_||t[9]!==p||t[10]!==y||t[11]!==h?(b=(0,F.jsx)(V,{providerId:p,voiceSettings:h,mutateVoice:_},y),t[8]=_,t[9]=p,t[10]=y,t[11]=h,t[12]=b):b=t[12],b}function U(e){return!!e.conversationId}function W(e){return e.language}function G(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function K(e){let t={};if(e.type!==`object`||!G(e.properties))return t;for(let[n,r]of Object.entries(e.properties))G(r)&&Object.prototype.hasOwnProperty.call(r,`default`)&&(t[n]=r.default);return t}function q(e,t){switch(t.type){case`sync`:return{localValues:t.value,isDirty:!1};case`change`:return{localValues:t.value,isDirty:!0};case`reset-defaults`:return{localValues:t.value,isDirty:!0};case`saved`:return JSON.stringify(e.localValues)===JSON.stringify(t.value)?{localValues:e.localValues,isDirty:!1}:e}}function J({extensionId:e}){let t=c(e=>!!e.conversationId),{data:n,error:r}=g(t&&e?`ext-detail-${e}`:null,()=>u(s(`/api/extensions/${encodeURIComponent(e)}`))),{data:i,mutate:a,error:l}=g(t&&e?`ext-cfg-${e}`:null,()=>u(s(`/api/extensions/${encodeURIComponent(e)}/config`))),d=n?.manifest?.configSchema,f=(0,N.useMemo)(()=>d&&d.type===`object`?K(d):{},[d]),p=(0,N.useMemo)(()=>({...f,...i??{}}),[f,i]),[m,h]=(0,N.useReducer)(q,{localValues:{},isDirty:!1}),v=(0,N.useRef)(!1),y=(0,N.useRef)(m.localValues);y.current=m.localValues;let b=(0,N.useRef)(p);!v.current&&b.current!==p&&(b.current=p,h({type:`sync`,value:p}));let x=(0,N.useCallback)(e=>{v.current=!0,h({type:`change`,value:e})},[]),S=(0,N.useCallback)(()=>{!d||d.type!==`object`||(v.current=!0,h({type:`reset-defaults`,value:{...K(d)}}))},[d]),C=(0,N.useCallback)(async t=>{if(!e)return;let n=await o(s(`/api/extensions/${encodeURIComponent(e)}/config`),{method:`PATCH`,body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error?.message??n.statusText)}await a(t,!1),h({type:`saved`,value:t}),v.current=JSON.stringify(y.current)!==JSON.stringify(t)},[e,a]),w=D({value:m.localValues,dirty:m.isDirty,onSave:C});if(!t)return null;if(r||l){let e=r??l;return(0,F.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[`Could not load extension settings: `,e instanceof Error?e.message:String(e)]})}return!d||d.type!==`object`?null:(0,F.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-surface-hover/20 p-4`,onBlurCapture:w.onBlurCapture,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,F.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Configuration`}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(E,{status:w.status,error:w.error}),(0,F.jsx)(_,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:S,children:`Reset to defaults`})]})]}),(0,F.jsx)(M,{schema:d,values:m.localValues,onChange:x})]})}function Y(){let e=(0,P.c)(36),t=l(X),n;e[0]===t?n=e[1]:(n=d(t),e[0]=t,e[1]=n);let r=n.extensionSttMedia,{extensionId:o,panelId:s}=i(),c=v();if(!o){let t;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,F.jsx)(f,{kind:`plugin`,backTo:`/capabilities/extensions`}),e[2]=t):t=e[2],t}let u,p,m;if(e[3]!==o||e[4]!==c||e[5]!==s){m=Symbol.for(`react.early_return_sentinel`);bb0:{let t;if(e[9]===o?t=e[10]:(t=e=>e.id===o,e[9]=o,e[10]=t),u=c.find(t),!u){let t;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,F.jsx)(f,{kind:`plugin`,backTo:`/capabilities/extensions`}),e[11]=t):t=e[11],m=t;break bb0}let n=u.ui?.contributions?.settingsPanels;p=s?n?.find(e=>e.id===s||e.id===`${o}.${s}`):n?.[0]}e[3]=o,e[4]=c,e[5]=s,e[6]=u,e[7]=p,e[8]=m}else u=e[6],p=e[7],m=e[8];if(m!==Symbol.for(`react.early_return_sentinel`))return m;let h=p,g=!!(h&&u.ui),_=!!u.hasConfigSchema,y=u.kind===`media-provider`;if(!_&&!g&&!y){let t;return e[12]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,F.jsx)(f,{kind:`plugin-settings`,backTo:`/capabilities/extensions`}),e[12]=t):t=e[12],t}let b=h?.title??(t===`zh`?`${u.name} 设置`:`${u.name} Settings`),x;e[13]===b?x=e[14]:(x=(0,F.jsx)(T,{title:b}),e[13]=b,e[14]=x);let C;e[15]!==y||e[16]!==r?(C=y?(0,F.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base px-4 py-3 text-sm`,children:[(0,F.jsx)(`p`,{className:`leading-relaxed text-fg-muted`,children:r.banner}),(0,F.jsx)(a,{to:`/settings/capabilities/models?configure=transcription`,className:`w-fit font-medium text-accent hover:underline`,children:r.openVoice})]}):null,e[15]=y,e[16]=r,e[17]=C):C=e[17];let E;e[18]!==o||e[19]!==y?(E=y?(0,F.jsx)(H,{extensionId:o}):null,e[18]=o,e[19]=y,e[20]=E):E=e[20];let D;e[21]!==o||e[22]!==_?(D=_?(0,F.jsx)(J,{extensionId:o}):null,e[21]=o,e[22]=_,e[23]=D):D=e[23];let O;e[24]!==u.name||e[25]!==u.ui||e[26]!==o||e[27]!==g||e[28]!==h?(O=g&&h&&u.ui?(0,F.jsx)(`div`,{className:`overflow-hidden rounded-xl bg-surface-base shadow-surface`,children:(0,F.jsx)(S,{extensionId:o,extensionName:u.name,entrypoint:h.entrypoint,permissions:u.ui?.permissions,title:h.title,className:`w-full`,minHeight:120,maxHeight:2e3})}):null,e[24]=u.name,e[25]=u.ui,e[26]=o,e[27]=g,e[28]=h,e[29]=O):O=e[29];let k;return e[30]!==x||e[31]!==C||e[32]!==E||e[33]!==D||e[34]!==O?(k=(0,F.jsxs)(w,{gap:`gap-5`,children:[x,C,E,D,O]}),e[30]=x,e[31]=C,e[32]=E,e[33]=D,e[34]=O,e[35]=k):k=e[35],k}function X(e){return e.language}export{Y as ExtensionSettingsPage};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i,t as a}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{a as o,i as s,l as c,n as l,o as u}from"./locale-store-VNjH18Dj.js";import{t as d}from"./messages-Btr7C0hF.js";import{t as f}from"./resource-unavailable-35wBZxmz.js";import{n as p,r as m}from"./popover-select-DD8fmrxH.js";import{t as h}from"./cn-0WouolD0.js";import{i as g}from"./vendor-swr-CdRzEUwF.js";import{t as _}from"./button-CnRSIP6m.js";import{r as v}from"./extension-provider-B2Mf3FBu.js";import{a as y,o as b,s as x}from"./form-field-width-DJw_jULe.js";import{t as S}from"./extension-iframe-host-vlZVeMCY.js";import{t as C}from"./settings-loading-skeleton-BTqvr_Fw.js";import{n as w,t as T}from"./settings-page-header-CsPAYlqV.js";import"./settings-page-layout-lPLeJQoV.js";import{n as E,t as D}from"./use-autosave-B7cbumro.js";import{a as O,c as k,o as A}from"./voice-config-api-wotvT6Hw.js";import{t as j}from"./voice-api-key-field-DzYdJZN4.js";import{t as M}from"./schema-form-BKeP5G7b.js";var N=e(t(),1),P=n(),F=r();function I(e){let t=(0,P.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,F.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}function L(e){let t=e?.manifest?.mediaUnderstandingProviders?.[0];if(typeof t==`string`&&t.trim())return t.trim();let n=e?.manifest?.contracts?.mediaUnderstandingProviders?.[0];if(typeof n==`string`&&n.trim())return n.trim()}function R(){return h(b,y)}function z(){return h(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,x,`dark:border-edge`)}function B(e,t,n){if(!e||!t)return{apiKey:``,model:n};let r=e.stt.providers?.[t];return{apiKey:typeof r?.apiKey==`string`?r.apiKey:``,model:typeof r?.model==`string`?r.model:n}}function V({providerId:e,voiceSettings:t,mutateVoice:n}){let r=d(l(e=>e.language)),i=r.voiceSettings,a=r.extensionSttMedia,o={maskedHelp:i.apiKeyMaskedHelp,copy:i.apiKeyCopy,copied:i.apiKeyCopied,show:i.apiKeyShow,hide:i.apiKeyHide,notInConfigFile:i.apiKeyNotInConfigFile,loadFailed:i.apiKeyRevealFailed},{data:c}=g(s(`/api/voice/stt-providers`),A,{revalidateOnFocus:!1}),u=(0,N.useMemo)(()=>c?.providers.find(t=>t.id===e),[e,c]),f=u?.configured??!1,_=u?.models??[],v=_[0]?.id??u?.fields.find(e=>e.key===`model`)?.defaultValue??``,b=(0,N.useMemo)(()=>B(t,e,v),[v,e,t]),x=(0,N.useRef)(!1),[S,C]=(0,N.useState)(null),w=S??b,T=(0,N.useRef)(w);T.current=w;let O=b,M=D({value:w,dirty:w.apiKey!==O.apiKey||w.model!==O.model,onSave:(0,N.useCallback)(async r=>{let i=structuredClone(t);i.stt.enabled=!0,i.stt.provider=e,i.stt.providers={...i.stt.providers??{},[e]:{...i.stt.providers?.[e]??{},apiKey:r.apiKey,model:r.model}},await k(i,`transcription`),await n(i,!1),x.current=JSON.stringify(T.current)!==JSON.stringify(r),C(e=>e&&JSON.stringify(e)===JSON.stringify(r)?null:e)},[n,e,t])}),P=_.length>0?_:w.model?[{id:w.model,name:w.model}]:[];return(0,F.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-xl bg-surface-base p-4`,onBlurCapture:M.onBlurCapture,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:a.credentialsTitle}),(0,F.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a.credentialsHint.replace(`{providerId}`,e)})]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(E,{status:M.status,error:M.error}),(0,F.jsx)(`span`,{className:h(`rounded-full px-2 py-0.5 text-xs font-medium`,f?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-800 dark:text-amber-200`),children:f?a.configured:a.notConfigured})]})]}),(0,F.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,F.jsxs)(`div`,{className:h(`flex flex-col gap-1.5`,y),children:[(0,F.jsx)(I,{children:i.stt.apiKey}),(0,F.jsx)(j,{kind:`stt`,providerId:e,fieldId:`ext-stt-${e}-api-key`,value:w.apiKey,onChange:e=>{x.current=!0,C(t=>({...t??b,apiKey:e}))},labels:o,placeholder:e===`groq`?`gsk_...`:`sk-...`}),(0,F.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[i.stt.apiKeyDesc,e===`groq`?` (GROQ_API_KEY)`:``]})]}),(0,F.jsxs)(`div`,{className:h(`flex flex-col gap-1.5`,y),children:[(0,F.jsx)(I,{children:i.stt.model}),P.length>0?(0,F.jsx)(p,{className:R(),value:w.model,onChange:e=>{x.current=!0,C(t=>({...t??b,model:e.target.value})),M.saveNow({...w,model:e.target.value})},children:P.map(e=>(0,F.jsx)(m,{value:e.id,children:e.name},e.id))}):(0,F.jsx)(`input`,{className:z(),value:w.model,onChange:e=>{x.current=!0,C(t=>({...t??b,model:e.target.value}))}})]})]})]})}function H(e){let t=(0,P.c)(13),{extensionId:n}=e,r=l(W),i=c(U),a;t[0]===n?a=t[1]:(a=()=>u(s(`/api/extensions/${encodeURIComponent(n)}`)),t[0]=n,t[1]=a);let{data:o,isLoading:d}=g(i&&n?`ext-stt-detail-${n}`:null,a),f;t[2]===o?f=t[3]:(f=L(o),t[2]=o,t[3]=f);let p=f,m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m={revalidateOnFocus:!1},t[4]=m):m=t[4];let{data:h,mutate:_,isLoading:v}=g(i?`voice-settings-ext-stt`:null,O,m);if(!i)return null;if(d||v){let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,F.jsx)(C,{rows:2}),t[5]=e):e=t[5],e}if(!p){let e=r===`zh`?`该插件未声明 mediaUnderstandingProviders。`:`This plugin does not declare mediaUnderstandingProviders.`,n;return t[6]===e?n=t[7]:(n=(0,F.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[6]=e,t[7]=n),n}if(!h)return null;let y=`${n}:${p}`,b;return t[8]!==_||t[9]!==p||t[10]!==y||t[11]!==h?(b=(0,F.jsx)(V,{providerId:p,voiceSettings:h,mutateVoice:_},y),t[8]=_,t[9]=p,t[10]=y,t[11]=h,t[12]=b):b=t[12],b}function U(e){return!!e.conversationId}function W(e){return e.language}function G(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function K(e){let t={};if(e.type!==`object`||!G(e.properties))return t;for(let[n,r]of Object.entries(e.properties))G(r)&&Object.prototype.hasOwnProperty.call(r,`default`)&&(t[n]=r.default);return t}function q(e,t){switch(t.type){case`sync`:return{localValues:t.value,isDirty:!1};case`change`:return{localValues:t.value,isDirty:!0};case`reset-defaults`:return{localValues:t.value,isDirty:!0};case`saved`:return JSON.stringify(e.localValues)===JSON.stringify(t.value)?{localValues:e.localValues,isDirty:!1}:e}}function J({extensionId:e}){let t=c(e=>!!e.conversationId),{data:n,error:r}=g(t&&e?`ext-detail-${e}`:null,()=>u(s(`/api/extensions/${encodeURIComponent(e)}`))),{data:i,mutate:a,error:l}=g(t&&e?`ext-cfg-${e}`:null,()=>u(s(`/api/extensions/${encodeURIComponent(e)}/config`))),d=n?.manifest?.configSchema,f=(0,N.useMemo)(()=>d&&d.type===`object`?K(d):{},[d]),p=(0,N.useMemo)(()=>({...f,...i??{}}),[f,i]),[m,h]=(0,N.useReducer)(q,{localValues:{},isDirty:!1}),v=(0,N.useRef)(!1),y=(0,N.useRef)(m.localValues);y.current=m.localValues;let b=(0,N.useRef)(p);!v.current&&b.current!==p&&(b.current=p,h({type:`sync`,value:p}));let x=(0,N.useCallback)(e=>{v.current=!0,h({type:`change`,value:e})},[]),S=(0,N.useCallback)(()=>{!d||d.type!==`object`||(v.current=!0,h({type:`reset-defaults`,value:{...K(d)}}))},[d]),C=(0,N.useCallback)(async t=>{if(!e)return;let n=await o(s(`/api/extensions/${encodeURIComponent(e)}/config`),{method:`PATCH`,body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error?.message??n.statusText)}await a(t,!1),h({type:`saved`,value:t}),v.current=JSON.stringify(y.current)!==JSON.stringify(t)},[e,a]),w=D({value:m.localValues,dirty:m.isDirty,onSave:C});if(!t)return null;if(r||l){let e=r??l;return(0,F.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[`Could not load extension settings: `,e instanceof Error?e.message:String(e)]})}return!d||d.type!==`object`?null:(0,F.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-surface-hover/20 p-4`,onBlurCapture:w.onBlurCapture,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,F.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Configuration`}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(E,{status:w.status,error:w.error}),(0,F.jsx)(_,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:S,children:`Reset to defaults`})]})]}),(0,F.jsx)(M,{schema:d,values:m.localValues,onChange:x})]})}function Y(){let e=(0,P.c)(36),t=l(X),n;e[0]===t?n=e[1]:(n=d(t),e[0]=t,e[1]=n);let r=n.extensionSttMedia,{extensionId:o,panelId:s}=i(),c=v();if(!o){let t;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,F.jsx)(f,{kind:`plugin`,backTo:`/capabilities/extensions`}),e[2]=t):t=e[2],t}let u,p,m;if(e[3]!==o||e[4]!==c||e[5]!==s){m=Symbol.for(`react.early_return_sentinel`);bb0:{let t;if(e[9]===o?t=e[10]:(t=e=>e.id===o,e[9]=o,e[10]=t),u=c.find(t),!u){let t;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,F.jsx)(f,{kind:`plugin`,backTo:`/capabilities/extensions`}),e[11]=t):t=e[11],m=t;break bb0}let n=u.ui?.contributions?.settingsPanels;p=s?n?.find(e=>e.id===s||e.id===`${o}.${s}`):n?.[0]}e[3]=o,e[4]=c,e[5]=s,e[6]=u,e[7]=p,e[8]=m}else u=e[6],p=e[7],m=e[8];if(m!==Symbol.for(`react.early_return_sentinel`))return m;let h=p,g=!!(h&&u.ui),_=!!u.hasConfigSchema,y=u.kind===`media-provider`;if(!_&&!g&&!y){let t;return e[12]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,F.jsx)(f,{kind:`plugin-settings`,backTo:`/capabilities/extensions`}),e[12]=t):t=e[12],t}let b=h?.title??(t===`zh`?`${u.name} 设置`:`${u.name} Settings`),x;e[13]===b?x=e[14]:(x=(0,F.jsx)(T,{title:b}),e[13]=b,e[14]=x);let C;e[15]!==y||e[16]!==r?(C=y?(0,F.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base px-4 py-3 text-sm`,children:[(0,F.jsx)(`p`,{className:`leading-relaxed text-fg-muted`,children:r.banner}),(0,F.jsx)(a,{to:`/settings/capabilities/models?configure=transcription`,className:`w-fit font-medium text-accent hover:underline`,children:r.openVoice})]}):null,e[15]=y,e[16]=r,e[17]=C):C=e[17];let E;e[18]!==o||e[19]!==y?(E=y?(0,F.jsx)(H,{extensionId:o}):null,e[18]=o,e[19]=y,e[20]=E):E=e[20];let D;e[21]!==o||e[22]!==_?(D=_?(0,F.jsx)(J,{extensionId:o}):null,e[21]=o,e[22]=_,e[23]=D):D=e[23];let O;e[24]!==u.name||e[25]!==u.ui||e[26]!==o||e[27]!==g||e[28]!==h?(O=g&&h&&u.ui?(0,F.jsx)(`div`,{className:`overflow-hidden rounded-xl bg-surface-base shadow-surface`,children:(0,F.jsx)(S,{extensionId:o,extensionName:u.name,entrypoint:h.entrypoint,permissions:u.ui?.permissions,title:h.title,className:`w-full`,minHeight:120,maxHeight:2e3})}):null,e[24]=u.name,e[25]=u.ui,e[26]=o,e[27]=g,e[28]=h,e[29]=O):O=e[29];let k;return e[30]!==x||e[31]!==C||e[32]!==E||e[33]!==D||e[34]!==O?(k=(0,F.jsxs)(w,{gap:`gap-5`,children:[x,C,E,D,O]}),e[30]=x,e[31]=C,e[32]=E,e[33]=D,e[34]=O,e[35]=k):k=e[35],k}function X(e){return e.language}export{Y as ExtensionSettingsPage};
|