@adaline/vertex 1.4.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  var zod = require('zod');
4
4
 
5
- var An=Object.defineProperty,Hn=Object.defineProperties;var zn=Object.getOwnPropertyDescriptors;var Jt=Object.getOwnPropertySymbols;var Vn=Object.prototype.hasOwnProperty,Kn=Object.prototype.propertyIsEnumerable;var He=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Yn=t=>{throw TypeError(t)};var Wt=(t,e,o)=>e in t?An(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,T=(t,e)=>{for(var o in e||(e={}))Vn.call(e,o)&&Wt(t,o,e[o]);if(Jt)for(var o of Jt(e))Kn.call(e,o)&&Wt(t,o,e[o]);return t},x=(t,e)=>Hn(t,zn(e));var Te=(t,e,o)=>new Promise((i,a)=>{var d=l=>{try{m(o.next(l));}catch(c){a(c);}},r=l=>{try{m(o.throw(l));}catch(c){a(c);}},m=l=>l.done?i(l.value):Promise.resolve(l.value).then(d,r);m((o=o.apply(t,e)).next());}),Jn=function(t,e){this[0]=t,this[1]=e;};var Xt=t=>{var e=t[He("asyncIterator")],o=!1,i,a={};return e==null?(e=t[He("iterator")](),i=d=>a[d]=r=>e[d](r)):(e=e.call(t),i=d=>a[d]=r=>{if(o){if(o=!1,d==="throw")throw r;return r}return o=!0,{done:!1,value:new Jn(new Promise(m=>{var l=e[d](r);l instanceof Object||Yn("Object expected"),m(l);}),1)}}),a[He("iterator")]=()=>a,i("next"),"throw"in e?i("throw"):a.throw=d=>{throw d},"return"in e&&i("return"),a};var ue="system",V="user",q="assistant",ee="tool",Wn=[ue,V,q,ee],Ke=zod.z.enum(Wn),Xn=[q],Zn=zod.z.enum(Xn),te="image",Ye="base64",Qn=["png","jpeg","webp","gif"],ei=zod.z.object({type:zod.z.literal(Ye),base64:zod.z.string(),mediaType:zod.z.enum(Qn)}),ti="url",oi=zod.z.object({type:zod.z.literal(ti),url:zod.z.string()}),ni=zod.z.discriminatedUnion("type",[ei,oi]),ii=["low","medium","high","auto"],ai=zod.z.enum(ii),si=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(te),detail:ai,value:ni,metadata:t}),se="pdf",ri="base64",li=zod.z.object({type:zod.z.literal(ri),base64:zod.z.string()}),mi="url",di=zod.z.object({type:zod.z.literal(mi),url:zod.z.string()}),ci=zod.z.discriminatedUnion("type",[li,di]),pi=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(se),value:ci,providerCacheKey:zod.z.string(),metadata:t}),to="reasoning",oo="partial-reasoning",no="thinking",ui="redacted",Ve=zod.z.object({type:zod.z.literal(no),thinking:zod.z.string(),signature:zod.z.string()}),io=zod.z.object({type:zod.z.literal(ui),data:zod.z.string()}),gi=zod.z.discriminatedUnion("type",[Ve,io]),hi=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(to),value:gi,metadata:t}),fi=zod.z.object({type:zod.z.literal(no),thinking:Ve.shape.thinking.optional(),signature:Ve.shape.signature.optional()}),yi=zod.z.discriminatedUnion("type",[fi,io]),bi=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(oo),value:yi,metadata:t}),S="text",ao=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(S),value:zod.z.string(),metadata:t}),Je="partial-text",so=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Je),value:zod.z.string(),metadata:t}),A="tool-call",ro=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(A),index:zod.z.number().int().nonnegative(),id:zod.z.string().min(1),name:zod.z.string().min(1),arguments:zod.z.string(),metadata:t}),We="partial-tool-call",lo=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(We),index:zod.z.number().int().nonnegative(),id:zod.z.string().optional(),name:zod.z.string().optional(),arguments:zod.z.string().optional(),metadata:t}),oe="tool-response",Ti=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(oe),index:zod.z.number().int().nonnegative(),id:zod.z.string().min(1),name:zod.z.string().min(1),data:zod.z.string(),apiResponse:zod.z.object({statusCode:zod.z.number().int().nonnegative()}).optional(),metadata:t}),Mi=[S,te,se,A,oe,to],mo=zod.z.enum(Mi),_i=(t=zod.z.undefined(),e=zod.z.undefined(),o=zod.z.undefined(),i=zod.z.undefined(),a=zod.z.undefined(),d=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[ao(t),si(e),pi(o),ro(i),Ti(a),hi(d)]),Pi=[Je,We,oo];zod.z.enum(Pi);var Ei=(t=zod.z.undefined(),e=zod.z.undefined(),o=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[so(t),lo(e),bi(o)]);var Xe=(t=Ke,e=zod.z.undefined(),o=zod.z.undefined(),i=zod.z.undefined(),a=zod.z.undefined(),d=zod.z.undefined(),r=zod.z.undefined())=>zod.z.object({role:t,content:zod.z.array(_i(e,o,i,a,r)),metadata:d}),Ze=(t=Zn,e=zod.z.undefined(),o=zod.z.undefined(),i=zod.z.undefined(),a=zod.z.undefined())=>zod.z.object({role:t,partialContent:Ei(e,o,i),metadata:a}),ki=zod.z.object({promptTokens:zod.z.number().nonnegative(),completionTokens:zod.z.number().nonnegative(),totalTokens:zod.z.number().nonnegative()}),Zt=zod.z.object({token:zod.z.string(),logProb:zod.z.number(),bytes:zod.z.array(zod.z.number().int()).nullable()}),xi=Zt.extend({topLogProbs:zod.z.array(Zt)}),co=zod.z.array(xi);zod.z.object({messages:zod.z.array(Xe()),usage:ki.optional(),logProbs:co.optional()});var vi=zod.z.object({promptTokens:zod.z.number().nonnegative().optional(),completionTokens:zod.z.number().nonnegative().optional(),totalTokens:zod.z.number().nonnegative().optional()});zod.z.object({partialMessages:zod.z.array(Ze()),usage:vi.optional(),logProbs:co.optional()});var ge=(t=zod.z.record(zod.z.string(),zod.z.any()).optional())=>t,Ci=["object","array","number","string","boolean","enum"],Qt=zod.z.enum(Ci),Si=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:zod.z.union([Qt,zod.z.array(zod.z.union([Qt,zod.z.literal("null")]))]).optional(),default:zod.z.any().optional(),title:zod.z.string().optional(),description:zod.z.string().max(4096).optional(),properties:zod.z.record(zod.z.any()).optional(),required:zod.z.array(zod.z.string()).optional(),minItems:zod.z.number().int().min(0).optional(),maxItems:zod.z.number().int().optional(),items:zod.z.record(zod.z.any()).optional(),enum:zod.z.array(zod.z.union([zod.z.string(),zod.z.number(),zod.z.boolean(),zod.z.null()])).optional(),minimum:zod.z.number().optional(),maximum:zod.z.number().optional(),minLength:zod.z.number().int().min(0).optional(),maxLength:zod.z.number().int().optional(),$ref:zod.z.string().optional()}),Oi=zod.z.object({type:zod.z.enum(["object"]),required:zod.z.array(zod.z.string()),$defs:zod.z.record(zod.z.any()).optional(),properties:zod.z.record(Si),additionalProperties:zod.z.literal(!1)}),po=zod.z.object({name:zod.z.string().regex(/^[a-zA-Z0-9_]{1,64}$/).max(64),description:zod.z.string().max(4096),strict:zod.z.boolean().optional(),schema:Oi}).optional(),O="text",uo="token",wi=[O,uo],go=zod.z.enum(wi),Gi=zod.z.array(zod.z.string().min(1)),Ri=zod.z.array(zod.z.array(zod.z.number().int().nonnegative())),Me=(t=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[zod.z.object({modality:zod.z.literal(O),metadata:t,requests:Gi}),zod.z.object({modality:zod.z.literal(uo),metadata:t,requests:Ri})]),he="float",Ii=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.array(zod.z.number())}),ji="base64",Ni=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.string().base64()}),eo=zod.z.object({totalTokens:zod.z.number().int().nonnegative()});zod.z.discriminatedUnion("encodingFormat",[zod.z.object({encodingFormat:zod.z.literal(he),embeddings:zod.z.array(Ii),usage:eo.optional()}),zod.z.object({encodingFormat:zod.z.literal(ji),embeddings:zod.z.array(Ni),usage:eo.optional()})]);var Fi=t=>{let e=new WeakSet;return JSON.stringify(t,(o,i)=>{if(typeof i=="object"&&i!==null){if(e.has(i))return;e.add(i);}return i})},Li=t=>t==null?"unknown error":typeof t=="string"?t:t instanceof Error?t.message:Fi(t),ze="GatewayBaseError",W=class ho extends Error{constructor({info:e,cause:o},i){super(`[${i!=null?i:ze}]: ${e}
5
+ var An=Object.defineProperty,Hn=Object.defineProperties;var zn=Object.getOwnPropertyDescriptors;var Jt=Object.getOwnPropertySymbols;var Vn=Object.prototype.hasOwnProperty,Kn=Object.prototype.propertyIsEnumerable;var He=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Yn=t=>{throw TypeError(t)};var Wt=(t,e,o)=>e in t?An(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,T=(t,e)=>{for(var o in e||(e={}))Vn.call(e,o)&&Wt(t,o,e[o]);if(Jt)for(var o of Jt(e))Kn.call(e,o)&&Wt(t,o,e[o]);return t},x=(t,e)=>Hn(t,zn(e));var Te=(t,e,o)=>new Promise((i,a)=>{var d=l=>{try{m(o.next(l));}catch(c){a(c);}},r=l=>{try{m(o.throw(l));}catch(c){a(c);}},m=l=>l.done?i(l.value):Promise.resolve(l.value).then(d,r);m((o=o.apply(t,e)).next());}),Jn=function(t,e){this[0]=t,this[1]=e;};var Xt=t=>{var e=t[He("asyncIterator")],o=!1,i,a={};return e==null?(e=t[He("iterator")](),i=d=>a[d]=r=>e[d](r)):(e=e.call(t),i=d=>a[d]=r=>{if(o){if(o=!1,d==="throw")throw r;return r}return o=!0,{done:!1,value:new Jn(new Promise(m=>{var l=e[d](r);l instanceof Object||Yn("Object expected"),m(l);}),1)}}),a[He("iterator")]=()=>a,i("next"),"throw"in e?i("throw"):a.throw=d=>{throw d},"return"in e&&i("return"),a};var ue="system",V="user",q="assistant",ee="tool",Wn=[ue,V,q,ee],Ke=zod.z.enum(Wn),Xn=[q],Zn=zod.z.enum(Xn),te="image",Ye="base64",Qn=["png","jpeg","webp","gif"],ei=zod.z.object({type:zod.z.literal(Ye),base64:zod.z.string(),mediaType:zod.z.enum(Qn)}),ti="url",oi=zod.z.object({type:zod.z.literal(ti),url:zod.z.string()}),ni=zod.z.discriminatedUnion("type",[ei,oi]),ii=["low","medium","high","auto"],ai=zod.z.enum(ii),si=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(te),detail:ai,value:ni,metadata:t}),se="pdf",ri="base64",li=zod.z.object({type:zod.z.literal(ri),base64:zod.z.string()}),mi="url",di=zod.z.object({type:zod.z.literal(mi),url:zod.z.string()}),ci=zod.z.discriminatedUnion("type",[li,di]),pi=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(se),value:ci,providerCacheKey:zod.z.string(),metadata:t}),to="reasoning",oo="partial-reasoning",no="thinking",ui="redacted",Ve=zod.z.object({type:zod.z.literal(no),thinking:zod.z.string(),signature:zod.z.string()}),io=zod.z.object({type:zod.z.literal(ui),data:zod.z.string()}),gi=zod.z.discriminatedUnion("type",[Ve,io]),hi=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(to),value:gi,metadata:t}),fi=zod.z.object({type:zod.z.literal(no),thinking:Ve.shape.thinking.optional(),signature:Ve.shape.signature.optional()}),yi=zod.z.discriminatedUnion("type",[fi,io]),bi=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(oo),value:yi,metadata:t}),S="text",ao=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(S),value:zod.z.string(),metadata:t}),Je="partial-text",so=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Je),value:zod.z.string(),metadata:t}),A="tool-call",ro=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(A),index:zod.z.number().int().nonnegative(),id:zod.z.string().min(1),name:zod.z.string().min(1),arguments:zod.z.string(),metadata:t}),We="partial-tool-call",lo=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(We),index:zod.z.number().int().nonnegative(),id:zod.z.string().optional(),name:zod.z.string().optional(),arguments:zod.z.string().optional(),metadata:t}),oe="tool-response",Ti=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(oe),index:zod.z.number().int().nonnegative(),id:zod.z.string().min(1),name:zod.z.string().min(1),data:zod.z.string(),apiResponse:zod.z.object({statusCode:zod.z.number().int().nonnegative()}).optional(),metadata:t}),Mi=[S,te,se,A,oe,to],mo=zod.z.enum(Mi),_i=(t=zod.z.undefined(),e=zod.z.undefined(),o=zod.z.undefined(),i=zod.z.undefined(),a=zod.z.undefined(),d=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[ao(t),si(e),pi(o),ro(i),Ti(a),hi(d)]),Pi=[Je,We,oo];zod.z.enum(Pi);var Ei=(t=zod.z.undefined(),e=zod.z.undefined(),o=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[so(t),lo(e),bi(o)]);var Xe=(t=Ke,e=zod.z.undefined(),o=zod.z.undefined(),i=zod.z.undefined(),a=zod.z.undefined(),d=zod.z.undefined(),r=zod.z.undefined(),m=zod.z.undefined())=>zod.z.object({role:t,content:zod.z.array(_i(e,o,i,a,r,d)),metadata:m}),Ze=(t=Zn,e=zod.z.undefined(),o=zod.z.undefined(),i=zod.z.undefined(),a=zod.z.undefined())=>zod.z.object({role:t,partialContent:Ei(e,o,i),metadata:a}),ki=zod.z.object({promptTokens:zod.z.number().nonnegative(),completionTokens:zod.z.number().nonnegative(),totalTokens:zod.z.number().nonnegative()}),Zt=zod.z.object({token:zod.z.string(),logProb:zod.z.number(),bytes:zod.z.array(zod.z.number().int()).nullable()}),xi=Zt.extend({topLogProbs:zod.z.array(Zt)}),co=zod.z.array(xi);zod.z.object({messages:zod.z.array(Xe()),usage:ki.optional(),logProbs:co.optional()});var vi=zod.z.object({promptTokens:zod.z.number().nonnegative().optional(),completionTokens:zod.z.number().nonnegative().optional(),totalTokens:zod.z.number().nonnegative().optional()});zod.z.object({partialMessages:zod.z.array(Ze()),usage:vi.optional(),logProbs:co.optional()});var ge=(t=zod.z.record(zod.z.string(),zod.z.any()).optional())=>t,Ci=["object","array","number","string","boolean","enum"],Qt=zod.z.enum(Ci),Si=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:zod.z.union([Qt,zod.z.array(zod.z.union([Qt,zod.z.literal("null")]))]).optional(),default:zod.z.any().optional(),title:zod.z.string().optional(),description:zod.z.string().max(4096).optional(),properties:zod.z.record(zod.z.any()).optional(),required:zod.z.array(zod.z.string()).optional(),minItems:zod.z.number().int().min(0).optional(),maxItems:zod.z.number().int().optional(),items:zod.z.record(zod.z.any()).optional(),enum:zod.z.array(zod.z.union([zod.z.string(),zod.z.number(),zod.z.boolean(),zod.z.null()])).optional(),minimum:zod.z.number().optional(),maximum:zod.z.number().optional(),minLength:zod.z.number().int().min(0).optional(),maxLength:zod.z.number().int().optional(),$ref:zod.z.string().optional()}),Oi=zod.z.object({type:zod.z.enum(["object"]),required:zod.z.array(zod.z.string()),$defs:zod.z.record(zod.z.any()).optional(),properties:zod.z.record(Si),additionalProperties:zod.z.literal(!1)}),po=zod.z.object({name:zod.z.string().regex(/^[a-zA-Z0-9_]{1,64}$/).max(64),description:zod.z.string().max(4096),strict:zod.z.boolean().optional(),schema:Oi}).optional(),O="text",uo="token",wi=[O,uo],go=zod.z.enum(wi),Gi=zod.z.array(zod.z.string().min(1)),Ri=zod.z.array(zod.z.array(zod.z.number().int().nonnegative())),Me=(t=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[zod.z.object({modality:zod.z.literal(O),metadata:t,requests:Gi}),zod.z.object({modality:zod.z.literal(uo),metadata:t,requests:Ri})]),he="float",Ii=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.array(zod.z.number())}),ji="base64",Ni=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.string().base64()}),eo=zod.z.object({totalTokens:zod.z.number().int().nonnegative()});zod.z.discriminatedUnion("encodingFormat",[zod.z.object({encodingFormat:zod.z.literal(he),embeddings:zod.z.array(Ii),usage:eo.optional()}),zod.z.object({encodingFormat:zod.z.literal(ji),embeddings:zod.z.array(Ni),usage:eo.optional()})]);var Fi=t=>{let e=new WeakSet;return JSON.stringify(t,(o,i)=>{if(typeof i=="object"&&i!==null){if(e.has(i))return;e.add(i);}return i})},Li=t=>t==null?"unknown error":typeof t=="string"?t:t instanceof Error?t.message:Fi(t),ze="GatewayBaseError",W=class ho extends Error{constructor({info:e,cause:o},i){super(`[${i!=null?i:ze}]: ${e}
6
6
  Message: ${Li(o)}`),this.name=ze,this.info=e,this.cause=o,this.name=i!=null?i:ze,Object.setPrototypeOf(this,new.target.prototype);}static isGatewayBaseError(e){return e instanceof ho}toJSON(){return {name:this.name,info:this.info,cause:this.cause,message:this.message,stack:this.stack}}},Ui=zod.z.object({inputPricePerMillion:zod.z.number().nonnegative().describe("Price per 1M input tokens"),outputPricePerMillion:zod.z.number().nonnegative().describe("Price per 1M output tokens")}).describe("Input/output price pair (per 1M tokens) for a specific category within a ChatModel pricing tier."),$i=zod.z.object({base:Ui.describe("Base (uncached, non\u2011reasoning) rates")}).describe("Holds the `ChatModelTokenPairPrice` for different categories (e.g., base) within a single pricing tier."),Di=zod.z.object({minTokens:zod.z.number().int().nonnegative().describe("Inclusive lower token bound for this tier."),maxTokens:zod.z.number().int().nullable().optional().describe("Exclusive upper token bound; `null` means \u221E."),prices:$i.describe("Price categories and rates for this specific token range.")}).refine(t=>t.maxTokens===null||typeof t.maxTokens=="number"&&t.maxTokens>t.minTokens,{message:"maxTokens must be > minTokens (or null for infinite).",path:["maxTokens"]}).describe("A single pricing tier defined by a token range and associated prices.");zod.z.object({modelName:zod.z.string().describe("Model name this schedule applies to."),currency:zod.z.string().default("USD").describe("Currency code (e.g., USD)."),tokenRanges:zod.z.array(Di).min(1).describe("Pricing tiers (`ChatModelTokenRangePrice`) schedule, sorted by minTokens.")}).superRefine((t,e)=>{let{tokenRanges:o}=t;o[0].minTokens!==0&&e.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",0,"minTokens"],message:"The first tier must have minTokens = 0."});for(let a=1;a<o.length;a++){let d=o[a-1],r=o[a];if(d.maxTokens===null){e.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",a-1,"maxTokens"],message:"Cannot define any tokenRanges after an infinite tier (maxTokens = null)."});break}r.minTokens!==d.maxTokens&&e.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",a,"minTokens"],message:`Tier ${a} minTokens (${r.minTokens}) must equal previous tier's maxTokens (${d.maxTokens}) for contiguity.`}),r.minTokens<d.minTokens&&e.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",a,"minTokens"],message:`tokenRanges must be sorted by ascending minTokens. Tier ${a} (${r.minTokens}) starts before Tier ${a-1} (${d.minTokens}).`});}let i=o[o.length-1];o.every(a=>a.maxTokens!==null||a===i)&&i.maxTokens!==null&&e.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",o.length-1,"maxTokens"],message:"The final tier must have maxTokens = null (representing infinity)."});}).describe("Complete pricing schedule for a single chat model, including all its token-based tiers.");var qi="function";var Bi=zod.z.enum(["object","array","number","string","boolean","null"]),Ai=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:Bi.optional(),default:zod.z.any().optional(),title:zod.z.string().optional(),description:zod.z.string().max(4096).optional(),properties:zod.z.record(zod.z.any()).optional(),required:zod.z.array(zod.z.string()).optional(),minItems:zod.z.number().int().min(0).optional(),maxItems:zod.z.number().int().optional(),items:zod.z.record(zod.z.any()).optional(),enum:zod.z.array(zod.z.union([zod.z.string(),zod.z.number(),zod.z.boolean(),zod.z.null()])).optional(),minimum:zod.z.number().optional(),maximum:zod.z.number().optional(),minLength:zod.z.number().int().min(0).optional(),maxLength:zod.z.number().int().optional()});zod.z.object({type:zod.z.enum(["object"]),title:zod.z.string().optional(),$defs:zod.z.record(zod.z.any()).optional(),properties:zod.z.record(Ai).optional(),required:zod.z.array(zod.z.string()).optional()});var Hi=zod.z.object({name:zod.z.string().regex(/^[a-zA-Z0-9_]{1,64}$/).max(64),description:zod.z.string().max(4096),parameters:zod.z.any(),strict:zod.z.boolean().optional()});var zi=zod.z.enum(["function"]),Vi=zod.z.object({maxAttempts:zod.z.number().int().positive(),initialDelay:zod.z.number().int().positive(),exponentialFactor:zod.z.number().int().positive()}),Ki=zod.z.object({type:zod.z.literal("http"),method:zod.z.enum(["get","post"]),url:zod.z.string().url(),headers:zod.z.record(zod.z.string()).optional(),query:zod.z.record(zod.z.string()).optional(),body:zod.z.record(zod.z.any()).optional(),proxyUrl:zod.z.string().url().optional(),proxyHeaders:zod.z.record(zod.z.string()).optional(),retry:Vi.optional()}),Yi=zod.z.discriminatedUnion("type",[Ki]),Ji=zod.z.object({type:zi,definition:zod.z.object({schema:Hi}),request:Yi.optional()}),Wi=[qi];zod.z.enum(Wi);var fo=(t=zod.z.undefined())=>zod.z.discriminatedUnion("type",[Ji.extend({metadata:t})]),yo=t=>ao().parse({modality:S,value:t}),bo=(t,e,o,i)=>ro().parse({modality:A,index:t,id:e,name:o,arguments:i});var Qe=(t,e)=>Ze().parse({role:t,partialContent:so().parse({modality:Je,value:e})}),et=(t,e,o,i,a)=>Ze().parse({role:t,partialContent:lo().parse({modality:We,index:e,id:o,name:i,arguments:a})});var Xi=Object.defineProperty,To=Object.getOwnPropertySymbols,Zi=Object.prototype.hasOwnProperty,Qi=Object.prototype.propertyIsEnumerable,Mo=(t,e,o)=>e in t?Xi(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,fe=(t,e)=>{for(var o in e||(e={}))Zi.call(e,o)&&Mo(t,o,e[o]);if(To)for(var o of To(e))Qi.call(e,o)&&Mo(t,o,e[o]);return t},_o="ProviderError",de=class Oo extends W{constructor({info:e,cause:o}){super({info:e,cause:o},_o),this.name=_o,this.info=e,this.cause=o;}static isProviderError(e){return e instanceof Oo}},Po="ModelError",_e=class wo extends W{constructor({info:e,cause:o}){super({info:e,cause:o},Po),this.name=Po,this.info=e,this.cause=o;}static isModelError(e){return e instanceof wo}},Eo="ModelResponseError",I=class Go extends W{constructor({info:e,cause:o}){super({info:e,cause:o},Eo),this.name=Eo,this.cause=o,this.info=e;}static isModelResponseError(e){return e instanceof Go}},ko="InvalidModelRequestError",X=class Ro extends W{constructor({info:e,cause:o}){super({info:e,cause:o},ko),this.name=ko,this.cause=o,this.info=e,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidModelRequestError(e){return e instanceof Ro}},xo="InvalidConfigError",H=class Io extends W{constructor({info:e,cause:o}){super({info:e,cause:o},xo),this.name=xo,this.cause=o,this.info=e,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidConfigError(e){return e instanceof Io}},vo="InvalidMessagesError",b=class jo extends W{constructor({info:e,cause:o}){super({info:e,cause:o},vo),this.name=vo,this.cause=o,this.info=e,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidMessagesError(e){return e instanceof jo}},Co="InvalidToolsError",tt=class No extends W{constructor({info:e,cause:o}){super({info:e,cause:o},Co),this.name=Co,this.cause=o,this.info=e,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidToolsError(e){return e instanceof No}},So="InvalidEmbeddingRequestsError",ne=class Fo extends W{constructor({info:e,cause:o}){super({info:e,cause:o},So),this.name=So,this.info=e,this.cause=o,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidEmbeddingRequestsError(e){return e instanceof Fo}},ot="multi-string",Lo=zod.z.object({type:zod.z.literal(ot),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),max:zod.z.number().int().positive()}),ea=t=>zod.z.array(zod.z.string()).max(t).default([]).optional(),Uo=t=>({def:Lo.parse(fe({type:ot},t)),schema:ea(t.max)}),nt="object-schema",$o=zod.z.object({type:zod.z.literal(nt),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),objectSchema:zod.z.any()}),ta=t=>t.optional(),it=t=>({def:$o.parse(fe({type:nt},t)),schema:ta(t.objectSchema)}),at="range",Do=zod.z.object({type:zod.z.literal(at),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),min:zod.z.number().int(),max:zod.z.number().int(),step:zod.z.number().positive(),default:zod.z.number()}),oa=(t,e,o,i)=>zod.z.number().min(t).max(e).step(o).default(i).optional(),K=t=>({def:Do.parse(fe({type:at},t)),schema:oa(t.min,t.max,t.step,t.default)}),st="select-boolean",qo=zod.z.object({type:zod.z.literal(st),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),default:zod.z.boolean().nullable()}),na=t=>zod.z.boolean().nullable().default(t).optional(),Pe=t=>({def:qo.parse(fe({type:st},t)),schema:na(t.default)}),rt="select-string",Bo=zod.z.object({type:zod.z.literal(rt),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),default:zod.z.string(),choices:zod.z.array(zod.z.string())}),ia=(t,e)=>zod.z.enum(e).nullable().default(t).optional(),lt=t=>({def:Bo.parse(fe({type:rt},t)),schema:ia(t.default,t.choices)}),aa=[at,ot,rt,nt,st];zod.z.enum(aa);var Ao=zod.z.discriminatedUnion("type",[Do,Lo,Bo,qo,$o]),j=(t=Ke,e=mo)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),roles:zod.z.record(t,zod.z.string().min(1).optional()),modalities:zod.z.array(e).nonempty(),maxInputTokens:zod.z.number().int().positive().min(1),maxOutputTokens:zod.z.number().int().positive().min(1),maxReasoningTokens:zod.z.number().int().positive().min(1).optional(),config:zod.z.object({def:zod.z.record(zod.z.string().min(1),Ao),schema:zod.z.instanceof(zod.z.ZodObject)}).refine(o=>{var i,a;let d=Object.keys(o.def),r=Object.keys((a=(i=o.schema)==null?void 0:i.shape)!=null?a:{});return d.every(m=>r.includes(m))&&r.every(m=>d.includes(m))},{message:"Keys in 'config.def' must exactly match keys in 'config.schema'"}),price:zod.z.custom()}),z=(t=go)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),modalities:zod.z.array(t).nonempty(),maxInputTokens:zod.z.number().int().positive().min(1),maxOutputTokens:zod.z.number().int().positive().min(1),config:zod.z.object({def:zod.z.record(zod.z.string().min(1),Ao),schema:zod.z.instanceof(zod.z.ZodObject)}).refine(e=>{var o,i;let a=Object.keys(e.def),d=Object.keys((i=(o=e.schema)==null?void 0:o.shape)!=null?i:{});return a.every(r=>d.includes(r))&&d.every(r=>a.includes(r))},{message:"Keys in 'config.def' must exactly match keys in 'config.schema'"})});zod.z.record(zod.z.string());zod.z.record(zod.z.union([zod.z.boolean(),zod.z.string(),zod.z.number(),zod.z.object({}),zod.z.array(zod.z.any()),zod.z.null(),zod.z.undefined()]));zod.z.string().url();var sa={type:"range",title:"Temperature",description:"Adjusts the model's creativity level. With a setting of 0, the model strictly picks the most probable next word. For endeavors that benefit from a dash of inventiveness, consider dialing it up to 0.7 or higher, enabling the model to produce text that's unexpectedly fresh."},ra={type:"range",title:"Max tokens",description:"Specify the total tokens for generation, where one token approximates four English characters. Setting this to 0 defaults to the model's maximum capacity."},la={type:"range",title:"Max reasoning tokens",description:"Specify the total tokens for reasoning, where one token approximates four English characters."},ma=t=>({type:"multi",title:"Stop sequence",description:`Enter up to ${t} sequences that will halt additional text output. The generated text will exclude these sequences.`}),da={type:"range",title:"Top A",description:"Considers only the top tokens that have 'sufficiently high' probabilities relative to the most likely token, functioning like a dynamic Top-P. A lower Top-A value narrows down the token choices based on the highest probability token, while a higher Top-A value refines the filtering without necessarily impacting the creativity of the output."},ca={type:"range",title:"Top P",description:"Selects a subset of likely tokens for generation, restricting choices to the top-P fraction of possibilities, such as the top 10% when P=0.1. This approach can limit the variety of the output. By default, it's set to 1, indicating no restriction. It's advised to adjust this parameter or temperature to modulate output diversity, but not to modify both simultaneously."},pa={type:"range",title:"Top K",description:"Select only from the highest K probabilities for each following word, effectively eliminating the less likely 'long tail' options."},ua={type:"range",title:"Min P",description:"Specifies the minimum probability a token must have to be considered, in relation to the probability of the most likely token. (This value varies based on the confidence level of the top token.) For example, if Min-P is set to 0.1, only tokens with at least 1/10th the probability of the highest-ranked token will be considered."},ga={type:"range",title:"Frequency penalty",description:"Minimize redundancy. By assigning a penalty to frequently used tokens within the text, the likelihood of repeating identical phrases is reduced. The default setting for this penalty is zero."},ha={type:"range",title:"Presence penalty",description:"Enhance the introduction of novel subjects by reducing the preference for tokens that have already appeared in the text, thus boosting the chances of exploring fresh topics. The standard setting for this is zero."},fa={type:"range",title:"Seed",description:"When seed is fixed to a specific value, the model makes a best effort to provide the same response for repeated requests. Deterministic output isn't guaranteed. Also, changing the model or parameter settings, such as the temperature, can cause variations in the response even when you use the same seed value. By default, a random seed value is used."},ya={type:"range",title:"Repetition penalty",description:"Reduces the likelihood of repeating tokens from the input. Increasing this value makes the model less prone to repetition, but setting it too high may lead to less coherent output, often resulting in run-on sentences missing smaller words. The token penalty is scaled according to the original token's probability."},ba={type:"boolean",title:"Log probs",description:"Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned."},Ta={type:"range",title:"Top log probs",description:"The number of most likely tokens to return at each token position, each with an associated log probability. 'logprobs' must be set to true if this parameter is used."},Ma={type:"boolean",title:"Echo",description:"If true, the response will contain the prompt."},_a={type:"select",title:"Response format",description:"Choose the response format of your model. For JSON, you must include the string 'JSON' in some form within your system / user prompt."},Pa={type:"select",title:"Response format",description:"Choose the response format of your model. 'json_object' colloquially known as JSON mode, instructs the model to respond with a valid JSON (must include the term 'json' in prompt). 'json_schema' colloquially known as structured outputs, allows you to specify a strict response schema that the model will adhere to."},Ea={type:"object",title:"Response schema",description:"When response format is set to 'json_schema', the model will return a JSON object of the specified schema."},_={TEMPERATURE:sa,MAX_TOKENS:ra,STOP:ma,TOP_A:da,TOP_P:ca,TOP_K:pa,MIN_P:ua,FREQUENCY_PENALTY:ga,PRESENCE_PENALTY:ha,REPETITION_PENALTY:ya,SEED:fa,LOG_PROBS:ba,TOP_LOG_PROBS:Ta,ECHO:Ma,RESPONSE_FORMAT:_a,RESPONSE_FORMAT_WITH_SCHEMA:Pa,RESPONSE_SCHEMA:Ea,MAX_REASONING_TOKENS:la},ka={type:"range",title:"Dimensions",description:"Select the number of dimensions for the word embedding."},xa={type:"select",title:"Encoding format",description:"Select the encoding format for the word embedding."},ce={DIMENSIONS:ka,ENCODING_FORMAT:xa};var ye=t=>Object.fromEntries(Object.entries(t).filter(([e,o])=>o!=null));var pe=t=>t==null?void 0:t.replace(/\/$/,"");var va=Object.defineProperty,Ca=Object.defineProperties,Sa=Object.getOwnPropertyDescriptors,Ho=Object.getOwnPropertySymbols,Oa=Object.prototype.hasOwnProperty,wa=Object.prototype.propertyIsEnumerable,Ee=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Ga=t=>{throw TypeError(t)},zo=(t,e,o)=>e in t?va(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,M=(t,e)=>{for(var o in e||(e={}))Oa.call(e,o)&&zo(t,o,e[o]);if(Ho)for(var o of Ho(e))wa.call(e,o)&&zo(t,o,e[o]);return t},be=(t,e)=>Ca(t,Sa(e)),P=(t,e,o)=>new Promise((i,a)=>{var d=l=>{try{m(o.next(l));}catch(c){a(c);}},r=l=>{try{m(o.throw(l));}catch(c){a(c);}},m=l=>l.done?i(l.value):Promise.resolve(l.value).then(d,r);m((o=o.apply(t,e)).next());}),Zo=function(t,e){this[0]=t,this[1]=e;},Vo=(t,e,o)=>{var i=(r,m,l,c)=>{try{var u=o[r](m),g=(m=u.value)instanceof Zo,h=u.done;Promise.resolve(g?m[0]:m).then(y=>g?i(r==="return"?r:"next",m[1]?{done:y.done,value:y.value}:y,l,c):l({value:y,done:h})).catch(y=>i("throw",y,l,c));}catch(y){c(y);}},a=r=>d[r]=m=>new Promise((l,c)=>i(r,m,l,c)),d={};return o=o.apply(t,e),d[Ee("asyncIterator")]=()=>d,a("next"),a("throw"),a("return"),d},Ra=t=>{var e=t[Ee("asyncIterator")],o=!1,i,a={};return e==null?(e=t[Ee("iterator")](),i=d=>a[d]=r=>e[d](r)):(e=e.call(t),i=d=>a[d]=r=>{if(o){if(o=!1,d==="throw")throw r;return r}return o=!0,{done:!1,value:new Zo(new Promise(m=>{var l=e[d](r);l instanceof Object||Ga("Object expected"),m(l);}),1)}}),a[Ee("iterator")]=()=>a,i("next"),"throw"in e?i("throw"):a.throw=d=>{throw d},"return"in e&&i("return"),a},Qo=(t,e)=>K({param:"temperature",title:_.TEMPERATURE.title,description:_.TEMPERATURE.description,min:0,max:t,step:.01,default:e}),en=t=>K({param:"maxOutputTokens",title:_.MAX_TOKENS.title,description:_.MAX_TOKENS.description,min:0,max:t,step:1,default:0}),tn=t=>Uo({param:"stopSequences",title:_.STOP(t).title,description:_.STOP(t).description,max:t}),on=t=>K({param:"topP",title:_.TOP_P.title,description:_.TOP_P.description,min:0,max:1,step:.01,default:t});K({param:"frequencyPenalty",title:_.FREQUENCY_PENALTY.title,description:_.FREQUENCY_PENALTY.description,min:-2,max:2,step:.01,default:0});K({param:"presencePenalty",title:_.PRESENCE_PENALTY.title,description:_.PRESENCE_PENALTY.description,min:-2,max:2,step:.01,default:0});K({param:"seed",title:_.SEED.title,description:_.SEED.description,min:0,max:1e6,step:1,default:0});var nn=lt({param:"toolChoice",title:"Tool choice",description:"Controls which (if any) tool is called by the model. 'none' means the model will not call a function. 'auto' means the model can pick between generating a message or calling a tool.",default:"auto",choices:["auto","any","none"]}),an=it({param:"safetySettings",title:"Safety settings",description:"The safety rating contains the category of harm and the harm probability level in that category for a piece of content.",objectSchema:zod.z.array(zod.z.object({threshold:zod.z.enum(["HARM_BLOCK_THRESHOLD_UNSPECIFIED","BLOCK_LOW_AND_ABOVE","BLOCK_MEDIUM_AND_ABOVE","BLOCK_ONLY_HIGH","BLOCK_NONE","OFF"]),category:zod.z.enum(["HARM_CATEGORY_UNSPECIFIED","HARM_CATEGORY_HARASSMENT","HARM_CATEGORY_HATE_SPEECH","HARM_CATEGORY_SEXUALLY_EXPLICIT","HARM_CATEGORY_DANGEROUS_CONTENT","HARM_CATEGORY_CIVIC_INTEGRITY"])}))}),sn=Pe({param:"reasoningEnabled",title:"Reasoning Enabled",description:"Controls whether the model is allowed to think for a longer period of time before generating a response. This can be useful for complex tasks that require more time to think.",default:!1}),rn=(t,e,o,i,a)=>zod.z.object({temperature:Qo(t,e).schema,maxTokens:en(o).schema,stop:tn(i).schema,topP:on(a).schema,toolChoice:nn.schema,safetySettings:an.schema}),ln=(t,e,o,i,a)=>({temperature:Qo(t,e).def,maxTokens:en(o).def,stop:tn(i).def,topP:on(a).def,toolChoice:nn.def,safetySettings:an.def}),mn=it({param:"response_schema",title:_.RESPONSE_SCHEMA.title,description:_.RESPONSE_SCHEMA.description,objectSchema:po}),dn=lt({param:"response_format",title:_.RESPONSE_FORMAT_WITH_SCHEMA.title,description:_.RESPONSE_FORMAT_WITH_SCHEMA.description,default:"text",choices:["text","json_schema"]}),cn=(t,e,o,i,a)=>be(M({},ln(t,e,o,i,a)),{responseFormat:dn.def,responseSchema:mn.def}),pn=(t,e,o,i,a)=>rn(t,e,o,i,a).extend({responseFormat:dn.schema,responseSchema:mn.schema}),Ia=(t,e,o,i,a)=>pn(t,e,o,i,a).extend({reasoningEnabled:sn.schema}),ja=(t,e,o,i,a)=>be(M({},cn(t,e,o,i,a)),{reasoningEnabled:sn.def}),un=t=>K({param:"outputDimensionality",title:ce.DIMENSIONS.title,description:ce.DIMENSIONS.description,min:1,max:t,step:1,default:t}),Na=t=>zod.z.object({dimensions:un(t).schema}),Fa=t=>({dimensions:un(t).def}),f={base:(t,e,o,i,a)=>({def:ln(t,e,o,i,a),schema:rn(t,e,o,i,a)}),responseSchema:(t,e,o,i,a)=>({def:cn(t,e,o,i,a),schema:pn(t,e,o,i,a)}),reasoning:(t,e,o,i,a)=>({def:ja(t,e,o,i,a),schema:Ia(t,e,o,i,a)})},ke={base:t=>({def:Fa(t),schema:Na(t)})},La="google",Pt=class{constructor(){this.version="v1",this.name=La,this.chatModelFactories={[mt]:{model:es,modelOptions:Qa,modelSchema:xe},[dt]:{model:ns,modelOptions:os,modelSchema:ve},[ct]:{model:ss,modelOptions:as,modelSchema:hn},[pt]:{model:ms,modelOptions:ls,modelSchema:Ce},[ut]:{model:ps,modelOptions:cs,modelSchema:Se},[gt]:{model:hs,modelOptions:gs,modelSchema:Oe},[ht]:{model:bs,modelOptions:ys,modelSchema:fn},[ft]:{model:_s,modelOptions:Ms,modelSchema:we},[yt]:{model:ks,modelOptions:Es,modelSchema:Ge},[bt]:{model:Cs,modelOptions:vs,modelSchema:yn},[Tt]:{model:ws,modelOptions:Os,modelSchema:bn},[Mt]:{model:Is,modelOptions:Rs,modelSchema:Tn},[_t]:{model:Fs,modelOptions:Ns,modelSchema:Mn}},this.embeddingModelFactories={[kn]:{model:Bs,modelOptions:qs,modelSchema:xn},[vn]:{model:zs,modelOptions:Hs,modelSchema:Cn}};}chatModelLiterals(){return Object.keys(this.chatModelFactories)}chatModelSchemas(){return Object.keys(this.chatModelFactories).reduce((t,e)=>(t[e]=this.chatModelFactories[e].modelSchema,t),{})}chatModel(t){let e=t.modelName;if(!(e in this.chatModelFactories))throw new de({info:`Google chat model: ${e} not found`,cause:new Error(`Google chat model: ${e} not found, available chat models:
7
7
  [${this.chatModelLiterals().join(", ")}]`)});let o=this.chatModelFactories[e].model,i=this.chatModelFactories[e].modelOptions.parse(t);return new o(i)}embeddingModelLiterals(){return Object.keys(this.embeddingModelFactories)}embeddingModelSchemas(){return Object.keys(this.embeddingModelFactories).reduce((t,e)=>(t[e]=this.embeddingModelFactories[e].modelSchema,t),{})}embeddingModel(t){let e=t.modelName;if(!(e in this.embeddingModelFactories))throw new de({info:`Google embedding model: ${e} not found`,cause:new Error(`Google embedding model: ${e} not found, available embedding models:
8
8
  [${this.embeddingModelLiterals().join(", ")}]`)});let o=this.embeddingModelFactories[e].model,i=this.embeddingModelFactories[e].modelOptions.parse(t);return new o(i)}};Pt.baseUrl="https://generativelanguage.googleapis.com/v1beta";var w={"base-gemini-1-chat-model":{modelName:"base-gemini-1-chat-model",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:0,outputPricePerMillion:0}}}]},"gemini-1.0-pro-001":{modelName:"gemini-1.0-pro-001",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-1.0-pro-latest":{modelName:"gemini-1.0-pro-latest",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-1.0-pro-vision":{modelName:"gemini-1.0-pro-vision",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-1.0-pro":{modelName:"gemini-1.0-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-1.5-flash-001":{modelName:"gemini-1.5-flash-001",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.15,outputPricePerMillion:.6}}}]},"gemini-1.5-flash-002":{modelName:"gemini-1.5-flash-002",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.0375,outputPricePerMillion:.15}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}}]},"gemini-1.5-flash-latest":{modelName:"gemini-1.5-flash-latest",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.15,outputPricePerMillion:.6}}}]},"gemini-1.5-flash":{modelName:"gemini-1.5-flash",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.15,outputPricePerMillion:.6}}}]},"gemini-1.5-pro-001":{modelName:"gemini-1.5-pro-001",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:5}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gemini-1.5-pro-002":{modelName:"gemini-1.5-pro-002",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:5}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gemini-1.5-pro-latest":{modelName:"gemini-1.5-pro-latest",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:5}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gemini-1.5-pro":{modelName:"gemini-1.5-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:5}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gemini-2.0-flash-exp":{modelName:"gemini-2.0-flash-exp",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.4}}}]},"gemini-2.5-flash-preview-04-17":{modelName:"gemini-2.5-flash-preview-04-17",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.15,outputPricePerMillion:.6}}}]},"gemini-2.5-pro-preview-03-25":{modelName:"gemini-2.5-pro-preview-03-25",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:2e5,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:10}}},{minTokens:200001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:15}}}]},"gemini-pro-vision":{modelName:"gemini-pro-vision",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-pro":{modelName:"gemini-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-2.5-pro":{modelName:"gemini-2.5-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:10}}}]},"gemini-2.5-flash":{modelName:"gemini-2.5-flash",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.3,outputPricePerMillion:2.5}}}]}},F=zod.z.enum([ue,V,q,ee]),Ua="model",$a="function",L={system:V,user:V,assistant:Ua,tool:$a},U=[S,te,se,A,oe],$=zod.z.enum([S,te,se,A,oe]);zod.z.enum([S]);zod.z.enum([S,te]);zod.z.enum([S,A,oe]);var Da=zod.z.object({text:zod.z.string()}),qa=zod.z.object({functionCall:zod.z.object({name:zod.z.string(),args:zod.z.record(zod.z.any())})}),Ba=zod.z.object({candidates:zod.z.array(zod.z.object({content:zod.z.object({role:zod.z.string(),parts:zod.z.array(zod.z.union([Da,qa]))}).optional(),finishReason:zod.z.string(),index:zod.z.number().optional(),safetyRatings:zod.z.optional(zod.z.array(zod.z.object({category:zod.z.string(),probability:zod.z.string(),blocked:zod.z.boolean().optional()})))})),promptFeedback:zod.z.optional(zod.z.object({safetyRatings:zod.z.optional(zod.z.array(zod.z.object({category:zod.z.string(),probability:zod.z.string()})))})),usageMetadata:zod.z.object({promptTokenCount:zod.z.number(),cachedContentTokenCount:zod.z.number().optional(),candidatesTokenCount:zod.z.number().optional(),totalTokenCount:zod.z.number()}).optional()}),Aa=zod.z.object({text:zod.z.string()}),Ha=zod.z.object({functionCall:zod.z.object({name:zod.z.string(),args:zod.z.record(zod.z.any())})}),Ko=zod.z.object({candidates:zod.z.array(zod.z.object({content:zod.z.object({role:zod.z.string(),parts:zod.z.array(zod.z.union([Aa,Ha]))}).optional(),finishReason:zod.z.string().optional(),index:zod.z.number().optional(),safetyRatings:zod.z.optional(zod.z.array(zod.z.object({category:zod.z.string(),probability:zod.z.string(),blocked:zod.z.boolean().optional()})))})),promptFeedback:zod.z.optional(zod.z.object({safetyRatings:zod.z.optional(zod.z.array(zod.z.object({category:zod.z.string(),probability:zod.z.string()})))})),usageMetadata:zod.z.object({promptTokenCount:zod.z.number().optional(),cachedContentTokenCount:zod.z.number().optional(),candidatesTokenCount:zod.z.number().optional(),totalTokenCount:zod.z.number().optional()}).optional()}),gn=zod.z.object({text:zod.z.string().min(1)}),za=zod.z.object({inline_data:zod.z.object({mime_type:zod.z.string().min(1),data:zod.z.string().base64()})}),Va=zod.z.object({file_data:zod.z.object({mime_type:zod.z.string().min(1),file_uri:zod.z.string().min(1)})}),Ka=zod.z.object({function_call:zod.z.object({name:zod.z.string().min(1),args:zod.z.record(zod.z.string().min(1))})}),Ya=zod.z.object({function_response:zod.z.object({name:zod.z.string().min(1),response:zod.z.record(zod.z.string().min(1))})}),Ja=zod.z.object({role:zod.z.enum(["user","model","function"]),parts:zod.z.array(zod.z.union([gn,za,Va,Ka,Ya]))}),Yo=zod.z.object({parts:zod.z.array(gn)}),Wa=zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),parameters:zod.z.any()}),Jo=zod.z.object({function_calling_config:zod.z.object({mode:zod.z.enum(["ANY","AUTO","NONE"]),allowed_function_names:zod.z.array(zod.z.string()).optional()})}),Wo=zod.z.object({stopSequences:zod.z.array(zod.z.string()).optional(),maxOutputTokens:zod.z.number().optional(),temperature:zod.z.number().optional(),topP:zod.z.number().optional(),topK:zod.z.number().optional(),presencePenalty:zod.z.number().optional(),frequencyPenalty:zod.z.number().optional(),seed:zod.z.number().optional()}),Xo=zod.z.object({category:zod.z.enum(["HARM_CATEGORY_HARASSMENT","HARM_CATEGORY_HATE_SPEECH","HARM_CATEGORY_SEXUALLY_EXPLICIT","HARM_CATEGORY_DANGEROUS_CONTENT","HARM_CATEGORY_CIVIC_INTEGRITY"]),threshold:zod.z.enum(["HARM_BLOCK_THRESHOLD_UNSPECIFIED","BLOCK_LOW_AND_ABOVE","BLOCK_MEDIUM_AND_ABOVE","BLOCK_ONLY_HIGH","BLOCK_NONE","OFF"])}),Xa=zod.z.object({model:zod.z.string().min(1).optional(),contents:zod.z.array(Ja),systemInstruction:Yo.optional(),system_instruction:Yo.optional(),generationConfig:Wo.optional(),generation_config:Wo.optional(),safetySettings:zod.z.array(Xo).optional(),safety_settings:zod.z.array(Xo).optional(),tools:zod.z.object({function_declarations:zod.z.array(Wa)}).optional(),toolConfig:Jo.optional(),tool_config:Jo.optional()}),N=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string(),baseUrl:zod.z.string().url().optional(),completeChatUrl:zod.z.string().url().optional(),streamChatUrl:zod.z.string().url().optional()}),G=class{constructor(t,e){this.version="v1";var o;let i=N.parse(e);this.modelSchema=t,this.modelName=i.modelName,this.apiKey=i.apiKey,this.baseUrl=pe((o=i.baseUrl)!=null?o:Pt.baseUrl),this.completeChatUrl=pe(i.completeChatUrl||`${this.baseUrl}/models/${this.modelName}:generateContent?key=${this.apiKey}`),this.streamChatUrl=pe(i.streamChatUrl||`${this.baseUrl}/models/${this.modelName}:streamGenerateContent?key=${this.apiKey}`);}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {"Content-Type":"application/json"}}getDefaultParams(){return {}}getRetryDelay(t){return {shouldRetry:!1,delayMs:0}}getTokenCount(t){return t.reduce((e,o)=>e+o.content.map(i=>i.modality==="text"?i.value:"").join(" ").length,0)}transformPdfMessages(t){return P(this,null,function*(){let e=r=>P(this,null,function*(){let m=yield fetch(r,{headers:{"User-Agent":"Mozilla/5.0 (compatible; GoogleFilesAPI/1.0)"}});if(!m.ok)throw new b({info:`Failed to download PDF from URL: ${r}`,cause:new Error(`HTTP ${m.status}: ${m.statusText}`)});let l=yield m.arrayBuffer();return Buffer.from(l)}),o=r=>P(this,null,function*(){try{let m=yield fetch(`https://generativelanguage.googleapis.com/v1beta/files?key=${this.apiKey}`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!m.ok)return null;let l=((yield m.json()).files||[]).find(c=>c.displayName===r);return l?l.uri:null}catch(m){return null}}),i=(r,m)=>P(this,null,function*(){let l=yield fetch(`https://generativelanguage.googleapis.com/upload/v1beta/files?key=${this.apiKey}`,{method:"POST",headers:{"X-Goog-Upload-Protocol":"resumable","X-Goog-Upload-Command":"start","X-Goog-Upload-Header-Content-Length":r.length.toString(),"X-Goog-Upload-Header-Content-Type":"application/pdf","Content-Type":"application/json"},body:JSON.stringify({file:{display_name:m}})});if(!l.ok)throw new b({info:"Failed to start PDF upload to Google Files API",cause:new Error(`HTTP ${l.status}: ${l.statusText}`)});let c=l.headers.get("x-goog-upload-url");if(!c)throw new b({info:"No upload URL received from Google Files API",cause:new Error("Missing x-goog-upload-url header")});let u=yield fetch(c,{method:"POST",headers:{"Content-Length":r.length.toString(),"X-Goog-Upload-Offset":"0","X-Goog-Upload-Command":"upload, finalize"},body:r});if(!u.ok)throw new b({info:"Failed to upload PDF content to Google Files API",cause:new Error(`HTTP ${u.status}: ${u.statusText}`)});return (yield u.json()).file.uri}),a=r=>P(this,null,function*(){let m=yield o(r.providerCacheKey);if(m)return m;let l;if(r.value.type==="url")l=yield e(r.value.url);else {let c=r.value.base64,u="data:application/pdf;base64,";c=c.startsWith(u)?c.substring(u.length):c,l=Buffer.from(c,"base64");let g=l.toString("ascii",0,4);if(g!=="%PDF")throw new b({info:`Base64 content is not a valid PDF. Header: ${g}`,cause:new Error(`Expected PDF header '%PDF', got '${g}'`)})}return yield i(l,r.providerCacheKey)}),d=[];for(let r of t){let m=[];for(let l of r.content)if(l.modality===se){let c=yield a(l);m.push(be(M({},l),{value:{type:"url",url:c}}));}else m.push(l);d.push(be(M({},r),{content:m}));}return d})}transformModelRequest(t){let e=Xa.safeParse(t);if(!e.success)throw new X({info:"Invalid model request",cause:e.error});let o=e.data,i=o.model;if(o.system_instruction&&o.systemInstruction)throw new X({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'system_instruction' and 'systemInstruction' are not allowed at the same time")});if(o.generation_config&&o.generationConfig)throw new X({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'generation_config' and 'generationConfig' are not allowed at the same time")});if(o.tool_config&&o.toolConfig)throw new X({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'tool_config' and 'toolConfig' are not allowed at the same time")});let a=o.system_instruction||o.systemInstruction,d=o.generation_config||o.generationConfig,r=o.safety_settings||o.safetySettings,m=o.tool_config||o.toolConfig;if(m&&(!o.tools||o.tools.function_declarations.length===0))throw new X({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'tool_choice' is specified")});let l={};m&&(m.function_calling_config.mode==="ANY"&&m.function_calling_config.allowed_function_names&&m.function_calling_config.allowed_function_names.length===1?l.toolChoice=m.function_calling_config.allowed_function_names[0]:l.toolChoice=m.function_calling_config.mode.toLowerCase()),l.seed=d==null?void 0:d.seed,l.maxTokens=d==null?void 0:d.maxOutputTokens,l.temperature=d==null?void 0:d.temperature,l.topP=d==null?void 0:d.topP,l.presencePenalty=d==null?void 0:d.presencePenalty,l.frequencyPenalty=d==null?void 0:d.frequencyPenalty,l.stop=d==null?void 0:d.stopSequences,l.safetySettings=r;let c=ge().parse(ye(l)),u=[];a&&a.parts.forEach(h=>{u.push({role:ue,content:[{modality:S,value:h.text}]});}),o.contents.forEach(h=>{let y=h.role;switch(y){case"user":{let C=h.parts.map(E=>"text"in E?{modality:S,value:E.text}:{modality:te,detail:"auto",value:{type:Ye,base64:E.inline_data.data,mediaType:E.inline_data.mime_type.split("/")[1]}});u.push({role:y,content:C});}break;case"model":{let C=h.parts.map((E,D)=>"text"in E?{modality:S,value:E.text}:{modality:A,id:D.toString(),index:D,name:E.function_call.name,arguments:JSON.stringify(E.function_call.args)});u.push({role:q,content:C});}break;case"function":{let C=h.parts.map((E,D)=>({modality:oe,id:D.toString(),index:D,name:E.function_response.name,data:JSON.stringify(E.function_response.response)}));u.push({role:ee,content:C});}break;default:throw new b({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`role : '${h.role}' is not supported for model : ${this.modelName}`)})}});let g=[];return o.tools&&o.tools.function_declarations.forEach(h=>{g.push({type:"function",definition:{schema:{name:h.name,description:h.description,parameters:h.parameters}}});}),{modelName:i,config:c,messages:u,tools:g.length>0?g:void 0}}transformConfig(t,e,o){let i=t.toolChoice;delete t.toolChoice;let a=this.modelSchema.config.schema.safeParse(t);if(!a.success)throw new H({info:`Invalid config for model : '${this.modelName}'`,cause:a.error});let d=a.data;Object.keys(d).forEach(c=>{if(!(c in this.modelSchema.config.def))throw new H({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${c}',