sliccy 6.218.2 → 6.220.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/dist/ui/.vite/manifest.json +182 -182
- package/dist/ui/assets/SKILL-53i4JhqF.js +1 -0
- package/dist/ui/assets/{account-store-ravOkuEh.js → account-store-CPtYzXW6.js} +1 -1
- package/dist/ui/assets/{account-store-BAcqOQ-B.js → account-store-Cl-FqDg2.js} +1 -1
- package/dist/ui/assets/{adobe-pJN-ccGb.js → adobe-BeBRKE0L.js} +1 -1
- package/dist/ui/assets/{adobe-BiZfsUty.js → adobe-BrXpxUlh.js} +1 -1
- package/dist/ui/assets/{agent-panels-RX0aZNxw.js → agent-panels-D8EphX6Z.js} +1 -1
- package/dist/ui/assets/{almost-bash-shell-headless-CrjX8fl9.js → almost-bash-shell-headless-1Osh0Z8C.js} +36 -36
- package/dist/ui/assets/{apply-layout-el2h8g2C.js → apply-layout-DDkQHScp.js} +1 -1
- package/dist/ui/assets/{apps-B_AtpN8Z.js → apps-CYhZkZhV.js} +1 -1
- package/dist/ui/assets/{azure-openai-DHcO2cmT.js → azure-openai-C8OX-0Yv.js} +1 -1
- package/dist/ui/assets/{azure-openai-KNZuu6zT.js → azure-openai-FqtiJilI.js} +1 -1
- package/dist/ui/assets/{backend-hostfs-BDDFu6nL.js → backend-hostfs-DLGJSflr.js} +1 -1
- package/dist/ui/assets/{cdp-DCRqc_78.js → cdp-Ckvzmp8B.js} +1 -1
- package/dist/ui/assets/{cerebras-BlJAvwBj.js → cerebras-B45pfuRX.js} +1 -1
- package/dist/ui/assets/{cerebras-cELX_-Tv.js → cerebras-DmzPOFQ_.js} +1 -1
- package/dist/ui/assets/{composer-speech-DH1izq66.js → composer-speech-BBc1XkYd.js} +1 -1
- package/dist/ui/assets/{connect-surface-B3q5wFk-.js → connect-surface-BRbaHldo.js} +1 -1
- package/dist/ui/assets/{directed-approval-D1HryfoH.js → directed-approval-BWUFnlaC.js} +1 -1
- package/dist/ui/assets/{emscripten-vfs-hook-B4FfTaY4.js → emscripten-vfs-hook-yLP6dJtB.js} +1 -1
- package/dist/ui/assets/{ensure-speech-assets-D4_slw76.js → ensure-speech-assets-BI-zTzno.js} +1 -1
- package/dist/ui/assets/{frozen-archive-writer-e3mSQ8e5.js → frozen-archive-writer-BZ76mOLL.js} +1 -1
- package/dist/ui/assets/{fs-BVa_vuoo.js → fs-C3ewd7zM.js} +1 -1
- package/dist/ui/assets/{fs-gotPoSZp.js → fs-CPOlAGHF.js} +2 -2
- package/dist/ui/assets/{gelatiere-store-DAXCFmPP.js → gelatiere-store-D-qUWaKm.js} +1 -1
- package/dist/ui/assets/{gelatiere-unit-qTkgNxXs.js → gelatiere-unit-HNzB0CJ8.js} +1 -1
- package/dist/ui/assets/{github-B2VWEFqp.js → github-BIZEUSeE.js} +2 -2
- package/dist/ui/assets/{github-BZHffErO.js → github-DqsPFEa7.js} +1 -1
- package/dist/ui/assets/{github-auth-BNgH9jG6.js → github-auth-Dyywp0XK.js} +1 -1
- package/dist/ui/assets/{github-copilot-BfIflOh7.js → github-copilot-BVkNwGDF.js} +1 -1
- package/dist/ui/assets/{github-copilot-B5jdTW-u.js → github-copilot-C-DftX7y.js} +1 -1
- package/dist/ui/assets/{github-install-Cxleuyru.js → github-install-DhfQgSHk.js} +1 -1
- package/dist/ui/assets/{github-zip-DgJl9Jw1.js → github-zip-Bkjwx2jz.js} +1 -1
- package/dist/ui/assets/{hear-BiUNm14H.js → hear-CIpNY63f.js} +1 -1
- package/dist/ui/assets/{help-Bo2yyWMr.js → help-BukbR0D0.js} +1 -1
- package/dist/ui/assets/{installer-DP22Qfj-.js → installer-BFRw_lRf.js} +1 -1
- package/dist/ui/assets/{ipk-mamba-DvgLiW3J.js → ipk-mamba-UJdZm2KK.js} +1 -1
- package/dist/ui/assets/{js-realm-worker-jCLcGISU.js → js-realm-worker-C3pS4nWP.js} +2 -2
- package/dist/ui/assets/{jsh-executor-eAgbPICA.js → jsh-executor-DJ08VhaN.js} +2 -2
- package/dist/ui/assets/{kernel-worker-BVn6NgIr.js → kernel-worker-CmBiahAZ.js} +10 -10
- package/dist/ui/assets/{lick-ws-bridge-5hziXRsb.js → lick-ws-bridge-DUBZZFMr.js} +1 -1
- package/dist/ui/assets/{lick-ws-bridge-CNWoPxh8.js → lick-ws-bridge-DfuaXcGI.js} +1 -1
- package/dist/ui/assets/{live-session-curation-6r5THRVc.js → live-session-curation-eYKAR5xE.js} +1 -1
- package/dist/ui/assets/{live-session-snapshot-XuA7hS3R.js → live-session-snapshot-D5Sooner.js} +1 -1
- package/dist/ui/assets/{local-llm-JneFYPSJ.js → local-llm-BIp2HhiA.js} +1 -1
- package/dist/ui/assets/{local-llm-BIToWY5w.js → local-llm-Csax_zi_.js} +1 -1
- package/dist/ui/assets/{main-B0thDo_I.js → main-8USr6q37.js} +3 -3
- package/dist/ui/assets/{main-cherry-i42Stq_t.js → main-cherry-CmbogfhO.js} +1 -1
- package/dist/ui/assets/{memory-curation-seam-jPN-pjNv.js → memory-curation-seam-i2jIitmU.js} +1 -1
- package/dist/ui/assets/{memory-health-D9MwFVu8.js → memory-health-CAJ3GwFC.js} +1 -1
- package/dist/ui/assets/{memory-write-execute-DxJVccvs.js → memory-write-execute-8BwvKQHC.js} +1 -1
- package/dist/ui/assets/{merge-folded-cost-into-frozen-BOnFPZYR.js → merge-folded-cost-into-frozen-DCwSAakf.js} +1 -1
- package/dist/ui/assets/{mount-D9DpIM-H.js → mount-CSNiw0gw.js} +1 -1
- package/dist/ui/assets/{mount-7auALEdt.js → mount-CaZBT6Qv.js} +3 -3
- package/dist/ui/assets/{new-session-dV2C39fB.js → new-session-oP5qFRj5.js} +2 -2
- package/dist/ui/assets/{oauth-bootstrap-MsvroWIf.js → oauth-bootstrap-DywNUo8g.js} +2 -2
- package/dist/ui/assets/{onboarding-orchestrator-BsyNlEp6.js → onboarding-orchestrator-s94oEY8i.js} +1 -1
- package/dist/ui/assets/{openai-codex-D6aLn4wD.js → openai-codex-CsbcxAwK.js} +1 -1
- package/dist/ui/assets/{openai-codex-QMojLG84.js → openai-codex-Izb1oUMi.js} +1 -1
- package/dist/ui/assets/{openrouter-DeSZmyWQ.js → openrouter-CMhrvGEI.js} +1 -1
- package/dist/ui/assets/{openrouter-LDOkDdfN.js → openrouter-CuxKI9sw.js} +1 -1
- package/dist/ui/assets/{openrouter-free-BDD5HUZF.js → openrouter-free-AYsgMf78.js} +1 -1
- package/dist/ui/assets/{openrouter-free-AToAyfMH.js → openrouter-free-DN-d1p7u.js} +1 -1
- package/dist/ui/assets/{openrouter-oauth-DqxRskZC.js → openrouter-oauth-Bj_L5M3b.js} +1 -1
- package/dist/ui/assets/{openrouter-oauth-CztvqBA0.js → openrouter-oauth-BtOSulAG.js} +1 -1
- package/dist/ui/assets/{opfs-mount-DP4EQVf_.js → opfs-mount-CnfXosX_.js} +1 -1
- package/dist/ui/assets/{panel-rpc-handlers-W71VzlDM.js → panel-rpc-handlers-txfCPZNY.js} +2 -2
- package/dist/ui/assets/{panelize-shell-9j9B_80g.js → panelize-shell-jKLhcD44.js} +1 -1
- package/dist/ui/assets/{pi-edit-execution-BShsB4bj.js → pi-edit-execution-DH85YBq5.js} +1 -1
- package/dist/ui/assets/{process-worker-Bm14-oXj.js → process-worker-7-U7pJ31.js} +2 -2
- package/dist/ui/assets/{provider-CE1zpBVX.js → provider-CiPG2QqU.js} +1 -1
- package/dist/ui/assets/{provider-Ca9Zz8yb.js → provider-DU5qXtgs.js} +2 -2
- package/dist/ui/assets/{provider-settings-uiENuCqB.js → provider-settings-CYtZYE0m.js} +1 -1
- package/dist/ui/assets/provider-store-access-05KdIOnd.js +1 -0
- package/dist/ui/assets/provider-store-access-Dnk3gXiV.js +1 -0
- package/dist/ui/assets/{providers-bam7z0UT.js → providers-3Vh9AkCt.js} +1 -1
- package/dist/ui/assets/{providers-DCmI83QO.js → providers-D-gHhkUb.js} +2 -2
- package/dist/ui/assets/{quick-llm-CzXagx_t.js → quick-llm-DZblyqJ_.js} +1 -1
- package/dist/ui/assets/{realm-inprocess-sTQMTEkB.js → realm-inprocess-xfgVdnu2.js} +2 -2
- package/dist/ui/assets/{realm-unhandled-rejections-BXaHCNJa.js → realm-unhandled-rejections-8FfA1Gxn.js} +1 -1
- package/dist/ui/assets/{realm-unhandled-rejections-DDmLwwJS.js → realm-unhandled-rejections-DYtt6P4B.js} +1 -1
- package/dist/ui/assets/{recovery-screen-BKbUhrGB.js → recovery-screen-07Mn3nGq.js} +1 -1
- package/dist/ui/assets/{remote-terminal-view-BLwdw7dM.js → remote-terminal-view-qKI_Uk-3.js} +2 -2
- package/dist/ui/assets/{restore-o9YtsuVz.js → restore-Wbg4rqS8.js} +1 -1
- package/dist/ui/assets/{run-DSre5ukc.js → run-BqyPtei-.js} +2 -2
- package/dist/ui/assets/{run-CilACXgz.js → run-CLjtjzEy.js} +2 -2
- package/dist/ui/assets/{run-medvCK_6.js → run-D6J4u7Dw.js} +1 -1
- package/dist/ui/assets/run-DYdVr3s9.js +17 -0
- package/dist/ui/assets/{run-BUej2chT.js → run-DqJvJNya.js} +1 -1
- package/dist/ui/assets/{run-BFNiHcEW.js → run-MUMHxwWH.js} +1 -1
- package/dist/ui/assets/{run-Bh8htYg7.js → run-vaI9AZHT.js} +1 -1
- package/dist/ui/assets/{script-catalog-1QnOA1GQ.js → script-catalog-DE0NMRm5.js} +1 -1
- package/dist/ui/assets/{session-command-memory-CK-bjU-i.js → session-command-memory-2oP0GfW4.js} +2 -2
- package/dist/ui/assets/{session-jsonl-BHcQKeee.js → session-jsonl-CAjcgY95.js} +1 -1
- package/dist/ui/assets/{session-jsonl-B6O31EYv.js → session-jsonl-D_aKJXyR.js} +1 -1
- package/dist/ui/assets/{session-search-index-Ddwbbkut.js → session-search-index-BnZt5Q3i.js} +1 -1
- package/dist/ui/assets/{setup-feature-flags-remote-DHIyA7Ql.js → setup-feature-flags-remote-CVKiJ3Dt.js} +1 -1
- package/dist/ui/assets/{setup-model-catalog-DtyllODF.js → setup-model-catalog-CDVDbpgE.js} +1 -1
- package/dist/ui/assets/{signed-fetch-DFBopENg.js → signed-fetch-xwKpuY0p.js} +1 -1
- package/dist/ui/assets/{silent-renew-backoff-BL8wMKQc.js → silent-renew-backoff-aQDTrjJz.js} +1 -1
- package/dist/ui/assets/slicc-version-C_dEkbAr.js +1 -0
- package/dist/ui/assets/{snapshot-CsXWOCBJ.js → snapshot-9ScYN3qc.js} +1 -1
- package/dist/ui/assets/{snapshot-features-BPgaCNDl.js → snapshot-features-BPVDwE7j.js} +1 -1
- package/dist/ui/assets/{soundscape-C7FEDgkP.js → soundscape-BMSIxpf9.js} +1 -1
- package/dist/ui/assets/{speak-tkO5HiC2.js → speak-CZpoPzFy.js} +1 -1
- package/dist/ui/assets/{sprinkle-manager-BlbSbFUW.js → sprinkle-manager-CtJTUHgd.js} +1 -1
- package/dist/ui/assets/{sprinkle-renderer-DuZBBlID.js → sprinkle-renderer-BHhs9N3d.js} +1 -1
- package/dist/ui/assets/{state-l6lHl-l7.js → state-e2oZ6Uk0.js} +1 -1
- package/dist/ui/assets/{stdio-tty-DNcYk275.js → stdio-tty-BtHlICFx.js} +1 -1
- package/dist/ui/assets/{store-CkDykWVq.js → store-98kKUKyW.js} +1 -1
- package/dist/ui/assets/{store-aGHgfLPM.js → store-Cln3HWXL.js} +1 -1
- package/dist/ui/assets/{sudo-NxhV_dIm.js → sudo-BMKSeLdQ.js} +1 -1
- package/dist/ui/assets/{supervisor-BRrTWhmg.js → supervisor-DkcJwuTP.js} +1 -1
- package/dist/ui/assets/{sync-dialog-CJG4icPz.js → sync-dialog-DWXFfvJ0.js} +1 -1
- package/dist/ui/assets/{transformers-env-DwuHApPS.js → transformers-env-DnBVlojJ.js} +1 -1
- package/dist/ui/assets/{tray-leader-BhwzHsW4.js → tray-leader-6JyRjLk0.js} +1 -1
- package/dist/ui/assets/{tray-leave-runtime-DzJgtJD5.js → tray-leave-runtime-Csg3aRUD.js} +1 -1
- package/dist/ui/assets/{tray-sidecar-B0VqIheG.js → tray-sidecar-DJyUo816.js} +1 -1
- package/dist/ui/assets/{upgrade-detection-0h2MYFF0.js → upgrade-detection-h9mE8Ptk.js} +1 -1
- package/dist/ui/assets/{upskill-lick-skip-BCj_PLi0.js → upskill-lick-skip-CN91n2bj.js} +1 -1
- package/dist/ui/assets/{voice-reply-C5gcSbT4.js → voice-reply-C8ecYofJ.js} +1 -1
- package/dist/ui/assets/wasi-runtime-2IxB3dc0.js +1 -0
- package/dist/ui/assets/wasm-programs-C7jo07yv.js +1 -0
- package/dist/ui/assets/{wc-attach-DnwMWit4.js → wc-attach-WGYvrgeT.js} +2 -2
- package/dist/ui/assets/{wc-browser-BQC_7cG7.js → wc-browser-DbbvyoTT.js} +1 -1
- package/dist/ui/assets/{wc-computers-CecKLajY.js → wc-computers-CXuo01dJ.js} +1 -1
- package/dist/ui/assets/{wc-detached-DeqWd0nW.js → wc-detached-C-JbZAhi.js} +1 -1
- package/dist/ui/assets/{wc-extension-B3Jqz0iE.js → wc-extension-BmNmrGiQ.js} +2 -2
- package/dist/ui/assets/{wc-follower-CONbTzRc.js → wc-follower-BSGRMfbg.js} +3 -3
- package/dist/ui/assets/{wc-follower-oauth-B_EiiAvr.js → wc-follower-oauth-BTgKLLqf.js} +1 -1
- package/dist/ui/assets/{wc-gelatiere-Dsw0YMCT.js → wc-gelatiere-BILpTJsl.js} +1 -1
- package/dist/ui/assets/{wc-live-BgzKz_k0.js → wc-live-Cl_0tOQ-.js} +5 -5
- package/dist/ui/assets/{wc-nav-DyWKt3_Y.js → wc-nav-DLBMXPAF.js} +2 -2
- package/dist/ui/assets/{wc-onboarding-CKWhBBSy.js → wc-onboarding-CC4I43ZL.js} +2 -2
- package/dist/ui/assets/{wc-permissions-pLNhbxI6.js → wc-permissions-BQMxdSLj.js} +2 -2
- package/dist/ui/assets/{wc-placeholder-CmAWVzs3.js → wc-placeholder-BWUSBXo3.js} +3 -3
- package/dist/ui/assets/{wc-secret-request-D_GiKx5L.js → wc-secret-request-DEP2cfjm.js} +1 -1
- package/dist/ui/assets/{wc-settings-iRSoSmMz.js → wc-settings-C3CIZZw-.js} +3 -3
- package/dist/ui/assets/{wc-shell-B0PhY3hq.js → wc-shell-BJTnAxDb.js} +3 -3
- package/dist/ui/assets/{wc-shortcut-config-DvRLapnh.js → wc-shortcut-config-BWOMjx1B.js} +1 -1
- package/dist/ui/assets/{wc-sprinkles-BEPQPFKR.js → wc-sprinkles-3R7yEaKB.js} +2 -2
- package/dist/ui/assets/{wc-transcript-export-BCmTsnHP.js → wc-transcript-export-Ce2jKH_F.js} +2 -2
- package/dist/ui/assets/{wc-tray-BRdwlPkC.js → wc-tray-CYYxNUcK.js} +4 -4
- package/dist/ui/assets/welcome-detection-BiAdqlNi.js +1 -0
- package/dist/ui/assets/{whisper-session-BPJbM4fv.js → whisper-session-B60X5T1B.js} +2 -2
- package/dist/ui/assets/{xai-grok-mxLxouZL.js → xai-grok-9zAL3G19.js} +1 -1
- package/dist/ui/assets/{xai-grok-fAOHWGfl.js → xai-grok-aVv0829R.js} +1 -1
- package/dist/ui/index.html +3 -3
- package/dist/ui/packages/webapp/index.html +3 -3
- package/package.json +1 -1
- package/dist/ui/assets/SKILL-Byz4bBkH.js +0 -1
- package/dist/ui/assets/provider-store-access-D0H9f5vw.js +0 -1
- package/dist/ui/assets/provider-store-access-qw-70nQO.js +0 -1
- package/dist/ui/assets/run-Bk9OlZwF.js +0 -17
- package/dist/ui/assets/slicc-version-eQ6JEYYJ.js +0 -1
- package/dist/ui/assets/wasm-programs-CsoF9Lrt.js +0 -1
- package/dist/ui/assets/welcome-detection-C_huX4jr.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t as e}from"./base64-BPBW1Gzr.js";import{m as t}from"./state-l6lHl-l7.js";import{t as n}from"./realm-browser-fetch-V3uggGbM.js";const r=new TextEncoder;function i(e){return typeof e==`object`&&!!e&&`exitCode`in e}async function a(e,t){try{return await e.fs.readFileBuffer(e.fs.resolvePath(e.cwd,t))}catch{return{message:`curlwright: cannot read ${t}`,exitCode:26}}}function o(e){let t=new Uint8Array(e.length),n=0;for(let r of e)r!==10&&r!==13&&(t[n++]=r);return t.subarray(0,n)}async function s(e,t){let n=t.indexOf(`=`),o=t.indexOf(`@`),s=o!==-1&&(n===-1||o<n),c=s?o:n,l=c===-1?``:t.slice(0,c),u=c===-1?t:t.slice(c+1),d=u;if(s){let t=await a(e,u);if(i(t))return t;d=new TextDecoder().decode(t)}let f=encodeURIComponent(d);return r.encode(l===``?f:`${l}=${f}`)}async function c(e,t){if(t.kind===`urlencode`)return s(e,t.value);if(t.kind===`raw`||!t.value.startsWith(`@`))return r.encode(t.value);let n=await a(e,t.value.slice(1));return i(n)||t.kind===`binary`?n:o(n)}function l(e){let t=Math.max(0,e.length-1),n=e.reduce((e,t)=>e+t.length,0)+t,r=new Uint8Array(n),i=0;return e.forEach((e,t)=>{t>0&&(r[i++]=38),r.set(e,i),i+=e.length}),r}function u(e){let t=e.split(`;`);return{value:t[0],options:t.slice(1)}}function d(e,t){for(let n of e){let e=n.trim();if(e.startsWith(`${t}=`))return e.slice(t.length+1)}return null}function f(e){let t=e.replace(/\/+$/,``),n=t.lastIndexOf(`/`);return n===-1?t:t.slice(n+1)}async function p(e,t,n){let r=n.value.indexOf(`=`);if(r===-1)return{message:`curlwright: -F requires name=content (got "${n.value}")`,exitCode:2};let o=n.value.slice(0,r),s=n.value.slice(r+1);if(n.literal||s[0]!==`@`&&s[0]!==`<`)return t.append(o,s),null;let{value:c,options:l}=u(s.slice(1)),p=await a(e,c);if(i(p))return p;if(s[0]===`<`)return t.append(o,new TextDecoder().decode(p)),null;let m=d(l,`type`)??`application/octet-stream`,h=d(l,`filename`)??f(c);return t.append(o,new Blob([p],{type:m}),h),null}async function m(e,t,n){if(t.length>0&&n.length>0)return{message:`curlwright: -F cannot be combined with -d`,exitCode:2};if(n.length>0){let t=new FormData;for(let r of n){let n=await p(e,t,r);if(n)return n}return{bytes:null,form:t,contentType:null,accept:null}}if(t.length===0)return{bytes:null,form:null,contentType:null,accept:null};let r=[];for(let n of t){let t=await c(e,n);if(i(t))return t;r.push(t)}let a=t.some(e=>e.kind===`json`);return{bytes:l(r),form:null,contentType:a?`application/json`:`application/x-www-form-urlencoded`,accept:a?`application/json`:null}}const h=new Set([`request`,`header`,`data`,`data-raw`,`data-binary`,`data-ascii`,`data-urlencode`,`json`,`form`,`form-string`,`output`,`dump-header`,`write-out`,`max-time`,`user`,`referer`,`range`,`url`,`tab`,`frame`]),g=new Set([`silent`,`show-error`,`include`,`head`,`verbose`,`fail`,`location`,`remote-name`,`get`,`no-credentials`,`help`]),_={X:`request`,H:`header`,d:`data`,F:`form`,o:`output`,D:`dump-header`,w:`write-out`,m:`max-time`,u:`user`,e:`referer`,r:`range`},v={s:`silent`,S:`show-error`,i:`include`,I:`head`,v:`verbose`,f:`fail`,L:`location`,O:`remote-name`,G:`get`,h:`help`},y={cert:`client certificates are the browser profile's to present, not the shell's`,"cert-type":`client certificates are the browser profile's to present, not the shell's`,key:`client certificates are the browser profile's to present, not the shell's`,cacert:`the browser decides which roots to trust`,capath:`the browser decides which roots to trust`,insecure:`the browser enforces TLS verification; a page cannot opt out`,proxy:`proxying is configured on the browser, not per request`,"proxy-user":`proxying is configured on the browser, not per request`,interface:`a page cannot choose an outgoing interface`,"unix-socket":`a page cannot dial a unix socket`,resolve:`a page cannot override DNS resolution`,compressed:`always on — the browser negotiates encoding itself`,cookie:"the tab's own cookies are already sent; set one with `playwright-cli cookie-set`","cookie-jar":"cookies live in the browser profile; read them with `playwright-cli cookies`","limit-rate":`a page cannot throttle a fetch`,"continue-at":"a page fetch cannot resume; use `-H 'Range: bytes=N-'`","connect-timeout":"a page fetch cannot time the connect phase alone; use `--max-time`","http1.1":`the browser negotiates the HTTP version`,http2:`the browser negotiates the HTTP version`,http3:`the browser negotiates the HTTP version`,"no-buffer":`responses are read whole, never streamed to stdout`,"trace-ascii":"no wire trace exists; use `playwright-cli network-requests`",trace:"no wire trace exists; use `playwright-cli network-requests`","user-agent":`User-Agent is a forbidden header name for fetch(); the tab sets it`},b={k:`insecure`,x:`proxy`,b:`cookie`,c:`cookie-jar`,E:`cert`,C:`continue-at`,N:`no-buffer`,A:`user-agent`};function ee(){return{url:null,requestMethod:null,headers:[],data:[],form:[],get:!1,output:null,remoteName:!1,include:!1,head:!1,dumpHeader:null,writeOut:null,silent:!1,showError:!1,verbose:!1,failOnError:!1,maxTimeSeconds:null,credentials:`include`,tab:null,frame:null,user:null,referer:null,range:null,help:!1}}function x(e,t){return{message:`curlwright: option ${e} is not supported in a page context — ${y[t]}`,exitCode:2}}function S(e){return{message:`curlwright: unknown option ${e}\nRun 'curlwright --help' for the supported flags.`,exitCode:2}}function C(e){let t=e.indexOf(`:`);if(t===-1)return e.endsWith(`;`)?{name:e.slice(0,-1).trim(),value:``,unset:!1}:{name:e.trim(),value:``,unset:!1};let n=e.slice(0,t).trim(),r=e.slice(t+1).trim();return{name:n,value:r,unset:r===``}}function w(e,t,n,r){switch(t){case`request`:return e.requestMethod=n,null;case`header`:return e.headers.push(C(n??``)),null;case`data`:case`data-ascii`:return e.data.push({kind:`ascii`,value:n??``}),null;case`data-raw`:return e.data.push({kind:`raw`,value:n??``}),null;case`data-binary`:return e.data.push({kind:`binary`,value:n??``}),null;case`data-urlencode`:return e.data.push({kind:`urlencode`,value:n??``}),null;case`json`:return e.data.push({kind:`json`,value:n??``}),null;case`form`:return e.form.push({value:n??``,literal:!1}),null;case`form-string`:return e.form.push({value:n??``,literal:!0}),null;case`output`:return e.output=n,null;case`dump-header`:return e.dumpHeader=n,null;case`write-out`:return e.writeOut=n,null;case`max-time`:return T(e,n,r);case`user`:return e.user=n,null;case`referer`:return e.referer=n,null;case`range`:return e.range=n,null;case`url`:return e.url=n,null;case`tab`:return e.tab=n,null;case`frame`:return e.frame=n,null;default:return E(e,t,r)}}function T(e,t,n){let r=Number(t);return!Number.isFinite(r)||r<=0?{message:`curlwright: ${n} expects a positive number of seconds`,exitCode:2}:(e.maxTimeSeconds=r,null)}function E(e,t,n){switch(t){case`silent`:return e.silent=!0,null;case`show-error`:return e.showError=!0,null;case`include`:return e.include=!0,null;case`head`:return e.head=!0,null;case`verbose`:return e.verbose=!0,null;case`fail`:return e.failOnError=!0,null;case`location`:return null;case`remote-name`:return e.remoteName=!0,null;case`get`:return e.get=!0,null;case`no-credentials`:return e.credentials=`omit`,null;case`help`:return e.help=!0,null;default:return S(n)}}function te(e,t,n){let r=t[n],i=r.indexOf(`=`),a=(i===-1?r.slice(2):r.slice(2,i)).trim(),o=i===-1?null:r.slice(i+1);if(a in y)return x(`--${a}`,a);if(h.has(a)){let r=o??t[n+1];return r===void 0?{message:`curlwright: option --${a} requires a value`,exitCode:2}:w(e,a,r,`--${a}`)??{next:o===null?n+2:n+1}}return g.has(a)?w(e,a,null,`--${a}`)??{next:n+1}:S(`--${a}`)}function ne(e,t,n){let r=t[n];for(let i=1;i<r.length;i++){let a=r[i];if(a in b)return x(`-${a}`,b[a]);if(a in _){let o=r.slice(i+1),s=o===``?t[n+1]:o;return s===void 0?{message:`curlwright: option -${a} requires a value`,exitCode:2}:w(e,_[a],s,`-${a}`)??{next:o===``?n+2:n+1}}if(!(a in v))return S(`-${a}`);let o=w(e,v[a],null,`-${a}`);if(o)return o}return{next:n+1}}function re(e,t){return e.url!==null&&e.url!==t?{message:`curlwright: only one URL is supported (got "${e.url}" and "${t}")`,exitCode:2}:(e.url=t,null)}function ie(e){let t=ee(),n=0,r=!1;for(;n<e.length;){let i=e[n];if(!r&&i===`--`){r=!0,n++;continue}if(!r&&i.startsWith(`--`)){let r=te(t,e,n);if(`message`in r)return r;n=r.next;continue}if(!r&&i.startsWith(`-`)&&i.length>1){let r=ne(t,e,n);if(`message`in r)return r;n=r.next;continue}let a=re(t,i);if(a)return a;n++}return t}function ae(e){return`message`in e}const D={"accept-charset":`the browser sets it`,"accept-encoding":`the browser negotiates encoding`,connection:`the browser owns the connection`,"content-length":`derived from the body`,cookie:"the tab's cookies are sent already; set one with `playwright-cli cookie-set`",cookie2:`the tab's cookies are sent already`,date:`the browser sets it`,dnt:`the browser sets it`,expect:`a page fetch cannot send it`,host:`derived from the URL`,"keep-alive":`the browser owns the connection`,origin:`the tab's own origin is sent automatically`,referer:`use -e/--referer, which sets the fetch referrer`,te:`the browser owns transfer encoding`,trailer:`the browser owns transfer encoding`,"transfer-encoding":`the browser owns transfer encoding`,upgrade:`the browser owns the connection`,via:`the browser sets it`};function oe(e){let t=e.toLowerCase();return t in D?D[t]:t.startsWith(`proxy-`)?`proxying is configured on the browser`:t.startsWith(`sec-`)?`Sec- headers are reserved for the browser`:null}function se(e){for(let t of e){let e=oe(t.name);if(e)return{message:`curlwright: header "${t.name}" cannot be set from a page — ${e}`,exitCode:2}}return null}function O(e,t){let n=t.toLowerCase();return Object.keys(e).some(e=>e.toLowerCase()===n)}function k(e){let t={},n=new Set;for(let r of e.headers)if(r.name!==``){if(r.unset){n.add(r.name.toLowerCase());continue}t[r.name]=r.value}return{headers:t,suppressed:n}}function A(e,t,n){return!O(e,n)&&!t.has(n)}function j(e){return/^[a-zA-Z]+=/.test(e)?e:`bytes=${e}`}function M(e,t,n,r){n.user!==null&&A(e,t,`authorization`)&&(e.Authorization=`Basic ${btoa(n.user)}`),n.range!==null&&A(e,t,`range`)&&(e.Range=j(n.range)),r.contentType&&A(e,t,`content-type`)&&(e[`Content-Type`]=r.contentType),r.accept&&A(e,t,`accept`)&&(e.Accept=r.accept)}function N(e,t){if(t===``)return e;let[n,r]=P(e);return`${n}${n.includes(`?`)?`&`:`?`}${t}${r}`}function P(e){let t=e.indexOf(`#`);return t===-1?[e,``]:[e.slice(0,t),e.slice(t)]}function F(e,t){return e.requestMethod?e.requestMethod:e.head?`HEAD`:t?`POST`:`GET`}function I(e,t,n){let r=e.toUpperCase();return!t||r!==`GET`&&r!==`HEAD`?null:{message:`curlwright: ${n.requestMethod?`-X ${n.requestMethod}`:`-I`} cannot carry a request body — a page fetch rejects a ${r} with one. Drop the data, or use -G to send it as a query string.`,exitCode:2}}function L(e,t){if(e.url===null)return{message:`curlwright: no URL specified`,exitCode:2};let{headers:n,suppressed:r}=k(e),i=e.get&&t.bytes!==null,a=i?{...t,bytes:null,contentType:null}:t;M(n,r,e,a);let o=i?N(e.url,new TextDecoder().decode(t.bytes??new Uint8Array)):e.url,s=a.bytes!==null||a.form!==null,c=F(e,s),l=I(c,s,e);if(l)return l;let u={method:c,headers:n,credentials:e.credentials,responseType:`binary`};return a.form?u.body=a.form:a.bytes&&(u.body=a.bytes),e.referer!==null&&(u.referrer=e.referer),e.maxTimeSeconds!==null&&(u.timeoutMs=e.maxTimeSeconds*1e3),{url:o,method:c,fetchOptions:u,uploadSize:a.bytes?.length??0}}function R(e){let t=e.fetchOptions.headers??{},n=[`> ${e.method} ${e.url}`];for(let[e,r]of Object.entries(t))n.push(`> ${e}: ${r}`);return n.push(`> `),`${n.join(`
|
|
1
|
+
import{t as e}from"./base64-BPBW1Gzr.js";import{m as t}from"./state-e2oZ6Uk0.js";import{t as n}from"./realm-browser-fetch-V3uggGbM.js";const r=new TextEncoder;function i(e){return typeof e==`object`&&!!e&&`exitCode`in e}async function a(e,t){try{return await e.fs.readFileBuffer(e.fs.resolvePath(e.cwd,t))}catch{return{message:`curlwright: cannot read ${t}`,exitCode:26}}}function o(e){let t=new Uint8Array(e.length),n=0;for(let r of e)r!==10&&r!==13&&(t[n++]=r);return t.subarray(0,n)}async function s(e,t){let n=t.indexOf(`=`),o=t.indexOf(`@`),s=o!==-1&&(n===-1||o<n),c=s?o:n,l=c===-1?``:t.slice(0,c),u=c===-1?t:t.slice(c+1),d=u;if(s){let t=await a(e,u);if(i(t))return t;d=new TextDecoder().decode(t)}let f=encodeURIComponent(d);return r.encode(l===``?f:`${l}=${f}`)}async function c(e,t){if(t.kind===`urlencode`)return s(e,t.value);if(t.kind===`raw`||!t.value.startsWith(`@`))return r.encode(t.value);let n=await a(e,t.value.slice(1));return i(n)||t.kind===`binary`?n:o(n)}function l(e){let t=Math.max(0,e.length-1),n=e.reduce((e,t)=>e+t.length,0)+t,r=new Uint8Array(n),i=0;return e.forEach((e,t)=>{t>0&&(r[i++]=38),r.set(e,i),i+=e.length}),r}function u(e){let t=e.split(`;`);return{value:t[0],options:t.slice(1)}}function d(e,t){for(let n of e){let e=n.trim();if(e.startsWith(`${t}=`))return e.slice(t.length+1)}return null}function f(e){let t=e.replace(/\/+$/,``),n=t.lastIndexOf(`/`);return n===-1?t:t.slice(n+1)}async function p(e,t,n){let r=n.value.indexOf(`=`);if(r===-1)return{message:`curlwright: -F requires name=content (got "${n.value}")`,exitCode:2};let o=n.value.slice(0,r),s=n.value.slice(r+1);if(n.literal||s[0]!==`@`&&s[0]!==`<`)return t.append(o,s),null;let{value:c,options:l}=u(s.slice(1)),p=await a(e,c);if(i(p))return p;if(s[0]===`<`)return t.append(o,new TextDecoder().decode(p)),null;let m=d(l,`type`)??`application/octet-stream`,h=d(l,`filename`)??f(c);return t.append(o,new Blob([p],{type:m}),h),null}async function m(e,t,n){if(t.length>0&&n.length>0)return{message:`curlwright: -F cannot be combined with -d`,exitCode:2};if(n.length>0){let t=new FormData;for(let r of n){let n=await p(e,t,r);if(n)return n}return{bytes:null,form:t,contentType:null,accept:null}}if(t.length===0)return{bytes:null,form:null,contentType:null,accept:null};let r=[];for(let n of t){let t=await c(e,n);if(i(t))return t;r.push(t)}let a=t.some(e=>e.kind===`json`);return{bytes:l(r),form:null,contentType:a?`application/json`:`application/x-www-form-urlencoded`,accept:a?`application/json`:null}}const h=new Set([`request`,`header`,`data`,`data-raw`,`data-binary`,`data-ascii`,`data-urlencode`,`json`,`form`,`form-string`,`output`,`dump-header`,`write-out`,`max-time`,`user`,`referer`,`range`,`url`,`tab`,`frame`]),g=new Set([`silent`,`show-error`,`include`,`head`,`verbose`,`fail`,`location`,`remote-name`,`get`,`no-credentials`,`help`]),_={X:`request`,H:`header`,d:`data`,F:`form`,o:`output`,D:`dump-header`,w:`write-out`,m:`max-time`,u:`user`,e:`referer`,r:`range`},v={s:`silent`,S:`show-error`,i:`include`,I:`head`,v:`verbose`,f:`fail`,L:`location`,O:`remote-name`,G:`get`,h:`help`},y={cert:`client certificates are the browser profile's to present, not the shell's`,"cert-type":`client certificates are the browser profile's to present, not the shell's`,key:`client certificates are the browser profile's to present, not the shell's`,cacert:`the browser decides which roots to trust`,capath:`the browser decides which roots to trust`,insecure:`the browser enforces TLS verification; a page cannot opt out`,proxy:`proxying is configured on the browser, not per request`,"proxy-user":`proxying is configured on the browser, not per request`,interface:`a page cannot choose an outgoing interface`,"unix-socket":`a page cannot dial a unix socket`,resolve:`a page cannot override DNS resolution`,compressed:`always on — the browser negotiates encoding itself`,cookie:"the tab's own cookies are already sent; set one with `playwright-cli cookie-set`","cookie-jar":"cookies live in the browser profile; read them with `playwright-cli cookies`","limit-rate":`a page cannot throttle a fetch`,"continue-at":"a page fetch cannot resume; use `-H 'Range: bytes=N-'`","connect-timeout":"a page fetch cannot time the connect phase alone; use `--max-time`","http1.1":`the browser negotiates the HTTP version`,http2:`the browser negotiates the HTTP version`,http3:`the browser negotiates the HTTP version`,"no-buffer":`responses are read whole, never streamed to stdout`,"trace-ascii":"no wire trace exists; use `playwright-cli network-requests`",trace:"no wire trace exists; use `playwright-cli network-requests`","user-agent":`User-Agent is a forbidden header name for fetch(); the tab sets it`},b={k:`insecure`,x:`proxy`,b:`cookie`,c:`cookie-jar`,E:`cert`,C:`continue-at`,N:`no-buffer`,A:`user-agent`};function ee(){return{url:null,requestMethod:null,headers:[],data:[],form:[],get:!1,output:null,remoteName:!1,include:!1,head:!1,dumpHeader:null,writeOut:null,silent:!1,showError:!1,verbose:!1,failOnError:!1,maxTimeSeconds:null,credentials:`include`,tab:null,frame:null,user:null,referer:null,range:null,help:!1}}function x(e,t){return{message:`curlwright: option ${e} is not supported in a page context — ${y[t]}`,exitCode:2}}function S(e){return{message:`curlwright: unknown option ${e}\nRun 'curlwright --help' for the supported flags.`,exitCode:2}}function C(e){let t=e.indexOf(`:`);if(t===-1)return e.endsWith(`;`)?{name:e.slice(0,-1).trim(),value:``,unset:!1}:{name:e.trim(),value:``,unset:!1};let n=e.slice(0,t).trim(),r=e.slice(t+1).trim();return{name:n,value:r,unset:r===``}}function w(e,t,n,r){switch(t){case`request`:return e.requestMethod=n,null;case`header`:return e.headers.push(C(n??``)),null;case`data`:case`data-ascii`:return e.data.push({kind:`ascii`,value:n??``}),null;case`data-raw`:return e.data.push({kind:`raw`,value:n??``}),null;case`data-binary`:return e.data.push({kind:`binary`,value:n??``}),null;case`data-urlencode`:return e.data.push({kind:`urlencode`,value:n??``}),null;case`json`:return e.data.push({kind:`json`,value:n??``}),null;case`form`:return e.form.push({value:n??``,literal:!1}),null;case`form-string`:return e.form.push({value:n??``,literal:!0}),null;case`output`:return e.output=n,null;case`dump-header`:return e.dumpHeader=n,null;case`write-out`:return e.writeOut=n,null;case`max-time`:return T(e,n,r);case`user`:return e.user=n,null;case`referer`:return e.referer=n,null;case`range`:return e.range=n,null;case`url`:return e.url=n,null;case`tab`:return e.tab=n,null;case`frame`:return e.frame=n,null;default:return E(e,t,r)}}function T(e,t,n){let r=Number(t);return!Number.isFinite(r)||r<=0?{message:`curlwright: ${n} expects a positive number of seconds`,exitCode:2}:(e.maxTimeSeconds=r,null)}function E(e,t,n){switch(t){case`silent`:return e.silent=!0,null;case`show-error`:return e.showError=!0,null;case`include`:return e.include=!0,null;case`head`:return e.head=!0,null;case`verbose`:return e.verbose=!0,null;case`fail`:return e.failOnError=!0,null;case`location`:return null;case`remote-name`:return e.remoteName=!0,null;case`get`:return e.get=!0,null;case`no-credentials`:return e.credentials=`omit`,null;case`help`:return e.help=!0,null;default:return S(n)}}function te(e,t,n){let r=t[n],i=r.indexOf(`=`),a=(i===-1?r.slice(2):r.slice(2,i)).trim(),o=i===-1?null:r.slice(i+1);if(a in y)return x(`--${a}`,a);if(h.has(a)){let r=o??t[n+1];return r===void 0?{message:`curlwright: option --${a} requires a value`,exitCode:2}:w(e,a,r,`--${a}`)??{next:o===null?n+2:n+1}}return g.has(a)?w(e,a,null,`--${a}`)??{next:n+1}:S(`--${a}`)}function ne(e,t,n){let r=t[n];for(let i=1;i<r.length;i++){let a=r[i];if(a in b)return x(`-${a}`,b[a]);if(a in _){let o=r.slice(i+1),s=o===``?t[n+1]:o;return s===void 0?{message:`curlwright: option -${a} requires a value`,exitCode:2}:w(e,_[a],s,`-${a}`)??{next:o===``?n+2:n+1}}if(!(a in v))return S(`-${a}`);let o=w(e,v[a],null,`-${a}`);if(o)return o}return{next:n+1}}function re(e,t){return e.url!==null&&e.url!==t?{message:`curlwright: only one URL is supported (got "${e.url}" and "${t}")`,exitCode:2}:(e.url=t,null)}function ie(e){let t=ee(),n=0,r=!1;for(;n<e.length;){let i=e[n];if(!r&&i===`--`){r=!0,n++;continue}if(!r&&i.startsWith(`--`)){let r=te(t,e,n);if(`message`in r)return r;n=r.next;continue}if(!r&&i.startsWith(`-`)&&i.length>1){let r=ne(t,e,n);if(`message`in r)return r;n=r.next;continue}let a=re(t,i);if(a)return a;n++}return t}function ae(e){return`message`in e}const D={"accept-charset":`the browser sets it`,"accept-encoding":`the browser negotiates encoding`,connection:`the browser owns the connection`,"content-length":`derived from the body`,cookie:"the tab's cookies are sent already; set one with `playwright-cli cookie-set`",cookie2:`the tab's cookies are sent already`,date:`the browser sets it`,dnt:`the browser sets it`,expect:`a page fetch cannot send it`,host:`derived from the URL`,"keep-alive":`the browser owns the connection`,origin:`the tab's own origin is sent automatically`,referer:`use -e/--referer, which sets the fetch referrer`,te:`the browser owns transfer encoding`,trailer:`the browser owns transfer encoding`,"transfer-encoding":`the browser owns transfer encoding`,upgrade:`the browser owns the connection`,via:`the browser sets it`};function oe(e){let t=e.toLowerCase();return t in D?D[t]:t.startsWith(`proxy-`)?`proxying is configured on the browser`:t.startsWith(`sec-`)?`Sec- headers are reserved for the browser`:null}function se(e){for(let t of e){let e=oe(t.name);if(e)return{message:`curlwright: header "${t.name}" cannot be set from a page — ${e}`,exitCode:2}}return null}function O(e,t){let n=t.toLowerCase();return Object.keys(e).some(e=>e.toLowerCase()===n)}function k(e){let t={},n=new Set;for(let r of e.headers)if(r.name!==``){if(r.unset){n.add(r.name.toLowerCase());continue}t[r.name]=r.value}return{headers:t,suppressed:n}}function A(e,t,n){return!O(e,n)&&!t.has(n)}function j(e){return/^[a-zA-Z]+=/.test(e)?e:`bytes=${e}`}function M(e,t,n,r){n.user!==null&&A(e,t,`authorization`)&&(e.Authorization=`Basic ${btoa(n.user)}`),n.range!==null&&A(e,t,`range`)&&(e.Range=j(n.range)),r.contentType&&A(e,t,`content-type`)&&(e[`Content-Type`]=r.contentType),r.accept&&A(e,t,`accept`)&&(e.Accept=r.accept)}function N(e,t){if(t===``)return e;let[n,r]=P(e);return`${n}${n.includes(`?`)?`&`:`?`}${t}${r}`}function P(e){let t=e.indexOf(`#`);return t===-1?[e,``]:[e.slice(0,t),e.slice(t)]}function F(e,t){return e.requestMethod?e.requestMethod:e.head?`HEAD`:t?`POST`:`GET`}function I(e,t,n){let r=e.toUpperCase();return!t||r!==`GET`&&r!==`HEAD`?null:{message:`curlwright: ${n.requestMethod?`-X ${n.requestMethod}`:`-I`} cannot carry a request body — a page fetch rejects a ${r} with one. Drop the data, or use -G to send it as a query string.`,exitCode:2}}function L(e,t){if(e.url===null)return{message:`curlwright: no URL specified`,exitCode:2};let{headers:n,suppressed:r}=k(e),i=e.get&&t.bytes!==null,a=i?{...t,bytes:null,contentType:null}:t;M(n,r,e,a);let o=i?N(e.url,new TextDecoder().decode(t.bytes??new Uint8Array)):e.url,s=a.bytes!==null||a.form!==null,c=F(e,s),l=I(c,s,e);if(l)return l;let u={method:c,headers:n,credentials:e.credentials,responseType:`binary`};return a.form?u.body=a.form:a.bytes&&(u.body=a.bytes),e.referer!==null&&(u.referrer=e.referer),e.maxTimeSeconds!==null&&(u.timeoutMs=e.maxTimeSeconds*1e3),{url:o,method:c,fetchOptions:u,uploadSize:a.bytes?.length??0}}function R(e){let t=e.fetchOptions.headers??{},n=[`> ${e.method} ${e.url}`];for(let[e,r]of Object.entries(t))n.push(`> ${e}: ${r}`);return n.push(`> `),`${n.join(`
|
|
2
2
|
`)}\n`}function z(e,t){let n=[`< ${e}`];for(let[e,r]of Object.entries(t))n.push(`< ${e}: ${r}`);return n.push(`< `),`${n.join(`
|
|
3
3
|
`)}\n`}function B(t,n){return typeof t==`string`?n===`base64`?e(t):new TextEncoder().encode(t):new Uint8Array}function V(e,t){return t?`HTTP/1.1 ${e} ${t}`:`HTTP/1.1 ${e}`}function H(e,t,n){let r=[V(e,t)];for(let[e,t]of Object.entries(n))r.push(`${e}: ${t}`);return`${r.join(`\r
|
|
4
4
|
`)}\r\n\r\n`}function U(e){if(e.includes(0))return!0;try{return new TextDecoder(`utf-8`,{fatal:!0}).decode(e),!1}catch{return!0}}function W(e){let t;try{t=new URL(e).pathname}catch{t=e.split(`?`)[0]}return t.replace(/\/+$/,``).split(`/`).pop()||null}function G(e,t,n){return new TextEncoder().encode(H(e,t,n)).length}function K(e){try{return new URL(e).origin}catch{return null}}function q(e){return e.map(e=>` --tab=${e.targetId} ${e.url}`).join(`
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import{t as e}from"./logger-LESFN7Hj.js";import{i as t,n,r,t as i}from"./proxied-fetch-CoZ8jHud.js";import{r as a}from"./proxy-error-BVzVNPvv.js";import{_ as o,a as s,c,d as l,f as u,h as d,l as f,m as p,n as m,o as h,p as g,s as _,t as ee,u as te}from"./stdio-tty-BtHlICFx.js";import{r as ne}from"./global-prefix-DqCuANmV.js";import{r as re}from"./wasm-programs-C7jo07yv.js";import{n as ie,t as ae}from"./wasm-compiler-Ct7QZURL.js";import{S as oe,w as se,x as ce}from"./sync-exec-dispatch-DvIKQEFv.js";import{t as le}from"./sync-sab-wire-D_d0fd3b.js";import{t as ue}from"./sync-sab-responder-CKgRMoHC.js";import{i as de}from"./just-bash-compat-B-SPHuh_.js";const fe=String.raw`printf '\033]7777;%s\007' "$?"`,pe=[`if [ -f ~/.bashrc ]; then . ~/.bashrc; fi`,`exec 98<&-`,``].join(`
|
|
2
|
+
`);var v=class extends Error{status;constructor(e,t){super(t),this.status=e}};const me=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,he={100:`Continue`,200:`OK`,400:`Bad Request`,403:`Forbidden`,408:`Request Timeout`,411:`Length Required`,413:`Content Too Large`,417:`Expectation Failed`,421:`Misdirected Request`,431:`Request Header Fields Too Large`,501:`Not Implemented`,502:`Bad Gateway`,503:`Service Unavailable`,505:`HTTP Version Not Supported`};var ge=class{source;buf=new Uint8Array;eof=!1;constructor(e){this.source=e}get buffered(){return this.buf.length}async fill(e){if(this.eof)return!1;let t=await this.source.read(65536,e);if(t.length===0)return this.eof=!0,!1;let n=new Uint8Array(this.buf.length+t.length);return n.set(this.buf),n.set(t,this.buf.length),this.buf=n,!0}take(e){let t=this.buf.slice(0,e);return this.buf=this.buf.subarray(e),t}async some(e,t){if(this.buf.length>0)return this.take(Math.min(e,this.buf.length));if(this.eof)return new Uint8Array;let n=await this.source.read(e,t);return n.length===0&&(this.eof=!0),n}async head(e,t){let n=0;for(;;){let r=_e(this.buf,n);if(r>0){if(r>e)throw new v(431,`request head too large`);return this.take(r)}if(this.buf.length>e)throw new v(431,`request head too large`);if(n=Math.max(0,this.buf.length-3),!await this.fill(t)){if(this.buf.length===0)return null;throw new v(400,`connection closed inside a request head`)}}}async line(e,t){let n=0;for(;;){let r=this.buf.indexOf(10,n);if(r>=0){let e=this.take(r+1);return ve(e.subarray(0,e[r-1]===13?r-1:r))}if(this.buf.length>e)throw new v(400,`line too long`);if(n=this.buf.length,!await this.fill(t))throw new v(400,`connection closed inside a body`)}}async exactly(e,t){for(;this.buf.length<e;)if(!await this.fill(t))throw new v(400,`connection closed inside a body`);return this.take(e)}};function _e(e,t){for(let n=t;n<e.length;n++)if(e[n]===10){if(e[n+1]===10)return n+2;if(e[n+1]===13&&e[n+2]===10)return n+3}return 0}function ve(e){let t=``;for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return t}function y(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return t}function ye(e){let t=ve(e).split(/\r?\n/);for(;t.length>0&&t[0]===``;)t.shift();let n=/^([!#$%&'*+\-.^_`|~0-9A-Za-z]+) (\S+) HTTP\/(\d)\.(\d)$/.exec(t.shift()??``);if(!n)throw new v(400,`malformed request line`);if(n[3]!==`1`)throw new v(505,`HTTP/${n[3]}.${n[4]} is not supported`);return{method:n[1],target:n[2],minor:Number(n[4]),headers:be(t)}}function be(e){let t=[];for(let n of e){if(n===``)continue;if(n.startsWith(` `)||n.startsWith(` `))throw new v(400,`obsolete line folding`);let e=n.indexOf(`:`),r=e>0?n.slice(0,e):``;if(!me.test(r))throw new v(400,`malformed header field`);t.push([r,n.slice(e+1).trim()])}return t}function b(e,t){let n=t.toLowerCase();return e.filter(([e])=>e.toLowerCase()===n).map(([,e])=>e)}function x(e,t){return b(e,t).flatMap(e=>e.split(`,`)).map(e=>e.trim().toLowerCase()).filter(e=>e!==``)}function xe(e){let t=x(e,`transfer-encoding`),n=b(e,`content-length`);if(t.length>0){if(n.length>0)throw new v(400,`both Transfer-Encoding and Content-Length`);if(t.length!==1||t[0]!==`chunked`)throw new v(501,`unsupported Transfer-Encoding: ${t.join(`, `)}`);return{kind:`chunked`}}if(n.length===0)return{kind:`none`};let r=new Set(n.flatMap(e=>e.split(`,`)).map(e=>e.trim())),[i]=r;if(r.size!==1||!/^\d{1,15}$/.test(i))throw new v(400,`invalid Content-Length`);let a=Number(i);return a===0?{kind:`none`}:{kind:`length`,length:a}}const S=65536;async function Se(e,t,n,r){if(t.kind===`none`)return;if(t.kind===`length`){if(t.length>n)throw new v(413,`request body over ${n} bytes`);return e.exactly(t.length,r)}let i=[],a=0;for(;;){let t=await e.line(4096,r),o=/^([0-9A-Fa-f]{1,12})[ \t]*(;.*)?$/.exec(t);if(!o)throw new v(400,`malformed chunk size`);let s=Number.parseInt(o[1],16);if(s===0)break;if(a+=s,a>n)throw new v(413,`request body over ${n} bytes`);if(i.push(await e.exactly(s,r)),await e.line(2,r)!==``)throw new v(400,`malformed chunk`)}let o=0;for(let t=await e.line(S,r);t!==``;){if(o+=t.length,o>S)throw new v(431,`trailers too large`);t=await e.line(S,r)}return Ce(i,a)}function Ce(e,t=e.reduce((e,t)=>e+t.length,0)){let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}function we(e){return!/[\r\n\0]/.test(e)}function Te(e,t,n){let r=`HTTP/1.1 ${e} ${/^[\t\x20-\x7e\x80-\xff]*$/.test(t)?t:``}\r\n`;for(let[e,t]of n)me.test(e)&&we(t)&&(r+=`${e}: ${t}\r\n`);return y(`${r}\r\n`)}function Ee(e){let t=y(`${e.length.toString(16)}\r\n`),n=new Uint8Array(t.length+e.length+2);return n.set(t),n.set(e,t.length),n[n.length-2]=13,n[n.length-1]=10,n}const De=y(`0\r
|
|
3
|
+
\r
|
|
4
|
+
`),Oe=e(`realm-proxy`),ke=3128,Ae={maxConnections:64,maxHead:65536,idleMs:12e4,bodyBudget:134217728},je=new Set([`connection`,`keep-alive`,`proxy-connection`,`proxy-authenticate`,`proxy-authorization`,`te`,`trailer`,`transfer-encoding`,`upgrade`]),Me=new Set([`host`,`content-length`,`expect`]);var C=class{free;waiters=[];constructor(e){this.free=e}async acquire(e,t){for(;this.free<e;)t.throwIfAborted(),await new Promise(e=>{let n=()=>{t.removeEventListener(`abort`,n),e()};this.waiters.push(n),t.addEventListener(`abort`,n,{once:!0})});this.free-=e}release(e){this.free+=e;let t=this.waiters;this.waiters=[];for(let e of t)e()}};function w(e){let t=e.includes(`:`)&&!e.startsWith(`[`)?`[${e}]`:e;try{return new URL(`http://${t}/`).hostname}catch{return}}function Ne(e,t){return e===127||e===0||e===169&&t===254}function Pe(e){let[t,n,r]=e.split(`::`);if(r!==void 0)return;let i=e=>e?e.split(`:`).map(e=>Number.parseInt(e,16)):[],a=i(t),o=i(n),s=n===void 0?a:[...a,...Array(8-a.length-o.length).fill(0),...o];return s.length===8&&s.every(e=>e>=0&&e<=65535)?s:void 0}function Fe(e){let t=Pe(e);return!t||(t[0]&65472)==65152?!0:t.slice(0,5).every(e=>e===0)?t[5]===65535||t[5]===0&&t[6]!==0?Ne(t[6]>>8,t[6]&255):t[5]===0&&t[6]===0:!1}function Ie(e){let t=w(e);if(t===void 0)return!1;let n=t.replace(/\.+$/,``);if(n===`localhost`||n.endsWith(`.localhost`))return!0;if(n.startsWith(`[`))return Fe(n.slice(1,-1));let r=/^(\d+)\.(\d+)\.\d+\.\d+$/.exec(n);return r?Ne(Number(r[1]),Number(r[2])):!1}function Le(e){return new Set([...je,...x(e,`connection`)])}function Re(e){let t=Le(e);return e.filter(([e])=>{let n=e.toLowerCase();return!t.has(n)&&!Me.has(n)})}function ze(e,t){let n=Le(e);return t.encodedBodies||n.add(`content-encoding`),t.encodedBodies&&t.bodiless||n.add(`content-length`),e.filter(([e])=>!n.has(e.toLowerCase()))}function Be(e){let t=x(e.headers,`connection`);return t.includes(`close`)?!1:e.minor>=1||t.includes(`keep-alive`)}function Ve(e,t){let n=new URL(t),r;try{r=new URL(e.target,e.target.startsWith(`/`)?n:void 0)}catch{throw new v(400,`malformed request target`)}let i=b(e.headers,`host`).every(e=>URL.canParse(`https://${e}`)&&new URL(`https://${e}`).host===n.host);if(r.origin!==n.origin||!i)throw new v(421,`this tunnel is for ${n.host}`);return r.href}function He(e){if(e.target.startsWith(`/`))throw new v(400,`this is a proxy: send the absolute URL (GET http://host/path)`);let t;try{t=new URL(e.target)}catch{throw new v(400,`malformed request target`)}if(t.protocol!==`http:`&&t.protocol!==`https:`)throw new v(400,`unsupported scheme ${t.protocol}`);if(Ie(t.hostname))throw new v(403,`${t.hostname} is the realm's own loopback, which the proxy does not reach: list it in no_proxy`);return t.href}function Ue(e){let t=/^([A-Za-z0-9.-]+|\[[0-9A-Fa-f:.]+\]):(\d{1,5})$/.exec(e.target),n=Number(t?.[2]);if(!t||n<1||n>65535)throw new v(400,`CONNECT needs host:port`);let r=w(t[1]);if(r===void 0)throw new v(400,`CONNECT needs host:port`);if(Ie(r))throw new v(403,`${r} is the realm's own loopback, which the proxy does not reach: list it in no_proxy`);return{host:r,port:n}}async function We(e,t,n){for(;!n.aborted&&!t.signal.aborted;){if(e.poll().hangup){t.abort(new h(`EPIPE`));return}try{await e.changed(n)}catch{return}}}function Ge(e,t){return new Promise((n,r)=>{let i=()=>{r(t.reason??new h(`EINTR`)),e.then(e=>e.cancel()).catch(()=>void 0)};if(t.aborted)return i();t.addEventListener(`abort`,i,{once:!0}),e.then(n,r).finally(()=>t.removeEventListener(`abort`,i))})}function Ke(e,t){let n=y(`slicc realm proxy: ${t}\n`);return{status:e,statusText:he[e]??``,headers:[[`Content-Type`,`text/plain; charset=utf-8`]],body:(async function*(){yield n})(),cancel:async()=>void 0}}function qe(e,t,n){return{read:(r,i)=>e.read(r,AbortSignal.any([n,AbortSignal.timeout(t),...i?[i]:[]]))}}var Je=class{options;listener;stop=new AbortController;limits;slots;bodies;connections=new Set;closed;port;constructor(e){this.options=e,this.limits={...Ae,...e.limits},this.slots=new C(this.limits.maxConnections),this.bodies=new C(this.limits.bodyBudget),this.listener=e.net.listen({family:`inet`,host:e.host??`127.0.0.1`,port:e.port??3128}),this.port=this.listener.local?.family===`inet`?this.listener.local.port:0,this.closed=this.acceptLoop()}get stopped(){return this.stop.signal.aborted}close(){if(!this.stop.signal.aborted){this.stop.abort(),this.listener.close();for(let e of this.connections)e.close()}}async acceptLoop(){let e=new Set;try{for(;;){await this.slots.acquire(1,this.stop.signal);let t;try{t=await this.listener.accept(this.stop.signal)}catch{this.slots.release(1);break}let n=this.serve(t).finally(()=>{this.slots.release(1),e.delete(n)});e.add(n)}}catch{}await Promise.allSettled([...e])}async serve(e){this.connections.add(e);let t=new ge(qe(e,this.limits.idleMs,this.stop.signal));try{await this.requests({sink:e,incoming:t,conn:e,socket:e})}finally{this.connections.delete(e),e.close()}}async requests(e){try{for(;;){let t=await e.incoming.head(this.limits.maxHead);if(!t||!await this.exchange(e,t))break}}catch(t){t instanceof v&&await this.refuse(e.sink,t)}}async refuse(e,t){try{await this.relay(e,`GET`,1,Ke(t.status,t.message),!1)}catch{}}async exchange(e,t){let{sink:n,incoming:r}=e,i=ye(t);if(i.method===`CONNECT`){if(!e.conn)throw new v(400,`CONNECT inside a tunnel`);return await this.connect(e.conn,r,i),!1}let a=e.origin?Ve(i,e.origin):He(i),o=Be(i),s=xe(i.headers),c=s.kind===`length`?s.length:s.kind===`chunked`?this.cap():0;if(c>this.cap())throw new v(413,`request body over ${this.cap()} bytes`);await this.expectContinue(n,i,s.kind!==`none`),await this.bodies.acquire(c,this.stop.signal);let l,u=new AbortController,d=()=>u.abort();this.stop.signal.addEventListener(`abort`,d,{once:!0});try{try{let t=await Se(r,s,this.cap()),n=new AbortController;We(e.socket,u,n.signal);try{l=await this.upstream(i,a,t,u.signal)}finally{n.abort()}}finally{this.bodies.release(c)}return await this.relay(n,i.method,i.minor,l,o)}finally{this.stop.signal.removeEventListener(`abort`,d),u.abort()}}cap(){return Math.min(this.options.transport.traits.maxRequestBody,this.limits.bodyBudget)}async expectContinue(e,t,n){let r=x(t.headers,`expect`);if(r.length!==0){if(r.length!==1||r[0]!==`100-continue`)throw new v(417,`unsupported expectation: ${r.join(`, `)}`);n&&t.minor>=1&&await e.write(y(`HTTP/1.1 100 Continue\r
|
|
5
|
+
\r
|
|
6
|
+
`),this.stop.signal)}}async upstream(e,t,n,r){try{return await Ge(this.options.transport.fetch({url:t,method:e.method.toUpperCase(),headers:Re(e.headers),body:e.method===`GET`||e.method===`HEAD`?void 0:n,signal:r}),r)}catch(e){if(r.aborted)throw e;let t=e instanceof Error?e.message:String(e),n=e?.status;return Ke(typeof n==`number`&&n>=400&&n<=599?n:502,t||`upstream request failed`)}}async relay(e,t,n,r,i){let a=r.status,o=t===`HEAD`||a===204||a===304||a<200,s=ze(r.headers,{encodedBodies:this.options.transport.traits.encodedBodies,bodiless:o}),c=!o&&n>=1,l=i&&(o||c);s.push([`Connection`,l?`keep-alive`:`close`]),c&&s.push([`Transfer-Encoding`,`chunked`]);let u=this.stop.signal;if(await e.write(Te(a,r.statusText||he[a]||``,s),u),o)return await r.cancel(),l;try{for await(let t of r.body)t.length>0&&await e.write(c?Ee(t):t,u)}catch{return await r.cancel().catch(()=>void 0),!1}return c&&await e.write(De,u),l}async connect(e,t,n){let r=Ue(n),i=this.options.tunnel;if(!i)throw new v(501,`CONNECT ${r.host}:${r.port}: no tunnels through this proxy`);await e.write(y(`HTTP/1.1 200 Connection Established\r
|
|
7
|
+
\r
|
|
8
|
+
`),this.stop.signal);try{await i(e,t,r,this.stop.signal,(t,n,r)=>this.requests({sink:n,incoming:new ge(t),origin:r,socket:e}))}catch(e){e instanceof h||Oe.warn(`tunnel failed`,{host:r.host,error:String(e)})}}};function Ye(){return{buffered:n(),streaming:r()}}function Xe(e){let t={};for(let[n,r]of e){let e=n.toLowerCase(),i=t[e];t[e]=i===void 0?r:`${i}${e===`cookie`?`; `:`, `}${r}`}return t}function Ze(e){return e.startsWith(`x-proxy-`)||e.startsWith(`access-control-`)}function Qe(e){let t=[];for(let[n,r]of Object.entries(e)){let e=n.toLowerCase();if(!Ze(e)){if(e===`set-cookie`)for(let e of $e(r))t.push([n,e]);else t.push([n,r])}}return t}function $e(e){if(e.startsWith(`[`))try{let t=JSON.parse(e);if(Array.isArray(t)&&t.every(e=>typeof e==`string`))return t}catch{}return[e]}async function*et(e){e.byteLength>0&&(yield e)}function tt(e){if(typeof e!=`string`)return e;let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return t}function nt(e=Ye()){return{traits:{manualRedirects:!1,encodedBodies:!1,maxRequestBody:i},async fetch(t){let n=Xe(t.headers);if(t.body&&t.body.byteLength>0){let r=await e.buffered(t.url,{method:t.method,headers:n,body:t.body,signal:t.signal});return{status:r.status,statusText:r.statusText,headers:Qe(r.headers),body:et(tt(r.body)),cancel:async()=>void 0}}let r=await e.streaming(t.url,{method:t.method,headers:n,signal:t.signal});return{status:r.status,statusText:r.statusText,headers:Qe(r.headers),body:r.body,cancel:()=>r.cancel()}}}}function rt(e){if(!e)return{body:(async function*(){})(),cancel:async()=>void 0};let t=e.getReader(),n=!1;async function*r(){try{for(;;){let e=await t.read();if(e.done)break;yield e.value}n=!0}finally{n||await t.cancel().catch(()=>void 0)}}return{body:r(),cancel:async()=>{n||await t.cancel().catch(()=>void 0),n=!0}}}function it(e,t){return{traits:{manualRedirects:!0,encodedBodies:!0,maxRequestBody:t.maxRequestBodyBytes},async fetch(t){let n=await e(t.url,{method:t.method,headers:t.headers.map(([e,t])=>[e,t]),...t.body&&t.body.byteLength>0?{body:t.body}:{},signal:t.signal});return{status:n.status,statusText:n.statusText,headers:n.headers,...rt(n.body)}}}}function at(e={}){let n,i=()=>(n??=(e.fallback??(()=>nt()))(),n),o,s=Promise.resolve().then(()=>(e.capabilities??t)()).then(t=>t.supported?it((e.raw??(()=>r({mode:`raw`})))(),t):i(),()=>i()).then(e=>(o??=e,o));return{get traits(){return(o??i()).traits},async fetch(e){let t=o??await s;if(t===n)return t.fetch(e);try{return await t.fetch(e)}catch(t){if(!(t instanceof a)||t.code!==`unsupported`)throw t;return o=i(),o.fetch(e)}}}}function T(e){let t=new Uint8Array(e.reduce((e,t)=>e+t.length,0)),n=0;for(let r of e)t.set(r,n),n+=r.length;return t}function ot(e){if(e<128)return Uint8Array.of(e);let t=[];for(let n=e;n>0;n=Math.floor(n/256))t.unshift(n&255);return Uint8Array.of(128|t.length,...t)}function E(e,...t){let n=T(t);return T([Uint8Array.of(e),ot(n.length),n])}const D=(...e)=>E(48,...e),st=(...e)=>E(49,...e),O=e=>E(4,e),k=(e,t=0)=>E(3,Uint8Array.of(t),e),ct=E(1,Uint8Array.of(255));function A(e){let t=0;for(;t<e.length-1&&e[t]===0;)t++;let n=e.subarray(t);return E(2,n[0]&128?T([Uint8Array.of(0),n]):n)}function j(e){let[t,n,...r]=e.split(`.`).map(Number),i=[40*t+n];for(let e of r){let t=[];for(let n=e;t.unshift(n&127),!(n<128);n=Math.floor(n/128));i.push(...t.map((e,n)=>n<t.length-1?e|128:e))}return E(6,Uint8Array.from(i))}const lt=e=>E(12,new TextEncoder().encode(e)),M=e=>Uint8Array.from(e,e=>e.charCodeAt(0)&127);function ut(e){let t=e.toISOString().replace(/[-:T]/g,``).slice(0,14);return e.getUTCFullYear()<2050?E(23,M(`${t.slice(2)}Z`)):E(24,M(`${t}Z`))}const dt=D(j(`1.2.840.10045.4.3.2`));function ft(e){let t=[];return e.organization&&t.push(st(D(j(`2.5.4.10`),lt(e.organization)))),t.push(st(D(j(`2.5.4.3`),lt(e.commonName)))),D(...t)}function N(e,t,n){return t?D(j(e),ct,O(n)):D(j(e),O(n))}function pt(e){let t=[],[,n,r]=P(e,0);for(let i=n;i<r;){let[,,n]=P(e,i);t.push(e.subarray(i,n)),i=n}return t}function P(e,t){let n=e[t],r=e[t+1],i=t+2;if(r&128){let t=r&127;r=0;for(let n=0;n<t;n++)r=r*256+e[i+n];i+=t}if(i+r>e.length)throw Error(`truncated DER`);return[n,i,i+r]}function mt(e){let[,t,n]=P(e,0);return e.subarray(t,n)}function ht(e){let t=pt(e)[1];return mt(t).subarray(1)}async function gt(e){return new Uint8Array(await crypto.subtle.digest(`SHA-1`,ht(e)))}function _t(e){let t=e.length/2;return D(A(e.subarray(0,t)),A(e.subarray(t)))}function vt(){let e=crypto.getRandomValues(new Uint8Array(16));return e[0]=e[0]&127|1,e}function yt(e){let t=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(e);if(!t)return;let n=t.slice(1).map(Number);return n.every(e=>e<=255)?Uint8Array.from(n):void 0}function bt(e){if(!e.includes(`:`)||!/^[0-9A-Fa-f:.]+$/.test(e))return;let t=/(\d{1,3}(?:\.\d{1,3}){3})$/.exec(e),n=e,r=[];if(t){let i=yt(t[1]);if(!i)return;r.push(i[0]<<8|i[1],i[2]<<8|i[3]),n=e.slice(0,-t[1].length).replace(/:$/,e.endsWith(`::${t[1]}`)?`:`:``)}let i=n.split(`::`);if(i.length>2)return;let a=e=>e===``?[]:e.split(`:`),o=a(i[0]),s=i.length===2?a(i[1]):[];if(![...o,...s].every(e=>/^[0-9A-Fa-f]{1,4}$/.test(e)))return;let c=8-[...o,...s].map(e=>Number.parseInt(e,16)).length-r.length;if(i.length===2?c<1:c!==0)return;let l=[...o.map(e=>Number.parseInt(e,16)),...Array(i.length===2?c:0).fill(0),...s.map(e=>Number.parseInt(e,16)),...r];return Uint8Array.from(l.flatMap(e=>[e>>8,e&255]))}async function xt(e){let t=[N(`2.5.29.14`,!1,O(await gt(e.spki)))];if(e.kind.ca)t.push(N(`2.5.29.19`,!0,D(ct,A(Uint8Array.of(0))))),t.push(N(`2.5.29.15`,!0,k(Uint8Array.of(134),1)));else{t.push(N(`2.5.29.35`,!1,D(E(128,await gt(e.issuerSpki))))),t.push(N(`2.5.29.19`,!0,D())),t.push(N(`2.5.29.15`,!0,k(Uint8Array.of(128),7))),t.push(N(`2.5.29.37`,!1,D(j(`1.3.6.1.5.5.7.3.1`))));let n=yt(e.kind.host)??bt(e.kind.host),r=n?E(135,n):E(130,M(e.kind.host));t.push(N(`2.5.29.17`,!1,D(r)))}return E(163,D(...t))}async function St(e){let t=D(E(160,A(Uint8Array.of(2))),A(e.serial),dt,ft(e.issuer),D(ut(e.notBefore),ut(e.notAfter)),ft(e.subject),e.spki,await xt(e)),n=_t(await e.sign(t));return D(t,dt,k(n))}function Ct(e){let t=``;for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return`-----BEGIN CERTIFICATE-----\n${(btoa(t).match(/.{1,64}/g)??[]).join(`
|
|
9
|
+
`)}\n-----END CERTIFICATE-----\n`}const wt={name:`ECDSA`,namedCurve:`P-256`},Tt={name:`ECDSA`,hash:`SHA-256`};function Et(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}function Dt(e=`slicc-realm-ca`){let t,n=()=>(t??=new Promise((t,n)=>{let r=indexedDB.open(e,1);r.onupgradeneeded=()=>r.result.createObjectStore(`ca`),r.onsuccess=()=>t(r.result),r.onerror=()=>n(r.error)}),t.catch(()=>{t=void 0}),t);return{async get(e){return await Et((await n()).transaction(`ca`).objectStore(`ca`).get(e))},async put(e,t){let r=(await n()).transaction(`ca`,`readwrite`);r.objectStore(`ca`).put(t,e),await new Promise((e,t)=>{r.oncomplete=()=>e(),r.onerror=()=>t(r.error)})}}}var Ot=class extends Error{};function kt(e){return bt(e)?!0:e.length===0||e.length>253?!1:e.split(`.`).every(e=>/^(?!-)[a-z0-9-]{1,63}(?<!-)$/i.test(e))}var At=class e{record;constructor(e){this.record=e}static async open(t,n,r=Date.now()){let i=await n.get(t).catch(()=>void 0);if(i&&i.notAfter-r>2592e6)return new e(i);let a=await e.create(t,r);return await n.put(t,a),new e(a)}static async create(e,t){let n=await crypto.subtle.generateKey(wt,!1,[`sign`,`verify`]),r=new Uint8Array(await crypto.subtle.exportKey(`spki`,n.publicKey)),i={organization:`SLICC`,commonName:`SLICC realm CA ${e} ${Array.from(crypto.getRandomValues(new Uint8Array(4)),e=>e.toString(16).padStart(2,`0`)).join(``)}`},a=t+31536e7,o=await St({serial:vt(),issuer:i,subject:i,notBefore:new Date(t-864e5),notAfter:new Date(a),spki:r,issuerSpki:r,kind:{ca:!0},sign:jt(n.privateKey)});return{key:n.privateKey,cert:o,spki:r,notAfter:a,name:i}}get cert(){return this.record.cert}get pem(){return Ct(this.record.cert)}async issue(e,t,n=Date.now()){let r=e.toLowerCase();if(!kt(r))throw new Ot(`no certificate for ${e}`);return St({serial:vt(),issuer:this.record.name,subject:{commonName:r.length<=64?r:`SLICC realm leaf`},notBefore:new Date(n-36e5),notAfter:new Date(n+6048e5),spki:t,issuerSpki:this.record.spki,kind:{ca:!1,host:r},sign:jt(this.record.key)})}};function jt(e){return async t=>new Uint8Array(await crypto.subtle.sign(Tt,e,t))}let Mt;const F=new Map;function Nt(e,t){let n=F.get(e);return n||(Mt??=t?void 0:Dt(),n=At.open(e,t??Mt),F.set(e,n),n.catch(()=>{F.get(e)===n&&F.delete(e)})),n}const Pt=65536;var Ft=class extends Error{code;constructor(e,t){super(t),this.code=e}},It=class{m;scratch;constructor(e){if(this.m=e,this.scratch=e._malloc(Pt),!this.scratch)throw Error(`tls engine: out of memory`)}put(e){let t=this.m._malloc(e.length+1);if(!t)throw Error(`tls engine: out of memory`);return this.m.HEAPU8.set(e,t),this.m.HEAPU8[t+e.length]=0,t}taken(e){return this.m.HEAPU8.slice(this.scratch,this.scratch+e)}error(e,t){this.m._tls_strerror(e,this.scratch,256);let n=this.m.HEAPU8.indexOf(0,this.scratch);return new Ft(e,`${t}: ${new TextDecoder().decode(this.m.HEAPU8.subarray(this.scratch,n))||e}`)}leaf(){let e=this.m._tls_leaf_new();if(!e)throw this.error(this.m._tls_last_error(),`leaf key`);return new Lt(this,this.m,e)}session(e,t){let n=this.put(new TextEncoder().encode(t));try{let t=this.m._tls_session_new(e.ptr,n);if(!t)throw this.error(this.m._tls_last_error(),`tls session`);return new Rt(this,this.m,t)}finally{this.m._free(n)}}withBytes(e,t){let n=this.put(e);try{return t(n)}finally{this.m._free(n)}}intoScratch(e){let t=e(this.scratch,Pt);return t>0?this.taken(t):t}},Lt=class{engine;m;ptr;constructor(e,t,n){this.engine=e,this.m=t,this.ptr=n}spki(){let e=this.engine.intoScratch((e,t)=>this.m._tls_leaf_spki(this.ptr,e,t));if(typeof e==`number`)throw this.engine.error(e,`leaf public key`);return e}addCert(e){let t=this.engine.withBytes(e,t=>this.m._tls_leaf_add_cert(this.ptr,t,e.length));if(t!==0)throw this.engine.error(t,`leaf certificate`)}release(){this.m._tls_leaf_free(this.ptr)}},Rt=class{engine;m;ptr;constructor(e,t,n){this.engine=e,this.m=t,this.ptr=n}feed(e){return this.engine.withBytes(e,t=>this.m._tls_feed(this.ptr,t,e.length))}feedEnd(){this.m._tls_feed_eof(this.ptr)}read(){let e=this.engine.intoScratch((e,t)=>this.m._tls_read(this.ptr,e,t));if(e instanceof Uint8Array)return e;if(e===0)return`more`;if(e===-1)return`eof`;throw this.engine.error(e,`tls`)}write(e){let t=this.engine.withBytes(e,t=>this.m._tls_write(this.ptr,t,e.length));if(t<0)throw this.engine.error(t,`tls`);return t}take(){if(this.m._tls_out_size(this.ptr)===0)return new Uint8Array;let e=this.engine.intoScratch((e,t)=>this.m._tls_out_take(this.ptr,e,t));return e instanceof Uint8Array?e:new Uint8Array}close(){this.m._tls_close(this.ptr)}get version(){return this.m._tls_version(this.ptr)}get handshakeDone(){return this.m._tls_handshake_done(this.ptr)!==0}free(){this.m._tls_session_free(this.ptr)}};let I;function zt(e=async()=>(await import(`./slicc-tls-engine-DfyKw1Ua.js`)).default()){return I??=e().then(e=>new It(e)),I.catch(()=>{I=void 0}),I}const Bt=e(`realm-tls`);var Vt=class{session;cipherIn;cipherOut;pending=new Uint8Array;ended=!1;constructor(e,t,n){this.session=e,this.cipherIn=t,this.cipherOut=n}async flush(e){for(let t=this.session.take();t.length>0;t=this.session.take())await this.cipherOut.write(t,e)}feedPending(){if(this.pending.length===0)return;let e=this.session.feed(this.pending);this.pending=this.pending.subarray(e)}async read(e,t){for(;;){this.feedPending();let e=this.session.read();if(await this.flush(t),e instanceof Uint8Array)return e;if(e===`eof`)return new Uint8Array;if(this.pending.length>0)continue;if(this.ended){this.session.feedEnd();let e=this.session.read();return await this.flush(t),e instanceof Uint8Array?e:new Uint8Array}let n=await this.cipherIn.read(65536,t);n.length===0?this.ended=!0:this.pending=n}}async write(e,t){for(let n=0;n<e.length;){let r=this.session.write(e.subarray(n,n+16384));await this.flush(t),n+=r}return e.length}async close(e){this.session.close(),await this.flush(e)}},Ht=class{options;leaves=new Map;now;constructor(e){this.options=e,this.now=e.now??Date.now}leafFor(e,t){let n=this.now(),r=this.leaves.get(t);if(r&&r.expires>n)return this.leaves.delete(t),this.leaves.set(t,r),r.leaf;r&&this.drop(t,r);let i=this.issue(e,t,n),a={leaf:i,expires:n+5184e5};this.leaves.set(t,a),i.catch(()=>{this.leaves.get(t)===a&&this.leaves.delete(t)});for(let[e,t]of this.leaves){if(this.leaves.size<=256)break;this.drop(e,t)}return i}async drop(e,t){this.leaves.get(e)===t&&this.leaves.delete(e),(await t.leaf.catch(()=>void 0))?.release()}async issue(e,t,n){let r=await this.options.ca(),i=e.leaf();try{return i.addCert(await r.issue(t,i.spki(),n)),i.addCert(r.cert),i}catch(e){throw i.release(),e}}async close(){await Promise.all([...this.leaves].map(([e,t])=>this.drop(e,t)))}handler=async(e,t,n,r,i)=>{let a=await this.options.engine(),o=n.host.replace(/^\[|\]$/g,``),s=await this.leafFor(a,o),c=a.session(s,o);try{let a=new Vt(c,Wt(t),e),s=`https://${Ut(n)}`;try{await i(a,a,s),await a.close(r).catch(()=>void 0)}catch(e){throw Bt.debug(`tunnel ended`,{host:o,error:String(e)}),e}}finally{c.free()}}};function Ut(e){return e.port===443?e.host:`${e.host}:${e.port}`}function Wt(e){return{read:(t,n)=>e.some(t,n)}}const L=`http://127.0.0.1:${ke}`,Gt=`localhost,.localhost,127.0.0.1,127.0.0.0/8`;function Kt(){return{http_proxy:L,https_proxy:L,HTTP_PROXY:L,HTTPS_PROXY:L,no_proxy:Gt,NO_PROXY:Gt}}function qt(e){if(e)return`ca`in e?new Ht(e):new Ht({ca:()=>Nt(e.owner),engine:()=>zt()})}const Jt=new WeakMap,Yt=`/.config/slicc/realm-ca-`;function Xt(e){return e.replace(/[^A-Za-z0-9_-]+/g,`-`).replace(/-+$/,``)}function Zt(e,t){return`${e.replace(/\/+$/,``)}${Yt}${Xt(t)}.pem`}function R(e){return{SSL_CERT_FILE:e,CURL_CA_BUNDLE:e,GIT_SSL_CAINFO:e}}const Qt=`/.config/slicc/gitconfig`;function $t(e){return`${e.replace(/\/+$/,``)}${Qt}`}function en(e){return`"${e.replace(/[\r\n]+/g,` `).replace(/[\\"]/g,e=>`\\${e}`)}"`}function tn(e){let t=[`[credential]`,` helper = slicc`];return e&&t.push(`[user]`,`\tname = ${en(e.name)}`,`\temail = ${en(e.email)}`),`${t.join(`
|
|
10
|
+
`)}\n`}async function nn(e,t,n){try{let r=tn(n);return(await e.exists(t)?await e.readFile(t):void 0)!==r&&(await e.mkdir(t.slice(0,t.lastIndexOf(`/`)),{recursive:!0}),await e.writeFile(t,r)),{GIT_CONFIG_SYSTEM:t}}catch{return{}}}function rn(e,t){let n=Kt();return e in n?n[e]===t:e===`GIT_CONFIG_SYSTEM`?t.endsWith(Qt):e in R(``)&&t.includes(Yt)}async function an(e,t,n,r=Nt){try{let{pem:i}=await r(n);return(await e.exists(t)?await e.readFile(t):void 0)!==i&&(await e.mkdir(t.slice(0,t.lastIndexOf(`/`)),{recursive:!0}),await e.writeFile(t,i)),R(t)}catch{return{}}}function on(e,t={}){if(Jt.has(e))return;let n={proxy:void 0};Jt.set(e,n);let r;e.activate({family:`inet`,host:`127.0.0.1`,port:ke},()=>{r??=(t.transport??at)();let i=qt(t.tls),a=new Je({net:e,transport:r,tunnel:i?.handler,...t.proxy});n.proxy=a,sn(a,t.process).then(async()=>{n.proxy===a&&(n.proxy=void 0),await i?.close()})})}async function sn(e,t){if(!t){await e.closed;return}let n=t.processManager,r=n.spawn({kind:`net`,argv:[`http-proxy`,`127.0.0.1:${e.port}`],cwd:`/`,owner:t.owner}),i=()=>e.close();r.abort.signal.addEventListener(`abort`,i,{once:!0}),await e.closed,r.abort.signal.removeEventListener(`abort`,i),n.exit(r.pid,r.abort.signal.aborted?null:0)}const cn=32768;function ln(e){return/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(e)}async function z(e){try{return await e()}catch(e){throw e instanceof o?new h(e.code):e}}var un=class{waiters=[];wait(e){return e?.aborted?Promise.reject(new h(`EINTR`)):new Promise((t,n)=>{let r=()=>{this.waiters=this.waiters.filter(e=>e!==i),n(new h(`EINTR`))},i=()=>{e?.removeEventListener(`abort`,r),t()};this.waiters.push(i),e?.addEventListener(`abort`,r,{once:!0})})}wake(){let e=this.waiters;this.waiters=[];for(let t of e)t()}};function dn(e,t){let n=new d,r=new d;for(let e of[n,r])e.openRead(),e.openWrite();e.attach({rx:r,tx:n}),t.attach({rx:n,tx:r})}var B=class e{net;domain;state=`open`;local;peer;link;readShut=!1;writeShut=!1;queue=[];backlog=0;bound=!1;changes=new un;options=new Map;constructor(e,t){this.net=e,this.domain=t}attach(e){this.link=e,this.state=`connected`,this.changes.wake()}get listening(){return this.state===`listening`}connection(){if(!this.link||this.state!==`connected`)throw new h(`ENOTCONN`);return this.link}async read(e,t){let{rx:n}=this.connection();return this.readShut||e<=0?new Uint8Array:z(()=>n.read(e,t))}async peek(e,t){let{rx:n}=this.connection();return this.readShut||e<=0?new Uint8Array:z(()=>n.peek(e,t))}async write(e,t){let{tx:n}=this.connection();if(this.writeShut)throw new h(`EPIPE`);return z(()=>n.write(e,t))}poll(){if(this.state===`listening`)return{readable:this.queue.length>0,writable:!1,hangup:!1};if(this.state!==`connected`||!this.link)return{readable:!1,writable:!1,hangup:!0};let{rx:e,tx:t}=this.link;return{readable:this.readShut||e.readReady,writable:this.writeShut||t.writeReady,hangup:e.writersGone&&t.readersGone}}changed(e){let t=this.changes.wait(e);if(this.state!==`connected`||!this.link)return t;let n=[t,this.link.rx.changed(e),this.link.tx.changed(e)];for(let e of n)e.catch(()=>void 0);return z(()=>Promise.race(n))}bind(e){if(this.state!==`open`||this.local)throw new h(`EINVAL`);if(e.family!==this.domain)throw new h(`EAFNOSUPPORT`);this.local=this.net.bind(this,e),this.bound=!0}listen(e){if(this.state===`connected`)throw new h(`EISCONN`);if(this.state!==`open`&&this.state!==`listening`)throw new h(`EINVAL`);if(!this.local){if(this.domain===`unix`)throw new h(`EINVAL`);this.bind({family:`inet`,host:`0.0.0.0`,port:0})}this.backlog=Math.min(Math.max(e,1),4096),this.state=`listening`}async accept(e,t=!1){for(;;){if(this.state!==`listening`)throw new h(`EINVAL`);let n=this.queue.shift();if(n)return n;if(t)throw new h(`EAGAIN`);await this.changes.wait(e)}}offer(e){return this.state!==`listening`||this.queue.length>=this.backlog?!1:(this.queue.push(e),this.changes.wake(),!0)}connect(t){if(this.state===`connected`)throw new h(`EISCONN`);if(this.state!==`open`)throw new h(`EINVAL`);if(t.family!==this.domain)throw new h(`EAFNOSUPPORT`);let n=this.net.target(t);this.local||(t.family===`inet`?(this.local=this.net.bind(this,{family:`inet`,host:`127.0.0.1`,port:0}),this.bound=!0):this.local={family:`unix`,path:``});let r=new e(this.net,this.domain);if(r.local=t.family===`inet`?{...t,host:fn(t.host)}:t,r.peer=this.local,this.peer=r.local,dn(this,r),!n.offer(r))throw this.unlink(),r.close(),new h(`ECONNREFUSED`)}unlink(){let e=this.link;e&&(e.rx.closeRead(),e.tx.closeWrite()),this.link=void 0,this.peer=void 0,this.state=`open`}shutdown(e){let{rx:t,tx:n}=this.connection();if(e!==0&&e!==1&&e!==2)throw new h(`EINVAL`);e!==1&&!this.readShut&&(this.readShut=!0,t.closeRead()),e!==0&&!this.writeShut&&(this.writeShut=!0,n.closeWrite()),this.changes.wake()}getOption(e,t){if(e===1)switch(t){case 3:return 1;case 4:return 0;case 30:return+(this.state===`listening`);case 39:return this.domain===`inet`?2:1;case 7:case 8:return this.options.get(`${e}:${t}`)??65536}return this.options.get(`${e}:${t}`)??0}setOption(e,t,n){this.options.set(`${e}:${t}`,n)}close(){let e=this.state;if(this.state=`closed`,e===`listening`)for(let e of this.queue.splice(0))e.close();this.link&&(this.readShut||this.link.rx.closeRead(),this.writeShut||this.link.tx.closeWrite(),this.readShut=!0,this.writeShut=!0),this.bound&&this.local&&this.net.release(this.local,this),this.bound=!1,this.changes.wake()}static pair(t,n){let r=new e(t,n),i=new e(t,n);return r.local=i.local=r.peer=i.peer=n===`inet`?{family:`inet`,host:`127.0.0.1`,port:0}:{family:`unix`,path:``},dn(r,i),[r,i]}};function fn(e){return e===`0.0.0.0`?`127.0.0.1`:e}function V(e){return e.family===`inet`?`inet:${e.port}`:`unix:${e.path}`}var pn=class{bound=new Map;activators=new Map;nextEphemeral=cn;activate(e,t){this.activators.set(V(e),t)}socket(e){return new B(this,e)}listen(e,t=128){let n=this.socket(e.family);return n.bind(e),n.listen(t),n}connect(e){let t=this.socket(e.family);return t.connect(e),t}bind(e,t){if(t.family===`unix`){if(t.path===``)throw new h(`EINVAL`)}else if(t.host!==`0.0.0.0`&&!ln(t.host))throw new h(`EADDRNOTAVAIL`);let n=t.family===`inet`&&t.port===0?{...t,port:this.ephemeral()}:t,r=V(n);if(this.bound.has(r))throw new h(`EADDRINUSE`);return this.bound.set(r,e),n}release(e,t){let n=V(e);this.bound.get(n)===t&&this.bound.delete(n)}target(e){if(e.family===`inet`&&!ln(fn(e.host)))throw new h(`ENETUNREACH`);let t=V(e);this.bound.has(t)||this.activators.get(t)?.();let n=this.bound.get(t);if(!n?.listening)throw new h(`ECONNREFUSED`);return n}ephemeral(){for(let e=0;e<28232;e++){let e=this.nextEphemeral;if(this.nextEphemeral=e===60999?cn:e+1,!this.bound.has(`inet:${e}`))return e}throw new h(`EADDRINUSE`)}};const mn=new Map;function hn(e){let t=mn.get(e);return t||(t=new pn,mn.set(e,t)),t}function H(e){return e?`${e.kind}:${e.scoopJid??``}`:`local`}const U={HUP:1,INT:2,QUIT:3,ILL:4,TRAP:5,ABRT:6,BUS:7,FPE:8,KILL:9,USR1:10,SEGV:11,USR2:12,PIPE:13,ALRM:14,TERM:15,STKFLT:16,CHLD:17,CONT:18,STOP:19,TSTP:20,TTIN:21,TTOU:22,URG:23,XCPU:24,XFSZ:25,VTALRM:26,PROF:27,WINCH:28,POLL:29,PWR:30,SYS:31},gn=new Set([U.CHLD,U.URG,U.WINCH]),_n=new Set([U.STOP,U.TSTP,U.TTIN,U.TTOU]);function vn(e){return e===U.CONT?`continue`:_n.has(e)?`stop`:gn.has(e)?`ignore`:`terminate`}function yn(e){return Number.isInteger(e)&&e>=1&&e<=31}function W(e){return 1<<e}const G={SIGINT:U.INT,SIGTERM:U.TERM,SIGKILL:U.KILL,SIGSTOP:U.STOP,SIGCONT:U.CONT},bn=16384;function xn(){let e=Array(32).fill(0);return Object.assign(e,{0:3,1:28,2:127,3:21}),Object.assign(e,{4:4,6:1,8:17,9:19,10:26}),Object.assign(e,{12:18,13:15,14:23,15:22}),{c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:e}}const Sn=new TextEncoder;function Cn(e){return(e&192)==128}var wn=class{screen;signal;termios=xn();cols=80;rows=24;readable=[];line=[];waiters=[];constructor(e,t){this.screen=e,this.signal=t}receive(e){for(let t of e)this.key(t);this.wake()}resize(e,t){this.setSize(e,t),this.signal(U.WINCH)}setSize(e,t){this.cols=e,this.rows=t}tcgets(){return{...this.termios,c_cc:[...this.termios.c_cc]}}tcsets(e){let t=this.canonical;this.termios={...e,c_cc:[...e.c_cc]},t&&!this.canonical&&this.line.length>0&&(this.readable.push(Uint8Array.from(this.line)),this.line=[],this.wake())}winsize(){return[this.rows,this.cols]}file(){return new _({read:(e,t)=>this.read(e,t),write:async e=>(this.output(e),e.length),poll:()=>({readable:this.readable.length>0,writable:!0,hangup:!1}),changed:e=>this.changed(e),close:()=>{},tty:this})}get canonical(){return!!(this.termios.c_lflag&2)}cc(e){return this.termios.c_cc[e]??0}key(e){let{c_iflag:t,c_lflag:n}=this.termios,r=e===13&&t&256?10:e;if(!(n&1&&this.signalKey(r))){if(!this.canonical){this.readable.push(Uint8Array.of(r)),n&8&&this.echo(r);return}this.edit(r)}}signalKey(e){let t=e===this.cc(0)?U.INT:e===this.cc(1)?U.QUIT:e===this.cc(10)?U.TSTP:0;return!t||e===0?!1:(this.termios.c_lflag&8&&this.echo(e),this.termios.c_lflag&128||(this.line=[],this.readable=[]),this.signal(t),!0)}edit(e){let t=!!(this.termios.c_lflag&8);e===this.cc(2)||e===8?this.rubOut(this.lastCharLength()):e===this.cc(3)?this.rubOut(this.line.length):e===this.cc(14)?this.rubOut(this.lastWordLength()):e===this.cc(4)?(this.readable.push(this.line.length>0?Uint8Array.from(this.line):null),this.line=[]):e===10?(this.line.push(e),t&&this.output(Sn.encode(`
|
|
11
|
+
`)),this.readable.push(Uint8Array.from(this.line)),this.line=[]):(this.line.push(e),t&&this.echo(e))}lastWordLength(){let e=this.line.length;for(;e>0&&this.line[e-1]===32;)e--;for(;e>0&&this.line[e-1]!==32;)e--;return this.line.length-e}lastCharLength(){let{line:e}=this,t=Math.min(1,e.length);if(this.termios.c_iflag&bn)for(;t<e.length&&Cn(e[e.length-t]??0);)t++;return t}rubOut(e){let t=this.line.splice(this.line.length-e,e),n=this.termios.c_iflag&bn?t.filter(e=>!Cn(e)).length:t.length;n>0&&this.termios.c_lflag&8&&this.output(Sn.encode(`\b \b`.repeat(n)),!1)}echo(e){if(e<32&&e!==10&&e!==9&&this.termios.c_lflag&512){this.output(Uint8Array.of(94,e+64),!1);return}this.output(Uint8Array.of(e))}output(e,t=!0){let{c_oflag:n}=this.termios;if(!t||!(n&1&&n&4)||!e.includes(10)){this.screen.write(e);return}let r=[];for(let t of e)t===10&&r.push(13),r.push(t);this.screen.write(Uint8Array.from(r))}async read(e,t){for(;this.readable.length===0;)await this.changed(t);let n=this.readable[0];if(n===null)return this.readable.shift(),new Uint8Array;if(n===void 0)return new Uint8Array;let r=[],i=0;for(;this.readable.length>0&&i<e;){let t=this.readable[0];if(t==null)break;let n=t.subarray(0,e-i);if(r.push(n),i+=n.length,n.length<t.length?this.readable[0]=t.subarray(n.length):this.readable.shift(),this.canonical)break}let a=new Uint8Array(i),o=0;for(let e of r)a.set(e,o),o+=e.length;return a}changed(e){return e?.aborted?Promise.reject(new h(`EINTR`)):new Promise((t,n)=>{let r=()=>{this.waiters=this.waiters.filter(e=>e!==i),n(new h(`EINTR`))},i=()=>{e?.removeEventListener(`abort`,r),t()};this.waiters.push(i),e?.addEventListener(`abort`,r,{once:!0})})}wake(){let e=this.waiters;this.waiters=[];for(let t of e)t()}},K=class extends Error{code;constructor(e){super(e),this.code=e}};function Tn(e){let t=()=>{};return{promise:new Promise((n,r)=>{t=()=>r(new h(`EINTR`)),e?.aborted?t():e?.addEventListener(`abort`,t,{once:!0})}),done:()=>e?.removeEventListener(`abort`,t)}}function En(e){return(e&255)<<8|127}function Dn(e,t){return t?t&127:(e&255)<<8}function On(e){let t=new Uint8Array(e.reduce((e,t)=>e+t.length,0)),n=0;for(let r of e)t.set(r,n),n+=r.length;return t}var kn=class{parentFds;spawner;forker;children=new Map;leftovers=new Map;onChildState;stateChanged=[];watchers=new Map;constructor(e,t,n){this.parentFds=e,this.spawner=t,this.forker=n}async fork(e){if(!this.forker)throw new K(`ENOSYS`);return this.track(e,this.parentFds.fork(),new Map,this.forker)}async spawn(e,t,n=[]){if(!this.spawner)throw new K(`ENOSYS`);let r=new s,i=new Map;try{for(let[e,n]of t.entries())r.installAt(e,this.openSlot(n,e,i));for(let{fd:e,kernel:t,flags:i}of n)e<=2||(r.installAt(e,this.parentFds.get(t).retain()),i!==void 0&&r.setStatusFlags(e,i))}catch(e){throw await r.closeAll(),e}return this.track(e,r,i,this.spawner)}async track(e,t,n,r){let i;try{i=await r(e,t)}catch(e){throw await t.closeAll(),e}let a={exited:i.exited,termsig:i.termsig,captured:n};return i.exited.then(e=>{a.code=e,this.watchers.delete(i.pid),this.onChildState?.()}),i.onState?.((e,t)=>{a.stopReport=e===`stopped`?t:void 0,a.continueReport=e===`continued`,this.watchers.get(i.pid)?.(e,t);let n=this.stateChanged;this.stateChanged=[];for(let e of n)e();this.onChildState?.()}),this.children.set(i.pid,a),i.pid}watch(e,t){this.children.has(e)&&this.watchers.set(e,t)}openSlot(e,t,n){if(`fd`in e)return this.parentFds.get(e.fd).retain();if(`input`in e)return c(e.input);if(`capture`in e){let e=[];return n.set(t,e),p(t=>e.push(t))}return l()}async wait(e,t,n,r={}){let i;try{for(;;){let a=this.candidates(e,r);if(a.length===0)throw new h(`ECHILD`);let o=a.find(([,e])=>e.code!==void 0);if(o)return this.reap(o[0],o[1].code);let s=this.stateReport(a,r);if(s)return s;if(t)return[0,0];i??=Tn(n),await this.nextChange(a,r,i.promise)}}finally{i?.done()}}candidates(e,t){let n=[...this.children];if(e>0)return n.filter(([t])=>t===e);let r=t.inGroup;return e===-1||!r?n:n.filter(([e])=>r(e))}async nextChange(e,t,n){let r,i=new Promise(e=>r=e),a=t.untraced||t.continued;a&&r&&this.stateChanged.push(r);try{await Promise.race([...e.map(([,e])=>e.exited),...a?[i]:[],n])}finally{this.stateChanged=this.stateChanged.filter(e=>e!==r)}}stateReport(e,t){for(let[n,r]of e){if(t.untraced&&r.stopReport!==void 0){let e=r.stopReport;return r.stopReport=void 0,[n,En(e)]}if(t.continued&&r.continueReport)return r.continueReport=!1,[n,65535]}return null}reap(e,t){let n=this.children.get(e);return this.children.delete(e),n&&n.captured.size>0&&this.leftovers.set(e,n.captured),[e,Dn(t,n?.termsig?.())]}captured(e,t){let n=this.leftovers.get(e),r=n?.get(t);return!n||!r?new Uint8Array:(n.delete(t),n.size===0&&this.leftovers.delete(e),On(r))}};function An(e,t,n){let r=new Set,i=(t,n)=>t.filter(t=>{let i=g(e.get(t).file);return i.hangup&&r.add(t),i[n]||i.hangup}),a={read:i(t,`readable`),write:i(n,`writable`)};return r.size>0&&(a.hangup=[...r]),a}function jn(e){let t=()=>{};return{promise:new Promise((n,r)=>{t=()=>r(new h(`EINTR`)),e.aborted?t():e.addEventListener(`abort`,t,{once:!0})}),done:()=>e.removeEventListener(`abort`,t)}}async function Mn(e,t,n,r,i){let a=r<0?1/0:Date.now()+r,o=jn(i);o.promise.catch(()=>{});try{return await Nn(e,t,n,a,o.promise)}finally{o.done()}}async function Nn(e,t,n,r,i){for(;;){let a=An(e,t,n);if(a.read.length>0||a.write.length>0||Date.now()>=r)return a;let o=new AbortController,s=[...new Set([...t,...n])].flatMap(t=>{let n=e.get(t).file;return n.changed===void 0?[]:[n.changed(o.signal).catch(()=>void 0)]}),c,l=r===1/0?[]:[new Promise(e=>c=setTimeout(e,r-Date.now()))];try{await Promise.race([...s,...l,i])}finally{o.abort(),clearTimeout(c)}}}const Pn=[`sock-open`,`sock-pair`,`sock-bind`,`sock-listen`,`sock-accept`,`sock-connect`,`sock-shutdown`,`sock-name`,`sock-getopt`,`sock-setopt`];function q(e,t){let n=e.get(t).file;if(!(n instanceof B))throw new h(`ENOTSOCK`);return n}const J=e=>e===void 0?{ok:!0,kind:`void`}:{ok:!0,kind:`json`,json:e};async function Fn(e,t){let{fds:n,net:r}=t;switch(e.op){case`sock-open`:return J(n.install(new _(r.socket(e.domain)),3));case`sock-pair`:{let[t,i]=B.pair(r,e.domain),a=n.install(new _(t),3);try{return J([a,n.install(new _(i),3)])}catch(e){throw await Promise.resolve(n.close(a)),e}}case`sock-bind`:return q(n,e.fd).bind(e.addr),J();case`sock-listen`:return q(n,e.fd).listen(e.backlog),J();case`sock-accept`:return J(await Ln(t,e.fd,e.nonblock));case`sock-connect`:if(q(n,e.fd).connect(e.addr),e.nonblock)throw new h(`EINPROGRESS`);return J();case`sock-shutdown`:return q(n,e.fd).shutdown(e.how),J();case`sock-name`:{let t=q(n,e.fd),r=e.peer?t.peer:t.local;if(e.peer&&!r)throw new h(`ENOTCONN`);return J(r??In(t.domain))}case`sock-getopt`:return J(q(n,e.fd).getOption(e.level,e.name));case`sock-setopt`:return q(n,e.fd).setOption(e.level,e.name,e.value),J()}}function In(e){return e===`inet`?{family:`inet`,host:`0.0.0.0`,port:0}:{family:`unix`,path:``}}async function Ln(e,t,n){let r=q(e.fds,t),i=!n&&!g(r).readable,a=await r.accept(i?e.blocking():void 0,n);return{fd:e.fds.install(new _(a),3),peer:a.peer}}function Rn(e,t){let n=t.flags&3,r=n!==1,i=n===1||n===2,a=t.contents===void 0?t.orphan?new Uint8Array:void 0:new Uint8Array(t.contents),o=a?.length??0,s=!1,c=t.position,l=Promise.resolve(),u=e=>{let t=l.then(e);return l=t.catch(()=>void 0),t},d=async()=>{if(!a){try{a=await e.readFileBuffer(t.path)}catch{a=new Uint8Array}o=a.length}return a},f=e=>{let t=a??new Uint8Array;if(t.length>=e)return t;let n=new Uint8Array(Math.max(e,t.length*2,256));return n.set(t.subarray(0,o)),a=n,n},p=async()=>{!s||!a||t.orphan||(s=!1,await e.writeFile(t.path,a.slice(0,o)))};return new _({read:r?e=>u(async()=>{let t=await d(),n=Math.max(0,Math.min(e,o-c)),r=t.slice(c,c+n);return c+=n,r}):void 0,write:i?e=>u(async()=>{await d(),t.flags&1024&&(c=o);let n=f(c+e.length);return c>o&&n.fill(0,o,c),n.set(e,c),c+=e.length,o=Math.max(o,c),s=!0,e.length}):void 0,seek:(e,t)=>u(async()=>{let n=0;if(t===1)n=c;else if(t===2)await d(),n=o;else if(t!==0)throw new h(`EINVAL`);if(n+e<0)throw new h(`EINVAL`);return c=n+e,c}),flush:()=>u(p),close:()=>u(p)})}const zn=new Set([`proc-setpgid`,`proc-getpgid`,`proc-getsid`,`proc-setsid`]);function Bn(e){return zn.has(e.op)}function Vn(e){return e.op.startsWith(`sock-`)}function Hn(e){return e.op.startsWith(`fd-`)}function Un(e){return e.op.startsWith(`tty-`)}const Wn=new Set([`fd-read`,`fd-write`,`fd-close`,`fd-pipe`,`fd-poll`,`fd-open-vfs`,`fd-seek`,`fd-select`,`fd-info`,`fd-dup`,`fd-reserve`,`fd-renumber`,`fd-open-tty`,`tty-get`,`tty-set`,`tty-winsz`,`fd-flush`,`proc-spawn`,`proc-wait`,`proc-captured`,`proc-fork`,`proc-kill`,`proc-exec`,`proc-setpgid`,`proc-getpgid`,`proc-getsid`,`proc-setsid`,`tty-pgrp-get`,`tty-pgrp-set`,`sig-mask`,...Pn]);function Gn(e){let t=e.op;return typeof t==`string`&&Wn.has(t)}var Kn=class{pid;fds;options;exited=!1;children;caught=0;ignored=0;interrupt=new AbortController;execChild;execTermsig;stopped=0;stops=0;resumed=Promise.resolve();wake=()=>{};stateListeners=[];net;constructor(e,t,n={}){this.pid=e,this.fds=t,this.options=n,this.children=new kn(t,n.spawner,n.forker),this.children.onChildState=()=>this.signal(U.CHLD)}signal(e){if(this.execChild!==void 0)return Promise.resolve(this.options.kill?.(this.execChild,e)).catch(()=>void 0),e===U.KILL?`terminate`:`forward`;if(e===U.KILL)return`terminate`;if(e===U.CONT&&this.cont(),e===U.STOP)return this.stop(e);let t=W(e);if(this.ignored&t)return`ignore`;if(!(this.caught&t)){let t=vn(e);return t===`stop`?this.stop(e):t}this.options.onPending?.(e);let n=this.interrupt;return this.interrupt=new AbortController,n.abort(),`deliver`}onState(e){this.stateListeners.push(e)}stop(e){if(this.stopped)return`stop`;this.stopped=e,this.stops++,this.resumed=new Promise(e=>this.wake=e);let t=this.interrupt;this.interrupt=new AbortController,t.abort();for(let t of this.stateListeners)t(`stopped`,e);return`stop`}cont(){if(this.stopped){this.stopped=0,this.wake();for(let e of this.stateListeners)e(`continued`,U.CONT)}}async syscall(e){for(;;){await this.resumed;let t=this.stops,n=await this.dispatch(e);if(!(!n.ok&&n.errno===`EINTR`&&this.stops!==t&&!this.options.hasPending?.()))return await this.resumed,n}}async dispatch(e){try{return Hn(e)?await this.fdSyscall(e):Un(e)?this.ttySyscall(e):Bn(e)?this.jobSyscall(e):Vn(e)?await this.socketSyscall(e):await this.procSyscall(e)}catch(e){if(e instanceof h||e instanceof K)return{ok:!1,errno:e.code,message:e.code};throw e}}blockingSignal(){if(this.options.hasPending?.())throw new h(`EINTR`);return this.interrupt.signal}async read(e){let t=this.fds.get(e.fd).file,n=e.peek?t.peek:t.read;if(!n)throw new h(e.peek&&t.read?`EOPNOTSUPP`:`EBADF`);if(t.tty&&this.checkForeground(t.tty),e.max<=0)return new Uint8Array;let r=g(t).readable;if(!r&&e.nonblock)throw new h(`EAGAIN`);let i=r?this.interrupt.signal:this.blockingSignal();return n.call(t,Math.max(0,Math.min(e.max,1048576)),i)}async write(e,t,n=!1){let r=this.fds.get(e).file;if(!r.write)throw new h(`EBADF`);if(!g(r).writable){if(n)throw new h(`EAGAIN`);return r.write(t,this.blockingSignal())}return n?r.write(t,AbortSignal.abort()):r.write(t,this.options.hasPending?.()?AbortSignal.abort():this.interrupt.signal)}async fdSyscall(e){switch(e.op){case`fd-read`:return{ok:!0,kind:`bytes`,bytes:await this.read(e)};case`fd-write`:return{ok:!0,kind:`json`,json:await this.write(e.fd,e.body,e.nonblock)};case`fd-close`:return await Promise.resolve(this.fds.close(e.fd)),{ok:!0,kind:`void`};case`fd-pipe`:{let e=u(),t=this.fds.install(e.read,3),n;try{n=this.fds.install(e.write,3)}catch(e){throw await Promise.resolve(this.fds.close(t)),e}return{ok:!0,kind:`json`,json:[t,n]}}case`fd-poll`:return{ok:!0,kind:`json`,json:g(this.fds.get(e.fd).file)};case`fd-open-vfs`:{if(!this.options.fs)throw new K(`ENOSYS`);let t=Rn(this.options.fs,{path:e.path,flags:e.flags,position:e.position,...e.contents===void 0?{}:{contents:e.contents},...e.orphan?{orphan:!0}:{}});return{ok:!0,kind:`json`,json:this.fds.install(t,3)}}case`fd-info`:{let t=this.fds.get(e.fd).file,n=t instanceof B?`socket`:te(t);return{ok:!0,kind:`json`,json:{tty:t.tty!==void 0,kind:n}}}case`fd-dup`:return{ok:!0,kind:`json`,json:this.fds.dup(e.fd,e.min??3)};case`fd-reserve`:return{ok:!0,kind:`json`,json:this.reserve(e.fd)};case`fd-renumber`:return e.from!==e.to&&(this.fds.dup2(e.from,e.to),await Promise.resolve(this.fds.close(e.from))),{ok:!0,kind:`void`};case`fd-open-tty`:{let e=this.controllingTerminal();if(!e)throw new h(`ENXIO`);return{ok:!0,kind:`json`,json:this.fds.install(e.file(),3)}}case`fd-select`:{let{read:t,write:n,timeoutMs:r}=e,i=this.blockingSignal();return{ok:!0,kind:`json`,json:await Mn(this.fds,t,n,r,i)}}case`fd-seek`:{let t=this.fds.get(e.fd).file;if(!t.seek)throw new h(`ESPIPE`);return{ok:!0,kind:`json`,json:await t.seek(e.offset,e.whence)}}case`fd-flush`:{let t=this.fds.get(e.fd).file;return t.flush&&await t.flush(),{ok:!0,kind:`void`}}}}reserve(e){if(e===void 0)return this.fds.install(f(),3);if(this.fds.has(e))throw new h(`EBADF`);return this.fds.installAt(e,f()),e}ttySyscall(e){let t=this.tty(e.fd),n=this.options.jobs;switch(e.op){case`tty-get`:return{ok:!0,kind:`json`,json:t.tcgets()};case`tty-set`:return t.tcsets(e.termios),{ok:!0,kind:`void`};case`tty-winsz`:return{ok:!0,kind:`json`,json:t.winsize()};case`tty-pgrp-get`:return{ok:!0,kind:`json`,json:n?n.tcgetpgrp(t,this.sid()):this.pid};case`tty-pgrp-set`:if(n)n.tcsetpgrp(this.pid,t,e.pgrp);else if(e.pgrp!==this.pid)throw new h(`EPERM`);return{ok:!0,kind:`void`}}}checkForeground(e){let t=this.options.jobs;if(!t)return;let n=this.pgid();if(t.tcgetpgrp(e,this.sid())!==n)throw this.ignored&W(U.TTIN)?new h(`EIO`):(t.killGroup(n,U.TTIN),new h(`EINTR`))}waitGroup(e){let t=this.options.jobs;if(!t||e>0||e===-1)return;let n=e===0?this.pgid():-e;return e=>(t.pgidOf(e)??this.pgid())===n}pgid(){return this.options.jobs?.getpgid(this.pid,0)??this.pid}sid(){return this.options.jobs?.getsid(this.pid,0)??this.pid}controllingTerminal(){let e=this.options.jobs?.controllingTerminal(this.pid);return e===void 0?this.fds.stdioTerminal():e??void 0}jobSyscall(e){let t=this.options.jobs,n=e=>{if(e!==0&&e!==this.pid)throw new h(`ESRCH`);return this.pid};switch(e.op){case`proc-setpgid`:if(t)t.setpgid(this.pid,e.pid,e.pgid);else if(n(e.pid)!==(e.pgid||this.pid))throw new h(`EPERM`);return{ok:!0,kind:`void`};case`proc-getpgid`:return{ok:!0,kind:`json`,json:t?.getpgid(this.pid,e.pid)??n(e.pid)};case`proc-getsid`:return{ok:!0,kind:`json`,json:t?.getsid(this.pid,e.pid)??n(e.pid)};case`proc-setsid`:if(!t)throw new h(`EPERM`);return{ok:!0,kind:`json`,json:t.setsid(this.pid)}}}tty(e){let t=this.fds.get(e).file.tty;if(!t)throw new h(`ENOTTY`);return t}socketSyscall(e){return this.net??=this.options.net??new pn,Fn(e,{fds:this.fds,net:this.net,blocking:()=>this.blockingSignal()})}async procSyscall(e){switch(e.op){case`proc-fork`:return{ok:!0,kind:`json`,json:await this.children.fork(e.state)};case`proc-spawn`:{let{file:t,argv:n,env:r,cwd:i,stdio:a,inherit:o}=e;return{ok:!0,kind:`json`,json:await this.children.spawn({file:t,argv:n,env:r,cwd:i},a,o)}}case`proc-wait`:{let t=e.nohang?this.interrupt.signal:this.blockingSignal(),n={untraced:e.untraced,continued:e.continued,inGroup:this.waitGroup(e.pid)};return{ok:!0,kind:`json`,json:await this.children.wait(e.pid,e.nohang,t,n)}}case`proc-exec`:this.execChild=e.pid,this.options.jobs?.exec(this.pid,e.pid),this.children.watch(e.pid,(e,t)=>e===`stopped`?this.stop(t):this.cont()),await this.fds.closeAll();try{let t=await this.children.wait(e.pid,!1),n=t[1]&127;return n&&(this.execTermsig=n),{ok:!0,kind:`json`,json:t}}finally{this.execChild=void 0}case`proc-kill`:if(e.sig!==0&&!yn(e.sig))throw new h(`EINVAL`);if(!await this.options.kill?.(e.pid===0?-this.pgid():e.pid,e.sig))throw new h(`ESRCH`);return{ok:!0,kind:`void`};case`sig-mask`:return this.caught=e.caught,this.ignored=e.ignored,{ok:!0,kind:`void`};case`proc-captured`:return{ok:!0,kind:`bytes`,bytes:this.children.captured(e.pid,e.slot)}}}async exit(){this.exited||(this.exited=!0,await this.fds.closeAll())}};function qn(){return new Worker(new URL(`/assets/process-worker-7-U7pJ31.js`,``+import.meta.url),{type:`module`})}const Jn=new WeakMap;let Yn=1;function Xn(e){let t=Jn.get(e);return t===void 0&&Jn.set(e,t=Yn++),t}function Zn(e){return e.numbers().filter(t=>t>2&&!e.get(t).file.held).map(t=>{let n=e.get(t),r=e.statusFlags(t),i=n.file instanceof B?`socket`:te(n.file);return{fd:t,kind:i,...r===void 0?{}:{flags:r},...e.closesOnExec(t)?{cloexec:!0}:{},...i===`stream`?{desc:Xn(n)}:{}}})}function Qn(e){let t=new SharedArrayBuffer(64+le),n=new Int32Array(t,0,16),r=new Kn(e.pid,e.fds,{spawner:e.spawner,forker:e.forker,fs:e.fs,kill:e.kill,jobs:e.jobs,net:e.net,onPending:e=>void Atomics.or(n,8,W(e)),hasPending:()=>Atomics.load(n,8)!==0}),i=oe({fs:e.fs,cwd:e.cwd}),a=(e.createWorker??qn)(),o=ue(a,t,i,{dispatch:async e=>Gn(e)?r.syscall(e):`op`in e&&typeof e.op==`string`&&`path`in e?ce(e):{ok:!1,errno:`ENOSYS`,message:`wasm-realm: no exec yet`}}),s,c=new Promise(e=>s=e),l=!1,u,d=(e,t)=>{l||(l=!0,u=t??r.execTermsig,a.removeEventListener(`message`,f),a.removeEventListener(`error`,p),o.dispose(),se(i),a.terminate(),r.exit().then(()=>s(e),()=>s(e)))},f=t=>{let n=t.data;n?.type===`wasm-process-exit`?d(typeof n.code==`number`?n.code:70):n?.type===`wasm-process-error`&&(e.onError?.(String(n.message)),d(70))},p=t=>{t.preventDefault(),e.onError?.(String(t.message??`worker error`)),d(70)};a.addEventListener(`message`,f),a.addEventListener(`error`,p);let m={type:`wasm-process-init`,pid:e.pid,program:e.program,argv0:e.argv0,args:e.args,env:e.env,cwd:e.cwd,sab:t,...e.fork?{fork:e.fork}:{fds:Zn(e.fds)}};return a.postMessage(m,e.fork?[e.fork.memory.buffer]:[]),{pid:e.pid,exited:c,kill:(e=137)=>d(e,e>128&&e<160?e-128:void 0),signal:e=>{r.signal(e)===`terminate`&&d(e===U.KILL?137:128+e,e)},termsig:()=>u,onState:e=>r.onState(e)}}var $n=class{members=new Map;foreground=new Map;terminals=new Map;add(e,t,n,r){let i=t===void 0?void 0:this.members.get(t);!i&&r&&this.terminals.set(e,r);let a={pid:e,ppid:i?.pid,pgid:i?.pgid??e,sid:i?.sid??e,signal:n};return this.members.set(e,a),a}remove(e){this.members.delete(e)}exec(e,t){let n=this.members.get(t);n&&(n.execParent=e);let r=this.members.get(e);r&&(r.execed=!0)}pgidOf(e){return this.members.get(e)?.pgid}member(e){let t=this.members.get(e);if(!t)throw new h(`ESRCH`);return t}setpgid(e,t,n){let r=this.member(t||e),i=n||r.pid;if(i<0)throw new h(`EINVAL`);let a=this.member(e);if(r.pid!==e){if(r.ppid!==e)throw new h(`ESRCH`);if(r.execed)throw new h(`EACCES`)}if(r.sid!==a.sid||r.pid===r.sid)throw new h(`EPERM`);let o=[...this.members.values()].some(e=>e.pgid===i&&e.sid===r.sid);if(i!==r.pid&&!o)throw new h(`EPERM`);r.pgid=i}getpgid(e,t){return this.member(t||e).pgid}getsid(e,t){return this.member(t||e).sid}setsid(e){let t=this.member(e);if(t.pgid===e)throw new h(`EPERM`);return t.sid=e,t.pgid=e,this.terminals.delete(e),e}controllingTerminal(e){let t=this.members.get(e);return t&&(this.terminals.get(t.sid)??null)}killGroup(e,t){let n=[...this.members.values()].filter(t=>t.pgid===e),r=new Set(n.map(e=>e.pid));if(t!==0)for(let e of n)(e.execParent===void 0||!r.has(e.execParent))&&e.signal(t);return n.length>0}tcgetpgrp(e,t){return this.foreground.get(e)??t}tcsetpgrp(e,t,n){let r=this.member(e);if(![...this.members.values()].some(e=>e.pgid===n&&e.sid===r.sid))throw new h(`EPERM`);this.foreground.set(t,n)}signalForeground(e,t,n){this.killGroup(this.tcgetpgrp(e,t),n)}};function er(e,t){if(!e)return t;if(!(t.GIT_CONFIG_SYSTEM!==void 0&&rn(`GIT_CONFIG_SYSTEM`,t.GIT_CONFIG_SYSTEM))||!(`GIT_CONFIG_NOSYSTEM`in e))return{...e,...t};let{GIT_CONFIG_NOSYSTEM:n,...r}=e;return{...r,...t}}function tr(e,t){return!/^(ba)?sh$/.test(Z(e))||`BASH_FUNC_secret%%`in t?t:{...t,"BASH_FUNC_secret%%":`() { command secret "$@" || return; local __slicc_env; if __slicc_env=$(command secret shell-env "$@" 2>/dev/null); then eval "$__slicc_env"; fi; return 0; }`}}const Y=new Map,nr=new Map(Object.entries(G).map(([e,t])=>[t,e])),X=/^\/(?:usr\/)?bin\/([^/]+)$/,rr=/^(.*\/node_modules\/(?:@[^/]+\/)?[^/]+)\//,ir=/locateFile\(\s*["']([^"'/]+\.wasm)["']\s*\)/;let ar=4e4;function or(e){return e.glue===e.module}const sr=[0,97,115,109];function cr(e){return sr.every((t,n)=>e[n]===t)}function lr(e){return e.endsWith(`.js`)?`${e.slice(0,-3)}.wasm`:`${e}.wasm`}function ur(e){return X.exec(e)?.[1]??Z(e)}function Z(e){return e.slice(e.lastIndexOf(`/`)+1)}function dr(e){return{exists:t=>e.fs.exists(t),readDir:async t=>(await e.fs.readdir(t)).map(e=>({name:e})),readFile:t=>e.fs.readFile(t)}}function fr(e){return re(dr(e),ne)}function pr(e,t){return`${e}:${t.size}:${t.mtime.getTime()}`}function mr(e,t){return Y.set(e,t),t.catch(()=>Y.delete(e)),t}async function hr(e,t){let n=pr(t,await e.fs.stat(t));return Y.get(n)??mr(n,ae(t=>e.fs.readFileBuffer(t),t))}async function gr(e,t){let n;try{let r=await e.fs.stat(t);if(!r.isFile)return!1;n=pr(t,r)}catch{return!1}if(Y.has(n))return!0;let r;try{r=await e.fs.readFileBuffer(t)}catch{return!1}return cr(r)?(mr(n,ie(r)).catch(()=>void 0),!0):!1}function _r(e){let t=``;for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return t}function vr(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return t}async function yr(e){if(!e.file.read)return new Uint8Array;let t=[],n=0;for(let r=await e.file.read(65536);r.length>0;)t.push(r),n+=r.length,r=await e.file.read(65536);let r=new Uint8Array(n),i=0;for(let e of t)r.set(e,i),i+=e.length;return r}async function Q(e,t,n){if(n.length===0||!e.has(t))return;let r=e.get(t).file;try{await r.write?.(n)}catch{}}function $(e,t){return e.has(t)&&e.get(t).file.tty!==void 0}function br(e){return{...$(e,0)?{}:{[ee]:`0`},...$(e,1)?{}:{[m]:`0`}}}function xr(e){return{pid:e.pid,exited:e.exited,termsig:e.termsig,onState:t=>e.onState(t)}}var Sr=class{ctx;processConfig;onError;gate;lookup;live=new Set;shellChildren=new Set;wasmByPid=new Map;shellByPid=new Map;installed;jobs=new $n;leader;net;constructor(e,t,n,r,i){this.ctx=e,this.processConfig=t,this.onError=n,this.gate=r,this.lookup=i,this.net=hn(H(t?.owner));let a=H(t?.owner);on(this.net,{process:t,tls:{owner:a}})}commands(){return this.lookup?this.lookup():(this.installed??=fr(this.ctx),this.installed)}async launch(e){let t=or(e),n=``,r;try{t||(n=await this.ctx.fs.readFile(e.glue)),r=await hr(this.ctx,e.module),e.signal?.throwIfAborted()}catch(t){throw await e.fds.closeAll(),t}let i=tr(e.argv0,er(e.defaults,e.env));return this.start({...e,env:i,program:t?{abi:`wasi`,glue:n,module:r}:{glue:n,module:r}})}start(e){let t=this.processConfig?.processManager,{pid:n}=this.register(`wasm`,[e.argv0,...e.args],e.cwd,e.env,e.ppid),r=e.fds.stdioTerminal(),i=Qn({pid:n,program:e.program,argv0:e.argv0,args:e.args,env:e.env,cwd:e.cwd,fds:e.fds,fs:this.ctx.fs,onError:this.onError,spawner:this.spawner(n),forker:this.forker(n,e),kill:(e,t)=>this.kill(e,t),jobs:this.jobs,net:this.net,...e.fork?{fork:e.fork}:{}});this.live.add(i),this.wasmByPid.set(n,i),this.leader??=n,this.jobs.add(n,e.ppid,e=>i.signal(e),r);let a=t?.onSignal((e,t)=>{e.pid===n&&i.signal(G[t])});return i.exited.then(e=>{this.live.delete(i),this.wasmByPid.delete(n),this.jobs.remove(n),a?.(),this.processConfig&&t?.exit(n,e)}),i}kill(e,t){if(e<0)return this.jobs.killGroup(-e,t);let n=this.wasmByPid.get(e);if(n)return t!==0&&n.signal(t),!0;let r=this.shellByPid.get(e);if(r)return t!==0&&r(t),!0;let i=this.processConfig?.processManager;if(!i)return!1;if(t===0)return i.get(e)!==null;let a=nr.get(t);return a===void 0?!1:this.gate?this.killOutside(e,a):i.signal(e,a)}async killOutside(e,t){if(await this.gate?.(`kill`,[`-${t.slice(3)}`,String(e)],{}))throw new h(`EPERM`);return this.processConfig?.processManager.signal(e,t)??!1}listen(e){return new _(this.net.listen(e))}signalAll(e){for(let t of this.live)t.signal(e)}signalTerminal(e,t){this.leader!==void 0&&this.jobs.signalForeground(e,this.leader,t)}killAll(e){for(let t of this.live)t.kill(e);for(let e of this.shellChildren)e.abort()}async resolve(e,t,n){let r=X.exec(e)?.[1]??(e.includes(`/`)?void 0:e);if(r!==void 0){let e=await this.commands(),t=e.get(r);if(t)return{glue:t.glue,module:t.wasm,argv0:t.argv0,defaults:t.env};let n=r===`sh`?e.get(`bash`):void 0;return n&&{glue:n.glue,module:n.wasm,argv0:`sh`,defaults:n.env}}let i=this.ctx.fs.resolvePath(n,e);if(!await this.ctx.fs.exists(i))return;let a=lr(i);return await this.ctx.fs.exists(a)?{glue:i,module:a,argv0:Z(t||e)}:await gr(this.ctx,i)?{glue:i,module:i,argv0:Z(t||e).replace(/\.wasm$/,``)}:this.packagedCopy(i,t||e)}async packagedCopy(e,t){let n=rr.exec(e)?.[1];if(n===void 0)return;let r;try{r=await this.ctx.fs.readFile(e)}catch{return}let i=ir.exec(r)?.[1];if(i!==void 0){for(let e of(await this.commands()).values())if(e.wasm.startsWith(`${n}/`)&&e.wasm.endsWith(`/${i}`))return{glue:e.glue,module:e.wasm,argv0:Z(t),defaults:e.env}}}forker(e,t){return async(n,r)=>xr(this.start({...t,cwd:n.cwd??t.cwd,fds:r,ppid:e,fork:n}))}async interpreted(e){if(!e.file.includes(`/`)||X.test(e.file))return;let t;try{t=(await this.ctx.fs.readFileBuffer(this.ctx.fs.resolvePath(e.cwd,e.file))).subarray(0,256)}catch{return}if(t[0]!==35||t[1]!==33)return;let[n,...r]=new TextDecoder().decode(t).slice(2).split(`
|
|
12
|
+
`)[0].trim().split(/[ \t]+/);if(!n)return;let i=await this.resolve(n,n,e.cwd);if(!i)return;let a=r.join(` `);return{target:i,file:n,args:[...a?[a]:[],e.file,...e.argv.slice(1)]}}spawner(e){return async(t,n)=>{let r=await this.resolve(t.file,t.argv[0]??t.file,t.cwd),i=r?{target:r,file:t.file,args:t.argv.slice(1)}:await this.interpreted(t);if(!i)return this.runShellChild(t,n,e);let a=await this.gate?.(ur(i.file),i.args,t.env);return a?this.deniedChild(t,n,e,a):xr(await this.launch({...i.target,args:i.args,env:t.env,cwd:t.cwd,fds:n,ppid:e}))}}deniedChild(e,t,n,r){let{pid:i}=this.register(`shell`,e.argv,e.cwd,e.env,n),a=(async()=>(await Q(t,2,new TextEncoder().encode(r.stderr)),await t.closeAll(),r.exitCode))();return this.processConfig&&a.then(e=>this.processConfig?.processManager.exit(i,e)),{pid:i,exited:a}}runShellChild(e,t,n){let r=this.ctx.exec;if(!r)throw t.closeAll().catch(()=>void 0),new K(`ENOSYS`);let{pid:i,abort:a}=this.register(`shell`,e.argv,e.cwd,e.env,n),o=a??new AbortController,s=()=>o.abort();this.ctx.signal?.addEventListener(`abort`,s,{once:!0}),this.ctx.signal?.aborted&&s();let c,l=e=>{vn(e)===`terminate`&&(c??=e,o.abort())};this.shellChildren.add(o),this.shellByPid.set(i,l),this.jobs.add(i,n,l);let u=this.processConfig?.processManager.onSignal((e,t)=>{e.pid===i&&l(G[t])}),d=(async()=>{try{let n=$(t,0),i=t.has(0)&&!n?await yr(t.get(0)):new Uint8Array,a=await r(e.file,{args:e.argv.slice(1),cwd:e.cwd,env:{...e.env,...br(t)},replaceEnv:!0,stdin:_r(i),stdinKind:`bytes`,signal:o.signal});return await Q(t,1,a.stdoutKind===`bytes`?vr(a.stdout):new TextEncoder().encode(a.stdout)),await Q(t,2,new TextEncoder().encode(a.stderr)),a.exitCode}catch(n){let r=n instanceof Error?n.message:String(n);return await Q(t,2,new TextEncoder().encode(`${e.file}: ${r}\n`)),126}finally{await t.closeAll(),this.shellChildren.delete(o),this.shellByPid.delete(i),this.jobs.remove(i),u?.(),this.ctx.signal?.removeEventListener(`abort`,s)}})();return this.processConfig&&d.then(e=>this.processConfig?.processManager.exit(i,e)),{pid:i,exited:d,termsig:()=>c}}register(e,t,n,r,i){let a=this.processConfig;return a?a.processManager.spawn({kind:e,argv:t,cwd:n,env:r,owner:a.owner,ppid:i??a.getParentPid?.()}):{pid:ar++}}};const Cr=`usage: wasm [-t] [--argv0 NAME] [--module PATH] [--listen [HOST:]PORT] PROGRAM [ARGS...]
|
|
13
|
+
wasm --list
|
|
14
|
+
wasm --login
|
|
15
|
+
`;function wr(e){let t={},n=0;for(;;){if(e[n]===`-t`){t.tty=!0,n+=1;continue}if(e[n]===`--login-prompt`){t.login=!0,n+=1;continue}if(e[n]!==`--argv0`&&e[n]!==`--module`&&e[n]!==`--listen`)break;let r=e[n+1];if(r===void 0)return;e[n]===`--argv0`?t.argv0=r:e[n]===`--listen`?t.listen=r:t.module=r,n+=2}let r=e[n];if(!(!r||r.startsWith(`-`)))return{...t,program:r,args:e.slice(n+1)}}function Tr(e,t){return t.commands?.()??fr(e)}function Er(e){if(!e)return()=>{};let t=new TextDecoder;return n=>{let r=t.decode(n,{stream:!0});r&&e(r)}}function Dr(e,t,n,r){let i=[],a=e.limits?.maxOutputSize??268435456,o=0,l=!1,u=(e,n)=>r=>{if(o+=r.length,o>a){l=!0,t.killAll(1);return}e.push(r),n(r)},d=new s;return d.install(c(Rr(e))),d.install(p(u(i,Er(r)))),d.install(p(u(n,Er(r)))),{fds:d,collected:()=>({stdout:Lr(i),note:l?`wasm: output exceeded ${a} bytes; stopped\n`:``}),release:()=>{}}}function Or(e,t){let n=new wn({write:t=>e.write(t)},e=>t.signalTerminal(n,e));n.setSize(e.cols,e.rows),e.onInput(e=>n.receive(e)),e.onResize((e,t)=>n.resize(e,t));let r=n.file(),i=new s;return i.installAt(0,r),i.installAt(1,r.retain()),i.installAt(2,r.retain()),{fds:i,collected:()=>({stdout:``,note:``}),release:()=>e.release()}}function kr(e,t){return Object.fromEntries(Object.entries(e).filter(([e,n])=>e in t||!rn(e,n)))}async function Ar(e,t){let n=H(t.processConfig?.owner);return an(e.fs,Zt(jr(e),n),n)}function jr(e){return e.exportedEnv?.HOME??e.env.get(`HOME`)??`/tmp`}async function Mr(e,t){let n=await t.gitIdentity?.().catch(()=>void 0);return nn(e.fs,$t(jr(e)),n)}function Nr(e,t,n){let r={...n,...e.exportedEnv??Object.fromEntries(e.env)};return t.tty&&(!r.TERM||r.TERM===`dumb`)&&(r.TERM=`xterm-256color`,r.COLORTERM??=`truecolor`),t.login&&(r.PS1??=`\\w $ `,r.PROMPT_COMMAND??=fe),r}async function Pr(e,t){let n={stdout:``,stderr:``,exitCode:125};if((e.exportedEnv?.SLICC_SHELL??e.env.get(`SLICC_SHELL`))===`just-bash`||!t.terminal||typeof SharedArrayBuffer!=`function`||!(await Tr(e,t)).has(`bash`))return n;let r=c(new TextEncoder().encode(pe));return Ur([`-t`,`--login-prompt`,`bash`,`--rcfile`,`/dev/fd/98`,`-i`],e,{...t,fds:[[98,r]]})}function Fr(e){let t=[...e.values()].sort((e,t)=>e.name.localeCompare(t.name)),n=Math.max(0,...t.map(e=>e.name.length));return t.map(e=>`${e.name.padEnd(n)} ${e.pkg}\n`).join(``)}async function Ir(e,t,n){if(n.program.includes(`/`)||await e.fs.exists(e.fs.resolvePath(e.cwd,n.program)))return n;let r=(await t.commands()).get(n.program);return r?{...n,argv0:n.argv0??r.argv0,module:n.module??r.wasm,program:r.glue,defaults:r.env}:n}function Lr(e){let t=``;for(let n of e)for(let e=0;e<n.length;e+=32768)t+=String.fromCharCode(...n.subarray(e,e+32768));return t}function Rr(e){let t=de(e.stdin),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e)&255;return n}async function zr(e,t,n){return t.module?e.fs.resolvePath(e.cwd,t.module):await gr(e,n)?n:lr(n)}function Br(e){let t=/^(?:([0-9.]+):)?(\d{1,5})$/.exec(e),n=t?Number(t[2]):0;if(!(!t||n<1||n>65535))return{family:`inet`,host:t[1]??`127.0.0.1`,port:n}}function Vr(e,t,n){if(e.listen===void 0)return{env:{}};let r=Br(e.listen);if(!r)return{error:`--listen ${e.listen}: not a [HOST:]PORT\n`};try{let e=n.install(t.listen(r),3);return n.setStatusFlags(e,2048),{env:{SLICC_LISTEN_FDS:String(e)}}}catch(t){let n=t.code??String(t);return{error:`--listen ${e.listen}: ${n}\n`}}}function Hr(e,t){return e.defaults??t.defaults}async function Ur(e,t,n={}){let{processConfig:r,terminal:i}=n;if(e[0]===`--help`||e[0]===`-h`)return{stdout:Cr,stderr:``,exitCode:0};if(e[0]===`--login`&&e.length===1)return Pr(t,n);if(e[0]===`--list`&&e.length===1)return{stdout:Fr(await Tr(t,n)),stderr:``,exitCode:0};let a=wr(e);if(!a)return{stdout:``,stderr:Cr,exitCode:2};if(typeof SharedArrayBuffer!=`function`)return{stdout:``,stderr:`wasm: the wasm realm needs SharedArrayBuffer, which this page lacks (it is not cross-origin isolated)
|
|
16
|
+
`,exitCode:126};let o=[],s=e=>{o.push(new TextEncoder().encode(`wasm: ${e}\n`))},c=new Sr(t,r,e=>s(e),n.gate,n.commands),l=await Ir(t,c,a),u=t.fs.resolvePath(t.cwd,l.program),d=await zr(t,l,u),f;if(l.tty){let e=i?.lease();if(!e)return{stdout:``,stderr:`wasm: -t: no terminal to lend (only the panel terminal has one)
|
|
17
|
+
`,exitCode:1};f=Or(e,c),s=t=>e.write(new TextEncoder().encode(`wasm: ${t}\r\n`))}else f=Dr(t,c,o,n.onOutput);for(let[e,t]of n.fds??[])f.fds.installAt(e,t),f.fds.setCloseOnExec(e);let{fds:p}=f,m=Vr(l,c,p);if(`error`in m)return f.release(),await p.closeAll(),{stdout:``,stderr:`wasm: ${m.error}`,exitCode:1};let h;try{h=await c.launch({glue:u,module:d,argv0:l.argv0??u.slice(u.lastIndexOf(`/`)+1).replace(/\.(js|wasm)$/,``),args:l.args,env:{...Nr(t,l,{...Kt(),...await Ar(t,n),...await Mr(t,n)}),...m.env},defaults:Hr(l,n),cwd:t.cwd,fds:p,signal:t.signal})}catch(e){if(f.release(),t.signal?.aborted)return{stdout:``,stderr:``,exitCode:130};let n=e instanceof Error?e.message:String(e);return{stdout:``,stderr:`wasm: ${l.program}: ${n}\n`,exitCode:127}}let g=()=>c.killAll(130);t.signal?.addEventListener(`abort`,g,{once:!0}),t.signal?.aborted&&g();try{let e=await h.exited,{stdout:t,note:n}=f.collected();return n&&o.push(new TextEncoder().encode(n)),{stdout:t,stderr:new TextDecoder().decode(Wr(o)),exitCode:e,stdoutKind:`bytes`}}finally{f.release(),t.signal?.removeEventListener(`abort`,g)}}function Wr(e){let t=e.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}export{Ur as runWasmCommand,kr as withoutRealmDefaults};
|
|
@@ -42,7 +42,7 @@ Examples:
|
|
|
42
42
|
gelatiere suggest "$TMPDIR/candidates.json" && gelatiere deliver
|
|
43
43
|
gelatiere dismiss skill-github
|
|
44
44
|
gelatiere use-cases --limit 3 --json
|
|
45
|
-
`,i=[`--scoop`],a=[`--limit`],o=[...i,...a];function s(e){return{stdout:e,stderr:``,exitCode:0}}function c(e){return{stdout:``,stderr:`gelatiere: ${e}\n`,exitCode:1}}const l=`kernel host has not booted yet — try again in a moment`;function u(){let e=globalThis.__slicc_gelatiere;return e&&typeof e.roots==`function`?e:null}function d(){return import(`./gelatiere-store-
|
|
45
|
+
`,i=[`--scoop`],a=[`--limit`],o=[...i,...a];function s(e){return{stdout:e,stderr:``,exitCode:0}}function c(e){return{stdout:``,stderr:`gelatiere: ${e}\n`,exitCode:1}}const l=`kernel host has not booted yet — try again in a moment`;function u(){let e=globalThis.__slicc_gelatiere;return e&&typeof e.roots==`function`?e:null}function d(){return import(`./gelatiere-store-D-qUWaKm.js`)}async function f(t,n){let r=e(t,{bool:[`--reset`]});if(`error`in r)return c(r.error);let i=u();if(!i)return c(l);let a=await(await d()).loadGelatiereConfig(n),o=``;if(r.bools.has(`--reset`)){let e=await i.unregisterOwned();o=e.length?`Dropped ${e.length} gelatiere unit(s): ${e.join(`, `)}\n`:``}let f;try{f=await i.ensureUnit(a.allowedCommands)}catch(e){return c(e instanceof Error?e.message:String(e))}let m=await i.ensureNightly(a.nightly);return s(o+`${f.created?`Created`:`Found`} the gelatiere (${f.jid}, folder ${f.folder})\n`+p(f.allowList)+`${m.created?`Registered`:`Found`} nightly pass: cron "${m.cron}" (${m.id})\nSuggestions render in the suggestions card; \`gelatiere run\` asks for a pass now.
|
|
46
46
|
`)}function p(e){return e===`updated`?`Updated its command allow-list from GELATIERE.md
|
|
47
47
|
`:e===`deferred`?`Left its command allow-list alone: the gelatiere is mid-pass and applying it would
|
|
48
48
|
cancel the pass — run \`gelatiere init\` again once it is idle
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as e}from"./slicc-version-
|
|
1
|
+
import{n as e}from"./slicc-version-C_dEkbAr.js";import{a as t}from"./just-bash-compat-B-SPHuh_.js";const n=`/dev/null`;function r(e){return e.oldName===n}function i(e){return e.newName===n}function a(e){let t=e.indexOf(` `);return(t===-1?e.replace(/\s+\d{4}-\d\d-\d\d[ T].*$/,``):e.slice(0,t)).trimEnd()}const o=/^@@+ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/;function s(e){let t=o.exec(e);return t?{oldStart:Number(t[1]),oldCount:t[2]===void 0?1:Number(t[2]),newStart:Number(t[3]),newCount:t[4]===void 0?1:Number(t[4])}:null}function c(e,t){return{...e,oldLines:[],newLines:[],oldSeen:0,newSeen:0,changeSeen:!1,leadingContext:0,trailingContext:0,lastSide:null,oldNoNewlineAtEof:!1,newNoNewlineAtEof:!1,raw:[t]}}function l(e){return{oldStart:e.oldStart,newStart:e.newStart,oldLines:e.oldLines,newLines:e.newLines,leadingContext:e.leadingContext,trailingContext:e.trailingContext,oldNoNewlineAtEof:e.oldNoNewlineAtEof,newNoNewlineAtEof:e.newNoNewlineAtEof,raw:e.raw}}function u(e){return e.oldSeen>=e.oldCount&&e.newSeen>=e.newCount}function d(e,t){e.oldLines.push(t),e.newLines.push(t),e.oldSeen++,e.newSeen++,e.lastSide=`both`,e.changeSeen?e.trailingContext++:e.leadingContext++}function f(e,t,n){t===`old`?(e.oldLines.push(n),e.oldSeen++):(e.newLines.push(n),e.newSeen++),e.lastSide=t,e.changeSeen=!0,e.trailingContext=0}function p(e,t){if(t.startsWith(`\\`))return(e.lastSide===`old`||e.lastSide===`both`)&&(e.oldNoNewlineAtEof=!0),(e.lastSide===`new`||e.lastSide===`both`)&&(e.newNoNewlineAtEof=!0),e.raw.push(t),!0;if(t===``)return d(e,``),e.raw.push(` `),!0;let n=t.slice(1);switch(t[0]){case` `:d(e,n);break;case`-`:f(e,`old`,n);break;case`+`:f(e,`new`,n);break;default:return!1}return e.raw.push(t),!0}function m(e){e.hunk&&e.current&&e.current.hunks.push(l(e.hunk)),e.hunk=null,e.complete=!1}function h(e,t){let n=e.hunk;if(!n)return!1;if(e.complete){let r=t.startsWith(`\\`);return r&&p(n,t),m(e),r}return p(n,t)?(u(n)&&(e.complete=!0),!0):(m(e),!1)}function g(e){let t={files:[],current:null,hunk:null,complete:!1,pendingOld:null};for(let n of e.split(`
|
|
2
2
|
`)){if(h(t,n))continue;if(n.startsWith(`--- `)){t.pendingOld=a(n.slice(4));continue}if(n.startsWith(`+++ `)&&t.pendingOld!==null){t.current={oldName:t.pendingOld,newName:a(n.slice(4)),hunks:[]},t.files.push(t.current),t.pendingOld=null;continue}t.pendingOld=null;let e=s(n);e&&t.current&&(t.hunk=c(e,n))}return m(t),t.files.filter(e=>e.hunks.length>0)}function _(e){return{oldName:e.newName,newName:e.oldName,hunks:e.hunks.map(e=>({oldStart:e.newStart,newStart:e.oldStart,oldLines:e.newLines,newLines:e.oldLines,leadingContext:e.leadingContext,trailingContext:e.trailingContext,oldNoNewlineAtEof:e.newNoNewlineAtEof,newNoNewlineAtEof:e.oldNoNewlineAtEof,raw:v(e)}))}}function v(e){return e.raw.map((t,n)=>n===0?`@@ -${e.newStart},${e.newLines.length} +${e.oldStart},${e.oldLines.length} @@`:t.startsWith(`-`)?`+${t.slice(1)}`:t.startsWith(`+`)?`-${t.slice(1)}`:t)}function y(e){if(e===``)return{lines:[],newlineAtEof:!0};let t=e.endsWith(`
|
|
3
3
|
`),n=e.split(`
|
|
4
4
|
`);return t&&n.pop(),{lines:n,newlineAtEof:t}}function b(e){return e.lines.length===0?``:e.lines.join(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t as e}from"./record-COQlaFL1.js";import{t,u as n}from"./descriptor-CKLcFFX3.js";import{t as r}from"./subcommand-flags-BZi7j78Q.js";import{t as i}from"./subcommand-help-CgO7wRS5.js";import{a,r as o,t as s}from"./memory-budget-CFfevxz_.js";import{s as c}from"./kernel-worker-
|
|
1
|
+
import{t as e}from"./record-COQlaFL1.js";import{t,u as n}from"./descriptor-CKLcFFX3.js";import{t as r}from"./subcommand-flags-BZi7j78Q.js";import{t as i}from"./subcommand-help-CgO7wRS5.js";import{a,r as o,t as s}from"./memory-budget-CFfevxz_.js";import{s as c}from"./kernel-worker-CmBiahAZ.js";const l=`usage: memory <command> [options]
|
|
2
2
|
|
|
3
3
|
Durable cone memory: one file per cone, rewritten by the memory-curator
|
|
4
4
|
scoop after a chat freezes. This command inspects that system and pokes it.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./logger-LESFN7Hj.js";import{r as n}from"./global-prefix-DqCuANmV.js";import{n as r,r as i}from"./wasm-programs-
|
|
1
|
+
import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./logger-LESFN7Hj.js";import{r as n}from"./global-prefix-DqCuANmV.js";import{n as r,r as i}from"./wasm-programs-C7jo07yv.js";import{r as a,t as o}from"./jsh-discovery-CnvNKojr.js";const s=[`/workspace`,`/shared`];async function c(e){let t=[],n=new Set;for(let r of s)await e.exists(r)&&await l(e,r,t,n);return t}async function l(e,t,n,r){for await(let i of e.walk(t)){if(!i.endsWith(`.bsh`)||r.has(i))continue;r.add(i);let t=u(i);if(!t)continue;let a=await e.readFile(i,{encoding:`utf-8`}),o=d(typeof a==`string`?a:new TextDecoder().decode(a));n.push({path:i,hostnamePattern:t,matchPatterns:o})}}function u(e){let t=e.split(`/`).pop()??``;if(!t.endsWith(`.bsh`))return null;let n=t.slice(0,-4);return n?n.startsWith(`-.`)?`*`+n.slice(1):n:null}function d(e){let t=e.split(`
|
|
2
2
|
`).slice(0,10),n=[];for(let e of t){let t=e.match(/^\s*\/\/\s*@match\s+(.+)$/);t&&n.push(t[1].trim())}return n}function f(e,t){if(t.startsWith(`*.`)){let n=t.slice(1);return e===t.slice(2)||e.endsWith(n)&&e.length>n.length}return e===t}function p(e,t){try{let n=new URL(e),r=t.match(/^(\*|https?):\/\/([^/]+)(\/.*)?$/);if(!r)return!1;let[,i,a,o]=r;return i!==`*`&&n.protocol.slice(0,-1)!==i||!f(n.hostname,a)?!1:!o||m(n.pathname+n.search,o)}catch{return!1}}function m(e,t){let n=`^`+t.replace(/[.+^${}()|[\]\\]/g,`\\$&`).replace(/\*/g,`.*`)+`$`;return new RegExp(n).test(e)}function h(e,t){try{let n=new URL(t);return e.filter(e=>f(n.hostname,e.hostnamePattern)?e.matchPatterns.length>0?e.matchPatterns.some(e=>p(t,e)):!0:!1)}catch{return[]}}const g=t(`workflow-discovery`),_=`/workspace/.workflows`,v=`/workspace/skills`,y=[_,v],b=`.workflow.js`,x=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;async function S(e){let t=new Map;try{await e.exists(_)&&await C(e,t)}catch(e){g.warn(`workflow discovery: ${_} scan failed`,e)}try{await e.exists(v)&&await w(e,t)}catch(e){g.warn(`workflow discovery: ${v} scan failed`,e)}return t}async function C(e,t){for await(let n of e.walk(_)){if(!n.endsWith(b))continue;let e=T(n);if(!x.test(e)){g.warn(`skipping saved workflow with invalid command name: '${e}' (${n})`);continue}t.has(e)||t.set(e,{path:n,kind:`saved`})}}async function w(e,t){for await(let n of e.walk(v)){if(!n.endsWith(b))continue;let e=E(n);if(!e)continue;let r=T(n);if(!x.test(e)||!x.test(r)){g.warn(`skipping skill workflow with invalid name segment: '${e}:${r}' (${n})`);continue}let i=`${e}:${r}`;t.has(i)||t.set(i,{path:n,kind:`skill`,skill:e})}}function T(e){let t=e.split(`/`).pop()??e;return t.endsWith(b)?t.slice(0,-12):t}function E(e){let t=e.slice(18).split(`/`);return t.length>=3&&t[1]===`.workflows`?t[0]:null}function D(e,t){let n=!1,r=[],i=!1;for(let e of t){if(i){r.push(e);continue}if(e===`--`){i=!0;continue}if(e===`--wait`){n=!0;continue}r.push(e)}let a=[`workflow`,`run`,e];return n&&a.push(`--wait`),r.length===1?a.push(`--args`,O(r[0])):r.length>1&&a.push(`--args`,JSON.stringify(r)),a}function O(e){try{return JSON.parse(e),e}catch{return JSON.stringify(e)}}var k=e({ScriptCatalog:()=>V});const A=[`/workspace`,`/shared`];function j(e){return new Map(e)}function M(e){return{commands:j(e.commands),collisions:e.collisions.map(e=>({name:e.name,winnerPath:e.winnerPath,shadowedPaths:[...e.shadowedPaths],reason:e.reason}))}}function N(e){return new Map([...e].map(([e,t])=>[e,{...t}]))}function P(e){return new Map([...e].map(([e,t])=>[e,{...t}]))}function F(e){return e.map(e=>({...e,matchPatterns:[...e.matchPatterns]}))}function I(e){if(e&&typeof e.listMounts==`function`)return e;if(e&&typeof e.getUnderlyingFS==`function`){let t=e.getUnderlyingFS?.();if(t&&typeof t.listMounts==`function`)return t}return null}function L(e,t){return(I(e)?.listMounts?.()??[]).some(e=>t.some(t=>e===t||e.startsWith(`${t}/`)||t.startsWith(`${e}/`)))}function R(e){return e?(I(e)?.listMounts?.()??[]).some(e=>A.some(t=>e===t||e.startsWith(t+`/`))):!1}function z(){return{cache:null,inflight:null,generation:0}}function B(e){e.generation++,e.cache=null,e.inflight=null}var V=class{jshFs;bshFs;watcher;watcherUnsubs=[];jshByRoots=new Map;bsh=z();workflow=z();wasm=z();constructor(e){if(this.jshFs=e.jshFs,this.bshFs=e.bshFs,this.watcher=e.watcher??null,this.watcher&&(this.watcherUnsubs.push(this.watcher.watch(`/`,()=>!0,()=>{this.invalidateJsh(),this.invalidateWorkflows(),this.invalidateWasm()})),this.bshFs))for(let e of A)this.watcherUnsubs.push(this.watcher.watch(e,()=>!0,()=>this.invalidateBsh()))}dispose(){for(let e of this.watcherUnsubs)e();this.watcherUnsubs.length=0,this.invalidateAll()}invalidateAll(){this.invalidateJsh(),this.invalidateBsh(),this.invalidateWorkflows(),this.invalidateWasm()}invalidateJsh(){for(let e of this.jshByRoots.values())B(e)}invalidateBsh(){B(this.bsh)}invalidateWorkflows(){B(this.workflow)}invalidateWasm(){B(this.wasm)}async getJshIndex(e=o){return M(await this.loadJshIndex(e))}async getJshCommands(e=o){return(await this.getJshIndex(e)).commands}async getJshCommandNames(e){return[...(await this.getJshCommands(e)).keys()]}async getBshEntries(){return this.bshFs?F(await this.loadBshEntries()):[]}async findMatchingBshScripts(e){return this.bshFs?F(h(await this.loadBshEntries(),e)):[]}async getWorkflowCommands(){return N(await this.loadWorkflowCommands())}async getWasmCommands(){return P(await this.loadWasmCommands())}shouldCacheJsh(e){return!!this.watcher&&!L(this.jshFs,e)}shouldCacheBsh(){return!!this.watcher&&!!this.bshFs&&!R(this.bshFs)}shouldCacheWorkflows(){return!!this.watcher&&!L(this.jshFs,y)}shouldCacheWasm(){return!!this.watcher&&!L(this.jshFs,[n])}loadCached(e,t,n,r){if(t&&e.cache)return Promise.resolve(e.cache);if(!e.inflight){let i=e.generation,a=n().then(n=>{let a=r(n);return t&&e.generation===i&&(e.cache=a),a}).finally(()=>{e.inflight===a&&(e.inflight=null)});e.inflight=a}return e.inflight}loadJshIndex(e){let t=e.join(`:`),n=this.jshByRoots.get(t);n||(n=z(),this.jshByRoots.set(t,n));let r=[...e];return this.loadCached(n,this.shouldCacheJsh(r),()=>a(this.jshFs,r),M)}loadBshEntries(){if(!this.bshFs)return Promise.resolve([]);let e=this.bshFs;return this.loadCached(this.bsh,this.shouldCacheBsh(),()=>c(e),F)}loadWorkflowCommands(){return this.loadCached(this.workflow,this.shouldCacheWorkflows(),()=>S(this.jshFs),N)}loadWasmCommands(){let e=this.jshFs;return r(e)?this.loadCached(this.wasm,this.shouldCacheWasm(),()=>i(e,n),P):Promise.resolve(new Map)}};export{S as i,k as n,D as r,V as t};
|
package/dist/ui/assets/{session-command-memory-CK-bjU-i.js → session-command-memory-2oP0GfW4.js}
RENAMED
|
@@ -18,5 +18,5 @@ import{r as e,t}from"./subcommand-help-CgO7wRS5.js";const n=`session — export
|
|
|
18
18
|
usage: session search <query> [--limit N]
|
|
19
19
|
`}}function i(e,t,n){if(!e||e.startsWith(`-`))return{ok:!1,stderr:`session read: ${t} requires a number\n`};let r=Number(e);return!Number.isFinite(r)||r<n?{ok:!1,stderr:`session read: ${t} must be ${n===0?`a non-negative integer`:`a positive integer`}\n`}:{ok:!0,n:Math.floor(r)}}function a(e){let t=e.slice(1),n,r,a;for(let e=0;e<t.length;e++){let o=t[e];if(o===`--from`||o===`--count`){let n=i(t[e+1],o,o===`--from`?0:1);if(!n.ok)return n;o===`--from`?r=n.n:a=n.n,e++}else if(o.startsWith(`-`))return{ok:!1,stderr:`session read: unknown flag ${o}\n`};else if(n===void 0)n=o;else return{ok:!1,stderr:`session read: unexpected argument ${JSON.stringify(o)}\n`}}return n?{ok:!0,id:n,from:r,count:a}:{ok:!1,stderr:`session read: missing id
|
|
20
20
|
usage: session read <id> [--from N --count M]
|
|
21
|
-
`}}async function o(e,t){let n=r(e);if(!n.ok)return{stdout:``,stderr:n.stderr,exitCode:1};try{let{searchSessions:e}=await import(`./session-search-index-
|
|
22
|
-
`)}\n`,stderr:``,exitCode:0}}catch(e){return{stdout:``,stderr:`session search: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}async function s(e,t){let n=a(e);if(!n.ok)return{stdout:``,stderr:n.stderr,exitCode:1};try{let{readSessionHit:e,SESSION_READ_BYTE_CAP:r}=await import(`./session-search-index-
|
|
21
|
+
`}}async function o(e,t){let n=r(e);if(!n.ok)return{stdout:``,stderr:n.stderr,exitCode:1};try{let{searchSessions:e}=await import(`./session-search-index-BnZt5Q3i.js`),r=await e(t.fs,n.query,{limit:n.limit});if(r.length===0)return{stdout:`# session search: ${n.query} (0 hits)\nNo matching messages in /sessions.\n`,stderr:``,exitCode:0};let i=[`# session search: ${n.query} (${r.length} hits)`];for(let e of r)i.push(`id=${e.id} score=${e.score.toFixed(2)} kind=${e.echoKind} role=${e.role}`),i.push(` session=${JSON.stringify(e.sessionTitle)} path=${e.path}`),i.push(` ${e.excerpt}`),i.push(``);return i.push(`Use: session read <id> [--from N --count M]`),{stdout:`${i.join(`
|
|
22
|
+
`)}\n`,stderr:``,exitCode:0}}catch(e){return{stdout:``,stderr:`session search: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}async function s(e,t){let n=a(e);if(!n.ok)return{stdout:``,stderr:n.stderr,exitCode:1};try{let{readSessionHit:e,SESSION_READ_BYTE_CAP:r}=await import(`./session-search-index-BnZt5Q3i.js`),i=await e(t.fs,n.id,{from:n.from,count:n.count});return i?{stdout:`# session read: ${n.id}\npath=${i.hit.path} title=${JSON.stringify(i.hit.sessionTitle)}\nmessages ${i.from}–${i.from+i.count-1} of ${i.total} (remaining: ${i.remaining}${i.truncated?`, truncated to byte cap`:``})\nbyteCap=${r}\n\n`+i.text,stderr:``,exitCode:0}:{stdout:``,stderr:`session read: unknown id ${JSON.stringify(n.id)}\n`,exitCode:1}}catch(e){return{stdout:``,stderr:`session read: ${e instanceof Error?e.message:String(e)}\n`,exitCode:1}}}async function c(r,i,a,c){return r===`help`?{stdout:c?e(`session`,c,n):n,stderr:``,exitCode:0}:t(i.slice(1))?{stdout:e(`session`,r,n),stderr:``,exitCode:0}:r===`search`?o(i,a):s(i,a)}async function l(e,n,r){let{isMemoryV2Enabled:i}=await import(`./memory-v2-flag-Bw4vo1l_.js`),a=i();if(t(e)){if(!a)return{stdout:r,stderr:``,exitCode:0};let t=e[0];return c(`help`,e,n,t&&t!==`--help`&&t!==`-h`?t:void 0)}let o=e[0];return o===`search`||o===`read`?a?c(o,e,n):{stdout:``,stderr:`session export: unknown subcommand ${JSON.stringify(o)} — usage: session export [--id <id>] [--output <path>]\n`,exitCode:1}:a?{stdout:``,stderr:`session: unknown subcommand ${JSON.stringify(o??``)} — usage: session export|search|read (see session --help)\n`,exitCode:1}:{stdout:``,stderr:`session export: unknown subcommand ${JSON.stringify(o??``)} — usage: session export [--id <id>] [--output <path>]\n`,exitCode:1}}export{l as dispatchSessionMemoryAware};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{t as e}from"./types-D8gIX-W-.js";import{i as t,o as n}from"./kernel-worker-
|
|
1
|
+
import{t as e}from"./types-D8gIX-W-.js";import{i as t,o as n}from"./kernel-worker-CmBiahAZ.js";import"./frozen-archive-writer-BZ76mOLL.js";function r(e){let n=`${e.endsWith(`.md`)?e.slice(0,-3):e.replace(/\.md$/i,``)}.jsonl`;return n.startsWith(`/`)?n:`${t}/${n}`}async function i(e,t,r){let i=n(t);if(i.messages.length>0||!i.sidecar)return i;let a=await u(e,r??i.sidecar.replace(/\.jsonl$/i,`.md`));return a?{...i,messages:a}:i}function a(e){let t=[],n=null;for(let r of e.split(`
|
|
2
2
|
`)){let e=r.trim();if(!e)continue;let i=o(e);if(i){if(i.role===`user`)t.push(s(i)),n=null;else if(i.role===`assistant`){let e=c(i);t.push(e),n=e}else i.role===`toolResult`&&l(n,i)}}return t}function o(e){try{return JSON.parse(e)}catch{return null}}function s(e){return{id:e.id??m(`u`),role:`user`,content:f(e.content),timestamp:e.timestamp??0,...e.source?{source:e.source}:{},...e.channel?{channel:e.channel}:{},...e.attachments?.length?{attachments:e.attachments}:{}}}function c(e){let t=p(e.content);return{id:e.id??m(`a`),role:`assistant`,content:f(e.content),timestamp:e.timestamp??0,...t.length?{toolCalls:t}:{},...e.source?{source:e.source}:{},...e.compaction?{compaction:e.compaction}:{},...e.attachments?.length?{attachments:e.attachments}:{}}}function l(e,t){if(!t.toolCallId||!e?.toolCalls)return;let n=e.toolCalls.find(e=>e.id===t.toolCallId);n&&(n.result=f(t.content),t.isError&&(n.isError=!0))}async function u(t,n){let i=r(n);try{let e=await t.readFile(i,{encoding:`utf-8`});return a(typeof e==`string`?e:new TextDecoder().decode(e))}catch(t){if(t instanceof e&&t.code===`ENOENT`)return null;throw t}}async function d(t,n){let i=r(n);try{await t.rm(i)}catch(t){if(t instanceof e&&t.code===`ENOENT`)return;throw t}}function f(e){return typeof e==`string`?e:e.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
3
3
|
`)}function p(e){return typeof e==`string`?[]:e.filter(e=>e.type===`toolCall`).map(e=>({id:e.id,name:e.name,input:e.arguments}))}function m(e){return`${e}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`}export{i as loadFrozenArchive,d as removeSessionJsonl};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{Dt as t,at as n}from"./wc-shell-
|
|
1
|
+
import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{Dt as t,at as n}from"./wc-shell-BJTnAxDb.js";import{t as r}from"./slugify-BYJ6QVAt.js";import{t as i}from"./types-D8gIX-W-.js";var a=[{category:`jwt`,source:String.raw`ey[A-Za-z0-9_-]{4,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+`,flags:`g`},{category:`private-key`,source:`-----BEGIN [A-Z ]* PRIVATE KEY-----`+String.raw`[\s\S]*?`+`-----END [A-Z ]* PRIVATE KEY-----`,flags:`g`},{category:`bearer-token`,source:`Bearer [A-Za-z0-9._~+/=!-]+`,flags:`gi`},{category:`api-key`,source:`(?:sk-(?:live|test|prod|proj)-[A-Za-z0-9]{8,}|sk-ant-[A-Za-z0-9-]{8,}|xoxb-[A-Za-z0-9-]{10,}|xoxp-[A-Za-z0-9-]{10,}|AKIA[A-Z0-9]{16}|ghp_[A-Za-z0-9]{36}|hf_[A-Za-z0-9]{34})`,flags:`g`},{category:`password`,source:String.raw`\b(?:password|passwd|token|secret|api_key)\s*[=:]\s*\S+`,flags:`gi`}],o=`⟦REDACTED:[^⟧]*⟧`;function s(e,t){return e.start<t.end&&t.start<e.end}function c(e){let t=[];for(let n of e.matchAll(new RegExp(o,`g`))){let e=n.index;e!==void 0&&t.push({start:e,end:e+n[0].length})}return t}function l(e,t,n=1,r){let i=c(e),o=[],l=n,u=r?.categories?a.filter(e=>r.categories?.includes(e.category)):a;for(let{category:n,source:r,flags:a}of u)for(let c of e.matchAll(new RegExp(r,a))){let e=c.index;if(e===void 0)continue;let r={start:e,end:e+c[0].length};i.some(e=>s(e,r))||o.some(e=>s(e,r))||o.push({...r,id:`${t}${l++}`,category:n})}o.sort((e,t)=>e.start-t.start);let d=``,f=0;for(let{start:t,end:n,id:r,category:i}of o)d+=e.slice(f,t),d+=`⟦REDACTED:${i}:${r}⟧`,f=n;return d+=e.slice(f),{text:d,matches:o.map(({id:e,category:t})=>({id:e,category:t})),nextId:l}}var u=[`jwt`,`private-key`,`bearer-token`,`api-key`],d=`ar`;function f(){return{nextId:1}}function p(e,t){let{text:n,nextId:r}=l(e,d,t.nextId,{categories:u});return t.nextId=r,n}function m(e,t){if(typeof e==`string`)return p(e,t);if(Array.isArray(e)){let n=!1,r=[];for(let i of e){let e=m(i,t);e!==i&&(n=!0),r.push(e)}return n?r:e}if(typeof e==`object`&&e){let n=!1,r={};for(let[i,a]of Object.entries(e)){let e=m(a,t);e!==a&&(n=!0),r[i]=e}return n?r:e}return e}function h(e,t=f()){return m(e,t)}var g=`/sessions`,_=`/sessions/index.json`;async function ee(e){try{let t=await e.readFile(_,{encoding:`utf-8`}),n=typeof t==`string`?t:new TextDecoder().decode(t),r=JSON.parse(n);return Array.isArray(r)?r:[]}catch{return[]}}function v(e){return`${g}/${e.filename}`}function y(e){let t=e,n=`Untitled`,r={},i=t.match(/^---\n([\s\S]*?)\n---\n+/);if(i){t=t.slice(i[0].length),Object.assign(r,te(i[1]));let e=i[1].match(/^title:\s*(.+?)\s*$/m);e&&(n=b(e[1]))}let a=t.match(/<!-- slicc:session-data\n([\s\S]*?)\n-->\n*/);if(a){try{let e=a[1].replace(/-- >/g,`-->`),t=JSON.parse(e);if(Array.isArray(t))return{title:n,messages:t,...r}}catch{}t=t.replace(/<!-- slicc:session-data\n[\s\S]*?\n-->\n*/,``)}return r.sidecar?{title:n,messages:[],...r}:(t=t.replace(/^#\s+[^\n]*\n+/,``),{title:n,messages:S(t),...r})}function te(e){let t={},n=x(e,`cost`),r=x(e,`models`);n&&(t.cost=n),r&&(t.models=r);let i=e.match(/^cone:\s*(.+?)\s*$/m)?.[1];i&&(t.cone=i);let a=e.match(/^coneLabel:\s*(.+?)\s*$/m)?.[1];a&&(t.coneLabel=b(a)),/^memorySkipped:\s*true\s*$/m.test(e)&&(t.memorySkipped=!0),/^live:\s*true\s*$/m.test(e)&&(t.live=!0);let o=Number(e.match(/^liveThrough:\s*(\d+)\s*$/m)?.[1]);Number.isFinite(o)&&o>0&&(t.liveThrough=o);let s=Number(e.match(/^compactions:\s*(\d+)\s*$/m)?.[1]);Number.isFinite(s)&&s>0&&(t.compactions=s);let c=Number(e.match(/^curatedThrough:\s*(\d+)\s*$/m)?.[1]);Number.isFinite(c)&&c>0&&(t.curatedThrough=c);let l=e.match(/^id:\s*(\S+)\s*$/m)?.[1];l&&(t.id=l);let u=e.match(/^sidecar:\s*(\S+)\s*$/m)?.[1];return u&&(t.sidecar=u),t}function b(e){let t=e.trim();if(!t.startsWith(`"`))return t;try{let e=JSON.parse(t);if(typeof e==`string`)return e}catch{}return t.replace(/^"|"$/g,``)}function x(e,t){let n=RegExp(`^${t}:\\s*(.+?)\\s*$`,`m`).exec(e)?.[1];if(n)try{return JSON.parse(n)}catch{return}}function S(e){let t=[],n=/^## (User|Assistant)\s*\n/gm,r=[],i;for(;(i=n.exec(e))!==null;)r.push({role:i[1]===`User`?`user`:`assistant`,start:i.index,bodyStart:i.index+i[0].length});for(let n=0;n<r.length;n++){let i=n+1<r.length?r[n+1].start:e.length,a=e.slice(r[n].bodyStart,i).trim();t.push({id:`frozen-${n}`,role:r[n].role,content:a,timestamp:0})}return t}function C(e){let r=``;for(let i of e){let e=i.role===`user`?`User`:`Assistant`,a=i.role===`user`?n(i.content):i.content;if(r+=`## ${e}\n${a}\n\n`,i.attachments?.length&&(r+=`Attachments:\n${i.attachments.map(e=>`- ${t(e)}`).join(`
|
|
2
2
|
`)}\n\n`),i.toolCalls)for(let e of i.toolCalls)r+=`### Tool: ${e.name}\nInput: ${JSON.stringify(e.input,null,2)}\nResult: ${e.result??``}\n\n`}return r}var ne=`<!-- slicc:session-data
|
|
3
3
|
`,re=`
|
|
4
4
|
-->`;function w(e){return e.startsWith(`pending-`)||e.startsWith(`live-`)}function T(e,t){return e.find(e=>e.live===!0&&(e.cone??`cone`)===t)}function E(){return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`}function D(e){return r(e,{maxLen:48,fallback:`session`})}var O=`untitled-session`,k=RegExp(`^(?:_Forwarded from .+?\\._\\s*)*(?:\\[@\\S+ (?:completed|idle|sudo-request|FAILED)\\b|\\[scoop_wait\\b|\\[(?:${[`Webhook Event`,`Sprinkle Event`,`File Watch Event`,`Session Reload`,`Navigate Event`,`Upgrade Event`,`Cherry Event`,`Workflow Event`,`Background Command`,`jshd Unit`,`Cron Event`,`Scoop Access Request`,`Preview Event`,`Preview event`,`Discovery Event`].join(`|`)})\\b|Preview tab (?:connected|disconnected) from |<context-summary\\b)`);function ie(e){return e.slice(0,480).trim().replace(/\s+/g,` `).slice(0,240)}function ae(e){let t=ie(e);return t.length>0&&k.test(t)}function oe(e){return e.role!==`user`||!e.content?.trim()||e.source===`lick`||e.channel?!1:!ae(e.content)}function se(e){let t=e.find(oe);if(!t?.content)return O;let n=t.content.trim().replace(/\s+/g,` `);return n.length>60?`${n.slice(0,60)}…`:n||O}function A(e){return e.map(e=>{let t={id:e.id,role:e.role,content:e.content,timestamp:e.timestamp};return e.attachments?.length&&(t.attachments=e.attachments),e.toolCalls?.length&&(t.toolCalls=e.toolCalls.map(e=>({id:e.id,name:e.name,input:e.input,...e.result===void 0?{}:{result:e.result},...e.isError?{isError:e.isError}:{}}))),e.source&&(t.source=e.source),e.channel&&(t.channel=e.channel),e.compaction&&(t.compaction=e.compaction),t})}function ce(e,t,n){return!t||t===n?e:e.split(t).join(n)}function j(e){let t=f(),n={...e,title:p(e.title,t),messages:h(e.messages,t)},r=(n.cost?`cost: ${JSON.stringify(n.cost)}\n`:``)+(n.models?`models: ${JSON.stringify(n.models)}\n`:``),i=(n.cone?`cone: ${n.cone}\n`:``)+(n.coneLabel?`coneLabel: ${JSON.stringify(n.coneLabel)}\n`:``)+(n.memorySkipped?`memorySkipped: true
|
package/dist/ui/assets/{session-search-index-Ddwbbkut.js → session-search-index-BnZt5Q3i.js}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{i as e,s as t}from"./kernel-worker-
|
|
1
|
+
import{i as e,s as t}from"./kernel-worker-CmBiahAZ.js";import{loadFrozenArchive as n}from"./session-jsonl-CAjcgY95.js";const r=`/sessions/.search-index.json`,i=12e3,a=4e3;async function o(e,t){return typeof e.readdir==`function`?e.readdir(t):typeof e.readDir==`function`?(await e.readDir(t)).map(e=>e.name):[]}const s={fields:[`title`,`body`],storeFields:[`title`,`body`,`sessionId`,`sessionTitle`,`filename`,`messageId`,`messageIndex`,`role`,`echoKind`,`path`],idField:`id`,processTerm:e=>{let t=e.toLowerCase();return t.length<2?null:j(t)},searchOptions:{boost:{title:4,body:1},prefix:!0}},c={original:1,summary:.35,echo:.15};function l(e){if(e.compaction)return`summary`;let t=e.content??``;return/<context-summary>/i.test(t)||/Earlier conversation messages were compacted/i.test(t)||/full transcript of the conversation before this compaction is saved at/i.test(t)?`summary`:/^# session (search|read):/m.test(t)||/\bid=sess\/[^\s]+/.test(t)||e.role===`assistant`&&e.toolCalls?.some(e=>e.name===`bash`&&typeof e.input==`object`&&e.input!==null&&/session\s+(search|read)\b/.test(String(e.input.command??``)))?`echo`:`original`}function u(e,t){return`sess/${e}/msg/${t}`}function d(e){let t=/^sess\/([^/]+)\/msg\/(.+)$/.exec(e);return t?{sessionId:t[1],messageId:t[2]}:null}function f(e){let t=`${e.sessionsDir??`/sessions`}/${e.filename}`,n=[];return e.messages.forEach((r,i)=>{let o=r.id||`i${i}`,s=[k(r.content??``,a)];for(let e of r.toolCalls??[])s.push(e.name,k(A(e.input),a)),e.result&&s.push(k(e.result,a));let c=k(s.filter(Boolean).join(`
|
|
2
2
|
`),a);!c.trim()&&!r.compaction||n.push({id:u(e.sessionId,o),title:e.sessionTitle,body:c,sessionId:e.sessionId,sessionTitle:e.sessionTitle,filename:e.filename,messageId:o,messageIndex:i,role:r.role,echoKind:l(r),path:t})}),n}const p=`/scoops`;async function m(e){let t;try{t=await o(e,p)}catch{return[]}let n=[];for(let r of t)try{let t=await o(e,`${p}/${r}/sessions`);for(let e of t)n.push(`${p}/${r}/sessions/${e}`)}catch{}return n.sort()}async function h(n){let r=(await t(n)).map(t=>({entry:t,sessionsDir:e}));for(let e of await m(n))for(let t of await g(n,e))r.push({entry:t,sessionsDir:e});return r}async function g(e,t){try{let n=await e.readFile(`${t}/index.json`,{encoding:`utf-8`}),r=typeof n==`string`?n:new TextDecoder().decode(n),i=JSON.parse(r);return Array.isArray(i)?i:[]}catch{return[]}}async function _(e){let t=(await import(`./es-BR4l6CGS.js`)).default,n=await h(e),i=[],a=new Set;for(let{entry:t,sessionsDir:r}of n)for(let n of await x(e,t,r))a.has(n.id)||(a.add(n.id),i.push(n));let o=new t(s);i.length&&o.addAll(i);let c={version:1,builtAt:Date.now(),archiveCount:n.length,fingerprint:C(n)};return await e.writeFile(r,JSON.stringify({meta:c,index:o.toJSON()})),{docs:i.length,archives:n.length}}async function v(e){let t=(await import(`./es-BR4l6CGS.js`)).default,n=C(await h(e));try{let i=await e.readFile(r,{encoding:`utf-8`}),a=typeof i==`string`?i:new TextDecoder().decode(i),o=JSON.parse(a);if(o.meta?.fingerprint===n&&o.index)return t.loadJS(o.index,s)}catch{}await _(e);let i=await e.readFile(r,{encoding:`utf-8`}),a=typeof i==`string`?i:new TextDecoder().decode(i),o=JSON.parse(a);return t.loadJS(o.index,s)}async function y(e,t,n={}){let r=Math.min(Math.max(1,n.limit??8),20),i=t.trim();if(!i)return[];let a=await v(e),o=a.search(i,{boost:{title:4,body:1},prefix:!0}),s=[];for(let e of o){let t=a.getStoredFields(e.id);if(!t)continue;let n=t.echoKind??`original`,r=e.score*(c[n]??1);s.push({id:String(e.id),score:r,echoKind:n,sessionId:t.sessionId,sessionTitle:t.sessionTitle,filename:t.filename,messageId:t.messageId,messageIndex:t.messageIndex,role:t.role,path:t.path,excerpt:w(t.body,i)})}return s.sort((e,t)=>t.score-e.score),s.slice(0,r)}async function b(e,t,n={}){let r=d(t);if(!r)return null;let i=await h(e),a=i.find(({entry:e})=>e.sessionId===r.sessionId)??i.find(({entry:e})=>e.filename.replace(/\.md$/i,``)===r.sessionId);if(!a)return null;let{entry:o,sessionsDir:s}=a,c=await S(e,o,s),l=c.findIndex((e,t)=>(e.id||`i${t}`)===r.messageId),u=Math.max(0,n.from??Math.max(0,l)),f=Math.max(1,n.count??3),p=c.slice(u,u+f),m=T(p,u),g=!1;for(;O(m)>12e3&&p.length>1;)p=p.slice(0,-1),m=T(p,u),g=!0;O(m)>12e3&&(m=`${k(m,11980)}\n…[truncated]\n`,g=!0);let _=p.length,v=Math.max(0,c.length-(u+_));return{hit:{sessionId:o.sessionId??r.sessionId,messageId:r.messageId,sessionTitle:o.title,path:`${s}/${o.filename}`},messages:p,from:u,count:_,total:c.length,remaining:v,truncated:g,text:m}}async function x(t,n,r=e){let i=await S(t,n,r);return f({sessionId:n.sessionId??n.filename.replace(/\.md$/i,``),sessionTitle:n.title,filename:n.filename,messages:i,sessionsDir:r})}async function S(t,r,i=e){try{let e=`${i}/${r.filename}`,a=await t.readFile(e,{encoding:`utf-8`}),o=typeof a==`string`?a:new TextDecoder().decode(a);return(await n(t,o,e)).messages}catch{return[]}}function C(e){return e.map(({entry:e,sessionsDir:t})=>`${t}/${e.filename}:${e.messageCount}:${e.frozenAt}:${e.sessionId??``}`).sort().join(`|`)}function w(e,t,n=80){let r=e.replace(/\s+/g,` `).trim();if(!r)return``;let i=t.toLowerCase().split(/\s+/).filter(e=>e.length>1),a=-1;for(let e of i)if(a=r.toLowerCase().indexOf(e),a>=0)break;if(a<0)return r.slice(0,n*2)+(r.length>n*2?`…`:``);let o=Math.max(0,a-n),s=Math.min(r.length,a+n);return`${o>0?`…`:``}${r.slice(o,s)}${s<r.length?`…`:``}`}function T(e,t){let n=[];return e.forEach((e,r)=>{let i=t+r,a=e.id||`i${i}`;n.push(`## [${i}] ${e.role} id=${a}`),e.content&&n.push(e.content);for(let t of e.toolCalls??[])n.push(`### tool ${t.name} (${t.id})${t.isError?` ERROR`:``}`),n.push(A(t.input)),t.result&&n.push(t.result);n.push(``)}),n.join(`
|
|
3
3
|
`)}async function E(e){try{await e.rm(r)}catch{}}const D=new TextEncoder;function O(e){return D.encode(e).byteLength}function k(e,t){if(t<=0)return``;let n=D.encode(e);if(n.byteLength<=t)return e;let r=t;for(;r>0&&(n[r]&192)==128;)r--;return new TextDecoder().decode(n.subarray(0,r))}function A(e){try{return JSON.stringify(e)}catch{return String(e)}}function j(e){if(e.length<3)return e;let t=e;if(t.endsWith(`sses`)||t.endsWith(`ies`)?t=`${t.slice(0,-2)}`:t.endsWith(`ss`)||t.endsWith(`s`)&&t.length>3&&(t=t.slice(0,-1)),t.endsWith(`eed`))M(t.slice(0,-3))>0&&(t=t.slice(0,-1));else if(/(ed|ing)$/.test(t)){let e=t.replace(/(ed|ing)$/,``);/[aeiouy]/.test(e)&&(t=e,/(at|bl|iz)$/.test(t)?t=`${t}e`:/(.)\1$/.test(t)&&!/[lsz]$/.test(t)?t=t.slice(0,-1):M(t)===1&&N(t)&&(t=`${t}e`))}return t.endsWith(`y`)&&/[aeiouy]/.test(t.slice(0,-1))&&(t=`${t.slice(0,-1)}i`),t}function M(e){return(e.toLowerCase().replace(/[^aeiouy]+/g,`C`).replace(/[aeiouy]+/g,`V`).replace(/^C/,``).replace(/V$/,``).match(/VC/g)??[]).length}function N(e){if(e.length<3)return!1;let t=e[e.length-3],n=e[e.length-2],r=e[e.length-1],i=e=>/[aeiouy]/.test(e);return!i(t)&&i(n)&&!i(r)&&!/[wxy]/.test(r)}export{i as SESSION_READ_BYTE_CAP,E as invalidateSessionSearchIndex,b as readSessionHit,y as searchSessions};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{l as e}from"./feature-flags-DvsApnS-.js";import{A as t,_ as n,g as r,j as i,k as a}from"./main-
|
|
1
|
+
import{l as e}from"./feature-flags-DvsApnS-.js";import{A as t,_ as n,g as r,j as i,k as a}from"./main-8USr6q37.js";var o=3e3;async function s(n,r){let i=a(r.storage);try{let a=new URL(`/api/flags`,`${r.workerBaseUrl.replace(/\/+$/,``)}/`);a.searchParams.set(`float`,n);let s=await c(a.toString(),r.fetchImpl??fetch,r.timeoutMs??o);if(!s)return;t(i,n,s),e(n,s)}catch{}}async function c(e,t,n){let r=new AbortController,i;try{let a=new Promise(e=>{i=setTimeout(()=>{r.abort(),e(null)},n)}),o=t(e,{cache:`no-store`,headers:{Accept:`application/json`},signal:r.signal}).then(async e=>e.ok?l(await e.json()):null).catch(()=>null);return await Promise.race([o,a])}catch{return null}finally{i!==void 0&&clearTimeout(i)}}function l(e){if(!u(e))return null;let t=e.flags;return!u(t)||Object.values(t).some(e=>typeof e!=`string`)?null:t}function u(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function d(e,t){return s(e,{workerBaseUrl:g(t),storage:t.storage})}var f=18e5,p=null;function m(e,t,n=f){return h(),p=setInterval(()=>{d(e,t)},n),h}function h(){p!==null&&(clearInterval(p),p=null)}function g(e){let t=_(e.storage),a=i(e.envBaseUrl??null);if(t)return t;if(a)return a;if(!e.isDev)try{let t=new URL(e.locationHref);if(t.protocol===`http:`||t.protocol===`https:`)return t.origin}catch{}return e.isDev?n:r}function _(e){try{return i(e?.getItem(`slicc.trayWorkerBaseUrl`)??null)}catch{return null}}export{d as refreshFeatureFlagsForPage,g as resolveFeatureFlagsWorkerBaseUrl,m as scheduleFeatureFlagsRefresh};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,n as t,r as n,s as r,t as i}from"./core-CbbeQz7g.js";import{i as a}from"./compat-Dy2zIWAW.js";import{t as o}from"./logger-DDBAeTLF.js";import{a as s}from"./feature-flags-DvsApnS-.js";import{w as c}from"./account-store-
|
|
1
|
+
import{c as e,n as t,r as n,s as r,t as i}from"./core-CbbeQz7g.js";import{i as a}from"./compat-Dy2zIWAW.js";import{t as o}from"./logger-DDBAeTLF.js";import{a as s}from"./feature-flags-DvsApnS-.js";import{w as c}from"./account-store-CPtYzXW6.js";import{resolveFeatureFlagsWorkerBaseUrl as l}from"./setup-feature-flags-remote-CVKiJ3Dt.js";var u=`/api/models/providers/`,d=4e3,f=2e3;function p(e){let t=Array.isArray(e)?e:r(e)&&Array.isArray(n(e,`models`))?n(e,`models`):r(e)?Object.values(e):null;return t?t.filter(e=>r(e)&&typeof n(e,`id`)==`string`).slice(0,f):null}async function m(e,t,n,r){let i=new AbortController,a=setTimeout(()=>i.abort(),r);try{return await e(t,{...n,signal:i.signal})}finally{clearTimeout(a)}}async function h(e,t,n){if(!n.force&&t?.checkedAt!==void 0&&n.now-t.checkedAt<144e5)return{kind:`skip`};let r=new URL(`${u}${encodeURIComponent(e)}`,`${n.workerBaseUrl.replace(/\/+$/,``)}/`).toString(),i=t?.models.length?t.etag:void 0,a;try{a=await m(n.fetchImpl,r,{headers:{Accept:`application/json`,...i?{"If-None-Match":i}:{}}},n.timeoutMs)}catch{return{kind:`failed`,entry:t?{...t,checkedAt:n.now}:void 0}}if(a.status===304&&t)return{kind:`stored`,entry:{...t,checkedAt:n.now},changed:!1};if(a.status===404)return{kind:`stored`,entry:{models:[],checkedAt:n.now,lastModified:0},changed:!0};if(!a.ok)return{kind:`failed`,entry:t?{...t,checkedAt:n.now}:void 0};let o;try{o=p(await a.json())}catch{o=null}if(!o)return{kind:`failed`,entry:t};let s=Date.parse(a.headers.get(`last-modified`)??``),c={models:o,checkedAt:n.now,lastModified:Number.isNaN(s)?0:s},l=a.headers.get(`etag`);return l&&(c.etag=l),{kind:`stored`,entry:c,changed:!0}}async function g(n){let r={updated:[],failed:[]};if(!s(`live-model-catalog`))return r;let o=n.storage===void 0?t():n.storage;if(!o)return r;let c=new Set(a()),l=[...new Set(n.providers)].filter(e=>c.has(e));if(l.length===0)return r;let u=(n.now??Date.now)(),f={workerBaseUrl:n.workerBaseUrl,fetchImpl:n.fetchImpl??fetch,timeoutMs:n.timeoutMs??d,force:n.force===!0,now:u},p=e(o).store,m=await Promise.all(l.map(async e=>[e,await h(e,p[e],f)])),g={...e(o).store},_=!1;for(let[e,t]of m)t.kind!==`skip`&&(t.entry&&(g[e]=t.entry,_=!0),t.kind===`failed`?r.failed.push(e):t.changed&&r.updated.push(e));if(_)try{o.setItem(i,JSON.stringify(g))}catch{}return r}var _=o(`model-catalog`),v=36e5,y=null;async function b(e,t=!1){let n=await g({workerBaseUrl:l(e),providers:c(),storage:e.storage,force:t});return n.updated.length>0&&_.info(`Model catalogue refreshed`,{providers:n.updated}),n.failed.length>0&&_.debug(`Model catalogue refresh failed`,{providers:n.failed}),n}function x(e,t=v){return S(),y=setInterval(()=>{b(e)},t),b(e)}function S(){y!==null&&(clearInterval(y),y=null)}export{x as setupModelCatalog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,t}from"./base64-BPBW1Gzr.js";import{t as n}from"./mime-types-D7IV6i7k.js";import{t as r}from"./types-D8gIX-W-.js";import{n as i}from"./multipart-form-data-DopbgwRR.js";const a=`https://api.aem.live`;function o(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 s(e){if(!e)return``;let t=Date.parse(e);return Number.isNaN(t)?``:String(t)}function c(e){let t=Date.parse(e??``);return Number.isNaN(t)?0:t}function l(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:s(e[`last-modified`]),lastModified:c(e[`last-modified`])})}var u=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=o(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??5242880,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new r(`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:a,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 i=await this.request(`GET`,this.toSourcePath(t));if(i.status===404)throw await this.cache.invalidateBody(t),new r(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new r(`EACCES`,`aem access denied`,e);if(i.status>=400)throw new r(`EIO`,`aem readFile failed: ${i.status}`,e);let a=new Uint8Array(await i.arrayBuffer());if(a.byteLength>this.maxBodyBytes)throw new r(`EFBIG`,`body exceeds maxBodyBytes`,e);return await this.cache.putBody(t,a,s(i.headers.get(`last-modified`))),a}async assertUnchanged(e,t,n){if(!n)return;let i=await this.request(`HEAD`,this.toSourcePath(t));if(i.status===404)return;if(i.status>=400)throw new r(`EIO`,`aem precondition HEAD failed: ${i.status}`,e);let a=s(i.headers.get(`last-modified`));if(a&&a!==n)throw await this.cache.invalidateBody(t),new r(`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 r(`EFBIG`,`body exceeds maxBodyBytes`,e);let n=this.toMountRelative(e),i=await this.cache.getBody(n);await this.assertUnchanged(e,n,i?.etag??``);let a=await this.request(`PUT`,this.toSourcePath(n),{body:t});if(a.status===401||a.status===403)throw new r(`EACCES`,`aem write denied`,e);if(a.status>=400)throw new r(`EIO`,`aem writeFile failed: ${a.status}`,e);await this.cache.invalidateBody(n);let o=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o)}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 i=await this.request(`GET`,this.toListPath(t));if(i.status===404)throw new r(`ENOENT`,`no such directory`,e);if(i.status===401||i.status===403)throw new r(`EACCES`,`aem access denied`,e);if(i.status>=400)throw new r(`EIO`,`aem list failed: ${i.status}`,e);let a=l(await i.json());return await this.cache.putListing(t,a),a}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 i=t.split(`/`),a=i.pop()??``,o=i.join(`/`),s=await this.cache.getListing(o),c=(s&&!this.cache.isStale(s.cachedAt)?s.entries:await this.readDirQuietly(o))?.find(e=>e.name===a);if(!c)throw new r(`ENOENT`,`no such file or directory`,e);return c.kind===`directory`?{kind:`directory`,size:0,mtime:c.lastModified??0}:{kind:`file`,size:c.size??0,mtime:c.lastModified??0,etag:c.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 r(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new r(`EACCES`,`aem delete denied`,e);if(n.status>=400)throw new r(`EIO`,`aem delete failed: ${n.status}`,e);await this.cache.invalidateBody(t);let i=t.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(i)}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=l(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 d(e,t,n){let r=i([{name:`data`,file:{bytes:n,filename:e,contentType:t}}]);return{contentType:r.contentType,body:r.bytes}}function f(e){return e.split(`/`).pop()||`data`}function p(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 m=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=p(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??5242880,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new r(`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 i={};n&&(i[`if-none-match`]=n.etag);let a=await this.transport({method:`GET`,path:this.toSourcePath(t),headers:i});if(a.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(a.status===404)throw await this.cache.invalidateBody(t),new r(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new r(`EACCES`,`da access denied`,e);if(a.status>=400)throw new r(`EIO`,`da readFile failed: ${a.status}`,e);let o=a.headers.get(`content-length`),s=o?Number(o):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new r(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new r(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=a.headers.get(`etag`)??``,u=l.startsWith(`W/`)?l.slice(2):l;return await this.cache.putBody(t,c,u),c}async writeFile(e,t){if(this.assertOpen(e),t.byteLength>this.maxBodyBytes)throw new r(`EFBIG`,`body exceeds maxBodyBytes`,e);let i=this.toMountRelative(e),a=await this.cache.getBody(i),o=d(f(e),n(e),t),s={"content-type":o.contentType,"content-length":String(o.body.byteLength)};a?.etag?s[`if-match`]=a.etag.startsWith(`W/`)?a.etag.slice(2):a.etag:a||(s[`if-none-match`]=`*`);let c=()=>this.transport({method:`POST`,path:this.toSourcePath(i),headers:s,body:o.body}),l,u=1;try{l=await c()}catch{u=2,l=await c()}if(l.status===412){if(u===2){let n=await this.transport({method:`HEAD`,path:this.toSourcePath(i)});if(n.status>=400)throw new r(`EIO`,`da reconcile HEAD failed: ${n.status}`,e);let a=n.headers.get(`etag`)??``;await this.cache.putBody(i,t,a);let o=i.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(i);try{await this.readFile(e)}catch{}throw new r(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(l.status===401||l.status===403)throw new r(`EACCES`,`da write denied`,e);if(l.status>=400)throw new r(`EIO`,`da writeFile failed: ${l.status}`,e);let p=l.headers.get(`etag`)??``;await this.cache.putBody(i,t,p);let m=i.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(m)}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 i=await this.transport({method:`GET`,path:this.toListPath(t)});if(i.status===404)throw new r(`ENOENT`,`no such directory`,e);if(i.status>=400)throw new r(`EIO`,`da list failed: ${i.status}`,e);let a=(await i.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,a),a}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 i=t.split(`/`),a=i.pop()??``,o=i.join(`/`),s=await this.cache.getListing(o);if(s&&!this.cache.isStale(s.cachedAt)){let t=s.entries.find(e=>e.name===a);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??s.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??s.cachedAt};if(!t)throw new r(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,path:this.toSourcePath(t)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`),r=n?Date.parse(n):0;if(s){let n=s.entries.map(n=>n.name===a&&n.kind===`file`?{...n,size:e,etag:t,lastModified:r}:n);await this.cache.putListing(o,n)}return{kind:`file`,size:e,mtime:r,etag:t}}if(c.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new r(`ENOENT`,`no such file or directory`,e)}throw new r(`EIO`,`da stat failed: ${c.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 r(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new r(`EACCES`,`da delete denied`,e);if(n.status>=400)throw new r(`EIO`,`da delete failed: ${n.status}`,e);await this.cache.invalidateBody(t);let i=t.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(i)}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 h(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 g=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=h(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??26214400,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new r(`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 i={};n&&(i[`if-none-match`]=n.etag);let a=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:this.toS3Key(t),headers:i});if(a.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(a.status===404)throw await this.cache.invalidateBody(t),new r(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new r(`EACCES`,`s3 access denied`,e);if(a.status>=400)throw new r(`EIO`,`s3 readFile failed: ${a.status}`,e);let o=a.headers.get(`content-length`),s=o?Number(o):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new r(`EFBIG`,`body exceeds maxBodyBytes (${s} > ${this.maxBodyBytes})`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new r(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=a.headers.get(`etag`)??``;return await this.cache.putBody(t,c,l),c}async writeFile(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t.byteLength>this.maxBodyBytes)throw new r(`EFBIG`,`body exceeds maxBodyBytes`,e);let i=await this.cache.getBody(n),a={"content-type":`application/octet-stream`,"content-length":String(t.byteLength)};i?a[`if-match`]=i.etag:a[`if-none-match`]=`*`;let o=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(n),headers:a,body:t}),s,c=1;try{s=await o()}catch{c=2,s=await o()}if(s.status===412){if(c===2){let i=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(i.status>=400)throw new r(`EIO`,`s3 reconcile HEAD failed: ${i.status}`,e);let a=i.headers.get(`etag`)??``;await this.cache.putBody(n,t,a);let o=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new r(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(s.status===401||s.status===403)throw new r(`EACCES`,`s3 write denied`,e);if(s.status>=400)throw new r(`EIO`,`s3 writeFile failed: ${s.status}`,e);let l=s.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 i=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:``,query:n});if(i.status>=400)throw new r(`EIO`,`s3 list failed: ${i.status}`,`/`);let a=await i.text(),o=this.parseListingXml(a);e.push(...o.contents),t=o.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 i=t.split(`/`),a=i.pop()??``,o=i.join(`/`),s=await this.cache.getListing(o);if(s&&!this.cache.isStale(s.cachedAt)){let t=s.entries.find(e=>e.name===a);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??s.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??s.cachedAt};if(!t)throw new r(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(t)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`);return{kind:`file`,size:e,mtime:n?Date.parse(n):0,etag:t}}if(c.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new r(`ENOENT`,`no such file or directory`,e)}throw new r(`EIO`,`s3 stat failed: ${c.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 r(`EINVAL`,`recursive remove not yet supported on S3`,e);let i=await this.transport({method:`DELETE`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(i.status===404)throw new r(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new r(`EACCES`,`s3 delete denied`,e);if(i.status>=400)throw new r(`EIO`,`s3 delete failed: ${i.status}`,e);await this.cache.invalidateBody(n);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a)}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}},_=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function v(){let{getAccounts:e}=await import(`./account-store-BAcqOQ-B.js`).then(e=>e.t),t=e().find(e=>e.providerId===`adobe`);if(!t?.accessToken)throw new _(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>t.accessToken}}let y;function b(e){y=e}function x(){return y}const S=t,C=e,w=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),T=new Set([101,103,204,205,304]);function E(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new r(`EACCES`,e.error):e.errorCode===`invalid_request`?new r(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||w.has(String(e.errorCode))?new r(`EIO`,e.error):new r(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=S(e.bodyBase64)}catch(e){throw new r(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let n=T.has(e.status)?null:t;return new Response(n,{status:e.status,headers:new Headers(e.headers)})}function D(e,t){return t===void 0?e===`node-rest`?` (SLICC backend at localhost may not be running)`:e===`extension-direct`||e===`extension-delegate`?` (extension service worker not responding)`:``:``}async function O(e){let t=x();if(!t)throw new r(`EIO`,`mount transport unavailable: setMountCapabilityBroker was never called for this float (composition bug — refusing to guess a transport for a privileged sign-and-forward request)`);let n=await t.mounts.signRequest(e);if(!n.ok){let e=`status`in n?n.status:void 0;throw new r(`EIO`,`mount transport failed: ${n.message}${D(t.adapter,e)}`)}return n.value}function k(e){return async t=>E(await O({backend:`s3`,envelope:{profile:e,method:t.method,bucket:t.bucket,key:t.key,query:t.query,headers:t.headers,bodyBase64:t.body?C(t.body):void 0}}))}function A(e){let t=e?.getImsToken??(async()=>(await v()).getBearerToken());return async e=>{let n;try{n=await t()}catch(e){throw new r(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}return E(await O({backend:`da`,envelope:{imsToken:n,method:e.method,path:e.path,origin:e.origin,query:e.query,headers:e.headers,bodyBase64:e.body?C(e.body):void 0}}))}}export{m as a,g as i,k as n,a as o,b as r,u as s,A as t};
|
|
1
|
+
import{r as e,t}from"./base64-BPBW1Gzr.js";import{t as n}from"./mime-types-D7IV6i7k.js";import{t as r}from"./types-D8gIX-W-.js";import{n as i}from"./multipart-form-data-DopbgwRR.js";const a=`https://api.aem.live`;function o(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 s(e){if(!e)return``;let t=Date.parse(e);return Number.isNaN(t)?``:String(t)}function c(e){let t=Date.parse(e??``);return Number.isNaN(t)?0:t}function l(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:s(e[`last-modified`]),lastModified:c(e[`last-modified`])})}var u=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=o(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??5242880,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new r(`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:a,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 i=await this.request(`GET`,this.toSourcePath(t));if(i.status===404)throw await this.cache.invalidateBody(t),new r(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new r(`EACCES`,`aem access denied`,e);if(i.status>=400)throw new r(`EIO`,`aem readFile failed: ${i.status}`,e);let a=new Uint8Array(await i.arrayBuffer());if(a.byteLength>this.maxBodyBytes)throw new r(`EFBIG`,`body exceeds maxBodyBytes`,e);return await this.cache.putBody(t,a,s(i.headers.get(`last-modified`))),a}async assertUnchanged(e,t,n){if(!n)return;let i=await this.request(`HEAD`,this.toSourcePath(t));if(i.status===404)return;if(i.status>=400)throw new r(`EIO`,`aem precondition HEAD failed: ${i.status}`,e);let a=s(i.headers.get(`last-modified`));if(a&&a!==n)throw await this.cache.invalidateBody(t),new r(`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 r(`EFBIG`,`body exceeds maxBodyBytes`,e);let n=this.toMountRelative(e),i=await this.cache.getBody(n);await this.assertUnchanged(e,n,i?.etag??``);let a=await this.request(`PUT`,this.toSourcePath(n),{body:t});if(a.status===401||a.status===403)throw new r(`EACCES`,`aem write denied`,e);if(a.status>=400)throw new r(`EIO`,`aem writeFile failed: ${a.status}`,e);await this.cache.invalidateBody(n);let o=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o)}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 i=await this.request(`GET`,this.toListPath(t));if(i.status===404)throw new r(`ENOENT`,`no such directory`,e);if(i.status===401||i.status===403)throw new r(`EACCES`,`aem access denied`,e);if(i.status>=400)throw new r(`EIO`,`aem list failed: ${i.status}`,e);let a=l(await i.json());return await this.cache.putListing(t,a),a}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 i=t.split(`/`),a=i.pop()??``,o=i.join(`/`),s=await this.cache.getListing(o),c=(s&&!this.cache.isStale(s.cachedAt)?s.entries:await this.readDirQuietly(o))?.find(e=>e.name===a);if(!c)throw new r(`ENOENT`,`no such file or directory`,e);return c.kind===`directory`?{kind:`directory`,size:0,mtime:c.lastModified??0}:{kind:`file`,size:c.size??0,mtime:c.lastModified??0,etag:c.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 r(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new r(`EACCES`,`aem delete denied`,e);if(n.status>=400)throw new r(`EIO`,`aem delete failed: ${n.status}`,e);await this.cache.invalidateBody(t);let i=t.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(i)}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=l(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 d(e,t,n){let r=i([{name:`data`,file:{bytes:n,filename:e,contentType:t}}]);return{contentType:r.contentType,body:r.bytes}}function f(e){return e.split(`/`).pop()||`data`}function p(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 m=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=p(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??5242880,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new r(`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 i={};n&&(i[`if-none-match`]=n.etag);let a=await this.transport({method:`GET`,path:this.toSourcePath(t),headers:i});if(a.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(a.status===404)throw await this.cache.invalidateBody(t),new r(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new r(`EACCES`,`da access denied`,e);if(a.status>=400)throw new r(`EIO`,`da readFile failed: ${a.status}`,e);let o=a.headers.get(`content-length`),s=o?Number(o):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new r(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new r(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=a.headers.get(`etag`)??``,u=l.startsWith(`W/`)?l.slice(2):l;return await this.cache.putBody(t,c,u),c}async writeFile(e,t){if(this.assertOpen(e),t.byteLength>this.maxBodyBytes)throw new r(`EFBIG`,`body exceeds maxBodyBytes`,e);let i=this.toMountRelative(e),a=await this.cache.getBody(i),o=d(f(e),n(e),t),s={"content-type":o.contentType,"content-length":String(o.body.byteLength)};a?.etag?s[`if-match`]=a.etag.startsWith(`W/`)?a.etag.slice(2):a.etag:a||(s[`if-none-match`]=`*`);let c=()=>this.transport({method:`POST`,path:this.toSourcePath(i),headers:s,body:o.body}),l,u=1;try{l=await c()}catch{u=2,l=await c()}if(l.status===412){if(u===2){let n=await this.transport({method:`HEAD`,path:this.toSourcePath(i)});if(n.status>=400)throw new r(`EIO`,`da reconcile HEAD failed: ${n.status}`,e);let a=n.headers.get(`etag`)??``;await this.cache.putBody(i,t,a);let o=i.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(i);try{await this.readFile(e)}catch{}throw new r(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(l.status===401||l.status===403)throw new r(`EACCES`,`da write denied`,e);if(l.status>=400)throw new r(`EIO`,`da writeFile failed: ${l.status}`,e);let p=l.headers.get(`etag`)??``;await this.cache.putBody(i,t,p);let m=i.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(m)}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 i=await this.transport({method:`GET`,path:this.toListPath(t)});if(i.status===404)throw new r(`ENOENT`,`no such directory`,e);if(i.status>=400)throw new r(`EIO`,`da list failed: ${i.status}`,e);let a=(await i.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,a),a}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 i=t.split(`/`),a=i.pop()??``,o=i.join(`/`),s=await this.cache.getListing(o);if(s&&!this.cache.isStale(s.cachedAt)){let t=s.entries.find(e=>e.name===a);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??s.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??s.cachedAt};if(!t)throw new r(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,path:this.toSourcePath(t)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`),r=n?Date.parse(n):0;if(s){let n=s.entries.map(n=>n.name===a&&n.kind===`file`?{...n,size:e,etag:t,lastModified:r}:n);await this.cache.putListing(o,n)}return{kind:`file`,size:e,mtime:r,etag:t}}if(c.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new r(`ENOENT`,`no such file or directory`,e)}throw new r(`EIO`,`da stat failed: ${c.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 r(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new r(`EACCES`,`da delete denied`,e);if(n.status>=400)throw new r(`EIO`,`da delete failed: ${n.status}`,e);await this.cache.invalidateBody(t);let i=t.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(i)}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 h(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 g=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=h(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??26214400,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new r(`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 i={};n&&(i[`if-none-match`]=n.etag);let a=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:this.toS3Key(t),headers:i});if(a.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(a.status===404)throw await this.cache.invalidateBody(t),new r(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new r(`EACCES`,`s3 access denied`,e);if(a.status>=400)throw new r(`EIO`,`s3 readFile failed: ${a.status}`,e);let o=a.headers.get(`content-length`),s=o?Number(o):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new r(`EFBIG`,`body exceeds maxBodyBytes (${s} > ${this.maxBodyBytes})`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new r(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=a.headers.get(`etag`)??``;return await this.cache.putBody(t,c,l),c}async writeFile(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t.byteLength>this.maxBodyBytes)throw new r(`EFBIG`,`body exceeds maxBodyBytes`,e);let i=await this.cache.getBody(n),a={"content-type":`application/octet-stream`,"content-length":String(t.byteLength)};i?a[`if-match`]=i.etag:a[`if-none-match`]=`*`;let o=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(n),headers:a,body:t}),s,c=1;try{s=await o()}catch{c=2,s=await o()}if(s.status===412){if(c===2){let i=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(i.status>=400)throw new r(`EIO`,`s3 reconcile HEAD failed: ${i.status}`,e);let a=i.headers.get(`etag`)??``;await this.cache.putBody(n,t,a);let o=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new r(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(s.status===401||s.status===403)throw new r(`EACCES`,`s3 write denied`,e);if(s.status>=400)throw new r(`EIO`,`s3 writeFile failed: ${s.status}`,e);let l=s.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 i=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:``,query:n});if(i.status>=400)throw new r(`EIO`,`s3 list failed: ${i.status}`,`/`);let a=await i.text(),o=this.parseListingXml(a);e.push(...o.contents),t=o.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 i=t.split(`/`),a=i.pop()??``,o=i.join(`/`),s=await this.cache.getListing(o);if(s&&!this.cache.isStale(s.cachedAt)){let t=s.entries.find(e=>e.name===a);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??s.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??s.cachedAt};if(!t)throw new r(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(t)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`);return{kind:`file`,size:e,mtime:n?Date.parse(n):0,etag:t}}if(c.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new r(`ENOENT`,`no such file or directory`,e)}throw new r(`EIO`,`s3 stat failed: ${c.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 r(`EINVAL`,`recursive remove not yet supported on S3`,e);let i=await this.transport({method:`DELETE`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(i.status===404)throw new r(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new r(`EACCES`,`s3 delete denied`,e);if(i.status>=400)throw new r(`EIO`,`s3 delete failed: ${i.status}`,e);await this.cache.invalidateBody(n);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a)}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}},_=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function v(){let{getAccounts:e}=await import(`./account-store-Cl-FqDg2.js`).then(e=>e.t),t=e().find(e=>e.providerId===`adobe`);if(!t?.accessToken)throw new _(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>t.accessToken}}let y;function b(e){y=e}function x(){return y}const S=t,C=e,w=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),T=new Set([101,103,204,205,304]);function E(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new r(`EACCES`,e.error):e.errorCode===`invalid_request`?new r(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||w.has(String(e.errorCode))?new r(`EIO`,e.error):new r(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=S(e.bodyBase64)}catch(e){throw new r(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let n=T.has(e.status)?null:t;return new Response(n,{status:e.status,headers:new Headers(e.headers)})}function D(e,t){return t===void 0?e===`node-rest`?` (SLICC backend at localhost may not be running)`:e===`extension-direct`||e===`extension-delegate`?` (extension service worker not responding)`:``:``}async function O(e){let t=x();if(!t)throw new r(`EIO`,`mount transport unavailable: setMountCapabilityBroker was never called for this float (composition bug — refusing to guess a transport for a privileged sign-and-forward request)`);let n=await t.mounts.signRequest(e);if(!n.ok){let e=`status`in n?n.status:void 0;throw new r(`EIO`,`mount transport failed: ${n.message}${D(t.adapter,e)}`)}return n.value}function k(e){return async t=>E(await O({backend:`s3`,envelope:{profile:e,method:t.method,bucket:t.bucket,key:t.key,query:t.query,headers:t.headers,bodyBase64:t.body?C(t.body):void 0}}))}function A(e){let t=e?.getImsToken??(async()=>(await v()).getBearerToken());return async e=>{let n;try{n=await t()}catch(e){throw new r(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}return E(await O({backend:`da`,envelope:{imsToken:n,method:e.method,path:e.path,origin:e.origin,query:e.query,headers:e.headers,bodyBase64:e.body?C(e.body):void 0}}))}}export{m as a,g as i,k as n,a as o,b as r,u as s,A as t};
|
package/dist/ui/assets/{silent-renew-backoff-BL8wMKQc.js → silent-renew-backoff-aQDTrjJz.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./bridge-protocol-C52CnDIj.js";import{M as e}from"./main-
|
|
1
|
+
import"./bridge-protocol-C52CnDIj.js";import{M as e}from"./main-8USr6q37.js";function t(t){try{let n=new URL(t);return n.searchParams.has(`bridge`)?!0:!e(n.hostname)}catch{return!1}}function n(n,r){let i=t(n.pageHref),a=r();if(i){if(n.configuredRedirectUri){let t=``;try{t=new URL(n.configuredRedirectUri).origin}catch{t=``}if(t&&n.pageOrigin===t){let e=btoa(JSON.stringify({source:`opener`,path:`/auth/callback`,nonce:a}));return{redirectUri:n.configuredRedirectUri,oauthState:e,expectedNonce:a,source:`opener`}}let r=null;try{r=new URL(n.pageHref)}catch{r=null}if(r!==null&&r.protocol===`http:`&&e(r.hostname)&&r.port!==``&&r){let e=parseInt(r.port,10),t=btoa(JSON.stringify({source:`local`,port:e,path:`/auth/callback`,nonce:a}));return{redirectUri:n.configuredRedirectUri,oauthState:t,expectedNonce:a,source:`local`}}}return{redirectUri:`${n.pageOrigin}/auth/callback`,oauthState:btoa(JSON.stringify({source:`opener`,path:`/auth/callback`,nonce:a})),expectedNonce:a,source:`opener`}}let o=n.configuredRedirectUri??`${n.pageOrigin}/auth/callback`,s=parseInt(new URL(n.pageHref).port||`5710`,10);return{redirectUri:o,oauthState:btoa(JSON.stringify({port:s,path:`/auth/callback`,nonce:a})),expectedNonce:a,source:`local`}}var r=3e5;function i(e=r){let t=0;return{async run(n,r=Date.now()){if(r<t)return null;let i=null;try{i=await n()}catch(e){console.debug(`[silent-renew-backoff] renew threw:`,e instanceof Error?e.message:String(e)),i=null}return t=i?0:r+e,i},inCooldown(e=Date.now()){return e<t}}}export{n,t as r,i as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(){return{version:`6.220.0`,releasedAt:`2026-09-29T20:02:53Z`,buildId:`6.220.0-mun3sn3m`}}let t=null;function n(e){t=e}function r(){return t}export{e as n,n as r,r as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./panel-rpc-DW7W4w6_.js";import{m as t}from"./state-
|
|
1
|
+
import{r as e}from"./panel-rpc-DW7W4w6_.js";import{m as t}from"./state-e2oZ6Uk0.js";function n(e,t=``){if(e==null)return t;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return String(e);try{return JSON.stringify(e)??t}catch{return String(e)}}function r(e){return e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/\n/g,`\\n`)}function i(e){return e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}const a=[`none`,`presentation`,`generic`,`rootwebarea`],o=[`textbox`,`button`,`link`,`checkbox`,`radio`];function s(e,t){return a.includes(e)?!1:!!t||o.includes(e)}function c(e,t){let n=i(t);return e===`button`&&t?[`button[aria-label="${n}"]`,`button[title="${n}"]`,`[role="button"][aria-label="${n}"]`,`[role="button"][title="${n}"]`,`input[type="button"][value="${n}"]`,`input[type="submit"][value="${n}"]`,`input[type="reset"][value="${n}"]`].join(`, `):e===`link`&&t?`a[aria-label="${n}"], a[title="${n}"], [role="link"][aria-label="${n}"], [role="link"][title="${n}"]`:e===`textbox`?t?`input[aria-label="${n}"], textarea[aria-label="${n}"], [contenteditable][aria-label="${n}"], input[placeholder="${n}"], textarea[placeholder="${n}"], [contenteditable][placeholder="${n}"], input[title="${n}"], textarea[title="${n}"], [contenteditable][title="${n}"]`:`input, textarea, [contenteditable]`:e===`checkbox`?`input[type="checkbox"]`:e===`radio`?`input[type="radio"]`:t?`[aria-label="${n}"], [title="${n}"]`:`[role="${e}"]`}function l(e,t,i,a,o=``,u=``){let d=[],f=n(e.role,`unknown`).toLowerCase(),p=n(e.name),m=n(e.value),h=``;s(f,p)&&(h=u+`e${++a.value}`,e.backendNodeId&&i.set(h,e.backendNodeId),t.set(h,c(f,p)));let g=`${o}- ${f}`;if(p&&(g+=` "${r(p)}"`),h&&(g+=` [ref=${h}]`),m&&(g+=`: "${r(m)}"`),d.push(g),e.children)for(let n of e.children)d.push(...l(n,t,i,a,o+` `,u));return d}async function u(e,t){if(t.appTabId)return;let n=await e.listPages(),r=await d(),i=n.find(e=>e.url.startsWith(r)&&!e.url.includes(`/preview/`));i&&(t.appTabId=i.targetId)}async function d(){if(typeof window<`u`)return window.location.origin;let t=e();if(t)try{let e=await t.call(`page-info`,void 0,{timeoutMs:2e3});if(e.origin)return e.origin}catch{}return`http://localhost:5710`}function f(e,t){return t===e.appTabId}function p(e){let t=e.url.trim(),n=e.title.trim();return n===`Omnibox Popup`||t.startsWith(`chrome://`)||t.startsWith(`chrome-search://`)||t.startsWith(`chrome-untrusted://`)||t.startsWith(`devtools://`)||t.length===0&&/popup$/i.test(n)}function m(e,t){return!f(e,t.targetId)&&!p(t)}async function h(e,n){return await u(e,n),(await t(e)).filter(e=>m(n,e))}function g(e,t){try{let n=new URL(e,t);return n.origin+n.pathname.replace(/\/$/,``)+n.search}catch{return null}}function _(e,t,n,r){let i=g(t,n);return e.find(e=>{if(r.has(e.frameId))return!1;let n=g(e.url);return n!==null&&i!==null?n===i:e.url===t})}async function v(e,t,n,r,i,a,o){try{let s=await e.getAccessibilityTreeForFrame(t),c=new Map,u=new Map,d=l(s,c,u,{value:0},n,r);for(let[e,n]of c)i.set(e,n),o.set(e,t);for(let[e,n]of u)a.set(e,n),o.set(e,t);return d}catch{return[]}}async function y(e,t,n,r,i,a){if(typeof e.getFrameTree!=`function`)return t;try{let o=(await e.getFrameTree()).filter(e=>e.parentFrameId);if(o.length===0)return t;let s=0,c=[],l=new Set;for(let u of t.split(`
|
|
2
2
|
`)){c.push(u);let t=u.match(/^(\s*)- iframe(?=\s|:)/);if(!t)continue;let d=u.match(/:\s*"([^"]+)"\s*$/);if(!d)continue;let f=_(o,d[1],n,l);f&&(l.add(f.frameId),s++,c.push(...await v(e,f.frameId,t[1]+` `,`f${s}`,r,i,a)))}return c.join(`
|
|
3
3
|
`)}catch{return t}}async function b(e,t){let n=await e.evaluate(`JSON.stringify({ url: location.href, title: document.title })`),{url:r,title:i}=JSON.parse(n),a=await e.getAccessibilityTree(),o=new Map,s=new Map,c=new Map,u=l(a,o,s,{value:0}).join(`
|
|
4
4
|
`);return t?.noIframes||(u=await y(e,u,r,o,s,c)),{url:r,title:i,text:u,refToSelector:o,refToBackendNodeId:s,refToFrameId:c}}async function x(e,t,n,r){let{url:i,title:a,text:o,refToSelector:s,refToBackendNodeId:c,refToFrameId:l}=await b(e,r),u={url:i,title:a,refToSelector:s,refToBackendNodeId:c,refToFrameId:l,content:o,timestamp:Date.now()};return t.snapshots.set(n,u),{snapshot:u,output:[`Page URL: ${i}`,`Page Title: ${a}`,``,o].join(`
|