sliccy 6.87.3 → 6.89.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 -1
- package/dist/node-server/hostfs.d.ts +58 -0
- package/dist/node-server/hostfs.js +257 -0
- package/dist/node-server/index.js +10 -0
- package/dist/node-server/runtime-flags.d.ts +22 -0
- package/dist/node-server/runtime-flags.js +78 -2
- package/dist/ui/.vite/manifest.json +540 -449
- package/dist/ui/assets/CLAUDE-4LHXSyPA.js +1 -0
- package/dist/ui/assets/CLAUDE-Bio4HPGK.js +1 -0
- package/dist/ui/assets/MEMORY-6FXnIBfJ.js +135 -0
- package/dist/ui/assets/SKILL-BKUxKc7f.js +296 -0
- package/dist/ui/assets/SKILL-BKyxMoME.js +1 -0
- package/dist/ui/assets/SKILL-BcELX5TL.js +1 -0
- package/dist/ui/assets/SKILL-Bd5ykLEh.js +1 -0
- package/dist/ui/assets/SKILL-Bt-RhG0L.js +1 -0
- package/dist/ui/assets/SKILL-CED8RXQP.js +69 -0
- package/dist/ui/assets/SKILL-CNdAIhbb.js +1 -0
- package/dist/ui/assets/SKILL-CcMg6eqt.js +1 -0
- package/dist/ui/assets/SKILL-Ch-cOl61.js +1 -0
- package/dist/ui/assets/SKILL-CkfptFag.js +132 -0
- package/dist/ui/assets/SKILL-Ckg2XbSL.js +114 -0
- package/dist/ui/assets/SKILL-D40-t9w0.js +57 -0
- package/dist/ui/assets/SKILL-D4YtbN6n.js +1 -0
- package/dist/ui/assets/SKILL-DFKKFkzD.js +96 -0
- package/dist/ui/assets/SKILL-DJ815vTN.js +62 -0
- package/dist/ui/assets/SKILL-DLXzwsY4.js +1 -0
- package/dist/ui/assets/SKILL-DXIigmDy.js +35 -0
- package/dist/ui/assets/SKILL-DfSluXpV.js +385 -0
- package/dist/ui/assets/SKILL-DhKtVqb-.js +1 -0
- package/dist/ui/assets/SKILL-FnBxPcDX.js +1 -0
- package/dist/ui/assets/SKILL-HEHb9hIB.js +1 -0
- package/dist/ui/assets/SKILL-oOIS8LAm.js +1 -0
- package/dist/ui/assets/{account-store-DysucxMw.js → account-store-Bo-yhxpr.js} +4 -4
- package/dist/ui/assets/{account-store-Cy3TJKnu.js → account-store-CYz2dZdk.js} +2 -2
- package/dist/ui/assets/adobe-BABx4YQD.js +1 -0
- package/dist/ui/assets/adobe-DFu35kBc.js +2 -0
- package/dist/ui/assets/{angular-html-Cm4-xod0.js → angular-html-aPuBvESs.js} +1 -1
- package/dist/ui/assets/{angular-ts-Dopuir71.js → angular-ts-ocjSXnvf.js} +1 -1
- package/dist/ui/assets/anthropic-messages-CpSojOI8.js +39 -0
- package/dist/ui/assets/anthropic-messages-DbPJ2ji9.js +39 -0
- package/dist/ui/assets/api-endpoint-C00IT5T9.js +1 -0
- package/dist/ui/assets/api-endpoint-GRCyib6X.js +1 -0
- package/dist/ui/assets/{apply-layout-TIXzvNTN.js → apply-layout-DtjqLMjP.js} +1 -1
- package/dist/ui/assets/{apps-e--FORGt.js → apps-CvbmIZii.js} +1 -1
- package/dist/ui/assets/{astro-E_b8esPp.js → astro-go1PgQEf.js} +1 -1
- package/dist/ui/assets/auto-mount-table-CdyPAwVL.js +1 -0
- package/dist/ui/assets/{azure-openai-mDyNL8OK.js → azure-openai-C47c28Th.js} +2 -2
- package/dist/ui/assets/{azure-openai-C5josrBb.js → azure-openai-Dn30Odmd.js} +2 -2
- package/dist/ui/assets/azure-openai-responses-BcoOaRCx.js +1 -0
- package/dist/ui/assets/azure-openai-responses-DUMDrZ29.js +1 -0
- package/dist/ui/assets/backend-hostfs-Com-zF5W.js +1 -0
- package/dist/ui/assets/backend-hostfs-bQQx-S0W.js +1 -0
- package/dist/ui/assets/bedrock-camp-BcJEC3Pg.js +1 -0
- package/dist/ui/assets/bedrock-camp-LeceEQbU.js +1 -0
- package/dist/ui/assets/bedrock-camp-compat-CYnC9BQI.js +1 -0
- package/dist/ui/assets/bedrock-camp-compat-CgBMwna8.js +1 -0
- package/dist/ui/assets/{blade-mj2TcBTp.js → blade-DPPr6MF0.js} +1 -1
- package/dist/ui/assets/catppuccin-frappe-C9Q5zVZY.js +1 -0
- package/dist/ui/assets/catppuccin-latte-CtsyrtPq.js +1 -0
- package/dist/ui/assets/catppuccin-macchiato-R8nAf1vR.js +1 -0
- package/dist/ui/assets/catppuccin-mocha-DjuaAJKi.js +1 -0
- package/dist/ui/assets/cerebras-B2bBHcWG.js +1 -0
- package/dist/ui/assets/cerebras-DWI7o4tY.js +1 -0
- package/dist/ui/assets/chime-CPc6qSh5.js +1 -0
- package/dist/ui/assets/claude-model-version-Csn7RPVg.js +1 -0
- package/dist/ui/assets/claude-model-version-DoVrYsKi.js +2 -0
- package/dist/ui/assets/{client-BTUV7dbh.js → client-DVC0x03n.js} +1 -1
- package/dist/ui/assets/{composer-speech-SNeD5SER.js → composer-speech-Cy4g3lh3.js} +1 -1
- package/dist/ui/assets/connect-llm-FevTa-aV.js +561 -0
- package/dist/ui/assets/{connect-surface-DqU2NC2c.js → connect-surface-Dd462OJJ.js} +1 -1
- package/dist/ui/assets/cpp-Ct9pQPqT.js +1 -0
- package/dist/ui/assets/{css-vJJohHMc.js → css-DlBQoFxe.js} +1 -1
- package/dist/ui/assets/db-DSIYsBgP.js +1 -0
- package/dist/ui/assets/db-cKsBsMMN.js +1 -0
- package/dist/ui/assets/discovery-preference-__0HPYJC.js +1 -0
- package/dist/ui/assets/dist-B4LJzMVB.js +1547 -0
- package/dist/ui/assets/{ensure-speech-assets-DvFwJX-M.js → ensure-speech-assets-CKwQ54O1.js} +1 -1
- package/dist/ui/assets/float-topology-DiK91BlA.js +1 -0
- package/dist/ui/assets/{follower-navigate-watcher-CNC7ybEv.js → follower-navigate-watcher-Dz-52eZY.js} +1 -1
- package/dist/ui/assets/fs-BHEdp-e-.js +1 -0
- package/dist/ui/assets/fs-MCOH5KUJ.js +2 -0
- package/dist/ui/assets/github-BbQO4O_c.js +2 -0
- package/dist/ui/assets/github-C-f5ThxJ.js +1 -0
- package/dist/ui/assets/github-copilot-DXrDbEzB.js +1 -0
- package/dist/ui/assets/github-copilot-Du-Z6Dmn.js +2 -0
- package/dist/ui/assets/{github-install-CFJLPySf.js → github-install-DbrQX7SM.js} +1 -1
- package/dist/ui/assets/{github-zip-C7dhlRG8.js → github-zip-BRYnSLKK.js} +1 -1
- package/dist/ui/assets/{go-BJwz_mda.js → go-rLFTqkRN.js} +1 -1
- package/dist/ui/assets/google-generative-ai-Dxo91M3n.js +1 -0
- package/dist/ui/assets/google-generative-ai-Rjh7hNBV.js +1 -0
- package/dist/ui/assets/{google-shared-BMJ_JErv.js → google-shared-CzJgTu-P.js} +3 -3
- package/dist/ui/assets/{google-shared-YqcyR4cm.js → google-shared-DQJPCU3d.js} +3 -3
- package/dist/ui/assets/google-vertex-61Jj0dk6.js +1 -0
- package/dist/ui/assets/google-vertex-DEwkNZJm.js +1 -0
- package/dist/ui/assets/{haml-DboNpPfQ.js → haml-Bqgi1Cau.js} +1 -1
- package/dist/ui/assets/{handlebars-Bv_jLwHk.js → handlebars-JgcNzdBj.js} +1 -1
- package/dist/ui/assets/{hear-D33CHppO.js → hear-BqNAK8-P.js} +1 -1
- package/dist/ui/assets/{horizon-bright-Br1oVSNq.js → horizon-bright-DSNQnXHK.js} +1 -1
- package/dist/ui/assets/host-command-zx0pt9Np.js +1 -0
- package/dist/ui/assets/{html-BLkwJ0Yd.js → html-BsvMqTlf.js} +1 -1
- package/dist/ui/assets/{html-derivative-B3p5VrMH.js → html-derivative-D9FvRNj4.js} +1 -1
- package/dist/ui/assets/icon-example-LUkiEXyS.js +111 -0
- package/dist/ui/assets/{jinja-BeFOxtqS.js → jinja-CixBDh_U.js} +1 -1
- package/dist/ui/assets/{js-realm-worker-BcijiBMH.js → js-realm-worker-BZhHEqbx.js} +1 -1
- package/dist/ui/assets/jsh-runtime-extensions-DpVq60Gw.js +1 -0
- package/dist/ui/assets/julia-B5NbrcUp.js +1 -0
- package/dist/ui/assets/kanagawa-dragon-Bozd7klA.js +1 -0
- package/dist/ui/assets/kanagawa-lotus-BmuOG9ZW.js +1 -0
- package/dist/ui/assets/kanagawa-wave-BML5mF2J.js +1 -0
- package/dist/ui/assets/kernel-worker-CwFqaikq.js +5233 -0
- package/dist/ui/assets/legacy-api-aliases-BnRqMAef.js +1 -0
- package/dist/ui/assets/legacy-api-aliases-oJPAvhVV.js +1 -0
- package/dist/ui/assets/{lick-manager-BJhAu_iX.js → lick-manager-DFmMezV-.js} +1 -1
- package/dist/ui/assets/{lick-urls-AW0BSaf4.js → lick-urls-DcXOqXGm.js} +1 -1
- package/dist/ui/assets/{lick-ws-bridge-DiPcVRfN.js → lick-ws-bridge-CnkYvHKI.js} +1 -1
- package/dist/ui/assets/{lick-ws-bridge-CWRES2H2.js → lick-ws-bridge-yklVm5en.js} +1 -1
- package/dist/ui/assets/{local-llm-DVCKFUl_.js → local-llm-D4MgnlBK.js} +1 -1
- package/dist/ui/assets/{local-llm-CQE3URQQ.js → local-llm-HluX94rS.js} +1 -1
- package/dist/ui/assets/{main-DQS8QHXU.js → main-BmpPeikS.js} +3 -3
- package/dist/ui/assets/{marko-C3klgjEa.js → marko-DYWPPmCl.js} +1 -1
- package/dist/ui/assets/mdc-Cno1UUUH.js +1 -0
- package/dist/ui/assets/mistral-conversations-BtaPxrK1.js +4 -0
- package/dist/ui/assets/mistral-conversations-CDLVw-9i.js +4 -0
- package/dist/ui/assets/{transform-messages-DEFauvrq.js → models-4WTk3EBD.js} +1 -1
- package/dist/ui/assets/{transform-messages-N_eMsP2M.js → models-BSkXF4T6.js} +1 -1
- package/dist/ui/assets/monokai-B_bV9PQ9.js +1 -0
- package/dist/ui/assets/mount-B_Yysj_W.js +2 -0
- package/dist/ui/assets/{mount-bridge-client-4blXuJO1.js → mount-bridge-client-DZE6sHdr.js} +1 -1
- package/dist/ui/assets/mount-kkSADJkJ.js +1 -0
- package/dist/ui/assets/mount-recovery-xQgEe0_O.js +2 -0
- package/dist/ui/assets/new-session-CEfChDqS.js +2 -0
- package/dist/ui/assets/oauth-bootstrap-C9bBExq6.js +2 -0
- package/dist/ui/assets/oauth-service-CTntqv0R.js +1 -0
- package/dist/ui/assets/oauth-service-Uk8UIb05.js +1 -0
- package/dist/ui/assets/{onboarding-orchestrator-CaLdds3m.js → onboarding-orchestrator-CnKr0yBW.js} +1 -1
- package/dist/ui/assets/openai-codex-Cs4FnQBb.js +1 -0
- package/dist/ui/assets/openai-codex-QVbVkjdj.js +1 -0
- package/dist/ui/assets/openai-codex-responses-CPOJeFUY.js +7 -0
- package/dist/ui/assets/openai-codex-responses-jQR19NyX.js +7 -0
- package/dist/ui/assets/openai-completions-DGOcowq8.js +5 -0
- package/dist/ui/assets/openai-completions-DGZFJo5D.js +5 -0
- package/dist/ui/assets/openai-responses-CDTdSIhv.js +1 -0
- package/dist/ui/assets/openai-responses-bnETPgx9.js +1 -0
- package/dist/ui/assets/{openai-responses-shared-DxcsuzHF.js → openai-responses-shared-ChgvRZ74.js} +5 -5
- package/dist/ui/assets/{openai-responses-shared-DhnqxYC9.js → openai-responses-shared-DqJbHrek.js} +5 -5
- package/dist/ui/assets/openrouter-CKoiUQKB.js +1 -0
- package/dist/ui/assets/openrouter-D1wpkLTj.js +1 -0
- package/dist/ui/assets/{openrouter-oauth-Dy4Qqt06.js → openrouter-oauth-Df_lWai3.js} +1 -1
- package/dist/ui/assets/{openrouter-oauth-DvOb1QMV.js → openrouter-oauth-jvPojBWW.js} +1 -1
- package/dist/ui/assets/{page-approval-service-Bbc3_KdK.js → page-approval-service-BsXoPdFJ.js} +1 -1
- package/dist/ui/assets/panel-rpc-handlers-Dwk2fvsL.js +2 -0
- package/dist/ui/assets/{panelize-shell-BRldzPxv.js → panelize-shell-DG3fFAS4.js} +1 -1
- package/dist/ui/assets/patterns-ChiGbijt.js +171 -0
- package/dist/ui/assets/php-m5Ug_San.js +1 -0
- package/dist/ui/assets/port-bridge-client-BhmNRlRv.js +2 -0
- package/dist/ui/assets/port-bridge-client-Bz2N1tvn.js +1 -0
- package/dist/ui/assets/{provider-D2RXncrR.js → provider-Dq-ruSoi.js} +2 -2
- package/dist/ui/assets/{provider-Bk24TjUg.js → provider-Y9RlYumW.js} +1 -1
- package/dist/ui/assets/{provider-settings-B5B0NtAl.js → provider-settings-CR96H2hU.js} +1 -1
- package/dist/ui/assets/provider-settings-DNJS-V3F.js +2 -0
- package/dist/ui/assets/{provider-store-access-Cl5aZRx7.js → provider-store-access-BIdOJknd.js} +2 -2
- package/dist/ui/assets/provider-store-access-HarlSCPD.js +1 -0
- package/dist/ui/assets/providers-BS5_Cp-0.js +2 -0
- package/dist/ui/assets/providers-DRiRdLO1.js +1 -0
- package/dist/ui/assets/proxied-fetch-BGeNrvQ4.js +2 -0
- package/dist/ui/assets/proxied-fetch-Co-pb0x0.js +1 -0
- package/dist/ui/assets/{pug-BPcX_o8k.js → pug-B4bk2kWf.js} +1 -1
- package/dist/ui/assets/quick-llm-9w6VrHaQ.js +1 -0
- package/dist/ui/assets/r-C5FwQflr.js +1 -0
- package/dist/ui/assets/record-Cy655bTh.js +1 -0
- package/dist/ui/assets/{recovery-screen-MHXsY2RD.js → recovery-screen-ClVBOtr7.js} +1 -1
- package/dist/ui/assets/red-DX1BQOs8.js +1 -0
- package/dist/ui/assets/{redirect-uri-B1SxiY-b.js → redirect-uri-B16gkDfI.js} +1 -1
- package/dist/ui/assets/{remote-terminal-view-Dc-DMywu.js → remote-terminal-view-DSUnPeXp.js} +1 -1
- package/dist/ui/assets/rose-pine-aMsaMD1D.js +1 -0
- package/dist/ui/assets/rose-pine-dawn-8PwUyIlP.js +1 -0
- package/dist/ui/assets/rose-pine-moon-DO-qXg-I.js +1 -0
- package/dist/ui/assets/{scss-0nEf0IT-.js → scss-BaZL6t2Y.js} +1 -1
- package/dist/ui/assets/secret-env-CjwX7z7b.js +1 -0
- package/dist/ui/assets/secret-topology-0AWfFTh5.js +1 -0
- package/dist/ui/assets/{secrets-bridge-client-cWDAnFqs.js → secrets-bridge-client-DCQ44RyR.js} +1 -1
- package/dist/ui/assets/{session-freezer-CnFBCb6j.js → session-freezer-BcGQ4XGx.js} +3 -3
- package/dist/ui/assets/{setup-feature-flags-remote-Dlcwmn-_.js → setup-feature-flags-remote-8Rvw554i.js} +1 -1
- package/dist/ui/assets/setup-standalone-prelude-NNpe-m64.js +2 -0
- package/dist/ui/assets/setup-sudo-CbAhwltm.js +2 -0
- package/dist/ui/assets/{skills-C90t15zW.js → skills-CDnSEmr6.js} +1 -1
- package/dist/ui/assets/{slicc-diff-DsGtkf0J.js → slicc-diff-DhGIKKqP.js} +1 -1
- package/dist/ui/assets/slicc-version-2zGA6xjX.js +1 -0
- package/dist/ui/assets/smithy-Dgaz7aur.js +1 -0
- package/dist/ui/assets/solarized-dark-UdsmMDCL.js +1 -0
- package/dist/ui/assets/solarized-light-C1IUL_tW.js +1 -0
- package/dist/ui/assets/{speak-BDT9rGzg.js → speak-BSK3Souh.js} +1 -1
- package/dist/ui/assets/{sql-69VAgb2g.js → sql-DvarVTMJ.js} +1 -1
- package/dist/ui/assets/{src-DsDPrXOS.js → src-DXdqCrdV.js} +2 -2
- package/dist/ui/assets/{store-BmhLnay6.js → store-BKV5dm_L.js} +1 -1
- package/dist/ui/assets/{store-Cvg04_Rz.js → store-Bl3OB-Qs.js} +1 -1
- package/dist/ui/assets/style-guide-Bgzsk7bf.js +821 -0
- package/dist/ui/assets/{sudo-DYhM4jWf.js → sudo-Bnq6X0me.js} +2 -2
- package/dist/ui/assets/{svelte-B4PVQJ-7.js → svelte-D4FIy7cP.js} +1 -1
- package/dist/ui/assets/swift-CyEgAFGc.js +1 -0
- package/dist/ui/assets/temperature-support-B4x2xaWY.js +1 -0
- package/dist/ui/assets/temperature-support-Cpml9LfI.js +1 -0
- package/dist/ui/assets/transform-messages-DZg9zDcV.js +1 -0
- package/dist/ui/assets/transform-messages-XkZ1QnTb.js +1 -0
- package/dist/ui/assets/transformers-env-DPjdc2EQ.js +1 -0
- package/dist/ui/assets/tray-leader-iVJTGwuf.js +1 -0
- package/dist/ui/assets/{tray-leave-runtime-BGfdX5KF.js → tray-leave-runtime-CN7V9V7O.js} +1 -1
- package/dist/ui/assets/{tray-runtime-config-B1LF8Kd4.js → tray-runtime-config-CVoPQrT2.js} +1 -1
- package/dist/ui/assets/tray-runtime-config-D7cmCcHJ.js +1 -0
- package/dist/ui/assets/ts-tags-C4Ifwy6r.js +1 -0
- package/dist/ui/assets/{upgrade-detection-Co2MZvYS.js → upgrade-detection-BC1ILaMz.js} +1 -1
- package/dist/ui/assets/vesper-DdrHHSXu.js +1 -0
- package/dist/ui/assets/{voice-reply-CnP5wEO_.js → voice-reply-BNX-jA0G.js} +1 -1
- package/dist/ui/assets/{vue-Dg0Kv3qp.js → vue-Djeyp8pE.js} +1 -1
- package/dist/ui/assets/{vue-vine-DdvC-EE2.js → vue-vine-By_xyXdL.js} +1 -1
- package/dist/ui/assets/{wc-attach-DsMfUpx8.js → wc-attach-CPoS-Z-g.js} +2 -2
- package/dist/ui/assets/{wc-extension-CL-LAE0W.js → wc-extension-pWBTulcf.js} +2 -2
- package/dist/ui/assets/wc-float-label-D7p-4xyd.js +1 -0
- package/dist/ui/assets/wc-follower-TQacOT97.js +17 -0
- package/dist/ui/assets/wc-live-DlayGhwI.js +8 -0
- package/dist/ui/assets/wc-nav-Co62IQ9D.js +2 -0
- package/dist/ui/assets/wc-onboarding-CqIwr35s.js +2 -0
- package/dist/ui/assets/{wc-permissions-gFKCQht9.js → wc-permissions-Oq3nX_59.js} +2 -2
- package/dist/ui/assets/wc-placeholder-CRVvrH3X.js +4 -0
- package/dist/ui/assets/{wc-scoop-color-CByZNEJo.js → wc-scoop-color-ShF3p7L9.js} +1 -1
- package/dist/ui/assets/wc-settings-Bh5hIzNc.js +51 -0
- package/dist/ui/assets/{wc-shell-DC5bovWA.js → wc-shell-7mtD7TN_.js} +3 -3
- package/dist/ui/assets/wc-sprinkles-wT8iHdRT.js +2 -0
- package/dist/ui/assets/wc-tray-DxDD8gsB.js +2 -0
- package/dist/ui/assets/wc-tray-scoops-B7RY-1VN.js +5 -0
- package/dist/ui/assets/wc-unit-context-C0EqsYUD.js +1 -0
- package/dist/ui/assets/welcome-CyCMJDqG.js +621 -0
- package/dist/ui/assets/{welcome-detection-C2MvJDW4.js → welcome-detection-DjomEbCT.js} +1 -1
- package/dist/ui/assets/whisper-session-DpDs0sDL.js +2 -0
- package/dist/ui/assets/x_search-C-5p00-C.js +131 -0
- package/dist/ui/assets/xai-grok-CcoDiPUW.js +1 -0
- package/dist/ui/assets/xai-grok-DO4be7QU.js +1 -0
- package/dist/ui/index.html +16 -14
- package/dist/ui/packages/webapp/index.html +16 -14
- package/dist/ui/slicc-diff.js +1 -1
- package/package.json +3 -4
- package/dist/ui/assets/adobe-C19oqBaU.js +0 -1
- package/dist/ui/assets/adobe-Dv-gMc09.js +0 -2
- package/dist/ui/assets/anthropic-messages-BX4DpK10.js +0 -39
- package/dist/ui/assets/anthropic-messages-C-orWG7m.js +0 -39
- package/dist/ui/assets/azure-openai-responses-C2LleG-4.js +0 -1
- package/dist/ui/assets/azure-openai-responses-Df9YPxyp.js +0 -1
- package/dist/ui/assets/bedrock-camp-B0KF_4RS.js +0 -1
- package/dist/ui/assets/bedrock-camp-qpZqnqLa.js +0 -2
- package/dist/ui/assets/catppuccin-frappe-3VR1Za6u.js +0 -1
- package/dist/ui/assets/catppuccin-latte-DwIHMF0Q.js +0 -1
- package/dist/ui/assets/catppuccin-macchiato-DYnBP6_5.js +0 -1
- package/dist/ui/assets/catppuccin-mocha-DYhrFGRu.js +0 -1
- package/dist/ui/assets/cerebras-CDHmZz_Y.js +0 -1
- package/dist/ui/assets/cerebras-DPV0CO1I.js +0 -1
- package/dist/ui/assets/cpp-CdhRINFH.js +0 -1
- package/dist/ui/assets/db-DATxPCUz.js +0 -1
- package/dist/ui/assets/db-DIbBClfy.js +0 -1
- package/dist/ui/assets/discovery-preference-fqUhjzeE.js +0 -1
- package/dist/ui/assets/dist-Dwa3Gdd4.js +0 -1547
- package/dist/ui/assets/float-topology-BgioAcOd.js +0 -1
- package/dist/ui/assets/fs-CIIVB1OK.js +0 -2
- package/dist/ui/assets/fs-QyBiZMuq.js +0 -1
- package/dist/ui/assets/github-Ctvr_Nd6.js +0 -1
- package/dist/ui/assets/github-Dq-ryVOk.js +0 -2
- package/dist/ui/assets/github-copilot-DIk_soEH.js +0 -1
- package/dist/ui/assets/github-copilot-Dm5mGSYk.js +0 -2
- package/dist/ui/assets/google-generative-ai-C9uw7Zks.js +0 -1
- package/dist/ui/assets/google-generative-ai-DHBc1oKV.js +0 -1
- package/dist/ui/assets/google-vertex-BaT3InWy.js +0 -1
- package/dist/ui/assets/google-vertex-DX8CfGr6.js +0 -1
- package/dist/ui/assets/host-command-G_JIdBPR.js +0 -1
- package/dist/ui/assets/julia-DibC-h6i.js +0 -1
- package/dist/ui/assets/kanagawa-dragon-CXtmUGW6.js +0 -1
- package/dist/ui/assets/kanagawa-lotus-BN08jTvb.js +0 -1
- package/dist/ui/assets/kanagawa-wave-CTweb8Dz.js +0 -1
- package/dist/ui/assets/kernel-worker-BiaHa-Mz.js +0 -9014
- package/dist/ui/assets/legacy-api-aliases-CsTVszvY.js +0 -1
- package/dist/ui/assets/legacy-api-aliases-nSD9C16V.js +0 -1
- package/dist/ui/assets/mdc-Otire2H_.js +0 -1
- package/dist/ui/assets/mistral-conversations-BXo-tb0V.js +0 -4
- package/dist/ui/assets/mistral-conversations-Ck257tvp.js +0 -4
- package/dist/ui/assets/monokai-CdkpiU2Y.js +0 -1
- package/dist/ui/assets/mount-C20u28qg.js +0 -2
- package/dist/ui/assets/mount-DSlWOyRg.js +0 -1
- package/dist/ui/assets/mount-recovery-Dp2uzDT3.js +0 -2
- package/dist/ui/assets/new-session-BmqHuPnd.js +0 -2
- package/dist/ui/assets/oauth-bootstrap-CF5Iq7xU.js +0 -2
- package/dist/ui/assets/oauth-service-Bbrrl8Mr.js +0 -1
- package/dist/ui/assets/oauth-service-Cy5ngmcU.js +0 -1
- package/dist/ui/assets/openai-codex-C2ilX51B.js +0 -1
- package/dist/ui/assets/openai-codex-bhWf9evO.js +0 -1
- package/dist/ui/assets/openai-codex-responses-BQzefg3i.js +0 -7
- package/dist/ui/assets/openai-codex-responses-JtcU5b3J.js +0 -7
- package/dist/ui/assets/openai-completions-D-HjYi8x.js +0 -5
- package/dist/ui/assets/openai-completions-QMfwfjiE.js +0 -5
- package/dist/ui/assets/openai-responses-BVHnEPuG.js +0 -1
- package/dist/ui/assets/openai-responses-Ca0oWhbv.js +0 -1
- package/dist/ui/assets/openrouter-Bo62to17.js +0 -1
- package/dist/ui/assets/openrouter-C9_8OqEu.js +0 -1
- package/dist/ui/assets/panel-rpc-handlers-Dbhx7m_G.js +0 -2
- package/dist/ui/assets/php-BidqsJNR.js +0 -1
- package/dist/ui/assets/port-bridge-client-BbVs1yhx.js +0 -2
- package/dist/ui/assets/port-bridge-client-DxYLF2-N.js +0 -1
- package/dist/ui/assets/provider-settings-BTpBo_o4.js +0 -2
- package/dist/ui/assets/provider-store-access-CrgSlufJ.js +0 -1
- package/dist/ui/assets/providers-Crdj27DN.js +0 -2
- package/dist/ui/assets/providers-DX7EJ4Fn.js +0 -1
- package/dist/ui/assets/proxied-fetch-B4g-4VbQ.js +0 -2
- package/dist/ui/assets/proxied-fetch-n2pCvcgW.js +0 -1
- package/dist/ui/assets/quick-llm-hL6bZGLe.js +0 -1
- package/dist/ui/assets/r-Dzep-lPg.js +0 -1
- package/dist/ui/assets/record-Z5ZWTUPJ.js +0 -1
- package/dist/ui/assets/red-CJ3rzSJv.js +0 -1
- package/dist/ui/assets/rose-pine-BthvhNj6.js +0 -1
- package/dist/ui/assets/rose-pine-dawn-Dg85fqjY.js +0 -1
- package/dist/ui/assets/rose-pine-moon-hon4tzzS.js +0 -1
- package/dist/ui/assets/secret-env-q4hxkt7Z.js +0 -1
- package/dist/ui/assets/secret-topology-xLmXoozo.js +0 -1
- package/dist/ui/assets/setup-standalone-prelude-Btsjqjoe.js +0 -2
- package/dist/ui/assets/setup-sudo-DrmeHwU_.js +0 -2
- package/dist/ui/assets/slicc-version-tsUsi909.js +0 -1
- package/dist/ui/assets/solarized-dark-DV17i1UV.js +0 -1
- package/dist/ui/assets/solarized-light-DSh2HLQt.js +0 -1
- package/dist/ui/assets/swift-DonLKvLd.js +0 -1
- package/dist/ui/assets/transformers-env-SL0zTs7S.js +0 -1
- package/dist/ui/assets/tray-leader-DcRtwWl-.js +0 -1
- package/dist/ui/assets/tray-runtime-config-CRGwg9SK.js +0 -1
- package/dist/ui/assets/ts-tags-BUIgHz80.js +0 -1
- package/dist/ui/assets/vesper-D5bVUKB1.js +0 -1
- package/dist/ui/assets/wc-float-label-qqb_uM9y.js +0 -1
- package/dist/ui/assets/wc-follower-troAtcMA.js +0 -17
- package/dist/ui/assets/wc-live-D1Mon0cw.js +0 -8
- package/dist/ui/assets/wc-nav-BV6Jm98e.js +0 -2
- package/dist/ui/assets/wc-onboarding-Dg4E9VDR.js +0 -2
- package/dist/ui/assets/wc-placeholder-_6RUOpYH.js +0 -4
- package/dist/ui/assets/wc-settings-Dy5cPd8c.js +0 -51
- package/dist/ui/assets/wc-sprinkles-CDP31nXS.js +0 -2
- package/dist/ui/assets/wc-tray-MFZAPwt4.js +0 -2
- package/dist/ui/assets/wc-tray-scoops-B2RP8cgD.js +0 -5
- package/dist/ui/assets/whisper-session-Cf2gGkoR.js +0 -2
- package/dist/ui/assets/xai-grok-C2GEvF8U.js +0 -1
- package/dist/ui/assets/xai-grok-CoSPbEFx.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as e,b as t,g as n,h as r,m as i,v as a,x as o,y as s}from"./bedrock-camp-qpZqnqLa.js";var c=o(),l=t(),u=s(),d=a(),f=e(),p=n(),m=r(),h=i(),g=c.stream,_=c.streamSimple;l.stream,l.streamSimple,u.stream,u.streamSimple,d.stream,d.streamSimple,f.stream,f.streamSimple;var v=p.stream,y=p.streamSimple,b=m.stream,x=m.streamSimple,S=h.stream,C=h.streamSimple;export{_ as a,C as c,S as i,v as n,y as o,b as r,x as s,g as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{S as e,_ as t,b as n,g as r,h as i,v as a,x as o,y as s}from"./bedrock-camp-B0KF_4RS.js";const c=e(),l=o(),u=n(),d=s(),f=a(),p=t(),m=r(),h=i(),g=c.stream,_=c.streamSimple;l.stream,l.streamSimple,u.stream,u.streamSimple,d.stream,d.streamSimple,f.stream,f.streamSimple;const v=p.stream,y=p.streamSimple,b=m.stream,x=m.streamSimple,S=h.stream,C=h.streamSimple;export{_ as a,C as c,S as i,v as n,y as o,b as r,x as s,g as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import e from"./html-derivative-B3p5VrMH.js";import t from"./yaml-rwi0_p6S.js";import n from"./markdown-BYOwaDjH.js";var r=Object.freeze(JSON.parse(`{"displayName":"MDC","injectionSelector":"L:text.html.markdown","name":"mdc","patterns":[{"include":"text.html.markdown#frontMatter"},{"include":"#block"}],"repository":{"attribute":{"patterns":[{"captures":{"2":{"name":"entity.other.attribute-name.html"},"3":{"patterns":[{"include":"#attribute-interior"}]}},"match":"(([^<=>\\\\s]*)(=\\"([^\\"]*)(\\")|'([^']*)(')|=[^\\"'}\\\\s]*)?\\\\s*)"}]},"attribute-interior":{"patterns":[{"begin":"=","beginCaptures":{"0":{"name":"punctuation.separator.key-value.html"}},"end":"(?<=[^=\\\\s])(?!\\\\s*=)|(?=/?>)","patterns":[{"match":"([^\\"'/<=>\`\\\\s]|/(?!>))+","name":"string.unquoted.html"},{"begin":"\\"","beginCaptures":{"0":{"name":"punctuation.definition.string.begin.html"}},"end":"\\"","endCaptures":{"0":{"name":"punctuation.definition.string.end.html"}},"name":"string.quoted.double.html","patterns":[{"include":"#entities"}]},{"begin":"'","beginCaptures":{"0":{"name":"punctuation.definition.string.begin.html"}},"end":"'","endCaptures":{"0":{"name":"punctuation.definition.string.end.html"}},"name":"string.quoted.single.html","patterns":[{"include":"#entities"}]},{"match":"=","name":"invalid.illegal.unexpected-equals-sign.html"}]}]},"attributes":{"captures":{"1":{"name":"punctuation.definition.tag.start.component"},"3":{"patterns":[{"include":"#attribute"}]},"4":{"name":"punctuation.definition.tag.end.component"}},"match":"((\\\\{)([^{]*)(}))","name":"attributes.mdc"},"block":{"patterns":[{"include":"#inline"},{"include":"#component_block"},{"include":"text.html.markdown#separator"},{"include":"#heading"},{"include":"#blockquote"},{"include":"#lists"},{"include":"text.html.markdown#fenced_code_block"},{"include":"text.html.markdown#link-def"},{"include":"text.html.markdown#html"},{"include":"#paragraph"}]},"blockquote":{"begin":"(^|\\\\G) *(>) ?","captures":{"2":{"name":"punctuation.definition.quote.begin.markdown"}},"name":"markup.quote.markdown","patterns":[{"include":"#block"}],"while":"(^|\\\\G)\\\\s*(>) ?"},"component_block":{"begin":"(^|\\\\G)(\\\\s*)(:{2,})(?i:(\\\\w[-\\\\w\\\\d]+)(\\\\s*|\\\\s*(\\\\{[^{]*}))$)","beginCaptures":{"3":{"name":"punctuation.definition.tag.start.mdc"},"4":{"name":"entity.name.tag.mdc"},"5":{"patterns":[{"include":"#attributes"}]}},"end":"(^|\\\\G)(\\\\2)(\\\\3)\\\\s*$","endCaptures":{"3":{"name":"punctuation.definition.tag.end.mdc"}},"name":"block.component.mdc","patterns":[{"captures":{"2":{"name":"punctuation.definition.tag.end.mdc"}},"match":"(^|\\\\G)\\\\s*(:{2,})$"},{"begin":"(^|\\\\G)(\\\\s*)(-{3})(\\\\s*)$","end":"(^|\\\\G)(\\\\s*(-{3})(\\\\s*))$","patterns":[{"include":"source.yaml"}]},{"captures":{"2":{"name":"entity.other.attribute-name.html"},"3":{"name":"comment.block.html"}},"match":"^(\\\\s*)(#[-_\\\\w]*)\\\\s*(<!--(.*)-->)?$"},{"include":"#block"}]},"component_inline":{"captures":{"2":{"name":"punctuation.definition.tag.start.component"},"3":{"name":"entity.name.tag.component"},"5":{"patterns":[{"include":"#attributes"}]},"6":{"patterns":[{"include":"#span"}]},"7":{"patterns":[{"include":"#span"}]},"8":{"patterns":[{"include":"#attributes"}]}},"match":"(^|\\\\G|\\\\s+)(:)(?i:(\\\\w[-\\\\w\\\\d]*))((\\\\{[^}]*})(\\\\[[^]]*])?|(\\\\[[^]]*])(\\\\{[^}]*})?)?\\\\s","name":"inline.component.mdc"},"entities":{"patterns":[{"captures":{"1":{"name":"punctuation.definition.entity.html"},"912":{"name":"punctuation.definition.entity.html"}},"match":"(&)(?=[A-Za-z])((a(s(ymp(eq)?|cr|t)|n(d(slope|[dv]|and)?|g(s(t|ph)|zarr|e|le|rt(vb(d)?)?|msd(a([a-h]))?)?)|c(y|irc|d|ute|E)?|tilde|o(pf|gon)|uml|p(id|os|prox(eq)?|[Ee]|acir)?|elig|f(r)?|w((?:con|)int)|l(pha|e(ph|fsym))|acute|ring|grave|m(p|a(cr|lg))|breve)|A(s(sign|cr)|nd|MP|c(y|irc)|tilde|o(pf|gon)|uml|pplyFunction|fr|Elig|lpha|acute|ring|grave|macr|breve))|(B(scr|cy|opf|umpeq|e(cause|ta|rnoullis)|fr|a(ckslash|r(v|wed))|reve)|b(s(cr|im(e)?|ol(hsub|b)?|emi)|n(ot|e(quiv)?)|c(y|ong)|ig(s(tar|qcup)|c(irc|up|ap)|triangle(down|up)|o(times|dot|plus)|uplus|vee|wedge)|o(t(tom)?|pf|wtie|x(h([DUdu])?|times|H([DUdu])?|d([LRlr])|u([LRlr])|plus|D([LRlr])|v([HLRhlr])?|U([LRlr])|V([HLRhlr])?|minus|box))|Not|dquo|u(ll(et)?|mp(e(q)?|E)?)|prime|e(caus(e)?|t(h|ween|a)|psi|rnou|mptyv)|karow|fr|l(ock|k(1([24])|34)|a(nk|ck(square|triangle(down|left|right)?|lozenge)))|a(ck(sim(eq)?|cong|prime|epsilon)|r(vee|wed(ge)?))|r(eve|vbar)|brk(tbrk)?))|(c(s(cr|u(p(e)?|b(e)?))|h(cy|i|eck(mark)?)|ylcty|c(irc|ups(sm)?|edil|a(ps|ron))|tdot|ir(scir|c(eq|le(d(R|circ|S|dash|ast)|arrow(left|right)))?|e|fnint|E|mid)?|o(n(int|g(dot)?)|p(y(sr)?|f|rod)|lon(e(q)?)?|m(p(fn|le(xes|ment))?|ma(t)?))|dot|u(darr([lr])|p(s|c([au]p)|or|dot|brcap)?|e(sc|pr)|vee|wed|larr(p)?|r(vearrow(left|right)|ly(eq(succ|prec)|vee|wedge)|arr(m)?|ren))|e(nt(erdot)?|dil|mptyv)|fr|w((?:con|)int)|lubs(uit)?|a(cute|p(s|c([au]p)|dot|and|brcup)?|r(on|et))|r(oss|arr))|C(scr|hi|c(irc|onint|edil|aron)|ircle(Minus|Times|Dot|Plus)|Hcy|o(n(tourIntegral|int|gruent)|unterClockwiseContourIntegral|p(f|roduct)|lon(e)?)|dot|up(Cap)?|OPY|e(nterDot|dilla)|fr|lo(seCurly((?:Double|)Quote)|ckwiseContourIntegral)|a(yleys|cute|p(italDifferentialD)?)|ross))|(d(s(c([ry])|trok|ol)|har([lr])|c(y|aron)|t(dot|ri(f)?)|i(sin|e|v(ide(ontimes)?|onx)?|am(s|ond(suit)?)?|gamma)|Har|z(cy|igrarr)|o(t(square|plus|eq(dot)?|minus)?|ublebarwedge|pf|wn(harpoon(left|right)|downarrows|arrow)|llar)|d(otseq|a(rr|gger))?|u(har|arr)|jcy|e(lta|g|mptyv)|f(isht|r)|wangle|lc(orn|rop)|a(sh(v)?|leth|rr|gger)|r(c(orn|rop)|bkarow)|b(karow|lac)|Arr)|D(s(cr|trok)|c(y|aron)|Scy|i(fferentialD|a(critical(Grave|Tilde|Do(t|ubleAcute)|Acute)|mond))|o(t(Dot|Equal)?|uble(Right(Tee|Arrow)|ContourIntegral|Do(t|wnArrow)|Up((?:Down|)Arrow)|VerticalBar|L(ong(RightArrow|Left((?:Right|)Arrow))|eft(RightArrow|Tee|Arrow)))|pf|wn(Right(TeeVector|Vector(Bar)?)|Breve|Tee(Arrow)?|arrow|Left(RightVector|TeeVector|Vector(Bar)?)|Arrow(Bar|UpArrow)?))|Zcy|el(ta)?|D(otrahd)?|Jcy|fr|a(shv|rr|gger)))|(e(s(cr|im|dot)|n(sp|g)|c(y|ir(c)?|olon|aron)|t([ah])|o(pf|gon)|dot|u(ro|ml)|p(si(v|lon)?|lus|ar(sl)?)|e|D(D??ot)|q(s(im|lant(less|gtr))|c(irc|olon)|u(iv(DD)?|est|als)|vparsl)|f(Dot|r)|l(s(dot)?|inters|l)?|a(ster|cute)|r(Dot|arr)|g(s(dot)?|rave)?|x(cl|ist|p(onentiale|ectation))|m(sp(1([34]))?|pty(set|v)?|acr))|E(s(cr|im)|c(y|irc|aron)|ta|o(pf|gon)|NG|dot|uml|TH|psilon|qu(ilibrium|al(Tilde)?)|fr|lement|acute|grave|x(ists|ponentialE)|m(pty((?:|Very)SmallSquare)|acr)))|(f(scr|nof|cy|ilig|o(pf|r(k(v)?|all))|jlig|partint|emale|f(ilig|l(l??ig)|r)|l(tns|lig|at)|allingdotseq|r(own|a(sl|c(1([2-68])|78|2([35])|3([458])|45|5([68])))))|F(scr|cy|illed((?:|Very)SmallSquare)|o(uriertrf|pf|rAll)|fr))|(G(scr|c(y|irc|edil)|t|opf|dot|T|Jcy|fr|amma(d)?|reater(Greater|SlantEqual|Tilde|Equal(Less)?|FullEqual|Less)|g|breve)|g(s(cr|im([el])?)|n(sim|e(q(q)?)?|E|ap(prox)?)|c(y|irc)|t(c(c|ir)|dot|quest|lPar|r(sim|dot|eq(q?less)|less|a(pprox|rr)))?|imel|opf|dot|jcy|e(s(cc|dot(o(l)?)?|l(es)?)?|q(slant|q)?|l)?|v(nE|ertneqq)|fr|E(l)?|l([Eaj])?|a(cute|p|mma(d)?)|rave|g(g)?|breve))|(h(s(cr|trok|lash)|y(phen|bull)|circ|o(ok((?:lef|righ)tarrow)|pf|arr|rbar|mtht)|e(llip|arts(uit)?|rcon)|ks([ew]arow)|fr|a(irsp|lf|r(dcy|r(cir|w)?)|milt)|bar|Arr)|H(s(cr|trok)|circ|ilbertSpace|o(pf|rizontalLine)|ump(DownHump|Equal)|fr|a(cek|t)|ARDcy))|(i(s(cr|in(s(v)?|dot|[Ev])?)|n(care|t(cal|prod|e(rcal|gers)|larhk)?|odot|fin(tie)?)?|c(y|irc)?|t(ilde)?|i(nfin|i(i??nt)|ota)?|o(cy|ta|pf|gon)|u(kcy|ml)|jlig|prod|e(cy|xcl)|quest|f([fr])|acute|grave|m(of|ped|a(cr|th|g(part|e|line))))|I(scr|n(t(e(rsection|gral))?|visible(Comma|Times))|c(y|irc)|tilde|o(ta|pf|gon)|dot|u(kcy|ml)|Ocy|Jlig|fr|Ecy|acute|grave|m(plies|a(cr|ginaryI))?))|(j(s(cr|ercy)|c(y|irc)|opf|ukcy|fr|math)|J(s(cr|ercy)|c(y|irc)|opf|ukcy|fr))|(k(scr|hcy|c(y|edil)|opf|jcy|fr|appa(v)?|green)|K(scr|c(y|edil)|Hcy|opf|Jcy|fr|appa))|(l(s(h|cr|trok|im([eg])?|q(uo(r)?|b)|aquo)|h(ar(d|u(l)?)|blk)|n(sim|e(q(q)?)?|E|ap(prox)?)|c(y|ub|e(d??il)|aron)|Barr|t(hree|c(c|ir)|imes|dot|quest|larr|r(i([ef])?|Par))?|Har|o(ng(left((?:|right)arrow)|rightarrow|mapsto)|times|z(enge|f)?|oparrow(left|right)|p(f|lus|ar)|w(ast|bar)|a(ng|rr)|brk)|d(sh|ca|quo(r)?|r((?:d|us)har))|ur((?:ds|u)har)|jcy|par(lt)?|e(s(s(sim|dot|eq(q?gtr)|approx|gtr)|cc|dot(o(r)?)?|g(es)?)?|q(slant|q)?|ft(harpoon(down|up)|threetimes|leftarrows|arrow(tail)?|right(squigarrow|harpoons|arrow(s)?))|g)?|v(nE|ertneqq)|f(isht|loor|r)|E(g)?|l(hard|corner|tri|arr)?|a(ng(d|le)?|cute|t(e(s)?|ail)?|p|emptyv|quo|rr(sim|hk|tl|pl|fs|lp|b(fs)?)?|gran|mbda)|r(har(d)?|corner|tri|arr|m)|g(E)?|m(idot|oust(ache)?)|b(arr|r(k(sl([du])|e)|ac([ek]))|brk)|A(tail|arr|rr))|L(s(h|cr|trok)|c(y|edil|aron)|t|o(ng(RightArrow|left((?:|right)arrow)|rightarrow|Left((?:Right|)Arrow))|pf|wer((?:Righ|Lef)tArrow))|T|e(ss(Greater|SlantEqual|Tilde|EqualGreater|FullEqual|Less)|ft(Right(Vector|Arrow)|Ceiling|T(ee(Vector|Arrow)?|riangle(Bar|Equal)?)|Do(ubleBracket|wn(TeeVector|Vector(Bar)?))|Up(TeeVector|DownVector|Vector(Bar)?)|Vector(Bar)?|arrow|rightarrow|Floor|A(ngleBracket|rrow(RightArrow|Bar)?)))|Jcy|fr|l(eftarrow)?|a(ng|cute|placetrf|rr|mbda)|midot))|(M(scr|cy|inusPlus|opf|u|e(diumSpace|llintrf)|fr|ap)|m(s(cr|tpos)|ho|nplus|c(y|omma)|i(nus(d(u)?|b)?|cro|d(cir|dot|ast)?)|o(dels|pf)|dash|u((?:lti|)map)?|p|easuredangle|DDot|fr|l(cp|dr)|a(cr|p(sto(down|up|left)?)?|l(t(ese)?|e)|rker)))|(n(s(hort(parallel|mid)|c(cue|[er])?|im(e(q)?)?|u(cc(eq)?|p(set(eq(q)?)?|[Ee])?|b(set(eq(q)?)?|[Ee])?)|par|qsu([bp]e)|mid)|Rightarrow|h(par|arr|Arr)|G(t(v)?|g)|c(y|ong(dot)?|up|edil|a(p|ron))|t(ilde|lg|riangle(left(eq)?|right(eq)?)|gl)|i(s(d)?|v)?|o(t(ni(v([abc]))?|in(dot|v([abc])|E)?)?|pf)|dash|u(m(sp|ero)?)?|jcy|p(olint|ar(sl|t|allel)?|r(cue|e(c(eq)?)?)?)|e(s(im|ear)|dot|quiv|ar(hk|r(ow)?)|xist(s)?|Arr)?|v(sim|infin|Harr|dash|Dash|l(t(rie)?|e|Arr)|ap|r(trie|Arr)|g([et]))|fr|w(near|ar(hk|r(ow)?)|Arr)|V([Dd]ash)|l(sim|t(ri(e)?)?|dr|e(s(s)?|q(slant|q)?|ft((?:|right)arrow))?|E|arr|Arr)|a(ng|cute|tur(al(s)?)?|p(id|os|prox|E)?|bla)|r(tri(e)?|ightarrow|arr([cw])?|Arr)|g(sim|t(r)?|e(s|q(slant|q)?)?|E)|mid|L(t(v)?|eft((?:|right)arrow)|l)|b(sp|ump(e)?))|N(scr|c(y|edil|aron)|tilde|o(nBreakingSpace|Break|t(R(ightTriangle(Bar|Equal)?|everseElement)|Greater(Greater|SlantEqual|Tilde|Equal|FullEqual|Less)?|S(u(cceeds(SlantEqual|Tilde|Equal)?|perset(Equal)?|bset(Equal)?)|quareSu(perset(Equal)?|bset(Equal)?))|Hump(DownHump|Equal)|Nested(GreaterGreater|LessLess)|C(ongruent|upCap)|Tilde(Tilde|Equal|FullEqual)?|DoubleVerticalBar|Precedes((?:Slant|)Equal)?|E(qual(Tilde)?|lement|xists)|VerticalBar|Le(ss(Greater|SlantEqual|Tilde|Equal|Less)?|ftTriangle(Bar|Equal)?))?|pf)|u|e(sted(GreaterGreater|LessLess)|wLine|gative(MediumSpace|Thi((?:n|ck)Space)|VeryThinSpace))|Jcy|fr|acute))|(o(s(cr|ol|lash)|h(m|bar)|c(y|ir(c)?)|ti(lde|mes(as)?)|S|int|opf|d(sold|iv|ot|ash|blac)|uml|p(erp|lus|ar)|elig|vbar|f(cir|r)|l(c(ir|ross)|t|ine|arr)|a(st|cute)|r(slope|igof|or|d(er(of)?|[fm])?|v|arr)?|g(t|on|rave)|m(i(nus|cron|d)|ega|acr))|O(s(cr|lash)|c(y|irc)|ti(lde|mes)|opf|dblac|uml|penCurly((?:Double|)Quote)|ver(B(ar|rac(e|ket))|Parenthesis)|fr|Elig|acute|r|grave|m(icron|ega|acr)))|(p(s(cr|i)|h(i(v)?|one|mmat)|cy|i(tchfork|v)?|o(intint|und|pf)|uncsp|er(cnt|tenk|iod|p|mil)|fr|l(us(sim|cir|two|d([ou])|e|acir|mn|b)?|an(ck(h)?|kv))|ar(s(im|l)|t|a(llel)?)?|r(sim|n(sim|E|ap)|cue|ime(s)?|o(d|p(to)?|f(surf|line|alar))|urel|e(c(sim|n(sim|eqq|approx)|curlyeq|eq|approx)?)?|E|ap)?|m)|P(s(cr|i)|hi|cy|i|o(incareplane|pf)|fr|lusMinus|artialD|r(ime|o(duct|portion(al)?)|ecedes(SlantEqual|Tilde|Equal)?)?))|(q(scr|int|opf|u(ot|est(eq)?|at(int|ernions))|prime|fr)|Q(scr|opf|UOT|fr))|(R(s(h|cr)|ho|c(y|edil|aron)|Barr|ight(Ceiling|T(ee(Vector|Arrow)?|riangle(Bar|Equal)?)|Do(ubleBracket|wn(TeeVector|Vector(Bar)?))|Up(TeeVector|DownVector|Vector(Bar)?)|Vector(Bar)?|arrow|Floor|A(ngleBracket|rrow(Bar|LeftArrow)?))|o(undImplies|pf)|uleDelayed|e(verse(UpEquilibrium|E(quilibrium|lement)))?|fr|EG|a(ng|cute|rr(tl)?)|rightarrow)|r(s(h|cr|q(uo(r)?|b)|aquo)|h(o(v)?|ar(d|u(l)?))|nmid|c(y|ub|e(d??il)|aron)|Barr|t(hree|imes|ri([ef]|ltri)?)|i(singdotseq|ng|ght(squigarrow|harpoon(down|up)|threetimes|left(harpoons|arrows)|arrow(tail)?|rightarrows))|Har|o(times|p(f|lus|ar)|a(ng|rr)|brk)|d(sh|ca|quo(r)?|ldhar)|uluhar|p(polint|ar(gt)?)|e(ct|al(s|ine|part)?|g)|f(isht|loor|r)|l(har|arr|m)|a(ng([de]|le)?|c(ute|e)|t(io(nals)?|ail)|dic|emptyv|quo|rr(sim|hk|c|tl|pl|fs|w|lp|ap|b(fs)?)?)|rarr|x|moust(ache)?|b(arr|r(k(sl([du])|e)|ac([ek]))|brk)|A(tail|arr|rr)))|(s(s(cr|tarf|etmn|mile)|h(y|c(hcy|y)|ort(parallel|mid)|arp)|c(sim|y|n(sim|E|ap)|cue|irc|polint|e(dil)?|E|a(p|ron))?|t(ar(f)?|r(ns|aight(phi|epsilon)))|i(gma([fv])?|m(ne|dot|plus|e(q)?|l(E)?|rarr|g(E)?)?)|zlig|o(pf|ftcy|l(b(ar)?)?)|dot([be])?|u(ng|cc(sim|n(sim|eqq|approx)|curlyeq|eq|approx)?|p(s(im|u([bp])|et(neq(q)?|eq(q)?)?)|hs(ol|ub)|1|n([Ee])|2|d(sub|ot)|3|plus|e(dot)?|E|larr|mult)?|m|b(s(im|u([bp])|et(neq(q)?|eq(q)?)?)|n([Ee])|dot|plus|e(dot)?|E|rarr|mult)?)|pa(des(uit)?|r)|e(swar|ct|tm(n|inus)|ar(hk|r(ow)?)|xt|mi|Arr)|q(su(p(set(eq)?|e)?|b(set(eq)?|e)?)|c(up(s)?|ap(s)?)|u(f|ar([ef]))?)|fr(own)?|w(nwar|ar(hk|r(ow)?)|Arr)|larr|acute|rarr|m(t(e(s)?)?|i(d|le)|eparsl|a(shp|llsetminus))|bquo)|S(scr|hort((?:Right|Down|Up|Left)Arrow)|c(y|irc|edil|aron)?|tar|igma|H(cy|CHcy)|opf|u(c(hThat|ceeds(SlantEqual|Tilde|Equal)?)|p(set|erset(Equal)?)?|m|b(set(Equal)?)?)|OFTcy|q(uare(Su(perset(Equal)?|bset(Equal)?)|Intersection|Union)?|rt)|fr|acute|mallCircle))|(t(s(hcy|c([ry])|trok)|h(i(nsp|ck(sim|approx))|orn|e(ta(sym|v)?|re(4|fore))|k(sim|ap))|c(y|edil|aron)|i(nt|lde|mes(d|b(ar)?)?)|o(sa|p(cir|f(ork)?|bot)?|ea)|dot|prime|elrec|fr|w(ixt|ohead((?:lef|righ)tarrow))|a(u|rget)|r(i(sb|time|dot|plus|e|angle(down|q|left(eq)?|right(eq)?)?|minus)|pezium|ade)|brk)|T(s(cr|trok)|RADE|h(i((?:n|ck)Space)|e(ta|refore))|c(y|edil|aron)|S(H??cy)|ilde(Tilde|Equal|FullEqual)?|HORN|opf|fr|a([bu])|ripleDot))|(u(scr|h(ar([lr])|blk)|c(y|irc)|t(ilde|dot|ri(f)?)|Har|o(pf|gon)|d(har|arr|blac)|u(arr|ml)|p(si(h|lon)?|harpoon(left|right)|downarrow|uparrows|lus|arrow)|f(isht|r)|wangle|l(c(orn(er)?|rop)|tri)|a(cute|rr)|r(c(orn(er)?|rop)|tri|ing)|grave|m(l|acr)|br(cy|eve)|Arr)|U(scr|n(ion(Plus)?|der(B(ar|rac(e|ket))|Parenthesis))|c(y|irc)|tilde|o(pf|gon)|dblac|uml|p(si(lon)?|downarrow|Tee(Arrow)?|per((?:Righ|Lef)tArrow)|DownArrow|Equilibrium|arrow|Arrow(Bar|DownArrow)?)|fr|a(cute|rr(ocir)?)|ring|grave|macr|br(cy|eve)))|(v(s(cr|u(pn([Ee])|bn([Ee])))|nsu([bp])|cy|Bar(v)?|zigzag|opf|dash|prop|e(e(eq|bar)?|llip|r(t|bar))|Dash|fr|ltri|a(ngrt|r(s(igma|u(psetneq(q)?|bsetneq(q)?))|nothing|t(heta|riangle(left|right))|p(hi|i|ropto)|epsilon|kappa|r(ho)?))|rtri|Arr)|V(scr|cy|opf|dash(l)?|e(e|r(yThinSpace|t(ical(Bar|Separator|Tilde|Line))?|bar))|Dash|vdash|fr|bar))|(w(scr|circ|opf|p|e(ierp|d(ge(q)?|bar))|fr|r(eath)?)|W(scr|circ|opf|edge|fr))|(X(scr|i|opf|fr)|x(s(cr|qcup)|h([Aa]rr)|nis|c(irc|up|ap)|i|o(time|dot|p(f|lus))|dtri|u(tri|plus)|vee|fr|wedge|l([Aa]rr)|r([Aa]rr)|map))|(y(scr|c(y|irc)|icy|opf|u(cy|ml)|en|fr|ac(y|ute))|Y(scr|c(y|irc)|opf|uml|Icy|Ucy|fr|acute|Acy))|(z(scr|hcy|c(y|aron)|igrarr|opf|dot|e(ta|etrf)|fr|w(n?j)|acute)|Z(scr|c(y|aron)|Hcy|opf|dot|e(ta|roWidthSpace)|fr|acute)))(;)","name":"constant.character.entity.named.$2.html"},{"captures":{"1":{"name":"punctuation.definition.entity.html"},"3":{"name":"punctuation.definition.entity.html"}},"match":"(&)#[0-9]+(;)","name":"constant.character.entity.numeric.decimal.html"},{"captures":{"1":{"name":"punctuation.definition.entity.html"},"3":{"name":"punctuation.definition.entity.html"}},"match":"(&)#[Xx]\\\\h+(;)","name":"constant.character.entity.numeric.hexadecimal.html"},{"match":"&(?=[0-9A-Za-z]+;)","name":"invalid.illegal.ambiguous-ampersand.html"}]},"heading":{"captures":{"1":{"patterns":[{"captures":{"1":{"name":"punctuation.definition.heading.markdown"},"2":{"name":"entity.name.section.markdown","patterns":[{"include":"text.html.markdown#inline"},{"include":"text.html.derivative"}]},"3":{"name":"punctuation.definition.heading.markdown"}},"match":"(#{6})\\\\s+(.*?)(?:\\\\s+(#+))?\\\\s*$","name":"heading.6.markdown"},{"captures":{"1":{"name":"punctuation.definition.heading.markdown"},"2":{"name":"entity.name.section.markdown","patterns":[{"include":"text.html.markdown#inline"},{"include":"text.html.derivative"}]},"3":{"name":"punctuation.definition.heading.markdown"}},"match":"(#{5})\\\\s+(.*?)(?:\\\\s+(#+))?\\\\s*$","name":"heading.5.markdown"},{"captures":{"1":{"name":"punctuation.definition.heading.markdown"},"2":{"name":"entity.name.section.markdown","patterns":[{"include":"text.html.markdown#inline"},{"include":"text.html.derivative"}]},"3":{"name":"punctuation.definition.heading.markdown"}},"match":"(#{4})\\\\s+(.*?)(?:\\\\s+(#+))?\\\\s*$","name":"heading.4.markdown"},{"captures":{"1":{"name":"punctuation.definition.heading.markdown"},"2":{"name":"entity.name.section.markdown","patterns":[{"include":"text.html.markdown#inline"},{"include":"text.html.derivative"}]},"3":{"name":"punctuation.definition.heading.markdown"}},"match":"(#{3})\\\\s+(.*?)(?:\\\\s+(#+))?\\\\s*$","name":"heading.3.markdown"},{"captures":{"1":{"name":"punctuation.definition.heading.markdown"},"2":{"name":"entity.name.section.markdown","patterns":[{"include":"text.html.markdown#inline"},{"include":"text.html.derivative"}]},"3":{"name":"punctuation.definition.heading.markdown"}},"match":"(#{2})\\\\s+(.*?)(?:\\\\s+(#+))?\\\\s*$","name":"heading.2.markdown"},{"captures":{"1":{"name":"punctuation.definition.heading.markdown"},"2":{"name":"entity.name.section.markdown","patterns":[{"include":"text.html.markdown#inline"},{"include":"text.html.derivative"}]},"3":{"name":"punctuation.definition.heading.markdown"}},"match":"(#{1})\\\\s+(.*?)(?:\\\\s+(#+))?\\\\s*$","name":"heading.1.markdown"}]}},"match":"(?:^|\\\\G) *(#{1,6}\\\\s+(.*?)(\\\\s+#{1,6})?\\\\s*)$","name":"markup.heading.markdown","patterns":[{"include":"text.html.markdown#inline"}]},"heading-setext":{"patterns":[{"match":"^(={3,})(?=[\\\\t ]*$\\\\n?)","name":"markup.heading.setext.1.markdown"},{"match":"^(-{3,})(?=[\\\\t ]*$\\\\n?)","name":"markup.heading.setext.2.markdown"}]},"inline":{"patterns":[{"include":"#component_inline"},{"include":"#span"},{"include":"#attributes"}]},"lists":{"patterns":[{"begin":"(^|\\\\G)( *)([-*+])([\\\\t ])","beginCaptures":{"3":{"name":"punctuation.definition.list.begin.markdown"}},"name":"markup.list.unnumbered.markdown","patterns":[{"include":"#block"},{"include":"text.html.markdown#list_paragraph"}],"while":"((^|\\\\G)[\\\\t ]+)|^([\\\\t ]*)$"},{"begin":"(^|\\\\G)( *)([0-9]+\\\\.)([\\\\t ])","beginCaptures":{"3":{"name":"punctuation.definition.list.begin.markdown"}},"name":"markup.list.numbered.markdown","patterns":[{"include":"#block"},{"include":"text.html.markdown#list_paragraph"}],"while":"((^|\\\\G)[\\\\t ]+)|^([\\\\t ]*)$"}]},"paragraph":{"begin":"(^|\\\\G) *(?=\\\\S)","name":"meta.paragraph.markdown","patterns":[{"include":"text.html.markdown#inline"},{"include":"text.html.derivative"},{"include":"#heading-setext"}],"while":"(^|\\\\G)((?=\\\\s*[-=]{3,}\\\\s*$)| {4,}(?=\\\\S))"},"span":{"captures":{"1":{"name":"punctuation.definition.tag.start.component"},"2":{"name":"string.other.link.description.title.markdown"},"3":{"name":"punctuation.definition.tag.end.component"},"4":{"patterns":[{"include":"#attributes"}]}},"match":"(\\\\[)([^]]*)(])((\\\\{)([^{]*)(}))?\\\\s","name":"span.component.mdc"}},"scopeName":"text.markdown.mdc.standalone","embeddedLangs":["markdown","yaml","html-derivative"]}`)),i=[...n,...t,...e,r];export{i as default};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./diagnostics-DN_idNHx.js";import{c as t,i as n,s as r,t as i}from"./transform-messages-N_eMsP2M.js";import{n as a}from"./json-parse-CgFfIg4Q.js";import{t as o}from"./headers-CbDaTl3c.js";import{t as s}from"./sanitize-unicode-DmIE6hZJ.js";import{i as c,o as l}from"./constrained-sampling-Zzx2ko9x.js";import{t as u}from"./hash-yQufAZII.js";var d=9,f=4e3,p=(t,n,r)=>{let a=new e;return(async()=>{let e=h(t);try{let o=r?.apiKey;if(!o)throw Error(`No API key for provider: ${t.provider}`);let s=g(),c=F(t,n,i(n.messages,t,e=>s(e)),r),l=await r?.onPayload?.(c,t);l!==void 0&&(c=l);let u=await x(t,c,o,r);if(a.push({type:`start`,partial:e}),await R(t,e,a,u),r?.signal?.aborted)throw Error(`Request was aborted`);if(e.stopReason===`pending`)throw Error(`Mistral stream ended without a finish reason`);if(e.stopReason===`aborted`||e.stopReason===`error`)throw Error(e.errorMessage||`An unknown error occurred`);a.push({type:`done`,reason:e.stopReason,message:e}),a.end()}catch(t){for(let t of e.content)delete t.partialArgs;e.stopReason=r?.signal?.aborted?`aborted`:`error`,e.errorMessage=v(t),a.push({type:`error`,reason:e.stopReason,error:e}),a.end()}})(),a},m=(e,r,i)=>{let a=i?.apiKey;if(!a)throw Error(`No API key for provider: ${e.provider}`);let o=n(e,r,i,a),s=i?.reasoning?t(e,i.reasoning):void 0,c=s===`off`?void 0:s,l=e.reasoning&&c!==void 0;return p(e,r,{...o,promptMode:l&&W(e)?`reasoning`:void 0,reasoningEffort:l&&U(e)?G(e,c):void 0})};function h(e){return{role:`assistant`,content:[],api:e.api,provider:e.provider,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:`pending`,timestamp:Date.now()}}function g(){let e=new Map,t=new Map;return n=>{let r=e.get(n);if(r)return r;let i=0;for(;;){let r=_(n,i),a=t.get(r);if(!a||a===n)return e.set(n,r),t.set(r,n),r;i++}}}function _(e,t){let n=e.replace(/[^a-zA-Z0-9]/g,``);if(t===0&&n.length===d)return n;let r=n||e,i=t===0?r:`${r}:${t}`;return u(i).replace(/[^a-zA-Z0-9]/g,``).slice(0,d)}function v(e){if(e instanceof Error){let t=e,n=typeof t.statusCode==`number`?t.statusCode:void 0,r=typeof t.body==`string`?t.body.trim():void 0;return n!==void 0&&r?`Mistral API error (${n}): ${y(r,f)}`:n===void 0?e.message:`Mistral API error (${n}): ${e.message}`}return b(e)}function y(e,t){return e.length<=t?e:`${e.slice(0,t)}... [truncated ${e.length-t} chars]`}function b(e){try{let t=JSON.stringify(e);return t===void 0?String(e):t}catch{return String(e)}}async function x(e,t,n,r){let i=new URL(e.baseUrl);i.pathname=`${i.pathname.replace(/\/+$/u,``)}/`;let a=new URL(`v1/chat/completions`,i),s=C(e,n,r),c=AbortSignal.timeout(r?.timeoutMs??6e4),l=r?.signal?AbortSignal.any([r.signal,c]):c,u=await(r?.fetch??globalThis.fetch)(a,{method:`POST`,headers:s,body:JSON.stringify(E(t)),signal:l});if(await r?.onResponse?.({status:u.status,headers:o(u.headers)},e),!u.ok){let e=await u.text();throw new S(u.status,e,u.statusText)}if(!u.body)throw Error(`Mistral response has no body`);return M(u.body,l)}var S=class extends Error{statusCode;body;constructor(e,t,n){super(n||`Request failed with status ${e}`),this.name=`MistralHttpError`,this.statusCode=e,this.body=t}};function C(e,t,n){let r=new Headers({accept:`text/event-stream`,authorization:`Bearer ${t}`,"content-type":`application/json`});w(r,e.headers),w(r,n?.headers);let i=T(e.headers,`x-affinity`)||T(n?.headers,`x-affinity`);return I(n)&&!i&&r.set(`x-affinity`,n.sessionId),r}function w(e,t){if(t)for(let[n,r]of Object.entries(t))r===null?e.delete(n):e.set(n,r)}function T(e,t){return!!e&&Object.keys(e).some(e=>e.toLowerCase()===t)}function E(e){let t={...e};for(let[e,n]of[[`topP`,`top_p`],[`maxTokens`,`max_tokens`],[`randomSeed`,`random_seed`],[`responseFormat`,`response_format`],[`toolChoice`,`tool_choice`],[`presencePenalty`,`presence_penalty`],[`frequencyPenalty`,`frequency_penalty`],[`parallelToolCalls`,`parallel_tool_calls`],[`reasoningEffort`,`reasoning_effort`],[`promptMode`,`prompt_mode`],[`promptCacheKey`,`prompt_cache_key`],[`safePrompt`,`safe_prompt`]])k(t,e,n);t.messages=e.messages.map(e=>D(e));let n=t.response_format;if(A(n)){let e={...n};k(e,`jsonSchema`,`json_schema`);let r=e.json_schema;if(A(r)){let t={...r};k(t,`schemaDefinition`,`schema`),e.json_schema=t}t.response_format=e}return t}function D(e){let t={...e};return k(t,`toolCalls`,`tool_calls`),k(t,`toolCallId`,`tool_call_id`),Array.isArray(e.content)&&(t.content=e.content.map(e=>O(e))),t}function O(e){let t={...e};for(let[e,n]of[[`imageUrl`,`image_url`],[`documentUrl`,`document_url`],[`documentName`,`document_name`],[`fileId`,`file_id`],[`referenceIds`,`reference_ids`],[`inputAudio`,`input_audio`]])k(t,e,n);return t}function k(e,t,n){t in e&&(e[n]=e[t],delete e[t])}function A(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var j=Symbol(`mistral-stream-done`);async function*M(e,t){let n=e.getReader(),r=new TextDecoder,i=``,a=()=>{n.cancel().catch(()=>{})};t.addEventListener(`abort`,a,{once:!0});try{for(;;){if(t.aborted)throw t.reason;let{done:e,value:a}=await n.read();if(t.aborted)throw t.reason;i+=e?r.decode():r.decode(a,{stream:!0});let o=N(i);for(;o;){let e=P(i.slice(0,o.index));if(i=i.slice(o.index+o.length),e===j)return;e&&(yield e),o=N(i)}if(e)break}if(i.trim()){let e=P(i);e!==j&&e&&(yield e)}}finally{t.removeEventListener(`abort`,a);try{await n.cancel()}catch{}try{n.releaseLock()}catch{}}}function N(e){let t=/\r\n\r\n|\r\n\r|\r\n\n|\r\r\n|\n\r\n|\r\r|\n\r|\n\n/u.exec(e);return t?.index===void 0?void 0:{index:t.index,length:t[0].length}}function P(e){let t=e.split(/\r\n|\r|\n/u).filter(e=>e.startsWith(`data:`)).map(e=>e.slice(5).trimStart()).join(`
|
|
2
|
-
`).trim();if(!t)return;if(t===`[DONE]`)return j;let n=JSON.parse(t);if(!A(n)||!Array.isArray(n.choices))throw Error(`Invalid Mistral streaming event`);return{data:n}}function F(e,t,n,r){let i={model:e.id,stream:!0,messages:V(n,e.input.includes(`image`))};return t.tools?.length&&(i.tools=z(t.tools)),r?.temperature!==void 0&&(i.temperature=r.temperature),r?.maxTokens!==void 0&&(i.maxTokens=r.maxTokens),r?.toolChoice&&(i.toolChoice=K(r.toolChoice)),r?.promptMode&&(i.promptMode=r.promptMode),r?.reasoningEffort&&(i.reasoningEffort=r.reasoningEffort),I(r)&&(i.promptCacheKey=r.sessionId),t.systemPrompt&&i.messages.unshift({role:`system`,content:s(t.systemPrompt)}),i}function I(e){return e?.cacheRetention!==`none`&&!!e?.sessionId}function L(e,t){let n=e,r=n.promptTokensDetails?.cachedTokens??n.prompt_tokens_details?.cached_tokens??n.promptTokenDetails?.cachedTokens??n.prompt_token_details?.cached_tokens??n.numCachedTokens??n.num_cached_tokens??0;return Math.min(t,Math.max(0,typeof r==`number`&&Number.isFinite(r)?r:0))}async function R(e,t,n,i){let o=null,c=t.content,l=()=>c.length-1,u=new Map,d=e=>{if(e){if(e.type===`text`){n.push({type:`text_end`,contentIndex:l(),content:e.text,partial:t});return}e.type===`thinking`&&n.push({type:`thinking_end`,contentIndex:l(),content:e.thinking,partial:t})}};for await(let c of i){let i=c.data;if(t.responseId||=i.id,i.usage){let n=i.usage.prompt_tokens||0,a=L(i.usage,n);t.usage.input=Math.max(0,n-a),t.usage.output=i.usage.completion_tokens||0,t.usage.cacheRead=a,t.usage.cacheWrite=0,t.usage.totalTokens=i.usage.total_tokens||t.usage.input+t.usage.output+t.usage.cacheRead+t.usage.cacheWrite,r(e,t.usage)}let f=i.choices[0];if(!f)continue;if(f.finish_reason){t.rawStopReason=f.finish_reason;let e=q(f.finish_reason);t.stopReason=e.stopReason,e.errorMessage&&(t.errorMessage=e.errorMessage)}let p=f.delta;if(p.content!==null&&p.content!==void 0){let e=typeof p.content==`string`?[p.content]:p.content;for(let r of e){if(typeof r==`string`){let e=s(r);(!o||o.type!==`text`)&&(d(o),o={type:`text`,text:``},t.content.push(o),n.push({type:`text_start`,contentIndex:l(),partial:t})),o.text+=e,n.push({type:`text_delta`,contentIndex:l(),delta:e,partial:t});continue}if(r.type===`thinking`){let e=(r.thinking??[]).map(e=>e.text??``).filter(e=>e.length>0).join(``),i=s(e);if(!i)continue;(!o||o.type!==`thinking`)&&(d(o),o={type:`thinking`,thinking:``},t.content.push(o),n.push({type:`thinking_start`,contentIndex:l(),partial:t})),o.thinking+=i,n.push({type:`thinking_delta`,contentIndex:l(),delta:i,partial:t});continue}if(r.type===`text`){let e=s(r.text??``);(!o||o.type!==`text`)&&(d(o),o={type:`text`,text:``},t.content.push(o),n.push({type:`text_start`,contentIndex:l(),partial:t})),o.text+=e,n.push({type:`text_delta`,contentIndex:l(),delta:e,partial:t})}}}let m=p.tool_calls||[];for(let e of m){o&&=(d(o),null);let r=e.id&&e.id!==`null`?e.id:_(`toolcall:${e.index??0}`,0),i=`${r}:${e.index||0}`,s=u.get(i),c;if(s!==void 0){let e=t.content[s];e?.type===`toolCall`&&(c=e)}c||(c={type:`toolCall`,id:r,name:e.function.name,arguments:{},partialArgs:``},t.content.push(c),u.set(i,t.content.length-1),n.push({type:`toolcall_start`,contentIndex:t.content.length-1,partial:t}));let l=typeof e.function.arguments==`string`?e.function.arguments:JSON.stringify(e.function.arguments||{});c.partialArgs=(c.partialArgs||``)+l,c.arguments=a(c.partialArgs),n.push({type:`toolcall_delta`,contentIndex:u.get(i),delta:l,partial:t})}}d(o);for(let e of u.values()){let r=t.content[e];if(r.type!==`toolCall`)continue;let i=r;i.arguments=a(i.partialArgs),delete i.partialArgs,n.push({type:`toolcall_end`,contentIndex:e,toolCall:i,partial:t})}}function z(e){return e.map(e=>{let t=l(e,!0);return{type:`function`,function:{name:e.name,description:e.description,parameters:B(c(e,t)),strict:t??!1}}})}function B(e){if(Array.isArray(e))return e.map(e=>B(e));if(e&&typeof e==`object`){let t={};for(let[n,r]of Object.entries(e))t[n]=B(r);return t}return e}function V(e,t){let n=[];for(let r of e){if(r.role===`user`){if(typeof r.content==`string`){n.push({role:`user`,content:s(r.content)});continue}let e=r.content.some(e=>e.type===`image`),i=r.content.filter(e=>e.type===`text`||t).map(e=>e.type===`text`?{type:`text`,text:s(e.text)}:{type:`image_url`,imageUrl:`data:${e.mimeType};base64,${e.data}`});if(i.length>0){n.push({role:`user`,content:i});continue}e&&!t&&n.push({role:`user`,content:`(image omitted: model does not support images)`});continue}if(r.role===`assistant`){let e=[],t=[];for(let n of r.content){if(n.type===`text`){n.text.trim().length>0&&e.push({type:`text`,text:s(n.text)});continue}if(n.type===`thinking`){n.thinking.trim().length>0&&e.push({type:`thinking`,thinking:[{type:`text`,text:s(n.thinking)}]});continue}t.push({id:n.id,type:`function`,function:{name:n.name,arguments:JSON.stringify(n.arguments||{})},index:0})}let i={role:`assistant`,prefix:!1};e.length>0&&(i.content=e),t.length>0&&(i.toolCalls=t),(e.length>0||t.length>0)&&n.push(i);continue}let e=[],i=H(r.content.filter(e=>e.type===`text`).map(e=>e.type===`text`?s(e.text):``).join(`
|
|
3
|
-
`),r.content.some(e=>e.type===`image`),t,r.isError);e.push({type:`text`,text:i});for(let n of r.content)t&&n.type===`image`&&e.push({type:`image_url`,imageUrl:`data:${n.mimeType};base64,${n.data}`});n.push({role:`tool`,toolCallId:r.toolCallId,name:r.toolName,content:e})}return n}function H(e,t,n,r){let i=e.trim(),a=r?`[tool error] `:``;return i.length>0?`${a}${i}${t&&!n?`
|
|
4
|
-
[tool image omitted: model does not support images]`:``}`:t?n?r?`[tool error] (see attached image)`:`(see attached image)`:r?`[tool error] (image omitted: model does not support images)`:`(image omitted: model does not support images)`:r?`[tool error] (no tool output)`:`(no tool output)`}function U(e){return e.id===`mistral-small-2603`||e.id===`mistral-small-latest`||e.id===`mistral-medium-3.5`}function W(e){return e.reasoning&&!U(e)}function G(e,t){return e.thinkingLevelMap?.[t]??`high`}function K(e){if(e)return e===`auto`||e===`none`||e===`any`||e===`required`?e:{type:`function`,function:{name:e.function.name}}}function q(e){if(e===null)return{stopReason:`stop`};switch(e){case`stop`:return{stopReason:`stop`};case`length`:case`model_length`:return{stopReason:`length`};case`tool_calls`:return{stopReason:`toolUse`};case`error`:return{stopReason:`error`,errorMessage:`Provider stopped with: error`};default:return{stopReason:`error`,errorMessage:`Provider stopped with: ${e}`}}}export{p as stream,m as streamSimple};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./diagnostics-DN_idNHx.js";import{c as t,i as n,s as r,t as i}from"./transform-messages-DEFauvrq.js";import{n as a}from"./json-parse-ClXMvBdK.js";import{t as o}from"./headers-CbDaTl3c.js";import{t as s}from"./sanitize-unicode-DmIE6hZJ.js";import{i as c,o as l}from"./constrained-sampling-BNmnoM-i.js";import{t as u}from"./hash-yQufAZII.js";const d=(t,n,r)=>{let a=new e;return(async()=>{let e=p(t);try{let o=r?.apiKey;if(!o)throw Error(`No API key for provider: ${t.provider}`);let s=m(),c=N(t,n,i(n.messages,t,e=>s(e)),r),l=await r?.onPayload?.(c,t);l!==void 0&&(c=l);let u=await y(t,c,o,r);if(a.push({type:`start`,partial:e}),await I(t,e,a,u),r?.signal?.aborted)throw Error(`Request was aborted`);if(e.stopReason===`pending`)throw Error(`Mistral stream ended without a finish reason`);if(e.stopReason===`aborted`||e.stopReason===`error`)throw Error(e.errorMessage||`An unknown error occurred`);a.push({type:`done`,reason:e.stopReason,message:e}),a.end()}catch(t){for(let t of e.content)delete t.partialArgs;e.stopReason=r?.signal?.aborted?`aborted`:`error`,e.errorMessage=g(t),a.push({type:`error`,reason:e.stopReason,error:e}),a.end()}})(),a},f=(e,r,i)=>{let a=i?.apiKey;if(!a)throw Error(`No API key for provider: ${e.provider}`);let o=n(e,r,i,a),s=i?.reasoning?t(e,i.reasoning):void 0,c=s===`off`?void 0:s,l=e.reasoning&&c!==void 0;return d(e,r,{...o,promptMode:l&&H(e)?`reasoning`:void 0,reasoningEffort:l&&V(e)?U(e,c):void 0})};function p(e){return{role:`assistant`,content:[],api:e.api,provider:e.provider,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:`pending`,timestamp:Date.now()}}function m(){let e=new Map,t=new Map;return n=>{let r=e.get(n);if(r)return r;let i=0;for(;;){let r=h(n,i),a=t.get(r);if(!a||a===n)return e.set(n,r),t.set(r,n),r;i++}}}function h(e,t){let n=e.replace(/[^a-zA-Z0-9]/g,``);if(t===0&&n.length===9)return n;let r=n||e,i=t===0?r:`${r}:${t}`;return u(i).replace(/[^a-zA-Z0-9]/g,``).slice(0,9)}function g(e){if(e instanceof Error){let t=e,n=typeof t.statusCode==`number`?t.statusCode:void 0,r=typeof t.body==`string`?t.body.trim():void 0;return n!==void 0&&r?`Mistral API error (${n}): ${_(r,4e3)}`:n===void 0?e.message:`Mistral API error (${n}): ${e.message}`}return v(e)}function _(e,t){return e.length<=t?e:`${e.slice(0,t)}... [truncated ${e.length-t} chars]`}function v(e){try{let t=JSON.stringify(e);return t===void 0?String(e):t}catch{return String(e)}}async function y(e,t,n,r){let i=new URL(e.baseUrl);i.pathname=`${i.pathname.replace(/\/+$/u,``)}/`;let a=new URL(`v1/chat/completions`,i),s=x(e,n,r),c=AbortSignal.timeout(r?.timeoutMs??6e4),l=r?.signal?AbortSignal.any([r.signal,c]):c,u=await(r?.fetch??globalThis.fetch)(a,{method:`POST`,headers:s,body:JSON.stringify(w(t)),signal:l});if(await r?.onResponse?.({status:u.status,headers:o(u.headers)},e),!u.ok){let e=await u.text();throw new b(u.status,e,u.statusText)}if(!u.body)throw Error(`Mistral response has no body`);return A(u.body,l)}var b=class extends Error{statusCode;body;constructor(e,t,n){super(n||`Request failed with status ${e}`),this.name=`MistralHttpError`,this.statusCode=e,this.body=t}};function x(e,t,n){let r=new Headers({accept:`text/event-stream`,authorization:`Bearer ${t}`,"content-type":`application/json`});S(r,e.headers),S(r,n?.headers);let i=C(e.headers,`x-affinity`)||C(n?.headers,`x-affinity`);return P(n)&&!i&&r.set(`x-affinity`,n.sessionId),r}function S(e,t){if(t)for(let[n,r]of Object.entries(t))r===null?e.delete(n):e.set(n,r)}function C(e,t){return!!e&&Object.keys(e).some(e=>e.toLowerCase()===t)}function w(e){let t={...e};for(let[e,n]of[[`topP`,`top_p`],[`maxTokens`,`max_tokens`],[`randomSeed`,`random_seed`],[`responseFormat`,`response_format`],[`toolChoice`,`tool_choice`],[`presencePenalty`,`presence_penalty`],[`frequencyPenalty`,`frequency_penalty`],[`parallelToolCalls`,`parallel_tool_calls`],[`reasoningEffort`,`reasoning_effort`],[`promptMode`,`prompt_mode`],[`promptCacheKey`,`prompt_cache_key`],[`safePrompt`,`safe_prompt`]])D(t,e,n);t.messages=e.messages.map(e=>T(e));let n=t.response_format;if(O(n)){let e={...n};D(e,`jsonSchema`,`json_schema`);let r=e.json_schema;if(O(r)){let t={...r};D(t,`schemaDefinition`,`schema`),e.json_schema=t}t.response_format=e}return t}function T(e){let t={...e};return D(t,`toolCalls`,`tool_calls`),D(t,`toolCallId`,`tool_call_id`),Array.isArray(e.content)&&(t.content=e.content.map(e=>E(e))),t}function E(e){let t={...e};for(let[e,n]of[[`imageUrl`,`image_url`],[`documentUrl`,`document_url`],[`documentName`,`document_name`],[`fileId`,`file_id`],[`referenceIds`,`reference_ids`],[`inputAudio`,`input_audio`]])D(t,e,n);return t}function D(e,t,n){t in e&&(e[n]=e[t],delete e[t])}function O(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const k=Symbol(`mistral-stream-done`);async function*A(e,t){let n=e.getReader(),r=new TextDecoder,i=``,a=()=>{n.cancel().catch(()=>{})};t.addEventListener(`abort`,a,{once:!0});try{for(;;){if(t.aborted)throw t.reason;let{done:e,value:a}=await n.read();if(t.aborted)throw t.reason;i+=e?r.decode():r.decode(a,{stream:!0});let o=j(i);for(;o;){let e=M(i.slice(0,o.index));if(i=i.slice(o.index+o.length),e===k)return;e&&(yield e),o=j(i)}if(e)break}if(i.trim()){let e=M(i);e!==k&&e&&(yield e)}}finally{t.removeEventListener(`abort`,a);try{await n.cancel()}catch{}try{n.releaseLock()}catch{}}}function j(e){let t=/\r\n\r\n|\r\n\r|\r\n\n|\r\r\n|\n\r\n|\r\r|\n\r|\n\n/u.exec(e);return t?.index===void 0?void 0:{index:t.index,length:t[0].length}}function M(e){let t=e.split(/\r\n|\r|\n/u).filter(e=>e.startsWith(`data:`)).map(e=>e.slice(5).trimStart()).join(`
|
|
2
|
-
`).trim();if(!t)return;if(t===`[DONE]`)return k;let n=JSON.parse(t);if(!O(n)||!Array.isArray(n.choices))throw Error(`Invalid Mistral streaming event`);return{data:n}}function N(e,t,n,r){let i={model:e.id,stream:!0,messages:z(n,e.input.includes(`image`))};return t.tools?.length&&(i.tools=L(t.tools)),r?.temperature!==void 0&&(i.temperature=r.temperature),r?.maxTokens!==void 0&&(i.maxTokens=r.maxTokens),r?.toolChoice&&(i.toolChoice=W(r.toolChoice)),r?.promptMode&&(i.promptMode=r.promptMode),r?.reasoningEffort&&(i.reasoningEffort=r.reasoningEffort),P(r)&&(i.promptCacheKey=r.sessionId),t.systemPrompt&&i.messages.unshift({role:`system`,content:s(t.systemPrompt)}),i}function P(e){return e?.cacheRetention!==`none`&&!!e?.sessionId}function F(e,t){let n=e,r=n.promptTokensDetails?.cachedTokens??n.prompt_tokens_details?.cached_tokens??n.promptTokenDetails?.cachedTokens??n.prompt_token_details?.cached_tokens??n.numCachedTokens??n.num_cached_tokens??0;return Math.min(t,Math.max(0,typeof r==`number`&&Number.isFinite(r)?r:0))}async function I(e,t,n,i){let o=null,c=t.content,l=()=>c.length-1,u=new Map,d=e=>{if(e){if(e.type===`text`){n.push({type:`text_end`,contentIndex:l(),content:e.text,partial:t});return}e.type===`thinking`&&n.push({type:`thinking_end`,contentIndex:l(),content:e.thinking,partial:t})}};for await(let c of i){let i=c.data;if(t.responseId||=i.id,i.usage){let n=i.usage.prompt_tokens||0,a=F(i.usage,n);t.usage.input=Math.max(0,n-a),t.usage.output=i.usage.completion_tokens||0,t.usage.cacheRead=a,t.usage.cacheWrite=0,t.usage.totalTokens=i.usage.total_tokens||t.usage.input+t.usage.output+t.usage.cacheRead+t.usage.cacheWrite,r(e,t.usage)}let f=i.choices[0];if(!f)continue;if(f.finish_reason){t.rawStopReason=f.finish_reason;let e=G(f.finish_reason);t.stopReason=e.stopReason,e.errorMessage&&(t.errorMessage=e.errorMessage)}let p=f.delta;if(p.content!==null&&p.content!==void 0){let e=typeof p.content==`string`?[p.content]:p.content;for(let r of e){if(typeof r==`string`){let e=s(r);(!o||o.type!==`text`)&&(d(o),o={type:`text`,text:``},t.content.push(o),n.push({type:`text_start`,contentIndex:l(),partial:t})),o.text+=e,n.push({type:`text_delta`,contentIndex:l(),delta:e,partial:t});continue}if(r.type===`thinking`){let e=(r.thinking??[]).map(e=>e.text??``).filter(e=>e.length>0).join(``),i=s(e);if(!i)continue;(!o||o.type!==`thinking`)&&(d(o),o={type:`thinking`,thinking:``},t.content.push(o),n.push({type:`thinking_start`,contentIndex:l(),partial:t})),o.thinking+=i,n.push({type:`thinking_delta`,contentIndex:l(),delta:i,partial:t});continue}if(r.type===`text`){let e=s(r.text??``);(!o||o.type!==`text`)&&(d(o),o={type:`text`,text:``},t.content.push(o),n.push({type:`text_start`,contentIndex:l(),partial:t})),o.text+=e,n.push({type:`text_delta`,contentIndex:l(),delta:e,partial:t})}}}let m=p.tool_calls||[];for(let e of m){o&&=(d(o),null);let r=e.id&&e.id!==`null`?e.id:h(`toolcall:${e.index??0}`,0),i=`${r}:${e.index||0}`,s=u.get(i),c;if(s!==void 0){let e=t.content[s];e?.type===`toolCall`&&(c=e)}c||(c={type:`toolCall`,id:r,name:e.function.name,arguments:{},partialArgs:``},t.content.push(c),u.set(i,t.content.length-1),n.push({type:`toolcall_start`,contentIndex:t.content.length-1,partial:t}));let l=typeof e.function.arguments==`string`?e.function.arguments:JSON.stringify(e.function.arguments||{});c.partialArgs=(c.partialArgs||``)+l,c.arguments=a(c.partialArgs),n.push({type:`toolcall_delta`,contentIndex:u.get(i),delta:l,partial:t})}}d(o);for(let e of u.values()){let r=t.content[e];if(r.type!==`toolCall`)continue;let i=r;i.arguments=a(i.partialArgs),delete i.partialArgs,n.push({type:`toolcall_end`,contentIndex:e,toolCall:i,partial:t})}}function L(e){return e.map(e=>{let t=l(e,!0);return{type:`function`,function:{name:e.name,description:e.description,parameters:R(c(e,t)),strict:t??!1}}})}function R(e){if(Array.isArray(e))return e.map(e=>R(e));if(e&&typeof e==`object`){let t={};for(let[n,r]of Object.entries(e))t[n]=R(r);return t}return e}function z(e,t){let n=[];for(let r of e){if(r.role===`user`){if(typeof r.content==`string`){n.push({role:`user`,content:s(r.content)});continue}let e=r.content.some(e=>e.type===`image`),i=r.content.filter(e=>e.type===`text`||t).map(e=>e.type===`text`?{type:`text`,text:s(e.text)}:{type:`image_url`,imageUrl:`data:${e.mimeType};base64,${e.data}`});if(i.length>0){n.push({role:`user`,content:i});continue}e&&!t&&n.push({role:`user`,content:`(image omitted: model does not support images)`});continue}if(r.role===`assistant`){let e=[],t=[];for(let n of r.content){if(n.type===`text`){n.text.trim().length>0&&e.push({type:`text`,text:s(n.text)});continue}if(n.type===`thinking`){n.thinking.trim().length>0&&e.push({type:`thinking`,thinking:[{type:`text`,text:s(n.thinking)}]});continue}t.push({id:n.id,type:`function`,function:{name:n.name,arguments:JSON.stringify(n.arguments||{})},index:0})}let i={role:`assistant`,prefix:!1};e.length>0&&(i.content=e),t.length>0&&(i.toolCalls=t),(e.length>0||t.length>0)&&n.push(i);continue}let e=[],i=B(r.content.filter(e=>e.type===`text`).map(e=>e.type===`text`?s(e.text):``).join(`
|
|
3
|
-
`),r.content.some(e=>e.type===`image`),t,r.isError);e.push({type:`text`,text:i});for(let n of r.content)t&&n.type===`image`&&e.push({type:`image_url`,imageUrl:`data:${n.mimeType};base64,${n.data}`});n.push({role:`tool`,toolCallId:r.toolCallId,name:r.toolName,content:e})}return n}function B(e,t,n,r){let i=e.trim(),a=r?`[tool error] `:``;return i.length>0?`${a}${i}${t&&!n?`
|
|
4
|
-
[tool image omitted: model does not support images]`:``}`:t?n?r?`[tool error] (see attached image)`:`(see attached image)`:r?`[tool error] (image omitted: model does not support images)`:`(image omitted: model does not support images)`:r?`[tool error] (no tool output)`:`(no tool output)`}function V(e){return e.id===`mistral-small-2603`||e.id===`mistral-small-latest`||e.id===`mistral-medium-3.5`}function H(e){return e.reasoning&&!V(e)}function U(e,t){return e.thinkingLevelMap?.[t]??`high`}function W(e){if(e)return e===`auto`||e===`none`||e===`any`||e===`required`?e:{type:`function`,function:{name:e.function.name}}}function G(e){if(e===null)return{stopReason:`stop`};switch(e){case`stop`:return{stopReason:`stop`};case`length`:case`model_length`:return{stopReason:`length`};case`tool_calls`:return{stopReason:`toolUse`};case`error`:return{stopReason:`error`,errorMessage:`Provider stopped with: error`};default:return{stopReason:`error`,errorMessage:`Provider stopped with: ${e}`}}}export{d as stream,f as streamSimple};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e=Object.freeze(JSON.parse(`{"colors":{"activityBar.background":"#272822","activityBar.foreground":"#f8f8f2","badge.background":"#75715E","badge.foreground":"#f8f8f2","button.background":"#75715E","debugToolBar.background":"#1e1f1c","diffEditor.insertedTextBackground":"#4b661680","diffEditor.removedTextBackground":"#90274A70","dropdown.background":"#414339","dropdown.listBackground":"#1e1f1c","editor.background":"#272822","editor.foreground":"#f8f8f2","editor.lineHighlightBackground":"#3e3d32","editor.selectionBackground":"#878b9180","editor.selectionHighlightBackground":"#575b6180","editor.wordHighlightBackground":"#4a4a7680","editor.wordHighlightStrongBackground":"#6a6a9680","editorCursor.foreground":"#f8f8f0","editorGroup.border":"#34352f","editorGroup.dropBackground":"#41433980","editorGroupHeader.tabsBackground":"#1e1f1c","editorHoverWidget.background":"#414339","editorHoverWidget.border":"#75715E","editorIndentGuide.activeBackground":"#767771","editorIndentGuide.background":"#464741","editorLineNumber.activeForeground":"#c2c2bf","editorLineNumber.foreground":"#90908a","editorSuggestWidget.background":"#272822","editorSuggestWidget.border":"#75715E","editorWhitespace.foreground":"#464741","editorWidget.background":"#1e1f1c","focusBorder":"#99947c","input.background":"#414339","inputOption.activeBorder":"#75715E","inputValidation.errorBackground":"#90274A","inputValidation.errorBorder":"#f92672","inputValidation.infoBackground":"#546190","inputValidation.infoBorder":"#819aff","inputValidation.warningBackground":"#848528","inputValidation.warningBorder":"#e2e22e","list.activeSelectionBackground":"#75715E","list.dropBackground":"#414339","list.highlightForeground":"#f8f8f2","list.hoverBackground":"#3e3d32","list.inactiveSelectionBackground":"#414339","menu.background":"#1e1f1c","menu.foreground":"#cccccc","minimap.selectionHighlight":"#878b9180","panel.border":"#414339","panelTitle.activeBorder":"#75715E","panelTitle.activeForeground":"#f8f8f2","panelTitle.inactiveForeground":"#75715E","peekView.border":"#75715E","peekViewEditor.background":"#272822","peekViewEditor.matchHighlightBackground":"#75715E","peekViewResult.background":"#1e1f1c","peekViewResult.matchHighlightBackground":"#75715E","peekViewResult.selectionBackground":"#414339","peekViewTitle.background":"#1e1f1c","pickerGroup.foreground":"#75715E","ports.iconRunningProcessForeground":"#ccccc7","progressBar.background":"#75715E","quickInputList.focusBackground":"#414339","selection.background":"#878b9180","settings.focusedRowBackground":"#4143395A","sideBar.background":"#1e1f1c","sideBarSectionHeader.background":"#272822","statusBar.background":"#414339","statusBar.debuggingBackground":"#75715E","statusBar.noFolderBackground":"#414339","statusBarItem.remoteBackground":"#AC6218","tab.border":"#1e1f1c","tab.inactiveBackground":"#34352f","tab.inactiveForeground":"#ccccc7","tab.lastPinnedBorder":"#414339","terminal.ansiBlack":"#333333","terminal.ansiBlue":"#6A7EC8","terminal.ansiBrightBlack":"#666666","terminal.ansiBrightBlue":"#819aff","terminal.ansiBrightCyan":"#66D9EF","terminal.ansiBrightGreen":"#A6E22E","terminal.ansiBrightMagenta":"#AE81FF","terminal.ansiBrightRed":"#f92672","terminal.ansiBrightWhite":"#f8f8f2","terminal.ansiBrightYellow":"#e2e22e","terminal.ansiCyan":"#56ADBC","terminal.ansiGreen":"#86B42B","terminal.ansiMagenta":"#8C6BC8","terminal.ansiRed":"#C4265E","terminal.ansiWhite":"#e3e3dd","terminal.ansiYellow":"#B3B42B","titleBar.activeBackground":"#1e1f1c","widget.shadow":"#00000098"},"displayName":"Monokai","name":"monokai","semanticHighlighting":true,"tokenColors":[{"settings":{"foreground":"#F8F8F2"}},{"scope":["meta.embedded","source.groovy.embedded","string meta.image.inline.markdown","variable.legacy.builtin.python"],"settings":{"foreground":"#F8F8F2"}},{"scope":"comment","settings":{"foreground":"#88846f"}},{"scope":"string","settings":{"foreground":"#E6DB74"}},{"scope":["punctuation.definition.template-expression","punctuation.section.embedded"],"settings":{"foreground":"#F92672"}},{"scope":["meta.template.expression"],"settings":{"foreground":"#F8F8F2"}},{"scope":"constant.numeric","settings":{"foreground":"#AE81FF"}},{"scope":"constant.language","settings":{"foreground":"#AE81FF"}},{"scope":"constant.character, constant.other","settings":{"foreground":"#AE81FF"}},{"scope":"variable","settings":{"fontStyle":"","foreground":"#F8F8F2"}},{"scope":"keyword","settings":{"foreground":"#F92672"}},{"scope":"storage","settings":{"fontStyle":"","foreground":"#F92672"}},{"scope":"storage.type","settings":{"fontStyle":"italic","foreground":"#66D9EF"}},{"scope":"entity.name.type, entity.name.class, entity.name.namespace, entity.name.scope-resolution","settings":{"fontStyle":"underline","foreground":"#A6E22E"}},{"scope":["entity.other.inherited-class","punctuation.separator.namespace.ruby"],"settings":{"fontStyle":"italic underline","foreground":"#A6E22E"}},{"scope":"entity.name.function","settings":{"fontStyle":"","foreground":"#A6E22E"}},{"scope":"variable.parameter","settings":{"fontStyle":"italic","foreground":"#FD971F"}},{"scope":"entity.name.tag","settings":{"fontStyle":"","foreground":"#F92672"}},{"scope":"entity.other.attribute-name","settings":{"fontStyle":"","foreground":"#A6E22E"}},{"scope":"support.function","settings":{"fontStyle":"","foreground":"#66D9EF"}},{"scope":"support.constant","settings":{"fontStyle":"","foreground":"#66D9EF"}},{"scope":"support.type, support.class","settings":{"fontStyle":"italic","foreground":"#66D9EF"}},{"scope":"support.other.variable","settings":{"fontStyle":""}},{"scope":"invalid","settings":{"fontStyle":"","foreground":"#F44747"}},{"scope":"invalid.deprecated","settings":{"foreground":"#F44747"}},{"scope":"meta.structure.dictionary.json string.quoted.double.json","settings":{"foreground":"#CFCFC2"}},{"scope":"meta.diff, meta.diff.header","settings":{"foreground":"#75715E"}},{"scope":"markup.deleted","settings":{"foreground":"#F92672"}},{"scope":"markup.inserted","settings":{"foreground":"#A6E22E"}},{"scope":"markup.changed","settings":{"foreground":"#E6DB74"}},{"scope":"constant.numeric.line-number.find-in-files - match","settings":{"foreground":"#AE81FFA0"}},{"scope":"entity.name.filename.find-in-files","settings":{"foreground":"#E6DB74"}},{"scope":"markup.quote","settings":{"foreground":"#F92672"}},{"scope":"markup.list","settings":{"foreground":"#E6DB74"}},{"scope":"markup.bold, markup.italic","settings":{"foreground":"#66D9EF"}},{"scope":"markup.inline.raw","settings":{"fontStyle":"","foreground":"#FD971F"}},{"scope":"markup.heading","settings":{"foreground":"#A6E22E"}},{"scope":"markup.heading.setext","settings":{"fontStyle":"bold","foreground":"#A6E22E"}},{"scope":"markup.heading.markdown","settings":{"fontStyle":"bold"}},{"scope":"markup.quote.markdown","settings":{"fontStyle":"italic","foreground":"#75715E"}},{"scope":"markup.bold.markdown","settings":{"fontStyle":"bold"}},{"scope":"string.other.link.title.markdown,string.other.link.description.markdown","settings":{"foreground":"#AE81FF"}},{"scope":"markup.underline.link.markdown,markup.underline.link.image.markdown","settings":{"foreground":"#E6DB74"}},{"scope":"markup.italic.markdown","settings":{"fontStyle":"italic"}},{"scope":"markup.strikethrough","settings":{"fontStyle":"strikethrough"}},{"scope":"markup.list.unnumbered.markdown, markup.list.numbered.markdown","settings":{"foreground":"#f8f8f2"}},{"scope":["punctuation.definition.list.begin.markdown"],"settings":{"foreground":"#A6E22E"}},{"scope":"token.info-token","settings":{"foreground":"#6796e6"}},{"scope":"token.warn-token","settings":{"foreground":"#cd9731"}},{"scope":"token.error-token","settings":{"foreground":"#f44747"}},{"scope":"token.debug-token","settings":{"foreground":"#b267e6"}},{"scope":"variable.language","settings":{"foreground":"#FD971F"}}],"type":"dark"}`));export{e as default};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/account-store-DysucxMw.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/preload-helper-Czpn1I53.js","assets/bedrock-camp-qpZqnqLa.js","assets/diagnostics-DN_idNHx.js","assets/transform-messages-N_eMsP2M.js","assets/provider-env-CTOcDKrQ.js","assets/__vite-browser-external-5eBdwsFd.js","assets/openrouter.models-gbjkpjE_.js","assets/libesm-BI4UHVqp.js","assets/logger-DDBAeTLF.js","assets/src-CAWTvdAa.js","assets/proxied-fetch-B4g-4VbQ.js","assets/base64-DpPqYZJF.js","assets/runtime-env-Dlaokqg1.js","assets/fetch-body-D2PwksUW.js","assets/float-topology-BgioAcOd.js","assets/runtime-env-E-i2SW1s.js","assets/secret-topology-xLmXoozo.js","assets/secrets-bridge-client-cWDAnFqs.js","assets/port-bridge-client-BbVs1yhx.js","assets/image-markers-BXtVm4og.js","assets/tool-ui-DfXu6quJ.js","assets/providers-Crdj27DN.js","assets/panel-rpc-B3MSVImO.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{t as e}from"./preload-helper-Czpn1I53.js";import{t}from"./mime-types-ugOWOUZ9.js";import{n,t as r}from"./base64-DpPqYZJF.js";import"./src-CAWTvdAa.js";import{i,o as a,r as o}from"./proxied-fetch-B4g-4VbQ.js";import{n as s}from"./runtime-env-Dlaokqg1.js";import"./runtime-env-E-i2SW1s.js";import{t as c}from"./types-idfTVsM8.js";import"./backend-local-1YuE96fx.js";import"./mount-table-store-dY2IfQ5S.js";import{t as l}from"./mount-bridge-client-4blXuJO1.js";var u=`https://api.aem.live`,d=`application/folder`,f=5242880;function p(e){let t=e.match(/^aem:\/\/([^/]+)\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid AEM source '${e}' — expected aem://org/site[/path]`);return{org:t[1],site:t[2],path:(t[3]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}function m(e){if(!e)return``;let t=Date.parse(e);return Number.isNaN(t)?``:String(t)}function h(e){let t=Date.parse(e??``);return Number.isNaN(t)?0:t}function g(e){return e.map(e=>e[`content-type`]===d||e.name.endsWith(`/`)?{name:e.name.replace(/\/+$/,``),kind:`directory`}:{name:e.name,kind:`file`,size:e.size,etag:m(e[`last-modified`]),lastModified:h(e[`last-modified`])})}var _=class{kind=`aem`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=p(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??f,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new c(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toSourcePath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`),r=`/${this.parsed.org}/sites/${this.parsed.site}/source`;return n?`${r}/${n}`:r}toListPath(e){return`${this.toSourcePath(e)}/`}request(e,t,n){return this.transport({method:e,path:t,origin:u,headers:n?.headers,body:n?.body})}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r=await this.request(`GET`,this.toSourcePath(t));if(r.status===404)throw await this.cache.invalidateBody(t),new c(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new c(`EACCES`,`aem access denied`,e);if(r.status>=400)throw new c(`EIO`,`aem readFile failed: ${r.status}`,e);let i=new Uint8Array(await r.arrayBuffer());if(i.byteLength>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes`,e);return await this.cache.putBody(t,i,m(r.headers.get(`last-modified`))),i}async assertUnchanged(e,t,n){if(!n)return;let r=await this.request(`HEAD`,this.toSourcePath(t));if(r.status===404)return;if(r.status>=400)throw new c(`EIO`,`aem precondition HEAD failed: ${r.status}`,e);let i=m(r.headers.get(`last-modified`));if(i&&i!==n)throw await this.cache.invalidateBody(t),new c(`EBUSY`,`remote modified since last read — re-read and retry`,e)}async writeFile(e,t){if(this.assertOpen(e),t.byteLength>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes`,e);let n=this.toMountRelative(e),r=await this.cache.getBody(n);await this.assertUnchanged(e,n,r?.etag??``);let i=await this.request(`PUT`,this.toSourcePath(n),{body:t});if(i.status===401||i.status===403)throw new c(`EACCES`,`aem write denied`,e);if(i.status>=400)throw new c(`EIO`,`aem writeFile failed: ${i.status}`,e);await this.cache.invalidateBody(n);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a)}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.request(`GET`,this.toListPath(t));if(r.status===404)throw new c(`ENOENT`,`no such directory`,e);if(r.status===401||r.status===403)throw new c(`EACCES`,`aem access denied`,e);if(r.status>=400)throw new c(`EIO`,`aem list failed: ${r.status}`,e);let i=g(await r.json());return await this.cache.putListing(t,i),i}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e);if(t===``)return{kind:`directory`,size:0,mtime:0};let n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.size,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),i=r.pop()??``,a=r.join(`/`),o=await this.cache.getListing(a),s=(o&&!this.cache.isStale(o.cachedAt)?o.entries:await this.readDirQuietly(a))?.find(e=>e.name===i);if(!s)throw new c(`ENOENT`,`no such file or directory`,e);return s.kind===`directory`?{kind:`directory`,size:0,mtime:s.lastModified??0}:{kind:`file`,size:s.size??0,mtime:s.lastModified??0,etag:s.etag??``}}async readDirQuietly(e){try{return await this.readDir(e)}catch{return null}}async mkdir(e){}async remove(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.request(`DELETE`,this.toSourcePath(t));if(n.status===404)throw new c(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new c(`EACCES`,`aem delete denied`,e);if(n.status>=400)throw new c(`EIO`,`aem delete failed: ${n.status}`,e);await this.cache.invalidateBody(t);let r=t.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(r)}async refresh(e){this.assertOpen(`/`);let t={added:[],removed:[],changed:[],unchanged:0,errors:[]},n=[``];for(;n.length>0;){let e=n.pop();try{await this.refreshDir(e,t,n)}catch(n){t.errors.push({path:e,message:n instanceof Error?n.message:String(n)})}}return e?.bodies&&await this.refreshBodies(t),t}async classifyFile(e,t,n){let r=await this.cache.getBody(e);r?t&&r.etag!==t?(await this.cache.invalidateBody(e),n.changed.push(e)):n.unchanged++:n.added.push(e)}async refreshDir(e,t,n){let r=await this.request(`GET`,this.toListPath(e));if(r.status===404){await this.cache.putListing(e,[]);return}if(r.status>=400){t.errors.push({path:e,message:`list failed: ${r.status}`});return}let i=g(await r.json());for(let r of i){let i=e?`${e}/${r.name}`:r.name;r.kind===`directory`?n.push(i):await this.classifyFile(i,r.etag??``,t)}await this.cache.putListing(e,i)}async refreshBodies(e){for(let t of e.changed)try{await this.readFile(t)}catch(n){e.errors.push({path:t,message:n instanceof Error?n.message:String(n)})}}describe(){return{displayName:`${this.parsed.org}/${this.parsed.site}${this.parsed.path?`/${this.parsed.path}`:``}`,source:this.source,profile:this.profile}}async close(){this.closed||=!0}};function v(e,t,n){let r=`----DaMount${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`,i=new TextEncoder,a=i.encode(`--${r}\r\nContent-Disposition: form-data; name="data"; filename="${e}"\r\nContent-Type: ${t}\r\n\r\n`),o=i.encode(`\r\n--${r}--\r\n`),s=new Uint8Array(a.byteLength+n.byteLength+o.byteLength);return s.set(a,0),s.set(n,a.byteLength),s.set(o,a.byteLength+n.byteLength),{contentType:`multipart/form-data; boundary=${r}`,body:s}}function y(e){return e.split(`/`).pop()||`data`}function b(e){let t=e.match(/^da:\/\/([^/]+)\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid DA source '${e}' — expected da://org/repo[/path]`);return{org:t[1],repo:t[2],path:(t[3]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}var x=5242880,S=class{kind=`da`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=b(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??x,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new c(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toSourcePath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/source/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}toListPath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/list/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r={};n&&(r[`if-none-match`]=n.etag);let i=await this.transport({method:`GET`,path:this.toSourcePath(t),headers:r});if(i.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(i.status===404)throw await this.cache.invalidateBody(t),new c(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new c(`EACCES`,`da access denied`,e);if(i.status>=400)throw new c(`EIO`,`da readFile failed: ${i.status}`,e);let a=i.headers.get(`content-length`),o=a?Number(a):void 0;if(o!==void 0&&o>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes`,e);let s=new Uint8Array(await i.arrayBuffer());if(s.byteLength>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=i.headers.get(`etag`)??``,u=l.startsWith(`W/`)?l.slice(2):l;return await this.cache.putBody(t,s,u),s}async writeFile(e,n){if(this.assertOpen(e),n.byteLength>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=this.toMountRelative(e),i=await this.cache.getBody(r),a=v(y(e),t(e),n),o={"content-type":a.contentType,"content-length":String(a.body.byteLength)};i?.etag?o[`if-match`]=i.etag.startsWith(`W/`)?i.etag.slice(2):i.etag:i||(o[`if-none-match`]=`*`);let s=()=>this.transport({method:`POST`,path:this.toSourcePath(r),headers:o,body:a.body}),l,u=1;try{l=await s()}catch{u=2,l=await s()}if(l.status===412){if(u===2){let t=await this.transport({method:`HEAD`,path:this.toSourcePath(r)});if(t.status>=400)throw new c(`EIO`,`da reconcile HEAD failed: ${t.status}`,e);let i=t.headers.get(`etag`)??``;await this.cache.putBody(r,n,i);let a=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a);return}await this.cache.invalidateBody(r);try{await this.readFile(e)}catch{}throw new c(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(l.status===401||l.status===403)throw new c(`EACCES`,`da write denied`,e);if(l.status>=400)throw new c(`EIO`,`da writeFile failed: ${l.status}`,e);let d=l.headers.get(`etag`)??``;await this.cache.putBody(r,n,d);let f=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(f)}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.transport({method:`GET`,path:this.toListPath(t)});if(r.status===404)throw new c(`ENOENT`,`no such directory`,e);if(r.status>=400)throw new c(`EIO`,`da list failed: ${r.status}`,e);let i=(await r.json()).map(e=>e.ext?{name:`${e.name}.${e.ext}`,kind:`file`,etag:e.etag,lastModified:e.lastModified}:{name:e.name,kind:`directory`,lastModified:e.lastModified});return await this.cache.putListing(t,i),i}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.size,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),i=r.pop()??``,a=r.join(`/`),o=await this.cache.getListing(a);if(o&&!this.cache.isStale(o.cachedAt)){let t=o.entries.find(e=>e.name===i);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??o.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??o.cachedAt};if(!t)throw new c(`ENOENT`,`no such file or directory`,e)}let s=await this.transport({method:`HEAD`,path:this.toSourcePath(t)});if(s.status===200){let e=Number(s.headers.get(`content-length`)??`0`),t=s.headers.get(`etag`)??``,n=s.headers.get(`last-modified`),r=n?Date.parse(n):0;if(o){let n=o.entries.map(n=>n.name===i&&n.kind===`file`?{...n,size:e,etag:t,lastModified:r}:n);await this.cache.putListing(a,n)}return{kind:`file`,size:e,mtime:r,etag:t}}if(s.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new c(`ENOENT`,`no such file or directory`,e)}throw new c(`EIO`,`da stat failed: ${s.status}`,e)}async mkdir(e){}async remove(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.transport({method:`DELETE`,path:this.toSourcePath(t)});if(n.status===404)throw new c(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new c(`EACCES`,`da delete denied`,e);if(n.status>=400)throw new c(`EIO`,`da delete failed: ${n.status}`,e);await this.cache.invalidateBody(t);let r=t.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(r)}async refresh(e){this.assertOpen(`/`);let t={added:[],removed:[],changed:[],unchanged:0,errors:[]},n=[``];for(;n.length>0;){let e=n.pop();try{await this.refreshDir(e,t,n)}catch(n){t.errors.push({path:e,message:n instanceof Error?n.message:String(n)})}}return e?.bodies&&await this.refreshBodies(t),t}async classifyFile(e,t,n){let r=await this.cache.getBody(e);r?t&&r.etag!==t?(await this.cache.invalidateBody(e),n.changed.push(e)):n.unchanged++:n.added.push(e)}async refreshDir(e,t,n){let r=await this.transport({method:`GET`,path:this.toListPath(e)});if(r.status>=400){t.errors.push({path:e,message:`list failed: ${r.status}`});return}let i=await r.json(),a=[];for(let r of i)if(r.ext){let n=e?`${e}/${r.name}.${r.ext}`:`${r.name}.${r.ext}`;a.push({name:`${r.name}.${r.ext}`,kind:`file`,etag:r.etag,lastModified:r.lastModified}),await this.classifyFile(n,r.etag,t)}else a.push({name:r.name,kind:`directory`}),n.push(e?`${e}/${r.name}`:r.name);await this.cache.putListing(e,a)}async refreshBodies(e){for(let t of e.changed)try{await this.readFile(t)}catch(n){e.errors.push({path:t,message:n instanceof Error?n.message:String(n)})}}describe(){return{displayName:`${this.parsed.org}/${this.parsed.repo}${this.parsed.path?`/${this.parsed.path}`:``}`,source:this.source,profile:this.profile}}async close(){this.closed||=!0}};function C(e){let t=e.match(/^s3:\/\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid S3 source '${e}' — expected s3://bucket[/prefix]`);return{bucket:t[1],prefix:(t[2]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}var w=26214400,T=class{kind=`s3`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=C(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??w,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new c(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toS3Key(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``);return[this.parsed.prefix,t].filter(e=>e.length>0).join(`/`)}toMountRelativeKey(e){return this.parsed.prefix?e.slice(this.parsed.prefix.length+1):e}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r={};n&&(r[`if-none-match`]=n.etag);let i=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:this.toS3Key(t),headers:r});if(i.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(i.status===404)throw await this.cache.invalidateBody(t),new c(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new c(`EACCES`,`s3 access denied`,e);if(i.status>=400)throw new c(`EIO`,`s3 readFile failed: ${i.status}`,e);let a=i.headers.get(`content-length`),o=a?Number(a):void 0;if(o!==void 0&&o>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes (${o} > ${this.maxBodyBytes})`,e);let s=new Uint8Array(await i.arrayBuffer());if(s.byteLength>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=i.headers.get(`etag`)??``;return await this.cache.putBody(t,s,l),s}async writeFile(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t.byteLength>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=await this.cache.getBody(n),i={"content-type":`application/octet-stream`,"content-length":String(t.byteLength)};r?i[`if-match`]=r.etag:i[`if-none-match`]=`*`;let a=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(n),headers:i,body:t}),o,s=1;try{o=await a()}catch{s=2,o=await a()}if(o.status===412){if(s===2){let r=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status>=400)throw new c(`EIO`,`s3 reconcile HEAD failed: ${r.status}`,e);let i=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,i);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new c(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(o.status===401||o.status===403)throw new c(`EACCES`,`s3 write denied`,e);if(o.status>=400)throw new c(`EIO`,`s3 writeFile failed: ${o.status}`,e);let l=o.headers.get(`etag`)??``;await this.cache.putBody(n,t,l);let u=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(u)}async listObjectsV2(){let e=[],t;do{let n={"list-type":`2`};this.parsed.prefix&&(n.prefix=`${this.parsed.prefix}/`),t&&(n[`continuation-token`]=t);let r=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:``,query:n});if(r.status>=400)throw new c(`EIO`,`s3 list failed: ${r.status}`,`/`);let i=await r.text(),a=this.parseListingXml(i);e.push(...a.contents),t=a.nextContinuationToken}while(t);return e}parseListingXml(e){let t=[];for(let n of e.matchAll(/<Contents>([\s\S]*?)<\/Contents>/g)){let e=n[1],r=e.match(/<Key>([^<]+)<\/Key>/)?.[1]??``,i=e.match(/<ETag>([^<]+)<\/ETag>/)?.[1]??``,a=e.match(/<Size>([^<]+)<\/Size>/)?.[1]??`0`,o=e.match(/<LastModified>([^<]+)<\/LastModified>/)?.[1]??``;t.push({key:r,etag:i,size:Number(a),lastModified:o?Date.parse(o):0})}return{contents:t,nextContinuationToken:e.match(/<IsTruncated>([^<]+)<\/IsTruncated>/)?.[1]===`true`?e.match(/<NextContinuationToken>([^<]+)<\/NextContinuationToken>/)?.[1]:void 0}}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.listObjectsV2(),i=this.groupByDir(r);for(let[e,t]of i)await this.cache.putListing(e,t);return i.get(t)??[]}groupByDir(e){let t=new Map,n=e=>(t.has(e)||t.set(e,[]),t.get(e));n(``);for(let t of e){let e=this.toMountRelativeKey(t.key).split(`/`),r=e.pop();n(e.join(`/`)).push({name:r,kind:`file`,size:t.size,etag:t.etag,lastModified:t.lastModified});let i=``;for(let t of e){let e=i;i=i?`${i}/${t}`:t;let r=n(e);r.find(e=>e.name===t&&e.kind===`directory`)||r.push({name:t,kind:`directory`}),n(i)}}return t}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.body.byteLength,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),i=r.pop()??``,a=r.join(`/`),o=await this.cache.getListing(a);if(o&&!this.cache.isStale(o.cachedAt)){let t=o.entries.find(e=>e.name===i);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??o.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??o.cachedAt};if(!t)throw new c(`ENOENT`,`no such file or directory`,e)}let s=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(t)});if(s.status===200){let e=Number(s.headers.get(`content-length`)??`0`),t=s.headers.get(`etag`)??``,n=s.headers.get(`last-modified`);return{kind:`file`,size:e,mtime:n?Date.parse(n):0,etag:t}}if(s.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new c(`ENOENT`,`no such file or directory`,e)}throw new c(`EIO`,`s3 stat failed: ${s.status}`,e)}async refresh(e){this.assertOpen(`/`);let t=await this.listObjectsV2(),n=new Set(t.map(e=>this.toMountRelativeKey(e.key))),r=new Map(t.map(e=>[this.toMountRelativeKey(e.key),e.etag])),i={added:[],removed:[],changed:[],unchanged:0,errors:[]};for(let e of n){let t=await this.cache.getBody(e),n=r.get(e);t?t.etag===n?i.unchanged++:(await this.cache.invalidateBody(e),i.changed.push(e)):i.added.push(e)}let a=this.groupByDir(t);for(let[e,t]of a)await this.cache.putListing(e,t);if(e?.bodies)for(let e of i.changed)try{await this.readFile(e)}catch(t){i.errors.push({path:e,message:t instanceof Error?t.message:String(t)})}return i}async mkdir(e){}async remove(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t?.recursive)throw new c(`EINVAL`,`recursive remove not yet supported on S3`,e);let r=await this.transport({method:`DELETE`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status===404)throw new c(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new c(`EACCES`,`s3 delete denied`,e);if(r.status>=400)throw new c(`EIO`,`s3 delete failed: ${r.status}`,e);await this.cache.invalidateBody(n);let i=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(i)}describe(){return{displayName:this.parsed.prefix?`${this.parsed.bucket}/${this.parsed.prefix}`:this.parsed.bucket,source:this.source,profile:this.profile}}async close(){this.closed||=!0}},E=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function D(){let{getAccounts:t}=await e(async()=>{let{getAccounts:e}=await import(`./account-store-DysucxMw.js`).then(e=>e.r);return{getAccounts:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24])),n=t().find(e=>e.providerId===`adobe`);if(!n?.accessToken)throw new E(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>n.accessToken}}var O=`slicc-mount-cache`,k=`listings`,A=`bodies`,j=class{mountId;ttlMs;dbName;dbPromise=null;constructor(e){this.mountId=e.mountId,this.ttlMs=e.ttlMs,this.dbName=e.dbName??O}isStale(e,t){return Date.now()-e>=(t??this.ttlMs)}async openDb(){return this.dbPromise||=new Promise((e,t)=>{let n=indexedDB.open(this.dbName,1);n.onupgradeneeded=()=>{let e=n.result;e.objectStoreNames.contains(k)||e.createObjectStore(k),e.objectStoreNames.contains(A)||e.createObjectStore(A)},n.onsuccess=()=>{let t=n.result;t.onversionchange=()=>{t.close(),this.dbPromise=null},t.onclose=()=>{this.dbPromise=null},e(t)},n.onerror=()=>t(n.error)}),this.dbPromise}key(e){return`${this.mountId}::${e}`}async getListing(e){let t=await this.openDb();return new Promise((n,r)=>{let i=t.transaction(k,`readonly`).objectStore(k).get(this.key(e));i.onsuccess=()=>n(i.result??null),i.onerror=()=>r(i.error)})}async putListing(e,t){let n=await this.openDb();return new Promise((r,i)=>{let a=n.transaction(k,`readwrite`),o={entries:t,cachedAt:Date.now()};a.objectStore(k).put(o,this.key(e)),a.oncomplete=()=>r(),a.onerror=()=>i(a.error)})}async invalidateListing(e){let t=await this.openDb();return new Promise((n,r)=>{let i=t.transaction(k,`readwrite`);i.objectStore(k).delete(this.key(e)),i.oncomplete=()=>n(),i.onerror=()=>r(i.error)})}async getBody(e){let t=await this.openDb();return new Promise((n,r)=>{let i=t.transaction(A,`readonly`).objectStore(A).get(this.key(e));i.onsuccess=()=>n(i.result??null),i.onerror=()=>r(i.error)})}async putBody(e,t,n){let r=await this.openDb(),i={body:t,etag:n,size:t.byteLength,cachedAt:Date.now()};try{await this.txPut(r,A,this.key(e),i)}catch(t){if(t instanceof DOMException&&t.name===`QuotaExceededError`){await this.evictLru(.25);try{await this.txPut(r,A,this.key(e),i)}catch{}return}throw t}}async invalidateBody(e){let t=await this.openDb();return new Promise((n,r)=>{let i=t.transaction(A,`readwrite`);i.objectStore(A).delete(this.key(e)),i.oncomplete=()=>n(),i.onerror=()=>r(i.error)})}async clearMount(){let e=await this.openDb(),t=`${this.mountId}::`,n=n=>new Promise((r,i)=>{let a=e.transaction(n,`readwrite`),o=a.objectStore(n),s=o.getAllKeys();s.onsuccess=()=>{for(let e of s.result)typeof e==`string`&&e.startsWith(t)&&o.delete(e)},a.oncomplete=()=>r(),a.onerror=()=>i(a.error)});await Promise.all([n(k),n(A)])}txPut(e,t,n,r){return new Promise((i,a)=>{let o=e.transaction(t,`readwrite`);o.objectStore(t).put(r,n),o.oncomplete=()=>i(),o.onerror=()=>a(o.error)})}async evictLru(e){let t=await this.openDb(),n=`${this.mountId}::`,r=await new Promise((e,r)=>{let i=t.transaction(A,`readonly`).objectStore(A),a=[],o=i.openCursor();o.onsuccess=()=>{let t=o.result;if(!t){e(a);return}if(typeof t.key==`string`&&t.key.startsWith(n)){let e=t.value;a.push({key:t.key,cachedAt:e.cachedAt})}t.continue()},o.onerror=()=>r(o.error)});r.sort((e,t)=>e.cachedAt-t.cachedAt);let i=Math.max(1,Math.ceil(r.length*e)),a=r.slice(0,i);await new Promise((e,n)=>{let r=t.transaction(A,`readwrite`),i=r.objectStore(A);for(let{key:e}of a)i.delete(e);r.oncomplete=()=>e(),r.onerror=()=>n(r.error)})}},M=r,N=n,P=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),F=new Set([101,103,204,205,304]);function I(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new c(`EACCES`,e.error):e.errorCode===`invalid_request`?new c(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||P.has(String(e.errorCode))?new c(`EIO`,e.error):new c(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=M(e.bodyBase64)}catch(e){throw new c(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let n=F.has(e.status)?null:t;return new Response(n,{status:e.status,headers:new Headers(e.headers)})}async function L(e,t){let n;try{n=await fetch(a(e),{method:`POST`,headers:o({"content-type":`application/json`}),body:JSON.stringify(t)})}catch(e){throw new c(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (SLICC backend at localhost may not be running)`)}try{return await n.json()}catch(e){throw new c(`EIO`,`mount transport: response is not a JSON envelope (status ${n.status}): ${e instanceof Error?e.message:String(e)}`)}}async function R(e,t){try{return await chrome.runtime.sendMessage({type:e,envelope:t})}catch(e){throw new c(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (extension service worker not responding)`)}}async function z(e,t,n){return s()?R(e,n):i()?l(e,n):L(t,n)}function B(e){return async t=>I(await z(`mount.s3-sign-and-forward`,`/api/s3-sign-and-forward`,{profile:e,method:t.method,bucket:t.bucket,key:t.key,query:t.query,headers:t.headers,bodyBase64:t.body?N(t.body):void 0}))}function V(e){let t=e?.getImsToken??(async()=>(await D()).getBearerToken());return async e=>{let n;try{n=await t()}catch(e){throw new c(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}return I(await z(`mount.da-sign-and-forward`,`/api/da-sign-and-forward`,{imsToken:n,method:e.method,path:e.path,origin:e.origin,query:e.query,headers:e.headers,bodyBase64:e.body?N(e.body):void 0}))}}export{_ as AemMountBackend,S as DaMountBackend,j as RemoteMountCache,T as S3MountBackend,V as makeSignedFetchDa,B as makeSignedFetchS3};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{f as t,i as n,o as r,p as i,r as a}from"./proxied-fetch-n2pCvcgW.js";import"./src-CcFD5QfS.js";import{t as o}from"./runtime-env-DadgceZk.js";import{t as s}from"./mime-types-D7IV6i7k.js";import"./runtime-env-Dtj99aNH.js";import{t as c}from"./port-bridge-client-DxYLF2-N.js";import"./backend-local-B6kc_FvN.js";import{t as l}from"./types-idfTVsM8.js";import{t as u}from"./remote-cache-JAv9sQH_.js";const d=`https://api.aem.live`;function f(e){let t=e.match(/^aem:\/\/([^/]+)\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid AEM source '${e}' — expected aem://org/site[/path]`);return{org:t[1],site:t[2],path:(t[3]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}function p(e){if(!e)return``;let t=Date.parse(e);return Number.isNaN(t)?``:String(t)}function m(e){let t=Date.parse(e??``);return Number.isNaN(t)?0:t}function h(e){return e.map(e=>e[`content-type`]===`application/folder`||e.name.endsWith(`/`)?{name:e.name.replace(/\/+$/,``),kind:`directory`}:{name:e.name,kind:`file`,size:e.size,etag:p(e[`last-modified`]),lastModified:m(e[`last-modified`])})}var g=class{kind=`aem`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=f(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??5242880,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new l(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toSourcePath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`),r=`/${this.parsed.org}/sites/${this.parsed.site}/source`;return n?`${r}/${n}`:r}toListPath(e){return`${this.toSourcePath(e)}/`}request(e,t,n){return this.transport({method:e,path:t,origin:d,headers:n?.headers,body:n?.body})}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r=await this.request(`GET`,this.toSourcePath(t));if(r.status===404)throw await this.cache.invalidateBody(t),new l(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new l(`EACCES`,`aem access denied`,e);if(r.status>=400)throw new l(`EIO`,`aem readFile failed: ${r.status}`,e);let i=new Uint8Array(await r.arrayBuffer());if(i.byteLength>this.maxBodyBytes)throw new l(`EFBIG`,`body exceeds maxBodyBytes`,e);return await this.cache.putBody(t,i,p(r.headers.get(`last-modified`))),i}async assertUnchanged(e,t,n){if(!n)return;let r=await this.request(`HEAD`,this.toSourcePath(t));if(r.status===404)return;if(r.status>=400)throw new l(`EIO`,`aem precondition HEAD failed: ${r.status}`,e);let i=p(r.headers.get(`last-modified`));if(i&&i!==n)throw await this.cache.invalidateBody(t),new l(`EBUSY`,`remote modified since last read — re-read and retry`,e)}async writeFile(e,t){if(this.assertOpen(e),t.byteLength>this.maxBodyBytes)throw new l(`EFBIG`,`body exceeds maxBodyBytes`,e);let n=this.toMountRelative(e),r=await this.cache.getBody(n);await this.assertUnchanged(e,n,r?.etag??``);let i=await this.request(`PUT`,this.toSourcePath(n),{body:t});if(i.status===401||i.status===403)throw new l(`EACCES`,`aem write denied`,e);if(i.status>=400)throw new l(`EIO`,`aem writeFile failed: ${i.status}`,e);await this.cache.invalidateBody(n);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a)}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.request(`GET`,this.toListPath(t));if(r.status===404)throw new l(`ENOENT`,`no such directory`,e);if(r.status===401||r.status===403)throw new l(`EACCES`,`aem access denied`,e);if(r.status>=400)throw new l(`EIO`,`aem list failed: ${r.status}`,e);let i=h(await r.json());return await this.cache.putListing(t,i),i}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e);if(t===``)return{kind:`directory`,size:0,mtime:0};let n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.size,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),i=r.pop()??``,a=r.join(`/`),o=await this.cache.getListing(a),s=(o&&!this.cache.isStale(o.cachedAt)?o.entries:await this.readDirQuietly(a))?.find(e=>e.name===i);if(!s)throw new l(`ENOENT`,`no such file or directory`,e);return s.kind===`directory`?{kind:`directory`,size:0,mtime:s.lastModified??0}:{kind:`file`,size:s.size??0,mtime:s.lastModified??0,etag:s.etag??``}}async readDirQuietly(e){try{return await this.readDir(e)}catch{return null}}async mkdir(e){}async remove(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.request(`DELETE`,this.toSourcePath(t));if(n.status===404)throw new l(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new l(`EACCES`,`aem delete denied`,e);if(n.status>=400)throw new l(`EIO`,`aem delete failed: ${n.status}`,e);await this.cache.invalidateBody(t);let r=t.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(r)}async refresh(e){this.assertOpen(`/`);let t={added:[],removed:[],changed:[],unchanged:0,errors:[]},n=[``];for(;n.length>0;){let e=n.pop();try{await this.refreshDir(e,t,n)}catch(n){t.errors.push({path:e,message:n instanceof Error?n.message:String(n)})}}return e?.bodies&&await this.refreshBodies(t),t}async classifyFile(e,t,n){let r=await this.cache.getBody(e);r?t&&r.etag!==t?(await this.cache.invalidateBody(e),n.changed.push(e)):n.unchanged++:n.added.push(e)}async refreshDir(e,t,n){let r=await this.request(`GET`,this.toListPath(e));if(r.status===404){await this.cache.putListing(e,[]);return}if(r.status>=400){t.errors.push({path:e,message:`list failed: ${r.status}`});return}let i=h(await r.json());for(let r of i){let i=e?`${e}/${r.name}`:r.name;r.kind===`directory`?n.push(i):await this.classifyFile(i,r.etag??``,t)}await this.cache.putListing(e,i)}async refreshBodies(e){for(let t of e.changed)try{await this.readFile(t)}catch(n){e.errors.push({path:t,message:n instanceof Error?n.message:String(n)})}}describe(){return{displayName:`${this.parsed.org}/${this.parsed.site}${this.parsed.path?`/${this.parsed.path}`:``}`,source:this.source,profile:this.profile}}async close(){this.closed||=!0}};function _(e,t,n){let r=`----DaMount${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`,i=new TextEncoder,a=i.encode(`--${r}\r\nContent-Disposition: form-data; name="data"; filename="${e}"\r\nContent-Type: ${t}\r\n\r\n`),o=i.encode(`\r\n--${r}--\r\n`),s=new Uint8Array(a.byteLength+n.byteLength+o.byteLength);return s.set(a,0),s.set(n,a.byteLength),s.set(o,a.byteLength+n.byteLength),{contentType:`multipart/form-data; boundary=${r}`,body:s}}function v(e){return e.split(`/`).pop()||`data`}function y(e){let t=e.match(/^da:\/\/([^/]+)\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid DA source '${e}' — expected da://org/repo[/path]`);return{org:t[1],repo:t[2],path:(t[3]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}var b=class{kind=`da`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=y(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??5242880,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new l(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toSourcePath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/source/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}toListPath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/list/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r={};n&&(r[`if-none-match`]=n.etag);let i=await this.transport({method:`GET`,path:this.toSourcePath(t),headers:r});if(i.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(i.status===404)throw await this.cache.invalidateBody(t),new l(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new l(`EACCES`,`da access denied`,e);if(i.status>=400)throw new l(`EIO`,`da readFile failed: ${i.status}`,e);let a=i.headers.get(`content-length`),o=a?Number(a):void 0;if(o!==void 0&&o>this.maxBodyBytes)throw new l(`EFBIG`,`body exceeds maxBodyBytes`,e);let s=new Uint8Array(await i.arrayBuffer());if(s.byteLength>this.maxBodyBytes)throw new l(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=i.headers.get(`etag`)??``,u=c.startsWith(`W/`)?c.slice(2):c;return await this.cache.putBody(t,s,u),s}async writeFile(e,t){if(this.assertOpen(e),t.byteLength>this.maxBodyBytes)throw new l(`EFBIG`,`body exceeds maxBodyBytes`,e);let n=this.toMountRelative(e),r=await this.cache.getBody(n),i=_(v(e),s(e),t),a={"content-type":i.contentType,"content-length":String(i.body.byteLength)};r?.etag?a[`if-match`]=r.etag.startsWith(`W/`)?r.etag.slice(2):r.etag:r||(a[`if-none-match`]=`*`);let o=()=>this.transport({method:`POST`,path:this.toSourcePath(n),headers:a,body:i.body}),c,u=1;try{c=await o()}catch{u=2,c=await o()}if(c.status===412){if(u===2){let r=await this.transport({method:`HEAD`,path:this.toSourcePath(n)});if(r.status>=400)throw new l(`EIO`,`da reconcile HEAD failed: ${r.status}`,e);let i=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,i);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new l(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(c.status===401||c.status===403)throw new l(`EACCES`,`da write denied`,e);if(c.status>=400)throw new l(`EIO`,`da writeFile failed: ${c.status}`,e);let d=c.headers.get(`etag`)??``;await this.cache.putBody(n,t,d);let f=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(f)}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.transport({method:`GET`,path:this.toListPath(t)});if(r.status===404)throw new l(`ENOENT`,`no such directory`,e);if(r.status>=400)throw new l(`EIO`,`da list failed: ${r.status}`,e);let i=(await r.json()).map(e=>e.ext?{name:`${e.name}.${e.ext}`,kind:`file`,etag:e.etag,lastModified:e.lastModified}:{name:e.name,kind:`directory`,lastModified:e.lastModified});return await this.cache.putListing(t,i),i}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.size,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),i=r.pop()??``,a=r.join(`/`),o=await this.cache.getListing(a);if(o&&!this.cache.isStale(o.cachedAt)){let t=o.entries.find(e=>e.name===i);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??o.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??o.cachedAt};if(!t)throw new l(`ENOENT`,`no such file or directory`,e)}let s=await this.transport({method:`HEAD`,path:this.toSourcePath(t)});if(s.status===200){let e=Number(s.headers.get(`content-length`)??`0`),t=s.headers.get(`etag`)??``,n=s.headers.get(`last-modified`),r=n?Date.parse(n):0;if(o){let n=o.entries.map(n=>n.name===i&&n.kind===`file`?{...n,size:e,etag:t,lastModified:r}:n);await this.cache.putListing(a,n)}return{kind:`file`,size:e,mtime:r,etag:t}}if(s.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new l(`ENOENT`,`no such file or directory`,e)}throw new l(`EIO`,`da stat failed: ${s.status}`,e)}async mkdir(e){}async remove(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.transport({method:`DELETE`,path:this.toSourcePath(t)});if(n.status===404)throw new l(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new l(`EACCES`,`da delete denied`,e);if(n.status>=400)throw new l(`EIO`,`da delete failed: ${n.status}`,e);await this.cache.invalidateBody(t);let r=t.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(r)}async refresh(e){this.assertOpen(`/`);let t={added:[],removed:[],changed:[],unchanged:0,errors:[]},n=[``];for(;n.length>0;){let e=n.pop();try{await this.refreshDir(e,t,n)}catch(n){t.errors.push({path:e,message:n instanceof Error?n.message:String(n)})}}return e?.bodies&&await this.refreshBodies(t),t}async classifyFile(e,t,n){let r=await this.cache.getBody(e);r?t&&r.etag!==t?(await this.cache.invalidateBody(e),n.changed.push(e)):n.unchanged++:n.added.push(e)}async refreshDir(e,t,n){let r=await this.transport({method:`GET`,path:this.toListPath(e)});if(r.status>=400){t.errors.push({path:e,message:`list failed: ${r.status}`});return}let i=await r.json(),a=[];for(let r of i)if(r.ext){let n=e?`${e}/${r.name}.${r.ext}`:`${r.name}.${r.ext}`;a.push({name:`${r.name}.${r.ext}`,kind:`file`,etag:r.etag,lastModified:r.lastModified}),await this.classifyFile(n,r.etag,t)}else a.push({name:r.name,kind:`directory`}),n.push(e?`${e}/${r.name}`:r.name);await this.cache.putListing(e,a)}async refreshBodies(e){for(let t of e.changed)try{await this.readFile(t)}catch(n){e.errors.push({path:t,message:n instanceof Error?n.message:String(n)})}}describe(){return{displayName:`${this.parsed.org}/${this.parsed.repo}${this.parsed.path?`/${this.parsed.path}`:``}`,source:this.source,profile:this.profile}}async close(){this.closed||=!0}};function x(e){let t=e.match(/^s3:\/\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid S3 source '${e}' — expected s3://bucket[/prefix]`);return{bucket:t[1],prefix:(t[2]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}var S=class{kind=`s3`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=x(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??26214400,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new l(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toS3Key(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``);return[this.parsed.prefix,t].filter(e=>e.length>0).join(`/`)}toMountRelativeKey(e){return this.parsed.prefix?e.slice(this.parsed.prefix.length+1):e}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r={};n&&(r[`if-none-match`]=n.etag);let i=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:this.toS3Key(t),headers:r});if(i.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(i.status===404)throw await this.cache.invalidateBody(t),new l(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new l(`EACCES`,`s3 access denied`,e);if(i.status>=400)throw new l(`EIO`,`s3 readFile failed: ${i.status}`,e);let a=i.headers.get(`content-length`),o=a?Number(a):void 0;if(o!==void 0&&o>this.maxBodyBytes)throw new l(`EFBIG`,`body exceeds maxBodyBytes (${o} > ${this.maxBodyBytes})`,e);let s=new Uint8Array(await i.arrayBuffer());if(s.byteLength>this.maxBodyBytes)throw new l(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=i.headers.get(`etag`)??``;return await this.cache.putBody(t,s,c),s}async writeFile(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t.byteLength>this.maxBodyBytes)throw new l(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=await this.cache.getBody(n),i={"content-type":`application/octet-stream`,"content-length":String(t.byteLength)};r?i[`if-match`]=r.etag:i[`if-none-match`]=`*`;let a=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(n),headers:i,body:t}),o,s=1;try{o=await a()}catch{s=2,o=await a()}if(o.status===412){if(s===2){let r=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status>=400)throw new l(`EIO`,`s3 reconcile HEAD failed: ${r.status}`,e);let i=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,i);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new l(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(o.status===401||o.status===403)throw new l(`EACCES`,`s3 write denied`,e);if(o.status>=400)throw new l(`EIO`,`s3 writeFile failed: ${o.status}`,e);let c=o.headers.get(`etag`)??``;await this.cache.putBody(n,t,c);let u=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(u)}async listObjectsV2(){let e=[],t;do{let n={"list-type":`2`};this.parsed.prefix&&(n.prefix=`${this.parsed.prefix}/`),t&&(n[`continuation-token`]=t);let r=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:``,query:n});if(r.status>=400)throw new l(`EIO`,`s3 list failed: ${r.status}`,`/`);let i=await r.text(),a=this.parseListingXml(i);e.push(...a.contents),t=a.nextContinuationToken}while(t);return e}parseListingXml(e){let t=[];for(let n of e.matchAll(/<Contents>([\s\S]*?)<\/Contents>/g)){let e=n[1],r=e.match(/<Key>([^<]+)<\/Key>/)?.[1]??``,i=e.match(/<ETag>([^<]+)<\/ETag>/)?.[1]??``,a=e.match(/<Size>([^<]+)<\/Size>/)?.[1]??`0`,o=e.match(/<LastModified>([^<]+)<\/LastModified>/)?.[1]??``;t.push({key:r,etag:i,size:Number(a),lastModified:o?Date.parse(o):0})}return{contents:t,nextContinuationToken:e.match(/<IsTruncated>([^<]+)<\/IsTruncated>/)?.[1]===`true`?e.match(/<NextContinuationToken>([^<]+)<\/NextContinuationToken>/)?.[1]:void 0}}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.listObjectsV2(),i=this.groupByDir(r);for(let[e,t]of i)await this.cache.putListing(e,t);return i.get(t)??[]}groupByDir(e){let t=new Map,n=e=>(t.has(e)||t.set(e,[]),t.get(e));n(``);for(let t of e){let e=this.toMountRelativeKey(t.key).split(`/`),r=e.pop();n(e.join(`/`)).push({name:r,kind:`file`,size:t.size,etag:t.etag,lastModified:t.lastModified});let i=``;for(let t of e){let e=i;i=i?`${i}/${t}`:t;let r=n(e);r.find(e=>e.name===t&&e.kind===`directory`)||r.push({name:t,kind:`directory`}),n(i)}}return t}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.body.byteLength,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),i=r.pop()??``,a=r.join(`/`),o=await this.cache.getListing(a);if(o&&!this.cache.isStale(o.cachedAt)){let t=o.entries.find(e=>e.name===i);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??o.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??o.cachedAt};if(!t)throw new l(`ENOENT`,`no such file or directory`,e)}let s=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(t)});if(s.status===200){let e=Number(s.headers.get(`content-length`)??`0`),t=s.headers.get(`etag`)??``,n=s.headers.get(`last-modified`);return{kind:`file`,size:e,mtime:n?Date.parse(n):0,etag:t}}if(s.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new l(`ENOENT`,`no such file or directory`,e)}throw new l(`EIO`,`s3 stat failed: ${s.status}`,e)}async refresh(e){this.assertOpen(`/`);let t=await this.listObjectsV2(),n=new Set(t.map(e=>this.toMountRelativeKey(e.key))),r=new Map(t.map(e=>[this.toMountRelativeKey(e.key),e.etag])),i={added:[],removed:[],changed:[],unchanged:0,errors:[]};for(let e of n){let t=await this.cache.getBody(e),n=r.get(e);t?t.etag===n?i.unchanged++:(await this.cache.invalidateBody(e),i.changed.push(e)):i.added.push(e)}let a=this.groupByDir(t);for(let[e,t]of a)await this.cache.putListing(e,t);if(e?.bodies)for(let e of i.changed)try{await this.readFile(e)}catch(t){i.errors.push({path:e,message:t instanceof Error?t.message:String(t)})}return i}async mkdir(e){}async remove(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t?.recursive)throw new l(`EINVAL`,`recursive remove not yet supported on S3`,e);let r=await this.transport({method:`DELETE`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status===404)throw new l(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new l(`EACCES`,`s3 delete denied`,e);if(r.status>=400)throw new l(`EIO`,`s3 delete failed: ${r.status}`,e);await this.cache.invalidateBody(n);let i=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(i)}describe(){return{displayName:this.parsed.prefix?`${this.parsed.bucket}/${this.parsed.prefix}`:this.parsed.bucket,source:this.source,profile:this.profile}}async close(){this.closed||=!0}},C=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function w(){let{getAccounts:e}=await import(`./account-store-Cy3TJKnu.js`).then(e=>e.r),t=e().find(e=>e.providerId===`adobe`);if(!t?.accessToken)throw new C(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>t.accessToken}}const T=c({portName:`mount.sign-and-forward`,panelRpcOp:`mount-sign-and-forward`,timeoutMs:12e4,onUnavailable:`reject`,makeError:e=>new l(`EIO`,`mount transport failed: ${e}`),logNamespace:`mount-bridge`,toPortMessage:({type:e,envelope:t})=>({type:e,envelope:t}),toPanelRpcPayload:({type:e,envelope:t})=>({type:e,envelope:t})});function E(e,t){return T({type:e,envelope:t})}const D=t,O=i,k=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),A=new Set([101,103,204,205,304]);function j(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new l(`EACCES`,e.error):e.errorCode===`invalid_request`?new l(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||k.has(String(e.errorCode))?new l(`EIO`,e.error):new l(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=D(e.bodyBase64)}catch(e){throw new l(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let n=A.has(e.status)?null:t;return new Response(n,{status:e.status,headers:new Headers(e.headers)})}async function M(e,t){let n;try{n=await fetch(r(e),{method:`POST`,headers:a({"content-type":`application/json`}),body:JSON.stringify(t)})}catch(e){throw new l(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (SLICC backend at localhost may not be running)`)}try{return await n.json()}catch(e){throw new l(`EIO`,`mount transport: response is not a JSON envelope (status ${n.status}): ${e instanceof Error?e.message:String(e)}`)}}async function N(e,t){try{return await chrome.runtime.sendMessage({type:e,envelope:t})}catch(e){throw new l(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (extension service worker not responding)`)}}async function P(e,t,r){return o()?N(e,r):n()?E(e,r):M(t,r)}function F(e){return async t=>j(await P(`mount.s3-sign-and-forward`,`/api/s3-sign-and-forward`,{profile:e,method:t.method,bucket:t.bucket,key:t.key,query:t.query,headers:t.headers,bodyBase64:t.body?O(t.body):void 0}))}function I(e){let t=e?.getImsToken??(async()=>(await w()).getBearerToken());return async e=>{let n;try{n=await t()}catch(e){throw new l(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}return j(await P(`mount.da-sign-and-forward`,`/api/da-sign-and-forward`,{imsToken:n,method:e.method,path:e.path,origin:e.origin,query:e.query,headers:e.headers,bodyBase64:e.body?O(e.body):void 0}))}}var L=e({AEM_SOURCE_BUS_ORIGIN:()=>d,AemMountBackend:()=>g,DaMountBackend:()=>b,RemoteMountCache:()=>u,S3MountBackend:()=>S,makeSignedFetchDa:()=>I,makeSignedFetchS3:()=>F});export{b as a,S as i,I as n,d as o,F as r,g as s,L as t};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./backend-local-B6kc_FvN.js";import{a as n,i as r,n as i,r as a,s as o}from"./mount-DSlWOyRg.js";import{n as s}from"./mount-table-store-DrF_Ifaz.js";import{t as c}from"./remote-cache-JAv9sQH_.js";var l=e({formatMountRecoveryPrompt:()=>g,mdInlineCode:()=>h,recoverMounts:()=>p,shellQuote:()=>m});function u(e){return e instanceof Error?e.message:String(e)}async function d(e,n,r,i){let a=await s(n.idbHandleKey),o=typeof a?.name==`string`?a.name:``,c={kind:`local`,path:e,dirName:o};if(!a||!(`queryPermission`in a))return{entry:c,ok:!1};let l;try{l=await a.queryPermission({mode:`readwrite`})}catch(t){return i?.warn?.(`queryPermission threw on persisted handle`,{path:e,error:u(t)}),{entry:c,ok:!1}}if(l!==`granted`)return{entry:c,ok:!1};try{let s=t.fromHandle(a,{mountId:n.mountId});return await r.mount(e,s),i?.info?.(`Restored mount from previous session`,{path:e,name:o}),{entry:c,ok:!0}}catch(t){return i?.warn?.(`Failed to re-mount persisted handle`,{path:e,error:u(t)}),{entry:c,ok:!1}}}async function f(e,t,s,l){let{kind:d,source:f,profile:p,mountId:m}=t,h=d===`s3`?`S3`:d===`aem`?`AEM`:`DA`;try{let t={source:f,profile:p,cache:new c({mountId:m,ttlMs:3e4}),mountId:m},u=d===`s3`?new r({...t,signedFetch:a(p)}):d===`aem`?new o({...t,signedFetch:i()}):new n({...t,signedFetch:i()});return await s.mount(e,u),l?.info?.(`Restored ${h} mount from previous session`,{path:e,source:f}),{entry:{kind:d,path:e,source:f,profile:p,reason:``},ok:!0}}catch(t){let n=u(t);return l?.warn?.(`Failed to restore ${h} mount`,{path:e,error:n}),{entry:{kind:d,path:e,source:f,profile:p,reason:n},ok:!1}}}async function p(e,t,n){let r=[],i=[];for(let{targetPath:a,descriptor:o}of e){let e=o.kind===`local`?await d(a,o,t,n):await f(a,o,t,n);(e.ok?r:i).push(e.entry)}return{restored:r,needsRecovery:i}}function m(e){return`'${e.replace(/'/g,`'\\''`)}'`}function h(e){let t=e.replace(/\r\n|[\r\n]/g,` `),n=t.match(/`+/g),r=n?Math.max(...n.map(e=>e.length))+1:1,i="`".repeat(r);return`${i}${t.startsWith("`")||t.endsWith("`")?` ${t} `:t}${i}`}function g(e){if(!Array.isArray(e)||e.length===0)return null;let t=e.length===1?`mount point`:`mount points`,n=e.length===1?`it`:`them`,r=e.filter(e=>e.kind===`local`),i=e.filter(e=>e.kind===`s3`||e.kind===`da`||e.kind===`aem`),a=[`[Session Reload] Mount recovery required for ${e.length} ${t}.`,``];if(r.length>0){let e=r.map(({path:e,dirName:t})=>{let n=t?` (previously mounted from ${h(t)})`:``;return`- ${h(e)}${n}`}),i=r.map(({path:e})=>` mount ${m(e)}`);a.push(`The page was reloaded and the following local ${t} lost filesystem permission. The browser cannot restore access without a fresh user gesture, so ${n} cannot be used until the user re-authorizes:`,``,...e,``,`Please tell the user what happened and ask whether they want to re-mount. If yes, run the corresponding command(s) so the folder picker opens and they can re-select the same directory:`,``,...i,``)}if(i.length>0){let e=i.map(({path:e,source:t,profile:n,reason:r})=>{let i=n==="default"?``:` --profile ${m(n)}`,a=`mount --source ${m(t)}${i} ${m(e)}`;return`- ${h(e)} (${h(t)}, profile ${h(n)}) — ${r}\n Retry: ${h(a)}`});a.push(`The following remote ${t} could not be auto-restored:`,``,...e,``)}return a.push("If the user no longer needs a mount, run `mount unmount <path>` (with the path shell-quoted the same way) to clear the stale entry instead."),a.join(`
|
|
2
|
-
`)}export{l as n,m as r,g as t};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/quick-llm-hL6bZGLe.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/account-store-DysucxMw.js","assets/preload-helper-Czpn1I53.js","assets/bedrock-camp-qpZqnqLa.js","assets/diagnostics-DN_idNHx.js","assets/transform-messages-N_eMsP2M.js","assets/provider-env-CTOcDKrQ.js","assets/__vite-browser-external-5eBdwsFd.js","assets/openrouter.models-gbjkpjE_.js","assets/libesm-BI4UHVqp.js","assets/logger-DDBAeTLF.js","assets/src-CAWTvdAa.js","assets/proxied-fetch-B4g-4VbQ.js","assets/base64-DpPqYZJF.js","assets/runtime-env-Dlaokqg1.js","assets/fetch-body-D2PwksUW.js","assets/float-topology-BgioAcOd.js","assets/runtime-env-E-i2SW1s.js","assets/secret-topology-xLmXoozo.js","assets/secrets-bridge-client-cWDAnFqs.js","assets/port-bridge-client-BbVs1yhx.js","assets/image-markers-BXtVm4og.js","assets/tool-ui-DfXu6quJ.js","assets/providers-Crdj27DN.js","assets/panel-rpc-B3MSVImO.js","assets/llm-session-id-bZQs6gBN.js","assets/icons-ZLR7gmJ4.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{L as e,m as t}from"./account-store-DysucxMw.js";import{t as n}from"./preload-helper-Czpn1I53.js";import{t as r}from"./logger-DDBAeTLF.js";import{r as i}from"./feature-flags-ByMXaIc4.js";import"./provider-settings-BTpBo_o4.js";import{t as a}from"./llm-session-id-bZQs6gBN.js";import{t as o}from"./chat-session-store-pWb1-jNp.js";import{a as s,i as c,n as l,r as u,t as d}from"./session-freezer-CnFBCb6j.js";var f=r(`new-session`),p=`ui-new-session`,m=2e4,h=250;async function g(n){try{let r=await n.openVfs(),i=t()??void 0;if(!i)return;let o;try{o=e()}catch{return}let c=o.provider===`adobe`?{"X-Session-Id":a(p)}:void 0;await s({vfs:r,model:o,apiKey:i,headers:c}),n.onComplete?.()}catch(e){f.warn(`Pending session catch-up failed (boot continues)`,{error:e instanceof Error?e.message:String(e)})}}function _(e){(e.schedule??v)(()=>{g(e)})}function v(e){if(typeof globalThis.requestIdleCallback==`function`){globalThis.requestIdleCallback(e,{timeout:5e3});return}setTimeout(e,0)}function y(e){if(i(`agentic-memory`)){if(!e.agenticMemorySpawn){f.info(`Agentic memory enabled but agent bridge unavailable — using legacy enrichment`);return}return e.agenticMemorySpawn}}async function b(e,t,n,r,i,a){let o=await u({sessionStore:t,vfs:e.vfs,mode:`quick`,agenticMemorySpawn:a,cone:e.cone});if(!o)return null;if(e.captureCompleteSnapshot)try{await e.captureCompleteSnapshot(o)}catch(t){let n=t?.code??`unknown`;f.warn(`captureCompleteSnapshot failed`,{code:n}),o.completeSnapshotUnavailable=!0;try{await c(e.vfs,o.filename)}catch{}}return x(e,t,n,r,i,a,o),o}async function x(e,t,r,i,a,o,s){let c=s;try{let t=await l(e.vfs,s,{model:r,apiKey:i,headers:a,skipMemory:!0,pickIcon:e=>n(async()=>{let{pickLucideIcon:e}=await import(`./quick-llm-hL6bZGLe.js`).then(e=>e.n);return{pickLucideIcon:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27])).then(({pickLucideIcon:t})=>t(e))});t&&(c={...t,archive:s.archive},e.onBackgroundEnriched?.(t))}catch(e){f.warn(`Agentic title enrichment threw (draft stays pending)`,{filename:s.filename,error:e instanceof Error?e.message:String(e)})}let u=await d({sessionStore:t,vfs:e.vfs,mode:`full`,model:r,apiKey:i,headers:a,agenticMemorySpawn:o,cone:e.cone},c).catch(e=>(f.warn(`Agentic memory curator threw (entry stays pending)`,{filename:c.filename,error:e instanceof Error?e.message:String(e)}),null));f.info(`Agentic memory curator finished`,{filename:c.filename,memoryPending:!u||u.memoryPending===!0}),e.onBackgroundEnriched?.(u)}async function S(e,t,n,r){for(let i of n){let n=`${t}/${i.name}`;r.has(n)||i.type===`directory`&&(await S(e,n,await e.readDir(n),r),[...r].some(e=>e.startsWith(`${n}/`)))||await e.rm(n)}}async function C(e){let t=new Set((await e.listMountPoints()).map(({path:e})=>e).filter(e=>e===`/tmp`||e.startsWith(`/tmp/`)));if(t.has(`/tmp`))return;let n;try{n=await e.readDir(`/tmp`)}catch(t){if(t?.code!==`ENOENT`)throw t;await e.mkdir(`/tmp`,{recursive:!0});return}await S(e,`/tmp`,n,t),await e.mkdir(`/tmp`,{recursive:!0})}async function w(r){let i=r.enrichmentRaceMs??m,s=t()??void 0,d;try{d=e()}catch(e){f.info(`No active model — freezing without LLM enrichment`,{error:e instanceof Error?e.message:String(e)})}let h=d?.provider===`adobe`?{"X-Session-Id":a(p)}:void 0,g=new o;try{await g.init()}catch(e){return f.warn(`SessionStore init failed — cannot freeze`,{error:e instanceof Error?e.message:String(e)}),null}let _=s&&d?y(r):void 0;if(_)return await b(r,g,d,s,h,_);let v=await u({sessionStore:g,vfs:r.vfs,mode:`quick`,cone:r.cone});if(!v)return null;if(r.captureCompleteSnapshot)try{await r.captureCompleteSnapshot(v)}catch(e){let t=e?.code??`unknown`;f.warn(`captureCompleteSnapshot failed`,{code:t}),v.completeSnapshotUnavailable=!0;try{await c(r.vfs,v.filename)}catch{}}if(!s||!d)return f.info(`Frozen without enrichment (no LLM credentials) — left pending`,{filename:v.filename}),v;let x=d,S=l(r.vfs,v,{model:x,apiKey:s,headers:h,pickIcon:e=>n(async()=>{let{pickLucideIcon:e}=await import(`./quick-llm-hL6bZGLe.js`).then(e=>e.n);return{pickLucideIcon:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27])).then(({pickLucideIcon:t})=>t(e))}).catch(e=>(f.warn(`Single-click enrichment threw (entry stays pending)`,{filename:v.filename,error:e instanceof Error?e.message:String(e)}),null)),C=await T(S,i,r.onProgress);return C.kind===`llm`?C.updated?{...C.updated,archive:v.archive}:v:(S.then(e=>{f.info(`Background enrichment resolved after race window`,{filename:v.filename,enriched:e?.filename??null}),r.onBackgroundEnriched?.(e)}),v)}async function T(e,t,n){let r=Date.now(),i,a;n?.(0),n&&(i=setInterval(()=>{n(Math.min(1,(Date.now()-r)/t))},h));let o=new Promise(e=>{a=setTimeout(()=>e({kind:`timer`}),t)}),s=e.then(e=>({kind:`llm`,updated:e}));try{return await Promise.race([s,o])}finally{i&&clearInterval(i),a&&clearTimeout(a),n?.(null)}}async function E(e){return O(e,void 0)}async function D(e){return O(e,`skip`)}async function O(e,t){let n=new o;try{await n.init()}catch(e){return f.warn(`SessionStore init failed — cannot quick-freeze`,{error:e instanceof Error?e.message:String(e)}),null}let r=await u({sessionStore:n,vfs:e.vfs,mode:`quick`,cone:e.cone,...t?{memory:t}:{}});if(r&&e.captureCompleteSnapshot)try{await e.captureCompleteSnapshot(r)}catch(t){let n=t?.code??`unknown`;f.warn(`captureCompleteSnapshot failed (quick-freeze)`,{code:n}),r.completeSnapshotUnavailable=!0;try{await c(e.vfs,r.filename)}catch{}}return r}export{C as resetNewSessionTmp,D as runNewSessionArchiveOnly,w as runNewSessionFreeze,E as runNewSessionFreezeQuick,_ as schedulePendingSessionCatchup};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/provider-D2RXncrR.js","assets/account-store-DysucxMw.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/preload-helper-Czpn1I53.js","assets/bedrock-camp-qpZqnqLa.js","assets/diagnostics-DN_idNHx.js","assets/transform-messages-N_eMsP2M.js","assets/provider-env-CTOcDKrQ.js","assets/__vite-browser-external-5eBdwsFd.js","assets/openrouter.models-gbjkpjE_.js","assets/libesm-BI4UHVqp.js","assets/logger-DDBAeTLF.js","assets/src-CAWTvdAa.js","assets/proxied-fetch-B4g-4VbQ.js","assets/base64-DpPqYZJF.js","assets/runtime-env-Dlaokqg1.js","assets/fetch-body-D2PwksUW.js","assets/float-topology-BgioAcOd.js","assets/runtime-env-E-i2SW1s.js","assets/secret-topology-xLmXoozo.js","assets/secrets-bridge-client-cWDAnFqs.js","assets/port-bridge-client-BbVs1yhx.js","assets/image-markers-BXtVm4og.js","assets/tool-ui-DfXu6quJ.js","assets/providers-Crdj27DN.js","assets/panel-rpc-B3MSVImO.js","assets/pkce-hGf_TEnP.js","assets/provider-store-access-Cl5aZRx7.js","assets/global-db-CbuLl-zx.js","assets/types-idfTVsM8.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{H as e,d as t}from"./account-store-DysucxMw.js";import{t as n}from"./preload-helper-Czpn1I53.js";import{t as r}from"./logger-DDBAeTLF.js";import{t as i}from"./providers-Crdj27DN.js";import"./provider-settings-BTpBo_o4.js";import"./logger-BoSvu4mW.js";var a=r(`oauth-bootstrap`),o=6e4;async function s(){try{let{ensureAllMcpProvidersRegistered:e}=await n(async()=>{let{ensureAllMcpProvidersRegistered:e}=await import(`./provider-D2RXncrR.js`);return{ensureAllMcpProvidersRegistered:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29])),t=await e();t.length>0&&a.debug(`Pre-registered MCP providers for OAuth bootstrap`,{count:t.length})}catch(e){a.warn(`Failed to pre-register MCP providers for OAuth bootstrap`,{error:e instanceof Error?e.message:String(e)})}let r=t();a.info(`Bootstrap OAuth replicas`,{count:r.length});for(let t of r){if(!t.accessToken){a.debug(`Skipping account without token`,{providerId:t.providerId});continue}if((t.tokenExpiresAt??1/0)-Date.now()<=o){let e=i(t.providerId);if(e?.onSilentRenew)try{if(await e.onSilentRenew()){a.info(`Silently renewed OAuth token`,{providerId:t.providerId});continue}a.warn(`Silent renewal yielded no token; user must re-authenticate`,{providerId:t.providerId});continue}catch(e){a.warn(`Silent renewal failed`,{providerId:t.providerId,error:e instanceof Error?e.message:String(e)});continue}a.debug(`Skipping expired account (no silent-renew hook)`,{providerId:t.providerId});continue}try{await e({providerId:t.providerId,accessToken:t.accessToken,refreshToken:t.refreshToken,tokenExpiresAt:t.tokenExpiresAt,userName:t.userName,userAvatar:t.userAvatar}),a.debug(`Bootstrapped OAuth replica`,{providerId:t.providerId})}catch(e){a.error(`OAuth bootstrap failed`,{providerId:t.providerId,error:e instanceof Error?e.message:String(e)})}}}export{s as bootstrapOAuthReplicas};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./panel-rpc-BPwAqRch.js";import{o as t,r as n}from"./proxied-fetch-n2pCvcgW.js";import{t as r}from"./runtime-env-DadgceZk.js";import"./runtime-env-DVGQx9p3.js";import{t as i}from"./permissions-surface-registry-BqPdUk9w.js";import{t as a}from"./intercepted-oauth-BIKnTjZm.js";const o=r();var s=class extends Error{constructor(e){super(e),this.name=`OAuthLaunchError`}};async function c(){if(typeof window<`u`)return!1;let t=e();if(!t)return!1;try{return(await t.call(`oauth-route`,{},{timeoutMs:5e3})).delegate===!0}catch{return!1}}function l(){return o?y:typeof window>`u`?p:m}async function u(){let e=await d();return e?a(e):null}async function d(){try{let{getActiveCdpTransport:e}=await import(`./active-transport-BIjzxdwv.js`);return await e()}catch(e){return console.warn(`[oauth-service] could not resolve active CDP transport:`,e instanceof Error?e.message:String(e)),null}}async function f(){if(typeof window<`u`)return{origin:window.location.origin,href:window.location.href};let t=e();if(!t)throw Error(`OAuth from worker context requires the panel-RPC bridge (no page-info available)`);let n=await t.call(`page-info`,void 0);return{origin:n.origin,href:n.href}}async function p(t){let n=e();if(!n)return console.error(`[oauth-service] panel-RPC client unavailable in worker`),null;try{let e=await n.call(`oauth-popup`,{url:t},{timeoutMs:13e4});if(!e.redirectUrl&&e.error)throw new s(e.error);return e.redirectUrl}catch(e){if(e instanceof s)throw e;return console.error(`[oauth-service] oauth-popup RPC failed:`,e instanceof Error?e.message:String(e)),null}}async function m(e){if(h())return g(window.open(e,`_blank`,`width=500,height=700,popup=yes`));let t=i();if(t){let n=await _(t,e);return n===void 0?null:g(n)}return g(window.open(e,`_blank`,`width=500,height=700,popup=yes`))}function h(){return(typeof navigator<`u`?navigator.userActivation:void 0)?.isActive===!0}function g(e){return new Promise(r=>{let i=!1,a=null,o=null,s=()=>{i||(i=!0,window.removeEventListener(`message`,c),clearTimeout(l),a&&clearInterval(a),o&&clearInterval(o))},c=t=>{if(t.data?.type!==`oauth-callback`||t.origin!==window.location.origin||e&&t.source!==e)return;if(s(),t.data.error){console.error(`[oauth-service] CLI OAuth error:`,t.data.error),r(null);return}let n=t.data.redirectUrl;(typeof n==`string`||n==null)&&r(n??null)};window.addEventListener(`message`,c),a=setInterval(async()=>{if(!i)try{let e=await fetch(t(`/api/oauth-result`),{headers:n()});if(e.status===204||!e.ok)return;let a=await e.json();if(i)return;if(s(),a.error){console.error(`[oauth-service] Server relay OAuth error:`,a.error),r(null);return}r(a.redirectUrl??null)}catch(e){console.warn(`[oauth-service] Poll failed:`,e instanceof Error?e.message:String(e))}},1e3),e&&(o=setInterval(()=>{e.closed&&(clearInterval(o),o=null,setTimeout(()=>{i||(s(),r(null))},1500))},500));let l=setTimeout(()=>{s();try{e?.close()}catch{}r(null)},12e4)})}async function _(e,t){let n=await e.prompt({kinds:[`popup`],description:`Continue to sign in. A new window will open to the provider.`,grantLabel:`Continue`,requestOptions:{popup:{url:t}}});if(n.status!==`granted`)return;let r=n.grants.find(e=>e.kind===`popup`);return r&&r.kind===`popup`?r.window:null}async function v(e,t=18e4){if(typeof window>`u`||o)return;let n=window.open(e,`_blank`,`width=500,height=600,popup=yes`);if(!n){console.warn(`[oauth-service] Could not open IdP logout popup — popups may be blocked`);return}await new Promise(e=>{let r=setTimeout(()=>{clearInterval(i);try{n.close()}catch{}e()},t),i=setInterval(()=>{n.closed&&(clearTimeout(r),clearInterval(i),e())},500)})}async function y(e,t){let n=chrome.runtime;return new Promise(r=>{let i=!1,a=()=>{i||(i=!0,n.onMessage.removeListener(o),clearTimeout(s))},o=e=>{if(typeof e!=`object`||!e)return;let t=e;if(t.source===`service-worker`&&t.payload?.type===`oauth-result`){if(a(),t.payload.error){console.error(`[oauth-service] Extension OAuth error:`,t.payload.error),r(null);return}r(t.payload.redirectUrl??null)}};n.onMessage.addListener(o),n.sendMessage({source:`panel`,payload:{type:`oauth-request`,providerId:`oauth`,authorizeUrl:e,interactive:t?.interactive??!0}}).catch(e=>{console.error(`[oauth-service] Failed to send OAuth request to service worker:`,e)});let s=setTimeout(()=>{a(),r(null)},12e4)})}export{u as createInterceptingOAuthLauncherForCurrentRuntime,l as createOAuthLauncher,f as getOAuthPageOrigin,v as openIdpLogoutUrl,c as resolveOAuthDelegation};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./preload-helper-Czpn1I53.js";import{o as t,r as n}from"./proxied-fetch-B4g-4VbQ.js";import{n as r}from"./runtime-env-Dlaokqg1.js";import"./runtime-env-CgsZ7LTp.js";import{t as i}from"./panel-rpc-B3MSVImO.js";import{t as a}from"./permissions-surface-registry-CilCRwhh.js";var o=12e4;function s(e,t){return t.endsWith(`*`)?e.startsWith(t.slice(0,-1)):e===t||e.startsWith(`${t}?`)||e.startsWith(`${t}#`)}function c(e){return e.endsWith(`*`)?e:`${e}*`}function l(e,t){if(!t||t.length===0)return e;let n=e;for(let e of t)if(n.includes(e.match)){if(e.replaceUrl){n=e.replaceUrl;continue}if(e.appendParams)try{let t=new URL(n);for(let[n,r]of Object.entries(e.appendParams))t.searchParams.set(n,r);n=t.toString()}catch{}}return n}function u(e){return async t=>{let n=t.timeoutMs??o,r=t.rewrite??[],i=t.onCapture??`close`,a,u,d=!1,f=null,p=async()=>{if(u){try{await e.send(`Fetch.disable`,{},u)}catch{}try{await e.send(`Target.detachFromTarget`,{sessionId:u})}catch{}}if(a&&i===`close`)try{await e.send(`Target.closeTarget`,{targetId:a})}catch{}};return await new Promise(i=>{let o=async t=>{d||(d=!0,clearTimeout(h),e.off(`Fetch.requestPaused`,m),await p(),i(t))},m=n=>{let i=n;if(!i?.request?.url||!u||(typeof n.sessionId==`string`?n.sessionId:void 0)!==u)return;if(s(i.request.url,t.redirectUriPattern)){f=i.request.url,e.send(`Fetch.failRequest`,{requestId:i.requestId,errorReason:`Aborted`},u).catch(()=>{}),o(f);return}let a=l(i.request.url,r);if(a!==i.request.url){e.send(`Fetch.continueRequest`,{requestId:i.requestId,url:a},u).catch(e=>{console.warn(`[intercepted-oauth] continueRequest (rewrite) failed:`,e instanceof Error?e.message:String(e))});return}e.send(`Fetch.continueRequest`,{requestId:i.requestId},u).catch(()=>{})},h=setTimeout(()=>{o(null)},n);(async()=>{try{a=(await e.send(`Target.createTarget`,{url:`about:blank`})).targetId,u=(await e.send(`Target.attachToTarget`,{targetId:a,flatten:!0})).sessionId,e.on(`Fetch.requestPaused`,m),await e.send(`Fetch.enable`,{patterns:[{urlPattern:c(t.redirectUriPattern),requestStage:`Request`},...r.map(e=>({urlPattern:`*${e.match}*`,requestStage:`Request`}))]},u),await e.send(`Page.navigate`,{url:t.authorizeUrl},u)}catch(e){console.error(`[intercepted-oauth] setup failed:`,e instanceof Error?e.message:String(e)),o(null)}})()})}}var d=r(),f=class extends Error{constructor(e){super(e),this.name=`OAuthLaunchError`}};async function p(){if(typeof window<`u`)return!1;let e=i();if(!e)return!1;try{return(await e.call(`oauth-route`,{},{timeoutMs:5e3})).delegate===!0}catch{return!1}}function m(){return d?w:typeof window>`u`?v:y}async function h(){let e=await g();return e?u(e):null}async function g(){try{let{getActiveCdpTransport:t}=await e(async()=>{let{getActiveCdpTransport:e}=await import(`./active-transport-BIjzxdwv.js`);return{getActiveCdpTransport:e}},[]);return await t()}catch(e){return console.warn(`[oauth-service] could not resolve active CDP transport:`,e instanceof Error?e.message:String(e)),null}}async function _(){if(typeof window<`u`)return{origin:window.location.origin,href:window.location.href};let e=i();if(!e)throw Error(`OAuth from worker context requires the panel-RPC bridge (no page-info available)`);let t=await e.call(`page-info`,void 0);return{origin:t.origin,href:t.href}}async function v(e){let t=i();if(!t)return console.error(`[oauth-service] panel-RPC client unavailable in worker`),null;try{let n=await t.call(`oauth-popup`,{url:e},{timeoutMs:13e4});if(!n.redirectUrl&&n.error)throw new f(n.error);return n.redirectUrl}catch(e){if(e instanceof f)throw e;return console.error(`[oauth-service] oauth-popup RPC failed:`,e instanceof Error?e.message:String(e)),null}}async function y(e){if(b())return x(window.open(e,`_blank`,`width=500,height=700,popup=yes`));let t=a();if(t){let n=await S(t,e);return n===void 0?null:x(n)}return x(window.open(e,`_blank`,`width=500,height=700,popup=yes`))}function b(){return(typeof navigator<`u`?navigator.userActivation:void 0)?.isActive===!0}function x(e){return new Promise(r=>{let i=!1,a=null,o=null,s=()=>{i||(i=!0,window.removeEventListener(`message`,c),clearTimeout(l),a&&clearInterval(a),o&&clearInterval(o))},c=t=>{if(t.data?.type!==`oauth-callback`||t.origin!==window.location.origin||e&&t.source!==e)return;if(s(),t.data.error){console.error(`[oauth-service] CLI OAuth error:`,t.data.error),r(null);return}let n=t.data.redirectUrl;(typeof n==`string`||n==null)&&r(n??null)};window.addEventListener(`message`,c),a=setInterval(async()=>{if(!i)try{let e=await fetch(t(`/api/oauth-result`),{headers:n()});if(e.status===204||!e.ok)return;let a=await e.json();if(i)return;if(s(),a.error){console.error(`[oauth-service] Server relay OAuth error:`,a.error),r(null);return}r(a.redirectUrl??null)}catch(e){console.warn(`[oauth-service] Poll failed:`,e instanceof Error?e.message:String(e))}},1e3),e&&(o=setInterval(()=>{e.closed&&(clearInterval(o),o=null,setTimeout(()=>{i||(s(),r(null))},1500))},500));let l=setTimeout(()=>{s();try{e?.close()}catch{}r(null)},12e4)})}async function S(e,t){let n=await e.prompt({kinds:[`popup`],description:`Continue to sign in. A new window will open to the provider.`,grantLabel:`Continue`,requestOptions:{popup:{url:t}}});if(n.status!==`granted`)return;let r=n.grants.find(e=>e.kind===`popup`);return r&&r.kind===`popup`?r.window:null}async function C(e,t=18e4){if(typeof window>`u`||d)return;let n=window.open(e,`_blank`,`width=500,height=600,popup=yes`);if(!n){console.warn(`[oauth-service] Could not open IdP logout popup — popups may be blocked`);return}await new Promise(e=>{let r=setTimeout(()=>{clearInterval(i);try{n.close()}catch{}e()},t),i=setInterval(()=>{n.closed&&(clearTimeout(r),clearInterval(i),e())},500)})}async function w(e,t){let n=chrome.runtime;return new Promise(r=>{let i=!1,a=()=>{i||(i=!0,n.onMessage.removeListener(o),clearTimeout(s))},o=e=>{if(typeof e!=`object`||!e)return;let t=e;if(t.source===`service-worker`&&t.payload?.type===`oauth-result`){if(a(),t.payload.error){console.error(`[oauth-service] Extension OAuth error:`,t.payload.error),r(null);return}r(t.payload.redirectUrl??null)}};n.onMessage.addListener(o),n.sendMessage({source:`panel`,payload:{type:`oauth-request`,providerId:`oauth`,authorizeUrl:e,interactive:t?.interactive??!0}}).catch(e=>{console.error(`[oauth-service] Failed to send OAuth request to service worker:`,e)});let s=setTimeout(()=>{a(),r(null)},12e4)})}export{h as createInterceptingOAuthLauncherForCurrentRuntime,m as createOAuthLauncher,_ as getOAuthPageOrigin,C as openIdpLogoutUrl,p as resolveOAuthDelegation};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{H as e,d as t}from"./account-store-Cy3TJKnu.js";import{a as n}from"./diagnostics-DN_idNHx.js";import{p as r}from"./bedrock-camp-B0KF_4RS.js";import{n as i,o as a}from"./legacy-api-aliases-nSD9C16V.js";import"./provider-settings-B5B0NtAl.js";import{n as o,r as s,t as c}from"./pkce-hGf_TEnP.js";const l=`openai-codex`,u=`app_EMoamEEZ73f0CkXaXp7hrann`,d=`https://auth.openai.com/oauth/token`,f=`http://localhost:1455/auth/callback`,p=`https://chatgpt.com/backend-api`,m=`openai-codex-responses`,h=`${l}-openai`,g={xhigh:`xhigh`,minimal:`low`},_=[{id:`gpt-5.5`,name:`GPT-5.5`,input:[`text`,`image`]},{id:`gpt-5.4`,name:`GPT-5.4`,input:[`text`,`image`]},{id:`gpt-5.4-mini`,name:`GPT-5.4 mini`,input:[`text`,`image`]},{id:`gpt-5.3-codex`,name:`GPT-5.3 Codex`,input:[`text`,`image`]},{id:`gpt-5.3-codex-spark`,name:`GPT-5.3 Codex Spark`,input:[`text`]},{id:`gpt-5.2`,name:`GPT-5.2`,input:[`text`,`image`]}].map(e=>({...e,api:`openai`,reasoning:!0,context_window:272e3,max_tokens:128e3,thinkingLevelMap:g}));async function v(e,t){let n=new URLSearchParams({grant_type:`authorization_code`,client_id:u,code:e,code_verifier:t,redirect_uri:f}),r=await fetch(d,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:n});if(!r.ok)throw Error(`OpenAI Codex token exchange failed: ${r.status} ${await r.text()}`);let i=await r.json();if(!i.access_token)throw Error(`OpenAI Codex token exchange did not return access_token.`);return i}async function y(e){try{let t=new URLSearchParams({grant_type:`refresh_token`,refresh_token:e,client_id:u}),n=await fetch(d,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:t});return n.ok?await n.json():(console.error(`[openai-codex] refresh failed:`,n.status,await n.text()),null)}catch(e){return console.error(`[openai-codex] refresh error:`,e instanceof Error?e.message:String(e)),null}}function b(e){try{let t=e.split(`.`);if(t.length!==3)return;let n=t[1].replace(/-/g,`+`).replace(/_/g,`/`);return n.length%4&&(n+=`=`.repeat(4-n.length%4)),JSON.parse(atob(n))}catch{return}}function x(e){let t=b(e)?.[`https://api.openai.com/profile`];return typeof t?.email==`string`?t.email:void 0}function S(e){let t=b(e)?.[`https://api.openai.com/auth`],n=x(e),r=typeof t?.chatgpt_plan_type==`string`?t.chatgpt_plan_type:void 0,i=r?r.charAt(0).toUpperCase()+r.slice(1):void 0;if(n&&i)return`${n} (${i})`;if(n)return n;if(i)return`ChatGPT ${i}`}async function C(e){let t=x(e);if(t)try{let e=t.trim().toLowerCase(),n=new Uint8Array(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e)));return`https://www.gravatar.com/avatar/${Array.from(n).map(e=>e.toString(16).padStart(2,`0`)).join(``)}?s=128&d=404`}catch{return}}function w(){return t().find(e=>e.providerId===l)}async function T(){let t=w();if(!t?.accessToken)throw Error("Not signed in to OpenAI Codex — run `oauth-token openai-codex` or /login");let n=t.tokenExpiresAt??0;if(n&&Date.now()+6e4<n)return t.accessToken;if(t.refreshToken){let n=await y(t.refreshToken);if(n?.access_token)return await e({providerId:l,accessToken:n.access_token,refreshToken:n.refresh_token??t.refreshToken,tokenExpiresAt:Date.now()+(n.expires_in??3600)*1e3,baseUrl:p,userName:S(n.access_token),userAvatar:await C(n.access_token),scopes:n.scope??t.scopes}),n.access_token}return t.accessToken}function E(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:h,provider:l,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()}}}const D=(e,t,r={})=>{let a=n();return(async()=>{try{let n=await T(),o={...e,baseUrl:p,api:m},s=i(o,t,{...r,apiKey:n,transport:`sse`});for await(let e of s)a.push(e);a.end()}catch(t){console.error(`[openai-codex] Stream error:`,t instanceof Error?t.message:String(t)),a.push(E(e,t)),a.end()}})(),a},O=(e,t,r)=>{let i=n();return(async()=>{try{let n=await T(),o={...e,baseUrl:p,api:m},s=a(o,t,{...r,apiKey:n,transport:`sse`});for await(let e of s)i.push(e);i.end()}catch(t){console.error(`[openai-codex] Stream error:`,t instanceof Error?t.message:String(t)),i.push(E(e,t)),i.end()}})(),i},k={id:l,name:`OpenAI Codex (ChatGPT Subscription)`,description:`GPT-5 Codex via your ChatGPT Plus/Pro/Business subscription — OAuth login, no API key needed. Default model is GPT-5.5.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:`gpt-5.5`,oauthTokenDomains:[`chatgpt.com`,`*.chatgpt.com`,`auth.openai.com`,`api.openai.com`],getModelIds:()=>_,onOAuthLoginIntercepted:async(t,n,r)=>{let i=o(),a=await c(i),d=s(),m=new URL(`https://auth.openai.com/oauth/authorize`);m.searchParams.set(`response_type`,`code`),m.searchParams.set(`client_id`,u),m.searchParams.set(`redirect_uri`,f),m.searchParams.set(`scope`,r?.scopes??`openid profile email offline_access`),m.searchParams.set(`code_challenge`,a),m.searchParams.set(`code_challenge_method`,`S256`),m.searchParams.set(`state`,d),m.searchParams.set(`id_token_add_organizations`,`true`),m.searchParams.set(`codex_cli_simplified_flow`,`true`),m.searchParams.set(`originator`,`pi`);let h=await t({authorizeUrl:m.toString(),redirectUriPattern:`http://localhost:1455/auth/callback*`,onCapture:`close`});if(!h)throw Error(`OpenAI Codex OAuth login was cancelled or timed out`);let g=new URL(h),_=g.searchParams.get(`code`),y=g.searchParams.get(`state`);if(!_)throw Error(`OpenAI Codex OAuth redirect did not include a code`);if(y!==d)throw Error(`OpenAI Codex OAuth state mismatch — possible CSRF, aborting`);let b=await v(_,i);await e({providerId:l,accessToken:b.access_token,refreshToken:b.refresh_token,tokenExpiresAt:Date.now()+(b.expires_in??3600)*1e3,baseUrl:p,userName:S(b.access_token),userAvatar:await C(b.access_token),scopes:b.scope}),n()},onOAuthLogout:async()=>{await e({providerId:l,accessToken:``})},onSilentRenew:async()=>{let t=w();if(!t?.refreshToken)return null;let n=await y(t.refreshToken);return n?.access_token?(await e({providerId:l,accessToken:n.access_token,refreshToken:n.refresh_token??t.refreshToken,tokenExpiresAt:Date.now()+(n.expires_in??3600)*1e3,baseUrl:p,userName:S(n.access_token),userAvatar:await C(n.access_token),scopes:n.scope??t.scopes}),n.access_token):null}};function A(){r({api:h,stream:D,streamSimple:O})}export{k as config,A as register};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{H as e,d as t}from"./account-store-DysucxMw.js";import{a as n}from"./diagnostics-DN_idNHx.js";import{p as r}from"./bedrock-camp-qpZqnqLa.js";import{n as i,o as a}from"./legacy-api-aliases-CsTVszvY.js";import"./provider-settings-BTpBo_o4.js";import{n as o,r as s,t as c}from"./pkce-hGf_TEnP.js";var l=`openai-codex`,u=`app_EMoamEEZ73f0CkXaXp7hrann`,d=`https://auth.openai.com/oauth/authorize`,f=`https://auth.openai.com/oauth/token`,p=`openid profile email offline_access`,m=`http://localhost:1455/auth/callback`,h=`http://localhost:1455/auth/callback*`,g=`https://chatgpt.com/backend-api`,_=`openai-codex-responses`,v=`${l}-openai`,y={xhigh:`xhigh`,minimal:`low`},b=[{id:`gpt-5.5`,name:`GPT-5.5`,input:[`text`,`image`]},{id:`gpt-5.4`,name:`GPT-5.4`,input:[`text`,`image`]},{id:`gpt-5.4-mini`,name:`GPT-5.4 mini`,input:[`text`,`image`]},{id:`gpt-5.3-codex`,name:`GPT-5.3 Codex`,input:[`text`,`image`]},{id:`gpt-5.3-codex-spark`,name:`GPT-5.3 Codex Spark`,input:[`text`]},{id:`gpt-5.2`,name:`GPT-5.2`,input:[`text`,`image`]}].map(e=>({...e,api:`openai`,reasoning:!0,context_window:272e3,max_tokens:128e3,thinkingLevelMap:y}));async function x(e,t){let n=new URLSearchParams({grant_type:`authorization_code`,client_id:u,code:e,code_verifier:t,redirect_uri:m}),r=await fetch(f,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:n});if(!r.ok)throw Error(`OpenAI Codex token exchange failed: ${r.status} ${await r.text()}`);let i=await r.json();if(!i.access_token)throw Error(`OpenAI Codex token exchange did not return access_token.`);return i}async function S(e){try{let t=new URLSearchParams({grant_type:`refresh_token`,refresh_token:e,client_id:u}),n=await fetch(f,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:t});return n.ok?await n.json():(console.error(`[openai-codex] refresh failed:`,n.status,await n.text()),null)}catch(e){return console.error(`[openai-codex] refresh error:`,e instanceof Error?e.message:String(e)),null}}function C(e){try{let t=e.split(`.`);if(t.length!==3)return;let n=t[1].replace(/-/g,`+`).replace(/_/g,`/`);return n.length%4&&(n+=`=`.repeat(4-n.length%4)),JSON.parse(atob(n))}catch{return}}function w(e){let t=C(e)?.[`https://api.openai.com/profile`];return typeof t?.email==`string`?t.email:void 0}function T(e){let t=C(e)?.[`https://api.openai.com/auth`],n=w(e),r=typeof t?.chatgpt_plan_type==`string`?t.chatgpt_plan_type:void 0,i=r?r.charAt(0).toUpperCase()+r.slice(1):void 0;if(n&&i)return`${n} (${i})`;if(n)return n;if(i)return`ChatGPT ${i}`}async function E(e){let t=w(e);if(t)try{let e=t.trim().toLowerCase(),n=new Uint8Array(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e)));return`https://www.gravatar.com/avatar/${Array.from(n).map(e=>e.toString(16).padStart(2,`0`)).join(``)}?s=128&d=404`}catch{return}}function D(){return t().find(e=>e.providerId===l)}async function O(){let t=D();if(!t?.accessToken)throw Error("Not signed in to OpenAI Codex — run `oauth-token openai-codex` or /login");let n=t.tokenExpiresAt??0;if(n&&Date.now()+6e4<n)return t.accessToken;if(t.refreshToken){let n=await S(t.refreshToken);if(n?.access_token)return await e({providerId:l,accessToken:n.access_token,refreshToken:n.refresh_token??t.refreshToken,tokenExpiresAt:Date.now()+(n.expires_in??3600)*1e3,baseUrl:g,userName:T(n.access_token),userAvatar:await E(n.access_token),scopes:n.scope??t.scopes}),n.access_token}return t.accessToken}function k(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:v,provider:l,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()}}}var A=(e,t,r={})=>{let a=n();return(async()=>{try{let n=await O(),o={...e,baseUrl:g,api:_},s=i(o,t,{...r,apiKey:n,transport:`sse`});for await(let e of s)a.push(e);a.end()}catch(t){console.error(`[openai-codex] Stream error:`,t instanceof Error?t.message:String(t)),a.push(k(e,t)),a.end()}})(),a},j=(e,t,r)=>{let i=n();return(async()=>{try{let n=await O(),o={...e,baseUrl:g,api:_},s=a(o,t,{...r,apiKey:n,transport:`sse`});for await(let e of s)i.push(e);i.end()}catch(t){console.error(`[openai-codex] Stream error:`,t instanceof Error?t.message:String(t)),i.push(k(e,t)),i.end()}})(),i},M={id:l,name:`OpenAI Codex (ChatGPT Subscription)`,description:`GPT-5 Codex via your ChatGPT Plus/Pro/Business subscription — OAuth login, no API key needed. Default model is GPT-5.5.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:`gpt-5.5`,oauthTokenDomains:[`chatgpt.com`,`*.chatgpt.com`,`auth.openai.com`,`api.openai.com`],getModelIds:()=>b,onOAuthLoginIntercepted:async(t,n,r)=>{let i=o(),a=await c(i),f=s(),_=new URL(d);_.searchParams.set(`response_type`,`code`),_.searchParams.set(`client_id`,u),_.searchParams.set(`redirect_uri`,m),_.searchParams.set(`scope`,r?.scopes??p),_.searchParams.set(`code_challenge`,a),_.searchParams.set(`code_challenge_method`,`S256`),_.searchParams.set(`state`,f),_.searchParams.set(`id_token_add_organizations`,`true`),_.searchParams.set(`codex_cli_simplified_flow`,`true`),_.searchParams.set(`originator`,`pi`);let v=await t({authorizeUrl:_.toString(),redirectUriPattern:h,onCapture:`close`});if(!v)throw Error(`OpenAI Codex OAuth login was cancelled or timed out`);let y=new URL(v),b=y.searchParams.get(`code`),S=y.searchParams.get(`state`);if(!b)throw Error(`OpenAI Codex OAuth redirect did not include a code`);if(S!==f)throw Error(`OpenAI Codex OAuth state mismatch — possible CSRF, aborting`);let C=await x(b,i);await e({providerId:l,accessToken:C.access_token,refreshToken:C.refresh_token,tokenExpiresAt:Date.now()+(C.expires_in??3600)*1e3,baseUrl:g,userName:T(C.access_token),userAvatar:await E(C.access_token),scopes:C.scope}),n()},onOAuthLogout:async()=>{await e({providerId:l,accessToken:``})},onSilentRenew:async()=>{let t=D();if(!t?.refreshToken)return null;let n=await S(t.refreshToken);return n?.access_token?(await e({providerId:l,accessToken:n.access_token,refreshToken:n.refresh_token??t.refreshToken,tokenExpiresAt:Date.now()+(n.expires_in??3600)*1e3,baseUrl:g,userName:T(n.access_token),userAvatar:await E(n.access_token),scopes:n.scope??t.scopes}),n.access_token):null}};function N(){r({api:v,stream:A,streamSimple:j})}export{M as config,N as register};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import{i as e,n as t,r as n,t as r}from"./diagnostics-DN_idNHx.js";import{c as i,i as a}from"./transform-messages-DEFauvrq.js";import{t as o}from"./provider-env-CILujRmO.js";import{t as s}from"./deferred-tools-DNuoafg8.js";import{t as c}from"./headers-CbDaTl3c.js";import{t as l}from"./pi-user-agent-BlGZrXbX.js";import{n as u}from"./constrained-sampling-BNmnoM-i.js";import{n as d,t as f}from"./error-body-pkrba6pf.js";import{t as p}from"./openai-prompt-cache-DXo9f3w5.js";import{n as m,r as h,t as g}from"./openai-responses-shared-DxcsuzHF.js";const _=new Set;function v(e){return _.add(e),()=>{_.delete(e)}}let y=-1/0,b=0;function x(e){if(globalThis.crypto?.getRandomValues){globalThis.crypto.getRandomValues(e);return}for(let t=0;t<e.length;t++)e[t]=Math.floor(Math.random()*256)}function S(){let e=new Uint8Array(16);x(e);let t=Date.now();t>y?(b=e[6]*16777216+e[7]*65536+e[8]*256+e[9],y=t):(b=b+1>>>0,b===0&&y++);let n=new Uint8Array(16);n[0]=y/1099511627776&255,n[1]=y/4294967296&255,n[2]=y/16777216&255,n[3]=y/65536&255,n[4]=y/256&255,n[5]=y&255,n[6]=112|b>>>28&15,n[7]=b>>>20&255,n[8]=128|b>>>14&63,n[9]=b>>>6&255,n[10]=(b&63)<<2|e[10]&3,n[11]=e[11],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15];let r=Array.from(n,e=>e.toString(16).padStart(2,`0`));return`${r.slice(0,4).join(``)}-${r.slice(4,6).join(``)}-${r.slice(6,8).join(``)}-${r.slice(8,10).join(``)}-${r.slice(10,16).join(``)}`}function C(e){let t=e.filter(e=>e!==void 0);if(t.length===0)return{cleanup:()=>{}};if(t.length===1)return{signal:t[0],cleanup:()=>{}};let n=new AbortController,r=[],i=e=>{n.signal.aborted||n.abort(e.reason)};for(let e of t){if(e.aborted){i(e);break}let t=()=>i(e);e.addEventListener(`abort`,t,{once:!0}),r.push({signal:e,listener:t})}return{signal:n.signal,cleanup:()=>{for(let{signal:e,listener:t}of r)e.removeEventListener(`abort`,t)}}}const w={ftp:21,gopher:70,http:80,https:443,ws:80,wss:443};function T(e,t){let n=e.toLowerCase(),r=e.toUpperCase();return t?.[n]||t?.[r]||o(n)||o(r)||``}function E(e){if(e instanceof URL)return e;try{return new URL(e)}catch{return}}function D(e,t,n){let r=T(`no_proxy`,n).toLowerCase();return!r||r!==`*`&&r.split(/[,\s]/).every(n=>{if(!n)return!0;let r=n.match(/^(.+):(\d+)$/),i=r?r[1]:n,a=r?Number.parseInt(r[2],10):0;return a&&a!==t?!0:/^[.*]/.test(i)?(i.startsWith(`*`)&&(i=i.slice(1)),!e.endsWith(i)):e!==i})}function O(e,t){let n=E(e);if(!n?.protocol||!n.host)return``;let r=n.protocol.split(`:`,1)[0];if(!D(n.host.replace(/:\d*$/,``),Number.parseInt(n.port,10)||w[r]||0,t))return``;let i=T(`${r}_proxy`,t)||T(`all_proxy`,t);return i&&!i.includes(`://`)&&(i=`${r}://${i}`),i}function k(e,t){let n=O(e,t);if(!n)return;let r;try{r=new URL(n)}catch(e){throw Error(`Invalid proxy URL ${JSON.stringify(n)}: ${e instanceof Error?e.message:String(e)}`)}if(r.protocol!==`http:`&&r.protocol!==`https:`)throw Error(`Unsupported proxy protocol. SOCKS and PAC proxy URLs are not supported; use an HTTP or HTTPS proxy URL. Got ${r.protocol}`);return r}const A=1e3,j=new Set([`openai`,`openai-codex`,`opencode`]),M=new Set([`completed`,`incomplete`,`failed`,`cancelled`,`queued`,`in_progress`]);function N(e){if(e.stopReason===`pending`)throw Error(`Codex stream ended without a stop reason`);if(e.stopReason===`error`||e.stopReason===`aborted`)throw Error(e.errorMessage||`An unknown error occurred`)}function P(e){return/GoUsageLimitError|FreeUsageLimitError|Monthly usage limit reached|available balance|insufficient_quota|out of budget|quota exceeded|billing/i.test(e)}function ee(e,t){return e===429&&P(t)?!1:e===429||e===500||e===502||e===503||e===504||/rate.?limit|overloaded|service.?unavailable|upstream.?connect|connection.?refused/i.test(t)}function te(e){let t=e.get(`retry-after-ms`);if(t!==null){let e=Number(t);if(Number.isFinite(e))return Math.max(0,e)}let n=e.get(`retry-after`);if(!n)return;let r=Number(n);if(Number.isFinite(r))return Math.max(0,r*1e3);let i=Date.parse(n);if(!Number.isNaN(i))return Math.max(0,i-Date.now())}var F=class extends Error{};function ne(e,t){let n=t?.maxRetryDelayMs??6e4;if(n>0&&e>n)throw new F(`Server requested ${Math.ceil(e/1e3)}s retry delay (max: ${Math.ceil(n/1e3)}s)`);return e}function re(e,t){return new Promise((n,r)=>{if(t?.aborted){r(Error(`Request was aborted`));return}let i=setTimeout(n,e);t?.addEventListener(`abort`,()=>{clearTimeout(i),r(Error(`Request was aborted`))})})}function ie(e){if(e!==void 0){if(!Number.isFinite(e)||e<0)throw Error(`Invalid timeoutMs: ${String(e)}`);return Math.floor(e)}}function ae(){return typeof process>`u`||!(process.versions?.node||process.versions?.bun)?null:process.getBuiltinModule?.(`node:zlib`)??null}function oe(e){let t=ae();if(!t||typeof t.zstdCompressSync!=`function`)return null;try{let n=t.zstdCompressSync(e,{params:{[t.constants.ZSTD_c_compressionLevel]:3}});return new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}catch{return null}}const I=(n,i,a)=>{let o=new e;return(async()=>{let e={role:`assistant`,content:[],api:`openai-codex-responses`,provider:n.provider,model:n.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`pending`,timestamp:Date.now()};try{let s=a?.apiKey;if(!s)throw Error(`No API key for provider: ${n.provider}`);let l=ze(s),d=u(i.tools,n.compat?.supportsOpenAIGrammarTools??!1),f=a?.cacheRetention===`none`?void 0:a?.sessionId,m=p(f),h=ce(n,i,a,m,d),g=await a?.onPayload?.(h,n);g!==void 0&&(h=g);let _=m||S(),v=Ve(n.headers,a?.headers,l,s,m),y=He(n.headers,a?.headers,l,s,_),b=JSON.stringify(h),x=ie(a?.timeoutMs),w=ie(a?.websocketConnectTimeoutMs),T=a?.transport||`auto`,E=!1,D=T!==`sse`&&J(f);if(D&&Y(f),T!==`sse`&&!D){let i=!1,s=!1,c=!1;for(;;){i=!1;try{if(await Le(ue(n.baseUrl),h,y,e,o,n,()=>{i=!0,E||(E=!0,o.push({type:`start`,partial:e}))},x,w,f,l,d,a),a?.signal?.aborted)throw Error(`Request was aborted`);N(e),o.push({type:`done`,reason:e.stopReason,message:e}),o.end();return}catch(n){let o=a?.signal?.aborted,l=!i&&pe(n),u=me(n);if(!o&&u&&!c){c=!0;continue}if(!o&&l&&!s){s=!0;continue}if(o||fe(n)&&!l||(r(e,t(`provider_transport_failure`,n,{configuredTransport:T,fallbackTransport:i?void 0:`sse`,eventsEmitted:i,phase:i?`after_message_stream_start`:`before_message_stream_start`,requestBytes:new TextEncoder().encode(b).byteLength})),be(f,n),i))throw n;Y(f);break}}}let O=oe(b);O&&v.set(`content-encoding`,`zstd`);let k=O??b,j,M,P=a?.maxRetries??0;for(let e=0;e<=P;e++){if(a?.signal?.aborted)throw Error(`Request was aborted`);try{let t=x!==void 0&&x>0?AbortSignal.timeout(x):void 0,r=C([a?.signal,t]);try{j=await(a?.fetch??globalThis.fetch)(z(n.baseUrl),{method:`POST`,headers:v,body:k,signal:r.signal})}catch(e){throw t?.aborted&&!a?.signal?.aborted?Error(`Codex SSE response headers timed out after ${x}ms`):e}finally{r.cleanup()}if(await a?.onResponse?.({status:j.status,headers:c(j.headers)},n),j.ok)break;let i=await j.text();if(e<P&&ee(j.status,i)){let t=te(j.headers);await re(t===void 0?A*2**e:ne(t,a),a?.signal);continue}let o=await Re(new Response(i,{status:j.status,statusText:j.statusText}));throw Error(o.friendlyMessage||o.message)}catch(t){if(t instanceof Error&&(t.name===`AbortError`||t.message===`Request was aborted`))throw Error(`Request was aborted`);if(M=t instanceof Error?t:Error(String(t)),e<P&&!(M instanceof F)&&!M.message.includes(`usage limit`)){await re(A*2**e,a?.signal);continue}throw M}}if(!j?.ok)throw M??Error(`Failed after retries`);if(!j.body)throw Error(`No response body`);if(E||(E=!0,o.push({type:`start`,partial:e})),await de(j,e,o,n,d,a),a?.signal?.aborted)throw Error(`Request was aborted`);N(e),o.push({type:`done`,reason:e.stopReason,message:e}),o.end()}catch(t){for(let t of e.content)delete t.partialJson,delete t.customInput;e.stopReason=a?.signal?.aborted?`aborted`:`error`,e.errorMessage=f(d(t)),o.push({type:`error`,reason:e.stopReason,error:e}),o.end()}})(),o},se=(e,t,n)=>{let r=n?.apiKey;if(!r)throw Error(`No API key for provider: ${e.provider}`);let o=a(e,t,n,r),s=n?.reasoning?i(e,n.reasoning):void 0,c=s===`off`?void 0:s;return I(e,t,{...o,reasoningEffort:c})};function ce(e,t,n,r,i=u(t.tools,e.compat?.supportsOpenAIGrammarTools??!1)){let a=e.compat?.supportsStrictMode??!0,o=e.compat?.supportsOpenAIGrammarTools??!1,c=e.compat?.supportsAdditionalTools?`additional-tools`:e.compat?.supportsToolSearch?`tool-search`:void 0,l=s(t,c!==void 0),d=g(e,t,j,{includeSystemPrompt:!1,grammarToolInputProperties:i,deferredTools:l.deferred,deferredToolsMode:c,toolOptions:{strict:null,supportsStrictMode:a,supportsOpenAIGrammarTools:o}}),f={model:e.id,store:!1,stream:!0,instructions:t.systemPrompt||`You are a helpful assistant.`,input:d,text:{verbosity:n?.textVerbosity||`low`},include:[`reasoning.encrypted_content`],prompt_cache_key:r,tool_choice:n?.toolChoice??`auto`,parallel_tool_calls:!0};if(n?.temperature!==void 0&&(f.temperature=n.temperature),n?.serviceTier!==void 0&&(f.service_tier=n.serviceTier),l.immediate.length>0&&(f.tools=m(l.immediate,{strict:null,supportsStrictMode:a,supportsOpenAIGrammarTools:o})),n?.reasoningEffort!==void 0){let t=n.reasoningEffort===`none`?e.thinkingLevelMap?.off??`none`:e.thinkingLevelMap?.[n.reasoningEffort]??n.reasoningEffort;t!==null&&(f.reasoning={effort:t,summary:n.reasoningSummary??`auto`})}return f}function le(e,t){switch(t){case`flex`:return .5;case`priority`:return e.id===`gpt-5.5`?2.5:2;default:return 1}}function L(e,t,n){let r=le(n,t);r!==1&&(e.cost.input*=r,e.cost.output*=r,e.cost.cacheRead*=r,e.cost.cacheWrite*=r,e.cost.total=e.cost.input+e.cost.output+e.cost.cacheRead+e.cost.cacheWrite)}function R(e,t){return e==="default"&&(t===`flex`||t===`priority`)?t:e??t}function z(e){let t=(e&&e.trim().length>0?e:`https://chatgpt.com/backend-api`).replace(/\/+$/,``);return t.endsWith(`/codex/responses`)?t:t.endsWith(`/codex`)?`${t}/responses`:`${t}/codex/responses`}function ue(e){let t=new URL(z(e));return t.protocol===`https:`&&(t.protocol=`wss:`),t.protocol===`http:`&&(t.protocol=`ws:`),t.toString()}async function de(e,t,n,r,i,a){await h(H(_e(e,a?.signal),t),t,n,r,{serviceTier:a?.serviceTier,grammarToolInputProperties:i,resolveServiceTier:R,applyServiceTierPricing:(e,t)=>L(e,t,r)})}var B=class extends Error{code;payload;constructor(e,t){super(e),this.name=`CodexApiError`,this.code=t?.code,this.payload=t?.payload,this.cause=t?.cause}},V=class extends Error{payload;constructor(e,t){super(e),this.name=`CodexProtocolError`,this.payload=t?.payload,this.cause=t?.cause}};function fe(e){return e instanceof B||e instanceof V}function pe(e){return e instanceof B&&e.code===`websocket_connection_limit_reached`}function me(e){return e instanceof B&&e.code===`previous_response_not_found`}function he(e){let t=e.error&&typeof e.error==`object`?e.error:void 0;return{code:typeof e.code==`string`?e.code:typeof t?.code==`string`?t.code:void 0,message:typeof e.message==`string`?e.message:typeof t?.message==`string`?t.message:void 0}}async function*H(e,t){for await(let n of e){let e=typeof n.type==`string`?n.type:void 0;if(e){if(e===`error`){let{code:e,message:t}=he(n);throw new B(`Codex error: ${t||e||JSON.stringify(n)}`,{code:e,payload:n})}if(e===`response.failed`){let e=n.response,t=e?.error?.code,r=e?.error?.message;throw new B(r||`Codex response failed`,{code:t,payload:n})}if(e===`response.done`||e===`response.completed`||e===`response.incomplete`){let e=n.response;typeof e?.end_turn==`boolean`&&(t.endTurn=e.end_turn);let r=e&&{...e,status:ge(e.status)};yield{...n,type:`response.completed`,response:r};return}yield n}}}function ge(e){if(typeof e==`string`)return M.has(e)?e:void 0}async function*_e(e,t){if(!e.body)return;let r=e.body.getReader(),i=new TextDecoder,a=``,o=()=>{r.cancel().catch(()=>{})};t?.addEventListener(`abort`,o,{once:!0});try{for(;;){if(t?.aborted)throw Error(`Request was aborted`);let{done:e,value:o}=await r.read();if(t?.aborted)throw Error(`Request was aborted`);if(e)break;a+=i.decode(o,{stream:!0});let s=a.indexOf(`
|
|
2
|
-
|
|
3
|
-
`);for(;s!==-1;){let e=a.slice(0,s);a=a.slice(s+2);let t=e.split(`
|
|
4
|
-
`).filter(e=>e.startsWith(`data:`)).map(e=>e.slice(5).trim());if(t.length>0){let e=t.join(`
|
|
5
|
-
`).trim();if(e&&e!==`[DONE]`)try{yield JSON.parse(e)}catch(t){throw new V(`Invalid Codex SSE JSON: ${n(t)}`,{cause:t,payload:e})}}s=a.indexOf(`
|
|
6
|
-
|
|
7
|
-
`)}}}finally{t?.removeEventListener(`abort`,o);try{await r.cancel()}catch{}try{r.releaseLock()}catch{}}}const U=new Map,W=new Map,G=new Set;function K(e){let t=W.get(e);return t||(t={requests:0,connectionsCreated:0,connectionsReused:0,cachedContextRequests:0,storeTrueRequests:0,fullContextRequests:0,deltaRequests:0,lastInputItems:0,websocketFailures:0,sseFallbacks:0},W.set(e,t)),t}function ve(e){let t=W.get(e);return t?{...t}:void 0}function ye(e){if(e){W.delete(e),G.delete(e);return}W.clear(),G.clear()}function q(e){let t=e=>{e.idleTimer&&clearTimeout(e.idleTimer),Q(e.socket,1e3,`debug_close`)};if(e){for(let n of U.get(e)?.values()??[])t(n);U.delete(e);return}for(let e of U.values())for(let n of e.values())t(n);U.clear()}v(q);function J(e){return e?G.has(e):!1}function Y(e){if(!e)return;let t=K(e);t.sseFallbacks++,t.websocketFallbackActive=J(e)}function be(e,t){if(!e)return;G.add(e);let r=K(e);r.websocketFailures++,r.lastWebSocketError=n(t),r.websocketFallbackActive=!0}let X=null;async function xe(e){if(!e&&X)return X;if(typeof process<`u`&&process.versions?.bun){let t=class extends WebSocket{constructor(t,n){let r={};r=Array.isArray(n)||typeof n==`string`?{protocols:n}:{...n};let i=k(t.toString().replace(/^wss:/,`https:`).replace(/^ws:/,`http:`),e);super(t,{...r,...i?{proxy:i.toString()}:{}})}};return e||(X=t),t}let t=globalThis.WebSocket;return typeof t==`function`?t:null}var Se=class extends Error{code;reason;wasClean;constructor(e,t){super(e),this.name=`WebSocketCloseError`,this.code=t?.code,this.reason=t?.reason,this.wasClean=t?.wasClean}};function Ce(e){let t=e.readyState;return typeof t==`number`?t:void 0}function Z(e){let t=Ce(e);return t===void 0||t===1}function we(e){return Date.now()-e.createdAt>=33e5}function Q(e,t=1e3,n=`done`){try{e.close(t,n)}catch{}}function Te(e,t,n){n.idleTimer&&clearTimeout(n.idleTimer),n.idleTimer=setTimeout(()=>{if(n.busy)return;Q(n.socket,1e3,`idle_timeout`);let r=U.get(e);r?.get(t)===n&&r.delete(t),r?.size===0&&U.delete(e)},3e5)}async function $(e,t,n,r=15e3,i){let a=await xe(i);if(!a)throw Error(`WebSocket transport is not available in this runtime`);let o=c(t);return delete o[`OpenAI-Beta`],new Promise((t,i)=>{let s=!1,c,l;try{l=new a(e,{headers:o})}catch(e){i(e instanceof Error?e:Error(String(e)));return}let u=()=>{c&&=(clearTimeout(c),void 0),l.removeEventListener(`open`,f),l.removeEventListener(`error`,p),l.removeEventListener(`close`,m),n?.removeEventListener(`abort`,h)},d=(e,t)=>{s||(s=!0,u(),t&&Q(l,1e3,t),i(e))},f=()=>{s||(s=!0,u(),t(l))},p=e=>{d(De(e))},m=e=>{d(Oe(e))},h=()=>{d(Error(`Request was aborted`),`aborted`)};l.addEventListener(`open`,f),l.addEventListener(`error`,p),l.addEventListener(`close`,m),n?.addEventListener(`abort`,h),r>0&&(c=setTimeout(()=>{d(Error(`WebSocket connect timeout after ${r}ms`),`connect_timeout`)},r)),n?.aborted&&h()})}async function Ee(e,t,n,r,i,a,o){if(!n){let n=await $(e,t,i,a,o);return{socket:n,reused:!1,release:()=>Q(n)}}let s=U.get(n),c=s?.get(r);if(c){if(c.idleTimer&&=(clearTimeout(c.idleTimer),void 0),!c.busy&&we(c))Q(c.socket,1e3,`connection_age_limit`),s?.delete(r),s?.size===0&&U.delete(n);else if(!c.busy&&Z(c.socket))return c.busy=!0,{socket:c.socket,entry:c,reused:!0,release:({keep:e}={})=>{if(!e||!Z(c.socket)){Q(c.socket);let e=U.get(n);e?.get(r)===c&&e.delete(r),e?.size===0&&U.delete(n);return}c.busy=!1,Te(n,r,c)}};if(c.busy){let n=await $(e,t,i,a,o);return{socket:n,reused:!1,release:()=>{Q(n)}}}Z(c.socket)||(Q(c.socket),s?.delete(r),s?.size===0&&U.delete(n))}let l=await $(e,t,i,a,o),u={socket:l,busy:!0,createdAt:Date.now()};return s=U.get(n),s||(s=new Map,U.set(n,s)),s.set(r,u),{socket:l,entry:u,reused:!1,release:({keep:e}={})=>{if(!e||!Z(u.socket)){Q(u.socket),u.idleTimer&&clearTimeout(u.idleTimer);let e=U.get(n);e?.get(r)===u&&e.delete(r),e?.size===0&&U.delete(n);return}u.busy=!1,Te(n,r,u)}}}function De(e){if(e&&typeof e==`object`){let t=`message`in e?e.message:void 0;if(typeof t==`string`&&t.length>0)return Error(t);let n=`error`in e?e.error:void 0;if(n instanceof Error&&n.message.length>0)return n;if(n&&typeof n==`object`&&`message`in n){let e=n.message;if(typeof e==`string`&&e.length>0)return Error(e)}}return Error(`WebSocket error`)}function Oe(e){if(e&&typeof e==`object`){let t=`code`in e?e.code:void 0,n=`reason`in e?e.reason:void 0,r=`wasClean`in e?e.wasClean:void 0,i=typeof t==`number`?` ${t}`:``,a=typeof n==`string`&&n.length>0?` ${n}`:``;return!a&&t===1009&&(a=` message too big`),new Se(`WebSocket closed${i}${a}`.trim(),{code:typeof t==`number`?t:void 0,reason:typeof n==`string`&&n.length>0?n:void 0,wasClean:typeof r==`boolean`?r:void 0})}return Error(`WebSocket closed`)}async function ke(e){if(typeof e==`string`)return e;if(e instanceof ArrayBuffer)return new TextDecoder().decode(new Uint8Array(e));if(ArrayBuffer.isView(e)){let t=e;return new TextDecoder().decode(new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}if(e&&typeof e==`object`&&`arrayBuffer`in e){let t=await e.arrayBuffer();return new TextDecoder().decode(new Uint8Array(t))}return null}async function*Ae(e,t,r){let i=[],a=null,o=!1,s=null,c=!1,l=()=>{if(!a)return;let e=a;a=null,e()},u=e=>{(async()=>{let t=null;try{if(!e||typeof e!=`object`||!(`data`in e)||(t=await ke(e.data),!t))return;let n=JSON.parse(t),r=typeof n.type==`string`?n.type:``;(r===`response.completed`||r===`response.done`||r===`response.incomplete`)&&(c=!0,o=!0),i.push(n),l()}catch(e){s=new V(`Invalid Codex WebSocket JSON: ${n(e)}`,{cause:e,payload:t}),o=!0,l()}})()},d=e=>{s=De(e),o=!0,l()},f=e=>{if(c){o=!0,l();return}s||=Oe(e),o=!0,l()},p=()=>{s=Error(`Request was aborted`),o=!0,l()};e.addEventListener(`message`,u),e.addEventListener(`error`,d),e.addEventListener(`close`,f),t?.addEventListener(`abort`,p);try{for(;;){if(t?.aborted)throw Error(`Request was aborted`);if(i.length>0){yield i.shift();continue}if(o)break;let n;await new Promise((t,i)=>{a=t,r!==void 0&&r>0&&(n=setTimeout(()=>{let t=Error(`WebSocket idle timeout after ${r}ms`);s=t,o=!0,a=null,Q(e,1e3,`idle_timeout`),i(t)},r))}).finally(()=>{n&&clearTimeout(n)})}if(s)throw s;if(!c)throw Error(`WebSocket stream closed before response.completed`)}finally{e.removeEventListener(`message`,u),e.removeEventListener(`error`,d),e.removeEventListener(`close`,f),t?.removeEventListener(`abort`,p)}}function je(e){let{input:t,previous_response_id:n,...r}=e;return r}function Me(e,t){return JSON.stringify(e??[])===JSON.stringify(t??[])}function Ne(e,t){return JSON.stringify(je(e))===JSON.stringify(je(t))}function Pe(e,t){if(!Ne(e,t.lastRequestBody))return;let n=e.input??[],r=[...t.lastRequestBody.input??[],...t.lastResponseItems];if(!(n.length<r.length)&&Me(n.slice(0,r.length),r))return n.slice(r.length)}function Fe(e,t){let n=e.continuation;if(!n)return t;let r=Pe(t,n);return!r||!n.lastResponseId?(e.continuation=void 0,t):{...t,previous_response_id:n.lastResponseId,input:r}}async function*Ie(e,t){let n=!1;for await(let r of e)n||(n=!0,t()),yield r}async function Le(e,t,n,r,i,a,o,s,c,l,u,d,f){let{socket:p,entry:m,reused:_,release:v}=await Ee(e,n,l,u,f?.signal,c,f?.env),y=!0,b=f?.transport===`websocket-cached`||f?.transport===`auto`,x=t,S=b&&m?Fe(m,x):x,C=l?K(l):void 0;C&&(C.requests++,_?C.connectionsReused++:C.connectionsCreated++,b&&C.cachedContextRequests++,S.store===!0&&C.storeTrueRequests++,C.lastInputItems=S.input?.length??0,S.previous_response_id?(C.deltaRequests++,C.lastDeltaInputItems=S.input?.length??0,C.lastPreviousResponseId=S.previous_response_id):(C.fullContextRequests++,C.lastDeltaInputItems=void 0,C.lastPreviousResponseId=void 0));try{if(p.send(JSON.stringify({type:`response.create`,...S})),await h(Ie(H(Ae(p,f?.signal,s),r),o),r,i,a,{serviceTier:f?.serviceTier,grammarToolInputProperties:d,resolveServiceTier:R,applyServiceTierPricing:(e,t)=>L(e,t,a)}),f?.signal?.aborted)y=!1;else if(b&&m&&r.responseId){let e=g(a,{messages:[r]},j,{includeSystemPrompt:!1,grammarToolInputProperties:d}).filter(e=>e.type!==`function_call_output`&&e.type!==`custom_tool_call_output`);m.continuation={lastRequestBody:x,lastResponseId:r.responseId,lastResponseItems:e}}}catch(e){throw m&&(m.continuation=void 0),y=!1,e}finally{v({keep:y})}}async function Re(e){let t=await e.text(),n=t||e.statusText||`Request failed`,r;try{let i=JSON.parse(t)?.error;if(i){let t=i.code||i.type||``;if(/usage_limit_reached|usage_not_included|rate_limit_exceeded/i.test(t)||e.status===429){let e=i.plan_type?` (${i.plan_type.toLowerCase()} plan)`:``,t=i.resets_at?Math.max(0,Math.round((i.resets_at*1e3-Date.now())/6e4)):void 0;r=`You have hit your ChatGPT usage limit${e}.${t===void 0?``:` Try again in ~${t} min.`}`.trim()}n=i.message||r||n}}catch{}return{message:n,friendlyMessage:r}}function ze(e){try{let t=e.split(`.`);if(t.length!==3)throw Error(`Invalid token`);let n=JSON.parse(atob(t[1]))?.[`https://api.openai.com/auth`]?.chatgpt_account_id;if(!n)throw Error(`No account ID in token`);return n}catch{throw Error(`Failed to extract accountId from token`)}}function Be(e,t,n,r){let i=new Headers(e);for(let[e,n]of Object.entries(t||{}))n===null?i.delete(e):i.set(e,n);return i.set(`Authorization`,`Bearer ${r}`),i.set(`chatgpt-account-id`,n),i.set(`originator`,`pi`),i.set(`User-Agent`,l()),i}function Ve(e,t,n,r,i){let a=Be(e,t,n,r);return a.set(`OpenAI-Beta`,`responses=experimental`),a.set(`accept`,`text/event-stream`),a.set(`content-type`,`application/json`),i&&(a.set(`session-id`,i),a.set(`x-client-request-id`,i)),a}function He(e,t,n,r,i){let a=Be(e,t,n,r);return a.delete(`accept`),a.delete(`content-type`),a.delete(`OpenAI-Beta`),a.delete(`openai-beta`),a.set(`OpenAI-Beta`,`responses_websockets=2026-02-06`),a.set(`x-client-request-id`,i),a.set(`session-id`,i),a}export{q as closeOpenAICodexWebSocketSessions,ve as getOpenAICodexWebSocketDebugStats,ye as resetOpenAICodexWebSocketDebugStats,I as stream,se as streamSimple};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import{i as e,n as t,r as n,t as r}from"./diagnostics-DN_idNHx.js";import{c as i,i as a}from"./transform-messages-N_eMsP2M.js";import{t as o}from"./provider-env-CTOcDKrQ.js";import{t as s}from"./deferred-tools-C1IEsG5C.js";import{t as c}from"./headers-CbDaTl3c.js";import{t as l}from"./pi-user-agent-6Rm79QmC.js";import{n as u}from"./constrained-sampling-Zzx2ko9x.js";import{n as d,t as f}from"./error-body-pkrba6pf.js";import{t as p}from"./openai-prompt-cache-DXo9f3w5.js";import{n as m,r as h,t as g}from"./openai-responses-shared-DhnqxYC9.js";var _=new Set;function v(e){return _.add(e),()=>{_.delete(e)}}var y=-1/0,b=0;function x(e){if(globalThis.crypto?.getRandomValues){globalThis.crypto.getRandomValues(e);return}for(let t=0;t<e.length;t++)e[t]=Math.floor(Math.random()*256)}function S(){let e=new Uint8Array(16);x(e);let t=Date.now();t>y?(b=e[6]*16777216+e[7]*65536+e[8]*256+e[9],y=t):(b=b+1>>>0,b===0&&y++);let n=new Uint8Array(16);n[0]=y/1099511627776&255,n[1]=y/4294967296&255,n[2]=y/16777216&255,n[3]=y/65536&255,n[4]=y/256&255,n[5]=y&255,n[6]=112|b>>>28&15,n[7]=b>>>20&255,n[8]=128|b>>>14&63,n[9]=b>>>6&255,n[10]=(b&63)<<2|e[10]&3,n[11]=e[11],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15];let r=Array.from(n,e=>e.toString(16).padStart(2,`0`));return`${r.slice(0,4).join(``)}-${r.slice(4,6).join(``)}-${r.slice(6,8).join(``)}-${r.slice(8,10).join(``)}-${r.slice(10,16).join(``)}`}function C(e){let t=e.filter(e=>e!==void 0);if(t.length===0)return{cleanup:()=>{}};if(t.length===1)return{signal:t[0],cleanup:()=>{}};let n=new AbortController,r=[],i=e=>{n.signal.aborted||n.abort(e.reason)};for(let e of t){if(e.aborted){i(e);break}let t=()=>i(e);e.addEventListener(`abort`,t,{once:!0}),r.push({signal:e,listener:t})}return{signal:n.signal,cleanup:()=>{for(let{signal:e,listener:t}of r)e.removeEventListener(`abort`,t)}}}var w={ftp:21,gopher:70,http:80,https:443,ws:80,wss:443};function T(e,t){let n=e.toLowerCase(),r=e.toUpperCase();return t?.[n]||t?.[r]||o(n)||o(r)||``}function E(e){if(e instanceof URL)return e;try{return new URL(e)}catch{return}}function D(e,t,n){let r=T(`no_proxy`,n).toLowerCase();return!r||r!==`*`&&r.split(/[,\s]/).every(n=>{if(!n)return!0;let r=n.match(/^(.+):(\d+)$/),i=r?r[1]:n,a=r?Number.parseInt(r[2],10):0;return a&&a!==t?!0:/^[.*]/.test(i)?(i.startsWith(`*`)&&(i=i.slice(1)),!e.endsWith(i)):e!==i})}function O(e,t){let n=E(e);if(!n?.protocol||!n.host)return``;let r=n.protocol.split(`:`,1)[0];if(!D(n.host.replace(/:\d*$/,``),Number.parseInt(n.port,10)||w[r]||0,t))return``;let i=T(`${r}_proxy`,t)||T(`all_proxy`,t);return i&&!i.includes(`://`)&&(i=`${r}://${i}`),i}var k=`Unsupported proxy protocol. SOCKS and PAC proxy URLs are not supported; use an HTTP or HTTPS proxy URL.`;function A(e,t){let n=O(e,t);if(!n)return;let r;try{r=new URL(n)}catch(e){throw Error(`Invalid proxy URL ${JSON.stringify(n)}: ${e instanceof Error?e.message:String(e)}`)}if(r.protocol!==`http:`&&r.protocol!==`https:`)throw Error(`${k} Got ${r.protocol}`);return r}var j=`https://chatgpt.com/backend-api`,M=`https://api.openai.com/auth`,ee=0,N=1e3,te=6e4,ne=15e3,re=3,ie=new Set([`openai`,`openai-codex`,`opencode`]),ae=1009,oe=`websocket_connection_limit_reached`,se=`previous_response_not_found`,ce=new Set([`completed`,`incomplete`,`failed`,`cancelled`,`queued`,`in_progress`]);function P(e){if(e.stopReason===`pending`)throw Error(`Codex stream ended without a stop reason`);if(e.stopReason===`error`||e.stopReason===`aborted`)throw Error(e.errorMessage||`An unknown error occurred`)}function le(e){return/GoUsageLimitError|FreeUsageLimitError|Monthly usage limit reached|available balance|insufficient_quota|out of budget|quota exceeded|billing/i.test(e)}function ue(e,t){return e===429&&le(t)?!1:e===429||e===500||e===502||e===503||e===504||/rate.?limit|overloaded|service.?unavailable|upstream.?connect|connection.?refused/i.test(t)}function de(e){let t=e.get(`retry-after-ms`);if(t!==null){let e=Number(t);if(Number.isFinite(e))return Math.max(0,e)}let n=e.get(`retry-after`);if(!n)return;let r=Number(n);if(Number.isFinite(r))return Math.max(0,r*1e3);let i=Date.parse(n);if(!Number.isNaN(i))return Math.max(0,i-Date.now())}var F=class extends Error{};function fe(e,t){let n=t?.maxRetryDelayMs??te;if(n>0&&e>n)throw new F(`Server requested ${Math.ceil(e/1e3)}s retry delay (max: ${Math.ceil(n/1e3)}s)`);return e}function I(e,t){return new Promise((n,r)=>{if(t?.aborted){r(Error(`Request was aborted`));return}let i=setTimeout(n,e);t?.addEventListener(`abort`,()=>{clearTimeout(i),r(Error(`Request was aborted`))})})}function L(e){if(e!==void 0){if(!Number.isFinite(e)||e<0)throw Error(`Invalid timeoutMs: ${String(e)}`);return Math.floor(e)}}function pe(){return typeof process>`u`||!(process.versions?.node||process.versions?.bun)?null:process.getBuiltinModule?.(`node:zlib`)??null}function me(e){let t=pe();if(!t||typeof t.zstdCompressSync!=`function`)return null;try{let n=t.zstdCompressSync(e,{params:{[t.constants.ZSTD_c_compressionLevel]:re}});return new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}catch{return null}}var R=(n,i,a)=>{let o=new e;return(async()=>{let e={role:`assistant`,content:[],api:`openai-codex-responses`,provider:n.provider,model:n.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`pending`,timestamp:Date.now()};try{let s=a?.apiKey;if(!s)throw Error(`No API key for provider: ${n.provider}`);let l=Qe(s),d=u(i.tools,n.compat?.supportsOpenAIGrammarTools??!1),f=a?.cacheRetention===`none`?void 0:a?.sessionId,m=p(f),h=ge(n,i,a,m,d),g=await a?.onPayload?.(h,n);g!==void 0&&(h=g);let _=m||S(),v=et(n.headers,a?.headers,l,s,m),y=tt(n.headers,a?.headers,l,s,_),b=JSON.stringify(h),x=L(a?.timeoutMs),w=L(a?.websocketConnectTimeoutMs),T=a?.transport||`auto`,E=!1,D=T!==`sse`&&Me(f);if(D&&Ne(f),T!==`sse`&&!D){let i=!1,s=!1,c=!1;for(;;){i=!1;try{if(await Xe(ve(n.baseUrl),h,y,e,o,n,()=>{i=!0,E||(E=!0,o.push({type:`start`,partial:e}))},x,w,f,l,d,a),a?.signal?.aborted)throw Error(`Request was aborted`);P(e),o.push({type:`done`,reason:e.stopReason,message:e}),o.end();return}catch(n){let o=a?.signal?.aborted,l=!i&&xe(n),u=Se(n);if(!o&&u&&!c){c=!0;continue}if(!o&&l&&!s){s=!0;continue}if(o||be(n)&&!l||(r(e,t(`provider_transport_failure`,n,{configuredTransport:T,fallbackTransport:i?void 0:`sse`,eventsEmitted:i,phase:i?`after_message_stream_start`:`before_message_stream_start`,requestBytes:new TextEncoder().encode(b).byteLength})),Pe(f,n),i))throw n;Ne(f);break}}}let O=me(b);O&&v.set(`content-encoding`,`zstd`);let k=O??b,A,j,M=a?.maxRetries??ee;for(let e=0;e<=M;e++){if(a?.signal?.aborted)throw Error(`Request was aborted`);try{let t=x!==void 0&&x>0?AbortSignal.timeout(x):void 0,r=C([a?.signal,t]);try{A=await(a?.fetch??globalThis.fetch)(V(n.baseUrl),{method:`POST`,headers:v,body:k,signal:r.signal})}catch(e){throw t?.aborted&&!a?.signal?.aborted?Error(`Codex SSE response headers timed out after ${x}ms`):e}finally{r.cleanup()}if(await a?.onResponse?.({status:A.status,headers:c(A.headers)},n),A.ok)break;let i=await A.text();if(e<M&&ue(A.status,i)){let t=de(A.headers);await I(t===void 0?N*2**e:fe(t,a),a?.signal);continue}let o=await Ze(new Response(i,{status:A.status,statusText:A.statusText}));throw Error(o.friendlyMessage||o.message)}catch(t){if(t instanceof Error&&(t.name===`AbortError`||t.message===`Request was aborted`))throw Error(`Request was aborted`);if(j=t instanceof Error?t:Error(String(t)),e<M&&!(j instanceof F)&&!j.message.includes(`usage limit`)){await I(N*2**e,a?.signal);continue}throw j}}if(!A?.ok)throw j??Error(`Failed after retries`);if(!A.body)throw Error(`No response body`);if(E||(E=!0,o.push({type:`start`,partial:e})),await ye(A,e,o,n,d,a),a?.signal?.aborted)throw Error(`Request was aborted`);P(e),o.push({type:`done`,reason:e.stopReason,message:e}),o.end()}catch(t){for(let t of e.content)delete t.partialJson,delete t.customInput;e.stopReason=a?.signal?.aborted?`aborted`:`error`,e.errorMessage=f(d(t)),o.push({type:`error`,reason:e.stopReason,error:e}),o.end()}})(),o},he=(e,t,n)=>{let r=n?.apiKey;if(!r)throw Error(`No API key for provider: ${e.provider}`);let o=a(e,t,n,r),s=n?.reasoning?i(e,n.reasoning):void 0,c=s===`off`?void 0:s;return R(e,t,{...o,reasoningEffort:c})};function ge(e,t,n,r,i=u(t.tools,e.compat?.supportsOpenAIGrammarTools??!1)){let a=e.compat?.supportsStrictMode??!0,o=e.compat?.supportsOpenAIGrammarTools??!1,c=e.compat?.supportsAdditionalTools?`additional-tools`:e.compat?.supportsToolSearch?`tool-search`:void 0,l=s(t,c!==void 0),d=g(e,t,ie,{includeSystemPrompt:!1,grammarToolInputProperties:i,deferredTools:l.deferred,deferredToolsMode:c,toolOptions:{strict:null,supportsStrictMode:a,supportsOpenAIGrammarTools:o}}),f={model:e.id,store:!1,stream:!0,instructions:t.systemPrompt||`You are a helpful assistant.`,input:d,text:{verbosity:n?.textVerbosity||`low`},include:[`reasoning.encrypted_content`],prompt_cache_key:r,tool_choice:n?.toolChoice??`auto`,parallel_tool_calls:!0};if(n?.temperature!==void 0&&(f.temperature=n.temperature),n?.serviceTier!==void 0&&(f.service_tier=n.serviceTier),l.immediate.length>0&&(f.tools=m(l.immediate,{strict:null,supportsStrictMode:a,supportsOpenAIGrammarTools:o})),n?.reasoningEffort!==void 0){let t=n.reasoningEffort===`none`?e.thinkingLevelMap?.off??`none`:e.thinkingLevelMap?.[n.reasoningEffort]??n.reasoningEffort;t!==null&&(f.reasoning={effort:t,summary:n.reasoningSummary??`auto`})}return f}function _e(e,t){switch(t){case`flex`:return .5;case`priority`:return e.id===`gpt-5.5`?2.5:2;default:return 1}}function z(e,t,n){let r=_e(n,t);r!==1&&(e.cost.input*=r,e.cost.output*=r,e.cost.cacheRead*=r,e.cost.cacheWrite*=r,e.cost.total=e.cost.input+e.cost.output+e.cost.cacheRead+e.cost.cacheWrite)}function B(e,t){return e==="default"&&(t===`flex`||t===`priority`)?t:e??t}function V(e){let t=(e&&e.trim().length>0?e:j).replace(/\/+$/,``);return t.endsWith(`/codex/responses`)?t:t.endsWith(`/codex`)?`${t}/responses`:`${t}/codex/responses`}function ve(e){let t=new URL(V(e));return t.protocol===`https:`&&(t.protocol=`wss:`),t.protocol===`http:`&&(t.protocol=`ws:`),t.toString()}async function ye(e,t,n,r,i,a){await h(W(Te(e,a?.signal),t),t,n,r,{serviceTier:a?.serviceTier,grammarToolInputProperties:i,resolveServiceTier:B,applyServiceTierPricing:(e,t)=>z(e,t,r)})}var H=class extends Error{code;payload;constructor(e,t){super(e),this.name=`CodexApiError`,this.code=t?.code,this.payload=t?.payload,this.cause=t?.cause}},U=class extends Error{payload;constructor(e,t){super(e),this.name=`CodexProtocolError`,this.payload=t?.payload,this.cause=t?.cause}};function be(e){return e instanceof H||e instanceof U}function xe(e){return e instanceof H&&e.code===oe}function Se(e){return e instanceof H&&e.code===se}function Ce(e){let t=e.error&&typeof e.error==`object`?e.error:void 0;return{code:typeof e.code==`string`?e.code:typeof t?.code==`string`?t.code:void 0,message:typeof e.message==`string`?e.message:typeof t?.message==`string`?t.message:void 0}}async function*W(e,t){for await(let n of e){let e=typeof n.type==`string`?n.type:void 0;if(e){if(e===`error`){let{code:e,message:t}=Ce(n);throw new H(`Codex error: ${t||e||JSON.stringify(n)}`,{code:e,payload:n})}if(e===`response.failed`){let e=n.response,t=e?.error?.code,r=e?.error?.message;throw new H(r||`Codex response failed`,{code:t,payload:n})}if(e===`response.done`||e===`response.completed`||e===`response.incomplete`){let e=n.response;typeof e?.end_turn==`boolean`&&(t.endTurn=e.end_turn);let r=e&&{...e,status:we(e.status)};yield{...n,type:`response.completed`,response:r};return}yield n}}}function we(e){if(typeof e==`string`)return ce.has(e)?e:void 0}async function*Te(e,t){if(!e.body)return;let r=e.body.getReader(),i=new TextDecoder,a=``,o=()=>{r.cancel().catch(()=>{})};t?.addEventListener(`abort`,o,{once:!0});try{for(;;){if(t?.aborted)throw Error(`Request was aborted`);let{done:e,value:o}=await r.read();if(t?.aborted)throw Error(`Request was aborted`);if(e)break;a+=i.decode(o,{stream:!0});let s=a.indexOf(`
|
|
2
|
-
|
|
3
|
-
`);for(;s!==-1;){let e=a.slice(0,s);a=a.slice(s+2);let t=e.split(`
|
|
4
|
-
`).filter(e=>e.startsWith(`data:`)).map(e=>e.slice(5).trim());if(t.length>0){let e=t.join(`
|
|
5
|
-
`).trim();if(e&&e!==`[DONE]`)try{yield JSON.parse(e)}catch(t){throw new U(`Invalid Codex SSE JSON: ${n(t)}`,{cause:t,payload:e})}}s=a.indexOf(`
|
|
6
|
-
|
|
7
|
-
`)}}}finally{t?.removeEventListener(`abort`,o);try{await r.cancel()}catch{}try{r.releaseLock()}catch{}}}var Ee=`responses_websockets=2026-02-06`,De=3e5,Oe=33e5,G=new Map,K=new Map,q=new Set;function J(e){let t=K.get(e);return t||(t={requests:0,connectionsCreated:0,connectionsReused:0,cachedContextRequests:0,storeTrueRequests:0,fullContextRequests:0,deltaRequests:0,lastInputItems:0,websocketFailures:0,sseFallbacks:0},K.set(e,t)),t}function ke(e){let t=K.get(e);return t?{...t}:void 0}function Ae(e){if(e){K.delete(e),q.delete(e);return}K.clear(),q.clear()}function je(e){let t=e=>{e.idleTimer&&clearTimeout(e.idleTimer),Z(e.socket,1e3,`debug_close`)};if(e){for(let n of G.get(e)?.values()??[])t(n);G.delete(e);return}for(let e of G.values())for(let n of e.values())t(n);G.clear()}v(je);function Me(e){return e?q.has(e):!1}function Ne(e){if(!e)return;let t=J(e);t.sseFallbacks++,t.websocketFallbackActive=Me(e)}function Pe(e,t){if(!e)return;q.add(e);let r=J(e);r.websocketFailures++,r.lastWebSocketError=n(t),r.websocketFallbackActive=!0}var Y=null;async function Fe(e){if(!e&&Y)return Y;if(typeof process<`u`&&process.versions?.bun){let t=class extends WebSocket{constructor(t,n){let r={};r=Array.isArray(n)||typeof n==`string`?{protocols:n}:{...n};let i=A(t.toString().replace(/^wss:/,`https:`).replace(/^ws:/,`http:`),e);super(t,{...r,...i?{proxy:i.toString()}:{}})}};return e||(Y=t),t}let t=globalThis.WebSocket;return typeof t==`function`?t:null}var Ie=class extends Error{code;reason;wasClean;constructor(e,t){super(e),this.name=`WebSocketCloseError`,this.code=t?.code,this.reason=t?.reason,this.wasClean=t?.wasClean}};function Le(e){let t=e.readyState;return typeof t==`number`?t:void 0}function X(e){let t=Le(e);return t===void 0||t===1}function Re(e){return Date.now()-e.createdAt>=Oe}function Z(e,t=1e3,n=`done`){try{e.close(t,n)}catch{}}function ze(e,t,n){n.idleTimer&&clearTimeout(n.idleTimer),n.idleTimer=setTimeout(()=>{if(n.busy)return;Z(n.socket,1e3,`idle_timeout`);let r=G.get(e);r?.get(t)===n&&r.delete(t),r?.size===0&&G.delete(e)},De)}async function Q(e,t,n,r=ne,i){let a=await Fe(i);if(!a)throw Error(`WebSocket transport is not available in this runtime`);let o=c(t);return delete o[`OpenAI-Beta`],new Promise((t,i)=>{let s=!1,c,l;try{l=new a(e,{headers:o})}catch(e){i(e instanceof Error?e:Error(String(e)));return}let u=()=>{c&&=(clearTimeout(c),void 0),l.removeEventListener(`open`,f),l.removeEventListener(`error`,p),l.removeEventListener(`close`,m),n?.removeEventListener(`abort`,h)},d=(e,t)=>{s||(s=!0,u(),t&&Z(l,1e3,t),i(e))},f=()=>{s||(s=!0,u(),t(l))},p=e=>{d(Ve(e))},m=e=>{d($(e))},h=()=>{d(Error(`Request was aborted`),`aborted`)};l.addEventListener(`open`,f),l.addEventListener(`error`,p),l.addEventListener(`close`,m),n?.addEventListener(`abort`,h),r>0&&(c=setTimeout(()=>{d(Error(`WebSocket connect timeout after ${r}ms`),`connect_timeout`)},r)),n?.aborted&&h()})}async function Be(e,t,n,r,i,a,o){if(!n){let n=await Q(e,t,i,a,o);return{socket:n,reused:!1,release:()=>Z(n)}}let s=G.get(n),c=s?.get(r);if(c){if(c.idleTimer&&=(clearTimeout(c.idleTimer),void 0),!c.busy&&Re(c))Z(c.socket,1e3,`connection_age_limit`),s?.delete(r),s?.size===0&&G.delete(n);else if(!c.busy&&X(c.socket))return c.busy=!0,{socket:c.socket,entry:c,reused:!0,release:({keep:e}={})=>{if(!e||!X(c.socket)){Z(c.socket);let e=G.get(n);e?.get(r)===c&&e.delete(r),e?.size===0&&G.delete(n);return}c.busy=!1,ze(n,r,c)}};if(c.busy){let n=await Q(e,t,i,a,o);return{socket:n,reused:!1,release:()=>{Z(n)}}}X(c.socket)||(Z(c.socket),s?.delete(r),s?.size===0&&G.delete(n))}let l=await Q(e,t,i,a,o),u={socket:l,busy:!0,createdAt:Date.now()};return s=G.get(n),s||(s=new Map,G.set(n,s)),s.set(r,u),{socket:l,entry:u,reused:!1,release:({keep:e}={})=>{if(!e||!X(u.socket)){Z(u.socket),u.idleTimer&&clearTimeout(u.idleTimer);let e=G.get(n);e?.get(r)===u&&e.delete(r),e?.size===0&&G.delete(n);return}u.busy=!1,ze(n,r,u)}}}function Ve(e){if(e&&typeof e==`object`){let t=`message`in e?e.message:void 0;if(typeof t==`string`&&t.length>0)return Error(t);let n=`error`in e?e.error:void 0;if(n instanceof Error&&n.message.length>0)return n;if(n&&typeof n==`object`&&`message`in n){let e=n.message;if(typeof e==`string`&&e.length>0)return Error(e)}}return Error(`WebSocket error`)}function $(e){if(e&&typeof e==`object`){let t=`code`in e?e.code:void 0,n=`reason`in e?e.reason:void 0,r=`wasClean`in e?e.wasClean:void 0,i=typeof t==`number`?` ${t}`:``,a=typeof n==`string`&&n.length>0?` ${n}`:``;return!a&&t===ae&&(a=` message too big`),new Ie(`WebSocket closed${i}${a}`.trim(),{code:typeof t==`number`?t:void 0,reason:typeof n==`string`&&n.length>0?n:void 0,wasClean:typeof r==`boolean`?r:void 0})}return Error(`WebSocket closed`)}async function He(e){if(typeof e==`string`)return e;if(e instanceof ArrayBuffer)return new TextDecoder().decode(new Uint8Array(e));if(ArrayBuffer.isView(e)){let t=e;return new TextDecoder().decode(new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}if(e&&typeof e==`object`&&`arrayBuffer`in e){let t=await e.arrayBuffer();return new TextDecoder().decode(new Uint8Array(t))}return null}async function*Ue(e,t,r){let i=[],a=null,o=!1,s=null,c=!1,l=()=>{if(!a)return;let e=a;a=null,e()},u=e=>{(async()=>{let t=null;try{if(!e||typeof e!=`object`||!(`data`in e)||(t=await He(e.data),!t))return;let n=JSON.parse(t),r=typeof n.type==`string`?n.type:``;(r===`response.completed`||r===`response.done`||r===`response.incomplete`)&&(c=!0,o=!0),i.push(n),l()}catch(e){s=new U(`Invalid Codex WebSocket JSON: ${n(e)}`,{cause:e,payload:t}),o=!0,l()}})()},d=e=>{s=Ve(e),o=!0,l()},f=e=>{if(c){o=!0,l();return}s||=$(e),o=!0,l()},p=()=>{s=Error(`Request was aborted`),o=!0,l()};e.addEventListener(`message`,u),e.addEventListener(`error`,d),e.addEventListener(`close`,f),t?.addEventListener(`abort`,p);try{for(;;){if(t?.aborted)throw Error(`Request was aborted`);if(i.length>0){yield i.shift();continue}if(o)break;let n;await new Promise((t,i)=>{a=t,r!==void 0&&r>0&&(n=setTimeout(()=>{let t=Error(`WebSocket idle timeout after ${r}ms`);s=t,o=!0,a=null,Z(e,1e3,`idle_timeout`),i(t)},r))}).finally(()=>{n&&clearTimeout(n)})}if(s)throw s;if(!c)throw Error(`WebSocket stream closed before response.completed`)}finally{e.removeEventListener(`message`,u),e.removeEventListener(`error`,d),e.removeEventListener(`close`,f),t?.removeEventListener(`abort`,p)}}function We(e){let{input:t,previous_response_id:n,...r}=e;return r}function Ge(e,t){return JSON.stringify(e??[])===JSON.stringify(t??[])}function Ke(e,t){return JSON.stringify(We(e))===JSON.stringify(We(t))}function qe(e,t){if(!Ke(e,t.lastRequestBody))return;let n=e.input??[],r=[...t.lastRequestBody.input??[],...t.lastResponseItems];if(!(n.length<r.length)&&Ge(n.slice(0,r.length),r))return n.slice(r.length)}function Je(e,t){let n=e.continuation;if(!n)return t;let r=qe(t,n);return!r||!n.lastResponseId?(e.continuation=void 0,t):{...t,previous_response_id:n.lastResponseId,input:r}}async function*Ye(e,t){let n=!1;for await(let r of e)n||(n=!0,t()),yield r}async function Xe(e,t,n,r,i,a,o,s,c,l,u,d,f){let{socket:p,entry:m,reused:_,release:v}=await Be(e,n,l,u,f?.signal,c,f?.env),y=!0,b=f?.transport===`websocket-cached`||f?.transport===`auto`,x=t,S=b&&m?Je(m,x):x,C=l?J(l):void 0;C&&(C.requests++,_?C.connectionsReused++:C.connectionsCreated++,b&&C.cachedContextRequests++,S.store===!0&&C.storeTrueRequests++,C.lastInputItems=S.input?.length??0,S.previous_response_id?(C.deltaRequests++,C.lastDeltaInputItems=S.input?.length??0,C.lastPreviousResponseId=S.previous_response_id):(C.fullContextRequests++,C.lastDeltaInputItems=void 0,C.lastPreviousResponseId=void 0));try{if(p.send(JSON.stringify({type:`response.create`,...S})),await h(Ye(W(Ue(p,f?.signal,s),r),o),r,i,a,{serviceTier:f?.serviceTier,grammarToolInputProperties:d,resolveServiceTier:B,applyServiceTierPricing:(e,t)=>z(e,t,a)}),f?.signal?.aborted)y=!1;else if(b&&m&&r.responseId){let e=g(a,{messages:[r]},ie,{includeSystemPrompt:!1,grammarToolInputProperties:d}).filter(e=>e.type!==`function_call_output`&&e.type!==`custom_tool_call_output`);m.continuation={lastRequestBody:x,lastResponseId:r.responseId,lastResponseItems:e}}}catch(e){throw m&&(m.continuation=void 0),y=!1,e}finally{v({keep:y})}}async function Ze(e){let t=await e.text(),n=t||e.statusText||`Request failed`,r;try{let i=JSON.parse(t)?.error;if(i){let t=i.code||i.type||``;if(/usage_limit_reached|usage_not_included|rate_limit_exceeded/i.test(t)||e.status===429){let e=i.plan_type?` (${i.plan_type.toLowerCase()} plan)`:``,t=i.resets_at?Math.max(0,Math.round((i.resets_at*1e3-Date.now())/6e4)):void 0;r=`You have hit your ChatGPT usage limit${e}.${t===void 0?``:` Try again in ~${t} min.`}`.trim()}n=i.message||r||n}}catch{}return{message:n,friendlyMessage:r}}function Qe(e){try{let t=e.split(`.`);if(t.length!==3)throw Error(`Invalid token`);let n=JSON.parse(atob(t[1]))?.[M]?.chatgpt_account_id;if(!n)throw Error(`No account ID in token`);return n}catch{throw Error(`Failed to extract accountId from token`)}}function $e(e,t,n,r){let i=new Headers(e);for(let[e,n]of Object.entries(t||{}))n===null?i.delete(e):i.set(e,n);return i.set(`Authorization`,`Bearer ${r}`),i.set(`chatgpt-account-id`,n),i.set(`originator`,`pi`),i.set(`User-Agent`,l()),i}function et(e,t,n,r,i){let a=$e(e,t,n,r);return a.set(`OpenAI-Beta`,`responses=experimental`),a.set(`accept`,`text/event-stream`),a.set(`content-type`,`application/json`),i&&(a.set(`session-id`,i),a.set(`x-client-request-id`,i)),a}function tt(e,t,n,r,i){let a=$e(e,t,n,r);return a.delete(`accept`),a.delete(`content-type`),a.delete(`OpenAI-Beta`),a.delete(`openai-beta`),a.set(`OpenAI-Beta`,Ee),a.set(`x-client-request-id`,i),a.set(`session-id`,i),a}export{je as closeOpenAICodexWebSocketSessions,ke as getOpenAICodexWebSocketDebugStats,Ae as resetOpenAICodexWebSocketDebugStats,R as stream,he as streamSimple};
|