sliccy 3.23.2 → 3.24.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 (83) hide show
  1. package/dist/ui/assets/{adobe-D_Vugf80.js → adobe-DCmk0Yjs.js} +1 -1
  2. package/dist/ui/assets/{adobe-xcpfIdRj.js → adobe-DuGjWsAB.js} +2 -2
  3. package/dist/ui/assets/{agent-bridge-D-rPsRyB.js → agent-bridge-B5ntabFw.js} +1 -1
  4. package/dist/ui/assets/{agent-message-to-chat-D8QrXH4U.js → agent-message-to-chat-FHeeyH4g.js} +1 -1
  5. package/dist/ui/assets/{anthropic-Dtyagoir.js → anthropic-CvkR6nsg.js} +1 -1
  6. package/dist/ui/assets/{anthropic-DzGu5Vy6.js → anthropic-_c4IJIJc.js} +1 -1
  7. package/dist/ui/assets/{apps-BFfIpvJ_.js → apps-M2Aa7hBa.js} +1 -1
  8. package/dist/ui/assets/{azure-openai-D9cMP_Fj.js → azure-openai-B8CdsRHU.js} +1 -1
  9. package/dist/ui/assets/{azure-openai-CjMzlRs0.js → azure-openai-CJoVnOXi.js} +1 -1
  10. package/dist/ui/assets/{azure-openai-responses-LiaaDPcJ.js → azure-openai-responses-4Ibq2iLZ.js} +1 -1
  11. package/dist/ui/assets/{azure-openai-responses-DJIV1DiX.js → azure-openai-responses-DxO2YRYD.js} +1 -1
  12. package/dist/ui/assets/{biome_wasm-DILoyHYz.js → biome_wasm-DDPDUXo8.js} +1 -1
  13. package/dist/ui/assets/{bsh-watchdog-Q9N25_0z.js → bsh-watchdog-CDk7M3ke.js} +1 -1
  14. package/dist/ui/assets/{cdp-CUD-ZSn-.js → cdp-BOxBJGjg.js} +3 -3
  15. package/dist/ui/assets/{cdp-ws-page-bridge-DFPNsTYM.js → cdp-ws-page-bridge-DfqKeVqO.js} +1 -1
  16. package/dist/ui/assets/{common-BLw2Nl-J.js → common-T5gU4oRn.js} +1 -1
  17. package/dist/ui/assets/cost-command-fG_A-GvW.js +1 -0
  18. package/dist/ui/assets/{es-Cv0XkUMG.js → es-DS6manEM.js} +1 -1
  19. package/dist/ui/assets/{follower-sprinkle-bridge-BavA0y-a.js → follower-sprinkle-bridge-CSHtoxPF.js} +1 -1
  20. package/dist/ui/assets/{github-D12QW14k.js → github-BeDakA_T.js} +2 -2
  21. package/dist/ui/assets/{github-copilot-IJf0jSNt.js → github-copilot-6OeNfzot.js} +1 -1
  22. package/dist/ui/assets/{github-copilot-Bs5NPvgU.js → github-copilot-BXGQqXDl.js} +2 -2
  23. package/dist/ui/assets/{github-Di28abu4.js → github-z8aoms6H.js} +1 -1
  24. package/dist/ui/assets/{google-BA98QhNu.js → google-BzqydtPy.js} +1 -1
  25. package/dist/ui/assets/{google-CPKtCy-G.js → google-D4KuY-rc.js} +1 -1
  26. package/dist/ui/assets/{google-shared-CgUd6GQm.js → google-shared-BMl3Xihh.js} +1 -1
  27. package/dist/ui/assets/{google-shared-DkyMo0mW.js → google-shared-DbLcpQyZ.js} +1 -1
  28. package/dist/ui/assets/{google-vertex-hAuGJ52e.js → google-vertex-DfjIFr8M.js} +1 -1
  29. package/dist/ui/assets/{google-vertex-C-aVeSbm.js → google-vertex-DoweO0I9.js} +1 -1
  30. package/dist/ui/assets/{intercepted-oauth-pM-BGD58.js → intercepted-oauth-CwEK-L0K.js} +1 -1
  31. package/dist/ui/assets/{kernel-worker-CplizLfv.js → kernel-worker-DaPtM-8x.js} +822 -822
  32. package/dist/ui/assets/{lick-ws-bridge-Bkz1htb0.js → lick-ws-bridge-CQ1tPlmR.js} +1 -1
  33. package/dist/ui/assets/{local-llm-tWVawqAZ.js → local-llm-DFPI3n32.js} +1 -1
  34. package/dist/ui/assets/{magick-wasm-D5OOE7EJ.js → magick-wasm-chBeilAX.js} +1 -1
  35. package/dist/ui/assets/{main-CHCnJnQN.js → main-D7VEsE-b.js} +9 -9
  36. package/dist/ui/assets/{mistral-7XK8ILdS.js → mistral-B5O4swNv.js} +1 -1
  37. package/dist/ui/assets/{mistral-BiWQi-Q6.js → mistral-Dfb9V64D.js} +1 -1
  38. package/dist/ui/assets/{nodejs-BkZc6PQH.js → nodejs-DI_LeGHw.js} +1 -1
  39. package/dist/ui/assets/{nuke-command-D9F-SaCE.js → nuke-command-B4El21LL.js} +1 -1
  40. package/dist/ui/assets/{oauth-bootstrap-CF2U0zkY.js → oauth-bootstrap-BjjrrmHO.js} +2 -2
  41. package/dist/ui/assets/{oauth-BBPIyKim.js → oauth-rzfgWWpg.js} +1 -1
  42. package/dist/ui/assets/{oauth-service-ERwyg8Sp.js → oauth-service-B552XGCl.js} +1 -1
  43. package/dist/ui/assets/{oauth-service-DK0AQV_B.js → oauth-service-aZp7J_hU.js} +1 -1
  44. package/dist/ui/assets/{offscreen-client-C-HybLAA.js → offscreen-client-rCGcmXFf.js} +1 -1
  45. package/dist/ui/assets/{onboarding-orchestrator-q_dw4jTj.js → onboarding-orchestrator-PRA-OCd9.js} +1 -1
  46. package/dist/ui/assets/{openai-codex-Dis6-HzW.js → openai-codex-PDs5X775.js} +1 -1
  47. package/dist/ui/assets/{openai-codex-CKIJ_djo.js → openai-codex-lqYLYvJs.js} +1 -1
  48. package/dist/ui/assets/{openai-codex-responses-B1mnlbR0.js → openai-codex-responses-CajaR5X4.js} +1 -1
  49. package/dist/ui/assets/{openai-codex-responses-DTOZv7ds.js → openai-codex-responses-ZZCmgEBr.js} +1 -1
  50. package/dist/ui/assets/{openai-completions-DEKTYAs0.js → openai-completions-xWVk5G_p.js} +1 -1
  51. package/dist/ui/assets/{openai-responses-DZq9SNe1.js → openai-responses-CkjNHcYP.js} +1 -1
  52. package/dist/ui/assets/{openai-responses-DdPu4D27.js → openai-responses-azyXFv_t.js} +1 -1
  53. package/dist/ui/assets/{openai-responses-shared-BO_vXKUY.js → openai-responses-shared-Bo-TQs1Z.js} +1 -1
  54. package/dist/ui/assets/{openai-responses-shared-Bpr6gUIV.js → openai-responses-shared-jzF_QKPJ.js} +1 -1
  55. package/dist/ui/assets/{openrouter-sGm2CoIh.js → openrouter-DmnYeH2b.js} +1 -1
  56. package/dist/ui/assets/{openrouter-BWyBMaJk.js → openrouter-Hn0subU6.js} +1 -1
  57. package/dist/ui/assets/panel-rpc-handlers-B3PQoGQd.js +1 -0
  58. package/dist/ui/assets/{provider-BbVTh-k4.js → provider-C8dSaOb7.js} +1 -1
  59. package/dist/ui/assets/provider-store-access-Bq_zzlXN.js +1 -0
  60. package/dist/ui/assets/provider-store-access-CvTifuQZ.js +1 -0
  61. package/dist/ui/assets/{provider-CaJ2hVUo.js → provider-ygPhwwcO.js} +2 -2
  62. package/dist/ui/assets/{proxied-fetch-D24a0F7e.js → proxied-fetch-SaHs3JCC.js} +1 -1
  63. package/dist/ui/assets/{pyodide-C_KurNw9.js → pyodide-Uvhe43JY.js} +2 -2
  64. package/dist/ui/assets/{remote-terminal-view-CJvKEhzM.js → remote-terminal-view-rBU4vKLy.js} +1 -1
  65. package/dist/ui/assets/{secret-env-8LsY1D5V.js → secret-env-CdkPe-KX.js} +1 -1
  66. package/dist/ui/assets/{slicc-editor--ueqTKSL.js → slicc-editor-QIi0gOCN.js} +1 -1
  67. package/dist/ui/assets/{spawn-DiUZmxNj.js → spawn-BVZyMdgu.js} +1 -1
  68. package/dist/ui/assets/{sql-wasm-CE8UHQay.js → sql-wasm-DgXo5gk9.js} +1 -1
  69. package/dist/ui/assets/{store-CAvgWs2u.js → store-DggPJ0ca.js} +1 -1
  70. package/dist/ui/assets/{tray-leave-runtime-DB4sGbH0.js → tray-leave-runtime-CchhmhLg.js} +1 -1
  71. package/dist/ui/assets/{typescript-D2-l6K2R.js → typescript-BHOVx8Ug.js} +1 -1
  72. package/dist/ui/assets/{upgrade-detection-DiI90xNN.js → upgrade-detection-D_gZmzhj.js} +1 -1
  73. package/dist/ui/assets/{web-D-HxA_an.js → web-Bx1gb9T9.js} +1 -1
  74. package/dist/ui/assets/{ws-subscribers-DbDgvsk8.js → ws-subscribers-B0W73i_i.js} +1 -1
  75. package/dist/ui/assets/{xai-grok-ClPIZsB5.js → xai-grok-CsnDUpe1.js} +1 -1
  76. package/dist/ui/assets/{xai-grok-BQCbJ4jC.js → xai-grok-VBMzCWw_.js} +1 -1
  77. package/dist/ui/index.html +1 -1
  78. package/dist/ui/packages/webapp/index.html +1 -1
  79. package/package.json +1 -1
  80. package/dist/ui/assets/cost-command-Po1gR-Hi.js +0 -1
  81. package/dist/ui/assets/panel-rpc-handlers-BSkdF8o-.js +0 -1
  82. package/dist/ui/assets/provider-store-access-BAieyLsa.js +0 -1
  83. package/dist/ui/assets/provider-store-access-k5aUOcMc.js +0 -1
@@ -1 +1 @@
1
- import{T as e,b as t,h as n,ot as r,st as i,w as a}from"./kernel-worker-CplizLfv.js";import{getOAuthPageOrigin as o}from"./oauth-service-ERwyg8Sp.js";var s={clientId:``,scopes:`repo,read:user,user:email`};function c(){try{let e=localStorage.getItem(i);if(e)return e.replace(/\/$/,``)}catch{}return r}async function l(e){let t=`${c()}/oauth/token`,n=await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e.provider,code:e.code,redirect_uri:e.redirectUri})}),r;try{r=await n.json()}catch{throw Error(`Token exchange failed (HTTP ${n.status}): non-JSON response`)}if(!n.ok&&n.status!==200){let e=r.error_description??r.error??`Token exchange failed (HTTP ${n.status})`;throw Error(e)}if(r.error){let e=r.error_description??r.error;throw Error(e)}return r}async function u(e){let t=`${c()}/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})`)}}const d=Object.assign({"/packages/webapp/providers/github-config.json":s})[`/packages/webapp/providers/github-config.json`]??{clientId:``,scopes:`repo,read:user,user:email`};let f=null,p=null;async function m(){if(f)return f;if(h){try{let e=await fetch(`${c()}/api/runtime-config`);if(e.ok){let t=await e.json();if(t.oauth?.github)return f=t.oauth.github,f}}catch{}return d.clientId}try{let e=await fetch(`/api/runtime-config`);if(e.ok){let t=await e.json();if(t.oauth?.github)return f=t.oauth.github,f;if(t.trayWorkerBaseUrl){p=t.trayWorkerBaseUrl;let e=await fetch(`${t.trayWorkerBaseUrl}/api/runtime-config`);if(e.ok){let t=await e.json();if(t.oauth?.github)return f=t.oauth.github,f}}}}catch{}return d.clientId}const h=typeof chrome<`u`&&!!chrome?.runtime?.id;function g(){return t().find(e=>e.providerId===`github`)}function _(e){try{return new URL(e).searchParams.get(`code`)}catch{return null}}async function v(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 y(e,t){return`${e}+${t}@users.noreply.github.com`}async function b(e){try{let{VirtualFS:t}=await import(`./kernel-worker-CplizLfv.js`).then(e=>e.v);await(await t.create({dbName:n})).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 x(){try{let{VirtualFS:e}=await import(`./kernel-worker-CplizLfv.js`).then(e=>e.v);await(await e.create({dbName:n})).rm(`/workspace/.git/github-token`),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`github-token-changed`))}catch{}}async function S(e){if(!(!e.login||e.id===void 0))try{let{VirtualFS:t}=await import(`./kernel-worker-CplizLfv.js`).then(e=>e.v),{readGlobalGitConfigValue:r,writeGlobalGitConfigValue:i}=await import(`./kernel-worker-CplizLfv.js`).then(e=>e.m),a=await t.create({dbName:n}),o=e.name||e.login,s=y(e.id,e.login);!await r(a,`user.name`)&&o&&await i(a,`user.name`,o),await r(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))}}async function C(){let e=g();if(!e?.accessToken)throw Error(`Not logged in to GitHub — please log in first`);return e.accessToken}const w={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,n,r)=>{let i=await m();if(!i)throw Error(`GitHub OAuth not configured — no client ID available`);let s=r?.scopes??d.scopes,u=h?null:await o(),f=h?`${c()}/auth/callback`:`${p??u.origin}/auth/callback`,g=crypto.randomUUID(),y=h?chrome.runtime.id:``,C=h?{source:`extension`,extensionId:y,path:`/github`,nonce:g}:{port:parseInt(new URL(u.href).port||`5710`,10),path:`/auth/callback`,nonce:g},w=btoa(JSON.stringify(C)),T=g,E=new URLSearchParams({client_id:i,scope:s,redirect_uri:f});w&&E.set(`state`,w);let D=await t(`https://github.com/login/oauth/authorize?${E}`);if(!D)return;if(T)try{if(new URL(D).searchParams.get(`nonce`)!==T){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 O=_(D);if(!O){console.error(`[github] Could not extract authorization code from redirect URL`);return}let k=await l({provider:`github`,code:O,redirectUri:f}),A=await v(k.access_token);await e({providerId:`github`,accessToken:k.access_token,userName:A.name,userAvatar:A.avatar});let j=a(`github`)?.maskedValue;j?await b(j):await x(),await S(A),n()},onOAuthLogout:async()=>{let t=g();t?.accessToken&&await u({provider:`github`,accessToken:t.accessToken}).catch(e=>console.warn(`[github] Token revocation failed:`,e instanceof Error?e.message:String(e))),await x(),await e({providerId:`github`,accessToken:``})},getOAuthLogoutUrl:e=>`https://github.com/logout`};export{y as buildNoreplyEmail,w as config,_ as extractCodeFromUrl,C as getValidAccessToken,S as syncGitIdentityFromGitHub};
1
+ import{T as e,b as t,h as n,ot as r,st as i,w as a}from"./kernel-worker-DaPtM-8x.js";import{getOAuthPageOrigin as o}from"./oauth-service-B552XGCl.js";var s={clientId:``,scopes:`repo,read:user,user:email`};function c(){try{let e=localStorage.getItem(i);if(e)return e.replace(/\/$/,``)}catch{}return r}async function l(e){let t=`${c()}/oauth/token`,n=await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e.provider,code:e.code,redirect_uri:e.redirectUri})}),r;try{r=await n.json()}catch{throw Error(`Token exchange failed (HTTP ${n.status}): non-JSON response`)}if(!n.ok&&n.status!==200){let e=r.error_description??r.error??`Token exchange failed (HTTP ${n.status})`;throw Error(e)}if(r.error){let e=r.error_description??r.error;throw Error(e)}return r}async function u(e){let t=`${c()}/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})`)}}const d=Object.assign({"/packages/webapp/providers/github-config.json":s})[`/packages/webapp/providers/github-config.json`]??{clientId:``,scopes:`repo,read:user,user:email`};let f=null,p=null;async function m(){if(f)return f;if(h){try{let e=await fetch(`${c()}/api/runtime-config`);if(e.ok){let t=await e.json();if(t.oauth?.github)return f=t.oauth.github,f}}catch{}return d.clientId}try{let e=await fetch(`/api/runtime-config`);if(e.ok){let t=await e.json();if(t.oauth?.github)return f=t.oauth.github,f;if(t.trayWorkerBaseUrl){p=t.trayWorkerBaseUrl;let e=await fetch(`${t.trayWorkerBaseUrl}/api/runtime-config`);if(e.ok){let t=await e.json();if(t.oauth?.github)return f=t.oauth.github,f}}}}catch{}return d.clientId}const h=typeof chrome<`u`&&!!chrome?.runtime?.id;function g(){return t().find(e=>e.providerId===`github`)}function _(e){try{return new URL(e).searchParams.get(`code`)}catch{return null}}async function v(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 y(e,t){return`${e}+${t}@users.noreply.github.com`}async function b(e){try{let{VirtualFS:t}=await import(`./kernel-worker-DaPtM-8x.js`).then(e=>e.v);await(await t.create({dbName:n})).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 x(){try{let{VirtualFS:e}=await import(`./kernel-worker-DaPtM-8x.js`).then(e=>e.v);await(await e.create({dbName:n})).rm(`/workspace/.git/github-token`),typeof window<`u`&&window.dispatchEvent(new CustomEvent(`github-token-changed`))}catch{}}async function S(e){if(!(!e.login||e.id===void 0))try{let{VirtualFS:t}=await import(`./kernel-worker-DaPtM-8x.js`).then(e=>e.v),{readGlobalGitConfigValue:r,writeGlobalGitConfigValue:i}=await import(`./kernel-worker-DaPtM-8x.js`).then(e=>e.m),a=await t.create({dbName:n}),o=e.name||e.login,s=y(e.id,e.login);!await r(a,`user.name`)&&o&&await i(a,`user.name`,o),await r(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))}}async function C(){let e=g();if(!e?.accessToken)throw Error(`Not logged in to GitHub — please log in first`);return e.accessToken}const w={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,n,r)=>{let i=await m();if(!i)throw Error(`GitHub OAuth not configured — no client ID available`);let s=r?.scopes??d.scopes,u=h?null:await o(),f=h?`${c()}/auth/callback`:`${p??u.origin}/auth/callback`,g=crypto.randomUUID(),y=h?chrome.runtime.id:``,C=h?{source:`extension`,extensionId:y,path:`/github`,nonce:g}:{port:parseInt(new URL(u.href).port||`5710`,10),path:`/auth/callback`,nonce:g},w=btoa(JSON.stringify(C)),T=g,E=new URLSearchParams({client_id:i,scope:s,redirect_uri:f});w&&E.set(`state`,w);let D=await t(`https://github.com/login/oauth/authorize?${E}`);if(!D)return;if(T)try{if(new URL(D).searchParams.get(`nonce`)!==T){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 O=_(D);if(!O){console.error(`[github] Could not extract authorization code from redirect URL`);return}let k=await l({provider:`github`,code:O,redirectUri:f}),A=await v(k.access_token);await e({providerId:`github`,accessToken:k.access_token,userName:A.name,userAvatar:A.avatar});let j=a(`github`)?.maskedValue;j?await b(j):await x(),await S(A),n()},onOAuthLogout:async()=>{let t=g();t?.accessToken&&await u({provider:`github`,accessToken:t.accessToken}).catch(e=>console.warn(`[github] Token revocation failed:`,e instanceof Error?e.message:String(e))),await x(),await e({providerId:`github`,accessToken:``})},getOAuthLogoutUrl:e=>`https://github.com/logout`};export{y as buildNoreplyEmail,w as config,_ as extractCodeFromUrl,C as getValidAccessToken,S as syncGitIdentityFromGitHub};
@@ -1 +1 @@
1
- import{A as e,G as t,J as n,Q as r,l as i,q as a}from"./kernel-worker-CplizLfv.js";import{a as o,i as s,n as c,o as l,r as u,s as d,t as f}from"./google-shared-DkyMo0mW.js";let p=0;const m=(e,n,i)=>{let o=new t;return(async()=>{let t={role:`assistant`,content:[],api:`google-generative-ai`,provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`stop`,timestamp:Date.now()};try{let c=g(e,i?.apiKey||r(e.provider)||``,i?.headers),d=_(e,n,i),f=await i?.onPayload?.(d,e);f!==void 0&&(d=f);let m=await c.models.generateContentStream(d);o.push({type:`start`,partial:t});let h=null,v=t.content,y=()=>v.length-1;for await(let n of m){t.responseId||=n.responseId;let r=n.candidates?.[0];if(r?.content?.parts)for(let e of r.content.parts){if(e.text!==void 0){let n=u(e);(!h||n&&h.type!==`thinking`||!n&&h.type!==`text`)&&(h&&(h.type===`text`?o.push({type:`text_end`,contentIndex:v.length-1,content:h.text,partial:t}):o.push({type:`thinking_end`,contentIndex:y(),content:h.thinking,partial:t})),n?(h={type:`thinking`,thinking:``,thinkingSignature:void 0},t.content.push(h),o.push({type:`thinking_start`,contentIndex:y(),partial:t})):(h={type:`text`,text:``},t.content.push(h),o.push({type:`text_start`,contentIndex:y(),partial:t}))),h.type===`thinking`?(h.thinking+=e.text,h.thinkingSignature=l(h.thinkingSignature,e.thoughtSignature),o.push({type:`thinking_delta`,contentIndex:y(),delta:e.text,partial:t})):(h.text+=e.text,h.textSignature=l(h.textSignature,e.thoughtSignature),o.push({type:`text_delta`,contentIndex:y(),delta:e.text,partial:t}))}if(e.functionCall){h&&=(h.type===`text`?o.push({type:`text_end`,contentIndex:y(),content:h.text,partial:t}):o.push({type:`thinking_end`,contentIndex:y(),content:h.thinking,partial:t}),null);let n=e.functionCall.id,r={type:`toolCall`,id:!n||t.content.some(e=>e.type===`toolCall`&&e.id===n)?`${e.functionCall.name}_${Date.now()}_${++p}`:n,name:e.functionCall.name||``,arguments:e.functionCall.args??{},...e.thoughtSignature&&{thoughtSignature:e.thoughtSignature}};t.content.push(r),o.push({type:`toolcall_start`,contentIndex:y(),partial:t}),o.push({type:`toolcall_delta`,contentIndex:y(),delta:JSON.stringify(r.arguments),partial:t}),o.push({type:`toolcall_end`,contentIndex:y(),toolCall:r,partial:t})}}r?.finishReason&&(t.stopReason=s(r.finishReason),t.content.some(e=>e.type===`toolCall`)&&(t.stopReason=`toolUse`)),n.usageMetadata&&(t.usage={input:(n.usageMetadata.promptTokenCount||0)-(n.usageMetadata.cachedContentTokenCount||0),output:(n.usageMetadata.candidatesTokenCount||0)+(n.usageMetadata.thoughtsTokenCount||0),cacheRead:n.usageMetadata.cachedContentTokenCount||0,cacheWrite:0,totalTokens:n.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},a(e,t.usage))}if(h&&(h.type===`text`?o.push({type:`text_end`,contentIndex:y(),content:h.text,partial:t}):o.push({type:`thinking_end`,contentIndex:y(),content:h.thinking,partial:t})),i?.signal?.aborted)throw Error(`Request was aborted`);if(t.stopReason===`aborted`||t.stopReason===`error`)throw Error(`An unknown error occurred`);o.push({type:`done`,reason:t.stopReason,message:t}),o.end()}catch(e){for(let e of t.content)`index`in e&&delete e.index;t.stopReason=i?.signal?.aborted?`aborted`:`error`,t.errorMessage=e instanceof Error?e.message:JSON.stringify(e),o.push({type:`error`,reason:t.stopReason,error:t}),o.end()}})(),o},h=(t,i,a)=>{let o=a?.apiKey||r(t.provider);if(!o)throw Error(`No API key for provider: ${t.provider}`);let s=e(t,a,o);if(!a?.reasoning)return m(t,i,{...s,thinking:{enabled:!1}});let c=n(t,a.reasoning),l=c===`off`?`high`:c,u=t;return y(u)||b(u)||v(u)?m(t,i,{...s,thinking:{enabled:!0,level:S(l,u)}}):m(t,i,{...s,thinking:{enabled:!0,budgetTokens:C(u,l,a.thinkingBudgets)}})};function g(e,t,n){let r={};return e.baseUrl&&(r.baseUrl=e.baseUrl,r.apiVersion=``),(e.headers||n)&&(r.headers={...e.headers,...n}),new d({apiKey:t,httpOptions:Object.keys(r).length>0?r:void 0})}function _(e,t,n={}){let r=f(e,t),a={};n.temperature!==void 0&&(a.temperature=n.temperature),n.maxTokens!==void 0&&(a.maxOutputTokens=n.maxTokens);let s={...Object.keys(a).length>0&&a,...t.systemPrompt&&{systemInstruction:i(t.systemPrompt)},...t.tools&&t.tools.length>0&&{tools:c(t.tools)}};if(t.tools&&t.tools.length>0&&n.toolChoice?s.toolConfig={functionCallingConfig:{mode:o(n.toolChoice)}}:s.toolConfig=void 0,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=x(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 v(e){return/gemma-?4/.test(e.id.toLowerCase())}function y(e){return/gemini-3(?:\.\d+)?-pro/.test(e.id.toLowerCase())}function b(e){return/gemini-3(?:\.\d+)?-flash/.test(e.id.toLowerCase())}function x(e){return y(e)?{thinkingLevel:`LOW`}:b(e)||v(e)?{thinkingLevel:`MINIMAL`}:{thinkingBudget:0}}function S(e,t){if(y(t))switch(e){case`minimal`:case`low`:return`LOW`;case`medium`:case`high`:return`HIGH`}if(v(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 C(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{m as streamGoogle,h as streamSimpleGoogle};
1
+ import{A as e,G as t,J as n,Q as r,l as i,q as a}from"./kernel-worker-DaPtM-8x.js";import{a as o,i as s,n as c,o as l,r as u,s as d,t as f}from"./google-shared-DbLcpQyZ.js";let p=0;const m=(e,n,i)=>{let o=new t;return(async()=>{let t={role:`assistant`,content:[],api:`google-generative-ai`,provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`stop`,timestamp:Date.now()};try{let c=g(e,i?.apiKey||r(e.provider)||``,i?.headers),d=_(e,n,i),f=await i?.onPayload?.(d,e);f!==void 0&&(d=f);let m=await c.models.generateContentStream(d);o.push({type:`start`,partial:t});let h=null,v=t.content,y=()=>v.length-1;for await(let n of m){t.responseId||=n.responseId;let r=n.candidates?.[0];if(r?.content?.parts)for(let e of r.content.parts){if(e.text!==void 0){let n=u(e);(!h||n&&h.type!==`thinking`||!n&&h.type!==`text`)&&(h&&(h.type===`text`?o.push({type:`text_end`,contentIndex:v.length-1,content:h.text,partial:t}):o.push({type:`thinking_end`,contentIndex:y(),content:h.thinking,partial:t})),n?(h={type:`thinking`,thinking:``,thinkingSignature:void 0},t.content.push(h),o.push({type:`thinking_start`,contentIndex:y(),partial:t})):(h={type:`text`,text:``},t.content.push(h),o.push({type:`text_start`,contentIndex:y(),partial:t}))),h.type===`thinking`?(h.thinking+=e.text,h.thinkingSignature=l(h.thinkingSignature,e.thoughtSignature),o.push({type:`thinking_delta`,contentIndex:y(),delta:e.text,partial:t})):(h.text+=e.text,h.textSignature=l(h.textSignature,e.thoughtSignature),o.push({type:`text_delta`,contentIndex:y(),delta:e.text,partial:t}))}if(e.functionCall){h&&=(h.type===`text`?o.push({type:`text_end`,contentIndex:y(),content:h.text,partial:t}):o.push({type:`thinking_end`,contentIndex:y(),content:h.thinking,partial:t}),null);let n=e.functionCall.id,r={type:`toolCall`,id:!n||t.content.some(e=>e.type===`toolCall`&&e.id===n)?`${e.functionCall.name}_${Date.now()}_${++p}`:n,name:e.functionCall.name||``,arguments:e.functionCall.args??{},...e.thoughtSignature&&{thoughtSignature:e.thoughtSignature}};t.content.push(r),o.push({type:`toolcall_start`,contentIndex:y(),partial:t}),o.push({type:`toolcall_delta`,contentIndex:y(),delta:JSON.stringify(r.arguments),partial:t}),o.push({type:`toolcall_end`,contentIndex:y(),toolCall:r,partial:t})}}r?.finishReason&&(t.stopReason=s(r.finishReason),t.content.some(e=>e.type===`toolCall`)&&(t.stopReason=`toolUse`)),n.usageMetadata&&(t.usage={input:(n.usageMetadata.promptTokenCount||0)-(n.usageMetadata.cachedContentTokenCount||0),output:(n.usageMetadata.candidatesTokenCount||0)+(n.usageMetadata.thoughtsTokenCount||0),cacheRead:n.usageMetadata.cachedContentTokenCount||0,cacheWrite:0,totalTokens:n.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},a(e,t.usage))}if(h&&(h.type===`text`?o.push({type:`text_end`,contentIndex:y(),content:h.text,partial:t}):o.push({type:`thinking_end`,contentIndex:y(),content:h.thinking,partial:t})),i?.signal?.aborted)throw Error(`Request was aborted`);if(t.stopReason===`aborted`||t.stopReason===`error`)throw Error(`An unknown error occurred`);o.push({type:`done`,reason:t.stopReason,message:t}),o.end()}catch(e){for(let e of t.content)`index`in e&&delete e.index;t.stopReason=i?.signal?.aborted?`aborted`:`error`,t.errorMessage=e instanceof Error?e.message:JSON.stringify(e),o.push({type:`error`,reason:t.stopReason,error:t}),o.end()}})(),o},h=(t,i,a)=>{let o=a?.apiKey||r(t.provider);if(!o)throw Error(`No API key for provider: ${t.provider}`);let s=e(t,a,o);if(!a?.reasoning)return m(t,i,{...s,thinking:{enabled:!1}});let c=n(t,a.reasoning),l=c===`off`?`high`:c,u=t;return y(u)||b(u)||v(u)?m(t,i,{...s,thinking:{enabled:!0,level:S(l,u)}}):m(t,i,{...s,thinking:{enabled:!0,budgetTokens:C(u,l,a.thinkingBudgets)}})};function g(e,t,n){let r={};return e.baseUrl&&(r.baseUrl=e.baseUrl,r.apiVersion=``),(e.headers||n)&&(r.headers={...e.headers,...n}),new d({apiKey:t,httpOptions:Object.keys(r).length>0?r:void 0})}function _(e,t,n={}){let r=f(e,t),a={};n.temperature!==void 0&&(a.temperature=n.temperature),n.maxTokens!==void 0&&(a.maxOutputTokens=n.maxTokens);let s={...Object.keys(a).length>0&&a,...t.systemPrompt&&{systemInstruction:i(t.systemPrompt)},...t.tools&&t.tools.length>0&&{tools:c(t.tools)}};if(t.tools&&t.tools.length>0&&n.toolChoice?s.toolConfig={functionCallingConfig:{mode:o(n.toolChoice)}}:s.toolConfig=void 0,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=x(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 v(e){return/gemma-?4/.test(e.id.toLowerCase())}function y(e){return/gemini-3(?:\.\d+)?-pro/.test(e.id.toLowerCase())}function b(e){return/gemini-3(?:\.\d+)?-flash/.test(e.id.toLowerCase())}function x(e){return y(e)?{thinkingLevel:`LOW`}:b(e)||v(e)?{thinkingLevel:`MINIMAL`}:{thinkingBudget:0}}function S(e,t){if(y(t))switch(e){case`minimal`:case`low`:return`LOW`;case`medium`:case`high`:return`HIGH`}if(v(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 C(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{m as streamGoogle,h as streamSimpleGoogle};
@@ -1 +1 @@
1
- import{$ as e,J as t,K as n,Y as r,m as i}from"./main-CHCnJnQN.js";import{t as a}from"./sanitize-unicode-DmIE6hZJ.js";import{a as o,i as s,n as c,o as l,r as u,s as d,t as f}from"./google-shared-CgUd6GQm.js";var p=0,m=(r,i,a)=>{let o=new n;return(async()=>{let n={role:`assistant`,content:[],api:`google-generative-ai`,provider:r.provider,model:r.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 c=g(r,a?.apiKey||e(r.provider)||``,a?.headers),d=_(r,i,a),f=await a?.onPayload?.(d,r);f!==void 0&&(d=f);let m=await c.models.generateContentStream(d);o.push({type:`start`,partial:n});let h=null,v=n.content,y=()=>v.length-1;for await(let e of m){n.responseId||=e.responseId;let i=e.candidates?.[0];if(i?.content?.parts)for(let e of i.content.parts){if(e.text!==void 0){let t=u(e);(!h||t&&h.type!==`thinking`||!t&&h.type!==`text`)&&(h&&(h.type===`text`?o.push({type:`text_end`,contentIndex:v.length-1,content:h.text,partial:n}):o.push({type:`thinking_end`,contentIndex:y(),content:h.thinking,partial:n})),t?(h={type:`thinking`,thinking:``,thinkingSignature:void 0},n.content.push(h),o.push({type:`thinking_start`,contentIndex:y(),partial:n})):(h={type:`text`,text:``},n.content.push(h),o.push({type:`text_start`,contentIndex:y(),partial:n}))),h.type===`thinking`?(h.thinking+=e.text,h.thinkingSignature=l(h.thinkingSignature,e.thoughtSignature),o.push({type:`thinking_delta`,contentIndex:y(),delta:e.text,partial:n})):(h.text+=e.text,h.textSignature=l(h.textSignature,e.thoughtSignature),o.push({type:`text_delta`,contentIndex:y(),delta:e.text,partial:n}))}if(e.functionCall){h&&=(h.type===`text`?o.push({type:`text_end`,contentIndex:y(),content:h.text,partial:n}):o.push({type:`thinking_end`,contentIndex:y(),content:h.thinking,partial:n}),null);let t=e.functionCall.id,r={type:`toolCall`,id:!t||n.content.some(e=>e.type===`toolCall`&&e.id===t)?`${e.functionCall.name}_${Date.now()}_${++p}`:t,name:e.functionCall.name||``,arguments:e.functionCall.args??{},...e.thoughtSignature&&{thoughtSignature:e.thoughtSignature}};n.content.push(r),o.push({type:`toolcall_start`,contentIndex:y(),partial:n}),o.push({type:`toolcall_delta`,contentIndex:y(),delta:JSON.stringify(r.arguments),partial:n}),o.push({type:`toolcall_end`,contentIndex:y(),toolCall:r,partial:n})}}i?.finishReason&&(n.stopReason=s(i.finishReason),n.content.some(e=>e.type===`toolCall`)&&(n.stopReason=`toolUse`)),e.usageMetadata&&(n.usage={input:(e.usageMetadata.promptTokenCount||0)-(e.usageMetadata.cachedContentTokenCount||0),output:(e.usageMetadata.candidatesTokenCount||0)+(e.usageMetadata.thoughtsTokenCount||0),cacheRead:e.usageMetadata.cachedContentTokenCount||0,cacheWrite:0,totalTokens:e.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},t(r,n.usage))}if(h&&(h.type===`text`?o.push({type:`text_end`,contentIndex:y(),content:h.text,partial:n}):o.push({type:`thinking_end`,contentIndex:y(),content:h.thinking,partial:n})),a?.signal?.aborted)throw Error(`Request was aborted`);if(n.stopReason===`aborted`||n.stopReason===`error`)throw Error(`An unknown error occurred`);o.push({type:`done`,reason:n.stopReason,message:n}),o.end()}catch(e){for(let e of n.content)`index`in e&&delete e.index;n.stopReason=a?.signal?.aborted?`aborted`:`error`,n.errorMessage=e instanceof Error?e.message:JSON.stringify(e),o.push({type:`error`,reason:n.stopReason,error:n}),o.end()}})(),o},h=(t,n,a)=>{let o=a?.apiKey||e(t.provider);if(!o)throw Error(`No API key for provider: ${t.provider}`);let s=i(t,a,o);if(!a?.reasoning)return m(t,n,{...s,thinking:{enabled:!1}});let c=r(t,a.reasoning),l=c===`off`?`high`:c,u=t;return y(u)||b(u)||v(u)?m(t,n,{...s,thinking:{enabled:!0,level:S(l,u)}}):m(t,n,{...s,thinking:{enabled:!0,budgetTokens:C(u,l,a.thinkingBudgets)}})};function g(e,t,n){let r={};return e.baseUrl&&(r.baseUrl=e.baseUrl,r.apiVersion=``),(e.headers||n)&&(r.headers={...e.headers,...n}),new d({apiKey:t,httpOptions:Object.keys(r).length>0?r:void 0})}function _(e,t,n={}){let r=f(e,t),i={};n.temperature!==void 0&&(i.temperature=n.temperature),n.maxTokens!==void 0&&(i.maxOutputTokens=n.maxTokens);let s={...Object.keys(i).length>0&&i,...t.systemPrompt&&{systemInstruction:a(t.systemPrompt)},...t.tools&&t.tools.length>0&&{tools:c(t.tools)}};if(t.tools&&t.tools.length>0&&n.toolChoice?s.toolConfig={functionCallingConfig:{mode:o(n.toolChoice)}}:s.toolConfig=void 0,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=x(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 v(e){return/gemma-?4/.test(e.id.toLowerCase())}function y(e){return/gemini-3(?:\.\d+)?-pro/.test(e.id.toLowerCase())}function b(e){return/gemini-3(?:\.\d+)?-flash/.test(e.id.toLowerCase())}function x(e){return y(e)?{thinkingLevel:`LOW`}:b(e)||v(e)?{thinkingLevel:`MINIMAL`}:{thinkingBudget:0}}function S(e,t){if(y(t))switch(e){case`minimal`:case`low`:return`LOW`;case`medium`:case`high`:return`HIGH`}if(v(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 C(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{m as streamGoogle,h as streamSimpleGoogle};
1
+ import{$ as e,J as t,K as n,Y as r,m as i}from"./main-D7VEsE-b.js";import{t as a}from"./sanitize-unicode-DmIE6hZJ.js";import{a as o,i as s,n as c,o as l,r as u,s as d,t as f}from"./google-shared-BMl3Xihh.js";var p=0,m=(r,i,a)=>{let o=new n;return(async()=>{let n={role:`assistant`,content:[],api:`google-generative-ai`,provider:r.provider,model:r.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 c=g(r,a?.apiKey||e(r.provider)||``,a?.headers),d=_(r,i,a),f=await a?.onPayload?.(d,r);f!==void 0&&(d=f);let m=await c.models.generateContentStream(d);o.push({type:`start`,partial:n});let h=null,v=n.content,y=()=>v.length-1;for await(let e of m){n.responseId||=e.responseId;let i=e.candidates?.[0];if(i?.content?.parts)for(let e of i.content.parts){if(e.text!==void 0){let t=u(e);(!h||t&&h.type!==`thinking`||!t&&h.type!==`text`)&&(h&&(h.type===`text`?o.push({type:`text_end`,contentIndex:v.length-1,content:h.text,partial:n}):o.push({type:`thinking_end`,contentIndex:y(),content:h.thinking,partial:n})),t?(h={type:`thinking`,thinking:``,thinkingSignature:void 0},n.content.push(h),o.push({type:`thinking_start`,contentIndex:y(),partial:n})):(h={type:`text`,text:``},n.content.push(h),o.push({type:`text_start`,contentIndex:y(),partial:n}))),h.type===`thinking`?(h.thinking+=e.text,h.thinkingSignature=l(h.thinkingSignature,e.thoughtSignature),o.push({type:`thinking_delta`,contentIndex:y(),delta:e.text,partial:n})):(h.text+=e.text,h.textSignature=l(h.textSignature,e.thoughtSignature),o.push({type:`text_delta`,contentIndex:y(),delta:e.text,partial:n}))}if(e.functionCall){h&&=(h.type===`text`?o.push({type:`text_end`,contentIndex:y(),content:h.text,partial:n}):o.push({type:`thinking_end`,contentIndex:y(),content:h.thinking,partial:n}),null);let t=e.functionCall.id,r={type:`toolCall`,id:!t||n.content.some(e=>e.type===`toolCall`&&e.id===t)?`${e.functionCall.name}_${Date.now()}_${++p}`:t,name:e.functionCall.name||``,arguments:e.functionCall.args??{},...e.thoughtSignature&&{thoughtSignature:e.thoughtSignature}};n.content.push(r),o.push({type:`toolcall_start`,contentIndex:y(),partial:n}),o.push({type:`toolcall_delta`,contentIndex:y(),delta:JSON.stringify(r.arguments),partial:n}),o.push({type:`toolcall_end`,contentIndex:y(),toolCall:r,partial:n})}}i?.finishReason&&(n.stopReason=s(i.finishReason),n.content.some(e=>e.type===`toolCall`)&&(n.stopReason=`toolUse`)),e.usageMetadata&&(n.usage={input:(e.usageMetadata.promptTokenCount||0)-(e.usageMetadata.cachedContentTokenCount||0),output:(e.usageMetadata.candidatesTokenCount||0)+(e.usageMetadata.thoughtsTokenCount||0),cacheRead:e.usageMetadata.cachedContentTokenCount||0,cacheWrite:0,totalTokens:e.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},t(r,n.usage))}if(h&&(h.type===`text`?o.push({type:`text_end`,contentIndex:y(),content:h.text,partial:n}):o.push({type:`thinking_end`,contentIndex:y(),content:h.thinking,partial:n})),a?.signal?.aborted)throw Error(`Request was aborted`);if(n.stopReason===`aborted`||n.stopReason===`error`)throw Error(`An unknown error occurred`);o.push({type:`done`,reason:n.stopReason,message:n}),o.end()}catch(e){for(let e of n.content)`index`in e&&delete e.index;n.stopReason=a?.signal?.aborted?`aborted`:`error`,n.errorMessage=e instanceof Error?e.message:JSON.stringify(e),o.push({type:`error`,reason:n.stopReason,error:n}),o.end()}})(),o},h=(t,n,a)=>{let o=a?.apiKey||e(t.provider);if(!o)throw Error(`No API key for provider: ${t.provider}`);let s=i(t,a,o);if(!a?.reasoning)return m(t,n,{...s,thinking:{enabled:!1}});let c=r(t,a.reasoning),l=c===`off`?`high`:c,u=t;return y(u)||b(u)||v(u)?m(t,n,{...s,thinking:{enabled:!0,level:S(l,u)}}):m(t,n,{...s,thinking:{enabled:!0,budgetTokens:C(u,l,a.thinkingBudgets)}})};function g(e,t,n){let r={};return e.baseUrl&&(r.baseUrl=e.baseUrl,r.apiVersion=``),(e.headers||n)&&(r.headers={...e.headers,...n}),new d({apiKey:t,httpOptions:Object.keys(r).length>0?r:void 0})}function _(e,t,n={}){let r=f(e,t),i={};n.temperature!==void 0&&(i.temperature=n.temperature),n.maxTokens!==void 0&&(i.maxOutputTokens=n.maxTokens);let s={...Object.keys(i).length>0&&i,...t.systemPrompt&&{systemInstruction:a(t.systemPrompt)},...t.tools&&t.tools.length>0&&{tools:c(t.tools)}};if(t.tools&&t.tools.length>0&&n.toolChoice?s.toolConfig={functionCallingConfig:{mode:o(n.toolChoice)}}:s.toolConfig=void 0,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=x(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 v(e){return/gemma-?4/.test(e.id.toLowerCase())}function y(e){return/gemini-3(?:\.\d+)?-pro/.test(e.id.toLowerCase())}function b(e){return/gemini-3(?:\.\d+)?-flash/.test(e.id.toLowerCase())}function x(e){return y(e)?{thinkingLevel:`LOW`}:b(e)||v(e)?{thinkingLevel:`MINIMAL`}:{thinkingBudget:0}}function S(e,t){if(y(t))switch(e){case`minimal`:case`low`:return`LOW`;case`medium`:case`high`:return`HIGH`}if(v(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 C(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{m as streamGoogle,h as streamSimpleGoogle};