sliccy 6.131.1 → 6.131.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 (94) hide show
  1. package/dist/ui/.vite/manifest.json +144 -144
  2. package/dist/ui/assets/{account-store-B2fM_hVm.js → account-store-BcQeOBmj.js} +1 -1
  3. package/dist/ui/assets/{account-store-CnTVyV3B.js → account-store-ChQLfZgz.js} +1 -1
  4. package/dist/ui/assets/{adobe-Cwc5x2uv.js → adobe-D10Mg1h_.js} +1 -1
  5. package/dist/ui/assets/{adobe-DDIBiAPC.js → adobe-DEKdi3oD.js} +1 -1
  6. package/dist/ui/assets/{agent-bridge-BNzVNteR.js → agent-bridge-Bvzfs8rB.js} +1 -1
  7. package/dist/ui/assets/{apply-layout-CaZC02vG.js → apply-layout-wFAir12c.js} +1 -1
  8. package/dist/ui/assets/{apps-BKCcSwUS.js → apps-B97sfmxi.js} +1 -1
  9. package/dist/ui/assets/{azure-openai-BbS3zNfN.js → azure-openai-CBu-puRS.js} +1 -1
  10. package/dist/ui/assets/{azure-openai-DS9LetAu.js → azure-openai-DY2D8FBl.js} +1 -1
  11. package/dist/ui/assets/{cerebras-Bl6JS-Zz.js → cerebras-C18SmUxs.js} +1 -1
  12. package/dist/ui/assets/{cerebras-CXTvGhJy.js → cerebras-DRjpuHAs.js} +1 -1
  13. package/dist/ui/assets/{connect-surface-Cga7yA1x.js → connect-surface-DHUhaoge.js} +1 -1
  14. package/dist/ui/assets/{directed-approval-D5JxaPCg.js → directed-approval-fA2Km1F9.js} +1 -1
  15. package/dist/ui/assets/{dist-iMxkf8fm.js → dist-BPZbDBP1.js} +1 -1
  16. package/dist/ui/assets/{dist-DHO9E-gl.js → dist-DOnCyc4g.js} +1 -1
  17. package/dist/ui/assets/{fs-WglxnM0m.js → fs-DWYk-XaG.js} +2 -2
  18. package/dist/ui/assets/{fs-B5l0OgHF.js → fs-DWgVdrZr.js} +1 -1
  19. package/dist/ui/assets/{github-CipnBUW0.js → github-C5jWaC1B.js} +1 -1
  20. package/dist/ui/assets/{github-rNEu9Il2.js → github-D0NGzYdm.js} +2 -2
  21. package/dist/ui/assets/{github-copilot-ByPeJOvj.js → github-copilot-7nHjLcI7.js} +1 -1
  22. package/dist/ui/assets/{github-copilot-CPGYy73b.js → github-copilot-Ci9xf6YE.js} +1 -1
  23. package/dist/ui/assets/{github-install-B7uGR7D1.js → github-install-aoLT8eLh.js} +1 -1
  24. package/dist/ui/assets/{github-zip-CXwGYOT2.js → github-zip-q8IzoiWD.js} +1 -1
  25. package/dist/ui/assets/{help-aOXHqJ8Q.js → help-BDi4nJVZ.js} +1 -1
  26. package/dist/ui/assets/icons-ClfjE6Ij.js +1 -0
  27. package/dist/ui/assets/{js-realm-worker-BNIyA4hZ.js → js-realm-worker-BTzYdudb.js} +1 -1
  28. package/dist/ui/assets/{kernel-worker-_zyksCUm.js → kernel-worker-mpO2ngRI.js} +30 -30
  29. package/dist/ui/assets/{local-llm-DZNM8DQQ.js → local-llm-CQkvkABD.js} +1 -1
  30. package/dist/ui/assets/{local-llm-mXBzcfos.js → local-llm-DOTvMYuW.js} +1 -1
  31. package/dist/ui/assets/{main-B-nfOo4q.js → main-EFFZWAZj.js} +3 -3
  32. package/dist/ui/assets/{mount-B4KSGLVw.js → mount-B9qMwVml.js} +1 -1
  33. package/dist/ui/assets/{mount-Ch4xd9rB.js → mount-DXpXq69M.js} +3 -3
  34. package/dist/ui/assets/{mount-recovery-Di7nIeaF.js → mount-recovery-DwetnkcN.js} +1 -1
  35. package/dist/ui/assets/{new-session-ClnfXCAZ.js → new-session-D3H9k43E.js} +2 -2
  36. package/dist/ui/assets/{oauth-bootstrap-DESksVSP.js → oauth-bootstrap-BZdvwVda.js} +2 -2
  37. package/dist/ui/assets/{openai-codex-nfIOpXSu.js → openai-codex-BGFoQXPR.js} +1 -1
  38. package/dist/ui/assets/{openai-codex-ByROFNSi.js → openai-codex-CqCN43Vp.js} +1 -1
  39. package/dist/ui/assets/{openrouter-CqAv3VZj.js → openrouter-CyO_8clr.js} +1 -1
  40. package/dist/ui/assets/{openrouter-BfHAZQmK.js → openrouter-CyuFwjSD.js} +1 -1
  41. package/dist/ui/assets/{openrouter-oauth-DQITUCdi.js → openrouter-oauth-Bl5DUyyK.js} +1 -1
  42. package/dist/ui/assets/{openrouter-oauth-BoC1y3uz.js → openrouter-oauth-ukqAIszR.js} +1 -1
  43. package/dist/ui/assets/{panel-rpc-handlers-B6r8KSY4.js → panel-rpc-handlers-q48hKE-j.js} +2 -2
  44. package/dist/ui/assets/{panelize-shell-KNX1XTnq.js → panelize-shell-n4cz4LHX.js} +1 -1
  45. package/dist/ui/assets/{provider-CuvQQp10.js → provider-BJTW8Inb.js} +2 -2
  46. package/dist/ui/assets/{provider-NGK7XrJs.js → provider-BiFOaUnO.js} +1 -1
  47. package/dist/ui/assets/provider-settings-D3GCdjWv.js +1 -0
  48. package/dist/ui/assets/{provider-settings-C_7ia6Wg.js → provider-settings-DxvegOPb.js} +1 -1
  49. package/dist/ui/assets/{provider-store-access-CMt1lgF6.js → provider-store-access-P8QylrtO.js} +2 -2
  50. package/dist/ui/assets/provider-store-access-tUb6KDi9.js +1 -0
  51. package/dist/ui/assets/{providers-Cc4NoSCd.js → providers-BvcoVwoV.js} +2 -2
  52. package/dist/ui/assets/{providers-CtPlPUAl.js → providers-nRNq_HqB.js} +1 -1
  53. package/dist/ui/assets/{quick-llm-By0alwjq.js → quick-llm-vmNyLwWF.js} +1 -1
  54. package/dist/ui/assets/{recovery-screen-Cr55gwtB.js → recovery-screen-D3feoocF.js} +1 -1
  55. package/dist/ui/assets/{run-Bf9B4QDH.js → run-CAXyjr03.js} +2 -2
  56. package/dist/ui/assets/{run-Bub_JJ9Q.js → run-D5UZFh8p.js} +1 -1
  57. package/dist/ui/assets/{run-mzRo2_pR.js → run-R83PHioW.js} +1 -1
  58. package/dist/ui/assets/{session-freezer-FCAjtzB9.js → session-freezer-ChfPSkjG.js} +3 -3
  59. package/dist/ui/assets/{setup-feature-flags-remote-AO0av6y4.js → setup-feature-flags-remote-B7YsGX1C.js} +1 -1
  60. package/dist/ui/assets/{setup-standalone-prelude-C-gDZsJ6.js → setup-standalone-prelude-DMtkl-2o.js} +1 -1
  61. package/dist/ui/assets/{setup-sudo-CyDP6flA.js → setup-sudo-BbqNoR1S.js} +2 -2
  62. package/dist/ui/assets/{skills-CoT8PzSA.js → skills-BkBm2fAz.js} +1 -1
  63. package/dist/ui/assets/slicc-version-B55cSOI0.js +1 -0
  64. package/dist/ui/assets/{snapshot-C26Hnrzl.js → snapshot-CLXWXjqM.js} +1 -1
  65. package/dist/ui/assets/{snapshot-features-DMqvwv22.js → snapshot-features-qD3Jv7eK.js} +1 -1
  66. package/dist/ui/assets/{src-Bex_z_yH.js → src-CWTsG5Zz.js} +1 -1
  67. package/dist/ui/assets/{state-DihPwc0x.js → state-Du90LXhH.js} +1 -1
  68. package/dist/ui/assets/{store-BFQaIUNf.js → store-BW6jwedj.js} +1 -1
  69. package/dist/ui/assets/{store-jCHEXPsn.js → store-G_IzwEbI.js} +1 -1
  70. package/dist/ui/assets/{sudo-DV79W8d_.js → sudo-CiGYbddr.js} +1 -1
  71. package/dist/ui/assets/{sync-dialog-D7Wg49Up.js → sync-dialog-Bpp9Sloe.js} +1 -1
  72. package/dist/ui/assets/{upgrade-detection-DS0TnOrq.js → upgrade-detection-qaPo2iNP.js} +1 -1
  73. package/dist/ui/assets/{wc-attach-BbT2famN.js → wc-attach-Bmy0D7zx.js} +2 -2
  74. package/dist/ui/assets/{wc-extension-NZBjLMIl.js → wc-extension-HpEFmEaM.js} +2 -2
  75. package/dist/ui/assets/{wc-float-label-CnFnKVLC.js → wc-float-label-D-EfJUCy.js} +1 -1
  76. package/dist/ui/assets/{wc-follower-BdUaqkeK.js → wc-follower-CaCmbsFC.js} +3 -3
  77. package/dist/ui/assets/{wc-live-Doom1Cuk.js → wc-live-nJl674nq.js} +3 -3
  78. package/dist/ui/assets/{wc-nav-DX0vhaA2.js → wc-nav-Bnfi20v0.js} +2 -2
  79. package/dist/ui/assets/{wc-onboarding-DWR8Cofn.js → wc-onboarding-yJakorfA.js} +2 -2
  80. package/dist/ui/assets/{wc-placeholder-EhKkP8p0.js → wc-placeholder-BIs0O5Tv.js} +2 -2
  81. package/dist/ui/assets/{wc-settings-D_ym_qw0.js → wc-settings-C4sBkTAZ.js} +2 -2
  82. package/dist/ui/assets/{wc-shell-p7cHxhJQ.js → wc-shell-D0eljkIj.js} +3 -3
  83. package/dist/ui/assets/{wc-sprinkles-Bm5U1hNI.js → wc-sprinkles-Dxi8ZWGE.js} +2 -2
  84. package/dist/ui/assets/{wc-tray-DL-rVcIK.js → wc-tray-bViGindn.js} +4 -4
  85. package/dist/ui/assets/{xai-grok-DbCJs1Ps.js → xai-grok-BfUF5UgI.js} +1 -1
  86. package/dist/ui/assets/{xai-grok-QZxyqlOs.js → xai-grok-BxzPJBhW.js} +1 -1
  87. package/dist/ui/index.html +6 -6
  88. package/dist/ui/lucide-icons.js +190 -186
  89. package/dist/ui/packages/webapp/index.html +6 -6
  90. package/package.json +2 -2
  91. package/dist/ui/assets/icons-BJsliYCh.js +0 -1
  92. package/dist/ui/assets/provider-settings-s-43s4y0.js +0 -1
  93. package/dist/ui/assets/provider-store-access-BLtf32eE.js +0 -1
  94. package/dist/ui/assets/slicc-version-C11usX8a.js +0 -1
@@ -1,2 +1,2 @@
1
- import{b as e}from"./account-store-B2fM_hVm.js";import{a as t}from"./diagnostics-DN_idNHx.js";import{u as n}from"./claude-model-version-BJLrDjmH.js";import{r,s as i}from"./legacy-api-aliases-45zvHmpJ.js";import{t as a}from"./logger-DDBAeTLF.js";var o=a(`local-llm`),s=`local-llm`,c=`local`,l=`${s}-unconfigured`,u={id:s,name:`Local LLM (OpenAI-compatible)`,description:[`Connect to any OpenAI-compatible local model server.`,``,`Common base URLs:`,` • Ollama http://localhost:11434/v1`,` • LM Studio http://localhost:1234/v1`,` • llama.cpp http://localhost:8080/v1`,` • vLLM http://localhost:8000/v1`,` • mlx_lm http://localhost:8080/v1`,` • Jan http://localhost:1337/v1`,``,`Ollama needs OLLAMA_ORIGINS=* (or chrome-extension://*) so the`,`browser can reach it. macOS: launchctl setenv OLLAMA_ORIGINS "*".`].join(`
1
+ import{b as e}from"./account-store-BcQeOBmj.js";import{a as t}from"./diagnostics-DN_idNHx.js";import{u as n}from"./claude-model-version-BJLrDjmH.js";import{r,s as i}from"./legacy-api-aliases-45zvHmpJ.js";import{t as a}from"./logger-DDBAeTLF.js";var o=a(`local-llm`),s=`local-llm`,c=`local`,l=`${s}-unconfigured`,u={id:s,name:`Local LLM (OpenAI-compatible)`,description:[`Connect to any OpenAI-compatible local model server.`,``,`Common base URLs:`,` • Ollama http://localhost:11434/v1`,` • LM Studio http://localhost:1234/v1`,` • llama.cpp http://localhost:8080/v1`,` • vLLM http://localhost:8000/v1`,` • mlx_lm http://localhost:8080/v1`,` • Jan http://localhost:1337/v1`,``,`Ollama needs OLLAMA_ORIGINS=* (or chrome-extension://*) so the`,`browser can reach it. macOS: launchctl setenv OLLAMA_ORIGINS "*".`].join(`
2
2
  `),requiresApiKey:!1,optionalApiKey:!0,apiKeyPlaceholder:`Leave empty for local servers, or paste a key for hosted endpoints`,apiKeyEnvVar:`LOCAL_LLM_API_KEY`,requiresBaseUrl:!0,baseUrlPlaceholder:`http://localhost:11434/v1`,baseUrlDescription:`Ollama: 11434 • LM Studio: 1234 • llama.cpp/mlx: 8080 • vLLM: 8000 • Jan: 1337. Trailing /v1 required.`,requiresDeployment:!0,deploymentPlaceholder:`llama3.1:8b, qwen2.5-coder:14b`,deploymentDescription:`Comma-separated model IDs from your server. List them with: curl <baseUrl>/models | jq -r .data[].id`,getModelIds:()=>{let t=d(e(s));return t.length===0?[{id:l,name:`Local LLM (set base URL + model IDs in Settings)`,api:`openai`}]:t.map(e=>({id:e,name:e,api:`openai`,input:[`text`],context_window:32e3,max_tokens:4096}))}};function d(e){return e?e.split(`,`).map(e=>e.trim()).filter(Boolean):[]}var f=`openai-completions`,p=`${s}-openai`;function m(e){return{...e,api:f}}function h(e){let t=e??{};return!t.apiKey||t.apiKey.length===0?{...t,apiKey:c}:t}var g=(e,t,n={})=>e.id===l?v(e,`Local LLM is not configured. Set base URL and model IDs in Settings.`):e.baseUrl?r(m(e),t,h(n)):v(e,`Local LLM base URL is required (e.g. http://localhost:11434/v1).`),_=(e,t,n)=>e.id===l?v(e,`Local LLM is not configured. Set base URL and model IDs in Settings.`):e.baseUrl?i(m(e),t,h(n)):v(e,`Local LLM base URL is required (e.g. http://localhost:11434/v1).`);function v(e,n){let r=t(),i={role:`assistant`,content:[],api:e.api,provider:e.provider,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:n,timestamp:Date.now()};return queueMicrotask(()=>{r.push({type:`error`,reason:`error`,error:i}),r.end()}),r}function y(){n({api:p,stream:g,streamSimple:_})}function b(e){return typeof e==`object`&&!!e&&`object`in e&&e.object===`list`}function x(e){return typeof e==`object`&&!!e&&`build_info`in e}function S(e){try{let t=new URL(e);return`${t.protocol}//${t.host}`}catch{return e.replace(/\/v1\/?$/,``).replace(/\/+$/,``)}}function C(e){let t=e.replace(/\/+$/,``);try{let e=new URL(t);if(e.pathname===``||e.pathname===`/`)return`${t}/v1`}catch{}return t}async function w(e,t,n){let r=`${C(e)}/models`,i={Accept:`application/json`};t&&t.length>0&&(i.Authorization=`Bearer ${t}`);let a=await fetch(r,{method:`GET`,headers:i,signal:n});if(!a.ok)throw Error(`GET ${r} -> ${a.status} ${a.statusText}`);let o=await a.json();return Array.isArray(o.data)?o.data.map(e=>e.id??``).filter(e=>e.length>0):[]}async function T(e,t){let n=S(e),r=await D(`${n}/api/version`,t);if(r&&typeof r.version==`string`)return{kind:`ollama`,version:r.version};if(b(await D(`${n}/api/v0/models`,t)))return{kind:`lmstudio`};let i=await D(`${n}/props`,t);if(x(i))return{kind:`llamacpp`,version:i.build_info?.version};let a=E(e);return a===`11434`?{kind:`ollama`}:a===`1234`?{kind:`lmstudio`}:a===`8000`?{kind:`vllm`}:a===`1337`?{kind:`jan`}:{kind:`unknown`}}function E(e){try{return new URL(e).port||null}catch{return null}}async function D(e,t){try{let n=await fetch(e,{method:`GET`,signal:t});return n.ok?await n.json():null}catch{return null}}async function O(e,t,n){let r={kind:`unknown`};try{r=await T(e,n)}catch{}try{let i=await w(e,t,n);return{ok:!0,runtime:r,models:i}}catch(t){let n=t instanceof Error?t.message:String(t),i=k(n,r.kind);return o.warn(`verifyConnection failed`,{baseUrl:e,runtime:r.kind,message:n}),{ok:!1,runtime:r,models:[],error:i}}}function k(e,t){let n=e.toLowerCase();return n.includes(`failed to fetch`)||n.includes(`networkerror`)?t===`ollama`?{kind:`cors`,message:e,hint:'Ollama rejects requests from non-localhost origins by default. Set OLLAMA_ORIGINS=* (or chrome-extension://*) and restart Ollama. macOS: `launchctl setenv OLLAMA_ORIGINS "*"` then quit and relaunch the Ollama app.'}:{kind:`connection`,message:e,hint:`Server unreachable. Check the URL and that the server is running.`}:n.includes(` 401`)||n.includes(` 403`)?{kind:`auth`,message:e,hint:`Server returned an auth error. If your endpoint requires a key, set it in Settings.`}:/-> \d{3} /.test(e)?{kind:`http`,message:e}:{kind:`unknown`,message:e}}export{u as config,T as detectRuntime,w as discoverModels,S as originOf,y as register,O as verifyConnection};
@@ -1,2 +1,2 @@
1
- import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./logger-LESFN7Hj.js";import{s as n}from"./account-store-CnTVyV3B.js";import{a as r}from"./diagnostics-DN_idNHx.js";import{a as i}from"./compat-uEPf6-XW.js";import{r as a,s as o}from"./legacy-api-aliases-jKEvBgOL.js";var s=e({config:()=>d,detectRuntime:()=>T,discoverModels:()=>w,originOf:()=>S,register:()=>y,verifyConnection:()=>O});const c=t(`local-llm`),l=`local-llm`,u=`${l}-unconfigured`,d={id:l,name:`Local LLM (OpenAI-compatible)`,description:[`Connect to any OpenAI-compatible local model server.`,``,`Common base URLs:`,` • Ollama http://localhost:11434/v1`,` • LM Studio http://localhost:1234/v1`,` • llama.cpp http://localhost:8080/v1`,` • vLLM http://localhost:8000/v1`,` • mlx_lm http://localhost:8080/v1`,` • Jan http://localhost:1337/v1`,``,`Ollama needs OLLAMA_ORIGINS=* (or chrome-extension://*) so the`,`browser can reach it. macOS: launchctl setenv OLLAMA_ORIGINS "*".`].join(`
1
+ import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./logger-LESFN7Hj.js";import{s as n}from"./account-store-ChQLfZgz.js";import{a as r}from"./diagnostics-DN_idNHx.js";import{a as i}from"./compat-uEPf6-XW.js";import{r as a,s as o}from"./legacy-api-aliases-jKEvBgOL.js";var s=e({config:()=>d,detectRuntime:()=>T,discoverModels:()=>w,originOf:()=>S,register:()=>y,verifyConnection:()=>O});const c=t(`local-llm`),l=`local-llm`,u=`${l}-unconfigured`,d={id:l,name:`Local LLM (OpenAI-compatible)`,description:[`Connect to any OpenAI-compatible local model server.`,``,`Common base URLs:`,` • Ollama http://localhost:11434/v1`,` • LM Studio http://localhost:1234/v1`,` • llama.cpp http://localhost:8080/v1`,` • vLLM http://localhost:8000/v1`,` • mlx_lm http://localhost:8080/v1`,` • Jan http://localhost:1337/v1`,``,`Ollama needs OLLAMA_ORIGINS=* (or chrome-extension://*) so the`,`browser can reach it. macOS: launchctl setenv OLLAMA_ORIGINS "*".`].join(`
2
2
  `),requiresApiKey:!1,optionalApiKey:!0,apiKeyPlaceholder:`Leave empty for local servers, or paste a key for hosted endpoints`,apiKeyEnvVar:`LOCAL_LLM_API_KEY`,requiresBaseUrl:!0,baseUrlPlaceholder:`http://localhost:11434/v1`,baseUrlDescription:`Ollama: 11434 • LM Studio: 1234 • llama.cpp/mlx: 8080 • vLLM: 8000 • Jan: 1337. Trailing /v1 required.`,requiresDeployment:!0,deploymentPlaceholder:`llama3.1:8b, qwen2.5-coder:14b`,deploymentDescription:`Comma-separated model IDs from your server. List them with: curl <baseUrl>/models | jq -r .data[].id`,getModelIds:()=>{let e=f(n(l));return e.length===0?[{id:u,name:`Local LLM (set base URL + model IDs in Settings)`,api:`openai`}]:e.map(e=>({id:e,name:e,api:`openai`,input:[`text`],context_window:32e3,max_tokens:4096}))}};function f(e){return e?e.split(`,`).map(e=>e.trim()).filter(Boolean):[]}const p=`${l}-openai`;function m(e){return{...e,api:`openai-completions`}}function h(e){let t=e??{};return!t.apiKey||t.apiKey.length===0?{...t,apiKey:`local`}:t}const g=(e,t,n={})=>e.id===u?v(e,`Local LLM is not configured. Set base URL and model IDs in Settings.`):e.baseUrl?a(m(e),t,h(n)):v(e,`Local LLM base URL is required (e.g. http://localhost:11434/v1).`),_=(e,t,n)=>e.id===u?v(e,`Local LLM is not configured. Set base URL and model IDs in Settings.`):e.baseUrl?o(m(e),t,h(n)):v(e,`Local LLM base URL is required (e.g. http://localhost:11434/v1).`);function v(e,t){let n=r(),i={role:`assistant`,content:[],api:e.api,provider:e.provider,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,timestamp:Date.now()};return queueMicrotask(()=>{n.push({type:`error`,reason:`error`,error:i}),n.end()}),n}function y(){i({api:p,stream:g,streamSimple:_})}function b(e){return typeof e==`object`&&!!e&&`object`in e&&e.object===`list`}function x(e){return typeof e==`object`&&!!e&&`build_info`in e}function S(e){try{let t=new URL(e);return`${t.protocol}//${t.host}`}catch{return e.replace(/\/v1\/?$/,``).replace(/\/+$/,``)}}function C(e){let t=e.replace(/\/+$/,``);try{let e=new URL(t);if(e.pathname===``||e.pathname===`/`)return`${t}/v1`}catch{}return t}async function w(e,t,n){let r=`${C(e)}/models`,i={Accept:`application/json`};t&&t.length>0&&(i.Authorization=`Bearer ${t}`);let a=await fetch(r,{method:`GET`,headers:i,signal:n});if(!a.ok)throw Error(`GET ${r} -> ${a.status} ${a.statusText}`);let o=await a.json();return Array.isArray(o.data)?o.data.map(e=>e.id??``).filter(e=>e.length>0):[]}async function T(e,t){let n=S(e),r=await D(`${n}/api/version`,t);if(r&&typeof r.version==`string`)return{kind:`ollama`,version:r.version};if(b(await D(`${n}/api/v0/models`,t)))return{kind:`lmstudio`};let i=await D(`${n}/props`,t);if(x(i))return{kind:`llamacpp`,version:i.build_info?.version};let a=E(e);return a===`11434`?{kind:`ollama`}:a===`1234`?{kind:`lmstudio`}:a===`8000`?{kind:`vllm`}:a===`1337`?{kind:`jan`}:{kind:`unknown`}}function E(e){try{return new URL(e).port||null}catch{return null}}async function D(e,t){try{let n=await fetch(e,{method:`GET`,signal:t});return n.ok?await n.json():null}catch{return null}}async function O(e,t,n){let r={kind:`unknown`};try{r=await T(e,n)}catch{}try{let i=await w(e,t,n);return{ok:!0,runtime:r,models:i}}catch(t){let n=t instanceof Error?t.message:String(t),i=k(n,r.kind);return c.warn(`verifyConnection failed`,{baseUrl:e,runtime:r.kind,message:n}),{ok:!1,runtime:r,models:[],error:i}}}function k(e,t){let n=e.toLowerCase();return n.includes(`failed to fetch`)||n.includes(`networkerror`)?t===`ollama`?{kind:`cors`,message:e,hint:'Ollama rejects requests from non-localhost origins by default. Set OLLAMA_ORIGINS=* (or chrome-extension://*) and restart Ollama. macOS: `launchctl setenv OLLAMA_ORIGINS "*"` then quit and relaunch the Ollama app.'}:{kind:`connection`,message:e,hint:`Server unreachable. Check the URL and that the server is running.`}:n.includes(` 401`)||n.includes(` 403`)?{kind:`auth`,message:e,hint:`Server returned an auth error. If your endpoint requires a key, set it in Settings.`}:/-> \d{3} /.test(e)?{kind:`http`,message:e}:{kind:`unknown`,message:e}}export{s as n,d as t};
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/setup-feature-flags-remote-AO0av6y4.js","assets/tray-runtime-config-BQL-GPqt.js","assets/bridge-protocol-06nbmp2X.js","assets/proxied-fetch-CiijUcSt.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/preload-helper-Czpn1I53.js","assets/base64-DJRlyqZu.js","assets/fetch-body-D2PwksUW.js","assets/api-endpoint-DGxXvrur.js","assets/runtime-env-Dlaokqg1.js","assets/messages-BD4p8GuF.js","assets/feature-flags-DaSRRz0w.js","assets/wc-shell-p7cHxhJQ.js","assets/logger-DDBAeTLF.js","assets/agent-message-to-chat-Df4an5Ei.js","assets/image-markers-BFDmhPy4.js","assets/mime-types-D0xZwlMO.js","assets/telemetry-MJ77Fp1a.js","assets/icons-BJsliYCh.js","assets/preview-url-r19H6zH1.js","assets/dictation-priming-CNllGgNq.js","assets/timestamp-preference-sKwBl5I8.js","assets/src-Bex_z_yH.js","assets/speech-C5U8h4In.js","assets/soundscape-cues-5_sT5Un6.js","assets/panel-registry-CJdOibpf.js","assets/layout-schema-m9_VAwOw.js","assets/surface-fullscreen-4YjALjE7.js","assets/trusted-layer-ghPA1ENf.js","assets/wc-shortcuts-BDQiHczD.js","assets/wc-shell-WkeczD9x.css","assets/wc-follower-BdUaqkeK.js","assets/setup-standalone-prelude-C-gDZsJ6.js","assets/setup-sudo-CyDP6flA.js","assets/transcript-export-DP-r8eDz.js","assets/wc-live-Doom1Cuk.js","assets/account-store-B2fM_hVm.js","assets/claude-model-version-BJLrDjmH.js","assets/models-BSkXF4T6.js","assets/diagnostics-DN_idNHx.js","assets/provider-env-CTOcDKrQ.js","assets/__vite-browser-external-5eBdwsFd.js","assets/openrouter.models-B-zmcypy.js","assets/libesm-BypnjKEL.js","assets/float-topology-hfgMx1Yq.js","assets/secret-topology-Yt0aO4Gz.js","assets/secrets-bridge-client-BVl0YuB2.js","assets/port-bridge-client-C1tBBqwu.js","assets/tool-ui-eSQ1g2I1.js","assets/providers-Cc4NoSCd.js","assets/panel-rpc-B3MSVImO.js","assets/bedrock-camp-compat-CgBMwna8.js","assets/tray-follower-status-BAjnN7Ar.js","assets/src-BWaKqLvQ.js","assets/chat-session-store-pWb1-jNp.js","assets/tray-leader-DabyaEs-.js","assets/db-cKsBsMMN.js","assets/record-DOq72weu.js","assets/shared-Djytys1b.js","assets/export-provider-CqI0pk50.js","assets/dip-1TiuHkUR.js","assets/sprinkle-renderer-BnSqYzuY.js","assets/theme-CXRqxpw6.js","assets/theme-engine-By4GU_Wc.js","assets/permissions-surface-registry-CilCRwhh.js","assets/hid-device-registry-B2R-0rNt.js","assets/serial-port-registry-CCqklAEr.js","assets/usb-operations-BBXJ4GF8.js","assets/usb-device-registry-CRsCisej.js","assets/sprinkle-bridge-BNzhEsPj.js","assets/session-freezer-FCAjtzB9.js","assets/types-Dgm4REV3.js","assets/follower-presentation-DqBw0YiV.js","assets/wc-unit-context-1szdc5sL.js","assets/host-command-29ain4NA.js","assets/browser-DGwroBSO.js","assets/agent-handle-CNeA3sd0.js","assets/wc-float-label-CnFnKVLC.js","assets/tray-sync-protocol-jKTx-dCF.js","assets/wc-follower-oauth-B6m2XpVI.js","assets/slicc-app-url-B9OxaBDe.js","assets/tray-webrtc-uW6sTyIA.js","assets/pending-request-table-Dgn6qYdL.js","assets/export-spool-CuNzzI8a.js","assets/wc-sprinkles-Bm5U1hNI.js","assets/wc-attach-BbT2famN.js","assets/wc-permissions-CppSymRx.js","assets/oauth-bootstrap-DESksVSP.js","assets/provider-settings-C_7ia6Wg.js","assets/clipboard-eqmn97SP.js","assets/tray-join-url-BIvzbiFR.js","assets/logger-BoSvu4mW.js","assets/legacy-styles-B3nS5QUo.js","assets/connect-surface-Cga7yA1x.js","assets/wc-extension-NZBjLMIl.js","assets/wc-detached-B3WCbbZT.js"])))=>i.map(i=>d[i]);
2
- import"./modulepreload-polyfill-P2Xu9kJm.js";import{a as e}from"./account-store-B2fM_hVm.js";import{t}from"./preload-helper-Czpn1I53.js";import{t as n}from"./logger-DDBAeTLF.js";import{c as r,o as i,s as a,t as o}from"./setup-standalone-prelude-C-gDZsJ6.js";import{n as s,t as c}from"./runtime-env-Dlaokqg1.js";import{t as l}from"./telemetry-MJ77Fp1a.js";import{a as u}from"./providers-Cc4NoSCd.js";import{n as d}from"./feature-flags-DaSRRz0w.js";import"./provider-settings-C_7ia6Wg.js";var f=`slicc:bridge-config`,p=`slicc:extension-delegate-config`;function m(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.type===`slicc:ext-fetch`&&typeof t.extensionId==`string`&&!!t.request&&typeof t.request==`object`}var h=n(`boot/ext-fetch-delegate`);function g(){let e=globalThis.chrome?.runtime;return e&&typeof e.connect==`function`?e:null}function _(e,t,n){let r=g();if(!r){try{t.postMessage({type:`response-error`,error:`extension-delegate: chrome.runtime.connect unavailable`})}catch{}t.close();return}let i=e.extensionId||n,a;try{a=r.connect(i,{name:`fetch-proxy.fetch`})}catch(e){try{t.postMessage({type:`response-error`,error:`extension-delegate: connect failed — ${e instanceof Error?e.message:String(e)}`})}catch{}t.close();return}let o=!1,s=()=>{o=!0;try{a.disconnect()}catch{}try{t.close()}catch{}};a.onMessage.addListener(e=>{if(o)return;let n=e;try{t.postMessage(n)}catch{}(n.type===`response-end`||n.type===`response-error`)&&s()}),a.onDisconnect.addListener(()=>{if(!o){try{t.postMessage({type:`response-error`,error:`extension-delegate: fetch-proxy port disconnected`})}catch{}s()}}),a.postMessage({type:`request`,...e.request})}function v(e){typeof navigator>`u`||!navigator.serviceWorker||navigator.serviceWorker.addEventListener(`message`,t=>{if(!m(t.data))return;let n=t.ports?.[0];if(!n){h.warn(`delegated fetch envelope arrived without a response port`);return}_(t.data,n,e)})}var y=`slicc_feature_flags_remote`;function b(e){return`${y}:${e}`}function x(e,t){let n=C(t);d(e,w(n,e)??{})}function S(e,t,n){try{e?.setItem(b(t),JSON.stringify(n))}catch{}}function C(e){if(e!==void 0)return e;try{let e=globalThis.localStorage;return typeof e?.getItem!=`function`||typeof e.setItem!=`function`?void 0:e}catch{return}}function w(e,t){try{let n=e?.getItem(b(t));return n?T(JSON.parse(n)):null}catch{return null}}function T(e){return!E(e)||Object.values(e).some(e=>typeof e!=`string`)?null:e}function E(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function D(e,n){x(e,n.storage),t(async()=>{let{refreshFeatureFlagsForPage:e}=await import(`./setup-feature-flags-remote-AO0av6y4.js`);return{refreshFeatureFlagsForPage:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])).then(({refreshFeatureFlagsForPage:t})=>t(e,n)).catch(()=>{})}function O(e){let t=a(e.locationHref,e.isExtension,e.storage);return D(t,e),t}function k(){if(s())return;let e=new Blob([`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/setup-feature-flags-remote-B7YsGX1C.js","assets/tray-runtime-config-BQL-GPqt.js","assets/bridge-protocol-06nbmp2X.js","assets/proxied-fetch-CiijUcSt.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/preload-helper-Czpn1I53.js","assets/base64-DJRlyqZu.js","assets/fetch-body-D2PwksUW.js","assets/api-endpoint-DGxXvrur.js","assets/runtime-env-Dlaokqg1.js","assets/messages-BD4p8GuF.js","assets/feature-flags-DaSRRz0w.js","assets/wc-shell-D0eljkIj.js","assets/logger-DDBAeTLF.js","assets/agent-message-to-chat-Df4an5Ei.js","assets/image-markers-BFDmhPy4.js","assets/mime-types-D0xZwlMO.js","assets/telemetry-MJ77Fp1a.js","assets/icons-ClfjE6Ij.js","assets/preview-url-r19H6zH1.js","assets/dictation-priming-CNllGgNq.js","assets/timestamp-preference-sKwBl5I8.js","assets/src-CWTsG5Zz.js","assets/speech-C5U8h4In.js","assets/soundscape-cues-5_sT5Un6.js","assets/panel-registry-CJdOibpf.js","assets/layout-schema-m9_VAwOw.js","assets/surface-fullscreen-4YjALjE7.js","assets/trusted-layer-ghPA1ENf.js","assets/wc-shortcuts-BDQiHczD.js","assets/wc-shell-WkeczD9x.css","assets/wc-follower-CaCmbsFC.js","assets/setup-standalone-prelude-DMtkl-2o.js","assets/setup-sudo-BbqNoR1S.js","assets/transcript-export-DP-r8eDz.js","assets/wc-live-nJl674nq.js","assets/account-store-BcQeOBmj.js","assets/claude-model-version-BJLrDjmH.js","assets/models-BSkXF4T6.js","assets/diagnostics-DN_idNHx.js","assets/provider-env-CTOcDKrQ.js","assets/__vite-browser-external-5eBdwsFd.js","assets/openrouter.models-B-zmcypy.js","assets/libesm-BypnjKEL.js","assets/float-topology-hfgMx1Yq.js","assets/secret-topology-Yt0aO4Gz.js","assets/secrets-bridge-client-BVl0YuB2.js","assets/port-bridge-client-C1tBBqwu.js","assets/tool-ui-eSQ1g2I1.js","assets/providers-BvcoVwoV.js","assets/panel-rpc-B3MSVImO.js","assets/bedrock-camp-compat-CgBMwna8.js","assets/tray-follower-status-BAjnN7Ar.js","assets/src-BWaKqLvQ.js","assets/chat-session-store-pWb1-jNp.js","assets/tray-leader-DabyaEs-.js","assets/db-cKsBsMMN.js","assets/record-DOq72weu.js","assets/shared-Djytys1b.js","assets/export-provider-CqI0pk50.js","assets/dip-1TiuHkUR.js","assets/sprinkle-renderer-BnSqYzuY.js","assets/theme-CXRqxpw6.js","assets/theme-engine-By4GU_Wc.js","assets/permissions-surface-registry-CilCRwhh.js","assets/hid-device-registry-B2R-0rNt.js","assets/serial-port-registry-CCqklAEr.js","assets/usb-operations-BBXJ4GF8.js","assets/usb-device-registry-CRsCisej.js","assets/sprinkle-bridge-BNzhEsPj.js","assets/session-freezer-ChfPSkjG.js","assets/types-Dgm4REV3.js","assets/follower-presentation-DqBw0YiV.js","assets/wc-unit-context-1szdc5sL.js","assets/host-command-29ain4NA.js","assets/browser-DGwroBSO.js","assets/agent-handle-CNeA3sd0.js","assets/wc-float-label-D-EfJUCy.js","assets/tray-sync-protocol-jKTx-dCF.js","assets/wc-follower-oauth-B6m2XpVI.js","assets/slicc-app-url-B9OxaBDe.js","assets/tray-webrtc-uW6sTyIA.js","assets/pending-request-table-Dgn6qYdL.js","assets/export-spool-CuNzzI8a.js","assets/wc-sprinkles-Dxi8ZWGE.js","assets/wc-attach-Bmy0D7zx.js","assets/wc-permissions-CppSymRx.js","assets/oauth-bootstrap-BZdvwVda.js","assets/provider-settings-DxvegOPb.js","assets/clipboard-eqmn97SP.js","assets/tray-join-url-BIvzbiFR.js","assets/logger-BoSvu4mW.js","assets/legacy-styles-B3nS5QUo.js","assets/connect-surface-DHUhaoge.js","assets/wc-extension-HpEFmEaM.js","assets/wc-detached-B3WCbbZT.js"])))=>i.map(i=>d[i]);
2
+ import"./modulepreload-polyfill-P2Xu9kJm.js";import{a as e}from"./account-store-BcQeOBmj.js";import{t}from"./preload-helper-Czpn1I53.js";import{t as n}from"./logger-DDBAeTLF.js";import{c as r,o as i,s as a,t as o}from"./setup-standalone-prelude-DMtkl-2o.js";import{n as s,t as c}from"./runtime-env-Dlaokqg1.js";import{t as l}from"./telemetry-MJ77Fp1a.js";import{a as u}from"./providers-BvcoVwoV.js";import{n as d}from"./feature-flags-DaSRRz0w.js";import"./provider-settings-DxvegOPb.js";var f=`slicc:bridge-config`,p=`slicc:extension-delegate-config`;function m(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.type===`slicc:ext-fetch`&&typeof t.extensionId==`string`&&!!t.request&&typeof t.request==`object`}var h=n(`boot/ext-fetch-delegate`);function g(){let e=globalThis.chrome?.runtime;return e&&typeof e.connect==`function`?e:null}function _(e,t,n){let r=g();if(!r){try{t.postMessage({type:`response-error`,error:`extension-delegate: chrome.runtime.connect unavailable`})}catch{}t.close();return}let i=e.extensionId||n,a;try{a=r.connect(i,{name:`fetch-proxy.fetch`})}catch(e){try{t.postMessage({type:`response-error`,error:`extension-delegate: connect failed — ${e instanceof Error?e.message:String(e)}`})}catch{}t.close();return}let o=!1,s=()=>{o=!0;try{a.disconnect()}catch{}try{t.close()}catch{}};a.onMessage.addListener(e=>{if(o)return;let n=e;try{t.postMessage(n)}catch{}(n.type===`response-end`||n.type===`response-error`)&&s()}),a.onDisconnect.addListener(()=>{if(!o){try{t.postMessage({type:`response-error`,error:`extension-delegate: fetch-proxy port disconnected`})}catch{}s()}}),a.postMessage({type:`request`,...e.request})}function v(e){typeof navigator>`u`||!navigator.serviceWorker||navigator.serviceWorker.addEventListener(`message`,t=>{if(!m(t.data))return;let n=t.ports?.[0];if(!n){h.warn(`delegated fetch envelope arrived without a response port`);return}_(t.data,n,e)})}var y=`slicc_feature_flags_remote`;function b(e){return`${y}:${e}`}function x(e,t){let n=C(t);d(e,w(n,e)??{})}function S(e,t,n){try{e?.setItem(b(t),JSON.stringify(n))}catch{}}function C(e){if(e!==void 0)return e;try{let e=globalThis.localStorage;return typeof e?.getItem!=`function`||typeof e.setItem!=`function`?void 0:e}catch{return}}function w(e,t){try{let n=e?.getItem(b(t));return n?T(JSON.parse(n)):null}catch{return null}}function T(e){return!E(e)||Object.values(e).some(e=>typeof e!=`string`)?null:e}function E(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function D(e,n){x(e,n.storage),t(async()=>{let{refreshFeatureFlagsForPage:e}=await import(`./setup-feature-flags-remote-B7YsGX1C.js`);return{refreshFeatureFlagsForPage:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])).then(({refreshFeatureFlagsForPage:t})=>t(e,n)).catch(()=>{})}function O(e){let t=a(e.locationHref,e.isExtension,e.storage);return D(t,e),t}function k(){if(s())return;let e=new Blob([`
3
3
  let lastPong = Date.now();
4
4
  let frozen = false;
5
5
  setInterval(() => {
@@ -19,4 +19,4 @@ import"./modulepreload-polyfill-P2Xu9kJm.js";import{a as e}from"./account-store-
19
19
  }
20
20
  }
21
21
  };
22
- `],{type:`application/javascript`}),t=URL.createObjectURL(e),n=new Worker(t);URL.revokeObjectURL(t),n.onmessage=e=>{if(e.data.type===`ping`)n.postMessage({type:`pong`});else if(e.data.type===`freeze-detected`)console.error(`[freeze-watchdog] Main thread blocked for ${e.data.elapsed}ms — capturing trace on recovery`);else if(e.data.type===`freeze-recovered`){console.error(`[freeze-watchdog] Main thread recovered. Stack trace at recovery point:`),console.trace(`[freeze-watchdog] recovery stack`);let e=performance.getEntriesByType(`longtask`);e.length>0&&console.error(`[freeze-watchdog] Long tasks:`,e.map(e=>({duration:e.duration,startTime:e.startTime,name:e.name})))}},window.addEventListener(`beforeunload`,()=>{n.terminate()},{once:!0})}var A=`slicc-nuke-control`,j=[`slicc:welcome-flow-fired`,`slicc.trayJoinUrl`,`slicc.trayWorkerBaseUrl`];function M(e=()=>location.reload()){if(typeof BroadcastChannel!=`function`)return()=>{};let t=new BroadcastChannel(A),n=t=>{let n=t.data;if(n?.type===`nuke-reload`){if(Array.isArray(n.keysToRemove)){for(let e of n.keysToRemove)if(typeof e==`string`)try{localStorage.removeItem(e)}catch{}}e()}};return t.addEventListener(`message`,n),()=>{t.removeEventListener(`message`,n),t.close()}}var N=null;function P(){return N||(N=M(),N)}var F=n(`storage-persist`);function I(){try{return globalThis.navigator?.storage}catch{return}}async function L(e=I()){try{return typeof e?.persist==`function`?typeof e.persisted==`function`&&await e.persisted()?`already-persisted`:await e.persist()?`granted`:`denied`:`unsupported`}catch(e){return F.warn(`storage persistence check failed`,e),`failed`}}var R=!1;function z(){R||(R=!0,L().then(e=>{switch(e){case`granted`:F.info(`OPFS marked persistent — SLICC data is now exempt from disk-pressure eviction`);break;case`already-persisted`:F.debug(`OPFS already persistent`);break;case`denied`:F.warn(`Browser declined persistent storage — SLICC data can be evicted if the disk fills up`);break;case`unsupported`:F.debug(`navigator.storage.persist() unavailable in this runtime`)}}).catch(()=>{}))}var B=n(`boot/sw-registration`);async function V(e=null,t=null){let n=(()=>{try{return new URL(window.location.href).searchParams.get(`connect`)===`1`}catch{return!1}})();if(`serviceWorker`in navigator&&n&&await W())return`reload-pending`;if(!(`serviceWorker`in navigator)||n)return`ready`;try{if(await navigator.serviceWorker.register(`/preview-sw.js`,{scope:`/preview/`}),B.info(`Preview SW registered`),!s())try{await navigator.serviceWorker.register(`/llm-proxy-sw.js`,{scope:`/`}),B.info(`LLM-proxy SW registered`)}catch(e){B.error(`LLM-proxy SW registration failed — cross-origin LLM calls will hit CORS`,e)}if(navigator.serviceWorker.controller||await Promise.race([new Promise(e=>navigator.serviceWorker.addEventListener(`controllerchange`,()=>e(),{once:!0})),new Promise(e=>setTimeout(e,1500))]),!navigator.serviceWorker.controller&&!sessionStorage.getItem(`slicc-sw-reloaded`))return sessionStorage.setItem(`slicc-sw-reloaded`,`1`),B.info(`Reloading once to gain SW control`),location.reload(),`reload-pending`;sessionStorage.removeItem(`slicc-sw-reloaded`),e&&(H(e),navigator.serviceWorker.addEventListener(`controllerchange`,()=>{H(e)})),t&&(U(t),navigator.serviceWorker.addEventListener(`controllerchange`,()=>{U(t)}))}catch(e){B.error(`Preview SW registration failed — preview feature will not work`,e)}return`ready`}function H(e){let t=navigator.serviceWorker.controller;if(!t)return;let n={type:f,apiBaseUrl:e.apiBaseUrl,token:e.token};try{t.postMessage(n)}catch(e){B.warn(`LLM-proxy SW bridge-config postMessage failed`,e)}}function U(e){let t=navigator.serviceWorker.controller;if(!t)return;let n={type:p,extensionId:e.extensionId};try{t.postMessage(n)}catch(e){B.warn(`LLM-proxy SW extension-delegate postMessage failed`,e)}}async function W(){try{let e=await navigator.serviceWorker.getRegistrations();if(await Promise.all(e.map(e=>e.unregister().catch(()=>!1))),navigator.serviceWorker.controller&&!sessionStorage.getItem(`slicc-connect-sw-cleared`))return sessionStorage.setItem(`slicc-connect-sw-cleared`,`1`),B.info(`connect mode: detaching from service worker (no proxy on worker origin)`),location.reload(),!0;sessionStorage.removeItem(`slicc-connect-sw-cleared`)}catch(e){B.error(`connect-mode SW cleanup failed`,e)}return!1}var G=n(`main`);function K(e){try{return new URL(e).searchParams.has(`ui-fixture`)}catch{return!1}}async function q(){i();let n=document.getElementById(`app`);if(!n)throw Error(`#app element not found`);let a=s(),d=O({locationHref:window.location.href,storage:window.localStorage,envBaseUrl:null,isDev:!1,isExtension:a});if(K(window.location.href)){let{mountWcUiPreview:e}=await t(async()=>{let{mountWcUiPreview:e}=await import(`./wc-shell-p7cHxhJQ.js`).then(e=>e.s);return{mountWcUiPreview:e}},__vite__mapDeps([12,4,5,13,14,15,6,16,2,17,18,19,9,20,21,22,23,24,25,26,27,28,29,30]));e(n);return}k(),P(),z(),d!==`connect`&&l({isExtensionRealm:a}).catch(()=>{});let f=r(window.location.search),p=d===`cherry`?null:o(window.location.search),m=!!p&&c();if(await V(f?{apiBaseUrl:f.apiBaseUrl,token:f.token}:null,m&&p?{extensionId:p.extensionId}:null)===`reload-pending`)return;if(!a&&(d===`follower`||d===`cherry`)){let{bootFollowerFloat:e}=await t(async()=>{let{bootFollowerFloat:e}=await import(`./wc-follower-BdUaqkeK.js`);return{bootFollowerFloat:e}},__vite__mapDeps([31,5,13,32,2,3,4,6,7,8,9,1,10,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,15,48,49,50,51,17,11,52,53,12,14,16,18,19,20,21,22,23,24,25,26,27,28,29,30,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86]));return e(n,G,d)}await u(),e();let{bootstrapOAuthReplicas:h}=await t(async()=>{let{bootstrapOAuthReplicas:e}=await import(`./oauth-bootstrap-DESksVSP.js`);return{bootstrapOAuthReplicas:e}},__vite__mapDeps([87,36,4,5,37,38,39,40,41,42,43,13,3,6,7,8,9,44,45,46,47,15,48,49,50,51,88,2,1,10,17,52,89,90,91]));if(await Promise.race([h().catch(e=>{G.error(`OAuth bootstrap failed`,e)}),new Promise(e=>setTimeout(e,1e4))]),d===`connect`){globalThis.__slicc_connect_mode=!0;let{loadLegacyStyles:e}=await t(async()=>{let{loadLegacyStyles:e}=await import(`./legacy-styles-B3nS5QUo.js`);return{loadLegacyStyles:e}},__vite__mapDeps([92,5]));await e();let{mountConnectSurface:r}=await t(async()=>{let{mountConnectSurface:e}=await import(`./connect-surface-Cga7yA1x.js`);return{mountConnectSurface:e}},__vite__mapDeps([93,36,4,5,37,38,39,40,41,42,43,13,3,6,7,8,9,44,45,46,47,15,48,49,50,51,88,2,1,10,17,52,89,90]));await r(n);return}if(a){let{bootExtensionFloat:e}=await t(async()=>{let{bootExtensionFloat:e}=await import(`./wc-extension-NZBjLMIl.js`);return{bootExtensionFloat:e}},__vite__mapDeps([94,5,35,4,36,37,38,39,40,41,42,43,13,3,6,7,8,9,44,45,46,47,15,48,49,50,51,32,2,1,10,33,34,17,11,52,53,12,14,16,18,19,20,21,22,23,24,25,26,27,28,29,30,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,95]));return e(n,G,d===`extension-detached`)}m&&p&&v(p.extensionId);let{bootLeaderFloat:g}=await t(async()=>{let{bootLeaderFloat:e}=await import(`./wc-live-Doom1Cuk.js`).then(e=>e.n);return{bootLeaderFloat:e}},__vite__mapDeps([35,4,36,5,37,38,39,40,41,42,43,13,3,6,7,8,9,44,45,46,47,15,48,49,50,51,32,2,1,10,33,34,17,11,52,53,12,14,16,18,19,20,21,22,23,24,25,26,27,28,29,30,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77]));return g(n,G,d)}function J(e,t){let n=document.createElement(`div`);n.style.cssText=`padding:2rem;text-align:center;font-family:system-ui;`;let r=document.createElement(`h1`);r.textContent=`Failed to start`;let i=document.createElement(`p`);i.textContent=t instanceof Error?t.message:String(t);let a=document.createElement(`button`);a.type=`button`,a.textContent=`Reload`,a.addEventListener(`click`,()=>location.reload()),n.append(r,i,a),e.replaceChildren(n)}async function Y(e,n){let r;try{({renderBootRecoveryScreen:r}=await t(()=>import(`./recovery-screen-Cr55gwtB.js`),[]))}catch{J(e,n);return}if(r(e,n),n instanceof Error&&n.message.includes(`did not signal ready`))try{let{triageModuleWorkerHealth:i}=await t(async()=>{let{triageModuleWorkerHealth:e}=await import(`./worker-triage-BvsMZrdR.js`);return{triageModuleWorkerHealth:e}},[]),a=await i();a===`browser-wedged`&&r(e,n,{verdict:a})}catch{}}q().catch(e=>{G.error(`Fatal error`,e);let t=document.getElementById(`app`);t&&Y(t,e)});export{C as n,S as r,j as t};
22
+ `],{type:`application/javascript`}),t=URL.createObjectURL(e),n=new Worker(t);URL.revokeObjectURL(t),n.onmessage=e=>{if(e.data.type===`ping`)n.postMessage({type:`pong`});else if(e.data.type===`freeze-detected`)console.error(`[freeze-watchdog] Main thread blocked for ${e.data.elapsed}ms — capturing trace on recovery`);else if(e.data.type===`freeze-recovered`){console.error(`[freeze-watchdog] Main thread recovered. Stack trace at recovery point:`),console.trace(`[freeze-watchdog] recovery stack`);let e=performance.getEntriesByType(`longtask`);e.length>0&&console.error(`[freeze-watchdog] Long tasks:`,e.map(e=>({duration:e.duration,startTime:e.startTime,name:e.name})))}},window.addEventListener(`beforeunload`,()=>{n.terminate()},{once:!0})}var A=`slicc-nuke-control`,j=[`slicc:welcome-flow-fired`,`slicc.trayJoinUrl`,`slicc.trayWorkerBaseUrl`];function M(e=()=>location.reload()){if(typeof BroadcastChannel!=`function`)return()=>{};let t=new BroadcastChannel(A),n=t=>{let n=t.data;if(n?.type===`nuke-reload`){if(Array.isArray(n.keysToRemove)){for(let e of n.keysToRemove)if(typeof e==`string`)try{localStorage.removeItem(e)}catch{}}e()}};return t.addEventListener(`message`,n),()=>{t.removeEventListener(`message`,n),t.close()}}var N=null;function P(){return N||(N=M(),N)}var F=n(`storage-persist`);function I(){try{return globalThis.navigator?.storage}catch{return}}async function L(e=I()){try{return typeof e?.persist==`function`?typeof e.persisted==`function`&&await e.persisted()?`already-persisted`:await e.persist()?`granted`:`denied`:`unsupported`}catch(e){return F.warn(`storage persistence check failed`,e),`failed`}}var R=!1;function z(){R||(R=!0,L().then(e=>{switch(e){case`granted`:F.info(`OPFS marked persistent — SLICC data is now exempt from disk-pressure eviction`);break;case`already-persisted`:F.debug(`OPFS already persistent`);break;case`denied`:F.warn(`Browser declined persistent storage — SLICC data can be evicted if the disk fills up`);break;case`unsupported`:F.debug(`navigator.storage.persist() unavailable in this runtime`)}}).catch(()=>{}))}var B=n(`boot/sw-registration`);async function V(e=null,t=null){let n=(()=>{try{return new URL(window.location.href).searchParams.get(`connect`)===`1`}catch{return!1}})();if(`serviceWorker`in navigator&&n&&await W())return`reload-pending`;if(!(`serviceWorker`in navigator)||n)return`ready`;try{if(await navigator.serviceWorker.register(`/preview-sw.js`,{scope:`/preview/`}),B.info(`Preview SW registered`),!s())try{await navigator.serviceWorker.register(`/llm-proxy-sw.js`,{scope:`/`}),B.info(`LLM-proxy SW registered`)}catch(e){B.error(`LLM-proxy SW registration failed — cross-origin LLM calls will hit CORS`,e)}if(navigator.serviceWorker.controller||await Promise.race([new Promise(e=>navigator.serviceWorker.addEventListener(`controllerchange`,()=>e(),{once:!0})),new Promise(e=>setTimeout(e,1500))]),!navigator.serviceWorker.controller&&!sessionStorage.getItem(`slicc-sw-reloaded`))return sessionStorage.setItem(`slicc-sw-reloaded`,`1`),B.info(`Reloading once to gain SW control`),location.reload(),`reload-pending`;sessionStorage.removeItem(`slicc-sw-reloaded`),e&&(H(e),navigator.serviceWorker.addEventListener(`controllerchange`,()=>{H(e)})),t&&(U(t),navigator.serviceWorker.addEventListener(`controllerchange`,()=>{U(t)}))}catch(e){B.error(`Preview SW registration failed — preview feature will not work`,e)}return`ready`}function H(e){let t=navigator.serviceWorker.controller;if(!t)return;let n={type:f,apiBaseUrl:e.apiBaseUrl,token:e.token};try{t.postMessage(n)}catch(e){B.warn(`LLM-proxy SW bridge-config postMessage failed`,e)}}function U(e){let t=navigator.serviceWorker.controller;if(!t)return;let n={type:p,extensionId:e.extensionId};try{t.postMessage(n)}catch(e){B.warn(`LLM-proxy SW extension-delegate postMessage failed`,e)}}async function W(){try{let e=await navigator.serviceWorker.getRegistrations();if(await Promise.all(e.map(e=>e.unregister().catch(()=>!1))),navigator.serviceWorker.controller&&!sessionStorage.getItem(`slicc-connect-sw-cleared`))return sessionStorage.setItem(`slicc-connect-sw-cleared`,`1`),B.info(`connect mode: detaching from service worker (no proxy on worker origin)`),location.reload(),!0;sessionStorage.removeItem(`slicc-connect-sw-cleared`)}catch(e){B.error(`connect-mode SW cleanup failed`,e)}return!1}var G=n(`main`);function K(e){try{return new URL(e).searchParams.has(`ui-fixture`)}catch{return!1}}async function q(){i();let n=document.getElementById(`app`);if(!n)throw Error(`#app element not found`);let a=s(),d=O({locationHref:window.location.href,storage:window.localStorage,envBaseUrl:null,isDev:!1,isExtension:a});if(K(window.location.href)){let{mountWcUiPreview:e}=await t(async()=>{let{mountWcUiPreview:e}=await import(`./wc-shell-D0eljkIj.js`).then(e=>e.s);return{mountWcUiPreview:e}},__vite__mapDeps([12,4,5,13,14,15,6,16,2,17,18,19,9,20,21,22,23,24,25,26,27,28,29,30]));e(n);return}k(),P(),z(),d!==`connect`&&l({isExtensionRealm:a}).catch(()=>{});let f=r(window.location.search),p=d===`cherry`?null:o(window.location.search),m=!!p&&c();if(await V(f?{apiBaseUrl:f.apiBaseUrl,token:f.token}:null,m&&p?{extensionId:p.extensionId}:null)===`reload-pending`)return;if(!a&&(d===`follower`||d===`cherry`)){let{bootFollowerFloat:e}=await t(async()=>{let{bootFollowerFloat:e}=await import(`./wc-follower-CaCmbsFC.js`);return{bootFollowerFloat:e}},__vite__mapDeps([31,5,13,32,2,3,4,6,7,8,9,1,10,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,15,48,49,50,51,17,11,52,53,12,14,16,18,19,20,21,22,23,24,25,26,27,28,29,30,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86]));return e(n,G,d)}await u(),e();let{bootstrapOAuthReplicas:h}=await t(async()=>{let{bootstrapOAuthReplicas:e}=await import(`./oauth-bootstrap-BZdvwVda.js`);return{bootstrapOAuthReplicas:e}},__vite__mapDeps([87,36,4,5,37,38,39,40,41,42,43,13,3,6,7,8,9,44,45,46,47,15,48,49,50,51,88,2,1,10,17,52,89,90,91]));if(await Promise.race([h().catch(e=>{G.error(`OAuth bootstrap failed`,e)}),new Promise(e=>setTimeout(e,1e4))]),d===`connect`){globalThis.__slicc_connect_mode=!0;let{loadLegacyStyles:e}=await t(async()=>{let{loadLegacyStyles:e}=await import(`./legacy-styles-B3nS5QUo.js`);return{loadLegacyStyles:e}},__vite__mapDeps([92,5]));await e();let{mountConnectSurface:r}=await t(async()=>{let{mountConnectSurface:e}=await import(`./connect-surface-DHUhaoge.js`);return{mountConnectSurface:e}},__vite__mapDeps([93,36,4,5,37,38,39,40,41,42,43,13,3,6,7,8,9,44,45,46,47,15,48,49,50,51,88,2,1,10,17,52,89,90]));await r(n);return}if(a){let{bootExtensionFloat:e}=await t(async()=>{let{bootExtensionFloat:e}=await import(`./wc-extension-HpEFmEaM.js`);return{bootExtensionFloat:e}},__vite__mapDeps([94,5,35,4,36,37,38,39,40,41,42,43,13,3,6,7,8,9,44,45,46,47,15,48,49,50,51,32,2,1,10,33,34,17,11,52,53,12,14,16,18,19,20,21,22,23,24,25,26,27,28,29,30,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,95]));return e(n,G,d===`extension-detached`)}m&&p&&v(p.extensionId);let{bootLeaderFloat:g}=await t(async()=>{let{bootLeaderFloat:e}=await import(`./wc-live-nJl674nq.js`).then(e=>e.n);return{bootLeaderFloat:e}},__vite__mapDeps([35,4,36,5,37,38,39,40,41,42,43,13,3,6,7,8,9,44,45,46,47,15,48,49,50,51,32,2,1,10,33,34,17,11,52,53,12,14,16,18,19,20,21,22,23,24,25,26,27,28,29,30,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77]));return g(n,G,d)}function J(e,t){let n=document.createElement(`div`);n.style.cssText=`padding:2rem;text-align:center;font-family:system-ui;`;let r=document.createElement(`h1`);r.textContent=`Failed to start`;let i=document.createElement(`p`);i.textContent=t instanceof Error?t.message:String(t);let a=document.createElement(`button`);a.type=`button`,a.textContent=`Reload`,a.addEventListener(`click`,()=>location.reload()),n.append(r,i,a),e.replaceChildren(n)}async function Y(e,n){let r;try{({renderBootRecoveryScreen:r}=await t(()=>import(`./recovery-screen-D3feoocF.js`),[]))}catch{J(e,n);return}if(r(e,n),n instanceof Error&&n.message.includes(`did not signal ready`))try{let{triageModuleWorkerHealth:i}=await t(async()=>{let{triageModuleWorkerHealth:e}=await import(`./worker-triage-BvsMZrdR.js`);return{triageModuleWorkerHealth:e}},[]),a=await i();a===`browser-wedged`&&r(e,n,{verdict:a})}catch{}}q().catch(e=>{G.error(`Fatal error`,e);let t=document.getElementById(`app`);t&&Y(t,e)});export{C as n,S as r,j as t};
@@ -9,4 +9,4 @@ Content-Disposition: form-data; name="${e}"\r
9
9
  ${g(i.value)}\r
10
10
  `))}return r.push(n.encode(`--${t}--\r
11
11
  `)),{bytes:y(r),contentType:`multipart/form-data; boundary=${t}`,boundary:t}}async function h(e,t=f()){let n=[];for(let[t,r]of e.entries()){if(typeof r==`string`){n.push({name:t,value:r});continue}let e=typeof r.name==`string`?r.name:`blob`;n.push({name:t,file:{bytes:new Uint8Array(await r.arrayBuffer()),filename:e,contentType:r.type||void 0}})}return m(n,t)}function g(e){return e.replace(/\r\n|\r|\n/g,`\r
12
- `)}function _(e){return e.replace(/\r/g,`%0D`).replace(/\n/g,`%0A`).replace(/"/g,`%22`)}function v(e){return(e??``).replace(/[\r\n]/g,``).trim()}function y(e){let t=0;for(let n of e)t+=n.byteLength;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.byteLength;return n}function b(e,t,n){let r=m([{name:`data`,file:{bytes:n,filename:e,contentType:t}}]);return{contentType:r.contentType,body:r.bytes}}function x(e){return e.split(`/`).pop()||`data`}function S(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 C=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=S(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??5242880,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new i(`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 a=await this.transport({method:`GET`,path:this.toSourcePath(t),headers:r});if(a.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(a.status===404)throw await this.cache.invalidateBody(t),new i(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new i(`EACCES`,`da access denied`,e);if(a.status>=400)throw new i(`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 i(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=a.headers.get(`etag`)??``,u=l.startsWith(`W/`)?l.slice(2):l;return await this.cache.putBody(t,c,u),c}async writeFile(e,t){if(this.assertOpen(e),t.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let n=this.toMountRelative(e),a=await this.cache.getBody(n),o=b(x(e),r(e),t),s={"content-type":o.contentType,"content-length":String(o.body.byteLength)};a?.etag?s[`if-match`]=a.etag.startsWith(`W/`)?a.etag.slice(2):a.etag:a||(s[`if-none-match`]=`*`);let c=()=>this.transport({method:`POST`,path:this.toSourcePath(n),headers:s,body:o.body}),l,u=1;try{l=await c()}catch{u=2,l=await c()}if(l.status===412){if(u===2){let r=await this.transport({method:`HEAD`,path:this.toSourcePath(n)});if(r.status>=400)throw new i(`EIO`,`da reconcile HEAD failed: ${r.status}`,e);let a=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,a);let o=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new i(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(l.status===401||l.status===403)throw new i(`EACCES`,`da write denied`,e);if(l.status>=400)throw new i(`EIO`,`da writeFile failed: ${l.status}`,e);let d=l.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 i(`ENOENT`,`no such directory`,e);if(r.status>=400)throw new i(`EIO`,`da list failed: ${r.status}`,e);let a=(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,a),a}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(`/`),a=r.pop()??``,o=r.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 i(`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 n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new i(`ENOENT`,`no such file or directory`,e)}throw new i(`EIO`,`da stat failed: ${c.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 i(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new i(`EACCES`,`da delete denied`,e);if(n.status>=400)throw new i(`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 w(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 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=w(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??26214400,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new i(`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 a=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:this.toS3Key(t),headers:r});if(a.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(a.status===404)throw await this.cache.invalidateBody(t),new i(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new i(`EACCES`,`s3 access denied`,e);if(a.status>=400)throw new i(`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 i(`EFBIG`,`body exceeds maxBodyBytes (${s} > ${this.maxBodyBytes})`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new i(`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 n=this.toMountRelative(e);if(t.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=await this.cache.getBody(n),a={"content-type":`application/octet-stream`,"content-length":String(t.byteLength)};r?a[`if-match`]=r.etag:a[`if-none-match`]=`*`;let o=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(n),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 r=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status>=400)throw new i(`EIO`,`s3 reconcile HEAD failed: ${r.status}`,e);let a=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,a);let o=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new i(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(s.status===401||s.status===403)throw new i(`EACCES`,`s3 write denied`,e);if(s.status>=400)throw new i(`EIO`,`s3 writeFile failed: ${s.status}`,e);let l=s.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 i(`EIO`,`s3 list failed: ${r.status}`,`/`);let a=await r.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),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(`/`),a=r.pop()??``,o=r.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 i(`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 n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new i(`ENOENT`,`no such file or directory`,e)}throw new i(`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 n=this.toMountRelative(e);if(t?.recursive)throw new i(`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 i(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new i(`EACCES`,`s3 delete denied`,e);if(r.status>=400)throw new i(`EIO`,`s3 delete failed: ${r.status}`,e);await this.cache.invalidateBody(n);let a=n.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}},E=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function D(){let{getAccounts:e}=await import(`./account-store-CnTVyV3B.js`).then(e=>e.t),t=e().find(e=>e.providerId===`adobe`);if(!t?.accessToken)throw new E(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>t.accessToken}}let O;function k(e){O=e}function A(){return O}const j=n,M=t,N=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),P=new Set([101,103,204,205,304]);function F(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new i(`EACCES`,e.error):e.errorCode===`invalid_request`?new i(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||N.has(String(e.errorCode))?new i(`EIO`,e.error):new i(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=j(e.bodyBase64)}catch(e){throw new i(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let n=P.has(e.status)?null:t;return new Response(n,{status:e.status,headers:new Headers(e.headers)})}function I(e,t){return t===void 0?e===`node-rest`?` (SLICC backend at localhost may not be running)`:e===`extension-direct`||e===`extension-delegate`?` (extension service worker not responding)`:``:``}async function L(e){let t=A();if(!t)throw new i(`EIO`,`mount transport unavailable: setMountCapabilityBroker was never called for this float (composition bug — refusing to guess a transport for a privileged sign-and-forward request)`);let n=await t.mounts.signRequest(e);if(!n.ok){let e=`status`in n?n.status:void 0;throw new i(`EIO`,`mount transport failed: ${n.message}${I(t.adapter,e)}`)}return n.value}function R(e){return async t=>F(await L({backend:`s3`,envelope:{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}}))}function z(e){let t=e?.getImsToken??(async()=>(await D()).getBearerToken());return async e=>{let n;try{n=await t()}catch(e){throw new i(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}return F(await L({backend:`da`,envelope:{imsToken:n,method:e.method,path:e.path,origin:e.origin,query:e.query,headers:e.headers,bodyBase64:e.body?M(e.body):void 0}}))}}var B=e({AEM_SOURCE_BUS_ORIGIN:()=>o,AemMountBackend:()=>d,DaMountBackend:()=>C,RemoteMountCache:()=>a,S3MountBackend:()=>T,makeSignedFetchDa:()=>z,makeSignedFetchS3:()=>R});export{T as a,p as c,k as i,o as l,z as n,C as o,R as r,h as s,B as t,d as u};
12
+ `)}function _(e){return e.replace(/\r/g,`%0D`).replace(/\n/g,`%0A`).replace(/"/g,`%22`)}function v(e){return(e??``).replace(/[\r\n]/g,``).trim()}function y(e){let t=0;for(let n of e)t+=n.byteLength;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.byteLength;return n}function b(e,t,n){let r=m([{name:`data`,file:{bytes:n,filename:e,contentType:t}}]);return{contentType:r.contentType,body:r.bytes}}function x(e){return e.split(`/`).pop()||`data`}function S(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 C=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=S(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??5242880,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new i(`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 a=await this.transport({method:`GET`,path:this.toSourcePath(t),headers:r});if(a.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(a.status===404)throw await this.cache.invalidateBody(t),new i(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new i(`EACCES`,`da access denied`,e);if(a.status>=400)throw new i(`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 i(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=a.headers.get(`etag`)??``,u=l.startsWith(`W/`)?l.slice(2):l;return await this.cache.putBody(t,c,u),c}async writeFile(e,t){if(this.assertOpen(e),t.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let n=this.toMountRelative(e),a=await this.cache.getBody(n),o=b(x(e),r(e),t),s={"content-type":o.contentType,"content-length":String(o.body.byteLength)};a?.etag?s[`if-match`]=a.etag.startsWith(`W/`)?a.etag.slice(2):a.etag:a||(s[`if-none-match`]=`*`);let c=()=>this.transport({method:`POST`,path:this.toSourcePath(n),headers:s,body:o.body}),l,u=1;try{l=await c()}catch{u=2,l=await c()}if(l.status===412){if(u===2){let r=await this.transport({method:`HEAD`,path:this.toSourcePath(n)});if(r.status>=400)throw new i(`EIO`,`da reconcile HEAD failed: ${r.status}`,e);let a=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,a);let o=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new i(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(l.status===401||l.status===403)throw new i(`EACCES`,`da write denied`,e);if(l.status>=400)throw new i(`EIO`,`da writeFile failed: ${l.status}`,e);let d=l.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 i(`ENOENT`,`no such directory`,e);if(r.status>=400)throw new i(`EIO`,`da list failed: ${r.status}`,e);let a=(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,a),a}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(`/`),a=r.pop()??``,o=r.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 i(`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 n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new i(`ENOENT`,`no such file or directory`,e)}throw new i(`EIO`,`da stat failed: ${c.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 i(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new i(`EACCES`,`da delete denied`,e);if(n.status>=400)throw new i(`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 w(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 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=w(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??26214400,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new i(`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 a=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:this.toS3Key(t),headers:r});if(a.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(a.status===404)throw await this.cache.invalidateBody(t),new i(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new i(`EACCES`,`s3 access denied`,e);if(a.status>=400)throw new i(`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 i(`EFBIG`,`body exceeds maxBodyBytes (${s} > ${this.maxBodyBytes})`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new i(`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 n=this.toMountRelative(e);if(t.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=await this.cache.getBody(n),a={"content-type":`application/octet-stream`,"content-length":String(t.byteLength)};r?a[`if-match`]=r.etag:a[`if-none-match`]=`*`;let o=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(n),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 r=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status>=400)throw new i(`EIO`,`s3 reconcile HEAD failed: ${r.status}`,e);let a=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,a);let o=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new i(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(s.status===401||s.status===403)throw new i(`EACCES`,`s3 write denied`,e);if(s.status>=400)throw new i(`EIO`,`s3 writeFile failed: ${s.status}`,e);let l=s.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 i(`EIO`,`s3 list failed: ${r.status}`,`/`);let a=await r.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),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(`/`),a=r.pop()??``,o=r.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 i(`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 n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new i(`ENOENT`,`no such file or directory`,e)}throw new i(`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 n=this.toMountRelative(e);if(t?.recursive)throw new i(`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 i(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new i(`EACCES`,`s3 delete denied`,e);if(r.status>=400)throw new i(`EIO`,`s3 delete failed: ${r.status}`,e);await this.cache.invalidateBody(n);let a=n.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}},E=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function D(){let{getAccounts:e}=await import(`./account-store-ChQLfZgz.js`).then(e=>e.t),t=e().find(e=>e.providerId===`adobe`);if(!t?.accessToken)throw new E(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>t.accessToken}}let O;function k(e){O=e}function A(){return O}const j=n,M=t,N=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),P=new Set([101,103,204,205,304]);function F(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new i(`EACCES`,e.error):e.errorCode===`invalid_request`?new i(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||N.has(String(e.errorCode))?new i(`EIO`,e.error):new i(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=j(e.bodyBase64)}catch(e){throw new i(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let n=P.has(e.status)?null:t;return new Response(n,{status:e.status,headers:new Headers(e.headers)})}function I(e,t){return t===void 0?e===`node-rest`?` (SLICC backend at localhost may not be running)`:e===`extension-direct`||e===`extension-delegate`?` (extension service worker not responding)`:``:``}async function L(e){let t=A();if(!t)throw new i(`EIO`,`mount transport unavailable: setMountCapabilityBroker was never called for this float (composition bug — refusing to guess a transport for a privileged sign-and-forward request)`);let n=await t.mounts.signRequest(e);if(!n.ok){let e=`status`in n?n.status:void 0;throw new i(`EIO`,`mount transport failed: ${n.message}${I(t.adapter,e)}`)}return n.value}function R(e){return async t=>F(await L({backend:`s3`,envelope:{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}}))}function z(e){let t=e?.getImsToken??(async()=>(await D()).getBearerToken());return async e=>{let n;try{n=await t()}catch(e){throw new i(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}return F(await L({backend:`da`,envelope:{imsToken:n,method:e.method,path:e.path,origin:e.origin,query:e.query,headers:e.headers,bodyBase64:e.body?M(e.body):void 0}}))}}var B=e({AEM_SOURCE_BUS_ORIGIN:()=>o,AemMountBackend:()=>d,DaMountBackend:()=>C,RemoteMountCache:()=>a,S3MountBackend:()=>T,makeSignedFetchDa:()=>z,makeSignedFetchS3:()=>R});export{T as a,p as c,k as i,o as l,z as n,C as o,R as r,h as s,B as t,d as u};
@@ -1,3 +1,3 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/account-store-B2fM_hVm.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/preload-helper-Czpn1I53.js","assets/claude-model-version-BJLrDjmH.js","assets/models-BSkXF4T6.js","assets/diagnostics-DN_idNHx.js","assets/provider-env-CTOcDKrQ.js","assets/__vite-browser-external-5eBdwsFd.js","assets/openrouter.models-B-zmcypy.js","assets/libesm-BypnjKEL.js","assets/logger-DDBAeTLF.js","assets/proxied-fetch-CiijUcSt.js","assets/base64-DJRlyqZu.js","assets/fetch-body-D2PwksUW.js","assets/api-endpoint-DGxXvrur.js","assets/runtime-env-Dlaokqg1.js","assets/float-topology-hfgMx1Yq.js","assets/secret-topology-Yt0aO4Gz.js","assets/secrets-bridge-client-BVl0YuB2.js","assets/port-bridge-client-C1tBBqwu.js","assets/image-markers-BFDmhPy4.js","assets/tool-ui-eSQ1g2I1.js","assets/providers-Cc4NoSCd.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-D0xZwlMO.js";import{r as n,t as r}from"./base64-DJRlyqZu.js";import{t as i}from"./types-Dgm4REV3.js";import"./mount-table-store-dY2IfQ5S.js";import"./fs-WglxnM0m.js";import{t as a}from"./remote-cache-3KNT1gsp.js";var o=`https://api.aem.live`,s=`application/folder`,c=5242880;function l(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 u(e){if(!e)return``;let t=Date.parse(e);return Number.isNaN(t)?``:String(t)}function d(e){let t=Date.parse(e??``);return Number.isNaN(t)?0:t}function f(e){return e.map(e=>e[`content-type`]===s||e.name.endsWith(`/`)?{name:e.name.replace(/\/+$/,``),kind:`directory`}:{name:e.name,kind:`file`,size:e.size,etag:u(e[`last-modified`]),lastModified:d(e[`last-modified`])})}var p=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=l(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??c,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new i(`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:o,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 i(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new i(`EACCES`,`aem access denied`,e);if(r.status>=400)throw new i(`EIO`,`aem readFile failed: ${r.status}`,e);let a=new Uint8Array(await r.arrayBuffer());if(a.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);return await this.cache.putBody(t,a,u(r.headers.get(`last-modified`))),a}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 i(`EIO`,`aem precondition HEAD failed: ${r.status}`,e);let a=u(r.headers.get(`last-modified`));if(a&&a!==n)throw await this.cache.invalidateBody(t),new i(`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 i(`EFBIG`,`body exceeds maxBodyBytes`,e);let n=this.toMountRelative(e),r=await this.cache.getBody(n);await this.assertUnchanged(e,n,r?.etag??``);let a=await this.request(`PUT`,this.toSourcePath(n),{body:t});if(a.status===401||a.status===403)throw new i(`EACCES`,`aem write denied`,e);if(a.status>=400)throw new i(`EIO`,`aem writeFile failed: ${a.status}`,e);await this.cache.invalidateBody(n);let o=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o)}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 i(`ENOENT`,`no such directory`,e);if(r.status===401||r.status===403)throw new i(`EACCES`,`aem access denied`,e);if(r.status>=400)throw new i(`EIO`,`aem list failed: ${r.status}`,e);let a=f(await r.json());return await this.cache.putListing(t,a),a}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(`/`),a=r.pop()??``,o=r.join(`/`),s=await this.cache.getListing(o),c=(s&&!this.cache.isStale(s.cachedAt)?s.entries:await this.readDirQuietly(o))?.find(e=>e.name===a);if(!c)throw new i(`ENOENT`,`no such file or directory`,e);return c.kind===`directory`?{kind:`directory`,size:0,mtime:c.lastModified??0}:{kind:`file`,size:c.size??0,mtime:c.lastModified??0,etag:c.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 i(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new i(`EACCES`,`aem delete denied`,e);if(n.status>=400)throw new i(`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=f(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}},m=`\r
3
- `;function h(){let e=new Uint8Array(16);if(typeof crypto<`u`&&typeof crypto.getRandomValues==`function`)crypto.getRandomValues(e);else for(let t=0;t<e.length;t+=1)e[t]=Math.floor(Math.random()*256);let t=``;for(let n of e)t+=n.toString(16).padStart(2,`0`);return`----SliccFormBoundary${t}`}function g(e,t=h()){let n=new TextEncoder,r=[];for(let i of e){let e=v(_(i.name));if(`file`in i){let a=v(i.file.filename),o=y(i.file.contentType)||`application/octet-stream`;r.push(n.encode(`--${t}${m}Content-Disposition: form-data; name="${e}"; filename="${a}"${m}Content-Type: ${o}${m}${m}`)),r.push(i.file.bytes),r.push(n.encode(m))}else r.push(n.encode(`--${t}${m}Content-Disposition: form-data; name="${e}"${m}${m}${_(i.value)}${m}`))}return r.push(n.encode(`--${t}--${m}`)),{bytes:b(r),contentType:`multipart/form-data; boundary=${t}`,boundary:t}}function _(e){return e.replace(/\r\n|\r|\n/g,m)}function v(e){return e.replace(/\r/g,`%0D`).replace(/\n/g,`%0A`).replace(/"/g,`%22`)}function y(e){return(e??``).replace(/[\r\n]/g,``).trim()}function b(e){let t=0;for(let n of e)t+=n.byteLength;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.byteLength;return n}function x(e,t,n){let r=g([{name:`data`,file:{bytes:n,filename:e,contentType:t}}]);return{contentType:r.contentType,body:r.bytes}}function S(e){return e.split(`/`).pop()||`data`}function C(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 w=5242880,T=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=C(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??w,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new i(`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 a=await this.transport({method:`GET`,path:this.toSourcePath(t),headers:r});if(a.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(a.status===404)throw await this.cache.invalidateBody(t),new i(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new i(`EACCES`,`da access denied`,e);if(a.status>=400)throw new i(`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 i(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=a.headers.get(`etag`)??``,u=l.startsWith(`W/`)?l.slice(2):l;return await this.cache.putBody(t,c,u),c}async writeFile(e,n){if(this.assertOpen(e),n.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=this.toMountRelative(e),a=await this.cache.getBody(r),o=x(S(e),t(e),n),s={"content-type":o.contentType,"content-length":String(o.body.byteLength)};a?.etag?s[`if-match`]=a.etag.startsWith(`W/`)?a.etag.slice(2):a.etag:a||(s[`if-none-match`]=`*`);let c=()=>this.transport({method:`POST`,path:this.toSourcePath(r),headers:s,body:o.body}),l,u=1;try{l=await c()}catch{u=2,l=await c()}if(l.status===412){if(u===2){let t=await this.transport({method:`HEAD`,path:this.toSourcePath(r)});if(t.status>=400)throw new i(`EIO`,`da reconcile HEAD failed: ${t.status}`,e);let a=t.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 i(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(l.status===401||l.status===403)throw new i(`EACCES`,`da write denied`,e);if(l.status>=400)throw new i(`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 i(`ENOENT`,`no such directory`,e);if(r.status>=400)throw new i(`EIO`,`da list failed: ${r.status}`,e);let a=(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,a),a}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(`/`),a=r.pop()??``,o=r.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 i(`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 n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new i(`ENOENT`,`no such file or directory`,e)}throw new i(`EIO`,`da stat failed: ${c.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 i(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new i(`EACCES`,`da delete denied`,e);if(n.status>=400)throw new i(`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 E(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 D=26214400,O=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=E(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??D,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new i(`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 a=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:this.toS3Key(t),headers:r});if(a.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(a.status===404)throw await this.cache.invalidateBody(t),new i(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new i(`EACCES`,`s3 access denied`,e);if(a.status>=400)throw new i(`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 i(`EFBIG`,`body exceeds maxBodyBytes (${s} > ${this.maxBodyBytes})`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new i(`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 n=this.toMountRelative(e);if(t.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=await this.cache.getBody(n),a={"content-type":`application/octet-stream`,"content-length":String(t.byteLength)};r?a[`if-match`]=r.etag:a[`if-none-match`]=`*`;let o=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(n),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 r=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status>=400)throw new i(`EIO`,`s3 reconcile HEAD failed: ${r.status}`,e);let a=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,a);let o=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new i(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(s.status===401||s.status===403)throw new i(`EACCES`,`s3 write denied`,e);if(s.status>=400)throw new i(`EIO`,`s3 writeFile failed: ${s.status}`,e);let l=s.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 i(`EIO`,`s3 list failed: ${r.status}`,`/`);let a=await r.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),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(`/`),a=r.pop()??``,o=r.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 i(`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 n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new i(`ENOENT`,`no such file or directory`,e)}throw new i(`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 n=this.toMountRelative(e);if(t?.recursive)throw new i(`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 i(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new i(`EACCES`,`s3 delete denied`,e);if(r.status>=400)throw new i(`EIO`,`s3 delete failed: ${r.status}`,e);await this.cache.invalidateBody(n);let a=n.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}},k=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function A(){let{getAccounts:t}=await e(async()=>{let{getAccounts:e}=await import(`./account-store-B2fM_hVm.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])),n=t().find(e=>e.providerId===`adobe`);if(!n?.accessToken)throw new k(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>n.accessToken}}var j=r,M=n,N=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),P=new Set([101,103,204,205,304]);function F(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new i(`EACCES`,e.error):e.errorCode===`invalid_request`?new i(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||N.has(String(e.errorCode))?new i(`EIO`,e.error):new i(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=j(e.bodyBase64)}catch(e){throw new i(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let n=P.has(e.status)?null:t;return new Response(n,{status:e.status,headers:new Headers(e.headers)})}async function I(e){throw new i(`EIO`,`mount transport unavailable: setMountCapabilityBroker was never called for this float (composition bug — refusing to guess a transport for a privileged sign-and-forward request)`)}function L(e){return async t=>F(await I({backend:`s3`,envelope:{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}}))}function R(e){let t=e?.getImsToken??(async()=>(await A()).getBearerToken());return async e=>{let n;try{n=await t()}catch(e){throw new i(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}return F(await I({backend:`da`,envelope:{imsToken:n,method:e.method,path:e.path,origin:e.origin,query:e.query,headers:e.headers,bodyBase64:e.body?M(e.body):void 0}}))}}export{p as AemMountBackend,T as DaMountBackend,a as RemoteMountCache,O as S3MountBackend,R as makeSignedFetchDa,L as makeSignedFetchS3};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/account-store-BcQeOBmj.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/preload-helper-Czpn1I53.js","assets/claude-model-version-BJLrDjmH.js","assets/models-BSkXF4T6.js","assets/diagnostics-DN_idNHx.js","assets/provider-env-CTOcDKrQ.js","assets/__vite-browser-external-5eBdwsFd.js","assets/openrouter.models-B-zmcypy.js","assets/libesm-BypnjKEL.js","assets/logger-DDBAeTLF.js","assets/proxied-fetch-CiijUcSt.js","assets/base64-DJRlyqZu.js","assets/fetch-body-D2PwksUW.js","assets/api-endpoint-DGxXvrur.js","assets/runtime-env-Dlaokqg1.js","assets/float-topology-hfgMx1Yq.js","assets/secret-topology-Yt0aO4Gz.js","assets/secrets-bridge-client-BVl0YuB2.js","assets/port-bridge-client-C1tBBqwu.js","assets/image-markers-BFDmhPy4.js","assets/tool-ui-eSQ1g2I1.js","assets/providers-BvcoVwoV.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-D0xZwlMO.js";import{r as n,t as r}from"./base64-DJRlyqZu.js";import{t as i}from"./types-Dgm4REV3.js";import"./mount-table-store-dY2IfQ5S.js";import"./fs-DWYk-XaG.js";import{t as a}from"./remote-cache-3KNT1gsp.js";var o=`https://api.aem.live`,s=`application/folder`,c=5242880;function l(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 u(e){if(!e)return``;let t=Date.parse(e);return Number.isNaN(t)?``:String(t)}function d(e){let t=Date.parse(e??``);return Number.isNaN(t)?0:t}function f(e){return e.map(e=>e[`content-type`]===s||e.name.endsWith(`/`)?{name:e.name.replace(/\/+$/,``),kind:`directory`}:{name:e.name,kind:`file`,size:e.size,etag:u(e[`last-modified`]),lastModified:d(e[`last-modified`])})}var p=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=l(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??c,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new i(`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:o,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 i(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new i(`EACCES`,`aem access denied`,e);if(r.status>=400)throw new i(`EIO`,`aem readFile failed: ${r.status}`,e);let a=new Uint8Array(await r.arrayBuffer());if(a.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);return await this.cache.putBody(t,a,u(r.headers.get(`last-modified`))),a}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 i(`EIO`,`aem precondition HEAD failed: ${r.status}`,e);let a=u(r.headers.get(`last-modified`));if(a&&a!==n)throw await this.cache.invalidateBody(t),new i(`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 i(`EFBIG`,`body exceeds maxBodyBytes`,e);let n=this.toMountRelative(e),r=await this.cache.getBody(n);await this.assertUnchanged(e,n,r?.etag??``);let a=await this.request(`PUT`,this.toSourcePath(n),{body:t});if(a.status===401||a.status===403)throw new i(`EACCES`,`aem write denied`,e);if(a.status>=400)throw new i(`EIO`,`aem writeFile failed: ${a.status}`,e);await this.cache.invalidateBody(n);let o=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o)}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 i(`ENOENT`,`no such directory`,e);if(r.status===401||r.status===403)throw new i(`EACCES`,`aem access denied`,e);if(r.status>=400)throw new i(`EIO`,`aem list failed: ${r.status}`,e);let a=f(await r.json());return await this.cache.putListing(t,a),a}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(`/`),a=r.pop()??``,o=r.join(`/`),s=await this.cache.getListing(o),c=(s&&!this.cache.isStale(s.cachedAt)?s.entries:await this.readDirQuietly(o))?.find(e=>e.name===a);if(!c)throw new i(`ENOENT`,`no such file or directory`,e);return c.kind===`directory`?{kind:`directory`,size:0,mtime:c.lastModified??0}:{kind:`file`,size:c.size??0,mtime:c.lastModified??0,etag:c.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 i(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new i(`EACCES`,`aem delete denied`,e);if(n.status>=400)throw new i(`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=f(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}},m=`\r
3
+ `;function h(){let e=new Uint8Array(16);if(typeof crypto<`u`&&typeof crypto.getRandomValues==`function`)crypto.getRandomValues(e);else for(let t=0;t<e.length;t+=1)e[t]=Math.floor(Math.random()*256);let t=``;for(let n of e)t+=n.toString(16).padStart(2,`0`);return`----SliccFormBoundary${t}`}function g(e,t=h()){let n=new TextEncoder,r=[];for(let i of e){let e=v(_(i.name));if(`file`in i){let a=v(i.file.filename),o=y(i.file.contentType)||`application/octet-stream`;r.push(n.encode(`--${t}${m}Content-Disposition: form-data; name="${e}"; filename="${a}"${m}Content-Type: ${o}${m}${m}`)),r.push(i.file.bytes),r.push(n.encode(m))}else r.push(n.encode(`--${t}${m}Content-Disposition: form-data; name="${e}"${m}${m}${_(i.value)}${m}`))}return r.push(n.encode(`--${t}--${m}`)),{bytes:b(r),contentType:`multipart/form-data; boundary=${t}`,boundary:t}}function _(e){return e.replace(/\r\n|\r|\n/g,m)}function v(e){return e.replace(/\r/g,`%0D`).replace(/\n/g,`%0A`).replace(/"/g,`%22`)}function y(e){return(e??``).replace(/[\r\n]/g,``).trim()}function b(e){let t=0;for(let n of e)t+=n.byteLength;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.byteLength;return n}function x(e,t,n){let r=g([{name:`data`,file:{bytes:n,filename:e,contentType:t}}]);return{contentType:r.contentType,body:r.bytes}}function S(e){return e.split(`/`).pop()||`data`}function C(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 w=5242880,T=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=C(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??w,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new i(`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 a=await this.transport({method:`GET`,path:this.toSourcePath(t),headers:r});if(a.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(a.status===404)throw await this.cache.invalidateBody(t),new i(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new i(`EACCES`,`da access denied`,e);if(a.status>=400)throw new i(`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 i(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=a.headers.get(`etag`)??``,u=l.startsWith(`W/`)?l.slice(2):l;return await this.cache.putBody(t,c,u),c}async writeFile(e,n){if(this.assertOpen(e),n.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=this.toMountRelative(e),a=await this.cache.getBody(r),o=x(S(e),t(e),n),s={"content-type":o.contentType,"content-length":String(o.body.byteLength)};a?.etag?s[`if-match`]=a.etag.startsWith(`W/`)?a.etag.slice(2):a.etag:a||(s[`if-none-match`]=`*`);let c=()=>this.transport({method:`POST`,path:this.toSourcePath(r),headers:s,body:o.body}),l,u=1;try{l=await c()}catch{u=2,l=await c()}if(l.status===412){if(u===2){let t=await this.transport({method:`HEAD`,path:this.toSourcePath(r)});if(t.status>=400)throw new i(`EIO`,`da reconcile HEAD failed: ${t.status}`,e);let a=t.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 i(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(l.status===401||l.status===403)throw new i(`EACCES`,`da write denied`,e);if(l.status>=400)throw new i(`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 i(`ENOENT`,`no such directory`,e);if(r.status>=400)throw new i(`EIO`,`da list failed: ${r.status}`,e);let a=(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,a),a}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(`/`),a=r.pop()??``,o=r.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 i(`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 n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new i(`ENOENT`,`no such file or directory`,e)}throw new i(`EIO`,`da stat failed: ${c.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 i(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new i(`EACCES`,`da delete denied`,e);if(n.status>=400)throw new i(`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 E(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 D=26214400,O=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=E(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??D,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new i(`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 a=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:this.toS3Key(t),headers:r});if(a.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(a.status===404)throw await this.cache.invalidateBody(t),new i(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new i(`EACCES`,`s3 access denied`,e);if(a.status>=400)throw new i(`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 i(`EFBIG`,`body exceeds maxBodyBytes (${s} > ${this.maxBodyBytes})`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new i(`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 n=this.toMountRelative(e);if(t.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=await this.cache.getBody(n),a={"content-type":`application/octet-stream`,"content-length":String(t.byteLength)};r?a[`if-match`]=r.etag:a[`if-none-match`]=`*`;let o=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(n),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 r=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status>=400)throw new i(`EIO`,`s3 reconcile HEAD failed: ${r.status}`,e);let a=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,a);let o=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new i(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(s.status===401||s.status===403)throw new i(`EACCES`,`s3 write denied`,e);if(s.status>=400)throw new i(`EIO`,`s3 writeFile failed: ${s.status}`,e);let l=s.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 i(`EIO`,`s3 list failed: ${r.status}`,`/`);let a=await r.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),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(`/`),a=r.pop()??``,o=r.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 i(`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 n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new i(`ENOENT`,`no such file or directory`,e)}throw new i(`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 n=this.toMountRelative(e);if(t?.recursive)throw new i(`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 i(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new i(`EACCES`,`s3 delete denied`,e);if(r.status>=400)throw new i(`EIO`,`s3 delete failed: ${r.status}`,e);await this.cache.invalidateBody(n);let a=n.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}},k=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function A(){let{getAccounts:t}=await e(async()=>{let{getAccounts:e}=await import(`./account-store-BcQeOBmj.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])),n=t().find(e=>e.providerId===`adobe`);if(!n?.accessToken)throw new k(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>n.accessToken}}var j=r,M=n,N=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),P=new Set([101,103,204,205,304]);function F(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new i(`EACCES`,e.error):e.errorCode===`invalid_request`?new i(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||N.has(String(e.errorCode))?new i(`EIO`,e.error):new i(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=j(e.bodyBase64)}catch(e){throw new i(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let n=P.has(e.status)?null:t;return new Response(n,{status:e.status,headers:new Headers(e.headers)})}async function I(e){throw new i(`EIO`,`mount transport unavailable: setMountCapabilityBroker was never called for this float (composition bug — refusing to guess a transport for a privileged sign-and-forward request)`)}function L(e){return async t=>F(await I({backend:`s3`,envelope:{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}}))}function R(e){let t=e?.getImsToken??(async()=>(await A()).getBearerToken());return async e=>{let n;try{n=await t()}catch(e){throw new i(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}return F(await I({backend:`da`,envelope:{imsToken:n,method:e.method,path:e.path,origin:e.origin,query:e.query,headers:e.headers,bodyBase64:e.body?M(e.body):void 0}}))}}export{p as AemMountBackend,T as DaMountBackend,a as RemoteMountCache,O as S3MountBackend,R as makeSignedFetchDa,L as makeSignedFetchS3};
@@ -1,2 +1,2 @@
1
- import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{i as t,n}from"./mount-index-D9w_zMSm.js";import{a as r,n as i,o as a,r as o,u as s}from"./mount-B4KSGLVw.js";import{n as c}from"./mount-table-store-DrF_Ifaz.js";import{t as l}from"./remote-cache-BE5T1-53.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 r({...t,signedFetch:o(p)}):u===`aem`?new s({...t,signedFetch:i()}):new a({...t,signedFetch:i()});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(`
1
+ import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{i as t,n}from"./mount-index-D9w_zMSm.js";import{a as r,n as i,o as a,r as o,u as s}from"./mount-B9qMwVml.js";import{n as c}from"./mount-table-store-DrF_Ifaz.js";import{t as l}from"./remote-cache-BE5T1-53.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 r({...t,signedFetch:o(p)}):u===`aem`?new s({...t,signedFetch:i()}):new a({...t,signedFetch:i()});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
2
  `)}export{u as n,h as r,_ as t};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/quick-llm-By0alwjq.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/account-store-B2fM_hVm.js","assets/preload-helper-Czpn1I53.js","assets/claude-model-version-BJLrDjmH.js","assets/models-BSkXF4T6.js","assets/diagnostics-DN_idNHx.js","assets/provider-env-CTOcDKrQ.js","assets/__vite-browser-external-5eBdwsFd.js","assets/openrouter.models-B-zmcypy.js","assets/libesm-BypnjKEL.js","assets/logger-DDBAeTLF.js","assets/proxied-fetch-CiijUcSt.js","assets/base64-DJRlyqZu.js","assets/fetch-body-D2PwksUW.js","assets/api-endpoint-DGxXvrur.js","assets/runtime-env-Dlaokqg1.js","assets/float-topology-hfgMx1Yq.js","assets/secret-topology-Yt0aO4Gz.js","assets/secrets-bridge-client-BVl0YuB2.js","assets/port-bridge-client-C1tBBqwu.js","assets/image-markers-BFDmhPy4.js","assets/tool-ui-eSQ1g2I1.js","assets/providers-Cc4NoSCd.js","assets/panel-rpc-B3MSVImO.js","assets/bedrock-camp-compat-CgBMwna8.js","assets/llm-session-id-bZQs6gBN.js","assets/icons-BJsliYCh.js"])))=>i.map(i=>d[i]);
2
- import{L as e,m as t}from"./account-store-B2fM_hVm.js";import{t as n}from"./preload-helper-Czpn1I53.js";import{t as r}from"./logger-DDBAeTLF.js";import{r as i}from"./feature-flags-DaSRRz0w.js";import"./provider-settings-C_7ia6Wg.js";import{t as a}from"./llm-session-id-bZQs6gBN.js";import{t as o}from"./chat-session-store-pWb1-jNp.js";import{a as s,i as c,n as l,r as u,t as d}from"./session-freezer-FCAjtzB9.js";var f=r(`new-session`),p=`ui-new-session`,m=2e4,h=250;async function g(n){try{let r=await n.openVfs(),i=t()??void 0;if(!i)return;let o;try{o=e()}catch{return}let c=o.provider===`adobe`?{"X-Session-Id":a(p)}:void 0;await s({vfs:r,model:o,apiKey:i,headers:c}),n.onComplete?.()}catch(e){f.warn(`Pending session catch-up failed (boot continues)`,{error:e instanceof Error?e.message:String(e)})}}function _(e){(e.schedule??v)(()=>{g(e)})}function v(e){if(typeof globalThis.requestIdleCallback==`function`){globalThis.requestIdleCallback(e,{timeout:5e3});return}setTimeout(e,0)}function y(e){if(i(`agentic-memory`)){if(!e.agenticMemorySpawn){f.info(`Agentic memory enabled but agent bridge unavailable — using legacy enrichment`);return}return e.agenticMemorySpawn}}async function b(e,t,n,r,i,a){let o=await u({sessionStore:t,vfs:e.vfs,mode:`quick`,agenticMemorySpawn:a,cone:e.cone});if(!o)return null;if(e.captureCompleteSnapshot)try{await e.captureCompleteSnapshot(o)}catch(t){let n=t?.code??`unknown`;f.warn(`captureCompleteSnapshot failed`,{code:n}),o.completeSnapshotUnavailable=!0;try{await c(e.vfs,o.filename)}catch{}}return x(e,t,n,r,i,a,o),o}async function x(e,t,r,i,a,o,s){let c=s;try{let t=await l(e.vfs,s,{model:r,apiKey:i,headers:a,skipMemory:!0,pickIcon:e=>n(async()=>{let{pickLucideIcon:e}=await import(`./quick-llm-By0alwjq.js`).then(e=>e.n);return{pickLucideIcon:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27])).then(({pickLucideIcon:t})=>t(e))});t&&(c={...t,archive:s.archive},e.onBackgroundEnriched?.(t))}catch(e){f.warn(`Agentic title enrichment threw (draft stays pending)`,{filename:s.filename,error:e instanceof Error?e.message:String(e)})}let u=await d({sessionStore:t,vfs:e.vfs,mode:`full`,model:r,apiKey:i,headers:a,agenticMemorySpawn:o,cone:e.cone},c).catch(e=>(f.warn(`Agentic memory curator threw (entry stays pending)`,{filename:c.filename,error:e instanceof Error?e.message:String(e)}),null));f.info(`Agentic memory curator finished`,{filename:c.filename,memoryPending:!u||u.memoryPending===!0}),e.onBackgroundEnriched?.(u)}function S(e){return e?.code===`ENOENT`}function C(e,t){return e===t||t.startsWith(e.endsWith(`/`)?e:`${e}/`)}async function w(e,t,n,r){for(let i of n){let n=`${t}/${i.name}`;if(!r.has(n)){if(i.type===`directory`){let t;try{t=await e.readDir(n)}catch(e){if(S(e))continue;throw e}if(await w(e,n,t,r),[...r].some(e=>e.startsWith(`${n}/`)))continue}try{await e.rm(n)}catch(e){if(!S(e))throw e}}}}async function T(e,t){let n=(await e.listMountPoints()).map(({path:e})=>e);if(n.some(e=>C(e,t)))return;let r=new Set(n.filter(e=>e.startsWith(`${t}/`))),i;try{i=await e.readDir(t)}catch(n){if(n?.code!==`ENOENT`)throw n;await e.mkdir(t,{recursive:!0});return}await w(e,t,i,r),await e.mkdir(t,{recursive:!0})}async function E(r){let i=r.enrichmentRaceMs??m,s=t()??void 0,d;try{d=e()}catch(e){f.info(`No active model — freezing without LLM enrichment`,{error:e instanceof Error?e.message:String(e)})}let h=d?.provider===`adobe`?{"X-Session-Id":a(p)}:void 0,g=new o;try{await g.init()}catch(e){return f.warn(`SessionStore init failed — cannot freeze`,{error:e instanceof Error?e.message:String(e)}),null}let _=s&&d?y(r):void 0;if(_)return await b(r,g,d,s,h,_);let v=await u({sessionStore:g,vfs:r.vfs,mode:`quick`,cone:r.cone});if(!v)return null;if(r.captureCompleteSnapshot)try{await r.captureCompleteSnapshot(v)}catch(e){let t=e?.code??`unknown`;f.warn(`captureCompleteSnapshot failed`,{code:t}),v.completeSnapshotUnavailable=!0;try{await c(r.vfs,v.filename)}catch{}}if(!s||!d)return f.info(`Frozen without enrichment (no LLM credentials) — left pending`,{filename:v.filename}),v;let x=d,S=l(r.vfs,v,{model:x,apiKey:s,headers:h,pickIcon:e=>n(async()=>{let{pickLucideIcon:e}=await import(`./quick-llm-By0alwjq.js`).then(e=>e.n);return{pickLucideIcon:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27])).then(({pickLucideIcon:t})=>t(e))}).catch(e=>(f.warn(`Single-click enrichment threw (entry stays pending)`,{filename:v.filename,error:e instanceof Error?e.message:String(e)}),null)),C=await D(S,i,r.onProgress);return C.kind===`llm`?C.updated?{...C.updated,archive:v.archive}:v:(S.then(e=>{f.info(`Background enrichment resolved after race window`,{filename:v.filename,enriched:e?.filename??null}),r.onBackgroundEnriched?.(e)}),v)}async function D(e,t,n){let r=Date.now(),i,a;n?.(0),n&&(i=setInterval(()=>{n(Math.min(1,(Date.now()-r)/t))},h));let o=new Promise(e=>{a=setTimeout(()=>e({kind:`timer`}),t)}),s=e.then(e=>({kind:`llm`,updated:e}));try{return await Promise.race([s,o])}finally{i&&clearInterval(i),a&&clearTimeout(a),n?.(null)}}async function O(e){return A(e,void 0)}async function k(e){return A(e,`skip`)}async function A(e,t){let n=new o;try{await n.init()}catch(e){return f.warn(`SessionStore init failed — cannot quick-freeze`,{error:e instanceof Error?e.message:String(e)}),null}let r=await u({sessionStore:n,vfs:e.vfs,mode:`quick`,cone:e.cone,...t?{memory:t}:{}});if(r&&e.captureCompleteSnapshot)try{await e.captureCompleteSnapshot(r)}catch(t){let n=t?.code??`unknown`;f.warn(`captureCompleteSnapshot failed (quick-freeze)`,{code:n}),r.completeSnapshotUnavailable=!0;try{await c(e.vfs,r.filename)}catch{}}return r}export{T as resetNewSessionTmp,k as runNewSessionArchiveOnly,E as runNewSessionFreeze,O as runNewSessionFreezeQuick,_ as schedulePendingSessionCatchup};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/quick-llm-vmNyLwWF.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/account-store-BcQeOBmj.js","assets/preload-helper-Czpn1I53.js","assets/claude-model-version-BJLrDjmH.js","assets/models-BSkXF4T6.js","assets/diagnostics-DN_idNHx.js","assets/provider-env-CTOcDKrQ.js","assets/__vite-browser-external-5eBdwsFd.js","assets/openrouter.models-B-zmcypy.js","assets/libesm-BypnjKEL.js","assets/logger-DDBAeTLF.js","assets/proxied-fetch-CiijUcSt.js","assets/base64-DJRlyqZu.js","assets/fetch-body-D2PwksUW.js","assets/api-endpoint-DGxXvrur.js","assets/runtime-env-Dlaokqg1.js","assets/float-topology-hfgMx1Yq.js","assets/secret-topology-Yt0aO4Gz.js","assets/secrets-bridge-client-BVl0YuB2.js","assets/port-bridge-client-C1tBBqwu.js","assets/image-markers-BFDmhPy4.js","assets/tool-ui-eSQ1g2I1.js","assets/providers-BvcoVwoV.js","assets/panel-rpc-B3MSVImO.js","assets/bedrock-camp-compat-CgBMwna8.js","assets/llm-session-id-bZQs6gBN.js","assets/icons-ClfjE6Ij.js"])))=>i.map(i=>d[i]);
2
+ import{L as e,m as t}from"./account-store-BcQeOBmj.js";import{t as n}from"./preload-helper-Czpn1I53.js";import{t as r}from"./logger-DDBAeTLF.js";import{r as i}from"./feature-flags-DaSRRz0w.js";import"./provider-settings-DxvegOPb.js";import{t as a}from"./llm-session-id-bZQs6gBN.js";import{t as o}from"./chat-session-store-pWb1-jNp.js";import{a as s,i as c,n as l,r as u,t as d}from"./session-freezer-ChfPSkjG.js";var f=r(`new-session`),p=`ui-new-session`,m=2e4,h=250;async function g(n){try{let r=await n.openVfs(),i=t()??void 0;if(!i)return;let o;try{o=e()}catch{return}let c=o.provider===`adobe`?{"X-Session-Id":a(p)}:void 0;await s({vfs:r,model:o,apiKey:i,headers:c}),n.onComplete?.()}catch(e){f.warn(`Pending session catch-up failed (boot continues)`,{error:e instanceof Error?e.message:String(e)})}}function _(e){(e.schedule??v)(()=>{g(e)})}function v(e){if(typeof globalThis.requestIdleCallback==`function`){globalThis.requestIdleCallback(e,{timeout:5e3});return}setTimeout(e,0)}function y(e){if(i(`agentic-memory`)){if(!e.agenticMemorySpawn){f.info(`Agentic memory enabled but agent bridge unavailable — using legacy enrichment`);return}return e.agenticMemorySpawn}}async function b(e,t,n,r,i,a){let o=await u({sessionStore:t,vfs:e.vfs,mode:`quick`,agenticMemorySpawn:a,cone:e.cone});if(!o)return null;if(e.captureCompleteSnapshot)try{await e.captureCompleteSnapshot(o)}catch(t){let n=t?.code??`unknown`;f.warn(`captureCompleteSnapshot failed`,{code:n}),o.completeSnapshotUnavailable=!0;try{await c(e.vfs,o.filename)}catch{}}return x(e,t,n,r,i,a,o),o}async function x(e,t,r,i,a,o,s){let c=s;try{let t=await l(e.vfs,s,{model:r,apiKey:i,headers:a,skipMemory:!0,pickIcon:e=>n(async()=>{let{pickLucideIcon:e}=await import(`./quick-llm-vmNyLwWF.js`).then(e=>e.n);return{pickLucideIcon:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27])).then(({pickLucideIcon:t})=>t(e))});t&&(c={...t,archive:s.archive},e.onBackgroundEnriched?.(t))}catch(e){f.warn(`Agentic title enrichment threw (draft stays pending)`,{filename:s.filename,error:e instanceof Error?e.message:String(e)})}let u=await d({sessionStore:t,vfs:e.vfs,mode:`full`,model:r,apiKey:i,headers:a,agenticMemorySpawn:o,cone:e.cone},c).catch(e=>(f.warn(`Agentic memory curator threw (entry stays pending)`,{filename:c.filename,error:e instanceof Error?e.message:String(e)}),null));f.info(`Agentic memory curator finished`,{filename:c.filename,memoryPending:!u||u.memoryPending===!0}),e.onBackgroundEnriched?.(u)}function S(e){return e?.code===`ENOENT`}function C(e,t){return e===t||t.startsWith(e.endsWith(`/`)?e:`${e}/`)}async function w(e,t,n,r){for(let i of n){let n=`${t}/${i.name}`;if(!r.has(n)){if(i.type===`directory`){let t;try{t=await e.readDir(n)}catch(e){if(S(e))continue;throw e}if(await w(e,n,t,r),[...r].some(e=>e.startsWith(`${n}/`)))continue}try{await e.rm(n)}catch(e){if(!S(e))throw e}}}}async function T(e,t){let n=(await e.listMountPoints()).map(({path:e})=>e);if(n.some(e=>C(e,t)))return;let r=new Set(n.filter(e=>e.startsWith(`${t}/`))),i;try{i=await e.readDir(t)}catch(n){if(n?.code!==`ENOENT`)throw n;await e.mkdir(t,{recursive:!0});return}await w(e,t,i,r),await e.mkdir(t,{recursive:!0})}async function E(r){let i=r.enrichmentRaceMs??m,s=t()??void 0,d;try{d=e()}catch(e){f.info(`No active model — freezing without LLM enrichment`,{error:e instanceof Error?e.message:String(e)})}let h=d?.provider===`adobe`?{"X-Session-Id":a(p)}:void 0,g=new o;try{await g.init()}catch(e){return f.warn(`SessionStore init failed — cannot freeze`,{error:e instanceof Error?e.message:String(e)}),null}let _=s&&d?y(r):void 0;if(_)return await b(r,g,d,s,h,_);let v=await u({sessionStore:g,vfs:r.vfs,mode:`quick`,cone:r.cone});if(!v)return null;if(r.captureCompleteSnapshot)try{await r.captureCompleteSnapshot(v)}catch(e){let t=e?.code??`unknown`;f.warn(`captureCompleteSnapshot failed`,{code:t}),v.completeSnapshotUnavailable=!0;try{await c(r.vfs,v.filename)}catch{}}if(!s||!d)return f.info(`Frozen without enrichment (no LLM credentials) — left pending`,{filename:v.filename}),v;let x=d,S=l(r.vfs,v,{model:x,apiKey:s,headers:h,pickIcon:e=>n(async()=>{let{pickLucideIcon:e}=await import(`./quick-llm-vmNyLwWF.js`).then(e=>e.n);return{pickLucideIcon:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27])).then(({pickLucideIcon:t})=>t(e))}).catch(e=>(f.warn(`Single-click enrichment threw (entry stays pending)`,{filename:v.filename,error:e instanceof Error?e.message:String(e)}),null)),C=await D(S,i,r.onProgress);return C.kind===`llm`?C.updated?{...C.updated,archive:v.archive}:v:(S.then(e=>{f.info(`Background enrichment resolved after race window`,{filename:v.filename,enriched:e?.filename??null}),r.onBackgroundEnriched?.(e)}),v)}async function D(e,t,n){let r=Date.now(),i,a;n?.(0),n&&(i=setInterval(()=>{n(Math.min(1,(Date.now()-r)/t))},h));let o=new Promise(e=>{a=setTimeout(()=>e({kind:`timer`}),t)}),s=e.then(e=>({kind:`llm`,updated:e}));try{return await Promise.race([s,o])}finally{i&&clearInterval(i),a&&clearTimeout(a),n?.(null)}}async function O(e){return A(e,void 0)}async function k(e){return A(e,`skip`)}async function A(e,t){let n=new o;try{await n.init()}catch(e){return f.warn(`SessionStore init failed — cannot quick-freeze`,{error:e instanceof Error?e.message:String(e)}),null}let r=await u({sessionStore:n,vfs:e.vfs,mode:`quick`,cone:e.cone,...t?{memory:t}:{}});if(r&&e.captureCompleteSnapshot)try{await e.captureCompleteSnapshot(r)}catch(t){let n=t?.code??`unknown`;f.warn(`captureCompleteSnapshot failed (quick-freeze)`,{code:n}),r.completeSnapshotUnavailable=!0;try{await c(e.vfs,r.filename)}catch{}}return r}export{T as resetNewSessionTmp,k as runNewSessionArchiveOnly,E as runNewSessionFreeze,O as runNewSessionFreezeQuick,_ as schedulePendingSessionCatchup};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/provider-CuvQQp10.js","assets/account-store-B2fM_hVm.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/preload-helper-Czpn1I53.js","assets/claude-model-version-BJLrDjmH.js","assets/models-BSkXF4T6.js","assets/diagnostics-DN_idNHx.js","assets/provider-env-CTOcDKrQ.js","assets/__vite-browser-external-5eBdwsFd.js","assets/openrouter.models-B-zmcypy.js","assets/libesm-BypnjKEL.js","assets/logger-DDBAeTLF.js","assets/proxied-fetch-CiijUcSt.js","assets/base64-DJRlyqZu.js","assets/fetch-body-D2PwksUW.js","assets/api-endpoint-DGxXvrur.js","assets/runtime-env-Dlaokqg1.js","assets/float-topology-hfgMx1Yq.js","assets/secret-topology-Yt0aO4Gz.js","assets/secrets-bridge-client-BVl0YuB2.js","assets/port-bridge-client-C1tBBqwu.js","assets/image-markers-BFDmhPy4.js","assets/tool-ui-eSQ1g2I1.js","assets/providers-Cc4NoSCd.js","assets/panel-rpc-B3MSVImO.js","assets/bedrock-camp-compat-CgBMwna8.js","assets/pkce-hGf_TEnP.js","assets/provider-store-access-CMt1lgF6.js","assets/global-db-CbuLl-zx.js","assets/types-Dgm4REV3.js"])))=>i.map(i=>d[i]);
2
- import{H as e,d as t}from"./account-store-B2fM_hVm.js";import{t as n}from"./preload-helper-Czpn1I53.js";import{t as r}from"./logger-DDBAeTLF.js";import{t as i}from"./providers-Cc4NoSCd.js";import"./provider-settings-C_7ia6Wg.js";import"./logger-BoSvu4mW.js";var a=r(`oauth-bootstrap`),o=6e4;function s(e){return e instanceof Error?e.message:String(e)}async function c(){try{let{ensureAllMcpProvidersRegistered:e}=await n(async()=>{let{ensureAllMcpProvidersRegistered:e}=await import(`./provider-CuvQQp10.js`);return{ensureAllMcpProvidersRegistered:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29])),t=await e();t.length>0&&a.debug(`Pre-registered MCP providers for OAuth bootstrap`,{count:t.length})}catch(e){a.warn(`Failed to pre-register MCP providers for OAuth bootstrap`,{error:s(e)})}}function l(e){return(e.tokenExpiresAt??1/0)-Date.now()<=o}async function u(e){let t=i(e.providerId);if(!t?.onSilentRenew){a.debug(`Skipping expired account (no silent-renew hook)`,{providerId:e.providerId});return}try{if(await t.onSilentRenew()){a.info(`Silently renewed OAuth token`,{providerId:e.providerId});return}a.warn(`Silent renewal yielded no token; user must re-authenticate`,{providerId:e.providerId})}catch(t){a.warn(`Silent renewal failed`,{providerId:e.providerId,error:s(t)})}}async function d(t,n){try{await e({providerId:t.providerId,accessToken:n,refreshToken:t.refreshToken,tokenExpiresAt:t.tokenExpiresAt,userName:t.userName,userAvatar:t.userAvatar}),a.debug(`Bootstrapped OAuth replica`,{providerId:t.providerId})}catch(e){a.error(`OAuth bootstrap failed`,{providerId:t.providerId,error:s(e)})}}async function f(e){let t=e.accessToken;if(!t){a.debug(`Skipping account without token`,{providerId:e.providerId});return}if(l(e)){await u(e);return}await d(e,t)}async function p(){await c();let e=t();a.info(`Bootstrap OAuth replicas`,{count:e.length});for(let t of e)await f(t)}export{p as bootstrapOAuthReplicas};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/provider-BJTW8Inb.js","assets/account-store-BcQeOBmj.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/preload-helper-Czpn1I53.js","assets/claude-model-version-BJLrDjmH.js","assets/models-BSkXF4T6.js","assets/diagnostics-DN_idNHx.js","assets/provider-env-CTOcDKrQ.js","assets/__vite-browser-external-5eBdwsFd.js","assets/openrouter.models-B-zmcypy.js","assets/libesm-BypnjKEL.js","assets/logger-DDBAeTLF.js","assets/proxied-fetch-CiijUcSt.js","assets/base64-DJRlyqZu.js","assets/fetch-body-D2PwksUW.js","assets/api-endpoint-DGxXvrur.js","assets/runtime-env-Dlaokqg1.js","assets/float-topology-hfgMx1Yq.js","assets/secret-topology-Yt0aO4Gz.js","assets/secrets-bridge-client-BVl0YuB2.js","assets/port-bridge-client-C1tBBqwu.js","assets/image-markers-BFDmhPy4.js","assets/tool-ui-eSQ1g2I1.js","assets/providers-BvcoVwoV.js","assets/panel-rpc-B3MSVImO.js","assets/bedrock-camp-compat-CgBMwna8.js","assets/pkce-hGf_TEnP.js","assets/provider-store-access-P8QylrtO.js","assets/global-db-CbuLl-zx.js","assets/types-Dgm4REV3.js"])))=>i.map(i=>d[i]);
2
+ import{H as e,d as t}from"./account-store-BcQeOBmj.js";import{t as n}from"./preload-helper-Czpn1I53.js";import{t as r}from"./logger-DDBAeTLF.js";import{t as i}from"./providers-BvcoVwoV.js";import"./provider-settings-DxvegOPb.js";import"./logger-BoSvu4mW.js";var a=r(`oauth-bootstrap`),o=6e4;function s(e){return e instanceof Error?e.message:String(e)}async function c(){try{let{ensureAllMcpProvidersRegistered:e}=await n(async()=>{let{ensureAllMcpProvidersRegistered:e}=await import(`./provider-BJTW8Inb.js`);return{ensureAllMcpProvidersRegistered:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29])),t=await e();t.length>0&&a.debug(`Pre-registered MCP providers for OAuth bootstrap`,{count:t.length})}catch(e){a.warn(`Failed to pre-register MCP providers for OAuth bootstrap`,{error:s(e)})}}function l(e){return(e.tokenExpiresAt??1/0)-Date.now()<=o}async function u(e){let t=i(e.providerId);if(!t?.onSilentRenew){a.debug(`Skipping expired account (no silent-renew hook)`,{providerId:e.providerId});return}try{if(await t.onSilentRenew()){a.info(`Silently renewed OAuth token`,{providerId:e.providerId});return}a.warn(`Silent renewal yielded no token; user must re-authenticate`,{providerId:e.providerId})}catch(t){a.warn(`Silent renewal failed`,{providerId:e.providerId,error:s(t)})}}async function d(t,n){try{await e({providerId:t.providerId,accessToken:n,refreshToken:t.refreshToken,tokenExpiresAt:t.tokenExpiresAt,userName:t.userName,userAvatar:t.userAvatar}),a.debug(`Bootstrapped OAuth replica`,{providerId:t.providerId})}catch(e){a.error(`OAuth bootstrap failed`,{providerId:t.providerId,error:s(e)})}}async function f(e){let t=e.accessToken;if(!t){a.debug(`Skipping account without token`,{providerId:e.providerId});return}if(l(e)){await u(e);return}await d(e,t)}async function p(){await c();let e=t();a.info(`Bootstrap OAuth replicas`,{count:e.length});for(let t of e)await f(t)}export{p as bootstrapOAuthReplicas};
@@ -1 +1 @@
1
- import{H as e,d as t}from"./account-store-B2fM_hVm.js";import{a as n}from"./diagnostics-DN_idNHx.js";import{u as r}from"./claude-model-version-BJLrDjmH.js";import{n as i,o as a}from"./legacy-api-aliases-45zvHmpJ.js";import"./provider-settings-C_7ia6Wg.js";import{n as o,r as s,t as c}from"./pkce-hGf_TEnP.js";var l=`openai-codex`,u=`app_EMoamEEZ73f0CkXaXp7hrann`,d=`https://auth.openai.com/oauth/authorize`,f=`https://auth.openai.com/oauth/token`,p=`openid profile email offline_access`,m=`http://localhost:1455/auth/callback`,h=`http://localhost:1455/auth/callback*`,g=`https://chatgpt.com/backend-api`,_=`openai-codex-responses`,v=`${l}-openai`,y={xhigh:`xhigh`,minimal:`low`},b=[{id:`gpt-5.5`,name:`GPT-5.5`,input:[`text`,`image`]},{id:`gpt-5.4`,name:`GPT-5.4`,input:[`text`,`image`]},{id:`gpt-5.4-mini`,name:`GPT-5.4 mini`,input:[`text`,`image`]},{id:`gpt-5.3-codex`,name:`GPT-5.3 Codex`,input:[`text`,`image`]},{id:`gpt-5.3-codex-spark`,name:`GPT-5.3 Codex Spark`,input:[`text`]},{id:`gpt-5.2`,name:`GPT-5.2`,input:[`text`,`image`]}].map(e=>({...e,api:`openai`,reasoning:!0,context_window:272e3,max_tokens:128e3,thinkingLevelMap:y}));async function x(e,t){let n=new URLSearchParams({grant_type:`authorization_code`,client_id:u,code:e,code_verifier:t,redirect_uri:m}),r=await fetch(f,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:n});if(!r.ok)throw Error(`OpenAI Codex token exchange failed: ${r.status} ${await r.text()}`);let i=await r.json();if(!i.access_token)throw Error(`OpenAI Codex token exchange did not return access_token.`);return i}async function S(e){try{let t=new URLSearchParams({grant_type:`refresh_token`,refresh_token:e,client_id:u}),n=await fetch(f,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:t});return n.ok?await n.json():(console.error(`[openai-codex] refresh failed:`,n.status,await n.text()),null)}catch(e){return console.error(`[openai-codex] refresh error:`,e instanceof Error?e.message:String(e)),null}}function C(e){try{let t=e.split(`.`);if(t.length!==3)return;let n=t[1].replace(/-/g,`+`).replace(/_/g,`/`);return n.length%4&&(n+=`=`.repeat(4-n.length%4)),JSON.parse(atob(n))}catch{return}}function w(e){let t=C(e)?.[`https://api.openai.com/profile`]?.email;return typeof t==`string`?t:void 0}function T(e){let t=C(e)?.[`https://api.openai.com/auth`],n=w(e),r=typeof t?.chatgpt_plan_type==`string`?t.chatgpt_plan_type:void 0,i=r?r.charAt(0).toUpperCase()+r.slice(1):void 0;if(n&&i)return`${n} (${i})`;if(n)return n;if(i)return`ChatGPT ${i}`}async function E(e){let t=w(e);if(t)try{let e=t.trim().toLowerCase(),n=new Uint8Array(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e)));return`https://www.gravatar.com/avatar/${Array.from(n).map(e=>e.toString(16).padStart(2,`0`)).join(``)}?s=128&d=404`}catch{return}}function D(){return t().find(e=>e.providerId===l)}async function O(){let t=D();if(!t?.accessToken)throw Error("Not signed in to OpenAI Codex — run `oauth-token openai-codex` or /login");let n=t.tokenExpiresAt??0;if(n&&Date.now()+6e4<n)return t.accessToken;if(t.refreshToken){let n=await S(t.refreshToken);if(n?.access_token)return await e({providerId:l,accessToken:n.access_token,refreshToken:n.refresh_token??t.refreshToken,tokenExpiresAt:Date.now()+(n.expires_in??3600)*1e3,baseUrl:g,userName:T(n.access_token),userAvatar:await E(n.access_token),scopes:n.scope??t.scopes}),n.access_token}return t.accessToken}function k(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:v,provider:l,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 A(e){console.error(`[openai-codex] Stream error:`,e instanceof Error?e.message:String(e))}async function j(e,t,n,r){try{let a=await O(),o={...t,baseUrl:g,api:_},s=i(o,n,{...r,apiKey:a,transport:`sse`});for await(let t of s)e.push(t);e.end()}catch(n){A(n),e.push(k(t,n)),e.end()}}async function M(e,t,n,r){try{let i=await O(),o={...t,baseUrl:g,api:_},s=a(o,n,{...r,apiKey:i,transport:`sse`});for await(let t of s)e.push(t);e.end()}catch(n){A(n),e.push(k(t,n)),e.end()}}var N=(e,t,r={})=>{let i=n();return j(i,e,t,r).catch(A),i},P=(e,t,r)=>{let i=n();return M(i,e,t,r).catch(A),i},F={id:l,name:`OpenAI Codex (ChatGPT Subscription)`,description:`GPT-5 Codex via your ChatGPT Plus/Pro/Business subscription — OAuth login, no API key needed. Default model is GPT-5.5.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:`gpt-5.5`,oauthTokenDomains:[`chatgpt.com`,`*.chatgpt.com`,`auth.openai.com`,`api.openai.com`],getModelIds:()=>b,onOAuthLoginIntercepted:async(t,n,r)=>{let i=o(),a=await c(i),f=s(),_=new URL(d);_.searchParams.set(`response_type`,`code`),_.searchParams.set(`client_id`,u),_.searchParams.set(`redirect_uri`,m),_.searchParams.set(`scope`,r?.scopes??p),_.searchParams.set(`code_challenge`,a),_.searchParams.set(`code_challenge_method`,`S256`),_.searchParams.set(`state`,f),_.searchParams.set(`id_token_add_organizations`,`true`),_.searchParams.set(`codex_cli_simplified_flow`,`true`),_.searchParams.set(`originator`,`pi`);let v=await t({authorizeUrl:_.toString(),redirectUriPattern:h,onCapture:`close`});if(!v)throw Error(`OpenAI Codex OAuth login was cancelled or timed out`);let y=new URL(v),b=y.searchParams.get(`code`),S=y.searchParams.get(`state`);if(!b)throw Error(`OpenAI Codex OAuth redirect did not include a code`);if(S!==f)throw Error(`OpenAI Codex OAuth state mismatch — possible CSRF, aborting`);let C=await x(b,i);await e({providerId:l,accessToken:C.access_token,refreshToken:C.refresh_token,tokenExpiresAt:Date.now()+(C.expires_in??3600)*1e3,baseUrl:g,userName:T(C.access_token),userAvatar:await E(C.access_token),scopes:C.scope}),n()},onOAuthLogout:async()=>{await e({providerId:l,accessToken:``})},onSilentRenew:async()=>{let t=D();if(!t?.refreshToken)return null;let n=await S(t.refreshToken);return n?.access_token?(await e({providerId:l,accessToken:n.access_token,refreshToken:n.refresh_token??t.refreshToken,tokenExpiresAt:Date.now()+(n.expires_in??3600)*1e3,baseUrl:g,userName:T(n.access_token),userAvatar:await E(n.access_token),scopes:n.scope??t.scopes}),n.access_token):null}};function I(){r({api:v,stream:N,streamSimple:P})}export{F as config,I as register};
1
+ import{H as e,d as t}from"./account-store-BcQeOBmj.js";import{a as n}from"./diagnostics-DN_idNHx.js";import{u as r}from"./claude-model-version-BJLrDjmH.js";import{n as i,o as a}from"./legacy-api-aliases-45zvHmpJ.js";import"./provider-settings-DxvegOPb.js";import{n as o,r as s,t as c}from"./pkce-hGf_TEnP.js";var l=`openai-codex`,u=`app_EMoamEEZ73f0CkXaXp7hrann`,d=`https://auth.openai.com/oauth/authorize`,f=`https://auth.openai.com/oauth/token`,p=`openid profile email offline_access`,m=`http://localhost:1455/auth/callback`,h=`http://localhost:1455/auth/callback*`,g=`https://chatgpt.com/backend-api`,_=`openai-codex-responses`,v=`${l}-openai`,y={xhigh:`xhigh`,minimal:`low`},b=[{id:`gpt-5.5`,name:`GPT-5.5`,input:[`text`,`image`]},{id:`gpt-5.4`,name:`GPT-5.4`,input:[`text`,`image`]},{id:`gpt-5.4-mini`,name:`GPT-5.4 mini`,input:[`text`,`image`]},{id:`gpt-5.3-codex`,name:`GPT-5.3 Codex`,input:[`text`,`image`]},{id:`gpt-5.3-codex-spark`,name:`GPT-5.3 Codex Spark`,input:[`text`]},{id:`gpt-5.2`,name:`GPT-5.2`,input:[`text`,`image`]}].map(e=>({...e,api:`openai`,reasoning:!0,context_window:272e3,max_tokens:128e3,thinkingLevelMap:y}));async function x(e,t){let n=new URLSearchParams({grant_type:`authorization_code`,client_id:u,code:e,code_verifier:t,redirect_uri:m}),r=await fetch(f,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:n});if(!r.ok)throw Error(`OpenAI Codex token exchange failed: ${r.status} ${await r.text()}`);let i=await r.json();if(!i.access_token)throw Error(`OpenAI Codex token exchange did not return access_token.`);return i}async function S(e){try{let t=new URLSearchParams({grant_type:`refresh_token`,refresh_token:e,client_id:u}),n=await fetch(f,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:t});return n.ok?await n.json():(console.error(`[openai-codex] refresh failed:`,n.status,await n.text()),null)}catch(e){return console.error(`[openai-codex] refresh error:`,e instanceof Error?e.message:String(e)),null}}function C(e){try{let t=e.split(`.`);if(t.length!==3)return;let n=t[1].replace(/-/g,`+`).replace(/_/g,`/`);return n.length%4&&(n+=`=`.repeat(4-n.length%4)),JSON.parse(atob(n))}catch{return}}function w(e){let t=C(e)?.[`https://api.openai.com/profile`]?.email;return typeof t==`string`?t:void 0}function T(e){let t=C(e)?.[`https://api.openai.com/auth`],n=w(e),r=typeof t?.chatgpt_plan_type==`string`?t.chatgpt_plan_type:void 0,i=r?r.charAt(0).toUpperCase()+r.slice(1):void 0;if(n&&i)return`${n} (${i})`;if(n)return n;if(i)return`ChatGPT ${i}`}async function E(e){let t=w(e);if(t)try{let e=t.trim().toLowerCase(),n=new Uint8Array(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e)));return`https://www.gravatar.com/avatar/${Array.from(n).map(e=>e.toString(16).padStart(2,`0`)).join(``)}?s=128&d=404`}catch{return}}function D(){return t().find(e=>e.providerId===l)}async function O(){let t=D();if(!t?.accessToken)throw Error("Not signed in to OpenAI Codex — run `oauth-token openai-codex` or /login");let n=t.tokenExpiresAt??0;if(n&&Date.now()+6e4<n)return t.accessToken;if(t.refreshToken){let n=await S(t.refreshToken);if(n?.access_token)return await e({providerId:l,accessToken:n.access_token,refreshToken:n.refresh_token??t.refreshToken,tokenExpiresAt:Date.now()+(n.expires_in??3600)*1e3,baseUrl:g,userName:T(n.access_token),userAvatar:await E(n.access_token),scopes:n.scope??t.scopes}),n.access_token}return t.accessToken}function k(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:v,provider:l,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 A(e){console.error(`[openai-codex] Stream error:`,e instanceof Error?e.message:String(e))}async function j(e,t,n,r){try{let a=await O(),o={...t,baseUrl:g,api:_},s=i(o,n,{...r,apiKey:a,transport:`sse`});for await(let t of s)e.push(t);e.end()}catch(n){A(n),e.push(k(t,n)),e.end()}}async function M(e,t,n,r){try{let i=await O(),o={...t,baseUrl:g,api:_},s=a(o,n,{...r,apiKey:i,transport:`sse`});for await(let t of s)e.push(t);e.end()}catch(n){A(n),e.push(k(t,n)),e.end()}}var N=(e,t,r={})=>{let i=n();return j(i,e,t,r).catch(A),i},P=(e,t,r)=>{let i=n();return M(i,e,t,r).catch(A),i},F={id:l,name:`OpenAI Codex (ChatGPT Subscription)`,description:`GPT-5 Codex via your ChatGPT Plus/Pro/Business subscription — OAuth login, no API key needed. Default model is GPT-5.5.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:`gpt-5.5`,oauthTokenDomains:[`chatgpt.com`,`*.chatgpt.com`,`auth.openai.com`,`api.openai.com`],getModelIds:()=>b,onOAuthLoginIntercepted:async(t,n,r)=>{let i=o(),a=await c(i),f=s(),_=new URL(d);_.searchParams.set(`response_type`,`code`),_.searchParams.set(`client_id`,u),_.searchParams.set(`redirect_uri`,m),_.searchParams.set(`scope`,r?.scopes??p),_.searchParams.set(`code_challenge`,a),_.searchParams.set(`code_challenge_method`,`S256`),_.searchParams.set(`state`,f),_.searchParams.set(`id_token_add_organizations`,`true`),_.searchParams.set(`codex_cli_simplified_flow`,`true`),_.searchParams.set(`originator`,`pi`);let v=await t({authorizeUrl:_.toString(),redirectUriPattern:h,onCapture:`close`});if(!v)throw Error(`OpenAI Codex OAuth login was cancelled or timed out`);let y=new URL(v),b=y.searchParams.get(`code`),S=y.searchParams.get(`state`);if(!b)throw Error(`OpenAI Codex OAuth redirect did not include a code`);if(S!==f)throw Error(`OpenAI Codex OAuth state mismatch — possible CSRF, aborting`);let C=await x(b,i);await e({providerId:l,accessToken:C.access_token,refreshToken:C.refresh_token,tokenExpiresAt:Date.now()+(C.expires_in??3600)*1e3,baseUrl:g,userName:T(C.access_token),userAvatar:await E(C.access_token),scopes:C.scope}),n()},onOAuthLogout:async()=>{await e({providerId:l,accessToken:``})},onSilentRenew:async()=>{let t=D();if(!t?.refreshToken)return null;let n=await S(t.refreshToken);return n?.access_token?(await e({providerId:l,accessToken:n.access_token,refreshToken:n.refresh_token??t.refreshToken,tokenExpiresAt:Date.now()+(n.expires_in??3600)*1e3,baseUrl:g,userName:T(n.access_token),userAvatar:await E(n.access_token),scopes:n.scope??t.scopes}),n.access_token):null}};function I(){r({api:v,stream:N,streamSimple:P})}export{F as config,I as register};
@@ -1 +1 @@
1
- import{g as e,n as t}from"./account-store-CnTVyV3B.js";import{a as n}from"./diagnostics-DN_idNHx.js";import{a as r}from"./compat-uEPf6-XW.js";import{n as i,o as a}from"./legacy-api-aliases-jKEvBgOL.js";import"./provider-settings-s-43s4y0.js";import{n as o,r as s,t as c}from"./pkce-hGf_TEnP.js";const l=`openai-codex`,u=`app_EMoamEEZ73f0CkXaXp7hrann`,d=`https://auth.openai.com/oauth/token`,f=`http://localhost:1455/auth/callback`,p=`https://chatgpt.com/backend-api`,m=`openai-codex-responses`,h=`${l}-openai`,g={xhigh:`xhigh`,minimal:`low`},_=[{id:`gpt-5.5`,name:`GPT-5.5`,input:[`text`,`image`]},{id:`gpt-5.4`,name:`GPT-5.4`,input:[`text`,`image`]},{id:`gpt-5.4-mini`,name:`GPT-5.4 mini`,input:[`text`,`image`]},{id:`gpt-5.3-codex`,name:`GPT-5.3 Codex`,input:[`text`,`image`]},{id:`gpt-5.3-codex-spark`,name:`GPT-5.3 Codex Spark`,input:[`text`]},{id:`gpt-5.2`,name:`GPT-5.2`,input:[`text`,`image`]}].map(e=>({...e,api:`openai`,reasoning:!0,context_window:272e3,max_tokens:128e3,thinkingLevelMap:g}));async function v(e,t){let n=new URLSearchParams({grant_type:`authorization_code`,client_id:u,code:e,code_verifier:t,redirect_uri:f}),r=await fetch(d,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:n});if(!r.ok)throw Error(`OpenAI Codex token exchange failed: ${r.status} ${await r.text()}`);let i=await r.json();if(!i.access_token)throw Error(`OpenAI Codex token exchange did not return access_token.`);return i}async function y(e){try{let t=new URLSearchParams({grant_type:`refresh_token`,refresh_token:e,client_id:u}),n=await fetch(d,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:t});return n.ok?await n.json():(console.error(`[openai-codex] refresh failed:`,n.status,await n.text()),null)}catch(e){return console.error(`[openai-codex] refresh error:`,e instanceof Error?e.message:String(e)),null}}function b(e){try{let t=e.split(`.`);if(t.length!==3)return;let n=t[1].replace(/-/g,`+`).replace(/_/g,`/`);return n.length%4&&(n+=`=`.repeat(4-n.length%4)),JSON.parse(atob(n))}catch{return}}function x(e){let t=b(e)?.[`https://api.openai.com/profile`]?.email;return typeof t==`string`?t:void 0}function S(e){let t=b(e)?.[`https://api.openai.com/auth`],n=x(e),r=typeof t?.chatgpt_plan_type==`string`?t.chatgpt_plan_type:void 0,i=r?r.charAt(0).toUpperCase()+r.slice(1):void 0;if(n&&i)return`${n} (${i})`;if(n)return n;if(i)return`ChatGPT ${i}`}async function C(e){let t=x(e);if(t)try{let e=t.trim().toLowerCase(),n=new Uint8Array(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e)));return`https://www.gravatar.com/avatar/${Array.from(n).map(e=>e.toString(16).padStart(2,`0`)).join(``)}?s=128&d=404`}catch{return}}function w(){return t().find(e=>e.providerId===l)}async function T(){let t=w();if(!t?.accessToken)throw Error("Not signed in to OpenAI Codex — run `oauth-token openai-codex` or /login");let n=t.tokenExpiresAt??0;if(n&&Date.now()+6e4<n)return t.accessToken;if(t.refreshToken){let n=await y(t.refreshToken);if(n?.access_token)return await e({providerId:l,accessToken:n.access_token,refreshToken:n.refresh_token??t.refreshToken,tokenExpiresAt:Date.now()+(n.expires_in??3600)*1e3,baseUrl:p,userName:S(n.access_token),userAvatar:await C(n.access_token),scopes:n.scope??t.scopes}),n.access_token}return t.accessToken}function E(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:h,provider:l,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 D(e){console.error(`[openai-codex] Stream error:`,e instanceof Error?e.message:String(e))}async function O(e,t,n,r){try{let a=await T(),o={...t,baseUrl:p,api:m},s=i(o,n,{...r,apiKey:a,transport:`sse`});for await(let t of s)e.push(t);e.end()}catch(n){D(n),e.push(E(t,n)),e.end()}}async function k(e,t,n,r){try{let i=await T(),o={...t,baseUrl:p,api:m},s=a(o,n,{...r,apiKey:i,transport:`sse`});for await(let t of s)e.push(t);e.end()}catch(n){D(n),e.push(E(t,n)),e.end()}}const A=(e,t,r={})=>{let i=n();return O(i,e,t,r).catch(D),i},j=(e,t,r)=>{let i=n();return k(i,e,t,r).catch(D),i},M={id:l,name:`OpenAI Codex (ChatGPT Subscription)`,description:`GPT-5 Codex via your ChatGPT Plus/Pro/Business subscription — OAuth login, no API key needed. Default model is GPT-5.5.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:`gpt-5.5`,oauthTokenDomains:[`chatgpt.com`,`*.chatgpt.com`,`auth.openai.com`,`api.openai.com`],getModelIds:()=>_,onOAuthLoginIntercepted:async(t,n,r)=>{let i=o(),a=await c(i),d=s(),m=new URL(`https://auth.openai.com/oauth/authorize`);m.searchParams.set(`response_type`,`code`),m.searchParams.set(`client_id`,u),m.searchParams.set(`redirect_uri`,f),m.searchParams.set(`scope`,r?.scopes??`openid profile email offline_access`),m.searchParams.set(`code_challenge`,a),m.searchParams.set(`code_challenge_method`,`S256`),m.searchParams.set(`state`,d),m.searchParams.set(`id_token_add_organizations`,`true`),m.searchParams.set(`codex_cli_simplified_flow`,`true`),m.searchParams.set(`originator`,`pi`);let h=await t({authorizeUrl:m.toString(),redirectUriPattern:`http://localhost:1455/auth/callback*`,onCapture:`close`});if(!h)throw Error(`OpenAI Codex OAuth login was cancelled or timed out`);let g=new URL(h),_=g.searchParams.get(`code`),y=g.searchParams.get(`state`);if(!_)throw Error(`OpenAI Codex OAuth redirect did not include a code`);if(y!==d)throw Error(`OpenAI Codex OAuth state mismatch — possible CSRF, aborting`);let b=await v(_,i);await e({providerId:l,accessToken:b.access_token,refreshToken:b.refresh_token,tokenExpiresAt:Date.now()+(b.expires_in??3600)*1e3,baseUrl:p,userName:S(b.access_token),userAvatar:await C(b.access_token),scopes:b.scope}),n()},onOAuthLogout:async()=>{await e({providerId:l,accessToken:``})},onSilentRenew:async()=>{let t=w();if(!t?.refreshToken)return null;let n=await y(t.refreshToken);return n?.access_token?(await e({providerId:l,accessToken:n.access_token,refreshToken:n.refresh_token??t.refreshToken,tokenExpiresAt:Date.now()+(n.expires_in??3600)*1e3,baseUrl:p,userName:S(n.access_token),userAvatar:await C(n.access_token),scopes:n.scope??t.scopes}),n.access_token):null}};function N(){r({api:h,stream:A,streamSimple:j})}export{M as config,N as register};
1
+ import{g as e,n as t}from"./account-store-ChQLfZgz.js";import{a as n}from"./diagnostics-DN_idNHx.js";import{a as r}from"./compat-uEPf6-XW.js";import{n as i,o as a}from"./legacy-api-aliases-jKEvBgOL.js";import"./provider-settings-D3GCdjWv.js";import{n as o,r as s,t as c}from"./pkce-hGf_TEnP.js";const l=`openai-codex`,u=`app_EMoamEEZ73f0CkXaXp7hrann`,d=`https://auth.openai.com/oauth/token`,f=`http://localhost:1455/auth/callback`,p=`https://chatgpt.com/backend-api`,m=`openai-codex-responses`,h=`${l}-openai`,g={xhigh:`xhigh`,minimal:`low`},_=[{id:`gpt-5.5`,name:`GPT-5.5`,input:[`text`,`image`]},{id:`gpt-5.4`,name:`GPT-5.4`,input:[`text`,`image`]},{id:`gpt-5.4-mini`,name:`GPT-5.4 mini`,input:[`text`,`image`]},{id:`gpt-5.3-codex`,name:`GPT-5.3 Codex`,input:[`text`,`image`]},{id:`gpt-5.3-codex-spark`,name:`GPT-5.3 Codex Spark`,input:[`text`]},{id:`gpt-5.2`,name:`GPT-5.2`,input:[`text`,`image`]}].map(e=>({...e,api:`openai`,reasoning:!0,context_window:272e3,max_tokens:128e3,thinkingLevelMap:g}));async function v(e,t){let n=new URLSearchParams({grant_type:`authorization_code`,client_id:u,code:e,code_verifier:t,redirect_uri:f}),r=await fetch(d,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:n});if(!r.ok)throw Error(`OpenAI Codex token exchange failed: ${r.status} ${await r.text()}`);let i=await r.json();if(!i.access_token)throw Error(`OpenAI Codex token exchange did not return access_token.`);return i}async function y(e){try{let t=new URLSearchParams({grant_type:`refresh_token`,refresh_token:e,client_id:u}),n=await fetch(d,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:t});return n.ok?await n.json():(console.error(`[openai-codex] refresh failed:`,n.status,await n.text()),null)}catch(e){return console.error(`[openai-codex] refresh error:`,e instanceof Error?e.message:String(e)),null}}function b(e){try{let t=e.split(`.`);if(t.length!==3)return;let n=t[1].replace(/-/g,`+`).replace(/_/g,`/`);return n.length%4&&(n+=`=`.repeat(4-n.length%4)),JSON.parse(atob(n))}catch{return}}function x(e){let t=b(e)?.[`https://api.openai.com/profile`]?.email;return typeof t==`string`?t:void 0}function S(e){let t=b(e)?.[`https://api.openai.com/auth`],n=x(e),r=typeof t?.chatgpt_plan_type==`string`?t.chatgpt_plan_type:void 0,i=r?r.charAt(0).toUpperCase()+r.slice(1):void 0;if(n&&i)return`${n} (${i})`;if(n)return n;if(i)return`ChatGPT ${i}`}async function C(e){let t=x(e);if(t)try{let e=t.trim().toLowerCase(),n=new Uint8Array(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e)));return`https://www.gravatar.com/avatar/${Array.from(n).map(e=>e.toString(16).padStart(2,`0`)).join(``)}?s=128&d=404`}catch{return}}function w(){return t().find(e=>e.providerId===l)}async function T(){let t=w();if(!t?.accessToken)throw Error("Not signed in to OpenAI Codex — run `oauth-token openai-codex` or /login");let n=t.tokenExpiresAt??0;if(n&&Date.now()+6e4<n)return t.accessToken;if(t.refreshToken){let n=await y(t.refreshToken);if(n?.access_token)return await e({providerId:l,accessToken:n.access_token,refreshToken:n.refresh_token??t.refreshToken,tokenExpiresAt:Date.now()+(n.expires_in??3600)*1e3,baseUrl:p,userName:S(n.access_token),userAvatar:await C(n.access_token),scopes:n.scope??t.scopes}),n.access_token}return t.accessToken}function E(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:h,provider:l,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 D(e){console.error(`[openai-codex] Stream error:`,e instanceof Error?e.message:String(e))}async function O(e,t,n,r){try{let a=await T(),o={...t,baseUrl:p,api:m},s=i(o,n,{...r,apiKey:a,transport:`sse`});for await(let t of s)e.push(t);e.end()}catch(n){D(n),e.push(E(t,n)),e.end()}}async function k(e,t,n,r){try{let i=await T(),o={...t,baseUrl:p,api:m},s=a(o,n,{...r,apiKey:i,transport:`sse`});for await(let t of s)e.push(t);e.end()}catch(n){D(n),e.push(E(t,n)),e.end()}}const A=(e,t,r={})=>{let i=n();return O(i,e,t,r).catch(D),i},j=(e,t,r)=>{let i=n();return k(i,e,t,r).catch(D),i},M={id:l,name:`OpenAI Codex (ChatGPT Subscription)`,description:`GPT-5 Codex via your ChatGPT Plus/Pro/Business subscription — OAuth login, no API key needed. Default model is GPT-5.5.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:`gpt-5.5`,oauthTokenDomains:[`chatgpt.com`,`*.chatgpt.com`,`auth.openai.com`,`api.openai.com`],getModelIds:()=>_,onOAuthLoginIntercepted:async(t,n,r)=>{let i=o(),a=await c(i),d=s(),m=new URL(`https://auth.openai.com/oauth/authorize`);m.searchParams.set(`response_type`,`code`),m.searchParams.set(`client_id`,u),m.searchParams.set(`redirect_uri`,f),m.searchParams.set(`scope`,r?.scopes??`openid profile email offline_access`),m.searchParams.set(`code_challenge`,a),m.searchParams.set(`code_challenge_method`,`S256`),m.searchParams.set(`state`,d),m.searchParams.set(`id_token_add_organizations`,`true`),m.searchParams.set(`codex_cli_simplified_flow`,`true`),m.searchParams.set(`originator`,`pi`);let h=await t({authorizeUrl:m.toString(),redirectUriPattern:`http://localhost:1455/auth/callback*`,onCapture:`close`});if(!h)throw Error(`OpenAI Codex OAuth login was cancelled or timed out`);let g=new URL(h),_=g.searchParams.get(`code`),y=g.searchParams.get(`state`);if(!_)throw Error(`OpenAI Codex OAuth redirect did not include a code`);if(y!==d)throw Error(`OpenAI Codex OAuth state mismatch — possible CSRF, aborting`);let b=await v(_,i);await e({providerId:l,accessToken:b.access_token,refreshToken:b.refresh_token,tokenExpiresAt:Date.now()+(b.expires_in??3600)*1e3,baseUrl:p,userName:S(b.access_token),userAvatar:await C(b.access_token),scopes:b.scope}),n()},onOAuthLogout:async()=>{await e({providerId:l,accessToken:``})},onSilentRenew:async()=>{let t=w();if(!t?.refreshToken)return null;let n=await y(t.refreshToken);return n?.access_token?(await e({providerId:l,accessToken:n.access_token,refreshToken:n.refresh_token??t.refreshToken,tokenExpiresAt:Date.now()+(n.expires_in??3600)*1e3,baseUrl:p,userName:S(n.access_token),userAvatar:await C(n.access_token),scopes:n.scope??t.scopes}),n.access_token):null}};function N(){r({api:h,stream:A,streamSimple:j})}export{M as config,N as register};
@@ -1 +1 @@
1
- import{H as e,h as t}from"./account-store-B2fM_hVm.js";import{u as n}from"./claude-model-version-BJLrDjmH.js";import{r,s as i}from"./legacy-api-aliases-45zvHmpJ.js";import"./provider-settings-C_7ia6Wg.js";import{fetchModels as a,getCatalog as o}from"./openrouter-models-D210d5Hg.js";import{loginIntercepted as s}from"./openrouter-oauth-BoC1y3uz.js";var c=`openrouter`,l=`https://openrouter.ai/api/v1`,u=`openai-completions`,d=`${c}-openai`,f={"HTTP-Referer":`https://sliccy.ai`,"X-Title":`SLICC`};function p(e){return{...e,baseUrl:l,api:u}}function m(e){return{...e??{},...f}}var h=(e,n,i={})=>r(p(e),n,{...i,apiKey:t(c)??i.apiKey,headers:m(i.headers)}),g=(e,n,r={})=>i(p(e),n,{...r,apiKey:t(c)??r.apiKey,headers:m(r.headers)}),_={id:c,name:`OpenRouter`,description:`Access OpenRouter models with one-click PKCE login. No pasted API key is required.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:`anthropic/claude-sonnet-4.6`,oauthTokenDomains:[`openrouter.ai`,`*.openrouter.ai`],getModelIds:o,refreshModels:async()=>{await a()},onOAuthLoginIntercepted:async(e,t,n)=>{await s(e,()=>void 0,n),await a().catch(()=>void 0),t()},onOAuthLogout:async()=>{await e({providerId:c,accessToken:``})}};function v(){n({api:d,stream:h,streamSimple:g})}export{_ as config,v as register};
1
+ import{H as e,h as t}from"./account-store-BcQeOBmj.js";import{u as n}from"./claude-model-version-BJLrDjmH.js";import{r,s as i}from"./legacy-api-aliases-45zvHmpJ.js";import"./provider-settings-DxvegOPb.js";import{fetchModels as a,getCatalog as o}from"./openrouter-models-D210d5Hg.js";import{loginIntercepted as s}from"./openrouter-oauth-ukqAIszR.js";var c=`openrouter`,l=`https://openrouter.ai/api/v1`,u=`openai-completions`,d=`${c}-openai`,f={"HTTP-Referer":`https://sliccy.ai`,"X-Title":`SLICC`};function p(e){return{...e,baseUrl:l,api:u}}function m(e){return{...e??{},...f}}var h=(e,n,i={})=>r(p(e),n,{...i,apiKey:t(c)??i.apiKey,headers:m(i.headers)}),g=(e,n,r={})=>i(p(e),n,{...r,apiKey:t(c)??r.apiKey,headers:m(r.headers)}),_={id:c,name:`OpenRouter`,description:`Access OpenRouter models with one-click PKCE login. No pasted API key is required.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:`anthropic/claude-sonnet-4.6`,oauthTokenDomains:[`openrouter.ai`,`*.openrouter.ai`],getModelIds:o,refreshModels:async()=>{await a()},onOAuthLoginIntercepted:async(e,t,n)=>{await s(e,()=>void 0,n),await a().catch(()=>void 0),t()},onOAuthLogout:async()=>{await e({providerId:c,accessToken:``})}};function v(){n({api:d,stream:h,streamSimple:g})}export{_ as config,v as register};
@@ -1 +1 @@
1
- import{g as e,i as t}from"./account-store-CnTVyV3B.js";import{a as n}from"./compat-uEPf6-XW.js";import{r,s as i}from"./legacy-api-aliases-jKEvBgOL.js";import"./provider-settings-s-43s4y0.js";import{fetchModels as a,getCatalog as o}from"./openrouter-models-C9w8lxkF.js";import{loginIntercepted as s}from"./openrouter-oauth-DQITUCdi.js";const c=`openrouter`,l=`${c}-openai`,u={"HTTP-Referer":`https://sliccy.ai`,"X-Title":`SLICC`};function d(e){return{...e,baseUrl:`https://openrouter.ai/api/v1`,api:`openai-completions`}}function f(e){return{...e??{},...u}}const p=(e,n,i={})=>r(d(e),n,{...i,apiKey:t(c)??i.apiKey,headers:f(i.headers)}),m=(e,n,r={})=>i(d(e),n,{...r,apiKey:t(c)??r.apiKey,headers:f(r.headers)}),h={id:c,name:`OpenRouter`,description:`Access OpenRouter models with one-click PKCE login. No pasted API key is required.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:`anthropic/claude-sonnet-4.6`,oauthTokenDomains:[`openrouter.ai`,`*.openrouter.ai`],getModelIds:o,refreshModels:async()=>{await a()},onOAuthLoginIntercepted:async(e,t,n)=>{await s(e,()=>void 0,n),await a().catch(()=>void 0),t()},onOAuthLogout:async()=>{await e({providerId:c,accessToken:``})}};function g(){n({api:l,stream:p,streamSimple:m})}export{h as config,g as register};
1
+ import{g as e,i as t}from"./account-store-ChQLfZgz.js";import{a as n}from"./compat-uEPf6-XW.js";import{r,s as i}from"./legacy-api-aliases-jKEvBgOL.js";import"./provider-settings-D3GCdjWv.js";import{fetchModels as a,getCatalog as o}from"./openrouter-models-C9w8lxkF.js";import{loginIntercepted as s}from"./openrouter-oauth-Bl5DUyyK.js";const c=`openrouter`,l=`${c}-openai`,u={"HTTP-Referer":`https://sliccy.ai`,"X-Title":`SLICC`};function d(e){return{...e,baseUrl:`https://openrouter.ai/api/v1`,api:`openai-completions`}}function f(e){return{...e??{},...u}}const p=(e,n,i={})=>r(d(e),n,{...i,apiKey:t(c)??i.apiKey,headers:f(i.headers)}),m=(e,n,r={})=>i(d(e),n,{...r,apiKey:t(c)??r.apiKey,headers:f(r.headers)}),h={id:c,name:`OpenRouter`,description:`Access OpenRouter models with one-click PKCE login. No pasted API key is required.`,requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,defaultModelId:`anthropic/claude-sonnet-4.6`,oauthTokenDomains:[`openrouter.ai`,`*.openrouter.ai`],getModelIds:o,refreshModels:async()=>{await a()},onOAuthLoginIntercepted:async(e,t,n)=>{await s(e,()=>void 0,n),await a().catch(()=>void 0),t()},onOAuthLogout:async()=>{await e({providerId:c,accessToken:``})}};function g(){n({api:l,stream:p,streamSimple:m})}export{h as config,g as register};
@@ -1 +1 @@
1
- import{g as e}from"./account-store-CnTVyV3B.js";import"./provider-settings-s-43s4y0.js";import{n as t,t as n}from"./pkce-hGf_TEnP.js";const r=`http://127.0.0.1:3000/callback`,i=`http://127.0.0.1:3000/*`;function a(e,t){let n=new URL(`https://openrouter.ai/auth`);return n.searchParams.set(`callback_url`,e),n.searchParams.set(`code_challenge`,t),n.searchParams.set(`code_challenge_method`,`S256`),n.toString()}function o(e){if(!e)throw Error(`OpenRouter OAuth login was cancelled or timed out`);let t;try{t=new URL(e)}catch{throw Error(`OpenRouter OAuth returned an invalid callback URL`)}let n=t.searchParams.get(`code`);if(!n)throw Error(`OpenRouter OAuth redirect did not include an authorization code`);return n}async function s(e,t,n=fetch){let r=await n(`https://openrouter.ai/api/v1/auth/keys`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({code:e,code_verifier:t,code_challenge_method:`S256`}),signal:AbortSignal.timeout(3e4)});if(!r.ok){let e=await r.text();throw Error(`OpenRouter key exchange failed (${r.status}): ${e||`(empty response body)`}`)}let i;try{i=await r.json()}catch{throw Error(`OpenRouter key exchange returned invalid JSON`)}let a=i&&typeof i==`object`&&typeof i.key==`string`?i.key.trim():``;if(!a)throw Error(`OpenRouter key exchange returned an empty or invalid API key`);return a}async function c(c,l,u){let d=t(),f=await n(d),p=await s(o(await c({authorizeUrl:a(r,f),redirectUriPattern:i,onCapture:`close`})),d);await e({providerId:`openrouter`,accessToken:p,tokenExpiresAt:2**53-1,baseUrl:`https://openrouter.ai/api/v1`}),l()}export{r as OPENROUTER_CALLBACK_URL,i as OPENROUTER_REDIRECT_URI_PATTERN,a as buildAuthorizeUrl,n as deriveCodeChallenge,s as exchangeCodeForKey,t as generateCodeVerifier,c as loginIntercepted,o as parseCallbackCode};
1
+ import{g as e}from"./account-store-ChQLfZgz.js";import"./provider-settings-D3GCdjWv.js";import{n as t,t as n}from"./pkce-hGf_TEnP.js";const r=`http://127.0.0.1:3000/callback`,i=`http://127.0.0.1:3000/*`;function a(e,t){let n=new URL(`https://openrouter.ai/auth`);return n.searchParams.set(`callback_url`,e),n.searchParams.set(`code_challenge`,t),n.searchParams.set(`code_challenge_method`,`S256`),n.toString()}function o(e){if(!e)throw Error(`OpenRouter OAuth login was cancelled or timed out`);let t;try{t=new URL(e)}catch{throw Error(`OpenRouter OAuth returned an invalid callback URL`)}let n=t.searchParams.get(`code`);if(!n)throw Error(`OpenRouter OAuth redirect did not include an authorization code`);return n}async function s(e,t,n=fetch){let r=await n(`https://openrouter.ai/api/v1/auth/keys`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({code:e,code_verifier:t,code_challenge_method:`S256`}),signal:AbortSignal.timeout(3e4)});if(!r.ok){let e=await r.text();throw Error(`OpenRouter key exchange failed (${r.status}): ${e||`(empty response body)`}`)}let i;try{i=await r.json()}catch{throw Error(`OpenRouter key exchange returned invalid JSON`)}let a=i&&typeof i==`object`&&typeof i.key==`string`?i.key.trim():``;if(!a)throw Error(`OpenRouter key exchange returned an empty or invalid API key`);return a}async function c(c,l,u){let d=t(),f=await n(d),p=await s(o(await c({authorizeUrl:a(r,f),redirectUriPattern:i,onCapture:`close`})),d);await e({providerId:`openrouter`,accessToken:p,tokenExpiresAt:2**53-1,baseUrl:`https://openrouter.ai/api/v1`}),l()}export{r as OPENROUTER_CALLBACK_URL,i as OPENROUTER_REDIRECT_URI_PATTERN,a as buildAuthorizeUrl,n as deriveCodeChallenge,s as exchangeCodeForKey,t as generateCodeVerifier,c as loginIntercepted,o as parseCallbackCode};
@@ -1 +1 @@
1
- import{H as e}from"./account-store-B2fM_hVm.js";import"./provider-settings-C_7ia6Wg.js";import{n as t,t as n}from"./pkce-hGf_TEnP.js";var r=`https://openrouter.ai/auth`,i=`https://openrouter.ai/api/v1/auth/keys`,a=`https://openrouter.ai/api/v1`,o=`http://127.0.0.1:3000/callback`,s=`http://127.0.0.1:3000/*`;function c(e,t){let n=new URL(r);return n.searchParams.set(`callback_url`,e),n.searchParams.set(`code_challenge`,t),n.searchParams.set(`code_challenge_method`,`S256`),n.toString()}function l(e){if(!e)throw Error(`OpenRouter OAuth login was cancelled or timed out`);let t;try{t=new URL(e)}catch{throw Error(`OpenRouter OAuth returned an invalid callback URL`)}let n=t.searchParams.get(`code`);if(!n)throw Error(`OpenRouter OAuth redirect did not include an authorization code`);return n}async function u(e,t,n=fetch){let r=await n(i,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({code:e,code_verifier:t,code_challenge_method:`S256`}),signal:AbortSignal.timeout(3e4)});if(!r.ok){let e=await r.text();throw Error(`OpenRouter key exchange failed (${r.status}): ${e||`(empty response body)`}`)}let a;try{a=await r.json()}catch{throw Error(`OpenRouter key exchange returned invalid JSON`)}let o=a&&typeof a==`object`&&typeof a.key==`string`?a.key.trim():``;if(!o)throw Error(`OpenRouter key exchange returned an empty or invalid API key`);return o}async function d(r,i,d){let f=t(),p=await u(l(await r({authorizeUrl:c(o,await n(f)),redirectUriPattern:s,onCapture:`close`})),f);await e({providerId:`openrouter`,accessToken:p,tokenExpiresAt:2**53-1,baseUrl:a}),i()}export{o as OPENROUTER_CALLBACK_URL,s as OPENROUTER_REDIRECT_URI_PATTERN,c as buildAuthorizeUrl,n as deriveCodeChallenge,u as exchangeCodeForKey,t as generateCodeVerifier,d as loginIntercepted,l as parseCallbackCode};
1
+ import{H as e}from"./account-store-BcQeOBmj.js";import"./provider-settings-DxvegOPb.js";import{n as t,t as n}from"./pkce-hGf_TEnP.js";var r=`https://openrouter.ai/auth`,i=`https://openrouter.ai/api/v1/auth/keys`,a=`https://openrouter.ai/api/v1`,o=`http://127.0.0.1:3000/callback`,s=`http://127.0.0.1:3000/*`;function c(e,t){let n=new URL(r);return n.searchParams.set(`callback_url`,e),n.searchParams.set(`code_challenge`,t),n.searchParams.set(`code_challenge_method`,`S256`),n.toString()}function l(e){if(!e)throw Error(`OpenRouter OAuth login was cancelled or timed out`);let t;try{t=new URL(e)}catch{throw Error(`OpenRouter OAuth returned an invalid callback URL`)}let n=t.searchParams.get(`code`);if(!n)throw Error(`OpenRouter OAuth redirect did not include an authorization code`);return n}async function u(e,t,n=fetch){let r=await n(i,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({code:e,code_verifier:t,code_challenge_method:`S256`}),signal:AbortSignal.timeout(3e4)});if(!r.ok){let e=await r.text();throw Error(`OpenRouter key exchange failed (${r.status}): ${e||`(empty response body)`}`)}let a;try{a=await r.json()}catch{throw Error(`OpenRouter key exchange returned invalid JSON`)}let o=a&&typeof a==`object`&&typeof a.key==`string`?a.key.trim():``;if(!o)throw Error(`OpenRouter key exchange returned an empty or invalid API key`);return o}async function d(r,i,d){let f=t(),p=await u(l(await r({authorizeUrl:c(o,await n(f)),redirectUriPattern:s,onCapture:`close`})),f);await e({providerId:`openrouter`,accessToken:p,tokenExpiresAt:2**53-1,baseUrl:a}),i()}export{o as OPENROUTER_CALLBACK_URL,s as OPENROUTER_REDIRECT_URI_PATTERN,c as buildAuthorizeUrl,n as deriveCodeChallenge,u as exchangeCodeForKey,t as generateCodeVerifier,d as loginIntercepted,l as parseCallbackCode};