sliccy 3.48.0 → 3.48.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/ui/assets/{adobe-Dw1KLzF0.js → adobe-BgM1MjV7.js} +1 -1
  2. package/dist/ui/assets/{adobe-XIfmEcYK.js → adobe-BqH9mQFN.js} +2 -2
  3. package/dist/ui/assets/{agent-bridge-BEF1hIty.js → agent-bridge-Cy37Noc1.js} +1 -1
  4. package/dist/ui/assets/agent-message-to-chat-B79se35Y.js +7 -0
  5. package/dist/ui/assets/{apps-eGg9tGKY.js → apps-Cm-UqI97.js} +1 -1
  6. package/dist/ui/assets/{azure-openai-B6-fovpR.js → azure-openai-2H4TUaol.js} +1 -1
  7. package/dist/ui/assets/{azure-openai-5rXpEjUJ.js → azure-openai-731nPtK-.js} +1 -1
  8. package/dist/ui/assets/{bsh-watchdog-CROJP2Yc.js → bsh-watchdog-CIQk-ti7.js} +1 -1
  9. package/dist/ui/assets/{cdp-BYIfy3ZR.js → cdp-4VEOywrU.js} +3 -3
  10. package/dist/ui/assets/{connect-surface-B8afIHD4.js → connect-surface-VbgNCfAS.js} +1 -1
  11. package/dist/ui/assets/cost-command-BhpM_0Eu.js +1 -0
  12. package/dist/ui/assets/{dist-BN6l3u_g.js → dist-BBWWQ_fo.js} +1 -1
  13. package/dist/ui/assets/{dist-D1-v9_zA.js → dist-By9pLLsg.js} +1 -1
  14. package/dist/ui/assets/{es-CR5zR-J5.js → es-Bc0zoAOL.js} +1 -1
  15. package/dist/ui/assets/{follower-sprinkle-bridge-WYPpVMY-.js → follower-sprinkle-bridge-kd58ZuVi.js} +1 -1
  16. package/dist/ui/assets/{fs-BAw7axTJ.js → fs-Bmm-dVgS.js} +1 -1
  17. package/dist/ui/assets/{github-C5w4XnAO.js → github-DFUc2En9.js} +2 -2
  18. package/dist/ui/assets/{github-BHWdZQhw.js → github-DkQGqap-.js} +1 -1
  19. package/dist/ui/assets/{github-copilot-BFdzTYMm.js → github-copilot-C89aRkqs.js} +1 -1
  20. package/dist/ui/assets/{github-copilot-BIUN8eqB.js → github-copilot-C9yH0gek.js} +1 -1
  21. package/dist/ui/assets/{kernel-worker-D0mD7VaJ.js → kernel-worker-D7phkSl5.js} +1025 -1025
  22. package/dist/ui/assets/{lick-ws-bridge-B6-rmKYz.js → lick-ws-bridge-BGBA0Wcd.js} +1 -1
  23. package/dist/ui/assets/{local-llm-CLRAWq23.js → local-llm-P4N9PBZq.js} +1 -1
  24. package/dist/ui/assets/{magick-wasm-B59SHUdz.js → magick-wasm-BSSrd2Q9.js} +1 -1
  25. package/dist/ui/assets/{main-B-7wG_p8.js → main-8qsCPK6A.js} +8 -8
  26. package/dist/ui/assets/{main-cherry-eqj0Nu2C.js → main-cherry-DF3BM3LY.js} +1 -1
  27. package/dist/ui/assets/{migration-run-CfSJ5uPv.js → migration-run-CM6Hy1Wi.js} +1 -1
  28. package/dist/ui/assets/{mount-D4fmsx8s.js → mount-rjU2vl8h.js} +1 -1
  29. package/dist/ui/assets/{nuke-command-D68JEESV.js → nuke-command-C50gJVIh.js} +1 -1
  30. package/dist/ui/assets/{oauth-bootstrap-DRiSHWay.js → oauth-bootstrap-CJvHspVy.js} +2 -2
  31. package/dist/ui/assets/{oauth-service-CczC27lE.js → oauth-service-D21kFAZe.js} +1 -1
  32. package/dist/ui/assets/{onboarding-orchestrator-D-GBXYsj.js → onboarding-orchestrator-ChSNis3N.js} +1 -1
  33. package/dist/ui/assets/{openai-codex-BJzOHy6e.js → openai-codex-CYCa_pKQ.js} +1 -1
  34. package/dist/ui/assets/{openai-codex-D9mJoG9R.js → openai-codex-Dl6kC3U8.js} +1 -1
  35. package/dist/ui/assets/{panel-rpc-handlers-qpYZdpDo.js → panel-rpc-handlers-BXV8dPq7.js} +1 -1
  36. package/dist/ui/assets/{provider-Caph6pfA.js → provider-BorjVMc8.js} +2 -2
  37. package/dist/ui/assets/{provider-DHk3eblm.js → provider-CywdX216.js} +1 -1
  38. package/dist/ui/assets/{provider-settings-Cf_3ifG8.js → provider-settings-BSNYuaP_.js} +2 -2
  39. package/dist/ui/assets/provider-store-access-BSHOm2Gf.js +1 -0
  40. package/dist/ui/assets/provider-store-access-Dx8RSSsP.js +1 -0
  41. package/dist/ui/assets/{providers-D3em42N8.js → providers-BHEOADL6.js} +1 -1
  42. package/dist/ui/assets/{proxied-fetch-C6Rx5YCJ.js → proxied-fetch-fuq9VePW.js} +1 -1
  43. package/dist/ui/assets/{remote-terminal-view-De1qIJHZ.js → remote-terminal-view-DcjePR9Z.js} +1 -1
  44. package/dist/ui/assets/{store-BA9_NNHT.js → store-DSogcuqh.js} +1 -1
  45. package/dist/ui/assets/{sudo-Cw4ipR5k.js → sudo-zwFtFx2s.js} +1 -1
  46. package/dist/ui/assets/{tray-leave-runtime-BKuFnLnM.js → tray-leave-runtime-D730SOKi.js} +1 -1
  47. package/dist/ui/assets/{upgrade-detection-D400qfJn.js → upgrade-detection-BXai6prL.js} +1 -1
  48. package/dist/ui/assets/{xai-grok-Bw1qm-LC.js → xai-grok-B4e3rwb3.js} +1 -1
  49. package/dist/ui/assets/{xai-grok-C6ixGXqZ.js → xai-grok-CfoauSWY.js} +1 -1
  50. package/dist/ui/index.html +1 -1
  51. package/dist/ui/packages/webapp/index.html +1 -1
  52. package/package.json +1 -1
  53. package/dist/ui/assets/agent-message-to-chat-gnQ33fzd.js +0 -7
  54. package/dist/ui/assets/cost-command-DRDl5XLB.js +0 -1
  55. package/dist/ui/assets/provider-store-access-BEST5M4v.js +0 -1
  56. package/dist/ui/assets/provider-store-access-JTSTcWPW.js +0 -1
@@ -1 +1 @@
1
- import{i as e,p as t,t as n}from"./provider-settings-Cf_3ifG8.js";import{a as r,b as i,f as a,g as o,i as s,m as c,o as l,s as u,v as d}from"./bedrock-camp-wxdDcDkR.js";import{d as f,o as p,u as m}from"./transform-messages-C1X1O3BY.js";import{h}from"./kernel-worker-D0mD7VaJ.js";import{getOAuthPageOrigin as ee}from"./oauth-service-CSJo71ct.js";var g={proxyEndpoint:`https://adobe-llm-proxy.paolo-moz.workers.dev`,redirectUri:`https://www.sliccy.ai/auth/callback`,extensionRedirectUri:`https://akjjllgokmbgpbdbmafpiefnhidlmbgf.chromiumapp.org/adobe`};function te(e,t){return r(e,t)}function _(e,t,n){return e!==`xhigh`||!t?e:u(t,n)?`xhigh`:l(t,n)?`max`:`high`}function ne(e,t){let n=e?t?.thinkingLevelMap?.[e]:void 0;return _((()=>{if(typeof n==`string`)return n;switch(e){case`minimal`:case`low`:return`low`;case`medium`:return`medium`;case`xhigh`:return`xhigh`;default:return`high`}})(),t?.id,t?.name)}function v(e,t){return async(n,r)=>{let i=t?await t(n,r)??n:n,a=i.thinking;return a&&a.type===`enabled`&&(i.thinking={type:`adaptive`,...a.display===void 0?{}:{display:a.display}},i.output_config={...i.output_config??{},effort:e}),i}}function y(e,t){if(!te(e.id,e.name))return t;let n=t,r=_(n.effort??ne(n.reasoning,e),e.id,e.name);return{...t,onPayload:v(r,n.onPayload)}}function b(e,t){let n={id:e.id,name:e.name??e.id},r=t?.api??e.api,i=t?.context_window??e.context_window,a=t?.max_tokens??e.max_tokens,o=t?.reasoning??e.reasoning,s=t?.input??e.input;return r&&(n.api=r),i!==void 0&&(n.context_window=i),a!==void 0&&(n.max_tokens=a),o!==void 0&&(n.reasoning=o),s&&(n.input=s),/haiku/i.test(e.id)&&(n.compat={supportsEagerToolInputStreaming:!1}),n}function x(e=3e5){let t=0;return{async run(n,r=Date.now()){if(r<t)return null;let i=null;try{i=await n()}catch(e){console.debug(`[silent-renew-backoff] renew threw:`,e instanceof Error?e.message:String(e)),i=null}return t=i?0:r+e,i},inCooldown(e=Date.now()){return e<t}}}const S=Object.assign({"/packages/webapp/providers/adobe-config.json":g})[`/packages/webapp/providers/adobe-config.json`]??{clientId:``,proxyEndpoint:``,scopes:`openid,profile,email`};function C(){let t=e(`adobe`);if(t)return t.replace(/\/$/,``);if(S.proxyEndpoint)return S.proxyEndpoint.replace(/\/$/,``);throw Error(`Adobe proxy endpoint not configured — set it in Settings or adobe-config.json`)}const w=new Map,T=new Map,E=`slicc-adobe-models`;function D(e){try{localStorage.setItem(E,JSON.stringify(e))}catch{}}async function O(e){let t=w.get(e);if(t)return t;try{let t=await fetch(`${e}/v1/config`,{headers:{[U]:`3.48.0`}});if(t.ok){let n=await t.json();return w.set(e,n),n}console.warn(`[adobe] Proxy /v1/config returned ${t.status}, falling back to build-time config`)}catch(e){console.warn(`[adobe] Failed to fetch proxy config:`,e instanceof Error?e.message:String(e))}let n={};return w.set(e,n),n}function k(e){let t=e.clientId||S.clientId;if(!t)throw Error(`Could not determine IMS client ID — proxy /v1/config did not return one and adobe-config.json is empty`);return t}function A(e){return e.scopes||S.scopes}function j(e){return e.imsEnvironment||S.imsEnvironment||`prod`}const M={prod:`https://ims-na1.adobelogin.com`,stg1:`https://ims-na1-stg1.adobelogin.com`};function N(e){return M[e??S.imsEnvironment??`prod`]??M.prod}const P=typeof chrome<`u`&&!!chrome?.runtime?.id;function F(){return n().find(e=>e.providerId===`adobe`)}async function I(e,t){try{let n=await fetch(`${N(t)}/ims/userinfo/v2`,{headers:{Authorization:`Bearer ${e}`}});if(n.ok){let e=await n.json();return{name:e.displayName||e.name||e.email,avatar:e.picture||e.avatar_url}}console.warn(`[adobe] User profile fetch returned ${n.status}, account will have no display name`)}catch(e){console.warn(`[adobe] Failed to fetch user profile:`,e instanceof Error?e.message:String(e))}return{}}function L(e){let t=e.indexOf(`#`);if(t<0)return null;let n=new URLSearchParams(e.slice(t+1)),r=n.get(`access_token`);return r?{accessToken:r,expiresIn:parseInt(n.get(`expires_in`)??`86400`,10)}:null}const R={id:`adobe`,name:`Adobe`,description:`Claude via Adobe — login with your Adobe ID`,requiresApiKey:!1,requiresBaseUrl:!S.proxyEndpoint,baseUrlPlaceholder:`https://your-proxy.example.com`,baseUrlDescription:`Anthropic-compatible proxy endpoint`,isOAuth:!0,defaultModelId:`sonnet`,oauthTokenDomains:[`ims-na1.adobelogin.com`,`ims-na1-stg1.adobelogin.com`,`*.adobelogin.com`,`*.adobe.io`,`firefall.adobe.io`,`admin.hlx.page`,`admin.hlx.live`,`admin.aem.page`,`admin.aem.live`],getModelIds:()=>{let e=e=>b(e,T.get(e.id));for(let t of Q.values())if(t.length){let n=t.map(t=>e({id:t.id,name:t.name??t.id}));return D(n),n}for(let t of w.values())if(t.models?.length)return t.models.map(t=>e(t));try{let e=localStorage.getItem(E);if(e){let t=JSON.parse(e);if(t.length)return t}}catch{}return[{id:`claude-sonnet-4-6`,name:`Claude Sonnet 4.6`}]},onOAuthLogin:async(e,n,r)=>{let i=C(),a=await O(i),o=k(a),s=A(a),c=j(a),l=P?null:await ee(),u=P?S.extensionRedirectUri??`https://${chrome.runtime.id}.chromiumapp.org/`:S.redirectUri??`${l.origin}/auth/callback`,d=P?void 0:btoa(JSON.stringify({port:parseInt(new URL(l.href).port||`5710`,10),path:`/auth/callback`,nonce:crypto.randomUUID()})),f=d?JSON.parse(atob(d)).nonce:null,p=new URLSearchParams({client_id:o,scope:s,response_type:`token`,redirect_uri:u});d&&p.set(`state`,d),r?.forceReauth&&p.set(`prompt`,`login`);let m=await e(`${N(c)}/ims/authorize/v2?${p}`);if(!m)return;if(f&&m)try{if(new URL(m).searchParams.get(`nonce`)!==f){console.error(`[adobe] OAuth nonce mismatch — possible CSRF`);return}}catch(e){console.warn(`[adobe] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}let h=L(m);if(!h){console.error(`[adobe] Could not extract token from redirect URL`);return}let g=await I(h.accessToken,c);await t({providerId:`adobe`,accessToken:h.accessToken,tokenExpiresAt:Date.now()+h.expiresIn*1e3,userName:g.name,userAvatar:g.avatar,baseUrl:S.proxyEndpoint?void 0:i}),await $().catch(e=>console.warn(`[adobe] Failed to fetch models after login:`,e instanceof Error?e.message:String(e))),n()},onOAuthLogout:async()=>{let e=F();if(e?.accessToken)try{let t=w.values().next().value??{},n=t.clientId||S.clientId,r=j(t);if(n){let t=await fetch(`${N(r)}/ims/revoke`,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:new URLSearchParams({token:e.accessToken,token_type_hint:`access_token`,client_id:n})});t.ok||console.warn(`[adobe] Token revocation returned ${t.status}, token may still be valid server-side`)}}catch(e){console.warn(`[adobe] Failed to revoke token:`,e instanceof Error?e.message:String(e))}await t({providerId:`adobe`,accessToken:``})},onSilentRenew:async()=>F()?.accessToken?H():null,refreshModels:async e=>{await $(e);let t=R.getModelIds?.();t?.length&&D(t)}};let z=null;const B=x();async function V(){let e=F();if(!e?.accessToken)throw Error(`Not logged in to Adobe — please log in first`);if((e.tokenExpiresAt??0)-Date.now()>6e4)return e.accessToken;console.log(`[adobe] Token expired or expiring soon, attempting silent renewal...`);let t=await B.run(()=>H());if(t)return t;let n=F();if((n?.tokenExpiresAt??0)-Date.now()>0&&n?.accessToken)return n.accessToken;throw Error(`Adobe session expired — please log in again`)}function re(){let e=F();return e?.tokenExpiresAt?Date.now()>e.tokenExpiresAt-6e4:!0}async function H(){return typeof window>`u`?null:z||(z=(async()=>{try{let e=C(),n=await O(e),r=k(n),i=A(n),a=j(n),o=P?S.extensionRedirectUri??`https://${chrome.runtime.id}.chromiumapp.org/`:S.redirectUri??`${window.location.origin}/auth/callback`,s=P?void 0:btoa(JSON.stringify({port:parseInt(new URL(window.location.href).port||`5710`,10),path:`/auth/callback`,nonce:crypto.randomUUID()})),c=s?JSON.parse(atob(s)).nonce:null,l=new URLSearchParams({client_id:r,scope:i,response_type:`token`,redirect_uri:o,prompt:`none`});s&&l.set(`state`,s);let u=`${N(a)}/ims/authorize/v2?${l}`,{createOAuthLauncher:d}=await import(`./oauth-service-CSJo71ct.js`),f=await d()(u,{interactive:!1});if(!f)return null;if(c&&f)try{if(new URL(f).searchParams.get(`nonce`)!==c)return console.error(`[adobe] OAuth nonce mismatch — possible CSRF`),null}catch(e){console.warn(`[adobe] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}let p=L(f);if(!p)return null;let m=F();return await t({providerId:`adobe`,accessToken:p.accessToken,tokenExpiresAt:Date.now()+p.expiresIn*1e3,userName:m?.userName,userAvatar:m?.userAvatar,baseUrl:S.proxyEndpoint?void 0:e}),console.log(`[adobe] Token renewed silently`),await $().catch(e=>console.warn(`[adobe] Failed to refresh models after silent renewal:`,e instanceof Error?e.message:String(e))),p.accessToken}catch(e){return console.warn(`[adobe] Silent renewal error:`,e instanceof Error?e.message:String(e)),null}finally{z=null}})(),z)}const U=`X-Slicc-Version`;function W(e){let t={};if(e.headers)for(let[n,r]of Object.entries(e.headers))n.toLowerCase()!==`x-slicc-version`&&(t[n]=r);return t[U]=`3.48.0`,{...e,headers:t}}const G=new Set;function K(e,t){if(e.headers){for(let t of Object.keys(e.headers))if(t.toLowerCase()===`x-session-id`)return e}return G.has(t)||(G.add(t),console.warn(`[adobe] Missing X-Session-Id from ${t} — using daily fallback. Attach an X-Session-Id header at the call site (see scoop-context.ts streamWithSessionId or docs/pitfalls.md).`)),{...e,headers:{...e.headers??{},"X-Session-Id":h(`adobe-provider-fallback`)}}}function q(){G.clear()}function J(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:`adobe-anthropic`,provider:`adobe`,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}}const Y=(e,t,n={})=>{let r=p();return(async()=>{try{let i=await V();if(String(e.api).includes(`openai`)){let a=c({...e,baseUrl:`${C()}/v1`,api:`openai-completions`,compat:{...e.compat,supportsStore:!1,supportsDeveloperRole:!1}},t,W(K({...n,apiKey:i},`streamAdobe[openai]`)));for await(let e of a)r.push(e)}else{let o=a({...e,baseUrl:C(),api:`anthropic-messages`},t,W(K(y(e,s(e.id,e.name,{...n,apiKey:i})),`streamAdobe[anthropic]`)));for await(let e of o)r.push(e)}r.end()}catch(t){console.error(`[adobe] Stream error:`,t instanceof Error?t.message:String(t)),r.push(J(e,t)),r.end()}})(),r},X=(e,t,n)=>{let r=p();return(async()=>{try{let i=await V();if(String(e.api).includes(`openai`)){let a=d({...e,baseUrl:`${C()}/v1`,api:`openai-completions`,compat:{...e.compat,supportsStore:!1,supportsDeveloperRole:!1}},t,W(K({...n,apiKey:i},`streamSimpleAdobe[openai]`)));for await(let e of a)r.push(e)}else{let a=o({...e,baseUrl:C(),api:`anthropic-messages`},t,W(K(y(e,s(e.id,e.name,{...n,apiKey:i})),`streamSimpleAdobe[anthropic]`)));for await(let e of a)r.push(e)}r.end()}catch(t){console.error(`[adobe] Stream error:`,t instanceof Error?t.message:String(t)),r.push(J(e,t)),r.end()}})(),r};async function Z(e){try{let t=e??await V(),n=C(),r=await fetch(`${n}/v1/models`,{headers:{Authorization:`Bearer ${t}`,[U]:`3.48.0`}});if(r.ok){let e=await r.json();if(e.data?.length){for(let t of e.data){let e={id:t.id,name:t.name};t.api!==void 0&&(e.api=t.api),t.context_window!==void 0&&(e.context_window=t.context_window),t.max_tokens!==void 0&&(e.max_tokens=t.max_tokens),t.reasoning!==void 0&&(e.reasoning=t.reasoning),t.input!==void 0&&(e.input=t.input),T.set(t.id,e)}let t=new Map;for(let e of f())try{for(let n of m(e))t.set(n.id,n)}catch{}return e.data.map(e=>{let r=t.get(e.id),i=`adobe-${e.api===`openai`?`openai`:`anthropic`}`;return r?{...r,provider:`adobe`,api:i}:{id:e.id,name:e.name??e.id,provider:`adobe`,api:i,baseUrl:n,contextWindow:2e5,maxTokens:16384,input:[`text`,`image`],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},inputCost:0,outputCost:0,cacheReadCost:0,cacheWriteCost:0,reasoning:!0}})}}else console.warn(`[adobe] Proxy /v1/models returned ${r.status}, falling back to Anthropic models`)}catch(e){console.warn(`[adobe] Failed to fetch proxy models:`,e instanceof Error?e.message:String(e))}return null}const Q=new Map;function ie(){return m(`anthropic`).map(e=>({...e,provider:`adobe`,api:`adobe-anthropic`}))}async function $(e){let t=C(),n=Q.get(t);if(n)return n;let r=await Z(e);return r?(Q.set(t,r),r):ie()}function ae(){i({api:`adobe-anthropic`,stream:Y,streamSimple:X}),i({api:`adobe-openai`,stream:Y,streamSimple:X})}export{q as __resetAdobeSessionIdWarningCacheForTests,R as config,$ as getAdobeModels,V as getValidAccessToken,re as isTokenExpired,ae as register};
1
+ import{i as e,p as t,t as n}from"./provider-settings-BSNYuaP_.js";import{a as r,b as i,f as a,g as o,i as s,m as c,o as l,s as u,v as d}from"./bedrock-camp-wxdDcDkR.js";import{d as f,o as p,u as m}from"./transform-messages-C1X1O3BY.js";import{h}from"./kernel-worker-D7phkSl5.js";import{getOAuthPageOrigin as ee}from"./oauth-service-CSJo71ct.js";var g={proxyEndpoint:`https://adobe-llm-proxy.paolo-moz.workers.dev`,redirectUri:`https://www.sliccy.ai/auth/callback`,extensionRedirectUri:`https://akjjllgokmbgpbdbmafpiefnhidlmbgf.chromiumapp.org/adobe`};function te(e,t){return r(e,t)}function _(e,t,n){return e!==`xhigh`||!t?e:u(t,n)?`xhigh`:l(t,n)?`max`:`high`}function ne(e,t){let n=e?t?.thinkingLevelMap?.[e]:void 0;return _((()=>{if(typeof n==`string`)return n;switch(e){case`minimal`:case`low`:return`low`;case`medium`:return`medium`;case`xhigh`:return`xhigh`;default:return`high`}})(),t?.id,t?.name)}function v(e,t){return async(n,r)=>{let i=t?await t(n,r)??n:n,a=i.thinking;return a&&a.type===`enabled`&&(i.thinking={type:`adaptive`,...a.display===void 0?{}:{display:a.display}},i.output_config={...i.output_config??{},effort:e}),i}}function y(e,t){if(!te(e.id,e.name))return t;let n=t,r=_(n.effort??ne(n.reasoning,e),e.id,e.name);return{...t,onPayload:v(r,n.onPayload)}}function b(e,t){let n={id:e.id,name:e.name??e.id},r=t?.api??e.api,i=t?.context_window??e.context_window,a=t?.max_tokens??e.max_tokens,o=t?.reasoning??e.reasoning,s=t?.input??e.input;return r&&(n.api=r),i!==void 0&&(n.context_window=i),a!==void 0&&(n.max_tokens=a),o!==void 0&&(n.reasoning=o),s&&(n.input=s),/haiku/i.test(e.id)&&(n.compat={supportsEagerToolInputStreaming:!1}),n}function x(e=3e5){let t=0;return{async run(n,r=Date.now()){if(r<t)return null;let i=null;try{i=await n()}catch(e){console.debug(`[silent-renew-backoff] renew threw:`,e instanceof Error?e.message:String(e)),i=null}return t=i?0:r+e,i},inCooldown(e=Date.now()){return e<t}}}const S=Object.assign({"/packages/webapp/providers/adobe-config.json":g})[`/packages/webapp/providers/adobe-config.json`]??{clientId:``,proxyEndpoint:``,scopes:`openid,profile,email`};function C(){let t=e(`adobe`);if(t)return t.replace(/\/$/,``);if(S.proxyEndpoint)return S.proxyEndpoint.replace(/\/$/,``);throw Error(`Adobe proxy endpoint not configured — set it in Settings or adobe-config.json`)}const w=new Map,T=new Map,E=`slicc-adobe-models`;function D(e){try{localStorage.setItem(E,JSON.stringify(e))}catch{}}async function O(e){let t=w.get(e);if(t)return t;try{let t=await fetch(`${e}/v1/config`,{headers:{[U]:`3.48.1`}});if(t.ok){let n=await t.json();return w.set(e,n),n}console.warn(`[adobe] Proxy /v1/config returned ${t.status}, falling back to build-time config`)}catch(e){console.warn(`[adobe] Failed to fetch proxy config:`,e instanceof Error?e.message:String(e))}let n={};return w.set(e,n),n}function k(e){let t=e.clientId||S.clientId;if(!t)throw Error(`Could not determine IMS client ID — proxy /v1/config did not return one and adobe-config.json is empty`);return t}function A(e){return e.scopes||S.scopes}function j(e){return e.imsEnvironment||S.imsEnvironment||`prod`}const M={prod:`https://ims-na1.adobelogin.com`,stg1:`https://ims-na1-stg1.adobelogin.com`};function N(e){return M[e??S.imsEnvironment??`prod`]??M.prod}const P=typeof chrome<`u`&&!!chrome?.runtime?.id;function F(){return n().find(e=>e.providerId===`adobe`)}async function I(e,t){try{let n=await fetch(`${N(t)}/ims/userinfo/v2`,{headers:{Authorization:`Bearer ${e}`}});if(n.ok){let e=await n.json();return{name:e.displayName||e.name||e.email,avatar:e.picture||e.avatar_url}}console.warn(`[adobe] User profile fetch returned ${n.status}, account will have no display name`)}catch(e){console.warn(`[adobe] Failed to fetch user profile:`,e instanceof Error?e.message:String(e))}return{}}function L(e){let t=e.indexOf(`#`);if(t<0)return null;let n=new URLSearchParams(e.slice(t+1)),r=n.get(`access_token`);return r?{accessToken:r,expiresIn:parseInt(n.get(`expires_in`)??`86400`,10)}:null}const R={id:`adobe`,name:`Adobe`,description:`Claude via Adobe — login with your Adobe ID`,requiresApiKey:!1,requiresBaseUrl:!S.proxyEndpoint,baseUrlPlaceholder:`https://your-proxy.example.com`,baseUrlDescription:`Anthropic-compatible proxy endpoint`,isOAuth:!0,defaultModelId:`sonnet`,oauthTokenDomains:[`ims-na1.adobelogin.com`,`ims-na1-stg1.adobelogin.com`,`*.adobelogin.com`,`*.adobe.io`,`firefall.adobe.io`,`admin.hlx.page`,`admin.hlx.live`,`admin.aem.page`,`admin.aem.live`],getModelIds:()=>{let e=e=>b(e,T.get(e.id));for(let t of Q.values())if(t.length){let n=t.map(t=>e({id:t.id,name:t.name??t.id}));return D(n),n}for(let t of w.values())if(t.models?.length)return t.models.map(t=>e(t));try{let e=localStorage.getItem(E);if(e){let t=JSON.parse(e);if(t.length)return t}}catch{}return[{id:`claude-sonnet-4-6`,name:`Claude Sonnet 4.6`}]},onOAuthLogin:async(e,n,r)=>{let i=C(),a=await O(i),o=k(a),s=A(a),c=j(a),l=P?null:await ee(),u=P?S.extensionRedirectUri??`https://${chrome.runtime.id}.chromiumapp.org/`:S.redirectUri??`${l.origin}/auth/callback`,d=P?void 0:btoa(JSON.stringify({port:parseInt(new URL(l.href).port||`5710`,10),path:`/auth/callback`,nonce:crypto.randomUUID()})),f=d?JSON.parse(atob(d)).nonce:null,p=new URLSearchParams({client_id:o,scope:s,response_type:`token`,redirect_uri:u});d&&p.set(`state`,d),r?.forceReauth&&p.set(`prompt`,`login`);let m=await e(`${N(c)}/ims/authorize/v2?${p}`);if(!m)return;if(f&&m)try{if(new URL(m).searchParams.get(`nonce`)!==f){console.error(`[adobe] OAuth nonce mismatch — possible CSRF`);return}}catch(e){console.warn(`[adobe] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}let h=L(m);if(!h){console.error(`[adobe] Could not extract token from redirect URL`);return}let g=await I(h.accessToken,c);await t({providerId:`adobe`,accessToken:h.accessToken,tokenExpiresAt:Date.now()+h.expiresIn*1e3,userName:g.name,userAvatar:g.avatar,baseUrl:S.proxyEndpoint?void 0:i}),await $().catch(e=>console.warn(`[adobe] Failed to fetch models after login:`,e instanceof Error?e.message:String(e))),n()},onOAuthLogout:async()=>{let e=F();if(e?.accessToken)try{let t=w.values().next().value??{},n=t.clientId||S.clientId,r=j(t);if(n){let t=await fetch(`${N(r)}/ims/revoke`,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:new URLSearchParams({token:e.accessToken,token_type_hint:`access_token`,client_id:n})});t.ok||console.warn(`[adobe] Token revocation returned ${t.status}, token may still be valid server-side`)}}catch(e){console.warn(`[adobe] Failed to revoke token:`,e instanceof Error?e.message:String(e))}await t({providerId:`adobe`,accessToken:``})},onSilentRenew:async()=>F()?.accessToken?H():null,refreshModels:async e=>{await $(e);let t=R.getModelIds?.();t?.length&&D(t)}};let z=null;const B=x();async function V(){let e=F();if(!e?.accessToken)throw Error(`Not logged in to Adobe — please log in first`);if((e.tokenExpiresAt??0)-Date.now()>6e4)return e.accessToken;console.log(`[adobe] Token expired or expiring soon, attempting silent renewal...`);let t=await B.run(()=>H());if(t)return t;let n=F();if((n?.tokenExpiresAt??0)-Date.now()>0&&n?.accessToken)return n.accessToken;throw Error(`Adobe session expired — please log in again`)}function re(){let e=F();return e?.tokenExpiresAt?Date.now()>e.tokenExpiresAt-6e4:!0}async function H(){return typeof window>`u`?null:z||(z=(async()=>{try{let e=C(),n=await O(e),r=k(n),i=A(n),a=j(n),o=P?S.extensionRedirectUri??`https://${chrome.runtime.id}.chromiumapp.org/`:S.redirectUri??`${window.location.origin}/auth/callback`,s=P?void 0:btoa(JSON.stringify({port:parseInt(new URL(window.location.href).port||`5710`,10),path:`/auth/callback`,nonce:crypto.randomUUID()})),c=s?JSON.parse(atob(s)).nonce:null,l=new URLSearchParams({client_id:r,scope:i,response_type:`token`,redirect_uri:o,prompt:`none`});s&&l.set(`state`,s);let u=`${N(a)}/ims/authorize/v2?${l}`,{createOAuthLauncher:d}=await import(`./oauth-service-CSJo71ct.js`),f=await d()(u,{interactive:!1});if(!f)return null;if(c&&f)try{if(new URL(f).searchParams.get(`nonce`)!==c)return console.error(`[adobe] OAuth nonce mismatch — possible CSRF`),null}catch(e){console.warn(`[adobe] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}let p=L(f);if(!p)return null;let m=F();return await t({providerId:`adobe`,accessToken:p.accessToken,tokenExpiresAt:Date.now()+p.expiresIn*1e3,userName:m?.userName,userAvatar:m?.userAvatar,baseUrl:S.proxyEndpoint?void 0:e}),console.log(`[adobe] Token renewed silently`),await $().catch(e=>console.warn(`[adobe] Failed to refresh models after silent renewal:`,e instanceof Error?e.message:String(e))),p.accessToken}catch(e){return console.warn(`[adobe] Silent renewal error:`,e instanceof Error?e.message:String(e)),null}finally{z=null}})(),z)}const U=`X-Slicc-Version`;function W(e){let t={};if(e.headers)for(let[n,r]of Object.entries(e.headers))n.toLowerCase()!==`x-slicc-version`&&(t[n]=r);return t[U]=`3.48.1`,{...e,headers:t}}const G=new Set;function K(e,t){if(e.headers){for(let t of Object.keys(e.headers))if(t.toLowerCase()===`x-session-id`)return e}return G.has(t)||(G.add(t),console.warn(`[adobe] Missing X-Session-Id from ${t} — using daily fallback. Attach an X-Session-Id header at the call site (see scoop-context.ts streamWithSessionId or docs/pitfalls.md).`)),{...e,headers:{...e.headers??{},"X-Session-Id":h(`adobe-provider-fallback`)}}}function q(){G.clear()}function J(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:`adobe-anthropic`,provider:`adobe`,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}}const Y=(e,t,n={})=>{let r=p();return(async()=>{try{let i=await V();if(String(e.api).includes(`openai`)){let a=c({...e,baseUrl:`${C()}/v1`,api:`openai-completions`,compat:{...e.compat,supportsStore:!1,supportsDeveloperRole:!1}},t,W(K({...n,apiKey:i},`streamAdobe[openai]`)));for await(let e of a)r.push(e)}else{let o=a({...e,baseUrl:C(),api:`anthropic-messages`},t,W(K(y(e,s(e.id,e.name,{...n,apiKey:i})),`streamAdobe[anthropic]`)));for await(let e of o)r.push(e)}r.end()}catch(t){console.error(`[adobe] Stream error:`,t instanceof Error?t.message:String(t)),r.push(J(e,t)),r.end()}})(),r},X=(e,t,n)=>{let r=p();return(async()=>{try{let i=await V();if(String(e.api).includes(`openai`)){let a=d({...e,baseUrl:`${C()}/v1`,api:`openai-completions`,compat:{...e.compat,supportsStore:!1,supportsDeveloperRole:!1}},t,W(K({...n,apiKey:i},`streamSimpleAdobe[openai]`)));for await(let e of a)r.push(e)}else{let a=o({...e,baseUrl:C(),api:`anthropic-messages`},t,W(K(y(e,s(e.id,e.name,{...n,apiKey:i})),`streamSimpleAdobe[anthropic]`)));for await(let e of a)r.push(e)}r.end()}catch(t){console.error(`[adobe] Stream error:`,t instanceof Error?t.message:String(t)),r.push(J(e,t)),r.end()}})(),r};async function Z(e){try{let t=e??await V(),n=C(),r=await fetch(`${n}/v1/models`,{headers:{Authorization:`Bearer ${t}`,[U]:`3.48.1`}});if(r.ok){let e=await r.json();if(e.data?.length){for(let t of e.data){let e={id:t.id,name:t.name};t.api!==void 0&&(e.api=t.api),t.context_window!==void 0&&(e.context_window=t.context_window),t.max_tokens!==void 0&&(e.max_tokens=t.max_tokens),t.reasoning!==void 0&&(e.reasoning=t.reasoning),t.input!==void 0&&(e.input=t.input),T.set(t.id,e)}let t=new Map;for(let e of f())try{for(let n of m(e))t.set(n.id,n)}catch{}return e.data.map(e=>{let r=t.get(e.id),i=`adobe-${e.api===`openai`?`openai`:`anthropic`}`;return r?{...r,provider:`adobe`,api:i}:{id:e.id,name:e.name??e.id,provider:`adobe`,api:i,baseUrl:n,contextWindow:2e5,maxTokens:16384,input:[`text`,`image`],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},inputCost:0,outputCost:0,cacheReadCost:0,cacheWriteCost:0,reasoning:!0}})}}else console.warn(`[adobe] Proxy /v1/models returned ${r.status}, falling back to Anthropic models`)}catch(e){console.warn(`[adobe] Failed to fetch proxy models:`,e instanceof Error?e.message:String(e))}return null}const Q=new Map;function ie(){return m(`anthropic`).map(e=>({...e,provider:`adobe`,api:`adobe-anthropic`}))}async function $(e){let t=C(),n=Q.get(t);if(n)return n;let r=await Z(e);return r?(Q.set(t,r),r):ie()}function ae(){i({api:`adobe-anthropic`,stream:Y,streamSimple:X}),i({api:`adobe-openai`,stream:Y,streamSimple:X})}export{q as __resetAdobeSessionIdWarningCacheForTests,R as config,$ as getAdobeModels,V as getValidAccessToken,re as isTokenExpired,ae as register};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/oauth-service-CczC27lE.js","assets/preload-helper-zJ_50EbN.js","assets/main-B-7wG_p8.js","assets/chunk-aKtaBQYM.js","assets/modulepreload-polyfill-Dezn_h7o.js","assets/bedrock-camp-ChanTZ04.js","assets/transform-messages-B3Q-Bwv-.js","assets/json-parse-BUunmmNl.js","assets/logger-DDBAeTLF.js","assets/mime-types-B9LIwKG5.js","assets/mount-picker-popup-DncaR5N8.js","assets/path-utils-DU6QhF_k.js","assets/types-idfTVsM8.js","assets/hid-device-registry-D2LsJCRr.js","assets/picker-approval-tzbkMw-e.js","assets/tool-ui-YOPqzMmL.js","assets/clipboard-DgFtRQbq.js","assets/main-B-eXD0kW.css"])))=>i.map(i=>d[i]);
2
- import{_ as e,a as t,d as n,h as r,i,l as a,o,p as s,s as c}from"./bedrock-camp-ChanTZ04.js";import{t as l}from"./preload-helper-zJ_50EbN.js";import{d as u,o as d,u as f}from"./transform-messages-B3Q-Bwv-.js";import{$ as p,J as m,W as h,rt as g}from"./main-B-7wG_p8.js";import{getOAuthPageOrigin as ee}from"./oauth-service-CczC27lE.js";var _={proxyEndpoint:`https://adobe-llm-proxy.paolo-moz.workers.dev`,redirectUri:`https://www.sliccy.ai/auth/callback`,extensionRedirectUri:`https://akjjllgokmbgpbdbmafpiefnhidlmbgf.chromiumapp.org/adobe`};function v(e,n){return t(e,n)}function y(e,t,n){return e!==`xhigh`||!t?e:c(t,n)?`xhigh`:o(t,n)?`max`:`high`}function b(e,t){let n=e?t?.thinkingLevelMap?.[e]:void 0;return y((()=>{if(typeof n==`string`)return n;switch(e){case`minimal`:case`low`:return`low`;case`medium`:return`medium`;case`xhigh`:return`xhigh`;default:return`high`}})(),t?.id,t?.name)}function x(e,t){return async(n,r)=>{let i=t?await t(n,r)??n:n,a=i.thinking;return a&&a.type===`enabled`&&(i.thinking={type:`adaptive`,...a.display===void 0?{}:{display:a.display}},i.output_config={...i.output_config??{},effort:e}),i}}function S(e,t){if(!v(e.id,e.name))return t;let n=t,r=y(n.effort??b(n.reasoning,e),e.id,e.name);return{...t,onPayload:x(r,n.onPayload)}}function te(e,t){let n={id:e.id,name:e.name??e.id},r=t?.api??e.api,i=t?.context_window??e.context_window,a=t?.max_tokens??e.max_tokens,o=t?.reasoning??e.reasoning,s=t?.input??e.input;return r&&(n.api=r),i!==void 0&&(n.context_window=i),a!==void 0&&(n.max_tokens=a),o!==void 0&&(n.reasoning=o),s&&(n.input=s),/haiku/i.test(e.id)&&(n.compat={supportsEagerToolInputStreaming:!1}),n}var ne=5*6e4;function re(e=ne){let t=0;return{async run(n,r=Date.now()){if(r<t)return null;let i=null;try{i=await n()}catch(e){console.debug(`[silent-renew-backoff] renew threw:`,e instanceof Error?e.message:String(e)),i=null}return t=i?0:r+e,i},inCooldown(e=Date.now()){return e<t}}}var C=Object.assign({"/packages/webapp/providers/adobe-config.json":_})[`/packages/webapp/providers/adobe-config.json`]??{clientId:``,proxyEndpoint:``,scopes:`openid,profile,email`};function w(){let e=m(`adobe`);if(e)return e.replace(/\/$/,``);if(C.proxyEndpoint)return C.proxyEndpoint.replace(/\/$/,``);throw Error(`Adobe proxy endpoint not configured — set it in Settings or adobe-config.json`)}var T=new Map,E=new Map,D=`slicc-adobe-models`;function O(e){try{localStorage.setItem(D,JSON.stringify(e))}catch{}}async function k(e){let t=T.get(e);if(t)return t;try{let t=await fetch(`${e}/v1/config`,{headers:{[G]:`3.48.0`}});if(t.ok){let n=await t.json();return T.set(e,n),n}console.warn(`[adobe] Proxy /v1/config returned ${t.status}, falling back to build-time config`)}catch(e){console.warn(`[adobe] Failed to fetch proxy config:`,e instanceof Error?e.message:String(e))}let n={};return T.set(e,n),n}function A(e){let t=e.clientId||C.clientId;if(!t)throw Error(`Could not determine IMS client ID — proxy /v1/config did not return one and adobe-config.json is empty`);return t}function j(e){return e.scopes||C.scopes}function M(e){return e.imsEnvironment||C.imsEnvironment||`prod`}var N={prod:`https://ims-na1.adobelogin.com`,stg1:`https://ims-na1-stg1.adobelogin.com`};function P(e){return N[e??C.imsEnvironment??`prod`]??N.prod}var F=typeof chrome<`u`&&!!chrome?.runtime?.id;function I(){return h().find(e=>e.providerId===`adobe`)}async function L(e,t){try{let n=await fetch(`${P(t)}/ims/userinfo/v2`,{headers:{Authorization:`Bearer ${e}`}});if(n.ok){let e=await n.json();return{name:e.displayName||e.name||e.email,avatar:e.picture||e.avatar_url}}console.warn(`[adobe] User profile fetch returned ${n.status}, account will have no display name`)}catch(e){console.warn(`[adobe] Failed to fetch user profile:`,e instanceof Error?e.message:String(e))}return{}}function R(e){let t=e.indexOf(`#`);if(t<0)return null;let n=new URLSearchParams(e.slice(t+1)),r=n.get(`access_token`);return r?{accessToken:r,expiresIn:parseInt(n.get(`expires_in`)??`86400`,10)}:null}var z={id:`adobe`,name:`Adobe`,description:`Claude via Adobe — login with your Adobe ID`,requiresApiKey:!1,requiresBaseUrl:!C.proxyEndpoint,baseUrlPlaceholder:`https://your-proxy.example.com`,baseUrlDescription:`Anthropic-compatible proxy endpoint`,isOAuth:!0,defaultModelId:`sonnet`,oauthTokenDomains:[`ims-na1.adobelogin.com`,`ims-na1-stg1.adobelogin.com`,`*.adobelogin.com`,`*.adobe.io`,`firefall.adobe.io`,`admin.hlx.page`,`admin.hlx.live`,`admin.aem.page`,`admin.aem.live`],getModelIds:()=>{let e=e=>te(e,E.get(e.id));for(let t of Q.values())if(t.length){let n=t.map(t=>e({id:t.id,name:t.name??t.id}));return O(n),n}for(let t of T.values())if(t.models?.length)return t.models.map(t=>e(t));try{let e=localStorage.getItem(D);if(e){let t=JSON.parse(e);if(t.length)return t}}catch{}return[{id:`claude-sonnet-4-6`,name:`Claude Sonnet 4.6`}]},onOAuthLogin:async(e,t,n)=>{let r=w(),i=await k(r),a=A(i),o=j(i),s=M(i),c=F?null:await ee(),l=F?C.extensionRedirectUri??`https://${chrome.runtime.id}.chromiumapp.org/`:C.redirectUri??`${c.origin}/auth/callback`,u=F?void 0:btoa(JSON.stringify({port:parseInt(new URL(c.href).port||`5710`,10),path:`/auth/callback`,nonce:crypto.randomUUID()})),d=u?JSON.parse(atob(u)).nonce:null,f=new URLSearchParams({client_id:a,scope:o,response_type:`token`,redirect_uri:l});u&&f.set(`state`,u),n?.forceReauth&&f.set(`prompt`,`login`);let m=await e(`${P(s)}/ims/authorize/v2?${f}`);if(!m)return;if(d&&m)try{if(new URL(m).searchParams.get(`nonce`)!==d){console.error(`[adobe] OAuth nonce mismatch — possible CSRF`);return}}catch(e){console.warn(`[adobe] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}let h=R(m);if(!h){console.error(`[adobe] Could not extract token from redirect URL`);return}let g=await L(h.accessToken,s);await p({providerId:`adobe`,accessToken:h.accessToken,tokenExpiresAt:Date.now()+h.expiresIn*1e3,userName:g.name,userAvatar:g.avatar,baseUrl:C.proxyEndpoint?void 0:r}),await $().catch(e=>console.warn(`[adobe] Failed to fetch models after login:`,e instanceof Error?e.message:String(e))),t()},onOAuthLogout:async()=>{let e=I();if(e?.accessToken)try{let t=T.values().next().value??{},n=t.clientId||C.clientId,r=M(t);if(n){let t=await fetch(`${P(r)}/ims/revoke`,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:new URLSearchParams({token:e.accessToken,token_type_hint:`access_token`,client_id:n})});t.ok||console.warn(`[adobe] Token revocation returned ${t.status}, token may still be valid server-side`)}}catch(e){console.warn(`[adobe] Failed to revoke token:`,e instanceof Error?e.message:String(e))}await p({providerId:`adobe`,accessToken:``})},onSilentRenew:async()=>I()?.accessToken?W():null,refreshModels:async e=>{await $(e);let t=z.getModelIds?.();t?.length&&O(t)}},B=null,V=re();async function H(){let e=I();if(!e?.accessToken)throw Error(`Not logged in to Adobe — please log in first`);if((e.tokenExpiresAt??0)-Date.now()>6e4)return e.accessToken;console.log(`[adobe] Token expired or expiring soon, attempting silent renewal...`);let t=await V.run(()=>W());if(t)return t;let n=I();if((n?.tokenExpiresAt??0)-Date.now()>0&&n?.accessToken)return n.accessToken;throw Error(`Adobe session expired — please log in again`)}function U(){let e=I();return e?.tokenExpiresAt?Date.now()>e.tokenExpiresAt-6e4:!0}async function W(){return typeof window>`u`?null:B||(B=(async()=>{try{let e=w(),t=await k(e),n=A(t),r=j(t),i=M(t),a=F?C.extensionRedirectUri??`https://${chrome.runtime.id}.chromiumapp.org/`:C.redirectUri??`${window.location.origin}/auth/callback`,o=F?void 0:btoa(JSON.stringify({port:parseInt(new URL(window.location.href).port||`5710`,10),path:`/auth/callback`,nonce:crypto.randomUUID()})),s=o?JSON.parse(atob(o)).nonce:null,c=new URLSearchParams({client_id:n,scope:r,response_type:`token`,redirect_uri:a,prompt:`none`});o&&c.set(`state`,o);let u=`${P(i)}/ims/authorize/v2?${c}`,{createOAuthLauncher:d}=await l(async()=>{let{createOAuthLauncher:e}=await import(`./oauth-service-CczC27lE.js`);return{createOAuthLauncher:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17])),f=await d()(u,{interactive:!1});if(!f)return null;if(s&&f)try{if(new URL(f).searchParams.get(`nonce`)!==s)return console.error(`[adobe] OAuth nonce mismatch — possible CSRF`),null}catch(e){console.warn(`[adobe] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}let m=R(f);if(!m)return null;let h=I();return await p({providerId:`adobe`,accessToken:m.accessToken,tokenExpiresAt:Date.now()+m.expiresIn*1e3,userName:h?.userName,userAvatar:h?.userAvatar,baseUrl:C.proxyEndpoint?void 0:e}),console.log(`[adobe] Token renewed silently`),await $().catch(e=>console.warn(`[adobe] Failed to refresh models after silent renewal:`,e instanceof Error?e.message:String(e))),m.accessToken}catch(e){return console.warn(`[adobe] Silent renewal error:`,e instanceof Error?e.message:String(e)),null}finally{B=null}})(),B)}var G=`X-Slicc-Version`;function K(e){let t={},n=G.toLowerCase();if(e.headers)for(let[r,i]of Object.entries(e.headers))r.toLowerCase()!==n&&(t[r]=i);return t[G]=`3.48.0`,{...e,headers:t}}var ie=`adobe-provider-fallback`,q=new Set;function J(e,t){if(e.headers){for(let t of Object.keys(e.headers))if(t.toLowerCase()===`x-session-id`)return e}return q.has(t)||(q.add(t),console.warn(`[adobe] Missing X-Session-Id from ${t} — using daily fallback. Attach an X-Session-Id header at the call site (see scoop-context.ts streamWithSessionId or docs/pitfalls.md).`)),{...e,headers:{...e.headers??{},"X-Session-Id":g(ie)}}}function ae(){q.clear()}function Y(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:`adobe-anthropic`,provider:`adobe`,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}}var X=(e,t,r={})=>{let o=d();return(async()=>{try{let s=await H();if(String(e.api).includes(`openai`)){let i=n({...e,baseUrl:`${w()}/v1`,api:`openai-completions`,compat:{...e.compat,supportsStore:!1,supportsDeveloperRole:!1}},t,K(J({...r,apiKey:s},`streamAdobe[openai]`)));for await(let e of i)o.push(e)}else{let n=a({...e,baseUrl:w(),api:`anthropic-messages`},t,K(J(S(e,i(e.id,e.name,{...r,apiKey:s})),`streamAdobe[anthropic]`)));for await(let e of n)o.push(e)}o.end()}catch(t){console.error(`[adobe] Stream error:`,t instanceof Error?t.message:String(t)),o.push(Y(e,t)),o.end()}})(),o},Z=(e,t,n)=>{let a=d();return(async()=>{try{let o=await H();if(String(e.api).includes(`openai`)){let i=r({...e,baseUrl:`${w()}/v1`,api:`openai-completions`,compat:{...e.compat,supportsStore:!1,supportsDeveloperRole:!1}},t,K(J({...n,apiKey:o},`streamSimpleAdobe[openai]`)));for await(let e of i)a.push(e)}else{let r=s({...e,baseUrl:w(),api:`anthropic-messages`},t,K(J(S(e,i(e.id,e.name,{...n,apiKey:o})),`streamSimpleAdobe[anthropic]`)));for await(let e of r)a.push(e)}a.end()}catch(t){console.error(`[adobe] Stream error:`,t instanceof Error?t.message:String(t)),a.push(Y(e,t)),a.end()}})(),a};async function oe(e){try{let t=e??await H(),n=w(),r=await fetch(`${n}/v1/models`,{headers:{Authorization:`Bearer ${t}`,[G]:`3.48.0`}});if(r.ok){let e=await r.json();if(e.data?.length){for(let t of e.data){let e={id:t.id,name:t.name};t.api!==void 0&&(e.api=t.api),t.context_window!==void 0&&(e.context_window=t.context_window),t.max_tokens!==void 0&&(e.max_tokens=t.max_tokens),t.reasoning!==void 0&&(e.reasoning=t.reasoning),t.input!==void 0&&(e.input=t.input),E.set(t.id,e)}let t=new Map;for(let e of u())try{for(let n of f(e))t.set(n.id,n)}catch{}return e.data.map(e=>{let r=t.get(e.id),i=`adobe-${e.api===`openai`?`openai`:`anthropic`}`;return r?{...r,provider:`adobe`,api:i}:{id:e.id,name:e.name??e.id,provider:`adobe`,api:i,baseUrl:n,contextWindow:2e5,maxTokens:16384,input:[`text`,`image`],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},inputCost:0,outputCost:0,cacheReadCost:0,cacheWriteCost:0,reasoning:!0}})}}else console.warn(`[adobe] Proxy /v1/models returned ${r.status}, falling back to Anthropic models`)}catch(e){console.warn(`[adobe] Failed to fetch proxy models:`,e instanceof Error?e.message:String(e))}return null}var Q=new Map;function se(){return f(`anthropic`).map(e=>({...e,provider:`adobe`,api:`adobe-anthropic`}))}async function $(e){let t=w(),n=Q.get(t);if(n)return n;let r=await oe(e);return r?(Q.set(t,r),r):se()}function ce(){e({api:`adobe-anthropic`,stream:X,streamSimple:Z}),e({api:`adobe-openai`,stream:X,streamSimple:Z})}export{ae as __resetAdobeSessionIdWarningCacheForTests,z as config,$ as getAdobeModels,H as getValidAccessToken,U as isTokenExpired,ce as register};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/oauth-service-D21kFAZe.js","assets/preload-helper-zJ_50EbN.js","assets/main-8qsCPK6A.js","assets/chunk-aKtaBQYM.js","assets/modulepreload-polyfill-Dezn_h7o.js","assets/bedrock-camp-ChanTZ04.js","assets/transform-messages-B3Q-Bwv-.js","assets/json-parse-BUunmmNl.js","assets/logger-DDBAeTLF.js","assets/mime-types-B9LIwKG5.js","assets/mount-picker-popup-DncaR5N8.js","assets/path-utils-DU6QhF_k.js","assets/types-idfTVsM8.js","assets/hid-device-registry-D2LsJCRr.js","assets/picker-approval-tzbkMw-e.js","assets/tool-ui-YOPqzMmL.js","assets/clipboard-DgFtRQbq.js","assets/main-B-eXD0kW.css"])))=>i.map(i=>d[i]);
2
+ import{_ as e,a as t,d as n,h as r,i,l as a,o,p as s,s as c}from"./bedrock-camp-ChanTZ04.js";import{t as l}from"./preload-helper-zJ_50EbN.js";import{d as u,o as d,u as f}from"./transform-messages-B3Q-Bwv-.js";import{$ as p,J as m,W as h,rt as g}from"./main-8qsCPK6A.js";import{getOAuthPageOrigin as ee}from"./oauth-service-D21kFAZe.js";var _={proxyEndpoint:`https://adobe-llm-proxy.paolo-moz.workers.dev`,redirectUri:`https://www.sliccy.ai/auth/callback`,extensionRedirectUri:`https://akjjllgokmbgpbdbmafpiefnhidlmbgf.chromiumapp.org/adobe`};function v(e,n){return t(e,n)}function y(e,t,n){return e!==`xhigh`||!t?e:c(t,n)?`xhigh`:o(t,n)?`max`:`high`}function b(e,t){let n=e?t?.thinkingLevelMap?.[e]:void 0;return y((()=>{if(typeof n==`string`)return n;switch(e){case`minimal`:case`low`:return`low`;case`medium`:return`medium`;case`xhigh`:return`xhigh`;default:return`high`}})(),t?.id,t?.name)}function x(e,t){return async(n,r)=>{let i=t?await t(n,r)??n:n,a=i.thinking;return a&&a.type===`enabled`&&(i.thinking={type:`adaptive`,...a.display===void 0?{}:{display:a.display}},i.output_config={...i.output_config??{},effort:e}),i}}function S(e,t){if(!v(e.id,e.name))return t;let n=t,r=y(n.effort??b(n.reasoning,e),e.id,e.name);return{...t,onPayload:x(r,n.onPayload)}}function te(e,t){let n={id:e.id,name:e.name??e.id},r=t?.api??e.api,i=t?.context_window??e.context_window,a=t?.max_tokens??e.max_tokens,o=t?.reasoning??e.reasoning,s=t?.input??e.input;return r&&(n.api=r),i!==void 0&&(n.context_window=i),a!==void 0&&(n.max_tokens=a),o!==void 0&&(n.reasoning=o),s&&(n.input=s),/haiku/i.test(e.id)&&(n.compat={supportsEagerToolInputStreaming:!1}),n}var ne=5*6e4;function re(e=ne){let t=0;return{async run(n,r=Date.now()){if(r<t)return null;let i=null;try{i=await n()}catch(e){console.debug(`[silent-renew-backoff] renew threw:`,e instanceof Error?e.message:String(e)),i=null}return t=i?0:r+e,i},inCooldown(e=Date.now()){return e<t}}}var C=Object.assign({"/packages/webapp/providers/adobe-config.json":_})[`/packages/webapp/providers/adobe-config.json`]??{clientId:``,proxyEndpoint:``,scopes:`openid,profile,email`};function w(){let e=m(`adobe`);if(e)return e.replace(/\/$/,``);if(C.proxyEndpoint)return C.proxyEndpoint.replace(/\/$/,``);throw Error(`Adobe proxy endpoint not configured — set it in Settings or adobe-config.json`)}var T=new Map,E=new Map,D=`slicc-adobe-models`;function O(e){try{localStorage.setItem(D,JSON.stringify(e))}catch{}}async function k(e){let t=T.get(e);if(t)return t;try{let t=await fetch(`${e}/v1/config`,{headers:{[G]:`3.48.1`}});if(t.ok){let n=await t.json();return T.set(e,n),n}console.warn(`[adobe] Proxy /v1/config returned ${t.status}, falling back to build-time config`)}catch(e){console.warn(`[adobe] Failed to fetch proxy config:`,e instanceof Error?e.message:String(e))}let n={};return T.set(e,n),n}function A(e){let t=e.clientId||C.clientId;if(!t)throw Error(`Could not determine IMS client ID — proxy /v1/config did not return one and adobe-config.json is empty`);return t}function j(e){return e.scopes||C.scopes}function M(e){return e.imsEnvironment||C.imsEnvironment||`prod`}var N={prod:`https://ims-na1.adobelogin.com`,stg1:`https://ims-na1-stg1.adobelogin.com`};function P(e){return N[e??C.imsEnvironment??`prod`]??N.prod}var F=typeof chrome<`u`&&!!chrome?.runtime?.id;function I(){return h().find(e=>e.providerId===`adobe`)}async function L(e,t){try{let n=await fetch(`${P(t)}/ims/userinfo/v2`,{headers:{Authorization:`Bearer ${e}`}});if(n.ok){let e=await n.json();return{name:e.displayName||e.name||e.email,avatar:e.picture||e.avatar_url}}console.warn(`[adobe] User profile fetch returned ${n.status}, account will have no display name`)}catch(e){console.warn(`[adobe] Failed to fetch user profile:`,e instanceof Error?e.message:String(e))}return{}}function R(e){let t=e.indexOf(`#`);if(t<0)return null;let n=new URLSearchParams(e.slice(t+1)),r=n.get(`access_token`);return r?{accessToken:r,expiresIn:parseInt(n.get(`expires_in`)??`86400`,10)}:null}var z={id:`adobe`,name:`Adobe`,description:`Claude via Adobe — login with your Adobe ID`,requiresApiKey:!1,requiresBaseUrl:!C.proxyEndpoint,baseUrlPlaceholder:`https://your-proxy.example.com`,baseUrlDescription:`Anthropic-compatible proxy endpoint`,isOAuth:!0,defaultModelId:`sonnet`,oauthTokenDomains:[`ims-na1.adobelogin.com`,`ims-na1-stg1.adobelogin.com`,`*.adobelogin.com`,`*.adobe.io`,`firefall.adobe.io`,`admin.hlx.page`,`admin.hlx.live`,`admin.aem.page`,`admin.aem.live`],getModelIds:()=>{let e=e=>te(e,E.get(e.id));for(let t of Q.values())if(t.length){let n=t.map(t=>e({id:t.id,name:t.name??t.id}));return O(n),n}for(let t of T.values())if(t.models?.length)return t.models.map(t=>e(t));try{let e=localStorage.getItem(D);if(e){let t=JSON.parse(e);if(t.length)return t}}catch{}return[{id:`claude-sonnet-4-6`,name:`Claude Sonnet 4.6`}]},onOAuthLogin:async(e,t,n)=>{let r=w(),i=await k(r),a=A(i),o=j(i),s=M(i),c=F?null:await ee(),l=F?C.extensionRedirectUri??`https://${chrome.runtime.id}.chromiumapp.org/`:C.redirectUri??`${c.origin}/auth/callback`,u=F?void 0:btoa(JSON.stringify({port:parseInt(new URL(c.href).port||`5710`,10),path:`/auth/callback`,nonce:crypto.randomUUID()})),d=u?JSON.parse(atob(u)).nonce:null,f=new URLSearchParams({client_id:a,scope:o,response_type:`token`,redirect_uri:l});u&&f.set(`state`,u),n?.forceReauth&&f.set(`prompt`,`login`);let m=await e(`${P(s)}/ims/authorize/v2?${f}`);if(!m)return;if(d&&m)try{if(new URL(m).searchParams.get(`nonce`)!==d){console.error(`[adobe] OAuth nonce mismatch — possible CSRF`);return}}catch(e){console.warn(`[adobe] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}let h=R(m);if(!h){console.error(`[adobe] Could not extract token from redirect URL`);return}let g=await L(h.accessToken,s);await p({providerId:`adobe`,accessToken:h.accessToken,tokenExpiresAt:Date.now()+h.expiresIn*1e3,userName:g.name,userAvatar:g.avatar,baseUrl:C.proxyEndpoint?void 0:r}),await $().catch(e=>console.warn(`[adobe] Failed to fetch models after login:`,e instanceof Error?e.message:String(e))),t()},onOAuthLogout:async()=>{let e=I();if(e?.accessToken)try{let t=T.values().next().value??{},n=t.clientId||C.clientId,r=M(t);if(n){let t=await fetch(`${P(r)}/ims/revoke`,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:new URLSearchParams({token:e.accessToken,token_type_hint:`access_token`,client_id:n})});t.ok||console.warn(`[adobe] Token revocation returned ${t.status}, token may still be valid server-side`)}}catch(e){console.warn(`[adobe] Failed to revoke token:`,e instanceof Error?e.message:String(e))}await p({providerId:`adobe`,accessToken:``})},onSilentRenew:async()=>I()?.accessToken?W():null,refreshModels:async e=>{await $(e);let t=z.getModelIds?.();t?.length&&O(t)}},B=null,V=re();async function H(){let e=I();if(!e?.accessToken)throw Error(`Not logged in to Adobe — please log in first`);if((e.tokenExpiresAt??0)-Date.now()>6e4)return e.accessToken;console.log(`[adobe] Token expired or expiring soon, attempting silent renewal...`);let t=await V.run(()=>W());if(t)return t;let n=I();if((n?.tokenExpiresAt??0)-Date.now()>0&&n?.accessToken)return n.accessToken;throw Error(`Adobe session expired — please log in again`)}function U(){let e=I();return e?.tokenExpiresAt?Date.now()>e.tokenExpiresAt-6e4:!0}async function W(){return typeof window>`u`?null:B||(B=(async()=>{try{let e=w(),t=await k(e),n=A(t),r=j(t),i=M(t),a=F?C.extensionRedirectUri??`https://${chrome.runtime.id}.chromiumapp.org/`:C.redirectUri??`${window.location.origin}/auth/callback`,o=F?void 0:btoa(JSON.stringify({port:parseInt(new URL(window.location.href).port||`5710`,10),path:`/auth/callback`,nonce:crypto.randomUUID()})),s=o?JSON.parse(atob(o)).nonce:null,c=new URLSearchParams({client_id:n,scope:r,response_type:`token`,redirect_uri:a,prompt:`none`});o&&c.set(`state`,o);let u=`${P(i)}/ims/authorize/v2?${c}`,{createOAuthLauncher:d}=await l(async()=>{let{createOAuthLauncher:e}=await import(`./oauth-service-D21kFAZe.js`);return{createOAuthLauncher:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17])),f=await d()(u,{interactive:!1});if(!f)return null;if(s&&f)try{if(new URL(f).searchParams.get(`nonce`)!==s)return console.error(`[adobe] OAuth nonce mismatch — possible CSRF`),null}catch(e){console.warn(`[adobe] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}let m=R(f);if(!m)return null;let h=I();return await p({providerId:`adobe`,accessToken:m.accessToken,tokenExpiresAt:Date.now()+m.expiresIn*1e3,userName:h?.userName,userAvatar:h?.userAvatar,baseUrl:C.proxyEndpoint?void 0:e}),console.log(`[adobe] Token renewed silently`),await $().catch(e=>console.warn(`[adobe] Failed to refresh models after silent renewal:`,e instanceof Error?e.message:String(e))),m.accessToken}catch(e){return console.warn(`[adobe] Silent renewal error:`,e instanceof Error?e.message:String(e)),null}finally{B=null}})(),B)}var G=`X-Slicc-Version`;function K(e){let t={},n=G.toLowerCase();if(e.headers)for(let[r,i]of Object.entries(e.headers))r.toLowerCase()!==n&&(t[r]=i);return t[G]=`3.48.1`,{...e,headers:t}}var ie=`adobe-provider-fallback`,q=new Set;function J(e,t){if(e.headers){for(let t of Object.keys(e.headers))if(t.toLowerCase()===`x-session-id`)return e}return q.has(t)||(q.add(t),console.warn(`[adobe] Missing X-Session-Id from ${t} — using daily fallback. Attach an X-Session-Id header at the call site (see scoop-context.ts streamWithSessionId or docs/pitfalls.md).`)),{...e,headers:{...e.headers??{},"X-Session-Id":g(ie)}}}function ae(){q.clear()}function Y(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:`adobe-anthropic`,provider:`adobe`,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}}var X=(e,t,r={})=>{let o=d();return(async()=>{try{let s=await H();if(String(e.api).includes(`openai`)){let i=n({...e,baseUrl:`${w()}/v1`,api:`openai-completions`,compat:{...e.compat,supportsStore:!1,supportsDeveloperRole:!1}},t,K(J({...r,apiKey:s},`streamAdobe[openai]`)));for await(let e of i)o.push(e)}else{let n=a({...e,baseUrl:w(),api:`anthropic-messages`},t,K(J(S(e,i(e.id,e.name,{...r,apiKey:s})),`streamAdobe[anthropic]`)));for await(let e of n)o.push(e)}o.end()}catch(t){console.error(`[adobe] Stream error:`,t instanceof Error?t.message:String(t)),o.push(Y(e,t)),o.end()}})(),o},Z=(e,t,n)=>{let a=d();return(async()=>{try{let o=await H();if(String(e.api).includes(`openai`)){let i=r({...e,baseUrl:`${w()}/v1`,api:`openai-completions`,compat:{...e.compat,supportsStore:!1,supportsDeveloperRole:!1}},t,K(J({...n,apiKey:o},`streamSimpleAdobe[openai]`)));for await(let e of i)a.push(e)}else{let r=s({...e,baseUrl:w(),api:`anthropic-messages`},t,K(J(S(e,i(e.id,e.name,{...n,apiKey:o})),`streamSimpleAdobe[anthropic]`)));for await(let e of r)a.push(e)}a.end()}catch(t){console.error(`[adobe] Stream error:`,t instanceof Error?t.message:String(t)),a.push(Y(e,t)),a.end()}})(),a};async function oe(e){try{let t=e??await H(),n=w(),r=await fetch(`${n}/v1/models`,{headers:{Authorization:`Bearer ${t}`,[G]:`3.48.1`}});if(r.ok){let e=await r.json();if(e.data?.length){for(let t of e.data){let e={id:t.id,name:t.name};t.api!==void 0&&(e.api=t.api),t.context_window!==void 0&&(e.context_window=t.context_window),t.max_tokens!==void 0&&(e.max_tokens=t.max_tokens),t.reasoning!==void 0&&(e.reasoning=t.reasoning),t.input!==void 0&&(e.input=t.input),E.set(t.id,e)}let t=new Map;for(let e of u())try{for(let n of f(e))t.set(n.id,n)}catch{}return e.data.map(e=>{let r=t.get(e.id),i=`adobe-${e.api===`openai`?`openai`:`anthropic`}`;return r?{...r,provider:`adobe`,api:i}:{id:e.id,name:e.name??e.id,provider:`adobe`,api:i,baseUrl:n,contextWindow:2e5,maxTokens:16384,input:[`text`,`image`],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},inputCost:0,outputCost:0,cacheReadCost:0,cacheWriteCost:0,reasoning:!0}})}}else console.warn(`[adobe] Proxy /v1/models returned ${r.status}, falling back to Anthropic models`)}catch(e){console.warn(`[adobe] Failed to fetch proxy models:`,e instanceof Error?e.message:String(e))}return null}var Q=new Map;function se(){return f(`anthropic`).map(e=>({...e,provider:`adobe`,api:`adobe-anthropic`}))}async function $(e){let t=w(),n=Q.get(t);if(n)return n;let r=await oe(e);return r?(Q.set(t,r),r):se()}function ce(){e({api:`adobe-anthropic`,stream:X,streamSimple:Z}),e({api:`adobe-openai`,stream:X,streamSimple:Z})}export{ae as __resetAdobeSessionIdWarningCacheForTests,z as config,$ as getAdobeModels,H as getValidAccessToken,U as isTokenExpired,ce as register};
@@ -1 +1 @@
1
- import{t as e}from"./logger-DDBAeTLF.js";import"./main-B-7wG_p8.js";var t=e(`agent-bridge`),n=`__slicc_agent`,r=`agent-spawn-request`;function i(){let e={spawn(e){return new Promise((t,n)=>{let i=globalThis.chrome?.runtime;if(!i||typeof i.sendMessage!=`function`){n(Error(`agent: chrome.runtime.sendMessage not available`));return}let a=e=>{let r=i.lastError;if(r){n(Error(r.message??`chrome.runtime error`));return}if(e==null){n(Error(`agent: empty response from offscreen bridge`));return}let a=e;if(!a.ok){n(Error(a.error??`agent: offscreen bridge error`));return}if(!a.result){n(Error(`agent: offscreen bridge returned no result`));return}t(a.result)};try{i.sendMessage({source:`panel`,payload:{type:r,options:e}},a)}catch(e){n(e instanceof Error?e:Error(String(e)))}})}};return globalThis[n]=e,t.info(`agent bridge proxy published on globalThis.__slicc_agent`),e}export{i as publishAgentBridgeProxy};
1
+ import{t as e}from"./logger-DDBAeTLF.js";import"./main-8qsCPK6A.js";var t=e(`agent-bridge`),n=`__slicc_agent`,r=`agent-spawn-request`;function i(){let e={spawn(e){return new Promise((t,n)=>{let i=globalThis.chrome?.runtime;if(!i||typeof i.sendMessage!=`function`){n(Error(`agent: chrome.runtime.sendMessage not available`));return}let a=e=>{let r=i.lastError;if(r){n(Error(r.message??`chrome.runtime error`));return}if(e==null){n(Error(`agent: empty response from offscreen bridge`));return}let a=e;if(!a.ok){n(Error(a.error??`agent: offscreen bridge error`));return}if(!a.result){n(Error(`agent: offscreen bridge returned no result`));return}t(a.result)};try{i.sendMessage({source:`panel`,payload:{type:r,options:e}},a)}catch(e){n(e instanceof Error?e:Error(String(e)))}})}};return globalThis[n]=e,t.info(`agent bridge proxy published on globalThis.__slicc_agent`),e}export{i as publishAgentBridgeProxy};
@@ -0,0 +1,7 @@
1
+ import{S as e,b as t,x as n}from"./kernel-worker-D7phkSl5.js";const r=new Set([`webhook`,`cron`,`sprinkle`,`fswatch`,`session-reload`,`navigate`,`upgrade`,`workflow`,`scoop-notify`,`scoop-idle`,`scoop-wait`]);function i(e){return e!=null&&r.has(e)}function a(t,n={}){let{source:r=`cone`,idSeed:i=g,hiddenToolNames:a=e}=n,f=[],p=null,m=new Set;for(let e of t)l(e)?(f.push(...o(e,i)),p=null):u(e)?(p=s(e,r,i,a,m),f.push(p)):d(e)&&c(e,p,m);return f}function o(e,t){let n=f(e.content);if(n.length===0)return[];let r=[];for(let i of v(n)){if(i.body.length===0&&i.sender==null)continue;let n=i.sender?y(i.sender):null,a={id:t(),role:`user`,content:i.body,timestamp:e.timestamp};n&&(a.source=`lick`,a.channel=n),r.push(a)}return r}function s(e,t,n,r,i){let a=[];for(let t of h(e))r.has(t.name)?i.add(t.id):a.push(t);let o={id:n(),role:`assistant`,content:f(e.content),timestamp:e.timestamp,source:t};return a.length>0&&(o.toolCalls=a),o}function c(e,n,r){if(r.has(e.toolCallId))return;let i=n?.toolCalls?.find(t=>t.id===e.toolCallId);i&&(i.result=t(f(e.content)),i.isError=e.isError)}function l(e){return e.role===`user`}function u(e){return e.role===`assistant`}function d(e){return e.role===`toolResult`}function f(e){if(typeof e==`string`)return e;if(!Array.isArray(e))return``;let t=[];for(let n of e)p(n)&&t.push(n.text);return t.join(``)}function p(e){return e.type===`text`}function m(e){return e.type===`toolCall`}function h(e){if(!Array.isArray(e.content))return[];let t=[];for(let r of e.content)m(r)&&t.push({id:r.id,name:r.name,input:n(r.arguments)});return t}function g(){return Date.now().toString(36)+Math.random().toString(36).slice(2,8)}function _(e){if(!e.startsWith(`[`))return null;let t=e.indexOf(`] `);if(t<=0||e.lastIndexOf(`
2
+ `,t)!==-1)return null;let n=e.slice(t+2);if(n.startsWith(`User: `))return{sender:`User`,body:n.slice(6)};for(let e of r){let t=`${e}:`;if(!n.startsWith(t))continue;let r=n.indexOf(`
3
+ `),i=r===-1?n.length:r,a=n.slice(0,i),o=-1,s=a.indexOf(`[`,t.length);if(s>t.length&&(o=a.lastIndexOf(`: `,s)),o<t.length&&(o=n.indexOf(`: `,t.length)),!(o<0||o>=i))return{sender:n.slice(0,o),body:n.slice(o+2)}}let i=n.indexOf(`
4
+ `),a=i===-1?n.length:i,o=n.indexOf(`: `);if(o<=0||o>=a)return null;let s=n.slice(0,o);return s.includes(`
5
+ `)?null:{sender:s,body:n.slice(o+2)}}function v(e){if(e.length===0)return[];let t=e.split(`
6
+ `);if(!t[0].startsWith(`[`))return[{sender:null,body:e}];let n=[],r=null,i=()=>{if(!r)return;let e=r.rest.length>0?`${r.firstLine}\n${r.rest.join(`
7
+ `)}`:r.firstLine,t=_(e);t?n.push({sender:t.sender,body:t.body}):n.push({sender:null,body:e}),r=null};for(let e of t){if(e.startsWith(`[`)&&/^\[[^\]\n]+\] /.test(e)&&e.includes(`: `)&&_(e)){i(),r={firstLine:e,rest:[]};continue}r?r.rest.push(e):r={firstLine:e,rest:[]}}return i(),n.length===0?[{sender:null,body:e}]:n}function y(e){let t=e.indexOf(`:`);if(t<=0)return null;let n=e.slice(0,t);return i(n)?n:null}export{a as agentMessagesToChatMessages};
@@ -1,4 +1,4 @@
1
- import{t as e}from"./logger-LESFN7Hj.js";import{t}from"./types-idfTVsM8.js";import{u as n}from"./kernel-worker-D0mD7VaJ.js";const r=e(`mcp-apps`),i=`/workspace/.mcp/sprinkles`;async function a(e){if(e)return e;let{VirtualFS:t}=await import(`./fs-BAw7axTJ.js`).then(e=>e.t);return await t.create({dbName:n})}function o(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,64)||`app`}function s(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function c(e,t){let n=s(t.title??t.name),r=t.description?s(t.description):``,i=s(t.templateUri??`about:blank`),a=JSON.stringify(e),o=JSON.stringify(t.name);return`<div class="mcp-app" data-sprinkle-title="${n}" style="display:flex;flex-direction:column;height:100%;min-height:0;">
1
+ import{t as e}from"./logger-LESFN7Hj.js";import{t}from"./types-idfTVsM8.js";import{u as n}from"./kernel-worker-D7phkSl5.js";const r=e(`mcp-apps`),i=`/workspace/.mcp/sprinkles`;async function a(e){if(e)return e;let{VirtualFS:t}=await import(`./fs-Bmm-dVgS.js`).then(e=>e.t);return await t.create({dbName:n})}function o(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,64)||`app`}function s(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function c(e,t){let n=s(t.title??t.name),r=t.description?s(t.description):``,i=s(t.templateUri??`about:blank`),a=JSON.stringify(e),o=JSON.stringify(t.name);return`<div class="mcp-app" data-sprinkle-title="${n}" style="display:flex;flex-direction:column;height:100%;min-height:0;">
2
2
  <header class="mcp-app__header" style="padding:8px 12px;border-bottom:1px solid var(--s2-border-subtle,#3a3a3a);">
3
3
  <h2 style="font-size:14px;font-weight:600;margin:0;">${n}</h2>${r?`\n <p style="font-size:12px;margin:4px 0 0;color:var(--s2-content-secondary,#a0a0a0);">${r}</p>`:``}
4
4
  </header>
@@ -1 +1 @@
1
- import{a as e,r as t}from"./provider-settings-Cf_3ifG8.js";import{b as n}from"./bedrock-camp-wxdDcDkR.js";import{o as r,r as i,s as a,t as o}from"./transform-messages-C1X1O3BY.js";import{t as s}from"./openai-i4HWKCeW.js";const c=`azure-openai`,l=`2024-12-01-preview`,u={id:c,name:`Azure OpenAI`,description:`GPT models via Azure AI Foundry`,requiresApiKey:!0,apiKeyPlaceholder:`Azure API key`,apiKeyEnvVar:`AZURE_OPENAI_API_KEY`,requiresBaseUrl:!0,baseUrlPlaceholder:`https://your-resource.cognitiveservices.azure.com/`,baseUrlDescription:`Azure resource endpoint`,requiresDeployment:!0,deploymentPlaceholder:`gpt-4.1-mini, gpt-4o, o4-mini`,deploymentDescription:`Comma-separated deployment names (from Azure Portal → Deployments)`,requiresApiVersion:!0,apiVersionDefault:l,apiVersionDescription:`Azure OpenAI API version`,getModelIds:()=>{let t=e(c);if(!t)return[{id:`azure-unconfigured`,name:`Azure OpenAI (set deployments in Settings)`}];let n=t.split(`,`).map(e=>e.trim()).filter(Boolean);return n.length===0?[{id:`azure-unconfigured`,name:`Azure OpenAI (set deployments in Settings)`}]:n.map(e=>{let t=e.startsWith(`o1`)||e.startsWith(`o3`)||e.startsWith(`o4`);return{id:e,name:`${e} (Azure)`,reasoning:t,input:[`text`,`image`]}})}};function d(e){return e.replace(/[^a-zA-Z0-9_-]/g,`_`).slice(0,64)}function f(e,t){let n=o(e.messages,t,d),r=[];for(let e of n)if(e.role===`user`)if(typeof e.content==`string`)r.push({role:`user`,content:e.content});else{let t=e.content.map(e=>e.type===`text`?{type:`text`,text:e.text??``}:e.type===`image`?{type:`image_url`,image_url:{url:`data:${e.mimeType};base64,${e.data}`}}:{type:`text`,text:JSON.stringify(e)});r.push({role:`user`,content:t})}else if(e.role===`assistant`){let t=e.content,n=t.filter(e=>e.type===`text`).map(e=>e.text??``).join(``),i=t.filter(e=>e.type===`toolCall`).map(e=>({id:e.id??``,type:`function`,function:{name:e.name??``,arguments:JSON.stringify(e.arguments??{})}}));i.length?r.push({role:`assistant`,content:n||null,tool_calls:i}):r.push({role:`assistant`,content:n})}else if(e.role===`toolResult`){let t=e.content;r.push({role:`tool`,tool_call_id:e.toolCallId??``,content:t?.map(e=>e.type===`text`?e.text??``:JSON.stringify(e)).join(``)||``})}return r}function p(e){if(e?.length)return e.map(e=>({type:`function`,function:{name:e.name,description:e.description,parameters:e.parameters}}))}function m(e){let t=e.content.find(e=>e.type===`text`);if(t)return{block:t,index:e.content.indexOf(t)};let n={type:`text`,text:``};return e.content.push(n),{block:n,index:e.content.length-1}}function h(e,t){return e.content.find(e=>e.type===`toolCall`&&e.id===t)}const g=(e,n,i={})=>{let o=r();return(async()=>{let r={role:`assistant`,content:[],api:`azure-openai-anthropic`,provider:c,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:`stop`,timestamp:Date.now()};try{let u=i.apiKey;if(!u)throw Error(`Azure API key is required`);let d=e.baseUrl;if(!d)throw Error(`Azure endpoint is required`);let g=e.id,_={};e.headers&&Object.assign(_,e.headers),i.headers&&Object.assign(_,i.headers);let v=t(c)||l,y=new s({endpoint:d.replace(/\/+$/,``),apiKey:u,deployment:g,apiVersion:v,dangerouslyAllowBrowser:!0,defaultHeaders:_}),b=[...n.systemPrompt?[{role:`system`,content:n.systemPrompt}]:[],...f(n,e)],x=p(n.tools),S=await y.chat.completions.create({model:g,messages:b,stream:!0,stream_options:{include_usage:!0},...i.maxTokens?{max_completion_tokens:i.maxTokens}:{},...i.temperature===void 0?{}:{temperature:i.temperature},...x?{tools:x}:{}});o.push({type:`start`,partial:r});for await(let t of S){t.usage&&(r.usage.input=t.usage.prompt_tokens??0,r.usage.output=t.usage.completion_tokens??0,r.usage.totalTokens=t.usage.total_tokens??0,a(e,r.usage));for(let e of t.choices??[]){let t=e.delta;if(t){if(t.content){let{block:e,index:n}=m(r);e.text===``&&o.push({type:`text_start`,contentIndex:n,partial:r}),e.text+=t.content,o.push({type:`text_delta`,contentIndex:n,delta:t.content,partial:r})}if(t.tool_calls)for(let e of t.tool_calls){let t=e.id?h(r,e.id):void 0;if(!t&&e.id&&(t={type:`toolCall`,id:e.id,name:e.function?.name??``,arguments:{},_partialJson:``},r.content.push(t),o.push({type:`toolcall_start`,contentIndex:r.content.length-1,partial:r})),t&&e.function?.arguments){t._partialJson+=e.function.arguments;try{t.arguments=JSON.parse(t._partialJson)}catch{}o.push({type:`toolcall_delta`,contentIndex:r.content.indexOf(t),delta:e.function.arguments,partial:r})}}e.finish_reason&&(r.stopReason=e.finish_reason===`tool_calls`?`toolUse`:e.finish_reason===`length`?`length`:`stop`)}}}for(let e of r.content){let t=r.content.indexOf(e);if(e.type===`toolCall`){let n=e;try{n.arguments=JSON.parse(n._partialJson||`{}`)}catch{}delete n._partialJson,o.push({type:`toolcall_end`,contentIndex:t,toolCall:e,partial:r})}else e.type===`text`&&o.push({type:`text_end`,contentIndex:t,content:e.text,partial:r})}o.push({type:`done`,reason:r.stopReason,message:r}),o.end()}catch(e){r.stopReason=i.signal?.aborted?`aborted`:`error`,r.errorMessage=e instanceof Error?e.message:JSON.stringify(e),o.push({type:`error`,reason:r.stopReason,error:r}),o.end()}})(),o},_=(e,t,n)=>{let r=n?.apiKey;if(!r)throw Error(`Azure API key is required`);return g(e,t,{...i(e,n,r)})};function v(){n({api:`azure-openai-anthropic`,stream:g,streamSimple:_})}export{u as config,v as register};
1
+ import{a as e,r as t}from"./provider-settings-BSNYuaP_.js";import{b as n}from"./bedrock-camp-wxdDcDkR.js";import{o as r,r as i,s as a,t as o}from"./transform-messages-C1X1O3BY.js";import{t as s}from"./openai-i4HWKCeW.js";const c=`azure-openai`,l=`2024-12-01-preview`,u={id:c,name:`Azure OpenAI`,description:`GPT models via Azure AI Foundry`,requiresApiKey:!0,apiKeyPlaceholder:`Azure API key`,apiKeyEnvVar:`AZURE_OPENAI_API_KEY`,requiresBaseUrl:!0,baseUrlPlaceholder:`https://your-resource.cognitiveservices.azure.com/`,baseUrlDescription:`Azure resource endpoint`,requiresDeployment:!0,deploymentPlaceholder:`gpt-4.1-mini, gpt-4o, o4-mini`,deploymentDescription:`Comma-separated deployment names (from Azure Portal → Deployments)`,requiresApiVersion:!0,apiVersionDefault:l,apiVersionDescription:`Azure OpenAI API version`,getModelIds:()=>{let t=e(c);if(!t)return[{id:`azure-unconfigured`,name:`Azure OpenAI (set deployments in Settings)`}];let n=t.split(`,`).map(e=>e.trim()).filter(Boolean);return n.length===0?[{id:`azure-unconfigured`,name:`Azure OpenAI (set deployments in Settings)`}]:n.map(e=>{let t=e.startsWith(`o1`)||e.startsWith(`o3`)||e.startsWith(`o4`);return{id:e,name:`${e} (Azure)`,reasoning:t,input:[`text`,`image`]}})}};function d(e){return e.replace(/[^a-zA-Z0-9_-]/g,`_`).slice(0,64)}function f(e,t){let n=o(e.messages,t,d),r=[];for(let e of n)if(e.role===`user`)if(typeof e.content==`string`)r.push({role:`user`,content:e.content});else{let t=e.content.map(e=>e.type===`text`?{type:`text`,text:e.text??``}:e.type===`image`?{type:`image_url`,image_url:{url:`data:${e.mimeType};base64,${e.data}`}}:{type:`text`,text:JSON.stringify(e)});r.push({role:`user`,content:t})}else if(e.role===`assistant`){let t=e.content,n=t.filter(e=>e.type===`text`).map(e=>e.text??``).join(``),i=t.filter(e=>e.type===`toolCall`).map(e=>({id:e.id??``,type:`function`,function:{name:e.name??``,arguments:JSON.stringify(e.arguments??{})}}));i.length?r.push({role:`assistant`,content:n||null,tool_calls:i}):r.push({role:`assistant`,content:n})}else if(e.role===`toolResult`){let t=e.content;r.push({role:`tool`,tool_call_id:e.toolCallId??``,content:t?.map(e=>e.type===`text`?e.text??``:JSON.stringify(e)).join(``)||``})}return r}function p(e){if(e?.length)return e.map(e=>({type:`function`,function:{name:e.name,description:e.description,parameters:e.parameters}}))}function m(e){let t=e.content.find(e=>e.type===`text`);if(t)return{block:t,index:e.content.indexOf(t)};let n={type:`text`,text:``};return e.content.push(n),{block:n,index:e.content.length-1}}function h(e,t){return e.content.find(e=>e.type===`toolCall`&&e.id===t)}const g=(e,n,i={})=>{let o=r();return(async()=>{let r={role:`assistant`,content:[],api:`azure-openai-anthropic`,provider:c,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:`stop`,timestamp:Date.now()};try{let u=i.apiKey;if(!u)throw Error(`Azure API key is required`);let d=e.baseUrl;if(!d)throw Error(`Azure endpoint is required`);let g=e.id,_={};e.headers&&Object.assign(_,e.headers),i.headers&&Object.assign(_,i.headers);let v=t(c)||l,y=new s({endpoint:d.replace(/\/+$/,``),apiKey:u,deployment:g,apiVersion:v,dangerouslyAllowBrowser:!0,defaultHeaders:_}),b=[...n.systemPrompt?[{role:`system`,content:n.systemPrompt}]:[],...f(n,e)],x=p(n.tools),S=await y.chat.completions.create({model:g,messages:b,stream:!0,stream_options:{include_usage:!0},...i.maxTokens?{max_completion_tokens:i.maxTokens}:{},...i.temperature===void 0?{}:{temperature:i.temperature},...x?{tools:x}:{}});o.push({type:`start`,partial:r});for await(let t of S){t.usage&&(r.usage.input=t.usage.prompt_tokens??0,r.usage.output=t.usage.completion_tokens??0,r.usage.totalTokens=t.usage.total_tokens??0,a(e,r.usage));for(let e of t.choices??[]){let t=e.delta;if(t){if(t.content){let{block:e,index:n}=m(r);e.text===``&&o.push({type:`text_start`,contentIndex:n,partial:r}),e.text+=t.content,o.push({type:`text_delta`,contentIndex:n,delta:t.content,partial:r})}if(t.tool_calls)for(let e of t.tool_calls){let t=e.id?h(r,e.id):void 0;if(!t&&e.id&&(t={type:`toolCall`,id:e.id,name:e.function?.name??``,arguments:{},_partialJson:``},r.content.push(t),o.push({type:`toolcall_start`,contentIndex:r.content.length-1,partial:r})),t&&e.function?.arguments){t._partialJson+=e.function.arguments;try{t.arguments=JSON.parse(t._partialJson)}catch{}o.push({type:`toolcall_delta`,contentIndex:r.content.indexOf(t),delta:e.function.arguments,partial:r})}}e.finish_reason&&(r.stopReason=e.finish_reason===`tool_calls`?`toolUse`:e.finish_reason===`length`?`length`:`stop`)}}}for(let e of r.content){let t=r.content.indexOf(e);if(e.type===`toolCall`){let n=e;try{n.arguments=JSON.parse(n._partialJson||`{}`)}catch{}delete n._partialJson,o.push({type:`toolcall_end`,contentIndex:t,toolCall:e,partial:r})}else e.type===`text`&&o.push({type:`text_end`,contentIndex:t,content:e.text,partial:r})}o.push({type:`done`,reason:r.stopReason,message:r}),o.end()}catch(e){r.stopReason=i.signal?.aborted?`aborted`:`error`,r.errorMessage=e instanceof Error?e.message:JSON.stringify(e),o.push({type:`error`,reason:r.stopReason,error:r}),o.end()}})(),o},_=(e,t,n)=>{let r=n?.apiKey;if(!r)throw Error(`Azure API key is required`);return g(e,t,{...i(e,n,r)})};function v(){n({api:`azure-openai-anthropic`,stream:g,streamSimple:_})}export{u as config,v as register};
@@ -1 +1 @@
1
- import{_ as e}from"./bedrock-camp-ChanTZ04.js";import{o as t,r as n,s as r,t as i}from"./transform-messages-B3Q-Bwv-.js";import{Y as a,q as o}from"./main-B-7wG_p8.js";import{t as s}from"./openai-Cn5LRPCm.js";var c=`azure-openai`,l=`2024-12-01-preview`,u={id:c,name:`Azure OpenAI`,description:`GPT models via Azure AI Foundry`,requiresApiKey:!0,apiKeyPlaceholder:`Azure API key`,apiKeyEnvVar:`AZURE_OPENAI_API_KEY`,requiresBaseUrl:!0,baseUrlPlaceholder:`https://your-resource.cognitiveservices.azure.com/`,baseUrlDescription:`Azure resource endpoint`,requiresDeployment:!0,deploymentPlaceholder:`gpt-4.1-mini, gpt-4o, o4-mini`,deploymentDescription:`Comma-separated deployment names (from Azure Portal → Deployments)`,requiresApiVersion:!0,apiVersionDefault:l,apiVersionDescription:`Azure OpenAI API version`,getModelIds:()=>{let e=a(c);if(!e)return[{id:`azure-unconfigured`,name:`Azure OpenAI (set deployments in Settings)`}];let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);return t.length===0?[{id:`azure-unconfigured`,name:`Azure OpenAI (set deployments in Settings)`}]:t.map(e=>{let t=e.startsWith(`o1`)||e.startsWith(`o3`)||e.startsWith(`o4`);return{id:e,name:`${e} (Azure)`,reasoning:t,input:[`text`,`image`]}})}};function d(e){return e.replace(/[^a-zA-Z0-9_-]/g,`_`).slice(0,64)}function f(e,t){let n=i(e.messages,t,d),r=[];for(let e of n)if(e.role===`user`)if(typeof e.content==`string`)r.push({role:`user`,content:e.content});else{let t=e.content.map(e=>e.type===`text`?{type:`text`,text:e.text??``}:e.type===`image`?{type:`image_url`,image_url:{url:`data:${e.mimeType};base64,${e.data}`}}:{type:`text`,text:JSON.stringify(e)});r.push({role:`user`,content:t})}else if(e.role===`assistant`){let t=e.content,n=t.filter(e=>e.type===`text`).map(e=>e.text??``).join(``),i=t.filter(e=>e.type===`toolCall`).map(e=>({id:e.id??``,type:`function`,function:{name:e.name??``,arguments:JSON.stringify(e.arguments??{})}}));i.length?r.push({role:`assistant`,content:n||null,tool_calls:i}):r.push({role:`assistant`,content:n})}else if(e.role===`toolResult`){let t=e.content;r.push({role:`tool`,tool_call_id:e.toolCallId??``,content:t?.map(e=>e.type===`text`?e.text??``:JSON.stringify(e)).join(``)||``})}return r}function p(e){if(e?.length)return e.map(e=>({type:`function`,function:{name:e.name,description:e.description,parameters:e.parameters}}))}function m(e){let t=e.content.find(e=>e.type===`text`);if(t)return{block:t,index:e.content.indexOf(t)};let n={type:`text`,text:``};return e.content.push(n),{block:n,index:e.content.length-1}}function h(e,t){return e.content.find(e=>e.type===`toolCall`&&e.id===t)}var g=(e,n,i={})=>{let a=t();return(async()=>{let t={role:`assistant`,content:[],api:`azure-openai-anthropic`,provider:c,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:`stop`,timestamp:Date.now()};try{let u=i.apiKey;if(!u)throw Error(`Azure API key is required`);let d=e.baseUrl;if(!d)throw Error(`Azure endpoint is required`);let g=e.id,_={};e.headers&&Object.assign(_,e.headers),i.headers&&Object.assign(_,i.headers);let v=o(c)||l,y=new s({endpoint:d.replace(/\/+$/,``),apiKey:u,deployment:g,apiVersion:v,dangerouslyAllowBrowser:!0,defaultHeaders:_}),b=[...n.systemPrompt?[{role:`system`,content:n.systemPrompt}]:[],...f(n,e)],x=p(n.tools),S=await y.chat.completions.create({model:g,messages:b,stream:!0,stream_options:{include_usage:!0},...i.maxTokens?{max_completion_tokens:i.maxTokens}:{},...i.temperature===void 0?{}:{temperature:i.temperature},...x?{tools:x}:{}});a.push({type:`start`,partial:t});for await(let n of S){n.usage&&(t.usage.input=n.usage.prompt_tokens??0,t.usage.output=n.usage.completion_tokens??0,t.usage.totalTokens=n.usage.total_tokens??0,r(e,t.usage));for(let e of n.choices??[]){let n=e.delta;if(n){if(n.content){let{block:e,index:r}=m(t);e.text===``&&a.push({type:`text_start`,contentIndex:r,partial:t}),e.text+=n.content,a.push({type:`text_delta`,contentIndex:r,delta:n.content,partial:t})}if(n.tool_calls)for(let e of n.tool_calls){let n=e.id?h(t,e.id):void 0;if(!n&&e.id&&(n={type:`toolCall`,id:e.id,name:e.function?.name??``,arguments:{},_partialJson:``},t.content.push(n),a.push({type:`toolcall_start`,contentIndex:t.content.length-1,partial:t})),n&&e.function?.arguments){n._partialJson+=e.function.arguments;try{n.arguments=JSON.parse(n._partialJson)}catch{}a.push({type:`toolcall_delta`,contentIndex:t.content.indexOf(n),delta:e.function.arguments,partial:t})}}e.finish_reason&&(t.stopReason=e.finish_reason===`tool_calls`?`toolUse`:e.finish_reason===`length`?`length`:`stop`)}}}for(let e of t.content){let n=t.content.indexOf(e);if(e.type===`toolCall`){let r=e;try{r.arguments=JSON.parse(r._partialJson||`{}`)}catch{}delete r._partialJson,a.push({type:`toolcall_end`,contentIndex:n,toolCall:e,partial:t})}else e.type===`text`&&a.push({type:`text_end`,contentIndex:n,content:e.text,partial:t})}a.push({type:`done`,reason:t.stopReason,message:t}),a.end()}catch(e){t.stopReason=i.signal?.aborted?`aborted`:`error`,t.errorMessage=e instanceof Error?e.message:JSON.stringify(e),a.push({type:`error`,reason:t.stopReason,error:t}),a.end()}})(),a},_=(e,t,r)=>{let i=r?.apiKey;if(!i)throw Error(`Azure API key is required`);return g(e,t,{...n(e,r,i)})};function v(){e({api:`azure-openai-anthropic`,stream:g,streamSimple:_})}export{u as config,v as register};
1
+ import{_ as e}from"./bedrock-camp-ChanTZ04.js";import{o as t,r as n,s as r,t as i}from"./transform-messages-B3Q-Bwv-.js";import{Y as a,q as o}from"./main-8qsCPK6A.js";import{t as s}from"./openai-Cn5LRPCm.js";var c=`azure-openai`,l=`2024-12-01-preview`,u={id:c,name:`Azure OpenAI`,description:`GPT models via Azure AI Foundry`,requiresApiKey:!0,apiKeyPlaceholder:`Azure API key`,apiKeyEnvVar:`AZURE_OPENAI_API_KEY`,requiresBaseUrl:!0,baseUrlPlaceholder:`https://your-resource.cognitiveservices.azure.com/`,baseUrlDescription:`Azure resource endpoint`,requiresDeployment:!0,deploymentPlaceholder:`gpt-4.1-mini, gpt-4o, o4-mini`,deploymentDescription:`Comma-separated deployment names (from Azure Portal → Deployments)`,requiresApiVersion:!0,apiVersionDefault:l,apiVersionDescription:`Azure OpenAI API version`,getModelIds:()=>{let e=a(c);if(!e)return[{id:`azure-unconfigured`,name:`Azure OpenAI (set deployments in Settings)`}];let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);return t.length===0?[{id:`azure-unconfigured`,name:`Azure OpenAI (set deployments in Settings)`}]:t.map(e=>{let t=e.startsWith(`o1`)||e.startsWith(`o3`)||e.startsWith(`o4`);return{id:e,name:`${e} (Azure)`,reasoning:t,input:[`text`,`image`]}})}};function d(e){return e.replace(/[^a-zA-Z0-9_-]/g,`_`).slice(0,64)}function f(e,t){let n=i(e.messages,t,d),r=[];for(let e of n)if(e.role===`user`)if(typeof e.content==`string`)r.push({role:`user`,content:e.content});else{let t=e.content.map(e=>e.type===`text`?{type:`text`,text:e.text??``}:e.type===`image`?{type:`image_url`,image_url:{url:`data:${e.mimeType};base64,${e.data}`}}:{type:`text`,text:JSON.stringify(e)});r.push({role:`user`,content:t})}else if(e.role===`assistant`){let t=e.content,n=t.filter(e=>e.type===`text`).map(e=>e.text??``).join(``),i=t.filter(e=>e.type===`toolCall`).map(e=>({id:e.id??``,type:`function`,function:{name:e.name??``,arguments:JSON.stringify(e.arguments??{})}}));i.length?r.push({role:`assistant`,content:n||null,tool_calls:i}):r.push({role:`assistant`,content:n})}else if(e.role===`toolResult`){let t=e.content;r.push({role:`tool`,tool_call_id:e.toolCallId??``,content:t?.map(e=>e.type===`text`?e.text??``:JSON.stringify(e)).join(``)||``})}return r}function p(e){if(e?.length)return e.map(e=>({type:`function`,function:{name:e.name,description:e.description,parameters:e.parameters}}))}function m(e){let t=e.content.find(e=>e.type===`text`);if(t)return{block:t,index:e.content.indexOf(t)};let n={type:`text`,text:``};return e.content.push(n),{block:n,index:e.content.length-1}}function h(e,t){return e.content.find(e=>e.type===`toolCall`&&e.id===t)}var g=(e,n,i={})=>{let a=t();return(async()=>{let t={role:`assistant`,content:[],api:`azure-openai-anthropic`,provider:c,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:`stop`,timestamp:Date.now()};try{let u=i.apiKey;if(!u)throw Error(`Azure API key is required`);let d=e.baseUrl;if(!d)throw Error(`Azure endpoint is required`);let g=e.id,_={};e.headers&&Object.assign(_,e.headers),i.headers&&Object.assign(_,i.headers);let v=o(c)||l,y=new s({endpoint:d.replace(/\/+$/,``),apiKey:u,deployment:g,apiVersion:v,dangerouslyAllowBrowser:!0,defaultHeaders:_}),b=[...n.systemPrompt?[{role:`system`,content:n.systemPrompt}]:[],...f(n,e)],x=p(n.tools),S=await y.chat.completions.create({model:g,messages:b,stream:!0,stream_options:{include_usage:!0},...i.maxTokens?{max_completion_tokens:i.maxTokens}:{},...i.temperature===void 0?{}:{temperature:i.temperature},...x?{tools:x}:{}});a.push({type:`start`,partial:t});for await(let n of S){n.usage&&(t.usage.input=n.usage.prompt_tokens??0,t.usage.output=n.usage.completion_tokens??0,t.usage.totalTokens=n.usage.total_tokens??0,r(e,t.usage));for(let e of n.choices??[]){let n=e.delta;if(n){if(n.content){let{block:e,index:r}=m(t);e.text===``&&a.push({type:`text_start`,contentIndex:r,partial:t}),e.text+=n.content,a.push({type:`text_delta`,contentIndex:r,delta:n.content,partial:t})}if(n.tool_calls)for(let e of n.tool_calls){let n=e.id?h(t,e.id):void 0;if(!n&&e.id&&(n={type:`toolCall`,id:e.id,name:e.function?.name??``,arguments:{},_partialJson:``},t.content.push(n),a.push({type:`toolcall_start`,contentIndex:t.content.length-1,partial:t})),n&&e.function?.arguments){n._partialJson+=e.function.arguments;try{n.arguments=JSON.parse(n._partialJson)}catch{}a.push({type:`toolcall_delta`,contentIndex:t.content.indexOf(n),delta:e.function.arguments,partial:t})}}e.finish_reason&&(t.stopReason=e.finish_reason===`tool_calls`?`toolUse`:e.finish_reason===`length`?`length`:`stop`)}}}for(let e of t.content){let n=t.content.indexOf(e);if(e.type===`toolCall`){let r=e;try{r.arguments=JSON.parse(r._partialJson||`{}`)}catch{}delete r._partialJson,a.push({type:`toolcall_end`,contentIndex:n,toolCall:e,partial:t})}else e.type===`text`&&a.push({type:`text_end`,contentIndex:n,content:e.text,partial:t})}a.push({type:`done`,reason:t.stopReason,message:t}),a.end()}catch(e){t.stopReason=i.signal?.aborted?`aborted`:`error`,t.errorMessage=e instanceof Error?e.message:JSON.stringify(e),a.push({type:`error`,reason:t.stopReason,error:t}),a.end()}})(),a},_=(e,t,r)=>{let i=r?.apiKey;if(!i)throw Error(`Azure API key is required`);return g(e,t,{...n(e,r,i)})};function v(){e({api:`azure-openai-anthropic`,stream:g,streamSimple:_})}export{u as config,v as register};
@@ -1,4 +1,4 @@
1
- import{t as e}from"./logger-LESFN7Hj.js";import{c as t}from"./kernel-worker-D0mD7VaJ.js";const n=t(``).toString(),r=e(`bsh-watchdog`);var i=class{transport;browserAPI;fs;scriptCatalog;running=!1;executing=new Set;constructor(e){if(!e.transport&&!e.browserAPI)throw Error(`BshWatchdog requires either transport or browserAPI`);if(!e.scriptCatalog)throw Error(`BshWatchdog requires a ScriptCatalog`);this.browserAPI=e.browserAPI,this.transport=e.transport??e.browserAPI.getTransport(),this.fs=e.fs,this.scriptCatalog=e.scriptCatalog}async start(){if(this.running)return;this.running=!0,this.transport.on(`Page.frameNavigated`,this.onFrameNavigated),this.browserAPI&&this.browserAPI.setSessionChangeCallback((e,t)=>{t!==this.transport&&this.setTransport(t)});let e;try{e=(await this.scriptCatalog.getBshEntries()).length}catch(e){r.warn(`BSH watchdog startup discovery failed`,{error:e instanceof Error?e.message:String(e)})}r.info(`BSH watchdog started`,e===void 0?void 0:{scriptCount:e})}stop(){this.running&&(this.running=!1,this.transport.off(`Page.frameNavigated`,this.onFrameNavigated),this.browserAPI&&this.browserAPI.setSessionChangeCallback(void 0),this.executing.clear(),r.info(`BSH watchdog stopped`))}setTransport(e){e!==this.transport&&(this.transport.off(`Page.frameNavigated`,this.onFrameNavigated),this.transport=e,this.running&&this.transport.on(`Page.frameNavigated`,this.onFrameNavigated),r.info(`BSH watchdog transport swapped`))}async discover(){this.scriptCatalog.invalidateBsh(),await this.scriptCatalog.getBshEntries()}async getEntries(){return this.scriptCatalog.getBshEntries()}onFrameNavigated=e=>{let t=e.frame;if(t?.parentId||!t?.url)return;let n=t.url,i=e.sessionId;if(!(!n.startsWith(`http://`)&&!n.startsWith(`https://`))){if(!i){r.warn(`BSH watchdog: no sessionId in Page.frameNavigated params, skipping`,{url:n});return}this.scriptCatalog.findMatchingBshScripts(n).then(e=>{if(e.length!==0)for(let t of e){let e=`${t.path}::${n}`;this.executing.has(e)||(this.executing.add(e),r.info(`BSH watchdog executing script`,{script:t.path,url:n}),this.executeInTargetPage(t.path,n,i).then(()=>{r.info(`BSH script completed`,{script:t.path,url:n})}).catch(e=>{r.error(`BSH script execution error`,{script:t.path,url:n,error:e instanceof Error?e.message:String(e)})}).finally(()=>{this.executing.delete(e)}))}}).catch(e=>{r.error(`BSH discovery failed`,{url:n,error:e instanceof Error?e.message:String(e)})})}};async executeInTargetPage(e,t,i){let a=await this.fs.readFile(e),o=typeof a==`string`?a:new TextDecoder().decode(a),s=`(async () => {
1
+ import{t as e}from"./logger-LESFN7Hj.js";import{c as t}from"./kernel-worker-D7phkSl5.js";const n=t(``).toString(),r=e(`bsh-watchdog`);var i=class{transport;browserAPI;fs;scriptCatalog;running=!1;executing=new Set;constructor(e){if(!e.transport&&!e.browserAPI)throw Error(`BshWatchdog requires either transport or browserAPI`);if(!e.scriptCatalog)throw Error(`BshWatchdog requires a ScriptCatalog`);this.browserAPI=e.browserAPI,this.transport=e.transport??e.browserAPI.getTransport(),this.fs=e.fs,this.scriptCatalog=e.scriptCatalog}async start(){if(this.running)return;this.running=!0,this.transport.on(`Page.frameNavigated`,this.onFrameNavigated),this.browserAPI&&this.browserAPI.setSessionChangeCallback((e,t)=>{t!==this.transport&&this.setTransport(t)});let e;try{e=(await this.scriptCatalog.getBshEntries()).length}catch(e){r.warn(`BSH watchdog startup discovery failed`,{error:e instanceof Error?e.message:String(e)})}r.info(`BSH watchdog started`,e===void 0?void 0:{scriptCount:e})}stop(){this.running&&(this.running=!1,this.transport.off(`Page.frameNavigated`,this.onFrameNavigated),this.browserAPI&&this.browserAPI.setSessionChangeCallback(void 0),this.executing.clear(),r.info(`BSH watchdog stopped`))}setTransport(e){e!==this.transport&&(this.transport.off(`Page.frameNavigated`,this.onFrameNavigated),this.transport=e,this.running&&this.transport.on(`Page.frameNavigated`,this.onFrameNavigated),r.info(`BSH watchdog transport swapped`))}async discover(){this.scriptCatalog.invalidateBsh(),await this.scriptCatalog.getBshEntries()}async getEntries(){return this.scriptCatalog.getBshEntries()}onFrameNavigated=e=>{let t=e.frame;if(t?.parentId||!t?.url)return;let n=t.url,i=e.sessionId;if(!(!n.startsWith(`http://`)&&!n.startsWith(`https://`))){if(!i){r.warn(`BSH watchdog: no sessionId in Page.frameNavigated params, skipping`,{url:n});return}this.scriptCatalog.findMatchingBshScripts(n).then(e=>{if(e.length!==0)for(let t of e){let e=`${t.path}::${n}`;this.executing.has(e)||(this.executing.add(e),r.info(`BSH watchdog executing script`,{script:t.path,url:n}),this.executeInTargetPage(t.path,n,i).then(()=>{r.info(`BSH script completed`,{script:t.path,url:n})}).catch(e=>{r.error(`BSH script execution error`,{script:t.path,url:n,error:e instanceof Error?e.message:String(e)})}).finally(()=>{this.executing.delete(e)}))}}).catch(e=>{r.error(`BSH discovery failed`,{url:n,error:e instanceof Error?e.message:String(e)})})}};async executeInTargetPage(e,t,i){let a=await this.fs.readFile(e),o=typeof a==`string`?a:new TextDecoder().decode(a),s=`(async () => {
2
2
  const __requireSpecifiers = (function() {
3
3
  const re = /require\\s*\\(\\s*['"]([^'"]+)['"]\\s*\\)/g;
4
4
  const code = ${JSON.stringify(o)};
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/magick-wasm-B59SHUdz.js","assets/preload-helper-zJ_50EbN.js","assets/main-B-7wG_p8.js","assets/chunk-aKtaBQYM.js","assets/modulepreload-polyfill-Dezn_h7o.js","assets/bedrock-camp-ChanTZ04.js","assets/transform-messages-B3Q-Bwv-.js","assets/json-parse-BUunmmNl.js","assets/logger-DDBAeTLF.js","assets/mime-types-B9LIwKG5.js","assets/mount-picker-popup-DncaR5N8.js","assets/path-utils-DU6QhF_k.js","assets/types-idfTVsM8.js","assets/hid-device-registry-D2LsJCRr.js","assets/picker-approval-tzbkMw-e.js","assets/tool-ui-YOPqzMmL.js","assets/clipboard-DgFtRQbq.js","assets/main-B-eXD0kW.css"])))=>i.map(i=>d[i]);
2
- import{t as e}from"./preload-helper-zJ_50EbN.js";import{t}from"./logger-DDBAeTLF.js";import"./main-B-7wG_p8.js";var n=t(`cdp`),r=class{ws=null;nextId=1;pending=new Map;listeners=new Map;_state=`disconnected`;get state(){return this._state}async connect(e){if(this._state!==`disconnected`)throw Error(`Cannot connect: state is ${this._state}`);if(!e?.url)throw Error(`CDPClient.connect() requires a WebSocket URL`);let{url:t,timeout:r=5e3}=e;return this._state=`connecting`,new Promise((e,i)=>{let a=setTimeout(()=>{this.cleanup(),i(Error(`CDP connection timed out after ${r}ms`))},r);try{this.ws=new WebSocket(t)}catch(e){clearTimeout(a),this._state=`disconnected`,i(e);return}this.ws.onopen=()=>{clearTimeout(a),this._state=`connected`,n.info(`Connected`,{url:t}),e()},this.ws.onerror=e=>{clearTimeout(a),this._state===`connecting`&&(n.error(`Connection failed`,{url:t}),this.cleanup(),i(Error(`CDP WebSocket connection failed`)))},this.ws.onmessage=e=>{this.handleMessage(e.data)},this.ws.onclose=()=>{this.handleClose()}})}disconnect(){this.ws&&(this.ws.onclose=null,this.ws.close()),this.cleanup(),n.info(`Disconnected`)}async send(e,t,r,i=3e4){if(this._state!==`connected`||!this.ws)throw Error(`CDP client is not connected`);let a=this.nextId++,o={id:a,method:e};return t&&(o.params=t),r&&(o.sessionId=r),n.debug(`Send`,{method:e,id:a,sessionId:r}),new Promise((t,n)=>{let r=setTimeout(()=>{this.pending.delete(a),n(Error(`CDP command timed out after ${i}ms: ${e}`))},i);this.pending.set(a,{resolve:e=>{clearTimeout(r),t(e)},reject:e=>{clearTimeout(r),n(e)}}),this.ws.send(JSON.stringify(o))})}on(e,t){let n=this.listeners.get(e);n||(n=new Set,this.listeners.set(e,n)),n.add(t)}off(e,t){let n=this.listeners.get(e);n&&(n.delete(t),n.size===0&&this.listeners.delete(e))}once(e,t=3e4){return new Promise((n,r)=>{let i=setTimeout(()=>{this.off(e,a),r(Error(`Timed out waiting for event: ${e}`))},t),a=t=>{clearTimeout(i),this.off(e,a),n(t)};this.on(e,a)})}handleMessage(e){let t;try{t=JSON.parse(e)}catch{return}if(`id`in t&&typeof t.id==`number`){let e=t;n.debug(`Response`,{id:e.id,hasError:!!e.error});let r=this.pending.get(e.id);r&&(this.pending.delete(e.id),e.error?(n.error(`Command error`,{id:e.id,code:e.error.code,message:e.error.message}),r.reject(Error(`CDP error: ${e.error.message} (${e.error.code})`))):r.resolve(e.result??{}));return}if(`method`in t){let e=t;n.debug(`Event`,{method:e.method,sessionId:e.sessionId});let r=this.listeners.get(e.method);if(r){let t=e.sessionId?{...e.params,sessionId:e.sessionId}:e.params??{};for(let e of r)try{e(t)}catch{}}}}handleClose(){n.error(`Connection closed unexpectedly`,{pendingCommands:this.pending.size});for(let[,e]of this.pending)e.reject(Error(`CDP connection closed`));this.cleanup()}cleanup(){this.ws=null,this._state=`disconnected`,this.pending.clear()}},i=`(function() {
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/magick-wasm-BSSrd2Q9.js","assets/preload-helper-zJ_50EbN.js","assets/main-8qsCPK6A.js","assets/chunk-aKtaBQYM.js","assets/modulepreload-polyfill-Dezn_h7o.js","assets/bedrock-camp-ChanTZ04.js","assets/transform-messages-B3Q-Bwv-.js","assets/json-parse-BUunmmNl.js","assets/logger-DDBAeTLF.js","assets/mime-types-B9LIwKG5.js","assets/mount-picker-popup-DncaR5N8.js","assets/path-utils-DU6QhF_k.js","assets/types-idfTVsM8.js","assets/hid-device-registry-D2LsJCRr.js","assets/picker-approval-tzbkMw-e.js","assets/tool-ui-YOPqzMmL.js","assets/clipboard-DgFtRQbq.js","assets/main-B-eXD0kW.css"])))=>i.map(i=>d[i]);
2
+ import{t as e}from"./preload-helper-zJ_50EbN.js";import{t}from"./logger-DDBAeTLF.js";import"./main-8qsCPK6A.js";var n=t(`cdp`),r=class{ws=null;nextId=1;pending=new Map;listeners=new Map;_state=`disconnected`;get state(){return this._state}async connect(e){if(this._state!==`disconnected`)throw Error(`Cannot connect: state is ${this._state}`);if(!e?.url)throw Error(`CDPClient.connect() requires a WebSocket URL`);let{url:t,timeout:r=5e3}=e;return this._state=`connecting`,new Promise((e,i)=>{let a=setTimeout(()=>{this.cleanup(),i(Error(`CDP connection timed out after ${r}ms`))},r);try{this.ws=new WebSocket(t)}catch(e){clearTimeout(a),this._state=`disconnected`,i(e);return}this.ws.onopen=()=>{clearTimeout(a),this._state=`connected`,n.info(`Connected`,{url:t}),e()},this.ws.onerror=e=>{clearTimeout(a),this._state===`connecting`&&(n.error(`Connection failed`,{url:t}),this.cleanup(),i(Error(`CDP WebSocket connection failed`)))},this.ws.onmessage=e=>{this.handleMessage(e.data)},this.ws.onclose=()=>{this.handleClose()}})}disconnect(){this.ws&&(this.ws.onclose=null,this.ws.close()),this.cleanup(),n.info(`Disconnected`)}async send(e,t,r,i=3e4){if(this._state!==`connected`||!this.ws)throw Error(`CDP client is not connected`);let a=this.nextId++,o={id:a,method:e};return t&&(o.params=t),r&&(o.sessionId=r),n.debug(`Send`,{method:e,id:a,sessionId:r}),new Promise((t,n)=>{let r=setTimeout(()=>{this.pending.delete(a),n(Error(`CDP command timed out after ${i}ms: ${e}`))},i);this.pending.set(a,{resolve:e=>{clearTimeout(r),t(e)},reject:e=>{clearTimeout(r),n(e)}}),this.ws.send(JSON.stringify(o))})}on(e,t){let n=this.listeners.get(e);n||(n=new Set,this.listeners.set(e,n)),n.add(t)}off(e,t){let n=this.listeners.get(e);n&&(n.delete(t),n.size===0&&this.listeners.delete(e))}once(e,t=3e4){return new Promise((n,r)=>{let i=setTimeout(()=>{this.off(e,a),r(Error(`Timed out waiting for event: ${e}`))},t),a=t=>{clearTimeout(i),this.off(e,a),n(t)};this.on(e,a)})}handleMessage(e){let t;try{t=JSON.parse(e)}catch{return}if(`id`in t&&typeof t.id==`number`){let e=t;n.debug(`Response`,{id:e.id,hasError:!!e.error});let r=this.pending.get(e.id);r&&(this.pending.delete(e.id),e.error?(n.error(`Command error`,{id:e.id,code:e.error.code,message:e.error.message}),r.reject(Error(`CDP error: ${e.error.message} (${e.error.code})`))):r.resolve(e.result??{}));return}if(`method`in t){let e=t;n.debug(`Event`,{method:e.method,sessionId:e.sessionId});let r=this.listeners.get(e.method);if(r){let t=e.sessionId?{...e.params,sessionId:e.sessionId}:e.params??{};for(let e of r)try{e(t)}catch{}}}}handleClose(){n.error(`Connection closed unexpectedly`,{pendingCommands:this.pending.size});for(let[,e]of this.pending)e.reject(Error(`CDP connection closed`));this.cleanup()}cleanup(){this.ws=null,this._state=`disconnected`,this.pending.clear()}},i=`(function() {
3
3
  'use strict';
4
4
 
5
5
  // ===== DOM Utilities =====
@@ -869,7 +869,7 @@ import{t as e}from"./preload-helper-zJ_50EbN.js";import{t}from"./logger-DDBAeTLF
869
869
  } catch(e) {
870
870
  return { role: 'RootWebArea', name: '', description: 'Error: ' + (e.message || String(e)) };
871
871
  }
872
- })()`;function a(e,t=``){if(e==null)return t;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return String(e);try{return JSON.stringify(e)??t}catch{return String(e)}}var o=`ws://localhost:5710/cdp`,s=t(`browser-api`);function c(e=typeof window<`u`?window.location:null){return e?.host?`${e.protocol===`https:`?`wss:`:`ws:`}//${e.host}/cdp`:o}var l=class{client;localClient;sessionId=null;attachedTargetId=null;trayTargetProvider=null;remoteTargetInfo=null;_frameContextCache=new Map;_tabLock=Promise.resolve();_onSessionChange;handleJavaScriptDialogOpening=async e=>{let t=typeof e.sessionId==`string`?e.sessionId:this.sessionId;if(t)try{await this.client.send(`Page.handleJavaScriptDialog`,{accept:!1},t,5e3),s.warn(`Auto-dismissed unexpected JavaScript dialog`,{sessionId:t,type:e.type,message:e.message,url:e.url})}catch(e){s.warn(`Failed to auto-dismiss JavaScript dialog`,{sessionId:t,error:e instanceof Error?e.message:String(e)})}};constructor(e){this.client=e??new r,this.localClient=this.client,this.addDialogListener(this.client)}getTransport(){return this.client}setSessionChangeCallback(e){this._onSessionChange=e}getSessionId(){return this.sessionId}getAttachedTargetId(){return this.attachedTargetId}async withTab(e,t){let n,r=new Promise(e=>{n=e}),i=this._tabLock;this._tabLock=r,await i;try{return await t(await this.attachToPage(e))}finally{n()}}setTrayTargetProvider(e){this.trayTargetProvider=e}async listAllTargets(){let e=await this.listPages();if(!this.trayTargetProvider)return e;let t=!this.remoteTargetInfo,n=new Set(e.map(e=>e.targetId)),r=this.trayTargetProvider.getTargets().filter(e=>!t||!(e.runtimeId===`leader`&&n.has(e.localTargetId))).map(e=>({targetId:e.targetId,title:e.title,url:e.url,kind:e.kind,capabilities:e.capabilities}));return[...e,...r]}async connect(e){await this.client.connect({url:e?.url??c(),timeout:e?.timeout})}async createPage(e){return await this.ensureConnected(),await this.ensureLocalConnected(),(await this.localClient.send(`Target.createTarget`,{url:e??`about:blank`,background:!0})).targetId}async createRemotePage(e,t){if(!this.trayTargetProvider?.openRemoteTab)throw Error(`Remote tab opening not available (no tray target provider)`);return this.trayTargetProvider.openRemoteTab(e,t??`about:blank`)}async closePage(e){if(await this.ensureConnected(),this.trayTargetProvider?.createRemoteTransport&&e.includes(`:`)){let t=e.indexOf(`:`),n=e.substring(0,t),r=e.substring(t+1);{let t=this.trayTargetProvider.createRemoteTransport(n,r);try{await t.send(`Target.closeTarget`,{targetId:r})}finally{this.trayTargetProvider.removeRemoteTransport&&this.trayTargetProvider.removeRemoteTransport(n,r)}this.attachedTargetId===e&&(this.remoteTargetInfo&&=(this.setClient(this.localClient),null),this.sessionId=null,this.attachedTargetId=null);return}}await this.localClient.send(`Target.closeTarget`,{targetId:e}),this.attachedTargetId===e&&(this.sessionId=null,this.attachedTargetId=null)}disconnect(){this.sessionId=null,this.attachedTargetId=null,this.client.disconnect()}async listPages(){return await this.ensureConnected(),await this.ensureLocalConnected(),((await this.localClient.send(`Target.getTargets`)).targetInfos??[]).filter(e=>e.type===`page`).map(e=>({targetId:e.targetId,title:e.title,url:e.url,...e.active?{active:!0}:{}}))}async attachToPage(e){if(await this.ensureConnected(),this.sessionId&&this.attachedTargetId===e)return this.sessionId;if(this._frameContextCache.clear(),this.trayTargetProvider?.createRemoteTransport&&e.includes(`:`)){let t=e.indexOf(`:`),n=e.substring(0,t),r=e.substring(t+1);{let t=this.trayTargetProvider.createRemoteTransport(n,r);this.setClient(t),this.remoteTargetInfo={runtimeId:n,localTargetId:r};let i=await this.client.send(`Target.attachToTarget`,{targetId:r,flatten:!0});return this.sessionId=i.sessionId,this.attachedTargetId=e,await this.client.send(`Page.enable`,{},this.sessionId),this._onSessionChange?.(this.sessionId,this.client),this.sessionId}}this.remoteTargetInfo&&=(this.trayTargetProvider?.removeRemoteTransport&&this.trayTargetProvider.removeRemoteTransport(this.remoteTargetInfo.runtimeId,this.remoteTargetInfo.localTargetId),this.setClient(this.localClient),null),await this.ensureLocalConnected();let t=await this.localClient.send(`Target.attachToTarget`,{targetId:e,flatten:!0});return this.sessionId=t.sessionId,this.attachedTargetId=e,await this.localClient.send(`Page.enable`,{},this.sessionId),this._onSessionChange?.(this.sessionId,this.localClient),this.sessionId}async detach(){if(this.sessionId){try{await this.client.send(`Target.detachFromTarget`,{sessionId:this.sessionId})}catch{}this.remoteTargetInfo&&this.trayTargetProvider?.removeRemoteTransport&&(this.trayTargetProvider.removeRemoteTransport(this.remoteTargetInfo.runtimeId,this.remoteTargetInfo.localTargetId),this.setClient(this.localClient),this.remoteTargetInfo=null),this.sessionId=null,this.attachedTargetId=null}}async navigate(e){await this.ensureConnected(),this.ensureAttached(),await this.client.send(`Page.enable`,{},this.sessionId);let t=this.client.once(`Page.loadEventFired`);await this.client.send(`Page.navigate`,{url:e},this.sessionId),await t}async screenshot(t){await this.ensureConnected(),this.ensureAttached();try{let n={format:t?.format??`png`,captureBeyondViewport:!0};if(t?.quality!==void 0&&(n.quality=t.quality),t?.clip||t?.fullPage){let e=0,r=0;try{await this.client.send(`Runtime.enable`,{},this.sessionId);let t=await this.client.send(`Runtime.evaluate`,{expression:`JSON.stringify({ w: window.innerWidth, h: document.documentElement.scrollHeight })`,returnByValue:!0},this.sessionId),n=JSON.parse(t.result?.value??`{}`);e=n.w??0,r=n.h??0}catch{}t?.clip?n.clip={...t.clip,scale:t.clip.scale??1}:n.clip={x:0,y:0,width:e||1280,height:r||800,scale:1}}let r;try{r=await this.client.send(`Page.captureScreenshot`,n,this.sessionId)}catch{await this.client.send(`Page.bringToFront`,{},this.sessionId),r=await this.client.send(`Page.captureScreenshot`,n,this.sessionId)}let i=r.data;if(t?.maxWidth)try{let{getMagick:n}=await e(async()=>{let{getMagick:e}=await import(`./magick-wasm-B59SHUdz.js`);return{getMagick:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17])),r=await n(),a=atob(i),o=new Uint8Array(a.length);for(let e=0;e<a.length;e++)o[e]=a.charCodeAt(e);let s=8e3,c=!1;await r.ImageMagick.read(o,async e=>{let n=Math.min(t.maxWidth,s),r=Math.max(e.width,e.height);if(e.width>n||r>s){let t=Math.min(n/e.width,s/r);e.resize(Math.round(e.width*t),Math.round(e.height*t)),c=!0}c&&e.write(`PNG`,e=>{let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);i=btoa(t)})})}catch(e){console.warn(`[browser-api] Screenshot maxWidth resize failed, returning original`,e)}return i}finally{}}async evaluate(e,t){await this.ensureConnected(),this.ensureAttached(),await this.client.send(`Runtime.enable`,{},this.sessionId);let n=await this.client.send(`Runtime.evaluate`,{expression:e,awaitPromise:t?.awaitPromise??!0,returnByValue:t?.returnByValue??!0},this.sessionId),r=n.exceptionDetails;if(r){let e=r.exception?.description??r.text;throw Error(`Evaluation failed: ${e}`)}return n.result.value}async click(e){await this.ensureConnected(),this.ensureAttached();let t=await this.boundingBox(e);if(!t)throw Error(`Element not found: ${e}`);let n=t.x+t.width/2,r=t.y+t.height/2;await this.client.send(`Input.dispatchMouseEvent`,{type:`mousePressed`,x:n,y:r,button:`left`,clickCount:1},this.sessionId),await this.client.send(`Input.dispatchMouseEvent`,{type:`mouseReleased`,x:n,y:r,button:`left`,clickCount:1},this.sessionId)}async type(e){await this.ensureConnected(),this.ensureAttached();for(let t of e)await this.client.send(`Input.dispatchKeyEvent`,{type:`keyDown`,text:t},this.sessionId),await this.client.send(`Input.dispatchKeyEvent`,{type:`keyUp`,text:t},this.sessionId)}async insertText(e){await this.ensureConnected(),this.ensureAttached(),await this.client.send(`Input.insertText`,{text:e},this.sessionId)}async waitForSelector(e,t){await this.ensureConnected(),this.ensureAttached();let n=t?.timeout??3e4,r=t?.interval??100,i=Date.now();for(;Date.now()-i<n;){if(await this.evaluate(`!!document.querySelector(${JSON.stringify(e)})`))return;await new Promise(e=>setTimeout(e,r))}throw Error(`waitForSelector timed out after ${n}ms: ${e}`)}async getAccessibilityTree(){await this.ensureConnected(),this.ensureAttached();let e=await this.evaluate(i,{awaitPromise:!1,returnByValue:!0});return!e||typeof e!=`object`?{role:`RootWebArea`,name:``}:u(e)}async clickByBackendNodeId(e){await this.ensureConnected(),this.ensureAttached(),await this.client.send(`DOM.enable`,{},this.sessionId),await this.client.send(`Runtime.enable`,{},this.sessionId);let t=(await this.client.send(`DOM.resolveNode`,{backendNodeId:e},this.sessionId)).object;if(!t?.objectId)throw Error(`Could not resolve backend node ${e} to a DOM element`);let n=(await this.client.send(`Runtime.callFunctionOn`,{objectId:t.objectId,functionDeclaration:`function() {
872
+ })()`;function a(e,t=``){if(e==null)return t;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return String(e);try{return JSON.stringify(e)??t}catch{return String(e)}}var o=`ws://localhost:5710/cdp`,s=t(`browser-api`);function c(e=typeof window<`u`?window.location:null){return e?.host?`${e.protocol===`https:`?`wss:`:`ws:`}//${e.host}/cdp`:o}var l=class{client;localClient;sessionId=null;attachedTargetId=null;trayTargetProvider=null;remoteTargetInfo=null;_frameContextCache=new Map;_tabLock=Promise.resolve();_onSessionChange;handleJavaScriptDialogOpening=async e=>{let t=typeof e.sessionId==`string`?e.sessionId:this.sessionId;if(t)try{await this.client.send(`Page.handleJavaScriptDialog`,{accept:!1},t,5e3),s.warn(`Auto-dismissed unexpected JavaScript dialog`,{sessionId:t,type:e.type,message:e.message,url:e.url})}catch(e){s.warn(`Failed to auto-dismiss JavaScript dialog`,{sessionId:t,error:e instanceof Error?e.message:String(e)})}};constructor(e){this.client=e??new r,this.localClient=this.client,this.addDialogListener(this.client)}getTransport(){return this.client}setSessionChangeCallback(e){this._onSessionChange=e}getSessionId(){return this.sessionId}getAttachedTargetId(){return this.attachedTargetId}async withTab(e,t){let n,r=new Promise(e=>{n=e}),i=this._tabLock;this._tabLock=r,await i;try{return await t(await this.attachToPage(e))}finally{n()}}setTrayTargetProvider(e){this.trayTargetProvider=e}async listAllTargets(){let e=await this.listPages();if(!this.trayTargetProvider)return e;let t=!this.remoteTargetInfo,n=new Set(e.map(e=>e.targetId)),r=this.trayTargetProvider.getTargets().filter(e=>!t||!(e.runtimeId===`leader`&&n.has(e.localTargetId))).map(e=>({targetId:e.targetId,title:e.title,url:e.url,kind:e.kind,capabilities:e.capabilities}));return[...e,...r]}async connect(e){await this.client.connect({url:e?.url??c(),timeout:e?.timeout})}async createPage(e){return await this.ensureConnected(),await this.ensureLocalConnected(),(await this.localClient.send(`Target.createTarget`,{url:e??`about:blank`,background:!0})).targetId}async createRemotePage(e,t){if(!this.trayTargetProvider?.openRemoteTab)throw Error(`Remote tab opening not available (no tray target provider)`);return this.trayTargetProvider.openRemoteTab(e,t??`about:blank`)}async closePage(e){if(await this.ensureConnected(),this.trayTargetProvider?.createRemoteTransport&&e.includes(`:`)){let t=e.indexOf(`:`),n=e.substring(0,t),r=e.substring(t+1);{let t=this.trayTargetProvider.createRemoteTransport(n,r);try{await t.send(`Target.closeTarget`,{targetId:r})}finally{this.trayTargetProvider.removeRemoteTransport&&this.trayTargetProvider.removeRemoteTransport(n,r)}this.attachedTargetId===e&&(this.remoteTargetInfo&&=(this.setClient(this.localClient),null),this.sessionId=null,this.attachedTargetId=null);return}}await this.localClient.send(`Target.closeTarget`,{targetId:e}),this.attachedTargetId===e&&(this.sessionId=null,this.attachedTargetId=null)}disconnect(){this.sessionId=null,this.attachedTargetId=null,this.client.disconnect()}async listPages(){return await this.ensureConnected(),await this.ensureLocalConnected(),((await this.localClient.send(`Target.getTargets`)).targetInfos??[]).filter(e=>e.type===`page`).map(e=>({targetId:e.targetId,title:e.title,url:e.url,...e.active?{active:!0}:{}}))}async attachToPage(e){if(await this.ensureConnected(),this.sessionId&&this.attachedTargetId===e)return this.sessionId;if(this._frameContextCache.clear(),this.trayTargetProvider?.createRemoteTransport&&e.includes(`:`)){let t=e.indexOf(`:`),n=e.substring(0,t),r=e.substring(t+1);{let t=this.trayTargetProvider.createRemoteTransport(n,r);this.setClient(t),this.remoteTargetInfo={runtimeId:n,localTargetId:r};let i=await this.client.send(`Target.attachToTarget`,{targetId:r,flatten:!0});return this.sessionId=i.sessionId,this.attachedTargetId=e,await this.client.send(`Page.enable`,{},this.sessionId),this._onSessionChange?.(this.sessionId,this.client),this.sessionId}}this.remoteTargetInfo&&=(this.trayTargetProvider?.removeRemoteTransport&&this.trayTargetProvider.removeRemoteTransport(this.remoteTargetInfo.runtimeId,this.remoteTargetInfo.localTargetId),this.setClient(this.localClient),null),await this.ensureLocalConnected();let t=await this.localClient.send(`Target.attachToTarget`,{targetId:e,flatten:!0});return this.sessionId=t.sessionId,this.attachedTargetId=e,await this.localClient.send(`Page.enable`,{},this.sessionId),this._onSessionChange?.(this.sessionId,this.localClient),this.sessionId}async detach(){if(this.sessionId){try{await this.client.send(`Target.detachFromTarget`,{sessionId:this.sessionId})}catch{}this.remoteTargetInfo&&this.trayTargetProvider?.removeRemoteTransport&&(this.trayTargetProvider.removeRemoteTransport(this.remoteTargetInfo.runtimeId,this.remoteTargetInfo.localTargetId),this.setClient(this.localClient),this.remoteTargetInfo=null),this.sessionId=null,this.attachedTargetId=null}}async navigate(e){await this.ensureConnected(),this.ensureAttached(),await this.client.send(`Page.enable`,{},this.sessionId);let t=this.client.once(`Page.loadEventFired`);await this.client.send(`Page.navigate`,{url:e},this.sessionId),await t}async screenshot(t){await this.ensureConnected(),this.ensureAttached();try{let n={format:t?.format??`png`,captureBeyondViewport:!0};if(t?.quality!==void 0&&(n.quality=t.quality),t?.clip||t?.fullPage){let e=0,r=0;try{await this.client.send(`Runtime.enable`,{},this.sessionId);let t=await this.client.send(`Runtime.evaluate`,{expression:`JSON.stringify({ w: window.innerWidth, h: document.documentElement.scrollHeight })`,returnByValue:!0},this.sessionId),n=JSON.parse(t.result?.value??`{}`);e=n.w??0,r=n.h??0}catch{}t?.clip?n.clip={...t.clip,scale:t.clip.scale??1}:n.clip={x:0,y:0,width:e||1280,height:r||800,scale:1}}let r;try{r=await this.client.send(`Page.captureScreenshot`,n,this.sessionId)}catch{await this.client.send(`Page.bringToFront`,{},this.sessionId),r=await this.client.send(`Page.captureScreenshot`,n,this.sessionId)}let i=r.data;if(t?.maxWidth)try{let{getMagick:n}=await e(async()=>{let{getMagick:e}=await import(`./magick-wasm-BSSrd2Q9.js`);return{getMagick:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17])),r=await n(),a=atob(i),o=new Uint8Array(a.length);for(let e=0;e<a.length;e++)o[e]=a.charCodeAt(e);let s=8e3,c=!1;await r.ImageMagick.read(o,async e=>{let n=Math.min(t.maxWidth,s),r=Math.max(e.width,e.height);if(e.width>n||r>s){let t=Math.min(n/e.width,s/r);e.resize(Math.round(e.width*t),Math.round(e.height*t)),c=!0}c&&e.write(`PNG`,e=>{let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);i=btoa(t)})})}catch(e){console.warn(`[browser-api] Screenshot maxWidth resize failed, returning original`,e)}return i}finally{}}async evaluate(e,t){await this.ensureConnected(),this.ensureAttached(),await this.client.send(`Runtime.enable`,{},this.sessionId);let n=await this.client.send(`Runtime.evaluate`,{expression:e,awaitPromise:t?.awaitPromise??!0,returnByValue:t?.returnByValue??!0},this.sessionId),r=n.exceptionDetails;if(r){let e=r.exception?.description??r.text;throw Error(`Evaluation failed: ${e}`)}return n.result.value}async click(e){await this.ensureConnected(),this.ensureAttached();let t=await this.boundingBox(e);if(!t)throw Error(`Element not found: ${e}`);let n=t.x+t.width/2,r=t.y+t.height/2;await this.client.send(`Input.dispatchMouseEvent`,{type:`mousePressed`,x:n,y:r,button:`left`,clickCount:1},this.sessionId),await this.client.send(`Input.dispatchMouseEvent`,{type:`mouseReleased`,x:n,y:r,button:`left`,clickCount:1},this.sessionId)}async type(e){await this.ensureConnected(),this.ensureAttached();for(let t of e)await this.client.send(`Input.dispatchKeyEvent`,{type:`keyDown`,text:t},this.sessionId),await this.client.send(`Input.dispatchKeyEvent`,{type:`keyUp`,text:t},this.sessionId)}async insertText(e){await this.ensureConnected(),this.ensureAttached(),await this.client.send(`Input.insertText`,{text:e},this.sessionId)}async waitForSelector(e,t){await this.ensureConnected(),this.ensureAttached();let n=t?.timeout??3e4,r=t?.interval??100,i=Date.now();for(;Date.now()-i<n;){if(await this.evaluate(`!!document.querySelector(${JSON.stringify(e)})`))return;await new Promise(e=>setTimeout(e,r))}throw Error(`waitForSelector timed out after ${n}ms: ${e}`)}async getAccessibilityTree(){await this.ensureConnected(),this.ensureAttached();let e=await this.evaluate(i,{awaitPromise:!1,returnByValue:!0});return!e||typeof e!=`object`?{role:`RootWebArea`,name:``}:u(e)}async clickByBackendNodeId(e){await this.ensureConnected(),this.ensureAttached(),await this.client.send(`DOM.enable`,{},this.sessionId),await this.client.send(`Runtime.enable`,{},this.sessionId);let t=(await this.client.send(`DOM.resolveNode`,{backendNodeId:e},this.sessionId)).object;if(!t?.objectId)throw Error(`Could not resolve backend node ${e} to a DOM element`);let n=(await this.client.send(`Runtime.callFunctionOn`,{objectId:t.objectId,functionDeclaration:`function() {
873
873
  this.scrollIntoView({ block: 'center', inline: 'center' });
874
874
  const r = this.getBoundingClientRect();
875
875
  return { x: r.x, y: r.y, width: r.width, height: r.height };
@@ -1,4 +1,4 @@
1
- import{G as e,Q as t,W as n,Z as r,tt as i}from"./main-B-7wG_p8.js";var a=`slicc_cloud_model_catalog`,o=`adobe`;function s(e){if(e===o)return!1;let t=r(e);return!(t.hidden||t.onOAuthLoginIntercepted)}function c(){try{let t=e().map(e=>({providerId:e.providerId,providerName:e.providerName,models:e.models.map(e=>({id:e.id,name:e.name}))}));localStorage.setItem(a,JSON.stringify(t))}catch{}}async function l(e){for(;e.firstChild;)e.removeChild(e.firstChild);e.className=`connect-surface`;let a=document.createElement(`h1`);a.className=`connect-surface__title`,a.textContent=`Connect providers`,e.appendChild(a);let l=document.createElement(`p`);l.className=`connect-surface__desc`,l.textContent=`Log in or add API keys for the providers your cone should use, then click Done to return to the dashboard.`,e.appendChild(l);let u=document.createElement(`div`);u.className=`connect-surface__accounts`,e.appendChild(u);function d(){for(;u.firstChild;)u.removeChild(u.firstChild);let e=n().filter(e=>e.providerId!==o);if(e.length===0){let e=document.createElement(`div`);e.className=`connect-surface__empty`,e.textContent=`No providers connected yet.`,u.appendChild(e)}else{let n=document.createElement(`div`);n.className=`connect-surface__accounts-list`;for(let i of e){let e=r(i.providerId),a=document.createElement(`div`);a.className=`connect-surface__account-row`;let o=document.createElement(`div`);o.className=`connect-surface__account-info`;let s=document.createElement(`div`);s.className=`connect-surface__account-name`,s.textContent=e.name,o.appendChild(s);let l=document.createElement(`div`);l.className=`connect-surface__account-detail`,i.userName?l.textContent=i.userName:i.accessToken?l.textContent=`Logged in`:l.textContent=i.apiKey?`API key set`:`No credentials`,o.appendChild(l),a.appendChild(o);let u=document.createElement(`button`);u.className=`connect-surface__remove-btn`,u.textContent=`Remove`,u.onclick=async()=>{await t(i.providerId),c(),d()},a.appendChild(u),n.appendChild(a)}u.appendChild(n)}let a=document.createElement(`button`);a.className=`connect-surface__add-btn`,a.textContent=e.length===0?`Add provider`:`Manage providers`,a.onclick=async()=>{await i({startInAddAccount:!0,providerFilter:s})&&(c(),d())},u.appendChild(a)}d(),c();let f=document.createElement(`div`);f.className=`connect-surface__footer`;let p=document.createElement(`button`);if(p.className=`connect-surface__done-btn`,p.textContent=`Done — return to dashboard`,p.onclick=()=>{c(),window.close()},f.appendChild(p),e.appendChild(f),!document.getElementById(`connect-surface-style`)){let e=document.createElement(`style`);e.id=`connect-surface-style`,e.textContent=`
1
+ import{G as e,Q as t,W as n,Z as r,tt as i}from"./main-8qsCPK6A.js";var a=`slicc_cloud_model_catalog`,o=`adobe`;function s(e){if(e===o)return!1;let t=r(e);return!(t.hidden||t.onOAuthLoginIntercepted)}function c(){try{let t=e().map(e=>({providerId:e.providerId,providerName:e.providerName,models:e.models.map(e=>({id:e.id,name:e.name}))}));localStorage.setItem(a,JSON.stringify(t))}catch{}}async function l(e){for(;e.firstChild;)e.removeChild(e.firstChild);e.className=`connect-surface`;let a=document.createElement(`h1`);a.className=`connect-surface__title`,a.textContent=`Connect providers`,e.appendChild(a);let l=document.createElement(`p`);l.className=`connect-surface__desc`,l.textContent=`Log in or add API keys for the providers your cone should use, then click Done to return to the dashboard.`,e.appendChild(l);let u=document.createElement(`div`);u.className=`connect-surface__accounts`,e.appendChild(u);function d(){for(;u.firstChild;)u.removeChild(u.firstChild);let e=n().filter(e=>e.providerId!==o);if(e.length===0){let e=document.createElement(`div`);e.className=`connect-surface__empty`,e.textContent=`No providers connected yet.`,u.appendChild(e)}else{let n=document.createElement(`div`);n.className=`connect-surface__accounts-list`;for(let i of e){let e=r(i.providerId),a=document.createElement(`div`);a.className=`connect-surface__account-row`;let o=document.createElement(`div`);o.className=`connect-surface__account-info`;let s=document.createElement(`div`);s.className=`connect-surface__account-name`,s.textContent=e.name,o.appendChild(s);let l=document.createElement(`div`);l.className=`connect-surface__account-detail`,i.userName?l.textContent=i.userName:i.accessToken?l.textContent=`Logged in`:l.textContent=i.apiKey?`API key set`:`No credentials`,o.appendChild(l),a.appendChild(o);let u=document.createElement(`button`);u.className=`connect-surface__remove-btn`,u.textContent=`Remove`,u.onclick=async()=>{await t(i.providerId),c(),d()},a.appendChild(u),n.appendChild(a)}u.appendChild(n)}let a=document.createElement(`button`);a.className=`connect-surface__add-btn`,a.textContent=e.length===0?`Add provider`:`Manage providers`,a.onclick=async()=>{await i({startInAddAccount:!0,providerFilter:s})&&(c(),d())},u.appendChild(a)}d(),c();let f=document.createElement(`div`);f.className=`connect-surface__footer`;let p=document.createElement(`button`);if(p.className=`connect-surface__done-btn`,p.textContent=`Done — return to dashboard`,p.onclick=()=>{c(),window.close()},f.appendChild(p),e.appendChild(f),!document.getElementById(`connect-surface-style`)){let e=document.createElement(`style`);e.id=`connect-surface-style`,e.textContent=`
2
2
  .connect-surface {
3
3
  padding: 2rem;
4
4
  max-width: 560px;
@@ -0,0 +1 @@
1
+ import"./main-8qsCPK6A.js";function e(e){}export{e as registerSessionCostsProvider};
@@ -1,2 +1,2 @@
1
- import{C as e,D as t,E as n,O as r,S as i,T as a,_ as o,a as s,b as c,c as l,d as u,f as d,g as f,h as p,i as m,k as h,l as g,m as _,n as v,o as y,p as b,r as x,s as S,u as C,w,x as T}from"./dist-D1-v9_zA.js";function E(e){switch(e.name){case`TypeMismatchError`:return`EPERM`;case`IndexSizeError`:case`HierarchyRequestError`:case`InvalidCharacterError`:case`InvalidStateError`:case`SyntaxError`:case`NamespaceError`:case`ConstraintError`:case`VersionError`:case`URLMismatchError`:case`InvalidNodeTypeError`:return`EINVAL`;case`WrongDocumentError`:return`EXDEV`;case`NoModificationAllowedError`:case`InvalidModificationError`:case`InvalidAccessError`:case`SecurityError`:case`NotAllowedError`:return`EACCES`;case`NotFoundError`:return`ENOENT`;case`NotSupportedError`:return`ENOTSUP`;case`InUseAttributeError`:return`EBUSY`;case`NetworkError`:return`ENETDOWN`;case`AbortError`:return`EINTR`;case`QuotaExceededError`:return`ENOSPC`;case`TimeoutError`:return`ETIMEDOUT`;case`ReadOnlyError`:return`EROFS`;default:return`EIO`}}function D(e,t){if(e instanceof a)return e;let n=new a(e instanceof DOMException?w[E(e)]:w.EIO,e.message);return n.stack=e.stack,Error.captureStackTrace?.(n,D),n.cause=e.cause,n}function O(e){return typeof e==`object`&&!!e&&e.constructor.name==`SharedArrayBuffer`}function k(e){return e instanceof ArrayBuffer?e.resizable:O(e)?e.growable:!1}function A(e,t){return e.kind==t}var j=class extends x(m){async _loadHandles(e,t){for await(let[n,r]of t.entries()){let t=_(e,n);this._handles.set(t,r),A(r,`directory`)&&await this._loadHandles(t,r)}}async _loadMetadata(e){if(this._handles.set(`/`,this.root),await this._loadHandles(`/`,this.root),e){let t=await(await(await this.get(`file`,e)).getFile()).text(),n=JSON.parse(t);this.index.fromJSON(n);return}for(let[e,t]of this._handles){if(A(t,`file`)){let{lastModified:n,size:r}=await t.getFile();this.index.set(e,new C({mode:420|o,size:r,mtimeMs:n}));continue}if(!A(t,`directory`))throw n(`EIO`,`Invalid handle`);this.index.set(e,new C({mode:511|p,size:0}))}}constructor(e,t=!1){super(2003133025,`webaccessfs`),this.root=e,this.disableHandleCache=t,this._handles=new Map,this._sync=s.create({label:`accessfs-cache`}),this.attributes.set(`no_buffer_resize`,!0),t&&this.attributes.set(`no_handle_cache`,!0)}async stat(e){try{return await super.stat(e)}catch(t){if(t.code!=`ENOENT`)throw t;let n=await this.get(null,e),r=new C;if(A(n,`file`)){let e=await n.getFile();r.update({mode:420|o,size:e.size,mtimeMs:e.lastModified})}else r.update({mode:p|511,size:0});return this.index.set(e,r),r}}async readdir(e){let t=await this.get(`directory`,e);return await Array.fromAsync(t.keys())}async remove(e){let t=await this.get(`directory`,b(e));for(let t of this._handles.keys())b(t)==e&&this._handles.delete(t);this._handles.delete(e),await t.removeEntry(d(e),{recursive:!0}).catch(t=>h(D(t,e)))}removeSync(){throw T(n(`ENOSYS`))}async read(e,t,r,i){if(i<=r)return;let a=await(await(await this.get(`file`,e)).getFile()).arrayBuffer();if(a.byteLength<i-r)throw c(n(`EIO`,[`Unexpected mismatch in file data size. This should not happen.`,`tried to read ${i-r} bytes but the file is ${a.byteLength} bytes.`,`path: ${e}`].join(`
1
+ import{C as e,D as t,E as n,O as r,S as i,T as a,_ as o,a as s,b as c,c as l,d as u,f as d,g as f,h as p,i as m,k as h,l as g,m as _,n as v,o as y,p as b,r as x,s as S,u as C,w,x as T}from"./dist-By9pLLsg.js";function E(e){switch(e.name){case`TypeMismatchError`:return`EPERM`;case`IndexSizeError`:case`HierarchyRequestError`:case`InvalidCharacterError`:case`InvalidStateError`:case`SyntaxError`:case`NamespaceError`:case`ConstraintError`:case`VersionError`:case`URLMismatchError`:case`InvalidNodeTypeError`:return`EINVAL`;case`WrongDocumentError`:return`EXDEV`;case`NoModificationAllowedError`:case`InvalidModificationError`:case`InvalidAccessError`:case`SecurityError`:case`NotAllowedError`:return`EACCES`;case`NotFoundError`:return`ENOENT`;case`NotSupportedError`:return`ENOTSUP`;case`InUseAttributeError`:return`EBUSY`;case`NetworkError`:return`ENETDOWN`;case`AbortError`:return`EINTR`;case`QuotaExceededError`:return`ENOSPC`;case`TimeoutError`:return`ETIMEDOUT`;case`ReadOnlyError`:return`EROFS`;default:return`EIO`}}function D(e,t){if(e instanceof a)return e;let n=new a(e instanceof DOMException?w[E(e)]:w.EIO,e.message);return n.stack=e.stack,Error.captureStackTrace?.(n,D),n.cause=e.cause,n}function O(e){return typeof e==`object`&&!!e&&e.constructor.name==`SharedArrayBuffer`}function k(e){return e instanceof ArrayBuffer?e.resizable:O(e)?e.growable:!1}function A(e,t){return e.kind==t}var j=class extends x(m){async _loadHandles(e,t){for await(let[n,r]of t.entries()){let t=_(e,n);this._handles.set(t,r),A(r,`directory`)&&await this._loadHandles(t,r)}}async _loadMetadata(e){if(this._handles.set(`/`,this.root),await this._loadHandles(`/`,this.root),e){let t=await(await(await this.get(`file`,e)).getFile()).text(),n=JSON.parse(t);this.index.fromJSON(n);return}for(let[e,t]of this._handles){if(A(t,`file`)){let{lastModified:n,size:r}=await t.getFile();this.index.set(e,new C({mode:420|o,size:r,mtimeMs:n}));continue}if(!A(t,`directory`))throw n(`EIO`,`Invalid handle`);this.index.set(e,new C({mode:511|p,size:0}))}}constructor(e,t=!1){super(2003133025,`webaccessfs`),this.root=e,this.disableHandleCache=t,this._handles=new Map,this._sync=s.create({label:`accessfs-cache`}),this.attributes.set(`no_buffer_resize`,!0),t&&this.attributes.set(`no_handle_cache`,!0)}async stat(e){try{return await super.stat(e)}catch(t){if(t.code!=`ENOENT`)throw t;let n=await this.get(null,e),r=new C;if(A(n,`file`)){let e=await n.getFile();r.update({mode:420|o,size:e.size,mtimeMs:e.lastModified})}else r.update({mode:p|511,size:0});return this.index.set(e,r),r}}async readdir(e){let t=await this.get(`directory`,e);return await Array.fromAsync(t.keys())}async remove(e){let t=await this.get(`directory`,b(e));for(let t of this._handles.keys())b(t)==e&&this._handles.delete(t);this._handles.delete(e),await t.removeEntry(d(e),{recursive:!0}).catch(t=>h(D(t,e)))}removeSync(){throw T(n(`ENOSYS`))}async read(e,t,r,i){if(i<=r)return;let a=await(await(await this.get(`file`,e)).getFile()).arrayBuffer();if(a.byteLength<i-r)throw c(n(`EIO`,[`Unexpected mismatch in file data size. This should not happen.`,`tried to read ${i-r} bytes but the file is ${a.byteLength} bytes.`,`path: ${e}`].join(`
2
2
  `+` `.repeat(24))));t.set(new Uint8Array(a,r,i-r))}async write(e,t,r){if(k(t.buffer)||O(t.buffer)){let e=new Uint8Array(new ArrayBuffer(t.byteLength),t.byteOffset,t.byteLength);e.set(t),t=e}let i=this.index.get(e);if(!i)throw n(`ENOENT`);let a=(i.mode&f)==p,o;try{o=await this.get(a?`directory`:`file`,e)}catch{o=await(await this.get(`directory`,b(e)))[a?`getDirectoryHandle`:`getFileHandle`](d(e),{create:!0}).catch(t=>h(D(t,e))),this.disableHandleCache||this._handles.set(e,o)}if(a)return;if(A(o,`directory`)){T(n(`EIO`,`Mismatch in entry kind on write`));return}let s=await o.createWritable({keepExistingData:!0});try{r<i.size&&await s.seek(r)}catch{await s.write({type:`seek`,position:r})}await s.write(t),await s.close();let{size:c,lastModified:l}=await o.getFile();i.update({size:c,mtimeMs:l}),this.index.set(e,i)}async writeFile(e,t){return this.write(e,t,0)}async _mkdir(e){let t=await(await this.get(`directory`,b(e))).getDirectoryHandle(d(e),{create:!0}).catch(t=>h(D(t,e)));this.disableHandleCache||this._handles.set(e,t)}async get(e=null,t){let r=this._handles.get(t);if(!this.disableHandleCache&&r){if(e&&!A(r,e))throw n(e==`directory`?`ENOTDIR`:`EISDIR`);return r}if(t==`/`)return this.root;let i=t.slice(1).split(`/`),a=this.root;for(let e=0;e<i.length-1;++e)a=await a.getDirectoryHandle(i[e]).catch(e=>h(D(e,t)));try{let n=await a[e==`file`?`getFileHandle`:`getDirectoryHandle`](i.at(-1));return this.disableHandleCache||this._handles.set(t,n),n}catch(r){if(r.name!=`TypeMismatchError`)throw D(r,t);if(e===null){let e=await a.getFileHandle(i.at(-1)).catch(e=>h(D(e,t)));return this.disableHandleCache||this._handles.set(t,e),e}else throw n(e==`file`?`EISDIR`:`ENOTDIR`)}}};const M={name:`WebAccess`,options:{handle:{type:`object`,required:!0},metadata:{type:`string`,required:!1},disableHandleCache:{type:`boolean`,required:!1}},async create(e){let t=new j(e.handle,e.disableHandleCache);return await t._loadMetadata(e.metadata),t}};function N(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=t=>{t.preventDefault(),n(D(e.error))}})}var P=class extends l{async(e){this.asyncDone=this.asyncDone.then(()=>e)}constructor(e,t){super(t),this.tx=e,this.store=t,this.asyncDone=Promise.resolve(),this._idb=e.objectStore(t.name)}async keys(){return(await N(this._idb.getAllKeys())).map(Number)}async get(e){let t=await N(this._idb.get(e));return t&&this.store.cache.set(e,new Uint8Array(t)),t}getSync(e,t,n){if(!this.store.cache.has(e))return;let r=new Uint8Array(this.store.cache.get(e));return n??=r.byteLength,r.subarray(t,n)}async set(e,t){this.store.cache.set(e,new Uint8Array(t)),await N(this._idb.put(t,e))}setSync(e,t){this.async(this.set(e,t))}remove(e){return this.store.cache.delete(e),N(this._idb.delete(e))}removeSync(e){this.store.cache.delete(e),this.async(this.remove(e))}async commit(){await this.asyncDone;let{promise:e,resolve:t,reject:n}=Promise.withResolvers();return this.tx.oncomplete=()=>t(),this.tx.onerror=()=>n(D(this.tx.error)),this.tx.commit(),e}async abort(){await this.asyncDone;let{promise:e,resolve:t,reject:n}=Promise.withResolvers();return this.tx.onabort=()=>t(),this.tx.onerror=()=>n(D(this.tx.error)),this.tx.abort(),e}};async function F(t,n=globalThis.indexedDB){let r=n.open(t);return r.onupgradeneeded=()=>{let n=r.result;n.objectStoreNames.contains(t)&&(e(`Found unexpected object store: `+t),n.deleteObjectStore(t)),n.createObjectStore(t)},await N(r)}var I=class{constructor(e){this.db=e,this.cache=new Map}sync(){return Promise.resolve()}get name(){return this.db.name}transaction(){return new P(this.db.transaction(this.name,`readwrite`),this)}};const L=new WeakMap;async function R(e){if(!(e instanceof IDBFactory))return!1;try{return(await N(e.open(`__zenfs_test`))).close(),!0}catch{return!1}finally{e?.deleteDatabase(`__zenfs_test`)}}const z={name:`IndexedDB`,options:{storeName:{type:`string`,required:!1},idbFactory:{type:`object`,required:!1}},async isAvailable({idbFactory:e=globalThis.indexedDB}){if(L.has(e))return L.get(e);let t=R(e);return L.set(e,t),t},async create(e){let t=new I(await F(e.storeName||`zenfs`,e.idbFactory)),n=new S(t);if(e?.disableAsyncCache)return i(`Async preloading disabled for IndexedDB`),n;let r=t.transaction();for(let e of await r.keys())await r.get(e);return n}};var B=class{get name(){return V.name}constructor(e){this.storage=e}clear(){this.storage.clear()}clearSync(){this.storage.clear()}async sync(){}transaction(){return new y(this)}keys(){return Object.keys(this.storage).map(e=>Number(e))}get(e){let t=this.storage.getItem(e.toString());if(typeof t==`string`)return r(t)}set(e,r){try{this.storage.setItem(e.toString(),t(r))}catch{throw n(`ENOSPC`)}}delete(e){try{this.storage.removeItem(e.toString())}catch(t){throw n(`EIO`,`Unable to delete '${e}': ${t}`)}}};const V={name:`WebStorage`,options:{storage:{type:`object`,required:!1}},isAvailable(e){return(e?.storage??globalThis.localStorage)instanceof globalThis.Storage},create({storage:e=globalThis.localStorage}){return new S(new B(e))}};function H(e){let t={};for(let n of u){let r=e.getAttribute(n);r!=null&&(t[n]=parseInt(r,16))}return new C(t)}function U(e,t){for(let n of Object.keys(t))!(n in u)||t[n]===void 0||e.setAttribute(n,t[n].toString(16))}function W(e,t=!1){let n;try{let r=t?e.textContent:e.getAttribute(`paths`);n=JSON.parse(r||`[]`)}catch{n=[]}return n}var G=class extends v(g){constructor(e=new DOMParser().parseFromString(`<fs></fs>`,`application/xml`).documentElement){super(544763244,`xmltmpfs`),this.root=e;try{this.mkdirSync(`/`,{uid:0,gid:0,mode:511})}catch(e){let t=e;if(t.code!=`EEXIST`)throw t}}renameSync(e,t){let n=this.get(`rename`,e);this.remove(`rename`,n,e),this.add(`rename`,n,t)}statSync(e){return H(this.get(`stat`,e))}createFileSync(e,t){let n=this.statSync(b(e)),r=new C({mode:t.mode|o,uid:n.mode&2048?n.uid:t.uid,gid:n.mode&1024?n.gid:t.gid});return this.create(`createFile`,e,r),r}unlinkSync(e){let t=this.get(`unlink`,e);if(H(t).mode&16384)throw n(`EISDIR`);this.remove(`unlink`,t,e)}rmdirSync(e){let t=this.get(`rmdir`,e);if(t.textContent?.length)throw n(`ENOTEMPTY`);if(!(H(t).mode&16384))throw n(`ENOTDIR`);this.remove(`rmdir`,t,e)}mkdirSync(e,t){let n=this.statSync(b(e)),r=new C({mode:t.mode|p,uid:n.mode&2048?n.uid:t.uid,gid:n.mode&1024?n.gid:t.gid});return this.create(`mkdir`,e,r).textContent=`[]`,r}readdirSync(e){let t=this.get(`readdir`,e);if(!(H(t).mode&16384))throw n(`ENOTDIR`);try{return JSON.parse(t.textContent)}catch(e){throw n(`EIO`,`Invalid directory listing: `+e)}}linkSync(e,t){let n=this.get(`link`,e);this.add(`link`,n,t)}touchSync(e,t){U(this.get(`touch`,e),t)}syncSync(){}readSync(e,t,n,i){let a=r(this.get(`read`,e).textContent.slice(n,i));t.set(a)}writeSync(e,n,r){let i=this.get(`write`,e),a=t(n),o=i.textContent.slice(r+a.length);i.textContent=i.textContent.slice(0,r)+a+o}toString(){return new XMLSerializer().serializeToString(this.root)}get(e,t){let r=this.root.children;if(!r)throw n(`EIO`);for(let e=0;e<r.length;e++)if(W(r[e]).includes(t))return r[e];throw n(`ENOENT`)}create(e,t,r){if(this.existsSync(t))throw n(`EEXIST`);let i=document.createElement(`file`);return this.add(e,i,t),U(i,new C({...r,uid:r.mode})),this.root.append(i),i}add(e,t,n,r=!1){let i=W(t,r);if(i.push(n),r){t.textContent=JSON.stringify(i);return}if(t.setAttribute(`paths`,JSON.stringify(i)),t.setAttribute(`nlink`,i.length.toString(16)),n!=`/`){let t=this.get(e,b(n));this.add(e,t,d(n),!0)}}remove(e,t,n,r=!1){let i=W(t,r),a=i.indexOf(n);if(a!=-1){if(i.splice(a,1),r){t.textContent=JSON.stringify(i);return}if(i.length?(t.setAttribute(`paths`,JSON.stringify(i)),t.setAttribute(`nlink`,i.length.toString(16))):t.remove(),n!=`/`){let t=this.get(e,b(n));this.remove(e,t,d(n),!0)}}}};const K={name:`XML`,options:{root:{type:`object`,required:!1}},isAvailable(){return!0},create(e){return new G(e.root)}};export{z as IndexedDB,I as IndexedDBStore,P as IndexedDBTransaction,M as WebAccess,j as WebAccessFS,V as WebStorage,B as WebStorageStore,K as XML,G as XMLFS};