@hienlh/ppm 0.23.20 → 0.23.22
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/CHANGELOG.md +26 -0
- package/CLAUDE.md +3 -2
- package/assets/skills/ppm/SKILL.md +1 -1
- package/assets/skills/ppm/references/http-api.md +1 -1
- package/dist/web/assets/{accounts-settings-section-BTga1zwH.js → accounts-settings-section-CiNmIj02.js} +1 -1
- package/dist/web/assets/accounts-settings-section-CiNmIj02.js.br +0 -0
- package/dist/web/assets/accounts-settings-section-CiNmIj02.js.gz +0 -0
- package/dist/web/assets/{agent-session-sheet-Q3kasbrZ.js → agent-session-sheet-DRR36PDA.js} +2 -2
- package/dist/web/assets/agent-session-sheet-DRR36PDA.js.br +0 -0
- package/dist/web/assets/agent-session-sheet-DRR36PDA.js.gz +0 -0
- package/dist/web/assets/{agent-session-window-content-UNuEprIK.js → agent-session-window-content-DMhy16BM.js} +1 -1
- package/dist/web/assets/agent-session-window-content-DMhy16BM.js.br +0 -0
- package/dist/web/assets/agent-session-window-content-DMhy16BM.js.gz +0 -0
- package/dist/web/assets/{ai-resource-editor-BEwA6Do0.js → ai-resource-editor-BG8boPw7.js} +1 -1
- package/dist/web/assets/ai-resource-editor-BG8boPw7.js.br +0 -0
- package/dist/web/assets/ai-resource-editor-BG8boPw7.js.gz +0 -0
- package/dist/web/assets/{ai-settings-section-DVKJPM0n.js → ai-settings-section-DMGM1hYx.js} +1 -1
- package/dist/web/assets/ai-settings-section-DMGM1hYx.js.br +0 -0
- package/dist/web/assets/ai-settings-section-DMGM1hYx.js.gz +0 -0
- package/dist/web/assets/{ai-settings-section-DlfY5lFT.js → ai-settings-section-De5dYWlC.js} +1 -1
- package/dist/web/assets/{android-tab-BNa6R9fV.js → android-tab-lHDxD93G.js} +1 -1
- package/dist/web/assets/android-tab-lHDxD93G.js.br +0 -0
- package/dist/web/assets/android-tab-lHDxD93G.js.gz +0 -0
- package/dist/web/assets/{appearance-settings-section-CjWFwWNn.js → appearance-settings-section-DO-ZyoMj.js} +1 -1
- package/dist/web/assets/appearance-settings-section-DO-ZyoMj.js.br +0 -0
- package/dist/web/assets/appearance-settings-section-DO-ZyoMj.js.gz +0 -0
- package/dist/web/assets/{apps-panel-D4xjeMN9.js → apps-panel-CH-0CHYY.js} +1 -1
- package/dist/web/assets/apps-panel-CH-0CHYY.js.br +0 -0
- package/dist/web/assets/apps-panel-CH-0CHYY.js.gz +0 -0
- package/dist/web/assets/{branch-review-tab-BCW5294d.js → branch-review-tab-CdGtvekz.js} +1 -1
- package/dist/web/assets/branch-review-tab-CdGtvekz.js.br +0 -0
- package/dist/web/assets/branch-review-tab-CdGtvekz.js.gz +0 -0
- package/dist/web/assets/{chat-tab-BG0M1D3d.js → chat-tab-DMqWnFIo.js} +1 -1
- package/dist/web/assets/chat-tab-DMqWnFIo.js.br +0 -0
- package/dist/web/assets/chat-tab-DMqWnFIo.js.gz +0 -0
- package/dist/web/assets/{chat-tab-DsW93LTL.js → chat-tab-DzWpwPFb.js} +4 -4
- package/dist/web/assets/chat-tab-DzWpwPFb.js.br +0 -0
- package/dist/web/assets/chat-tab-DzWpwPFb.js.gz +0 -0
- package/dist/web/assets/{code-editor-AxLIpK-b.js → code-editor-BCv8ONNS.js} +4 -4
- package/dist/web/assets/code-editor-BCv8ONNS.js.br +0 -0
- package/dist/web/assets/code-editor-BCv8ONNS.js.gz +0 -0
- package/dist/web/assets/{codex-reset-credit-button-BnRmkBZu.js → codex-reset-credit-button-CGMbIHak.js} +1 -1
- package/dist/web/assets/codex-reset-credit-button-CGMbIHak.js.br +0 -0
- package/dist/web/assets/codex-reset-credit-button-CGMbIHak.js.gz +0 -0
- package/dist/web/assets/{conflict-editor-BwuNUPAK.js → conflict-editor-3WmzqBlW.js} +1 -1
- package/dist/web/assets/conflict-editor-3WmzqBlW.js.br +0 -0
- package/dist/web/assets/conflict-editor-3WmzqBlW.js.gz +0 -0
- package/dist/web/assets/{connection-form-tab-CM2o80eB.js → connection-form-tab-BoWucvAe.js} +1 -1
- package/dist/web/assets/connection-form-tab-BoWucvAe.js.br +0 -0
- package/dist/web/assets/connection-form-tab-BoWucvAe.js.gz +0 -0
- package/dist/web/assets/{csv-preview-C7ErHm4U.js → csv-preview-BCgGsy7F.js} +1 -1
- package/dist/web/assets/csv-preview-BCgGsy7F.js.br +0 -0
- package/dist/web/assets/csv-preview-BCgGsy7F.js.gz +0 -0
- package/dist/web/assets/{db-tab-parts-C8jbkfxO.js → db-tab-parts-o6QMHBbA.js} +1 -1
- package/dist/web/assets/db-tab-parts-o6QMHBbA.js.br +0 -0
- package/dist/web/assets/db-tab-parts-o6QMHBbA.js.gz +0 -0
- package/dist/web/assets/{design-settings-section-BcGEY4Zf.js → design-settings-section-seo6SdSk.js} +1 -1
- package/dist/web/assets/design-settings-section-seo6SdSk.js.br +0 -0
- package/dist/web/assets/design-settings-section-seo6SdSk.js.gz +0 -0
- package/dist/web/assets/{design-tab-BGPYNFvy.js → design-tab-B-f_b2LM.js} +1 -1
- package/dist/web/assets/design-tab-B-f_b2LM.js.br +0 -0
- package/dist/web/assets/design-tab-B-f_b2LM.js.gz +0 -0
- package/dist/web/assets/{designs-sidebar-panel-BgMj7xRm.js → designs-sidebar-panel-CVT_TQP7.js} +1 -1
- package/dist/web/assets/designs-sidebar-panel-CVT_TQP7.js.br +0 -0
- package/dist/web/assets/designs-sidebar-panel-CVT_TQP7.js.gz +0 -0
- package/dist/web/assets/{diff-viewer-BKJkesHk.js → diff-viewer-y9uBp_8u.js} +1 -1
- package/dist/web/assets/diff-viewer-y9uBp_8u.js.br +0 -0
- package/dist/web/assets/diff-viewer-y9uBp_8u.js.gz +0 -0
- package/dist/web/assets/{docx-preview-DD5oD_nL.js → docx-preview-Dn_x3Inm.js} +1 -1
- package/dist/web/assets/docx-preview-Dn_x3Inm.js.br +0 -0
- package/dist/web/assets/docx-preview-Dn_x3Inm.js.gz +0 -0
- package/dist/web/assets/{editor-dialog--07lKJxl.js → editor-dialog-BwNXSajD.js} +1 -1
- package/dist/web/assets/editor-dialog-BwNXSajD.js.br +0 -0
- package/dist/web/assets/editor-dialog-BwNXSajD.js.gz +0 -0
- package/dist/web/assets/{editor-language-service-51xjO5d3.js → editor-language-service-XA_TnPLN.js} +1 -1
- package/dist/web/assets/editor-language-service-XA_TnPLN.js.br +0 -0
- package/dist/web/assets/editor-language-service-XA_TnPLN.js.gz +0 -0
- package/dist/web/assets/{explorer-body-BXK5SjJQ.js → explorer-body-DukR7zM9.js} +1 -1
- package/dist/web/assets/explorer-body-DukR7zM9.js.br +0 -0
- package/dist/web/assets/explorer-body-DukR7zM9.js.gz +0 -0
- package/dist/web/assets/{explorer-window-content-DKXcCmuX.js → explorer-window-content-BjTZ44S3.js} +1 -1
- package/dist/web/assets/explorer-window-content-BjTZ44S3.js.br +0 -0
- package/dist/web/assets/explorer-window-content-BjTZ44S3.js.gz +0 -0
- package/dist/web/assets/{extension-manager-section-CTpQP6te.js → extension-manager-section-C4WD1BPQ.js} +1 -1
- package/dist/web/assets/extension-manager-section-C4WD1BPQ.js.br +0 -0
- package/dist/web/assets/extension-manager-section-C4WD1BPQ.js.gz +0 -0
- package/dist/web/assets/{extension-webview-COT-yLrM.js → extension-webview-CV2ujflc.js} +1 -1
- package/dist/web/assets/extension-webview-CV2ujflc.js.br +0 -0
- package/dist/web/assets/extension-webview-CV2ujflc.js.gz +0 -0
- package/dist/web/assets/{files-settings-section-CgVR0fqi.js → files-settings-section-hS5ixQ8o.js} +1 -1
- package/dist/web/assets/files-settings-section-hS5ixQ8o.js.br +0 -0
- package/dist/web/assets/files-settings-section-hS5ixQ8o.js.gz +0 -0
- package/dist/web/assets/{general-settings-section-BEMIbE4Y.js → general-settings-section-BnKYY0AA.js} +1 -1
- package/dist/web/assets/general-settings-section-BnKYY0AA.js.br +0 -0
- package/dist/web/assets/general-settings-section-BnKYY0AA.js.gz +0 -0
- package/dist/web/assets/{git-log-panel-Cp2174iI.js → git-log-panel-JiWfR5xv.js} +1 -1
- package/dist/web/assets/git-log-panel-JiWfR5xv.js.br +0 -0
- package/dist/web/assets/git-log-panel-JiWfR5xv.js.gz +0 -0
- package/dist/web/assets/{git-review-tab-CpMJ0qDi.js → git-review-tab-DgvcY__Q.js} +1 -1
- package/dist/web/assets/git-review-tab-DgvcY__Q.js.br +0 -0
- package/dist/web/assets/git-review-tab-DgvcY__Q.js.gz +0 -0
- package/dist/web/assets/{glide-data-grid-BAhwWUhO.js → glide-data-grid-r1MKxDjz.js} +1 -1
- package/dist/web/assets/glide-data-grid-r1MKxDjz.js.br +0 -0
- package/dist/web/assets/glide-data-grid-r1MKxDjz.js.gz +0 -0
- package/dist/web/assets/{grid-save-dialog-DmJhaWOl.js → grid-save-dialog-Fa0yA-Ep.js} +1 -1
- package/dist/web/assets/grid-save-dialog-Fa0yA-Ep.js.br +0 -0
- package/dist/web/assets/grid-save-dialog-Fa0yA-Ep.js.gz +0 -0
- package/dist/web/assets/{group-chat-tab-Bq7-Yegf.js → group-chat-tab-B2Q8yqSX.js} +1 -1
- package/dist/web/assets/group-chat-tab-B2Q8yqSX.js.br +0 -0
- package/dist/web/assets/group-chat-tab-B2Q8yqSX.js.gz +0 -0
- package/dist/web/assets/{impexp-tab-COx3Cvs7.js → impexp-tab-B8Ht4l32.js} +1 -1
- package/dist/web/assets/impexp-tab-B8Ht4l32.js.br +0 -0
- package/dist/web/assets/impexp-tab-B8Ht4l32.js.gz +0 -0
- package/dist/web/assets/{index-BGk8EFQb.js → index-BtAn_krv.js} +5 -5
- package/dist/web/assets/index-BtAn_krv.js.br +0 -0
- package/dist/web/assets/index-BtAn_krv.js.gz +0 -0
- package/dist/web/assets/{jira-watcher-section-BEPbsi62.js → jira-watcher-section--ibKZfBs.js} +1 -1
- package/dist/web/assets/{keybindings-store-DzcSIJUF.js → keybindings-store-Cwxl4tHv.js} +1 -1
- package/dist/web/assets/{keyboard-shortcuts-section-Bqg7AZiZ.js → keyboard-shortcuts-section-aoiLpWwf.js} +1 -1
- package/dist/web/assets/keyboard-shortcuts-section-aoiLpWwf.js.br +0 -0
- package/dist/web/assets/keyboard-shortcuts-section-aoiLpWwf.js.gz +0 -0
- package/dist/web/assets/{language-servers-section-CJ47DSIA.js → language-servers-section-BkGAezo6.js} +2 -2
- package/dist/web/assets/language-servers-section-BkGAezo6.js.br +0 -0
- package/dist/web/assets/language-servers-section-BkGAezo6.js.gz +0 -0
- package/dist/web/assets/{logs-app-BK-n-y_K.js → logs-app-DYgPtmjm.js} +1 -1
- package/dist/web/assets/logs-app-DYgPtmjm.js.br +0 -0
- package/dist/web/assets/logs-app-DYgPtmjm.js.gz +0 -0
- package/dist/web/assets/{logs-tab-B84EZJ1b.js → logs-tab-BbDosK63.js} +1 -1
- package/dist/web/assets/{logs-window-content-B1uN_3pN.js → logs-window-content-CEXAyv-f.js} +1 -1
- package/dist/web/assets/{lsp-client-DHSaAyJW.js → lsp-client-CIcphNmU.js} +1 -1
- package/dist/web/assets/lsp-client-CIcphNmU.js.br +0 -0
- package/dist/web/assets/lsp-client-CIcphNmU.js.gz +0 -0
- package/dist/web/assets/{markdown-renderer-BjDQUqT-.js → markdown-renderer-BNzQeoAO.js} +1 -1
- package/dist/web/assets/{markdown-renderer-CpxdNG0f.js → markdown-renderer-dk1w3goH.js} +1 -1
- package/dist/web/assets/markdown-renderer-dk1w3goH.js.br +0 -0
- package/dist/web/assets/markdown-renderer-dk1w3goH.js.gz +0 -0
- package/dist/web/assets/{mobile-explorer-sheet-BBwXGmXA.js → mobile-explorer-sheet-D4lPZQZc.js} +1 -1
- package/dist/web/assets/mobile-explorer-sheet-D4lPZQZc.js.br +0 -0
- package/dist/web/assets/mobile-explorer-sheet-D4lPZQZc.js.gz +0 -0
- package/dist/web/assets/{new-design-dialog-B_ZOvGhR.js → new-design-dialog-CIq7xspW.js} +1 -1
- package/dist/web/assets/new-design-dialog-CIq7xspW.js.br +0 -0
- package/dist/web/assets/new-design-dialog-CIq7xspW.js.gz +0 -0
- package/dist/web/assets/{notification-store-HuMqfadD.js → notification-store-Rv36noYX.js} +1 -1
- package/dist/web/assets/notifications-settings-section-CoWMtXCC.js +1 -0
- package/dist/web/assets/notifications-settings-section-CoWMtXCC.js.br +0 -0
- package/dist/web/assets/notifications-settings-section-CoWMtXCC.js.gz +0 -0
- package/dist/web/assets/{ppmbot-settings-section-JDvyI-gZ.js → ppmbot-settings-section-Ct0UwA6T.js} +1 -1
- package/dist/web/assets/ppmbot-settings-section-Ct0UwA6T.js.br +0 -0
- package/dist/web/assets/ppmbot-settings-section-Ct0UwA6T.js.gz +0 -0
- package/dist/web/assets/{problems-panel-Bsv_L6T2.js → problems-panel-D-HT-0PE.js} +1 -1
- package/dist/web/assets/problems-panel-D-HT-0PE.js.br +0 -0
- package/dist/web/assets/problems-panel-D-HT-0PE.js.gz +0 -0
- package/dist/web/assets/{process-table-3kZyWOJx.js → process-table-CXN0s4Pq.js} +1 -1
- package/dist/web/assets/process-table-CXN0s4Pq.js.br +0 -0
- package/dist/web/assets/process-table-CXN0s4Pq.js.gz +0 -0
- package/dist/web/assets/{proxy-settings-section-CYcmIp7W.js → proxy-settings-section-e6WWzP8n.js} +1 -1
- package/dist/web/assets/proxy-settings-section-e6WWzP8n.js.br +0 -0
- package/dist/web/assets/proxy-settings-section-e6WWzP8n.js.gz +0 -0
- package/dist/web/assets/{query-tab-CjrWnQUl.js → query-tab-C7C67t8F.js} +1 -1
- package/dist/web/assets/query-tab-C7C67t8F.js.br +0 -0
- package/dist/web/assets/query-tab-C7C67t8F.js.gz +0 -0
- package/dist/web/assets/{remote-access-settings-section-iQkakiVx.js → remote-access-settings-section-gGoATCF9.js} +1 -1
- package/dist/web/assets/remote-access-settings-section-gGoATCF9.js.br +0 -0
- package/dist/web/assets/remote-access-settings-section-gGoATCF9.js.gz +0 -0
- package/dist/web/assets/{remote-desktop-clipboard-notice-CFLnb7ML.js → remote-desktop-clipboard-notice-D5KjvMZx.js} +1 -1
- package/dist/web/assets/remote-desktop-clipboard-notice-D5KjvMZx.js.br +0 -0
- package/dist/web/assets/remote-desktop-clipboard-notice-D5KjvMZx.js.gz +0 -0
- package/dist/web/assets/{remote-desktop-mobile-sheet-C_-_-Nkz.js → remote-desktop-mobile-sheet-CY_DsGXZ.js} +2 -2
- package/dist/web/assets/remote-desktop-mobile-sheet-CY_DsGXZ.js.br +0 -0
- package/dist/web/assets/remote-desktop-mobile-sheet-CY_DsGXZ.js.gz +0 -0
- package/dist/web/assets/{remote-desktop-mobile-view-BnHSrind.js → remote-desktop-mobile-view-DdpI-RF8.js} +1 -1
- package/dist/web/assets/remote-desktop-mobile-view-DdpI-RF8.js.br +0 -0
- package/dist/web/assets/remote-desktop-mobile-view-DdpI-RF8.js.gz +0 -0
- package/dist/web/assets/{remote-desktop-readiness-gate-BGHJ7Sv6.js → remote-desktop-readiness-gate-WIyCCAv5.js} +1 -1
- package/dist/web/assets/remote-desktop-readiness-gate-WIyCCAv5.js.br +0 -0
- package/dist/web/assets/remote-desktop-readiness-gate-WIyCCAv5.js.gz +0 -0
- package/dist/web/assets/{remote-desktop-window-content-BBm1YwM8.js → remote-desktop-window-content-BMORZLZt.js} +1 -1
- package/dist/web/assets/remote-desktop-window-content-BMORZLZt.js.br +0 -0
- package/dist/web/assets/remote-desktop-window-content-BMORZLZt.js.gz +0 -0
- package/dist/web/assets/{rename-object-dialog-BLnF9xyn.js → rename-object-dialog-pIgWe_AL.js} +1 -1
- package/dist/web/assets/rename-object-dialog-pIgWe_AL.js.br +0 -0
- package/dist/web/assets/rename-object-dialog-pIgWe_AL.js.gz +0 -0
- package/dist/web/assets/{review-code-DG7sCIzr.js → review-code-oTNcTYlI.js} +1 -1
- package/dist/web/assets/review-code-oTNcTYlI.js.br +0 -0
- package/dist/web/assets/review-code-oTNcTYlI.js.gz +0 -0
- package/dist/web/assets/{save-as-dialog-KW7cErWh.js → save-as-dialog-CnPLGTaL.js} +1 -1
- package/dist/web/assets/save-as-dialog-CnPLGTaL.js.br +0 -0
- package/dist/web/assets/save-as-dialog-CnPLGTaL.js.gz +0 -0
- package/dist/web/assets/{schedules-settings-section-B4AV4ORv.js → schedules-settings-section-CREqHG_i.js} +1 -1
- package/dist/web/assets/schedules-settings-section-CREqHG_i.js.br +0 -0
- package/dist/web/assets/schedules-settings-section-CREqHG_i.js.gz +0 -0
- package/dist/web/assets/{session-review-tab-C5nPyBzo.js → session-review-tab-nFVJYYJH.js} +1 -1
- package/dist/web/assets/session-review-tab-nFVJYYJH.js.br +0 -0
- package/dist/web/assets/session-review-tab-nFVJYYJH.js.gz +0 -0
- package/dist/web/assets/{settings-body-xWSmRXUD.js → settings-body-DNzH0wOQ.js} +1 -1
- package/dist/web/assets/settings-body-DNzH0wOQ.js.br +0 -0
- package/dist/web/assets/settings-body-DNzH0wOQ.js.gz +0 -0
- package/dist/web/assets/{settings-rows-ChKBHk07.js → settings-rows-D02_4sDY.js} +1 -1
- package/dist/web/assets/settings-rows-D02_4sDY.js.br +0 -0
- package/dist/web/assets/settings-rows-D02_4sDY.js.gz +0 -0
- package/dist/web/assets/settings-section-content-BYW_9mHv.js +1 -0
- package/dist/web/assets/{settings-section-content-DdVdyPVX.js → settings-section-content-DWopMfmq.js} +2 -2
- package/dist/web/assets/settings-section-content-DWopMfmq.js.br +0 -0
- package/dist/web/assets/settings-section-content-DWopMfmq.js.gz +0 -0
- package/dist/web/assets/{settings-tab-CzaBBNoj.js → settings-tab-Cg0v5kO7.js} +1 -1
- package/dist/web/assets/{settings-window-content-DAvWSu_O.js → settings-window-content-CqhwxJJn.js} +1 -1
- package/dist/web/assets/{slash-command-picker-Cn2Fdz2p.js → slash-command-picker-Bcizxvbh.js} +1 -1
- package/dist/web/assets/slash-command-picker-Bcizxvbh.js.br +0 -0
- package/dist/web/assets/slash-command-picker-Bcizxvbh.js.gz +0 -0
- package/dist/web/assets/{sql-object-tab-_mPRCvD9.js → sql-object-tab-b1Z2zVBm.js} +1 -1
- package/dist/web/assets/sql-object-tab-b1Z2zVBm.js.br +0 -0
- package/dist/web/assets/sql-object-tab-b1Z2zVBm.js.gz +0 -0
- package/dist/web/assets/{sqlite-viewer-B8VZt-mA.js → sqlite-viewer-DhPv28tq.js} +1 -1
- package/dist/web/assets/sqlite-viewer-DhPv28tq.js.br +0 -0
- package/dist/web/assets/sqlite-viewer-DhPv28tq.js.gz +0 -0
- package/dist/web/assets/{structure-save-dialog-Lcst7kAl.js → structure-save-dialog-sGUpqs8D.js} +1 -1
- package/dist/web/assets/structure-save-dialog-sGUpqs8D.js.br +0 -0
- package/dist/web/assets/structure-save-dialog-sGUpqs8D.js.gz +0 -0
- package/dist/web/assets/{structure-tab-ljJCzxUe.js → structure-tab-Bo2OmDOc.js} +1 -1
- package/dist/web/assets/structure-tab-Bo2OmDOc.js.br +0 -0
- package/dist/web/assets/structure-tab-Bo2OmDOc.js.gz +0 -0
- package/dist/web/assets/{system-monitor-body-CTi5xUZz.js → system-monitor-body-C475Et9u.js} +2 -2
- package/dist/web/assets/system-monitor-body-C475Et9u.js.br +0 -0
- package/dist/web/assets/system-monitor-body-C475Et9u.js.gz +0 -0
- package/dist/web/assets/{system-monitor-tab-DeL2YoXO.js → system-monitor-tab-Cm52yoW8.js} +1 -1
- package/dist/web/assets/{system-monitor-window-content-DK-rQIZh.js → system-monitor-window-content-YYsGHxZF.js} +1 -1
- package/dist/web/assets/{tab-host-window-content-CG0vPTc_.js → tab-host-window-content-BKI6QoDa.js} +1 -1
- package/dist/web/assets/tab-host-window-content-BKI6QoDa.js.br +0 -0
- package/dist/web/assets/tab-host-window-content-BKI6QoDa.js.gz +0 -0
- package/dist/web/assets/{table-tab-CTZ3nCWV.js → table-tab-D-nKWMJR.js} +1 -1
- package/dist/web/assets/table-tab-D-nKWMJR.js.br +0 -0
- package/dist/web/assets/table-tab-D-nKWMJR.js.gz +0 -0
- package/dist/web/assets/{telegram-bot-token-field-DF7zq7_h.js → telegram-bot-token-field-BeNS2X2k.js} +1 -1
- package/dist/web/assets/telegram-bot-token-field-BeNS2X2k.js.br +0 -0
- package/dist/web/assets/telegram-bot-token-field-BeNS2X2k.js.gz +0 -0
- package/dist/web/assets/{terminal-tab-B_jECWTH.js → terminal-tab-BbP753Ab.js} +1 -1
- package/dist/web/assets/terminal-tab-BbP753Ab.js.br +0 -0
- package/dist/web/assets/terminal-tab-BbP753Ab.js.gz +0 -0
- package/dist/web/assets/{tool-cards-CsD_VXcG.js → tool-cards-Dh8Ekn2W.js} +2 -2
- package/dist/web/assets/tool-cards-Dh8Ekn2W.js.br +0 -0
- package/dist/web/assets/tool-cards-Dh8Ekn2W.js.gz +0 -0
- package/dist/web/assets/{tools-settings-section-DbBr0Hnr.js → tools-settings-section-DGZRIULE.js} +1 -1
- package/dist/web/assets/tools-settings-section-DGZRIULE.js.br +0 -0
- package/dist/web/assets/tools-settings-section-DGZRIULE.js.gz +0 -0
- package/dist/web/assets/{use-inline-blame-BA2mrMxT.js → use-inline-blame-BxwM-Wkj.js} +1 -1
- package/dist/web/assets/use-inline-blame-BxwM-Wkj.js.br +0 -0
- package/dist/web/assets/use-inline-blame-BxwM-Wkj.js.gz +0 -0
- package/dist/web/assets/{use-lsp-ChbrzwvS.js → use-lsp-BqvwRKmM.js} +1 -1
- package/dist/web/assets/use-lsp-BqvwRKmM.js.br +0 -0
- package/dist/web/assets/use-lsp-BqvwRKmM.js.gz +0 -0
- package/dist/web/assets/{use-monaco-theme-C3_wfz5J.js → use-monaco-theme-DU0EpDHH.js} +1 -1
- package/dist/web/assets/{use-process-kill-C-YetnGd.js → use-process-kill-CVN_c4KF.js} +1 -1
- package/dist/web/assets/use-process-kill-CVN_c4KF.js.br +0 -0
- package/dist/web/assets/use-process-kill-CVN_c4KF.js.gz +0 -0
- package/dist/web/assets/{use-sql-schema-info-pKwLD9wk.js → use-sql-schema-info-C0wBmR6-.js} +1 -1
- package/dist/web/assets/use-sql-schema-info-C0wBmR6-.js.br +0 -0
- package/dist/web/assets/use-sql-schema-info-C0wBmR6-.js.gz +0 -0
- package/dist/web/assets/{use-websocket-BFnUq0-x.js → use-websocket-K0OUXbbY.js} +1 -1
- package/dist/web/assets/{web-preview-tab-DGLPuZYM.js → web-preview-tab-DOgLv8Gt.js} +1 -1
- package/dist/web/assets/web-preview-tab-DOgLv8Gt.js.br +0 -0
- package/dist/web/assets/web-preview-tab-DOgLv8Gt.js.gz +0 -0
- package/dist/web/index.html +1 -1
- package/dist/web/index.html.br +0 -0
- package/dist/web/index.html.gz +0 -0
- package/dist/web/sw.js +1 -1
- package/dist/web/sw.js.br +0 -0
- package/dist/web/sw.js.gz +0 -0
- package/docs/deployment-guide.md +39 -0
- package/package.json +1 -1
- package/scripts/mem-diag-report.ts +31 -0
- package/src/providers/registry.ts +10 -1
- package/src/server/index.ts +7 -6
- package/src/server/middleware/access-log.ts +3 -0
- package/src/server/middleware/cors-headers.ts +44 -0
- package/src/server/routes/chat.ts +4 -1
- package/src/server/routes/database-impexp.ts +1 -1
- package/src/server/routes/design-preview.ts +2 -2
- package/src/server/ws/chat.ts +3 -0
- package/src/services/compact-segment.ts +14 -19
- package/src/services/database/grid-export-tickets.ts +6 -2
- package/src/services/database/impexp/readers/file-text.ts +6 -3
- package/src/services/edge-forwarder.ts +12 -0
- package/src/services/file-chunks.ts +39 -0
- package/src/services/file-lines.ts +10 -17
- package/src/services/lsp/lsp-manager.ts +3 -0
- package/src/services/memory-diagnostics-native.ts +110 -0
- package/src/services/memory-diagnostics-report.ts +200 -0
- package/src/services/memory-diagnostics-requests.ts +95 -0
- package/src/services/memory-diagnostics-spawns.ts +242 -0
- package/src/services/memory-diagnostics.ts +121 -23
- package/src/services/memory-watchdog.ts +185 -0
- package/src/services/nested-subagent-spy.ts +3 -0
- package/src/services/process-thread-snapshot.ts +12 -2
- package/src/services/process-tree-memory.ts +161 -0
- package/src/services/read-lines.ts +16 -27
- package/src/services/supervisor.ts +1 -0
- package/src/services/terminal.service.ts +8 -0
- package/src/services/transcript-images-file.ts +7 -11
- package/src/web/components/chat/question-card.tsx +10 -4
- package/src/web/components/settings/notifications-settings-section.tsx +14 -1
- package/src/web/lib/web-push-client.ts +35 -5
- package/src/web/lib/web-push-support.ts +57 -4
- package/dist/web/assets/accounts-settings-section-BTga1zwH.js.br +0 -0
- package/dist/web/assets/accounts-settings-section-BTga1zwH.js.gz +0 -0
- package/dist/web/assets/agent-session-sheet-Q3kasbrZ.js.br +0 -0
- package/dist/web/assets/agent-session-sheet-Q3kasbrZ.js.gz +0 -0
- package/dist/web/assets/agent-session-window-content-UNuEprIK.js.br +0 -0
- package/dist/web/assets/agent-session-window-content-UNuEprIK.js.gz +0 -0
- package/dist/web/assets/ai-resource-editor-BEwA6Do0.js.br +0 -0
- package/dist/web/assets/ai-resource-editor-BEwA6Do0.js.gz +0 -0
- package/dist/web/assets/ai-settings-section-DVKJPM0n.js.br +0 -0
- package/dist/web/assets/ai-settings-section-DVKJPM0n.js.gz +0 -0
- package/dist/web/assets/android-tab-BNa6R9fV.js.br +0 -0
- package/dist/web/assets/android-tab-BNa6R9fV.js.gz +0 -0
- package/dist/web/assets/appearance-settings-section-CjWFwWNn.js.br +0 -0
- package/dist/web/assets/appearance-settings-section-CjWFwWNn.js.gz +0 -0
- package/dist/web/assets/apps-panel-D4xjeMN9.js.br +0 -0
- package/dist/web/assets/apps-panel-D4xjeMN9.js.gz +0 -0
- package/dist/web/assets/branch-review-tab-BCW5294d.js.br +0 -0
- package/dist/web/assets/branch-review-tab-BCW5294d.js.gz +0 -0
- package/dist/web/assets/chat-tab-BG0M1D3d.js.br +0 -3
- package/dist/web/assets/chat-tab-BG0M1D3d.js.gz +0 -0
- package/dist/web/assets/chat-tab-DsW93LTL.js.br +0 -0
- package/dist/web/assets/chat-tab-DsW93LTL.js.gz +0 -0
- package/dist/web/assets/code-editor-AxLIpK-b.js.br +0 -0
- package/dist/web/assets/code-editor-AxLIpK-b.js.gz +0 -0
- package/dist/web/assets/codex-reset-credit-button-BnRmkBZu.js.br +0 -0
- package/dist/web/assets/codex-reset-credit-button-BnRmkBZu.js.gz +0 -0
- package/dist/web/assets/conflict-editor-BwuNUPAK.js.br +0 -0
- package/dist/web/assets/conflict-editor-BwuNUPAK.js.gz +0 -0
- package/dist/web/assets/connection-form-tab-CM2o80eB.js.br +0 -0
- package/dist/web/assets/connection-form-tab-CM2o80eB.js.gz +0 -0
- package/dist/web/assets/csv-preview-C7ErHm4U.js.br +0 -0
- package/dist/web/assets/csv-preview-C7ErHm4U.js.gz +0 -0
- package/dist/web/assets/db-tab-parts-C8jbkfxO.js.br +0 -0
- package/dist/web/assets/db-tab-parts-C8jbkfxO.js.gz +0 -0
- package/dist/web/assets/design-settings-section-BcGEY4Zf.js.br +0 -0
- package/dist/web/assets/design-settings-section-BcGEY4Zf.js.gz +0 -0
- package/dist/web/assets/design-tab-BGPYNFvy.js.br +0 -0
- package/dist/web/assets/design-tab-BGPYNFvy.js.gz +0 -0
- package/dist/web/assets/designs-sidebar-panel-BgMj7xRm.js.br +0 -0
- package/dist/web/assets/designs-sidebar-panel-BgMj7xRm.js.gz +0 -0
- package/dist/web/assets/diff-viewer-BKJkesHk.js.br +0 -0
- package/dist/web/assets/diff-viewer-BKJkesHk.js.gz +0 -0
- package/dist/web/assets/docx-preview-DD5oD_nL.js.br +0 -0
- package/dist/web/assets/docx-preview-DD5oD_nL.js.gz +0 -0
- package/dist/web/assets/editor-dialog--07lKJxl.js.br +0 -0
- package/dist/web/assets/editor-dialog--07lKJxl.js.gz +0 -0
- package/dist/web/assets/editor-language-service-51xjO5d3.js.br +0 -0
- package/dist/web/assets/editor-language-service-51xjO5d3.js.gz +0 -0
- package/dist/web/assets/explorer-body-BXK5SjJQ.js.br +0 -0
- package/dist/web/assets/explorer-body-BXK5SjJQ.js.gz +0 -0
- package/dist/web/assets/explorer-window-content-DKXcCmuX.js.br +0 -0
- package/dist/web/assets/explorer-window-content-DKXcCmuX.js.gz +0 -0
- package/dist/web/assets/extension-manager-section-CTpQP6te.js.br +0 -0
- package/dist/web/assets/extension-manager-section-CTpQP6te.js.gz +0 -0
- package/dist/web/assets/extension-webview-COT-yLrM.js.br +0 -0
- package/dist/web/assets/extension-webview-COT-yLrM.js.gz +0 -0
- package/dist/web/assets/files-settings-section-CgVR0fqi.js.br +0 -0
- package/dist/web/assets/files-settings-section-CgVR0fqi.js.gz +0 -0
- package/dist/web/assets/general-settings-section-BEMIbE4Y.js.br +0 -0
- package/dist/web/assets/general-settings-section-BEMIbE4Y.js.gz +0 -0
- package/dist/web/assets/git-log-panel-Cp2174iI.js.br +0 -0
- package/dist/web/assets/git-log-panel-Cp2174iI.js.gz +0 -0
- package/dist/web/assets/git-review-tab-CpMJ0qDi.js.br +0 -0
- package/dist/web/assets/git-review-tab-CpMJ0qDi.js.gz +0 -0
- package/dist/web/assets/glide-data-grid-BAhwWUhO.js.br +0 -0
- package/dist/web/assets/glide-data-grid-BAhwWUhO.js.gz +0 -0
- package/dist/web/assets/grid-save-dialog-DmJhaWOl.js.br +0 -0
- package/dist/web/assets/grid-save-dialog-DmJhaWOl.js.gz +0 -0
- package/dist/web/assets/group-chat-tab-Bq7-Yegf.js.br +0 -0
- package/dist/web/assets/group-chat-tab-Bq7-Yegf.js.gz +0 -0
- package/dist/web/assets/impexp-tab-COx3Cvs7.js.br +0 -0
- package/dist/web/assets/impexp-tab-COx3Cvs7.js.gz +0 -0
- package/dist/web/assets/index-BGk8EFQb.js.br +0 -0
- package/dist/web/assets/index-BGk8EFQb.js.gz +0 -0
- package/dist/web/assets/keyboard-shortcuts-section-Bqg7AZiZ.js.br +0 -0
- package/dist/web/assets/keyboard-shortcuts-section-Bqg7AZiZ.js.gz +0 -0
- package/dist/web/assets/language-servers-section-CJ47DSIA.js.br +0 -0
- package/dist/web/assets/language-servers-section-CJ47DSIA.js.gz +0 -0
- package/dist/web/assets/logs-app-BK-n-y_K.js.br +0 -0
- package/dist/web/assets/logs-app-BK-n-y_K.js.gz +0 -0
- package/dist/web/assets/lsp-client-DHSaAyJW.js.br +0 -0
- package/dist/web/assets/lsp-client-DHSaAyJW.js.gz +0 -0
- package/dist/web/assets/markdown-renderer-CpxdNG0f.js.br +0 -0
- package/dist/web/assets/markdown-renderer-CpxdNG0f.js.gz +0 -0
- package/dist/web/assets/mobile-explorer-sheet-BBwXGmXA.js.br +0 -0
- package/dist/web/assets/mobile-explorer-sheet-BBwXGmXA.js.gz +0 -0
- package/dist/web/assets/new-design-dialog-B_ZOvGhR.js.br +0 -0
- package/dist/web/assets/new-design-dialog-B_ZOvGhR.js.gz +0 -0
- package/dist/web/assets/notifications-settings-section-D7fIVFHe.js +0 -1
- package/dist/web/assets/notifications-settings-section-D7fIVFHe.js.br +0 -0
- package/dist/web/assets/notifications-settings-section-D7fIVFHe.js.gz +0 -0
- package/dist/web/assets/ppmbot-settings-section-JDvyI-gZ.js.br +0 -0
- package/dist/web/assets/ppmbot-settings-section-JDvyI-gZ.js.gz +0 -0
- package/dist/web/assets/problems-panel-Bsv_L6T2.js.br +0 -0
- package/dist/web/assets/problems-panel-Bsv_L6T2.js.gz +0 -0
- package/dist/web/assets/process-table-3kZyWOJx.js.br +0 -0
- package/dist/web/assets/process-table-3kZyWOJx.js.gz +0 -0
- package/dist/web/assets/proxy-settings-section-CYcmIp7W.js.br +0 -0
- package/dist/web/assets/proxy-settings-section-CYcmIp7W.js.gz +0 -0
- package/dist/web/assets/query-tab-CjrWnQUl.js.br +0 -0
- package/dist/web/assets/query-tab-CjrWnQUl.js.gz +0 -0
- package/dist/web/assets/remote-access-settings-section-iQkakiVx.js.br +0 -0
- package/dist/web/assets/remote-access-settings-section-iQkakiVx.js.gz +0 -0
- package/dist/web/assets/remote-desktop-clipboard-notice-CFLnb7ML.js.br +0 -0
- package/dist/web/assets/remote-desktop-clipboard-notice-CFLnb7ML.js.gz +0 -0
- package/dist/web/assets/remote-desktop-mobile-sheet-C_-_-Nkz.js.br +0 -0
- package/dist/web/assets/remote-desktop-mobile-sheet-C_-_-Nkz.js.gz +0 -0
- package/dist/web/assets/remote-desktop-mobile-view-BnHSrind.js.br +0 -0
- package/dist/web/assets/remote-desktop-mobile-view-BnHSrind.js.gz +0 -0
- package/dist/web/assets/remote-desktop-readiness-gate-BGHJ7Sv6.js.br +0 -0
- package/dist/web/assets/remote-desktop-readiness-gate-BGHJ7Sv6.js.gz +0 -0
- package/dist/web/assets/remote-desktop-window-content-BBm1YwM8.js.br +0 -0
- package/dist/web/assets/remote-desktop-window-content-BBm1YwM8.js.gz +0 -0
- package/dist/web/assets/rename-object-dialog-BLnF9xyn.js.br +0 -0
- package/dist/web/assets/rename-object-dialog-BLnF9xyn.js.gz +0 -0
- package/dist/web/assets/review-code-DG7sCIzr.js.br +0 -0
- package/dist/web/assets/review-code-DG7sCIzr.js.gz +0 -0
- package/dist/web/assets/save-as-dialog-KW7cErWh.js.br +0 -0
- package/dist/web/assets/save-as-dialog-KW7cErWh.js.gz +0 -0
- package/dist/web/assets/schedules-settings-section-B4AV4ORv.js.br +0 -0
- package/dist/web/assets/schedules-settings-section-B4AV4ORv.js.gz +0 -0
- package/dist/web/assets/session-review-tab-C5nPyBzo.js.br +0 -0
- package/dist/web/assets/session-review-tab-C5nPyBzo.js.gz +0 -0
- package/dist/web/assets/settings-body-xWSmRXUD.js.br +0 -0
- package/dist/web/assets/settings-body-xWSmRXUD.js.gz +0 -0
- package/dist/web/assets/settings-rows-ChKBHk07.js.br +0 -0
- package/dist/web/assets/settings-rows-ChKBHk07.js.gz +0 -0
- package/dist/web/assets/settings-section-content-BOh2jaWV.js +0 -1
- package/dist/web/assets/settings-section-content-DdVdyPVX.js.br +0 -0
- package/dist/web/assets/settings-section-content-DdVdyPVX.js.gz +0 -0
- package/dist/web/assets/slash-command-picker-Cn2Fdz2p.js.br +0 -0
- package/dist/web/assets/slash-command-picker-Cn2Fdz2p.js.gz +0 -0
- package/dist/web/assets/sql-object-tab-_mPRCvD9.js.br +0 -0
- package/dist/web/assets/sql-object-tab-_mPRCvD9.js.gz +0 -0
- package/dist/web/assets/sqlite-viewer-B8VZt-mA.js.br +0 -0
- package/dist/web/assets/sqlite-viewer-B8VZt-mA.js.gz +0 -0
- package/dist/web/assets/structure-save-dialog-Lcst7kAl.js.br +0 -0
- package/dist/web/assets/structure-save-dialog-Lcst7kAl.js.gz +0 -0
- package/dist/web/assets/structure-tab-ljJCzxUe.js.br +0 -0
- package/dist/web/assets/structure-tab-ljJCzxUe.js.gz +0 -0
- package/dist/web/assets/system-monitor-body-CTi5xUZz.js.br +0 -0
- package/dist/web/assets/system-monitor-body-CTi5xUZz.js.gz +0 -0
- package/dist/web/assets/tab-host-window-content-CG0vPTc_.js.br +0 -0
- package/dist/web/assets/tab-host-window-content-CG0vPTc_.js.gz +0 -0
- package/dist/web/assets/table-tab-CTZ3nCWV.js.br +0 -0
- package/dist/web/assets/table-tab-CTZ3nCWV.js.gz +0 -0
- package/dist/web/assets/telegram-bot-token-field-DF7zq7_h.js.br +0 -0
- package/dist/web/assets/telegram-bot-token-field-DF7zq7_h.js.gz +0 -0
- package/dist/web/assets/terminal-tab-B_jECWTH.js.br +0 -0
- package/dist/web/assets/terminal-tab-B_jECWTH.js.gz +0 -0
- package/dist/web/assets/tool-cards-CsD_VXcG.js.br +0 -0
- package/dist/web/assets/tool-cards-CsD_VXcG.js.gz +0 -0
- package/dist/web/assets/tools-settings-section-DbBr0Hnr.js.br +0 -0
- package/dist/web/assets/tools-settings-section-DbBr0Hnr.js.gz +0 -0
- package/dist/web/assets/use-inline-blame-BA2mrMxT.js.br +0 -0
- package/dist/web/assets/use-inline-blame-BA2mrMxT.js.gz +0 -0
- package/dist/web/assets/use-lsp-ChbrzwvS.js.br +0 -0
- package/dist/web/assets/use-lsp-ChbrzwvS.js.gz +0 -0
- package/dist/web/assets/use-process-kill-C-YetnGd.js.br +0 -0
- package/dist/web/assets/use-process-kill-C-YetnGd.js.gz +0 -0
- package/dist/web/assets/use-sql-schema-info-pKwLD9wk.js.br +0 -0
- package/dist/web/assets/use-sql-schema-info-pKwLD9wk.js.gz +0 -0
- package/dist/web/assets/web-preview-tab-DGLPuZYM.js.br +0 -0
- package/dist/web/assets/web-preview-tab-DGLPuZYM.js.gz +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.23.22] - 2026-10-30
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- **`ppm.log` now answers "why is PPM using so much RAM" by itself, with nothing to turn on.** A summary every 30 minutes names this process, its children by program, the biggest child branches with the chat session each one serves, the busiest routes and the open sessions, terminals and LSP servers; a warning goes out the first time memory crosses each threshold, and a line marks every Claude or Codex subprocess starting and exiting. Route names are logged with ids, paths and tokens replaced.
|
|
8
|
+
|
|
9
|
+
- **`PPM_MEM_DIAG=1` records more:** private bytes, handles and every child process with the chat it belongs to, the edge forwarder writes its own `mem-diag-edge.log`, and `scripts/mem-diag-report.ts` lines memory growth up against what was spawned and what was served.
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- **The server leaked about a transcript's size of memory every time a chat tab opened, until the machine ran out.** Reading a file through Bun's file stream never gave the memory back, so a day of tabs reconnecting took the server to 25 GB and every new Claude session died at start. Transcripts, chat images, the app's own files, downloads and imported files are now read and sent in a way that returns it.
|
|
14
|
+
|
|
15
|
+
- **A video or audio file asked for in part (seeking) was sent from that point to the end instead of just the part asked for.**
|
|
16
|
+
|
|
17
|
+
- **Push could not be turned on in Brave, and the pane said only "Registration failed - push service error".** Brave delivers push through Google's service and keeps it off until "Use Google services for push messaging" is turned on in brave://settings/privacy; the pane now says so, and to restart Brave and turn push on again. In other browsers that cannot reach their push service, the pane names the service (Google's for Chrome, Mozilla's for Firefox, Apple's for Safari) and what may be blocking it, and gives up after a minute: Chrome never answers on a network that blocks Google's service, which left the switch stuck for good. Firefox with `dom.push.enabled` off in about:config is told to turn it on. The message stays under the switch instead of in a toast that was gone in four seconds, and while the browser registers the pane says it is waiting, which just after the browser starts takes about half a minute.
|
|
18
|
+
|
|
19
|
+
- **Brave was listed as Chrome among the devices that get push.** Brave's user agent is Chrome's, so "This device" and the saved device both said "Chrome on macOS", and a Mac with push on in both browsers showed two identical rows. The name now says Brave. A device turned on before this keeps its old name until push is turned off and on again in it.
|
|
20
|
+
|
|
21
|
+
- **A Claude chat's "Chat completed" notification quoted the previous turn's answer.** Claude keeps one stream for every turn of a session, and the answer a notification quotes was reset only when that stream started or a tool ran. So a follow-up's notification began with the last turn's text — after a long answer it held nothing else — and a turn that wrote nothing quoted the previous answer as its own. Each turn now quotes only what it wrote.
|
|
22
|
+
|
|
23
|
+
## [0.23.21] - 2026-10-26
|
|
24
|
+
|
|
25
|
+
### Fixed
|
|
26
|
+
|
|
27
|
+
- **A pending AI question no longer takes focus back**: two chats waiting on questions side by side can each be answered, and the chat above a question can be scrolled up to read.
|
|
28
|
+
|
|
3
29
|
## [0.23.20] - 2026-10-26
|
|
4
30
|
|
|
5
31
|
### Fixed
|
package/CLAUDE.md
CHANGED
|
@@ -192,9 +192,9 @@ Related: `configService.save()`/`set()` throw when `load()` has not run, because
|
|
|
192
192
|
- **Bridge features cannot close over anything**: `bridge-script.ts` ships each feature as `fn.toString()`, so an import, a module constant or a helper called by name compiles, passes review, and is `undefined` in the frame. Everything arrives through `ppm`, shared helpers as `ppm.lib`. Loading the module throws if the script contains `</script`, `<script` or `<!--`, and `bun build` of `bridge-script.ts` followed by `new Function(BRIDGE_JS)` checks that the shipped bundler kept it intact.
|
|
193
193
|
- **Design exports are octet-stream Blobs, and the view tabs are real links**: a `blob:` URL has PPM's origin, and a browser that ignores `download` (iOS Safari) would open an HTML one and run the design beside the token in `localStorage`. Print and "Open in new tab" are `<a target=_blank rel="noopener noreferrer">` to tokens minted when the menu opens, because a `noopener` `window.open` cannot report a blocked popup. `allow-modals` is reachable only through a print-purpose token; the CDN hosts the design CSP allows (jsdelivr, unpkg) run any npm or GitHub code, which is accepted.
|
|
194
194
|
- **`tabSessionId()` is the only way to ask a tab for its session**: design tabs hold chat sessions too, so `type === "chat" && metadata.sessionId` makes a design session look unopened, and reopening it starts a plain chat outside design mode (`src/web/lib/tab-session-id.ts`).
|
|
195
|
-
- **Hono's
|
|
195
|
+
- **The app does not use Hono's `cors()`, and no global middleware may touch `c.res` before `next()`**: headers set before the handler make Hono's `c.res` setter rebuild the handler's response as `new Response(res.body, res)` and copy the early headers over it. That overwrote the `Access-Control-Allow-Origin: null` the design preview sets (hence its after-`next()` re-assert, which `design-preview.test.ts` checks behind the real `corsHeaders`), made Bun lose a `BunFile.slice()` body (a `rangeFileResponse` 206 for `bytes=2-5` sent `"23456789"` with no `Content-Length`), and turned every `Bun.file` body into a leaking stream (the `Bun.file().stream()` entry above). `src/server/middleware/cors-headers.ts` writes after `next()` and leaves an origin a route set; `tests/unit/server/cors-headers.test.ts` covers all three.
|
|
196
196
|
- **A reviewer's files never go through the canvas's `systems/<id>/**` alias**: for the `default` app that alias is `designs/` itself, i.e. every other design and the live copy of the shared one. A share link serves its pinned snapshot plus `design-guest-alias.ts`'s allow-list (`tokens.css`, and the snapshot's own app's `tokens.css` + `kit/**`, live), with the kit contained in its own folder so a `kit` that links elsewhere under `designs/` is refused.
|
|
197
|
-
- **`/s` is mounted before
|
|
197
|
+
- **`/s` is mounted before the CORS layer and ends in a catch-all**: it predates `corsHeaders` and was written against Hono's `cors()`, where a reviewer response answered `ACAO: *` and its range bodies hit the re-wrap described above — `corsHeaders` writes after `next()` and no longer does either, so the mount order now buys the auth and fallback reasons alone; without the catch-all an unknown `/s` path falls to `staticRoutes` and gets the app shell and its service worker. `tests/integration/api/design-share-guest-mount.test.ts` runs against the real `app` and fails when the mount moves. The reviewer page shares PPM's origin, `localStorage` and token included, so it renders reviewer text as text only.
|
|
198
198
|
- **Share codes are derived, never stored**: HMAC of link id + code version under `<ppm dir>/design-share.key`, with only the code's hash in the database, so a copied `ppm.db` or backup opens no link and the owner can still copy one again. `resolveShareCode` also re-derives the code and compares in constant time, so a link waiting for a new code does not open for its old one. Deleting the key retires every code without a restart.
|
|
199
199
|
- **Behind the supervisor every LAN and Tailscale reviewer is one loopback address**: the share routes' client key is `"local"` for all of them (`CF-Connecting-IP` is believed only from loopback with the tunnel's `Host`), so write spacing is keyed by client *and* reviewer key, or a reply sent right after a colleague's comment is refused; the per-link cap bounds a sender that invents keys.
|
|
200
200
|
- **`rehype-raw` without a sanitiser is script on PPM's origin**: the app shell has no CSP and keeps the token in `localStorage`, so an `<iframe srcdoc>` in an AI reply or a Markdown file could read it. `markdown-sanitize.ts` runs right after `rehype-raw` and before KaTeX, and leaves URLs to `markdownUrlTransform` (a scheme allow-list would delete `README.md:5` and `C:\x.png`); it prefixes ids, so `#fragment` links get the same prefix and remark-rehype's own footnote prefix is off. Two more renderers had the same hole: Mermaid's `securityLevel: "loose"` keeps `click … href "javascript:…"` live in the SVG (now `strict`), and mammoth does no sanitising and passes `javascript:` hyperlinks through, so `docx-html-sanitize.ts` checks schemes itself. A `<task-notification>` result renders with `rawHtml={false}`.
|
|
@@ -221,6 +221,7 @@ Related: `configService.save()`/`set()` throw when `load()` has not run, because
|
|
|
221
221
|
- **A session's "before" for a file is PPM's to keep, because no transcript holds it**: Claude Code records a tool's `toolUseResult.originalFile` only for small files (measured: kept at 9,836 B, gone from 13.6 KB up), an Edit's `old_string` is a fragment at an unknown offset, SDK checkpointing is off, and git HEAD also holds whatever was uncommitted before the session began. So the session review reads `session-baselines/` (see Architecture), filled at PreToolUse **in every permission mode**. That last part is new: before it, a bypass-mode session — the default — installed **no PreToolUse hook at all** (the permission hook is skipped there by design), so anything added to the permission hook does not run for most sessions. `buildToolHooks` therefore gives bypass mode a file-write hook of its own (`PreToolUse[0]` there), while every other mode runs it from the permission hook once that has allowed the write — a denied write records nothing; `permissionHook()` in `claude-agent-sdk.test.ts` finds that `.*` one. Verified against the real CLI in bypass mode: the hook fires for a sub-agent's Write too. A record is hard-linked into place so the **first capture wins**; never "fix" a missing record by writing one later in the session, which would record a state the session itself produced. Shell commands are the exception that proves it: `shell-change-tracker.ts` reads a file's bytes *before* the command runs and records them only if the command moved it, and a file git did not list is HEAD — read from the **pre-command** HEAD, because `git commit` in the same command moves it (the post-command HEAD would name the new content as the "before"). Outside bypass mode that snapshot is taken by the permission hook once it has allowed the command, not by a hook of its own, so it cannot be taken while the approval prompt is still open — an edit made during that wait would otherwise be put on the command (checked with the real CLI: a file edited during a 1.5 s approval wait was not recorded).
|
|
222
222
|
- **Codex's `FileUpdateChange.diff` is a diff only for an update**: for `add` and `delete` it is the file's **raw content**, and an update may end in `\n\nMoved to: <path>`. Parsing all three as a unified diff (`diffToOldNew`) dropped every line without a `+`/`-`/space prefix, so a created file counted +0. The rollout's `item_completed` FileChange carries `changes` as a dict keyed by path, not the live array (`rolloutFileChanges` vs `fileUpdateChanges` in `codex-patch.ts`). One patch over several files is **one** Edit/Write card whose own fields describe only the first file, with `input.files` listing all of them — read `files`, or every file after the first is invisible. And the patch is on disk before PPM hears of it, so its "before" is the diff reverse-applied (`reverse-unified-diff.ts`), which refuses rather than guesses when a hunk does not match.
|
|
223
223
|
- **`@monaco-editor/react` 4.7 disposes a diff's models before the diff editor holding them**, and Monaco 0.55 reports it as an uncaught "TextModel got disposed before DiffEditorWidget model got reset" on every unmount — every closed diff tab, every file a review steps to. `DiffEditor` in `diff-viewer.tsx` is the library component's parent and detaches and disposes the models in its own cleanup, which React runs first because it runs a removed subtree's cleanups parent before child (every layout one before any passive one). The layout effect there is margin, not the fix: measured on React 19.2, a `useEffect` cleanup in the wrapper also runs before the library's passive one. `diff-viewer-dispose-order.test.ts` mounts the real viewer over the real library and goes red without the cleanup. Separately, that file's word-wrap sync forced `wordWrapOverride2` onto the original editor in **inline** mode too, where the original is a hidden 35px column: every line wrapped many rows tall and the inline view padded the visible side to match, so a phone showed one changed line between screens of hatching (`.diagonal-fill`). Monaco itself keeps that editor unwrapped when inline; only a side-by-side original wraps now.
|
|
224
|
+
- **Never read a file through `Bun.file().stream()`: every full read keeps about the file's size in native memory, for good**. Measured on Bun 1.3.10 (Windows): a 30 MB transcript read 40 times took a process from 377 MB to 1,949 MB private (38 MB a read) with the JS heap back at 18 MB, and `new Response(file.stream())` keeps 34 MB per response of a 23 MB file. Opening a chat tab read the whole transcript this way (`readCompactions` → `readLines`), so a server whose tabs reconnected all day reached 25 GB committed and the machine ran out of memory twice in two days; RSS read 1–9 GB throughout, which is why it hid behind "memory looks fine". `createReadStream`, `readSync` and a `FileHandle` stay flat, and so does `new Response(Bun.file(path))` — **but only if nothing rebuilds that response**. Hono's `cors()` set its headers on `c.res` before the handler, so Hono's `c.res` setter rebuilt every response as `new Response(res.body, res)`, and reading `.body` turns a `Bun.file` into the same leaking stream (23 MB file: 3 MB a response bare, 32 MB behind `cors()`, 0.9 MB behind `corsHeaders`). That covered every static asset, chat image and download. The tell is the header: a rebuilt file response loses `Content-Length` and goes out chunked. So the app's CORS layer is `src/server/middleware/cors-headers.ts`, which writes after `next()`; any middleware that touches `c.res` *before* `next()` brings the leak back. Read through `readFileChunks` (`src/services/file-chunks.ts`) and hand a `Bun.file` itself to a `Response`; `tests/unit/services/file-chunks.test.ts` fails on any `.stream()` in `src`, and `tests/unit/server/cors-headers.test.ts` on a file response that loses its `Content-Length`. Reading one file repeatedly with `readFileSync`/`.text()` looks like a leak for the first ~12 reads and then plateaus (allocator reuse) — measure 40+ iterations and compare the second half before calling anything a leak.
|
|
224
225
|
- **A bounded read of a file stream has to count its own bytes and end with `cancel()`**: on Bun 1.3.11, `Bun.file(f).slice(a, b).stream()` never finishes when `b` is well short of the end of a multi-MB file — the last `read()` neither resolves nor errors (a 4MB file's `slice(0, 259)` hung; `slice(0, size - 1)` and an endless `slice(a)` did not) — so `readLines` takes `toByte` and stops at it itself. And a reader let go of before its end with `releaseLock()` keeps its file descriptor: 2000 early stops left 2000 open, `reader.cancel()` closes it. Both bite the windowed transcript reads in `compact-segment.ts`, which stop early on every scroll up by design; `compact-segment.test.ts` pins both.
|
|
225
226
|
|
|
226
227
|
- **Rebuilding a table that others reference deletes their rows unless foreign keys are off — and that pragma is ignored inside a transaction**: SQLite's recipe for changing a constraint (create the new table, copy, drop the old one, rename) is how migration 55 let `connections` accept `mysql` / `mariadb`. With `foreign_keys = ON`, `DROP TABLE connections` runs an implicit `DELETE` that cascades through `connection_table_cache`'s `ON DELETE CASCADE` and empties it before the new table exists — no error, just a cache that is gone. `PRAGMA foreign_keys = OFF` is a no-op inside a transaction, so `allowConnectionTypes` in `db.service.ts` turns it off *before* `BEGIN`, reads it back and refuses to run when a caller's transaction kept it on, and restores it afterwards. It also rebuilds from the table's own recorded SQL with only the CHECK replaced, so a column a later migration added is carried over, and keeps the `AUTOINCREMENT` high-water mark, because query-audit rows still name the ids of deleted connections.
|
|
@@ -73,4 +73,4 @@ This skill covers the `ppm` CLI, its HTTP API, and its config DB. It does **not*
|
|
|
73
73
|
- Third-party extensions (inspect via `ppm ext list`).
|
|
74
74
|
- The Claude Agent SDK internals (separate skill).
|
|
75
75
|
|
|
76
|
-
<!-- Generated for PPM v0.23.
|
|
76
|
+
<!-- Generated for PPM v0.23.22 at build time. Re-run `ppm export skill --install` to refresh. -->
|
|
@@ -490,4 +490,4 @@ _Base URL: `http://localhost:8080` (default; override via `ppm config set port <
|
|
|
490
490
|
- `ws://<host>/ws/terminal` — PTY terminal multiplexer
|
|
491
491
|
- `ws://<host>/ws/extensions` — extension host channel
|
|
492
492
|
|
|
493
|
-
<!-- Generated from src/server/routes/ for PPM v0.23.
|
|
493
|
+
<!-- Generated from src/server/routes/ for PPM v0.23.22 -->
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{D as t,E as n}from"./vendor-markdown-C-P1aR4p.js";import"./vendor-ui-BTSIXzhZ.js";import{At as r,Cn as i,Cr as a,J as o,Kr as s,Zr as c,cr as l,ht as u,li as d,ln as f,ut as p,xn as m}from"./icons-BwyIKaTT.js";import{a as h}from"./api-client-xQDlhUTu.js";import{n as g}from"./utils-Bslrbb-G.js";import"./portal-container-context-NBi-KGK0.js";import"./chat-preparation-cache-190LLyy7.js";import{n as _}from"./use-is-mobile-VRV9eZy1.js";import{r as v}from"./clipboard-D-VCry-F.js";import{r as y,t as b}from"./button-C9ZXWb3b.js";import{a as x,i as S,n as C,o as w,r as T,t as E}from"./dialog-Dn_2tuYa.js";import{t as D}from"./mobile-bottom-sheet-DArbIyrD.js";import"./use-visual-viewport-MmugpRg-.js";import{t as O}from"./input-C3oVNCMq.js";import{Ai as k,Er as A,Gi as j,Gn as M,Hn as N,Kn as P,Ui as F,Un as I,Vn as ee,Wi as L,Wn as te}from"./index-BGk8EFQb.js";import{_ as ne,a as re,h as ie,m as ae,o as oe,p as se,r as ce,v as le,x as R,y as ue}from"./api-settings-vmIRFNwZ.js";import{_ as de,a as fe,b as pe,c as me,d as he,g as z,h as B,l as ge,m as _e,n as ve,o as ye,p as V,r as be,s as H,t as xe,u as Se,x as U,y as W}from"./codex-reset-credit-button-BnRmkBZu.js";var G=e(t(),1),K=n(),q=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],J=Array.from({length:24},(e,t)=>t);function Ce(e,t){let n=Array.from({length:7},()=>Array.from({length:24},()=>({sum:0,count:0,avg:0})));for(let r of e){let e=t===`5h`?r.five_hour_util:r.weekly_util;if(e==null)continue;let i=new Date(r.recorded_at+(r.recorded_at.endsWith(`Z`)?``:`Z`)),a=(i.getDay()+6)%7,o=i.getHours();n[a][o].sum+=e,n[a][o].count+=1}for(let e of n)for(let t of e)t.avg=t.count>0?t.sum/t.count:0;return n}function we(e){return e.map(e=>{let t=e.reduce((e,t)=>e+t.sum,0),n=e.reduce((e,t)=>e+t.count,0);return n>0?t/n:0})}function Te(e){return J.map(t=>{let n=0,r=0;for(let i of e)n+=i[t].sum,r+=i[t].count;return r>0?n/r:0})}function Y(e){return e===0?`bg-surface-elevated`:e<.3?`bg-success/30`:e<.5?`bg-success/60`:e<.7?`bg-warning/50`:e<.9?`bg-warning/80`:`bg-error/80`}function Ee(e){return e<.3?`bg-success`:e<.7?`bg-warning`:`bg-error`}function De({accountId:e}){let[t,n]=(0,G.useState)(null),[r,i]=(0,G.useState)(!0),[a,o]=(0,G.useState)(`5h`);(0,G.useEffect)(()=>{i(!0),se(e).then(n).catch(()=>n([])).finally(()=>i(!1))},[e]);let s=(0,G.useMemo)(()=>t?Ce(t,a):null,[t,a]),c=(0,G.useMemo)(()=>s?we(s):[],[s]),l=(0,G.useMemo)(()=>s?Te(s):[],[s]),u=Math.max(...c,.01);if(Math.max(...l,.01),r)return(0,K.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,K.jsx)(m,{className:`size-3 animate-spin text-text-subtle`})});if(!t||t.length===0)return(0,K.jsx)(`div`,{className:`text-[10px] text-text-subtle py-2 text-center`,children:`No usage history yet`});let d=t.length,f=new Set(t.map(e=>new Date(e.recorded_at+(e.recorded_at.endsWith(`Z`)?``:`Z`)).toDateString())).size;return(0,K.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-[10px] font-medium text-text-subtle`,children:`Usage Pattern (7d)`}),(0,K.jsxs)(`div`,{className:`flex gap-0.5 text-[9px]`,children:[(0,K.jsx)(`button`,{onClick:()=>o(`5h`),className:`px-1.5 py-0.5 rounded cursor-pointer transition-colors ${a===`5h`?`bg-primary/15 text-primary`:`text-text-subtle hover:text-text-secondary`}`,title:`5-hour rolling window limit — resets every 5 hours`,children:`5h`}),(0,K.jsx)(`button`,{onClick:()=>o(`weekly`),className:`px-1.5 py-0.5 rounded cursor-pointer transition-colors ${a===`weekly`?`bg-primary/15 text-primary`:`text-text-subtle hover:text-text-secondary`}`,title:`Weekly limit — resets every 7 days`,children:`Wk`})]})]}),(0,K.jsxs)(`p`,{className:`text-[9px] text-text-subtle leading-tight`,children:[`Avg `,a===`5h`?`5-hour`:`weekly`,` limit usage over `,f,`d (`,d,` samples). Higher % = closer to rate limit. Hover cells for details.`]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-[9px] text-text-subtle`,children:`Avg usage by day of week`}),(0,K.jsx)(`div`,{className:`flex flex-col gap-[2px] mt-0.5`,children:q.map((e,t)=>{let n=c[t]??0;return(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`span`,{className:`text-[8px] text-text-subtle w-5 shrink-0 text-right tabular-nums`,children:e}),(0,K.jsx)(`div`,{className:`flex-1 h-2.5 bg-surface-elevated rounded-sm overflow-hidden`,children:(0,K.jsx)(`div`,{className:`h-full rounded-sm transition-all ${Ee(n)}`,style:{width:`${Math.round(n/u*100)}%`}})}),(0,K.jsxs)(`span`,{className:`text-[8px] text-text-subtle w-6 shrink-0 text-right tabular-nums`,children:[Math.round(n*100),`%`]})]},e)})})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-[9px] text-text-subtle`,children:`Avg usage by hour (0h-23h)`}),(0,K.jsx)(`div`,{className:`flex gap-[1px] mt-0.5`,children:J.map(e=>{let t=l[e]??0;return(0,K.jsxs)(`div`,{className:`flex-1 flex flex-col items-center gap-[1px]`,children:[(0,K.jsx)(`div`,{className:`w-full aspect-square rounded-[2px] ${Y(t)}`,title:`${e}:00 — avg ${Math.round(t*100)}% usage`}),e%6==0&&(0,K.jsx)(`span`,{className:`text-[7px] text-text-subtle tabular-nums`,children:e})]},e)})})]}),s&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-[9px] text-text-subtle`,children:`Day x Hour heatmap`}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-[1px] mt-0.5`,children:[q.map((e,t)=>(0,K.jsxs)(`div`,{className:`flex items-center gap-[1px]`,children:[(0,K.jsx)(`span`,{className:`text-[7px] text-text-subtle w-4 shrink-0 text-right`,children:e.charAt(0)}),J.map(n=>{let r=s[t][n];return(0,K.jsx)(`div`,{className:`flex-1 aspect-square rounded-[1px] ${Y(r.avg)}`,title:`${e} ${n}:00 — ${r.count>0?`avg ${Math.round(r.avg*100)}% (${r.count} samples)`:`no data`}`},n)})]},e)),(0,K.jsxs)(`div`,{className:`flex items-center gap-[1px]`,children:[(0,K.jsx)(`span`,{className:`w-4 shrink-0`}),J.map(e=>(0,K.jsx)(`div`,{className:`flex-1 text-center`,children:e%6==0&&(0,K.jsx)(`span`,{className:`text-[7px] text-text-subtle tabular-nums`,children:e})},e))]})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[8px] text-text-subtle`,children:[(0,K.jsx)(`span`,{children:`Low`}),(0,K.jsxs)(`div`,{className:`flex gap-[2px]`,children:[(0,K.jsx)(`div`,{className:`size-2 rounded-[1px] bg-success/30`}),(0,K.jsx)(`div`,{className:`size-2 rounded-[1px] bg-success/60`}),(0,K.jsx)(`div`,{className:`size-2 rounded-[1px] bg-warning/50`}),(0,K.jsx)(`div`,{className:`size-2 rounded-[1px] bg-warning/80`}),(0,K.jsx)(`div`,{className:`size-2 rounded-[1px] bg-error/80`})]}),(0,K.jsx)(`span`,{children:`High`}),(0,K.jsx)(`span`,{className:`ml-1`,children:`|`}),(0,K.jsx)(`div`,{className:`size-2 rounded-[1px] bg-surface-elevated border border-border/30`}),(0,K.jsx)(`span`,{children:`No data`})]})]})}function Oe({profile:e,accountId:t,onClose:n}){let r=[[`Name`,e.account?.display_name],[`Email`,e.account?.email],[`Org`,e.organization?.name],[`Type`,e.organization?.organization_type],[`Tier`,e.organization?.rate_limit_tier],[`Status`,e.organization?.subscription_status]];return(0,K.jsxs)(`section`,{className:`space-y-2 border-t border-border pt-3`,"data-testid":`account-profile-panel`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium`,children:`Profile`}),(0,K.jsx)(`button`,{className:`p-2 text-muted-foreground hover:text-foreground cursor-pointer`,onClick:n,"aria-label":`Close profile`,children:(0,K.jsx)(d,{className:`size-4`})})]}),(0,K.jsx)(`div`,{className:`grid grid-cols-[80px_1fr] gap-x-3 gap-y-1 text-xs`,children:r.map(([e,t])=>t?(0,K.jsxs)(`span`,{className:`contents`,children:[(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,K.jsx)(`span`,{className:`break-all`,children:t})]},e):null)}),(0,K.jsx)(De,{accountId:t})]})}function ke({display:e,onConfirm:t,onCancel:n}){let r=_(),i=(0,K.jsxs)(`div`,{className:`space-y-4`,"data-testid":`account-delete-confirm`,children:[(0,K.jsxs)(`p`,{className:`text-sm`,children:[`Remove `,(0,K.jsx)(`span`,{className:`font-medium`,children:e}),`?`]}),(0,K.jsx)(`p`,{className:`text-xs text-text-subtle`,children:`The stored token is deleted from this machine. Any export you already made keeps working.`}),(0,K.jsxs)(`div`,{className:`flex flex-col-reverse md:flex-row gap-2 md:justify-end pt-2`,children:[(0,K.jsx)(b,{variant:`outline`,onClick:n,className:`min-h-11`,children:`Cancel`}),(0,K.jsx)(b,{variant:`destructive`,autoFocus:!1,onClick:t,className:`min-h-11`,children:`Remove account`})]})]});return r?(0,K.jsx)(D,{open:!0,onClose:n,children:(0,K.jsxs)(`div`,{className:`px-4 pb-4`,children:[(0,K.jsx)(`h2`,{className:`text-base font-semibold mb-3`,children:`Remove account`}),i]})}):(0,K.jsx)(E,{open:!0,onOpenChange:e=>{e||n()},children:(0,K.jsxs)(C,{className:`sm:max-w-sm`,children:[(0,K.jsx)(x,{children:(0,K.jsx)(w,{className:`text-sm`,children:`Remove account`})}),i]})})}function Ae(e){let t=new Blob([e],{type:`application/json`}),n=document.createElement(`a`);n.href=URL.createObjectURL(t),n.download=`ppm-accounts-backup.json`,n.click(),URL.revokeObjectURL(n.href)}function je({open:e,onOpenChange:t,accounts:n,preselectId:r,onMessage:a}){let o=n.filter(e=>e.hasRefreshToken),[s,c]=(0,G.useState)(new Set),[l,d]=(0,G.useState)(``),[f,g]=(0,G.useState)(!1),[_,y]=(0,G.useState)(!1),[D,k]=(0,G.useState)(!1),[j,M]=(0,G.useState)(!1);e&&!j&&(c(r?new Set([r]):new Set(o.map(e=>e.id))),M(!0)),!e&&j&&M(!1);function N(){t(!1),d(``),g(!1),y(!1)}async function P(e){if(s.size===0)return;k(!0);let t=l.trim()||`ppm-hienlh`;try{let n={"Content-Type":`application/json`},r=h();r&&(n.Authorization=`Bearer ${r}`);let i=await fetch(`/api/accounts/export`,{method:`POST`,headers:n,body:JSON.stringify({password:t,accountIds:[...s],includeRefreshToken:f,refreshBeforeExport:_})});if(!i.ok){let e=await i.json();throw Error(e.error??`Export failed: ${i.status}`)}let o=await i.text();e&&await v(o)?a?.(`Backup copied to clipboard!`):(Ae(o),a?.(`Backup downloaded.`)),N()}catch{}k(!1)}let F=s.size>0&&!D;return(0,K.jsx)(E,{open:e,onOpenChange:e=>{e||N()},children:(0,K.jsxs)(C,{className:`sm:max-w-md`,children:[(0,K.jsxs)(x,{children:[(0,K.jsxs)(w,{className:`text-sm flex items-center gap-1.5`,children:[(0,K.jsx)(i,{className:`size-3.5`}),` Export Accounts`]}),(0,K.jsx)(T,{className:`text-xs`,children:`Select accounts and set a password to protect the backup.`})]}),(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,K.jsx)(`p`,{className:`text-[11px] font-medium text-muted-foreground`,children:`Accounts to export`}),(0,K.jsx)(`button`,{className:`text-[10px] text-primary hover:underline cursor-pointer`,onClick:()=>c(s.size===o.length?new Set:new Set(o.map(e=>e.id))),children:s.size===o.length?`Deselect all`:`Select all`})]}),o.length===0?(0,K.jsx)(`p`,{className:`text-[10px] text-muted-foreground p-2 border rounded`,children:`No exportable accounts.`}):(0,K.jsx)(`div`,{className:`max-h-36 overflow-y-auto space-y-1 border rounded p-2`,children:o.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`checkbox`,id:`exp-${e.id}`,checked:s.has(e.id),onChange:t=>{let n=new Set(s);t.target.checked?n.add(e.id):n.delete(e.id),c(n)},className:`size-3.5 accent-primary cursor-pointer`}),(0,K.jsx)(`label`,{htmlFor:`exp-${e.id}`,className:`text-xs cursor-pointer truncate`,children:e.label??e.email??e.id.slice(0,8)})]},e.id))})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(A,{className:`text-xs`,children:[`Password `,(0,K.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(optional)`})]}),(0,K.jsx)(O,{type:`password`,placeholder:`Leave empty for default`,value:l,onChange:e=>d(e.target.value),className:`text-xs h-8`,autoComplete:`new-password`})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`checkbox`,id:`exp-full`,checked:f,onChange:e=>g(e.target.checked),className:`size-3.5 accent-primary cursor-pointer`}),(0,K.jsx)(`label`,{htmlFor:`exp-full`,className:`text-[11px] cursor-pointer`,children:`Include refresh tokens (full transfer)`})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`checkbox`,id:`exp-refresh`,checked:_,onChange:e=>y(e.target.checked),className:`size-3.5 accent-primary cursor-pointer`}),(0,K.jsx)(`label`,{htmlFor:`exp-refresh`,className:`text-[11px] cursor-pointer`,children:`Refresh tokens before export`})]}),f?(0,K.jsxs)(`div`,{className:`rounded-md border border-error/30 bg-error/5 p-2.5`,children:[(0,K.jsx)(`p`,{className:`text-[10px] font-medium text-error`,children:`Full transfer — source accounts will expire`}),(0,K.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Refresh tokens included. Source machine expires in ~1h after target refreshes.`})]}):_?(0,K.jsx)(`div`,{className:`rounded-md border border-warning/30 bg-warning/5 p-2.5`,children:(0,K.jsx)(`p`,{className:`text-[10px] font-medium text-warning`,children:`Refresh before export — invalidates previous shares`})}):(0,K.jsx)(`div`,{className:`rounded-md border border-success/30 bg-success/5 p-2.5`,children:(0,K.jsx)(`p`,{className:`text-[10px] font-medium text-success`,children:`Share current token (safe)`})}),(0,K.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Encrypted with AES-256-GCM + scrypt.`})]}),(0,K.jsxs)(S,{className:`gap-1.5 flex-col sm:flex-row`,children:[(0,K.jsx)(b,{size:`sm`,variant:`outline`,className:`text-xs h-7 cursor-pointer`,onClick:N,children:`Cancel`}),(0,K.jsxs)(b,{size:`sm`,variant:`outline`,className:`text-xs h-7 cursor-pointer`,disabled:!F,onClick:()=>P(!0),children:[(0,K.jsx)(p,{className:`size-3 mr-1`}),` Copy`]}),(0,K.jsx)(b,{size:`sm`,className:`text-xs h-7 cursor-pointer`,disabled:!F,onClick:()=>P(!1),children:D?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(m,{className:`size-3 animate-spin mr-1`}),` Exporting...`]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(u,{className:`size-3 mr-1`}),` Download`]})})]})]})})}function Me({open:e,onOpenChange:t,onSuccess:n}){let[r,a]=(0,G.useState)(``),[o,s]=(0,G.useState)(``),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(null);function f(){t(!1),a(``),s(``),d(null)}async function p(){if(r.trim()){l(!0),d(null);try{let e=await ae({data:r.trim(),password:o.trim()||`ppm-hienlh`});f(),n(`Imported ${e.imported} account(s)`)}catch(e){d(e.message||`Import failed`)}l(!1)}}return(0,K.jsx)(E,{open:e,onOpenChange:e=>{e||f()},children:(0,K.jsxs)(C,{className:`sm:max-w-md`,children:[(0,K.jsxs)(x,{children:[(0,K.jsxs)(w,{className:`text-sm flex items-center gap-1.5`,children:[(0,K.jsx)(i,{className:`size-3.5`}),` Import Accounts`]}),(0,K.jsx)(T,{className:`text-xs`,children:`Paste backup data and enter the export password. Imported accounts are temporary (~1h).`})]}),(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(A,{className:`text-xs`,children:`Backup data`}),(0,K.jsx)(`textarea`,{value:r,onChange:e=>a(e.target.value),placeholder:`Paste backup JSON here...`,rows:4,className:`w-full text-xs p-2 rounded border border-border bg-background font-mono resize-none focus:outline-none focus:ring-1 focus:ring-primary`})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(A,{className:`text-xs`,children:[`Password `,(0,K.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(optional)`})]}),(0,K.jsx)(O,{type:`password`,placeholder:`Leave empty for default`,value:o,onChange:e=>s(e.target.value),className:`text-xs h-8`,autoComplete:`current-password`})]})]}),u&&(0,K.jsx)(`div`,{className:`text-[11px] p-2 rounded bg-error/10 text-error`,children:u}),(0,K.jsxs)(S,{children:[(0,K.jsx)(b,{size:`sm`,variant:`outline`,className:`text-xs h-7 cursor-pointer`,onClick:f,children:`Cancel`}),(0,K.jsx)(b,{size:`sm`,className:`text-xs h-7 cursor-pointer`,disabled:!r.trim()||c,onClick:p,children:c?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(m,{className:`size-3 animate-spin mr-1`}),` Importing...`]}):`Import`})]})]})})}var X=typeof window<`u`?window.matchMedia(`(min-width: 768px)`):null;function Ne(e){return X?.addEventListener(`change`,e),()=>X?.removeEventListener(`change`,e)}function Pe(){return X?.matches??!0}function Z(){let[e,t]=(0,G.useState)(null),[n,r]=(0,G.useState)(!0);return(0,G.useEffect)(()=>{r(!0),oe().then(t).finally(()=>r(!1))},[]),n?(0,K.jsx)(`p`,{className:`text-xs text-text-subtle py-4 text-center`,children:`Loading...`}):e?(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-xs font-medium text-text-primary`,children:`Rotation Strategy`}),(0,K.jsxs)(ee,{value:e.strategy,onValueChange:async e=>{t(await R({strategy:e}))},children:[(0,K.jsx)(te,{className:`w-full h-9 text-xs`,children:(0,K.jsx)(M,{})}),(0,K.jsxs)(N,{children:[(0,K.jsx)(I,{value:`round-robin`,children:`Round-robin`}),(0,K.jsx)(I,{value:`fill-first`,children:`Fill-first`}),(0,K.jsx)(I,{value:`lowest-usage`,children:`Lowest usage`})]})]}),(0,K.jsxs)(`p`,{className:`text-[10px] text-text-subtle`,children:[e.strategy===`round-robin`&&`Cycles through accounts evenly`,e.strategy===`fill-first`&&`Uses one account until its limit, then moves on`,e.strategy===`lowest-usage`&&`Picks the account with the lowest current usage`]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-xs font-medium text-text-primary`,children:`Max Retry`}),(0,K.jsx)(`input`,{type:`number`,min:0,value:e.maxRetry,className:`w-full h-9 text-xs border rounded-md px-3 bg-background`,onChange:async e=>{let n=parseInt(e.target.value,10);!isNaN(n)&&n>=0&&t(await R({maxRetry:n}))}}),(0,K.jsx)(`p`,{className:`text-[10px] text-text-subtle`,children:`How many accounts to try on failure. 0 = try all available accounts.`})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5 border-t border-border pt-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`label`,{className:`text-xs font-medium text-text-primary`,children:`Cooldown parking`}),(0,K.jsx)(P,{checked:e.cooldownEnabled,onCheckedChange:async e=>{t(await R({cooldownEnabled:e}))}})]}),(0,K.jsx)(`p`,{className:`text-[10px] text-text-subtle`,children:`Park a failing account (rate limit / usage limit / auth error) until it recovers. Off: accounts stay selectable — rotation still skips accounts already ≥95% on the 5-hour limit.`})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between text-xs border-t border-border pt-3`,children:[(0,K.jsx)(`span`,{className:`text-text-subtle`,children:`Active accounts`}),(0,K.jsx)(`span`,{className:`font-medium text-text-primary`,children:e.activeCount})]})]}):(0,K.jsx)(`p`,{className:`text-xs text-text-subtle py-4 text-center`,children:`Failed to load settings`})}function Fe({open:e,onOpenChange:t}){let n=(0,G.useSyncExternalStore)(Ne,Pe);return e?n?(0,K.jsx)(E,{open:e,onOpenChange:t,children:(0,K.jsxs)(C,{className:`sm:max-w-sm`,children:[(0,K.jsx)(x,{children:(0,K.jsxs)(w,{className:`text-sm flex items-center gap-2`,children:[(0,K.jsx)(a,{className:`size-4`}),` Rotation & Retry`]})}),(0,K.jsx)(Z,{})]})}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 transition-opacity duration-200 opacity-100`,onClick:()=>t(!1),style:{backgroundColor:`rgba(0,0,0,0.5)`}}),(0,K.jsxs)(`div`,{className:g(`fixed bottom-0 left-0 right-0 z-50 bg-background rounded-t-2xl border-t border-border shadow-2xl`,`transition-transform duration-300 ease-out max-h-[85vh] overflow-y-auto`,`translate-y-0`),children:[(0,K.jsx)(`div`,{className:`flex justify-center pt-3 pb-1`,children:(0,K.jsx)(`div`,{className:`w-10 h-1 rounded-full bg-border`})}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-b border-border`,children:[(0,K.jsxs)(`span`,{className:`text-sm font-semibold flex items-center gap-2`,children:[(0,K.jsx)(a,{className:`size-4`}),` Rotation & Retry`]}),(0,K.jsx)(`button`,{onClick:()=>t(!1),className:`flex items-center justify-center size-7 rounded-md hover:bg-surface-elevated transition-colors`,children:(0,K.jsx)(d,{className:`size-4`})})]}),(0,K.jsx)(`div`,{className:`px-4 py-4 pb-8`,children:(0,K.jsx)(Z,{})})]})]}):null}var Ie=y(`inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2`,{variants:{variant:{default:`border-transparent bg-primary text-primary-foreground shadow`,secondary:`border-transparent bg-secondary text-secondary-foreground`,destructive:`border-transparent bg-destructive text-destructive-foreground shadow`,outline:`text-foreground`}},defaultVariants:{variant:`default`}});function Q({className:e,variant:t,...n}){return(0,K.jsx)(`div`,{className:g(Ie({variant:t}),e),...n})}function Le(e){let t=Math.floor(Date.now()/1e3);return e>t?`${Math.floor((e-t)/60)}m`:`exp`}function Re({accounts:e}){let[t,n]=(0,G.useState)([]),[r,i]=(0,G.useState)(!1),[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(new Map),l=e.filter(e=>e.hasRefreshToken);async function u(){if(l.length!==0){i(!0);try{let e=await le(l.map(e=>e.id),a);n(t=>[...t,{round:t.length+1,time:new Date().toLocaleTimeString(),includeRefresh:a,items:e}])}catch{}i(!1)}}async function d(e,t){c(t=>new Map(t).set(e,{loading:!0}));try{let n=await ue(t);c(t=>new Map(t).set(e,{loading:!1,...n}))}catch(t){c(n=>new Map(n).set(e,{loading:!1,status:`error`,error:t.message}))}}function f(e,t){return[{key:`r${e.round}-pre-${t.id}`,label:`Pre-export`,token:t.preExportTokenFull,preview:t.preExportToken,expires:t.preExportExpires},{key:`r${e.round}-exp-${t.id}`,label:`Exported`,token:t.exportedTokenFull,preview:t.exportedToken,expires:t.exportedExpires},{key:`r${e.round}-post-${t.id}`,label:`Post-export`,token:t.postExportTokenFull,preview:t.postExportToken,expires:t.postExportExpires}]}function p(){for(let e of t)for(let t of e.items)for(let n of f(e,t))n.token&&d(n.key,n.token)}return(0,K.jsxs)(`section`,{className:`border-t pt-4 space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium`,children:`Simulate export`}),t.length>0&&(0,K.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[t.length,` round(s)`]})]}),(0,K.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Every run appends a round. Earlier rounds are kept so tokens can be compared across runs.`}),l.length===0?(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No OAuth account with a refresh token to export.`}):(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(P,{id:`sim-include-refresh`,checked:a,onCheckedChange:o,className:`cursor-pointer`}),(0,K.jsx)(A,{htmlFor:`sim-include-refresh`,className:`text-[11px] cursor-pointer`,children:`Include refresh tokens`})]}),(0,K.jsx)(b,{size:`sm`,className:`h-7 text-xs cursor-pointer`,disabled:r,onClick:()=>void u(),children:r?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(m,{className:`size-3 animate-spin mr-1`}),` Exporting...`]}):`Run export #${t.length+1}`})]}),t.length>0&&(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(b,{size:`sm`,variant:`outline`,className:`w-full h-7 text-[11px] cursor-pointer`,onClick:p,children:[`Test all tokens (`,t.reduce((e,t)=>e+t.items.length*3,0),`)`]}),t.map(e=>(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`p`,{className:`text-xs font-medium text-primary`,children:[`Round #`,e.round]}),(0,K.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:e.time}),(0,K.jsx)(Q,{variant:e.includeRefresh?`destructive`:`secondary`,className:`text-[9px] px-1 py-0`,children:e.includeRefresh?`with refresh`:`access only`})]}),e.items.map(t=>(0,K.jsxs)(`div`,{className:`p-2 rounded-lg border bg-card space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-[11px] font-medium`,children:t.label??t.email??t.id.slice(0,8)}),t.tokenChanged&&(0,K.jsx)(Q,{variant:`secondary`,className:`text-[9px] px-1 py-0`,children:`DB token changed`})]}),f(e,t).map(e=>{let t=s.get(e.key);return(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px]`,children:[(0,K.jsx)(`span`,{className:`w-20 shrink-0 text-muted-foreground text-[10px]`,children:e.label}),(0,K.jsx)(`code`,{className:`flex-1 truncate font-mono text-[10px] bg-muted px-1 rounded`,children:e.preview??`N/A`}),e.expires&&(0,K.jsx)(`span`,{className:`text-[10px] text-muted-foreground shrink-0`,children:Le(e.expires)}),e.token?(0,K.jsx)(b,{size:`sm`,variant:`outline`,className:`h-6 text-[10px] px-1.5 cursor-pointer shrink-0`,disabled:t?.loading,onClick:()=>void d(e.key,e.token),children:t?.loading?(0,K.jsx)(m,{className:`size-3 animate-spin`}):`Test`}):(0,K.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`-`}),t&&!t.loading&&(0,K.jsx)(`span`,{className:`text-[10px] font-medium shrink-0 ${t.status?.startsWith(`valid`)?`text-success`:`text-error`}`,children:t.status})]},e.key)})]},`r${e.round}-${t.id}`))]},e.round))]})]})}function ze(e){let t=Math.floor(Date.now()/1e3),n=Math.floor(Math.abs(e-t)/60);return e>t?`${n}m left`:`expired ${n}m ago`}function Be({open:e,onOpenChange:t,accounts:n}){let[i,a]=(0,G.useState)(new Map),[o,s]=(0,G.useState)(!1);async function c(e){a(t=>new Map(t).set(e,{loading:!0}));try{let t=await ne(e,o);a(n=>new Map(n).set(e,{loading:!1,result:t}))}catch(t){a(n=>new Map(n).set(e,{loading:!1,error:t.message}))}}function l(){for(let e of n.filter(e=>e.expiresAt!==null))c(e.id)}return(0,K.jsx)(E,{open:e,onOpenChange:t,children:(0,K.jsxs)(C,{className:`sm:max-w-xl max-h-[85vh] flex flex-col`,children:[(0,K.jsxs)(x,{children:[(0,K.jsxs)(w,{className:`text-sm flex items-center gap-1.5`,children:[(0,K.jsx)(r,{className:`size-4`}),` Token Test`]}),(0,K.jsx)(T,{className:`text-xs`,children:`Probe stored tokens for validity. Nothing is modified.`})]}),(0,K.jsxs)(`div`,{className:`space-y-4 overflow-y-auto flex-1 pr-1`,children:[(0,K.jsxs)(`section`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium`,children:`Current tokens`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(P,{id:`token-test-refresh`,checked:o,onCheckedChange:s,className:`cursor-pointer`}),(0,K.jsx)(A,{htmlFor:`token-test-refresh`,className:`text-[11px] cursor-pointer`,children:`Also test refresh`})]}),(0,K.jsx)(b,{size:`sm`,variant:`outline`,className:`h-7 text-xs cursor-pointer`,onClick:l,children:`Test all`})]})]}),n.length===0&&(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No accounts to test.`}),(0,K.jsx)(`div`,{className:`space-y-1.5`,children:n.map(e=>{let t=i.get(e.id),n=t?.result?.accessToken.status;return(0,K.jsxs)(`div`,{className:`p-2 rounded border bg-card space-y-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`span`,{className:`text-xs font-medium truncate block`,children:e.label??e.email??e.id.slice(0,8)}),e.expiresAt&&(0,K.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:ze(e.expiresAt)})]}),(0,K.jsx)(b,{size:`sm`,variant:`outline`,className:`h-7 text-xs cursor-pointer shrink-0`,disabled:t?.loading,onClick:()=>void c(e.id),children:t?.loading?(0,K.jsx)(m,{className:`size-3 animate-spin`}):`Test`})]}),t&&!t.loading&&(0,K.jsxs)(`div`,{className:`text-[11px] pl-2 border-l-2 border-muted`,children:[t.error&&(0,K.jsx)(`p`,{className:`text-error`,children:t.error}),n&&(0,K.jsxs)(`span`,{className:n.startsWith(`valid`)?`text-success`:`text-error`,children:[n,t.result?.accessToken.code?` (${t.result.accessToken.code})`:``]})]})]},e.id)})})]}),(0,K.jsx)(Re,{accounts:n})]}),(0,K.jsx)(S,{children:(0,K.jsx)(b,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:()=>t(!1),children:`Close`})})]})})}function Ve(){let{usages:e,accounts:t,activeAccountId:n,initialLoading:i,refreshing:o,flashIds:s,reload:d}=ge(),[p,h]=(0,G.useState)(null),[g,_]=(0,G.useState)(null),[v,y]=(0,G.useState)(null),[x,S]=(0,G.useState)(null),[C,w]=(0,G.useState)(null),[T,E]=(0,G.useState)(null),[D,O]=(0,G.useState)(void 0);function k(e){d(),e&&h(e)}async function A(e,t){_(e);try{await ie(e,{status:t===`disabled`?`active`:`disabled`})}catch(e){h(e.message)}_(null),d()}async function j(){if(v){try{await ce(v.id),h(`Account "${v.display}" removed.`),d()}catch(e){h(`Failed to remove: ${e.message}`)}y(null)}}let M=new Map(t.map(e=>[e.id,e])),N=e[0]?.usage.lastFetchedAt;return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(B,{description:`Connect multiple Claude accounts. PPM rotates between them automatically to avoid rate limits.`,onRefresh:()=>void d(),refreshing:o,disabled:i,actions:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(b,{size:`sm`,className:`cursor-pointer gap-1.5`,onClick:()=>{O(void 0),E(`add`)},children:[(0,K.jsx)(l,{className:`size-4`}),` Add account`]}),(0,K.jsxs)(b,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>{w(null),E(`export`)},children:[(0,K.jsx)(u,{className:`size-4`}),` Export`]}),(0,K.jsxs)(b,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>E(`import`),children:[(0,K.jsx)(c,{className:`size-4`}),` Import`]}),(0,K.jsxs)(b,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>E(`rotation`),children:[(0,K.jsx)(a,{className:`size-4`}),` Rotation`]}),(0,K.jsxs)(b,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>E(`token-test`),children:[(0,K.jsx)(r,{className:`size-4`}),` Token test`]})]})}),(0,K.jsx)(z,{message:p,onDismiss:()=>h(null)}),(0,K.jsxs)(`section`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium`,children:`Accounts`}),N&&(0,K.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`usage `,pe(new Date(N).getTime())]})]}),i?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-xs text-muted-foreground`,children:[(0,K.jsx)(m,{className:`size-4 animate-spin`}),` Loading accounts...`]}):e.length===0?(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-8 text-center`,children:[(0,K.jsx)(f,{className:`size-5 text-muted-foreground`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No accounts connected yet.`}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Add one to start using PPM.`})]}):(0,K.jsx)(V,{children:e.map(e=>(0,K.jsx)(Se,{layout:`strip`,entry:e,isActive:e.accountId===n,accountInfo:M.get(e.accountId),onToggle:A,toggling:g===e.accountId,onDelete:(e,t)=>y({id:e,display:t}),onExport:e=>{w(e),E(`export`)},onViewProfile:(e,t)=>S({profile:e,accountId:t}),onReauth:()=>{O({id:e.accountId,label:e.accountLabel??e.accountId.slice(0,8)}),E(`add`)},flash:s.has(e.accountId)},e.accountId))})]}),x&&(0,K.jsx)(Oe,{profile:x.profile,accountId:x.accountId,onClose:()=>S(null)}),v&&(0,K.jsx)(ke,{display:v.display,onConfirm:()=>void j(),onCancel:()=>y(null)}),(0,K.jsx)(me,{open:T===`add`,onOpenChange:e=>{E(e?`add`:null),e||O(void 0)},onSuccess:k,signInAgainFor:D}),(0,K.jsx)(je,{open:T===`export`,onOpenChange:e=>{E(e?`export`:null),e||w(null)},accounts:t,preselectId:C,onMessage:h}),(0,K.jsx)(Me,{open:T===`import`,onOpenChange:e=>E(e?`import`:null),onSuccess:k}),(0,K.jsx)(Fe,{open:T===`rotation`,onOpenChange:e=>E(e?`rotation`:null)}),(0,K.jsx)(Be,{open:T===`token-test`,onOpenChange:e=>E(e?`token-test`:null),accounts:t})]})}function He({mode:e,onOpenChange:t,password:n,onPasswordChange:r,busy:a,onExport:o,onImport:s,error:l}){let d=(0,G.useRef)(null),f=e===`export`;return(0,K.jsx)(E,{open:e!==null,onOpenChange:t,children:(0,K.jsxs)(C,{className:`sm:max-w-md`,children:[(0,K.jsxs)(x,{children:[(0,K.jsxs)(w,{className:`text-sm flex items-center gap-1.5`,children:[(0,K.jsx)(i,{className:`size-4`}),` `,f?`Export Codex Accounts`:`Import Codex Accounts`]}),(0,K.jsx)(T,{className:`text-xs leading-relaxed`,children:f?`Writes a password-encrypted file containing each account's login.`:`Reads a backup file. The password must be the one it was exported with.`})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(A,{htmlFor:`codex-backup-password`,className:`text-xs`,children:`Password`}),(0,K.jsx)(O,{id:`codex-backup-password`,type:`password`,placeholder:f?`Choose a password`:`Password used for the export`,value:n,onChange:e=>r(e.target.value),className:`text-xs`,autoComplete:f?`new-password`:`current-password`}),(0,K.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`A backup holds full logins — keep the file and its password together.`})]}),l&&(0,K.jsx)(`div`,{className:`text-[11px] p-2 rounded bg-error/10 text-error`,children:l}),(0,K.jsx)(`input`,{ref:d,type:`file`,accept:`application/json,.json`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&s(t)}}),(0,K.jsxs)(S,{children:[(0,K.jsx)(b,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:()=>t(!1),children:`Cancel`}),(0,K.jsxs)(b,{size:`sm`,className:`text-xs cursor-pointer gap-1.5`,disabled:!n.trim()||a,onClick:()=>f?o():d.current?.click(),children:[a?(0,K.jsx)(m,{className:`size-3.5 animate-spin`}):f?(0,K.jsx)(u,{className:`size-3.5`}):(0,K.jsx)(c,{className:`size-3.5`}),f?`Download backup`:`Choose file`]})]})]})})}var Ue=[{value:`round-robin`,label:`Round-robin`,hint:`Take the next account each time.`},{value:`fill-first`,label:`Fill-first`,hint:`Stay on one account until it runs out.`},{value:`lowest-usage`,label:`Lowest usage`,hint:`Pick whichever has the most left.`}];function We({open:e,onOpenChange:t,strategy:n,onChange:r}){return(0,K.jsx)(E,{open:e,onOpenChange:t,children:(0,K.jsxs)(C,{className:`sm:max-w-md`,children:[(0,K.jsxs)(x,{children:[(0,K.jsx)(w,{className:`text-sm`,children:`Codex Rotation`}),(0,K.jsx)(T,{className:`text-xs leading-relaxed`,children:`How a new chat chooses among your Codex accounts.`})]}),(0,K.jsx)(`div`,{className:`space-y-2`,children:Ue.map(e=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>r(e.value),"aria-current":n===e.value?`true`:void 0,className:g(`w-full text-left rounded-md border px-3 py-2.5 min-h-11 cursor-pointer transition-colors`,n===e.value?`border-primary bg-primary/10`:`border-border hover:bg-accent/50 active:bg-accent`),children:[(0,K.jsx)(`p`,{className:`text-sm font-medium`,children:e.label}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.hint})]},e.value))}),(0,K.jsx)(S,{children:(0,K.jsx)(b,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:()=>t(!1),children:`Done`})})]})})}function $(e){return e==null?null:Math.round(e*100)}function Ge({usage:e}){let t=e.session==null&&e.weekly==null;return(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(t||e.session!=null)&&(0,K.jsx)(W,{label:`5-Hour Session`,pct:$(e.fiveHour),reset:U(e.session),resetsAt:e.session?.resetsAt}),(t||e.weekly!=null)&&(0,K.jsx)(W,{label:`Weekly`,pct:$(e.sevenDay),reset:U(e.weekly),resetsAt:e.weekly?.resetsAt})]})}function Ke(){let[e,t]=(0,G.useState)(null),n=fe(()=>t(null)),[r,i]=(0,G.useState)(null);return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(B,{description:(0,K.jsxs)(K.Fragment,{children:[`Each Codex account keeps its own login (`,(0,K.jsx)(`code`,{children:`CODEX_HOME`}),`). One is picked per chat by the rotation setting.`]}),onRefresh:()=>void n.load(),refreshing:n.loading,actions:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(b,{size:`sm`,className:`cursor-pointer gap-1.5`,onClick:()=>t(`add`),children:[(0,K.jsx)(l,{className:`size-4`}),` Add account`]}),(0,K.jsxs)(b,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>t(`export`),children:[(0,K.jsx)(u,{className:`size-4`}),` Export`]}),(0,K.jsxs)(b,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>t(`import`),children:[(0,K.jsx)(c,{className:`size-4`}),` Import`]}),(0,K.jsxs)(b,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>t(`rotation`),children:[(0,K.jsx)(a,{className:`size-4`}),` Rotation`]})]})}),(0,K.jsx)(z,{message:n.msg??n.err,onDismiss:()=>{n.setMsg(null),n.setErr(null)}}),(0,K.jsxs)(`section`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium`,children:`Codex Accounts`}),(0,K.jsx)(`span`,{className:`text-[10px] text-muted-foreground capitalize`,children:n.strategy.replace(`-`,` `)})]}),n.loading&&n.accounts.length===0?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-xs text-muted-foreground`,children:[(0,K.jsx)(m,{className:`size-4 animate-spin`}),` Loading accounts...`]}):n.accounts.length===0?(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-8 text-center`,children:[(0,K.jsx)(f,{className:`size-5 text-muted-foreground`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No Codex accounts yet.`}),(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Chats use your default `,(0,K.jsx)(`code`,{children:`~/.codex`}),` login until you add one.`]})]}):(0,K.jsx)(V,{children:n.accounts.map(e=>{let t=n.usages[e.id]??{};return(0,K.jsxs)(_e,{dense:!0,className:`min-w-[300px] shrink-0 snap-start${e.signedOut?` opacity-60`:``}`,"data-testid":`account-card`,"data-account-id":e.id,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium truncate flex-1 min-w-0`,children:e.label}),e.signedOut&&(0,K.jsx)(de,{className:`text-[10px] text-error shrink-0 font-medium`,hint:`Codex rejected this account's login (revoked or expired), so no turn can run on it and it is skipped. The usage shown is the last reading. Click to sign in again — the account keeps its settings and chats.`,onClick:e.type===`chatgpt`?()=>i(e):void 0,children:`Sign in again`}),(0,K.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-text-subtle border border-border rounded px-1 shrink-0`,children:e.type}),H(e.planType)&&(0,K.jsx)(`span`,{className:`text-[10px] text-text-subtle shrink-0`,children:H(e.planType)}),(0,K.jsx)(P,{checked:e.status!==`disabled`,onCheckedChange:()=>void n.toggle(e.id,e.status??`active`),disabled:n.toggling.has(e.id),"aria-label":e.status===`disabled`?`Enable account`:`Disable account`,className:`cursor-pointer shrink-0`}),(0,K.jsxs)(F,{children:[(0,K.jsx)(j,{asChild:!0,children:(0,K.jsx)(`button`,{type:`button`,onClick:()=>void n.remove(e.id),"aria-label":`Remove account`,className:`p-2 rounded cursor-pointer text-text-subtle hover:text-error hover:bg-surface-elevated transition-colors shrink-0`,children:(0,K.jsx)(s,{className:`size-4`})})}),(0,K.jsx)(L,{side:`top`,children:`Remove account`})]})]}),(0,K.jsx)(Ge,{usage:t}),t.resetCredits&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap text-[10px] text-text-subtle`,children:[(0,K.jsx)(he,{credits:t.resetCredits}),(0,K.jsx)(xe,{account:e,usage:t,onDone:e=>{n.setMsg(e),n.load()}})]}),t.session==null&&(()=>{let r=ye(t.weekly);return r?(0,K.jsxs)(`div`,{className:`flex min-h-12 items-center justify-between gap-3 rounded-md border px-2.5 py-1.5 ${e.dailyGuardEnabled&&r.blocked?`border-error/40 bg-error/5`:`border-border/50 bg-surface/40`}`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 space-y-0.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-medium ${e.dailyGuardEnabled&&r.blocked?`text-error`:`text-text-secondary`}`,children:[(0,K.jsx)(`span`,{children:`Daily guard`}),(0,K.jsxs)(F,{children:[(0,K.jsx)(j,{asChild:!0,children:(0,K.jsx)(`button`,{type:`button`,"aria-label":`About Daily guard`,className:`text-text-subtle hover:text-text-primary cursor-help`,children:(0,K.jsx)(o,{className:`size-3.5`})})}),(0,K.jsx)(L,{side:`top`,className:`max-w-64 text-xs leading-relaxed`,children:`Spreads the weekly quota across five weekdays, adding 20% per weekday. Weekend slots keep the previous cap; unused allowance carries forward. Daily slots start at the reset time and use UTC weekdays. Turn it off any time to use the remaining quota freely.`})]})]}),(0,K.jsx)(`p`,{className:`text-[10px] tabular-nums ${e.dailyGuardEnabled&&r.blocked?`text-error`:`text-text-subtle`}`,children:e.dailyGuardEnabled&&r.blocked?`${Math.round(r.used*100)}% used / ${Math.round(r.cap*100)}% daily cap. New turns paused.`:`Weekday ${r.day}/5, ${Math.round(r.cap*100)}% daily cap`})]}),(0,K.jsxs)(`span`,{className:`hidden`,title:`Weekday ${r.day}/5: hold weekly usage at or below ${Math.round(r.cap*100)}% to last until reset.`,children:[`Daily guard `,e.dailyGuardEnabled?`· Weekday ${r.day}/5 cap ${Math.round(r.cap*100)}%`:``]}),(0,K.jsx)(P,{checked:!!e.dailyGuardEnabled,onCheckedChange:()=>void n.toggleDailyGuard(e.id,!!e.dailyGuardEnabled),disabled:n.toggling.has(e.id),"aria-label":e.dailyGuardEnabled?`Disable Daily guard`:`Enable Daily guard`,className:`cursor-pointer shrink-0`})]}):null})()]},e.id)})})]}),(0,K.jsx)(be,{open:e===`add`,onOpenChange:e=>{e||n.cancelLogin(),t(e?`add`:null)},label:n.label,onLabelChange:n.setLabel,apiKey:n.apiKey,onApiKeyChange:n.setApiKey,adding:n.adding,onAddApiKey:()=>void n.addApiKey(),deviceWaiting:n.deviceWaiting,onStartDevice:()=>void n.startDevice(),device:n.device,browser:n.browser,onStartBrowser:()=>void n.startBrowser(),loginStarting:n.loginStarting,callbackUrl:n.callbackUrl,onCallbackUrlChange:n.setCallbackUrl,submittingCallback:n.submittingCallback,onSubmitCallback:()=>void n.submitCallback(),error:n.err}),(0,K.jsx)(He,{mode:e===`export`?`export`:e===`import`?`import`:null,onOpenChange:e=>{e||t(null)},password:n.backupPassword,onPasswordChange:n.setBackupPassword,busy:n.exporting||n.importing,onExport:()=>void n.doExport(),onImport:e=>void n.doImport(e),error:n.err}),r&&(0,K.jsx)(ve,{account:r,onClose:()=>i(null),onDone:()=>void n.load()}),(0,K.jsx)(We,{open:e===`rotation`,onOpenChange:e=>t(e?`rotation`:null),strategy:n.strategy,onChange:e=>void n.changeStrategy(e)})]})}var qe=[{id:`claude`,label:`Claude`},{id:`codex`,label:`Codex`}];function Je(){let[e,t]=(0,G.useState)(null),[n,r]=(0,G.useState)(`claude`);(0,G.useEffect)(()=>{let e=!1;return re().then(n=>{e||t(new Set(Object.keys(n.providers??{})))}).catch(()=>{e||t(new Set([`claude`]))}),()=>{e=!0}},[]);let i=qe.filter(t=>t.id===`claude`||e?.has(t.id)),a=i.length>1;return(0,K.jsxs)(`div`,{className:`space-y-4`,"data-testid":`accounts-pane`,"data-provider":n,children:[a&&(0,K.jsx)(`div`,{className:`flex gap-1 border-b border-border/50`,children:i.map(e=>(0,K.jsxs)(`button`,{onClick:()=>r(e.id),"data-testid":`accounts-tab-${e.id}`,"aria-current":n===e.id?`page`:void 0,className:`flex items-center gap-1.5 px-3 py-2 text-xs rounded-t transition-colors cursor-pointer ${n===e.id?`text-primary border-b-2 border-primary font-medium`:`text-text-subtle hover:text-text-secondary`}`,children:[(0,K.jsx)(k,{providerId:e.id}),e.label]},e.id))}),e===null&&!a&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,K.jsx)(m,{className:`size-3 animate-spin`}),` Checking configured providers...`]}),n===`claude`?(0,K.jsx)(Ve,{}):(0,K.jsx)(Ke,{})]})}export{Je as AccountsSettingsSection};
|
|
1
|
+
import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{D as t,E as n}from"./vendor-markdown-C-P1aR4p.js";import"./vendor-ui-BTSIXzhZ.js";import{At as r,Cn as i,Cr as a,J as o,Kr as s,Zr as c,cr as l,ht as u,li as d,ln as f,ut as p,xn as m}from"./icons-BwyIKaTT.js";import{a as h}from"./api-client-xQDlhUTu.js";import{n as g}from"./utils-Bslrbb-G.js";import"./portal-container-context-NBi-KGK0.js";import"./chat-preparation-cache-190LLyy7.js";import{n as _}from"./use-is-mobile-VRV9eZy1.js";import{r as v}from"./clipboard-D-VCry-F.js";import{r as y,t as b}from"./button-C9ZXWb3b.js";import{a as x,i as S,n as C,o as w,r as T,t as E}from"./dialog-Dn_2tuYa.js";import{t as D}from"./mobile-bottom-sheet-DArbIyrD.js";import"./use-visual-viewport-MmugpRg-.js";import{t as O}from"./input-C3oVNCMq.js";import{Ai as k,Er as A,Gi as j,Gn as M,Hn as N,Kn as P,Ui as F,Un as I,Vn as ee,Wi as L,Wn as te}from"./index-BtAn_krv.js";import{_ as ne,a as re,h as ie,m as ae,o as oe,p as se,r as ce,v as le,x as R,y as ue}from"./api-settings-vmIRFNwZ.js";import{_ as de,a as fe,b as pe,c as me,d as he,g as z,h as B,l as ge,m as _e,n as ve,o as ye,p as V,r as be,s as H,t as xe,u as Se,x as U,y as W}from"./codex-reset-credit-button-CGMbIHak.js";var G=e(t(),1),K=n(),q=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],J=Array.from({length:24},(e,t)=>t);function Ce(e,t){let n=Array.from({length:7},()=>Array.from({length:24},()=>({sum:0,count:0,avg:0})));for(let r of e){let e=t===`5h`?r.five_hour_util:r.weekly_util;if(e==null)continue;let i=new Date(r.recorded_at+(r.recorded_at.endsWith(`Z`)?``:`Z`)),a=(i.getDay()+6)%7,o=i.getHours();n[a][o].sum+=e,n[a][o].count+=1}for(let e of n)for(let t of e)t.avg=t.count>0?t.sum/t.count:0;return n}function we(e){return e.map(e=>{let t=e.reduce((e,t)=>e+t.sum,0),n=e.reduce((e,t)=>e+t.count,0);return n>0?t/n:0})}function Te(e){return J.map(t=>{let n=0,r=0;for(let i of e)n+=i[t].sum,r+=i[t].count;return r>0?n/r:0})}function Y(e){return e===0?`bg-surface-elevated`:e<.3?`bg-success/30`:e<.5?`bg-success/60`:e<.7?`bg-warning/50`:e<.9?`bg-warning/80`:`bg-error/80`}function Ee(e){return e<.3?`bg-success`:e<.7?`bg-warning`:`bg-error`}function De({accountId:e}){let[t,n]=(0,G.useState)(null),[r,i]=(0,G.useState)(!0),[a,o]=(0,G.useState)(`5h`);(0,G.useEffect)(()=>{i(!0),se(e).then(n).catch(()=>n([])).finally(()=>i(!1))},[e]);let s=(0,G.useMemo)(()=>t?Ce(t,a):null,[t,a]),c=(0,G.useMemo)(()=>s?we(s):[],[s]),l=(0,G.useMemo)(()=>s?Te(s):[],[s]),u=Math.max(...c,.01);if(Math.max(...l,.01),r)return(0,K.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,K.jsx)(m,{className:`size-3 animate-spin text-text-subtle`})});if(!t||t.length===0)return(0,K.jsx)(`div`,{className:`text-[10px] text-text-subtle py-2 text-center`,children:`No usage history yet`});let d=t.length,f=new Set(t.map(e=>new Date(e.recorded_at+(e.recorded_at.endsWith(`Z`)?``:`Z`)).toDateString())).size;return(0,K.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-[10px] font-medium text-text-subtle`,children:`Usage Pattern (7d)`}),(0,K.jsxs)(`div`,{className:`flex gap-0.5 text-[9px]`,children:[(0,K.jsx)(`button`,{onClick:()=>o(`5h`),className:`px-1.5 py-0.5 rounded cursor-pointer transition-colors ${a===`5h`?`bg-primary/15 text-primary`:`text-text-subtle hover:text-text-secondary`}`,title:`5-hour rolling window limit — resets every 5 hours`,children:`5h`}),(0,K.jsx)(`button`,{onClick:()=>o(`weekly`),className:`px-1.5 py-0.5 rounded cursor-pointer transition-colors ${a===`weekly`?`bg-primary/15 text-primary`:`text-text-subtle hover:text-text-secondary`}`,title:`Weekly limit — resets every 7 days`,children:`Wk`})]})]}),(0,K.jsxs)(`p`,{className:`text-[9px] text-text-subtle leading-tight`,children:[`Avg `,a===`5h`?`5-hour`:`weekly`,` limit usage over `,f,`d (`,d,` samples). Higher % = closer to rate limit. Hover cells for details.`]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-[9px] text-text-subtle`,children:`Avg usage by day of week`}),(0,K.jsx)(`div`,{className:`flex flex-col gap-[2px] mt-0.5`,children:q.map((e,t)=>{let n=c[t]??0;return(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`span`,{className:`text-[8px] text-text-subtle w-5 shrink-0 text-right tabular-nums`,children:e}),(0,K.jsx)(`div`,{className:`flex-1 h-2.5 bg-surface-elevated rounded-sm overflow-hidden`,children:(0,K.jsx)(`div`,{className:`h-full rounded-sm transition-all ${Ee(n)}`,style:{width:`${Math.round(n/u*100)}%`}})}),(0,K.jsxs)(`span`,{className:`text-[8px] text-text-subtle w-6 shrink-0 text-right tabular-nums`,children:[Math.round(n*100),`%`]})]},e)})})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-[9px] text-text-subtle`,children:`Avg usage by hour (0h-23h)`}),(0,K.jsx)(`div`,{className:`flex gap-[1px] mt-0.5`,children:J.map(e=>{let t=l[e]??0;return(0,K.jsxs)(`div`,{className:`flex-1 flex flex-col items-center gap-[1px]`,children:[(0,K.jsx)(`div`,{className:`w-full aspect-square rounded-[2px] ${Y(t)}`,title:`${e}:00 — avg ${Math.round(t*100)}% usage`}),e%6==0&&(0,K.jsx)(`span`,{className:`text-[7px] text-text-subtle tabular-nums`,children:e})]},e)})})]}),s&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-[9px] text-text-subtle`,children:`Day x Hour heatmap`}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-[1px] mt-0.5`,children:[q.map((e,t)=>(0,K.jsxs)(`div`,{className:`flex items-center gap-[1px]`,children:[(0,K.jsx)(`span`,{className:`text-[7px] text-text-subtle w-4 shrink-0 text-right`,children:e.charAt(0)}),J.map(n=>{let r=s[t][n];return(0,K.jsx)(`div`,{className:`flex-1 aspect-square rounded-[1px] ${Y(r.avg)}`,title:`${e} ${n}:00 — ${r.count>0?`avg ${Math.round(r.avg*100)}% (${r.count} samples)`:`no data`}`},n)})]},e)),(0,K.jsxs)(`div`,{className:`flex items-center gap-[1px]`,children:[(0,K.jsx)(`span`,{className:`w-4 shrink-0`}),J.map(e=>(0,K.jsx)(`div`,{className:`flex-1 text-center`,children:e%6==0&&(0,K.jsx)(`span`,{className:`text-[7px] text-text-subtle tabular-nums`,children:e})},e))]})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[8px] text-text-subtle`,children:[(0,K.jsx)(`span`,{children:`Low`}),(0,K.jsxs)(`div`,{className:`flex gap-[2px]`,children:[(0,K.jsx)(`div`,{className:`size-2 rounded-[1px] bg-success/30`}),(0,K.jsx)(`div`,{className:`size-2 rounded-[1px] bg-success/60`}),(0,K.jsx)(`div`,{className:`size-2 rounded-[1px] bg-warning/50`}),(0,K.jsx)(`div`,{className:`size-2 rounded-[1px] bg-warning/80`}),(0,K.jsx)(`div`,{className:`size-2 rounded-[1px] bg-error/80`})]}),(0,K.jsx)(`span`,{children:`High`}),(0,K.jsx)(`span`,{className:`ml-1`,children:`|`}),(0,K.jsx)(`div`,{className:`size-2 rounded-[1px] bg-surface-elevated border border-border/30`}),(0,K.jsx)(`span`,{children:`No data`})]})]})}function Oe({profile:e,accountId:t,onClose:n}){let r=[[`Name`,e.account?.display_name],[`Email`,e.account?.email],[`Org`,e.organization?.name],[`Type`,e.organization?.organization_type],[`Tier`,e.organization?.rate_limit_tier],[`Status`,e.organization?.subscription_status]];return(0,K.jsxs)(`section`,{className:`space-y-2 border-t border-border pt-3`,"data-testid":`account-profile-panel`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium`,children:`Profile`}),(0,K.jsx)(`button`,{className:`p-2 text-muted-foreground hover:text-foreground cursor-pointer`,onClick:n,"aria-label":`Close profile`,children:(0,K.jsx)(d,{className:`size-4`})})]}),(0,K.jsx)(`div`,{className:`grid grid-cols-[80px_1fr] gap-x-3 gap-y-1 text-xs`,children:r.map(([e,t])=>t?(0,K.jsxs)(`span`,{className:`contents`,children:[(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,K.jsx)(`span`,{className:`break-all`,children:t})]},e):null)}),(0,K.jsx)(De,{accountId:t})]})}function ke({display:e,onConfirm:t,onCancel:n}){let r=_(),i=(0,K.jsxs)(`div`,{className:`space-y-4`,"data-testid":`account-delete-confirm`,children:[(0,K.jsxs)(`p`,{className:`text-sm`,children:[`Remove `,(0,K.jsx)(`span`,{className:`font-medium`,children:e}),`?`]}),(0,K.jsx)(`p`,{className:`text-xs text-text-subtle`,children:`The stored token is deleted from this machine. Any export you already made keeps working.`}),(0,K.jsxs)(`div`,{className:`flex flex-col-reverse md:flex-row gap-2 md:justify-end pt-2`,children:[(0,K.jsx)(b,{variant:`outline`,onClick:n,className:`min-h-11`,children:`Cancel`}),(0,K.jsx)(b,{variant:`destructive`,autoFocus:!1,onClick:t,className:`min-h-11`,children:`Remove account`})]})]});return r?(0,K.jsx)(D,{open:!0,onClose:n,children:(0,K.jsxs)(`div`,{className:`px-4 pb-4`,children:[(0,K.jsx)(`h2`,{className:`text-base font-semibold mb-3`,children:`Remove account`}),i]})}):(0,K.jsx)(E,{open:!0,onOpenChange:e=>{e||n()},children:(0,K.jsxs)(C,{className:`sm:max-w-sm`,children:[(0,K.jsx)(x,{children:(0,K.jsx)(w,{className:`text-sm`,children:`Remove account`})}),i]})})}function Ae(e){let t=new Blob([e],{type:`application/json`}),n=document.createElement(`a`);n.href=URL.createObjectURL(t),n.download=`ppm-accounts-backup.json`,n.click(),URL.revokeObjectURL(n.href)}function je({open:e,onOpenChange:t,accounts:n,preselectId:r,onMessage:a}){let o=n.filter(e=>e.hasRefreshToken),[s,c]=(0,G.useState)(new Set),[l,d]=(0,G.useState)(``),[f,g]=(0,G.useState)(!1),[_,y]=(0,G.useState)(!1),[D,k]=(0,G.useState)(!1),[j,M]=(0,G.useState)(!1);e&&!j&&(c(r?new Set([r]):new Set(o.map(e=>e.id))),M(!0)),!e&&j&&M(!1);function N(){t(!1),d(``),g(!1),y(!1)}async function P(e){if(s.size===0)return;k(!0);let t=l.trim()||`ppm-hienlh`;try{let n={"Content-Type":`application/json`},r=h();r&&(n.Authorization=`Bearer ${r}`);let i=await fetch(`/api/accounts/export`,{method:`POST`,headers:n,body:JSON.stringify({password:t,accountIds:[...s],includeRefreshToken:f,refreshBeforeExport:_})});if(!i.ok){let e=await i.json();throw Error(e.error??`Export failed: ${i.status}`)}let o=await i.text();e&&await v(o)?a?.(`Backup copied to clipboard!`):(Ae(o),a?.(`Backup downloaded.`)),N()}catch{}k(!1)}let F=s.size>0&&!D;return(0,K.jsx)(E,{open:e,onOpenChange:e=>{e||N()},children:(0,K.jsxs)(C,{className:`sm:max-w-md`,children:[(0,K.jsxs)(x,{children:[(0,K.jsxs)(w,{className:`text-sm flex items-center gap-1.5`,children:[(0,K.jsx)(i,{className:`size-3.5`}),` Export Accounts`]}),(0,K.jsx)(T,{className:`text-xs`,children:`Select accounts and set a password to protect the backup.`})]}),(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,K.jsx)(`p`,{className:`text-[11px] font-medium text-muted-foreground`,children:`Accounts to export`}),(0,K.jsx)(`button`,{className:`text-[10px] text-primary hover:underline cursor-pointer`,onClick:()=>c(s.size===o.length?new Set:new Set(o.map(e=>e.id))),children:s.size===o.length?`Deselect all`:`Select all`})]}),o.length===0?(0,K.jsx)(`p`,{className:`text-[10px] text-muted-foreground p-2 border rounded`,children:`No exportable accounts.`}):(0,K.jsx)(`div`,{className:`max-h-36 overflow-y-auto space-y-1 border rounded p-2`,children:o.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`checkbox`,id:`exp-${e.id}`,checked:s.has(e.id),onChange:t=>{let n=new Set(s);t.target.checked?n.add(e.id):n.delete(e.id),c(n)},className:`size-3.5 accent-primary cursor-pointer`}),(0,K.jsx)(`label`,{htmlFor:`exp-${e.id}`,className:`text-xs cursor-pointer truncate`,children:e.label??e.email??e.id.slice(0,8)})]},e.id))})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(A,{className:`text-xs`,children:[`Password `,(0,K.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(optional)`})]}),(0,K.jsx)(O,{type:`password`,placeholder:`Leave empty for default`,value:l,onChange:e=>d(e.target.value),className:`text-xs h-8`,autoComplete:`new-password`})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`checkbox`,id:`exp-full`,checked:f,onChange:e=>g(e.target.checked),className:`size-3.5 accent-primary cursor-pointer`}),(0,K.jsx)(`label`,{htmlFor:`exp-full`,className:`text-[11px] cursor-pointer`,children:`Include refresh tokens (full transfer)`})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`checkbox`,id:`exp-refresh`,checked:_,onChange:e=>y(e.target.checked),className:`size-3.5 accent-primary cursor-pointer`}),(0,K.jsx)(`label`,{htmlFor:`exp-refresh`,className:`text-[11px] cursor-pointer`,children:`Refresh tokens before export`})]}),f?(0,K.jsxs)(`div`,{className:`rounded-md border border-error/30 bg-error/5 p-2.5`,children:[(0,K.jsx)(`p`,{className:`text-[10px] font-medium text-error`,children:`Full transfer — source accounts will expire`}),(0,K.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Refresh tokens included. Source machine expires in ~1h after target refreshes.`})]}):_?(0,K.jsx)(`div`,{className:`rounded-md border border-warning/30 bg-warning/5 p-2.5`,children:(0,K.jsx)(`p`,{className:`text-[10px] font-medium text-warning`,children:`Refresh before export — invalidates previous shares`})}):(0,K.jsx)(`div`,{className:`rounded-md border border-success/30 bg-success/5 p-2.5`,children:(0,K.jsx)(`p`,{className:`text-[10px] font-medium text-success`,children:`Share current token (safe)`})}),(0,K.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Encrypted with AES-256-GCM + scrypt.`})]}),(0,K.jsxs)(S,{className:`gap-1.5 flex-col sm:flex-row`,children:[(0,K.jsx)(b,{size:`sm`,variant:`outline`,className:`text-xs h-7 cursor-pointer`,onClick:N,children:`Cancel`}),(0,K.jsxs)(b,{size:`sm`,variant:`outline`,className:`text-xs h-7 cursor-pointer`,disabled:!F,onClick:()=>P(!0),children:[(0,K.jsx)(p,{className:`size-3 mr-1`}),` Copy`]}),(0,K.jsx)(b,{size:`sm`,className:`text-xs h-7 cursor-pointer`,disabled:!F,onClick:()=>P(!1),children:D?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(m,{className:`size-3 animate-spin mr-1`}),` Exporting...`]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(u,{className:`size-3 mr-1`}),` Download`]})})]})]})})}function Me({open:e,onOpenChange:t,onSuccess:n}){let[r,a]=(0,G.useState)(``),[o,s]=(0,G.useState)(``),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(null);function f(){t(!1),a(``),s(``),d(null)}async function p(){if(r.trim()){l(!0),d(null);try{let e=await ae({data:r.trim(),password:o.trim()||`ppm-hienlh`});f(),n(`Imported ${e.imported} account(s)`)}catch(e){d(e.message||`Import failed`)}l(!1)}}return(0,K.jsx)(E,{open:e,onOpenChange:e=>{e||f()},children:(0,K.jsxs)(C,{className:`sm:max-w-md`,children:[(0,K.jsxs)(x,{children:[(0,K.jsxs)(w,{className:`text-sm flex items-center gap-1.5`,children:[(0,K.jsx)(i,{className:`size-3.5`}),` Import Accounts`]}),(0,K.jsx)(T,{className:`text-xs`,children:`Paste backup data and enter the export password. Imported accounts are temporary (~1h).`})]}),(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(A,{className:`text-xs`,children:`Backup data`}),(0,K.jsx)(`textarea`,{value:r,onChange:e=>a(e.target.value),placeholder:`Paste backup JSON here...`,rows:4,className:`w-full text-xs p-2 rounded border border-border bg-background font-mono resize-none focus:outline-none focus:ring-1 focus:ring-primary`})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(A,{className:`text-xs`,children:[`Password `,(0,K.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(optional)`})]}),(0,K.jsx)(O,{type:`password`,placeholder:`Leave empty for default`,value:o,onChange:e=>s(e.target.value),className:`text-xs h-8`,autoComplete:`current-password`})]})]}),u&&(0,K.jsx)(`div`,{className:`text-[11px] p-2 rounded bg-error/10 text-error`,children:u}),(0,K.jsxs)(S,{children:[(0,K.jsx)(b,{size:`sm`,variant:`outline`,className:`text-xs h-7 cursor-pointer`,onClick:f,children:`Cancel`}),(0,K.jsx)(b,{size:`sm`,className:`text-xs h-7 cursor-pointer`,disabled:!r.trim()||c,onClick:p,children:c?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(m,{className:`size-3 animate-spin mr-1`}),` Importing...`]}):`Import`})]})]})})}var X=typeof window<`u`?window.matchMedia(`(min-width: 768px)`):null;function Ne(e){return X?.addEventListener(`change`,e),()=>X?.removeEventListener(`change`,e)}function Pe(){return X?.matches??!0}function Z(){let[e,t]=(0,G.useState)(null),[n,r]=(0,G.useState)(!0);return(0,G.useEffect)(()=>{r(!0),oe().then(t).finally(()=>r(!1))},[]),n?(0,K.jsx)(`p`,{className:`text-xs text-text-subtle py-4 text-center`,children:`Loading...`}):e?(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-xs font-medium text-text-primary`,children:`Rotation Strategy`}),(0,K.jsxs)(ee,{value:e.strategy,onValueChange:async e=>{t(await R({strategy:e}))},children:[(0,K.jsx)(te,{className:`w-full h-9 text-xs`,children:(0,K.jsx)(M,{})}),(0,K.jsxs)(N,{children:[(0,K.jsx)(I,{value:`round-robin`,children:`Round-robin`}),(0,K.jsx)(I,{value:`fill-first`,children:`Fill-first`}),(0,K.jsx)(I,{value:`lowest-usage`,children:`Lowest usage`})]})]}),(0,K.jsxs)(`p`,{className:`text-[10px] text-text-subtle`,children:[e.strategy===`round-robin`&&`Cycles through accounts evenly`,e.strategy===`fill-first`&&`Uses one account until its limit, then moves on`,e.strategy===`lowest-usage`&&`Picks the account with the lowest current usage`]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-xs font-medium text-text-primary`,children:`Max Retry`}),(0,K.jsx)(`input`,{type:`number`,min:0,value:e.maxRetry,className:`w-full h-9 text-xs border rounded-md px-3 bg-background`,onChange:async e=>{let n=parseInt(e.target.value,10);!isNaN(n)&&n>=0&&t(await R({maxRetry:n}))}}),(0,K.jsx)(`p`,{className:`text-[10px] text-text-subtle`,children:`How many accounts to try on failure. 0 = try all available accounts.`})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5 border-t border-border pt-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`label`,{className:`text-xs font-medium text-text-primary`,children:`Cooldown parking`}),(0,K.jsx)(P,{checked:e.cooldownEnabled,onCheckedChange:async e=>{t(await R({cooldownEnabled:e}))}})]}),(0,K.jsx)(`p`,{className:`text-[10px] text-text-subtle`,children:`Park a failing account (rate limit / usage limit / auth error) until it recovers. Off: accounts stay selectable — rotation still skips accounts already ≥95% on the 5-hour limit.`})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between text-xs border-t border-border pt-3`,children:[(0,K.jsx)(`span`,{className:`text-text-subtle`,children:`Active accounts`}),(0,K.jsx)(`span`,{className:`font-medium text-text-primary`,children:e.activeCount})]})]}):(0,K.jsx)(`p`,{className:`text-xs text-text-subtle py-4 text-center`,children:`Failed to load settings`})}function Fe({open:e,onOpenChange:t}){let n=(0,G.useSyncExternalStore)(Ne,Pe);return e?n?(0,K.jsx)(E,{open:e,onOpenChange:t,children:(0,K.jsxs)(C,{className:`sm:max-w-sm`,children:[(0,K.jsx)(x,{children:(0,K.jsxs)(w,{className:`text-sm flex items-center gap-2`,children:[(0,K.jsx)(a,{className:`size-4`}),` Rotation & Retry`]})}),(0,K.jsx)(Z,{})]})}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 transition-opacity duration-200 opacity-100`,onClick:()=>t(!1),style:{backgroundColor:`rgba(0,0,0,0.5)`}}),(0,K.jsxs)(`div`,{className:g(`fixed bottom-0 left-0 right-0 z-50 bg-background rounded-t-2xl border-t border-border shadow-2xl`,`transition-transform duration-300 ease-out max-h-[85vh] overflow-y-auto`,`translate-y-0`),children:[(0,K.jsx)(`div`,{className:`flex justify-center pt-3 pb-1`,children:(0,K.jsx)(`div`,{className:`w-10 h-1 rounded-full bg-border`})}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-b border-border`,children:[(0,K.jsxs)(`span`,{className:`text-sm font-semibold flex items-center gap-2`,children:[(0,K.jsx)(a,{className:`size-4`}),` Rotation & Retry`]}),(0,K.jsx)(`button`,{onClick:()=>t(!1),className:`flex items-center justify-center size-7 rounded-md hover:bg-surface-elevated transition-colors`,children:(0,K.jsx)(d,{className:`size-4`})})]}),(0,K.jsx)(`div`,{className:`px-4 py-4 pb-8`,children:(0,K.jsx)(Z,{})})]})]}):null}var Ie=y(`inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2`,{variants:{variant:{default:`border-transparent bg-primary text-primary-foreground shadow`,secondary:`border-transparent bg-secondary text-secondary-foreground`,destructive:`border-transparent bg-destructive text-destructive-foreground shadow`,outline:`text-foreground`}},defaultVariants:{variant:`default`}});function Q({className:e,variant:t,...n}){return(0,K.jsx)(`div`,{className:g(Ie({variant:t}),e),...n})}function Le(e){let t=Math.floor(Date.now()/1e3);return e>t?`${Math.floor((e-t)/60)}m`:`exp`}function Re({accounts:e}){let[t,n]=(0,G.useState)([]),[r,i]=(0,G.useState)(!1),[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(new Map),l=e.filter(e=>e.hasRefreshToken);async function u(){if(l.length!==0){i(!0);try{let e=await le(l.map(e=>e.id),a);n(t=>[...t,{round:t.length+1,time:new Date().toLocaleTimeString(),includeRefresh:a,items:e}])}catch{}i(!1)}}async function d(e,t){c(t=>new Map(t).set(e,{loading:!0}));try{let n=await ue(t);c(t=>new Map(t).set(e,{loading:!1,...n}))}catch(t){c(n=>new Map(n).set(e,{loading:!1,status:`error`,error:t.message}))}}function f(e,t){return[{key:`r${e.round}-pre-${t.id}`,label:`Pre-export`,token:t.preExportTokenFull,preview:t.preExportToken,expires:t.preExportExpires},{key:`r${e.round}-exp-${t.id}`,label:`Exported`,token:t.exportedTokenFull,preview:t.exportedToken,expires:t.exportedExpires},{key:`r${e.round}-post-${t.id}`,label:`Post-export`,token:t.postExportTokenFull,preview:t.postExportToken,expires:t.postExportExpires}]}function p(){for(let e of t)for(let t of e.items)for(let n of f(e,t))n.token&&d(n.key,n.token)}return(0,K.jsxs)(`section`,{className:`border-t pt-4 space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium`,children:`Simulate export`}),t.length>0&&(0,K.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[t.length,` round(s)`]})]}),(0,K.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Every run appends a round. Earlier rounds are kept so tokens can be compared across runs.`}),l.length===0?(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No OAuth account with a refresh token to export.`}):(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(P,{id:`sim-include-refresh`,checked:a,onCheckedChange:o,className:`cursor-pointer`}),(0,K.jsx)(A,{htmlFor:`sim-include-refresh`,className:`text-[11px] cursor-pointer`,children:`Include refresh tokens`})]}),(0,K.jsx)(b,{size:`sm`,className:`h-7 text-xs cursor-pointer`,disabled:r,onClick:()=>void u(),children:r?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(m,{className:`size-3 animate-spin mr-1`}),` Exporting...`]}):`Run export #${t.length+1}`})]}),t.length>0&&(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(b,{size:`sm`,variant:`outline`,className:`w-full h-7 text-[11px] cursor-pointer`,onClick:p,children:[`Test all tokens (`,t.reduce((e,t)=>e+t.items.length*3,0),`)`]}),t.map(e=>(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`p`,{className:`text-xs font-medium text-primary`,children:[`Round #`,e.round]}),(0,K.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:e.time}),(0,K.jsx)(Q,{variant:e.includeRefresh?`destructive`:`secondary`,className:`text-[9px] px-1 py-0`,children:e.includeRefresh?`with refresh`:`access only`})]}),e.items.map(t=>(0,K.jsxs)(`div`,{className:`p-2 rounded-lg border bg-card space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-[11px] font-medium`,children:t.label??t.email??t.id.slice(0,8)}),t.tokenChanged&&(0,K.jsx)(Q,{variant:`secondary`,className:`text-[9px] px-1 py-0`,children:`DB token changed`})]}),f(e,t).map(e=>{let t=s.get(e.key);return(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px]`,children:[(0,K.jsx)(`span`,{className:`w-20 shrink-0 text-muted-foreground text-[10px]`,children:e.label}),(0,K.jsx)(`code`,{className:`flex-1 truncate font-mono text-[10px] bg-muted px-1 rounded`,children:e.preview??`N/A`}),e.expires&&(0,K.jsx)(`span`,{className:`text-[10px] text-muted-foreground shrink-0`,children:Le(e.expires)}),e.token?(0,K.jsx)(b,{size:`sm`,variant:`outline`,className:`h-6 text-[10px] px-1.5 cursor-pointer shrink-0`,disabled:t?.loading,onClick:()=>void d(e.key,e.token),children:t?.loading?(0,K.jsx)(m,{className:`size-3 animate-spin`}):`Test`}):(0,K.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`-`}),t&&!t.loading&&(0,K.jsx)(`span`,{className:`text-[10px] font-medium shrink-0 ${t.status?.startsWith(`valid`)?`text-success`:`text-error`}`,children:t.status})]},e.key)})]},`r${e.round}-${t.id}`))]},e.round))]})]})}function ze(e){let t=Math.floor(Date.now()/1e3),n=Math.floor(Math.abs(e-t)/60);return e>t?`${n}m left`:`expired ${n}m ago`}function Be({open:e,onOpenChange:t,accounts:n}){let[i,a]=(0,G.useState)(new Map),[o,s]=(0,G.useState)(!1);async function c(e){a(t=>new Map(t).set(e,{loading:!0}));try{let t=await ne(e,o);a(n=>new Map(n).set(e,{loading:!1,result:t}))}catch(t){a(n=>new Map(n).set(e,{loading:!1,error:t.message}))}}function l(){for(let e of n.filter(e=>e.expiresAt!==null))c(e.id)}return(0,K.jsx)(E,{open:e,onOpenChange:t,children:(0,K.jsxs)(C,{className:`sm:max-w-xl max-h-[85vh] flex flex-col`,children:[(0,K.jsxs)(x,{children:[(0,K.jsxs)(w,{className:`text-sm flex items-center gap-1.5`,children:[(0,K.jsx)(r,{className:`size-4`}),` Token Test`]}),(0,K.jsx)(T,{className:`text-xs`,children:`Probe stored tokens for validity. Nothing is modified.`})]}),(0,K.jsxs)(`div`,{className:`space-y-4 overflow-y-auto flex-1 pr-1`,children:[(0,K.jsxs)(`section`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium`,children:`Current tokens`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(P,{id:`token-test-refresh`,checked:o,onCheckedChange:s,className:`cursor-pointer`}),(0,K.jsx)(A,{htmlFor:`token-test-refresh`,className:`text-[11px] cursor-pointer`,children:`Also test refresh`})]}),(0,K.jsx)(b,{size:`sm`,variant:`outline`,className:`h-7 text-xs cursor-pointer`,onClick:l,children:`Test all`})]})]}),n.length===0&&(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No accounts to test.`}),(0,K.jsx)(`div`,{className:`space-y-1.5`,children:n.map(e=>{let t=i.get(e.id),n=t?.result?.accessToken.status;return(0,K.jsxs)(`div`,{className:`p-2 rounded border bg-card space-y-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`span`,{className:`text-xs font-medium truncate block`,children:e.label??e.email??e.id.slice(0,8)}),e.expiresAt&&(0,K.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:ze(e.expiresAt)})]}),(0,K.jsx)(b,{size:`sm`,variant:`outline`,className:`h-7 text-xs cursor-pointer shrink-0`,disabled:t?.loading,onClick:()=>void c(e.id),children:t?.loading?(0,K.jsx)(m,{className:`size-3 animate-spin`}):`Test`})]}),t&&!t.loading&&(0,K.jsxs)(`div`,{className:`text-[11px] pl-2 border-l-2 border-muted`,children:[t.error&&(0,K.jsx)(`p`,{className:`text-error`,children:t.error}),n&&(0,K.jsxs)(`span`,{className:n.startsWith(`valid`)?`text-success`:`text-error`,children:[n,t.result?.accessToken.code?` (${t.result.accessToken.code})`:``]})]})]},e.id)})})]}),(0,K.jsx)(Re,{accounts:n})]}),(0,K.jsx)(S,{children:(0,K.jsx)(b,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:()=>t(!1),children:`Close`})})]})})}function Ve(){let{usages:e,accounts:t,activeAccountId:n,initialLoading:i,refreshing:o,flashIds:s,reload:d}=ge(),[p,h]=(0,G.useState)(null),[g,_]=(0,G.useState)(null),[v,y]=(0,G.useState)(null),[x,S]=(0,G.useState)(null),[C,w]=(0,G.useState)(null),[T,E]=(0,G.useState)(null),[D,O]=(0,G.useState)(void 0);function k(e){d(),e&&h(e)}async function A(e,t){_(e);try{await ie(e,{status:t===`disabled`?`active`:`disabled`})}catch(e){h(e.message)}_(null),d()}async function j(){if(v){try{await ce(v.id),h(`Account "${v.display}" removed.`),d()}catch(e){h(`Failed to remove: ${e.message}`)}y(null)}}let M=new Map(t.map(e=>[e.id,e])),N=e[0]?.usage.lastFetchedAt;return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(B,{description:`Connect multiple Claude accounts. PPM rotates between them automatically to avoid rate limits.`,onRefresh:()=>void d(),refreshing:o,disabled:i,actions:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(b,{size:`sm`,className:`cursor-pointer gap-1.5`,onClick:()=>{O(void 0),E(`add`)},children:[(0,K.jsx)(l,{className:`size-4`}),` Add account`]}),(0,K.jsxs)(b,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>{w(null),E(`export`)},children:[(0,K.jsx)(u,{className:`size-4`}),` Export`]}),(0,K.jsxs)(b,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>E(`import`),children:[(0,K.jsx)(c,{className:`size-4`}),` Import`]}),(0,K.jsxs)(b,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>E(`rotation`),children:[(0,K.jsx)(a,{className:`size-4`}),` Rotation`]}),(0,K.jsxs)(b,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>E(`token-test`),children:[(0,K.jsx)(r,{className:`size-4`}),` Token test`]})]})}),(0,K.jsx)(z,{message:p,onDismiss:()=>h(null)}),(0,K.jsxs)(`section`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium`,children:`Accounts`}),N&&(0,K.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`usage `,pe(new Date(N).getTime())]})]}),i?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-xs text-muted-foreground`,children:[(0,K.jsx)(m,{className:`size-4 animate-spin`}),` Loading accounts...`]}):e.length===0?(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-8 text-center`,children:[(0,K.jsx)(f,{className:`size-5 text-muted-foreground`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No accounts connected yet.`}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Add one to start using PPM.`})]}):(0,K.jsx)(V,{children:e.map(e=>(0,K.jsx)(Se,{layout:`strip`,entry:e,isActive:e.accountId===n,accountInfo:M.get(e.accountId),onToggle:A,toggling:g===e.accountId,onDelete:(e,t)=>y({id:e,display:t}),onExport:e=>{w(e),E(`export`)},onViewProfile:(e,t)=>S({profile:e,accountId:t}),onReauth:()=>{O({id:e.accountId,label:e.accountLabel??e.accountId.slice(0,8)}),E(`add`)},flash:s.has(e.accountId)},e.accountId))})]}),x&&(0,K.jsx)(Oe,{profile:x.profile,accountId:x.accountId,onClose:()=>S(null)}),v&&(0,K.jsx)(ke,{display:v.display,onConfirm:()=>void j(),onCancel:()=>y(null)}),(0,K.jsx)(me,{open:T===`add`,onOpenChange:e=>{E(e?`add`:null),e||O(void 0)},onSuccess:k,signInAgainFor:D}),(0,K.jsx)(je,{open:T===`export`,onOpenChange:e=>{E(e?`export`:null),e||w(null)},accounts:t,preselectId:C,onMessage:h}),(0,K.jsx)(Me,{open:T===`import`,onOpenChange:e=>E(e?`import`:null),onSuccess:k}),(0,K.jsx)(Fe,{open:T===`rotation`,onOpenChange:e=>E(e?`rotation`:null)}),(0,K.jsx)(Be,{open:T===`token-test`,onOpenChange:e=>E(e?`token-test`:null),accounts:t})]})}function He({mode:e,onOpenChange:t,password:n,onPasswordChange:r,busy:a,onExport:o,onImport:s,error:l}){let d=(0,G.useRef)(null),f=e===`export`;return(0,K.jsx)(E,{open:e!==null,onOpenChange:t,children:(0,K.jsxs)(C,{className:`sm:max-w-md`,children:[(0,K.jsxs)(x,{children:[(0,K.jsxs)(w,{className:`text-sm flex items-center gap-1.5`,children:[(0,K.jsx)(i,{className:`size-4`}),` `,f?`Export Codex Accounts`:`Import Codex Accounts`]}),(0,K.jsx)(T,{className:`text-xs leading-relaxed`,children:f?`Writes a password-encrypted file containing each account's login.`:`Reads a backup file. The password must be the one it was exported with.`})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(A,{htmlFor:`codex-backup-password`,className:`text-xs`,children:`Password`}),(0,K.jsx)(O,{id:`codex-backup-password`,type:`password`,placeholder:f?`Choose a password`:`Password used for the export`,value:n,onChange:e=>r(e.target.value),className:`text-xs`,autoComplete:f?`new-password`:`current-password`}),(0,K.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`A backup holds full logins — keep the file and its password together.`})]}),l&&(0,K.jsx)(`div`,{className:`text-[11px] p-2 rounded bg-error/10 text-error`,children:l}),(0,K.jsx)(`input`,{ref:d,type:`file`,accept:`application/json,.json`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&s(t)}}),(0,K.jsxs)(S,{children:[(0,K.jsx)(b,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:()=>t(!1),children:`Cancel`}),(0,K.jsxs)(b,{size:`sm`,className:`text-xs cursor-pointer gap-1.5`,disabled:!n.trim()||a,onClick:()=>f?o():d.current?.click(),children:[a?(0,K.jsx)(m,{className:`size-3.5 animate-spin`}):f?(0,K.jsx)(u,{className:`size-3.5`}):(0,K.jsx)(c,{className:`size-3.5`}),f?`Download backup`:`Choose file`]})]})]})})}var Ue=[{value:`round-robin`,label:`Round-robin`,hint:`Take the next account each time.`},{value:`fill-first`,label:`Fill-first`,hint:`Stay on one account until it runs out.`},{value:`lowest-usage`,label:`Lowest usage`,hint:`Pick whichever has the most left.`}];function We({open:e,onOpenChange:t,strategy:n,onChange:r}){return(0,K.jsx)(E,{open:e,onOpenChange:t,children:(0,K.jsxs)(C,{className:`sm:max-w-md`,children:[(0,K.jsxs)(x,{children:[(0,K.jsx)(w,{className:`text-sm`,children:`Codex Rotation`}),(0,K.jsx)(T,{className:`text-xs leading-relaxed`,children:`How a new chat chooses among your Codex accounts.`})]}),(0,K.jsx)(`div`,{className:`space-y-2`,children:Ue.map(e=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>r(e.value),"aria-current":n===e.value?`true`:void 0,className:g(`w-full text-left rounded-md border px-3 py-2.5 min-h-11 cursor-pointer transition-colors`,n===e.value?`border-primary bg-primary/10`:`border-border hover:bg-accent/50 active:bg-accent`),children:[(0,K.jsx)(`p`,{className:`text-sm font-medium`,children:e.label}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.hint})]},e.value))}),(0,K.jsx)(S,{children:(0,K.jsx)(b,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:()=>t(!1),children:`Done`})})]})})}function $(e){return e==null?null:Math.round(e*100)}function Ge({usage:e}){let t=e.session==null&&e.weekly==null;return(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(t||e.session!=null)&&(0,K.jsx)(W,{label:`5-Hour Session`,pct:$(e.fiveHour),reset:U(e.session),resetsAt:e.session?.resetsAt}),(t||e.weekly!=null)&&(0,K.jsx)(W,{label:`Weekly`,pct:$(e.sevenDay),reset:U(e.weekly),resetsAt:e.weekly?.resetsAt})]})}function Ke(){let[e,t]=(0,G.useState)(null),n=fe(()=>t(null)),[r,i]=(0,G.useState)(null);return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(B,{description:(0,K.jsxs)(K.Fragment,{children:[`Each Codex account keeps its own login (`,(0,K.jsx)(`code`,{children:`CODEX_HOME`}),`). One is picked per chat by the rotation setting.`]}),onRefresh:()=>void n.load(),refreshing:n.loading,actions:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(b,{size:`sm`,className:`cursor-pointer gap-1.5`,onClick:()=>t(`add`),children:[(0,K.jsx)(l,{className:`size-4`}),` Add account`]}),(0,K.jsxs)(b,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>t(`export`),children:[(0,K.jsx)(u,{className:`size-4`}),` Export`]}),(0,K.jsxs)(b,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>t(`import`),children:[(0,K.jsx)(c,{className:`size-4`}),` Import`]}),(0,K.jsxs)(b,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>t(`rotation`),children:[(0,K.jsx)(a,{className:`size-4`}),` Rotation`]})]})}),(0,K.jsx)(z,{message:n.msg??n.err,onDismiss:()=>{n.setMsg(null),n.setErr(null)}}),(0,K.jsxs)(`section`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium`,children:`Codex Accounts`}),(0,K.jsx)(`span`,{className:`text-[10px] text-muted-foreground capitalize`,children:n.strategy.replace(`-`,` `)})]}),n.loading&&n.accounts.length===0?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-xs text-muted-foreground`,children:[(0,K.jsx)(m,{className:`size-4 animate-spin`}),` Loading accounts...`]}):n.accounts.length===0?(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-8 text-center`,children:[(0,K.jsx)(f,{className:`size-5 text-muted-foreground`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No Codex accounts yet.`}),(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Chats use your default `,(0,K.jsx)(`code`,{children:`~/.codex`}),` login until you add one.`]})]}):(0,K.jsx)(V,{children:n.accounts.map(e=>{let t=n.usages[e.id]??{};return(0,K.jsxs)(_e,{dense:!0,className:`min-w-[300px] shrink-0 snap-start${e.signedOut?` opacity-60`:``}`,"data-testid":`account-card`,"data-account-id":e.id,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium truncate flex-1 min-w-0`,children:e.label}),e.signedOut&&(0,K.jsx)(de,{className:`text-[10px] text-error shrink-0 font-medium`,hint:`Codex rejected this account's login (revoked or expired), so no turn can run on it and it is skipped. The usage shown is the last reading. Click to sign in again — the account keeps its settings and chats.`,onClick:e.type===`chatgpt`?()=>i(e):void 0,children:`Sign in again`}),(0,K.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-text-subtle border border-border rounded px-1 shrink-0`,children:e.type}),H(e.planType)&&(0,K.jsx)(`span`,{className:`text-[10px] text-text-subtle shrink-0`,children:H(e.planType)}),(0,K.jsx)(P,{checked:e.status!==`disabled`,onCheckedChange:()=>void n.toggle(e.id,e.status??`active`),disabled:n.toggling.has(e.id),"aria-label":e.status===`disabled`?`Enable account`:`Disable account`,className:`cursor-pointer shrink-0`}),(0,K.jsxs)(F,{children:[(0,K.jsx)(j,{asChild:!0,children:(0,K.jsx)(`button`,{type:`button`,onClick:()=>void n.remove(e.id),"aria-label":`Remove account`,className:`p-2 rounded cursor-pointer text-text-subtle hover:text-error hover:bg-surface-elevated transition-colors shrink-0`,children:(0,K.jsx)(s,{className:`size-4`})})}),(0,K.jsx)(L,{side:`top`,children:`Remove account`})]})]}),(0,K.jsx)(Ge,{usage:t}),t.resetCredits&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap text-[10px] text-text-subtle`,children:[(0,K.jsx)(he,{credits:t.resetCredits}),(0,K.jsx)(xe,{account:e,usage:t,onDone:e=>{n.setMsg(e),n.load()}})]}),t.session==null&&(()=>{let r=ye(t.weekly);return r?(0,K.jsxs)(`div`,{className:`flex min-h-12 items-center justify-between gap-3 rounded-md border px-2.5 py-1.5 ${e.dailyGuardEnabled&&r.blocked?`border-error/40 bg-error/5`:`border-border/50 bg-surface/40`}`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 space-y-0.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-medium ${e.dailyGuardEnabled&&r.blocked?`text-error`:`text-text-secondary`}`,children:[(0,K.jsx)(`span`,{children:`Daily guard`}),(0,K.jsxs)(F,{children:[(0,K.jsx)(j,{asChild:!0,children:(0,K.jsx)(`button`,{type:`button`,"aria-label":`About Daily guard`,className:`text-text-subtle hover:text-text-primary cursor-help`,children:(0,K.jsx)(o,{className:`size-3.5`})})}),(0,K.jsx)(L,{side:`top`,className:`max-w-64 text-xs leading-relaxed`,children:`Spreads the weekly quota across five weekdays, adding 20% per weekday. Weekend slots keep the previous cap; unused allowance carries forward. Daily slots start at the reset time and use UTC weekdays. Turn it off any time to use the remaining quota freely.`})]})]}),(0,K.jsx)(`p`,{className:`text-[10px] tabular-nums ${e.dailyGuardEnabled&&r.blocked?`text-error`:`text-text-subtle`}`,children:e.dailyGuardEnabled&&r.blocked?`${Math.round(r.used*100)}% used / ${Math.round(r.cap*100)}% daily cap. New turns paused.`:`Weekday ${r.day}/5, ${Math.round(r.cap*100)}% daily cap`})]}),(0,K.jsxs)(`span`,{className:`hidden`,title:`Weekday ${r.day}/5: hold weekly usage at or below ${Math.round(r.cap*100)}% to last until reset.`,children:[`Daily guard `,e.dailyGuardEnabled?`· Weekday ${r.day}/5 cap ${Math.round(r.cap*100)}%`:``]}),(0,K.jsx)(P,{checked:!!e.dailyGuardEnabled,onCheckedChange:()=>void n.toggleDailyGuard(e.id,!!e.dailyGuardEnabled),disabled:n.toggling.has(e.id),"aria-label":e.dailyGuardEnabled?`Disable Daily guard`:`Enable Daily guard`,className:`cursor-pointer shrink-0`})]}):null})()]},e.id)})})]}),(0,K.jsx)(be,{open:e===`add`,onOpenChange:e=>{e||n.cancelLogin(),t(e?`add`:null)},label:n.label,onLabelChange:n.setLabel,apiKey:n.apiKey,onApiKeyChange:n.setApiKey,adding:n.adding,onAddApiKey:()=>void n.addApiKey(),deviceWaiting:n.deviceWaiting,onStartDevice:()=>void n.startDevice(),device:n.device,browser:n.browser,onStartBrowser:()=>void n.startBrowser(),loginStarting:n.loginStarting,callbackUrl:n.callbackUrl,onCallbackUrlChange:n.setCallbackUrl,submittingCallback:n.submittingCallback,onSubmitCallback:()=>void n.submitCallback(),error:n.err}),(0,K.jsx)(He,{mode:e===`export`?`export`:e===`import`?`import`:null,onOpenChange:e=>{e||t(null)},password:n.backupPassword,onPasswordChange:n.setBackupPassword,busy:n.exporting||n.importing,onExport:()=>void n.doExport(),onImport:e=>void n.doImport(e),error:n.err}),r&&(0,K.jsx)(ve,{account:r,onClose:()=>i(null),onDone:()=>void n.load()}),(0,K.jsx)(We,{open:e===`rotation`,onOpenChange:e=>t(e?`rotation`:null),strategy:n.strategy,onChange:e=>void n.changeStrategy(e)})]})}var qe=[{id:`claude`,label:`Claude`},{id:`codex`,label:`Codex`}];function Je(){let[e,t]=(0,G.useState)(null),[n,r]=(0,G.useState)(`claude`);(0,G.useEffect)(()=>{let e=!1;return re().then(n=>{e||t(new Set(Object.keys(n.providers??{})))}).catch(()=>{e||t(new Set([`claude`]))}),()=>{e=!0}},[]);let i=qe.filter(t=>t.id===`claude`||e?.has(t.id)),a=i.length>1;return(0,K.jsxs)(`div`,{className:`space-y-4`,"data-testid":`accounts-pane`,"data-provider":n,children:[a&&(0,K.jsx)(`div`,{className:`flex gap-1 border-b border-border/50`,children:i.map(e=>(0,K.jsxs)(`button`,{onClick:()=>r(e.id),"data-testid":`accounts-tab-${e.id}`,"aria-current":n===e.id?`page`:void 0,className:`flex items-center gap-1.5 px-3 py-2 text-xs rounded-t transition-colors cursor-pointer ${n===e.id?`text-primary border-b-2 border-primary font-medium`:`text-text-subtle hover:text-text-secondary`}`,children:[(0,K.jsx)(k,{providerId:e.id}),e.label]},e.id))}),e===null&&!a&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,K.jsx)(m,{className:`size-3 animate-spin`}),` Checking configured providers...`]}),n===`claude`?(0,K.jsx)(Ve,{}):(0,K.jsx)(Ke,{})]})}export{Je as AccountsSettingsSection};
|
|
Binary file
|
|
Binary file
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/agent-session-window-content-
|
|
2
|
-
import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{D as t,E as n}from"./vendor-markdown-C-P1aR4p.js";import"./vendor-ui-BTSIXzhZ.js";import{li as r}from"./icons-BwyIKaTT.js";import{t as i}from"./preload-helper-CM8YhcCa.js";import"./portal-container-context-NBi-KGK0.js";import{t as a}from"./mobile-bottom-sheet-DArbIyrD.js";import"./use-visual-viewport-MmugpRg-.js";import{t as o}from"./agent-session-sheet-store-BAfLnsLX.js";var s=e(t(),1),c=n(),l=(0,s.lazy)(()=>i(()=>import(`./agent-session-window-content-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/agent-session-window-content-DMhy16BM.js","assets/rolldown-runtime-C5c2KzVm.js","assets/index-BtAn_krv.js","assets/preload-helper-CM8YhcCa.js","assets/vendor-ui-BTSIXzhZ.js","assets/vendor-markdown-C-P1aR4p.js","assets/button-C9ZXWb3b.js","assets/utils-Bslrbb-G.js","assets/createLucideIcon-D9_fdOKS.js","assets/file-diff-CcDhJkXB.js","assets/git-commit-horizontal-BPdj2L1i.js","assets/api-client-xQDlhUTu.js","assets/react-BZ0kba1-.js","assets/open-db-tabs-CtWIWHOa.js","assets/window-store-DqX_qmkQ.js","assets/panel-store-BJhazigC.js","assets/session-list-sync-triggers-DtJI5KF0.js","assets/project-store-BLGl9IAO.js","assets/project-framework-store-DwLxaRan.js","assets/explorer-model-BtJN4MZ9.js","assets/db-sidebar-reveal-_qw0CliT.js","assets/settings-store-B4mLp19V.js","assets/use-is-mobile-VRV9eZy1.js","assets/db-types-CNhENouW.js","assets/tab-store-D5I52eLN.js","assets/use-db-driver-installed-anzWkGi5.js","assets/impexp-state-BWKOuRGj.js","assets/file-store-BQ41vIs5.js","assets/sql-identifiers-DDISwQor.js","assets/db-explorer-store-BmpvDHz6.js","assets/onboarding-quick-orientation-CTHtIRib.js","assets/dialog-Dn_2tuYa.js","assets/portal-container-context-NBi-KGK0.js","assets/icons-BwyIKaTT.js","assets/format-file-meta-DdYtk07C.js","assets/fs-api-CFtQzsIJ.js","assets/open-settings-EXR4zoZG.js","assets/settings-categories-Ajj4ui27.js","assets/adaptive-context-menu-C4jNSORA.js","assets/context-menu-BCuZYfWC.js","assets/mobile-bottom-sheet-DArbIyrD.js","assets/use-visual-viewport-MmugpRg-.js","assets/dropdown-menu-BQidk_OJ.js","assets/input-C3oVNCMq.js","assets/scroll-area-DOlQJGZp.js","assets/start-ellipsis-CU8GkxaV.js","assets/chat-preparation-cache-190LLyy7.js","assets/clipboard-D-VCry-F.js","assets/file-icons-JInFtBVl.js","assets/format-date-CSHaU2wN.js","assets/git-repo-store-CKB5fdNP.js","assets/patch-tab-metadata-C92YkrRX.js","assets/ws-auth-CbF6GqxP.js","assets/apply-theme-ORrEdHKT.js","assets/resolve-theme-BqoL27BW.js","assets/index-BACBJm4i.css","assets/libesm-B6LsX5wH.js","assets/tool-cards-Dh8Ekn2W.js","assets/db-ai-tools-CVbbW_MZ.js","assets/split-sql-statements-DcAeXbk_.js","assets/agent-session-sheet-store-BAfLnsLX.js","assets/image-preview-geometry-CCq8rio7.js","assets/use-blob-url-Clm7wbB_.js","assets/html-preview-loads-CMWBC-iv.js","assets/image-gallery-BuxSgBug.js","assets/design-canvas-check-BIHc2d_k.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{D as t,E as n}from"./vendor-markdown-C-P1aR4p.js";import"./vendor-ui-BTSIXzhZ.js";import{li as r}from"./icons-BwyIKaTT.js";import{t as i}from"./preload-helper-CM8YhcCa.js";import"./portal-container-context-NBi-KGK0.js";import{t as a}from"./mobile-bottom-sheet-DArbIyrD.js";import"./use-visual-viewport-MmugpRg-.js";import{t as o}from"./agent-session-sheet-store-BAfLnsLX.js";var s=e(t(),1),c=n(),l=(0,s.lazy)(()=>i(()=>import(`./agent-session-window-content-DMhy16BM.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65])));function u(){let e=o(e=>e.payload),t=o(e=>e.close);return e?(0,c.jsxs)(a,{open:!0,onClose:t,zIndex:45,className:`flex h-[var(--sheet-vh)] flex-col p-0`,children:[(0,c.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-3 py-2 shrink-0`,children:[(0,c.jsx)(`span`,{className:`truncate text-sm font-medium text-text-primary`,children:e.title??`Agent session`}),(0,c.jsx)(`button`,{type:`button`,onClick:t,className:`ml-auto flex size-11 items-center justify-center rounded text-text-secondary hover:text-text-primary`,"aria-label":`Close`,children:(0,c.jsx)(r,{className:`size-5`})})]}),(0,c.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:(0,c.jsx)(s.Suspense,{fallback:(0,c.jsx)(`div`,{className:`p-4 text-sm text-text-2`,children:`Loading…`}),children:(0,c.jsx)(l,{id:`sheet-${e.sessionId}`,payload:e})})})]}):null}export{u as AgentSessionSheet};
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{D as t,E as n}from"./vendor-markdown-C-P1aR4p.js";import"./vendor-ui-BTSIXzhZ.js";import{L as r,P as i,xn as a}from"./icons-BwyIKaTT.js";import"./api-client-xQDlhUTu.js";import{n as o}from"./utils-Bslrbb-G.js";import"./window-store-DqX_qmkQ.js";import"./panel-store-BJhazigC.js";import"./project-store-BLGl9IAO.js";import"./project-framework-store-DwLxaRan.js";import"./session-list-sync-triggers-DtJI5KF0.js";import"./tab-store-D5I52eLN.js";import"./file-store-BQ41vIs5.js";import"./use-is-mobile-VRV9eZy1.js";import"./fs-api-CFtQzsIJ.js";import{F as s,I as c,Xr as l}from"./index-
|
|
1
|
+
import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{D as t,E as n}from"./vendor-markdown-C-P1aR4p.js";import"./vendor-ui-BTSIXzhZ.js";import{L as r,P as i,xn as a}from"./icons-BwyIKaTT.js";import"./api-client-xQDlhUTu.js";import{n as o}from"./utils-Bslrbb-G.js";import"./window-store-DqX_qmkQ.js";import"./panel-store-BJhazigC.js";import"./project-store-BLGl9IAO.js";import"./project-framework-store-DwLxaRan.js";import"./session-list-sync-triggers-DtJI5KF0.js";import"./tab-store-D5I52eLN.js";import"./file-store-BQ41vIs5.js";import"./use-is-mobile-VRV9eZy1.js";import"./fs-api-CFtQzsIJ.js";import{F as s,I as c,Xr as l}from"./index-BtAn_krv.js";import"./agent-session-sheet-store-BAfLnsLX.js";import"./libesm-B6LsX5wH.js";import{f as u,l as d,t as f,u as p}from"./tool-cards-Dh8Ekn2W.js";import"./use-blob-url-Clm7wbB_.js";import"./design-canvas-check-BIHc2d_k.js";import"./db-ai-tools-CVbbW_MZ.js";var m=e(t(),1),h=2e3;function g(e,t){let n=t.reset?[]:e.slice();for(let{ev:e,ts:r,k:i,replace:a}of t.events){let t=n.findIndex(e=>e.k===i);if(t!==-1){a&&(n[t]={k:i,ts:r,ev:e});continue}let o=n.length;for(;o>0&&n[o-1].ts>r;)o--;n.splice(o,0,{k:i,ts:r,ev:e})}return n.length>2e3?n.slice(n.length-h):n}function _(){return`ats-${Math.random().toString(36).slice(2,10)}`}function v(e){let{projectName:t,providerId:n,sessionId:r,source:i,fallbackEvents:a}=e,[o,l]=(0,m.useState)([]),[u,d]=(0,m.useState)(!1),[f,p]=(0,m.useState)(!1),[h,v]=(0,m.useState)(!0),[y,b]=(0,m.useState)(null);(0,m.useEffect)(()=>{let e=_(),a=[],o;l([]),d(!1),p(!1),v(!0),b(null);let u=()=>{c(JSON.stringify({type:`agent-transcript:subscribe`,subId:e,projectName:t,providerId:n,sessionId:r,source:i,...o?{cursor:o}:{}}))},f=t=>{let n=t.detail;n.subId===e&&(a=g(a,n),o=n.cursor,l(a),d(n.available),p(n.running),v(!1),b(null))},m=t=>{let n=t.detail;n.subId===e&&(d(!1),v(!1),b(n.code))};window.addEventListener(`agent-transcript:events`,f),window.addEventListener(`agent-transcript:error`,m);let h=s(u);return u(),()=>{window.removeEventListener(`agent-transcript:events`,f),window.removeEventListener(`agent-transcript:error`,m),h(),c(JSON.stringify({type:`agent-transcript:unsubscribe`,subId:e}))}},[JSON.stringify([t,n,r,i])]);let x=(0,m.useMemo)(()=>o.map(e=>e.ev),[o]);return{events:u?x:a??[],available:u,running:f,loading:h,error:y}}var y=n();function b(e){return e.filter(e=>e.type===`tool_use`).length}function x({status:e}){return e===`loading`?null:e===`running`?(0,y.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] text-primary shrink-0`,children:[(0,y.jsx)(a,{className:`size-2.5 animate-spin`}),` running`]}):e===`failed`?(0,y.jsx)(`span`,{className:`text-[10px] text-error shrink-0`,children:`failed`}):(0,y.jsx)(`span`,{className:`text-[10px] text-success shrink-0`,children:`done`})}function S({payload:e}){let t=e??{},n=t.sessionId?d(t.sessionId,t.source):``,s=p(e=>n?e.entries[n]:void 0),{events:c,available:h,running:g,loading:_,error:S}=v({projectName:t.projectName,providerId:t.providerId,sessionId:t.sessionId,source:t.source,fallbackEvents:s}),[C,w]=(0,m.useState)(!1),T=l(),E=(0,m.useMemo)(()=>b(c),[c]),D=c[c.length-1],O=!g&&!!D&&D.type===`tool_result`&&!!D.isError,k=_?`loading`:g?`running`:O?`failed`:`done`;return(0,y.jsxs)(`div`,{className:`flex flex-col h-full min-h-0 bg-surface @container`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 border-b border-border/30 shrink-0`,children:[(0,y.jsx)(`span`,{className:`truncate text-xs font-medium`,children:t.title??`Agent session`}),c.length>0&&(0,y.jsx)(`span`,{className:`text-[10px] text-text-subtle shrink-0`,children:u(E)}),(0,y.jsx)(x,{status:k}),!h&&!_&&(0,y.jsx)(`span`,{className:`ml-auto text-[10px] text-text-subtle shrink-0`,title:`No live transcript for this session — showing steps already held in memory`,children:`offline`})]}),!!t.prompt&&(0,y.jsxs)(`div`,{className:`border-b border-border/30 shrink-0`,children:[(0,y.jsxs)(`button`,{type:`button`,onClick:()=>w(e=>!e),className:o(`flex w-full items-center gap-1.5 px-3 py-1.5 text-[11px] text-text-subtle hover:text-foreground`,T?`min-h-[44px]`:`min-h-[28px]`),children:[C?(0,y.jsx)(i,{className:`size-3`}):(0,y.jsx)(r,{className:`size-3`}),`Prompt`]}),C&&(0,y.jsx)(`div`,{className:`px-3 pb-2 text-[11px] text-text-secondary whitespace-pre-wrap select-text`,children:t.prompt})]}),_&&c.length===0?(0,y.jsxs)(`div`,{className:`flex-1 flex items-center justify-center gap-2 text-xs text-text-subtle`,children:[(0,y.jsx)(a,{className:`size-3 animate-spin`}),`Loading session…`]}):c.length===0?(0,y.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-xs text-text-subtle px-4 text-center`,children:S?`Could not load this session`:`No recorded steps`}):(0,y.jsx)(f,{events:c,projectName:t.projectName,variant:`window`,className:`flex-1 min-h-0 overflow-y-auto px-3 py-2 space-y-1`})]})}export{S as default};
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{D as t,E as n}from"./vendor-markdown-C-P1aR4p.js";import"./vendor-ui-BTSIXzhZ.js";import{Cn as r,Yr as i,r as a,vr as o,xn as s}from"./icons-BwyIKaTT.js";import{k as c}from"./api-client-xQDlhUTu.js";import"./settings-store-B4mLp19V.js";import{n as l}from"./utils-Bslrbb-G.js";import{Bn as u,In as d,J as f,Ln as p,Rn as m,Y as h,zn as g}from"./index-
|
|
1
|
+
import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{D as t,E as n}from"./vendor-markdown-C-P1aR4p.js";import"./vendor-ui-BTSIXzhZ.js";import{Cn as r,Yr as i,r as a,vr as o,xn as s}from"./icons-BwyIKaTT.js";import{k as c}from"./api-client-xQDlhUTu.js";import"./settings-store-B4mLp19V.js";import{n as l}from"./utils-Bslrbb-G.js";import{Bn as u,In as d,J as f,Ln as p,Rn as m,Y as h,zn as g}from"./index-BtAn_krv.js";import{t as _}from"./use-monaco-theme-DU0EpDHH.js";var v=e(t(),1),y=n();function b({metadata:e}){let t=e?.filePath,n=e?.name,l=e?.resourceType??`skill`,b=e?.scope??`user`,S=e?.readOnly===!0,C=e?.shadowed===!0,w=e?.shadowedBy,T=e?.project??``,[E,D]=(0,v.useState)(``),[O,k]=(0,v.useState)(``),[A,j]=(0,v.useState)(!0),[M,N]=(0,v.useState)(null),[P,F]=(0,v.useState)(!1),I=_(),L=(0,v.useRef)(``),R=E!==O;(0,v.useEffect)(()=>{let e=!1;return j(!0),N(null),g(t,T).then(t=>{e||(D(t.content),k(t.content),L.current=t.content)}).catch(t=>{e||N(t.message)}).finally(()=>{e||j(!1)}),()=>{e=!0}},[t,T]);let z=(0,v.useCallback)(async()=>{if(S||P)return;let e=L.current;if(e!==O){F(!0);try{await u(t,e,T),k(e),D(e),c.success(`Saved`),m.getState().reload()}catch(e){c.error(e.message)}finally{F(!1)}}},[t,T,O,S,P]);(0,v.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`s`&&(e.preventDefault(),z())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[z]);let B=p[l];return(0,y.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-3 py-2 shrink-0`,children:[(0,y.jsx)(B,{className:`size-4 text-text-subtle`}),(0,y.jsx)(`span`,{className:`text-sm font-semibold`,children:n}),(0,y.jsx)(d,{scope:b}),R&&!S&&(0,y.jsx)(`span`,{className:`size-1.5 rounded-full bg-primary`,title:`Unsaved changes`}),(0,y.jsx)(`div`,{className:`flex-1`}),(0,y.jsxs)(`span`,{className:`hidden sm:block text-[11px] text-text-subtle`,children:[l,` · markdown`]}),!S&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`button`,{onClick:()=>D(O),disabled:!R||P,className:`flex items-center gap-1 rounded px-2 py-1 text-xs text-text-secondary hover:bg-surface-elevated disabled:opacity-40`,children:[(0,y.jsx)(i,{className:`size-3.5`}),` Revert`]}),(0,y.jsxs)(`button`,{onClick:()=>void z(),disabled:!R||P,className:`flex items-center gap-1 rounded bg-primary px-2.5 py-1 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-40`,children:[P?(0,y.jsx)(s,{className:`size-3.5 animate-spin`}):(0,y.jsx)(o,{className:`size-3.5`}),` Save`]})]})]}),S&&(0,y.jsx)(x,{icon:r,tone:`muted`,children:`Bundled resource — read-only. Duplicate it (from the AI Resources panel) to make an editable copy.`}),C&&w&&(0,y.jsxs)(x,{icon:a,tone:`warn`,children:[`This `,l,` is overridden by another “`,w.name,`” from a higher-priority source (`,w.source,`). It is currently inactive.`]}),(0,y.jsx)(`div`,{className:`min-h-0 flex-1`,children:A?(0,y.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,y.jsx)(s,{className:`size-5 animate-spin text-primary`})}):M?(0,y.jsx)(`div`,{className:`p-6 text-center text-sm text-destructive`,children:M}):(0,y.jsx)(h,{beforeMount:f,height:`100%`,language:`markdown`,theme:I,value:E,onChange:e=>{let t=e??``;L.current=t,D(t)},options:{readOnly:S,minimap:{enabled:!1},fontSize:13,wordWrap:`on`,scrollBeyondLastLine:!1,lineNumbers:`on`}})})]})}function x({icon:e,tone:t,children:n}){return(0,y.jsxs)(`div`,{className:l(`flex items-start gap-2 px-3 py-2 text-[12px] shrink-0 border-b border-border`,t===`warn`?`bg-amber-500/10 text-amber-300`:`bg-surface-elevated text-text-secondary`),children:[(0,y.jsx)(e,{className:`mt-0.5 size-3.5 shrink-0`}),(0,y.jsx)(`span`,{children:n})]})}export{b as AiResourceEditor};
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{D as t,E as n}from"./vendor-markdown-C-P1aR4p.js";import{Kr as r,gt as i,hr as a,r as o}from"./icons-BwyIKaTT.js";import{r as s}from"./api-client-xQDlhUTu.js";import{t as c}from"./open-settings-EXR4zoZG.js";import{t as l}from"./button-C9ZXWb3b.js";import{t as u}from"./input-C3oVNCMq.js";import{Ai as d,Er as f,Gn as p,Hn as m,Kn as h,Pn as g,Un as _,Vn as v,Wn as y}from"./index-BGk8EFQb.js";import{a as b,b as x}from"./api-settings-vmIRFNwZ.js";var S=e(t(),1),C=n(),w=[128e3,272e3,4e5,512e3,872e3,1e6],T=[1e5,2e5,23e4,35e4,45e4,75e4,9e5];function E({id:e,label:t,value:n,presets:r,disabled:i,compact:a,onChange:o}){let[s,c]=(0,S.useState)(!!n&&!r.includes(Number(n))),l=a?`text-[11px]`:`text-sm`;return(0,C.jsxs)(`div`,{className:`space-y-1`,children:[(0,C.jsx)(f,{htmlFor:e,className:l,children:t}),(0,C.jsxs)(`select`,{id:e,value:s?`custom`:n||`default`,disabled:i,"aria-describedby":`codex-context-help`,className:`w-full min-h-11 sm:min-h-0 rounded-md border border-input bg-background px-3 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50 ${a?`h-7`:`h-9`} ${l}`,onChange:e=>{let t=e.target.value;c(t===`custom`),t!==`custom`&&o(t===`default`?``:t)},children:[(0,C.jsx)(`option`,{value:`default`,children:`Codex default`}),r.map(e=>(0,C.jsxs)(`option`,{value:String(e),children:[e===1e6?`1M`:`${e/1e3}K`,` tokens`]},e)),(0,C.jsx)(`option`,{value:`custom`,children:`Custom...`})]}),s&&(0,C.jsx)(u,{id:`${e}-custom`,"aria-label":`Custom ${t.toLowerCase()}`,type:`number`,min:1,step:1,required:!0,value:n,disabled:i,placeholder:`Enter tokens`,"aria-describedby":`codex-context-help`,className:`min-h-11 sm:min-h-0 ${a?`h-7 text-[11px]`:``}`,onChange:e=>o(e.target.value)})]})}function D({config:e,compact:t,saving:n,onSave:r}){let[i,a]=(0,S.useState)(String(e?.model_context_window??``)),[o,s]=(0,S.useState)(String(e?.model_auto_compact_token_limit??``)),[c,l]=(0,S.useState)(null),u=t?`text-[11px]`:`text-sm`,d=t?`text-[9px]`:`text-[11px]`;async function f(e){e.preventDefault();let t=i.trim()?Number(i):null,n=o.trim()?Number(o):null;if([t,n].some(e=>e!==null&&(!Number.isSafeInteger(e)||e<=0))){l(`Enter positive whole numbers of tokens, or leave blank for Codex defaults.`);return}if(t!==null&&n!==null&&n>t){l(`Auto-compact threshold must not exceed the context window.`);return}l(null),await r({model_context_window:t,model_auto_compact_token_limit:n})}return(0,C.jsxs)(`form`,{onSubmit:f,className:`space-y-2 rounded-md border border-border p-3`,children:[(0,C.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[(0,C.jsx)(E,{id:`codex-context-window`,label:`Context window (tokens)`,value:i,presets:w,disabled:n,compact:t,onChange:e=>{a(e),l(null)}}),(0,C.jsx)(E,{id:`codex-compact-threshold`,label:`Auto-compact threshold (tokens)`,value:o,presets:T,disabled:n,compact:t,onChange:e=>{s(e),l(null)}})]}),(0,C.jsx)(`p`,{id:`codex-context-help`,className:`${d} text-muted-foreground`,children:`Choose Codex default to use Codex configuration and model defaults, or Custom to enter a value. Presets are shortcuts, not a list of limits supported by your model; increasing these values does not unlock a larger context window. Applies to new sessions and sessions resumed after a PPM restart.`}),c&&(0,C.jsx)(`p`,{role:`alert`,className:`${u} text-error`,children:c}),(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,C.jsx)(`a`,{href:`https://learn.chatgpt.com/docs/config-file/config-reference`,target:`_blank`,rel:`noreferrer`,className:`${d} text-primary underline`,children:`Codex context documentation`}),(0,C.jsx)(`button`,{type:`submit`,disabled:n,className:`min-h-11 sm:min-h-0 rounded-md border border-border px-3 py-1.5 hover:bg-surface-elevated disabled:opacity-50 ${u}`,children:n?`Saving...`:`Save context settings`})]})]})}var O=[{value:`low`,label:`Low`},{value:`medium`,label:`Medium`},{value:`high`,label:`High`},{value:`xhigh`,label:`Extra`},{value:`max`,label:`Max`}],k=[{value:`bypassPermissions`,label:`Bypass permissions (default)`},{value:`default`,label:`Ask before edits`},{value:`acceptEdits`,label:`Edit automatically`},{value:`plan`,label:`Plan mode`}],A={claude:`Claude`,cursor:`Cursor`,codex:`Codex`,gemini:`Gemini`};function j({compact:e}={}){let[t,n]=(0,S.useState)(null),[r,w]=(0,S.useState)(``),[T,E]=(0,S.useState)([]),[j,M]=(0,S.useState)(!1),[N,P]=(0,S.useState)(!1),[F,I]=(0,S.useState)(null),[L,R]=(0,S.useState)(0),[z,B]=(0,S.useState)([]),[V,H]=(0,S.useState)(!1);(0,S.useEffect)(()=>{b().then(e=>{n(e),w(e.default_provider??`claude`)}).catch(e=>I(e.message))},[]),(0,S.useEffect)(()=>{r&&s.get(`/api/settings/ai/providers/status`).then(B).catch(()=>B([]))},[r]);let U=z.find(e=>e.id===r&&!e.registered);(0,S.useEffect)(()=>{r&&(M(!0),s.get(`/api/settings/ai/providers/${r}/models`).then(E).catch(()=>E([])).finally(()=>M(!1)))},[r,!U]);let W=async()=>{H(!0);try{let e=await s.post(`/api/settings/ai/providers/${r}/probe`);B(t=>t.map(t=>t.id===e.id?e:t))}catch(e){I(e.message)}finally{H(!1)}},G=t?Object.keys(t.providers).filter(e=>e!==`mock`).map(e=>({id:e,name:A[e]??e})):[],K=t?.providers[r],q=K?.type===`agent-sdk`||!K?.type&&r===`claude`,J=async e=>{if(!t)return!1;P(!0),I(null);try{return n(await x(e)),R(e=>e+1),!0}catch(e){return I(e.message),!1}finally{P(!1)}},Y=(e,t)=>J({providers:{[r]:{[e]:t}}}),X=e?`text-[11px]`:`text-sm`,Z=e?`text-xs`:`text-sm`,te=e?`space-y-2`:`space-y-4`,Q=e?`space-y-1.5`:`space-y-3`,$=e?`space-y-1`:`space-y-1.5`;if(!t)return(0,C.jsxs)(`div`,{className:Q,children:[(0,C.jsx)(`h3`,{className:`${Z} font-medium text-text-secondary`,children:`AI Settings`}),(0,C.jsx)(`p`,{className:`${X} text-text-subtle`,children:F?`Error: ${F}`:`Loading...`})]});let ne=q?T:[{value:`__default__`,label:`Auto (default)`},...T];return(0,C.jsxs)(`div`,{className:te,children:[(0,C.jsx)(`h3`,{className:`${Z} font-medium text-text-secondary`,children:`AI Settings`}),(0,C.jsxs)(`div`,{className:$,children:[(0,C.jsx)(f,{htmlFor:`ai-new-chat-provider`,className:e?X:void 0,children:`New chat provider`}),(0,C.jsxs)(v,{value:t.new_chat_provider_mode??`default`,disabled:N,onValueChange:e=>J({new_chat_provider_mode:e}),children:[(0,C.jsx)(y,{id:`ai-new-chat-provider`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,C.jsx)(p,{})}),(0,C.jsxs)(m,{children:[(0,C.jsx)(_,{value:`follow-focus`,children:`Follow last focused chat`}),(0,C.jsx)(_,{value:`default`,children:`Always use default provider`})]})]}),(0,C.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:t.new_chat_provider_mode===`follow-focus`?`New tabs follow the last chat you focused in this project, across panels. Existing tabs keep their provider.`:`New tabs always use the default provider. Existing tabs keep their provider.`})]}),(0,C.jsxs)(`div`,{className:$,children:[(0,C.jsx)(f,{htmlFor:`ai-default-provider`,className:e?X:void 0,children:`Default provider`}),(0,C.jsxs)(v,{value:t.default_provider,disabled:N,onValueChange:e=>J({default_provider:e}),children:[(0,C.jsx)(y,{id:`ai-default-provider`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,C.jsx)(p,{})}),(0,C.jsx)(m,{children:G.map(e=>(0,C.jsx)(_,{value:e.id,children:e.name},e.id))})]}),t.new_chat_provider_mode===`follow-focus`&&(0,C.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Used when no chat has been focused in this project yet.`})]}),(0,C.jsxs)(`div`,{className:`flex items-start justify-between gap-3 rounded-md border border-border p-3`,children:[(0,C.jsxs)(`div`,{className:$,children:[(0,C.jsx)(f,{htmlFor:`ai-share-provider-context`,className:e?X:void 0,children:`Share rules and memory between providers`}),(0,C.jsx)(`p`,{id:`ai-share-provider-context-description`,className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Share project rules and memory, plus global instruction files, across providers. Applies from the next project-chat message. Turning off keeps context already sent.`})]}),(0,C.jsx)(h,{id:`ai-share-provider-context`,"aria-describedby":`ai-share-provider-context-description`,checked:t.share_provider_context??!0,disabled:N,onCheckedChange:e=>J({share_provider_context:e})})]}),G.length>1&&(0,C.jsx)(`div`,{className:`flex gap-0.5 border-b border-border/50 -mx-1 px-1`,children:G.map(e=>(0,C.jsxs)(`button`,{onClick:()=>w(e.id),className:`flex items-center gap-1 px-2 py-1 text-[11px] rounded-t transition-colors ${r===e.id?`text-primary border-b-2 border-primary font-medium`:`text-text-subtle hover:text-text-secondary`}`,children:[(0,C.jsx)(d,{providerId:e.id}),(0,C.jsx)(`span`,{className:`capitalize`,children:e.name})]},e.id))}),(0,C.jsxs)(`div`,{className:Q,children:[U&&(0,C.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-warning/30 bg-warning/5 px-2.5 py-2`,children:[(0,C.jsx)(o,{className:`size-3.5 text-warning shrink-0 mt-0.5`}),(0,C.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1.5`,children:[(0,C.jsxs)(`p`,{className:`${X} text-text-secondary`,children:[A[r]??r,` is not available in chat — PPM could not start it.`]}),(0,C.jsx)(`p`,{className:`text-[11px] text-muted-foreground break-words`,children:U.reason}),U.nextProbeAt&&(0,C.jsxs)(`p`,{className:`text-[11px] text-text-subtle`,children:[`Checking again at `,new Date(U.nextProbeAt).toLocaleTimeString()]}),(0,C.jsxs)(l,{variant:`outline`,size:`sm`,onClick:W,disabled:V,className:`gap-1.5 cursor-pointer min-h-11 md:min-h-8`,children:[(0,C.jsx)(a,{className:`size-3.5 ${V?`animate-spin`:``}`}),V?`Checking...`:`Check again`]})]})]}),r===`codex`&&(0,C.jsxs)(`button`,{type:`button`,onClick:()=>c(`accounts`),className:`w-full flex items-center justify-between gap-2 rounded-md border border-border px-2.5 py-2 text-left cursor-pointer hover:bg-surface-elevated transition-colors`,children:[(0,C.jsx)(`span`,{className:`${X} text-text-secondary`,children:`Codex accounts & login`}),(0,C.jsx)(i,{className:`size-3.5 text-text-subtle shrink-0`})]}),T.length>0&&(0,C.jsxs)(`div`,{className:$,children:[(0,C.jsx)(f,{htmlFor:`ai-model`,className:e?X:void 0,children:`Model`}),(0,C.jsxs)(v,{value:q?K?.model??T[0]?.value:K?.model||`__default__`,onValueChange:e=>Y(`model`,e===`__default__`?void 0:e),disabled:j,children:[(0,C.jsx)(y,{id:`ai-model`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,C.jsx)(p,{placeholder:j?`Loading models...`:`Select model`})}),(0,C.jsx)(m,{className:`max-h-[300px]`,children:ne.map(e=>(0,C.jsx)(_,{value:e.value,children:e.label},e.value))})]})]}),r===`codex`&&(0,C.jsx)(D,{config:K,compact:e,saving:N,onSave:e=>J({providers:{codex:e}})},JSON.stringify([K?.model_context_window,K?.model_auto_compact_token_limit])),q&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(`div`,{className:$,children:[(0,C.jsx)(f,{htmlFor:`ai-base-url`,className:e?X:void 0,children:`Base URL`}),(0,C.jsx)(u,{id:`ai-base-url`,type:`url`,defaultValue:K?.base_url??``,placeholder:`https://api.anthropic.com (default)`,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{Y(`base_url`,e.target.value.trim()||void 0)}},`baseurl-${r}-${L}`)]}),(0,C.jsxs)(`div`,{className:$,children:[(0,C.jsx)(f,{htmlFor:`ai-api-key`,className:e?X:void 0,children:`API Key / Token`}),(0,C.jsx)(u,{id:`ai-api-key`,type:`password`,defaultValue:K?.api_key??``,placeholder:`sk-ant-... (optional, overrides accounts)`,className:e?`h-7 text-[11px] font-mono`:`font-mono`,onBlur:e=>{let t=e.target.value.trim();t.startsWith(`••••`)||Y(`api_key`,t||void 0)}},`apikey-${r}-${L}`),(0,C.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Direct API key or OAuth token. Leave empty to use connected accounts.`})]}),(0,C.jsxs)(`div`,{className:$,children:[(0,C.jsx)(f,{htmlFor:`ai-effort`,className:e?X:void 0,children:`Effort`}),(0,C.jsxs)(v,{value:K?.effort??`high`,onValueChange:e=>Y(`effort`,e),children:[(0,C.jsx)(y,{id:`ai-effort`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,C.jsx)(p,{})}),(0,C.jsx)(m,{children:O.map(e=>(0,C.jsx)(_,{value:e.value,children:e.label},e.value))})]})]}),(0,C.jsxs)(`div`,{className:$,children:[(0,C.jsx)(f,{htmlFor:`ai-max-turns`,className:e?X:void 0,children:`Max Turns (1-500)`}),(0,C.jsx)(u,{id:`ai-max-turns`,type:`number`,min:1,max:500,defaultValue:K?.max_turns??100,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{let t=parseInt(e.target.value);isNaN(t)||Y(`max_turns`,t)}},`turns-${r}-${L}`)]}),(0,C.jsxs)(`div`,{className:$,children:[(0,C.jsx)(f,{htmlFor:`ai-budget`,className:e?X:void 0,children:`Max Budget (USD)`}),(0,C.jsx)(u,{id:`ai-budget`,type:`number`,step:.1,min:.01,max:50,defaultValue:K?.max_budget_usd??``,placeholder:`No limit`,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{let t=parseFloat(e.target.value);Y(`max_budget_usd`,isNaN(t)?void 0:t)}},`budget-${r}-${L}`)]}),(0,C.jsxs)(`div`,{className:$,children:[(0,C.jsx)(f,{htmlFor:`ai-thinking`,className:e?X:void 0,children:`Thinking Budget (tokens)`}),(0,C.jsx)(u,{id:`ai-thinking`,type:`number`,min:0,defaultValue:K?.thinking_budget_tokens??``,placeholder:`Adaptive (model decides)`,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{let t=parseInt(e.target.value);Y(`thinking_budget_tokens`,isNaN(t)?void 0:t)}},`thinking-${r}-${L}`)]}),(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(f,{htmlFor:`ai-agent-teams`,className:e?X:void 0,children:`Agent Teams`}),(0,C.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Experimental. Enables multi-agent collaboration with shared tasks and messaging. Uses ~7x more tokens.`})]}),(0,C.jsx)(h,{id:`ai-agent-teams`,checked:K?.agent_teams??!1,onCheckedChange:e=>Y(`agent_teams`,e)})]}),K?.agent_teams&&(0,C.jsx)(ee,{compact:e}),(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(f,{htmlFor:`ai-context-1m`,className:e?X:void 0,children:`1M Context Window`}),(0,C.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Requires an entitled account (Max/Team/Enterprise) and an Opus 4 / Sonnet 4 model. Other accounts will error.`})]}),(0,C.jsx)(h,{id:`ai-context-1m`,checked:K?.context_1m??!1,onCheckedChange:e=>Y(`context_1m`,e)})]}),(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(f,{htmlFor:`ai-inherit-mcp`,className:e?X:void 0,children:`Inherit Claude Code MCP`}),(0,C.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Auto-load MCP servers from Claude Code's ~/.claude.json (global + per-project). Your own MCP servers override inherited ones.`})]}),(0,C.jsx)(h,{id:`ai-inherit-mcp`,checked:K?.inherit_claude_mcp??!0,onCheckedChange:e=>Y(`inherit_claude_mcp`,e)})]}),(0,C.jsxs)(`div`,{className:$,children:[(0,C.jsx)(f,{className:e?X:void 0,children:`MCP sign-in`}),(0,C.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Servers that use OAuth stay unavailable to Claude until someone signs in. Project-scoped servers are listed in the project's AI Resources panel.`}),(0,C.jsx)(`div`,{className:`-mx-2`,children:(0,C.jsx)(g,{showWhenEmpty:!0})})]})]}),(0,C.jsxs)(`div`,{className:$,children:[(0,C.jsx)(f,{htmlFor:`ai-permission-mode`,className:e?X:void 0,children:`Default Permission Mode`}),(0,C.jsxs)(v,{value:K?.permission_mode??`bypassPermissions`,onValueChange:e=>Y(`permission_mode`,e),children:[(0,C.jsx)(y,{id:`ai-permission-mode`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,C.jsx)(p,{})}),(0,C.jsx)(m,{children:k.map(e=>(0,C.jsx)(_,{value:e.value,children:e.label},e.value))})]})]}),(0,C.jsxs)(`div`,{className:$,children:[(0,C.jsx)(f,{htmlFor:`ai-system-prompt`,className:e?X:void 0,children:`Additional Instructions`}),(0,C.jsx)(`textarea`,{id:`ai-system-prompt`,rows:e?3:4,defaultValue:K?.system_prompt??``,placeholder:`Enter additional instructions for ${r}...`,className:`w-full rounded-md border border-input bg-background px-3 py-2 ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ${e?`text-[11px]`:`text-sm`}`,onBlur:e=>{Y(`system_prompt`,e.target.value.trim()||void 0)}},`sysprompt-${r}-${L}`)]})]}),N&&(0,C.jsx)(`p`,{className:`text-xs text-text-subtle`,children:`Saving...`}),F&&(0,C.jsx)(`p`,{className:`text-xs text-error`,children:F})]})}function ee({compact:e}){let[t,n]=(0,S.useState)([]),[i,o]=(0,S.useState)(!1),[c,l]=(0,S.useState)(null),u=(0,S.useCallback)(async()=>{o(!0);try{n(await s.get(`/api/teams`)??[])}catch{}o(!1)},[]);(0,S.useEffect)(()=>{u()},[u]);let d=async e=>{try{await s.del(`/api/teams/${encodeURIComponent(e)}`),n(t=>t.filter(t=>t.name!==e)),l(null)}catch{}};return t.length===0&&!i?null:(0,C.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,C.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,C.jsxs)(f,{className:e?`text-[11px]`:void 0,children:[`Teams (`,t.length,`)`]}),(0,C.jsx)(`button`,{onClick:u,className:`text-text-subtle hover:text-foreground p-1`,"aria-label":`Refresh teams`,children:(0,C.jsx)(a,{className:`size-3 ${i?`animate-spin`:``}`})})]}),t.map(e=>(0,C.jsxs)(`div`,{className:`flex items-center justify-between p-2 rounded bg-surface-elevated text-xs`,children:[(0,C.jsxs)(`div`,{className:`min-w-0`,children:[(0,C.jsx)(`div`,{className:`font-medium truncate`,children:e.name}),e.description&&(0,C.jsx)(`div`,{className:`text-text-subtle truncate`,children:e.description}),(0,C.jsxs)(`div`,{className:`text-text-subtle`,children:[e.members?.length??e.memberCount??0,` members`,e.createdAt?` · ${new Date(e.createdAt).toLocaleDateString()}`:``]})]}),c===e.name?(0,C.jsxs)(`div`,{className:`flex gap-1 shrink-0 ml-2`,children:[(0,C.jsx)(`button`,{onClick:()=>d(e.name),className:`px-2 py-1 bg-error text-white rounded text-[10px]`,children:`Delete`}),(0,C.jsx)(`button`,{onClick:()=>l(null),className:`px-2 py-1 bg-panel-2 text-text rounded text-[10px]`,children:`Cancel`})]}):(0,C.jsx)(`button`,{onClick:()=>l(e.name),className:`shrink-0 text-text-subtle hover:text-error p-1 ml-2`,"aria-label":`Delete team ${e.name}`,children:(0,C.jsx)(r,{className:`size-3.5`})})]},e.name))]})}export{j as t};
|
|
1
|
+
import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{D as t,E as n}from"./vendor-markdown-C-P1aR4p.js";import{Kr as r,gt as i,hr as a,r as o}from"./icons-BwyIKaTT.js";import{r as s}from"./api-client-xQDlhUTu.js";import{t as c}from"./open-settings-EXR4zoZG.js";import{t as l}from"./button-C9ZXWb3b.js";import{t as u}from"./input-C3oVNCMq.js";import{Ai as d,Er as f,Gn as p,Hn as m,Kn as h,Pn as g,Un as _,Vn as v,Wn as y}from"./index-BtAn_krv.js";import{a as b,b as x}from"./api-settings-vmIRFNwZ.js";var S=e(t(),1),C=n(),w=[128e3,272e3,4e5,512e3,872e3,1e6],T=[1e5,2e5,23e4,35e4,45e4,75e4,9e5];function E({id:e,label:t,value:n,presets:r,disabled:i,compact:a,onChange:o}){let[s,c]=(0,S.useState)(!!n&&!r.includes(Number(n))),l=a?`text-[11px]`:`text-sm`;return(0,C.jsxs)(`div`,{className:`space-y-1`,children:[(0,C.jsx)(f,{htmlFor:e,className:l,children:t}),(0,C.jsxs)(`select`,{id:e,value:s?`custom`:n||`default`,disabled:i,"aria-describedby":`codex-context-help`,className:`w-full min-h-11 sm:min-h-0 rounded-md border border-input bg-background px-3 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50 ${a?`h-7`:`h-9`} ${l}`,onChange:e=>{let t=e.target.value;c(t===`custom`),t!==`custom`&&o(t===`default`?``:t)},children:[(0,C.jsx)(`option`,{value:`default`,children:`Codex default`}),r.map(e=>(0,C.jsxs)(`option`,{value:String(e),children:[e===1e6?`1M`:`${e/1e3}K`,` tokens`]},e)),(0,C.jsx)(`option`,{value:`custom`,children:`Custom...`})]}),s&&(0,C.jsx)(u,{id:`${e}-custom`,"aria-label":`Custom ${t.toLowerCase()}`,type:`number`,min:1,step:1,required:!0,value:n,disabled:i,placeholder:`Enter tokens`,"aria-describedby":`codex-context-help`,className:`min-h-11 sm:min-h-0 ${a?`h-7 text-[11px]`:``}`,onChange:e=>o(e.target.value)})]})}function D({config:e,compact:t,saving:n,onSave:r}){let[i,a]=(0,S.useState)(String(e?.model_context_window??``)),[o,s]=(0,S.useState)(String(e?.model_auto_compact_token_limit??``)),[c,l]=(0,S.useState)(null),u=t?`text-[11px]`:`text-sm`,d=t?`text-[9px]`:`text-[11px]`;async function f(e){e.preventDefault();let t=i.trim()?Number(i):null,n=o.trim()?Number(o):null;if([t,n].some(e=>e!==null&&(!Number.isSafeInteger(e)||e<=0))){l(`Enter positive whole numbers of tokens, or leave blank for Codex defaults.`);return}if(t!==null&&n!==null&&n>t){l(`Auto-compact threshold must not exceed the context window.`);return}l(null),await r({model_context_window:t,model_auto_compact_token_limit:n})}return(0,C.jsxs)(`form`,{onSubmit:f,className:`space-y-2 rounded-md border border-border p-3`,children:[(0,C.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[(0,C.jsx)(E,{id:`codex-context-window`,label:`Context window (tokens)`,value:i,presets:w,disabled:n,compact:t,onChange:e=>{a(e),l(null)}}),(0,C.jsx)(E,{id:`codex-compact-threshold`,label:`Auto-compact threshold (tokens)`,value:o,presets:T,disabled:n,compact:t,onChange:e=>{s(e),l(null)}})]}),(0,C.jsx)(`p`,{id:`codex-context-help`,className:`${d} text-muted-foreground`,children:`Choose Codex default to use Codex configuration and model defaults, or Custom to enter a value. Presets are shortcuts, not a list of limits supported by your model; increasing these values does not unlock a larger context window. Applies to new sessions and sessions resumed after a PPM restart.`}),c&&(0,C.jsx)(`p`,{role:`alert`,className:`${u} text-error`,children:c}),(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,C.jsx)(`a`,{href:`https://learn.chatgpt.com/docs/config-file/config-reference`,target:`_blank`,rel:`noreferrer`,className:`${d} text-primary underline`,children:`Codex context documentation`}),(0,C.jsx)(`button`,{type:`submit`,disabled:n,className:`min-h-11 sm:min-h-0 rounded-md border border-border px-3 py-1.5 hover:bg-surface-elevated disabled:opacity-50 ${u}`,children:n?`Saving...`:`Save context settings`})]})]})}var O=[{value:`low`,label:`Low`},{value:`medium`,label:`Medium`},{value:`high`,label:`High`},{value:`xhigh`,label:`Extra`},{value:`max`,label:`Max`}],k=[{value:`bypassPermissions`,label:`Bypass permissions (default)`},{value:`default`,label:`Ask before edits`},{value:`acceptEdits`,label:`Edit automatically`},{value:`plan`,label:`Plan mode`}],A={claude:`Claude`,cursor:`Cursor`,codex:`Codex`,gemini:`Gemini`};function j({compact:e}={}){let[t,n]=(0,S.useState)(null),[r,w]=(0,S.useState)(``),[T,E]=(0,S.useState)([]),[j,M]=(0,S.useState)(!1),[N,P]=(0,S.useState)(!1),[F,I]=(0,S.useState)(null),[L,R]=(0,S.useState)(0),[z,B]=(0,S.useState)([]),[V,H]=(0,S.useState)(!1);(0,S.useEffect)(()=>{b().then(e=>{n(e),w(e.default_provider??`claude`)}).catch(e=>I(e.message))},[]),(0,S.useEffect)(()=>{r&&s.get(`/api/settings/ai/providers/status`).then(B).catch(()=>B([]))},[r]);let U=z.find(e=>e.id===r&&!e.registered);(0,S.useEffect)(()=>{r&&(M(!0),s.get(`/api/settings/ai/providers/${r}/models`).then(E).catch(()=>E([])).finally(()=>M(!1)))},[r,!U]);let W=async()=>{H(!0);try{let e=await s.post(`/api/settings/ai/providers/${r}/probe`);B(t=>t.map(t=>t.id===e.id?e:t))}catch(e){I(e.message)}finally{H(!1)}},G=t?Object.keys(t.providers).filter(e=>e!==`mock`).map(e=>({id:e,name:A[e]??e})):[],K=t?.providers[r],q=K?.type===`agent-sdk`||!K?.type&&r===`claude`,J=async e=>{if(!t)return!1;P(!0),I(null);try{return n(await x(e)),R(e=>e+1),!0}catch(e){return I(e.message),!1}finally{P(!1)}},Y=(e,t)=>J({providers:{[r]:{[e]:t}}}),X=e?`text-[11px]`:`text-sm`,Z=e?`text-xs`:`text-sm`,te=e?`space-y-2`:`space-y-4`,Q=e?`space-y-1.5`:`space-y-3`,$=e?`space-y-1`:`space-y-1.5`;if(!t)return(0,C.jsxs)(`div`,{className:Q,children:[(0,C.jsx)(`h3`,{className:`${Z} font-medium text-text-secondary`,children:`AI Settings`}),(0,C.jsx)(`p`,{className:`${X} text-text-subtle`,children:F?`Error: ${F}`:`Loading...`})]});let ne=q?T:[{value:`__default__`,label:`Auto (default)`},...T];return(0,C.jsxs)(`div`,{className:te,children:[(0,C.jsx)(`h3`,{className:`${Z} font-medium text-text-secondary`,children:`AI Settings`}),(0,C.jsxs)(`div`,{className:$,children:[(0,C.jsx)(f,{htmlFor:`ai-new-chat-provider`,className:e?X:void 0,children:`New chat provider`}),(0,C.jsxs)(v,{value:t.new_chat_provider_mode??`default`,disabled:N,onValueChange:e=>J({new_chat_provider_mode:e}),children:[(0,C.jsx)(y,{id:`ai-new-chat-provider`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,C.jsx)(p,{})}),(0,C.jsxs)(m,{children:[(0,C.jsx)(_,{value:`follow-focus`,children:`Follow last focused chat`}),(0,C.jsx)(_,{value:`default`,children:`Always use default provider`})]})]}),(0,C.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:t.new_chat_provider_mode===`follow-focus`?`New tabs follow the last chat you focused in this project, across panels. Existing tabs keep their provider.`:`New tabs always use the default provider. Existing tabs keep their provider.`})]}),(0,C.jsxs)(`div`,{className:$,children:[(0,C.jsx)(f,{htmlFor:`ai-default-provider`,className:e?X:void 0,children:`Default provider`}),(0,C.jsxs)(v,{value:t.default_provider,disabled:N,onValueChange:e=>J({default_provider:e}),children:[(0,C.jsx)(y,{id:`ai-default-provider`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,C.jsx)(p,{})}),(0,C.jsx)(m,{children:G.map(e=>(0,C.jsx)(_,{value:e.id,children:e.name},e.id))})]}),t.new_chat_provider_mode===`follow-focus`&&(0,C.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Used when no chat has been focused in this project yet.`})]}),(0,C.jsxs)(`div`,{className:`flex items-start justify-between gap-3 rounded-md border border-border p-3`,children:[(0,C.jsxs)(`div`,{className:$,children:[(0,C.jsx)(f,{htmlFor:`ai-share-provider-context`,className:e?X:void 0,children:`Share rules and memory between providers`}),(0,C.jsx)(`p`,{id:`ai-share-provider-context-description`,className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Share project rules and memory, plus global instruction files, across providers. Applies from the next project-chat message. Turning off keeps context already sent.`})]}),(0,C.jsx)(h,{id:`ai-share-provider-context`,"aria-describedby":`ai-share-provider-context-description`,checked:t.share_provider_context??!0,disabled:N,onCheckedChange:e=>J({share_provider_context:e})})]}),G.length>1&&(0,C.jsx)(`div`,{className:`flex gap-0.5 border-b border-border/50 -mx-1 px-1`,children:G.map(e=>(0,C.jsxs)(`button`,{onClick:()=>w(e.id),className:`flex items-center gap-1 px-2 py-1 text-[11px] rounded-t transition-colors ${r===e.id?`text-primary border-b-2 border-primary font-medium`:`text-text-subtle hover:text-text-secondary`}`,children:[(0,C.jsx)(d,{providerId:e.id}),(0,C.jsx)(`span`,{className:`capitalize`,children:e.name})]},e.id))}),(0,C.jsxs)(`div`,{className:Q,children:[U&&(0,C.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-warning/30 bg-warning/5 px-2.5 py-2`,children:[(0,C.jsx)(o,{className:`size-3.5 text-warning shrink-0 mt-0.5`}),(0,C.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1.5`,children:[(0,C.jsxs)(`p`,{className:`${X} text-text-secondary`,children:[A[r]??r,` is not available in chat — PPM could not start it.`]}),(0,C.jsx)(`p`,{className:`text-[11px] text-muted-foreground break-words`,children:U.reason}),U.nextProbeAt&&(0,C.jsxs)(`p`,{className:`text-[11px] text-text-subtle`,children:[`Checking again at `,new Date(U.nextProbeAt).toLocaleTimeString()]}),(0,C.jsxs)(l,{variant:`outline`,size:`sm`,onClick:W,disabled:V,className:`gap-1.5 cursor-pointer min-h-11 md:min-h-8`,children:[(0,C.jsx)(a,{className:`size-3.5 ${V?`animate-spin`:``}`}),V?`Checking...`:`Check again`]})]})]}),r===`codex`&&(0,C.jsxs)(`button`,{type:`button`,onClick:()=>c(`accounts`),className:`w-full flex items-center justify-between gap-2 rounded-md border border-border px-2.5 py-2 text-left cursor-pointer hover:bg-surface-elevated transition-colors`,children:[(0,C.jsx)(`span`,{className:`${X} text-text-secondary`,children:`Codex accounts & login`}),(0,C.jsx)(i,{className:`size-3.5 text-text-subtle shrink-0`})]}),T.length>0&&(0,C.jsxs)(`div`,{className:$,children:[(0,C.jsx)(f,{htmlFor:`ai-model`,className:e?X:void 0,children:`Model`}),(0,C.jsxs)(v,{value:q?K?.model??T[0]?.value:K?.model||`__default__`,onValueChange:e=>Y(`model`,e===`__default__`?void 0:e),disabled:j,children:[(0,C.jsx)(y,{id:`ai-model`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,C.jsx)(p,{placeholder:j?`Loading models...`:`Select model`})}),(0,C.jsx)(m,{className:`max-h-[300px]`,children:ne.map(e=>(0,C.jsx)(_,{value:e.value,children:e.label},e.value))})]})]}),r===`codex`&&(0,C.jsx)(D,{config:K,compact:e,saving:N,onSave:e=>J({providers:{codex:e}})},JSON.stringify([K?.model_context_window,K?.model_auto_compact_token_limit])),q&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(`div`,{className:$,children:[(0,C.jsx)(f,{htmlFor:`ai-base-url`,className:e?X:void 0,children:`Base URL`}),(0,C.jsx)(u,{id:`ai-base-url`,type:`url`,defaultValue:K?.base_url??``,placeholder:`https://api.anthropic.com (default)`,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{Y(`base_url`,e.target.value.trim()||void 0)}},`baseurl-${r}-${L}`)]}),(0,C.jsxs)(`div`,{className:$,children:[(0,C.jsx)(f,{htmlFor:`ai-api-key`,className:e?X:void 0,children:`API Key / Token`}),(0,C.jsx)(u,{id:`ai-api-key`,type:`password`,defaultValue:K?.api_key??``,placeholder:`sk-ant-... (optional, overrides accounts)`,className:e?`h-7 text-[11px] font-mono`:`font-mono`,onBlur:e=>{let t=e.target.value.trim();t.startsWith(`••••`)||Y(`api_key`,t||void 0)}},`apikey-${r}-${L}`),(0,C.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Direct API key or OAuth token. Leave empty to use connected accounts.`})]}),(0,C.jsxs)(`div`,{className:$,children:[(0,C.jsx)(f,{htmlFor:`ai-effort`,className:e?X:void 0,children:`Effort`}),(0,C.jsxs)(v,{value:K?.effort??`high`,onValueChange:e=>Y(`effort`,e),children:[(0,C.jsx)(y,{id:`ai-effort`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,C.jsx)(p,{})}),(0,C.jsx)(m,{children:O.map(e=>(0,C.jsx)(_,{value:e.value,children:e.label},e.value))})]})]}),(0,C.jsxs)(`div`,{className:$,children:[(0,C.jsx)(f,{htmlFor:`ai-max-turns`,className:e?X:void 0,children:`Max Turns (1-500)`}),(0,C.jsx)(u,{id:`ai-max-turns`,type:`number`,min:1,max:500,defaultValue:K?.max_turns??100,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{let t=parseInt(e.target.value);isNaN(t)||Y(`max_turns`,t)}},`turns-${r}-${L}`)]}),(0,C.jsxs)(`div`,{className:$,children:[(0,C.jsx)(f,{htmlFor:`ai-budget`,className:e?X:void 0,children:`Max Budget (USD)`}),(0,C.jsx)(u,{id:`ai-budget`,type:`number`,step:.1,min:.01,max:50,defaultValue:K?.max_budget_usd??``,placeholder:`No limit`,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{let t=parseFloat(e.target.value);Y(`max_budget_usd`,isNaN(t)?void 0:t)}},`budget-${r}-${L}`)]}),(0,C.jsxs)(`div`,{className:$,children:[(0,C.jsx)(f,{htmlFor:`ai-thinking`,className:e?X:void 0,children:`Thinking Budget (tokens)`}),(0,C.jsx)(u,{id:`ai-thinking`,type:`number`,min:0,defaultValue:K?.thinking_budget_tokens??``,placeholder:`Adaptive (model decides)`,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{let t=parseInt(e.target.value);Y(`thinking_budget_tokens`,isNaN(t)?void 0:t)}},`thinking-${r}-${L}`)]}),(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(f,{htmlFor:`ai-agent-teams`,className:e?X:void 0,children:`Agent Teams`}),(0,C.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Experimental. Enables multi-agent collaboration with shared tasks and messaging. Uses ~7x more tokens.`})]}),(0,C.jsx)(h,{id:`ai-agent-teams`,checked:K?.agent_teams??!1,onCheckedChange:e=>Y(`agent_teams`,e)})]}),K?.agent_teams&&(0,C.jsx)(ee,{compact:e}),(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(f,{htmlFor:`ai-context-1m`,className:e?X:void 0,children:`1M Context Window`}),(0,C.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Requires an entitled account (Max/Team/Enterprise) and an Opus 4 / Sonnet 4 model. Other accounts will error.`})]}),(0,C.jsx)(h,{id:`ai-context-1m`,checked:K?.context_1m??!1,onCheckedChange:e=>Y(`context_1m`,e)})]}),(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(f,{htmlFor:`ai-inherit-mcp`,className:e?X:void 0,children:`Inherit Claude Code MCP`}),(0,C.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Auto-load MCP servers from Claude Code's ~/.claude.json (global + per-project). Your own MCP servers override inherited ones.`})]}),(0,C.jsx)(h,{id:`ai-inherit-mcp`,checked:K?.inherit_claude_mcp??!0,onCheckedChange:e=>Y(`inherit_claude_mcp`,e)})]}),(0,C.jsxs)(`div`,{className:$,children:[(0,C.jsx)(f,{className:e?X:void 0,children:`MCP sign-in`}),(0,C.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Servers that use OAuth stay unavailable to Claude until someone signs in. Project-scoped servers are listed in the project's AI Resources panel.`}),(0,C.jsx)(`div`,{className:`-mx-2`,children:(0,C.jsx)(g,{showWhenEmpty:!0})})]})]}),(0,C.jsxs)(`div`,{className:$,children:[(0,C.jsx)(f,{htmlFor:`ai-permission-mode`,className:e?X:void 0,children:`Default Permission Mode`}),(0,C.jsxs)(v,{value:K?.permission_mode??`bypassPermissions`,onValueChange:e=>Y(`permission_mode`,e),children:[(0,C.jsx)(y,{id:`ai-permission-mode`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,C.jsx)(p,{})}),(0,C.jsx)(m,{children:k.map(e=>(0,C.jsx)(_,{value:e.value,children:e.label},e.value))})]})]}),(0,C.jsxs)(`div`,{className:$,children:[(0,C.jsx)(f,{htmlFor:`ai-system-prompt`,className:e?X:void 0,children:`Additional Instructions`}),(0,C.jsx)(`textarea`,{id:`ai-system-prompt`,rows:e?3:4,defaultValue:K?.system_prompt??``,placeholder:`Enter additional instructions for ${r}...`,className:`w-full rounded-md border border-input bg-background px-3 py-2 ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ${e?`text-[11px]`:`text-sm`}`,onBlur:e=>{Y(`system_prompt`,e.target.value.trim()||void 0)}},`sysprompt-${r}-${L}`)]})]}),N&&(0,C.jsx)(`p`,{className:`text-xs text-text-subtle`,children:`Saving...`}),F&&(0,C.jsx)(`p`,{className:`text-xs text-error`,children:F})]})}function ee({compact:e}){let[t,n]=(0,S.useState)([]),[i,o]=(0,S.useState)(!1),[c,l]=(0,S.useState)(null),u=(0,S.useCallback)(async()=>{o(!0);try{n(await s.get(`/api/teams`)??[])}catch{}o(!1)},[]);(0,S.useEffect)(()=>{u()},[u]);let d=async e=>{try{await s.del(`/api/teams/${encodeURIComponent(e)}`),n(t=>t.filter(t=>t.name!==e)),l(null)}catch{}};return t.length===0&&!i?null:(0,C.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,C.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,C.jsxs)(f,{className:e?`text-[11px]`:void 0,children:[`Teams (`,t.length,`)`]}),(0,C.jsx)(`button`,{onClick:u,className:`text-text-subtle hover:text-foreground p-1`,"aria-label":`Refresh teams`,children:(0,C.jsx)(a,{className:`size-3 ${i?`animate-spin`:``}`})})]}),t.map(e=>(0,C.jsxs)(`div`,{className:`flex items-center justify-between p-2 rounded bg-surface-elevated text-xs`,children:[(0,C.jsxs)(`div`,{className:`min-w-0`,children:[(0,C.jsx)(`div`,{className:`font-medium truncate`,children:e.name}),e.description&&(0,C.jsx)(`div`,{className:`text-text-subtle truncate`,children:e.description}),(0,C.jsxs)(`div`,{className:`text-text-subtle`,children:[e.members?.length??e.memberCount??0,` members`,e.createdAt?` · ${new Date(e.createdAt).toLocaleDateString()}`:``]})]}),c===e.name?(0,C.jsxs)(`div`,{className:`flex gap-1 shrink-0 ml-2`,children:[(0,C.jsx)(`button`,{onClick:()=>d(e.name),className:`px-2 py-1 bg-error text-white rounded text-[10px]`,children:`Delete`}),(0,C.jsx)(`button`,{onClick:()=>l(null),className:`px-2 py-1 bg-panel-2 text-text rounded text-[10px]`,children:`Cancel`})]}):(0,C.jsx)(`button`,{onClick:()=>l(e.name),className:`shrink-0 text-text-subtle hover:text-error p-1 ml-2`,"aria-label":`Delete team ${e.name}`,children:(0,C.jsx)(r,{className:`size-3.5`})})]},e.name))]})}export{j as t};
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./vendor-markdown-C-P1aR4p.js";import"./vendor-ui-BTSIXzhZ.js";import"./icons-BwyIKaTT.js";import"./api-client-xQDlhUTu.js";import"./settings-store-B4mLp19V.js";import"./portal-container-context-NBi-KGK0.js";import"./window-store-DqX_qmkQ.js";import"./panel-store-BJhazigC.js";import"./project-store-BLGl9IAO.js";import"./project-framework-store-DwLxaRan.js";import"./session-list-sync-triggers-DtJI5KF0.js";import"./tab-store-D5I52eLN.js";import"./chat-preparation-cache-190LLyy7.js";import"./use-is-mobile-VRV9eZy1.js";import"./settings-categories-Ajj4ui27.js";import"./open-settings-EXR4zoZG.js";import"./button-C9ZXWb3b.js";import"./dialog-Dn_2tuYa.js";import"./mobile-bottom-sheet-DArbIyrD.js";import"./use-visual-viewport-MmugpRg-.js";import"./input-C3oVNCMq.js";import"./api-settings-vmIRFNwZ.js";import{t as e}from"./ai-settings-section-
|
|
1
|
+
import"./vendor-markdown-C-P1aR4p.js";import"./vendor-ui-BTSIXzhZ.js";import"./icons-BwyIKaTT.js";import"./api-client-xQDlhUTu.js";import"./settings-store-B4mLp19V.js";import"./portal-container-context-NBi-KGK0.js";import"./window-store-DqX_qmkQ.js";import"./panel-store-BJhazigC.js";import"./project-store-BLGl9IAO.js";import"./project-framework-store-DwLxaRan.js";import"./session-list-sync-triggers-DtJI5KF0.js";import"./tab-store-D5I52eLN.js";import"./chat-preparation-cache-190LLyy7.js";import"./use-is-mobile-VRV9eZy1.js";import"./settings-categories-Ajj4ui27.js";import"./open-settings-EXR4zoZG.js";import"./button-C9ZXWb3b.js";import"./dialog-Dn_2tuYa.js";import"./mobile-bottom-sheet-DArbIyrD.js";import"./use-visual-viewport-MmugpRg-.js";import"./input-C3oVNCMq.js";import"./api-settings-vmIRFNwZ.js";import{t as e}from"./ai-settings-section-DMGM1hYx.js";export{e as AISettingsSection};
|