sliccy 6.112.2 → 6.112.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/node-server/bridge-security.d.ts +9 -0
- package/dist/node-server/bridge-security.js +11 -0
- package/dist/node-server/fetch-proxy-headers.d.ts +13 -0
- package/dist/node-server/fetch-proxy-headers.js +19 -0
- package/dist/node-server/hostfs.d.ts +57 -1
- package/dist/node-server/hostfs.js +197 -38
- package/dist/node-server/index.js +6 -11
- package/dist/ui/.vite/manifest.json +162 -145
- package/dist/ui/assets/SKILL-DAPuZ44V.js +1 -0
- package/dist/ui/assets/{account-store-DFb7ccri.js → account-store-B3f-l-jt.js} +1 -1
- package/dist/ui/assets/{account-store-BEm3ZOf4.js → account-store-D70z_yO5.js} +1 -1
- package/dist/ui/assets/{adobe-D4NDqSKt.js → adobe-BRlKLkkQ.js} +1 -1
- package/dist/ui/assets/{adobe-CrYs-_-w.js → adobe-k-m8pmTS.js} +1 -1
- package/dist/ui/assets/{agent-bridge-D2uQgl3Y.js → agent-bridge-BqjAoNUf.js} +1 -1
- package/dist/ui/assets/{agent-panels-SlP4qUD9.js → agent-panels-RneBItRe.js} +1 -1
- package/dist/ui/assets/{apply-layout-Btd25a-I.js → apply-layout-DzjHaXRe.js} +1 -1
- package/dist/ui/assets/{apps-DvB62CHa.js → apps-BEVCpVN0.js} +1 -1
- package/dist/ui/assets/{auto-mount-table-B5XJxoBU.js → auto-mount-table-BRFqHPcB.js} +1 -1
- package/dist/ui/assets/{azure-openai-CwiVZb3U.js → azure-openai-BJ1cYZ2M.js} +1 -1
- package/dist/ui/assets/{azure-openai-pZTdx_lF.js → azure-openai-ChK12_Uk.js} +1 -1
- package/dist/ui/assets/backend-hostfs-CwOm0hxZ.js +1 -0
- package/dist/ui/assets/backend-hostfs-DHZa_yjt.js +1 -0
- package/dist/ui/assets/bounded-walk-C7TvwGQi.js +1 -0
- package/dist/ui/assets/{cerebras-BBG5B3l5.js → cerebras-B9Z6MCch.js} +1 -1
- package/dist/ui/assets/{cerebras-Kr8CGPGL.js → cerebras-DNkVBTks.js} +1 -1
- package/dist/ui/assets/{connect-surface-CZmki_ui.js → connect-surface-CRXNPBGI.js} +1 -1
- package/dist/ui/assets/{directed-approval-DJkc0X5A.js → directed-approval-DNxALRIR.js} +1 -1
- package/dist/ui/assets/fs-80WHk5Hb.js +2 -0
- package/dist/ui/assets/{fs-DrhcgSjY.js → fs-BO4V2Z_q.js} +1 -1
- package/dist/ui/assets/{github-DLvfbIxr.js → github-CFlqk9ps.js} +1 -1
- package/dist/ui/assets/github-CvaDwGdD.js +2 -0
- package/dist/ui/assets/{github-copilot-COHzkV9u.js → github-copilot-B13HlOo9.js} +1 -1
- package/dist/ui/assets/{github-copilot-KpwsmwEN.js → github-copilot-MM8Tpwn2.js} +1 -1
- package/dist/ui/assets/{github-install-ZepK9sNf.js → github-install-Bm_uCKXC.js} +1 -1
- package/dist/ui/assets/{github-zip-DdnZ7Mnj.js → github-zip-Bqtwtfr7.js} +1 -1
- package/dist/ui/assets/{js-realm-worker-DB2Y7zuK.js → js-realm-worker-CHIuQdq-.js} +1 -1
- package/dist/ui/assets/{kernel-worker-CMjt7tHc.js → kernel-worker-BgucGvxZ.js} +597 -597
- package/dist/ui/assets/{local-llm-CtJOiUkB.js → local-llm-DDIpnXLI.js} +1 -1
- package/dist/ui/assets/{local-llm-CHmYak89.js → local-llm-DZLn1YLb.js} +1 -1
- package/dist/ui/assets/{main-CbyCXNIn.js → main-W20AbqqF.js} +3 -3
- package/dist/ui/assets/{mount-Dodh2D8V.js → mount-BhKHPJ0t.js} +3 -3
- package/dist/ui/assets/{mount-DO3EG6PG.js → mount-CjD6A-dA.js} +1 -1
- package/dist/ui/assets/{mount-recovery-DixhqwBC.js → mount-recovery-DJ-Bvidw.js} +1 -1
- package/dist/ui/assets/{new-session-B8nhZDEn.js → new-session-CG86gx28.js} +2 -2
- package/dist/ui/assets/{oauth-bootstrap-BkzTKBfF.js → oauth-bootstrap-BXVy8GOk.js} +2 -2
- package/dist/ui/assets/{openai-codex-DJr9IgkK.js → openai-codex-BUJorx66.js} +1 -1
- package/dist/ui/assets/{openai-codex-BIKDqKu_.js → openai-codex-BsOK_EUW.js} +1 -1
- package/dist/ui/assets/{openrouter-B9IxwYeV.js → openrouter-BrxyoCbR.js} +1 -1
- package/dist/ui/assets/{openrouter-DH4eLV-K.js → openrouter-C8LIcw5U.js} +1 -1
- package/dist/ui/assets/{openrouter-oauth-CQJY8i6t.js → openrouter-oauth-BTZCdA38.js} +1 -1
- package/dist/ui/assets/{openrouter-oauth-BWsz3-ge.js → openrouter-oauth-D64Ebhmz.js} +1 -1
- package/dist/ui/assets/{panel-rpc-handlers-DH7xx1M0.js → panel-rpc-handlers-DP4QW2_r.js} +2 -2
- package/dist/ui/assets/{panelize-shell-k--mebzt.js → panelize-shell-D8SpCM1_.js} +1 -1
- package/dist/ui/assets/{provider-ClUAbw1j.js → provider-DBXUieC5.js} +1 -1
- package/dist/ui/assets/{provider-CDbrFirS.js → provider-Do7aOOtm.js} +2 -2
- package/dist/ui/assets/{provider-settings-IGWxggS0.js → provider-settings-Bk6Nzxxq.js} +1 -1
- package/dist/ui/assets/{provider-settings-Dca6XryJ.js → provider-settings-Cqxptsvs.js} +1 -1
- package/dist/ui/assets/provider-store-access-DGN2DE_L.js +2 -0
- package/dist/ui/assets/provider-store-access-d0qE5Z_s.js +1 -0
- package/dist/ui/assets/{providers-W21iBf-y.js → providers-BS3QLLDk.js} +1 -1
- package/dist/ui/assets/{providers-CVZc7zSe.js → providers-w3UpuVJ7.js} +2 -2
- package/dist/ui/assets/{quick-llm-BO0uuygb.js → quick-llm-eNqWcO0a.js} +1 -1
- package/dist/ui/assets/{recovery-screen-0xv_XYuL.js → recovery-screen-d59NpLgV.js} +1 -1
- package/dist/ui/assets/remote-sprinkle-vfs-PoLlJ0Bo.js +1 -0
- package/dist/ui/assets/{run-CcUi-QR8.js → run-DTiJh7fB.js} +2 -2
- package/dist/ui/assets/{run-oqzFNdad.js → run-MBbACQaU.js} +1 -1
- package/dist/ui/assets/{session-freezer-D6A9ph34.js → session-freezer-Dcstn02C.js} +3 -3
- package/dist/ui/assets/{setup-feature-flags-remote-DQ12tLeR.js → setup-feature-flags-remote-MUihR7_C.js} +1 -1
- package/dist/ui/assets/{setup-standalone-prelude-C4hTP-NY.js → setup-standalone-prelude-D-My7gqn.js} +1 -1
- package/dist/ui/assets/{setup-sudo-Bv52MwOC.js → setup-sudo-DWVKfxX5.js} +2 -2
- package/dist/ui/assets/{skills-CRrnKp2n.js → skills-C4OPb7lv.js} +1 -1
- package/dist/ui/assets/slicc-version-P9XLGLfH.js +1 -0
- package/dist/ui/assets/sprinkle-manager-CwFBoRrT.js +1 -0
- package/dist/ui/assets/{state-BlkDfTVY.js → state-B-6qOUGY.js} +1 -1
- package/dist/ui/assets/{store-za51L75Y.js → store-CJOsAi2B.js} +1 -1
- package/dist/ui/assets/{store-ljIGz9wi.js → store-DKaVNOdU.js} +1 -1
- package/dist/ui/assets/{sudo-JK66KVfq.js → sudo-CNW0dVE5.js} +1 -1
- package/dist/ui/assets/{upgrade-detection-DayCJLDc.js → upgrade-detection-DvWUyLV6.js} +1 -1
- package/dist/ui/assets/walker-DBIHfELE.js +1 -0
- package/dist/ui/assets/{wc-attach-CCbv56td.js → wc-attach-CU3BE3l1.js} +2 -2
- package/dist/ui/assets/{wc-extension-daiiHAwe.js → wc-extension-ZJGWvF9c.js} +2 -2
- package/dist/ui/assets/{wc-float-label-CYQ1O9IG.js → wc-float-label-CbDdlGLO.js} +1 -1
- package/dist/ui/assets/{wc-floatbar-online-DOvI2Gz9.js → wc-floatbar-online-C0IuZZKr.js} +1 -1
- package/dist/ui/assets/{wc-follower-CmtSqM4T.js → wc-follower-CTyxrOzu.js} +3 -3
- package/dist/ui/assets/{wc-follower-oauth-CfVGAzoz.js → wc-follower-oauth-SkmauQIC.js} +1 -1
- package/dist/ui/assets/{wc-live-CEb85_ni.js → wc-live-9pvTjifM.js} +4 -4
- package/dist/ui/assets/{wc-nav-9JsFLg8Q.js → wc-nav-BE5dy4LG.js} +2 -2
- package/dist/ui/assets/{wc-onboarding-INB8m-An.js → wc-onboarding-xdhdNGcZ.js} +2 -2
- package/dist/ui/assets/{wc-placeholder-KVfEJPvC.js → wc-placeholder-Cf022JY0.js} +2 -2
- package/dist/ui/assets/{wc-settings-Dh7v_Gm7.js → wc-settings-m4Ir4Q6n.js} +2 -2
- package/dist/ui/assets/{wc-shell-vKd9u5Qb.js → wc-shell-Cn5weYPT.js} +2 -2
- package/dist/ui/assets/{wc-shortcut-config-DNWWZUqP.js → wc-shortcut-config-DZ0FRyoV.js} +1 -1
- package/dist/ui/assets/{wc-sprinkles-BbjnvtOw.js → wc-sprinkles-a5wgtCTP.js} +2 -2
- package/dist/ui/assets/{wc-tray-B-HO43dD.js → wc-tray-mjZWSM63.js} +4 -4
- package/dist/ui/assets/{xai-grok-S5ay2Ab2.js → xai-grok-BWiDrNsj.js} +1 -1
- package/dist/ui/assets/{xai-grok-BAMOZLLE.js → xai-grok-weW--uzN.js} +1 -1
- package/dist/ui/index.html +6 -6
- package/dist/ui/packages/webapp/index.html +6 -6
- package/package.json +1 -1
- package/dist/ui/assets/SKILL-WFB8Hz-G.js +0 -1
- package/dist/ui/assets/backend-hostfs-Com-zF5W.js +0 -1
- package/dist/ui/assets/backend-hostfs-bQQx-S0W.js +0 -1
- package/dist/ui/assets/fs-C7Q7Gwx0.js +0 -2
- package/dist/ui/assets/github-2ePt7Y4O.js +0 -2
- package/dist/ui/assets/provider-store-access-CjkPfBXV.js +0 -1
- package/dist/ui/assets/provider-store-access-CxUkiz_V.js +0 -2
- package/dist/ui/assets/remote-sprinkle-vfs-CawR6gXx.js +0 -1
- package/dist/ui/assets/slicc-version-0JCDQACw.js +0 -1
- package/dist/ui/assets/sprinkle-manager-DjLsrQSV.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as e,n as t}from"./account-store-
|
|
1
|
+
import{g as e,n as t}from"./account-store-D70z_yO5.js";import{a as n}from"./diagnostics-DN_idNHx.js";import{a as r,r as i}from"./compat-uEPf6-XW.js";import{c as a,i as o,r as s,s as c}from"./legacy-api-aliases-jKEvBgOL.js";import"./provider-settings-Cqxptsvs.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 i(`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}function M(e){console.error(`[xai-grok] Stream error:`,e instanceof Error?e.message:String(e))}async function N(e,t,n,r){try{let i=await k(),a=r.sessionId,c=T(t),l={...r,apiKey:i,headers:j(r.headers,a)},u=c.api===`openai-responses`?o(c,n,l):s(c,n,l);for await(let t of u)e.push(t);e.end()}catch(n){M(n),e.push(A(t,n)),e.end()}}async function P(e,t,n,r){try{let i=await k(),o=r?.sessionId,s=T(t),l={...r,apiKey:i,headers:j(r?.headers,o)},u=s.api===`openai-responses`?a(s,n,l):c(s,n,l);for await(let t of u)e.push(t);e.end()}catch(n){M(n),e.push(A(t,n)),e.end()}}const F=(e,t,r={})=>{let i=n();return N(i,e,t,r).catch(M),i},I=(e,t,r)=>{let i=n();return P(i,e,t,r).catch(M),i},L={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 R(){r({api:S,stream:F,streamSimple:I})}export{f as XaiErrorCode,p as XaiOAuthError,L as config,R as register};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{H as e,d as t}from"./account-store-
|
|
1
|
+
import{H as e,d as t}from"./account-store-B3f-l-jt.js";import{a as n}from"./diagnostics-DN_idNHx.js";import{c as r,u as i}from"./claude-model-version-BJLrDjmH.js";import{c as a,i as o,r as s,s as c}from"./legacy-api-aliases-45zvHmpJ.js";import"./provider-settings-Bk6Nzxxq.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}function P(e){console.error(`[xai-grok] Stream error:`,e instanceof Error?e.message:String(e))}async function F(e,t,n,r){try{let i=await j(),a=r.sessionId,c=D(t),l={...r,apiKey:i,headers:N(r.headers,a)},u=c.api===`openai-responses`?o(c,n,l):s(c,n,l);for await(let t of u)e.push(t);e.end()}catch(n){P(n),e.push(M(t,n)),e.end()}}async function I(e,t,n,r){try{let i=await j(),o=r?.sessionId,s=D(t),l={...r,apiKey:i,headers:N(r?.headers,o)},u=s.api===`openai-responses`?a(s,n,l):c(s,n,l);for await(let t of u)e.push(t);e.end()}catch(n){P(n),e.push(M(t,n)),e.end()}}var L=(e,t,r={})=>{let i=n();return F(i,e,t,r).catch(P),i},R=(e,t,r)=>{let i=n();return I(i,e,t,r).catch(P),i},z={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 B(){i({api:w,stream:L,streamSimple:R})}export{f as XaiErrorCode,p as XaiOAuthError,z as config,B as register};
|
package/dist/ui/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>slicc</title>
|
|
7
7
|
<link rel="icon" type="image/png" href="/logos/sliccy-color-1scoops-32x32.png" />
|
|
8
|
-
<script type="module" crossorigin src="/assets/main-
|
|
8
|
+
<script type="module" crossorigin src="/assets/main-W20AbqqF.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-H8-Z1RVR.js">
|
|
31
31
|
<link rel="modulepreload" crossorigin href="/assets/image-markers-CxJ9ZBgw.js">
|
|
32
32
|
<link rel="modulepreload" crossorigin href="/assets/tool-ui-eSQ1g2I1.js">
|
|
33
|
-
<link rel="modulepreload" crossorigin href="/assets/providers-
|
|
33
|
+
<link rel="modulepreload" crossorigin href="/assets/providers-w3UpuVJ7.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-
|
|
36
|
+
<link rel="modulepreload" crossorigin href="/assets/account-store-B3f-l-jt.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-CluPgaPA.js">
|
|
40
|
-
<link rel="modulepreload" crossorigin href="/assets/setup-sudo-
|
|
41
|
-
<link rel="modulepreload" crossorigin href="/assets/setup-standalone-prelude-
|
|
40
|
+
<link rel="modulepreload" crossorigin href="/assets/setup-sudo-DWVKfxX5.js">
|
|
41
|
+
<link rel="modulepreload" crossorigin href="/assets/setup-standalone-prelude-D-My7gqn.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-
|
|
47
|
+
<link rel="modulepreload" crossorigin href="/assets/provider-settings-Bk6Nzxxq.js">
|
|
48
48
|
</head>
|
|
49
49
|
<body>
|
|
50
50
|
<div id="app"></div>
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>slicc</title>
|
|
7
7
|
<link rel="icon" type="image/png" href="/logos/sliccy-color-1scoops-32x32.png" />
|
|
8
|
-
<script type="module" crossorigin src="/assets/main-
|
|
8
|
+
<script type="module" crossorigin src="/assets/main-W20AbqqF.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-H8-Z1RVR.js">
|
|
31
31
|
<link rel="modulepreload" crossorigin href="/assets/image-markers-CxJ9ZBgw.js">
|
|
32
32
|
<link rel="modulepreload" crossorigin href="/assets/tool-ui-eSQ1g2I1.js">
|
|
33
|
-
<link rel="modulepreload" crossorigin href="/assets/providers-
|
|
33
|
+
<link rel="modulepreload" crossorigin href="/assets/providers-w3UpuVJ7.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-
|
|
36
|
+
<link rel="modulepreload" crossorigin href="/assets/account-store-B3f-l-jt.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-CluPgaPA.js">
|
|
40
|
-
<link rel="modulepreload" crossorigin href="/assets/setup-sudo-
|
|
41
|
-
<link rel="modulepreload" crossorigin href="/assets/setup-standalone-prelude-
|
|
40
|
+
<link rel="modulepreload" crossorigin href="/assets/setup-sudo-DWVKfxX5.js">
|
|
41
|
+
<link rel="modulepreload" crossorigin href="/assets/setup-standalone-prelude-D-My7gqn.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-
|
|
47
|
+
<link rel="modulepreload" crossorigin href="/assets/provider-settings-Bk6Nzxxq.js">
|
|
48
48
|
</head>
|
|
49
49
|
<body>
|
|
50
50
|
<div id="app"></div>
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e='---\nname: sprinkles\ndescription: |\n Use this when the user wants a persistent UI panel — a dashboard, form,\n editor, report, or visualization that lives alongside the chat. Sprinkles are\n `.shtml` files under `/shared/sprinkles/` rendered in the side rail or as a\n full-screen tab. For ephemeral inline widgets, use dips instead. Covers\n creation, modification, layout constraints, the cone-to-scoop orchestration\n rules, the `slicc.*` bridge API, and `sprinkle chat` for blocking inline\n prompts.\nallowed-tools: bash, read_file, write_file, edit_file\n---\n\n# Sprinkles\n\n`.shtml` files in `/shared/sprinkles/` become interactive UI panels. Use them for dashboards, forms, and visualizations that persist alongside the chat.\n\n## Two rendering modes\n\n- **Fragment mode** (default): plain HTML fragments injected into the sidebar. Do NOT use `<!DOCTYPE html>`, `<html>`, `<head>`, `<body>`, or custom CSS — use the built-in `.sprinkle-*` classes. Scripts get a `slicc` bridge object automatically.\n- **Full-document mode**: complete HTML documents (starting with `<!DOCTYPE html>` or `<html>`) render inside sandboxed iframes. Use this for complex layouts with custom CSS, sidebars, split panes, modals, or canvas/SVG visualizations. The bridge script is auto-injected — `window.slicc` and `window.bridge` are available. The parent page\'s S2 theme tokens are injected automatically.\n\nPick full-document mode when you need custom CSS beyond `.sprinkle-*` classes, complex layouts (sidebar + main, split panes, tabs), or interactive canvas/SVG.\n\n## Light & dark mode\n\nTheming is **automatic**. The parent injects its S2 tokens into every sprinkle and toggles a `.theme-light` class on the sprinkle root — the iframe\'s `<html>` in full-document mode, or the outermost container injected into the sidebar in fragment mode — whenever the user flips the parent theme. All `var(--s2-*)` tokens swap in lockstep. **Never hard-code colors for one theme.**\n\n- Use S2 tokens (`var(--s2-content-default)`, `var(--s2-bg-layer-2)`, etc.) for everything — see `style-guide.md` for the full reference.\n- For one-off colors not covered by an S2 token, use CSS `light-dark(<light>, <dark>)` and set `color-scheme: light dark` on an ancestor (the root in full-document mode, the outermost container in fragment mode). `light-dark()` returns the dark value only when `color-scheme` is set. This intentionally follows the user\'s OS `color-scheme` preference for one-off custom colors; S2 tokens still track the parent app\'s class-based theme toggle in lockstep.\n- **Do NOT use `@media (prefers-color-scheme: ...)`** to swap colors that should mirror the parent app\'s theme. The parent\'s theme toggle is a class on the sprinkle root, not the OS preference, so media queries desync from the actual app theme. Use S2 tokens (class-driven) or `light-dark()` (OS-driven, for one-off custom colors only) instead.\n\n## Layout & viewport\n\nSprinkles open in **one of four viewport contexts**, and you must design for the narrowest:\n\n| Float | Default viewport | Multi-column safe? |\n| -------------------------------- | -------------------------------------- | ----------------------- |\n| Desktop (CLI / Electron) sidebar | Narrow rail (≈ 360 px) | No — single column only |\n| Desktop full-screen pop-out | Full window | Yes |\n| iOS / Sliccstart app frame | Full-width but always single-column UX | No |\n| Chrome extension side panel | Narrow (≈ 360 px, fixed by Chrome) | No |\n\n**Default to a single-column layout.** Multi-column layouts (sidebar + main, split panes, three-up grids) only render usefully when the user explicitly pops the sprinkle to full-screen on desktop. They look broken in the rail and on iOS.\n\nIf you genuinely need multi-column UI, do all of the following:\n\n1. Build it in **full-document mode** so you can use grid / flex / media queries cleanly.\n2. Use `@media (max-width: 600px)` (or similar) to collapse to single column at narrow widths so the sidebar/iOS view still works.\n3. Tell the user in your reply that this sprinkle is "best viewed full-screen — pop it out from the rail header."\n\nFor dashboards with many widgets, prefer a vertical stack of `.sprinkle-card` blocks over a grid. The card stack is responsive by default and looks good in both rail and full-screen.\n\n## Arranging panels with `layout`\n\nThe `layout` shell command arranges panels, independent of what\'s inside each one.\nEvery panel is the same kind of thing: chat, each tool panel, and each sprinkle.\n\n```bash\nlayout list # shipped presets (there is one: the default)\nlayout set <preset> # reset to a shipped arrangement\nlayout save <name> # save the CURRENT arrangement as JSON\nlayout load <name> # load a saved layout or the shipped default\nlayout open <surfaceId> <zone> # place a panel (zone: top|left|middle|right|bottom)\nlayout move <surfaceId> <zone> # relocate a placed panel\nlayout close <surfaceId> # remove it (chat is pinned; it can move, never close)\nlayout size <surfaceId> [--width <px|%>] [--height <px|%>] # exact, pixel-perfect\nlayout chat <zone> # move the chat panel\nlayout reset # back to the default\n```\n\nSLICC ships exactly ONE arrangement (the default). To give a skill its own layout,\narrange the panels and `layout save <name>` — do not expect named presets beyond the\ndefault to exist.\n\nOpening a sprinkle auto-places it, so `layout open` is only for overriding that.\n`layout size` is the programmatic counterpart to a user dragging a divider — use it\nwhen you want an exact size rather than a proportion.\n\nThe five zones are `top`, `left`, `center`, `right`, `bottom` — Java `BorderLayout`.\nThey sit inside the fixed chrome, so `top` is below the scoop/budget strip and\n`left`/`right` are inboard of the rails. A zone holds several panels at once, so\nplacing two sprinkles in `left` puts them both there (stacked by default).\n\n### Writing a layout JSON by hand\n\nA layout document has two sections, and **you only ever write `zones`**:\n\n```jsonc\n{\n "version": 1,\n "id": "my-layout",\n "base": {\n // DO NOT AUTHOR. The fixed chrome — scoop/budget strip, both rails. Copy it\n // verbatim from an existing document, or omit it to keep the shipped chrome.\n "docks": [...],\n // YOURS. Which panels go in which of the five zones.\n "zones": {\n "top": ["sprinkle:status-panel"],\n "left": ["chat"],\n "right": ["sprinkle:main-window"],\n "sizes": { "top": "180px", "left": "40%" }\n }\n }\n}\n```\n\nA "status bar across the top, below the SLICC bar, between the rails" is\n`zones.top` — NOT a second `docks` entry with `edge: "top"`. `docks` is the app\'s\nown chrome; adding to it puts your panel in the same strip as the scoop switcher and\nthe price counter. Reach for `zones` every time.\n\nPrefer `layout save` over hand-writing JSON: arrange the panels with `layout\nopen`/`move`/`size`, then save. Hand-editing is for shipping a layout with a skill.\n\nThe user can also rearrange by hand — there is no edit mode to enter. Hovering a\npanel reveals a grip in its top-left corner; grabbing it shows the five zones as a\ncompass. Two kinds of seam drag to resize: between panels inside a zone, and\nbetween the zones themselves. Their arrangement\npersists across reloads, so do NOT re-issue `layout` commands to "restore" a layout\nyou set earlier — you would be overwriting what they did.\n\nOn a narrow viewport (extension side panel, iOS, ≤700px) multi-panel arrangements\ncollapse to chat alone, so still design each sprinkle single-column-safe per the\ntable above.\n\n## Are panels always sprinkles?\n\nNo — but a sprinkle is the only kind YOU can create, and that is the intended path.\n\n| Kind | Who makes it | How |\n| --------------- | ---------------- | -------------------------------------------------------------- |\n| Sprinkle panel | you | write `.shtml`, `sprinkle open <name>` — this section |\n| Built-in panel | ships with SLICC | chat, both rails, the top strip, files/terminal/memory/monitor |\n| Layout document | you | JSON naming which panels go where; `layout save`/`load` |\n\nSo: to add UI, write a sprinkle. To rearrange existing UI, write a layout document\nor issue `layout` commands. There is no third mechanism, and no need for one — a\nsprinkle is a full HTML document with a bridge, which covers what a custom panel\nwould.\n\nA sprinkle IS tied to a scoop, and that is deliberate: whoever creates one owns it\nfor its lifetime and handles its lick events (see "Handling lick events" below).\nA layout document is not tied to anything — it only names panel ids.\n\n### Shipping UI with a skill\n\nA layout document saved under `/workspace/layouts/<name>.json` can be loaded with\n`layout load <name>`, so a skill can ship both its sprinkles and the arrangement\nthat presents them. Write the sprinkles, open them, arrange, then `layout save\n<name>` to capture what is on screen.\n\n## Creating a sprinkle\n\n1. `read_file /workspace/skills/sprinkles/style-guide.md` — **always read first** before writing any sprinkle.\n2. **Pick a rail icon** that matches the sprinkle\'s purpose (see "Sprinkle icon" below). Every new sprinkle MUST declare an icon — the generic Sparkles default is reserved for sprinkles that genuinely have no thematic anchor.\n3. `write_file` to `/shared/sprinkles/<name>/<name>.shtml` (follow the style guide templates).\n4. `bash` → `sprinkle open <name>`.\n5. **CRITICAL: do NOT finish or send a completion message.** You own this sprinkle for its entire lifetime. The cone will send you follow-up instructions (modifications, lick events) via `feed_scoop`. If you finish, you lose your context and cannot handle future work on this sprinkle.\n\n### Updating a sprinkle (when you receive follow-up instructions)\n\n1. Edit `/shared/sprinkles/<name>/<name>.shtml` with the requested changes.\n2. Reload: `sprinkle close <name> && sprinkle open <name>`.\n3. Do NOT finish — stay ready for more instructions.\n\n### Handling lick events (when the cone forwards a user interaction)\n\nThe cone will send you a message with the lick action and your sprinkle name. Only modify YOUR sprinkle — the one matching your scoop name. Process the action and push updates:\n\n- `bash` → `sprinkle send <name> \'{"key":"value"}\'` to push data to the sprinkle\'s `slicc.on(\'update\', ...)` handler.\n- Or edit the `.shtml` file and reload if the UI structure needs to change.\n- Do NOT finish — stay ready for more events.\n\n## Sprinkle icon\n\nEach sprinkle gets its own glyph in the rail so users can tell them apart at a glance. Declare it in the `.shtml`. Three formats, in order of preference:\n\n**1. Lucide icon name** (preferred — covers ~1500 icons from [lucide.dev/icons](https://lucide.dev/icons)):\n\n```html\n<link rel="icon" href="music" />\n```\n\nUse the kebab-case name from lucide.dev. Common picks: `music`, `code`, `terminal`, `chart-bar`, `chart-line`, `calendar`, `calendar-clock`, `clock`, `image`, `file-text`, `globe`, `book-open`, `compass`, `gauge`, `wrench`, `palette`, `bug`, `flask-conical`, `database`, `cloud`, `package`, `shopping-cart`, `dollar-sign`, `mail`, `message-square`, `bell`, `users`, `user`, `settings`, `sparkles`.\n\n**2. SVG file in the sprinkle\'s directory** (when no Lucide icon fits):\n\n```html\n<link rel="icon" href="/shared/sprinkles/<name>/icon.svg" />\n```\n\nAuthor the SVG with `viewBox="0 0 24 24"`. Keep paths simple — the rail renders at 16×16. **Note**: only Lucide icons inherit `currentColor` from the rail; author-supplied SVGs render through `<img>` (script-disabled), so set explicit colors in the SVG itself.\n\n**3. Inline SVG or data URL** (one-off icons, no extra file):\n\n```html\n<link\n rel="icon"\n href=\'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="..."/></svg>\'\n/>\n```\n\n**Where to put it**: inside `<head>` for full-document mode, or as the very first element in fragment mode.\n\n**Quoting tip**: when the `href` value contains quotes (inline-SVG data URLs do), wrap the attribute in single quotes: `href=\'data:image/svg+xml;utf8,<svg xmlns="...">...\'`.\n\n**Fallback**: if the icon spec is missing or unresolvable, the rail uses a generic Sparkles glyph.\n\n## Cone orchestration rules\n\nThese are the rules the cone follows when sprinkles are involved. They are absolute.\n\n### Rule 1: One scoop per sprinkle, named identically\n\nScoop name MUST match sprinkle name. Sprinkle `giro-winners` = scoop `giro-winners`.\n\n### Rule 2: Cone never touches sprinkle files or commands\n\nThe cone MUST NOT: write/edit `.shtml` files, run `sprinkle open / close / send`, or handle lick events directly. ALL sprinkle work goes through scoops via `feed_scoop`. **Never handle a lick in the cone.**\n\n### Rule 3: Creating sprinkles\n\nCreate a scoop, then feed it a complete, self-contained brief:\n\n```\nscoop_scoop("giro-winners")\nfeed_scoop("giro-winners", "You own the sprinkle \'giro-winners\'. Your job:\n1. Run: read_file /workspace/skills/sprinkles/style-guide.md\n2. Research the last 3 Giro d\'Italia winners\n3. Pick a rail icon — for cycling, use <link rel=\\"icon\\" href=\\"bike\\" /> in <head>. See the sprinkles SKILL.md \\"Sprinkle icon\\" section for the full list.\n4. Write the sprinkle to /shared/sprinkles/giro-winners/giro-winners.shtml\n5. Run: sprinkle open giro-winners\n6. IMPORTANT: After opening the sprinkle, do NOT finish. Stay ready — you will receive follow-up instructions and lick events for this sprinkle via feed_scoop. Do not send a completion message.")\n```\n\n### Rule 4: Modifying sprinkles\n\nFeed the EXISTING scoop that owns it. Do NOT create a new scoop:\n\n```\nfeed_scoop("giro-winners", "Modify YOUR sprinkle \'giro-winners\' at /shared/sprinkles/giro-winners/giro-winners.shtml:\nAdd an \'Add Previous Year\' button with onclick=\\"slicc.lick({action: \'add-year\'})\\"\nThen reload: sprinkle close giro-winners && sprinkle open giro-winners\nStay ready for more work.")\n```\n\n### Rule 5: Lick events\n\nForward to the owning scoop, never handle yourself:\n\n```\nfeed_scoop("giro-winners", "Lick event on YOUR sprinkle \'giro-winners\' (/shared/sprinkles/giro-winners/giro-winners.shtml):\nAction: \'add-year\'\nLook up the next previous year\'s Giro d\'Italia winner and update the sprinkle.\nUse: sprinkle send giro-winners \'<json>\' to push data, or edit the .shtml and reload.\nStay ready for more lick events.")\n```\n\n## Cheap interactions via `agent`\n\nWhen a sprinkle button needs to do real work but the owning scoop should NOT be pulled into a turn (it\'s busy, or the work is purely transactional), route the lick handler through `agent` instead.\n\nPattern:\n\n1. User clicks → `slicc.lick({action: \'lookup\', data: {q: \'foo\'}})`.\n2. Cone sees the lick, forwards to the owning scoop with `feed_scoop`.\n3. The scoop\'s reply runs `agent` against a tight allow-list and writes the result back via `sprinkle send`.\n\n```bash\n# Inside the owning scoop\'s reply to a lick:\nresult=$(agent "$TMPDIR" "curl,jq" "Look up \'$Q\' in <api>, return the price.")\nsprinkle send giro-winners "$(jq -n --arg r "$result" \'{result:$r}\')"\n```\n\nWhy this matters: a busy scoop that owns a sprinkle can shell to `agent` to handle a click without growing its own conversation. `agent` is **handoff-free** — the ephemeral sub-scoop doesn\'t notify the cone or the owning scoop on completion. See `/workspace/skills/delegation/SKILL.md` for the full `agent` reference.\n\nThis is the difference between "every click adds a turn to your owning scoop" (expensive, drifts) and "every click is a clean transaction" (predictable, cheap).\n\n## Managing sprinkles via bash\n\n- `sprinkle list` — available sprinkles, plus one `instance:` line per runtime rendering each (leader + reporting followers). `--runtime <id>` narrows it.\n- `sprinkle open <name>` — show a sprinkle in the sidebar.\n- `sprinkle close <name>` — remove it.\n- `sprinkle send <name> \'<json>\'` — push data (single-quote the JSON!). **Broadcasts** to every open instance, leader and followers. Prints the instances reached; exits non-zero when it reached none, so a vanished push is visible.\n- `sprinkle send <name> \'<json>\' --runtime <id>` — push to ONE runtime (ids from `host`; `leader` is the local one). Use it to answer a `request-load` from a specific follower panel.\n- Unknown flags are rejected, so a probe that exits 0 means the flag was honoured.\n- `sprinkle chat \'<html>\'` — show inline HTML in the chat (for quick confirmations / choices). Blocks until the user clicks; returns the lick result as JSON. Use when a tool needs user input mid-execution.\n- `open /path/to/file.shtml` — also opens as a sprinkle.\n\n```bash\nsprinkle chat \'<div class="sprinkle-action-card">\n <div class="sprinkle-action-card__header">Deploy to production?</div>\n <div class="sprinkle-action-card__actions">\n <button class="sprinkle-btn sprinkle-btn--secondary" onclick="slicc.lick({action:\\"cancel\\"})">Cancel</button>\n <button class="sprinkle-btn sprinkle-btn--primary" onclick="slicc.lick({action:\\"deploy\\",data:{env:\\"prod\\"}})">Deploy</button>\n </div>\n</div>\'\n```\n\n## Bridge API\n\nAvailable as `slicc` in `<script>` tags and `onclick` attributes:\n\n- `slicc.lick(event)` — send a lick event to the cone (cone routes to the right scoop). Accepts a string shortcut (`slicc.lick(\'cancel\')` → `{ action: \'cancel\' }`) or `{ action, data? }`. See payload-shape note below.\n- `slicc.on(\'update\', function(data) {...})` — receive data sent via `sprinkle send`.\n\n> **Payload shape:** the cone reads `event.data` as the payload — top-level extras outside `action` and `data` are silently dropped by the sprinkle bridge. Always use `slicc.lick({ action: \'deploy\', data: { env: \'prod\' } })`, not `slicc.lick({ action: \'deploy\', env: \'prod\' })`.\n\n- `slicc.name` — the sprinkle\'s name.\n- `slicc.close()` — close the sprinkle.\n- `slicc.minimize()` — collapse the sprinkle panel (rail icon stays visible; user can click to reopen). Does not close or destroy the sprinkle.\n- `slicc.stopCone()` — stop the cone agent.\n- `slicc.readFile(path)` — read a VFS file (returns `Promise<string>`).\n- `slicc.writeFile(path, content)` — write text content to a VFS file.\n- `slicc.readDir(path)` — list directory entries (returns `Promise<Array<{name, type}>>`).\n- `slicc.exists(path)` — check if path exists (returns `Promise<boolean>`).\n- `slicc.stat(path)` — get file metadata (returns `Promise<{type, size}>`).\n- `slicc.mkdir(path)` — create a directory (recursive).\n- `slicc.rm(path)` — remove a file.\n- `slicc.screenshot(selector?)` — capture sprinkle DOM as base64 PNG data URL. Note: the screenshot captures a DOM clone using SVG foreignObject. External stylesheets and some computed styles may not be fully reproduced. For best results, use inline styles on elements you intend to screenshot.\n- `slicc.captureScreen()` — capture a screen, window, or browser tab via Chrome\'s native picker. Takes no arguments. Returns `Promise<{base64: string, width: number, height: number, mimeType: string}>`. The picker appears immediately; the Promise resolves once the user selects a target and the frame is grabbed. Rejects if the user cancels or screen capture is unavailable. Use `slicc.attachImage(shot.base64, \'screenshot.png\', shot.mimeType)` to send the result to the agent. Key difference from `screenshot()`: this captures external content (any tab/window/screen), not the sprinkle\'s own DOM.\n\n### Shell, agent, and jsh globals\n\nThe bridge also reaches the **same worker shell** that `.jsh` scripts and `node -e` run in, so a sprinkle can call any supplemental command, any `.jsh` script, or spawn a sub-scoop directly from a button. These mirror the capability bridges reached from `.jsh` via `require(\'sliccy:<name>\')` (documented in `/workspace/skills/skill-authoring/jsh-runtime-extensions.md`). Sprinkle code keeps using the trust-gated `slicc.*` namespace; it does not call `require(\'sliccy:…\')` directly.\n\n- `slicc.exec(cmd)` — run a shell command in the worker shell. Returns `Promise<{stdout, stderr, exitCode}>`. A non-zero `exitCode` (or `127` when the shell bridge is unavailable) is returned in the result, never thrown. Use `slicc.exec.spawn(argv)` to bypass shell parsing for untrusted args.\n- `slicc.agent(prompt, opts?)` — spawn a one-shot sub-scoop, feed it `prompt`, block until it completes, and resolve with its final message on `stdout`. Returns `Promise<{stdout, exitCode}>`. `opts`: `{cwd?, allowedCommands?, model?, thinking?, readOnly?}`. Sugar over `slicc.exec` building the `agent` command — the same handoff-free delegation as the `agent` shell command. On failure the error text comes back on `stdout` with a non-zero `exitCode`, never thrown.\n- `slicc.fetch(url, init?)` — proxied, secret-injecting fetch (NOT the iframe\'s CORS-bound native fetch). Resolves to a native `Response` (with `.json()`/`.text()`/`.arrayBuffer()`/`.blob()` and `.ok`/`.status`/`.headers`/`.url`).\n- `slicc.http.client(config)` — higher-level API client over the proxied fetch (`get`/`post`/`put`/`patch`/`delete`). `config`: `{baseUrl?, token?, headers?, retry?, timeoutMs?}`.\n- `slicc.browser.*` — Playwright-style CDP surface (`findTab`, `ensureTab`, `eval`, `evalAsync`, `cookie`, `localStorage`, `fetch`), mirroring `require(\'sliccy:browser\')` in jsh.\n- `slicc.fetchToFile(url, path)` — download a URL (via the proxied fetch) straight to a VFS file; resolves with the byte count.\n- `slicc.readFileBinary(path)` / `slicc.writeFileBinary(path, bytes)` — binary VFS I/O (parity with `require(\'fs\')` in jsh).\n- `slicc.hid.*` / `slicc.serial.*` / `slicc.usb.*` — stateful device surfaces for WebHID / Web Serial / WebUSB (Chromium-only; absent in the cloud / hosted-leader float). Same opaque handles (`hid1`, `serial1`, `usb1`, …) as the `hid` / `serial` / `usb` shell commands and the `require(\'sliccy:hid\' | \'sliccy:serial\' | \'sliccy:usb\')` realm modules — discover via `list()` or trigger the OS picker via `request()` (a button-click is a real user gesture). For HID, `open(handle)` auto-attaches the input-report stream so every `slicc.hid.on(\'inputreport\', cb)` listener receives `{ handle, reportId, data: Uint8Array }` until `close(handle)` or sprinkle teardown. Use this for keyboard configurators, gamepad dashboards, ESP32 monitor panels — anything that needs a persistent device session across multiple button clicks. The realm bridge in `slicc.exec(\'node -e …\')` resets per call, so push handle ops through `slicc.hid|serial|usb` instead.\n\n```typescript\n// HID — stateful across the sprinkle\'s lifetime\nslicc.hid.list(): Promise<HidDeviceInfo[]>\nslicc.hid.request(filters?): Promise<HidDeviceInfo[]> // needs button-click gesture\nslicc.hid.open(handle): Promise<void> // auto-subscribes inputreport\nslicc.hid.close(handle): Promise<void>\nslicc.hid.sendReport(handle, reportId, data: Uint8Array): Promise<void>\nslicc.hid.on(\'inputreport\', cb): void // cb: ({ handle, reportId, data })\nslicc.hid.off(\'inputreport\', cb): void\n\n// Serial / USB — parity list/request/open/close; streaming I/O stays on the realm API.\nslicc.serial.list() / request(filters?) / open(handle, options) / close(handle)\nslicc.usb.list() / request(filters?) / open(handle) / close(handle)\n```\n\n```html\n<button\n id="connect"\n onclick="slicc.hid.request({vendorId:0x320f}).then(d => slicc.hid.open(d[0].handle))"\n>\n Connect keyboard\n</button>\n<script>\n slicc.hid.on(\'inputreport\', ({ reportId, data }) => {\n console.log(\'report\', reportId, [...data].map((b) => b.toString(16)).join(\' \'));\n });\n<\/script>\n```\n\n```html\n<button\n onclick="slicc.exec(\'git status -s\').then(r => slicc.lick({action: \'status\', data: r.stdout}))"\n>\n Refresh status\n</button>\n```\n\n> Prefer `slicc.exec`/`slicc.agent` for transactional work that should NOT grow the owning scoop\'s conversation (see "Cheap interactions via `agent`" above). These run in the same worker shell, so all ~50 supplemental commands and any `.jsh` script are reachable.\n\n**onclick attributes**: always use `slicc` — e.g. `onclick="slicc.lick({action: \'add-year\'})"`. The `slicc` variable is automatically resolved per-sprinkle, so multiple sprinkles won\'t collide. Do NOT use `bridge` or any other variable name in onclick.\n\n**CSS components**: do NOT write custom CSS. Use the built-in `.sprinkle-*` classes: cards, tables, badges, buttons, text fields, progress bars, meters, layout utilities, and more. For inputs use `class="sprinkle-text-field"`, never inline border/padding styles. Run `read_file /workspace/skills/sprinkles/style-guide.md` for the full component reference with markup examples.\n\n## Built-in sprinkles\n\nSLICC no longer ships with a catalog of pre-built sprinkles. The only `.shtml` under `/shared/sprinkles/` is `welcome/`, which backs the inline first-run welcome dip — not a panel sprinkle. **Always create sprinkles from scratch** for what the user is asking for, following the "Creating a sprinkle" flow above. Do not assume a built-in sprinkle name exists.\n';export{e as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e,t}from"./api-endpoint-GRCyib6X.js";import{t as n}from"./types-idfTVsM8.js";var r=104857600,i=new Set([`ENOENT`,`EEXIST`,`ENOTDIR`,`EISDIR`,`ENOTEMPTY`,`EINVAL`,`EACCES`,`ELOOP`,`EBUSY`,`EFBIG`,`EBADF`,`EIO`]),a=class{kind=`hostfs`;source;mountId;targetPath;hostPath;fetchImpl;closed=!1;constructor(e){this.targetPath=e.targetPath,this.hostPath=e.hostPath,this.source=`hostfs://${e.hostPath}`,this.mountId=e.mountId??crypto.randomUUID(),this.fetchImpl=e.fetchImpl??fetch}assertOpen(e){if(this.closed)throw new n(`EBADF`,`mount closed`,e)}url(t,n,r){let i=new URLSearchParams({mount:this.targetPath,path:n.replace(/^\/+/,``)});for(let[e,t]of Object.entries(r??{}))i.set(e,t);return e(`/api/hostfs/${t}?${i.toString()}`)}async request(e,r,a){this.assertOpen(r);let o;try{o=await this.fetchImpl(this.url(e,r,a?.extra),{...a,headers:t(a?.headers)})}catch(e){throw new n(`EIO`,`hostfs bridge unreachable: ${e instanceof Error?e.message:String(e)}`,r)}if(!o.ok){let t=`EIO`,a=`hostfs ${e} failed with HTTP ${o.status}`;try{let e=await o.json();typeof e.code==`string`&&i.has(e.code)&&(t=e.code),typeof e.message==`string`&&(a=e.message)}catch{}throw new n(t,a,r)}return o}async readDir(e){let t=await(await this.request(`list`,e)).json();if(!Array.isArray(t.entries))return[];let n=[];for(let e of t.entries){let t=e;typeof t.name!=`string`||t.kind!==`file`&&t.kind!==`directory`||n.push({name:t.name,kind:t.kind,...typeof t.size==`number`?{size:t.size}:{},...typeof t.lastModified==`number`?{lastModified:t.lastModified}:{}})}return n}async readFile(e){let t=await(await this.request(`read`,e)).arrayBuffer();if(t.byteLength>r)throw new n(`EFBIG`,`file exceeds the hostfs body cap`,e);return new Uint8Array(t)}async writeFile(e,t){if(t.byteLength>r)throw new n(`EFBIG`,`body exceeds the hostfs body cap`,e);await this.request(`write`,e,{method:`PUT`,headers:{"Content-Type":`application/octet-stream`},body:new Uint8Array(t)})}async stat(e){let t=await(await this.request(`stat`,e)).json();return{kind:t.kind===`directory`?`directory`:`file`,size:typeof t.size==`number`?t.size:0,mtime:typeof t.mtime==`number`?t.mtime:0}}async mkdir(e){await this.request(`mkdir`,e,{method:`POST`})}async rename(e,t){await this.request(`rename`,e,{method:`POST`,extra:{to:t.replace(/^\/+/,``)}})}async remove(e,t){await this.request(`remove`,e,{method:`DELETE`,extra:t?.recursive?{recursive:`1`}:void 0})}async refresh(){return this.assertOpen(this.targetPath),{added:[],removed:[],changed:[],unchanged:0,errors:[]}}describe(){return{displayName:this.hostPath.split(`/`).filter(Boolean).at(-1)??this.hostPath,source:this.source,extra:`configured via mount table (auto-mounted, live host view)`}}async close(){this.closed=!0}getHostPath(){return this.hostPath}};export{a as HostFsMountBackend};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e,t}from"./api-endpoint-C00IT5T9.js";import{t as n}from"./types-idfTVsM8.js";const r=104857600,i=new Set([`ENOENT`,`EEXIST`,`ENOTDIR`,`EISDIR`,`ENOTEMPTY`,`EINVAL`,`EACCES`,`ELOOP`,`EBUSY`,`EFBIG`,`EBADF`,`EIO`]);var a=class{kind=`hostfs`;source;mountId;targetPath;hostPath;fetchImpl;closed=!1;constructor(e){this.targetPath=e.targetPath,this.hostPath=e.hostPath,this.source=`hostfs://${e.hostPath}`,this.mountId=e.mountId??crypto.randomUUID(),this.fetchImpl=e.fetchImpl??fetch}assertOpen(e){if(this.closed)throw new n(`EBADF`,`mount closed`,e)}url(t,n,r){let i=new URLSearchParams({mount:this.targetPath,path:n.replace(/^\/+/,``)});for(let[e,t]of Object.entries(r??{}))i.set(e,t);return e(`/api/hostfs/${t}?${i.toString()}`)}async request(e,r,a){this.assertOpen(r);let o;try{o=await this.fetchImpl(this.url(e,r,a?.extra),{...a,headers:t(a?.headers)})}catch(e){throw new n(`EIO`,`hostfs bridge unreachable: ${e instanceof Error?e.message:String(e)}`,r)}if(!o.ok){let t=`EIO`,a=`hostfs ${e} failed with HTTP ${o.status}`;try{let e=await o.json();typeof e.code==`string`&&i.has(e.code)&&(t=e.code),typeof e.message==`string`&&(a=e.message)}catch{}throw new n(t,a,r)}return o}async readDir(e){let t=await(await this.request(`list`,e)).json();if(!Array.isArray(t.entries))return[];let n=[];for(let e of t.entries){let t=e;typeof t.name!=`string`||t.kind!==`file`&&t.kind!==`directory`||n.push({name:t.name,kind:t.kind,...typeof t.size==`number`?{size:t.size}:{},...typeof t.lastModified==`number`?{lastModified:t.lastModified}:{}})}return n}async readFile(e){let t=await(await this.request(`read`,e)).arrayBuffer();if(t.byteLength>r)throw new n(`EFBIG`,`file exceeds the hostfs body cap`,e);return new Uint8Array(t)}async writeFile(e,t){if(t.byteLength>r)throw new n(`EFBIG`,`body exceeds the hostfs body cap`,e);await this.request(`write`,e,{method:`PUT`,headers:{"Content-Type":`application/octet-stream`},body:new Uint8Array(t)})}async stat(e){let t=await(await this.request(`stat`,e)).json();return{kind:t.kind===`directory`?`directory`:`file`,size:typeof t.size==`number`?t.size:0,mtime:typeof t.mtime==`number`?t.mtime:0}}async mkdir(e){await this.request(`mkdir`,e,{method:`POST`})}async rename(e,t){await this.request(`rename`,e,{method:`POST`,extra:{to:t.replace(/^\/+/,``)}})}async remove(e,t){await this.request(`remove`,e,{method:`DELETE`,extra:t?.recursive?{recursive:`1`}:void 0})}async refresh(){return this.assertOpen(this.targetPath),{added:[],removed:[],changed:[],unchanged:0,errors:[]}}describe(){return{displayName:this.hostPath.split(`/`).filter(Boolean).at(-1)??this.hostPath,source:this.source,extra:`configured via mount table (auto-mounted, live host view)`}}async close(){this.closed=!0}getHostPath(){return this.hostPath}};export{a as HostFsMountBackend};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-BKQr3WRb.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/safe-buffer-iah92gQe.js","assets/dist-DHO9E-gl.js","assets/sidecar-repair-431vRT2V.js","assets/backend-hostfs-Com-zF5W.js","assets/api-endpoint-GRCyib6X.js","assets/types-idfTVsM8.js","assets/mount-Dodh2D8V.js","assets/preload-helper-Czpn1I53.js","assets/mime-types-k2E6ulyv.js","assets/base64-DJRlyqZu.js","assets/src-CAWTvdAa.js","assets/runtime-env-Dlaokqg1.js","assets/runtime-env-E-i2SW1s.js","assets/mount-table-store-dY2IfQ5S.js","assets/mount-bridge-client-BJeJ5p60.js","assets/port-bridge-client-Cti-DmEY.js","assets/logger-DDBAeTLF.js","assets/proxied-fetch-CFWkfPNA.js","assets/fetch-body-D2PwksUW.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{n as c,t as l}from"./virtual-device-paths-D45tpPP6.js";import{a as u,i as d,n as f,t as p}from"./mount-table-store-dY2IfQ5S.js";import{i as ee,r as te,t as m}from"./sidecar-repair-431vRT2V.js";var h=t(`fs-watcher`),g=0;function _(e,t){return t===`/`||e===t||e.startsWith(t+`/`)}var v=class{registrations=new Map;watch(e,t,n){let r=`fsw-${++g}`;return this.registrations.set(r,{id:r,basePath:e,filter:t,callback:n}),h.debug(`Watch registered`,{id:r,basePath:e}),()=>{this.registrations.delete(r),h.debug(`Watch unregistered`,{id:r})}}notify(e){if(e.length!==0)for(let[,t]of this.registrations){let n=e.filter(e=>_(e.path,t.basePath)&&t.filter(e.path));if(n.length>0)try{t.callback(n)}catch(e){h.error(`Watch callback error`,{id:t.id,error:e instanceof Error?e.message:String(e)})}}}dispose(){this.registrations.clear(),h.debug(`All watchers disposed`)}get size(){return this.registrations.size}},y=t(`mount-index`),ne=400,b=2e6,x=`SLICC_MOUNT_INDEX_MAX_DEPTH`,S=`SLICC_MOUNT_INDEX_MAX_ENTRIES`,C=256,w=class extends Error{cause;constructor(e,t){super(e),this.name=`MountIndexAbortError`,this.cause=t}};function T(e){let t=e.map(([e,t])=>`${e}\u0000${t.kind}`).sort(),n=t.length>C?t.slice(0,C):t;return`${t.length}\u0001${n.join(``)}`}async function E(e,t){let n=e.isSameEntry;if(typeof n!=`function`)return!1;try{return await n.call(e,t)}catch{return!1}}function D(e,t){return e instanceof Map?e.get(t):e[t]}function O(e){let t=e.trim();if(t===``)return;let n=Number(t);if(!(!Number.isInteger(n)||n<=0))return n}function k(e,t,n){let r=D(e,t);if(r===void 0||r.trim()===``)return n;let i=O(r);return i===void 0?(y.warn(`Ignoring invalid ${t}; expected a positive integer, using default`,{value:r,fallback:n}),n):i}function A(e){return{maxDepth:k(e,x,ne),maxEntries:k(e,S,b)}}var j=class{mounts=new Map;listeners=new Set;registerMount(e,t,n=A({})){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,y.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 w?r.cause:`indexing-error`;t.state={status:`error`,indexed:0,error:i,abortCause:a},y.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 w(`mount indexing aborted: directory nesting exceeded ${t.limits.maxDepth} levels`,`depth-exceeded`);if(t.directories.size+t.files.size>=t.limits.maxEntries)throw new w(`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 w(`mount indexing aborted: exceeded ${n.limits.maxEntries} entries`,`entries-exceeded`);i.push(e)}return i}async confirmNoCycle(e,t,n,r){let i=T(n),a=r.get(i);if(a){for(let n of a)if(await E(n.handle,t))throw new w(`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)))}}},M=new TextEncoder,N=new TextDecoder(`utf-8`,{fatal:!1}),P=class{entries=new Map;static handles(e){return c(i(e))}has(e){return this.entries.has(i(e))}write(e,t){let n=i(e),r=typeof t==`string`?M.encode(t):new Uint8Array(t),a=Date.now(),o=this.entries.get(n);this.entries.set(n,{bytes:r,mtime:a,ctime:o?.ctime??a})}read(e,t){let n=this.require(e);return(t?.encoding??`utf-8`)===`utf-8`?N.decode(n.bytes):new Uint8Array(n.bytes)}readText(e){return N.decode(this.require(e).bytes)}stat(e){let t=this.require(e);return{type:`file`,size:t.bytes.length,mtime:t.mtime,ctime:t.ctime}}remove(e){return this.entries.delete(i(e))}require(e){let t=i(e),n=this.entries.get(t);if(!n)throw new s(`ENOENT`,`no such file or directory`,t);return n}},F={[l]:{stat:()=>({type:`file`,size:0,mtime:0,ctime:0}),read:e=>(e?.encoding??`utf-8`)===`utf-8`?``:new Uint8Array,readText:()=>``,write:()=>{}}},I=[`/tmp/`],L=class{ephemeralFds=new P;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,...I]}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,...I].some(e=>t===e.slice(0,-1)||t.startsWith(e))}canWrite(e){return P.handles(e)||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=F[i(e)];if(n)return n.read(t);if(P.handles(e))return this.ephemeralFds.read(e,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=F[i(e)];if(t)return t.stat();if(P.handles(e))return this.ephemeralFds.stat(e);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=F[i(e)];return t?t.stat():P.handles(e)?this.ephemeralFds.has(e)?this.ephemeralFds.stat(e):null:!this.isAllowedStrict(e)||this.scanPathForSymlinks(e,!0)!==!1?null:this.vfs.statSync(e)}lstatSync(e){let t=F[i(e)];return t?t.stat():P.handles(e)?this.ephemeralFds.has(e)?this.ephemeralFds.stat(e):null:!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){if(P.handles(e)){let t=i(e);if(!this.ephemeralFds.has(t))throw new s(`ENOENT`,`no such file or directory`,t);return t}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(F[i(e)])return!0;if(P.handles(e))return this.ephemeralFds.has(e);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=F[i(e)];if(t)return t.readText();if(P.handles(e))return this.ephemeralFds.readText(e);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=F[i(e)];if(r){r.write(t);return}if(P.handles(e)){this.ephemeralFds.write(e,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)}refuseDescriptorTreeOp(e){if(P.handles(e))throw new s(`EACCES`,`permission denied`,i(e))}async mkdir(e,t){return this.refuseDescriptorTreeOp(e),this.checkWrite(e),await this.checkParentRealpathEscape(e),this.vfs.mkdir(e,t)}async rm(e,t){if(P.handles(e)){if(!this.ephemeralFds.remove(e))throw new s(`ENOENT`,`no such file or directory`,i(e));return}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.refuseDescriptorTreeOp(e),this.refuseDescriptorTreeOp(t),this.checkWrite(e),this.checkWrite(t),await this.resolveAndCheckWrite(e),await this.checkParentRealpathEscape(t),this.vfs.rename(e,t)}async copyFile(e,t){if(P.handles(e)){let n=this.ephemeralFds.read(e,{encoding:`binary`});await this.writeFile(t,n);return}if(P.handles(t)){if(!this.isAllowed(e))throw new s(`ENOENT`,`no such file or directory`,i(e));let n=await this.resolveAndCheckRead(e);this.ephemeralFds.write(t,await this.vfs.readFile(n,{encoding:`binary`}));return}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.refuseDescriptorTreeOp(t),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=F[i(e)];if(t)return t.stat();if(P.handles(e))return this.ephemeralFds.stat(e);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.refuseDescriptorTreeOp(e),this.checkWrite(e),await this.checkParentRealpathEscape(e),this.vfs.mount(e,t,n)}async unmount(e){return this.refuseDescriptorTreeOp(e),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.refuseDescriptorTreeOp(e),this.checkWrite(e),this.vfs.refreshMount(e,t)}async dispose(){await this.vfs.dispose()}};function R(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 z=[`ENOENT`,`EEXIST`,`ENOTDIR`,`EISDIR`,`ENOTEMPTY`,`EINVAL`,`EACCES`,`ELOOP`,`EBUSY`,`EFBIG`,`EBADF`,`ENOSYS`,`EIO`];function B(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(z.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 V=61440,H=16384;function U(e){return e===void 0?`absent`:(e&V)===H?`directory`:`file`}function W(e,t){return t===`absent`?!1:e.kind===`missing`||e.kind!==t}function G(e){let t=e?.mode;return typeof t==`number`?t:void 0}function K(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=U(G(r));o!==U(G(i))&&a.push({path:n,ownIsDirectory:o===`directory`})}return a}var q=class e{kind=`local`;source=void 0;profile=void 0;mountId;handle;closed=!1;constructor(e,t){this.handle=e,this.mountId=t.mountId}static fromHandle(t,n){return new e(t,n)}getHandle(){return this.handle}assertOpen(e){if(this.closed)throw new s(`EBADF`,`mount closed`,e)}splitPath(e){return e.replace(/^\/+/,``).replace(/\/+$/,``).split(`/`).filter(e=>e.length>0)}async resolveDir(e,t=!1){let n=this.splitPath(e),r=this.handle;for(let i of n)try{r=await r.getDirectoryHandle(i,{create:t})}catch(t){throw this.toFsError(t,e)}return r}async resolveFile(e,t=!1){let n=this.splitPath(e);if(n.length===0)throw new s(`EISDIR`,`is a directory`,e);let r=n.pop(),i=this.handle;for(let r of n)try{i=await i.getDirectoryHandle(r,{create:t})}catch(t){throw this.toFsError(t,e)}try{return await i.getFileHandle(r,{create:t})}catch(t){throw this.toFsError(t,e)}}toFsError(e,t){if(e instanceof s)return e;if(e instanceof DOMException){if(e.name===`NotFoundError`)return new s(`ENOENT`,`no such file or directory`,t);if(e.name===`TypeMismatchError`)return new s(`ENOTDIR`,`not a directory`,t);if(e.name===`NotAllowedError`)return new s(`EACCES`,`permission denied`,t);if(e.name===`InvalidModificationError`)return new s(`ENOTEMPTY`,`directory not empty`,t)}if(e instanceof Error){if(e.name===`NotFound`||e.name===`NotFoundError`)return new s(`ENOENT`,`no such file or directory`,t);if(e.name===`TypeMismatch`||e.name===`TypeMismatchError`)return new s(`ENOTDIR`,`not a directory`,t);if(e.name===`InvalidModification`||e.name===`InvalidModificationError`)return new s(`ENOTEMPTY`,`directory not empty`,t)}return new s(`EINVAL`,e instanceof Error?e.message:String(e),t)}async readDir(e){this.assertOpen(e);let t=await this.resolveDir(e),n=[];for await(let[e,r]of t)if(r.kind===`file`){let t=await r.getFile();n.push({name:e,kind:`file`,size:t.size,lastModified:t.lastModified})}else n.push({name:e,kind:`directory`});return n}async readFile(e){this.assertOpen(e);let t=await(await this.resolveFile(e)).getFile();return new Uint8Array(await t.arrayBuffer())}async writeFile(e,t){this.assertOpen(e);let n=await(await this.resolveFile(e,!0)).createWritable();await n.write(t),await n.close()}async stat(e){if(this.assertOpen(e),this.splitPath(e).length===0)return{kind:`directory`,size:0,mtime:0};try{let t=await(await this.resolveFile(e)).getFile();return{kind:`file`,size:t.size,mtime:t.lastModified}}catch{}return await this.resolveDir(e),{kind:`directory`,size:0,mtime:0}}async mkdir(e){this.assertOpen(e),await this.resolveDir(e,!0)}async remove(e,t){this.assertOpen(e);let n=this.splitPath(e);if(n.length===0)throw new s(`EINVAL`,`cannot remove mount root`,e);let r=n.pop(),i=n.join(`/`),a=await this.resolveDir(i||`/`);try{await a.removeEntry(r,{recursive:t?.recursive??!1})}catch(t){throw this.toFsError(t,e)}}async refresh(){return this.assertOpen(`/`),{added:[],removed:[],changed:[],unchanged:0,errors:[]}}describe(){return{displayName:this.handle.name}}async close(){this.closed=!0}};async function J(e,t,n,r){try{return await e.lstat(t)}catch(e){let t=B(e,r);if(t.code===`ENOENT`&&n)return null;throw t}}async function Y(e,t,r){let a;try{a=await e.readlink(t)}catch(e){throw B(e,r)}return a.startsWith(`/`)?i(a):i(o(n(t).dir,a))}async function X(e,t,n,r,i,a){let o=t===`/`?`/${n}`:`${t}/${n}`;for(;;){let t=await J(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 Y(e,o,i)}}async function Z(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 X(e,o,a[t],t===a.length-1,r,s);o=n.resolved,s=n.hops}return o}async function re(e,t,n){return t(n)?n:Z(e,t,n)}function ie(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 ae(e,t){try{return await e(t)}catch{return t}}async function*Q(e,t,n,r=0){let a=i(t);if(ie(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 ae(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*oe(e,t,a===`/`?`/${t.name}`:`${a}/${t.name}`,o,r+1)}async function*oe(e,t,n,r,i){if(t.type===`file`){yield n;return}if(t.type===`symlink`){yield*se(e,n,r,i);return}yield*Q(e,n,r,i)}async function*se(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 ce(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 le=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 j;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-BKQr3WRb.js`).then(e=>e.t),__vite__mapDeps([0,1,2])),e(()=>import(`./dist-DHO9E-gl.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-BKQr3WRb.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=te(e,r,i))}let o=JSON.stringify(ee(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=K(e,t,n.paths,n.prefixes);if(i.length===0)return;let a=m(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 m(n)(a),s=U(t.index.get(a)?.mode),c=t._handles?.get(a),l=c?.kind===`directory`?`directory`:c?.kind===`file`?`file`:`absent`,u=W(o,s),d=W(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 watch(e,t){let n=this.watcher;if(!n)throw new s(`ENOSYS`,`no FsWatcher attached to this VirtualFS`);let r=e.map(e=>n.watch(e,()=>!0,t));return()=>{for(let e of r)e()}}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-BKQr3WRb.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,ino:e.ino}}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,ino:e.ino};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,ino:e.ino}}return{type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs,ino:e.ino}}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??A(r?.env??{});this.mountIndex.registerMount(a,t.getHandle(),e)}let c=ce(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 q.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-Dodh2D8V.js`);return{S3MountBackend:e,RemoteMountCache:t,makeSignedFetchS3:n}},__vite__mapDeps([8,9,10,11,12,13,6,14,7,15,1,16,17,18,19,20])),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-Dodh2D8V.js`);return{DaMountBackend:e,RemoteMountCache:t,makeSignedFetchDa:n}},__vite__mapDeps([8,9,10,11,12,13,6,14,7,15,1,16,17,18,19,20])),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-Dodh2D8V.js`);return{AemMountBackend:e,RemoteMountCache:t,makeSignedFetchDa:n}},__vite__mapDeps([8,9,10,11,12,13,6,14,7,15,1,16,17,18,19,20])),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,A(t?.env??{})),this.watcher?.notify([{type:`modify`,path:n,entryType:`directory`}]),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){R(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 B(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){R(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 B(e,a)}}else throw B(e,a)}try{await this.lfs.truncate?.(c,e)}catch(e){throw B(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){R(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 B(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=[],r=``;for(let e of t){r+=`/`+e;try{await this.lfs.mkdir(r),n.push(r)}catch(e){if(e instanceof Error&&!e.message.includes(`EEXIST`))throw B(e,r);try{let e=await this.lfs.lstat(r);if(!e.isDirectory()&&!e.isSymbolicLink())throw new s(`ENOTDIR`,`not a directory`,r)}catch(e){if(e instanceof s&&e.code===`ENOTDIR`)throw e}}}return n}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){R(e,n)}t||this.watcher?.notify([{type:`create`,path:n,entryType:`directory`}]);return}if(t?.recursive){let e=await this.withWriteLock(()=>(this.markSidecarDirty(n),this.mkdirRecursiveUnlocked(n)));e.length>0&&this.watcher?.notify(e.map(e=>({type:`create`,path:e,entryType:`directory`})))}else await this.withWriteLock(async()=>{this.markSidecarDirty(n);try{await this.lfs.mkdir(n)}catch(e){throw B(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){R(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 B(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){R(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,ino:e.ino}}catch(e){throw B(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){R(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 B(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 B(e,r)}}else throw B(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 B(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,ino:e.ino}}return{type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs,ino:e.ino}}catch(e){throw B(e,t)}}async realpath(e){return Z(this.lfs,e=>this.findMount(e)!==null,e)}resolveSymlinks(e){return re(this.lfs,e=>this.findMount(e)!==null,e)}};export{s as FsError,v as FsWatcher,j as MountIndex,L as RestrictedFS,le as VirtualFS,o as joinPath,i as normalizePath,r as pathSegments,$ as resolveVfsBackendFromEnv,n as splitPath,q as t};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/fs-C7Q7Gwx0.js","assets/preload-helper-Czpn1I53.js","assets/logger-DDBAeTLF.js","assets/path-utils-DNJG-zQf.js","assets/types-idfTVsM8.js","assets/virtual-device-paths-D45tpPP6.js","assets/mount-table-store-dY2IfQ5S.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/sidecar-repair-431vRT2V.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{H as e,S as t,d as n}from"./account-store-DFb7ccri.js";import{t as r}from"./preload-helper-Czpn1I53.js";import"./proxied-fetch-CFWkfPNA.js";import{r as i,t as a}from"./silent-renew-backoff-t_Cd4Zw7.js";import{r as o}from"./api-endpoint-GRCyib6X.js";import{p as s,t as c}from"./tray-runtime-config-CluPgaPA.js";import"./provider-settings-IGWxggS0.js";import{getOAuthPageOrigin as l,resolveOAuthDelegation as u}from"./oauth-service-NaEg6KHx.js";import{t as d}from"./global-db-CbuLl-zx.js";var f={clientId:``,scopes:`repo,read:user,user:email`};function p(){try{let e=localStorage.getItem(s);if(e)return e.replace(/\/$/,``)}catch{}return c}function m(e){return{access_token:e.access_token,token_type:e.token_type,scope:e.scope,refresh_token:e.refresh_token,expires_in:e.expires_in}}async function h(e){let t;try{t=await e.json()}catch{throw Error(`Token exchange failed (HTTP ${e.status}): non-JSON response`)}if(!e.ok&&e.status!==200){let n=t.error_description??t.error??`Token exchange failed (HTTP ${e.status})`;throw Error(n)}if(t.error){let e=t.error_description??t.error;throw Error(e)}return m(t)}async function g(e){let t=`${p()}/oauth/token`;return h(await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e.provider,code:e.code,redirect_uri:e.redirectUri})}))}async function _(e){let t=`${p()}/oauth/token`;return h(await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e.provider,refresh_token:e.refreshToken})}))}async function v(e){let t=`${p()}/oauth/revoke`,n=await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e.provider,access_token:e.accessToken})});if(!(n.status===204||n.ok)){if(n.status===400)try{if((await n.json()).error===`unsupported`)return}catch{}throw Error(`Token revocation failed (HTTP ${n.status})`)}}var y=Object.assign({"/packages/webapp/providers/github-config.json":f})[`/packages/webapp/providers/github-config.json`]??{clientId:``,scopes:`repo,read:user,user:email`},b=null,x=null;function S(e){let{isExtension:t,isConnectMode:n,workerBaseUrl:r,pageOrigin:a,pageHref:o,bridgeApiBaseUrl:s,extensionId:c,nonce:l}=e;if(t)return{redirectUri:`${r}/auth/callback`,state:{source:`extension`,extensionId:c,path:`/github`,nonce:l}};if(e.delegated)return{redirectUri:`${e.runtimeWorkerBaseUrl??r}/auth/callback`,state:{source:`opener`,path:`/auth/callback`,nonce:l}};if(n){let e=a??``;if(/^https?:\/\/(localhost|127\.0\.0\.1):\d+$/.test(e)){let t=parseInt(new URL(o??e).port||`8790`,10);return{redirectUri:`${r}/auth/callback`,state:{source:`local`,port:t,path:`/auth/callback`,nonce:l}}}return{redirectUri:`${r}/auth/callback`,state:{source:`remote`,origin:e,path:`/auth/callback`,nonce:l}}}if(s&&o&&i(o)){let t=null;try{let e=new URL(s);(e.hostname===`localhost`||e.hostname===`127.0.0.1`)&&(t=parseInt(e.port||`5710`,10))}catch{t=null}if(t!==null&&!Number.isNaN(t))return{redirectUri:`${e.runtimeWorkerBaseUrl??r}/auth/callback`,state:{source:`local`,port:t,path:`/auth/callback`,nonce:l}}}return{redirectUri:`${e.runtimeWorkerBaseUrl??a??``}/auth/callback`,state:{port:parseInt(new URL(o??a??`http://localhost:5710`).port||`5710`,10),path:`/auth/callback`,nonce:l}}}async function C(){if(b)return b;if(w){try{let e=await fetch(`${p()}/api/runtime-config`);if(e.ok){let t=await e.json();if(t.oauth?.github)return b=t.oauth.github,b}}catch{}return y.clientId}try{let e=await fetch(`/api/runtime-config`);if(e.ok){let t=await e.json();if(t.oauth?.github)return b=t.oauth.github,t.trayWorkerBaseUrl&&(x=t.trayWorkerBaseUrl),b;if(t.trayWorkerBaseUrl){x=t.trayWorkerBaseUrl;let e=await fetch(`${t.trayWorkerBaseUrl}/api/runtime-config`);if(e.ok){let t=await e.json();if(t.oauth?.github)return b=t.oauth.github,b}}}}catch{}return y.clientId}var w=typeof globalThis<`u`&&typeof globalThis.chrome?.runtime?.id==`string`;function T(){return n().find(e=>e.providerId===`github`)}function E(e){try{return new URL(e).searchParams.get(`code`)}catch{return null}}async function D(e){try{let t=await fetch(`https://api.github.com/user`,{headers:{Authorization:`Bearer ${e}`,Accept:`application/vnd.github+json`}});if(t.ok){let e=await t.json();return{name:e.name||e.login,avatar:e.avatar_url,login:e.login,id:e.id}}}catch(e){console.warn(`[github] Failed to fetch user profile:`,e instanceof Error?e.message:String(e))}return{}}function O(e,t){return`${e}+${t}@users.noreply.github.com`}async function k(e){try{let{VirtualFS:t}=await r(async()=>{let{VirtualFS:e}=await import(`./fs-C7Q7Gwx0.js`);return{VirtualFS:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8]));await(await t.create({dbName:d})).writeFile(`/workspace/.git/github-token`,e),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`github-token-changed`))}catch(e){console.warn(`[github] Failed to write git token:`,e instanceof Error?e.message:String(e))}}async function A(){try{let{VirtualFS:e}=await r(async()=>{let{VirtualFS:e}=await import(`./fs-C7Q7Gwx0.js`);return{VirtualFS:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8]));await(await e.create({dbName:d})).rm(`/workspace/.git/github-token`),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`github-token-changed`))}catch{}}async function j(e){if(!(!e.login||e.id===void 0))try{let{VirtualFS:t}=await r(async()=>{let{VirtualFS:e}=await import(`./fs-C7Q7Gwx0.js`);return{VirtualFS:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8])),{readGlobalGitConfigValue:n,writeGlobalGitConfigValue:i}=await r(async()=>{let{readGlobalGitConfigValue:e,writeGlobalGitConfigValue:t}=await import(`./git-config-D2u6LGfT.js`);return{readGlobalGitConfigValue:e,writeGlobalGitConfigValue:t}},[]),a=await t.create({dbName:d}),o=e.name||e.login,s=O(e.id,e.login);!await n(a,`user.name`)&&o&&await i(a,`user.name`,o),await n(a,`user.email`)||await i(a,`user.email`,s)}catch(e){console.warn(`[github] Failed to seed git identity:`,e instanceof Error?e.message:String(e))}}var M=a();async function N(){try{let n=T();if(!n?.refreshToken)return null;let r=await _({provider:`github`,refreshToken:n.refreshToken});await e({providerId:`github`,accessToken:r.access_token,refreshToken:r.refresh_token,tokenExpiresAt:r.expires_in?Date.now()+r.expires_in*1e3:void 0,userName:n.userName,userAvatar:n.userAvatar,scopes:r.scope??n.scopes});let i=t(`github`)?.maskedValue;return i?await k(i):await A(),r.access_token}catch(e){return console.warn(`[github] Silent renewal failed:`,e instanceof Error?e.message:String(e)),null}}var P=1e4;async function F(){let e=T()?.accessToken;if(!e)return{status:`unknown`,detail:`no stored token`};try{let t=await fetch(`https://api.github.com/user`,{headers:{Authorization:`Bearer ${e}`,Accept:`application/vnd.github+json`},signal:AbortSignal.timeout(P)});if(t.ok){let e=await t.json().catch(()=>({}));return{status:`accepted`,userName:e.name||e.login}}return I(t)}catch(e){return{status:`unknown`,detail:e instanceof Error?e.message:String(e)}}}function I(e){let t=`HTTP ${e.status}${e.statusText?` ${e.statusText}`:``}`;return e.status===401?{status:`rejected`,detail:t}:e.status===403&&L(e)?{status:`unknown`,detail:`${t} (rate limited)`}:{status:`unknown`,detail:t}}function L(e){return e.headers.get(`x-ratelimit-remaining`)===`0`||e.headers.has(`retry-after`)}async function R(){let e=T();if(!e?.accessToken)throw Error(`Not logged in to GitHub — please log in first`);if((e.tokenExpiresAt??1/0)-Date.now()>6e4)return e.accessToken;let t=await M.run(()=>N());if(t)return t;let n=T();if((n?.tokenExpiresAt??1/0)-Date.now()>0&&n?.accessToken)return n.accessToken;throw Error(`GitHub session expired — please log in again`)}var z={id:`github`,name:`GitHub`,description:"Sign in with GitHub for git authentication (push/pull/clone) and the `oauth-token github` shell command. Does not expose LLM models — use the GitHub Copilot provider for those.",requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,oauthTokenDomains:[`github.com`,`*.github.com`,`api.github.com`,`raw.githubusercontent.com`],getModelIds:()=>[],onOAuthLogin:async(n,r,i)=>{let a=await C();if(!a)throw Error(`GitHub OAuth not configured — no client ID available`);let s=i?.scopes??y.scopes,c=w?null:await l(),d=!w&&await u(),f=crypto.randomUUID(),m=w?chrome.runtime.id:``,{redirectUri:h,state:_}=S({isExtension:w,isConnectMode:!!globalThis.__slicc_connect_mode,workerBaseUrl:p(),runtimeWorkerBaseUrl:x,pageOrigin:c?.origin??null,pageHref:c?.href??null,bridgeApiBaseUrl:o(),delegated:d,extensionId:m,nonce:f}),v=btoa(JSON.stringify(_)),b=f,T=new URLSearchParams({client_id:a,scope:s,redirect_uri:h});v&&T.set(`state`,v);let O=await n(`https://github.com/login/oauth/authorize?${T}`);if(!O)return;if(b)try{if(new URL(O).searchParams.get(`nonce`)!==b){console.error(`[github] OAuth nonce mismatch — possible CSRF`);return}}catch(e){console.warn(`[github] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}let M=E(O);if(!M){console.error(`[github] Could not extract authorization code from redirect URL`);return}let N=await g({provider:`github`,code:M,redirectUri:h}),P=await D(N.access_token);await e({providerId:`github`,accessToken:N.access_token,refreshToken:N.refresh_token,tokenExpiresAt:N.expires_in?Date.now()+N.expires_in*1e3:void 0,userName:P.name,userAvatar:P.avatar,scopes:N.scope});let F=t(`github`)?.maskedValue;F?await k(F):await A(),await j(P),r()},onSilentRenew:N,onValidateToken:F,getValidAccessToken:R,onOAuthLogout:async()=>{let t=T();t?.accessToken&&await v({provider:`github`,accessToken:t.accessToken}).catch(e=>console.warn(`[github] Token revocation failed:`,e instanceof Error?e.message:String(e))),await A(),await e({providerId:`github`,accessToken:``})},getOAuthLogoutUrl:e=>`https://github.com/logout`};export{O as buildNoreplyEmail,z as config,E as extractCodeFromUrl,R as getValidAccessToken,S as resolveGithubOAuthRedirect,j as syncGitIdentityFromGitHub};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./store-ljIGz9wi.js";export{e as readMcpAuthEntries};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/fs-C7Q7Gwx0.js","assets/preload-helper-Czpn1I53.js","assets/logger-DDBAeTLF.js","assets/path-utils-DNJG-zQf.js","assets/types-idfTVsM8.js","assets/virtual-device-paths-D45tpPP6.js","assets/mount-table-store-dY2IfQ5S.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/sidecar-repair-431vRT2V.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{t as e}from"./preload-helper-Czpn1I53.js";import{t}from"./logger-DDBAeTLF.js";import{t as n}from"./global-db-CbuLl-zx.js";import{t as r}from"./types-idfTVsM8.js";var i=t(`mcp-store`),a=`/workspace/.mcp/servers.json`,o=1,s=null,c=null;async function l(){return s||=await e(()=>import(`./fs-C7Q7Gwx0.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8])),s}async function u(e){if(e)return e;if(c&&c.dbName===`slicc-fs-global`)return c.instance;let{VirtualFS:t}=await l(),r=await t.create({dbName:n});return c={instance:r,dbName:n},r}function d(){return{version:o,servers:{}}}function f(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function p(e){if(!f(e))return null;let t={...e};return typeof t.url==`string`?(delete t.sessionId,t):null}function m(e){if(!f(e))return d();let t=e,n=typeof t.version==`number`?t.version:o,r={};if(f(t.servers))for(let[e,n]of Object.entries(t.servers)){let t=p(n);t&&(r[e]=t)}return{version:n,servers:r}}async function h(e){try{let t=await(await u(e)).readFile(a,{encoding:`utf-8`});try{return m(JSON.parse(t))}catch(e){return i.warn(`servers.json is not valid JSON; treating as empty`,{error:e instanceof Error?e.message:String(e)}),d()}}catch(e){return e instanceof r&&e.code===`ENOENT`||i.warn(`Failed to read servers.json`,{error:e instanceof Error?e.message:String(e)}),d()}}async function g(e){return(await h(e)).servers}async function _(){let e=await g(),t=[];for(let[n,r]of Object.entries(e))!r?.url||!r.auth?.clientId||t.push({name:n,serverUrl:r.url,auth:r.auth});return t}export{_ as readMcpAuthEntries};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./types-idfTVsM8.js";function t(e,t){return e===`/`?`/${t}`:`${e}/${t}`}async function n(t,n){try{return await t.stat(n),!0}catch(t){return t instanceof e&&t.code,!1}}async function r(e,t){try{return await e.readDir(t)}catch{return null}}async function*i(e,t,n){try{let r=await e.stat(t);if(r.type===`file`){yield t;return}r.type===`directory`&&n.push(t)}catch{}}async function*a(e,t,n,r){if(t.type===`file`){yield n;return}if(t.type===`directory`){r.push(n);return}t.type===`symlink`&&(yield*i(e,n,r))}async function*o(e,n){let i=[n],o=new Set;for(;i.length>0;){let n=i.pop();if(n===void 0)break;if(o.has(n))continue;o.add(n);let s=await r(e,n);if(s)for(let r of s)yield*a(e,r,t(n,r.name),i)}}function s(e){let{reader:t,writer:r}=e;return{readFile:(e,n)=>t.readFile(e,n),readDir:e=>t.readDir(e),stat:e=>t.stat(e),writeFile:(e,t,n)=>r.writeFile(e,t,n),mkdir:(e,t)=>r.mkdir(e,t),rm:(e,t)=>r.rm(e,t),flush:()=>r.flush(),exists:e=>n(t,e),walk:e=>o(t,e)}}export{s as createRemoteSprinkleVfs};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function e(){return{version:`6.112.2`,releasedAt:`2026-09-01T14:34:48Z`,buildId:`6.112.2-mtirqu2o`}}let t=null;function n(e){t=e}function r(){return t}export{e as n,n as r,r as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./logger-DDBAeTLF.js";import{s as t}from"./telemetry-BVzuNdvW.js";import{n,t as r}from"./panel-rpc-B3MSVImO.js";import{t as i}from"./sprinkle-renderer-1C1DNVyK.js";import{t as a}from"./sprinkle-bridge-D4YmJlZ6.js";import"./sprinkle-instances-B8n7h-oP.js";var o=[`/shared/sprinkles`],s=new Set([`welcome`,`connect-llm`]);async function c(e){let t=new Map;for(let n of o)await e.exists(n)&&await l(e,n,t);return await l(e,`/`,t),t}async function l(e,t,n){for await(let r of e.walk(t)){if(!r.endsWith(`.shtml`))continue;let t=u(r);if(!s.has(t)&&!n.has(t)){let i;try{i=await e.readFile(r,{encoding:`utf-8`})??``}catch{i=``}n.set(t,{name:t,path:r,title:d(i,t),autoOpen:f(i),icon:p(i)})}}}function u(e){let t=e.split(`/`).pop()??e;return t.endsWith(`.shtml`)?t.slice(0,-6):t}function d(e,t){let n=e.match(/data-sprinkle-title=["']([^"']+)["']/);if(n)return n[1];let r=e.match(/<title>([^<]+)<\/title>/i);return r?r[1].trim():t}function f(e){return/data-sprinkle-autoopen\b/.test(e)}function p(e){let t=/<link\b/gi,n;for(;(n=t.exec(e))!==null;){let t=n.index+n[0].length,r=m(e,t);if(r<0)continue;let i=e.slice(t,r);if(!/\brel\s*=\s*("|')\s*(?:shortcut\s+)?icon\s*\1/i.test(i))continue;let a=h(i,`href`);if(a!==void 0)return a.trim()}let r=h(e,`data-sprinkle-icon`);if(r!==void 0)return r.trim()}function m(e,t){let n=!1,r=!1;for(let i=t;i<e.length;i++){let t=e.charCodeAt(i);if(n)t===34&&(n=!1);else if(r)t===39&&(r=!1);else if(t===34)n=!0;else if(t===39)r=!0;else if(t===62)return i}return-1}function h(e,t){let n=RegExp(`\\b${t}\\s*=\\s*(?:"([^"]*)"|'([^']*)')`,`i`),r=e.match(n);if(r)return r[1]??r[2]??void 0}var g=e(`sprinkle-manager`),_=`slicc-open-sprinkles`,v=`sprinkles`;function y(){try{if(typeof window>`u`||!window.location)return null;let e=new URLSearchParams(window.location.search).get(v);return e===null?null:e===``?[]:e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0)}catch{return null}}function b(e){try{if(typeof window>`u`||!window.location||typeof history>`u`||typeof history.replaceState!=`function`)return;let t=new URL(window.location.href);e.length===0?t.searchParams.delete(v):t.searchParams.set(v,e.join(`,`));let n=t.pathname+t.search+t.hash;history.replaceState(history.state??null,``,n)}catch{}}var x=`slicc-known-sprinkles`;function S(e){try{let t=new Set(e),n=C().filter(e=>t.has(e));localStorage.setItem(x,JSON.stringify(n))}catch{}}function C(){try{let e=localStorage.getItem(x);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}var w=`slicc-autoopened-once`,T=[`/workspace`,`/shared`,`/scoops`],E=250,D=class{fs;bridge;callbacks;availableSprinkles=new Map;watcherUnsub;openSprinkles=new Map;attentionOnly=new Set;inflightRefresh=null;lastRefreshAt=0;autoOpenBehavior;onSendToSprinkle;onSprinkleReloaded;registeredSprinkles=new Set;inlineSprinkles;changeListeners=new Set;changeNotifyScheduled=!1;urlWriteScheduled=!1;constructor(e,t,i,o,s={}){this.fs=e;let c=async()=>{let e=`image/png`,t=n(),i=r();if(!t&&!i)throw Error(`Screen capture unavailable in this environment`);if(t&&!navigator.mediaDevices?.getDisplayMedia)throw Error(`Screen capture not supported in this browser`);let a,o,s;if(t){let t=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!1});try{let n=document.createElement(`video`);n.srcObject=t,n.muted=!0,n.playsInline=!0,await new Promise((e,t)=>{n.onloadedmetadata=()=>n.play().then(()=>e()).catch(t),n.onerror=()=>t(Error(`Failed to load video stream`))}),await new Promise(e=>setTimeout(e,100)),o=n.videoWidth,s=n.videoHeight;let r=document.createElement(`canvas`);r.width=o,r.height=s;let i=r.getContext(`2d`);if(!i)throw Error(`Failed to get canvas context`);i.drawImage(n,0,0,o,s),a=await(await new Promise((t,n)=>{r.toBlob(e=>e?t(e):n(Error(`Failed to create image blob`)),e,1)})).arrayBuffer()}finally{for(let e of t.getTracks())e.stop()}}else{let t=await i.call(`screencapture`,{mimeType:e,quality:1},{timeoutMs:3e5});a=t.bytes,o=t.width,s=t.height}let c=new Uint8Array(a),l=[],u=8192;for(let e=0;e<c.length;e+=u)l.push(String.fromCharCode(...c.subarray(e,e+u)));return{base64:btoa(l.join(``)),width:o,height:s,mimeType:e}};this.bridge=new a(e,t,e=>this.close(e),e=>this.minimize(e),o,s.onAttachImage??(()=>{}),c,s.execHandler,(e,t,n)=>{this.openSprinkles.get(e)?.renderer.pushDeviceEvent(t,n)}),this.callbacks=i,this.autoOpenBehavior=s.autoOpenBehavior??`activate`,this.onSendToSprinkle=s.onSendToSprinkle,this.onSprinkleReloaded=s.onSprinkleReloaded,this.inlineSprinkles=s.inlineSprinkles??new Set}setSendToSprinkleHook(e){this.onSendToSprinkle&&!e&&g.error(`SprinkleManager broadcast hook detached`),this.onSendToSprinkle=e}setReloadHook(e){this.onSprinkleReloaded=e}async reload(e){let t=this.openSprinkles.get(e);if(!t){g.info(`Cannot reload closed sprinkle`,{name:e});return}let n=this.availableSprinkles.get(e);if(n||=(await this.refresh(),this.availableSprinkles.get(e)),!n){g.warn(`Sprinkle not found during reload`,{name:e});return}let r=await this.fs.readFile(n.path,{encoding:`utf-8`});if(r==null){g.warn(`Failed to read sprinkle content during reload`,{name:e});return}let a=typeof r==`string`?r:new TextDecoder(`utf-8`).decode(r);t.renderer?.dispose(),this.bridge.removeSprinkle(e);let o=this.bridge.createAPI(e),s=new i(t.container,o);if(await s.render(a,e),!this.openSprinkles.has(e)){s.dispose();return}if(t.renderer=s,s.activateBridgeLifecycle(),this.openSprinkles.has(e)&&(g.info(`Sprinkle reloaded`,{name:e}),this.notifyChange(),this.onSprinkleReloaded))try{this.onSprinkleReloaded(e)}catch(t){g.error(`onSprinkleReloaded hook threw`,{name:e,error:t instanceof Error?t.message:String(t)})}}async restoreOpenSprinkles(){try{let e=y();if(e!==null){await this.reopenInBackground(e);return}let t=localStorage.getItem(_);t?await this.restoreFromLegacyStorage(t):await this.autoOpenFirstRun()}catch{}await this.surfaceUnseenSprinkles()}async reopenInBackground(e){for(let t of e)try{await this.open(t,void 0,{background:!0})}catch{g.warn(`Failed to restore sprinkle`,{name:t})}}async restoreFromLegacyStorage(e){try{await this.reopenInBackground(JSON.parse(e))}finally{try{localStorage.removeItem(_)}catch{}}}async autoOpenFirstRun(){let e=this.autoOpenBehavior===`attention`,t=this.loadAutoOpenedOnce(),n=new Set;for(let r of this.availableSprinkles.values())if(!(!r.autoOpen||t.has(r.name)))try{await this.open(r.name,void 0,{attention:e}),n.add(r.name)}catch{g.warn(`Failed to auto-open sprinkle`,{name:r.name})}n.size>0&&this.persistAutoOpenedOnce(n)}async surfaceUnseenSprinkles(){let e=this.loadKnownSprinkles(),t=this.loadAutoOpenedOnce(),n=this.autoOpenBehavior===`attention`,r=new Set;for(let i of this.availableSprinkles.values())if(!e.has(i.name)&&!this.openSprinkles.has(i.name)&&!(i.autoOpen&&t.has(i.name)))try{await this.open(i.name,void 0,{attention:!i.autoOpen||n}),i.autoOpen&&r.add(i.name),g.info(`Surfaced previously-unseen sprinkle`,{name:i.name})}catch{g.warn(`Failed to surface unseen sprinkle`,{name:i.name})}this.persistKnownSprinkles(new Set(this.availableSprinkles.keys())),r.size>0&&this.persistAutoOpenedOnce(r)}loadKnownSprinkles(){return new Set(C())}persistKnownSprinkles(e){try{let t=new Set([...this.loadKnownSprinkles(),...e]);localStorage.setItem(x,JSON.stringify([...t]))}catch{}}loadAutoOpenedOnce(){try{let e=localStorage.getItem(w);if(!e)return new Set;let t=JSON.parse(e);return Array.isArray(t)?new Set(t.filter(e=>typeof e==`string`)):new Set}catch{return new Set}}persistAutoOpenedOnce(e){try{let t=new Set([...this.loadAutoOpenedOnce(),...e]);localStorage.setItem(w,JSON.stringify([...t]))}catch{}}persistOpenSprinkles(){try{let e=[...this.openSprinkles.keys()].filter(e=>!this.attentionOnly.has(e));localStorage.setItem(_,JSON.stringify(e))}catch{}this.schedulePersistOpenSprinklesToUrl()}schedulePersistOpenSprinklesToUrl(){this.urlWriteScheduled||(this.urlWriteScheduled=!0,queueMicrotask(()=>{this.urlWriteScheduled=!1,b([...this.openSprinkles.keys()].filter(e=>!this.attentionOnly.has(e)))}))}async openNewAutoOpenSprinkles(){if(this.inflightRefresh!==null)return this.inflightRefresh;if(!(Date.now()-this.lastRefreshAt<E))return this.inflightRefresh=this.runOpenNewAutoOpenSprinkles().finally(()=>{this.lastRefreshAt=Date.now(),this.inflightRefresh=null}),this.inflightRefresh}async runOpenNewAutoOpenSprinkles(){let e=new Set(this.availableSprinkles.keys());await this.refresh();let t=this.autoOpenBehavior===`attention`,n=this.loadAutoOpenedOnce(),r=new Set,i=!1;for(let a of this.availableSprinkles.values())if(!this.openSprinkles.has(a.name)&&!e.has(a.name)){if(i=!0,a.autoOpen){if(n.has(a.name)){g.info(`Skipped one-shot auto-open for previously-consumed sprinkle`,{name:a.name});continue}try{await this.open(a.name,void 0,{attention:t}),r.add(a.name),g.info(`Auto-opened new sprinkle after install`,{name:a.name,attention:t})}catch{g.warn(`Failed to auto-open new sprinkle`,{name:a.name})}}else try{await this.open(a.name,void 0,{attention:!0}),g.info(`Surfaced newly-installed sprinkle in rail`,{name:a.name})}catch{g.warn(`Failed to surface newly-installed sprinkle`,{name:a.name})}}i&&this.persistKnownSprinkles(new Set(this.availableSprinkles.keys())),r.size>0&&this.persistAutoOpenedOnce(r)}async refresh(){this.availableSprinkles=await c(this.fs),g.info(`Discovered sprinkles`,{count:this.availableSprinkles.size}),this.syncRegisteredIcons(),this.notifyChange()}syncRegisteredIcons(){if(!this.callbacks.registerSprinkle)return;let e=new Set;for(let t of this.availableSprinkles.values())this.inlineSprinkles.has(t.name)||e.add(t.name);for(let t of this.availableSprinkles.values())if(e.has(t.name)&&!this.registeredSprinkles.has(t.name))try{this.callbacks.registerSprinkle(t.name,t.title,{icon:t.icon}),this.registeredSprinkles.add(t.name)}catch(e){g.warn(`registerSprinkle callback threw`,{name:t.name,error:e instanceof Error?e.message:String(e)})}for(let t of[...this.registeredSprinkles])if(!e.has(t)){this.openSprinkles.has(t)&&this.close(t);try{this.callbacks.unregisterSprinkle?.(t)}catch(e){g.warn(`unregisterSprinkle callback threw`,{name:t,error:e instanceof Error?e.message:String(e)})}this.registeredSprinkles.delete(t)}}onChange(e){return this.changeListeners.add(e),()=>{this.changeListeners.delete(e)}}notifyChange(){this.changeNotifyScheduled||(this.changeNotifyScheduled=!0,queueMicrotask(()=>{this.changeNotifyScheduled=!1;for(let e of this.changeListeners)try{e()}catch(e){g.error(`SprinkleManager.onChange handler threw`,{error:e instanceof Error?e.message:String(e)})}}))}async open(e,n,r={}){if(this.openSprinkles.has(e)){g.info(`Sprinkle already open`,{name:e});return}let a=this.availableSprinkles.get(e);if(a||=(await this.refresh(),this.availableSprinkles.get(e)),!a)throw Error(`Sprinkle not found: ${e}`);let o=await this.fs.readFile(a.path,{encoding:`utf-8`});if(o==null)throw Error(`Failed to read sprinkle content: ${a.path} (file may be corrupted or missing)`);let s=typeof o==`string`?o:new TextDecoder(`utf-8`).decode(o),c=document.createElement(`div`);c.className=`sprinkle-panel`,c.style.cssText=`width: 100%; height: 100%; display: flex; flex-direction: column; overflow-y: auto;`,c.dataset.sprinkle=e,this.openSprinkles.set(e,{renderer:null,container:c}),r.attention?this.attentionOnly.add(e):this.attentionOnly.delete(e),this.callbacks.addSprinkle(e,a.title,c,n,{...r,icon:a.icon});let l=this.bridge.createAPI(e),u=new i(c,l);await u.render(s,e);let d=this.openSprinkles.get(e);if(!d){u.dispose();return}d.renderer=u,u.activateBridgeLifecycle(),this.openSprinkles.has(e)&&(this.persistOpenSprinkles(),t(e),g.info(`Sprinkle opened`,{name:e,title:a.title}),this.notifyChange())}markActivated(e){this.attentionOnly.has(e)&&(this.attentionOnly.delete(e),this.persistOpenSprinkles(),g.info(`Sprinkle promoted from attention to user-opened`,{name:e}),this.notifyChange())}async activate(e,t){if(this.attentionOnly.has(e)){this.markActivated(e);return}let n=this.openSprinkles.get(e);if(!n){try{await this.open(e,t)}catch(t){g.warn(`Failed to open sprinkle from rail-icon click`,{name:e,error:t instanceof Error?t.message:String(t)})}return}let r=this.availableSprinkles.get(e);this.callbacks.addSprinkle(e,r?.title??e,n.container,t,{icon:r?.icon})}close(e){let t=this.openSprinkles.get(e);t&&(t.renderer?.dispose(),t.container.remove(),this.bridge.removeSprinkle(e),this.openSprinkles.delete(e),this.attentionOnly.delete(e),this.callbacks.closeSprinkleContent?this.callbacks.closeSprinkleContent(e):this.callbacks.removeSprinkle(e),this.persistOpenSprinkles(),g.info(`Sprinkle closed`,{name:e}),this.notifyChange())}minimize(e){this.openSprinkles.has(e)&&(this.callbacks.minimizeSprinkle(e),g.info(`Sprinkle minimized`,{name:e}))}available(){return Array.from(this.availableSprinkles.values())}opened(){return Array.from(this.openSprinkles.keys())}setupWatcher(e){let t=null,n=new Map,r=e=>{let r=!1;for(let t of e){let e=this.findOpenSprinkleByPath(t.path);if(e){let t=n.get(e);t&&clearTimeout(t),n.set(e,setTimeout(()=>{n.delete(e),this.reload(e).catch(t=>{g.warn(`Sprinkle reload on watcher event failed`,{name:e,error:t instanceof Error?t.message:String(t)})})},300))}else r=!0}r&&!t&&(t=setTimeout(()=>{t=null,this.openNewAutoOpenSprinkles().catch(e=>{g.warn(`Sprinkle refresh on watcher event failed`,{error:e instanceof Error?e.message:String(e)})})},150))},i=T.map(t=>e.watch(t,e=>e.endsWith(`.shtml`),r));this.watcherUnsub=()=>{for(let e of i)e();t&&=(clearTimeout(t),null);for(let e of n.values())clearTimeout(e);n.clear()}}findOpenSprinkleByPath(e){for(let[t]of this.openSprinkles){let n=this.availableSprinkles.get(t);if(n&&n.path===e)return t}return null}dispose(){this.watcherUnsub?.()}sendToSprinkle(e,t,n){let r=!n?.runtime||n.runtime===`leader`,i=!n?.runtime||n.runtime!==`leader`,a={leader:!1,followers:[]};if(r){let n=this.openSprinkles.get(e);n?(this.bridge.pushUpdate(e,t),n.renderer.pushUpdate(t),a.leader=!0):g.warn(`Cannot send to closed sprinkle`,{name:e})}if(i&&this.onSendToSprinkle)try{let r=this.onSendToSprinkle(e,t,n);r&&(a.followers=r.followers,r.unknownRuntime&&(a.unknownRuntime=r.unknownRuntime))}catch(t){g.error(`onSendToSprinkle hook threw`,{name:e,error:t instanceof Error?t.message:String(t)})}return a}};export{D as SprinkleManager,S as pruneKnownSprinkleNames,C as readKnownSprinkleNames};
|