sliccy 6.110.13 → 6.111.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ui/.vite/manifest.json +140 -140
- package/dist/ui/assets/{account-store-B5g-mrn8.js → account-store-5huAVUJd.js} +1 -1
- package/dist/ui/assets/{account-store-mFC76tgv.js → account-store-C2d9XYrH.js} +1 -1
- package/dist/ui/assets/adobe-6J5g6dZ-.js +2 -0
- package/dist/ui/assets/adobe-DdMgATM4.js +1 -0
- package/dist/ui/assets/{agent-bridge-DJ2Gh9VA.js → agent-bridge-wRC_zS0T.js} +1 -1
- package/dist/ui/assets/{agent-panels-SjLPDAhx.js → agent-panels-D4R-CbBf.js} +1 -1
- package/dist/ui/assets/{apply-layout-DegnOb_8.js → apply-layout-CljC_Ya3.js} +1 -1
- package/dist/ui/assets/{apps-CeTlBebf.js → apps-Ci2ypCzp.js} +1 -1
- package/dist/ui/assets/{azure-openai-Co7qiHsD.js → azure-openai-CafCXVCP.js} +1 -1
- package/dist/ui/assets/{azure-openai-CbsjCnKF.js → azure-openai-oQR1AY3j.js} +1 -1
- package/dist/ui/assets/{cerebras-CHy7N-5g.js → cerebras-DBILSiEr.js} +1 -1
- package/dist/ui/assets/{cerebras-CnIp8GQk.js → cerebras-asnRP0OK.js} +1 -1
- package/dist/ui/assets/{connect-surface-Hu5fOtLV.js → connect-surface-CQ2QXO1o.js} +1 -1
- package/dist/ui/assets/{directed-approval-CRALKPfL.js → directed-approval-C5DlHmLq.js} +1 -1
- package/dist/ui/assets/{fs-CSRyHRw6.js → fs-CPJfgVh0.js} +2 -2
- package/dist/ui/assets/{fs-BhUjB1cK.js → fs-DsFTKWgZ.js} +1 -1
- package/dist/ui/assets/{github-CWYdKkWk.js → github-BO6153VB.js} +1 -1
- package/dist/ui/assets/{github-CaubYdfd.js → github-BhWMVyfS.js} +2 -2
- package/dist/ui/assets/{github-copilot-Ygk85cjt.js → github-copilot-B7S-8vhk.js} +1 -1
- package/dist/ui/assets/{github-copilot-BAWQ9UfS.js → github-copilot-CeKx2NTf.js} +1 -1
- package/dist/ui/assets/{github-install-C_CLyb3u.js → github-install-TZJUKgmh.js} +1 -1
- package/dist/ui/assets/{github-zip-CKXdHtbK.js → github-zip-Cnj2AkBP.js} +1 -1
- package/dist/ui/assets/{js-realm-worker-B8Mm9E9s.js → js-realm-worker-Daj7wlpT.js} +15 -4
- package/dist/ui/assets/{kernel-worker-BBWsqNvT.js → kernel-worker-J_TbwK8T.js} +541 -541
- package/dist/ui/assets/{local-llm-DiTdUVxp.js → local-llm-BWQ3He74.js} +1 -1
- package/dist/ui/assets/{local-llm-CBszF_hu.js → local-llm-CmEq7Stx.js} +1 -1
- package/dist/ui/assets/{main-DzWg1TK_.js → main-ZU92NtZw.js} +3 -3
- package/dist/ui/assets/mount-BfB7iXvU.js +12 -0
- package/dist/ui/assets/mount-CD64xiPS.js +3 -0
- package/dist/ui/assets/mount-recovery-BBOSA9YV.js +2 -0
- package/dist/ui/assets/{new-session-jeNmXk7P.js → new-session-nSS-DCLV.js} +2 -2
- package/dist/ui/assets/{oauth-bootstrap-8ihF-R_z.js → oauth-bootstrap-Colw7nkj.js} +2 -2
- package/dist/ui/assets/{openai-codex-BzNYKmfn.js → openai-codex-hgaXe8rW.js} +1 -1
- package/dist/ui/assets/{openai-codex-lPthoW8r.js → openai-codex-qmfE81HH.js} +1 -1
- package/dist/ui/assets/{openrouter-mwt9jwZa.js → openrouter-B2_3FEmY.js} +1 -1
- package/dist/ui/assets/{openrouter-BknXSW5c.js → openrouter-D2LKKYhW.js} +1 -1
- package/dist/ui/assets/{openrouter-oauth-BXgZzA3Q.js → openrouter-oauth-BhIVrilr.js} +1 -1
- package/dist/ui/assets/{openrouter-oauth-B65Wk580.js → openrouter-oauth-BwOKdiOL.js} +1 -1
- package/dist/ui/assets/{panel-rpc-handlers-NEPkzdP3.js → panel-rpc-handlers-MZnNKHBC.js} +2 -2
- package/dist/ui/assets/{panelize-shell-C8nHDKSj.js → panelize-shell-DnZjsHE1.js} +1 -1
- package/dist/ui/assets/{provider-l9BFMaHE.js → provider-CJ3Zf2lk.js} +1 -1
- package/dist/ui/assets/{provider-BD2eMVRi.js → provider-CrmAetaJ.js} +2 -2
- package/dist/ui/assets/{provider-settings-8XzaJ7Uj.js → provider-settings-C6t3FTvi.js} +1 -1
- package/dist/ui/assets/{provider-settings-CsTcfP8K.js → provider-settings-DDq1uOSZ.js} +1 -1
- package/dist/ui/assets/{provider-store-access-DdMRpexA.js → provider-store-access-BeYCdCyj.js} +2 -2
- package/dist/ui/assets/provider-store-access-ktUJ0f7H.js +1 -0
- package/dist/ui/assets/{providers-CGzsfbUR.js → providers-Dzua7awM.js} +2 -2
- package/dist/ui/assets/{providers-Bybk43BU.js → providers-igVhiinv.js} +1 -1
- package/dist/ui/assets/{quick-llm-BjHgHVhH.js → quick-llm-biFdkUKD.js} +1 -1
- package/dist/ui/assets/{recovery-screen-J3JWTpgF.js → recovery-screen-Bau5w59K.js} +1 -1
- package/dist/ui/assets/{run-BvngdJSx.js → run-V7i6CRW2.js} +1 -1
- package/dist/ui/assets/{session-freezer-Dp8tR_wX.js → session-freezer-Pej6xP_h.js} +3 -3
- package/dist/ui/assets/{setup-feature-flags-remote-4vmTEIMx.js → setup-feature-flags-remote-Djw73MiT.js} +1 -1
- package/dist/ui/assets/{setup-standalone-prelude-4rQCXLGL.js → setup-standalone-prelude-DVnD2YOt.js} +1 -1
- package/dist/ui/assets/{setup-sudo-D-pI9Wj_.js → setup-sudo-Sg6jPLd8.js} +2 -2
- package/dist/ui/assets/{skills-DFSM0Mzw.js → skills-D8XaTxOF.js} +1 -1
- package/dist/ui/assets/slicc-version-DkKuMdfp.js +1 -0
- package/dist/ui/assets/{state-Bxe7U2uR.js → state-pLijtNur.js} +1 -1
- package/dist/ui/assets/{store-BwjB3mN4.js → store-C6JhZrDR.js} +1 -1
- package/dist/ui/assets/{store-DgTQh3uY.js → store-D3Nz9k_U.js} +1 -1
- package/dist/ui/assets/{sudo-B1uN4VjQ.js → sudo-T-PxlTiH.js} +1 -1
- package/dist/ui/assets/{upgrade-detection-Dm6JI5c7.js → upgrade-detection-Dc_Ox92s.js} +1 -1
- package/dist/ui/assets/{wc-attach-2iyRKvmt.js → wc-attach-D663Nr87.js} +2 -2
- package/dist/ui/assets/{wc-extension-DvH_frrB.js → wc-extension-biCKwlke.js} +2 -2
- package/dist/ui/assets/{wc-float-label-CPaEzWWM.js → wc-float-label-BYB2OvzB.js} +1 -1
- package/dist/ui/assets/{wc-floatbar-online-GqMjLIby.js → wc-floatbar-online-D33VmpVZ.js} +1 -1
- package/dist/ui/assets/{wc-follower-3cX8fmJu.js → wc-follower-CJ8peVT_.js} +3 -3
- package/dist/ui/assets/{wc-follower-oauth-B_i4VloV.js → wc-follower-oauth-Ce5uqp4l.js} +1 -1
- package/dist/ui/assets/{wc-live-M5a3sBeq.js → wc-live-CxJAPZUQ.js} +4 -4
- package/dist/ui/assets/{wc-nav-CHWKuXtU.js → wc-nav-DrnMXngR.js} +2 -2
- package/dist/ui/assets/{wc-onboarding-BKIUSDvB.js → wc-onboarding-D3RegjeS.js} +2 -2
- package/dist/ui/assets/{wc-placeholder-bZ8QbN6-.js → wc-placeholder-CcUDPjiw.js} +2 -2
- package/dist/ui/assets/{wc-settings-CBxN34VQ.js → wc-settings-CW4RBrLN.js} +2 -2
- package/dist/ui/assets/{wc-shell-Cdl88M0O.js → wc-shell-v_L8CKjn.js} +5 -5
- package/dist/ui/assets/{wc-shortcut-config-kW-FDTbf.js → wc-shortcut-config-CmN4peN6.js} +1 -1
- package/dist/ui/assets/{wc-sprinkles-CZHZhfaV.js → wc-sprinkles-BwiYA03A.js} +2 -2
- package/dist/ui/assets/{wc-tray-XaKABUZZ.js → wc-tray-BM36fqHv.js} +4 -4
- package/dist/ui/assets/{xai-grok-D0_yKThq.js → xai-grok-CjNdMwmo.js} +1 -1
- package/dist/ui/assets/{xai-grok-ktVvnBiV.js → xai-grok-DMcdPf6b.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/adobe-BCBLeEqn.js +0 -1
- package/dist/ui/assets/adobe-DN_cMZlf.js +0 -2
- package/dist/ui/assets/mount-4B-1d5oh.js +0 -2
- package/dist/ui/assets/mount-CY0WMJLG.js +0 -1
- package/dist/ui/assets/mount-recovery-DBMLMXSG.js +0 -2
- package/dist/ui/assets/provider-store-access-DO9H0PId.js +0 -1
- package/dist/ui/assets/slicc-version-DamSgLEW.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{H as e,d as t}from"./account-store-
|
|
1
|
+
import{H as e,d as t}from"./account-store-C2d9XYrH.js";import{a as n}from"./diagnostics-DN_idNHx.js";import{c as r,u as i}from"./claude-model-version-C0HLsjny.js";import{c as a,i as o,r as s,s as c}from"./legacy-api-aliases-7-tLus57.js";import"./provider-settings-C6t3FTvi.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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as e,n as t}from"./account-store-
|
|
1
|
+
import{g as e,n as t}from"./account-store-5huAVUJd.js";import{a as n}from"./diagnostics-DN_idNHx.js";import{a as r,r as i}from"./compat-Dujkqs4W.js";import{c as a,i as o,r as s,s as c}from"./legacy-api-aliases-PgIrFmtQ.js";import"./provider-settings-DDq1uOSZ.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};
|
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-ZU92NtZw.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-Dzua7awM.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-C2d9XYrH.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-Sg6jPLd8.js">
|
|
41
|
+
<link rel="modulepreload" crossorigin href="/assets/setup-standalone-prelude-DVnD2YOt.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-C6t3FTvi.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-ZU92NtZw.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-Dzua7awM.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-C2d9XYrH.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-Sg6jPLd8.js">
|
|
41
|
+
<link rel="modulepreload" crossorigin href="/assets/setup-standalone-prelude-DVnD2YOt.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-C6t3FTvi.js">
|
|
48
48
|
</head>
|
|
49
49
|
<body>
|
|
50
50
|
<div id="app"></div>
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./panel-rpc-BPwAqRch.js";import{g as t,n,o as r,x as i}from"./account-store-B5g-mrn8.js";import{a}from"./diagnostics-DN_idNHx.js";import{a as o,i as s,r as c}from"./compat-Dujkqs4W.js";import{a as l,r as u,s as d,t as f}from"./legacy-api-aliases-PgIrFmtQ.js";import{i as p,n as m,r as h}from"./claude-model-version-CJiITCDG.js";import{n as g}from"./llm-session-id-BZyXP_j2.js";import{n as _,t as v}from"./silent-renew-backoff-C_Iv54ZG.js";import{getOAuthPageOrigin as ee}from"./oauth-service-TDESX_tk.js";import{n as y}from"./temperature-support-BCoY8YuX.js";import"./provider-settings-CsTcfP8K.js";var te={proxyEndpoint:`https://adobe-llm-proxy.paolo-moz.workers.dev`,redirectUri:`https://www.sliccy.ai/auth/callback`,extensionRedirectUri:`https://akjjllgokmbgpbdbmafpiefnhidlmbgf.chromiumapp.org/adobe`};function b(e,t){return m(e,t)}function x(e,t,n){return e!==`xhigh`||!t?e:p(t,n)?`xhigh`:h(t,n)?`max`:`high`}function ne(e,t){let n=e?t?.thinkingLevelMap?.[e]:void 0;return x((()=>{if(typeof n==`string`)return n;switch(e){case`minimal`:case`low`:return`low`;case`medium`:return`medium`;case`xhigh`:return`xhigh`;default:return`high`}})(),t?.id,t?.name)}function re(e,t){return async(n,r)=>{let i=t?await t(n,r)??n:n,a=i.thinking;return a&&a.type===`enabled`&&(i.thinking={type:`adaptive`,...a.display===void 0?{}:{display:a.display}},i.output_config={...i.output_config??{},effort:e}),i}}function S(e,t){if(!b(e.id,e.name))return t;let n=t,r=x(n.effort??ne(n.reasoning,e),e.id,e.name);return{...t,onPayload:re(r,n.onPayload)}}function ie(e,t){let n={id:e.id,name:e.name??e.id},r=t?.api??e.api,i=t?.context_window??e.context_window,a=t?.max_tokens??e.max_tokens,o=t?.reasoning??e.reasoning,s=t?.input??e.input;r&&(n.api=r),i!==void 0&&(n.context_window=i),a!==void 0&&(n.max_tokens=a),o!==void 0&&(n.reasoning=o),s&&(n.input=s);let c=t?.cost??e.cost;return c&&(n.cost=c),/haiku/i.test(e.id)&&(n.compat={supportsEagerToolInputStreaming:!1}),/sonnet-5\b/i.test(e.id)&&!n.thinkingLevelMap&&(n.thinkingLevelMap={xhigh:`xhigh`}),n}const C=Object.assign({"/packages/webapp/providers/adobe-config.json":te})[`/packages/webapp/providers/adobe-config.json`]??{clientId:``,proxyEndpoint:``,scopes:`openid,profile,email`};function w(){let e=r(`adobe`);if(e)return e.replace(/\/$/,``);if(C.proxyEndpoint)return C.proxyEndpoint.replace(/\/$/,``);throw Error(`Adobe proxy endpoint not configured — set it in Settings or adobe-config.json`)}const T=new Map,E=new Map,D=`slicc-adobe-models`;function O(e){try{localStorage.setItem(D,JSON.stringify(e))}catch{}}async function k(e){let t=T.get(e);if(t)return t;try{let t=await fetch(`${e}/v1/config`,{headers:{[W]:`6.110.13`}});if(t.ok){let n=await t.json();return T.set(e,n),n}console.warn(`[adobe] Proxy /v1/config returned ${t.status}, falling back to build-time config`)}catch(e){console.warn(`[adobe] Failed to fetch proxy config:`,e instanceof Error?e.message:String(e))}return{}}function A(e){let t=e.clientId||C.clientId;if(!t)throw Error(`Could not determine IMS client ID — proxy /v1/config did not return one and adobe-config.json is empty`);return t}function j(e){return e.scopes||C.scopes}function M(e){return e.imsEnvironment||C.imsEnvironment||`prod`}const N={prod:`https://ims-na1.adobelogin.com`,stg1:`https://ims-na1-stg1.adobelogin.com`};function P(e){return N[e??C.imsEnvironment??`prod`]??N.prod}const F=typeof chrome<`u`&&!!chrome?.runtime?.id;function I(){return n().find(e=>e.providerId===`adobe`)}async function ae(e,t){try{let n=await fetch(`${P(t)}/ims/userinfo/v2`,{headers:{Authorization:`Bearer ${e}`}});if(n.ok){let e=await n.json();return{name:e.displayName||e.name||e.email,avatar:e.picture||e.avatar_url}}console.warn(`[adobe] User profile fetch returned ${n.status}, account will have no display name`)}catch(e){console.warn(`[adobe] Failed to fetch user profile:`,e instanceof Error?e.message:String(e))}return{}}function L(e){let t=e.indexOf(`#`);if(t<0)return null;let n=new URLSearchParams(e.slice(t+1)),r=n.get(`access_token`);return r?{accessToken:r,expiresIn:parseInt(n.get(`expires_in`)??`86400`,10),scope:n.get(`scope`)??void 0}:null}const R={id:`adobe`,name:`Adobe`,description:`Claude via Adobe — login with your Adobe ID`,requiresApiKey:!1,requiresBaseUrl:!C.proxyEndpoint,baseUrlPlaceholder:`https://your-proxy.example.com`,baseUrlDescription:`Anthropic-compatible proxy endpoint`,isOAuth:!0,defaultModelId:`sonnet`,oauthTokenDomains:[`ims-na1.adobelogin.com`,`ims-na1-stg1.adobelogin.com`,`*.adobelogin.com`,`*.adobe.io`,`firefall.adobe.io`,`admin.hlx.page`,`admin.hlx.live`,`admin.aem.page`,`admin.aem.live`],getModelIds:()=>{let e=e=>ie(e,E.get(e.id));for(let t of Q.values())if(t.length){let n=t.map(t=>e({id:t.id,name:t.name??t.id,reasoning:t.reasoning,input:t.input,cost:t.cost}));return O(n),n}for(let t of T.values())if(t.models?.length)return t.models.map(t=>e(t));try{let e=localStorage.getItem(D);if(e){let t=JSON.parse(e);if(t.length)return t}}catch{}return[{id:`claude-sonnet-4-6`,name:`Claude Sonnet 4.6`}]},onOAuthLogin:async(e,n,r)=>{let i=w(),a=await k(i),o=A(a),s=j(a),c=M(a),l=F?null:await ee(),u=F?null:_({pageHref:l.href,pageOrigin:l.origin,configuredRedirectUri:C.redirectUri},()=>crypto.randomUUID()),d=F?C.extensionRedirectUri??`https://${chrome.runtime.id}.chromiumapp.org/`:u.redirectUri,f=u?.oauthState,p=u?.expectedNonce??null,m=new URLSearchParams({client_id:o,scope:s,response_type:`token`,redirect_uri:d});f&&m.set(`state`,f),r?.forceReauth&&m.set(`prompt`,`login`);let h=await e(`${P(c)}/ims/authorize/v2?${m}`);if(!h)return;if(p&&h)try{if(new URL(h).searchParams.get(`nonce`)!==p){console.error(`[adobe] OAuth nonce mismatch — possible CSRF`);return}}catch(e){console.warn(`[adobe] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}let g=L(h);if(!g){console.error(`[adobe] Could not extract token from redirect URL`);return}let v=await ae(g.accessToken,c);await t({providerId:`adobe`,accessToken:g.accessToken,tokenExpiresAt:Date.now()+g.expiresIn*1e3,userName:v.name,userAvatar:v.avatar,scopes:g.scope,baseUrl:C.proxyEndpoint?void 0:i}),await $().catch(e=>console.warn(`[adobe] Failed to fetch models after login:`,e instanceof Error?e.message:String(e))),n()},onOAuthLogout:async()=>{let e=I();if(e?.accessToken)try{let t=T.values().next().value??{},n=t.clientId||C.clientId,r=M(t);if(n){let t=await fetch(`${P(r)}/ims/revoke`,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:new URLSearchParams({token:e.accessToken,token_type_hint:`access_token`,client_id:n})});t.ok||console.warn(`[adobe] Token revocation returned ${t.status}, token may still be valid server-side`)}}catch(e){console.warn(`[adobe] Failed to revoke token:`,e instanceof Error?e.message:String(e))}await t({providerId:`adobe`,accessToken:``})},onSilentRenew:async()=>I()?.accessToken?V():null,refreshModels:async e=>{await $(e);let t=R.getModelIds?.();t?.length&&O(t)}};let z=null;const oe=v();async function B(){let e=I();if(!e?.accessToken)throw Error(`Not logged in to Adobe — please log in first`);if((e.tokenExpiresAt??0)-Date.now()>6e4)return e.accessToken;console.log(`[adobe] Token expired or expiring soon, attempting silent renewal...`);let t=await oe.run(()=>V());if(t)return t;let n=I();if((n?.tokenExpiresAt??0)-Date.now()>0&&n?.accessToken)return n.accessToken;throw Error(`Adobe session expired — please log in again`)}function se(){let e=I();return!e?.tokenExpiresAt||Date.now()>e.tokenExpiresAt-6e4}async function V(){if(typeof window>`u`){let t=e();if(!t)return null;try{let{accessToken:e}=await t.call(`silent-renew`,{providerId:`adobe`},{timeoutMs:13e4});return e}catch(e){return console.warn(`[adobe] worker→page silent-renew bridge failed:`,e instanceof Error?e.message:String(e)),null}}return z===null&&(z=U().finally(()=>{z=null})),z}function ce(e,t){let n=A(t),r=j(t),i=M(t),a=F?null:_({pageHref:window.location.href,pageOrigin:window.location.origin,configuredRedirectUri:C.redirectUri},()=>crypto.randomUUID()),o=F?C.extensionRedirectUri??`https://${chrome.runtime.id}.chromiumapp.org/`:a.redirectUri,s=a?.oauthState,c=a?.expectedNonce??null,l=new URLSearchParams({client_id:n,scope:r,response_type:`token`,redirect_uri:o,prompt:`none`});return s&&l.set(`state`,s),{authorizeUrl:`${P(i)}/ims/authorize/v2?${l}`,expectedNonce:c,proxyEndpoint:e}}function le(e,t){if(!t)return!0;try{if(new URL(e).searchParams.get(`nonce`)!==t)return console.error(`[adobe] OAuth nonce mismatch — possible CSRF`),!1}catch(e){console.warn(`[adobe] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}return!0}async function H(e,n){let r=I();await t({providerId:`adobe`,accessToken:e.accessToken,tokenExpiresAt:Date.now()+e.expiresIn*1e3,userName:r?.userName,userAvatar:r?.userAvatar,scopes:e.scope,baseUrl:C.proxyEndpoint?void 0:n})}async function U(){try{let e=w(),{authorizeUrl:t,expectedNonce:n}=ce(e,await k(e)),{createOAuthLauncher:r}=await import(`./oauth-service-TDESX_tk.js`),i=await r()(t,{interactive:!1});if(!i||!le(i,n))return null;let a=L(i);return a?(await H(a,e),console.log(`[adobe] Token renewed silently`),await $().catch(e=>console.warn(`[adobe] Failed to refresh models after silent renewal:`,e instanceof Error?e.message:String(e))),a.accessToken):null}catch(e){return console.warn(`[adobe] Silent renewal error:`,e instanceof Error?e.message:String(e)),null}}const W=`X-Slicc-Version`;function G(e){let t={};if(e.headers)for(let[n,r]of Object.entries(e.headers))n.toLowerCase()!==`x-slicc-version`&&(t[n]=r);return t[W]=`6.110.13`,{...e,headers:t}}const K=new Set;function q(e,t){if(e.headers){for(let[t,n]of Object.entries(e.headers))if(t.toLowerCase()===`x-session-id`&&n!=null)return e}return K.has(t)||(K.add(t),console.warn(`[adobe] Missing X-Session-Id from ${t} — using daily fallback. Attach an X-Session-Id header at the call site (see scoop-context.ts streamWithSessionId or docs/pitfalls.md).`)),{...e,headers:{...e.headers??{},"X-Session-Id":g(`adobe-provider-fallback`)}}}function ue(){K.clear()}function J(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:`adobe-anthropic`,provider:`adobe`,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 Y(e){console.error(`[adobe] Stream error:`,e instanceof Error?e.message:String(e))}const X=(e,t,n={})=>{let r=a();return de(r,e,t,n).catch(Y),r};async function de(e,t,n,r){try{let i=await B();if(String(t.api).includes(`openai`)){let a={...t,baseUrl:`${w()}/v1`,api:`openai-completions`,compat:{...t.compat,supportsStore:!1,supportsDeveloperRole:!1}},o=u(a,n,G(q({...r,apiKey:i},`streamAdobe[openai]`)));for await(let t of o)e.push(t)}else{let a={...t,baseUrl:w(),api:`anthropic-messages`},o=f(a,n,G(q(S(t,y(t.id,t.name,{...r,apiKey:i})),`streamAdobe[anthropic]`)));for await(let t of o)e.push(t)}e.end()}catch(n){Y(n),e.push(J(t,n)),e.end()}}const Z=(e,t,n)=>{let r=a();return fe(r,e,t,n).catch(Y),r};async function fe(e,t,n,r){try{let i=await B();if(String(t.api).includes(`openai`)){let a={...t,baseUrl:`${w()}/v1`,api:`openai-completions`,compat:{...t.compat,supportsStore:!1,supportsDeveloperRole:!1}},o=d(a,n,G(q({...r,apiKey:i},`streamSimpleAdobe[openai]`)));for await(let t of o)e.push(t)}else{let a={...t,baseUrl:w(),api:`anthropic-messages`},o=l(a,n,G(q(S(t,y(t.id,t.name,{...r,apiKey:i})),`streamSimpleAdobe[anthropic]`)));for await(let t of o)e.push(t)}e.end()}catch(n){Y(n),e.push(J(t,n)),e.end()}}function pe(e){let t={id:e.id,name:e.name};return e.api!==void 0&&(t.api=e.api),e.context_window!==void 0&&(t.context_window=e.context_window),e.max_tokens!==void 0&&(t.max_tokens=e.max_tokens),e.reasoning!==void 0&&(t.reasoning=e.reasoning),e.input!==void 0&&(t.input=e.input),t}function me(){let e=new Map;for(let t of s())try{for(let n of c(t))e.set(n.id,n)}catch{}return e}function he(e,t,n){let r=`adobe-${e.api===`openai`?`openai`:`anthropic`}`,a=n.get(e.id);if(a)return{...a,provider:`adobe`,api:r};let o=i(e.id,n);return{id:e.id,name:e.name??e.id,provider:`adobe`,api:r,baseUrl:t,contextWindow:2e5,maxTokens:16384,input:[`text`,`image`],cost:o,inputCost:o.input,outputCost:o.output,cacheReadCost:o.cacheRead,cacheWriteCost:o.cacheWrite,reasoning:!0}}function ge(e,t){for(let t of e)E.set(t.id,pe(t));let n=me();return e.map(e=>he(e,t,n))}async function _e(e){try{let t=e??await B(),n=w(),r=await fetch(`${n}/v1/models`,{headers:{Authorization:`Bearer ${t}`,[W]:`6.110.13`}});if(!r.ok)console.warn(`[adobe] Proxy /v1/models returned ${r.status}, falling back to Anthropic models`);else{let e=await r.json();if(e.data?.length)return ge(e.data,n)}}catch(e){console.warn(`[adobe] Failed to fetch proxy models:`,e instanceof Error?e.message:String(e))}return null}const Q=new Map;function ve(){return c(`anthropic`).map(e=>({...e,provider:`adobe`,api:`adobe-anthropic`}))}async function $(e){let t=w(),n=Q.get(t);if(n)return n;let r=await _e(e);return r?(Q.set(t,r),r):ve()}function ye(){o({api:`adobe-anthropic`,stream:X,streamSimple:Z}),o({api:`adobe-openai`,stream:X,streamSimple:Z})}export{ue as __resetAdobeSessionIdWarningCacheForTests,R as config,L as extractTokenFromUrl,$ as getAdobeModels,B as getValidAccessToken,se as isTokenExpired,ye as register};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/oauth-service-NaEg6KHx.js","assets/preload-helper-Czpn1I53.js","assets/proxied-fetch-CFWkfPNA.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/base64-DJRlyqZu.js","assets/src-CAWTvdAa.js","assets/runtime-env-Dlaokqg1.js","assets/fetch-body-D2PwksUW.js","assets/api-endpoint-GRCyib6X.js","assets/runtime-env-CgsZ7LTp.js","assets/runtime-env-E-i2SW1s.js","assets/panel-rpc-B3MSVImO.js","assets/permissions-surface-registry-CilCRwhh.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{H as e,Y as t,d as n,y as r}from"./account-store-mFC76tgv.js";import{a as i}from"./diagnostics-DN_idNHx.js";import{t as a}from"./preload-helper-Czpn1I53.js";import{c as o,i as s,l as c,n as l,r as u,u as d}from"./claude-model-version-C0HLsjny.js";import{a as f,r as p,s as m,t as h}from"./legacy-api-aliases-7-tLus57.js";import{n as g,t as _}from"./silent-renew-backoff-t_Cd4Zw7.js";import{t as v}from"./panel-rpc-B3MSVImO.js";import"./provider-settings-8XzaJ7Uj.js";import{getOAuthPageOrigin as y}from"./oauth-service-NaEg6KHx.js";import{n as b}from"./temperature-support-BZ2SNscA.js";import{t as ee}from"./llm-session-id-bZQs6gBN.js";var te={proxyEndpoint:`https://adobe-llm-proxy.paolo-moz.workers.dev`,redirectUri:`https://www.sliccy.ai/auth/callback`,extensionRedirectUri:`https://akjjllgokmbgpbdbmafpiefnhidlmbgf.chromiumapp.org/adobe`};function ne(e,t){return l(e,t)}function x(e,t,n){return e!==`xhigh`||!t?e:s(t,n)?`xhigh`:u(t,n)?`max`:`high`}function re(e,t){let n=e?t?.thinkingLevelMap?.[e]:void 0;return x((()=>{if(typeof n==`string`)return n;switch(e){case`minimal`:case`low`:return`low`;case`medium`:return`medium`;case`xhigh`:return`xhigh`;default:return`high`}})(),t?.id,t?.name)}function ie(e,t){return async(n,r)=>{let i=t?await t(n,r)??n:n,a=i.thinking;return a&&a.type===`enabled`&&(i.thinking={type:`adaptive`,...a.display===void 0?{}:{display:a.display}},i.output_config={...i.output_config??{},effort:e}),i}}function S(e,t){if(!ne(e.id,e.name))return t;let n=t,r=x(n.effort??re(n.reasoning,e),e.id,e.name);return{...t,onPayload:ie(r,n.onPayload)}}function ae(e,t){let n={id:e.id,name:e.name??e.id},r=t?.api??e.api,i=t?.context_window??e.context_window,a=t?.max_tokens??e.max_tokens,o=t?.reasoning??e.reasoning,s=t?.input??e.input;r&&(n.api=r),i!==void 0&&(n.context_window=i),a!==void 0&&(n.max_tokens=a),o!==void 0&&(n.reasoning=o),s&&(n.input=s);let c=t?.cost??e.cost;return c&&(n.cost=c),/haiku/i.test(e.id)&&(n.compat={supportsEagerToolInputStreaming:!1}),/sonnet-5\b/i.test(e.id)&&!n.thinkingLevelMap&&(n.thinkingLevelMap={xhigh:`xhigh`}),n}var C=Object.assign({"/packages/webapp/providers/adobe-config.json":te})[`/packages/webapp/providers/adobe-config.json`]??{clientId:``,proxyEndpoint:``,scopes:`openid,profile,email`};function w(){let e=r(`adobe`);if(e)return e.replace(/\/$/,``);if(C.proxyEndpoint)return C.proxyEndpoint.replace(/\/$/,``);throw Error(`Adobe proxy endpoint not configured — set it in Settings or adobe-config.json`)}var T=new Map,E=new Map,D=`slicc-adobe-models`;function O(e){try{localStorage.setItem(D,JSON.stringify(e))}catch{}}async function k(e){let t=T.get(e);if(t)return t;try{let t=await fetch(`${e}/v1/config`,{headers:{[W]:`6.110.13`}});if(t.ok){let n=await t.json();return T.set(e,n),n}console.warn(`[adobe] Proxy /v1/config returned ${t.status}, falling back to build-time config`)}catch(e){console.warn(`[adobe] Failed to fetch proxy config:`,e instanceof Error?e.message:String(e))}return{}}function A(e){let t=e.clientId||C.clientId;if(!t)throw Error(`Could not determine IMS client ID — proxy /v1/config did not return one and adobe-config.json is empty`);return t}function j(e){return e.scopes||C.scopes}function M(e){return e.imsEnvironment||C.imsEnvironment||`prod`}var N={prod:`https://ims-na1.adobelogin.com`,stg1:`https://ims-na1-stg1.adobelogin.com`};function P(e){return N[e??C.imsEnvironment??`prod`]??N.prod}var F=typeof chrome<`u`&&!!chrome?.runtime?.id;function I(){return n().find(e=>e.providerId===`adobe`)}async function oe(e,t){try{let n=await fetch(`${P(t)}/ims/userinfo/v2`,{headers:{Authorization:`Bearer ${e}`}});if(n.ok){let e=await n.json();return{name:e.displayName||e.name||e.email,avatar:e.picture||e.avatar_url}}console.warn(`[adobe] User profile fetch returned ${n.status}, account will have no display name`)}catch(e){console.warn(`[adobe] Failed to fetch user profile:`,e instanceof Error?e.message:String(e))}return{}}function L(e){let t=e.indexOf(`#`);if(t<0)return null;let n=new URLSearchParams(e.slice(t+1)),r=n.get(`access_token`);return r?{accessToken:r,expiresIn:parseInt(n.get(`expires_in`)??`86400`,10),scope:n.get(`scope`)??void 0}:null}var R={id:`adobe`,name:`Adobe`,description:`Claude via Adobe — login with your Adobe ID`,requiresApiKey:!1,requiresBaseUrl:!C.proxyEndpoint,baseUrlPlaceholder:`https://your-proxy.example.com`,baseUrlDescription:`Anthropic-compatible proxy endpoint`,isOAuth:!0,defaultModelId:`sonnet`,oauthTokenDomains:[`ims-na1.adobelogin.com`,`ims-na1-stg1.adobelogin.com`,`*.adobelogin.com`,`*.adobe.io`,`firefall.adobe.io`,`admin.hlx.page`,`admin.hlx.live`,`admin.aem.page`,`admin.aem.live`],getModelIds:()=>{let e=e=>ae(e,E.get(e.id));for(let t of Q.values())if(t.length){let n=t.map(t=>e({id:t.id,name:t.name??t.id,reasoning:t.reasoning,input:t.input,cost:t.cost}));return O(n),n}for(let t of T.values())if(t.models?.length)return t.models.map(t=>e(t));try{let e=localStorage.getItem(D);if(e){let t=JSON.parse(e);if(t.length)return t}}catch{}return[{id:`claude-sonnet-4-6`,name:`Claude Sonnet 4.6`}]},onOAuthLogin:async(t,n,r)=>{let i=w(),a=await k(i),o=A(a),s=j(a),c=M(a),l=F?null:await y(),u=F?null:g({pageHref:l.href,pageOrigin:l.origin,configuredRedirectUri:C.redirectUri},()=>crypto.randomUUID()),d=F?C.extensionRedirectUri??`https://${chrome.runtime.id}.chromiumapp.org/`:u.redirectUri,f=u?.oauthState,p=u?.expectedNonce??null,m=new URLSearchParams({client_id:o,scope:s,response_type:`token`,redirect_uri:d});f&&m.set(`state`,f),r?.forceReauth&&m.set(`prompt`,`login`);let h=await t(`${P(c)}/ims/authorize/v2?${m}`);if(!h)return;if(p&&h)try{if(new URL(h).searchParams.get(`nonce`)!==p){console.error(`[adobe] OAuth nonce mismatch — possible CSRF`);return}}catch(e){console.warn(`[adobe] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}let _=L(h);if(!_){console.error(`[adobe] Could not extract token from redirect URL`);return}let v=await oe(_.accessToken,c);await e({providerId:`adobe`,accessToken:_.accessToken,tokenExpiresAt:Date.now()+_.expiresIn*1e3,userName:v.name,userAvatar:v.avatar,scopes:_.scope,baseUrl:C.proxyEndpoint?void 0:i}),await $().catch(e=>console.warn(`[adobe] Failed to fetch models after login:`,e instanceof Error?e.message:String(e))),n()},onOAuthLogout:async()=>{let t=I();if(t?.accessToken)try{let e=T.values().next().value??{},n=e.clientId||C.clientId,r=M(e);if(n){let e=await fetch(`${P(r)}/ims/revoke`,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:new URLSearchParams({token:t.accessToken,token_type_hint:`access_token`,client_id:n})});e.ok||console.warn(`[adobe] Token revocation returned ${e.status}, token may still be valid server-side`)}}catch(e){console.warn(`[adobe] Failed to revoke token:`,e instanceof Error?e.message:String(e))}await e({providerId:`adobe`,accessToken:``})},onSilentRenew:async()=>I()?.accessToken?V():null,refreshModels:async e=>{await $(e);let t=R.getModelIds?.();t?.length&&O(t)}},z=null,se=_();async function B(){let e=I();if(!e?.accessToken)throw Error(`Not logged in to Adobe — please log in first`);if((e.tokenExpiresAt??0)-Date.now()>6e4)return e.accessToken;console.log(`[adobe] Token expired or expiring soon, attempting silent renewal...`);let t=await se.run(()=>V());if(t)return t;let n=I();if((n?.tokenExpiresAt??0)-Date.now()>0&&n?.accessToken)return n.accessToken;throw Error(`Adobe session expired — please log in again`)}function ce(){let e=I();return!e?.tokenExpiresAt||Date.now()>e.tokenExpiresAt-6e4}async function V(){if(typeof window>`u`){let e=v();if(!e)return null;try{let{accessToken:t}=await e.call(`silent-renew`,{providerId:`adobe`},{timeoutMs:13e4});return t}catch(e){return console.warn(`[adobe] worker→page silent-renew bridge failed:`,e instanceof Error?e.message:String(e)),null}}return z===null&&(z=ue().finally(()=>{z=null})),z}function le(e,t){let n=A(t),r=j(t),i=M(t),a=F?null:g({pageHref:window.location.href,pageOrigin:window.location.origin,configuredRedirectUri:C.redirectUri},()=>crypto.randomUUID()),o=F?C.extensionRedirectUri??`https://${chrome.runtime.id}.chromiumapp.org/`:a.redirectUri,s=a?.oauthState,c=a?.expectedNonce??null,l=new URLSearchParams({client_id:n,scope:r,response_type:`token`,redirect_uri:o,prompt:`none`});return s&&l.set(`state`,s),{authorizeUrl:`${P(i)}/ims/authorize/v2?${l}`,expectedNonce:c,proxyEndpoint:e}}function H(e,t){if(!t)return!0;try{if(new URL(e).searchParams.get(`nonce`)!==t)return console.error(`[adobe] OAuth nonce mismatch — possible CSRF`),!1}catch(e){console.warn(`[adobe] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}return!0}async function U(t,n){let r=I();await e({providerId:`adobe`,accessToken:t.accessToken,tokenExpiresAt:Date.now()+t.expiresIn*1e3,userName:r?.userName,userAvatar:r?.userAvatar,scopes:t.scope,baseUrl:C.proxyEndpoint?void 0:n})}async function ue(){try{let e=w(),{authorizeUrl:t,expectedNonce:n}=le(e,await k(e)),{createOAuthLauncher:r}=await a(async()=>{let{createOAuthLauncher:e}=await import(`./oauth-service-NaEg6KHx.js`);return{createOAuthLauncher:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12])),i=await r()(t,{interactive:!1});if(!i||!H(i,n))return null;let o=L(i);return o?(await U(o,e),console.log(`[adobe] Token renewed silently`),await $().catch(e=>console.warn(`[adobe] Failed to refresh models after silent renewal:`,e instanceof Error?e.message:String(e))),o.accessToken):null}catch(e){return console.warn(`[adobe] Silent renewal error:`,e instanceof Error?e.message:String(e)),null}}var W=`X-Slicc-Version`;function G(e){let t={},n=W.toLowerCase();if(e.headers)for(let[r,i]of Object.entries(e.headers))r.toLowerCase()!==n&&(t[r]=i);return t[W]=`6.110.13`,{...e,headers:t}}var de=`adobe-provider-fallback`,K=new Set;function q(e,t){if(e.headers){for(let[t,n]of Object.entries(e.headers))if(t.toLowerCase()===`x-session-id`&&n!=null)return e}return K.has(t)||(K.add(t),console.warn(`[adobe] Missing X-Session-Id from ${t} — using daily fallback. Attach an X-Session-Id header at the call site (see scoop-context.ts streamWithSessionId or docs/pitfalls.md).`)),{...e,headers:{...e.headers??{},"X-Session-Id":ee(de)}}}function fe(){K.clear()}function J(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:`adobe-anthropic`,provider:`adobe`,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 Y(e){console.error(`[adobe] Stream error:`,e instanceof Error?e.message:String(e))}var X=(e,t,n={})=>{let r=i();return pe(r,e,t,n).catch(Y),r};async function pe(e,t,n,r){try{let i=await B();if(String(t.api).includes(`openai`)){let a={...t,baseUrl:`${w()}/v1`,api:`openai-completions`,compat:{...t.compat,supportsStore:!1,supportsDeveloperRole:!1}},o=p(a,n,G(q({...r,apiKey:i},`streamAdobe[openai]`)));for await(let t of o)e.push(t)}else{let a={...t,baseUrl:w(),api:`anthropic-messages`},o=h(a,n,G(q(S(t,b(t.id,t.name,{...r,apiKey:i})),`streamAdobe[anthropic]`)));for await(let t of o)e.push(t)}e.end()}catch(n){Y(n),e.push(J(t,n)),e.end()}}var Z=(e,t,n)=>{let r=i();return me(r,e,t,n).catch(Y),r};async function me(e,t,n,r){try{let i=await B();if(String(t.api).includes(`openai`)){let a={...t,baseUrl:`${w()}/v1`,api:`openai-completions`,compat:{...t.compat,supportsStore:!1,supportsDeveloperRole:!1}},o=m(a,n,G(q({...r,apiKey:i},`streamSimpleAdobe[openai]`)));for await(let t of o)e.push(t)}else{let a={...t,baseUrl:w(),api:`anthropic-messages`},o=f(a,n,G(q(S(t,b(t.id,t.name,{...r,apiKey:i})),`streamSimpleAdobe[anthropic]`)));for await(let t of o)e.push(t)}e.end()}catch(n){Y(n),e.push(J(t,n)),e.end()}}function he(e){let t={id:e.id,name:e.name};return e.api!==void 0&&(t.api=e.api),e.context_window!==void 0&&(t.context_window=e.context_window),e.max_tokens!==void 0&&(t.max_tokens=e.max_tokens),e.reasoning!==void 0&&(t.reasoning=e.reasoning),e.input!==void 0&&(t.input=e.input),t}function ge(){let e=new Map;for(let t of c())try{for(let n of o(t))e.set(n.id,n)}catch{}return e}function _e(e,n,r){let i=`adobe-${e.api===`openai`?`openai`:`anthropic`}`,a=r.get(e.id);if(a)return{...a,provider:`adobe`,api:i};let o=t(e.id,r);return{id:e.id,name:e.name??e.id,provider:`adobe`,api:i,baseUrl:n,contextWindow:2e5,maxTokens:16384,input:[`text`,`image`],cost:o,inputCost:o.input,outputCost:o.output,cacheReadCost:o.cacheRead,cacheWriteCost:o.cacheWrite,reasoning:!0}}function ve(e,t){for(let t of e)E.set(t.id,he(t));let n=ge();return e.map(e=>_e(e,t,n))}async function ye(e){try{let t=e??await B(),n=w(),r=await fetch(`${n}/v1/models`,{headers:{Authorization:`Bearer ${t}`,[W]:`6.110.13`}});if(!r.ok)console.warn(`[adobe] Proxy /v1/models returned ${r.status}, falling back to Anthropic models`);else{let e=await r.json();if(e.data?.length)return ve(e.data,n)}}catch(e){console.warn(`[adobe] Failed to fetch proxy models:`,e instanceof Error?e.message:String(e))}return null}var Q=new Map;function be(){return o(`anthropic`).map(e=>({...e,provider:`adobe`,api:`adobe-anthropic`}))}async function $(e){let t=w(),n=Q.get(t);if(n)return n;let r=await ye(e);return r?(Q.set(t,r),r):be()}function xe(){d({api:`adobe-anthropic`,stream:X,streamSimple:Z}),d({api:`adobe-openai`,stream:X,streamSimple:Z})}export{fe as __resetAdobeSessionIdWarningCacheForTests,R as config,L as extractTokenFromUrl,$ as getAdobeModels,B as getValidAccessToken,ce as isTokenExpired,xe as register};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/account-store-mFC76tgv.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/preload-helper-Czpn1I53.js","assets/claude-model-version-C0HLsjny.js","assets/models-BSkXF4T6.js","assets/diagnostics-DN_idNHx.js","assets/provider-env-CTOcDKrQ.js","assets/__vite-browser-external-5eBdwsFd.js","assets/openrouter.models-BxrUfzom.js","assets/libesm-BypnjKEL.js","assets/logger-DDBAeTLF.js","assets/src-CAWTvdAa.js","assets/proxied-fetch-CFWkfPNA.js","assets/base64-DJRlyqZu.js","assets/runtime-env-Dlaokqg1.js","assets/fetch-body-D2PwksUW.js","assets/api-endpoint-GRCyib6X.js","assets/float-topology-BYb7rxY5.js","assets/runtime-env-E-i2SW1s.js","assets/secret-topology-BE7Eyd3P.js","assets/secrets-bridge-client-H8-Z1RVR.js","assets/port-bridge-client-Cti-DmEY.js","assets/image-markers-CxJ9ZBgw.js","assets/tool-ui-eSQ1g2I1.js","assets/providers-CGzsfbUR.js","assets/panel-rpc-B3MSVImO.js","assets/bedrock-camp-compat-CgBMwna8.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{t as e}from"./preload-helper-Czpn1I53.js";import{n as t}from"./mime-types-k2E6ulyv.js";import{r as n,t as r}from"./base64-DJRlyqZu.js";import"./src-CAWTvdAa.js";import{n as i}from"./runtime-env-Dlaokqg1.js";import{i as a,n as o,t as s}from"./api-endpoint-GRCyib6X.js";import"./runtime-env-E-i2SW1s.js";import{t as c}from"./types-idfTVsM8.js";import"./mount-table-store-dY2IfQ5S.js";import"./fs-CSRyHRw6.js";import{t as l}from"./mount-bridge-client-BJeJ5p60.js";var u=`https://api.aem.live`,d=`application/folder`,f=5242880;function p(e){let t=e.match(/^aem:\/\/([^/]+)\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid AEM source '${e}' — expected aem://org/site[/path]`);return{org:t[1],site:t[2],path:(t[3]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}function m(e){if(!e)return``;let t=Date.parse(e);return Number.isNaN(t)?``:String(t)}function h(e){let t=Date.parse(e??``);return Number.isNaN(t)?0:t}function g(e){return e.map(e=>e[`content-type`]===d||e.name.endsWith(`/`)?{name:e.name.replace(/\/+$/,``),kind:`directory`}:{name:e.name,kind:`file`,size:e.size,etag:m(e[`last-modified`]),lastModified:h(e[`last-modified`])})}var _=class{kind=`aem`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=p(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??f,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new c(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toSourcePath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`),r=`/${this.parsed.org}/sites/${this.parsed.site}/source`;return n?`${r}/${n}`:r}toListPath(e){return`${this.toSourcePath(e)}/`}request(e,t,n){return this.transport({method:e,path:t,origin:u,headers:n?.headers,body:n?.body})}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r=await this.request(`GET`,this.toSourcePath(t));if(r.status===404)throw await this.cache.invalidateBody(t),new c(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new c(`EACCES`,`aem access denied`,e);if(r.status>=400)throw new c(`EIO`,`aem readFile failed: ${r.status}`,e);let i=new Uint8Array(await r.arrayBuffer());if(i.byteLength>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes`,e);return await this.cache.putBody(t,i,m(r.headers.get(`last-modified`))),i}async assertUnchanged(e,t,n){if(!n)return;let r=await this.request(`HEAD`,this.toSourcePath(t));if(r.status===404)return;if(r.status>=400)throw new c(`EIO`,`aem precondition HEAD failed: ${r.status}`,e);let i=m(r.headers.get(`last-modified`));if(i&&i!==n)throw await this.cache.invalidateBody(t),new c(`EBUSY`,`remote modified since last read — re-read and retry`,e)}async writeFile(e,t){if(this.assertOpen(e),t.byteLength>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes`,e);let n=this.toMountRelative(e),r=await this.cache.getBody(n);await this.assertUnchanged(e,n,r?.etag??``);let i=await this.request(`PUT`,this.toSourcePath(n),{body:t});if(i.status===401||i.status===403)throw new c(`EACCES`,`aem write denied`,e);if(i.status>=400)throw new c(`EIO`,`aem writeFile failed: ${i.status}`,e);await this.cache.invalidateBody(n);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a)}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.request(`GET`,this.toListPath(t));if(r.status===404)throw new c(`ENOENT`,`no such directory`,e);if(r.status===401||r.status===403)throw new c(`EACCES`,`aem access denied`,e);if(r.status>=400)throw new c(`EIO`,`aem list failed: ${r.status}`,e);let i=g(await r.json());return await this.cache.putListing(t,i),i}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e);if(t===``)return{kind:`directory`,size:0,mtime:0};let n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.size,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),i=r.pop()??``,a=r.join(`/`),o=await this.cache.getListing(a),s=(o&&!this.cache.isStale(o.cachedAt)?o.entries:await this.readDirQuietly(a))?.find(e=>e.name===i);if(!s)throw new c(`ENOENT`,`no such file or directory`,e);return s.kind===`directory`?{kind:`directory`,size:0,mtime:s.lastModified??0}:{kind:`file`,size:s.size??0,mtime:s.lastModified??0,etag:s.etag??``}}async readDirQuietly(e){try{return await this.readDir(e)}catch{return null}}async mkdir(e){}async remove(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.request(`DELETE`,this.toSourcePath(t));if(n.status===404)throw new c(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new c(`EACCES`,`aem delete denied`,e);if(n.status>=400)throw new c(`EIO`,`aem delete failed: ${n.status}`,e);await this.cache.invalidateBody(t);let r=t.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(r)}async refresh(e){this.assertOpen(`/`);let t={added:[],removed:[],changed:[],unchanged:0,errors:[]},n=[``];for(;n.length>0;){let e=n.pop();try{await this.refreshDir(e,t,n)}catch(n){t.errors.push({path:e,message:n instanceof Error?n.message:String(n)})}}return e?.bodies&&await this.refreshBodies(t),t}async classifyFile(e,t,n){let r=await this.cache.getBody(e);r?t&&r.etag!==t?(await this.cache.invalidateBody(e),n.changed.push(e)):n.unchanged++:n.added.push(e)}async refreshDir(e,t,n){let r=await this.request(`GET`,this.toListPath(e));if(r.status===404){await this.cache.putListing(e,[]);return}if(r.status>=400){t.errors.push({path:e,message:`list failed: ${r.status}`});return}let i=g(await r.json());for(let r of i){let i=e?`${e}/${r.name}`:r.name;r.kind===`directory`?n.push(i):await this.classifyFile(i,r.etag??``,t)}await this.cache.putListing(e,i)}async refreshBodies(e){for(let t of e.changed)try{await this.readFile(t)}catch(n){e.errors.push({path:t,message:n instanceof Error?n.message:String(n)})}}describe(){return{displayName:`${this.parsed.org}/${this.parsed.site}${this.parsed.path?`/${this.parsed.path}`:``}`,source:this.source,profile:this.profile}}async close(){this.closed||=!0}};function v(e,t,n){let r=`----DaMount${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`,i=new TextEncoder,a=i.encode(`--${r}\r\nContent-Disposition: form-data; name="data"; filename="${e}"\r\nContent-Type: ${t}\r\n\r\n`),o=i.encode(`\r\n--${r}--\r\n`),s=new Uint8Array(a.byteLength+n.byteLength+o.byteLength);return s.set(a,0),s.set(n,a.byteLength),s.set(o,a.byteLength+n.byteLength),{contentType:`multipart/form-data; boundary=${r}`,body:s}}function y(e){return e.split(`/`).pop()||`data`}function b(e){let t=e.match(/^da:\/\/([^/]+)\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid DA source '${e}' — expected da://org/repo[/path]`);return{org:t[1],repo:t[2],path:(t[3]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}var x=5242880,S=class{kind=`da`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=b(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??x,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new c(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toSourcePath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/source/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}toListPath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/list/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r={};n&&(r[`if-none-match`]=n.etag);let i=await this.transport({method:`GET`,path:this.toSourcePath(t),headers:r});if(i.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(i.status===404)throw await this.cache.invalidateBody(t),new c(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new c(`EACCES`,`da access denied`,e);if(i.status>=400)throw new c(`EIO`,`da readFile failed: ${i.status}`,e);let a=i.headers.get(`content-length`),o=a?Number(a):void 0;if(o!==void 0&&o>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes`,e);let s=new Uint8Array(await i.arrayBuffer());if(s.byteLength>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=i.headers.get(`etag`)??``,u=l.startsWith(`W/`)?l.slice(2):l;return await this.cache.putBody(t,s,u),s}async writeFile(e,n){if(this.assertOpen(e),n.byteLength>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=this.toMountRelative(e),i=await this.cache.getBody(r),a=v(y(e),t(e),n),o={"content-type":a.contentType,"content-length":String(a.body.byteLength)};i?.etag?o[`if-match`]=i.etag.startsWith(`W/`)?i.etag.slice(2):i.etag:i||(o[`if-none-match`]=`*`);let s=()=>this.transport({method:`POST`,path:this.toSourcePath(r),headers:o,body:a.body}),l,u=1;try{l=await s()}catch{u=2,l=await s()}if(l.status===412){if(u===2){let t=await this.transport({method:`HEAD`,path:this.toSourcePath(r)});if(t.status>=400)throw new c(`EIO`,`da reconcile HEAD failed: ${t.status}`,e);let i=t.headers.get(`etag`)??``;await this.cache.putBody(r,n,i);let a=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a);return}await this.cache.invalidateBody(r);try{await this.readFile(e)}catch{}throw new c(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(l.status===401||l.status===403)throw new c(`EACCES`,`da write denied`,e);if(l.status>=400)throw new c(`EIO`,`da writeFile failed: ${l.status}`,e);let d=l.headers.get(`etag`)??``;await this.cache.putBody(r,n,d);let f=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(f)}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.transport({method:`GET`,path:this.toListPath(t)});if(r.status===404)throw new c(`ENOENT`,`no such directory`,e);if(r.status>=400)throw new c(`EIO`,`da list failed: ${r.status}`,e);let i=(await r.json()).map(e=>e.ext?{name:`${e.name}.${e.ext}`,kind:`file`,etag:e.etag,lastModified:e.lastModified}:{name:e.name,kind:`directory`,lastModified:e.lastModified});return await this.cache.putListing(t,i),i}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.size,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),i=r.pop()??``,a=r.join(`/`),o=await this.cache.getListing(a);if(o&&!this.cache.isStale(o.cachedAt)){let t=o.entries.find(e=>e.name===i);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??o.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??o.cachedAt};if(!t)throw new c(`ENOENT`,`no such file or directory`,e)}let s=await this.transport({method:`HEAD`,path:this.toSourcePath(t)});if(s.status===200){let e=Number(s.headers.get(`content-length`)??`0`),t=s.headers.get(`etag`)??``,n=s.headers.get(`last-modified`),r=n?Date.parse(n):0;if(o){let n=o.entries.map(n=>n.name===i&&n.kind===`file`?{...n,size:e,etag:t,lastModified:r}:n);await this.cache.putListing(a,n)}return{kind:`file`,size:e,mtime:r,etag:t}}if(s.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new c(`ENOENT`,`no such file or directory`,e)}throw new c(`EIO`,`da stat failed: ${s.status}`,e)}async mkdir(e){}async remove(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.transport({method:`DELETE`,path:this.toSourcePath(t)});if(n.status===404)throw new c(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new c(`EACCES`,`da delete denied`,e);if(n.status>=400)throw new c(`EIO`,`da delete failed: ${n.status}`,e);await this.cache.invalidateBody(t);let r=t.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(r)}async refresh(e){this.assertOpen(`/`);let t={added:[],removed:[],changed:[],unchanged:0,errors:[]},n=[``];for(;n.length>0;){let e=n.pop();try{await this.refreshDir(e,t,n)}catch(n){t.errors.push({path:e,message:n instanceof Error?n.message:String(n)})}}return e?.bodies&&await this.refreshBodies(t),t}async classifyFile(e,t,n){let r=await this.cache.getBody(e);r?t&&r.etag!==t?(await this.cache.invalidateBody(e),n.changed.push(e)):n.unchanged++:n.added.push(e)}async refreshDir(e,t,n){let r=await this.transport({method:`GET`,path:this.toListPath(e)});if(r.status>=400){t.errors.push({path:e,message:`list failed: ${r.status}`});return}let i=await r.json(),a=[];for(let r of i)if(r.ext){let n=e?`${e}/${r.name}.${r.ext}`:`${r.name}.${r.ext}`;a.push({name:`${r.name}.${r.ext}`,kind:`file`,etag:r.etag,lastModified:r.lastModified}),await this.classifyFile(n,r.etag,t)}else a.push({name:r.name,kind:`directory`}),n.push(e?`${e}/${r.name}`:r.name);await this.cache.putListing(e,a)}async refreshBodies(e){for(let t of e.changed)try{await this.readFile(t)}catch(n){e.errors.push({path:t,message:n instanceof Error?n.message:String(n)})}}describe(){return{displayName:`${this.parsed.org}/${this.parsed.repo}${this.parsed.path?`/${this.parsed.path}`:``}`,source:this.source,profile:this.profile}}async close(){this.closed||=!0}};function C(e){let t=e.match(/^s3:\/\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid S3 source '${e}' — expected s3://bucket[/prefix]`);return{bucket:t[1],prefix:(t[2]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}var w=26214400,T=class{kind=`s3`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=C(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??w,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new c(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toS3Key(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``);return[this.parsed.prefix,t].filter(e=>e.length>0).join(`/`)}toMountRelativeKey(e){return this.parsed.prefix?e.slice(this.parsed.prefix.length+1):e}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r={};n&&(r[`if-none-match`]=n.etag);let i=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:this.toS3Key(t),headers:r});if(i.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(i.status===404)throw await this.cache.invalidateBody(t),new c(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new c(`EACCES`,`s3 access denied`,e);if(i.status>=400)throw new c(`EIO`,`s3 readFile failed: ${i.status}`,e);let a=i.headers.get(`content-length`),o=a?Number(a):void 0;if(o!==void 0&&o>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes (${o} > ${this.maxBodyBytes})`,e);let s=new Uint8Array(await i.arrayBuffer());if(s.byteLength>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=i.headers.get(`etag`)??``;return await this.cache.putBody(t,s,l),s}async writeFile(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t.byteLength>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=await this.cache.getBody(n),i={"content-type":`application/octet-stream`,"content-length":String(t.byteLength)};r?i[`if-match`]=r.etag:i[`if-none-match`]=`*`;let a=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(n),headers:i,body:t}),o,s=1;try{o=await a()}catch{s=2,o=await a()}if(o.status===412){if(s===2){let r=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status>=400)throw new c(`EIO`,`s3 reconcile HEAD failed: ${r.status}`,e);let i=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,i);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new c(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(o.status===401||o.status===403)throw new c(`EACCES`,`s3 write denied`,e);if(o.status>=400)throw new c(`EIO`,`s3 writeFile failed: ${o.status}`,e);let l=o.headers.get(`etag`)??``;await this.cache.putBody(n,t,l);let u=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(u)}async listObjectsV2(){let e=[],t;do{let n={"list-type":`2`};this.parsed.prefix&&(n.prefix=`${this.parsed.prefix}/`),t&&(n[`continuation-token`]=t);let r=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:``,query:n});if(r.status>=400)throw new c(`EIO`,`s3 list failed: ${r.status}`,`/`);let i=await r.text(),a=this.parseListingXml(i);e.push(...a.contents),t=a.nextContinuationToken}while(t);return e}parseListingXml(e){let t=[];for(let n of e.matchAll(/<Contents>([\s\S]*?)<\/Contents>/g)){let e=n[1],r=e.match(/<Key>([^<]+)<\/Key>/)?.[1]??``,i=e.match(/<ETag>([^<]+)<\/ETag>/)?.[1]??``,a=e.match(/<Size>([^<]+)<\/Size>/)?.[1]??`0`,o=e.match(/<LastModified>([^<]+)<\/LastModified>/)?.[1]??``;t.push({key:r,etag:i,size:Number(a),lastModified:o?Date.parse(o):0})}return{contents:t,nextContinuationToken:e.match(/<IsTruncated>([^<]+)<\/IsTruncated>/)?.[1]===`true`?e.match(/<NextContinuationToken>([^<]+)<\/NextContinuationToken>/)?.[1]:void 0}}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.listObjectsV2(),i=this.groupByDir(r);for(let[e,t]of i)await this.cache.putListing(e,t);return i.get(t)??[]}groupByDir(e){let t=new Map,n=e=>(t.has(e)||t.set(e,[]),t.get(e));n(``);for(let t of e){let e=this.toMountRelativeKey(t.key).split(`/`),r=e.pop();n(e.join(`/`)).push({name:r,kind:`file`,size:t.size,etag:t.etag,lastModified:t.lastModified});let i=``;for(let t of e){let e=i;i=i?`${i}/${t}`:t;let r=n(e);r.find(e=>e.name===t&&e.kind===`directory`)||r.push({name:t,kind:`directory`}),n(i)}}return t}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.body.byteLength,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),i=r.pop()??``,a=r.join(`/`),o=await this.cache.getListing(a);if(o&&!this.cache.isStale(o.cachedAt)){let t=o.entries.find(e=>e.name===i);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??o.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??o.cachedAt};if(!t)throw new c(`ENOENT`,`no such file or directory`,e)}let s=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(t)});if(s.status===200){let e=Number(s.headers.get(`content-length`)??`0`),t=s.headers.get(`etag`)??``,n=s.headers.get(`last-modified`);return{kind:`file`,size:e,mtime:n?Date.parse(n):0,etag:t}}if(s.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new c(`ENOENT`,`no such file or directory`,e)}throw new c(`EIO`,`s3 stat failed: ${s.status}`,e)}async refresh(e){this.assertOpen(`/`);let t=await this.listObjectsV2(),n=new Set(t.map(e=>this.toMountRelativeKey(e.key))),r=new Map(t.map(e=>[this.toMountRelativeKey(e.key),e.etag])),i={added:[],removed:[],changed:[],unchanged:0,errors:[]};for(let e of n){let t=await this.cache.getBody(e),n=r.get(e);t?t.etag===n?i.unchanged++:(await this.cache.invalidateBody(e),i.changed.push(e)):i.added.push(e)}let a=this.groupByDir(t);for(let[e,t]of a)await this.cache.putListing(e,t);if(e?.bodies)for(let e of i.changed)try{await this.readFile(e)}catch(t){i.errors.push({path:e,message:t instanceof Error?t.message:String(t)})}return i}async mkdir(e){}async remove(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t?.recursive)throw new c(`EINVAL`,`recursive remove not yet supported on S3`,e);let r=await this.transport({method:`DELETE`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status===404)throw new c(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new c(`EACCES`,`s3 delete denied`,e);if(r.status>=400)throw new c(`EIO`,`s3 delete failed: ${r.status}`,e);await this.cache.invalidateBody(n);let i=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(i)}describe(){return{displayName:this.parsed.prefix?`${this.parsed.bucket}/${this.parsed.prefix}`:this.parsed.bucket,source:this.source,profile:this.profile}}async close(){this.closed||=!0}},E=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function D(){let{getAccounts:t}=await e(async()=>{let{getAccounts:e}=await import(`./account-store-mFC76tgv.js`).then(e=>e.r);return{getAccounts:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26])),n=t().find(e=>e.providerId===`adobe`);if(!n?.accessToken)throw new E(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>n.accessToken}}var O=`slicc-mount-cache`,k=`listings`,A=`bodies`,j=class{mountId;ttlMs;dbName;dbPromise=null;constructor(e){this.mountId=e.mountId,this.ttlMs=e.ttlMs,this.dbName=e.dbName??O}isStale(e,t){return Date.now()-e>=(t??this.ttlMs)}async openDb(){return this.dbPromise||=new Promise((e,t)=>{let n=indexedDB.open(this.dbName,1);n.onupgradeneeded=()=>{let e=n.result;e.objectStoreNames.contains(k)||e.createObjectStore(k),e.objectStoreNames.contains(A)||e.createObjectStore(A)},n.onsuccess=()=>{let t=n.result;t.onversionchange=()=>{t.close(),this.dbPromise=null},t.onclose=()=>{this.dbPromise=null},e(t)},n.onerror=()=>t(n.error)}),this.dbPromise}key(e){return`${this.mountId}::${e}`}async getListing(e){let t=await this.openDb();return new Promise((n,r)=>{let i=t.transaction(k,`readonly`).objectStore(k).get(this.key(e));i.onsuccess=()=>n(i.result??null),i.onerror=()=>r(i.error)})}async putListing(e,t){let n=await this.openDb();return new Promise((r,i)=>{let a=n.transaction(k,`readwrite`),o={entries:t,cachedAt:Date.now()};a.objectStore(k).put(o,this.key(e)),a.oncomplete=()=>r(),a.onerror=()=>i(a.error)})}async invalidateListing(e){let t=await this.openDb();return new Promise((n,r)=>{let i=t.transaction(k,`readwrite`);i.objectStore(k).delete(this.key(e)),i.oncomplete=()=>n(),i.onerror=()=>r(i.error)})}async getBody(e){let t=await this.openDb();return new Promise((n,r)=>{let i=t.transaction(A,`readonly`).objectStore(A).get(this.key(e));i.onsuccess=()=>n(i.result??null),i.onerror=()=>r(i.error)})}async putBody(e,t,n){let r=await this.openDb(),i={body:t,etag:n,size:t.byteLength,cachedAt:Date.now()};try{await this.txPut(r,A,this.key(e),i)}catch(t){if(t instanceof DOMException&&t.name===`QuotaExceededError`){await this.evictLru(.25);try{await this.txPut(r,A,this.key(e),i)}catch{}return}throw t}}async invalidateBody(e){let t=await this.openDb();return new Promise((n,r)=>{let i=t.transaction(A,`readwrite`);i.objectStore(A).delete(this.key(e)),i.oncomplete=()=>n(),i.onerror=()=>r(i.error)})}async clearMount(){let e=await this.openDb(),t=`${this.mountId}::`,n=n=>new Promise((r,i)=>{let a=e.transaction(n,`readwrite`),o=a.objectStore(n),s=o.getAllKeys();s.onsuccess=()=>{for(let e of s.result)typeof e==`string`&&e.startsWith(t)&&o.delete(e)},a.oncomplete=()=>r(),a.onerror=()=>i(a.error)});await Promise.all([n(k),n(A)])}txPut(e,t,n,r){return new Promise((i,a)=>{let o=e.transaction(t,`readwrite`);o.objectStore(t).put(r,n),o.oncomplete=()=>i(),o.onerror=()=>a(o.error)})}async evictLru(e){let t=await this.openDb(),n=`${this.mountId}::`,r=await new Promise((e,r)=>{let i=t.transaction(A,`readonly`).objectStore(A),a=[],o=i.openCursor();o.onsuccess=()=>{let t=o.result;if(!t){e(a);return}if(typeof t.key==`string`&&t.key.startsWith(n)){let e=t.value;a.push({key:t.key,cachedAt:e.cachedAt})}t.continue()},o.onerror=()=>r(o.error)});r.sort((e,t)=>e.cachedAt-t.cachedAt);let i=Math.max(1,Math.ceil(r.length*e)),a=r.slice(0,i);await new Promise((e,n)=>{let r=t.transaction(A,`readwrite`),i=r.objectStore(A);for(let{key:e}of a)i.delete(e);r.oncomplete=()=>e(),r.onerror=()=>n(r.error)})}},M=r,N=n,P=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),F=new Set([101,103,204,205,304]);function I(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new c(`EACCES`,e.error):e.errorCode===`invalid_request`?new c(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||P.has(String(e.errorCode))?new c(`EIO`,e.error):new c(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=M(e.bodyBase64)}catch(e){throw new c(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let n=F.has(e.status)?null:t;return new Response(n,{status:e.status,headers:new Headers(e.headers)})}async function L(e,t){let n;try{n=await fetch(a(e),{method:`POST`,headers:s({"content-type":`application/json`}),body:JSON.stringify(t)})}catch(e){throw new c(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (SLICC backend at localhost may not be running)`)}try{return await n.json()}catch(e){throw new c(`EIO`,`mount transport: response is not a JSON envelope (status ${n.status}): ${e instanceof Error?e.message:String(e)}`)}}async function R(e,t){try{return await chrome.runtime.sendMessage({type:e,envelope:t})}catch(e){throw new c(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (extension service worker not responding)`)}}async function z(e,t,n){return i()?R(e,n):o()?l(e,n):L(t,n)}function B(e){return async t=>I(await z(`mount.s3-sign-and-forward`,`/api/s3-sign-and-forward`,{profile:e,method:t.method,bucket:t.bucket,key:t.key,query:t.query,headers:t.headers,bodyBase64:t.body?N(t.body):void 0}))}function V(e){let t=e?.getImsToken??(async()=>(await D()).getBearerToken());return async e=>{let n;try{n=await t()}catch(e){throw new c(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}return I(await z(`mount.da-sign-and-forward`,`/api/da-sign-and-forward`,{imsToken:n,method:e.method,path:e.path,origin:e.origin,query:e.query,headers:e.headers,bodyBase64:e.body?N(e.body):void 0}))}}export{_ as AemMountBackend,S as DaMountBackend,j as RemoteMountCache,T as S3MountBackend,V as makeSignedFetchDa,B as makeSignedFetchS3};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{r as t,t as n}from"./base64-DzRgusa4.js";import"./src-CcFD5QfS.js";import{t as r}from"./runtime-env-DadgceZk.js";import{i,n as a,t as o}from"./api-endpoint-C00IT5T9.js";import{t as s}from"./mime-types-D7IV6i7k.js";import"./runtime-env-Dtj99aNH.js";import{t as c}from"./port-bridge-client-D5ndzGCE.js";import{t as l}from"./types-idfTVsM8.js";import{t as u}from"./remote-cache-JAv9sQH_.js";const d=`https://api.aem.live`;function f(e){let t=e.match(/^aem:\/\/([^/]+)\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid AEM source '${e}' — expected aem://org/site[/path]`);return{org:t[1],site:t[2],path:(t[3]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}function p(e){if(!e)return``;let t=Date.parse(e);return Number.isNaN(t)?``:String(t)}function m(e){let t=Date.parse(e??``);return Number.isNaN(t)?0:t}function h(e){return e.map(e=>e[`content-type`]===`application/folder`||e.name.endsWith(`/`)?{name:e.name.replace(/\/+$/,``),kind:`directory`}:{name:e.name,kind:`file`,size:e.size,etag:p(e[`last-modified`]),lastModified:m(e[`last-modified`])})}var g=class{kind=`aem`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=f(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??5242880,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new l(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toSourcePath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`),r=`/${this.parsed.org}/sites/${this.parsed.site}/source`;return n?`${r}/${n}`:r}toListPath(e){return`${this.toSourcePath(e)}/`}request(e,t,n){return this.transport({method:e,path:t,origin:d,headers:n?.headers,body:n?.body})}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r=await this.request(`GET`,this.toSourcePath(t));if(r.status===404)throw await this.cache.invalidateBody(t),new l(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new l(`EACCES`,`aem access denied`,e);if(r.status>=400)throw new l(`EIO`,`aem readFile failed: ${r.status}`,e);let i=new Uint8Array(await r.arrayBuffer());if(i.byteLength>this.maxBodyBytes)throw new l(`EFBIG`,`body exceeds maxBodyBytes`,e);return await this.cache.putBody(t,i,p(r.headers.get(`last-modified`))),i}async assertUnchanged(e,t,n){if(!n)return;let r=await this.request(`HEAD`,this.toSourcePath(t));if(r.status===404)return;if(r.status>=400)throw new l(`EIO`,`aem precondition HEAD failed: ${r.status}`,e);let i=p(r.headers.get(`last-modified`));if(i&&i!==n)throw await this.cache.invalidateBody(t),new l(`EBUSY`,`remote modified since last read — re-read and retry`,e)}async writeFile(e,t){if(this.assertOpen(e),t.byteLength>this.maxBodyBytes)throw new l(`EFBIG`,`body exceeds maxBodyBytes`,e);let n=this.toMountRelative(e),r=await this.cache.getBody(n);await this.assertUnchanged(e,n,r?.etag??``);let i=await this.request(`PUT`,this.toSourcePath(n),{body:t});if(i.status===401||i.status===403)throw new l(`EACCES`,`aem write denied`,e);if(i.status>=400)throw new l(`EIO`,`aem writeFile failed: ${i.status}`,e);await this.cache.invalidateBody(n);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a)}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.request(`GET`,this.toListPath(t));if(r.status===404)throw new l(`ENOENT`,`no such directory`,e);if(r.status===401||r.status===403)throw new l(`EACCES`,`aem access denied`,e);if(r.status>=400)throw new l(`EIO`,`aem list failed: ${r.status}`,e);let i=h(await r.json());return await this.cache.putListing(t,i),i}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e);if(t===``)return{kind:`directory`,size:0,mtime:0};let n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.size,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),i=r.pop()??``,a=r.join(`/`),o=await this.cache.getListing(a),s=(o&&!this.cache.isStale(o.cachedAt)?o.entries:await this.readDirQuietly(a))?.find(e=>e.name===i);if(!s)throw new l(`ENOENT`,`no such file or directory`,e);return s.kind===`directory`?{kind:`directory`,size:0,mtime:s.lastModified??0}:{kind:`file`,size:s.size??0,mtime:s.lastModified??0,etag:s.etag??``}}async readDirQuietly(e){try{return await this.readDir(e)}catch{return null}}async mkdir(e){}async remove(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.request(`DELETE`,this.toSourcePath(t));if(n.status===404)throw new l(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new l(`EACCES`,`aem delete denied`,e);if(n.status>=400)throw new l(`EIO`,`aem delete failed: ${n.status}`,e);await this.cache.invalidateBody(t);let r=t.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(r)}async refresh(e){this.assertOpen(`/`);let t={added:[],removed:[],changed:[],unchanged:0,errors:[]},n=[``];for(;n.length>0;){let e=n.pop();try{await this.refreshDir(e,t,n)}catch(n){t.errors.push({path:e,message:n instanceof Error?n.message:String(n)})}}return e?.bodies&&await this.refreshBodies(t),t}async classifyFile(e,t,n){let r=await this.cache.getBody(e);r?t&&r.etag!==t?(await this.cache.invalidateBody(e),n.changed.push(e)):n.unchanged++:n.added.push(e)}async refreshDir(e,t,n){let r=await this.request(`GET`,this.toListPath(e));if(r.status===404){await this.cache.putListing(e,[]);return}if(r.status>=400){t.errors.push({path:e,message:`list failed: ${r.status}`});return}let i=h(await r.json());for(let r of i){let i=e?`${e}/${r.name}`:r.name;r.kind===`directory`?n.push(i):await this.classifyFile(i,r.etag??``,t)}await this.cache.putListing(e,i)}async refreshBodies(e){for(let t of e.changed)try{await this.readFile(t)}catch(n){e.errors.push({path:t,message:n instanceof Error?n.message:String(n)})}}describe(){return{displayName:`${this.parsed.org}/${this.parsed.site}${this.parsed.path?`/${this.parsed.path}`:``}`,source:this.source,profile:this.profile}}async close(){this.closed||=!0}};function _(e,t,n){let r=`----DaMount${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`,i=new TextEncoder,a=i.encode(`--${r}\r\nContent-Disposition: form-data; name="data"; filename="${e}"\r\nContent-Type: ${t}\r\n\r\n`),o=i.encode(`\r\n--${r}--\r\n`),s=new Uint8Array(a.byteLength+n.byteLength+o.byteLength);return s.set(a,0),s.set(n,a.byteLength),s.set(o,a.byteLength+n.byteLength),{contentType:`multipart/form-data; boundary=${r}`,body:s}}function v(e){return e.split(`/`).pop()||`data`}function y(e){let t=e.match(/^da:\/\/([^/]+)\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid DA source '${e}' — expected da://org/repo[/path]`);return{org:t[1],repo:t[2],path:(t[3]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}var b=class{kind=`da`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=y(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??5242880,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new l(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toSourcePath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/source/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}toListPath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/list/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r={};n&&(r[`if-none-match`]=n.etag);let i=await this.transport({method:`GET`,path:this.toSourcePath(t),headers:r});if(i.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(i.status===404)throw await this.cache.invalidateBody(t),new l(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new l(`EACCES`,`da access denied`,e);if(i.status>=400)throw new l(`EIO`,`da readFile failed: ${i.status}`,e);let a=i.headers.get(`content-length`),o=a?Number(a):void 0;if(o!==void 0&&o>this.maxBodyBytes)throw new l(`EFBIG`,`body exceeds maxBodyBytes`,e);let s=new Uint8Array(await i.arrayBuffer());if(s.byteLength>this.maxBodyBytes)throw new l(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=i.headers.get(`etag`)??``,u=c.startsWith(`W/`)?c.slice(2):c;return await this.cache.putBody(t,s,u),s}async writeFile(e,t){if(this.assertOpen(e),t.byteLength>this.maxBodyBytes)throw new l(`EFBIG`,`body exceeds maxBodyBytes`,e);let n=this.toMountRelative(e),r=await this.cache.getBody(n),i=_(v(e),s(e),t),a={"content-type":i.contentType,"content-length":String(i.body.byteLength)};r?.etag?a[`if-match`]=r.etag.startsWith(`W/`)?r.etag.slice(2):r.etag:r||(a[`if-none-match`]=`*`);let o=()=>this.transport({method:`POST`,path:this.toSourcePath(n),headers:a,body:i.body}),c,u=1;try{c=await o()}catch{u=2,c=await o()}if(c.status===412){if(u===2){let r=await this.transport({method:`HEAD`,path:this.toSourcePath(n)});if(r.status>=400)throw new l(`EIO`,`da reconcile HEAD failed: ${r.status}`,e);let i=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,i);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new l(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(c.status===401||c.status===403)throw new l(`EACCES`,`da write denied`,e);if(c.status>=400)throw new l(`EIO`,`da writeFile failed: ${c.status}`,e);let d=c.headers.get(`etag`)??``;await this.cache.putBody(n,t,d);let f=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(f)}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.transport({method:`GET`,path:this.toListPath(t)});if(r.status===404)throw new l(`ENOENT`,`no such directory`,e);if(r.status>=400)throw new l(`EIO`,`da list failed: ${r.status}`,e);let i=(await r.json()).map(e=>e.ext?{name:`${e.name}.${e.ext}`,kind:`file`,etag:e.etag,lastModified:e.lastModified}:{name:e.name,kind:`directory`,lastModified:e.lastModified});return await this.cache.putListing(t,i),i}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.size,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),i=r.pop()??``,a=r.join(`/`),o=await this.cache.getListing(a);if(o&&!this.cache.isStale(o.cachedAt)){let t=o.entries.find(e=>e.name===i);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??o.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??o.cachedAt};if(!t)throw new l(`ENOENT`,`no such file or directory`,e)}let s=await this.transport({method:`HEAD`,path:this.toSourcePath(t)});if(s.status===200){let e=Number(s.headers.get(`content-length`)??`0`),t=s.headers.get(`etag`)??``,n=s.headers.get(`last-modified`),r=n?Date.parse(n):0;if(o){let n=o.entries.map(n=>n.name===i&&n.kind===`file`?{...n,size:e,etag:t,lastModified:r}:n);await this.cache.putListing(a,n)}return{kind:`file`,size:e,mtime:r,etag:t}}if(s.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new l(`ENOENT`,`no such file or directory`,e)}throw new l(`EIO`,`da stat failed: ${s.status}`,e)}async mkdir(e){}async remove(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.transport({method:`DELETE`,path:this.toSourcePath(t)});if(n.status===404)throw new l(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new l(`EACCES`,`da delete denied`,e);if(n.status>=400)throw new l(`EIO`,`da delete failed: ${n.status}`,e);await this.cache.invalidateBody(t);let r=t.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(r)}async refresh(e){this.assertOpen(`/`);let t={added:[],removed:[],changed:[],unchanged:0,errors:[]},n=[``];for(;n.length>0;){let e=n.pop();try{await this.refreshDir(e,t,n)}catch(n){t.errors.push({path:e,message:n instanceof Error?n.message:String(n)})}}return e?.bodies&&await this.refreshBodies(t),t}async classifyFile(e,t,n){let r=await this.cache.getBody(e);r?t&&r.etag!==t?(await this.cache.invalidateBody(e),n.changed.push(e)):n.unchanged++:n.added.push(e)}async refreshDir(e,t,n){let r=await this.transport({method:`GET`,path:this.toListPath(e)});if(r.status>=400){t.errors.push({path:e,message:`list failed: ${r.status}`});return}let i=await r.json(),a=[];for(let r of i)if(r.ext){let n=e?`${e}/${r.name}.${r.ext}`:`${r.name}.${r.ext}`;a.push({name:`${r.name}.${r.ext}`,kind:`file`,etag:r.etag,lastModified:r.lastModified}),await this.classifyFile(n,r.etag,t)}else a.push({name:r.name,kind:`directory`}),n.push(e?`${e}/${r.name}`:r.name);await this.cache.putListing(e,a)}async refreshBodies(e){for(let t of e.changed)try{await this.readFile(t)}catch(n){e.errors.push({path:t,message:n instanceof Error?n.message:String(n)})}}describe(){return{displayName:`${this.parsed.org}/${this.parsed.repo}${this.parsed.path?`/${this.parsed.path}`:``}`,source:this.source,profile:this.profile}}async close(){this.closed||=!0}};function x(e){let t=e.match(/^s3:\/\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid S3 source '${e}' — expected s3://bucket[/prefix]`);return{bucket:t[1],prefix:(t[2]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}var S=class{kind=`s3`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=x(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??26214400,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new l(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toS3Key(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``);return[this.parsed.prefix,t].filter(e=>e.length>0).join(`/`)}toMountRelativeKey(e){return this.parsed.prefix?e.slice(this.parsed.prefix.length+1):e}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r={};n&&(r[`if-none-match`]=n.etag);let i=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:this.toS3Key(t),headers:r});if(i.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(i.status===404)throw await this.cache.invalidateBody(t),new l(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new l(`EACCES`,`s3 access denied`,e);if(i.status>=400)throw new l(`EIO`,`s3 readFile failed: ${i.status}`,e);let a=i.headers.get(`content-length`),o=a?Number(a):void 0;if(o!==void 0&&o>this.maxBodyBytes)throw new l(`EFBIG`,`body exceeds maxBodyBytes (${o} > ${this.maxBodyBytes})`,e);let s=new Uint8Array(await i.arrayBuffer());if(s.byteLength>this.maxBodyBytes)throw new l(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=i.headers.get(`etag`)??``;return await this.cache.putBody(t,s,c),s}async writeFile(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t.byteLength>this.maxBodyBytes)throw new l(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=await this.cache.getBody(n),i={"content-type":`application/octet-stream`,"content-length":String(t.byteLength)};r?i[`if-match`]=r.etag:i[`if-none-match`]=`*`;let a=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(n),headers:i,body:t}),o,s=1;try{o=await a()}catch{s=2,o=await a()}if(o.status===412){if(s===2){let r=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status>=400)throw new l(`EIO`,`s3 reconcile HEAD failed: ${r.status}`,e);let i=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,i);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new l(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(o.status===401||o.status===403)throw new l(`EACCES`,`s3 write denied`,e);if(o.status>=400)throw new l(`EIO`,`s3 writeFile failed: ${o.status}`,e);let c=o.headers.get(`etag`)??``;await this.cache.putBody(n,t,c);let u=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(u)}async listObjectsV2(){let e=[],t;do{let n={"list-type":`2`};this.parsed.prefix&&(n.prefix=`${this.parsed.prefix}/`),t&&(n[`continuation-token`]=t);let r=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:``,query:n});if(r.status>=400)throw new l(`EIO`,`s3 list failed: ${r.status}`,`/`);let i=await r.text(),a=this.parseListingXml(i);e.push(...a.contents),t=a.nextContinuationToken}while(t);return e}parseListingXml(e){let t=[];for(let n of e.matchAll(/<Contents>([\s\S]*?)<\/Contents>/g)){let e=n[1],r=e.match(/<Key>([^<]+)<\/Key>/)?.[1]??``,i=e.match(/<ETag>([^<]+)<\/ETag>/)?.[1]??``,a=e.match(/<Size>([^<]+)<\/Size>/)?.[1]??`0`,o=e.match(/<LastModified>([^<]+)<\/LastModified>/)?.[1]??``;t.push({key:r,etag:i,size:Number(a),lastModified:o?Date.parse(o):0})}return{contents:t,nextContinuationToken:e.match(/<IsTruncated>([^<]+)<\/IsTruncated>/)?.[1]===`true`?e.match(/<NextContinuationToken>([^<]+)<\/NextContinuationToken>/)?.[1]:void 0}}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.listObjectsV2(),i=this.groupByDir(r);for(let[e,t]of i)await this.cache.putListing(e,t);return i.get(t)??[]}groupByDir(e){let t=new Map,n=e=>(t.has(e)||t.set(e,[]),t.get(e));n(``);for(let t of e){let e=this.toMountRelativeKey(t.key).split(`/`),r=e.pop();n(e.join(`/`)).push({name:r,kind:`file`,size:t.size,etag:t.etag,lastModified:t.lastModified});let i=``;for(let t of e){let e=i;i=i?`${i}/${t}`:t;let r=n(e);r.find(e=>e.name===t&&e.kind===`directory`)||r.push({name:t,kind:`directory`}),n(i)}}return t}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.body.byteLength,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),i=r.pop()??``,a=r.join(`/`),o=await this.cache.getListing(a);if(o&&!this.cache.isStale(o.cachedAt)){let t=o.entries.find(e=>e.name===i);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??o.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??o.cachedAt};if(!t)throw new l(`ENOENT`,`no such file or directory`,e)}let s=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(t)});if(s.status===200){let e=Number(s.headers.get(`content-length`)??`0`),t=s.headers.get(`etag`)??``,n=s.headers.get(`last-modified`);return{kind:`file`,size:e,mtime:n?Date.parse(n):0,etag:t}}if(s.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new l(`ENOENT`,`no such file or directory`,e)}throw new l(`EIO`,`s3 stat failed: ${s.status}`,e)}async refresh(e){this.assertOpen(`/`);let t=await this.listObjectsV2(),n=new Set(t.map(e=>this.toMountRelativeKey(e.key))),r=new Map(t.map(e=>[this.toMountRelativeKey(e.key),e.etag])),i={added:[],removed:[],changed:[],unchanged:0,errors:[]};for(let e of n){let t=await this.cache.getBody(e),n=r.get(e);t?t.etag===n?i.unchanged++:(await this.cache.invalidateBody(e),i.changed.push(e)):i.added.push(e)}let a=this.groupByDir(t);for(let[e,t]of a)await this.cache.putListing(e,t);if(e?.bodies)for(let e of i.changed)try{await this.readFile(e)}catch(t){i.errors.push({path:e,message:t instanceof Error?t.message:String(t)})}return i}async mkdir(e){}async remove(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t?.recursive)throw new l(`EINVAL`,`recursive remove not yet supported on S3`,e);let r=await this.transport({method:`DELETE`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status===404)throw new l(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new l(`EACCES`,`s3 delete denied`,e);if(r.status>=400)throw new l(`EIO`,`s3 delete failed: ${r.status}`,e);await this.cache.invalidateBody(n);let i=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(i)}describe(){return{displayName:this.parsed.prefix?`${this.parsed.bucket}/${this.parsed.prefix}`:this.parsed.bucket,source:this.source,profile:this.profile}}async close(){this.closed||=!0}},C=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function w(){let{getAccounts:e}=await import(`./account-store-B5g-mrn8.js`).then(e=>e.t),t=e().find(e=>e.providerId===`adobe`);if(!t?.accessToken)throw new C(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>t.accessToken}}const T=c({portName:`mount.sign-and-forward`,panelRpcOp:`mount-sign-and-forward`,timeoutMs:12e4,onUnavailable:`reject`,makeError:e=>new l(`EIO`,`mount transport failed: ${e}`),logNamespace:`mount-bridge`,toPortMessage:({type:e,envelope:t})=>({type:e,envelope:t}),toPanelRpcPayload:({type:e,envelope:t})=>({type:e,envelope:t})});function E(e,t){return T({type:e,envelope:t})}const D=n,O=t,k=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),A=new Set([101,103,204,205,304]);function j(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new l(`EACCES`,e.error):e.errorCode===`invalid_request`?new l(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||k.has(String(e.errorCode))?new l(`EIO`,e.error):new l(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=D(e.bodyBase64)}catch(e){throw new l(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let n=A.has(e.status)?null:t;return new Response(n,{status:e.status,headers:new Headers(e.headers)})}async function M(e,t){let n;try{n=await fetch(i(e),{method:`POST`,headers:o({"content-type":`application/json`}),body:JSON.stringify(t)})}catch(e){throw new l(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (SLICC backend at localhost may not be running)`)}try{return await n.json()}catch(e){throw new l(`EIO`,`mount transport: response is not a JSON envelope (status ${n.status}): ${e instanceof Error?e.message:String(e)}`)}}async function N(e,t){try{return await chrome.runtime.sendMessage({type:e,envelope:t})}catch(e){throw new l(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (extension service worker not responding)`)}}async function P(e,t,n){return r()?N(e,n):a()?E(e,n):M(t,n)}function F(e){return async t=>j(await P(`mount.s3-sign-and-forward`,`/api/s3-sign-and-forward`,{profile:e,method:t.method,bucket:t.bucket,key:t.key,query:t.query,headers:t.headers,bodyBase64:t.body?O(t.body):void 0}))}function I(e){let t=e?.getImsToken??(async()=>(await w()).getBearerToken());return async e=>{let n;try{n=await t()}catch(e){throw new l(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}return j(await P(`mount.da-sign-and-forward`,`/api/da-sign-and-forward`,{imsToken:n,method:e.method,path:e.path,origin:e.origin,query:e.query,headers:e.headers,bodyBase64:e.body?O(e.body):void 0}))}}var L=e({AEM_SOURCE_BUS_ORIGIN:()=>d,AemMountBackend:()=>g,DaMountBackend:()=>b,RemoteMountCache:()=>u,S3MountBackend:()=>S,makeSignedFetchDa:()=>I,makeSignedFetchS3:()=>F});export{b as a,S as i,I as n,d as o,F as r,g as s,L as t};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{i as t,n}from"./mount-index-BCzDM4LQ.js";import{a as r,i,n as a,r as o,s}from"./mount-CY0WMJLG.js";import{n as c}from"./mount-table-store-DrF_Ifaz.js";import{t as l}from"./remote-cache-JAv9sQH_.js";var u=e({formatMountRecoveryPrompt:()=>_,mdInlineCode:()=>g,recoverMounts:()=>m,shellQuote:()=>h});function d(e){return e instanceof Error?e.message:String(e)}async function f(e,r,i,a){let o=await c(r.idbHandleKey),s=typeof o?.name==`string`?o.name:``,l={kind:`local`,path:e,dirName:s};if(!o||!(`queryPermission`in o))return{entry:l,ok:!1};let u;try{u=await o.queryPermission({mode:`readwrite`})}catch(t){return a?.warn?.(`queryPermission threw on persisted handle`,{path:e,error:d(t)}),{entry:l,ok:!1}}if(u!==`granted`)return{entry:l,ok:!1};try{let c=t.fromHandle(o,{mountId:r.mountId});return await i.mount(e,c,{limits:n}),a?.info?.(`Restored mount from previous session`,{path:e,name:s}),{entry:l,ok:!0}}catch(t){return a?.warn?.(`Failed to re-mount persisted handle`,{path:e,error:d(t)}),{entry:l,ok:!1}}}async function p(e,t,n,c){let{kind:u,source:f,profile:p,mountId:m}=t,h=u===`s3`?`S3`:u===`aem`?`AEM`:`DA`;try{let t={source:f,profile:p,cache:new l({mountId:m,ttlMs:3e4}),mountId:m},d=u===`s3`?new i({...t,signedFetch:o(p)}):u===`aem`?new s({...t,signedFetch:a()}):new r({...t,signedFetch:a()});return await n.mount(e,d),c?.info?.(`Restored ${h} mount from previous session`,{path:e,source:f}),{entry:{kind:u,path:e,source:f,profile:p,reason:``},ok:!0}}catch(t){let n=d(t);return c?.warn?.(`Failed to restore ${h} mount`,{path:e,error:n}),{entry:{kind:u,path:e,source:f,profile:p,reason:n},ok:!1}}}async function m(e,t,n){let r=[],i=[];for(let{targetPath:a,descriptor:o}of e){if(o.kind===`hostfs`)continue;let e=o.kind===`local`?await f(a,o,t,n):await p(a,o,t,n);(e.ok?r:i).push(e.entry)}return{restored:r,needsRecovery:i}}function h(e){return`'${e.replace(/'/g,`'\\''`)}'`}function g(e){let t=e.replace(/\r\n|[\r\n]/g,` `),n=t.match(/`+/g),r=n?Math.max(...n.map(e=>e.length))+1:1,i="`".repeat(r);return`${i}${t.startsWith("`")||t.endsWith("`")?` ${t} `:t}${i}`}function _(e){if(!Array.isArray(e)||e.length===0)return null;let t=e.length===1?`mount point`:`mount points`,n=e.length===1?`it`:`them`,r=e.filter(e=>e.kind===`local`),i=e.filter(e=>e.kind===`s3`||e.kind===`da`||e.kind===`aem`),a=[`[Session Reload] Mount recovery required for ${e.length} ${t}.`,``];if(r.length>0){let e=r.map(({path:e,dirName:t})=>{let n=t?` (previously mounted from ${g(t)})`:``;return`- ${g(e)}${n}`}),i=r.map(({path:e})=>` mount ${h(e)}`);a.push(`The page was reloaded and the following local ${t} lost filesystem permission. The browser cannot restore access without a fresh user gesture, so ${n} cannot be used until the user re-authorizes:`,``,...e,``,`Please tell the user what happened and ask whether they want to re-mount. If yes, run the corresponding command(s) so the folder picker opens and they can re-select the same directory:`,``,...i,``)}if(i.length>0){let e=i.map(({path:e,source:t,profile:n,reason:r})=>{let i=n==="default"?``:` --profile ${h(n)}`,a=`mount --source ${h(t)}${i} ${h(e)}`;return`- ${g(e)} (${g(t)}, profile ${g(n)}) — ${r}\n Retry: ${g(a)}`});a.push(`The following remote ${t} could not be auto-restored:`,``,...e,``)}return a.push("If the user no longer needs a mount, run `mount unmount <path>` (with the path shell-quoted the same way) to clear the stale entry instead."),a.join(`
|
|
2
|
-
`)}export{u as n,h as r,_ as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./store-DgTQh3uY.js";export{e as readMcpAuthEntries};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function e(){return{version:`6.110.13`,releasedAt:`2026-08-31T17:43:28Z`,buildId:`6.110.13-mthj1lxx`}}let t=null;function n(e){t=e}function r(){return t}export{e as n,n as r,r as t};
|