sliccy 6.237.2 → 6.238.1
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-BOv2yBlr.js +1 -0
- package/dist/ui/assets/{account-store-CivERjco.js → account-store-BCtXK44B.js} +1 -1
- package/dist/ui/assets/{account-store-nItMZcAJ.js → account-store-C4jFzcnJ.js} +1 -1
- package/dist/ui/assets/{adobe-MMPVnSgh.js → adobe-C4ooMe21.js} +1 -1
- package/dist/ui/assets/{adobe-4eesEDU-.js → adobe-DemK72Ow.js} +1 -1
- package/dist/ui/assets/{agent-panels-DXzQhcvZ.js → agent-panels-CSihjufA.js} +1 -1
- package/dist/ui/assets/{almost-bash-shell-headless-CuCsoGqg.js → almost-bash-shell-headless-MaULAwCk.js} +563 -637
- package/dist/ui/assets/{apply-layout-B2b7IUja.js → apply-layout-CtPcVAlt.js} +1 -1
- package/dist/ui/assets/{azure-openai-C4mbMK4r.js → azure-openai-Cgukt6kz.js} +1 -1
- package/dist/ui/assets/{azure-openai-Cr3qJeUH.js → azure-openai-D3kSXfVg.js} +1 -1
- package/dist/ui/assets/{cdp-B22XS335.js → cdp-yUs7BKnl.js} +67 -10
- package/dist/ui/assets/{cerebras-BaMBQf_X.js → cerebras-CXUqbHeU.js} +1 -1
- package/dist/ui/assets/{cerebras-BuYH9IiU.js → cerebras-DKNgM2vX.js} +1 -1
- package/dist/ui/assets/{composer-speech-DzH0Bd4f.js → composer-speech-DKdxsF9o.js} +1 -1
- package/dist/ui/assets/{connect-surface-CyrhmG_X.js → connect-surface-DaUDdGjw.js} +1 -1
- package/dist/ui/assets/{directed-approval-Y33yS_Sc.js → directed-approval-o-AaFndq.js} +1 -1
- package/dist/ui/assets/{emscripten-vfs-hook-CZ1HwPSC.js → emscripten-vfs-hook-fuZPCx2X.js} +1 -1
- package/dist/ui/assets/{frozen-archive-writer-D0G3o1-H.js → frozen-archive-writer-BTgbp54d.js} +1 -1
- package/dist/ui/assets/{gelatiere-unit-CHmUVRvm.js → gelatiere-unit-C_Ae4LbS.js} +1 -1
- package/dist/ui/assets/{github-C4Vhddvl.js → github-BA6d9eht.js} +1 -1
- package/dist/ui/assets/{github-DlK6mA37.js → github-Dio3imoh.js} +1 -1
- package/dist/ui/assets/{github-copilot-DekLIFTd.js → github-copilot-QflVq9Sv.js} +1 -1
- package/dist/ui/assets/{github-copilot-lAZ4OZ2r.js → github-copilot-jJPLzphe.js} +1 -1
- package/dist/ui/assets/{go-driver-DS6D_tfi.js → go-driver-CvHJRpyw.js} +3 -3
- package/dist/ui/assets/{hear-C4ca410z.js → hear-B3M8eRJT.js} +1 -1
- package/dist/ui/assets/{help-DuAvKnbR.js → help-DcgBLrYQ.js} +1 -1
- package/dist/ui/assets/{js-realm-worker-DJD5ZrxD.js → js-realm-worker-DRt9zLrg.js} +2 -2
- package/dist/ui/assets/{jsh-executor-C2__rSFU.js → jsh-executor-Cd1GQ0OP.js} +3 -3
- package/dist/ui/assets/{kernel-worker-CjZd9XRW.js → kernel-worker-my32WaPE.js} +132 -75
- package/dist/ui/assets/{lick-ws-bridge-DGKfgSKw.js → lick-ws-bridge-7CqP4WuI.js} +1 -1
- package/dist/ui/assets/{lick-ws-bridge-CRI7ClW9.js → lick-ws-bridge-K4Z32oej.js} +1 -1
- package/dist/ui/assets/{live-session-curation-Cazg45Op.js → live-session-curation-DDbemDZ6.js} +1 -1
- package/dist/ui/assets/{live-session-snapshot-Ctqy459R.js → live-session-snapshot-DvDg9OPs.js} +1 -1
- package/dist/ui/assets/{local-llm-D0ojMz3e.js → local-llm-BIaPO0CA.js} +1 -1
- package/dist/ui/assets/{local-llm-yQTqA0rT.js → local-llm-CRo-6fGR.js} +1 -1
- package/dist/ui/assets/{main-CwuzK63d.js → main-DDVh6Avm.js} +3 -3
- package/dist/ui/assets/{main-cherry-D-nAkYws.js → main-cherry-DqfkS0P5.js} +1 -1
- package/dist/ui/assets/{mcp-command-DvN8ZhAS.js → mcp-command-Btiuj-jI.js} +9 -9
- package/dist/ui/assets/{memory-curation-seam-CDJkbUen.js → memory-curation-seam-aAPl5vkT.js} +1 -1
- package/dist/ui/assets/{memory-health-CbJmcfg5.js → memory-health-Dk9_Owqi.js} +1 -1
- package/dist/ui/assets/{memory-write-execute-BgP8zbbw.js → memory-write-execute-2vEawCxj.js} +1 -1
- package/dist/ui/assets/{merge-folded-cost-into-frozen-1G2R8HHx.js → merge-folded-cost-into-frozen-DtJKmur-.js} +1 -1
- package/dist/ui/assets/{new-session-BR0chPjF.js → new-session-Dyoiqjx7.js} +2 -2
- package/dist/ui/assets/{oauth-bootstrap-vp6UbI-4.js → oauth-bootstrap-BHaGmQuH.js} +2 -2
- package/dist/ui/assets/{onboarding-orchestrator-CzvMpmV1.js → onboarding-orchestrator-B6ttynZz.js} +1 -1
- package/dist/ui/assets/{openai-codex-C6lioSUA.js → openai-codex-DD78zvo0.js} +1 -1
- package/dist/ui/assets/{openai-codex-O8d_rNUe.js → openai-codex-LQisGyNi.js} +1 -1
- package/dist/ui/assets/{openrouter-COsS8Xpw.js → openrouter-BSo_vl4k.js} +1 -1
- package/dist/ui/assets/{openrouter-zonVO2eI.js → openrouter-DpgNQbmE.js} +1 -1
- package/dist/ui/assets/{openrouter-free-ByMT7WZ1.js → openrouter-free-B_GqODIL.js} +1 -1
- package/dist/ui/assets/{openrouter-free-P1MfNqEl.js → openrouter-free-CQQJEFzf.js} +1 -1
- package/dist/ui/assets/{openrouter-oauth-CPxQhdjy.js → openrouter-oauth-BnJMmgE0.js} +1 -1
- package/dist/ui/assets/{openrouter-oauth-SYD1905j.js → openrouter-oauth-CHeVt7YP.js} +1 -1
- package/dist/ui/assets/{panel-rpc-handlers-Bqn2L52U.js → panel-rpc-handlers-CatvINmN.js} +2 -2
- package/dist/ui/assets/{panelize-shell-LwoDOAMg.js → panelize-shell-Nh9snCaw.js} +1 -1
- package/dist/ui/assets/{pi-edit-execution-Ck6QElbD.js → pi-edit-execution-DLSOh-vn.js} +1 -1
- package/dist/ui/assets/pipe-status-BBrT3VeG.js +5 -0
- package/dist/ui/assets/{provider-B6Br6Gyv.js → provider-BWoACff3.js} +1 -1
- package/dist/ui/assets/{provider-CU3KQBgV.js → provider-D1tmekEg.js} +1 -1
- package/dist/ui/assets/{provider-settings-D9qJh-F0.js → provider-settings-BIeT1Kq1.js} +1 -1
- package/dist/ui/assets/provider-store-access-BoYpv_zg.js +1 -0
- package/dist/ui/assets/provider-store-access-C-XzgW97.js +1 -0
- package/dist/ui/assets/{providers-C8yJv_dr.js → providers-BAE1vIhe.js} +1 -1
- package/dist/ui/assets/{providers-CIG9-dLB.js → providers-DuWMGRl5.js} +2 -2
- package/dist/ui/assets/{quick-llm-BrUsz6_e.js → quick-llm-Dl2K77Gl.js} +1 -1
- package/dist/ui/assets/{realm-inprocess-DA-IpJz_.js → realm-inprocess-CoEb-6j3.js} +2 -2
- package/dist/ui/assets/{realm-unhandled-rejections-BlU0laaY.js → realm-unhandled-rejections-CYuXlq1n.js} +1 -1
- package/dist/ui/assets/{realm-unhandled-rejections-CEC2iGJJ.js → realm-unhandled-rejections-ptnmwsDO.js} +1 -1
- package/dist/ui/assets/{recovery-screen-CJLHjEMb.js → recovery-screen-Dy45LlR9.js} +1 -1
- package/dist/ui/assets/{remote-terminal-view-X8J5vWDE.js → remote-terminal-view-4M1-99_r.js} +2 -2
- package/dist/ui/assets/restore-weSKzOvD.js +1 -0
- package/dist/ui/assets/{run-DMfFMxTu.js → run-BluNZqg2.js} +1 -1
- package/dist/ui/assets/{run-B7Gxq2hA.js → run-CAk52sqo.js} +1 -1
- package/dist/ui/assets/run-DKWaudm_.js +18 -0
- package/dist/ui/assets/{run-Cxla4Ky-.js → run-Dfqc_wPL.js} +2 -2
- package/dist/ui/assets/{run-_s42Xqna.js → run-DvNJEF6S.js} +2 -2
- package/dist/ui/assets/{run-XzRUhomo.js → run-_Bioonv1.js} +1 -1
- package/dist/ui/assets/script-catalog-D5joO5l7.js +2 -0
- package/dist/ui/assets/{session-command-memory-B9VZUetL.js → session-command-memory-D4W3vYO0.js} +2 -2
- package/dist/ui/assets/{session-jsonl-Cy6mSJro.js → session-jsonl-DQLn7BhM.js} +1 -1
- package/dist/ui/assets/{session-jsonl-C7YjxaqI.js → session-jsonl-Ddr8h01D.js} +1 -1
- package/dist/ui/assets/{session-search-index-k_YYabTx.js → session-search-index-CPuVujaI.js} +1 -1
- package/dist/ui/assets/{setup-feature-flags-remote-BFeC2dQJ.js → setup-feature-flags-remote-BEN7v8wL.js} +1 -1
- package/dist/ui/assets/{setup-model-catalog-Chd_-juK.js → setup-model-catalog-kHlvq1OQ.js} +1 -1
- package/dist/ui/assets/{silent-renew-backoff-D1G-RWqE.js → silent-renew-backoff-D70ksoq1.js} +1 -1
- package/dist/ui/assets/slicc-version-BH37H7i7.js +1 -0
- package/dist/ui/assets/snapshot-DOcF3hJX.js +5 -0
- package/dist/ui/assets/snapshot-features-DS-wngT-.js +9 -0
- package/dist/ui/assets/{soundscape-Ct3AH8QQ.js → soundscape-B6zBj4Iv.js} +1 -1
- package/dist/ui/assets/{speak-DJXj5PvG.js → speak-C-SrEuoh.js} +1 -1
- package/dist/ui/assets/{sprinkle-manager-LjJrtRZH.js → sprinkle-manager-DgZx1uoa.js} +1 -1
- package/dist/ui/assets/{sprinkle-renderer-HUCbAhU7.js → sprinkle-renderer-k7sbHOXk.js} +1 -1
- package/dist/ui/assets/{state-BOigwV2f.js → state-vriQRO0O.js} +5 -5
- package/dist/ui/assets/{sudo-BXJunwqL.js → sudo-D7vpuQ10.js} +1 -1
- package/dist/ui/assets/{supervisor-U9qlUctV.js → supervisor-Dt8Pw9d3.js} +1 -1
- package/dist/ui/assets/{sync-dialog-LspjDHlq.js → sync-dialog-DpwDmSDa.js} +1 -1
- package/dist/ui/assets/{transformers-env-BMp3dDDM.js → transformers-env-C0Yb__tm.js} +1 -1
- package/dist/ui/assets/{tray-leader-a3iXhi2A.js → tray-leader-BbkPYZsT.js} +1 -1
- package/dist/ui/assets/{tray-leave-runtime-BHizYKM6.js → tray-leave-runtime-DYyVe7iD.js} +1 -1
- package/dist/ui/assets/{tray-sidecar-C8Q4XNtE.js → tray-sidecar-DUD4cDKg.js} +1 -1
- package/dist/ui/assets/{upgrade-detection-eU9c4eEh.js → upgrade-detection-r5LC465b.js} +1 -1
- package/dist/ui/assets/{voice-reply-DeHGblbd.js → voice-reply-DpcyhU9z.js} +1 -1
- package/dist/ui/assets/{wc-attach-DLREOCz-.js → wc-attach-xRsI6vlF.js} +2 -2
- package/dist/ui/assets/{wc-browser-BtZeD7Zc.js → wc-browser-LUPp8FMq.js} +1 -1
- package/dist/ui/assets/{wc-computers-TX6BQM57.js → wc-computers-CiIA2mic.js} +1 -1
- package/dist/ui/assets/{wc-detached-BxT0et3z.js → wc-detached-DokY3p96.js} +1 -1
- package/dist/ui/assets/{wc-extension-BWo9_LqW.js → wc-extension-CL7ZNW5r.js} +2 -2
- package/dist/ui/assets/{wc-follower-BAmWu-u0.js → wc-follower-BqChAtCl.js} +3 -3
- package/dist/ui/assets/{wc-follower-oauth-C3mtX0jD.js → wc-follower-oauth-JD5VOYTd.js} +1 -1
- package/dist/ui/assets/{wc-gelatiere-XfyqMi6T.js → wc-gelatiere-DNCUwAp1.js} +1 -1
- package/dist/ui/assets/{wc-live-CaTybw3B.js → wc-live-DT9MR1Sa.js} +5 -5
- package/dist/ui/assets/{wc-nav-TlytGNMB.js → wc-nav-BD-jmYJB.js} +2 -2
- package/dist/ui/assets/{wc-onboarding-DA2R9grP.js → wc-onboarding-CXO7WSqh.js} +2 -2
- package/dist/ui/assets/{wc-permissions-BK6nOWSB.js → wc-permissions-CZneIa8b.js} +2 -2
- package/dist/ui/assets/{wc-placeholder-Cj1kmDRN.js → wc-placeholder-BOHp8Moc.js} +3 -3
- package/dist/ui/assets/{wc-secret-request-DkCIXIYZ.js → wc-secret-request-DmgBT7Kf.js} +1 -1
- package/dist/ui/assets/{wc-settings-Cf_nJ6JU.js → wc-settings-C4PfwLyN.js} +3 -3
- package/dist/ui/assets/{wc-shell-DOvfO-Op.js → wc-shell-FF40TncL.js} +12 -4
- package/dist/ui/assets/{wc-shortcut-config-CBtz7DgT.js → wc-shortcut-config-CbT6ZrWU.js} +1 -1
- package/dist/ui/assets/{wc-sprinkles-C_IFSUWu.js → wc-sprinkles-8eWRimnm.js} +2 -2
- package/dist/ui/assets/{wc-transcript-export-C_w4FeXX.js → wc-transcript-export-DYad8Flt.js} +2 -2
- package/dist/ui/assets/{wc-tray-zSpr15Y0.js → wc-tray-BUqNTlRe.js} +4 -4
- package/dist/ui/assets/welcome-detection-DNCtOSRv.js +1 -0
- package/dist/ui/assets/{whisper-session-B4ufzVy8.js → whisper-session-SIUgaNPF.js} +2 -2
- package/dist/ui/assets/{xai-grok-1aO0rfQw.js → xai-grok-CFA2nbp5.js} +1 -1
- package/dist/ui/assets/{xai-grok-COKdRcaD.js → xai-grok-DyihJR2q.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-IFmza_44.js +0 -1
- package/dist/ui/assets/provider-store-access-10_vLR43.js +0 -1
- package/dist/ui/assets/provider-store-access-DcsCov37.js +0 -1
- package/dist/ui/assets/reason-l_1I9RdR.js +0 -5
- package/dist/ui/assets/restore-Cvb2_Tys.js +0 -1
- package/dist/ui/assets/run-BI9A9cl8.js +0 -18
- package/dist/ui/assets/script-catalog-WaCMvXY3.js +0 -2
- package/dist/ui/assets/slicc-version-B_Uar9hQ.js +0 -1
- package/dist/ui/assets/snapshot-YDNf2VnW.js +0 -5
- package/dist/ui/assets/snapshot-features-Kbro52QQ.js +0 -12
- package/dist/ui/assets/welcome-detection-C5wmcpXs.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./wc-onboarding-CXO7WSqh.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-C-SrEuoh.js","assets/preload-helper-Czpn1I53.js","assets/logger-DDBAeTLF.js","assets/runtime-env-Dlaokqg1.js","assets/speech-assets-bridge-CFYafE89.js","assets/transformers-env-C0Yb__tm.js","assets/wc-shell-FF40TncL.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/mime-types-D0xZwlMO.js","assets/base64-ELzoYfwP.js","assets/bridge-protocol-C52CnDIj.js","assets/account-store-C4jFzcnJ.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-DuWMGRl5.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/same-file-identity-OexpsaSD.js","assets/telemetry-B0sKnLBU.js","assets/types-D8gIX-W-.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-C0Yb__tm.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-C-SrEuoh.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-BCtXK44B.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-BIeT1Kq1.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-C4jFzcnJ.js";import"./main-DDVh6Avm.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-DDVh6Avm.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-DuWMGRl5.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-C4jFzcnJ.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-DDVh6Avm.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-DuWMGRl5.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-C4jFzcnJ.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\nWhen present, accessibility states appear after the ref in Playwright aria-snapshot form — `[checked]`, `[checked=mixed]`, `[expanded]` / `[expanded=false]`, `[selected]`, `[pressed]`, `[disabled]`, `[level=N]` — so a re-snapshot shows whether a radio, disclosure, tab, or toggle changed.\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-CU3KQBgV.js";export{e as readMcpAuthEntries};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./store-tvt1tIjf.js";import"./provider-B6Br6Gyv.js";export{e as readMcpAuthEntries};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
function e(e){return/^[A-Za-z_][A-Za-z0-9_]*$/.test(e)}const t=`__SLICC_PIPESTATUS`,n=`__SLICC_PIPESTATUS_EX`,r=/^(0|[1-9]\d*)$/;function i(e){let r=a(e.trimEnd());return r?`{
|
|
2
|
-
${r}
|
|
3
|
-
}
|
|
4
|
-
${n}=$? ${t}="\${PIPESTATUS[*]}"`:e}function a(e){let t=0;for(let n=e.length-1;n>=0&&e[n]===`\\`;n--)t+=1;return t%2==0?e:`${e}\\`}function o(e){if(!e)return[];let t=e.trim().split(/\s+/).filter(Boolean);if(t.length===0)return[];let n=[];for(let e of t){if(!r.test(e))return[];let t=Number(e);if(t>255)return[];n.push(t)}return n}function s(e,t){return t?i(e):e}function c(e,t){if(!t||!e.env)return e;let n=u(e.env),r=n.exitCode===void 0?e:{...e,exitCode:n.exitCode};return n.pipeStatus.length===0?r:{...r,pipeStatus:n.pipeStatus}}function l(e,t){return t===void 0?e:{...e,pipeStatus:t}}function u(e){let i=e[t],a=e[n];delete e[t],delete e[n];let s;if(a!==void 0&&r.test(a)){let e=Number(a);e<=255&&(s=e)}return{pipeStatus:o(i),exitCode:s}}function d(e){return e.length<2||e.every(e=>e===0)||!e.every(e=>Number.isInteger(e)&&e>=0&&e<=255)?null:`pipeline: ${e.join(` `)}`}function f(e,t){let n=t?d(t):null;return n?e?e.endsWith(`
|
|
5
|
-
`)?`${e}${n}`:`${e}\n${n}`:n:e}function p(e){let t=e.replace(/\s+/g,` `).trim();if(t.length<=300)return t;let n=Array.from(t);return n.length<=300?t:`${n.slice(0,299).join(``).trimEnd()}…`}export{c as a,e as c,f as i,t as n,l as o,n as r,s,p as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,s as t,t as n}from"./almost-bash-shell-headless-CuCsoGqg.js";import{n as r}from"./browser-CGX7MbCQ.js";import{c as i}from"./sudoers-BdBYQPUn.js";import{r as a}from"./sudo-fs-D88yRk1b.js";import{n as o}from"./jsh-discovery-CnvNKojr.js";import{o as s}from"./just-bash-compat-B-SPHuh_.js";import{n as c,r as l}from"./supervisor-U9qlUctV.js";function u(e,n){return new Map(Object.entries({HOME:t,PATH:o,USER:`user`,SHELL:`/bin/bash`,TMPDIR:`/tmp`,PWD:e.cwd,...n,...e.env}))}function d(e,t,n,i){let a=u(t,i);return r({fs:e,cwd:t.cwd,env:a,stdin:s(``),exec:(e,r)=>n.exec(e,{env:r?.env??Object.fromEntries(a),cwd:r?.cwd??t.cwd,args:r?.args,...r?.env===void 0?{}:{replaceEnv:!0}})})}const f={requestApproval:async()=>({decision:`deny`})};async function p(t){let r=h(t.fs,t.sudo),i=new e(r),a=new n({fs:r,cwd:`/workspace`,processManager:t.processManager,processOwner:{kind:`jshd`}}),o={exec:(e,t)=>a.getBash().exec(e,{env:t?.env??a.getEnv(),cwd:t?.cwd??`/workspace`,args:t?.args,...t?.env===void 0?{}:{replaceEnv:!0}})},s=c({fs:t.fs,processManager:t.processManager,lickManager:t.lickManager,...t.realmFactory?{realmFactory:t.realmFactory}:{},buildContext:e=>m(i,e,o)}),u=(await l(t.fs)).filter(e=>e.enabled);if(u.length===0)return[];let d=[];for(let e of u)try{await s.start(e),d.push(e.name)}catch{}return d}function m(e,t,n){return d(e,t,n)}function h(e,t){return a(e,{broker:t?.broker??f,getPolicy:t?.getPolicy??i,defaultDisposition:`allow`})}export{p as restoreEnabledJshdUnits};
|
|
@@ -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{a as o,c as s,d as c,f as l,g 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,v as y}from"./stdio-tty-CipJs8Mm.js";import{r as te}from"./global-prefix-DqCuANmV.js";import{a as ne,i as re,o as ie,r as ae}from"./wasm-programs-Bd5YaoqY.js";import{n as oe,t as se}from"./wasm-compiler-Ct7QZURL.js";import{S as ce,T as le,w as ue,x as de}from"./sync-exec-dispatch-B-gdI8lu.js";import{t as fe}from"./sync-sab-wire-D_d0fd3b.js";import{t as pe}from"./sync-sab-responder-DlSgon7c.js";import{i as me}from"./just-bash-compat-B-SPHuh_.js";import{t as he}from"./shebang-exec-hint-CSwess-H.js";const ge=String.raw`printf '\033]7777;%s\007' "$?"`,_e=[`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 ve=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,ye={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 be=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=xe(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 Se(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 xe(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 Se(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 Ce(e){let t=Se(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:we(t)}}function we(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(!ve.test(r))throw new b(400,`malformed header field`);t.push([r,n.slice(e+1).trim()])}return t}function S(e,t){let n=t.toLowerCase();return e.filter(([e])=>e.toLowerCase()===n).map(([,e])=>e)}function C(e,t){return S(e,t).flatMap(e=>e.split(`,`)).map(e=>e.trim().toLowerCase()).filter(e=>e!==``)}function Te(e){let t=C(e,`transfer-encoding`),n=S(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 Ee=65536;async function De(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(Ee,r);t!==``;){if(o+=t.length,o>Ee)throw new b(431,`trailers too large`);t=await e.line(Ee,r)}return Oe(i,a)}function Oe(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 ke(e){return!/[\r\n\0]/.test(e)}function Ae(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)ve.test(e)&&ke(t)&&(r+=`${e}: ${t}\r\n`);return x(`${r}\r\n`)}function je(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 Me=x(`0\r
|
|
3
|
-
\r
|
|
4
|
-
`),Ne=e(`realm-proxy`),Pe=3128,Fe={maxConnections:64,maxHead:65536,idleMs:12e4,bodyBudget:134217728},Ie=new Set([`connection`,`keep-alive`,`proxy-connection`,`proxy-authenticate`,`proxy-authorization`,`te`,`trailer`,`transfer-encoding`,`upgrade`]),Le=new Set([`host`,`content-length`,`expect`]);var Re=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 ze(e){let t=e.includes(`:`)&&!e.startsWith(`[`)?`[${e}]`:e;try{return new URL(`http://${t}/`).hostname}catch{return}}function Be(e,t){return e===127||e===0||e===169&&t===254}function Ve(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 He(e){let t=Ve(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?Be(t[6]>>8,t[6]&255):t[5]===0&&t[6]===0:!1}function Ue(e){let t=ze(e);if(t===void 0)return!1;let n=t.replace(/\.+$/,``);if(n===`localhost`||n.endsWith(`.localhost`))return!0;if(n.startsWith(`[`))return He(n.slice(1,-1));let r=/^(\d+)\.(\d+)\.\d+\.\d+$/.exec(n);return r?Be(Number(r[1]),Number(r[2])):!1}function We(e){return new Set([...Ie,...C(e,`connection`)])}function Ge(e){let t=We(e);return e.filter(([e])=>{let n=e.toLowerCase();return!t.has(n)&&!Le.has(n)})}function Ke(e,t){let n=We(e);return t.encodedBodies||n.add(`content-encoding`),t.encodedBodies&&t.bodiless||n.add(`content-length`),e.filter(([e])=>!n.has(e.toLowerCase()))}function qe(e){let t=C(e.headers,`connection`);return t.includes(`close`)?!1:e.minor>=1||t.includes(`keep-alive`)}function Je(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=S(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 Ye(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(Ue(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 Xe(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=ze(t[1]);if(r===void 0)throw new b(400,`CONNECT needs host:port`);if(Ue(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 Ze(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 Qe(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 $e(e,t){let n=x(`slicc realm proxy: ${t}\n`);return{status:e,statusText:ye[e]??``,headers:[[`Content-Type`,`text/plain; charset=utf-8`]],body:(async function*(){yield n})(),cancel:async()=>void 0}}function et(e,t,n){return{read:(r,i)=>e.read(r,AbortSignal.any([n,AbortSignal.timeout(t),...i?[i]:[]]))}}var tt=class{options;listener;stop=new AbortController;limits;slots;bodies;connections=new Set;closed;port;constructor(e){this.options=e,this.limits={...Fe,...e.limits},this.slots=new Re(this.limits.maxConnections),this.bodies=new Re(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 be(et(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,$e(t.status,t.message),!1)}catch{}}async exchange(e,t){let{sink:n,incoming:r}=e,i=Ce(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?Je(i,e.origin):Ye(i),o=qe(i),s=Te(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 De(r,s,this.cap()),n=new AbortController;Ze(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=C(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 Qe(this.options.transport.fetch({url:t,method:e.method.toUpperCase(),headers:Ge(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 $e(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=Ke(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(Ae(a,r.statusText||ye[a]||``,s),u),o)return await r.cancel(),l;try{for await(let t of r.body)t.length>0&&await e.write(c?je(t):t,u)}catch{return await r.cancel().catch(()=>void 0),!1}return c&&await e.write(Me,u),l}async connect(e,t,n){let r=Xe(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 be(t),origin:r,socket:e}))}catch(e){e instanceof h||Ne.warn(`tunnel failed`,{host:r.host,error:String(e)})}}};function nt(){return{buffered:n(),streaming:r()}}function rt(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 it(e){return e.startsWith(`x-proxy-`)||e.startsWith(`access-control-`)}function at(e){let t=[];for(let[n,r]of Object.entries(e)){let e=n.toLowerCase();if(!it(e)){if(e===`set-cookie`)for(let e of ot(r))t.push([n,e]);else t.push([n,r])}}return t}function ot(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*st(e){e.byteLength>0&&(yield e)}function ct(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 lt(e=nt()){return{traits:{manualRedirects:!1,encodedBodies:!1,maxRequestBody:i},async fetch(t){let n=rt(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:at(r.headers),body:st(ct(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:at(r.headers),body:r.body,cancel:()=>r.cancel()}}}}function ut(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 dt(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,...ut(n.body)}}}}function ft(e={}){let n,i=()=>(n??=(e.fallback??(()=>lt()))(),n),o,s=Promise.resolve().then(()=>(e.capabilities??t)()).then(t=>t.supported?dt((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 pt(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 mt(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 w(e,...t){let n=pt(t);return pt([Uint8Array.of(e),mt(n.length),n])}const T=(...e)=>w(48,...e),ht=(...e)=>w(49,...e),E=e=>w(4,e),D=(e,t=0)=>w(3,Uint8Array.of(t),e),gt=w(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 w(2,n[0]&128?pt([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 w(6,Uint8Array.from(i))}const _t=e=>w(12,new TextEncoder().encode(e)),vt=e=>Uint8Array.from(e,e=>e.charCodeAt(0)&127);function yt(e){let t=e.toISOString().replace(/[-:T]/g,``).slice(0,14);return e.getUTCFullYear()<2050?w(23,vt(`${t.slice(2)}Z`)):w(24,vt(`${t}Z`))}const bt=T(k(`1.2.840.10045.4.3.2`));function xt(e){let t=[];return e.organization&&t.push(ht(T(k(`2.5.4.10`),_t(e.organization)))),t.push(ht(T(k(`2.5.4.3`),_t(e.commonName)))),T(...t)}function A(e,t,n){return t?T(k(e),gt,E(n)):T(k(e),E(n))}function St(e){let t=[],[,n,r]=j(e,0);for(let i=n;i<r;){let[,,n]=j(e,i);t.push(e.subarray(i,n)),i=n}return t}function j(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 Ct(e){let[,t,n]=j(e,0);return e.subarray(t,n)}function wt(e){let t=St(e)[1];return Ct(t).subarray(1)}async function Tt(e){return new Uint8Array(await crypto.subtle.digest(`SHA-1`,wt(e)))}function Et(e){let t=e.length/2;return T(O(e.subarray(0,t)),O(e.subarray(t)))}function Dt(){let e=crypto.getRandomValues(new Uint8Array(16));return e[0]=e[0]&127|1,e}function Ot(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 kt(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=Ot(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 At(e){let t=[A(`2.5.29.14`,!1,E(await Tt(e.spki)))];if(e.kind.ca)t.push(A(`2.5.29.19`,!0,T(gt,O(Uint8Array.of(0))))),t.push(A(`2.5.29.15`,!0,D(Uint8Array.of(134),1)));else{t.push(A(`2.5.29.35`,!1,T(w(128,await Tt(e.issuerSpki))))),t.push(A(`2.5.29.19`,!0,T())),t.push(A(`2.5.29.15`,!0,D(Uint8Array.of(128),7))),t.push(A(`2.5.29.37`,!1,T(k(`1.3.6.1.5.5.7.3.1`))));let n=Ot(e.kind.host)??kt(e.kind.host),r=n?w(135,n):w(130,vt(e.kind.host));t.push(A(`2.5.29.17`,!1,T(r)))}return w(163,T(...t))}async function jt(e){let t=T(w(160,O(Uint8Array.of(2))),O(e.serial),bt,xt(e.issuer),T(yt(e.notBefore),yt(e.notAfter)),xt(e.subject),e.spki,await At(e)),n=Et(await e.sign(t));return T(t,bt,D(n))}function Mt(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 Nt={name:`ECDSA`,namedCurve:`P-256`},Pt={name:`ECDSA`,hash:`SHA-256`};function Ft(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}function It(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 Ft((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 Lt=class extends Error{};function Rt(e){return kt(e)?!0:e.length===0||e.length>253?!1:e.split(`.`).every(e=>/^(?!-)[a-z0-9-]{1,63}(?<!-)$/i.test(e))}var zt=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(Nt,!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 jt({serial:Dt(),issuer:i,subject:i,notBefore:new Date(t-864e5),notAfter:new Date(a),spki:r,issuerSpki:r,kind:{ca:!0},sign:Bt(n.privateKey)});return{key:n.privateKey,cert:o,spki:r,notAfter:a,name:i}}get cert(){return this.record.cert}get pem(){return Mt(this.record.cert)}async issue(e,t,n=Date.now()){let r=e.toLowerCase();if(!Rt(r))throw new Lt(`no certificate for ${e}`);return jt({serial:Dt(),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:Bt(this.record.key)})}};function Bt(e){return async t=>new Uint8Array(await crypto.subtle.sign(Pt,e,t))}let Vt;const M=new Map;function Ht(e,t){let n=M.get(e);return n||(Vt??=t?void 0:It(),n=zt.open(e,t??Vt),M.set(e,n),n.catch(()=>{M.get(e)===n&&M.delete(e)})),n}const Ut=65536;var Wt=class extends Error{code;constructor(e,t){super(t),this.code=e}},Gt=class{m;scratch;constructor(e){if(this.m=e,this.scratch=e._malloc(Ut),!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 Wt(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 Kt(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 qt(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,Ut);return t>0?this.taken(t):t}},Kt=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)}},qt=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 N;function Jt(e=async()=>(await import(`./slicc-tls-engine-DfyKw1Ua.js`)).default()){return N??=e().then(e=>new Gt(e)),N.catch(()=>{N=void 0}),N}const Yt=e(`realm-tls`);var Xt=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)}},Zt=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 Xt(c,$t(t),e),s=`https://${Qt(n)}`;try{await i(a,a,s),await a.close(r).catch(()=>void 0)}catch(e){throw Yt.debug(`tunnel ended`,{host:o,error:String(e)}),e}}finally{c.free()}}};function Qt(e){return e.port===443?e.host:`${e.host}:${e.port}`}function $t(e){return{read:(t,n)=>e.some(t,n)}}const P=`http://127.0.0.1:${Pe}`,en=`localhost,.localhost,127.0.0.1,127.0.0.0/8`;function tn(){return{http_proxy:P,https_proxy:P,HTTP_PROXY:P,HTTPS_PROXY:P,no_proxy:en,NO_PROXY:en}}function nn(e){if(e)return`ca`in e?new Zt(e):new Zt({ca:()=>Ht(e.owner),engine:()=>Jt()})}const rn=new WeakMap,an=`/.config/slicc/realm-ca-`;function on(e){return e.replace(/[^A-Za-z0-9_-]+/g,`-`).replace(/-+$/,``)}function sn(e,t){return`${e.replace(/\/+$/,``)}${an}${on(t)}.pem`}function cn(e){return{SSL_CERT_FILE:e,CURL_CA_BUNDLE:e,GIT_SSL_CAINFO:e}}const ln=`/.config/slicc/gitconfig`;function un(e){return`${e.replace(/\/+$/,``)}${ln}`}function dn(e){return`"${e.replace(/[\r\n]+/g,` `).replace(/[\\"]/g,e=>`\\${e}`)}"`}function fn(e){let t=[`[credential]`,` helper = slicc`];return e&&t.push(`[user]`,`\tname = ${dn(e.name)}`,`\temail = ${dn(e.email)}`),`${t.join(`
|
|
10
|
-
`)}\n`}async function pn(e,t,n){try{let r=fn(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 mn(e,t){let n=tn();return e in n?n[e]===t:e===`GIT_CONFIG_SYSTEM`?t.endsWith(ln):e in cn(``)&&t.includes(an)}async function hn(e,t,n,r=Ht){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)),cn(t)}catch{return{}}}function gn(e,t={}){if(rn.has(e))return;let n={proxy:void 0};rn.set(e,n);let r;e.activate({family:`inet`,host:`127.0.0.1`,port:Pe},()=>{r??=(t.transport??ft)();let i=nn(t.tls),a=new tt({net:e,transport:r,tunnel:i?.handler,...t.proxy});n.proxy=a,_n(a,t.process).then(async()=>{n.proxy===a&&(n.proxy=void 0),await i?.close()})})}async function _n(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 vn=32768;function yn(e){return/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(e)}async function F(e){try{return await e()}catch(e){throw e instanceof y?new h(e.code):e}}var bn=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 xn(e,t){let n=new u,r=new u;for(let e of[n,r])e.openRead(),e.openWrite();e.attach({rx:r,tx:n}),t.attach({rx:n,tx:r})}var I=class e{net;domain;state=`open`;local;peer;link;readShut=!1;writeShut=!1;queue=[];backlog=0;bound=!1;changes=new bn;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:F(()=>n.read(e,t))}async peek(e,t){let{rx:n}=this.connection();return this.readShut||e<=0?new Uint8Array:F(()=>n.peek(e,t))}async write(e,t){let{tx:n}=this.connection();if(this.writeShut)throw new h(`EPIPE`);return F(()=>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 F(()=>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:Sn(t.host)}:t,r.peer=this.local,this.peer=r.local,xn(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:``},xn(r,i),[r,i]}};function Sn(e){return e===`0.0.0.0`?`127.0.0.1`:e}function L(e){return e.family===`inet`?`inet:${e.port}`:`unix:${e.path}`}var Cn=class{bound=new Map;activators=new Map;nextEphemeral=vn;activate(e,t){this.activators.set(L(e),t)}socket(e){return new I(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`&&!yn(t.host))throw new h(`EADDRNOTAVAIL`);let n=t.family===`inet`&&t.port===0?{...t,port:this.ephemeral()}:t,r=L(n);if(this.bound.has(r))throw new h(`EADDRINUSE`);return this.bound.set(r,e),n}release(e,t){let n=L(e);this.bound.get(n)===t&&this.bound.delete(n)}target(e){if(e.family===`inet`&&!yn(Sn(e.host)))throw new h(`ENETUNREACH`);let t=L(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?vn:e+1,!this.bound.has(`inet:${e}`))return e}throw new h(`EADDRINUSE`)}};const wn=new Map;function Tn(e){let t=wn.get(e);return t||(t=new Cn,wn.set(e,t)),t}function En(e){return e?`${e.kind}:${e.scoopJid??``}`:`local`}const R={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},Dn=new Set([R.CHLD,R.URG,R.WINCH]),On=new Set([R.STOP,R.TSTP,R.TTIN,R.TTOU]);function kn(e){return e===R.CONT?`continue`:On.has(e)?`stop`:Dn.has(e)?`ignore`:`terminate`}function An(e){return Number.isInteger(e)&&e>=1&&e<=31}function z(e){return 1<<e}const B={SIGINT:R.INT,SIGTERM:R.TERM,SIGKILL:R.KILL,SIGSTOP:R.STOP,SIGCONT:R.CONT},jn=16384;function Mn(){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 Nn=new TextEncoder;function Pn(e){return(e&192)==128}var Fn=class{screen;signal;termios=Mn();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(R.WINCH)}hangup(){this.hungUp=!0,this.wake()}signalHangup(){this.signal(R.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)?R.INT:e===this.cc(1)?R.QUIT:e===this.cc(10)?R.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(Nn.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&jn)for(;t<e.length&&Pn(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&jn?t.filter(e=>!Pn(e)).length:t.length;n>0&&this.termios.c_lflag&8&&this.output(Nn.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()}},V=class extends Error{code;constructor(e){super(e),this.code=e}};function In(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 Ln(e){return(e&255)<<8|127}function Rn(e,t){return t?t&127:(e&255)<<8}function zn(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 Bn=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 V(`ENOSYS`);return this.track(e,this.parentFds.fork(),new Map,this.forker)}async spawn(e,t,n=[]){if(!this.spawner)throw new V(`ENOSYS`);let r=new o,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(`device`in e){r.installAt(e.fd,f(e.device,e.access));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 s(e.input);if(`capture`in e){let e=[];return n.set(t,e),d(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??=In(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,Ln(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,Rn(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),zn(r))}},Vn=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 Fn({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()}},Hn=class{signal;pairs=new Map;constructor(e){this.signal=e}open(){let e=0;for(;this.pairs.has(e);)e+=1;let t=new Vn(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 Un=[`pty-open`,`pty-slave-open`,`pty-number`,`pty-lock`,`pty-ctty`,`pty-packet`,`pty-list`,`pty-winsz-set`];function H(e,t){let n=e.fds.get(t).file.pty;if(!n)throw new h(`ENOTTY`);return n}function Wn(e,t){let n=e.fds.get(t).file,r=n.tty??n.pty?.slave;if(!r)throw new h(`ENOTTY`);return r}const U=e=>({ok:!0,kind:`json`,json:e}),W={ok:!0,kind:`void`};function Gn(e,t){switch(e.op){case`pty-open`:if(!t.ptys)throw new h(`ENOENT`);return U(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),U(r)}case`pty-number`:return U(H(t,e.fd).index);case`pty-lock`:return H(t,e.fd).locked=e.lock,W;case`pty-ctty`:{let n=Wn(t,e.fd);if(t.jobs?.getsid(t.pid,0)===t.pid&&t.jobs?.controllingTerminal(t.pid)===n)return W;if(!t.jobs?.acquireTerminal(t.pid,n))throw new h(`EPERM`);return W}case`pty-list`:return U(t.ptys?.numbers()??[]);case`pty-packet`:return H(t,e.fd).packet=e.on,W;case`pty-winsz-set`:return Wn(t,e.fd).resize(e.cols,e.rows),W}}function Kn(e,t,n){let r=new Set,i=(t,n)=>t.filter(t=>{let i=p(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 qn(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 Jn(e,t,n,r,i){let a=r<0?1/0:Date.now()+r,o=qn(i);o.promise.catch(()=>{});try{return await Yn(e,t,n,a,o.promise)}finally{o.done()}}async function Yn(e,t,n,r,i){for(;;){let a=Kn(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 Xn=[`sock-open`,`sock-pair`,`sock-bind`,`sock-listen`,`sock-accept`,`sock-connect`,`sock-shutdown`,`sock-name`,`sock-getopt`,`sock-setopt`];function G(e,t){let n=e.get(t).file;if(!(n instanceof I))throw new h(`ENOTSOCK`);return n}const K=e=>e===void 0?{ok:!0,kind:`void`}:{ok:!0,kind:`json`,json:e};async function Zn(e,t){let{fds:n,net:r}=t;switch(e.op){case`sock-open`:return K(n.install(new _(r.socket(e.domain)),3));case`sock-pair`:{let[t,i]=I.pair(r,e.domain),a=n.install(new _(t),3);try{return K([a,n.install(new _(i),3)])}catch(e){throw await Promise.resolve(n.close(a)),e}}case`sock-bind`:return G(n,e.fd).bind(e.addr),K();case`sock-listen`:return G(n,e.fd).listen(e.backlog),K();case`sock-accept`:return K(await $n(t,e.fd,e.nonblock));case`sock-connect`:if(G(n,e.fd).connect(e.addr),e.nonblock)throw new h(`EINPROGRESS`);return K();case`sock-shutdown`:return G(n,e.fd).shutdown(e.how),K();case`sock-name`:{let t=G(n,e.fd),r=e.peer?t.peer:t.local;if(e.peer&&!r)throw new h(`ENOTCONN`);return K(r??Qn(t.domain))}case`sock-getopt`:return K(G(n,e.fd).getOption(e.level,e.name));case`sock-setopt`:return G(n,e.fd).setOption(e.level,e.name,e.value),K()}}function Qn(e){return e===`inet`?{family:`inet`,host:`0.0.0.0`,port:0}:{family:`unix`,path:``}}async function $n(e,t,n){let r=G(e.fds,t),i=!n&&!p(r).readable,a=await r.accept(i?e.blocking():void 0,n);return{fd:e.fds.install(new _(a),3),peer:a.peer}}function er(e){return e?.code===`ENOENT`||e instanceof Error&&e.message.startsWith(`ENOENT`)}function q(e,t){return e===t||e.startsWith(t.endsWith(`/`)?t:`${t}/`)}var J=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,i=!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,i&&n!==void 0&&this.markDirty()}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 le(this.fs,this.path)}catch(e){if(!er(e))throw e;this.data=new Uint8Array,this.missing=!0}this.length=this.data.length}return this.data}replace(e){this.data=new Uint8Array(e),this.length=this.data.length,this.missing=!1,this.markDirty()}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();try{await this.fs.writeFile(this.path,this.data.slice(0,this.length))}catch(e){throw this.dirty=!0,e}this.writeBackCost=performance.now()-e}},tr=class{fs;byPath=new Map;constructor(e){this.fs=e}open(e){let t=this.byPath.get(e);return t||(t=new J(this.fs,e),this.byPath.set(e,t)),t.opens++,t}adopt(e,t,n){let r=this.byPath.get(e);return r?n&&r.replace(t):(r=new J(this.fs,e,t,!1,n),this.byPath.set(e,r)),r.opens++,r}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)q(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)q(r,e)?n.push(i):q(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 nr(e,t,n){let r=t.flags&3,i=r!==1,a=r===1||r===2,o=!n||t.orphan?new J(e,t.path,t.contents,t.orphan===!0,t.dirty===!0):t.contents===void 0?n.open(t.path):n.adopt(t.path,t.contents,t.dirty===!0),s,c=e=>{o.serial(e).catch(e=>{s??={err:e}})};t.create&&c(()=>o.materialize()),t.truncate&&c(()=>o.truncate(0));let l=()=>{if(!s)return;let{err:e}=s;throw s=void 0,e},u=t.position,d=e=>o.serial(()=>(l(),e()));return new _({read:i?e=>d(async()=>{let t=await o.pread(e,u);return u+=t.length,t}):void 0,write:a?e=>d(async()=>(t.flags&1024&&(u=await o.size()),u+=await o.pwrite(e,u),e.length)):void 0,seek:(e,t)=>d(async()=>{let n=0;if(t===1)n=u;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 u=n+e,u}),pread:(e,t)=>d(()=>{if(!i)throw new h(`EBADF`);return o.pread(e,t)}),pwrite:(e,t)=>d(()=>{if(!a)throw new h(`EBADF`);return o.pwrite(e,t)}),resize:e=>d(()=>{if(!a)throw new h(`EBADF`);return o.truncate(e)}),stat:()=>d(async()=>({path:o.path,size:await o.size(),...o.orphaned?{orphan:!0}:{}})),flush:()=>d(()=>o.flush()),close:()=>o.serial(async()=>{try{l(),await o.flush()}finally{n?.closed(o)}})})}const rr=new Set([`proc-setpgid`,`proc-getpgid`,`proc-getsid`,`proc-setsid`]);function ir(e){return rr.has(e.op)}function ar(e){return e.op.startsWith(`pty-`)}function or(e){return e.op.startsWith(`sock-`)}function sr(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 cr(e){return e.op.startsWith(`fd-`)}function lr(e){return e.op.startsWith(`tty-`)}const ur=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`,...Xn,...Un]);function dr(e){let t=e.op;return typeof t==`string`&&ur.has(t)}const fr=1048576;var pr=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 Bn(t,n.spawner,n.forker),this.nodes=n.fs?new tr(n.fs):void 0,this.children.onChildState=()=>this.signal(R.CHLD)}signal(e){if(this.execChild!==void 0)return Promise.resolve(this.options.kill?.(this.execChild,e)).catch(()=>void 0),e===R.KILL?`terminate`:`forward`;if(e===R.KILL)return`terminate`;if(e===R.CONT&&this.cont(),e===R.STOP)return this.stop(e);let t=z(e);if(this.ignored&t)return`ignore`;if(!(this.caught&t)){let t=kn(e);return t===`stop`?this.stop(e):t}let n=kn(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`,R.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(cr(e))return await this.fdSyscall(e);if(lr(e))return this.ttySyscall(e);if(ir(e))return this.jobSyscall(e);if(or(e))return await this.socketSyscall(e);if(ar(e)){let{ptys:t,jobs:n}=this.options;return Gn(e,{pid:this.pid,fds:this.fds,ptys:t,jobs:n})}return await this.procSyscall(e)}catch(e){if(e instanceof h||e instanceof V)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=p(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,fr)),i)}async write(e,t,n=!1){let r=this.fds.get(e).file;if(!r.write)throw new h(`EBADF`);if(!p(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 V(`ENOSYS`);return nr(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(sr(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=g(),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:p(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 Jn(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,fr),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=nr(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}:{},...e.dirty?{dirty:!0}:{}},this.nodes);this.fds.installAt(e.fd,t)}reserve(e,t=3,n){if(e===void 0)return this.fds.install(v(n),Math.max(3,t));if(this.fds.has(e))throw new h(`EBADF`);return this.fds.installAt(e,v(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 I?`socket`:c(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&z(R.TTIN)?new h(`EIO`):(t.killGroup(r,R.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 Cn,Zn(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&&!An(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(!An(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 mr(){return new Worker(new URL(`/assets/process-worker-Qo-KJQnm.js`,``+import.meta.url),{type:`module`})}const hr=new WeakMap;let gr=1;function _r(e){let t=hr.get(e);return t===void 0&&hr.set(e,t=gr++),t}function vr(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 I?`socket`:c(n.file),a=n.file.heldMeta;return{fd:t,kind:i,...i===`device`&&a&&`device`in a?{device:a}:{},...r===void 0?{}:{flags:r},...e.closesOnExec(t)?{cloexec:!0}:{},...i===`stream`?{desc:_r(n)}:{}}})}function yr(e){let t=new SharedArrayBuffer(64+fe),n=new Int32Array(t,0,16),r=new pr(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,z(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=ce({fs:e.fs,cwd:e.cwd}),a=(e.createWorker??mr)(),o=async e=>dr(e)?r.syscall(e):`op`in e&&typeof e.op==`string`&&`path`in e?de(e):{ok:!1,errno:`ENOSYS`,message:`wasm-realm: no exec yet`},s=pe(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);ue(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+fe),r=(e.createWorker??mr)(),a=pe(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:vr(e.fds)}};a.postMessage(v,e.fork?[e.fork.memory.buffer]:[]);let y=e=>{r.signal(e)===`terminate`&&f(e===R.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 br=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 xr(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 Sr=/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g;function Cr(e,t){let n={};for(let[r,i]of Object.entries(e)){let e=!1,a=i.replace(Sr,(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 wr(e,t){if(!e)return t;let n=Cr(e,t);if(!(t.GIT_CONFIG_SYSTEM!==void 0&&mn(`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 Tr(e){return e.USER===void 0||`LOGNAME`in e?e:{...e,LOGNAME:e.USER}}function Er(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 Y=new Map,Dr=new Map,Or=new Map(Object.entries(B).map(([e,t])=>[t,e])),X=/^\/(?:usr\/)?bin\/([^/]+)$/,Z=/^(.*\/node_modules\/(?:@[^/]+\/)?[^/]+)\//,kr=/locateFile\(\s*["']([^"'/]+\.wasm)["']\s*\)/;let Ar=4e4;function jr(e){return e.glue===e.module}const Mr=[0,97,115,109];function Nr(e){return Mr.every((t,n)=>e[n]===t)}function Pr(e){return e.endsWith(`.js`)?`${e.slice(0,-3)}.wasm`:`${e}.wasm`}async function Fr(e,t){let n=e.readFileRange,r;try{r=n?new TextDecoder().decode(await n.call(e,t,0,256)):(await e.readFile(t)).slice(0,256)}catch{return!1}return r.startsWith(`#!`)?he(r)!==`node`:!1}function Ir(e){return X.exec(e)?.[1]??Q(e)}function Q(e){return e.slice(e.lastIndexOf(`/`)+1)}function Lr(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 Rr(e){return re(Lr(e),te)}function zr(e,t){return`${e}:${t.size}:${t.mtime.getTime()}`}function Br(e,t){return Y.set(e,t),t.catch(()=>Y.delete(e)),t}async function Vr(e,t){let n=zr(t,await e.fs.stat(t));return Y.get(n)??Br(n,se(t=>e.fs.readFileBuffer(t),t))}function Hr(e,t){return Dr.set(e,xr(t)),Br(e,oe(t))}async function Ur(e,t){let n=zr(t,await e.fs.stat(t)),r=Y.get(n),i=await(r&&Dr.has(n)?r:Hr(n,await e.fs.readFileBuffer(t))),a=Dr.get(n);return{module:i,...a?{memory:a}:{}}}async function Wr(e,t,n){if(WebAssembly.Module.customSections(n,`name`).length>0)return;let r=`${t}.names`;if(await e.fs.exists(r))return r;let i=Z.exec(t)?.[1];if(i===void 0)return;let a=`${i}-names${r.slice(i.length)}`;return await e.fs.exists(a)?a:void 0}async function Gr(e,t){let n;try{let r=await e.fs.stat(t);if(!r.isFile)return!1;n=zr(t,r)}catch{return!1}if(Y.has(n))return!0;let r;try{r=await e.fs.readFileBuffer(t)}catch{return!1}return Nr(r)?(Hr(n,r).catch(()=>void 0),!0):!1}function Kr(e){let t=``;for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return t}function qr(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 Jr(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 Yr(e,t){return e.has(t)&&e.get(t).file.tty!==void 0}function Xr(e){return{...Yr(e,0)?{}:{[ee]:`0`},...Yr(e,1)?{}:{[m]:`0`}}}function Zr(e){return{pid:e.pid,exited:e.exited,termsig:e.termsig,onState:t=>e.onState(t)}}const Qr=new WeakMap;var $r=class{ctx;processConfig;onError;gate;lookup;live=new Set;shellChildren=new Set;wasmByPid=new Map;shellByPid=new Map;installed;jobs=new br;ptys=new Hn((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=Tn(En(t?.owner));let a=En(t?.owner);gn(this.net,{process:t,tls:{owner:a}})}commands(){return this.lookup?this.lookup():(this.installed??=Rr(this.ctx),this.installed)}async launch(e){let t=jr(e),n=``,r,i;try{t?{module:r,memory:i}=await Ur(this.ctx,e.module):(n=await this.ctx.fs.readFile(e.glue),r=await Vr(this.ctx,e.module)),e.signal?.throwIfAborted()}catch(t){throw await e.fds.closeAll(),t}let a=Er(e.argv0,Tr(wr(e.defaults,e.env)));t&&await this.pythonPackages(e,a);let o=t&&a.SLICC_WASM_BACKTRACE===`1`?await Wr(this.ctx,e.module,r):void 0;return this.start({...e,env:a,program:t?{abi:`wasi`,glue:n,module:r,...i?{memory:i}:{},...o?{names:o}:{}}:{glue:n,module:r}})}async pythonPackages(e,t){let n=Z.exec(e.module)?.[1];if(n)try{let r=Lr(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=ie(n,o,a.slicc?.python).interpreter;if(!s)return;let{packages:c}=await this.pythonScan(r),l=await ne(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=Qr.get(t);return n||(n=ae(e,te),Qr.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=yr({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(B[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=Or.get(t);return a===void 0?!1:this.gate?this.killOutside(e,a):i.signal(e,a)}async killOutside(e,t){if(await this.gate?.(`kill`,[`-${t.slice(3)}`,String(e)],{}))throw new h(`EPERM`);return this.processConfig?.processManager.signal(e,t)??!1}listen(e){return new _(this.net.listen(e))}signalAll(e){for(let t of this.live)t.signal(e)}signalTerminal(e,t){this.leader!==void 0&&this.jobs.signalForeground(e,this.leader,t)}killAll(e){for(let t of this.live)t.kill(e);for(let e of this.shellChildren)e.abort()}async resolve(e,t,n){let r=X.exec(e)?.[1]??(e.includes(`/`)?void 0:e);if(r!==void 0){let e=await this.commands(),t=e.get(r);if(t?.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)||await Fr(this.ctx.fs,i))return;let a=Pr(i);return await this.ctx.fs.exists(a)?{glue:i,module:a,argv0:Q(t||e)}:await Gr(this.ctx,i)?{glue:i,module:i,argv0:Q(t||e).replace(/\.wasm$/,``)}:this.packagedCopy(i,t||e)}async packagedCopy(e,t){let n=Z.exec(e)?.[1];if(n===void 0)return;let r;try{r=await this.ctx.fs.readFile(e)}catch{return}let i=kr.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)=>Zr(this.start({...t,cwd:n.cwd??t.cwd,fds:r,ppid:e,fork:n}))}async scriptCommand(e){let t=X.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(`/`)||X.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 V(`ENOENT`);return this.runShellChild(t,n,e)}let a=await this.gate?.(Ir(i.file),i.args,t.env);return a?this.deniedChild(t,n,e,a):Zr(await this.launch({...i.target,args:i.args,env:t.env,cwd:t.cwd,fds:n,ppid:e}))}}async shellRuns(e){let t=X.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 V(`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=>{kn(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(B[t])}),d=(async()=>{try{let n=Yr(t,0),i=t.has(0)&&!n?await Jr(t.get(0)):new Uint8Array,a=await r(e.file,{args:e.argv.slice(1),cwd:e.cwd,env:{...e.env,...Xr(t)},replaceEnv:!0,stdin:Kr(i),stdinKind:`bytes`,signal:o.signal});return await $(t,1,a.stdoutKind===`bytes`?qr(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:Ar++}}};const ei=`usage: wasm [-t] [--argv0 NAME] [--module PATH] [--listen [HOST:]PORT] PROGRAM [ARGS...]
|
|
13
|
-
wasm --list
|
|
14
|
-
wasm --login
|
|
15
|
-
`;function ti(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 ni(e,t){return t.commands?.()??Rr(e)}function ri(e){if(!e)return()=>{};let t=new TextDecoder;return n=>{let r=t.decode(n,{stream:!0});r&&e(r)}}function ii(e,t,n,r){let i=[],a=e.limits?.maxOutputSize??268435456,c=0,l=!1,u=(e,n)=>r=>{if(c+=r.length,c>a){l=!0,t.killAll(1);return}e.push(r),n(r)},f=new o;return f.install(s(gi(e))),f.install(d(u(i,ri(r)))),f.install(d(u(n,ri(r)))),{fds:f,collected:()=>({stdout:hi(i),note:l?`wasm: output exceeded ${a} bytes; stopped\n`:``}),release:()=>{}}}function ai(e,t){let n=new Fn({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 o;return i.installAt(0,r),i.installAt(1,r.retain()),i.installAt(2,r.retain()),{fds:i,collected:()=>({stdout:``,note:``}),release:()=>e.release()}}function oi(e,t){return Object.fromEntries(Object.entries(e).filter(([e,n])=>e in t||!mn(e,n)))}async function si(e,t){let n=En(t.processConfig?.owner);return hn(e.fs,sn(ci(e),n),n)}function ci(e){return e.exportedEnv?.HOME??e.env.get(`HOME`)??`/tmp`}async function li(e,t){let n=await t.gitIdentity?.().catch(()=>void 0);return pn(e.fs,un(ci(e)),n)}function ui(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??=ge),r}async function di(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 ni(e,t)).has(`bash`))return n;let r=s(new TextEncoder().encode(_e));return xi([`-t`,`--login-prompt`,`bash`,`--rcfile`,`/dev/fd/98`,`-i`],e,{...t,fds:[[98,r]]})}function fi(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 pi(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 mi(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 pi(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 hi(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 gi(e){let t=me(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 _i(e,t,n){return t.module?e.fs.resolvePath(e.cwd,t.module):await Gr(e,n)?n:Pr(n)}function vi(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 yi(e,t,n){if(e.listen===void 0)return{env:{}};let r=vi(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 bi(e,t){return e.defaults??t.defaults}async function xi(e,t,n={}){let{processConfig:r,terminal:i}=n;if(e[0]===`--help`||e[0]===`-h`)return{stdout:ei,stderr:``,exitCode:0};if(e[0]===`--login`&&e.length===1)return di(t,n);if(e[0]===`--list`&&e.length===1)return{stdout:fi(await ni(t,n)),stderr:``,exitCode:0};let a=ti(e);if(!a)return{stdout:``,stderr:ei,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 $r(t,r,e=>s(e),n.gate,n.commands),l=await mi(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 _i(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=ai(e,c),s=t=>e.write(new TextEncoder().encode(`wasm: ${t}\r\n`))}else f=ii(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=yi(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:{...ui(t,l,{...tn(),...await si(t,n),...await li(t,n)}),...m.env},defaults:bi(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(Si(o)),exitCode:e,stdoutKind:`bytes`}}finally{f.release(),t.signal?.removeEventListener(`abort`,g)}}function Si(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{xi as runWasmCommand,oi as withoutRealmDefaults};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./logger-LESFN7Hj.js";import{r as n}from"./global-prefix-DqCuANmV.js";import{i as r,n as i}from"./wasm-programs-Bd5YaoqY.js";import{r as a,t as o}from"./jsh-discovery-CnvNKojr.js";const s=[`/workspace`,`/shared`];async function c(e){let t=[],n=new Set;for(let r of s)await e.exists(r)&&await l(e,r,t,n);return t}async function l(e,t,n,r){for await(let i of e.walk(t)){if(!i.endsWith(`.bsh`)||r.has(i))continue;r.add(i);let t=u(i);if(!t)continue;let a=await e.readFile(i,{encoding:`utf-8`}),o=d(typeof a==`string`?a:new TextDecoder().decode(a));n.push({path:i,hostnamePattern:t,matchPatterns:o})}}function u(e){let t=e.split(`/`).pop()??``;if(!t.endsWith(`.bsh`))return null;let n=t.slice(0,-4);return n?n.startsWith(`-.`)?`*`+n.slice(1):n:null}function d(e){let t=e.split(`
|
|
2
|
-
`).slice(0,10),n=[];for(let e of t){let t=e.match(/^\s*\/\/\s*@match\s+(.+)$/);t&&n.push(t[1].trim())}return n}function f(e,t){if(t.startsWith(`*.`)){let n=t.slice(1);return e===t.slice(2)||e.endsWith(n)&&e.length>n.length}return e===t}function p(e,t){try{let n=new URL(e),r=t.match(/^(\*|https?):\/\/([^/]+)(\/.*)?$/);if(!r)return!1;let[,i,a,o]=r;return i!==`*`&&n.protocol.slice(0,-1)!==i||!f(n.hostname,a)?!1:!o||m(n.pathname+n.search,o)}catch{return!1}}function m(e,t){let n=`^`+t.replace(/[.+^${}()|[\]\\]/g,`\\$&`).replace(/\*/g,`.*`)+`$`;return new RegExp(n).test(e)}function h(e,t){try{let n=new URL(t);return e.filter(e=>f(n.hostname,e.hostnamePattern)?e.matchPatterns.length>0?e.matchPatterns.some(e=>p(t,e)):!0:!1)}catch{return[]}}const g=t(`workflow-discovery`),_=`/workspace/.workflows`,v=`/workspace/skills`,y=[_,v],b=`.workflow.js`,x=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;async function S(e){let t=new Map;try{await e.exists(_)&&await C(e,t)}catch(e){g.warn(`workflow discovery: ${_} scan failed`,e)}try{await e.exists(v)&&await w(e,t)}catch(e){g.warn(`workflow discovery: ${v} scan failed`,e)}return t}async function C(e,t){for await(let n of e.walk(_)){if(!n.endsWith(b))continue;let e=T(n);if(!x.test(e)){g.warn(`skipping saved workflow with invalid command name: '${e}' (${n})`);continue}t.has(e)||t.set(e,{path:n,kind:`saved`})}}async function w(e,t){for await(let n of e.walk(v)){if(!n.endsWith(b))continue;let e=E(n);if(!e)continue;let r=T(n);if(!x.test(e)||!x.test(r)){g.warn(`skipping skill workflow with invalid name segment: '${e}:${r}' (${n})`);continue}let i=`${e}:${r}`;t.has(i)||t.set(i,{path:n,kind:`skill`,skill:e})}}function T(e){let t=e.split(`/`).pop()??e;return t.endsWith(b)?t.slice(0,-12):t}function E(e){let t=e.slice(18).split(`/`);return t.length>=3&&t[1]===`.workflows`?t[0]:null}function D(e,t){let n=!1,r=[],i=!1;for(let e of t){if(i){r.push(e);continue}if(e===`--`){i=!0;continue}if(e===`--wait`){n=!0;continue}r.push(e)}let a=[`workflow`,`run`,e];return n&&a.push(`--wait`),r.length===1?a.push(`--args`,O(r[0])):r.length>1&&a.push(`--args`,JSON.stringify(r)),a}function O(e){try{return JSON.parse(e),e}catch{return JSON.stringify(e)}}var k=e({ScriptCatalog:()=>V});const A=[`/workspace`,`/shared`];function j(e){return new Map(e)}function M(e){return{commands:j(e.commands),collisions:e.collisions.map(e=>({name:e.name,winnerPath:e.winnerPath,shadowedPaths:[...e.shadowedPaths],reason:e.reason}))}}function N(e){return new Map([...e].map(([e,t])=>[e,{...t}]))}function P(e){return new Map([...e].map(([e,t])=>[e,{...t}]))}function F(e){return e.map(e=>({...e,matchPatterns:[...e.matchPatterns]}))}function I(e){if(e&&typeof e.listMounts==`function`)return e;if(e&&typeof e.getUnderlyingFS==`function`){let t=e.getUnderlyingFS?.();if(t&&typeof t.listMounts==`function`)return t}return null}function L(e,t){return(I(e)?.listMounts?.()??[]).some(e=>t.some(t=>e===t||e.startsWith(`${t}/`)||t.startsWith(`${e}/`)))}function R(e){return e?(I(e)?.listMounts?.()??[]).some(e=>A.some(t=>e===t||e.startsWith(t+`/`))):!1}function z(){return{cache:null,inflight:null,generation:0}}function B(e){e.generation++,e.cache=null,e.inflight=null}var V=class{jshFs;bshFs;watcher;watcherUnsubs=[];jshByRoots=new Map;bsh=z();workflow=z();wasm=z();constructor(e){if(this.jshFs=e.jshFs,this.bshFs=e.bshFs,this.watcher=e.watcher??null,this.watcher&&(this.watcherUnsubs.push(this.watcher.watch(`/`,()=>!0,()=>{this.invalidateJsh(),this.invalidateWorkflows(),this.invalidateWasm()})),this.bshFs))for(let e of A)this.watcherUnsubs.push(this.watcher.watch(e,()=>!0,()=>this.invalidateBsh()))}dispose(){for(let e of this.watcherUnsubs)e();this.watcherUnsubs.length=0,this.invalidateAll()}invalidateAll(){this.invalidateJsh(),this.invalidateBsh(),this.invalidateWorkflows(),this.invalidateWasm()}invalidateJsh(){for(let e of this.jshByRoots.values())B(e)}invalidateBsh(){B(this.bsh)}invalidateWorkflows(){B(this.workflow)}invalidateWasm(){B(this.wasm)}async getJshIndex(e=o){return M(await this.loadJshIndex(e))}async getJshCommands(e=o){return(await this.getJshIndex(e)).commands}async getJshCommandNames(e){return[...(await this.getJshCommands(e)).keys()]}async getBshEntries(){return this.bshFs?F(await this.loadBshEntries()):[]}async findMatchingBshScripts(e){return this.bshFs?F(h(await this.loadBshEntries(),e)):[]}async getWorkflowCommands(){return N(await this.loadWorkflowCommands())}async getWasmCommands(){return P(await this.loadWasmCommands())}shouldCacheJsh(e){return!!this.watcher&&!L(this.jshFs,e)}shouldCacheBsh(){return!!this.watcher&&!!this.bshFs&&!R(this.bshFs)}shouldCacheWorkflows(){return!!this.watcher&&!L(this.jshFs,y)}shouldCacheWasm(){return!!this.watcher&&!L(this.jshFs,[n])}loadCached(e,t,n,r){if(t&&e.cache)return Promise.resolve(e.cache);if(!e.inflight){let i=e.generation,a=n().then(n=>{let a=r(n);return t&&e.generation===i&&(e.cache=a),a}).finally(()=>{e.inflight===a&&(e.inflight=null)});e.inflight=a}return e.inflight}loadJshIndex(e){let t=e.join(`:`),n=this.jshByRoots.get(t);n||(n=z(),this.jshByRoots.set(t,n));let r=[...e];return this.loadCached(n,this.shouldCacheJsh(r),()=>a(this.jshFs,r),M)}loadBshEntries(){if(!this.bshFs)return Promise.resolve([]);let e=this.bshFs;return this.loadCached(this.bsh,this.shouldCacheBsh(),()=>c(e),F)}loadWorkflowCommands(){return this.loadCached(this.workflow,this.shouldCacheWorkflows(),()=>S(this.jshFs),N)}loadWasmCommands(){let e=this.jshFs;return i(e)?this.loadCached(this.wasm,this.shouldCacheWasm(),()=>r(e,n),P):Promise.resolve(new Map)}};export{S as i,k as n,D as r,V as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function e(){return{version:`6.237.2`,releasedAt:`2026-10-04T14:42:27Z`,buildId:`6.237.2-mutxjtcp`}}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-BOigwV2f.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){if(!e)return``;let t=[];for(let n of e.split(`,`).map(e=>e.trim()).filter(Boolean)){if(n===`collapsed`){t.push(`[expanded=false]`);continue}t.push(`[${n}]`)}return t.length>0?` ${t.join(` `)}`:``}function l(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 u(e,t,i,a,o=``,d=``){let f=[],p=n(e.role,`unknown`).toLowerCase(),m=n(e.name),h=n(e.value),g=``;s(p,m)&&(g=d+`e${++a.value}`,e.backendNodeId&&i.set(g,e.backendNodeId),t.set(g,l(p,m)));let _=`${o}- ${p}`;if(m&&(_+=` "${r(m)}"`),g&&(_+=` [ref=${g}]`),_+=c(e.description),h&&(_+=`: "${r(h)}"`),f.push(_),e.children)for(let n of e.children)f.push(...u(n,t,i,a,o+` `,d));return f}async function d(e,t){if(t.appTabId)return;let n=await e.listPages(),r=await f(),i=n.find(e=>e.url.startsWith(r)&&!e.url.includes(`/preview/`));i&&(t.appTabId=i.targetId)}async function f(){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 p(e,t){return t===e.appTabId}function m(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 h(e,t){return!p(e,t.targetId)&&!m(t)}async function g(e,n){return await d(e,n),(await t(e)).filter(e=>h(n,e))}function _(e,t){try{let n=new URL(e,t);return n.origin+n.pathname.replace(/\/$/,``)+n.search}catch{return null}}function v(e,t,n,r){let i=_(t,n);return e.find(e=>{if(r.has(e.frameId))return!1;let n=_(e.url);return n!==null&&i!==null?n===i:e.url===t})}async function y(e,t,n,r,i,a,o){try{let s=await e.getAccessibilityTreeForFrame(t),c=new Map,l=new Map,d=u(s,c,l,{value:0},n,r);for(let[e,n]of c)i.set(e,n),o.set(e,t);for(let[e,n]of l)a.set(e,n),o.set(e,t);return d}catch{return[]}}async function b(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=v(o,d[1],n,l);f&&(l.add(f.frameId),s++,c.push(...await y(e,f.frameId,t[1]+` `,`f${s}`,r,i,a)))}return c.join(`
|
|
3
|
-
`)}catch{return t}}async function x(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,l=u(a,o,s,{value:0}).join(`
|
|
4
|
-
`);return t?.noIframes||(l=await b(e,l,r,o,s,c)),{url:r,title:i,text:l,refToSelector:o,refToBackendNodeId:s,refToFrameId:c}}async function S(e,t,n,r){let{url:i,title:a,text:o,refToSelector:s,refToBackendNodeId:c,refToFrameId:l}=await x(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{S as a,d as i,g as n,n as o,u as r,x as t};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./snapshot-YDNf2VnW.js";import{g as t,v as n}from"./state-BOigwV2f.js";function r(e,t){let n=0,r=e.split(`
|
|
2
|
-
`).filter(e=>{let r=/^( *)- /.exec(e);return!r||r[1].length/2<t||(n++,!1)});return n>0&&r.push(`(${n} node(s) below depth ${t} elided — re-run without --depth for the full tree)`),r.join(`
|
|
3
|
-
`)}async function i(e,t,n){await e.send(`DOM.enable`),await e.send(`Runtime.enable`);let r={};for(let[n,i]of t)if(!n.startsWith(`f`))try{let t=(await e.send(`DOM.resolveNode`,{backendNodeId:i})).object?.objectId;if(!t)continue;let a=(await e.send(`Runtime.callFunctionOn`,{objectId:t,functionDeclaration:`function() {
|
|
4
|
-
const r = this.getBoundingClientRect();
|
|
5
|
-
return [Math.round(r.x), Math.round(r.y), Math.round(r.width), Math.round(r.height)];
|
|
6
|
-
}`,returnByValue:!0})).result?.value;a&&(r[n]=a)}catch{}return n.replace(/\[ref=([a-z0-9]+)\]/g,(e,t)=>r[t]?`${e} [box=${r[t].join(`,`)}]`:e)}async function a(e,n,r){let i=t(await e.evaluate(`JSON.stringify({ dpr: window.devicePixelRatio, w: window.innerWidth, h: window.innerHeight, sh: document.documentElement.scrollHeight, x: window.scrollX, y: window.scrollY })`),`--hires viewport dimensions`),a=i.dpr||1;return n?{...n,scale:a}:r?{x:0,y:0,width:i.w,height:i.sh,scale:a}:{x:i.x??0,y:i.y??0,width:i.w,height:i.h,scale:a}}function o(e,t){if(t)try{let e=new RegExp(t,`i`);return t=>e.test(t)}catch(e){return{error:`find: invalid --regex: ${e instanceof Error?e.message:String(e)}\n`}}let n=e.toLowerCase();return e=>e.toLowerCase().includes(n)}const s=async({browser:t,state:r,positional:i,flags:a,onTab:s})=>{let c=n(a);if(`error`in c)return{stdout:``,stderr:c.error,exitCode:1};let l=i.join(` `),u=a.regex;if(l&&u||!l&&!u)return{stdout:``,stderr:`find: provide either a text argument or --regex, not both
|
|
7
|
-
`,exitCode:1};let d=o(l,u);if(typeof d!=`function`)return{stdout:``,stderr:d.error,exitCode:1};let f=(await s(c.targetId,async t=>{let{output:n}=await e(t,r,c.targetId,{});return n})).split(`
|
|
8
|
-
`),p=[];for(let e=0;e<f.length;e++)d(f[e])&&p.push(e);if(p.length===0)return{stdout:`No matches in the page snapshot.
|
|
9
|
-
`,stderr:``,exitCode:0};let m=p.slice(0,20),h=[];for(let e of m){let t=Math.max(0,e-2),n=Math.min(f.length,e+2+1),r=h[h.length-1];r&&t<=r.end?r.end=Math.max(r.end,n):h.push({start:t,end:n})}let g=h.map(e=>f.slice(e.start,e.end).join(`
|
|
10
|
-
`));return{stdout:`${p.length>20?`Showing first 20 of ${p.length} matching lines (narrow the query for the rest):`:`${p.length} matching line(s) in ${h.length} region(s):`}\n\n${g.join(`
|
|
11
|
-
---
|
|
12
|
-
`)}\n`,stderr:``,exitCode:0}};export{i as annotateBoxes,s as findHandlerImpl,a as hiresClip,r as limitSnapshotDepth};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./wc-onboarding-DA2R9grP.js";export{e as hasOnboardingFinalLickInHistory};
|