sliccy 6.235.0 → 6.235.2
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 +177 -177
- package/dist/ui/assets/SKILL-IFmza_44.js +1 -0
- package/dist/ui/assets/{account-store-Dp3-Xn7L.js → account-store-BT0pbAvQ.js} +1 -1
- package/dist/ui/assets/{account-store-BGMKtG5Y.js → account-store-D7DGAxNM.js} +1 -1
- package/dist/ui/assets/{adobe-Bjzb-4li.js → adobe-CEArSxCX.js} +1 -1
- package/dist/ui/assets/{adobe-BAk2XFoI.js → adobe-_I4i3x_7.js} +1 -1
- package/dist/ui/assets/{agent-panels-CKLY91Ka.js → agent-panels-C_58flxq.js} +1 -1
- package/dist/ui/assets/{almost-bash-shell-headless-Di8IjgQ4.js → almost-bash-shell-headless-B6ZMvYl4.js} +296 -296
- package/dist/ui/assets/{apply-layout-CS-toayl.js → apply-layout-8fGhBCeJ.js} +1 -1
- package/dist/ui/assets/{azure-openai-wdTg5Wbz.js → azure-openai-B1ImIasn.js} +1 -1
- package/dist/ui/assets/{azure-openai-BPzPHwaS.js → azure-openai-eCi3qaKl.js} +1 -1
- package/dist/ui/assets/{cdp-DDvgfoMG.js → cdp-D7X02m26.js} +1 -1
- package/dist/ui/assets/{cerebras-CfXNiSS5.js → cerebras-DLriLpBm.js} +1 -1
- package/dist/ui/assets/{cerebras-dGdYGjQw.js → cerebras-Dw16qbLP.js} +1 -1
- package/dist/ui/assets/{composer-speech-BdRosU9N.js → composer-speech-C5aq2EHX.js} +1 -1
- package/dist/ui/assets/{connect-surface-BlQdWnMB.js → connect-surface-B33YxHel.js} +1 -1
- package/dist/ui/assets/{directed-approval-Bd7qek3T.js → directed-approval-CsWbrazD.js} +1 -1
- package/dist/ui/assets/{emscripten-vfs-hook-jCFXNkwf.js → emscripten-vfs-hook-C_WW9D-C.js} +1 -1
- package/dist/ui/assets/{frozen-archive-writer-C3tdnTfy.js → frozen-archive-writer-Bjl1A6fy.js} +1 -1
- package/dist/ui/assets/{gelatiere-unit-DcStO6Pk.js → gelatiere-unit-69YQevwx.js} +1 -1
- package/dist/ui/assets/{github-Bv7TQyhc.js → github-5665N6-Q.js} +1 -1
- package/dist/ui/assets/{github-BVvS9yXo.js → github-DeAThA8k.js} +1 -1
- package/dist/ui/assets/{github-copilot-DtuKtM8B.js → github-copilot-2CNJ6evQ.js} +1 -1
- package/dist/ui/assets/{github-copilot-COXEglZJ.js → github-copilot-B-F9GN74.js} +1 -1
- package/dist/ui/assets/{go-driver-CKhlxhTD.js → go-driver-C0zJJSTi.js} +1 -1
- package/dist/ui/assets/{hear-CraiWDpz.js → hear-DzjhPERk.js} +1 -1
- package/dist/ui/assets/{js-realm-worker-9AElT3xJ.js → js-realm-worker-ALz7TOVI.js} +2 -2
- package/dist/ui/assets/{jsh-executor-D8okn0pR.js → jsh-executor-UfR3L63B.js} +2 -2
- package/dist/ui/assets/{kernel-worker-DefIX_AF.js → kernel-worker-coLE80Cx.js} +9 -9
- package/dist/ui/assets/{lick-ws-bridge-DqvDNYdO.js → lick-ws-bridge-BwZ6Lsqx.js} +1 -1
- package/dist/ui/assets/{lick-ws-bridge-DIhQXDNu.js → lick-ws-bridge-DpjVEf6h.js} +1 -1
- package/dist/ui/assets/{live-session-curation-xBvullFQ.js → live-session-curation-CN8ifDXh.js} +1 -1
- package/dist/ui/assets/{live-session-snapshot-BBO9svAu.js → live-session-snapshot-BoQYDzUq.js} +1 -1
- package/dist/ui/assets/{local-llm-DvCg__dx.js → local-llm-CBWcw9ga.js} +1 -1
- package/dist/ui/assets/{local-llm-B4YA09uv.js → local-llm-DAdQyx68.js} +1 -1
- package/dist/ui/assets/{main-v-uHzakV.js → main-D7Ilh1cw.js} +3 -3
- package/dist/ui/assets/{main-cherry-CfObHKlY.js → main-cherry-9nngpfRy.js} +1 -1
- package/dist/ui/assets/{mcp-command-CQkRyZv1.js → mcp-command-BeBM1rHC.js} +9 -9
- package/dist/ui/assets/{memory-curation-seam-CNje6hJ8.js → memory-curation-seam-CUFsPZ6T.js} +1 -1
- package/dist/ui/assets/{memory-health-C_wI3AOx.js → memory-health-hDyNPmp-.js} +1 -1
- package/dist/ui/assets/{memory-write-execute-D052wKe_.js → memory-write-execute-CgR8Y6VS.js} +1 -1
- package/dist/ui/assets/{merge-folded-cost-into-frozen-f-UEXAfF.js → merge-folded-cost-into-frozen-DTjO_AHz.js} +1 -1
- package/dist/ui/assets/{new-session-BT6tsmB6.js → new-session-CLqykoTf.js} +2 -2
- package/dist/ui/assets/{oauth-bootstrap-nVNcu8ih.js → oauth-bootstrap-UPOMQS2N.js} +2 -2
- package/dist/ui/assets/{onboarding-orchestrator-aAGs543b.js → onboarding-orchestrator-DKu8ScwD.js} +1 -1
- package/dist/ui/assets/{openai-codex-BrF7dQqU.js → openai-codex-C3rT7EJ-.js} +1 -1
- package/dist/ui/assets/{openai-codex-DIt1eAL_.js → openai-codex-CXG3CPUO.js} +1 -1
- package/dist/ui/assets/{openrouter-DzDP8Nsr.js → openrouter-C_mHcLUY.js} +1 -1
- package/dist/ui/assets/{openrouter-DxYCIi6r.js → openrouter-MNU1Hy35.js} +1 -1
- package/dist/ui/assets/{openrouter-free-BCfkQSXH.js → openrouter-free-2vZpBTFE.js} +1 -1
- package/dist/ui/assets/{openrouter-free-B1NcCkBD.js → openrouter-free-wsl2KNbX.js} +1 -1
- package/dist/ui/assets/{openrouter-oauth-CWrCuOZo.js → openrouter-oauth-Bw05OEXj.js} +1 -1
- package/dist/ui/assets/{openrouter-oauth-CDUTjZL0.js → openrouter-oauth-sx8YMfw_.js} +1 -1
- package/dist/ui/assets/{panel-rpc-handlers-CFeJoi6l.js → panel-rpc-handlers-C4ZEbr-L.js} +2 -2
- package/dist/ui/assets/{panelize-shell-Dsl0LtcU.js → panelize-shell-CLTgjV9N.js} +1 -1
- package/dist/ui/assets/{pi-edit-execution-D9KvDmkY.js → pi-edit-execution-DF0ZCxw2.js} +1 -1
- package/dist/ui/assets/{process-worker-mYSiRbYg.js → process-worker-ERAVsYOh.js} +3 -3
- package/dist/ui/assets/{provider-BeHuaFUs.js → provider-CBb3zRgf.js} +1 -1
- package/dist/ui/assets/{provider-Dp-AUJYR.js → provider-CWkiPaFF.js} +1 -1
- package/dist/ui/assets/{provider-settings-gkKLdxqj.js → provider-settings-BySNZFTG.js} +1 -1
- package/dist/ui/assets/provider-store-access-BmLF3yiQ.js +1 -0
- package/dist/ui/assets/provider-store-access-qocbyVYP.js +1 -0
- package/dist/ui/assets/{providers-g8bqtt3g.js → providers-3muwTGPn.js} +2 -2
- package/dist/ui/assets/{providers-Cu-JTUhF.js → providers-Dz9lZ6WH.js} +1 -1
- package/dist/ui/assets/{quick-llm-BiIGx8uX.js → quick-llm-BE1MoA8w.js} +1 -1
- package/dist/ui/assets/{realm-inprocess-CvVF0qXA.js → realm-inprocess-B-C5-frg.js} +2 -2
- package/dist/ui/assets/{realm-unhandled-rejections-CCFHXO-I.js → realm-unhandled-rejections-CE1G6Vqu.js} +1 -1
- package/dist/ui/assets/{realm-unhandled-rejections-DuMO2BTT.js → realm-unhandled-rejections-zi6bFzVe.js} +1 -1
- package/dist/ui/assets/{recovery-screen-MOiv9sFc.js → recovery-screen-tADn1zrY.js} +1 -1
- package/dist/ui/assets/{remote-terminal-view-CasqnGQw.js → remote-terminal-view-4u9dBB0E.js} +2 -2
- package/dist/ui/assets/{restore-30lG0Rle.js → restore-ue1IxJw4.js} +1 -1
- package/dist/ui/assets/{run-BXY4xm9Y.js → run-BSPrcB21.js} +2 -2
- package/dist/ui/assets/{run-D5V1rBmu.js → run-BVj8rfi8.js} +1 -1
- package/dist/ui/assets/{run-CTXs0tgt.js → run-Blqu2GaE.js} +2 -2
- package/dist/ui/assets/run-Cf2apntf.js +18 -0
- package/dist/ui/assets/{run-CogNNkBe.js → run-DKbvbERf.js} +1 -1
- package/dist/ui/assets/{session-command-memory-DUB-rTlJ.js → session-command-memory-Cep9cwKm.js} +2 -2
- package/dist/ui/assets/{session-jsonl-By4E4Ifw.js → session-jsonl-CFn8rdop.js} +1 -1
- package/dist/ui/assets/{session-jsonl-_6flcE_u.js → session-jsonl-j0zMWVNK.js} +1 -1
- package/dist/ui/assets/{session-search-index-CHeeecsJ.js → session-search-index-la9-q_G1.js} +1 -1
- package/dist/ui/assets/{setup-feature-flags-remote-CL50wmO5.js → setup-feature-flags-remote-BTYJL90t.js} +1 -1
- package/dist/ui/assets/{setup-model-catalog-C1iT0LX3.js → setup-model-catalog-D8Ea_olZ.js} +1 -1
- package/dist/ui/assets/{silent-renew-backoff-BMztJHje.js → silent-renew-backoff-BtuCuxCi.js} +1 -1
- package/dist/ui/assets/slicc-version-_RfsCQCx.js +1 -0
- package/dist/ui/assets/snapshot-Dtq5VBeA.js +5 -0
- package/dist/ui/assets/{snapshot-features-Dw5v6SoZ.js → snapshot-features-Dopnb9Bm.js} +1 -1
- package/dist/ui/assets/{soundscape-Bqt7hhbo.js → soundscape-CGUkUoeQ.js} +1 -1
- package/dist/ui/assets/{speak-Bt6rUel5.js → speak-CxwK7WUc.js} +1 -1
- package/dist/ui/assets/{sprinkle-manager-BO_EiUuv.js → sprinkle-manager-7If5XMR2.js} +1 -1
- package/dist/ui/assets/{sprinkle-renderer-B-5D8jG7.js → sprinkle-renderer-BZE6UauM.js} +1 -1
- package/dist/ui/assets/{stdio-tty-CA5sZxWL.js → stdio-tty-BB4qV92F.js} +1 -1
- package/dist/ui/assets/{sudo-BXYhcyYn.js → sudo-Bur3ckJR.js} +1 -1
- package/dist/ui/assets/{supervisor-D9GsUUZz.js → supervisor-BoiwgqlW.js} +1 -1
- package/dist/ui/assets/{sync-dialog-CQAslMYT.js → sync-dialog-CoFg-wC1.js} +1 -1
- package/dist/ui/assets/{transformers-env-CfJzmxee.js → transformers-env-CvumQVfQ.js} +1 -1
- package/dist/ui/assets/{tray-leader-DDtu7vPC.js → tray-leader-B4zwhLBC.js} +1 -1
- package/dist/ui/assets/{tray-leave-runtime-18EOUa0y.js → tray-leave-runtime-gvronesJ.js} +1 -1
- package/dist/ui/assets/{tray-sidecar-Czj8OIo2.js → tray-sidecar-DOIJd5vJ.js} +1 -1
- package/dist/ui/assets/{upgrade-detection-DFrbhD5b.js → upgrade-detection-DbUZ5LnM.js} +1 -1
- package/dist/ui/assets/{voice-reply-_4YMaQsn.js → voice-reply-CMQ06Wn-.js} +1 -1
- package/dist/ui/assets/wasi-runtime-BIpSafPE.js +5 -0
- package/dist/ui/assets/{wc-attach-Dq6xz6VP.js → wc-attach-CtS_GXt-.js} +2 -2
- package/dist/ui/assets/{wc-browser-DarLxgVl.js → wc-browser-DjJiSTyC.js} +1 -1
- package/dist/ui/assets/{wc-computers-Dgt_14kH.js → wc-computers-hk2xbTfE.js} +1 -1
- package/dist/ui/assets/{wc-detached-BIwL6lvs.js → wc-detached-Cwjv2dxL.js} +1 -1
- package/dist/ui/assets/{wc-extension-kAXUuhKY.js → wc-extension-ClEdff6M.js} +2 -2
- package/dist/ui/assets/{wc-follower-BxZs23i2.js → wc-follower-Bf76brRQ.js} +3 -3
- package/dist/ui/assets/{wc-follower-oauth-SwN-s0h6.js → wc-follower-oauth-BZYWuEQu.js} +1 -1
- package/dist/ui/assets/{wc-gelatiere-DJiVHjQS.js → wc-gelatiere-Cs0ORVhQ.js} +1 -1
- package/dist/ui/assets/{wc-live-CWROGoQx.js → wc-live-C-qevd3g.js} +5 -5
- package/dist/ui/assets/{wc-nav-CcrWWixX.js → wc-nav-Rophsgk9.js} +2 -2
- package/dist/ui/assets/{wc-onboarding-BEnUTFQr.js → wc-onboarding-Caj_waOY.js} +2 -2
- package/dist/ui/assets/{wc-permissions-DsjjTDGc.js → wc-permissions-D9yyGqLl.js} +2 -2
- package/dist/ui/assets/{wc-placeholder-DJSoiPYz.js → wc-placeholder-BfxhJIh1.js} +3 -3
- package/dist/ui/assets/{wc-secret-request-CASq9SdH.js → wc-secret-request-DqxZuJUL.js} +1 -1
- package/dist/ui/assets/{wc-settings-DzZ3vKZK.js → wc-settings-Bh44ZTl-.js} +3 -3
- package/dist/ui/assets/{wc-shell-BW5oZjMk.js → wc-shell-CJLjywlF.js} +3 -3
- package/dist/ui/assets/{wc-shortcut-config-CxjODcHO.js → wc-shortcut-config-Cz7Vv65u.js} +1 -1
- package/dist/ui/assets/{wc-sprinkles-BGacrZ0g.js → wc-sprinkles-DVTcJSN3.js} +2 -2
- package/dist/ui/assets/{wc-transcript-export-D6yGycOu.js → wc-transcript-export-CE_ns2-x.js} +2 -2
- package/dist/ui/assets/{wc-tray-CE-PDIL5.js → wc-tray-DSEM6WbT.js} +4 -4
- package/dist/ui/assets/welcome-detection-BxKU2eoh.js +1 -0
- package/dist/ui/assets/{whisper-session-D9dh1Wpf.js → whisper-session-BycheH59.js} +2 -2
- package/dist/ui/assets/{xai-grok-DZo25qHM.js → xai-grok-CW0J74cE.js} +1 -1
- package/dist/ui/assets/{xai-grok-DFPGp-w8.js → xai-grok-Xy7OSykN.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-DLrI4y2g.js +0 -1
- package/dist/ui/assets/provider-store-access-BpYc7sxi.js +0 -1
- package/dist/ui/assets/provider-store-access-DmCK1m2H.js +0 -1
- package/dist/ui/assets/run-Ccyk_j1M.js +0 -18
- package/dist/ui/assets/slicc-version-65AwHbmH.js +0 -1
- package/dist/ui/assets/snapshot-D6YGbggk.js +0 -5
- package/dist/ui/assets/wasi-runtime-Cm3PKls-.js +0 -5
- package/dist/ui/assets/welcome-detection-BOdQEeMJ.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./wc-onboarding-Caj_waOY.js";export{e as hasOnboardingFinalLickInHistory};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/speak-
|
|
2
|
-
import{t as e}from"./preload-helper-Czpn1I53.js";import{t}from"./logger-DDBAeTLF.js";import{a as n,n as r,o as i,r as a,t as o}from"./transformers-env-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/speak-CxwK7WUc.js","assets/preload-helper-Czpn1I53.js","assets/logger-DDBAeTLF.js","assets/runtime-env-Dlaokqg1.js","assets/speech-assets-bridge-CFYafE89.js","assets/transformers-env-CvumQVfQ.js","assets/wc-shell-CJLjywlF.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/mime-types-D0xZwlMO.js","assets/base64-ELzoYfwP.js","assets/bridge-protocol-C52CnDIj.js","assets/account-store-BT0pbAvQ.js","assets/core-Cx9N3lmn.js","assets/compat-BAGLwgqY.js","assets/models-Xc0Gclrk.js","assets/diagnostics-Cag7MsZI.js","assets/env-api-keys-BXRkymgV.js","assets/provider-env-CTOcDKrQ.js","assets/__vite-browser-external-5eBdwsFd.js","assets/openrouter.models-DHpsqCCC.js","assets/libesm-BypnjKEL.js","assets/feature-flags-DvsApnS-.js","assets/proxied-fetch-4VBgrEIu.js","assets/proxy-error-BSFYY7jj.js","assets/api-endpoint-DuEQRZ4g.js","assets/secret-topology-hMRoGGjt.js","assets/float-topology-C_iRKPQK.js","assets/secrets-bridge-client-D734Xx8G.js","assets/port-bridge-client-B-gpiOVR.js","assets/panel-rpc-accessor-B4BfPLSo.js","assets/image-markers-q8JQTtid.js","assets/tool-ui-eSQ1g2I1.js","assets/providers-3muwTGPn.js","assets/stored-accounts-ChNHYF68.js","assets/bedrock-camp-compat-B1oHsbyo.js","assets/bedrock-camp-extra-models-BYrxX19D.js","assets/claude-model-version-DZmbk9E2.js","assets/telemetry-B0sKnLBU.js","assets/types-D8gIX-W-.js","assets/same-file-identity-DuEcSmPX.js","assets/icons-2DY2vYOc.js","assets/wc-shell-WkeczD9x.css","assets/shared-DSEuryGJ.js","assets/transformers.web-BBJR2ai3.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{t as e}from"./preload-helper-Czpn1I53.js";import{t}from"./logger-DDBAeTLF.js";import{a as n,n as r,o as i,r as a,t as o}from"./transformers-env-CvumQVfQ.js";var s=t(`speech:whisper`),c=null,l=`idle`,u=null,d=new Set;function f(){return l}function p(){return u}function m(e){return e&&d.add(e),c||=(l=`loading`,g().then(e=>(l=`ready`,h(),e),e=>{throw l=`failed`,c=null,s.error(`whisper load failed`,e),e})),c}function h(){e(async()=>{let{kokoroWarmup:e}=await import(`./speak-CxwK7WUc.js`);return{kokoroWarmup:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42])).then(({kokoroWarmup:e})=>e()).catch(e=>s.warn(`kokoro warmup (chained after whisper) failed`,e))}async function g(){let{pipeline:t,env:c}=await e(async()=>{let{pipeline:e,env:t}=await import(`./transformers.web-BBJR2ai3.js`);return{pipeline:e,env:t}},__vite__mapDeps([43,7,1]));r(c),await o(n),await a();let l=i(),f=e=>{if(e?.file){if(e.status===`progress`)l.update(e.file,e.loaded??0,e.total??0);else if(e.status===`done`)l.complete(e.file);else return;u=l.snapshot();for(let e of d)e(u)}},p=async e=>await t(`automatic-speech-recognition`,n,{device:e,dtype:e===`webgpu`?`fp32`:`q8`,progress_callback:f}),m=typeof navigator<`u`&&`gpu`in navigator,h;if(m)try{h=await p(`webgpu`)}catch(e){s.warn(`whisper webgpu init failed; retrying on wasm`,e),h=await p(`wasm`)}else h=await p(`wasm`);return s.info(`whisper ready`,{model:n,device:m?`webgpu`:`wasm`}),{async transcribe(e,t){let n=performance.now(),r=await h(e,{chunk_length_s:30,task:`transcribe`,...t?.language?{language:t.language}:{}}),i=Array.isArray(r)?r.map(e=>e.text??``).join(` `):r.text??``;return s.info(`whisper transcribe`,{elapsedMs:Math.round(performance.now()-n),audioSeconds:Math.round(e.length/160)/100,numThreads:c.backends?.onnx?.wasm?.numThreads,device:m?`webgpu`:`wasm`}),i.trim()}}}var _=16e3;async function v(e){if(typeof AudioContext>`u`||typeof OfflineAudioContext>`u`)throw Error(`audio decoding requires a window/page realm (AudioContext unavailable)`);let t=new AudioContext,n;try{n=await t.decodeAudioData(e.slice(0))}finally{await t.close().catch(()=>{})}let r=Math.max(1,Math.ceil(n.duration*_)),i=new OfflineAudioContext(1,r,_),a=i.createBufferSource();return a.buffer=n,a.connect(i.destination),a.start(),(await i.startRendering()).getChannelData(0).slice(0)}var y=t(`speech:whisper-session`),b=2e3,x=500,S=5e3,C=3e4,w=(e,t,n)=>new Promise((r,i)=>{let a=setTimeout(()=>i(Error(`${n} timed out after ${t}ms`)),t);e.then(e=>{clearTimeout(a),r(e)},e=>{clearTimeout(a),i(e)})});function T(e){return e?.split(`-`)[0]?.toLowerCase()||void 0}async function E(e,t){let n;if(t.stream)n=t.stream;else{if(!navigator.mediaDevices?.getUserMedia)throw Error(`microphone capture unavailable in this realm`);n=await navigator.mediaDevices.getUserMedia({audio:t.deviceId&&t.deviceId!=="default"?{deviceId:{exact:t.deviceId}}:!0})}let r=new MediaRecorder(n),i=[],a=T(t.lang),o=!1,s=!1;r.ondataavailable=e=>{e.data.size>0&&i.push(e.data)};let c=async()=>{if(i.length===0)return``;let t=await v(await new Blob(i,{type:r.mimeType||`audio/webm`}).arrayBuffer());return e.transcribe(t,{language:a})},l=Promise.resolve(``),u=()=>{let e=l.catch(()=>``).then(()=>c());return l=e.catch(()=>``),e},d=setInterval(()=>{o||s||i.length===0||(o=!0,u().then(e=>{!s&&e&&t.onPartial?.(e)}).catch(e=>{y.warn(`partial transcription failed`,e)}).finally(()=>{o=!1}))},b),f=()=>{if(clearInterval(d),r.state!==`inactive`)try{r.stop()}catch{}for(let e of n.getTracks())e.stop()},p=()=>new Promise(e=>{if(r.state===`inactive`){e();return}r.onstop=()=>e();try{r.stop()}catch{e()}});return r.start(x),{async stop(){if(s)return``;s=!0,clearInterval(d);try{await w(p(),S,`recorder flush`);for(let e of n.getTracks())e.stop();return await w(u(),C,`transcription`)}catch(e){for(let e of n.getTracks())e.stop();let r=e instanceof Error?e.message:String(e);return t.onError?.(`transcription failed: ${r}`),``}},cancel(){s||(s=!0,f())}}}export{p as a,m as i,T as n,f as o,v as r,E as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e,r as t}from"./account-store-
|
|
1
|
+
import{_ as e,r as t}from"./account-store-D7DGAxNM.js";import{a as n}from"./diagnostics-Cag7MsZI.js";import{a as r}from"./compat-nGhSz-U1.js";import{a as i}from"./core-C1m4D34S.js";import{c as a,i as o,r as s,s as c}from"./legacy-api-aliases--xyLjPgC.js";import{n as l}from"./pi-transcript-context-4pjVPiVC.js";import"./provider-settings-BySNZFTG.js";import{n as u,r as d}from"./bridge-token-required-BYgoMwr7.js";import{n as f,r as p,t as m}from"./pkce-hGf_TEnP.js";import{XaiErrorCode as h,XaiOAuthError as g}from"./xai-grok-errors-ByEMMSoz.js";function _(e){return typeof e==`object`&&!!e}function v(e){if(!_(e))return null;let t=_(e.config)?e.config:e,n=t.creditUsagePercent;if(typeof n!=`number`||!Number.isFinite(n))return null;let r=Math.min(1e3,Math.max(0,n)),i=_(t.currentPeriod)?t.currentPeriod:{},a=i.type,o=typeof a==`string`?a.replace(`USAGE_PERIOD_TYPE_`,``).toLowerCase():``,s=i.end??t.billingPeriodEnd,c=typeof s==`string`&&Number.isFinite(Date.parse(s))?s:void 0;return{percent:r,status:`ok`,window:o&&o!==`unspecified`?o:`billing`,...c?{resetsAt:c}:{}}}async function y(e,t,n={}){let r=new AbortController,i=setTimeout(()=>r.abort(),n.timeoutMs??8e3);try{let n=await t(`https://cli-chat-proxy.grok.com/v1/billing?format=credits`,{headers:{Authorization:`Bearer ${e}`},signal:r.signal}),{status:i}=n;if(i===404||i===501)return null;if(!n.ok)throw Error(`xAI Grok usage: ${i===401||i===403?`re-login required`:`failed`} (${i})`);let a=await n.text();if(a.length>65536)return null;try{return v(JSON.parse(a))}catch{return null}}finally{clearTimeout(i)}}const b=`xai-grok`,x=`https://auth.x.ai`,S=`${x}/oauth2/authorize`,C=`${x}/oauth2/token`,w=`b1a00492-073a-47ea-816f-4c329264a828`,T=`http://127.0.0.1:56121/callback`,E=`https://api.x.ai/v1`,D=`grok-4.7`,O=`${b}-openai`;function k(e){if(e.some(e=>e.id===D))return e;let t=e.find(e=>e.id===`grok-4.6`)??e.find(e=>e.api===`openai-responses`)??e[0];return t?[{...t,id:D,name:`Grok 4.7`,api:`openai-responses`,reasoning:!0,input:[`text`,`image`],cost:{input:2,output:6,cacheRead:.5,cacheWrite:0},contextWindow:5e5,maxTokens:5e5,thinkingLevelMap:{off:null,minimal:null,low:`low`,medium:`medium`,high:`high`,xhigh:`xhigh`,max:null}},...e]:e}function A(){return k(i(`xai`))}function j(e){return{id:e.id,name:e.name,api:`openai`,reasoning:e.reasoning,input:e.input,context_window:e.contextWindow,max_tokens:e.maxTokens,compat:e.compat,thinkingLevelMap:e.thinkingLevelMap,cost:e.cost}}function M(e){let t=A(),n=t.find(t=>t.id===e.id);if(!n&&(console.warn(`xAI model "${e.id}" is no longer in the pi-ai catalog; falling back to default "${D}"`),n=t.find(e=>e.id===D),!n))throw Error(`xAI default model "${D}" is not registered by pi-ai`);if(n.api!==`openai-responses`&&n.api!==`openai-completions`)throw Error(`Unsupported pi-ai API "${n.api}" for xAI model "${e.id}"`);return{...e,...n,baseUrl:E}}async function N(e,t){let n=new URLSearchParams({grant_type:`authorization_code`,code:e,redirect_uri:T,client_id:w,code_verifier:t}),r=await fetch(C,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:n});if(!r.ok)throw new g(`xAI token exchange failed: ${r.status} ${await r.text()}`,h.TOKEN_EXCHANGE_FAILED);let i=await r.json();if(!i.access_token)throw new g(`xAI token exchange did not return access_token.`,h.TOKEN_EXCHANGE_INVALID);return i}async function P(e){if(u())return null;try{let t=new URLSearchParams({grant_type:`refresh_token`,refresh_token:e,client_id:w}),n=await fetch(C,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:t});if(!n.ok){let e=await n.text();return d(n.status,e)||console.error(`[xai-grok] refresh failed:`,n.status,e),null}return await n.json()}catch(e){return console.error(`[xai-grok] refresh error:`,e instanceof Error?e.message:String(e)),null}}function F(){return t().find(e=>e.providerId===b)}async function I(){let t=F();if(!t?.accessToken)throw new g("Not signed in to xAI Grok — run /login or `oauth-token xai-grok`",h.AUTH_MISSING,!0);let n=t.tokenExpiresAt??0;if(n&&Date.now()+6e4<n)return t.accessToken;if(t.refreshToken){let n=await P(t.refreshToken);if(n?.access_token)return await e({providerId:b,accessToken:n.access_token,refreshToken:n.refresh_token??t.refreshToken,tokenExpiresAt:Date.now()+(n.expires_in??21600)*1e3,scopes:n.scope??t.scopes}),n.access_token}return t.accessToken}async function L(){if(!F()?.accessToken)throw Error(`xAI Grok budget: not signed in`);return y(await I(),fetch)}function R(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:O,provider:b,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}}function z(e,t){return t?{...e??{},"x-grok-conv-id":t}:e}function B(e){console.error(`[xai-grok] Stream error:`,e instanceof Error?e.message:String(e))}async function V(e,t,n,r){try{let i=await I(),a=r.sessionId,c=M(t),u={...r,apiKey:i,headers:z(r.headers,a)},d=c.api===`openai-responses`?o(c,l(n),u):s(c,l(n),u);for await(let t of d)e.push(t);e.end()}catch(n){B(n),e.push(R(t,n)),e.end()}}async function H(e,t,n,r){try{let i=await I(),o=r?.sessionId,s=M(t),u={...r,apiKey:i,headers:z(r?.headers,o)},d=s.api===`openai-responses`?a(s,l(n),u):c(s,l(n),u);for await(let t of d)e.push(t);e.end()}catch(n){B(n),e.push(R(t,n)),e.end()}}const U=(e,t,r={})=>{let i=n();return V(i,e,t,r).catch(B),i},W=(e,t,r)=>{let i=n();return H(i,e,t,r).catch(B),i},G={id:b,name:`xAI Grok (SuperGrok OAuth)`,description:`Grok via xAI OAuth — uses your SuperGrok subscription, no API key needed. Default model is Grok 4.7.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:D,oauthTokenDomains:[`api.x.ai`,`*.x.ai`,`auth.x.ai`,`accounts.x.ai`,`cli-chat-proxy.grok.com`],getModelIds:()=>A().map(j),getBudgetUsage:L,onOAuthLoginIntercepted:async(t,n,r)=>{let i=f(),a=await m(i),o=p(),s=p(),c=new URL(S);c.searchParams.set(`response_type`,`code`),c.searchParams.set(`client_id`,w),c.searchParams.set(`redirect_uri`,T),c.searchParams.set(`scope`,r?.scopes??`openid profile email offline_access grok-cli:access api:access`),c.searchParams.set(`code_challenge`,a),c.searchParams.set(`code_challenge_method`,`S256`),c.searchParams.set(`state`,o),c.searchParams.set(`nonce`,s),c.searchParams.set(`plan`,`generic`),c.searchParams.set(`referrer`,`slicc`);let l=await t({authorizeUrl:c.toString(),redirectUriPattern:`http://127.0.0.1:56121/*`,onCapture:`close`});if(!l)throw new g(`xAI OAuth login was cancelled or timed out`,h.CALLBACK_TIMEOUT);let u=new URL(l),d=u.searchParams.get(`code`),_=u.searchParams.get(`state`);if(!d)throw new g(`xAI OAuth redirect did not include a code`,h.CODE_MISSING);if(_!==o)throw new g(`xAI OAuth state mismatch — possible CSRF, aborting`,h.STATE_MISMATCH);let v=await N(d,i);await e({providerId:b,accessToken:v.access_token,refreshToken:v.refresh_token,tokenExpiresAt:Date.now()+(v.expires_in??21600)*1e3,baseUrl:E,scopes:v.scope}),n()},onOAuthLogout:async()=>{await e({providerId:b,accessToken:``})},onSilentRenew:async()=>{let t=F();if(!t?.refreshToken)return null;let n=await P(t.refreshToken);return n?.access_token?(await e({providerId:b,accessToken:n.access_token,refreshToken:n.refresh_token??t.refreshToken,tokenExpiresAt:Date.now()+(n.expires_in??21600)*1e3,scopes:n.scope??t.scopes}),n.access_token):null}};function K(){r({api:O,stream:U,streamSimple:W})}export{h as XaiErrorCode,g as XaiOAuthError,G as config,K as register};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./core-Cx9N3lmn.js";import{a as t}from"./diagnostics-Cag7MsZI.js";import{a as n}from"./compat-BAGLwgqY.js";import{c as r,i,r as a,s as o}from"./legacy-api-aliases-BjgG1CsY.js";import{W as s,u as c}from"./account-store-
|
|
1
|
+
import{a as e}from"./core-Cx9N3lmn.js";import{a as t}from"./diagnostics-Cag7MsZI.js";import{a as n}from"./compat-BAGLwgqY.js";import{c as r,i,r as a,s as o}from"./legacy-api-aliases-BjgG1CsY.js";import{W as s,u as c}from"./account-store-BT0pbAvQ.js";import"./main-D7Ilh1cw.js";import{n as l}from"./pi-transcript-context-miZCMig3.js";import{n as u,r as d}from"./bridge-token-required-DMk2va9k.js";import{n as f,r as p,t as m}from"./pkce-hGf_TEnP.js";import{XaiErrorCode as h,XaiOAuthError as g}from"./xai-grok-errors-bnlIBeu-.js";var _=`https://cli-chat-proxy.grok.com/v1/billing?format=credits`,v=8e3,y=65536,b=1e3;function x(e){return typeof e==`object`&&!!e}function S(e){if(!x(e))return null;let t=x(e.config)?e.config:e,n=t.creditUsagePercent;if(typeof n!=`number`||!Number.isFinite(n))return null;let r=Math.min(b,Math.max(0,n)),i=x(t.currentPeriod)?t.currentPeriod:{},a=i.type,o=typeof a==`string`?a.replace(`USAGE_PERIOD_TYPE_`,``).toLowerCase():``,s=i.end??t.billingPeriodEnd,c=typeof s==`string`&&Number.isFinite(Date.parse(s))?s:void 0;return{percent:r,status:`ok`,window:o&&o!==`unspecified`?o:`billing`,...c?{resetsAt:c}:{}}}async function C(e,t,n={}){let r=new AbortController,i=setTimeout(()=>r.abort(),n.timeoutMs??v);try{let n=await t(_,{headers:{Authorization:`Bearer ${e}`},signal:r.signal}),{status:i}=n;if(i===404||i===501)return null;if(!n.ok)throw Error(`xAI Grok usage: ${i===401||i===403?`re-login required`:`failed`} (${i})`);let a=await n.text();if(a.length>y)return null;try{return S(JSON.parse(a))}catch{return null}}finally{clearTimeout(i)}}var w=`xai-grok`,T=`https://auth.x.ai`,E=`${T}/oauth2/authorize`,D=`${T}/oauth2/token`,O=`b1a00492-073a-47ea-816f-4c329264a828`,k=`openid profile email offline_access grok-cli:access api:access`,A=`http://127.0.0.1:56121/callback`,j=`http://127.0.0.1:56121/*`,M=`https://api.x.ai/v1`,N=`grok-4.7`,P=`${w}-openai`;function F(e){if(e.some(e=>e.id===N))return e;let t=e.find(e=>e.id===`grok-4.6`)??e.find(e=>e.api===`openai-responses`)??e[0];return t?[{...t,id:N,name:`Grok 4.7`,api:`openai-responses`,reasoning:!0,input:[`text`,`image`],cost:{input:2,output:6,cacheRead:.5,cacheWrite:0},contextWindow:5e5,maxTokens:5e5,thinkingLevelMap:{off:null,minimal:null,low:`low`,medium:`medium`,high:`high`,xhigh:`xhigh`,max:null}},...e]:e}function I(){return F(e(`xai`))}function L(e){return{id:e.id,name:e.name,api:`openai`,reasoning:e.reasoning,input:e.input,context_window:e.contextWindow,max_tokens:e.maxTokens,compat:e.compat,thinkingLevelMap:e.thinkingLevelMap,cost:e.cost}}function R(e){let t=I(),n=t.find(t=>t.id===e.id);if(!n&&(console.warn(`xAI model "${e.id}" is no longer in the pi-ai catalog; falling back to default "${N}"`),n=t.find(e=>e.id===N),!n))throw Error(`xAI default model "${N}" is not registered by pi-ai`);if(n.api!==`openai-responses`&&n.api!==`openai-completions`)throw Error(`Unsupported pi-ai API "${n.api}" for xAI model "${e.id}"`);return{...e,...n,baseUrl:M}}async function z(e,t){let n=new URLSearchParams({grant_type:`authorization_code`,code:e,redirect_uri:A,client_id:O,code_verifier:t}),r=await fetch(D,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:n});if(!r.ok)throw new g(`xAI token exchange failed: ${r.status} ${await r.text()}`,h.TOKEN_EXCHANGE_FAILED);let i=await r.json();if(!i.access_token)throw new g(`xAI token exchange did not return access_token.`,h.TOKEN_EXCHANGE_INVALID);return i}async function B(e){if(u())return null;try{let t=new URLSearchParams({grant_type:`refresh_token`,refresh_token:e,client_id:O}),n=await fetch(D,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:t});if(!n.ok){let e=await n.text();return d(n.status,e)||console.error(`[xai-grok] refresh failed:`,n.status,e),null}return await n.json()}catch(e){return console.error(`[xai-grok] refresh error:`,e instanceof Error?e.message:String(e)),null}}function V(){return c().find(e=>e.providerId===w)}async function H(){let e=V();if(!e?.accessToken)throw new g("Not signed in to xAI Grok — run /login or `oauth-token xai-grok`",h.AUTH_MISSING,!0);let t=e.tokenExpiresAt??0;if(t&&Date.now()+6e4<t)return e.accessToken;if(e.refreshToken){let t=await B(e.refreshToken);if(t?.access_token)return await s({providerId:w,accessToken:t.access_token,refreshToken:t.refresh_token??e.refreshToken,tokenExpiresAt:Date.now()+(t.expires_in??21600)*1e3,scopes:t.scope??e.scopes}),t.access_token}return e.accessToken}async function U(){if(!V()?.accessToken)throw Error(`xAI Grok budget: not signed in`);return C(await H(),fetch)}function W(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:P,provider:w,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}}function G(e,t){return t?{...e??{},"x-grok-conv-id":t}:e}function K(e){console.error(`[xai-grok] Stream error:`,e instanceof Error?e.message:String(e))}async function q(e,t,n,r){try{let o=await H(),s=r.sessionId,c=R(t),u={...r,apiKey:o,headers:G(r.headers,s)},d=c.api===`openai-responses`?i(c,l(n),u):a(c,l(n),u);for await(let t of d)e.push(t);e.end()}catch(n){K(n),e.push(W(t,n)),e.end()}}async function J(e,t,n,i){try{let a=await H(),s=i?.sessionId,c=R(t),u={...i,apiKey:a,headers:G(i?.headers,s)},d=c.api===`openai-responses`?r(c,l(n),u):o(c,l(n),u);for await(let t of d)e.push(t);e.end()}catch(n){K(n),e.push(W(t,n)),e.end()}}var Y=(e,n,r={})=>{let i=t();return q(i,e,n,r).catch(K),i},X=(e,n,r)=>{let i=t();return J(i,e,n,r).catch(K),i},Z={id:w,name:`xAI Grok (SuperGrok OAuth)`,description:`Grok via xAI OAuth — uses your SuperGrok subscription, no API key needed. Default model is Grok 4.7.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:N,oauthTokenDomains:[`api.x.ai`,`*.x.ai`,`auth.x.ai`,`accounts.x.ai`,`cli-chat-proxy.grok.com`],getModelIds:()=>I().map(L),getBudgetUsage:U,onOAuthLoginIntercepted:async(e,t,n)=>{let r=f(),i=await m(r),a=p(),o=p(),c=new URL(E);c.searchParams.set(`response_type`,`code`),c.searchParams.set(`client_id`,O),c.searchParams.set(`redirect_uri`,A),c.searchParams.set(`scope`,n?.scopes??k),c.searchParams.set(`code_challenge`,i),c.searchParams.set(`code_challenge_method`,`S256`),c.searchParams.set(`state`,a),c.searchParams.set(`nonce`,o),c.searchParams.set(`plan`,`generic`),c.searchParams.set(`referrer`,`slicc`);let l=await e({authorizeUrl:c.toString(),redirectUriPattern:j,onCapture:`close`});if(!l)throw new g(`xAI OAuth login was cancelled or timed out`,h.CALLBACK_TIMEOUT);let u=new URL(l),d=u.searchParams.get(`code`),_=u.searchParams.get(`state`);if(!d)throw new g(`xAI OAuth redirect did not include a code`,h.CODE_MISSING);if(_!==a)throw new g(`xAI OAuth state mismatch — possible CSRF, aborting`,h.STATE_MISMATCH);let v=await z(d,r);await s({providerId:w,accessToken:v.access_token,refreshToken:v.refresh_token,tokenExpiresAt:Date.now()+(v.expires_in??21600)*1e3,baseUrl:M,scopes:v.scope}),t()},onOAuthLogout:async()=>{await s({providerId:w,accessToken:``})},onSilentRenew:async()=>{let e=V();if(!e?.refreshToken)return null;let t=await B(e.refreshToken);return t?.access_token?(await s({providerId:w,accessToken:t.access_token,refreshToken:t.refresh_token??e.refreshToken,tokenExpiresAt:Date.now()+(t.expires_in??21600)*1e3,scopes:t.scope??e.scopes}),t.access_token):null}};function Q(){n({api:P,stream:Y,streamSimple:X})}export{h as XaiErrorCode,g as XaiOAuthError,Z as config,Q as register};
|
package/dist/ui/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>slicc</title>
|
|
7
7
|
<link rel="icon" type="image/png" href="/logos/sliccy-color-1scoops-32x32.png" />
|
|
8
|
-
<script type="module" crossorigin src="/assets/main-
|
|
8
|
+
<script type="module" crossorigin src="/assets/main-D7Ilh1cw.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-Dd_uD5pT.js">
|
|
10
10
|
<link rel="modulepreload" crossorigin href="/assets/modulepreload-polyfill-P2Xu9kJm.js">
|
|
11
11
|
<link rel="modulepreload" crossorigin href="/assets/diagnostics-Cag7MsZI.js">
|
|
@@ -33,12 +33,12 @@
|
|
|
33
33
|
<link rel="modulepreload" crossorigin href="/assets/tool-ui-eSQ1g2I1.js">
|
|
34
34
|
<link rel="modulepreload" crossorigin href="/assets/core-Cx9N3lmn.js">
|
|
35
35
|
<link rel="modulepreload" crossorigin href="/assets/bridge-protocol-C52CnDIj.js">
|
|
36
|
-
<link rel="modulepreload" crossorigin href="/assets/providers-
|
|
36
|
+
<link rel="modulepreload" crossorigin href="/assets/providers-3muwTGPn.js">
|
|
37
37
|
<link rel="modulepreload" crossorigin href="/assets/stored-accounts-ChNHYF68.js">
|
|
38
38
|
<link rel="modulepreload" crossorigin href="/assets/bedrock-camp-compat-B1oHsbyo.js">
|
|
39
39
|
<link rel="modulepreload" crossorigin href="/assets/bedrock-camp-extra-models-BYrxX19D.js">
|
|
40
40
|
<link rel="modulepreload" crossorigin href="/assets/claude-model-version-DZmbk9E2.js">
|
|
41
|
-
<link rel="modulepreload" crossorigin href="/assets/account-store-
|
|
41
|
+
<link rel="modulepreload" crossorigin href="/assets/account-store-BT0pbAvQ.js">
|
|
42
42
|
<link rel="modulepreload" crossorigin href="/assets/telemetry-B0sKnLBU.js">
|
|
43
43
|
<link rel="modulepreload" crossorigin href="/assets/tray-follower-status-BAjnN7Ar.js">
|
|
44
44
|
<link rel="modulepreload" crossorigin href="/assets/clipboard-eqmn97SP.js">
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>slicc</title>
|
|
7
7
|
<link rel="icon" type="image/png" href="/logos/sliccy-color-1scoops-32x32.png" />
|
|
8
|
-
<script type="module" crossorigin src="/assets/main-
|
|
8
|
+
<script type="module" crossorigin src="/assets/main-D7Ilh1cw.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-Dd_uD5pT.js">
|
|
10
10
|
<link rel="modulepreload" crossorigin href="/assets/modulepreload-polyfill-P2Xu9kJm.js">
|
|
11
11
|
<link rel="modulepreload" crossorigin href="/assets/diagnostics-Cag7MsZI.js">
|
|
@@ -33,12 +33,12 @@
|
|
|
33
33
|
<link rel="modulepreload" crossorigin href="/assets/tool-ui-eSQ1g2I1.js">
|
|
34
34
|
<link rel="modulepreload" crossorigin href="/assets/core-Cx9N3lmn.js">
|
|
35
35
|
<link rel="modulepreload" crossorigin href="/assets/bridge-protocol-C52CnDIj.js">
|
|
36
|
-
<link rel="modulepreload" crossorigin href="/assets/providers-
|
|
36
|
+
<link rel="modulepreload" crossorigin href="/assets/providers-3muwTGPn.js">
|
|
37
37
|
<link rel="modulepreload" crossorigin href="/assets/stored-accounts-ChNHYF68.js">
|
|
38
38
|
<link rel="modulepreload" crossorigin href="/assets/bedrock-camp-compat-B1oHsbyo.js">
|
|
39
39
|
<link rel="modulepreload" crossorigin href="/assets/bedrock-camp-extra-models-BYrxX19D.js">
|
|
40
40
|
<link rel="modulepreload" crossorigin href="/assets/claude-model-version-DZmbk9E2.js">
|
|
41
|
-
<link rel="modulepreload" crossorigin href="/assets/account-store-
|
|
41
|
+
<link rel="modulepreload" crossorigin href="/assets/account-store-BT0pbAvQ.js">
|
|
42
42
|
<link rel="modulepreload" crossorigin href="/assets/telemetry-B0sKnLBU.js">
|
|
43
43
|
<link rel="modulepreload" crossorigin href="/assets/tray-follower-status-BAjnN7Ar.js">
|
|
44
44
|
<link rel="modulepreload" crossorigin href="/assets/clipboard-eqmn97SP.js">
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e="---\nname: playwright-cli\ndescription: |\n Use this whenever the user asks to browse, navigate, click, fill a form,\n scrape, take a screenshot, or otherwise interact with a web page. SLICC drives\n the browser through the `playwright-cli` shell command (also aliased as\n `playwright` and `puppeteer`). Read this BEFORE running any browser\n automation: every tab-operating command requires a `--tab` target id, and\n multi-agent tab handling has rules you must follow.\nallowed-tools: bash\n---\n\n# Browser Automation via playwright-cli\n\nUse `playwright-cli` (also aliased as `playwright` and `puppeteer`) via the bash tool for all browser automation.\n\n**Every tab-operating command requires `--tab=<targetId>`.** There is no implicit \"current tab\". Always specify which tab you're operating on.\n\n`playwright-cli <command> --help` prints that command's usage and does nothing else — safe to run before any action.\n\n## Quick Start\n\n```bash\n# 1. Open a page — note the targetId in the output\nplaywright-cli open https://example.com\n# Output: Opened https://example.com in new tab [targetId: E9A3F...]\n\n# 2. Take a snapshot to see the page structure and get element refs\nplaywright-cli snapshot --tab=E9A3F\n\n# 3. Interact using refs from the snapshot (e.g. e5, e12)\nplaywright-cli click --tab=E9A3F e5\nplaywright-cli fill --tab=E9A3F e12 \"hello world\"\n\n# 4. Re-snapshot after interactions (refs change)\nplaywright-cli snapshot --tab=E9A3F\n```\n\n## Tab IDs\n\n- `tab-list` shows all tabs with their targetIds. The user's active tab is marked `(active)`.\n- `tab-new` / `open` return the new tab's targetId — capture it for subsequent commands.\n- Use `--tab=<targetId>` on ALL commands that operate on a tab.\n\n## Frame IDs\n\n- `frames --tab=<targetId>` lists frame IDs. A frame ID is not a tab target ID; never pass it to `--tab`.\n- Use `--tab=<targetId> --frame=<frameId>` with `eval`, `eval-file`, or `snapshot` to target a child frame, including cross-origin frames.\n- A frame-scoped `snapshot` prints only that frame's accessibility subtree. Its frame-prefixed refs work with `click`, `fill`, `dblclick`, `hover`, `select`, `check`, and `uncheck`; do not pass `--frame` to those commands. Other ref commands require refs from a top-level snapshot.\n\n## Common Failure Modes\n\n- `--tab <targetId> is required` — you forgot `--tab=<id>`. Run `tab-list` to get IDs.\n- `is a frame ID, not a tab target ID` — keep the owning tab's targetId in `--tab` and pass the frame ID with `--frame`.\n- `No snapshot available` — run `snapshot --tab=<id>` before using refs.\n- `unknown flag \"--x\"` / `unexpected argument \"y\"` — every subcommand rejects arguments it does not\n support, so an exit code of 0 means everything you passed was honoured. Check `<verb> --help`.\n- For free-text payloads that start with `-` (e.g. `fill`/`type`/`eval`), put `--` before the text:\n `fill --tab=<id> e1 -- --dash-looking`.\n- `is not an element ref` — a screenshot's positional is a main-frame element ref (`e5`); the output\n path is `--filename=<path>`. Frame-prefixed refs (`f1e5`) clip only with `click`-family commands.\n- Refs are tied to **one tab + one snapshot**. They do not carry across tabs, navigations, or reloads.\n\n## Element Refs\n\nSnapshots assign short ref IDs (`e1`, `e2`, ...) to interactive elements. Use these refs with `click`, `fill`, `dblclick`, `hover`, `select`, `check`, `uncheck`, `drag`, `upload`, `drop`, and `screenshot`.\n\nRefs are invalidated after any state-changing command. Always re-snapshot to get fresh refs.\n\n## Commands\n\nAll commands below that operate on a tab require `--tab=<targetId>`.\n\n### Core\n\n```bash\nplaywright-cli open [url] [--foreground] [--mobile] # Open tab (background by default), returns targetId\nplaywright-cli tab-new [url] [--foreground] [--mobile] # Same as open\nplaywright-cli tab-close --tab=<id> # Close tab (alias: close)\nplaywright-cli goto --tab=<id> <url> # Navigate tab\nplaywright-cli navigate --tab=<id> <url> # Alias for goto\nplaywright-cli snapshot --tab=<id> [--frame=<frameId>] [--no-iframes] [--filename=path] [--depth=<n>] [--boxes] # Tab tree or one frame subtree; --depth limits nesting, --boxes adds [box=x,y,w,h] rects\nplaywright-cli find --tab=<id> <text> # Search the snapshot for text (case-insensitive), returns matching lines + context\nplaywright-cli find --tab=<id> --regex=<re> # Same, with a regexp (use either text or --regex, not both)\nplaywright-cli eval --tab=<id> [--frame=<frameId>] <expression> [--filename=path|--output=path] # Evaluate JS in a tab/frame, incl. top-level await/return; use `--` before an expression that starts with `-`\nplaywright-cli eval-file --tab=<id> [--frame=<frameId>] <vfs-path> [--output=path|--filename=path] # Evaluate JS from a VFS file in a tab/frame (top-level await/return supported)\nplaywright-cli frames --tab=<id> # List frame IDs for --frame (not --tab)\nplaywright-cli resize --tab=<id> <width> <height> # Resize viewport\n```\n\n`--foreground` (or `--fg`) opens the new tab **in the foreground** — it brings the\nnew tab to the front and switches the user's visible/active tab to it, instead of\nopening in the background.\n\n**Bringing a tab to the foreground (activate / focus / raise / switch to a tab):**\n\n- **New tab** → `open <url> --foreground` (or `tab-new <url> --fg`).\n- **Existing tab** → `tab-select <index>` (1-based index from `tab-list`).\n\n`--mobile` opens the tab with generic mobile-device emulation (viewport,\ndevice pixel ratio, touch, Android Chrome UA), sticky for the tab's lifetime —\na later `resize` changes only the dimensions and keeps the mobile identity.\nMobile pages are usually lighter, which saves tokens.\n\nThese two are the ONLY ways to change which tab is in front. There is no\n`activate`, `bring-to-front`, or `focus` subcommand, and `eval`-ing\n`window.focus()` does NOT work (browsers block a page from stealing foreground).\nIf a tab didn't come to the front, re-run `tab-select` / `--foreground` — do not\nfall back to `window.focus()`.\n\n### Interaction\n\n```bash\nplaywright-cli click --tab=<id> <ref> [--modifiers=Shift,Control,Alt,Meta] # Click element\nplaywright-cli dblclick --tab=<id> <ref> [button] [--modifiers=...] # Double-click\nplaywright-cli fill --tab=<id> <ref> <text> [--submit] # Clear input + type text (--submit presses Enter); use `--` before text that starts with `-`\nplaywright-cli type --tab=<id> <text> [--submit] # Type into focused element (--submit presses Enter); use `--` before text that starts with `-`\nplaywright-cli hover --tab=<id> <ref> # Hover over element\nplaywright-cli select --tab=<id> <ref> <value> # Select dropdown value\nplaywright-cli check --tab=<id> <ref> # Check checkbox/radio\nplaywright-cli uncheck --tab=<id> <ref> # Uncheck checkbox/radio\nplaywright-cli drag --tab=<id> <startRef> <endRef> # Drag and drop\nplaywright-cli upload --tab=<id> [ref] <file> [file...] # Upload VFS files to file input as raw bytes (optional snapshot ref targets hidden inputs)\nplaywright-cli drop --tab=<id> <ref> [--path=<vfs-path>] [--data=<mime/type=value>] # Drop files/data onto element (--path drops raw bytes)\nplaywright-cli dialog-accept --tab=<id> [text] # Accept JS dialog\nplaywright-cli dialog-dismiss --tab=<id> # Dismiss JS dialog\n```\n\n### Keyboard\n\n```bash\nplaywright-cli press --tab=<id> <key> # Press key (keyDown + keyUp, e.g. Enter, Tab, Escape)\nplaywright-cli keydown --tab=<id> <key> # Hold key down (no paired keyUp)\nplaywright-cli keyup --tab=<id> <key> # Release held key (no paired keyDown)\n```\n\n### Mouse\n\n```bash\nplaywright-cli mousemove --tab=<id> <x> <y> # Move mouse to coordinates (negative coords ok, e.g. -10 20)\nplaywright-cli mousedown --tab=<id> [button] # Press mouse button (left/right/middle, default: left)\nplaywright-cli mouseup --tab=<id> [button] # Release mouse button\nplaywright-cli mousewheel --tab=<id> <dx> <dy> # Scroll mouse wheel (negative deltas ok, e.g. 0 -300)\n```\n\n### Navigation\n\n```bash\nplaywright-cli go-back --tab=<id> # history.back()\nplaywright-cli go-forward --tab=<id> # history.forward()\nplaywright-cli reload --tab=<id> # Reload page\n```\n\n### Teleport\n\n```bash\nplaywright-cli teleport --tab=<id> --start=<regex> --return=<regex> [--timeout=<s>]\nplaywright-cli teleport --list # List available follower runtimes\nplaywright-cli teleport --off --tab=<id> # Cancel a teleport on this tab\nplaywright-cli open <url> --teleport-start=<regex> --teleport-return=<regex>\nplaywright-cli goto --tab=<id> <url> --teleport-start=<regex> --teleport-return=<regex>\n```\n\nTeleport is for leader/follower tray auth handoffs. Scoped to a specific tab — only commands targeting the teleporting tab are blocked; other tabs remain operational.\n\n`--runtime` is optional: without it, teleport picks the most recently active eligible follower (preferring standalone floats). Only followers that can actually serve cookies are eligible — cherry hosts, exec-only CLI followers, and any target advertising `network: false` are excluded, so a teleport fails fast instead of \"succeeding\" with zero cookies.\n\n### Screenshots\n\n```bash\nplaywright-cli screenshot --tab=<id> # Save to $TMPDIR/screenshot-<ts>.png\nplaywright-cli screenshot --tab=<id> --filename=page.png # Save to custom path\nplaywright-cli screenshot --tab=<id> e5 # Clip to an element (positional = MAIN-FRAME ref, not a path)\nplaywright-cli screenshot --tab=<id> --fullPage # Full scrollable page (alias: --full-page)\nplaywright-cli screenshot --tab=<id> --max-width=800 # Downscale to a max width (png output only)\nplaywright-cli screenshot --tab=<id> --type=jpeg # png (default) / jpeg / webp; inferred from --filename extension\nplaywright-cli screenshot --tab=<id> --hires # Capture in device pixels (honors device pixel ratio)\n```\n\nViewport screenshots (default, `--max-width`, `--hires`) honor the tab's current scroll position. `--fullPage` captures from the document origin.\n\nAn element screenshot (`screenshot e5`) returns **that element's crop or fails**\n(exit 1) — typically because the snapshot went stale after a navigation or\nlayout change. Re-run `snapshot` and retry with a fresh ref; it never silently\nsubstitutes a full-viewport frame.\n\nA `resize` sticks to its tab: the viewport override is re-applied automatically\nwhenever the tab is re-attached, so another driver switching tabs cannot reset\nit.\n\nAll playwright-cli commands share one browser, and locking is **per tab**:\ncommands on different tabs run in parallel; commands on the same tab serialize.\nA slow or hung navigation stalls only its own tab. A few genuinely global\noperations (`tab-select`, `--foreground`, and the attach that points the bridge\nat a tab) still take a bridge-wide lock, but they are short and never wrap a\npage wait. When callers queue up, commands may emit a\n`note: browser bridge contended — ...` line on stderr with the total lock wait\nand queue depth; the note says whether the wait was on **this tab** or\n**bridge-wide**. Either way it is back-off guidance — stagger callers or give\neach one its own tab, never re-run the command; it already ran, it was just\nslow to get the lock.\n\n**Giving up cancels the command.** When your `bash` call stops waiting — the\nturn is cancelled, `timeout` fires, or someone runs `kill <pid>` — the\nplaywright-cli command is cancelled too instead of running on for a caller that\nis gone: a queued command drops out of the tab's queue without taking the lock,\na `goto` waiting on a load event and a `waitForSelector` poll stop at once, and\na multi-step command stops before its next CDP round trip. Such a command exits\n**130** with a stderr line naming the step it stopped at, never 0.\n\nTwo consequences for you:\n\n- A cancelled command may have **half-landed**. The CDP request already on the\n wire cannot be recalled, so keys may be typed or a click delivered before the\n stop. `snapshot` the tab and continue from what you see rather than blindly\n re-running — same rule as a mid-command session reset.\n- `background_after` alone does **not** cancel; it detaches, and the command\n keeps running as a background job (that is what makes a long `goto` usable).\n Use `timeout` or `kill <pid>` when you actually want it stopped.\n\n**Stale session.** The bridge re-attaches automatically after a Chrome reset;\nthere is no need to reload the tab or open a new one. Two error shapes:\n\n- `Session with given id not found` — the bridge already re-attached; re-run\n the command.\n- `… was reset mid-command … the outcome is unknown` — part of the command may\n have landed (keys typed, a click delivered) before the session died. Do NOT\n blindly re-run it: `snapshot` the tab first and continue from what you see.\n\n### Save As\n\n```bash\nplaywright-cli pdf --tab=<id> [--filename=path] # Save page as PDF (not available in extension mode)\n```\n\n### Viewing pages and screenshots yourself\n\nThe browser displays things to the human; `open --view` is what lets _you_ see them. **But viewing screenshots is a last resort for the cone — every image you load eats a large chunk of the context window** (a single 1280×800 PNG can run 1500+ tokens, full-page screenshots much more). Reach for cheaper signals first:\n\n1. **`playwright-cli snapshot --tab=<id>`** — text accessibility tree. Use this first; it answers \"what's on the page\" for almost all verification tasks at a tiny fraction of the token cost. On a big page, `find --tab=<id> <text>` greps the snapshot and returns just the matching lines with context, and `snapshot --depth=<n>` caps the tree — both much cheaper than the full tree.\n2. **`eval` against the DOM** — when you need a specific value (`document.title`, an attribute, computed style), `eval` it. Don't screenshot for facts you can extract.\n3. **Delegate visual inspection to a scoop.** If the cone genuinely needs vision (layout regression, render fidelity, \"does this look right\"), spawn a scoop to take and view the screenshot — the scoop's context absorbs the tokens, and you receive its summary back. The cone's window stays clean for orchestration.\n4. **`open --view` in the cone** — only when the cone itself must see pixels for its current decision and steps 1–3 won't do.\n\n**What you CAN see:**\n\n- `open --view --size <low|medium|high|WxH> <path>` — reads an image from the VFS and returns it, resized to fit the box (`low` 256×256, `medium` 768×768, `high` 1536×1536). `--size` is required. Works with PNG, JPEG, GIF, WebP, SVG.\n- `playwright-cli screenshot --tab=<id> --filename=<path>` + `open --view --size medium <path>` — screenshot a tab, then view it.\n- `screencapture --view screenshot.png` — capture the user's screen via browser screen sharing.\n- `screencapture --video -V 10 clip.webm` — record a timed screen/window/tab clip (WebM).\n- `playwright-cli snapshot --tab=<id>` — accessibility tree (text). Use to verify content without vision.\n\n**What only the human sees:**\n\n- `serve <dir>` — opens an app directory in a browser tab (read-only preview).\n- Preview URLs survive authenticated tray roves without changing their original directory, entry file, or bridge permissions. A handoff can briefly return `503`; retry the same pending rove rather than minting another target. Bridge tabs reconnect automatically (their connection IDs may change). Revoked previews stay revoked, and persistent snapshots keep their original expiry rather than receiving a fresh TTL.\n- Persistent uploads retry safely only with the same file bytes and MIME type. Body/R2-write waits time out after 30 seconds. Unknown writes retain bounded cleanup bookkeeping (up to eight unresolved uploads per preview); expiry/revoke never makes such a preview serve again, even if a delayed write finishes later.\n- `serve --ttl 30d <dir>` — uploads an immutable snapshot that works without the leader. TTL units are whole `m`, `h`, `d`, or `w`, capped at 30 days. It implies `--no-bridge`, conflicts with `--bridge`/`--max-tabs`, and is limited to 1,000 files, 25 MiB per file, and 50 MiB total. Use `serve --list` for mode/expiry and `serve --stop <token>` to revoke it early.\n- **`serve` limits — plan for them:** a live-preview file over 25 MiB is served only through Range requests (a plain GET answers 413; media elements use ranges, so no splitting is needed), and `--ttl` files must be ≤ 25 MiB. A tray holds at most **10 `--ttl` snapshots** (uploads in progress count); live previews have no quota. A live preview is deleted once the leader has been disconnected for 5 minutes; a snapshot lasts until its TTL. Each `serve` prints `Preview token: …`; `serve --stop <token-or-url>` snapshots you no longer need, and on `Snapshot limit reached` run `serve --list` and stop old ones.\n- `serve --bridge <dir>` — opens a **driveable** preview whose visitors auto-connect as live synthetic-CDP targets you can navigate/click/evaluate/screenshot via playwright. **Security: opt-in only; cross-subdomain cookie risk accepted (host-only cookies isolated; `Domain=.sliccy.now` cookies readable across previews).** Flags: `--max-tabs <N>` (default 20), `--quiet` (suppress the first-visit announcement), `--no-bridge` (force read-only), `--stop <token>` (revoke + delete webhook). Use `serve --logs [<token>] [--lines <N>]` to inspect leader-memory-only connect/disconnect records without emitting a lick or waking the cone. `serve --truncate [<token>]` clears matching records **and re-arms the first-visit announcement**, so the next visit announces once. Visitor page API: `window.slicc.emit(name, detail?)` (fires webhook lick on cone), `window.slicc.on(name, cb)` (subscribes to CustomEvents you dispatch).\n- **Media in `serve` previews plays through Range requests:** live previews answer `Range` in ≤ 8 MiB windows, so `<video>`/`<audio>` larger than 25 MiB play and seek without splitting; only a plain full-file GET of such a file gets 413. `--ttl` snapshots support Range too (their files stay ≤ 25 MiB).\n- `open <path>` (no flags) — opens a file in a browser tab.\n- `imgcat <path>` — displays an image in the terminal preview.\n\n**Workflow to verify a page (when vision is actually required):**\n\n1. `serve /workspace/app` — open the app (the human sees it).\n2. `playwright-cli tab-list` — find the tab by URL, note the targetId.\n3. `playwright-cli snapshot --tab=<id>` — required before screenshot, and often answers your question on its own.\n4. `playwright-cli screenshot --tab=<id> --filename=\"$TMPDIR/shot.png\"` — consider `--max-width` to keep the file small.\n5. `open --view --size medium \"$TMPDIR/shot.png\"` — now you can see it. Use `--size low` when layout is all you need. Strongly prefer doing this from a scoop, not the cone.\n\n**Don't:**\n\n- Default to screenshots when a snapshot would do.\n- `read_file` on a PNG or base64-encode to view images.\n- `imgcat` or `cat` on screenshots expecting to see them.\n- Open a screenshot then screenshot that tab.\n- Use `eval` to check the active tab — use `tab-list`.\n\n### Tab Management\n\n```bash\nplaywright-cli tab-list # List tabs with targetIds + (active) marker\nplaywright-cli tab-new [url] # New tab, returns targetId\nplaywright-cli tab-close --tab=<id> # Close specific tab\nplaywright-cli tab-select <index> # Select (bring to front) tab by 1-based index\n```\n\n### Cookies\n\n```bash\nplaywright-cli cookie-list --tab=<id> [--domain=<d>] [--path=<p>] # List cookies (filter by domain/path)\nplaywright-cli cookie-get --tab=<id> <name> # Get cookie\nplaywright-cli cookie-set --tab=<id> <name> <value> [--sameSite=Strict|Lax|None] [other flags] # Set cookie\nplaywright-cli cookie-delete --tab=<id> <name> [--domain= --path=] # Delete cookie\nplaywright-cli cookie-clear --tab=<id> # Clear all cookies\n```\n\n### Storage\n\n```bash\nplaywright-cli localstorage-list --tab=<id>\nplaywright-cli localstorage-get --tab=<id> <key>\nplaywright-cli localstorage-set --tab=<id> <key> <value>\nplaywright-cli localstorage-delete --tab=<id> <key>\nplaywright-cli localstorage-clear --tab=<id>\n# Same pattern for sessionstorage-*\nplaywright-cli state-save --tab=<id> [filename|--filename=path] # Save cookies + localStorage to JSON\nplaywright-cli state-load --tab=<id> <filename> # Restore from state file\n```\n\n### Network\n\n```bash\nplaywright-cli console --tab=<id> [min-level] [--clear] # List console messages (debug/log/info/warning/error)\nplaywright-cli requests --tab=<id> [--static] [--filter=<regex>] [--clear] # List network requests\nplaywright-cli request --tab=<id> <index> [--filename=path] # Full request details\nplaywright-cli request-headers --tab=<id> <index> # Request headers only\nplaywright-cli request-body --tab=<id> <index> # Request body only\nplaywright-cli response-headers --tab=<id> <index> # Response headers only\nplaywright-cli response-body --tab=<id> <index> [--filename=path] # Response body (--filename saves the exact bytes)\nplaywright-cli network-state-set --tab=<id> <online|offline> # Toggle network state\nplaywright-cli route --tab=<id> <pattern> [--status=N] [--body=text] [--content-type=type] [--header=name:value]\nplaywright-cli route-list --tab=<id> # List active routes\nplaywright-cli unroute --tab=<id> [pattern] # Remove routes (all if no pattern)\n```\n\n### DevTools\n\n```bash\nplaywright-cli generate-locator --tab=<id> <ref> # Generate Playwright locator string for element\nplaywright-cli highlight --tab=<id> <ref> [--style=<css>] # Highlight element with visual overlay\nplaywright-cli highlight --tab=<id> --hide [ref] # Remove highlight (all if no ref)\n```\n\n### HAR Recording\n\n```bash\nplaywright-cli record [url] [--filter=<js-expr>] # Open tab with network recording\nplaywright-cli stop-recording <recordingId> # Stop and save HAR\n```\n\n## Multi-Agent Tab Behavior\n\n**All agents (cone + scoops) share the same tab namespace.** There is no tab isolation.\n\n- `tab-list` shows **every** tab from every agent — yours, the cone's, other scoops'. The list can be noisy.\n- Any agent can `eval`, `snapshot`, or `close` any tab — there are no ownership checks.\n- Tab counts fluctuate as other agents open and close tabs concurrently.\n\n**Best practices for scoops:**\n\n1. **Track your own tab IDs.** When you open a tab, capture the targetId and store it. Don't rely on `tab-list` to find your tabs later — other agents' tabs will be mixed in.\n\n ```bash\n # Open and capture the ID\n playwright-cli tab-new https://example.com\n # Output: Opened https://example.com in new tab [targetId: ABC123...]\n # Use ABC123 for all subsequent commands on this tab\n ```\n\n2. **NEVER close tabs you didn't open.** Tabs you don't recognize belong to the **user** or other agents. User tabs are off-limits unless the user explicitly asks you to close them. Only close tabs whose targetId you captured from your own `tab-new` / `open` calls.\n\n3. **Handle \"tab not found\" gracefully.** Another agent might close a tab between your `tab-list` and your command. If you get `Error: No tab with id`, the tab is gone — move on.\n\n4. **Don't depend on tab count or ordering.** Other agents are opening/closing tabs concurrently. Use targetIds, not positional logic.\n\n5. **Clean up when done.** Close all tabs you opened before finishing. Include this in every scoop brief:\n _\"Close each tab with `playwright-cli tab-close --tab=<id>` when done.\"_\n\n## Tips\n\n- **Refs change after every interaction** — always re-snapshot before clicking or filling.\n- `open` and `tab-new` open tabs in the **background** by default. Capture the targetId from the output. To open in the **foreground** add `--foreground`/`--fg`; to raise an **already-open** tab use `tab-select <index>`.\n- After `click`, `fill`, `goto`, `go-back`, `go-forward`, `reload`, `select`, `check`, `uncheck`, `drag`, or `dialog-*`, take a fresh `snapshot --tab=<id>` before using refs again.\n- Unexpected JavaScript dialogs are auto-dismissed on attached pages.\n- Use `eval --tab=<id>` for DOM operations not covered by built-in commands; save results with `--filename=path`.\n- The SLICC app tab and Chrome internal UI tabs are automatically excluded from `tab-list`.\n- `fill` clears and types into regular inputs, textareas, and `contenteditable` elements. Use `--submit` to press Enter after. If the text or an `eval` expression starts with `-`, put `--` before it so it is not parsed as a flag.\n- Negative numbers for `mousewheel` / `mousemove` are positionals (no `--` needed): `mousewheel --tab=<id> 0 -300`.\n- `drop --path=<vfs-path>` injects the file as **raw bytes**; a UTF-8 text round-trip would replace every byte >= 0x80 with `EF BF BD`, so mp4/zip/jpg drops stay byte-exact.\n- Screenshots default to `$TMPDIR/screenshot-<timestamp>.png` — your own scratch directory, not the shared root. Use `--filename=path` to save elsewhere —\n `screenshot <path>` is an error, because that slot is the element ref.\n- Unsupported flags and extra positionals are rejected per subcommand, so a probe that exits 0 means\n the flag was honoured — nothing is silently dropped.\n- Use `keydown`/`keyup` for holding modifier keys (e.g. Shift+click: `keydown Shift`, `click`, `keyup Shift`).\n- Use `requests` + `response-body` to inspect XHR/fetch responses; `route` to mock or block them.\n- **Calling the app's own backend? Use `curlwright`, not `eval-file`.** It is curl's flags run by a `fetch()` inside the tab, so cookies, origin and session come along: `curlwright -s -X POST https://app.example.com/api/items -H 'X-CSRF-Token: abc' -d '{\"name\":\"x\"}' --tab=<id>`. `-o <file>` writes a **byte-exact** body, which `eval-file` cannot do at all — that is the only way to pull a binary response out of a page. Without `--tab` it uses the tab already on that origin. `curlwright --help` for the flag list. It cancels the same way playwright-cli does — giving up exits **130** and writes no `-o` file for a response nobody is reading — but the in-page `fetch` is bounded by `-m`, not by the cancellation, so a cancelled request may still have reached the server.\n- `state-save` / `state-load` persist auth state (cookies + localStorage) across sessions.\n- Every command is logged to `session.md` (auto-snapshots and screenshot copies alongside) under `/.playwright/` in the cone, or your own `$TMPDIR/.playwright/` in a scoop. `state-save` with no filename writes `storage-state.json` there too.\n- `pdf` saves a print-layout PDF; not available in extension mode.\n- `upload` injects VFS files as **raw bytes** (a UTF-8 text round-trip would replace every byte ≥ 0x80 with `EF BF BD`). A leading `eN` / `fNeN` token is a snapshot ref, never a filename — run `snapshot` first; without a ref, focus the file input first. To upload a file named `e2`, pass `./e2` or an absolute path.\n\n## Low-level CDP escape hatch\n\nFor raw Chrome DevTools Protocol calls that `playwright-cli` doesn't wrap, send JSON-RPC directly over WebSocket with `websocat`:\n\n```bash\n# Discover the page's debug socket URL via the CDP HTTP endpoint\ncurl -s http://127.0.0.1:9222/json | jq -r '.[0].webSocketDebuggerUrl'\n\n# Send a single CDP method, receive the response, exit\necho 'Page.navigate {\"url\":\"https://example.com\"}' \\\n | websocat -1 --jsonrpc --jsonrpc-omit-jsonrpc ws://127.0.0.1:9222/devtools/page/<id>\n```\n\nRun `websocat --help` for the full flag list. Use this only when `playwright-cli` has no wrapper for the CDP method you need.\n";export{e as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./provider-BeHuaFUs.js";export{e as readMcpAuthEntries};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./store-wiEGJ_43.js";import"./provider-Dp-AUJYR.js";export{e as readMcpAuthEntries};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./logger-LESFN7Hj.js";import{i as t,n,r,t as i}from"./proxied-fetch-F-dCBEfh.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 v}from"./stdio-tty-CA5sZxWL.js";import{r as y}from"./global-prefix-DqCuANmV.js";import{a as te,i as ne,o as re,r as ie}from"./wasm-programs-Bd5YaoqY.js";import{n as ae,t as oe}from"./wasm-compiler-Ct7QZURL.js";import{S as se,w as ce,x as le}from"./sync-exec-dispatch-DSTbkRmG.js";import{t as ue}from"./sync-sab-wire-D_d0fd3b.js";import{t as de}from"./sync-sab-responder-BmZDqqnK.js";import{i as fe}from"./just-bash-compat-B-SPHuh_.js";const pe=String.raw`printf '\033]7777;%s\007' "$?"`,me=[`if [ -f ~/.bashrc ]; then . ~/.bashrc; fi`,`exec 98<&-`,``].join(`
|
|
2
|
-
`);var b=class extends Error{status;constructor(e,t){super(t),this.status=e}};const he=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,ge={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 _e=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=ve(this.buf,n);if(r>0){if(r>e)throw new b(431,`request head too large`);return this.take(r)}if(this.buf.length>e)throw new b(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 b(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 ye(e.subarray(0,e[r-1]===13?r-1:r))}if(this.buf.length>e)throw new b(400,`line too long`);if(n=this.buf.length,!await this.fill(t))throw new b(400,`connection closed inside a body`)}}async exactly(e,t){for(;this.buf.length<e;)if(!await this.fill(t))throw new b(400,`connection closed inside a body`);return this.take(e)}};function ve(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 ye(e){let t=``;for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return t}function x(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return t}function be(e){let t=ye(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 b(400,`malformed request line`);if(n[3]!==`1`)throw new b(505,`HTTP/${n[3]}.${n[4]} is not supported`);return{method:n[1],target:n[2],minor:Number(n[4]),headers:xe(t)}}function xe(e){let t=[];for(let n of e){if(n===``)continue;if(n.startsWith(` `)||n.startsWith(` `))throw new b(400,`obsolete line folding`);let e=n.indexOf(`:`),r=e>0?n.slice(0,e):``;if(!he.test(r))throw new b(400,`malformed header field`);t.push([r,n.slice(e+1).trim()])}return t}function Se(e,t){let n=t.toLowerCase();return e.filter(([e])=>e.toLowerCase()===n).map(([,e])=>e)}function S(e,t){return Se(e,t).flatMap(e=>e.split(`,`)).map(e=>e.trim().toLowerCase()).filter(e=>e!==``)}function Ce(e){let t=S(e,`transfer-encoding`),n=Se(e,`content-length`);if(t.length>0){if(n.length>0)throw new b(400,`both Transfer-Encoding and Content-Length`);if(t.length!==1||t[0]!==`chunked`)throw new b(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 b(400,`invalid Content-Length`);let a=Number(i);return a===0?{kind:`none`}:{kind:`length`,length:a}}const C=65536;async function we(e,t,n,r){if(t.kind===`none`)return;if(t.kind===`length`){if(t.length>n)throw new b(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 b(400,`malformed chunk size`);let s=Number.parseInt(o[1],16);if(s===0)break;if(a+=s,a>n)throw new b(413,`request body over ${n} bytes`);if(i.push(await e.exactly(s,r)),await e.line(2,r)!==``)throw new b(400,`malformed chunk`)}let o=0;for(let t=await e.line(C,r);t!==``;){if(o+=t.length,o>C)throw new b(431,`trailers too large`);t=await e.line(C,r)}return Te(i,a)}function Te(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 Ee(e){return!/[\r\n\0]/.test(e)}function De(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)he.test(e)&&Ee(t)&&(r+=`${e}: ${t}\r\n`);return x(`${r}\r\n`)}function Oe(e){let t=x(`${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 ke=x(`0\r
|
|
3
|
-
\r
|
|
4
|
-
`),Ae=e(`realm-proxy`),je=3128,Me={maxConnections:64,maxHead:65536,idleMs:12e4,bodyBudget:134217728},Ne=new Set([`connection`,`keep-alive`,`proxy-connection`,`proxy-authenticate`,`proxy-authorization`,`te`,`trailer`,`transfer-encoding`,`upgrade`]),Pe=new Set([`host`,`content-length`,`expect`]);var Fe=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 Ie(e){let t=e.includes(`:`)&&!e.startsWith(`[`)?`[${e}]`:e;try{return new URL(`http://${t}/`).hostname}catch{return}}function Le(e,t){return e===127||e===0||e===169&&t===254}function Re(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 ze(e){let t=Re(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?Le(t[6]>>8,t[6]&255):t[5]===0&&t[6]===0:!1}function Be(e){let t=Ie(e);if(t===void 0)return!1;let n=t.replace(/\.+$/,``);if(n===`localhost`||n.endsWith(`.localhost`))return!0;if(n.startsWith(`[`))return ze(n.slice(1,-1));let r=/^(\d+)\.(\d+)\.\d+\.\d+$/.exec(n);return r?Le(Number(r[1]),Number(r[2])):!1}function Ve(e){return new Set([...Ne,...S(e,`connection`)])}function He(e){let t=Ve(e);return e.filter(([e])=>{let n=e.toLowerCase();return!t.has(n)&&!Pe.has(n)})}function Ue(e,t){let n=Ve(e);return t.encodedBodies||n.add(`content-encoding`),t.encodedBodies&&t.bodiless||n.add(`content-length`),e.filter(([e])=>!n.has(e.toLowerCase()))}function We(e){let t=S(e.headers,`connection`);return t.includes(`close`)?!1:e.minor>=1||t.includes(`keep-alive`)}function Ge(e,t){let n=new URL(t),r;try{r=new URL(e.target,e.target.startsWith(`/`)?n:void 0)}catch{throw new b(400,`malformed request target`)}let i=Se(e.headers,`host`).every(e=>URL.canParse(`https://${e}`)&&new URL(`https://${e}`).host===n.host);if(r.origin!==n.origin||!i)throw new b(421,`this tunnel is for ${n.host}`);return r.href}function Ke(e){if(e.target.startsWith(`/`))throw new b(400,`this is a proxy: send the absolute URL (GET http://host/path)`);let t;try{t=new URL(e.target)}catch{throw new b(400,`malformed request target`)}if(t.protocol!==`http:`&&t.protocol!==`https:`)throw new b(400,`unsupported scheme ${t.protocol}`);if(Be(t.hostname))throw new b(403,`${t.hostname} is the realm's own loopback, which the proxy does not reach: list it in no_proxy`);return t.href}function qe(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 b(400,`CONNECT needs host:port`);let r=Ie(t[1]);if(r===void 0)throw new b(400,`CONNECT needs host:port`);if(Be(r))throw new b(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 Je(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 Ye(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 Xe(e,t){let n=x(`slicc realm proxy: ${t}\n`);return{status:e,statusText:ge[e]??``,headers:[[`Content-Type`,`text/plain; charset=utf-8`]],body:(async function*(){yield n})(),cancel:async()=>void 0}}function Ze(e,t,n){return{read:(r,i)=>e.read(r,AbortSignal.any([n,AbortSignal.timeout(t),...i?[i]:[]]))}}var Qe=class{options;listener;stop=new AbortController;limits;slots;bodies;connections=new Set;closed;port;constructor(e){this.options=e,this.limits={...Me,...e.limits},this.slots=new Fe(this.limits.maxConnections),this.bodies=new Fe(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 _e(Ze(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 b&&await this.refuse(e.sink,t)}}async refuse(e,t){try{await this.relay(e,`GET`,1,Xe(t.status,t.message),!1)}catch{}}async exchange(e,t){let{sink:n,incoming:r}=e,i=be(t);if(i.method===`CONNECT`){if(!e.conn)throw new b(400,`CONNECT inside a tunnel`);return await this.connect(e.conn,r,i),!1}let a=e.origin?Ge(i,e.origin):Ke(i),o=We(i),s=Ce(i.headers),c=s.kind===`length`?s.length:s.kind===`chunked`?this.cap():0;if(c>this.cap())throw new b(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 we(r,s,this.cap()),n=new AbortController;Je(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=S(t.headers,`expect`);if(r.length!==0){if(r.length!==1||r[0]!==`100-continue`)throw new b(417,`unsupported expectation: ${r.join(`, `)}`);n&&t.minor>=1&&await e.write(x(`HTTP/1.1 100 Continue\r
|
|
5
|
-
\r
|
|
6
|
-
`),this.stop.signal)}}async upstream(e,t,n,r){try{return await Ye(this.options.transport.fetch({url:t,method:e.method.toUpperCase(),headers:He(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 Xe(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=Ue(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(De(a,r.statusText||ge[a]||``,s),u),o)return await r.cancel(),l;try{for await(let t of r.body)t.length>0&&await e.write(c?Oe(t):t,u)}catch{return await r.cancel().catch(()=>void 0),!1}return c&&await e.write(ke,u),l}async connect(e,t,n){let r=qe(n),i=this.options.tunnel;if(!i)throw new b(501,`CONNECT ${r.host}:${r.port}: no tunnels through this proxy`);await e.write(x(`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 _e(t),origin:r,socket:e}))}catch(e){e instanceof h||Ae.warn(`tunnel failed`,{host:r.host,error:String(e)})}}};function $e(){return{buffered:n(),streaming:r()}}function et(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 tt(e){return e.startsWith(`x-proxy-`)||e.startsWith(`access-control-`)}function nt(e){let t=[];for(let[n,r]of Object.entries(e)){let e=n.toLowerCase();if(!tt(e)){if(e===`set-cookie`)for(let e of rt(r))t.push([n,e]);else t.push([n,r])}}return t}function rt(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*it(e){e.byteLength>0&&(yield e)}function at(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 ot(e=$e()){return{traits:{manualRedirects:!1,encodedBodies:!1,maxRequestBody:i},async fetch(t){let n=et(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:nt(r.headers),body:it(at(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:nt(r.headers),body:r.body,cancel:()=>r.cancel()}}}}function st(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 ct(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,...st(n.body)}}}}function lt(e={}){let n,i=()=>(n??=(e.fallback??(()=>ot()))(),n),o,s=Promise.resolve().then(()=>(e.capabilities??t)()).then(t=>t.supported?ct((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 w(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 ut(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 T(e,...t){let n=w(t);return w([Uint8Array.of(e),ut(n.length),n])}const E=(...e)=>T(48,...e),dt=(...e)=>T(49,...e),D=e=>T(4,e),ft=(e,t=0)=>T(3,Uint8Array.of(t),e),pt=T(1,Uint8Array.of(255));function O(e){let t=0;for(;t<e.length-1&&e[t]===0;)t++;let n=e.subarray(t);return T(2,n[0]&128?w([Uint8Array.of(0),n]):n)}function k(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 T(6,Uint8Array.from(i))}const mt=e=>T(12,new TextEncoder().encode(e)),A=e=>Uint8Array.from(e,e=>e.charCodeAt(0)&127);function ht(e){let t=e.toISOString().replace(/[-:T]/g,``).slice(0,14);return e.getUTCFullYear()<2050?T(23,A(`${t.slice(2)}Z`)):T(24,A(`${t}Z`))}const gt=E(k(`1.2.840.10045.4.3.2`));function _t(e){let t=[];return e.organization&&t.push(dt(E(k(`2.5.4.10`),mt(e.organization)))),t.push(dt(E(k(`2.5.4.3`),mt(e.commonName)))),E(...t)}function j(e,t,n){return t?E(k(e),pt,D(n)):E(k(e),D(n))}function vt(e){let t=[],[,n,r]=M(e,0);for(let i=n;i<r;){let[,,n]=M(e,i);t.push(e.subarray(i,n)),i=n}return t}function M(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 yt(e){let[,t,n]=M(e,0);return e.subarray(t,n)}function bt(e){let t=vt(e)[1];return yt(t).subarray(1)}async function xt(e){return new Uint8Array(await crypto.subtle.digest(`SHA-1`,bt(e)))}function St(e){let t=e.length/2;return E(O(e.subarray(0,t)),O(e.subarray(t)))}function Ct(){let e=crypto.getRandomValues(new Uint8Array(16));return e[0]=e[0]&127|1,e}function wt(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 Tt(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=wt(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 Et(e){let t=[j(`2.5.29.14`,!1,D(await xt(e.spki)))];if(e.kind.ca)t.push(j(`2.5.29.19`,!0,E(pt,O(Uint8Array.of(0))))),t.push(j(`2.5.29.15`,!0,ft(Uint8Array.of(134),1)));else{t.push(j(`2.5.29.35`,!1,E(T(128,await xt(e.issuerSpki))))),t.push(j(`2.5.29.19`,!0,E())),t.push(j(`2.5.29.15`,!0,ft(Uint8Array.of(128),7))),t.push(j(`2.5.29.37`,!1,E(k(`1.3.6.1.5.5.7.3.1`))));let n=wt(e.kind.host)??Tt(e.kind.host),r=n?T(135,n):T(130,A(e.kind.host));t.push(j(`2.5.29.17`,!1,E(r)))}return T(163,E(...t))}async function Dt(e){let t=E(T(160,O(Uint8Array.of(2))),O(e.serial),gt,_t(e.issuer),E(ht(e.notBefore),ht(e.notAfter)),_t(e.subject),e.spki,await Et(e)),n=St(await e.sign(t));return E(t,gt,ft(n))}function Ot(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 kt={name:`ECDSA`,namedCurve:`P-256`},At={name:`ECDSA`,hash:`SHA-256`};function jt(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}function Mt(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 jt((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 Nt=class extends Error{};function Pt(e){return Tt(e)?!0:e.length===0||e.length>253?!1:e.split(`.`).every(e=>/^(?!-)[a-z0-9-]{1,63}(?<!-)$/i.test(e))}var Ft=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(kt,!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 Dt({serial:Ct(),issuer:i,subject:i,notBefore:new Date(t-864e5),notAfter:new Date(a),spki:r,issuerSpki:r,kind:{ca:!0},sign:It(n.privateKey)});return{key:n.privateKey,cert:o,spki:r,notAfter:a,name:i}}get cert(){return this.record.cert}get pem(){return Ot(this.record.cert)}async issue(e,t,n=Date.now()){let r=e.toLowerCase();if(!Pt(r))throw new Nt(`no certificate for ${e}`);return Dt({serial:Ct(),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:It(this.record.key)})}};function It(e){return async t=>new Uint8Array(await crypto.subtle.sign(At,e,t))}let Lt;const N=new Map;function Rt(e,t){let n=N.get(e);return n||(Lt??=t?void 0:Mt(),n=Ft.open(e,t??Lt),N.set(e,n),n.catch(()=>{N.get(e)===n&&N.delete(e)})),n}const zt=65536;var Bt=class extends Error{code;constructor(e,t){super(t),this.code=e}},Vt=class{m;scratch;constructor(e){if(this.m=e,this.scratch=e._malloc(zt),!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 Bt(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 Ht(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 Ut(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,zt);return t>0?this.taken(t):t}},Ht=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)}},Ut=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 P;function Wt(e=async()=>(await import(`./slicc-tls-engine-DfyKw1Ua.js`)).default()){return P??=e().then(e=>new Vt(e)),P.catch(()=>{P=void 0}),P}const Gt=e(`realm-tls`);var Kt=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)}},qt=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 Kt(c,Yt(t),e),s=`https://${Jt(n)}`;try{await i(a,a,s),await a.close(r).catch(()=>void 0)}catch(e){throw Gt.debug(`tunnel ended`,{host:o,error:String(e)}),e}}finally{c.free()}}};function Jt(e){return e.port===443?e.host:`${e.host}:${e.port}`}function Yt(e){return{read:(t,n)=>e.some(t,n)}}const F=`http://127.0.0.1:${je}`,Xt=`localhost,.localhost,127.0.0.1,127.0.0.0/8`;function Zt(){return{http_proxy:F,https_proxy:F,HTTP_PROXY:F,HTTPS_PROXY:F,no_proxy:Xt,NO_PROXY:Xt}}function Qt(e){if(e)return`ca`in e?new qt(e):new qt({ca:()=>Rt(e.owner),engine:()=>Wt()})}const $t=new WeakMap,en=`/.config/slicc/realm-ca-`;function tn(e){return e.replace(/[^A-Za-z0-9_-]+/g,`-`).replace(/-+$/,``)}function nn(e,t){return`${e.replace(/\/+$/,``)}${en}${tn(t)}.pem`}function rn(e){return{SSL_CERT_FILE:e,CURL_CA_BUNDLE:e,GIT_SSL_CAINFO:e}}const an=`/.config/slicc/gitconfig`;function on(e){return`${e.replace(/\/+$/,``)}${an}`}function sn(e){return`"${e.replace(/[\r\n]+/g,` `).replace(/[\\"]/g,e=>`\\${e}`)}"`}function cn(e){let t=[`[credential]`,` helper = slicc`];return e&&t.push(`[user]`,`\tname = ${sn(e.name)}`,`\temail = ${sn(e.email)}`),`${t.join(`
|
|
10
|
-
`)}\n`}async function ln(e,t,n){try{let r=cn(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 un(e,t){let n=Zt();return e in n?n[e]===t:e===`GIT_CONFIG_SYSTEM`?t.endsWith(an):e in rn(``)&&t.includes(en)}async function dn(e,t,n,r=Rt){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)),rn(t)}catch{return{}}}function fn(e,t={}){if($t.has(e))return;let n={proxy:void 0};$t.set(e,n);let r;e.activate({family:`inet`,host:`127.0.0.1`,port:je},()=>{r??=(t.transport??lt)();let i=Qt(t.tls),a=new Qe({net:e,transport:r,tunnel:i?.handler,...t.proxy});n.proxy=a,pn(a,t.process).then(async()=>{n.proxy===a&&(n.proxy=void 0),await i?.close()})})}async function pn(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 mn=32768;function hn(e){return/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(e)}async function I(e){try{return await e()}catch(e){throw e instanceof o?new h(e.code):e}}var gn=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 _n(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 L=class e{net;domain;state=`open`;local;peer;link;readShut=!1;writeShut=!1;queue=[];backlog=0;bound=!1;changes=new gn;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:I(()=>n.read(e,t))}async peek(e,t){let{rx:n}=this.connection();return this.readShut||e<=0?new Uint8Array:I(()=>n.peek(e,t))}async write(e,t){let{tx:n}=this.connection();if(this.writeShut)throw new h(`EPIPE`);return I(()=>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 I(()=>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:vn(t.host)}:t,r.peer=this.local,this.peer=r.local,_n(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:``},_n(r,i),[r,i]}};function vn(e){return e===`0.0.0.0`?`127.0.0.1`:e}function R(e){return e.family===`inet`?`inet:${e.port}`:`unix:${e.path}`}var yn=class{bound=new Map;activators=new Map;nextEphemeral=mn;activate(e,t){this.activators.set(R(e),t)}socket(e){return new L(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`&&!hn(t.host))throw new h(`EADDRNOTAVAIL`);let n=t.family===`inet`&&t.port===0?{...t,port:this.ephemeral()}:t,r=R(n);if(this.bound.has(r))throw new h(`EADDRINUSE`);return this.bound.set(r,e),n}release(e,t){let n=R(e);this.bound.get(n)===t&&this.bound.delete(n)}target(e){if(e.family===`inet`&&!hn(vn(e.host)))throw new h(`ENETUNREACH`);let t=R(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?mn:e+1,!this.bound.has(`inet:${e}`))return e}throw new h(`EADDRINUSE`)}};const bn=new Map;function xn(e){let t=bn.get(e);return t||(t=new yn,bn.set(e,t)),t}function z(e){return e?`${e.kind}:${e.scoopJid??``}`:`local`}const B={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},Sn=new Set([B.CHLD,B.URG,B.WINCH]),Cn=new Set([B.STOP,B.TSTP,B.TTIN,B.TTOU]);function V(e){return e===B.CONT?`continue`:Cn.has(e)?`stop`:Sn.has(e)?`ignore`:`terminate`}function wn(e){return Number.isInteger(e)&&e>=1&&e<=31}function H(e){return 1<<e}const U={SIGINT:B.INT,SIGTERM:B.TERM,SIGKILL:B.KILL,SIGSTOP:B.STOP,SIGCONT:B.CONT},Tn=16384;function En(){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 Dn=new TextEncoder;function On(e){return(e&192)==128}var kn=class{screen;signal;termios=En();cols=80;rows=24;readable=[];line=[];waiters=[];hungUp=!1;name;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(B.WINCH)}hangup(){this.hungUp=!0,this.wake()}signalHangup(){this.signal(B.HUP)}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=>{if(this.hungUp)throw new h(`EIO`);return this.output(e),e.length},poll:()=>({readable:this.readable.length>0||this.hungUp,writable:!0,hangup:this.hungUp}),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)?B.INT:e===this.cc(1)?B.QUIT:e===this.cc(10)?B.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(Dn.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&Tn)for(;t<e.length&&On(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&Tn?t.filter(e=>!On(e)).length:t.length;n>0&&this.termios.c_lflag&8&&this.output(Dn.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;){if(this.hungUp)return new Uint8Array;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()}},W=class extends Error{code;constructor(e){super(e),this.code=e}};function An(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 jn(e){return(e&255)<<8|127}function Mn(e,t){return t?t&127:(e&255)<<8}function Nn(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 Pn=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 W(`ENOSYS`);return this.track(e,this.parentFds.fork(),new Map,this.forker)}async spawn(e,t,n=[]){if(!this.spawner)throw new W(`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 e of n)if(!(e.fd<=2)){if(`null`in e){r.installAt(e.fd,l());continue}r.installAt(e.fd,this.parentFds.get(e.kernel).retain()),e.flags!==void 0&&r.setStatusFlags(e.fd,e.flags)}}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??=An(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,jn(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,Mn(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),Nn(r))}},Fn=class{index;onFree;slave;locked=!0;packet=!1;queue=[];waiters=[];masterOpen=!0;slaveRefs=0;slaveSeen=!1;constructor(e,t,n){this.index=e,this.onFree=n,this.slave=new kn({write:e=>this.fromSlave(e)},e=>t(this.slave,e)),this.slave.name=`/dev/pts/${e}`}master(){return new _({read:(e,t)=>this.readMaster(e,t),write:async e=>(this.slave.receive(e),e.length),poll:()=>({readable:this.queue.length>0||this.slaveGone,writable:!0,hangup:this.slaveGone}),changed:e=>this.changed(e),close:()=>this.closeMaster(),pty:this})}openSlave(){if(!this.masterOpen||this.locked)throw new h(`EIO`);let e=this.slave.file().file;return this.slaveRefs+=1,this.slaveSeen=!0,new _({...e,close:()=>this.closeSlave()})}get slaveGone(){return this.slaveSeen&&this.slaveRefs===0}fromSlave(e){this.masterOpen&&(this.queue.push(e.slice()),this.wake())}async readMaster(e,t){for(;this.queue.length===0;){if(this.slaveGone)throw new h(`EIO`);await this.changed(t)}let n=+!!this.packet,r=[],i=0;for(;this.queue.length>0&&i<e-n;){let t=this.queue[0],a=t.subarray(0,e-n-i);r.push(a),i+=a.length,a.length<t.length?this.queue[0]=t.subarray(a.length):this.queue.shift()}let a=new Uint8Array(n+i),o=n;for(let e of r)a.set(e,o),o+=e.length;return a}closeMaster(){this.masterOpen=!1,this.queue=[],this.slave.hangup(),this.slave.signalHangup(),this.freeIfUnused()}closeSlave(){--this.slaveRefs,this.wake(),this.freeIfUnused()}freeIfUnused(){!this.masterOpen&&this.slaveRefs===0&&this.onFree(this)}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()}},In=class{signal;pairs=new Map;constructor(e){this.signal=e}open(){let e=0;for(;this.pairs.has(e);)e+=1;let t=new Fn(e,this.signal,e=>this.pairs.delete(e.index));return this.pairs.set(e,t),{pair:t,master:t.master()}}get(e){let t=this.pairs.get(e);if(!t)throw new h(`ENOENT`);return t}numbers(){return[...this.pairs.keys()].sort((e,t)=>e-t)}};const Ln=[`pty-open`,`pty-slave-open`,`pty-number`,`pty-lock`,`pty-ctty`,`pty-packet`,`pty-list`,`pty-winsz-set`];function G(e,t){let n=e.fds.get(t).file.pty;if(!n)throw new h(`ENOTTY`);return n}function Rn(e,t){let n=e.fds.get(t).file,r=n.tty??n.pty?.slave;if(!r)throw new h(`ENOTTY`);return r}const K=e=>({ok:!0,kind:`json`,json:e}),q={ok:!0,kind:`void`};function zn(e,t){switch(e.op){case`pty-open`:if(!t.ptys)throw new h(`ENOENT`);return K(t.fds.install(t.ptys.open().master,3));case`pty-slave-open`:{if(!t.ptys)throw new h(`ENOENT`);let n=t.ptys.get(e.n),r=t.fds.install(n.openSlave(),3);return e.noctty||t.jobs?.acquireTerminal(t.pid,n.slave),K(r)}case`pty-number`:return K(G(t,e.fd).index);case`pty-lock`:return G(t,e.fd).locked=e.lock,q;case`pty-ctty`:{let n=Rn(t,e.fd);if(t.jobs?.getsid(t.pid,0)===t.pid&&t.jobs?.controllingTerminal(t.pid)===n)return q;if(!t.jobs?.acquireTerminal(t.pid,n))throw new h(`EPERM`);return q}case`pty-list`:return K(t.ptys?.numbers()??[]);case`pty-packet`:return G(t,e.fd).packet=e.on,q;case`pty-winsz-set`:return Rn(t,e.fd).resize(e.cols,e.rows),q}}function Bn(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 Vn(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 Hn(e,t,n,r,i){let a=r<0?1/0:Date.now()+r,o=Vn(i);o.promise.catch(()=>{});try{return await Un(e,t,n,a,o.promise)}finally{o.done()}}async function Un(e,t,n,r,i){for(;;){let a=Bn(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 Wn=[`sock-open`,`sock-pair`,`sock-bind`,`sock-listen`,`sock-accept`,`sock-connect`,`sock-shutdown`,`sock-name`,`sock-getopt`,`sock-setopt`];function J(e,t){let n=e.get(t).file;if(!(n instanceof L))throw new h(`ENOTSOCK`);return n}const Y=e=>e===void 0?{ok:!0,kind:`void`}:{ok:!0,kind:`json`,json:e};async function Gn(e,t){let{fds:n,net:r}=t;switch(e.op){case`sock-open`:return Y(n.install(new _(r.socket(e.domain)),3));case`sock-pair`:{let[t,i]=L.pair(r,e.domain),a=n.install(new _(t),3);try{return Y([a,n.install(new _(i),3)])}catch(e){throw await Promise.resolve(n.close(a)),e}}case`sock-bind`:return J(n,e.fd).bind(e.addr),Y();case`sock-listen`:return J(n,e.fd).listen(e.backlog),Y();case`sock-accept`:return Y(await qn(t,e.fd,e.nonblock));case`sock-connect`:if(J(n,e.fd).connect(e.addr),e.nonblock)throw new h(`EINPROGRESS`);return Y();case`sock-shutdown`:return J(n,e.fd).shutdown(e.how),Y();case`sock-name`:{let t=J(n,e.fd),r=e.peer?t.peer:t.local;if(e.peer&&!r)throw new h(`ENOTCONN`);return Y(r??Kn(t.domain))}case`sock-getopt`:return Y(J(n,e.fd).getOption(e.level,e.name));case`sock-setopt`:return J(n,e.fd).setOption(e.level,e.name,e.value),Y()}}function Kn(e){return e===`inet`?{family:`inet`,host:`0.0.0.0`,port:0}:{family:`unix`,path:``}}async function qn(e,t,n){let r=J(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 Jn(e,t){return e===t||e.startsWith(t.endsWith(`/`)?t:`${t}/`)}var Yn=class{fs;path;orphaned;data;length=0;dirty=!1;queue=Promise.resolve();writeBack;writeBackCost=0;opens=0;missing=!1;constructor(e,t,n,r=!1){this.fs=e,this.path=t,this.orphaned=r,n===void 0?r&&(this.data=new Uint8Array):this.data=new Uint8Array(n),this.length=this.data?.length??0}serial(e){let t=this.queue.then(e);return this.queue=t.catch(()=>void 0),t}async load(){if(!this.data){try{this.data=await this.fs.readFileBuffer(this.path)}catch{this.data=new Uint8Array,this.missing=!0}this.length=this.data.length}return this.data}async materialize(){await this.load(),!(!this.missing||this.orphaned)&&(this.missing=!1,await this.fs.writeFile(this.path,this.data?.slice(0,this.length)??new Uint8Array))}async size(){return await this.load(),this.length}async pread(e,t){let n=await this.load(),r=Math.max(0,Math.min(e,this.length-t));return n.slice(t,t+r)}async pwrite(e,t){await this.load();let n=this.ensure(t+e.length);return t>this.length&&n.fill(0,this.length,t),n.set(e,t),this.length=Math.max(this.length,t+e.length),this.markDirty(),e.length}async truncate(e){await this.load();let t=this.ensure(e);e>this.length&&t.fill(0,this.length,e),this.length=e,this.markDirty()}markDirty(){if(this.dirty=!0,this.writeBack!==void 0||this.orphaned)return;let e=Math.max(250,this.writeBackCost*10);this.writeBack=setTimeout(()=>{this.writeBack=void 0,this.serial(()=>this.flush()).catch(()=>void 0)},e)}ensure(e){let t=this.data??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,this.length)),this.data=n,n}async flush(){if(!this.dirty||!this.data||this.orphaned)return;this.dirty=!1;let e=performance.now();await this.fs.writeFile(this.path,this.data.slice(0,this.length)),this.writeBackCost=performance.now()-e}},Xn=class{fs;byPath=new Map;constructor(e){this.fs=e}open(e){let t=this.byPath.get(e);return t||(t=new Yn(this.fs,e),this.byPath.set(e,t)),t.opens++,t}closed(e){e.opens--,e.opens===0&&this.byPath.get(e.path)===e&&this.byPath.delete(e.path)}async flush(e){for(let[t,n]of this.byPath)Jn(t,e)&&await n.serial(()=>n.flush())}async unlinking(e){let t=this.byPath.get(e);t&&await t.serial(()=>t.load())}unlinked(e){let t=this.byPath.get(e);t&&(t.orphaned=!0,this.byPath.delete(e))}renamed(e,t){if(e===t)return;let n=[];for(let[r,i]of this.byPath)Jn(r,e)?n.push(i):Jn(r,t)&&(i.orphaned=!0,this.byPath.delete(r));for(let r of n)this.byPath.delete(r.path),r.path=t+r.path.slice(e.length),this.byPath.set(r.path,r)}};function Zn(e,t,n){let r=t.flags&3,i=r!==1,a=r===1||r===2,o=n&&t.contents===void 0&&!t.orphan?n.open(t.path):new Yn(e,t.path,t.contents,t.orphan===!0);t.create&&o.serial(()=>o.materialize()),t.truncate&&o.serial(()=>o.truncate(0));let s=t.position,c=e=>o.serial(e);return new _({read:i?e=>c(async()=>{let t=await o.pread(e,s);return s+=t.length,t}):void 0,write:a?e=>c(async()=>(t.flags&1024&&(s=await o.size()),s+=await o.pwrite(e,s),e.length)):void 0,seek:(e,t)=>c(async()=>{let n=0;if(t===1)n=s;else if(t===2)n=await o.size();else if(t!==0)throw new h(`EINVAL`);if(n+e<0)throw new h(`EINVAL`);return s=n+e,s}),pread:(e,t)=>c(()=>{if(!i)throw new h(`EBADF`);return o.pread(e,t)}),pwrite:(e,t)=>c(()=>{if(!a)throw new h(`EBADF`);return o.pwrite(e,t)}),resize:e=>c(()=>{if(!a)throw new h(`EBADF`);return o.truncate(e)}),stat:()=>c(async()=>({path:o.path,size:await o.size(),...o.orphaned?{orphan:!0}:{}})),flush:()=>c(()=>o.flush()),close:()=>c(async()=>{await o.flush(),n?.closed(o)})})}const Qn=new Set([`proc-setpgid`,`proc-getpgid`,`proc-getsid`,`proc-setsid`]);function $n(e){return Qn.has(e.op)}function er(e){return e.op.startsWith(`pty-`)}function tr(e){return e.op.startsWith(`sock-`)}function nr(e){return e.op.startsWith(`fd-path-`)||e.op===`fd-pread`||e.op===`fd-pwrite`||e.op===`fd-resize`||e.op===`fd-vfs-stat`}function rr(e){return e.op.startsWith(`fd-`)}function ir(e){return e.op.startsWith(`tty-`)}const ar=new Set([`fd-read`,`fd-write`,`fd-close`,`fd-pipe`,`fd-poll`,`fd-open-vfs`,`fd-seek`,`fd-pread`,`fd-pwrite`,`fd-resize`,`fd-vfs-stat`,`fd-path-flush`,`fd-path-unlinking`,`fd-path-unlinked`,`fd-path-renamed`,`fd-select`,`fd-info`,`fd-dup`,`fd-reserve`,`fd-meta`,`fd-setfl`,`fd-cloexec`,`fd-list`,`dl-log`,`proc-alarm`,`fd-renumber`,`fd-promote`,`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`,`sig-pause`,...Wn,...Ln]);function or(e){let t=e.op;return typeof t==`string`&&ar.has(t)}const sr=1048576;var cr=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;nodes;constructor(e,t,n={}){this.pid=e,this.fds=t,this.options=n,this.children=new Pn(t,n.spawner,n.forker),this.nodes=n.fs?new Xn(n.fs):void 0,this.children.onChildState=()=>this.signal(B.CHLD)}signal(e){if(this.execChild!==void 0)return Promise.resolve(this.options.kill?.(this.execChild,e)).catch(()=>void 0),e===B.KILL?`terminate`:`forward`;if(e===B.KILL)return`terminate`;if(e===B.CONT&&this.cont(),e===B.STOP)return this.stop(e);let t=H(e);if(this.ignored&t)return`ignore`;if(!(this.caught&t)){let t=V(e);return t===`stop`?this.stop(e):t}let n=V(e);if(((this.options.pendingBits?.()??0)&t)!==0&&n===`terminate`)return n;this.options.onPending?.(e);let r=this.interrupt;return this.interrupt=new AbortController,r.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`,B.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{if(rr(e))return await this.fdSyscall(e);if(ir(e))return this.ttySyscall(e);if($n(e))return this.jobSyscall(e);if(tr(e))return await this.socketSyscall(e);if(er(e)){let{ptys:t,jobs:n}=this.options;return zn(e,{pid:this.pid,fds:this.fds,ptys:t,jobs:n})}return await this.procSyscall(e)}catch(e){if(e instanceof h||e instanceof W)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,sr)),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)}openVfsFile(e){if(!this.options.fs)throw new W(`ENOSYS`);return Zn(this.options.fs,{path:e.path,flags:e.flags,position:e.position,...e.contents===void 0?{}:{contents:e.contents},...e.orphan?{orphan:!0}:{},...e.truncate?{truncate:!0}:{},...e.create?{create:!0}:{}},this.nodes)}async fdSyscall(e){if(nr(e))return this.vfsSyscall(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`:return{ok:!0,kind:`json`,json:this.fds.install(this.openVfsFile(e),3)};case`fd-info`:return{ok:!0,kind:`json`,json:this.fdInfo(e.fd)};case`fd-list`:return{ok:!0,kind:`json`,json:this.fds.numbers().map(e=>({fd:e,...this.fdInfo(e)}))};case`fd-meta`:{let t=this.fds.get(e.fd).file;if(!t.held)throw new h(`EBADF`);return t.heldMeta=e.meta,{ok:!0,kind:`void`}}case`fd-setfl`:return this.fds.setStatusFlags(e.fd,e.flags),{ok:!0,kind:`void`};case`fd-cloexec`:return e.on?this.fds.setCloseOnExec(e.fd):this.fds.clearCloseOnExec(e.fd),{ok:!0,kind:`void`};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,e.min,e.meta)};case`fd-promote`:return this.promote(e),{ok:!0,kind:`void`};case`fd-renumber`:return e.from!==e.to&&(this.fds.dup2(e.from,e.to),e.keep||await Promise.resolve(this.fds.close(e.from))),{ok:!0,kind:`void`};case`fd-open-tty`:{let t=e.name===void 0?this.controllingTerminal():this.options.jobs?.terminalNamed(e.name);if(!t)throw new h(`ENXIO`);return{ok:!0,kind:`json`,json:this.fds.install(t.file(),3)}}case`fd-select`:{let{read:t,write:n,timeoutMs:r}=e,i=this.blockingSignal();return{ok:!0,kind:`json`,json:await Hn(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`}}}}async vfsSyscall(e){if(`path`in e||`from`in e){let t=this.nodes;return e.op===`fd-path-flush`?await t?.flush(e.path):e.op===`fd-path-unlinking`?await t?.unlinking(e.path):e.op===`fd-path-unlinked`?t?.unlinked(e.path):e.op===`fd-path-renamed`&&t?.renamed(e.from,e.to),{ok:!0,kind:`void`}}let t=this.fds.get(e.fd).file;if(!t.pread||!t.pwrite||!t.resize||!t.stat)throw new h(`ESPIPE`);switch(e.op){case`fd-pread`:return{ok:!0,kind:`bytes`,bytes:await t.pread(Math.min(e.max,sr),e.offset)};case`fd-pwrite`:return{ok:!0,kind:`json`,json:await t.pwrite(e.body,e.offset)};case`fd-resize`:return await t.resize(e.size),{ok:!0,kind:`void`};case`fd-vfs-stat`:return{ok:!0,kind:`json`,json:await t.stat()}}}promote(e){if(!this.fds.get(e.fd).file.held)throw new h(`EBADF`);if(e.share!==void 0){this.fds.dup2(e.share,e.fd);return}if(!this.options.fs||e.path===void 0)throw new h(`EINVAL`);let t=Zn(this.options.fs,{path:e.path,flags:e.flags??0,position:e.position??0,...e.contents===void 0?{}:{contents:e.contents},...e.orphan?{orphan:!0}:{}},this.nodes);this.fds.installAt(e.fd,t)}reserve(e,t=3,n){if(e===void 0)return this.fds.install(f(n),Math.max(3,t));if(this.fds.has(e))throw new h(`EBADF`);return this.fds.installAt(e,f(n)),e}fdInfo(e){let t=this.fds.get(e).file,n=this.fds.statusFlags(e);return{tty:t.tty!==void 0,kind:t instanceof L?`socket`:v(t),...t.heldMeta?{meta:t.heldMeta}:{},...n===void 0?{}:{flags:n},...this.fds.closesOnExec(e)?{cloexec:!0}:{},...t.tty?.name?{name:t.tty.name}:t.pty?{name:`/dev/ptmx`}:{}}}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=t.controllingTerminal(this.pid);if(n!==void 0&&n!==e)return;let r=this.pgid();if(t.tcgetpgrp(e,this.sid())!==r)throw this.ignored&H(B.TTIN)?new h(`EIO`):(t.killGroup(r,B.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,n=t.tty??t.pty?.slave;if(!n)throw new h(`ENOTTY`);return n}socketSyscall(e){return this.net??=this.options.net??new yn,Gn(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&&!wn(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`dl-log`:return e.append&&this.dlLog.push(e.append),{ok:!0,kind:`json`,json:this.dlLog.slice(e.from)};case`proc-alarm`:return this.setAlarm(e.sig,e.firstMs??e.ms,e.repeat?e.ms:0,e.timer),{ok:!0,kind:`void`};case`sig-mask`:return this.caught=e.caught,this.ignored=e.ignored,{ok:!0,kind:`void`};case`sig-pause`:return this.pause();case`proc-captured`:return{ok:!0,kind:`bytes`,bytes:this.children.captured(e.pid,e.slot)}}}pause(){let e=this.blockingSignal();return new Promise((t,n)=>{e.addEventListener(`abort`,()=>n(new h(`EINTR`)),{once:!0})})}dlLog=[];alarm;alarmEvery;setAlarm(e,t,n,r){if(!wn(e))throw new h(`EINVAL`);if(this.clearAlarm(),t<=0)return;let i=r===void 0?()=>this.options.raise?.(e):()=>this.timerExpired(r);this.alarm=setTimeout(()=>{this.alarm=void 0,i(),n>0&&(this.alarmEvery=setInterval(i,n))},t)}timerExpired(e){this.options.onTimer?.(e);let t=this.interrupt;this.interrupt=new AbortController,t.abort()}clearAlarm(){clearTimeout(this.alarm),clearInterval(this.alarmEvery),this.alarm=void 0,this.alarmEvery=void 0}async exit(){this.exited||(this.exited=!0,this.clearAlarm(),await this.fds.closeAll())}};function lr(){return new Worker(new URL(`/assets/process-worker-mYSiRbYg.js`,``+import.meta.url),{type:`module`})}const ur=new WeakMap;let dr=1;function fr(e){let t=ur.get(e);return t===void 0&&ur.set(e,t=dr++),t}function pr(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 L?`socket`:v(n.file);return{fd:t,kind:i,...r===void 0?{}:{flags:r},...e.closesOnExec(t)?{cloexec:!0}:{},...i===`stream`?{desc:fr(n)}:{}}})}function mr(e){let t=new SharedArrayBuffer(64+ue),n=new Int32Array(t,0,16),r=new cr(e.pid,e.fds,{spawner:e.spawner,forker:e.forker,fs:e.fs,kill:e.kill,jobs:e.jobs,ptys:e.ptys,net:e.net,onPending:e=>void Atomics.or(n,8,H(e)),onTimer:e=>void Atomics.or(n,9,1<<e),hasPending:()=>Atomics.load(n,8)!==0||Atomics.load(n,9)!==0,...e.program.abi===`wasi`?{pendingBits:()=>Atomics.load(n,8)}:{},raise:e=>y(e)}),i=se({fs:e.fs,cwd:e.cwd}),a=(e.createWorker??lr)(),o=async e=>or(e)?r.syscall(e):`op`in e&&typeof e.op==`string`&&`path`in e?le(e):{ok:!1,errno:`ENOSYS`,message:`wasm-realm: no exec yet`},s=de(a,t,i,{dispatch:o}),c,l=new Promise(e=>c=e),u=!1,d,f=(e,t)=>{if(!u){u=!0,d=t??r.execTermsig,a.removeEventListener(`message`,m),a.removeEventListener(`error`,h),s.dispose();for(let e of[...g.keys()])_(e);ce(i),a.terminate(),r.exit().then(()=>c(e),()=>c(e))}},p=t=>{t?.type===`wasm-process-exit`?f(typeof t.code==`number`?t.code:70):t?.type===`wasm-process-error`?(e.onError?.(String(t.message)),f(70)):t?.type===`wasm-thread-spawn`&&t.thread&&ee(t.thread)},m=e=>p(e.data),h=t=>{t.preventDefault(),e.onError?.(String(t.message??`worker error`)),f(70)},g=new Map,_=e=>{let t=g.get(e);g.delete(e),t?.()},ee=t=>{if(u)return;if(g.size>=63){e.onError?.(`more than 64 threads`),f(70);return}let n=new SharedArrayBuffer(64+ue),r=(e.createWorker??lr)(),a=de(r,n,i,{dispatch:o}),s=e=>{let n=e.data;n?.type===`wasm-thread-exit`?_(t.tid):p(n)};r.addEventListener(`message`,s),r.addEventListener(`error`,h),g.set(t.tid,()=>{r.removeEventListener(`message`,s),r.removeEventListener(`error`,h),a.dispose(),r.terminate()});let c={type:`wasm-thread-init`,pid:e.pid,program:e.program,argv0:e.argv0,args:e.args,env:e.env,cwd:e.cwd,sab:n,...e.ppid===void 0?{}:{ppid:e.ppid},thread:t};r.postMessage(c)};a.addEventListener(`message`,m),a.addEventListener(`error`,h);let v={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.ppid===void 0?{}:{ppid:e.ppid},...e.fork?{fork:e.fork}:{fds:pr(e.fds)}};a.postMessage(v,e.fork?[e.fork.memory.buffer]:[]);let y=e=>{r.signal(e)===`terminate`&&f(e===B.KILL?137:128+e,e)};return{pid:e.pid,exited:l,kill:(e=137)=>f(e,e>128&&e<160?e-128:void 0),signal:y,termsig:()=>d,onState:e=>r.onState(e)}}var hr=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}terminalNamed(e){return[...new Set([...this.terminals.values(),...this.foreground.keys()])].find(t=>t.name===e)}controllingTerminal(e){let t=this.members.get(e);return t&&(this.terminals.get(t.sid)??null)}acquireTerminal(e,t){let n=this.members.get(e);return!n||n.sid!==e||this.terminals.has(e)||[...this.terminals.values()].includes(t)?!1:(this.terminals.set(e,t),this.foreground.set(t,n.pgid),!0)}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)}signalOwnedForeground(e,t){let n=this.foreground.get(e);n!==void 0&&this.killGroup(n,t)}signalForeground(e,t,n){this.killGroup(this.tcgetpgrp(e,t),n)}};function gr(e){let t=8,n=()=>{let n=0,r=0;for(;;){let i=e[t++];if(n|=(i&127)<<r,!(i&128))return n>>>0;r+=7}},r=()=>{let r=n(),i=new TextDecoder().decode(e.subarray(t,t+r));return t+=r,i},i=()=>{let r=e[t++];return{initial:n(),maximum:r&1?n():void 0,shared:!!(r&2)}};for(;t<e.length;){let a=e[t++],o=n(),s=t+o;if(a!==2){t=s;continue}let c=n();for(let a=0;a<c;a++){let a=r(),o=r(),s=e[t++];if(s===0)n();else if(s===1)t++,i();else if(s===2)return{module:a,name:o,...i()};else s===3?t+=2:s===4&&(t++,n())}return}}const _r=/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g;function vr(e,t){let n={};for(let[r,i]of Object.entries(e)){let e=!1,a=i.replace(_r,(n,r)=>{let i=Object.hasOwn(t,r)?t[r]:void 0;return i===void 0&&(e=!0),i??``});e||(n[r]=a)}return n}function yr(e,t){if(!e)return t;let n=vr(e,t);if(!(t.GIT_CONFIG_SYSTEM!==void 0&&un(`GIT_CONFIG_SYSTEM`,t.GIT_CONFIG_SYSTEM))||!(`GIT_CONFIG_NOSYSTEM`in n))return{...n,...t};let{GIT_CONFIG_NOSYSTEM:r,...i}=n;return{...i,...t}}function br(e){return e.USER===void 0||`LOGNAME`in e?e:{...e,LOGNAME:e.USER}}function xr(e,t){return!/^(ba)?sh$/.test(Q(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 X=new Map,Sr=new Map,Cr=new Map(Object.entries(U).map(([e,t])=>[t,e])),Z=/^\/(?:usr\/)?bin\/([^/]+)$/,wr=/^(.*\/node_modules\/(?:@[^/]+\/)?[^/]+)\//,Tr=/locateFile\(\s*["']([^"'/]+\.wasm)["']\s*\)/;let Er=4e4;function Dr(e){return e.glue===e.module}const Or=[0,97,115,109];function kr(e){return Or.every((t,n)=>e[n]===t)}function Ar(e){return e.endsWith(`.js`)?`${e.slice(0,-3)}.wasm`:`${e}.wasm`}function jr(e){return Z.exec(e)?.[1]??Q(e)}function Q(e){return e.slice(e.lastIndexOf(`/`)+1)}function Mr(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 Nr(e){return ne(Mr(e),y)}function Pr(e,t){return`${e}:${t.size}:${t.mtime.getTime()}`}function Fr(e,t){return X.set(e,t),t.catch(()=>X.delete(e)),t}async function Ir(e,t){let n=Pr(t,await e.fs.stat(t));return X.get(n)??Fr(n,oe(t=>e.fs.readFileBuffer(t),t))}function Lr(e,t){return Sr.set(e,gr(t)),Fr(e,ae(t))}async function Rr(e,t){let n=Pr(t,await e.fs.stat(t)),r=X.get(n),i=await(r&&Sr.has(n)?r:Lr(n,await e.fs.readFileBuffer(t))),a=Sr.get(n);return{module:i,...a?{memory:a}:{}}}async function zr(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(X.has(n))return!0;let r;try{r=await e.fs.readFileBuffer(t)}catch{return!1}return kr(r)?(Lr(n,r).catch(()=>void 0),!0):!1}function Br(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 Hr(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 $(e,t,n){if(n.length===0||!e.has(t))return;let r=e.get(t).file;try{await r.write?.(n)}catch{}}function Ur(e,t){return e.has(t)&&e.get(t).file.tty!==void 0}function Wr(e){return{...Ur(e,0)?{}:{[ee]:`0`},...Ur(e,1)?{}:{[m]:`0`}}}function Gr(e){return{pid:e.pid,exited:e.exited,termsig:e.termsig,onState:t=>e.onState(t)}}const Kr=new WeakMap;var qr=class{ctx;processConfig;onError;gate;lookup;live=new Set;shellChildren=new Set;wasmByPid=new Map;shellByPid=new Map;installed;jobs=new hr;ptys=new In((e,t)=>this.jobs.signalOwnedForeground(e,t));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=xn(z(t?.owner));let a=z(t?.owner);fn(this.net,{process:t,tls:{owner:a}})}commands(){return this.lookup?this.lookup():(this.installed??=Nr(this.ctx),this.installed)}async launch(e){let t=Dr(e),n=``,r,i;try{t?{module:r,memory:i}=await Rr(this.ctx,e.module):(n=await this.ctx.fs.readFile(e.glue),r=await Ir(this.ctx,e.module)),e.signal?.throwIfAborted()}catch(t){throw await e.fds.closeAll(),t}let a=xr(e.argv0,br(yr(e.defaults,e.env)));return t&&await this.pythonPackages(e,a),this.start({...e,env:a,program:t?{abi:`wasi`,glue:n,module:r,...i?{memory:i}:{}}:{glue:n,module:r}})}async pythonPackages(e,t){let n=wr.exec(e.module)?.[1];if(n)try{let r=Mr(this.ctx),i=await r.readFile(`${n}/package.json`,{encoding:`utf-8`}),a=JSON.parse(typeof i==`string`?i:new TextDecoder().decode(i)),o=typeof a.name==`string`?a.name:n,s=re(n,o,a.slicc?.python).interpreter;if(!s)return;let{packages:c}=await this.pythonScan(r),l=await te(this.ctx.fs,t.HOME??`/home`,s,c);if(l.length>0){let t=`${s.abi}-${s.platform}`,n=`${e.argv0}: not for ${t}, left off the path: ${l.map(e=>e.pkg).join(`, `)}\n`;await $(e.fds,2,new TextEncoder().encode(n))}}catch{}}pythonScan(e){return this.commands().then(t=>{let n=Kr.get(t);return n||(n=ie(e,y),Kr.set(t,n)),n})}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=mr({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,ptys:this.ptys,net:this.net,...e.fork?{fork:e.fork}:{},...e.ppid===void 0?{}:{ppid:e.ppid}});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(U[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=Cr.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=Z.exec(e)?.[1]??(e.includes(`/`)?void 0:e);if(r!==void 0){let e=await this.commands(),t=e.get(r);if(t?.script)return;if(t)return{glue:t.glue,module:t.wasm,argv0:t.argv0,...t.args?{prefixArgs:t.args}:{},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=Ar(i);return await this.ctx.fs.exists(a)?{glue:i,module:a,argv0:Q(t||e)}:await zr(this.ctx,i)?{glue:i,module:i,argv0:Q(t||e).replace(/\.wasm$/,``)}:this.packagedCopy(i,t||e)}async packagedCopy(e,t){let n=wr.exec(e)?.[1];if(n===void 0)return;let r;try{r=await this.ctx.fs.readFile(e)}catch{return}let i=Tr.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:Q(t),defaults:e.env}}}forker(e,t){return async(n,r)=>Gr(this.start({...t,cwd:n.cwd??t.cwd,fds:r,ppid:e,fork:n}))}async scriptCommand(e){let t=Z.exec(e)?.[1]??(e.includes(`/`)?void 0:e);if(t===void 0)return;let n=(await this.commands()).get(t);return n?.script?n:void 0}async interpreted(e){let t=await this.scriptCommand(e.file);if(!t&&(!e.file.includes(`/`)||Z.test(e.file)))return;let n=t?.script??this.ctx.fs.resolvePath(e.cwd,e.file),r;try{r=(await this.ctx.fs.readFileBuffer(n)).subarray(0,256)}catch{return}if(r[0]!==35||r[1]!==33)return;let[i,...a]=new TextDecoder().decode(r).slice(2).split(`
|
|
12
|
-
`)[0].trim().split(/[ \t]+/);if(!i)return;let o=await this.resolve(i,i,e.cwd);if(!o)return;let s=t?.env?{...o,defaults:{...o.defaults,...t.env}}:o,c=a.join(` `);return{target:s,file:i,args:[...o.prefixArgs??[],...c?[c]:[],t?n: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:[...r.prefixArgs??[],...t.argv.slice(1)]}:await this.interpreted(t);if(!i){if(!await this.shellRuns(t))throw n.closeAll().catch(()=>void 0),new W(`ENOENT`);return this.runShellChild(t,n,e)}let a=await this.gate?.(jr(i.file),i.args,t.env);return a?this.deniedChild(t,n,e,a):Gr(await this.launch({...i.target,args:i.args,env:t.env,cwd:t.cwd,fds:n,ppid:e}))}}async shellRuns(e){let t=Z.exec(e.file)?.[1]??(e.file.includes(`/`)?void 0:e.file);if(t===void 0)return this.ctx.fs.exists(this.ctx.fs.resolvePath(e.cwd,e.file));let n=this.ctx.getRegisteredCommands?.();return!n||n.includes(t)||!this.ctx.exec?!0:(await this.ctx.exec(`command`,{args:[`-v`,t],cwd:e.cwd,env:e.env,replaceEnv:!0})).exitCode===0}deniedChild(e,t,n,r){let{pid:i}=this.register(`shell`,e.argv,e.cwd,e.env,n),a=(async()=>(await $(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 W(`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=>{V(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(U[t])}),d=(async()=>{try{let n=Ur(t,0),i=t.has(0)&&!n?await Hr(t.get(0)):new Uint8Array,a=await r(e.file,{args:e.argv.slice(1),cwd:e.cwd,env:{...e.env,...Wr(t)},replaceEnv:!0,stdin:Br(i),stdinKind:`bytes`,signal:o.signal});return await $(t,1,a.stdoutKind===`bytes`?Vr(a.stdout):new TextEncoder().encode(a.stdout)),await $(t,2,new TextEncoder().encode(a.stderr)),a.exitCode}catch(n){let r=n instanceof Error?n.message:String(n);return await $(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:Er++}}};const Jr=`usage: wasm [-t] [--argv0 NAME] [--module PATH] [--listen [HOST:]PORT] PROGRAM [ARGS...]
|
|
13
|
-
wasm --list
|
|
14
|
-
wasm --login
|
|
15
|
-
`;function Yr(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 Xr(e,t){return t.commands?.()??Nr(e)}function Zr(e){if(!e)return()=>{};let t=new TextDecoder;return n=>{let r=t.decode(n,{stream:!0});r&&e(r)}}function Qr(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(ui(e))),d.install(p(u(i,Zr(r)))),d.install(p(u(n,Zr(r)))),{fds:d,collected:()=>({stdout:li(i),note:l?`wasm: output exceeded ${a} bytes; stopped\n`:``}),release:()=>{}}}function $r(e,t){let n=new kn({write:t=>e.write(t)},e=>t.signalTerminal(n,e));n.name=`/dev/tty1`,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 ei(e,t){return Object.fromEntries(Object.entries(e).filter(([e,n])=>e in t||!un(e,n)))}async function ti(e,t){let n=z(t.processConfig?.owner);return dn(e.fs,nn(ni(e),n),n)}function ni(e){return e.exportedEnv?.HOME??e.env.get(`HOME`)??`/tmp`}async function ri(e,t){let n=await t.gitIdentity?.().catch(()=>void 0);return ln(e.fs,on(ni(e)),n)}function ii(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??=pe),r}async function ai(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 Xr(e,t)).has(`bash`))return n;let r=c(new TextEncoder().encode(me));return hi([`-t`,`--login-prompt`,`bash`,`--rcfile`,`/dev/fd/98`,`-i`],e,{...t,fds:[[98,r]]})}function oi(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 si(e,t,n){let r=``;try{r=(await e.fs.readFile(n)).split(`
|
|
16
|
-
`,1)[0]??``}catch{return`${t}: ${n}: No such file or directory`}return r.startsWith(`#!`)?`${t}: ${r.slice(2).trim().split(/[ \t]+/)[0]??``}: bad interpreter: No such file or directory`:`${t}: ${n}: no #! line naming its interpreter`}async function ci(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);if(!r)return n;if(r.script){let i=await t.interpreted({file:n.program,argv:[n.program,...n.args],cwd:e.cwd});return i?{...n,argv0:i.target.argv0,module:i.target.module,program:i.target.glue,args:i.args,defaults:i.target.defaults}:{error:await si(e,n.program,r.script)}}return{...n,argv0:n.argv0??r.argv0,module:n.module??r.wasm,program:r.glue,args:[...r.args??[],...n.args],defaults:r.env}}function li(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 ui(e){let t=fe(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 di(e,t,n){return t.module?e.fs.resolvePath(e.cwd,t.module):await zr(e,n)?n:Ar(n)}function fi(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 pi(e,t,n){if(e.listen===void 0)return{env:{}};let r=fi(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 mi(e,t){return e.defaults??t.defaults}async function hi(e,t,n={}){let{processConfig:r,terminal:i}=n;if(e[0]===`--help`||e[0]===`-h`)return{stdout:Jr,stderr:``,exitCode:0};if(e[0]===`--login`&&e.length===1)return ai(t,n);if(e[0]===`--list`&&e.length===1)return{stdout:oi(await Xr(t,n)),stderr:``,exitCode:0};let a=Yr(e);if(!a)return{stdout:``,stderr:Jr,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)
|
|
17
|
-
`,exitCode:126};let o=[],s=e=>{o.push(new TextEncoder().encode(`wasm: ${e}\n`))},c=new qr(t,r,e=>s(e),n.gate,n.commands),l=await ci(t,c,a);if(`error`in l)return{stdout:``,stderr:`${l.error}\n`,exitCode:127};let u=t.fs.resolvePath(t.cwd,l.program),d=await di(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)
|
|
18
|
-
`,exitCode:1};f=$r(e,c),s=t=>e.write(new TextEncoder().encode(`wasm: ${t}\r\n`))}else f=Qr(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=pi(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:{...ii(t,l,{...Zt(),...await ti(t,n),...await ri(t,n)}),...m.env},defaults:mi(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(gi(o)),exitCode:e,stdoutKind:`bytes`}}finally{f.release(),t.signal?.removeEventListener(`abort`,g)}}function gi(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{hi as runWasmCommand,ei as withoutRealmDefaults};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function e(){return{version:`6.235.0`,releasedAt:`2026-10-02T17:55:42Z`,buildId:`6.235.0-mur9kl7y`}}let t=null;function n(e){t=e}function r(){return t}export{e as n,n as r,r as t};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./panel-rpc-accessor-B4BfPLSo.js";import{m as t}from"./state-Tykh4Vum.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
|
-
`)){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
|
-
`)}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
|
-
`);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(`
|
|
5
|
-
`)}}export{x as a,u as i,h as n,n as o,l as r,b as t};
|