sliccy 6.177.0 → 6.178.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/node-server/bridge-security.d.ts +7 -0
- package/dist/node-server/bridge-security.js +14 -0
- package/dist/node-server/index.js +8 -2
- package/dist/ui/.vite/manifest.json +316 -305
- package/dist/ui/assets/{SKILL-CLL4Q13w.js → SKILL-BIdAO7Ya.js} +1 -1
- package/dist/ui/assets/SKILL-Be-LbAuP.js +1 -0
- package/dist/ui/assets/SKILL-D3hRMDs3.js +1 -0
- package/dist/ui/assets/{SKILL-D4YrvP3q.js → SKILL-wvtABi3i.js} +1 -1
- package/dist/ui/assets/__vite-browser-external-C7Grxh8D.js +1 -0
- package/dist/ui/assets/account-store-Cq1iLLd1.js +1 -0
- package/dist/ui/assets/{account-store-Bdv0oQNY.js → account-store-S74-2PYK.js} +2 -2
- package/dist/ui/assets/adobe-00iHjKNp.js +1 -0
- package/dist/ui/assets/{adobe-lWDt5QnR.js → adobe-Df_ijIBF.js} +2 -2
- package/dist/ui/assets/{agent-panels-D38tk9xU.js → agent-panels-DoC14erl.js} +1 -1
- package/dist/ui/assets/{almost-bash-shell-headless-CpwJRuei.js → almost-bash-shell-headless-BNKnE7iz.js} +551 -548
- package/dist/ui/assets/api-endpoint-D8lUKmPu.js +1 -0
- package/dist/ui/assets/api-endpoint-DuEQRZ4g.js +1 -0
- package/dist/ui/assets/{apply-layout-C9TMgTk-.js → apply-layout-qbXcgYo4.js} +1 -1
- package/dist/ui/assets/{apps-3n3ekc2J.js → apps-DGVYlpFo.js} +1 -1
- package/dist/ui/assets/auto-mount-table-B7KPVgHq.js +1 -0
- package/dist/ui/assets/{azure-openai-L9KqKr5a.js → azure-openai-B7GWIGtX.js} +1 -1
- package/dist/ui/assets/{azure-openai-DrfcNNWp.js → azure-openai-C0BQBEQP.js} +1 -1
- package/dist/ui/assets/{backend-hostfs-Be-dB7Kf.js → backend-hostfs-B-dnlb2V.js} +1 -1
- package/dist/ui/assets/{backend-hostfs-CsCDQ3wI.js → backend-hostfs-CMj5JyW-.js} +1 -1
- package/dist/ui/assets/boot-stall-overlay-Cs-FNlf8.js +1 -0
- package/dist/ui/assets/{bridge-protocol-06nbmp2X.js → bridge-protocol-C52CnDIj.js} +1 -1
- package/dist/ui/assets/bridge-token-required-BYgoMwr7.js +1 -0
- package/dist/ui/assets/bridge-token-required-DMk2va9k.js +1 -0
- package/dist/ui/assets/{capability-Ozyg0pIj.js → capability-BpyI5pqv.js} +2 -2
- package/dist/ui/assets/{cdp-0v9KGJm0.js → cdp-DEzvh01y.js} +4 -4
- package/dist/ui/assets/{cerebras-BZv7_kiD.js → cerebras-0-LP8uU7.js} +1 -1
- package/dist/ui/assets/{cerebras-hoLQspWz.js → cerebras-Du1-GKAd.js} +1 -1
- package/dist/ui/assets/{client-GY8xUpw7.js → client-SwBG2bcE.js} +1 -1
- package/dist/ui/assets/{composer-speech-CO4x2Icz.js → composer-speech-Bjx5KF3K.js} +1 -1
- package/dist/ui/assets/{connect-surface-CW4FOL-O.js → connect-surface-B_6zei2K.js} +1 -1
- package/dist/ui/assets/{core-NCt3m1n7.js → core-LSLY4su2.js} +1 -1
- package/dist/ui/assets/{core-DzCO93gg.js → core-zz8rWM4c.js} +1 -1
- package/dist/ui/assets/{directed-approval-B4zZ7lVA.js → directed-approval-JnY9fFHA.js} +1 -1
- package/dist/ui/assets/{discovery-preference-DETLSUyX.js → discovery-preference-pvxthSOH.js} +1 -1
- package/dist/ui/assets/{ensure-speech-assets-D7aP5soE.js → ensure-speech-assets-DpMK2BVK.js} +1 -1
- package/dist/ui/assets/{extension-ops-2LnlLuXD.js → extension-ops-fZojaKTV.js} +1 -1
- package/dist/ui/assets/float-topology-U8FF9pgZ.js +1 -0
- package/dist/ui/assets/{follower-navigate-watcher-CikMiDmz.js → follower-navigate-watcher-B9be6j6U.js} +1 -1
- package/dist/ui/assets/frozen-archive-writer-C6rkeqTj.js +8 -0
- package/dist/ui/assets/fs-B04LUR23.js +1 -0
- package/dist/ui/assets/fs-DNazCCQe.js +2 -0
- package/dist/ui/assets/gelatiere-store-CYT3L7Vb.js +1 -0
- package/dist/ui/assets/{gelatiere-unit-WsZZxiMN.js → gelatiere-unit-DwXO8ltI.js} +1 -1
- package/dist/ui/assets/github-CcKV5VKp.js +1 -0
- package/dist/ui/assets/{github-auth-nx9iXEsx.js → github-auth-BGT4O5xo.js} +1 -1
- package/dist/ui/assets/{github-copilot-CXLis8Dj.js → github-copilot-BwhWpIu1.js} +1 -1
- package/dist/ui/assets/{github-copilot-QTaUnKtg.js → github-copilot-CvHvBxAK.js} +1 -1
- package/dist/ui/assets/github-iChs8y5l.js +2 -0
- package/dist/ui/assets/{github-install-ZbbmDvD_.js → github-install-XqRYcMtt.js} +1 -1
- package/dist/ui/assets/{github-zip-WjzQjXHF.js → github-zip-4EqOXIUE.js} +1 -1
- package/dist/ui/assets/{guest-tool-gate-DImAU5XR.js → guest-tool-gate-BSlehwdt.js} +1 -1
- package/dist/ui/assets/{hear-DdNPsEN1.js → hear-Cpn_F-65.js} +1 -1
- package/dist/ui/assets/{help-Dh3ue9pg.js → help-QX0cC2We.js} +1 -1
- package/dist/ui/assets/{installer-C9yRicr8.js → installer-U9S8N8N1.js} +1 -1
- package/dist/ui/assets/{interrupted-work-recovery-DfZ1NojB.js → interrupted-work-recovery-DD66Ttob.js} +1 -1
- package/dist/ui/assets/{js-realm-worker-TovMDqWM.js → js-realm-worker-DKMnVG_N.js} +1 -1
- package/dist/ui/assets/jsh-executor-BiCBEs7e.js +18 -0
- package/dist/ui/assets/{kernel-worker-BbLNbBtI.js → kernel-worker-C96uVLqD.js} +67 -67
- package/dist/ui/assets/{lick-ws-bridge-ClSwgMz7.js → lick-ws-bridge-DGI7H1_T.js} +1 -1
- package/dist/ui/assets/{lick-ws-bridge-DmiMWYa2.js → lick-ws-bridge-DOF7QXQ9.js} +1 -1
- package/dist/ui/assets/live-session-curation-DVhFE-Ox.js +1 -0
- package/dist/ui/assets/live-session-snapshot-C3DrUEnT.js +1 -0
- package/dist/ui/assets/{local-llm-DFe624II.js → local-llm-DWDhMi6m.js} +1 -1
- package/dist/ui/assets/{local-llm-CCqVGtOE.js → local-llm-OCXxf3jz.js} +1 -1
- package/dist/ui/assets/main-cI-uMcJb.js +22 -0
- package/dist/ui/assets/{main-cherry-C3y_78Lr.js → main-cherry-BDzXVcQE.js} +1 -1
- package/dist/ui/assets/memory-curation-seam-DtuGVyA0.js +1 -0
- package/dist/ui/assets/{memory-health-Dag4bwWD.js → memory-health-C1-Ws6TZ.js} +1 -1
- package/dist/ui/assets/memory-v2-flag-CYHl_0MX.js +1 -0
- package/dist/ui/assets/{memory-write-execute-CITeUrzL.js → memory-write-execute-DXKJTpgr.js} +1 -1
- package/dist/ui/assets/{mount-CmqQZ7ym.js → mount-Beg7rJyd.js} +3 -3
- package/dist/ui/assets/{mount-BCqk0zUX.js → mount-DNQXdZUP.js} +1 -1
- package/dist/ui/assets/{mount-bridge-client-Cvu7boPy.js → mount-bridge-client-B5qwRZN4.js} +1 -1
- package/dist/ui/assets/{mount-bridge-client-DYjwnGiI.js → mount-bridge-client-BjdUSzYx.js} +1 -1
- package/dist/ui/assets/mount-picker-popup-BMils9JY.js +1 -0
- package/dist/ui/assets/mount-picker-popup-qcWGbpG5.js +1 -0
- package/dist/ui/assets/{navigation-watcher-BpA1OwJw.js → navigation-watcher-CPcnZL9l.js} +1 -1
- package/dist/ui/assets/{new-session-C5L_JrfK.js → new-session-CcLRyHPG.js} +2 -2
- package/dist/ui/assets/oauth-D20BEoY6.js +1 -0
- package/dist/ui/assets/oauth-bootstrap-ZVkzpjIg.js +2 -0
- package/dist/ui/assets/{oauth-service-JZ31fJQ0.js → oauth-service-C2D9b8uV.js} +1 -1
- package/dist/ui/assets/oauth-service-Gh6Z-BhZ.js +1 -0
- package/dist/ui/assets/{onboarding-orchestrator-C5ZXBhHI.js → onboarding-orchestrator-DT4m4G7X.js} +1 -1
- package/dist/ui/assets/openai-codex-BC4IvaOv.js +1 -0
- package/dist/ui/assets/openai-codex-BQ9tRIIq.js +1 -0
- package/dist/ui/assets/{openrouter-LSWcGgQS.js → openrouter-CJBLDVpZ.js} +1 -1
- package/dist/ui/assets/{openrouter-DE37mf8G.js → openrouter-TyodWHrW.js} +1 -1
- package/dist/ui/assets/{openrouter-free-rYs3pjwg.js → openrouter-free-BX50G01y.js} +1 -1
- package/dist/ui/assets/{openrouter-free-BjJjNfw8.js → openrouter-free-WPcdZKoe.js} +1 -1
- package/dist/ui/assets/{openrouter-oauth-Dor4HDp1.js → openrouter-oauth-C3IjVanq.js} +1 -1
- package/dist/ui/assets/{openrouter-oauth-BaDX3fok.js → openrouter-oauth-CSHbAliA.js} +1 -1
- package/dist/ui/assets/{opfs-mount-Dnk4pRBr.js → opfs-mount-Bfohoi0h.js} +1 -1
- package/dist/ui/assets/opfs-mount-Dizi9FS1.js +2 -0
- package/dist/ui/assets/{page-approval-service-Dz1E4_a-.js → page-approval-service-CDc9BXzz.js} +1 -1
- package/dist/ui/assets/panel-rpc-handlers-DLOTqcPU.js +2 -0
- package/dist/ui/assets/{panelize-shell-2JDpS7mz.js → panelize-shell-CwsQzaeI.js} +1 -1
- package/dist/ui/assets/{pi-edit-execution-D1pOXHNL.js → pi-edit-execution-Chc5AuQc.js} +1 -1
- package/dist/ui/assets/picker-popup-B6AyYTBw.js +1 -0
- package/dist/ui/assets/{port-bridge-client-CIPpFep1.js → port-bridge-client-BYQawsDH.js} +1 -1
- package/dist/ui/assets/{port-bridge-client-nVkmNLtE.js → port-bridge-client-xBAWa6XJ.js} +1 -1
- package/dist/ui/assets/provider-DhpqYKvN.js +1 -0
- package/dist/ui/assets/provider-DxWLekYl.js +2 -0
- package/dist/ui/assets/{provider-settings-DyJic7fg.js → provider-settings-B0jrEjPK.js} +1 -1
- package/dist/ui/assets/provider-store-access-B_XDCrzI.js +1 -0
- package/dist/ui/assets/provider-store-access-EsgcgdjM.js +1 -0
- package/dist/ui/assets/providers-BXX3OkWO.js +2 -0
- package/dist/ui/assets/{providers-CoLEjgu1.js → providers-DXeKO0vp.js} +1 -1
- package/dist/ui/assets/proxied-fetch-CZTz7e5K.js +1 -0
- package/dist/ui/assets/{proxied-fetch-CUw_f_qQ.js → proxied-fetch-W1rZTqEQ.js} +1 -1
- package/dist/ui/assets/py-realm-worker-A1ICPvEl.js +244 -0
- package/dist/ui/assets/{pyodide-b5uAaIjj.js → pyodide-DGH4V3SQ.js} +2 -2
- package/dist/ui/assets/{quick-llm-B4Bl3BlB.js → quick-llm-D491FPqp.js} +1 -1
- package/dist/ui/assets/{realm-inprocess-ld6jzV_I.js → realm-inprocess-CzoLj3Xw.js} +1 -1
- package/dist/ui/assets/recovery-screen-BsX5dSxb.js +1 -0
- package/dist/ui/assets/{redirect-uri-C-c6wFfz.js → redirect-uri-9iVFGZvL.js} +1 -1
- package/dist/ui/assets/remote-sprinkle-vfs-UzNBy5VJ.js +1 -0
- package/dist/ui/assets/{remote-terminal-view-D2zzMSC8.js → remote-terminal-view-Cvej7E9x.js} +1 -1
- package/dist/ui/assets/rest-ops-FDyHTLt7.js +1 -0
- package/dist/ui/assets/{rest-ops-2kW9P3JM.js → rest-ops-Ftm8DOzU.js} +1 -1
- package/dist/ui/assets/{restore-B2W_z1S2.js → restore-DNbXSMdv.js} +1 -1
- package/dist/ui/assets/{run-D_brqxlz.js → run-0lgIGPtR.js} +2 -2
- package/dist/ui/assets/{run-BI7sTnua.js → run-B4NB-XFg.js} +3 -3
- package/dist/ui/assets/{run-DftiEM24.js → run-BEvYI68Y.js} +1 -1
- package/dist/ui/assets/{run-BLeqr8vT.js → run-BW1OgEfH.js} +2 -2
- package/dist/ui/assets/{run-B7uhqajU.js → run-DT94aw3i.js} +3 -3
- package/dist/ui/assets/{run-B11J_wRm.js → run-DTdaPeZk.js} +1 -1
- package/dist/ui/assets/{run-DLiMjFBS.js → run-YU9tYQ-s.js} +3 -3
- package/dist/ui/assets/{run-DChEOHrZ.js → run-hrgOVM1K.js} +2 -2
- package/dist/ui/assets/{screencapture-run-CoYnKG1H.js → screencapture-run-BiNJCwLY.js} +2 -2
- package/dist/ui/assets/{secret-env-Plkbj3bZ.js → secret-env-DXqj6sUK.js} +1 -1
- package/dist/ui/assets/secret-topology-fyLSbV8r.js +1 -0
- package/dist/ui/assets/{secrets-bridge-client-DB1JAAHL.js → secrets-bridge-client-9RRVsrGm.js} +1 -1
- package/dist/ui/assets/{secrets-bridge-client-nOf1jubu.js → secrets-bridge-client-C0Lc0mUg.js} +1 -1
- package/dist/ui/assets/{session-command-memory-DXc5L79C.js → session-command-memory-qhFqpZin.js} +2 -2
- package/dist/ui/assets/session-jsonl-7CMJAz_O.js +11 -0
- package/dist/ui/assets/{session-jsonl-wn519EPw.js → session-jsonl-D6H0oEEs.js} +1 -1
- package/dist/ui/assets/{session-search-index-BnGk-_KQ.js → session-search-index-DB-cA304.js} +1 -1
- package/dist/ui/assets/{setup-feature-flags-remote-geXdRdMR.js → setup-feature-flags-remote-CbHmB3yy.js} +1 -1
- package/dist/ui/assets/sidecar-repair-BTU4PjlG.js +1 -0
- package/dist/ui/assets/{signed-fetch-3xYgaihI.js → signed-fetch-K5mg-UNn.js} +1 -1
- package/dist/ui/assets/{silent-renew-backoff-Cillu2Yi.js → silent-renew-backoff-DPs8MKs1.js} +1 -1
- package/dist/ui/assets/{slicc-app-url-B9OxaBDe.js → slicc-app-url-BKHBBuTR.js} +1 -1
- package/dist/ui/assets/slicc-version-cii7tBRO.js +1 -0
- package/dist/ui/assets/{snapshot-ppL3jnc4.js → snapshot-DRjB280n.js} +1 -1
- package/dist/ui/assets/{snapshot-features-DJtOdayi.js → snapshot-features-1VuozUQ1.js} +1 -1
- package/dist/ui/assets/{soundscape-UA-NNqes.js → soundscape-Yi1I_to2.js} +1 -1
- package/dist/ui/assets/{speak-DhMbfN3c.js → speak-u3eKnBhD.js} +1 -1
- package/dist/ui/assets/sprinkle-manager-B6umvMDL.js +1 -0
- package/dist/ui/assets/{sprinkle-renderer-BMts24Dw.js → sprinkle-renderer-DFLUy8Rt.js} +19 -14
- package/dist/ui/assets/{ssh-hdAOAXd4.js → ssh-2T7ub5Yk.js} +1 -1
- package/dist/ui/assets/state-C3NHMuT8.js +42 -0
- package/dist/ui/assets/{store-QnpdPWRn.js → store-BCiln3U9.js} +1 -1
- package/dist/ui/assets/{store-CK0Fsd_O.js → store-C89y4bgq.js} +1 -1
- package/dist/ui/assets/{sudo-Bur5cwA-.js → sudo-LmUbpBOj.js} +1 -1
- package/dist/ui/assets/{supervisor-Bnak5TrD.js → supervisor-me6fQoK1.js} +1 -1
- package/dist/ui/assets/{sync-dialog-B0LfXo1C.js → sync-dialog-DYhNAkny.js} +1 -1
- package/dist/ui/assets/sync-sab-wire-CN1_ni9J.js +252 -0
- package/dist/ui/assets/{tab-_QYcA2dc.js → tab-DI1zy4Vd.js} +1 -1
- package/dist/ui/assets/{tab-teleport-BimzPYfT.js → tab-teleport-C8QSKgl0.js} +1 -1
- package/dist/ui/assets/{transformers-env-Dd94b1pO.js → transformers-env-DfP7DUPB.js} +1 -1
- package/dist/ui/assets/{tray-leader-2dEWkCuU.js → tray-leader-C3rsjUjA.js} +1 -1
- package/dist/ui/assets/{tray-leave-runtime-CQXAePRr.js → tray-leave-runtime-BcynwR81.js} +1 -1
- package/dist/ui/assets/{tray-runtime-config-CdGCS5ij.js → tray-runtime-config-uT8n-bhV.js} +1 -1
- package/dist/ui/assets/{tray-sidecar-BK4X5gHH.js → tray-sidecar-Cv9tMmdt.js} +1 -1
- package/dist/ui/assets/{turn-journal-Bs0f1xVJ.js → turn-journal-D-4ODSvZ.js} +1 -1
- package/dist/ui/assets/{upgrade-detection-AlkgZXGy.js → upgrade-detection-BlJcBVzi.js} +1 -1
- package/dist/ui/assets/{upskill-lick-skip-VYCXh17R.js → upskill-lick-skip-DjF0bJdQ.js} +1 -1
- package/dist/ui/assets/{voice-reply-DE74ddGy.js → voice-reply-DIIIZYai.js} +1 -1
- package/dist/ui/assets/wc-attach-DJ0Fkabv.js +13 -0
- package/dist/ui/assets/{wc-browser-D_EHo2B_.js → wc-browser-JGWqtFMD.js} +1 -1
- package/dist/ui/assets/{wc-computers-CHVpBPWH.js → wc-computers-9ZIUJZ_0.js} +1 -1
- package/dist/ui/assets/{wc-detached-BT3r3qtt.js → wc-detached-B_EqDI_e.js} +1 -1
- package/dist/ui/assets/{wc-extension-Cet_eFYg.js → wc-extension-DvB8B2eR.js} +2 -2
- package/dist/ui/assets/wc-follower-DirKNNKd.js +17 -0
- package/dist/ui/assets/wc-follower-oauth-CmPQI9r7.js +5 -0
- package/dist/ui/assets/{wc-gelatiere-CsV-a3tv.js → wc-gelatiere-CNMtGFnh.js} +1 -1
- package/dist/ui/assets/wc-live-Cnwth3gF.js +427 -0
- package/dist/ui/assets/wc-nav-BtpwKT3F.js +2 -0
- package/dist/ui/assets/{wc-onboarding-ClJKGG7w.js → wc-onboarding-CMqXuHAF.js} +2 -2
- package/dist/ui/assets/{wc-permissions-Dx6_7yws.js → wc-permissions-D0noVnzr.js} +3 -3
- package/dist/ui/assets/{wc-permissions-providers-wSXekwkO.js → wc-permissions-providers-DwX67umy.js} +2 -2
- package/dist/ui/assets/{wc-placeholder-wz1P9kKJ.js → wc-placeholder-BYDPnffr.js} +3 -3
- package/dist/ui/assets/{wc-secret-request-uyvmg8ez.js → wc-secret-request-BPq25scU.js} +1 -1
- package/dist/ui/assets/{wc-settings-B7QOBPYh.js → wc-settings-C4ArQscj.js} +3 -3
- package/dist/ui/assets/{wc-shell-CDPFVzUu.js → wc-shell-BIvWfO_D.js} +240 -235
- package/dist/ui/assets/{wc-shortcut-config-S0cBne8g.js → wc-shortcut-config-5XM5GhZn.js} +1 -1
- package/dist/ui/assets/wc-sprinkles-DcxL7Mr5.js +2 -0
- package/dist/ui/assets/{wc-transcript-export-DKUtO_Ml.js → wc-transcript-export-D1mWHlgn.js} +2 -2
- package/dist/ui/assets/wc-tray-J5wALVKi.js +5 -0
- package/dist/ui/assets/{wc-unit-context-CSP19OOz.js → wc-unit-context-CS4hSDi7.js} +1 -1
- package/dist/ui/assets/welcome-detection-DJpDcarv.js +1 -0
- package/dist/ui/assets/whisper-session-8ebia7af.js +2 -0
- package/dist/ui/assets/xai-grok-A-4PUiGr.js +1 -0
- package/dist/ui/assets/xai-grok-Bd7-uPOA.js +1 -0
- package/dist/ui/index.html +11 -11
- package/dist/ui/packages/webapp/index.html +11 -11
- package/package.json +2 -2
- package/dist/ui/assets/SKILL-CAjeMrDa.js +0 -1
- package/dist/ui/assets/SKILL-DYIL6DC-.js +0 -1
- package/dist/ui/assets/__vite-browser-external-C-cVeSv_.js +0 -1
- package/dist/ui/assets/account-store-DySOM26M.js +0 -1
- package/dist/ui/assets/adobe-DZRGIa4d.js +0 -1
- package/dist/ui/assets/api-endpoint-3qEcn7BY.js +0 -1
- package/dist/ui/assets/api-endpoint-DGxXvrur.js +0 -1
- package/dist/ui/assets/auto-mount-table-rytW5wPV.js +0 -1
- package/dist/ui/assets/boot-stall-overlay-Pxp4nHfq.js +0 -1
- package/dist/ui/assets/float-topology-BYFyBtfs.js +0 -1
- package/dist/ui/assets/frozen-archive-writer-QkV6dExt.js +0 -8
- package/dist/ui/assets/fs-CCpQF0G9.js +0 -1
- package/dist/ui/assets/fs-D2K9G9FZ.js +0 -2
- package/dist/ui/assets/gelatiere-store-D9sgKnzt.js +0 -1
- package/dist/ui/assets/github-B5JyqLNQ.js +0 -2
- package/dist/ui/assets/github-C9ML_II8.js +0 -1
- package/dist/ui/assets/jsh-executor-BjHZP-Fb.js +0 -18
- package/dist/ui/assets/live-session-snapshot-CXgNHHwJ.js +0 -1
- package/dist/ui/assets/main-DfK3SKJC.js +0 -22
- package/dist/ui/assets/memory-curation-seam-DOVN8aTj.js +0 -1
- package/dist/ui/assets/memory-v2-flag-b3sGLRsR.js +0 -1
- package/dist/ui/assets/mount-picker-popup--ijSfN8u.js +0 -1
- package/dist/ui/assets/oauth-DR6XMm1M.js +0 -1
- package/dist/ui/assets/oauth-bootstrap-Cpk_Xn8-.js +0 -2
- package/dist/ui/assets/oauth-service-DLGjPRxS.js +0 -1
- package/dist/ui/assets/openai-codex-C_8CRhI9.js +0 -1
- package/dist/ui/assets/openai-codex-Ddf7u6Ce.js +0 -1
- package/dist/ui/assets/opfs-mount-BN5U6fN-.js +0 -2
- package/dist/ui/assets/panel-rpc-handlers-B3VUxGLz.js +0 -2
- package/dist/ui/assets/provider-DCXgj7GO.js +0 -2
- package/dist/ui/assets/provider-DjS4x4zP.js +0 -1
- package/dist/ui/assets/provider-store-access-Buwu2W4Q.js +0 -1
- package/dist/ui/assets/provider-store-access-C7o0o9Kn.js +0 -1
- package/dist/ui/assets/providers-OIk249yO.js +0 -2
- package/dist/ui/assets/proxied-fetch-D6EBne5P.js +0 -1
- package/dist/ui/assets/py-realm-worker-DXmzJqJi.js +0 -244
- package/dist/ui/assets/recovery-screen-DRysJsQr.js +0 -1
- package/dist/ui/assets/remote-sprinkle-vfs-D-Wz5t8k.js +0 -1
- package/dist/ui/assets/rest-ops-DBG2rYMP.js +0 -1
- package/dist/ui/assets/secret-topology-CYhWCLbt.js +0 -1
- package/dist/ui/assets/session-jsonl-B7wXtsIg.js +0 -11
- package/dist/ui/assets/sidecar-repair-CWpX6fJD.js +0 -1
- package/dist/ui/assets/slicc-version-J6yPgeQ2.js +0 -1
- package/dist/ui/assets/sprinkle-manager-Hz-f5ScM.js +0 -1
- package/dist/ui/assets/state-C5hoKydi.js +0 -42
- package/dist/ui/assets/sync-sab-wire-CC30v4TL.js +0 -252
- package/dist/ui/assets/wc-attach-Bjp3_el9.js +0 -13
- package/dist/ui/assets/wc-follower-oauth-rxh8P8O7.js +0 -5
- package/dist/ui/assets/wc-follower-sM5_qy--.js +0 -17
- package/dist/ui/assets/wc-live-BwUp4-xo.js +0 -427
- package/dist/ui/assets/wc-nav-CYwCltAh.js +0 -2
- package/dist/ui/assets/wc-sprinkles-JyUvUoHY.js +0 -2
- package/dist/ui/assets/wc-tray-Cvh_bf6Q.js +0 -5
- package/dist/ui/assets/welcome-detection-Bvi-e-fv.js +0 -1
- package/dist/ui/assets/whisper-session-DAstywJN.js +0 -2
- package/dist/ui/assets/xai-grok-BEWk2qp1.js +0 -1
- package/dist/ui/assets/xai-grok-D0PHjeHl.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e='---\nname: mount\ndescription: |\n Use this whenever the user asks to mount anything — local folders, S3\n buckets, S3-compatible services (Cloudflare R2, MinIO), or Adobe da.live\n / AEM Document Authoring repos. Read this skill BEFORE deciding which\n backend to use; do NOT default to a local file picker when the user\n names a remote service. Covers credential setup with profile-namespaced\n `secret set` keys (e.g. `s3.aws.access_key_id`) or the extension Options\n page, the right `mount --source` invocation per intent, `mount info` for\n probed case/Unicode/exec-bit semantics, and common errors (EACCES on\n missing credentials, EBUSY on concurrent edits, EFBIG on oversized files).\nallowed-tools: bash, read_file, write_file, edit\n---\n\n# Mount\n\nThe `mount` shell command bridges remote storage into the VFS. After mounting, `read_file`, `write_file`, `edit`, and `bash` (with `cat`, `ls`, etc.) all work against the remote source as if it were a local directory. Four backends:\n\n| Backend | Source URI | Auth |\n| ------- | ----------------------------- | ------------------------------------------------------ |\n| Local | (no `--source`) | OS file picker — cone-only, fails in scoops |\n| S3 | `s3://<bucket>[/<prefix>]` | Profile-namespaced secrets (`s3.<profile>.*`) |\n| DA | `da://<org>/<repo>[/<path>]` | Adobe IMS bearer (reuses the Adobe LLM provider login) |\n| AEM | `aem://<org>/<site>[/<path>]` | Adobe IMS bearer (same login as DA) |\n\n## Choosing a backend from user intent\n\nWhen the user asks to "mount X", read the request literally before defaulting to local:\n\n| User says | Use this backend |\n| -------------------------------------------------- | ------------------------------------------------------- |\n| "mount my Documents folder" / "mount /tmp" | Local — `mount /mnt/documents` |\n| "mount this S3 bucket: s3://my-bucket/foo" | S3 — `mount --source s3://my-bucket/foo /mnt/s3` |\n| "mount this R2 bucket" | S3 with a custom-endpoint profile (R2 is S3-compatible) |\n| "mount the AEM DA repo for org/site" | DA — `mount --source da://<org>/<site> /mnt/da` |\n| "mount this Adobe DA project" / "mount da.live" | DA |\n| "mount this Helix 6 site" / "mount the Source Bus" | AEM — `mount --source aem://<org>/<site> /mnt/aem` |\n| "mount this S3-compatible storage" (MinIO, etc.) | S3 with a custom-endpoint profile |\n\nIf the URL scheme is `s3://`, `da://`, or `aem://`, the choice is unambiguous — don\'t ask. If the user gives a hostname or describes a service without a URL, ask one specific clarifying question (e.g. "Is this the AEM Document Authoring service at da.live, or a different system?") rather than offering a menu of generic options.\n\n**Don\'t default to local when the user mentions a remote service name.**\n\n### DA or AEM? You don\'t have to know — but read the mount output\n\nA site upgraded to the Helix 6 architecture keeps its `da.live` authoring UI and its `<org>/<site>` name, but its content moves to the Source Bus on `api.aem.live`. `da://` handles this for you: it probes the site config before mounting and re-routes to the Source Bus when that is where the content lives, printing a note on stderr. So `mount --source da://<org>/<site>` is always safe to reach for.\n\nTwo things follow:\n\n- **Read the stderr note.** `mount: <org>/<site> is on Helix 6 …` means the mount landed on `aem://` — that is correct, not a warning to work around.\n- **A `da://` mount can now fail with `could not determine the content source`.** That means the site config was unreadable (usually: no Adobe login), not that the site is missing. Fix the login, or pass `--backend da` / `--backend aem` if you already know which store holds the content. Don\'t retry the same command hoping for a different answer.\n\n## Setting up credentials before the first mount\n\n### S3 / R2 / MinIO\n\nS3 mounts read credentials from profile-namespaced secrets. Set them via the `secret` command before mounting. The agent never sees real secret values; only the server-side sign-and-forward handler does.\n\n```bash\n# AWS S3 (default profile)\nsecret set s3.default.access_key_id AKIA... --domain "*.amazonaws.com"\nsecret set s3.default.secret_access_key ... --domain "*.amazonaws.com"\nsecret set s3.default.region us-east-1 --domain "*.amazonaws.com"\n\n# Cloudflare R2 (uses a custom endpoint, requires path-style addressing for some setups)\nsecret set s3.r2.access_key_id ... --domain "*.r2.cloudflarestorage.com"\nsecret set s3.r2.secret_access_key ... --domain "*.r2.cloudflarestorage.com"\nsecret set s3.r2.endpoint https://<account>.r2.cloudflarestorage.com --domain "*.r2.cloudflarestorage.com"\n# Optional — only set this if R2 returns "Bucket name was not in expected format" at first read:\nsecret set s3.r2.path_style true --domain "*.r2.cloudflarestorage.com"\n```\n\nPer-profile keys: `access_key_id` and `secret_access_key` are required; `region` (default `us-east-1`), `endpoint` (custom host for R2/MinIO), `session_token` (for STS), and `path_style` (`"true"` for path-style addressing) are optional.\n\nIn **CLI / Electron mode** secrets live in `~/.slicc/secrets.env` (or macOS Keychain via swift-server). In **extension mode** they live in `chrome.storage.local` and the `secret` command writes to it directly.\n\n### Adobe da.live and AEM Source Bus\n\nDA and AEM mounts both use the Adobe IMS bearer token from the existing Adobe LLM provider — there are no DA-specific secrets to set. **If the user has not logged into the Adobe LLM provider yet, the first mount will fail with `EACCES`. Tell them to log in via Settings → Providers → Adobe (or run `oauth-token adobe`) first.**\n\n## Mounting\n\n```bash\n# Local (interactive picker, cone only)\nmount /mnt/local\n\n# S3 — bucket + optional prefix\nmount --source s3://my-bucket /mnt/s3\nmount --source s3://my-bucket/site --profile aws /mnt/aws\n\n# Cloudflare R2 — same s3:// scheme, different profile (custom endpoint)\nmount --source s3://my-r2-bucket/path --profile r2 /mnt/r2\n\n# Adobe da.live — org + repo (probes the site config, re-routes if Helix 6)\nmount --source da://my-org/my-repo /mnt/da\n\n# AEM Helix 6 Source Bus — org + site, no probe needed\nmount --source aem://my-org/my-site /mnt/aem\n```\n\nUseful flags:\n\n- `--profile <name>` — selects which `s3.<profile>.*` keys to use (S3 only). Defaults to `default`.\n- `--backend <da|aem>` — force the Adobe backend instead of probing the site config. Reach for it only when the probe fails or you know it is wrong.\n- `--no-probe` — skip the mount-time `HEAD bucket` / `GET /list` probe. Use when you want the mount to land even if the source is temporarily unreachable; first read/write will surface any auth errors instead. It does **not** skip the `da://` content-source probe.\n- `--max-body-mb <n>` — override the per-mount body-size limit. Defaults: S3 25 MB, DA/AEM 5 MB. Files exceeding this throw `EFBIG` before bytes flow.\n\n## Lifecycle\n\n```bash\nmount list # show all active mounts\nmount --list # same as `mount list` (`-l` also works)\nmount info /tmp # probe case / Unicode / exec-bit / name semantics\nmount info --json /mnt/kb # same report as JSON (the programmatic form)\nmount unmount /mnt/r2 # tear down (cache stays for next mount within TTL)\numount /mnt/r2 # alias for `mount unmount` (same flags, same exit codes)\nmount unmount --clear-cache /mnt/r2 # tear down + drop cached listings/bodies\nmount refresh /mnt/r2 # re-walk the source and diff against cache\nmount refresh --bodies /mnt/r2 # also conditionally re-fetch changed bodies\n```\n\n`umount <path>` is a plain alias for `mount unmount <path>` — same parser, same `--clear-cache`, same exit codes; only the error prefix says `umount:`. Use whichever spelling the user typed. Unmounting a path that is not mounted is a no-op (not an error) under both.\n\n### `mount info` — ask before assuming names are unique\n\nTwo mounts in one runtime can disagree about identity. MEASURED: `/tmp` is case-sensitive and byte-exact; a macOS APFS hostfs mount (`/mnt/kb`) is case- **and** Unicode-normalization-insensitive. `ls` / `exists` / `read_file` will resolve `SLICC.md` to `Slicc.md` on the latter, and an NFC spelling of an NFD-stored name. **Do not discover this by renaming.** A rename between two names the volume considers equal has truncated files (#3107). Ask instead:\n\n```bash\nmount info --json /mnt/kb\n```\n\nThe report is probed (scratch file, stat back, always cleaned up), not declared from `diskutil`. Fields: `caseSensitivity`, `unicodeNormalization` (`byte-exact` vs `insensitive`), `unicodeStorage` (`nfc` / `nfd` / `as-written`), `executableBit`, `namesRoundTripByteExact`, `maxFilenameLength`, `writable`, `hostBacked`. If `unicodeNormalization` is `insensitive` or `caseSensitivity` is `insensitive`, compare names by folding case and NFC — do not treat a case/Unicode mismatch as a missing file, and do not rename one spelling onto the other.\n\nBuilt-in VFS paths such as `/tmp` support executable bits through `chmod`.\nMounted sources report the capability their bridge implements; the host disk\'s\ncapabilities alone do not imply that the mounted metadata operation is supported.\n\n`mount refresh` prints a structured summary: `Refreshed /mnt/r2: +2 -1 ~3 (47 unchanged, 0 errors)`. Use it after you know the remote changed externally and you want the local view to catch up before the 30 s TTL expires.\n\n## Index state and bounds (`mount list`)\n\nEach mount is indexed in the background for fast file discovery and listings; `mount list` shows each mount\'s index state. The walk is bounded — defaults (raised 10×): max directory depth **400**, max total entries **2,000,000**. Two env vars override them: `SLICC_MOUNT_INDEX_MAX_DEPTH` and `SLICC_MOUNT_INDEX_MAX_ENTRIES` (an invalid value falls back to the default with a warning).\n\nWhen a bound is hit the index is **skipped** (reads still work via the slow fallback) and `mount list` shows a distinct cause, so advise the right remedy:\n\n- `directory nesting exceeded the depth limit` → raise `SLICC_MOUNT_INDEX_MAX_DEPTH` or unmount.\n- `mounted tree is too large` → raise `SLICC_MOUNT_INDEX_MAX_ENTRIES` or unmount (this is **not** a cycle).\n- `self-referential mount cycle detected` → a real, confirmed cycle; unmount it.\n- `index error: <message>` → any other indexing failure.\n\nDon\'t call a large or deep mount "cyclic" — only `self-referential mount cycle detected` means a true self-reference.\n\n## Reading and writing once mounted\n\nTreat the mount path like any other VFS directory:\n\n```bash\nls /mnt/da\nread_file /mnt/da/index.html\nwrite_file /mnt/da/new-page.html "<html>..."\nedit /mnt/da/index.html # via the standard edit tool\nrm /mnt/da/old.html\n```\n\nReads and writes use TTL + ETag caching (30 s default). Reads are zero-RTT within TTL. Writes use `If-Match` / `If-None-Match: *` for conflict detection.\n\nOn an AEM (Source Bus) mount there are no ETags — the API exposes only `last-modified` — so conflict detection uses modification time and only covers files you read first. A blind `write_file` to a path you never read will overwrite whatever is there. Read before you write on `aem://` mounts.\n\n## Common error patterns\n\n| Error | What it means |\n| ---------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `mount: probe failed for s3://… — profile \'aws\' missing required field \'access_key_id\'.` | The user hasn\'t set credentials yet. Walk them through `secret set s3.<profile>.*`. |\n| `EACCES: s3 access denied` | Wrong credentials, wrong region, or the bucket policy denies the user. |\n| `EACCES: da access denied` / `EACCES: aem access denied` | IMS token expired or user not authed against the Adobe provider. |\n| `mount: could not determine the content source for da://…` | The site config probe failed — usually no Adobe login. Fix the login, or pass `--backend da` / `--backend aem`. Don\'t just retry. |\n| `EBUSY: remote modified since last read — re-read and retry` | Concurrent writer changed the file. Re-read with `read_file` and retry the edit. |\n| `EFBIG: body exceeds maxBodyBytes` | File is over the per-mount size limit (S3 25 MB, DA/AEM 5 MB). Use shell tools (`aws s3 cp`) for very large files instead, or pass `--max-body-mb <n>` at mount time. |\n| `mount: cannot mount local directories from a scoop (no UI).` | Local mounts need a user gesture. Either ask the cone to mount, or use S3/DA which work in scoops. |\n| `EXDEV: cannot create a symlink across a mount boundary` | `ln -s /mnt/… <vfs-path>` cannot create a real link (mount backends have no symlink inode). Use the mount path, or copy. Do not retry — it will not become a link. |\n\n## When asked to "explore" a mounted DA or S3 source\n\nAfter mounting, prefer `bash: ls` over `read_file` for navigation — it\'s instant within the TTL window because the listing is cached. Only `read_file` files you actually intend to read; every read is a network round-trip on the first call.\n\nFor DA specifically: the `/list` endpoint doesn\'t include file sizes, so `ls -l` triggers one HEAD per file the first time, then caches. Subsequent `ls -l` within 30 s is free.\n\nFor AEM: listings _do_ carry size and mtime, so `ls -l` costs one listing and no per-file round-trips. The size shown is the stored (compressed) size until the file has been read, so it can be well under what `read_file` returns. Empty folders don\'t exist on the Source Bus — a directory disappears when its last file is deleted.\n\n## Don\'t\n\n- Don\'t suggest the user install a separate AWS CLI / da.live SDK — `mount` is the integration point.\n- Don\'t try to `cd` into a remote mount before mounting; `bash`\'s working directory is independent of mount setup.\n- Don\'t ask "do you have credentials" if the user has already named a service — try the mount first, surface the actionable error from the probe, and walk them through the specific `secret set` commands.\n- Don\'t work around a `could not determine the content source` failure by switching to `--no-probe` — that flag doesn\'t skip the content-source probe, and the failure is telling you the login is missing.\n- Don\'t fall back to a local mount if the user mentioned a remote service. Default to clarifying which remote backend, not which directory to pick.\n- Don\'t rename a file to change only case or Unicode form until `mount info` says the volume is byte-exact. On an insensitive mount that is the #3107 truncate.\n- Don\'t `ln -s` a mounted path onto `/tmp`, `/shared`, or any other VFS path to alias it. That is `EXDEV` (#3311); use the mount path or copy.\n';export{e as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e="---\nname: memory\ndescription: |\n Use this when the user asks what SLICC remembers, why a remembered fact is\n missing or stale, whether memory curation ran, to re-run curation for an\n archived session, or to consolidate a bloated memory file. Covers the\n `memory` shell command (`show`, `status`, `log`, `curate`, `dream`), the\n per-cone memory files, and the curation ledger in /sessions/index.json.\n Requires the memory-v2 feature flag for everything except `memory status`.\nallowed-tools: bash\n---\n\n# memory — inspect and manage durable cone memory\n\nDurable memory is one markdown file per cone — `/workspace/CLAUDE.md` for the primary cone, `/cones/<folder>/CLAUDE.md` for extra cones. Agents write these files only through the `memory_write` tool, which enforces the budget (over budget, a write must shrink the file) and reports the remaining room; other writers are refused. After a chat freezes, a memory-curator scoop rewrites that file from the archived session; `/sessions/index.json` is the per-archive ledger of whether that pass succeeded (`memoryCuratedAt`), failed (`memoryFailed`), is still owed (`memoryPending`), or was skipped by the user (`memorySkipped`).\n\n## Usage\n\n```bash\nmemory show [--cone <folder>] # the cone's memory file, verbatim\nmemory status [--json] [--check] # files, budget, curation tally, health\nmemory log [--limit N] # per-archive ledger, newest first\nmemory curate [--archive <file>] [--cone <folder>] # run a curator pass now\nmemory dream [--cone <folder>] [--all] [--wait] # consolidate memory (dreamer pass)\n```\n\n## When to reach for it\n\n- \"What do you remember about me / this project?\" → `memory show`.\n- A fact you expected to be remembered is missing → `memory log` to see whether the session that established it was ever curated; `memory status --check` for systemic failures.\n- After a failed curation (`memoryFailed` in the log) → fix the cause if visible (usually a missing provider or a timeout), then `memory curate --archive <that-file>`.\n- The memory file has grown duplicated, contradictory, or over budget → `memory dream` (add `--wait` to see the dreamer's report; `--all` for every cone with a memory file). The gelatiere's nightly already runs `memory dream --all`, so reach for this manually only when it cannot wait.\n- Extra cones keep separate memory: pass `--cone <folder>` to `show`, `curate`, and `dream`. The folder must exist (`cone`, or a `/cones/<folder>`); `curate` without it targets the cone the archive was frozen from.\n\n## Reading `memory status`\n\n- **Budget** grows logarithmically with the archived-session count; the curator is told to stay under it.\n- **Curation tally** counts index entries by ledger state: curated / failed / pending / skipped / unmarked (pre-ledger or freshly frozen).\n- **`--check`** exits non-zero on the two lying-memory shapes: any archive whose last curation attempt failed, or archives reporting success while the primary memory file is missing or empty. A clean run exits 0.\n- **`Scheduled:`** shows the runtime's own health check — the kernel runs the same checks ~90s after boot and daily without being asked, persisting the numbers to `/sessions/.curation/health.json`. If that line says `never ran` long after boot, or names failures, the memory system needs attention even if nobody asked about it.\n\n## Notes\n\n- `memory curate` runs the exact pass the session freezer runs (snapshot → curator scoop → three-way merge), so concurrent edits to the memory file merge instead of being clobbered. It can take several minutes; the curator's closing report is printed when it lands.\n- `memory dream` reads no session archive — the dreamer consolidates the memory file itself under the same `/etc/MEMORY.md` instructions as curation (its own `dreamTimeoutSeconds` bound), through the same staged draft and merge. Detached by default; the outcome lands in `/sessions/.curation/dream-<date>-<cone>.md/status.json`.\n- When consolidation cannot fit everything, the dreamer moves reference knowledge into the shared wiki at `/shared/wiki/` (schema: `/shared/wiki/WIKI.md`; browse it with the `wiki` skill) and leaves a pointer line in the memory file.\n- The command does not edit the ledger itself; a manual pass on a still-pending archive is reconciled by the boot catch-up through the bridge's receipt.\n- Everything except `status` requires the **Memory v2** flag (Settings → Experimental).\n";export{e as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./py-realm-worker-DXmzJqJi.js";var t=e(((e,t)=>{t.exports={}}));export default t();
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./logger-LESFN7Hj.js";import{n,r}from"./panel-rpc-DVS1uJpt.js";import{n as i,o as a,t as o}from"./providers-CoLEjgu1.js";import"./proxied-fetch-D6EBne5P.js";import{o as s,t as c}from"./api-endpoint-3qEcn7BY.js";import{i as l,n as ee,r as u}from"./compat-uEPf6-XW.js";import{a as d}from"./core-NCt3m1n7.js";import{t as f}from"./secrets-bridge-client-nOf1jubu.js";import{i as te,r as ne,t as re}from"./bedrock-camp-compat-99DjWBHV.js";import{s as ie}from"./claude-model-version-ceOteQ2f.js";const ae=`slicc_oauth_extra_domains`;function p(e){try{let t=e.getItem(ae);if(!t)return{};let n=JSON.parse(t);if(typeof n!=`object`||!n||Array.isArray(n))return{};let r={};for(let[e,t]of Object.entries(n)){if(typeof e!=`string`||!Array.isArray(t))continue;let n=t.filter(e=>typeof e==`string`&&e.length>0);n.length>0&&(r[e]=n)}return r}catch{return{}}}function oe(e,t){try{e.setItem(ae,JSON.stringify(t))}catch(e){throw Error(`Failed to persist OAuth extras (localStorage quota exceeded?): ${e instanceof Error?e.message:String(e)}`)}}function se(e,t){let n={input:0,output:0,cacheRead:0,cacheWrite:0},r=ie(e);if(!r)return n;let i;for(let e of t.values()){let t=ie(e.id);!t||t.family!==r.family||(!i||t.major>i.major||t.major===i.major&&t.minor>i.minor)&&(i={major:t.major,minor:t.minor,cost:e.cost})}return i?.cost??n}const ce=t(`model-policy`),m=`/etc/models`;function h(){return{sections:{}}}function le(e){let t=e.indexOf(`#`);return(t===-1?e:e.slice(0,t)).trim()}function ue(e){let t=h();if(typeof e!=`string`)return t;let n=null;for(let r of e.split(/\r?\n/)){let e=le(r);if(!e)continue;let i=/^\[([^\]]+)\]$/.exec(e);if(i){n=i[1].trim(),t.sections[n]??=[];continue}if(n===null){ce.warn(`model policy entry before any [provider] section — ignored`,{entry:e});continue}let a=e.startsWith(`-`),o=a?e.slice(1).trim():e,s=o.indexOf(`:`);if(s<=0||s===o.length-1){ce.warn(`model policy entry is not provider:model — ignored`,{entry:e});continue}t.sections[n].push({providerId:o.slice(0,s).trim(),modelId:o.slice(s+1).trim(),deny:a})}return t}function g(e,t,n){return e.providerId===t?e.modelId===`*`||e.modelId===n:!1}function de(e,t){return e.sections[t]??[]}function fe(e,t,n,r){return de(e,t).some(e=>e.deny&&g(e,n,r))}function pe(e,t,n,r){let i=de(e,t);return i.some(e=>e.deny&&g(e,n,r))?!1:n===t||i.some(e=>!e.deny&&g(e,n,r))}let me=h();function he(e){me=e}function _(){return me}function ge(e,t,n){return`add \`${t}:${n}\` (or \`${t}:*\`) under \`[${e}]\` in ${m}`}var _e=e({ACCOUNTS_KEY:()=>b,__test__:()=>Ce,addAccount:()=>P,applyProviderDefaults:()=>Ee,clearAllSettings:()=>lt,clearApiKey:()=>it,clearBaseUrl:()=>st,clearSelectedProvider:()=>tt,ensureOAuthMaskReplica:()=>qe,exportProviders:()=>ct,getAccounts:()=>M,getAllAvailableModels:()=>Ae,getAllExtraOAuthDomains:()=>Fe,getAlternativeModelProviders:()=>je,getApiKey:()=>nt,getApiKeyForProvider:()=>B,getApiVersionForProvider:()=>Ze,getAvailableProviders:()=>w,getBaseUrl:()=>at,getBaseUrlForProvider:()=>V,getDeploymentForProvider:()=>Xe,getExtraOAuthDomains:()=>Me,getOAuthAccountInfo:()=>k,getProviderConfig:()=>E,getProviderModels:()=>O,getRawApiKeyForProvider:()=>z,getSelectedModelId:()=>H,getSelectedProvider:()=>U,isModelHiddenFromPicker:()=>j,isUsableOAuthMaskReplica:()=>L,logoutOAuthAccount:()=>Re,maskOAuthTokenWithRetry:()=>ze,migrateLegacyAuthOnlySelection:()=>xe,modelRunsOnProvider:()=>mt,persistOAuthMaskViaServiceWorker:()=>R,policyVisible:()=>ke,providerOffersLlmModels:()=>T,removeAccount:()=>F,resolveCurrentModel:()=>q,resolveModelById:()=>K,resolveModelByShorthand:()=>ht,resolveModelIdForScoop:()=>St,resolveModelSelectionForScoop:()=>Z,saveOAuthAccount:()=>Ye,setApiKey:()=>rt,setBaseUrl:()=>ot,setExtraOAuthDomains:()=>Ne,setExtraOAuthDomainsAsync:()=>Pe,setSelectedModelId:()=>Qe,setSelectedProvider:()=>et});const v=ee,y=u,b=`slicc_accounts`,x=`selected-model`,ve=[`slicc_provider`,`slicc_api_key`,`slicc_base_url`,`anthropic_api_key`,`api_provider`,`azure_resource`,`bedrock_region`],ye=new Set([`github`]);function S(e){let t;try{t=l()}catch{return!1}return t.includes(e)&&!a(e)}let C=!1;function be(){if(!C){C=!0;for(let e of ve)try{localStorage.removeItem(e)}catch{}xe()}}function xe(){try{let e=localStorage.getItem(x);if(e){let t=e.indexOf(`:`);if(t>0){let n=e.slice(0,t);(ye.has(n)||S(n))&&localStorage.removeItem(x)}}}catch{}try{let e=localStorage.getItem(b);if(!e)return;let t=JSON.parse(e);if(!Array.isArray(t))return;let n=t.filter(e=>!(typeof e==`object`&&e&&typeof e.providerId==`string`&&S(e.providerId)));n.length!==t.length&&localStorage.setItem(b,JSON.stringify(n))}catch{}}function Se(){C=!1}const Ce={_resetLegacyCleanup:Se};function w(){let e=l().filter(a),t=i();return[...new Set([...e,...t])].filter(e=>!o(e)?.hidden)}function T(e){try{if(O(e).length>0)return!0}catch{}try{if(u(e).length>0)return!0}catch{}let t=o(e);return!!(t?.modelOverrides&&Object.keys(t.modelOverrides).length>0)}function we(e,t){try{if(O(e).some(e=>e.id===t))return!0}catch{}try{if(u(e).some(e=>e.id===t))return!0}catch{}let n=o(e);return!!(n?.modelOverrides&&Object.hasOwn(n.modelOverrides,t))}function E(e){return o(e)||{id:e,name:e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `),description:`${e} provider`,requiresApiKey:!0,requiresBaseUrl:!1}}function D(e,t){t.context_window!==void 0&&(e.contextWindow=t.context_window),t.max_tokens!==void 0&&(e.maxTokens=t.max_tokens),t.reasoning!==void 0&&(e.reasoning=t.reasoning),t.input!==void 0&&(e.input=t.input),t.cost!==void 0&&(e.cost=t.cost,e.inputCost=t.cost.input,e.outputCost=t.cost.output,e.cacheReadCost=t.cost.cacheRead,e.cacheWriteCost=t.cost.cacheWrite),t.compat!==void 0&&(e.compat={...e.compat??{},...t.compat}),t.thinkingLevelMap!==void 0&&(e.thinkingLevelMap={...e.thinkingLevelMap??{},...t.thinkingLevelMap})}function O(e){try{if(e===`bedrock-camp`){let e=re(V(`bedrock-camp`));return y(`amazon-bedrock`).filter(t=>te(t,e)).map(e=>({...e,api:`bedrock-camp-converse`,provider:`bedrock-camp`,reasoning:e.reasoning===!0&&ne(e)}))}let t=E(e);if(t.getModelIds){let n;try{n=t.getModelIds()}catch(t){return A.error(`Provider getModelIds callback failed`,{providerId:e,error:t instanceof Error?t.message:String(t)}),[]}let r=new Map;for(let e of l())try{for(let t of y(e))r.set(t.id,t)}catch{}return n.map(n=>{let i=n.api===`openai`?`openai`:`anthropic`,a=`${e}-${i}`,o=r.get(n.id),s;if(o)s={...o,api:a,provider:e};else if(s=W(e,n.id,``,a),n.name&&(s.name=n.name),i===`anthropic`){let e=se(n.id,r);s.cost=e,s.inputCost=e.input,s.outputCost=e.output,s.cacheReadCost=e.cacheRead,s.cacheWriteCost=e.cacheWrite}let c=t.modelOverrides?.[n.id];return c&&D(s,c),D(s,n),s})}if(t.isOAuth){let n=y(`anthropic`),r=`${e}-anthropic`;return n.map(n=>{let i={...n,api:r,provider:e},a=t.modelOverrides?.[n.id];return a&&D(i,a),i})}return y(e===`azure-ai-foundry`?`anthropic`:e)}catch(t){return A.error(`Failed to load models`,{providerId:e,error:t instanceof Error?t.message:String(t)}),[]}}function k(e){let t=M().find(t=>t.providerId===e);if(!t?.accessToken)return null;let n=!!t.tokenExpiresAt&&Date.now()>t.tokenExpiresAt-6e4;return{token:t.accessToken,maskedValue:t.maskedValue,expiresAt:t.tokenExpiresAt,userName:t.userName,userAvatar:t.userAvatar,scopes:t.scopes,expired:n}}const Te=Object.assign({})[`/packages/webapp/providers.json`]??[],A=t(`provider-settings`);function Ee(e=Te){if(e.length===0||M().length>0)return;let t=new Set(w());for(let n of e)if(!(!n.providerId||!n.apiKey)){if(!t.has(n.providerId)){A.warn(`Unknown provider "${n.providerId}" in providers.json — skipping`);continue}P(n.providerId,n.apiKey,n.baseUrl)}let n=e.find(e=>e.providerId&&e.apiKey&&t.has(e.providerId));n?.model&&!localStorage.getItem(x)&&localStorage.setItem(x,`${n.providerId}:${n.model}`)}const De=[/haiku/i];function j(e){return De.some(t=>t.test(e))}function Oe(e){return e.filter(e=>!j(e.id))}function ke(e,t){let n=Q();if(n===null)return e;let r=_();return e.filter(e=>!fe(r,n,t,e.id))}function Ae(){let e=M();if(e.length===0)return[];let t=new Map;for(let n of e){if(t.has(n.providerId))continue;let e=E(n.providerId);if(e.hidden||S(n.providerId))continue;let r=ke(Oe(O(n.providerId)),n.providerId);if(r.length===0)continue;let i={providerId:n.providerId,providerName:e.name,models:r};t.set(n.providerId,i)}return[...t.values()]}function je(e){return Ae().map(e=>e.providerId).filter(t=>t!==e)}function M(){be();let e=localStorage.getItem(b);if(!e)return[];try{let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`object`&&!!e&&typeof e.providerId==`string`&&typeof e.apiKey==`string`):[]}catch{return[]}}function Me(e){return p(localStorage)[e]??[]}function Ne(e,t){let n=p(localStorage),r=t.map(e=>e.trim()).filter(e=>e.length>0);r.length===0?delete n[e]:n[e]=r,oe(localStorage,n)}async function Pe(e,t){if(r()){Ne(e,t);return}let i=n();if(!i)throw Error(`setExtraOAuthDomainsAsync: no DOM and no panel-rpc client — cannot persist to page localStorage`);let{storeAfter:a}=await i.call(`oauth-extras-set`,{providerId:e,domains:t});try{oe(localStorage,a)}catch(t){A.warn(`worker-shim mirror failed after successful page write — reload to refresh`,{providerId:e,error:t instanceof Error?t.message:String(t)})}}function Fe(){return p(localStorage)}function Ie(e){localStorage.setItem(b,JSON.stringify(e))}async function N(e){if(r()){Ie(e);return}let t=n();if(!t)throw Error(`saveAccountsAsync: no DOM and no panel-rpc client — cannot persist to page localStorage`);let i=JSON.stringify(e),{storedJson:a}=await t.call(`save-oauth-accounts`,{accountsJson:i});try{localStorage.setItem(b,a)}catch(e){A.warn(`worker-shim mirror failed after successful page write — reload to refresh`,{error:e instanceof Error?e.message:String(e)})}}function P(e,t,n,r,i){let a=M().filter(t=>t.providerId!==e),o={providerId:e,apiKey:t};n&&(o.baseUrl=n),r&&(o.deployment=r),i&&(o.apiVersion=i),a.push(o),Ie(a)}async function Le(e){let t=d();try{if(t===`extension-direct`){let t=await new Promise(t=>{chrome.runtime.sendMessage({type:`secrets.delete`,name:`oauth.${e}.token`},n=>{chrome.runtime.lastError&&A.error(`SW secrets.delete transport failed`,{providerId:e,error:chrome.runtime.lastError.message}),t(n??{})})});t.error&&A.error(`SW secrets.delete returned error`,{providerId:e,error:t.error})}else if(t===`extension-delegate`){let t=await f(`secrets.delete`,{name:`oauth.${e}.token`});t?.error&&A.error(`Bridge secrets.delete returned error`,{providerId:e,error:t.error})}else if(t!==`connect`){let t=await fetch(s(`/api/secrets/oauth/${e}`),{method:`DELETE`,headers:c()});!t.ok&&t.status!==404&&A.warn(`OAuth replica DELETE non-ok`,{providerId:e,status:t.status})}}catch(n){A.error(`OAuth replica removal failed`,{providerId:e,topology:t,error:n instanceof Error?n.message:String(n)})}}async function F(e){let t=M().find(t=>t.providerId===e),n=E(e);t&&n?.isOAuth&&await Re(e),await Le(e),await N(M().filter(t=>t.providerId!==e));let r=localStorage.getItem(x)??``,i=r.indexOf(`:`);i>0&&r.slice(0,i)===e&&localStorage.removeItem(x)}async function Re(e){let t=M().find(t=>t.providerId===e);if(!t)return;let n=E(e);if(n?.isOAuth){if(n.onOAuthLogout)try{await n.onOAuthLogout()}catch(t){A.warn(`onOAuthLogout failed`,{providerId:e,error:t instanceof Error?t.message:String(t)})}if(n.getOAuthLogoutUrl){let r=n.getOAuthLogoutUrl(t);if(r){let{openIdpLogoutUrl:t}=await import(`./oauth-service-DLGjPRxS.js`);await t(r).catch(t=>{A.warn(`IdP logout popup failed`,{providerId:e,error:t instanceof Error?t.message:String(t)})})}}await N(M().map(t=>t.providerId===e?{providerId:t.providerId,apiKey:``,baseUrl:t.baseUrl,userName:t.userName,userAvatar:t.userAvatar,loggedOut:!0}:t)),await Le(e)}}async function ze(e,t={}){let n=Math.max(1,t.attempts??3),r=t.delayMs??150,i=t.sleep??(e=>new Promise(t=>setTimeout(t,e))),a;for(let t=0;t<n;t++){let o=await e();if(o.maskedValue)return{maskedValue:o.maskedValue};o.error&&(a=o.error),t<n-1&&await i(r)}return{lastError:a}}const Be=`access token rotated during mask write`;function I(e,t,n,r){let i=r.find(t=>t.providerId===e);return i?.accessToken?i.accessToken===t?(i.maskedValue=n,{maskedValue:n}):(A.warn(`OAuth mask write raced with token rotation; discarding replica`,{providerId:e}),{error:Be}):{error:`account gone after mask write`}}function L(e,t){return!!e&&e!==t}async function R(e,t,n){let r={providerId:e.providerId,accessToken:e.accessToken,domains:e.domains.join(`,`)},{maskedValue:i,lastError:a}=await ze(()=>t.sendMaskRequest(r),n);if(!L(i,e.accessToken)){let t=i?`mask replica equals the access token`:a??`no error reported (cold SW or empty reply)`;return A.error(`OAuth mask give-up: no masked value after retries`,{providerId:e.providerId,reason:t}),{error:t}}let o=t.getAccounts(),s=I(e.providerId,e.accessToken,i,o);return s.maskedValue&&await t.saveAccounts(o),s}function Ve(e){let t=E(e).oauthTokenDomains??[],n=Me(e),r=new Set,i=[];for(let e of[...t,...n]){let t=e.toLowerCase();r.has(t)||(r.add(t),i.push(e))}return i}function He(e){return new Promise(t=>{chrome.runtime.sendMessage({type:`secrets.mask-oauth-token`,...e},n=>{chrome.runtime.lastError&&A.error(`SW mask-oauth-token transport failed`,{providerId:e.providerId,error:chrome.runtime.lastError.message});let r=typeof n==`object`&&n?n:void 0;r?.error&&A.warn(`SW mask-oauth-token returned error`,{providerId:e.providerId,error:r.error}),t(r??{})})})}function Ue(e){return f(`secrets.mask-oauth-token`,e).then(t=>(t?.error&&A.warn(`Bridge mask-oauth-token returned error`,{providerId:e.providerId,error:t.error}),t??{})).catch(t=>(A.error(`Bridge mask-oauth-token transport failed`,{providerId:e.providerId,error:t instanceof Error?t.message:String(t)}),{}))}async function We(e,t,n){let r=s(`/api/secrets/oauth-update`),i=await fetch(r,{method:`POST`,headers:c({"Content-Type":`application/json`}),body:JSON.stringify({providerId:e,accessToken:t,domains:n})});if(!i.ok)return A.warn(`OAuth replica POST non-ok`,{providerId:e,status:i.status,url:r}),{error:`OAuth replica POST HTTP ${i.status}`};let a=await i.json();if(typeof a.maskedValue!=`string`)return A.warn(`OAuth replica POST ok but missing maskedValue`,{providerId:e,url:r}),{error:`OAuth replica POST ok but missing maskedValue`};if(!L(a.maskedValue,t))return A.error(`OAuth mask replica equals the access token; refusing to persist`,{providerId:e}),{error:`mask replica equals the access token`};let o=M(),l=I(e,t,a.maskedValue,o);return l.maskedValue&&await N(o),l}async function Ge(e,t){let n=await Ke(e,t);if(n.error!==Be)return n;let r=M().find(t=>t.providerId===e)?.accessToken;return!r||r===t?n:Ke(e,r)}async function Ke(e,t){let n=Ve(e);if(n.length===0)return{error:`no oauth token domains configured`};let r=d();try{return r===`extension-direct`?R({providerId:e,accessToken:t,domains:n},{sendMaskRequest:He,getAccounts:M,saveAccounts:N}):r===`extension-delegate`?R({providerId:e,accessToken:t,domains:n},{sendMaskRequest:Ue,getAccounts:M,saveAccounts:N}):r===`connect`?{error:`no replica store in connect mode`}:await We(e,t,n)}catch(t){let n=t instanceof Error?t.message:String(t);return A.error(`OAuth replica sync failed`,{providerId:e,topology:r,error:n}),{error:n}}}async function qe(e){let t=M().find(t=>t.providerId===e);return t?.accessToken?L(t.maskedValue,t.accessToken)?{maskedValue:t.maskedValue}:Ge(e,t.accessToken):{error:`no access token held`}}function Je(e,t){if(e.accessToken)return`scopes`in e?e.scopes:t?.scopes}async function Ye(e){let t=M().find(t=>t.providerId===e.providerId),n=M().filter(t=>t.providerId!==e.providerId);n.push({providerId:e.providerId,apiKey:``,accessToken:e.accessToken,refreshToken:e.refreshToken,tokenExpiresAt:e.tokenExpiresAt,userName:e.userName,userAvatar:e.userAvatar,baseUrl:e.baseUrl??t?.baseUrl,scopes:Je(e,t)}),await N(n),await Ge(e.providerId,e.accessToken)}function z(e){let t=M().find(t=>t.providerId===e);return t&&(t.accessToken||t.apiKey)||null}function B(e){let t=M().find(t=>t.providerId===e);return t?t.accessToken||t.apiKey||(E(e).optionalApiKey?`local`:null):null}function V(e){return M().find(t=>t.providerId===e)?.baseUrl??null}function Xe(e){return M().find(t=>t.providerId===e)?.deployment??null}function Ze(e){return M().find(t=>t.providerId===e)?.apiVersion??null}function H(){let e=localStorage.getItem(x)||``,t=e.indexOf(`:`);return t>=0?e.slice(t+1):e}function Qe(e){let t=e.indexOf(`:`);if(t>0){let n=e.slice(0,t),r=new Set([...i(),...w()]),a=n.includes(`.`);if(r.has(n)||!a){localStorage.setItem(x,e);return}}let n=U();localStorage.setItem(x,`${n}:${e}`)}function $e(){return localStorage.getItem(x)||``}function U(){let e=$e(),t=e.indexOf(`:`);if(t>0)return e.slice(0,t);let n=M(),r=H();if(r){let e=n.find(e=>T(e.providerId)&&we(e.providerId,r));if(e)return e.providerId}let i=n.find(e=>T(e.providerId));return i?i.providerId:n.length>0?n[0].providerId:`anthropic`}function et(e){let t=H();localStorage.setItem(x,`${e}:${t}`)}function tt(){let e=H();localStorage.setItem(x,e)}function nt(){return B(U())}function rt(e){let t=U();P(t,e,V(t)??void 0)}async function it(){await F(U())}function at(){return V(U())}function ot(e){let t=U(),n=z(t);n&&P(t,n,e||void 0)}function st(){let e=U(),t=z(e);t&&P(e,t)}function ct(){let e=M(),t=U(),n=H();return e.map(e=>{let r={providerId:e.providerId,apiKey:e.apiKey};return e.baseUrl&&(r.baseUrl=e.baseUrl),e.providerId===t&&n&&(r.model=n),r})}async function lt(){let e=M();await Promise.allSettled(e.map(e=>F(e.providerId))),localStorage.removeItem(b),localStorage.removeItem(x);for(let e of ve)localStorage.removeItem(e)}function ut(e){return/^(?:gpt[-.]?|o[0-9]|chatgpt)/i.test(e)?`openai`:`anthropic`}function W(e,t,n,r){return{id:t,name:t,provider:e,api:r??`${e}-${ut(t)}`,baseUrl:n??``,contextWindow:2e5,maxTokens:16384,input:[`text`,`image`],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},reasoning:!0}}function G(e,t){return t.isOAuth||e===`azure-ai-foundry`?`anthropic`:e===`bedrock-camp`?`amazon-bedrock`:e}function dt(e,t,n){let r=O(e).find(e=>e.id===t);return r?n?{...r,baseUrl:n}:r:null}function ft(e,t,n,r){return n.isOAuth?O(t).find(e=>e.id===r)||{...e,api:`${t}-anthropic`,provider:t}:t===`bedrock-camp`?{...e,api:`bedrock-camp-converse`,provider:`bedrock-camp`}:e}function pt(e,t,n,r,i){if(t.isOAuth)return dt(e,n,r)??W(e,n,r);if(i)throw Error(`Model ${n} is not available from provider ${e}`);return q()}function K(e,t){if(!e)return q();let n=t??U(),r=V(n),i=E(n);if(t!==void 0){let t=dt(n,e,r);if(t)return t}try{let t=G(n,i),a=v(t,e);if(!a?.id)throw Error(`Model ${e} not found`);let o=ft(a,n,i,e);return r?{...o,baseUrl:r}:o}catch(a){return A.debug(`resolveModelById: pi-ai lookup miss, using provider fallback`,{providerId:n,modelId:e,error:a instanceof Error?a.message:String(a)}),pt(n,i,e,r,t!==void 0)}}function mt(e,t){return e.provider===t||e.provider===G(t,E(t))}function q(){let e=U(),t=H(),n=V(e),r=O(e),i=E(e),a=i.defaultModelId?r.find(e=>e.id.toLowerCase().includes(i.defaultModelId.toLowerCase()))?.id:void 0,o=t||a||r[0]?.id||`claude-sonnet-4-6`;try{let t=G(e,i),a=v(t,o);if(!a?.id)throw Error(`Model ${o} not found in ${t} registry`);let s=a;return i.isOAuth?s=r.find(e=>e.id===o)||{...s,api:`${e}-anthropic`,provider:e}:e===`bedrock-camp`&&(s={...s,api:`bedrock-camp-converse`,provider:`bedrock-camp`}),n&&(s={...s,baseUrl:n}),s}catch(t){A.debug(`resolveCurrentModel: pi-ai lookup miss, using provider fallback`,{providerId:e,effectiveModelId:o,error:t instanceof Error?t.message:String(t)});let a=r.find(e=>e.id===o);return a?n?{...a,baseUrl:n}:a:i.isOAuth?W(e,o,n):v(`anthropic`,`claude-sonnet-4-0`)}}function ht(e){let t=e.toLowerCase();if(!t)return null;let n=null;try{n=U()}catch{}if(n!==null){let e=J(t,[n]);if(e!==null)return e}return J(t,M().map(e=>e.providerId))}function J(e,t){let n=null,r=-1;for(let i of t)for(let t of O(i)){let i=t.id.toLowerCase(),a=(t.name??``).toLowerCase();if(!i.includes(e)&&!a.includes(e))continue;let o=t.contextWindow??0;(o>r||o===r&&Ct(t.id,n??``)>0)&&(r=o,n=t.id)}return n}function Y(){let e=[];try{for(let t of M())e.includes(t.providerId)||e.push(t.providerId)}catch{}try{let t=U();e.includes(t)||e.push(t)}catch{}return e}function gt(e){let t=e.indexOf(`:`);if(t<=0||t===e.length-1)return null;let n=e.slice(0,t),r=e.slice(t+1),i=Y().includes(n);if(i)return{providerId:n,modelId:r,configured:i};let a=!1;try{a=w().includes(n)}catch{}return a?{providerId:n,modelId:r,configured:!1}:null}function X(e,t,n=!0){let r=[e],i=n?J(e.toLowerCase(),[t]):null;i!==null&&i!==e&&r.push(i);let a=[];try{a=O(t)}catch{}for(let n of r)if(!(a.length>0&&!a.some(e=>e.id===n)))try{if(K(n,t).id===n)return{modelId:n,providerId:t}}catch(r){A.debug(`selectModelFromProvider: candidate did not resolve`,{input:e,candidate:n,providerId:t,error:r instanceof Error?r.message:String(r)})}return null}function _t(e){return e.map(e=>`${e.providerId}:${e.modelId}`).join(`, `)}function Z(e){if(!e)return{ok:!1,error:`unknown model: (empty)`};let t=gt(e);if(t)return bt(e,t);let n=null;try{n=U()}catch{}if(n!==null){let t=X(e,n);if(t)return $(t)}return xt(e,n)}function Q(){try{return U()}catch{return null}}function vt(e){let t=Q();return t===null||pe(_(),t,e.providerId,e.modelId)}function yt(e){let t=Q()??`<none>`;return{ok:!1,error:`model not allowed: ${`${e.providerId}:${e.modelId}`} is blocked by ${m} while "${t}" is selected — ${ge(t,e.providerId,e.modelId)}`}}function $(e){return vt(e)?{ok:!0,selection:e}:yt(e)}function bt(e,t){if(!t.configured){let n=Y();return{ok:!1,error:`unknown model: ${e} (provider "${t.providerId}" is not configured${n.length>0?`; configured: ${n.join(`, `)}`:``})`}}let n=X(t.modelId,t.providerId);return n?$(n):{ok:!1,error:`unknown model: ${e} (provider "${t.providerId}" does not offer "${t.modelId}")`}}function xt(e,t){let n=Y().filter(e=>e!==t);for(let t of[`exact`,`shorthand`]){let r=[];for(let i of n){let n=t===`exact`?e:J(e.toLowerCase(),[i]);if(n===null)continue;let a=X(n,i,!1);a&&r.push(a)}let i=r.filter(vt);if(i.length===0&&r.length>0)return yt(r[0]);if(i.length===1)return{ok:!0,selection:i[0]};if(i.length>1)return{ok:!1,error:`ambiguous model: ${e} matches ${_t(i)} — qualify it as provider:model`}}return{ok:!1,error:`unknown model: ${e}`}}function St(e){let t=Z(e);return t.ok?t.selection.modelId:null}function Ct(e,t){let n=e.match(/\d+/g)?.map(Number)??[],r=t.match(/\d+/g)?.map(Number)??[],i=Math.max(n.length,r.length);for(let e=0;e<i;e++){let t=(n[e]??0)-(r[e]??0);if(t!==0)return t}return 0}export{se as S,Ye as _,B as a,ue as b,Xe as c,H as d,U as f,Z as g,K as h,nt as i,k as l,q as m,qe as n,Ze as o,mt as p,M as r,V as s,_e as t,O as u,m as v,he as x,h as y};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./panel-rpc-DVS1uJpt.js";import{S as t,_ as n,r,s as i}from"./account-store-DySOM26M.js";import{a}from"./diagnostics-DN_idNHx.js";import{a as o,i as s,r as c}from"./compat-uEPf6-XW.js";import{a as l,r as u,s as d,t as f}from"./legacy-api-aliases-jKEvBgOL.js";import{a as p,i as m,r as h}from"./claude-model-version-ceOteQ2f.js";import{r as g}from"./provider-budget-DbHWq3j6.js";import{n as _}from"./llm-session-id-BZyXP_j2.js";import{v}from"./kernel-worker-BbLNbBtI.js";import{n as y,t as ee}from"./silent-renew-backoff-Dmz3DJHb.js";import{getOAuthPageOrigin as te}from"./oauth-service-DLGjPRxS.js";import{n as b}from"./temperature-support-PjwXIa-F.js";import"./provider-settings-DyJic7fg.js";var ne={proxyEndpoint:`https://adobe-llm-proxy.paolo-moz.workers.dev`,redirectUri:`https://www.sliccy.ai/auth/callback`,extensionRedirectUri:`https://akjjllgokmbgpbdbmafpiefnhidlmbgf.chromiumapp.org/adobe`};function re(e,t){return h(e,t)}function x(e,t,n){return e!==`xhigh`||!t?e:p(t,n)?`xhigh`:m(t,n)?`max`:`high`}function ie(e,t){let n=e?t?.thinkingLevelMap?.[e]:void 0;return x((()=>{if(typeof n==`string`)return n;switch(e){case`minimal`:case`low`:return`low`;case`medium`:return`medium`;case`xhigh`:return`xhigh`;default:return`high`}})(),t?.id,t?.name)}function ae(e,t){return async(n,r)=>{let i=t?await t(n,r)??n:n,a=i.thinking;return a&&a.type===`enabled`&&(i.thinking={type:`adaptive`,...a.display===void 0?{}:{display:a.display}},i.output_config={...i.output_config??{},effort:e}),i}}function S(e,t){if(!re(e.id,e.name))return t;let n=t,r=x(n.effort??ie(n.reasoning,e),e.id,e.name);return{...t,onPayload:ae(r,n.onPayload)}}function oe(e,t){let n={id:e.id,name:e.name??e.id},r=t?.api??e.api,i=t?.context_window??e.context_window,a=t?.max_tokens??e.max_tokens,o=t?.reasoning??e.reasoning,s=t?.input??e.input;r&&(n.api=r),i!==void 0&&(n.context_window=i),a!==void 0&&(n.max_tokens=a),o!==void 0&&(n.reasoning=o),s&&(n.input=s);let c=t?.cost??e.cost;return c&&(n.cost=c),/haiku/i.test(e.id)&&(n.compat={supportsEagerToolInputStreaming:!1}),/sonnet-5\b/i.test(e.id)&&!n.thinkingLevelMap&&(n.thinkingLevelMap={xhigh:`xhigh`}),n}async function se(e,t,n,r={}){let i=typeof AbortController==`function`?new AbortController:null,a=i?setTimeout(()=>i.abort(),r.timeoutMs??8e3):null;try{let a=await n(`${e.replace(/\/$/,``)}/v1/usage`,{headers:{...r.headers,Authorization:`Bearer ${t}`},...i?{signal:i.signal}:{}});if(a.status===404||a.status===501)return null;if(!a.ok)throw Error(`Adobe /v1/usage returned ${a.status}`);return g(await a.json())}finally{a&&clearTimeout(a)}}const C=Object.assign({"/packages/webapp/providers/adobe-config.json":ne})[`/packages/webapp/providers/adobe-config.json`]??{clientId:``,proxyEndpoint:``,scopes:`openid,profile,email`};function w(){let e=i(`adobe`);if(e)return e.replace(/\/$/,``);if(C.proxyEndpoint)return C.proxyEndpoint.replace(/\/$/,``);throw Error(`Adobe proxy endpoint not configured — set it in Settings or adobe-config.json`)}const T=new Map,ce=new Map,le=`slicc-adobe-models`;function E(e){try{localStorage.setItem(le,JSON.stringify(e))}catch{}}async function D(e){try{let t=await fetch(`${e}/v1/config`,{headers:{[W]:`6.177.0`}});return t.ok?await t.json():(console.warn(`[adobe] Proxy /v1/config returned ${t.status}`),null)}catch(e){return console.warn(`[adobe] Failed to fetch proxy config:`,e instanceof Error?e.message:String(e)),null}}async function O(e){let t=T.get(e);if(t)return t;let n=await D(e);return n||=(await new Promise(e=>setTimeout(e,600)),await D(e)),n?(T.set(e,n),n):{}}function k(e){let t=e.clientId||C.clientId;if(!t)throw Error(`Could not determine IMS client ID — proxy /v1/config did not return one and adobe-config.json is empty`);return t}function A(e){return e.scopes||C.scopes}function j(e){return e.imsEnvironment||C.imsEnvironment||`prod`}const M={prod:`https://ims-na1.adobelogin.com`,stg1:`https://ims-na1-stg1.adobelogin.com`};function N(e){return M[e??C.imsEnvironment??`prod`]??M.prod}async function P(){let e;try{e=w()}catch{return{}}return T.get(e)||new Promise(t=>{let n=setTimeout(()=>t({}),5e3),r=e=>{clearTimeout(n),t(e)};O(e).then(r,()=>r({}))})}function F(e){try{let t=e.split(`.`)[1];if(!t)return;let n=t.replace(/-/g,`+`).replace(/_/g,`/`),r=atob(n+`=`.repeat((4-n.length%4)%4)),i=JSON.parse(r);return typeof i.client_id==`string`?i.client_id:void 0}catch{return}}const I=typeof chrome<`u`&&!!chrome?.runtime?.id;function L(){return r().find(e=>e.providerId===`adobe`)}const ue=[`/ims/profile/v1`,`/ims/userinfo/v2`];async function de(e,t){try{let n=await fetch(e,{headers:{Authorization:`Bearer ${t}`}});if(!n.ok){console.warn(`[adobe] Profile fetch ${e} returned ${n.status}`);return}let r=await n.json(),i=r.displayName||r.name||r.email;return i?{name:i,avatar:r.picture||r.avatar_url}:void 0}catch(t){console.warn(`[adobe] Profile fetch ${e} failed:`,t instanceof Error?t.message:String(t));return}}async function fe(e,t){for(let n of ue){let r=await de(`${N(t)}${n}`,e);if(r)return r}return console.warn(`[adobe] No IMS profile endpoint named the user; account will have no display name`),{}}async function pe(){let e=L(),t=e?.accessToken;if(!t)return{status:`unknown`,detail:`no stored token`};let n=await P(),r=F(t)||n.clientId||C.clientId||``;if(!r)return{status:`unknown`,detail:`no IMS client ID available`};let i=N(j(n));try{let n=await fetch(`${i}/ims/validate_token/v1`,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:new URLSearchParams({client_id:r,token:t,type:`access_token`}),signal:AbortSignal.timeout(1e4)});if(!n.ok)return{status:`unknown`,detail:`HTTP ${n.status}${n.statusText?` ${n.statusText}`:``}`};let a=await n.json();return a.valid===!0?{status:`accepted`,userName:e?.userName}:a.valid===!1?{status:`rejected`,detail:`IMS reported the token invalid (${typeof a.reason==`string`?a.reason:`no reason given`})`}:{status:`unknown`,detail:"IMS answered 200 without a boolean `valid` verdict"}}catch(e){return{status:`unknown`,detail:e instanceof Error?e.message:String(e)}}}function R(e){let t=e.indexOf(`#`);if(t<0)return null;let n=new URLSearchParams(e.slice(t+1)),r=n.get(`access_token`);return r?{accessToken:r,expiresIn:parseInt(n.get(`expires_in`)??`86400`,10),scope:n.get(`scope`)??void 0}:null}const z={id:`adobe`,name:`Adobe`,description:`Claude via Adobe — login with your Adobe ID`,requiresApiKey:!1,requiresBaseUrl:!C.proxyEndpoint,baseUrlPlaceholder:`https://your-proxy.example.com`,baseUrlDescription:`Anthropic-compatible proxy endpoint`,isOAuth:!0,defaultModelId:`sonnet`,oauthTokenDomains:[`ims-na1.adobelogin.com`,`ims-na1-stg1.adobelogin.com`,`*.adobelogin.com`,`*.adobe.io`,`firefall.adobe.io`,`admin.hlx.page`,`admin.hlx.live`,`admin.aem.page`,`admin.aem.live`,`api.aem.live`],getBudgetUsage:he,getModelIds:()=>{let e=e=>oe(e,ce.get(e.id));for(let t of Q.values())if(t.length){let n=t.map(t=>e({id:t.id,name:t.name??t.id,reasoning:t.reasoning,input:t.input,cost:t.cost}));return E(n),n}for(let t of T.values())if(t.models?.length)return t.models.map(t=>e(t));try{let e=localStorage.getItem(le);if(e){let t=JSON.parse(e);if(t.length)return t}}catch{}return[{id:`claude-sonnet-4-6`,name:`Claude Sonnet 4.6`}]},onOAuthLogin:async(e,t,r)=>{let i=w(),a=await O(i),o=k(a),s=A(a),c=j(a),l=I?null:await te(),u=I?null:y({pageHref:l.href,pageOrigin:l.origin,configuredRedirectUri:C.redirectUri},()=>crypto.randomUUID()),d=I?C.extensionRedirectUri??`https://${chrome.runtime.id}.chromiumapp.org/`:u.redirectUri,f=u?.oauthState,p=u?.expectedNonce??null,m=new URLSearchParams({client_id:o,scope:s,response_type:`token`,redirect_uri:d});f&&m.set(`state`,f),r?.forceReauth&&m.set(`prompt`,`login`);let h=await e(`${N(c)}/ims/authorize/v2?${m}`);if(!h)return;if(p&&h)try{if(new URL(h).searchParams.get(`nonce`)!==p){console.error(`[adobe] OAuth nonce mismatch — possible CSRF`);return}}catch(e){console.warn(`[adobe] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}let g=R(h);if(!g){console.error(`[adobe] Could not extract token from redirect URL`);return}let _=await fe(g.accessToken,c);await n({providerId:`adobe`,accessToken:g.accessToken,tokenExpiresAt:Date.now()+g.expiresIn*1e3,userName:_.name,userAvatar:_.avatar,scopes:g.scope,baseUrl:C.proxyEndpoint?void 0:i}),v(),await $().catch(e=>console.warn(`[adobe] Failed to fetch models after login:`,e instanceof Error?e.message:String(e))),t()},onOAuthLogout:async()=>{let e=L();if(e?.accessToken)try{let t=await P(),n=F(e.accessToken)||t.clientId||C.clientId,r=j(t);if(n){let t=await fetch(`${N(r)}/ims/revoke`,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:new URLSearchParams({token:e.accessToken,token_type_hint:`access_token`,client_id:n})});t.ok||console.warn(`[adobe] Token revocation returned ${t.status}, token may still be valid server-side`)}}catch(e){console.warn(`[adobe] Failed to revoke token:`,e instanceof Error?e.message:String(e))}await n({providerId:`adobe`,accessToken:``}),v()},onSilentRenew:async()=>L()?.accessToken?U():null,onValidateToken:pe,refreshModels:async e=>{await $(e);let t=z.getModelIds?.();t?.length&&E(t)}};let B=null;const me=ee();async function V(){let e=L();if(!e?.accessToken)throw Error(`Not logged in to Adobe — please log in first`);if((e.tokenExpiresAt??0)-Date.now()>6e4)return e.accessToken;console.log(`[adobe] Token expired or expiring soon, attempting silent renewal...`);let t=await me.run(()=>U());if(t)return t;let n=L();if((n?.tokenExpiresAt??0)-Date.now()>0&&n?.accessToken)return n.accessToken;throw Error(`Adobe session expired — please log in again`)}async function he(){let e;try{e=w()}catch{return null}let t=L();if(!t?.accessToken||H())throw Error(`Adobe budget: not signed in`);return se(e,t.accessToken,fetch,{headers:{"X-Session-Id":_(be)}})}function H(){let e=L();return!e?.tokenExpiresAt||Date.now()>e.tokenExpiresAt-6e4}async function U(){if(typeof window>`u`){let t=e();if(!t)return null;try{let{accessToken:e}=await t.call(`silent-renew`,{providerId:`adobe`},{timeoutMs:13e4});return e}catch(e){return console.warn(`[adobe] worker→page silent-renew bridge failed:`,e instanceof Error?e.message:String(e)),null}}return B===null&&(B=ye().finally(()=>{B=null})),B}function ge(e,t){let n=k(t),r=A(t),i=j(t),a=I?null:y({pageHref:window.location.href,pageOrigin:window.location.origin,configuredRedirectUri:C.redirectUri},()=>crypto.randomUUID()),o=I?C.extensionRedirectUri??`https://${chrome.runtime.id}.chromiumapp.org/`:a.redirectUri,s=a?.oauthState,c=a?.expectedNonce??null,l=new URLSearchParams({client_id:n,scope:r,response_type:`token`,redirect_uri:o,prompt:`none`});return s&&l.set(`state`,s),{authorizeUrl:`${N(i)}/ims/authorize/v2?${l}`,expectedNonce:c,proxyEndpoint:e}}function _e(e,t){if(!t)return!0;try{if(new URL(e).searchParams.get(`nonce`)!==t)return console.error(`[adobe] OAuth nonce mismatch — possible CSRF`),!1}catch(e){console.warn(`[adobe] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}return!0}async function ve(e,t){let r=L();await n({providerId:`adobe`,accessToken:e.accessToken,tokenExpiresAt:Date.now()+e.expiresIn*1e3,userName:r?.userName,userAvatar:r?.userAvatar,scopes:e.scope,baseUrl:C.proxyEndpoint?void 0:t})}async function ye(){try{let e=w(),{authorizeUrl:t,expectedNonce:n}=ge(e,await O(e)),{createOAuthLauncher:r}=await import(`./oauth-service-DLGjPRxS.js`),i=await r()(t,{interactive:!1});if(!i||!_e(i,n))return null;let a=R(i);return a?(await ve(a,e),console.log(`[adobe] Token renewed silently`),await $().catch(e=>console.warn(`[adobe] Failed to refresh models after silent renewal:`,e instanceof Error?e.message:String(e))),a.accessToken):null}catch(e){return console.warn(`[adobe] Silent renewal error:`,e instanceof Error?e.message:String(e)),null}}const W=`X-Slicc-Version`;function G(e){let t={};if(e.headers)for(let[n,r]of Object.entries(e.headers))n.toLowerCase()!==`x-slicc-version`&&(t[n]=r);return t[W]=`6.177.0`,{...e,headers:t}}const be=`adobe-usage-probe`,K=new Set;function q(e,t){if(e.headers){for(let[t,n]of Object.entries(e.headers))if(t.toLowerCase()===`x-session-id`&&n!=null)return e}return K.has(t)||(K.add(t),console.warn(`[adobe] Missing X-Session-Id from ${t} — using daily fallback. Attach an X-Session-Id header at the call site (see scoop-context.ts streamWithSessionId or docs/pitfalls.md).`)),{...e,headers:{...e.headers??{},"X-Session-Id":_(`adobe-provider-fallback`)}}}function xe(){K.clear()}function J(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:`adobe-anthropic`,provider:`adobe`,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}}function Y(e){console.error(`[adobe] Stream error:`,e instanceof Error?e.message:String(e))}const X=(e,t,n={})=>{let r=a();return Se(r,e,t,n).catch(Y),r};async function Se(e,t,n,r){try{let i=await V();if(String(t.api).includes(`openai`)){let a={...t,baseUrl:`${w()}/v1`,api:`openai-completions`,compat:{...t.compat,supportsStore:!1,supportsDeveloperRole:!1}},o=u(a,n,G(q({...r,apiKey:i},`streamAdobe[openai]`)));for await(let t of o)e.push(t)}else{let a={...t,baseUrl:w(),api:`anthropic-messages`},o=f(a,n,G(q(S(t,b(t.id,t.name,{...r,apiKey:i})),`streamAdobe[anthropic]`)));for await(let t of o)e.push(t)}e.end()}catch(n){Y(n),e.push(J(t,n)),e.end()}}const Z=(e,t,n)=>{let r=a();return Ce(r,e,t,n).catch(Y),r};async function Ce(e,t,n,r){try{let i=await V();if(String(t.api).includes(`openai`)){let a={...t,baseUrl:`${w()}/v1`,api:`openai-completions`,compat:{...t.compat,supportsStore:!1,supportsDeveloperRole:!1}},o=d(a,n,G(q({...r,apiKey:i},`streamSimpleAdobe[openai]`)));for await(let t of o)e.push(t)}else{let a={...t,baseUrl:w(),api:`anthropic-messages`},o=l(a,n,G(q(S(t,b(t.id,t.name,{...r,apiKey:i})),`streamSimpleAdobe[anthropic]`)));for await(let t of o)e.push(t)}e.end()}catch(n){Y(n),e.push(J(t,n)),e.end()}}function we(e){let t={id:e.id,name:e.name};return e.api!==void 0&&(t.api=e.api),e.context_window!==void 0&&(t.context_window=e.context_window),e.max_tokens!==void 0&&(t.max_tokens=e.max_tokens),e.reasoning!==void 0&&(t.reasoning=e.reasoning),e.input!==void 0&&(t.input=e.input),t}function Te(){let e=new Map;for(let t of s())try{let n=c(t);for(let t of n)e.set(t.id,t)}catch{}return e}function Ee(e,n,r){let i=`adobe-${e.api===`openai`?`openai`:`anthropic`}`,a=r.get(e.id);if(a)return{...a,provider:`adobe`,api:i};let o=t(e.id,r);return{id:e.id,name:e.name??e.id,provider:`adobe`,api:i,baseUrl:n,contextWindow:2e5,maxTokens:16384,input:[`text`,`image`],cost:o,inputCost:o.input,outputCost:o.output,cacheReadCost:o.cacheRead,cacheWriteCost:o.cacheWrite,reasoning:!0}}function De(e,t){for(let t of e)ce.set(t.id,we(t));let n=Te();return e.map(e=>Ee(e,t,n))}async function Oe(e){try{let t=e??await V(),n=w(),r=await fetch(`${n}/v1/models`,{headers:{Authorization:`Bearer ${t}`,[W]:`6.177.0`}});if(!r.ok)console.warn(`[adobe] Proxy /v1/models returned ${r.status}, falling back to Anthropic models`);else{let e=await r.json();if(e.data?.length)return De(e.data,n)}}catch(e){console.warn(`[adobe] Failed to fetch proxy models:`,e instanceof Error?e.message:String(e))}return null}const Q=new Map;function ke(){return c(`anthropic`).map(e=>({...e,provider:`adobe`,api:`adobe-anthropic`}))}async function $(e){let t=w(),n=Q.get(t);if(n)return n;let r=await Oe(e);return r?(Q.set(t,r),r):ke()}function Ae(){o({api:`adobe-anthropic`,stream:X,streamSimple:Z}),o({api:`adobe-openai`,stream:X,streamSimple:Z})}export{xe as __resetAdobeSessionIdWarningCacheForTests,z as config,R as extractTokenFromUrl,$ as getAdobeModels,V as getValidAccessToken,H as isTokenExpired,Ae as register};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./runtime-env-DadgceZk.js";let t=null,n=null;function r(e){if(e===null||e===``){t=null;return}t=e.replace(/\/+$/,``)}function i(){return t}function a(e){n=e===null||e===``?null:e}function o(){return n}let s=null;function c(e){s=e===null||e===``?null:e}function l(){return s}let u=null;function d(e){u=e}function f(){return u===null&&(u=e()),u}function p(e){return t?`${t}${e}`:e}function m(e){let r={};if(n&&t&&(r[`X-Bridge-Token`]=n),e)for(let t of Object.keys(e))r[t]=e[t];return r}export{i as a,d as c,l as i,c as l,o as n,p as o,f as r,a as s,m as t,r as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./runtime-env-Dlaokqg1.js";var t=null,n=null;function r(e){if(e===null||e===``){t=null;return}t=e.replace(/\/+$/,``)}function i(){return t}function a(e){n=e===null||e===``?null:e}var o=null;function s(e){o=e===null||e===``?null:e}function c(){return o}var l=null;function u(){return l===null&&(l=e()),l}function d(e){return t?`${t}${e}`:e}function f(e){let r={};if(n&&t&&(r[`X-Bridge-Token`]=n),e)for(let t of Object.keys(e))r[t]=e[t];return r}export{d as a,r as c,i,u as n,a as o,c as r,s,f as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e,t}from"./api-endpoint-3qEcn7BY.js";function n(e){return!e.startsWith(`/`)||e===`/`?!1:e.split(`/`).slice(1).every(e=>e!==``&&e!==`.`&&e!==`..`)}async function r(r=fetch){try{let i=await r(e(`/api/runtime-config`),{cache:`no-store`,headers:t()});if(!i.ok)return[];let a=await i.json();if(!Array.isArray(a.autoMounts))return[];let o=[];for(let e of a.autoMounts){let t=e;typeof t.path!=`string`||!n(t.path)||typeof t.hostPath==`string`&&t.hostPath.length!==0&&o.push({path:t.path,hostPath:t.hostPath})}return o}catch{return[]}}function i(e,t){if(t.length===0)return e;let n=new Set(t.map(e=>e.path));return e.filter(e=>!n.has(e.targetPath.replace(/\/+$/,``)||`/`))}function a(e,t){if(t.length===0)return[];let n=new Set(t.map(e=>e.path));return e.filter(e=>n.has(e.targetPath.replace(/\/+$/,``)||`/`))}async function o(e,t,n=fetch){let i=await r(n);if(i.length===0)return[];let a=new Set(e.listMounts()),o=[],{HostFsMountBackend:s}=await import(`./backend-hostfs-CsCDQ3wI.js`);for(let n of i)if(!a.has(n.path))try{let r=new s({targetPath:n.path,hostPath:n.hostPath});await e.mount(n.path,r),o.push(n),t?.info?.(`Auto-mounted host folder from the mount table`,n)}catch(e){t?.warn?.(`Failed to auto-mount host folder`,{...n,error:e instanceof Error?e.message:String(e)})}return o}export{a as hostShadowedEntries,o as mountConfiguredHostMounts,i as withoutHostMountedTargets};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e=`slicc-boot-stall-overlay`;function t(t,n,r={}){let i=`Still starting — the kernel is taking longer than expected (${Math.max(1,Math.round(n.elapsedMs/1e3))}s). Waiting is safe; your data is untouched.`,a=t.getElementById(e);if(a){let e=a.querySelector(`p`);e&&(e.textContent=i);return}let o=t.createElement(`div`);o.id=e,o.style.cssText=`position:fixed;left:50%;bottom:1.5rem;transform:translateX(-50%);z-index:2147483000;display:flex;gap:0.75rem;align-items:center;padding:0.75rem 1rem;border-radius:8px;font-family:system-ui;font-size:0.875rem;max-width:min(90vw,34rem);background:var(--s2-background-elevated, #1e1e1e);color:var(--s2-content, #eee);border:1px solid var(--s2-content-tertiary, #717171);box-shadow:0 4px 16px rgba(0,0,0,0.4);`;let s=t.createElement(`p`);s.style.cssText=`margin:0;`,s.textContent=i;let c=t.createElement(`button`);c.type=`button`,c.textContent=`Reload`,c.style.cssText=`padding:0.35rem 0.75rem;cursor:pointer;border:1px solid var(--s2-content-tertiary, #717171);background:transparent;color:inherit;border-radius:4px;flex-shrink:0;`;let l=r.reload??(()=>location.reload());c.addEventListener(`click`,()=>l()),o.append(s,c),t.body.appendChild(o)}function n(t){t.getElementById(e)?.remove()}export{n as removeBootStallOverlay,t as showBootStallOverlay};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./proxied-fetch-CUw_f_qQ.js";import{n as e}from"./runtime-env-Dlaokqg1.js";import{r as t}from"./api-endpoint-DGxXvrur.js";function n(){return e()?`extension-direct`:t()?`extension-delegate`:globalThis.__slicc_connect_mode?`connect`:`node-rest`}function r(){return n()===`node-rest`}export{n,r as t};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./slugify-BYJ6QVAt.js";import{n as t,r as n,t as r}from"./archive-redaction-ByV7X5fs.js";import{t as i}from"./types-D8gIX-W-.js";import{i as a,r as o,y as s}from"./kernel-worker-BbLNbBtI.js";const c=/\uD83C\uDF99\uFE0F?/g,l=/\u25C1[\s\S]*?\u25B7/g;function u(e){return e.replace(l,``).replace(c,``).replace(/[ \t]+$/g,``).trimEnd()}function d(e){let t=``;for(let n of e){let e=n.role===`user`?`User`:`Assistant`,r=n.role===`user`?u(n.content):n.content;if(t+=`## ${e}\n${r}\n\n`,n.attachments?.length&&(t+=`Attachments:\n${n.attachments.map(e=>`- ${s(e)}`).join(`
|
|
2
|
-
`)}\n\n`),n.toolCalls)for(let e of n.toolCalls)t+=`### Tool: ${e.name}\nInput: ${JSON.stringify(e.input,null,2)}\nResult: ${e.result??``}\n\n`}return t}function f(e){return`live-${h(e)}-${m()}.md`}function p(e,t){return e.find(e=>e.live===!0&&(e.cone??`cone`)===t)}function m(){return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`}function h(t){return e(t,{maxLen:48,fallback:`session`})}function g(e){let t=e.find(e=>e.role===`user`);if(!t?.content)return`untitled-session`;let n=t.content.trim().replace(/\s+/g,` `);return n.length>60?`${n.slice(0,60)}…`:n||`untitled-session`}function _(e){return e.map(e=>{let t={id:e.id,role:e.role,content:e.content,timestamp:e.timestamp};return e.attachments?.length&&(t.attachments=e.attachments),e.toolCalls?.length&&(t.toolCalls=e.toolCalls.map(e=>({id:e.id,name:e.name,input:e.input,...e.result===void 0?{}:{result:e.result},...e.isError?{isError:e.isError}:{}}))),e.source&&(t.source=e.source),e.channel&&(t.channel=e.channel),e.compaction&&(t.compaction=e.compaction),t})}function v(e){let i=r(),a={...e,title:t(e.title,i),messages:n(e.messages,i)},o=(a.cost?`cost: ${JSON.stringify(a.cost)}\n`:``)+(a.models?`models: ${JSON.stringify(a.models)}\n`:``),s=(a.cone?`cone: ${a.cone}\n`:``)+(a.coneLabel?`coneLabel: ${JSON.stringify(a.coneLabel)}\n`:``)+(a.memorySkipped?`memorySkipped: true
|
|
3
|
-
`:``)+(a.live?`live: true
|
|
4
|
-
`:``)+(a.live&&a.liveThrough?`liveThrough: ${a.liveThrough}\n`:``)+(a.live&&a.compactions?`compactions: ${a.compactions}\n`:``),c=`---\nid: ${a.id}\ntitle: ${JSON.stringify(a.title)}\nfrozenAt: ${a.frozenAt}\ncreatedAt: ${a.createdAt}\nupdatedAt: ${a.updatedAt}\nmessageCount: ${a.messageCount}\n`+o+s+`---
|
|
5
|
-
|
|
6
|
-
`,l=`# ${a.title}\n\n`;return c+`<!-- slicc:session-data
|
|
7
|
-
${JSON.stringify(_(a.messages)).replace(/-->/g,`-- >`)}
|
|
8
|
-
-->\n\n`+l+d(a.messages)}function y(e){return e===`/sessions`?a:`${e}/index.json`}function b(e){return e===`/sessions`?C:`slicc:sessions-index:${e}`}async function x(e,t=o){try{await e.mkdir(t,{recursive:!0})}catch{}}async function S(e,t=o){try{let n=await e.readFile(y(t),{encoding:`utf-8`}),r=typeof n==`string`?n:new TextDecoder().decode(n),i=JSON.parse(r);return Array.isArray(i)?i:[]}catch(e){if(e instanceof i&&e.code!==`ENOENT`)throw e;return[]}}const C=`slicc:sessions-index`;let w=Promise.resolve();function T(e,t=C){let n=()=>{let n=globalThis.navigator?.locks;return typeof n?.request==`function`?n.request(t,()=>e()):e()},r=w.then(n,n);return w=r.then(()=>void 0,()=>void 0),r}function E(e,t,n=o){return e.writeFile(y(n),JSON.stringify(t,null,2))}async function D(e,t,n=o){await E(e,[t,...(await S(e,n)).filter(e=>e.filename!==t.filename)],n)}export{f as a,b as c,g as i,D as l,p as n,S as o,v as r,T as s,x as t,E as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./logger-LESFN7Hj.js";import{a as n,i as r,n as i,r as a,t as o}from"./path-utils-DNJG-zQf.js";import{n as s,t as c}from"./types-D8gIX-W-.js";import{i as l,r as u,t as d}from"./mount-index-CQfmUPuZ.js";import{a as f,i as p,n as m,t as h}from"./mount-table-store-DrF_Ifaz.js";import{n as g,t as _}from"./virtual-device-paths-CS5o4QVz.js";import{t as v}from"./same-file-identity-DuEcSmPX.js";import{a as y,i as b,t as x}from"./sidecar-repair-CWpX6fJD.js";import{t as S}from"./stat-identity-BaU9yoai.js";function ee(e,t,n){return e.size===0||!e.has(n)||!t.isReady(n)?!1:!Array.from(e.keys()).some(e=>e!==n&&e.startsWith(n+`/`))}async function C(e,t){try{return await e(t)}catch{return t}}async function*w(e,t,n,r=0){let a=i(t);if(ee(e.mountPoints,e.mountIndex,a)){let t=e.mountIndex.getFiles(a);if(t){for(let e of t)yield e;return}}let o=n??new Set;if(r>64||o.size>=1e5)return;let s=await C(t=>e.realpath(t),a);if(o.has(s))return;o.add(s);let c=await e.readDir(a);for(let t of c)yield*T(e,t,a===`/`?`/${t.name}`:`${a}/${t.name}`,o,r+1)}async function*T(e,t,n,r,i){if(t.type===`file`){yield n;return}if(t.type===`symlink`){yield*E(e,n,r,i);return}yield*w(e,n,r,i)}async function*E(e,t,n,r){try{let i=await e.stat(t);i.type===`file`?yield t:i.type===`directory`&&(yield*w(e,t,n,r))}catch{}}const D=t(`fs-watcher`);let O=0;function k(e,t){return t===`/`||e===t||e.startsWith(t+`/`)}var A=class{registrations=new Map;watch(e,t,n){let r=`fsw-${++O}`;return this.registrations.set(r,{id:r,basePath:e,filter:t,callback:n}),D.debug(`Watch registered`,{id:r,basePath:e}),()=>{this.registrations.delete(r),D.debug(`Watch unregistered`,{id:r})}}notify(e){if(e.length!==0)for(let[,t]of this.registrations){let n=e.filter(e=>k(e.path,t.basePath)&&t.filter(e.path));if(n.length>0)try{t.callback(n)}catch(e){D.error(`Watch callback error`,{id:t.id,error:e instanceof Error?e.message:String(e)})}}}dispose(){this.registrations.clear(),D.debug(`All watchers disposed`)}get size(){return this.registrations.size}};const j=new TextEncoder,M=new TextDecoder(`utf-8`,{fatal:!1});var N=class{entries=new Map;static handles(e){return g(i(e))}has(e){return this.entries.has(i(e))}write(e,t){let n=i(e),r=typeof t==`string`?j.encode(t):new Uint8Array(t),a=Date.now(),o=this.entries.get(n);this.entries.set(n,{bytes:r,mtime:a,ctime:o?.ctime??a})}append(e,t){let n=this.entries.get(i(e))?.bytes??new Uint8Array,r=typeof t==`string`?j.encode(t):t,a=new Uint8Array(n.length+r.length);a.set(n),a.set(r,n.length),this.write(e,a)}read(e,t){let n=this.require(e);return(t?.encoding??`utf-8`)===`utf-8`?M.decode(n.bytes):new Uint8Array(n.bytes)}readText(e){return M.decode(this.require(e).bytes)}stat(e){let t=this.require(e);return{type:`file`,size:t.bytes.length,mtime:t.mtime,ctime:t.ctime}}remove(e){return this.entries.delete(i(e))}require(e){let t=i(e),n=this.entries.get(t);if(!n)throw new c(`ENOENT`,`no such file or directory`,t);return n}};const P={[_]:{stat:()=>({type:`file`,size:0,mtime:0,ctime:0}),read:e=>(e?.encoding??`utf-8`)===`utf-8`?``:new Uint8Array,readText:()=>``,write:()=>{}}},F=[`/tmp/`];var I=class{ephemeralFds=new N;vfs;allowedPrefixes;readOnlyPrefixes;readGrantPatterns=[];writeEnforcement;includeMounts;constructor(e,t,n=[],r=`hard`,a={}){this.vfs=e;let o=e=>{let t=i(e);return t.endsWith(`/`)?t:t+`/`};this.allowedPrefixes=t.map(o),this.readOnlyPrefixes=n.map(o),this.writeEnforcement=r,this.includeMounts=a.includeMounts!==!1}getAllPrefixes(){let e=this.includeMounts?this.vfs.listMounts().map(e=>e.endsWith(`/`)?e:e+`/`):[];return[...this.allowedPrefixes,...this.readOnlyPrefixes,...e,...F]}setReadGrants(e){this.readGrantPatterns=[];for(let t of new Set(e))this.addReadGrant(t)}addReadGrant(e){let t=e.split(`/`),n=[];for(let e=1;e<t.length;e++)n.push(a(t.slice(0,e).join(`/`)||`/`));this.readGrantPatterns.push({pattern:e,regex:a(e),ancestorRegexes:n})}matchesReadGrant(e){return this.readGrantPatterns.some(t=>t.regex.test(e))}leadsToReadGrant(e){return this.readGrantPatterns.some(t=>t.ancestorRegexes.some(t=>t.test(e)))}isAllowed(e){let t=i(e),n=this.getAllPrefixes();return this.matchesReadGrant(t)||this.leadsToReadGrant(t)||n.some(e=>t===e.slice(0,-1)||t.startsWith(e)||t===`/`||e.startsWith(t+`/`))}isAllowedStrict(e){let t=i(e),n=this.getAllPrefixes();return this.matchesReadGrant(t)||n.some(e=>t===e.slice(0,-1)||t.startsWith(e))}isWritable(e){let t=i(e);return[...this.allowedPrefixes,...F].some(e=>t===e.slice(0,-1)||t.startsWith(e))}canWrite(e){return N.handles(e)||this.isWritable(e)}checkWrite(e){if(this.writeEnforcement!==`sudo-delegated`&&!this.isWritable(e))throw new c(`EACCES`,`permission denied`,i(e))}async resolveAndCheckRead(e){try{let t=await this.vfs.realpath(e);if(!this.isAllowedStrict(t))throw new c(`ENOENT`,`no such file or directory`,i(e));return t}catch(t){throw t instanceof c?t:new c(`ENOENT`,`no such file or directory`,i(e))}}async resolveAndCheckWrite(e){try{let t=await this.vfs.realpath(e);if(!this.isWritable(t)&&!this.isSymlinkEscapeAllowed(t))throw new c(`EACCES`,`permission denied`,i(e));return t}catch(t){throw t instanceof c?t:new c(`EACCES`,`permission denied`,i(e))}}isSymlinkEscapeAllowed(e){return!1}async checkParentRealpathEscape(e){let t=this.vfs.dirname(e),n=this.vfs.basename(e),r;try{r=await this.vfs.realpath(t)}catch(e){if(e instanceof c&&e.code===`EACCES`)throw e;return}let a=r+`/`+n;if(this.isWritable(a))return;let o=i(r)!==i(t);if(!(this.writeEnforcement===`sudo-delegated`&&!o))throw new c(`EACCES`,`permission denied`,i(e))}getUnderlyingFS(){return this.vfs}invalidatePaths(e){this.vfs.invalidatePaths(e)}async flush(){await this.vfs.flush()}isPathUnderMount(e){return this.vfs.isPathUnderMount(e)}async readFile(e,t){let n=P[i(e)];if(n)return n.read(t);if(N.handles(e))return this.ephemeralFds.read(e,t);if(!this.isAllowedStrict(e))throw new c(`ENOENT`,`no such file or directory`,i(e));let r=await this.resolveAndCheckRead(e);return this.vfs.readFile(r,t)}async readFileRange(e,t,n){if(!this.isAllowedStrict(e))throw new c(`ENOENT`,`no such file or directory`,i(e));let r=await this.resolveAndCheckRead(e);return this.vfs.readFileRange(r,t,n)}async getNativeFile(e){if(P[i(e)]||N.handles(e)||!this.isAllowedStrict(e))return null;try{let t=await this.resolveAndCheckRead(e);return await this.vfs.getNativeFile(t)}catch{return null}}async readDir(e,t){if(!this.isAllowed(e))return[];let n=e;if(this.isAllowedStrict(e))try{n=await this.resolveAndCheckRead(e)}catch{return[]}let r=await this.vfs.readDir(n,t);if(!this.isAllowedStrict(e)){let t=i(e);return r.filter(e=>{let n=t===`/`?`/${e.name}`:`${t}/${e.name}`;return this.isAllowed(n)})}return r}async stat(e){let t=P[i(e)];if(t)return t.stat();if(N.handles(e))return this.ephemeralFds.stat(e);if(!this.isAllowed(e))throw new c(`ENOENT`,`no such file or directory`,i(e));if(this.isAllowedStrict(e)){let t=await this.resolveAndCheckRead(e);return this.vfs.stat(t)}return this.vfs.stat(e)}scanPathForSymlinks(e,t){let n=i(e);if(n===`/`)return!1;let r=n.slice(1).split(`/`),a=t?r.length:r.length-1,o=``;for(let e=0;e<a;e++){o=o+`/`+r[e];let t=this.vfs.lstatSync(o);if(t===null)return null;if(t.type===`symlink`)return!0}return!1}statSync(e){let t=P[i(e)];return t?t.stat():N.handles(e)?this.ephemeralFds.has(e)?this.ephemeralFds.stat(e):null:!this.isAllowedStrict(e)||this.scanPathForSymlinks(e,!0)!==!1?null:this.vfs.statSync(e)}lstatSync(e){let t=P[i(e)];return t?t.stat():N.handles(e)?this.ephemeralFds.has(e)?this.ephemeralFds.stat(e):null:!this.isAllowed(e)||this.scanPathForSymlinks(e,!1)!==!1?null:this.vfs.lstatSync(e)}readDirSync(e){if(!this.isAllowed(e)||this.scanPathForSymlinks(e,!0)!==!1)return null;let t=this.vfs.readDirSync(e);if(t===null)return null;if(this.isAllowedStrict(e))return t;let n=i(e);return t.filter(e=>{let t=n===`/`?`/${e.name}`:`${n}/${e.name}`;return this.isAllowed(t)})}async realpath(e){if(N.handles(e)){let t=i(e);if(!this.ephemeralFds.has(t))throw new c(`ENOENT`,`no such file or directory`,t);return t}let t;try{t=await this.vfs.realpath(e)}catch(t){throw t instanceof c?t:new c(`ENOENT`,`no such file or directory`,i(e))}if(!this.isAllowedStrict(t))throw new c(`ENOENT`,`no such file or directory`,i(e));return t}async exists(e){if(P[i(e)])return!0;if(N.handles(e))return this.ephemeralFds.has(e);if(!this.isAllowed(e))return!1;if(this.isAllowedStrict(e))try{await this.resolveAndCheckRead(e)}catch{return!1}return this.vfs.exists(e)}async readTextFile(e){let t=P[i(e)];if(t)return t.readText();if(N.handles(e))return this.ephemeralFds.readText(e);if(!this.isAllowedStrict(e))throw new c(`ENOENT`,`no such file or directory`,i(e));let n=await this.resolveAndCheckRead(e);return this.vfs.readTextFile(n)}async*walk(e){if(!this.isAllowed(e))return;let t=e;if(this.isAllowedStrict(e))try{t=await this.resolveAndCheckRead(e)}catch{return}for await(let e of this.vfs.walk(t))this.isAllowed(e)&&(yield e)}async writeFile(e,t,n){let r=P[i(e)];if(r){r.write(t);return}if(N.handles(e)){this.ephemeralFds.write(e,t);return}return await this.checkContentWrite(e),this.vfs.writeFile(e,t,n)}async appendFile(e,t){let n=P[i(e)];if(n){n.write(t);return}if(N.handles(e)){this.ephemeralFds.append(e,t);return}return await this.checkContentWrite(e),this.vfs.appendFile(e,t)}async chmod(e,t){return this.refuseDescriptorTreeOp(e),await this.checkContentWrite(e),this.vfs.chmod(e,t)}async utimes(e,t,n){return this.refuseDescriptorTreeOp(e),await this.checkContentWrite(e),this.vfs.utimes(e,t,n)}async checkContentWrite(e){this.checkWrite(e),await this.checkParentRealpathEscape(e);try{(await this.vfs.lstat(e)).type===`symlink`&&await this.resolveAndCheckWrite(e)}catch(e){if(e instanceof c&&e.code===`EACCES`)throw e}}refuseDescriptorTreeOp(e){if(N.handles(e))throw new c(`EACCES`,`permission denied`,i(e))}async mkdir(e,t){return this.refuseDescriptorTreeOp(e),this.checkWrite(e),await this.checkParentRealpathEscape(e),this.vfs.mkdir(e,t)}async rm(e,t){if(N.handles(e)){if(!this.ephemeralFds.remove(e))throw new c(`ENOENT`,`no such file or directory`,i(e));return}this.checkWrite(e);try{(await this.vfs.lstat(e)).type===`symlink`||await this.resolveAndCheckWrite(e)}catch(e){if(e instanceof c&&e.code===`EACCES`)throw e}return this.vfs.rm(e,t)}async rename(e,t){return this.refuseDescriptorTreeOp(e),this.refuseDescriptorTreeOp(t),this.checkWrite(e),this.checkWrite(t),await this.resolveAndCheckWrite(e),await this.checkParentRealpathEscape(t),this.vfs.rename(e,t)}async copyFile(e,t){if(N.handles(e)){let n=this.ephemeralFds.read(e,{encoding:`binary`});await this.writeFile(t,n);return}if(N.handles(t)){if(!this.isAllowed(e))throw new c(`ENOENT`,`no such file or directory`,i(e));let n=await this.resolveAndCheckRead(e);this.ephemeralFds.write(t,await this.vfs.readFile(n,{encoding:`binary`}));return}if(!this.isAllowed(e))throw new c(`ENOENT`,`no such file or directory`,i(e));this.checkWrite(t);let n=await this.resolveAndCheckRead(e);await this.checkParentRealpathEscape(t);try{(await this.vfs.lstat(t)).type===`symlink`&&await this.resolveAndCheckWrite(t)}catch(e){if(e instanceof c&&e.code===`EACCES`)throw e}return this.vfs.copyFile(n,t)}async symlink(e,t){return this.refuseDescriptorTreeOp(t),this.checkWrite(t),await this.checkParentRealpathEscape(t),this.vfs.symlink(e,t)}async readlink(e){if(!this.isAllowedStrict(e))throw new c(`ENOENT`,`no such file or directory`,i(e));let t=await this.vfs.readlink(e),n;if(t.startsWith(`/`))n=i(t);else{let r=this.vfs.dirname(e);n=i(r+`/`+t)}if(!this.isAllowedStrict(n))throw new c(`ENOENT`,`no such file or directory`,i(e));return t}async lstat(e){let t=P[i(e)];if(t)return t.stat();if(N.handles(e))return this.ephemeralFds.stat(e);if(!this.isAllowed(e))throw new c(`ENOENT`,`no such file or directory`,i(e));let n=i(e),r=this.vfs.dirname(n),a=this.vfs.basename(n),o;if(r===n)o=r;else try{o=await this.vfs.realpath(r)}catch{throw new c(`ENOENT`,`no such file or directory`,n)}let s=o===`/`?`/${a}`:`${o}/${a}`;if(!this.isAllowed(s))throw new c(`ENOENT`,`no such file or directory`,n);return this.vfs.lstat(s)}watch(e,t,n){if(!this.isAllowed(e))throw new c(`EACCES`,`permission denied`,i(e));let r=this.vfs.getWatcher();if(!r)throw new c(`EINVAL`,`no watcher configured`);return r.watch(i(e),t,n)}dirname(e){return this.vfs.dirname(e)}basename(e){return this.vfs.basename(e)}async mount(e,t,n){return this.refuseDescriptorTreeOp(e),this.checkWrite(e),await this.checkParentRealpathEscape(e),this.vfs.mount(e,t,n)}async unmount(e){return this.refuseDescriptorTreeOp(e),this.checkWrite(e),await this.checkParentRealpathEscape(e),this.vfs.unmount(e)}listMounts(){let e=this.vfs.listMounts();return this.includeMounts?e:e.filter(e=>this.isAllowedStrict(e))}getMountIndex(){return this.vfs.getMountIndex()}async refreshMount(e,t){return this.refuseDescriptorTreeOp(e),this.checkWrite(e),this.vfs.refreshMount(e,t)}async dispose(){await this.vfs.dispose()}};function L(e,t){if(e instanceof c){let n=`${e.code}: `,r=e.message;throw r.startsWith(n)&&(r=r.slice(n.length)),e.path&&r.endsWith(` '${e.path}'`)&&(r=r.slice(0,r.length-` '${e.path}'`.length)),new c(e.code,r,t)}throw e}const R=[`ENOENT`,`EEXIST`,`ENOTDIR`,`EISDIR`,`ENOTEMPTY`,`EINVAL`,`EACCES`,`ELOOP`,`EBUSY`,`EFBIG`,`EBADF`,`ENOSYS`,`EOPNOTSUPP`,`EXDEV`,`EIO`];function z(e,t){if(e instanceof c)return e;{let n=e instanceof Error?e.message:String(e);if(n.includes(`maximum size exceeded`)||n.includes(`call stack size exceeded`))return new c(`EIO`,`internal overflow, not storage: ${n} — reload the session`,t)}let n=e?.code;if(typeof n==`string`){let r=n;if(R.includes(r)){let n=e instanceof Error?e.message:String(e);return n.startsWith(`${r}: `)&&(n=n.slice(r.length+2),n=n.replace(/, undefined( '[^']*')?$/,``).replace(/ '[^']*'$/,``)),new c(r,n||r,t)}}let r=e instanceof Error?e.message:String(e);return r.includes(`ENOENT`)?new c(`ENOENT`,`no such file or directory`,t):r.includes(`EEXIST`)?new c(`EEXIST`,`file already exists`,t):r.includes(`ENOTDIR`)?new c(`ENOTDIR`,`not a directory`,t):r.includes(`EISDIR`)?new c(`EISDIR`,`is a directory`,t):r.includes(`ENOTEMPTY`)?new c(`ENOTEMPTY`,`directory not empty`,t):r.includes(`ELOOP`)?new c(`ELOOP`,`too many levels of symbolic links`,t):r.includes(`EOPNOTSUPP`)||r.includes(`ENOTSUP`)?new c(`EOPNOTSUPP`,`operation not supported`,t):r.includes(`EXDEV`)?new c(`EXDEV`,`cross-device link`,t):new c(`EINVAL`,r,t)}function B(e){return e===void 0?`absent`:(e&61440)==16384?`directory`:`file`}function V(e,t){return t===`absent`?!1:e.kind===`missing`||e.kind!==t}function H(e){let t=e?.mode;return typeof t==`number`?t:void 0}function U(e,t,n,r=new Set){let i=new Set(n);if(r.size>0){for(let t of Object.keys(e.entries??{}))for(let e of r)if(t===e||t.startsWith(`${e}/`)){i.add(t);break}}let a=[];for(let n of i){let r=e.entries?.[n],i=t.entries?.[n];if(!r||!i)continue;let o=B(H(r));o!==B(H(i))&&a.push({path:n,ownIsDirectory:o===`directory`})}return a}async function W(e,t){let n=t.split(`/`).filter(Boolean),r=n.pop();if(r===void 0)return null;try{let t=e;for(let e of n)t=await t.getDirectoryHandle(e);return await(await t.getFileHandle(r)).getFile()}catch{return null}}async function G(e,t,n,r){try{return await e.lstat(t)}catch(e){let t=z(e,r);if(t.code===`ENOENT`&&n)return null;throw t}}async function K(e,t,r){let a;try{a=await e.readlink(t)}catch(e){throw z(e,r)}return a.startsWith(`/`)?i(a):i(o(n(t).dir,a))}async function q(e,t,n,r,i,a){let o=t===`/`?`/${n}`:`${t}/${n}`;for(;;){let t=await G(e,o,r,i);if(t===null||!t.isSymbolicLink())return{resolved:o,hops:a};if(++a>10)throw new c(`ELOOP`,`too many symbolic links encountered`,i);o=await K(e,o,i)}}async function J(e,t,n){let r=i(n);if(t(r))return r;let a=r.split(`/`).filter(Boolean),o=`/`,s=0;for(let t=0;t<a.length;t++){let n=await q(e,o,a[t],t===a.length-1,r,s);o=n.resolved,s=n.hops}return o}async function Y(e,t,n){return t(n)?n:J(e,t,n)}function X(){try{if(typeof globalThis.navigator?.storage?.getDirectory==`function`)return`opfs`}catch{}return`memory`}function Z(e,t){let n=e.kind===`directory`?`directory`:`file`;return t?{name:e.name,type:n,...e.size===void 0?{}:{size:e.size},...e.lastModified===void 0?{}:{mtime:e.lastModified},...e.ctime===void 0?{}:{ctime:e.ctime},...e.ino===void 0?{}:{ino:e.ino},...e.identity===void 0?{}:{identity:e.identity},...e.dev===void 0?{}:{dev:e.dev},...e.uid===void 0?{}:{uid:e.uid},...e.gid===void 0?{}:{gid:e.gid},...e.mode===void 0?{}:{mode:e.mode}}:{name:e.name,type:n}}function Q(e,t){switch(e.kind){case`local`:case`proc`:return{kind:`local`,mountId:e.mountId,idbHandleKey:t};case`hostfs`:return{kind:`hostfs`,mountId:e.mountId,hostPath:e.getHostPath()};default:return{kind:e.kind===`s3`?`s3`:e.kind===`aem`?`aem`:`da`,mountId:e.mountId,source:e.source,profile:e.profile??`default`}}}var $=class e{lfs;lfsSync;rawLfs=null;rawLfsSync=null;_ready;_readyResolved=!1;backend;mountPoints=new Map;opfsBackendFs=null;opfsHandle=null;mountRoot=``;internalMounts=new Set;watcher=null;dbName;mountSyncChannel=null;mountIndex=new d;static writeChains=new Map;onRepairProgress;constructor(t,n,r,i,a,o){if(this.dbName=t,this.onRepairProgress=a,this.backend=r===`opfs`?`opfs`:`memory`,this.lfs=this.makeDeferredLfs(),this.lfsSync=this.makeDeferredLfsSync(),this._ready=this.backend===`opfs`?e.initOpfsBackend(this,i,n===!0,o):e.initMemoryBackend(this,t,n===!0),this._ready.then(()=>{this._readyResolved=!0},()=>{}),typeof BroadcastChannel<`u`)try{this.mountSyncChannel=new BroadcastChannel(`vfs-mount-sync:${t}`),this.mountSyncChannel.onmessage=e=>{let{type:t,path:n,descriptor:r}=e.data??{};if(t===`mount`&&typeof n==`string`&&r)this.reconstructBackendFromDescriptor(r,n).then(e=>{this.mountPoints.set(n,e),e.kind===`local`&&this.mountIndex.registerMount(n,e.getHandle()),this.watcher?.notify([{type:`modify`,path:n,entryType:`directory`}])}).catch(()=>{});else if(t===`unmount`&&typeof n==`string`){let e=this.mountPoints.get(n);this.mountPoints.delete(n),this.mountIndex.unregisterMount(n),e?.close(),this.watcher?.notify([{type:`modify`,path:n,entryType:`directory`}])}}}catch{}}static opfsInitChains=new Map;static async initOpfsBackend(t,n,r,i){let a=(e.opfsInitChains.get(t.dbName)??Promise.resolve()).catch(()=>{}).then(()=>e.resolveOpfsBackend(t,n,r,i));e.opfsInitChains.set(t.dbName,a);try{await a}finally{e.opfsInitChains.get(t.dbName)===a&&e.opfsInitChains.delete(t.dbName)}}static async resolveOpfsBackend(t,n,r,i){let a=e.opfsBackends.get(t.dbName);if(a&&r)throw new c(`EBUSY`,`Cannot wipe an OPFS backend with live holders`,t.dbName);if(a&&i!==void 0&&a.asyncCache!==i)throw new c(`EBUSY`,`OPFS async cache setting conflicts with the live backend`,t.dbName);let o=n??await e.acquireOpfsHandle(t.dbName,r);await t.withWriteLock(()=>e.seedOpfsMetadataSidecarIfMissing(o));let s=await import(`./dist-CTNUClOy.js`);await e.ensureRootMount(s);let l=`/__opfs__/${t.dbName}`,u=e.opfsBackends.get(t.dbName);if(!u){let{resolveOpfsMount:n}=await import(`./opfs-mount-BN5U6fN-.js`),r=await n({handle:o,dbName:t.dbName,asyncCache:i,onRepairProgress:t.onRepairProgress,withWriteLock:e=>t.withWriteLock(e)});try{s.mount(l,r)}catch{}u={backendFs:r,refs:0,asyncCache:i!==!1,sidecarDirty:{paths:new Set,prefixes:new Set}},e.opfsBackends.set(t.dbName,u)}u.refs+=1,t.opfsBackendFs=u.backendFs.index?u.backendFs:null,t.opfsHandle=o,t.mountRoot=l,t.rawLfs=s.promises,t.rawLfsSync=s}static async initMemoryBackend(t,n,r){let i=await import(`./dist-CTNUClOy.js`);await e.ensureRootMount(i);let a=`/__zenfs__/${n}`,o=e.memoryBackends.get(n);if(o&&r){try{i.umount(a)}catch{}e.memoryBackends.delete(n),o=void 0}o||(o={store:i.InMemory.create({label:n}),refs:0},e.memoryBackends.set(n,o)),o.refs+=1;try{i.mount(a,o.store)}catch{}t.mountRoot=a,t.rawLfs=i.promises,t.rawLfsSync=i,t.opfsBackendFs=null,t.opfsHandle=null}static rootMountReady=null;static memoryBackends=new Map;static opfsBackends=new Map;static async ensureRootMount(t){return e.rootMountReady===null&&(e.rootMountReady=(async()=>{await t.configureSingle({backend:t.InMemory,label:`__vfs_root__`})})()),e.rootMountReady}prefix(e){return this.mountRoot?e===`/`?this.mountRoot:this.mountRoot+e:e}unprefix(e){return!this.mountRoot||!e.startsWith(this.mountRoot)?e:e.slice(this.mountRoot.length)||`/`}makeDeferredLfs(){let e=e=>this.prefix(e),t=e=>this.unprefix(e),n=()=>{if(!this.rawLfs)throw Error(`VirtualFS used before init resolved`);return this.rawLfs};return{readFile:(t,r)=>this._readyResolved?n().readFile(e(t),r):this._ready.then(()=>n().readFile(e(t),r)),writeFile:(t,r,i)=>this._readyResolved?n().writeFile(e(t),r,i):this._ready.then(()=>n().writeFile(e(t),r,i)),appendFile:async(t,r)=>{this._readyResolved||await this._ready,await n().appendFile(e(t),r)},chmod:async(t,r)=>{this._readyResolved||await this._ready,await n().chmod(e(t),r)},utimes:async(t,r,i)=>{this._readyResolved||await this._ready,await n().utimes(e(t),r,i)},readdir:t=>this._readyResolved?n().readdir(e(t)):this._ready.then(()=>n().readdir(e(t))),mkdir:(t,r)=>this._readyResolved?n().mkdir(e(t),r):this._ready.then(()=>n().mkdir(e(t),r)),rmdir:t=>this._readyResolved?n().rmdir(e(t)):this._ready.then(()=>n().rmdir(e(t))),unlink:t=>this._readyResolved?n().unlink(e(t)):this._ready.then(()=>n().unlink(e(t))),rename:(t,r)=>this._readyResolved?n().rename(e(t),e(r)):this._ready.then(()=>n().rename(e(t),e(r))),stat:t=>this._readyResolved?n().stat(e(t)):this._ready.then(()=>n().stat(e(t))),lstat:t=>this._readyResolved?n().lstat(e(t)):this._ready.then(()=>n().lstat(e(t))),symlink:(t,r)=>{let i=t.startsWith(`/`)?e(t):t;return this._readyResolved?n().symlink(i,e(r)):this._ready.then(()=>n().symlink(i,e(r)))},readlink:async r=>(this._readyResolved||await this._ready,t(await n().readlink(e(r)))),truncate:async(t,r)=>{this._readyResolved||await this._ready;let i=n();typeof i.truncate==`function`&&await i.truncate(e(t),r)},realpath:async r=>{this._readyResolved||await this._ready;let i=n();return typeof i.realpath==`function`?t(await i.realpath(e(r))):e(r)}}}makeDeferredLfsSync(){let e=e=>this.prefix(e),t=e=>this.unprefix(e);return{readdirSync:t=>{let n=this.rawLfsSync;return n?.readdirSync?n.readdirSync(e(t)):void 0},statSync:t=>{let n=this.rawLfsSync;return n?.statSync?n.statSync(e(t)):void 0},lstatSync:t=>{let n=this.rawLfsSync;return n?.lstatSync?n.lstatSync(e(t)):void 0},readlinkSync:n=>{let r=this.rawLfsSync;return r?.readlinkSync?t(r.readlinkSync(e(n))):void 0}}}static async seedOpfsMetadataSidecarIfMissing(t){let n=`.metadata.json`;try{let r=await t.getFileHandle(n);if(e.isUsableMetadataDocument(await e.readSidecarText(r)))return;console.warn(`[virtual-fs] metadata sidecar is unparseable (torn write?); reseeding an empty index`)}catch(e){if(e?.name!==`NotFoundError`)throw e}let r=await(await t.getFileHandle(n,{create:!0})).createWritable(),i=JSON.stringify({version:1,maxSize:4294967295,entries:{}});await r.write(i),await r.close()}static async readSidecarText(e){let t;for(let n=0;n<3;n++)try{return await(await e.getFile()).text()}catch(e){if(e?.name!==`NotReadableError`)throw e;t=e}throw t}static isUsableMetadataDocument(e){let t;try{t=JSON.parse(e)}catch{return!1}if(!t||typeof t!=`object`)return!1;let n=t.entries;return!!n&&typeof n==`object`}static async acquireOpfsHandle(e,t){let n=navigator.storage;if(!n?.getDirectory)throw new c(`EINVAL`,`OPFS is not available in this environment`);let r=await n.getDirectory();if(t)try{await r.removeEntry(e,{recursive:!0})}catch{}return r.getDirectoryHandle(e,{create:!0})}static _createSyncForTests(t){return new e(t)}static async create(t){let n=t?.dbName??`browser-fs`,r=t?.wipe===!0,i=t?.backend??X(),a=new e(n,r,i,void 0,t?.onRepairProgress,t?.opfsAsyncCache);try{await a._ready}catch(e){throw a.mountSyncChannel?.close(),e}return r&&await h().catch(()=>{}),a}async flush(){await this.writeOpfsMetadataSidecar()}async writeOpfsMetadataSidecar(){this.backend===`opfs`&&await this.withWriteLock(()=>this.writeOpfsMetadataSidecarUnlocked())}async writeOpfsMetadataSidecarUnlocked(){if(this.backend!==`opfs`)return;let t=this.opfsBackendFs,n=this.opfsHandle;if(!t||!n)return;let r=t.index.toJSON(),i=e.opfsBackends.get(this.dbName)?.sidecarDirty,a=r;if(i){let e=null;try{let t=await n.getFileHandle(`.metadata.json`),r=JSON.parse(await(await t.getFile()).text());r&&typeof r==`object`&&r.entries&&(e=r)}catch{}e&&(await this.auditDirtyKindFlips(r,e,i,n),a=b(e,r,i))}let o=JSON.stringify(y(a)),s=await(await n.getFileHandle(`.metadata.json`,{create:!0})).createWritable();await s.write(o),await s.close(),i&&(i.paths.clear(),i.prefixes.clear())}async auditDirtyKindFlips(e,t,n,r){let i=U(e,t,n.paths,n.prefixes);if(i.length===0)return;let a=x(r),o=this.opfsBackendFs;for(let n of i){let r=await a(n.path).catch(()=>null);if(r!==null&&r.kind!==`missing`&&r.kind===`directory`===n.ownIsDirectory)continue;let i=t.entries?.[n.path];e.entries&&i!==void 0&&(e.entries[n.path]=i);let s=r!==null&&r.kind!==`missing`;s&&(o?.index?.delete(n.path),o?._handles?.delete(n.path)),console.warn(`[virtual-fs] refused to flush in-memory kind flip over sidecar record (#2006)`,{path:n.path,reality:r?.kind??`unverifiable`,evicted:s})}}markSidecarDirty(t,r=`path`){if(this.backend!==`opfs`)return;let a=e.opfsBackends.get(this.dbName)?.sidecarDirty;if(!a)return;let o=i(t);(r===`prefix`?a.prefixes:a.paths).add(o);let{dir:s}=n(o);for(;s!==`/`;)a.paths.add(s),s=n(s).dir}invalidatePaths(e){if(this.backend!==`opfs`||!this.opfsBackendFs)return;let t=this.opfsBackendFs;for(let n of e){let e=i(n);t.index.delete(e),t._handles?.delete(e),this.markSidecarDirty(e)}}async withKindMismatchRetry(e,t){return this.withKindMismatchRetryPaths([e],t)}async withKindMismatchRetryPaths(e,t){try{return await t()}catch(n){let r=n?.code;if(r!==`EISDIR`&&r!==`ENOTDIR`&&r!==`EINVAL`)throw n;for(let n of e)if(await this.reconcileKindMismatch(n).catch(()=>!1))return await t();throw n}}async reconcileKindMismatch(e){if(this.backend!==`opfs`)return!1;let t=this.opfsBackendFs,n=this.opfsHandle;if(!t?.index||!n)return!1;let r=i(e),a=r;try{a=await this.resolveSymlinks(r)}catch{}let o=await x(n)(a),s=B(t.index.get(a)?.mode),c=t._handles?.get(a),l=c?.kind===`directory`?`directory`:c?.kind===`file`?`file`:`absent`,u=V(o,s),d=V(o,l);if(!u&&!d)return!1;if(t.index.delete(a),t._handles?.delete(a),s===`directory`||l===`directory`){let e=`${a}/`;for(let n of[...t.index.keys()])n.startsWith(e)&&t.index.delete(n);if(t._handles)for(let n of[...t._handles.keys()])n.startsWith(e)&&t._handles.delete(n)}return this.markSidecarDirty(a),console.warn(`[virtual-fs] reconciled in-memory kind mismatch (#2006)`,{path:a,reality:o.kind,indexHeld:s,handleHeld:l}),!0}localIdentity(e){return S(`zenfs:${this.backend}:${this.dbName}`,e)}canWrite(e){return!0}setWatcher(e){this.watcher=e}getWatcher(){return this.watcher}async watch(e,t){let n=this.watcher;if(!n)throw new c(`ENOSYS`,`no FsWatcher attached to this VirtualFS`);let r=e.map(e=>n.watch(e,()=>!0,t));return()=>{for(let e of r)e()}}async dispose(){if(this.mountSyncChannel?.close(),this.mountSyncChannel=null,this.watcher?.dispose(),this.watcher=null,this.mountIndex.dispose(),await this.writeOpfsMetadataSidecar(),this.mountRoot){let t=this.backend===`opfs`?e.opfsBackends:e.memoryBackends,n=t.get(this.dbName);if(n&&(--n.refs,n.refs<=0)){t.delete(this.dbName);try{(await import(`./dist-CTNUClOy.js`)).umount(this.mountRoot)}catch{}}}}readDirSync(e){let t=i(e);if(this.findMount(t))return null;let n=this.lfsSync;if(typeof n.readdirSync!=`function`||typeof n.lstatSync!=`function`)return null;try{let e=n.readdirSync(t),r=[];for(let i of e){let e=t===`/`?`/${i}`:`${t}/${i}`;try{let t=n.lstatSync(e),a=t.isSymbolicLink()?`symlink`:t.isDirectory()?`directory`:`file`;r.push(a===`symlink`?{name:i,type:a}:{name:i,type:a,size:t.size,mtime:t.mtimeMs,ctime:t.ctimeMs,...t.ino===void 0?{}:{ino:t.ino,identity:this.localIdentity(t.ino),dev:t.dev},...t.uid===void 0?{}:{uid:t.uid},...t.gid===void 0?{}:{gid:t.gid},mode:t.mode})}catch{}}return r}catch{return null}}statSync(e){let t=i(e);if(this.findMount(t))return null;let r=this.lfsSync;if(typeof r.statSync!=`function`||typeof r.lstatSync!=`function`||typeof r.readlinkSync!=`function`)return null;if(t===`/`)try{let e=r.statSync(t);return{type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs,ino:e.ino,identity:this.localIdentity(e.ino),dev:e.dev,mode:e.mode}}catch{return null}let a=t;for(let e=0;e<=10;e++){let e;try{e=r.lstatSync(a)}catch{return null}if(!e.isSymbolicLink())return{type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs,ino:e.ino,identity:this.localIdentity(e.ino),dev:e.dev,mode:e.mode};let t;try{t=r.readlinkSync(a)}catch{return null}a=t.startsWith(`/`)?i(t):i(o(n(a).dir,t))}return null}lstatSync(e){let t=i(e);if(this.findMount(t))return null;let n=this.lfsSync;if(typeof n.lstatSync!=`function`)return null;if(t===`/`)return this.statSync(t);try{let e=n.lstatSync(t);if(e.isSymbolicLink()){let r=n.readlinkSync?n.readlinkSync(t):``;return{type:`symlink`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs,isSymlink:!0,symlinkTarget:r,ino:e.ino,identity:this.localIdentity(e.ino),dev:e.dev,mode:e.mode}}return{type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs,ino:e.ino,identity:this.localIdentity(e.ino),dev:e.dev,mode:e.mode}}catch{return null}}async mount(e,t,r){let a=i(e);if(this.mountPoints.has(a))throw new c(`EEXIST`,`mount point is already mounted`,a);try{if((await this.lstat(a)).type!==`directory`)throw new c(`ENOTDIR`,`mount point must be a directory`,a);if((await this.readDir(a)).length>0)throw new c(`ENOTEMPTY`,`mount point must be empty to avoid shadowing existing files`,a)}catch(e){if(!(e instanceof c)||e.code!==`ENOENT`)throw e}let{dir:o}=n(a);o!==`/`&&await this.mkdir(o,{recursive:!0});try{await this.lfs.mkdir(a)}catch{}if(this.mountPoints.set(a,t),t.kind===`local`){let e=r?.limits??u(r?.env??{});this.mountIndex.registerMount(a,t.getHandle(),e)}let s=Q(t,a);try{this.mountSyncChannel?.postMessage({type:`mount`,path:a,descriptor:s})}catch{}if(this.watcher?.notify([{type:`modify`,path:a,entryType:`directory`}]),t.kind!==`hostfs`)try{let e={targetPath:a,descriptor:s,createdAt:Date.now()},n=t.kind===`local`?t.getHandle():void 0;await f(e,n)}catch{}}async unmount(e){let t=i(e),n=this.mountPoints.get(t);this.mountPoints.delete(t),this.mountIndex.unregisterMount(t);try{this.mountSyncChannel?.postMessage({type:`unmount`,path:t})}catch{}this.watcher?.notify([{type:`modify`,path:t,entryType:`directory`}]),await n?.close();try{await p(t)}catch{}}async reconstructBackendFromDescriptor(e,t){switch(e.kind){case`local`:{let t=await m(e.idbHandleKey);if(!t)throw Error(`no handle stored for ${e.idbHandleKey}`);return l.fromHandle(t,{mountId:e.mountId})}case`hostfs`:{let{HostFsMountBackend:n}=await import(`./backend-hostfs-CsCDQ3wI.js`);return new n({targetPath:t,hostPath:e.hostPath,mountId:e.mountId})}case`s3`:{let{S3MountBackend:t,RemoteMountCache:n,makeSignedFetchS3:r}=await import(`./mount-BCqk0zUX.js`).then(e=>e.t),i=new n({mountId:e.mountId,ttlMs:3e4});return new t({source:e.source,profile:e.profile,cache:i,mountId:e.mountId,signedFetch:r(e.profile)})}case`da`:{let{DaMountBackend:t,RemoteMountCache:n,makeSignedFetchDa:r}=await import(`./mount-BCqk0zUX.js`).then(e=>e.t),i=new n({mountId:e.mountId,ttlMs:3e4});return new t({source:e.source,profile:e.profile,cache:i,mountId:e.mountId,signedFetch:r()})}case`aem`:{let{AemMountBackend:t,RemoteMountCache:n,makeSignedFetchDa:r}=await import(`./mount-BCqk0zUX.js`).then(e=>e.t),i=new n({mountId:e.mountId,ttlMs:3e4});return new t({source:e.source,profile:e.profile,cache:i,mountId:e.mountId,signedFetch:r()})}}}listMounts(){let e=[];for(let t of this.mountPoints.keys())this.internalMounts.has(t)||e.push(t);return e}listInternalMounts(){return[...this.internalMounts]}listMountPoints(){let e=[];for(let[t,n]of this.mountPoints)this.internalMounts.has(t)||e.push({path:t,kind:n.kind});return e}getMountBackend(e){let t=i(e);return this.mountPoints.get(t)??null}async mountInternal(e,t){let r=i(e);if(this.mountPoints.has(r))throw new c(`EEXIST`,`mount point is already mounted`,r);let{dir:a}=n(r);a!==`/`&&await this.mkdir(a,{recursive:!0});try{await this.lfs.mkdir(r)}catch{}this.mountPoints.set(r,t),this.internalMounts.add(r),this.watcher?.notify([{type:`modify`,path:r,entryType:`directory`}])}async unmountInternal(e){let t=i(e);if(!this.internalMounts.has(t))throw new c(`ENOENT`,`not an internal mount point`,t);let n=this.mountPoints.get(t);this.mountPoints.delete(t),this.internalMounts.delete(t),this.watcher?.notify([{type:`modify`,path:t,entryType:`directory`}]),await n?.close()}getMountIndex(){return this.mountIndex}async refreshMount(e,t){let n=i(e),r=this.mountPoints.get(n);if(!r)throw new c(`ENOENT`,`not a mount point`,n);let a=await r.refresh(t);return r.kind===`local`&&await this.mountIndex.refreshMount(n,u(t?.env??{})),this.watcher?.notify([{type:`modify`,path:n,entryType:`directory`}]),a}isPathUnderMount(e){for(let t of this.mountPoints.keys())if(e===t||e.startsWith(t+`/`))return!0;return!1}findMount(e){let t=null;for(let[n,r]of this.mountPoints)(e===n||e.startsWith(n+`/`))&&(!t||n.length>t.mountPath.length)&&(t={mountPath:n,backend:r});return t?e===t.mountPath?{path:t.mountPath,backend:t.backend,relParts:[]}:{path:t.mountPath,backend:t.backend,relParts:e.slice(t.mountPath.length+1).split(`/`).filter(Boolean)}:null}async readFile(e,t){return this.withKindMismatchRetry(e,()=>this.readFileInner(e,t))}async readFileInner(e,t){let n=i(e),r=this.findMount(n);if(r){if(r.relParts.length===0)throw new c(`EISDIR`,`is a directory`,n);let e=r.relParts.join(`/`);try{let n=await r.backend.readFile(e);return(t?.encoding??`utf-8`)===`utf-8`?new TextDecoder(`utf-8`).decode(n):n}catch(e){L(e,n)}}let a=await this.resolveSymlinks(n);try{return(t?.encoding??`utf-8`)===`utf-8`?await this.lfs.readFile(a,{encoding:`utf8`}):await this.lfs.readFile(a)}catch(e){throw z(e,n)}}async readFileRange(e,t,n){let r=i(e);if(!Number.isInteger(t)||!Number.isInteger(n)||t<0||n<t)throw new c(`EINVAL`,`invalid byte range ${t}-${n}`,r);if(t===n)return new Uint8Array;let a=this.findMount(r),o=a?.backend.readFileRange;if(a&&o){if(a.relParts.length===0)throw new c(`EISDIR`,`is a directory`,r);try{return await o.call(a.backend,a.relParts.join(`/`),t,n)}catch(e){L(e,r)}}let s=await this.sliceNativeFile(r,t,n);if(s)return s;let l=await this.readFile(r,{encoding:`binary`});return new Uint8Array(l.subarray(t,Math.min(n,l.byteLength)))}async sliceNativeFile(e,t,n){try{let r=await this.getNativeFile(e);if(!r)return null;let i=r.slice(t,Math.min(n,r.size));return new Uint8Array(await i.arrayBuffer())}catch{return null}}async getNativeFile(e){let t=i(e),n=this.findMount(t);if(n){let e=n.backend.getNativeFile;if(!e||n.relParts.length===0)return null;try{return await e.call(n.backend,n.relParts.join(`/`))}catch{return null}}let r=this.opfsHandle;if(!r)return null;try{return await W(r,await this.resolveSymlinks(t))}catch{return null}}async writeFile(e,t,n){return this.withKindMismatchRetry(e,()=>this.writeFileInner(e,t,n))}async writeFileInner(e,t,r){let a=i(e),o=this.findMount(a);if(o){if(o.relParts.length===0)throw new c(`EISDIR`,`is a directory`,a);let e=o.relParts.join(`/`),n=!1;try{await this.stat(a),n=!0}catch{}let r=typeof t==`string`?new TextEncoder().encode(t):t instanceof Uint8Array?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(t);try{await o.backend.writeFile(e,r)}catch(e){L(e,a)}this.watcher?.notify([{type:n?`modify`:`create`,path:a,entryType:`file`}]),this.mountIndex.notifyWrite(a);return}let s;try{s=await this.resolveSymlinks(a)}catch{s=a}let l=!1;try{await this.lfs.stat(s),l=!0}catch{}let{dir:u}=n(s);await this.withWriteLock(async()=>{this.markSidecarDirty(s),u!==`/`&&await this.mkdirRecursiveUnlocked(u);let e=typeof t==`string`?new TextEncoder().encode(t).byteLength:(t instanceof Uint8Array,t.byteLength);try{await this.lfs.writeFile(s,t)}catch(e){if(u!==`/`&&e instanceof Error&&e.message.includes(`ENOENT`)){await this.mkdirRecursiveUnlocked(u);try{await this.lfs.writeFile(s,t)}catch(e){throw z(e,a)}}else throw z(e,a)}try{await this.lfs.truncate?.(s,e)}catch(e){throw z(e,a)}}),this.watcher?.notify([{type:l?`modify`:`create`,path:s,entryType:`file`}])}async appendFile(e,t){let r=i(e);await this.withKindMismatchRetry(r,()=>this.withWriteLock(async()=>{if(this.findMount(r)){await this.appendMounted(r,t);return}let e=r,i=!1;try{if(e=await this.resolveSymlinks(r),(await this.lfs.stat(e)).isDirectory())throw new c(`EISDIR`,`is a directory`,r);i=!0}catch(e){let t=z(e,r);if(t.code!==`ENOENT`)throw t}this.markSidecarDirty(e);let{dir:a}=n(e);await this.mkdirRecursiveUnlocked(a);try{await this.lfs.appendFile(e,t)}catch(e){throw z(e,r)}this.watcher?.notify([{type:i?`modify`:`create`,path:e,entryType:`file`}])}))}async appendMounted(e,t){let n=new Uint8Array;try{let t=await this.readFileInner(e,{encoding:`binary`});n=typeof t==`string`?new TextEncoder().encode(t):new Uint8Array(t)}catch(t){let n=z(t,e);if(n.code!==`ENOENT`)throw n}let r=typeof t==`string`?new TextEncoder().encode(t):t,i=new Uint8Array(n.length+r.length);i.set(n),i.set(r,n.length),await this.writeFileInner(e,i)}async chmod(e,t){if(!Number.isInteger(t)||t<0||t>4095)throw new c(`EINVAL`,`invalid file mode`,i(e));await this.changeMetadata(e,e=>this.lfs.chmod(e,t))}async utimes(e,t,n){if(!Number.isFinite(t.getTime())||!Number.isFinite(n.getTime()))throw new c(`EINVAL`,`invalid file time`,i(e));await this.changeMetadata(e,e=>this.lfs.utimes(e,t,n))}async changeMetadata(e,t){let n=i(e);if(this.findMount(n))throw await this.stat(n),new c(`ENOSYS`,`metadata changes are not supported by this mount`,n);await this.withKindMismatchRetry(n,()=>this.withWriteLock(async()=>{let e=await this.resolveSymlinks(n);try{let n=await this.lfs.stat(e);this.markSidecarDirty(e),await t(e),await this.writeOpfsMetadataSidecarUnlocked(),this.watcher?.notify([{type:`modify`,path:e,entryType:n.isDirectory()?`directory`:`file`}])}catch(e){throw z(e,n)}}))}async readDir(e,t){let n=i(e),r=this.findMount(n);return r?this.readDirMounted(n,r,t):this.readDirLocal(n)}async readDirMounted(e,t,n){let r=n?.includeStats===!0?void 0:this.mountIndex.getDirectoryEntries(t.path,e);if(r!==void 0){let t=new Map;for(let e of r)t.set(e.name,{name:e.name,type:e.type});return this.addNestedMountEntries(t,e),[...t.values()]}let i=t.relParts.join(`/`)||`/`,a;try{a=await t.backend.readDir(i,n)}catch(t){L(t,e)}let o=new Map,s=t.backend.listingStatsMatchStat===!0;for(let e of a)o.set(e.name,Z(e,s));return this.addNestedMountEntries(o,e),[...o.values()]}async readDirLocal(e){return this.withKindMismatchRetry(e,()=>this.readDirLocalInner(e))}async readDirLocalInner(e){let t=await this.resolveSymlinks(e);try{let e=await this.lfs.readdir(t),n=[];for(let r of e){let e=await this.statDirEntry(t,r);e&&n.push(e)}return n}catch(t){throw z(t,e)}}async statDirEntry(e,t){let n=e===`/`?`/${t}`:`${e}/${t}`;try{let e=await this.lfs.lstat(n);return e.isSymbolicLink()?{name:t,type:`symlink`}:{name:t,type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs,...e.ino===void 0?{}:{ino:e.ino,identity:this.localIdentity(e.ino),dev:e.dev},...e.uid===void 0?{}:{uid:e.uid},...e.gid===void 0?{}:{gid:e.gid},mode:e.mode}}catch{return null}}addNestedMountEntries(e,t){let n=t===`/`?`/`:`${t}/`;for(let r of this.mountPoints.keys()){if(r===t||!r.startsWith(n))continue;let i=r.slice(n.length);!i||i.includes(`/`)||e.has(i)||e.set(i,{name:i,type:`directory`})}}async withWriteLock(t){let n=this.dbName,r,i=new Promise(e=>{r=e}),a=e.writeChains.get(n)??Promise.resolve();e.writeChains.set(n,i),await a;try{let e=globalThis.navigator?.locks;return this.backend!==`opfs`||typeof e?.request!=`function`?await t():await e.request(`slicc-vfs:${n}`,()=>t())}finally{r(),e.writeChains.get(n)===i&&e.writeChains.delete(n)}}async mkdirRecursiveUnlocked(e){let t=e.split(`/`).filter(Boolean),n=[],r=``;for(let e of t){r+=`/`+e;try{await this.lfs.mkdir(r),n.push(r)}catch(e){if(e instanceof Error&&!e.message.includes(`EEXIST`))throw z(e,r);try{let e=await this.lfs.lstat(r);if(!e.isDirectory()&&!e.isSymbolicLink())throw new c(`ENOTDIR`,`not a directory`,r)}catch(e){if(e instanceof c&&e.code===`ENOTDIR`)throw e}}}return n}async mkdir(e,t){let n=i(e);if(n===`/`)return;let r=this.findMount(n);if(r){if(r.relParts.length===0)return;let e=r.relParts.join(`/`),t=await this.exists(n);try{await r.backend.mkdir(e)}catch(e){L(e,n)}t||this.watcher?.notify([{type:`create`,path:n,entryType:`directory`}]);return}if(t?.recursive){let e=await this.withWriteLock(()=>(this.markSidecarDirty(n),this.mkdirRecursiveUnlocked(n)));e.length>0&&this.watcher?.notify(e.map(e=>({type:`create`,path:e,entryType:`directory`})))}else await this.withWriteLock(async()=>{this.markSidecarDirty(n);try{await this.lfs.mkdir(n)}catch(e){throw z(e,n)}}),this.watcher?.notify([{type:`create`,path:n,entryType:`directory`}])}async rm(e,t){return this.withKindMismatchRetry(i(e),()=>this.rmInner(e,t))}async rmInner(e,t){let n=i(e),r=this.findMount(n);if(r){if(r.relParts.length===0)throw new c(`EINVAL`,`cannot remove a mount point — use unmount`,n);let e;try{e=(await this.stat(n)).type}catch{}let i=r.relParts.join(`/`);try{await r.backend.remove(i,{recursive:t?.recursive})}catch(e){L(e,n)}this.watcher?.notify([{type:`delete`,path:n,entryType:e}]),this.mountIndex.notifyDelete(n);return}try{let e=await this.lfs.lstat(n);await this.withWriteLock(async()=>{e.isSymbolicLink()?await this.lfs.unlink(n):e.isDirectory()?t?.recursive?await this.rmRecursiveUnlocked(n):await this.lfs.rmdir(n):await this.lfs.unlink(n),this.markSidecarDirty(n,`prefix`),await this.writeOpfsMetadataSidecarUnlocked()})}catch(e){throw z(e,n)}this.watcher?.notify([{type:`delete`,path:n}])}async rmRecursiveUnlocked(e){let t=await this.lfs.readdir(e);for(let n of t){let t=e===`/`?`/${n}`:`${e}/${n}`,r=await this.lfs.lstat(t);r.isSymbolicLink()?await this.lfs.unlink(t):r.isDirectory()?await this.rmRecursiveUnlocked(t):await this.lfs.unlink(t)}await this.lfs.rmdir(e)}async stat(e){return this.withKindMismatchRetry(e,()=>this.statInner(e))}async statInner(e){let t=i(e),n=this.findMount(t);if(n){if(n.relParts.length===0)try{let e=await this.lfs.stat(t);return{type:`directory`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs}}catch{return{type:`directory`,size:0,mtime:Date.now(),ctime:Date.now()}}let e=n.relParts.join(`/`);try{let t=await n.backend.stat(e);return{type:t.kind===`directory`?`directory`:`file`,size:t.size,mtime:t.mtime,ctime:t.ctime??t.mtime,...t.ino===void 0?{}:{ino:t.ino},...t.identity===void 0?{}:{identity:t.identity},...t.dev===void 0?{}:{dev:t.dev},...t.uid===void 0?{}:{uid:t.uid},...t.gid===void 0?{}:{gid:t.gid},...t.mode===void 0?{}:{mode:t.mode}}}catch(e){L(e,t)}}let r=await this.resolveSymlinks(t);try{let e=await this.lfs.stat(r);return{type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs,ino:e.ino,dev:e.dev,identity:this.localIdentity(e.ino),uid:e.uid,gid:e.gid,mode:e.mode}}catch(e){throw z(e,t)}}async exists(e){let t=i(e),n=this.findMount(t);if(n){if(n.relParts.length===0)return!0;try{return await this.stat(t),!0}catch{return!1}}try{return await this.stat(t),!0}catch{try{return await this.lfs.lstat(t),!0}catch{return!1}}}async rename(e,t){return this.withKindMismatchRetryPaths([i(e),i(t)],()=>this.renameInner(e,t))}async renameInner(e,t){let n=i(e),r=i(t);if(n===r)return;let a;try{a=await this.lstat(n)}catch{}let o=a?.type,s=this.findMount(n);if(s?.backend.rename){let e=this.findMount(r);if(e&&e.backend===s.backend){let t=!1;try{t=(await s.backend.rename(s.relParts.join(`/`),e.relParts.join(`/`)))?.noop===!0}catch(e){L(e,n)}t||(this.watcher?.notify([{type:`delete`,path:n,entryType:o},{type:`create`,path:r,entryType:o}]),this.mountIndex.notifyRename(n,r));return}}if(a)try{let e=await this.lstat(r);if(v(a,e))return}catch{}try{await this.withWriteLock(async()=>{this.markSidecarDirty(n,`prefix`),this.markSidecarDirty(r,`prefix`),await this.lfs.rename(n,r),await this.writeOpfsMetadataSidecarUnlocked()})}catch(e){throw z(e,n)}this.watcher?.notify([{type:`delete`,path:n,entryType:o},{type:`create`,path:r,entryType:o}]),this.mountIndex.notifyRename(n,r)}async readTextFile(e){return await this.readFile(e,{encoding:`utf-8`})}async*walk(e,t,n=0){yield*w({mountPoints:this.mountPoints,mountIndex:this.mountIndex,realpath:e=>this.realpath(e),readDir:e=>this.readDir(e),stat:e=>this.stat(e)},e,t,n)}async copyFile(e,t){let n=await this.stat(e);if(n.type===`directory`)throw new c(`EISDIR`,`is a directory`,e);try{let e=await this.stat(t);if(v(n,e))return}catch{}let r=await this.readFile(e,{encoding:`binary`});await this.writeFile(t,r)}dirname(e){return n(i(e)).dir}basename(e){return n(i(e)).base}resolveSymlinkTargetPath(e,t){return e.startsWith(`/`)?i(e):i(o(n(t).dir,e))}assertSymlinkCreateAllowed(e,t){if(this.findMount(t))throw new c(`EINVAL`,`symlinks not supported on mounted filesystems`,t);let n=this.resolveSymlinkTargetPath(e,t);if(this.findMount(n))throw new c(`EXDEV`,`cannot create a symlink across a mount boundary to '${n}'`,t)}async symlink(e,t){let r=i(t);this.assertSymlinkCreateAllowed(e,r);let{dir:a}=n(r);await this.withWriteLock(async()=>{a!==`/`&&await this.mkdirRecursiveUnlocked(a);try{await this.lfs.symlink(e,r)}catch(t){if(a!==`/`&&t instanceof Error&&t.message.includes(`ENOENT`)){await this.mkdirRecursiveUnlocked(a);try{await this.lfs.symlink(e,r)}catch(e){throw z(e,r)}}else throw z(t,r)}this.markSidecarDirty(r),await this.writeOpfsMetadataSidecarUnlocked()}),this.watcher?.notify([{type:`create`,path:r,entryType:`symlink`}])}async readlink(e){let t=i(e);try{return await this.lfs.readlink(t)}catch(e){throw z(e,t)}}async lstat(e){let t=i(e);if(this.findMount(t)||t===`/`)return this.stat(t);try{let e=await this.lfs.lstat(t);if(e.isSymbolicLink()){let n=await this.lfs.readlink(t);return{type:`symlink`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs,isSymlink:!0,symlinkTarget:n,ino:e.ino,dev:e.dev,identity:this.localIdentity(e.ino),uid:e.uid,gid:e.gid,mode:e.mode}}return{type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs,ino:e.ino,dev:e.dev,identity:this.localIdentity(e.ino),uid:e.uid,gid:e.gid,mode:e.mode}}catch(e){throw z(e,t)}}async realpath(e){return J(this.lfs,e=>this.findMount(e)!==null,e)}resolveSymlinks(e){return Y(this.lfs,e=>this.findMount(e)!==null,e)}},te=e({FsError:()=>c,FsWatcher:()=>A,MountIndex:()=>d,RestrictedFS:()=>I,VirtualFS:()=>$,joinPath:()=>o,normalizePath:()=>i,pathSegments:()=>r,resolveVfsBackendFromEnv:()=>X,sameFileIdentity:()=>v,splitPath:()=>n,statsFromDirEntry:()=>s});export{A as i,$ as n,I as r,te as t};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-BZsj6rXC.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/buffer-DvhmllZ2.js","assets/opfs-mount-Dnk4pRBr.js","assets/backend-hostfs-Be-dB7Kf.js","assets/api-endpoint-DGxXvrur.js","assets/runtime-env-Dlaokqg1.js","assets/types-D8gIX-W-.js","assets/remote-cache-3KNT1gsp.js","assets/mount-CmqQZ7ym.js","assets/preload-helper-Czpn1I53.js","assets/mime-types-D0xZwlMO.js","assets/base64-ELzoYfwP.js","assets/mount-table-store-dY2IfQ5S.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./preload-helper-Czpn1I53.js";import{t as n}from"./logger-DDBAeTLF.js";import{a as r,i,n as a,r as o,t as s}from"./path-utils-DNJG-zQf.js";import{r as c,t as l}from"./bounded-walk-BjxKWNqp.js";import{n as u,t as d}from"./types-D8gIX-W-.js";import{n as ee,t as te}from"./virtual-device-paths-D45tpPP6.js";import{t as f}from"./same-file-identity-DuEcSmPX.js";import{a as p,i as m,n as h,t as ne}from"./mount-table-store-dY2IfQ5S.js";var g=n(`fs-watcher`),re=0;function _(e,t){return t===`/`||e===t||e.startsWith(t+`/`)}var v=class{registrations=new Map;watch(e,t,n){let r=`fsw-${++re}`;return this.registrations.set(r,{id:r,basePath:e,filter:t,callback:n}),g.debug(`Watch registered`,{id:r,basePath:e}),()=>{this.registrations.delete(r),g.debug(`Watch unregistered`,{id:r})}}notify(e){if(e.length!==0)for(let[,t]of this.registrations){let n=e.filter(e=>_(e.path,t.basePath)&&t.filter(e.path));if(n.length>0)try{t.callback(n)}catch(e){g.error(`Watch callback error`,{id:t.id,error:e instanceof Error?e.message:String(e)})}}}dispose(){this.registrations.clear(),g.debug(`All watchers disposed`)}get size(){return this.registrations.size}},y=n(`mount-index`),ie=400,ae=2e6,oe=`SLICC_MOUNT_INDEX_MAX_DEPTH`,b=`SLICC_MOUNT_INDEX_MAX_ENTRIES`,x=256,S=class extends Error{cause;constructor(e,t){super(e),this.name=`MountIndexAbortError`,this.cause=t}};function C(e){let t=e.map(([e,t])=>`${e}\u0000${t.kind}`).sort(),n=t.length>x?t.slice(0,x):t;return`${t.length}\u0001${n.join(``)}`}async function se(e,t){let n=e.isSameEntry;if(typeof n!=`function`)return!1;try{return await n.call(e,t)}catch{return!1}}function ce(e,t){return e instanceof Map?e.get(t):e[t]}function le(e){let t=e.trim();if(t===``)return;let n=Number(t);if(!(!Number.isInteger(n)||n<=0))return n}function w(e,t,n){let r=ce(e,t);if(r===void 0||r.trim()===``)return n;let i=le(r);return i===void 0?(y.warn(`Ignoring invalid ${t}; expected a positive integer, using default`,{value:r,fallback:n}),n):i}function T(e){return{maxDepth:w(e,oe,ie),maxEntries:w(e,b,ae),skipNoiseDirs:!0}}var E=class{mounts=new Map;listeners=new Set;registerMount(e,t,n=T({})){this.mounts.get(e)?.abortController?.abort();let r=new AbortController,i={handle:t,state:{status:`pending`,indexed:0},files:new Set,directories:new Set,childrenByDirectory:new Map,abortController:r,limits:n};this.mounts.set(e,i),this.notifyListeners(),this.indexMount(e,i,r.signal)}unregisterMount(e){let t=this.mounts.get(e);t&&(t.abortController?.abort(),this.mounts.delete(e),this.notifyListeners())}async refreshMount(e,t){let n=this.mounts.get(e);if(!n)throw Error(`No mount at ${e}`);n.abortController?.abort();let r=new AbortController;n.abortController=r,n.state={status:`pending`,indexed:0},n.files.clear(),n.directories.clear(),n.childrenByDirectory.clear(),t&&(n.limits=t),this.notifyListeners(),await this.indexMount(e,n,r.signal)}isReady(e){return this.mounts.get(e)?.state.status===`ready`}isAnyIndexing(){for(let e of this.mounts.values())if(e.state.status===`indexing`||e.state.status===`pending`)return!0;return!1}dispose(){for(let e of this.mounts.values())e.abortController?.abort();this.mounts.clear(),this.listeners.clear()}getState(e){return this.mounts.get(e)?.state}getFiles(e,t){let n=this.mounts.get(e);if(n?.state.status!==`ready`)return;if(!t)return[...n.files];let r=[];for(let e of n.files)t(e)&&r.push(e);return r}getDirectoryEntries(e,t){let n=this.mounts.get(e);if(n?.state.status!==`ready`)return;let r=n.childrenByDirectory.get(t);if(r)return[...r].map(([e,t])=>({name:e,type:t}))}hasPath(e,t){let n=this.mounts.get(e);if(n?.state.status===`ready`)return n.files.has(t)||n.directories.has(t)}notifyWrite(e){let t=this.findMountForPath(e);if(!t)return;let n=this.mounts.get(t);if(n?.state.status!==`ready`||this.isSkippedNoisePath(t,e,n,`file`))return;n.files.add(e),this.addPathToChildIndex(n,e,`file`);let r=this.parentPath(e);for(;(r===t||r.startsWith(`${t}/`))&&(n.directories.add(r),this.ensureDirectoryChildren(n,r),r!==t);)this.addPathToChildIndex(n,r,`directory`),r=this.parentPath(r)}notifyDelete(e){let t=this.findMountForPath(e);if(!t)return;let n=this.mounts.get(t);if(n?.state.status!==`ready`||this.isSkippedNoisePath(t,e,n,`unknown`))return;n.files.delete(e),n.directories.delete(e);let r=e+`/`;for(let e of n.files)e.startsWith(r)&&n.files.delete(e);for(let e of n.directories)e.startsWith(r)&&n.directories.delete(e);this.removePathFromChildIndex(n,e);for(let t of n.childrenByDirectory.keys())(t===e||t.startsWith(r))&&n.childrenByDirectory.delete(t)}notifyRename(e,t){let n=this.findMountForPath(e);if(!n)return;let r=this.mounts.get(n);if(r?.state.status!==`ready`)return;let i=r.files.has(e)?`file`:r.directories.has(e)?`directory`:`unknown`;if(i===`unknown`||this.isSkippedNoisePath(n,e,r,i))return;if(this.isSkippedNoisePath(n,t,r,i)){this.notifyDelete(e);return}if(i===`file`){r.files.delete(e),r.files.add(t),this.removePathFromChildIndex(r,e),this.addPathToChildIndex(r,t,`file`);return}r.directories.delete(e),r.directories.add(t);let a=e+`/`,o=t+`/`;for(let e of[...r.files])e.startsWith(a)&&(r.files.delete(e),r.files.add(o+e.slice(a.length)));for(let e of[...r.directories])e.startsWith(a)&&(r.directories.delete(e),r.directories.add(o+e.slice(a.length)));this.removePathFromChildIndex(r,e),this.addPathToChildIndex(r,t,`directory`);let s=[...r.childrenByDirectory.entries()].filter(([t])=>t===e||t.startsWith(a));for(let[e]of s)r.childrenByDirectory.delete(e);for(let[n,i]of s){let s=n===e?t:o+n.slice(a.length);r.childrenByDirectory.set(s,i)}}ensureDirectoryChildren(e,t){let n=e.childrenByDirectory.get(t);return n||(n=new Map,e.childrenByDirectory.set(t,n)),n}addPathToChildIndex(e,t,n){let r=t.slice(t.lastIndexOf(`/`)+1);r&&(this.ensureDirectoryChildren(e,this.parentPath(t)).set(r,n),n===`directory`&&this.ensureDirectoryChildren(e,t))}removePathFromChildIndex(e,t){let n=t.slice(t.lastIndexOf(`/`)+1);e.childrenByDirectory.get(this.parentPath(t))?.delete(n)}parentPath(e){let t=e.lastIndexOf(`/`);return t<=0?`/`:e.slice(0,t)}isSkippedNoisePath(e,t,n,r){if(!n.limits.skipNoiseDirs||!t.startsWith(`${e}/`))return!1;let i=t.slice(e.length+1).split(`/`),a=r===`unknown`?n.files.has(t)?`file`:n.directories.has(t)?`directory`:`unknown`:r;for(let e=0;e<i.length;e++){let t=e===i.length-1;if(!(t&&a===`file`)&&!(t&&a===`unknown`&&!l(i[e]))&&l(i[e]))return!0}return!1}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}findMountForPath(e){let t;for(let n of this.mounts.keys())(e===n||e.startsWith(n+`/`))&&(!t||n.length>t.length)&&(t=n);return t}notifyListeners(){for(let e of this.listeners)try{e()}catch{}}async indexMount(e,t,n){t.state={status:`indexing`,indexed:0},this.notifyListeners();try{if(await this.walkHandle(e,t.handle,t,n),n.aborted)return;t.state={status:`ready`,indexed:t.files.size+t.directories.size,total:t.files.size+t.directories.size},t.abortController=null,y.info(`Mount indexed`,{path:e,files:t.files.size,directories:t.directories.size})}catch(r){if(n.aborted)return;let i=r instanceof Error?r.message:String(r),a=r instanceof S?r.cause:`indexing-error`;t.state={status:`error`,indexed:0,error:i,abortCause:a},y.error(`Mount indexing failed`,{path:e,error:i,abortCause:a})}this.notifyListeners()}async walkHandle(e,t,n,r,i=0,a=new Map){if(r.aborted)return;this.enforceWalkBounds(i,n),n.directories.add(e),this.ensureDirectoryChildren(n,e);let o=await this.readChildren(t,r,n);if(r.aborted)return;let s=await this.confirmNoCycle(e,t,o,a),c=this.pushAncestor(a,s,e,t);try{await this.walkChildren(e,o,n,r,i,a)}finally{this.popAncestor(a,s,c)}}enforceWalkBounds(e,t){if(e>t.limits.maxDepth)throw new S(`mount indexing aborted: directory nesting exceeded ${t.limits.maxDepth} levels`,`depth-exceeded`);if(t.directories.size+t.files.size>=t.limits.maxEntries)throw new S(`mount indexing aborted: exceeded ${t.limits.maxEntries} entries`,`entries-exceeded`)}async readChildren(e,t,n){let r=e,i=[];for await(let e of r){if(t.aborted)break;if(n.directories.size+n.files.size+i.length>=n.limits.maxEntries)throw new S(`mount indexing aborted: exceeded ${n.limits.maxEntries} entries`,`entries-exceeded`);i.push(e)}return i}async confirmNoCycle(e,t,n,r){let i=C(n),a=r.get(i);if(a){for(let n of a)if(await se(n.handle,t))throw new S(`mount indexing aborted: self-referential mount cycle detected at ${e} (re-exposes ${n.path})`,`cycle-detected`)}return i}pushAncestor(e,t,n,r){let i=e.get(t);return i||(i=[],e.set(t,i)),i.push({path:n,handle:r,signature:t}),i}popAncestor(e,t,n){n.pop(),n.length===0&&e.delete(t)}async walkChildren(e,t,n,r,i,a){for(let[o,s]of t){if(r.aborted)return;let t=e===`/`?`/${o}`:`${e}/${o}`;if(s.kind===`file`)n.files.add(t),this.addPathToChildIndex(n,t,`file`),n.state.indexed++;else if(s.kind===`directory`){if(n.limits.skipNoiseDirs&&l(o))continue;this.addPathToChildIndex(n,t,`directory`),await this.walkHandle(t,s,n,r,i+1,a)}n.state.indexed%500==0&&(this.notifyListeners(),await new Promise(e=>setTimeout(e,0)))}}},D=new TextEncoder,O=new TextDecoder(`utf-8`,{fatal:!1}),k=class{entries=new Map;static handles(e){return ee(a(e))}has(e){return this.entries.has(a(e))}write(e,t){let n=a(e),r=typeof t==`string`?D.encode(t):new Uint8Array(t),i=Date.now(),o=this.entries.get(n);this.entries.set(n,{bytes:r,mtime:i,ctime:o?.ctime??i})}append(e,t){let n=this.entries.get(a(e))?.bytes??new Uint8Array,r=typeof t==`string`?D.encode(t):t,i=new Uint8Array(n.length+r.length);i.set(n),i.set(r,n.length),this.write(e,i)}read(e,t){let n=this.require(e);return(t?.encoding??`utf-8`)===`utf-8`?O.decode(n.bytes):new Uint8Array(n.bytes)}readText(e){return O.decode(this.require(e).bytes)}stat(e){let t=this.require(e);return{type:`file`,size:t.bytes.length,mtime:t.mtime,ctime:t.ctime}}remove(e){return this.entries.delete(a(e))}require(e){let t=a(e),n=this.entries.get(t);if(!n)throw new d(`ENOENT`,`no such file or directory`,t);return n}},A={[te]:{stat:()=>({type:`file`,size:0,mtime:0,ctime:0}),read:e=>(e?.encoding??`utf-8`)===`utf-8`?``:new Uint8Array,readText:()=>``,write:()=>{}}},j=[`/tmp/`],M=class{ephemeralFds=new k;vfs;allowedPrefixes;readOnlyPrefixes;readGrantPatterns=[];writeEnforcement;includeMounts;constructor(e,t,n=[],r=`hard`,i={}){this.vfs=e;let o=e=>{let t=a(e);return t.endsWith(`/`)?t:t+`/`};this.allowedPrefixes=t.map(o),this.readOnlyPrefixes=n.map(o),this.writeEnforcement=r,this.includeMounts=i.includeMounts!==!1}getAllPrefixes(){let e=this.includeMounts?this.vfs.listMounts().map(e=>e.endsWith(`/`)?e:e+`/`):[];return[...this.allowedPrefixes,...this.readOnlyPrefixes,...e,...j]}setReadGrants(e){this.readGrantPatterns=[];for(let t of new Set(e))this.addReadGrant(t)}addReadGrant(e){let t=e.split(`/`),n=[];for(let e=1;e<t.length;e++)n.push(o(t.slice(0,e).join(`/`)||`/`));this.readGrantPatterns.push({pattern:e,regex:o(e),ancestorRegexes:n})}matchesReadGrant(e){return this.readGrantPatterns.some(t=>t.regex.test(e))}leadsToReadGrant(e){return this.readGrantPatterns.some(t=>t.ancestorRegexes.some(t=>t.test(e)))}isAllowed(e){let t=a(e),n=this.getAllPrefixes();return this.matchesReadGrant(t)||this.leadsToReadGrant(t)||n.some(e=>t===e.slice(0,-1)||t.startsWith(e)||t===`/`||e.startsWith(t+`/`))}isAllowedStrict(e){let t=a(e),n=this.getAllPrefixes();return this.matchesReadGrant(t)||n.some(e=>t===e.slice(0,-1)||t.startsWith(e))}isWritable(e){let t=a(e);return[...this.allowedPrefixes,...j].some(e=>t===e.slice(0,-1)||t.startsWith(e))}canWrite(e){return k.handles(e)||this.isWritable(e)}checkWrite(e){if(this.writeEnforcement!==`sudo-delegated`&&!this.isWritable(e))throw new d(`EACCES`,`permission denied`,a(e))}async resolveAndCheckRead(e){try{let t=await this.vfs.realpath(e);if(!this.isAllowedStrict(t))throw new d(`ENOENT`,`no such file or directory`,a(e));return t}catch(t){throw t instanceof d?t:new d(`ENOENT`,`no such file or directory`,a(e))}}async resolveAndCheckWrite(e){try{let t=await this.vfs.realpath(e);if(!this.isWritable(t)&&!this.isSymlinkEscapeAllowed(t))throw new d(`EACCES`,`permission denied`,a(e));return t}catch(t){throw t instanceof d?t:new d(`EACCES`,`permission denied`,a(e))}}isSymlinkEscapeAllowed(e){return!1}async checkParentRealpathEscape(e){let t=this.vfs.dirname(e),n=this.vfs.basename(e),r;try{r=await this.vfs.realpath(t)}catch(e){if(e instanceof d&&e.code===`EACCES`)throw e;return}let i=r+`/`+n;if(this.isWritable(i))return;let o=a(r)!==a(t);if(!(this.writeEnforcement===`sudo-delegated`&&!o))throw new d(`EACCES`,`permission denied`,a(e))}getUnderlyingFS(){return this.vfs}invalidatePaths(e){this.vfs.invalidatePaths(e)}async flush(){await this.vfs.flush()}isPathUnderMount(e){return this.vfs.isPathUnderMount(e)}async readFile(e,t){let n=A[a(e)];if(n)return n.read(t);if(k.handles(e))return this.ephemeralFds.read(e,t);if(!this.isAllowedStrict(e))throw new d(`ENOENT`,`no such file or directory`,a(e));let r=await this.resolveAndCheckRead(e);return this.vfs.readFile(r,t)}async readFileRange(e,t,n){if(!this.isAllowedStrict(e))throw new d(`ENOENT`,`no such file or directory`,a(e));let r=await this.resolveAndCheckRead(e);return this.vfs.readFileRange(r,t,n)}async getNativeFile(e){if(A[a(e)]||k.handles(e)||!this.isAllowedStrict(e))return null;try{let t=await this.resolveAndCheckRead(e);return await this.vfs.getNativeFile(t)}catch{return null}}async readDir(e,t){if(!this.isAllowed(e))return[];let n=e;if(this.isAllowedStrict(e))try{n=await this.resolveAndCheckRead(e)}catch{return[]}let r=await this.vfs.readDir(n,t);if(!this.isAllowedStrict(e)){let t=a(e);return r.filter(e=>{let n=t===`/`?`/${e.name}`:`${t}/${e.name}`;return this.isAllowed(n)})}return r}async stat(e){let t=A[a(e)];if(t)return t.stat();if(k.handles(e))return this.ephemeralFds.stat(e);if(!this.isAllowed(e))throw new d(`ENOENT`,`no such file or directory`,a(e));if(this.isAllowedStrict(e)){let t=await this.resolveAndCheckRead(e);return this.vfs.stat(t)}return this.vfs.stat(e)}scanPathForSymlinks(e,t){let n=a(e);if(n===`/`)return!1;let r=n.slice(1).split(`/`),i=t?r.length:r.length-1,o=``;for(let e=0;e<i;e++){o=o+`/`+r[e];let t=this.vfs.lstatSync(o);if(t===null)return null;if(t.type===`symlink`)return!0}return!1}statSync(e){let t=A[a(e)];return t?t.stat():k.handles(e)?this.ephemeralFds.has(e)?this.ephemeralFds.stat(e):null:!this.isAllowedStrict(e)||this.scanPathForSymlinks(e,!0)!==!1?null:this.vfs.statSync(e)}lstatSync(e){let t=A[a(e)];return t?t.stat():k.handles(e)?this.ephemeralFds.has(e)?this.ephemeralFds.stat(e):null:!this.isAllowed(e)||this.scanPathForSymlinks(e,!1)!==!1?null:this.vfs.lstatSync(e)}readDirSync(e){if(!this.isAllowed(e)||this.scanPathForSymlinks(e,!0)!==!1)return null;let t=this.vfs.readDirSync(e);if(t===null)return null;if(this.isAllowedStrict(e))return t;let n=a(e);return t.filter(e=>{let t=n===`/`?`/${e.name}`:`${n}/${e.name}`;return this.isAllowed(t)})}async realpath(e){if(k.handles(e)){let t=a(e);if(!this.ephemeralFds.has(t))throw new d(`ENOENT`,`no such file or directory`,t);return t}let t;try{t=await this.vfs.realpath(e)}catch(t){throw t instanceof d?t:new d(`ENOENT`,`no such file or directory`,a(e))}if(!this.isAllowedStrict(t))throw new d(`ENOENT`,`no such file or directory`,a(e));return t}async exists(e){if(A[a(e)])return!0;if(k.handles(e))return this.ephemeralFds.has(e);if(!this.isAllowed(e))return!1;if(this.isAllowedStrict(e))try{await this.resolveAndCheckRead(e)}catch{return!1}return this.vfs.exists(e)}async readTextFile(e){let t=A[a(e)];if(t)return t.readText();if(k.handles(e))return this.ephemeralFds.readText(e);if(!this.isAllowedStrict(e))throw new d(`ENOENT`,`no such file or directory`,a(e));let n=await this.resolveAndCheckRead(e);return this.vfs.readTextFile(n)}async*walk(e){if(!this.isAllowed(e))return;let t=e;if(this.isAllowedStrict(e))try{t=await this.resolveAndCheckRead(e)}catch{return}for await(let e of this.vfs.walk(t))this.isAllowed(e)&&(yield e)}async writeFile(e,t,n){let r=A[a(e)];if(r){r.write(t);return}if(k.handles(e)){this.ephemeralFds.write(e,t);return}return await this.checkContentWrite(e),this.vfs.writeFile(e,t,n)}async appendFile(e,t){let n=A[a(e)];if(n){n.write(t);return}if(k.handles(e)){this.ephemeralFds.append(e,t);return}return await this.checkContentWrite(e),this.vfs.appendFile(e,t)}async chmod(e,t){return this.refuseDescriptorTreeOp(e),await this.checkContentWrite(e),this.vfs.chmod(e,t)}async utimes(e,t,n){return this.refuseDescriptorTreeOp(e),await this.checkContentWrite(e),this.vfs.utimes(e,t,n)}async checkContentWrite(e){this.checkWrite(e),await this.checkParentRealpathEscape(e);try{(await this.vfs.lstat(e)).type===`symlink`&&await this.resolveAndCheckWrite(e)}catch(e){if(e instanceof d&&e.code===`EACCES`)throw e}}refuseDescriptorTreeOp(e){if(k.handles(e))throw new d(`EACCES`,`permission denied`,a(e))}async mkdir(e,t){return this.refuseDescriptorTreeOp(e),this.checkWrite(e),await this.checkParentRealpathEscape(e),this.vfs.mkdir(e,t)}async rm(e,t){if(k.handles(e)){if(!this.ephemeralFds.remove(e))throw new d(`ENOENT`,`no such file or directory`,a(e));return}this.checkWrite(e);try{(await this.vfs.lstat(e)).type===`symlink`||await this.resolveAndCheckWrite(e)}catch(e){if(e instanceof d&&e.code===`EACCES`)throw e}return this.vfs.rm(e,t)}async rename(e,t){return this.refuseDescriptorTreeOp(e),this.refuseDescriptorTreeOp(t),this.checkWrite(e),this.checkWrite(t),await this.resolveAndCheckWrite(e),await this.checkParentRealpathEscape(t),this.vfs.rename(e,t)}async copyFile(e,t){if(k.handles(e)){let n=this.ephemeralFds.read(e,{encoding:`binary`});await this.writeFile(t,n);return}if(k.handles(t)){if(!this.isAllowed(e))throw new d(`ENOENT`,`no such file or directory`,a(e));let n=await this.resolveAndCheckRead(e);this.ephemeralFds.write(t,await this.vfs.readFile(n,{encoding:`binary`}));return}if(!this.isAllowed(e))throw new d(`ENOENT`,`no such file or directory`,a(e));this.checkWrite(t);let n=await this.resolveAndCheckRead(e);await this.checkParentRealpathEscape(t);try{(await this.vfs.lstat(t)).type===`symlink`&&await this.resolveAndCheckWrite(t)}catch(e){if(e instanceof d&&e.code===`EACCES`)throw e}return this.vfs.copyFile(n,t)}async symlink(e,t){return this.refuseDescriptorTreeOp(t),this.checkWrite(t),await this.checkParentRealpathEscape(t),this.vfs.symlink(e,t)}async readlink(e){if(!this.isAllowedStrict(e))throw new d(`ENOENT`,`no such file or directory`,a(e));let t=await this.vfs.readlink(e),n;if(t.startsWith(`/`))n=a(t);else{let r=this.vfs.dirname(e);n=a(r+`/`+t)}if(!this.isAllowedStrict(n))throw new d(`ENOENT`,`no such file or directory`,a(e));return t}async lstat(e){let t=A[a(e)];if(t)return t.stat();if(k.handles(e))return this.ephemeralFds.stat(e);if(!this.isAllowed(e))throw new d(`ENOENT`,`no such file or directory`,a(e));let n=a(e),r=this.vfs.dirname(n),i=this.vfs.basename(n),o;if(r===n)o=r;else try{o=await this.vfs.realpath(r)}catch{throw new d(`ENOENT`,`no such file or directory`,n)}let s=o===`/`?`/${i}`:`${o}/${i}`;if(!this.isAllowed(s))throw new d(`ENOENT`,`no such file or directory`,n);return this.vfs.lstat(s)}watch(e,t,n){if(!this.isAllowed(e))throw new d(`EACCES`,`permission denied`,a(e));let r=this.vfs.getWatcher();if(!r)throw new d(`EINVAL`,`no watcher configured`);return r.watch(a(e),t,n)}dirname(e){return this.vfs.dirname(e)}basename(e){return this.vfs.basename(e)}async mount(e,t,n){return this.refuseDescriptorTreeOp(e),this.checkWrite(e),await this.checkParentRealpathEscape(e),this.vfs.mount(e,t,n)}async unmount(e){return this.refuseDescriptorTreeOp(e),this.checkWrite(e),await this.checkParentRealpathEscape(e),this.vfs.unmount(e)}listMounts(){let e=this.vfs.listMounts();return this.includeMounts?e:e.filter(e=>this.isAllowedStrict(e))}getMountIndex(){return this.vfs.getMountIndex()}async refreshMount(e,t){return this.refuseDescriptorTreeOp(e),this.checkWrite(e),this.vfs.refreshMount(e,t)}async dispose(){await this.vfs.dispose()}};function N(e,t){if(e instanceof d){let n=`${e.code}: `,r=e.message;throw r.startsWith(n)&&(r=r.slice(n.length)),e.path&&r.endsWith(` '${e.path}'`)&&(r=r.slice(0,r.length-` '${e.path}'`.length)),new d(e.code,r,t)}throw e}var ue=[`ENOENT`,`EEXIST`,`ENOTDIR`,`EISDIR`,`ENOTEMPTY`,`EINVAL`,`EACCES`,`ELOOP`,`EBUSY`,`EFBIG`,`EBADF`,`ENOSYS`,`EOPNOTSUPP`,`EXDEV`,`EIO`];function P(e,t){if(e instanceof d)return e;{let n=e instanceof Error?e.message:String(e);if(n.includes(`maximum size exceeded`)||n.includes(`call stack size exceeded`))return new d(`EIO`,`internal overflow, not storage: ${n} — reload the session`,t)}let n=e?.code;if(typeof n==`string`){let r=n;if(ue.includes(r)){let n=e instanceof Error?e.message:String(e);return n.startsWith(`${r}: `)&&(n=n.slice(r.length+2),n=n.replace(/, undefined( '[^']*')?$/,``).replace(/ '[^']*'$/,``)),new d(r,n||r,t)}}let r=e instanceof Error?e.message:String(e);return r.includes(`ENOENT`)?new d(`ENOENT`,`no such file or directory`,t):r.includes(`EEXIST`)?new d(`EEXIST`,`file already exists`,t):r.includes(`ENOTDIR`)?new d(`ENOTDIR`,`not a directory`,t):r.includes(`EISDIR`)?new d(`EISDIR`,`is a directory`,t):r.includes(`ENOTEMPTY`)?new d(`ENOTEMPTY`,`directory not empty`,t):r.includes(`ELOOP`)?new d(`ELOOP`,`too many levels of symbolic links`,t):r.includes(`EOPNOTSUPP`)||r.includes(`ENOTSUP`)?new d(`EOPNOTSUPP`,`operation not supported`,t):r.includes(`EXDEV`)?new d(`EXDEV`,`cross-device link`,t):new d(`EINVAL`,r,t)}var F=61440,I=16384;function L(e){return e===void 0?`absent`:(e&F)===I?`directory`:`file`}function R(e,t){return t===`absent`?!1:e.kind===`missing`||e.kind!==t}function z(e){let t=e?.mode;return typeof t==`number`?t:void 0}function B(e,t,n,r=new Set){let i=new Set(n);if(r.size>0){for(let t of Object.keys(e.entries??{}))for(let e of r)if(t===e||t.startsWith(`${e}/`)){i.add(t);break}}let a=[];for(let n of i){let r=e.entries?.[n],i=t.entries?.[n];if(!r||!i)continue;let o=L(z(r));o!==L(z(i))&&a.push({path:n,ownIsDirectory:o===`directory`})}return a}var V=512,H=class e{kind=`local`;listingStatsMatchStat=!0;source=void 0;profile=void 0;mountId;handle;dirCacheMax;dirCache=new Map;closed=!1;constructor(e,t){this.handle=e,this.mountId=t.mountId,this.dirCacheMax=t.dirCacheMax??V}static fromHandle(t,n){return new e(t,n)}getHandle(){return this.handle}assertOpen(e){if(this.closed)throw new d(`EBADF`,`mount closed`,e)}splitPath(e){return e.replace(/^\/+/,``).replace(/\/+$/,``).split(`/`).filter(e=>e.length>0)}cacheGet(e){let t=this.dirCache.get(e);if(t!==void 0)return this.dirCache.delete(e),this.dirCache.set(e,t),t}cacheSet(e,t){for(this.dirCache.has(e)&&this.dirCache.delete(e),this.dirCache.set(e,t);this.dirCache.size>this.dirCacheMax;){let e=this.dirCache.keys().next();if(e.done)break;this.dirCache.delete(e.value)}}invalidate(e){if(e===``){this.dirCache.clear();return}let t=`${e}/`;for(let n of[...this.dirCache.keys()])(n===e||n.startsWith(t))&&this.dirCache.delete(n)}getDirCacheSize(){return this.dirCache.size}async resolveDirFrom(e,t,n,r=!0){let i=this.handle,a=``,o=0;if(r)for(let t=e.length;t>0;t--){let n=e.slice(0,t).join(`/`),r=this.cacheGet(n);if(r){i=r,a=n,o=t;break}}let s=a;for(;o<e.length;o++){let r=e[o];try{i=await i.getDirectoryHandle(r,{create:n})}catch(r){if(n&&s!==``)return this.invalidate(s),this.resolveDirFrom(e,t,n,!1);throw this.toFsError(r,t)}a=a===``?r:`${a}/${r}`,this.cacheSet(a,i)}return i}async resolveDir(e,t=!1){return this.resolveDirFrom(this.splitPath(e),e,t)}async resolveParent(e,t){let n=this.splitPath(e);if(n.length===0)throw new d(`EISDIR`,`is a directory`,e);let r=n.pop();return{parent:await this.resolveDirFrom(n,e,t),name:r}}async resolveFile(e,t=!1){let{parent:n,name:r}=await this.resolveParent(e,t);try{return await n.getFileHandle(r,{create:t})}catch(t){throw this.toFsError(t,e)}}toFsError(e,t){if(e instanceof d)return e;if(e instanceof DOMException){if(e.name===`NotFoundError`)return new d(`ENOENT`,`no such file or directory`,t);if(e.name===`TypeMismatchError`)return new d(`ENOTDIR`,`not a directory`,t);if(e.name===`NotAllowedError`)return new d(`EACCES`,`permission denied`,t);if(e.name===`InvalidModificationError`)return new d(`ENOTEMPTY`,`directory not empty`,t)}if(e instanceof Error){if(e.name===`NotFound`||e.name===`NotFoundError`)return new d(`ENOENT`,`no such file or directory`,t);if(e.name===`TypeMismatch`||e.name===`TypeMismatchError`)return new d(`ENOTDIR`,`not a directory`,t);if(e.name===`InvalidModification`||e.name===`InvalidModificationError`)return new d(`ENOTEMPTY`,`directory not empty`,t)}return new d(`EINVAL`,e instanceof Error?e.message:String(e),t)}async readDir(e,t){this.assertOpen(e);let n=await this.resolveDir(e),r=[];for await(let[e,i]of n){if(i.kind!==`file`){r.push({name:e,kind:`directory`});continue}if(!t?.includeStats){r.push({name:e,kind:`file`});continue}let n=await i.getFile();r.push({name:e,kind:`file`,size:n.size,lastModified:n.lastModified})}return r}async readFile(e){this.assertOpen(e);let t=await(await this.resolveFile(e)).getFile();return new Uint8Array(await t.arrayBuffer())}async getNativeFile(e){this.assertOpen(e);try{return await(await this.resolveFile(e)).getFile()}catch{return null}}async writeFile(e,t){this.assertOpen(e);let n=await(await this.resolveFile(e,!0)).createWritable();await n.write(t),await n.close()}async stat(e){this.assertOpen(e);let t=this.splitPath(e);if(t.length===0)return{kind:`directory`,size:0,mtime:0};let n=t.pop(),r=await this.resolveDirFrom(t,e,!1);try{let e=await(await r.getFileHandle(n)).getFile();return{kind:`file`,size:e.size,mtime:e.lastModified}}catch(t){let n=this.toFsError(t,e);if(n.code!==`ENOENT`&&n.code!==`ENOTDIR`)throw n}try{let e=await r.getDirectoryHandle(n);this.cacheSet(t.length===0?n:`${t.join(`/`)}/${n}`,e)}catch(t){throw this.toFsError(t,e)}return{kind:`directory`,size:0,mtime:0}}async mkdir(e){this.assertOpen(e),await this.resolveDir(e,!0)}async remove(e,t){this.assertOpen(e);let n=this.splitPath(e);if(n.length===0)throw new d(`EINVAL`,`cannot remove mount root`,e);let r=n.pop(),i=await this.resolveDirFrom(n,e,!1);try{await i.removeEntry(r,{recursive:t?.recursive??!1})}catch(t){throw this.toFsError(t,e)}this.invalidate(n.length===0?r:`${n.join(`/`)}/${r}`)}async refresh(){return this.assertOpen(`/`),this.dirCache.clear(),{added:[],removed:[],changed:[],unchanged:0,errors:[]}}describe(){return{displayName:this.handle.name}}async close(){this.closed=!0,this.dirCache.clear()}};async function U(e,t){let n=t.split(`/`).filter(Boolean),r=n.pop();if(r===void 0)return null;try{let t=e;for(let e of n)t=await t.getDirectoryHandle(e);return await(await t.getFileHandle(r)).getFile()}catch{return null}}function W(e,t){return e===t||e.startsWith(t===`/`?`/`:`${t}/`)}var de=`/.metadata.json`;function G(e){return e.entries&&delete e.entries[de],e}function fe(e,t,n){let r=t.entries??{},i={...e.entries??{}};`/`in r&&(i[`/`]=r[`/`]);for(let e of n.paths)e in r?i[e]=r[e]:delete i[e];for(let e of n.prefixes){for(let t of Object.keys(i))W(t,e)&&delete i[t];for(let t of Object.keys(r))W(t,e)&&(i[t]=r[t])}let{entries:a,...o}=t;return G({...o,entries:i})}var pe=61440,K=16384,q=32768,me=40960;async function he(e,t,n){let r={kindFixed:[],sizesFixed:0,dropped:0,selfEntryDropped:!1,inosReassigned:0,nlinksFixed:0,changed:!1},i=e.entries??{};for(let[e,a]of Object.entries(i)){if(n?.(),e===`/`||typeof a!=`object`||!a)continue;if(e===`/.metadata.json`){delete i[e],r.selfEntryDropped=!0,r.changed=!0;continue}let o=a,s=(o.mode??0)&pe;if(s===me){J(o,r);continue}let c=await t(e);if(c.kind===`missing`){delete i[e],r.dropped+=1,r.changed=!0;continue}J(o,r),_e(e,o,s,c,r)}return ge(i,r),r}function ge(e,t){let n=0;for(let t of Object.values(e)){let e=t;typeof e?.ino==`number`&&(n=Math.max(n,e.ino)),typeof e?.data==`number`&&(n=Math.max(n,e.data))}let r=n+1,i=new Set;for(let[n,a]of Object.entries(e)){if(typeof a!=`object`||!a)continue;let e=a;if(n===`/`){typeof e.ino==`number`&&i.add(e.ino);continue}let o=e.ino;if(typeof o==`number`&&o!==0&&!i.has(o)){i.add(o);continue}e.ino=r,e.data=r+1,i.add(r),r+=2,t.inosReassigned+=1,t.changed=!0}}function J(e,t){e.nlink||(e.nlink=1,t.nlinksFixed+=1,t.changed=!0)}function _e(e,t,n,r,i){if(n===q&&r.kind===`directory`){t.mode=((t.mode??0)&511||493)|K,i.kindFixed.push(`${e} file→dir`),i.changed=!0;return}if(n===K&&r.kind===`file`){t.mode=((t.mode??0)&511||420)|q,t.size=r.size,i.kindFixed.push(`${e} dir→file`),i.changed=!0;return}n===q&&r.kind===`file`&&typeof t.size==`number`&&t.size!==r.size&&(t.size=r.size,i.sizesFixed+=1,i.changed=!0)}function Y(e){return async t=>{let n=t.split(`/`).filter(Boolean),r=e;for(let e=0;e<n.length-1;e+=1)try{r=await r.getDirectoryHandle(n[e])}catch{return{kind:`missing`}}let i=n[n.length-1];if(i===void 0)return{kind:`directory`};try{return{kind:`file`,size:(await(await r.getFileHandle(i)).getFile()).size}}catch{}try{return await r.getDirectoryHandle(i),{kind:`directory`}}catch{return{kind:`missing`}}}}async function ve(e,t,n){try{return await e()}catch(r){let i=null;try{i=await t()}catch{}if(!i?.changed)throw r;return n(i),await e()}}async function ye(e,t){let n;try{let t=await e.getFileHandle(`.metadata.json`),r=JSON.parse(await(await t.getFile()).text());if(!r||typeof r!=`object`||!r.entries)return null;n=r}catch{return null}let r=await he(n,Y(e),t);if(!r.changed)return r;let i=await(await e.getFileHandle(`.metadata.json`,{create:!0})).createWritable();return await i.write(JSON.stringify(n)),await i.close(),r}function X(e,t,n=0){if(!(!Number.isSafeInteger(t)||(t??0)<=0||!Number.isSafeInteger(n)||n<0))return JSON.stringify([e,n,t])}async function be(e,t,n,r){try{return await e.lstat(t)}catch(e){let t=P(e,r);if(t.code===`ENOENT`&&n)return null;throw t}}async function xe(e,t,n){let i;try{i=await e.readlink(t)}catch(e){throw P(e,n)}return i.startsWith(`/`)?a(i):a(s(r(t).dir,i))}async function Se(e,t,n,r,i,a){let o=t===`/`?`/${n}`:`${t}/${n}`;for(;;){let t=await be(e,o,r,i);if(t===null||!t.isSymbolicLink())return{resolved:o,hops:a};if(++a>10)throw new d(`ELOOP`,`too many symbolic links encountered`,i);o=await xe(e,o,i)}}async function Z(e,t,n){let r=a(n);if(t(r))return r;let i=r.split(`/`).filter(Boolean),o=`/`,s=0;for(let t=0;t<i.length;t++){let n=await Se(e,o,i[t],t===i.length-1,r,s);o=n.resolved,s=n.hops}return o}async function Ce(e,t,n){return t(n)?n:Z(e,t,n)}function Q(){try{if(typeof globalThis.navigator?.storage?.getDirectory==`function`)return`opfs`}catch{}return`memory`}function we(e,t){let n=e.kind===`directory`?`directory`:`file`;return t?{name:e.name,type:n,...e.size===void 0?{}:{size:e.size},...e.lastModified===void 0?{}:{mtime:e.lastModified},...e.ctime===void 0?{}:{ctime:e.ctime},...e.ino===void 0?{}:{ino:e.ino},...e.identity===void 0?{}:{identity:e.identity},...e.dev===void 0?{}:{dev:e.dev},...e.uid===void 0?{}:{uid:e.uid},...e.gid===void 0?{}:{gid:e.gid},...e.mode===void 0?{}:{mode:e.mode}}:{name:e.name,type:n}}function Te(e,t){switch(e.kind){case`local`:case`proc`:return{kind:`local`,mountId:e.mountId,idbHandleKey:t};case`hostfs`:return{kind:`hostfs`,mountId:e.mountId,hostPath:e.getHostPath()};default:return{kind:e.kind===`s3`?`s3`:e.kind===`aem`?`aem`:`da`,mountId:e.mountId,source:e.source,profile:e.profile??`default`}}}var $=class e{lfs;lfsSync;rawLfs=null;rawLfsSync=null;_ready;_readyResolved=!1;backend;mountPoints=new Map;opfsBackendFs=null;opfsHandle=null;mountRoot=``;internalMounts=new Set;watcher=null;dbName;mountSyncChannel=null;mountIndex=new E;static writeChains=new Map;onRepairProgress;constructor(t,n,r,i,a,o){if(this.dbName=t,this.onRepairProgress=a,this.backend=r===`opfs`?`opfs`:`memory`,this.lfs=this.makeDeferredLfs(),this.lfsSync=this.makeDeferredLfsSync(),this._ready=this.backend===`opfs`?e.initOpfsBackend(this,i,n===!0,o):e.initMemoryBackend(this,t,n===!0),this._ready.then(()=>{this._readyResolved=!0},()=>{}),typeof BroadcastChannel<`u`)try{this.mountSyncChannel=new BroadcastChannel(`vfs-mount-sync:${t}`),this.mountSyncChannel.onmessage=e=>{let{type:t,path:n,descriptor:r}=e.data??{};if(t===`mount`&&typeof n==`string`&&r)this.reconstructBackendFromDescriptor(r,n).then(e=>{this.mountPoints.set(n,e),e.kind===`local`&&this.mountIndex.registerMount(n,e.getHandle()),this.watcher?.notify([{type:`modify`,path:n,entryType:`directory`}])}).catch(()=>{});else if(t===`unmount`&&typeof n==`string`){let e=this.mountPoints.get(n);this.mountPoints.delete(n),this.mountIndex.unregisterMount(n),e?.close(),this.watcher?.notify([{type:`modify`,path:n,entryType:`directory`}])}}}catch{}}static opfsInitChains=new Map;static async initOpfsBackend(t,n,r,i){let a=(e.opfsInitChains.get(t.dbName)??Promise.resolve()).catch(()=>{}).then(()=>e.resolveOpfsBackend(t,n,r,i));e.opfsInitChains.set(t.dbName,a);try{await a}finally{e.opfsInitChains.get(t.dbName)===a&&e.opfsInitChains.delete(t.dbName)}}static async resolveOpfsBackend(n,r,i,a){let o=e.opfsBackends.get(n.dbName);if(o&&i)throw new d(`EBUSY`,`Cannot wipe an OPFS backend with live holders`,n.dbName);if(o&&a!==void 0&&o.asyncCache!==a)throw new d(`EBUSY`,`OPFS async cache setting conflicts with the live backend`,n.dbName);let s=r??await e.acquireOpfsHandle(n.dbName,i);await n.withWriteLock(()=>e.seedOpfsMetadataSidecarIfMissing(s));let c=await t(()=>import(`./dist-BZsj6rXC.js`),__vite__mapDeps([0,1,2]));await e.ensureRootMount(c);let l=`/__opfs__/${n.dbName}`,u=e.opfsBackends.get(n.dbName);if(!u){let{resolveOpfsMount:r}=await t(async()=>{let{resolveOpfsMount:e}=await import(`./opfs-mount-Dnk4pRBr.js`);return{resolveOpfsMount:e}},__vite__mapDeps([3,0,1,2])),i=await r({handle:s,dbName:n.dbName,asyncCache:a,onRepairProgress:n.onRepairProgress,withWriteLock:e=>n.withWriteLock(e)});try{c.mount(l,i)}catch{}u={backendFs:i,refs:0,asyncCache:a!==!1,sidecarDirty:{paths:new Set,prefixes:new Set}},e.opfsBackends.set(n.dbName,u)}u.refs+=1,n.opfsBackendFs=u.backendFs.index?u.backendFs:null,n.opfsHandle=s,n.mountRoot=l,n.rawLfs=c.promises,n.rawLfsSync=c}static async initMemoryBackend(n,r,i){let a=await t(()=>import(`./dist-BZsj6rXC.js`),__vite__mapDeps([0,1,2]));await e.ensureRootMount(a);let o=`/__zenfs__/${r}`,s=e.memoryBackends.get(r);if(s&&i){try{a.umount(o)}catch{}e.memoryBackends.delete(r),s=void 0}s||(s={store:a.InMemory.create({label:r}),refs:0},e.memoryBackends.set(r,s)),s.refs+=1;try{a.mount(o,s.store)}catch{}n.mountRoot=o,n.rawLfs=a.promises,n.rawLfsSync=a,n.opfsBackendFs=null,n.opfsHandle=null}static rootMountReady=null;static memoryBackends=new Map;static opfsBackends=new Map;static async ensureRootMount(t){return e.rootMountReady===null&&(e.rootMountReady=(async()=>{await t.configureSingle({backend:t.InMemory,label:`__vfs_root__`})})()),e.rootMountReady}prefix(e){return this.mountRoot?e===`/`?this.mountRoot:this.mountRoot+e:e}unprefix(e){return!this.mountRoot||!e.startsWith(this.mountRoot)?e:e.slice(this.mountRoot.length)||`/`}makeDeferredLfs(){let e=e=>this.prefix(e),t=e=>this.unprefix(e),n=()=>{if(!this.rawLfs)throw Error(`VirtualFS used before init resolved`);return this.rawLfs};return{readFile:(t,r)=>this._readyResolved?n().readFile(e(t),r):this._ready.then(()=>n().readFile(e(t),r)),writeFile:(t,r,i)=>this._readyResolved?n().writeFile(e(t),r,i):this._ready.then(()=>n().writeFile(e(t),r,i)),appendFile:async(t,r)=>{this._readyResolved||await this._ready,await n().appendFile(e(t),r)},chmod:async(t,r)=>{this._readyResolved||await this._ready,await n().chmod(e(t),r)},utimes:async(t,r,i)=>{this._readyResolved||await this._ready,await n().utimes(e(t),r,i)},readdir:t=>this._readyResolved?n().readdir(e(t)):this._ready.then(()=>n().readdir(e(t))),mkdir:(t,r)=>this._readyResolved?n().mkdir(e(t),r):this._ready.then(()=>n().mkdir(e(t),r)),rmdir:t=>this._readyResolved?n().rmdir(e(t)):this._ready.then(()=>n().rmdir(e(t))),unlink:t=>this._readyResolved?n().unlink(e(t)):this._ready.then(()=>n().unlink(e(t))),rename:(t,r)=>this._readyResolved?n().rename(e(t),e(r)):this._ready.then(()=>n().rename(e(t),e(r))),stat:t=>this._readyResolved?n().stat(e(t)):this._ready.then(()=>n().stat(e(t))),lstat:t=>this._readyResolved?n().lstat(e(t)):this._ready.then(()=>n().lstat(e(t))),symlink:(t,r)=>{let i=t.startsWith(`/`)?e(t):t;return this._readyResolved?n().symlink(i,e(r)):this._ready.then(()=>n().symlink(i,e(r)))},readlink:async r=>(this._readyResolved||await this._ready,t(await n().readlink(e(r)))),truncate:async(t,r)=>{this._readyResolved||await this._ready;let i=n();typeof i.truncate==`function`&&await i.truncate(e(t),r)},realpath:async r=>{this._readyResolved||await this._ready;let i=n();return typeof i.realpath==`function`?t(await i.realpath(e(r))):e(r)}}}makeDeferredLfsSync(){let e=e=>this.prefix(e),t=e=>this.unprefix(e);return{readdirSync:t=>{let n=this.rawLfsSync;return n?.readdirSync?n.readdirSync(e(t)):void 0},statSync:t=>{let n=this.rawLfsSync;return n?.statSync?n.statSync(e(t)):void 0},lstatSync:t=>{let n=this.rawLfsSync;return n?.lstatSync?n.lstatSync(e(t)):void 0},readlinkSync:n=>{let r=this.rawLfsSync;return r?.readlinkSync?t(r.readlinkSync(e(n))):void 0}}}static async seedOpfsMetadataSidecarIfMissing(t){let n=`.metadata.json`;try{let r=await t.getFileHandle(n);if(e.isUsableMetadataDocument(await e.readSidecarText(r)))return;console.warn(`[virtual-fs] metadata sidecar is unparseable (torn write?); reseeding an empty index`)}catch(e){if(e?.name!==`NotFoundError`)throw e}let r=await(await t.getFileHandle(n,{create:!0})).createWritable(),i=JSON.stringify({version:1,maxSize:4294967295,entries:{}});await r.write(i),await r.close()}static async readSidecarText(e){let t;for(let n=0;n<3;n++)try{return await(await e.getFile()).text()}catch(e){if(e?.name!==`NotReadableError`)throw e;t=e}throw t}static isUsableMetadataDocument(e){let t;try{t=JSON.parse(e)}catch{return!1}if(!t||typeof t!=`object`)return!1;let n=t.entries;return!!n&&typeof n==`object`}static async acquireOpfsHandle(e,t){let n=navigator.storage;if(!n?.getDirectory)throw new d(`EINVAL`,`OPFS is not available in this environment`);let r=await n.getDirectory();if(t)try{await r.removeEntry(e,{recursive:!0})}catch{}return r.getDirectoryHandle(e,{create:!0})}static _createSyncForTests(t){return new e(t)}static async create(t){let n=t?.dbName??`browser-fs`,r=t?.wipe===!0,i=t?.backend??Q(),a=new e(n,r,i,void 0,t?.onRepairProgress,t?.opfsAsyncCache);try{await a._ready}catch(e){throw a.mountSyncChannel?.close(),e}return r&&await ne().catch(()=>{}),a}async flush(){await this.writeOpfsMetadataSidecar()}async writeOpfsMetadataSidecar(){this.backend===`opfs`&&await this.withWriteLock(()=>this.writeOpfsMetadataSidecarUnlocked())}async writeOpfsMetadataSidecarUnlocked(){if(this.backend!==`opfs`)return;let t=this.opfsBackendFs,n=this.opfsHandle;if(!t||!n)return;let r=t.index.toJSON(),i=e.opfsBackends.get(this.dbName)?.sidecarDirty,a=r;if(i){let e=null;try{let t=await n.getFileHandle(`.metadata.json`),r=JSON.parse(await(await t.getFile()).text());r&&typeof r==`object`&&r.entries&&(e=r)}catch{}e&&(await this.auditDirtyKindFlips(r,e,i,n),a=fe(e,r,i))}let o=JSON.stringify(G(a)),s=await(await n.getFileHandle(`.metadata.json`,{create:!0})).createWritable();await s.write(o),await s.close(),i&&(i.paths.clear(),i.prefixes.clear())}async auditDirtyKindFlips(e,t,n,r){let i=B(e,t,n.paths,n.prefixes);if(i.length===0)return;let a=Y(r),o=this.opfsBackendFs;for(let n of i){let r=await a(n.path).catch(()=>null);if(r!==null&&r.kind!==`missing`&&r.kind===`directory`===n.ownIsDirectory)continue;let i=t.entries?.[n.path];e.entries&&i!==void 0&&(e.entries[n.path]=i);let s=r!==null&&r.kind!==`missing`;s&&(o?.index?.delete(n.path),o?._handles?.delete(n.path)),console.warn(`[virtual-fs] refused to flush in-memory kind flip over sidecar record (#2006)`,{path:n.path,reality:r?.kind??`unverifiable`,evicted:s})}}markSidecarDirty(t,n=`path`){if(this.backend!==`opfs`)return;let i=e.opfsBackends.get(this.dbName)?.sidecarDirty;if(!i)return;let o=a(t);(n===`prefix`?i.prefixes:i.paths).add(o);let{dir:s}=r(o);for(;s!==`/`;)i.paths.add(s),s=r(s).dir}invalidatePaths(e){if(this.backend!==`opfs`||!this.opfsBackendFs)return;let t=this.opfsBackendFs;for(let n of e){let e=a(n);t.index.delete(e),t._handles?.delete(e),this.markSidecarDirty(e)}}async withKindMismatchRetry(e,t){return this.withKindMismatchRetryPaths([e],t)}async withKindMismatchRetryPaths(e,t){try{return await t()}catch(n){let r=n?.code;if(r!==`EISDIR`&&r!==`ENOTDIR`&&r!==`EINVAL`)throw n;for(let n of e)if(await this.reconcileKindMismatch(n).catch(()=>!1))return await t();throw n}}async reconcileKindMismatch(e){if(this.backend!==`opfs`)return!1;let t=this.opfsBackendFs,n=this.opfsHandle;if(!t?.index||!n)return!1;let r=a(e),i=r;try{i=await this.resolveSymlinks(r)}catch{}let o=await Y(n)(i),s=L(t.index.get(i)?.mode),c=t._handles?.get(i),l=c?.kind===`directory`?`directory`:c?.kind===`file`?`file`:`absent`,u=R(o,s),d=R(o,l);if(!u&&!d)return!1;if(t.index.delete(i),t._handles?.delete(i),s===`directory`||l===`directory`){let e=`${i}/`;for(let n of[...t.index.keys()])n.startsWith(e)&&t.index.delete(n);if(t._handles)for(let n of[...t._handles.keys()])n.startsWith(e)&&t._handles.delete(n)}return this.markSidecarDirty(i),console.warn(`[virtual-fs] reconciled in-memory kind mismatch (#2006)`,{path:i,reality:o.kind,indexHeld:s,handleHeld:l}),!0}localIdentity(e){return X(`zenfs:${this.backend}:${this.dbName}`,e)}canWrite(e){return!0}setWatcher(e){this.watcher=e}getWatcher(){return this.watcher}async watch(e,t){let n=this.watcher;if(!n)throw new d(`ENOSYS`,`no FsWatcher attached to this VirtualFS`);let r=e.map(e=>n.watch(e,()=>!0,t));return()=>{for(let e of r)e()}}async dispose(){if(this.mountSyncChannel?.close(),this.mountSyncChannel=null,this.watcher?.dispose(),this.watcher=null,this.mountIndex.dispose(),await this.writeOpfsMetadataSidecar(),this.mountRoot){let n=this.backend===`opfs`?e.opfsBackends:e.memoryBackends,r=n.get(this.dbName);if(r&&(--r.refs,r.refs<=0)){n.delete(this.dbName);try{(await t(()=>import(`./dist-BZsj6rXC.js`),__vite__mapDeps([0,1,2]))).umount(this.mountRoot)}catch{}}}}readDirSync(e){let t=a(e);if(this.findMount(t))return null;let n=this.lfsSync;if(typeof n.readdirSync!=`function`||typeof n.lstatSync!=`function`)return null;try{let e=n.readdirSync(t),r=[];for(let i of e){let e=t===`/`?`/${i}`:`${t}/${i}`;try{let t=n.lstatSync(e),a=t.isSymbolicLink()?`symlink`:t.isDirectory()?`directory`:`file`;r.push(a===`symlink`?{name:i,type:a}:{name:i,type:a,size:t.size,mtime:t.mtimeMs,ctime:t.ctimeMs,...t.ino===void 0?{}:{ino:t.ino,identity:this.localIdentity(t.ino),dev:t.dev},...t.uid===void 0?{}:{uid:t.uid},...t.gid===void 0?{}:{gid:t.gid},mode:t.mode})}catch{}}return r}catch{return null}}statSync(e){let t=a(e);if(this.findMount(t))return null;let n=this.lfsSync;if(typeof n.statSync!=`function`||typeof n.lstatSync!=`function`||typeof n.readlinkSync!=`function`)return null;if(t===`/`)try{let e=n.statSync(t);return{type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs,ino:e.ino,identity:this.localIdentity(e.ino),dev:e.dev,mode:e.mode}}catch{return null}let i=t;for(let e=0;e<=10;e++){let e;try{e=n.lstatSync(i)}catch{return null}if(!e.isSymbolicLink())return{type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs,ino:e.ino,identity:this.localIdentity(e.ino),dev:e.dev,mode:e.mode};let t;try{t=n.readlinkSync(i)}catch{return null}i=t.startsWith(`/`)?a(t):a(s(r(i).dir,t))}return null}lstatSync(e){let t=a(e);if(this.findMount(t))return null;let n=this.lfsSync;if(typeof n.lstatSync!=`function`)return null;if(t===`/`)return this.statSync(t);try{let e=n.lstatSync(t);if(e.isSymbolicLink()){let r=n.readlinkSync?n.readlinkSync(t):``;return{type:`symlink`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs,isSymlink:!0,symlinkTarget:r,ino:e.ino,identity:this.localIdentity(e.ino),dev:e.dev,mode:e.mode}}return{type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs,ino:e.ino,identity:this.localIdentity(e.ino),dev:e.dev,mode:e.mode}}catch{return null}}async mount(e,t,n){let i=a(e);if(this.mountPoints.has(i))throw new d(`EEXIST`,`mount point is already mounted`,i);try{if((await this.lstat(i)).type!==`directory`)throw new d(`ENOTDIR`,`mount point must be a directory`,i);if((await this.readDir(i)).length>0)throw new d(`ENOTEMPTY`,`mount point must be empty to avoid shadowing existing files`,i)}catch(e){if(!(e instanceof d)||e.code!==`ENOENT`)throw e}let{dir:o}=r(i);o!==`/`&&await this.mkdir(o,{recursive:!0});try{await this.lfs.mkdir(i)}catch{}if(this.mountPoints.set(i,t),t.kind===`local`){let e=n?.limits??T(n?.env??{});this.mountIndex.registerMount(i,t.getHandle(),e)}let s=Te(t,i);try{this.mountSyncChannel?.postMessage({type:`mount`,path:i,descriptor:s})}catch{}if(this.watcher?.notify([{type:`modify`,path:i,entryType:`directory`}]),t.kind!==`hostfs`)try{let e={targetPath:i,descriptor:s,createdAt:Date.now()},n=t.kind===`local`?t.getHandle():void 0;await p(e,n)}catch{}}async unmount(e){let t=a(e),n=this.mountPoints.get(t);this.mountPoints.delete(t),this.mountIndex.unregisterMount(t);try{this.mountSyncChannel?.postMessage({type:`unmount`,path:t})}catch{}this.watcher?.notify([{type:`modify`,path:t,entryType:`directory`}]),await n?.close();try{await m(t)}catch{}}async reconstructBackendFromDescriptor(e,n){switch(e.kind){case`local`:{let t=await h(e.idbHandleKey);if(!t)throw Error(`no handle stored for ${e.idbHandleKey}`);return H.fromHandle(t,{mountId:e.mountId})}case`hostfs`:{let{HostFsMountBackend:r}=await t(async()=>{let{HostFsMountBackend:e}=await import(`./backend-hostfs-Be-dB7Kf.js`);return{HostFsMountBackend:e}},__vite__mapDeps([4,5,6,7,8]));return new r({targetPath:n,hostPath:e.hostPath,mountId:e.mountId})}case`s3`:{let{S3MountBackend:n,RemoteMountCache:r,makeSignedFetchS3:i}=await t(async()=>{let{S3MountBackend:e,RemoteMountCache:t,makeSignedFetchS3:n}=await import(`./mount-CmqQZ7ym.js`);return{S3MountBackend:e,RemoteMountCache:t,makeSignedFetchS3:n}},__vite__mapDeps([9,10,11,12,7,13,1,8])),a=new r({mountId:e.mountId,ttlMs:3e4});return new n({source:e.source,profile:e.profile,cache:a,mountId:e.mountId,signedFetch:i(e.profile)})}case`da`:{let{DaMountBackend:n,RemoteMountCache:r,makeSignedFetchDa:i}=await t(async()=>{let{DaMountBackend:e,RemoteMountCache:t,makeSignedFetchDa:n}=await import(`./mount-CmqQZ7ym.js`);return{DaMountBackend:e,RemoteMountCache:t,makeSignedFetchDa:n}},__vite__mapDeps([9,10,11,12,7,13,1,8])),a=new r({mountId:e.mountId,ttlMs:3e4});return new n({source:e.source,profile:e.profile,cache:a,mountId:e.mountId,signedFetch:i()})}case`aem`:{let{AemMountBackend:n,RemoteMountCache:r,makeSignedFetchDa:i}=await t(async()=>{let{AemMountBackend:e,RemoteMountCache:t,makeSignedFetchDa:n}=await import(`./mount-CmqQZ7ym.js`);return{AemMountBackend:e,RemoteMountCache:t,makeSignedFetchDa:n}},__vite__mapDeps([9,10,11,12,7,13,1,8])),a=new r({mountId:e.mountId,ttlMs:3e4});return new n({source:e.source,profile:e.profile,cache:a,mountId:e.mountId,signedFetch:i()})}}}listMounts(){let e=[];for(let t of this.mountPoints.keys())this.internalMounts.has(t)||e.push(t);return e}listInternalMounts(){return[...this.internalMounts]}listMountPoints(){let e=[];for(let[t,n]of this.mountPoints)this.internalMounts.has(t)||e.push({path:t,kind:n.kind});return e}getMountBackend(e){let t=a(e);return this.mountPoints.get(t)??null}async mountInternal(e,t){let n=a(e);if(this.mountPoints.has(n))throw new d(`EEXIST`,`mount point is already mounted`,n);let{dir:i}=r(n);i!==`/`&&await this.mkdir(i,{recursive:!0});try{await this.lfs.mkdir(n)}catch{}this.mountPoints.set(n,t),this.internalMounts.add(n),this.watcher?.notify([{type:`modify`,path:n,entryType:`directory`}])}async unmountInternal(e){let t=a(e);if(!this.internalMounts.has(t))throw new d(`ENOENT`,`not an internal mount point`,t);let n=this.mountPoints.get(t);this.mountPoints.delete(t),this.internalMounts.delete(t),this.watcher?.notify([{type:`modify`,path:t,entryType:`directory`}]),await n?.close()}getMountIndex(){return this.mountIndex}async refreshMount(e,t){let n=a(e),r=this.mountPoints.get(n);if(!r)throw new d(`ENOENT`,`not a mount point`,n);let i=await r.refresh(t);return r.kind===`local`&&await this.mountIndex.refreshMount(n,T(t?.env??{})),this.watcher?.notify([{type:`modify`,path:n,entryType:`directory`}]),i}isPathUnderMount(e){for(let t of this.mountPoints.keys())if(e===t||e.startsWith(t+`/`))return!0;return!1}findMount(e){let t=null;for(let[n,r]of this.mountPoints)(e===n||e.startsWith(n+`/`))&&(!t||n.length>t.mountPath.length)&&(t={mountPath:n,backend:r});return t?e===t.mountPath?{path:t.mountPath,backend:t.backend,relParts:[]}:{path:t.mountPath,backend:t.backend,relParts:e.slice(t.mountPath.length+1).split(`/`).filter(Boolean)}:null}async readFile(e,t){return this.withKindMismatchRetry(e,()=>this.readFileInner(e,t))}async readFileInner(e,t){let n=a(e),r=this.findMount(n);if(r){if(r.relParts.length===0)throw new d(`EISDIR`,`is a directory`,n);let e=r.relParts.join(`/`);try{let n=await r.backend.readFile(e);return(t?.encoding??`utf-8`)===`utf-8`?new TextDecoder(`utf-8`).decode(n):n}catch(e){N(e,n)}}let i=await this.resolveSymlinks(n);try{return(t?.encoding??`utf-8`)===`utf-8`?await this.lfs.readFile(i,{encoding:`utf8`}):await this.lfs.readFile(i)}catch(e){throw P(e,n)}}async readFileRange(e,t,n){let r=a(e);if(!Number.isInteger(t)||!Number.isInteger(n)||t<0||n<t)throw new d(`EINVAL`,`invalid byte range ${t}-${n}`,r);if(t===n)return new Uint8Array;let i=this.findMount(r),o=i?.backend.readFileRange;if(i&&o){if(i.relParts.length===0)throw new d(`EISDIR`,`is a directory`,r);try{return await o.call(i.backend,i.relParts.join(`/`),t,n)}catch(e){N(e,r)}}let s=await this.sliceNativeFile(r,t,n);if(s)return s;let c=await this.readFile(r,{encoding:`binary`});return new Uint8Array(c.subarray(t,Math.min(n,c.byteLength)))}async sliceNativeFile(e,t,n){try{let r=await this.getNativeFile(e);if(!r)return null;let i=r.slice(t,Math.min(n,r.size));return new Uint8Array(await i.arrayBuffer())}catch{return null}}async getNativeFile(e){let t=a(e),n=this.findMount(t);if(n){let e=n.backend.getNativeFile;if(!e||n.relParts.length===0)return null;try{return await e.call(n.backend,n.relParts.join(`/`))}catch{return null}}let r=this.opfsHandle;if(!r)return null;try{return await U(r,await this.resolveSymlinks(t))}catch{return null}}async writeFile(e,t,n){return this.withKindMismatchRetry(e,()=>this.writeFileInner(e,t,n))}async writeFileInner(e,t,n){let i=a(e),o=this.findMount(i);if(o){if(o.relParts.length===0)throw new d(`EISDIR`,`is a directory`,i);let e=o.relParts.join(`/`),n=!1;try{await this.stat(i),n=!0}catch{}let r=typeof t==`string`?new TextEncoder().encode(t):t instanceof Uint8Array?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(t);try{await o.backend.writeFile(e,r)}catch(e){N(e,i)}this.watcher?.notify([{type:n?`modify`:`create`,path:i,entryType:`file`}]),this.mountIndex.notifyWrite(i);return}let s;try{s=await this.resolveSymlinks(i)}catch{s=i}let c=!1;try{await this.lfs.stat(s),c=!0}catch{}let{dir:l}=r(s);await this.withWriteLock(async()=>{this.markSidecarDirty(s),l!==`/`&&await this.mkdirRecursiveUnlocked(l);let e=typeof t==`string`?new TextEncoder().encode(t).byteLength:(t instanceof Uint8Array,t.byteLength);try{await this.lfs.writeFile(s,t)}catch(e){if(l!==`/`&&e instanceof Error&&e.message.includes(`ENOENT`)){await this.mkdirRecursiveUnlocked(l);try{await this.lfs.writeFile(s,t)}catch(e){throw P(e,i)}}else throw P(e,i)}try{await this.lfs.truncate?.(s,e)}catch(e){throw P(e,i)}}),this.watcher?.notify([{type:c?`modify`:`create`,path:s,entryType:`file`}])}async appendFile(e,t){let n=a(e);await this.withKindMismatchRetry(n,()=>this.withWriteLock(async()=>{if(this.findMount(n)){await this.appendMounted(n,t);return}let e=n,i=!1;try{if(e=await this.resolveSymlinks(n),(await this.lfs.stat(e)).isDirectory())throw new d(`EISDIR`,`is a directory`,n);i=!0}catch(e){let t=P(e,n);if(t.code!==`ENOENT`)throw t}this.markSidecarDirty(e);let{dir:a}=r(e);await this.mkdirRecursiveUnlocked(a);try{await this.lfs.appendFile(e,t)}catch(e){throw P(e,n)}this.watcher?.notify([{type:i?`modify`:`create`,path:e,entryType:`file`}])}))}async appendMounted(e,t){let n=new Uint8Array;try{let t=await this.readFileInner(e,{encoding:`binary`});n=typeof t==`string`?new TextEncoder().encode(t):new Uint8Array(t)}catch(t){let n=P(t,e);if(n.code!==`ENOENT`)throw n}let r=typeof t==`string`?new TextEncoder().encode(t):t,i=new Uint8Array(n.length+r.length);i.set(n),i.set(r,n.length),await this.writeFileInner(e,i)}async chmod(e,t){if(!Number.isInteger(t)||t<0||t>4095)throw new d(`EINVAL`,`invalid file mode`,a(e));await this.changeMetadata(e,e=>this.lfs.chmod(e,t))}async utimes(e,t,n){if(!Number.isFinite(t.getTime())||!Number.isFinite(n.getTime()))throw new d(`EINVAL`,`invalid file time`,a(e));await this.changeMetadata(e,e=>this.lfs.utimes(e,t,n))}async changeMetadata(e,t){let n=a(e);if(this.findMount(n))throw await this.stat(n),new d(`ENOSYS`,`metadata changes are not supported by this mount`,n);await this.withKindMismatchRetry(n,()=>this.withWriteLock(async()=>{let e=await this.resolveSymlinks(n);try{let n=await this.lfs.stat(e);this.markSidecarDirty(e),await t(e),await this.writeOpfsMetadataSidecarUnlocked(),this.watcher?.notify([{type:`modify`,path:e,entryType:n.isDirectory()?`directory`:`file`}])}catch(e){throw P(e,n)}}))}async readDir(e,t){let n=a(e),r=this.findMount(n);return r?this.readDirMounted(n,r,t):this.readDirLocal(n)}async readDirMounted(e,t,n){let r=n?.includeStats===!0?void 0:this.mountIndex.getDirectoryEntries(t.path,e);if(r!==void 0){let t=new Map;for(let e of r)t.set(e.name,{name:e.name,type:e.type});return this.addNestedMountEntries(t,e),[...t.values()]}let i=t.relParts.join(`/`)||`/`,a;try{a=await t.backend.readDir(i,n)}catch(t){N(t,e)}let o=new Map,s=t.backend.listingStatsMatchStat===!0;for(let e of a)o.set(e.name,we(e,s));return this.addNestedMountEntries(o,e),[...o.values()]}async readDirLocal(e){return this.withKindMismatchRetry(e,()=>this.readDirLocalInner(e))}async readDirLocalInner(e){let t=await this.resolveSymlinks(e);try{let e=await this.lfs.readdir(t),n=[];for(let r of e){let e=await this.statDirEntry(t,r);e&&n.push(e)}return n}catch(t){throw P(t,e)}}async statDirEntry(e,t){let n=e===`/`?`/${t}`:`${e}/${t}`;try{let e=await this.lfs.lstat(n);return e.isSymbolicLink()?{name:t,type:`symlink`}:{name:t,type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs,...e.ino===void 0?{}:{ino:e.ino,identity:this.localIdentity(e.ino),dev:e.dev},...e.uid===void 0?{}:{uid:e.uid},...e.gid===void 0?{}:{gid:e.gid},mode:e.mode}}catch{return null}}addNestedMountEntries(e,t){let n=t===`/`?`/`:`${t}/`;for(let r of this.mountPoints.keys()){if(r===t||!r.startsWith(n))continue;let i=r.slice(n.length);!i||i.includes(`/`)||e.has(i)||e.set(i,{name:i,type:`directory`})}}async withWriteLock(t){let n=this.dbName,r,i=new Promise(e=>{r=e}),a=e.writeChains.get(n)??Promise.resolve();e.writeChains.set(n,i),await a;try{let e=globalThis.navigator?.locks;return this.backend!==`opfs`||typeof e?.request!=`function`?await t():await e.request(`slicc-vfs:${n}`,()=>t())}finally{r(),e.writeChains.get(n)===i&&e.writeChains.delete(n)}}async mkdirRecursiveUnlocked(e){let t=e.split(`/`).filter(Boolean),n=[],r=``;for(let e of t){r+=`/`+e;try{await this.lfs.mkdir(r),n.push(r)}catch(e){if(e instanceof Error&&!e.message.includes(`EEXIST`))throw P(e,r);try{let e=await this.lfs.lstat(r);if(!e.isDirectory()&&!e.isSymbolicLink())throw new d(`ENOTDIR`,`not a directory`,r)}catch(e){if(e instanceof d&&e.code===`ENOTDIR`)throw e}}}return n}async mkdir(e,t){let n=a(e);if(n===`/`)return;let r=this.findMount(n);if(r){if(r.relParts.length===0)return;let e=r.relParts.join(`/`),t=await this.exists(n);try{await r.backend.mkdir(e)}catch(e){N(e,n)}t||this.watcher?.notify([{type:`create`,path:n,entryType:`directory`}]);return}if(t?.recursive){let e=await this.withWriteLock(()=>(this.markSidecarDirty(n),this.mkdirRecursiveUnlocked(n)));e.length>0&&this.watcher?.notify(e.map(e=>({type:`create`,path:e,entryType:`directory`})))}else await this.withWriteLock(async()=>{this.markSidecarDirty(n);try{await this.lfs.mkdir(n)}catch(e){throw P(e,n)}}),this.watcher?.notify([{type:`create`,path:n,entryType:`directory`}])}async rm(e,t){return this.withKindMismatchRetry(a(e),()=>this.rmInner(e,t))}async rmInner(e,t){let n=a(e),r=this.findMount(n);if(r){if(r.relParts.length===0)throw new d(`EINVAL`,`cannot remove a mount point — use unmount`,n);let e;try{e=(await this.stat(n)).type}catch{}let i=r.relParts.join(`/`);try{await r.backend.remove(i,{recursive:t?.recursive})}catch(e){N(e,n)}this.watcher?.notify([{type:`delete`,path:n,entryType:e}]),this.mountIndex.notifyDelete(n);return}try{let e=await this.lfs.lstat(n);await this.withWriteLock(async()=>{e.isSymbolicLink()?await this.lfs.unlink(n):e.isDirectory()?t?.recursive?await this.rmRecursiveUnlocked(n):await this.lfs.rmdir(n):await this.lfs.unlink(n),this.markSidecarDirty(n,`prefix`),await this.writeOpfsMetadataSidecarUnlocked()})}catch(e){throw P(e,n)}this.watcher?.notify([{type:`delete`,path:n}])}async rmRecursiveUnlocked(e){let t=await this.lfs.readdir(e);for(let n of t){let t=e===`/`?`/${n}`:`${e}/${n}`,r=await this.lfs.lstat(t);r.isSymbolicLink()?await this.lfs.unlink(t):r.isDirectory()?await this.rmRecursiveUnlocked(t):await this.lfs.unlink(t)}await this.lfs.rmdir(e)}async stat(e){return this.withKindMismatchRetry(e,()=>this.statInner(e))}async statInner(e){let t=a(e),n=this.findMount(t);if(n){if(n.relParts.length===0)try{let e=await this.lfs.stat(t);return{type:`directory`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs}}catch{return{type:`directory`,size:0,mtime:Date.now(),ctime:Date.now()}}let e=n.relParts.join(`/`);try{let t=await n.backend.stat(e);return{type:t.kind===`directory`?`directory`:`file`,size:t.size,mtime:t.mtime,ctime:t.ctime??t.mtime,...t.ino===void 0?{}:{ino:t.ino},...t.identity===void 0?{}:{identity:t.identity},...t.dev===void 0?{}:{dev:t.dev},...t.uid===void 0?{}:{uid:t.uid},...t.gid===void 0?{}:{gid:t.gid},...t.mode===void 0?{}:{mode:t.mode}}}catch(e){N(e,t)}}let r=await this.resolveSymlinks(t);try{let e=await this.lfs.stat(r);return{type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs,ino:e.ino,dev:e.dev,identity:this.localIdentity(e.ino),uid:e.uid,gid:e.gid,mode:e.mode}}catch(e){throw P(e,t)}}async exists(e){let t=a(e),n=this.findMount(t);if(n){if(n.relParts.length===0)return!0;try{return await this.stat(t),!0}catch{return!1}}try{return await this.stat(t),!0}catch{try{return await this.lfs.lstat(t),!0}catch{return!1}}}async rename(e,t){return this.withKindMismatchRetryPaths([a(e),a(t)],()=>this.renameInner(e,t))}async renameInner(e,t){let n=a(e),r=a(t);if(n===r)return;let i;try{i=await this.lstat(n)}catch{}let o=i?.type,s=this.findMount(n);if(s?.backend.rename){let e=this.findMount(r);if(e&&e.backend===s.backend){let t=!1;try{t=(await s.backend.rename(s.relParts.join(`/`),e.relParts.join(`/`)))?.noop===!0}catch(e){N(e,n)}t||(this.watcher?.notify([{type:`delete`,path:n,entryType:o},{type:`create`,path:r,entryType:o}]),this.mountIndex.notifyRename(n,r));return}}if(i)try{let e=await this.lstat(r);if(f(i,e))return}catch{}try{await this.withWriteLock(async()=>{this.markSidecarDirty(n,`prefix`),this.markSidecarDirty(r,`prefix`),await this.lfs.rename(n,r),await this.writeOpfsMetadataSidecarUnlocked()})}catch(e){throw P(e,n)}this.watcher?.notify([{type:`delete`,path:n,entryType:o},{type:`create`,path:r,entryType:o}]),this.mountIndex.notifyRename(n,r)}async readTextFile(e){return await this.readFile(e,{encoding:`utf-8`})}async*walk(e,t,n=0){yield*c({mountPoints:this.mountPoints,mountIndex:this.mountIndex,realpath:e=>this.realpath(e),readDir:e=>this.readDir(e),stat:e=>this.stat(e)},e,t,n)}async copyFile(e,t){let n=await this.stat(e);if(n.type===`directory`)throw new d(`EISDIR`,`is a directory`,e);try{let e=await this.stat(t);if(f(n,e))return}catch{}let r=await this.readFile(e,{encoding:`binary`});await this.writeFile(t,r)}dirname(e){return r(a(e)).dir}basename(e){return r(a(e)).base}resolveSymlinkTargetPath(e,t){return e.startsWith(`/`)?a(e):a(s(r(t).dir,e))}assertSymlinkCreateAllowed(e,t){if(this.findMount(t))throw new d(`EINVAL`,`symlinks not supported on mounted filesystems`,t);let n=this.resolveSymlinkTargetPath(e,t);if(this.findMount(n))throw new d(`EXDEV`,`cannot create a symlink across a mount boundary to '${n}'`,t)}async symlink(e,t){let n=a(t);this.assertSymlinkCreateAllowed(e,n);let{dir:i}=r(n);await this.withWriteLock(async()=>{i!==`/`&&await this.mkdirRecursiveUnlocked(i);try{await this.lfs.symlink(e,n)}catch(t){if(i!==`/`&&t instanceof Error&&t.message.includes(`ENOENT`)){await this.mkdirRecursiveUnlocked(i);try{await this.lfs.symlink(e,n)}catch(e){throw P(e,n)}}else throw P(t,n)}this.markSidecarDirty(n),await this.writeOpfsMetadataSidecarUnlocked()}),this.watcher?.notify([{type:`create`,path:n,entryType:`symlink`}])}async readlink(e){let t=a(e);try{return await this.lfs.readlink(t)}catch(e){throw P(e,t)}}async lstat(e){let t=a(e);if(this.findMount(t)||t===`/`)return this.stat(t);try{let e=await this.lfs.lstat(t);if(e.isSymbolicLink()){let n=await this.lfs.readlink(t);return{type:`symlink`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs,isSymlink:!0,symlinkTarget:n,ino:e.ino,dev:e.dev,identity:this.localIdentity(e.ino),uid:e.uid,gid:e.gid,mode:e.mode}}return{type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs,ino:e.ino,dev:e.dev,identity:this.localIdentity(e.ino),uid:e.uid,gid:e.gid,mode:e.mode}}catch(e){throw P(e,t)}}async realpath(e){return Z(this.lfs,e=>this.findMount(e)!==null,e)}resolveSymlinks(e){return Ce(this.lfs,e=>this.findMount(e)!==null,e)}},Ee=e({FsError:()=>d,FsWatcher:()=>v,MountIndex:()=>E,RestrictedFS:()=>M,VirtualFS:()=>$,joinPath:()=>s,normalizePath:()=>a,pathSegments:()=>i,resolveVfsBackendFromEnv:()=>Q,sameFileIdentity:()=>f,splitPath:()=>r,statsFromDirEntry:()=>u});export{d as FsError,v as FsWatcher,E as MountIndex,M as RestrictedFS,$ as VirtualFS,H as a,ve as i,s as joinPath,X as n,a as normalizePath,i as pathSegments,ye as r,Q as resolveVfsBackendFromEnv,f as sameFileIdentity,r as splitPath,u as statsFromDirEntry,Ee as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./logger-LESFN7Hj.js";import{c as t,d as n,l as r,s as i,u as a}from"./kernel-worker-BbLNbBtI.js";import{t as o}from"./GELATIERE-CLK_MA5a.js";import{a as s,i as c,n as l,t as u}from"./instruction-frontmatter-B48EsYtA.js";const d=e(`gelatiere-store`),f=`/shared/GELATIERE.md`,p=`/shared/.gelatiere`,m=`${p}/suggestions.json`,h=`${p}/state.json`,g=`gelatiere-suggestions`,_=`/workspace/skills/gelatiere/SKILL.md`,ee=`0 3 * * *`,v=24,y=5,b=10,x=40,te=5,ne={arrayKeys:new Set([`allowedCommands`]),scalarKeys:new Set([`intervalHours`,`nightly`,`maxSuggestions`])},S=`awk.basename.cat.column.cut.date.dirname.echo.expr.false.file.find.fold.gelatiere.grep.head.jq.ls.man.memory.mkdir.nl.paste.printf.realpath.rg.sed.seq.sort.stat.tail.tee.test.touch.tr.true.uniq.upskill.wc`.split(`.`),re=/^[A-Za-z0-9][A-Za-z0-9._-]*$/,ie=new Set([`skill`,`use-case`,`tip`,`skill-idea`,`issue`]),C=new Set([`use-case`,`skill-idea`,`issue`]);function w(e){let t=s(e,`GELATIERE.md`),n=u(t.frontmatter,ne),r=c(n.nightly,`nightly`)??`0 3 * * *`;if(r.trim().split(/\s+/).length!==5)throw Error(`nightly must be a 5-field cron expression`);return{allowedCommands:T(n),intervalHours:E(n.intervalHours,`intervalHours`,24),nightly:r.trim(),maxSuggestions:Math.min(10,E(n.maxSuggestions,`maxSuggestions`,5)),instructions:t.body}}function T(e){let t=l(e,`allowedCommands`,[]),n=t.find(e=>!re.test(e));if(n!==void 0)throw Error(`allowedCommands must contain bare command names, not "${n}"`);return[...new Set([...S,...t])]}function E(e,t,n){if(e===void 0)return n;if(typeof e!=`string`)throw Error(`${t} is invalid`);let r=Number(e);if(!Number.isFinite(r)||r<=0)throw Error(`${t} must be positive`);return r}async function D(e){try{return w(await O(e,f))}catch(e){return d.warn(`Could not load valid GELATIERE.md; using built-in default`,{error:pe(e)}),w(o)}}async function O(e,t){let n=await e.readFile(t,{encoding:`utf-8`});return typeof n==`string`?n:new TextDecoder().decode(n)}async function k(e,t){try{return JSON.parse(await O(e,t))}catch{return}}async function A(e){let t=await k(e,m);if(!Array.isArray(t))return[];let n=[];for(let e of t){let t=Y(e,null);if(!t)continue;let{dismissedAt:r,takenAt:i,retargets:a}=e;typeof r==`string`&&r&&(t.dismissedAt=r),typeof i==`string`&&i&&(t.takenAt=i);let o=ae(a);o.length>0&&(t.retargets=o),n.push(t)}return n}function ae(e){return Array.isArray(e)?e.filter(e=>!!e&&typeof e.cone==`string`&&typeof e.at==`string`):[]}async function j(e,t){await e.mkdir(p,{recursive:!0}),await e.writeFile(m,`${JSON.stringify(t,null,2)}\n`)}async function M(e){let t=await k(e,h);if(!t||typeof t!=`object`)return{passes:0};let n=t;return{passes:typeof n.passes==`number`&&n.passes>=0?n.passes:0,...typeof n.lastPassAt==`string`?{lastPassAt:n.lastPassAt}:{},...typeof n.lastTriggeredAt==`string`?{lastTriggeredAt:n.lastTriggeredAt}:{},...typeof n.lastDeliveredAt==`string`?{lastDeliveredAt:n.lastDeliveredAt}:{}}}async function N(e,t){await e.mkdir(p,{recursive:!0}),await e.writeFile(h,`${JSON.stringify(t,null,2)}\n`)}function P(e,t,n){let r=Math.max(...[e.lastPassAt,e.lastTriggeredAt].map(e=>e?Date.parse(e):NaN).filter(e=>!Number.isNaN(e)));return!Number.isFinite(r)||t.getTime()-r>=n*36e5}async function F(e,t=new Date){await N(e,{...await M(e),lastTriggeredAt:t.toISOString()})}function I(e){return e.filter(e=>!e.dismissedAt&&!e.takenAt)}function L(e){return e.filter(e=>!!e.takenAt)}function R(e,t){return I(e).filter(e=>z(e,t))}function z(e,t,n){let r=t?Date.parse(t):NaN;if(Number.isNaN(r))return!0;let i=e=>{let t=Date.parse(e);return Number.isNaN(t)||t>r};return i(e.createdAt)?!0:(e.retargets??[]).some(e=>(n===void 0||e.cone===n)&&i(e.at))}function B(e,t,n,r){return e.filter(e=>{let i=e.cones?.filter(e=>r.has(e))??[];return i.length>0?i.includes(t):t===n})}async function V(e,t,n=new Date){return W(e,t,`dismissedAt`,n)}async function H(e,t,n=new Date){return W(e,t,`takenAt`,n)}let U=Promise.resolve();function W(e,t,n,r){let i=async()=>{let i=await A(e),a=i.find(e=>e.id===t&&!e.dismissedAt&&!e.takenAt);return a?(a[n]=r.toISOString(),await j(e,i),!0):!1},a=U.then(i,i);return U=a.catch(()=>!1),a}const G=/[^a-z0-9]+/g;function K(e){return e.toLowerCase().replace(G,`-`).replace(/^-+|-+$/g,``).slice(0,60)}function q(e,t){if(typeof e!=`string`)return;let n=e.trim();return n?n.slice(0,t):void 0}function J(e){if(e)try{let t=new URL(e).protocol;return t===`http:`||t===`https:`?e:void 0}catch{return}}const oe=/^[A-Za-z0-9@._/:=-]+$/;function se(e){if(!e)return;let t=e.split(/\s+/);if(!(t[0]!==`upskill`||t.length<2))return t.slice(1).every(e=>oe.test(e))?e:void 0}const ce=/^[a-z0-9][a-z0-9_-]*$/i;function le(e){let t=(typeof e==`string`?[e]:Array.isArray(e)?e:[]).map(e=>q(e,80)).filter(e=>e!==void 0&&ce.test(e)),n=[...new Set(t)].slice(0,8);return n.length>0?n:void 0}function Y(e,t){if(!e||typeof e!=`object`)return null;let n=e,r=typeof n.kind==`string`?n.kind:``,i=q(n.title,200),a=q(n.body,1e3);if(!ie.has(r)||!i||!a)return null;let o=K(q(n.id,80)??`${r}-${i}`)||K(`${r}-${i}`);if(!o)return null;let s=t??q(n.createdAt,40)??``,c=n.skill===void 0?void 0:q(n.skill,120),l=n.install===void 0?void 0:se(q(n.install,300)),u=n.prompt===void 0?void 0:q(n.prompt,1e3);if(r===`skill`&&(!c||!l)||C.has(r)&&!u)return null;let d=le(n.cones);return{id:o,kind:r,title:i,body:a,...n.skill===void 0?{}:{skill:c},...n.install===void 0?{}:{install:l},...n.prompt===void 0?{}:{prompt:u},...n.url===void 0?{}:{url:J(q(n.url,500))},...n.evidence===void 0?{}:{evidence:q(n.evidence,500)},...d?{cones:d}:{},createdAt:s}}function X(e,t,n=10){let r=Array.isArray(e)?e:e&&typeof e==`object`&&Array.isArray(e.suggestions)?e.suggestions??[]:[],i=new Set,a=[];for(let e of r){let r=Y(e,t);if(!(!r||i.has(r.id))&&(i.add(r.id),a.push(r),a.length>=n))break}return a}function Z(e,t,n=40){let r=new Map(t.map(e=>[e.id,e])),i=new Set(e.map(e=>e.id)),a=t.filter(e=>!i.has(e.id)),o=[...a,...e.map(e=>ue(e,r.get(e.id)))];for(;o.length>n;){let e=Q(o,e=>!!e.dismissedAt),t=e>=0?e:Q(o,e=>!!e.takenAt);o.splice(t>=0?t:o.length-1,1)}return{merged:o,added:a}}function ue(e,t){if(!t?.cones||e.dismissedAt||e.takenAt)return e;let n=e.cones??[],r=t.cones.filter(e=>!n.includes(e)),i=[...n,...r].slice(0,8),a=r.filter(e=>i.includes(e));if(a.length===0)return e;let o=[...e.retargets??[],...a.map(e=>({cone:e,at:t.createdAt}))];return{...e,cones:i,retargets:o}}function Q(e,t){for(let n=e.length-1;n>=0;--n)if(t(e[n]))return n;return-1}async function de(e,t,n=new Date){let r=await D(e),i=X(t,n.toISOString(),r.maxSuggestions),{merged:a,added:o}=Z(await A(e),i);await j(e,a);let s=await M(e);return await N(e,{...s,passes:s.passes+1,lastPassAt:n.toISOString()}),{added:o,open:I(a)}}function fe(e,t){return{action:g,data:{added:e.length,open:t.length,suggestions:t.slice(0,5),path:m,skill:_}}}function pe(e){return e instanceof Error?e.message:String(e)}function me(e){let t=he(e);if(!t)return null;let{action:n,bag:r}=t;return n===`gelatiere-suggestions`?ge(n,r):n===`session-settled`?_e(n,r):n===`run`?ve(n,r):{action:n,headline:`gelatiere: ${n}`,titles:[]}}function he(e){let t=e.indexOf(`{`),n=e.lastIndexOf(`}`);if(t<0||n<=t)return null;let r;try{r=JSON.parse(e.slice(t,n+1))}catch{return null}if(!r||typeof r!=`object`)return null;let{action:i,data:a}=r;return typeof i==`string`?{action:i,bag:a&&typeof a==`object`?a:{}}:null}function ge(e,t){let n=$(t.suggestions),r=typeof t.added==`number`?t.added:n.length,i=typeof t.open==`number`?t.open:n.length;return{action:e,headline:r===0?`Nothing new — ${i} open ${i===1?`suggestion`:`suggestions`} in the suggestions card.`:`${r} new ${r===1?`suggestion`:`suggestions`} (${i} open) — the cards are in the suggestions sprinkle.`,titles:n}}function $(e){return Array.isArray(e)?e.map(e=>e&&typeof e==`object`?e.title:void 0).filter(e=>typeof e==`string`&&e.length>0):[]}function _e(e,t){let n=typeof t.cone==`string`?t.cone:void 0;return{action:e,headline:n?`A session ended in ${n} — time for a pass.`:`A session ended — time for a pass.`,titles:[]}}function ve(e,t){let n=typeof t.requestedBy==`string`?t.requestedBy:void 0;return{action:e,headline:n?`${n} asked for a pass now.`:`Someone asked for a pass now.`,titles:[]}}export{v as DEFAULT_GELATIERE_INTERVAL_HOURS,o as DEFAULT_GELATIERE_MD,ee as DEFAULT_GELATIERE_NIGHTLY_CRON,y as DEFAULT_MAX_SUGGESTIONS,S as GELATIERE_BASE_ALLOWED_COMMANDS,p as GELATIERE_DIR,i as GELATIERE_FOLDER,f as GELATIERE_INSTRUCTIONS_PATH,t as GELATIERE_NIGHTLY_CRON_NAME,r as GELATIERE_OWNER_JID,_ as GELATIERE_SKILL_PATH,a as GELATIERE_SPRINKLE_NAME,h as GELATIERE_STATE_PATH,g as GELATIERE_SUGGESTIONS_ACTION,m as GELATIERE_SUGGESTIONS_PATH,te as LICK_SUGGESTION_LIMIT,x as MAX_STORED_SUGGESTIONS,b as MAX_SUGGESTIONS_PER_PASS,fe as buildGelatiereLickBody,X as coerceSuggestions,me as describeGelatiereLick,V as dismissGelatiereSuggestion,n as isGelatiereUnit,z as isNewSince,P as isPassDue,D as loadGelatiereConfig,Z as mergeSuggestions,I as openSuggestions,w as parseGelatiereDocument,M as readGelatiereState,A as readGelatiereSuggestions,F as recordGelatiereTrigger,de as recordPass,B as suggestionsForCone,R as suggestionsSince,H as takeGelatiereSuggestion,L as takenSuggestions,N as writeGelatiereState,j as writeGelatiereSuggestions};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/fs-D2K9G9FZ.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/preload-helper-Czpn1I53.js","assets/logger-DDBAeTLF.js","assets/path-utils-DNJG-zQf.js","assets/bounded-walk-BjxKWNqp.js","assets/types-D8gIX-W-.js","assets/virtual-device-paths-D45tpPP6.js","assets/same-file-identity-DuEcSmPX.js","assets/mount-table-store-dY2IfQ5S.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{t as e}from"./preload-helper-Czpn1I53.js";import"./proxied-fetch-CUw_f_qQ.js";import{G as t,f as n,u as r}from"./account-store-Bdv0oQNY.js";import{i}from"./api-endpoint-DGxXvrur.js";import{u as a,x as o}from"./main-DfK3SKJC.js";import{r as s,t as c}from"./silent-renew-backoff-Cillu2Yi.js";import{getOAuthPageOrigin as l,resolveOAuthDelegation as u}from"./oauth-service-JZ31fJQ0.js";import{t as d}from"./global-db-CbuLl-zx.js";var f={clientId:``,scopes:`repo,read:user,user:email`};function p(){try{let e=localStorage.getItem(o);if(e)return e.replace(/\/$/,``)}catch{}return a}function m(e){return{access_token:e.access_token,token_type:e.token_type,scope:e.scope,refresh_token:e.refresh_token,expires_in:e.expires_in}}async function h(e){let t;try{t=await e.json()}catch{throw Error(`Token exchange failed (HTTP ${e.status}): non-JSON response`)}if(!e.ok&&e.status!==200){let n=t.error_description??t.error??`Token exchange failed (HTTP ${e.status})`;throw Error(n)}if(t.error){let e=t.error_description??t.error;throw Error(e)}return m(t)}async function g(e){let t=`${p()}/oauth/token`;return h(await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e.provider,code:e.code,redirect_uri:e.redirectUri})}))}async function _(e){let t=`${p()}/oauth/token`;return h(await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e.provider,refresh_token:e.refreshToken})}))}async function v(e){let t=`${p()}/oauth/revoke`,n=await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e.provider,access_token:e.accessToken})});if(!(n.status===204||n.ok)){if(n.status===400)try{if((await n.json()).error===`unsupported`)return}catch{}throw Error(`Token revocation failed (HTTP ${n.status})`)}}var y=Object.assign({"/packages/webapp/providers/github-config.json":f})[`/packages/webapp/providers/github-config.json`]??{clientId:``,scopes:`repo,read:user,user:email`},b=null,x=null;function S(e){let{isExtension:t,isConnectMode:n,workerBaseUrl:r,pageOrigin:i,pageHref:a,bridgeApiBaseUrl:o,extensionId:c,nonce:l}=e;if(t)return{redirectUri:`${r}/auth/callback`,state:{source:`extension`,extensionId:c,path:`/github`,nonce:l}};if(e.delegated)return{redirectUri:`${e.runtimeWorkerBaseUrl??r}/auth/callback`,state:{source:`opener`,path:`/auth/callback`,nonce:l}};if(n){let e=i??``;if(/^https?:\/\/(localhost|127\.0\.0\.1):\d+$/.test(e)){let t=parseInt(new URL(a??e).port||`8790`,10);return{redirectUri:`${r}/auth/callback`,state:{source:`local`,port:t,path:`/auth/callback`,nonce:l}}}return{redirectUri:`${r}/auth/callback`,state:{source:`remote`,origin:e,path:`/auth/callback`,nonce:l}}}if(o&&a&&s(a)){let t=null;try{let e=new URL(o);(e.hostname===`localhost`||e.hostname===`127.0.0.1`)&&(t=parseInt(e.port||`5710`,10))}catch{t=null}if(t!==null&&!Number.isNaN(t))return{redirectUri:`${e.runtimeWorkerBaseUrl??r}/auth/callback`,state:{source:`local`,port:t,path:`/auth/callback`,nonce:l}}}return{redirectUri:`${e.runtimeWorkerBaseUrl??i??``}/auth/callback`,state:{port:parseInt(new URL(a??i??`http://localhost:5710`).port||`5710`,10),path:`/auth/callback`,nonce:l}}}async function C(){if(b)return b;if(w){try{let e=await fetch(`${p()}/api/runtime-config`);if(e.ok){let t=await e.json();if(t.oauth?.github)return b=t.oauth.github,b}}catch{}return y.clientId}try{let e=await fetch(`/api/runtime-config`);if(e.ok){let t=await e.json();if(t.oauth?.github)return b=t.oauth.github,t.trayWorkerBaseUrl&&(x=t.trayWorkerBaseUrl),b;if(t.trayWorkerBaseUrl){x=t.trayWorkerBaseUrl;let e=await fetch(`${t.trayWorkerBaseUrl}/api/runtime-config`);if(e.ok){let t=await e.json();if(t.oauth?.github)return b=t.oauth.github,b}}}}catch{}return y.clientId}var w=typeof globalThis<`u`&&typeof globalThis.chrome?.runtime?.id==`string`;function T(){return n().find(e=>e.providerId===`github`)}function E(e){try{return new URL(e).searchParams.get(`code`)}catch{return null}}async function D(e){try{let t=await fetch(`https://api.github.com/user`,{headers:{Authorization:`Bearer ${e}`,Accept:`application/vnd.github+json`}});if(t.ok){let e=await t.json();return{name:e.name||e.login,avatar:e.avatar_url,login:e.login,id:e.id}}}catch(e){console.warn(`[github] Failed to fetch user profile:`,e instanceof Error?e.message:String(e))}return{}}function O(e,t){return`${e}+${t}@users.noreply.github.com`}async function k(t){try{let{VirtualFS:n}=await e(async()=>{let{VirtualFS:e}=await import(`./fs-D2K9G9FZ.js`).then(e=>e.t);return{VirtualFS:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]));await(await n.create({dbName:d})).writeFile(`/workspace/.git/github-token`,t),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`github-token-changed`))}catch(e){console.warn(`[github] Failed to write git token:`,e instanceof Error?e.message:String(e))}}async function A(){try{let{VirtualFS:t}=await e(async()=>{let{VirtualFS:e}=await import(`./fs-D2K9G9FZ.js`).then(e=>e.t);return{VirtualFS:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]));await(await t.create({dbName:d})).rm(`/workspace/.git/github-token`),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`github-token-changed`))}catch{}}async function j(e){let t=await r(`github`);if(t.maskedValue){await k(t.maskedValue);return}e?.clearOnFailure&&await A()}async function M(t){if(!(!t.login||t.id===void 0))try{let{VirtualFS:n}=await e(async()=>{let{VirtualFS:e}=await import(`./fs-D2K9G9FZ.js`).then(e=>e.t);return{VirtualFS:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])),{readGlobalGitConfigValue:r,writeGlobalGitConfigValue:i}=await e(async()=>{let{readGlobalGitConfigValue:e,writeGlobalGitConfigValue:t}=await import(`./git-config-D2u6LGfT.js`);return{readGlobalGitConfigValue:e,writeGlobalGitConfigValue:t}},[]),a=await n.create({dbName:d}),o=t.name||t.login,s=O(t.id,t.login);!await r(a,`user.name`)&&o&&await i(a,`user.name`,o),await r(a,`user.email`)||await i(a,`user.email`,s)}catch(e){console.warn(`[github] Failed to seed git identity:`,e instanceof Error?e.message:String(e))}}var N=c();async function P(){try{let e=T();if(!e?.refreshToken)return null;let n=await _({provider:`github`,refreshToken:e.refreshToken});return await t({providerId:`github`,accessToken:n.access_token,refreshToken:n.refresh_token,tokenExpiresAt:n.expires_in?Date.now()+n.expires_in*1e3:void 0,userName:e.userName,userAvatar:e.userAvatar,scopes:n.scope??e.scopes}),await j({clearOnFailure:!0}),n.access_token}catch(e){return console.warn(`[github] Silent renewal failed:`,e instanceof Error?e.message:String(e)),null}}var F=1e4;async function I(){let e=T()?.accessToken;if(!e)return{status:`unknown`,detail:`no stored token`};try{let t=await fetch(`https://api.github.com/user`,{headers:{Authorization:`Bearer ${e}`,Accept:`application/vnd.github+json`},signal:AbortSignal.timeout(F)});if(t.ok){let e=await t.json().catch(()=>({}));return{status:`accepted`,userName:e.name||e.login}}return L(t)}catch(e){return{status:`unknown`,detail:e instanceof Error?e.message:String(e)}}}function L(e){let t=`HTTP ${e.status}${e.statusText?` ${e.statusText}`:``}`;return e.status===401?{status:`rejected`,detail:t}:e.status===403&&R(e)?{status:`unknown`,detail:`${t} (rate limited)`}:{status:`unknown`,detail:t}}function R(e){return e.headers.get(`x-ratelimit-remaining`)===`0`||e.headers.has(`retry-after`)}async function z(){await j()}async function B(){let e=T();if(!e?.accessToken)throw Error(`Not logged in to GitHub — please log in first`);if((e.tokenExpiresAt??1/0)-Date.now()>6e4)return await z(),e.accessToken;let t=await N.run(()=>P());if(t)return t;let n=T();if((n?.tokenExpiresAt??1/0)-Date.now()>0&&n?.accessToken)return await z(),n.accessToken;throw Error(`GitHub session expired — please log in again`)}var V={id:`github`,name:`GitHub`,description:"Sign in with GitHub for git authentication (push/pull/clone) and the `oauth-token github` shell command. Does not expose LLM models — use the GitHub Copilot provider for those.",requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,oauthTokenDomains:[`github.com`,`*.github.com`,`api.github.com`,`raw.githubusercontent.com`],getModelIds:()=>[],onOAuthLogin:async(e,n,r)=>{let a=await C();if(!a)throw Error(`GitHub OAuth not configured — no client ID available`);let o=r?.scopes??y.scopes,s=w?null:await l(),c=!w&&await u(),d=crypto.randomUUID(),f=w?chrome.runtime.id:``,{redirectUri:m,state:h}=S({isExtension:w,isConnectMode:!!globalThis.__slicc_connect_mode,workerBaseUrl:p(),runtimeWorkerBaseUrl:x,pageOrigin:s?.origin??null,pageHref:s?.href??null,bridgeApiBaseUrl:i(),delegated:c,extensionId:f,nonce:d}),_=btoa(JSON.stringify(h)),v=d,b=new URLSearchParams({client_id:a,scope:o,redirect_uri:m});_&&b.set(`state`,_);let T=await e(`https://github.com/login/oauth/authorize?${b}`);if(!T)return;if(v)try{if(new URL(T).searchParams.get(`nonce`)!==v){console.error(`[github] OAuth nonce mismatch — possible CSRF`);return}}catch(e){console.warn(`[github] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}let O=E(T);if(!O){console.error(`[github] Could not extract authorization code from redirect URL`);return}let k=await g({provider:`github`,code:O,redirectUri:m}),A=await D(k.access_token);await t({providerId:`github`,accessToken:k.access_token,refreshToken:k.refresh_token,tokenExpiresAt:k.expires_in?Date.now()+k.expires_in*1e3:void 0,userName:A.name,userAvatar:A.avatar,scopes:k.scope}),await j({clearOnFailure:!0}),await M(A),n()},onSilentRenew:P,onValidateToken:I,getValidAccessToken:B,onOAuthLogout:async()=>{let e=T();e?.accessToken&&await v({provider:`github`,accessToken:e.accessToken}).catch(e=>console.warn(`[github] Token revocation failed:`,e instanceof Error?e.message:String(e))),await A(),await t({providerId:`github`,accessToken:``})},getOAuthLogoutUrl:e=>`https://github.com/logout`};export{O as buildNoreplyEmail,V as config,E as extractCodeFromUrl,B as getValidAccessToken,S as resolveGithubOAuthRedirect,M as syncGitIdentityFromGitHub};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as e,n as t,r as n}from"./account-store-DySOM26M.js";import"./proxied-fetch-D6EBne5P.js";import{a as r}from"./api-endpoint-3qEcn7BY.js";import{n as i}from"./tray-storage-keys-DbThbnIh.js";import{t as a}from"./tray-runtime-config-CdGCS5ij.js";import{t as o}from"./global-db-DJXlpNui.js";import{r as s,t as c}from"./silent-renew-backoff-Dmz3DJHb.js";import{getOAuthPageOrigin as l,resolveOAuthDelegation as u}from"./oauth-service-DLGjPRxS.js";import"./provider-settings-DyJic7fg.js";var d={clientId:``,scopes:`repo,read:user,user:email`};function f(){try{let e=localStorage.getItem(i);if(e)return e.replace(/\/$/,``)}catch{}return a}function p(e){return{access_token:e.access_token,token_type:e.token_type,scope:e.scope,refresh_token:e.refresh_token,expires_in:e.expires_in}}async function m(e){let t;try{t=await e.json()}catch{throw Error(`Token exchange failed (HTTP ${e.status}): non-JSON response`)}if(!e.ok&&e.status!==200){let n=t.error_description??t.error??`Token exchange failed (HTTP ${e.status})`;throw Error(n)}if(t.error){let e=t.error_description??t.error;throw Error(e)}return p(t)}async function h(e){let t=`${f()}/oauth/token`;return m(await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e.provider,code:e.code,redirect_uri:e.redirectUri})}))}async function g(e){let t=`${f()}/oauth/token`;return m(await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e.provider,refresh_token:e.refreshToken})}))}async function _(e){let t=`${f()}/oauth/revoke`,n=await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e.provider,access_token:e.accessToken})});if(!(n.status===204||n.ok)){if(n.status===400)try{if((await n.json()).error===`unsupported`)return}catch{}throw Error(`Token revocation failed (HTTP ${n.status})`)}}const v=Object.assign({"/packages/webapp/providers/github-config.json":d})[`/packages/webapp/providers/github-config.json`]??{clientId:``,scopes:`repo,read:user,user:email`};let y=null,b=null;function x(e){let{isExtension:t,isConnectMode:n,workerBaseUrl:r,pageOrigin:i,pageHref:a,bridgeApiBaseUrl:o,extensionId:c,nonce:l}=e;if(t)return{redirectUri:`${r}/auth/callback`,state:{source:`extension`,extensionId:c,path:`/github`,nonce:l}};if(e.delegated)return{redirectUri:`${e.runtimeWorkerBaseUrl??r}/auth/callback`,state:{source:`opener`,path:`/auth/callback`,nonce:l}};if(n){let e=i??``;if(/^https?:\/\/(localhost|127\.0\.0\.1):\d+$/.test(e)){let t=parseInt(new URL(a??e).port||`8790`,10);return{redirectUri:`${r}/auth/callback`,state:{source:`local`,port:t,path:`/auth/callback`,nonce:l}}}return{redirectUri:`${r}/auth/callback`,state:{source:`remote`,origin:e,path:`/auth/callback`,nonce:l}}}if(o&&a&&s(a)){let t=null;try{let e=new URL(o);(e.hostname===`localhost`||e.hostname===`127.0.0.1`)&&(t=parseInt(e.port||`5710`,10))}catch{t=null}if(t!==null&&!Number.isNaN(t))return{redirectUri:`${e.runtimeWorkerBaseUrl??r}/auth/callback`,state:{source:`local`,port:t,path:`/auth/callback`,nonce:l}}}return{redirectUri:`${e.runtimeWorkerBaseUrl??i??``}/auth/callback`,state:{port:parseInt(new URL(a??i??`http://localhost:5710`).port||`5710`,10),path:`/auth/callback`,nonce:l}}}async function S(){if(y)return y;if(C){try{let e=await fetch(`${f()}/api/runtime-config`);if(e.ok){let t=await e.json();if(t.oauth?.github)return y=t.oauth.github,y}}catch{}return v.clientId}try{let e=await fetch(`/api/runtime-config`);if(e.ok){let t=await e.json();if(t.oauth?.github)return y=t.oauth.github,t.trayWorkerBaseUrl&&(b=t.trayWorkerBaseUrl),y;if(t.trayWorkerBaseUrl){b=t.trayWorkerBaseUrl;let e=await fetch(`${t.trayWorkerBaseUrl}/api/runtime-config`);if(e.ok){let t=await e.json();if(t.oauth?.github)return y=t.oauth.github,y}}}}catch{}return v.clientId}const C=typeof globalThis<`u`&&typeof globalThis.chrome?.runtime?.id==`string`;function w(){return n().find(e=>e.providerId===`github`)}function T(e){try{return new URL(e).searchParams.get(`code`)}catch{return null}}async function E(e){try{let t=await fetch(`https://api.github.com/user`,{headers:{Authorization:`Bearer ${e}`,Accept:`application/vnd.github+json`}});if(t.ok){let e=await t.json();return{name:e.name||e.login,avatar:e.avatar_url,login:e.login,id:e.id}}}catch(e){console.warn(`[github] Failed to fetch user profile:`,e instanceof Error?e.message:String(e))}return{}}function D(e,t){return`${e}+${t}@users.noreply.github.com`}async function O(e){try{let{VirtualFS:t}=await import(`./fs-CCpQF0G9.js`).then(e=>e.t);await(await t.create({dbName:o})).writeFile(`/workspace/.git/github-token`,e),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`github-token-changed`))}catch(e){console.warn(`[github] Failed to write git token:`,e instanceof Error?e.message:String(e))}}async function k(){try{let{VirtualFS:e}=await import(`./fs-CCpQF0G9.js`).then(e=>e.t);await(await e.create({dbName:o})).rm(`/workspace/.git/github-token`),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`github-token-changed`))}catch{}}async function A(e){let n=await t(`github`);if(n.maskedValue){await O(n.maskedValue);return}e?.clearOnFailure&&await k()}async function j(e){if(!(!e.login||e.id===void 0))try{let{VirtualFS:t}=await import(`./fs-CCpQF0G9.js`).then(e=>e.t),{readGlobalGitConfigValue:n,writeGlobalGitConfigValue:r}=await import(`./git-config-Bdgu8kD2.js`).then(e=>e.n),i=await t.create({dbName:o}),a=e.name||e.login,s=D(e.id,e.login);!await n(i,`user.name`)&&a&&await r(i,`user.name`,a),await n(i,`user.email`)||await r(i,`user.email`,s)}catch(e){console.warn(`[github] Failed to seed git identity:`,e instanceof Error?e.message:String(e))}}const M=c();async function N(){try{let t=w();if(!t?.refreshToken)return null;let n=await g({provider:`github`,refreshToken:t.refreshToken});return await e({providerId:`github`,accessToken:n.access_token,refreshToken:n.refresh_token,tokenExpiresAt:n.expires_in?Date.now()+n.expires_in*1e3:void 0,userName:t.userName,userAvatar:t.userAvatar,scopes:n.scope??t.scopes}),await A({clearOnFailure:!0}),n.access_token}catch(e){return console.warn(`[github] Silent renewal failed:`,e instanceof Error?e.message:String(e)),null}}async function P(){let e=w()?.accessToken;if(!e)return{status:`unknown`,detail:`no stored token`};try{let t=await fetch(`https://api.github.com/user`,{headers:{Authorization:`Bearer ${e}`,Accept:`application/vnd.github+json`},signal:AbortSignal.timeout(1e4)});if(t.ok){let e=await t.json().catch(()=>({}));return{status:`accepted`,userName:e.name||e.login}}return F(t)}catch(e){return{status:`unknown`,detail:e instanceof Error?e.message:String(e)}}}function F(e){let t=`HTTP ${e.status}${e.statusText?` ${e.statusText}`:``}`;return e.status===401?{status:`rejected`,detail:t}:e.status===403&&I(e)?{status:`unknown`,detail:`${t} (rate limited)`}:{status:`unknown`,detail:t}}function I(e){return e.headers.get(`x-ratelimit-remaining`)===`0`||e.headers.has(`retry-after`)}async function L(){await A()}async function R(){let e=w();if(!e?.accessToken)throw Error(`Not logged in to GitHub — please log in first`);if((e.tokenExpiresAt??1/0)-Date.now()>6e4)return await L(),e.accessToken;let t=await M.run(()=>N());if(t)return t;let n=w();if((n?.tokenExpiresAt??1/0)-Date.now()>0&&n?.accessToken)return await L(),n.accessToken;throw Error(`GitHub session expired — please log in again`)}const z={id:`github`,name:`GitHub`,description:"Sign in with GitHub for git authentication (push/pull/clone) and the `oauth-token github` shell command. Does not expose LLM models — use the GitHub Copilot provider for those.",requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,oauthTokenDomains:[`github.com`,`*.github.com`,`api.github.com`,`raw.githubusercontent.com`],getModelIds:()=>[],onOAuthLogin:async(t,n,i)=>{let a=await S();if(!a)throw Error(`GitHub OAuth not configured — no client ID available`);let o=i?.scopes??v.scopes,s=C?null:await l(),c=!C&&await u(),d=crypto.randomUUID(),p=C?chrome.runtime.id:``,{redirectUri:m,state:g}=x({isExtension:C,isConnectMode:!!globalThis.__slicc_connect_mode,workerBaseUrl:f(),runtimeWorkerBaseUrl:b,pageOrigin:s?.origin??null,pageHref:s?.href??null,bridgeApiBaseUrl:r(),delegated:c,extensionId:p,nonce:d}),_=btoa(JSON.stringify(g)),y=d,w=new URLSearchParams({client_id:a,scope:o,redirect_uri:m});_&&w.set(`state`,_);let D=await t(`https://github.com/login/oauth/authorize?${w}`);if(!D)return;if(y)try{if(new URL(D).searchParams.get(`nonce`)!==y){console.error(`[github] OAuth nonce mismatch — possible CSRF`);return}}catch(e){console.warn(`[github] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}let O=T(D);if(!O){console.error(`[github] Could not extract authorization code from redirect URL`);return}let k=await h({provider:`github`,code:O,redirectUri:m}),M=await E(k.access_token);await e({providerId:`github`,accessToken:k.access_token,refreshToken:k.refresh_token,tokenExpiresAt:k.expires_in?Date.now()+k.expires_in*1e3:void 0,userName:M.name,userAvatar:M.avatar,scopes:k.scope}),await A({clearOnFailure:!0}),await j(M),n()},onSilentRenew:N,onValidateToken:P,getValidAccessToken:R,onOAuthLogout:async()=>{let t=w();t?.accessToken&&await _({provider:`github`,accessToken:t.accessToken}).catch(e=>console.warn(`[github] Token revocation failed:`,e instanceof Error?e.message:String(e))),await k(),await e({providerId:`github`,accessToken:``})},getOAuthLogoutUrl:e=>`https://github.com/logout`};export{D as buildNoreplyEmail,z as config,T as extractCodeFromUrl,R as getValidAccessToken,x as resolveGithubOAuthRedirect,j as syncGitIdentityFromGitHub};
|