@omniyat/aimodule 1.0.2 → 1.0.6

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/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import e from"file-type";function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var n,o,i,r,s,l,a,u,c,p,d,h,f,m,g,y={},v={exports:{}},E={};function T(){return i||(i=1,e=E,t=function(){if(o)return n;function e(e,t){"boolean"==typeof t&&(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))}return o=1,n=e,e.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)},e.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null},e.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(new Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var n=this._timeouts.shift();if(void 0===n){if(!this._cachedTimeouts)return!1;this._errors.splice(0,this._errors.length-1),n=this._cachedTimeouts.slice(-1)}var o=this;return this._timer=setTimeout(function(){o._attempts++,o._operationTimeoutCb&&(o._timeout=setTimeout(function(){o._operationTimeoutCb(o._attempts)},o._operationTimeout),o._options.unref&&o._timeout.unref()),o._fn(o._attempts)},n),this._options.unref&&this._timer.unref(),!0},e.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)},e.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)},e.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)},e.prototype.start=e.prototype.try,e.prototype.errors=function(){return this._errors},e.prototype.attempts=function(){return this._attempts},e.prototype.mainError=function(){if(0===this._errors.length)return null;for(var e={},t=null,n=0,o=0;o<this._errors.length;o++){var i=this._errors[o],r=i.message,s=(e[r]||0)+1;e[r]=s,s>=n&&(t=i,n=s)}return t},n}(),e.operation=function(n){var o=e.timeouts(n);return new t(o,{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:1e3,maxTimeout:1/0,randomize:!1};for(var n in e)t[n]=e[n];if(t.minTimeout>t.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var o=[],i=0;i<t.retries;i++)o.push(this.createTimeout(i,t));return e&&e.forever&&!o.length&&o.push(this.createTimeout(i,t)),o.sort(function(e,t){return e-t}),o},e.createTimeout=function(e,t){var n=t.randomize?Math.random()+1:1,o=Math.round(n*Math.max(t.minTimeout,1)*Math.pow(t.factor,e));return o=Math.min(o,t.maxTimeout)},e.wrap=function(t,n,o){if(n instanceof Array&&(o=n,n=null),!o)for(var i in o=[],t)"function"==typeof t[i]&&o.push(i);for(var r=0;r<o.length;r++){var s=o[r],l=t[s];t[s]=function(o){var i=e.operation(n),r=Array.prototype.slice.call(arguments,1),s=r.pop();r.push(function(e){i.retry(e)||(e&&(arguments[0]=i.mainError()),s.apply(this,arguments))}),i.attempt(function(){o.apply(t,r)})}.bind(t,l),t[s].options=n}}),E;var e,t}function I(){return s?r:(s=1,r=T())}function _(){if(l)return v.exports;l=1;const e=I(),t=["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"];class n extends Error{constructor(e){super(),e instanceof Error?(this.originalError=e,({message:e}=e)):(this.originalError=new Error(e),this.originalError.stack=this.stack),this.name="AbortError",this.message=e}}const o=(o,i)=>new Promise((r,s)=>{i={onFailedAttempt:()=>{},retries:10,...i};const l=e.operation(i);l.attempt(async e=>{try{r(await o(e))}catch(o){if(!(o instanceof Error))return void s(new TypeError(`Non-error was thrown: "${o}". You should only throw errors.`));if(o instanceof n)l.stop(),s(o.originalError);else if(o instanceof TypeError&&(a=o.message,!t.includes(a)))l.stop(),s(o);else{((e,t,n)=>{const o=n.retries-(t-1);e.attemptNumber=t,e.retriesLeft=o})(o,e,i);try{await i.onFailedAttempt(o)}catch(e){return void s(e)}l.retry(o)||s(l.mainError())}}var a})});return v.exports=o,v.exports.default=o,v.exports.AbortError=n,v.exports}function S(){return a||(a=1,function(e){var t,n,o,i,r,s,l,a,u,c,p,d,h,f,m,g,y,v,E,T,I,S,A,C,O,b,R,w,N,P,M,D,U,x,L,k,q,G,F,H,j,V,B,J,$,Y,K,W,z,X,Q,Z,ee,te,ne,oe,ie,re,se=_();
1
+ import e from"file-type";function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var n,o,i,r,s,l,a,u,c,p,d,h,f,m,g,y={},v={exports:{}},E={};function T(){return i||(i=1,e=E,t=function(){if(o)return n;function e(e,t){"boolean"==typeof t&&(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))}return o=1,n=e,e.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)},e.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null},e.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(new Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var n=this._timeouts.shift();if(void 0===n){if(!this._cachedTimeouts)return!1;this._errors.splice(0,this._errors.length-1),n=this._cachedTimeouts.slice(-1)}var o=this;return this._timer=setTimeout(function(){o._attempts++,o._operationTimeoutCb&&(o._timeout=setTimeout(function(){o._operationTimeoutCb(o._attempts)},o._operationTimeout),o._options.unref&&o._timeout.unref()),o._fn(o._attempts)},n),this._options.unref&&this._timer.unref(),!0},e.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)},e.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)},e.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)},e.prototype.start=e.prototype.try,e.prototype.errors=function(){return this._errors},e.prototype.attempts=function(){return this._attempts},e.prototype.mainError=function(){if(0===this._errors.length)return null;for(var e={},t=null,n=0,o=0;o<this._errors.length;o++){var i=this._errors[o],r=i.message,s=(e[r]||0)+1;e[r]=s,s>=n&&(t=i,n=s)}return t},n}(),e.operation=function(n){var o=e.timeouts(n);return new t(o,{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:1e3,maxTimeout:1/0,randomize:!1};for(var n in e)t[n]=e[n];if(t.minTimeout>t.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var o=[],i=0;i<t.retries;i++)o.push(this.createTimeout(i,t));return e&&e.forever&&!o.length&&o.push(this.createTimeout(i,t)),o.sort(function(e,t){return e-t}),o},e.createTimeout=function(e,t){var n=t.randomize?Math.random()+1:1,o=Math.round(n*Math.max(t.minTimeout,1)*Math.pow(t.factor,e));return o=Math.min(o,t.maxTimeout)},e.wrap=function(t,n,o){if(n instanceof Array&&(o=n,n=null),!o)for(var i in o=[],t)"function"==typeof t[i]&&o.push(i);for(var r=0;r<o.length;r++){var s=o[r],l=t[s];t[s]=function(o){var i=e.operation(n),r=Array.prototype.slice.call(arguments,1),s=r.pop();r.push(function(e){i.retry(e)||(e&&(arguments[0]=i.mainError()),s.apply(this,arguments))}),i.attempt(function(){o.apply(t,r)})}.bind(t,l),t[s].options=n}}),E;var e,t}function I(){return s?r:(s=1,r=T())}function _(){if(l)return v.exports;l=1;const e=I(),t=["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"];class n extends Error{constructor(e){super(),e instanceof Error?(this.originalError=e,({message:e}=e)):(this.originalError=new Error(e),this.originalError.stack=this.stack),this.name="AbortError",this.message=e}}const o=(o,i)=>new Promise((r,s)=>{i={onFailedAttempt:()=>{},retries:10,...i};const l=e.operation(i);l.attempt(async e=>{try{r(await o(e))}catch(o){if(!(o instanceof Error))return void s(new TypeError(`Non-error was thrown: "${o}". You should only throw errors.`));if(o instanceof n)l.stop(),s(o.originalError);else if(o instanceof TypeError&&(a=o.message,!t.includes(a)))l.stop(),s(o);else{((e,t,n)=>{const o=n.retries-(t-1);e.attemptNumber=t,e.retriesLeft=o})(o,e,i);try{await i.onFailedAttempt(o)}catch(e){return void s(e)}l.retry(o)||s(l.mainError())}}var a})});return v.exports=o,v.exports.default=o,v.exports.AbortError=n,v.exports}function S(){return a||(a=1,function(e){var t,n,o,i,r,s,l,a,u,c,p,d,h,f,m,g,y,v,E,T,I,S,A,C,O,b,R,w,N,P,M,D,U,x,L,k,G,q,F,H,j,V,B,J,Y,$,K,W,z,X,Q,Z,ee,te,ne,oe,ie,re,se=_();
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2025 Google LLC
@@ -24,7 +24,7 @@ class le{}function ae(e,t){return e.replace(/\{([^}]+)\}/g,(e,n)=>{if(Object.pro
24
24
  * @license
25
25
  * Copyright 2025 Google LLC
26
26
  * SPDX-License-Identifier: Apache-2.0
27
- */(n));return t}(e))),ue(t,["generatedVideos"],e)}const o=ce(e,["raiMediaFilteredCount"]);null!=o&&ue(t,["raiMediaFilteredCount"],o);const i=ce(e,["raiMediaFilteredReasons"]);null!=i&&ue(t,["raiMediaFilteredReasons"],i);return t}(s)),t}function me(e){const t={},n=ce(e,["name"]);null!=n&&ue(t,["name"],n);const o=ce(e,["metadata"]);null!=o&&ue(t,["metadata"],o);const i=ce(e,["done"]);null!=i&&ue(t,["done"],i);const r=ce(e,["error"]);null!=r&&ue(t,["error"],r);const s=ce(e,["response"]);return null!=s&&ue(t,["response"],function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["parent"]);null!=o&&ue(t,["parent"],o);const i=ce(e,["documentName"]);null!=i&&ue(t,["documentName"],i);return t}(s)),t}function ge(e){const t={},n=ce(e,["name"]);null!=n&&ue(t,["name"],n);const o=ce(e,["metadata"]);null!=o&&ue(t,["metadata"],o);const i=ce(e,["done"]);null!=i&&ue(t,["done"],i);const r=ce(e,["error"]);null!=r&&ue(t,["error"],r);const s=ce(e,["response"]);return null!=s&&ue(t,["response"],function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["parent"]);null!=o&&ue(t,["parent"],o);const i=ce(e,["documentName"]);null!=i&&ue(t,["documentName"],i);return t}(s)),t}e.Outcome=void 0,(t=e.Outcome||(e.Outcome={})).OUTCOME_UNSPECIFIED="OUTCOME_UNSPECIFIED",t.OUTCOME_OK="OUTCOME_OK",t.OUTCOME_FAILED="OUTCOME_FAILED",t.OUTCOME_DEADLINE_EXCEEDED="OUTCOME_DEADLINE_EXCEEDED",e.Language=void 0,(n=e.Language||(e.Language={})).LANGUAGE_UNSPECIFIED="LANGUAGE_UNSPECIFIED",n.PYTHON="PYTHON",e.FunctionResponseScheduling=void 0,(o=e.FunctionResponseScheduling||(e.FunctionResponseScheduling={})).SCHEDULING_UNSPECIFIED="SCHEDULING_UNSPECIFIED",o.SILENT="SILENT",o.WHEN_IDLE="WHEN_IDLE",o.INTERRUPT="INTERRUPT",e.Type=void 0,(i=e.Type||(e.Type={})).TYPE_UNSPECIFIED="TYPE_UNSPECIFIED",i.STRING="STRING",i.NUMBER="NUMBER",i.INTEGER="INTEGER",i.BOOLEAN="BOOLEAN",i.ARRAY="ARRAY",i.OBJECT="OBJECT",i.NULL="NULL",e.ApiSpec=void 0,(r=e.ApiSpec||(e.ApiSpec={})).API_SPEC_UNSPECIFIED="API_SPEC_UNSPECIFIED",r.SIMPLE_SEARCH="SIMPLE_SEARCH",r.ELASTIC_SEARCH="ELASTIC_SEARCH",e.AuthType=void 0,(s=e.AuthType||(e.AuthType={})).AUTH_TYPE_UNSPECIFIED="AUTH_TYPE_UNSPECIFIED",s.NO_AUTH="NO_AUTH",s.API_KEY_AUTH="API_KEY_AUTH",s.HTTP_BASIC_AUTH="HTTP_BASIC_AUTH",s.GOOGLE_SERVICE_ACCOUNT_AUTH="GOOGLE_SERVICE_ACCOUNT_AUTH",s.OAUTH="OAUTH",s.OIDC_AUTH="OIDC_AUTH",e.HttpElementLocation=void 0,(l=e.HttpElementLocation||(e.HttpElementLocation={})).HTTP_IN_UNSPECIFIED="HTTP_IN_UNSPECIFIED",l.HTTP_IN_QUERY="HTTP_IN_QUERY",l.HTTP_IN_HEADER="HTTP_IN_HEADER",l.HTTP_IN_PATH="HTTP_IN_PATH",l.HTTP_IN_BODY="HTTP_IN_BODY",l.HTTP_IN_COOKIE="HTTP_IN_COOKIE",e.PhishBlockThreshold=void 0,(a=e.PhishBlockThreshold||(e.PhishBlockThreshold={})).PHISH_BLOCK_THRESHOLD_UNSPECIFIED="PHISH_BLOCK_THRESHOLD_UNSPECIFIED",a.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",a.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",a.BLOCK_HIGH_AND_ABOVE="BLOCK_HIGH_AND_ABOVE",a.BLOCK_HIGHER_AND_ABOVE="BLOCK_HIGHER_AND_ABOVE",a.BLOCK_VERY_HIGH_AND_ABOVE="BLOCK_VERY_HIGH_AND_ABOVE",a.BLOCK_ONLY_EXTREMELY_HIGH="BLOCK_ONLY_EXTREMELY_HIGH",e.Behavior=void 0,(u=e.Behavior||(e.Behavior={})).UNSPECIFIED="UNSPECIFIED",u.BLOCKING="BLOCKING",u.NON_BLOCKING="NON_BLOCKING",e.DynamicRetrievalConfigMode=void 0,(c=e.DynamicRetrievalConfigMode||(e.DynamicRetrievalConfigMode={})).MODE_UNSPECIFIED="MODE_UNSPECIFIED",c.MODE_DYNAMIC="MODE_DYNAMIC",e.FunctionCallingConfigMode=void 0,(p=e.FunctionCallingConfigMode||(e.FunctionCallingConfigMode={})).MODE_UNSPECIFIED="MODE_UNSPECIFIED",p.AUTO="AUTO",p.ANY="ANY",p.NONE="NONE",p.VALIDATED="VALIDATED",e.ThinkingLevel=void 0,(d=e.ThinkingLevel||(e.ThinkingLevel={})).THINKING_LEVEL_UNSPECIFIED="THINKING_LEVEL_UNSPECIFIED",d.LOW="LOW",d.MEDIUM="MEDIUM",d.HIGH="HIGH",d.MINIMAL="MINIMAL",e.HarmCategory=void 0,(h=e.HarmCategory||(e.HarmCategory={})).HARM_CATEGORY_UNSPECIFIED="HARM_CATEGORY_UNSPECIFIED",h.HARM_CATEGORY_HARASSMENT="HARM_CATEGORY_HARASSMENT",h.HARM_CATEGORY_HATE_SPEECH="HARM_CATEGORY_HATE_SPEECH",h.HARM_CATEGORY_SEXUALLY_EXPLICIT="HARM_CATEGORY_SEXUALLY_EXPLICIT",h.HARM_CATEGORY_DANGEROUS_CONTENT="HARM_CATEGORY_DANGEROUS_CONTENT",h.HARM_CATEGORY_CIVIC_INTEGRITY="HARM_CATEGORY_CIVIC_INTEGRITY",h.HARM_CATEGORY_IMAGE_HATE="HARM_CATEGORY_IMAGE_HATE",h.HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT="HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT",h.HARM_CATEGORY_IMAGE_HARASSMENT="HARM_CATEGORY_IMAGE_HARASSMENT",h.HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT="HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT",h.HARM_CATEGORY_JAILBREAK="HARM_CATEGORY_JAILBREAK",e.HarmBlockMethod=void 0,(f=e.HarmBlockMethod||(e.HarmBlockMethod={})).HARM_BLOCK_METHOD_UNSPECIFIED="HARM_BLOCK_METHOD_UNSPECIFIED",f.SEVERITY="SEVERITY",f.PROBABILITY="PROBABILITY",e.HarmBlockThreshold=void 0,(m=e.HarmBlockThreshold||(e.HarmBlockThreshold={})).HARM_BLOCK_THRESHOLD_UNSPECIFIED="HARM_BLOCK_THRESHOLD_UNSPECIFIED",m.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",m.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",m.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",m.BLOCK_NONE="BLOCK_NONE",m.OFF="OFF",e.FinishReason=void 0,(g=e.FinishReason||(e.FinishReason={})).FINISH_REASON_UNSPECIFIED="FINISH_REASON_UNSPECIFIED",g.STOP="STOP",g.MAX_TOKENS="MAX_TOKENS",g.SAFETY="SAFETY",g.RECITATION="RECITATION",g.LANGUAGE="LANGUAGE",g.OTHER="OTHER",g.BLOCKLIST="BLOCKLIST",g.PROHIBITED_CONTENT="PROHIBITED_CONTENT",g.SPII="SPII",g.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",g.IMAGE_SAFETY="IMAGE_SAFETY",g.UNEXPECTED_TOOL_CALL="UNEXPECTED_TOOL_CALL",g.IMAGE_PROHIBITED_CONTENT="IMAGE_PROHIBITED_CONTENT",g.NO_IMAGE="NO_IMAGE",g.IMAGE_RECITATION="IMAGE_RECITATION",g.IMAGE_OTHER="IMAGE_OTHER",e.HarmProbability=void 0,(y=e.HarmProbability||(e.HarmProbability={})).HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",y.NEGLIGIBLE="NEGLIGIBLE",y.LOW="LOW",y.MEDIUM="MEDIUM",y.HIGH="HIGH",e.HarmSeverity=void 0,(v=e.HarmSeverity||(e.HarmSeverity={})).HARM_SEVERITY_UNSPECIFIED="HARM_SEVERITY_UNSPECIFIED",v.HARM_SEVERITY_NEGLIGIBLE="HARM_SEVERITY_NEGLIGIBLE",v.HARM_SEVERITY_LOW="HARM_SEVERITY_LOW",v.HARM_SEVERITY_MEDIUM="HARM_SEVERITY_MEDIUM",v.HARM_SEVERITY_HIGH="HARM_SEVERITY_HIGH",e.UrlRetrievalStatus=void 0,(E=e.UrlRetrievalStatus||(e.UrlRetrievalStatus={})).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",e.BlockedReason=void 0,(T=e.BlockedReason||(e.BlockedReason={})).BLOCKED_REASON_UNSPECIFIED="BLOCKED_REASON_UNSPECIFIED",T.SAFETY="SAFETY",T.OTHER="OTHER",T.BLOCKLIST="BLOCKLIST",T.PROHIBITED_CONTENT="PROHIBITED_CONTENT",T.IMAGE_SAFETY="IMAGE_SAFETY",T.MODEL_ARMOR="MODEL_ARMOR",T.JAILBREAK="JAILBREAK",e.TrafficType=void 0,(I=e.TrafficType||(e.TrafficType={})).TRAFFIC_TYPE_UNSPECIFIED="TRAFFIC_TYPE_UNSPECIFIED",I.ON_DEMAND="ON_DEMAND",I.PROVISIONED_THROUGHPUT="PROVISIONED_THROUGHPUT",e.Modality=void 0,(S=e.Modality||(e.Modality={})).MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",S.TEXT="TEXT",S.IMAGE="IMAGE",S.AUDIO="AUDIO",e.MediaResolution=void 0,(A=e.MediaResolution||(e.MediaResolution={})).MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",A.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",A.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",A.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH",e.TuningMode=void 0,(C=e.TuningMode||(e.TuningMode={})).TUNING_MODE_UNSPECIFIED="TUNING_MODE_UNSPECIFIED",C.TUNING_MODE_FULL="TUNING_MODE_FULL",C.TUNING_MODE_PEFT_ADAPTER="TUNING_MODE_PEFT_ADAPTER",e.AdapterSize=void 0,(O=e.AdapterSize||(e.AdapterSize={})).ADAPTER_SIZE_UNSPECIFIED="ADAPTER_SIZE_UNSPECIFIED",O.ADAPTER_SIZE_ONE="ADAPTER_SIZE_ONE",O.ADAPTER_SIZE_TWO="ADAPTER_SIZE_TWO",O.ADAPTER_SIZE_FOUR="ADAPTER_SIZE_FOUR",O.ADAPTER_SIZE_EIGHT="ADAPTER_SIZE_EIGHT",O.ADAPTER_SIZE_SIXTEEN="ADAPTER_SIZE_SIXTEEN",O.ADAPTER_SIZE_THIRTY_TWO="ADAPTER_SIZE_THIRTY_TWO",e.JobState=void 0,(b=e.JobState||(e.JobState={})).JOB_STATE_UNSPECIFIED="JOB_STATE_UNSPECIFIED",b.JOB_STATE_QUEUED="JOB_STATE_QUEUED",b.JOB_STATE_PENDING="JOB_STATE_PENDING",b.JOB_STATE_RUNNING="JOB_STATE_RUNNING",b.JOB_STATE_SUCCEEDED="JOB_STATE_SUCCEEDED",b.JOB_STATE_FAILED="JOB_STATE_FAILED",b.JOB_STATE_CANCELLING="JOB_STATE_CANCELLING",b.JOB_STATE_CANCELLED="JOB_STATE_CANCELLED",b.JOB_STATE_PAUSED="JOB_STATE_PAUSED",b.JOB_STATE_EXPIRED="JOB_STATE_EXPIRED",b.JOB_STATE_UPDATING="JOB_STATE_UPDATING",b.JOB_STATE_PARTIALLY_SUCCEEDED="JOB_STATE_PARTIALLY_SUCCEEDED",e.TuningTask=void 0,(R=e.TuningTask||(e.TuningTask={})).TUNING_TASK_UNSPECIFIED="TUNING_TASK_UNSPECIFIED",R.TUNING_TASK_I2V="TUNING_TASK_I2V",R.TUNING_TASK_T2V="TUNING_TASK_T2V",R.TUNING_TASK_R2V="TUNING_TASK_R2V",e.PartMediaResolutionLevel=void 0,(w=e.PartMediaResolutionLevel||(e.PartMediaResolutionLevel={})).MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",w.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",w.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",w.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH",w.MEDIA_RESOLUTION_ULTRA_HIGH="MEDIA_RESOLUTION_ULTRA_HIGH",e.ResourceScope=void 0,(e.ResourceScope||(e.ResourceScope={})).COLLECTION="COLLECTION",e.FeatureSelectionPreference=void 0,(N=e.FeatureSelectionPreference||(e.FeatureSelectionPreference={})).FEATURE_SELECTION_PREFERENCE_UNSPECIFIED="FEATURE_SELECTION_PREFERENCE_UNSPECIFIED",N.PRIORITIZE_QUALITY="PRIORITIZE_QUALITY",N.BALANCED="BALANCED",N.PRIORITIZE_COST="PRIORITIZE_COST",e.Environment=void 0,(P=e.Environment||(e.Environment={})).ENVIRONMENT_UNSPECIFIED="ENVIRONMENT_UNSPECIFIED",P.ENVIRONMENT_BROWSER="ENVIRONMENT_BROWSER",e.EmbeddingApiType=void 0,(M=e.EmbeddingApiType||(e.EmbeddingApiType={})).PREDICT="PREDICT",M.EMBED_CONTENT="EMBED_CONTENT",e.SafetyFilterLevel=void 0,(D=e.SafetyFilterLevel||(e.SafetyFilterLevel={})).BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",D.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",D.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",D.BLOCK_NONE="BLOCK_NONE",e.PersonGeneration=void 0,(U=e.PersonGeneration||(e.PersonGeneration={})).DONT_ALLOW="DONT_ALLOW",U.ALLOW_ADULT="ALLOW_ADULT",U.ALLOW_ALL="ALLOW_ALL",e.ImagePromptLanguage=void 0,(x=e.ImagePromptLanguage||(e.ImagePromptLanguage={})).auto="auto",x.en="en",x.ja="ja",x.ko="ko",x.hi="hi",x.zh="zh",x.pt="pt",x.es="es",e.MaskReferenceMode=void 0,(L=e.MaskReferenceMode||(e.MaskReferenceMode={})).MASK_MODE_DEFAULT="MASK_MODE_DEFAULT",L.MASK_MODE_USER_PROVIDED="MASK_MODE_USER_PROVIDED",L.MASK_MODE_BACKGROUND="MASK_MODE_BACKGROUND",L.MASK_MODE_FOREGROUND="MASK_MODE_FOREGROUND",L.MASK_MODE_SEMANTIC="MASK_MODE_SEMANTIC",e.ControlReferenceType=void 0,(k=e.ControlReferenceType||(e.ControlReferenceType={})).CONTROL_TYPE_DEFAULT="CONTROL_TYPE_DEFAULT",k.CONTROL_TYPE_CANNY="CONTROL_TYPE_CANNY",k.CONTROL_TYPE_SCRIBBLE="CONTROL_TYPE_SCRIBBLE",k.CONTROL_TYPE_FACE_MESH="CONTROL_TYPE_FACE_MESH",e.SubjectReferenceType=void 0,(q=e.SubjectReferenceType||(e.SubjectReferenceType={})).SUBJECT_TYPE_DEFAULT="SUBJECT_TYPE_DEFAULT",q.SUBJECT_TYPE_PERSON="SUBJECT_TYPE_PERSON",q.SUBJECT_TYPE_ANIMAL="SUBJECT_TYPE_ANIMAL",q.SUBJECT_TYPE_PRODUCT="SUBJECT_TYPE_PRODUCT",e.EditMode=void 0,(G=e.EditMode||(e.EditMode={})).EDIT_MODE_DEFAULT="EDIT_MODE_DEFAULT",G.EDIT_MODE_INPAINT_REMOVAL="EDIT_MODE_INPAINT_REMOVAL",G.EDIT_MODE_INPAINT_INSERTION="EDIT_MODE_INPAINT_INSERTION",G.EDIT_MODE_OUTPAINT="EDIT_MODE_OUTPAINT",G.EDIT_MODE_CONTROLLED_EDITING="EDIT_MODE_CONTROLLED_EDITING",G.EDIT_MODE_STYLE="EDIT_MODE_STYLE",G.EDIT_MODE_BGSWAP="EDIT_MODE_BGSWAP",G.EDIT_MODE_PRODUCT_IMAGE="EDIT_MODE_PRODUCT_IMAGE",e.SegmentMode=void 0,(F=e.SegmentMode||(e.SegmentMode={})).FOREGROUND="FOREGROUND",F.BACKGROUND="BACKGROUND",F.PROMPT="PROMPT",F.SEMANTIC="SEMANTIC",F.INTERACTIVE="INTERACTIVE",e.VideoGenerationReferenceType=void 0,(H=e.VideoGenerationReferenceType||(e.VideoGenerationReferenceType={})).ASSET="ASSET",H.STYLE="STYLE",e.VideoGenerationMaskMode=void 0,(j=e.VideoGenerationMaskMode||(e.VideoGenerationMaskMode={})).INSERT="INSERT",j.REMOVE="REMOVE",j.REMOVE_STATIC="REMOVE_STATIC",j.OUTPAINT="OUTPAINT",e.VideoCompressionQuality=void 0,(V=e.VideoCompressionQuality||(e.VideoCompressionQuality={})).OPTIMIZED="OPTIMIZED",V.LOSSLESS="LOSSLESS",e.TuningMethod=void 0,(B=e.TuningMethod||(e.TuningMethod={})).SUPERVISED_FINE_TUNING="SUPERVISED_FINE_TUNING",B.PREFERENCE_TUNING="PREFERENCE_TUNING",B.DISTILLATION="DISTILLATION",e.DocumentState=void 0,(J=e.DocumentState||(e.DocumentState={})).STATE_UNSPECIFIED="STATE_UNSPECIFIED",J.STATE_PENDING="STATE_PENDING",J.STATE_ACTIVE="STATE_ACTIVE",J.STATE_FAILED="STATE_FAILED",e.FileState=void 0,($=e.FileState||(e.FileState={})).STATE_UNSPECIFIED="STATE_UNSPECIFIED",$.PROCESSING="PROCESSING",$.ACTIVE="ACTIVE",$.FAILED="FAILED",e.FileSource=void 0,(Y=e.FileSource||(e.FileSource={})).SOURCE_UNSPECIFIED="SOURCE_UNSPECIFIED",Y.UPLOADED="UPLOADED",Y.GENERATED="GENERATED",Y.REGISTERED="REGISTERED",e.TurnCompleteReason=void 0,(K=e.TurnCompleteReason||(e.TurnCompleteReason={})).TURN_COMPLETE_REASON_UNSPECIFIED="TURN_COMPLETE_REASON_UNSPECIFIED",K.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",K.RESPONSE_REJECTED="RESPONSE_REJECTED",K.NEED_MORE_INPUT="NEED_MORE_INPUT",e.MediaModality=void 0,(W=e.MediaModality||(e.MediaModality={})).MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",W.TEXT="TEXT",W.IMAGE="IMAGE",W.VIDEO="VIDEO",W.AUDIO="AUDIO",W.DOCUMENT="DOCUMENT",e.VadSignalType=void 0,(z=e.VadSignalType||(e.VadSignalType={})).VAD_SIGNAL_TYPE_UNSPECIFIED="VAD_SIGNAL_TYPE_UNSPECIFIED",z.VAD_SIGNAL_TYPE_SOS="VAD_SIGNAL_TYPE_SOS",z.VAD_SIGNAL_TYPE_EOS="VAD_SIGNAL_TYPE_EOS",e.VoiceActivityType=void 0,(X=e.VoiceActivityType||(e.VoiceActivityType={})).TYPE_UNSPECIFIED="TYPE_UNSPECIFIED",X.ACTIVITY_START="ACTIVITY_START",X.ACTIVITY_END="ACTIVITY_END",e.StartSensitivity=void 0,(Q=e.StartSensitivity||(e.StartSensitivity={})).START_SENSITIVITY_UNSPECIFIED="START_SENSITIVITY_UNSPECIFIED",Q.START_SENSITIVITY_HIGH="START_SENSITIVITY_HIGH",Q.START_SENSITIVITY_LOW="START_SENSITIVITY_LOW",e.EndSensitivity=void 0,(Z=e.EndSensitivity||(e.EndSensitivity={})).END_SENSITIVITY_UNSPECIFIED="END_SENSITIVITY_UNSPECIFIED",Z.END_SENSITIVITY_HIGH="END_SENSITIVITY_HIGH",Z.END_SENSITIVITY_LOW="END_SENSITIVITY_LOW",e.ActivityHandling=void 0,(ee=e.ActivityHandling||(e.ActivityHandling={})).ACTIVITY_HANDLING_UNSPECIFIED="ACTIVITY_HANDLING_UNSPECIFIED",ee.START_OF_ACTIVITY_INTERRUPTS="START_OF_ACTIVITY_INTERRUPTS",ee.NO_INTERRUPTION="NO_INTERRUPTION",e.TurnCoverage=void 0,(te=e.TurnCoverage||(e.TurnCoverage={})).TURN_COVERAGE_UNSPECIFIED="TURN_COVERAGE_UNSPECIFIED",te.TURN_INCLUDES_ONLY_ACTIVITY="TURN_INCLUDES_ONLY_ACTIVITY",te.TURN_INCLUDES_ALL_INPUT="TURN_INCLUDES_ALL_INPUT",e.Scale=void 0,(ne=e.Scale||(e.Scale={})).SCALE_UNSPECIFIED="SCALE_UNSPECIFIED",ne.C_MAJOR_A_MINOR="C_MAJOR_A_MINOR",ne.D_FLAT_MAJOR_B_FLAT_MINOR="D_FLAT_MAJOR_B_FLAT_MINOR",ne.D_MAJOR_B_MINOR="D_MAJOR_B_MINOR",ne.E_FLAT_MAJOR_C_MINOR="E_FLAT_MAJOR_C_MINOR",ne.E_MAJOR_D_FLAT_MINOR="E_MAJOR_D_FLAT_MINOR",ne.F_MAJOR_D_MINOR="F_MAJOR_D_MINOR",ne.G_FLAT_MAJOR_E_FLAT_MINOR="G_FLAT_MAJOR_E_FLAT_MINOR",ne.G_MAJOR_E_MINOR="G_MAJOR_E_MINOR",ne.A_FLAT_MAJOR_F_MINOR="A_FLAT_MAJOR_F_MINOR",ne.A_MAJOR_G_FLAT_MINOR="A_MAJOR_G_FLAT_MINOR",ne.B_FLAT_MAJOR_G_MINOR="B_FLAT_MAJOR_G_MINOR",ne.B_MAJOR_A_FLAT_MINOR="B_MAJOR_A_FLAT_MINOR",e.MusicGenerationMode=void 0,(oe=e.MusicGenerationMode||(e.MusicGenerationMode={})).MUSIC_GENERATION_MODE_UNSPECIFIED="MUSIC_GENERATION_MODE_UNSPECIFIED",oe.QUALITY="QUALITY",oe.DIVERSITY="DIVERSITY",oe.VOCALIZATION="VOCALIZATION",e.LiveMusicPlaybackControl=void 0,(ie=e.LiveMusicPlaybackControl||(e.LiveMusicPlaybackControl={})).PLAYBACK_CONTROL_UNSPECIFIED="PLAYBACK_CONTROL_UNSPECIFIED",ie.PLAY="PLAY",ie.PAUSE="PAUSE",ie.STOP="STOP",ie.RESET_CONTEXT="RESET_CONTEXT";function ye(e){return{text:e}}function ve(e){return"object"==typeof e&&null!==e&&("fileData"in e||"text"in e||"functionCall"in e||"functionResponse"in e||"inlineData"in e||"videoMetadata"in e||"codeExecutionResult"in e||"executableCode"in e)}function Ee(e){const t=[];if("string"==typeof e)t.push(ye(e));else if(ve(e))t.push(e);else{if(!Array.isArray(e))throw new Error("partOrString must be a Part object, string, or array");if(0===e.length)throw new Error("partOrString cannot be an empty array");for(const n of e)if("string"==typeof n)t.push(ye(n));else{if(!ve(n))throw new Error("element in PartUnion must be a Part object or string");t.push(n)}}return t}class Te{constructor(e){const t={};for(const n of e.headers.entries())t[n[0]]=n[1];this.headers=t,this.responseInternal=e}json(){return this.responseInternal.json()}}class Ie{get text(){var e,t,n,o,i,r,s,l;if(0===(null===(o=null===(n=null===(t=null===(e=this.candidates)||void 0===e?void 0:e[0])||void 0===t?void 0:t.content)||void 0===n?void 0:n.parts)||void 0===o?void 0:o.length))return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning text from the first one.");let a="",u=!1;const c=[];for(const e of null!==(l=null===(s=null===(r=null===(i=this.candidates)||void 0===i?void 0:i[0])||void 0===r?void 0:r.content)||void 0===s?void 0:s.parts)&&void 0!==l?l:[]){for(const[t,n]of Object.entries(e))"text"===t||"thought"===t||"thoughtSignature"===t||null===n&&void 0===n||c.push(t);if("string"==typeof e.text){if("boolean"==typeof e.thought&&e.thought)continue;u=!0,a+=e.text}}return c.length>0&&console.warn(`there are non-text parts ${c} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),u?a:void 0}get data(){var e,t,n,o,i,r,s,l;if(0===(null===(o=null===(n=null===(t=null===(e=this.candidates)||void 0===e?void 0:e[0])||void 0===t?void 0:t.content)||void 0===n?void 0:n.parts)||void 0===o?void 0:o.length))return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning data from the first one.");let a="";const u=[];for(const e of null!==(l=null===(s=null===(r=null===(i=this.candidates)||void 0===i?void 0:i[0])||void 0===r?void 0:r.content)||void 0===s?void 0:s.parts)&&void 0!==l?l:[]){for(const[t,n]of Object.entries(e))"inlineData"===t||null===n&&void 0===n||u.push(t);e.inlineData&&"string"==typeof e.inlineData.data&&(a+=atob(e.inlineData.data))}return u.length>0&&console.warn(`there are non-data parts ${u} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),a.length>0?btoa(a):void 0}get functionCalls(){var e,t,n,o,i,r,s,l;if(0===(null===(o=null===(n=null===(t=null===(e=this.candidates)||void 0===e?void 0:e[0])||void 0===t?void 0:t.content)||void 0===n?void 0:n.parts)||void 0===o?void 0:o.length))return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning function calls from the first one.");const a=null===(l=null===(s=null===(r=null===(i=this.candidates)||void 0===i?void 0:i[0])||void 0===r?void 0:r.content)||void 0===s?void 0:s.parts)||void 0===l?void 0:l.filter(e=>e.functionCall).map(e=>e.functionCall).filter(e=>void 0!==e);return 0!==(null==a?void 0:a.length)?a:void 0}get executableCode(){var e,t,n,o,i,r,s,l,a;if(0===(null===(o=null===(n=null===(t=null===(e=this.candidates)||void 0===e?void 0:e[0])||void 0===t?void 0:t.content)||void 0===n?void 0:n.parts)||void 0===o?void 0:o.length))return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning executable code from the first one.");const u=null===(l=null===(s=null===(r=null===(i=this.candidates)||void 0===i?void 0:i[0])||void 0===r?void 0:r.content)||void 0===s?void 0:s.parts)||void 0===l?void 0:l.filter(e=>e.executableCode).map(e=>e.executableCode).filter(e=>void 0!==e);return 0!==(null==u?void 0:u.length)?null===(a=null==u?void 0:u[0])||void 0===a?void 0:a.code:void 0}get codeExecutionResult(){var e,t,n,o,i,r,s,l,a;if(0===(null===(o=null===(n=null===(t=null===(e=this.candidates)||void 0===e?void 0:e[0])||void 0===t?void 0:t.content)||void 0===n?void 0:n.parts)||void 0===o?void 0:o.length))return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning code execution result from the first one.");const u=null===(l=null===(s=null===(r=null===(i=this.candidates)||void 0===i?void 0:i[0])||void 0===r?void 0:r.content)||void 0===s?void 0:s.parts)||void 0===l?void 0:l.filter(e=>e.codeExecutionResult).map(e=>e.codeExecutionResult).filter(e=>void 0!==e);return 0!==(null==u?void 0:u.length)?null===(a=null==u?void 0:u[0])||void 0===a?void 0:a.output:void 0}}class _e{}class Se{}class Ae{}class Ce{}class Oe{}class be{}class Re{}class we{}class Ne{}class Pe{}class Me{_fromAPIResponse({apiResponse:e,_isVertexAI:t}){const n=new Me;let o;const i=e;return o=t?fe(i):he(i),Object.assign(n,o),n}}class De{}class Ue{}class xe{}class Le{}class ke{}class qe{}class Ge{}class Fe{_fromAPIResponse({apiResponse:e,_isVertexAI:t}){const n=new Fe,o=me(e);return Object.assign(n,o),n}}class He{}class je{}class Ve{}class Be{}class Je{}class $e{get text(){var e,t,n;let o="",i=!1;const r=[];for(const s of null!==(n=null===(t=null===(e=this.serverContent)||void 0===e?void 0:e.modelTurn)||void 0===t?void 0:t.parts)&&void 0!==n?n:[]){for(const[e,t]of Object.entries(s))"text"!==e&&"thought"!==e&&null!==t&&r.push(e);if("string"==typeof s.text){if("boolean"==typeof s.thought&&s.thought)continue;i=!0,o+=s.text}}return r.length>0&&console.warn(`there are non-text parts ${r} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),i?o:void 0}get data(){var e,t,n;let o="";const i=[];for(const r of null!==(n=null===(t=null===(e=this.serverContent)||void 0===e?void 0:e.modelTurn)||void 0===t?void 0:t.parts)&&void 0!==n?n:[]){for(const[e,t]of Object.entries(r))"inlineData"!==e&&null!==t&&i.push(e);r.inlineData&&"string"==typeof r.inlineData.data&&(o+=atob(r.inlineData.data))}return i.length>0&&console.warn(`there are non-data parts ${i} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),o.length>0?btoa(o):void 0}}class Ye{get audioChunk(){if(this.serverContent&&this.serverContent.audioChunks&&this.serverContent.audioChunks.length>0)return this.serverContent.audioChunks[0]}}class Ke{_fromAPIResponse({apiResponse:e,_isVertexAI:t}){const n=new Ke,o=ge(e);return Object.assign(n,o),n}}
27
+ */(n));return t}(e))),ue(t,["generatedVideos"],e)}const o=ce(e,["raiMediaFilteredCount"]);null!=o&&ue(t,["raiMediaFilteredCount"],o);const i=ce(e,["raiMediaFilteredReasons"]);null!=i&&ue(t,["raiMediaFilteredReasons"],i);return t}(s)),t}function me(e){const t={},n=ce(e,["name"]);null!=n&&ue(t,["name"],n);const o=ce(e,["metadata"]);null!=o&&ue(t,["metadata"],o);const i=ce(e,["done"]);null!=i&&ue(t,["done"],i);const r=ce(e,["error"]);null!=r&&ue(t,["error"],r);const s=ce(e,["response"]);return null!=s&&ue(t,["response"],function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["parent"]);null!=o&&ue(t,["parent"],o);const i=ce(e,["documentName"]);null!=i&&ue(t,["documentName"],i);return t}(s)),t}function ge(e){const t={},n=ce(e,["name"]);null!=n&&ue(t,["name"],n);const o=ce(e,["metadata"]);null!=o&&ue(t,["metadata"],o);const i=ce(e,["done"]);null!=i&&ue(t,["done"],i);const r=ce(e,["error"]);null!=r&&ue(t,["error"],r);const s=ce(e,["response"]);return null!=s&&ue(t,["response"],function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["parent"]);null!=o&&ue(t,["parent"],o);const i=ce(e,["documentName"]);null!=i&&ue(t,["documentName"],i);return t}(s)),t}e.Outcome=void 0,(t=e.Outcome||(e.Outcome={})).OUTCOME_UNSPECIFIED="OUTCOME_UNSPECIFIED",t.OUTCOME_OK="OUTCOME_OK",t.OUTCOME_FAILED="OUTCOME_FAILED",t.OUTCOME_DEADLINE_EXCEEDED="OUTCOME_DEADLINE_EXCEEDED",e.Language=void 0,(n=e.Language||(e.Language={})).LANGUAGE_UNSPECIFIED="LANGUAGE_UNSPECIFIED",n.PYTHON="PYTHON",e.FunctionResponseScheduling=void 0,(o=e.FunctionResponseScheduling||(e.FunctionResponseScheduling={})).SCHEDULING_UNSPECIFIED="SCHEDULING_UNSPECIFIED",o.SILENT="SILENT",o.WHEN_IDLE="WHEN_IDLE",o.INTERRUPT="INTERRUPT",e.Type=void 0,(i=e.Type||(e.Type={})).TYPE_UNSPECIFIED="TYPE_UNSPECIFIED",i.STRING="STRING",i.NUMBER="NUMBER",i.INTEGER="INTEGER",i.BOOLEAN="BOOLEAN",i.ARRAY="ARRAY",i.OBJECT="OBJECT",i.NULL="NULL",e.ApiSpec=void 0,(r=e.ApiSpec||(e.ApiSpec={})).API_SPEC_UNSPECIFIED="API_SPEC_UNSPECIFIED",r.SIMPLE_SEARCH="SIMPLE_SEARCH",r.ELASTIC_SEARCH="ELASTIC_SEARCH",e.AuthType=void 0,(s=e.AuthType||(e.AuthType={})).AUTH_TYPE_UNSPECIFIED="AUTH_TYPE_UNSPECIFIED",s.NO_AUTH="NO_AUTH",s.API_KEY_AUTH="API_KEY_AUTH",s.HTTP_BASIC_AUTH="HTTP_BASIC_AUTH",s.GOOGLE_SERVICE_ACCOUNT_AUTH="GOOGLE_SERVICE_ACCOUNT_AUTH",s.OAUTH="OAUTH",s.OIDC_AUTH="OIDC_AUTH",e.HttpElementLocation=void 0,(l=e.HttpElementLocation||(e.HttpElementLocation={})).HTTP_IN_UNSPECIFIED="HTTP_IN_UNSPECIFIED",l.HTTP_IN_QUERY="HTTP_IN_QUERY",l.HTTP_IN_HEADER="HTTP_IN_HEADER",l.HTTP_IN_PATH="HTTP_IN_PATH",l.HTTP_IN_BODY="HTTP_IN_BODY",l.HTTP_IN_COOKIE="HTTP_IN_COOKIE",e.PhishBlockThreshold=void 0,(a=e.PhishBlockThreshold||(e.PhishBlockThreshold={})).PHISH_BLOCK_THRESHOLD_UNSPECIFIED="PHISH_BLOCK_THRESHOLD_UNSPECIFIED",a.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",a.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",a.BLOCK_HIGH_AND_ABOVE="BLOCK_HIGH_AND_ABOVE",a.BLOCK_HIGHER_AND_ABOVE="BLOCK_HIGHER_AND_ABOVE",a.BLOCK_VERY_HIGH_AND_ABOVE="BLOCK_VERY_HIGH_AND_ABOVE",a.BLOCK_ONLY_EXTREMELY_HIGH="BLOCK_ONLY_EXTREMELY_HIGH",e.Behavior=void 0,(u=e.Behavior||(e.Behavior={})).UNSPECIFIED="UNSPECIFIED",u.BLOCKING="BLOCKING",u.NON_BLOCKING="NON_BLOCKING",e.DynamicRetrievalConfigMode=void 0,(c=e.DynamicRetrievalConfigMode||(e.DynamicRetrievalConfigMode={})).MODE_UNSPECIFIED="MODE_UNSPECIFIED",c.MODE_DYNAMIC="MODE_DYNAMIC",e.FunctionCallingConfigMode=void 0,(p=e.FunctionCallingConfigMode||(e.FunctionCallingConfigMode={})).MODE_UNSPECIFIED="MODE_UNSPECIFIED",p.AUTO="AUTO",p.ANY="ANY",p.NONE="NONE",p.VALIDATED="VALIDATED",e.ThinkingLevel=void 0,(d=e.ThinkingLevel||(e.ThinkingLevel={})).THINKING_LEVEL_UNSPECIFIED="THINKING_LEVEL_UNSPECIFIED",d.LOW="LOW",d.MEDIUM="MEDIUM",d.HIGH="HIGH",d.MINIMAL="MINIMAL",e.HarmCategory=void 0,(h=e.HarmCategory||(e.HarmCategory={})).HARM_CATEGORY_UNSPECIFIED="HARM_CATEGORY_UNSPECIFIED",h.HARM_CATEGORY_HARASSMENT="HARM_CATEGORY_HARASSMENT",h.HARM_CATEGORY_HATE_SPEECH="HARM_CATEGORY_HATE_SPEECH",h.HARM_CATEGORY_SEXUALLY_EXPLICIT="HARM_CATEGORY_SEXUALLY_EXPLICIT",h.HARM_CATEGORY_DANGEROUS_CONTENT="HARM_CATEGORY_DANGEROUS_CONTENT",h.HARM_CATEGORY_CIVIC_INTEGRITY="HARM_CATEGORY_CIVIC_INTEGRITY",h.HARM_CATEGORY_IMAGE_HATE="HARM_CATEGORY_IMAGE_HATE",h.HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT="HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT",h.HARM_CATEGORY_IMAGE_HARASSMENT="HARM_CATEGORY_IMAGE_HARASSMENT",h.HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT="HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT",h.HARM_CATEGORY_JAILBREAK="HARM_CATEGORY_JAILBREAK",e.HarmBlockMethod=void 0,(f=e.HarmBlockMethod||(e.HarmBlockMethod={})).HARM_BLOCK_METHOD_UNSPECIFIED="HARM_BLOCK_METHOD_UNSPECIFIED",f.SEVERITY="SEVERITY",f.PROBABILITY="PROBABILITY",e.HarmBlockThreshold=void 0,(m=e.HarmBlockThreshold||(e.HarmBlockThreshold={})).HARM_BLOCK_THRESHOLD_UNSPECIFIED="HARM_BLOCK_THRESHOLD_UNSPECIFIED",m.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",m.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",m.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",m.BLOCK_NONE="BLOCK_NONE",m.OFF="OFF",e.FinishReason=void 0,(g=e.FinishReason||(e.FinishReason={})).FINISH_REASON_UNSPECIFIED="FINISH_REASON_UNSPECIFIED",g.STOP="STOP",g.MAX_TOKENS="MAX_TOKENS",g.SAFETY="SAFETY",g.RECITATION="RECITATION",g.LANGUAGE="LANGUAGE",g.OTHER="OTHER",g.BLOCKLIST="BLOCKLIST",g.PROHIBITED_CONTENT="PROHIBITED_CONTENT",g.SPII="SPII",g.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",g.IMAGE_SAFETY="IMAGE_SAFETY",g.UNEXPECTED_TOOL_CALL="UNEXPECTED_TOOL_CALL",g.IMAGE_PROHIBITED_CONTENT="IMAGE_PROHIBITED_CONTENT",g.NO_IMAGE="NO_IMAGE",g.IMAGE_RECITATION="IMAGE_RECITATION",g.IMAGE_OTHER="IMAGE_OTHER",e.HarmProbability=void 0,(y=e.HarmProbability||(e.HarmProbability={})).HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",y.NEGLIGIBLE="NEGLIGIBLE",y.LOW="LOW",y.MEDIUM="MEDIUM",y.HIGH="HIGH",e.HarmSeverity=void 0,(v=e.HarmSeverity||(e.HarmSeverity={})).HARM_SEVERITY_UNSPECIFIED="HARM_SEVERITY_UNSPECIFIED",v.HARM_SEVERITY_NEGLIGIBLE="HARM_SEVERITY_NEGLIGIBLE",v.HARM_SEVERITY_LOW="HARM_SEVERITY_LOW",v.HARM_SEVERITY_MEDIUM="HARM_SEVERITY_MEDIUM",v.HARM_SEVERITY_HIGH="HARM_SEVERITY_HIGH",e.UrlRetrievalStatus=void 0,(E=e.UrlRetrievalStatus||(e.UrlRetrievalStatus={})).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",e.BlockedReason=void 0,(T=e.BlockedReason||(e.BlockedReason={})).BLOCKED_REASON_UNSPECIFIED="BLOCKED_REASON_UNSPECIFIED",T.SAFETY="SAFETY",T.OTHER="OTHER",T.BLOCKLIST="BLOCKLIST",T.PROHIBITED_CONTENT="PROHIBITED_CONTENT",T.IMAGE_SAFETY="IMAGE_SAFETY",T.MODEL_ARMOR="MODEL_ARMOR",T.JAILBREAK="JAILBREAK",e.TrafficType=void 0,(I=e.TrafficType||(e.TrafficType={})).TRAFFIC_TYPE_UNSPECIFIED="TRAFFIC_TYPE_UNSPECIFIED",I.ON_DEMAND="ON_DEMAND",I.PROVISIONED_THROUGHPUT="PROVISIONED_THROUGHPUT",e.Modality=void 0,(S=e.Modality||(e.Modality={})).MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",S.TEXT="TEXT",S.IMAGE="IMAGE",S.AUDIO="AUDIO",e.MediaResolution=void 0,(A=e.MediaResolution||(e.MediaResolution={})).MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",A.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",A.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",A.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH",e.TuningMode=void 0,(C=e.TuningMode||(e.TuningMode={})).TUNING_MODE_UNSPECIFIED="TUNING_MODE_UNSPECIFIED",C.TUNING_MODE_FULL="TUNING_MODE_FULL",C.TUNING_MODE_PEFT_ADAPTER="TUNING_MODE_PEFT_ADAPTER",e.AdapterSize=void 0,(O=e.AdapterSize||(e.AdapterSize={})).ADAPTER_SIZE_UNSPECIFIED="ADAPTER_SIZE_UNSPECIFIED",O.ADAPTER_SIZE_ONE="ADAPTER_SIZE_ONE",O.ADAPTER_SIZE_TWO="ADAPTER_SIZE_TWO",O.ADAPTER_SIZE_FOUR="ADAPTER_SIZE_FOUR",O.ADAPTER_SIZE_EIGHT="ADAPTER_SIZE_EIGHT",O.ADAPTER_SIZE_SIXTEEN="ADAPTER_SIZE_SIXTEEN",O.ADAPTER_SIZE_THIRTY_TWO="ADAPTER_SIZE_THIRTY_TWO",e.JobState=void 0,(b=e.JobState||(e.JobState={})).JOB_STATE_UNSPECIFIED="JOB_STATE_UNSPECIFIED",b.JOB_STATE_QUEUED="JOB_STATE_QUEUED",b.JOB_STATE_PENDING="JOB_STATE_PENDING",b.JOB_STATE_RUNNING="JOB_STATE_RUNNING",b.JOB_STATE_SUCCEEDED="JOB_STATE_SUCCEEDED",b.JOB_STATE_FAILED="JOB_STATE_FAILED",b.JOB_STATE_CANCELLING="JOB_STATE_CANCELLING",b.JOB_STATE_CANCELLED="JOB_STATE_CANCELLED",b.JOB_STATE_PAUSED="JOB_STATE_PAUSED",b.JOB_STATE_EXPIRED="JOB_STATE_EXPIRED",b.JOB_STATE_UPDATING="JOB_STATE_UPDATING",b.JOB_STATE_PARTIALLY_SUCCEEDED="JOB_STATE_PARTIALLY_SUCCEEDED",e.TuningTask=void 0,(R=e.TuningTask||(e.TuningTask={})).TUNING_TASK_UNSPECIFIED="TUNING_TASK_UNSPECIFIED",R.TUNING_TASK_I2V="TUNING_TASK_I2V",R.TUNING_TASK_T2V="TUNING_TASK_T2V",R.TUNING_TASK_R2V="TUNING_TASK_R2V",e.PartMediaResolutionLevel=void 0,(w=e.PartMediaResolutionLevel||(e.PartMediaResolutionLevel={})).MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",w.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",w.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",w.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH",w.MEDIA_RESOLUTION_ULTRA_HIGH="MEDIA_RESOLUTION_ULTRA_HIGH",e.ResourceScope=void 0,(e.ResourceScope||(e.ResourceScope={})).COLLECTION="COLLECTION",e.FeatureSelectionPreference=void 0,(N=e.FeatureSelectionPreference||(e.FeatureSelectionPreference={})).FEATURE_SELECTION_PREFERENCE_UNSPECIFIED="FEATURE_SELECTION_PREFERENCE_UNSPECIFIED",N.PRIORITIZE_QUALITY="PRIORITIZE_QUALITY",N.BALANCED="BALANCED",N.PRIORITIZE_COST="PRIORITIZE_COST",e.Environment=void 0,(P=e.Environment||(e.Environment={})).ENVIRONMENT_UNSPECIFIED="ENVIRONMENT_UNSPECIFIED",P.ENVIRONMENT_BROWSER="ENVIRONMENT_BROWSER",e.EmbeddingApiType=void 0,(M=e.EmbeddingApiType||(e.EmbeddingApiType={})).PREDICT="PREDICT",M.EMBED_CONTENT="EMBED_CONTENT",e.SafetyFilterLevel=void 0,(D=e.SafetyFilterLevel||(e.SafetyFilterLevel={})).BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",D.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",D.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",D.BLOCK_NONE="BLOCK_NONE",e.PersonGeneration=void 0,(U=e.PersonGeneration||(e.PersonGeneration={})).DONT_ALLOW="DONT_ALLOW",U.ALLOW_ADULT="ALLOW_ADULT",U.ALLOW_ALL="ALLOW_ALL",e.ImagePromptLanguage=void 0,(x=e.ImagePromptLanguage||(e.ImagePromptLanguage={})).auto="auto",x.en="en",x.ja="ja",x.ko="ko",x.hi="hi",x.zh="zh",x.pt="pt",x.es="es",e.MaskReferenceMode=void 0,(L=e.MaskReferenceMode||(e.MaskReferenceMode={})).MASK_MODE_DEFAULT="MASK_MODE_DEFAULT",L.MASK_MODE_USER_PROVIDED="MASK_MODE_USER_PROVIDED",L.MASK_MODE_BACKGROUND="MASK_MODE_BACKGROUND",L.MASK_MODE_FOREGROUND="MASK_MODE_FOREGROUND",L.MASK_MODE_SEMANTIC="MASK_MODE_SEMANTIC",e.ControlReferenceType=void 0,(k=e.ControlReferenceType||(e.ControlReferenceType={})).CONTROL_TYPE_DEFAULT="CONTROL_TYPE_DEFAULT",k.CONTROL_TYPE_CANNY="CONTROL_TYPE_CANNY",k.CONTROL_TYPE_SCRIBBLE="CONTROL_TYPE_SCRIBBLE",k.CONTROL_TYPE_FACE_MESH="CONTROL_TYPE_FACE_MESH",e.SubjectReferenceType=void 0,(G=e.SubjectReferenceType||(e.SubjectReferenceType={})).SUBJECT_TYPE_DEFAULT="SUBJECT_TYPE_DEFAULT",G.SUBJECT_TYPE_PERSON="SUBJECT_TYPE_PERSON",G.SUBJECT_TYPE_ANIMAL="SUBJECT_TYPE_ANIMAL",G.SUBJECT_TYPE_PRODUCT="SUBJECT_TYPE_PRODUCT",e.EditMode=void 0,(q=e.EditMode||(e.EditMode={})).EDIT_MODE_DEFAULT="EDIT_MODE_DEFAULT",q.EDIT_MODE_INPAINT_REMOVAL="EDIT_MODE_INPAINT_REMOVAL",q.EDIT_MODE_INPAINT_INSERTION="EDIT_MODE_INPAINT_INSERTION",q.EDIT_MODE_OUTPAINT="EDIT_MODE_OUTPAINT",q.EDIT_MODE_CONTROLLED_EDITING="EDIT_MODE_CONTROLLED_EDITING",q.EDIT_MODE_STYLE="EDIT_MODE_STYLE",q.EDIT_MODE_BGSWAP="EDIT_MODE_BGSWAP",q.EDIT_MODE_PRODUCT_IMAGE="EDIT_MODE_PRODUCT_IMAGE",e.SegmentMode=void 0,(F=e.SegmentMode||(e.SegmentMode={})).FOREGROUND="FOREGROUND",F.BACKGROUND="BACKGROUND",F.PROMPT="PROMPT",F.SEMANTIC="SEMANTIC",F.INTERACTIVE="INTERACTIVE",e.VideoGenerationReferenceType=void 0,(H=e.VideoGenerationReferenceType||(e.VideoGenerationReferenceType={})).ASSET="ASSET",H.STYLE="STYLE",e.VideoGenerationMaskMode=void 0,(j=e.VideoGenerationMaskMode||(e.VideoGenerationMaskMode={})).INSERT="INSERT",j.REMOVE="REMOVE",j.REMOVE_STATIC="REMOVE_STATIC",j.OUTPAINT="OUTPAINT",e.VideoCompressionQuality=void 0,(V=e.VideoCompressionQuality||(e.VideoCompressionQuality={})).OPTIMIZED="OPTIMIZED",V.LOSSLESS="LOSSLESS",e.TuningMethod=void 0,(B=e.TuningMethod||(e.TuningMethod={})).SUPERVISED_FINE_TUNING="SUPERVISED_FINE_TUNING",B.PREFERENCE_TUNING="PREFERENCE_TUNING",B.DISTILLATION="DISTILLATION",e.DocumentState=void 0,(J=e.DocumentState||(e.DocumentState={})).STATE_UNSPECIFIED="STATE_UNSPECIFIED",J.STATE_PENDING="STATE_PENDING",J.STATE_ACTIVE="STATE_ACTIVE",J.STATE_FAILED="STATE_FAILED",e.FileState=void 0,(Y=e.FileState||(e.FileState={})).STATE_UNSPECIFIED="STATE_UNSPECIFIED",Y.PROCESSING="PROCESSING",Y.ACTIVE="ACTIVE",Y.FAILED="FAILED",e.FileSource=void 0,($=e.FileSource||(e.FileSource={})).SOURCE_UNSPECIFIED="SOURCE_UNSPECIFIED",$.UPLOADED="UPLOADED",$.GENERATED="GENERATED",$.REGISTERED="REGISTERED",e.TurnCompleteReason=void 0,(K=e.TurnCompleteReason||(e.TurnCompleteReason={})).TURN_COMPLETE_REASON_UNSPECIFIED="TURN_COMPLETE_REASON_UNSPECIFIED",K.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",K.RESPONSE_REJECTED="RESPONSE_REJECTED",K.NEED_MORE_INPUT="NEED_MORE_INPUT",e.MediaModality=void 0,(W=e.MediaModality||(e.MediaModality={})).MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",W.TEXT="TEXT",W.IMAGE="IMAGE",W.VIDEO="VIDEO",W.AUDIO="AUDIO",W.DOCUMENT="DOCUMENT",e.VadSignalType=void 0,(z=e.VadSignalType||(e.VadSignalType={})).VAD_SIGNAL_TYPE_UNSPECIFIED="VAD_SIGNAL_TYPE_UNSPECIFIED",z.VAD_SIGNAL_TYPE_SOS="VAD_SIGNAL_TYPE_SOS",z.VAD_SIGNAL_TYPE_EOS="VAD_SIGNAL_TYPE_EOS",e.VoiceActivityType=void 0,(X=e.VoiceActivityType||(e.VoiceActivityType={})).TYPE_UNSPECIFIED="TYPE_UNSPECIFIED",X.ACTIVITY_START="ACTIVITY_START",X.ACTIVITY_END="ACTIVITY_END",e.StartSensitivity=void 0,(Q=e.StartSensitivity||(e.StartSensitivity={})).START_SENSITIVITY_UNSPECIFIED="START_SENSITIVITY_UNSPECIFIED",Q.START_SENSITIVITY_HIGH="START_SENSITIVITY_HIGH",Q.START_SENSITIVITY_LOW="START_SENSITIVITY_LOW",e.EndSensitivity=void 0,(Z=e.EndSensitivity||(e.EndSensitivity={})).END_SENSITIVITY_UNSPECIFIED="END_SENSITIVITY_UNSPECIFIED",Z.END_SENSITIVITY_HIGH="END_SENSITIVITY_HIGH",Z.END_SENSITIVITY_LOW="END_SENSITIVITY_LOW",e.ActivityHandling=void 0,(ee=e.ActivityHandling||(e.ActivityHandling={})).ACTIVITY_HANDLING_UNSPECIFIED="ACTIVITY_HANDLING_UNSPECIFIED",ee.START_OF_ACTIVITY_INTERRUPTS="START_OF_ACTIVITY_INTERRUPTS",ee.NO_INTERRUPTION="NO_INTERRUPTION",e.TurnCoverage=void 0,(te=e.TurnCoverage||(e.TurnCoverage={})).TURN_COVERAGE_UNSPECIFIED="TURN_COVERAGE_UNSPECIFIED",te.TURN_INCLUDES_ONLY_ACTIVITY="TURN_INCLUDES_ONLY_ACTIVITY",te.TURN_INCLUDES_ALL_INPUT="TURN_INCLUDES_ALL_INPUT",e.Scale=void 0,(ne=e.Scale||(e.Scale={})).SCALE_UNSPECIFIED="SCALE_UNSPECIFIED",ne.C_MAJOR_A_MINOR="C_MAJOR_A_MINOR",ne.D_FLAT_MAJOR_B_FLAT_MINOR="D_FLAT_MAJOR_B_FLAT_MINOR",ne.D_MAJOR_B_MINOR="D_MAJOR_B_MINOR",ne.E_FLAT_MAJOR_C_MINOR="E_FLAT_MAJOR_C_MINOR",ne.E_MAJOR_D_FLAT_MINOR="E_MAJOR_D_FLAT_MINOR",ne.F_MAJOR_D_MINOR="F_MAJOR_D_MINOR",ne.G_FLAT_MAJOR_E_FLAT_MINOR="G_FLAT_MAJOR_E_FLAT_MINOR",ne.G_MAJOR_E_MINOR="G_MAJOR_E_MINOR",ne.A_FLAT_MAJOR_F_MINOR="A_FLAT_MAJOR_F_MINOR",ne.A_MAJOR_G_FLAT_MINOR="A_MAJOR_G_FLAT_MINOR",ne.B_FLAT_MAJOR_G_MINOR="B_FLAT_MAJOR_G_MINOR",ne.B_MAJOR_A_FLAT_MINOR="B_MAJOR_A_FLAT_MINOR",e.MusicGenerationMode=void 0,(oe=e.MusicGenerationMode||(e.MusicGenerationMode={})).MUSIC_GENERATION_MODE_UNSPECIFIED="MUSIC_GENERATION_MODE_UNSPECIFIED",oe.QUALITY="QUALITY",oe.DIVERSITY="DIVERSITY",oe.VOCALIZATION="VOCALIZATION",e.LiveMusicPlaybackControl=void 0,(ie=e.LiveMusicPlaybackControl||(e.LiveMusicPlaybackControl={})).PLAYBACK_CONTROL_UNSPECIFIED="PLAYBACK_CONTROL_UNSPECIFIED",ie.PLAY="PLAY",ie.PAUSE="PAUSE",ie.STOP="STOP",ie.RESET_CONTEXT="RESET_CONTEXT";function ye(e){return{text:e}}function ve(e){return"object"==typeof e&&null!==e&&("fileData"in e||"text"in e||"functionCall"in e||"functionResponse"in e||"inlineData"in e||"videoMetadata"in e||"codeExecutionResult"in e||"executableCode"in e)}function Ee(e){const t=[];if("string"==typeof e)t.push(ye(e));else if(ve(e))t.push(e);else{if(!Array.isArray(e))throw new Error("partOrString must be a Part object, string, or array");if(0===e.length)throw new Error("partOrString cannot be an empty array");for(const n of e)if("string"==typeof n)t.push(ye(n));else{if(!ve(n))throw new Error("element in PartUnion must be a Part object or string");t.push(n)}}return t}class Te{constructor(e){const t={};for(const n of e.headers.entries())t[n[0]]=n[1];this.headers=t,this.responseInternal=e}json(){return this.responseInternal.json()}}class Ie{get text(){var e,t,n,o,i,r,s,l;if(0===(null===(o=null===(n=null===(t=null===(e=this.candidates)||void 0===e?void 0:e[0])||void 0===t?void 0:t.content)||void 0===n?void 0:n.parts)||void 0===o?void 0:o.length))return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning text from the first one.");let a="",u=!1;const c=[];for(const e of null!==(l=null===(s=null===(r=null===(i=this.candidates)||void 0===i?void 0:i[0])||void 0===r?void 0:r.content)||void 0===s?void 0:s.parts)&&void 0!==l?l:[]){for(const[t,n]of Object.entries(e))"text"===t||"thought"===t||"thoughtSignature"===t||null===n&&void 0===n||c.push(t);if("string"==typeof e.text){if("boolean"==typeof e.thought&&e.thought)continue;u=!0,a+=e.text}}return c.length>0&&console.warn(`there are non-text parts ${c} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),u?a:void 0}get data(){var e,t,n,o,i,r,s,l;if(0===(null===(o=null===(n=null===(t=null===(e=this.candidates)||void 0===e?void 0:e[0])||void 0===t?void 0:t.content)||void 0===n?void 0:n.parts)||void 0===o?void 0:o.length))return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning data from the first one.");let a="";const u=[];for(const e of null!==(l=null===(s=null===(r=null===(i=this.candidates)||void 0===i?void 0:i[0])||void 0===r?void 0:r.content)||void 0===s?void 0:s.parts)&&void 0!==l?l:[]){for(const[t,n]of Object.entries(e))"inlineData"===t||null===n&&void 0===n||u.push(t);e.inlineData&&"string"==typeof e.inlineData.data&&(a+=atob(e.inlineData.data))}return u.length>0&&console.warn(`there are non-data parts ${u} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),a.length>0?btoa(a):void 0}get functionCalls(){var e,t,n,o,i,r,s,l;if(0===(null===(o=null===(n=null===(t=null===(e=this.candidates)||void 0===e?void 0:e[0])||void 0===t?void 0:t.content)||void 0===n?void 0:n.parts)||void 0===o?void 0:o.length))return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning function calls from the first one.");const a=null===(l=null===(s=null===(r=null===(i=this.candidates)||void 0===i?void 0:i[0])||void 0===r?void 0:r.content)||void 0===s?void 0:s.parts)||void 0===l?void 0:l.filter(e=>e.functionCall).map(e=>e.functionCall).filter(e=>void 0!==e);return 0!==(null==a?void 0:a.length)?a:void 0}get executableCode(){var e,t,n,o,i,r,s,l,a;if(0===(null===(o=null===(n=null===(t=null===(e=this.candidates)||void 0===e?void 0:e[0])||void 0===t?void 0:t.content)||void 0===n?void 0:n.parts)||void 0===o?void 0:o.length))return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning executable code from the first one.");const u=null===(l=null===(s=null===(r=null===(i=this.candidates)||void 0===i?void 0:i[0])||void 0===r?void 0:r.content)||void 0===s?void 0:s.parts)||void 0===l?void 0:l.filter(e=>e.executableCode).map(e=>e.executableCode).filter(e=>void 0!==e);return 0!==(null==u?void 0:u.length)?null===(a=null==u?void 0:u[0])||void 0===a?void 0:a.code:void 0}get codeExecutionResult(){var e,t,n,o,i,r,s,l,a;if(0===(null===(o=null===(n=null===(t=null===(e=this.candidates)||void 0===e?void 0:e[0])||void 0===t?void 0:t.content)||void 0===n?void 0:n.parts)||void 0===o?void 0:o.length))return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning code execution result from the first one.");const u=null===(l=null===(s=null===(r=null===(i=this.candidates)||void 0===i?void 0:i[0])||void 0===r?void 0:r.content)||void 0===s?void 0:s.parts)||void 0===l?void 0:l.filter(e=>e.codeExecutionResult).map(e=>e.codeExecutionResult).filter(e=>void 0!==e);return 0!==(null==u?void 0:u.length)?null===(a=null==u?void 0:u[0])||void 0===a?void 0:a.output:void 0}}class _e{}class Se{}class Ae{}class Ce{}class Oe{}class be{}class Re{}class we{}class Ne{}class Pe{}class Me{_fromAPIResponse({apiResponse:e,_isVertexAI:t}){const n=new Me;let o;const i=e;return o=t?fe(i):he(i),Object.assign(n,o),n}}class De{}class Ue{}class xe{}class Le{}class ke{}class Ge{}class qe{}class Fe{_fromAPIResponse({apiResponse:e,_isVertexAI:t}){const n=new Fe,o=me(e);return Object.assign(n,o),n}}class He{}class je{}class Ve{}class Be{}class Je{}class Ye{get text(){var e,t,n;let o="",i=!1;const r=[];for(const s of null!==(n=null===(t=null===(e=this.serverContent)||void 0===e?void 0:e.modelTurn)||void 0===t?void 0:t.parts)&&void 0!==n?n:[]){for(const[e,t]of Object.entries(s))"text"!==e&&"thought"!==e&&null!==t&&r.push(e);if("string"==typeof s.text){if("boolean"==typeof s.thought&&s.thought)continue;i=!0,o+=s.text}}return r.length>0&&console.warn(`there are non-text parts ${r} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),i?o:void 0}get data(){var e,t,n;let o="";const i=[];for(const r of null!==(n=null===(t=null===(e=this.serverContent)||void 0===e?void 0:e.modelTurn)||void 0===t?void 0:t.parts)&&void 0!==n?n:[]){for(const[e,t]of Object.entries(r))"inlineData"!==e&&null!==t&&i.push(e);r.inlineData&&"string"==typeof r.inlineData.data&&(o+=atob(r.inlineData.data))}return i.length>0&&console.warn(`there are non-data parts ${i} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),o.length>0?btoa(o):void 0}}class $e{get audioChunk(){if(this.serverContent&&this.serverContent.audioChunks&&this.serverContent.audioChunks.length>0)return this.serverContent.audioChunks[0]}}class Ke{_fromAPIResponse({apiResponse:e,_isVertexAI:t}){const n=new Ke,o=ge(e);return Object.assign(n,o),n}}
28
28
  /**
29
29
  * @license
30
30
  * Copyright 2025 Google LLC
@@ -40,22 +40,22 @@ function bt(e){const t={},n=ce(e,["responsesFile"]);null!=n&&ue(t,["fileName"],n
40
40
  * @license
41
41
  * Copyright 2025 Google LLC
42
42
  * SPDX-License-Identifier: Apache-2.0
43
- */(ht(e)))),ue(n,["tools"],e)}const I=ce(t,["toolConfig"]);void 0!==n&&null!=I&&ue(n,["toolConfig"],function(e){const t={},n=ce(e,["retrievalConfig"]);null!=n&&ue(t,["retrievalConfig"],n);const o=ce(e,["functionCallingConfig"]);null!=o&&ue(t,["functionCallingConfig"],function(e){const t={},n=ce(e,["allowedFunctionNames"]);null!=n&&ue(t,["allowedFunctionNames"],n);const o=ce(e,["mode"]);null!=o&&ue(t,["mode"],o);if(void 0!==ce(e,["streamFunctionCallArguments"]))throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return t}(o));return t}(I));if(void 0!==ce(t,["labels"]))throw new Error("labels parameter is not supported in Gemini API.");const _=ce(t,["cachedContent"]);void 0!==n&&null!=_&&ue(n,["cachedContent"],mt(e,_));const S=ce(t,["responseModalities"]);null!=S&&ue(o,["responseModalities"],S);const A=ce(t,["mediaResolution"]);null!=A&&ue(o,["mediaResolution"],A);const C=ce(t,["speechConfig"]);null!=C&&ue(o,["speechConfig"],pt(C));if(void 0!==ce(t,["audioTimestamp"]))throw new Error("audioTimestamp parameter is not supported in Gemini API.");const O=ce(t,["thinkingConfig"]);null!=O&&ue(o,["thinkingConfig"],O);const b=ce(t,["imageConfig"]);null!=b&&ue(o,["imageConfig"],function(e){const t={},n=ce(e,["aspectRatio"]);null!=n&&ue(t,["aspectRatio"],n);const o=ce(e,["imageSize"]);null!=o&&ue(t,["imageSize"],o);if(void 0!==ce(e,["personGeneration"]))throw new Error("personGeneration parameter is not supported in Gemini API.");if(void 0!==ce(e,["outputMimeType"]))throw new Error("outputMimeType parameter is not supported in Gemini API.");if(void 0!==ce(e,["outputCompressionQuality"]))throw new Error("outputCompressionQuality parameter is not supported in Gemini API.");return t}(b));const R=ce(t,["enableEnhancedCivicAnswers"]);null!=R&&ue(o,["enableEnhancedCivicAnswers"],R);if(void 0!==ce(t,["modelArmorConfig"]))throw new Error("modelArmorConfig parameter is not supported in Gemini API.");return o}(e,s,ce(n,["request"],{})));return n}(e,t))),ue(n,["requests","requests"],t)}return n}function Pt(e){const t={},n=ce(e,["parts"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>function(e){const t={},n=ce(e,["mediaResolution"]);null!=n&&ue(t,["mediaResolution"],n);const o=ce(e,["codeExecutionResult"]);null!=o&&ue(t,["codeExecutionResult"],o);const i=ce(e,["executableCode"]);null!=i&&ue(t,["executableCode"],i);const r=ce(e,["fileData"]);null!=r&&ue(t,["fileData"],function(e){const t={};if(void 0!==ce(e,["displayName"]))throw new Error("displayName parameter is not supported in Gemini API.");const n=ce(e,["fileUri"]);null!=n&&ue(t,["fileUri"],n);const o=ce(e,["mimeType"]);null!=o&&ue(t,["mimeType"],o);return t}(r));const s=ce(e,["functionCall"]);null!=s&&ue(t,["functionCall"],function(e){const t={},n=ce(e,["id"]);null!=n&&ue(t,["id"],n);const o=ce(e,["args"]);null!=o&&ue(t,["args"],o);const i=ce(e,["name"]);null!=i&&ue(t,["name"],i);if(void 0!==ce(e,["partialArgs"]))throw new Error("partialArgs parameter is not supported in Gemini API.");if(void 0!==ce(e,["willContinue"]))throw new Error("willContinue parameter is not supported in Gemini API.");return t}(s));const l=ce(e,["functionResponse"]);null!=l&&ue(t,["functionResponse"],l);const a=ce(e,["inlineData"]);null!=a&&ue(t,["inlineData"],function(e){const t={},n=ce(e,["data"]);if(null!=n&&ue(t,["data"],n),void 0!==ce(e,["displayName"]))throw new Error("displayName parameter is not supported in Gemini API.");const o=ce(e,["mimeType"]);return null!=o&&ue(t,["mimeType"],o),t}(a));const u=ce(e,["text"]);null!=u&&ue(t,["text"],u);const c=ce(e,["thought"]);null!=c&&ue(t,["thought"],c);const p=ce(e,["thoughtSignature"]);null!=p&&ue(t,["thoughtSignature"],p);const d=ce(e,["videoMetadata"]);null!=d&&ue(t,["videoMetadata"],d);return t}(e))),ue(t,["parts"],e)}const o=ce(e,["role"]);return null!=o&&ue(t,["role"],o),t}function Mt(e,t){const n=ce(e,["displayName"]);void 0!==t&&null!=n&&ue(t,["displayName"],n);const o=ce(e,["dest"]);return void 0!==t&&null!=o&&ue(t,["outputConfig"],function(e){const t={},n=ce(e,["format"]);null!=n&&ue(t,["predictionsFormat"],n);const o=ce(e,["gcsUri"]);null!=o&&ue(t,["gcsDestination","outputUriPrefix"],o);const i=ce(e,["bigqueryUri"]);if(null!=i&&ue(t,["bigqueryDestination","outputUri"],i),void 0!==ce(e,["fileName"]))throw new Error("fileName parameter is not supported in Vertex AI.");if(void 0!==ce(e,["inlinedResponses"]))throw new Error("inlinedResponses parameter is not supported in Vertex AI.");if(void 0!==ce(e,["inlinedEmbedContentResponses"]))throw new Error("inlinedEmbedContentResponses parameter is not supported in Vertex AI.");return t}(function(e){if("string"!=typeof e)return e;const t=e;if(t.startsWith("gs://"))return{format:"jsonl",gcsUri:t};if(t.startsWith("bq://"))return{format:"bigquery",bigqueryUri:t};throw new Error(`Unsupported destination: ${t}`)}(o))),{}}function Dt(e,t){const n={},o=ce(t,["model"]);null!=o&&ue(n,["_url","model"],We(e,o));const i=ce(t,["src"]);null!=i&&ue(n,["batch","inputConfig"],Nt(e,St(e,i)));const r=ce(t,["config"]);return null!=r&&function(e,t){const n=ce(e,["displayName"]);if(void 0!==t&&null!=n&&ue(t,["batch","displayName"],n),void 0!==ce(e,["dest"]))throw new Error("dest parameter is not supported in Gemini API.")}(r,n),n}function Ut(e,t){const n={},o=ce(t,["model"]);null!=o&&ue(n,["model"],We(e,o));const i=ce(t,["src"]);null!=i&&ue(n,["inputConfig"],function(e){const t={},n=ce(e,["format"]);null!=n&&ue(t,["instancesFormat"],n);const o=ce(e,["gcsUri"]);null!=o&&ue(t,["gcsSource","uris"],o);const i=ce(e,["bigqueryUri"]);if(null!=i&&ue(t,["bigquerySource","inputUri"],i),void 0!==ce(e,["fileName"]))throw new Error("fileName parameter is not supported in Vertex AI.");if(void 0!==ce(e,["inlinedRequests"]))throw new Error("inlinedRequests parameter is not supported in Vertex AI.");return t}(St(e,i)));const r=ce(t,["config"]);return null!=r&&Mt(r,n),n}function xt(e,t){const n={},o=ce(t,["model"]);null!=o&&ue(n,["_url","model"],We(e,o));const i=ce(t,["src"]);null!=i&&ue(n,["batch","inputConfig"],function(e,t){const n={},o=ce(t,["fileName"]);null!=o&&ue(n,["file_name"],o);const i=ce(t,["inlinedRequests"]);null!=i&&ue(n,["requests"],function(e,t){const n={},o=ce(t,["contents"]);if(null!=o){let t=lt(e,o);Array.isArray(t)&&(t=t.map(e=>e)),ue(n,["requests[]","request","content"],t)}const i=ce(t,["config"]);null!=i&&(ue(n,["_self"],function(e,t){const n={},o=ce(e,["taskType"]);void 0!==t&&null!=o&&ue(t,["requests[]","taskType"],o);const i=ce(e,["title"]);void 0!==t&&null!=i&&ue(t,["requests[]","title"],i);const r=ce(e,["outputDimensionality"]);void 0!==t&&null!=r&&ue(t,["requests[]","outputDimensionality"],r);if(void 0!==ce(e,["mimeType"]))throw new Error("mimeType parameter is not supported in Gemini API.");if(void 0!==ce(e,["autoTruncate"]))throw new Error("autoTruncate parameter is not supported in Gemini API.");return n}(i,n)),function(e,t){for(const[n,o]of Object.entries(t)){const t=n.split("."),i=o.split("."),r=new Set;let s=-1;for(let e=0;e<t.length;e++)if("*"===t[e]){s=e;break}if(-1!==s&&i.length>s)for(let e=s;e<i.length;e++){const t=i[e];"*"===t||t.endsWith("[]")||t.endsWith("[0]")||r.add(t)}pe(e,t,i,0,r)}}(n,{"requests[].*":"requests[].request.*"}));return n}(e,i));return n}(e,i));const r=ce(t,["config"]);return null!=r&&function(e,t){const n=ce(e,["displayName"]);void 0!==t&&null!=n&&ue(t,["batch","displayName"],n)}(r,n),n}function Lt(e){const t={},n=ce(e,["config"]);return null!=n&&function(e,t){const n=ce(e,["pageSize"]);void 0!==t&&null!=n&&ue(t,["_query","pageSize"],n);const o=ce(e,["pageToken"]);if(void 0!==t&&null!=o&&ue(t,["_query","pageToken"],o),void 0!==ce(e,["filter"]))throw new Error("filter parameter is not supported in Gemini API.")}(n,t),t}function kt(e){const t={},n=ce(e,["config"]);return null!=n&&function(e,t){const n=ce(e,["pageSize"]);void 0!==t&&null!=n&&ue(t,["_query","pageSize"],n);const o=ce(e,["pageToken"]);void 0!==t&&null!=o&&ue(t,["_query","pageToken"],o);const i=ce(e,["filter"]);void 0!==t&&null!=i&&ue(t,["_query","filter"],i)}(n,t),t}e.PagedItem=void 0,(re=e.PagedItem||(e.PagedItem={})).PAGED_ITEM_BATCH_JOBS="batchJobs",re.PAGED_ITEM_MODELS="models",re.PAGED_ITEM_TUNING_JOBS="tuningJobs",re.PAGED_ITEM_FILES="files",re.PAGED_ITEM_CACHED_CONTENTS="cachedContents",re.PAGED_ITEM_FILE_SEARCH_STORES="fileSearchStores",re.PAGED_ITEM_DOCUMENTS="documents";class qt{constructor(e,t,n,o){this.pageInternal=[],this.paramsInternal={},this.requestInternal=t,this.init(e,n,o)}init(e,t,n){var o,i;this.nameInternal=e,this.pageInternal=t[this.nameInternal]||[],this.sdkHttpResponseInternal=null==t?void 0:t.sdkHttpResponse,this.idxInternal=0;let r={config:{}};r=n&&0!==Object.keys(n).length?"object"==typeof n?Object.assign({},n):n:{config:{}},r.config&&(r.config.pageToken=t.nextPageToken),this.paramsInternal=r,this.pageInternalSize=null!==(i=null===(o=r.config)||void 0===o?void 0:o.pageSize)&&void 0!==i?i: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())return{value:void 0,done:!0};await this.nextPage()}const 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 new Error("No more pages to fetch.");const e=await this.requestInternal(this.params);return this.initNextPage(e),this.page}hasNextPage(){var e;return void 0!==(null===(e=this.params.config)||void 0===e?void 0:e.pageToken)}}
43
+ */(ht(e)))),ue(n,["tools"],e)}const I=ce(t,["toolConfig"]);void 0!==n&&null!=I&&ue(n,["toolConfig"],function(e){const t={},n=ce(e,["retrievalConfig"]);null!=n&&ue(t,["retrievalConfig"],n);const o=ce(e,["functionCallingConfig"]);null!=o&&ue(t,["functionCallingConfig"],function(e){const t={},n=ce(e,["allowedFunctionNames"]);null!=n&&ue(t,["allowedFunctionNames"],n);const o=ce(e,["mode"]);null!=o&&ue(t,["mode"],o);if(void 0!==ce(e,["streamFunctionCallArguments"]))throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return t}(o));return t}(I));if(void 0!==ce(t,["labels"]))throw new Error("labels parameter is not supported in Gemini API.");const _=ce(t,["cachedContent"]);void 0!==n&&null!=_&&ue(n,["cachedContent"],mt(e,_));const S=ce(t,["responseModalities"]);null!=S&&ue(o,["responseModalities"],S);const A=ce(t,["mediaResolution"]);null!=A&&ue(o,["mediaResolution"],A);const C=ce(t,["speechConfig"]);null!=C&&ue(o,["speechConfig"],pt(C));if(void 0!==ce(t,["audioTimestamp"]))throw new Error("audioTimestamp parameter is not supported in Gemini API.");const O=ce(t,["thinkingConfig"]);null!=O&&ue(o,["thinkingConfig"],O);const b=ce(t,["imageConfig"]);null!=b&&ue(o,["imageConfig"],function(e){const t={},n=ce(e,["aspectRatio"]);null!=n&&ue(t,["aspectRatio"],n);const o=ce(e,["imageSize"]);null!=o&&ue(t,["imageSize"],o);if(void 0!==ce(e,["personGeneration"]))throw new Error("personGeneration parameter is not supported in Gemini API.");if(void 0!==ce(e,["outputMimeType"]))throw new Error("outputMimeType parameter is not supported in Gemini API.");if(void 0!==ce(e,["outputCompressionQuality"]))throw new Error("outputCompressionQuality parameter is not supported in Gemini API.");return t}(b));const R=ce(t,["enableEnhancedCivicAnswers"]);null!=R&&ue(o,["enableEnhancedCivicAnswers"],R);if(void 0!==ce(t,["modelArmorConfig"]))throw new Error("modelArmorConfig parameter is not supported in Gemini API.");return o}(e,s,ce(n,["request"],{})));return n}(e,t))),ue(n,["requests","requests"],t)}return n}function Pt(e){const t={},n=ce(e,["parts"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>function(e){const t={},n=ce(e,["mediaResolution"]);null!=n&&ue(t,["mediaResolution"],n);const o=ce(e,["codeExecutionResult"]);null!=o&&ue(t,["codeExecutionResult"],o);const i=ce(e,["executableCode"]);null!=i&&ue(t,["executableCode"],i);const r=ce(e,["fileData"]);null!=r&&ue(t,["fileData"],function(e){const t={};if(void 0!==ce(e,["displayName"]))throw new Error("displayName parameter is not supported in Gemini API.");const n=ce(e,["fileUri"]);null!=n&&ue(t,["fileUri"],n);const o=ce(e,["mimeType"]);null!=o&&ue(t,["mimeType"],o);return t}(r));const s=ce(e,["functionCall"]);null!=s&&ue(t,["functionCall"],function(e){const t={},n=ce(e,["id"]);null!=n&&ue(t,["id"],n);const o=ce(e,["args"]);null!=o&&ue(t,["args"],o);const i=ce(e,["name"]);null!=i&&ue(t,["name"],i);if(void 0!==ce(e,["partialArgs"]))throw new Error("partialArgs parameter is not supported in Gemini API.");if(void 0!==ce(e,["willContinue"]))throw new Error("willContinue parameter is not supported in Gemini API.");return t}(s));const l=ce(e,["functionResponse"]);null!=l&&ue(t,["functionResponse"],l);const a=ce(e,["inlineData"]);null!=a&&ue(t,["inlineData"],function(e){const t={},n=ce(e,["data"]);if(null!=n&&ue(t,["data"],n),void 0!==ce(e,["displayName"]))throw new Error("displayName parameter is not supported in Gemini API.");const o=ce(e,["mimeType"]);return null!=o&&ue(t,["mimeType"],o),t}(a));const u=ce(e,["text"]);null!=u&&ue(t,["text"],u);const c=ce(e,["thought"]);null!=c&&ue(t,["thought"],c);const p=ce(e,["thoughtSignature"]);null!=p&&ue(t,["thoughtSignature"],p);const d=ce(e,["videoMetadata"]);null!=d&&ue(t,["videoMetadata"],d);return t}(e))),ue(t,["parts"],e)}const o=ce(e,["role"]);return null!=o&&ue(t,["role"],o),t}function Mt(e,t){const n=ce(e,["displayName"]);void 0!==t&&null!=n&&ue(t,["displayName"],n);const o=ce(e,["dest"]);return void 0!==t&&null!=o&&ue(t,["outputConfig"],function(e){const t={},n=ce(e,["format"]);null!=n&&ue(t,["predictionsFormat"],n);const o=ce(e,["gcsUri"]);null!=o&&ue(t,["gcsDestination","outputUriPrefix"],o);const i=ce(e,["bigqueryUri"]);if(null!=i&&ue(t,["bigqueryDestination","outputUri"],i),void 0!==ce(e,["fileName"]))throw new Error("fileName parameter is not supported in Vertex AI.");if(void 0!==ce(e,["inlinedResponses"]))throw new Error("inlinedResponses parameter is not supported in Vertex AI.");if(void 0!==ce(e,["inlinedEmbedContentResponses"]))throw new Error("inlinedEmbedContentResponses parameter is not supported in Vertex AI.");return t}(function(e){if("string"!=typeof e)return e;const t=e;if(t.startsWith("gs://"))return{format:"jsonl",gcsUri:t};if(t.startsWith("bq://"))return{format:"bigquery",bigqueryUri:t};throw new Error(`Unsupported destination: ${t}`)}(o))),{}}function Dt(e,t){const n={},o=ce(t,["model"]);null!=o&&ue(n,["_url","model"],We(e,o));const i=ce(t,["src"]);null!=i&&ue(n,["batch","inputConfig"],Nt(e,St(e,i)));const r=ce(t,["config"]);return null!=r&&function(e,t){const n=ce(e,["displayName"]);if(void 0!==t&&null!=n&&ue(t,["batch","displayName"],n),void 0!==ce(e,["dest"]))throw new Error("dest parameter is not supported in Gemini API.")}(r,n),n}function Ut(e,t){const n={},o=ce(t,["model"]);null!=o&&ue(n,["model"],We(e,o));const i=ce(t,["src"]);null!=i&&ue(n,["inputConfig"],function(e){const t={},n=ce(e,["format"]);null!=n&&ue(t,["instancesFormat"],n);const o=ce(e,["gcsUri"]);null!=o&&ue(t,["gcsSource","uris"],o);const i=ce(e,["bigqueryUri"]);if(null!=i&&ue(t,["bigquerySource","inputUri"],i),void 0!==ce(e,["fileName"]))throw new Error("fileName parameter is not supported in Vertex AI.");if(void 0!==ce(e,["inlinedRequests"]))throw new Error("inlinedRequests parameter is not supported in Vertex AI.");return t}(St(e,i)));const r=ce(t,["config"]);return null!=r&&Mt(r,n),n}function xt(e,t){const n={},o=ce(t,["model"]);null!=o&&ue(n,["_url","model"],We(e,o));const i=ce(t,["src"]);null!=i&&ue(n,["batch","inputConfig"],function(e,t){const n={},o=ce(t,["fileName"]);null!=o&&ue(n,["file_name"],o);const i=ce(t,["inlinedRequests"]);null!=i&&ue(n,["requests"],function(e,t){const n={},o=ce(t,["contents"]);if(null!=o){let t=lt(e,o);Array.isArray(t)&&(t=t.map(e=>e)),ue(n,["requests[]","request","content"],t)}const i=ce(t,["config"]);null!=i&&(ue(n,["_self"],function(e,t){const n={},o=ce(e,["taskType"]);void 0!==t&&null!=o&&ue(t,["requests[]","taskType"],o);const i=ce(e,["title"]);void 0!==t&&null!=i&&ue(t,["requests[]","title"],i);const r=ce(e,["outputDimensionality"]);void 0!==t&&null!=r&&ue(t,["requests[]","outputDimensionality"],r);if(void 0!==ce(e,["mimeType"]))throw new Error("mimeType parameter is not supported in Gemini API.");if(void 0!==ce(e,["autoTruncate"]))throw new Error("autoTruncate parameter is not supported in Gemini API.");return n}(i,n)),function(e,t){for(const[n,o]of Object.entries(t)){const t=n.split("."),i=o.split("."),r=new Set;let s=-1;for(let e=0;e<t.length;e++)if("*"===t[e]){s=e;break}if(-1!==s&&i.length>s)for(let e=s;e<i.length;e++){const t=i[e];"*"===t||t.endsWith("[]")||t.endsWith("[0]")||r.add(t)}pe(e,t,i,0,r)}}(n,{"requests[].*":"requests[].request.*"}));return n}(e,i));return n}(e,i));const r=ce(t,["config"]);return null!=r&&function(e,t){const n=ce(e,["displayName"]);void 0!==t&&null!=n&&ue(t,["batch","displayName"],n)}(r,n),n}function Lt(e){const t={},n=ce(e,["config"]);return null!=n&&function(e,t){const n=ce(e,["pageSize"]);void 0!==t&&null!=n&&ue(t,["_query","pageSize"],n);const o=ce(e,["pageToken"]);if(void 0!==t&&null!=o&&ue(t,["_query","pageToken"],o),void 0!==ce(e,["filter"]))throw new Error("filter parameter is not supported in Gemini API.")}(n,t),t}function kt(e){const t={},n=ce(e,["config"]);return null!=n&&function(e,t){const n=ce(e,["pageSize"]);void 0!==t&&null!=n&&ue(t,["_query","pageSize"],n);const o=ce(e,["pageToken"]);void 0!==t&&null!=o&&ue(t,["_query","pageToken"],o);const i=ce(e,["filter"]);void 0!==t&&null!=i&&ue(t,["_query","filter"],i)}(n,t),t}e.PagedItem=void 0,(re=e.PagedItem||(e.PagedItem={})).PAGED_ITEM_BATCH_JOBS="batchJobs",re.PAGED_ITEM_MODELS="models",re.PAGED_ITEM_TUNING_JOBS="tuningJobs",re.PAGED_ITEM_FILES="files",re.PAGED_ITEM_CACHED_CONTENTS="cachedContents",re.PAGED_ITEM_FILE_SEARCH_STORES="fileSearchStores",re.PAGED_ITEM_DOCUMENTS="documents";class Gt{constructor(e,t,n,o){this.pageInternal=[],this.paramsInternal={},this.requestInternal=t,this.init(e,n,o)}init(e,t,n){var o,i;this.nameInternal=e,this.pageInternal=t[this.nameInternal]||[],this.sdkHttpResponseInternal=null==t?void 0:t.sdkHttpResponse,this.idxInternal=0;let r={config:{}};r=n&&0!==Object.keys(n).length?"object"==typeof n?Object.assign({},n):n:{config:{}},r.config&&(r.config.pageToken=t.nextPageToken),this.paramsInternal=r,this.pageInternalSize=null!==(i=null===(o=r.config)||void 0===o?void 0:o.pageSize)&&void 0!==i?i: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())return{value:void 0,done:!0};await this.nextPage()}const 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 new Error("No more pages to fetch.");const e=await this.requestInternal(this.params);return this.initNextPage(e),this.page}hasNextPage(){var e;return void 0!==(null===(e=this.params.config)||void 0===e?void 0:e.pageToken)}}
44
44
  /**
45
45
  * @license
46
46
  * Copyright 2025 Google LLC
47
47
  * SPDX-License-Identifier: Apache-2.0
48
- */class Gt extends le{constructor(t){super(),this.apiClient=t,this.list=async(t={})=>new qt(e.PagedItem.PAGED_ITEM_BATCH_JOBS,e=>this.listInternal(e),await this.listInternal(t),t),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 new Error("Vertex AI does not support batches.createEmbeddings.");return this.createEmbeddingsInternal(e)}}createInlinedGenerateContentRequest(e){const t=Dt(this.apiClient,e),n=ae("{model}:batchGenerateContent",t._url),o=t.batch.inputConfig.requests,i=o.requests,r=[];for(const e of i){const t=Object.assign({},e);if(t.systemInstruction){const e=t.systemInstruction;delete t.systemInstruction;const n=t.request;n.systemInstruction=e,t.request=n}r.push(t)}return o.requests=r,delete t.config,delete t._url,delete t._query,{path:n,body:t}}getGcsUri(e){return"string"==typeof e?e.startsWith("gs://")?e:void 0:!Array.isArray(e)&&e.gcsUri&&e.gcsUri.length>0?e.gcsUri[0]:void 0}getBigqueryUri(e){return"string"==typeof e?e.startsWith("bq://")?e:void 0:Array.isArray(e)?void 0:e.bigqueryUri}formatDestination(e,t){const n=t?Object.assign({},t):{},o=Date.now().toString();if(n.displayName||(n.displayName=`genaiBatchJob_${o}`),void 0===n.dest){const t=this.getGcsUri(e),i=this.getBigqueryUri(e);if(t)t.endsWith(".jsonl")?n.dest=`${t.slice(0,-6)}/dest`:n.dest=`${t}_dest_${o}`;else{if(!i)throw new Error("Unsupported source for Vertex AI: No GCS or BigQuery URI found.");n.dest=`${i}_dest_${o}`}}return n}async createInternal(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=Ut(this.apiClient,e);return s=ae("batchPredictionJobs",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),r.then(e=>wt(e))}{const t=Dt(this.apiClient,e);return s=ae("{model}:batchGenerateContent",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json()),r.then(e=>Rt(e))}}async createEmbeddingsInternal(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const s=xt(this.apiClient,e);return i=ae("{model}:asyncBatchEmbedContent",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),o.then(e=>Rt(e))}}async get(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=function(e,t){const n={},o=ce(t,["name"]);return null!=o&&ue(n,["_url","name"],Ct(e,o)),n}(this.apiClient,e);return s=ae("batchPredictionJobs/{name}",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"GET",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),r.then(e=>wt(e))}{const t=function(e,t){const n={},o=ce(t,["name"]);return null!=o&&ue(n,["_url","name"],Ct(e,o)),n}(this.apiClient,e);return s=ae("batches/{name}",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"GET",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json()),r.then(e=>Rt(e))}}async cancel(e){var t,n,o,i;let r="",s={};if(this.apiClient.isVertexAI()){const o=function(e,t){const n={},o=ce(t,["name"]);return null!=o&&ue(n,["_url","name"],Ct(e,o)),n}(this.apiClient,e);r=ae("batchPredictionJobs/{name}:cancel",o._url),s=o._query,delete o._url,delete o._query,await this.apiClient.request({path:r,queryParams:s,body:JSON.stringify(o),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal})}else{const t=function(e,t){const n={},o=ce(t,["name"]);return null!=o&&ue(n,["_url","name"],Ct(e,o)),n}(this.apiClient,e);r=ae("batches/{name}:cancel",t._url),s=t._query,delete t._url,delete t._query,await this.apiClient.request({path:r,queryParams:s,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal})}}async listInternal(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=kt(e);return s=ae("batchPredictionJobs",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"GET",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["nextPageToken"]);null!=o&&ue(t,["nextPageToken"],o);const i=ce(e,["batchPredictionJobs"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>wt(e))),ue(t,["batchJobs"],e)}return t}(e),n=new Je;return Object.assign(n,t),n})}{const t=Lt(e);return s=ae("batches",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"GET",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["nextPageToken"]);null!=o&&ue(t,["nextPageToken"],o);const i=ce(e,["operations"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>Rt(e))),ue(t,["batchJobs"],e)}return t}(e),n=new Je;return Object.assign(n,t),n})}}async delete(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=function(e,t){const n={},o=ce(t,["name"]);return null!=o&&ue(n,["_url","name"],Ct(e,o)),n}(this.apiClient,e);return s=ae("batchPredictionJobs/{name}",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"DELETE",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["name"]);null!=o&&ue(t,["name"],o);const i=ce(e,["done"]);null!=i&&ue(t,["done"],i);const r=ce(e,["error"]);return null!=r&&ue(t,["error"],r),t}(e))}{const t=function(e,t){const n={},o=ce(t,["name"]);return null!=o&&ue(n,["_url","name"],Ct(e,o)),n}(this.apiClient,e);return s=ae("batches/{name}",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"DELETE",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["name"]);null!=o&&ue(t,["name"],o);const i=ce(e,["done"]);null!=i&&ue(t,["done"],i);const r=ce(e,["error"]);return null!=r&&ue(t,["error"],r),t}(e))}}}
48
+ */class qt extends le{constructor(t){super(),this.apiClient=t,this.list=async(t={})=>new Gt(e.PagedItem.PAGED_ITEM_BATCH_JOBS,e=>this.listInternal(e),await this.listInternal(t),t),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 new Error("Vertex AI does not support batches.createEmbeddings.");return this.createEmbeddingsInternal(e)}}createInlinedGenerateContentRequest(e){const t=Dt(this.apiClient,e),n=ae("{model}:batchGenerateContent",t._url),o=t.batch.inputConfig.requests,i=o.requests,r=[];for(const e of i){const t=Object.assign({},e);if(t.systemInstruction){const e=t.systemInstruction;delete t.systemInstruction;const n=t.request;n.systemInstruction=e,t.request=n}r.push(t)}return o.requests=r,delete t.config,delete t._url,delete t._query,{path:n,body:t}}getGcsUri(e){return"string"==typeof e?e.startsWith("gs://")?e:void 0:!Array.isArray(e)&&e.gcsUri&&e.gcsUri.length>0?e.gcsUri[0]:void 0}getBigqueryUri(e){return"string"==typeof e?e.startsWith("bq://")?e:void 0:Array.isArray(e)?void 0:e.bigqueryUri}formatDestination(e,t){const n=t?Object.assign({},t):{},o=Date.now().toString();if(n.displayName||(n.displayName=`genaiBatchJob_${o}`),void 0===n.dest){const t=this.getGcsUri(e),i=this.getBigqueryUri(e);if(t)t.endsWith(".jsonl")?n.dest=`${t.slice(0,-6)}/dest`:n.dest=`${t}_dest_${o}`;else{if(!i)throw new Error("Unsupported source for Vertex AI: No GCS or BigQuery URI found.");n.dest=`${i}_dest_${o}`}}return n}async createInternal(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=Ut(this.apiClient,e);return s=ae("batchPredictionJobs",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),r.then(e=>wt(e))}{const t=Dt(this.apiClient,e);return s=ae("{model}:batchGenerateContent",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json()),r.then(e=>Rt(e))}}async createEmbeddingsInternal(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const s=xt(this.apiClient,e);return i=ae("{model}:asyncBatchEmbedContent",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),o.then(e=>Rt(e))}}async get(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=function(e,t){const n={},o=ce(t,["name"]);return null!=o&&ue(n,["_url","name"],Ct(e,o)),n}(this.apiClient,e);return s=ae("batchPredictionJobs/{name}",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"GET",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),r.then(e=>wt(e))}{const t=function(e,t){const n={},o=ce(t,["name"]);return null!=o&&ue(n,["_url","name"],Ct(e,o)),n}(this.apiClient,e);return s=ae("batches/{name}",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"GET",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json()),r.then(e=>Rt(e))}}async cancel(e){var t,n,o,i;let r="",s={};if(this.apiClient.isVertexAI()){const o=function(e,t){const n={},o=ce(t,["name"]);return null!=o&&ue(n,["_url","name"],Ct(e,o)),n}(this.apiClient,e);r=ae("batchPredictionJobs/{name}:cancel",o._url),s=o._query,delete o._url,delete o._query,await this.apiClient.request({path:r,queryParams:s,body:JSON.stringify(o),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal})}else{const t=function(e,t){const n={},o=ce(t,["name"]);return null!=o&&ue(n,["_url","name"],Ct(e,o)),n}(this.apiClient,e);r=ae("batches/{name}:cancel",t._url),s=t._query,delete t._url,delete t._query,await this.apiClient.request({path:r,queryParams:s,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal})}}async listInternal(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=kt(e);return s=ae("batchPredictionJobs",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"GET",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["nextPageToken"]);null!=o&&ue(t,["nextPageToken"],o);const i=ce(e,["batchPredictionJobs"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>wt(e))),ue(t,["batchJobs"],e)}return t}(e),n=new Je;return Object.assign(n,t),n})}{const t=Lt(e);return s=ae("batches",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"GET",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["nextPageToken"]);null!=o&&ue(t,["nextPageToken"],o);const i=ce(e,["operations"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>Rt(e))),ue(t,["batchJobs"],e)}return t}(e),n=new Je;return Object.assign(n,t),n})}}async delete(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=function(e,t){const n={},o=ce(t,["name"]);return null!=o&&ue(n,["_url","name"],Ct(e,o)),n}(this.apiClient,e);return s=ae("batchPredictionJobs/{name}",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"DELETE",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["name"]);null!=o&&ue(t,["name"],o);const i=ce(e,["done"]);null!=i&&ue(t,["done"],i);const r=ce(e,["error"]);return null!=r&&ue(t,["error"],r),t}(e))}{const t=function(e,t){const n={},o=ce(t,["name"]);return null!=o&&ue(n,["_url","name"],Ct(e,o)),n}(this.apiClient,e);return s=ae("batches/{name}",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"DELETE",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["name"]);null!=o&&ue(t,["name"],o);const i=ce(e,["done"]);null!=i&&ue(t,["done"],i);const r=ce(e,["error"]);return null!=r&&ue(t,["error"],r),t}(e))}}}
49
49
  /**
50
50
  * @license
51
51
  * Copyright 2025 Google LLC
52
52
  * SPDX-License-Identifier: Apache-2.0
53
- */function Ft(e){const t={},n=ce(e,["parts"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>function(e){const t={},n=ce(e,["mediaResolution"]);null!=n&&ue(t,["mediaResolution"],n);const o=ce(e,["codeExecutionResult"]);null!=o&&ue(t,["codeExecutionResult"],o);const i=ce(e,["executableCode"]);null!=i&&ue(t,["executableCode"],i);const r=ce(e,["fileData"]);null!=r&&ue(t,["fileData"],function(e){const t={};if(void 0!==ce(e,["displayName"]))throw new Error("displayName parameter is not supported in Gemini API.");const n=ce(e,["fileUri"]);null!=n&&ue(t,["fileUri"],n);const o=ce(e,["mimeType"]);null!=o&&ue(t,["mimeType"],o);return t}(r));const s=ce(e,["functionCall"]);null!=s&&ue(t,["functionCall"],function(e){const t={},n=ce(e,["id"]);null!=n&&ue(t,["id"],n);const o=ce(e,["args"]);null!=o&&ue(t,["args"],o);const i=ce(e,["name"]);null!=i&&ue(t,["name"],i);if(void 0!==ce(e,["partialArgs"]))throw new Error("partialArgs parameter is not supported in Gemini API.");if(void 0!==ce(e,["willContinue"]))throw new Error("willContinue parameter is not supported in Gemini API.");return t}(s));const l=ce(e,["functionResponse"]);null!=l&&ue(t,["functionResponse"],l);const a=ce(e,["inlineData"]);null!=a&&ue(t,["inlineData"],function(e){const t={},n=ce(e,["data"]);if(null!=n&&ue(t,["data"],n),void 0!==ce(e,["displayName"]))throw new Error("displayName parameter is not supported in Gemini API.");const o=ce(e,["mimeType"]);return null!=o&&ue(t,["mimeType"],o),t}(a));const u=ce(e,["text"]);null!=u&&ue(t,["text"],u);const c=ce(e,["thought"]);null!=c&&ue(t,["thought"],c);const p=ce(e,["thoughtSignature"]);null!=p&&ue(t,["thoughtSignature"],p);const d=ce(e,["videoMetadata"]);null!=d&&ue(t,["videoMetadata"],d);return t}(e))),ue(t,["parts"],e)}const o=ce(e,["role"]);return null!=o&&ue(t,["role"],o),t}function Ht(e,t){const n=ce(e,["ttl"]);void 0!==t&&null!=n&&ue(t,["ttl"],n);const o=ce(e,["expireTime"]);void 0!==t&&null!=o&&ue(t,["expireTime"],o);const i=ce(e,["displayName"]);void 0!==t&&null!=i&&ue(t,["displayName"],i);const r=ce(e,["contents"]);if(void 0!==t&&null!=r){let e=at(r);Array.isArray(e)&&(e=e.map(e=>Ft(e))),ue(t,["contents"],e)}const s=ce(e,["systemInstruction"]);void 0!==t&&null!=s&&ue(t,["systemInstruction"],Ft(st(s)));const l=ce(e,["tools"]);if(void 0!==t&&null!=l){let e=l;Array.isArray(e)&&(e=e.map(e=>function(e){const t={};if(void 0!==ce(e,["retrieval"]))throw new Error("retrieval parameter is not supported in Gemini API.");const n=ce(e,["computerUse"]);null!=n&&ue(t,["computerUse"],n);const o=ce(e,["fileSearch"]);null!=o&&ue(t,["fileSearch"],o);const i=ce(e,["codeExecution"]);null!=i&&ue(t,["codeExecution"],i);if(void 0!==ce(e,["enterpriseWebSearch"]))throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const r=ce(e,["functionDeclarations"]);if(null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["functionDeclarations"],e)}const s=ce(e,["googleMaps"]);null!=s&&ue(t,["googleMaps"],function(e){const t={};if(void 0!==ce(e,["authConfig"]))throw new Error("authConfig parameter is not supported in Gemini API.");const n=ce(e,["enableWidget"]);null!=n&&ue(t,["enableWidget"],n);return t}(s));const l=ce(e,["googleSearch"]);null!=l&&ue(t,["googleSearch"],function(e){const t={};if(void 0!==ce(e,["excludeDomains"]))throw new Error("excludeDomains parameter is not supported in Gemini API.");if(void 0!==ce(e,["blockingConfidence"]))throw new Error("blockingConfidence parameter is not supported in Gemini API.");const n=ce(e,["timeRangeFilter"]);null!=n&&ue(t,["timeRangeFilter"],n);return t}(l));const a=ce(e,["googleSearchRetrieval"]);null!=a&&ue(t,["googleSearchRetrieval"],a);const u=ce(e,["urlContext"]);null!=u&&ue(t,["urlContext"],u);return t}(e))),ue(t,["tools"],e)}const a=ce(e,["toolConfig"]);if(void 0!==t&&null!=a&&ue(t,["toolConfig"],function(e){const t={},n=ce(e,["retrievalConfig"]);null!=n&&ue(t,["retrievalConfig"],n);const o=ce(e,["functionCallingConfig"]);null!=o&&ue(t,["functionCallingConfig"],function(e){const t={},n=ce(e,["allowedFunctionNames"]);null!=n&&ue(t,["allowedFunctionNames"],n);const o=ce(e,["mode"]);null!=o&&ue(t,["mode"],o);if(void 0!==ce(e,["streamFunctionCallArguments"]))throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return t}(o));return t}(a)),void 0!==ce(e,["kmsKeyName"]))throw new Error("kmsKeyName parameter is not supported in Gemini API.");return{}}function jt(e,t){const n=ce(e,["ttl"]);void 0!==t&&null!=n&&ue(t,["ttl"],n);const o=ce(e,["expireTime"]);void 0!==t&&null!=o&&ue(t,["expireTime"],o);const i=ce(e,["displayName"]);void 0!==t&&null!=i&&ue(t,["displayName"],i);const r=ce(e,["contents"]);if(void 0!==t&&null!=r){let e=at(r);Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["contents"],e)}const s=ce(e,["systemInstruction"]);void 0!==t&&null!=s&&ue(t,["systemInstruction"],st(s));const l=ce(e,["tools"]);if(void 0!==t&&null!=l){let e=l;Array.isArray(e)&&(e=e.map(e=>function(e){const t={},n=ce(e,["retrieval"]);null!=n&&ue(t,["retrieval"],n);const o=ce(e,["computerUse"]);null!=o&&ue(t,["computerUse"],o);if(void 0!==ce(e,["fileSearch"]))throw new Error("fileSearch parameter is not supported in Vertex AI.");const i=ce(e,["codeExecution"]);null!=i&&ue(t,["codeExecution"],i);const r=ce(e,["enterpriseWebSearch"]);null!=r&&ue(t,["enterpriseWebSearch"],r);const s=ce(e,["functionDeclarations"]);if(null!=s){let e=s;Array.isArray(e)&&(e=e.map(e=>function(e){const t={},n=ce(e,["description"]);null!=n&&ue(t,["description"],n);const o=ce(e,["name"]);null!=o&&ue(t,["name"],o);const i=ce(e,["parameters"]);null!=i&&ue(t,["parameters"],i);const r=ce(e,["parametersJsonSchema"]);null!=r&&ue(t,["parametersJsonSchema"],r);const s=ce(e,["response"]);null!=s&&ue(t,["response"],s);const l=ce(e,["responseJsonSchema"]);null!=l&&ue(t,["responseJsonSchema"],l);if(void 0!==ce(e,["behavior"]))throw new Error("behavior parameter is not supported in Vertex AI.");return t}(e))),ue(t,["functionDeclarations"],e)}const l=ce(e,["googleMaps"]);null!=l&&ue(t,["googleMaps"],l);const a=ce(e,["googleSearch"]);null!=a&&ue(t,["googleSearch"],a);const u=ce(e,["googleSearchRetrieval"]);null!=u&&ue(t,["googleSearchRetrieval"],u);const c=ce(e,["urlContext"]);null!=c&&ue(t,["urlContext"],c);return t}(e))),ue(t,["tools"],e)}const a=ce(e,["toolConfig"]);void 0!==t&&null!=a&&ue(t,["toolConfig"],a);const u=ce(e,["kmsKeyName"]);return void 0!==t&&null!=u&&ue(t,["encryption_spec","kmsKeyName"],u),{}}function Vt(e){const t={},n=ce(e,["config"]);return null!=n&&function(e,t){const n=ce(e,["pageSize"]);void 0!==t&&null!=n&&ue(t,["_query","pageSize"],n);const o=ce(e,["pageToken"]);void 0!==t&&null!=o&&ue(t,["_query","pageToken"],o)}(n,t),t}function Bt(e){const t={},n=ce(e,["config"]);return null!=n&&function(e,t){const n=ce(e,["pageSize"]);void 0!==t&&null!=n&&ue(t,["_query","pageSize"],n);const o=ce(e,["pageToken"]);void 0!==t&&null!=o&&ue(t,["_query","pageToken"],o)}(n,t),t}function Jt(e,t){const n={},o=ce(t,["name"]);null!=o&&ue(n,["_url","name"],mt(e,o));const i=ce(t,["config"]);return null!=i&&function(e,t){const n=ce(e,["ttl"]);void 0!==t&&null!=n&&ue(t,["ttl"],n);const o=ce(e,["expireTime"]);void 0!==t&&null!=o&&ue(t,["expireTime"],o)}(i,n),n}function $t(e,t){const n={},o=ce(t,["name"]);null!=o&&ue(n,["_url","name"],mt(e,o));const i=ce(t,["config"]);return null!=i&&function(e,t){const n=ce(e,["ttl"]);void 0!==t&&null!=n&&ue(t,["ttl"],n);const o=ce(e,["expireTime"]);void 0!==t&&null!=o&&ue(t,["expireTime"],o)}(i,n),n}
53
+ */function Ft(e){const t={},n=ce(e,["parts"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>function(e){const t={},n=ce(e,["mediaResolution"]);null!=n&&ue(t,["mediaResolution"],n);const o=ce(e,["codeExecutionResult"]);null!=o&&ue(t,["codeExecutionResult"],o);const i=ce(e,["executableCode"]);null!=i&&ue(t,["executableCode"],i);const r=ce(e,["fileData"]);null!=r&&ue(t,["fileData"],function(e){const t={};if(void 0!==ce(e,["displayName"]))throw new Error("displayName parameter is not supported in Gemini API.");const n=ce(e,["fileUri"]);null!=n&&ue(t,["fileUri"],n);const o=ce(e,["mimeType"]);null!=o&&ue(t,["mimeType"],o);return t}(r));const s=ce(e,["functionCall"]);null!=s&&ue(t,["functionCall"],function(e){const t={},n=ce(e,["id"]);null!=n&&ue(t,["id"],n);const o=ce(e,["args"]);null!=o&&ue(t,["args"],o);const i=ce(e,["name"]);null!=i&&ue(t,["name"],i);if(void 0!==ce(e,["partialArgs"]))throw new Error("partialArgs parameter is not supported in Gemini API.");if(void 0!==ce(e,["willContinue"]))throw new Error("willContinue parameter is not supported in Gemini API.");return t}(s));const l=ce(e,["functionResponse"]);null!=l&&ue(t,["functionResponse"],l);const a=ce(e,["inlineData"]);null!=a&&ue(t,["inlineData"],function(e){const t={},n=ce(e,["data"]);if(null!=n&&ue(t,["data"],n),void 0!==ce(e,["displayName"]))throw new Error("displayName parameter is not supported in Gemini API.");const o=ce(e,["mimeType"]);return null!=o&&ue(t,["mimeType"],o),t}(a));const u=ce(e,["text"]);null!=u&&ue(t,["text"],u);const c=ce(e,["thought"]);null!=c&&ue(t,["thought"],c);const p=ce(e,["thoughtSignature"]);null!=p&&ue(t,["thoughtSignature"],p);const d=ce(e,["videoMetadata"]);null!=d&&ue(t,["videoMetadata"],d);return t}(e))),ue(t,["parts"],e)}const o=ce(e,["role"]);return null!=o&&ue(t,["role"],o),t}function Ht(e,t){const n=ce(e,["ttl"]);void 0!==t&&null!=n&&ue(t,["ttl"],n);const o=ce(e,["expireTime"]);void 0!==t&&null!=o&&ue(t,["expireTime"],o);const i=ce(e,["displayName"]);void 0!==t&&null!=i&&ue(t,["displayName"],i);const r=ce(e,["contents"]);if(void 0!==t&&null!=r){let e=at(r);Array.isArray(e)&&(e=e.map(e=>Ft(e))),ue(t,["contents"],e)}const s=ce(e,["systemInstruction"]);void 0!==t&&null!=s&&ue(t,["systemInstruction"],Ft(st(s)));const l=ce(e,["tools"]);if(void 0!==t&&null!=l){let e=l;Array.isArray(e)&&(e=e.map(e=>function(e){const t={};if(void 0!==ce(e,["retrieval"]))throw new Error("retrieval parameter is not supported in Gemini API.");const n=ce(e,["computerUse"]);null!=n&&ue(t,["computerUse"],n);const o=ce(e,["fileSearch"]);null!=o&&ue(t,["fileSearch"],o);const i=ce(e,["codeExecution"]);null!=i&&ue(t,["codeExecution"],i);if(void 0!==ce(e,["enterpriseWebSearch"]))throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const r=ce(e,["functionDeclarations"]);if(null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["functionDeclarations"],e)}const s=ce(e,["googleMaps"]);null!=s&&ue(t,["googleMaps"],function(e){const t={};if(void 0!==ce(e,["authConfig"]))throw new Error("authConfig parameter is not supported in Gemini API.");const n=ce(e,["enableWidget"]);null!=n&&ue(t,["enableWidget"],n);return t}(s));const l=ce(e,["googleSearch"]);null!=l&&ue(t,["googleSearch"],function(e){const t={};if(void 0!==ce(e,["excludeDomains"]))throw new Error("excludeDomains parameter is not supported in Gemini API.");if(void 0!==ce(e,["blockingConfidence"]))throw new Error("blockingConfidence parameter is not supported in Gemini API.");const n=ce(e,["timeRangeFilter"]);null!=n&&ue(t,["timeRangeFilter"],n);return t}(l));const a=ce(e,["googleSearchRetrieval"]);null!=a&&ue(t,["googleSearchRetrieval"],a);const u=ce(e,["urlContext"]);null!=u&&ue(t,["urlContext"],u);return t}(e))),ue(t,["tools"],e)}const a=ce(e,["toolConfig"]);if(void 0!==t&&null!=a&&ue(t,["toolConfig"],function(e){const t={},n=ce(e,["retrievalConfig"]);null!=n&&ue(t,["retrievalConfig"],n);const o=ce(e,["functionCallingConfig"]);null!=o&&ue(t,["functionCallingConfig"],function(e){const t={},n=ce(e,["allowedFunctionNames"]);null!=n&&ue(t,["allowedFunctionNames"],n);const o=ce(e,["mode"]);null!=o&&ue(t,["mode"],o);if(void 0!==ce(e,["streamFunctionCallArguments"]))throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return t}(o));return t}(a)),void 0!==ce(e,["kmsKeyName"]))throw new Error("kmsKeyName parameter is not supported in Gemini API.");return{}}function jt(e,t){const n=ce(e,["ttl"]);void 0!==t&&null!=n&&ue(t,["ttl"],n);const o=ce(e,["expireTime"]);void 0!==t&&null!=o&&ue(t,["expireTime"],o);const i=ce(e,["displayName"]);void 0!==t&&null!=i&&ue(t,["displayName"],i);const r=ce(e,["contents"]);if(void 0!==t&&null!=r){let e=at(r);Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["contents"],e)}const s=ce(e,["systemInstruction"]);void 0!==t&&null!=s&&ue(t,["systemInstruction"],st(s));const l=ce(e,["tools"]);if(void 0!==t&&null!=l){let e=l;Array.isArray(e)&&(e=e.map(e=>function(e){const t={},n=ce(e,["retrieval"]);null!=n&&ue(t,["retrieval"],n);const o=ce(e,["computerUse"]);null!=o&&ue(t,["computerUse"],o);if(void 0!==ce(e,["fileSearch"]))throw new Error("fileSearch parameter is not supported in Vertex AI.");const i=ce(e,["codeExecution"]);null!=i&&ue(t,["codeExecution"],i);const r=ce(e,["enterpriseWebSearch"]);null!=r&&ue(t,["enterpriseWebSearch"],r);const s=ce(e,["functionDeclarations"]);if(null!=s){let e=s;Array.isArray(e)&&(e=e.map(e=>function(e){const t={},n=ce(e,["description"]);null!=n&&ue(t,["description"],n);const o=ce(e,["name"]);null!=o&&ue(t,["name"],o);const i=ce(e,["parameters"]);null!=i&&ue(t,["parameters"],i);const r=ce(e,["parametersJsonSchema"]);null!=r&&ue(t,["parametersJsonSchema"],r);const s=ce(e,["response"]);null!=s&&ue(t,["response"],s);const l=ce(e,["responseJsonSchema"]);null!=l&&ue(t,["responseJsonSchema"],l);if(void 0!==ce(e,["behavior"]))throw new Error("behavior parameter is not supported in Vertex AI.");return t}(e))),ue(t,["functionDeclarations"],e)}const l=ce(e,["googleMaps"]);null!=l&&ue(t,["googleMaps"],l);const a=ce(e,["googleSearch"]);null!=a&&ue(t,["googleSearch"],a);const u=ce(e,["googleSearchRetrieval"]);null!=u&&ue(t,["googleSearchRetrieval"],u);const c=ce(e,["urlContext"]);null!=c&&ue(t,["urlContext"],c);return t}(e))),ue(t,["tools"],e)}const a=ce(e,["toolConfig"]);void 0!==t&&null!=a&&ue(t,["toolConfig"],a);const u=ce(e,["kmsKeyName"]);return void 0!==t&&null!=u&&ue(t,["encryption_spec","kmsKeyName"],u),{}}function Vt(e){const t={},n=ce(e,["config"]);return null!=n&&function(e,t){const n=ce(e,["pageSize"]);void 0!==t&&null!=n&&ue(t,["_query","pageSize"],n);const o=ce(e,["pageToken"]);void 0!==t&&null!=o&&ue(t,["_query","pageToken"],o)}(n,t),t}function Bt(e){const t={},n=ce(e,["config"]);return null!=n&&function(e,t){const n=ce(e,["pageSize"]);void 0!==t&&null!=n&&ue(t,["_query","pageSize"],n);const o=ce(e,["pageToken"]);void 0!==t&&null!=o&&ue(t,["_query","pageToken"],o)}(n,t),t}function Jt(e,t){const n={},o=ce(t,["name"]);null!=o&&ue(n,["_url","name"],mt(e,o));const i=ce(t,["config"]);return null!=i&&function(e,t){const n=ce(e,["ttl"]);void 0!==t&&null!=n&&ue(t,["ttl"],n);const o=ce(e,["expireTime"]);void 0!==t&&null!=o&&ue(t,["expireTime"],o)}(i,n),n}function Yt(e,t){const n={},o=ce(t,["name"]);null!=o&&ue(n,["_url","name"],mt(e,o));const i=ce(t,["config"]);return null!=i&&function(e,t){const n=ce(e,["ttl"]);void 0!==t&&null!=n&&ue(t,["ttl"],n);const o=ce(e,["expireTime"]);void 0!==t&&null!=o&&ue(t,["expireTime"],o)}(i,n),n}
54
54
  /**
55
55
  * @license
56
56
  * Copyright 2025 Google LLC
57
57
  * SPDX-License-Identifier: Apache-2.0
58
- */class Yt extends le{constructor(t){super(),this.apiClient=t,this.list=async(t={})=>new qt(e.PagedItem.PAGED_ITEM_CACHED_CONTENTS,e=>this.listInternal(e),await this.listInternal(t),t)}async create(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=function(e,t){const n={},o=ce(t,["model"]);null!=o&&ue(n,["model"],ze(e,o));const i=ce(t,["config"]);return null!=i&&jt(i,n),n}(this.apiClient,e);return s=ae("cachedContents",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),r.then(e=>e)}{const t=function(e,t){const n={},o=ce(t,["model"]);null!=o&&ue(n,["model"],ze(e,o));const i=ce(t,["config"]);return null!=i&&Ht(i,n),n}(this.apiClient,e);return s=ae("cachedContents",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json()),r.then(e=>e)}}async get(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=function(e,t){const n={},o=ce(t,["name"]);return null!=o&&ue(n,["_url","name"],mt(e,o)),n}(this.apiClient,e);return s=ae("{name}",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"GET",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),r.then(e=>e)}{const t=function(e,t){const n={},o=ce(t,["name"]);return null!=o&&ue(n,["_url","name"],mt(e,o)),n}(this.apiClient,e);return s=ae("{name}",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"GET",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json()),r.then(e=>e)}}async delete(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=function(e,t){const n={},o=ce(t,["name"]);return null!=o&&ue(n,["_url","name"],mt(e,o)),n}(this.apiClient,e);return s=ae("{name}",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"DELETE",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);return null!=n&&ue(t,["sdkHttpResponse"],n),t}(e),n=new xe;return Object.assign(n,t),n})}{const t=function(e,t){const n={},o=ce(t,["name"]);return null!=o&&ue(n,["_url","name"],mt(e,o)),n}(this.apiClient,e);return s=ae("{name}",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"DELETE",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);return null!=n&&ue(t,["sdkHttpResponse"],n),t}(e),n=new xe;return Object.assign(n,t),n})}}async update(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=$t(this.apiClient,e);return s=ae("{name}",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"PATCH",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),r.then(e=>e)}{const t=Jt(this.apiClient,e);return s=ae("{name}",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"PATCH",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json()),r.then(e=>e)}}async listInternal(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=Bt(e);return s=ae("cachedContents",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"GET",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["nextPageToken"]);null!=o&&ue(t,["nextPageToken"],o);const i=ce(e,["cachedContents"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["cachedContents"],e)}return t}(e),n=new Le;return Object.assign(n,t),n})}{const t=Vt(e);return s=ae("cachedContents",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"GET",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["nextPageToken"]);null!=o&&ue(t,["nextPageToken"],o);const i=ce(e,["cachedContents"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["cachedContents"],e)}return t}(e),n=new Le;return Object.assign(n,t),n})}}}function Kt(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(e);i<o.length;i++)t.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(e,o[i])&&(n[o[i]]=e[o[i]])}return n}function Wt(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],o=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&o>=e.length&&(e=void 0),{value:e&&e[o++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function zt(e){return this instanceof zt?(this.v=e,this):new zt(e)}function Xt(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o,i=n.apply(e,t||[]),r=[];return o=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),s("next"),s("throw"),s("return",function(e){return function(t){return Promise.resolve(t).then(e,u)}}),o[Symbol.asyncIterator]=function(){return this},o;function s(e,t){i[e]&&(o[e]=function(t){return new Promise(function(n,o){r.push([e,t,n,o])>1||l(e,t)})},t&&(o[e]=t(o[e])))}function l(e,t){try{(n=i[e](t)).value instanceof zt?Promise.resolve(n.value.v).then(a,u):c(r[0][2],n)}catch(e){c(r[0][3],e)}var n}function a(e){l("next",e)}function u(e){l("throw",e)}function c(e,t){e(t),r.shift(),r.length&&l(r[0][0],r[0][1])}}function Qt(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=Wt(e),t={},o("next"),o("throw"),o("return"),t[Symbol.asyncIterator]=function(){return this},t);function o(n){t[n]=e[n]&&function(t){return new Promise(function(o,i){(function(e,t,n,o){Promise.resolve(o).then(function(t){e({value:t,done:n})},t)})(o,i,(t=e[n](t)).done,t.value)})}}}
58
+ */class $t extends le{constructor(t){super(),this.apiClient=t,this.list=async(t={})=>new Gt(e.PagedItem.PAGED_ITEM_CACHED_CONTENTS,e=>this.listInternal(e),await this.listInternal(t),t)}async create(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=function(e,t){const n={},o=ce(t,["model"]);null!=o&&ue(n,["model"],ze(e,o));const i=ce(t,["config"]);return null!=i&&jt(i,n),n}(this.apiClient,e);return s=ae("cachedContents",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),r.then(e=>e)}{const t=function(e,t){const n={},o=ce(t,["model"]);null!=o&&ue(n,["model"],ze(e,o));const i=ce(t,["config"]);return null!=i&&Ht(i,n),n}(this.apiClient,e);return s=ae("cachedContents",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json()),r.then(e=>e)}}async get(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=function(e,t){const n={},o=ce(t,["name"]);return null!=o&&ue(n,["_url","name"],mt(e,o)),n}(this.apiClient,e);return s=ae("{name}",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"GET",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),r.then(e=>e)}{const t=function(e,t){const n={},o=ce(t,["name"]);return null!=o&&ue(n,["_url","name"],mt(e,o)),n}(this.apiClient,e);return s=ae("{name}",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"GET",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json()),r.then(e=>e)}}async delete(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=function(e,t){const n={},o=ce(t,["name"]);return null!=o&&ue(n,["_url","name"],mt(e,o)),n}(this.apiClient,e);return s=ae("{name}",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"DELETE",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);return null!=n&&ue(t,["sdkHttpResponse"],n),t}(e),n=new xe;return Object.assign(n,t),n})}{const t=function(e,t){const n={},o=ce(t,["name"]);return null!=o&&ue(n,["_url","name"],mt(e,o)),n}(this.apiClient,e);return s=ae("{name}",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"DELETE",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);return null!=n&&ue(t,["sdkHttpResponse"],n),t}(e),n=new xe;return Object.assign(n,t),n})}}async update(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=Yt(this.apiClient,e);return s=ae("{name}",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"PATCH",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),r.then(e=>e)}{const t=Jt(this.apiClient,e);return s=ae("{name}",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"PATCH",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json()),r.then(e=>e)}}async listInternal(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=Bt(e);return s=ae("cachedContents",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"GET",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["nextPageToken"]);null!=o&&ue(t,["nextPageToken"],o);const i=ce(e,["cachedContents"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["cachedContents"],e)}return t}(e),n=new Le;return Object.assign(n,t),n})}{const t=Vt(e);return s=ae("cachedContents",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"GET",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["nextPageToken"]);null!=o&&ue(t,["nextPageToken"],o);const i=ce(e,["cachedContents"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["cachedContents"],e)}return t}(e),n=new Le;return Object.assign(n,t),n})}}}function Kt(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(e);i<o.length;i++)t.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(e,o[i])&&(n[o[i]]=e[o[i]])}return n}function Wt(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],o=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&o>=e.length&&(e=void 0),{value:e&&e[o++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function zt(e){return this instanceof zt?(this.v=e,this):new zt(e)}function Xt(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o,i=n.apply(e,t||[]),r=[];return o=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),s("next"),s("throw"),s("return",function(e){return function(t){return Promise.resolve(t).then(e,u)}}),o[Symbol.asyncIterator]=function(){return this},o;function s(e,t){i[e]&&(o[e]=function(t){return new Promise(function(n,o){r.push([e,t,n,o])>1||l(e,t)})},t&&(o[e]=t(o[e])))}function l(e,t){try{(n=i[e](t)).value instanceof zt?Promise.resolve(n.value.v).then(a,u):c(r[0][2],n)}catch(e){c(r[0][3],e)}var n}function a(e){l("next",e)}function u(e){l("throw",e)}function c(e,t){e(t),r.shift(),r.length&&l(r[0][0],r[0][1])}}function Qt(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=Wt(e),t={},o("next"),o("throw"),o("return"),t[Symbol.asyncIterator]=function(){return this},t);function o(n){t[n]=e[n]&&function(t){return new Promise(function(o,i){(function(e,t,n,o){Promise.resolve(o).then(function(t){e({value:t,done:n})},t)})(o,i,(t=e[n](t)).done,t.value)})}}}
59
59
  /**
60
60
  * @license
61
61
  * Copyright 2025 Google LLC
@@ -103,7 +103,7 @@ class pn extends Error{constructor(e){super(e.message),this.name="ApiError",this
103
103
  * Copyright 2025 Google LLC
104
104
  * SPDX-License-Identifier: Apache-2.0
105
105
  */
106
- class An extends le{constructor(t){super(),this.apiClient=t,this.list=async(t={})=>new qt(e.PagedItem.PAGED_ITEM_FILES,e=>this.listInternal(e),await this.listInternal(t),t)}async upload(e){if(this.apiClient.isVertexAI())throw new Error("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 new Error("registerFiles is only supported in Node.js environments.")}async _registerFiles(e){return this.registerFilesInternal(e)}async listInternal(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const s=Sn(e);return i=ae("files",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"GET",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),o.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["nextPageToken"]);null!=o&&ue(t,["nextPageToken"],o);const i=ce(e,["files"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["files"],e)}return t}(e),n=new He;return Object.assign(n,t),n})}}async createInternal(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const s=function(e){const t={},n=ce(e,["file"]);return null!=n&&ue(t,["file"],n),t}(e);return i=ae("upload/v1beta/files",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),o.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);return null!=n&&ue(t,["sdkHttpResponse"],n),t}(e),n=new je;return Object.assign(n,t),n})}}async get(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const s=function(e){const t={},n=ce(e,["name"]);return null!=n&&ue(t,["_url","file"],vt(n)),t}(e);return i=ae("files/{file}",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"GET",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),o.then(e=>e)}}async delete(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const s=function(e){const t={},n=ce(e,["name"]);return null!=n&&ue(t,["_url","file"],vt(n)),t}(e);return i=ae("files/{file}",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"DELETE",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),o.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);return null!=n&&ue(t,["sdkHttpResponse"],n),t}(e),n=new Ve;return Object.assign(n,t),n})}}async registerFilesInternal(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const s=function(e){const t={},n=ce(e,["uris"]);return null!=n&&ue(t,["uris"],n),t}(e);return i=ae("files:register",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),o.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["files"]);if(null!=o){let e=o;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["files"],e)}return t}(e),n=new Be;return Object.assign(n,t),n})}}}
106
+ class An extends le{constructor(t){super(),this.apiClient=t,this.list=async(t={})=>new Gt(e.PagedItem.PAGED_ITEM_FILES,e=>this.listInternal(e),await this.listInternal(t),t)}async upload(e){if(this.apiClient.isVertexAI())throw new Error("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 new Error("registerFiles is only supported in Node.js environments.")}async _registerFiles(e){return this.registerFilesInternal(e)}async listInternal(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const s=Sn(e);return i=ae("files",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"GET",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),o.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["nextPageToken"]);null!=o&&ue(t,["nextPageToken"],o);const i=ce(e,["files"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["files"],e)}return t}(e),n=new He;return Object.assign(n,t),n})}}async createInternal(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const s=function(e){const t={},n=ce(e,["file"]);return null!=n&&ue(t,["file"],n),t}(e);return i=ae("upload/v1beta/files",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),o.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);return null!=n&&ue(t,["sdkHttpResponse"],n),t}(e),n=new je;return Object.assign(n,t),n})}}async get(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const s=function(e){const t={},n=ce(e,["name"]);return null!=n&&ue(t,["_url","file"],vt(n)),t}(e);return i=ae("files/{file}",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"GET",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),o.then(e=>e)}}async delete(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const s=function(e){const t={},n=ce(e,["name"]);return null!=n&&ue(t,["_url","file"],vt(n)),t}(e);return i=ae("files/{file}",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"DELETE",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),o.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);return null!=n&&ue(t,["sdkHttpResponse"],n),t}(e),n=new Ve;return Object.assign(n,t),n})}}async registerFilesInternal(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const s=function(e){const t={},n=ce(e,["uris"]);return null!=n&&ue(t,["uris"],n),t}(e);return i=ae("files:register",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),o.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["files"]);if(null!=o){let e=o;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["files"],e)}return t}(e),n=new Be;return Object.assign(n,t),n})}}}
107
107
  /**
108
108
  * @license
109
109
  * Copyright 2025 Google LLC
@@ -114,12 +114,12 @@ class An extends le{constructor(t){super(),this.apiClient=t,this.list=async(t={}
114
114
  * Copyright 2025 Google LLC
115
115
  * SPDX-License-Identifier: Apache-2.0
116
116
  */
117
- class bn extends le{constructor(t){super(),this.apiClient=t,this.list=async t=>new qt(e.PagedItem.PAGED_ITEM_DOCUMENTS,e=>this.listInternal({parent:t.parent,config:e.config}),await this.listInternal(t),t)}async get(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const s=function(e){const t={},n=ce(e,["name"]);return null!=n&&ue(t,["_url","name"],n),t}(e);return i=ae("{name}",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"GET",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),o.then(e=>e)}}async delete(e){var t,n;let o="",i={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const r=Cn(e);o=ae("{name}",r._url),i=r._query,delete r._url,delete r._query,await this.apiClient.request({path:o,queryParams:i,body:JSON.stringify(r),httpMethod:"DELETE",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal})}}async listInternal(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const s=On(e);return i=ae("{parent}/documents",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"GET",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),o.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["nextPageToken"]);null!=o&&ue(t,["nextPageToken"],o);const i=ce(e,["documents"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["documents"],e)}return t}(e),n=new ke;return Object.assign(n,t),n})}}}
117
+ class bn extends le{constructor(t){super(),this.apiClient=t,this.list=async t=>new Gt(e.PagedItem.PAGED_ITEM_DOCUMENTS,e=>this.listInternal({parent:t.parent,config:e.config}),await this.listInternal(t),t)}async get(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const s=function(e){const t={},n=ce(e,["name"]);return null!=n&&ue(t,["_url","name"],n),t}(e);return i=ae("{name}",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"GET",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),o.then(e=>e)}}async delete(e){var t,n;let o="",i={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const r=Cn(e);o=ae("{name}",r._url),i=r._query,delete r._url,delete r._query,await this.apiClient.request({path:o,queryParams:i,body:JSON.stringify(r),httpMethod:"DELETE",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal})}}async listInternal(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const s=On(e);return i=ae("{parent}/documents",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"GET",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),o.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["nextPageToken"]);null!=o&&ue(t,["nextPageToken"],o);const i=ce(e,["documents"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["documents"],e)}return t}(e),n=new ke;return Object.assign(n,t),n})}}}
118
118
  /**
119
119
  * @license
120
120
  * Copyright 2025 Google LLC
121
121
  * SPDX-License-Identifier: Apache-2.0
122
- */class Rn extends le{constructor(t,n=new bn(t)){super(),this.apiClient=t,this.documents=n,this.list=async(t={})=>new qt(e.PagedItem.PAGED_ITEM_FILE_SEARCH_STORES,e=>this.listInternal(e),await this.listInternal(t),t)}async uploadToFileSearchStore(e){if(this.apiClient.isVertexAI())throw new Error("Vertex AI does not support uploading files to a file search store.");return this.apiClient.uploadFileToFileSearchStore(e.fileSearchStoreName,e.file,e.config)}async create(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const s=rn(e);return i=ae("fileSearchStores",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),o.then(e=>e)}}async get(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const s=function(e){const t={},n=ce(e,["name"]);return null!=n&&ue(t,["_url","name"],n),t}(e);return i=ae("{name}",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"GET",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),o.then(e=>e)}}async delete(e){var t,n;let o="",i={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const r=sn(e);o=ae("{name}",r._url),i=r._query,delete r._url,delete r._query,await this.apiClient.request({path:o,queryParams:i,body:JSON.stringify(r),httpMethod:"DELETE",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal})}}async listInternal(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const s=un(e);return i=ae("fileSearchStores",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"GET",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),o.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["nextPageToken"]);null!=o&&ue(t,["nextPageToken"],o);const i=ce(e,["fileSearchStores"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["fileSearchStores"],e)}return t}(e),n=new qe;return Object.assign(n,t),n})}}async uploadToFileSearchStoreInternal(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const s=function(e){const t={},n=ce(e,["fileSearchStoreName"]);null!=n&&ue(t,["_url","file_search_store_name"],n);const o=ce(e,["config"]);return null!=o&&cn(o,t),t}(e);return i=ae("upload/v1beta/{file_search_store_name}:uploadToFileSearchStore",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),o.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);return null!=n&&ue(t,["sdkHttpResponse"],n),t}(e),n=new Ge;return Object.assign(n,t),n})}}async importFile(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const s=an(e);return i=ae("{file_search_store_name}:importFile",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),o.then(e=>{const t=ln(e),n=new Fe;return Object.assign(n,t),n})}}}
122
+ */class Rn extends le{constructor(t,n=new bn(t)){super(),this.apiClient=t,this.documents=n,this.list=async(t={})=>new Gt(e.PagedItem.PAGED_ITEM_FILE_SEARCH_STORES,e=>this.listInternal(e),await this.listInternal(t),t)}async uploadToFileSearchStore(e){if(this.apiClient.isVertexAI())throw new Error("Vertex AI does not support uploading files to a file search store.");return this.apiClient.uploadFileToFileSearchStore(e.fileSearchStoreName,e.file,e.config)}async create(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const s=rn(e);return i=ae("fileSearchStores",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),o.then(e=>e)}}async get(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const s=function(e){const t={},n=ce(e,["name"]);return null!=n&&ue(t,["_url","name"],n),t}(e);return i=ae("{name}",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"GET",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),o.then(e=>e)}}async delete(e){var t,n;let o="",i={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const r=sn(e);o=ae("{name}",r._url),i=r._query,delete r._url,delete r._query,await this.apiClient.request({path:o,queryParams:i,body:JSON.stringify(r),httpMethod:"DELETE",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal})}}async listInternal(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const s=un(e);return i=ae("fileSearchStores",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"GET",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),o.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["nextPageToken"]);null!=o&&ue(t,["nextPageToken"],o);const i=ce(e,["fileSearchStores"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["fileSearchStores"],e)}return t}(e),n=new Ge;return Object.assign(n,t),n})}}async uploadToFileSearchStoreInternal(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const s=function(e){const t={},n=ce(e,["fileSearchStoreName"]);null!=n&&ue(t,["_url","file_search_store_name"],n);const o=ce(e,["config"]);return null!=o&&cn(o,t),t}(e);return i=ae("upload/v1beta/{file_search_store_name}:uploadToFileSearchStore",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),o.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);return null!=n&&ue(t,["sdkHttpResponse"],n),t}(e),n=new qe;return Object.assign(n,t),n})}}async importFile(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const s=an(e);return i=ae("{file_search_store_name}:importFile",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),o.then(e=>{const t=ln(e),n=new Fe;return Object.assign(n,t),n})}}}
123
123
  /**
124
124
  * @license
125
125
  * Copyright 2025 Google LLC
@@ -135,12 +135,12 @@ function Nn(e){return"object"==typeof e&&null!==e&&("name"in e&&"AbortError"===e
135
135
  * @license
136
136
  * Copyright 2025 Google LLC
137
137
  * SPDX-License-Identifier: Apache-2.0
138
- */class Mn extends Error{}class Dn extends Mn{constructor(e,t,n,o){super(`${Dn.makeMessage(e,t,n)}`),this.status=e,this.headers=o,this.error=t}static makeMessage(e,t,n){const o=(null==t?void 0:t.message)?"string"==typeof t.message?t.message:JSON.stringify(t.message):t?JSON.stringify(t):n;return e&&o?`${e} ${o}`:e?`${e} status code (no body)`:o||"(no status code or body)"}static generate(e,t,n,o){if(!e||!o)return new xn({message:n,cause:Pn(t)});const i=t;return 400===e?new kn(e,i,n,o):401===e?new qn(e,i,n,o):403===e?new Gn(e,i,n,o):404===e?new Fn(e,i,n,o):409===e?new Hn(e,i,n,o):422===e?new jn(e,i,n,o):429===e?new Vn(e,i,n,o):e>=500?new Bn(e,i,n,o):new Dn(e,i,n,o)}}class Un extends Dn{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}}class xn extends Dn{constructor({message:e,cause:t}){super(void 0,void 0,e||"Connection error.",void 0),t&&(this.cause=t)}}class Ln extends xn{constructor({message:e}={}){super({message:null!=e?e:"Request timed out."})}}class kn extends Dn{}class qn extends Dn{}class Gn extends Dn{}class Fn extends Dn{}class Hn extends Dn{}class jn extends Dn{}class Vn extends Dn{}class Bn extends Dn{}
138
+ */class Mn extends Error{}class Dn extends Mn{constructor(e,t,n,o){super(`${Dn.makeMessage(e,t,n)}`),this.status=e,this.headers=o,this.error=t}static makeMessage(e,t,n){const o=(null==t?void 0:t.message)?"string"==typeof t.message?t.message:JSON.stringify(t.message):t?JSON.stringify(t):n;return e&&o?`${e} ${o}`:e?`${e} status code (no body)`:o||"(no status code or body)"}static generate(e,t,n,o){if(!e||!o)return new xn({message:n,cause:Pn(t)});const i=t;return 400===e?new kn(e,i,n,o):401===e?new Gn(e,i,n,o):403===e?new qn(e,i,n,o):404===e?new Fn(e,i,n,o):409===e?new Hn(e,i,n,o):422===e?new jn(e,i,n,o):429===e?new Vn(e,i,n,o):e>=500?new Bn(e,i,n,o):new Dn(e,i,n,o)}}class Un extends Dn{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}}class xn extends Dn{constructor({message:e,cause:t}){super(void 0,void 0,e||"Connection error.",void 0),t&&(this.cause=t)}}class Ln extends xn{constructor({message:e}={}){super({message:null!=e?e:"Request timed out."})}}class kn extends Dn{}class Gn extends Dn{}class qn extends Dn{}class Fn extends Dn{}class Hn extends Dn{}class jn extends Dn{}class Vn extends Dn{}class Bn extends Dn{}
139
139
  /**
140
140
  * @license
141
141
  * Copyright 2025 Google LLC
142
142
  * SPDX-License-Identifier: Apache-2.0
143
- */const Jn=/^[a-z][a-z0-9+.-]*:/i;let $n=e=>($n=Array.isArray,$n(e));const Yn=$n;const Kn="0.0.1";const Wn=()=>{var e,t,n,o,i;const r="undefined"!=typeof Deno&&null!=Deno.build?"deno":"undefined"!=typeof EdgeRuntime?"edge":"[object process]"===Object.prototype.toString.call(void 0!==globalThis.process?globalThis.process:0)?"node":"unknown";if("deno"===r)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Kn,"X-Stainless-OS":Xn(Deno.build.os),"X-Stainless-Arch":zn(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":"string"==typeof Deno.version?Deno.version:null!==(t=null===(e=Deno.version)||void 0===e?void 0:e.deno)&&void 0!==t?t:"unknown"};if("undefined"!=typeof EdgeRuntime)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Kn,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if("node"===r)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Kn,"X-Stainless-OS":Xn(null!==(n=globalThis.process.platform)&&void 0!==n?n:"unknown"),"X-Stainless-Arch":zn(null!==(o=globalThis.process.arch)&&void 0!==o?o:"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":null!==(i=globalThis.process.version)&&void 0!==i?i:"unknown"};const s=function(){if("undefined"==typeof navigator||!navigator)return null;const e=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(const{key:t,pattern:n}of e){const e=n.exec(navigator.userAgent);if(e){return{browser:t,version:`${e[1]||0}.${e[2]||0}.${e[3]||0}`}}}return null}();return s?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Kn,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${s.browser}`,"X-Stainless-Runtime-Version":s.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Kn,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};const zn=e=>"x32"===e?"x32":"x86_64"===e||"x64"===e?"x64":"arm"===e?"arm":"aarch64"===e||"arm64"===e?"arm64":e?`other:${e}`:"unknown",Xn=e=>(e=e.toLowerCase()).includes("ios")?"iOS":"android"===e?"Android":"darwin"===e?"MacOS":"win32"===e?"Windows":"freebsd"===e?"FreeBSD":"openbsd"===e?"OpenBSD":"linux"===e?"Linux":e?`Other:${e}`:"Unknown";let Qn;function Zn(...e){const t=globalThis.ReadableStream;if(void 0===t)throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function eo(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return Zn({start(){},async pull(e){const{done:n,value:o}=await t.next();n?e.close():e.enqueue(o)},async cancel(){var e;await(null===(e=t.return)||void 0===e?void 0:e.call(t))}})}function to(e){if(e[Symbol.asyncIterator])return e;const t=e.getReader();return{async next(){try{const e=await t.read();return(null==e?void 0:e.done)&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){const e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}
143
+ */const Jn=/^[a-z][a-z0-9+.-]*:/i;let Yn=e=>(Yn=Array.isArray,Yn(e));const $n=Yn;const Kn="0.0.1";const Wn=()=>{var e,t,n,o,i;const r="undefined"!=typeof Deno&&null!=Deno.build?"deno":"undefined"!=typeof EdgeRuntime?"edge":"[object process]"===Object.prototype.toString.call(void 0!==globalThis.process?globalThis.process:0)?"node":"unknown";if("deno"===r)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Kn,"X-Stainless-OS":Xn(Deno.build.os),"X-Stainless-Arch":zn(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":"string"==typeof Deno.version?Deno.version:null!==(t=null===(e=Deno.version)||void 0===e?void 0:e.deno)&&void 0!==t?t:"unknown"};if("undefined"!=typeof EdgeRuntime)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Kn,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if("node"===r)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Kn,"X-Stainless-OS":Xn(null!==(n=globalThis.process.platform)&&void 0!==n?n:"unknown"),"X-Stainless-Arch":zn(null!==(o=globalThis.process.arch)&&void 0!==o?o:"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":null!==(i=globalThis.process.version)&&void 0!==i?i:"unknown"};const s=function(){if("undefined"==typeof navigator||!navigator)return null;const e=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(const{key:t,pattern:n}of e){const e=n.exec(navigator.userAgent);if(e){return{browser:t,version:`${e[1]||0}.${e[2]||0}.${e[3]||0}`}}}return null}();return s?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Kn,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${s.browser}`,"X-Stainless-Runtime-Version":s.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Kn,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};const zn=e=>"x32"===e?"x32":"x86_64"===e||"x64"===e?"x64":"arm"===e?"arm":"aarch64"===e||"arm64"===e?"arm64":e?`other:${e}`:"unknown",Xn=e=>(e=e.toLowerCase()).includes("ios")?"iOS":"android"===e?"Android":"darwin"===e?"MacOS":"win32"===e?"Windows":"freebsd"===e?"FreeBSD":"openbsd"===e?"OpenBSD":"linux"===e?"Linux":e?`Other:${e}`:"Unknown";let Qn;function Zn(...e){const t=globalThis.ReadableStream;if(void 0===t)throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function eo(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return Zn({start(){},async pull(e){const{done:n,value:o}=await t.next();n?e.close():e.enqueue(o)},async cancel(){var e;await(null===(e=t.return)||void 0===e?void 0:e.call(t))}})}function to(e){if(e[Symbol.asyncIterator])return e;const t=e.getReader();return{async next(){try{const e=await t.read();return(null==e?void 0:e.done)&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){const e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}
144
144
  /**
145
145
  * @license
146
146
  * Copyright 2025 Google LLC
@@ -208,7 +208,7 @@ class ho extends lo{create(e,t){var n;const{api_version:o=this._client.apiVersio
208
208
  * @license
209
209
  * Copyright 2025 Google LLC
210
210
  * SPDX-License-Identifier: Apache-2.0
211
- */const Uo=Symbol("brand.privateNullableHeaders");function*xo(e){if(!e)return;if(Uo in e){const{values:t,nulls:n}=e;yield*t.entries();for(const e of n)yield[e,null];return}let t,n=!1;e instanceof Headers?t=e.entries():Yn(e)?t=e:(n=!0,t=Object.entries(null!=e?e:{}));for(let e of t){const t=e[0];if("string"!=typeof t)throw new TypeError("expected header name to be a string");const o=Yn(e[1])?e[1]:[e[1]];let i=!1;for(const e of o)void 0!==e&&(n&&!i&&(i=!0,yield[t,null]),yield[t,e])}}const Lo=e=>{const t=new Headers,n=new Set;for(const o of e){const e=new Set;for(const[i,r]of xo(o)){const o=i.toLowerCase();e.has(o)||(t.delete(i),e.add(o)),null===r?(t.delete(i),n.add(o)):(t.append(i,r),n.delete(o))}}return{[Uo]:!0,values:t,nulls:n}},ko=e=>{var t,n,o,i,r,s;return void 0!==globalThis.process?null!==(o=null===(n=null===(t=globalThis.process.env)||void 0===t?void 0:t[e])||void 0===n?void 0:n.trim())&&void 0!==o?o:void 0:void 0!==globalThis.Deno?null===(s=null===(r=null===(i=globalThis.Deno.env)||void 0===i?void 0:i.get)||void 0===r?void 0:r.call(i,e))||void 0===s?void 0:s.trim():void 0};
211
+ */const Uo=Symbol("brand.privateNullableHeaders");function*xo(e){if(!e)return;if(Uo in e){const{values:t,nulls:n}=e;yield*t.entries();for(const e of n)yield[e,null];return}let t,n=!1;e instanceof Headers?t=e.entries():$n(e)?t=e:(n=!0,t=Object.entries(null!=e?e:{}));for(let e of t){const t=e[0];if("string"!=typeof t)throw new TypeError("expected header name to be a string");const o=$n(e[1])?e[1]:[e[1]];let i=!1;for(const e of o)void 0!==e&&(n&&!i&&(i=!0,yield[t,null]),yield[t,e])}}const Lo=e=>{const t=new Headers,n=new Set;for(const o of e){const e=new Set;for(const[i,r]of xo(o)){const o=i.toLowerCase();e.has(o)||(t.delete(i),e.add(o)),null===r?(t.delete(i),n.add(o)):(t.append(i,r),n.delete(o))}}return{[Uo]:!0,values:t,nulls:n}},ko=e=>{var t,n,o,i,r,s;return void 0!==globalThis.process?null!==(o=null===(n=null===(t=globalThis.process.env)||void 0===t?void 0:t[e])||void 0===n?void 0:n.trim())&&void 0!==o?o:void 0:void 0!==globalThis.Deno?null===(s=null===(r=null===(i=globalThis.Deno.env)||void 0===i?void 0:i.get)||void 0===r?void 0:r.call(i,e))||void 0===s?void 0:s.trim():void 0};
212
212
  /**
213
213
  * @license
214
214
  * Copyright 2025 Google LLC
@@ -219,19 +219,19 @@ class ho extends lo{create(e,t){var n;const{api_version:o=this._client.apiVersio
219
219
  * Copyright 2025 Google LLC
220
220
  * SPDX-License-Identifier: Apache-2.0
221
221
  */
222
- var qo;class Go{constructor(e){var t,n,o,i,r,s,l,{baseURL:a=ko("GEMINI_NEXT_GEN_API_BASE_URL"),apiKey:u=(null!==(t=ko("GEMINI_API_KEY"))&&void 0!==t?t:null),apiVersion:c="v1beta"}=e,p=Kt(e,["baseURL","apiKey","apiVersion"]);const d=Object.assign(Object.assign({apiKey:u,apiVersion:c},p),{baseURL:a||"https://generativelanguage.googleapis.com"});this.baseURL=d.baseURL,this.timeout=null!==(n=d.timeout)&&void 0!==n?n:Go.DEFAULT_TIMEOUT,this.logger=null!==(o=d.logger)&&void 0!==o?o:console;const h="warn";this.logLevel=h,this.logLevel=null!==(r=null!==(i=So(d.logLevel,"ClientOptions.logLevel",this))&&void 0!==i?i:So(ko("GEMINI_NEXT_GEN_API_LOG"),"process.env['GEMINI_NEXT_GEN_API_LOG']",this))&&void 0!==r?r:h,this.fetchOptions=d.fetchOptions,this.maxRetries=null!==(s=d.maxRetries)&&void 0!==s?s:2,this.fetch=null!==(l=d.fetch)&&void 0!==l?l:
222
+ var Go;class qo{constructor(e){var t,n,o,i,r,s,l,{baseURL:a=ko("GEMINI_NEXT_GEN_API_BASE_URL"),apiKey:u=(null!==(t=ko("GEMINI_API_KEY"))&&void 0!==t?t:null),apiVersion:c="v1beta"}=e,p=Kt(e,["baseURL","apiKey","apiVersion"]);const d=Object.assign(Object.assign({apiKey:u,apiVersion:c},p),{baseURL:a||"https://generativelanguage.googleapis.com"});this.baseURL=d.baseURL,this.timeout=null!==(n=d.timeout)&&void 0!==n?n:qo.DEFAULT_TIMEOUT,this.logger=null!==(o=d.logger)&&void 0!==o?o:console;const h="warn";this.logLevel=h,this.logLevel=null!==(r=null!==(i=So(d.logLevel,"ClientOptions.logLevel",this))&&void 0!==i?i:So(ko("GEMINI_NEXT_GEN_API_LOG"),"process.env['GEMINI_NEXT_GEN_API_LOG']",this))&&void 0!==r?r:h,this.fetchOptions=d.fetchOptions,this.maxRetries=null!==(s=d.maxRetries)&&void 0!==s?s:2,this.fetch=null!==(l=d.fetch)&&void 0!==l?l:
223
223
  /**
224
224
  * @license
225
225
  * Copyright 2025 Google LLC
226
226
  * SPDX-License-Identifier: Apache-2.0
227
227
  */
228
- function(){if("undefined"!=typeof fetch)return fetch;throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new GeminiNextGenAPIClient({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}(),this.encoder=no,this._options=d,this.apiKey=u,this.apiVersion=c,this.clientAdapter=d.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"https://generativelanguage.googleapis.com"!==this.baseURL}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 new 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){const t=Lo([e.headers]);if(!t.values.has("authorization")&&!t.values.has("x-goog-api-key"))return this.apiKey?Lo([{"x-goog-api-key":this.apiKey}]):this.clientAdapter.isVertexAI()?Lo([await this.clientAdapter.getAuthHeaders()]):void 0}stringifyQuery(e){return Object.entries(e).filter(([e,t])=>void 0!==t).map(([e,t])=>{if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return`${encodeURIComponent(e)}=${encodeURIComponent(t)}`;if(null===t)return`${encodeURIComponent(e)}=`;throw new Mn(`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("&")}getUserAgent(){return`${this.constructor.name}/JS ${Kn}`}defaultIdempotencyKey(){return`stainless-node-retry-${wn()}`}makeStatusError(e,t,n,o){return Dn.generate(e,t,n,o)}buildURL(e,t,n){const o=!this.baseURLOverridden()&&n||this.baseURL,i=(e=>Jn.test(e))(e)?new URL(e):new URL(o+(o.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),r=this.defaultQuery();return function(e){if(!e)return!0;for(const t in e)return!1;return!0}(r)||(t=Object.assign(Object.assign({},r),t)),"object"==typeof t&&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/`)){const 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 Do(this,this.makeRequest(e,t,void 0))}async makeRequest(e,t,n){var o,i,r;const s=await e,l=null!==(o=s.maxRetries)&&void 0!==o?o:this.maxRetries;null==t&&(t=l),await this.prepareOptions(s);const{req:a,url:u,timeout:c}=await this.buildRequest(s,{retryCount:l-t});await this.prepareRequest(a,{url:u,options:s});const p="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),d=void 0===n?"":`, retryOf: ${n}`,h=Date.now();if(Ro(this).debug(`[${p}] sending request`,wo({retryOfRequestLogID:n,method:s.method,url:u,options:s,headers:a.headers})),null===(i=s.signal)||void 0===i?void 0:i.aborted)throw new Un;const f=new AbortController,m=await this.fetchWithTimeout(u,a,c,f).catch(Pn),g=Date.now();if(m instanceof globalThis.Error){const e=`retrying, ${t} attempts remaining`;if(null===(r=s.signal)||void 0===r?void 0:r.aborted)throw new Un;const o=Nn(m)||/timed? ?out/i.test(String(m)+("cause"in m?String(m.cause):""));if(t)return Ro(this).info(`[${p}] connection ${o?"timed out":"failed"} - ${e}`),Ro(this).debug(`[${p}] connection ${o?"timed out":"failed"} (${e})`,wo({retryOfRequestLogID:n,url:u,durationMs:g-h,message:m.message})),this.retryRequest(s,t,null!=n?n:p);if(Ro(this).info(`[${p}] connection ${o?"timed out":"failed"} - error; no more retries left`),Ro(this).debug(`[${p}] connection ${o?"timed out":"failed"} (error; no more retries left)`,wo({retryOfRequestLogID:n,url:u,durationMs:g-h,message:m.message})),o)throw new Ln;throw new xn({cause:m})}const y=`[${p}${d}] ${a.method} ${u} ${m.ok?"succeeded":"failed"} with status ${m.status} in ${g-h}ms`;if(!m.ok){const e=await this.shouldRetry(m);if(t&&e){const e=`retrying, ${t} attempts remaining`;return await async function(e){var t,n;if(null===e||"object"!=typeof e)return;if(e[Symbol.asyncIterator])return void await(null===(n=(t=e[Symbol.asyncIterator]()).return)||void 0===n?void 0:n.call(t));const o=e.getReader(),i=o.cancel();o.releaseLock(),await i}(m.body),Ro(this).info(`${y} - ${e}`),Ro(this).debug(`[${p}] response error (${e})`,wo({retryOfRequestLogID:n,url:m.url,status:m.status,headers:m.headers,durationMs:g-h})),this.retryRequest(s,t,null!=n?n:p,m.headers)}const o=e?"error; no more retries left":"error; not retryable";Ro(this).info(`${y} - ${o}`);const i=await m.text().catch(e=>Pn(e).message),r=(e=>{try{return JSON.parse(e)}catch(e){return}})(i),l=r?void 0:i;Ro(this).debug(`[${p}] response error (${o})`,wo({retryOfRequestLogID:n,url:m.url,status:m.status,headers:m.headers,message:l,durationMs:Date.now()-h}));throw this.makeStatusError(m.status,r,l,m.headers)}return Ro(this).info(y),Ro(this).debug(`[${p}] response start`,wo({retryOfRequestLogID:n,url:m.url,status:m.status,headers:m.headers,durationMs:g-h})),{response:m,options:s,controller:f,requestLogID:p,retryOfRequestLogID:n,startTime:h}}async fetchWithTimeout(e,t,n,o){const i=t||{},{signal:r,method:s}=i,l=Kt(i,["signal","method"]),a=this._makeAbort(o);r&&r.addEventListener("abort",a,{once:!0});const u=setTimeout(a,n),c=globalThis.ReadableStream&&l.body instanceof globalThis.ReadableStream||"object"==typeof l.body&&null!==l.body&&Symbol.asyncIterator in l.body,p=Object.assign(Object.assign(Object.assign({signal:o.signal},c?{duplex:"half"}:{}),{method:"GET"}),l);s&&(p.method=s.toUpperCase());try{return await this.fetch.call(void 0,e,p)}finally{clearTimeout(u)}}async shouldRetry(e){const t=e.headers.get("x-should-retry");return"true"===t||"false"!==t&&(408===e.status||(409===e.status||(429===e.status||e.status>=500)))}async retryRequest(e,t,n,o){var i;let r;const s=null==o?void 0:o.get("retry-after-ms");if(s){const e=parseFloat(s);Number.isNaN(e)||(r=e)}const l=null==o?void 0:o.get("retry-after");if(l&&!r){const e=parseFloat(l);r=Number.isNaN(e)?Date.parse(l)-Date.now():1e3*e}if(!(r&&0<=r&&r<6e4)){const n=null!==(i=e.maxRetries)&&void 0!==i?i:this.maxRetries;r=this.calculateDefaultRetryTimeoutMillis(t,n)}var a;return await(a=r,new Promise(e=>setTimeout(e,a))),this.makeRequest(e,t-1,n)}calculateDefaultRetryTimeoutMillis(e,t){const n=t-e;return Math.min(.5*Math.pow(2,n),8)*(1-.25*Math.random())*1e3}async buildRequest(e,{retryCount:t=0}={}){var n,o,i;const r=Object.assign({},e),{method:s,path:l,query:a,defaultBaseURL:u}=r,c=this.buildURL(l,a,u);"timeout"in r&&((e,t)=>{if("number"!=typeof t||!Number.isInteger(t))throw new Mn(`${e} must be an integer`);if(t<0)throw new Mn(`${e} must be a positive integer`)})("timeout",r.timeout),r.timeout=null!==(n=r.timeout)&&void 0!==n?n:this.timeout;const{bodyHeaders:p,body:d}=this.buildBody({options:r}),h=await this.buildHeaders({options:e,method:s,bodyHeaders:p,retryCount:t});return{req:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({method:s,headers:h},r.signal&&{signal:r.signal}),globalThis.ReadableStream&&d instanceof globalThis.ReadableStream&&{duplex:"half"}),d&&{body:d}),null!==(o=this.fetchOptions)&&void 0!==o?o:{}),null!==(i=r.fetchOptions)&&void 0!==i?i:{}),url:c,timeout:r.timeout}}async buildHeaders({options:e,method:t,bodyHeaders:n,retryCount:o}){let i={};this.idempotencyHeader&&"get"!==t&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),i[this.idempotencyHeader]=e.idempotencyKey);const r=await this.authHeaders(e);let s=Lo([i,Object.assign(Object.assign({Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(o)},e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{}),null!=Qn?Qn:Qn=Wn()),this._options.defaultHeaders,n,e.headers,r]);return this.validateHeaders(s),s.values}_makeAbort(e){return()=>e.abort()}buildBody({options:{body:e,headers:t}}){if(!e)return{bodyHeaders:void 0,body:void 0};const n=Lo([t]);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||"string"==typeof e&&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}:"object"==typeof e&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&"function"==typeof e.next)?{bodyHeaders:void 0,body:eo(e)}:"object"==typeof e&&"application/x-www-form-urlencoded"===n.values.get("content-type")?{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(e)}:this.encoder({body:e,headers:n})}}Go.DEFAULT_TIMEOUT=6e4;class Fo extends Go{constructor(){super(...arguments),this.interactions=new fo(this)}}
228
+ function(){if("undefined"!=typeof fetch)return fetch;throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new GeminiNextGenAPIClient({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}(),this.encoder=no,this._options=d,this.apiKey=u,this.apiVersion=c,this.clientAdapter=d.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"https://generativelanguage.googleapis.com"!==this.baseURL}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 new 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){const t=Lo([e.headers]);if(!t.values.has("authorization")&&!t.values.has("x-goog-api-key"))return this.apiKey?Lo([{"x-goog-api-key":this.apiKey}]):this.clientAdapter.isVertexAI()?Lo([await this.clientAdapter.getAuthHeaders()]):void 0}stringifyQuery(e){return Object.entries(e).filter(([e,t])=>void 0!==t).map(([e,t])=>{if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return`${encodeURIComponent(e)}=${encodeURIComponent(t)}`;if(null===t)return`${encodeURIComponent(e)}=`;throw new Mn(`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("&")}getUserAgent(){return`${this.constructor.name}/JS ${Kn}`}defaultIdempotencyKey(){return`stainless-node-retry-${wn()}`}makeStatusError(e,t,n,o){return Dn.generate(e,t,n,o)}buildURL(e,t,n){const o=!this.baseURLOverridden()&&n||this.baseURL,i=(e=>Jn.test(e))(e)?new URL(e):new URL(o+(o.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),r=this.defaultQuery();return function(e){if(!e)return!0;for(const t in e)return!1;return!0}(r)||(t=Object.assign(Object.assign({},r),t)),"object"==typeof t&&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/`)){const 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 Do(this,this.makeRequest(e,t,void 0))}async makeRequest(e,t,n){var o,i,r;const s=await e,l=null!==(o=s.maxRetries)&&void 0!==o?o:this.maxRetries;null==t&&(t=l),await this.prepareOptions(s);const{req:a,url:u,timeout:c}=await this.buildRequest(s,{retryCount:l-t});await this.prepareRequest(a,{url:u,options:s});const p="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),d=void 0===n?"":`, retryOf: ${n}`,h=Date.now();if(Ro(this).debug(`[${p}] sending request`,wo({retryOfRequestLogID:n,method:s.method,url:u,options:s,headers:a.headers})),null===(i=s.signal)||void 0===i?void 0:i.aborted)throw new Un;const f=new AbortController,m=await this.fetchWithTimeout(u,a,c,f).catch(Pn),g=Date.now();if(m instanceof globalThis.Error){const e=`retrying, ${t} attempts remaining`;if(null===(r=s.signal)||void 0===r?void 0:r.aborted)throw new Un;const o=Nn(m)||/timed? ?out/i.test(String(m)+("cause"in m?String(m.cause):""));if(t)return Ro(this).info(`[${p}] connection ${o?"timed out":"failed"} - ${e}`),Ro(this).debug(`[${p}] connection ${o?"timed out":"failed"} (${e})`,wo({retryOfRequestLogID:n,url:u,durationMs:g-h,message:m.message})),this.retryRequest(s,t,null!=n?n:p);if(Ro(this).info(`[${p}] connection ${o?"timed out":"failed"} - error; no more retries left`),Ro(this).debug(`[${p}] connection ${o?"timed out":"failed"} (error; no more retries left)`,wo({retryOfRequestLogID:n,url:u,durationMs:g-h,message:m.message})),o)throw new Ln;throw new xn({cause:m})}const y=`[${p}${d}] ${a.method} ${u} ${m.ok?"succeeded":"failed"} with status ${m.status} in ${g-h}ms`;if(!m.ok){const e=await this.shouldRetry(m);if(t&&e){const e=`retrying, ${t} attempts remaining`;return await async function(e){var t,n;if(null===e||"object"!=typeof e)return;if(e[Symbol.asyncIterator])return void await(null===(n=(t=e[Symbol.asyncIterator]()).return)||void 0===n?void 0:n.call(t));const o=e.getReader(),i=o.cancel();o.releaseLock(),await i}(m.body),Ro(this).info(`${y} - ${e}`),Ro(this).debug(`[${p}] response error (${e})`,wo({retryOfRequestLogID:n,url:m.url,status:m.status,headers:m.headers,durationMs:g-h})),this.retryRequest(s,t,null!=n?n:p,m.headers)}const o=e?"error; no more retries left":"error; not retryable";Ro(this).info(`${y} - ${o}`);const i=await m.text().catch(e=>Pn(e).message),r=(e=>{try{return JSON.parse(e)}catch(e){return}})(i),l=r?void 0:i;Ro(this).debug(`[${p}] response error (${o})`,wo({retryOfRequestLogID:n,url:m.url,status:m.status,headers:m.headers,message:l,durationMs:Date.now()-h}));throw this.makeStatusError(m.status,r,l,m.headers)}return Ro(this).info(y),Ro(this).debug(`[${p}] response start`,wo({retryOfRequestLogID:n,url:m.url,status:m.status,headers:m.headers,durationMs:g-h})),{response:m,options:s,controller:f,requestLogID:p,retryOfRequestLogID:n,startTime:h}}async fetchWithTimeout(e,t,n,o){const i=t||{},{signal:r,method:s}=i,l=Kt(i,["signal","method"]),a=this._makeAbort(o);r&&r.addEventListener("abort",a,{once:!0});const u=setTimeout(a,n),c=globalThis.ReadableStream&&l.body instanceof globalThis.ReadableStream||"object"==typeof l.body&&null!==l.body&&Symbol.asyncIterator in l.body,p=Object.assign(Object.assign(Object.assign({signal:o.signal},c?{duplex:"half"}:{}),{method:"GET"}),l);s&&(p.method=s.toUpperCase());try{return await this.fetch.call(void 0,e,p)}finally{clearTimeout(u)}}async shouldRetry(e){const t=e.headers.get("x-should-retry");return"true"===t||"false"!==t&&(408===e.status||(409===e.status||(429===e.status||e.status>=500)))}async retryRequest(e,t,n,o){var i;let r;const s=null==o?void 0:o.get("retry-after-ms");if(s){const e=parseFloat(s);Number.isNaN(e)||(r=e)}const l=null==o?void 0:o.get("retry-after");if(l&&!r){const e=parseFloat(l);r=Number.isNaN(e)?Date.parse(l)-Date.now():1e3*e}if(!(r&&0<=r&&r<6e4)){const n=null!==(i=e.maxRetries)&&void 0!==i?i:this.maxRetries;r=this.calculateDefaultRetryTimeoutMillis(t,n)}var a;return await(a=r,new Promise(e=>setTimeout(e,a))),this.makeRequest(e,t-1,n)}calculateDefaultRetryTimeoutMillis(e,t){const n=t-e;return Math.min(.5*Math.pow(2,n),8)*(1-.25*Math.random())*1e3}async buildRequest(e,{retryCount:t=0}={}){var n,o,i;const r=Object.assign({},e),{method:s,path:l,query:a,defaultBaseURL:u}=r,c=this.buildURL(l,a,u);"timeout"in r&&((e,t)=>{if("number"!=typeof t||!Number.isInteger(t))throw new Mn(`${e} must be an integer`);if(t<0)throw new Mn(`${e} must be a positive integer`)})("timeout",r.timeout),r.timeout=null!==(n=r.timeout)&&void 0!==n?n:this.timeout;const{bodyHeaders:p,body:d}=this.buildBody({options:r}),h=await this.buildHeaders({options:e,method:s,bodyHeaders:p,retryCount:t});return{req:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({method:s,headers:h},r.signal&&{signal:r.signal}),globalThis.ReadableStream&&d instanceof globalThis.ReadableStream&&{duplex:"half"}),d&&{body:d}),null!==(o=this.fetchOptions)&&void 0!==o?o:{}),null!==(i=r.fetchOptions)&&void 0!==i?i:{}),url:c,timeout:r.timeout}}async buildHeaders({options:e,method:t,bodyHeaders:n,retryCount:o}){let i={};this.idempotencyHeader&&"get"!==t&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),i[this.idempotencyHeader]=e.idempotencyKey);const r=await this.authHeaders(e);let s=Lo([i,Object.assign(Object.assign({Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(o)},e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{}),null!=Qn?Qn:Qn=Wn()),this._options.defaultHeaders,n,e.headers,r]);return this.validateHeaders(s),s.values}_makeAbort(e){return()=>e.abort()}buildBody({options:{body:e,headers:t}}){if(!e)return{bodyHeaders:void 0,body:void 0};const n=Lo([t]);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||"string"==typeof e&&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}:"object"==typeof e&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&"function"==typeof e.next)?{bodyHeaders:void 0,body:eo(e)}:"object"==typeof e&&"application/x-www-form-urlencoded"===n.values.get("content-type")?{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(e)}:this.encoder({body:e,headers:n})}}qo.DEFAULT_TIMEOUT=6e4;class Fo extends qo{constructor(){super(...arguments),this.interactions=new fo(this)}}
229
229
  /**
230
230
  * @license
231
231
  * Copyright 2025 Google LLC
232
232
  * SPDX-License-Identifier: Apache-2.0
233
233
  */
234
- function Ho(e){const t={},n=ce(e,["data"]);if(null!=n&&ue(t,["data"],n),void 0!==ce(e,["displayName"]))throw new Error("displayName parameter is not supported in Gemini API.");const o=ce(e,["mimeType"]);return null!=o&&ue(t,["mimeType"],o),t}function jo(e){const t={},n=ce(e,["parts"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>function(e){const t={},n=ce(e,["mediaResolution"]);null!=n&&ue(t,["mediaResolution"],n);const o=ce(e,["codeExecutionResult"]);null!=o&&ue(t,["codeExecutionResult"],o);const i=ce(e,["executableCode"]);null!=i&&ue(t,["executableCode"],i);const r=ce(e,["fileData"]);null!=r&&ue(t,["fileData"],function(e){const t={};if(void 0!==ce(e,["displayName"]))throw new Error("displayName parameter is not supported in Gemini API.");const n=ce(e,["fileUri"]);null!=n&&ue(t,["fileUri"],n);const o=ce(e,["mimeType"]);null!=o&&ue(t,["mimeType"],o);return t}(r));const s=ce(e,["functionCall"]);null!=s&&ue(t,["functionCall"],function(e){const t={},n=ce(e,["id"]);null!=n&&ue(t,["id"],n);const o=ce(e,["args"]);null!=o&&ue(t,["args"],o);const i=ce(e,["name"]);null!=i&&ue(t,["name"],i);if(void 0!==ce(e,["partialArgs"]))throw new Error("partialArgs parameter is not supported in Gemini API.");if(void 0!==ce(e,["willContinue"]))throw new Error("willContinue parameter is not supported in Gemini API.");return t}(s));const l=ce(e,["functionResponse"]);null!=l&&ue(t,["functionResponse"],l);const a=ce(e,["inlineData"]);null!=a&&ue(t,["inlineData"],Ho(a));const u=ce(e,["text"]);null!=u&&ue(t,["text"],u);const c=ce(e,["thought"]);null!=c&&ue(t,["thought"],c);const p=ce(e,["thoughtSignature"]);null!=p&&ue(t,["thoughtSignature"],p);const d=ce(e,["videoMetadata"]);null!=d&&ue(t,["videoMetadata"],d);return t}(e))),ue(t,["parts"],e)}const o=ce(e,["role"]);return null!=o&&ue(t,["role"],o),t}function Vo(e,t){const n=ce(e,["generationConfig"]);void 0!==t&&null!=n&&ue(t,["setup","generationConfig"],n);const o=ce(e,["responseModalities"]);void 0!==t&&null!=o&&ue(t,["setup","generationConfig","responseModalities"],o);const i=ce(e,["temperature"]);void 0!==t&&null!=i&&ue(t,["setup","generationConfig","temperature"],i);const r=ce(e,["topP"]);void 0!==t&&null!=r&&ue(t,["setup","generationConfig","topP"],r);const s=ce(e,["topK"]);void 0!==t&&null!=s&&ue(t,["setup","generationConfig","topK"],s);const l=ce(e,["maxOutputTokens"]);void 0!==t&&null!=l&&ue(t,["setup","generationConfig","maxOutputTokens"],l);const a=ce(e,["mediaResolution"]);void 0!==t&&null!=a&&ue(t,["setup","generationConfig","mediaResolution"],a);const u=ce(e,["seed"]);void 0!==t&&null!=u&&ue(t,["setup","generationConfig","seed"],u);const c=ce(e,["speechConfig"]);void 0!==t&&null!=c&&ue(t,["setup","generationConfig","speechConfig"],dt(c));const p=ce(e,["thinkingConfig"]);void 0!==t&&null!=p&&ue(t,["setup","generationConfig","thinkingConfig"],p);const d=ce(e,["enableAffectiveDialog"]);void 0!==t&&null!=d&&ue(t,["setup","generationConfig","enableAffectiveDialog"],d);const h=ce(e,["systemInstruction"]);void 0!==t&&null!=h&&ue(t,["setup","systemInstruction"],jo(st(h)));const f=ce(e,["tools"]);if(void 0!==t&&null!=f){let e=ft(f);Array.isArray(e)&&(e=e.map(e=>function(e){const t={};if(void 0!==ce(e,["retrieval"]))throw new Error("retrieval parameter is not supported in Gemini API.");const n=ce(e,["computerUse"]);null!=n&&ue(t,["computerUse"],n);const o=ce(e,["fileSearch"]);null!=o&&ue(t,["fileSearch"],o);const i=ce(e,["codeExecution"]);null!=i&&ue(t,["codeExecution"],i);if(void 0!==ce(e,["enterpriseWebSearch"]))throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const r=ce(e,["functionDeclarations"]);if(null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["functionDeclarations"],e)}const s=ce(e,["googleMaps"]);null!=s&&ue(t,["googleMaps"],function(e){const t={};if(void 0!==ce(e,["authConfig"]))throw new Error("authConfig parameter is not supported in Gemini API.");const n=ce(e,["enableWidget"]);return null!=n&&ue(t,["enableWidget"],n),t}(s));const l=ce(e,["googleSearch"]);null!=l&&ue(t,["googleSearch"],function(e){const t={};if(void 0!==ce(e,["excludeDomains"]))throw new Error("excludeDomains parameter is not supported in Gemini API.");if(void 0!==ce(e,["blockingConfidence"]))throw new Error("blockingConfidence parameter is not supported in Gemini API.");const n=ce(e,["timeRangeFilter"]);return null!=n&&ue(t,["timeRangeFilter"],n),t}(l));const a=ce(e,["googleSearchRetrieval"]);null!=a&&ue(t,["googleSearchRetrieval"],a);const u=ce(e,["urlContext"]);null!=u&&ue(t,["urlContext"],u);return t}(ht(e)))),ue(t,["setup","tools"],e)}const m=ce(e,["sessionResumption"]);void 0!==t&&null!=m&&ue(t,["setup","sessionResumption"],function(e){const t={},n=ce(e,["handle"]);null!=n&&ue(t,["handle"],n);if(void 0!==ce(e,["transparent"]))throw new Error("transparent parameter is not supported in Gemini API.");return t}(m));const g=ce(e,["inputAudioTranscription"]);void 0!==t&&null!=g&&ue(t,["setup","inputAudioTranscription"],g);const y=ce(e,["outputAudioTranscription"]);void 0!==t&&null!=y&&ue(t,["setup","outputAudioTranscription"],y);const v=ce(e,["realtimeInputConfig"]);void 0!==t&&null!=v&&ue(t,["setup","realtimeInputConfig"],v);const E=ce(e,["contextWindowCompression"]);void 0!==t&&null!=E&&ue(t,["setup","contextWindowCompression"],E);const T=ce(e,["proactivity"]);if(void 0!==t&&null!=T&&ue(t,["setup","proactivity"],T),void 0!==ce(e,["explicitVadSignal"]))throw new Error("explicitVadSignal parameter is not supported in Gemini API.");return{}}function Bo(e,t){const n=ce(e,["generationConfig"]);void 0!==t&&null!=n&&ue(t,["setup","generationConfig"],function(e){const t={},n=ce(e,["modelSelectionConfig"]);null!=n&&ue(t,["modelConfig"],n);const o=ce(e,["responseJsonSchema"]);null!=o&&ue(t,["responseJsonSchema"],o);const i=ce(e,["audioTimestamp"]);null!=i&&ue(t,["audioTimestamp"],i);const r=ce(e,["candidateCount"]);null!=r&&ue(t,["candidateCount"],r);const s=ce(e,["enableAffectiveDialog"]);null!=s&&ue(t,["enableAffectiveDialog"],s);const l=ce(e,["frequencyPenalty"]);null!=l&&ue(t,["frequencyPenalty"],l);const a=ce(e,["logprobs"]);null!=a&&ue(t,["logprobs"],a);const u=ce(e,["maxOutputTokens"]);null!=u&&ue(t,["maxOutputTokens"],u);const c=ce(e,["mediaResolution"]);null!=c&&ue(t,["mediaResolution"],c);const p=ce(e,["presencePenalty"]);null!=p&&ue(t,["presencePenalty"],p);const d=ce(e,["responseLogprobs"]);null!=d&&ue(t,["responseLogprobs"],d);const h=ce(e,["responseMimeType"]);null!=h&&ue(t,["responseMimeType"],h);const f=ce(e,["responseModalities"]);null!=f&&ue(t,["responseModalities"],f);const m=ce(e,["responseSchema"]);null!=m&&ue(t,["responseSchema"],m);const g=ce(e,["routingConfig"]);null!=g&&ue(t,["routingConfig"],g);const y=ce(e,["seed"]);null!=y&&ue(t,["seed"],y);const v=ce(e,["speechConfig"]);null!=v&&ue(t,["speechConfig"],v);const E=ce(e,["stopSequences"]);null!=E&&ue(t,["stopSequences"],E);const T=ce(e,["temperature"]);null!=T&&ue(t,["temperature"],T);const I=ce(e,["thinkingConfig"]);null!=I&&ue(t,["thinkingConfig"],I);const _=ce(e,["topK"]);null!=_&&ue(t,["topK"],_);const S=ce(e,["topP"]);if(null!=S&&ue(t,["topP"],S),void 0!==ce(e,["enableEnhancedCivicAnswers"]))throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.");return t}(n));const o=ce(e,["responseModalities"]);void 0!==t&&null!=o&&ue(t,["setup","generationConfig","responseModalities"],o);const i=ce(e,["temperature"]);void 0!==t&&null!=i&&ue(t,["setup","generationConfig","temperature"],i);const r=ce(e,["topP"]);void 0!==t&&null!=r&&ue(t,["setup","generationConfig","topP"],r);const s=ce(e,["topK"]);void 0!==t&&null!=s&&ue(t,["setup","generationConfig","topK"],s);const l=ce(e,["maxOutputTokens"]);void 0!==t&&null!=l&&ue(t,["setup","generationConfig","maxOutputTokens"],l);const a=ce(e,["mediaResolution"]);void 0!==t&&null!=a&&ue(t,["setup","generationConfig","mediaResolution"],a);const u=ce(e,["seed"]);void 0!==t&&null!=u&&ue(t,["setup","generationConfig","seed"],u);const c=ce(e,["speechConfig"]);void 0!==t&&null!=c&&ue(t,["setup","generationConfig","speechConfig"],dt(c));const p=ce(e,["thinkingConfig"]);void 0!==t&&null!=p&&ue(t,["setup","generationConfig","thinkingConfig"],p);const d=ce(e,["enableAffectiveDialog"]);void 0!==t&&null!=d&&ue(t,["setup","generationConfig","enableAffectiveDialog"],d);const h=ce(e,["systemInstruction"]);void 0!==t&&null!=h&&ue(t,["setup","systemInstruction"],st(h));const f=ce(e,["tools"]);if(void 0!==t&&null!=f){let e=ft(f);Array.isArray(e)&&(e=e.map(e=>function(e){const t={},n=ce(e,["retrieval"]);null!=n&&ue(t,["retrieval"],n);const o=ce(e,["computerUse"]);null!=o&&ue(t,["computerUse"],o);if(void 0!==ce(e,["fileSearch"]))throw new Error("fileSearch parameter is not supported in Vertex AI.");const i=ce(e,["codeExecution"]);null!=i&&ue(t,["codeExecution"],i);const r=ce(e,["enterpriseWebSearch"]);null!=r&&ue(t,["enterpriseWebSearch"],r);const s=ce(e,["functionDeclarations"]);if(null!=s){let e=s;Array.isArray(e)&&(e=e.map(e=>function(e){const t={},n=ce(e,["description"]);null!=n&&ue(t,["description"],n);const o=ce(e,["name"]);null!=o&&ue(t,["name"],o);const i=ce(e,["parameters"]);null!=i&&ue(t,["parameters"],i);const r=ce(e,["parametersJsonSchema"]);null!=r&&ue(t,["parametersJsonSchema"],r);const s=ce(e,["response"]);null!=s&&ue(t,["response"],s);const l=ce(e,["responseJsonSchema"]);if(null!=l&&ue(t,["responseJsonSchema"],l),void 0!==ce(e,["behavior"]))throw new Error("behavior parameter is not supported in Vertex AI.");return t}(e))),ue(t,["functionDeclarations"],e)}const l=ce(e,["googleMaps"]);null!=l&&ue(t,["googleMaps"],l);const a=ce(e,["googleSearch"]);null!=a&&ue(t,["googleSearch"],a);const u=ce(e,["googleSearchRetrieval"]);null!=u&&ue(t,["googleSearchRetrieval"],u);const c=ce(e,["urlContext"]);null!=c&&ue(t,["urlContext"],c);return t}(ht(e)))),ue(t,["setup","tools"],e)}const m=ce(e,["sessionResumption"]);void 0!==t&&null!=m&&ue(t,["setup","sessionResumption"],m);const g=ce(e,["inputAudioTranscription"]);void 0!==t&&null!=g&&ue(t,["setup","inputAudioTranscription"],g);const y=ce(e,["outputAudioTranscription"]);void 0!==t&&null!=y&&ue(t,["setup","outputAudioTranscription"],y);const v=ce(e,["realtimeInputConfig"]);void 0!==t&&null!=v&&ue(t,["setup","realtimeInputConfig"],v);const E=ce(e,["contextWindowCompression"]);void 0!==t&&null!=E&&ue(t,["setup","contextWindowCompression"],E);const T=ce(e,["proactivity"]);void 0!==t&&null!=T&&ue(t,["setup","proactivity"],T);const I=ce(e,["explicitVadSignal"]);return void 0!==t&&null!=I&&ue(t,["setup","explicitVadSignal"],I),{}}function Jo(e){const t={},n=ce(e,["media"]);if(null!=n){let e=Xe(n);Array.isArray(e)&&(e=e.map(e=>Ho(e))),ue(t,["mediaChunks"],e)}const o=ce(e,["audio"]);null!=o&&ue(t,["audio"],Ho(et(o)));const i=ce(e,["audioStreamEnd"]);null!=i&&ue(t,["audioStreamEnd"],i);const r=ce(e,["video"]);null!=r&&ue(t,["video"],Ho(Ze(r)));const s=ce(e,["text"]);null!=s&&ue(t,["text"],s);const l=ce(e,["activityStart"]);null!=l&&ue(t,["activityStart"],l);const a=ce(e,["activityEnd"]);return null!=a&&ue(t,["activityEnd"],a),t}function $o(e){const t={},n=ce(e,["media"]);if(null!=n){let e=Xe(n);Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["mediaChunks"],e)}const o=ce(e,["audio"]);null!=o&&ue(t,["audio"],et(o));const i=ce(e,["audioStreamEnd"]);null!=i&&ue(t,["audioStreamEnd"],i);const r=ce(e,["video"]);null!=r&&ue(t,["video"],Ze(r));const s=ce(e,["text"]);null!=s&&ue(t,["text"],s);const l=ce(e,["activityStart"]);null!=l&&ue(t,["activityStart"],l);const a=ce(e,["activityEnd"]);return null!=a&&ue(t,["activityEnd"],a),t}function Yo(e){const t={},n=ce(e,["setupComplete"]);null!=n&&ue(t,["setupComplete"],n);const o=ce(e,["serverContent"]);null!=o&&ue(t,["serverContent"],o);const i=ce(e,["toolCall"]);null!=i&&ue(t,["toolCall"],i);const r=ce(e,["toolCallCancellation"]);null!=r&&ue(t,["toolCallCancellation"],r);const s=ce(e,["usageMetadata"]);null!=s&&ue(t,["usageMetadata"],function(e){const t={},n=ce(e,["promptTokenCount"]);null!=n&&ue(t,["promptTokenCount"],n);const o=ce(e,["cachedContentTokenCount"]);null!=o&&ue(t,["cachedContentTokenCount"],o);const i=ce(e,["candidatesTokenCount"]);null!=i&&ue(t,["responseTokenCount"],i);const r=ce(e,["toolUsePromptTokenCount"]);null!=r&&ue(t,["toolUsePromptTokenCount"],r);const s=ce(e,["thoughtsTokenCount"]);null!=s&&ue(t,["thoughtsTokenCount"],s);const l=ce(e,["totalTokenCount"]);null!=l&&ue(t,["totalTokenCount"],l);const a=ce(e,["promptTokensDetails"]);if(null!=a){let e=a;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["promptTokensDetails"],e)}const u=ce(e,["cacheTokensDetails"]);if(null!=u){let e=u;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["cacheTokensDetails"],e)}const c=ce(e,["candidatesTokensDetails"]);if(null!=c){let e=c;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["responseTokensDetails"],e)}const p=ce(e,["toolUsePromptTokensDetails"]);if(null!=p){let e=p;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["toolUsePromptTokensDetails"],e)}const d=ce(e,["trafficType"]);null!=d&&ue(t,["trafficType"],d);return t}(s));const l=ce(e,["goAway"]);null!=l&&ue(t,["goAway"],l);const a=ce(e,["sessionResumptionUpdate"]);null!=a&&ue(t,["sessionResumptionUpdate"],a);const u=ce(e,["voiceActivityDetectionSignal"]);null!=u&&ue(t,["voiceActivityDetectionSignal"],u);const c=ce(e,["voiceActivity"]);return null!=c&&ue(t,["voiceActivity"],function(e){const t={},n=ce(e,["type"]);null!=n&&ue(t,["voiceActivityType"],n);return t}
234
+ function Ho(e){const t={},n=ce(e,["data"]);if(null!=n&&ue(t,["data"],n),void 0!==ce(e,["displayName"]))throw new Error("displayName parameter is not supported in Gemini API.");const o=ce(e,["mimeType"]);return null!=o&&ue(t,["mimeType"],o),t}function jo(e){const t={},n=ce(e,["parts"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>function(e){const t={},n=ce(e,["mediaResolution"]);null!=n&&ue(t,["mediaResolution"],n);const o=ce(e,["codeExecutionResult"]);null!=o&&ue(t,["codeExecutionResult"],o);const i=ce(e,["executableCode"]);null!=i&&ue(t,["executableCode"],i);const r=ce(e,["fileData"]);null!=r&&ue(t,["fileData"],function(e){const t={};if(void 0!==ce(e,["displayName"]))throw new Error("displayName parameter is not supported in Gemini API.");const n=ce(e,["fileUri"]);null!=n&&ue(t,["fileUri"],n);const o=ce(e,["mimeType"]);null!=o&&ue(t,["mimeType"],o);return t}(r));const s=ce(e,["functionCall"]);null!=s&&ue(t,["functionCall"],function(e){const t={},n=ce(e,["id"]);null!=n&&ue(t,["id"],n);const o=ce(e,["args"]);null!=o&&ue(t,["args"],o);const i=ce(e,["name"]);null!=i&&ue(t,["name"],i);if(void 0!==ce(e,["partialArgs"]))throw new Error("partialArgs parameter is not supported in Gemini API.");if(void 0!==ce(e,["willContinue"]))throw new Error("willContinue parameter is not supported in Gemini API.");return t}(s));const l=ce(e,["functionResponse"]);null!=l&&ue(t,["functionResponse"],l);const a=ce(e,["inlineData"]);null!=a&&ue(t,["inlineData"],Ho(a));const u=ce(e,["text"]);null!=u&&ue(t,["text"],u);const c=ce(e,["thought"]);null!=c&&ue(t,["thought"],c);const p=ce(e,["thoughtSignature"]);null!=p&&ue(t,["thoughtSignature"],p);const d=ce(e,["videoMetadata"]);null!=d&&ue(t,["videoMetadata"],d);return t}(e))),ue(t,["parts"],e)}const o=ce(e,["role"]);return null!=o&&ue(t,["role"],o),t}function Vo(e,t){const n=ce(e,["generationConfig"]);void 0!==t&&null!=n&&ue(t,["setup","generationConfig"],n);const o=ce(e,["responseModalities"]);void 0!==t&&null!=o&&ue(t,["setup","generationConfig","responseModalities"],o);const i=ce(e,["temperature"]);void 0!==t&&null!=i&&ue(t,["setup","generationConfig","temperature"],i);const r=ce(e,["topP"]);void 0!==t&&null!=r&&ue(t,["setup","generationConfig","topP"],r);const s=ce(e,["topK"]);void 0!==t&&null!=s&&ue(t,["setup","generationConfig","topK"],s);const l=ce(e,["maxOutputTokens"]);void 0!==t&&null!=l&&ue(t,["setup","generationConfig","maxOutputTokens"],l);const a=ce(e,["mediaResolution"]);void 0!==t&&null!=a&&ue(t,["setup","generationConfig","mediaResolution"],a);const u=ce(e,["seed"]);void 0!==t&&null!=u&&ue(t,["setup","generationConfig","seed"],u);const c=ce(e,["speechConfig"]);void 0!==t&&null!=c&&ue(t,["setup","generationConfig","speechConfig"],dt(c));const p=ce(e,["thinkingConfig"]);void 0!==t&&null!=p&&ue(t,["setup","generationConfig","thinkingConfig"],p);const d=ce(e,["enableAffectiveDialog"]);void 0!==t&&null!=d&&ue(t,["setup","generationConfig","enableAffectiveDialog"],d);const h=ce(e,["systemInstruction"]);void 0!==t&&null!=h&&ue(t,["setup","systemInstruction"],jo(st(h)));const f=ce(e,["tools"]);if(void 0!==t&&null!=f){let e=ft(f);Array.isArray(e)&&(e=e.map(e=>function(e){const t={};if(void 0!==ce(e,["retrieval"]))throw new Error("retrieval parameter is not supported in Gemini API.");const n=ce(e,["computerUse"]);null!=n&&ue(t,["computerUse"],n);const o=ce(e,["fileSearch"]);null!=o&&ue(t,["fileSearch"],o);const i=ce(e,["codeExecution"]);null!=i&&ue(t,["codeExecution"],i);if(void 0!==ce(e,["enterpriseWebSearch"]))throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const r=ce(e,["functionDeclarations"]);if(null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["functionDeclarations"],e)}const s=ce(e,["googleMaps"]);null!=s&&ue(t,["googleMaps"],function(e){const t={};if(void 0!==ce(e,["authConfig"]))throw new Error("authConfig parameter is not supported in Gemini API.");const n=ce(e,["enableWidget"]);return null!=n&&ue(t,["enableWidget"],n),t}(s));const l=ce(e,["googleSearch"]);null!=l&&ue(t,["googleSearch"],function(e){const t={};if(void 0!==ce(e,["excludeDomains"]))throw new Error("excludeDomains parameter is not supported in Gemini API.");if(void 0!==ce(e,["blockingConfidence"]))throw new Error("blockingConfidence parameter is not supported in Gemini API.");const n=ce(e,["timeRangeFilter"]);return null!=n&&ue(t,["timeRangeFilter"],n),t}(l));const a=ce(e,["googleSearchRetrieval"]);null!=a&&ue(t,["googleSearchRetrieval"],a);const u=ce(e,["urlContext"]);null!=u&&ue(t,["urlContext"],u);return t}(ht(e)))),ue(t,["setup","tools"],e)}const m=ce(e,["sessionResumption"]);void 0!==t&&null!=m&&ue(t,["setup","sessionResumption"],function(e){const t={},n=ce(e,["handle"]);null!=n&&ue(t,["handle"],n);if(void 0!==ce(e,["transparent"]))throw new Error("transparent parameter is not supported in Gemini API.");return t}(m));const g=ce(e,["inputAudioTranscription"]);void 0!==t&&null!=g&&ue(t,["setup","inputAudioTranscription"],g);const y=ce(e,["outputAudioTranscription"]);void 0!==t&&null!=y&&ue(t,["setup","outputAudioTranscription"],y);const v=ce(e,["realtimeInputConfig"]);void 0!==t&&null!=v&&ue(t,["setup","realtimeInputConfig"],v);const E=ce(e,["contextWindowCompression"]);void 0!==t&&null!=E&&ue(t,["setup","contextWindowCompression"],E);const T=ce(e,["proactivity"]);if(void 0!==t&&null!=T&&ue(t,["setup","proactivity"],T),void 0!==ce(e,["explicitVadSignal"]))throw new Error("explicitVadSignal parameter is not supported in Gemini API.");return{}}function Bo(e,t){const n=ce(e,["generationConfig"]);void 0!==t&&null!=n&&ue(t,["setup","generationConfig"],function(e){const t={},n=ce(e,["modelSelectionConfig"]);null!=n&&ue(t,["modelConfig"],n);const o=ce(e,["responseJsonSchema"]);null!=o&&ue(t,["responseJsonSchema"],o);const i=ce(e,["audioTimestamp"]);null!=i&&ue(t,["audioTimestamp"],i);const r=ce(e,["candidateCount"]);null!=r&&ue(t,["candidateCount"],r);const s=ce(e,["enableAffectiveDialog"]);null!=s&&ue(t,["enableAffectiveDialog"],s);const l=ce(e,["frequencyPenalty"]);null!=l&&ue(t,["frequencyPenalty"],l);const a=ce(e,["logprobs"]);null!=a&&ue(t,["logprobs"],a);const u=ce(e,["maxOutputTokens"]);null!=u&&ue(t,["maxOutputTokens"],u);const c=ce(e,["mediaResolution"]);null!=c&&ue(t,["mediaResolution"],c);const p=ce(e,["presencePenalty"]);null!=p&&ue(t,["presencePenalty"],p);const d=ce(e,["responseLogprobs"]);null!=d&&ue(t,["responseLogprobs"],d);const h=ce(e,["responseMimeType"]);null!=h&&ue(t,["responseMimeType"],h);const f=ce(e,["responseModalities"]);null!=f&&ue(t,["responseModalities"],f);const m=ce(e,["responseSchema"]);null!=m&&ue(t,["responseSchema"],m);const g=ce(e,["routingConfig"]);null!=g&&ue(t,["routingConfig"],g);const y=ce(e,["seed"]);null!=y&&ue(t,["seed"],y);const v=ce(e,["speechConfig"]);null!=v&&ue(t,["speechConfig"],v);const E=ce(e,["stopSequences"]);null!=E&&ue(t,["stopSequences"],E);const T=ce(e,["temperature"]);null!=T&&ue(t,["temperature"],T);const I=ce(e,["thinkingConfig"]);null!=I&&ue(t,["thinkingConfig"],I);const _=ce(e,["topK"]);null!=_&&ue(t,["topK"],_);const S=ce(e,["topP"]);if(null!=S&&ue(t,["topP"],S),void 0!==ce(e,["enableEnhancedCivicAnswers"]))throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.");return t}(n));const o=ce(e,["responseModalities"]);void 0!==t&&null!=o&&ue(t,["setup","generationConfig","responseModalities"],o);const i=ce(e,["temperature"]);void 0!==t&&null!=i&&ue(t,["setup","generationConfig","temperature"],i);const r=ce(e,["topP"]);void 0!==t&&null!=r&&ue(t,["setup","generationConfig","topP"],r);const s=ce(e,["topK"]);void 0!==t&&null!=s&&ue(t,["setup","generationConfig","topK"],s);const l=ce(e,["maxOutputTokens"]);void 0!==t&&null!=l&&ue(t,["setup","generationConfig","maxOutputTokens"],l);const a=ce(e,["mediaResolution"]);void 0!==t&&null!=a&&ue(t,["setup","generationConfig","mediaResolution"],a);const u=ce(e,["seed"]);void 0!==t&&null!=u&&ue(t,["setup","generationConfig","seed"],u);const c=ce(e,["speechConfig"]);void 0!==t&&null!=c&&ue(t,["setup","generationConfig","speechConfig"],dt(c));const p=ce(e,["thinkingConfig"]);void 0!==t&&null!=p&&ue(t,["setup","generationConfig","thinkingConfig"],p);const d=ce(e,["enableAffectiveDialog"]);void 0!==t&&null!=d&&ue(t,["setup","generationConfig","enableAffectiveDialog"],d);const h=ce(e,["systemInstruction"]);void 0!==t&&null!=h&&ue(t,["setup","systemInstruction"],st(h));const f=ce(e,["tools"]);if(void 0!==t&&null!=f){let e=ft(f);Array.isArray(e)&&(e=e.map(e=>function(e){const t={},n=ce(e,["retrieval"]);null!=n&&ue(t,["retrieval"],n);const o=ce(e,["computerUse"]);null!=o&&ue(t,["computerUse"],o);if(void 0!==ce(e,["fileSearch"]))throw new Error("fileSearch parameter is not supported in Vertex AI.");const i=ce(e,["codeExecution"]);null!=i&&ue(t,["codeExecution"],i);const r=ce(e,["enterpriseWebSearch"]);null!=r&&ue(t,["enterpriseWebSearch"],r);const s=ce(e,["functionDeclarations"]);if(null!=s){let e=s;Array.isArray(e)&&(e=e.map(e=>function(e){const t={},n=ce(e,["description"]);null!=n&&ue(t,["description"],n);const o=ce(e,["name"]);null!=o&&ue(t,["name"],o);const i=ce(e,["parameters"]);null!=i&&ue(t,["parameters"],i);const r=ce(e,["parametersJsonSchema"]);null!=r&&ue(t,["parametersJsonSchema"],r);const s=ce(e,["response"]);null!=s&&ue(t,["response"],s);const l=ce(e,["responseJsonSchema"]);if(null!=l&&ue(t,["responseJsonSchema"],l),void 0!==ce(e,["behavior"]))throw new Error("behavior parameter is not supported in Vertex AI.");return t}(e))),ue(t,["functionDeclarations"],e)}const l=ce(e,["googleMaps"]);null!=l&&ue(t,["googleMaps"],l);const a=ce(e,["googleSearch"]);null!=a&&ue(t,["googleSearch"],a);const u=ce(e,["googleSearchRetrieval"]);null!=u&&ue(t,["googleSearchRetrieval"],u);const c=ce(e,["urlContext"]);null!=c&&ue(t,["urlContext"],c);return t}(ht(e)))),ue(t,["setup","tools"],e)}const m=ce(e,["sessionResumption"]);void 0!==t&&null!=m&&ue(t,["setup","sessionResumption"],m);const g=ce(e,["inputAudioTranscription"]);void 0!==t&&null!=g&&ue(t,["setup","inputAudioTranscription"],g);const y=ce(e,["outputAudioTranscription"]);void 0!==t&&null!=y&&ue(t,["setup","outputAudioTranscription"],y);const v=ce(e,["realtimeInputConfig"]);void 0!==t&&null!=v&&ue(t,["setup","realtimeInputConfig"],v);const E=ce(e,["contextWindowCompression"]);void 0!==t&&null!=E&&ue(t,["setup","contextWindowCompression"],E);const T=ce(e,["proactivity"]);void 0!==t&&null!=T&&ue(t,["setup","proactivity"],T);const I=ce(e,["explicitVadSignal"]);return void 0!==t&&null!=I&&ue(t,["setup","explicitVadSignal"],I),{}}function Jo(e){const t={},n=ce(e,["media"]);if(null!=n){let e=Xe(n);Array.isArray(e)&&(e=e.map(e=>Ho(e))),ue(t,["mediaChunks"],e)}const o=ce(e,["audio"]);null!=o&&ue(t,["audio"],Ho(et(o)));const i=ce(e,["audioStreamEnd"]);null!=i&&ue(t,["audioStreamEnd"],i);const r=ce(e,["video"]);null!=r&&ue(t,["video"],Ho(Ze(r)));const s=ce(e,["text"]);null!=s&&ue(t,["text"],s);const l=ce(e,["activityStart"]);null!=l&&ue(t,["activityStart"],l);const a=ce(e,["activityEnd"]);return null!=a&&ue(t,["activityEnd"],a),t}function Yo(e){const t={},n=ce(e,["media"]);if(null!=n){let e=Xe(n);Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["mediaChunks"],e)}const o=ce(e,["audio"]);null!=o&&ue(t,["audio"],et(o));const i=ce(e,["audioStreamEnd"]);null!=i&&ue(t,["audioStreamEnd"],i);const r=ce(e,["video"]);null!=r&&ue(t,["video"],Ze(r));const s=ce(e,["text"]);null!=s&&ue(t,["text"],s);const l=ce(e,["activityStart"]);null!=l&&ue(t,["activityStart"],l);const a=ce(e,["activityEnd"]);return null!=a&&ue(t,["activityEnd"],a),t}function $o(e){const t={},n=ce(e,["setupComplete"]);null!=n&&ue(t,["setupComplete"],n);const o=ce(e,["serverContent"]);null!=o&&ue(t,["serverContent"],o);const i=ce(e,["toolCall"]);null!=i&&ue(t,["toolCall"],i);const r=ce(e,["toolCallCancellation"]);null!=r&&ue(t,["toolCallCancellation"],r);const s=ce(e,["usageMetadata"]);null!=s&&ue(t,["usageMetadata"],function(e){const t={},n=ce(e,["promptTokenCount"]);null!=n&&ue(t,["promptTokenCount"],n);const o=ce(e,["cachedContentTokenCount"]);null!=o&&ue(t,["cachedContentTokenCount"],o);const i=ce(e,["candidatesTokenCount"]);null!=i&&ue(t,["responseTokenCount"],i);const r=ce(e,["toolUsePromptTokenCount"]);null!=r&&ue(t,["toolUsePromptTokenCount"],r);const s=ce(e,["thoughtsTokenCount"]);null!=s&&ue(t,["thoughtsTokenCount"],s);const l=ce(e,["totalTokenCount"]);null!=l&&ue(t,["totalTokenCount"],l);const a=ce(e,["promptTokensDetails"]);if(null!=a){let e=a;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["promptTokensDetails"],e)}const u=ce(e,["cacheTokensDetails"]);if(null!=u){let e=u;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["cacheTokensDetails"],e)}const c=ce(e,["candidatesTokensDetails"]);if(null!=c){let e=c;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["responseTokensDetails"],e)}const p=ce(e,["toolUsePromptTokensDetails"]);if(null!=p){let e=p;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["toolUsePromptTokensDetails"],e)}const d=ce(e,["trafficType"]);null!=d&&ue(t,["trafficType"],d);return t}(s));const l=ce(e,["goAway"]);null!=l&&ue(t,["goAway"],l);const a=ce(e,["sessionResumptionUpdate"]);null!=a&&ue(t,["sessionResumptionUpdate"],a);const u=ce(e,["voiceActivityDetectionSignal"]);null!=u&&ue(t,["voiceActivityDetectionSignal"],u);const c=ce(e,["voiceActivity"]);return null!=c&&ue(t,["voiceActivity"],function(e){const t={},n=ce(e,["type"]);null!=n&&ue(t,["voiceActivityType"],n);return t}
235
235
  /**
236
236
  * @license
237
237
  * Copyright 2025 Google LLC
@@ -241,7 +241,7 @@ function Ho(e){const t={},n=ce(e,["data"]);if(null!=n&&ue(t,["data"],n),void 0!=
241
241
  * @license
242
242
  * Copyright 2025 Google LLC
243
243
  * SPDX-License-Identifier: Apache-2.0
244
- */qo=Fo,Fo.GeminiNextGenAPIClient=qo,Fo.GeminiNextGenAPIClientError=Mn,Fo.APIError=Dn,Fo.APIConnectionError=xn,Fo.APIConnectionTimeoutError=Ln,Fo.APIUserAbortError=Un,Fo.NotFoundError=Fn,Fo.ConflictError=Hn,Fo.RateLimitError=Vn,Fo.BadRequestError=kn,Fo.AuthenticationError=qn,Fo.InternalServerError=Bn,Fo.PermissionDeniedError=Gn,Fo.UnprocessableEntityError=jn,Fo.toFile=async function(e,t,n){if(oo(),(e=>null!=e&&"object"==typeof e&&"string"==typeof e.name&&"number"==typeof e.lastModified&&ro(e))(e=await e))return e instanceof File?e:io([await e.arrayBuffer()],e.name);if((e=>null!=e&&"object"==typeof e&&"string"==typeof e.url&&"function"==typeof e.blob)(e)){const o=await e.blob();return t||(t=new URL(e.url).pathname.split(/[\\/]/).pop()),io(await so(o),t,n)}const o=await so(e);if(t||(t=function(e){return("object"==typeof e&&null!==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}(e)),!(null==n?void 0:n.type)){const e=o.find(e=>"object"==typeof e&&"type"in e&&e.type);"string"==typeof e&&(n=Object.assign(Object.assign({},n),{type:e}))}return io(o,t,n)},Fo.Interactions=fo;let Li=!1;function ki(e){for(const t of e){if(Gi(t))return!0;if("object"==typeof t&&"inputSchema"in t)return!0}return Li}function qi(e){var t;const n=null!==(t=e[dn])&&void 0!==t?t:"";e[dn]=(n+" mcp_used/unknown").trimStart()}function Gi(e){return null!==e&&"object"==typeof e&&e instanceof Hi}function Fi(e){return Xt(this,arguments,function*(e,t=100){let n,o=0;for(;o<t;){const t=yield zt(e.listTools({cursor:n}));for(const e of t.tools)yield yield zt(e),o++;if(!t.nextCursor)break;n=t.nextCursor}})}class Hi{constructor(e=[],t){this.mcpTools=[],this.functionNameToMcpClient={},this.mcpClients=e,this.config=t}static create(e,t){return new Hi(e,t)}async initialize(){var e,t,n,o;if(this.mcpTools.length>0)return;const i={},r=[];for(const u of this.mcpClients)try{for(var s,l=!0,a=(t=void 0,Qt(Fi(u)));!(e=(s=await a.next()).done);l=!0){o=s.value,l=!1;const e=o;r.push(e);const t=e.name;if(i[t])throw new Error(`Duplicate function name ${t} found in MCP tools. Please ensure function names are unique.`);i[t]=u}}catch(e){t={error:e}}finally{try{l||e||!(n=a.return)||await n.call(a)}finally{if(t)throw t.error}}this.mcpTools=r,this.functionNameToMcpClient=i}async tool(){return await this.initialize(),function(e,t={}){const n=[],o=new Set;for(const i of e){const e=i.name;if(o.has(e))throw new Error(`Duplicate function name ${e} found in MCP tools. Please ensure function names are unique.`);o.add(e);const r=_t(i,t);r.functionDeclarations&&n.push(...r.functionDeclarations)}return{functionDeclarations:n}}(this.mcpTools,this.config)}async callTool(e){await this.initialize();const t=[];for(const n of e)if(n.name in this.functionNameToMcpClient){const e=this.functionNameToMcpClient[n.name];let o;this.config.timeout&&(o={timeout:this.config.timeout});const i=await e.callTool({name:n.name,arguments:n.args},void 0,o);t.push({functionResponse:{name:n.name,response:i.isError?{error:i}:i}})}return t}}class ji{constructor(e,t,n){this.apiClient=e,this.auth=t,this.webSocketFactory=n}async connect(e){var t,n;if(this.apiClient.isVertexAI())throw new Error("Live music is not supported for Vertex AI.");console.warn("Live music generation is experimental and may change in future versions.");const o=this.apiClient.getWebsocketBaseUrl(),i=this.apiClient.getApiVersion(),r=function(e){const t=new Headers;for(const[n,o]of Object.entries(e))t.append(n,o);return t}
244
+ */Go=Fo,Fo.GeminiNextGenAPIClient=Go,Fo.GeminiNextGenAPIClientError=Mn,Fo.APIError=Dn,Fo.APIConnectionError=xn,Fo.APIConnectionTimeoutError=Ln,Fo.APIUserAbortError=Un,Fo.NotFoundError=Fn,Fo.ConflictError=Hn,Fo.RateLimitError=Vn,Fo.BadRequestError=kn,Fo.AuthenticationError=Gn,Fo.InternalServerError=Bn,Fo.PermissionDeniedError=qn,Fo.UnprocessableEntityError=jn,Fo.toFile=async function(e,t,n){if(oo(),(e=>null!=e&&"object"==typeof e&&"string"==typeof e.name&&"number"==typeof e.lastModified&&ro(e))(e=await e))return e instanceof File?e:io([await e.arrayBuffer()],e.name);if((e=>null!=e&&"object"==typeof e&&"string"==typeof e.url&&"function"==typeof e.blob)(e)){const o=await e.blob();return t||(t=new URL(e.url).pathname.split(/[\\/]/).pop()),io(await so(o),t,n)}const o=await so(e);if(t||(t=function(e){return("object"==typeof e&&null!==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}(e)),!(null==n?void 0:n.type)){const e=o.find(e=>"object"==typeof e&&"type"in e&&e.type);"string"==typeof e&&(n=Object.assign(Object.assign({},n),{type:e}))}return io(o,t,n)},Fo.Interactions=fo;let Li=!1;function ki(e){for(const t of e){if(qi(t))return!0;if("object"==typeof t&&"inputSchema"in t)return!0}return Li}function Gi(e){var t;const n=null!==(t=e[dn])&&void 0!==t?t:"";e[dn]=(n+" mcp_used/unknown").trimStart()}function qi(e){return null!==e&&"object"==typeof e&&e instanceof Hi}function Fi(e){return Xt(this,arguments,function*(e,t=100){let n,o=0;for(;o<t;){const t=yield zt(e.listTools({cursor:n}));for(const e of t.tools)yield yield zt(e),o++;if(!t.nextCursor)break;n=t.nextCursor}})}class Hi{constructor(e=[],t){this.mcpTools=[],this.functionNameToMcpClient={},this.mcpClients=e,this.config=t}static create(e,t){return new Hi(e,t)}async initialize(){var e,t,n,o;if(this.mcpTools.length>0)return;const i={},r=[];for(const u of this.mcpClients)try{for(var s,l=!0,a=(t=void 0,Qt(Fi(u)));!(e=(s=await a.next()).done);l=!0){o=s.value,l=!1;const e=o;r.push(e);const t=e.name;if(i[t])throw new Error(`Duplicate function name ${t} found in MCP tools. Please ensure function names are unique.`);i[t]=u}}catch(e){t={error:e}}finally{try{l||e||!(n=a.return)||await n.call(a)}finally{if(t)throw t.error}}this.mcpTools=r,this.functionNameToMcpClient=i}async tool(){return await this.initialize(),function(e,t={}){const n=[],o=new Set;for(const i of e){const e=i.name;if(o.has(e))throw new Error(`Duplicate function name ${e} found in MCP tools. Please ensure function names are unique.`);o.add(e);const r=_t(i,t);r.functionDeclarations&&n.push(...r.functionDeclarations)}return{functionDeclarations:n}}(this.mcpTools,this.config)}async callTool(e){await this.initialize();const t=[];for(const n of e)if(n.name in this.functionNameToMcpClient){const e=this.functionNameToMcpClient[n.name];let o;this.config.timeout&&(o={timeout:this.config.timeout});const i=await e.callTool({name:n.name,arguments:n.args},void 0,o);t.push({functionResponse:{name:n.name,response:i.isError?{error:i}:i}})}return t}}class ji{constructor(e,t,n){this.apiClient=e,this.auth=t,this.webSocketFactory=n}async connect(e){var t,n;if(this.apiClient.isVertexAI())throw new Error("Live music is not supported for Vertex AI.");console.warn("Live music generation is experimental and may change in future versions.");const o=this.apiClient.getWebsocketBaseUrl(),i=this.apiClient.getApiVersion(),r=function(e){const t=new Headers;for(const[n,o]of Object.entries(e))t.append(n,o);return t}
245
245
  /**
246
246
  * @license
247
247
  * Copyright 2025 Google LLC
@@ -252,17 +252,17 @@ function Ho(e){const t={},n=ce(e,["data"]);if(null!=n&&ue(t,["data"],n),void 0!=
252
252
  * Copyright 2025 Google LLC
253
253
  * SPDX-License-Identifier: Apache-2.0
254
254
  */
255
- async function(e,t,n){const o=new Ye;let i;i=n.data instanceof Blob?JSON.parse(await n.data.text()):JSON.parse(n.data),Object.assign(o,i),t(o)}(0,u.onmessage,e)},onerror:null!==(t=null==u?void 0:u.onerror)&&void 0!==t?t:function(e){},onclose:null!==(n=null==u?void 0:u.onclose)&&void 0!==n?n:function(e){}}),p=this.webSocketFactory.create(s,function(e){const t={};return e.forEach((e,n)=>{t[n]=e}),t}(r),c);p.connect(),await a;const d={setup:{model:We(this.apiClient,e.model)}};return p.send(JSON.stringify(d)),new Vi(p,this.apiClient)}}class Vi{constructor(e,t){this.conn=e,this.apiClient=t}async setWeightedPrompts(e){if(!e.weightedPrompts||0===Object.keys(e.weightedPrompts).length)throw new Error("Weighted prompts must be set and contain at least one entry.");const t=function(e){const t={},n=ce(e,["weightedPrompts"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["weightedPrompts"],e)}return t}(e);this.conn.send(JSON.stringify({clientContent:t}))}async setMusicGenerationConfig(e){e.musicGenerationConfig||(e.musicGenerationConfig={});const t=function(e){const t={},n=ce(e,["musicGenerationConfig"]);return null!=n&&ue(t,["musicGenerationConfig"],n),t}(e);this.conn.send(JSON.stringify(t))}sendPlaybackControl(e){const t={playbackControl:e};this.conn.send(JSON.stringify(t))}play(){this.sendPlaybackControl(e.LiveMusicPlaybackControl.PLAY)}pause(){this.sendPlaybackControl(e.LiveMusicPlaybackControl.PAUSE)}stop(){this.sendPlaybackControl(e.LiveMusicPlaybackControl.STOP)}resetContext(){this.sendPlaybackControl(e.LiveMusicPlaybackControl.RESET_CONTEXT)}close(){this.conn.close()}}class Bi{constructor(e,t,n){this.apiClient=e,this.auth=t,this.webSocketFactory=n,this.music=new ji(this.apiClient,this.auth,this.webSocketFactory)}async connect(t){var n,o,i,r,s,l;if(t.config&&t.config.httpOptions)throw new Error("The Live module does not support httpOptions at request-level in LiveConnectConfig yet. Please use the client-level httpOptions configuration instead.");const a=this.apiClient.getWebsocketBaseUrl(),u=this.apiClient.getApiVersion();let c;const p=this.apiClient.getHeaders();t.config&&t.config.tools&&ki(t.config.tools)&&qi(p);const d=function(e){const t=new Headers;for(const[n,o]of Object.entries(e))t.append(n,o);return t}
255
+ async function(e,t,n){const o=new $e;let i;i=n.data instanceof Blob?JSON.parse(await n.data.text()):JSON.parse(n.data),Object.assign(o,i),t(o)}(0,u.onmessage,e)},onerror:null!==(t=null==u?void 0:u.onerror)&&void 0!==t?t:function(e){},onclose:null!==(n=null==u?void 0:u.onclose)&&void 0!==n?n:function(e){}}),p=this.webSocketFactory.create(s,function(e){const t={};return e.forEach((e,n)=>{t[n]=e}),t}(r),c);p.connect(),await a;const d={setup:{model:We(this.apiClient,e.model)}};return p.send(JSON.stringify(d)),new Vi(p,this.apiClient)}}class Vi{constructor(e,t){this.conn=e,this.apiClient=t}async setWeightedPrompts(e){if(!e.weightedPrompts||0===Object.keys(e.weightedPrompts).length)throw new Error("Weighted prompts must be set and contain at least one entry.");const t=function(e){const t={},n=ce(e,["weightedPrompts"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["weightedPrompts"],e)}return t}(e);this.conn.send(JSON.stringify({clientContent:t}))}async setMusicGenerationConfig(e){e.musicGenerationConfig||(e.musicGenerationConfig={});const t=function(e){const t={},n=ce(e,["musicGenerationConfig"]);return null!=n&&ue(t,["musicGenerationConfig"],n),t}(e);this.conn.send(JSON.stringify(t))}sendPlaybackControl(e){const t={playbackControl:e};this.conn.send(JSON.stringify(t))}play(){this.sendPlaybackControl(e.LiveMusicPlaybackControl.PLAY)}pause(){this.sendPlaybackControl(e.LiveMusicPlaybackControl.PAUSE)}stop(){this.sendPlaybackControl(e.LiveMusicPlaybackControl.STOP)}resetContext(){this.sendPlaybackControl(e.LiveMusicPlaybackControl.RESET_CONTEXT)}close(){this.conn.close()}}class Bi{constructor(e,t,n){this.apiClient=e,this.auth=t,this.webSocketFactory=n,this.music=new ji(this.apiClient,this.auth,this.webSocketFactory)}async connect(t){var n,o,i,r,s,l;if(t.config&&t.config.httpOptions)throw new Error("The Live module does not support httpOptions at request-level in LiveConnectConfig yet. Please use the client-level httpOptions configuration instead.");const a=this.apiClient.getWebsocketBaseUrl(),u=this.apiClient.getApiVersion();let c;const p=this.apiClient.getHeaders();t.config&&t.config.tools&&ki(t.config.tools)&&Gi(p);const d=function(e){const t=new Headers;for(const[n,o]of Object.entries(e))t.append(n,o);return t}
256
256
  /**
257
257
  * @license
258
258
  * Copyright 2025 Google LLC
259
259
  * SPDX-License-Identifier: Apache-2.0
260
- */(p);if(this.apiClient.isVertexAI()){const e=this.apiClient.getProject(),t=this.apiClient.getLocation(),n=this.apiClient.getApiKey(),o=!!e&&!!t||!!n;this.apiClient.getCustomBaseUrl()&&!o?c=a:(c=`${a}/ws/google.cloud.aiplatform.${u}.LlmBidiService/BidiGenerateContent`,await this.auth.addAuthHeaders(d,c))}else{const e=this.apiClient.getApiKey();let t="BidiGenerateContent",n="key";(null==e?void 0:e.startsWith("auth_tokens/"))&&(console.warn("Warning: Ephemeral token support is experimental and may change in future versions."),"v1alpha"!==u&&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."),t="BidiGenerateContentConstrained",n="access_token"),c=`${a}/ws/google.ai.generativelanguage.${u}.GenerativeService.${t}?${n}=${e}`}let h=()=>{};const f=new Promise(e=>{h=e}),m=t.callbacks,g=this.apiClient,y={onopen:function(){var e;null===(e=null==m?void 0:m.onopen)||void 0===e||e.call(m),h({})},onmessage:e=>{!async function(e,t,n){const o=new $e;let i;i=n.data instanceof Blob?await n.data.text():n.data instanceof ArrayBuffer?(new TextDecoder).decode(n.data):n.data;const r=JSON.parse(i);if(e.isVertexAI()){const e=Yo(r);Object.assign(o,e)}else{const e=r;Object.assign(o,e)}t(o)}(g,m.onmessage,e)},onerror:null!==(n=null==m?void 0:m.onerror)&&void 0!==n?n:function(e){},onclose:null!==(o=null==m?void 0:m.onclose)&&void 0!==o?o:function(e){}},v=this.webSocketFactory.create(c,function(e){const t={};return e.forEach((e,n)=>{t[n]=e}),t}(d),y);v.connect(),await f;let E=We(this.apiClient,t.model);if(this.apiClient.isVertexAI()&&E.startsWith("publishers/")){const e=this.apiClient.getProject(),t=this.apiClient.getLocation();e&&t&&(E=`projects/${e}/locations/${t}/`+E)}let T={};this.apiClient.isVertexAI()&&void 0===(null===(i=t.config)||void 0===i?void 0:i.responseModalities)&&(void 0===t.config?t.config={responseModalities:[e.Modality.AUDIO]}:t.config.responseModalities=[e.Modality.AUDIO]),(null===(r=t.config)||void 0===r?void 0:r.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).");const I=null!==(l=null===(s=t.config)||void 0===s?void 0:s.tools)&&void 0!==l?l:[],_=[];for(const e of I)if(this.isCallableTool(e)){const t=e;_.push(await t.tool())}else _.push(e);_.length>0&&(t.config.tools=_);const S={model:E,config:t.config,callbacks:t.callbacks};return T=this.apiClient.isVertexAI()?function(e,t){const n={},o=ce(t,["model"]);null!=o&&ue(n,["setup","model"],We(e,o));const i=ce(t,["config"]);return null!=i&&ue(n,["config"],Bo(i,n)),n}(this.apiClient,S):function(e,t){const n={},o=ce(t,["model"]);null!=o&&ue(n,["setup","model"],We(e,o));const i=ce(t,["config"]);return null!=i&&ue(n,["config"],Vo(i,n)),n}(this.apiClient,S),delete T.config,v.send(JSON.stringify(T)),new $i(v,this.apiClient)}isCallableTool(e){return"callTool"in e&&"function"==typeof e.callTool}}const Ji={turnComplete:!0};class $i{constructor(e,t){this.conn=e,this.apiClient=t}tLiveClientContent(e,t){if(null!==t.turns&&void 0!==t.turns){let n=[];try{n=at(t.turns),e.isVertexAI()||(n=n.map(e=>zo(e)))}catch(e){throw new 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(null==t.functionResponses)throw new Error("functionResponses is required.");if(n=Array.isArray(t.functionResponses)?t.functionResponses:[t.functionResponses],0===n.length)throw new Error("functionResponses is required.");for(const t of n){if("object"!=typeof t||null===t||!("name"in t)||!("response"in t))throw new Error(`Could not parse function response, type '${typeof t}'.`);if(!e.isVertexAI()&&!("id"in t))throw new 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({},Ji),e);const t=this.tLiveClientContent(this.apiClient,e);this.conn.send(JSON.stringify(t))}sendRealtimeInput(e){let t={};t=this.apiClient.isVertexAI()?{realtimeInput:$o(e)}:{realtimeInput:Jo(e)},this.conn.send(JSON.stringify(t))}sendToolResponse(e){if(null==e.functionResponses)throw new Error("Tool response parameters are required.");const t=this.tLiveClienttToolResponse(this.apiClient,e);this.conn.send(JSON.stringify(t))}close(){this.conn.close()}}function Yi(e){var t,n,o;if(null===(t=null==e?void 0:e.automaticFunctionCalling)||void 0===t?void 0:t.disable)return!0;let i=!1;for(const t of null!==(n=null==e?void 0:e.tools)&&void 0!==n?n:[])if(Ki(t)){i=!0;break}if(!i)return!0;const r=null===(o=null==e?void 0:e.automaticFunctionCalling)||void 0===o?void 0:o.maximumRemoteCalls;return!!(r&&(r<0||!Number.isInteger(r))||0==r)&&(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:",r),!0)}function Ki(e){return"callTool"in e&&"function"==typeof e.callTool}function Wi(e){var t;const n=[];return(null===(t=null==e?void 0:e.config)||void 0===t?void 0:t.tools)?(e.config.tools.forEach((e,t)=>{if(Ki(e))return;const o=e;o.functionDeclarations&&o.functionDeclarations.length>0&&n.push(t)}),n):n}function zi(e){var t;return!(null===(t=null==e?void 0:e.automaticFunctionCalling)||void 0===t?void 0:t.ignoreCallHistory)}
260
+ */(p);if(this.apiClient.isVertexAI()){const e=this.apiClient.getProject(),t=this.apiClient.getLocation(),n=this.apiClient.getApiKey(),o=!!e&&!!t||!!n;this.apiClient.getCustomBaseUrl()&&!o?c=a:(c=`${a}/ws/google.cloud.aiplatform.${u}.LlmBidiService/BidiGenerateContent`,await this.auth.addAuthHeaders(d,c))}else{const e=this.apiClient.getApiKey();let t="BidiGenerateContent",n="key";(null==e?void 0:e.startsWith("auth_tokens/"))&&(console.warn("Warning: Ephemeral token support is experimental and may change in future versions."),"v1alpha"!==u&&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."),t="BidiGenerateContentConstrained",n="access_token"),c=`${a}/ws/google.ai.generativelanguage.${u}.GenerativeService.${t}?${n}=${e}`}let h=()=>{};const f=new Promise(e=>{h=e}),m=t.callbacks,g=this.apiClient,y={onopen:function(){var e;null===(e=null==m?void 0:m.onopen)||void 0===e||e.call(m),h({})},onmessage:e=>{!async function(e,t,n){const o=new Ye;let i;i=n.data instanceof Blob?await n.data.text():n.data instanceof ArrayBuffer?(new TextDecoder).decode(n.data):n.data;const r=JSON.parse(i);if(e.isVertexAI()){const e=$o(r);Object.assign(o,e)}else{const e=r;Object.assign(o,e)}t(o)}(g,m.onmessage,e)},onerror:null!==(n=null==m?void 0:m.onerror)&&void 0!==n?n:function(e){},onclose:null!==(o=null==m?void 0:m.onclose)&&void 0!==o?o:function(e){}},v=this.webSocketFactory.create(c,function(e){const t={};return e.forEach((e,n)=>{t[n]=e}),t}(d),y);v.connect(),await f;let E=We(this.apiClient,t.model);if(this.apiClient.isVertexAI()&&E.startsWith("publishers/")){const e=this.apiClient.getProject(),t=this.apiClient.getLocation();e&&t&&(E=`projects/${e}/locations/${t}/`+E)}let T={};this.apiClient.isVertexAI()&&void 0===(null===(i=t.config)||void 0===i?void 0:i.responseModalities)&&(void 0===t.config?t.config={responseModalities:[e.Modality.AUDIO]}:t.config.responseModalities=[e.Modality.AUDIO]),(null===(r=t.config)||void 0===r?void 0:r.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).");const I=null!==(l=null===(s=t.config)||void 0===s?void 0:s.tools)&&void 0!==l?l:[],_=[];for(const e of I)if(this.isCallableTool(e)){const t=e;_.push(await t.tool())}else _.push(e);_.length>0&&(t.config.tools=_);const S={model:E,config:t.config,callbacks:t.callbacks};return T=this.apiClient.isVertexAI()?function(e,t){const n={},o=ce(t,["model"]);null!=o&&ue(n,["setup","model"],We(e,o));const i=ce(t,["config"]);return null!=i&&ue(n,["config"],Bo(i,n)),n}(this.apiClient,S):function(e,t){const n={},o=ce(t,["model"]);null!=o&&ue(n,["setup","model"],We(e,o));const i=ce(t,["config"]);return null!=i&&ue(n,["config"],Vo(i,n)),n}(this.apiClient,S),delete T.config,v.send(JSON.stringify(T)),new Yi(v,this.apiClient)}isCallableTool(e){return"callTool"in e&&"function"==typeof e.callTool}}const Ji={turnComplete:!0};class Yi{constructor(e,t){this.conn=e,this.apiClient=t}tLiveClientContent(e,t){if(null!==t.turns&&void 0!==t.turns){let n=[];try{n=at(t.turns),e.isVertexAI()||(n=n.map(e=>zo(e)))}catch(e){throw new 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(null==t.functionResponses)throw new Error("functionResponses is required.");if(n=Array.isArray(t.functionResponses)?t.functionResponses:[t.functionResponses],0===n.length)throw new Error("functionResponses is required.");for(const t of n){if("object"!=typeof t||null===t||!("name"in t)||!("response"in t))throw new Error(`Could not parse function response, type '${typeof t}'.`);if(!e.isVertexAI()&&!("id"in t))throw new 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({},Ji),e);const t=this.tLiveClientContent(this.apiClient,e);this.conn.send(JSON.stringify(t))}sendRealtimeInput(e){let t={};t=this.apiClient.isVertexAI()?{realtimeInput:Yo(e)}:{realtimeInput:Jo(e)},this.conn.send(JSON.stringify(t))}sendToolResponse(e){if(null==e.functionResponses)throw new Error("Tool response parameters are required.");const t=this.tLiveClienttToolResponse(this.apiClient,e);this.conn.send(JSON.stringify(t))}close(){this.conn.close()}}function $i(e){var t,n,o;if(null===(t=null==e?void 0:e.automaticFunctionCalling)||void 0===t?void 0:t.disable)return!0;let i=!1;for(const t of null!==(n=null==e?void 0:e.tools)&&void 0!==n?n:[])if(Ki(t)){i=!0;break}if(!i)return!0;const r=null===(o=null==e?void 0:e.automaticFunctionCalling)||void 0===o?void 0:o.maximumRemoteCalls;return!!(r&&(r<0||!Number.isInteger(r))||0==r)&&(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:",r),!0)}function Ki(e){return"callTool"in e&&"function"==typeof e.callTool}function Wi(e){var t;const n=[];return(null===(t=null==e?void 0:e.config)||void 0===t?void 0:t.tools)?(e.config.tools.forEach((e,t)=>{if(Ki(e))return;const o=e;o.functionDeclarations&&o.functionDeclarations.length>0&&n.push(t)}),n):n}function zi(e){var t;return!(null===(t=null==e?void 0:e.automaticFunctionCalling)||void 0===t?void 0:t.ignoreCallHistory)}
261
261
  /**
262
262
  * @license
263
263
  * Copyright 2025 Google LLC
264
264
  * SPDX-License-Identifier: Apache-2.0
265
- */class Xi extends le{constructor(t){super(),this.apiClient=t,this.embedContent=async t=>{if(!this.apiClient.isVertexAI())return await this.embedContentInternal(t);if(t.model.includes("gemini")&&"gemini-embedding-001"!==t.model||t.model.includes("maas")){const n=at(t.contents);if(n.length>1)throw new Error("The embedContent API for this model only supports one content at a time.");const o=Object.assign(Object.assign({},t),{content:n[0],embeddingApiType:e.EmbeddingApiType.EMBED_CONTENT});return await this.embedContentInternal(o)}{const n=Object.assign(Object.assign({},t),{embeddingApiType:e.EmbeddingApiType.PREDICT});return await this.embedContentInternal(n)}},this.generateContent=async e=>{var t,n,o,i,r;const s=await this.processParamsMaybeAddMcpUsage(e);if(this.maybeMoveToResponseJsonSchem(e),!function(e){var t,n,o;return null!==(o=null===(n=null===(t=e.config)||void 0===t?void 0:t.tools)||void 0===n?void 0:n.some(e=>Ki(e)))&&void 0!==o&&o}(e)||Yi(e.config))return await this.generateContentInternal(s);const l=Wi(e);if(l.length>0){const e=l.map(e=>`tools[${e}]`).join(", ");throw new Error(`Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations is not yet supported. Incompatible tools found at ${e}.`)}let a,u;const c=at(s.contents),p=null!==(o=null===(n=null===(t=s.config)||void 0===t?void 0:t.automaticFunctionCalling)||void 0===n?void 0:n.maximumRemoteCalls)&&void 0!==o?o:10;let d=0;for(;d<p&&(a=await this.generateContentInternal(s),a.functionCalls&&0!==a.functionCalls.length);){const t=a.candidates[0].content,n=[];for(const t of null!==(r=null===(i=e.config)||void 0===i?void 0:i.tools)&&void 0!==r?r:[])if(Ki(t)){const e=t,o=await e.callTool(a.functionCalls);n.push(...o)}d++,u={role:"user",parts:n},s.contents=at(s.contents),s.contents.push(t),s.contents.push(u),zi(s.config)&&(c.push(t),c.push(u))}return zi(s.config)&&(a.automaticFunctionCallingHistory=c),a},this.generateContentStream=async e=>{var t,n,o,i,r;if(this.maybeMoveToResponseJsonSchem(e),Yi(e.config)){const t=await this.processParamsMaybeAddMcpUsage(e);return await this.generateContentStreamInternal(t)}const s=Wi(e);if(s.length>0){const e=s.map(e=>`tools[${e}]`).join(", ");throw new Error(`Incompatible tools found at ${e}. Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations" is not yet supported.`)}const l=null===(o=null===(n=null===(t=null==e?void 0:e.config)||void 0===t?void 0:t.toolConfig)||void 0===n?void 0:n.functionCallingConfig)||void 0===o?void 0:o.streamFunctionCallArguments,a=null===(r=null===(i=null==e?void 0:e.config)||void 0===i?void 0:i.automaticFunctionCalling)||void 0===r?void 0:r.disable;if(l&&!a)throw new 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=>{var t;let n;const o=[];if(null==e?void 0:e.generatedImages)for(const i of e.generatedImages)i&&(null==i?void 0:i.safetyAttributes)&&"Positive Prompt"===(null===(t=null==i?void 0:i.safetyAttributes)||void 0===t?void 0:t.contentType)?n=null==i?void 0:i.safetyAttributes:o.push(i);let i;return i=n?{generatedImages:o,positivePromptSafetyAttributes:n,sdkHttpResponse:e.sdkHttpResponse}:{generatedImages:o,sdkHttpResponse:e.sdkHttpResponse},i}),this.list=async t=>{var n;const o={config:Object.assign(Object.assign({},{queryBase:!0}),null==t?void 0:t.config)};if(this.apiClient.isVertexAI()&&!o.config.queryBase){if(null===(n=o.config)||void 0===n?void 0:n.filter)throw new Error("Filtering tuned models list for Vertex AI is not currently supported");o.config.filter="labels.tune-type:*"}return new qt(e.PagedItem.PAGED_ITEM_MODELS,e=>this.listInternal(e),await this.listInternal(o),o)},this.editImage=async e=>{const 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));const n={model:e.model,image:e.image,upscaleFactor:e.upscaleFactor,config:t};return await this.upscaleImageInternal(n)},this.generateVideos=async e=>{var t,n,o,i,r,s;if((e.prompt||e.image||e.video)&&e.source)throw new Error("Source and prompt/image/video are mutually exclusive. Please only use source.");return this.apiClient.isVertexAI()||((null===(t=e.video)||void 0===t?void 0:t.uri)&&(null===(n=e.video)||void 0===n?void 0:n.videoBytes)?e.video={uri:e.video.uri,mimeType:e.video.mimeType}:(null===(i=null===(o=e.source)||void 0===o?void 0:o.video)||void 0===i?void 0:i.uri)&&(null===(s=null===(r=e.source)||void 0===r?void 0:r.video)||void 0===s?void 0:s.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){var t,n,o;const i=null===(t=e.config)||void 0===t?void 0:t.tools;if(!i)return e;const r=await Promise.all(i.map(async e=>{if(Ki(e)){const t=e;return await t.tool()}return e})),s={model:e.model,contents:e.contents,config:Object.assign(Object.assign({},e.config),{tools:r})};if(s.config.tools=r,e.config&&e.config.tools&&ki(e.config.tools)){const t=null!==(o=null===(n=e.config.httpOptions)||void 0===n?void 0:n.headers)&&void 0!==o?o:{};let i=Object.assign({},t);0===Object.keys(i).length&&(i=this.apiClient.getDefaultHeaders()),qi(i),s.config.httpOptions=Object.assign(Object.assign({},e.config.httpOptions),{headers:i})}return s}async initAfcToolsMap(e){var t,n,o;const i=new Map;for(const r of null!==(n=null===(t=e.config)||void 0===t?void 0:t.tools)&&void 0!==n?n:[])if(Ki(r)){const e=r,t=await e.tool();for(const n of null!==(o=t.functionDeclarations)&&void 0!==o?o:[]){if(!n.name)throw new Error("Function declaration name is required.");if(i.has(n.name))throw new Error(`Duplicate tool declaration name: ${n.name}`);i.set(n.name,e)}}return i}async processAfcStream(e){var t,n,o;const i=null!==(o=null===(n=null===(t=e.config)||void 0===t?void 0:t.automaticFunctionCalling)||void 0===n?void 0:n.maximumRemoteCalls)&&void 0!==o?o:10;let r=!1,s=0;return function(e,t,n){return Xt(this,arguments,function*(){for(var o,l,a,u,c,p;s<i;){r&&(s++,r=!1);const m=yield zt(e.processParamsMaybeAddMcpUsage(n)),g=yield zt(e.generateContentStreamInternal(m)),y=[],v=[];try{for(var d,h=!0,f=(l=void 0,Qt(g));!(o=(d=yield zt(f.next())).done);h=!0){u=d.value,h=!1;const e=u;if(yield yield zt(e),e.candidates&&(null===(c=e.candidates[0])||void 0===c?void 0:c.content)){v.push(e.candidates[0].content);for(const n of null!==(p=e.candidates[0].content.parts)&&void 0!==p?p:[])if(s<i&&n.functionCall){if(!n.functionCall.name)throw new Error("Function call name was not returned by the model.");if(!t.has(n.functionCall.name))throw new Error(`Automatic function calling was requested, but not all the tools the model used implement the CallableTool interface. Available tools: ${t.keys()}, mising tool: ${n.functionCall.name}`);{const e=yield zt(t.get(n.functionCall.name).callTool([n.functionCall]));y.push(...e)}}}}}catch(e){l={error:e}}finally{try{h||o||!(a=f.return)||(yield zt(a.call(f)))}finally{if(l)throw l.error}}if(!(y.length>0))break;{r=!0;const e=new Ie;e.candidates=[{content:{role:"user",parts:y}}],yield yield zt(e);const t=[];t.push(...v),t.push({role:"user",parts:y});const o=at(n.contents).concat(t);n.contents=o}}})}(this,await this.initAfcToolsMap(e),e)}async generateContentInternal(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=ri(this.apiClient,e);return s=ae("{model}:generateContent",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=li(e),n=new Ie;return Object.assign(n,t),n})}{const t=ii(this.apiClient,e);return s=ae("{model}:generateContent",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=si(e),n=new Ie;return Object.assign(n,t),n})}}async generateContentStreamInternal(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=ri(this.apiClient,e);s=ae("{model}:streamGenerateContent?alt=sse",o._url),l=o._query,delete o._url,delete o._query;return r=this.apiClient.requestStream({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}),r.then(function(e){return Xt(this,arguments,function*(){var t,n,o,i;try{for(var r,s=!0,l=Qt(e);!(t=(r=yield zt(l.next())).done);s=!0){i=r.value,s=!1;const e=i,t=li(yield zt(e.json()));t.sdkHttpResponse={headers:e.headers};const n=new Ie;Object.assign(n,t),yield yield zt(n)}}catch(e){n={error:e}}finally{try{s||t||!(o=l.return)||(yield zt(o.call(l)))}finally{if(n)throw n.error}}})})}{const t=ii(this.apiClient,e);s=ae("{model}:streamGenerateContent?alt=sse",t._url),l=t._query,delete t._url,delete t._query;return r=this.apiClient.requestStream({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}),r.then(function(e){return Xt(this,arguments,function*(){var t,n,o,i;try{for(var r,s=!0,l=Qt(e);!(t=(r=yield zt(l.next())).done);s=!0){i=r.value,s=!1;const e=i,t=si(yield zt(e.json()));t.sdkHttpResponse={headers:e.headers};const n=new Ie;Object.assign(n,t),yield yield zt(n)}}catch(e){n={error:e}}finally{try{s||t||!(o=l.return)||(yield zt(o.call(l)))}finally{if(n)throw n.error}}})})}}async embedContentInternal(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=ti(this.apiClient,e,e);return s=ae((a=e.model).includes("gemini")&&"gemini-embedding-001"!==a||a.includes("maas")?"{model}:embedContent":"{model}:predict",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(t=>{const n=function(e,t){const n={},o=ce(e,["sdkHttpResponse"]);null!=o&&ue(n,["sdkHttpResponse"],o);const i=ce(e,["predictions[]","embeddings"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>Wo(e))),ue(n,["embeddings"],e)}const r=ce(e,["metadata"]);if(null!=r&&ue(n,["metadata"],r),t&&"EMBED_CONTENT"===ce(t,["embeddingApiType"])){const t=ce(e,["embedding"]),o=ce(e,["usageMetadata"]),i=ce(e,["truncated"]);if(t){const e={};o&&o.promptTokenCount&&(e.tokenCount=o.promptTokenCount),i&&(e.truncated=i),t.statistics=e,ue(n,["embeddings"],[t])}}return n}(t,e),o=new _e;return Object.assign(o,n),o})}{const t=ei(this.apiClient,e);return s=ae("{model}:batchEmbedContents",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["embeddings"]);if(null!=o){let e=o;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["embeddings"],e)}const i=ce(e,["metadata"]);return null!=i&&ue(t,["metadata"],i),t}(e),n=new _e;return Object.assign(n,t),n})}var a}async generateImagesInternal(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=ui(this.apiClient,e);return s=ae("{model}:predict",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["predictions"]);if(null!=o){let e=o;Array.isArray(e)&&(e=e.map(e=>yi(e))),ue(t,["generatedImages"],e)}const i=ce(e,["positivePromptSafetyAttributes"]);return null!=i&&ue(t,["positivePromptSafetyAttributes"],bi(i)),t}(e),n=new Se;return Object.assign(n,t),n})}{const t=ai(this.apiClient,e);return s=ae("{model}:predict",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=ci(e),n=new Se;return Object.assign(n,t),n})}}async editImageInternal(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI()){const s=Zo(this.apiClient,e);return i=ae("{model}:predict",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),o.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["predictions"]);if(null!=o){let e=o;Array.isArray(e)&&(e=e.map(e=>yi(e))),ue(t,["generatedImages"],e)}return t}(e),n=new Ae;return Object.assign(n,t),n})}throw new Error("This method is only supported by the Vertex AI.")}async upscaleImageInternal(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI()){const s=Di(this.apiClient,e);return i=ae("{model}:predict",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),o.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["predictions"]);if(null!=o){let e=o;Array.isArray(e)&&(e=e.map(e=>yi(e))),ue(t,["generatedImages"],e)}return t}(e),n=new Ce;return Object.assign(n,t),n})}throw new Error("This method is only supported by the Vertex AI.")}async recontextImage(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI()){const s=Ci(this.apiClient,e);return i=ae("{model}:predict",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),o.then(e=>{const t=function(e){const t={},n=ce(e,["predictions"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>yi(e))),ue(t,["generatedImages"],e)}return t}(e),n=new Oe;return Object.assign(n,t),n})}throw new Error("This method is only supported by the Vertex AI.")}async segmentImage(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI()){const s=Ri(this.apiClient,e);return i=ae("{model}:predict",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),o.then(e=>{const t=wi(e),n=new be;return Object.assign(n,t),n})}throw new Error("This method is only supported by the Vertex AI.")}async get(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=function(e,t){const n={},o=ce(t,["model"]);return null!=o&&ue(n,["_url","name"],We(e,o)),n}(this.apiClient,e);return s=ae("{name}",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"GET",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),r.then(e=>Ai(e))}{const t=function(e,t){const n={},o=ce(t,["model"]);return null!=o&&ue(n,["_url","name"],We(e,o)),n}(this.apiClient,e);return s=ae("{name}",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"GET",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json()),r.then(e=>Si(e))}}async listInternal(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=_i(this.apiClient,e);return s=ae("{models_url}",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"GET",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["nextPageToken"]);null!=o&&ue(t,["nextPageToken"],o);const i=ce(e,["_self"]);if(null!=i){let e=Tt(i);Array.isArray(e)&&(e=e.map(e=>Ai(e))),ue(t,["models"],e)}return t}(e),n=new Re;return Object.assign(n,t),n})}{const t=Ii(this.apiClient,e);return s=ae("{models_url}",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"GET",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["nextPageToken"]);null!=o&&ue(t,["nextPageToken"],o);const i=ce(e,["_self"]);if(null!=i){let e=Tt(i);Array.isArray(e)&&(e=e.map(e=>Si(e))),ue(t,["models"],e)}return t}(e),n=new Re;return Object.assign(n,t),n})}}async update(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=Mi(this.apiClient,e);return s=ae("{model}",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"PATCH",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),r.then(e=>Ai(e))}{const t=Pi(this.apiClient,e);return s=ae("{name}",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"PATCH",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json()),r.then(e=>Si(e))}}async delete(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=function(e,t){const n={},o=ce(t,["model"]);return null!=o&&ue(n,["_url","name"],We(e,o)),n}(this.apiClient,e);return s=ae("{name}",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"DELETE",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);return null!=n&&ue(t,["sdkHttpResponse"],n),t}(e),n=new we;return Object.assign(n,t),n})}{const t=function(e,t){const n={},o=ce(t,["model"]);return null!=o&&ue(n,["_url","name"],We(e,o)),n}(this.apiClient,e);return s=ae("{name}",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"DELETE",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);return null!=n&&ue(t,["sdkHttpResponse"],n),t}(e),n=new we;return Object.assign(n,t),n})}}async countTokens(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=function(e,t){const n={},o=ce(t,["model"]);null!=o&&ue(n,["_url","model"],We(e,o));const i=ce(t,["contents"]);if(null!=i){let e=at(i);Array.isArray(e)&&(e=e.map(e=>e)),ue(n,["contents"],e)}const r=ce(t,["config"]);return null!=r&&Xo(r,n),n}(this.apiClient,e);return s=ae("{model}:countTokens",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["totalTokens"]);return null!=o&&ue(t,["totalTokens"],o),t}(e),n=new Ne;return Object.assign(n,t),n})}{const t=Qo(this.apiClient,e);return s=ae("{model}:countTokens",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["totalTokens"]);null!=o&&ue(t,["totalTokens"],o);const i=ce(e,["cachedContentTokenCount"]);return null!=i&&ue(t,["cachedContentTokenCount"],i),t}(e),n=new Ne;return Object.assign(n,t),n})}}async computeTokens(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI()){const s=function(e,t){const n={},o=ce(t,["model"]);null!=o&&ue(n,["_url","model"],We(e,o));const i=ce(t,["contents"]);if(null!=i){let e=at(i);Array.isArray(e)&&(e=e.map(e=>e)),ue(n,["contents"],e)}return n}(this.apiClient,e);return i=ae("{model}:computeTokens",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),o.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["tokensInfo"]);if(null!=o){let e=o;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["tokensInfo"],e)}return t}(e),n=new Pe;return Object.assign(n,t),n})}throw new Error("This method is only supported by the Vertex AI.")}async generateVideosInternal(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=gi(this.apiClient,e);return s=ae("{model}:predictLongRunning",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),r.then(e=>{const t=fi(e),n=new Me;return Object.assign(n,t),n})}{const t=mi(this.apiClient,e);return s=ae("{model}:predictLongRunning",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json()),r.then(e=>{const t=hi(e),n=new Me;return Object.assign(n,t),n})}}}
265
+ */class Xi extends le{constructor(t){super(),this.apiClient=t,this.embedContent=async t=>{if(!this.apiClient.isVertexAI())return await this.embedContentInternal(t);if(t.model.includes("gemini")&&"gemini-embedding-001"!==t.model||t.model.includes("maas")){const n=at(t.contents);if(n.length>1)throw new Error("The embedContent API for this model only supports one content at a time.");const o=Object.assign(Object.assign({},t),{content:n[0],embeddingApiType:e.EmbeddingApiType.EMBED_CONTENT});return await this.embedContentInternal(o)}{const n=Object.assign(Object.assign({},t),{embeddingApiType:e.EmbeddingApiType.PREDICT});return await this.embedContentInternal(n)}},this.generateContent=async e=>{var t,n,o,i,r;const s=await this.processParamsMaybeAddMcpUsage(e);if(this.maybeMoveToResponseJsonSchem(e),!function(e){var t,n,o;return null!==(o=null===(n=null===(t=e.config)||void 0===t?void 0:t.tools)||void 0===n?void 0:n.some(e=>Ki(e)))&&void 0!==o&&o}(e)||$i(e.config))return await this.generateContentInternal(s);const l=Wi(e);if(l.length>0){const e=l.map(e=>`tools[${e}]`).join(", ");throw new Error(`Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations is not yet supported. Incompatible tools found at ${e}.`)}let a,u;const c=at(s.contents),p=null!==(o=null===(n=null===(t=s.config)||void 0===t?void 0:t.automaticFunctionCalling)||void 0===n?void 0:n.maximumRemoteCalls)&&void 0!==o?o:10;let d=0;for(;d<p&&(a=await this.generateContentInternal(s),a.functionCalls&&0!==a.functionCalls.length);){const t=a.candidates[0].content,n=[];for(const t of null!==(r=null===(i=e.config)||void 0===i?void 0:i.tools)&&void 0!==r?r:[])if(Ki(t)){const e=t,o=await e.callTool(a.functionCalls);n.push(...o)}d++,u={role:"user",parts:n},s.contents=at(s.contents),s.contents.push(t),s.contents.push(u),zi(s.config)&&(c.push(t),c.push(u))}return zi(s.config)&&(a.automaticFunctionCallingHistory=c),a},this.generateContentStream=async e=>{var t,n,o,i,r;if(this.maybeMoveToResponseJsonSchem(e),$i(e.config)){const t=await this.processParamsMaybeAddMcpUsage(e);return await this.generateContentStreamInternal(t)}const s=Wi(e);if(s.length>0){const e=s.map(e=>`tools[${e}]`).join(", ");throw new Error(`Incompatible tools found at ${e}. Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations" is not yet supported.`)}const l=null===(o=null===(n=null===(t=null==e?void 0:e.config)||void 0===t?void 0:t.toolConfig)||void 0===n?void 0:n.functionCallingConfig)||void 0===o?void 0:o.streamFunctionCallArguments,a=null===(r=null===(i=null==e?void 0:e.config)||void 0===i?void 0:i.automaticFunctionCalling)||void 0===r?void 0:r.disable;if(l&&!a)throw new 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=>{var t;let n;const o=[];if(null==e?void 0:e.generatedImages)for(const i of e.generatedImages)i&&(null==i?void 0:i.safetyAttributes)&&"Positive Prompt"===(null===(t=null==i?void 0:i.safetyAttributes)||void 0===t?void 0:t.contentType)?n=null==i?void 0:i.safetyAttributes:o.push(i);let i;return i=n?{generatedImages:o,positivePromptSafetyAttributes:n,sdkHttpResponse:e.sdkHttpResponse}:{generatedImages:o,sdkHttpResponse:e.sdkHttpResponse},i}),this.list=async t=>{var n;const o={config:Object.assign(Object.assign({},{queryBase:!0}),null==t?void 0:t.config)};if(this.apiClient.isVertexAI()&&!o.config.queryBase){if(null===(n=o.config)||void 0===n?void 0:n.filter)throw new Error("Filtering tuned models list for Vertex AI is not currently supported");o.config.filter="labels.tune-type:*"}return new Gt(e.PagedItem.PAGED_ITEM_MODELS,e=>this.listInternal(e),await this.listInternal(o),o)},this.editImage=async e=>{const 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));const n={model:e.model,image:e.image,upscaleFactor:e.upscaleFactor,config:t};return await this.upscaleImageInternal(n)},this.generateVideos=async e=>{var t,n,o,i,r,s;if((e.prompt||e.image||e.video)&&e.source)throw new Error("Source and prompt/image/video are mutually exclusive. Please only use source.");return this.apiClient.isVertexAI()||((null===(t=e.video)||void 0===t?void 0:t.uri)&&(null===(n=e.video)||void 0===n?void 0:n.videoBytes)?e.video={uri:e.video.uri,mimeType:e.video.mimeType}:(null===(i=null===(o=e.source)||void 0===o?void 0:o.video)||void 0===i?void 0:i.uri)&&(null===(s=null===(r=e.source)||void 0===r?void 0:r.video)||void 0===s?void 0:s.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){var t,n,o;const i=null===(t=e.config)||void 0===t?void 0:t.tools;if(!i)return e;const r=await Promise.all(i.map(async e=>{if(Ki(e)){const t=e;return await t.tool()}return e})),s={model:e.model,contents:e.contents,config:Object.assign(Object.assign({},e.config),{tools:r})};if(s.config.tools=r,e.config&&e.config.tools&&ki(e.config.tools)){const t=null!==(o=null===(n=e.config.httpOptions)||void 0===n?void 0:n.headers)&&void 0!==o?o:{};let i=Object.assign({},t);0===Object.keys(i).length&&(i=this.apiClient.getDefaultHeaders()),Gi(i),s.config.httpOptions=Object.assign(Object.assign({},e.config.httpOptions),{headers:i})}return s}async initAfcToolsMap(e){var t,n,o;const i=new Map;for(const r of null!==(n=null===(t=e.config)||void 0===t?void 0:t.tools)&&void 0!==n?n:[])if(Ki(r)){const e=r,t=await e.tool();for(const n of null!==(o=t.functionDeclarations)&&void 0!==o?o:[]){if(!n.name)throw new Error("Function declaration name is required.");if(i.has(n.name))throw new Error(`Duplicate tool declaration name: ${n.name}`);i.set(n.name,e)}}return i}async processAfcStream(e){var t,n,o;const i=null!==(o=null===(n=null===(t=e.config)||void 0===t?void 0:t.automaticFunctionCalling)||void 0===n?void 0:n.maximumRemoteCalls)&&void 0!==o?o:10;let r=!1,s=0;return function(e,t,n){return Xt(this,arguments,function*(){for(var o,l,a,u,c,p;s<i;){r&&(s++,r=!1);const m=yield zt(e.processParamsMaybeAddMcpUsage(n)),g=yield zt(e.generateContentStreamInternal(m)),y=[],v=[];try{for(var d,h=!0,f=(l=void 0,Qt(g));!(o=(d=yield zt(f.next())).done);h=!0){u=d.value,h=!1;const e=u;if(yield yield zt(e),e.candidates&&(null===(c=e.candidates[0])||void 0===c?void 0:c.content)){v.push(e.candidates[0].content);for(const n of null!==(p=e.candidates[0].content.parts)&&void 0!==p?p:[])if(s<i&&n.functionCall){if(!n.functionCall.name)throw new Error("Function call name was not returned by the model.");if(!t.has(n.functionCall.name))throw new Error(`Automatic function calling was requested, but not all the tools the model used implement the CallableTool interface. Available tools: ${t.keys()}, mising tool: ${n.functionCall.name}`);{const e=yield zt(t.get(n.functionCall.name).callTool([n.functionCall]));y.push(...e)}}}}}catch(e){l={error:e}}finally{try{h||o||!(a=f.return)||(yield zt(a.call(f)))}finally{if(l)throw l.error}}if(!(y.length>0))break;{r=!0;const e=new Ie;e.candidates=[{content:{role:"user",parts:y}}],yield yield zt(e);const t=[];t.push(...v),t.push({role:"user",parts:y});const o=at(n.contents).concat(t);n.contents=o}}})}(this,await this.initAfcToolsMap(e),e)}async generateContentInternal(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=ri(this.apiClient,e);return s=ae("{model}:generateContent",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=li(e),n=new Ie;return Object.assign(n,t),n})}{const t=ii(this.apiClient,e);return s=ae("{model}:generateContent",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=si(e),n=new Ie;return Object.assign(n,t),n})}}async generateContentStreamInternal(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=ri(this.apiClient,e);s=ae("{model}:streamGenerateContent?alt=sse",o._url),l=o._query,delete o._url,delete o._query;return r=this.apiClient.requestStream({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}),r.then(function(e){return Xt(this,arguments,function*(){var t,n,o,i;try{for(var r,s=!0,l=Qt(e);!(t=(r=yield zt(l.next())).done);s=!0){i=r.value,s=!1;const e=i,t=li(yield zt(e.json()));t.sdkHttpResponse={headers:e.headers};const n=new Ie;Object.assign(n,t),yield yield zt(n)}}catch(e){n={error:e}}finally{try{s||t||!(o=l.return)||(yield zt(o.call(l)))}finally{if(n)throw n.error}}})})}{const t=ii(this.apiClient,e);s=ae("{model}:streamGenerateContent?alt=sse",t._url),l=t._query,delete t._url,delete t._query;return r=this.apiClient.requestStream({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}),r.then(function(e){return Xt(this,arguments,function*(){var t,n,o,i;try{for(var r,s=!0,l=Qt(e);!(t=(r=yield zt(l.next())).done);s=!0){i=r.value,s=!1;const e=i,t=si(yield zt(e.json()));t.sdkHttpResponse={headers:e.headers};const n=new Ie;Object.assign(n,t),yield yield zt(n)}}catch(e){n={error:e}}finally{try{s||t||!(o=l.return)||(yield zt(o.call(l)))}finally{if(n)throw n.error}}})})}}async embedContentInternal(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=ti(this.apiClient,e,e);return s=ae((a=e.model).includes("gemini")&&"gemini-embedding-001"!==a||a.includes("maas")?"{model}:embedContent":"{model}:predict",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(t=>{const n=function(e,t){const n={},o=ce(e,["sdkHttpResponse"]);null!=o&&ue(n,["sdkHttpResponse"],o);const i=ce(e,["predictions[]","embeddings"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>Wo(e))),ue(n,["embeddings"],e)}const r=ce(e,["metadata"]);if(null!=r&&ue(n,["metadata"],r),t&&"EMBED_CONTENT"===ce(t,["embeddingApiType"])){const t=ce(e,["embedding"]),o=ce(e,["usageMetadata"]),i=ce(e,["truncated"]);if(t){const e={};o&&o.promptTokenCount&&(e.tokenCount=o.promptTokenCount),i&&(e.truncated=i),t.statistics=e,ue(n,["embeddings"],[t])}}return n}(t,e),o=new _e;return Object.assign(o,n),o})}{const t=ei(this.apiClient,e);return s=ae("{model}:batchEmbedContents",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["embeddings"]);if(null!=o){let e=o;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["embeddings"],e)}const i=ce(e,["metadata"]);return null!=i&&ue(t,["metadata"],i),t}(e),n=new _e;return Object.assign(n,t),n})}var a}async generateImagesInternal(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=ui(this.apiClient,e);return s=ae("{model}:predict",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["predictions"]);if(null!=o){let e=o;Array.isArray(e)&&(e=e.map(e=>yi(e))),ue(t,["generatedImages"],e)}const i=ce(e,["positivePromptSafetyAttributes"]);return null!=i&&ue(t,["positivePromptSafetyAttributes"],bi(i)),t}(e),n=new Se;return Object.assign(n,t),n})}{const t=ai(this.apiClient,e);return s=ae("{model}:predict",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=ci(e),n=new Se;return Object.assign(n,t),n})}}async editImageInternal(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI()){const s=Zo(this.apiClient,e);return i=ae("{model}:predict",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),o.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["predictions"]);if(null!=o){let e=o;Array.isArray(e)&&(e=e.map(e=>yi(e))),ue(t,["generatedImages"],e)}return t}(e),n=new Ae;return Object.assign(n,t),n})}throw new Error("This method is only supported by the Vertex AI.")}async upscaleImageInternal(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI()){const s=Di(this.apiClient,e);return i=ae("{model}:predict",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),o.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["predictions"]);if(null!=o){let e=o;Array.isArray(e)&&(e=e.map(e=>yi(e))),ue(t,["generatedImages"],e)}return t}(e),n=new Ce;return Object.assign(n,t),n})}throw new Error("This method is only supported by the Vertex AI.")}async recontextImage(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI()){const s=Ci(this.apiClient,e);return i=ae("{model}:predict",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),o.then(e=>{const t=function(e){const t={},n=ce(e,["predictions"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>yi(e))),ue(t,["generatedImages"],e)}return t}(e),n=new Oe;return Object.assign(n,t),n})}throw new Error("This method is only supported by the Vertex AI.")}async segmentImage(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI()){const s=Ri(this.apiClient,e);return i=ae("{model}:predict",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),o.then(e=>{const t=wi(e),n=new be;return Object.assign(n,t),n})}throw new Error("This method is only supported by the Vertex AI.")}async get(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=function(e,t){const n={},o=ce(t,["model"]);return null!=o&&ue(n,["_url","name"],We(e,o)),n}(this.apiClient,e);return s=ae("{name}",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"GET",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),r.then(e=>Ai(e))}{const t=function(e,t){const n={},o=ce(t,["model"]);return null!=o&&ue(n,["_url","name"],We(e,o)),n}(this.apiClient,e);return s=ae("{name}",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"GET",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json()),r.then(e=>Si(e))}}async listInternal(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=_i(this.apiClient,e);return s=ae("{models_url}",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"GET",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["nextPageToken"]);null!=o&&ue(t,["nextPageToken"],o);const i=ce(e,["_self"]);if(null!=i){let e=Tt(i);Array.isArray(e)&&(e=e.map(e=>Ai(e))),ue(t,["models"],e)}return t}(e),n=new Re;return Object.assign(n,t),n})}{const t=Ii(this.apiClient,e);return s=ae("{models_url}",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"GET",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["nextPageToken"]);null!=o&&ue(t,["nextPageToken"],o);const i=ce(e,["_self"]);if(null!=i){let e=Tt(i);Array.isArray(e)&&(e=e.map(e=>Si(e))),ue(t,["models"],e)}return t}(e),n=new Re;return Object.assign(n,t),n})}}async update(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=Mi(this.apiClient,e);return s=ae("{model}",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"PATCH",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),r.then(e=>Ai(e))}{const t=Pi(this.apiClient,e);return s=ae("{name}",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"PATCH",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json()),r.then(e=>Si(e))}}async delete(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=function(e,t){const n={},o=ce(t,["model"]);return null!=o&&ue(n,["_url","name"],We(e,o)),n}(this.apiClient,e);return s=ae("{name}",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"DELETE",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);return null!=n&&ue(t,["sdkHttpResponse"],n),t}(e),n=new we;return Object.assign(n,t),n})}{const t=function(e,t){const n={},o=ce(t,["model"]);return null!=o&&ue(n,["_url","name"],We(e,o)),n}(this.apiClient,e);return s=ae("{name}",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"DELETE",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);return null!=n&&ue(t,["sdkHttpResponse"],n),t}(e),n=new we;return Object.assign(n,t),n})}}async countTokens(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=function(e,t){const n={},o=ce(t,["model"]);null!=o&&ue(n,["_url","model"],We(e,o));const i=ce(t,["contents"]);if(null!=i){let e=at(i);Array.isArray(e)&&(e=e.map(e=>e)),ue(n,["contents"],e)}const r=ce(t,["config"]);return null!=r&&Xo(r,n),n}(this.apiClient,e);return s=ae("{model}:countTokens",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["totalTokens"]);return null!=o&&ue(t,["totalTokens"],o),t}(e),n=new Ne;return Object.assign(n,t),n})}{const t=Qo(this.apiClient,e);return s=ae("{model}:countTokens",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["totalTokens"]);null!=o&&ue(t,["totalTokens"],o);const i=ce(e,["cachedContentTokenCount"]);return null!=i&&ue(t,["cachedContentTokenCount"],i),t}(e),n=new Ne;return Object.assign(n,t),n})}}async computeTokens(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI()){const s=function(e,t){const n={},o=ce(t,["model"]);null!=o&&ue(n,["_url","model"],We(e,o));const i=ce(t,["contents"]);if(null!=i){let e=at(i);Array.isArray(e)&&(e=e.map(e=>e)),ue(n,["contents"],e)}return n}(this.apiClient,e);return i=ae("{model}:computeTokens",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),o.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["tokensInfo"]);if(null!=o){let e=o;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["tokensInfo"],e)}return t}(e),n=new Pe;return Object.assign(n,t),n})}throw new Error("This method is only supported by the Vertex AI.")}async generateVideosInternal(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=gi(this.apiClient,e);return s=ae("{model}:predictLongRunning",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),r.then(e=>{const t=fi(e),n=new Me;return Object.assign(n,t),n})}{const t=mi(this.apiClient,e);return s=ae("{model}:predictLongRunning",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json()),r.then(e=>{const t=hi(e),n=new Me;return Object.assign(n,t),n})}}}
266
266
  /**
267
267
  * @license
268
268
  * Copyright 2025 Google LLC
@@ -287,7 +287,7 @@ async function(e,t,n){const o=new Ye;let i;i=n.data instanceof Blob?JSON.parse(a
287
287
  * @license
288
288
  * Copyright 2025 Google LLC
289
289
  * SPDX-License-Identifier: Apache-2.0
290
- */class cr extends le{constructor(t){super(),this.apiClient=t,this.list=async(t={})=>new qt(e.PagedItem.PAGED_ITEM_TUNING_JOBS,e=>this.listInternal(e),await this.listInternal(t),t),this.get=async e=>await this.getInternal(e),this.tune=async t=>{var n;if(this.apiClient.isVertexAI()){if(t.baseModel.startsWith("projects/")){const e={tunedModelName:t.baseModel};(null===(n=t.config)||void 0===n?void 0:n.preTunedModelCheckpointId)&&(e.checkpointId=t.config.preTunedModelCheckpointId);const o=Object.assign(Object.assign({},t),{preTunedModel:e});return o.baseModel=void 0,await this.tuneInternal(o)}{const e=Object.assign({},t);return await this.tuneInternal(e)}}{const n=Object.assign({},t),o=await this.tuneMldevInternal(n);let i="";void 0!==o.metadata&&void 0!==o.metadata.tunedModel?i=o.metadata.tunedModel:void 0!==o.name&&o.name.includes("/operations/")&&(i=o.name.split("/operations/")[0]);return{name:i,state:e.JobState.JOB_STATE_QUEUED}}}}async getInternal(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=function(e){const t={},n=ce(e,["name"]);return null!=n&&ue(t,["_url","name"],n),t}(e);return s=ae("{name}",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"GET",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>ar(e))}{const t=function(e){const t={},n=ce(e,["name"]);return null!=n&&ue(t,["_url","name"],n),t}(e);return s=ae("{name}",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"GET",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>lr(e))}}async listInternal(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=sr(e);return s=ae("tuningJobs",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"GET",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["nextPageToken"]);null!=o&&ue(t,["nextPageToken"],o);const i=ce(e,["tuningJobs"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>ar(e))),ue(t,["tuningJobs"],e)}return t}(e),n=new De;return Object.assign(n,t),n})}{const t=rr(e);return s=ae("tunedModels",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"GET",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["nextPageToken"]);null!=o&&ue(t,["nextPageToken"],o);const i=ce(e,["tunedModels"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>lr(e))),ue(t,["tuningJobs"],e)}return t}(e),n=new De;return Object.assign(n,t),n})}}async cancel(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=function(e){const t={},n=ce(e,["name"]);return null!=n&&ue(t,["_url","name"],n),t}(e);return s=ae("{name}:cancel",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);return null!=n&&ue(t,["sdkHttpResponse"],n),t}(e),n=new Ue;return Object.assign(n,t),n})}{const t=function(e){const t={},n=ce(e,["name"]);return null!=n&&ue(t,["_url","name"],n),t}(e);return s=ae("{name}:cancel",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);return null!=n&&ue(t,["sdkHttpResponse"],n),t}(e),n=new Ue;return Object.assign(n,t),n})}}async tuneInternal(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI()){const s=ir(e,e);return i=ae("tuningJobs",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),o.then(e=>ar(e))}throw new Error("This method is only supported by the Vertex AI.")}async tuneMldevInternal(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const s=or(e);return i=ae("tunedModels",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),o.then(e=>function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["name"]);null!=o&&ue(t,["name"],o);const i=ce(e,["metadata"]);null!=i&&ue(t,["metadata"],i);const r=ce(e,["done"]);null!=r&&ue(t,["done"],r);const s=ce(e,["error"]);return null!=s&&ue(t,["error"],s),t}(e))}}}
290
+ */class cr extends le{constructor(t){super(),this.apiClient=t,this.list=async(t={})=>new Gt(e.PagedItem.PAGED_ITEM_TUNING_JOBS,e=>this.listInternal(e),await this.listInternal(t),t),this.get=async e=>await this.getInternal(e),this.tune=async t=>{var n;if(this.apiClient.isVertexAI()){if(t.baseModel.startsWith("projects/")){const e={tunedModelName:t.baseModel};(null===(n=t.config)||void 0===n?void 0:n.preTunedModelCheckpointId)&&(e.checkpointId=t.config.preTunedModelCheckpointId);const o=Object.assign(Object.assign({},t),{preTunedModel:e});return o.baseModel=void 0,await this.tuneInternal(o)}{const e=Object.assign({},t);return await this.tuneInternal(e)}}{const n=Object.assign({},t),o=await this.tuneMldevInternal(n);let i="";void 0!==o.metadata&&void 0!==o.metadata.tunedModel?i=o.metadata.tunedModel:void 0!==o.name&&o.name.includes("/operations/")&&(i=o.name.split("/operations/")[0]);return{name:i,state:e.JobState.JOB_STATE_QUEUED}}}}async getInternal(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=function(e){const t={},n=ce(e,["name"]);return null!=n&&ue(t,["_url","name"],n),t}(e);return s=ae("{name}",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"GET",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>ar(e))}{const t=function(e){const t={},n=ce(e,["name"]);return null!=n&&ue(t,["_url","name"],n),t}(e);return s=ae("{name}",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"GET",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>lr(e))}}async listInternal(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=sr(e);return s=ae("tuningJobs",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"GET",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["nextPageToken"]);null!=o&&ue(t,["nextPageToken"],o);const i=ce(e,["tuningJobs"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>ar(e))),ue(t,["tuningJobs"],e)}return t}(e),n=new De;return Object.assign(n,t),n})}{const t=rr(e);return s=ae("tunedModels",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"GET",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["nextPageToken"]);null!=o&&ue(t,["nextPageToken"],o);const i=ce(e,["tunedModels"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>lr(e))),ue(t,["tuningJobs"],e)}return t}(e),n=new De;return Object.assign(n,t),n})}}async cancel(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=function(e){const t={},n=ce(e,["name"]);return null!=n&&ue(t,["_url","name"],n),t}(e);return s=ae("{name}:cancel",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);return null!=n&&ue(t,["sdkHttpResponse"],n),t}(e),n=new Ue;return Object.assign(n,t),n})}{const t=function(e){const t={},n=ce(e,["name"]);return null!=n&&ue(t,["_url","name"],n),t}(e);return s=ae("{name}:cancel",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);return null!=n&&ue(t,["sdkHttpResponse"],n),t}(e),n=new Ue;return Object.assign(n,t),n})}}async tuneInternal(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI()){const s=ir(e,e);return i=ae("tuningJobs",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),o.then(e=>ar(e))}throw new Error("This method is only supported by the Vertex AI.")}async tuneMldevInternal(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const s=or(e);return i=ae("tunedModels",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),o.then(e=>function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["name"]);null!=o&&ue(t,["name"],o);const i=ce(e,["metadata"]);null!=i&&ue(t,["metadata"],i);const r=ce(e,["done"]);null!=r&&ue(t,["done"],r);const s=ce(e,["error"]);return null!=s&&ue(t,["error"],s),t}(e))}}}
291
291
  /**
292
292
  * @license
293
293
  * Copyright 2025 Google LLC
@@ -297,4 +297,4 @@ async function(e,t,n){const o=new Ye;let i;i=n.data instanceof Blob?JSON.parse(a
297
297
  * @license
298
298
  * Copyright 2025 Google LLC
299
299
  * SPDX-License-Identifier: Apache-2.0
300
- */e.ApiError=pn,e.Batches=Gt,e.Caches=Yt,e.CancelTuningJobResponse=Ue,e.Chat=on,e.Chats=nn,e.ComputeTokensResponse=Pe,e.ContentReferenceImage=class{toReferenceImageAPI(){return{referenceType:"REFERENCE_TYPE_CONTENT",referenceImage:this.referenceImage,referenceId:this.referenceId}}},e.ControlReferenceImage=class{toReferenceImageAPI(){return{referenceType:"REFERENCE_TYPE_CONTROL",referenceImage:this.referenceImage,referenceId:this.referenceId,controlImageConfig:this.config}}},e.CountTokensResponse=Ne,e.CreateFileResponse=je,e.DeleteCachedContentResponse=xe,e.DeleteFileResponse=Ve,e.DeleteModelResponse=we,e.EditImageResponse=Ae,e.EmbedContentResponse=_e,e.Files=An,e.FunctionResponse=class{},e.FunctionResponseBlob=class{},e.FunctionResponseFileData=class{},e.FunctionResponsePart=class{},e.GenerateContentResponse=Ie,e.GenerateContentResponsePromptFeedback=class{},e.GenerateContentResponseUsageMetadata=class{},e.GenerateImagesResponse=Se,e.GenerateVideosOperation=Me,e.GenerateVideosResponse=class{},e.GoogleGenAI=class{get interactions(){var e;if(void 0!==this._interactions)return this._interactions;if(console.warn("GoogleGenAI.interactions: Interactions usage is experimental and may change in future versions."),this.vertexai)throw new Error("This version of the GenAI SDK does not support Vertex AI API for interactions.");const t=this.httpOptions;(null==t?void 0:t.extraBody)&&console.warn("GoogleGenAI.interactions: Client level httpOptions.extraBody is not supported by the interactions client and will be ignored.");const n=new Fo({baseURL:this.apiClient.getBaseUrl(),apiKey:this.apiKey,apiVersion:this.apiClient.getApiVersion(),clientAdapter:this.apiClient,defaultHeaders:this.apiClient.getDefaultHeaders(),timeout:null==t?void 0:t.timeout,maxRetries:null===(e=null==t?void 0:t.retryOptions)||void 0===e?void 0:e.attempts});return this._interactions=n.interactions,this._interactions}constructor(e){var t;if(null==e.apiKey)throw new Error(`An API Key must be set when running in an unspecified environment.\n + ${gn().message}`);this.vertexai=null!==(t=e.vertexai)&&void 0!==t&&t,this.apiKey=e.apiKey,this.apiVersion=e.apiVersion,this.httpOptions=e.httpOptions;const n=new dr(this.apiKey);this.apiClient=new fn({auth:n,apiVersion:this.apiVersion,apiKey:this.apiKey,vertexai:this.vertexai,httpOptions:this.httpOptions,userAgentExtra:"gl-node/cross",uploader:new En,downloader:new yn}),this.models=new Xi(this.apiClient),this.live=new Bi(this.apiClient,n,new _n),this.chats=new nn(this.models,this.apiClient),this.batches=new Gt(this.apiClient),this.caches=new Yt(this.apiClient),this.files=new An(this.apiClient),this.operations=new Qi(this.apiClient),this.authTokens=new nr(this.apiClient),this.tunings=new cr(this.apiClient),this.fileSearchStores=new Rn(this.apiClient)}},e.HttpResponse=Te,e.ImportFileOperation=Fe,e.ImportFileResponse=class{},e.InlinedEmbedContentResponse=class{},e.InlinedResponse=class{},e.ListBatchJobsResponse=Je,e.ListCachedContentsResponse=Le,e.ListDocumentsResponse=ke,e.ListFileSearchStoresResponse=qe,e.ListFilesResponse=He,e.ListModelsResponse=Re,e.ListTuningJobsResponse=De,e.Live=Bi,e.LiveClientToolResponse=class{},e.LiveMusicServerMessage=Ye,e.LiveSendToolResponseParameters=class{constructor(){this.functionResponses=[]}},e.LiveServerMessage=$e,e.MaskReferenceImage=class{toReferenceImageAPI(){return{referenceType:"REFERENCE_TYPE_MASK",referenceImage:this.referenceImage,referenceId:this.referenceId,maskImageConfig:this.config}}},e.Models=Xi,e.Operations=Qi,e.Pager=qt,e.RawReferenceImage=class{toReferenceImageAPI(){return{referenceType:"REFERENCE_TYPE_RAW",referenceImage:this.referenceImage,referenceId:this.referenceId}}},e.RecontextImageResponse=Oe,e.RegisterFilesResponse=Be,e.ReplayResponse=class{},e.SegmentImageResponse=be,e.Session=$i,e.SingleEmbedContentResponse=class{},e.StyleReferenceImage=class{toReferenceImageAPI(){return{referenceType:"REFERENCE_TYPE_STYLE",referenceImage:this.referenceImage,referenceId:this.referenceId,styleImageConfig:this.config}}},e.SubjectReferenceImage=class{toReferenceImageAPI(){return{referenceType:"REFERENCE_TYPE_SUBJECT",referenceImage:this.referenceImage,referenceId:this.referenceId,subjectImageConfig:this.config}}},e.Tokens=nr,e.UploadToFileSearchStoreOperation=Ke,e.UploadToFileSearchStoreResponse=class{},e.UploadToFileSearchStoreResumableResponse=Ge,e.UpscaleImageResponse=Ce,e.createFunctionResponsePartFromBase64=function(e,t){return{inlineData:{data:e,mimeType:t}}},e.createFunctionResponsePartFromUri=function(e,t){return{fileData:{fileUri:e,mimeType:t}}},e.createModelContent=function(e){return{role:"model",parts:Ee(e)}},e.createPartFromBase64=function(e,t,n){return Object.assign({inlineData:{data:e,mimeType:t}},n&&{mediaResolution:{level:n}})},e.createPartFromCodeExecutionResult=function(e,t){return{codeExecutionResult:{outcome:e,output:t}}},e.createPartFromExecutableCode=function(e,t){return{executableCode:{code:e,language:t}}},e.createPartFromFunctionCall=function(e,t){return{functionCall:{name:e,args:t}}},e.createPartFromFunctionResponse=function(e,t,n,o=[]){return{functionResponse:Object.assign({id:e,name:t,response:n},o.length>0&&{parts:o})}},e.createPartFromText=ye,e.createPartFromUri=function(e,t,n){return Object.assign({fileData:{fileUri:e,mimeType:t}},n&&{mediaResolution:{level:n}})},e.createUserContent=function(e){return{role:"user",parts:Ee(e)}},e.mcpToTool=function(...e){if(Li=!0,0===e.length)throw new Error("No MCP clients provided");const t=e[e.length-1];return null!==(n=t)&&"object"==typeof n&&"listTools"in n&&"function"==typeof n.listTools?Hi.create(e,{}):Hi.create(e.slice(0,e.length-1),t);var n},e.setDefaultBaseUrls=function(e){e.geminiUrl,e.vertexUrl}}(y)),y}function A(){if(c)return u;return c=1,u={getExtractionPrompt:function(){return'\nTu es un moteur d\'extraction et de classification spécialisé dans les factures du secteur mécanique automobile.\n\nTa tâche est d’analyser le texte fourni.\n\nIMPORTANT :\n- Si le document n’est PAS clairement une facture, retourne STRICTEMENT : null\n- Sinon retourne UNIQUEMENT un JSON valide correspondant au schéma.\nLe JSON doit respecter STRICTEMENT cette structure :\n\n{\n "reference": string | null,\n "date": string | null,\n "supplier": string | null,\n "customer": string | null,\n "totalAmount": number | null,\n "currency": string | null,\n "address": string | null,\n "items": [\n {\n "description": string,\n "quantity": number | null,\n "unitPrice": number | null,\n "totalPrice": number | null,\n "category": string | null\n }\n ],\n "taxAmount": number | null,\n "language": string | null\n}\n\nCATEGORIES AUTORISÉES (liste fermée) :\n\n- carrosserie\n- depannage\n- entretien_preventif\n- reparation_curative\n- diagnostic_electronique\n- autre\n\nRÈGLES DE CLASSIFICATION :\n\nAnalyse la description de chaque article et classe-le dans UNE SEULE catégorie :\n\n- carrosserie → peinture, tôle, choc, pare-chocs, aile, redressage\n- depannage → remorquage, dépannage route, batterie à plat\n- entretien_preventif → vidange, filtres, révision, entretien périodique\n- reparation_curative → remplacement pièce, réparation moteur, frein, embrayage\n- diagnostic_electronique → valise, scanner OBD, diagnostic calculateur\n\nSi aucune catégorie ne correspond clairement → "autre".\n\nRÈGLES GÉNÉRALES :\n\n1. Retourne UNIQUEMENT :\n - soit null\n - soit un JSON valide.\n2. Aucun texte explicatif.\n3. Aucun markdown.\n4. Si une donnée est absente → null.\n5. Les montants doivent être des NOMBRES.\n6. Utilise "." comme séparateur décimal.\n7. Date format YYYY-MM-DD ou null.\n8. Devise normalisée (EUR, USD, MAD...).\n9. Ne déduis aucune information absente explicitement.\n10. Une seule catégorie par item.\n\nAnalyse maintenant le texte suivant :\n'},getTasksCreationPrompt:function(e,t){return`\n CONTEXTE: Creation de tâches dans une solution de fleet management system.\n Tu es le responsable de park en maintenance de flottes(automobiles, camions, vehicules). \n Les taches sont le moyen de communiquer entre les personnes impliquées dans la gestion de resolution de l'intervention.\n Tu reçois les signalement des chauffeurs sur l'état de leurs véhicules. \n\n À partir de l'intervention, génère un tableau JSON de tâches détaillées et structurées.\n Tu pourrais recevoir un audio ou une photo descriptive de l'intervention ou de la panne.\n Il faudra les analyser pour en extraire des informations utiles à la création des tâches.\n Genere uniquement des taches principales relatives à la resolution de l'intervention.'\n \n **Titre :** ${e}\n **Description :** ${t}\n Réponds UNIQUEMENT avec un tableau JSON valide (sans markdown, sans explication), en suivant exactement ce format :\n [\n {\n "title": "Titre de la tâche",\n "description": "Description détaillée",\n "category": "catégorie de la tache(exemple: mécanique, electric, pneumatique,..)"\n }\n ]`},cleanJsonResponse:function(e){return e.replace(/```json/g,"").replace(/```/g,"").trim()},getMimeType:function(e){return{jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",webp:"image/webp",mp3:"audio/mpeg",wav:"audio/wav"}[e.replace(".","").toLowerCase()]}}}var C=t(function(){if(g)return m;g=1;const{GoogleGenAI:t}=S(),{extractFromBase64:n}=function(){if(d)return p;d=1;const t=e,{getExtractionPrompt:n}=A();return p={extractFromBase64:async function(e,o,i){if(!i)return null;if(!e)throw new Error("InvoiceExtractor not initialized. Call init() first.");let r,s=i;const l=i.match(/^data:(.*);base64,(.*)$/);if(l)r=l[1],s=l[2];else{const e=Buffer.from(i,"base64"),n=await t(e);if(!n)throw new Error("Unable to detect file type");r=n.mime}const a=await e.models.generateContent({model:o,contents:[{role:"user",parts:[{inlineData:{mimeType:r,data:s}},{text:n()}]}]});if(!a?.text)return null;const u=a.text.replace(/```json|```/g,"").trim();return JSON.parse(u)}}}(),{generateTasks:o}=function(){if(f)return h;f=1;const{cleanJsonResponse:e,getMimeType:t,getTasksCreationPrompt:n}=A();return h={generateTasks:async function(o,i,r,s,l,a){if(!r||!s)throw new Error("Le titre et la description sont obligatoires.");if(!o)throw new Error("TasksGenerator not initialized. Call init() first.");const u=[];l&&u.push({inlineData:{mimeType:t(l.extension),data:Buffer.from(l.buffer).toString("base64")}}),a&&u.push({inlineData:{mimeType:t(a.extension),data:Buffer.from(a.buffer).toString("base64")}}),u.push({text:n(r,s)});const c=await o.models.generateContent({model:i,contents:[{role:"user",parts:u}],generationConfig:{maxOutputTokens:2048,temperature:.2}}),p=c.candidates?.[0]?.content?.parts?.[0]?.text?.trim();if(!p)throw new Error("Réponse vide du modèle.");const d=JSON.parse(e(p));if(!Array.isArray(d))throw new Error("La réponse n'est pas un tableau JSON.");return d}}}();return m=new class{#e;#t;init({apiKey:e,model:n}={}){const o=e??process.env.AI_API_KEY,i=n??process.env.AI_MODEL??"gemini-2.5-flash";if(!o)throw new Error("API key is required. Provide it via init() or AI_API_KEY env variable.");return this.#e=new t({apiKey:o}),this.#t=i,this}extract(e){if(!this.#e)throw new Error("AiModule not initialized. Call init() first.");return n(this.#e,this.#t,e)}generateTasks(e,t,n,i){if(!this.#e)throw new Error("AiModule not initialized. Call init() first.");return o(this.#e,this.#t,e,t,n,i)}}}());export{C as default};
300
+ */e.ApiError=pn,e.Batches=qt,e.Caches=$t,e.CancelTuningJobResponse=Ue,e.Chat=on,e.Chats=nn,e.ComputeTokensResponse=Pe,e.ContentReferenceImage=class{toReferenceImageAPI(){return{referenceType:"REFERENCE_TYPE_CONTENT",referenceImage:this.referenceImage,referenceId:this.referenceId}}},e.ControlReferenceImage=class{toReferenceImageAPI(){return{referenceType:"REFERENCE_TYPE_CONTROL",referenceImage:this.referenceImage,referenceId:this.referenceId,controlImageConfig:this.config}}},e.CountTokensResponse=Ne,e.CreateFileResponse=je,e.DeleteCachedContentResponse=xe,e.DeleteFileResponse=Ve,e.DeleteModelResponse=we,e.EditImageResponse=Ae,e.EmbedContentResponse=_e,e.Files=An,e.FunctionResponse=class{},e.FunctionResponseBlob=class{},e.FunctionResponseFileData=class{},e.FunctionResponsePart=class{},e.GenerateContentResponse=Ie,e.GenerateContentResponsePromptFeedback=class{},e.GenerateContentResponseUsageMetadata=class{},e.GenerateImagesResponse=Se,e.GenerateVideosOperation=Me,e.GenerateVideosResponse=class{},e.GoogleGenAI=class{get interactions(){var e;if(void 0!==this._interactions)return this._interactions;if(console.warn("GoogleGenAI.interactions: Interactions usage is experimental and may change in future versions."),this.vertexai)throw new Error("This version of the GenAI SDK does not support Vertex AI API for interactions.");const t=this.httpOptions;(null==t?void 0:t.extraBody)&&console.warn("GoogleGenAI.interactions: Client level httpOptions.extraBody is not supported by the interactions client and will be ignored.");const n=new Fo({baseURL:this.apiClient.getBaseUrl(),apiKey:this.apiKey,apiVersion:this.apiClient.getApiVersion(),clientAdapter:this.apiClient,defaultHeaders:this.apiClient.getDefaultHeaders(),timeout:null==t?void 0:t.timeout,maxRetries:null===(e=null==t?void 0:t.retryOptions)||void 0===e?void 0:e.attempts});return this._interactions=n.interactions,this._interactions}constructor(e){var t;if(null==e.apiKey)throw new Error(`An API Key must be set when running in an unspecified environment.\n + ${gn().message}`);this.vertexai=null!==(t=e.vertexai)&&void 0!==t&&t,this.apiKey=e.apiKey,this.apiVersion=e.apiVersion,this.httpOptions=e.httpOptions;const n=new dr(this.apiKey);this.apiClient=new fn({auth:n,apiVersion:this.apiVersion,apiKey:this.apiKey,vertexai:this.vertexai,httpOptions:this.httpOptions,userAgentExtra:"gl-node/cross",uploader:new En,downloader:new yn}),this.models=new Xi(this.apiClient),this.live=new Bi(this.apiClient,n,new _n),this.chats=new nn(this.models,this.apiClient),this.batches=new qt(this.apiClient),this.caches=new $t(this.apiClient),this.files=new An(this.apiClient),this.operations=new Qi(this.apiClient),this.authTokens=new nr(this.apiClient),this.tunings=new cr(this.apiClient),this.fileSearchStores=new Rn(this.apiClient)}},e.HttpResponse=Te,e.ImportFileOperation=Fe,e.ImportFileResponse=class{},e.InlinedEmbedContentResponse=class{},e.InlinedResponse=class{},e.ListBatchJobsResponse=Je,e.ListCachedContentsResponse=Le,e.ListDocumentsResponse=ke,e.ListFileSearchStoresResponse=Ge,e.ListFilesResponse=He,e.ListModelsResponse=Re,e.ListTuningJobsResponse=De,e.Live=Bi,e.LiveClientToolResponse=class{},e.LiveMusicServerMessage=$e,e.LiveSendToolResponseParameters=class{constructor(){this.functionResponses=[]}},e.LiveServerMessage=Ye,e.MaskReferenceImage=class{toReferenceImageAPI(){return{referenceType:"REFERENCE_TYPE_MASK",referenceImage:this.referenceImage,referenceId:this.referenceId,maskImageConfig:this.config}}},e.Models=Xi,e.Operations=Qi,e.Pager=Gt,e.RawReferenceImage=class{toReferenceImageAPI(){return{referenceType:"REFERENCE_TYPE_RAW",referenceImage:this.referenceImage,referenceId:this.referenceId}}},e.RecontextImageResponse=Oe,e.RegisterFilesResponse=Be,e.ReplayResponse=class{},e.SegmentImageResponse=be,e.Session=Yi,e.SingleEmbedContentResponse=class{},e.StyleReferenceImage=class{toReferenceImageAPI(){return{referenceType:"REFERENCE_TYPE_STYLE",referenceImage:this.referenceImage,referenceId:this.referenceId,styleImageConfig:this.config}}},e.SubjectReferenceImage=class{toReferenceImageAPI(){return{referenceType:"REFERENCE_TYPE_SUBJECT",referenceImage:this.referenceImage,referenceId:this.referenceId,subjectImageConfig:this.config}}},e.Tokens=nr,e.UploadToFileSearchStoreOperation=Ke,e.UploadToFileSearchStoreResponse=class{},e.UploadToFileSearchStoreResumableResponse=qe,e.UpscaleImageResponse=Ce,e.createFunctionResponsePartFromBase64=function(e,t){return{inlineData:{data:e,mimeType:t}}},e.createFunctionResponsePartFromUri=function(e,t){return{fileData:{fileUri:e,mimeType:t}}},e.createModelContent=function(e){return{role:"model",parts:Ee(e)}},e.createPartFromBase64=function(e,t,n){return Object.assign({inlineData:{data:e,mimeType:t}},n&&{mediaResolution:{level:n}})},e.createPartFromCodeExecutionResult=function(e,t){return{codeExecutionResult:{outcome:e,output:t}}},e.createPartFromExecutableCode=function(e,t){return{executableCode:{code:e,language:t}}},e.createPartFromFunctionCall=function(e,t){return{functionCall:{name:e,args:t}}},e.createPartFromFunctionResponse=function(e,t,n,o=[]){return{functionResponse:Object.assign({id:e,name:t,response:n},o.length>0&&{parts:o})}},e.createPartFromText=ye,e.createPartFromUri=function(e,t,n){return Object.assign({fileData:{fileUri:e,mimeType:t}},n&&{mediaResolution:{level:n}})},e.createUserContent=function(e){return{role:"user",parts:Ee(e)}},e.mcpToTool=function(...e){if(Li=!0,0===e.length)throw new Error("No MCP clients provided");const t=e[e.length-1];return null!==(n=t)&&"object"==typeof n&&"listTools"in n&&"function"==typeof n.listTools?Hi.create(e,{}):Hi.create(e.slice(0,e.length-1),t);var n},e.setDefaultBaseUrls=function(e){e.geminiUrl,e.vertexUrl}}(y)),y}function A(){if(c)return u;return c=1,u={getExtractionPrompt:function(){return'\nRôle :\nTu es un agent d\'extraction de données OCR haute précision, spécialisé exclusivement dans les factures du secteur automobile (garages, concessions, centres de réparation).\nDirectives de sortie strictes :\nTon analyse doit être binaire : soit un objet JSON, soit le mot null.\nNe produis AUCUN texte avant ou après le JSON (pas de "Voici le résultat", pas de blocs de code Markdown ```json).\nSi le texte fourni n\'est pas une facture automobile identifiable, réponds uniquement : null.\nSchéma JSON cible :\n{\n "reference": string | null,\n "date": "YYYY-MM-DD" | null,\n "supplier": string | null,\n "customer": string | null,\n "totalAmount": number | null,\n "currency": "ISO_CODE" | null,\n "address": string | null,\n "items": [\n {\n "description": string,\n "quantity": number | null,\n "unitPrice": number | null,\n "totalPrice": number | null,\n "category": "carrosserie" | "depannage" | "entretien_preventif" | "reparation_curative" | "diagnostic_electronique" | "autre"\n }\n ],\n "taxAmount": number | null,\n "language": "ISO_639-1" | null\n}\nLogique de classification des items (Priorité absolue) :\nClasse chaque ligne de service/pièce selon ces mots-clés :\ncarrosserie : peinture, tôle, choc, débosselage, redressage, aile, pare-chocs.\ndepannage : remorquage, assistance, transport véhicule, batterie (si dépannage sur place).\nentretien_preventif : vidange, révision, remplacement filtres (air/huile/habitacle), niveaux, bougies.\nreparation_curative : freinage (plaquettes/disques), embrayage, distribution, cardan, amortisseurs, moteur, boîte de vitesse.\ndiagnostic_electronique : passage valise, lecture codes défaut, programmation, reset voyant.\nautre : frais de dossier, recyclage déchets, main d\'œuvre non spécifiée.\nRègles de formatage des données :\nNombres : Utilise exclusivement le point . comme séparateur décimal. Pas de séparateur de milliers.\nDates : Normalise impérativement au format YYYY-MM-DD.\nDevise : Utilise le code ISO 4217 (ex: EUR, MAD, USD).\nIntégrité : Si une valeur est incertaine ou absente, utilise null. Ne devine jamais une information.\n'},getTasksCreationPrompt:function(e,t){return`\n CONTEXTE: Creation de tâches dans une solution de fleet management system.\n Tu es le responsable de park en maintenance de flottes(automobiles, camions, vehicules). \n Les taches sont le moyen de communiquer entre les personnes impliquées dans la gestion de resolution de l'intervention.\n Tu reçois les signalement des chauffeurs sur l'état de leurs véhicules. \n\n À partir de l'intervention, génère un tableau JSON de tâches détaillées et structurées.\n Tu pourrais recevoir un audio ou une photo descriptive de l'intervention ou de la panne.\n Il faudra les analyser pour en extraire des informations utiles à la création des tâches.\n Genere uniquement des taches principales relatives à la resolution de l'intervention.'\n \n **Titre :** ${e}\n **Description :** ${t}\n Réponds UNIQUEMENT avec un tableau JSON valide (sans markdown, sans explication), en suivant exactement ce format :\n [\n {\n "title": "Titre de la tâche",\n "description": "Description détaillée",\n "category": "catégorie de la tache(exemple: mécanique, electric, pneumatique,..)"\n }\n ]`},cleanJsonResponse:function(e){return e.replace(/```json/g,"").replace(/```/g,"").trim()},getMimeType:function(e){return{jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",webp:"image/webp",mp3:"audio/mpeg",wav:"audio/wav"}[e.replace(".","").toLowerCase()]},safeParseJSON:function(e){if(!e)return null;let t=e.replace(/```json/gi,"").replace(/```/g,"").trim();if("null"===t)return null;const n=t.match(/\{[\s\S]*\}/);return n?(t=n[0],t=t.replace(/,\s*([\]}])/g,"$1"),t=t.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,""),JSON.parse(t)):null}}}var C=t(function(){if(g)return m;g=1;const{GoogleGenAI:t}=S(),{extractFromBase64:n}=function(){if(d)return p;d=1;const{fromBuffer:t}=e,{getExtractionPrompt:n}=A(),{safeParseJSON:o}=A(),{Type:i}=S();return p={extractFromBase64:async function(e,r,s){if(!s)return null;if(!e)throw new Error("InvoiceExtractor not initialized. Call init() first.");let l,a=s;const u=s.match(/^data:(.*);base64,(.*)$/);if(u)l=u[1],a=u[2];else{const e=Buffer.from(s,"base64"),n=await t(e);if(!n)throw new Error("Unable to detect file type");l=n.mime}const c=await e.models.generateContent({model:r,contents:[{role:"user",parts:[{inlineData:{mimeType:l,data:a}},{text:n()}]}],config:{responseMimeType:"application/json",responseSchema:{type:i.OBJECT,properties:{reference:{type:i.STRING,nullable:!0},date:{type:i.STRING,nullable:!0},supplier:{type:i.STRING,nullable:!0},customer:{type:i.STRING,nullable:!0},totalAmount:{type:i.NUMBER,nullable:!0},currency:{type:i.STRING,nullable:!0},address:{type:i.STRING,nullable:!0},taxAmount:{type:i.NUMBER,nullable:!0},language:{type:i.STRING,nullable:!0},items:{type:i.ARRAY,items:{type:i.OBJECT,properties:{description:{type:i.STRING},quantity:{type:i.NUMBER,nullable:!0},unitPrice:{type:i.NUMBER,nullable:!0},totalPrice:{type:i.NUMBER,nullable:!0},category:{type:i.STRING,enum:["carrosserie","depannage","entretien_preventif","reparation_curative","diagnostic_electronique","autre"]}}}}}}}});return c?.text?o(c.text):null}}}(),{generateTasks:o}=function(){if(f)return h;f=1;const{cleanJsonResponse:e,getMimeType:t,getTasksCreationPrompt:n}=A();return h={generateTasks:async function(o,i,r,s,l,a){if(!r||!s)throw new Error("Le titre et la description sont obligatoires.");if(!o)throw new Error("TasksGenerator not initialized. Call init() first.");const u=[];l&&u.push({inlineData:{mimeType:t(l.extension),data:Buffer.from(l.buffer).toString("base64")}}),a&&u.push({inlineData:{mimeType:t(a.extension),data:Buffer.from(a.buffer).toString("base64")}}),u.push({text:n(r,s)});const c=await o.models.generateContent({model:i,contents:[{role:"user",parts:u}],generationConfig:{maxOutputTokens:2048,temperature:.2}}),p=c.candidates?.[0]?.content?.parts?.[0]?.text?.trim();if(!p)throw new Error("Réponse vide du modèle.");const d=JSON.parse(e(p));if(!Array.isArray(d))throw new Error("La réponse n'est pas un tableau JSON.");return d}}}();return m=new class{#e;#t;init({apiKey:e,model:n}={}){const o=e??process.env.AI_API_KEY,i=n??process.env.AI_MODEL??"gemini-2.5-flash";if(!o)throw new Error("API key is required. Provide it via init() or AI_API_KEY env variable.");return this.#e=new t({apiKey:o}),this.#t=i,this}extract(e){if(!this.#e)throw new Error("AiModule not initialized. Call init() first.");return n(this.#e,this.#t,e)}generateTasks(e,t,n,i){if(!this.#e)throw new Error("AiModule not initialized. Call init() first.");return o(this.#e,this.#t,e,t,n,i)}}}());export{C as default};