sliccy 6.97.0 → 6.99.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/README.md +28 -0
  2. package/dist/ui/.vite/manifest.json +161 -145
  3. package/dist/ui/assets/{CLAUDE-CYnFKAQa.js → CLAUDE-CFY4V2wt.js} +1 -1
  4. package/dist/ui/assets/{SKILL-Ckg2XbSL.js → SKILL-BTVvFyRd.js} +3 -0
  5. package/dist/ui/assets/{SKILL-BdkyF8EU.js → SKILL-BpeW5CoS.js} +34 -0
  6. package/dist/ui/assets/SKILL-DQMA6JP2.js +1 -0
  7. package/dist/ui/assets/{account-store-o9kbxYNP.js → account-store-PGhT8u8K.js} +1 -1
  8. package/dist/ui/assets/{account-store-Cg-2w49h.js → account-store-UhvCpVi5.js} +1 -1
  9. package/dist/ui/assets/{adobe-BwMsnLTW.js → adobe-B0t9xpao.js} +1 -1
  10. package/dist/ui/assets/{adobe-Fh1l3uBG.js → adobe-CbQx7GGT.js} +1 -1
  11. package/dist/ui/assets/{apply-layout-CVaCm6ez.js → apply-layout-DesK_rTC.js} +1 -1
  12. package/dist/ui/assets/{apps-D8Fy0C0w.js → apps-D-cDcEBd.js} +1 -1
  13. package/dist/ui/assets/{azure-openai-DbK1jljH.js → azure-openai-tjg_Jac-.js} +1 -1
  14. package/dist/ui/assets/{azure-openai-DdTjgY_D.js → azure-openai-tx7uteql.js} +1 -1
  15. package/dist/ui/assets/{cerebras-Dn322vwm.js → cerebras-DHTBGb5d.js} +1 -1
  16. package/dist/ui/assets/{cerebras-DzRhzShV.js → cerebras-E43VFxsv.js} +1 -1
  17. package/dist/ui/assets/{connect-surface-85GQYPN7.js → connect-surface-DBraaKfB.js} +1 -1
  18. package/dist/ui/assets/fs-5TZPzTFc.js +1 -0
  19. package/dist/ui/assets/fs-fHIHSoGm.js +2 -0
  20. package/dist/ui/assets/{github-DVOLTeAR.js → github-CW-SPSdU.js} +2 -2
  21. package/dist/ui/assets/{github-copilot-BYEoLjZp.js → github-copilot-B2uCXhTH.js} +1 -1
  22. package/dist/ui/assets/{github-copilot-CbxhqDze.js → github-copilot-DmnUQ1GA.js} +1 -1
  23. package/dist/ui/assets/{github-install--6Mfi7-s.js → github-install-oNYELWrF.js} +1 -1
  24. package/dist/ui/assets/{github-3egbaDKx.js → github-olMzIeFS.js} +1 -1
  25. package/dist/ui/assets/{github-zip-NkED8tGl.js → github-zip-D48f7PNt.js} +1 -1
  26. package/dist/ui/assets/{js-realm-worker-C4jFZjVj.js → js-realm-worker-BXYcQvVa.js} +1 -1
  27. package/dist/ui/assets/{kernel-worker-B7JlGf5x.js → kernel-worker-CDlC4Khp.js} +583 -581
  28. package/dist/ui/assets/keys-0y1eyH9C.js +42 -0
  29. package/dist/ui/assets/{local-llm-G2BryvIP.js → local-llm-Da-S9Rwh.js} +1 -1
  30. package/dist/ui/assets/{local-llm-Bvc4sHV8.js → local-llm-yAuiAi8x.js} +1 -1
  31. package/dist/ui/assets/{main-Br8-CIKL.js → main-CjVUpZQF.js} +3 -3
  32. package/dist/ui/assets/{mount-B8ydUbOd.js → mount-CElAhSXQ.js} +2 -2
  33. package/dist/ui/assets/{mount-BDMPDS2b.js → mount-NuIgZQ5K.js} +1 -1
  34. package/dist/ui/assets/{mount-recovery-CA6Ao3BH.js → mount-recovery-CPdlB14n.js} +1 -1
  35. package/dist/ui/assets/{new-session-Cg2Mpqc9.js → new-session-CzJbuo5H.js} +2 -2
  36. package/dist/ui/assets/{oauth-bootstrap-DMDvHk4B.js → oauth-bootstrap-CyJ1t1fx.js} +2 -2
  37. package/dist/ui/assets/{openai-codex-CxEHICNB.js → openai-codex-B-dbXWiv.js} +1 -1
  38. package/dist/ui/assets/{openai-codex-C_Knsezn.js → openai-codex-s9z4Oe5H.js} +1 -1
  39. package/dist/ui/assets/{openrouter-gtOkB6u2.js → openrouter-BYtnhBPk.js} +1 -1
  40. package/dist/ui/assets/{openrouter-GTi8MsPB.js → openrouter-JAWMEkX8.js} +1 -1
  41. package/dist/ui/assets/{openrouter-oauth-CaBxtPod.js → openrouter-oauth-B2dqDEOw.js} +1 -1
  42. package/dist/ui/assets/{openrouter-oauth-J_crPpbH.js → openrouter-oauth-CcdLIqjS.js} +1 -1
  43. package/dist/ui/assets/{panel-rpc-handlers-BKjFPuBJ.js → panel-rpc-handlers-81nV4l2z.js} +2 -2
  44. package/dist/ui/assets/{panelize-shell-COz1Z7LB.js → panelize-shell-Dfx0Qk97.js} +1 -1
  45. package/dist/ui/assets/{provider-DmCr6kWk.js → provider-5iXJYXIP.js} +1 -1
  46. package/dist/ui/assets/{provider-CiZqhPJ9.js → provider-BrGxm1af.js} +2 -2
  47. package/dist/ui/assets/{provider-settings-BMTnSd2m.js → provider-settings-BcDzUFLS.js} +1 -1
  48. package/dist/ui/assets/{provider-settings-C1clUTbw.js → provider-settings-iKaSUXO2.js} +1 -1
  49. package/dist/ui/assets/{provider-store-access-DUGIDQde.js → provider-store-access-C0VGVu4i.js} +2 -2
  50. package/dist/ui/assets/provider-store-access-XG-jW25O.js +1 -0
  51. package/dist/ui/assets/{providers-BWBIz57j.js → providers-BEtOul-J.js} +1 -1
  52. package/dist/ui/assets/{providers-Czeq-PzU.js → providers-DePjGjI9.js} +2 -2
  53. package/dist/ui/assets/{quick-llm-6yEQ4lC4.js → quick-llm-CA49HefL.js} +1 -1
  54. package/dist/ui/assets/{recovery-screen-CJC7a2MU.js → recovery-screen-C820fnXa.js} +1 -1
  55. package/dist/ui/assets/{redirect-uri-Dg45MIO8.js → redirect-uri-_DXXUb3_.js} +1 -1
  56. package/dist/ui/assets/remote-vfs-client-CN1pCs1m.js +1 -0
  57. package/dist/ui/assets/{run-DYd2CZ4P.js → run-BtFwUHL1.js} +1 -1
  58. package/dist/ui/assets/{session-freezer-DtY95H68.js → session-freezer--jQwkHBW.js} +3 -3
  59. package/dist/ui/assets/{setup-feature-flags-remote-BcfR6hUl.js → setup-feature-flags-remote-CemRpM4O.js} +1 -1
  60. package/dist/ui/assets/{setup-standalone-prelude-CabX_m61.js → setup-standalone-prelude-B_CwyTA7.js} +1 -1
  61. package/dist/ui/assets/{setup-sudo-hKf18Nz8.js → setup-sudo-B6DI1Any.js} +2 -2
  62. package/dist/ui/assets/{skills-BRk53XDT.js → skills-OJDKT8VI.js} +1 -1
  63. package/dist/ui/assets/slicc-version-DJdeZSuo.js +1 -0
  64. package/dist/ui/assets/{src-CG9Sp0SZ.js → src-B-encLtu.js} +1 -1
  65. package/dist/ui/assets/{state-BJr9lEFI.js → state-DUdcCGso.js} +1 -1
  66. package/dist/ui/assets/{store-B2n1cRM8.js → store-Cxu67puX.js} +1 -1
  67. package/dist/ui/assets/{store-B-OIjDgy.js → store-WNZa0aQX.js} +1 -1
  68. package/dist/ui/assets/{sudo-6Ixuyt40.js → sudo-w5yl__4P.js} +1 -1
  69. package/dist/ui/assets/{upgrade-detection-CVEShXgP.js → upgrade-detection-BsjYW856.js} +1 -1
  70. package/dist/ui/assets/validate-args-DEw-pWqJ.js +1 -0
  71. package/dist/ui/assets/{wc-attach-BbEnzTrf.js → wc-attach-3I9pOCPA.js} +2 -2
  72. package/dist/ui/assets/{wc-extension-CnAvqxvk.js → wc-extension-CnWiY4XW.js} +2 -2
  73. package/dist/ui/assets/{wc-float-label-BATxvSb5.js → wc-float-label-CCMo81Ds.js} +1 -1
  74. package/dist/ui/assets/{wc-floatbar-online-Dogbrrqe.js → wc-floatbar-online-tsTifrU7.js} +1 -1
  75. package/dist/ui/assets/{wc-follower-DrbsL9Qv.js → wc-follower-BxgSEnFh.js} +3 -3
  76. package/dist/ui/assets/wc-live-C-Tc-fkR.js +8 -0
  77. package/dist/ui/assets/wc-nav-4BWGTo3o.js +2 -0
  78. package/dist/ui/assets/{wc-onboarding-DGuMIgxe.js → wc-onboarding-C_K_bkLE.js} +2 -2
  79. package/dist/ui/assets/{wc-placeholder-D95SuRGT.js → wc-placeholder-BJUxgyv_.js} +2 -2
  80. package/dist/ui/assets/{wc-settings-SEM2ky_l.js → wc-settings-vHpNnJj9.js} +2 -2
  81. package/dist/ui/assets/wc-shell-tlPtWG89.js +119 -0
  82. package/dist/ui/assets/wc-shortcut-config-w6fJ0bVB.js +42 -0
  83. package/dist/ui/assets/wc-shortcuts-GiPteshM.js +26 -0
  84. package/dist/ui/assets/{wc-sprinkles-Dvok17gm.js → wc-sprinkles-Mzuq6tXf.js} +2 -2
  85. package/dist/ui/assets/{wc-tray-CzVJdHpb.js → wc-tray-CiN14R7Y.js} +2 -2
  86. package/dist/ui/assets/{writable-vfs-client-Dqrpx9iK.js → writable-vfs-client-CuBjWhy3.js} +1 -1
  87. package/dist/ui/assets/{xai-grok-YCcAjHnt.js → xai-grok-C3Cl0btv.js} +1 -1
  88. package/dist/ui/assets/{xai-grok-CWGsClO5.js → xai-grok-CDtgl5Ap.js} +1 -1
  89. package/dist/ui/index.html +6 -6
  90. package/dist/ui/llm-proxy-sw.js +1 -1
  91. package/dist/ui/packages/webapp/index.html +6 -6
  92. package/package.json +1 -1
  93. package/dist/ui/assets/SKILL-AQBip2ki.js +0 -1
  94. package/dist/ui/assets/fs-5FHqzVIZ.js +0 -1
  95. package/dist/ui/assets/fs-_H4iQl_D.js +0 -2
  96. package/dist/ui/assets/provider-store-access-f12_9OHR.js +0 -1
  97. package/dist/ui/assets/remote-vfs-client-5faRBsEi.js +0 -1
  98. package/dist/ui/assets/slicc-version-bYWbRDsC.js +0 -1
  99. package/dist/ui/assets/wc-live-BInekJR7.js +0 -8
  100. package/dist/ui/assets/wc-nav-DUairsPL.js +0 -2
  101. package/dist/ui/assets/wc-shell-DRaOFz6u.js +0 -119
@@ -1 +1 @@
1
- import{t as e}from"./types-idfTVsM8.js";function t(e){return new r(e)}var n=`vfs-w-`,r=class{transport;log;genId;pending=new Map;unsubscribe=null;counter=0;constructor(e){this.transport=e.transport,this.log=e.logger??console,this.genId=e.generateRequestId??(()=>{this.counter=this.counter+1>>>0;let e=Math.random().toString(36).slice(2,8);return`${n}${this.counter.toString(36)}-${e}`}),this.unsubscribe=this.transport.onMessage(e=>{if(!i(e)||e.source!==`offscreen`)return;let t=e.payload;a(t)&&this.handleResult(t)})}readDir(e){let t=this.genId(),n={type:`vfs-read-dir`,requestId:t,path:e};return this.request(t,`vfs-read-dir-result`,e,n)}readFile(e,t){let n=this.genId(),r={type:`vfs-read-file`,requestId:n,path:e,encoding:t?.encoding??`utf-8`};return this.request(n,`vfs-read-file-result`,e,r)}stat(e){let t=this.genId(),n={type:`vfs-stat`,requestId:t,path:e};return this.request(t,`vfs-stat-result`,e,n)}writeFile(t,n,r){let i=this.genId(),a=r?.recursive;if(n instanceof Uint8Array){let e={type:`vfs-write-file`,requestId:i,path:t,encoding:`binary`,data:n,...a===void 0?{}:{recursive:a}},r=n.buffer,o=typeof ArrayBuffer<`u`&&r instanceof ArrayBuffer?[r]:void 0;return this.request(i,`vfs-write-file-result`,t,e,o)}if(typeof n!=`string`)return Promise.reject(new e(`EINVAL`,`writeFile content must be string or Uint8Array`,t));let o={type:`vfs-write-file`,requestId:i,path:t,encoding:`utf-8`,data:n,...a===void 0?{}:{recursive:a}};return this.request(i,`vfs-write-file-result`,t,o)}mkdir(e,t){let n=this.genId(),r=t?.recursive,i={type:`vfs-mkdir`,requestId:n,path:e,...r===void 0?{}:{recursive:r}};return this.request(n,`vfs-mkdir-result`,e,i)}rm(e,t){let n=this.genId(),r=t?.recursive,i={type:`vfs-rm`,requestId:n,path:e,...r===void 0?{}:{recursive:r}};return this.request(n,`vfs-rm-result`,e,i)}flush(){let e=this.genId(),t={type:`vfs-flush`,requestId:e};return this.request(e,`vfs-flush-result`,``,t)}listMountPoints(){let e=this.genId(),t={type:`vfs-list-mount-points`,requestId:e};return this.request(e,`vfs-list-mount-points-result`,``,t)}dispose(){this.unsubscribe?.(),this.unsubscribe=null;for(let[,t]of this.pending)t.reject(new e(`EBADF`,`RemoteWritableVfsClient disposed`,t.path));this.pending.clear()}request(e,t,n,r,i){return new Promise((a,o)=>{this.pending.set(e,{resolve:a,reject:o,expect:t,path:n});try{this.transport.send(r,i)}catch(t){this.pending.delete(e),o(t)}})}handleResult(t){let r=this.pending.get(t.requestId);if(!r){t.requestId.startsWith(n)&&this.log.debug?.(`[remote-writable-vfs-client] drop unmatched response`,{type:t.type,requestId:t.requestId});return}if(r.expect!==t.type){this.pending.delete(t.requestId),r.reject(new e(`EIO`,`vfs-rpc response type mismatch (got ${t.type})`,r.path));return}if(this.pending.delete(t.requestId),t.ok===!1){r.reject(o(t.error.code,t.error.message,t.error.path??r.path));return}switch(t.type){case`vfs-read-dir-result`:r.resolve(t.entries);return;case`vfs-read-file-result`:r.resolve(t.data);return;case`vfs-stat-result`:r.resolve(t.stats);return;case`vfs-list-mount-points-result`:r.resolve(t.mountPoints);return;case`vfs-write-file-result`:case`vfs-mkdir-result`:case`vfs-rm-result`:case`vfs-flush-result`:r.resolve(void 0);return}}};function i(e){return typeof e==`object`&&!!e&&`source`in e&&`payload`in e}function a(e){if(typeof e.requestId!=`string`)return!1;let t=e.type;return t===`vfs-read-dir-result`||t===`vfs-read-file-result`||t===`vfs-stat-result`||t===`vfs-write-file-result`||t===`vfs-mkdir-result`||t===`vfs-rm-result`||t===`vfs-flush-result`||t===`vfs-list-mount-points-result`}function o(t,n,r){let i=[`ENOENT`,`EEXIST`,`ENOTDIR`,`EISDIR`,`ENOTEMPTY`,`EINVAL`,`EACCES`,`ELOOP`,`EBUSY`,`EFBIG`,`EBADF`,`EIO`].includes(t)?t:`EIO`;return new e(i,n,r)}export{t as createRemoteWritableVfsClient};
1
+ import{t as e}from"./types-idfTVsM8.js";function t(e){return new r(e)}var n=`vfs-w-`,r=class{transport;log;genId;pending=new Map;unsubscribe=null;counter=0;constructor(e){this.transport=e.transport,this.log=e.logger??console,this.genId=e.generateRequestId??(()=>{this.counter=this.counter+1>>>0;let e=Math.random().toString(36).slice(2,8);return`${n}${this.counter.toString(36)}-${e}`}),this.unsubscribe=this.transport.onMessage(e=>{if(!i(e)||e.source!==`offscreen`)return;let t=e.payload;a(t)&&this.handleResult(t)})}readDir(e){let t=this.genId(),n={type:`vfs-read-dir`,requestId:t,path:e};return this.request(t,`vfs-read-dir-result`,e,n)}readFile(e,t){let n=this.genId(),r={type:`vfs-read-file`,requestId:n,path:e,encoding:t?.encoding??`utf-8`};return this.request(n,`vfs-read-file-result`,e,r)}stat(e){let t=this.genId(),n={type:`vfs-stat`,requestId:t,path:e};return this.request(t,`vfs-stat-result`,e,n)}writeFile(t,n,r){let i=this.genId(),a=r?.recursive;if(n instanceof Uint8Array){let e={type:`vfs-write-file`,requestId:i,path:t,encoding:`binary`,data:n,...a===void 0?{}:{recursive:a}},r=n.buffer,o=typeof ArrayBuffer<`u`&&r instanceof ArrayBuffer?[r]:void 0;return this.request(i,`vfs-write-file-result`,t,e,o)}if(typeof n!=`string`)return Promise.reject(new e(`EINVAL`,`writeFile content must be string or Uint8Array`,t));let o={type:`vfs-write-file`,requestId:i,path:t,encoding:`utf-8`,data:n,...a===void 0?{}:{recursive:a}};return this.request(i,`vfs-write-file-result`,t,o)}mkdir(e,t){let n=this.genId(),r=t?.recursive,i={type:`vfs-mkdir`,requestId:n,path:e,...r===void 0?{}:{recursive:r}};return this.request(n,`vfs-mkdir-result`,e,i)}rm(e,t){let n=this.genId(),r=t?.recursive,i={type:`vfs-rm`,requestId:n,path:e,...r===void 0?{}:{recursive:r}};return this.request(n,`vfs-rm-result`,e,i)}flush(){let e=this.genId(),t={type:`vfs-flush`,requestId:e};return this.request(e,`vfs-flush-result`,``,t)}listMountPoints(){let e=this.genId(),t={type:`vfs-list-mount-points`,requestId:e};return this.request(e,`vfs-list-mount-points-result`,``,t)}dispose(){this.unsubscribe?.(),this.unsubscribe=null;for(let[,t]of this.pending)t.reject(new e(`EBADF`,`RemoteWritableVfsClient disposed`,t.path));this.pending.clear()}request(e,t,n,r,i){return new Promise((a,o)=>{this.pending.set(e,{resolve:a,reject:o,expect:t,path:n});try{this.transport.send(r,i)}catch(t){this.pending.delete(e),o(t)}})}handleResult(t){let r=this.pending.get(t.requestId);if(!r){t.requestId.startsWith(n)&&this.log.debug?.(`[remote-writable-vfs-client] drop unmatched response`,{type:t.type,requestId:t.requestId});return}if(r.expect!==t.type){this.pending.delete(t.requestId),r.reject(new e(`EIO`,`vfs-rpc response type mismatch (got ${t.type})`,r.path));return}if(this.pending.delete(t.requestId),t.ok===!1){r.reject(o(t.error.code,t.error.message,t.error.path??r.path));return}switch(t.type){case`vfs-read-dir-result`:r.resolve(t.entries);return;case`vfs-read-file-result`:r.resolve(t.data);return;case`vfs-stat-result`:r.resolve(t.stats);return;case`vfs-list-mount-points-result`:r.resolve(t.mountPoints);return;case`vfs-write-file-result`:case`vfs-mkdir-result`:case`vfs-rm-result`:case`vfs-flush-result`:r.resolve(void 0);return}}};function i(e){return typeof e==`object`&&!!e&&`source`in e&&`payload`in e}function a(e){if(typeof e.requestId!=`string`)return!1;let t=e.type;return t===`vfs-read-dir-result`||t===`vfs-read-file-result`||t===`vfs-stat-result`||t===`vfs-write-file-result`||t===`vfs-mkdir-result`||t===`vfs-rm-result`||t===`vfs-flush-result`||t===`vfs-list-mount-points-result`}function o(t,n,r){let i=[`ENOENT`,`EEXIST`,`ENOTDIR`,`EISDIR`,`ENOTEMPTY`,`EINVAL`,`EACCES`,`ELOOP`,`EBUSY`,`EFBIG`,`EBADF`,`ENOSYS`,`EIO`].includes(t)?t:`EIO`;return new e(i,n,r)}export{t as createRemoteWritableVfsClient};
@@ -1 +1 @@
1
- import{H as e,d as t}from"./account-store-o9kbxYNP.js";import{a as n}from"./diagnostics-DN_idNHx.js";import{c as r,u as i}from"./claude-model-version-DoVrYsKi.js";import{c as a,i as o,r as s,s as c}from"./legacy-api-aliases-BnRqMAef.js";import"./provider-settings-C1clUTbw.js";import{n as l,r as u,t as d}from"./pkce-hGf_TEnP.js";import{XaiErrorCode as f,XaiOAuthError as p}from"./xai-grok-errors-bnlIBeu-.js";var m=`xai-grok`,h=`https://auth.x.ai`,g=`${h}/oauth2/authorize`,_=`${h}/oauth2/token`,v=`b1a00492-073a-47ea-816f-4c329264a828`,y=`openid profile email offline_access grok-cli:access api:access`,b=`http://127.0.0.1:56121/callback`,x=`http://127.0.0.1:56121/*`,S=`https://api.x.ai/v1`,C=`grok-4.5`,w=`${m}-openai`;function T(){return r(`xai`)}function E(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}}function D(e){let t=T(),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 "${C}"`),n=t.find(e=>e.id===C),!n))throw Error(`xAI default model "${C}" 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:S}}async function O(e,t){let n=new URLSearchParams({grant_type:`authorization_code`,code:e,redirect_uri:b,client_id:v,code_verifier:t}),r=await fetch(_,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:n});if(!r.ok)throw new p(`xAI token exchange failed: ${r.status} ${await r.text()}`,f.TOKEN_EXCHANGE_FAILED);let i=await r.json();if(!i.access_token)throw new p(`xAI token exchange did not return access_token.`,f.TOKEN_EXCHANGE_INVALID);return i}async function k(e){try{let t=new URLSearchParams({grant_type:`refresh_token`,refresh_token:e,client_id:v}),n=await fetch(_,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:t});return n.ok?await n.json():(console.error(`[xai-grok] refresh failed:`,n.status,await n.text()),null)}catch(e){return console.error(`[xai-grok] refresh error:`,e instanceof Error?e.message:String(e)),null}}function A(){return t().find(e=>e.providerId===m)}async function j(){let t=A();if(!t?.accessToken)throw new p("Not signed in to xAI Grok — run /login or `oauth-token xai-grok`",f.AUTH_MISSING,!0);let n=t.tokenExpiresAt??0;if(n&&Date.now()+6e4<n)return t.accessToken;if(t.refreshToken){let n=await k(t.refreshToken);if(n?.access_token)return await e({providerId:m,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}function M(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:w,provider:m,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 N(e,t){return t?{...e??{},"x-grok-conv-id":t}:e}var P=(e,t,r={})=>{let i=n();return(async()=>{try{let n=await j(),a=r.sessionId,c=D(e),l={...r,apiKey:n,headers:N(r.headers,a)},u=c.api===`openai-responses`?o(c,t,l):s(c,t,l);for await(let e of u)i.push(e);i.end()}catch(t){console.error(`[xai-grok] Stream error:`,t instanceof Error?t.message:String(t)),i.push(M(e,t)),i.end()}})(),i},F=(e,t,r)=>{let i=n();return(async()=>{try{let n=await j(),o=r?.sessionId,s=D(e),l={...r,apiKey:n,headers:N(r?.headers,o)},u=s.api===`openai-responses`?a(s,t,l):c(s,t,l);for await(let e of u)i.push(e);i.end()}catch(t){console.error(`[xai-grok] Stream error:`,t instanceof Error?t.message:String(t)),i.push(M(e,t)),i.end()}})(),i},I={id:m,name:`xAI Grok (SuperGrok OAuth)`,description:`Grok via xAI OAuth — uses your SuperGrok subscription, no API key needed. Default model is Grok 4.5.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:C,oauthTokenDomains:[`api.x.ai`,`*.x.ai`,`auth.x.ai`,`accounts.x.ai`],getModelIds:()=>T().map(E),onOAuthLoginIntercepted:async(t,n,r)=>{let i=l(),a=await d(i),o=u(),s=u(),c=new URL(g);c.searchParams.set(`response_type`,`code`),c.searchParams.set(`client_id`,v),c.searchParams.set(`redirect_uri`,b),c.searchParams.set(`scope`,r?.scopes??y),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 h=await t({authorizeUrl:c.toString(),redirectUriPattern:x,onCapture:`close`});if(!h)throw new p(`xAI OAuth login was cancelled or timed out`,f.CALLBACK_TIMEOUT);let _=new URL(h),C=_.searchParams.get(`code`),w=_.searchParams.get(`state`);if(!C)throw new p(`xAI OAuth redirect did not include a code`,f.CODE_MISSING);if(w!==o)throw new p(`xAI OAuth state mismatch — possible CSRF, aborting`,f.STATE_MISMATCH);let T=await O(C,i);await e({providerId:m,accessToken:T.access_token,refreshToken:T.refresh_token,tokenExpiresAt:Date.now()+(T.expires_in??21600)*1e3,baseUrl:S,scopes:T.scope}),n()},onOAuthLogout:async()=>{await e({providerId:m,accessToken:``})},onSilentRenew:async()=>{let t=A();if(!t?.refreshToken)return null;let n=await k(t.refreshToken);return n?.access_token?(await e({providerId:m,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 L(){i({api:w,stream:P,streamSimple:F})}export{f as XaiErrorCode,p as XaiOAuthError,I as config,L as register};
1
+ import{H as e,d as t}from"./account-store-PGhT8u8K.js";import{a as n}from"./diagnostics-DN_idNHx.js";import{c as r,u as i}from"./claude-model-version-DoVrYsKi.js";import{c as a,i as o,r as s,s as c}from"./legacy-api-aliases-BnRqMAef.js";import"./provider-settings-iKaSUXO2.js";import{n as l,r as u,t as d}from"./pkce-hGf_TEnP.js";import{XaiErrorCode as f,XaiOAuthError as p}from"./xai-grok-errors-bnlIBeu-.js";var m=`xai-grok`,h=`https://auth.x.ai`,g=`${h}/oauth2/authorize`,_=`${h}/oauth2/token`,v=`b1a00492-073a-47ea-816f-4c329264a828`,y=`openid profile email offline_access grok-cli:access api:access`,b=`http://127.0.0.1:56121/callback`,x=`http://127.0.0.1:56121/*`,S=`https://api.x.ai/v1`,C=`grok-4.5`,w=`${m}-openai`;function T(){return r(`xai`)}function E(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}}function D(e){let t=T(),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 "${C}"`),n=t.find(e=>e.id===C),!n))throw Error(`xAI default model "${C}" 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:S}}async function O(e,t){let n=new URLSearchParams({grant_type:`authorization_code`,code:e,redirect_uri:b,client_id:v,code_verifier:t}),r=await fetch(_,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:n});if(!r.ok)throw new p(`xAI token exchange failed: ${r.status} ${await r.text()}`,f.TOKEN_EXCHANGE_FAILED);let i=await r.json();if(!i.access_token)throw new p(`xAI token exchange did not return access_token.`,f.TOKEN_EXCHANGE_INVALID);return i}async function k(e){try{let t=new URLSearchParams({grant_type:`refresh_token`,refresh_token:e,client_id:v}),n=await fetch(_,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:t});return n.ok?await n.json():(console.error(`[xai-grok] refresh failed:`,n.status,await n.text()),null)}catch(e){return console.error(`[xai-grok] refresh error:`,e instanceof Error?e.message:String(e)),null}}function A(){return t().find(e=>e.providerId===m)}async function j(){let t=A();if(!t?.accessToken)throw new p("Not signed in to xAI Grok — run /login or `oauth-token xai-grok`",f.AUTH_MISSING,!0);let n=t.tokenExpiresAt??0;if(n&&Date.now()+6e4<n)return t.accessToken;if(t.refreshToken){let n=await k(t.refreshToken);if(n?.access_token)return await e({providerId:m,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}function M(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:w,provider:m,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 N(e,t){return t?{...e??{},"x-grok-conv-id":t}:e}var P=(e,t,r={})=>{let i=n();return(async()=>{try{let n=await j(),a=r.sessionId,c=D(e),l={...r,apiKey:n,headers:N(r.headers,a)},u=c.api===`openai-responses`?o(c,t,l):s(c,t,l);for await(let e of u)i.push(e);i.end()}catch(t){console.error(`[xai-grok] Stream error:`,t instanceof Error?t.message:String(t)),i.push(M(e,t)),i.end()}})(),i},F=(e,t,r)=>{let i=n();return(async()=>{try{let n=await j(),o=r?.sessionId,s=D(e),l={...r,apiKey:n,headers:N(r?.headers,o)},u=s.api===`openai-responses`?a(s,t,l):c(s,t,l);for await(let e of u)i.push(e);i.end()}catch(t){console.error(`[xai-grok] Stream error:`,t instanceof Error?t.message:String(t)),i.push(M(e,t)),i.end()}})(),i},I={id:m,name:`xAI Grok (SuperGrok OAuth)`,description:`Grok via xAI OAuth — uses your SuperGrok subscription, no API key needed. Default model is Grok 4.5.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:C,oauthTokenDomains:[`api.x.ai`,`*.x.ai`,`auth.x.ai`,`accounts.x.ai`],getModelIds:()=>T().map(E),onOAuthLoginIntercepted:async(t,n,r)=>{let i=l(),a=await d(i),o=u(),s=u(),c=new URL(g);c.searchParams.set(`response_type`,`code`),c.searchParams.set(`client_id`,v),c.searchParams.set(`redirect_uri`,b),c.searchParams.set(`scope`,r?.scopes??y),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 h=await t({authorizeUrl:c.toString(),redirectUriPattern:x,onCapture:`close`});if(!h)throw new p(`xAI OAuth login was cancelled or timed out`,f.CALLBACK_TIMEOUT);let _=new URL(h),C=_.searchParams.get(`code`),w=_.searchParams.get(`state`);if(!C)throw new p(`xAI OAuth redirect did not include a code`,f.CODE_MISSING);if(w!==o)throw new p(`xAI OAuth state mismatch — possible CSRF, aborting`,f.STATE_MISMATCH);let T=await O(C,i);await e({providerId:m,accessToken:T.access_token,refreshToken:T.refresh_token,tokenExpiresAt:Date.now()+(T.expires_in??21600)*1e3,baseUrl:S,scopes:T.scope}),n()},onOAuthLogout:async()=>{await e({providerId:m,accessToken:``})},onSilentRenew:async()=>{let t=A();if(!t?.refreshToken)return null;let n=await k(t.refreshToken);return n?.access_token?(await e({providerId:m,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 L(){i({api:w,stream:P,streamSimple:F})}export{f as XaiErrorCode,p as XaiOAuthError,I as config,L as register};
@@ -1 +1 @@
1
- import{H as e,d as t}from"./account-store-Cg-2w49h.js";import{a as n}from"./diagnostics-DN_idNHx.js";import{c as r,u as i}from"./claude-model-version-Csn7RPVg.js";import{c as a,i as o,r as s,s as c}from"./legacy-api-aliases-oJPAvhVV.js";import"./provider-settings-BMTnSd2m.js";import{n as l,r as u,t as d}from"./pkce-hGf_TEnP.js";import{XaiErrorCode as f,XaiOAuthError as p}from"./xai-grok-errors-ByEMMSoz.js";const m=`xai-grok`,h=`https://auth.x.ai`,g=`${h}/oauth2/authorize`,_=`${h}/oauth2/token`,v=`b1a00492-073a-47ea-816f-4c329264a828`,y=`http://127.0.0.1:56121/callback`,b=`https://api.x.ai/v1`,x=`grok-4.5`,S=`${m}-openai`;function C(){return r(`xai`)}function w(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}}function T(e){let t=C(),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 "${x}"`),n=t.find(e=>e.id===x),!n))throw Error(`xAI default model "${x}" 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:b}}async function E(e,t){let n=new URLSearchParams({grant_type:`authorization_code`,code:e,redirect_uri:y,client_id:v,code_verifier:t}),r=await fetch(_,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:n});if(!r.ok)throw new p(`xAI token exchange failed: ${r.status} ${await r.text()}`,f.TOKEN_EXCHANGE_FAILED);let i=await r.json();if(!i.access_token)throw new p(`xAI token exchange did not return access_token.`,f.TOKEN_EXCHANGE_INVALID);return i}async function D(e){try{let t=new URLSearchParams({grant_type:`refresh_token`,refresh_token:e,client_id:v}),n=await fetch(_,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:t});return n.ok?await n.json():(console.error(`[xai-grok] refresh failed:`,n.status,await n.text()),null)}catch(e){return console.error(`[xai-grok] refresh error:`,e instanceof Error?e.message:String(e)),null}}function O(){return t().find(e=>e.providerId===m)}async function k(){let t=O();if(!t?.accessToken)throw new p("Not signed in to xAI Grok — run /login or `oauth-token xai-grok`",f.AUTH_MISSING,!0);let n=t.tokenExpiresAt??0;if(n&&Date.now()+6e4<n)return t.accessToken;if(t.refreshToken){let n=await D(t.refreshToken);if(n?.access_token)return await e({providerId:m,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}function A(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:S,provider:m,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 j(e,t){return t?{...e??{},"x-grok-conv-id":t}:e}const M=(e,t,r={})=>{let i=n();return(async()=>{try{let n=await k(),a=r.sessionId,c=T(e),l={...r,apiKey:n,headers:j(r.headers,a)},u=c.api===`openai-responses`?o(c,t,l):s(c,t,l);for await(let e of u)i.push(e);i.end()}catch(t){console.error(`[xai-grok] Stream error:`,t instanceof Error?t.message:String(t)),i.push(A(e,t)),i.end()}})(),i},N=(e,t,r)=>{let i=n();return(async()=>{try{let n=await k(),o=r?.sessionId,s=T(e),l={...r,apiKey:n,headers:j(r?.headers,o)},u=s.api===`openai-responses`?a(s,t,l):c(s,t,l);for await(let e of u)i.push(e);i.end()}catch(t){console.error(`[xai-grok] Stream error:`,t instanceof Error?t.message:String(t)),i.push(A(e,t)),i.end()}})(),i},P={id:m,name:`xAI Grok (SuperGrok OAuth)`,description:`Grok via xAI OAuth — uses your SuperGrok subscription, no API key needed. Default model is Grok 4.5.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:x,oauthTokenDomains:[`api.x.ai`,`*.x.ai`,`auth.x.ai`,`accounts.x.ai`],getModelIds:()=>C().map(w),onOAuthLoginIntercepted:async(t,n,r)=>{let i=l(),a=await d(i),o=u(),s=u(),c=new URL(g);c.searchParams.set(`response_type`,`code`),c.searchParams.set(`client_id`,v),c.searchParams.set(`redirect_uri`,y),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 h=await t({authorizeUrl:c.toString(),redirectUriPattern:`http://127.0.0.1:56121/*`,onCapture:`close`});if(!h)throw new p(`xAI OAuth login was cancelled or timed out`,f.CALLBACK_TIMEOUT);let _=new URL(h),x=_.searchParams.get(`code`),S=_.searchParams.get(`state`);if(!x)throw new p(`xAI OAuth redirect did not include a code`,f.CODE_MISSING);if(S!==o)throw new p(`xAI OAuth state mismatch — possible CSRF, aborting`,f.STATE_MISMATCH);let C=await E(x,i);await e({providerId:m,accessToken:C.access_token,refreshToken:C.refresh_token,tokenExpiresAt:Date.now()+(C.expires_in??21600)*1e3,baseUrl:b,scopes:C.scope}),n()},onOAuthLogout:async()=>{await e({providerId:m,accessToken:``})},onSilentRenew:async()=>{let t=O();if(!t?.refreshToken)return null;let n=await D(t.refreshToken);return n?.access_token?(await e({providerId:m,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 F(){i({api:S,stream:M,streamSimple:N})}export{f as XaiErrorCode,p as XaiOAuthError,P as config,F as register};
1
+ import{H as e,d as t}from"./account-store-UhvCpVi5.js";import{a as n}from"./diagnostics-DN_idNHx.js";import{c as r,u as i}from"./claude-model-version-Csn7RPVg.js";import{c as a,i as o,r as s,s as c}from"./legacy-api-aliases-oJPAvhVV.js";import"./provider-settings-BcDzUFLS.js";import{n as l,r as u,t as d}from"./pkce-hGf_TEnP.js";import{XaiErrorCode as f,XaiOAuthError as p}from"./xai-grok-errors-ByEMMSoz.js";const m=`xai-grok`,h=`https://auth.x.ai`,g=`${h}/oauth2/authorize`,_=`${h}/oauth2/token`,v=`b1a00492-073a-47ea-816f-4c329264a828`,y=`http://127.0.0.1:56121/callback`,b=`https://api.x.ai/v1`,x=`grok-4.5`,S=`${m}-openai`;function C(){return r(`xai`)}function w(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}}function T(e){let t=C(),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 "${x}"`),n=t.find(e=>e.id===x),!n))throw Error(`xAI default model "${x}" 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:b}}async function E(e,t){let n=new URLSearchParams({grant_type:`authorization_code`,code:e,redirect_uri:y,client_id:v,code_verifier:t}),r=await fetch(_,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:n});if(!r.ok)throw new p(`xAI token exchange failed: ${r.status} ${await r.text()}`,f.TOKEN_EXCHANGE_FAILED);let i=await r.json();if(!i.access_token)throw new p(`xAI token exchange did not return access_token.`,f.TOKEN_EXCHANGE_INVALID);return i}async function D(e){try{let t=new URLSearchParams({grant_type:`refresh_token`,refresh_token:e,client_id:v}),n=await fetch(_,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:t});return n.ok?await n.json():(console.error(`[xai-grok] refresh failed:`,n.status,await n.text()),null)}catch(e){return console.error(`[xai-grok] refresh error:`,e instanceof Error?e.message:String(e)),null}}function O(){return t().find(e=>e.providerId===m)}async function k(){let t=O();if(!t?.accessToken)throw new p("Not signed in to xAI Grok — run /login or `oauth-token xai-grok`",f.AUTH_MISSING,!0);let n=t.tokenExpiresAt??0;if(n&&Date.now()+6e4<n)return t.accessToken;if(t.refreshToken){let n=await D(t.refreshToken);if(n?.access_token)return await e({providerId:m,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}function A(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:S,provider:m,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 j(e,t){return t?{...e??{},"x-grok-conv-id":t}:e}const M=(e,t,r={})=>{let i=n();return(async()=>{try{let n=await k(),a=r.sessionId,c=T(e),l={...r,apiKey:n,headers:j(r.headers,a)},u=c.api===`openai-responses`?o(c,t,l):s(c,t,l);for await(let e of u)i.push(e);i.end()}catch(t){console.error(`[xai-grok] Stream error:`,t instanceof Error?t.message:String(t)),i.push(A(e,t)),i.end()}})(),i},N=(e,t,r)=>{let i=n();return(async()=>{try{let n=await k(),o=r?.sessionId,s=T(e),l={...r,apiKey:n,headers:j(r?.headers,o)},u=s.api===`openai-responses`?a(s,t,l):c(s,t,l);for await(let e of u)i.push(e);i.end()}catch(t){console.error(`[xai-grok] Stream error:`,t instanceof Error?t.message:String(t)),i.push(A(e,t)),i.end()}})(),i},P={id:m,name:`xAI Grok (SuperGrok OAuth)`,description:`Grok via xAI OAuth — uses your SuperGrok subscription, no API key needed. Default model is Grok 4.5.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:x,oauthTokenDomains:[`api.x.ai`,`*.x.ai`,`auth.x.ai`,`accounts.x.ai`],getModelIds:()=>C().map(w),onOAuthLoginIntercepted:async(t,n,r)=>{let i=l(),a=await d(i),o=u(),s=u(),c=new URL(g);c.searchParams.set(`response_type`,`code`),c.searchParams.set(`client_id`,v),c.searchParams.set(`redirect_uri`,y),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 h=await t({authorizeUrl:c.toString(),redirectUriPattern:`http://127.0.0.1:56121/*`,onCapture:`close`});if(!h)throw new p(`xAI OAuth login was cancelled or timed out`,f.CALLBACK_TIMEOUT);let _=new URL(h),x=_.searchParams.get(`code`),S=_.searchParams.get(`state`);if(!x)throw new p(`xAI OAuth redirect did not include a code`,f.CODE_MISSING);if(S!==o)throw new p(`xAI OAuth state mismatch — possible CSRF, aborting`,f.STATE_MISMATCH);let C=await E(x,i);await e({providerId:m,accessToken:C.access_token,refreshToken:C.refresh_token,tokenExpiresAt:Date.now()+(C.expires_in??21600)*1e3,baseUrl:b,scopes:C.scope}),n()},onOAuthLogout:async()=>{await e({providerId:m,accessToken:``})},onSilentRenew:async()=>{let t=O();if(!t?.refreshToken)return null;let n=await D(t.refreshToken);return n?.access_token?(await e({providerId:m,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 F(){i({api:S,stream:M,streamSimple:N})}export{f as XaiErrorCode,p as XaiOAuthError,P as config,F as register};
@@ -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-Br8-CIKL.js"></script>
8
+ <script type="module" crossorigin src="/assets/main-CjVUpZQF.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/modulepreload-polyfill-P2Xu9kJm.js">
10
10
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-Dd_uD5pT.js">
11
11
  <link rel="modulepreload" crossorigin href="/assets/preload-helper-Czpn1I53.js">
@@ -30,21 +30,21 @@
30
30
  <link rel="modulepreload" crossorigin href="/assets/secrets-bridge-client-DCQ44RyR.js">
31
31
  <link rel="modulepreload" crossorigin href="/assets/image-markers-BXtVm4og.js">
32
32
  <link rel="modulepreload" crossorigin href="/assets/tool-ui-DfXu6quJ.js">
33
- <link rel="modulepreload" crossorigin href="/assets/providers-Czeq-PzU.js">
33
+ <link rel="modulepreload" crossorigin href="/assets/providers-DePjGjI9.js">
34
34
  <link rel="modulepreload" crossorigin href="/assets/panel-rpc-B3MSVImO.js">
35
35
  <link rel="modulepreload" crossorigin href="/assets/bedrock-camp-compat-CgBMwna8.js">
36
- <link rel="modulepreload" crossorigin href="/assets/account-store-o9kbxYNP.js">
36
+ <link rel="modulepreload" crossorigin href="/assets/account-store-PGhT8u8K.js">
37
37
  <link rel="modulepreload" crossorigin href="/assets/runtime-env-CgsZ7LTp.js">
38
38
  <link rel="modulepreload" crossorigin href="/assets/messages-BD4p8GuF.js">
39
39
  <link rel="modulepreload" crossorigin href="/assets/tray-runtime-config-D7cmCcHJ.js">
40
- <link rel="modulepreload" crossorigin href="/assets/setup-sudo-hKf18Nz8.js">
41
- <link rel="modulepreload" crossorigin href="/assets/setup-standalone-prelude-CabX_m61.js">
40
+ <link rel="modulepreload" crossorigin href="/assets/setup-sudo-B6DI1Any.js">
41
+ <link rel="modulepreload" crossorigin href="/assets/setup-standalone-prelude-B_CwyTA7.js">
42
42
  <link rel="modulepreload" crossorigin href="/assets/telemetry-BVzuNdvW.js">
43
43
  <link rel="modulepreload" crossorigin href="/assets/feature-flags-ByMXaIc4.js">
44
44
  <link rel="modulepreload" crossorigin href="/assets/tray-follower-status-BAjnN7Ar.js">
45
45
  <link rel="modulepreload" crossorigin href="/assets/clipboard-eqmn97SP.js">
46
46
  <link rel="modulepreload" crossorigin href="/assets/tray-join-url-BIvzbiFR.js">
47
- <link rel="modulepreload" crossorigin href="/assets/provider-settings-C1clUTbw.js">
47
+ <link rel="modulepreload" crossorigin href="/assets/provider-settings-iKaSUXO2.js">
48
48
  </head>
49
49
  <body>
50
50
  <div id="app"></div>
@@ -1 +1 @@
1
- "use strict";(()=>{var v="https://www.sliccy.ai";var T="bridgeToken",I="bridge",B="X-Bridge-Token";var Ee=new URL(v).hostname,at={[Ee]:"sliccy.now","sliccy.ai":"sliccy.now","slicc-tray-hub-staging.minivelos.workers.dev":"sliccy.dev","localhost:8787":"localhost:8787"};var Re=["ghp_","gho_","ghu_","ghs_","ghr_","github_pat_","sk-","pk-","xoxb-","xoxp-","xoxa-","xoxs-","AKIA","ABIA","ACCA","ASIA","sk-ant-","Bearer "],dt=[...Re].sort((e,t)=>t.length-e.length);var Me=["canonical-agent-history-unavailable","tool-data-may-be-truncated","model-metadata-unavailable","scoop-history-unavailable","attachment-file-missing","attachment-association-unavailable","complete-snapshot-unavailable"];var It=new Set(Me);var Ft=[{category:"jwt",source:String.raw`ey[A-Za-z0-9_-]{4,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+`,flags:"g"},{category:"private-key",source:"-----BEGIN [A-Z ]* PRIVATE KEY-----"+String.raw`[\s\S]*?`+"-----END [A-Z ]* PRIVATE KEY-----",flags:"g"},{category:"bearer-token",source:"Bearer [A-Za-z0-9._~+/=!-]+",flags:"gi"},{category:"api-key",source:"(?:sk-(?:live|test|prod|proj)-[A-Za-z0-9]{8,}|sk-ant-[A-Za-z0-9-]{8,}|xoxb-[A-Za-z0-9-]{10,}|xoxp-[A-Za-z0-9-]{10,}|AKIA[A-Z0-9]{16}|ghp_[A-Za-z0-9]{36}|hf_[A-Za-z0-9]{34})",flags:"g"},{category:"password",source:String.raw`\b(?:password|passwd|token|secret|api_key)\s*[=:]\s*\S+`,flags:"gi"}];var Ot=16*1024;var Dt=64*1024,Pt=32*1024;var _e="slicc-sync-fs-";function q(e){return _e+e}var H="sync-fs-nonce",V="sync-fs-need-nonce",E="/__slicc/fs-sync/";var R="/__slicc/exec-sync",N="x-slicc-fs-token",S="x-slicc-fs-errno",m="x-slicc-fs",M="x-slicc-fs-no-responder",j="sync-fs-req",Y="sync-fs-ack",G="sync-fs-res",W=25e3,z=2e3,K=12e4,F=6e5,X=2e3;function U(e){if(!e)return{};let t={};for(let[r,n]of Object.entries(e)){let s=r.toLowerCase();s==="cookie"?t["X-Proxy-Cookie"]=n:s==="origin"?t["X-Proxy-Origin"]=n:s==="referer"?t["X-Proxy-Referer"]=n:s.startsWith("proxy-")?t[`X-Proxy-${r}`]=n:t[r]=n}return t}function J(e){let t={};for(let[r,n]of Object.entries(e))r.toLowerCase()==="x-proxy-set-cookie"?t["set-cookie"]=n:t[r]=n;return t}var be=new Set([101,103,204,205,304]);function Ae(e){let t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function Q(e){let t,r,n=new Promise((o,a)=>{t=o,r=a}),s=null,i=new ReadableStream({start(o){s=o}}),u=!1,p=!1,g=()=>{try{s?.close()}catch{}},y=o=>{try{s?.error(o)}catch{}},d=o=>{if(u)return;u=!0;let a=new Headers;for(let[k,x]of Object.entries(J(o.headers)))a.set(k,x);let h=be.has(o.status)?null:i;t(new Response(h,{status:o.status,statusText:o.statusText,headers:a}))},l=o=>{p=!0;let a=new Error(o.error);u?y(a):r(a),e.close?.()};return e.onmessage=o=>{let a=o.data;!a||typeof a.type!="string"||p||(a.type==="response-head"?d(a):a.type==="response-chunk"?s?.enqueue(Ae(a.dataBase64)):a.type==="response-end"?(p=!0,g(),e.close?.()):a.type==="response-error"&&l(a))},e.start?.(),{responsePromise:n}}var we=new Set([101,103,204,205,304]);function L(e){let t=we.has(e.status)?null:e.body;return new Response(t,{status:e.status,statusText:e.statusText,headers:e.headers})}var Z="slicc",ee="leader";function te(e){try{let t=new URL(e);return`${t.protocol==="wss:"?"https:":"http:"}//${t.host}`}catch{return null}}var ve="slicc:bridge-config";function re(e,t){if(e?.apiBaseUrl&&e.token)return{apiBaseUrl:e.apiBaseUrl.replace(/\/+$/,""),token:e.token};if(!t)return null;let r;try{r=new URL(t)}catch{return null}let n=r.searchParams.get(I),s=r.searchParams.get(T);if(!n||!s)return null;let i=te(n);return i?{apiBaseUrl:i.replace(/\/+$/,""),token:s}:null}function ne(e,t){if(e?.apiBaseUrl&&e.token)return re(e,null);for(let r of t){let n=re(null,r);if(n)return n}return null}function se(e,t){return t?`${t.apiBaseUrl}${e}`:e}function oe(e,t){let r,n;try{r=new URL(t),n=new URL(e)}catch{return!1}return n.origin===r.origin&&n.pathname.startsWith("/api/")}function ie(e){return!e||typeof e!="object"?!1:e.type===ve}var _=class{byClient=new Map;set(t,r){if(t){if(!r.apiBaseUrl||!r.token){this.byClient.delete(t);return}this.byClient.set(t,{apiBaseUrl:r.apiBaseUrl.replace(/\/+$/,""),token:r.token})}}get(t){return t?this.byClient.get(t)??null:null}delete(t){this.byClient.delete(t)}size(){return this.byClient.size}},Te="slicc:extension-delegate-config",ae="slicc:ext-fetch";function ce(e){return!e||typeof e!="object"?!1:e.type===Te}function O(e){if(!e)return null;let t;try{t=new URL(e)}catch{return null}if(t.searchParams.get(Z)!==ee)return null;let r=t.searchParams.get("ext");return r?{extensionId:r}:null}function ue(e,t){if(e?.extensionId)return{extensionId:e.extensionId};for(let r of t){let n=O(r);if(n)return n}return null}var b=class{byClient=new Map;set(t,r){if(t){if(!r.extensionId){this.byClient.delete(t);return}this.byClient.set(t,{extensionId:r.extensionId})}}get(t){return t?this.byClient.get(t)??null:null}delete(t){this.byClient.delete(t)}size(){return this.byClient.size}},Ie=new Set(["image","font","style","video","audio","track","iframe","object","embed"]);function le(e){return Ie.has(e)}function D(e){let t=e;return t?.type==="window"&&t.frameType==="top-level"}function A(e){return D(e)}function w(e){return e.filter(A)}function de(){let e=[];return{notify(){let t=e;e=[];for(let r of t)r()},wait(t){return new Promise(r=>{let n=!1,s=()=>{n||(n=!0,clearTimeout(i),e=e.filter(u=>u!==s),r())},i=setTimeout(s,t);e.push(s)})}}}var P="exec";function fe(e,t){return typeof e!="number"||!Number.isFinite(e)||e<=0?Math.min(t,F):Math.min(e,F)}var Fe=W,Ue=200,Le=1e4,Oe=new Set(["stat","lstat","readdir","exists"]),De=new Set(["mkdir","rm"]);function Pe(e){return $e(e)?fe(e.timeoutMs,K)+X:Fe}function $e(e){return e.channel===P}function Be(e){switch(e){case"ENOENT":return 404;case"EACCES":return 403;case"EISDIR":case"ENOTDIR":case"EINVAL":return 400;case"EIO":return 503;default:return 500}}async function qe(e){if(e.method!=="POST")return null;let t;try{let i=await e.arrayBuffer();t=JSON.parse(new TextDecoder().decode(new Uint8Array(i)))}catch{return null}if(!t||typeof t!="object")return null;let r=t,n=r.command;return typeof n=="string"||Array.isArray(n)&&n.every(i=>typeof i=="string")?{token:e.headers.get(N)??"",channel:P,command:n,...Array.isArray(r.args)&&r.args.every(i=>typeof i=="string")?{args:r.args}:{},...typeof r.stdin=="string"?{stdin:r.stdin}:{},...typeof r.timeoutMs=="number"?{timeoutMs:r.timeoutMs}:{}}:null}async function pe(e){let t=new URL(e.url);if(t.pathname===R)return qe(e);if(!t.pathname.startsWith(E))return null;let r=t.pathname.slice(E.length-1),n;try{n=r.split("/").map(decodeURIComponent).join("/")}catch{return null}let s=e.headers.get(N)??"",i=t.searchParams.get("op");if(e.method==="POST"){if(i&&De.has(i))return{token:s,op:i,path:n};let u=await e.arrayBuffer();return{token:s,op:"write",path:n,body:new Uint8Array(u)}}return i&&Oe.has(i)?{token:s,op:i,path:n}:{token:s,op:"read",path:n}}function He(e){if(!e.ok){let r=e.errno??"EIO";return new Response(e.message??r,{status:Be(r),headers:{[S]:r,[m]:"1"}})}if(e.kind==="json")return new Response(JSON.stringify(e.json??null),{status:200,headers:{"content-type":"application/json",[m]:"1"}});let t=e.kind==="bytes"?new Uint8Array(e.bytes):new Uint8Array(0);return new Response(t,{status:200,headers:{"content-type":"application/octet-stream",[m]:"1"}})}function ge(e,t,r={}){let n=r.timeoutMs??Pe(t),s=r.retryIntervalMs??Ue,i=Math.min(r.noResponderMs??Le,n),u=crypto.randomUUID();return new Promise(p=>{let g=!1,y=!1,d,l,o,a=()=>{for(let c of e)c.removeEventListener("message",k);d&&clearInterval(d),l&&clearTimeout(l),o&&clearTimeout(o)},h=c=>{y||(y=!0,a(),p(c))},k=c=>{let f=c.data;if(!(!f||f.id!==u)){if(f.type===Y){g=!0,d&&clearInterval(d),o&&clearTimeout(o);return}f.type===G&&h(He(f))}};for(let c of e)c.addEventListener("message",k);let x=()=>{for(let c of e)c.postMessage({type:j,id:u,...t})};x(),d=setInterval(()=>{g||x()},s),o=setTimeout(()=>{g||h(new Response("sync-fs bridge: no responder",{status:503,headers:{[S]:"EIO",[m]:"1",[M]:"1"}}))},i),l=setTimeout(()=>{h(new Response("sync-fs bridge timeout",{status:503,headers:{[S]:"EIO",[m]:"1"}}))},n)})}var Ve="/api/fetch-proxy",C="x-bypass-llm-proxy",Se=new _,ke=new b,je=32*1024*1024;self.importScripts("/preview-sw.js");self.addEventListener("install",e=>{e.waitUntil(self.skipWaiting())});self.addEventListener("activate",e=>{e.waitUntil(self.clients.claim())});self.addEventListener("message",e=>{let t=e.source;if(!t||!("id"in t)||typeof t.id!="string")return;if(ie(e.data)&&A(t)){Se.set(t.id,{apiBaseUrl:e.data.apiBaseUrl,token:e.data.token});return}if(ce(e.data)&&A(t)){ke.set(t.id,{extensionId:e.data.extensionId});return}let r=e.data;if(r?.type===H&&typeof r.nonce=="string"){D(t)&&Ye(r.nonce);return}});self.addEventListener("fetch",e=>{let t=e.request;if(t.headers.get(C)==="1"||le(t.destination))return;let r;try{r=new URL(t.url)}catch{return}r.origin!==self.location.origin&&(r.protocol!=="http:"&&r.protocol!=="https:"||e.respondWith(Ge(t,e.clientId||null)))});var $=new Map,xe=de();function me(){return[...$.values()]}function Ye(e){$.has(e)||($.set(e,new BroadcastChannel(q(e))),xe.notify())}async function ye(){let e=await self.clients.matchAll({type:"window"}),t={type:V};for(let r of e)r.postMessage(t)}self.addEventListener("fetch",e=>{let t=new URL(e.request.url);t.origin===self.location.origin&&(!t.pathname.startsWith(E)&&t.pathname!==R||e.respondWith((async()=>{let r=await pe(e.request);if(!r)return new Response("sync bridge: malformed request",{status:400,headers:{[S]:"EINVAL",[m]:"1"}});let n=me();if(n.length===0&&(ye(),await xe.wait(z),n=me(),n.length===0))return new Response("sync-fs bridge not ready",{status:503,headers:{[S]:"EIO",[m]:"1"}});let s=await ge(n,r);return s.headers.get(M)==="1"&&ye(),s})()))});async function Ge(e,t){let r=e.url,n={};e.headers.forEach((c,f)=>{f.toLowerCase()!==C&&(n[f]=c)});let s=U(n),i=new Headers;for(let[c,f]of Object.entries(s))i.set(c,f);i.set("X-Target-URL",r);let u=Se.get(t),p=ke.get(t),g=await We(t),y=u||p?[]:await ze(),d=[g,...y],l=ue(p,d);if(l){let c=await Ke();if(c)return Je(e,l,c,r)}let o=ne(u,d);if(o&&oe(e.url,o.apiBaseUrl)){let c=new Headers(e.headers);c.set(C,"1");let f={method:e.method,headers:c,cache:"no-store",credentials:e.credentials,redirect:"manual",signal:e.signal,body:await he(e)};return L(await fetch(e.url,f))}o&&i.set(B,o.token);let a=se(Ve,o),h=await he(e),k={method:e.method,headers:i,cache:"no-store",credentials:"omit",redirect:"manual",signal:e.signal,body:h},x=await fetch(a,k);return L(x)}async function he(e){if(e.method==="GET"||e.method==="HEAD")return;let t=await e.arrayBuffer();return t.byteLength>0?t:void 0}async function We(e){if(!e)return null;try{let t=await self.clients.get(e);return w(t?[t]:[])[0]?.url??null}catch{return null}}async function ze(){try{let e=await self.clients.matchAll({type:"window",includeUncontrolled:!0});return w(e).map(t=>t.url).filter(t=>!!t)}catch{return[]}}async function Ke(){try{let e=w(await self.clients.matchAll({type:"window",includeUncontrolled:!0}));return e.length===0?null:e.find(r=>O(r.url)!==null)??e[0]}catch{return null}}function Xe(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}async function Je(e,t,r,n){let s={};e.headers.forEach((l,o)=>{o.toLowerCase()!==C&&(s[o]=l)});let i=U(s),u,p=!1;if(e.method!=="GET"&&e.method!=="HEAD"){let l=await e.arrayBuffer();l.byteLength>je?p=!0:l.byteLength>0&&(u=Xe(new Uint8Array(l)))}let g=new MessageChannel,{responsePromise:y}=Q(g.port1),d={type:ae,requestId:Qe(),extensionId:t.extensionId,request:{url:n,method:e.method,headers:i,bodyBase64:u,requestBodyTooLarge:p}};return r.postMessage(d,[g.port2]),y}function Qe(){let e=globalThis.crypto;return e&&typeof e.randomUUID=="function"?e.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2)}`}})();
1
+ "use strict";(()=>{var v="https://www.sliccy.ai";var T="bridgeToken",I="bridge",q="X-Bridge-Token";var Ee=new URL(v).hostname,at={[Ee]:"sliccy.now","sliccy.ai":"sliccy.now","slicc-tray-hub-staging.minivelos.workers.dev":"sliccy.dev","localhost:8787":"localhost:8787"};var Re=["ghp_","gho_","ghu_","ghs_","ghr_","github_pat_","sk-","pk-","xoxb-","xoxp-","xoxa-","xoxs-","AKIA","ABIA","ACCA","ASIA","sk-ant-","Bearer "],dt=[...Re].sort((e,t)=>t.length-e.length);var Me=["canonical-agent-history-unavailable","tool-data-may-be-truncated","model-metadata-unavailable","scoop-history-unavailable","attachment-file-missing","attachment-association-unavailable","complete-snapshot-unavailable"];var It=new Set(Me);var Ft=[{category:"jwt",source:String.raw`ey[A-Za-z0-9_-]{4,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+`,flags:"g"},{category:"private-key",source:"-----BEGIN [A-Z ]* PRIVATE KEY-----"+String.raw`[\s\S]*?`+"-----END [A-Z ]* PRIVATE KEY-----",flags:"g"},{category:"bearer-token",source:"Bearer [A-Za-z0-9._~+/=!-]+",flags:"gi"},{category:"api-key",source:"(?:sk-(?:live|test|prod|proj)-[A-Za-z0-9]{8,}|sk-ant-[A-Za-z0-9-]{8,}|xoxb-[A-Za-z0-9-]{10,}|xoxp-[A-Za-z0-9-]{10,}|AKIA[A-Z0-9]{16}|ghp_[A-Za-z0-9]{36}|hf_[A-Za-z0-9]{34})",flags:"g"},{category:"password",source:String.raw`\b(?:password|passwd|token|secret|api_key)\s*[=:]\s*\S+`,flags:"gi"}];var Ot=16*1024;var Pt=64*1024,Dt=32*1024;var _e="slicc-sync-fs-";function B(e){return _e+e}var H="sync-fs-nonce",V="sync-fs-need-nonce",E="/__slicc/fs-sync/";var R="/__slicc/exec-sync",N="x-slicc-fs-token",S="x-slicc-fs-errno",m="x-slicc-fs",M="x-slicc-fs-no-responder",j="sync-fs-req",Y="sync-fs-ack",W="sync-fs-res",G=25e3,z=2e3,K=12e4,F=6e5,X=2e3;function U(e){if(!e)return{};let t={};for(let[r,n]of Object.entries(e)){let s=r.toLowerCase();s==="cookie"?t["X-Proxy-Cookie"]=n:s==="origin"?t["X-Proxy-Origin"]=n:s==="referer"?t["X-Proxy-Referer"]=n:s.startsWith("proxy-")?t[`X-Proxy-${r}`]=n:t[r]=n}return t}function J(e){let t={};for(let[r,n]of Object.entries(e))r.toLowerCase()==="x-proxy-set-cookie"?t["set-cookie"]=n:t[r]=n;return t}var be=new Set([101,103,204,205,304]);function Ae(e){let t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function Q(e){let t,r,n=new Promise((o,a)=>{t=o,r=a}),s=null,i=new ReadableStream({start(o){s=o}}),u=!1,p=!1,g=()=>{try{s?.close()}catch{}},y=o=>{try{s?.error(o)}catch{}},d=o=>{if(u)return;u=!0;let a=new Headers;for(let[k,x]of Object.entries(J(o.headers)))a.set(k,x);let h=be.has(o.status)?null:i;t(new Response(h,{status:o.status,statusText:o.statusText,headers:a}))},l=o=>{p=!0;let a=new Error(o.error);u?y(a):r(a),e.close?.()};return e.onmessage=o=>{let a=o.data;!a||typeof a.type!="string"||p||(a.type==="response-head"?d(a):a.type==="response-chunk"?s?.enqueue(Ae(a.dataBase64)):a.type==="response-end"?(p=!0,g(),e.close?.()):a.type==="response-error"&&l(a))},e.start?.(),{responsePromise:n}}var we=new Set([101,103,204,205,304]);function L(e){let t=we.has(e.status)?null:e.body;return new Response(t,{status:e.status,statusText:e.statusText,headers:e.headers})}var Z="slicc",ee="leader";function te(e){try{let t=new URL(e);return`${t.protocol==="wss:"?"https:":"http:"}//${t.host}`}catch{return null}}var ve="slicc:bridge-config";function re(e,t){if(e?.apiBaseUrl&&e.token)return{apiBaseUrl:e.apiBaseUrl.replace(/\/+$/,""),token:e.token};if(!t)return null;let r;try{r=new URL(t)}catch{return null}let n=r.searchParams.get(I),s=r.searchParams.get(T);if(!n||!s)return null;let i=te(n);return i?{apiBaseUrl:i.replace(/\/+$/,""),token:s}:null}function ne(e,t){if(e?.apiBaseUrl&&e.token)return re(e,null);for(let r of t){let n=re(null,r);if(n)return n}return null}function se(e,t){return t?`${t.apiBaseUrl}${e}`:e}function oe(e,t){let r,n;try{r=new URL(t),n=new URL(e)}catch{return!1}return n.origin===r.origin&&n.pathname.startsWith("/api/")}function ie(e){return!e||typeof e!="object"?!1:e.type===ve}var _=class{byClient=new Map;set(t,r){if(t){if(!r.apiBaseUrl||!r.token){this.byClient.delete(t);return}this.byClient.set(t,{apiBaseUrl:r.apiBaseUrl.replace(/\/+$/,""),token:r.token})}}get(t){return t?this.byClient.get(t)??null:null}delete(t){this.byClient.delete(t)}size(){return this.byClient.size}},Te="slicc:extension-delegate-config",ae="slicc:ext-fetch";function ce(e){return!e||typeof e!="object"?!1:e.type===Te}function O(e){if(!e)return null;let t;try{t=new URL(e)}catch{return null}if(t.searchParams.get(Z)!==ee)return null;let r=t.searchParams.get("ext");return r?{extensionId:r}:null}function ue(e,t){if(e?.extensionId)return{extensionId:e.extensionId};for(let r of t){let n=O(r);if(n)return n}return null}var b=class{byClient=new Map;set(t,r){if(t){if(!r.extensionId){this.byClient.delete(t);return}this.byClient.set(t,{extensionId:r.extensionId})}}get(t){return t?this.byClient.get(t)??null:null}delete(t){this.byClient.delete(t)}size(){return this.byClient.size}},Ie=new Set(["image","font","style","video","audio","track","iframe","object","embed"]);function le(e){return Ie.has(e)}function P(e){let t=e;return t?.type==="window"&&t.frameType==="top-level"}function A(e){return P(e)}function w(e){return e.filter(A)}function de(){let e=[];return{notify(){let t=e;e=[];for(let r of t)r()},wait(t){return new Promise(r=>{let n=!1,s=()=>{n||(n=!0,clearTimeout(i),e=e.filter(u=>u!==s),r())},i=setTimeout(s,t);e.push(s)})}}}var D="exec";function fe(e,t){return typeof e!="number"||!Number.isFinite(e)||e<=0?Math.min(t,F):Math.min(e,F)}var Fe=G,Ue=200,Le=1e4,Oe=new Set(["stat","lstat","readdir","exists"]),Pe=new Set(["mkdir","rm"]);function De(e){return $e(e)?fe(e.timeoutMs,K)+X:Fe}function $e(e){return e.channel===D}function qe(e){switch(e){case"ENOENT":return 404;case"EACCES":return 403;case"EISDIR":case"ENOTDIR":case"EINVAL":return 400;case"EIO":return 503;default:return 500}}async function Be(e){if(e.method!=="POST")return null;let t;try{let i=await e.arrayBuffer();t=JSON.parse(new TextDecoder().decode(new Uint8Array(i)))}catch{return null}if(!t||typeof t!="object")return null;let r=t,n=r.command;return typeof n=="string"||Array.isArray(n)&&n.every(i=>typeof i=="string")?{token:e.headers.get(N)??"",channel:D,command:n,...Array.isArray(r.args)&&r.args.every(i=>typeof i=="string")?{args:r.args}:{},...typeof r.stdin=="string"?{stdin:r.stdin}:{},...typeof r.timeoutMs=="number"?{timeoutMs:r.timeoutMs}:{}}:null}async function pe(e){let t=new URL(e.url);if(t.pathname===R)return Be(e);if(!t.pathname.startsWith(E))return null;let r=t.pathname.slice(E.length-1),n;try{n=r.split("/").map(decodeURIComponent).join("/")}catch{return null}let s=e.headers.get(N)??"",i=t.searchParams.get("op");if(e.method==="POST"){if(i&&Pe.has(i))return{token:s,op:i,path:n};let u=await e.arrayBuffer();return{token:s,op:"write",path:n,body:new Uint8Array(u)}}return i&&Oe.has(i)?{token:s,op:i,path:n}:{token:s,op:"read",path:n}}function He(e){if(!e.ok){let r=e.errno??"EIO";return new Response(e.message??r,{status:qe(r),headers:{[S]:r,[m]:"1"}})}if(e.kind==="json")return new Response(JSON.stringify(e.json??null),{status:200,headers:{"content-type":"application/json",[m]:"1"}});let t=e.kind==="bytes"?new Uint8Array(e.bytes):new Uint8Array(0);return new Response(t,{status:200,headers:{"content-type":"application/octet-stream",[m]:"1"}})}function ge(e,t,r={}){let n=r.timeoutMs??De(t),s=r.retryIntervalMs??Ue,i=Math.min(r.noResponderMs??Le,n),u=crypto.randomUUID();return new Promise(p=>{let g=!1,y=!1,d,l,o,a=()=>{for(let c of e)c.removeEventListener("message",k);d&&clearInterval(d),l&&clearTimeout(l),o&&clearTimeout(o)},h=c=>{y||(y=!0,a(),p(c))},k=c=>{let f=c.data;if(!(!f||f.id!==u)){if(f.type===Y){g=!0,d&&clearInterval(d),o&&clearTimeout(o);return}f.type===W&&h(He(f))}};for(let c of e)c.addEventListener("message",k);let x=()=>{for(let c of e)c.postMessage({type:j,id:u,...t})};x(),d=setInterval(()=>{g||x()},s),o=setTimeout(()=>{g||h(new Response("sync-fs bridge: no responder",{status:503,headers:{[S]:"EIO",[m]:"1",[M]:"1"}}))},i),l=setTimeout(()=>{h(new Response("sync-fs bridge timeout",{status:503,headers:{[S]:"EIO",[m]:"1"}}))},n)})}var Ve="/api/fetch-proxy",C="x-bypass-llm-proxy",Se=new _,ke=new b,je=32*1024*1024;self.importScripts("/preview-sw.js");self.addEventListener("install",e=>{e.waitUntil(self.skipWaiting())});self.addEventListener("activate",e=>{e.waitUntil(self.clients.claim())});self.addEventListener("message",e=>{let t=e.source;if(!t||!("id"in t)||typeof t.id!="string")return;if(ie(e.data)&&A(t)){Se.set(t.id,{apiBaseUrl:e.data.apiBaseUrl,token:e.data.token});return}if(ce(e.data)&&A(t)){ke.set(t.id,{extensionId:e.data.extensionId});return}let r=e.data;if(r?.type===H&&typeof r.nonce=="string"){P(t)&&Ye(r.nonce);return}});self.addEventListener("fetch",e=>{let t=e.request;if(t.headers.get(C)==="1"||le(t.destination))return;let r;try{r=new URL(t.url)}catch{return}r.origin!==self.location.origin&&(r.protocol!=="http:"&&r.protocol!=="https:"||e.respondWith(We(t,e.clientId||null)))});var $=new Map,xe=de();function me(){return[...$.values()]}function Ye(e){$.has(e)||($.set(e,new BroadcastChannel(B(e))),xe.notify())}async function ye(){let e=await self.clients.matchAll({type:"window"}),t={type:V};for(let r of e)r.postMessage(t)}self.addEventListener("fetch",e=>{let t=new URL(e.request.url);t.origin===self.location.origin&&(!t.pathname.startsWith(E)&&t.pathname!==R||e.respondWith((async()=>{let r=await pe(e.request);if(!r)return new Response("sync bridge: malformed request",{status:400,headers:{[S]:"EINVAL",[m]:"1"}});let n=me();if(n.length===0&&(ye(),await xe.wait(z),n=me(),n.length===0))return new Response("sync-fs bridge not ready",{status:503,headers:{[S]:"EIO",[m]:"1"}});let s=await ge(n,r);return s.headers.get(M)==="1"&&ye(),s})()))});async function We(e,t){let r=e.url,n={};e.headers.forEach((c,f)=>{f.toLowerCase()!==C&&(n[f]=c)});let s=U(n),i=new Headers;for(let[c,f]of Object.entries(s))i.set(c,f);i.set("X-Target-URL",r);let u=Se.get(t),p=ke.get(t),g=await Ge(t),y=u||p?[]:await ze(),d=[g,...y],l=ue(p,d);if(l){let c=await Ke();if(c)return Je(e,l,c,r)}let o=ne(u,d);if(o&&oe(e.url,o.apiBaseUrl)){let c=new Headers(e.headers);c.set(C,"1");let f={method:e.method,headers:c,cache:"no-store",credentials:e.credentials,redirect:"manual",signal:e.signal,body:await he(e)};return L(await fetch(e.url,f))}o&&i.set(q,o.token);let a=se(Ve,o),h=await he(e),k={method:e.method,headers:i,cache:"no-store",credentials:"omit",redirect:"manual",signal:e.signal,body:h},x=await fetch(a,k);return L(x)}async function he(e){if(e.method==="GET"||e.method==="HEAD")return;let t=await e.arrayBuffer();return t.byteLength>0?t:void 0}async function Ge(e){if(!e)return null;try{let t=await self.clients.get(e);return w(t?[t]:[])[0]?.url??null}catch{return null}}async function ze(){try{let e=await self.clients.matchAll({type:"window",includeUncontrolled:!0});return w(e).map(t=>t.url).filter(t=>!!t)}catch{return[]}}async function Ke(){try{let e=w(await self.clients.matchAll({type:"window",includeUncontrolled:!0}));return e.length===0?null:e.find(r=>O(r.url)!==null)??e[0]}catch{return null}}function Xe(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}async function Je(e,t,r,n){let s={};e.headers.forEach((l,o)=>{o.toLowerCase()!==C&&(s[o]=l)});let i=U(s),u,p=!1;if(e.method!=="GET"&&e.method!=="HEAD"){let l=await e.arrayBuffer();l.byteLength>je?p=!0:l.byteLength>0&&(u=Xe(new Uint8Array(l)))}let g=new MessageChannel,{responsePromise:y}=Q(g.port1),d={type:ae,requestId:Qe(),extensionId:t.extensionId,request:{url:n,method:e.method,headers:i,bodyBase64:u,requestBodyTooLarge:p}};return r.postMessage(d,[g.port2]),y}function Qe(){let e=globalThis.crypto;return e&&typeof e.randomUUID=="function"?e.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2)}`}})();
@@ -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-Br8-CIKL.js"></script>
8
+ <script type="module" crossorigin src="/assets/main-CjVUpZQF.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/modulepreload-polyfill-P2Xu9kJm.js">
10
10
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-Dd_uD5pT.js">
11
11
  <link rel="modulepreload" crossorigin href="/assets/preload-helper-Czpn1I53.js">
@@ -30,21 +30,21 @@
30
30
  <link rel="modulepreload" crossorigin href="/assets/secrets-bridge-client-DCQ44RyR.js">
31
31
  <link rel="modulepreload" crossorigin href="/assets/image-markers-BXtVm4og.js">
32
32
  <link rel="modulepreload" crossorigin href="/assets/tool-ui-DfXu6quJ.js">
33
- <link rel="modulepreload" crossorigin href="/assets/providers-Czeq-PzU.js">
33
+ <link rel="modulepreload" crossorigin href="/assets/providers-DePjGjI9.js">
34
34
  <link rel="modulepreload" crossorigin href="/assets/panel-rpc-B3MSVImO.js">
35
35
  <link rel="modulepreload" crossorigin href="/assets/bedrock-camp-compat-CgBMwna8.js">
36
- <link rel="modulepreload" crossorigin href="/assets/account-store-o9kbxYNP.js">
36
+ <link rel="modulepreload" crossorigin href="/assets/account-store-PGhT8u8K.js">
37
37
  <link rel="modulepreload" crossorigin href="/assets/runtime-env-CgsZ7LTp.js">
38
38
  <link rel="modulepreload" crossorigin href="/assets/messages-BD4p8GuF.js">
39
39
  <link rel="modulepreload" crossorigin href="/assets/tray-runtime-config-D7cmCcHJ.js">
40
- <link rel="modulepreload" crossorigin href="/assets/setup-sudo-hKf18Nz8.js">
41
- <link rel="modulepreload" crossorigin href="/assets/setup-standalone-prelude-CabX_m61.js">
40
+ <link rel="modulepreload" crossorigin href="/assets/setup-sudo-B6DI1Any.js">
41
+ <link rel="modulepreload" crossorigin href="/assets/setup-standalone-prelude-B_CwyTA7.js">
42
42
  <link rel="modulepreload" crossorigin href="/assets/telemetry-BVzuNdvW.js">
43
43
  <link rel="modulepreload" crossorigin href="/assets/feature-flags-ByMXaIc4.js">
44
44
  <link rel="modulepreload" crossorigin href="/assets/tray-follower-status-BAjnN7Ar.js">
45
45
  <link rel="modulepreload" crossorigin href="/assets/clipboard-eqmn97SP.js">
46
46
  <link rel="modulepreload" crossorigin href="/assets/tray-join-url-BIvzbiFR.js">
47
- <link rel="modulepreload" crossorigin href="/assets/provider-settings-C1clUTbw.js">
47
+ <link rel="modulepreload" crossorigin href="/assets/provider-settings-iKaSUXO2.js">
48
48
  </head>
49
49
  <body>
50
50
  <div id="app"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sliccy",
3
- "version": "6.97.0",
3
+ "version": "6.99.0",
4
4
  "description": "Browser-based coding agent with thin CLI server",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -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- Refs are tied to **one tab + one snapshot**. They do not carry across tabs, navigations, or reloads.\n\n## Element Refs\n\nSnapshots assign short ref IDs (`e1`, `e2`, ...) to interactive elements. Use these refs with `click`, `fill`, `dblclick`, `hover`, `select`, `check`, `uncheck`, `drag`, `upload`, `drop`, and `screenshot`.\n\nRefs are invalidated after any state-changing command. Always re-snapshot to get fresh refs.\n\n## Commands\n\nAll commands below that operate on a tab require `--tab=<targetId>`.\n\n### Core\n\n```bash\nplaywright-cli open [url] [--foreground] # Open tab (background by default), returns targetId\nplaywright-cli tab-new [url] [--foreground] # Same as open\nplaywright-cli tab-close --tab=<id> # Close tab\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\nplaywright-cli eval --tab=<id> [--frame=<frameId>] <expression> [--filename=path] # Evaluate JS in a tab/frame, incl. top-level await/return\nplaywright-cli eval-file --tab=<id> [--frame=<frameId>] <vfs-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\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)\nplaywright-cli type --tab=<id> <text> [--submit] # Type into focused element (--submit presses Enter)\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 (optional ref targets hidden inputs)\nplaywright-cli drop --tab=<id> <ref> [--path=<vfs-path>] [--data=<mime/type=value>] # Drop files/data onto element\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\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\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 /tmp/screenshot-<ts>.png\nplaywright-cli screenshot --tab=<id> --filename=page.png # Save to custom path\nplaywright-cli screenshot --tab=<id> e5 # Screenshot specific element\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\n```\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.\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 <path>` — reads an image from the VFS and returns it. Works with PNG, JPEG, GIF, WebP, SVG.\n- `playwright-cli screenshot --tab=<id>` + `open --view <path>` — screenshot a tab, then view it.\n- `screencapture --view screenshot.png` — capture the user's screen via browser screen sharing.\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- `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 --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- `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=/tmp/shot.png` — consider `--max-width` to keep the file small.\n5. `open --view /tmp/shot.png` — now you can see it. 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 (saves binary to file)\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.\n- Screenshots default to `/tmp/screenshot-<timestamp>.png`. Use `--filename=path` to save elsewhere.\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.\n- `state-save` / `state-load` persist auth state (cookies + localStorage) across sessions.\n- `pdf` saves a print-layout PDF; not available in extension mode.\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{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./logger-LESFN7Hj.js";import{a as n,i as r,n as i,r as a,t as o}from"./path-utils-DNJG-zQf.js";import{t as s}from"./backend-local-B6kc_FvN.js";import{t as c}from"./types-idfTVsM8.js";import{a as l,i as u,n as d,t as f}from"./mount-table-store-DrF_Ifaz.js";import{r as p,t as m}from"./mount-index-CD1UKs2l.js";import{i as h,r as g,t as _}from"./sidecar-repair-CIHuOk7H.js";const v=t(`fs-watcher`);let y=0;function b(e,t){return t===`/`||e===t||e.startsWith(t+`/`)}var x=class{registrations=new Map;watch(e,t,n){let r=`fsw-${++y}`;return this.registrations.set(r,{id:r,basePath:e,filter:t,callback:n}),v.debug(`Watch registered`,{id:r,basePath:e}),()=>{this.registrations.delete(r),v.debug(`Watch unregistered`,{id:r})}}notify(e){if(e.length!==0)for(let[,t]of this.registrations){let n=e.filter(e=>b(e.path,t.basePath)&&t.filter(e.path));if(n.length>0)try{t.callback(n)}catch(e){v.error(`Watch callback error`,{id:t.id,error:e instanceof Error?e.message:String(e)})}}}dispose(){this.registrations.clear(),v.debug(`All watchers disposed`)}get size(){return this.registrations.size}};const S=`/dev/null`,C=new Set([S]);function w(e){return C.has(e)}const T={[S]:{stat:()=>({type:`file`,size:0,mtime:0,ctime:0}),read:e=>(e?.encoding??`utf-8`)===`utf-8`?``:new Uint8Array,readText:()=>``,write:()=>{}}},E=[`/tmp/`];var D=class{vfs;allowedPrefixes;readOnlyPrefixes;readGrantPatterns=[];writeEnforcement;constructor(e,t,n=[],r=`hard`){this.vfs=e;let a=e=>{let t=i(e);return t.endsWith(`/`)?t:t+`/`};this.allowedPrefixes=t.map(a),this.readOnlyPrefixes=n.map(a),this.writeEnforcement=r}getAllPrefixes(){let e=this.vfs.listMounts().map(e=>e.endsWith(`/`)?e:e+`/`);return[...this.allowedPrefixes,...this.readOnlyPrefixes,...e,...E]}setReadGrants(e){this.readGrantPatterns=[];for(let t of new Set(e))this.addReadGrant(t)}addReadGrant(e){let t=e.split(`/`),n=[];for(let e=1;e<t.length;e++)n.push(a(t.slice(0,e).join(`/`)||`/`));this.readGrantPatterns.push({pattern:e,regex:a(e),ancestorRegexes:n})}matchesReadGrant(e){return this.readGrantPatterns.some(t=>t.regex.test(e))}leadsToReadGrant(e){return this.readGrantPatterns.some(t=>t.ancestorRegexes.some(t=>t.test(e)))}isAllowed(e){let t=i(e),n=this.getAllPrefixes();return this.matchesReadGrant(t)||this.leadsToReadGrant(t)||n.some(e=>t===e.slice(0,-1)||t.startsWith(e)||t===`/`||e.startsWith(t+`/`))}isAllowedStrict(e){let t=i(e),n=this.getAllPrefixes();return this.matchesReadGrant(t)||n.some(e=>t===e.slice(0,-1)||t.startsWith(e))}isWritable(e){let t=i(e);return[...this.allowedPrefixes,...E].some(e=>t===e.slice(0,-1)||t.startsWith(e))}canWrite(e){return this.isWritable(e)}checkWrite(e){if(this.writeEnforcement!==`sudo-delegated`&&!this.isWritable(e))throw new c(`EACCES`,`permission denied`,i(e))}async resolveAndCheckRead(e){try{let t=await this.vfs.realpath(e);if(!this.isAllowedStrict(t))throw new c(`ENOENT`,`no such file or directory`,i(e));return t}catch(t){throw t instanceof c?t:new c(`ENOENT`,`no such file or directory`,i(e))}}async resolveAndCheckWrite(e){try{let t=await this.vfs.realpath(e);if(!this.isWritable(t)&&!this.isSymlinkEscapeAllowed(t))throw new c(`EACCES`,`permission denied`,i(e));return t}catch(t){throw t instanceof c?t:new c(`EACCES`,`permission denied`,i(e))}}isSymlinkEscapeAllowed(e){return!1}async checkParentRealpathEscape(e){let t=this.vfs.dirname(e),n=this.vfs.basename(e),r;try{r=await this.vfs.realpath(t)}catch(e){if(e instanceof c&&e.code===`EACCES`)throw e;return}let a=r+`/`+n;if(this.isWritable(a))return;let o=i(r)!==i(t);if(!(this.writeEnforcement===`sudo-delegated`&&!o))throw new c(`EACCES`,`permission denied`,i(e))}getUnderlyingFS(){return this.vfs}invalidatePaths(e){this.vfs.invalidatePaths(e)}async flush(){await this.vfs.flush()}isPathUnderMount(e){return this.vfs.isPathUnderMount(e)}async readFile(e,t){let n=T[i(e)];if(n)return n.read(t);if(!this.isAllowedStrict(e))throw new c(`ENOENT`,`no such file or directory`,i(e));let r=await this.resolveAndCheckRead(e);return this.vfs.readFile(r,t)}async readDir(e){if(!this.isAllowed(e))return[];let t=e;if(this.isAllowedStrict(e))try{t=await this.resolveAndCheckRead(e)}catch{return[]}let n=await this.vfs.readDir(t);if(!this.isAllowedStrict(e)){let t=i(e);return n.filter(e=>{let n=t===`/`?`/${e.name}`:`${t}/${e.name}`;return this.isAllowed(n)})}return n}async stat(e){let t=T[i(e)];if(t)return t.stat();if(!this.isAllowed(e))throw new c(`ENOENT`,`no such file or directory`,i(e));if(this.isAllowedStrict(e)){let t=await this.resolveAndCheckRead(e);return this.vfs.stat(t)}return this.vfs.stat(e)}scanPathForSymlinks(e,t){let n=i(e);if(n===`/`)return!1;let r=n.slice(1).split(`/`),a=t?r.length:r.length-1,o=``;for(let e=0;e<a;e++){o=o+`/`+r[e];let t=this.vfs.lstatSync(o);if(t===null)return null;if(t.type===`symlink`)return!0}return!1}statSync(e){let t=T[i(e)];return t?t.stat():!this.isAllowedStrict(e)||this.scanPathForSymlinks(e,!0)!==!1?null:this.vfs.statSync(e)}lstatSync(e){let t=T[i(e)];return t?t.stat():!this.isAllowed(e)||this.scanPathForSymlinks(e,!1)!==!1?null:this.vfs.lstatSync(e)}readDirSync(e){if(!this.isAllowed(e)||this.scanPathForSymlinks(e,!0)!==!1)return null;let t=this.vfs.readDirSync(e);if(t===null)return null;if(this.isAllowedStrict(e))return t;let n=i(e);return t.filter(e=>{let t=n===`/`?`/${e.name}`:`${n}/${e.name}`;return this.isAllowed(t)})}async realpath(e){let t;try{t=await this.vfs.realpath(e)}catch(t){throw t instanceof c?t:new c(`ENOENT`,`no such file or directory`,i(e))}if(!this.isAllowedStrict(t))throw new c(`ENOENT`,`no such file or directory`,i(e));return t}async exists(e){if(T[i(e)])return!0;if(!this.isAllowed(e))return!1;if(this.isAllowedStrict(e))try{await this.resolveAndCheckRead(e)}catch{return!1}return this.vfs.exists(e)}async readTextFile(e){let t=T[i(e)];if(t)return t.readText();if(!this.isAllowedStrict(e))throw new c(`ENOENT`,`no such file or directory`,i(e));let n=await this.resolveAndCheckRead(e);return this.vfs.readTextFile(n)}async*walk(e){if(!this.isAllowed(e))return;let t=e;if(this.isAllowedStrict(e))try{t=await this.resolveAndCheckRead(e)}catch{return}for await(let e of this.vfs.walk(t))this.isAllowed(e)&&(yield e)}async writeFile(e,t,n){let r=T[i(e)];if(r){r.write(t);return}this.checkWrite(e),await this.checkParentRealpathEscape(e);try{(await this.vfs.lstat(e)).type===`symlink`&&await this.resolveAndCheckWrite(e)}catch(e){if(e instanceof c&&e.code===`EACCES`)throw e}return this.vfs.writeFile(e,t,n)}async mkdir(e,t){return this.checkWrite(e),await this.checkParentRealpathEscape(e),this.vfs.mkdir(e,t)}async rm(e,t){this.checkWrite(e);try{(await this.vfs.lstat(e)).type===`symlink`||await this.resolveAndCheckWrite(e)}catch(e){if(e instanceof c&&e.code===`EACCES`)throw e}return this.vfs.rm(e,t)}async rename(e,t){return this.checkWrite(e),this.checkWrite(t),await this.resolveAndCheckWrite(e),await this.checkParentRealpathEscape(t),this.vfs.rename(e,t)}async copyFile(e,t){if(!this.isAllowed(e))throw new c(`ENOENT`,`no such file or directory`,i(e));this.checkWrite(t);let n=await this.resolveAndCheckRead(e);await this.checkParentRealpathEscape(t);try{(await this.vfs.lstat(t)).type===`symlink`&&await this.resolveAndCheckWrite(t)}catch(e){if(e instanceof c&&e.code===`EACCES`)throw e}return this.vfs.copyFile(n,t)}async symlink(e,t){return this.checkWrite(t),await this.checkParentRealpathEscape(t),this.vfs.symlink(e,t)}async readlink(e){if(!this.isAllowedStrict(e))throw new c(`ENOENT`,`no such file or directory`,i(e));let t=await this.vfs.readlink(e),n;if(t.startsWith(`/`))n=i(t);else{let r=this.vfs.dirname(e);n=i(r+`/`+t)}if(!this.isAllowedStrict(n))throw new c(`ENOENT`,`no such file or directory`,i(e));return t}async lstat(e){let t=T[i(e)];if(t)return t.stat();if(!this.isAllowed(e))throw new c(`ENOENT`,`no such file or directory`,i(e));let n=i(e),r=this.vfs.dirname(n),a=this.vfs.basename(n),o;if(r===n)o=r;else try{o=await this.vfs.realpath(r)}catch{throw new c(`ENOENT`,`no such file or directory`,n)}let s=o===`/`?`/${a}`:`${o}/${a}`;if(!this.isAllowed(s))throw new c(`ENOENT`,`no such file or directory`,n);return this.vfs.lstat(s)}watch(e,t,n){if(!this.isAllowed(e))throw new c(`EACCES`,`permission denied`,i(e));let r=this.vfs.getWatcher();if(!r)throw new c(`EINVAL`,`no watcher configured`);return r.watch(i(e),t,n)}dirname(e){return this.vfs.dirname(e)}basename(e){return this.vfs.basename(e)}async mount(e,t,n){return this.checkWrite(e),await this.checkParentRealpathEscape(e),this.vfs.mount(e,t,n)}async unmount(e){return this.checkWrite(e),await this.checkParentRealpathEscape(e),this.vfs.unmount(e)}listMounts(){return this.vfs.listMounts()}getMountIndex(){return this.vfs.getMountIndex()}async refreshMount(e,t){return this.checkWrite(e),this.vfs.refreshMount(e,t)}async dispose(){await this.vfs.dispose()}};function O(e,t){if(e instanceof c){let n=`${e.code}: `,r=e.message;throw r.startsWith(n)&&(r=r.slice(n.length)),e.path&&r.endsWith(` '${e.path}'`)&&(r=r.slice(0,r.length-` '${e.path}'`.length)),new c(e.code,r,t)}throw e}const k=[`ENOENT`,`EEXIST`,`ENOTDIR`,`EISDIR`,`ENOTEMPTY`,`EINVAL`,`EACCES`,`ELOOP`,`EBUSY`,`EFBIG`,`EBADF`,`EIO`];function A(e,t){if(e instanceof c)return e;{let n=e instanceof Error?e.message:String(e);if(n.includes(`maximum size exceeded`)||n.includes(`call stack size exceeded`))return new c(`EIO`,`internal overflow, not storage: ${n} — reload the session`,t)}let n=e?.code;if(typeof n==`string`){let r=n;if(k.includes(r)){let n=e instanceof Error?e.message:String(e);return n.startsWith(`${r}: `)&&(n=n.slice(r.length+2),n=n.replace(/, undefined( '[^']*')?$/,``).replace(/ '[^']*'$/,``)),new c(r,n||r,t)}}let r=e instanceof Error?e.message:String(e);return r.includes(`ENOENT`)?new c(`ENOENT`,`no such file or directory`,t):r.includes(`EEXIST`)?new c(`EEXIST`,`file already exists`,t):r.includes(`ENOTDIR`)?new c(`ENOTDIR`,`not a directory`,t):r.includes(`EISDIR`)?new c(`EISDIR`,`is a directory`,t):r.includes(`ENOTEMPTY`)?new c(`ENOTEMPTY`,`directory not empty`,t):r.includes(`ELOOP`)?new c(`ELOOP`,`too many levels of symbolic links`,t):new c(`EINVAL`,r,t)}function j(e){return e===void 0?`absent`:(e&61440)==16384?`directory`:`file`}function M(e,t){return t===`absent`?!1:e.kind===`missing`||e.kind!==t}function N(e){let t=e?.mode;return typeof t==`number`?t:void 0}function P(e,t,n,r=new Set){let i=new Set(n);if(r.size>0){for(let t of Object.keys(e.entries??{}))for(let e of r)if(t===e||t.startsWith(`${e}/`)){i.add(t);break}}let a=[];for(let n of i){let r=e.entries?.[n],i=t.entries?.[n];if(!r||!i)continue;let o=j(N(r));o!==j(N(i))&&a.push({path:n,ownIsDirectory:o===`directory`})}return a}async function F(e,t,n,r){try{return await e.lstat(t)}catch(e){let t=A(e,r);if(t.code===`ENOENT`&&n)return null;throw t}}async function I(e,t,r){let a;try{a=await e.readlink(t)}catch(e){throw A(e,r)}return a.startsWith(`/`)?i(a):i(o(n(t).dir,a))}async function L(e,t,n,r,i,a){let o=t===`/`?`/${n}`:`${t}/${n}`;for(;;){let t=await F(e,o,r,i);if(t===null||!t.isSymbolicLink())return{resolved:o,hops:a};if(++a>10)throw new c(`ELOOP`,`too many symbolic links encountered`,i);o=await I(e,o,i)}}async function R(e,t,n){let r=i(n);if(t(r))return r;let a=r.split(`/`).filter(Boolean),o=`/`,s=0;for(let t=0;t<a.length;t++){let n=await L(e,o,a[t],t===a.length-1,r,s);o=n.resolved,s=n.hops}return o}async function z(e,t,n){return t(n)?n:R(e,t,n)}function B(e,t,n){return e.size===0||!e.has(n)||!t.isReady(n)?!1:!Array.from(e.keys()).some(e=>e!==n&&e.startsWith(n+`/`))}async function V(e,t){try{return await e(t)}catch{return t}}async function*H(e,t,n,r=0){let a=i(t);if(B(e.mountPoints,e.mountIndex,a)){let t=e.mountIndex.getFiles(a);if(t){for(let e of t)yield e;return}}let o=n??new Set;if(r>64||o.size>=1e5)return;let s=await V(t=>e.realpath(t),a);if(o.has(s))return;o.add(s);let c=await e.readDir(a);for(let t of c)yield*U(e,t,a===`/`?`/${t.name}`:`${a}/${t.name}`,o,r+1)}async function*U(e,t,n,r,i){if(t.type===`file`){yield n;return}if(t.type===`symlink`){yield*W(e,n,r,i);return}yield*H(e,n,r,i)}async function*W(e,t,n,r){try{let i=await e.stat(t);i.type===`file`?yield t:i.type===`directory`&&(yield*H(e,t,n,r))}catch{}}function G(){try{if(typeof globalThis.navigator?.storage?.getDirectory==`function`)return`opfs`}catch{}return`memory`}function K(e,t){switch(e.kind){case`local`:case`proc`:return{kind:`local`,mountId:e.mountId,idbHandleKey:t};case`hostfs`:return{kind:`hostfs`,mountId:e.mountId,hostPath:e.getHostPath()};default:return{kind:e.kind===`s3`?`s3`:e.kind===`aem`?`aem`:`da`,mountId:e.mountId,source:e.source,profile:e.profile??`default`}}}var q=class e{lfs;lfsSync;rawLfs=null;rawLfsSync=null;_ready;_readyResolved=!1;backend;mountPoints=new Map;opfsBackendFs=null;opfsHandle=null;mountRoot=``;internalMounts=new Set;watcher=null;dbName;mountSyncChannel=null;mountIndex=new m;static writeChains=new Map;onRepairProgress;constructor(t,n,r,i,a){if(this.dbName=t,this.onRepairProgress=a,this.backend=r===`opfs`?`opfs`:`memory`,this.lfs=this.makeDeferredLfs(),this.lfsSync=this.makeDeferredLfsSync(),this._ready=this.backend===`opfs`?e.initOpfsBackend(this,i,n===!0):e.initMemoryBackend(this,t,n===!0),this._ready.then(()=>{this._readyResolved=!0},()=>{}),typeof BroadcastChannel<`u`)try{this.mountSyncChannel=new BroadcastChannel(`vfs-mount-sync:${t}`),this.mountSyncChannel.onmessage=e=>{let{type:t,path:n,descriptor:r}=e.data??{};if(t===`mount`&&typeof n==`string`&&r)this.reconstructBackendFromDescriptor(r,n).then(e=>{this.mountPoints.set(n,e),e.kind===`local`&&this.mountIndex.registerMount(n,e.getHandle()),this.watcher?.notify([{type:`modify`,path:n,entryType:`directory`}])}).catch(()=>{});else if(t===`unmount`&&typeof n==`string`){let e=this.mountPoints.get(n);this.mountPoints.delete(n),this.mountIndex.unregisterMount(n),e?.close(),this.watcher?.notify([{type:`modify`,path:n,entryType:`directory`}])}}}catch{}}static async initOpfsBackend(t,n,r){let i=n??await e.acquireOpfsHandle(t.dbName,r);await e.seedOpfsMetadataSidecarIfMissing(i);let[a,{WebAccess:o}]=await Promise.all([import(`./dist-C56QxoYU.js`).then(e=>e.t),import(`./dist-D7yTTAcb.js`)]);await e.ensureRootMount(a);let s=`/__opfs__/${t.dbName}`,c=e.opfsBackends.get(t.dbName);if(c&&r){try{a.umount(s)}catch{}e.opfsBackends.delete(t.dbName),c=void 0}if(!c){let n=()=>a.resolveMountConfig({backend:o,handle:i,metadata:`/.metadata.json`}),{resolveWithSidecarRepair:r,repairOpfsMetadataSidecar:l}=await import(`./sidecar-repair-CIHuOk7H.js`).then(e=>e.n);try{let e=await t.withWriteLock(()=>l(i,t.onRepairProgress));e?.changed&&console.warn(`[virtual-fs] repaired metadata sidecar before mount (#2146)`,{dbName:t.dbName,kindFixed:e.kindFixed,sizesFixed:e.sizesFixed,dropped:e.dropped,inosReassigned:e.inosReassigned,nlinksFixed:e.nlinksFixed,selfEntryDropped:e.selfEntryDropped})}catch{}let u=await r(n,()=>t.withWriteLock(()=>l(i,t.onRepairProgress)),e=>console.warn(`[virtual-fs] repaired poisoned metadata sidecar; retrying mount`,{dbName:t.dbName,kindFixed:e.kindFixed,sizesFixed:e.sizesFixed,dropped:e.dropped,nlinksFixed:e.nlinksFixed,selfEntryDropped:e.selfEntryDropped}));try{a.mount(s,u)}catch{}c={backendFs:u,refs:0,sidecarDirty:{paths:new Set,prefixes:new Set}},e.opfsBackends.set(t.dbName,c)}c.refs+=1,t.opfsBackendFs=c.backendFs.index?c.backendFs:null,t.opfsHandle=i,t.mountRoot=s,t.rawLfs=a.promises,t.rawLfsSync=a}static async initMemoryBackend(t,n,r){let i=await import(`./dist-C56QxoYU.js`).then(e=>e.t);await e.ensureRootMount(i);let a=`/__zenfs__/${n}`,o=e.memoryBackends.get(n);if(o&&r){try{i.umount(a)}catch{}e.memoryBackends.delete(n),o=void 0}o||(o={store:i.InMemory.create({label:n}),refs:0},e.memoryBackends.set(n,o)),o.refs+=1;try{i.mount(a,o.store)}catch{}t.mountRoot=a,t.rawLfs=i.promises,t.rawLfsSync=i,t.opfsBackendFs=null,t.opfsHandle=null}static rootMountReady=null;static memoryBackends=new Map;static opfsBackends=new Map;static async ensureRootMount(t){return e.rootMountReady===null&&(e.rootMountReady=(async()=>{await t.configureSingle({backend:t.InMemory,label:`__vfs_root__`})})()),e.rootMountReady}prefix(e){return this.mountRoot?e===`/`?this.mountRoot:this.mountRoot+e:e}unprefix(e){return!this.mountRoot||!e.startsWith(this.mountRoot)?e:e.slice(this.mountRoot.length)||`/`}makeDeferredLfs(){let e=e=>this.prefix(e),t=e=>this.unprefix(e),n=()=>{if(!this.rawLfs)throw Error(`VirtualFS used before init resolved`);return this.rawLfs};return{readFile:(t,r)=>this._readyResolved?n().readFile(e(t),r):this._ready.then(()=>n().readFile(e(t),r)),writeFile:(t,r,i)=>this._readyResolved?n().writeFile(e(t),r,i):this._ready.then(()=>n().writeFile(e(t),r,i)),readdir:t=>this._readyResolved?n().readdir(e(t)):this._ready.then(()=>n().readdir(e(t))),mkdir:(t,r)=>this._readyResolved?n().mkdir(e(t),r):this._ready.then(()=>n().mkdir(e(t),r)),rmdir:t=>this._readyResolved?n().rmdir(e(t)):this._ready.then(()=>n().rmdir(e(t))),unlink:t=>this._readyResolved?n().unlink(e(t)):this._ready.then(()=>n().unlink(e(t))),rename:(t,r)=>this._readyResolved?n().rename(e(t),e(r)):this._ready.then(()=>n().rename(e(t),e(r))),stat:t=>this._readyResolved?n().stat(e(t)):this._ready.then(()=>n().stat(e(t))),lstat:t=>this._readyResolved?n().lstat(e(t)):this._ready.then(()=>n().lstat(e(t))),symlink:(t,r)=>{let i=t.startsWith(`/`)?e(t):t;return this._readyResolved?n().symlink(i,e(r)):this._ready.then(()=>n().symlink(i,e(r)))},readlink:async r=>(this._readyResolved||await this._ready,t(await n().readlink(e(r)))),truncate:async(t,r)=>{this._readyResolved||await this._ready;let i=n();typeof i.truncate==`function`&&await i.truncate(e(t),r)},realpath:async r=>{this._readyResolved||await this._ready;let i=n();return typeof i.realpath==`function`?t(await i.realpath(e(r))):e(r)}}}makeDeferredLfsSync(){let e=e=>this.prefix(e),t=e=>this.unprefix(e);return{readdirSync:t=>{let n=this.rawLfsSync;return n?.readdirSync?n.readdirSync(e(t)):void 0},statSync:t=>{let n=this.rawLfsSync;return n?.statSync?n.statSync(e(t)):void 0},lstatSync:t=>{let n=this.rawLfsSync;return n?.lstatSync?n.lstatSync(e(t)):void 0},readlinkSync:n=>{let r=this.rawLfsSync;return r?.readlinkSync?t(r.readlinkSync(e(n))):void 0}}}static async seedOpfsMetadataSidecarIfMissing(e){let t=`.metadata.json`;try{await e.getFileHandle(t);return}catch(e){if(e?.name!==`NotFoundError`)throw e}let n=await(await e.getFileHandle(t,{create:!0})).createWritable(),r=JSON.stringify({version:1,maxSize:4294967295,entries:{}});await n.write(r),await n.close()}static async acquireOpfsHandle(e,t){let n=navigator.storage;if(!n?.getDirectory)throw new c(`EINVAL`,`OPFS is not available in this environment`);let r=await n.getDirectory();if(t)try{await r.removeEntry(e,{recursive:!0})}catch{}return r.getDirectoryHandle(e,{create:!0})}static _createSyncForTests(t){return new e(t)}static async create(t){let n=t?.dbName??`browser-fs`,r=t?.wipe===!0,i=t?.backend??G(),a=new e(n,r,i,void 0,t?.onRepairProgress);return await a._ready,r&&await f().catch(()=>{}),a}async flush(){await this.writeOpfsMetadataSidecar()}async writeOpfsMetadataSidecar(){this.backend===`opfs`&&await this.withWriteLock(()=>this.writeOpfsMetadataSidecarUnlocked())}async writeOpfsMetadataSidecarUnlocked(){if(this.backend!==`opfs`)return;let t=this.opfsBackendFs,n=this.opfsHandle;if(!t||!n)return;let r=t.index.toJSON(),i=e.opfsBackends.get(this.dbName)?.sidecarDirty,a=r;if(i){let e=null;try{let t=await n.getFileHandle(`.metadata.json`),r=JSON.parse(await(await t.getFile()).text());r&&typeof r==`object`&&r.entries&&(e=r)}catch{}e&&(await this.auditDirtyKindFlips(r,e,i,n),a=g(e,r,i))}let o=JSON.stringify(h(a)),s=await(await n.getFileHandle(`.metadata.json`,{create:!0})).createWritable();await s.write(o),await s.close(),i&&(i.paths.clear(),i.prefixes.clear())}async auditDirtyKindFlips(e,t,n,r){let i=P(e,t,n.paths,n.prefixes);if(i.length===0)return;let a=_(r),o=this.opfsBackendFs;for(let n of i){let r=await a(n.path).catch(()=>null);if(r!==null&&r.kind!==`missing`&&r.kind===`directory`===n.ownIsDirectory)continue;let i=t.entries?.[n.path];e.entries&&i!==void 0&&(e.entries[n.path]=i);let s=r!==null&&r.kind!==`missing`;s&&(o?.index?.delete(n.path),o?._handles?.delete(n.path)),console.warn(`[virtual-fs] refused to flush in-memory kind flip over sidecar record (#2006)`,{path:n.path,reality:r?.kind??`unverifiable`,evicted:s})}}markSidecarDirty(t,r=`path`){if(this.backend!==`opfs`)return;let a=e.opfsBackends.get(this.dbName)?.sidecarDirty;if(!a)return;let o=i(t);(r===`prefix`?a.prefixes:a.paths).add(o);let{dir:s}=n(o);for(;s!==`/`;)a.paths.add(s),s=n(s).dir}invalidatePaths(e){if(this.backend!==`opfs`||!this.opfsBackendFs)return;let t=this.opfsBackendFs;for(let n of e){let e=i(n);t.index.delete(e),t._handles?.delete(e),this.markSidecarDirty(e)}}async withKindMismatchRetry(e,t){return this.withKindMismatchRetryPaths([e],t)}async withKindMismatchRetryPaths(e,t){try{return await t()}catch(n){let r=n?.code;if(r!==`EISDIR`&&r!==`ENOTDIR`&&r!==`EINVAL`)throw n;for(let n of e)if(await this.reconcileKindMismatch(n).catch(()=>!1))return await t();throw n}}async reconcileKindMismatch(e){if(this.backend!==`opfs`)return!1;let t=this.opfsBackendFs,n=this.opfsHandle;if(!t?.index||!n)return!1;let r=i(e),a=r;try{a=await this.resolveSymlinks(r)}catch{}let o=await _(n)(a),s=j(t.index.get(a)?.mode),c=t._handles?.get(a),l=c?.kind===`directory`?`directory`:c?.kind===`file`?`file`:`absent`,u=M(o,s),d=M(o,l);if(!u&&!d)return!1;if(t.index.delete(a),t._handles?.delete(a),s===`directory`||l===`directory`){let e=`${a}/`;for(let n of[...t.index.keys()])n.startsWith(e)&&t.index.delete(n);if(t._handles)for(let n of[...t._handles.keys()])n.startsWith(e)&&t._handles.delete(n)}return this.markSidecarDirty(a),console.warn(`[virtual-fs] reconciled in-memory kind mismatch (#2006)`,{path:a,reality:o.kind,indexHeld:s,handleHeld:l}),!0}canWrite(e){return!0}setWatcher(e){this.watcher=e}getWatcher(){return this.watcher}async dispose(){if(this.mountSyncChannel?.close(),this.mountSyncChannel=null,this.watcher?.dispose(),this.watcher=null,this.mountIndex.dispose(),await this.writeOpfsMetadataSidecar(),this.mountRoot){let t=this.backend===`opfs`?e.opfsBackends:e.memoryBackends,n=t.get(this.dbName);if(n&&(--n.refs,n.refs<=0)){t.delete(this.dbName);try{(await import(`./dist-C56QxoYU.js`).then(e=>e.t)).umount(this.mountRoot)}catch{}}}}readDirSync(e){let t=i(e);if(this.findMount(t))return null;let n=this.lfsSync;if(typeof n.readdirSync!=`function`||typeof n.lstatSync!=`function`)return null;try{let e=n.readdirSync(t),r=[];for(let i of e){let e=t===`/`?`/${i}`:`${t}/${i}`;try{let t=n.lstatSync(e),a=t.isSymbolicLink()?`symlink`:t.isDirectory()?`directory`:`file`;r.push({name:i,type:a})}catch{}}return r}catch{return null}}statSync(e){let t=i(e);if(this.findMount(t))return null;let r=this.lfsSync;if(typeof r.statSync!=`function`||typeof r.lstatSync!=`function`||typeof r.readlinkSync!=`function`)return null;if(t===`/`)try{let e=r.statSync(t);return{type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs}}catch{return null}let a=t;for(let e=0;e<=10;e++){let e;try{e=r.lstatSync(a)}catch{return null}if(!e.isSymbolicLink())return{type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs};let t;try{t=r.readlinkSync(a)}catch{return null}a=t.startsWith(`/`)?i(t):i(o(n(a).dir,t))}return null}lstatSync(e){let t=i(e);if(this.findMount(t))return null;let n=this.lfsSync;if(typeof n.lstatSync!=`function`)return null;if(t===`/`)return this.statSync(t);try{let e=n.lstatSync(t);if(e.isSymbolicLink()){let r=n.readlinkSync?n.readlinkSync(t):``;return{type:`symlink`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs,isSymlink:!0,symlinkTarget:r}}return{type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs}}catch{return null}}async mount(e,t,r){let a=i(e);if(this.mountPoints.has(a))throw new c(`EEXIST`,`mount point is already mounted`,a);try{if((await this.lstat(a)).type!==`directory`)throw new c(`ENOTDIR`,`mount point must be a directory`,a);if((await this.readDir(a)).length>0)throw new c(`ENOTEMPTY`,`mount point must be empty to avoid shadowing existing files`,a)}catch(e){if(!(e instanceof c)||e.code!==`ENOENT`)throw e}let{dir:o}=n(a);o!==`/`&&await this.mkdir(o,{recursive:!0});try{await this.lfs.mkdir(a)}catch{}if(this.mountPoints.set(a,t),t.kind===`local`){let e=r?.limits??p(r?.env??{});this.mountIndex.registerMount(a,t.getHandle(),e)}let s=K(t,a);try{this.mountSyncChannel?.postMessage({type:`mount`,path:a,descriptor:s})}catch{}if(this.watcher?.notify([{type:`modify`,path:a,entryType:`directory`}]),t.kind!==`hostfs`)try{let e={targetPath:a,descriptor:s,createdAt:Date.now()},n=t.kind===`local`?t.getHandle():void 0;await l(e,n)}catch{}}async unmount(e){let t=i(e),n=this.mountPoints.get(t);this.mountPoints.delete(t),this.mountIndex.unregisterMount(t);try{this.mountSyncChannel?.postMessage({type:`unmount`,path:t})}catch{}this.watcher?.notify([{type:`modify`,path:t,entryType:`directory`}]),await n?.close();try{await u(t)}catch{}}async reconstructBackendFromDescriptor(e,t){switch(e.kind){case`local`:{let t=await d(e.idbHandleKey);if(!t)throw Error(`no handle stored for ${e.idbHandleKey}`);return s.fromHandle(t,{mountId:e.mountId})}case`hostfs`:{let{HostFsMountBackend:n}=await import(`./backend-hostfs-bQQx-S0W.js`);return new n({targetPath:t,hostPath:e.hostPath,mountId:e.mountId})}case`s3`:{let{S3MountBackend:t,RemoteMountCache:n,makeSignedFetchS3:r}=await import(`./mount-BDMPDS2b.js`).then(e=>e.t),i=new n({mountId:e.mountId,ttlMs:3e4});return new t({source:e.source,profile:e.profile,cache:i,mountId:e.mountId,signedFetch:r(e.profile)})}case`da`:{let{DaMountBackend:t,RemoteMountCache:n,makeSignedFetchDa:r}=await import(`./mount-BDMPDS2b.js`).then(e=>e.t),i=new n({mountId:e.mountId,ttlMs:3e4});return new t({source:e.source,profile:e.profile,cache:i,mountId:e.mountId,signedFetch:r()})}case`aem`:{let{AemMountBackend:t,RemoteMountCache:n,makeSignedFetchDa:r}=await import(`./mount-BDMPDS2b.js`).then(e=>e.t),i=new n({mountId:e.mountId,ttlMs:3e4});return new t({source:e.source,profile:e.profile,cache:i,mountId:e.mountId,signedFetch:r()})}}}listMounts(){let e=[];for(let t of this.mountPoints.keys())this.internalMounts.has(t)||e.push(t);return e}listInternalMounts(){return[...this.internalMounts]}listMountPoints(){let e=[];for(let[t,n]of this.mountPoints)this.internalMounts.has(t)||e.push({path:t,kind:n.kind});return e}async mountInternal(e,t){let r=i(e);if(this.mountPoints.has(r))throw new c(`EEXIST`,`mount point is already mounted`,r);let{dir:a}=n(r);a!==`/`&&await this.mkdir(a,{recursive:!0});try{await this.lfs.mkdir(r)}catch{}this.mountPoints.set(r,t),this.internalMounts.add(r),this.watcher?.notify([{type:`modify`,path:r,entryType:`directory`}])}async unmountInternal(e){let t=i(e);if(!this.internalMounts.has(t))throw new c(`ENOENT`,`not an internal mount point`,t);let n=this.mountPoints.get(t);this.mountPoints.delete(t),this.internalMounts.delete(t),this.watcher?.notify([{type:`modify`,path:t,entryType:`directory`}]),await n?.close()}getMountIndex(){return this.mountIndex}async refreshMount(e,t){let n=i(e),r=this.mountPoints.get(n);if(!r)throw new c(`ENOENT`,`not a mount point`,n);let a=await r.refresh(t);return r.kind===`local`&&await this.mountIndex.refreshMount(n,p(t?.env??{})),a}isPathUnderMount(e){for(let t of this.mountPoints.keys())if(e===t||e.startsWith(t+`/`))return!0;return!1}findMount(e){let t=null;for(let[n,r]of this.mountPoints)(e===n||e.startsWith(n+`/`))&&(!t||n.length>t.mountPath.length)&&(t={mountPath:n,backend:r});return t?e===t.mountPath?{path:t.mountPath,backend:t.backend,relParts:[]}:{path:t.mountPath,backend:t.backend,relParts:e.slice(t.mountPath.length+1).split(`/`).filter(Boolean)}:null}async readFile(e,t){return this.withKindMismatchRetry(e,()=>this.readFileInner(e,t))}async readFileInner(e,t){let n=i(e),r=this.findMount(n);if(r){if(r.relParts.length===0)throw new c(`EISDIR`,`is a directory`,n);let e=r.relParts.join(`/`);try{let n=await r.backend.readFile(e);return(t?.encoding??`utf-8`)===`utf-8`?new TextDecoder(`utf-8`).decode(n):n}catch(e){O(e,n)}}let a=await this.resolveSymlinks(n);try{return(t?.encoding??`utf-8`)===`utf-8`?await this.lfs.readFile(a,{encoding:`utf8`}):await this.lfs.readFile(a)}catch(e){throw A(e,n)}}async writeFile(e,t,n){return this.withKindMismatchRetry(e,()=>this.writeFileInner(e,t,n))}async writeFileInner(e,t,r){let a=i(e),o=this.findMount(a);if(o){if(o.relParts.length===0)throw new c(`EISDIR`,`is a directory`,a);let e=o.relParts.join(`/`),n=!1;try{await this.stat(a),n=!0}catch{}let r=typeof t==`string`?new TextEncoder().encode(t):t instanceof Uint8Array?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(t);try{await o.backend.writeFile(e,r)}catch(e){O(e,a)}this.watcher?.notify([{type:n?`modify`:`create`,path:a,entryType:`file`}]),this.mountIndex.notifyWrite(a);return}let s;try{s=await this.resolveSymlinks(a)}catch{s=a}let l=!1;try{await this.lfs.stat(s),l=!0}catch{}let{dir:u}=n(s);await this.withWriteLock(async()=>{this.markSidecarDirty(s),u!==`/`&&await this.mkdirRecursiveUnlocked(u);let e=typeof t==`string`?new TextEncoder().encode(t).byteLength:(t instanceof Uint8Array,t.byteLength);try{await this.lfs.writeFile(s,t)}catch(e){if(u!==`/`&&e instanceof Error&&e.message.includes(`ENOENT`)){await this.mkdirRecursiveUnlocked(u);try{await this.lfs.writeFile(s,t)}catch(e){throw A(e,a)}}else throw A(e,a)}try{await this.lfs.truncate?.(s,e)}catch(e){throw A(e,a)}}),this.watcher?.notify([{type:l?`modify`:`create`,path:s,entryType:`file`}])}async readDir(e){let t=i(e),n=this.findMount(t);return n?this.readDirMounted(t,n):this.readDirLocal(t)}async readDirMounted(e,t){let n=this.mountIndex.getDirectoryEntries(t.path,e);if(n!==void 0){let t=new Map;for(let e of n)t.set(e.name,{name:e.name,type:e.type});return this.addNestedMountEntries(t,e),[...t.values()]}let r=t.relParts.join(`/`)||`/`,i;try{i=await t.backend.readDir(r)}catch(t){O(t,e)}let a=new Map;for(let e of i)a.set(e.name,{name:e.name,type:e.kind===`directory`?`directory`:`file`});return this.addNestedMountEntries(a,e),[...a.values()]}async readDirLocal(e){return this.withKindMismatchRetry(e,()=>this.readDirLocalInner(e))}async readDirLocalInner(e){let t=await this.resolveSymlinks(e);try{let e=await this.lfs.readdir(t),n=[];for(let r of e){let e=await this.statDirEntry(t,r);e&&n.push(e)}return n}catch(t){throw A(t,e)}}async statDirEntry(e,t){let n=e===`/`?`/${t}`:`${e}/${t}`;try{let e=await this.lfs.lstat(n);return e.isSymbolicLink()?{name:t,type:`symlink`}:{name:t,type:e.isDirectory()?`directory`:`file`}}catch{return null}}addNestedMountEntries(e,t){let n=t===`/`?`/`:`${t}/`;for(let r of this.mountPoints.keys()){if(r===t||!r.startsWith(n))continue;let i=r.slice(n.length);!i||i.includes(`/`)||e.has(i)||e.set(i,{name:i,type:`directory`})}}async withWriteLock(t){let n=this.dbName,r,i=new Promise(e=>{r=e}),a=e.writeChains.get(n)??Promise.resolve();e.writeChains.set(n,i),await a;try{let e=globalThis.navigator?.locks;return this.backend!==`opfs`||typeof e?.request!=`function`?await t():await e.request(`slicc-vfs:${n}`,()=>t())}finally{r(),e.writeChains.get(n)===i&&e.writeChains.delete(n)}}async mkdirRecursiveUnlocked(e){let t=e.split(`/`).filter(Boolean),n=``;for(let e of t){n+=`/`+e;try{await this.lfs.mkdir(n)}catch(e){if(e instanceof Error&&!e.message.includes(`EEXIST`))throw A(e,n);try{let e=await this.lfs.lstat(n);if(!e.isDirectory()&&!e.isSymbolicLink())throw new c(`ENOTDIR`,`not a directory`,n)}catch(e){if(e instanceof c&&e.code===`ENOTDIR`)throw e}}}}async mkdir(e,t){let n=i(e);if(n===`/`)return;let r=this.findMount(n);if(r){if(r.relParts.length===0)return;let e=r.relParts.join(`/`),t=await this.exists(n);try{await r.backend.mkdir(e)}catch(e){O(e,n)}t||this.watcher?.notify([{type:`create`,path:n,entryType:`directory`}]);return}t?.recursive?await this.withWriteLock(()=>(this.markSidecarDirty(n),this.mkdirRecursiveUnlocked(n))):(await this.withWriteLock(async()=>{this.markSidecarDirty(n);try{await this.lfs.mkdir(n)}catch(e){throw A(e,n)}}),this.watcher?.notify([{type:`create`,path:n,entryType:`directory`}]))}async rm(e,t){return this.withKindMismatchRetry(i(e),()=>this.rmInner(e,t))}async rmInner(e,t){let n=i(e),r=this.findMount(n);if(r){if(r.relParts.length===0)throw new c(`EINVAL`,`cannot remove a mount point — use unmount`,n);let e;try{e=(await this.stat(n)).type}catch{}let i=r.relParts.join(`/`);try{await r.backend.remove(i,{recursive:t?.recursive})}catch(e){O(e,n)}this.watcher?.notify([{type:`delete`,path:n,entryType:e}]),this.mountIndex.notifyDelete(n);return}try{let e=await this.lfs.lstat(n);await this.withWriteLock(async()=>{e.isSymbolicLink()?await this.lfs.unlink(n):e.isDirectory()?t?.recursive?await this.rmRecursiveUnlocked(n):await this.lfs.rmdir(n):await this.lfs.unlink(n),this.markSidecarDirty(n,`prefix`),await this.writeOpfsMetadataSidecarUnlocked()})}catch(e){throw A(e,n)}this.watcher?.notify([{type:`delete`,path:n}])}async rmRecursiveUnlocked(e){let t=await this.lfs.readdir(e);for(let n of t){let t=e===`/`?`/${n}`:`${e}/${n}`,r=await this.lfs.lstat(t);r.isSymbolicLink()?await this.lfs.unlink(t):r.isDirectory()?await this.rmRecursiveUnlocked(t):await this.lfs.unlink(t)}await this.lfs.rmdir(e)}async stat(e){return this.withKindMismatchRetry(e,()=>this.statInner(e))}async statInner(e){let t=i(e),n=this.findMount(t);if(n){if(n.relParts.length===0)try{let e=await this.lfs.stat(t);return{type:`directory`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs}}catch{return{type:`directory`,size:0,mtime:Date.now(),ctime:Date.now()}}let e=n.relParts.join(`/`);try{let t=await n.backend.stat(e);return{type:t.kind===`directory`?`directory`:`file`,size:t.size,mtime:t.mtime,ctime:t.mtime}}catch(e){O(e,t)}}let r=await this.resolveSymlinks(t);try{let e=await this.lfs.stat(r);return{type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs}}catch(e){throw A(e,t)}}async exists(e){let t=i(e),n=this.findMount(t);if(n){if(n.relParts.length===0)return!0;try{return await this.stat(t),!0}catch{return!1}}try{return await this.stat(t),!0}catch{try{return await this.lfs.lstat(t),!0}catch{return!1}}}async rename(e,t){return this.withKindMismatchRetryPaths([i(e),i(t)],()=>this.renameInner(e,t))}async renameInner(e,t){let n=i(e),r=i(t),a;try{a=(await this.lstat(n)).type}catch{}let o=this.findMount(n);if(o?.backend.rename){let e=this.findMount(r);if(e&&e.backend===o.backend){try{await o.backend.rename(o.relParts.join(`/`),e.relParts.join(`/`))}catch(e){O(e,n)}this.watcher?.notify([{type:`delete`,path:n,entryType:a},{type:`create`,path:r,entryType:a}]),this.mountIndex.notifyRename(n,r);return}}try{await this.withWriteLock(async()=>{this.markSidecarDirty(n,`prefix`),this.markSidecarDirty(r,`prefix`),await this.lfs.rename(n,r),await this.writeOpfsMetadataSidecarUnlocked()})}catch(e){throw A(e,n)}this.watcher?.notify([{type:`delete`,path:n,entryType:a},{type:`create`,path:r,entryType:a}]),this.mountIndex.notifyRename(n,r)}async readTextFile(e){return await this.readFile(e,{encoding:`utf-8`})}async*walk(e,t,n=0){yield*H({mountPoints:this.mountPoints,mountIndex:this.mountIndex,realpath:e=>this.realpath(e),readDir:e=>this.readDir(e),stat:e=>this.stat(e)},e,t,n)}async copyFile(e,t){if((await this.stat(e)).type===`directory`)throw new c(`EISDIR`,`is a directory`,e);let n=await this.readFile(e,{encoding:`binary`});await this.writeFile(t,n)}dirname(e){return n(i(e)).dir}basename(e){return n(i(e)).base}async symlink(e,t){let r=i(t);if(this.findMount(r))throw new c(`EINVAL`,`symlinks not supported on mounted filesystems`,r);let{dir:a}=n(r);await this.withWriteLock(async()=>{a!==`/`&&await this.mkdirRecursiveUnlocked(a);try{await this.lfs.symlink(e,r)}catch(t){if(a!==`/`&&t instanceof Error&&t.message.includes(`ENOENT`)){await this.mkdirRecursiveUnlocked(a);try{await this.lfs.symlink(e,r)}catch(e){throw A(e,r)}}else throw A(t,r)}this.markSidecarDirty(r),await this.writeOpfsMetadataSidecarUnlocked()}),this.watcher?.notify([{type:`create`,path:r,entryType:`symlink`}])}async readlink(e){let t=i(e);try{return await this.lfs.readlink(t)}catch(e){throw A(e,t)}}async lstat(e){let t=i(e);if(this.findMount(t)||t===`/`)return this.stat(t);try{let e=await this.lfs.lstat(t);if(e.isSymbolicLink()){let n=await this.lfs.readlink(t);return{type:`symlink`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs,isSymlink:!0,symlinkTarget:n}}return{type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs}}catch(e){throw A(e,t)}}async realpath(e){return R(this.lfs,e=>this.findMount(e)!==null,e)}resolveSymlinks(e){return z(this.lfs,e=>this.findMount(e)!==null,e)}},J=e({FsError:()=>c,FsWatcher:()=>x,MountIndex:()=>m,RestrictedFS:()=>D,VirtualFS:()=>q,joinPath:()=>o,normalizePath:()=>i,pathSegments:()=>r,resolveVfsBackendFromEnv:()=>G,splitPath:()=>n});export{x as a,w as i,q as n,D as r,J as t};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-Cew647MY.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/safe-buffer-BwTVRVVo.js","assets/dist-_7dnux20.js","assets/sidecar-repair-431vRT2V.js","assets/backend-hostfs-Com-zF5W.js","assets/api-endpoint-GRCyib6X.js","assets/types-idfTVsM8.js","assets/mount-B8ydUbOd.js","assets/preload-helper-Czpn1I53.js","assets/mime-types-ugOWOUZ9.js","assets/base64-DpPqYZJF.js","assets/src-CAWTvdAa.js","assets/proxied-fetch-BGeNrvQ4.js","assets/runtime-env-Dlaokqg1.js","assets/fetch-body-D2PwksUW.js","assets/runtime-env-E-i2SW1s.js","assets/backend-local-1YuE96fx.js","assets/tool-ui-DfXu6quJ.js","assets/logger-DDBAeTLF.js","assets/picker-approval-D89YhXsA.js","assets/html-B_Hg2WOy.js","assets/mount-picker-popup-Bc3ca2Vl.js","assets/logger-BoSvu4mW.js","assets/picker-popup-Bwcnocm6.js","assets/runtime-env-CgsZ7LTp.js","assets/mount-table-store-dY2IfQ5S.js","assets/mount-bridge-client-DZE6sHdr.js","assets/port-bridge-client-BhmNRlRv.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,i as r,n as i,r as a,t as o}from"./path-utils-DNJG-zQf.js";import{t as s}from"./types-idfTVsM8.js";import{t as c}from"./virtual-device-paths-9EXC9iPp.js";import{t as l}from"./backend-local-1YuE96fx.js";import{a as u,i as d,n as f,t as p}from"./mount-table-store-dY2IfQ5S.js";import{i as m,r as h,t as g}from"./sidecar-repair-431vRT2V.js";var _=t(`fs-watcher`),v=0;function y(e,t){return t===`/`||e===t||e.startsWith(t+`/`)}var b=class{registrations=new Map;watch(e,t,n){let r=`fsw-${++v}`;return this.registrations.set(r,{id:r,basePath:e,filter:t,callback:n}),_.debug(`Watch registered`,{id:r,basePath:e}),()=>{this.registrations.delete(r),_.debug(`Watch unregistered`,{id:r})}}notify(e){if(e.length!==0)for(let[,t]of this.registrations){let n=e.filter(e=>y(e.path,t.basePath)&&t.filter(e.path));if(n.length>0)try{t.callback(n)}catch(e){_.error(`Watch callback error`,{id:t.id,error:e instanceof Error?e.message:String(e)})}}}dispose(){this.registrations.clear(),_.debug(`All watchers disposed`)}get size(){return this.registrations.size}},x=t(`mount-index`),S=400,C=2e6,w=`SLICC_MOUNT_INDEX_MAX_DEPTH`,T=`SLICC_MOUNT_INDEX_MAX_ENTRIES`,E=256,D=class extends Error{cause;constructor(e,t){super(e),this.name=`MountIndexAbortError`,this.cause=t}};function O(e){let t=e.map(([e,t])=>`${e}\u0000${t.kind}`).sort(),n=t.length>E?t.slice(0,E):t;return`${t.length}\u0001${n.join(``)}`}async function ee(e,t){let n=e.isSameEntry;if(typeof n!=`function`)return!1;try{return await n.call(e,t)}catch{return!1}}function te(e,t){return e instanceof Map?e.get(t):e[t]}function k(e){let t=e.trim();if(t===``)return;let n=Number(t);if(!(!Number.isInteger(n)||n<=0))return n}function A(e,t,n){let r=te(e,t);if(r===void 0||r.trim()===``)return n;let i=k(r);return i===void 0?(x.warn(`Ignoring invalid ${t}; expected a positive integer, using default`,{value:r,fallback:n}),n):i}function j(e){return{maxDepth:A(e,w,S),maxEntries:A(e,T,C)}}var M=class{mounts=new Map;listeners=new Set;registerMount(e,t,n=j({})){this.mounts.get(e)?.abortController?.abort();let r=new AbortController,i={handle:t,state:{status:`pending`,indexed:0},files:new Set,directories:new Set,abortController:r,limits:n};this.mounts.set(e,i),this.notifyListeners(),this.indexMount(e,i,r.signal)}unregisterMount(e){let t=this.mounts.get(e);t&&(t.abortController?.abort(),this.mounts.delete(e),this.notifyListeners())}async refreshMount(e,t){let n=this.mounts.get(e);if(!n)throw Error(`No mount at ${e}`);n.abortController?.abort();let r=new AbortController;n.abortController=r,n.state={status:`pending`,indexed:0},n.files.clear(),n.directories.clear(),t&&(n.limits=t),this.notifyListeners(),await this.indexMount(e,n,r.signal)}isReady(e){return this.mounts.get(e)?.state.status===`ready`}isAnyIndexing(){for(let e of this.mounts.values())if(e.state.status===`indexing`||e.state.status===`pending`)return!0;return!1}dispose(){for(let e of this.mounts.values())e.abortController?.abort();this.mounts.clear(),this.listeners.clear()}getState(e){return this.mounts.get(e)?.state}getFiles(e,t){let n=this.mounts.get(e);if(n?.state.status!==`ready`)return;if(!t)return[...n.files];let r=[];for(let e of n.files)t(e)&&r.push(e);return r}getDirectoryEntries(e,t){let n=this.mounts.get(e);if(n?.state.status!==`ready`)return;let r=t===`/`?`/`:t+`/`,i=new Map;for(let e of n.files){if(!e.startsWith(r))continue;let t=e.slice(r.length);t.includes(`/`)||i.set(t,`file`)}for(let e of n.directories){if(!e.startsWith(r))continue;let t=e.slice(r.length);t.includes(`/`)||i.set(t,`directory`)}return[...i.entries()].map(([e,t])=>({name:e,type:t}))}hasPath(e,t){let n=this.mounts.get(e);if(n?.state.status===`ready`)return n.files.has(t)||n.directories.has(t)}notifyWrite(e){let t=this.findMountForPath(e);if(!t)return;let n=this.mounts.get(t);if(n?.state.status!==`ready`)return;n.files.add(e);let r=e;for(;r!==t;){let e=r.lastIndexOf(`/`);if(e<=0)break;r=r.slice(0,e)||`/`,r.length>=t.length&&n.directories.add(r)}}notifyDelete(e){let t=this.findMountForPath(e);if(!t)return;let n=this.mounts.get(t);if(n?.state.status!==`ready`)return;n.files.delete(e),n.directories.delete(e);let r=e+`/`;for(let e of n.files)e.startsWith(r)&&n.files.delete(e);for(let e of n.directories)e.startsWith(r)&&n.directories.delete(e)}notifyRename(e,t){let n=this.findMountForPath(e);if(!n)return;let r=this.mounts.get(n);if(r?.state.status===`ready`){if(r.files.has(e)){r.files.delete(e),r.files.add(t);return}if(r.directories.has(e)){r.directories.delete(e),r.directories.add(t);let n=e+`/`,i=t+`/`;for(let e of[...r.files])e.startsWith(n)&&(r.files.delete(e),r.files.add(i+e.slice(n.length)));for(let e of[...r.directories])e.startsWith(n)&&(r.directories.delete(e),r.directories.add(i+e.slice(n.length)))}}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}findMountForPath(e){let t;for(let n of this.mounts.keys())(e===n||e.startsWith(n+`/`))&&(!t||n.length>t.length)&&(t=n);return t}notifyListeners(){for(let e of this.listeners)try{e()}catch{}}async indexMount(e,t,n){t.state={status:`indexing`,indexed:0},this.notifyListeners();try{if(await this.walkHandle(e,t.handle,t,n),n.aborted)return;t.state={status:`ready`,indexed:t.files.size+t.directories.size,total:t.files.size+t.directories.size},t.abortController=null,x.info(`Mount indexed`,{path:e,files:t.files.size,directories:t.directories.size})}catch(r){if(n.aborted)return;let i=r instanceof Error?r.message:String(r),a=r instanceof D?r.cause:`indexing-error`;t.state={status:`error`,indexed:0,error:i,abortCause:a},x.error(`Mount indexing failed`,{path:e,error:i,abortCause:a})}this.notifyListeners()}async walkHandle(e,t,n,r,i=0,a=new Map){if(r.aborted)return;this.enforceWalkBounds(i,n),n.directories.add(e);let o=await this.readChildren(t,r,n);if(r.aborted)return;let s=await this.confirmNoCycle(e,t,o,a),c=this.pushAncestor(a,s,e,t);try{await this.walkChildren(e,o,n,r,i,a)}finally{this.popAncestor(a,s,c)}}enforceWalkBounds(e,t){if(e>t.limits.maxDepth)throw new D(`mount indexing aborted: directory nesting exceeded ${t.limits.maxDepth} levels`,`depth-exceeded`);if(t.directories.size+t.files.size>=t.limits.maxEntries)throw new D(`mount indexing aborted: exceeded ${t.limits.maxEntries} entries`,`entries-exceeded`)}async readChildren(e,t,n){let r=e,i=[];for await(let e of r){if(t.aborted)break;if(n.directories.size+n.files.size+i.length>=n.limits.maxEntries)throw new D(`mount indexing aborted: exceeded ${n.limits.maxEntries} entries`,`entries-exceeded`);i.push(e)}return i}async confirmNoCycle(e,t,n,r){let i=O(n),a=r.get(i);if(a){for(let n of a)if(await ee(n.handle,t))throw new D(`mount indexing aborted: self-referential mount cycle detected at ${e} (re-exposes ${n.path})`,`cycle-detected`)}return i}pushAncestor(e,t,n,r){let i=e.get(t);return i||(i=[],e.set(t,i)),i.push({path:n,handle:r,signature:t}),i}popAncestor(e,t,n){n.pop(),n.length===0&&e.delete(t)}async walkChildren(e,t,n,r,i,a){for(let[o,s]of t){if(r.aborted)return;let t=e===`/`?`/${o}`:`${e}/${o}`;s.kind===`file`?(n.files.add(t),n.state.indexed++):s.kind===`directory`&&await this.walkHandle(t,s,n,r,i+1,a),n.state.indexed%500==0&&(this.notifyListeners(),await new Promise(e=>setTimeout(e,0)))}}},N={[c]:{stat:()=>({type:`file`,size:0,mtime:0,ctime:0}),read:e=>(e?.encoding??`utf-8`)===`utf-8`?``:new Uint8Array,readText:()=>``,write:()=>{}}},P=[`/tmp/`],F=class{vfs;allowedPrefixes;readOnlyPrefixes;readGrantPatterns=[];writeEnforcement;constructor(e,t,n=[],r=`hard`){this.vfs=e;let a=e=>{let t=i(e);return t.endsWith(`/`)?t:t+`/`};this.allowedPrefixes=t.map(a),this.readOnlyPrefixes=n.map(a),this.writeEnforcement=r}getAllPrefixes(){let e=this.vfs.listMounts().map(e=>e.endsWith(`/`)?e:e+`/`);return[...this.allowedPrefixes,...this.readOnlyPrefixes,...e,...P]}setReadGrants(e){this.readGrantPatterns=[];for(let t of new Set(e))this.addReadGrant(t)}addReadGrant(e){let t=e.split(`/`),n=[];for(let e=1;e<t.length;e++)n.push(a(t.slice(0,e).join(`/`)||`/`));this.readGrantPatterns.push({pattern:e,regex:a(e),ancestorRegexes:n})}matchesReadGrant(e){return this.readGrantPatterns.some(t=>t.regex.test(e))}leadsToReadGrant(e){return this.readGrantPatterns.some(t=>t.ancestorRegexes.some(t=>t.test(e)))}isAllowed(e){let t=i(e),n=this.getAllPrefixes();return this.matchesReadGrant(t)||this.leadsToReadGrant(t)||n.some(e=>t===e.slice(0,-1)||t.startsWith(e)||t===`/`||e.startsWith(t+`/`))}isAllowedStrict(e){let t=i(e),n=this.getAllPrefixes();return this.matchesReadGrant(t)||n.some(e=>t===e.slice(0,-1)||t.startsWith(e))}isWritable(e){let t=i(e);return[...this.allowedPrefixes,...P].some(e=>t===e.slice(0,-1)||t.startsWith(e))}canWrite(e){return this.isWritable(e)}checkWrite(e){if(this.writeEnforcement!==`sudo-delegated`&&!this.isWritable(e))throw new s(`EACCES`,`permission denied`,i(e))}async resolveAndCheckRead(e){try{let t=await this.vfs.realpath(e);if(!this.isAllowedStrict(t))throw new s(`ENOENT`,`no such file or directory`,i(e));return t}catch(t){throw t instanceof s?t:new s(`ENOENT`,`no such file or directory`,i(e))}}async resolveAndCheckWrite(e){try{let t=await this.vfs.realpath(e);if(!this.isWritable(t)&&!this.isSymlinkEscapeAllowed(t))throw new s(`EACCES`,`permission denied`,i(e));return t}catch(t){throw t instanceof s?t:new s(`EACCES`,`permission denied`,i(e))}}isSymlinkEscapeAllowed(e){return!1}async checkParentRealpathEscape(e){let t=this.vfs.dirname(e),n=this.vfs.basename(e),r;try{r=await this.vfs.realpath(t)}catch(e){if(e instanceof s&&e.code===`EACCES`)throw e;return}let a=r+`/`+n;if(this.isWritable(a))return;let o=i(r)!==i(t);if(!(this.writeEnforcement===`sudo-delegated`&&!o))throw new s(`EACCES`,`permission denied`,i(e))}getUnderlyingFS(){return this.vfs}invalidatePaths(e){this.vfs.invalidatePaths(e)}async flush(){await this.vfs.flush()}isPathUnderMount(e){return this.vfs.isPathUnderMount(e)}async readFile(e,t){let n=N[i(e)];if(n)return n.read(t);if(!this.isAllowedStrict(e))throw new s(`ENOENT`,`no such file or directory`,i(e));let r=await this.resolveAndCheckRead(e);return this.vfs.readFile(r,t)}async readDir(e){if(!this.isAllowed(e))return[];let t=e;if(this.isAllowedStrict(e))try{t=await this.resolveAndCheckRead(e)}catch{return[]}let n=await this.vfs.readDir(t);if(!this.isAllowedStrict(e)){let t=i(e);return n.filter(e=>{let n=t===`/`?`/${e.name}`:`${t}/${e.name}`;return this.isAllowed(n)})}return n}async stat(e){let t=N[i(e)];if(t)return t.stat();if(!this.isAllowed(e))throw new s(`ENOENT`,`no such file or directory`,i(e));if(this.isAllowedStrict(e)){let t=await this.resolveAndCheckRead(e);return this.vfs.stat(t)}return this.vfs.stat(e)}scanPathForSymlinks(e,t){let n=i(e);if(n===`/`)return!1;let r=n.slice(1).split(`/`),a=t?r.length:r.length-1,o=``;for(let e=0;e<a;e++){o=o+`/`+r[e];let t=this.vfs.lstatSync(o);if(t===null)return null;if(t.type===`symlink`)return!0}return!1}statSync(e){let t=N[i(e)];return t?t.stat():!this.isAllowedStrict(e)||this.scanPathForSymlinks(e,!0)!==!1?null:this.vfs.statSync(e)}lstatSync(e){let t=N[i(e)];return t?t.stat():!this.isAllowed(e)||this.scanPathForSymlinks(e,!1)!==!1?null:this.vfs.lstatSync(e)}readDirSync(e){if(!this.isAllowed(e)||this.scanPathForSymlinks(e,!0)!==!1)return null;let t=this.vfs.readDirSync(e);if(t===null)return null;if(this.isAllowedStrict(e))return t;let n=i(e);return t.filter(e=>{let t=n===`/`?`/${e.name}`:`${n}/${e.name}`;return this.isAllowed(t)})}async realpath(e){let t;try{t=await this.vfs.realpath(e)}catch(t){throw t instanceof s?t:new s(`ENOENT`,`no such file or directory`,i(e))}if(!this.isAllowedStrict(t))throw new s(`ENOENT`,`no such file or directory`,i(e));return t}async exists(e){if(N[i(e)])return!0;if(!this.isAllowed(e))return!1;if(this.isAllowedStrict(e))try{await this.resolveAndCheckRead(e)}catch{return!1}return this.vfs.exists(e)}async readTextFile(e){let t=N[i(e)];if(t)return t.readText();if(!this.isAllowedStrict(e))throw new s(`ENOENT`,`no such file or directory`,i(e));let n=await this.resolveAndCheckRead(e);return this.vfs.readTextFile(n)}async*walk(e){if(!this.isAllowed(e))return;let t=e;if(this.isAllowedStrict(e))try{t=await this.resolveAndCheckRead(e)}catch{return}for await(let e of this.vfs.walk(t))this.isAllowed(e)&&(yield e)}async writeFile(e,t,n){let r=N[i(e)];if(r){r.write(t);return}this.checkWrite(e),await this.checkParentRealpathEscape(e);try{(await this.vfs.lstat(e)).type===`symlink`&&await this.resolveAndCheckWrite(e)}catch(e){if(e instanceof s&&e.code===`EACCES`)throw e}return this.vfs.writeFile(e,t,n)}async mkdir(e,t){return this.checkWrite(e),await this.checkParentRealpathEscape(e),this.vfs.mkdir(e,t)}async rm(e,t){this.checkWrite(e);try{(await this.vfs.lstat(e)).type===`symlink`||await this.resolveAndCheckWrite(e)}catch(e){if(e instanceof s&&e.code===`EACCES`)throw e}return this.vfs.rm(e,t)}async rename(e,t){return this.checkWrite(e),this.checkWrite(t),await this.resolveAndCheckWrite(e),await this.checkParentRealpathEscape(t),this.vfs.rename(e,t)}async copyFile(e,t){if(!this.isAllowed(e))throw new s(`ENOENT`,`no such file or directory`,i(e));this.checkWrite(t);let n=await this.resolveAndCheckRead(e);await this.checkParentRealpathEscape(t);try{(await this.vfs.lstat(t)).type===`symlink`&&await this.resolveAndCheckWrite(t)}catch(e){if(e instanceof s&&e.code===`EACCES`)throw e}return this.vfs.copyFile(n,t)}async symlink(e,t){return this.checkWrite(t),await this.checkParentRealpathEscape(t),this.vfs.symlink(e,t)}async readlink(e){if(!this.isAllowedStrict(e))throw new s(`ENOENT`,`no such file or directory`,i(e));let t=await this.vfs.readlink(e),n;if(t.startsWith(`/`))n=i(t);else{let r=this.vfs.dirname(e);n=i(r+`/`+t)}if(!this.isAllowedStrict(n))throw new s(`ENOENT`,`no such file or directory`,i(e));return t}async lstat(e){let t=N[i(e)];if(t)return t.stat();if(!this.isAllowed(e))throw new s(`ENOENT`,`no such file or directory`,i(e));let n=i(e),r=this.vfs.dirname(n),a=this.vfs.basename(n),o;if(r===n)o=r;else try{o=await this.vfs.realpath(r)}catch{throw new s(`ENOENT`,`no such file or directory`,n)}let c=o===`/`?`/${a}`:`${o}/${a}`;if(!this.isAllowed(c))throw new s(`ENOENT`,`no such file or directory`,n);return this.vfs.lstat(c)}watch(e,t,n){if(!this.isAllowed(e))throw new s(`EACCES`,`permission denied`,i(e));let r=this.vfs.getWatcher();if(!r)throw new s(`EINVAL`,`no watcher configured`);return r.watch(i(e),t,n)}dirname(e){return this.vfs.dirname(e)}basename(e){return this.vfs.basename(e)}async mount(e,t,n){return this.checkWrite(e),await this.checkParentRealpathEscape(e),this.vfs.mount(e,t,n)}async unmount(e){return this.checkWrite(e),await this.checkParentRealpathEscape(e),this.vfs.unmount(e)}listMounts(){return this.vfs.listMounts()}getMountIndex(){return this.vfs.getMountIndex()}async refreshMount(e,t){return this.checkWrite(e),this.vfs.refreshMount(e,t)}async dispose(){await this.vfs.dispose()}};function I(e,t){if(e instanceof s){let n=`${e.code}: `,r=e.message;throw r.startsWith(n)&&(r=r.slice(n.length)),e.path&&r.endsWith(` '${e.path}'`)&&(r=r.slice(0,r.length-` '${e.path}'`.length)),new s(e.code,r,t)}throw e}var L=[`ENOENT`,`EEXIST`,`ENOTDIR`,`EISDIR`,`ENOTEMPTY`,`EINVAL`,`EACCES`,`ELOOP`,`EBUSY`,`EFBIG`,`EBADF`,`EIO`];function R(e,t){if(e instanceof s)return e;{let n=e instanceof Error?e.message:String(e);if(n.includes(`maximum size exceeded`)||n.includes(`call stack size exceeded`))return new s(`EIO`,`internal overflow, not storage: ${n} — reload the session`,t)}let n=e?.code;if(typeof n==`string`){let r=n;if(L.includes(r)){let n=e instanceof Error?e.message:String(e);return n.startsWith(`${r}: `)&&(n=n.slice(r.length+2),n=n.replace(/, undefined( '[^']*')?$/,``).replace(/ '[^']*'$/,``)),new s(r,n||r,t)}}let r=e instanceof Error?e.message:String(e);return r.includes(`ENOENT`)?new s(`ENOENT`,`no such file or directory`,t):r.includes(`EEXIST`)?new s(`EEXIST`,`file already exists`,t):r.includes(`ENOTDIR`)?new s(`ENOTDIR`,`not a directory`,t):r.includes(`EISDIR`)?new s(`EISDIR`,`is a directory`,t):r.includes(`ENOTEMPTY`)?new s(`ENOTEMPTY`,`directory not empty`,t):r.includes(`ELOOP`)?new s(`ELOOP`,`too many levels of symbolic links`,t):new s(`EINVAL`,r,t)}var z=61440,B=16384;function V(e){return e===void 0?`absent`:(e&z)===B?`directory`:`file`}function H(e,t){return t===`absent`?!1:e.kind===`missing`||e.kind!==t}function U(e){let t=e?.mode;return typeof t==`number`?t:void 0}function W(e,t,n,r=new Set){let i=new Set(n);if(r.size>0){for(let t of Object.keys(e.entries??{}))for(let e of r)if(t===e||t.startsWith(`${e}/`)){i.add(t);break}}let a=[];for(let n of i){let r=e.entries?.[n],i=t.entries?.[n];if(!r||!i)continue;let o=V(U(r));o!==V(U(i))&&a.push({path:n,ownIsDirectory:o===`directory`})}return a}async function G(e,t,n,r){try{return await e.lstat(t)}catch(e){let t=R(e,r);if(t.code===`ENOENT`&&n)return null;throw t}}async function K(e,t,r){let a;try{a=await e.readlink(t)}catch(e){throw R(e,r)}return a.startsWith(`/`)?i(a):i(o(n(t).dir,a))}async function q(e,t,n,r,i,a){let o=t===`/`?`/${n}`:`${t}/${n}`;for(;;){let t=await G(e,o,r,i);if(t===null||!t.isSymbolicLink())return{resolved:o,hops:a};if(++a>10)throw new s(`ELOOP`,`too many symbolic links encountered`,i);o=await K(e,o,i)}}async function J(e,t,n){let r=i(n);if(t(r))return r;let a=r.split(`/`).filter(Boolean),o=`/`,s=0;for(let t=0;t<a.length;t++){let n=await q(e,o,a[t],t===a.length-1,r,s);o=n.resolved,s=n.hops}return o}async function Y(e,t,n){return t(n)?n:J(e,t,n)}function X(e,t,n){return e.size===0||!e.has(n)||!t.isReady(n)?!1:!Array.from(e.keys()).some(e=>e!==n&&e.startsWith(n+`/`))}async function Z(e,t){try{return await e(t)}catch{return t}}async function*Q(e,t,n,r=0){let a=i(t);if(X(e.mountPoints,e.mountIndex,a)){let t=e.mountIndex.getFiles(a);if(t){for(let e of t)yield e;return}}let o=n??new Set;if(r>64||o.size>=1e5)return;let s=await Z(t=>e.realpath(t),a);if(o.has(s))return;o.add(s);let c=await e.readDir(a);for(let t of c)yield*ne(e,t,a===`/`?`/${t.name}`:`${a}/${t.name}`,o,r+1)}async function*ne(e,t,n,r,i){if(t.type===`file`){yield n;return}if(t.type===`symlink`){yield*re(e,n,r,i);return}yield*Q(e,n,r,i)}async function*re(e,t,n,r){try{let i=await e.stat(t);i.type===`file`?yield t:i.type===`directory`&&(yield*Q(e,t,n,r))}catch{}}function $(){try{if(typeof globalThis.navigator?.storage?.getDirectory==`function`)return`opfs`}catch{}return`memory`}function ie(e,t){switch(e.kind){case`local`:case`proc`:return{kind:`local`,mountId:e.mountId,idbHandleKey:t};case`hostfs`:return{kind:`hostfs`,mountId:e.mountId,hostPath:e.getHostPath()};default:return{kind:e.kind===`s3`?`s3`:e.kind===`aem`?`aem`:`da`,mountId:e.mountId,source:e.source,profile:e.profile??`default`}}}var ae=class t{lfs;lfsSync;rawLfs=null;rawLfsSync=null;_ready;_readyResolved=!1;backend;mountPoints=new Map;opfsBackendFs=null;opfsHandle=null;mountRoot=``;internalMounts=new Set;watcher=null;dbName;mountSyncChannel=null;mountIndex=new M;static writeChains=new Map;onRepairProgress;constructor(e,n,r,i,a){if(this.dbName=e,this.onRepairProgress=a,this.backend=r===`opfs`?`opfs`:`memory`,this.lfs=this.makeDeferredLfs(),this.lfsSync=this.makeDeferredLfsSync(),this._ready=this.backend===`opfs`?t.initOpfsBackend(this,i,n===!0):t.initMemoryBackend(this,e,n===!0),this._ready.then(()=>{this._readyResolved=!0},()=>{}),typeof BroadcastChannel<`u`)try{this.mountSyncChannel=new BroadcastChannel(`vfs-mount-sync:${e}`),this.mountSyncChannel.onmessage=e=>{let{type:t,path:n,descriptor:r}=e.data??{};if(t===`mount`&&typeof n==`string`&&r)this.reconstructBackendFromDescriptor(r,n).then(e=>{this.mountPoints.set(n,e),e.kind===`local`&&this.mountIndex.registerMount(n,e.getHandle()),this.watcher?.notify([{type:`modify`,path:n,entryType:`directory`}])}).catch(()=>{});else if(t===`unmount`&&typeof n==`string`){let e=this.mountPoints.get(n);this.mountPoints.delete(n),this.mountIndex.unregisterMount(n),e?.close(),this.watcher?.notify([{type:`modify`,path:n,entryType:`directory`}])}}}catch{}}static async initOpfsBackend(n,r,i){let a=r??await t.acquireOpfsHandle(n.dbName,i);await t.seedOpfsMetadataSidecarIfMissing(a);let[o,{WebAccess:s}]=await Promise.all([e(()=>import(`./dist-Cew647MY.js`).then(e=>e.t),__vite__mapDeps([0,1,2])),e(()=>import(`./dist-_7dnux20.js`),__vite__mapDeps([3,0,1,2]))]);await t.ensureRootMount(o);let c=`/__opfs__/${n.dbName}`,l=t.opfsBackends.get(n.dbName);if(l&&i){try{o.umount(c)}catch{}t.opfsBackends.delete(n.dbName),l=void 0}if(!l){let r=()=>o.resolveMountConfig({backend:s,handle:a,metadata:`/.metadata.json`}),{resolveWithSidecarRepair:i,repairOpfsMetadataSidecar:u}=await e(async()=>{let{resolveWithSidecarRepair:e,repairOpfsMetadataSidecar:t}=await import(`./sidecar-repair-431vRT2V.js`).then(e=>e.n);return{resolveWithSidecarRepair:e,repairOpfsMetadataSidecar:t}},__vite__mapDeps([4,1]));try{let e=await n.withWriteLock(()=>u(a,n.onRepairProgress));e?.changed&&console.warn(`[virtual-fs] repaired metadata sidecar before mount (#2146)`,{dbName:n.dbName,kindFixed:e.kindFixed,sizesFixed:e.sizesFixed,dropped:e.dropped,inosReassigned:e.inosReassigned,nlinksFixed:e.nlinksFixed,selfEntryDropped:e.selfEntryDropped})}catch{}let d=await i(r,()=>n.withWriteLock(()=>u(a,n.onRepairProgress)),e=>console.warn(`[virtual-fs] repaired poisoned metadata sidecar; retrying mount`,{dbName:n.dbName,kindFixed:e.kindFixed,sizesFixed:e.sizesFixed,dropped:e.dropped,nlinksFixed:e.nlinksFixed,selfEntryDropped:e.selfEntryDropped}));try{o.mount(c,d)}catch{}l={backendFs:d,refs:0,sidecarDirty:{paths:new Set,prefixes:new Set}},t.opfsBackends.set(n.dbName,l)}l.refs+=1,n.opfsBackendFs=l.backendFs.index?l.backendFs:null,n.opfsHandle=a,n.mountRoot=c,n.rawLfs=o.promises,n.rawLfsSync=o}static async initMemoryBackend(n,r,i){let a=await e(()=>import(`./dist-Cew647MY.js`).then(e=>e.t),__vite__mapDeps([0,1,2]));await t.ensureRootMount(a);let o=`/__zenfs__/${r}`,s=t.memoryBackends.get(r);if(s&&i){try{a.umount(o)}catch{}t.memoryBackends.delete(r),s=void 0}s||(s={store:a.InMemory.create({label:r}),refs:0},t.memoryBackends.set(r,s)),s.refs+=1;try{a.mount(o,s.store)}catch{}n.mountRoot=o,n.rawLfs=a.promises,n.rawLfsSync=a,n.opfsBackendFs=null,n.opfsHandle=null}static rootMountReady=null;static memoryBackends=new Map;static opfsBackends=new Map;static async ensureRootMount(e){return t.rootMountReady===null&&(t.rootMountReady=(async()=>{await e.configureSingle({backend:e.InMemory,label:`__vfs_root__`})})()),t.rootMountReady}prefix(e){return this.mountRoot?e===`/`?this.mountRoot:this.mountRoot+e:e}unprefix(e){return!this.mountRoot||!e.startsWith(this.mountRoot)?e:e.slice(this.mountRoot.length)||`/`}makeDeferredLfs(){let e=e=>this.prefix(e),t=e=>this.unprefix(e),n=()=>{if(!this.rawLfs)throw Error(`VirtualFS used before init resolved`);return this.rawLfs};return{readFile:(t,r)=>this._readyResolved?n().readFile(e(t),r):this._ready.then(()=>n().readFile(e(t),r)),writeFile:(t,r,i)=>this._readyResolved?n().writeFile(e(t),r,i):this._ready.then(()=>n().writeFile(e(t),r,i)),readdir:t=>this._readyResolved?n().readdir(e(t)):this._ready.then(()=>n().readdir(e(t))),mkdir:(t,r)=>this._readyResolved?n().mkdir(e(t),r):this._ready.then(()=>n().mkdir(e(t),r)),rmdir:t=>this._readyResolved?n().rmdir(e(t)):this._ready.then(()=>n().rmdir(e(t))),unlink:t=>this._readyResolved?n().unlink(e(t)):this._ready.then(()=>n().unlink(e(t))),rename:(t,r)=>this._readyResolved?n().rename(e(t),e(r)):this._ready.then(()=>n().rename(e(t),e(r))),stat:t=>this._readyResolved?n().stat(e(t)):this._ready.then(()=>n().stat(e(t))),lstat:t=>this._readyResolved?n().lstat(e(t)):this._ready.then(()=>n().lstat(e(t))),symlink:(t,r)=>{let i=t.startsWith(`/`)?e(t):t;return this._readyResolved?n().symlink(i,e(r)):this._ready.then(()=>n().symlink(i,e(r)))},readlink:async r=>(this._readyResolved||await this._ready,t(await n().readlink(e(r)))),truncate:async(t,r)=>{this._readyResolved||await this._ready;let i=n();typeof i.truncate==`function`&&await i.truncate(e(t),r)},realpath:async r=>{this._readyResolved||await this._ready;let i=n();return typeof i.realpath==`function`?t(await i.realpath(e(r))):e(r)}}}makeDeferredLfsSync(){let e=e=>this.prefix(e),t=e=>this.unprefix(e);return{readdirSync:t=>{let n=this.rawLfsSync;return n?.readdirSync?n.readdirSync(e(t)):void 0},statSync:t=>{let n=this.rawLfsSync;return n?.statSync?n.statSync(e(t)):void 0},lstatSync:t=>{let n=this.rawLfsSync;return n?.lstatSync?n.lstatSync(e(t)):void 0},readlinkSync:n=>{let r=this.rawLfsSync;return r?.readlinkSync?t(r.readlinkSync(e(n))):void 0}}}static async seedOpfsMetadataSidecarIfMissing(e){let t=`.metadata.json`;try{await e.getFileHandle(t);return}catch(e){if(e?.name!==`NotFoundError`)throw e}let n=await(await e.getFileHandle(t,{create:!0})).createWritable(),r=JSON.stringify({version:1,maxSize:4294967295,entries:{}});await n.write(r),await n.close()}static async acquireOpfsHandle(e,t){let n=navigator.storage;if(!n?.getDirectory)throw new s(`EINVAL`,`OPFS is not available in this environment`);let r=await n.getDirectory();if(t)try{await r.removeEntry(e,{recursive:!0})}catch{}return r.getDirectoryHandle(e,{create:!0})}static _createSyncForTests(e){return new t(e)}static async create(e){let n=e?.dbName??`browser-fs`,r=e?.wipe===!0,i=e?.backend??$(),a=new t(n,r,i,void 0,e?.onRepairProgress);return await a._ready,r&&await p().catch(()=>{}),a}async flush(){await this.writeOpfsMetadataSidecar()}async writeOpfsMetadataSidecar(){this.backend===`opfs`&&await this.withWriteLock(()=>this.writeOpfsMetadataSidecarUnlocked())}async writeOpfsMetadataSidecarUnlocked(){if(this.backend!==`opfs`)return;let e=this.opfsBackendFs,n=this.opfsHandle;if(!e||!n)return;let r=e.index.toJSON(),i=t.opfsBackends.get(this.dbName)?.sidecarDirty,a=r;if(i){let e=null;try{let t=await n.getFileHandle(`.metadata.json`),r=JSON.parse(await(await t.getFile()).text());r&&typeof r==`object`&&r.entries&&(e=r)}catch{}e&&(await this.auditDirtyKindFlips(r,e,i,n),a=h(e,r,i))}let o=JSON.stringify(m(a)),s=await(await n.getFileHandle(`.metadata.json`,{create:!0})).createWritable();await s.write(o),await s.close(),i&&(i.paths.clear(),i.prefixes.clear())}async auditDirtyKindFlips(e,t,n,r){let i=W(e,t,n.paths,n.prefixes);if(i.length===0)return;let a=g(r),o=this.opfsBackendFs;for(let n of i){let r=await a(n.path).catch(()=>null);if(r!==null&&r.kind!==`missing`&&r.kind===`directory`===n.ownIsDirectory)continue;let i=t.entries?.[n.path];e.entries&&i!==void 0&&(e.entries[n.path]=i);let s=r!==null&&r.kind!==`missing`;s&&(o?.index?.delete(n.path),o?._handles?.delete(n.path)),console.warn(`[virtual-fs] refused to flush in-memory kind flip over sidecar record (#2006)`,{path:n.path,reality:r?.kind??`unverifiable`,evicted:s})}}markSidecarDirty(e,r=`path`){if(this.backend!==`opfs`)return;let a=t.opfsBackends.get(this.dbName)?.sidecarDirty;if(!a)return;let o=i(e);(r===`prefix`?a.prefixes:a.paths).add(o);let{dir:s}=n(o);for(;s!==`/`;)a.paths.add(s),s=n(s).dir}invalidatePaths(e){if(this.backend!==`opfs`||!this.opfsBackendFs)return;let t=this.opfsBackendFs;for(let n of e){let e=i(n);t.index.delete(e),t._handles?.delete(e),this.markSidecarDirty(e)}}async withKindMismatchRetry(e,t){return this.withKindMismatchRetryPaths([e],t)}async withKindMismatchRetryPaths(e,t){try{return await t()}catch(n){let r=n?.code;if(r!==`EISDIR`&&r!==`ENOTDIR`&&r!==`EINVAL`)throw n;for(let n of e)if(await this.reconcileKindMismatch(n).catch(()=>!1))return await t();throw n}}async reconcileKindMismatch(e){if(this.backend!==`opfs`)return!1;let t=this.opfsBackendFs,n=this.opfsHandle;if(!t?.index||!n)return!1;let r=i(e),a=r;try{a=await this.resolveSymlinks(r)}catch{}let o=await g(n)(a),s=V(t.index.get(a)?.mode),c=t._handles?.get(a),l=c?.kind===`directory`?`directory`:c?.kind===`file`?`file`:`absent`,u=H(o,s),d=H(o,l);if(!u&&!d)return!1;if(t.index.delete(a),t._handles?.delete(a),s===`directory`||l===`directory`){let e=`${a}/`;for(let n of[...t.index.keys()])n.startsWith(e)&&t.index.delete(n);if(t._handles)for(let n of[...t._handles.keys()])n.startsWith(e)&&t._handles.delete(n)}return this.markSidecarDirty(a),console.warn(`[virtual-fs] reconciled in-memory kind mismatch (#2006)`,{path:a,reality:o.kind,indexHeld:s,handleHeld:l}),!0}canWrite(e){return!0}setWatcher(e){this.watcher=e}getWatcher(){return this.watcher}async dispose(){if(this.mountSyncChannel?.close(),this.mountSyncChannel=null,this.watcher?.dispose(),this.watcher=null,this.mountIndex.dispose(),await this.writeOpfsMetadataSidecar(),this.mountRoot){let n=this.backend===`opfs`?t.opfsBackends:t.memoryBackends,r=n.get(this.dbName);if(r&&(--r.refs,r.refs<=0)){n.delete(this.dbName);try{(await e(()=>import(`./dist-Cew647MY.js`).then(e=>e.t),__vite__mapDeps([0,1,2]))).umount(this.mountRoot)}catch{}}}}readDirSync(e){let t=i(e);if(this.findMount(t))return null;let n=this.lfsSync;if(typeof n.readdirSync!=`function`||typeof n.lstatSync!=`function`)return null;try{let e=n.readdirSync(t),r=[];for(let i of e){let e=t===`/`?`/${i}`:`${t}/${i}`;try{let t=n.lstatSync(e),a=t.isSymbolicLink()?`symlink`:t.isDirectory()?`directory`:`file`;r.push({name:i,type:a})}catch{}}return r}catch{return null}}statSync(e){let t=i(e);if(this.findMount(t))return null;let r=this.lfsSync;if(typeof r.statSync!=`function`||typeof r.lstatSync!=`function`||typeof r.readlinkSync!=`function`)return null;if(t===`/`)try{let e=r.statSync(t);return{type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs}}catch{return null}let a=t;for(let e=0;e<=10;e++){let e;try{e=r.lstatSync(a)}catch{return null}if(!e.isSymbolicLink())return{type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs};let t;try{t=r.readlinkSync(a)}catch{return null}a=t.startsWith(`/`)?i(t):i(o(n(a).dir,t))}return null}lstatSync(e){let t=i(e);if(this.findMount(t))return null;let n=this.lfsSync;if(typeof n.lstatSync!=`function`)return null;if(t===`/`)return this.statSync(t);try{let e=n.lstatSync(t);if(e.isSymbolicLink()){let r=n.readlinkSync?n.readlinkSync(t):``;return{type:`symlink`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs,isSymlink:!0,symlinkTarget:r}}return{type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs}}catch{return null}}async mount(e,t,r){let a=i(e);if(this.mountPoints.has(a))throw new s(`EEXIST`,`mount point is already mounted`,a);try{if((await this.lstat(a)).type!==`directory`)throw new s(`ENOTDIR`,`mount point must be a directory`,a);if((await this.readDir(a)).length>0)throw new s(`ENOTEMPTY`,`mount point must be empty to avoid shadowing existing files`,a)}catch(e){if(!(e instanceof s)||e.code!==`ENOENT`)throw e}let{dir:o}=n(a);o!==`/`&&await this.mkdir(o,{recursive:!0});try{await this.lfs.mkdir(a)}catch{}if(this.mountPoints.set(a,t),t.kind===`local`){let e=r?.limits??j(r?.env??{});this.mountIndex.registerMount(a,t.getHandle(),e)}let c=ie(t,a);try{this.mountSyncChannel?.postMessage({type:`mount`,path:a,descriptor:c})}catch{}if(this.watcher?.notify([{type:`modify`,path:a,entryType:`directory`}]),t.kind!==`hostfs`)try{let e={targetPath:a,descriptor:c,createdAt:Date.now()},n=t.kind===`local`?t.getHandle():void 0;await u(e,n)}catch{}}async unmount(e){let t=i(e),n=this.mountPoints.get(t);this.mountPoints.delete(t),this.mountIndex.unregisterMount(t);try{this.mountSyncChannel?.postMessage({type:`unmount`,path:t})}catch{}this.watcher?.notify([{type:`modify`,path:t,entryType:`directory`}]),await n?.close();try{await d(t)}catch{}}async reconstructBackendFromDescriptor(t,n){switch(t.kind){case`local`:{let e=await f(t.idbHandleKey);if(!e)throw Error(`no handle stored for ${t.idbHandleKey}`);return l.fromHandle(e,{mountId:t.mountId})}case`hostfs`:{let{HostFsMountBackend:r}=await e(async()=>{let{HostFsMountBackend:e}=await import(`./backend-hostfs-Com-zF5W.js`);return{HostFsMountBackend:e}},__vite__mapDeps([5,6,7]));return new r({targetPath:n,hostPath:t.hostPath,mountId:t.mountId})}case`s3`:{let{S3MountBackend:n,RemoteMountCache:r,makeSignedFetchS3:i}=await e(async()=>{let{S3MountBackend:e,RemoteMountCache:t,makeSignedFetchS3:n}=await import(`./mount-B8ydUbOd.js`);return{S3MountBackend:e,RemoteMountCache:t,makeSignedFetchS3:n}},__vite__mapDeps([8,9,10,11,12,13,1,14,15,6,16,7,17,18,19,20,21,22,23,24,25,26,27,28])),a=new r({mountId:t.mountId,ttlMs:3e4});return new n({source:t.source,profile:t.profile,cache:a,mountId:t.mountId,signedFetch:i(t.profile)})}case`da`:{let{DaMountBackend:n,RemoteMountCache:r,makeSignedFetchDa:i}=await e(async()=>{let{DaMountBackend:e,RemoteMountCache:t,makeSignedFetchDa:n}=await import(`./mount-B8ydUbOd.js`);return{DaMountBackend:e,RemoteMountCache:t,makeSignedFetchDa:n}},__vite__mapDeps([8,9,10,11,12,13,1,14,15,6,16,7,17,18,19,20,21,22,23,24,25,26,27,28])),a=new r({mountId:t.mountId,ttlMs:3e4});return new n({source:t.source,profile:t.profile,cache:a,mountId:t.mountId,signedFetch:i()})}case`aem`:{let{AemMountBackend:n,RemoteMountCache:r,makeSignedFetchDa:i}=await e(async()=>{let{AemMountBackend:e,RemoteMountCache:t,makeSignedFetchDa:n}=await import(`./mount-B8ydUbOd.js`);return{AemMountBackend:e,RemoteMountCache:t,makeSignedFetchDa:n}},__vite__mapDeps([8,9,10,11,12,13,1,14,15,6,16,7,17,18,19,20,21,22,23,24,25,26,27,28])),a=new r({mountId:t.mountId,ttlMs:3e4});return new n({source:t.source,profile:t.profile,cache:a,mountId:t.mountId,signedFetch:i()})}}}listMounts(){let e=[];for(let t of this.mountPoints.keys())this.internalMounts.has(t)||e.push(t);return e}listInternalMounts(){return[...this.internalMounts]}listMountPoints(){let e=[];for(let[t,n]of this.mountPoints)this.internalMounts.has(t)||e.push({path:t,kind:n.kind});return e}async mountInternal(e,t){let r=i(e);if(this.mountPoints.has(r))throw new s(`EEXIST`,`mount point is already mounted`,r);let{dir:a}=n(r);a!==`/`&&await this.mkdir(a,{recursive:!0});try{await this.lfs.mkdir(r)}catch{}this.mountPoints.set(r,t),this.internalMounts.add(r),this.watcher?.notify([{type:`modify`,path:r,entryType:`directory`}])}async unmountInternal(e){let t=i(e);if(!this.internalMounts.has(t))throw new s(`ENOENT`,`not an internal mount point`,t);let n=this.mountPoints.get(t);this.mountPoints.delete(t),this.internalMounts.delete(t),this.watcher?.notify([{type:`modify`,path:t,entryType:`directory`}]),await n?.close()}getMountIndex(){return this.mountIndex}async refreshMount(e,t){let n=i(e),r=this.mountPoints.get(n);if(!r)throw new s(`ENOENT`,`not a mount point`,n);let a=await r.refresh(t);return r.kind===`local`&&await this.mountIndex.refreshMount(n,j(t?.env??{})),a}isPathUnderMount(e){for(let t of this.mountPoints.keys())if(e===t||e.startsWith(t+`/`))return!0;return!1}findMount(e){let t=null;for(let[n,r]of this.mountPoints)(e===n||e.startsWith(n+`/`))&&(!t||n.length>t.mountPath.length)&&(t={mountPath:n,backend:r});return t?e===t.mountPath?{path:t.mountPath,backend:t.backend,relParts:[]}:{path:t.mountPath,backend:t.backend,relParts:e.slice(t.mountPath.length+1).split(`/`).filter(Boolean)}:null}async readFile(e,t){return this.withKindMismatchRetry(e,()=>this.readFileInner(e,t))}async readFileInner(e,t){let n=i(e),r=this.findMount(n);if(r){if(r.relParts.length===0)throw new s(`EISDIR`,`is a directory`,n);let e=r.relParts.join(`/`);try{let n=await r.backend.readFile(e);return(t?.encoding??`utf-8`)===`utf-8`?new TextDecoder(`utf-8`).decode(n):n}catch(e){I(e,n)}}let a=await this.resolveSymlinks(n);try{return(t?.encoding??`utf-8`)===`utf-8`?await this.lfs.readFile(a,{encoding:`utf8`}):await this.lfs.readFile(a)}catch(e){throw R(e,n)}}async writeFile(e,t,n){return this.withKindMismatchRetry(e,()=>this.writeFileInner(e,t,n))}async writeFileInner(e,t,r){let a=i(e),o=this.findMount(a);if(o){if(o.relParts.length===0)throw new s(`EISDIR`,`is a directory`,a);let e=o.relParts.join(`/`),n=!1;try{await this.stat(a),n=!0}catch{}let r=typeof t==`string`?new TextEncoder().encode(t):t instanceof Uint8Array?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(t);try{await o.backend.writeFile(e,r)}catch(e){I(e,a)}this.watcher?.notify([{type:n?`modify`:`create`,path:a,entryType:`file`}]),this.mountIndex.notifyWrite(a);return}let c;try{c=await this.resolveSymlinks(a)}catch{c=a}let l=!1;try{await this.lfs.stat(c),l=!0}catch{}let{dir:u}=n(c);await this.withWriteLock(async()=>{this.markSidecarDirty(c),u!==`/`&&await this.mkdirRecursiveUnlocked(u);let e=typeof t==`string`?new TextEncoder().encode(t).byteLength:(t instanceof Uint8Array,t.byteLength);try{await this.lfs.writeFile(c,t)}catch(e){if(u!==`/`&&e instanceof Error&&e.message.includes(`ENOENT`)){await this.mkdirRecursiveUnlocked(u);try{await this.lfs.writeFile(c,t)}catch(e){throw R(e,a)}}else throw R(e,a)}try{await this.lfs.truncate?.(c,e)}catch(e){throw R(e,a)}}),this.watcher?.notify([{type:l?`modify`:`create`,path:c,entryType:`file`}])}async readDir(e){let t=i(e),n=this.findMount(t);return n?this.readDirMounted(t,n):this.readDirLocal(t)}async readDirMounted(e,t){let n=this.mountIndex.getDirectoryEntries(t.path,e);if(n!==void 0){let t=new Map;for(let e of n)t.set(e.name,{name:e.name,type:e.type});return this.addNestedMountEntries(t,e),[...t.values()]}let r=t.relParts.join(`/`)||`/`,i;try{i=await t.backend.readDir(r)}catch(t){I(t,e)}let a=new Map;for(let e of i)a.set(e.name,{name:e.name,type:e.kind===`directory`?`directory`:`file`});return this.addNestedMountEntries(a,e),[...a.values()]}async readDirLocal(e){return this.withKindMismatchRetry(e,()=>this.readDirLocalInner(e))}async readDirLocalInner(e){let t=await this.resolveSymlinks(e);try{let e=await this.lfs.readdir(t),n=[];for(let r of e){let e=await this.statDirEntry(t,r);e&&n.push(e)}return n}catch(t){throw R(t,e)}}async statDirEntry(e,t){let n=e===`/`?`/${t}`:`${e}/${t}`;try{let e=await this.lfs.lstat(n);return e.isSymbolicLink()?{name:t,type:`symlink`}:{name:t,type:e.isDirectory()?`directory`:`file`}}catch{return null}}addNestedMountEntries(e,t){let n=t===`/`?`/`:`${t}/`;for(let r of this.mountPoints.keys()){if(r===t||!r.startsWith(n))continue;let i=r.slice(n.length);!i||i.includes(`/`)||e.has(i)||e.set(i,{name:i,type:`directory`})}}async withWriteLock(e){let n=this.dbName,r,i=new Promise(e=>{r=e}),a=t.writeChains.get(n)??Promise.resolve();t.writeChains.set(n,i),await a;try{let t=globalThis.navigator?.locks;return this.backend!==`opfs`||typeof t?.request!=`function`?await e():await t.request(`slicc-vfs:${n}`,()=>e())}finally{r(),t.writeChains.get(n)===i&&t.writeChains.delete(n)}}async mkdirRecursiveUnlocked(e){let t=e.split(`/`).filter(Boolean),n=``;for(let e of t){n+=`/`+e;try{await this.lfs.mkdir(n)}catch(e){if(e instanceof Error&&!e.message.includes(`EEXIST`))throw R(e,n);try{let e=await this.lfs.lstat(n);if(!e.isDirectory()&&!e.isSymbolicLink())throw new s(`ENOTDIR`,`not a directory`,n)}catch(e){if(e instanceof s&&e.code===`ENOTDIR`)throw e}}}}async mkdir(e,t){let n=i(e);if(n===`/`)return;let r=this.findMount(n);if(r){if(r.relParts.length===0)return;let e=r.relParts.join(`/`),t=await this.exists(n);try{await r.backend.mkdir(e)}catch(e){I(e,n)}t||this.watcher?.notify([{type:`create`,path:n,entryType:`directory`}]);return}t?.recursive?await this.withWriteLock(()=>(this.markSidecarDirty(n),this.mkdirRecursiveUnlocked(n))):(await this.withWriteLock(async()=>{this.markSidecarDirty(n);try{await this.lfs.mkdir(n)}catch(e){throw R(e,n)}}),this.watcher?.notify([{type:`create`,path:n,entryType:`directory`}]))}async rm(e,t){return this.withKindMismatchRetry(i(e),()=>this.rmInner(e,t))}async rmInner(e,t){let n=i(e),r=this.findMount(n);if(r){if(r.relParts.length===0)throw new s(`EINVAL`,`cannot remove a mount point — use unmount`,n);let e;try{e=(await this.stat(n)).type}catch{}let i=r.relParts.join(`/`);try{await r.backend.remove(i,{recursive:t?.recursive})}catch(e){I(e,n)}this.watcher?.notify([{type:`delete`,path:n,entryType:e}]),this.mountIndex.notifyDelete(n);return}try{let e=await this.lfs.lstat(n);await this.withWriteLock(async()=>{e.isSymbolicLink()?await this.lfs.unlink(n):e.isDirectory()?t?.recursive?await this.rmRecursiveUnlocked(n):await this.lfs.rmdir(n):await this.lfs.unlink(n),this.markSidecarDirty(n,`prefix`),await this.writeOpfsMetadataSidecarUnlocked()})}catch(e){throw R(e,n)}this.watcher?.notify([{type:`delete`,path:n}])}async rmRecursiveUnlocked(e){let t=await this.lfs.readdir(e);for(let n of t){let t=e===`/`?`/${n}`:`${e}/${n}`,r=await this.lfs.lstat(t);r.isSymbolicLink()?await this.lfs.unlink(t):r.isDirectory()?await this.rmRecursiveUnlocked(t):await this.lfs.unlink(t)}await this.lfs.rmdir(e)}async stat(e){return this.withKindMismatchRetry(e,()=>this.statInner(e))}async statInner(e){let t=i(e),n=this.findMount(t);if(n){if(n.relParts.length===0)try{let e=await this.lfs.stat(t);return{type:`directory`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs}}catch{return{type:`directory`,size:0,mtime:Date.now(),ctime:Date.now()}}let e=n.relParts.join(`/`);try{let t=await n.backend.stat(e);return{type:t.kind===`directory`?`directory`:`file`,size:t.size,mtime:t.mtime,ctime:t.mtime}}catch(e){I(e,t)}}let r=await this.resolveSymlinks(t);try{let e=await this.lfs.stat(r);return{type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs}}catch(e){throw R(e,t)}}async exists(e){let t=i(e),n=this.findMount(t);if(n){if(n.relParts.length===0)return!0;try{return await this.stat(t),!0}catch{return!1}}try{return await this.stat(t),!0}catch{try{return await this.lfs.lstat(t),!0}catch{return!1}}}async rename(e,t){return this.withKindMismatchRetryPaths([i(e),i(t)],()=>this.renameInner(e,t))}async renameInner(e,t){let n=i(e),r=i(t),a;try{a=(await this.lstat(n)).type}catch{}let o=this.findMount(n);if(o?.backend.rename){let e=this.findMount(r);if(e&&e.backend===o.backend){try{await o.backend.rename(o.relParts.join(`/`),e.relParts.join(`/`))}catch(e){I(e,n)}this.watcher?.notify([{type:`delete`,path:n,entryType:a},{type:`create`,path:r,entryType:a}]),this.mountIndex.notifyRename(n,r);return}}try{await this.withWriteLock(async()=>{this.markSidecarDirty(n,`prefix`),this.markSidecarDirty(r,`prefix`),await this.lfs.rename(n,r),await this.writeOpfsMetadataSidecarUnlocked()})}catch(e){throw R(e,n)}this.watcher?.notify([{type:`delete`,path:n,entryType:a},{type:`create`,path:r,entryType:a}]),this.mountIndex.notifyRename(n,r)}async readTextFile(e){return await this.readFile(e,{encoding:`utf-8`})}async*walk(e,t,n=0){yield*Q({mountPoints:this.mountPoints,mountIndex:this.mountIndex,realpath:e=>this.realpath(e),readDir:e=>this.readDir(e),stat:e=>this.stat(e)},e,t,n)}async copyFile(e,t){if((await this.stat(e)).type===`directory`)throw new s(`EISDIR`,`is a directory`,e);let n=await this.readFile(e,{encoding:`binary`});await this.writeFile(t,n)}dirname(e){return n(i(e)).dir}basename(e){return n(i(e)).base}async symlink(e,t){let r=i(t);if(this.findMount(r))throw new s(`EINVAL`,`symlinks not supported on mounted filesystems`,r);let{dir:a}=n(r);await this.withWriteLock(async()=>{a!==`/`&&await this.mkdirRecursiveUnlocked(a);try{await this.lfs.symlink(e,r)}catch(t){if(a!==`/`&&t instanceof Error&&t.message.includes(`ENOENT`)){await this.mkdirRecursiveUnlocked(a);try{await this.lfs.symlink(e,r)}catch(e){throw R(e,r)}}else throw R(t,r)}this.markSidecarDirty(r),await this.writeOpfsMetadataSidecarUnlocked()}),this.watcher?.notify([{type:`create`,path:r,entryType:`symlink`}])}async readlink(e){let t=i(e);try{return await this.lfs.readlink(t)}catch(e){throw R(e,t)}}async lstat(e){let t=i(e);if(this.findMount(t)||t===`/`)return this.stat(t);try{let e=await this.lfs.lstat(t);if(e.isSymbolicLink()){let n=await this.lfs.readlink(t);return{type:`symlink`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs,isSymlink:!0,symlinkTarget:n}}return{type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs}}catch(e){throw R(e,t)}}async realpath(e){return J(this.lfs,e=>this.findMount(e)!==null,e)}resolveSymlinks(e){return Y(this.lfs,e=>this.findMount(e)!==null,e)}};export{s as FsError,b as FsWatcher,M as MountIndex,F as RestrictedFS,ae as VirtualFS,o as joinPath,i as normalizePath,r as pathSegments,$ as resolveVfsBackendFromEnv,n as splitPath};
@@ -1 +0,0 @@
1
- import{t as e}from"./store-B-OIjDgy.js";export{e as readMcpAuthEntries};
@@ -1 +0,0 @@
1
- import{t as e}from"./types-idfTVsM8.js";function t(e){return new i(e)}var n=3e4,r=`vfs-r-`,i=class{transport;log;genId;requestTimeoutMs;pending=new Map;unsubscribe=null;counter=0;constructor(e){this.transport=e.transport,this.log=e.logger??console,this.requestTimeoutMs=e.requestTimeoutMs??n,this.genId=e.generateRequestId??(()=>{this.counter=this.counter+1>>>0;let e=Math.random().toString(36).slice(2,8);return`${r}${this.counter.toString(36)}-${e}`}),this.unsubscribe=this.transport.onMessage(e=>{if(!a(e)||e.source!==`offscreen`)return;let t=e.payload;o(t)&&this.handleResult(t)})}readDir(e){let t=this.genId(),n={type:`vfs-read-dir`,requestId:t,path:e};return this.request(t,`vfs-read-dir-result`,e,n)}readFile(e,t){let n=this.genId(),r={type:`vfs-read-file`,requestId:n,path:e,encoding:t?.encoding??`utf-8`};return this.request(n,`vfs-read-file-result`,e,r)}stat(e){let t=this.genId(),n={type:`vfs-stat`,requestId:t,path:e};return this.request(t,`vfs-stat-result`,e,n)}dispose(){this.unsubscribe?.(),this.unsubscribe=null;for(let[,t]of this.pending)t.timer!==null&&clearTimeout(t.timer),t.reject(new e(`EBADF`,`RemoteVfsClient disposed`,t.path));this.pending.clear()}request(t,n,r,i){return new Promise((a,o)=>{let s=null;this.requestTimeoutMs>0&&(s=setTimeout(()=>{this.pending.delete(t)&&o(new e(`EIO`,`vfs-rpc request timed out after ${this.requestTimeoutMs}ms (${n})`,r))},this.requestTimeoutMs)),this.pending.set(t,{resolve:a,reject:o,expect:n,path:r,timer:s});try{this.transport.send(i)}catch(e){this.pending.delete(t),s!==null&&clearTimeout(s),o(e)}})}handleResult(t){let n=this.pending.get(t.requestId);if(!n){t.requestId.startsWith(r)&&this.log.debug?.(`[remote-vfs-client] drop unmatched response`,{type:t.type,requestId:t.requestId});return}if(n.timer!==null&&clearTimeout(n.timer),n.expect!==t.type){this.pending.delete(t.requestId),n.reject(new e(`EIO`,`vfs-rpc response type mismatch (got ${t.type})`,n.path));return}if(this.pending.delete(t.requestId),t.ok===!1){n.reject(s(t.error.code,t.error.message,t.error.path??n.path));return}switch(t.type){case`vfs-read-dir-result`:n.resolve(t.entries);return;case`vfs-read-file-result`:n.resolve(t.data);return;case`vfs-stat-result`:n.resolve(t.stats);return}}};function a(e){return typeof e==`object`&&!!e&&`source`in e&&`payload`in e}function o(e){if(typeof e.requestId!=`string`)return!1;let t=e.type;return t===`vfs-read-dir-result`||t===`vfs-read-file-result`||t===`vfs-stat-result`}function s(t,n,r){let i=[`ENOENT`,`EEXIST`,`ENOTDIR`,`EISDIR`,`ENOTEMPTY`,`EINVAL`,`EACCES`,`ELOOP`,`EBUSY`,`EFBIG`,`EBADF`,`EIO`].includes(t)?t:`EIO`;return new e(i,n,r)}export{t as createRemoteVfsClient};
@@ -1 +0,0 @@
1
- function e(){return{version:`6.97.0`,releasedAt:`2026-08-26T09:47:26Z`,buildId:`6.97.0-mt9wu63g`}}let t=null;function n(e){t=e}function r(){return t}export{e as n,n as r,r as t};