sliccy 4.0.0 → 4.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/dist/ui/assets/{adobe-Cemo5C0u.js → adobe-B4ZijlN3.js} +1 -1
  2. package/dist/ui/assets/{adobe-BbrAWL2k.js → adobe-CXtz_LR-.js} +2 -2
  3. package/dist/ui/assets/{agent-message-to-chat-CcbdvCBX.js → agent-message-to-chat-2oatz-4r.js} +1 -1
  4. package/dist/ui/assets/{anthropic-F94JdHkD.js → anthropic-DdhoKMtR.js} +1 -1
  5. package/dist/ui/assets/{apps-DW9Ugrtq.js → apps-BkzP1PLW.js} +1 -1
  6. package/dist/ui/assets/{azure-openai-DeK0lFgF.js → azure-openai-C-3E46Ld.js} +1 -1
  7. package/dist/ui/assets/{azure-openai-BIN3lyjx.js → azure-openai-DTW6COMC.js} +1 -1
  8. package/dist/ui/assets/{azure-openai-responses-9zsK4075.js → azure-openai-responses-CdvI3ZMk.js} +1 -1
  9. package/dist/ui/assets/{bsh-watchdog-CFGe8ITX.js → bsh-watchdog-BFmmHSkm.js} +1 -1
  10. package/dist/ui/assets/{cdp-n4Jl6aC4.js → cdp-Bx-nkPzL.js} +3 -3
  11. package/dist/ui/assets/{connect-surface-C8QsyQkF.js → connect-surface-Dwz7gSuy.js} +1 -1
  12. package/dist/ui/assets/dip-_QvZN8wj.js +1 -0
  13. package/dist/ui/assets/{dist-tjBW4Ynj.js → dist-DBjE4kB5.js} +1 -1
  14. package/dist/ui/assets/{dist-Dgyr_bjn.js → dist-DU9Hdb6p.js} +1 -1
  15. package/dist/ui/assets/{es-CIP8vLYQ.js → es-CxV76drH.js} +1 -1
  16. package/dist/ui/assets/esp8266-91jA_HHD.js +1 -0
  17. package/dist/ui/assets/{esptool-operations-3OtqiSvP.js → esptool-operations-CXqSawtf.js} +2 -2
  18. package/dist/ui/assets/{fs-sLaOZiPe.js → fs-C3bDUkXJ.js} +2 -2
  19. package/dist/ui/assets/{fs-D9uHDiI8.js → fs-Dg90t6PY.js} +1 -1
  20. package/dist/ui/assets/{github-um5_lXvs.js → github-CPCc-EUr.js} +1 -1
  21. package/dist/ui/assets/{github-iKf-uv0l.js → github-DxSzH6PI.js} +2 -2
  22. package/dist/ui/assets/{github-copilot-Bn6df3EN.js → github-copilot-BSdH-X0I.js} +1 -1
  23. package/dist/ui/assets/{github-copilot-BWwpRuxR.js → github-copilot-C0PA1-T1.js} +2 -2
  24. package/dist/ui/assets/{google-BFjmrVhw.js → google-Cp_gRCg5.js} +1 -1
  25. package/dist/ui/assets/{google-shared-DA7BsMNj.js → google-shared-BoLRjUxb.js} +1 -1
  26. package/dist/ui/assets/{google-vertex-fXPbdwC1.js → google-vertex-IdSaJxmx.js} +1 -1
  27. package/dist/ui/assets/{hosted-config-apply-CTLeJas_.js → hosted-config-apply-CizDb9Vw.js} +1 -1
  28. package/dist/ui/assets/{kernel-worker-OJsR9uqi.js → kernel-worker-DpRMAeb1.js} +673 -673
  29. package/dist/ui/assets/{legacy-styles-CJFCJMPl.js → legacy-styles-Bt2Mk3g2.js} +1 -1
  30. package/dist/ui/assets/{lick-ws-bridge-BvcLlt-k.js → lick-ws-bridge-CIdCZl2q.js} +1 -1
  31. package/dist/ui/assets/{local-llm-4QlmT-tX.js → local-llm-DgWHei2e.js} +1 -1
  32. package/dist/ui/assets/{magick-wasm-CzacIjJk.js → magick-wasm-BCSDiya9.js} +1 -1
  33. package/dist/ui/assets/{main-CAjMV3Ro.js → main-D7K1MTaQ.js} +4 -4
  34. package/dist/ui/assets/{main-cherry-Cs47oYGZ.js → main-cherry-CXrrVAC-.js} +1 -1
  35. package/dist/ui/assets/{mistral-2x1R-8qy.js → mistral-C8Uiexjg.js} +1 -1
  36. package/dist/ui/assets/mount-BYWcec4u.js +2 -0
  37. package/dist/ui/assets/mount-CYuBE82h.js +1 -0
  38. package/dist/ui/assets/{mount-id-BuG8r64x.js → mount-id-Cy4nG68v.js} +1 -1
  39. package/dist/ui/assets/{mount-picker-popup-DuIeknAs.js → mount-picker-popup-B4U0fkZK.js} +1 -1
  40. package/dist/ui/assets/{new-session-FKHfcyjF.js → new-session-C8X_CG95.js} +1 -1
  41. package/dist/ui/assets/{oauth-bootstrap-GcJnv7ZS.js → oauth-bootstrap-DIqfOl-7.js} +2 -2
  42. package/dist/ui/assets/{oauth-service-C4iJUflq.js → oauth-service-CmHwn7zK.js} +1 -1
  43. package/dist/ui/assets/{onboarding-orchestrator-CMwxiNyG.js → onboarding-orchestrator-DSR8Msku.js} +1 -1
  44. package/dist/ui/assets/{openai-codex-Cd_FQwBX.js → openai-codex-Bnd4L2L7.js} +1 -1
  45. package/dist/ui/assets/{openai-codex-stad_9EL.js → openai-codex-DkqkFtKq.js} +1 -1
  46. package/dist/ui/assets/{openai-codex-responses-D6G4oCNQ.js → openai-codex-responses-iASEGX_4.js} +1 -1
  47. package/dist/ui/assets/{openai-completions-B-04OvVB.js → openai-completions-CnLJNyQk.js} +1 -1
  48. package/dist/ui/assets/{openai-responses-7lIT3cT2.js → openai-responses-TN943MT8.js} +1 -1
  49. package/dist/ui/assets/{openai-responses-shared-CWQY06he.js → openai-responses-shared-B1lth5mr.js} +1 -1
  50. package/dist/ui/assets/{panel-rpc-handlers-Cv_5zztD.js → panel-rpc-handlers-BgzkmaOE.js} +2 -2
  51. package/dist/ui/assets/{picker-approval-DeEn9TVD.js → picker-approval-EweLNWgE.js} +1 -1
  52. package/dist/ui/assets/{provider-98CPXvln.js → provider-DQ7BvBZw.js} +2 -2
  53. package/dist/ui/assets/{provider-settings-BHTU6Oq1.js → provider-settings-VV6aNiP5.js} +2 -2
  54. package/dist/ui/assets/provider-store-access-BGKXkdbd.js +1 -0
  55. package/dist/ui/assets/provider-store-access-Vtg1yxDc.js +1 -0
  56. package/dist/ui/assets/{provider-uxfYSUeg.js → provider-tWBv0sFX.js} +1 -1
  57. package/dist/ui/assets/{providers-ClvthlnA.js → providers-BmSZZhhm.js} +1 -1
  58. package/dist/ui/assets/{quick-llm-Dt3qzpkf.js → quick-llm-DdZDN1QH.js} +1 -1
  59. package/dist/ui/assets/{remote-cdp-transport-DGfqLmXT.js → remote-cdp-transport-B3-CFmk-.js} +1 -1
  60. package/dist/ui/assets/{remote-terminal-view-D1kkPl1J.js → remote-terminal-view-Hlq3HwiU.js} +1 -1
  61. package/dist/ui/assets/{secret-env-CmNKUmzu.js → secret-env-CkbRu-AG.js} +1 -1
  62. package/dist/ui/assets/session-freezer-JMR8P1Lt.js +1 -0
  63. package/dist/ui/assets/{setup-sprinkle-exec-CKhXbNXd.js → setup-sprinkle-exec-ByJwHfyz.js} +1 -1
  64. package/dist/ui/assets/setup-sudo-DPXnK0Zw.js +1 -0
  65. package/dist/ui/assets/{slicc-editor-BmqZL3Y5.js → slicc-editor-BxRqmU98.js} +1 -1
  66. package/dist/ui/assets/{sprinkle-manager-d2jZNgyG.js → sprinkle-manager-CqLTFoc9.js} +1 -1
  67. package/dist/ui/assets/{sprinkle-renderer-CYvBEU3p.js → sprinkle-renderer-5HX0pMZZ.js} +3 -3
  68. package/dist/ui/assets/{store-BzwlOEnO.js → store-CQo5JYZe.js} +1 -1
  69. package/dist/ui/assets/{sudo-bOqvYoca.js → sudo-fe6QprlZ.js} +1 -1
  70. package/dist/ui/assets/{sync-dialog-DcLi4B3X.js → sync-dialog-C1-e9vyv.js} +1 -1
  71. package/dist/ui/assets/{tray-leave-runtime-CNDoDnAL.js → tray-leave-runtime--Ue08Cke.js} +1 -1
  72. package/dist/ui/assets/{upgrade-detection-C6lp-50u.js → upgrade-detection-CHRBJqBB.js} +1 -1
  73. package/dist/ui/assets/{wc-attach-BGY9fjZ2.js → wc-attach-xs9Fh-R8.js} +3 -3
  74. package/dist/ui/assets/{wc-detached-BRgr8s0-.js → wc-detached-ux_E6SNJ.js} +1 -1
  75. package/dist/ui/assets/{wc-extension-aIAysc0n.js → wc-extension-BLxY1h5k.js} +2 -2
  76. package/dist/ui/assets/{wc-live-C6fyMRSK.js → wc-live-DHS3FYU1.js} +6 -6
  77. package/dist/ui/assets/{wc-nav-BXic2-dY.js → wc-nav-BZZe3rw8.js} +2 -2
  78. package/dist/ui/assets/{wc-onboarding-3iBOy9Nz.js → wc-onboarding-Cz9h4OE8.js} +2 -2
  79. package/dist/ui/assets/{wc-placeholder-B8YCKa-r.js → wc-placeholder-CO111fjo.js} +3 -3
  80. package/dist/ui/assets/{wc-settings-NLWwHmCR.js → wc-settings-DiYFz75I.js} +3 -3
  81. package/dist/ui/assets/{wc-shell-BlYl5z4M.js → wc-shell-9F74yNEh.js} +3 -3
  82. package/dist/ui/assets/{wc-sprinkles-B9Uz_XZG.js → wc-sprinkles-CUllz5Rn.js} +2 -2
  83. package/dist/ui/assets/{wc-tray-ChJE1e4m.js → wc-tray-DnIxlO0o.js} +3 -3
  84. package/dist/ui/assets/{wc-voice-BBKCesX0.js → wc-voice-DyAmRENA.js} +1 -1
  85. package/dist/ui/assets/{welcome-detection-CMcvBaT6.js → welcome-detection-D-eB9s6-.js} +1 -1
  86. package/dist/ui/assets/{xai-grok-BJlD5UbE.js → xai-grok-BNfjuAeJ.js} +1 -1
  87. package/dist/ui/assets/{xai-grok-CflYL-Ds.js → xai-grok-D8Dda6Qy.js} +1 -1
  88. package/dist/ui/index.html +1 -1
  89. package/dist/ui/packages/webapp/index.html +1 -1
  90. package/package.json +1 -1
  91. package/dist/ui/assets/dip-BjtVzOV1.js +0 -1
  92. package/dist/ui/assets/esp8266-k79PMUzO.js +0 -1
  93. package/dist/ui/assets/mount-CCWGGelc.js +0 -2
  94. package/dist/ui/assets/mount-ihMevaxm.js +0 -1
  95. package/dist/ui/assets/provider-store-access-DQA9SE91.js +0 -1
  96. package/dist/ui/assets/provider-store-access-DRY_bX7j.js +0 -1
  97. package/dist/ui/assets/session-freezer-tB8QnZcp.js +0 -1
  98. package/dist/ui/assets/setup-sudo-Bbfk21e1.js +0 -1
@@ -1 +1 @@
1
- import{n as e}from"./chunk-aKtaBQYM.js";import{nt as t}from"./main-CAjMV3Ro.js";var n=e({detectWelcomeFirstRun:()=>h,hasOnboardingFinalLickInHistory:()=>y,hasWelcomeLickInHistory:()=>p,recordWelcomed:()=>g}),r=t(`welcome-detection`),i=`/shared/.welcomed`,a=`browser-coding-agent`,o=1,s=`sessions`,c=`session-cone`,l=`[Sprinkle Event: welcome]`;function u(){return new Promise((e,t)=>{let n=indexedDB.open(a,o);n.onupgradeneeded=()=>{let e=n.result;e.objectStoreNames.contains(s)||e.createObjectStore(s,{keyPath:`id`})},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error),n.onblocked=()=>{}})}function d(){return u().catch(()=>new Promise((e,t)=>{setTimeout(()=>{u().then(e,t)},120)}))}async function f(){let e=await d();try{return await new Promise((t,n)=>{let r=e.transaction(s,`readonly`).objectStore(s).get(c);r.onsuccess=()=>t(r.result??null),r.onerror=()=>n(r.error)})}finally{e.close()}}async function p(){try{let e=await f();return!e||!Array.isArray(e.messages)?!1:e.messages.some(e=>m(e))}catch(e){return r.warn(`Failed to scan cone chat session for welcome lick`,{error:e instanceof Error?e.message:String(e)}),!1}}function m(e){let t=e.content;return typeof t==`string`?t.includes(l):Array.isArray(t)?t.some(e=>{if(typeof e==`string`)return e.includes(l);if(e&&typeof e==`object`){let t=e.text;if(typeof t==`string`)return t.includes(l)}return!1}):!1}async function h(e){let t=!1;try{t=await e.exists(i)}catch(e){return r.warn(`Failed to read welcomed marker`,{path:i,error:e instanceof Error?e.message:String(e)}),{isFirstRun:!1}}return t||await p()?{isFirstRun:!1}:{isFirstRun:!0}}async function g(e){await e.writeFile(i,`1`)}var _=`"action":"onboarding-complete-with-provider"`;function v(e){let t=e.content;return typeof t==`string`?t.includes(_):Array.isArray(t)?t.some(e=>{if(typeof e==`string`)return e.includes(_);if(e&&typeof e==`object`){let t=e.text;if(typeof t==`string`)return t.includes(_)}return!1}):!1}async function y(){try{let e=await f();return!e||!Array.isArray(e.messages)?!1:e.messages.some(e=>v(e))}catch(e){return r.warn(`Failed to scan cone chat session for final lick`,{error:e instanceof Error?e.message:String(e)}),!1}}export{g as n,n as r,h as t};
1
+ import{n as e}from"./chunk-aKtaBQYM.js";import{nt as t}from"./main-D7K1MTaQ.js";var n=e({detectWelcomeFirstRun:()=>h,hasOnboardingFinalLickInHistory:()=>y,hasWelcomeLickInHistory:()=>p,recordWelcomed:()=>g}),r=t(`welcome-detection`),i=`/shared/.welcomed`,a=`browser-coding-agent`,o=1,s=`sessions`,c=`session-cone`,l=`[Sprinkle Event: welcome]`;function u(){return new Promise((e,t)=>{let n=indexedDB.open(a,o);n.onupgradeneeded=()=>{let e=n.result;e.objectStoreNames.contains(s)||e.createObjectStore(s,{keyPath:`id`})},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error),n.onblocked=()=>{}})}function d(){return u().catch(()=>new Promise((e,t)=>{setTimeout(()=>{u().then(e,t)},120)}))}async function f(){let e=await d();try{return await new Promise((t,n)=>{let r=e.transaction(s,`readonly`).objectStore(s).get(c);r.onsuccess=()=>t(r.result??null),r.onerror=()=>n(r.error)})}finally{e.close()}}async function p(){try{let e=await f();return!e||!Array.isArray(e.messages)?!1:e.messages.some(e=>m(e))}catch(e){return r.warn(`Failed to scan cone chat session for welcome lick`,{error:e instanceof Error?e.message:String(e)}),!1}}function m(e){let t=e.content;return typeof t==`string`?t.includes(l):Array.isArray(t)?t.some(e=>{if(typeof e==`string`)return e.includes(l);if(e&&typeof e==`object`){let t=e.text;if(typeof t==`string`)return t.includes(l)}return!1}):!1}async function h(e){let t=!1;try{t=await e.exists(i)}catch(e){return r.warn(`Failed to read welcomed marker`,{path:i,error:e instanceof Error?e.message:String(e)}),{isFirstRun:!1}}return t||await p()?{isFirstRun:!1}:{isFirstRun:!0}}async function g(e){await e.writeFile(i,`1`)}var _=`"action":"onboarding-complete-with-provider"`;function v(e){let t=e.content;return typeof t==`string`?t.includes(_):Array.isArray(t)?t.some(e=>{if(typeof e==`string`)return e.includes(_);if(e&&typeof e==`object`){let t=e.text;if(typeof t==`string`)return t.includes(_)}return!1}):!1}async function y(){try{let e=await f();return!e||!Array.isArray(e.messages)?!1:e.messages.some(e=>v(e))}catch(e){return r.warn(`Failed to scan cone chat session for final lick`,{error:e instanceof Error?e.message:String(e)}),!1}}export{g as n,n as r,h as t};
@@ -1 +1 @@
1
- import{p as e,t}from"./provider-settings-BHTU6Oq1.js";import{b as n,h as r,y as i}from"./bedrock-camp-wxdDcDkR.js";import{o as a}from"./transform-messages-C1X1O3BY.js";import{XaiErrorCode as o,XaiOAuthError as s}from"./xai-grok-errors-ByEMMSoz.js";import{resolveModels as c,toModelMetadata as l}from"./xai-grok-models-B0Tf--xf.js";import{sanitizePayload as u}from"./xai-grok-sanitize-CV6qvaEF.js";const d=`xai-grok`,f=`https://auth.x.ai`,p=`${f}/oauth2/authorize`,m=`${f}/oauth2/token`,h=`b1a00492-073a-47ea-816f-4c329264a828`,g=`http://127.0.0.1:56121/callback`,_=`https://api.x.ai/v1`,v=`openai-responses`,y=`${d}-openai`;function b(){return typeof process>`u`?null:{}.PI_XAI_OAUTH_MODELS??null}const x=c(b());function S(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function C(e){let t=new Uint8Array(e);return crypto.getRandomValues(t),t}function w(){return S(C(32))}async function T(e){let t=new TextEncoder().encode(e);return S(new Uint8Array(await crypto.subtle.digest(`SHA-256`,t)))}function E(){return S(C(16))}async function D(e,t){let n=new URLSearchParams({grant_type:`authorization_code`,code:e,redirect_uri:g,client_id:h,code_verifier:t}),r=await fetch(m,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:n});if(!r.ok)throw new s(`xAI token exchange failed: ${r.status} ${await r.text()}`,o.TOKEN_EXCHANGE_FAILED);let i=await r.json();if(!i.access_token)throw new s(`xAI token exchange did not return access_token.`,o.TOKEN_EXCHANGE_INVALID);return i}async function O(e){try{let t=new URLSearchParams({grant_type:`refresh_token`,refresh_token:e,client_id:h}),n=await fetch(m,{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 k(){return t().find(e=>e.providerId===d)}async function A(){let t=k();if(!t?.accessToken)throw new s("Not signed in to xAI Grok — run /login or `oauth-token xai-grok`",o.AUTH_MISSING,!0);let n=t.tokenExpiresAt??0;if(n&&Date.now()+6e4<n)return t.accessToken;if(t.refreshToken){let n=await O(t.refreshToken);if(n?.access_token)return await e({providerId:d,accessToken:n.access_token,refreshToken:n.refresh_token??t.refreshToken,tokenExpiresAt:Date.now()+(n.expires_in??21600)*1e3}),n.access_token}return t.accessToken}function j(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:y,provider:d,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 M(e,t){return n=>!n||typeof n!=`object`?n:u(n,e,t)}function N(e,t){return t?{...e??{},"x-grok-conv-id":t}:e}const P=(e,t,n={})=>{let i=a();return(async()=>{try{let a=await A(),o=n.sessionId,s=r({...e,baseUrl:_,api:v},t,{...n,apiKey:a,headers:N(n.headers,o),onPayload:M(e.id,o)});for await(let e of s)i.push(e);i.end()}catch(t){console.error(`[xai-grok] Stream error:`,t instanceof Error?t.message:String(t)),i.push(j(e,t)),i.end()}})(),i},F=(e,t,n)=>{let r=a();return(async()=>{try{let a=await A(),o=n?.sessionId,s=i({...e,baseUrl:_,api:v},t,{...n,apiKey:a,headers:N(n?.headers,o),onPayload:M(e.id,o)});for await(let e of s)r.push(e);r.end()}catch(t){console.error(`[xai-grok] Stream error:`,t instanceof Error?t.message:String(t)),r.push(j(e,t)),r.end()}})(),r},I={id:d,name:`xAI Grok (SuperGrok OAuth)`,description:`Grok via xAI OAuth — uses your SuperGrok subscription, no API key needed. Default model is Grok Heavy.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:`grok-4.20-multi-agent-0309`,oauthTokenDomains:[`api.x.ai`,`*.x.ai`,`auth.x.ai`,`accounts.x.ai`],getModelIds:()=>x.map(e=>{let t=l(e);return e.thinkingLevelMap?{...t,thinkingLevelMap:e.thinkingLevelMap}:t}),onOAuthLoginIntercepted:async(t,n,r)=>{let i=w(),a=await T(i),c=E(),l=E(),u=new URL(p);u.searchParams.set(`response_type`,`code`),u.searchParams.set(`client_id`,h),u.searchParams.set(`redirect_uri`,g),u.searchParams.set(`scope`,r?.scopes??`openid profile email offline_access grok-cli:access api:access`),u.searchParams.set(`code_challenge`,a),u.searchParams.set(`code_challenge_method`,`S256`),u.searchParams.set(`state`,c),u.searchParams.set(`nonce`,l),u.searchParams.set(`plan`,`generic`),u.searchParams.set(`referrer`,`slicc`);let f=await t({authorizeUrl:u.toString(),redirectUriPattern:`http://127.0.0.1:56121/*`,onCapture:`close`});if(!f)throw new s(`xAI OAuth login was cancelled or timed out`,o.CALLBACK_TIMEOUT);let m=new URL(f),v=m.searchParams.get(`code`),y=m.searchParams.get(`state`);if(!v)throw new s(`xAI OAuth redirect did not include a code`,o.CODE_MISSING);if(y!==c)throw new s(`xAI OAuth state mismatch — possible CSRF, aborting`,o.STATE_MISMATCH);let b=await D(v,i);await e({providerId:d,accessToken:b.access_token,refreshToken:b.refresh_token,tokenExpiresAt:Date.now()+(b.expires_in??21600)*1e3,baseUrl:_}),n()},onOAuthLogout:async()=>{await e({providerId:d,accessToken:``})},onSilentRenew:async()=>{let t=k();if(!t?.refreshToken)return null;let n=await O(t.refreshToken);return n?.access_token?(await e({providerId:d,accessToken:n.access_token,refreshToken:n.refresh_token??t.refreshToken,tokenExpiresAt:Date.now()+(n.expires_in??21600)*1e3}),n.access_token):null}};function L(){n({api:y,stream:P,streamSimple:F})}export{o as XaiErrorCode,s as XaiOAuthError,I as config,L as register};
1
+ import{p as e,t}from"./provider-settings-VV6aNiP5.js";import{b as n,h as r,y as i}from"./bedrock-camp-wxdDcDkR.js";import{o as a}from"./transform-messages-C1X1O3BY.js";import{XaiErrorCode as o,XaiOAuthError as s}from"./xai-grok-errors-ByEMMSoz.js";import{resolveModels as c,toModelMetadata as l}from"./xai-grok-models-B0Tf--xf.js";import{sanitizePayload as u}from"./xai-grok-sanitize-CV6qvaEF.js";const d=`xai-grok`,f=`https://auth.x.ai`,p=`${f}/oauth2/authorize`,m=`${f}/oauth2/token`,h=`b1a00492-073a-47ea-816f-4c329264a828`,g=`http://127.0.0.1:56121/callback`,_=`https://api.x.ai/v1`,v=`openai-responses`,y=`${d}-openai`;function b(){return typeof process>`u`?null:{}.PI_XAI_OAUTH_MODELS??null}const x=c(b());function S(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function C(e){let t=new Uint8Array(e);return crypto.getRandomValues(t),t}function w(){return S(C(32))}async function T(e){let t=new TextEncoder().encode(e);return S(new Uint8Array(await crypto.subtle.digest(`SHA-256`,t)))}function E(){return S(C(16))}async function D(e,t){let n=new URLSearchParams({grant_type:`authorization_code`,code:e,redirect_uri:g,client_id:h,code_verifier:t}),r=await fetch(m,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:n});if(!r.ok)throw new s(`xAI token exchange failed: ${r.status} ${await r.text()}`,o.TOKEN_EXCHANGE_FAILED);let i=await r.json();if(!i.access_token)throw new s(`xAI token exchange did not return access_token.`,o.TOKEN_EXCHANGE_INVALID);return i}async function O(e){try{let t=new URLSearchParams({grant_type:`refresh_token`,refresh_token:e,client_id:h}),n=await fetch(m,{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 k(){return t().find(e=>e.providerId===d)}async function A(){let t=k();if(!t?.accessToken)throw new s("Not signed in to xAI Grok — run /login or `oauth-token xai-grok`",o.AUTH_MISSING,!0);let n=t.tokenExpiresAt??0;if(n&&Date.now()+6e4<n)return t.accessToken;if(t.refreshToken){let n=await O(t.refreshToken);if(n?.access_token)return await e({providerId:d,accessToken:n.access_token,refreshToken:n.refresh_token??t.refreshToken,tokenExpiresAt:Date.now()+(n.expires_in??21600)*1e3}),n.access_token}return t.accessToken}function j(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:y,provider:d,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 M(e,t){return n=>!n||typeof n!=`object`?n:u(n,e,t)}function N(e,t){return t?{...e??{},"x-grok-conv-id":t}:e}const P=(e,t,n={})=>{let i=a();return(async()=>{try{let a=await A(),o=n.sessionId,s=r({...e,baseUrl:_,api:v},t,{...n,apiKey:a,headers:N(n.headers,o),onPayload:M(e.id,o)});for await(let e of s)i.push(e);i.end()}catch(t){console.error(`[xai-grok] Stream error:`,t instanceof Error?t.message:String(t)),i.push(j(e,t)),i.end()}})(),i},F=(e,t,n)=>{let r=a();return(async()=>{try{let a=await A(),o=n?.sessionId,s=i({...e,baseUrl:_,api:v},t,{...n,apiKey:a,headers:N(n?.headers,o),onPayload:M(e.id,o)});for await(let e of s)r.push(e);r.end()}catch(t){console.error(`[xai-grok] Stream error:`,t instanceof Error?t.message:String(t)),r.push(j(e,t)),r.end()}})(),r},I={id:d,name:`xAI Grok (SuperGrok OAuth)`,description:`Grok via xAI OAuth — uses your SuperGrok subscription, no API key needed. Default model is Grok Heavy.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:`grok-4.20-multi-agent-0309`,oauthTokenDomains:[`api.x.ai`,`*.x.ai`,`auth.x.ai`,`accounts.x.ai`],getModelIds:()=>x.map(e=>{let t=l(e);return e.thinkingLevelMap?{...t,thinkingLevelMap:e.thinkingLevelMap}:t}),onOAuthLoginIntercepted:async(t,n,r)=>{let i=w(),a=await T(i),c=E(),l=E(),u=new URL(p);u.searchParams.set(`response_type`,`code`),u.searchParams.set(`client_id`,h),u.searchParams.set(`redirect_uri`,g),u.searchParams.set(`scope`,r?.scopes??`openid profile email offline_access grok-cli:access api:access`),u.searchParams.set(`code_challenge`,a),u.searchParams.set(`code_challenge_method`,`S256`),u.searchParams.set(`state`,c),u.searchParams.set(`nonce`,l),u.searchParams.set(`plan`,`generic`),u.searchParams.set(`referrer`,`slicc`);let f=await t({authorizeUrl:u.toString(),redirectUriPattern:`http://127.0.0.1:56121/*`,onCapture:`close`});if(!f)throw new s(`xAI OAuth login was cancelled or timed out`,o.CALLBACK_TIMEOUT);let m=new URL(f),v=m.searchParams.get(`code`),y=m.searchParams.get(`state`);if(!v)throw new s(`xAI OAuth redirect did not include a code`,o.CODE_MISSING);if(y!==c)throw new s(`xAI OAuth state mismatch — possible CSRF, aborting`,o.STATE_MISMATCH);let b=await D(v,i);await e({providerId:d,accessToken:b.access_token,refreshToken:b.refresh_token,tokenExpiresAt:Date.now()+(b.expires_in??21600)*1e3,baseUrl:_}),n()},onOAuthLogout:async()=>{await e({providerId:d,accessToken:``})},onSilentRenew:async()=>{let t=k();if(!t?.refreshToken)return null;let n=await O(t.refreshToken);return n?.access_token?(await e({providerId:d,accessToken:n.access_token,refreshToken:n.refresh_token??t.refreshToken,tokenExpiresAt:Date.now()+(n.expires_in??21600)*1e3}),n.access_token):null}};function L(){n({api:y,stream:P,streamSimple:F})}export{o as XaiErrorCode,s as XaiOAuthError,I as config,L as register};
@@ -1 +1 @@
1
- import{Ot as e,ht as t,r as n,v as r,xt as i,yt as a}from"./main-CAjMV3Ro.js";import{XaiErrorCode as o,XaiOAuthError as s}from"./xai-grok-errors-bnlIBeu-.js";import{resolveModels as c,toModelMetadata as l}from"./xai-grok-models-CeEBaUMC.js";import{sanitizePayload as u}from"./xai-grok-sanitize-CR2JoOJd.js";var d=`xai-grok`,f=`https://auth.x.ai`,p=`${f}/oauth2/authorize`,m=`${f}/oauth2/token`,h=`b1a00492-073a-47ea-816f-4c329264a828`,g=`openid profile email offline_access grok-cli:access api:access`,_=`http://127.0.0.1:56121/callback`,v=`http://127.0.0.1:56121/*`,y=`https://api.x.ai/v1`,b=`openai-responses`,x=`${d}-openai`;function S(){return typeof process>`u`?null:{}.PI_XAI_OAUTH_MODELS??null}var C=c(S());function w(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function T(e){let t=new Uint8Array(e);return crypto.getRandomValues(t),t}function E(){return w(T(32))}async function D(e){let t=new TextEncoder().encode(e);return w(new Uint8Array(await crypto.subtle.digest(`SHA-256`,t)))}function O(){return w(T(16))}async function k(e,t){let n=new URLSearchParams({grant_type:`authorization_code`,code:e,redirect_uri:_,client_id:h,code_verifier:t}),r=await fetch(m,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:n});if(!r.ok)throw new s(`xAI token exchange failed: ${r.status} ${await r.text()}`,o.TOKEN_EXCHANGE_FAILED);let i=await r.json();if(!i.access_token)throw new s(`xAI token exchange did not return access_token.`,o.TOKEN_EXCHANGE_INVALID);return i}async function A(e){try{let t=new URLSearchParams({grant_type:`refresh_token`,refresh_token:e,client_id:h}),n=await fetch(m,{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 j(){return n().find(e=>e.providerId===d)}async function M(){let e=j();if(!e?.accessToken)throw new s("Not signed in to xAI Grok — run /login or `oauth-token xai-grok`",o.AUTH_MISSING,!0);let t=e.tokenExpiresAt??0;if(t&&Date.now()+6e4<t)return e.accessToken;if(e.refreshToken){let t=await A(e.refreshToken);if(t?.access_token)return await r({providerId:d,accessToken:t.access_token,refreshToken:t.refresh_token??e.refreshToken,tokenExpiresAt:Date.now()+(t.expires_in??21600)*1e3}),t.access_token}return e.accessToken}function N(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:x,provider:d,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 P(e,t){return n=>!n||typeof n!=`object`?n:u(n,e,t)}function F(e,t){return t?{...e??{},"x-grok-conv-id":t}:e}var I=(e,n,r={})=>{let a=i();return(async()=>{try{let i=await M(),o=r.sessionId,s=t({...e,baseUrl:y,api:b},n,{...r,apiKey:i,headers:F(r.headers,o),onPayload:P(e.id,o)});for await(let e of s)a.push(e);a.end()}catch(t){console.error(`[xai-grok] Stream error:`,t instanceof Error?t.message:String(t)),a.push(N(e,t)),a.end()}})(),a},L=(e,t,n)=>{let r=i();return(async()=>{try{let i=await M(),o=n?.sessionId,s=a({...e,baseUrl:y,api:b},t,{...n,apiKey:i,headers:F(n?.headers,o),onPayload:P(e.id,o)});for await(let e of s)r.push(e);r.end()}catch(t){console.error(`[xai-grok] Stream error:`,t instanceof Error?t.message:String(t)),r.push(N(e,t)),r.end()}})(),r},R={id:d,name:`xAI Grok (SuperGrok OAuth)`,description:`Grok via xAI OAuth — uses your SuperGrok subscription, no API key needed. Default model is Grok Heavy.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:`grok-4.20-multi-agent-0309`,oauthTokenDomains:[`api.x.ai`,`*.x.ai`,`auth.x.ai`,`accounts.x.ai`],getModelIds:()=>C.map(e=>{let t=l(e);return e.thinkingLevelMap?{...t,thinkingLevelMap:e.thinkingLevelMap}:t}),onOAuthLoginIntercepted:async(e,t,n)=>{let i=E(),a=await D(i),c=O(),l=O(),u=new URL(p);u.searchParams.set(`response_type`,`code`),u.searchParams.set(`client_id`,h),u.searchParams.set(`redirect_uri`,_),u.searchParams.set(`scope`,n?.scopes??g),u.searchParams.set(`code_challenge`,a),u.searchParams.set(`code_challenge_method`,`S256`),u.searchParams.set(`state`,c),u.searchParams.set(`nonce`,l),u.searchParams.set(`plan`,`generic`),u.searchParams.set(`referrer`,`slicc`);let f=await e({authorizeUrl:u.toString(),redirectUriPattern:v,onCapture:`close`});if(!f)throw new s(`xAI OAuth login was cancelled or timed out`,o.CALLBACK_TIMEOUT);let m=new URL(f),b=m.searchParams.get(`code`),x=m.searchParams.get(`state`);if(!b)throw new s(`xAI OAuth redirect did not include a code`,o.CODE_MISSING);if(x!==c)throw new s(`xAI OAuth state mismatch — possible CSRF, aborting`,o.STATE_MISMATCH);let S=await k(b,i);await r({providerId:d,accessToken:S.access_token,refreshToken:S.refresh_token,tokenExpiresAt:Date.now()+(S.expires_in??21600)*1e3,baseUrl:y}),t()},onOAuthLogout:async()=>{await r({providerId:d,accessToken:``})},onSilentRenew:async()=>{let e=j();if(!e?.refreshToken)return null;let t=await A(e.refreshToken);return t?.access_token?(await r({providerId:d,accessToken:t.access_token,refreshToken:t.refresh_token??e.refreshToken,tokenExpiresAt:Date.now()+(t.expires_in??21600)*1e3}),t.access_token):null}};function z(){e({api:x,stream:I,streamSimple:L})}export{o as XaiErrorCode,s as XaiOAuthError,R as config,z as register};
1
+ import{Ot as e,ht as t,r as n,v as r,xt as i,yt as a}from"./main-D7K1MTaQ.js";import{XaiErrorCode as o,XaiOAuthError as s}from"./xai-grok-errors-bnlIBeu-.js";import{resolveModels as c,toModelMetadata as l}from"./xai-grok-models-CeEBaUMC.js";import{sanitizePayload as u}from"./xai-grok-sanitize-CR2JoOJd.js";var d=`xai-grok`,f=`https://auth.x.ai`,p=`${f}/oauth2/authorize`,m=`${f}/oauth2/token`,h=`b1a00492-073a-47ea-816f-4c329264a828`,g=`openid profile email offline_access grok-cli:access api:access`,_=`http://127.0.0.1:56121/callback`,v=`http://127.0.0.1:56121/*`,y=`https://api.x.ai/v1`,b=`openai-responses`,x=`${d}-openai`;function S(){return typeof process>`u`?null:{}.PI_XAI_OAUTH_MODELS??null}var C=c(S());function w(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function T(e){let t=new Uint8Array(e);return crypto.getRandomValues(t),t}function E(){return w(T(32))}async function D(e){let t=new TextEncoder().encode(e);return w(new Uint8Array(await crypto.subtle.digest(`SHA-256`,t)))}function O(){return w(T(16))}async function k(e,t){let n=new URLSearchParams({grant_type:`authorization_code`,code:e,redirect_uri:_,client_id:h,code_verifier:t}),r=await fetch(m,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:n});if(!r.ok)throw new s(`xAI token exchange failed: ${r.status} ${await r.text()}`,o.TOKEN_EXCHANGE_FAILED);let i=await r.json();if(!i.access_token)throw new s(`xAI token exchange did not return access_token.`,o.TOKEN_EXCHANGE_INVALID);return i}async function A(e){try{let t=new URLSearchParams({grant_type:`refresh_token`,refresh_token:e,client_id:h}),n=await fetch(m,{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 j(){return n().find(e=>e.providerId===d)}async function M(){let e=j();if(!e?.accessToken)throw new s("Not signed in to xAI Grok — run /login or `oauth-token xai-grok`",o.AUTH_MISSING,!0);let t=e.tokenExpiresAt??0;if(t&&Date.now()+6e4<t)return e.accessToken;if(e.refreshToken){let t=await A(e.refreshToken);if(t?.access_token)return await r({providerId:d,accessToken:t.access_token,refreshToken:t.refresh_token??e.refreshToken,tokenExpiresAt:Date.now()+(t.expires_in??21600)*1e3}),t.access_token}return e.accessToken}function N(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:x,provider:d,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 P(e,t){return n=>!n||typeof n!=`object`?n:u(n,e,t)}function F(e,t){return t?{...e??{},"x-grok-conv-id":t}:e}var I=(e,n,r={})=>{let a=i();return(async()=>{try{let i=await M(),o=r.sessionId,s=t({...e,baseUrl:y,api:b},n,{...r,apiKey:i,headers:F(r.headers,o),onPayload:P(e.id,o)});for await(let e of s)a.push(e);a.end()}catch(t){console.error(`[xai-grok] Stream error:`,t instanceof Error?t.message:String(t)),a.push(N(e,t)),a.end()}})(),a},L=(e,t,n)=>{let r=i();return(async()=>{try{let i=await M(),o=n?.sessionId,s=a({...e,baseUrl:y,api:b},t,{...n,apiKey:i,headers:F(n?.headers,o),onPayload:P(e.id,o)});for await(let e of s)r.push(e);r.end()}catch(t){console.error(`[xai-grok] Stream error:`,t instanceof Error?t.message:String(t)),r.push(N(e,t)),r.end()}})(),r},R={id:d,name:`xAI Grok (SuperGrok OAuth)`,description:`Grok via xAI OAuth — uses your SuperGrok subscription, no API key needed. Default model is Grok Heavy.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:`grok-4.20-multi-agent-0309`,oauthTokenDomains:[`api.x.ai`,`*.x.ai`,`auth.x.ai`,`accounts.x.ai`],getModelIds:()=>C.map(e=>{let t=l(e);return e.thinkingLevelMap?{...t,thinkingLevelMap:e.thinkingLevelMap}:t}),onOAuthLoginIntercepted:async(e,t,n)=>{let i=E(),a=await D(i),c=O(),l=O(),u=new URL(p);u.searchParams.set(`response_type`,`code`),u.searchParams.set(`client_id`,h),u.searchParams.set(`redirect_uri`,_),u.searchParams.set(`scope`,n?.scopes??g),u.searchParams.set(`code_challenge`,a),u.searchParams.set(`code_challenge_method`,`S256`),u.searchParams.set(`state`,c),u.searchParams.set(`nonce`,l),u.searchParams.set(`plan`,`generic`),u.searchParams.set(`referrer`,`slicc`);let f=await e({authorizeUrl:u.toString(),redirectUriPattern:v,onCapture:`close`});if(!f)throw new s(`xAI OAuth login was cancelled or timed out`,o.CALLBACK_TIMEOUT);let m=new URL(f),b=m.searchParams.get(`code`),x=m.searchParams.get(`state`);if(!b)throw new s(`xAI OAuth redirect did not include a code`,o.CODE_MISSING);if(x!==c)throw new s(`xAI OAuth state mismatch — possible CSRF, aborting`,o.STATE_MISMATCH);let S=await k(b,i);await r({providerId:d,accessToken:S.access_token,refreshToken:S.refresh_token,tokenExpiresAt:Date.now()+(S.expires_in??21600)*1e3,baseUrl:y}),t()},onOAuthLogout:async()=>{await r({providerId:d,accessToken:``})},onSilentRenew:async()=>{let e=j();if(!e?.refreshToken)return null;let t=await A(e.refreshToken);return t?.access_token?(await r({providerId:d,accessToken:t.access_token,refreshToken:t.refresh_token??e.refreshToken,tokenExpiresAt:Date.now()+(t.expires_in??21600)*1e3}),t.access_token):null}};function z(){e({api:x,stream:I,streamSimple:L})}export{o as XaiErrorCode,s as XaiOAuthError,R as config,z as register};
@@ -5,7 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>slicc</title>
7
7
  <link rel="icon" type="image/png" href="/logos/sliccy-color-1scoops-32x32.png" />
8
- <script type="module" crossorigin src="/assets/main-CAjMV3Ro.js"></script>
8
+ <script type="module" crossorigin src="/assets/main-D7K1MTaQ.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/chunk-aKtaBQYM.js">
10
10
  <link rel="modulepreload" crossorigin href="/assets/modulepreload-polyfill-Dezn_h7o.js">
11
11
  </head>
@@ -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-CAjMV3Ro.js"></script>
8
+ <script type="module" crossorigin src="/assets/main-D7K1MTaQ.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/chunk-aKtaBQYM.js">
10
10
  <link rel="modulepreload" crossorigin href="/assets/modulepreload-polyfill-Dezn_h7o.js">
11
11
  </head>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sliccy",
3
- "version": "4.0.0",
3
+ "version": "4.0.2",
4
4
  "description": "Browser-based coding agent with thin CLI server",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -1 +0,0 @@
1
- import{m as e}from"./wc-live-C6fyMRSK.js";export{e as setDipExecHandler};
@@ -1 +0,0 @@
1
- import{t as e}from"./esptool-operations-3OtqiSvP.js";export{e as ESP8266ROM};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/main-CAjMV3Ro.js","assets/chunk-aKtaBQYM.js","assets/modulepreload-polyfill-Dezn_h7o.js"])))=>i.map(i=>d[i]);
2
- import{Dt as e,Q as t}from"./main-CAjMV3Ro.js";import{t as n}from"./types-idfTVsM8.js";import"./mount-id-BuG8r64x.js";function r(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 i(e){return e.split(`/`).pop()||`data`}function a(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 o=5*1024*1024,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=a(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??o,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new n(`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),r=await this.cache.getBody(t);if(r&&!this.cache.isStale(r.cachedAt))return r.body;let i={};r&&(i[`if-none-match`]=r.etag);let a=await this.transport({method:`GET`,path:this.toSourcePath(t),headers:i});if(a.status===304&&r)return await this.cache.putBody(t,r.body,r.etag),r.body;if(a.status===404)throw await this.cache.invalidateBody(t),new n(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new n(`EACCES`,`da access denied`,e);if(a.status>=400)throw new n(`EIO`,`da readFile failed: ${a.status}`,e);let o=a.headers.get(`content-length`),s=o?Number(o):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new n(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new n(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=a.headers.get(`etag`)??``;return await this.cache.putBody(t,c,l),c}async writeFile(e,a){if(this.assertOpen(e),a.byteLength>this.maxBodyBytes)throw new n(`EFBIG`,`body exceeds maxBodyBytes`,e);let o=this.toMountRelative(e),s=await this.cache.getBody(o),c=r(i(e),t(e),a),l={"content-type":c.contentType,"content-length":String(c.body.byteLength)};s?.etag?l[`if-match`]=s.etag:s||(l[`if-none-match`]=`*`);let u=()=>this.transport({method:`POST`,path:this.toSourcePath(o),headers:l,body:c.body}),d,f=1;try{d=await u()}catch{f=2,d=await u()}if(d.status===412){if(f===2){let t=await this.transport({method:`HEAD`,path:this.toSourcePath(o)});if(t.status>=400)throw new n(`EIO`,`da reconcile HEAD failed: ${t.status}`,e);let r=t.headers.get(`etag`)??``;await this.cache.putBody(o,a,r);let i=o.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(i);return}await this.cache.invalidateBody(o);try{await this.readFile(e)}catch{}throw new n(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(d.status===401||d.status===403)throw new n(`EACCES`,`da write denied`,e);if(d.status>=400)throw new n(`EIO`,`da writeFile failed: ${d.status}`,e);let p=d.headers.get(`etag`)??``;await this.cache.putBody(o,a,p);let m=o.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(m)}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),r=await this.cache.getListing(t);if(r&&!this.cache.isStale(r.cachedAt))return r.entries;let i=await this.transport({method:`GET`,path:this.toListPath(t)});if(i.status===404)throw new n(`ENOENT`,`no such directory`,e);if(i.status>=400)throw new n(`EIO`,`da list failed: ${i.status}`,e);let a=(await i.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,a),a}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),r=await this.cache.getBody(t);if(r)return{kind:`file`,size:r.size,mtime:r.cachedAt,etag:r.etag};let i=t.split(`/`),a=i.pop()??``,o=i.join(`/`),s=await this.cache.getListing(o);if(s&&!this.cache.isStale(s.cachedAt)){let t=s.entries.find(e=>e.name===a);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??s.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??s.cachedAt};if(!t)throw new n(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,path:this.toSourcePath(t)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`),r=n?Date.parse(n):0;if(s){let n=s.entries.map(n=>n.name===a&&n.kind===`file`?{...n,size:e,etag:t,lastModified:r}:n);await this.cache.putListing(o,n)}return{kind:`file`,size:e,mtime:r,etag:t}}if(c.status===404){let r=await this.cache.getListing(t);if(r)return{kind:`directory`,size:0,mtime:r.cachedAt};throw new n(`ENOENT`,`no such file or directory`,e)}throw new n(`EIO`,`da stat failed: ${c.status}`,e)}async mkdir(e){}async remove(e){this.assertOpen(e);let t=this.toMountRelative(e),r=await this.transport({method:`DELETE`,path:this.toSourcePath(t)});if(r.status===404)throw new n(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new n(`EACCES`,`da delete denied`,e);if(r.status>=400)throw new n(`EIO`,`da delete failed: ${r.status}`,e);await this.cache.invalidateBody(t);let i=t.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(i)}async refresh(e){this.assertOpen(`/`);let t={added:[],removed:[],changed:[],unchanged:0,errors:[]},n=[``];for(;n.length>0;){let e=n.pop();try{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}`});continue}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});let i=await this.cache.getBody(n);i?r.etag&&i.etag!==r.etag?(await this.cache.invalidateBody(n),t.changed.push(n)):t.unchanged++:t.added.push(n)}else{a.push({name:r.name,kind:`directory`});let t=e?`${e}/${r.name}`:r.name;n.push(t)}await this.cache.putListing(e,a)}catch(n){t.errors.push({path:e,message:n instanceof Error?n.message:String(n)})}}if(e?.bodies)for(let e of t.changed)try{await this.readFile(e)}catch(n){t.errors.push({path:e,message:n instanceof Error?n.message:String(n)})}return t}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 l=25*1024*1024,u=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??l,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new n(`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),r=await this.cache.getBody(t);if(r&&!this.cache.isStale(r.cachedAt))return r.body;let i={};r&&(i[`if-none-match`]=r.etag);let a=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:this.toS3Key(t),headers:i});if(a.status===304&&r)return await this.cache.putBody(t,r.body,r.etag),r.body;if(a.status===404)throw await this.cache.invalidateBody(t),new n(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new n(`EACCES`,`s3 access denied`,e);if(a.status>=400)throw new n(`EIO`,`s3 readFile failed: ${a.status}`,e);let o=a.headers.get(`content-length`),s=o?Number(o):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new n(`EFBIG`,`body exceeds maxBodyBytes (${s} > ${this.maxBodyBytes})`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new n(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=a.headers.get(`etag`)??``;return await this.cache.putBody(t,c,l),c}async writeFile(e,t){this.assertOpen(e);let r=this.toMountRelative(e);if(t.byteLength>this.maxBodyBytes)throw new n(`EFBIG`,`body exceeds maxBodyBytes`,e);let i=await this.cache.getBody(r),a={"content-type":`application/octet-stream`,"content-length":String(t.byteLength)};i?a[`if-match`]=i.etag:a[`if-none-match`]=`*`;let o=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(r),headers:a,body:t}),s,c=1;try{s=await o()}catch{c=2,s=await o()}if(s.status===412){if(c===2){let i=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(r)});if(i.status>=400)throw new n(`EIO`,`s3 reconcile HEAD failed: ${i.status}`,e);let a=i.headers.get(`etag`)??``;await this.cache.putBody(r,t,a);let o=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(r);try{await this.readFile(e)}catch{}throw new n(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(s.status===401||s.status===403)throw new n(`EACCES`,`s3 write denied`,e);if(s.status>=400)throw new n(`EIO`,`s3 writeFile failed: ${s.status}`,e);let l=s.headers.get(`etag`)??``;await this.cache.putBody(r,t,l);let u=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(u)}async listObjectsV2(){let e=[],t;do{let r={"list-type":`2`};this.parsed.prefix&&(r.prefix=`${this.parsed.prefix}/`),t&&(r[`continuation-token`]=t);let i=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:``,query:r});if(i.status>=400)throw new n(`EIO`,`s3 list failed: ${i.status}`,`/`);let a=await i.text(),o=this.parseListingXml(a);e.push(...o.contents),t=o.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),r=await this.cache.getBody(t);if(r)return{kind:`file`,size:r.body.byteLength,mtime:r.cachedAt,etag:r.etag};let i=t.split(`/`),a=i.pop()??``,o=i.join(`/`),s=await this.cache.getListing(o);if(s&&!this.cache.isStale(s.cachedAt)){let t=s.entries.find(e=>e.name===a);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??s.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??s.cachedAt};if(!t)throw new n(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(t)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`);return{kind:`file`,size:e,mtime:n?Date.parse(n):0,etag:t}}if(c.status===404){let r=await this.cache.getListing(t);if(r)return{kind:`directory`,size:0,mtime:r.cachedAt};throw new n(`ENOENT`,`no such file or directory`,e)}throw new n(`EIO`,`s3 stat failed: ${c.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 r=this.toMountRelative(e);if(t?.recursive)throw new n(`EINVAL`,`recursive remove not yet supported on S3`,e);let i=await this.transport({method:`DELETE`,bucket:this.parsed.bucket,key:this.toS3Key(r)});if(i.status===404)throw new n(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new n(`EACCES`,`s3 delete denied`,e);if(i.status>=400)throw new n(`EIO`,`s3 delete failed: ${i.status}`,e);await this.cache.invalidateBody(r);let a=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a)}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}},d=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function f(){let{getAccounts:t}=await e(async()=>{let{getAccounts:e}=await import(`./main-CAjMV3Ro.js`).then(e=>e.h);return{getAccounts:e}},__vite__mapDeps([0,1,2])),n=t().find(e=>e.providerId===`adobe`);if(!n?.accessToken)throw new d(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>n.accessToken}}var p=`slicc-mount-cache`,m=`listings`,h=`bodies`,g=class{mountId;ttlMs;dbName;dbPromise=null;constructor(e){this.mountId=e.mountId,this.ttlMs=e.ttlMs,this.dbName=e.dbName??p}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(m)||e.createObjectStore(m),e.objectStoreNames.contains(h)||e.createObjectStore(h)},n.onsuccess=()=>e(n.result),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(m,`readonly`).objectStore(m).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(m,`readwrite`),o={entries:t,cachedAt:Date.now()};a.objectStore(m).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(m,`readwrite`);i.objectStore(m).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(h,`readonly`).objectStore(h).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,h,this.key(e),i)}catch(t){if(t instanceof DOMException&&t.name===`QuotaExceededError`){await this.evictLru(.25);try{await this.txPut(r,h,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(h,`readwrite`);i.objectStore(h).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(m),n(h)])}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(h,`readonly`).objectStore(h),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(h,`readwrite`),i=r.objectStore(h);for(let{key:e}of a)i.delete(e);r.oncomplete=()=>e(),r.onerror=()=>n(r.error)})}};function _(){return typeof chrome<`u`&&!!chrome?.runtime?.id}function v(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function y(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}var b=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),x=new Set([101,103,204,205,304]);function S(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new n(`EACCES`,e.error):e.errorCode===`invalid_request`?new n(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||b.has(String(e.errorCode))?new n(`EIO`,e.error):new n(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=v(e.bodyBase64)}catch(e){throw new n(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let r=x.has(e.status)?null:t;return new Response(r,{status:e.status,headers:new Headers(e.headers)})}async function C(e,t){let r;try{r=await fetch(e,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)})}catch(e){throw new n(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (SLICC backend at localhost may not be running)`)}try{return await r.json()}catch(e){throw new n(`EIO`,`mount transport: response is not a JSON envelope (status ${r.status}): ${e instanceof Error?e.message:String(e)}`)}}async function w(e,t){try{return await chrome.runtime.sendMessage({type:e,envelope:t})}catch(e){throw new n(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (extension service worker not responding)`)}}function T(e){return async t=>{let n={profile:e,method:t.method,bucket:t.bucket,key:t.key,query:t.query,headers:t.headers,bodyBase64:t.body?y(t.body):void 0};return S(_()?await w(`mount.s3-sign-and-forward`,n):await C(`/api/s3-sign-and-forward`,n))}}function E(e){let t=e?.getImsToken??(async()=>(await f()).getBearerToken());return async e=>{let r;try{r=await t()}catch(e){throw new n(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}let i={imsToken:r,method:e.method,path:e.path,query:e.query,headers:e.headers,bodyBase64:e.body?y(e.body):void 0};return S(_()?await w(`mount.da-sign-and-forward`,i):await C(`/api/da-sign-and-forward`,i))}}export{s as DaMountBackend,g as RemoteMountCache,u as S3MountBackend,E as makeSignedFetchDa,T as makeSignedFetchS3};
@@ -1 +0,0 @@
1
- import{r as e}from"./chunk-CMxvf4Kt.js";import"./backend-local-CMfz45hs.js";import{t}from"./types-idfTVsM8.js";import"./src-CpdsjHiA.js";import{t as n}from"./mime-types-BG9Gw1bq.js";import{t as r}from"./remote-cache-_bhYZSLy.js";function i(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 a(e){return e.split(`/`).pop()||`data`}function o(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 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=o(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??5242880,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new t(`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 n=this.toMountRelative(e),r=await this.cache.getBody(n);if(r&&!this.cache.isStale(r.cachedAt))return r.body;let i={};r&&(i[`if-none-match`]=r.etag);let a=await this.transport({method:`GET`,path:this.toSourcePath(n),headers:i});if(a.status===304&&r)return await this.cache.putBody(n,r.body,r.etag),r.body;if(a.status===404)throw await this.cache.invalidateBody(n),new t(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new t(`EACCES`,`da access denied`,e);if(a.status>=400)throw new t(`EIO`,`da readFile failed: ${a.status}`,e);let o=a.headers.get(`content-length`),s=o?Number(o):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new t(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new t(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=a.headers.get(`etag`)??``;return await this.cache.putBody(n,c,l),c}async writeFile(e,r){if(this.assertOpen(e),r.byteLength>this.maxBodyBytes)throw new t(`EFBIG`,`body exceeds maxBodyBytes`,e);let o=this.toMountRelative(e),s=await this.cache.getBody(o),c=i(a(e),n(e),r),l={"content-type":c.contentType,"content-length":String(c.body.byteLength)};s?.etag?l[`if-match`]=s.etag:s||(l[`if-none-match`]=`*`);let u=()=>this.transport({method:`POST`,path:this.toSourcePath(o),headers:l,body:c.body}),d,f=1;try{d=await u()}catch{f=2,d=await u()}if(d.status===412){if(f===2){let n=await this.transport({method:`HEAD`,path:this.toSourcePath(o)});if(n.status>=400)throw new t(`EIO`,`da reconcile HEAD failed: ${n.status}`,e);let i=n.headers.get(`etag`)??``;await this.cache.putBody(o,r,i);let a=o.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a);return}await this.cache.invalidateBody(o);try{await this.readFile(e)}catch{}throw new t(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(d.status===401||d.status===403)throw new t(`EACCES`,`da write denied`,e);if(d.status>=400)throw new t(`EIO`,`da writeFile failed: ${d.status}`,e);let p=d.headers.get(`etag`)??``;await this.cache.putBody(o,r,p);let m=o.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(m)}async readDir(e){this.assertOpen(e);let n=this.toMountRelative(e).replace(/\/+$/,``),r=await this.cache.getListing(n);if(r&&!this.cache.isStale(r.cachedAt))return r.entries;let i=await this.transport({method:`GET`,path:this.toListPath(n)});if(i.status===404)throw new t(`ENOENT`,`no such directory`,e);if(i.status>=400)throw new t(`EIO`,`da list failed: ${i.status}`,e);let a=(await i.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(n,a),a}async stat(e){this.assertOpen(e);let n=this.toMountRelative(e),r=await this.cache.getBody(n);if(r)return{kind:`file`,size:r.size,mtime:r.cachedAt,etag:r.etag};let i=n.split(`/`),a=i.pop()??``,o=i.join(`/`),s=await this.cache.getListing(o);if(s&&!this.cache.isStale(s.cachedAt)){let n=s.entries.find(e=>e.name===a);if(n?.kind===`file`&&n.size!==void 0)return{kind:`file`,size:n.size,mtime:n.lastModified??s.cachedAt,etag:n.etag??``};if(n?.kind===`directory`)return{kind:`directory`,size:0,mtime:n.lastModified??s.cachedAt};if(!n)throw new t(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,path:this.toSourcePath(n)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`),r=n?Date.parse(n):0;if(s){let n=s.entries.map(n=>n.name===a&&n.kind===`file`?{...n,size:e,etag:t,lastModified:r}:n);await this.cache.putListing(o,n)}return{kind:`file`,size:e,mtime:r,etag:t}}if(c.status===404){let r=await this.cache.getListing(n);if(r)return{kind:`directory`,size:0,mtime:r.cachedAt};throw new t(`ENOENT`,`no such file or directory`,e)}throw new t(`EIO`,`da stat failed: ${c.status}`,e)}async mkdir(e){}async remove(e){this.assertOpen(e);let n=this.toMountRelative(e),r=await this.transport({method:`DELETE`,path:this.toSourcePath(n)});if(r.status===404)throw new t(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new t(`EACCES`,`da delete denied`,e);if(r.status>=400)throw new t(`EIO`,`da delete failed: ${r.status}`,e);await this.cache.invalidateBody(n);let i=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(i)}async refresh(e){this.assertOpen(`/`);let t={added:[],removed:[],changed:[],unchanged:0,errors:[]},n=[``];for(;n.length>0;){let e=n.pop();try{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}`});continue}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});let i=await this.cache.getBody(n);i?r.etag&&i.etag!==r.etag?(await this.cache.invalidateBody(n),t.changed.push(n)):t.unchanged++:t.added.push(n)}else{a.push({name:r.name,kind:`directory`});let t=e?`${e}/${r.name}`:r.name;n.push(t)}await this.cache.putListing(e,a)}catch(n){t.errors.push({path:e,message:n instanceof Error?n.message:String(n)})}}if(e?.bodies)for(let e of t.changed)try{await this.readFile(e)}catch(n){t.errors.push({path:e,message:n instanceof Error?n.message:String(n)})}return t}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 l=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??26214400,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new t(`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 n=this.toMountRelative(e),r=await this.cache.getBody(n);if(r&&!this.cache.isStale(r.cachedAt))return r.body;let i={};r&&(i[`if-none-match`]=r.etag);let a=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:this.toS3Key(n),headers:i});if(a.status===304&&r)return await this.cache.putBody(n,r.body,r.etag),r.body;if(a.status===404)throw await this.cache.invalidateBody(n),new t(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new t(`EACCES`,`s3 access denied`,e);if(a.status>=400)throw new t(`EIO`,`s3 readFile failed: ${a.status}`,e);let o=a.headers.get(`content-length`),s=o?Number(o):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new t(`EFBIG`,`body exceeds maxBodyBytes (${s} > ${this.maxBodyBytes})`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new t(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=a.headers.get(`etag`)??``;return await this.cache.putBody(n,c,l),c}async writeFile(e,n){this.assertOpen(e);let r=this.toMountRelative(e);if(n.byteLength>this.maxBodyBytes)throw new t(`EFBIG`,`body exceeds maxBodyBytes`,e);let i=await this.cache.getBody(r),a={"content-type":`application/octet-stream`,"content-length":String(n.byteLength)};i?a[`if-match`]=i.etag:a[`if-none-match`]=`*`;let o=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(r),headers:a,body:n}),s,c=1;try{s=await o()}catch{c=2,s=await o()}if(s.status===412){if(c===2){let i=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(r)});if(i.status>=400)throw new t(`EIO`,`s3 reconcile HEAD failed: ${i.status}`,e);let a=i.headers.get(`etag`)??``;await this.cache.putBody(r,n,a);let o=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(r);try{await this.readFile(e)}catch{}throw new t(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(s.status===401||s.status===403)throw new t(`EACCES`,`s3 write denied`,e);if(s.status>=400)throw new t(`EIO`,`s3 writeFile failed: ${s.status}`,e);let l=s.headers.get(`etag`)??``;await this.cache.putBody(r,n,l);let u=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(u)}async listObjectsV2(){let e=[],n;do{let r={"list-type":`2`};this.parsed.prefix&&(r.prefix=`${this.parsed.prefix}/`),n&&(r[`continuation-token`]=n);let i=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:``,query:r});if(i.status>=400)throw new t(`EIO`,`s3 list failed: ${i.status}`,`/`);let a=await i.text(),o=this.parseListingXml(a);e.push(...o.contents),n=o.nextContinuationToken}while(n);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 n=this.toMountRelative(e),r=await this.cache.getBody(n);if(r)return{kind:`file`,size:r.body.byteLength,mtime:r.cachedAt,etag:r.etag};let i=n.split(`/`),a=i.pop()??``,o=i.join(`/`),s=await this.cache.getListing(o);if(s&&!this.cache.isStale(s.cachedAt)){let n=s.entries.find(e=>e.name===a);if(n?.kind===`file`&&n.size!==void 0)return{kind:`file`,size:n.size,mtime:n.lastModified??s.cachedAt,etag:n.etag??``};if(n?.kind===`directory`)return{kind:`directory`,size:0,mtime:n.lastModified??s.cachedAt};if(!n)throw new t(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`);return{kind:`file`,size:e,mtime:n?Date.parse(n):0,etag:t}}if(c.status===404){let r=await this.cache.getListing(n);if(r)return{kind:`directory`,size:0,mtime:r.cachedAt};throw new t(`ENOENT`,`no such file or directory`,e)}throw new t(`EIO`,`s3 stat failed: ${c.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,n){this.assertOpen(e);let r=this.toMountRelative(e);if(n?.recursive)throw new t(`EINVAL`,`recursive remove not yet supported on S3`,e);let i=await this.transport({method:`DELETE`,bucket:this.parsed.bucket,key:this.toS3Key(r)});if(i.status===404)throw new t(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new t(`EACCES`,`s3 delete denied`,e);if(i.status>=400)throw new t(`EIO`,`s3 delete failed: ${i.status}`,e);await this.cache.invalidateBody(r);let a=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a)}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}},u=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function d(){let{getAccounts:e}=await import(`./provider-settings-BHTU6Oq1.js`).then(e=>e.u),t=e().find(e=>e.providerId===`adobe`);if(!t?.accessToken)throw new u(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>t.accessToken}}function f(){return typeof chrome<`u`&&!!chrome?.runtime?.id}function p(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function m(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}const h=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),g=new Set([101,103,204,205,304]);function _(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new t(`EACCES`,e.error):e.errorCode===`invalid_request`?new t(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||h.has(String(e.errorCode))?new t(`EIO`,e.error):new t(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let n;try{n=p(e.bodyBase64)}catch(e){throw new t(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let r=g.has(e.status)?null:n;return new Response(r,{status:e.status,headers:new Headers(e.headers)})}async function v(e,n){let r;try{r=await fetch(e,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(n)})}catch(e){throw new t(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (SLICC backend at localhost may not be running)`)}try{return await r.json()}catch(e){throw new t(`EIO`,`mount transport: response is not a JSON envelope (status ${r.status}): ${e instanceof Error?e.message:String(e)}`)}}async function y(e,n){try{return await chrome.runtime.sendMessage({type:e,envelope:n})}catch(e){throw new t(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (extension service worker not responding)`)}}function b(e){return async t=>{let n={profile:e,method:t.method,bucket:t.bucket,key:t.key,query:t.query,headers:t.headers,bodyBase64:t.body?m(t.body):void 0};return _(f()?await y(`mount.s3-sign-and-forward`,n):await v(`/api/s3-sign-and-forward`,n))}}function x(e){let n=e?.getImsToken??(async()=>(await d()).getBearerToken());return async e=>{let r;try{r=await n()}catch(e){throw new t(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}let i={imsToken:r,method:e.method,path:e.path,query:e.query,headers:e.headers,bodyBase64:e.body?m(e.body):void 0};return _(f()?await y(`mount.da-sign-and-forward`,i):await v(`/api/da-sign-and-forward`,i))}}var S=e({DaMountBackend:()=>s,RemoteMountCache:()=>r,S3MountBackend:()=>l,makeSignedFetchDa:()=>x,makeSignedFetchS3:()=>b});export{s as a,l as i,x as n,b as r,S as t};
@@ -1 +0,0 @@
1
- import{t as e}from"./provider-98CPXvln.js";export{e as readMcpAuthEntries};
@@ -1 +0,0 @@
1
- import{t as e}from"./store-BzwlOEnO.js";import"./provider-uxfYSUeg.js";export{e as readMcpAuthEntries};
@@ -1 +0,0 @@
1
- import{l as e}from"./wc-live-C6fyMRSK.js";export{e as readSessionsIndex};
@@ -1 +0,0 @@
1
- import{g as e,h as t}from"./wc-live-C6fyMRSK.js";export{t as setupSudoExtension,e as setupSudoStandalone};