sliccy 6.1.0 → 6.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ui/assets/{account-store-BnUIIjUC.js → account-store-DhS8k8-S.js} +1 -1
- package/dist/ui/assets/account-store-Uj6VFvmJ.js +101 -0
- package/dist/ui/assets/adobe-B8qKdXEi.js +1 -0
- package/dist/ui/assets/{adobe-JmXV9kQp.js → adobe-DEqarHF7.js} +1 -1
- package/dist/ui/assets/{anthropic-messages-Cx3KdHDK.js → anthropic-messages-C8dDJE2X.js} +3 -3
- package/dist/ui/assets/{apps-eLp3JMi9.js → apps-Bie0e1m2.js} +1 -1
- package/dist/ui/assets/{azure-openai-WQPrzmzl.js → azure-openai-DuVr84k9.js} +1 -1
- package/dist/ui/assets/azure-openai-DvSSRCkA.js +1 -0
- package/dist/ui/assets/azure-openai-responses-CzG7X9qb.js +1 -0
- package/dist/ui/assets/bedrock-camp-DS0ilb3O.js +1 -0
- package/dist/ui/assets/cerebras-BpS22jYI.js +1 -0
- package/dist/ui/assets/{cerebras-Bzd0OB3R.js → cerebras-DzesQTXW.js} +1 -1
- package/dist/ui/assets/{connect-surface-C79IWXLS.js → connect-surface-Ct1AdFki.js} +1 -1
- package/dist/ui/assets/frozen-archive-format-CqpMlNNW.js +1 -0
- package/dist/ui/assets/{fs-BKwOXUGY.js → fs-CvnWZ6Jt.js} +1 -1
- package/dist/ui/assets/{fs-CPzDCGWj.js → fs-DIJccx8q.js} +2 -2
- package/dist/ui/assets/{github-copilot-BZDUFdt5.js → github-copilot-BiPqFhNX.js} +1 -1
- package/dist/ui/assets/github-copilot-VvH4s7sA.js +1 -0
- package/dist/ui/assets/{github-XkSGCSpp.js → github-dAErpFvL.js} +1 -1
- package/dist/ui/assets/{github-CDT9ErFJ.js → github-pk5_ylPv.js} +2 -2
- package/dist/ui/assets/google-generative-ai-DzD1vsXe.js +1 -0
- package/dist/ui/assets/{google-shared-DLE9jWCI.js → google-shared-BAKd3aSn.js} +1 -1
- package/dist/ui/assets/google-vertex-oQOD3HKr.js +1 -0
- package/dist/ui/assets/{kernel-worker-B4A3VjuZ.js → kernel-worker-ajcnNy0f.js} +630 -616
- package/dist/ui/assets/legacy-api-aliases-YuuBU-he.js +1 -0
- package/dist/ui/assets/{local-llm-BknCmmbt.js → local-llm-CJRbK1cS.js} +1 -1
- package/dist/ui/assets/{local-llm-6IajVSOQ.js → local-llm-CfVfbBNa.js} +1 -1
- package/dist/ui/assets/{main-5mEHTbp1.js → main-7V25oAV9.js} +3 -3
- package/dist/ui/assets/{mistral-conversations-BBexKxUC.js → mistral-conversations-CKK59QJS.js} +2 -2
- package/dist/ui/assets/{mount-DbCOeMHV.js → mount-Bsul2M7V.js} +2 -2
- package/dist/ui/assets/{mount-B6vXbOCk.js → mount-CRp56aa2.js} +1 -1
- package/dist/ui/assets/{mount-recovery-DFVBuWuW.js → mount-recovery-B6-FEnb7.js} +1 -1
- package/dist/ui/assets/new-session-BMY81iI-.js +2 -0
- package/dist/ui/assets/{oauth-bootstrap-9zGNab0F.js → oauth-bootstrap-DFhqreg0.js} +2 -2
- package/dist/ui/assets/{openai-codex-DhP3Bc4o.js → openai-codex-5ly8mDcH.js} +1 -1
- package/dist/ui/assets/openai-codex-o65C3vHM.js +1 -0
- package/dist/ui/assets/openai-codex-responses-DU5CHdDQ.js +7 -0
- package/dist/ui/assets/openai-completions-DhKgaAgM.js +5 -0
- package/dist/ui/assets/openai-responses-C4_jiYtu.js +1 -0
- package/dist/ui/assets/{openai-responses-shared-BU1VYwTh.js → openai-responses-shared-CiIL52L-.js} +5 -5
- package/dist/ui/assets/openrouter-Bl8rKbdM.js +1 -0
- package/dist/ui/assets/{openrouter-C6LzaTJh.js → openrouter-DZzCgoha.js} +1 -1
- package/dist/ui/assets/{openrouter-oauth-DIXeQ6QT.js → openrouter-oauth-DIW_pyO2.js} +1 -1
- package/dist/ui/assets/{openrouter-oauth-CLIQCCLY.js → openrouter-oauth-tJu_AMDh.js} +1 -1
- package/dist/ui/assets/{panel-rpc-handlers-Dyt8XcM7.js → panel-rpc-handlers-BN4BCAVK.js} +2 -2
- package/dist/ui/assets/{provider-BxyjRM0f.js → provider-BCQiQFKs.js} +1 -1
- package/dist/ui/assets/{provider-DW9RLF-a.js → provider-BaiyZqj2.js} +2 -2
- package/dist/ui/assets/{provider-settings-BXwbB8RF.js → provider-settings-CXes7fTR.js} +1 -1
- package/dist/ui/assets/{provider-settings-CzM2hHtV.js → provider-settings-VxXaQXu5.js} +1 -1
- package/dist/ui/assets/{provider-store-access-M-631pba.js → provider-store-access-B0oECQqK.js} +2 -2
- package/dist/ui/assets/provider-store-access-fl-MsQpU.js +1 -0
- package/dist/ui/assets/{providers-DQpYSqlR.js → providers-BwP_K_jW.js} +1 -1
- package/dist/ui/assets/{providers-BU_CYZEQ.js → providers-Bz0SwL53.js} +2 -2
- package/dist/ui/assets/{quick-llm-BmxcWrG9.js → quick-llm-P9wxZ7EU.js} +1 -1
- package/dist/ui/assets/{session-freezer-C9bwD5or.js → session-freezer-CueXX5nZ.js} +2 -2
- package/dist/ui/assets/{setup-standalone-prelude-DmP6XzHq.js → setup-standalone-prelude-BfeEnJkN.js} +1 -1
- package/dist/ui/assets/{setup-sudo-Disgv7TU.js → setup-sudo-DCOcjx2c.js} +2 -2
- package/dist/ui/assets/{skills-JWBWz93Y.js → skills-D_Ep23NZ.js} +1 -1
- package/dist/ui/assets/{sprinkle-manager-DwLCgrU9.js → sprinkle-manager-HaNmX2ye.js} +1 -1
- package/dist/ui/assets/{src-Bq5z8yvo.js → src-BTviaay1.js} +2 -2
- package/dist/ui/assets/{store-W4scCsQ2.js → store-CguDkxqH.js} +1 -1
- package/dist/ui/assets/{sudo-DlJO76Iy.js → sudo-V2MeKwLU.js} +1 -1
- package/dist/ui/assets/{telemetry-C8rZr13D.js → telemetry-DqIqVG5n.js} +3 -3
- package/dist/ui/assets/{models-CvUrqKSj.js → transform-messages-Bp94o3FD.js} +1 -1
- package/dist/ui/assets/{upgrade-detection-I9bwQZ3A.js → upgrade-detection-CGfE8fu7.js} +1 -1
- package/dist/ui/assets/{wc-attach-BCbFKAxf.js → wc-attach-KYdIYwcc.js} +2 -2
- package/dist/ui/assets/{wc-extension-C8rP0TQ5.js → wc-extension-CqFkjCEc.js} +2 -2
- package/dist/ui/assets/{wc-follower-BZbGw9cM.js → wc-follower-bcBXL4QF.js} +3 -3
- package/dist/ui/assets/wc-live-1igAgrHi.js +8 -0
- package/dist/ui/assets/{wc-nav-CeMp5ghF.js → wc-nav-s0llKqeE.js} +2 -2
- package/dist/ui/assets/{wc-onboarding-BW3KMsBt.js → wc-onboarding-CedoFc5j.js} +2 -2
- package/dist/ui/assets/{wc-placeholder-CvsaP7X6.js → wc-placeholder-DhOwMxPG.js} +2 -2
- package/dist/ui/assets/{wc-settings-nRxDO_kn.js → wc-settings-_h48_7UA.js} +2 -2
- package/dist/ui/assets/{wc-shell-DGg7WImK.js → wc-shell-Dmpb_Nl-.js} +21 -21
- package/dist/ui/assets/{wc-sprinkles-DiBOBknV.js → wc-sprinkles-BUPl0ZFx.js} +2 -2
- package/dist/ui/assets/{wc-tray-HHHE6vhN.js → wc-tray-C-KZScxb.js} +2 -2
- package/dist/ui/assets/xai-grok-BOdrR1oK.js +1 -0
- package/dist/ui/assets/{xai-grok-Dw-lxH04.js → xai-grok-JLJFEJOt.js} +1 -1
- package/dist/ui/index.html +7 -7
- package/dist/ui/llm-proxy-sw.js +1 -1
- package/dist/ui/packages/webapp/index.html +7 -7
- package/package.json +1 -1
- package/dist/ui/assets/account-store-Bj2PFEoD.js +0 -44
- package/dist/ui/assets/adobe-Czr7m_TT.js +0 -1
- package/dist/ui/assets/azure-openai-DmUBjHKn.js +0 -1
- package/dist/ui/assets/azure-openai-responses-D2e4727V.js +0 -1
- package/dist/ui/assets/bedrock-camp-CvcU-31w.js +0 -1
- package/dist/ui/assets/cerebras-B6OFJhQY.js +0 -1
- package/dist/ui/assets/compat-BHfpuQ4D.js +0 -1
- package/dist/ui/assets/cone-memory-budget-CfbbleAM.js +0 -15
- package/dist/ui/assets/context-compaction-DDE4L-Sj.js +0 -58
- package/dist/ui/assets/github-copilot-BLsTiukB.js +0 -1
- package/dist/ui/assets/google-generative-ai-BPByyH06.js +0 -1
- package/dist/ui/assets/google-vertex-0jNZ5aI-.js +0 -1
- package/dist/ui/assets/legacy-api-aliases-BLiHiLlu.js +0 -1
- package/dist/ui/assets/new-session-Cu_fMVmN.js +0 -2
- package/dist/ui/assets/openai-codex-CBAEHdaT.js +0 -1
- package/dist/ui/assets/openai-codex-responses-CBhbcvRK.js +0 -7
- package/dist/ui/assets/openai-completions-CBeXb_ux.js +0 -5
- package/dist/ui/assets/openai-responses-B5d1rOIe.js +0 -1
- package/dist/ui/assets/openrouter-D2M_Nolr.js +0 -1
- package/dist/ui/assets/provider-store-access-0M5vSpmv.js +0 -1
- package/dist/ui/assets/session-freezer-sudk6sSl.js +0 -1
- package/dist/ui/assets/wc-live-z1Woib4_.js +0 -8
- package/dist/ui/assets/xai-grok-9vAl224Q.js +0 -1
- /package/dist/ui/assets/{session-store-DQztDoVa.js → chat-session-store-DQztDoVa.js} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/fs-
|
|
2
|
-
import{S as e,d as t,z as n}from"./account-store-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/fs-DIJccx8q.js","assets/preload-helper-Czpn1I53.js","assets/logger-DDBAeTLF.js","assets/types-idfTVsM8.js","assets/backend-local-smcj-_Ox.js","assets/tool-ui-DfXu6quJ.js","assets/picker-approval-CdWaB1mR.js","assets/mount-picker-popup-Bs1o43Z5.js","assets/rolldown-runtime-aKtaBQYM.js","assets/picker-popup-BvzmBsGL.js","assets/runtime-env-DH4NDw4t.js","assets/mount-table-store-CfQUN_2R.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{S as e,d as t,z as n}from"./account-store-DhS8k8-S.js";import{t as r}from"./preload-helper-Czpn1I53.js";import{i}from"./proxied-fetch-CfcFb0B0.js";import{r as a,t as o}from"./tray-runtime-config-9kTxza5l.js";import"./provider-settings-CXes7fTR.js";import{r as s,t as c}from"./silent-renew-backoff-CqD4WRin.js";import{getOAuthPageOrigin as l}from"./oauth-service-Dk3L2UWh.js";import{t as u}from"./global-db-CbuLl-zx.js";var d={clientId:``,scopes:`repo,read:user,user:email`};function f(){try{let e=localStorage.getItem(a);if(e)return e.replace(/\/$/,``)}catch{}return o}async function p(e){let t;try{t=await e.json()}catch{throw Error(`Token exchange failed (HTTP ${e.status}): non-JSON response`)}if(!e.ok&&e.status!==200){let n=t.error_description??t.error??`Token exchange failed (HTTP ${e.status})`;throw Error(n)}if(t.error){let e=t.error_description??t.error;throw Error(e)}return t}async function m(e){let t=`${f()}/oauth/token`;return p(await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e.provider,code:e.code,redirect_uri:e.redirectUri})}))}async function h(e){let t=`${f()}/oauth/token`;return p(await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e.provider,refresh_token:e.refreshToken})}))}async function g(e){let t=`${f()}/oauth/revoke`,n=await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e.provider,access_token:e.accessToken})});if(!(n.status===204||n.ok)){if(n.status===400)try{if((await n.json()).error===`unsupported`)return}catch{}throw Error(`Token revocation failed (HTTP ${n.status})`)}}var _=Object.assign({"/packages/webapp/providers/github-config.json":d})[`/packages/webapp/providers/github-config.json`]??{clientId:``,scopes:`repo,read:user,user:email`},v=null,y=null;function b(e){let{isExtension:t,isConnectMode:n,workerBaseUrl:r,pageOrigin:i,pageHref:a,bridgeApiBaseUrl:o,extensionId:c,nonce:l}=e;if(t)return{redirectUri:`${r}/auth/callback`,state:{source:`extension`,extensionId:c,path:`/github`,nonce:l}};if(n){let e=i??``;if(/^https?:\/\/(localhost|127\.0\.0\.1):\d+$/.test(e)){let t=parseInt(new URL(a??e).port||`8790`,10);return{redirectUri:`${r}/auth/callback`,state:{source:`local`,port:t,path:`/auth/callback`,nonce:l}}}return{redirectUri:`${r}/auth/callback`,state:{source:`remote`,origin:e,path:`/auth/callback`,nonce:l}}}if(o&&a&&s(a)){let t=null;try{let e=new URL(o);(e.hostname===`localhost`||e.hostname===`127.0.0.1`)&&(t=parseInt(e.port||`5710`,10))}catch{t=null}if(t!==null&&!Number.isNaN(t))return{redirectUri:`${e.runtimeWorkerBaseUrl??r}/auth/callback`,state:{source:`local`,port:t,path:`/auth/callback`,nonce:l}}}return{redirectUri:`${e.runtimeWorkerBaseUrl??i??``}/auth/callback`,state:{port:parseInt(new URL(a??i??`http://localhost:5710`).port||`5710`,10),path:`/auth/callback`,nonce:l}}}async function x(){if(v)return v;if(S){try{let e=await fetch(`${f()}/api/runtime-config`);if(e.ok){let t=await e.json();if(t.oauth?.github)return v=t.oauth.github,v}}catch{}return _.clientId}try{let e=await fetch(`/api/runtime-config`);if(e.ok){let t=await e.json();if(t.oauth?.github)return v=t.oauth.github,t.trayWorkerBaseUrl&&(y=t.trayWorkerBaseUrl),v;if(t.trayWorkerBaseUrl){y=t.trayWorkerBaseUrl;let e=await fetch(`${t.trayWorkerBaseUrl}/api/runtime-config`);if(e.ok){let t=await e.json();if(t.oauth?.github)return v=t.oauth.github,v}}}}catch{}return _.clientId}var S=typeof globalThis<`u`&&typeof globalThis.chrome?.runtime?.id==`string`;function C(){return t().find(e=>e.providerId===`github`)}function w(e){try{return new URL(e).searchParams.get(`code`)}catch{return null}}async function T(e){try{let t=await fetch(`https://api.github.com/user`,{headers:{Authorization:`Bearer ${e}`,Accept:`application/vnd.github+json`}});if(t.ok){let e=await t.json();return{name:e.name||e.login,avatar:e.avatar_url,login:e.login,id:e.id}}}catch(e){console.warn(`[github] Failed to fetch user profile:`,e instanceof Error?e.message:String(e))}return{}}function E(e,t){return`${e}+${t}@users.noreply.github.com`}async function D(e){try{let{VirtualFS:t}=await r(async()=>{let{VirtualFS:e}=await import(`./fs-DIJccx8q.js`);return{VirtualFS:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]));await(await t.create({dbName:u})).writeFile(`/workspace/.git/github-token`,e),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`github-token-changed`))}catch(e){console.warn(`[github] Failed to write git token:`,e instanceof Error?e.message:String(e))}}async function O(){try{let{VirtualFS:e}=await r(async()=>{let{VirtualFS:e}=await import(`./fs-DIJccx8q.js`);return{VirtualFS:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]));await(await e.create({dbName:u})).rm(`/workspace/.git/github-token`),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`github-token-changed`))}catch{}}async function k(e){if(!(!e.login||e.id===void 0))try{let{VirtualFS:t}=await r(async()=>{let{VirtualFS:e}=await import(`./fs-DIJccx8q.js`);return{VirtualFS:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])),{readGlobalGitConfigValue:n,writeGlobalGitConfigValue:i}=await r(async()=>{let{readGlobalGitConfigValue:e,writeGlobalGitConfigValue:t}=await import(`./git-config-DLJIrKjL.js`);return{readGlobalGitConfigValue:e,writeGlobalGitConfigValue:t}},[]),a=await t.create({dbName:u}),o=e.name||e.login,s=E(e.id,e.login);!await n(a,`user.name`)&&o&&await i(a,`user.name`,o),await n(a,`user.email`)||await i(a,`user.email`,s)}catch(e){console.warn(`[github] Failed to seed git identity:`,e instanceof Error?e.message:String(e))}}var A=c();async function j(){try{let t=C();if(!t?.refreshToken)return null;let r=await h({provider:`github`,refreshToken:t.refreshToken});await n({providerId:`github`,accessToken:r.access_token,refreshToken:r.refresh_token,tokenExpiresAt:r.expires_in?Date.now()+r.expires_in*1e3:void 0,userName:t.userName,userAvatar:t.userAvatar});let i=e(`github`)?.maskedValue;return i?await D(i):await O(),r.access_token}catch(e){return console.warn(`[github] Silent renewal failed:`,e instanceof Error?e.message:String(e)),null}}async function M(){let e=C();if(!e?.accessToken)throw Error(`Not logged in to GitHub — please log in first`);if((e.tokenExpiresAt??1/0)-Date.now()>6e4)return e.accessToken;let t=await A.run(()=>j());if(t)return t;let n=C();if((n?.tokenExpiresAt??1/0)-Date.now()>0&&n?.accessToken)return n.accessToken;throw Error(`GitHub session expired — please log in again`)}var N={id:`github`,name:`GitHub`,description:"Sign in with GitHub for git authentication (push/pull/clone) and the `oauth-token github` shell command. Does not expose LLM models — use the GitHub Copilot provider for those.",requiresApiKey:!1,requiresBaseUrl:!1,isOAuth:!0,oauthTokenDomains:[`github.com`,`*.github.com`,`api.github.com`,`raw.githubusercontent.com`],getModelIds:()=>[],onOAuthLogin:async(t,r,a)=>{let o=await x();if(!o)throw Error(`GitHub OAuth not configured — no client ID available`);let s=a?.scopes??_.scopes,c=S?null:await l(),u=crypto.randomUUID(),d=S?chrome.runtime.id:``,{redirectUri:p,state:h}=b({isExtension:S,isConnectMode:!!globalThis.__slicc_connect_mode,workerBaseUrl:f(),runtimeWorkerBaseUrl:y,pageOrigin:c?.origin??null,pageHref:c?.href??null,bridgeApiBaseUrl:i(),extensionId:d,nonce:u}),g=btoa(JSON.stringify(h)),v=u,C=new URLSearchParams({client_id:o,scope:s,redirect_uri:p});g&&C.set(`state`,g);let E=await t(`https://github.com/login/oauth/authorize?${C}`);if(!E)return;if(v)try{if(new URL(E).searchParams.get(`nonce`)!==v){console.error(`[github] OAuth nonce mismatch — possible CSRF`);return}}catch(e){console.warn(`[github] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}let A=w(E);if(!A){console.error(`[github] Could not extract authorization code from redirect URL`);return}let j=await m({provider:`github`,code:A,redirectUri:p}),M=await T(j.access_token);await n({providerId:`github`,accessToken:j.access_token,refreshToken:j.refresh_token,tokenExpiresAt:j.expires_in?Date.now()+j.expires_in*1e3:void 0,userName:M.name,userAvatar:M.avatar});let N=e(`github`)?.maskedValue;N?await D(N):await O(),await k(M),r()},onSilentRenew:j,getValidAccessToken:M,onOAuthLogout:async()=>{let e=C();e?.accessToken&&await g({provider:`github`,accessToken:e.accessToken}).catch(e=>console.warn(`[github] Token revocation failed:`,e instanceof Error?e.message:String(e))),await O(),await n({providerId:`github`,accessToken:``})},getOAuthLogoutUrl:e=>`https://github.com/logout`};export{E as buildNoreplyEmail,N as config,w as extractCodeFromUrl,M as getValidAccessToken,b as resolveGithubOAuthRedirect,k as syncGitIdentityFromGitHub};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./event-stream-qbAZIAKV.js";import{o as t,r as n,s as r}from"./transform-messages-Bp94o3FD.js";import{n as i}from"./headers-CbDaTl3c.js";import{t as a}from"./sanitize-unicode-DmIE6hZJ.js";import{n as o,t as s}from"./error-body-C0EnfbdK.js";import{a as c,c as l,i as u,n as d,o as f,r as p,s as m,t as h}from"./google-shared-BAKd3aSn.js";let g=0;const _=(n,r,i)=>{let a=new e;return(async()=>{let e={role:`assistant`,content:[],api:`google-generative-ai`,provider:n.provider,model:n.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 o=i?.apiKey;if(!o)throw Error(`No API key for provider: ${n.provider}`);let s=y(n,o,i?.headers),c=b(n,r,i),l=await i?.onPayload?.(c,n);l!==void 0&&(c=l);let d=await s.models.generateContentStream(c);a.push({type:`start`,partial:e});let m=null,h=e.content,_=()=>h.length-1;for await(let r of d){e.responseId||=r.responseId;let i=r.candidates?.[0];if(i?.content?.parts)for(let t of i.content.parts){if(t.text!==void 0){let n=p(t);(!m||n&&m.type!==`thinking`||!n&&m.type!==`text`)&&(m&&(m.type===`text`?a.push({type:`text_end`,contentIndex:h.length-1,content:m.text,partial:e}):a.push({type:`thinking_end`,contentIndex:_(),content:m.thinking,partial:e})),n?(m={type:`thinking`,thinking:``,thinkingSignature:void 0},e.content.push(m),a.push({type:`thinking_start`,contentIndex:_(),partial:e})):(m={type:`text`,text:``},e.content.push(m),a.push({type:`text_start`,contentIndex:_(),partial:e}))),m.type===`thinking`?(m.thinking+=t.text,m.thinkingSignature=f(m.thinkingSignature,t.thoughtSignature),a.push({type:`thinking_delta`,contentIndex:_(),delta:t.text,partial:e})):(m.text+=t.text,m.textSignature=f(m.textSignature,t.thoughtSignature),a.push({type:`text_delta`,contentIndex:_(),delta:t.text,partial:e}))}if(t.functionCall){m&&=(m.type===`text`?a.push({type:`text_end`,contentIndex:_(),content:m.text,partial:e}):a.push({type:`thinking_end`,contentIndex:_(),content:m.thinking,partial:e}),null);let n=t.functionCall.id,r={type:`toolCall`,id:!n||e.content.some(e=>e.type===`toolCall`&&e.id===n)?`${t.functionCall.name}_${Date.now()}_${++g}`:n,name:t.functionCall.name||``,arguments:t.functionCall.args??{},...t.thoughtSignature&&{thoughtSignature:t.thoughtSignature}};e.content.push(r),a.push({type:`toolcall_start`,contentIndex:_(),partial:e}),a.push({type:`toolcall_delta`,contentIndex:_(),delta:JSON.stringify(r.arguments),partial:e}),a.push({type:`toolcall_end`,contentIndex:_(),toolCall:r,partial:e})}}i?.finishReason&&(e.stopReason=u(i.finishReason),e.content.some(e=>e.type===`toolCall`)&&(e.stopReason=`toolUse`)),r.usageMetadata&&(e.usage={input:(r.usageMetadata.promptTokenCount||0)-(r.usageMetadata.cachedContentTokenCount||0),output:(r.usageMetadata.candidatesTokenCount||0)+(r.usageMetadata.thoughtsTokenCount||0),cacheRead:r.usageMetadata.cachedContentTokenCount||0,cacheWrite:0,reasoning:r.usageMetadata.thoughtsTokenCount||0,totalTokens:r.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},t(n,e.usage))}if(m&&(m.type===`text`?a.push({type:`text_end`,contentIndex:_(),content:m.text,partial:e}):a.push({type:`thinking_end`,contentIndex:_(),content:m.thinking,partial:e})),i?.signal?.aborted)throw Error(`Request was aborted`);if(e.stopReason===`aborted`||e.stopReason===`error`)throw Error(`An unknown error occurred`);a.push({type:`done`,reason:e.stopReason,message:e}),a.end()}catch(t){for(let t of e.content)`index`in t&&delete t.index;e.stopReason=i?.signal?.aborted?`aborted`:`error`,e.errorMessage=s(o(t)),a.push({type:`error`,reason:e.stopReason,error:e}),a.end()}})(),a},v=(e,t,i)=>{let a=i?.apiKey;if(!a)throw Error(`No API key for provider: ${e.provider}`);let o=n(e,t,i,a);if(!i?.reasoning)return _(e,t,{...o,thinking:{enabled:!1}});let s=r(e,i.reasoning),c=s===`off`?`high`:s,l=e;return S(l)||C(l)||x(l)?_(e,t,{...o,thinking:{enabled:!0,level:T(c,l)}}):_(e,t,{...o,thinking:{enabled:!0,budgetTokens:E(l,c,i.thinkingBudgets)}})};function y(e,t,n){let r={};e.baseUrl&&(r.baseUrl=e.baseUrl,r.apiVersion=``);let a=i({...e.headers,...n});return a&&(r.headers=a),new l({apiKey:t,httpOptions:Object.keys(r).length>0?r:void 0})}function b(e,t,n={}){let r=h(e,t),i={};n.temperature!==void 0&&(i.temperature=n.temperature),n.maxTokens!==void 0&&(i.maxOutputTokens=n.maxTokens);let o=t.tools?.length?c(t.tools,n.toolChoice,m(e.id)):void 0,s={...Object.keys(i).length>0&&i,...t.systemPrompt&&{systemInstruction:a(t.systemPrompt)},...t.tools&&t.tools.length>0&&{tools:d(t.tools)},...o!==void 0&&{toolConfig:{functionCallingConfig:{mode:o}}}};if(n.thinking?.enabled&&e.reasoning){let e={includeThoughts:!0};n.thinking.level===void 0?n.thinking.budgetTokens!==void 0&&(e.thinkingBudget=n.thinking.budgetTokens):e.thinkingLevel=n.thinking.level,s.thinkingConfig=e}else e.reasoning&&n.thinking&&!n.thinking.enabled&&(s.thinkingConfig=w(e));if(n.signal){if(n.signal.aborted)throw Error(`Request aborted`);s.abortSignal=n.signal}return{model:e.id,contents:r,config:s}}function x(e){return/gemma-?4/.test(e.id.toLowerCase())}function S(e){return/gemini-3(?:\.\d+)?-pro/.test(e.id.toLowerCase())}function C(e){let t=e.id.toLowerCase();return/gemini-3(?:\.\d+)?-flash/.test(t)||t===`gemini-flash-latest`||t===`gemini-flash-lite-latest`}function w(e){return S(e)?{thinkingLevel:`LOW`}:C(e)||x(e)?{thinkingLevel:`MINIMAL`}:{thinkingBudget:0}}function T(e,t){if(S(t))switch(e){case`minimal`:case`low`:return`LOW`;case`medium`:case`high`:return`HIGH`}if(x(t))switch(e){case`minimal`:case`low`:return`MINIMAL`;case`medium`:case`high`:return`HIGH`}switch(e){case`minimal`:return`MINIMAL`;case`low`:return`LOW`;case`medium`:return`MEDIUM`;case`high`:return`HIGH`}}function E(e,t,n){return n?.[t]===void 0?e.id.includes(`2.5-pro`)?{minimal:128,low:2048,medium:8192,high:32768}[t]:e.id.includes(`2.5-flash-lite`)?{minimal:512,low:2048,medium:8192,high:24576}[t]:e.id.includes(`2.5-flash`)?{minimal:128,low:2048,medium:8192,high:24576}[t]:-1:n[t]}export{_ as stream,v as streamSimple};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e,t}from"./rolldown-runtime-aKtaBQYM.js";import{t as n}from"./transform-messages-
|
|
1
|
+
import{i as e,t}from"./rolldown-runtime-aKtaBQYM.js";import{t as n}from"./transform-messages-Bp94o3FD.js";import{t as r}from"./sanitize-unicode-DmIE6hZJ.js";import{a as i}from"./constrained-sampling-DafcjXU6.js";var a=t(((e,t)=>{function n(e,t){typeof t==`boolean`&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}t.exports=n,n.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)},n.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null},n.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.push(e),this._errors.unshift(Error(`RetryOperation timeout occurred`)),!1;this._errors.push(e);var n=this._timeouts.shift();if(n===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),n=this._cachedTimeouts.slice(-1);else return!1;var r=this;return this._timer=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},n),this._options.unref&&this._timer.unref(),!0},n.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){n._operationTimeoutCb()},n._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)},n.prototype.try=function(e){console.log(`Using RetryOperation.try() is deprecated`),this.attempt(e)},n.prototype.start=function(e){console.log(`Using RetryOperation.start() is deprecated`),this.attempt(e)},n.prototype.start=n.prototype.try,n.prototype.errors=function(){return this._errors},n.prototype.attempts=function(){return this._attempts},n.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},t=null,n=0,r=0;r<this._errors.length;r++){var i=this._errors[r],a=i.message,o=(e[a]||0)+1;e[a]=o,o>=n&&(t=i,n=o)}return t}})),o=t((e=>{var t=a();e.operation=function(n){return new t(e.timeouts(n),{forever:n&&(n.forever||n.retries===1/0),unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})},e.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var n in e)t[n]=e[n];if(t.minTimeout>t.maxTimeout)throw Error(`minTimeout is greater than maxTimeout`);for(var r=[],i=0;i<t.retries;i++)r.push(this.createTimeout(i,t));return e&&e.forever&&!r.length&&r.push(this.createTimeout(i,t)),r.sort(function(e,t){return e-t}),r},e.createTimeout=function(e,t){var n=t.randomize?Math.random()+1:1,r=Math.round(n*Math.max(t.minTimeout,1)*t.factor**+e);return r=Math.min(r,t.maxTimeout),r},e.wrap=function(t,n,r){if(n instanceof Array&&(r=n,n=null),!r)for(var i in r=[],t)typeof t[i]==`function`&&r.push(i);for(var a=0;a<r.length;a++){var o=r[a],s=t[o];t[o]=function(r){var i=e.operation(n),a=Array.prototype.slice.call(arguments,1),o=a.pop();a.push(function(e){i.retry(e)||(e&&(arguments[0]=i.mainError()),o.apply(this,arguments))}),i.attempt(function(){r.apply(t,a)})}.bind(t,s),t[o].options=n}}})),s=t(((e,t)=>{t.exports=o()})),c=e(t(((e,t)=>{let n=s(),r=[`Failed to fetch`,`NetworkError when attempting to fetch resource.`,`The Internet connection appears to be offline.`,`Network request failed`];var i=class extends Error{constructor(e){super(),e instanceof Error?(this.originalError=e,{message:e}=e):(this.originalError=Error(e),this.originalError.stack=this.stack),this.name=`AbortError`,this.message=e}};let a=(e,t,n)=>{let r=n.retries-(t-1);return e.attemptNumber=t,e.retriesLeft=r,e},o=e=>r.includes(e),c=(e,t)=>new Promise((r,s)=>{t={onFailedAttempt:()=>{},retries:10,...t};let c=n.operation(t);c.attempt(async n=>{try{r(await e(n))}catch(e){if(!(e instanceof Error)){s(TypeError(`Non-error was thrown: "${e}". You should only throw errors.`));return}if(e instanceof i)c.stop(),s(e.originalError);else if(e instanceof TypeError&&!o(e.message))c.stop(),s(e);else{a(e,n,t);try{await t.onFailedAttempt(e)}catch(e){s(e);return}c.retry(e)||s(c.mainError())}}})});t.exports=c,t.exports.default=c,t.exports.AbortError=i}))(),1)
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2025 Google LLC
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./event-stream-qbAZIAKV.js";import{o as t,r as n,s as r}from"./transform-messages-Bp94o3FD.js";import{t as i}from"./provider-env-DwY8YuMk.js";import{n as a}from"./headers-CbDaTl3c.js";import{t as o}from"./sanitize-unicode-DmIE6hZJ.js";import{n as s,t as c}from"./error-body-C0EnfbdK.js";import{a as l,c as u,i as d,l as f,n as p,o as m,r as h,s as g,t as _,u as v}from"./google-shared-BAKd3aSn.js";const y={THINKING_LEVEL_UNSPECIFIED:v.THINKING_LEVEL_UNSPECIFIED,MINIMAL:v.MINIMAL,LOW:v.LOW,MEDIUM:v.MEDIUM,HIGH:v.HIGH};let b=0;const x=(n,r,i)=>{let a=new e;return(async()=>{let e={role:`assistant`,content:[],api:`google-vertex`,provider:n.provider,model:n.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 o=k(i),s=o?w(n,o,i?.headers):C(n,j(i),M(i),i?.headers,i?.env),c=N(n,r,i),l=await i?.onPayload?.(c,n);l!==void 0&&(c=l);let u=await s.models.generateContentStream(c);a.push({type:`start`,partial:e});let f=null,p=e.content,g=()=>p.length-1;for await(let r of u){e.responseId||=r.responseId;let i=r.candidates?.[0];if(i?.content?.parts)for(let t of i.content.parts){if(t.text!==void 0){let n=h(t);(!f||n&&f.type!==`thinking`||!n&&f.type!==`text`)&&(f&&(f.type===`text`?a.push({type:`text_end`,contentIndex:p.length-1,content:f.text,partial:e}):a.push({type:`thinking_end`,contentIndex:g(),content:f.thinking,partial:e})),n?(f={type:`thinking`,thinking:``,thinkingSignature:void 0},e.content.push(f),a.push({type:`thinking_start`,contentIndex:g(),partial:e})):(f={type:`text`,text:``},e.content.push(f),a.push({type:`text_start`,contentIndex:g(),partial:e}))),f.type===`thinking`?(f.thinking+=t.text,f.thinkingSignature=m(f.thinkingSignature,t.thoughtSignature),a.push({type:`thinking_delta`,contentIndex:g(),delta:t.text,partial:e})):(f.text+=t.text,f.textSignature=m(f.textSignature,t.thoughtSignature),a.push({type:`text_delta`,contentIndex:g(),delta:t.text,partial:e}))}if(t.functionCall){f&&=(f.type===`text`?a.push({type:`text_end`,contentIndex:g(),content:f.text,partial:e}):a.push({type:`thinking_end`,contentIndex:g(),content:f.thinking,partial:e}),null);let n=t.functionCall.id,r={type:`toolCall`,id:!n||e.content.some(e=>e.type===`toolCall`&&e.id===n)?`${t.functionCall.name}_${Date.now()}_${++b}`:n,name:t.functionCall.name||``,arguments:t.functionCall.args??{},...t.thoughtSignature&&{thoughtSignature:t.thoughtSignature}};e.content.push(r),a.push({type:`toolcall_start`,contentIndex:g(),partial:e}),a.push({type:`toolcall_delta`,contentIndex:g(),delta:JSON.stringify(r.arguments),partial:e}),a.push({type:`toolcall_end`,contentIndex:g(),toolCall:r,partial:e})}}i?.finishReason&&(e.stopReason=d(i.finishReason),e.content.some(e=>e.type===`toolCall`)&&(e.stopReason=`toolUse`)),r.usageMetadata&&(e.usage={input:(r.usageMetadata.promptTokenCount||0)-(r.usageMetadata.cachedContentTokenCount||0),output:(r.usageMetadata.candidatesTokenCount||0)+(r.usageMetadata.thoughtsTokenCount||0),cacheRead:r.usageMetadata.cachedContentTokenCount||0,cacheWrite:0,reasoning:r.usageMetadata.thoughtsTokenCount||0,totalTokens:r.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},t(n,e.usage))}if(f&&(f.type===`text`?a.push({type:`text_end`,contentIndex:g(),content:f.text,partial:e}):a.push({type:`thinking_end`,contentIndex:g(),content:f.thinking,partial:e})),i?.signal?.aborted)throw Error(`Request was aborted`);if(e.stopReason===`aborted`||e.stopReason===`error`)throw Error(`An unknown error occurred`);a.push({type:`done`,reason:e.stopReason,message:e}),a.end()}catch(t){for(let t of e.content)`index`in t&&delete t.index;e.stopReason=i?.signal?.aborted?`aborted`:`error`,e.errorMessage=c(s(t)),a.push({type:`error`,reason:e.stopReason,error:e}),a.end()}})(),a},S=(e,t,i)=>{let a=n(e,t,i,void 0);if(!i?.reasoning)return x(e,t,{...a,thinking:{enabled:!1}});let o=r(e,i.reasoning),s=o===`off`?`high`:o,c=e;return P(c)||F(c)?x(e,t,{...a,thinking:{enabled:!0,level:L(s,c)}}):x(e,t,{...a,thinking:{enabled:!0,budgetTokens:R(c,s,i.thinkingBudgets)}})};function C(e,t,n,r,i){let a=O(i);return new u({vertexai:!0,project:t,location:n,apiVersion:`v1`,...a?{googleAuthOptions:a}:{},httpOptions:T(e,r)})}function w(e,t,n){return new u({vertexai:!0,apiKey:t,apiVersion:`v1`,httpOptions:T(e,n)})}function T(e,t){let n={},r=E(e.baseUrl);r&&(n.baseUrl=r,n.baseUrlResourceScope=f.COLLECTION,D(r)&&(n.apiVersion=``));let i=a({...e.headers,...t});return i&&(n.headers=i),Object.keys(n).length>0?n:void 0}function E(e){let t=e.trim();if(!(!t||t.includes(`{location}`)))return t}function D(e){try{return new URL(e).pathname.split(`/`).some(e=>/^v\d+(?:beta\d*)?$/.test(e))}catch{return/(?:^|\/)v\d+(?:beta\d*)?(?:\/|$)/.test(e)}}function O(e){let t=i(`GOOGLE_APPLICATION_CREDENTIALS`,e);return t?{keyFilename:t}:void 0}function k(e){let t=e?.apiKey?.trim();if(!(!t||t===`gcp-vertex-credentials`||A(t)))return t}function A(e){return/^<[^>]+>$/.test(e)}function j(e){let t=e?.project||i(`GOOGLE_CLOUD_PROJECT`,e?.env)||i(`GCLOUD_PROJECT`,e?.env);if(!t)throw Error(`Vertex AI requires a project ID. Set GOOGLE_CLOUD_PROJECT/GCLOUD_PROJECT or pass project in options.`);return t}function M(e){let t=e?.location||i(`GOOGLE_CLOUD_LOCATION`,e?.env);if(!t)throw Error(`Vertex AI requires a location. Set GOOGLE_CLOUD_LOCATION or pass location in options.`);return t}function N(e,t,n={}){let r=_(e,t),i={};n.temperature!==void 0&&(i.temperature=n.temperature),n.maxTokens!==void 0&&(i.maxOutputTokens=n.maxTokens);let a=t.tools?.length?l(t.tools,n.toolChoice,g(e.id)):void 0,s={...Object.keys(i).length>0&&i,...t.systemPrompt&&{systemInstruction:o(t.systemPrompt)},...t.tools&&t.tools.length>0&&{tools:p(t.tools)},...a!==void 0&&{toolConfig:{functionCallingConfig:{mode:a}}}};if(n.thinking?.enabled&&e.reasoning){let e={includeThoughts:!0};n.thinking.level===void 0?n.thinking.budgetTokens!==void 0&&(e.thinkingBudget=n.thinking.budgetTokens):e.thinkingLevel=y[n.thinking.level],s.thinkingConfig=e}else e.reasoning&&n.thinking&&!n.thinking.enabled&&(s.thinkingConfig=I(e));if(n.signal){if(n.signal.aborted)throw Error(`Request aborted`);s.abortSignal=n.signal}return{model:e.id,contents:r,config:s}}function P(e){return/gemini-3(?:\.\d+)?-pro/.test(e.id.toLowerCase())}function F(e){let t=e.id.toLowerCase();return/gemini-3(?:\.\d+)?-flash/.test(t)||t===`gemini-flash-latest`||t===`gemini-flash-lite-latest`}function I(e){let t=e;return P(t)?{thinkingLevel:v.LOW}:F(t)?{thinkingLevel:v.MINIMAL}:{thinkingBudget:0}}function L(e,t){if(P(t))switch(e){case`minimal`:case`low`:return`LOW`;case`medium`:case`high`:return`HIGH`}switch(e){case`minimal`:return`MINIMAL`;case`low`:return`LOW`;case`medium`:return`MEDIUM`;case`high`:return`HIGH`}}function R(e,t,n){return n?.[t]===void 0?e.id.includes(`2.5-pro`)?{minimal:128,low:2048,medium:8192,high:32768}[t]:e.id.includes(`2.5-flash`)?{minimal:128,low:2048,medium:8192,high:24576}[t]:-1:n[t]}export{x as stream,S as streamSimple};
|