sliccy 5.65.3 → 5.67.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ui/assets/{account-store-Bv6TisyU.js → account-store-D-iMuoaP.js} +3 -3
- package/dist/ui/assets/{account-store-zIg2byrO.js → account-store-RXT-Poh-.js} +2 -2
- package/dist/ui/assets/{adobe-Dk4PXOud.js → adobe-DcQIlInD.js} +1 -1
- package/dist/ui/assets/{adobe-VLaxbM3n.js → adobe-DidXxG4x.js} +2 -2
- package/dist/ui/assets/{apps-C6COZAy3.js → apps-BQCL2F5M.js} +1 -1
- package/dist/ui/assets/{azure-openai-B9K73a45.js → azure-openai-CMyCkrMc.js} +1 -1
- package/dist/ui/assets/{azure-openai-1J73cDhL.js → azure-openai-DZfeGNQz.js} +1 -1
- package/dist/ui/assets/{cerebras-gyb0tX_S.js → cerebras-Cm7b3Xfd.js} +1 -1
- package/dist/ui/assets/{cerebras-BkVp6tVp.js → cerebras-DBelOu2b.js} +1 -1
- package/dist/ui/assets/{client-CpLUc-P8.js → client-BliYDaDA.js} +1 -1
- package/dist/ui/assets/{composer-speech-BwORWIgx.js → composer-speech-CWgEvzia.js} +1 -1
- package/dist/ui/assets/{connect-surface-Di4VE6gd.js → connect-surface-YjE945TK.js} +1 -1
- package/dist/ui/assets/{dip-BijE5f-7.js → dip-CxC1oNbs.js} +1 -1
- package/dist/ui/assets/{discovery-preference-DCtfbqw1.js → discovery-preference-CUhsI-AU.js} +1 -1
- package/dist/ui/assets/{ensure-speech-assets-BHM7KI26.js → ensure-speech-assets-Wr0NmhbD.js} +1 -1
- package/dist/ui/assets/{follower-navigate-watcher-Cn5RjYxg.js → follower-navigate-watcher-UN0jo7Ge.js} +1 -1
- package/dist/ui/assets/{fs-BSqRNdV8.js → fs-CT6QHMkG.js} +1 -1
- package/dist/ui/assets/{fs-BHhBSByi.js → fs-vXmQvStI.js} +2 -2
- package/dist/ui/assets/{github-BjnlCNCE.js → github-8HwjyfW2.js} +1 -1
- package/dist/ui/assets/{github-copilot-Cv-QDX_5.js → github-copilot-Dh7Jo791.js} +1 -1
- package/dist/ui/assets/{github-copilot-dCBopF9I.js → github-copilot-Wg7QAnr5.js} +1 -1
- package/dist/ui/assets/{github-Dw7Be20Y.js → github-t9cd6UPo.js} +2 -2
- package/dist/ui/assets/{hear-CbYaCba-.js → hear-BxiGt0Ct.js} +1 -1
- package/dist/ui/assets/{hear-JuW_sP-u.js → hear-C1RTIY9q.js} +1 -1
- package/dist/ui/assets/{js-realm-worker-FgXpYXua.js → js-realm-worker-DFnuhv4z.js} +7 -7
- package/dist/ui/assets/{kernel-worker-C1Jk4Cgm.js → kernel-worker-DM9EjgTg.js} +596 -586
- package/dist/ui/assets/{kokoro-engine-6v0QDlru.js → kokoro-engine-8rE8HqhM.js} +1 -1
- package/dist/ui/assets/{lick-ws-bridge-C_bJMGw6.js → lick-ws-bridge-CW-Xewtf.js} +1 -1
- package/dist/ui/assets/{lick-ws-bridge-DZ9b0hn4.js → lick-ws-bridge-DUnNTVql.js} +1 -1
- package/dist/ui/assets/{local-llm-DlNJAfyr.js → local-llm-BYsullVk.js} +1 -1
- package/dist/ui/assets/{local-llm-DlLYYoVC.js → local-llm-CyWr_Z6G.js} +1 -1
- package/dist/ui/assets/{main-DLEdjSut.js → main-BlzS5aDO.js} +3 -3
- package/dist/ui/assets/{mount-IkmxltrP.js → mount-CyN9_GkS.js} +2 -2
- package/dist/ui/assets/{mount-bridge-client-BVLVI9yX.js → mount-bridge-client-DHGevTQu.js} +1 -1
- package/dist/ui/assets/mount-n8fLpdiw.js +1 -0
- package/dist/ui/assets/{mount-recovery-D-JXVLX-.js → mount-recovery-C7G_KBqI.js} +1 -1
- package/dist/ui/assets/{new-session-DOll8wFn.js → new-session-B6TlTKjK.js} +2 -2
- package/dist/ui/assets/{oauth-bootstrap-BOl1JV2i.js → oauth-bootstrap-C6Jt7mJP.js} +2 -2
- package/dist/ui/assets/{oauth-service-CmM0tZSO.js → oauth-service-B0BvQdYb.js} +1 -1
- package/dist/ui/assets/{oauth-service-CfqjxAd7.js → oauth-service-JdgAxFYW.js} +1 -1
- package/dist/ui/assets/{openai-codex-CkHFlc1B.js → openai-codex-BuosVxrr.js} +1 -1
- package/dist/ui/assets/{openai-codex-BwtSh55R.js → openai-codex-deoJJt88.js} +1 -1
- package/dist/ui/assets/{panel-rpc-handlers-PzFZnv10.js → panel-rpc-handlers-DqNuY6Aw.js} +2 -2
- package/dist/ui/assets/{port-bridge-client-CsrXhMWo.js → port-bridge-client-BC810skI.js} +1 -1
- package/dist/ui/assets/{port-bridge-client-CdvMlimf.js → port-bridge-client-CoFZLSYm.js} +1 -1
- package/dist/ui/assets/{provider-CE6cf8w6.js → provider-DE9Hwk8G.js} +2 -2
- package/dist/ui/assets/{provider-CK-RipyT.js → provider-DMWoe7Ax.js} +1 -1
- package/dist/ui/assets/{provider-settings-DRRlhEAk.js → provider-settings-CCbIum7u.js} +1 -1
- package/dist/ui/assets/{provider-settings-D3RdJihW.js → provider-settings-CwdBRbVy.js} +2 -2
- package/dist/ui/assets/provider-store-access-IRhFXRFa.js +1 -0
- package/dist/ui/assets/{provider-store-access-CTxdVVbk.js → provider-store-access-hzgvuQuF.js} +2 -2
- package/dist/ui/assets/{providers-qdFVBIs4.js → providers-BCdxJoU9.js} +1 -1
- package/dist/ui/assets/{providers-SjGrqb4i.js → providers-DE-eWlQD.js} +2 -2
- package/dist/ui/assets/proxied-fetch-D5h5REZy.js +2 -0
- package/dist/ui/assets/{proxied-fetch-sbHa3Tte.js → proxied-fetch-ldIfAeIb.js} +1 -1
- package/dist/ui/assets/{quick-llm-BIvNuo3r.js → quick-llm-D49Q05Ys.js} +1 -1
- package/dist/ui/assets/{runtime-mode-M-qJL9jF.js → runtime-mode-CEuVQ26O.js} +1 -1
- package/dist/ui/assets/{secret-env-1E2r2H5F.js → secret-env-dQA8rL_1.js} +1 -1
- package/dist/ui/assets/{secret-topology-D2k1IxFk.js → secret-topology-CptRwAX3.js} +1 -1
- package/dist/ui/assets/{secrets-bridge-client-CONYX8PU.js → secrets-bridge-client-D6nwnBvr.js} +1 -1
- package/dist/ui/assets/{session-freezer-BrenlJjn.js → session-freezer-C59A1pKQ.js} +2 -2
- package/dist/ui/assets/{setup-sudo-BaeAbuAK.js → setup-sudo-B-bx-L9P.js} +2 -2
- package/dist/ui/assets/{skills-Dufl6Cvm.js → skills-BtUerd5x.js} +1 -1
- package/dist/ui/assets/{speak-FrFSddsl.js → speak-BeDix5EH.js} +1 -1
- package/dist/ui/assets/{speak-DiVfWUSx.js → speak-CkvZB0fq.js} +1 -1
- package/dist/ui/assets/sprinkle-bridge-YYPWJ55I.js +2 -0
- package/dist/ui/assets/{sprinkle-manager-C24XXDyP.js → sprinkle-manager-CK0eo6zp.js} +1 -1
- package/dist/ui/assets/{store-uFAsGXgA.js → store-CxbakBcD.js} +1 -1
- package/dist/ui/assets/{sudo-xMWuhORC.js → sudo-bEpbQHwe.js} +1 -1
- package/dist/ui/assets/{transformers-env-CLKB9wzj.js → transformers-env-C77NUYNM.js} +1 -1
- package/dist/ui/assets/{transformers-env-B95qHQN4.js → transformers-env-RUMoBRzi.js} +1 -1
- package/dist/ui/assets/{tray-leader-DcLymd_E.js → tray-leader-DicSB8Dn.js} +1 -1
- package/dist/ui/assets/{tray-leave-runtime-lJcLlwtm.js → tray-leave-runtime-BI5IM82V.js} +1 -1
- package/dist/ui/assets/{tray-runtime-config-DlPGhxQs.js → tray-runtime-config-DEUlxEec.js} +1 -1
- package/dist/ui/assets/{tray-runtime-config-DJIIJaBR.js → tray-runtime-config-DquE2Rx9.js} +1 -1
- package/dist/ui/assets/{upgrade-detection-CZ41kMWI.js → upgrade-detection-BFMDXBSi.js} +1 -1
- package/dist/ui/assets/{voice-reply-qcPHpH1S.js → voice-reply-RJ5RbAjY.js} +1 -1
- package/dist/ui/assets/{wc-extension-DksCcKMT.js → wc-extension-CBkgPjaS.js} +2 -2
- package/dist/ui/assets/{wc-float-label-DeQPr3pd.js → wc-float-label-2tniyRvt.js} +1 -1
- package/dist/ui/assets/{wc-follower-CLveL_SV.js → wc-follower-B8OxCAeY.js} +3 -3
- package/dist/ui/assets/{wc-live-DWqGURv2.js → wc-live-CdHNHipT.js} +3 -3
- package/dist/ui/assets/{wc-nav-Cdknc2rm.js → wc-nav-CTWLKfZj.js} +2 -2
- package/dist/ui/assets/{wc-onboarding-Dy_sXTCd.js → wc-onboarding-D5WzBAw8.js} +2 -2
- package/dist/ui/assets/{wc-placeholder-C-iSe7Ak.js → wc-placeholder-BU3dOl5K.js} +2 -2
- package/dist/ui/assets/{wc-settings-y-dwr_Uo.js → wc-settings-DukL7XBW.js} +3 -3
- package/dist/ui/assets/{wc-shell-ltnl45Bc.js → wc-shell-BPXYInqs.js} +2 -2
- package/dist/ui/assets/{wc-sprinkles-BukmscGz.js → wc-sprinkles-Di46POCG.js} +2 -2
- package/dist/ui/assets/{wc-tray-DiP_YWNM.js → wc-tray-BzolR6pb.js} +2 -2
- package/dist/ui/assets/{whisper-engine-e9PW0ZbJ.js → whisper-engine-6Ks_tvV1.js} +1 -1
- package/dist/ui/assets/{whisper-session-B6XgtKMF.js → whisper-session-36PZh-9m.js} +2 -2
- package/dist/ui/assets/{xai-grok-DiuJbbaI.js → xai-grok-0yL7L2ss.js} +1 -1
- package/dist/ui/assets/{xai-grok-CANG3Qn2.js → xai-grok-Bnav25ad.js} +1 -1
- package/dist/ui/index.html +10 -10
- package/dist/ui/packages/webapp/index.html +10 -10
- package/package.json +4 -3
- package/dist/ui/assets/mount-DK1-DJow.js +0 -1
- package/dist/ui/assets/provider-store-access-BFF7cwJF.js +0 -1
- package/dist/ui/assets/proxied-fetch-DETjVL-j.js +0 -2
- package/dist/ui/assets/sprinkle-bridge-CHyIhYQL.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{t as e}from"./logger-LESFN7Hj.js";import{a as t,i as n,o as r,r as i}from"./transformers-env-
|
|
1
|
+
import{t as e}from"./logger-LESFN7Hj.js";import{a as t,i as n,o as r,r as i}from"./transformers-env-RUMoBRzi.js";const a=e(`speech:espeak`),o=`/workspace/node_modules/espeak-ng/dist/`,s=`espeak-ng.js`,c=`espeak-ng.wasm`;async function l(e,t,n,r){let i=`phonemes.txt`;return(await e({arguments:[`-q`,`-b=1`,`--ipa`,`-v`,n,`--phonout`,i,t],...r?{locateFile:r}:{}})).FS.readFile(i,{encoding:`utf8`}).split(`
|
|
2
2
|
`).map(e=>e.trim()).filter(e=>e.length>0)}function u(e,t){return async n=>{let r=URL.createObjectURL(new Blob([new Uint8Array(t)],{type:`application/wasm`}));try{let t=e=>e.endsWith(`.wasm`)?r:n.locateFile?.(e)??e;return await e({...n,locateFile:t})}finally{URL.revokeObjectURL(r)}}}function d(e){if(typeof BroadcastChannel>`u`)return Promise.reject(Error(`Cannot read VFS path ${e}: BroadcastChannel unavailable`));let t=new BroadcastChannel(`preview-vfs`),n=`espeak-${Date.now()}-${Math.random().toString(36).slice(2)}`;return new Promise((r,i)=>{let a=e=>{t.removeEventListener(`message`,s),t.close(),e()},o=setTimeout(()=>a(()=>i(Error(`ENOENT: ${e} (timed out)`))),3e4),s=t=>{let s=t.data;if(!(s?.type!==`preview-vfs-response`||s.id!==n))if(clearTimeout(o),typeof s.error==`string`)a(()=>i(Error(s.error)));else if(s.content instanceof Uint8Array){let e=s.content;a(()=>r(e))}else if(typeof s.content==`string`){let e=s.content;a(()=>r(new TextEncoder().encode(e)))}else a(()=>i(Error(`Empty preview-vfs response for ${e}`)))};t.addEventListener(`message`,s),t.postMessage({type:`preview-vfs-read`,id:n,path:e,asText:!1})})}async function f(){let[e,t]=await Promise.all([d(`${o}${s}`),d(`${o}${c}`)]),n=URL.createObjectURL(new Blob([new Uint8Array(e)],{type:`text/javascript`}));try{return{factory:u((await import(n)).default,t)}}finally{URL.revokeObjectURL(n)}}let p=f,m=null;function h(){return m||=p().then(({factory:e,locateFile:t})=>(a.info(`espeak-ng multilingual phonemizer loaded`),(n,r)=>l(e,n,r,t)),e=>{throw m=null,a.error(`espeak-ng load failed`,e),e}),m}const g=Object.freeze({e:`es`,f:`fr-fr`,i:`it`,h:`hi`,p:`pt-br`});function _(e){return g[e[0]]??null}const v=RegExp(`(\\s*[${`;:,.!?¡¿—…"«»“”(){}[]`.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}]+\\s*)+`,`g`);function y(e){let t=[],n=0;for(let r of e.matchAll(v)){let i=r[0],a=r.index??0;n<a&&t.push({punct:!1,text:e.slice(n,a)}),i.length>0&&t.push({punct:!0,text:i}),n=a+i.length}return n<e.length&&t.push({punct:!1,text:e.slice(n)}),t}function b(e){return e.replace(/kəkˈoːɹoʊ/g,`kˈoʊkəɹoʊ`).replace(/kəkˈɔːɹəʊ/g,`kˈəʊkəɹəʊ`).replace(/(?<=[a-zɹrː])(?=hˈʌndɹɪd)/g,` `).replace(/ z(?=[;:,.!?¡¿—…"«»“” ]|$)/g,`z`).trim()}async function x(e,t,n){let r=y(e);return b((await Promise.all(r.map(async e=>e.punct?e.text:(await n(e.text,t)).join(` `)))).join(``))}const S=e(`speech:kokoro`),C=`onnx-community/Kokoro-82M-v1.0-ONNX`,w={a:`en-US`,b:`en-GB`,e:`es-ES`,f:`fr-FR`,i:`it-IT`,h:`hi-IN`,p:`pt-BR`,j:`ja-JP`,z:`zh-CN`},T=new Set([`en-US`,`en-GB`,`es-ES`,`fr-FR`,`it-IT`,`hi-IN`,`pt-BR`]);function E(e){let[t,n]=e.split(`-`);return n?`${t.toLowerCase()}-${n.toUpperCase()}`:t.toLowerCase()}function D(e,t){if(!t)return!1;if(T.has(t))return!0;if(t.includes(`-`))return!1;let n=w[e[0]];return n!==void 0&&T.has(n)&&n.split(`-`)[0].toLowerCase()===t}function O(e){return Object.entries(e).map(([e,t])=>{let n=t.language?E(t.language):w[e[0]];return{id:e,name:t.name||e,lang:n??`en-US`,onDevice:D(e,n),...t.gender?{gender:t.gender}:{}}})}const k=Object.freeze({ef_dora:{name:`Dora`,gender:`Female`},em_alex:{name:`Alex`,gender:`Male`},em_santa:{name:`Santa`,gender:`Male`},ff_siwis:{name:`Siwis`,gender:`Female`},hf_alpha:{name:`Alpha`,gender:`Female`},hf_beta:{name:`Beta`,gender:`Female`},hm_omega:{name:`Omega`,gender:`Male`},hm_psi:{name:`Psi`,gender:`Male`},if_sara:{name:`Sara`,gender:`Female`},im_nicola:{name:`Nicola`,gender:`Male`},pf_dora:{name:`Dora`,gender:`Female`},pm_alex:{name:`Alex`,gender:`Male`},pm_santa:{name:`Santa`,gender:`Male`},jf_alpha:{name:`Alpha`,gender:`Female`},jf_gongitsune:{name:`Gongitsune`,gender:`Female`},jf_nezumi:{name:`Nezumi`,gender:`Female`},jf_tebukuro:{name:`Tebukuro`,gender:`Female`},jm_kumo:{name:`Kumo`,gender:`Male`},zf_xiaobei:{name:`Xiaobei`,gender:`Female`},zf_xiaoni:{name:`Xiaoni`,gender:`Female`},zf_xiaoxiao:{name:`Xiaoxiao`,gender:`Female`},zf_xiaoyi:{name:`Xiaoyi`,gender:`Female`},zm_yunjian:{name:`Yunjian`,gender:`Male`},zm_yunxi:{name:`Yunxi`,gender:`Male`},zm_yunxia:{name:`Yunxia`,gender:`Male`},zm_yunyang:{name:`Yunyang`,gender:`Male`}});function A(e){let t={...e};for(let[e,n]of Object.entries(k))e in t||(t[e]=n);return O(t)}const j=`style_text_to_speech_2`,M=`StyleTextToSpeech2Model`;function N(e){return e?.model_type===j&&(!Array.isArray(e.architectures)||e.architectures.length===0)&&(e.architectures=[M]),e}const P=Symbol.for(`slicc.kokoro.style-tts2-arch-shim`);function F(e){let t=e?.AutoConfig,n=t?.from_pretrained;if(!t||typeof n!=`function`){S.debug(`style_text_to_speech_2 shim skipped: AutoConfig.from_pretrained unavailable`);return}if(n[P])return;let r=async(...e)=>{let r=await n.apply(t,e),i=r?.model_type===j&&(!Array.isArray(r.architectures)||r.architectures.length===0);return N(r),i&&S.debug(`style_text_to_speech_2 architectures injected for "${String(e[0])}": [${M}]`),r};r[P]=!0,t.from_pretrained=r,S.debug(`style_text_to_speech_2 architecture shim installed on AutoConfig.from_pretrained`)}async function I(e,t,n,r,i,a){let o=await x(t,n,a),s=e.tokenizer,{input_ids:c}=s(o,{truncation:!0}),l=await e.generate_from_ids(c,{voice:r,...i?{speed:i}:{}});return{audio:l.audio,sampleRate:l.sampling_rate}}const L=/(?<=[.!?。!?…])\s+|\n{2,}/u;function R(e,t){let n=t??L,r=e.split(n).map(e=>e.trim()).filter(e=>e.length>0),i=e.trim();return r.length>0?r:i?[i]:[]}let z=null,B=`idle`,V=null,H=null;function U(){return B}function W(){return V}function G(){return H}function K(e){return z||=(B=`loading`,q(e).then(e=>(B=`ready`,H=e,e),e=>{throw B=`failed`,z=null,S.error(`kokoro load failed`,e),e})),z}async function q(e){let a=await import(`./transformers.web-CrioJkWG.js`);n(a.env),F(a),await i(C),await t();let{KokoroTTS:o,TextSplitterStream:s}=await import(`./kokoro-CGDCwNNA.js`),c=r(),l=typeof navigator<`u`&&`gpu`in navigator,u=await o.from_pretrained(C,{device:l?`webgpu`:`wasm`,dtype:l?`fp32`:`q8`,progress_callback:t=>{if(t?.file){if(t.status===`progress`)c.update(t.file,t.loaded??0,t.total??0);else if(t.status===`done`)c.complete(t.file);else return;V=c.snapshot(),e?.(V)}}});S.info(`kokoro ready`,{model:C,device:l?`webgpu`:`wasm`});let d=A(u.voices);return{async synthesize(e,t){let n=t?.voice??`af_heart`,r=_(n);if(r){let i=await h();return I(u,e,r,n,t?.speed,i)}let i=await u.generate(e,{...t?.voice?{voice:t.voice}:{},...t?.speed?{speed:t.speed}:{}});return{audio:i.audio,sampleRate:i.sampling_rate}},async*synthesizeStream(e,t){let n=t?.voice??`af_heart`,r=_(n);if(r){let i=await h();for(let a of R(e,t?.splitPattern))yield await I(u,a,r,n,t?.speed,i);return}let i={...t?.voice?{voice:t.voice}:{},...t?.speed?{speed:t.speed}:{}},a=new s;if(t?.splitPattern){let n=e.split(t.splitPattern).map(e=>e.trim()).filter(e=>e.length>0);a.push(...n)}else a.push(e);a.close();for await(let e of u.stream(a,i))yield{audio:e.audio.audio,sampleRate:e.audio.sampling_rate}},voices:()=>d}}export{U as a,c,G as i,K as n,o,W as r,s,C as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./logger-LESFN7Hj.js";import{a as t,i as n,n as r,r as i,t as a}from"./runtime-mode-
|
|
1
|
+
import{t as e}from"./logger-LESFN7Hj.js";import{a as t,i as n,n as r,r as i,t as a}from"./runtime-mode-CEuVQ26O.js";const o=e(`lick-ws-bridge`);function s(e){if(e.stopped)return;let t;try{t=e.wsFactory(e.wsUrl)}catch(t){o.error(`Failed to construct lick WebSocket`,{url:e.wsUrl,error:t instanceof Error?t.message:String(t)}),c(e,`construct-threw`);return}e.socket=t,t.onopen=()=>{e.consecutiveFailures>0?o.info(`Lick WebSocket recovered`,{attempts:e.consecutiveFailures}):o.info(`Lick WebSocket connected`),e.consecutiveFailures=0,e.unrecoverableSignalled=!1},t.onmessage=n=>{u(e,t,n.data).catch(e=>{let t=typeof n.data==`string`?n.data.slice(0,200):`[non-string payload]`;o.error(`Failed to process lick message`,{error:e instanceof Error?e.message:String(e),preview:t})})},t.onclose=n=>{if(e.socket===t&&(e.socket=null),e.stopped)return;let r=n.reason?` reason=${JSON.stringify(n.reason)}`:``;c(e,`disconnected code=${n.code}${r}`)},t.onerror=t=>{let n=t.target;o.error(`Lick WebSocket error`,{url:e.wsUrl,readyState:n?.readyState,eventType:t.type})}}function c(e,t){if(e.reconnectHandle!=null){o.debug(`Lick WS failure during pending reconnect — keeping existing timer`,{cause:t});return}e.consecutiveFailures++;let n=Math.min(e.baseDelay*2**(e.consecutiveFailures-1),6e4),r={url:e.wsUrl,attempt:e.consecutiveFailures,cause:t,retryInMs:n};if(e.consecutiveFailures>=3?o.error(`Lick WebSocket still down`,r):o.warn(`Lick WebSocket down`,r),e.consecutiveFailures===20&&!e.unrecoverableSignalled){e.unrecoverableSignalled=!0;try{e.lickManager.emitEvent({type:`session-reload`,targetScoop:void 0,timestamp:new Date().toISOString(),body:{reason:`lick-ws-bridge-down`,url:e.wsUrl,attempts:e.consecutiveFailures}})}catch(e){o.error(`Failed to emit lick-ws-bridge-down signal`,{error:e instanceof Error?e.message:String(e)})}}l(e,n)}function l(e,t){e.stopped||e.reconnectHandle!=null||(e.reconnectHandle=e.setTimer(()=>{e.reconnectHandle=null,s(e)},t))}async function u(e,t,n){let r=JSON.parse(typeof n==`string`?n:String(n));if(r.requestId){let n=r.requestId,i=await m(e,r,n);if(e.stopped||e.socket!==t||t.readyState!==1){o.warn(`Lick reply dropped — socket changed/closed mid-request`,{type:r.type,requestId:n});return}try{t.send(JSON.stringify(i))}catch(e){o.error(`ws.send() failed delivering lick reply`,{type:r.type,requestId:n,error:e instanceof Error?e.message:String(e)})}return}if(r.type===`webhook_event`){d(e.lickManager,r);return}r.type===`navigate_event`&&p(e.lickManager,r)}function d(e,t){let n=typeof t.webhookId==`string`?t.webhookId:null;if(!n){o.error(`Malformed webhook_event from lick-ws`,{receivedKeys:Object.keys(t)});return}let r=t.headers&&typeof t.headers==`object`?t.headers:{};try{e.handleWebhookEvent(n,r,t.body)}catch(e){o.error(`Webhook event dispatch failed`,{webhookId:n,error:e instanceof Error?e.message:String(e)})}}function f(e){let t=typeof e.verb==`string`?e.verb:null,n=typeof e.target==`string`?e.target:null,r=typeof e.url==`string`&&e.url.length>0?e.url:null;if(t!==`handoff`&&t!==`upskill`||!n||!r)return null;let i={url:r,verb:t,target:n};return typeof e.instruction==`string`&&(i.instruction=e.instruction),typeof e.branch==`string`&&(i.branch=e.branch),typeof e.path==`string`&&(i.path=e.path),typeof e.title==`string`&&(i.title=e.title),{type:`navigate`,navigateUrl:r,targetScoop:void 0,timestamp:typeof e.timestamp==`string`?e.timestamp:new Date().toISOString(),body:i}}function p(e,t){let n=f(t);if(!n){o.debug(`navigate_event dropped — invalid payload`,{hasVerb:typeof t.verb==`string`,hasTarget:typeof t.target==`string`,hasUrl:typeof t.url==`string`&&t.url.length>0});return}e.emitEvent(n)}async function m(e,t,r){let{lickManager:i}=e;try{switch(t.type){case`list_webhooks`:return{type:`response`,requestId:r,data:i.listWebhooks().map(t=>({...t,url:h(e,t.id)}))};case`create_webhook`:{let n=await i.createWebhook(t.name||`default`,t.scoop,t.filter);return{type:`response`,requestId:r,data:{...n,url:h(e,n.id)}}}case`delete_webhook`:return await i.deleteWebhook(t.id)?{type:`response`,requestId:r,data:{ok:!0}}:{type:`response`,requestId:r,data:{error:`Webhook not found`}};case`list_crontasks`:return{type:`response`,requestId:r,data:i.listCronTasks()};case`create_crontask`:if(!t.name)throw Error(`name is required`);if(!t.cron)throw Error(`cron is required`);return{type:`response`,requestId:r,data:await i.createCronTask(t.name,t.cron,t.scoop,t.filter)};case`delete_crontask`:return await i.deleteCronTask(t.id)?{type:`response`,requestId:r,data:{ok:!0}}:{type:`response`,requestId:r,data:{error:`Cron task not found`}};case`tray_status`:{let e=n();return{type:`response`,requestId:r,data:{state:e.state,joinUrl:e.session?.joinUrl??null,workerBaseUrl:e.session?.workerBaseUrl??null,trayId:e.session?.trayId??null}}}default:return{type:`response`,requestId:r,error:`Unknown request type: ${t.type}`}}}catch(e){return{type:`response`,requestId:r,error:e instanceof Error?e.message:String(e)}}}function h(e,n){let a=t().session;return a?.webhookUrl?r(a.webhookUrl,n):e.webhookOriginOverride?`${e.webhookOriginOverride}/webhooks/${n}`:i(e.options.locationHref,n)}function g(e){if(e.stopped)return;e.stopped=!0,e.reconnectHandle!=null&&(e.clearTimer(e.reconnectHandle),e.reconnectHandle=null);let t=e.socket;if(e.socket=null,t)try{t.close()}catch(e){t.readyState!==3&&t.readyState!==2&&o.warn(`Lick socket close() threw before terminal state`,{readyState:t.readyState,error:e instanceof Error?e.message:String(e)})}}function _(e,t){try{new URL(t.locationHref)}catch(e){throw Error(`startLickWsBridge: invalid locationHref ${JSON.stringify(t.locationHref)}: ${e instanceof Error?e.message:String(e)}`)}let n=typeof t.lickWsUrl==`string`&&t.lickWsUrl.length>0?t.lickWsUrl:a(t.locationHref),r=null;if(typeof t.lickWsUrl==`string`&&t.lickWsUrl.length>0)try{let e=new URL(t.lickWsUrl);r=`${e.protocol===`wss:`?`https:`:`http:`}//${e.host}`}catch{r=null}let i={lickManager:e,options:t,wsUrl:n,webhookOriginOverride:r,baseDelay:t.reconnectDelayMs??3e3,wsFactory:t.webSocketFactory??(e=>new WebSocket(e)),setTimer:t.setTimeoutFn??setTimeout.bind(globalThis),clearTimer:t.clearTimeoutFn??clearTimeout.bind(globalThis),stopped:!1,socket:null,reconnectHandle:null,consecutiveFailures:0,unrecoverableSignalled:!1};return s(i),{stop(){g(i)}}}export{_ as startLickWsBridge};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./logger-DDBAeTLF.js";import"./main-
|
|
1
|
+
import{t as e}from"./logger-DDBAeTLF.js";import"./main-BlzS5aDO.js";import"./tray-leader-DicSB8Dn.js";e(`lick-ws-bridge`);function t(e){let t=typeof e.verb==`string`?e.verb:null,n=typeof e.target==`string`?e.target:null,r=typeof e.url==`string`&&e.url.length>0?e.url:null;if(t!==`handoff`&&t!==`upskill`||!n||!r)return null;let i={url:r,verb:t,target:n};return typeof e.instruction==`string`&&(i.instruction=e.instruction),typeof e.branch==`string`&&(i.branch=e.branch),typeof e.path==`string`&&(i.path=e.path),typeof e.title==`string`&&(i.title=e.title),{type:`navigate`,navigateUrl:r,targetScoop:void 0,timestamp:typeof e.timestamp==`string`?e.timestamp:new Date().toISOString(),body:i}}function n(e){let t=typeof e.discoveryOrigin==`string`?e.discoveryOrigin:null,n=e.discoveryKind===`ai-catalog`||e.discoveryKind===`llms-txt`?e.discoveryKind:null,r=typeof e.discoveryUrl==`string`&&e.discoveryUrl.length>0?e.discoveryUrl:null;if(!t||!n||!r)return null;let i=typeof e.url==`string`?e.url:void 0;return{type:`discovery`,discoveryOrigin:t,discoveryKind:n,discoveryUrl:r,targetScoop:void 0,timestamp:typeof e.timestamp==`string`?e.timestamp:new Date().toISOString(),body:{origin:t,kind:n,url:r,...i?{pageUrl:i}:{}}}}export{n as mapDiscoveryPayloadToLickEvent,t as mapNavigatePayloadToLickEvent};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{t}from"./logger-LESFN7Hj.js";import{d as n}from"./account-store-
|
|
1
|
+
import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{t}from"./logger-LESFN7Hj.js";import{d as n}from"./account-store-RXT-Poh-.js";import{p as r}from"./transform-messages-CVIV-EgO.js";import{p as i}from"./bedrock-camp-CvxD6hHk.js";import{r as a,s as o}from"./legacy-api-aliases-DWJHPSiz.js";var s=e({config:()=>d,detectRuntime:()=>C,discoverModels:()=>S,originOf:()=>b,register:()=>y,verifyConnection:()=>E});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){try{let t=new URL(e);return`${t.protocol}//${t.host}`}catch{return e.replace(/\/v1\/?$/,``).replace(/\/+$/,``)}}function x(e){let t=e.replace(/\/+$/,``);try{let e=new URL(t);if(e.pathname===``||e.pathname===`/`)return`${t}/v1`}catch{}return t}async function S(e,t,n){let r=`${x(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 C(e,t){let n=b(e),r=await T(`${n}/api/version`,t);if(r&&typeof r.version==`string`)return{kind:`ollama`,version:r.version};let i=await T(`${n}/api/v0/models`,t);if(i&&i.object===`list`)return{kind:`lmstudio`};let a=await T(`${n}/props`,t);if(a&&`build_info`in a)return{kind:`llamacpp`,version:a.build_info?.version};let o=w(e);return o===`11434`?{kind:`ollama`}:o===`1234`?{kind:`lmstudio`}:o===`8000`?{kind:`vllm`}:o===`1337`?{kind:`jan`}:{kind:`unknown`}}function w(e){try{return new URL(e).port||null}catch{return null}}async function T(e,t){try{let n=await fetch(e,{method:`GET`,signal:t});return n.ok?await n.json():null}catch{return null}}async function E(e,t,n){let r={kind:`unknown`};try{r=await C(e,n)}catch{}try{let i=await S(e,t,n);return{ok:!0,runtime:r,models:i}}catch(t){let n=t instanceof Error?t.message:String(t),i=D(n,r.kind);return c.warn(`verifyConnection failed`,{baseUrl:e,runtime:r.kind,message:n}),{ok:!1,runtime:r,models:[],error:i}}}function D(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,2 +1,2 @@
|
|
|
1
|
-
import{s as e}from"./models-CzSI8IsT.js";import{a as t}from"./compat-DyT25qXb.js";import{r as n,s as r}from"./legacy-api-aliases-BQSsmFIS.js";import{b as i}from"./account-store-
|
|
1
|
+
import{s as e}from"./models-CzSI8IsT.js";import{a as t}from"./compat-DyT25qXb.js";import{r as n,s as r}from"./legacy-api-aliases-BQSsmFIS.js";import{b as i}from"./account-store-D-iMuoaP.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 e=d(i(s));return e.length===0?[{id:l,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 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,r={})=>e.id===l?v(e,`Local LLM is not configured. Set base URL and model IDs in Settings.`):e.baseUrl?n(m(e),t,h(r)):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?r(m(e),t,h(n)):v(e,`Local LLM base URL is required (e.g. http://localhost:11434/v1).`);function v(t,n){let r=e(),i={role:`assistant`,content:[],api:t.api,provider:t.provider,model:t.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(){t({api:p,stream:g,streamSimple:_})}function b(e){try{let t=new URL(e);return`${t.protocol}//${t.host}`}catch{return e.replace(/\/v1\/?$/,``).replace(/\/+$/,``)}}function x(e){let t=e.replace(/\/+$/,``);try{let e=new URL(t);if(e.pathname===``||e.pathname===`/`)return`${t}/v1`}catch{}return t}async function S(e,t,n){let r=`${x(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 C(e,t){let n=b(e),r=await T(`${n}/api/version`,t);if(r&&typeof r.version==`string`)return{kind:`ollama`,version:r.version};let i=await T(`${n}/api/v0/models`,t);if(i&&i.object===`list`)return{kind:`lmstudio`};let a=await T(`${n}/props`,t);if(a&&`build_info`in a)return{kind:`llamacpp`,version:a.build_info?.version};let o=w(e);return o===`11434`?{kind:`ollama`}:o===`1234`?{kind:`lmstudio`}:o===`8000`?{kind:`vllm`}:o===`1337`?{kind:`jan`}:{kind:`unknown`}}function w(e){try{return new URL(e).port||null}catch{return null}}async function T(e,t){try{let n=await fetch(e,{method:`GET`,signal:t});return n.ok?await n.json():null}catch{return null}}async function E(e,t,n){let r={kind:`unknown`};try{r=await C(e,n)}catch{}try{let i=await S(e,t,n);return{ok:!0,runtime:r,models:i}}catch(t){let n=t instanceof Error?t.message:String(t),i=D(n,r.kind);return o.warn(`verifyConnection failed`,{baseUrl:e,runtime:r.kind,message:n}),{ok:!1,runtime:r,models:[],error:i}}}function D(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,C as detectRuntime,S as discoverModels,b as originOf,y as register,E as verifyConnection};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/extension-bridge-transport-DHBo-K6K.js","assets/logger-DDBAeTLF.js","assets/lick-ws-bridge-
|
|
2
|
-
import"./modulepreload-polyfill-Dezn_h7o.js";import{t as e}from"./preload-helper-Czpn1I53.js";import{a as t}from"./account-store-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/extension-bridge-transport-DHBo-K6K.js","assets/logger-DDBAeTLF.js","assets/lick-ws-bridge-DUnNTVql.js","assets/tray-leader-DicSB8Dn.js","assets/rolldown-runtime-aKtaBQYM.js","assets/proxied-fetch-D5h5REZy.js","assets/preload-helper-Czpn1I53.js","assets/base64-DpPqYZJF.js","assets/src-CS5gSDhT.js","assets/runtime-env-DH4NDw4t.js","assets/fetch-body-D2PwksUW.js","assets/tray-runtime-config-DquE2Rx9.js","assets/messages-BD4p8GuF.js","assets/db-ysOO0kLr.js","assets/cdp-7evcrxxP.js","assets/navigation-watcher-BoJS9hdc.js","assets/handoff-link-CfgH86mb.js","assets/remote-cdp-transport-DOoXIxy3.js","assets/tray-sync-protocol-CVdiCvfU.js","assets/main-cherry-CGm5knH6.js","assets/synthetic-cdp-transport-DLIt5SkY.js","assets/wc-shell-BPXYInqs.js","assets/telemetry-C8rZr13D.js","assets/icons-C5g936Qd.js","assets/dictation-priming-DGpw1lUV.js","assets/timestamp-preference-DgrTvVNx.js","assets/src-6TqoULh8.js","assets/speech-C5U8h4In.js","assets/soundscape-cues-5_sT5Un6.js","assets/wc-scoop-color-CByZNEJo.js","assets/wc-shell-WkeczD9x.css","assets/wc-follower-B8OxCAeY.js","assets/theme-engine-jfuTMXZM.js","assets/dip-CxC1oNbs.js","assets/wc-permissions-registry-Blyunq37.js","assets/hid-device-registry-DboUgvzI.js","assets/serial-port-registry-DsPZvGpT.js","assets/usb-operations-BQbhk96u.js","assets/usb-device-registry-BOGfZXgp.js","assets/sprinkle-renderer-qv3mGpBG.js","assets/theme-C8b_iQ_9.js","assets/sprinkle-bridge-YYPWJ55I.js","assets/shared-CR9p6ivA.js","assets/mime-types-ugOWOUZ9.js","assets/wc-attach-DU0svqb7.js","assets/wc-live-CdHNHipT.js","assets/account-store-D-iMuoaP.js","assets/compat-DyT25qXb.js","assets/models-CzSI8IsT.js","assets/provider-env-D37PhSJu.js","assets/__vite-browser-external-SwrSgYTf.js","assets/context-compaction-dcYYajWb.js","assets/secret-topology-CptRwAX3.js","assets/secrets-bridge-client-D6nwnBvr.js","assets/port-bridge-client-CoFZLSYm.js","assets/tool-ui-DfXu6quJ.js","assets/providers-DE-eWlQD.js","assets/panel-rpc-DmJSNs0I.js","assets/bedrock-camp-BEi8MYUS.js","assets/transform-messages-fFaW-DLG.js","assets/tray-follower-status-CyJIKXH4.js","assets/session-freezer-C59A1pKQ.js","assets/attachments-CByeG2Ru.js","assets/types-idfTVsM8.js","assets/leader-session-events-m7I5BMZy.js","assets/page-follower-tray-BblmGsa_.js","assets/wc-sprinkles-Di46POCG.js","assets/oauth-bootstrap-C6Jt7mJP.js","assets/provider-settings-CwdBRbVy.js","assets/clipboard-DuHpK59o.js","assets/tray-join-url-BIvzbiFR.js","assets/legacy-styles-DcRu2WCJ.js","assets/connect-surface-YjE945TK.js","assets/wc-extension-CBkgPjaS.js","assets/wc-detached-B3WCbbZT.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import"./modulepreload-polyfill-Dezn_h7o.js";import{t as e}from"./preload-helper-Czpn1I53.js";import{a as t}from"./account-store-D-iMuoaP.js";import{t as n}from"./logger-DDBAeTLF.js";import"./src-CS5gSDhT.js";import"./electron-overlay-route-CjT6k9Df.js";import{c as r,l as i,s as a}from"./proxied-fetch-D5h5REZy.js";import{n as o,t as s}from"./runtime-env-DH4NDw4t.js";import{a as c}from"./providers-DE-eWlQD.js";import{t as l}from"./bridge-launch-params-jegYRGJ6.js";import"./messages-BD4p8GuF.js";import{c as u,l as d,o as f,t as p}from"./tray-runtime-config-DquE2Rx9.js";import{t as m}from"./setup-sudo-B-bx-L9P.js";import{t as h}from"./telemetry-C8rZr13D.js";import"./provider-settings-CwdBRbVy.js";var g=`slicc-nuke-control`,_=[`slicc:welcome-flow-fired`,`slicc.trayJoinUrl`,`slicc.trayWorkerBaseUrl`];function v(e=()=>location.reload()){if(typeof BroadcastChannel!=`function`)return()=>{};let t=new BroadcastChannel(g),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()}}async function y(){try{let e=await navigator.serviceWorker?.getRegistrations?.();e&&await Promise.all(e.map(e=>e.unregister().catch(()=>!1)))}catch{}try{let e=await indexedDB.databases();await Promise.all(e.filter(e=>!!e.name).map(e=>new Promise(t=>{let n=indexedDB.deleteDatabase(e.name);n.onsuccess=()=>t(),n.onerror=()=>t(),n.onblocked=()=>t()})))}catch{}try{let e=navigator.storage;if(typeof e?.getDirectory==`function`){let t=await e.getDirectory(),n=[];for await(let e of t.keys())n.push(e);await Promise.all(n.map(e=>t.removeEntry(e,{recursive:!0}).catch(()=>{})))}}catch{}}function b(e,t,n={}){let r=n.wipe??y,i=n.reload??(()=>location.reload()),a=t instanceof Error?t.message:String(t),o=document.createElement(`div`);o.style.cssText=`padding:2rem;text-align:center;font-family:system-ui;`;let s=document.createElement(`h1`);s.style.color=`var(--s2-negative, #e34850)`,s.textContent=`Failed to start`;let c=document.createElement(`p`);c.style.color=`var(--s2-content-tertiary, #717171)`,c.textContent=a;let l=document.createElement(`div`);l.style.cssText=`display:flex;gap:0.75rem;justify-content:center;flex-wrap:wrap;margin-top:1.5rem;`;let u=document.createElement(`button`);u.type=`button`,u.textContent=`Reset local data & reload`,u.style.cssText=`padding:0.5rem 1rem;cursor:pointer;border:1px solid var(--s2-negative, #e34850);background:var(--s2-negative, #e34850);color:#fff;border-radius:4px;`;let d=document.createElement(`button`);for(d.type=`button`,d.textContent=`Reload`,d.style.cssText=`padding:0.5rem 1rem;cursor:pointer;border:1px solid var(--s2-content-tertiary, #717171);background:transparent;color:inherit;border-radius:4px;`,u.addEventListener(`click`,()=>{u.disabled=!0,d.disabled=!0,u.textContent=`Resetting…`,(async()=>{try{await r()}catch{}for(let e of _)try{localStorage.removeItem(e)}catch{}i()})()}),d.addEventListener(`click`,()=>{i()}),l.append(u,d),o.append(s,c,l);e.firstChild;)e.removeChild(e.firstChild);e.appendChild(o)}var x=`slicc:bridge-config`,S=`slicc:extension-delegate-config`;function C(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 w=n(`boot/ext-fetch-delegate`);function T(){let e=globalThis.chrome?.runtime;return e&&typeof e.connect==`function`?e:null}function E(e,t,n){let r=T();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 D(e){typeof navigator>`u`||!navigator.serviceWorker||navigator.serviceWorker.addEventListener(`message`,t=>{if(!C(t.data))return;let n=t.ports?.[0];if(!n){w.warn(`delegated fetch envelope arrived without a response port`);return}E(t.data,n,e)})}function O(){if(o())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-Dezn_h7o.js";import{t as e}from"./preload-helper
|
|
|
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 k=null;function A(){return k||(k=v(),k)}n(`stale-asset`);var ee=`slicc-stale-asset-reload`;function te(e,t){if(typeof BroadcastChannel!=`function`)return()=>{};let n=new BroadcastChannel(ee),r=n=>{let r=n.data;r?.type!==`stale-asset-reload`||r.instanceId!==e||t(r.replayTurn===!0)};return n.addEventListener(`message`,r),()=>{n.removeEventListener(`message`,r),n.close()}}var ne=`slicc:stale-asset-reloaded-at`,re=6e4,j=`slicc:stale-asset-replay`;function M(e=window.sessionStorage){try{e.setItem(j,`1`)}catch{}}function N(e=window.sessionStorage){try{return e.getItem(j)===`1`?(e.removeItem(j),!0):!1}catch{return!1}}function P(){return{reload:()=>window.location.reload(),storage:window.sessionStorage,now:()=>Date.now(),windowMs:re,storageKey:ne}}function ie(e,t,n){return e===null||t-e>=n}function F(e=P()){let t;try{t=e.storage.getItem(e.storageKey)}catch{return!1}let n=t===null?null:Number(t),r=n!==null&&Number.isFinite(n)?n:null,i=e.now();if(!ie(r,i,e.windowMs))return!1;try{e.storage.setItem(e.storageKey,String(i))}catch{return!1}return e.reload(),!0}var I=null,L=null;function ae(e){I||(L={...P(),...e},I=e=>{F(L)&&e.preventDefault()},window.addEventListener(`vite:preloadError`,I))}var R=null;function z(e){return R||(R=te(e,e=>{e&&M(),F(L??void 0)}),R)}var B=`slicc-cdp-superseded-banner`;function V(e){if(e.getElementById(B))return;let t=e.createElement(`div`);t.id=B,t.setAttribute(`role`,`alert`),t.textContent=`Another SLICC tab or window has taken control of this browser instance. Only one tab can drive the browser per instance — close the other tabs, then reload this page to resume.`,t.style.cssText=[`position:fixed`,`top:0`,`left:0`,`right:0`,`z-index:2147483647`,`padding:10px 16px`,`background:#b3261e`,`color:#fff`,`font:13px/1.4 system-ui,sans-serif`,`text-align:center`,`box-shadow:0 1px 4px rgba(0,0,0,0.3)`].join(`;`),e.body.appendChild(t)}function H(e,t,n){if(t){try{if(new URL(e).searchParams.has(`detached`))return`extension-detached`}catch{}return`extension`}try{let t=new URL(e);return t.searchParams.get(`connect`)===`1`?`connect`:t.searchParams.get(`runtime`)===`hosted-leader`?`hosted-leader`:t.searchParams.get(`cherry`)===`1`?`cherry`:u(e,n===void 0?typeof window<`u`?window.localStorage:null:n)?`follower`:W(t)?`electron-overlay`:`standalone`}catch{return`standalone`}}function U(e,t){return e===`electron-overlay`||e===`hosted-leader`||e===`standalone`&&t}function W(e){return e.pathname===`/electron`||e.pathname===`/electron/`||e.searchParams.get(`runtime`)===`electron-overlay`}function G(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`slicc-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function K(e){let t;try{t=new URLSearchParams(e)}catch{return null}if(t.get(`slicc`)!==`leader`)return null;let n=t.get(`ext`);return n?{extensionId:n}:null}var q=[100,200,400,800,1600];async function J(e,t,n,r=q,i=e=>new Promise(t=>setTimeout(t,e))){let a=r.length+1,o=null;for(let s=0;s<a;s++)try{await e.connect(t),s>0&&n.info(`CDP bridge connect succeeded after retry`,{attempt:s+1});return}catch(e){o=e,s<r.length&&await i(r[s]??0)}n.warn(`Initial CDP connect failed after retries; worker-forwarded commands will retry on demand`,o instanceof Error?o.message:String(o))}async function oe(t,n,r){let{ExtensionBridgeTransport:i}=await e(async()=>{let{ExtensionBridgeTransport:e}=await import(`./extension-bridge-transport-DHBo-K6K.js`);return{ExtensionBridgeTransport:e}},__vite__mapDeps([0,1])),{mapDiscoveryPayloadToLickEvent:a,mapNavigatePayloadToLickEvent:o}=await e(async()=>{let{mapDiscoveryPayloadToLickEvent:e,mapNavigatePayloadToLickEvent:t}=await import(`./lick-ws-bridge-DZ9b0hn4.js`);return{mapDiscoveryPayloadToLickEvent:e,mapNavigatePayloadToLickEvent:t}},__vite__mapDeps([2,1,3,4,5,6,7,8,9,10,11,12,13])),s=null,c=[],l=!1,u=e=>{s=e;for(let t of c)e.sendForwardedLick(t);c.length=0},d=e=>{if(e){if(s){s.sendForwardedLick(e);return}c.length>=50&&(c.shift(),l||(l=!0,r.warn(`extension-bridge lick buffer overflow (cap 50); dropping oldest pending licks until the kernel client attaches`))),c.push(e)}},f=new t(new i({extensionId:n,onLick:e=>{d(o(e))},onDiscovery:e=>{d(a(e))},onOpenSettings:()=>{globalThis.dispatchEvent(new CustomEvent(`slicc:open-settings-from-panel`))}}));return await J(f,void 0,r),{browser:f,attachLickForwardingClient:u}}async function se(t){let{runtimeMode:n,envBaseUrl:o,window:c,log:u}=t,h=n===`electron-overlay`;u.info(`setting up standalone page runtime (BrowserAPI + CDP)`,{runtimeMode:n});let{BrowserAPI:g}=await e(async()=>{let{BrowserAPI:e}=await import(`./cdp-7evcrxxP.js`);return{BrowserAPI:e}},__vite__mapDeps([14,1,15,16,8,17,18,4]));await m({log:u});let _,v,y,b=null,x=null,S=null,C=null,w,T=n===`cherry`?null:K(c.location.search),E=!!T&&s(),D=n===`cherry`||E?null:l(c.location.search);D?.apiBaseUrl&&(b=D.apiBaseUrl,i(D.apiBaseUrl),x=D.token,a(D.token)),D?.lickWsUrl&&(S=D.lickWsUrl);let O=await f(),k=U(n,O!==null)?p:null;if(await d({locationHref:c.location.href,storage:c.localStorage,envBaseUrl:o,defaultWorkerBaseUrl:k,runtimeConfigFetcher:async()=>O}),n===`cherry`){let{setupCherryFollower:t}=await e(async()=>{let{setupCherryFollower:e}=await import(`./main-cherry-CGm5knH6.js`);return{setupCherryFollower:e}},__vite__mapDeps([19,1,14,15,16,8,17,18,4,20])),n=await t();_=n.browser,v=n.joinUrl,y=n.transport}else if(T&&s()){u.info(`Routing CDP through the extension bridge (leader tab)`);let e=await oe(g,T.extensionId,u);_=e.browser,w=e.attachLickForwardingClient,C=T.extensionId,r(T.extensionId)}else{_=new g,D&&u.info(`Routing CDP through local standalone bridge`,{url:D.url,role:D.role??`(unset)`});let e=D?{url:D.url,protocols:D.subprotocol}:void 0;D?.role===`follower`?(u.info(`Skipping CDP connect for follower overlay tab`),_.primeConnectOptions(e)):(await J(_,e,u),_.setCdpSupersededHandler(()=>V(c.document)))}let A=_.getTransport();return globalThis.__slicc_browser=_,{browser:_,realCdpTransport:A,cherryJoinUrl:v,cherryTransport:y,instanceId:G(),isElectronOverlay:h,localApiBaseUrl:b,bridgeToken:x,localLickWsUrl:S,extensionDelegateId:C,attachLickForwardingClient:w}}var Y=n(`boot/sw-registration`);async function ce(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 le())return`reload-pending`;if(!(`serviceWorker`in navigator)||n)return`ready`;try{if(await navigator.serviceWorker.register(`/preview-sw.js`,{scope:`/preview/`}),Y.info(`Preview SW registered`),!o())try{await navigator.serviceWorker.register(`/llm-proxy-sw.js`,{scope:`/`}),Y.info(`LLM-proxy SW registered`)}catch(e){Y.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`),Y.info(`Reloading once to gain SW control`),location.reload(),`reload-pending`;sessionStorage.removeItem(`slicc-sw-reloaded`),e&&(X(e),navigator.serviceWorker.addEventListener(`controllerchange`,()=>{X(e)})),t&&(Z(t),navigator.serviceWorker.addEventListener(`controllerchange`,()=>{Z(t)}))}catch(e){Y.error(`Preview SW registration failed — preview feature will not work`,e)}return`ready`}function X(e){let t=navigator.serviceWorker.controller;if(!t)return;let n={type:x,apiBaseUrl:e.apiBaseUrl,token:e.token};try{t.postMessage(n)}catch(e){Y.warn(`LLM-proxy SW bridge-config postMessage failed`,e)}}function Z(e){let t=navigator.serviceWorker.controller;if(!t)return;let n={type:S,extensionId:e.extensionId};try{t.postMessage(n)}catch(e){Y.warn(`LLM-proxy SW extension-delegate postMessage failed`,e)}}async function le(){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`),Y.info(`connect mode: detaching from service worker (no proxy on worker origin)`),location.reload(),!0;sessionStorage.removeItem(`slicc-connect-sw-cleared`)}catch(e){Y.error(`connect-mode SW cleanup failed`,e)}return!1}var Q=n(`main`);function $(e){try{return new URL(e).searchParams.has(`ui-fixture`)}catch{return!1}}async function ue(){ae();let n=document.getElementById(`app`);if(!n)throw Error(`#app element not found`);let r=o(),i=H(window.location.href,r);if($(window.location.href)){let{mountWcUiPreview:t}=await e(async()=>{let{mountWcUiPreview:e}=await import(`./wc-shell-ltnl45Bc.js`).then(e=>e.a);return{mountWcUiPreview:e}},__vite__mapDeps([21,4,6,8,22,9,23,24,25,26,27,28,29,30]));t(n);return}O(),A(),i!==`connect`&&h().catch(()=>{});let a=l(window.location.search),u=i===`cherry`?null:K(window.location.search),d=!!u&&s();if(await ce(a?{apiBaseUrl:a.apiBaseUrl,token:a.token}:null,d&&u?{extensionId:u.extensionId}:null)===`reload-pending`)return;if(!r&&(i===`follower`||i===`cherry`)){let{mountWcUiFollower:t}=await e(async()=>{let{mountWcUiFollower:e}=await import(`./wc-follower-CLveL_SV.js`);return{mountWcUiFollower:e}},__vite__mapDeps([31,6,1,18,4,8,11,5,7,9,10,12,32,33,34,35,36,37,38,39,40,41,42,43,44,21,22,23,24,25,26,27,28,29,30,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,3,13,61,62,63,64,65,17,66]));return t(n,Q,i)}await c(),t();let{bootstrapOAuthReplicas:f}=await e(async()=>{let{bootstrapOAuthReplicas:e}=await import(`./oauth-bootstrap-BOl1JV2i.js`);return{bootstrapOAuthReplicas:e}},__vite__mapDeps([67,6,46,4,47,48,49,50,51,1,8,5,7,9,10,52,53,54,55,56,57,58,59,68,11,12,60,69,22,70]));if(await Promise.race([f().catch(e=>{Q.error(`OAuth bootstrap failed`,e)}),new Promise(e=>setTimeout(e,1e4))]),i===`connect`){globalThis.__slicc_connect_mode=!0;let{loadLegacyStyles:t}=await e(async()=>{let{loadLegacyStyles:e}=await import(`./legacy-styles-DcRu2WCJ.js`);return{loadLegacyStyles:e}},__vite__mapDeps([71,6]));await t();let{mountConnectSurface:r}=await e(async()=>{let{mountConnectSurface:e}=await import(`./connect-surface-Di4VE6gd.js`);return{mountConnectSurface:e}},__vite__mapDeps([72,46,4,6,47,48,49,50,51,1,8,5,7,9,10,52,53,54,55,56,57,58,59,68,11,12,60,69,22,70]));await r(n);return}if(r){let{mountWcUiExtension:t}=await e(async()=>{let{mountWcUiExtension:e}=await import(`./wc-extension-DksCcKMT.js`);return{mountWcUiExtension:e}},__vite__mapDeps([73,6,74,12,45,46,4,47,48,49,50,51,1,8,5,7,9,10,52,53,54,55,56,57,58,59,11,60,22,3,13,42,43,24,33,34,35,36,37,38,39,40,32,41,61,62,63,23,21,25,26,27,28,29,30,64]));return t(n,Q,i===`extension-detached`)}d&&u&&D(u.extensionId);let{mountWcUiLive:p}=await e(async()=>{let{mountWcUiLive:e}=await import(`./wc-live-DWqGURv2.js`);return{mountWcUiLive:e}},__vite__mapDeps([45,6,46,4,47,48,49,50,51,1,8,5,7,9,10,52,53,54,55,56,57,58,59,11,12,60,22,3,13,42,43,24,33,34,35,36,37,38,39,40,32,41,61,62,63,23,21,25,26,27,28,29,30,64]));return p(n,Q,i)}ue().catch(e=>{Q.error(`Fatal error`,e);let t=document.getElementById(`app`);t&&b(t,e)});export{z as i,N as n,F as r,se 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 k=null;function A(){return k||(k=v(),k)}n(`stale-asset`);var ee=`slicc-stale-asset-reload`;function te(e,t){if(typeof BroadcastChannel!=`function`)return()=>{};let n=new BroadcastChannel(ee),r=n=>{let r=n.data;r?.type!==`stale-asset-reload`||r.instanceId!==e||t(r.replayTurn===!0)};return n.addEventListener(`message`,r),()=>{n.removeEventListener(`message`,r),n.close()}}var ne=`slicc:stale-asset-reloaded-at`,re=6e4,j=`slicc:stale-asset-replay`;function M(e=window.sessionStorage){try{e.setItem(j,`1`)}catch{}}function N(e=window.sessionStorage){try{return e.getItem(j)===`1`?(e.removeItem(j),!0):!1}catch{return!1}}function P(){return{reload:()=>window.location.reload(),storage:window.sessionStorage,now:()=>Date.now(),windowMs:re,storageKey:ne}}function ie(e,t,n){return e===null||t-e>=n}function F(e=P()){let t;try{t=e.storage.getItem(e.storageKey)}catch{return!1}let n=t===null?null:Number(t),r=n!==null&&Number.isFinite(n)?n:null,i=e.now();if(!ie(r,i,e.windowMs))return!1;try{e.storage.setItem(e.storageKey,String(i))}catch{return!1}return e.reload(),!0}var I=null,L=null;function ae(e){I||(L={...P(),...e},I=e=>{F(L)&&e.preventDefault()},window.addEventListener(`vite:preloadError`,I))}var R=null;function z(e){return R||(R=te(e,e=>{e&&M(),F(L??void 0)}),R)}var B=`slicc-cdp-superseded-banner`;function V(e){if(e.getElementById(B))return;let t=e.createElement(`div`);t.id=B,t.setAttribute(`role`,`alert`),t.textContent=`Another SLICC tab or window has taken control of this browser instance. Only one tab can drive the browser per instance — close the other tabs, then reload this page to resume.`,t.style.cssText=[`position:fixed`,`top:0`,`left:0`,`right:0`,`z-index:2147483647`,`padding:10px 16px`,`background:#b3261e`,`color:#fff`,`font:13px/1.4 system-ui,sans-serif`,`text-align:center`,`box-shadow:0 1px 4px rgba(0,0,0,0.3)`].join(`;`),e.body.appendChild(t)}function H(e,t,n){if(t){try{if(new URL(e).searchParams.has(`detached`))return`extension-detached`}catch{}return`extension`}try{let t=new URL(e);return t.searchParams.get(`connect`)===`1`?`connect`:t.searchParams.get(`runtime`)===`hosted-leader`?`hosted-leader`:t.searchParams.get(`cherry`)===`1`?`cherry`:u(e,n===void 0?typeof window<`u`?window.localStorage:null:n)?`follower`:W(t)?`electron-overlay`:`standalone`}catch{return`standalone`}}function U(e,t){return e===`electron-overlay`||e===`hosted-leader`||e===`standalone`&&t}function W(e){return e.pathname===`/electron`||e.pathname===`/electron/`||e.searchParams.get(`runtime`)===`electron-overlay`}function G(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`slicc-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function K(e){let t;try{t=new URLSearchParams(e)}catch{return null}if(t.get(`slicc`)!==`leader`)return null;let n=t.get(`ext`);return n?{extensionId:n}:null}var q=[100,200,400,800,1600];async function J(e,t,n,r=q,i=e=>new Promise(t=>setTimeout(t,e))){let a=r.length+1,o=null;for(let s=0;s<a;s++)try{await e.connect(t),s>0&&n.info(`CDP bridge connect succeeded after retry`,{attempt:s+1});return}catch(e){o=e,s<r.length&&await i(r[s]??0)}n.warn(`Initial CDP connect failed after retries; worker-forwarded commands will retry on demand`,o instanceof Error?o.message:String(o))}async function oe(t,n,r){let{ExtensionBridgeTransport:i}=await e(async()=>{let{ExtensionBridgeTransport:e}=await import(`./extension-bridge-transport-DHBo-K6K.js`);return{ExtensionBridgeTransport:e}},__vite__mapDeps([0,1])),{mapDiscoveryPayloadToLickEvent:a,mapNavigatePayloadToLickEvent:o}=await e(async()=>{let{mapDiscoveryPayloadToLickEvent:e,mapNavigatePayloadToLickEvent:t}=await import(`./lick-ws-bridge-DUnNTVql.js`);return{mapDiscoveryPayloadToLickEvent:e,mapNavigatePayloadToLickEvent:t}},__vite__mapDeps([2,1,3,4,5,6,7,8,9,10,11,12,13])),s=null,c=[],l=!1,u=e=>{s=e;for(let t of c)e.sendForwardedLick(t);c.length=0},d=e=>{if(e){if(s){s.sendForwardedLick(e);return}c.length>=50&&(c.shift(),l||(l=!0,r.warn(`extension-bridge lick buffer overflow (cap 50); dropping oldest pending licks until the kernel client attaches`))),c.push(e)}},f=new t(new i({extensionId:n,onLick:e=>{d(o(e))},onDiscovery:e=>{d(a(e))},onOpenSettings:()=>{globalThis.dispatchEvent(new CustomEvent(`slicc:open-settings-from-panel`))}}));return await J(f,void 0,r),{browser:f,attachLickForwardingClient:u}}async function se(t){let{runtimeMode:n,envBaseUrl:o,window:c,log:u}=t,h=n===`electron-overlay`;u.info(`setting up standalone page runtime (BrowserAPI + CDP)`,{runtimeMode:n});let{BrowserAPI:g}=await e(async()=>{let{BrowserAPI:e}=await import(`./cdp-7evcrxxP.js`);return{BrowserAPI:e}},__vite__mapDeps([14,1,15,16,8,17,18,4]));await m({log:u});let _,v,y,b=null,x=null,S=null,C=null,w,T=n===`cherry`?null:K(c.location.search),E=!!T&&s(),D=n===`cherry`||E?null:l(c.location.search);D?.apiBaseUrl&&(b=D.apiBaseUrl,i(D.apiBaseUrl),x=D.token,a(D.token)),D?.lickWsUrl&&(S=D.lickWsUrl);let O=await f(),k=U(n,O!==null)?p:null;if(await d({locationHref:c.location.href,storage:c.localStorage,envBaseUrl:o,defaultWorkerBaseUrl:k,runtimeConfigFetcher:async()=>O}),n===`cherry`){let{setupCherryFollower:t}=await e(async()=>{let{setupCherryFollower:e}=await import(`./main-cherry-CGm5knH6.js`);return{setupCherryFollower:e}},__vite__mapDeps([19,1,14,15,16,8,17,18,4,20])),n=await t();_=n.browser,v=n.joinUrl,y=n.transport}else if(T&&s()){u.info(`Routing CDP through the extension bridge (leader tab)`);let e=await oe(g,T.extensionId,u);_=e.browser,w=e.attachLickForwardingClient,C=T.extensionId,r(T.extensionId)}else{_=new g,D&&u.info(`Routing CDP through local standalone bridge`,{url:D.url,role:D.role??`(unset)`});let e=D?{url:D.url,protocols:D.subprotocol}:void 0;D?.role===`follower`?(u.info(`Skipping CDP connect for follower overlay tab`),_.primeConnectOptions(e)):(await J(_,e,u),_.setCdpSupersededHandler(()=>V(c.document)))}let A=_.getTransport();return globalThis.__slicc_browser=_,{browser:_,realCdpTransport:A,cherryJoinUrl:v,cherryTransport:y,instanceId:G(),isElectronOverlay:h,localApiBaseUrl:b,bridgeToken:x,localLickWsUrl:S,extensionDelegateId:C,attachLickForwardingClient:w}}var Y=n(`boot/sw-registration`);async function ce(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 le())return`reload-pending`;if(!(`serviceWorker`in navigator)||n)return`ready`;try{if(await navigator.serviceWorker.register(`/preview-sw.js`,{scope:`/preview/`}),Y.info(`Preview SW registered`),!o())try{await navigator.serviceWorker.register(`/llm-proxy-sw.js`,{scope:`/`}),Y.info(`LLM-proxy SW registered`)}catch(e){Y.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`),Y.info(`Reloading once to gain SW control`),location.reload(),`reload-pending`;sessionStorage.removeItem(`slicc-sw-reloaded`),e&&(X(e),navigator.serviceWorker.addEventListener(`controllerchange`,()=>{X(e)})),t&&(Z(t),navigator.serviceWorker.addEventListener(`controllerchange`,()=>{Z(t)}))}catch(e){Y.error(`Preview SW registration failed — preview feature will not work`,e)}return`ready`}function X(e){let t=navigator.serviceWorker.controller;if(!t)return;let n={type:x,apiBaseUrl:e.apiBaseUrl,token:e.token};try{t.postMessage(n)}catch(e){Y.warn(`LLM-proxy SW bridge-config postMessage failed`,e)}}function Z(e){let t=navigator.serviceWorker.controller;if(!t)return;let n={type:S,extensionId:e.extensionId};try{t.postMessage(n)}catch(e){Y.warn(`LLM-proxy SW extension-delegate postMessage failed`,e)}}async function le(){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`),Y.info(`connect mode: detaching from service worker (no proxy on worker origin)`),location.reload(),!0;sessionStorage.removeItem(`slicc-connect-sw-cleared`)}catch(e){Y.error(`connect-mode SW cleanup failed`,e)}return!1}var Q=n(`main`);function $(e){try{return new URL(e).searchParams.has(`ui-fixture`)}catch{return!1}}async function ue(){ae();let n=document.getElementById(`app`);if(!n)throw Error(`#app element not found`);let r=o(),i=H(window.location.href,r);if($(window.location.href)){let{mountWcUiPreview:t}=await e(async()=>{let{mountWcUiPreview:e}=await import(`./wc-shell-BPXYInqs.js`).then(e=>e.a);return{mountWcUiPreview:e}},__vite__mapDeps([21,4,6,8,22,9,23,24,25,26,27,28,29,30]));t(n);return}O(),A(),i!==`connect`&&h().catch(()=>{});let a=l(window.location.search),u=i===`cherry`?null:K(window.location.search),d=!!u&&s();if(await ce(a?{apiBaseUrl:a.apiBaseUrl,token:a.token}:null,d&&u?{extensionId:u.extensionId}:null)===`reload-pending`)return;if(!r&&(i===`follower`||i===`cherry`)){let{mountWcUiFollower:t}=await e(async()=>{let{mountWcUiFollower:e}=await import(`./wc-follower-B8OxCAeY.js`);return{mountWcUiFollower:e}},__vite__mapDeps([31,6,1,18,4,8,11,5,7,9,10,12,32,33,34,35,36,37,38,39,40,41,42,43,44,21,22,23,24,25,26,27,28,29,30,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,3,13,61,62,63,64,65,17,66]));return t(n,Q,i)}await c(),t();let{bootstrapOAuthReplicas:f}=await e(async()=>{let{bootstrapOAuthReplicas:e}=await import(`./oauth-bootstrap-C6Jt7mJP.js`);return{bootstrapOAuthReplicas:e}},__vite__mapDeps([67,6,46,4,47,48,49,50,51,1,8,5,7,9,10,52,53,54,55,56,57,58,59,68,11,12,60,69,22,70]));if(await Promise.race([f().catch(e=>{Q.error(`OAuth bootstrap failed`,e)}),new Promise(e=>setTimeout(e,1e4))]),i===`connect`){globalThis.__slicc_connect_mode=!0;let{loadLegacyStyles:t}=await e(async()=>{let{loadLegacyStyles:e}=await import(`./legacy-styles-DcRu2WCJ.js`);return{loadLegacyStyles:e}},__vite__mapDeps([71,6]));await t();let{mountConnectSurface:r}=await e(async()=>{let{mountConnectSurface:e}=await import(`./connect-surface-YjE945TK.js`);return{mountConnectSurface:e}},__vite__mapDeps([72,46,4,6,47,48,49,50,51,1,8,5,7,9,10,52,53,54,55,56,57,58,59,68,11,12,60,69,22,70]));await r(n);return}if(r){let{mountWcUiExtension:t}=await e(async()=>{let{mountWcUiExtension:e}=await import(`./wc-extension-CBkgPjaS.js`);return{mountWcUiExtension:e}},__vite__mapDeps([73,6,74,12,45,46,4,47,48,49,50,51,1,8,5,7,9,10,52,53,54,55,56,57,58,59,11,60,22,3,13,42,43,24,33,34,35,36,37,38,39,40,32,41,61,62,63,23,21,25,26,27,28,29,30,64]));return t(n,Q,i===`extension-detached`)}d&&u&&D(u.extensionId);let{mountWcUiLive:p}=await e(async()=>{let{mountWcUiLive:e}=await import(`./wc-live-CdHNHipT.js`);return{mountWcUiLive:e}},__vite__mapDeps([45,6,46,4,47,48,49,50,51,1,8,5,7,9,10,52,53,54,55,56,57,58,59,11,12,60,22,3,13,42,43,24,33,34,35,36,37,38,39,40,32,41,61,62,63,23,21,25,26,27,28,29,30,64]));return p(n,Q,i)}ue().catch(e=>{Q.error(`Fatal error`,e);let t=document.getElementById(`app`);t&&b(t,e)});export{z as i,N as n,F as r,se as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/account-store-
|
|
2
|
-
import{t as e}from"./preload-helper-Czpn1I53.js";import{t}from"./mime-types-ugOWOUZ9.js";import{n,t as r}from"./base64-DpPqYZJF.js";import"./src-CS5gSDhT.js";import{o as i,r as a,t as o}from"./proxied-fetch-DETjVL-j.js";import{n as s}from"./runtime-env-DH4NDw4t.js";import{t as c}from"./types-idfTVsM8.js";import"./backend-local-smcj-_Ox.js";import"./mount-table-store-CfQUN_2R.js";import{t as l}from"./mount-bridge-client-BVLVI9yX.js";function u(e,t,n){let r=`----DaMount${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`,i=new TextEncoder,a=i.encode(`--${r}\r\nContent-Disposition: form-data; name="data"; filename="${e}"\r\nContent-Type: ${t}\r\n\r\n`),o=i.encode(`\r\n--${r}--\r\n`),s=new Uint8Array(a.byteLength+n.byteLength+o.byteLength);return s.set(a,0),s.set(n,a.byteLength),s.set(o,a.byteLength+n.byteLength),{contentType:`multipart/form-data; boundary=${r}`,body:s}}function d(e){return e.split(`/`).pop()||`data`}function f(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 p=5*1024*1024,m=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=f(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??p,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new c(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toSourcePath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/source/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}toListPath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/list/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r={};n&&(r[`if-none-match`]=n.etag);let i=await this.transport({method:`GET`,path:this.toSourcePath(t),headers:r});if(i.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(i.status===404)throw await this.cache.invalidateBody(t),new c(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new c(`EACCES`,`da access denied`,e);if(i.status>=400)throw new c(`EIO`,`da readFile failed: ${i.status}`,e);let a=i.headers.get(`content-length`),o=a?Number(a):void 0;if(o!==void 0&&o>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes`,e);let s=new Uint8Array(await i.arrayBuffer());if(s.byteLength>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=i.headers.get(`etag`)??``,u=l.startsWith(`W/`)?l.slice(2):l;return await this.cache.putBody(t,s,u),s}async writeFile(e,n){if(this.assertOpen(e),n.byteLength>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=this.toMountRelative(e),i=await this.cache.getBody(r),a=u(d(e),t(e),n),o={"content-type":a.contentType,"content-length":String(a.body.byteLength)};i?.etag?o[`if-match`]=i.etag.startsWith(`W/`)?i.etag.slice(2):i.etag:i||(o[`if-none-match`]=`*`);let s=()=>this.transport({method:`POST`,path:this.toSourcePath(r),headers:o,body:a.body}),l,f=1;try{l=await s()}catch{f=2,l=await s()}if(l.status===412){if(f===2){let t=await this.transport({method:`HEAD`,path:this.toSourcePath(r)});if(t.status>=400)throw new c(`EIO`,`da reconcile HEAD failed: ${t.status}`,e);let i=t.headers.get(`etag`)??``;await this.cache.putBody(r,n,i);let a=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a);return}await this.cache.invalidateBody(r);try{await this.readFile(e)}catch{}throw new c(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(l.status===401||l.status===403)throw new c(`EACCES`,`da write denied`,e);if(l.status>=400)throw new c(`EIO`,`da writeFile failed: ${l.status}`,e);let p=l.headers.get(`etag`)??``;await this.cache.putBody(r,n,p);let m=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(m)}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.transport({method:`GET`,path:this.toListPath(t)});if(r.status===404)throw new c(`ENOENT`,`no such directory`,e);if(r.status>=400)throw new c(`EIO`,`da list failed: ${r.status}`,e);let i=(await r.json()).map(e=>e.ext?{name:`${e.name}.${e.ext}`,kind:`file`,etag:e.etag,lastModified:e.lastModified}:{name:e.name,kind:`directory`,lastModified:e.lastModified});return await this.cache.putListing(t,i),i}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.size,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),i=r.pop()??``,a=r.join(`/`),o=await this.cache.getListing(a);if(o&&!this.cache.isStale(o.cachedAt)){let t=o.entries.find(e=>e.name===i);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??o.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??o.cachedAt};if(!t)throw new c(`ENOENT`,`no such file or directory`,e)}let s=await this.transport({method:`HEAD`,path:this.toSourcePath(t)});if(s.status===200){let e=Number(s.headers.get(`content-length`)??`0`),t=s.headers.get(`etag`)??``,n=s.headers.get(`last-modified`),r=n?Date.parse(n):0;if(o){let n=o.entries.map(n=>n.name===i&&n.kind===`file`?{...n,size:e,etag:t,lastModified:r}:n);await this.cache.putListing(a,n)}return{kind:`file`,size:e,mtime:r,etag:t}}if(s.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new c(`ENOENT`,`no such file or directory`,e)}throw new c(`EIO`,`da stat failed: ${s.status}`,e)}async mkdir(e){}async remove(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.transport({method:`DELETE`,path:this.toSourcePath(t)});if(n.status===404)throw new c(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new c(`EACCES`,`da delete denied`,e);if(n.status>=400)throw new c(`EIO`,`da delete failed: ${n.status}`,e);await this.cache.invalidateBody(t);let r=t.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(r)}async refresh(e){this.assertOpen(`/`);let t={added:[],removed:[],changed:[],unchanged:0,errors:[]},n=[``];for(;n.length>0;){let e=n.pop();try{await this.refreshDir(e,t,n)}catch(n){t.errors.push({path:e,message:n instanceof Error?n.message:String(n)})}}return e?.bodies&&await this.refreshBodies(t),t}async classifyFile(e,t,n){let r=await this.cache.getBody(e);r?t&&r.etag!==t?(await this.cache.invalidateBody(e),n.changed.push(e)):n.unchanged++:n.added.push(e)}async refreshDir(e,t,n){let r=await this.transport({method:`GET`,path:this.toListPath(e)});if(r.status>=400){t.errors.push({path:e,message:`list failed: ${r.status}`});return}let i=await r.json(),a=[];for(let r of i)if(r.ext){let n=e?`${e}/${r.name}.${r.ext}`:`${r.name}.${r.ext}`;a.push({name:`${r.name}.${r.ext}`,kind:`file`,etag:r.etag,lastModified:r.lastModified}),await this.classifyFile(n,r.etag,t)}else a.push({name:r.name,kind:`directory`}),n.push(e?`${e}/${r.name}`:r.name);await this.cache.putListing(e,a)}async refreshBodies(e){for(let t of e.changed)try{await this.readFile(t)}catch(n){e.errors.push({path:t,message:n instanceof Error?n.message:String(n)})}}describe(){return{displayName:`${this.parsed.org}/${this.parsed.repo}${this.parsed.path?`/${this.parsed.path}`:``}`,source:this.source,profile:this.profile}}async close(){this.closed||=!0}};function h(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 g=25*1024*1024,_=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=h(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??g,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new c(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toS3Key(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``);return[this.parsed.prefix,t].filter(e=>e.length>0).join(`/`)}toMountRelativeKey(e){return this.parsed.prefix?e.slice(this.parsed.prefix.length+1):e}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r={};n&&(r[`if-none-match`]=n.etag);let i=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:this.toS3Key(t),headers:r});if(i.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(i.status===404)throw await this.cache.invalidateBody(t),new c(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new c(`EACCES`,`s3 access denied`,e);if(i.status>=400)throw new c(`EIO`,`s3 readFile failed: ${i.status}`,e);let a=i.headers.get(`content-length`),o=a?Number(a):void 0;if(o!==void 0&&o>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes (${o} > ${this.maxBodyBytes})`,e);let s=new Uint8Array(await i.arrayBuffer());if(s.byteLength>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=i.headers.get(`etag`)??``;return await this.cache.putBody(t,s,l),s}async writeFile(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t.byteLength>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=await this.cache.getBody(n),i={"content-type":`application/octet-stream`,"content-length":String(t.byteLength)};r?i[`if-match`]=r.etag:i[`if-none-match`]=`*`;let a=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(n),headers:i,body:t}),o,s=1;try{o=await a()}catch{s=2,o=await a()}if(o.status===412){if(s===2){let r=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status>=400)throw new c(`EIO`,`s3 reconcile HEAD failed: ${r.status}`,e);let i=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,i);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new c(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(o.status===401||o.status===403)throw new c(`EACCES`,`s3 write denied`,e);if(o.status>=400)throw new c(`EIO`,`s3 writeFile failed: ${o.status}`,e);let l=o.headers.get(`etag`)??``;await this.cache.putBody(n,t,l);let u=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(u)}async listObjectsV2(){let e=[],t;do{let n={"list-type":`2`};this.parsed.prefix&&(n.prefix=`${this.parsed.prefix}/`),t&&(n[`continuation-token`]=t);let r=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:``,query:n});if(r.status>=400)throw new c(`EIO`,`s3 list failed: ${r.status}`,`/`);let i=await r.text(),a=this.parseListingXml(i);e.push(...a.contents),t=a.nextContinuationToken}while(t);return e}parseListingXml(e){let t=[];for(let n of e.matchAll(/<Contents>([\s\S]*?)<\/Contents>/g)){let e=n[1],r=e.match(/<Key>([^<]+)<\/Key>/)?.[1]??``,i=e.match(/<ETag>([^<]+)<\/ETag>/)?.[1]??``,a=e.match(/<Size>([^<]+)<\/Size>/)?.[1]??`0`,o=e.match(/<LastModified>([^<]+)<\/LastModified>/)?.[1]??``;t.push({key:r,etag:i,size:Number(a),lastModified:o?Date.parse(o):0})}return{contents:t,nextContinuationToken:e.match(/<IsTruncated>([^<]+)<\/IsTruncated>/)?.[1]===`true`?e.match(/<NextContinuationToken>([^<]+)<\/NextContinuationToken>/)?.[1]:void 0}}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.listObjectsV2(),i=this.groupByDir(r);for(let[e,t]of i)await this.cache.putListing(e,t);return i.get(t)??[]}groupByDir(e){let t=new Map,n=e=>(t.has(e)||t.set(e,[]),t.get(e));n(``);for(let t of e){let e=this.toMountRelativeKey(t.key).split(`/`),r=e.pop();n(e.join(`/`)).push({name:r,kind:`file`,size:t.size,etag:t.etag,lastModified:t.lastModified});let i=``;for(let t of e){let e=i;i=i?`${i}/${t}`:t;let r=n(e);r.find(e=>e.name===t&&e.kind===`directory`)||r.push({name:t,kind:`directory`}),n(i)}}return t}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.body.byteLength,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),i=r.pop()??``,a=r.join(`/`),o=await this.cache.getListing(a);if(o&&!this.cache.isStale(o.cachedAt)){let t=o.entries.find(e=>e.name===i);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??o.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??o.cachedAt};if(!t)throw new c(`ENOENT`,`no such file or directory`,e)}let s=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(t)});if(s.status===200){let e=Number(s.headers.get(`content-length`)??`0`),t=s.headers.get(`etag`)??``,n=s.headers.get(`last-modified`);return{kind:`file`,size:e,mtime:n?Date.parse(n):0,etag:t}}if(s.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new c(`ENOENT`,`no such file or directory`,e)}throw new c(`EIO`,`s3 stat failed: ${s.status}`,e)}async refresh(e){this.assertOpen(`/`);let t=await this.listObjectsV2(),n=new Set(t.map(e=>this.toMountRelativeKey(e.key))),r=new Map(t.map(e=>[this.toMountRelativeKey(e.key),e.etag])),i={added:[],removed:[],changed:[],unchanged:0,errors:[]};for(let e of n){let t=await this.cache.getBody(e),n=r.get(e);t?t.etag===n?i.unchanged++:(await this.cache.invalidateBody(e),i.changed.push(e)):i.added.push(e)}let a=this.groupByDir(t);for(let[e,t]of a)await this.cache.putListing(e,t);if(e?.bodies)for(let e of i.changed)try{await this.readFile(e)}catch(t){i.errors.push({path:e,message:t instanceof Error?t.message:String(t)})}return i}async mkdir(e){}async remove(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t?.recursive)throw new c(`EINVAL`,`recursive remove not yet supported on S3`,e);let r=await this.transport({method:`DELETE`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status===404)throw new c(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new c(`EACCES`,`s3 delete denied`,e);if(r.status>=400)throw new c(`EIO`,`s3 delete failed: ${r.status}`,e);await this.cache.invalidateBody(n);let i=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(i)}describe(){return{displayName:this.parsed.prefix?`${this.parsed.bucket}/${this.parsed.prefix}`:this.parsed.bucket,source:this.source,profile:this.profile}}async close(){this.closed||=!0}},v=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function y(){let{getAccounts:t}=await e(async()=>{let{getAccounts:e}=await import(`./account-store-Bv6TisyU.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])),n=t().find(e=>e.providerId===`adobe`);if(!n?.accessToken)throw new v(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>n.accessToken}}var b=`slicc-mount-cache`,x=`listings`,S=`bodies`,C=class{mountId;ttlMs;dbName;dbPromise=null;constructor(e){this.mountId=e.mountId,this.ttlMs=e.ttlMs,this.dbName=e.dbName??b}isStale(e,t){return Date.now()-e>=(t??this.ttlMs)}async openDb(){return this.dbPromise||=new Promise((e,t)=>{let n=indexedDB.open(this.dbName,1);n.onupgradeneeded=()=>{let e=n.result;e.objectStoreNames.contains(x)||e.createObjectStore(x),e.objectStoreNames.contains(S)||e.createObjectStore(S)},n.onsuccess=()=>{let t=n.result;t.onversionchange=()=>{t.close(),this.dbPromise=null},t.onclose=()=>{this.dbPromise=null},e(t)},n.onerror=()=>t(n.error)}),this.dbPromise}key(e){return`${this.mountId}::${e}`}async getListing(e){let t=await this.openDb();return new Promise((n,r)=>{let i=t.transaction(x,`readonly`).objectStore(x).get(this.key(e));i.onsuccess=()=>n(i.result??null),i.onerror=()=>r(i.error)})}async putListing(e,t){let n=await this.openDb();return new Promise((r,i)=>{let a=n.transaction(x,`readwrite`),o={entries:t,cachedAt:Date.now()};a.objectStore(x).put(o,this.key(e)),a.oncomplete=()=>r(),a.onerror=()=>i(a.error)})}async invalidateListing(e){let t=await this.openDb();return new Promise((n,r)=>{let i=t.transaction(x,`readwrite`);i.objectStore(x).delete(this.key(e)),i.oncomplete=()=>n(),i.onerror=()=>r(i.error)})}async getBody(e){let t=await this.openDb();return new Promise((n,r)=>{let i=t.transaction(S,`readonly`).objectStore(S).get(this.key(e));i.onsuccess=()=>n(i.result??null),i.onerror=()=>r(i.error)})}async putBody(e,t,n){let r=await this.openDb(),i={body:t,etag:n,size:t.byteLength,cachedAt:Date.now()};try{await this.txPut(r,S,this.key(e),i)}catch(t){if(t instanceof DOMException&&t.name===`QuotaExceededError`){await this.evictLru(.25);try{await this.txPut(r,S,this.key(e),i)}catch{}return}throw t}}async invalidateBody(e){let t=await this.openDb();return new Promise((n,r)=>{let i=t.transaction(S,`readwrite`);i.objectStore(S).delete(this.key(e)),i.oncomplete=()=>n(),i.onerror=()=>r(i.error)})}async clearMount(){let e=await this.openDb(),t=`${this.mountId}::`,n=n=>new Promise((r,i)=>{let a=e.transaction(n,`readwrite`),o=a.objectStore(n),s=o.getAllKeys();s.onsuccess=()=>{for(let e of s.result)typeof e==`string`&&e.startsWith(t)&&o.delete(e)},a.oncomplete=()=>r(),a.onerror=()=>i(a.error)});await Promise.all([n(x),n(S)])}txPut(e,t,n,r){return new Promise((i,a)=>{let o=e.transaction(t,`readwrite`);o.objectStore(t).put(r,n),o.oncomplete=()=>i(),o.onerror=()=>a(o.error)})}async evictLru(e){let t=await this.openDb(),n=`${this.mountId}::`,r=await new Promise((e,r)=>{let i=t.transaction(S,`readonly`).objectStore(S),a=[],o=i.openCursor();o.onsuccess=()=>{let t=o.result;if(!t){e(a);return}if(typeof t.key==`string`&&t.key.startsWith(n)){let e=t.value;a.push({key:t.key,cachedAt:e.cachedAt})}t.continue()},o.onerror=()=>r(o.error)});r.sort((e,t)=>e.cachedAt-t.cachedAt);let i=Math.max(1,Math.ceil(r.length*e)),a=r.slice(0,i);await new Promise((e,n)=>{let r=t.transaction(S,`readwrite`),i=r.objectStore(S);for(let{key:e}of a)i.delete(e);r.oncomplete=()=>e(),r.onerror=()=>n(r.error)})}},w=r,T=n,E=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),D=new Set([101,103,204,205,304]);function O(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new c(`EACCES`,e.error):e.errorCode===`invalid_request`?new c(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||E.has(String(e.errorCode))?new c(`EIO`,e.error):new c(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=w(e.bodyBase64)}catch(e){throw new c(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let n=D.has(e.status)?null:t;return new Response(n,{status:e.status,headers:new Headers(e.headers)})}async function k(e,t){let n;try{n=await fetch(i(e),{method:`POST`,headers:o({"content-type":`application/json`}),body:JSON.stringify(t)})}catch(e){throw new c(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (SLICC backend at localhost may not be running)`)}try{return await n.json()}catch(e){throw new c(`EIO`,`mount transport: response is not a JSON envelope (status ${n.status}): ${e instanceof Error?e.message:String(e)}`)}}async function A(e,t){try{return await chrome.runtime.sendMessage({type:e,envelope:t})}catch(e){throw new c(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (extension service worker not responding)`)}}async function j(e,t,n){return s()?A(e,n):a()?l(e,n):k(t,n)}function M(e){return async t=>O(await j(`mount.s3-sign-and-forward`,`/api/s3-sign-and-forward`,{profile:e,method:t.method,bucket:t.bucket,key:t.key,query:t.query,headers:t.headers,bodyBase64:t.body?T(t.body):void 0}))}function N(e){let t=e?.getImsToken??(async()=>(await y()).getBearerToken());return async e=>{let n;try{n=await t()}catch(e){throw new c(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}return O(await j(`mount.da-sign-and-forward`,`/api/da-sign-and-forward`,{imsToken:n,method:e.method,path:e.path,query:e.query,headers:e.headers,bodyBase64:e.body?T(e.body):void 0}))}}export{m as DaMountBackend,C as RemoteMountCache,_ as S3MountBackend,N as makeSignedFetchDa,M as makeSignedFetchS3};
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/account-store-D-iMuoaP.js","assets/rolldown-runtime-aKtaBQYM.js","assets/preload-helper-Czpn1I53.js","assets/compat-DyT25qXb.js","assets/models-CzSI8IsT.js","assets/provider-env-D37PhSJu.js","assets/__vite-browser-external-SwrSgYTf.js","assets/context-compaction-dcYYajWb.js","assets/logger-DDBAeTLF.js","assets/src-CS5gSDhT.js","assets/proxied-fetch-D5h5REZy.js","assets/base64-DpPqYZJF.js","assets/runtime-env-DH4NDw4t.js","assets/fetch-body-D2PwksUW.js","assets/secret-topology-CptRwAX3.js","assets/secrets-bridge-client-D6nwnBvr.js","assets/port-bridge-client-CoFZLSYm.js","assets/tool-ui-DfXu6quJ.js","assets/providers-DE-eWlQD.js","assets/panel-rpc-DmJSNs0I.js","assets/bedrock-camp-BEi8MYUS.js","assets/transform-messages-fFaW-DLG.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{t as e}from"./preload-helper-Czpn1I53.js";import{t}from"./mime-types-ugOWOUZ9.js";import{n,t as r}from"./base64-DpPqYZJF.js";import"./src-CS5gSDhT.js";import{o as i,r as a,t as o}from"./proxied-fetch-D5h5REZy.js";import{n as s}from"./runtime-env-DH4NDw4t.js";import{t as c}from"./types-idfTVsM8.js";import"./backend-local-smcj-_Ox.js";import"./mount-table-store-CfQUN_2R.js";import{t as l}from"./mount-bridge-client-DHGevTQu.js";function u(e,t,n){let r=`----DaMount${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`,i=new TextEncoder,a=i.encode(`--${r}\r\nContent-Disposition: form-data; name="data"; filename="${e}"\r\nContent-Type: ${t}\r\n\r\n`),o=i.encode(`\r\n--${r}--\r\n`),s=new Uint8Array(a.byteLength+n.byteLength+o.byteLength);return s.set(a,0),s.set(n,a.byteLength),s.set(o,a.byteLength+n.byteLength),{contentType:`multipart/form-data; boundary=${r}`,body:s}}function d(e){return e.split(`/`).pop()||`data`}function f(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 p=5*1024*1024,m=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=f(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??p,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new c(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toSourcePath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/source/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}toListPath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/list/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r={};n&&(r[`if-none-match`]=n.etag);let i=await this.transport({method:`GET`,path:this.toSourcePath(t),headers:r});if(i.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(i.status===404)throw await this.cache.invalidateBody(t),new c(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new c(`EACCES`,`da access denied`,e);if(i.status>=400)throw new c(`EIO`,`da readFile failed: ${i.status}`,e);let a=i.headers.get(`content-length`),o=a?Number(a):void 0;if(o!==void 0&&o>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes`,e);let s=new Uint8Array(await i.arrayBuffer());if(s.byteLength>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=i.headers.get(`etag`)??``,u=l.startsWith(`W/`)?l.slice(2):l;return await this.cache.putBody(t,s,u),s}async writeFile(e,n){if(this.assertOpen(e),n.byteLength>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=this.toMountRelative(e),i=await this.cache.getBody(r),a=u(d(e),t(e),n),o={"content-type":a.contentType,"content-length":String(a.body.byteLength)};i?.etag?o[`if-match`]=i.etag.startsWith(`W/`)?i.etag.slice(2):i.etag:i||(o[`if-none-match`]=`*`);let s=()=>this.transport({method:`POST`,path:this.toSourcePath(r),headers:o,body:a.body}),l,f=1;try{l=await s()}catch{f=2,l=await s()}if(l.status===412){if(f===2){let t=await this.transport({method:`HEAD`,path:this.toSourcePath(r)});if(t.status>=400)throw new c(`EIO`,`da reconcile HEAD failed: ${t.status}`,e);let i=t.headers.get(`etag`)??``;await this.cache.putBody(r,n,i);let a=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a);return}await this.cache.invalidateBody(r);try{await this.readFile(e)}catch{}throw new c(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(l.status===401||l.status===403)throw new c(`EACCES`,`da write denied`,e);if(l.status>=400)throw new c(`EIO`,`da writeFile failed: ${l.status}`,e);let p=l.headers.get(`etag`)??``;await this.cache.putBody(r,n,p);let m=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(m)}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.transport({method:`GET`,path:this.toListPath(t)});if(r.status===404)throw new c(`ENOENT`,`no such directory`,e);if(r.status>=400)throw new c(`EIO`,`da list failed: ${r.status}`,e);let i=(await r.json()).map(e=>e.ext?{name:`${e.name}.${e.ext}`,kind:`file`,etag:e.etag,lastModified:e.lastModified}:{name:e.name,kind:`directory`,lastModified:e.lastModified});return await this.cache.putListing(t,i),i}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.size,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),i=r.pop()??``,a=r.join(`/`),o=await this.cache.getListing(a);if(o&&!this.cache.isStale(o.cachedAt)){let t=o.entries.find(e=>e.name===i);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??o.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??o.cachedAt};if(!t)throw new c(`ENOENT`,`no such file or directory`,e)}let s=await this.transport({method:`HEAD`,path:this.toSourcePath(t)});if(s.status===200){let e=Number(s.headers.get(`content-length`)??`0`),t=s.headers.get(`etag`)??``,n=s.headers.get(`last-modified`),r=n?Date.parse(n):0;if(o){let n=o.entries.map(n=>n.name===i&&n.kind===`file`?{...n,size:e,etag:t,lastModified:r}:n);await this.cache.putListing(a,n)}return{kind:`file`,size:e,mtime:r,etag:t}}if(s.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new c(`ENOENT`,`no such file or directory`,e)}throw new c(`EIO`,`da stat failed: ${s.status}`,e)}async mkdir(e){}async remove(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.transport({method:`DELETE`,path:this.toSourcePath(t)});if(n.status===404)throw new c(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new c(`EACCES`,`da delete denied`,e);if(n.status>=400)throw new c(`EIO`,`da delete failed: ${n.status}`,e);await this.cache.invalidateBody(t);let r=t.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(r)}async refresh(e){this.assertOpen(`/`);let t={added:[],removed:[],changed:[],unchanged:0,errors:[]},n=[``];for(;n.length>0;){let e=n.pop();try{await this.refreshDir(e,t,n)}catch(n){t.errors.push({path:e,message:n instanceof Error?n.message:String(n)})}}return e?.bodies&&await this.refreshBodies(t),t}async classifyFile(e,t,n){let r=await this.cache.getBody(e);r?t&&r.etag!==t?(await this.cache.invalidateBody(e),n.changed.push(e)):n.unchanged++:n.added.push(e)}async refreshDir(e,t,n){let r=await this.transport({method:`GET`,path:this.toListPath(e)});if(r.status>=400){t.errors.push({path:e,message:`list failed: ${r.status}`});return}let i=await r.json(),a=[];for(let r of i)if(r.ext){let n=e?`${e}/${r.name}.${r.ext}`:`${r.name}.${r.ext}`;a.push({name:`${r.name}.${r.ext}`,kind:`file`,etag:r.etag,lastModified:r.lastModified}),await this.classifyFile(n,r.etag,t)}else a.push({name:r.name,kind:`directory`}),n.push(e?`${e}/${r.name}`:r.name);await this.cache.putListing(e,a)}async refreshBodies(e){for(let t of e.changed)try{await this.readFile(t)}catch(n){e.errors.push({path:t,message:n instanceof Error?n.message:String(n)})}}describe(){return{displayName:`${this.parsed.org}/${this.parsed.repo}${this.parsed.path?`/${this.parsed.path}`:``}`,source:this.source,profile:this.profile}}async close(){this.closed||=!0}};function h(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 g=25*1024*1024,_=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=h(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??g,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new c(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toS3Key(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``);return[this.parsed.prefix,t].filter(e=>e.length>0).join(`/`)}toMountRelativeKey(e){return this.parsed.prefix?e.slice(this.parsed.prefix.length+1):e}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r={};n&&(r[`if-none-match`]=n.etag);let i=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:this.toS3Key(t),headers:r});if(i.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(i.status===404)throw await this.cache.invalidateBody(t),new c(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new c(`EACCES`,`s3 access denied`,e);if(i.status>=400)throw new c(`EIO`,`s3 readFile failed: ${i.status}`,e);let a=i.headers.get(`content-length`),o=a?Number(a):void 0;if(o!==void 0&&o>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes (${o} > ${this.maxBodyBytes})`,e);let s=new Uint8Array(await i.arrayBuffer());if(s.byteLength>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=i.headers.get(`etag`)??``;return await this.cache.putBody(t,s,l),s}async writeFile(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t.byteLength>this.maxBodyBytes)throw new c(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=await this.cache.getBody(n),i={"content-type":`application/octet-stream`,"content-length":String(t.byteLength)};r?i[`if-match`]=r.etag:i[`if-none-match`]=`*`;let a=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(n),headers:i,body:t}),o,s=1;try{o=await a()}catch{s=2,o=await a()}if(o.status===412){if(s===2){let r=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status>=400)throw new c(`EIO`,`s3 reconcile HEAD failed: ${r.status}`,e);let i=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,i);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new c(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(o.status===401||o.status===403)throw new c(`EACCES`,`s3 write denied`,e);if(o.status>=400)throw new c(`EIO`,`s3 writeFile failed: ${o.status}`,e);let l=o.headers.get(`etag`)??``;await this.cache.putBody(n,t,l);let u=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(u)}async listObjectsV2(){let e=[],t;do{let n={"list-type":`2`};this.parsed.prefix&&(n.prefix=`${this.parsed.prefix}/`),t&&(n[`continuation-token`]=t);let r=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:``,query:n});if(r.status>=400)throw new c(`EIO`,`s3 list failed: ${r.status}`,`/`);let i=await r.text(),a=this.parseListingXml(i);e.push(...a.contents),t=a.nextContinuationToken}while(t);return e}parseListingXml(e){let t=[];for(let n of e.matchAll(/<Contents>([\s\S]*?)<\/Contents>/g)){let e=n[1],r=e.match(/<Key>([^<]+)<\/Key>/)?.[1]??``,i=e.match(/<ETag>([^<]+)<\/ETag>/)?.[1]??``,a=e.match(/<Size>([^<]+)<\/Size>/)?.[1]??`0`,o=e.match(/<LastModified>([^<]+)<\/LastModified>/)?.[1]??``;t.push({key:r,etag:i,size:Number(a),lastModified:o?Date.parse(o):0})}return{contents:t,nextContinuationToken:e.match(/<IsTruncated>([^<]+)<\/IsTruncated>/)?.[1]===`true`?e.match(/<NextContinuationToken>([^<]+)<\/NextContinuationToken>/)?.[1]:void 0}}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.listObjectsV2(),i=this.groupByDir(r);for(let[e,t]of i)await this.cache.putListing(e,t);return i.get(t)??[]}groupByDir(e){let t=new Map,n=e=>(t.has(e)||t.set(e,[]),t.get(e));n(``);for(let t of e){let e=this.toMountRelativeKey(t.key).split(`/`),r=e.pop();n(e.join(`/`)).push({name:r,kind:`file`,size:t.size,etag:t.etag,lastModified:t.lastModified});let i=``;for(let t of e){let e=i;i=i?`${i}/${t}`:t;let r=n(e);r.find(e=>e.name===t&&e.kind===`directory`)||r.push({name:t,kind:`directory`}),n(i)}}return t}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.body.byteLength,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),i=r.pop()??``,a=r.join(`/`),o=await this.cache.getListing(a);if(o&&!this.cache.isStale(o.cachedAt)){let t=o.entries.find(e=>e.name===i);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??o.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??o.cachedAt};if(!t)throw new c(`ENOENT`,`no such file or directory`,e)}let s=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(t)});if(s.status===200){let e=Number(s.headers.get(`content-length`)??`0`),t=s.headers.get(`etag`)??``,n=s.headers.get(`last-modified`);return{kind:`file`,size:e,mtime:n?Date.parse(n):0,etag:t}}if(s.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new c(`ENOENT`,`no such file or directory`,e)}throw new c(`EIO`,`s3 stat failed: ${s.status}`,e)}async refresh(e){this.assertOpen(`/`);let t=await this.listObjectsV2(),n=new Set(t.map(e=>this.toMountRelativeKey(e.key))),r=new Map(t.map(e=>[this.toMountRelativeKey(e.key),e.etag])),i={added:[],removed:[],changed:[],unchanged:0,errors:[]};for(let e of n){let t=await this.cache.getBody(e),n=r.get(e);t?t.etag===n?i.unchanged++:(await this.cache.invalidateBody(e),i.changed.push(e)):i.added.push(e)}let a=this.groupByDir(t);for(let[e,t]of a)await this.cache.putListing(e,t);if(e?.bodies)for(let e of i.changed)try{await this.readFile(e)}catch(t){i.errors.push({path:e,message:t instanceof Error?t.message:String(t)})}return i}async mkdir(e){}async remove(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t?.recursive)throw new c(`EINVAL`,`recursive remove not yet supported on S3`,e);let r=await this.transport({method:`DELETE`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status===404)throw new c(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new c(`EACCES`,`s3 delete denied`,e);if(r.status>=400)throw new c(`EIO`,`s3 delete failed: ${r.status}`,e);await this.cache.invalidateBody(n);let i=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(i)}describe(){return{displayName:this.parsed.prefix?`${this.parsed.bucket}/${this.parsed.prefix}`:this.parsed.bucket,source:this.source,profile:this.profile}}async close(){this.closed||=!0}},v=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function y(){let{getAccounts:t}=await e(async()=>{let{getAccounts:e}=await import(`./account-store-D-iMuoaP.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])),n=t().find(e=>e.providerId===`adobe`);if(!n?.accessToken)throw new v(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>n.accessToken}}var b=`slicc-mount-cache`,x=`listings`,S=`bodies`,C=class{mountId;ttlMs;dbName;dbPromise=null;constructor(e){this.mountId=e.mountId,this.ttlMs=e.ttlMs,this.dbName=e.dbName??b}isStale(e,t){return Date.now()-e>=(t??this.ttlMs)}async openDb(){return this.dbPromise||=new Promise((e,t)=>{let n=indexedDB.open(this.dbName,1);n.onupgradeneeded=()=>{let e=n.result;e.objectStoreNames.contains(x)||e.createObjectStore(x),e.objectStoreNames.contains(S)||e.createObjectStore(S)},n.onsuccess=()=>{let t=n.result;t.onversionchange=()=>{t.close(),this.dbPromise=null},t.onclose=()=>{this.dbPromise=null},e(t)},n.onerror=()=>t(n.error)}),this.dbPromise}key(e){return`${this.mountId}::${e}`}async getListing(e){let t=await this.openDb();return new Promise((n,r)=>{let i=t.transaction(x,`readonly`).objectStore(x).get(this.key(e));i.onsuccess=()=>n(i.result??null),i.onerror=()=>r(i.error)})}async putListing(e,t){let n=await this.openDb();return new Promise((r,i)=>{let a=n.transaction(x,`readwrite`),o={entries:t,cachedAt:Date.now()};a.objectStore(x).put(o,this.key(e)),a.oncomplete=()=>r(),a.onerror=()=>i(a.error)})}async invalidateListing(e){let t=await this.openDb();return new Promise((n,r)=>{let i=t.transaction(x,`readwrite`);i.objectStore(x).delete(this.key(e)),i.oncomplete=()=>n(),i.onerror=()=>r(i.error)})}async getBody(e){let t=await this.openDb();return new Promise((n,r)=>{let i=t.transaction(S,`readonly`).objectStore(S).get(this.key(e));i.onsuccess=()=>n(i.result??null),i.onerror=()=>r(i.error)})}async putBody(e,t,n){let r=await this.openDb(),i={body:t,etag:n,size:t.byteLength,cachedAt:Date.now()};try{await this.txPut(r,S,this.key(e),i)}catch(t){if(t instanceof DOMException&&t.name===`QuotaExceededError`){await this.evictLru(.25);try{await this.txPut(r,S,this.key(e),i)}catch{}return}throw t}}async invalidateBody(e){let t=await this.openDb();return new Promise((n,r)=>{let i=t.transaction(S,`readwrite`);i.objectStore(S).delete(this.key(e)),i.oncomplete=()=>n(),i.onerror=()=>r(i.error)})}async clearMount(){let e=await this.openDb(),t=`${this.mountId}::`,n=n=>new Promise((r,i)=>{let a=e.transaction(n,`readwrite`),o=a.objectStore(n),s=o.getAllKeys();s.onsuccess=()=>{for(let e of s.result)typeof e==`string`&&e.startsWith(t)&&o.delete(e)},a.oncomplete=()=>r(),a.onerror=()=>i(a.error)});await Promise.all([n(x),n(S)])}txPut(e,t,n,r){return new Promise((i,a)=>{let o=e.transaction(t,`readwrite`);o.objectStore(t).put(r,n),o.oncomplete=()=>i(),o.onerror=()=>a(o.error)})}async evictLru(e){let t=await this.openDb(),n=`${this.mountId}::`,r=await new Promise((e,r)=>{let i=t.transaction(S,`readonly`).objectStore(S),a=[],o=i.openCursor();o.onsuccess=()=>{let t=o.result;if(!t){e(a);return}if(typeof t.key==`string`&&t.key.startsWith(n)){let e=t.value;a.push({key:t.key,cachedAt:e.cachedAt})}t.continue()},o.onerror=()=>r(o.error)});r.sort((e,t)=>e.cachedAt-t.cachedAt);let i=Math.max(1,Math.ceil(r.length*e)),a=r.slice(0,i);await new Promise((e,n)=>{let r=t.transaction(S,`readwrite`),i=r.objectStore(S);for(let{key:e}of a)i.delete(e);r.oncomplete=()=>e(),r.onerror=()=>n(r.error)})}},w=r,T=n,E=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),D=new Set([101,103,204,205,304]);function O(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new c(`EACCES`,e.error):e.errorCode===`invalid_request`?new c(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||E.has(String(e.errorCode))?new c(`EIO`,e.error):new c(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=w(e.bodyBase64)}catch(e){throw new c(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let n=D.has(e.status)?null:t;return new Response(n,{status:e.status,headers:new Headers(e.headers)})}async function k(e,t){let n;try{n=await fetch(i(e),{method:`POST`,headers:o({"content-type":`application/json`}),body:JSON.stringify(t)})}catch(e){throw new c(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (SLICC backend at localhost may not be running)`)}try{return await n.json()}catch(e){throw new c(`EIO`,`mount transport: response is not a JSON envelope (status ${n.status}): ${e instanceof Error?e.message:String(e)}`)}}async function A(e,t){try{return await chrome.runtime.sendMessage({type:e,envelope:t})}catch(e){throw new c(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (extension service worker not responding)`)}}async function j(e,t,n){return s()?A(e,n):a()?l(e,n):k(t,n)}function M(e){return async t=>O(await j(`mount.s3-sign-and-forward`,`/api/s3-sign-and-forward`,{profile:e,method:t.method,bucket:t.bucket,key:t.key,query:t.query,headers:t.headers,bodyBase64:t.body?T(t.body):void 0}))}function N(e){let t=e?.getImsToken??(async()=>(await y()).getBearerToken());return async e=>{let n;try{n=await t()}catch(e){throw new c(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}return O(await j(`mount.da-sign-and-forward`,`/api/da-sign-and-forward`,{imsToken:n,method:e.method,path:e.path,query:e.query,headers:e.headers,bodyBase64:e.body?T(e.body):void 0}))}}export{m as DaMountBackend,C as RemoteMountCache,_ as S3MountBackend,N as makeSignedFetchDa,M as makeSignedFetchS3};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{t}from"./port-bridge-client-
|
|
1
|
+
import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{t}from"./port-bridge-client-CoFZLSYm.js";import{t as n}from"./types-idfTVsM8.js";var r=e({callMountBridge:()=>a}),i=t({portName:`mount.sign-and-forward`,panelRpcOp:`mount-sign-and-forward`,timeoutMs:12e4,onUnavailable:`reject`,makeError:e=>new n(`EIO`,`mount transport failed: ${e}`),logNamespace:`mount-bridge`,toPortMessage:({type:e,envelope:t})=>({type:e,envelope:t}),toPanelRpcPayload:({type:e,envelope:t})=>({type:e,envelope:t})});function a(e,t){return i({type:e,envelope:t})}export{r as n,a as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{h as t,m as n,r,s as i,t as a}from"./proxied-fetch-ldIfAeIb.js";import"./src-Dk1QVJRd.js";import{t as o}from"./runtime-env-byAg9ij-.js";import"./backend-local-D4WZgy4J.js";import{t as s}from"./types-idfTVsM8.js";import{t as c}from"./mime-types-D7IV6i7k.js";import{t as l}from"./remote-cache-D59F5FOx.js";import{t as u}from"./port-bridge-client-BC810skI.js";function d(e,t,n){let r=`----DaMount${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`,i=new TextEncoder,a=i.encode(`--${r}\r\nContent-Disposition: form-data; name="data"; filename="${e}"\r\nContent-Type: ${t}\r\n\r\n`),o=i.encode(`\r\n--${r}--\r\n`),s=new Uint8Array(a.byteLength+n.byteLength+o.byteLength);return s.set(a,0),s.set(n,a.byteLength),s.set(o,a.byteLength+n.byteLength),{contentType:`multipart/form-data; boundary=${r}`,body:s}}function f(e){return e.split(`/`).pop()||`data`}function p(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 m=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=p(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??5242880,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new s(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toSourcePath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/source/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}toListPath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/list/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r={};n&&(r[`if-none-match`]=n.etag);let i=await this.transport({method:`GET`,path:this.toSourcePath(t),headers:r});if(i.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(i.status===404)throw await this.cache.invalidateBody(t),new s(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new s(`EACCES`,`da access denied`,e);if(i.status>=400)throw new s(`EIO`,`da readFile failed: ${i.status}`,e);let a=i.headers.get(`content-length`),o=a?Number(a):void 0;if(o!==void 0&&o>this.maxBodyBytes)throw new s(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=new Uint8Array(await i.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new s(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=i.headers.get(`etag`)??``,u=l.startsWith(`W/`)?l.slice(2):l;return await this.cache.putBody(t,c,u),c}async writeFile(e,t){if(this.assertOpen(e),t.byteLength>this.maxBodyBytes)throw new s(`EFBIG`,`body exceeds maxBodyBytes`,e);let n=this.toMountRelative(e),r=await this.cache.getBody(n),i=d(f(e),c(e),t),a={"content-type":i.contentType,"content-length":String(i.body.byteLength)};r?.etag?a[`if-match`]=r.etag.startsWith(`W/`)?r.etag.slice(2):r.etag:r||(a[`if-none-match`]=`*`);let o=()=>this.transport({method:`POST`,path:this.toSourcePath(n),headers:a,body:i.body}),l,u=1;try{l=await o()}catch{u=2,l=await o()}if(l.status===412){if(u===2){let r=await this.transport({method:`HEAD`,path:this.toSourcePath(n)});if(r.status>=400)throw new s(`EIO`,`da reconcile HEAD failed: ${r.status}`,e);let i=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,i);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new s(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(l.status===401||l.status===403)throw new s(`EACCES`,`da write denied`,e);if(l.status>=400)throw new s(`EIO`,`da writeFile failed: ${l.status}`,e);let p=l.headers.get(`etag`)??``;await this.cache.putBody(n,t,p);let m=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(m)}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 s(`ENOENT`,`no such directory`,e);if(r.status>=400)throw new s(`EIO`,`da list failed: ${r.status}`,e);let i=(await r.json()).map(e=>e.ext?{name:`${e.name}.${e.ext}`,kind:`file`,etag:e.etag,lastModified:e.lastModified}:{name:e.name,kind:`directory`,lastModified:e.lastModified});return await this.cache.putListing(t,i),i}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.size,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),i=r.pop()??``,a=r.join(`/`),o=await this.cache.getListing(a);if(o&&!this.cache.isStale(o.cachedAt)){let t=o.entries.find(e=>e.name===i);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??o.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??o.cachedAt};if(!t)throw new s(`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(o){let n=o.entries.map(n=>n.name===i&&n.kind===`file`?{...n,size:e,etag:t,lastModified:r}:n);await this.cache.putListing(a,n)}return{kind:`file`,size:e,mtime:r,etag:t}}if(c.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new s(`ENOENT`,`no such file or directory`,e)}throw new s(`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 s(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new s(`EACCES`,`da delete denied`,e);if(n.status>=400)throw new s(`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 h(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 g=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=h(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??26214400,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new s(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toS3Key(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``);return[this.parsed.prefix,t].filter(e=>e.length>0).join(`/`)}toMountRelativeKey(e){return this.parsed.prefix?e.slice(this.parsed.prefix.length+1):e}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r={};n&&(r[`if-none-match`]=n.etag);let i=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:this.toS3Key(t),headers:r});if(i.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(i.status===404)throw await this.cache.invalidateBody(t),new s(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new s(`EACCES`,`s3 access denied`,e);if(i.status>=400)throw new s(`EIO`,`s3 readFile failed: ${i.status}`,e);let a=i.headers.get(`content-length`),o=a?Number(a):void 0;if(o!==void 0&&o>this.maxBodyBytes)throw new s(`EFBIG`,`body exceeds maxBodyBytes (${o} > ${this.maxBodyBytes})`,e);let c=new Uint8Array(await i.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new s(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=i.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 s(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=await this.cache.getBody(n),i={"content-type":`application/octet-stream`,"content-length":String(t.byteLength)};r?i[`if-match`]=r.etag:i[`if-none-match`]=`*`;let a=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(n),headers:i,body:t}),o,c=1;try{o=await a()}catch{c=2,o=await a()}if(o.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 s(`EIO`,`s3 reconcile HEAD failed: ${r.status}`,e);let i=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,i);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new s(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(o.status===401||o.status===403)throw new s(`EACCES`,`s3 write denied`,e);if(o.status>=400)throw new s(`EIO`,`s3 writeFile failed: ${o.status}`,e);let l=o.headers.get(`etag`)??``;await this.cache.putBody(n,t,l);let u=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(u)}async listObjectsV2(){let e=[],t;do{let n={"list-type":`2`};this.parsed.prefix&&(n.prefix=`${this.parsed.prefix}/`),t&&(n[`continuation-token`]=t);let r=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:``,query:n});if(r.status>=400)throw new s(`EIO`,`s3 list failed: ${r.status}`,`/`);let i=await r.text(),a=this.parseListingXml(i);e.push(...a.contents),t=a.nextContinuationToken}while(t);return e}parseListingXml(e){let t=[];for(let n of e.matchAll(/<Contents>([\s\S]*?)<\/Contents>/g)){let e=n[1],r=e.match(/<Key>([^<]+)<\/Key>/)?.[1]??``,i=e.match(/<ETag>([^<]+)<\/ETag>/)?.[1]??``,a=e.match(/<Size>([^<]+)<\/Size>/)?.[1]??`0`,o=e.match(/<LastModified>([^<]+)<\/LastModified>/)?.[1]??``;t.push({key:r,etag:i,size:Number(a),lastModified:o?Date.parse(o):0})}return{contents:t,nextContinuationToken:e.match(/<IsTruncated>([^<]+)<\/IsTruncated>/)?.[1]===`true`?e.match(/<NextContinuationToken>([^<]+)<\/NextContinuationToken>/)?.[1]:void 0}}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.listObjectsV2(),i=this.groupByDir(r);for(let[e,t]of i)await this.cache.putListing(e,t);return i.get(t)??[]}groupByDir(e){let t=new Map,n=e=>(t.has(e)||t.set(e,[]),t.get(e));n(``);for(let t of e){let e=this.toMountRelativeKey(t.key).split(`/`),r=e.pop();n(e.join(`/`)).push({name:r,kind:`file`,size:t.size,etag:t.etag,lastModified:t.lastModified});let i=``;for(let t of e){let e=i;i=i?`${i}/${t}`:t;let r=n(e);r.find(e=>e.name===t&&e.kind===`directory`)||r.push({name:t,kind:`directory`}),n(i)}}return t}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.body.byteLength,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),i=r.pop()??``,a=r.join(`/`),o=await this.cache.getListing(a);if(o&&!this.cache.isStale(o.cachedAt)){let t=o.entries.find(e=>e.name===i);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??o.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??o.cachedAt};if(!t)throw new s(`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 s(`ENOENT`,`no such file or directory`,e)}throw new s(`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 s(`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 s(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new s(`EACCES`,`s3 delete denied`,e);if(r.status>=400)throw new s(`EIO`,`s3 delete failed: ${r.status}`,e);await this.cache.invalidateBody(n);let i=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(i)}describe(){return{displayName:this.parsed.prefix?`${this.parsed.bucket}/${this.parsed.prefix}`:this.parsed.bucket,source:this.source,profile:this.profile}}async close(){this.closed||=!0}},_=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function v(){let{getAccounts:e}=await import(`./account-store-RXT-Poh-.js`).then(e=>e.n),t=e().find(e=>e.providerId===`adobe`);if(!t?.accessToken)throw new _(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>t.accessToken}}const y=u({portName:`mount.sign-and-forward`,panelRpcOp:`mount-sign-and-forward`,timeoutMs:12e4,onUnavailable:`reject`,makeError:e=>new s(`EIO`,`mount transport failed: ${e}`),logNamespace:`mount-bridge`,toPortMessage:({type:e,envelope:t})=>({type:e,envelope:t}),toPanelRpcPayload:({type:e,envelope:t})=>({type:e,envelope:t})});function b(e,t){return y({type:e,envelope:t})}const x=n,S=t,C=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),w=new Set([101,103,204,205,304]);function T(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new s(`EACCES`,e.error):e.errorCode===`invalid_request`?new s(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||C.has(String(e.errorCode))?new s(`EIO`,e.error):new s(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=x(e.bodyBase64)}catch(e){throw new s(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let n=w.has(e.status)?null:t;return new Response(n,{status:e.status,headers:new Headers(e.headers)})}async function E(e,t){let n;try{n=await fetch(i(e),{method:`POST`,headers:a({"content-type":`application/json`}),body:JSON.stringify(t)})}catch(e){throw new s(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (SLICC backend at localhost may not be running)`)}try{return await n.json()}catch(e){throw new s(`EIO`,`mount transport: response is not a JSON envelope (status ${n.status}): ${e instanceof Error?e.message:String(e)}`)}}async function D(e,t){try{return await chrome.runtime.sendMessage({type:e,envelope:t})}catch(e){throw new s(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (extension service worker not responding)`)}}async function O(e,t,n){return o()?D(e,n):r()?b(e,n):E(t,n)}function k(e){return async t=>T(await O(`mount.s3-sign-and-forward`,`/api/s3-sign-and-forward`,{profile:e,method:t.method,bucket:t.bucket,key:t.key,query:t.query,headers:t.headers,bodyBase64:t.body?S(t.body):void 0}))}function A(e){let t=e?.getImsToken??(async()=>(await v()).getBearerToken());return async e=>{let n;try{n=await t()}catch(e){throw new s(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}return T(await O(`mount.da-sign-and-forward`,`/api/da-sign-and-forward`,{imsToken:n,method:e.method,path:e.path,query:e.query,headers:e.headers,bodyBase64:e.body?S(e.body):void 0}))}}var j=e({DaMountBackend:()=>m,RemoteMountCache:()=>l,S3MountBackend:()=>g,makeSignedFetchDa:()=>A,makeSignedFetchS3:()=>k});export{m as a,g as i,A as n,k as r,j as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{t}from"./backend-local-D4WZgy4J.js";import{a as n,i as r,n as i,r as a}from"./mount-
|
|
1
|
+
import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{t}from"./backend-local-D4WZgy4J.js";import{a as n,i as r,n as i,r as a}from"./mount-n8fLpdiw.js";import{n as o}from"./mount-table-store-CTrzlrNn.js";import{t as s}from"./remote-cache-D59F5FOx.js";var c=e({formatMountRecoveryPrompt:()=>f,mdInlineCode:()=>d,recoverMounts:()=>l,shellQuote:()=>u});async function l(e,c,l){let u=[],d=[];for(let f of e){let{targetPath:e,descriptor:p}=f;if(p.kind===`local`){let n=await o(p.idbHandleKey),r=typeof n?.name==`string`?n.name:``;if(!n||!(`queryPermission`in n)){d.push({kind:`local`,path:e,dirName:r});continue}let i;try{i=await n.queryPermission({mode:`readwrite`})}catch(t){l?.warn?.(`queryPermission threw on persisted handle`,{path:e,error:t instanceof Error?t.message:String(t)}),d.push({kind:`local`,path:e,dirName:r});continue}if(i!==`granted`){d.push({kind:`local`,path:e,dirName:r});continue}try{let i=t.fromHandle(n,{mountId:p.mountId});await c.mount(e,i),l?.info?.(`Restored mount from previous session`,{path:e,name:r}),u.push({kind:`local`,path:e,dirName:r})}catch(t){l?.warn?.(`Failed to re-mount persisted handle`,{path:e,error:t instanceof Error?t.message:String(t)}),d.push({kind:`local`,path:e,dirName:r})}continue}if(p.kind===`s3`){try{let t=new s({mountId:p.mountId,ttlMs:3e4}),n=new r({source:p.source,profile:p.profile,cache:t,mountId:p.mountId,signedFetch:a(p.profile)});await c.mount(e,n),l?.info?.(`Restored S3 mount from previous session`,{path:e,source:p.source}),u.push({kind:`s3`,path:e,source:p.source,profile:p.profile,reason:``})}catch(t){let n=t instanceof Error?t.message:String(t);l?.warn?.(`Failed to restore S3 mount`,{path:e,error:n}),d.push({kind:`s3`,path:e,source:p.source,profile:p.profile,reason:n})}continue}if(p.kind===`da`)try{let t=new s({mountId:p.mountId,ttlMs:3e4}),r=new n({source:p.source,profile:p.profile,cache:t,mountId:p.mountId,signedFetch:i()});await c.mount(e,r),l?.info?.(`Restored DA mount from previous session`,{path:e,source:p.source}),u.push({kind:`da`,path:e,source:p.source,profile:p.profile,reason:``})}catch(t){let n=t instanceof Error?t.message:String(t);l?.warn?.(`Failed to restore DA mount`,{path:e,error:n}),d.push({kind:`da`,path:e,source:p.source,profile:p.profile,reason:n})}}return{restored:u,needsRecovery:d}}function u(e){return`'${e.replace(/'/g,`'\\''`)}'`}function d(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 f(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`),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 ${d(t)})`:``;return`- ${d(e)}${n}`}),i=r.map(({path:e})=>` mount ${u(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 ${u(n)}`,a=`mount --source ${u(t)}${i} ${u(e)}`;return`- ${d(e)} (${d(t)}, profile ${d(n)}) — ${r}\n Retry: ${d(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{c as n,u as r,f as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/quick-llm-
|
|
2
|
-
import{t as e}from"./preload-helper-Czpn1I53.js";import{F as t,m as n}from"./account-store-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/quick-llm-D49Q05Ys.js","assets/rolldown-runtime-aKtaBQYM.js","assets/compat-DyT25qXb.js","assets/models-CzSI8IsT.js","assets/preload-helper-Czpn1I53.js","assets/provider-env-D37PhSJu.js","assets/__vite-browser-external-SwrSgYTf.js","assets/account-store-D-iMuoaP.js","assets/context-compaction-dcYYajWb.js","assets/logger-DDBAeTLF.js","assets/src-CS5gSDhT.js","assets/proxied-fetch-D5h5REZy.js","assets/base64-DpPqYZJF.js","assets/runtime-env-DH4NDw4t.js","assets/fetch-body-D2PwksUW.js","assets/secret-topology-CptRwAX3.js","assets/secrets-bridge-client-D6nwnBvr.js","assets/port-bridge-client-CoFZLSYm.js","assets/tool-ui-DfXu6quJ.js","assets/providers-DE-eWlQD.js","assets/panel-rpc-DmJSNs0I.js","assets/bedrock-camp-BEi8MYUS.js","assets/transform-messages-fFaW-DLG.js","assets/llm-session-id-bZQs6gBN.js","assets/icons-C5g936Qd.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{t as e}from"./preload-helper-Czpn1I53.js";import{F as t,m as n}from"./account-store-D-iMuoaP.js";import{t as r}from"./logger-DDBAeTLF.js";import"./provider-settings-CwdBRbVy.js";import{t as i}from"./llm-session-id-bZQs6gBN.js";import{n as a,r as o}from"./session-freezer-C59A1pKQ.js";import{SessionStore as s}from"./session-store-DAM8GRJ0.js";var c=r(`new-session`),l=`ui-new-session`,u=2e4,d=250;async function f(e,t,n,r){for(let i of n){let n=`${t}/${i.name}`;r.has(n)||i.type===`directory`&&(await f(e,n,await e.readDir(n),r),[...r].some(e=>e.startsWith(`${n}/`)))||await e.rm(n)}}async function p(e){let t=new Set((await e.listMountPoints()).map(({path:e})=>e).filter(e=>e===`/tmp`||e.startsWith(`/tmp/`)));if(t.has(`/tmp`))return;let n;try{n=await e.readDir(`/tmp`)}catch(t){if(t?.code!==`ENOENT`)throw t;await e.mkdir(`/tmp`,{recursive:!0});return}await f(e,`/tmp`,n,t),await e.mkdir(`/tmp`,{recursive:!0})}async function m(r){let d=r.enrichmentRaceMs??u,f=n()??void 0,p;try{p=t()}catch(e){c.info(`No active model — freezing without LLM enrichment`,{error:e instanceof Error?e.message:String(e)})}let m=p?.provider===`adobe`?{"X-Session-Id":i(l)}:void 0,g=new s;try{await g.init()}catch(e){return c.warn(`SessionStore init failed — cannot freeze`,{error:e instanceof Error?e.message:String(e)}),null}let _=await o({sessionStore:g,vfs:r.vfs,mode:`quick`});if(!_)return null;if(!f||!p)return c.info(`Frozen without enrichment (no LLM credentials) — left pending`,{filename:_.filename}),_;let v=p,y=a(r.vfs,_,{model:v,apiKey:f,headers:m,pickIcon:t=>e(async()=>{let{pickLucideIcon:e}=await import(`./quick-llm-D49Q05Ys.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])).then(({pickLucideIcon:e})=>e(t))}).catch(e=>(c.warn(`Single-click enrichment threw (entry stays pending)`,{filename:_.filename,error:e instanceof Error?e.message:String(e)}),null)),b=await h(y,d,r.onProgress);return b.kind===`llm`?b.updated?{...b.updated,archive:_.archive}:_:(y.then(e=>{c.info(`Background enrichment resolved after race window`,{filename:_.filename,enriched:e?.filename??null}),r.onBackgroundEnriched?.(e)}),_)}async function h(e,t,n){let r=Date.now(),i,a;n?.(0),n&&(i=setInterval(()=>{n(Math.min(1,(Date.now()-r)/t))},d));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 g(e){let t=new s;try{await t.init()}catch(e){return c.warn(`SessionStore init failed — cannot quick-freeze`,{error:e instanceof Error?e.message:String(e)}),null}return o({sessionStore:t,vfs:e.vfs,mode:`quick`})}export{p as resetNewSessionTmp,m as runNewSessionFreeze,g as runNewSessionFreezeQuick};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/provider-
|
|
2
|
-
import{t as e}from"./preload-helper-Czpn1I53.js";import{R as t,d as n}from"./account-store-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/provider-DE9Hwk8G.js","assets/preload-helper-Czpn1I53.js","assets/account-store-D-iMuoaP.js","assets/rolldown-runtime-aKtaBQYM.js","assets/compat-DyT25qXb.js","assets/models-CzSI8IsT.js","assets/provider-env-D37PhSJu.js","assets/__vite-browser-external-SwrSgYTf.js","assets/context-compaction-dcYYajWb.js","assets/logger-DDBAeTLF.js","assets/src-CS5gSDhT.js","assets/proxied-fetch-D5h5REZy.js","assets/base64-DpPqYZJF.js","assets/runtime-env-DH4NDw4t.js","assets/fetch-body-D2PwksUW.js","assets/secret-topology-CptRwAX3.js","assets/secrets-bridge-client-D6nwnBvr.js","assets/port-bridge-client-CoFZLSYm.js","assets/tool-ui-DfXu6quJ.js","assets/providers-DE-eWlQD.js","assets/panel-rpc-DmJSNs0I.js","assets/bedrock-camp-BEi8MYUS.js","assets/transform-messages-fFaW-DLG.js","assets/provider-store-access-hzgvuQuF.js","assets/global-db-CbuLl-zx.js","assets/types-idfTVsM8.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{t as e}from"./preload-helper-Czpn1I53.js";import{R as t,d as n}from"./account-store-D-iMuoaP.js";import{t as r}from"./logger-DDBAeTLF.js";import{t as i}from"./providers-DE-eWlQD.js";import"./provider-settings-CwdBRbVy.js";var a=r(`oauth-bootstrap`),o=6e4;async function s(){try{let{ensureAllMcpProvidersRegistered:t}=await e(async()=>{let{ensureAllMcpProvidersRegistered:e}=await import(`./provider-DE9Hwk8G.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])),n=await t();n.length>0&&a.debug(`Pre-registered MCP providers for OAuth bootstrap`,{count:n.length})}catch(e){a.warn(`Failed to pre-register MCP providers for OAuth bootstrap`,{error:e instanceof Error?e.message:String(e)})}let r=n();a.info(`Bootstrap OAuth replicas`,{count:r.length});for(let e of r){if(!e.accessToken){a.debug(`Skipping account without token`,{providerId:e.providerId});continue}if((e.tokenExpiresAt??1/0)-Date.now()<=o){let t=i(e.providerId);if(t?.onSilentRenew)try{if(await t.onSilentRenew()){a.info(`Silently renewed OAuth token`,{providerId:e.providerId});continue}a.warn(`Silent renewal yielded no token; user must re-authenticate`,{providerId:e.providerId});continue}catch(t){a.warn(`Silent renewal failed`,{providerId:e.providerId,error:t instanceof Error?t.message:String(t)});continue}a.debug(`Skipping expired account (no silent-renew hook)`,{providerId:e.providerId});continue}try{await t({providerId:e.providerId,accessToken:e.accessToken,refreshToken:e.refreshToken,tokenExpiresAt:e.tokenExpiresAt,userName:e.userName,userAvatar:e.userAvatar}),a.debug(`Bootstrapped OAuth replica`,{providerId:e.providerId})}catch(t){a.error(`OAuth bootstrap failed`,{providerId:e.providerId,error:t instanceof Error?t.message:String(t)})}}}export{s as bootstrapOAuthReplicas};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./preload-helper-Czpn1I53.js";import{o as t,t as n}from"./proxied-fetch-
|
|
1
|
+
import{t as e}from"./preload-helper-Czpn1I53.js";import{o as t,t as n}from"./proxied-fetch-D5h5REZy.js";import{n as r}from"./runtime-env-DH4NDw4t.js";import{t as i}from"./panel-rpc-DmJSNs0I.js";import{t as a}from"./wc-permissions-registry-Blyunq37.js";var o=12e4;function s(e,t){return t.endsWith(`*`)?e.startsWith(t.slice(0,-1)):e===t||e.startsWith(`${t}?`)||e.startsWith(`${t}#`)}function c(e){return e.endsWith(`*`)?e:`${e}*`}function l(e,t){if(!t||t.length===0)return e;let n=e;for(let e of t)if(n.includes(e.match)){if(e.replaceUrl){n=e.replaceUrl;continue}if(e.appendParams)try{let t=new URL(n);for(let[n,r]of Object.entries(e.appendParams))t.searchParams.set(n,r);n=t.toString()}catch{}}return n}function u(e){return async t=>{let n=t.timeoutMs??o,r=t.rewrite??[],i=t.onCapture??`close`,a,u,d=!1,f=null,p=async()=>{if(u){try{await e.send(`Fetch.disable`,{},u)}catch{}try{await e.send(`Target.detachFromTarget`,{sessionId:u})}catch{}}if(a&&i===`close`)try{await e.send(`Target.closeTarget`,{targetId:a})}catch{}};return await new Promise(i=>{let o=async t=>{d||(d=!0,clearTimeout(h),e.off(`Fetch.requestPaused`,m),await p(),i(t))},m=n=>{let i=n;if(!i?.request?.url||!u||(typeof n.sessionId==`string`?n.sessionId:void 0)!==u)return;if(s(i.request.url,t.redirectUriPattern)){f=i.request.url,e.send(`Fetch.failRequest`,{requestId:i.requestId,errorReason:`Aborted`},u).catch(()=>{}),o(f);return}let a=l(i.request.url,r);if(a!==i.request.url){e.send(`Fetch.continueRequest`,{requestId:i.requestId,url:a},u).catch(e=>{console.warn(`[intercepted-oauth] continueRequest (rewrite) failed:`,e instanceof Error?e.message:String(e))});return}e.send(`Fetch.continueRequest`,{requestId:i.requestId},u).catch(()=>{})},h=setTimeout(()=>{o(null)},n);(async()=>{try{a=(await e.send(`Target.createTarget`,{url:`about:blank`})).targetId,u=(await e.send(`Target.attachToTarget`,{targetId:a,flatten:!0})).sessionId,e.on(`Fetch.requestPaused`,m),await e.send(`Fetch.enable`,{patterns:[{urlPattern:c(t.redirectUriPattern),requestStage:`Request`},...r.map(e=>({urlPattern:`*${e.match}*`,requestStage:`Request`}))]},u),await e.send(`Page.navigate`,{url:t.authorizeUrl},u)}catch(e){console.error(`[intercepted-oauth] setup failed:`,e instanceof Error?e.message:String(e)),o(null)}})()})}}var d=r();function f(){return d?S:typeof window>`u`?g:_}async function p(){let e=await m();return e?u(e):null}async function m(){try{let{getActiveCdpTransport:t}=await e(async()=>{let{getActiveCdpTransport:e}=await import(`./active-transport-BIjzxdwv.js`);return{getActiveCdpTransport:e}},[]);return await t()}catch(e){return console.warn(`[oauth-service] could not resolve active CDP transport:`,e instanceof Error?e.message:String(e)),null}}async function h(){if(typeof window<`u`)return{origin:window.location.origin,href:window.location.href};let e=i();if(!e)throw Error(`OAuth from worker context requires the panel-RPC bridge (no page-info available)`);let t=await e.call(`page-info`,void 0);return{origin:t.origin,href:t.href}}async function g(e){let t=i();if(!t)return console.error(`[oauth-service] panel-RPC client unavailable in worker`),null;try{return(await t.call(`oauth-popup`,{url:e},{timeoutMs:13e4})).redirectUrl}catch(e){return console.error(`[oauth-service] oauth-popup RPC failed:`,e instanceof Error?e.message:String(e)),null}}async function _(e){if(v())return y(window.open(e,`_blank`,`width=500,height=700,popup=yes`));let t=a();if(t){let n=await b(t,e);return n===void 0?null:y(n)}return y(window.open(e,`_blank`,`width=500,height=700,popup=yes`))}function v(){return(typeof navigator<`u`?navigator.userActivation:void 0)?.isActive===!0}function y(e){return new Promise(r=>{let i=!1,a=null,o=null,s=()=>{i||(i=!0,window.removeEventListener(`message`,c),clearTimeout(l),a&&clearInterval(a),o&&clearInterval(o))},c=t=>{if(t.data?.type!==`oauth-callback`||t.origin!==window.location.origin||e&&t.source!==e)return;if(s(),t.data.error){console.error(`[oauth-service] CLI OAuth error:`,t.data.error),r(null);return}let n=t.data.redirectUrl;typeof n!=`string`&&n!=null||r(n??null)};window.addEventListener(`message`,c),a=setInterval(async()=>{if(!i)try{let e=await fetch(t(`/api/oauth-result`),{headers:n()});if(e.status===204||!e.ok)return;let a=await e.json();if(i)return;if(s(),a.error){console.error(`[oauth-service] Server relay OAuth error:`,a.error),r(null);return}r(a.redirectUrl??null)}catch(e){console.warn(`[oauth-service] Poll failed:`,e instanceof Error?e.message:String(e))}},1e3),e&&(o=setInterval(()=>{e.closed&&(clearInterval(o),o=null,setTimeout(()=>{i||(s(),r(null))},1500))},500));let l=setTimeout(()=>{s();try{e?.close()}catch{}r(null)},12e4)})}async function b(e,t){let n=await e.prompt({kinds:[`popup`],description:`Continue to sign in. A new window will open to the provider.`,grantLabel:`Continue`,requestOptions:{popup:{url:t}}});if(n.status!==`granted`)return;let r=n.grants.find(e=>e.kind===`popup`);return r&&r.kind===`popup`?r.window:null}async function x(e,t=180*1e3){if(typeof window>`u`||d)return;let n=window.open(e,`_blank`,`width=500,height=600,popup=yes`);if(!n){console.warn(`[oauth-service] Could not open IdP logout popup — popups may be blocked`);return}await new Promise(e=>{let r=setTimeout(()=>{clearInterval(i);try{n.close()}catch{}e()},t),i=setInterval(()=>{n.closed&&(clearTimeout(r),clearInterval(i),e())},500)})}async function S(e,t){return new Promise(n=>{let r=!1,i=()=>{r||(r=!0,chrome.runtime.onMessage.removeListener(a),clearTimeout(o))},a=e=>{if(e?.source===`service-worker`&&e?.payload?.type===`oauth-result`){if(i(),e.payload.error){console.error(`[oauth-service] Extension OAuth error:`,e.payload.error),n(null);return}n(e.payload.redirectUrl??null)}};chrome.runtime.onMessage.addListener(a),chrome.runtime.sendMessage({source:`panel`,payload:{type:`oauth-request`,providerId:`oauth`,authorizeUrl:e,interactive:t?.interactive??!0}}).catch(e=>{console.error(`[oauth-service] Failed to send OAuth request to service worker:`,e)});let o=setTimeout(()=>{i(),n(null)},12e4)})}export{p as createInterceptingOAuthLauncherForCurrentRuntime,f as createOAuthLauncher,h as getOAuthPageOrigin,x as openIdpLogoutUrl};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./panel-rpc-CjFVE0nK.js";import{
|
|
1
|
+
import{n as e}from"./panel-rpc-CjFVE0nK.js";import{s as t,t as n}from"./proxied-fetch-ldIfAeIb.js";import{t as r}from"./runtime-env-byAg9ij-.js";import{t as i}from"./wc-permissions-registry-C7PhTX3c.js";import{t as a}from"./intercepted-oauth-CaCw-rJ5.js";const o=r();function s(){return o?_:typeof window>`u`?d:f}async function c(){let e=await l();return e?a(e):null}async function l(){try{let{getActiveCdpTransport:e}=await import(`./active-transport-BIjzxdwv.js`);return await e()}catch(e){return console.warn(`[oauth-service] could not resolve active CDP transport:`,e instanceof Error?e.message:String(e)),null}}async function u(){if(typeof window<`u`)return{origin:window.location.origin,href:window.location.href};let t=e();if(!t)throw Error(`OAuth from worker context requires the panel-RPC bridge (no page-info available)`);let n=await t.call(`page-info`,void 0);return{origin:n.origin,href:n.href}}async function d(t){let n=e();if(!n)return console.error(`[oauth-service] panel-RPC client unavailable in worker`),null;try{return(await n.call(`oauth-popup`,{url:t},{timeoutMs:13e4})).redirectUrl}catch(e){return console.error(`[oauth-service] oauth-popup RPC failed:`,e instanceof Error?e.message:String(e)),null}}async function f(e){if(p())return m(window.open(e,`_blank`,`width=500,height=700,popup=yes`));let t=i();if(t){let n=await h(t,e);return n===void 0?null:m(n)}return m(window.open(e,`_blank`,`width=500,height=700,popup=yes`))}function p(){return(typeof navigator<`u`?navigator.userActivation:void 0)?.isActive===!0}function m(e){return new Promise(r=>{let i=!1,a=null,o=null,s=()=>{i||(i=!0,window.removeEventListener(`message`,c),clearTimeout(l),a&&clearInterval(a),o&&clearInterval(o))},c=t=>{if(t.data?.type!==`oauth-callback`||t.origin!==window.location.origin||e&&t.source!==e)return;if(s(),t.data.error){console.error(`[oauth-service] CLI OAuth error:`,t.data.error),r(null);return}let n=t.data.redirectUrl;typeof n!=`string`&&n!=null||r(n??null)};window.addEventListener(`message`,c),a=setInterval(async()=>{if(!i)try{let e=await fetch(t(`/api/oauth-result`),{headers:n()});if(e.status===204||!e.ok)return;let a=await e.json();if(i)return;if(s(),a.error){console.error(`[oauth-service] Server relay OAuth error:`,a.error),r(null);return}r(a.redirectUrl??null)}catch(e){console.warn(`[oauth-service] Poll failed:`,e instanceof Error?e.message:String(e))}},1e3),e&&(o=setInterval(()=>{e.closed&&(clearInterval(o),o=null,setTimeout(()=>{i||(s(),r(null))},1500))},500));let l=setTimeout(()=>{s();try{e?.close()}catch{}r(null)},12e4)})}async function h(e,t){let n=await e.prompt({kinds:[`popup`],description:`Continue to sign in. A new window will open to the provider.`,grantLabel:`Continue`,requestOptions:{popup:{url:t}}});if(n.status!==`granted`)return;let r=n.grants.find(e=>e.kind===`popup`);return r&&r.kind===`popup`?r.window:null}async function g(e,t=180*1e3){if(typeof window>`u`||o)return;let n=window.open(e,`_blank`,`width=500,height=600,popup=yes`);if(!n){console.warn(`[oauth-service] Could not open IdP logout popup — popups may be blocked`);return}await new Promise(e=>{let r=setTimeout(()=>{clearInterval(i);try{n.close()}catch{}e()},t),i=setInterval(()=>{n.closed&&(clearTimeout(r),clearInterval(i),e())},500)})}async function _(e,t){return new Promise(n=>{let r=!1,i=()=>{r||(r=!0,chrome.runtime.onMessage.removeListener(a),clearTimeout(o))},a=e=>{if(e?.source===`service-worker`&&e?.payload?.type===`oauth-result`){if(i(),e.payload.error){console.error(`[oauth-service] Extension OAuth error:`,e.payload.error),n(null);return}n(e.payload.redirectUrl??null)}};chrome.runtime.onMessage.addListener(a),chrome.runtime.sendMessage({source:`panel`,payload:{type:`oauth-request`,providerId:`oauth`,authorizeUrl:e,interactive:t?.interactive??!0}}).catch(e=>{console.error(`[oauth-service] Failed to send OAuth request to service worker:`,e)});let o=setTimeout(()=>{i(),n(null)},12e4)})}export{c as createInterceptingOAuthLauncherForCurrentRuntime,s as createOAuthLauncher,u as getOAuthPageOrigin,g as openIdpLogoutUrl};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{O as e,i as t}from"./account-store-
|
|
1
|
+
import{O as e,i as t}from"./account-store-RXT-Poh-.js";import{p as n}from"./transform-messages-CVIV-EgO.js";import{p as r}from"./bedrock-camp-CvxD6hHk.js";import{n as i,o as a}from"./legacy-api-aliases-DWJHPSiz.js";import"./provider-settings-CCbIum7u.js";const o=`openai-codex`,s=`app_EMoamEEZ73f0CkXaXp7hrann`,c=`https://auth.openai.com/oauth/token`,l=`http://localhost:1455/auth/callback`,u=`https://chatgpt.com/backend-api`,d=`openai-codex-responses`,f=`${o}-openai`,p={xhigh:`xhigh`,minimal:`low`},m=[{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:p}));function h(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function g(e){let t=new Uint8Array(e);return crypto.getRandomValues(t),t}function _(){return h(g(32))}async function v(e){let t=new TextEncoder().encode(e);return h(new Uint8Array(await crypto.subtle.digest(`SHA-256`,t)))}function y(){return h(g(16))}async function b(e,t){let n=new URLSearchParams({grant_type:`authorization_code`,client_id:s,code:e,code_verifier:t,redirect_uri:l}),r=await fetch(c,{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 x(e){try{let t=new URLSearchParams({grant_type:`refresh_token`,refresh_token:e,client_id:s}),n=await fetch(c,{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 S(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 C(e){let t=S(e)?.[`https://api.openai.com/profile`];return typeof t?.email==`string`?t.email:void 0}function w(e){let t=S(e)?.[`https://api.openai.com/auth`],n=C(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 T(e){let t=C(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 E(){return t().find(e=>e.providerId===o)}async function D(){let t=E();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 x(t.refreshToken);if(n?.access_token)return await e({providerId:o,accessToken:n.access_token,refreshToken:n.refresh_token??t.refreshToken,tokenExpiresAt:Date.now()+(n.expires_in??3600)*1e3,baseUrl:u,userName:w(n.access_token),userAvatar:await T(n.access_token)}),n.access_token}return t.accessToken}function O(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:f,provider:o,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()}}}const k=(e,t,r={})=>{let a=n();return(async()=>{try{let n=await D(),o=i({...e,baseUrl:u,api:d},t,{...r,apiKey:n,transport:`sse`});for await(let e of o)a.push(e);a.end()}catch(t){console.error(`[openai-codex] Stream error:`,t instanceof Error?t.message:String(t)),a.push(O(e,t)),a.end()}})(),a},A=(e,t,r)=>{let i=n();return(async()=>{try{let n=await D(),o=a({...e,baseUrl:u,api:d},t,{...r,apiKey:n,transport:`sse`});for await(let e of o)i.push(e);i.end()}catch(t){console.error(`[openai-codex] Stream error:`,t instanceof Error?t.message:String(t)),i.push(O(e,t)),i.end()}})(),i},j={id:o,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:()=>m,onOAuthLoginIntercepted:async(t,n,r)=>{let i=_(),a=await v(i),c=y(),d=new URL(`https://auth.openai.com/oauth/authorize`);d.searchParams.set(`response_type`,`code`),d.searchParams.set(`client_id`,s),d.searchParams.set(`redirect_uri`,l),d.searchParams.set(`scope`,r?.scopes??`openid profile email offline_access`),d.searchParams.set(`code_challenge`,a),d.searchParams.set(`code_challenge_method`,`S256`),d.searchParams.set(`state`,c),d.searchParams.set(`id_token_add_organizations`,`true`),d.searchParams.set(`codex_cli_simplified_flow`,`true`),d.searchParams.set(`originator`,`pi`);let f=await t({authorizeUrl:d.toString(),redirectUriPattern:`http://localhost:1455/auth/callback*`,onCapture:`close`});if(!f)throw Error(`OpenAI Codex OAuth login was cancelled or timed out`);let p=new URL(f),m=p.searchParams.get(`code`),h=p.searchParams.get(`state`);if(!m)throw Error(`OpenAI Codex OAuth redirect did not include a code`);if(h!==c)throw Error(`OpenAI Codex OAuth state mismatch — possible CSRF, aborting`);let g=await b(m,i);await e({providerId:o,accessToken:g.access_token,refreshToken:g.refresh_token,tokenExpiresAt:Date.now()+(g.expires_in??3600)*1e3,baseUrl:u,userName:w(g.access_token),userAvatar:await T(g.access_token)}),n()},onOAuthLogout:async()=>{await e({providerId:o,accessToken:``})},onSilentRenew:async()=>{let t=E();if(!t?.refreshToken)return null;let n=await x(t.refreshToken);return n?.access_token?(await e({providerId:o,accessToken:n.access_token,refreshToken:n.refresh_token??t.refreshToken,tokenExpiresAt:Date.now()+(n.expires_in??3600)*1e3,baseUrl:u,userName:w(n.access_token),userAvatar:await T(n.access_token)}),n.access_token):null}};function M(){r({api:f,stream:k,streamSimple:A})}export{j as config,M as register};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e}from"./models-CzSI8IsT.js";import{a as t}from"./compat-DyT25qXb.js";import{n,o as r}from"./legacy-api-aliases-BQSsmFIS.js";import{R as i,d as a}from"./account-store-
|
|
1
|
+
import{s as e}from"./models-CzSI8IsT.js";import{a as t}from"./compat-DyT25qXb.js";import{n,o as r}from"./legacy-api-aliases-BQSsmFIS.js";import{R as i,d as a}from"./account-store-D-iMuoaP.js";import"./provider-settings-CwdBRbVy.js";var o=`openai-codex`,s=`app_EMoamEEZ73f0CkXaXp7hrann`,c=`https://auth.openai.com/oauth/authorize`,l=`https://auth.openai.com/oauth/token`,u=`openid profile email offline_access`,d=`http://localhost:1455/auth/callback`,f=`http://localhost:1455/auth/callback*`,p=`https://chatgpt.com/backend-api`,m=`openai-codex-responses`,h=`${o}-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}));function v(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function y(e){let t=new Uint8Array(e);return crypto.getRandomValues(t),t}function b(){return v(y(32))}async function x(e){let t=new TextEncoder().encode(e);return v(new Uint8Array(await crypto.subtle.digest(`SHA-256`,t)))}function S(){return v(y(16))}async function C(e,t){let n=new URLSearchParams({grant_type:`authorization_code`,client_id:s,code:e,code_verifier:t,redirect_uri:d}),r=await fetch(l,{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 w(e){try{let t=new URLSearchParams({grant_type:`refresh_token`,refresh_token:e,client_id:s}),n=await fetch(l,{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 T(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 E(e){let t=T(e)?.[`https://api.openai.com/profile`];return typeof t?.email==`string`?t.email:void 0}function D(e){let t=T(e)?.[`https://api.openai.com/auth`],n=E(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 O(e){let t=E(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 k(){return a().find(e=>e.providerId===o)}async function A(){let e=k();if(!e?.accessToken)throw Error("Not signed in to OpenAI Codex — run `oauth-token openai-codex` or /login");let t=e.tokenExpiresAt??0;if(t&&Date.now()+6e4<t)return e.accessToken;if(e.refreshToken){let t=await w(e.refreshToken);if(t?.access_token)return await i({providerId:o,accessToken:t.access_token,refreshToken:t.refresh_token??e.refreshToken,tokenExpiresAt:Date.now()+(t.expires_in??3600)*1e3,baseUrl:p,userName:D(t.access_token),userAvatar:await O(t.access_token)}),t.access_token}return e.accessToken}function j(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:h,provider:o,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()}}}var M=(t,r,i={})=>{let a=e();return(async()=>{try{let e=await A(),o=n({...t,baseUrl:p,api:m},r,{...i,apiKey:e,transport:`sse`});for await(let e of o)a.push(e);a.end()}catch(e){console.error(`[openai-codex] Stream error:`,e instanceof Error?e.message:String(e)),a.push(j(t,e)),a.end()}})(),a},N=(t,n,i)=>{let a=e();return(async()=>{try{let e=await A(),o=r({...t,baseUrl:p,api:m},n,{...i,apiKey:e,transport:`sse`});for await(let e of o)a.push(e);a.end()}catch(e){console.error(`[openai-codex] Stream error:`,e instanceof Error?e.message:String(e)),a.push(j(t,e)),a.end()}})(),a},P={id:o,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(e,t,n)=>{let r=b(),a=await x(r),l=S(),m=new URL(c);m.searchParams.set(`response_type`,`code`),m.searchParams.set(`client_id`,s),m.searchParams.set(`redirect_uri`,d),m.searchParams.set(`scope`,n?.scopes??u),m.searchParams.set(`code_challenge`,a),m.searchParams.set(`code_challenge_method`,`S256`),m.searchParams.set(`state`,l),m.searchParams.set(`id_token_add_organizations`,`true`),m.searchParams.set(`codex_cli_simplified_flow`,`true`),m.searchParams.set(`originator`,`pi`);let h=await e({authorizeUrl:m.toString(),redirectUriPattern:f,onCapture:`close`});if(!h)throw Error(`OpenAI Codex OAuth login was cancelled or timed out`);let g=new URL(h),_=g.searchParams.get(`code`),v=g.searchParams.get(`state`);if(!_)throw Error(`OpenAI Codex OAuth redirect did not include a code`);if(v!==l)throw Error(`OpenAI Codex OAuth state mismatch — possible CSRF, aborting`);let y=await C(_,r);await i({providerId:o,accessToken:y.access_token,refreshToken:y.refresh_token,tokenExpiresAt:Date.now()+(y.expires_in??3600)*1e3,baseUrl:p,userName:D(y.access_token),userAvatar:await O(y.access_token)}),t()},onOAuthLogout:async()=>{await i({providerId:o,accessToken:``})},onSilentRenew:async()=>{let e=k();if(!e?.refreshToken)return null;let t=await w(e.refreshToken);return t?.access_token?(await i({providerId:o,accessToken:t.access_token,refreshToken:t.refresh_token??e.refreshToken,tokenExpiresAt:Date.now()+(t.expires_in??3600)*1e3,baseUrl:p,userName:D(t.access_token),userAvatar:await O(t.access_token)}),t.access_token):null}};function F(){t({api:h,stream:M,streamSimple:N})}export{P as config,F as register};
|