sliccy 5.73.2 → 5.73.4
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-DwSzwLW8.js +43 -0
- package/dist/ui/assets/account-store-DzwZMcTg.js +101 -0
- package/dist/ui/assets/{adobe-DES2cp-y.js → adobe-ChyPg00A.js} +1 -1
- package/dist/ui/assets/{adobe-DHUcvdyP.js → adobe-h2gWq2z2.js} +1 -1
- package/dist/ui/assets/anthropic-messages-BFic5zKY.js +39 -0
- package/dist/ui/assets/anthropic-messages-C8dDJE2X.js +39 -0
- package/dist/ui/assets/{apps-DJx3akpR.js → apps-C86xnKLs.js} +1 -1
- package/dist/ui/assets/{azure-openai-D7xJ5VET.js → azure-openai-CjkdyGG4.js} +1 -1
- package/dist/ui/assets/{azure-openai-C3DSYzL8.js → azure-openai-DMNa-Eup.js} +1 -1
- package/dist/ui/assets/azure-openai-responses-B_twhN44.js +1 -0
- package/dist/ui/assets/azure-openai-responses-CzG7X9qb.js +1 -0
- package/dist/ui/assets/bedrock-camp-BO4bvAKs.js +1 -0
- package/dist/ui/assets/{bedrock-camp-PMQ4Iu6f.js → bedrock-camp-CVignIdH.js} +1 -1
- package/dist/ui/assets/{cerebras-CnOHiorM.js → cerebras-B0gvSD27.js} +1 -1
- package/dist/ui/assets/{cerebras-EsczMAGe.js → cerebras-CvSC_Q2O.js} +1 -1
- package/dist/ui/assets/compat-aVSWLlYQ.js +2 -0
- package/dist/ui/assets/{connect-surface-BTk8oHjU.js → connect-surface-3UvT0SF3.js} +1 -1
- package/dist/ui/assets/constrained-sampling-DafcjXU6.js +1 -0
- package/dist/ui/assets/{context-compaction-CW5AQ9bv.js → context-compaction-_UkD06XB.js} +1 -1
- package/dist/ui/assets/{fs-C_SqCSvP.js → fs-DC3MEAD4.js} +2 -2
- package/dist/ui/assets/{fs-PoNPHaXB.js → fs-DgMOH-Zj.js} +1 -1
- package/dist/ui/assets/{github-DF16zQXQ.js → github-HKW-k0Oh.js} +1 -1
- package/dist/ui/assets/{github-copilot-DiGxn4oA.js → github-copilot-C7lsRXxS.js} +1 -1
- package/dist/ui/assets/{github-copilot-DeMLYZUN.js → github-copilot-CBv0T4_S.js} +1 -1
- package/dist/ui/assets/{github-DjE0FC03.js → github-mH266f8L.js} +2 -2
- package/dist/ui/assets/google-generative-ai-4YtIu_sJ.js +1 -0
- package/dist/ui/assets/google-generative-ai-DzD1vsXe.js +1 -0
- package/dist/ui/assets/google-shared-BAKd3aSn.js +371 -0
- package/dist/ui/assets/google-shared-CCLlnqMF.js +11 -0
- package/dist/ui/assets/google-vertex-8lUayXF0.js +1 -0
- package/dist/ui/assets/google-vertex-oQOD3HKr.js +1 -0
- package/dist/ui/assets/js-realm-worker-BIrkB9d8.js +48 -0
- package/dist/ui/assets/{kernel-worker-C-tryBGn.js → kernel-worker-CHs5yDJo.js} +589 -591
- package/dist/ui/assets/{legacy-api-aliases-CRTuRAqQ.js → legacy-api-aliases-IllWZ-uu.js} +1 -1
- package/dist/ui/assets/{legacy-api-aliases-CdGTJw-r.js → legacy-api-aliases-sqlB2uHc.js} +1 -1
- package/dist/ui/assets/{lick-ws-bridge-C3foeWDS.js → lick-ws-bridge-DbbdXQSp.js} +1 -1
- package/dist/ui/assets/{local-llm-CWi0ZprP.js → local-llm-DcKgaorK.js} +2 -2
- package/dist/ui/assets/{local-llm-Dq9HBaqe.js → local-llm-DpBDM1Dm.js} +1 -1
- package/dist/ui/assets/{main-BMElPt_b.js → main-CBUfGcTh.js} +3 -3
- package/dist/ui/assets/mistral-conversations-C57IiFrP.js +8 -0
- package/dist/ui/assets/mistral-conversations-CzEm7KNl.js +7 -0
- package/dist/ui/assets/{mount-CAFjW1QS.js → mount-BHqxxbwU.js} +1 -1
- package/dist/ui/assets/{mount-C7OeghLh.js → mount-BRSg0FIY.js} +2 -2
- package/dist/ui/assets/{mount-recovery-B8VdqP8T.js → mount-recovery-Beig7gzz.js} +1 -1
- package/dist/ui/assets/{new-session-BwNVjrlp.js → new-session-UPnjrqyz.js} +2 -2
- package/dist/ui/assets/oauth-bootstrap-DUaR-il_.js +2 -0
- package/dist/ui/assets/{openai-codex-D9LHZUcr.js → openai-codex-CZit4W_R.js} +1 -1
- package/dist/ui/assets/openai-codex-D0W343kX.js +1 -0
- package/dist/ui/assets/openai-codex-responses-DRR6raXn.js +7 -0
- package/dist/ui/assets/openai-codex-responses-DU5CHdDQ.js +7 -0
- package/dist/ui/assets/openai-completions-B9S6450Q.js +5 -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-DmKhLxzV.js +1 -0
- package/dist/ui/assets/openai-responses-shared-CiIL52L-.js +10 -0
- package/dist/ui/assets/openai-responses-shared-IJFiSqdz.js +10 -0
- package/dist/ui/assets/{openrouter-BmRdV9UY.js → openrouter-D4iz9RSI.js} +1 -1
- package/dist/ui/assets/{openrouter-BIvugNQ1.js → openrouter-XorTuzAh.js} +1 -1
- package/dist/ui/assets/openrouter-images-6_MxZkJZ.js +1 -0
- package/dist/ui/assets/openrouter-images-BixC5B6a.js +1 -0
- package/dist/ui/assets/{openrouter-models-DM9v24kQ.js → openrouter-models-Bu1Cy5AD.js} +1 -1
- package/dist/ui/assets/{openrouter-models-B8MWxzTa.js → openrouter-models-CfnkMx5-.js} +1 -1
- package/dist/ui/assets/{openrouter-oauth-lGTI8QBz.js → openrouter-oauth-BGOdgzqm.js} +1 -1
- package/dist/ui/assets/{openrouter-oauth-QExY6Qo3.js → openrouter-oauth-BLGBWXoP.js} +1 -1
- package/dist/ui/assets/openrouter.models-DS1_VkCm.js +1 -0
- package/dist/ui/assets/openrouter.models-HnnH-abS.js +1 -0
- package/dist/ui/assets/{panel-rpc-handlers-SvYz4p6A.js → panel-rpc-handlers-BPMsj1iE.js} +2 -2
- package/dist/ui/assets/{provider-dLnW_Qmu.js → provider-DZ7x1aM4.js} +1 -1
- package/dist/ui/assets/{provider-CDDFVleF.js → provider-YxK-lzhm.js} +2 -2
- package/dist/ui/assets/provider-retry-C8PJzY_l.js +1 -0
- package/dist/ui/assets/{provider-settings-BonXlQHx.js → provider-settings-CmJnFmK2.js} +1 -1
- package/dist/ui/assets/provider-settings-D6FC6-Ws.js +2 -0
- package/dist/ui/assets/{provider-store-access-CDUXoK9n.js → provider-store-access-Bqa_EvEK.js} +2 -2
- package/dist/ui/assets/provider-store-access-Dw2dlNIf.js +1 -0
- package/dist/ui/assets/{providers-BE5wq_hp.js → providers-7r6dA4ra.js} +1 -1
- package/dist/ui/assets/{providers-B8AC4r1K.js → providers-Bklgdp4G.js} +2 -2
- package/dist/ui/assets/quick-llm-BHegEzYY.js +1 -0
- package/dist/ui/assets/{session-freezer-jCi1eAnA.js → session-freezer-oYKtZTY0.js} +3 -3
- package/dist/ui/assets/{setup-sudo-CglheNlM.js → setup-sudo-DGrMEyR3.js} +2 -2
- package/dist/ui/assets/{skills-B6K9VVT7.js → skills-DkHenAsV.js} +1 -1
- package/dist/ui/assets/{store-Dpqwm0j1.js → store-DICK08O4.js} +1 -1
- package/dist/ui/assets/{sudo-Bfbjy3cy.js → sudo-9mYhdwPD.js} +1 -1
- package/dist/ui/assets/{upgrade-detection-DdRKki36.js → upgrade-detection-B8LfSgMb.js} +1 -1
- package/dist/ui/assets/{wc-extension-K9Yoj8xX.js → wc-extension-grYSDyJN.js} +2 -2
- package/dist/ui/assets/{wc-follower-BmFSgVpW.js → wc-follower-B6JesvuH.js} +3 -3
- package/dist/ui/assets/{wc-live-FQiVeP5H.js → wc-live-OHBNpb_A.js} +3 -3
- package/dist/ui/assets/{wc-nav-CPTHD9Gm.js → wc-nav-DcxqwpAS.js} +2 -2
- package/dist/ui/assets/{wc-onboarding-Du7r32Nc.js → wc-onboarding-t5pRxVjL.js} +2 -2
- package/dist/ui/assets/{wc-placeholder-qw9xzwIX.js → wc-placeholder-XW-qi_GD.js} +2 -2
- package/dist/ui/assets/{wc-settings-Dsqf_wFN.js → wc-settings-7Jj2UM15.js} +2 -2
- package/dist/ui/assets/{wc-shell-LFcAIFJQ.js → wc-shell-CoYCAmK-.js} +2 -2
- package/dist/ui/assets/{wc-sprinkles-CYSiEKaU.js → wc-sprinkles-CFaUt2sb.js} +2 -2
- package/dist/ui/assets/{wc-tray-Dg2nqNkH.js → wc-tray-C_yJiqov.js} +2 -2
- package/dist/ui/assets/xai-grok-CrEqywR8.js +1 -0
- package/dist/ui/assets/{xai-grok-D-owzioC.js → xai-grok-QulUPZS-.js} +1 -1
- package/dist/ui/index.html +10 -10
- package/dist/ui/packages/webapp/index.html +10 -10
- package/package.json +1 -1
- package/dist/ui/assets/account-store-1sWsdBXV.js +0 -38
- package/dist/ui/assets/account-store-DWKDZbQl.js +0 -94
- package/dist/ui/assets/amazon-bedrock-Cg62P8pR.json +0 -1
- package/dist/ui/assets/anthropic-4_qTN2Mu.json +0 -1
- package/dist/ui/assets/anthropic-messages-6XWFkWWy.js +0 -39
- package/dist/ui/assets/anthropic-messages-D42B1WVl.js +0 -39
- package/dist/ui/assets/azure-openai-responses-BvEv9lZE.js +0 -1
- package/dist/ui/assets/azure-openai-responses-DE9sINqp.json +0 -1
- package/dist/ui/assets/azure-openai-responses-DRSA640t.js +0 -1
- package/dist/ui/assets/bedrock-camp-D_7EbOFH.js +0 -1
- package/dist/ui/assets/cloudflare-ai-gateway-DDb7hKDm.json +0 -1
- package/dist/ui/assets/cloudflare-workers-ai-hYVOS3es.json +0 -1
- package/dist/ui/assets/compat-Spvv5tCW.js +0 -2
- package/dist/ui/assets/fireworks-B7kEGNCU.json +0 -1
- package/dist/ui/assets/github-copilot-K9C_HNHm.json +0 -1
- package/dist/ui/assets/google-F4XgvJ1y.json +0 -1
- package/dist/ui/assets/google-generative-ai-BqEHWDKc.js +0 -1
- package/dist/ui/assets/google-generative-ai-DOAY2Bef.js +0 -1
- package/dist/ui/assets/google-shared-2WQG4pNx.js +0 -11
- package/dist/ui/assets/google-shared-CGD-JGZx.js +0 -371
- package/dist/ui/assets/google-vertex-C-dQj0iH.js +0 -1
- package/dist/ui/assets/google-vertex-CiTExP0E.js +0 -1
- package/dist/ui/assets/huggingface-BjNadu0v.json +0 -1
- package/dist/ui/assets/js-realm-worker-BCzouR_m.js +0 -48
- package/dist/ui/assets/mistral-CLEcIOtP.json +0 -1
- package/dist/ui/assets/mistral-conversations-BIHTMTfL.js +0 -7
- package/dist/ui/assets/mistral-conversations-CFKNSaPt.js +0 -8
- package/dist/ui/assets/moonshotai-8QShYhhE.json +0 -1
- package/dist/ui/assets/moonshotai-cn-7hHZff5z.json +0 -1
- package/dist/ui/assets/nvidia-dA6GzUPm.json +0 -1
- package/dist/ui/assets/oauth-bootstrap-Bf7Ewk3g.js +0 -2
- package/dist/ui/assets/openai-BehvdaXx.json +0 -1
- package/dist/ui/assets/openai-codex-je7irmYi.js +0 -1
- package/dist/ui/assets/openai-codex-responses-B7cFMjWk.js +0 -7
- package/dist/ui/assets/openai-codex-responses-DqxoDEwc.js +0 -7
- package/dist/ui/assets/openai-completions-Z1aRkqWe.js +0 -5
- package/dist/ui/assets/openai-completions-o78dOizF.js +0 -5
- package/dist/ui/assets/openai-responses-SPfzkTJm.js +0 -1
- package/dist/ui/assets/openai-responses-shared-BHsJFKuB.js +0 -10
- package/dist/ui/assets/openai-responses-shared-Dg5Ojqlw.js +0 -10
- package/dist/ui/assets/openai-responses-xSdsW9lw.js +0 -1
- package/dist/ui/assets/opencode-4chvZrBR.json +0 -1
- package/dist/ui/assets/opencode-go-Chp1OOUx.json +0 -1
- package/dist/ui/assets/openrouter-ZLTwKIjA.json +0 -1
- package/dist/ui/assets/openrouter-images-BrQDTa3_.js +0 -1
- package/dist/ui/assets/openrouter-images-DtvjLeGK.js +0 -1
- package/dist/ui/assets/openrouter.models-Bi9GV7Zn.js +0 -1
- package/dist/ui/assets/openrouter.models-D41M1z_D.js +0 -1
- package/dist/ui/assets/provider-settings-BQ_ViD6o.js +0 -2
- package/dist/ui/assets/provider-store-access-B_M384kS.js +0 -1
- package/dist/ui/assets/quick-llm-j8Lw8DXh.js +0 -1
- package/dist/ui/assets/qwen-token-plan-BpxmzamU.json +0 -1
- package/dist/ui/assets/qwen-token-plan-cn-CPhDR0u_.json +0 -1
- package/dist/ui/assets/together-CYZ-lBBF.json +0 -1
- package/dist/ui/assets/vercel-ai-gateway-ZtkcQH_C.json +0 -1
- package/dist/ui/assets/xai-grok-BvvyCW-L.js +0 -1
|
@@ -0,0 +1,371 @@
|
|
|
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
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2025 Google LLC
|
|
5
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
6
|
+
*/
|
|
7
|
+
;function l(){return{geminiUrl:void 0,vertexUrl:void 0}}function u(e,t,n,r){if(!e?.baseUrl){let e=l();return t?e.vertexUrl??n:e.geminiUrl??r}return e.baseUrl}
|
|
8
|
+
/**
|
|
9
|
+
* @license
|
|
10
|
+
* Copyright 2025 Google LLC
|
|
11
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
12
|
+
*/
|
|
13
|
+
var d=class{};function f(e,t){return e.replace(/\{([^}]+)\}/g,(e,n)=>{if(Object.prototype.hasOwnProperty.call(t,n)){let e=t[n];return e==null?``:String(e)}else throw Error(`Key '${n}' not found in valueMap.`)})}function p(e,t,n){for(let r=0;r<t.length-1;r++){let i=t[r];if(i.endsWith(`[]`)){let a=i.slice(0,-2);if(!(a in e))if(Array.isArray(n))e[a]=Array.from({length:n.length},()=>({}));else throw Error(`Value must be a list given an array path ${i}`);if(Array.isArray(e[a])){let i=e[a];if(Array.isArray(n))for(let e=0;e<i.length;e++){let a=i[e];p(a,t.slice(r+1),n[e])}else for(let e of i)p(e,t.slice(r+1),n)}return}else if(i.endsWith(`[0]`)){let a=i.slice(0,-3);a in e||(e[a]=[{}]);let o=e[a];p(o[0],t.slice(r+1),n);return}(!e[i]||typeof e[i]!=`object`)&&(e[i]={}),e=e[i]}let r=t[t.length-1],i=e[r];if(i!==void 0){if(!n||typeof n==`object`&&Object.keys(n).length===0||n===i)return;if(typeof i==`object`&&typeof n==`object`&&i!==null&&n!==null)Object.assign(i,n);else throw Error(`Cannot set value for an existing key. Key: ${r}`)}else r===`_self`&&typeof n==`object`&&n&&!Array.isArray(n)?Object.assign(e,n):e[r]=n}function m(e,t,n=void 0){try{if(t.length===1&&t[0]===`_self`)return e;for(let r=0;r<t.length;r++){if(typeof e!=`object`||!e)return n;let i=t[r];if(i.endsWith(`[]`)){let a=i.slice(0,-2);if(a in e){let i=e[a];return Array.isArray(i)?i.map(e=>m(e,t.slice(r+1),n)):n}else return n}else e=e[i]}return e}catch(e){if(e instanceof TypeError)return n;throw e}}function h(e,t){for(let[n,r]of Object.entries(t)){let t=n.split(`.`),i=r.split(`.`),a=new Set,o=-1;for(let e=0;e<t.length;e++)if(t[e]===`*`){o=e;break}if(o!==-1&&i.length>o)for(let e=o;e<i.length;e++){let t=i[e];t!==`*`&&!t.endsWith(`[]`)&&!t.endsWith(`[0]`)&&a.add(t)}g(e,t,i,0,a)}}function g(e,t,n,r,i){if(r>=t.length||typeof e!=`object`||!e)return;let a=t[r];if(a.endsWith(`[]`)){let o=a.slice(0,-2),s=e;if(o in s&&Array.isArray(s[o]))for(let e of s[o])g(e,t,n,r+1,i)}else if(a===`*`){if(typeof e==`object`&&e&&!Array.isArray(e)){let t=e,a=Object.keys(t).filter(e=>!e.startsWith(`_`)&&!i.has(e)),o={};for(let e of a)o[e]=t[e];for(let[e,i]of Object.entries(o)){let a=[];for(let t of n.slice(r))t===`*`?a.push(e):a.push(t);p(t,a,i)}for(let e of a)delete t[e]}}else{let o=e;a in o&&g(o[a],t,n,r+1,i)}}
|
|
14
|
+
/**
|
|
15
|
+
* @license
|
|
16
|
+
* Copyright 2025 Google LLC
|
|
17
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
18
|
+
*/
|
|
19
|
+
function _(e){if(typeof e!=`string`)throw Error(`fromImageBytes must be a string`);return e}
|
|
20
|
+
/**
|
|
21
|
+
* @license
|
|
22
|
+
* Copyright 2025 Google LLC
|
|
23
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
24
|
+
*/
|
|
25
|
+
function v(e){let t={},n=m(e,[`operationName`]);n!=null&&p(t,[`operationName`],n);let r=m(e,[`resourceName`]);return r!=null&&p(t,[`_url`,`resourceName`],r),t}function y(e){let t={},n=m(e,[`name`]);n!=null&&p(t,[`name`],n);let r=m(e,[`metadata`]);r!=null&&p(t,[`metadata`],r);let i=m(e,[`done`]);i!=null&&p(t,[`done`],i);let a=m(e,[`error`]);a!=null&&p(t,[`error`],a);let o=m(e,[`response`,`generateVideoResponse`]);return o!=null&&p(t,[`response`],x(o)),t}function b(e){let t={},n=m(e,[`name`]);n!=null&&p(t,[`name`],n);let r=m(e,[`metadata`]);r!=null&&p(t,[`metadata`],r);let i=m(e,[`done`]);i!=null&&p(t,[`done`],i);let a=m(e,[`error`]);a!=null&&p(t,[`error`],a);let o=m(e,[`response`]);return o!=null&&p(t,[`response`],S(o)),t}function x(e){let t={},n=m(e,[`generatedSamples`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>C(e))),p(t,[`generatedVideos`],e)}let r=m(e,[`raiMediaFilteredCount`]);r!=null&&p(t,[`raiMediaFilteredCount`],r);let i=m(e,[`raiMediaFilteredReasons`]);return i!=null&&p(t,[`raiMediaFilteredReasons`],i),t}function S(e){let t={},n=m(e,[`videos`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>w(e))),p(t,[`generatedVideos`],e)}let r=m(e,[`raiMediaFilteredCount`]);r!=null&&p(t,[`raiMediaFilteredCount`],r);let i=m(e,[`raiMediaFilteredReasons`]);return i!=null&&p(t,[`raiMediaFilteredReasons`],i),t}function C(e){let t={},n=m(e,[`video`]);return n!=null&&p(t,[`video`],j(n)),t}function w(e){let t={},n=m(e,[`_self`]);return n!=null&&p(t,[`video`],M(n)),t}function T(e){let t={},n=m(e,[`operationName`]);return n!=null&&p(t,[`_url`,`operationName`],n),t}function E(e){let t={},n=m(e,[`operationName`]);return n!=null&&p(t,[`_url`,`operationName`],n),t}function D(e){let t={},n=m(e,[`name`]);n!=null&&p(t,[`name`],n);let r=m(e,[`metadata`]);r!=null&&p(t,[`metadata`],r);let i=m(e,[`done`]);i!=null&&p(t,[`done`],i);let a=m(e,[`error`]);a!=null&&p(t,[`error`],a);let o=m(e,[`response`]);return o!=null&&p(t,[`response`],O(o)),t}function O(e){let t={},n=m(e,[`sdkHttpResponse`]);n!=null&&p(t,[`sdkHttpResponse`],n);let r=m(e,[`parent`]);r!=null&&p(t,[`parent`],r);let i=m(e,[`documentName`]);return i!=null&&p(t,[`documentName`],i),t}function k(e){let t={},n=m(e,[`name`]);n!=null&&p(t,[`name`],n);let r=m(e,[`metadata`]);r!=null&&p(t,[`metadata`],r);let i=m(e,[`done`]);i!=null&&p(t,[`done`],i);let a=m(e,[`error`]);a!=null&&p(t,[`error`],a);let o=m(e,[`response`]);return o!=null&&p(t,[`response`],A(o)),t}function A(e){let t={},n=m(e,[`sdkHttpResponse`]);n!=null&&p(t,[`sdkHttpResponse`],n);let r=m(e,[`parent`]);r!=null&&p(t,[`parent`],r);let i=m(e,[`documentName`]);return i!=null&&p(t,[`documentName`],i),t}function j(e){let t={},n=m(e,[`uri`]);n!=null&&p(t,[`uri`],n);let r=m(e,[`encodedVideo`]);r!=null&&p(t,[`videoBytes`],_(r));let i=m(e,[`encoding`]);return i!=null&&p(t,[`mimeType`],i),t}function M(e){let t={},n=m(e,[`gcsUri`]);n!=null&&p(t,[`uri`],n);let r=m(e,[`bytesBase64Encoded`]);r!=null&&p(t,[`videoBytes`],_(r));let i=m(e,[`mimeType`]);return i!=null&&p(t,[`mimeType`],i),t}
|
|
26
|
+
/**
|
|
27
|
+
* @license
|
|
28
|
+
* Copyright 2025 Google LLC
|
|
29
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
30
|
+
*/
|
|
31
|
+
var ee;(function(e){e.LANGUAGE_UNSPECIFIED=`LANGUAGE_UNSPECIFIED`,e.PYTHON=`PYTHON`})(ee||={});var te;(function(e){e.OUTCOME_UNSPECIFIED=`OUTCOME_UNSPECIFIED`,e.OUTCOME_OK=`OUTCOME_OK`,e.OUTCOME_FAILED=`OUTCOME_FAILED`,e.OUTCOME_DEADLINE_EXCEEDED=`OUTCOME_DEADLINE_EXCEEDED`})(te||={});var ne;(function(e){e.SCHEDULING_UNSPECIFIED=`SCHEDULING_UNSPECIFIED`,e.SILENT=`SILENT`,e.WHEN_IDLE=`WHEN_IDLE`,e.INTERRUPT=`INTERRUPT`})(ne||={});var N;(function(e){e.TYPE_UNSPECIFIED=`TYPE_UNSPECIFIED`,e.STRING=`STRING`,e.NUMBER=`NUMBER`,e.INTEGER=`INTEGER`,e.BOOLEAN=`BOOLEAN`,e.ARRAY=`ARRAY`,e.OBJECT=`OBJECT`,e.NULL=`NULL`})(N||={});var re;(function(e){e.ENVIRONMENT_UNSPECIFIED=`ENVIRONMENT_UNSPECIFIED`,e.ENVIRONMENT_BROWSER=`ENVIRONMENT_BROWSER`})(re||={});var ie;(function(e){e.AUTH_TYPE_UNSPECIFIED=`AUTH_TYPE_UNSPECIFIED`,e.NO_AUTH=`NO_AUTH`,e.API_KEY_AUTH=`API_KEY_AUTH`,e.HTTP_BASIC_AUTH=`HTTP_BASIC_AUTH`,e.GOOGLE_SERVICE_ACCOUNT_AUTH=`GOOGLE_SERVICE_ACCOUNT_AUTH`,e.OAUTH=`OAUTH`,e.OIDC_AUTH=`OIDC_AUTH`})(ie||={});var ae;(function(e){e.HTTP_IN_UNSPECIFIED=`HTTP_IN_UNSPECIFIED`,e.HTTP_IN_QUERY=`HTTP_IN_QUERY`,e.HTTP_IN_HEADER=`HTTP_IN_HEADER`,e.HTTP_IN_PATH=`HTTP_IN_PATH`,e.HTTP_IN_BODY=`HTTP_IN_BODY`,e.HTTP_IN_COOKIE=`HTTP_IN_COOKIE`})(ae||={});var oe;(function(e){e.API_SPEC_UNSPECIFIED=`API_SPEC_UNSPECIFIED`,e.SIMPLE_SEARCH=`SIMPLE_SEARCH`,e.ELASTIC_SEARCH=`ELASTIC_SEARCH`})(oe||={});var se;(function(e){e.PHISH_BLOCK_THRESHOLD_UNSPECIFIED=`PHISH_BLOCK_THRESHOLD_UNSPECIFIED`,e.BLOCK_LOW_AND_ABOVE=`BLOCK_LOW_AND_ABOVE`,e.BLOCK_MEDIUM_AND_ABOVE=`BLOCK_MEDIUM_AND_ABOVE`,e.BLOCK_HIGH_AND_ABOVE=`BLOCK_HIGH_AND_ABOVE`,e.BLOCK_HIGHER_AND_ABOVE=`BLOCK_HIGHER_AND_ABOVE`,e.BLOCK_VERY_HIGH_AND_ABOVE=`BLOCK_VERY_HIGH_AND_ABOVE`,e.BLOCK_ONLY_EXTREMELY_HIGH=`BLOCK_ONLY_EXTREMELY_HIGH`})(se||={});var ce;(function(e){e.UNSPECIFIED=`UNSPECIFIED`,e.BLOCKING=`BLOCKING`,e.NON_BLOCKING=`NON_BLOCKING`})(ce||={});var le;(function(e){e.MODE_UNSPECIFIED=`MODE_UNSPECIFIED`,e.MODE_DYNAMIC=`MODE_DYNAMIC`})(le||={});var P;(function(e){e.MODE_UNSPECIFIED=`MODE_UNSPECIFIED`,e.AUTO=`AUTO`,e.ANY=`ANY`,e.NONE=`NONE`,e.VALIDATED=`VALIDATED`})(P||={});var ue;(function(e){e.THINKING_LEVEL_UNSPECIFIED=`THINKING_LEVEL_UNSPECIFIED`,e.MINIMAL=`MINIMAL`,e.LOW=`LOW`,e.MEDIUM=`MEDIUM`,e.HIGH=`HIGH`})(ue||={});var de;(function(e){e.DONT_ALLOW=`DONT_ALLOW`,e.ALLOW_ADULT=`ALLOW_ADULT`,e.ALLOW_ALL=`ALLOW_ALL`})(de||={});var fe;(function(e){e.PROMINENT_PEOPLE_UNSPECIFIED=`PROMINENT_PEOPLE_UNSPECIFIED`,e.ALLOW_PROMINENT_PEOPLE=`ALLOW_PROMINENT_PEOPLE`,e.BLOCK_PROMINENT_PEOPLE=`BLOCK_PROMINENT_PEOPLE`})(fe||={});var pe;(function(e){e.HARM_CATEGORY_UNSPECIFIED=`HARM_CATEGORY_UNSPECIFIED`,e.HARM_CATEGORY_HARASSMENT=`HARM_CATEGORY_HARASSMENT`,e.HARM_CATEGORY_HATE_SPEECH=`HARM_CATEGORY_HATE_SPEECH`,e.HARM_CATEGORY_SEXUALLY_EXPLICIT=`HARM_CATEGORY_SEXUALLY_EXPLICIT`,e.HARM_CATEGORY_DANGEROUS_CONTENT=`HARM_CATEGORY_DANGEROUS_CONTENT`,e.HARM_CATEGORY_CIVIC_INTEGRITY=`HARM_CATEGORY_CIVIC_INTEGRITY`,e.HARM_CATEGORY_IMAGE_HATE=`HARM_CATEGORY_IMAGE_HATE`,e.HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT=`HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT`,e.HARM_CATEGORY_IMAGE_HARASSMENT=`HARM_CATEGORY_IMAGE_HARASSMENT`,e.HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT=`HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT`,e.HARM_CATEGORY_JAILBREAK=`HARM_CATEGORY_JAILBREAK`})(pe||={});var me;(function(e){e.HARM_BLOCK_METHOD_UNSPECIFIED=`HARM_BLOCK_METHOD_UNSPECIFIED`,e.SEVERITY=`SEVERITY`,e.PROBABILITY=`PROBABILITY`})(me||={});var he;(function(e){e.HARM_BLOCK_THRESHOLD_UNSPECIFIED=`HARM_BLOCK_THRESHOLD_UNSPECIFIED`,e.BLOCK_LOW_AND_ABOVE=`BLOCK_LOW_AND_ABOVE`,e.BLOCK_MEDIUM_AND_ABOVE=`BLOCK_MEDIUM_AND_ABOVE`,e.BLOCK_ONLY_HIGH=`BLOCK_ONLY_HIGH`,e.BLOCK_NONE=`BLOCK_NONE`,e.OFF=`OFF`})(he||={});var F;(function(e){e.FINISH_REASON_UNSPECIFIED=`FINISH_REASON_UNSPECIFIED`,e.STOP=`STOP`,e.MAX_TOKENS=`MAX_TOKENS`,e.SAFETY=`SAFETY`,e.RECITATION=`RECITATION`,e.LANGUAGE=`LANGUAGE`,e.OTHER=`OTHER`,e.BLOCKLIST=`BLOCKLIST`,e.PROHIBITED_CONTENT=`PROHIBITED_CONTENT`,e.SPII=`SPII`,e.MALFORMED_FUNCTION_CALL=`MALFORMED_FUNCTION_CALL`,e.IMAGE_SAFETY=`IMAGE_SAFETY`,e.UNEXPECTED_TOOL_CALL=`UNEXPECTED_TOOL_CALL`,e.IMAGE_PROHIBITED_CONTENT=`IMAGE_PROHIBITED_CONTENT`,e.NO_IMAGE=`NO_IMAGE`,e.IMAGE_RECITATION=`IMAGE_RECITATION`,e.IMAGE_OTHER=`IMAGE_OTHER`})(F||={});var ge;(function(e){e.HARM_PROBABILITY_UNSPECIFIED=`HARM_PROBABILITY_UNSPECIFIED`,e.NEGLIGIBLE=`NEGLIGIBLE`,e.LOW=`LOW`,e.MEDIUM=`MEDIUM`,e.HIGH=`HIGH`})(ge||={});var _e;(function(e){e.HARM_SEVERITY_UNSPECIFIED=`HARM_SEVERITY_UNSPECIFIED`,e.HARM_SEVERITY_NEGLIGIBLE=`HARM_SEVERITY_NEGLIGIBLE`,e.HARM_SEVERITY_LOW=`HARM_SEVERITY_LOW`,e.HARM_SEVERITY_MEDIUM=`HARM_SEVERITY_MEDIUM`,e.HARM_SEVERITY_HIGH=`HARM_SEVERITY_HIGH`})(_e||={});var ve;(function(e){e.URL_RETRIEVAL_STATUS_UNSPECIFIED=`URL_RETRIEVAL_STATUS_UNSPECIFIED`,e.URL_RETRIEVAL_STATUS_SUCCESS=`URL_RETRIEVAL_STATUS_SUCCESS`,e.URL_RETRIEVAL_STATUS_ERROR=`URL_RETRIEVAL_STATUS_ERROR`,e.URL_RETRIEVAL_STATUS_PAYWALL=`URL_RETRIEVAL_STATUS_PAYWALL`,e.URL_RETRIEVAL_STATUS_UNSAFE=`URL_RETRIEVAL_STATUS_UNSAFE`})(ve||={});var ye;(function(e){e.BLOCKED_REASON_UNSPECIFIED=`BLOCKED_REASON_UNSPECIFIED`,e.SAFETY=`SAFETY`,e.OTHER=`OTHER`,e.BLOCKLIST=`BLOCKLIST`,e.PROHIBITED_CONTENT=`PROHIBITED_CONTENT`,e.IMAGE_SAFETY=`IMAGE_SAFETY`,e.MODEL_ARMOR=`MODEL_ARMOR`,e.JAILBREAK=`JAILBREAK`})(ye||={});var be;(function(e){e.TRAFFIC_TYPE_UNSPECIFIED=`TRAFFIC_TYPE_UNSPECIFIED`,e.ON_DEMAND=`ON_DEMAND`,e.ON_DEMAND_PRIORITY=`ON_DEMAND_PRIORITY`,e.ON_DEMAND_FLEX=`ON_DEMAND_FLEX`,e.PROVISIONED_THROUGHPUT=`PROVISIONED_THROUGHPUT`})(be||={});var xe;(function(e){e.MODALITY_UNSPECIFIED=`MODALITY_UNSPECIFIED`,e.TEXT=`TEXT`,e.IMAGE=`IMAGE`,e.AUDIO=`AUDIO`,e.VIDEO=`VIDEO`})(xe||={});var Se;(function(e){e.MODEL_STAGE_UNSPECIFIED=`MODEL_STAGE_UNSPECIFIED`,e.UNSTABLE_EXPERIMENTAL=`UNSTABLE_EXPERIMENTAL`,e.EXPERIMENTAL=`EXPERIMENTAL`,e.PREVIEW=`PREVIEW`,e.STABLE=`STABLE`,e.LEGACY=`LEGACY`,e.DEPRECATED=`DEPRECATED`,e.RETIRED=`RETIRED`})(Se||={});var Ce;(function(e){e.MEDIA_RESOLUTION_UNSPECIFIED=`MEDIA_RESOLUTION_UNSPECIFIED`,e.MEDIA_RESOLUTION_LOW=`MEDIA_RESOLUTION_LOW`,e.MEDIA_RESOLUTION_MEDIUM=`MEDIA_RESOLUTION_MEDIUM`,e.MEDIA_RESOLUTION_HIGH=`MEDIA_RESOLUTION_HIGH`})(Ce||={});var we;(function(e){e.TUNING_MODE_UNSPECIFIED=`TUNING_MODE_UNSPECIFIED`,e.TUNING_MODE_FULL=`TUNING_MODE_FULL`,e.TUNING_MODE_PEFT_ADAPTER=`TUNING_MODE_PEFT_ADAPTER`})(we||={});var Te;(function(e){e.ADAPTER_SIZE_UNSPECIFIED=`ADAPTER_SIZE_UNSPECIFIED`,e.ADAPTER_SIZE_ONE=`ADAPTER_SIZE_ONE`,e.ADAPTER_SIZE_TWO=`ADAPTER_SIZE_TWO`,e.ADAPTER_SIZE_FOUR=`ADAPTER_SIZE_FOUR`,e.ADAPTER_SIZE_EIGHT=`ADAPTER_SIZE_EIGHT`,e.ADAPTER_SIZE_SIXTEEN=`ADAPTER_SIZE_SIXTEEN`,e.ADAPTER_SIZE_THIRTY_TWO=`ADAPTER_SIZE_THIRTY_TWO`})(Te||={});var Ee;(function(e){e.JOB_STATE_UNSPECIFIED=`JOB_STATE_UNSPECIFIED`,e.JOB_STATE_QUEUED=`JOB_STATE_QUEUED`,e.JOB_STATE_PENDING=`JOB_STATE_PENDING`,e.JOB_STATE_RUNNING=`JOB_STATE_RUNNING`,e.JOB_STATE_SUCCEEDED=`JOB_STATE_SUCCEEDED`,e.JOB_STATE_FAILED=`JOB_STATE_FAILED`,e.JOB_STATE_CANCELLING=`JOB_STATE_CANCELLING`,e.JOB_STATE_CANCELLED=`JOB_STATE_CANCELLED`,e.JOB_STATE_PAUSED=`JOB_STATE_PAUSED`,e.JOB_STATE_EXPIRED=`JOB_STATE_EXPIRED`,e.JOB_STATE_UPDATING=`JOB_STATE_UPDATING`,e.JOB_STATE_PARTIALLY_SUCCEEDED=`JOB_STATE_PARTIALLY_SUCCEEDED`})(Ee||={});var De;(function(e){e.TUNING_JOB_STATE_UNSPECIFIED=`TUNING_JOB_STATE_UNSPECIFIED`,e.TUNING_JOB_STATE_WAITING_FOR_QUOTA=`TUNING_JOB_STATE_WAITING_FOR_QUOTA`,e.TUNING_JOB_STATE_PROCESSING_DATASET=`TUNING_JOB_STATE_PROCESSING_DATASET`,e.TUNING_JOB_STATE_WAITING_FOR_CAPACITY=`TUNING_JOB_STATE_WAITING_FOR_CAPACITY`,e.TUNING_JOB_STATE_TUNING=`TUNING_JOB_STATE_TUNING`,e.TUNING_JOB_STATE_POST_PROCESSING=`TUNING_JOB_STATE_POST_PROCESSING`})(De||={});var Oe;(function(e){e.AGGREGATION_METRIC_UNSPECIFIED=`AGGREGATION_METRIC_UNSPECIFIED`,e.AVERAGE=`AVERAGE`,e.MODE=`MODE`,e.STANDARD_DEVIATION=`STANDARD_DEVIATION`,e.VARIANCE=`VARIANCE`,e.MINIMUM=`MINIMUM`,e.MAXIMUM=`MAXIMUM`,e.MEDIAN=`MEDIAN`,e.PERCENTILE_P90=`PERCENTILE_P90`,e.PERCENTILE_P95=`PERCENTILE_P95`,e.PERCENTILE_P99=`PERCENTILE_P99`})(Oe||={});var ke;(function(e){e.PAIRWISE_CHOICE_UNSPECIFIED=`PAIRWISE_CHOICE_UNSPECIFIED`,e.BASELINE=`BASELINE`,e.CANDIDATE=`CANDIDATE`,e.TIE=`TIE`})(ke||={});var Ae;(function(e){e.TUNING_TASK_UNSPECIFIED=`TUNING_TASK_UNSPECIFIED`,e.TUNING_TASK_I2V=`TUNING_TASK_I2V`,e.TUNING_TASK_T2V=`TUNING_TASK_T2V`,e.TUNING_TASK_R2V=`TUNING_TASK_R2V`})(Ae||={});var je;(function(e){e.STATE_UNSPECIFIED=`STATE_UNSPECIFIED`,e.STATE_PENDING=`STATE_PENDING`,e.STATE_ACTIVE=`STATE_ACTIVE`,e.STATE_FAILED=`STATE_FAILED`})(je||={});var Me;(function(e){e.MEDIA_RESOLUTION_UNSPECIFIED=`MEDIA_RESOLUTION_UNSPECIFIED`,e.MEDIA_RESOLUTION_LOW=`MEDIA_RESOLUTION_LOW`,e.MEDIA_RESOLUTION_MEDIUM=`MEDIA_RESOLUTION_MEDIUM`,e.MEDIA_RESOLUTION_HIGH=`MEDIA_RESOLUTION_HIGH`,e.MEDIA_RESOLUTION_ULTRA_HIGH=`MEDIA_RESOLUTION_ULTRA_HIGH`})(Me||={});var Ne;(function(e){e.TOOL_TYPE_UNSPECIFIED=`TOOL_TYPE_UNSPECIFIED`,e.GOOGLE_SEARCH_WEB=`GOOGLE_SEARCH_WEB`,e.GOOGLE_SEARCH_IMAGE=`GOOGLE_SEARCH_IMAGE`,e.URL_CONTEXT=`URL_CONTEXT`,e.GOOGLE_MAPS=`GOOGLE_MAPS`,e.FILE_SEARCH=`FILE_SEARCH`})(Ne||={});var Pe;(function(e){e.COLLECTION=`COLLECTION`})(Pe||={});var Fe;(function(e){e.UNSPECIFIED=`unspecified`,e.FLEX=`flex`,e.STANDARD=`standard`,e.PRIORITY=`priority`})(Fe||={});var Ie;(function(e){e.FEATURE_SELECTION_PREFERENCE_UNSPECIFIED=`FEATURE_SELECTION_PREFERENCE_UNSPECIFIED`,e.PRIORITIZE_QUALITY=`PRIORITIZE_QUALITY`,e.BALANCED=`BALANCED`,e.PRIORITIZE_COST=`PRIORITIZE_COST`})(Ie||={});var Le;(function(e){e.PREDICT=`PREDICT`,e.EMBED_CONTENT=`EMBED_CONTENT`})(Le||={});var Re;(function(e){e.BLOCK_LOW_AND_ABOVE=`BLOCK_LOW_AND_ABOVE`,e.BLOCK_MEDIUM_AND_ABOVE=`BLOCK_MEDIUM_AND_ABOVE`,e.BLOCK_ONLY_HIGH=`BLOCK_ONLY_HIGH`,e.BLOCK_NONE=`BLOCK_NONE`})(Re||={});var ze;(function(e){e.auto=`auto`,e.en=`en`,e.ja=`ja`,e.ko=`ko`,e.hi=`hi`,e.zh=`zh`,e.pt=`pt`,e.es=`es`})(ze||={});var Be;(function(e){e.MASK_MODE_DEFAULT=`MASK_MODE_DEFAULT`,e.MASK_MODE_USER_PROVIDED=`MASK_MODE_USER_PROVIDED`,e.MASK_MODE_BACKGROUND=`MASK_MODE_BACKGROUND`,e.MASK_MODE_FOREGROUND=`MASK_MODE_FOREGROUND`,e.MASK_MODE_SEMANTIC=`MASK_MODE_SEMANTIC`})(Be||={});var Ve;(function(e){e.CONTROL_TYPE_DEFAULT=`CONTROL_TYPE_DEFAULT`,e.CONTROL_TYPE_CANNY=`CONTROL_TYPE_CANNY`,e.CONTROL_TYPE_SCRIBBLE=`CONTROL_TYPE_SCRIBBLE`,e.CONTROL_TYPE_FACE_MESH=`CONTROL_TYPE_FACE_MESH`})(Ve||={});var He;(function(e){e.SUBJECT_TYPE_DEFAULT=`SUBJECT_TYPE_DEFAULT`,e.SUBJECT_TYPE_PERSON=`SUBJECT_TYPE_PERSON`,e.SUBJECT_TYPE_ANIMAL=`SUBJECT_TYPE_ANIMAL`,e.SUBJECT_TYPE_PRODUCT=`SUBJECT_TYPE_PRODUCT`})(He||={});var Ue;(function(e){e.EDIT_MODE_DEFAULT=`EDIT_MODE_DEFAULT`,e.EDIT_MODE_INPAINT_REMOVAL=`EDIT_MODE_INPAINT_REMOVAL`,e.EDIT_MODE_INPAINT_INSERTION=`EDIT_MODE_INPAINT_INSERTION`,e.EDIT_MODE_OUTPAINT=`EDIT_MODE_OUTPAINT`,e.EDIT_MODE_CONTROLLED_EDITING=`EDIT_MODE_CONTROLLED_EDITING`,e.EDIT_MODE_STYLE=`EDIT_MODE_STYLE`,e.EDIT_MODE_BGSWAP=`EDIT_MODE_BGSWAP`,e.EDIT_MODE_PRODUCT_IMAGE=`EDIT_MODE_PRODUCT_IMAGE`})(Ue||={});var We;(function(e){e.FOREGROUND=`FOREGROUND`,e.BACKGROUND=`BACKGROUND`,e.PROMPT=`PROMPT`,e.SEMANTIC=`SEMANTIC`,e.INTERACTIVE=`INTERACTIVE`})(We||={});var Ge;(function(e){e.ASSET=`ASSET`,e.STYLE=`STYLE`})(Ge||={});var Ke;(function(e){e.INSERT=`INSERT`,e.REMOVE=`REMOVE`,e.REMOVE_STATIC=`REMOVE_STATIC`,e.OUTPAINT=`OUTPAINT`})(Ke||={});var qe;(function(e){e.OPTIMIZED=`OPTIMIZED`,e.LOSSLESS=`LOSSLESS`})(qe||={});var Je;(function(e){e.CROP=`CROP`,e.PAD=`PAD`})(Je||={});var Ye;(function(e){e.SUPERVISED_FINE_TUNING=`SUPERVISED_FINE_TUNING`,e.PREFERENCE_TUNING=`PREFERENCE_TUNING`,e.DISTILLATION=`DISTILLATION`})(Ye||={});var Xe;(function(e){e.STATE_UNSPECIFIED=`STATE_UNSPECIFIED`,e.PROCESSING=`PROCESSING`,e.ACTIVE=`ACTIVE`,e.FAILED=`FAILED`})(Xe||={});var Ze;(function(e){e.SOURCE_UNSPECIFIED=`SOURCE_UNSPECIFIED`,e.UPLOADED=`UPLOADED`,e.GENERATED=`GENERATED`,e.REGISTERED=`REGISTERED`})(Ze||={});var Qe;(function(e){e.TURN_COMPLETE_REASON_UNSPECIFIED=`TURN_COMPLETE_REASON_UNSPECIFIED`,e.MALFORMED_FUNCTION_CALL=`MALFORMED_FUNCTION_CALL`,e.RESPONSE_REJECTED=`RESPONSE_REJECTED`,e.NEED_MORE_INPUT=`NEED_MORE_INPUT`,e.PROHIBITED_INPUT_CONTENT=`PROHIBITED_INPUT_CONTENT`,e.IMAGE_PROHIBITED_INPUT_CONTENT=`IMAGE_PROHIBITED_INPUT_CONTENT`,e.INPUT_TEXT_CONTAIN_PROMINENT_PERSON_PROHIBITED=`INPUT_TEXT_CONTAIN_PROMINENT_PERSON_PROHIBITED`,e.INPUT_IMAGE_CELEBRITY=`INPUT_IMAGE_CELEBRITY`,e.INPUT_IMAGE_PHOTO_REALISTIC_CHILD_PROHIBITED=`INPUT_IMAGE_PHOTO_REALISTIC_CHILD_PROHIBITED`,e.INPUT_TEXT_NCII_PROHIBITED=`INPUT_TEXT_NCII_PROHIBITED`,e.INPUT_OTHER=`INPUT_OTHER`,e.INPUT_IP_PROHIBITED=`INPUT_IP_PROHIBITED`,e.BLOCKLIST=`BLOCKLIST`,e.UNSAFE_PROMPT_FOR_IMAGE_GENERATION=`UNSAFE_PROMPT_FOR_IMAGE_GENERATION`,e.GENERATED_IMAGE_SAFETY=`GENERATED_IMAGE_SAFETY`,e.GENERATED_CONTENT_SAFETY=`GENERATED_CONTENT_SAFETY`,e.GENERATED_AUDIO_SAFETY=`GENERATED_AUDIO_SAFETY`,e.GENERATED_VIDEO_SAFETY=`GENERATED_VIDEO_SAFETY`,e.GENERATED_CONTENT_PROHIBITED=`GENERATED_CONTENT_PROHIBITED`,e.GENERATED_CONTENT_BLOCKLIST=`GENERATED_CONTENT_BLOCKLIST`,e.GENERATED_IMAGE_PROHIBITED=`GENERATED_IMAGE_PROHIBITED`,e.GENERATED_IMAGE_CELEBRITY=`GENERATED_IMAGE_CELEBRITY`,e.GENERATED_IMAGE_PROMINENT_PEOPLE_DETECTED_BY_REWRITER=`GENERATED_IMAGE_PROMINENT_PEOPLE_DETECTED_BY_REWRITER`,e.GENERATED_IMAGE_IDENTIFIABLE_PEOPLE=`GENERATED_IMAGE_IDENTIFIABLE_PEOPLE`,e.GENERATED_IMAGE_MINORS=`GENERATED_IMAGE_MINORS`,e.OUTPUT_IMAGE_IP_PROHIBITED=`OUTPUT_IMAGE_IP_PROHIBITED`,e.GENERATED_OTHER=`GENERATED_OTHER`,e.MAX_REGENERATION_REACHED=`MAX_REGENERATION_REACHED`})(Qe||={});var $e;(function(e){e.MODALITY_UNSPECIFIED=`MODALITY_UNSPECIFIED`,e.TEXT=`TEXT`,e.IMAGE=`IMAGE`,e.VIDEO=`VIDEO`,e.AUDIO=`AUDIO`,e.DOCUMENT=`DOCUMENT`})($e||={});var et;(function(e){e.VAD_SIGNAL_TYPE_UNSPECIFIED=`VAD_SIGNAL_TYPE_UNSPECIFIED`,e.VAD_SIGNAL_TYPE_SOS=`VAD_SIGNAL_TYPE_SOS`,e.VAD_SIGNAL_TYPE_EOS=`VAD_SIGNAL_TYPE_EOS`})(et||={});var tt;(function(e){e.TYPE_UNSPECIFIED=`TYPE_UNSPECIFIED`,e.ACTIVITY_START=`ACTIVITY_START`,e.ACTIVITY_END=`ACTIVITY_END`})(tt||={});var nt;(function(e){e.START_SENSITIVITY_UNSPECIFIED=`START_SENSITIVITY_UNSPECIFIED`,e.START_SENSITIVITY_HIGH=`START_SENSITIVITY_HIGH`,e.START_SENSITIVITY_LOW=`START_SENSITIVITY_LOW`})(nt||={});var rt;(function(e){e.END_SENSITIVITY_UNSPECIFIED=`END_SENSITIVITY_UNSPECIFIED`,e.END_SENSITIVITY_HIGH=`END_SENSITIVITY_HIGH`,e.END_SENSITIVITY_LOW=`END_SENSITIVITY_LOW`})(rt||={});var it;(function(e){e.ACTIVITY_HANDLING_UNSPECIFIED=`ACTIVITY_HANDLING_UNSPECIFIED`,e.START_OF_ACTIVITY_INTERRUPTS=`START_OF_ACTIVITY_INTERRUPTS`,e.NO_INTERRUPTION=`NO_INTERRUPTION`})(it||={});var at;(function(e){e.TURN_COVERAGE_UNSPECIFIED=`TURN_COVERAGE_UNSPECIFIED`,e.TURN_INCLUDES_ONLY_ACTIVITY=`TURN_INCLUDES_ONLY_ACTIVITY`,e.TURN_INCLUDES_ALL_INPUT=`TURN_INCLUDES_ALL_INPUT`,e.TURN_INCLUDES_AUDIO_ACTIVITY_AND_ALL_VIDEO=`TURN_INCLUDES_AUDIO_ACTIVITY_AND_ALL_VIDEO`})(at||={});var ot;(function(e){e.SCALE_UNSPECIFIED=`SCALE_UNSPECIFIED`,e.C_MAJOR_A_MINOR=`C_MAJOR_A_MINOR`,e.D_FLAT_MAJOR_B_FLAT_MINOR=`D_FLAT_MAJOR_B_FLAT_MINOR`,e.D_MAJOR_B_MINOR=`D_MAJOR_B_MINOR`,e.E_FLAT_MAJOR_C_MINOR=`E_FLAT_MAJOR_C_MINOR`,e.E_MAJOR_D_FLAT_MINOR=`E_MAJOR_D_FLAT_MINOR`,e.F_MAJOR_D_MINOR=`F_MAJOR_D_MINOR`,e.G_FLAT_MAJOR_E_FLAT_MINOR=`G_FLAT_MAJOR_E_FLAT_MINOR`,e.G_MAJOR_E_MINOR=`G_MAJOR_E_MINOR`,e.A_FLAT_MAJOR_F_MINOR=`A_FLAT_MAJOR_F_MINOR`,e.A_MAJOR_G_FLAT_MINOR=`A_MAJOR_G_FLAT_MINOR`,e.B_FLAT_MAJOR_G_MINOR=`B_FLAT_MAJOR_G_MINOR`,e.B_MAJOR_A_FLAT_MINOR=`B_MAJOR_A_FLAT_MINOR`})(ot||={});var st;(function(e){e.MUSIC_GENERATION_MODE_UNSPECIFIED=`MUSIC_GENERATION_MODE_UNSPECIFIED`,e.QUALITY=`QUALITY`,e.DIVERSITY=`DIVERSITY`,e.VOCALIZATION=`VOCALIZATION`})(st||={});var ct;(function(e){e.PLAYBACK_CONTROL_UNSPECIFIED=`PLAYBACK_CONTROL_UNSPECIFIED`,e.PLAY=`PLAY`,e.PAUSE=`PAUSE`,e.STOP=`STOP`,e.RESET_CONTEXT=`RESET_CONTEXT`})(ct||={});var lt=class{constructor(e){let t={};for(let n of e.headers.entries())t[n[0]]=n[1];this.headers=t,this.responseInternal=e}json(){return this.responseInternal.json()}},ut=class{get text(){if(this.candidates?.[0]?.content?.parts?.length===0)return;this.candidates&&this.candidates.length>1&&console.warn(`there are multiple candidates in the response, returning text from the first one.`);let e=``,t=!1,n=[];for(let r of this.candidates?.[0]?.content?.parts??[]){for(let[e,t]of Object.entries(r))e!==`text`&&e!==`thought`&&e!==`thoughtSignature`&&(t!==null||t!==void 0)&&n.push(e);if(typeof r.text==`string`){if(typeof r.thought==`boolean`&&r.thought)continue;t=!0,e+=r.text}}return n.length>0&&console.warn(`there are non-text parts ${n} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),t?e:void 0}get data(){if(this.candidates?.[0]?.content?.parts?.length===0)return;this.candidates&&this.candidates.length>1&&console.warn(`there are multiple candidates in the response, returning data from the first one.`);let e=``,t=[];for(let n of this.candidates?.[0]?.content?.parts??[]){for(let[e,r]of Object.entries(n))e!==`inlineData`&&(r!==null||r!==void 0)&&t.push(e);n.inlineData&&typeof n.inlineData.data==`string`&&(e+=atob(n.inlineData.data))}return t.length>0&&console.warn(`there are non-data parts ${t} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),e.length>0?btoa(e):void 0}get functionCalls(){if(this.candidates?.[0]?.content?.parts?.length===0)return;this.candidates&&this.candidates.length>1&&console.warn(`there are multiple candidates in the response, returning function calls from the first one.`);let e=(this.candidates?.[0]?.content?.parts)?.filter(e=>e.functionCall).map(e=>e.functionCall).filter(e=>e!==void 0);if(e?.length!==0)return e}get executableCode(){if(this.candidates?.[0]?.content?.parts?.length===0)return;this.candidates&&this.candidates.length>1&&console.warn(`there are multiple candidates in the response, returning executable code from the first one.`);let e=(this.candidates?.[0]?.content?.parts)?.filter(e=>e.executableCode).map(e=>e.executableCode).filter(e=>e!==void 0);if(e?.length!==0)return e?.[0]?.code}get codeExecutionResult(){if(this.candidates?.[0]?.content?.parts?.length===0)return;this.candidates&&this.candidates.length>1&&console.warn(`there are multiple candidates in the response, returning code execution result from the first one.`);let e=(this.candidates?.[0]?.content?.parts)?.filter(e=>e.codeExecutionResult).map(e=>e.codeExecutionResult).filter(e=>e!==void 0);if(e?.length!==0)return e?.[0]?.output}},dt=class{},ft=class{},pt=class{},mt=class{},ht=class{},gt=class{},_t=class{},vt=class{},yt=class{},bt=class{},xt=class e{_fromAPIResponse({apiResponse:t,_isVertexAI:n}){let r=new e,i,a=t;return i=n?b(a):y(a),Object.assign(r,i),r}},St=class{},Ct=class{},wt=class{},Tt=class{},Et=class{},Dt=class{},Ot=class{},kt=class e{_fromAPIResponse({apiResponse:t,_isVertexAI:n}){let r=new e,i=D(t);return Object.assign(r,i),r}},At=class{},jt=class{},Mt=class{},Nt=class{},Pt=class{},Ft=class{get text(){let e=``,t=!1,n=[];for(let r of this.serverContent?.modelTurn?.parts??[]){for(let[e,t]of Object.entries(r))e!==`text`&&e!==`thought`&&t!==null&&n.push(e);if(typeof r.text==`string`){if(typeof r.thought==`boolean`&&r.thought)continue;t=!0,e+=r.text}}return n.length>0&&console.warn(`there are non-text parts ${n} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),t?e:void 0}get data(){let e=``,t=[];for(let n of this.serverContent?.modelTurn?.parts??[]){for(let[e,r]of Object.entries(n))e!==`inlineData`&&r!==null&&t.push(e);n.inlineData&&typeof n.inlineData.data==`string`&&(e+=atob(n.inlineData.data))}return t.length>0&&console.warn(`there are non-data parts ${t} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),e.length>0?btoa(e):void 0}},It=class{get audioChunk(){if(this.serverContent&&this.serverContent.audioChunks&&this.serverContent.audioChunks.length>0)return this.serverContent.audioChunks[0]}},Lt=class e{_fromAPIResponse({apiResponse:t,_isVertexAI:n}){let r=new e,i=k(t);return Object.assign(r,i),r}};
|
|
32
|
+
/**
|
|
33
|
+
* @license
|
|
34
|
+
* Copyright 2025 Google LLC
|
|
35
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
36
|
+
*/
|
|
37
|
+
function I(e,t){if(!t||typeof t!=`string`)throw Error(`model is required and must be a string`);if(t.includes(`..`)||t.includes(`?`)||t.includes(`&`))throw Error(`invalid model parameter`);if(e.isVertexAI()){if(t.startsWith(`publishers/`)||t.startsWith(`projects/`)||t.startsWith(`models/`))return t;if(t.indexOf(`/`)>=0){let e=t.split(`/`,2);return`publishers/${e[0]}/models/${e[1]}`}else return`publishers/google/models/${t}`}else if(t.startsWith(`models/`)||t.startsWith(`tunedModels/`))return t;else return`models/${t}`}function Rt(e,t){let n=I(e,t);return n?n.startsWith(`publishers/`)&&e.isVertexAI()?`projects/${e.getProject()}/locations/${e.getLocation()}/${n}`:n.startsWith(`models/`)&&e.isVertexAI()?`projects/${e.getProject()}/locations/${e.getLocation()}/publishers/google/${n}`:n:``}function zt(e){return Array.isArray(e)?e.map(e=>Bt(e)):[Bt(e)]}function Bt(e){if(typeof e==`object`&&e)return e;throw Error(`Could not parse input as Blob. Unsupported blob type: ${typeof e}`)}function Vt(e){let t=Bt(e);if(t.mimeType&&t.mimeType.startsWith(`image/`))return t;throw Error(`Unsupported mime type: ${t.mimeType}`)}function Ht(e){let t=Bt(e);if(t.mimeType&&t.mimeType.startsWith(`audio/`))return t;throw Error(`Unsupported mime type: ${t.mimeType}`)}function Ut(e){if(e==null)throw Error(`PartUnion is required`);if(typeof e==`object`)return e;if(typeof e==`string`)return{text:e};throw Error(`Unsupported part type: ${typeof e}`)}function Wt(e){if(e==null||Array.isArray(e)&&e.length===0)throw Error(`PartListUnion is required`);return Array.isArray(e)?e.map(e=>Ut(e)):[Ut(e)]}function Gt(e){return typeof e==`object`&&!!e&&`parts`in e&&Array.isArray(e.parts)}function Kt(e){return typeof e==`object`&&!!e&&`functionCall`in e}function qt(e){return typeof e==`object`&&!!e&&`functionResponse`in e}function L(e){if(e==null)throw Error(`ContentUnion is required`);return Gt(e)?e:{role:`user`,parts:Wt(e)}}function Jt(e,t){if(!t)return[];if(e.isVertexAI()&&Array.isArray(t))return t.flatMap(e=>{let t=L(e);return t.parts&&t.parts.length>0&&t.parts[0].text!==void 0?[t.parts[0].text]:[]});if(e.isVertexAI()){let e=L(t);return e.parts&&e.parts.length>0&&e.parts[0].text!==void 0?[e.parts[0].text]:[]}return Array.isArray(t)?t.map(e=>L(e)):[L(t)]}function R(e){if(e==null||Array.isArray(e)&&e.length===0)throw Error(`contents are required`);if(!Array.isArray(e)){if(Kt(e)||qt(e))throw Error(`To specify functionCall or functionResponse parts, please wrap them in a Content object, specifying the role for them`);return[L(e)]}let t=[],n=[],r=Gt(e[0]);for(let i of e){let e=Gt(i);if(e!=r)throw Error(`Mixing Content and Parts is not supported, please group the parts into a the appropriate Content objects and specify the roles for them`);if(e)t.push(i);else if(Kt(i)||qt(i))throw Error(`To specify functionCall or functionResponse parts, please wrap them, and any other parts, in Content objects as appropriate, specifying the role for them`);else n.push(i)}return r||t.push({role:`user`,parts:Wt(n)}),t}function Yt(e,t){e.includes(`null`)&&(t.nullable=!0);let n=e.filter(e=>e!==`null`);if(n.length===1)t.type=Object.values(N).includes(n[0].toUpperCase())?n[0].toUpperCase():N.TYPE_UNSPECIFIED;else{t.anyOf=[];for(let e of n)t.anyOf.push({type:Object.values(N).includes(e.toUpperCase())?e.toUpperCase():N.TYPE_UNSPECIFIED})}}function Xt(e){let t={},n=[`items`],r=[`anyOf`],i=[`properties`];if(e.type&&e.anyOf)throw Error(`type and anyOf cannot be both populated.`);let a=e.anyOf;a!=null&&a.length==2&&(a[0].type===`null`?(t.nullable=!0,e=a[1]):a[1].type===`null`&&(t.nullable=!0,e=a[0])),e.type instanceof Array&&Yt(e.type,t);for(let[a,o]of Object.entries(e))if(o!=null)if(a==`type`){if(o===`null`)throw Error(`type: null can not be the only possible type for the field.`);if(o instanceof Array)continue;t.type=Object.values(N).includes(o.toUpperCase())?o.toUpperCase():N.TYPE_UNSPECIFIED}else if(n.includes(a))t[a]=Xt(o);else if(r.includes(a)){let e=[];for(let n of o){if(n.type==`null`){t.nullable=!0;continue}e.push(Xt(n))}t[a]=e}else if(i.includes(a)){let e={};for(let[t,n]of Object.entries(o))e[t]=Xt(n);t[a]=e}else{if(a===`additionalProperties`)continue;t[a]=o}return t}function Zt(e){return Xt(e)}function Qt(e){if(typeof e==`object`)return e;if(typeof e==`string`)return{voiceConfig:{prebuiltVoiceConfig:{voiceName:e}}};throw Error(`Unsupported speechConfig type: ${typeof e}`)}function $t(e){if(`multiSpeakerVoiceConfig`in e)throw Error(`multiSpeakerVoiceConfig is not supported in the live API.`);return e}function en(e){if(e.functionDeclarations)for(let t of e.functionDeclarations)t.parameters&&(Object.keys(t.parameters).includes(`$schema`)?t.parametersJsonSchema||(t.parametersJsonSchema=t.parameters,delete t.parameters):t.parameters=Xt(t.parameters)),t.response&&(Object.keys(t.response).includes(`$schema`)?t.responseJsonSchema||(t.responseJsonSchema=t.response,delete t.response):t.response=Xt(t.response));return e}function tn(e){if(e==null)throw Error(`tools is required`);if(!Array.isArray(e))throw Error(`tools is required and must be an array of Tools`);let t=[];for(let n of e)t.push(n);return t}function nn(e,t,n,r=1){let i=!t.startsWith(`${n}/`)&&t.split(`/`).length===r;return e.isVertexAI()?t.startsWith(`projects/`)?t:t.startsWith(`locations/`)?`projects/${e.getProject()}/${t}`:t.startsWith(`${n}/`)?`projects/${e.getProject()}/locations/${e.getLocation()}/${t}`:i?`projects/${e.getProject()}/locations/${e.getLocation()}/${n}/${t}`:t:i?`${n}/${t}`:t}function z(e,t){if(typeof t!=`string`)throw Error(`name must be a string`);return nn(e,t,`cachedContents`)}function rn(e){switch(e){case`STATE_UNSPECIFIED`:return`JOB_STATE_UNSPECIFIED`;case`CREATING`:return`JOB_STATE_RUNNING`;case`ACTIVE`:return`JOB_STATE_SUCCEEDED`;case`FAILED`:return`JOB_STATE_FAILED`;default:return e}}function B(e){return _(e)}function an(e){return typeof e==`object`&&!!e&&`name`in e}function on(e){return typeof e==`object`&&!!e&&`video`in e}function sn(e){return typeof e==`object`&&!!e&&`uri`in e}function cn(e){let t;if(an(e)&&(t=e.name),!(sn(e)&&(t=e.uri,t===void 0))&&!(on(e)&&(t=e.video?.uri,t===void 0))){if(typeof e==`string`&&(t=e),t===void 0)throw Error(`Could not extract file name from the provided input.`);if(t.startsWith(`https://`)){let e=t.split(`files/`)[1].match(/[a-z0-9]+/);if(e===null)throw Error(`Could not extract file name from URI ${t}`);t=e[0]}else t.startsWith(`files/`)&&(t=t.split(`files/`)[1]);return t}}function ln(e,t){let n;return n=e.isVertexAI()?t?`publishers/google/models`:`models`:t?`models`:`tunedModels`,n}function un(e){for(let t of[`models`,`tunedModels`,`publisherModels`])if(dn(e,t))return e[t];return[]}function dn(e,t){return typeof e==`object`&&!!e&&t in e}function fn(e,t={}){let n=e,r={name:n.name,description:n.description,parametersJsonSchema:n.inputSchema};return n.outputSchema&&(r.responseJsonSchema=n.outputSchema),t.behavior&&(r.behavior=t.behavior),{functionDeclarations:[r]}}function pn(e,t={}){let n=[],r=new Set;for(let i of e){let e=i.name;if(r.has(e))throw Error(`Duplicate function name ${e} found in MCP tools. Please ensure function names are unique.`);r.add(e);let a=fn(i,t);a.functionDeclarations&&n.push(...a.functionDeclarations)}return{functionDeclarations:n}}function mn(e,t){let n;if(typeof t==`string`)if(e.isVertexAI())if(t.startsWith(`gs://`))n={format:`jsonl`,gcsUri:[t]};else if(t.startsWith(`bq://`))n={format:`bigquery`,bigqueryUri:t};else if(/^projects\/[^/]+\/locations\/[^/]+\/datasets\/[^/]+$/.test(t))n={format:`vertex-dataset`,vertexDatasetName:t};else throw Error(`Unsupported string source for Vertex AI: ${t}`);else if(t.startsWith(`files/`))n={fileName:t};else throw Error(`Unsupported string source for Gemini API: ${t}`);else if(Array.isArray(t)){if(e.isVertexAI())throw Error(`InlinedRequest[] is not supported in Vertex AI.`);n={inlinedRequests:t}}else n=t;let r=[n.gcsUri,n.bigqueryUri,n.vertexDatasetName].filter(Boolean).length,i=[n.inlinedRequests,n.fileName].filter(Boolean).length;if(e.isVertexAI()){if(i>0||r!==1)throw Error("Exactly one of `gcsUri`, `bigqueryUri`, or `vertexDatasetName` must be set for Vertex AI.")}else if(r>0||i!==1)throw Error("Exactly one of `inlinedRequests`, `fileName`, must be set for Gemini API.");return n}function hn(e){if(typeof e!=`string`)return e;let t=e;if(t.startsWith(`gs://`))return{format:`jsonl`,gcsUri:t};if(t.startsWith(`bq://`))return{format:`bigquery`,bigqueryUri:t};throw Error(`Unsupported destination: ${t}`)}function gn(e){if(typeof e!=`object`||!e)return{};let t=e,n=t.inlinedResponses;if(typeof n!=`object`||!n)return e;let r=n.inlinedResponses;if(!Array.isArray(r)||r.length===0)return e;let i=!1;for(let e of r){if(typeof e!=`object`||!e)continue;let t=e.response;if(!(typeof t!=`object`||!t)&&t.embedding!==void 0){i=!0;break}}return i&&(t.inlinedEmbedContentResponses=t.inlinedResponses,delete t.inlinedResponses),e}function _n(e,t){let n=t;if(!e.isVertexAI()){if(/batches\/[^/]+$/.test(n))return n.split(`/`).pop();throw Error(`Invalid batch job name: ${n}.`)}if(/^projects\/[^/]+\/locations\/[^/]+\/batchPredictionJobs\/[^/]+$/.test(n))return n.split(`/`).pop();if(/^\d+$/.test(n))return n;throw Error(`Invalid batch job name: ${n}.`)}function vn(e){let t=e;return t===`BATCH_STATE_UNSPECIFIED`?`JOB_STATE_UNSPECIFIED`:t===`BATCH_STATE_PENDING`?`JOB_STATE_PENDING`:t===`BATCH_STATE_RUNNING`?`JOB_STATE_RUNNING`:t===`BATCH_STATE_SUCCEEDED`?`JOB_STATE_SUCCEEDED`:t===`BATCH_STATE_FAILED`?`JOB_STATE_FAILED`:t===`BATCH_STATE_CANCELLED`?`JOB_STATE_CANCELLED`:t===`BATCH_STATE_EXPIRED`?`JOB_STATE_EXPIRED`:t}function yn(e){return e.includes(`gemini`)&&e!==`gemini-embedding-001`||e.includes(`maas`)}
|
|
38
|
+
/**
|
|
39
|
+
* @license
|
|
40
|
+
* Copyright 2025 Google LLC
|
|
41
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
42
|
+
*/
|
|
43
|
+
function bn(e){let t={},n=m(e,[`apiKey`]);if(n!=null&&p(t,[`apiKey`],n),m(e,[`apiKeyConfig`])!==void 0)throw Error(`apiKeyConfig parameter is not supported in Gemini API.`);if(m(e,[`authType`])!==void 0)throw Error(`authType parameter is not supported in Gemini API.`);if(m(e,[`googleServiceAccountConfig`])!==void 0)throw Error(`googleServiceAccountConfig parameter is not supported in Gemini API.`);if(m(e,[`httpBasicAuthConfig`])!==void 0)throw Error(`httpBasicAuthConfig parameter is not supported in Gemini API.`);if(m(e,[`oauthConfig`])!==void 0)throw Error(`oauthConfig parameter is not supported in Gemini API.`);if(m(e,[`oidcConfig`])!==void 0)throw Error(`oidcConfig parameter is not supported in Gemini API.`);return t}function xn(e){let t={},n=m(e,[`responsesFile`]);n!=null&&p(t,[`fileName`],n);let r=m(e,[`inlinedResponses`,`inlinedResponses`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>ar(e))),p(t,[`inlinedResponses`],e)}let i=m(e,[`inlinedEmbedContentResponses`,`inlinedResponses`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),p(t,[`inlinedEmbedContentResponses`],e)}return t}function Sn(e){let t={},n=m(e,[`predictionsFormat`]);n!=null&&p(t,[`format`],n);let r=m(e,[`gcsDestination`,`outputUriPrefix`]);r!=null&&p(t,[`gcsUri`],r);let i=m(e,[`bigqueryDestination`,`outputUri`]);i!=null&&p(t,[`bigqueryUri`],i);let a=m(e,[`vertexMultimodalDatasetDestination`]);return a!=null&&p(t,[`vertexDataset`],gr(a)),t}function Cn(e){let t={},n=m(e,[`format`]);n!=null&&p(t,[`predictionsFormat`],n);let r=m(e,[`gcsUri`]);r!=null&&p(t,[`gcsDestination`,`outputUriPrefix`],r);let i=m(e,[`bigqueryUri`]);if(i!=null&&p(t,[`bigqueryDestination`,`outputUri`],i),m(e,[`fileName`])!==void 0)throw Error(`fileName parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);if(m(e,[`inlinedResponses`])!==void 0)throw Error(`inlinedResponses parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);if(m(e,[`inlinedEmbedContentResponses`])!==void 0)throw Error(`inlinedEmbedContentResponses parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);let a=m(e,[`vertexDataset`]);return a!=null&&p(t,[`vertexMultimodalDatasetDestination`],_r(a)),t}function wn(e){let t={},n=m(e,[`name`]);n!=null&&p(t,[`name`],n);let r=m(e,[`metadata`,`displayName`]);r!=null&&p(t,[`displayName`],r);let i=m(e,[`metadata`,`state`]);i!=null&&p(t,[`state`],vn(i));let a=m(e,[`metadata`,`createTime`]);a!=null&&p(t,[`createTime`],a);let o=m(e,[`metadata`,`endTime`]);o!=null&&p(t,[`endTime`],o);let s=m(e,[`metadata`,`updateTime`]);s!=null&&p(t,[`updateTime`],s);let c=m(e,[`metadata`,`model`]);c!=null&&p(t,[`model`],c);let l=m(e,[`metadata`,`output`]);return l!=null&&p(t,[`dest`],xn(gn(l))),t}function Tn(e){let t={},n=m(e,[`name`]);n!=null&&p(t,[`name`],n);let r=m(e,[`displayName`]);r!=null&&p(t,[`displayName`],r);let i=m(e,[`state`]);i!=null&&p(t,[`state`],vn(i));let a=m(e,[`error`]);a!=null&&p(t,[`error`],a);let o=m(e,[`createTime`]);o!=null&&p(t,[`createTime`],o);let s=m(e,[`startTime`]);s!=null&&p(t,[`startTime`],s);let c=m(e,[`endTime`]);c!=null&&p(t,[`endTime`],c);let l=m(e,[`updateTime`]);l!=null&&p(t,[`updateTime`],l);let u=m(e,[`model`]);u!=null&&p(t,[`model`],u);let d=m(e,[`inputConfig`]);d!=null&&p(t,[`src`],En(d));let f=m(e,[`outputConfig`]);f!=null&&p(t,[`dest`],Sn(gn(f)));let h=m(e,[`completionStats`]);h!=null&&p(t,[`completionStats`],h);let g=m(e,[`outputInfo`]);return g!=null&&p(t,[`outputInfo`],g),t}function En(e){let t={},n=m(e,[`instancesFormat`]);n!=null&&p(t,[`format`],n);let r=m(e,[`gcsSource`,`uris`]);r!=null&&p(t,[`gcsUri`],r);let i=m(e,[`bigquerySource`,`inputUri`]);i!=null&&p(t,[`bigqueryUri`],i);let a=m(e,[`vertexMultimodalDatasetSource`,`datasetName`]);return a!=null&&p(t,[`vertexDatasetName`],a),t}function Dn(e,t){let n={};if(m(t,[`format`])!==void 0)throw Error(`format parameter is not supported in Gemini API.`);if(m(t,[`gcsUri`])!==void 0)throw Error(`gcsUri parameter is not supported in Gemini API.`);if(m(t,[`bigqueryUri`])!==void 0)throw Error(`bigqueryUri parameter is not supported in Gemini API.`);let r=m(t,[`fileName`]);r!=null&&p(n,[`fileName`],r);let i=m(t,[`inlinedRequests`]);if(i!=null){let t=i;Array.isArray(t)&&(t=t.map(t=>ir(e,t))),p(n,[`requests`,`requests`],t)}if(m(t,[`vertexDatasetName`])!==void 0)throw Error(`vertexDatasetName parameter is not supported in Gemini API.`);return n}function On(e){let t={},n=m(e,[`format`]);n!=null&&p(t,[`instancesFormat`],n);let r=m(e,[`gcsUri`]);r!=null&&p(t,[`gcsSource`,`uris`],r);let i=m(e,[`bigqueryUri`]);if(i!=null&&p(t,[`bigquerySource`,`inputUri`],i),m(e,[`fileName`])!==void 0)throw Error(`fileName parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);if(m(e,[`inlinedRequests`])!==void 0)throw Error(`inlinedRequests parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);let a=m(e,[`vertexDatasetName`]);return a!=null&&p(t,[`vertexMultimodalDatasetSource`,`datasetName`],a),t}function kn(e){let t={},n=m(e,[`data`]);if(n!=null&&p(t,[`data`],n),m(e,[`displayName`])!==void 0)throw Error(`displayName parameter is not supported in Gemini API.`);let r=m(e,[`mimeType`]);return r!=null&&p(t,[`mimeType`],r),t}function An(e,t){let n={},r=m(t,[`name`]);return r!=null&&p(n,[`_url`,`name`],_n(e,r)),n}function jn(e,t){let n={},r=m(t,[`name`]);return r!=null&&p(n,[`_url`,`name`],_n(e,r)),n}function Mn(e){let t={},n=m(e,[`content`]);n!=null&&p(t,[`content`],n);let r=m(e,[`citationMetadata`]);r!=null&&p(t,[`citationMetadata`],Nn(r));let i=m(e,[`tokenCount`]);i!=null&&p(t,[`tokenCount`],i);let a=m(e,[`finishReason`]);a!=null&&p(t,[`finishReason`],a);let o=m(e,[`groundingMetadata`]);o!=null&&p(t,[`groundingMetadata`],o);let s=m(e,[`avgLogprobs`]);s!=null&&p(t,[`avgLogprobs`],s);let c=m(e,[`index`]);c!=null&&p(t,[`index`],c);let l=m(e,[`logprobsResult`]);l!=null&&p(t,[`logprobsResult`],l);let u=m(e,[`safetyRatings`]);if(u!=null){let e=u;Array.isArray(e)&&(e=e.map(e=>e)),p(t,[`safetyRatings`],e)}let d=m(e,[`urlContextMetadata`]);return d!=null&&p(t,[`urlContextMetadata`],d),t}function Nn(e){let t={},n=m(e,[`citationSources`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>e)),p(t,[`citations`],e)}return t}function Pn(e){let t={},n=m(e,[`parts`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>fr(e))),p(t,[`parts`],e)}let r=m(e,[`role`]);return r!=null&&p(t,[`role`],r),t}function Fn(e,t){let n={},r=m(e,[`displayName`]);if(t!==void 0&&r!=null&&p(t,[`batch`,`displayName`],r),m(e,[`dest`])!==void 0)throw Error(`dest parameter is not supported in Gemini API.`);let i=m(e,[`webhookConfig`]);return t!==void 0&&i!=null&&p(t,[`batch`,`webhookConfig`],i),n}function In(e,t){let n={},r=m(e,[`displayName`]);t!==void 0&&r!=null&&p(t,[`displayName`],r);let i=m(e,[`dest`]);if(t!==void 0&&i!=null&&p(t,[`outputConfig`],Cn(hn(i))),m(e,[`webhookConfig`])!==void 0)throw Error(`webhookConfig parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);return n}function Ln(e,t){let n={},r=m(t,[`model`]);r!=null&&p(n,[`_url`,`model`],I(e,r));let i=m(t,[`src`]);i!=null&&p(n,[`batch`,`inputConfig`],Dn(e,mn(e,i)));let a=m(t,[`config`]);return a!=null&&Fn(a,n),n}function Rn(e,t){let n={},r=m(t,[`model`]);r!=null&&p(n,[`model`],I(e,r));let i=m(t,[`src`]);i!=null&&p(n,[`inputConfig`],On(mn(e,i)));let a=m(t,[`config`]);return a!=null&&In(a,n),n}function zn(e,t){let n={},r=m(e,[`displayName`]);return t!==void 0&&r!=null&&p(t,[`batch`,`displayName`],r),n}function Bn(e,t){let n={},r=m(t,[`model`]);r!=null&&p(n,[`_url`,`model`],I(e,r));let i=m(t,[`src`]);i!=null&&p(n,[`batch`,`inputConfig`],qn(e,i));let a=m(t,[`config`]);return a!=null&&zn(a,n),n}function Vn(e,t){let n={},r=m(t,[`name`]);return r!=null&&p(n,[`_url`,`name`],_n(e,r)),n}function Hn(e,t){let n={},r=m(t,[`name`]);return r!=null&&p(n,[`_url`,`name`],_n(e,r)),n}function Un(e){let t={},n=m(e,[`sdkHttpResponse`]);n!=null&&p(t,[`sdkHttpResponse`],n);let r=m(e,[`name`]);r!=null&&p(t,[`name`],r);let i=m(e,[`done`]);i!=null&&p(t,[`done`],i);let a=m(e,[`error`]);return a!=null&&p(t,[`error`],a),t}function Wn(e){let t={},n=m(e,[`sdkHttpResponse`]);n!=null&&p(t,[`sdkHttpResponse`],n);let r=m(e,[`name`]);r!=null&&p(t,[`name`],r);let i=m(e,[`done`]);i!=null&&p(t,[`done`],i);let a=m(e,[`error`]);return a!=null&&p(t,[`error`],a),t}function Gn(e,t){let n={},r=m(t,[`contents`]);if(r!=null){let t=Jt(e,r);Array.isArray(t)&&(t=t.map(e=>e)),p(n,[`requests[]`,`request`,`content`],t)}let i=m(t,[`config`]);return i!=null&&(p(n,[`_self`],Kn(i,n)),h(n,{"requests[].*":`requests[].request.*`})),n}function Kn(e,t){let n={},r=m(e,[`taskType`]);t!==void 0&&r!=null&&p(t,[`requests[]`,`taskType`],r);let i=m(e,[`title`]);t!==void 0&&i!=null&&p(t,[`requests[]`,`title`],i);let a=m(e,[`outputDimensionality`]);if(t!==void 0&&a!=null&&p(t,[`requests[]`,`outputDimensionality`],a),m(e,[`mimeType`])!==void 0)throw Error(`mimeType parameter is not supported in Gemini API.`);if(m(e,[`autoTruncate`])!==void 0)throw Error(`autoTruncate parameter is not supported in Gemini API.`);if(m(e,[`documentOcr`])!==void 0)throw Error(`documentOcr parameter is not supported in Gemini API.`);if(m(e,[`audioTrackExtraction`])!==void 0)throw Error(`audioTrackExtraction parameter is not supported in Gemini API.`);return n}function qn(e,t){let n={},r=m(t,[`fileName`]);r!=null&&p(n,[`file_name`],r);let i=m(t,[`inlinedRequests`]);return i!=null&&p(n,[`requests`],Gn(e,i)),n}function Jn(e){let t={};if(m(e,[`displayName`])!==void 0)throw Error(`displayName parameter is not supported in Gemini API.`);let n=m(e,[`fileUri`]);n!=null&&p(t,[`fileUri`],n);let r=m(e,[`mimeType`]);return r!=null&&p(t,[`mimeType`],r),t}function Yn(e){let t={},n=m(e,[`id`]);n!=null&&p(t,[`id`],n);let r=m(e,[`args`]);r!=null&&p(t,[`args`],r);let i=m(e,[`name`]);if(i!=null&&p(t,[`name`],i),m(e,[`partialArgs`])!==void 0)throw Error(`partialArgs parameter is not supported in Gemini API.`);if(m(e,[`willContinue`])!==void 0)throw Error(`willContinue parameter is not supported in Gemini API.`);return t}function Xn(e){let t={},n=m(e,[`allowedFunctionNames`]);n!=null&&p(t,[`allowedFunctionNames`],n);let r=m(e,[`mode`]);if(r!=null&&p(t,[`mode`],r),m(e,[`streamFunctionCallArguments`])!==void 0)throw Error(`streamFunctionCallArguments parameter is not supported in Gemini API.`);return t}function Zn(e,t,n){let r={},i=m(t,[`systemInstruction`]);n!==void 0&&i!=null&&p(n,[`systemInstruction`],Pn(L(i)));let a=m(t,[`temperature`]);a!=null&&p(r,[`temperature`],a);let o=m(t,[`topP`]);o!=null&&p(r,[`topP`],o);let s=m(t,[`topK`]);s!=null&&p(r,[`topK`],s);let c=m(t,[`candidateCount`]);c!=null&&p(r,[`candidateCount`],c);let l=m(t,[`maxOutputTokens`]);l!=null&&p(r,[`maxOutputTokens`],l);let u=m(t,[`stopSequences`]);u!=null&&p(r,[`stopSequences`],u);let d=m(t,[`responseLogprobs`]);d!=null&&p(r,[`responseLogprobs`],d);let f=m(t,[`logprobs`]);f!=null&&p(r,[`logprobs`],f);let h=m(t,[`presencePenalty`]);h!=null&&p(r,[`presencePenalty`],h);let g=m(t,[`frequencyPenalty`]);g!=null&&p(r,[`frequencyPenalty`],g);let _=m(t,[`seed`]);_!=null&&p(r,[`seed`],_);let v=m(t,[`responseMimeType`]);v!=null&&p(r,[`responseMimeType`],v);let y=m(t,[`responseSchema`]);y!=null&&p(r,[`responseSchema`],Zt(y));let b=m(t,[`responseJsonSchema`]);if(b!=null&&p(r,[`responseJsonSchema`],b),m(t,[`routingConfig`])!==void 0)throw Error(`routingConfig parameter is not supported in Gemini API.`);if(m(t,[`modelSelectionConfig`])!==void 0)throw Error(`modelSelectionConfig parameter is not supported in Gemini API.`);let x=m(t,[`safetySettings`]);if(n!==void 0&&x!=null){let e=x;Array.isArray(e)&&(e=e.map(e=>pr(e))),p(n,[`safetySettings`],e)}let S=m(t,[`tools`]);if(n!==void 0&&S!=null){let e=tn(S);Array.isArray(e)&&(e=e.map(e=>hr(en(e)))),p(n,[`tools`],e)}let C=m(t,[`toolConfig`]);if(n!==void 0&&C!=null&&p(n,[`toolConfig`],mr(C)),m(t,[`labels`])!==void 0)throw Error(`labels parameter is not supported in Gemini API.`);let w=m(t,[`cachedContent`]);n!==void 0&&w!=null&&p(n,[`cachedContent`],z(e,w));let T=m(t,[`responseModalities`]);T!=null&&p(r,[`responseModalities`],T);let E=m(t,[`mediaResolution`]);E!=null&&p(r,[`mediaResolution`],E);let D=m(t,[`speechConfig`]);if(D!=null&&p(r,[`speechConfig`],Qt(D)),m(t,[`audioTimestamp`])!==void 0)throw Error(`audioTimestamp parameter is not supported in Gemini API.`);let O=m(t,[`thinkingConfig`]);O!=null&&p(r,[`thinkingConfig`],O);let k=m(t,[`imageConfig`]);k!=null&&p(r,[`imageConfig`],rr(k));let A=m(t,[`enableEnhancedCivicAnswers`]);if(A!=null&&p(r,[`enableEnhancedCivicAnswers`],A),m(t,[`modelArmorConfig`])!==void 0)throw Error(`modelArmorConfig parameter is not supported in Gemini API.`);let j=m(t,[`serviceTier`]);return n!==void 0&&j!=null&&p(n,[`serviceTier`],j),r}function Qn(e){let t={},n=m(e,[`sdkHttpResponse`]);n!=null&&p(t,[`sdkHttpResponse`],n);let r=m(e,[`candidates`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>Mn(e))),p(t,[`candidates`],e)}let i=m(e,[`modelVersion`]);i!=null&&p(t,[`modelVersion`],i);let a=m(e,[`promptFeedback`]);a!=null&&p(t,[`promptFeedback`],a);let o=m(e,[`responseId`]);o!=null&&p(t,[`responseId`],o);let s=m(e,[`usageMetadata`]);s!=null&&p(t,[`usageMetadata`],s);let c=m(e,[`modelStatus`]);return c!=null&&p(t,[`modelStatus`],c),t}function $n(e,t){let n={},r=m(t,[`name`]);return r!=null&&p(n,[`_url`,`name`],_n(e,r)),n}function er(e,t){let n={},r=m(t,[`name`]);return r!=null&&p(n,[`_url`,`name`],_n(e,r)),n}function tr(e){let t={},n=m(e,[`authConfig`]);n!=null&&p(t,[`authConfig`],bn(n));let r=m(e,[`enableWidget`]);return r!=null&&p(t,[`enableWidget`],r),t}function nr(e){let t={},n=m(e,[`searchTypes`]);if(n!=null&&p(t,[`searchTypes`],n),m(e,[`blockingConfidence`])!==void 0)throw Error(`blockingConfidence parameter is not supported in Gemini API.`);if(m(e,[`excludeDomains`])!==void 0)throw Error(`excludeDomains parameter is not supported in Gemini API.`);let r=m(e,[`timeRangeFilter`]);return r!=null&&p(t,[`timeRangeFilter`],r),t}function rr(e){let t={},n=m(e,[`aspectRatio`]);n!=null&&p(t,[`aspectRatio`],n);let r=m(e,[`imageSize`]);if(r!=null&&p(t,[`imageSize`],r),m(e,[`personGeneration`])!==void 0)throw Error(`personGeneration parameter is not supported in Gemini API.`);if(m(e,[`prominentPeople`])!==void 0)throw Error(`prominentPeople parameter is not supported in Gemini API.`);if(m(e,[`outputMimeType`])!==void 0)throw Error(`outputMimeType parameter is not supported in Gemini API.`);if(m(e,[`outputCompressionQuality`])!==void 0)throw Error(`outputCompressionQuality parameter is not supported in Gemini API.`);if(m(e,[`imageOutputOptions`])!==void 0)throw Error(`imageOutputOptions parameter is not supported in Gemini API.`);return t}function ir(e,t){let n={},r=m(t,[`model`]);r!=null&&p(n,[`request`,`model`],I(e,r));let i=m(t,[`contents`]);if(i!=null){let e=R(i);Array.isArray(e)&&(e=e.map(e=>Pn(e))),p(n,[`request`,`contents`],e)}let a=m(t,[`metadata`]);a!=null&&p(n,[`metadata`],a);let o=m(t,[`config`]);return o!=null&&p(n,[`request`,`generationConfig`],Zn(e,o,m(n,[`request`],{}))),n}function ar(e){let t={},n=m(e,[`response`]);n!=null&&p(t,[`response`],Qn(n));let r=m(e,[`metadata`]);r!=null&&p(t,[`metadata`],r);let i=m(e,[`error`]);return i!=null&&p(t,[`error`],i),t}function or(e,t){let n={},r=m(e,[`pageSize`]);t!==void 0&&r!=null&&p(t,[`_query`,`pageSize`],r);let i=m(e,[`pageToken`]);if(t!==void 0&&i!=null&&p(t,[`_query`,`pageToken`],i),m(e,[`filter`])!==void 0)throw Error(`filter parameter is not supported in Gemini API.`);return n}function sr(e,t){let n={},r=m(e,[`pageSize`]);t!==void 0&&r!=null&&p(t,[`_query`,`pageSize`],r);let i=m(e,[`pageToken`]);t!==void 0&&i!=null&&p(t,[`_query`,`pageToken`],i);let a=m(e,[`filter`]);return t!==void 0&&a!=null&&p(t,[`_query`,`filter`],a),n}function cr(e){let t={},n=m(e,[`config`]);return n!=null&&or(n,t),t}function lr(e){let t={},n=m(e,[`config`]);return n!=null&&sr(n,t),t}function ur(e){let t={},n=m(e,[`sdkHttpResponse`]);n!=null&&p(t,[`sdkHttpResponse`],n);let r=m(e,[`nextPageToken`]);r!=null&&p(t,[`nextPageToken`],r);let i=m(e,[`operations`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>wn(e))),p(t,[`batchJobs`],e)}return t}function dr(e){let t={},n=m(e,[`sdkHttpResponse`]);n!=null&&p(t,[`sdkHttpResponse`],n);let r=m(e,[`nextPageToken`]);r!=null&&p(t,[`nextPageToken`],r);let i=m(e,[`batchPredictionJobs`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>Tn(e))),p(t,[`batchJobs`],e)}return t}function fr(e){let t={},n=m(e,[`mediaResolution`]);n!=null&&p(t,[`mediaResolution`],n);let r=m(e,[`codeExecutionResult`]);r!=null&&p(t,[`codeExecutionResult`],r);let i=m(e,[`executableCode`]);i!=null&&p(t,[`executableCode`],i);let a=m(e,[`fileData`]);a!=null&&p(t,[`fileData`],Jn(a));let o=m(e,[`functionCall`]);o!=null&&p(t,[`functionCall`],Yn(o));let s=m(e,[`functionResponse`]);s!=null&&p(t,[`functionResponse`],s);let c=m(e,[`inlineData`]);c!=null&&p(t,[`inlineData`],kn(c));let l=m(e,[`text`]);l!=null&&p(t,[`text`],l);let u=m(e,[`thought`]);u!=null&&p(t,[`thought`],u);let d=m(e,[`thoughtSignature`]);d!=null&&p(t,[`thoughtSignature`],d);let f=m(e,[`videoMetadata`]);f!=null&&p(t,[`videoMetadata`],f);let h=m(e,[`toolCall`]);h!=null&&p(t,[`toolCall`],h);let g=m(e,[`toolResponse`]);g!=null&&p(t,[`toolResponse`],g);let _=m(e,[`partMetadata`]);return _!=null&&p(t,[`partMetadata`],_),t}function pr(e){let t={},n=m(e,[`category`]);if(n!=null&&p(t,[`category`],n),m(e,[`method`])!==void 0)throw Error(`method parameter is not supported in Gemini API.`);let r=m(e,[`threshold`]);return r!=null&&p(t,[`threshold`],r),t}function mr(e){let t={},n=m(e,[`retrievalConfig`]);n!=null&&p(t,[`retrievalConfig`],n);let r=m(e,[`functionCallingConfig`]);r!=null&&p(t,[`functionCallingConfig`],Xn(r));let i=m(e,[`includeServerSideToolInvocations`]);return i!=null&&p(t,[`includeServerSideToolInvocations`],i),t}function hr(e){let t={};if(m(e,[`retrieval`])!==void 0)throw Error(`retrieval parameter is not supported in Gemini API.`);let n=m(e,[`computerUse`]);n!=null&&p(t,[`computerUse`],n);let r=m(e,[`fileSearch`]);r!=null&&p(t,[`fileSearch`],r);let i=m(e,[`googleSearch`]);i!=null&&p(t,[`googleSearch`],nr(i));let a=m(e,[`googleMaps`]);a!=null&&p(t,[`googleMaps`],tr(a));let o=m(e,[`codeExecution`]);if(o!=null&&p(t,[`codeExecution`],o),m(e,[`enterpriseWebSearch`])!==void 0)throw Error(`enterpriseWebSearch parameter is not supported in Gemini API.`);let s=m(e,[`functionDeclarations`]);if(s!=null){let e=s;Array.isArray(e)&&(e=e.map(e=>e)),p(t,[`functionDeclarations`],e)}let c=m(e,[`googleSearchRetrieval`]);if(c!=null&&p(t,[`googleSearchRetrieval`],c),m(e,[`parallelAiSearch`])!==void 0)throw Error(`parallelAiSearch parameter is not supported in Gemini API.`);let l=m(e,[`urlContext`]);l!=null&&p(t,[`urlContext`],l);let u=m(e,[`mcpServers`]);if(u!=null){let e=u;Array.isArray(e)&&(e=e.map(e=>e)),p(t,[`mcpServers`],e)}return t}function gr(e){let t={},n=m(e,[`bigqueryDestination`,`outputUri`]);n!=null&&p(t,[`bigqueryDestination`],n);let r=m(e,[`displayName`]);return r!=null&&p(t,[`displayName`],r),t}function _r(e){let t={},n=m(e,[`bigqueryDestination`]);n!=null&&p(t,[`bigqueryDestination`,`outputUri`],n);let r=m(e,[`displayName`]);return r!=null&&p(t,[`displayName`],r),t}
|
|
44
|
+
/**
|
|
45
|
+
* @license
|
|
46
|
+
* Copyright 2025 Google LLC
|
|
47
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
48
|
+
*/
|
|
49
|
+
var V;(function(e){e.PAGED_ITEM_BATCH_JOBS=`batchJobs`,e.PAGED_ITEM_MODELS=`models`,e.PAGED_ITEM_TUNING_JOBS=`tuningJobs`,e.PAGED_ITEM_FILES=`files`,e.PAGED_ITEM_CACHED_CONTENTS=`cachedContents`,e.PAGED_ITEM_FILE_SEARCH_STORES=`fileSearchStores`,e.PAGED_ITEM_DOCUMENTS=`documents`})(V||={});var H=class{constructor(e,t,n,r){this.pageInternal=[],this.paramsInternal={},this.requestInternal=t,this.init(e,n,r)}init(e,t,n){this.nameInternal=e,this.pageInternal=t[this.nameInternal]||[],this.sdkHttpResponseInternal=t?.sdkHttpResponse,this.idxInternal=0;let r={config:{}};r=!n||Object.keys(n).length===0?{config:{}}:typeof n==`object`?Object.assign({},n):n,r.config&&(r.config.pageToken=t.nextPageToken),this.paramsInternal=r,this.pageInternalSize=r.config?.pageSize??this.pageInternal.length}initNextPage(e){this.init(this.nameInternal,e,this.paramsInternal)}get page(){return this.pageInternal}get name(){return this.nameInternal}get pageSize(){return this.pageInternalSize}get sdkHttpResponse(){return this.sdkHttpResponseInternal}get params(){return this.paramsInternal}get pageLength(){return this.pageInternal.length}getItem(e){return this.pageInternal[e]}[Symbol.asyncIterator](){return{next:async()=>{if(this.idxInternal>=this.pageLength)if(this.hasNextPage())await this.nextPage();else return{value:void 0,done:!0};let e=this.getItem(this.idxInternal);return this.idxInternal+=1,{value:e,done:!1}},return:async()=>({value:void 0,done:!0})}}async nextPage(){if(!this.hasNextPage())throw Error(`No more pages to fetch.`);let e=await this.requestInternal(this.params);return this.initNextPage(e),this.page}hasNextPage(){return this.params.config?.pageToken!==void 0}},vr=class extends d{constructor(e){
|
|
50
|
+
/**
|
|
51
|
+
* @license
|
|
52
|
+
* Copyright 2025 Google LLC
|
|
53
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
54
|
+
*/
|
|
55
|
+
super(),this.apiClient=e,this.list=async(e={})=>new H(V.PAGED_ITEM_BATCH_JOBS,e=>this.listInternal(e),await this.listInternal(e),e),this.create=async e=>(this.apiClient.isVertexAI()&&(e.config=this.formatDestination(e.src,e.config)),this.createInternal(e)),this.createEmbeddings=async e=>{if(console.warn(`batches.createEmbeddings() is experimental and may change without notice.`),this.apiClient.isVertexAI())throw Error(`Gemini Enterprise Agent Platform (previously known as Vertex AI) does not support batches.createEmbeddings.`);return this.createEmbeddingsInternal(e)}}createInlinedGenerateContentRequest(e){let t=Ln(this.apiClient,e),n=t._url,r=f(`{model}:batchGenerateContent`,n),i=t.batch.inputConfig.requests,a=i.requests,o=[];for(let e of a){let t=Object.assign({},e);if(t.systemInstruction){let e=t.systemInstruction;delete t.systemInstruction;let n=t.request;n.systemInstruction=e,t.request=n}o.push(t)}return i.requests=o,delete t.config,delete t._url,delete t._query,{path:r,body:t}}getGcsUri(e){if(typeof e==`string`)return e.startsWith(`gs://`)?e:void 0;if(!Array.isArray(e)&&e.gcsUri&&e.gcsUri.length>0)return e.gcsUri[0]}getBigqueryUri(e){if(typeof e==`string`)return e.startsWith(`bq://`)?e:void 0;if(!Array.isArray(e))return e.bigqueryUri}formatDestination(e,t){let n=t?Object.assign({},t):{},r=Date.now().toString();if(n.displayName||=`genaiBatchJob_${r}`,n.dest===void 0){let t=this.getGcsUri(e),i=this.getBigqueryUri(e);if(t)t.endsWith(`.jsonl`)?n.dest=`${t.slice(0,-6)}/dest`:n.dest=`${t}_dest_${r}`;else if(i)n.dest=`${i}_dest_${r}`;else throw Error(`Unsupported source for Gemini Enterprise Agent Platform (previously known as Vertex AI): No GCS or BigQuery URI found.`)}return n}async createInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Rn(this.apiClient,e);return n=f(`batchPredictionJobs`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>Tn(e))}else{let i=Ln(this.apiClient,e);return n=f(`{model}:batchGenerateContent`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>wn(e))}}async createEmbeddingsInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=Bn(this.apiClient,e);return n=f(`{model}:asyncBatchEmbedContent`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>wn(e))}}async get(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=er(this.apiClient,e);return n=f(`batchPredictionJobs/{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>Tn(e))}else{let i=$n(this.apiClient,e);return n=f(`batches/{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>wn(e))}}async cancel(e){let t=``,n={};if(this.apiClient.isVertexAI()){let r=jn(this.apiClient,e);t=f(`batchPredictionJobs/{name}:cancel`,r._url),n=r._query,delete r._url,delete r._query,await this.apiClient.request({path:t,queryParams:n,body:JSON.stringify(r),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal})}else{let r=An(this.apiClient,e);t=f(`batches/{name}:cancel`,r._url),n=r._query,delete r._url,delete r._query,await this.apiClient.request({path:t,queryParams:n,body:JSON.stringify(r),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal})}}async listInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=lr(e);return n=f(`batchPredictionJobs`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=dr(e),n=new Pt;return Object.assign(n,t),n})}else{let i=cr(e);return n=f(`batches`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=ur(e),n=new Pt;return Object.assign(n,t),n})}}async delete(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Hn(this.apiClient,e);return n=f(`batchPredictionJobs/{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`DELETE`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>Wn(e))}else{let i=Vn(this.apiClient,e);return n=f(`batches/{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`DELETE`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>Un(e))}}};
|
|
56
|
+
/**
|
|
57
|
+
* @license
|
|
58
|
+
* Copyright 2025 Google LLC
|
|
59
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
60
|
+
*/
|
|
61
|
+
function yr(e){let t={},n=m(e,[`apiKey`]);if(n!=null&&p(t,[`apiKey`],n),m(e,[`apiKeyConfig`])!==void 0)throw Error(`apiKeyConfig parameter is not supported in Gemini API.`);if(m(e,[`authType`])!==void 0)throw Error(`authType parameter is not supported in Gemini API.`);if(m(e,[`googleServiceAccountConfig`])!==void 0)throw Error(`googleServiceAccountConfig parameter is not supported in Gemini API.`);if(m(e,[`httpBasicAuthConfig`])!==void 0)throw Error(`httpBasicAuthConfig parameter is not supported in Gemini API.`);if(m(e,[`oauthConfig`])!==void 0)throw Error(`oauthConfig parameter is not supported in Gemini API.`);if(m(e,[`oidcConfig`])!==void 0)throw Error(`oidcConfig parameter is not supported in Gemini API.`);return t}function br(e){let t={},n=m(e,[`data`]);if(n!=null&&p(t,[`data`],n),m(e,[`displayName`])!==void 0)throw Error(`displayName parameter is not supported in Gemini API.`);let r=m(e,[`mimeType`]);return r!=null&&p(t,[`mimeType`],r),t}function xr(e){let t={},n=m(e,[`parts`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>Gr(e))),p(t,[`parts`],e)}let r=m(e,[`role`]);return r!=null&&p(t,[`role`],r),t}function Sr(e){let t={},n=m(e,[`parts`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>Kr(e))),p(t,[`parts`],e)}let r=m(e,[`role`]);return r!=null&&p(t,[`role`],r),t}function Cr(e,t){let n={},r=m(e,[`ttl`]);t!==void 0&&r!=null&&p(t,[`ttl`],r);let i=m(e,[`expireTime`]);t!==void 0&&i!=null&&p(t,[`expireTime`],i);let a=m(e,[`displayName`]);t!==void 0&&a!=null&&p(t,[`displayName`],a);let o=m(e,[`contents`]);if(t!==void 0&&o!=null){let e=R(o);Array.isArray(e)&&(e=e.map(e=>xr(e))),p(t,[`contents`],e)}let s=m(e,[`systemInstruction`]);t!==void 0&&s!=null&&p(t,[`systemInstruction`],xr(L(s)));let c=m(e,[`tools`]);if(t!==void 0&&c!=null){let e=c;Array.isArray(e)&&(e=e.map(e=>Yr(e))),p(t,[`tools`],e)}let l=m(e,[`toolConfig`]);if(t!==void 0&&l!=null&&p(t,[`toolConfig`],qr(l)),m(e,[`kmsKeyName`])!==void 0)throw Error(`kmsKeyName parameter is not supported in Gemini API.`);return n}function wr(e,t){let n={},r=m(e,[`ttl`]);t!==void 0&&r!=null&&p(t,[`ttl`],r);let i=m(e,[`expireTime`]);t!==void 0&&i!=null&&p(t,[`expireTime`],i);let a=m(e,[`displayName`]);t!==void 0&&a!=null&&p(t,[`displayName`],a);let o=m(e,[`contents`]);if(t!==void 0&&o!=null){let e=R(o);Array.isArray(e)&&(e=e.map(e=>Sr(e))),p(t,[`contents`],e)}let s=m(e,[`systemInstruction`]);t!==void 0&&s!=null&&p(t,[`systemInstruction`],Sr(L(s)));let c=m(e,[`tools`]);if(t!==void 0&&c!=null){let e=c;Array.isArray(e)&&(e=e.map(e=>Xr(e))),p(t,[`tools`],e)}let l=m(e,[`toolConfig`]);t!==void 0&&l!=null&&p(t,[`toolConfig`],Jr(l));let u=m(e,[`kmsKeyName`]);return t!==void 0&&u!=null&&p(t,[`encryption_spec`,`kmsKeyName`],u),n}function Tr(e,t){let n={},r=m(t,[`model`]);r!=null&&p(n,[`model`],Rt(e,r));let i=m(t,[`config`]);return i!=null&&Cr(i,n),n}function Er(e,t){let n={},r=m(t,[`model`]);r!=null&&p(n,[`model`],Rt(e,r));let i=m(t,[`config`]);return i!=null&&wr(i,n),n}function Dr(e,t){let n={},r=m(t,[`name`]);return r!=null&&p(n,[`_url`,`name`],z(e,r)),n}function Or(e,t){let n={},r=m(t,[`name`]);return r!=null&&p(n,[`_url`,`name`],z(e,r)),n}function kr(e){let t={},n=m(e,[`sdkHttpResponse`]);return n!=null&&p(t,[`sdkHttpResponse`],n),t}function Ar(e){let t={},n=m(e,[`sdkHttpResponse`]);return n!=null&&p(t,[`sdkHttpResponse`],n),t}function jr(e){let t={};if(m(e,[`displayName`])!==void 0)throw Error(`displayName parameter is not supported in Gemini API.`);let n=m(e,[`fileUri`]);n!=null&&p(t,[`fileUri`],n);let r=m(e,[`mimeType`]);return r!=null&&p(t,[`mimeType`],r),t}function Mr(e){let t={},n=m(e,[`id`]);n!=null&&p(t,[`id`],n);let r=m(e,[`args`]);r!=null&&p(t,[`args`],r);let i=m(e,[`name`]);if(i!=null&&p(t,[`name`],i),m(e,[`partialArgs`])!==void 0)throw Error(`partialArgs parameter is not supported in Gemini API.`);if(m(e,[`willContinue`])!==void 0)throw Error(`willContinue parameter is not supported in Gemini API.`);return t}function Nr(e){let t={},n=m(e,[`allowedFunctionNames`]);n!=null&&p(t,[`allowedFunctionNames`],n);let r=m(e,[`mode`]);if(r!=null&&p(t,[`mode`],r),m(e,[`streamFunctionCallArguments`])!==void 0)throw Error(`streamFunctionCallArguments parameter is not supported in Gemini API.`);return t}function Pr(e){let t={},n=m(e,[`description`]);n!=null&&p(t,[`description`],n);let r=m(e,[`name`]);r!=null&&p(t,[`name`],r);let i=m(e,[`parameters`]);i!=null&&p(t,[`parameters`],i);let a=m(e,[`parametersJsonSchema`]);a!=null&&p(t,[`parametersJsonSchema`],a);let o=m(e,[`response`]);o!=null&&p(t,[`response`],o);let s=m(e,[`responseJsonSchema`]);if(s!=null&&p(t,[`responseJsonSchema`],s),m(e,[`behavior`])!==void 0)throw Error(`behavior parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);return t}function Fr(e,t){let n={},r=m(t,[`name`]);return r!=null&&p(n,[`_url`,`name`],z(e,r)),n}function Ir(e,t){let n={},r=m(t,[`name`]);return r!=null&&p(n,[`_url`,`name`],z(e,r)),n}function Lr(e){let t={},n=m(e,[`authConfig`]);n!=null&&p(t,[`authConfig`],yr(n));let r=m(e,[`enableWidget`]);return r!=null&&p(t,[`enableWidget`],r),t}function Rr(e){let t={},n=m(e,[`searchTypes`]);if(n!=null&&p(t,[`searchTypes`],n),m(e,[`blockingConfidence`])!==void 0)throw Error(`blockingConfidence parameter is not supported in Gemini API.`);if(m(e,[`excludeDomains`])!==void 0)throw Error(`excludeDomains parameter is not supported in Gemini API.`);let r=m(e,[`timeRangeFilter`]);return r!=null&&p(t,[`timeRangeFilter`],r),t}function zr(e,t){let n={},r=m(e,[`pageSize`]);t!==void 0&&r!=null&&p(t,[`_query`,`pageSize`],r);let i=m(e,[`pageToken`]);return t!==void 0&&i!=null&&p(t,[`_query`,`pageToken`],i),n}function Br(e,t){let n={},r=m(e,[`pageSize`]);t!==void 0&&r!=null&&p(t,[`_query`,`pageSize`],r);let i=m(e,[`pageToken`]);return t!==void 0&&i!=null&&p(t,[`_query`,`pageToken`],i),n}function Vr(e){let t={},n=m(e,[`config`]);return n!=null&&zr(n,t),t}function Hr(e){let t={},n=m(e,[`config`]);return n!=null&&Br(n,t),t}function Ur(e){let t={},n=m(e,[`sdkHttpResponse`]);n!=null&&p(t,[`sdkHttpResponse`],n);let r=m(e,[`nextPageToken`]);r!=null&&p(t,[`nextPageToken`],r);let i=m(e,[`cachedContents`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),p(t,[`cachedContents`],e)}return t}function Wr(e){let t={},n=m(e,[`sdkHttpResponse`]);n!=null&&p(t,[`sdkHttpResponse`],n);let r=m(e,[`nextPageToken`]);r!=null&&p(t,[`nextPageToken`],r);let i=m(e,[`cachedContents`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),p(t,[`cachedContents`],e)}return t}function Gr(e){let t={},n=m(e,[`mediaResolution`]);n!=null&&p(t,[`mediaResolution`],n);let r=m(e,[`codeExecutionResult`]);r!=null&&p(t,[`codeExecutionResult`],r);let i=m(e,[`executableCode`]);i!=null&&p(t,[`executableCode`],i);let a=m(e,[`fileData`]);a!=null&&p(t,[`fileData`],jr(a));let o=m(e,[`functionCall`]);o!=null&&p(t,[`functionCall`],Mr(o));let s=m(e,[`functionResponse`]);s!=null&&p(t,[`functionResponse`],s);let c=m(e,[`inlineData`]);c!=null&&p(t,[`inlineData`],br(c));let l=m(e,[`text`]);l!=null&&p(t,[`text`],l);let u=m(e,[`thought`]);u!=null&&p(t,[`thought`],u);let d=m(e,[`thoughtSignature`]);d!=null&&p(t,[`thoughtSignature`],d);let f=m(e,[`videoMetadata`]);f!=null&&p(t,[`videoMetadata`],f);let h=m(e,[`toolCall`]);h!=null&&p(t,[`toolCall`],h);let g=m(e,[`toolResponse`]);g!=null&&p(t,[`toolResponse`],g);let _=m(e,[`partMetadata`]);return _!=null&&p(t,[`partMetadata`],_),t}function Kr(e){let t={},n=m(e,[`mediaResolution`]);n!=null&&p(t,[`mediaResolution`],n);let r=m(e,[`codeExecutionResult`]);r!=null&&p(t,[`codeExecutionResult`],r);let i=m(e,[`executableCode`]);i!=null&&p(t,[`executableCode`],i);let a=m(e,[`fileData`]);a!=null&&p(t,[`fileData`],a);let o=m(e,[`functionCall`]);o!=null&&p(t,[`functionCall`],o);let s=m(e,[`functionResponse`]);s!=null&&p(t,[`functionResponse`],s);let c=m(e,[`inlineData`]);c!=null&&p(t,[`inlineData`],c);let l=m(e,[`text`]);l!=null&&p(t,[`text`],l);let u=m(e,[`thought`]);u!=null&&p(t,[`thought`],u);let d=m(e,[`thoughtSignature`]);d!=null&&p(t,[`thoughtSignature`],d);let f=m(e,[`videoMetadata`]);if(f!=null&&p(t,[`videoMetadata`],f),m(e,[`toolCall`])!==void 0)throw Error(`toolCall parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);if(m(e,[`toolResponse`])!==void 0)throw Error(`toolResponse parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);if(m(e,[`partMetadata`])!==void 0)throw Error(`partMetadata parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);return t}function qr(e){let t={},n=m(e,[`retrievalConfig`]);n!=null&&p(t,[`retrievalConfig`],n);let r=m(e,[`functionCallingConfig`]);r!=null&&p(t,[`functionCallingConfig`],Nr(r));let i=m(e,[`includeServerSideToolInvocations`]);return i!=null&&p(t,[`includeServerSideToolInvocations`],i),t}function Jr(e){let t={},n=m(e,[`retrievalConfig`]);n!=null&&p(t,[`retrievalConfig`],n);let r=m(e,[`functionCallingConfig`]);if(r!=null&&p(t,[`functionCallingConfig`],r),m(e,[`includeServerSideToolInvocations`])!==void 0)throw Error(`includeServerSideToolInvocations parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);return t}function Yr(e){let t={};if(m(e,[`retrieval`])!==void 0)throw Error(`retrieval parameter is not supported in Gemini API.`);let n=m(e,[`computerUse`]);n!=null&&p(t,[`computerUse`],n);let r=m(e,[`fileSearch`]);r!=null&&p(t,[`fileSearch`],r);let i=m(e,[`googleSearch`]);i!=null&&p(t,[`googleSearch`],Rr(i));let a=m(e,[`googleMaps`]);a!=null&&p(t,[`googleMaps`],Lr(a));let o=m(e,[`codeExecution`]);if(o!=null&&p(t,[`codeExecution`],o),m(e,[`enterpriseWebSearch`])!==void 0)throw Error(`enterpriseWebSearch parameter is not supported in Gemini API.`);let s=m(e,[`functionDeclarations`]);if(s!=null){let e=s;Array.isArray(e)&&(e=e.map(e=>e)),p(t,[`functionDeclarations`],e)}let c=m(e,[`googleSearchRetrieval`]);if(c!=null&&p(t,[`googleSearchRetrieval`],c),m(e,[`parallelAiSearch`])!==void 0)throw Error(`parallelAiSearch parameter is not supported in Gemini API.`);let l=m(e,[`urlContext`]);l!=null&&p(t,[`urlContext`],l);let u=m(e,[`mcpServers`]);if(u!=null){let e=u;Array.isArray(e)&&(e=e.map(e=>e)),p(t,[`mcpServers`],e)}return t}function Xr(e){let t={},n=m(e,[`retrieval`]);n!=null&&p(t,[`retrieval`],n);let r=m(e,[`computerUse`]);if(r!=null&&p(t,[`computerUse`],r),m(e,[`fileSearch`])!==void 0)throw Error(`fileSearch parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);let i=m(e,[`googleSearch`]);i!=null&&p(t,[`googleSearch`],i);let a=m(e,[`googleMaps`]);a!=null&&p(t,[`googleMaps`],a);let o=m(e,[`codeExecution`]);o!=null&&p(t,[`codeExecution`],o);let s=m(e,[`enterpriseWebSearch`]);s!=null&&p(t,[`enterpriseWebSearch`],s);let c=m(e,[`functionDeclarations`]);if(c!=null){let e=c;Array.isArray(e)&&(e=e.map(e=>Pr(e))),p(t,[`functionDeclarations`],e)}let l=m(e,[`googleSearchRetrieval`]);l!=null&&p(t,[`googleSearchRetrieval`],l);let u=m(e,[`parallelAiSearch`]);u!=null&&p(t,[`parallelAiSearch`],u);let d=m(e,[`urlContext`]);if(d!=null&&p(t,[`urlContext`],d),m(e,[`mcpServers`])!==void 0)throw Error(`mcpServers parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);return t}function Zr(e,t){let n={},r=m(e,[`ttl`]);t!==void 0&&r!=null&&p(t,[`ttl`],r);let i=m(e,[`expireTime`]);return t!==void 0&&i!=null&&p(t,[`expireTime`],i),n}function Qr(e,t){let n={},r=m(e,[`ttl`]);t!==void 0&&r!=null&&p(t,[`ttl`],r);let i=m(e,[`expireTime`]);return t!==void 0&&i!=null&&p(t,[`expireTime`],i),n}function $r(e,t){let n={},r=m(t,[`name`]);r!=null&&p(n,[`_url`,`name`],z(e,r));let i=m(t,[`config`]);return i!=null&&Zr(i,n),n}function ei(e,t){let n={},r=m(t,[`name`]);r!=null&&p(n,[`_url`,`name`],z(e,r));let i=m(t,[`config`]);return i!=null&&Qr(i,n),n}
|
|
62
|
+
/**
|
|
63
|
+
* @license
|
|
64
|
+
* Copyright 2025 Google LLC
|
|
65
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
66
|
+
*/
|
|
67
|
+
var ti=class extends d{constructor(e){super(),this.apiClient=e,this.list=async(e={})=>new H(V.PAGED_ITEM_CACHED_CONTENTS,e=>this.listInternal(e),await this.listInternal(e),e)}async create(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Er(this.apiClient,e);return n=f(`cachedContents`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>e)}else{let i=Tr(this.apiClient,e);return n=f(`cachedContents`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>e)}}async get(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Ir(this.apiClient,e);return n=f(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>e)}else{let i=Fr(this.apiClient,e);return n=f(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>e)}}async delete(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Or(this.apiClient,e);return n=f(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`DELETE`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Ar(e),n=new wt;return Object.assign(n,t),n})}else{let i=Dr(this.apiClient,e);return n=f(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`DELETE`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=kr(e),n=new wt;return Object.assign(n,t),n})}}async update(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=ei(this.apiClient,e);return n=f(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`PATCH`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>e)}else{let i=$r(this.apiClient,e);return n=f(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`PATCH`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>e)}}async listInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Hr(e);return n=f(`cachedContents`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Wr(e),n=new Tt;return Object.assign(n,t),n})}else{let i=Vr(e);return n=f(`cachedContents`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Ur(e),n=new Tt;return Object.assign(n,t),n})}}};function U(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function ni(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)}function W(e){return this instanceof W?(this.v=e,this):new W(e)}function G(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof W?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}}function K(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof ni==`function`?ni(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}}
|
|
68
|
+
/**
|
|
69
|
+
* @license
|
|
70
|
+
* Copyright 2025 Google LLC
|
|
71
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
72
|
+
*/
|
|
73
|
+
function ri(e){if(e.candidates==null||e.candidates.length===0)return!1;let t=e.candidates[0]?.content;return t!==void 0&&ii(t)}function ii(e){if(e.parts===void 0||e.parts.length===0)return!1;for(let t of e.parts)if(t===void 0||Object.keys(t).length===0)return!1;return!0}function ai(e){if(e.length!==0){for(let t of e)if(t.role!==`user`&&t.role!==`model`)throw Error(`Role must be user or model, but got ${t.role}.`)}}function oi(e){if(e===void 0||e.length===0)return[];let t=[],n=e.length,r=0;for(;r<n;)if(e[r].role===`user`)t.push(e[r]),r++;else{let i=[],a=!0;for(;r<n&&e[r].role===`model`;)i.push(e[r]),a&&!ii(e[r])&&(a=!1),r++;a?t.push(...i):t.pop()}return t}var si=class{constructor(e,t){this.modelsModule=e,this.apiClient=t}create(e){return new ci(this.apiClient,this.modelsModule,e.model,e.config,structuredClone(e.history))}},ci=class{constructor(e,t,n,r={},i=[]){this.apiClient=e,this.modelsModule=t,this.model=n,this.config=r,this.history=i,this.sendPromise=Promise.resolve(),ai(i)}async sendMessage(e){await this.sendPromise;let t=L(e.message),n=this.modelsModule.generateContent({model:this.model,contents:this.getHistory(!0).concat(t),config:e.config??this.config});return this.sendPromise=(async()=>{let e=await n,r=e.candidates?.[0]?.content,i=e.automaticFunctionCallingHistory,a=this.getHistory(!0).length,o=[];i!=null&&(o=i.slice(a)??[]);let s=r?[r]:[];this.recordHistory(t,s,o)})(),await this.sendPromise.catch(()=>{this.sendPromise=Promise.resolve()}),n}async sendMessageStream(e){await this.sendPromise;let t=L(e.message),n=this.modelsModule.generateContentStream({model:this.model,contents:this.getHistory(!0).concat(t),config:e.config??this.config});this.sendPromise=n.then(()=>void 0).catch(()=>void 0);let r=await n;return this.processStreamResponse(r,t)}getHistory(e=!1){let t=e?oi(this.history):this.history;return structuredClone(t)}processStreamResponse(e,t){return G(this,arguments,function*(){var n,r,i,a;let o=[];try{for(var s=!0,c=K(e),l;l=yield W(c.next()),n=l.done,!n;s=!0){a=l.value,s=!1;let e=a;if(ri(e)){let t=e.candidates?.[0]?.content;t!==void 0&&o.push(t)}yield yield W(e)}}catch(e){r={error:e}}finally{try{!s&&!n&&(i=c.return)&&(yield W(i.call(c)))}finally{if(r)throw r.error}}this.recordHistory(t,o)})}recordHistory(e,t,n){let r=[];t.length>0&&t.every(e=>e.role!==void 0)?r=t:r.push({role:`model`,parts:[]}),n&&n.length>0?this.history.push(...oi(n)):this.history.push(e),this.history.push(...r)}},li=class e extends Error{constructor(t){
|
|
74
|
+
/**
|
|
75
|
+
* @license
|
|
76
|
+
* Copyright 2025 Google LLC
|
|
77
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
78
|
+
*/
|
|
79
|
+
super(t.message),this.name=`ApiError`,this.status=t.status,Object.setPrototypeOf(this,e.prototype)}};
|
|
80
|
+
/**
|
|
81
|
+
* @license
|
|
82
|
+
* Copyright 2025 Google LLC
|
|
83
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
84
|
+
*/
|
|
85
|
+
function ui(e){let t={},n=m(e,[`file`]);return n!=null&&p(t,[`file`],n),t}function di(e){let t={},n=m(e,[`sdkHttpResponse`]);return n!=null&&p(t,[`sdkHttpResponse`],n),t}function fi(e){let t={},n=m(e,[`name`]);return n!=null&&p(t,[`_url`,`file`],cn(n)),t}function pi(e){let t={},n=m(e,[`sdkHttpResponse`]);return n!=null&&p(t,[`sdkHttpResponse`],n),t}function mi(e){let t={},n=m(e,[`name`]);return n!=null&&p(t,[`_url`,`file`],cn(n)),t}function hi(e){let t={},n=m(e,[`uris`]);return n!=null&&p(t,[`uris`],n),t}function gi(e,t){let n={},r=m(e,[`pageSize`]);t!==void 0&&r!=null&&p(t,[`_query`,`pageSize`],r);let i=m(e,[`pageToken`]);return t!==void 0&&i!=null&&p(t,[`_query`,`pageToken`],i),n}function _i(e){let t={},n=m(e,[`config`]);return n!=null&&gi(n,t),t}function vi(e){let t={},n=m(e,[`sdkHttpResponse`]);n!=null&&p(t,[`sdkHttpResponse`],n);let r=m(e,[`nextPageToken`]);r!=null&&p(t,[`nextPageToken`],r);let i=m(e,[`files`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),p(t,[`files`],e)}return t}function yi(e){let t={},n=m(e,[`sdkHttpResponse`]);n!=null&&p(t,[`sdkHttpResponse`],n);let r=m(e,[`files`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),p(t,[`files`],e)}return t}
|
|
86
|
+
/**
|
|
87
|
+
* @license
|
|
88
|
+
* Copyright 2025 Google LLC
|
|
89
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
90
|
+
*/
|
|
91
|
+
var bi=class extends d{constructor(e){super(),this.apiClient=e,this.list=async(e={})=>new H(V.PAGED_ITEM_FILES,e=>this.listInternal(e),await this.listInternal(e),e)}async upload(e){if(this.apiClient.isVertexAI())throw Error(`Gemini Enterprise Agent Platform (previously known as Vertex AI) does not support uploading files. You can share files through a GCS bucket.`);return this.apiClient.uploadFile(e.file,e.config).then(e=>e)}async download(e){await this.apiClient.downloadFile(e)}async registerFiles(e){throw Error(`registerFiles is only supported in Node.js environments.`)}async _registerFiles(e){return this.registerFilesInternal(e)}async listInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=_i(e);return n=f(`files`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=vi(e),n=new At;return Object.assign(n,t),n})}}async createInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=ui(e);return n=f(`upload/v1beta/files`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>{let t=di(e),n=new jt;return Object.assign(n,t),n})}}async get(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=mi(e);return n=f(`files/{file}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>e)}}async delete(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=fi(e);return n=f(`files/{file}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`DELETE`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=pi(e),n=new Mt;return Object.assign(n,t),n})}}async registerFilesInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=hi(e);return n=f(`files:register`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>{let t=yi(e),n=new Nt;return Object.assign(n,t),n})}}};
|
|
92
|
+
/**
|
|
93
|
+
* @license
|
|
94
|
+
* Copyright 2025 Google LLC
|
|
95
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
96
|
+
*/
|
|
97
|
+
function xi(e){let t={};if(m(e,[`languageCodes`])!==void 0)throw Error(`languageCodes parameter is not supported in Gemini API.`);return t}function Si(e){let t={},n=m(e,[`apiKey`]);if(n!=null&&p(t,[`apiKey`],n),m(e,[`apiKeyConfig`])!==void 0)throw Error(`apiKeyConfig parameter is not supported in Gemini API.`);if(m(e,[`authType`])!==void 0)throw Error(`authType parameter is not supported in Gemini API.`);if(m(e,[`googleServiceAccountConfig`])!==void 0)throw Error(`googleServiceAccountConfig parameter is not supported in Gemini API.`);if(m(e,[`httpBasicAuthConfig`])!==void 0)throw Error(`httpBasicAuthConfig parameter is not supported in Gemini API.`);if(m(e,[`oauthConfig`])!==void 0)throw Error(`oauthConfig parameter is not supported in Gemini API.`);if(m(e,[`oidcConfig`])!==void 0)throw Error(`oidcConfig parameter is not supported in Gemini API.`);return t}function Ci(e){let t={},n=m(e,[`data`]);if(n!=null&&p(t,[`data`],n),m(e,[`displayName`])!==void 0)throw Error(`displayName parameter is not supported in Gemini API.`);let r=m(e,[`mimeType`]);return r!=null&&p(t,[`mimeType`],r),t}function wi(e){let t={},n=m(e,[`parts`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>Vi(e))),p(t,[`parts`],e)}let r=m(e,[`role`]);return r!=null&&p(t,[`role`],r),t}function Ti(e){let t={},n=m(e,[`parts`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>Hi(e))),p(t,[`parts`],e)}let r=m(e,[`role`]);return r!=null&&p(t,[`role`],r),t}function Ei(e){let t={};if(m(e,[`displayName`])!==void 0)throw Error(`displayName parameter is not supported in Gemini API.`);let n=m(e,[`fileUri`]);n!=null&&p(t,[`fileUri`],n);let r=m(e,[`mimeType`]);return r!=null&&p(t,[`mimeType`],r),t}function Di(e){let t={},n=m(e,[`id`]);n!=null&&p(t,[`id`],n);let r=m(e,[`args`]);r!=null&&p(t,[`args`],r);let i=m(e,[`name`]);if(i!=null&&p(t,[`name`],i),m(e,[`partialArgs`])!==void 0)throw Error(`partialArgs parameter is not supported in Gemini API.`);if(m(e,[`willContinue`])!==void 0)throw Error(`willContinue parameter is not supported in Gemini API.`);return t}function Oi(e){let t={},n=m(e,[`description`]);n!=null&&p(t,[`description`],n);let r=m(e,[`name`]);r!=null&&p(t,[`name`],r);let i=m(e,[`parameters`]);i!=null&&p(t,[`parameters`],i);let a=m(e,[`parametersJsonSchema`]);a!=null&&p(t,[`parametersJsonSchema`],a);let o=m(e,[`response`]);o!=null&&p(t,[`response`],o);let s=m(e,[`responseJsonSchema`]);if(s!=null&&p(t,[`responseJsonSchema`],s),m(e,[`behavior`])!==void 0)throw Error(`behavior parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);return t}function ki(e){let t={},n=m(e,[`modelSelectionConfig`]);n!=null&&p(t,[`modelConfig`],n);let r=m(e,[`responseJsonSchema`]);r!=null&&p(t,[`responseJsonSchema`],r);let i=m(e,[`audioTimestamp`]);i!=null&&p(t,[`audioTimestamp`],i);let a=m(e,[`candidateCount`]);a!=null&&p(t,[`candidateCount`],a);let o=m(e,[`enableAffectiveDialog`]);o!=null&&p(t,[`enableAffectiveDialog`],o);let s=m(e,[`frequencyPenalty`]);s!=null&&p(t,[`frequencyPenalty`],s);let c=m(e,[`logprobs`]);c!=null&&p(t,[`logprobs`],c);let l=m(e,[`maxOutputTokens`]);l!=null&&p(t,[`maxOutputTokens`],l);let u=m(e,[`mediaResolution`]);u!=null&&p(t,[`mediaResolution`],u);let d=m(e,[`presencePenalty`]);d!=null&&p(t,[`presencePenalty`],d);let f=m(e,[`responseLogprobs`]);f!=null&&p(t,[`responseLogprobs`],f);let h=m(e,[`responseMimeType`]);h!=null&&p(t,[`responseMimeType`],h);let g=m(e,[`responseModalities`]);g!=null&&p(t,[`responseModalities`],g);let _=m(e,[`responseSchema`]);_!=null&&p(t,[`responseSchema`],_);let v=m(e,[`routingConfig`]);v!=null&&p(t,[`routingConfig`],v);let y=m(e,[`seed`]);y!=null&&p(t,[`seed`],y);let b=m(e,[`speechConfig`]);b!=null&&p(t,[`speechConfig`],b);let x=m(e,[`stopSequences`]);x!=null&&p(t,[`stopSequences`],x);let S=m(e,[`temperature`]);S!=null&&p(t,[`temperature`],S);let C=m(e,[`thinkingConfig`]);C!=null&&p(t,[`thinkingConfig`],C);let w=m(e,[`topK`]);w!=null&&p(t,[`topK`],w);let T=m(e,[`topP`]);if(T!=null&&p(t,[`topP`],T),m(e,[`enableEnhancedCivicAnswers`])!==void 0)throw Error(`enableEnhancedCivicAnswers parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);return t}function Ai(e){let t={},n=m(e,[`authConfig`]);n!=null&&p(t,[`authConfig`],Si(n));let r=m(e,[`enableWidget`]);return r!=null&&p(t,[`enableWidget`],r),t}function ji(e){let t={},n=m(e,[`searchTypes`]);if(n!=null&&p(t,[`searchTypes`],n),m(e,[`blockingConfidence`])!==void 0)throw Error(`blockingConfidence parameter is not supported in Gemini API.`);if(m(e,[`excludeDomains`])!==void 0)throw Error(`excludeDomains parameter is not supported in Gemini API.`);let r=m(e,[`timeRangeFilter`]);return r!=null&&p(t,[`timeRangeFilter`],r),t}function Mi(e,t){let n={},r=m(e,[`generationConfig`]);t!==void 0&&r!=null&&p(t,[`setup`,`generationConfig`],r);let i=m(e,[`responseModalities`]);t!==void 0&&i!=null&&p(t,[`setup`,`generationConfig`,`responseModalities`],i);let a=m(e,[`temperature`]);t!==void 0&&a!=null&&p(t,[`setup`,`generationConfig`,`temperature`],a);let o=m(e,[`topP`]);t!==void 0&&o!=null&&p(t,[`setup`,`generationConfig`,`topP`],o);let s=m(e,[`topK`]);t!==void 0&&s!=null&&p(t,[`setup`,`generationConfig`,`topK`],s);let c=m(e,[`maxOutputTokens`]);t!==void 0&&c!=null&&p(t,[`setup`,`generationConfig`,`maxOutputTokens`],c);let l=m(e,[`mediaResolution`]);t!==void 0&&l!=null&&p(t,[`setup`,`generationConfig`,`mediaResolution`],l);let u=m(e,[`seed`]);t!==void 0&&u!=null&&p(t,[`setup`,`generationConfig`,`seed`],u);let d=m(e,[`speechConfig`]);t!==void 0&&d!=null&&p(t,[`setup`,`generationConfig`,`speechConfig`],$t(d));let f=m(e,[`thinkingConfig`]);t!==void 0&&f!=null&&p(t,[`setup`,`generationConfig`,`thinkingConfig`],f);let h=m(e,[`enableAffectiveDialog`]);t!==void 0&&h!=null&&p(t,[`setup`,`generationConfig`,`enableAffectiveDialog`],h);let g=m(e,[`systemInstruction`]);t!==void 0&&g!=null&&p(t,[`setup`,`systemInstruction`],wi(L(g)));let _=m(e,[`tools`]);if(t!==void 0&&_!=null){let e=tn(_);Array.isArray(e)&&(e=e.map(e=>Gi(en(e)))),p(t,[`setup`,`tools`],e)}let v=m(e,[`sessionResumption`]);t!==void 0&&v!=null&&p(t,[`setup`,`sessionResumption`],Wi(v));let y=m(e,[`inputAudioTranscription`]);t!==void 0&&y!=null&&p(t,[`setup`,`inputAudioTranscription`],xi(y));let b=m(e,[`outputAudioTranscription`]);t!==void 0&&b!=null&&p(t,[`setup`,`outputAudioTranscription`],xi(b));let x=m(e,[`realtimeInputConfig`]);t!==void 0&&x!=null&&p(t,[`setup`,`realtimeInputConfig`],x);let S=m(e,[`contextWindowCompression`]);t!==void 0&&S!=null&&p(t,[`setup`,`contextWindowCompression`],S);let C=m(e,[`proactivity`]);if(t!==void 0&&C!=null&&p(t,[`setup`,`proactivity`],C),m(e,[`explicitVadSignal`])!==void 0)throw Error(`explicitVadSignal parameter is not supported in Gemini API.`);let w=m(e,[`avatarConfig`]);t!==void 0&&w!=null&&p(t,[`setup`,`avatarConfig`],w);let T=m(e,[`safetySettings`]);if(t!==void 0&&T!=null){let e=T;Array.isArray(e)&&(e=e.map(e=>Ui(e))),p(t,[`setup`,`safetySettings`],e)}return n}function Ni(e,t){let n={},r=m(e,[`generationConfig`]);t!==void 0&&r!=null&&p(t,[`setup`,`generationConfig`],ki(r));let i=m(e,[`responseModalities`]);t!==void 0&&i!=null&&p(t,[`setup`,`generationConfig`,`responseModalities`],i);let a=m(e,[`temperature`]);t!==void 0&&a!=null&&p(t,[`setup`,`generationConfig`,`temperature`],a);let o=m(e,[`topP`]);t!==void 0&&o!=null&&p(t,[`setup`,`generationConfig`,`topP`],o);let s=m(e,[`topK`]);t!==void 0&&s!=null&&p(t,[`setup`,`generationConfig`,`topK`],s);let c=m(e,[`maxOutputTokens`]);t!==void 0&&c!=null&&p(t,[`setup`,`generationConfig`,`maxOutputTokens`],c);let l=m(e,[`mediaResolution`]);t!==void 0&&l!=null&&p(t,[`setup`,`generationConfig`,`mediaResolution`],l);let u=m(e,[`seed`]);t!==void 0&&u!=null&&p(t,[`setup`,`generationConfig`,`seed`],u);let d=m(e,[`speechConfig`]);t!==void 0&&d!=null&&p(t,[`setup`,`generationConfig`,`speechConfig`],$t(d));let f=m(e,[`thinkingConfig`]);t!==void 0&&f!=null&&p(t,[`setup`,`generationConfig`,`thinkingConfig`],f);let h=m(e,[`enableAffectiveDialog`]);t!==void 0&&h!=null&&p(t,[`setup`,`generationConfig`,`enableAffectiveDialog`],h);let g=m(e,[`systemInstruction`]);t!==void 0&&g!=null&&p(t,[`setup`,`systemInstruction`],Ti(L(g)));let _=m(e,[`tools`]);if(t!==void 0&&_!=null){let e=tn(_);Array.isArray(e)&&(e=e.map(e=>Ki(en(e)))),p(t,[`setup`,`tools`],e)}let v=m(e,[`sessionResumption`]);t!==void 0&&v!=null&&p(t,[`setup`,`sessionResumption`],v);let y=m(e,[`inputAudioTranscription`]);t!==void 0&&y!=null&&p(t,[`setup`,`inputAudioTranscription`],y);let b=m(e,[`outputAudioTranscription`]);t!==void 0&&b!=null&&p(t,[`setup`,`outputAudioTranscription`],b);let x=m(e,[`realtimeInputConfig`]);t!==void 0&&x!=null&&p(t,[`setup`,`realtimeInputConfig`],x);let S=m(e,[`contextWindowCompression`]);t!==void 0&&S!=null&&p(t,[`setup`,`contextWindowCompression`],S);let C=m(e,[`proactivity`]);t!==void 0&&C!=null&&p(t,[`setup`,`proactivity`],C);let w=m(e,[`explicitVadSignal`]);t!==void 0&&w!=null&&p(t,[`setup`,`explicitVadSignal`],w);let T=m(e,[`avatarConfig`]);t!==void 0&&T!=null&&p(t,[`setup`,`avatarConfig`],T);let E=m(e,[`safetySettings`]);if(t!==void 0&&E!=null){let e=E;Array.isArray(e)&&(e=e.map(e=>e)),p(t,[`setup`,`safetySettings`],e)}return n}function Pi(e,t){let n={},r=m(t,[`model`]);r!=null&&p(n,[`setup`,`model`],I(e,r));let i=m(t,[`config`]);return i!=null&&p(n,[`config`],Mi(i,n)),n}function Fi(e,t){let n={},r=m(t,[`model`]);r!=null&&p(n,[`setup`,`model`],I(e,r));let i=m(t,[`config`]);return i!=null&&p(n,[`config`],Ni(i,n)),n}function Ii(e){let t={},n=m(e,[`musicGenerationConfig`]);return n!=null&&p(t,[`musicGenerationConfig`],n),t}function Li(e){let t={},n=m(e,[`weightedPrompts`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>e)),p(t,[`weightedPrompts`],e)}return t}function Ri(e){let t={},n=m(e,[`media`]);if(n!=null){let e=zt(n);Array.isArray(e)&&(e=e.map(e=>Ci(e))),p(t,[`mediaChunks`],e)}let r=m(e,[`audio`]);r!=null&&p(t,[`audio`],Ci(Ht(r)));let i=m(e,[`audioStreamEnd`]);i!=null&&p(t,[`audioStreamEnd`],i);let a=m(e,[`video`]);a!=null&&p(t,[`video`],Ci(Vt(a)));let o=m(e,[`text`]);o!=null&&p(t,[`text`],o);let s=m(e,[`activityStart`]);s!=null&&p(t,[`activityStart`],s);let c=m(e,[`activityEnd`]);return c!=null&&p(t,[`activityEnd`],c),t}function zi(e){let t={},n=m(e,[`media`]);if(n!=null){let e=zt(n);Array.isArray(e)&&(e=e.map(e=>e)),p(t,[`mediaChunks`],e)}let r=m(e,[`audio`]);r!=null&&p(t,[`audio`],Ht(r));let i=m(e,[`audioStreamEnd`]);i!=null&&p(t,[`audioStreamEnd`],i);let a=m(e,[`video`]);a!=null&&p(t,[`video`],Vt(a));let o=m(e,[`text`]);o!=null&&p(t,[`text`],o);let s=m(e,[`activityStart`]);s!=null&&p(t,[`activityStart`],s);let c=m(e,[`activityEnd`]);return c!=null&&p(t,[`activityEnd`],c),t}function Bi(e){let t={},n=m(e,[`setupComplete`]);n!=null&&p(t,[`setupComplete`],n);let r=m(e,[`serverContent`]);r!=null&&p(t,[`serverContent`],r);let i=m(e,[`toolCall`]);i!=null&&p(t,[`toolCall`],i);let a=m(e,[`toolCallCancellation`]);a!=null&&p(t,[`toolCallCancellation`],a);let o=m(e,[`usageMetadata`]);o!=null&&p(t,[`usageMetadata`],qi(o));let s=m(e,[`goAway`]);s!=null&&p(t,[`goAway`],s);let c=m(e,[`sessionResumptionUpdate`]);c!=null&&p(t,[`sessionResumptionUpdate`],c);let l=m(e,[`voiceActivityDetectionSignal`]);l!=null&&p(t,[`voiceActivityDetectionSignal`],l);let u=m(e,[`voiceActivity`]);return u!=null&&p(t,[`voiceActivity`],Ji(u)),t}function Vi(e){let t={},n=m(e,[`mediaResolution`]);n!=null&&p(t,[`mediaResolution`],n);let r=m(e,[`codeExecutionResult`]);r!=null&&p(t,[`codeExecutionResult`],r);let i=m(e,[`executableCode`]);i!=null&&p(t,[`executableCode`],i);let a=m(e,[`fileData`]);a!=null&&p(t,[`fileData`],Ei(a));let o=m(e,[`functionCall`]);o!=null&&p(t,[`functionCall`],Di(o));let s=m(e,[`functionResponse`]);s!=null&&p(t,[`functionResponse`],s);let c=m(e,[`inlineData`]);c!=null&&p(t,[`inlineData`],Ci(c));let l=m(e,[`text`]);l!=null&&p(t,[`text`],l);let u=m(e,[`thought`]);u!=null&&p(t,[`thought`],u);let d=m(e,[`thoughtSignature`]);d!=null&&p(t,[`thoughtSignature`],d);let f=m(e,[`videoMetadata`]);f!=null&&p(t,[`videoMetadata`],f);let h=m(e,[`toolCall`]);h!=null&&p(t,[`toolCall`],h);let g=m(e,[`toolResponse`]);g!=null&&p(t,[`toolResponse`],g);let _=m(e,[`partMetadata`]);return _!=null&&p(t,[`partMetadata`],_),t}function Hi(e){let t={},n=m(e,[`mediaResolution`]);n!=null&&p(t,[`mediaResolution`],n);let r=m(e,[`codeExecutionResult`]);r!=null&&p(t,[`codeExecutionResult`],r);let i=m(e,[`executableCode`]);i!=null&&p(t,[`executableCode`],i);let a=m(e,[`fileData`]);a!=null&&p(t,[`fileData`],a);let o=m(e,[`functionCall`]);o!=null&&p(t,[`functionCall`],o);let s=m(e,[`functionResponse`]);s!=null&&p(t,[`functionResponse`],s);let c=m(e,[`inlineData`]);c!=null&&p(t,[`inlineData`],c);let l=m(e,[`text`]);l!=null&&p(t,[`text`],l);let u=m(e,[`thought`]);u!=null&&p(t,[`thought`],u);let d=m(e,[`thoughtSignature`]);d!=null&&p(t,[`thoughtSignature`],d);let f=m(e,[`videoMetadata`]);if(f!=null&&p(t,[`videoMetadata`],f),m(e,[`toolCall`])!==void 0)throw Error(`toolCall parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);if(m(e,[`toolResponse`])!==void 0)throw Error(`toolResponse parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);if(m(e,[`partMetadata`])!==void 0)throw Error(`partMetadata parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);return t}function Ui(e){let t={},n=m(e,[`category`]);if(n!=null&&p(t,[`category`],n),m(e,[`method`])!==void 0)throw Error(`method parameter is not supported in Gemini API.`);let r=m(e,[`threshold`]);return r!=null&&p(t,[`threshold`],r),t}function Wi(e){let t={},n=m(e,[`handle`]);if(n!=null&&p(t,[`handle`],n),m(e,[`transparent`])!==void 0)throw Error(`transparent parameter is not supported in Gemini API.`);return t}function Gi(e){let t={};if(m(e,[`retrieval`])!==void 0)throw Error(`retrieval parameter is not supported in Gemini API.`);let n=m(e,[`computerUse`]);n!=null&&p(t,[`computerUse`],n);let r=m(e,[`fileSearch`]);r!=null&&p(t,[`fileSearch`],r);let i=m(e,[`googleSearch`]);i!=null&&p(t,[`googleSearch`],ji(i));let a=m(e,[`googleMaps`]);a!=null&&p(t,[`googleMaps`],Ai(a));let o=m(e,[`codeExecution`]);if(o!=null&&p(t,[`codeExecution`],o),m(e,[`enterpriseWebSearch`])!==void 0)throw Error(`enterpriseWebSearch parameter is not supported in Gemini API.`);let s=m(e,[`functionDeclarations`]);if(s!=null){let e=s;Array.isArray(e)&&(e=e.map(e=>e)),p(t,[`functionDeclarations`],e)}let c=m(e,[`googleSearchRetrieval`]);if(c!=null&&p(t,[`googleSearchRetrieval`],c),m(e,[`parallelAiSearch`])!==void 0)throw Error(`parallelAiSearch parameter is not supported in Gemini API.`);let l=m(e,[`urlContext`]);l!=null&&p(t,[`urlContext`],l);let u=m(e,[`mcpServers`]);if(u!=null){let e=u;Array.isArray(e)&&(e=e.map(e=>e)),p(t,[`mcpServers`],e)}return t}function Ki(e){let t={},n=m(e,[`retrieval`]);n!=null&&p(t,[`retrieval`],n);let r=m(e,[`computerUse`]);if(r!=null&&p(t,[`computerUse`],r),m(e,[`fileSearch`])!==void 0)throw Error(`fileSearch parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);let i=m(e,[`googleSearch`]);i!=null&&p(t,[`googleSearch`],i);let a=m(e,[`googleMaps`]);a!=null&&p(t,[`googleMaps`],a);let o=m(e,[`codeExecution`]);o!=null&&p(t,[`codeExecution`],o);let s=m(e,[`enterpriseWebSearch`]);s!=null&&p(t,[`enterpriseWebSearch`],s);let c=m(e,[`functionDeclarations`]);if(c!=null){let e=c;Array.isArray(e)&&(e=e.map(e=>Oi(e))),p(t,[`functionDeclarations`],e)}let l=m(e,[`googleSearchRetrieval`]);l!=null&&p(t,[`googleSearchRetrieval`],l);let u=m(e,[`parallelAiSearch`]);u!=null&&p(t,[`parallelAiSearch`],u);let d=m(e,[`urlContext`]);if(d!=null&&p(t,[`urlContext`],d),m(e,[`mcpServers`])!==void 0)throw Error(`mcpServers parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);return t}function qi(e){let t={},n=m(e,[`promptTokenCount`]);n!=null&&p(t,[`promptTokenCount`],n);let r=m(e,[`cachedContentTokenCount`]);r!=null&&p(t,[`cachedContentTokenCount`],r);let i=m(e,[`candidatesTokenCount`]);i!=null&&p(t,[`responseTokenCount`],i);let a=m(e,[`toolUsePromptTokenCount`]);a!=null&&p(t,[`toolUsePromptTokenCount`],a);let o=m(e,[`thoughtsTokenCount`]);o!=null&&p(t,[`thoughtsTokenCount`],o);let s=m(e,[`totalTokenCount`]);s!=null&&p(t,[`totalTokenCount`],s);let c=m(e,[`promptTokensDetails`]);if(c!=null){let e=c;Array.isArray(e)&&(e=e.map(e=>e)),p(t,[`promptTokensDetails`],e)}let l=m(e,[`cacheTokensDetails`]);if(l!=null){let e=l;Array.isArray(e)&&(e=e.map(e=>e)),p(t,[`cacheTokensDetails`],e)}let u=m(e,[`candidatesTokensDetails`]);if(u!=null){let e=u;Array.isArray(e)&&(e=e.map(e=>e)),p(t,[`responseTokensDetails`],e)}let d=m(e,[`toolUsePromptTokensDetails`]);if(d!=null){let e=d;Array.isArray(e)&&(e=e.map(e=>e)),p(t,[`toolUsePromptTokensDetails`],e)}let f=m(e,[`trafficType`]);return f!=null&&p(t,[`trafficType`],f),t}function Ji(e){let t={},n=m(e,[`type`]);return n!=null&&p(t,[`voiceActivityType`],n),t}
|
|
98
|
+
/**
|
|
99
|
+
* @license
|
|
100
|
+
* Copyright 2025 Google LLC
|
|
101
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
102
|
+
*/
|
|
103
|
+
function Yi(e,t){let n={},r=m(e,[`apiKey`]);if(r!=null&&p(n,[`apiKey`],r),m(e,[`apiKeyConfig`])!==void 0)throw Error(`apiKeyConfig parameter is not supported in Gemini API.`);if(m(e,[`authType`])!==void 0)throw Error(`authType parameter is not supported in Gemini API.`);if(m(e,[`googleServiceAccountConfig`])!==void 0)throw Error(`googleServiceAccountConfig parameter is not supported in Gemini API.`);if(m(e,[`httpBasicAuthConfig`])!==void 0)throw Error(`httpBasicAuthConfig parameter is not supported in Gemini API.`);if(m(e,[`oauthConfig`])!==void 0)throw Error(`oauthConfig parameter is not supported in Gemini API.`);if(m(e,[`oidcConfig`])!==void 0)throw Error(`oidcConfig parameter is not supported in Gemini API.`);return n}function Xi(e,t){let n={},r=m(e,[`data`]);if(r!=null&&p(n,[`data`],r),m(e,[`displayName`])!==void 0)throw Error(`displayName parameter is not supported in Gemini API.`);let i=m(e,[`mimeType`]);return i!=null&&p(n,[`mimeType`],i),n}function Zi(e,t){let n={},r=m(e,[`content`]);r!=null&&p(n,[`content`],r);let i=m(e,[`citationMetadata`]);i!=null&&p(n,[`citationMetadata`],Qi(i));let a=m(e,[`tokenCount`]);a!=null&&p(n,[`tokenCount`],a);let o=m(e,[`finishReason`]);o!=null&&p(n,[`finishReason`],o);let s=m(e,[`groundingMetadata`]);s!=null&&p(n,[`groundingMetadata`],s);let c=m(e,[`avgLogprobs`]);c!=null&&p(n,[`avgLogprobs`],c);let l=m(e,[`index`]);l!=null&&p(n,[`index`],l);let u=m(e,[`logprobsResult`]);u!=null&&p(n,[`logprobsResult`],u);let d=m(e,[`safetyRatings`]);if(d!=null){let e=d;Array.isArray(e)&&(e=e.map(e=>e)),p(n,[`safetyRatings`],e)}let f=m(e,[`urlContextMetadata`]);return f!=null&&p(n,[`urlContextMetadata`],f),n}function Qi(e,t){let n={},r=m(e,[`citationSources`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),p(n,[`citations`],e)}return n}function $i(e,t,n){let r={},i=m(t,[`model`]);i!=null&&p(r,[`_url`,`model`],I(e,i));let a=m(t,[`contents`]);if(a!=null){let e=R(a);Array.isArray(e)&&(e=e.map(e=>ia(e))),p(r,[`contents`],e)}return r}function ea(e,t){let n={},r=m(e,[`sdkHttpResponse`]);r!=null&&p(n,[`sdkHttpResponse`],r);let i=m(e,[`tokensInfo`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),p(n,[`tokensInfo`],e)}return n}function ta(e,t){let n={},r=m(e,[`values`]);r!=null&&p(n,[`values`],r);let i=m(e,[`statistics`]);return i!=null&&p(n,[`statistics`],na(i)),n}function na(e,t){let n={},r=m(e,[`truncated`]);r!=null&&p(n,[`truncated`],r);let i=m(e,[`token_count`]);return i!=null&&p(n,[`tokenCount`],i),n}function ra(e,t){let n={},r=m(e,[`parts`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>Co(e))),p(n,[`parts`],e)}let i=m(e,[`role`]);return i!=null&&p(n,[`role`],i),n}function ia(e,t){let n={},r=m(e,[`parts`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>wo(e))),p(n,[`parts`],e)}let i=m(e,[`role`]);return i!=null&&p(n,[`role`],i),n}function aa(e,t){let n={},r=m(e,[`controlType`]);r!=null&&p(n,[`controlType`],r);let i=m(e,[`enableControlImageComputation`]);return i!=null&&p(n,[`computeControl`],i),n}function oa(e,t){let n={};if(m(e,[`systemInstruction`])!==void 0)throw Error(`systemInstruction parameter is not supported in Gemini API.`);if(m(e,[`tools`])!==void 0)throw Error(`tools parameter is not supported in Gemini API.`);if(m(e,[`generationConfig`])!==void 0)throw Error(`generationConfig parameter is not supported in Gemini API.`);return n}function sa(e,t,n){let r={},i=m(e,[`systemInstruction`]);t!==void 0&&i!=null&&p(t,[`systemInstruction`],ia(L(i)));let a=m(e,[`tools`]);if(t!==void 0&&a!=null){let e=a;Array.isArray(e)&&(e=e.map(e=>Ho(e))),p(t,[`tools`],e)}let o=m(e,[`generationConfig`]);return t!==void 0&&o!=null&&p(t,[`generationConfig`],ro(o)),r}function ca(e,t,n){let r={},i=m(t,[`model`]);i!=null&&p(r,[`_url`,`model`],I(e,i));let a=m(t,[`contents`]);if(a!=null){let e=R(a);Array.isArray(e)&&(e=e.map(e=>ra(e))),p(r,[`contents`],e)}let o=m(t,[`config`]);return o!=null&&oa(o),r}function la(e,t,n){let r={},i=m(t,[`model`]);i!=null&&p(r,[`_url`,`model`],I(e,i));let a=m(t,[`contents`]);if(a!=null){let e=R(a);Array.isArray(e)&&(e=e.map(e=>ia(e))),p(r,[`contents`],e)}let o=m(t,[`config`]);return o!=null&&sa(o,r),r}function ua(e,t){let n={},r=m(e,[`sdkHttpResponse`]);r!=null&&p(n,[`sdkHttpResponse`],r);let i=m(e,[`totalTokens`]);i!=null&&p(n,[`totalTokens`],i);let a=m(e,[`cachedContentTokenCount`]);return a!=null&&p(n,[`cachedContentTokenCount`],a),n}function da(e,t){let n={},r=m(e,[`sdkHttpResponse`]);r!=null&&p(n,[`sdkHttpResponse`],r);let i=m(e,[`totalTokens`]);return i!=null&&p(n,[`totalTokens`],i),n}function fa(e,t,n){let r={},i=m(t,[`model`]);return i!=null&&p(r,[`_url`,`name`],I(e,i)),r}function pa(e,t,n){let r={},i=m(t,[`model`]);return i!=null&&p(r,[`_url`,`name`],I(e,i)),r}function ma(e,t){let n={},r=m(e,[`sdkHttpResponse`]);return r!=null&&p(n,[`sdkHttpResponse`],r),n}function ha(e,t){let n={},r=m(e,[`sdkHttpResponse`]);return r!=null&&p(n,[`sdkHttpResponse`],r),n}function ga(e,t,n){let r={},i=m(e,[`outputGcsUri`]);t!==void 0&&i!=null&&p(t,[`parameters`,`storageUri`],i);let a=m(e,[`negativePrompt`]);t!==void 0&&a!=null&&p(t,[`parameters`,`negativePrompt`],a);let o=m(e,[`numberOfImages`]);t!==void 0&&o!=null&&p(t,[`parameters`,`sampleCount`],o);let s=m(e,[`aspectRatio`]);t!==void 0&&s!=null&&p(t,[`parameters`,`aspectRatio`],s);let c=m(e,[`guidanceScale`]);t!==void 0&&c!=null&&p(t,[`parameters`,`guidanceScale`],c);let l=m(e,[`seed`]);t!==void 0&&l!=null&&p(t,[`parameters`,`seed`],l);let u=m(e,[`safetyFilterLevel`]);t!==void 0&&u!=null&&p(t,[`parameters`,`safetySetting`],u);let d=m(e,[`personGeneration`]);t!==void 0&&d!=null&&p(t,[`parameters`,`personGeneration`],d);let f=m(e,[`includeSafetyAttributes`]);t!==void 0&&f!=null&&p(t,[`parameters`,`includeSafetyAttributes`],f);let h=m(e,[`includeRaiReason`]);t!==void 0&&h!=null&&p(t,[`parameters`,`includeRaiReason`],h);let g=m(e,[`language`]);t!==void 0&&g!=null&&p(t,[`parameters`,`language`],g);let _=m(e,[`outputMimeType`]);t!==void 0&&_!=null&&p(t,[`parameters`,`outputOptions`,`mimeType`],_);let v=m(e,[`outputCompressionQuality`]);t!==void 0&&v!=null&&p(t,[`parameters`,`outputOptions`,`compressionQuality`],v);let y=m(e,[`addWatermark`]);t!==void 0&&y!=null&&p(t,[`parameters`,`addWatermark`],y);let b=m(e,[`labels`]);t!==void 0&&b!=null&&p(t,[`labels`],b);let x=m(e,[`editMode`]);t!==void 0&&x!=null&&p(t,[`parameters`,`editMode`],x);let S=m(e,[`baseSteps`]);return t!==void 0&&S!=null&&p(t,[`parameters`,`editConfig`,`baseSteps`],S),r}function _a(e,t,n){let r={},i=m(t,[`model`]);i!=null&&p(r,[`_url`,`model`],I(e,i));let a=m(t,[`prompt`]);a!=null&&p(r,[`instances[0]`,`prompt`],a);let o=m(t,[`referenceImages`]);if(o!=null){let e=o;Array.isArray(e)&&(e=e.map(e=>Ao(e))),p(r,[`instances[0]`,`referenceImages`],e)}let s=m(t,[`config`]);return s!=null&&ga(s,r),r}function va(e,t){let n={},r=m(e,[`sdkHttpResponse`]);r!=null&&p(n,[`sdkHttpResponse`],r);let i=m(e,[`predictions`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>$a(e))),p(n,[`generatedImages`],e)}return n}function ya(e,t,n){let r={},i=m(e,[`taskType`]);t!==void 0&&i!=null&&p(t,[`requests[]`,`taskType`],i);let a=m(e,[`title`]);t!==void 0&&a!=null&&p(t,[`requests[]`,`title`],a);let o=m(e,[`outputDimensionality`]);if(t!==void 0&&o!=null&&p(t,[`requests[]`,`outputDimensionality`],o),m(e,[`mimeType`])!==void 0)throw Error(`mimeType parameter is not supported in Gemini API.`);if(m(e,[`autoTruncate`])!==void 0)throw Error(`autoTruncate parameter is not supported in Gemini API.`);if(m(e,[`documentOcr`])!==void 0)throw Error(`documentOcr parameter is not supported in Gemini API.`);if(m(e,[`audioTrackExtraction`])!==void 0)throw Error(`audioTrackExtraction parameter is not supported in Gemini API.`);return r}function ba(e,t,n){let r={},i=m(n,[`embeddingApiType`]);if(i===void 0&&(i=`PREDICT`),i===`PREDICT`){let n=m(e,[`taskType`]);t!==void 0&&n!=null&&p(t,[`instances[]`,`task_type`],n)}else if(i===`EMBED_CONTENT`){let n=m(e,[`taskType`]);t!==void 0&&n!=null&&p(t,[`embedContentConfig`,`taskType`],n)}let a=m(n,[`embeddingApiType`]);if(a===void 0&&(a=`PREDICT`),a===`PREDICT`){let n=m(e,[`title`]);t!==void 0&&n!=null&&p(t,[`instances[]`,`title`],n)}else if(a===`EMBED_CONTENT`){let n=m(e,[`title`]);t!==void 0&&n!=null&&p(t,[`embedContentConfig`,`title`],n)}let o=m(n,[`embeddingApiType`]);if(o===void 0&&(o=`PREDICT`),o===`PREDICT`){let n=m(e,[`outputDimensionality`]);t!==void 0&&n!=null&&p(t,[`parameters`,`outputDimensionality`],n)}else if(o===`EMBED_CONTENT`){let n=m(e,[`outputDimensionality`]);t!==void 0&&n!=null&&p(t,[`embedContentConfig`,`outputDimensionality`],n)}let s=m(n,[`embeddingApiType`]);if(s===void 0&&(s=`PREDICT`),s===`PREDICT`){let n=m(e,[`mimeType`]);t!==void 0&&n!=null&&p(t,[`instances[]`,`mimeType`],n)}let c=m(n,[`embeddingApiType`]);if(c===void 0&&(c=`PREDICT`),c===`PREDICT`){let n=m(e,[`autoTruncate`]);t!==void 0&&n!=null&&p(t,[`parameters`,`autoTruncate`],n)}else if(c===`EMBED_CONTENT`){let n=m(e,[`autoTruncate`]);t!==void 0&&n!=null&&p(t,[`embedContentConfig`,`autoTruncate`],n)}let l=m(n,[`embeddingApiType`]);if(l===void 0&&(l=`PREDICT`),l===`EMBED_CONTENT`){let n=m(e,[`documentOcr`]);t!==void 0&&n!=null&&p(t,[`embedContentConfig`,`documentOcr`],n)}let u=m(n,[`embeddingApiType`]);if(u===void 0&&(u=`PREDICT`),u===`EMBED_CONTENT`){let n=m(e,[`audioTrackExtraction`]);t!==void 0&&n!=null&&p(t,[`embedContentConfig`,`audioTrackExtraction`],n)}return r}function xa(e,t,n){let r={},i=m(t,[`model`]);i!=null&&p(r,[`_url`,`model`],I(e,i));let a=m(t,[`contents`]);if(a!=null){let t=Jt(e,a);Array.isArray(t)&&(t=t.map(e=>e)),p(r,[`requests[]`,`content`],t)}let o=m(t,[`content`]);o!=null&&ra(L(o));let s=m(t,[`config`]);s!=null&&ya(s,r);let c=m(t,[`model`]);return c!==void 0&&p(r,[`requests[]`,`model`],I(e,c)),r}function Sa(e,t,n){let r={},i=m(t,[`model`]);i!=null&&p(r,[`_url`,`model`],I(e,i));let a=m(n,[`embeddingApiType`]);if(a===void 0&&(a=`PREDICT`),a===`PREDICT`){let n=m(t,[`contents`]);if(n!=null){let t=Jt(e,n);Array.isArray(t)&&(t=t.map(e=>e)),p(r,[`instances[]`,`content`],t)}}let o=m(n,[`embeddingApiType`]);if(o===void 0&&(o=`PREDICT`),o===`EMBED_CONTENT`){let e=m(t,[`content`]);e!=null&&p(r,[`content`],ia(L(e)))}let s=m(t,[`config`]);return s!=null&&ba(s,r,n),r}function Ca(e,t){let n={},r=m(e,[`sdkHttpResponse`]);r!=null&&p(n,[`sdkHttpResponse`],r);let i=m(e,[`embeddings`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),p(n,[`embeddings`],e)}let a=m(e,[`metadata`]);return a!=null&&p(n,[`metadata`],a),n}function wa(e,t){let n={},r=m(e,[`sdkHttpResponse`]);r!=null&&p(n,[`sdkHttpResponse`],r);let i=m(e,[`predictions[]`,`embeddings`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>ta(e))),p(n,[`embeddings`],e)}let a=m(e,[`metadata`]);if(a!=null&&p(n,[`metadata`],a),t&&m(t,[`embeddingApiType`])===`EMBED_CONTENT`){let t=m(e,[`embedding`]),r=m(e,[`usageMetadata`]),i=m(e,[`truncated`]);if(t){let e={};r&&r.promptTokenCount&&(e.tokenCount=r.promptTokenCount),i&&(e.truncated=i),t.statistics=e,p(n,[`embeddings`],[t])}}return n}function Ta(e,t){let n={},r=m(e,[`endpoint`]);r!=null&&p(n,[`name`],r);let i=m(e,[`deployedModelId`]);return i!=null&&p(n,[`deployedModelId`],i),n}function Ea(e,t){let n={};if(m(e,[`displayName`])!==void 0)throw Error(`displayName parameter is not supported in Gemini API.`);let r=m(e,[`fileUri`]);r!=null&&p(n,[`fileUri`],r);let i=m(e,[`mimeType`]);return i!=null&&p(n,[`mimeType`],i),n}function Da(e,t){let n={},r=m(e,[`id`]);r!=null&&p(n,[`id`],r);let i=m(e,[`args`]);i!=null&&p(n,[`args`],i);let a=m(e,[`name`]);if(a!=null&&p(n,[`name`],a),m(e,[`partialArgs`])!==void 0)throw Error(`partialArgs parameter is not supported in Gemini API.`);if(m(e,[`willContinue`])!==void 0)throw Error(`willContinue parameter is not supported in Gemini API.`);return n}function Oa(e,t){let n={},r=m(e,[`allowedFunctionNames`]);r!=null&&p(n,[`allowedFunctionNames`],r);let i=m(e,[`mode`]);if(i!=null&&p(n,[`mode`],i),m(e,[`streamFunctionCallArguments`])!==void 0)throw Error(`streamFunctionCallArguments parameter is not supported in Gemini API.`);return n}function ka(e,t){let n={},r=m(e,[`description`]);r!=null&&p(n,[`description`],r);let i=m(e,[`name`]);i!=null&&p(n,[`name`],i);let a=m(e,[`parameters`]);a!=null&&p(n,[`parameters`],a);let o=m(e,[`parametersJsonSchema`]);o!=null&&p(n,[`parametersJsonSchema`],o);let s=m(e,[`response`]);s!=null&&p(n,[`response`],s);let c=m(e,[`responseJsonSchema`]);if(c!=null&&p(n,[`responseJsonSchema`],c),m(e,[`behavior`])!==void 0)throw Error(`behavior parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);return n}function Aa(e,t,n,r){let i={},a=m(t,[`systemInstruction`]);n!==void 0&&a!=null&&p(n,[`systemInstruction`],ra(L(a)));let o=m(t,[`temperature`]);o!=null&&p(i,[`temperature`],o);let s=m(t,[`topP`]);s!=null&&p(i,[`topP`],s);let c=m(t,[`topK`]);c!=null&&p(i,[`topK`],c);let l=m(t,[`candidateCount`]);l!=null&&p(i,[`candidateCount`],l);let u=m(t,[`maxOutputTokens`]);u!=null&&p(i,[`maxOutputTokens`],u);let d=m(t,[`stopSequences`]);d!=null&&p(i,[`stopSequences`],d);let f=m(t,[`responseLogprobs`]);f!=null&&p(i,[`responseLogprobs`],f);let h=m(t,[`logprobs`]);h!=null&&p(i,[`logprobs`],h);let g=m(t,[`presencePenalty`]);g!=null&&p(i,[`presencePenalty`],g);let _=m(t,[`frequencyPenalty`]);_!=null&&p(i,[`frequencyPenalty`],_);let v=m(t,[`seed`]);v!=null&&p(i,[`seed`],v);let y=m(t,[`responseMimeType`]);y!=null&&p(i,[`responseMimeType`],y);let b=m(t,[`responseSchema`]);b!=null&&p(i,[`responseSchema`],Zt(b));let x=m(t,[`responseJsonSchema`]);if(x!=null&&p(i,[`responseJsonSchema`],x),m(t,[`routingConfig`])!==void 0)throw Error(`routingConfig parameter is not supported in Gemini API.`);if(m(t,[`modelSelectionConfig`])!==void 0)throw Error(`modelSelectionConfig parameter is not supported in Gemini API.`);let S=m(t,[`safetySettings`]);if(n!==void 0&&S!=null){let e=S;Array.isArray(e)&&(e=e.map(e=>No(e))),p(n,[`safetySettings`],e)}let C=m(t,[`tools`]);if(n!==void 0&&C!=null){let e=tn(C);Array.isArray(e)&&(e=e.map(e=>Vo(en(e)))),p(n,[`tools`],e)}let w=m(t,[`toolConfig`]);if(n!==void 0&&w!=null&&p(n,[`toolConfig`],zo(w)),m(t,[`labels`])!==void 0)throw Error(`labels parameter is not supported in Gemini API.`);let T=m(t,[`cachedContent`]);n!==void 0&&T!=null&&p(n,[`cachedContent`],z(e,T));let E=m(t,[`responseModalities`]);E!=null&&p(i,[`responseModalities`],E);let D=m(t,[`mediaResolution`]);D!=null&&p(i,[`mediaResolution`],D);let O=m(t,[`speechConfig`]);if(O!=null&&p(i,[`speechConfig`],Qt(O)),m(t,[`audioTimestamp`])!==void 0)throw Error(`audioTimestamp parameter is not supported in Gemini API.`);let k=m(t,[`thinkingConfig`]);k!=null&&p(i,[`thinkingConfig`],k);let A=m(t,[`imageConfig`]);A!=null&&p(i,[`imageConfig`],co(A));let j=m(t,[`enableEnhancedCivicAnswers`]);if(j!=null&&p(i,[`enableEnhancedCivicAnswers`],j),m(t,[`modelArmorConfig`])!==void 0)throw Error(`modelArmorConfig parameter is not supported in Gemini API.`);let M=m(t,[`serviceTier`]);return n!==void 0&&M!=null&&p(n,[`serviceTier`],M),i}function ja(e,t,n,r){let i={},a=m(t,[`systemInstruction`]);n!==void 0&&a!=null&&p(n,[`systemInstruction`],ia(L(a)));let o=m(t,[`temperature`]);o!=null&&p(i,[`temperature`],o);let s=m(t,[`topP`]);s!=null&&p(i,[`topP`],s);let c=m(t,[`topK`]);c!=null&&p(i,[`topK`],c);let l=m(t,[`candidateCount`]);l!=null&&p(i,[`candidateCount`],l);let u=m(t,[`maxOutputTokens`]);u!=null&&p(i,[`maxOutputTokens`],u);let d=m(t,[`stopSequences`]);d!=null&&p(i,[`stopSequences`],d);let f=m(t,[`responseLogprobs`]);f!=null&&p(i,[`responseLogprobs`],f);let h=m(t,[`logprobs`]);h!=null&&p(i,[`logprobs`],h);let g=m(t,[`presencePenalty`]);g!=null&&p(i,[`presencePenalty`],g);let _=m(t,[`frequencyPenalty`]);_!=null&&p(i,[`frequencyPenalty`],_);let v=m(t,[`seed`]);v!=null&&p(i,[`seed`],v);let y=m(t,[`responseMimeType`]);y!=null&&p(i,[`responseMimeType`],y);let b=m(t,[`responseSchema`]);b!=null&&p(i,[`responseSchema`],Zt(b));let x=m(t,[`responseJsonSchema`]);x!=null&&p(i,[`responseJsonSchema`],x);let S=m(t,[`routingConfig`]);S!=null&&p(i,[`routingConfig`],S);let C=m(t,[`modelSelectionConfig`]);C!=null&&p(i,[`modelConfig`],C);let w=m(t,[`safetySettings`]);if(n!==void 0&&w!=null){let e=w;Array.isArray(e)&&(e=e.map(e=>e)),p(n,[`safetySettings`],e)}let T=m(t,[`tools`]);if(n!==void 0&&T!=null){let e=tn(T);Array.isArray(e)&&(e=e.map(e=>Ho(en(e)))),p(n,[`tools`],e)}let E=m(t,[`toolConfig`]);n!==void 0&&E!=null&&p(n,[`toolConfig`],Bo(E));let D=m(t,[`labels`]);n!==void 0&&D!=null&&p(n,[`labels`],D);let O=m(t,[`cachedContent`]);n!==void 0&&O!=null&&p(n,[`cachedContent`],z(e,O));let k=m(t,[`responseModalities`]);k!=null&&p(i,[`responseModalities`],k);let A=m(t,[`mediaResolution`]);A!=null&&p(i,[`mediaResolution`],A);let j=m(t,[`speechConfig`]);j!=null&&p(i,[`speechConfig`],Qt(j));let M=m(t,[`audioTimestamp`]);M!=null&&p(i,[`audioTimestamp`],M);let ee=m(t,[`thinkingConfig`]);ee!=null&&p(i,[`thinkingConfig`],ee);let te=m(t,[`imageConfig`]);if(te!=null&&p(i,[`imageConfig`],lo(te)),m(t,[`enableEnhancedCivicAnswers`])!==void 0)throw Error(`enableEnhancedCivicAnswers parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);let ne=m(t,[`modelArmorConfig`]);n!==void 0&&ne!=null&&p(n,[`modelArmorConfig`],ne);let N=m(t,[`serviceTier`]);return n!==void 0&&N!=null&&p(n,[`serviceTier`],N),i}function Ma(e,t,n){let r={},i=m(t,[`model`]);i!=null&&p(r,[`_url`,`model`],I(e,i));let a=m(t,[`contents`]);if(a!=null){let e=R(a);Array.isArray(e)&&(e=e.map(e=>ra(e))),p(r,[`contents`],e)}let o=m(t,[`config`]);return o!=null&&p(r,[`generationConfig`],Aa(e,o,r)),r}function Na(e,t,n){let r={},i=m(t,[`model`]);i!=null&&p(r,[`_url`,`model`],I(e,i));let a=m(t,[`contents`]);if(a!=null){let e=R(a);Array.isArray(e)&&(e=e.map(e=>ia(e))),p(r,[`contents`],e)}let o=m(t,[`config`]);return o!=null&&p(r,[`generationConfig`],ja(e,o,r)),r}function Pa(e,t){let n={},r=m(e,[`sdkHttpResponse`]);r!=null&&p(n,[`sdkHttpResponse`],r);let i=m(e,[`candidates`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>Zi(e))),p(n,[`candidates`],e)}let a=m(e,[`modelVersion`]);a!=null&&p(n,[`modelVersion`],a);let o=m(e,[`promptFeedback`]);o!=null&&p(n,[`promptFeedback`],o);let s=m(e,[`responseId`]);s!=null&&p(n,[`responseId`],s);let c=m(e,[`usageMetadata`]);c!=null&&p(n,[`usageMetadata`],c);let l=m(e,[`modelStatus`]);return l!=null&&p(n,[`modelStatus`],l),n}function Fa(e,t){let n={},r=m(e,[`sdkHttpResponse`]);r!=null&&p(n,[`sdkHttpResponse`],r);let i=m(e,[`candidates`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),p(n,[`candidates`],e)}let a=m(e,[`createTime`]);a!=null&&p(n,[`createTime`],a);let o=m(e,[`modelVersion`]);o!=null&&p(n,[`modelVersion`],o);let s=m(e,[`promptFeedback`]);s!=null&&p(n,[`promptFeedback`],s);let c=m(e,[`responseId`]);c!=null&&p(n,[`responseId`],c);let l=m(e,[`usageMetadata`]);return l!=null&&p(n,[`usageMetadata`],l),n}function Ia(e,t,n){let r={};if(m(e,[`outputGcsUri`])!==void 0)throw Error(`outputGcsUri parameter is not supported in Gemini API.`);if(m(e,[`negativePrompt`])!==void 0)throw Error(`negativePrompt parameter is not supported in Gemini API.`);let i=m(e,[`numberOfImages`]);t!==void 0&&i!=null&&p(t,[`parameters`,`sampleCount`],i);let a=m(e,[`aspectRatio`]);t!==void 0&&a!=null&&p(t,[`parameters`,`aspectRatio`],a);let o=m(e,[`guidanceScale`]);if(t!==void 0&&o!=null&&p(t,[`parameters`,`guidanceScale`],o),m(e,[`seed`])!==void 0)throw Error(`seed parameter is not supported in Gemini API.`);let s=m(e,[`safetyFilterLevel`]);t!==void 0&&s!=null&&p(t,[`parameters`,`safetySetting`],s);let c=m(e,[`personGeneration`]);t!==void 0&&c!=null&&p(t,[`parameters`,`personGeneration`],c);let l=m(e,[`includeSafetyAttributes`]);t!==void 0&&l!=null&&p(t,[`parameters`,`includeSafetyAttributes`],l);let u=m(e,[`includeRaiReason`]);t!==void 0&&u!=null&&p(t,[`parameters`,`includeRaiReason`],u);let d=m(e,[`language`]);t!==void 0&&d!=null&&p(t,[`parameters`,`language`],d);let f=m(e,[`outputMimeType`]);t!==void 0&&f!=null&&p(t,[`parameters`,`outputOptions`,`mimeType`],f);let h=m(e,[`outputCompressionQuality`]);if(t!==void 0&&h!=null&&p(t,[`parameters`,`outputOptions`,`compressionQuality`],h),m(e,[`addWatermark`])!==void 0)throw Error(`addWatermark parameter is not supported in Gemini API.`);if(m(e,[`labels`])!==void 0)throw Error(`labels parameter is not supported in Gemini API.`);let g=m(e,[`imageSize`]);if(t!==void 0&&g!=null&&p(t,[`parameters`,`sampleImageSize`],g),m(e,[`enhancePrompt`])!==void 0)throw Error(`enhancePrompt parameter is not supported in Gemini API.`);return r}function La(e,t,n){let r={},i=m(e,[`outputGcsUri`]);t!==void 0&&i!=null&&p(t,[`parameters`,`storageUri`],i);let a=m(e,[`negativePrompt`]);t!==void 0&&a!=null&&p(t,[`parameters`,`negativePrompt`],a);let o=m(e,[`numberOfImages`]);t!==void 0&&o!=null&&p(t,[`parameters`,`sampleCount`],o);let s=m(e,[`aspectRatio`]);t!==void 0&&s!=null&&p(t,[`parameters`,`aspectRatio`],s);let c=m(e,[`guidanceScale`]);t!==void 0&&c!=null&&p(t,[`parameters`,`guidanceScale`],c);let l=m(e,[`seed`]);t!==void 0&&l!=null&&p(t,[`parameters`,`seed`],l);let u=m(e,[`safetyFilterLevel`]);t!==void 0&&u!=null&&p(t,[`parameters`,`safetySetting`],u);let d=m(e,[`personGeneration`]);t!==void 0&&d!=null&&p(t,[`parameters`,`personGeneration`],d);let f=m(e,[`includeSafetyAttributes`]);t!==void 0&&f!=null&&p(t,[`parameters`,`includeSafetyAttributes`],f);let h=m(e,[`includeRaiReason`]);t!==void 0&&h!=null&&p(t,[`parameters`,`includeRaiReason`],h);let g=m(e,[`language`]);t!==void 0&&g!=null&&p(t,[`parameters`,`language`],g);let _=m(e,[`outputMimeType`]);t!==void 0&&_!=null&&p(t,[`parameters`,`outputOptions`,`mimeType`],_);let v=m(e,[`outputCompressionQuality`]);t!==void 0&&v!=null&&p(t,[`parameters`,`outputOptions`,`compressionQuality`],v);let y=m(e,[`addWatermark`]);t!==void 0&&y!=null&&p(t,[`parameters`,`addWatermark`],y);let b=m(e,[`labels`]);t!==void 0&&b!=null&&p(t,[`labels`],b);let x=m(e,[`imageSize`]);t!==void 0&&x!=null&&p(t,[`parameters`,`sampleImageSize`],x);let S=m(e,[`enhancePrompt`]);return t!==void 0&&S!=null&&p(t,[`parameters`,`enhancePrompt`],S),r}function Ra(e,t,n){let r={},i=m(t,[`model`]);i!=null&&p(r,[`_url`,`model`],I(e,i));let a=m(t,[`prompt`]);a!=null&&p(r,[`instances[0]`,`prompt`],a);let o=m(t,[`config`]);return o!=null&&Ia(o,r),r}function za(e,t,n){let r={},i=m(t,[`model`]);i!=null&&p(r,[`_url`,`model`],I(e,i));let a=m(t,[`prompt`]);a!=null&&p(r,[`instances[0]`,`prompt`],a);let o=m(t,[`config`]);return o!=null&&La(o,r),r}function Ba(e,t){let n={},r=m(e,[`sdkHttpResponse`]);r!=null&&p(n,[`sdkHttpResponse`],r);let i=m(e,[`predictions`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>Qa(e))),p(n,[`generatedImages`],e)}let a=m(e,[`positivePromptSafetyAttributes`]);return a!=null&&p(n,[`positivePromptSafetyAttributes`],jo(a)),n}function Va(e,t){let n={},r=m(e,[`sdkHttpResponse`]);r!=null&&p(n,[`sdkHttpResponse`],r);let i=m(e,[`predictions`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>$a(e))),p(n,[`generatedImages`],e)}let a=m(e,[`positivePromptSafetyAttributes`]);return a!=null&&p(n,[`positivePromptSafetyAttributes`],Mo(a)),n}function Ha(e,t,n){let r={},i=m(e,[`numberOfVideos`]);if(t!==void 0&&i!=null&&p(t,[`parameters`,`sampleCount`],i),m(e,[`outputGcsUri`])!==void 0)throw Error(`outputGcsUri parameter is not supported in Gemini API.`);if(m(e,[`fps`])!==void 0)throw Error(`fps parameter is not supported in Gemini API.`);let a=m(e,[`durationSeconds`]);if(t!==void 0&&a!=null&&p(t,[`parameters`,`durationSeconds`],a),m(e,[`seed`])!==void 0)throw Error(`seed parameter is not supported in Gemini API.`);let o=m(e,[`aspectRatio`]);t!==void 0&&o!=null&&p(t,[`parameters`,`aspectRatio`],o);let s=m(e,[`resolution`]);t!==void 0&&s!=null&&p(t,[`parameters`,`resolution`],s);let c=m(e,[`personGeneration`]);if(t!==void 0&&c!=null&&p(t,[`parameters`,`personGeneration`],c),m(e,[`pubsubTopic`])!==void 0)throw Error(`pubsubTopic parameter is not supported in Gemini API.`);let l=m(e,[`negativePrompt`]);t!==void 0&&l!=null&&p(t,[`parameters`,`negativePrompt`],l);let u=m(e,[`enhancePrompt`]);if(t!==void 0&&u!=null&&p(t,[`parameters`,`enhancePrompt`],u),m(e,[`generateAudio`])!==void 0)throw Error(`generateAudio parameter is not supported in Gemini API.`);let d=m(e,[`lastFrame`]);t!==void 0&&d!=null&&p(t,[`instances[0]`,`lastFrame`],po(d));let f=m(e,[`referenceImages`]);if(t!==void 0&&f!=null){let e=f;Array.isArray(e)&&(e=e.map(e=>ts(e))),p(t,[`instances[0]`,`referenceImages`],e)}if(m(e,[`mask`])!==void 0)throw Error(`mask parameter is not supported in Gemini API.`);if(m(e,[`compressionQuality`])!==void 0)throw Error(`compressionQuality parameter is not supported in Gemini API.`);if(m(e,[`labels`])!==void 0)throw Error(`labels parameter is not supported in Gemini API.`);let h=m(e,[`webhookConfig`]);if(t!==void 0&&h!=null&&p(t,[`webhookConfig`],h),m(e,[`resizeMode`])!==void 0)throw Error(`resizeMode parameter is not supported in Gemini API.`);return r}function Ua(e,t,n){let r={},i=m(e,[`numberOfVideos`]);t!==void 0&&i!=null&&p(t,[`parameters`,`sampleCount`],i);let a=m(e,[`outputGcsUri`]);t!==void 0&&a!=null&&p(t,[`parameters`,`storageUri`],a);let o=m(e,[`fps`]);t!==void 0&&o!=null&&p(t,[`parameters`,`fps`],o);let s=m(e,[`durationSeconds`]);t!==void 0&&s!=null&&p(t,[`parameters`,`durationSeconds`],s);let c=m(e,[`seed`]);t!==void 0&&c!=null&&p(t,[`parameters`,`seed`],c);let l=m(e,[`aspectRatio`]);t!==void 0&&l!=null&&p(t,[`parameters`,`aspectRatio`],l);let u=m(e,[`resolution`]);t!==void 0&&u!=null&&p(t,[`parameters`,`resolution`],u);let d=m(e,[`personGeneration`]);t!==void 0&&d!=null&&p(t,[`parameters`,`personGeneration`],d);let f=m(e,[`pubsubTopic`]);t!==void 0&&f!=null&&p(t,[`parameters`,`pubsubTopic`],f);let h=m(e,[`negativePrompt`]);t!==void 0&&h!=null&&p(t,[`parameters`,`negativePrompt`],h);let g=m(e,[`enhancePrompt`]);t!==void 0&&g!=null&&p(t,[`parameters`,`enhancePrompt`],g);let _=m(e,[`generateAudio`]);t!==void 0&&_!=null&&p(t,[`parameters`,`generateAudio`],_);let v=m(e,[`lastFrame`]);t!==void 0&&v!=null&&p(t,[`instances[0]`,`lastFrame`],q(v));let y=m(e,[`referenceImages`]);if(t!==void 0&&y!=null){let e=y;Array.isArray(e)&&(e=e.map(e=>ns(e))),p(t,[`instances[0]`,`referenceImages`],e)}let b=m(e,[`mask`]);t!==void 0&&b!=null&&p(t,[`instances[0]`,`mask`],es(b));let x=m(e,[`compressionQuality`]);t!==void 0&&x!=null&&p(t,[`parameters`,`compressionQuality`],x);let S=m(e,[`labels`]);if(t!==void 0&&S!=null&&p(t,[`labels`],S),m(e,[`webhookConfig`])!==void 0)throw Error(`webhookConfig parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);let C=m(e,[`resizeMode`]);return t!==void 0&&C!=null&&p(t,[`parameters`,`resizeMode`],C),r}function Wa(e,t){let n={},r=m(e,[`name`]);r!=null&&p(n,[`name`],r);let i=m(e,[`metadata`]);i!=null&&p(n,[`metadata`],i);let a=m(e,[`done`]);a!=null&&p(n,[`done`],a);let o=m(e,[`error`]);o!=null&&p(n,[`error`],o);let s=m(e,[`response`,`generateVideoResponse`]);return s!=null&&p(n,[`response`],Ja(s)),n}function Ga(e,t){let n={},r=m(e,[`name`]);r!=null&&p(n,[`name`],r);let i=m(e,[`metadata`]);i!=null&&p(n,[`metadata`],i);let a=m(e,[`done`]);a!=null&&p(n,[`done`],a);let o=m(e,[`error`]);o!=null&&p(n,[`error`],o);let s=m(e,[`response`]);return s!=null&&p(n,[`response`],Ya(s)),n}function Ka(e,t,n){let r={},i=m(t,[`model`]);i!=null&&p(r,[`_url`,`model`],I(e,i));let a=m(t,[`prompt`]);a!=null&&p(r,[`instances[0]`,`prompt`],a);let o=m(t,[`image`]);o!=null&&p(r,[`instances[0]`,`image`],po(o));let s=m(t,[`video`]);s!=null&&p(r,[`instances[0]`,`video`],rs(s));let c=m(t,[`source`]);c!=null&&Xa(c,r);let l=m(t,[`config`]);return l!=null&&Ha(l,r),r}function qa(e,t,n){let r={},i=m(t,[`model`]);i!=null&&p(r,[`_url`,`model`],I(e,i));let a=m(t,[`prompt`]);a!=null&&p(r,[`instances[0]`,`prompt`],a);let o=m(t,[`image`]);o!=null&&p(r,[`instances[0]`,`image`],q(o));let s=m(t,[`video`]);s!=null&&p(r,[`instances[0]`,`video`],is(s));let c=m(t,[`source`]);c!=null&&Za(c,r);let l=m(t,[`config`]);return l!=null&&Ua(l,r),r}function Ja(e,t){let n={},r=m(e,[`generatedSamples`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>to(e))),p(n,[`generatedVideos`],e)}let i=m(e,[`raiMediaFilteredCount`]);i!=null&&p(n,[`raiMediaFilteredCount`],i);let a=m(e,[`raiMediaFilteredReasons`]);return a!=null&&p(n,[`raiMediaFilteredReasons`],a),n}function Ya(e,t){let n={},r=m(e,[`videos`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>no(e))),p(n,[`generatedVideos`],e)}let i=m(e,[`raiMediaFilteredCount`]);i!=null&&p(n,[`raiMediaFilteredCount`],i);let a=m(e,[`raiMediaFilteredReasons`]);return a!=null&&p(n,[`raiMediaFilteredReasons`],a),n}function Xa(e,t,n){let r={},i=m(e,[`prompt`]);t!==void 0&&i!=null&&p(t,[`instances[0]`,`prompt`],i);let a=m(e,[`image`]);t!==void 0&&a!=null&&p(t,[`instances[0]`,`image`],po(a));let o=m(e,[`video`]);return t!==void 0&&o!=null&&p(t,[`instances[0]`,`video`],rs(o)),r}function Za(e,t,n){let r={},i=m(e,[`prompt`]);t!==void 0&&i!=null&&p(t,[`instances[0]`,`prompt`],i);let a=m(e,[`image`]);t!==void 0&&a!=null&&p(t,[`instances[0]`,`image`],q(a));let o=m(e,[`video`]);return t!==void 0&&o!=null&&p(t,[`instances[0]`,`video`],is(o)),r}function Qa(e,t){let n={},r=m(e,[`_self`]);r!=null&&p(n,[`image`],uo(r));let i=m(e,[`raiFilteredReason`]);i!=null&&p(n,[`raiFilteredReason`],i);let a=m(e,[`_self`]);return a!=null&&p(n,[`safetyAttributes`],jo(a)),n}function $a(e,t){let n={},r=m(e,[`_self`]);r!=null&&p(n,[`image`],fo(r));let i=m(e,[`raiFilteredReason`]);i!=null&&p(n,[`raiFilteredReason`],i);let a=m(e,[`_self`]);a!=null&&p(n,[`safetyAttributes`],Mo(a));let o=m(e,[`prompt`]);return o!=null&&p(n,[`enhancedPrompt`],o),n}function eo(e,t){let n={},r=m(e,[`_self`]);r!=null&&p(n,[`mask`],fo(r));let i=m(e,[`labels`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),p(n,[`labels`],e)}return n}function to(e,t){let n={},r=m(e,[`video`]);return r!=null&&p(n,[`video`],Qo(r)),n}function no(e,t){let n={},r=m(e,[`_self`]);return r!=null&&p(n,[`video`],$o(r)),n}function ro(e,t){let n={},r=m(e,[`modelSelectionConfig`]);r!=null&&p(n,[`modelConfig`],r);let i=m(e,[`responseJsonSchema`]);i!=null&&p(n,[`responseJsonSchema`],i);let a=m(e,[`audioTimestamp`]);a!=null&&p(n,[`audioTimestamp`],a);let o=m(e,[`candidateCount`]);o!=null&&p(n,[`candidateCount`],o);let s=m(e,[`enableAffectiveDialog`]);s!=null&&p(n,[`enableAffectiveDialog`],s);let c=m(e,[`frequencyPenalty`]);c!=null&&p(n,[`frequencyPenalty`],c);let l=m(e,[`logprobs`]);l!=null&&p(n,[`logprobs`],l);let u=m(e,[`maxOutputTokens`]);u!=null&&p(n,[`maxOutputTokens`],u);let d=m(e,[`mediaResolution`]);d!=null&&p(n,[`mediaResolution`],d);let f=m(e,[`presencePenalty`]);f!=null&&p(n,[`presencePenalty`],f);let h=m(e,[`responseLogprobs`]);h!=null&&p(n,[`responseLogprobs`],h);let g=m(e,[`responseMimeType`]);g!=null&&p(n,[`responseMimeType`],g);let _=m(e,[`responseModalities`]);_!=null&&p(n,[`responseModalities`],_);let v=m(e,[`responseSchema`]);v!=null&&p(n,[`responseSchema`],v);let y=m(e,[`routingConfig`]);y!=null&&p(n,[`routingConfig`],y);let b=m(e,[`seed`]);b!=null&&p(n,[`seed`],b);let x=m(e,[`speechConfig`]);x!=null&&p(n,[`speechConfig`],x);let S=m(e,[`stopSequences`]);S!=null&&p(n,[`stopSequences`],S);let C=m(e,[`temperature`]);C!=null&&p(n,[`temperature`],C);let w=m(e,[`thinkingConfig`]);w!=null&&p(n,[`thinkingConfig`],w);let T=m(e,[`topK`]);T!=null&&p(n,[`topK`],T);let E=m(e,[`topP`]);if(E!=null&&p(n,[`topP`],E),m(e,[`enableEnhancedCivicAnswers`])!==void 0)throw Error(`enableEnhancedCivicAnswers parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);return n}function io(e,t,n){let r={},i=m(t,[`model`]);return i!=null&&p(r,[`_url`,`name`],I(e,i)),r}function ao(e,t,n){let r={},i=m(t,[`model`]);return i!=null&&p(r,[`_url`,`name`],I(e,i)),r}function oo(e,t){let n={},r=m(e,[`authConfig`]);r!=null&&p(n,[`authConfig`],Yi(r));let i=m(e,[`enableWidget`]);return i!=null&&p(n,[`enableWidget`],i),n}function so(e,t){let n={},r=m(e,[`searchTypes`]);if(r!=null&&p(n,[`searchTypes`],r),m(e,[`blockingConfidence`])!==void 0)throw Error(`blockingConfidence parameter is not supported in Gemini API.`);if(m(e,[`excludeDomains`])!==void 0)throw Error(`excludeDomains parameter is not supported in Gemini API.`);let i=m(e,[`timeRangeFilter`]);return i!=null&&p(n,[`timeRangeFilter`],i),n}function co(e,t){let n={},r=m(e,[`aspectRatio`]);r!=null&&p(n,[`aspectRatio`],r);let i=m(e,[`imageSize`]);if(i!=null&&p(n,[`imageSize`],i),m(e,[`personGeneration`])!==void 0)throw Error(`personGeneration parameter is not supported in Gemini API.`);if(m(e,[`prominentPeople`])!==void 0)throw Error(`prominentPeople parameter is not supported in Gemini API.`);if(m(e,[`outputMimeType`])!==void 0)throw Error(`outputMimeType parameter is not supported in Gemini API.`);if(m(e,[`outputCompressionQuality`])!==void 0)throw Error(`outputCompressionQuality parameter is not supported in Gemini API.`);if(m(e,[`imageOutputOptions`])!==void 0)throw Error(`imageOutputOptions parameter is not supported in Gemini API.`);return n}function lo(e,t){let n={},r=m(e,[`aspectRatio`]);r!=null&&p(n,[`aspectRatio`],r);let i=m(e,[`imageSize`]);i!=null&&p(n,[`imageSize`],i);let a=m(e,[`personGeneration`]);a!=null&&p(n,[`personGeneration`],a);let o=m(e,[`prominentPeople`]);o!=null&&p(n,[`prominentPeople`],o);let s=m(e,[`outputMimeType`]);s!=null&&p(n,[`imageOutputOptions`,`mimeType`],s);let c=m(e,[`outputCompressionQuality`]);c!=null&&p(n,[`imageOutputOptions`,`compressionQuality`],c);let l=m(e,[`imageOutputOptions`]);return l!=null&&p(n,[`imageOutputOptions`],l),n}function uo(e,t){let n={},r=m(e,[`bytesBase64Encoded`]);r!=null&&p(n,[`imageBytes`],B(r));let i=m(e,[`mimeType`]);return i!=null&&p(n,[`mimeType`],i),n}function fo(e,t){let n={},r=m(e,[`gcsUri`]);r!=null&&p(n,[`gcsUri`],r);let i=m(e,[`bytesBase64Encoded`]);i!=null&&p(n,[`imageBytes`],B(i));let a=m(e,[`mimeType`]);return a!=null&&p(n,[`mimeType`],a),n}function po(e,t){let n={};if(m(e,[`gcsUri`])!==void 0)throw Error(`gcsUri parameter is not supported in Gemini API.`);let r=m(e,[`imageBytes`]);r!=null&&p(n,[`bytesBase64Encoded`],B(r));let i=m(e,[`mimeType`]);return i!=null&&p(n,[`mimeType`],i),n}function q(e,t){let n={},r=m(e,[`gcsUri`]);r!=null&&p(n,[`gcsUri`],r);let i=m(e,[`imageBytes`]);i!=null&&p(n,[`bytesBase64Encoded`],B(i));let a=m(e,[`mimeType`]);return a!=null&&p(n,[`mimeType`],a),n}function mo(e,t,n,r){let i={},a=m(t,[`pageSize`]);n!==void 0&&a!=null&&p(n,[`_query`,`pageSize`],a);let o=m(t,[`pageToken`]);n!==void 0&&o!=null&&p(n,[`_query`,`pageToken`],o);let s=m(t,[`filter`]);n!==void 0&&s!=null&&p(n,[`_query`,`filter`],s);let c=m(t,[`queryBase`]);return n!==void 0&&c!=null&&p(n,[`_url`,`models_url`],ln(e,c)),i}function ho(e,t,n,r){let i={},a=m(t,[`pageSize`]);n!==void 0&&a!=null&&p(n,[`_query`,`pageSize`],a);let o=m(t,[`pageToken`]);n!==void 0&&o!=null&&p(n,[`_query`,`pageToken`],o);let s=m(t,[`filter`]);n!==void 0&&s!=null&&p(n,[`_query`,`filter`],s);let c=m(t,[`queryBase`]);return n!==void 0&&c!=null&&p(n,[`_url`,`models_url`],ln(e,c)),i}function go(e,t,n){let r={},i=m(t,[`config`]);return i!=null&&mo(e,i,r),r}function _o(e,t,n){let r={},i=m(t,[`config`]);return i!=null&&ho(e,i,r),r}function vo(e,t){let n={},r=m(e,[`sdkHttpResponse`]);r!=null&&p(n,[`sdkHttpResponse`],r);let i=m(e,[`nextPageToken`]);i!=null&&p(n,[`nextPageToken`],i);let a=m(e,[`_self`]);if(a!=null){let e=un(a);Array.isArray(e)&&(e=e.map(e=>xo(e))),p(n,[`models`],e)}return n}function yo(e,t){let n={},r=m(e,[`sdkHttpResponse`]);r!=null&&p(n,[`sdkHttpResponse`],r);let i=m(e,[`nextPageToken`]);i!=null&&p(n,[`nextPageToken`],i);let a=m(e,[`_self`]);if(a!=null){let e=un(a);Array.isArray(e)&&(e=e.map(e=>So(e))),p(n,[`models`],e)}return n}function bo(e,t){let n={},r=m(e,[`maskMode`]);r!=null&&p(n,[`maskMode`],r);let i=m(e,[`segmentationClasses`]);i!=null&&p(n,[`maskClasses`],i);let a=m(e,[`maskDilation`]);return a!=null&&p(n,[`dilation`],a),n}function xo(e,t){let n={},r=m(e,[`name`]);r!=null&&p(n,[`name`],r);let i=m(e,[`displayName`]);i!=null&&p(n,[`displayName`],i);let a=m(e,[`description`]);a!=null&&p(n,[`description`],a);let o=m(e,[`version`]);o!=null&&p(n,[`version`],o);let s=m(e,[`_self`]);s!=null&&p(n,[`tunedModelInfo`],Uo(s));let c=m(e,[`inputTokenLimit`]);c!=null&&p(n,[`inputTokenLimit`],c);let l=m(e,[`outputTokenLimit`]);l!=null&&p(n,[`outputTokenLimit`],l);let u=m(e,[`supportedGenerationMethods`]);u!=null&&p(n,[`supportedActions`],u);let d=m(e,[`temperature`]);d!=null&&p(n,[`temperature`],d);let f=m(e,[`maxTemperature`]);f!=null&&p(n,[`maxTemperature`],f);let h=m(e,[`topP`]);h!=null&&p(n,[`topP`],h);let g=m(e,[`topK`]);g!=null&&p(n,[`topK`],g);let _=m(e,[`thinking`]);return _!=null&&p(n,[`thinking`],_),n}function So(e,t){let n={},r=m(e,[`name`]);r!=null&&p(n,[`name`],r);let i=m(e,[`displayName`]);i!=null&&p(n,[`displayName`],i);let a=m(e,[`description`]);a!=null&&p(n,[`description`],a);let o=m(e,[`versionId`]);o!=null&&p(n,[`version`],o);let s=m(e,[`deployedModels`]);if(s!=null){let e=s;Array.isArray(e)&&(e=e.map(e=>Ta(e))),p(n,[`endpoints`],e)}let c=m(e,[`labels`]);c!=null&&p(n,[`labels`],c);let l=m(e,[`_self`]);l!=null&&p(n,[`tunedModelInfo`],Wo(l));let u=m(e,[`defaultCheckpointId`]);u!=null&&p(n,[`defaultCheckpointId`],u);let d=m(e,[`checkpoints`]);if(d!=null){let e=d;Array.isArray(e)&&(e=e.map(e=>e)),p(n,[`checkpoints`],e)}return n}function Co(e,t){let n={},r=m(e,[`mediaResolution`]);r!=null&&p(n,[`mediaResolution`],r);let i=m(e,[`codeExecutionResult`]);i!=null&&p(n,[`codeExecutionResult`],i);let a=m(e,[`executableCode`]);a!=null&&p(n,[`executableCode`],a);let o=m(e,[`fileData`]);o!=null&&p(n,[`fileData`],Ea(o));let s=m(e,[`functionCall`]);s!=null&&p(n,[`functionCall`],Da(s));let c=m(e,[`functionResponse`]);c!=null&&p(n,[`functionResponse`],c);let l=m(e,[`inlineData`]);l!=null&&p(n,[`inlineData`],Xi(l));let u=m(e,[`text`]);u!=null&&p(n,[`text`],u);let d=m(e,[`thought`]);d!=null&&p(n,[`thought`],d);let f=m(e,[`thoughtSignature`]);f!=null&&p(n,[`thoughtSignature`],f);let h=m(e,[`videoMetadata`]);h!=null&&p(n,[`videoMetadata`],h);let g=m(e,[`toolCall`]);g!=null&&p(n,[`toolCall`],g);let _=m(e,[`toolResponse`]);_!=null&&p(n,[`toolResponse`],_);let v=m(e,[`partMetadata`]);return v!=null&&p(n,[`partMetadata`],v),n}function wo(e,t){let n={},r=m(e,[`mediaResolution`]);r!=null&&p(n,[`mediaResolution`],r);let i=m(e,[`codeExecutionResult`]);i!=null&&p(n,[`codeExecutionResult`],i);let a=m(e,[`executableCode`]);a!=null&&p(n,[`executableCode`],a);let o=m(e,[`fileData`]);o!=null&&p(n,[`fileData`],o);let s=m(e,[`functionCall`]);s!=null&&p(n,[`functionCall`],s);let c=m(e,[`functionResponse`]);c!=null&&p(n,[`functionResponse`],c);let l=m(e,[`inlineData`]);l!=null&&p(n,[`inlineData`],l);let u=m(e,[`text`]);u!=null&&p(n,[`text`],u);let d=m(e,[`thought`]);d!=null&&p(n,[`thought`],d);let f=m(e,[`thoughtSignature`]);f!=null&&p(n,[`thoughtSignature`],f);let h=m(e,[`videoMetadata`]);if(h!=null&&p(n,[`videoMetadata`],h),m(e,[`toolCall`])!==void 0)throw Error(`toolCall parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);if(m(e,[`toolResponse`])!==void 0)throw Error(`toolResponse parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);if(m(e,[`partMetadata`])!==void 0)throw Error(`partMetadata parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);return n}function To(e,t){let n={},r=m(e,[`productImage`]);return r!=null&&p(n,[`image`],q(r)),n}function Eo(e,t,n){let r={},i=m(e,[`numberOfImages`]);t!==void 0&&i!=null&&p(t,[`parameters`,`sampleCount`],i);let a=m(e,[`baseSteps`]);t!==void 0&&a!=null&&p(t,[`parameters`,`baseSteps`],a);let o=m(e,[`outputGcsUri`]);t!==void 0&&o!=null&&p(t,[`parameters`,`storageUri`],o);let s=m(e,[`seed`]);t!==void 0&&s!=null&&p(t,[`parameters`,`seed`],s);let c=m(e,[`safetyFilterLevel`]);t!==void 0&&c!=null&&p(t,[`parameters`,`safetySetting`],c);let l=m(e,[`personGeneration`]);t!==void 0&&l!=null&&p(t,[`parameters`,`personGeneration`],l);let u=m(e,[`addWatermark`]);t!==void 0&&u!=null&&p(t,[`parameters`,`addWatermark`],u);let d=m(e,[`outputMimeType`]);t!==void 0&&d!=null&&p(t,[`parameters`,`outputOptions`,`mimeType`],d);let f=m(e,[`outputCompressionQuality`]);t!==void 0&&f!=null&&p(t,[`parameters`,`outputOptions`,`compressionQuality`],f);let h=m(e,[`enhancePrompt`]);t!==void 0&&h!=null&&p(t,[`parameters`,`enhancePrompt`],h);let g=m(e,[`labels`]);return t!==void 0&&g!=null&&p(t,[`labels`],g),r}function Do(e,t,n){let r={},i=m(t,[`model`]);i!=null&&p(r,[`_url`,`model`],I(e,i));let a=m(t,[`source`]);a!=null&&ko(a,r);let o=m(t,[`config`]);return o!=null&&Eo(o,r),r}function Oo(e,t){let n={},r=m(e,[`predictions`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>$a(e))),p(n,[`generatedImages`],e)}return n}function ko(e,t,n){let r={},i=m(e,[`prompt`]);t!==void 0&&i!=null&&p(t,[`instances[0]`,`prompt`],i);let a=m(e,[`personImage`]);t!==void 0&&a!=null&&p(t,[`instances[0]`,`personImage`,`image`],q(a));let o=m(e,[`productImages`]);if(t!==void 0&&o!=null){let e=o;Array.isArray(e)&&(e=e.map(e=>To(e))),p(t,[`instances[0]`,`productImages`],e)}return r}function Ao(e,t){let n={},r=m(e,[`referenceImage`]);r!=null&&p(n,[`referenceImage`],q(r));let i=m(e,[`referenceId`]);i!=null&&p(n,[`referenceId`],i);let a=m(e,[`referenceType`]);a!=null&&p(n,[`referenceType`],a);let o=m(e,[`maskImageConfig`]);o!=null&&p(n,[`maskImageConfig`],bo(o));let s=m(e,[`controlImageConfig`]);s!=null&&p(n,[`controlImageConfig`],aa(s));let c=m(e,[`styleImageConfig`]);c!=null&&p(n,[`styleImageConfig`],c);let l=m(e,[`subjectImageConfig`]);return l!=null&&p(n,[`subjectImageConfig`],l),n}function jo(e,t){let n={},r=m(e,[`safetyAttributes`,`categories`]);r!=null&&p(n,[`categories`],r);let i=m(e,[`safetyAttributes`,`scores`]);i!=null&&p(n,[`scores`],i);let a=m(e,[`contentType`]);return a!=null&&p(n,[`contentType`],a),n}function Mo(e,t){let n={},r=m(e,[`safetyAttributes`,`categories`]);r!=null&&p(n,[`categories`],r);let i=m(e,[`safetyAttributes`,`scores`]);i!=null&&p(n,[`scores`],i);let a=m(e,[`contentType`]);return a!=null&&p(n,[`contentType`],a),n}function No(e,t){let n={},r=m(e,[`category`]);if(r!=null&&p(n,[`category`],r),m(e,[`method`])!==void 0)throw Error(`method parameter is not supported in Gemini API.`);let i=m(e,[`threshold`]);return i!=null&&p(n,[`threshold`],i),n}function Po(e,t){let n={},r=m(e,[`image`]);return r!=null&&p(n,[`image`],q(r)),n}function Fo(e,t,n){let r={},i=m(e,[`mode`]);t!==void 0&&i!=null&&p(t,[`parameters`,`mode`],i);let a=m(e,[`maxPredictions`]);t!==void 0&&a!=null&&p(t,[`parameters`,`maxPredictions`],a);let o=m(e,[`confidenceThreshold`]);t!==void 0&&o!=null&&p(t,[`parameters`,`confidenceThreshold`],o);let s=m(e,[`maskDilation`]);t!==void 0&&s!=null&&p(t,[`parameters`,`maskDilation`],s);let c=m(e,[`binaryColorThreshold`]);t!==void 0&&c!=null&&p(t,[`parameters`,`binaryColorThreshold`],c);let l=m(e,[`labels`]);return t!==void 0&&l!=null&&p(t,[`labels`],l),r}function Io(e,t,n){let r={},i=m(t,[`model`]);i!=null&&p(r,[`_url`,`model`],I(e,i));let a=m(t,[`source`]);a!=null&&Ro(a,r);let o=m(t,[`config`]);return o!=null&&Fo(o,r),r}function Lo(e,t){let n={},r=m(e,[`predictions`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>eo(e))),p(n,[`generatedMasks`],e)}return n}function Ro(e,t,n){let r={},i=m(e,[`prompt`]);t!==void 0&&i!=null&&p(t,[`instances[0]`,`prompt`],i);let a=m(e,[`image`]);t!==void 0&&a!=null&&p(t,[`instances[0]`,`image`],q(a));let o=m(e,[`scribbleImage`]);return t!==void 0&&o!=null&&p(t,[`instances[0]`,`scribble`],Po(o)),r}function zo(e,t){let n={},r=m(e,[`retrievalConfig`]);r!=null&&p(n,[`retrievalConfig`],r);let i=m(e,[`functionCallingConfig`]);i!=null&&p(n,[`functionCallingConfig`],Oa(i));let a=m(e,[`includeServerSideToolInvocations`]);return a!=null&&p(n,[`includeServerSideToolInvocations`],a),n}function Bo(e,t){let n={},r=m(e,[`retrievalConfig`]);r!=null&&p(n,[`retrievalConfig`],r);let i=m(e,[`functionCallingConfig`]);if(i!=null&&p(n,[`functionCallingConfig`],i),m(e,[`includeServerSideToolInvocations`])!==void 0)throw Error(`includeServerSideToolInvocations parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);return n}function Vo(e,t){let n={};if(m(e,[`retrieval`])!==void 0)throw Error(`retrieval parameter is not supported in Gemini API.`);let r=m(e,[`computerUse`]);r!=null&&p(n,[`computerUse`],r);let i=m(e,[`fileSearch`]);i!=null&&p(n,[`fileSearch`],i);let a=m(e,[`googleSearch`]);a!=null&&p(n,[`googleSearch`],so(a));let o=m(e,[`googleMaps`]);o!=null&&p(n,[`googleMaps`],oo(o));let s=m(e,[`codeExecution`]);if(s!=null&&p(n,[`codeExecution`],s),m(e,[`enterpriseWebSearch`])!==void 0)throw Error(`enterpriseWebSearch parameter is not supported in Gemini API.`);let c=m(e,[`functionDeclarations`]);if(c!=null){let e=c;Array.isArray(e)&&(e=e.map(e=>e)),p(n,[`functionDeclarations`],e)}let l=m(e,[`googleSearchRetrieval`]);if(l!=null&&p(n,[`googleSearchRetrieval`],l),m(e,[`parallelAiSearch`])!==void 0)throw Error(`parallelAiSearch parameter is not supported in Gemini API.`);let u=m(e,[`urlContext`]);u!=null&&p(n,[`urlContext`],u);let d=m(e,[`mcpServers`]);if(d!=null){let e=d;Array.isArray(e)&&(e=e.map(e=>e)),p(n,[`mcpServers`],e)}return n}function Ho(e,t){let n={},r=m(e,[`retrieval`]);r!=null&&p(n,[`retrieval`],r);let i=m(e,[`computerUse`]);if(i!=null&&p(n,[`computerUse`],i),m(e,[`fileSearch`])!==void 0)throw Error(`fileSearch parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);let a=m(e,[`googleSearch`]);a!=null&&p(n,[`googleSearch`],a);let o=m(e,[`googleMaps`]);o!=null&&p(n,[`googleMaps`],o);let s=m(e,[`codeExecution`]);s!=null&&p(n,[`codeExecution`],s);let c=m(e,[`enterpriseWebSearch`]);c!=null&&p(n,[`enterpriseWebSearch`],c);let l=m(e,[`functionDeclarations`]);if(l!=null){let e=l;Array.isArray(e)&&(e=e.map(e=>ka(e))),p(n,[`functionDeclarations`],e)}let u=m(e,[`googleSearchRetrieval`]);u!=null&&p(n,[`googleSearchRetrieval`],u);let d=m(e,[`parallelAiSearch`]);d!=null&&p(n,[`parallelAiSearch`],d);let f=m(e,[`urlContext`]);if(f!=null&&p(n,[`urlContext`],f),m(e,[`mcpServers`])!==void 0)throw Error(`mcpServers parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);return n}function Uo(e,t){let n={},r=m(e,[`baseModel`]);r!=null&&p(n,[`baseModel`],r);let i=m(e,[`createTime`]);i!=null&&p(n,[`createTime`],i);let a=m(e,[`updateTime`]);return a!=null&&p(n,[`updateTime`],a),n}function Wo(e,t){let n={},r=m(e,[`labels`,`google-vertex-llm-tuning-base-model-id`]);r!=null&&p(n,[`baseModel`],r);let i=m(e,[`createTime`]);i!=null&&p(n,[`createTime`],i);let a=m(e,[`updateTime`]);return a!=null&&p(n,[`updateTime`],a),n}function Go(e,t,n){let r={},i=m(e,[`displayName`]);t!==void 0&&i!=null&&p(t,[`displayName`],i);let a=m(e,[`description`]);t!==void 0&&a!=null&&p(t,[`description`],a);let o=m(e,[`defaultCheckpointId`]);return t!==void 0&&o!=null&&p(t,[`defaultCheckpointId`],o),r}function Ko(e,t,n){let r={},i=m(e,[`displayName`]);t!==void 0&&i!=null&&p(t,[`displayName`],i);let a=m(e,[`description`]);t!==void 0&&a!=null&&p(t,[`description`],a);let o=m(e,[`defaultCheckpointId`]);return t!==void 0&&o!=null&&p(t,[`defaultCheckpointId`],o),r}function qo(e,t,n){let r={},i=m(t,[`model`]);i!=null&&p(r,[`_url`,`name`],I(e,i));let a=m(t,[`config`]);return a!=null&&Go(a,r),r}function Jo(e,t,n){let r={},i=m(t,[`model`]);i!=null&&p(r,[`_url`,`model`],I(e,i));let a=m(t,[`config`]);return a!=null&&Ko(a,r),r}function Yo(e,t,n){let r={},i=m(e,[`outputGcsUri`]);t!==void 0&&i!=null&&p(t,[`parameters`,`storageUri`],i);let a=m(e,[`safetyFilterLevel`]);t!==void 0&&a!=null&&p(t,[`parameters`,`safetySetting`],a);let o=m(e,[`personGeneration`]);t!==void 0&&o!=null&&p(t,[`parameters`,`personGeneration`],o);let s=m(e,[`includeRaiReason`]);t!==void 0&&s!=null&&p(t,[`parameters`,`includeRaiReason`],s);let c=m(e,[`outputMimeType`]);t!==void 0&&c!=null&&p(t,[`parameters`,`outputOptions`,`mimeType`],c);let l=m(e,[`outputCompressionQuality`]);t!==void 0&&l!=null&&p(t,[`parameters`,`outputOptions`,`compressionQuality`],l);let u=m(e,[`enhanceInputImage`]);t!==void 0&&u!=null&&p(t,[`parameters`,`upscaleConfig`,`enhanceInputImage`],u);let d=m(e,[`imagePreservationFactor`]);t!==void 0&&d!=null&&p(t,[`parameters`,`upscaleConfig`,`imagePreservationFactor`],d);let f=m(e,[`labels`]);t!==void 0&&f!=null&&p(t,[`labels`],f);let h=m(e,[`numberOfImages`]);t!==void 0&&h!=null&&p(t,[`parameters`,`sampleCount`],h);let g=m(e,[`mode`]);return t!==void 0&&g!=null&&p(t,[`parameters`,`mode`],g),r}function Xo(e,t,n){let r={},i=m(t,[`model`]);i!=null&&p(r,[`_url`,`model`],I(e,i));let a=m(t,[`image`]);a!=null&&p(r,[`instances[0]`,`image`],q(a));let o=m(t,[`upscaleFactor`]);o!=null&&p(r,[`parameters`,`upscaleConfig`,`upscaleFactor`],o);let s=m(t,[`config`]);return s!=null&&Yo(s,r),r}function Zo(e,t){let n={},r=m(e,[`sdkHttpResponse`]);r!=null&&p(n,[`sdkHttpResponse`],r);let i=m(e,[`predictions`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>$a(e))),p(n,[`generatedImages`],e)}return n}function Qo(e,t){let n={},r=m(e,[`uri`]);r!=null&&p(n,[`uri`],r);let i=m(e,[`encodedVideo`]);i!=null&&p(n,[`videoBytes`],B(i));let a=m(e,[`encoding`]);return a!=null&&p(n,[`mimeType`],a),n}function $o(e,t){let n={},r=m(e,[`gcsUri`]);r!=null&&p(n,[`uri`],r);let i=m(e,[`bytesBase64Encoded`]);i!=null&&p(n,[`videoBytes`],B(i));let a=m(e,[`mimeType`]);return a!=null&&p(n,[`mimeType`],a),n}function es(e,t){let n={},r=m(e,[`image`]);r!=null&&p(n,[`_self`],q(r));let i=m(e,[`maskMode`]);return i!=null&&p(n,[`maskMode`],i),n}function ts(e,t){let n={},r=m(e,[`image`]);r!=null&&p(n,[`image`],po(r));let i=m(e,[`referenceType`]);return i!=null&&p(n,[`referenceType`],i),n}function ns(e,t){let n={},r=m(e,[`image`]);r!=null&&p(n,[`image`],q(r));let i=m(e,[`referenceType`]);return i!=null&&p(n,[`referenceType`],i),n}function rs(e,t){let n={},r=m(e,[`uri`]);r!=null&&p(n,[`uri`],r);let i=m(e,[`videoBytes`]);i!=null&&p(n,[`encodedVideo`],B(i));let a=m(e,[`mimeType`]);return a!=null&&p(n,[`encoding`],a),n}function is(e,t){let n={},r=m(e,[`uri`]);r!=null&&p(n,[`gcsUri`],r);let i=m(e,[`videoBytes`]);i!=null&&p(n,[`bytesBase64Encoded`],B(i));let a=m(e,[`mimeType`]);return a!=null&&p(n,[`mimeType`],a),n}
|
|
104
|
+
/**
|
|
105
|
+
* @license
|
|
106
|
+
* Copyright 2025 Google LLC
|
|
107
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
108
|
+
*/
|
|
109
|
+
function as(e,t,n){let r={},i=m(t,[`displayName`]);n!==void 0&&i!=null&&p(n,[`displayName`],i);let a=m(t,[`embeddingModel`]);return n!==void 0&&a!=null&&p(n,[`embeddingModel`],I(e,a)),r}function os(e,t){let n={},r=m(t,[`config`]);return r!=null&&as(e,r,n),n}function ss(e,t){let n={},r=m(e,[`force`]);return t!==void 0&&r!=null&&p(t,[`_query`,`force`],r),n}function cs(e){let t={},n=m(e,[`name`]);n!=null&&p(t,[`_url`,`name`],n);let r=m(e,[`config`]);return r!=null&&ss(r,t),t}function ls(e){let t={},n=m(e,[`name`]);return n!=null&&p(t,[`_url`,`name`],n),t}function us(e,t){let n={},r=m(e,[`customMetadata`]);if(t!==void 0&&r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),p(t,[`customMetadata`],e)}let i=m(e,[`chunkingConfig`]);return t!==void 0&&i!=null&&p(t,[`chunkingConfig`],i),n}function ds(e){let t={},n=m(e,[`name`]);n!=null&&p(t,[`name`],n);let r=m(e,[`metadata`]);r!=null&&p(t,[`metadata`],r);let i=m(e,[`done`]);i!=null&&p(t,[`done`],i);let a=m(e,[`error`]);a!=null&&p(t,[`error`],a);let o=m(e,[`response`]);return o!=null&&p(t,[`response`],ps(o)),t}function fs(e){let t={},n=m(e,[`fileSearchStoreName`]);n!=null&&p(t,[`_url`,`file_search_store_name`],n);let r=m(e,[`fileName`]);r!=null&&p(t,[`fileName`],r);let i=m(e,[`config`]);return i!=null&&us(i,t),t}function ps(e){let t={},n=m(e,[`sdkHttpResponse`]);n!=null&&p(t,[`sdkHttpResponse`],n);let r=m(e,[`parent`]);r!=null&&p(t,[`parent`],r);let i=m(e,[`documentName`]);return i!=null&&p(t,[`documentName`],i),t}function ms(e,t){let n={},r=m(e,[`pageSize`]);t!==void 0&&r!=null&&p(t,[`_query`,`pageSize`],r);let i=m(e,[`pageToken`]);return t!==void 0&&i!=null&&p(t,[`_query`,`pageToken`],i),n}function hs(e){let t={},n=m(e,[`config`]);return n!=null&&ms(n,t),t}function gs(e){let t={},n=m(e,[`sdkHttpResponse`]);n!=null&&p(t,[`sdkHttpResponse`],n);let r=m(e,[`nextPageToken`]);r!=null&&p(t,[`nextPageToken`],r);let i=m(e,[`fileSearchStores`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),p(t,[`fileSearchStores`],e)}return t}function _s(e,t){let n={},r=m(e,[`mimeType`]);t!==void 0&&r!=null&&p(t,[`mimeType`],r);let i=m(e,[`displayName`]);t!==void 0&&i!=null&&p(t,[`displayName`],i);let a=m(e,[`customMetadata`]);if(t!==void 0&&a!=null){let e=a;Array.isArray(e)&&(e=e.map(e=>e)),p(t,[`customMetadata`],e)}let o=m(e,[`chunkingConfig`]);return t!==void 0&&o!=null&&p(t,[`chunkingConfig`],o),n}function vs(e){let t={},n=m(e,[`fileSearchStoreName`]);n!=null&&p(t,[`_url`,`file_search_store_name`],n);let r=m(e,[`config`]);return r!=null&&_s(r,t),t}function ys(e){let t={},n=m(e,[`sdkHttpResponse`]);return n!=null&&p(t,[`sdkHttpResponse`],n),t}
|
|
110
|
+
/**
|
|
111
|
+
* @license
|
|
112
|
+
* Copyright 2025 Google LLC
|
|
113
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
114
|
+
*/
|
|
115
|
+
const bs=`x-goog-api-client`,xs=new Set([`us`,`eu`]),Ss=[408,429,500,502,503,504];var Cs=class{constructor(e){this.clientOptions=Object.assign({},e),this.customBaseUrl=e.httpOptions?.baseUrl,this.clientOptions.vertexai&&(this.clientOptions.project&&this.clientOptions.location?this.clientOptions.apiKey=void 0:this.clientOptions.apiKey&&(this.clientOptions.project=void 0,this.clientOptions.location=void 0));let t={};if(this.clientOptions.vertexai){if(!this.clientOptions.location&&!this.clientOptions.apiKey&&!this.customBaseUrl&&(this.clientOptions.location=`global`),!(this.clientOptions.project&&this.clientOptions.location||this.clientOptions.apiKey)&&!this.customBaseUrl)throw Error(`Authentication is not set up. Please provide either a project and location, or an API key, or a custom base URL.`);let n=e.project&&e.location||!!e.apiKey;this.customBaseUrl&&!n?(t.baseUrl=this.customBaseUrl,this.clientOptions.project=void 0,this.clientOptions.location=void 0):this.clientOptions.apiKey||this.clientOptions.location===`global`?t.baseUrl=`https://aiplatform.googleapis.com/`:this.clientOptions.project&&this.clientOptions.location&&xs.has(this.clientOptions.location)?t.baseUrl=`https://aiplatform.${this.clientOptions.location}.rep.googleapis.com/`:this.clientOptions.project&&this.clientOptions.location&&(t.baseUrl=`https://${this.clientOptions.location}-aiplatform.googleapis.com/`),t.apiVersion=this.clientOptions.apiVersion??`v1beta1`}else this.clientOptions.apiKey||console.warn(`API key should be set when using the Gemini API.`),t.apiVersion=this.clientOptions.apiVersion??`v1beta`,t.baseUrl=`https://generativelanguage.googleapis.com/`;t.headers=this.getDefaultHeaders(),this.clientOptions.httpOptions=t,e.httpOptions&&(this.clientOptions.httpOptions=this.patchHttpOptions(t,e.httpOptions))}isVertexAI(){return this.clientOptions.vertexai??!1}getProject(){return this.clientOptions.project}getLocation(){return this.clientOptions.location}getCustomBaseUrl(){return this.customBaseUrl}async getAuthHeaders(){let e=new Headers;return await this.clientOptions.auth.addAuthHeaders(e),e}getApiVersion(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.apiVersion!==void 0)return this.clientOptions.httpOptions.apiVersion;throw Error(`API version is not set.`)}getBaseUrl(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.baseUrl!==void 0)return this.clientOptions.httpOptions.baseUrl;throw Error(`Base URL is not set.`)}getRequestUrl(){return this.getRequestUrlInternal(this.clientOptions.httpOptions)}getHeaders(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.headers!==void 0)return this.clientOptions.httpOptions.headers;throw Error(`Headers are not set.`)}getRequestUrlInternal(e){if(!e||e.baseUrl===void 0||e.apiVersion===void 0)throw Error(`HTTP options are not correctly set.`);let t=[e.baseUrl.endsWith(`/`)?e.baseUrl.slice(0,-1):e.baseUrl];return e.apiVersion&&e.apiVersion!==``&&t.push(e.apiVersion),t.join(`/`)}getBaseResourcePath(){return`projects/${this.clientOptions.project}/locations/${this.clientOptions.location}`}getApiKey(){return this.clientOptions.apiKey}getWebsocketBaseUrl(){let e=this.getBaseUrl(),t=new URL(e);return t.protocol=t.protocol==`http:`?`ws`:`wss`,t.toString()}setBaseUrl(e){if(this.clientOptions.httpOptions)this.clientOptions.httpOptions.baseUrl=e;else throw Error(`HTTP options are not correctly set.`)}constructUrl(e,t,n){let r=[this.getRequestUrlInternal(t)];return n&&r.push(this.getBaseResourcePath()),e!==``&&r.push(e),new URL(`${r.join(`/`)}`)}shouldPrependVertexProjectPath(e,t){return!(t.baseUrl&&t.baseUrlResourceScope===Pe.COLLECTION||this.clientOptions.apiKey||!this.clientOptions.vertexai||e.path.startsWith(`projects/`)||e.httpMethod===`GET`&&e.path.startsWith(`publishers/google/models`))}async request(e){let t=this.clientOptions.httpOptions;e.httpOptions&&(t=this.patchHttpOptions(this.clientOptions.httpOptions,e.httpOptions));let n=this.shouldPrependVertexProjectPath(e,t),r=this.constructUrl(e.path,t,n);if(e.queryParams)for(let[t,n]of Object.entries(e.queryParams))r.searchParams.append(t,String(n));let i={};if(e.httpMethod===`GET`){if(e.body&&e.body!==`{}`)throw Error(`Request body should be empty for GET request, but got non empty request body`)}else i.body=e.body;return i=await this.includeExtraHttpOptionsToRequestInit(i,t,r.toString(),e.abortSignal),this.unaryApiCall(r,i,e.httpMethod)}patchHttpOptions(e,t){let n=JSON.parse(JSON.stringify(e));for(let[e,r]of Object.entries(t))typeof r==`object`?n[e]=Object.assign(Object.assign({},n[e]),r):r!==void 0&&(n[e]=r);return n}async requestStream(e){let t=this.clientOptions.httpOptions;e.httpOptions&&(t=this.patchHttpOptions(this.clientOptions.httpOptions,e.httpOptions));let n=this.shouldPrependVertexProjectPath(e,t),r=this.constructUrl(e.path,t,n);(!r.searchParams.has(`alt`)||r.searchParams.get(`alt`)!==`sse`)&&r.searchParams.set(`alt`,`sse`);let i={};return i.body=e.body,i=await this.includeExtraHttpOptionsToRequestInit(i,t,r.toString(),e.abortSignal),this.streamApiCall(r,i,e.httpMethod)}async includeExtraHttpOptionsToRequestInit(e,t,n,r){if(t&&t.timeout||r){let n=new AbortController,i=n.signal;if(t.timeout&&t?.timeout>0){let e=setTimeout(()=>n.abort(),t.timeout);e&&typeof e.unref==`function`&&e.unref()}r&&r.addEventListener(`abort`,()=>{n.abort()}),e.signal=i}return t&&t.extraBody!==null&&Ts(e,t.extraBody),e.headers=await this.getHeadersInternal(t,n),e}async unaryApiCall(e,t,n){return this.apiCall(e.toString(),Object.assign(Object.assign({},t),{method:n})).then(async e=>(await ws(e),new lt(e))).catch(e=>{throw e instanceof Error?e:Error(JSON.stringify(e))})}async streamApiCall(e,t,n){return this.apiCall(e.toString(),Object.assign(Object.assign({},t),{method:n})).then(async e=>(await ws(e),this.processStreamResponse(e))).catch(e=>{throw e instanceof Error?e:Error(JSON.stringify(e))})}processStreamResponse(e){return G(this,arguments,function*(){let t=(e?.body)?.getReader(),n=new TextDecoder(`utf-8`);if(!t)throw Error(`Response body is empty`);try{let r=``,i=[`
|
|
116
|
+
|
|
117
|
+
`,`\r\r`,`\r
|
|
118
|
+
\r
|
|
119
|
+
`];for(;;){let{done:a,value:o}=yield W(t.read());if(a){if(r.trim().length>0)throw Error(`Incomplete JSON segment at the end`);break}let s=n.decode(o,{stream:!0});try{let e=JSON.parse(s);if(`error`in e){let t=JSON.parse(JSON.stringify(e.error)),n=t.status,r=t.code,i=`got status: ${n}. ${JSON.stringify(e)}`;if(r>=400&&r<600)throw new li({message:i,status:r})}}catch(e){if(e.name===`ApiError`)throw e}r+=s;let c=-1,l=0;for(;;){c=-1,l=0;for(let e of i){let t=r.indexOf(e);t!==-1&&(c===-1||t<c)&&(c=t,l=e.length)}if(c===-1)break;let t=r.substring(0,c);r=r.substring(c+l);let n=t.trim();if(n.startsWith(`data:`)){let t=n.substring(5).trim();try{yield yield W(new lt(new Response(t,{headers:e?.headers,status:e?.status,statusText:e?.statusText})))}catch(e){throw Error(`exception parsing stream chunk ${t}. ${e}`)}}}}}finally{t.releaseLock()}})}async apiCall(e,t){if(!this.clientOptions.httpOptions||!this.clientOptions.httpOptions.retryOptions)return fetch(e,t);let n=this.clientOptions.httpOptions.retryOptions;return(0,c.default)(async()=>{let n=await fetch(e,t);if(n.ok)return n;throw Ss.includes(n.status)?Error(`Retryable HTTP Error: ${n.statusText}`):new c.AbortError(`Non-retryable exception ${n.statusText} sending request`)},{retries:(n.attempts??5)-1})}getDefaultHeaders(){let e={},t=`google-genai-sdk/1.52.0 `+this.clientOptions.userAgentExtra;return e[`User-Agent`]=t,e[bs]=t,e[`Content-Type`]=`application/json`,e}async getHeadersInternal(e,t){let n=new Headers;if(e&&e.headers){for(let[t,r]of Object.entries(e.headers))n.append(t,r);e.timeout&&e.timeout>0&&n.append(`X-Server-Timeout`,String(Math.ceil(e.timeout/1e3)))}return await this.clientOptions.auth.addAuthHeaders(n,t),n}getFileName(e){let t=``;return typeof e==`string`&&(t=e.replace(/[/\\]+$/,``),t=t.split(/[/\\]/).pop()??``),t}async uploadFile(e,t){let n={};t!=null&&(n.mimeType=t.mimeType,n.name=t.name,n.displayName=t.displayName),n.name&&!n.name.startsWith(`files/`)&&(n.name=`files/${n.name}`);let r=this.clientOptions.uploader,i=await r.stat(e);n.sizeBytes=String(i.size);let a=t?.mimeType??i.type;if(a===void 0||a===``)throw Error(`Can not determine mimeType. Please provide mimeType in the config.`);n.mimeType=a;let o={file:n},s=this.getFileName(e),c=f(`upload/v1beta/files`,o._url),l=await this.fetchUploadUrl(c,n.sizeBytes,n.mimeType,s,o,t?.httpOptions);return r.upload(e,l,this)}async uploadFileToFileSearchStore(e,t,n){let r=this.clientOptions.uploader,i=await r.stat(t),a=String(i.size),o=n?.mimeType??i.type;if(o===void 0||o===``)throw Error(`Can not determine mimeType. Please provide mimeType in the config.`);let s=`upload/v1beta/${e}:uploadToFileSearchStore`,c=this.getFileName(t),l={};n!=null&&_s(n,l);let u=await this.fetchUploadUrl(s,a,o,c,l,n?.httpOptions);return r.uploadToFileSearchStore(t,u,this)}async downloadFile(e){await this.clientOptions.downloader.download(e,this)}async fetchUploadUrl(e,t,n,r,i,a){let o={};o=a||{apiVersion:``,headers:Object.assign({"Content-Type":`application/json`,"X-Goog-Upload-Protocol":`resumable`,"X-Goog-Upload-Command":`start`,"X-Goog-Upload-Header-Content-Length":`${t}`,"X-Goog-Upload-Header-Content-Type":`${n}`},r?{"X-Goog-Upload-File-Name":r}:{})};let s=await this.request({path:e,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:o});if(!s||!s?.headers)throw Error(`Server did not return an HttpResponse or the returned HttpResponse did not have headers.`);let c=s?.headers?.[`x-goog-upload-url`];if(c===void 0)throw Error(`Failed to get upload url. Server did not return the x-google-upload-url in the headers`);return c}};async function ws(e){if(e===void 0)throw Error(`response is undefined`);if(!e.ok){let t=e.status,n;n=e.headers.get(`content-type`)?.includes(`application/json`)?await e.json():{error:{message:await e.text(),code:e.status,status:e.statusText}};let r=JSON.stringify(n);throw t>=400&&t<600?new li({message:r,status:t}):Error(r)}}function Ts(e,t){if(!t||Object.keys(t).length===0)return;if(e.body instanceof Blob){console.warn(`includeExtraBodyToRequestInit: extraBody provided but current request body is a Blob. extraBody will be ignored as merging is not supported for Blob bodies.`);return}let n={};if(typeof e.body==`string`&&e.body.length>0)try{let t=JSON.parse(e.body);if(typeof t==`object`&&t&&!Array.isArray(t))n=t;else{console.warn(`includeExtraBodyToRequestInit: Original request body is valid JSON but not a non-array object. Skip applying extraBody to the request body.`);return}}catch{console.warn(`includeExtraBodyToRequestInit: Original request body is not valid JSON. Skip applying extraBody to the request body.`);return}function r(e,t){let n=Object.assign({},e);for(let e in t)if(Object.prototype.hasOwnProperty.call(t,e)){let i=t[e],a=n[e];i&&typeof i==`object`&&!Array.isArray(i)&&a&&typeof a==`object`&&!Array.isArray(a)?n[e]=r(a,i):(a&&i&&typeof a!=typeof i&&console.warn(`includeExtraBodyToRequestInit:deepMerge: Type mismatch for key "${e}". Original type: ${typeof a}, New type: ${typeof i}. Overwriting.`),n[e]=i)}return n}let i=r(n,t);e.body=JSON.stringify(i)}
|
|
120
|
+
/**
|
|
121
|
+
* @license
|
|
122
|
+
* Copyright 2025 Google LLC
|
|
123
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
124
|
+
*/
|
|
125
|
+
function Es(e){for(let t of e)if(Os(t)||typeof t==`object`&&`inputSchema`in t)return!0;return!1}function Ds(e){e[bs]=((e[bs]??``)+` mcp_used/unknown`).trimStart()}function Os(e){return typeof e==`object`&&!!e&&e instanceof As}function ks(e){return G(this,arguments,function*(e,t=100){let n,r=0;for(;r<t;){let t=yield W(e.listTools({cursor:n}));for(let e of t.tools)yield yield W(e),r++;if(!t.nextCursor)break;n=t.nextCursor}})}var As=class e{constructor(e=[],t){this.mcpTools=[],this.functionNameToMcpClient={},this.mcpClients=e,this.config=t}static create(t,n){return new e(t,n)}async initialize(){var e,t,n,r;if(this.mcpTools.length>0)return;let i={},a=[];for(let l of this.mcpClients)try{for(var o=!0,s=(t=void 0,K(ks(l))),c;c=await s.next(),e=c.done,!e;o=!0){r=c.value,o=!1;let e=r;a.push(e);let t=e.name;if(i[t])throw Error(`Duplicate function name ${t} found in MCP tools. Please ensure function names are unique.`);i[t]=l}}catch(e){t={error:e}}finally{try{!o&&!e&&(n=s.return)&&await n.call(s)}finally{if(t)throw t.error}}this.mcpTools=a,this.functionNameToMcpClient=i}async tool(){return await this.initialize(),pn(this.mcpTools,this.config)}async callTool(e){await this.initialize();let t=[];for(let n of e)if(n.name in this.functionNameToMcpClient){let e=this.functionNameToMcpClient[n.name],r;this.config.timeout&&(r={timeout:this.config.timeout});let i=await e.callTool({name:n.name,arguments:n.args},void 0,r);t.push({functionResponse:{name:n.name,response:i.isError?{error:i}:i}})}return t}};
|
|
126
|
+
/**
|
|
127
|
+
* @license
|
|
128
|
+
* Copyright 2025 Google LLC
|
|
129
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
130
|
+
*/
|
|
131
|
+
async function js(e,t,n){let r=new It,i;i=n.data instanceof Blob?JSON.parse(await n.data.text()):JSON.parse(n.data),Object.assign(r,i),t(r)}var Ms=class{constructor(e,t,n){this.apiClient=e,this.auth=t,this.webSocketFactory=n}async connect(e){if(this.apiClient.isVertexAI())throw Error(`Live music is not supported for Vertex AI.`);console.warn(`Live music generation is experimental and may change in future versions.`);let t=this.apiClient.getWebsocketBaseUrl(),n=this.apiClient.getApiVersion(),r=Fs(this.apiClient.getDefaultHeaders()),i=`${t}/ws/google.ai.generativelanguage.${n}.GenerativeService.BidiGenerateMusic?key=${this.apiClient.getApiKey()}`,a=()=>{},o=new Promise(e=>{a=e}),s=e.callbacks,c=function(){a({})},l=this.apiClient,u={onopen:c,onmessage:e=>{js(l,s.onmessage,e)},onerror:s?.onerror??function(e){},onclose:s?.onclose??function(e){}},d=this.webSocketFactory.create(i,Ps(r),u);d.connect(),await o;let f={setup:{model:I(this.apiClient,e.model)}};return d.send(JSON.stringify(f)),new Ns(d,this.apiClient)}},Ns=class{constructor(e,t){this.conn=e,this.apiClient=t}async setWeightedPrompts(e){if(!e.weightedPrompts||Object.keys(e.weightedPrompts).length===0)throw Error(`Weighted prompts must be set and contain at least one entry.`);let t=Li(e);this.conn.send(JSON.stringify({clientContent:t}))}async setMusicGenerationConfig(e){e.musicGenerationConfig||={};let t=Ii(e);this.conn.send(JSON.stringify(t))}sendPlaybackControl(e){let t={playbackControl:e};this.conn.send(JSON.stringify(t))}play(){this.sendPlaybackControl(ct.PLAY)}pause(){this.sendPlaybackControl(ct.PAUSE)}stop(){this.sendPlaybackControl(ct.STOP)}resetContext(){this.sendPlaybackControl(ct.RESET_CONTEXT)}close(){this.conn.close()}};function Ps(e){let t={};return e.forEach((e,n)=>{t[n]=e}),t}function Fs(e){let t=new Headers;for(let[n,r]of Object.entries(e))t.append(n,r);return t}
|
|
132
|
+
/**
|
|
133
|
+
* @license
|
|
134
|
+
* Copyright 2025 Google LLC
|
|
135
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
136
|
+
*/
|
|
137
|
+
async function Is(e,t,n){let r=new Ft,i;i=n.data instanceof Blob?await n.data.text():n.data instanceof ArrayBuffer?new TextDecoder().decode(n.data):n.data;let a=JSON.parse(i);if(e.isVertexAI()){let e=Bi(a);Object.assign(r,e)}else Object.assign(r,a);t(r)}var Ls=class{constructor(e,t,n){this.apiClient=e,this.auth=t,this.webSocketFactory=n,this.music=new Ms(this.apiClient,this.auth,this.webSocketFactory)}async connect(e){if(e.config&&e.config.httpOptions)throw Error(`The Live module does not support httpOptions at request-level in LiveConnectConfig yet. Please use the client-level httpOptions configuration instead.`);let t=this.apiClient.getWebsocketBaseUrl(),n=this.apiClient.getApiVersion(),r,i=this.apiClient.getHeaders();e.config&&e.config.tools&&Es(e.config.tools)&&Ds(i);let a=Vs(i);if(this.apiClient.isVertexAI()){let e=this.apiClient.getProject(),i=this.apiClient.getLocation(),o=this.apiClient.getApiKey(),s=!!e&&!!i||!!o;this.apiClient.getCustomBaseUrl()&&!s?r=t:(r=`${t}/ws/google.cloud.aiplatform.${n}.LlmBidiService/BidiGenerateContent`,await this.auth.addAuthHeaders(a,r))}else{let e=this.apiClient.getApiKey(),i=`BidiGenerateContent`,a=`key`;e?.startsWith(`auth_tokens/`)&&(console.warn(`Warning: Ephemeral token support is experimental and may change in future versions.`),n!==`v1alpha`&&console.warn(`Warning: The SDK's ephemeral token support is in v1alpha only. Please use const ai = new GoogleGenAI({apiKey: token.name, httpOptions: { apiVersion: 'v1alpha' }}); before session connection.`),i=`BidiGenerateContentConstrained`,a=`access_token`),r=`${t}/ws/google.ai.generativelanguage.${n}.GenerativeService.${i}?${a}=${e}`}let o=()=>{},s=new Promise(e=>{o=e}),c=e.callbacks,l=function(){var e;(e=c?.onopen)==null||e.call(c),o({})},u=this.apiClient,d={onopen:l,onmessage:e=>{Is(u,c.onmessage,e)},onerror:c?.onerror??function(e){},onclose:c?.onclose??function(e){}},f=this.webSocketFactory.create(r,Bs(a),d);f.connect(),await s;let p=I(this.apiClient,e.model);if(this.apiClient.isVertexAI()&&p.startsWith(`publishers/`)){let e=this.apiClient.getProject(),t=this.apiClient.getLocation();e&&t&&(p=`projects/${e}/locations/${t}/`+p)}let m={};this.apiClient.isVertexAI()&&e.config?.responseModalities===void 0&&(e.config===void 0?e.config={responseModalities:[xe.AUDIO]}:e.config.responseModalities=[xe.AUDIO]),e.config?.generationConfig&&console.warn("Setting `LiveConnectConfig.generation_config` is deprecated, please set the fields on `LiveConnectConfig` directly. This will become an error in a future version (not before Q3 2025).");let h=e.config?.tools??[],g=[];for(let e of h)if(this.isCallableTool(e)){let t=e;g.push(await t.tool())}else g.push(e);g.length>0&&(e.config.tools=g);let _={model:p,config:e.config,callbacks:e.callbacks};return m=this.apiClient.isVertexAI()?Fi(this.apiClient,_):Pi(this.apiClient,_),delete m.config,f.send(JSON.stringify(m)),new zs(f,this.apiClient)}isCallableTool(e){return`callTool`in e&&typeof e.callTool==`function`}};const Rs={turnComplete:!0};var zs=class{constructor(e,t){this.conn=e,this.apiClient=t}tLiveClientContent(e,t){if(t.turns!==null&&t.turns!==void 0){let n=[];try{n=R(t.turns),e.isVertexAI()||(n=n.map(e=>ra(e)))}catch{throw Error(`Failed to parse client content "turns", type: '${typeof t.turns}'`)}return{clientContent:{turns:n,turnComplete:t.turnComplete}}}return{clientContent:{turnComplete:t.turnComplete}}}tLiveClienttToolResponse(e,t){let n=[];if(t.functionResponses==null||(n=Array.isArray(t.functionResponses)?t.functionResponses:[t.functionResponses],n.length===0))throw Error(`functionResponses is required.`);for(let t of n){if(typeof t!=`object`||!t||!(`name`in t)||!(`response`in t))throw Error(`Could not parse function response, type '${typeof t}'.`);if(!e.isVertexAI()&&!(`id`in t))throw Error("FunctionResponse request must have an `id` field from the response of a ToolCall.FunctionalCalls in Google AI.")}return{toolResponse:{functionResponses:n}}}sendClientContent(e){e=Object.assign(Object.assign({},Rs),e);let t=this.tLiveClientContent(this.apiClient,e);this.conn.send(JSON.stringify(t))}sendRealtimeInput(e){let t={};t=this.apiClient.isVertexAI()?{realtimeInput:zi(e)}:{realtimeInput:Ri(e)},this.conn.send(JSON.stringify(t))}sendToolResponse(e){if(e.functionResponses==null)throw Error(`Tool response parameters are required.`);let t=this.tLiveClienttToolResponse(this.apiClient,e);this.conn.send(JSON.stringify(t))}close(){this.conn.close()}};function Bs(e){let t={};return e.forEach((e,n)=>{t[n]=e}),t}function Vs(e){let t=new Headers;for(let[n,r]of Object.entries(e))t.append(n,r);return t}
|
|
138
|
+
/**
|
|
139
|
+
* @license
|
|
140
|
+
* Copyright 2025 Google LLC
|
|
141
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
142
|
+
*/
|
|
143
|
+
function Hs(e){if(e?.automaticFunctionCalling?.disable)return!0;let t=!1;for(let n of e?.tools??[])if(Us(n)){t=!0;break}if(!t)return!0;let n=e?.automaticFunctionCalling?.maximumRemoteCalls;return n&&(n<0||!Number.isInteger(n))||n==0?(console.warn(`Invalid maximumRemoteCalls value provided for automatic function calling. Disabled automatic function calling. Please provide a valid integer value greater than 0. maximumRemoteCalls provided:`,n),!0):!1}function Us(e){return`callTool`in e&&typeof e.callTool==`function`}function Ws(e){return(e.config?.tools)?.some(e=>Us(e))??!1}function Gs(e){let t=[];return e?.config?.tools&&e.config.tools.forEach((e,n)=>{if(Us(e))return;let r=e;r.functionDeclarations&&r.functionDeclarations.length>0&&t.push(n)}),t}function Ks(e){return!e?.automaticFunctionCalling?.ignoreCallHistory}
|
|
144
|
+
/**
|
|
145
|
+
* @license
|
|
146
|
+
* Copyright 2025 Google LLC
|
|
147
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
148
|
+
*/
|
|
149
|
+
var qs=class extends d{constructor(e){super(),this.apiClient=e,this.embedContent=async e=>{if(!this.apiClient.isVertexAI())return e.model.includes(`gemini-embedding-2`)&&(e.contents=R(e.contents)),await this.embedContentInternal(e);if(e.model.includes(`gemini`)&&e.model!==`gemini-embedding-001`||e.model.includes(`maas`)){let t=R(e.contents);if(t.length>1)throw Error(`The embedContent API for this model only supports one content at a time.`);let n=Object.assign(Object.assign({},e),{content:t[0],embeddingApiType:Le.EMBED_CONTENT});return await this.embedContentInternal(n)}else{let t=Object.assign(Object.assign({},e),{embeddingApiType:Le.PREDICT});return await this.embedContentInternal(t)}},this.generateContent=async e=>{let t=await this.processParamsMaybeAddMcpUsage(e);if(this.maybeMoveToResponseJsonSchem(e),!Ws(e)||Hs(e.config))return await this.generateContentInternal(t);let n=Gs(e);if(n.length>0){let e=n.map(e=>`tools[${e}]`).join(`, `);throw Error(`Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations is not yet supported. Incompatible tools found at ${e}.`)}let r,i,a=R(t.contents),o=t.config?.automaticFunctionCalling?.maximumRemoteCalls??10,s=0;for(;s<o&&(r=await this.generateContentInternal(t),!(!r.functionCalls||r.functionCalls.length===0));){let n=r.candidates[0].content,o=[];for(let t of e.config?.tools??[])if(Us(t)){let e=await t.callTool(r.functionCalls);o.push(...e)}s++,i={role:`user`,parts:o},t.contents=R(t.contents),t.contents.push(n),t.contents.push(i),Ks(t.config)&&(a.push(n),a.push(i))}return Ks(t.config)&&(r.automaticFunctionCallingHistory=a),r},this.generateContentStream=async e=>{if(this.maybeMoveToResponseJsonSchem(e),Hs(e.config)){let t=await this.processParamsMaybeAddMcpUsage(e);return await this.generateContentStreamInternal(t)}let t=Gs(e);if(t.length>0){let e=t.map(e=>`tools[${e}]`).join(`, `);throw Error(`Incompatible tools found at ${e}. Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations" is not yet supported.`)}let n=e?.config?.toolConfig?.functionCallingConfig?.streamFunctionCallArguments,r=e?.config?.automaticFunctionCalling?.disable;if(n&&!r)throw Error(`Running in streaming mode with 'streamFunctionCallArguments' enabled, this feature is not compatible with automatic function calling (AFC). Please set 'config.automaticFunctionCalling.disable' to true to disable AFC or leave 'config.toolConfig.functionCallingConfig.streamFunctionCallArguments' to be undefined or set to false to disable streaming function call arguments feature.`);return await this.processAfcStream(e)},this.generateImages=async e=>await this.generateImagesInternal(e).then(e=>{let t,n=[];if(e?.generatedImages)for(let r of e.generatedImages)r&&r?.safetyAttributes&&r?.safetyAttributes?.contentType===`Positive Prompt`?t=r?.safetyAttributes:n.push(r);let r;return r=t?{generatedImages:n,positivePromptSafetyAttributes:t,sdkHttpResponse:e.sdkHttpResponse}:{generatedImages:n,sdkHttpResponse:e.sdkHttpResponse},r}),this.list=async e=>{let t={config:Object.assign(Object.assign({},{queryBase:!0}),e?.config)};if(this.apiClient.isVertexAI()&&!t.config.queryBase){if(t.config?.filter)throw Error(`Filtering tuned models list for Gemini Enterprise Agent Platform (previously known as Vertex AI) is not currently supported`);t.config.filter=`labels.tune-type:*`}return new H(V.PAGED_ITEM_MODELS,e=>this.listInternal(e),await this.listInternal(t),t)},this.editImage=async e=>{let t={model:e.model,prompt:e.prompt,referenceImages:[],config:e.config};return e.referenceImages&&e.referenceImages&&(t.referenceImages=e.referenceImages.map(e=>e.toReferenceImageAPI())),await this.editImageInternal(t)},this.upscaleImage=async e=>{let t={numberOfImages:1,mode:`upscale`};e.config&&(t=Object.assign(Object.assign({},t),e.config));let n={model:e.model,image:e.image,upscaleFactor:e.upscaleFactor,config:t};return await this.upscaleImageInternal(n)},this.generateVideos=async e=>{if((e.prompt||e.image||e.video)&&e.source)throw Error(`Source and prompt/image/video are mutually exclusive. Please only use source.`);return this.apiClient.isVertexAI()||(e.video?.uri&&e.video?.videoBytes?e.video={uri:e.video.uri,mimeType:e.video.mimeType}:e.source?.video?.uri&&e.source?.video?.videoBytes&&(e.source.video={uri:e.source.video.uri,mimeType:e.source.video.mimeType})),await this.generateVideosInternal(e)}}maybeMoveToResponseJsonSchem(e){e.config&&e.config.responseSchema&&(e.config.responseJsonSchema||Object.keys(e.config.responseSchema).includes(`$schema`)&&(e.config.responseJsonSchema=e.config.responseSchema,delete e.config.responseSchema))}async processParamsMaybeAddMcpUsage(e){let t=e.config?.tools;if(!t)return e;let n=await Promise.all(t.map(async e=>Us(e)?await e.tool():e)),r={model:e.model,contents:e.contents,config:Object.assign(Object.assign({},e.config),{tools:n})};if(r.config.tools=n,e.config&&e.config.tools&&Es(e.config.tools)){let t=e.config.httpOptions?.headers??{},n=Object.assign({},t);Object.keys(n).length===0&&(n=this.apiClient.getDefaultHeaders()),Ds(n),r.config.httpOptions=Object.assign(Object.assign({},e.config.httpOptions),{headers:n})}return r}async initAfcToolsMap(e){let t=new Map;for(let n of e.config?.tools??[])if(Us(n)){let e=n,r=await e.tool();for(let n of r.functionDeclarations??[]){if(!n.name)throw Error(`Function declaration name is required.`);if(t.has(n.name))throw Error(`Duplicate tool declaration name: ${n.name}`);t.set(n.name,e)}}return t}async processAfcStream(e){let t=e.config?.automaticFunctionCalling?.maximumRemoteCalls??10,n=!1,r=0,i=await this.initAfcToolsMap(e);return(function(e,i,a){return G(this,arguments,function*(){for(var o,s,c,l;r<t;){n&&=(r++,!1);let p=yield W(e.processParamsMaybeAddMcpUsage(a)),m=yield W(e.generateContentStreamInternal(p)),h=[],g=[];try{for(var u=!0,d=(s=void 0,K(m)),f;f=yield W(d.next()),o=f.done,!o;u=!0){l=f.value,u=!1;let e=l;if(yield yield W(e),e.candidates&&e.candidates[0]?.content){g.push(e.candidates[0].content);for(let n of e.candidates[0].content.parts??[])if(r<t&&n.functionCall){if(!n.functionCall.name)throw Error(`Function call name was not returned by the model.`);if(i.has(n.functionCall.name)){let e=yield W(i.get(n.functionCall.name).callTool([n.functionCall]));h.push(...e)}else throw Error(`Automatic function calling was requested, but not all the tools the model used implement the CallableTool interface. Available tools: ${i.keys()}, mising tool: ${n.functionCall.name}`)}}}}catch(e){s={error:e}}finally{try{!u&&!o&&(c=d.return)&&(yield W(c.call(d)))}finally{if(s)throw s.error}}if(h.length>0){n=!0;let e=new ut;e.candidates=[{content:{role:`user`,parts:h}}],yield yield W(e);let t=[];t.push(...g),t.push({role:`user`,parts:h}),a.contents=R(a.contents).concat(t)}else break}})})(this,i,e)}async generateContentInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Na(this.apiClient,e);return n=f(`{model}:generateContent`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Fa(e),n=new ut;return Object.assign(n,t),n})}else{let i=Ma(this.apiClient,e);return n=f(`{model}:generateContent`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Pa(e),n=new ut;return Object.assign(n,t),n})}}async generateContentStreamInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Na(this.apiClient,e);return n=f(`{model}:streamGenerateContent?alt=sse`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.requestStream({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}),t.then(function(t){return G(this,arguments,function*(){var n,r,i,a;try{for(var o=!0,s=K(t),c;c=yield W(s.next()),n=c.done,!n;o=!0){a=c.value,o=!1;let t=a,n=Fa(yield W(t.json()),e);n.sdkHttpResponse={headers:t.headers};let r=new ut;Object.assign(r,n),yield yield W(r)}}catch(e){r={error:e}}finally{try{!o&&!n&&(i=s.return)&&(yield W(i.call(s)))}finally{if(r)throw r.error}}})})}else{let i=Ma(this.apiClient,e);return n=f(`{model}:streamGenerateContent?alt=sse`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.requestStream({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}),t.then(function(t){return G(this,arguments,function*(){var n,r,i,a;try{for(var o=!0,s=K(t),c;c=yield W(s.next()),n=c.done,!n;o=!0){a=c.value,o=!1;let t=a,n=Pa(yield W(t.json()),e);n.sdkHttpResponse={headers:t.headers};let r=new ut;Object.assign(r,n),yield yield W(r)}}catch(e){r={error:e}}finally{try{!o&&!n&&(i=s.return)&&(yield W(i.call(s)))}finally{if(r)throw r.error}}})})}}async embedContentInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Sa(this.apiClient,e,e);return n=f(yn(e.model)?`{model}:embedContent`:`{model}:predict`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(t=>{let n=wa(t,e),r=new dt;return Object.assign(r,n),r})}else{let i=xa(this.apiClient,e);return n=f(`{model}:batchEmbedContents`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Ca(e),n=new dt;return Object.assign(n,t),n})}}async generateImagesInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=za(this.apiClient,e);return n=f(`{model}:predict`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Va(e),n=new ft;return Object.assign(n,t),n})}else{let i=Ra(this.apiClient,e);return n=f(`{model}:predict`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Ba(e),n=new ft;return Object.assign(n,t),n})}}async editImageInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=_a(this.apiClient,e);return n=f(`{model}:predict`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=va(e),n=new pt;return Object.assign(n,t),n})}else throw Error(`This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).`)}async upscaleImageInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Xo(this.apiClient,e);return n=f(`{model}:predict`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Zo(e),n=new mt;return Object.assign(n,t),n})}else throw Error(`This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).`)}async recontextImage(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Do(this.apiClient,e);return n=f(`{model}:predict`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>{let t=Oo(e),n=new ht;return Object.assign(n,t),n})}else throw Error(`This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).`)}async segmentImage(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Io(this.apiClient,e);return n=f(`{model}:predict`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>{let t=Lo(e),n=new gt;return Object.assign(n,t),n})}else throw Error(`This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).`)}async get(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=ao(this.apiClient,e);return n=f(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>So(e))}else{let i=io(this.apiClient,e);return n=f(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>xo(e))}}async listInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=_o(this.apiClient,e);return n=f(`{models_url}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=yo(e),n=new _t;return Object.assign(n,t),n})}else{let i=go(this.apiClient,e);return n=f(`{models_url}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=vo(e),n=new _t;return Object.assign(n,t),n})}}async update(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Jo(this.apiClient,e);return n=f(`{model}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`PATCH`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>So(e))}else{let i=qo(this.apiClient,e);return n=f(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`PATCH`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>xo(e))}}async delete(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=pa(this.apiClient,e);return n=f(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`DELETE`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=ha(e),n=new vt;return Object.assign(n,t),n})}else{let i=fa(this.apiClient,e);return n=f(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`DELETE`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=ma(e),n=new vt;return Object.assign(n,t),n})}}async countTokens(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=la(this.apiClient,e);return n=f(`{model}:countTokens`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=da(e),n=new yt;return Object.assign(n,t),n})}else{let i=ca(this.apiClient,e);return n=f(`{model}:countTokens`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=ua(e),n=new yt;return Object.assign(n,t),n})}}async computeTokens(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=$i(this.apiClient,e);return n=f(`{model}:computeTokens`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=ea(e),n=new bt;return Object.assign(n,t),n})}else throw Error(`This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).`)}async generateVideosInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=qa(this.apiClient,e);return n=f(`{model}:predictLongRunning`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>{let t=Ga(e),n=new xt;return Object.assign(n,t),n})}else{let i=Ka(this.apiClient,e);return n=f(`{model}:predictLongRunning`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>{let t=Wa(e),n=new xt;return Object.assign(n,t),n})}}},Js=class extends d{constructor(e){
|
|
150
|
+
/**
|
|
151
|
+
* @license
|
|
152
|
+
* Copyright 2025 Google LLC
|
|
153
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
154
|
+
*/
|
|
155
|
+
super(),this.apiClient=e}async getVideosOperation(e){let t=e.operation,n=e.config;if(t.name===void 0||t.name===``)throw Error(`Operation name is required.`);if(this.apiClient.isVertexAI()){let e=t.name.split(`/operations/`)[0],r;n&&`httpOptions`in n&&(r=n.httpOptions);let i=await this.fetchPredictVideosOperationInternal({operationName:t.name,resourceName:e,config:{httpOptions:r}});return t._fromAPIResponse({apiResponse:i,_isVertexAI:!0})}else{let e=await this.getVideosOperationInternal({operationName:t.name,config:n});return t._fromAPIResponse({apiResponse:e,_isVertexAI:!1})}}async get(e){let t=e.operation,n=e.config;if(t.name===void 0||t.name===``)throw Error(`Operation name is required.`);if(this.apiClient.isVertexAI()){let e=t.name.split(`/operations/`)[0],r;n&&`httpOptions`in n&&(r=n.httpOptions);let i=await this.fetchPredictVideosOperationInternal({operationName:t.name,resourceName:e,config:{httpOptions:r}});return t._fromAPIResponse({apiResponse:i,_isVertexAI:!0})}else{let e=await this.getVideosOperationInternal({operationName:t.name,config:n});return t._fromAPIResponse({apiResponse:e,_isVertexAI:!1})}}async getVideosOperationInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=E(e);return n=f(`{operationName}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t}else{let i=T(e);return n=f(`{operationName}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t}}async fetchPredictVideosOperationInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=v(e);return n=f(`{resourceName}:fetchPredictOperation`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t}else throw Error(`This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).`)}};
|
|
156
|
+
/**
|
|
157
|
+
* @license
|
|
158
|
+
* Copyright 2025 Google LLC
|
|
159
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
160
|
+
*/
|
|
161
|
+
function Ys(e){let t={};if(m(e,[`languageCodes`])!==void 0)throw Error(`languageCodes parameter is not supported in Gemini API.`);return t}function Xs(e){let t={},n=m(e,[`apiKey`]);if(n!=null&&p(t,[`apiKey`],n),m(e,[`apiKeyConfig`])!==void 0)throw Error(`apiKeyConfig parameter is not supported in Gemini API.`);if(m(e,[`authType`])!==void 0)throw Error(`authType parameter is not supported in Gemini API.`);if(m(e,[`googleServiceAccountConfig`])!==void 0)throw Error(`googleServiceAccountConfig parameter is not supported in Gemini API.`);if(m(e,[`httpBasicAuthConfig`])!==void 0)throw Error(`httpBasicAuthConfig parameter is not supported in Gemini API.`);if(m(e,[`oauthConfig`])!==void 0)throw Error(`oauthConfig parameter is not supported in Gemini API.`);if(m(e,[`oidcConfig`])!==void 0)throw Error(`oidcConfig parameter is not supported in Gemini API.`);return t}function Zs(e){let t={},n=m(e,[`data`]);if(n!=null&&p(t,[`data`],n),m(e,[`displayName`])!==void 0)throw Error(`displayName parameter is not supported in Gemini API.`);let r=m(e,[`mimeType`]);return r!=null&&p(t,[`mimeType`],r),t}function Qs(e){let t={},n=m(e,[`parts`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>sc(e))),p(t,[`parts`],e)}let r=m(e,[`role`]);return r!=null&&p(t,[`role`],r),t}function $s(e,t,n){let r={},i=m(t,[`expireTime`]);n!==void 0&&i!=null&&p(n,[`expireTime`],i);let a=m(t,[`newSessionExpireTime`]);n!==void 0&&a!=null&&p(n,[`newSessionExpireTime`],a);let o=m(t,[`uses`]);n!==void 0&&o!=null&&p(n,[`uses`],o);let s=m(t,[`liveConnectConstraints`]);n!==void 0&&s!=null&&p(n,[`bidiGenerateContentSetup`],oc(e,s));let c=m(t,[`lockAdditionalFields`]);return n!==void 0&&c!=null&&p(n,[`fieldMask`],c),r}function ec(e,t){let n={},r=m(t,[`config`]);return r!=null&&p(n,[`config`],$s(e,r,n)),n}function tc(e){let t={};if(m(e,[`displayName`])!==void 0)throw Error(`displayName parameter is not supported in Gemini API.`);let n=m(e,[`fileUri`]);n!=null&&p(t,[`fileUri`],n);let r=m(e,[`mimeType`]);return r!=null&&p(t,[`mimeType`],r),t}function nc(e){let t={},n=m(e,[`id`]);n!=null&&p(t,[`id`],n);let r=m(e,[`args`]);r!=null&&p(t,[`args`],r);let i=m(e,[`name`]);if(i!=null&&p(t,[`name`],i),m(e,[`partialArgs`])!==void 0)throw Error(`partialArgs parameter is not supported in Gemini API.`);if(m(e,[`willContinue`])!==void 0)throw Error(`willContinue parameter is not supported in Gemini API.`);return t}function rc(e){let t={},n=m(e,[`authConfig`]);n!=null&&p(t,[`authConfig`],Xs(n));let r=m(e,[`enableWidget`]);return r!=null&&p(t,[`enableWidget`],r),t}function ic(e){let t={},n=m(e,[`searchTypes`]);if(n!=null&&p(t,[`searchTypes`],n),m(e,[`blockingConfidence`])!==void 0)throw Error(`blockingConfidence parameter is not supported in Gemini API.`);if(m(e,[`excludeDomains`])!==void 0)throw Error(`excludeDomains parameter is not supported in Gemini API.`);let r=m(e,[`timeRangeFilter`]);return r!=null&&p(t,[`timeRangeFilter`],r),t}function ac(e,t){let n={},r=m(e,[`generationConfig`]);t!==void 0&&r!=null&&p(t,[`setup`,`generationConfig`],r);let i=m(e,[`responseModalities`]);t!==void 0&&i!=null&&p(t,[`setup`,`generationConfig`,`responseModalities`],i);let a=m(e,[`temperature`]);t!==void 0&&a!=null&&p(t,[`setup`,`generationConfig`,`temperature`],a);let o=m(e,[`topP`]);t!==void 0&&o!=null&&p(t,[`setup`,`generationConfig`,`topP`],o);let s=m(e,[`topK`]);t!==void 0&&s!=null&&p(t,[`setup`,`generationConfig`,`topK`],s);let c=m(e,[`maxOutputTokens`]);t!==void 0&&c!=null&&p(t,[`setup`,`generationConfig`,`maxOutputTokens`],c);let l=m(e,[`mediaResolution`]);t!==void 0&&l!=null&&p(t,[`setup`,`generationConfig`,`mediaResolution`],l);let u=m(e,[`seed`]);t!==void 0&&u!=null&&p(t,[`setup`,`generationConfig`,`seed`],u);let d=m(e,[`speechConfig`]);t!==void 0&&d!=null&&p(t,[`setup`,`generationConfig`,`speechConfig`],$t(d));let f=m(e,[`thinkingConfig`]);t!==void 0&&f!=null&&p(t,[`setup`,`generationConfig`,`thinkingConfig`],f);let h=m(e,[`enableAffectiveDialog`]);t!==void 0&&h!=null&&p(t,[`setup`,`generationConfig`,`enableAffectiveDialog`],h);let g=m(e,[`systemInstruction`]);t!==void 0&&g!=null&&p(t,[`setup`,`systemInstruction`],Qs(L(g)));let _=m(e,[`tools`]);if(t!==void 0&&_!=null){let e=tn(_);Array.isArray(e)&&(e=e.map(e=>uc(en(e)))),p(t,[`setup`,`tools`],e)}let v=m(e,[`sessionResumption`]);t!==void 0&&v!=null&&p(t,[`setup`,`sessionResumption`],lc(v));let y=m(e,[`inputAudioTranscription`]);t!==void 0&&y!=null&&p(t,[`setup`,`inputAudioTranscription`],Ys(y));let b=m(e,[`outputAudioTranscription`]);t!==void 0&&b!=null&&p(t,[`setup`,`outputAudioTranscription`],Ys(b));let x=m(e,[`realtimeInputConfig`]);t!==void 0&&x!=null&&p(t,[`setup`,`realtimeInputConfig`],x);let S=m(e,[`contextWindowCompression`]);t!==void 0&&S!=null&&p(t,[`setup`,`contextWindowCompression`],S);let C=m(e,[`proactivity`]);if(t!==void 0&&C!=null&&p(t,[`setup`,`proactivity`],C),m(e,[`explicitVadSignal`])!==void 0)throw Error(`explicitVadSignal parameter is not supported in Gemini API.`);let w=m(e,[`avatarConfig`]);t!==void 0&&w!=null&&p(t,[`setup`,`avatarConfig`],w);let T=m(e,[`safetySettings`]);if(t!==void 0&&T!=null){let e=T;Array.isArray(e)&&(e=e.map(e=>cc(e))),p(t,[`setup`,`safetySettings`],e)}return n}function oc(e,t){let n={},r=m(t,[`model`]);r!=null&&p(n,[`setup`,`model`],I(e,r));let i=m(t,[`config`]);return i!=null&&p(n,[`config`],ac(i,n)),n}function sc(e){let t={},n=m(e,[`mediaResolution`]);n!=null&&p(t,[`mediaResolution`],n);let r=m(e,[`codeExecutionResult`]);r!=null&&p(t,[`codeExecutionResult`],r);let i=m(e,[`executableCode`]);i!=null&&p(t,[`executableCode`],i);let a=m(e,[`fileData`]);a!=null&&p(t,[`fileData`],tc(a));let o=m(e,[`functionCall`]);o!=null&&p(t,[`functionCall`],nc(o));let s=m(e,[`functionResponse`]);s!=null&&p(t,[`functionResponse`],s);let c=m(e,[`inlineData`]);c!=null&&p(t,[`inlineData`],Zs(c));let l=m(e,[`text`]);l!=null&&p(t,[`text`],l);let u=m(e,[`thought`]);u!=null&&p(t,[`thought`],u);let d=m(e,[`thoughtSignature`]);d!=null&&p(t,[`thoughtSignature`],d);let f=m(e,[`videoMetadata`]);f!=null&&p(t,[`videoMetadata`],f);let h=m(e,[`toolCall`]);h!=null&&p(t,[`toolCall`],h);let g=m(e,[`toolResponse`]);g!=null&&p(t,[`toolResponse`],g);let _=m(e,[`partMetadata`]);return _!=null&&p(t,[`partMetadata`],_),t}function cc(e){let t={},n=m(e,[`category`]);if(n!=null&&p(t,[`category`],n),m(e,[`method`])!==void 0)throw Error(`method parameter is not supported in Gemini API.`);let r=m(e,[`threshold`]);return r!=null&&p(t,[`threshold`],r),t}function lc(e){let t={},n=m(e,[`handle`]);if(n!=null&&p(t,[`handle`],n),m(e,[`transparent`])!==void 0)throw Error(`transparent parameter is not supported in Gemini API.`);return t}function uc(e){let t={};if(m(e,[`retrieval`])!==void 0)throw Error(`retrieval parameter is not supported in Gemini API.`);let n=m(e,[`computerUse`]);n!=null&&p(t,[`computerUse`],n);let r=m(e,[`fileSearch`]);r!=null&&p(t,[`fileSearch`],r);let i=m(e,[`googleSearch`]);i!=null&&p(t,[`googleSearch`],ic(i));let a=m(e,[`googleMaps`]);a!=null&&p(t,[`googleMaps`],rc(a));let o=m(e,[`codeExecution`]);if(o!=null&&p(t,[`codeExecution`],o),m(e,[`enterpriseWebSearch`])!==void 0)throw Error(`enterpriseWebSearch parameter is not supported in Gemini API.`);let s=m(e,[`functionDeclarations`]);if(s!=null){let e=s;Array.isArray(e)&&(e=e.map(e=>e)),p(t,[`functionDeclarations`],e)}let c=m(e,[`googleSearchRetrieval`]);if(c!=null&&p(t,[`googleSearchRetrieval`],c),m(e,[`parallelAiSearch`])!==void 0)throw Error(`parallelAiSearch parameter is not supported in Gemini API.`);let l=m(e,[`urlContext`]);l!=null&&p(t,[`urlContext`],l);let u=m(e,[`mcpServers`]);if(u!=null){let e=u;Array.isArray(e)&&(e=e.map(e=>e)),p(t,[`mcpServers`],e)}return t}
|
|
162
|
+
/**
|
|
163
|
+
* @license
|
|
164
|
+
* Copyright 2025 Google LLC
|
|
165
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
166
|
+
*/
|
|
167
|
+
function dc(e){let t=[];for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)){let r=e[n];if(typeof r==`object`&&r&&Object.keys(r).length>0){let e=Object.keys(r).map(e=>`${n}.${e}`);t.push(...e)}else t.push(n)}return t.join(`,`)}function fc(e,t){let n=null,r=e.bidiGenerateContentSetup;if(typeof r==`object`&&r&&`setup`in r){let t=r.setup;typeof t==`object`&&t?(e.bidiGenerateContentSetup=t,n=t):delete e.bidiGenerateContentSetup}else r!==void 0&&delete e.bidiGenerateContentSetup;let i=e.fieldMask;if(n){let r=dc(n);if(Array.isArray(t?.lockAdditionalFields)&&t?.lockAdditionalFields.length===0)r?e.fieldMask=r:delete e.fieldMask;else if(t?.lockAdditionalFields&&t.lockAdditionalFields.length>0&&i!==null&&Array.isArray(i)&&i.length>0){let t=[`temperature`,`topK`,`topP`,`maxOutputTokens`,`responseModalities`,`seed`,`speechConfig`],n=[];i.length>0&&(n=i.map(e=>t.includes(e)?`generationConfig.${e}`:e));let a=[];r&&a.push(r),n.length>0&&a.push(...n),a.length>0?e.fieldMask=a.join(`,`):delete e.fieldMask}else delete e.fieldMask}else i!==null&&Array.isArray(i)&&i.length>0?e.fieldMask=i.join(`,`):delete e.fieldMask;return e}var pc=class extends d{constructor(e){super(),this.apiClient=e}async create(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`The client.tokens.create method is only supported by the Gemini Developer API.`);{let i=ec(this.apiClient,e);n=f(`auth_tokens`,i._url),r=i._query,delete i.config,delete i._url,delete i._query;let a=fc(i,e.config);return t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(a),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>e)}}};
|
|
168
|
+
/**
|
|
169
|
+
* @license
|
|
170
|
+
* Copyright 2025 Google LLC
|
|
171
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
172
|
+
*/
|
|
173
|
+
function mc(e,t){let n={},r=m(e,[`force`]);return t!==void 0&&r!=null&&p(t,[`_query`,`force`],r),n}function hc(e){let t={},n=m(e,[`name`]);n!=null&&p(t,[`_url`,`name`],n);let r=m(e,[`config`]);return r!=null&&mc(r,t),t}function gc(e){let t={},n=m(e,[`name`]);return n!=null&&p(t,[`_url`,`name`],n),t}function _c(e,t){let n={},r=m(e,[`pageSize`]);t!==void 0&&r!=null&&p(t,[`_query`,`pageSize`],r);let i=m(e,[`pageToken`]);return t!==void 0&&i!=null&&p(t,[`_query`,`pageToken`],i),n}function vc(e){let t={},n=m(e,[`parent`]);n!=null&&p(t,[`_url`,`parent`],n);let r=m(e,[`config`]);return r!=null&&_c(r,t),t}function yc(e){let t={},n=m(e,[`sdkHttpResponse`]);n!=null&&p(t,[`sdkHttpResponse`],n);let r=m(e,[`nextPageToken`]);r!=null&&p(t,[`nextPageToken`],r);let i=m(e,[`documents`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),p(t,[`documents`],e)}return t}
|
|
174
|
+
/**
|
|
175
|
+
* @license
|
|
176
|
+
* Copyright 2025 Google LLC
|
|
177
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
178
|
+
*/
|
|
179
|
+
var bc=class extends d{constructor(e){super(),this.apiClient=e,this.list=async e=>new H(V.PAGED_ITEM_DOCUMENTS,t=>this.listInternal({parent:e.parent,config:t.config}),await this.listInternal(e),e)}async get(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=gc(e);return n=f(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>e)}}async delete(e){let t=``,n={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let r=hc(e);t=f(`{name}`,r._url),n=r._query,delete r._url,delete r._query,await this.apiClient.request({path:t,queryParams:n,body:JSON.stringify(r),httpMethod:`DELETE`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal})}}async listInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=vc(e);return n=f(`{parent}/documents`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>{let t=yc(e),n=new Et;return Object.assign(n,t),n})}}},xc=class extends d{constructor(e,t=new bc(e)){
|
|
180
|
+
/**
|
|
181
|
+
* @license
|
|
182
|
+
* Copyright 2025 Google LLC
|
|
183
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
184
|
+
*/
|
|
185
|
+
super(),this.apiClient=e,this.documents=t,this.list=async(e={})=>new H(V.PAGED_ITEM_FILE_SEARCH_STORES,e=>this.listInternal(e),await this.listInternal(e),e)}async uploadToFileSearchStore(e){if(this.apiClient.isVertexAI())throw Error(`Gemini Enterprise Agent Platform (previously known as Vertex AI) does not support uploading files to a file search store.`);return this.apiClient.uploadFileToFileSearchStore(e.fileSearchStoreName,e.file,e.config)}async downloadMedia(e,t){if(this.apiClient.isVertexAI())throw Error(`This method is only supported in the Gemini Developer client.`);let n=new URL(e,`http://dummy.com`),r=n.pathname;if(r.startsWith(`/`)&&(r=r.slice(1)),!r.includes(`/media/`))throw Error(`Invalid uri format: ${e}. Expected to contain /media/`);let i={};n.searchParams.forEach((e,t)=>{i[t]=e}),i.alt=`media`;let a=Object.assign({},t?.httpOptions),o=await this.apiClient.request({path:r,httpMethod:`GET`,queryParams:i,httpOptions:a});if(o instanceof lt){let e=await o.responseInternal.arrayBuffer();return new Uint8Array(e)}else throw Error(`Unexpected response type from downloadMedia`)}async create(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=os(this.apiClient,e);return n=f(`fileSearchStores`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>e)}}async get(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=ls(e);return n=f(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>e)}}async delete(e){let t=``,n={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let r=cs(e);t=f(`{name}`,r._url),n=r._query,delete r._url,delete r._query,await this.apiClient.request({path:t,queryParams:n,body:JSON.stringify(r),httpMethod:`DELETE`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal})}}async listInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=hs(e);return n=f(`fileSearchStores`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>{let t=gs(e),n=new Dt;return Object.assign(n,t),n})}}async uploadToFileSearchStoreInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=vs(e);return n=f(`upload/v1beta/{file_search_store_name}:uploadToFileSearchStore`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>{let t=ys(e),n=new Ot;return Object.assign(n,t),n})}}async importFile(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=fs(e);return n=f(`{file_search_store_name}:importFile`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>{let t=ds(e),n=new kt;return Object.assign(n,t),n})}}};
|
|
186
|
+
/**
|
|
187
|
+
* @license
|
|
188
|
+
* Copyright 2025 Google LLC
|
|
189
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
190
|
+
*/
|
|
191
|
+
let Sc=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return Sc=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,e=>(e^n()&15>>e/4).toString(16))};const Cc=()=>Sc();
|
|
192
|
+
/**
|
|
193
|
+
* @license
|
|
194
|
+
* Copyright 2025 Google LLC
|
|
195
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
196
|
+
*/
|
|
197
|
+
function wc(e){return typeof e==`object`&&!!e&&(`name`in e&&e.name===`AbortError`||`message`in e&&String(e.message).includes(`FetchRequestCanceledException`))}const Tc=e=>{if(e instanceof Error)return e;if(typeof e==`object`&&e){try{if(Object.prototype.toString.call(e)===`[object Error]`){let t=Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return Error(JSON.stringify(e))}catch{}}return Error(e)};
|
|
198
|
+
/**
|
|
199
|
+
* @license
|
|
200
|
+
* Copyright 2025 Google LLC
|
|
201
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
202
|
+
*/
|
|
203
|
+
var J=class extends Error{},Y=class e extends J{constructor(t,n,r,i){super(`${e.makeMessage(t,n,r)}`),this.status=t,this.headers=i,this.error=n}static makeMessage(e,t,n){let r=t?.message?typeof t.message==`string`?t.message:JSON.stringify(t.message):t?JSON.stringify(t):n;return e&&r?`${e} ${r}`:e?`${e} status code (no body)`:r||`(no status code or body)`}static generate(t,n,r,i){if(!t||!i)return new Dc({message:r,cause:Tc(n)});let a=n;return t===400?new kc(t,a,r,i):t===401?new Ac(t,a,r,i):t===403?new jc(t,a,r,i):t===404?new Mc(t,a,r,i):t===409?new Nc(t,a,r,i):t===422?new Pc(t,a,r,i):t===429?new Fc(t,a,r,i):t>=500?new Ic(t,a,r,i):new e(t,a,r,i)}},Ec=class extends Y{constructor({message:e}={}){super(void 0,void 0,e||`Request was aborted.`,void 0)}},Dc=class extends Y{constructor({message:e,cause:t}){super(void 0,void 0,e||`Connection error.`,void 0),t&&(this.cause=t)}},Oc=class extends Dc{constructor({message:e}={}){super({message:e??`Request timed out.`})}},kc=class extends Y{},Ac=class extends Y{},jc=class extends Y{},Mc=class extends Y{},Nc=class extends Y{},Pc=class extends Y{},Fc=class extends Y{},Ic=class extends Y{};
|
|
204
|
+
/**
|
|
205
|
+
* @license
|
|
206
|
+
* Copyright 2025 Google LLC
|
|
207
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
208
|
+
*/
|
|
209
|
+
const Lc=/^[a-z][a-z0-9+.-]*:/i,Rc=e=>Lc.test(e);let zc=e=>(zc=Array.isArray,zc(e));const Bc=zc;function Vc(e){if(!e)return!0;for(let t in e)return!1;return!0}function Hc(e,t){return Object.prototype.hasOwnProperty.call(e,t)}const Uc=(e,t)=>{if(typeof t!=`number`||!Number.isInteger(t))throw new J(`${e} must be an integer`);if(t<0)throw new J(`${e} must be a positive integer`);return t},Wc=e=>{try{return JSON.parse(e)}catch{return}},Gc=e=>new Promise(t=>setTimeout(t,e))
|
|
210
|
+
/**
|
|
211
|
+
* @license
|
|
212
|
+
* Copyright 2025 Google LLC
|
|
213
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
214
|
+
*/
|
|
215
|
+
;
|
|
216
|
+
/**
|
|
217
|
+
* @license
|
|
218
|
+
* Copyright 2025 Google LLC
|
|
219
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
220
|
+
*/
|
|
221
|
+
function Kc(){if(typeof fetch<`u`)return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new GeminiNextGenAPIClient({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function qc(...e){let t=globalThis.ReadableStream;if(t===void 0)throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function Jc(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return qc({start(){},async pull(e){let{done:n,value:r}=await t.next();n?e.close():e.enqueue(r)},async cancel(){await t.return?.call(t)}})}function Yc(e){if(e[Symbol.asyncIterator])return e;let t=e.getReader();return{async next(){try{let e=await t.read();return e?.done&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){let e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function Xc(e){var t;if(typeof e!=`object`||!e)return;if(e[Symbol.asyncIterator]){await(t=e[Symbol.asyncIterator]()).return?.call(t);return}let n=e.getReader(),r=n.cancel();n.releaseLock(),await r}
|
|
222
|
+
/**
|
|
223
|
+
* @license
|
|
224
|
+
* Copyright 2025 Google LLC
|
|
225
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
226
|
+
*/
|
|
227
|
+
const Zc=({headers:e,body:t})=>({bodyHeaders:{"content-type":`application/json`},body:JSON.stringify(t)});
|
|
228
|
+
/**
|
|
229
|
+
* @license
|
|
230
|
+
* Copyright 2025 Google LLC
|
|
231
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
232
|
+
*/
|
|
233
|
+
function Qc(e){return Object.entries(e).filter(([e,t])=>t!==void 0).map(([e,t])=>{if(typeof t==`string`||typeof t==`number`||typeof t==`boolean`)return`${encodeURIComponent(e)}=${encodeURIComponent(t)}`;if(t===null)return`${encodeURIComponent(e)}=`;throw new J(`Cannot stringify type ${typeof t}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join(`&`)}
|
|
234
|
+
/**
|
|
235
|
+
* @license
|
|
236
|
+
* Copyright 2025 Google LLC
|
|
237
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
238
|
+
*/
|
|
239
|
+
const $c=()=>{
|
|
240
|
+
/**
|
|
241
|
+
* @license
|
|
242
|
+
* Copyright 2025 Google LLC
|
|
243
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
244
|
+
*/
|
|
245
|
+
if(typeof File>`u`){let{process:e}=globalThis,t=typeof e?.versions?.node==`string`&&parseInt(e.versions.node.split(`.`))<20;throw Error("`File` is not defined as a global, which is required for file uploads."+(t?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":``))}};function el(e,t,n){return $c(),new File(e,t??`unknown_file`,n)}function tl(e){return(typeof e==`object`&&!!e&&(`name`in e&&e.name&&String(e.name)||`url`in e&&e.url&&String(e.url)||`filename`in e&&e.filename&&String(e.filename)||`path`in e&&e.path&&String(e.path))||``).split(/[\\/]/).pop()||void 0}const nl=e=>typeof e==`object`&&!!e&&typeof e[Symbol.asyncIterator]==`function`,rl=e=>typeof e==`object`&&!!e&&typeof e.size==`number`&&typeof e.type==`string`&&typeof e.text==`function`&&typeof e.slice==`function`&&typeof e.arrayBuffer==`function`,il=e=>typeof e==`object`&&!!e&&typeof e.name==`string`&&typeof e.lastModified==`number`&&rl(e),al=e=>typeof e==`object`&&!!e&&typeof e.url==`string`&&typeof e.blob==`function`
|
|
246
|
+
/**
|
|
247
|
+
* @license
|
|
248
|
+
* Copyright 2025 Google LLC
|
|
249
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
250
|
+
*/
|
|
251
|
+
;async function ol(e,t,n){if($c(),e=await e,il(e))return e instanceof File?e:el([await e.arrayBuffer()],e.name);if(al(e)){let r=await e.blob();return t||=new URL(e.url).pathname.split(/[\\/]/).pop(),el(await sl(r),t,n)}let r=await sl(e);if(t||=tl(e),!n?.type){let e=r.find(e=>typeof e==`object`&&`type`in e&&e.type);typeof e==`string`&&(n=Object.assign(Object.assign({},n),{type:e}))}return el(r,t,n)}async function sl(e){var t,n,r,i;let a=[];if(typeof e==`string`||ArrayBuffer.isView(e)||e instanceof ArrayBuffer)a.push(e);else if(rl(e))a.push(e instanceof Blob?e:await e.arrayBuffer());else if(nl(e))try{for(var o=!0,s=K(e),c;c=await s.next(),t=c.done,!t;o=!0){i=c.value,o=!1;let e=i;a.push(...await sl(e))}}catch(e){n={error:e}}finally{try{!o&&!t&&(r=s.return)&&await r.call(s)}finally{if(n)throw n.error}}else{let t=e?.constructor?.name;throw Error(`Unexpected data type: ${typeof e}${t?`; constructor: ${t}`:``}${cl(e)}`)}return a}function cl(e){return typeof e!=`object`||!e?``:`; props: [${Object.getOwnPropertyNames(e).map(e=>`"${e}"`).join(`, `)}]`}
|
|
252
|
+
/**
|
|
253
|
+
* @license
|
|
254
|
+
* Copyright 2025 Google LLC
|
|
255
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
256
|
+
*/
|
|
257
|
+
var ll=class{constructor(e){this._client=e}};ll._key=[];
|
|
258
|
+
/**
|
|
259
|
+
* @license
|
|
260
|
+
* Copyright 2025 Google LLC
|
|
261
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
262
|
+
*/
|
|
263
|
+
function ul(e){return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}const dl=Object.freeze(Object.create(null)),X=((e=ul)=>(function(t,...n){if(t.length===1)return t[0];let r=!1,i=[],a=t.reduce((t,a,o)=>{/[?#]/.test(a)&&(r=!0);let s=n[o],c=(r?encodeURIComponent:e)(``+s);return o!==n.length&&(s==null||typeof s==`object`&&s.toString===Object.getPrototypeOf(Object.getPrototypeOf(s.hasOwnProperty??dl)??dl)?.toString)&&(c=s+``,i.push({start:t.length+a.length,length:c.length,error:`Value of type ${Object.prototype.toString.call(s).slice(8,-1)} is not a valid path parameter`})),t+a+(o===n.length?``:c)},``),o=a.split(/[?#]/,1)[0],s=/(^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi,c;for(;(c=s.exec(o))!==null;){let e=c[0].startsWith(`/`),t=+!!e,n=e?c[0].slice(1):c[0];i.push({start:c.index+t,length:n.length,error:`Value "${n}" can\'t be safely passed as a path parameter`})}if(i.sort((e,t)=>e.start-t.start),i.length>0){let e=0,t=i.reduce((t,n)=>{let r=` `.repeat(n.start-e),i=`^`.repeat(n.length);return e=n.start+n.length,t+r+i},``);throw new J(`Path parameters result in path with invalid segments:\n${i.map(e=>e.error).join(`
|
|
264
|
+
`)}\n${a}\n${t}`)}return a}))(ul);
|
|
265
|
+
/**
|
|
266
|
+
* @license
|
|
267
|
+
* Copyright 2025 Google LLC
|
|
268
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
269
|
+
*/
|
|
270
|
+
var fl=class extends ll{create(e,t){let{api_version:n=this._client.apiVersion}=e,r=U(e,[`api_version`]);if(`model`in r&&`agent_config`in r)throw new J("Invalid request: specified `model` and `agent_config`. If specifying `model`, use `generation_config`.");if(`agent`in r&&`generation_config`in r)throw new J("Invalid request: specified `agent` and `generation_config`. If specifying `agent`, use `agent_config`.");return this._client.post(X`/${n}/interactions`,Object.assign(Object.assign({body:r},t),{stream:e.stream??!1}))}delete(e,t={},n){let{api_version:r=this._client.apiVersion}=t??{};return this._client.delete(X`/${r}/interactions/${e}`,n)}cancel(e,t={},n){let{api_version:r=this._client.apiVersion}=t??{};return this._client.post(X`/${r}/interactions/${e}/cancel`,n)}get(e,t={},n){let r=t??{},{api_version:i=this._client.apiVersion}=r,a=U(r,[`api_version`]);return this._client.get(X`/${i}/interactions/${e}`,Object.assign(Object.assign({query:a},n),{stream:t?.stream??!1}))}};fl._key=Object.freeze([`interactions`]);var pl=class extends fl{},ml=class extends ll{create(e,t){
|
|
271
|
+
/**
|
|
272
|
+
* @license
|
|
273
|
+
* Copyright 2025 Google LLC
|
|
274
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
275
|
+
*/
|
|
276
|
+
let{api_version:n=this._client.apiVersion}=e,r=U(e,[`api_version`]);return this._client.post(X`/${n}/webhooks`,Object.assign({body:r},t))}update(e,t={},n){let r=t??{},{api_version:i=this._client.apiVersion,update_mask:a}=r,o=U(r,[`api_version`,`update_mask`]);return this._client.patch(X`/${i}/webhooks/${e}`,Object.assign({query:{update_mask:a},body:o},n))}list(e={},t){let n=e??{},{api_version:r=this._client.apiVersion}=n,i=U(n,[`api_version`]);return this._client.get(X`/${r}/webhooks`,Object.assign({query:i},t))}delete(e,t={},n){let{api_version:r=this._client.apiVersion}=t??{};return this._client.delete(X`/${r}/webhooks/${e}`,n)}get(e,t={},n){let{api_version:r=this._client.apiVersion}=t??{};return this._client.get(X`/${r}/webhooks/${e}`,n)}ping(e,t=void 0,n){let{api_version:r=this._client.apiVersion,body:i}=t??{};return this._client.post(X`/${r}/webhooks/${e}:ping`,Object.assign({body:i},n))}rotateSigningSecret(e,t={},n){let r=t??{},{api_version:i=this._client.apiVersion}=r,a=U(r,[`api_version`]);return this._client.post(X`/${i}/webhooks/${e}:rotateSigningSecret`,Object.assign({body:a},n))}};ml._key=Object.freeze([`webhooks`]);var hl=class extends ml{};
|
|
277
|
+
/**
|
|
278
|
+
* @license
|
|
279
|
+
* Copyright 2025 Google LLC
|
|
280
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
281
|
+
*/
|
|
282
|
+
function gl(e){let t=0;for(let n of e)t+=n.length;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}let _l;function vl(e){let t;return(_l??=(t=new globalThis.TextEncoder,t.encode.bind(t)))(e)}let yl;function bl(e){let t;return(yl??=(t=new globalThis.TextDecoder,t.decode.bind(t)))(e)}
|
|
283
|
+
/**
|
|
284
|
+
* @license
|
|
285
|
+
* Copyright 2025 Google LLC
|
|
286
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
287
|
+
*/
|
|
288
|
+
var xl=class{constructor(){this.buffer=new Uint8Array,this.carriageReturnIndex=null,this.searchIndex=0}decode(e){if(e==null)return[];let t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`string`?vl(e):e;this.buffer=gl([this.buffer,t]);let n=[],r;for(;(r=Sl(this.buffer,this.carriageReturnIndex??this.searchIndex))!=null;){if(r.carriage&&this.carriageReturnIndex==null){this.carriageReturnIndex=r.index;continue}if(this.carriageReturnIndex!=null&&(r.index!==this.carriageReturnIndex+1||r.carriage)){n.push(bl(this.buffer.subarray(0,this.carriageReturnIndex-1))),this.buffer=this.buffer.subarray(this.carriageReturnIndex),this.carriageReturnIndex=null,this.searchIndex=0;continue}let e=this.carriageReturnIndex===null?r.preceding:r.preceding-1,t=bl(this.buffer.subarray(0,e));n.push(t),this.buffer=this.buffer.subarray(r.index),this.carriageReturnIndex=null,this.searchIndex=0}return this.searchIndex=Math.max(0,this.buffer.length-1),n}flush(){return this.buffer.length?this.decode(`
|
|
289
|
+
`):[]}};xl.NEWLINE_CHARS=new Set([`
|
|
290
|
+
`,`\r`]),xl.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function Sl(e,t){let n=t??0,r=e.indexOf(10,n),i=e.indexOf(13,n);if(r===-1&&i===-1)return null;let a;return a=r!==-1&&i!==-1?Math.min(r,i):r===-1?i:r,e[a]===10?{preceding:a,index:a+1,carriage:!1}:{preceding:a,index:a+1,carriage:!0}}
|
|
291
|
+
/**
|
|
292
|
+
* @license
|
|
293
|
+
* Copyright 2025 Google LLC
|
|
294
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
295
|
+
*/
|
|
296
|
+
const Cl={off:0,error:200,warn:300,info:400,debug:500},wl=(e,t,n)=>{if(e){if(Hc(Cl,e))return e;Z(n).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(Cl))}`)}};function Tl(){}function El(e,t,n){return!t||Cl[e]>Cl[n]?Tl:t[e].bind(t)}const Dl={error:Tl,warn:Tl,info:Tl,debug:Tl};let Ol=new WeakMap;function Z(e){let t=e.logger,n=e.logLevel??`off`;if(!t)return Dl;let r=Ol.get(t);if(r&&r[0]===n)return r[1];let i={error:El(`error`,t,n),warn:El(`warn`,t,n),info:El(`info`,t,n),debug:El(`debug`,t,n)};return Ol.set(t,[n,i]),i}const Q=e=>(e.options&&(e.options=Object.assign({},e.options),delete e.options.headers),e.headers&&=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([e,t])=>[e,e.toLowerCase()===`x-goog-api-key`||e.toLowerCase()===`authorization`||e.toLowerCase()===`cookie`||e.toLowerCase()===`set-cookie`?`***`:t])),`retryOfRequestLogID`in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e);
|
|
297
|
+
/**
|
|
298
|
+
* @license
|
|
299
|
+
* Copyright 2025 Google LLC
|
|
300
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
301
|
+
*/
|
|
302
|
+
var kl=class e{constructor(e,t,n){this.iterator=e,this.controller=t,this.client=n}static fromSSEResponse(t,n,r){let i=!1,a=r?Z(r):console;function o(){return G(this,arguments,function*(){var e,r,o,s;if(i)throw new J("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let c=!1;try{try{for(var l=!0,u=K(Al(t,n)),d;d=yield W(u.next()),e=d.done,!e;l=!0){s=d.value,l=!1;let e=s;if(!c)if(e.data.startsWith(`[DONE]`)){c=!0;continue}else try{yield yield W(JSON.parse(e.data))}catch(t){throw a.error(`Could not parse message into JSON:`,e.data),a.error(`From chunk:`,e.raw),t}}}catch(e){r={error:e}}finally{try{!l&&!e&&(o=u.return)&&(yield W(o.call(u)))}finally{if(r)throw r.error}}c=!0}catch(e){if(wc(e))return yield W(void 0);throw e}finally{c||n.abort()}})}return new e(o,n,r)}static fromReadableStream(t,n,r){let i=!1;function a(){return G(this,arguments,function*(){var e,n,r,i;let a=new xl,o=Yc(t);try{for(var s=!0,c=K(o),l;l=yield W(c.next()),e=l.done,!e;s=!0){i=l.value,s=!1;let e=i;for(let t of a.decode(e))yield yield W(t)}}catch(e){n={error:e}}finally{try{!s&&!e&&(r=c.return)&&(yield W(r.call(c)))}finally{if(n)throw n.error}}for(let e of a.flush())yield yield W(e)})}function o(){return G(this,arguments,function*(){var e,t,r,o;if(i)throw new J("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let s=!1;try{try{for(var c=!0,l=K(a()),u;u=yield W(l.next()),e=u.done,!e;c=!0){o=u.value,c=!1;let e=o;s||e&&(yield yield W(JSON.parse(e)))}}catch(e){t={error:e}}finally{try{!c&&!e&&(r=l.return)&&(yield W(r.call(l)))}finally{if(t)throw t.error}}s=!0}catch(e){if(wc(e))return yield W(void 0);throw e}finally{s||n.abort()}})}return new e(o,n,r)}[Symbol.asyncIterator](){return this.iterator()}tee(){let t=[],n=[],r=this.iterator(),i=e=>({next:()=>{if(e.length===0){let e=r.next();t.push(e),n.push(e)}return e.shift()}});return[new e(()=>i(t),this.controller,this.client),new e(()=>i(n),this.controller,this.client)]}toReadableStream(){let e=this,t;return qc({async start(){t=e[Symbol.asyncIterator]()},async pull(e){try{let{value:n,done:r}=await t.next();if(r)return e.close();let i=vl(JSON.stringify(n)+`
|
|
303
|
+
`);e.enqueue(i)}catch(t){e.error(t)}},async cancel(){await t.return?.call(t)}})}};function Al(e,t){return G(this,arguments,function*(){var n,r,i,a;if(!e.body)throw t.abort(),globalThis.navigator!==void 0&&globalThis.navigator.product===`ReactNative`?new J(`The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api`):new J(`Attempted to iterate over a response with no body`);let o=new Ml,s=new xl,c=Yc(e.body);try{for(var l=!0,u=K(jl(c)),d;d=yield W(u.next()),n=d.done,!n;l=!0){a=d.value,l=!1;let e=a;for(let t of s.decode(e)){let e=o.decode(t);e&&(yield yield W(e))}}}catch(e){r={error:e}}finally{try{!l&&!n&&(i=u.return)&&(yield W(i.call(u)))}finally{if(r)throw r.error}}for(let e of s.flush()){let t=o.decode(e);t&&(yield yield W(t))}})}function jl(e){return G(this,arguments,function*(){var t,n,r,i;try{for(var a=!0,o=K(e),s;s=yield W(o.next()),t=s.done,!t;a=!0){i=s.value,a=!1;let e=i;e!=null&&(yield yield W(e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`string`?vl(e):e))}}catch(e){n={error:e}}finally{try{!a&&!t&&(r=o.return)&&(yield W(r.call(o)))}finally{if(n)throw n.error}}})}var Ml=class{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith(`\r`)&&(e=e.substring(0,e.length-1)),!e){if(!this.event&&!this.data.length)return null;let e={event:this.event,data:this.data.join(`
|
|
304
|
+
`),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],e}if(this.chunks.push(e),e.startsWith(`:`))return null;let[t,n,r]=Nl(e,`:`);return r.startsWith(` `)&&(r=r.substring(1)),t===`event`?this.event=r:t===`data`&&this.data.push(r),null}};function Nl(e,t){let n=e.indexOf(t);return n===-1?[e,``,``]:[e.substring(0,n),t,e.substring(n+t.length)]}
|
|
305
|
+
/**
|
|
306
|
+
* @license
|
|
307
|
+
* Copyright 2025 Google LLC
|
|
308
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
309
|
+
*/
|
|
310
|
+
async function Pl(e,t){let{response:n,requestLogID:r,retryOfRequestLogID:i,startTime:a}=t,o=await(async()=>{if(t.options.stream)return Z(e).debug(`response`,n.status,n.url,n.headers,n.body),t.options.__streamClass?t.options.__streamClass.fromSSEResponse(n,t.controller,e):kl.fromSSEResponse(n,t.controller,e);if(n.status===204)return null;if(t.options.__binaryResponse)return n;let r=(n.headers.get(`content-type`)?.split(`;`)[0])?.trim();return r?.includes(`application/json`)||r?.endsWith(`+json`)?n.headers.get(`content-length`)===`0`?void 0:await n.json():await n.text()})();return Z(e).debug(`[${r}] response parsed`,Q({retryOfRequestLogID:i,url:n.url,status:n.status,body:o,durationMs:Date.now()-a})),o}
|
|
311
|
+
/**
|
|
312
|
+
* @license
|
|
313
|
+
* Copyright 2025 Google LLC
|
|
314
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
315
|
+
*/
|
|
316
|
+
var Fl=class e extends Promise{constructor(e,t,n=Pl){super(e=>{e(null)}),this.responsePromise=t,this.parseResponse=n,this.client=e}_thenUnwrap(t){return new e(this.client,this.responsePromise,async(e,n)=>t(await this.parseResponse(e,n),n))}asResponse(){return this.responsePromise.then(e=>e.response)}async withResponse(){let[e,t]=await Promise.all([this.parse(),this.asResponse()]);return{data:e,response:t}}parse(){return this.parsedPromise||=this.responsePromise.then(e=>this.parseResponse(this.client,e)),this.parsedPromise}then(e,t){return this.parse().then(e,t)}catch(e){return this.parse().catch(e)}finally(e){return this.parse().finally(e)}};
|
|
317
|
+
/**
|
|
318
|
+
* @license
|
|
319
|
+
* Copyright 2025 Google LLC
|
|
320
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
321
|
+
*/
|
|
322
|
+
const Il=Symbol(`brand.privateNullableHeaders`);function*Ll(e){if(!e)return;if(Il in e){let{values:t,nulls:n}=e;yield*t.entries();for(let e of n)yield[e,null];return}let t=!1,n;e instanceof Headers?n=e.entries():Bc(e)?n=e:(t=!0,n=Object.entries(e??{}));for(let e of n){let n=e[0];if(typeof n!=`string`)throw TypeError(`expected header name to be a string`);let r=Bc(e[1])?e[1]:[e[1]],i=!1;for(let e of r)e!==void 0&&(t&&!i&&(i=!0,yield[n,null]),yield[n,e])}}const Rl=e=>{let t=new Headers,n=new Set;for(let r of e){let e=new Set;for(let[i,a]of Ll(r)){let r=i.toLowerCase();e.has(r)||(t.delete(i),e.add(r)),a===null?(t.delete(i),n.add(r)):(t.append(i,a),n.delete(r))}}return{[Il]:!0,values:t,nulls:n}},zl=e=>{
|
|
323
|
+
/**
|
|
324
|
+
* @license
|
|
325
|
+
* Copyright 2025 Google LLC
|
|
326
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
327
|
+
*/
|
|
328
|
+
var t;if(globalThis.process!==void 0)return{}[e]?.trim()||void 0;if(globalThis.Deno!==void 0)return(((t=globalThis.Deno.env)?.get)?.call(t,e))?.trim()||void 0};
|
|
329
|
+
/**
|
|
330
|
+
* @license
|
|
331
|
+
* Copyright 2025 Google LLC
|
|
332
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
333
|
+
*/
|
|
334
|
+
var Bl,Vl=class e{constructor(t){var{baseURL:n=zl(`GEMINI_NEXT_GEN_API_BASE_URL`),apiKey:r=zl(`GEMINI_API_KEY`)??null,apiVersion:i=`v1beta`}=t,a=U(t,[`baseURL`,`apiKey`,`apiVersion`]);let o=Object.assign(Object.assign({apiKey:r,apiVersion:i},a),{baseURL:n||`https://generativelanguage.googleapis.com`});this.baseURL=o.baseURL,this.timeout=o.timeout??e.DEFAULT_TIMEOUT,this.logger=o.logger??console;let s=`warn`;this.logLevel=s,this.logLevel=wl(o.logLevel,`ClientOptions.logLevel`,this)??wl(zl(`GEMINI_NEXT_GEN_API_LOG`),`process.env['GEMINI_NEXT_GEN_API_LOG']`,this)??s,this.fetchOptions=o.fetchOptions,this.maxRetries=o.maxRetries??2,this.fetch=o.fetch??Kc(),this.encoder=Zc,this._options=o,this.apiKey=r,this.apiVersion=i,this.clientAdapter=o.clientAdapter}withOptions(e){return new this.constructor(Object.assign(Object.assign(Object.assign({},this._options),{baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,apiVersion:this.apiVersion}),e))}baseURLOverridden(){return this.baseURL!==`https://generativelanguage.googleapis.com`}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:t}){if(!(e.has(`authorization`)||e.has(`x-goog-api-key`))&&!(this.apiKey&&e.get(`x-goog-api-key`))&&!t.has(`x-goog-api-key`))throw Error(`Could not resolve authentication method. Expected the apiKey to be set. Or for the "x-goog-api-key" headers to be explicitly omitted`)}async authHeaders(e){let t=Rl([e.headers]);if(!(t.values.has(`authorization`)||t.values.has(`x-goog-api-key`))){if(this.apiKey)return Rl([{"x-goog-api-key":this.apiKey}]);if(this.clientAdapter&&this.clientAdapter.isVertexAI())return Rl([await this.clientAdapter.getAuthHeaders()])}}stringifyQuery(e){return Qc(e)}getUserAgent(){return`${this.constructor.name}/JS 0.0.1`}defaultIdempotencyKey(){return`stainless-node-retry-${Cc()}`}makeStatusError(e,t,n,r){return Y.generate(e,t,n,r)}buildURL(e,t,n){let r=!this.baseURLOverridden()&&n||this.baseURL,i=Rc(e)?new URL(e):new URL(r+(r.endsWith(`/`)&&e.startsWith(`/`)?e.slice(1):e)),a=this.defaultQuery(),o=Object.fromEntries(i.searchParams);return(!Vc(a)||!Vc(o))&&(t=Object.assign(Object.assign(Object.assign({},o),a),t)),typeof t==`object`&&t&&!Array.isArray(t)&&(i.search=this.stringifyQuery(t)),i.toString()}async prepareOptions(e){if(this.clientAdapter&&this.clientAdapter.isVertexAI()&&!e.path.startsWith(`/${this.apiVersion}/projects/`)){let t=e.path.slice(this.apiVersion.length+1);e.path=`/${this.apiVersion}/projects/${this.clientAdapter.getProject()}/locations/${this.clientAdapter.getLocation()}${t}`}}async prepareRequest(e,{url:t,options:n}){}get(e,t){return this.methodRequest(`get`,e,t)}post(e,t){return this.methodRequest(`post`,e,t)}patch(e,t){return this.methodRequest(`patch`,e,t)}put(e,t){return this.methodRequest(`put`,e,t)}delete(e,t){return this.methodRequest(`delete`,e,t)}methodRequest(e,t,n){return this.request(Promise.resolve(n).then(n=>Object.assign({method:e,path:t},n)))}request(e,t=null){return new Fl(this,this.makeRequest(e,t,void 0))}async makeRequest(e,t,n){let r=await e,i=r.maxRetries??this.maxRetries;t??=i,await this.prepareOptions(r);let{req:a,url:o,timeout:s}=await this.buildRequest(r,{retryCount:i-t});await this.prepareRequest(a,{url:o,options:r});let c=`log_`+(Math.random()*(1<<24)|0).toString(16).padStart(6,`0`),l=n===void 0?``:`, retryOf: ${n}`,u=Date.now();if(Z(this).debug(`[${c}] sending request`,Q({retryOfRequestLogID:n,method:r.method,url:o,options:r,headers:a.headers})),r.signal?.aborted)throw new Ec;let d=new AbortController,f=await this.fetchWithTimeout(o,a,s,d).catch(Tc),p=Date.now();if(f instanceof globalThis.Error){let e=`retrying, ${t} attempts remaining`;if(r.signal?.aborted)throw new Ec;let i=wc(f)||/timed? ?out/i.test(String(f)+(`cause`in f?String(f.cause):``));if(t)return Z(this).info(`[${c}] connection ${i?`timed out`:`failed`} - ${e}`),Z(this).debug(`[${c}] connection ${i?`timed out`:`failed`} (${e})`,Q({retryOfRequestLogID:n,url:o,durationMs:p-u,message:f.message})),this.retryRequest(r,t,n??c);throw Z(this).info(`[${c}] connection ${i?`timed out`:`failed`} - error; no more retries left`),Z(this).debug(`[${c}] connection ${i?`timed out`:`failed`} (error; no more retries left)`,Q({retryOfRequestLogID:n,url:o,durationMs:p-u,message:f.message})),i?new Oc:new Dc({cause:f})}let m=`[${c}${l}] ${a.method} ${o} ${f.ok?`succeeded`:`failed`} with status ${f.status} in ${p-u}ms`;if(!f.ok){let e=await this.shouldRetry(f);if(t&&e){let e=`retrying, ${t} attempts remaining`;return await Xc(f.body),Z(this).info(`${m} - ${e}`),Z(this).debug(`[${c}] response error (${e})`,Q({retryOfRequestLogID:n,url:f.url,status:f.status,headers:f.headers,durationMs:p-u})),this.retryRequest(r,t,n??c,f.headers)}let i=e?`error; no more retries left`:`error; not retryable`;Z(this).info(`${m} - ${i}`);let a=await f.text().catch(e=>Tc(e).message),o=Wc(a),s=o?void 0:a;throw Z(this).debug(`[${c}] response error (${i})`,Q({retryOfRequestLogID:n,url:f.url,status:f.status,headers:f.headers,message:s,durationMs:Date.now()-u})),this.makeStatusError(f.status,o,s,f.headers)}return Z(this).info(m),Z(this).debug(`[${c}] response start`,Q({retryOfRequestLogID:n,url:f.url,status:f.status,headers:f.headers,durationMs:p-u})),{response:f,options:r,controller:d,requestLogID:c,retryOfRequestLogID:n,startTime:u}}async fetchWithTimeout(e,t,n,r){let i=t||{},{signal:a,method:o}=i,s=U(i,[`signal`,`method`]),c=this._makeAbort(r);a&&a.addEventListener(`abort`,c,{once:!0});let l=setTimeout(c,n),u=globalThis.ReadableStream&&s.body instanceof globalThis.ReadableStream||typeof s.body==`object`&&s.body!==null&&Symbol.asyncIterator in s.body,d=Object.assign(Object.assign(Object.assign({signal:r.signal},u?{duplex:`half`}:{}),{method:`GET`}),s);o&&(d.method=o.toUpperCase());try{return await this.fetch.call(void 0,e,d)}finally{clearTimeout(l)}}async shouldRetry(e){let t=e.headers.get(`x-should-retry`);return t===`true`?!0:t===`false`?!1:e.status===408||e.status===409||e.status===429||e.status>=500}async retryRequest(e,t,n,r){let i,a=r?.get(`retry-after-ms`);if(a){let e=parseFloat(a);Number.isNaN(e)||(i=e)}let o=r?.get(`retry-after`);if(o&&!i){let e=parseFloat(o);i=Number.isNaN(e)?Date.parse(o)-Date.now():e*1e3}if(i===void 0){let n=e.maxRetries??this.maxRetries;i=this.calculateDefaultRetryTimeoutMillis(t,n)}return await Gc(i),this.makeRequest(e,t-1,n)}calculateDefaultRetryTimeoutMillis(e,t){let n=t-e;return Math.min(.5*2**n,8)*(1-Math.random()*.25)*1e3}async buildRequest(e,{retryCount:t=0}={}){let n=Object.assign({},e),{method:r,path:i,query:a,defaultBaseURL:o}=n,s=this.buildURL(i,a,o);`timeout`in n&&Uc(`timeout`,n.timeout),n.timeout=n.timeout??this.timeout;let{bodyHeaders:c,body:l}=this.buildBody({options:n}),u=await this.buildHeaders({options:e,method:r,bodyHeaders:c,retryCount:t});return{req:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({method:r,headers:u},n.signal&&{signal:n.signal}),globalThis.ReadableStream&&l instanceof globalThis.ReadableStream&&{duplex:`half`}),l&&{body:l}),this.fetchOptions??{}),n.fetchOptions??{}),url:s,timeout:n.timeout}}async buildHeaders({options:e,method:t,bodyHeaders:n,retryCount:r}){let i={};this.idempotencyHeader&&t!==`get`&&(e.idempotencyKey||=this.defaultIdempotencyKey(),i[this.idempotencyHeader]=e.idempotencyKey);let a=await this.authHeaders(e),o=Rl([i,{Accept:`application/json`,"User-Agent":this.getUserAgent()},this._options.defaultHeaders,n,e.headers,a]);return this.validateHeaders(o),o.values}_makeAbort(e){return()=>e.abort()}buildBody({options:{body:e,headers:t}}){if(!e)return{bodyHeaders:void 0,body:void 0};let n=Rl([t]);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||typeof e==`string`&&n.values.has(`content-type`)||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||globalThis.ReadableStream&&e instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:e}:typeof e==`object`&&(Symbol.asyncIterator in e||Symbol.iterator in e&&`next`in e&&typeof e.next==`function`)?{bodyHeaders:void 0,body:Jc(e)}:typeof e==`object`&&n.values.get(`content-type`)===`application/x-www-form-urlencoded`?{bodyHeaders:{"content-type":`application/x-www-form-urlencoded`},body:this.stringifyQuery(e)}:this.encoder({body:e,headers:n})}};Vl.DEFAULT_TIMEOUT=6e4;var $=class extends Vl{constructor(){super(...arguments),this.interactions=new pl(this),this.webhooks=new hl(this)}};Bl=$,$.GeminiNextGenAPIClient=Bl,$.GeminiNextGenAPIClientError=J,$.APIError=Y,$.APIConnectionError=Dc,$.APIConnectionTimeoutError=Oc,$.APIUserAbortError=Ec,$.NotFoundError=Mc,$.ConflictError=Nc,$.RateLimitError=Fc,$.BadRequestError=kc,$.AuthenticationError=Ac,$.InternalServerError=Ic,$.PermissionDeniedError=jc,$.UnprocessableEntityError=Pc,$.toFile=ol,$.Interactions=pl,$.Webhooks=hl;
|
|
335
|
+
/**
|
|
336
|
+
* @license
|
|
337
|
+
* Copyright 2025 Google LLC
|
|
338
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
339
|
+
*/
|
|
340
|
+
function Hl(e,t){let n={},r=m(e,[`name`]);return r!=null&&p(n,[`_url`,`name`],r),n}function Ul(e,t){let n={},r=m(e,[`name`]);return r!=null&&p(n,[`_url`,`name`],r),n}function Wl(e,t){let n={},r=m(e,[`sdkHttpResponse`]);return r!=null&&p(n,[`sdkHttpResponse`],r),n}function Gl(e,t){let n={},r=m(e,[`sdkHttpResponse`]);return r!=null&&p(n,[`sdkHttpResponse`],r),n}function Kl(e,t,n){let r={};if(m(e,[`validationDataset`])!==void 0)throw Error(`validationDataset parameter is not supported in Gemini API.`);let i=m(e,[`tunedModelDisplayName`]);if(t!==void 0&&i!=null&&p(t,[`displayName`],i),m(e,[`description`])!==void 0)throw Error(`description parameter is not supported in Gemini API.`);let a=m(e,[`epochCount`]);t!==void 0&&a!=null&&p(t,[`tuningTask`,`hyperparameters`,`epochCount`],a);let o=m(e,[`learningRateMultiplier`]);if(o!=null&&p(r,[`tuningTask`,`hyperparameters`,`learningRateMultiplier`],o),m(e,[`exportLastCheckpointOnly`])!==void 0)throw Error(`exportLastCheckpointOnly parameter is not supported in Gemini API.`);if(m(e,[`preTunedModelCheckpointId`])!==void 0)throw Error(`preTunedModelCheckpointId parameter is not supported in Gemini API.`);if(m(e,[`adapterSize`])!==void 0)throw Error(`adapterSize parameter is not supported in Gemini API.`);if(m(e,[`tuningMode`])!==void 0)throw Error(`tuningMode parameter is not supported in Gemini API.`);if(m(e,[`customBaseModel`])!==void 0)throw Error(`customBaseModel parameter is not supported in Gemini API.`);let s=m(e,[`batchSize`]);t!==void 0&&s!=null&&p(t,[`tuningTask`,`hyperparameters`,`batchSize`],s);let c=m(e,[`learningRate`]);if(t!==void 0&&c!=null&&p(t,[`tuningTask`,`hyperparameters`,`learningRate`],c),m(e,[`labels`])!==void 0)throw Error(`labels parameter is not supported in Gemini API.`);if(m(e,[`beta`])!==void 0)throw Error(`beta parameter is not supported in Gemini API.`);if(m(e,[`baseTeacherModel`])!==void 0)throw Error(`baseTeacherModel parameter is not supported in Gemini API.`);if(m(e,[`tunedTeacherModelSource`])!==void 0)throw Error(`tunedTeacherModelSource parameter is not supported in Gemini API.`);if(m(e,[`sftLossWeightMultiplier`])!==void 0)throw Error(`sftLossWeightMultiplier parameter is not supported in Gemini API.`);if(m(e,[`outputUri`])!==void 0)throw Error(`outputUri parameter is not supported in Gemini API.`);if(m(e,[`encryptionSpec`])!==void 0)throw Error(`encryptionSpec parameter is not supported in Gemini API.`);return r}function ql(e,t,n){let r={},i=m(n,[`config`,`method`]);if(i===void 0&&(i=`SUPERVISED_FINE_TUNING`),i===`SUPERVISED_FINE_TUNING`){let n=m(e,[`validationDataset`]);t!==void 0&&n!=null&&p(t,[`supervisedTuningSpec`],su(n))}else if(i===`PREFERENCE_TUNING`){let n=m(e,[`validationDataset`]);t!==void 0&&n!=null&&p(t,[`preferenceOptimizationSpec`],su(n))}else if(i===`DISTILLATION`){let n=m(e,[`validationDataset`]);t!==void 0&&n!=null&&p(t,[`distillationSpec`],su(n))}let a=m(e,[`tunedModelDisplayName`]);t!==void 0&&a!=null&&p(t,[`tunedModelDisplayName`],a);let o=m(e,[`description`]);t!==void 0&&o!=null&&p(t,[`description`],o);let s=m(n,[`config`,`method`]);if(s===void 0&&(s=`SUPERVISED_FINE_TUNING`),s===`SUPERVISED_FINE_TUNING`){let n=m(e,[`epochCount`]);t!==void 0&&n!=null&&p(t,[`supervisedTuningSpec`,`hyperParameters`,`epochCount`],n)}else if(s===`PREFERENCE_TUNING`){let n=m(e,[`epochCount`]);t!==void 0&&n!=null&&p(t,[`preferenceOptimizationSpec`,`hyperParameters`,`epochCount`],n)}else if(s===`DISTILLATION`){let n=m(e,[`epochCount`]);t!==void 0&&n!=null&&p(t,[`distillationSpec`,`hyperParameters`,`epochCount`],n)}let c=m(n,[`config`,`method`]);if(c===void 0&&(c=`SUPERVISED_FINE_TUNING`),c===`SUPERVISED_FINE_TUNING`){let n=m(e,[`learningRateMultiplier`]);t!==void 0&&n!=null&&p(t,[`supervisedTuningSpec`,`hyperParameters`,`learningRateMultiplier`],n)}else if(c===`PREFERENCE_TUNING`){let n=m(e,[`learningRateMultiplier`]);t!==void 0&&n!=null&&p(t,[`preferenceOptimizationSpec`,`hyperParameters`,`learningRateMultiplier`],n)}else if(c===`DISTILLATION`){let n=m(e,[`learningRateMultiplier`]);t!==void 0&&n!=null&&p(t,[`distillationSpec`,`hyperParameters`,`learningRateMultiplier`],n)}let l=m(n,[`config`,`method`]);if(l===void 0&&(l=`SUPERVISED_FINE_TUNING`),l===`SUPERVISED_FINE_TUNING`){let n=m(e,[`exportLastCheckpointOnly`]);t!==void 0&&n!=null&&p(t,[`supervisedTuningSpec`,`exportLastCheckpointOnly`],n)}else if(l===`PREFERENCE_TUNING`){let n=m(e,[`exportLastCheckpointOnly`]);t!==void 0&&n!=null&&p(t,[`preferenceOptimizationSpec`,`exportLastCheckpointOnly`],n)}else if(l===`DISTILLATION`){let n=m(e,[`exportLastCheckpointOnly`]);t!==void 0&&n!=null&&p(t,[`distillationSpec`,`exportLastCheckpointOnly`],n)}let u=m(n,[`config`,`method`]);if(u===void 0&&(u=`SUPERVISED_FINE_TUNING`),u===`SUPERVISED_FINE_TUNING`){let n=m(e,[`adapterSize`]);t!==void 0&&n!=null&&p(t,[`supervisedTuningSpec`,`hyperParameters`,`adapterSize`],n)}else if(u===`PREFERENCE_TUNING`){let n=m(e,[`adapterSize`]);t!==void 0&&n!=null&&p(t,[`preferenceOptimizationSpec`,`hyperParameters`,`adapterSize`],n)}else if(u===`DISTILLATION`){let n=m(e,[`adapterSize`]);t!==void 0&&n!=null&&p(t,[`distillationSpec`,`hyperParameters`,`adapterSize`],n)}let d=m(n,[`config`,`method`]);if(d===void 0&&(d=`SUPERVISED_FINE_TUNING`),d===`SUPERVISED_FINE_TUNING`){let n=m(e,[`tuningMode`]);t!==void 0&&n!=null&&p(t,[`supervisedTuningSpec`,`tuningMode`],n)}else if(d===`DISTILLATION`){let n=m(e,[`tuningMode`]);t!==void 0&&n!=null&&p(t,[`distillationSpec`,`tuningMode`],n)}let f=m(e,[`customBaseModel`]);t!==void 0&&f!=null&&p(t,[`customBaseModel`],f);let h=m(n,[`config`,`method`]);if(h===void 0&&(h=`SUPERVISED_FINE_TUNING`),h===`SUPERVISED_FINE_TUNING`){let n=m(e,[`batchSize`]);t!==void 0&&n!=null&&p(t,[`supervisedTuningSpec`,`hyperParameters`,`batchSize`],n)}else if(h===`DISTILLATION`){let n=m(e,[`batchSize`]);t!==void 0&&n!=null&&p(t,[`distillationSpec`,`hyperParameters`,`batchSize`],n)}let g=m(n,[`config`,`method`]);if(g===void 0&&(g=`SUPERVISED_FINE_TUNING`),g===`SUPERVISED_FINE_TUNING`){let n=m(e,[`learningRate`]);t!==void 0&&n!=null&&p(t,[`supervisedTuningSpec`,`hyperParameters`,`learningRate`],n)}else if(g===`DISTILLATION`){let n=m(e,[`learningRate`]);t!==void 0&&n!=null&&p(t,[`distillationSpec`,`hyperParameters`,`learningRate`],n)}let _=m(e,[`labels`]);t!==void 0&&_!=null&&p(t,[`labels`],_);let v=m(e,[`beta`]);t!==void 0&&v!=null&&p(t,[`preferenceOptimizationSpec`,`hyperParameters`,`beta`],v);let y=m(e,[`baseTeacherModel`]);t!==void 0&&y!=null&&p(t,[`distillationSpec`,`baseTeacherModel`],y);let b=m(e,[`tunedTeacherModelSource`]);t!==void 0&&b!=null&&p(t,[`distillationSpec`,`tunedTeacherModelSource`],b);let x=m(e,[`sftLossWeightMultiplier`]);t!==void 0&&x!=null&&p(t,[`distillationSpec`,`hyperParameters`,`sftLossWeightMultiplier`],x);let S=m(e,[`outputUri`]);t!==void 0&&S!=null&&p(t,[`outputUri`],S);let C=m(e,[`encryptionSpec`]);return t!==void 0&&C!=null&&p(t,[`encryptionSpec`],C),r}function Jl(e,t){let n={},r=m(e,[`baseModel`]);r!=null&&p(n,[`baseModel`],r);let i=m(e,[`preTunedModel`]);i!=null&&p(n,[`preTunedModel`],i);let a=m(e,[`trainingDataset`]);a!=null&&nu(a);let o=m(e,[`config`]);return o!=null&&Kl(o,n),n}function Yl(e,t){let n={},r=m(e,[`baseModel`]);r!=null&&p(n,[`baseModel`],r);let i=m(e,[`preTunedModel`]);i!=null&&p(n,[`preTunedModel`],i);let a=m(e,[`trainingDataset`]);a!=null&&ru(a,n,t);let o=m(e,[`config`]);return o!=null&&ql(o,n,t),n}function Xl(e,t){let n={},r=m(e,[`name`]);return r!=null&&p(n,[`_url`,`name`],r),n}function Zl(e,t){let n={},r=m(e,[`name`]);return r!=null&&p(n,[`_url`,`name`],r),n}function Ql(e,t,n){let r={},i=m(e,[`pageSize`]);t!==void 0&&i!=null&&p(t,[`_query`,`pageSize`],i);let a=m(e,[`pageToken`]);t!==void 0&&a!=null&&p(t,[`_query`,`pageToken`],a);let o=m(e,[`filter`]);return t!==void 0&&o!=null&&p(t,[`_query`,`filter`],o),r}function $l(e,t){let n={},r=m(e,[`config`]);return r!=null&&Ql(r,n),n}function eu(e,t){let n={},r=m(e,[`sdkHttpResponse`]);r!=null&&p(n,[`sdkHttpResponse`],r);let i=m(e,[`nextPageToken`]);i!=null&&p(n,[`nextPageToken`],i);let a=m(e,[`tuningJobs`]);if(a!=null){let e=a;Array.isArray(e)&&(e=e.map(e=>au(e))),p(n,[`tuningJobs`],e)}return n}function tu(e,t){let n={},r=m(e,[`name`]);r!=null&&p(n,[`model`],r);let i=m(e,[`name`]);return i!=null&&p(n,[`endpoint`],i),n}function nu(e,t){let n={};if(m(e,[`gcsUri`])!==void 0)throw Error(`gcsUri parameter is not supported in Gemini API.`);if(m(e,[`vertexDatasetResource`])!==void 0)throw Error(`vertexDatasetResource parameter is not supported in Gemini API.`);let r=m(e,[`examples`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),p(n,[`examples`,`examples`],e)}return n}function ru(e,t,n){let r={},i=m(n,[`config`,`method`]);if(i===void 0&&(i=`SUPERVISED_FINE_TUNING`),i===`SUPERVISED_FINE_TUNING`){let n=m(e,[`gcsUri`]);t!==void 0&&n!=null&&p(t,[`supervisedTuningSpec`,`trainingDatasetUri`],n)}else if(i===`PREFERENCE_TUNING`){let n=m(e,[`gcsUri`]);t!==void 0&&n!=null&&p(t,[`preferenceOptimizationSpec`,`trainingDatasetUri`],n)}else if(i===`DISTILLATION`){let n=m(e,[`gcsUri`]);t!==void 0&&n!=null&&p(t,[`distillationSpec`,`promptDatasetUri`],n)}let a=m(n,[`config`,`method`]);if(a===void 0&&(a=`SUPERVISED_FINE_TUNING`),a===`SUPERVISED_FINE_TUNING`){let n=m(e,[`vertexDatasetResource`]);t!==void 0&&n!=null&&p(t,[`supervisedTuningSpec`,`trainingDatasetUri`],n)}else if(a===`PREFERENCE_TUNING`){let n=m(e,[`vertexDatasetResource`]);t!==void 0&&n!=null&&p(t,[`preferenceOptimizationSpec`,`trainingDatasetUri`],n)}else if(a===`DISTILLATION`){let n=m(e,[`vertexDatasetResource`]);t!==void 0&&n!=null&&p(t,[`distillationSpec`,`promptDatasetUri`],n)}if(m(e,[`examples`])!==void 0)throw Error(`examples parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);return r}function iu(e,t){let n={},r=m(e,[`sdkHttpResponse`]);r!=null&&p(n,[`sdkHttpResponse`],r);let i=m(e,[`name`]);i!=null&&p(n,[`name`],i);let a=m(e,[`state`]);a!=null&&p(n,[`state`],rn(a));let o=m(e,[`createTime`]);o!=null&&p(n,[`createTime`],o);let s=m(e,[`tuningTask`,`startTime`]);s!=null&&p(n,[`startTime`],s);let c=m(e,[`tuningTask`,`completeTime`]);c!=null&&p(n,[`endTime`],c);let l=m(e,[`updateTime`]);l!=null&&p(n,[`updateTime`],l);let u=m(e,[`description`]);u!=null&&p(n,[`description`],u);let d=m(e,[`baseModel`]);d!=null&&p(n,[`baseModel`],d);let f=m(e,[`_self`]);return f!=null&&p(n,[`tunedModel`],tu(f)),n}function au(e,t){let n={},r=m(e,[`sdkHttpResponse`]);r!=null&&p(n,[`sdkHttpResponse`],r);let i=m(e,[`name`]);i!=null&&p(n,[`name`],i);let a=m(e,[`state`]);a!=null&&p(n,[`state`],rn(a));let o=m(e,[`createTime`]);o!=null&&p(n,[`createTime`],o);let s=m(e,[`startTime`]);s!=null&&p(n,[`startTime`],s);let c=m(e,[`endTime`]);c!=null&&p(n,[`endTime`],c);let l=m(e,[`updateTime`]);l!=null&&p(n,[`updateTime`],l);let u=m(e,[`error`]);u!=null&&p(n,[`error`],u);let d=m(e,[`description`]);d!=null&&p(n,[`description`],d);let f=m(e,[`baseModel`]);f!=null&&p(n,[`baseModel`],f);let h=m(e,[`tunedModel`]);h!=null&&p(n,[`tunedModel`],h);let g=m(e,[`preTunedModel`]);g!=null&&p(n,[`preTunedModel`],g);let _=m(e,[`supervisedTuningSpec`]);_!=null&&p(n,[`supervisedTuningSpec`],_);let v=m(e,[`preferenceOptimizationSpec`]);v!=null&&p(n,[`preferenceOptimizationSpec`],v);let y=m(e,[`distillationSpec`]);y!=null&&p(n,[`distillationSpec`],y);let b=m(e,[`tuningDataStats`]);b!=null&&p(n,[`tuningDataStats`],b);let x=m(e,[`encryptionSpec`]);x!=null&&p(n,[`encryptionSpec`],x);let S=m(e,[`partnerModelTuningSpec`]);S!=null&&p(n,[`partnerModelTuningSpec`],S);let C=m(e,[`customBaseModel`]);C!=null&&p(n,[`customBaseModel`],C);let w=m(e,[`evaluateDatasetRuns`]);if(w!=null){let e=w;Array.isArray(e)&&(e=e.map(e=>e)),p(n,[`evaluateDatasetRuns`],e)}let T=m(e,[`experiment`]);T!=null&&p(n,[`experiment`],T);let E=m(e,[`fullFineTuningSpec`]);E!=null&&p(n,[`fullFineTuningSpec`],E);let D=m(e,[`labels`]);D!=null&&p(n,[`labels`],D);let O=m(e,[`outputUri`]);O!=null&&p(n,[`outputUri`],O);let k=m(e,[`pipelineJob`]);k!=null&&p(n,[`pipelineJob`],k);let A=m(e,[`serviceAccount`]);A!=null&&p(n,[`serviceAccount`],A);let j=m(e,[`tunedModelDisplayName`]);j!=null&&p(n,[`tunedModelDisplayName`],j);let M=m(e,[`tuningJobState`]);M!=null&&p(n,[`tuningJobState`],M);let ee=m(e,[`veoTuningSpec`]);ee!=null&&p(n,[`veoTuningSpec`],ee);let te=m(e,[`distillationSamplingSpec`]);te!=null&&p(n,[`distillationSamplingSpec`],te);let ne=m(e,[`tuningJobMetadata`]);return ne!=null&&p(n,[`tuningJobMetadata`],ne),n}function ou(e,t){let n={},r=m(e,[`sdkHttpResponse`]);r!=null&&p(n,[`sdkHttpResponse`],r);let i=m(e,[`name`]);i!=null&&p(n,[`name`],i);let a=m(e,[`metadata`]);a!=null&&p(n,[`metadata`],a);let o=m(e,[`done`]);o!=null&&p(n,[`done`],o);let s=m(e,[`error`]);return s!=null&&p(n,[`error`],s),n}function su(e,t){let n={},r=m(e,[`gcsUri`]);r!=null&&p(n,[`validationDatasetUri`],r);let i=m(e,[`vertexDatasetResource`]);return i!=null&&p(n,[`validationDatasetUri`],i),n}
|
|
341
|
+
/**
|
|
342
|
+
* @license
|
|
343
|
+
* Copyright 2025 Google LLC
|
|
344
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
345
|
+
*/
|
|
346
|
+
var cu=class extends d{constructor(e){super(),this.apiClient=e,this.list=async(e={})=>new H(V.PAGED_ITEM_TUNING_JOBS,e=>this.listInternal(e),await this.listInternal(e),e),this.get=async e=>await this.getInternal(e),this.tune=async e=>{if(this.apiClient.isVertexAI())if(e.baseModel.startsWith(`projects/`)){let t={tunedModelName:e.baseModel};e.config?.preTunedModelCheckpointId&&(t.checkpointId=e.config.preTunedModelCheckpointId);let n=Object.assign(Object.assign({},e),{preTunedModel:t});return n.baseModel=void 0,await this.tuneInternal(n)}else{let t=Object.assign({},e);return await this.tuneInternal(t)}else{let t=Object.assign({},e),n=await this.tuneMldevInternal(t),r=``;return n.metadata!==void 0&&n.metadata.tunedModel!==void 0?r=n.metadata.tunedModel:n.name!==void 0&&n.name.includes(`/operations/`)&&(r=n.name.split(`/operations/`)[0]),{name:r,state:Ee.JOB_STATE_QUEUED}}}}async getInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Zl(e);return n=f(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>au(e))}else{let i=Xl(e);return n=f(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>iu(e))}}async listInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=$l(e);return n=f(`tuningJobs`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=eu(e),n=new St;return Object.assign(n,t),n})}else throw Error(`This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).`)}async cancel(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Ul(e);return n=f(`{name}:cancel`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Gl(e),n=new Ct;return Object.assign(n,t),n})}else{let i=Hl(e);return n=f(`{name}:cancel`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Wl(e),n=new Ct;return Object.assign(n,t),n})}}async tuneInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Yl(e,e);return n=f(`tuningJobs`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>au(e))}else throw Error(`This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).`)}async tuneMldevInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=Jl(e);return n=f(`tunedModels`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>ou(e))}}},lu=class{async download(e,t){
|
|
347
|
+
/**
|
|
348
|
+
* @license
|
|
349
|
+
* Copyright 2025 Google LLC
|
|
350
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
351
|
+
*/
|
|
352
|
+
throw Error(`Download to file is not supported in the browser, please use a browser compliant download like an <a> tag.`)}};const uu=`x-goog-upload-status`;async function du(e,t,n,r){let i=await pu(e,t,n,r),a=await i?.json();if(i?.headers?.[uu]!==`final`)throw Error(`Failed to upload file: Upload status is not finalized.`);return a.file}async function fu(e,t,n,r){let i=await pu(e,t,n,r),a=await i?.json();if(i?.headers?.[uu]!==`final`)throw Error(`Failed to upload file: Upload status is not finalized.`);let o=k(a),s=new Lt;return Object.assign(s,o),s}async function pu(e,t,n,r){let i=t,a=r?.baseUrl||n.clientOptions.httpOptions?.baseUrl;if(a){let e=new URL(a),n=new URL(t);n.protocol=e.protocol,n.host=e.host,n.port=e.port,i=n.toString()}let o=0,s=0,c=new lt(new Response),l=`upload`;for(o=e.size;s<o;){let t=Math.min(8388608,o-s),a=e.slice(s,s+t);s+t>=o&&(l+=`, finalize`);let u=0,d=1e3;for(;u<3;){let e=Object.assign(Object.assign({},r?.headers||{}),{"X-Goog-Upload-Command":l,"X-Goog-Upload-Offset":String(s),"Content-Length":String(t)});if(c=await n.request({path:``,body:a,httpMethod:`POST`,httpOptions:Object.assign(Object.assign({},r),{apiVersion:``,baseUrl:i,headers:e})}),c?.headers?.[uu])break;u++,await hu(d),d*=2}if(s+=t,c?.headers?.[uu]!==`active`)break;if(o<=s)throw Error(`All content has been uploaded, but the upload status is not finalized.`)}return c}async function mu(e){return{size:e.size,type:e.type}}function hu(e){return new Promise(t=>setTimeout(t,e))}var gu=class{async upload(e,t,n,r){if(typeof e==`string`)throw Error(`File path is not supported in browser uploader.`);return await du(e,t,n,r)}async uploadToFileSearchStore(e,t,n,r){if(typeof e==`string`)throw Error(`File path is not supported in browser uploader.`);return await fu(e,t,n,r)}async stat(e){if(typeof e==`string`)throw Error(`File path is not supported in browser uploader.`);return await mu(e)}},_u=class{create(e,t,n){
|
|
353
|
+
/**
|
|
354
|
+
* @license
|
|
355
|
+
* Copyright 2025 Google LLC
|
|
356
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
357
|
+
*/
|
|
358
|
+
return new vu(e,t,n)}},vu=class{constructor(e,t,n){this.url=e,this.headers=t,this.callbacks=n}connect(){this.ws=new WebSocket(this.url),this.ws.onopen=this.callbacks.onopen,this.ws.onerror=this.callbacks.onerror,this.ws.onclose=this.callbacks.onclose,this.ws.onmessage=this.callbacks.onmessage}send(e){if(this.ws===void 0)throw Error(`WebSocket is not connected`);this.ws.send(e)}close(){if(this.ws===void 0)throw Error(`WebSocket is not connected`);this.ws.close()}};
|
|
359
|
+
/**
|
|
360
|
+
* @license
|
|
361
|
+
* Copyright 2025 Google LLC
|
|
362
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
363
|
+
*/
|
|
364
|
+
const yu=`x-goog-api-key`;var bu=class{constructor(e){this.apiKey=e}async addAuthHeaders(e,t){if(e.get(yu)===null){if(this.apiKey.startsWith(`auth_tokens/`))throw Error(`Ephemeral tokens are only supported by the live API.`);if(!this.apiKey)throw Error(`API key is missing. Please provide a valid API key.`);e.append(yu,this.apiKey)}}},xu=class{getNextGenClient(){
|
|
365
|
+
/**
|
|
366
|
+
* @license
|
|
367
|
+
* Copyright 2025 Google LLC
|
|
368
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
369
|
+
*/
|
|
370
|
+
let e=this.httpOptions;if(this._nextGenClient===void 0){let e=this.httpOptions;this._nextGenClient=new $({baseURL:this.apiClient.getBaseUrl(),apiKey:this.apiKey,apiVersion:this.apiClient.getApiVersion(),clientAdapter:this.apiClient,defaultHeaders:this.apiClient.getDefaultHeaders(),timeout:e?.timeout,maxRetries:e?.retryOptions?.attempts})}return e?.extraBody&&console.warn(`GoogleGenAI.interactions: Client level httpOptions.extraBody is not supported by the interactions client and will be ignored.`),this._nextGenClient}get interactions(){return this._interactions===void 0?(console.warn(`GoogleGenAI.interactions: Interactions usage is experimental and may change in future versions.`),this._interactions=this.getNextGenClient().interactions,this._interactions):this._interactions}get webhooks(){return this._webhooks===void 0&&(this._webhooks=this.getNextGenClient().webhooks),this._webhooks}constructor(e){if(e.apiKey==null)throw Error(`An API Key must be set when running in a browser`);if(e.project||e.location)throw Error(`Vertex AI project based authentication is not supported on browser runtimes. Please do not provide a project or location.`);this.vertexai=e.vertexai??!1,this.apiKey=e.apiKey;let t=u(e.httpOptions,e.vertexai,void 0,void 0);t&&(e.httpOptions?e.httpOptions.baseUrl=t:e.httpOptions={baseUrl:t}),this.apiVersion=e.apiVersion,this.httpOptions=e.httpOptions;let n=new bu(this.apiKey);this.apiClient=new Cs({auth:n,apiVersion:this.apiVersion,apiKey:this.apiKey,vertexai:this.vertexai,httpOptions:this.httpOptions,userAgentExtra:`gl-node/web`,uploader:new gu,downloader:new lu}),this.models=new qs(this.apiClient),this.live=new Ls(this.apiClient,n,new _u),this.batches=new vr(this.apiClient),this.chats=new si(this.models,this.apiClient),this.caches=new ti(this.apiClient),this.files=new bi(this.apiClient),this.operations=new Js(this.apiClient),this.authTokens=new pc(this.apiClient),this.tunings=new cu(this.apiClient),this.fileSearchStores=new xc(this.apiClient)}};function Su(e){return e.thought===!0}function Cu(e,t){return typeof t==`string`&&t.length>0?t:e}const wu=/^[A-Za-z0-9+/]+={0,2}$/;function Tu(e){return!e||e.length%4!=0?!1:wu.test(e)}function Eu(e,t){return e&&Tu(t)?t:void 0}function Du(e){return e.startsWith(`claude-`)||e.startsWith(`gpt-oss-`)}function Ou(e){let t=e.toLowerCase().match(/^gemini(?:-live)?-(\d+)/);if(t)return Number.parseInt(t[1],10)}function ku(e){let t=Ou(e);return t===void 0||t>=3}function Au(e,t){let i=[],a=n(t.messages,e,t=>Du(e.id)?t.replace(/[^a-zA-Z0-9_-]/g,`_`).slice(0,64):t);for(let t of a)if(t.role===`user`)if(typeof t.content==`string`)i.push({role:`user`,parts:[{text:r(t.content)}]});else{let e=t.content.map(e=>e.type===`text`?{text:r(e.text)}:{inlineData:{mimeType:e.mimeType,data:e.data}});if(e.length===0)continue;i.push({role:`user`,parts:e})}else if(t.role===`assistant`){let n=[],a=t.provider===e.provider&&t.model===e.id;for(let i of t.content)if(i.type===`text`){if(!i.text||i.text.trim()===``)continue;let e=Eu(a,i.textSignature);n.push({text:r(i.text),...e&&{thoughtSignature:e}})}else if(i.type===`thinking`){if(!i.thinking||i.thinking.trim()===``)continue;if(a){let e=Eu(a,i.thinkingSignature);n.push({thought:!0,text:r(i.thinking),...e&&{thoughtSignature:e}})}else n.push({text:r(i.thinking)})}else if(i.type===`toolCall`){let t=Eu(a,i.thoughtSignature),r={functionCall:{name:i.name,args:i.arguments??{},...Du(e.id)?{id:i.id}:{}},...t&&{thoughtSignature:t}};n.push(r)}if(n.length===0)continue;i.push({role:`model`,parts:n})}else if(t.role===`toolResult`){let n=t.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
371
|
+
`),a=e.input.includes(`image`)?t.content.filter(e=>e.type===`image`):[],o=n.length>0,s=a.length>0,c=ku(e.id),l=o?r(n):s?`(see attached image)`:``,u=a.map(e=>({inlineData:{mimeType:e.mimeType,data:e.data}})),d=Du(e.id),f={functionResponse:{name:t.toolName,response:t.isError?{error:l}:{output:l},...s&&c&&{parts:u},...d?{id:t.toolCallId}:{}}},p=i[i.length-1];p?.role===`user`&&p.parts?.some(e=>e.functionResponse)?p.parts.push(f):i.push({role:`user`,parts:[f]}),s&&!c&&i.push({role:`user`,parts:[{text:`Tool result image:`},...u]})}return i}const ju=new Set([`$schema`,`$id`,`$anchor`,`$dynamicAnchor`,`$vocabulary`,`$comment`,`$defs`,`definitions`]);function Mu(e){if(typeof e!=`object`||!e||Array.isArray(e))return e;let t={};for(let[n,r]of Object.entries(e))ju.has(n)||(t[n]=Mu(r));return t}function Nu(e,t=!1){if(e.length!==0)return[{functionDeclarations:e.map(e=>({name:e.name,description:e.description,...t?{parameters:Mu(e.parameters)}:{parametersJsonSchema:e.parameters}}))}]}function Pu(e){let t=Ou(e);return t!==void 0&&t>=3}function Fu(e){switch(e){case`auto`:return P.AUTO;case`none`:return P.NONE;case`any`:return P.ANY;default:return P.AUTO}}function Iu(e,t,n){let r=e.some(e=>i(e,n)===!0);return t===`none`||t===`any`?Fu(t):r?P.VALIDATED:t?Fu(t):void 0}function Lu(e){switch(e){case F.STOP:return`stop`;case F.MAX_TOKENS:return`length`;case F.BLOCKLIST:case F.PROHIBITED_CONTENT:case F.SPII:case F.SAFETY:case F.IMAGE_SAFETY:case F.IMAGE_PROHIBITED_CONTENT:case F.IMAGE_RECITATION:case F.IMAGE_OTHER:case F.RECITATION:case F.FINISH_REASON_UNSPECIFIED:case F.OTHER:case F.LANGUAGE:case F.MALFORMED_FUNCTION_CALL:case F.UNEXPECTED_TOOL_CALL:case F.NO_IMAGE:return`error`;default:throw Error(`Unhandled stop reason: ${e}`)}}export{Iu as a,xu as c,Lu as i,Pe as l,Nu as n,Cu as o,Su as r,Pu as s,Au as t,ue as u};
|