@adaline/anthropic 1.10.0 → 1.10.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,146 +2,146 @@
2
2
 
3
3
  var zod = require('zod');
4
4
 
5
- var Vn=Object.defineProperty,$n=Object.defineProperties;var Fn=Object.getOwnPropertyDescriptors;var io=Object.getOwnPropertySymbols;var Hn=Object.prototype.hasOwnProperty,Gn=Object.prototype.propertyIsEnumerable;var ge=(n,t)=>(t=Symbol[n])?t:Symbol.for("Symbol."+n),Kn=n=>{throw TypeError(n)};var ao=(n,t,o)=>t in n?Vn(n,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[t]=o,f=(n,t)=>{for(var o in t||(t={}))Hn.call(t,o)&&ao(n,o,t[o]);if(io)for(var o of io(t))Gn.call(t,o)&&ao(n,o,t[o]);return n},G=(n,t)=>$n(n,Fn(t));var w=(n,t,o)=>new Promise((i,a)=>{var p=r=>{try{c(o.next(r));}catch(g){a(g);}},d=r=>{try{c(o.throw(r));}catch(g){a(g);}},c=r=>r.done?i(r.value):Promise.resolve(r.value).then(p,d);c((o=o.apply(n,t)).next());}),so=function(n,t){this[0]=n,this[1]=t;},We=(n,t,o)=>{var i=(d,c,r,g)=>{try{var u=o[d](c),y=(c=u.value)instanceof so,R=u.done;Promise.resolve(y?c[0]:c).then(P=>y?i(d==="return"?d:"next",c[1]?{done:P.done,value:P.value}:P,r,g):r({value:P,done:R})).catch(P=>i("throw",P,r,g));}catch(P){g(P);}},a=d=>p[d]=c=>new Promise((r,g)=>i(d,c,r,g)),p={};return o=o.apply(n,t),p[ge("asyncIterator")]=()=>p,a("next"),a("throw"),a("return"),p},ro=n=>{var t=n[ge("asyncIterator")],o=!1,i,a={};return t==null?(t=n[ge("iterator")](),i=p=>a[p]=d=>t[p](d)):(t=t.call(n),i=p=>a[p]=d=>{if(o){if(o=!1,p==="throw")throw d;return d}return o=!0,{done:!1,value:new so(new Promise(c=>{var r=t[p](d);r instanceof Object||Kn("Object expected"),c(r);}),1)}}),a[ge("iterator")]=()=>a,i("next"),"throw"in t?i("throw"):a.throw=p=>{throw p},"return"in t&&i("return"),a};var ne="system",Y="user",O="assistant",de="tool",Jn=[ne,Y,O,de],Qe=zod.z.enum(Jn),Zn=[O],Wn=zod.z.enum(Zn),K="image",et="base64",Xn=["png","jpeg","webp","gif"],Yn=zod.z.object({type:zod.z.literal(et),base64:zod.z.string(),mediaType:zod.z.enum(Xn)}),Qn="url",ei=zod.z.object({type:zod.z.literal(Qn),url:zod.z.string()}),ti=zod.z.discriminatedUnion("type",[Yn,ei]),oi=["low","medium","high","auto"],ni=zod.z.enum(oi),ii=(n=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(K),detail:ni,value:ti,metadata:n}),co="pdf",ai="base64",si=zod.z.object({type:zod.z.literal(ai),base64:zod.z.string()}),ri="url",li=zod.z.object({type:zod.z.literal(ri),url:zod.z.string()}),di=zod.z.discriminatedUnion("type",[si,li]),pi=(n=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(co),value:di,file:zod.z.object({name:zod.z.string(),id:zod.z.string(),size:zod.z.number().optional()}),metadata:n}),J="reasoning",he="partial-reasoning",ye="thinking",tt="redacted",Ye=zod.z.object({type:zod.z.literal(ye),thinking:zod.z.string(),signature:zod.z.string()}),uo=zod.z.object({type:zod.z.literal(tt),data:zod.z.string()}),mi=zod.z.discriminatedUnion("type",[Ye,uo]),ot=(n=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(J),value:mi,metadata:n}),ci=zod.z.object({type:zod.z.literal(ye),thinking:Ye.shape.thinking.optional(),signature:Ye.shape.signature.optional()}),ui=zod.z.discriminatedUnion("type",[ci,uo]),nt=(n=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(he),value:ui,metadata:n}),_="text",go=(n=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(_),value:zod.z.string(),metadata:n}),it="partial-text",ho=(n=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(it),value:zod.z.string(),metadata:n}),j="tool-call",yo=(n=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(j),index:zod.z.number().int().nonnegative(),id:zod.z.string().min(1),name:zod.z.string().min(1),arguments:zod.z.string(),serverName:zod.z.string().optional(),metadata:n}),at="partial-tool-call",fo=(n=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(at),index:zod.z.number().int().nonnegative(),id:zod.z.string().optional(),name:zod.z.string().optional(),arguments:zod.z.string().optional(),serverName:zod.z.string().optional(),metadata:n}),B="tool-response",To=(n=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(B),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:n}),Co="partial-tool-response",bo=(n=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Co),index:zod.z.number().int().nonnegative(),id:zod.z.string().optional(),name:zod.z.string().optional(),data:zod.z.string().optional(),apiResponse:zod.z.object({statusCode:zod.z.number().int().nonnegative()}).optional(),metadata:n}),gi=[_,K,co,j,B,J],Mo=zod.z.enum(gi),hi=(n=zod.z.undefined(),t=zod.z.undefined(),o=zod.z.undefined(),i=zod.z.undefined(),a=zod.z.undefined(),p=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[go(n),ii(t),pi(o),yo(i),To(a),ot(p)]),yi=[it,at,he];zod.z.enum(yi);var fi=(n=zod.z.undefined(),t=zod.z.undefined(),o=zod.z.undefined(),i=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[ho(n),fo(t),nt(o),bo(i)]);var st=(n=Qe,t=zod.z.undefined(),o=zod.z.undefined(),i=zod.z.undefined(),a=zod.z.undefined(),p=zod.z.undefined(),d=zod.z.undefined(),c=zod.z.undefined())=>zod.z.object({role:n,content:zod.z.array(hi(t,o,i,a,d,p)),metadata:c}),se=(n=Wn,t=zod.z.undefined(),o=zod.z.undefined(),i=zod.z.undefined(),a=zod.z.undefined(),p=zod.z.undefined())=>zod.z.object({role:n,partialContent:fi(t,o,i,p),metadata:a}),Ti=zod.z.object({promptTokens:zod.z.number().nonnegative(),completionTokens:zod.z.number().nonnegative(),totalTokens:zod.z.number().nonnegative()}),lo=zod.z.object({token:zod.z.string(),logProb:zod.z.number(),bytes:zod.z.array(zod.z.number().int()).nullable()}),Ci=lo.extend({topLogProbs:zod.z.array(lo)}),ko=zod.z.array(Ci);zod.z.object({messages:zod.z.array(st()),usage:Ti.optional(),logProbs:ko.optional()});var bi=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(se()),usage:bi.optional(),logProbs:ko.optional()});var fe=(n=zod.z.record(zod.z.string(),zod.z.any()).optional())=>n,Mi=zod.z.object({enabled:zod.z.boolean().default(!0),allowedTools:zod.z.array(zod.z.string().min(1))}),Ro=zod.z.object({type:zod.z.literal("url"),url:zod.z.string().url().refine(n=>n.startsWith("https://"),{message:"MCP server URL must start with https://"}),name:zod.z.string().min(1),toolConfiguration:Mi.optional(),authorizationToken:zod.z.string().min(1).optional()}),ki=["object","array","number","string","boolean","enum"],po=zod.z.enum(ki),Ri=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:zod.z.union([po,zod.z.array(zod.z.union([po,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()}),Si=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(Ri),additionalProperties:zod.z.literal(!1)});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:Si}).optional();var Q="text",So="token",xi=[Q,So],xo=zod.z.enum(xi),vi=zod.z.array(zod.z.string().min(1)),Oi=zod.z.array(zod.z.array(zod.z.number().int().nonnegative())),vo=(n=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[zod.z.object({modality:zod.z.literal(Q),metadata:n,requests:vi}),zod.z.object({modality:zod.z.literal(So),metadata:n,requests:Oi})]),rt="float",Ei=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.array(zod.z.number())}),lt="base64",_i=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.string().base64()}),mo=zod.z.object({totalTokens:zod.z.number().int().nonnegative()});zod.z.discriminatedUnion("encodingFormat",[zod.z.object({encodingFormat:zod.z.literal(rt),embeddings:zod.z.array(Ei),usage:mo.optional()}),zod.z.object({encodingFormat:zod.z.literal(lt),embeddings:zod.z.array(_i),usage:mo.optional()})]);var Ai=n=>{let t=new WeakSet;return JSON.stringify(n,(o,i)=>{if(typeof i=="object"&&i!==null){if(t.has(i))return;t.add(i);}return i})},Pi=n=>n==null?"unknown error":typeof n=="string"?n:n instanceof Error?n.message:Ai(n),Xe="GatewayBaseError",ee=class Oo extends Error{constructor({info:t,cause:o},i){super(`[${i!=null?i:Xe}]: ${t}
6
- Message: ${Pi(o)}`),this.name=Xe,this.info=t,this.cause=o,this.name=i!=null?i:Xe,Object.setPrototypeOf(this,new.target.prototype);}static isGatewayBaseError(t){return t instanceof Oo}toJSON(){return {name:this.name,info:this.info,cause:this.cause,message:this.message,stack:this.stack}}},wi=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."),qi=zod.z.object({base:wi.describe("Base (uncached, non\u2011reasoning) rates")}).describe("Holds the `ChatModelTokenPairPrice` for different categories (e.g., base) within a single pricing tier."),ji=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:qi.describe("Price categories and rates for this specific token range.")}).refine(n=>n.maxTokens===null||typeof n.maxTokens=="number"&&n.maxTokens>n.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(ji).min(1).describe("Pricing tiers (`ChatModelTokenRangePrice`) schedule, sorted by minTokens.")}).superRefine((n,t)=>{let{tokenRanges:o}=n;o[0].minTokens!==0&&t.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 p=o[a-1],d=o[a];if(p.maxTokens===null){t.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",a-1,"maxTokens"],message:"Cannot define any tokenRanges after an infinite tier (maxTokens = null)."});break}d.minTokens!==p.maxTokens&&t.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",a,"minTokens"],message:`Tier ${a} minTokens (${d.minTokens}) must equal previous tier's maxTokens (${p.maxTokens}) for contiguity.`}),d.minTokens<p.minTokens&&t.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",a,"minTokens"],message:`tokenRanges must be sorted by ascending minTokens. Tier ${a} (${d.minTokens}) starts before Tier ${a-1} (${p.minTokens}).`});}let i=o[o.length-1];o.every(a=>a.maxTokens!==null||a===i)&&i.maxTokens!==null&&t.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 Ii="function";var Li=zod.z.enum(["object","array","number","string","boolean","null"]),Bi=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:Li.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(Bi).optional(),required:zod.z.array(zod.z.string()).optional()});var Ni=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 Ui=zod.z.enum(["function"]),zi=zod.z.object({maxAttempts:zod.z.number().int().positive(),initialDelay:zod.z.number().int().positive(),exponentialFactor:zod.z.number().int().positive()}),Di=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:zi.optional()}),Vi=zod.z.discriminatedUnion("type",[Di]),$i=zod.z.object({type:Ui,definition:zod.z.object({schema:Ni}),request:Vi.optional()}),Fi=[Ii];zod.z.enum(Fi);var Eo=(n=zod.z.undefined())=>zod.z.discriminatedUnion("type",[$i.extend({metadata:n})]),_o=n=>go().parse({modality:_,value:n}),dt=(n,t,o,i,a)=>yo().parse({modality:j,index:n,id:t,name:o,arguments:i,serverName:a}),Ao=(n,t,o,i,a,p)=>To().parse({modality:B,index:n,id:t,name:o,data:i,apiResponse:a,metadata:p});var pt=(n,t)=>se().parse({role:n,partialContent:ho().parse({modality:it,value:t})}),Te=(n,t,o,i,a,p)=>se().parse({role:n,partialContent:fo().parse({modality:at,index:t,id:o,name:i,arguments:a,serverName:p})}),Po=(n,t,o,i,a)=>se().parse({role:n,partialContent:bo().parse({modality:Co,index:t,id:o,name:i,data:a})}),wo=(n,t)=>ot().parse({modality:J,value:{type:ye,thinking:n,signature:t}});var qo=n=>ot().parse({modality:J,value:{type:tt,data:n}});var Ce=(n,t,o)=>se().parse({role:n,partialContent:nt().parse({modality:he,value:{type:ye,thinking:t,signature:o}})}),jo=(n,t)=>se().parse({role:n,partialContent:nt().parse({modality:he,value:{type:tt,data:t}})});var Hi=Object.defineProperty,Io=Object.getOwnPropertySymbols,Gi=Object.prototype.hasOwnProperty,Ki=Object.prototype.propertyIsEnumerable,Lo=(n,t,o)=>t in n?Hi(n,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[t]=o,pe=(n,t)=>{for(var o in t||(t={}))Gi.call(t,o)&&Lo(n,o,t[o]);if(Io)for(var o of Io(t))Ki.call(t,o)&&Lo(n,o,t[o]);return n},Bo="ProviderError",mt=class Ho extends ee{constructor({info:t,cause:o}){super({info:t,cause:o},Bo),this.name=Bo,this.info=t,this.cause=o;}static isProviderError(t){return t instanceof Ho}};var No="ModelResponseError",F=class Go extends ee{constructor({info:t,cause:o}){super({info:t,cause:o},No),this.name=No,this.cause=o,this.info=t;}static isModelResponseError(t){return t instanceof Go}},Uo="InvalidModelRequestError",me=class Ko extends ee{constructor({info:t,cause:o}){super({info:t,cause:o},Uo),this.name=Uo,this.cause=o,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidModelRequestError(t){return t instanceof Ko}},zo="InvalidConfigError",Z=class Jo extends ee{constructor({info:t,cause:o}){super({info:t,cause:o},zo),this.name=zo,this.cause=o,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidConfigError(t){return t instanceof Jo}},Do="InvalidMessagesError",I=class Zo extends ee{constructor({info:t,cause:o}){super({info:t,cause:o},Do),this.name=Do,this.cause=o,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidMessagesError(t){return t instanceof Zo}},Vo="InvalidToolsError",ct=class Wo extends ee{constructor({info:t,cause:o}){super({info:t,cause:o},Vo),this.name=Vo,this.cause=o,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidToolsError(t){return t instanceof Wo}},$o="InvalidEmbeddingRequestsError",ut=class Xo extends ee{constructor({info:t,cause:o}){super({info:t,cause:o},$o),this.name=$o,this.info=t,this.cause=o,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidEmbeddingRequestsError(t){return t instanceof Xo}},gt="multi-string",Yo=zod.z.object({type:zod.z.literal(gt),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()}),Ji=n=>zod.z.array(zod.z.string()).max(n).default([]).optional(),Qo=n=>({def:Yo.parse(pe({type:gt},n)),schema:Ji(n.max)}),ht="object-schema",en=zod.z.object({type:zod.z.literal(ht),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),objectSchema:zod.z.any()}),Zi=n=>n.optional(),tn=n=>({def:en.parse(pe({type:ht},n)),schema:Zi(n.objectSchema)}),on="paired-select",Wi=zod.z.object({value:zod.z.string().min(1),label:zod.z.string().min(1)}),Fo=zod.z.object({key:zod.z.string().min(1),label:zod.z.string().min(1),description:zod.z.string().min(1).max(500).optional(),choices:zod.z.array(Wi).min(1)}),Xi=zod.z.object({type:zod.z.literal(on),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),fields:zod.z.tuple([Fo,Fo]),uniqueByField:zod.z.string().min(1).optional()});var yt="range",nn=zod.z.object({type:zod.z.literal(yt),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()}),Yi=(n,t,o,i)=>zod.z.number().min(n).max(t).step(o).default(i).optional(),ie=n=>({def:nn.parse(pe({type:yt},n)),schema:Yi(n.min,n.max,n.step,n.default)}),ft="select-boolean",an=zod.z.object({type:zod.z.literal(ft),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()}),Qi=n=>zod.z.boolean().nullable().default(n).optional(),re=n=>({def:an.parse(pe({type:ft},n)),schema:Qi(n.default)}),Tt="select-string",sn=zod.z.object({type:zod.z.literal(Tt),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())}),ea=(n,t)=>zod.z.enum(t).nullable().default(n).optional(),ce=n=>({def:sn.parse(pe({type:Tt},n)),schema:ea(n.default,n.choices)}),ta=[yt,gt,Tt,ht,ft,on];zod.z.enum(ta);var rn=zod.z.discriminatedUnion("type",[nn,Yo,sn,an,en,Xi]),b=(n=Qe,t=Mo)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),roles:zod.z.record(n,zod.z.string().min(1).optional()),modalities:zod.z.array(t).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),rn),schema:zod.z.instanceof(zod.z.ZodObject)}).refine(o=>{var i,a;let p=Object.keys(o.def),d=Object.keys((a=(i=o.schema)==null?void 0:i.shape)!=null?a:{});return p.every(c=>d.includes(c))&&d.every(c=>p.includes(c))},{message:"Keys in 'config.def' must exactly match keys in 'config.schema'"}),price:zod.z.custom()}),N=(n=xo)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),modalities:zod.z.array(n).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),rn),schema:zod.z.instanceof(zod.z.ZodObject)}).refine(t=>{var o,i;let a=Object.keys(t.def),p=Object.keys((i=(o=t.schema)==null?void 0:o.shape)!=null?i:{});return a.every(d=>p.includes(d))&&p.every(d=>a.includes(d))},{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 oa={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."},na={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."},ia={type:"range",title:"Max reasoning tokens",description:"Specify the total tokens for reasoning, where one token approximates four English characters."},aa=n=>({type:"multi",title:"Stop sequence",description:`Enter up to ${n} sequences that will halt additional text output. The generated text will exclude these sequences.`}),sa={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."},ra={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."},la={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."},da={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."},pa={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."},ma={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."},ca={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."},ua={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."},ga={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."},ha={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."},ya={type:"boolean",title:"Echo",description:"If true, the response will contain the prompt."},fa={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."},Ta={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."},Ca={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."},ba={type:"object",title:"MCP servers",description:"MCP servers to use for the model."},A={TEMPERATURE:oa,MAX_TOKENS:na,STOP:aa,TOP_A:sa,TOP_P:ra,TOP_K:la,MIN_P:da,FREQUENCY_PENALTY:pa,PRESENCE_PENALTY:ma,REPETITION_PENALTY:ua,SEED:ca,LOG_PROBS:ga,TOP_LOG_PROBS:ha,ECHO:ya,RESPONSE_FORMAT:fa,RESPONSE_FORMAT_WITH_SCHEMA:Ta,RESPONSE_SCHEMA:Ca,MAX_REASONING_TOKENS:ia,MCP_SERVERS:ba};var be=n=>Object.fromEntries(Object.entries(n).filter(([t,o])=>o!=null));var ae=n=>n==null?void 0:n.replace(/\/$/,"");var Ct=ie({param:"temperature",title:A.TEMPERATURE.title,description:A.TEMPERATURE.description,min:0,max:1,step:.01,default:1}),bt=n=>ie({param:"max_tokens",title:A.MAX_TOKENS.title,description:A.MAX_TOKENS.description,min:0,max:n,step:1,default:0}),Mt=n=>Qo({param:"stop_sequences",title:A.STOP(n).title,description:A.STOP(n).description,max:n}),kt=ie({param:"top_p",title:A.TOP_P.title,description:A.TOP_P.description,min:0,max:1,step:.01,default:1}),Rt=ie({param:"top_k",title:A.TOP_K.title,description:A.TOP_K.description,min:0,max:1,step:.01,default:1}),St=ce({param:"tool_choice",title:"Tool choice",description:"Controls which (if any) tool is called by the model. 'any' means the model will call any of the provided tools. 'auto' means the model can pick between generating a message or calling a tool.",default:"auto",choices:["auto","any"]}),xt=re({param:"mcp",title:"MCP",description:"Enable or disable Model Context Protocol (MCP) functionality for this model.",default:!1}),vt=tn({param:"mcp_servers",title:A.MCP_SERVERS.title,description:A.MCP_SERVERS.description,objectSchema:zod.z.array(Ro)});var Me=(n,t)=>zod.z.object({temperature:Ct.schema,maxTokens:bt(n).schema,stop:Mt(t).schema,topP:kt.schema,topK:Rt.schema,toolChoice:St.schema,mcp:xt.schema,mcpServers:vt.schema}),ke=(n,t)=>({temperature:Ct.def,maxTokens:bt(n).def,stop:Mt(t).def,topP:kt.def,topK:Rt.def,toolChoice:St.def,mcp:xt.def,mcpServers:vt.def});var ln=(n,t)=>ie({param:"max_reasoning_tokens",title:A.MAX_REASONING_TOKENS.title,description:A.MAX_REASONING_TOKENS.description,min:n,max:t,step:1,default:0}),dn=re({param:"reasoning_enabled",title:"Reasoning Enabled",description:`Controls whether the model is allowed to think for a longer period of time before generating a response.
7
- This can be useful for complex tasks that require more time to think.`,default:!1}),pn=(n,t,o,i)=>G(f({},ke(n,t)),{reasoningEnabled:dn.def,maxReasoningTokens:ln(o,i).def}),mn=(n,t,o,i)=>Me(n,t).extend({reasoningEnabled:dn.schema,maxReasoningTokens:ln(o,i).schema});var Ot=ce({param:"encoding_format",title:"Encoding format",description:"Select the encoding format for the word embedding.",default:"",choices:["base64",""]}),Et=ce({param:"input_type",title:"Input type",description:"Select the input type for the word embedding.",default:"",choices:["query","document",""]}),_t=re({param:"truncation",title:"Truncation",description:"Select the truncation for the word embedding.",default:!0});var cn=()=>zod.z.object({encodingFormat:Ot.schema,inputType:Et.schema,truncation:_t.schema}),un=()=>({encodingFormat:Ot.def,inputType:Et.def,truncation:_t.def});var h={base:(n,t)=>({def:ke(n,t),schema:Me(n,t)}),extendedThinking:(n,t,o,i)=>({def:pn(n,t,o,i),schema:mn(n,t,o,i)})},E={base:()=>({def:un(),schema:cn()})};var Sa="anthropic",te=class{constructor(){this.version="v1";this.name=Sa;this.chatModelFactories={[Bt]:{model:Be,modelOptions:Mn,modelSchema:Nt},[Vt]:{model:De,modelOptions:Sn,modelSchema:$t},[zt]:{model:ze,modelOptions:Rn,modelSchema:Dt},[Pe]:{model:we,modelOptions:Tn,modelSchema:jt},[qe]:{model:je,modelOptions:Cn,modelSchema:It},[Ne]:{model:Ue,modelOptions:kn,modelSchema:Ut},[Ie]:{model:Le,modelOptions:bn,modelSchema:Lt},[xe]:{model:ve,modelOptions:hn,modelSchema:Pt},[_e]:{model:Ae,modelOptions:fn,modelSchema:qt},[Re]:{model:Se,modelOptions:gn,modelSchema:At},[Oe]:{model:Ee,modelOptions:yn,modelSchema:wt}};this.embeddingModelFactories={[eo]:{model:Ke,modelOptions:An,modelSchema:to},[Yt]:{model:Ge,modelOptions:_n,modelSchema:Qt},[Ft]:{model:Ve,modelOptions:xn,modelSchema:Ht},[Gt]:{model:$e,modelOptions:vn,modelSchema:Kt},[Jt]:{model:Fe,modelOptions:On,modelSchema:Zt},[Wt]:{model:He,modelOptions:En,modelSchema:Xt}};}chatModelLiterals(){return Object.keys(this.chatModelFactories)}chatModelSchemas(){return Object.keys(this.chatModelFactories).reduce((t,o)=>(t[o]=this.chatModelFactories[o].modelSchema,t),{})}chatModel(t){let o=t.modelName;if(!(o in this.chatModelFactories))throw new mt({info:`Anthropic chat model: ${o} not found`,cause:new Error(`Anthropic chat model: ${o} not found, available chat models:
8
- ${this.chatModelLiterals().join(", ")}`)});let i=this.chatModelFactories[o].model,a=this.chatModelFactories[o].modelOptions.parse(t);return new i(a)}embeddingModelLiterals(){return Object.keys(this.embeddingModelFactories)}embeddingModelSchemas(){return Object.keys(this.embeddingModelFactories).reduce((t,o)=>(t[o]=this.embeddingModelFactories[o].modelSchema,t),{})}embeddingModel(t){let o=t.modelName;if(!(o in this.embeddingModelFactories))throw new mt({info:`Anthropic embedding model: ${o} not found`,cause:new Error(`Anthropic embedding model: ${o} not found, available embedding models:
9
- ${this.embeddingModelLiterals().join(", ")}`)});let i=this.embeddingModelFactories[o].model,a=this.embeddingModelFactories[o].modelOptions.parse(t);return new i(a)}};te.chatBaseUrl="https://api.anthropic.com/v1",te.embeddingBaseUrl="https://api.voyageai.com/v1";var v={"claude-3-opus-20240229":{modelName:"claude-3-opus-20240229",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:15,outputPricePerMillion:75}}}]},"claude-3-sonnet-20240229":{modelName:"claude-3-sonnet-20240229",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:3,outputPricePerMillion:15}}}]},"claude-3-5-sonnet-20240620":{modelName:"claude-3-5-sonnet-20240620",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:3,outputPricePerMillion:15}}}]},"claude-3-5-sonnet-20241022":{modelName:"claude-3-5-sonnet-20241022",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:3,outputPricePerMillion:15}}}]},"claude-3-7-sonnet-20250219":{modelName:"claude-3-7-sonnet-20250219",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:3,outputPricePerMillion:15}}}]},"claude-3-haiku-20240307":{modelName:"claude-3-haiku-20240307",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.25,outputPricePerMillion:1.25}}}]},"claude-3-haiku-20241022":{modelName:"claude-3-haiku-20241022",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.25,outputPricePerMillion:1.25}}}]},"claude-3-5-haiku-20241022":{modelName:"claude-3-5-haiku-20241022",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.8,outputPricePerMillion:4}}}]},"claude-4-sonnet-20250514":{modelName:"claude-4-sonnet-20250514",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:3,outputPricePerMillion:15}}}]},"claude-4-opus-20250514":{modelName:"claude-4-opus-20250514",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:15,outputPricePerMillion:75}}}]},"claude-sonnet-4-5-20250929":{modelName:"claude-sonnet-4-5-20250929",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:3,outputPricePerMillion:15}}}]},"claude-opus-4-5-20251101":{modelName:"claude-opus-4-5-20251101",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:5,outputPricePerMillion:25}}}]}};var M=zod.z.enum([ne,Y,O,de]),k={system:ne,user:Y,assistant:O,tool:Y};var U=[_,K,j,B],z=zod.z.enum([_,K,j,B]),W=[_,K,j,B,J],X=zod.z.enum([_,K,j,B,J]);var Oa=zod.z.object({type:zod.z.literal("text"),text:zod.z.string()}),Ea=zod.z.object({type:zod.z.literal("tool_use"),id:zod.z.string(),name:zod.z.string(),input:zod.z.record(zod.z.any())}),_a=zod.z.object({type:zod.z.literal("thinking"),thinking:zod.z.string(),signature:zod.z.string()}),Aa=zod.z.object({type:zod.z.literal("redacted_thinking"),data:zod.z.string()}),Pa=zod.z.object({type:zod.z.literal("mcp_tool_use"),id:zod.z.string(),name:zod.z.string(),server_name:zod.z.string(),input:zod.z.record(zod.z.any())}),wa=zod.z.object({type:zod.z.literal("mcp_tool_result"),tool_use_id:zod.z.string(),is_error:zod.z.boolean(),content:zod.z.array(zod.z.any())}),wn=zod.z.object({content:zod.z.array(zod.z.discriminatedUnion("type",[Oa,Ea,_a,Aa,Pa,wa])),id:zod.z.string(),model:zod.z.string(),role:zod.z.string(),stop_reason:zod.z.string(),stop_sequence:zod.z.null(),type:zod.z.literal("message"),usage:zod.z.object({input_tokens:zod.z.number(),output_tokens:zod.z.number(),cache_creation_input_tokens:zod.z.number().nullish(),cache_read_input_tokens:zod.z.number().nullish()})}),qn=zod.z.object({type:zod.z.literal("message_start"),message:zod.z.object({id:zod.z.string(),type:zod.z.literal("message"),role:zod.z.string(),model:zod.z.string(),stop_reason:zod.z.string().nullable(),stop_sequence:zod.z.string().nullable(),content:zod.z.array(zod.z.any()),usage:zod.z.object({input_tokens:zod.z.number(),output_tokens:zod.z.number()})})}),jn=zod.z.object({type:zod.z.literal("message_delta"),delta:zod.z.object({stop_reason:zod.z.string().nullable(),stop_sequence:zod.z.string().nullable()}),usage:zod.z.object({output_tokens:zod.z.number()})}),qa=zod.z.object({type:zod.z.literal("text"),text:zod.z.string()}),ja=zod.z.object({type:zod.z.literal("tool_use"),id:zod.z.string(),name:zod.z.string(),input:zod.z.object({})}),Ia=zod.z.object({type:zod.z.literal("thinking"),thinking:zod.z.string()}),La=zod.z.object({type:zod.z.literal("redacted_thinking"),data:zod.z.string()}),Ba=zod.z.object({type:zod.z.literal("mcp_tool_use"),id:zod.z.string(),name:zod.z.string(),server_name:zod.z.string(),input:zod.z.record(zod.z.any())}),Na=zod.z.object({type:zod.z.literal("mcp_tool_result"),tool_use_id:zod.z.string(),is_error:zod.z.boolean(),content:zod.z.array(zod.z.any())}),In=zod.z.object({type:zod.z.literal("content_block_start"),index:zod.z.number(),content_block:zod.z.discriminatedUnion("type",[qa,ja,Ia,La,Ba,Na])}),Ua=zod.z.object({type:zod.z.literal("text_delta"),text:zod.z.string()}),za=zod.z.object({type:zod.z.literal("input_json_delta"),partial_json:zod.z.string()}),Da=zod.z.object({type:zod.z.literal("thinking_delta"),thinking:zod.z.string()}),Va=zod.z.object({type:zod.z.literal("signature_delta"),signature:zod.z.string()}),Ln=zod.z.object({type:zod.z.literal("content_block_delta"),index:zod.z.number(),delta:zod.z.discriminatedUnion("type",[Ua,za,Da,Va])});var $a=zod.z.object({type:zod.z.literal("thinking"),thinking:zod.z.string().optional(),signature:zod.z.string().optional()}),Fa=zod.z.object({type:zod.z.literal("redacted_thinking"),data:zod.z.string()}),Ha=zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1).optional(),input_schema:zod.z.any()}),Ga=zod.z.object({type:zod.z.enum(["auto","any"])}),Ka=zod.z.object({type:zod.z.literal("tool"),name:zod.z.string().min(1)}),oo=zod.z.object({text:zod.z.string().min(1),type:zod.z.literal("text")}),Bn=zod.z.object({type:zod.z.literal("image"),source:zod.z.object({type:zod.z.literal("base64"),media_type:zod.z.enum(["image/jpeg","image/png","image/gif","image/webp"]),data:zod.z.string().base64()})}),br=zod.z.object({id:zod.z.string().min(1),type:zod.z.literal("tool_use"),name:zod.z.string().min(1),input:zod.z.record(zod.z.any())}),Nn=zod.z.object({type:zod.z.literal("tool_result"),tool_use_id:zod.z.string().min(1),content:zod.z.string().min(1).or(zod.z.array(zod.z.union([oo,Bn])).min(1))}),Mr=zod.z.object({type:zod.z.literal("mcp_tool_use"),id:zod.z.string().min(1),name:zod.z.string().min(1),server_name:zod.z.string().min(1),input:zod.z.record(zod.z.any())}),kr=zod.z.object({type:zod.z.literal("mcp_tool_result"),tool_use_id:zod.z.string().min(1),is_error:zod.z.boolean().default(!1),content:zod.z.array(zod.z.any())}),Ja=zod.z.object({enabled:zod.z.boolean().default(!0),allowed_tools:zod.z.array(zod.z.string().min(1)).optional()}),Za=zod.z.object({type:zod.z.literal("url"),url:zod.z.string().url().refine(n=>n.startsWith("https://"),{message:"MCP server URL must start with https://"}),name:zod.z.string().min(1),tool_configuration:Ja.optional(),authorization_token:zod.z.string().min(1).optional()}),Wa=zod.z.object({role:zod.z.literal("user"),content:zod.z.string().min(1).or(zod.z.array(zod.z.union([oo,Bn,Nn])).min(1))}),Xa=zod.z.object({role:zod.z.literal("assistant"),content:zod.z.string().min(1).or(zod.z.array(zod.z.union([oo,Nn,$a,Fa])).min(1))}),Ya=zod.z.union([Wa,Xa]),Un=zod.z.object({model:zod.z.string().min(1).optional(),messages:zod.z.array(Ya).min(1),system:zod.z.string().min(1).optional(),max_tokens:zod.z.number().min(0).optional(),stop_sequences:zod.z.array(zod.z.string().min(1)).optional(),temperature:zod.z.number().min(0).max(1).optional(),tool_choice:zod.z.union([Ga,Ka]).optional(),tools:zod.z.array(Ha).min(1).optional(),top_p:zod.z.number().min(0).max(1).optional(),top_k:zod.z.number().min(0).optional(),mcp_servers:zod.z.array(Za).min(1).optional()});var C=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string(),completeChatUrl:zod.z.string().url().optional(),streamChatUrl:zod.z.string().url().optional()}),T=class{constructor(t,o){this.version="v1";let i=C.parse(o);this.modelSchema=t,this.modelName=i.modelName,this.apiKey=i.apiKey,this.baseUrl=ae(te.chatBaseUrl),this.completeChatUrl=ae(i.completeChatUrl||`${this.baseUrl}/messages`),this.streamChatUrl=ae(i.streamChatUrl||`${this.baseUrl}/messages`);}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {"x-api-key":`${this.apiKey}`,"anthropic-version":"2023-06-01","content-type":"application/json","anthropic-dangerous-direct-browser-access":"true"}}getDefaultParams(){return {model:this.modelName}}getRetryDelay(t){let o=0,i=!0;return t["x-should-retry"]&&(i=t["x-should-retry"].toLowerCase()!=="false"),t["retry-after"]&&(o=parseInt(t["retry-after"])*1e3),{shouldRetry:i,delayMs:o}}getTokenCount(t){return t.reduce((o,i)=>o+i.content.map(a=>a.modality==="text"?a.value:"").join(" ").length,0)}transformModelRequest(t){let o=Un.safeParse(t);if(!o.success)throw new me({info:"Invalid model request",cause:o.error});let i=o.data,a=i.model;if(i.tool_choice&&(!i.tools||i.tools.length===0))throw new me({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'tool_choice' is specified")});let p={};i.tool_choice&&(i.tool_choice.type==="tool"?p.toolChoice=i.tool_choice.name:p.toolChoice=i.tool_choice.type),p.maxTokens=i.max_tokens,p.temperature=i.temperature,p.topP=i.top_p,p.topK=i.top_k,p.stop=i.stop_sequences;let d=fe().parse(be(p)),c=[],r={};i.system&&c.push({role:ne,content:[{modality:_,value:i.system}]}),i.messages.forEach(u=>{let y=u.role;switch(y){case"user":{let R=u.content;if(typeof R=="string")c.push({role:y,content:[{modality:_,value:R}]});else {let P=R.map(S=>{if(S.type==="text")return {modality:_,value:S.text};if(S.type==="image"){let x="auto",H=S.source.media_type.split("/")[1];return {modality:K,detail:x,value:{type:et,mediaType:H,base64:S.source.data}}}else return {modality:B,id:S.tool_use_id,index:r[S.tool_use_id].index,name:r[S.tool_use_id].name,data:typeof S.content=="string"?S.content:JSON.stringify(S.content)}});c.push({role:y,content:P});}}break;case"assistant":{let R=u.content;if(typeof R=="string")c.push({role:y,content:[{modality:_,value:R}]});else {let P=R.map((S,x)=>{if(S.type==="text")return {modality:_,value:S.text};{let H={modality:j,id:S.id,index:x,name:S.name,arguments:JSON.stringify(S.input)};return r[S.id]=H,H}});c.push({role:y,content:P});}}break}});let g=[];return i.tools&&i.tools.forEach(u=>{g.push({type:"function",definition:{schema:{name:u.name,description:u.description||"",parameters:u.input_schema}}});}),{modelName:a,config:d,messages:c,tools:g.length>0?g:void 0}}transformConfig(t,o,i){let a=t.toolChoice,p=t.reasoningEnabled,d=t.maxReasoningTokens,c=t.mcp,r=t.mcpServers,g=f({},t);delete g.toolChoice,delete g.reasoningEnabled,delete g.maxReasoningTokens,delete g.mcp,delete g.mcpServers;let u=this.modelSchema.config.schema.safeParse(g);if(!u.success)throw new Z({info:`Invalid config for model : '${this.modelName}'`,cause:u.error});let y=u.data;a!==void 0&&(y.toolChoice=a),Object.keys(y).forEach(x=>{if(!(x in this.modelSchema.config.def))throw new Z({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${x}',
10
- available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})});let R=Object.keys(y).reduce((x,H)=>{let le=this.modelSchema.config.def[H],Ze=le.param,no=y[H];return Ze==="max_tokens"&&le.type==="range"&&no===0?x[Ze]=le.max:x[Ze]=no,x},{});if(!R.max_tokens){let x=this.modelSchema.config.def.maxTokens;R.max_tokens=x.max;}if("tool_choice"in R&&R.tool_choice!==void 0){let x=R.tool_choice;if(!i||i&&i.length===0)throw new Z({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'toolChoice' is specified")});if(i&&i.length>0){let H=this.modelSchema.config.def.toolChoice;if(H.choices.includes(x))R.tool_choice={type:x};else if(i.map(le=>le.definition.schema.name).includes(x))R.tool_choice={type:"tool",name:x};else throw new Z({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`toolChoice : '${x}' is not part of provided 'tools' names or
11
- one of [${H.choices.join(", ")}]`)})}}let P=p!==void 0,S=d!==void 0;if(P!==S)throw new Z({info:`Invalid extended thinking config for model: '${this.modelName}'`,cause:new Error("Both 'reasoningEnabled' and 'maxReasoningTokens' must be defined together.")});if(P&&S){let x=R.max_tokens;if(p)if(d<x)R.thinking={type:"enabled",budget_tokens:d};else throw new Z({info:`Invalid extended thinking token budget for model: '${this.modelName}'`,cause:new Error(`maxReasoningTokens (${d}) must be less than max_tokens (${x})`)})}return c&&r&&(R.mcp_servers=r),R}transformMessages(t){if(!t||t&&t.length===0)return {messages:[]};let o=d=>{let c=d.match(/^data:image\/[a-zA-Z]+;base64,/);return c?d.substring(c[0].length):d},i=t.map(d=>{let c=st().safeParse(d);if(!c.success)throw new I({info:"Invalid messages",cause:c.error});return c.data});i.forEach(d=>{d.content.forEach(c=>{if(!this.modelSchema.modalities.includes(c.modality))throw new I({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support modality : '${c.modality}', available modalities : [${this.modelSchema.modalities.join(", ")}]`)})});}),i.forEach(d=>{if(!Object.keys(this.modelSchema.roles).includes(d.role))throw new I({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support role : '${d.role}', available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})});let a="",p=[];if(i.forEach(d=>{switch(d.role){case ne:{d.content.forEach(c=>{if(c.modality===_)a+=c.value;else throw new I({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${d.role}' cannot have content with modality : '${c.modality}'`)})});break}case O:{let c=[];d.content.forEach(r=>{if(r.modality===_)c.push({type:"text",text:r.value});else if(r.modality===j)r.serverName?c.push({type:"mcp_tool_use",id:r.id,name:r.name,server_name:r.serverName,input:JSON.parse(r.arguments)}):c.push({type:"tool_use",id:r.id,name:r.name,input:JSON.parse(r.arguments)});else if(r.modality===J&&r.value.type==="thinking")c.push({type:"thinking",thinking:r.value.thinking,signature:r.value.signature});else if(r.modality===J&&r.value.type==="redacted")c.push({type:"redacted_thinking",data:r.value.data});else if(r.modality===B)c.push({type:"mcp_tool_result",tool_use_id:r.id,content:JSON.parse(r.data),is_error:r.apiResponse&&r.apiResponse.statusCode!==200||!1});else throw new I({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${d.role}' cannot have content with modality : '${r.modality}'`)})}),p.push({role:this.modelSchema.roles[d.role],content:c});break}case Y:{let c=[];d.content.forEach(r=>{if(r.modality===_)c.push({type:"text",text:r.value});else if(r.modality===K){if(r.value.type==="base64"){let g=r.value.base64;g=o(g),c.push({type:"image",source:{type:"base64",media_type:`image/${r.value.mediaType}`,data:g}});}else if(r.value.type==="url")throw new I({info:`Invalid message 'modality' for model : ${this.modelName}`,cause:new Error(`model: '${this.modelName}' does not support image content type: '${r.value.type}'`)})}else throw new I({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${d.role}' cannot have content with modality : '${r.modality}'`)})}),p.push({role:this.modelSchema.roles[d.role],content:c});break}case de:{let c=[];d.content.forEach(r=>{if(r.modality===B)c.push({type:"tool_result",tool_use_id:r.id,content:r.data});else throw new I({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${d.role}' cannot have content with modality : '${r.modality}'`)})}),p.push({role:this.modelSchema.roles[d.role],content:c});break}default:throw new I({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`role : '${d.role}' is not supported,
12
- available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}}),p[0].role!==this.modelSchema.roles[Y])throw new I({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' requires first message to be from user`)});return {system:a,messages:p}}transformTools(t){if(!this.modelSchema.modalities.includes(j))throw new ct({info:`Invalid tool 'modality' for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' does not support tool modality : '${j}'`)});return !t||t&&t.length===0?{tools:[]}:{tools:t.map(a=>{let p=Eo().safeParse(a);if(!p.success)throw new ct({info:"Invalid tools",cause:p.error});return p.data}).map(a=>({name:a.definition.schema.name,description:a.definition.schema.description,input_schema:a.definition.schema.parameters}))}}getCompleteChatUrl(t,o,i){return w(this,null,function*(){return new Promise(a=>{a(this.completeChatUrl);})})}getCompleteChatHeaders(t,o,i){return w(this,null,function*(){let a=this.getDefaultHeaders();if(t&&t.mcp&&t.mcpServers){let p=a["anthropic-beta"],d="mcp-client-2025-04-04";p?a=G(f({},a),{"anthropic-beta":`${p},${d}`}):a=G(f({},a),{"anthropic-beta":d});}return new Promise(p=>{p(a);})})}getCompleteChatData(t,o,i){return w(this,null,function*(){let a=this.transformConfig(t,o,i),p=this.transformMessages(o);if(p.messages&&p.messages.length===0)throw new I({info:"Messages are required",cause:new Error("Messages are required")});let d=i?this.transformTools(i):{};return new Promise(c=>{c(f(f(f(f({},this.getDefaultParams()),a),p),d));})})}transformCompleteChatResponse(t){let o=wn.safeParse(t);if(o.success){let i=o.data,p=i.content.map((r,g)=>{if(r.type==="text")return _o(r.text);if(r.type==="tool_use")return dt(g,r.id,r.name,JSON.stringify(r.input));if(r.type==="thinking")return wo(r.thinking,r.signature);if(r.type==="redacted_thinking")return qo(r.data);if(r.type==="mcp_tool_use")return dt(g,r.id,r.name,JSON.stringify(r.input),r.server_name);if(r.type==="mcp_tool_result")return Ao(g,r.tool_use_id,"mcp_tool_result",JSON.stringify(r.content),{statusCode:r.is_error?500:200})}),d=[{role:O,content:p}],c={promptTokens:i.usage.input_tokens,completionTokens:i.usage.output_tokens,totalTokens:i.usage.input_tokens+i.usage.output_tokens};return {messages:d,usage:c,logProbs:[]}}throw new F({info:"Invalid response from model",cause:o.error})}getStreamChatUrl(t,o,i){return w(this,null,function*(){return new Promise(a=>{a(this.streamChatUrl);})})}getStreamChatHeaders(t,o,i){return w(this,null,function*(){let a=this.getDefaultHeaders();if(t&&t.mcp&&t.mcpServers){let p=a["anthropic-beta"],d="mcp-client-2025-04-04";p?a=G(f({},a),{"anthropic-beta":`${p},${d}`}):a=G(f({},a),{"anthropic-beta":d});}return new Promise(p=>{p(a);})})}getStreamChatData(t,o,i){return w(this,null,function*(){let a=this.transformConfig(t,o,i),p=this.transformMessages(o);if(p.messages&&p.messages.length===0)throw new I({info:"Messages are required",cause:new Error("Messages are required")});let d=i?this.transformTools(i):{};return new Promise(c=>{c(f(f(f(f({stream:!0},this.getDefaultParams()),a),p),d));})})}transformStreamChatResponseChunk(t,o){return We(this,null,function*(){let i=o+t,a=[],p="",d=0;for(;d<i.length;){let c=i.indexOf(`
13
- `,d);if(c===-1){p=i.substring(d);break}else {let r=i.substring(d,c).trim();r&&a.push(r),d=c+1;}}for(let c of a)if(c.startsWith("data: {")&&c.endsWith("}")){let r;try{r=JSON.parse(c.substring(6));}catch(g){throw new F({info:`Malformed JSON received in stream : ${r}`,cause:g})}if("type"in r){if(r.type==="message_stop")return;if(r.type==="message_start"){let g=qn.safeParse(r);if(g.success){let u=g.data;yield {partialResponse:{partialMessages:[],usage:{promptTokens:u.message.usage.input_tokens,completionTokens:u.message.usage.output_tokens,totalTokens:u.message.usage.input_tokens+u.message.usage.output_tokens}},buffer:o};}else throw new F({info:"Invalid response from model",cause:g.error})}else if(r.type==="message_delta"){let g=jn.safeParse(r);if(g.success){let u=g.data;yield {partialResponse:{partialMessages:[],usage:{promptTokens:void 0,completionTokens:u.usage.output_tokens,totalTokens:u.usage.output_tokens}},buffer:o};}else throw new F({info:"Invalid response from model",cause:g.error})}else if(r.type==="content_block_start"){let g=In.safeParse(r);if(g.success){let u=g.data,y=[];u.content_block.type==="text"?y.push(pt(O,u.content_block.text)):u.content_block.type==="tool_use"?y.push(Te(O,u.index,u.content_block.id,u.content_block.name,"")):u.content_block.type==="thinking"?y.push(Ce(O,u.content_block.thinking)):u.content_block.type==="redacted_thinking"?y.push(jo(O,u.content_block.data)):u.content_block.type==="mcp_tool_use"?y.push(Te(O,u.index,u.content_block.id,u.content_block.name,JSON.stringify(u.content_block.input),u.content_block.server_name)):u.content_block.type==="mcp_tool_result"&&y.push(Po(O,u.index,u.content_block.tool_use_id,"mcp_tool_result",JSON.stringify(u.content_block.content))),yield {partialResponse:{partialMessages:y},buffer:o};}else throw new F({info:"Invalid response from model",cause:g.error})}else if(r.type==="content_block_delta"){let g=Ln.safeParse(r);if(g.success){let u=g.data,y=[];u.delta.type==="text_delta"?y.push(pt(O,u.delta.text)):u.delta.type==="input_json_delta"?y.push(Te(O,u.index,"","",u.delta.partial_json)):u.delta.type==="thinking_delta"?y.push(Ce(O,u.delta.thinking)):u.delta.type==="signature_delta"&&y.push(Ce(O,void 0,u.delta.signature)),yield {partialResponse:{partialMessages:y},buffer:o};}else throw new F({info:"Invalid response from model",cause:g.error})}}else throw new F({info:"Invalid JSON received in stream",cause:new Error(`Invalid JSON received in stream, expected 'type' property, received: ${JSON.stringify(r)}`)})}yield {partialResponse:{partialMessages:[]},buffer:p};})}transformProxyStreamChatResponseChunk(t,o,i,a,p){return We(this,null,function*(){yield*ro(this.transformStreamChatResponseChunk(t,o));})}getProxyStreamChatUrl(t,o,i){return w(this,null,function*(){return new Promise(a=>{a(this.streamChatUrl);})})}getProxyCompleteChatUrl(t,o,i){return w(this,null,function*(){return new Promise(a=>{a(this.completeChatUrl);})})}getProxyCompleteChatHeaders(t,o,i){return w(this,null,function*(){if(!o)return {};let a=f({},o);return delete a.host,delete a["content-length"],a})}getProxyStreamChatHeaders(t,o,i){return w(this,null,function*(){return yield this.getProxyCompleteChatHeaders(t,o,i)})}getModelPricing(){if(!(this.modelName in v))throw new F({info:`Invalid model pricing for model : '${this.modelName}'`,cause:new Error(`No pricing configuration found for model "${this.modelName}"`)});return v[this.modelName]}};var Re="claude-4-opus-20250514",Qa="Our high-performance model with exceptional reasoning and efficiency. Training cutoff: March 2025.",At=b(M,X).parse({name:Re,description:Qa,maxInputTokens:2e5,maxOutputTokens:32e3,maxReasoningTokens:32e3,roles:k,modalities:W,config:{def:h.extendedThinking(32e3,4,1024,32e3).def,schema:h.extendedThinking(32e3,4,1024,32e3).schema},price:v[Re]}),gn=C,Se=class extends T{constructor(t){super(At,t);}};var xe="claude-4-sonnet-20250514",es="Our most capable and intelligent model yet. Training cutoff: March 2025.",Pt=b(M,X).parse({name:xe,description:es,maxInputTokens:2e5,maxOutputTokens:64e3,maxReasoningTokens:64e3,roles:k,modalities:W,config:{def:h.extendedThinking(64e3,4,1024,64e3).def,schema:h.extendedThinking(64e3,4,1024,64e3).schema},price:v[xe]}),hn=C,ve=class extends T{constructor(t){super(Pt,t);}};var Oe="claude-opus-4-5-20251101",ts="Premium model combining maximum intelligence with practical performance. Ideal for complex specialized tasks, professional software engineering, and advanced agents. Training cutoff: August 2025.",wt=b(M,X).parse({name:Oe,description:ts,maxInputTokens:2e5,maxOutputTokens:64e3,maxReasoningTokens:64e3,roles:k,modalities:W,config:{def:h.extendedThinking(64e3,4,1024,64e3).def,schema:h.extendedThinking(64e3,4,1024,64e3).schema},price:v[Oe]}),yn=C,Ee=class extends T{constructor(t){super(wt,t);}};var _e="claude-sonnet-4-5-20250929",os="Our best model for complex agents and coding, with the highest intelligence across most tasks. Training cutoff: July 2025.",qt=b(M,X).parse({name:_e,description:os,maxInputTokens:2e5,maxOutputTokens:64e3,maxReasoningTokens:64e3,roles:k,modalities:W,config:{def:h.extendedThinking(64e3,4,1024,64e3).def,schema:h.extendedThinking(64e3,4,1024,64e3).schema},price:v[_e]}),fn=C,Ae=class extends T{constructor(t){super(qt,t);}};var Pe="claude-3-5-sonnet-20240620",ns="Most intelligent model. Highest level of intelligence and capability.",jt=b(M,z).parse({name:Pe,description:ns,maxInputTokens:2e5,maxOutputTokens:8192,roles:k,modalities:U,config:{def:h.base(8192,4).def,schema:h.base(8192,4).schema},price:v[Pe]}),Tn=C,we=class extends T{constructor(t){super(jt,t);}};var qe="claude-3-5-sonnet-20241022",is="Most intelligent model. Highest level of intelligence and capability.",It=b(M,z).parse({name:qe,description:is,maxInputTokens:2e5,maxOutputTokens:8192,roles:k,modalities:U,config:{def:h.base(8192,4).def,schema:h.base(8192,4).schema},price:v[qe]}),Cn=C,je=class extends T{constructor(t){super(It,t);}};var Ie="claude-3-7-sonnet-20250219",as="Most intelligent model. Highest level of intelligence and capability.",Lt=b(M,X).parse({name:Ie,description:as,maxInputTokens:2e5,maxOutputTokens:128e3,maxReasoningTokens:64e3,roles:k,modalities:W,config:{def:h.extendedThinking(128e3,4,1024,64e3).def,schema:h.extendedThinking(128e3,4,1024,64e3).schema},price:v[Ie]}),bn=C,Le=class extends T{constructor(t){super(Lt,t);}getDefaultHeaders(){let t=super.getDefaultHeaders(),o=t["anthropic-beta"],i="output-128k-2025-02-19";return o?t=G(f({},t),{"anthropic-beta":`${o},${i}`}):t=G(f({},t),{"anthropic-beta":i}),t}};var Bt="claude-3-haiku-20240307",ss="Fastest and most compact model for near-instant responsiveness. Quick and accurate targeted performance.",Nt=b(M,z).parse({name:Bt,description:ss,maxInputTokens:2e5,maxOutputTokens:4096,roles:k,modalities:U,config:{def:h.base(4096,4).def,schema:h.base(4096,4).schema}}),Mn=C,Be=class extends T{constructor(t){super(Nt,t);}};var Ne="claude-3-5-haiku-20241022",rs="Our fastest model with intelligence at blazing speeds.",Ut=b(M,z).parse({name:Ne,description:rs,maxInputTokens:2e5,maxOutputTokens:8192,roles:k,modalities:U,config:{def:h.base(8192,4).def,schema:h.base(8192,4).schema},price:v[Ne]}),kn=C,Ue=class extends T{constructor(t){super(Ut,t);}};var zt="claude-3-opus-20240229",ls="Powerful model for highly complex tasks. Top-level performance, intelligence, fluency, and understanding.",Dt=b(M,z).parse({name:zt,description:ls,maxInputTokens:2e5,maxOutputTokens:4096,roles:k,modalities:U,config:{def:h.base(4096,4).def,schema:h.base(4096,4).schema}}),Rn=C,ze=class extends T{constructor(t){super(Dt,t);}};var Vt="claude-3-sonnet-20240229",ds="Balance of intelligence and speed. Strong utility, balanced for scaled deployments.",$t=b(M,z).parse({name:Vt,description:ds,maxInputTokens:2e5,maxOutputTokens:4096,roles:k,modalities:U,config:{def:h.base(4096,4).def,schema:h.base(4096,4).schema}}),Sn=C,De=class extends T{constructor(t){super($t,t);}};var D=[Q],V=zod.z.enum([Q]);var zn=zod.z.object({object:zod.z.literal("list"),model:zod.z.string(),data:zod.z.array(zod.z.object({index:zod.z.number(),object:zod.z.literal("embedding"),embedding:zod.z.array(zod.z.number()).or(zod.z.string().base64())})),usage:zod.z.object({total_tokens:zod.z.number()})});var ms=zod.z.string().min(1).or(zod.z.array(zod.z.string().min(1)).min(1)),Dn=zod.z.object({model:zod.z.string().min(1).optional(),input:ms,encoding_format:zod.z.enum(["base64"]).nullable().optional(),input_type:zod.z.enum(["query","document"]).nullable().optional(),truncation:zod.z.boolean().optional()});var L=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string(),getEmbeddingsUrl:zod.z.string().url().optional()}),q=class{constructor(t,o){this.version="v1";let i=L.parse(o);this.modelSchema=t,this.modelName=i.modelName,this.apiKey=i.apiKey,this.baseUrl=ae(te.embeddingBaseUrl),this.getEmbeddingsUrl=ae(i.getEmbeddingsUrl||`${this.baseUrl}/embeddings`);}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"}}getDefaultParams(){return {model:this.modelName}}getTokenCount(t){return t.requests.reduce((o,i)=>o+i.length,0)}getRetryDelay(t){return {shouldRetry:!0,delayMs:0}}transformModelRequest(t){let o=Dn.safeParse(t);if(!o.success)throw new me({info:"Invalid model request",cause:o.error});let i=o.data,a=i.model,p={encodingFormat:i.encoding_format,inputType:i.input_type,truncation:i.truncation},d=fe().parse(be(p)),c;return typeof i.input=="string"?c={modality:Q,requests:[i.input]}:c={modality:Q,requests:i.input},{modelName:a,config:d,embeddingRequests:c}}transformConfig(t,o){"inputType"in t&&t.inputType===""&&delete t.inputType,"encodingFormat"in t&&t.encodingFormat===""&&delete t.encodingFormat;let i=this.modelSchema.config.schema.safeParse(t);if(!i.success)throw new Z({info:`Invalid config for model : '${this.modelName}'`,cause:i.error});let a=i.data;return Object.keys(a).forEach(d=>{if(!this.modelSchema.config.def[d])throw new Z({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${d}',
14
- available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})}),Object.keys(a).reduce((d,c)=>{let g=this.modelSchema.config.def[c].param,u=a[c];return d[g]=u,d},{})}transformEmbeddingRequests(t){let o=vo().safeParse(t);if(!o.success)throw new ut({info:"Invalid embedding requests",cause:o.error});if(o.data.requests.length>128)throw new ut({info:`Invalid embedding requests for model : '${this.modelName}'`,cause:new Error(`Max requests for model : '${this.modelName}' is 128`)});return {input:o.data.requests}}getGetEmbeddingsUrl(t,o){return w(this,null,function*(){return new Promise(i=>{i(this.getEmbeddingsUrl);})})}getGetEmbeddingsHeaders(t,o){return w(this,null,function*(){return new Promise(i=>{i(this.getDefaultHeaders());})})}getGetEmbeddingsData(t,o){return w(this,null,function*(){return new Promise(i=>{i(f(f(f({},this.getDefaultParams()),this.transformConfig(t,o)),this.transformEmbeddingRequests(o)));})})}transformGetEmbeddingsResponse(t){let o,i=zn.safeParse(t);if(i.success){let a=i.data;o=typeof a.data[0].embedding=="string"?lt:rt;let p=a.data.map(d=>typeof d.embedding=="string"?{index:d.index,embedding:d.embedding}:{index:d.index,embedding:d.embedding});return {encodingFormat:o,embeddings:p,usage:{totalTokens:a.usage.total_tokens}}}throw new F({info:"Invalid response from model",cause:i.error})}};var Ft="voyage-code-2",cs="Optimized for code retrieval.",Ht=N(V).parse({name:Ft,description:cs,modalities:D,maxInputTokens:16e3,maxOutputTokens:16e3,config:{def:E.base().def,schema:E.base().schema}}),xn=L,Ve=class extends q{constructor(t){super(Ht,t);}};var Gt="voyage-law-2",us="Optimized for legal and long-context retrieval and RAG. Also improved performance across all domains.",Kt=N(V).parse({name:Gt,description:us,modalities:D,maxInputTokens:16e3,maxOutputTokens:16e3,config:{def:E.base().def,schema:E.base().schema}}),vn=L,$e=class extends q{constructor(t){super(Kt,t);}};var Jt="voyage-multilingual-2",gs="Optimized for multilingual retrieval and RAG.",Zt=N(V).parse({name:Jt,description:gs,modalities:D,maxInputTokens:32e3,maxOutputTokens:32e3,config:{def:E.base().def,schema:E.base().schema}}),On=L,Fe=class extends q{constructor(t){super(Zt,t);}};var Wt="voyage-finance-2",hs="Optimized for finance retrieval and RAG.",Xt=N(V).parse({name:Wt,description:hs,modalities:D,maxInputTokens:32e3,maxOutputTokens:32e3,config:{def:E.base().def,schema:E.base().schema}}),En=L,He=class extends q{constructor(t){super(Xt,t);}};var Yt="voyage-3-lite",ys="Optimized for latency and cost.",Qt=N(V).parse({name:Yt,description:ys,modalities:D,maxInputTokens:32e3,maxOutputTokens:32e3,config:{def:E.base().def,schema:E.base().schema}}),_n=L,Ge=class extends q{constructor(t){super(Qt,t);}};var eo="voyage-3",fs="Optimized for quality.",to=N(V).parse({name:eo,description:fs,modalities:D,maxInputTokens:32e3,maxOutputTokens:32e3,config:{def:E.base().def,schema:E.base().schema}}),An=L,Ke=class extends q{constructor(t){super(to,t);}};
5
+ var Jn=Object.defineProperty,Wn=Object.defineProperties;var Zn=Object.getOwnPropertyDescriptors;var ao=Object.getOwnPropertySymbols;var Xn=Object.prototype.hasOwnProperty,Qn=Object.prototype.propertyIsEnumerable;var ge=(o,t)=>(t=Symbol[o])?t:Symbol.for("Symbol."+o),Yn=o=>{throw TypeError(o)};var io=(o,t,n)=>t in o?Jn(o,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[t]=n,f=(o,t)=>{for(var n in t||(t={}))Xn.call(t,n)&&io(o,n,t[n]);if(ao)for(var n of ao(t))Qn.call(t,n)&&io(o,n,t[n]);return o},G=(o,t)=>Wn(o,Zn(t));var w=(o,t,n)=>new Promise((a,i)=>{var p=r=>{try{c(n.next(r));}catch(g){i(g);}},d=r=>{try{c(n.throw(r));}catch(g){i(g);}},c=r=>r.done?a(r.value):Promise.resolve(r.value).then(p,d);c((n=n.apply(o,t)).next());}),so=function(o,t){this[0]=o,this[1]=t;},Ze=(o,t,n)=>{var a=(d,c,r,g)=>{try{var u=n[d](c),y=(c=u.value)instanceof so,k=u.done;Promise.resolve(y?c[0]:c).then(P=>y?a(d==="return"?d:"next",c[1]?{done:P.done,value:P.value}:P,r,g):r({value:P,done:k})).catch(P=>a("throw",P,r,g));}catch(P){g(P);}},i=d=>p[d]=c=>new Promise((r,g)=>a(d,c,r,g)),p={};return n=n.apply(o,t),p[ge("asyncIterator")]=()=>p,i("next"),i("throw"),i("return"),p},ro=o=>{var t=o[ge("asyncIterator")],n=!1,a,i={};return t==null?(t=o[ge("iterator")](),a=p=>i[p]=d=>t[p](d)):(t=t.call(o),a=p=>i[p]=d=>{if(n){if(n=!1,p==="throw")throw d;return d}return n=!0,{done:!1,value:new so(new Promise(c=>{var r=t[p](d);r instanceof Object||Yn("Object expected"),c(r);}),1)}}),i[ge("iterator")]=()=>i,a("next"),"throw"in t?a("throw"):i.throw=p=>{throw p},"return"in t&&a("return"),i};var ne="system",Q="user",E="assistant",de="tool",ea=[ne,Q,E,de],Ye=zod.z.enum(ea),ta=[E],oa=zod.z.enum(ta),co="error",uo="safety",na=zod.z.object({type:zod.z.literal(uo),value:zod.z.object({category:zod.z.string(),probability:zod.z.string(),blocked:zod.z.boolean(),message:zod.z.string()})}),aa=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(co),value:zod.z.discriminatedUnion("type",[na]),metadata:o}),go="partial-error",ia=zod.z.object({type:zod.z.literal(uo),category:zod.z.string().optional(),probability:zod.z.string().optional(),blocked:zod.z.boolean().optional(),message:zod.z.string().optional()}),sa=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(go),value:zod.z.discriminatedUnion("type",[ia]),metadata:o}),K="image",et="base64",ra=["png","jpeg","webp","gif"],la=zod.z.object({type:zod.z.literal(et),base64:zod.z.string(),mediaType:zod.z.enum(ra)}),da="url",pa=zod.z.object({type:zod.z.literal(da),url:zod.z.string()}),ma=zod.z.discriminatedUnion("type",[la,pa]),ca=["low","medium","high","auto"],ua=zod.z.enum(ca),ga=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(K),detail:ua,value:ma,metadata:o}),ho="pdf",ha="base64",ya=zod.z.object({type:zod.z.literal(ha),base64:zod.z.string()}),fa="url",ba=zod.z.object({type:zod.z.literal(fa),url:zod.z.string()}),Ta=zod.z.discriminatedUnion("type",[ya,ba]),Ca=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(ho),value:Ta,file:zod.z.object({name:zod.z.string(),id:zod.z.string(),size:zod.z.number().optional()}),metadata:o}),J="reasoning",he="partial-reasoning",ye="thinking",tt="redacted",Qe=zod.z.object({type:zod.z.literal(ye),thinking:zod.z.string(),signature:zod.z.string()}),yo=zod.z.object({type:zod.z.literal(tt),data:zod.z.string()}),Ma=zod.z.discriminatedUnion("type",[Qe,yo]),ot=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(J),value:Ma,metadata:o}),Ra=zod.z.object({type:zod.z.literal(ye),thinking:Qe.shape.thinking.optional(),signature:Qe.shape.signature.optional()}),ka=zod.z.discriminatedUnion("type",[Ra,yo]),nt=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(he),value:ka,metadata:o}),fo="search-result",bo="google",Sa=zod.z.object({type:zod.z.literal(bo),query:zod.z.string(),responses:zod.z.array(zod.z.object({source:zod.z.string(),url:zod.z.string(),title:zod.z.string(),snippet:zod.z.string().optional()})),references:zod.z.array(zod.z.object({text:zod.z.string(),responseIndices:zod.z.array(zod.z.number()),startIndex:zod.z.number().optional(),endIndex:zod.z.number().optional(),confidenceScores:zod.z.array(zod.z.number()).optional()}))}),va=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(fo),value:zod.z.discriminatedUnion("type",[Sa]),metadata:o}),To="partial-search-result",xa=zod.z.object({type:zod.z.literal(bo),query:zod.z.string().optional(),responses:zod.z.array(zod.z.object({source:zod.z.string().optional(),url:zod.z.string().optional(),title:zod.z.string().optional(),snippet:zod.z.string().optional()})).optional(),references:zod.z.array(zod.z.object({text:zod.z.string().optional(),responseIndices:zod.z.array(zod.z.number()).optional(),startIndex:zod.z.number().optional(),endIndex:zod.z.number().optional(),confidenceScores:zod.z.array(zod.z.number()).optional()})).optional()}),Ea=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(To),value:zod.z.discriminatedUnion("type",[xa]),metadata:o}),_="text",Co=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(_),value:zod.z.string(),metadata:o}),at="partial-text",Mo=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(at),value:zod.z.string(),metadata:o}),j="tool-call",Ro=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(j),index:zod.z.number().int().nonnegative(),id:zod.z.string().min(1),name:zod.z.string().min(1),arguments:zod.z.string(),serverName:zod.z.string().optional(),metadata:o}),it="partial-tool-call",ko=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(it),index:zod.z.number().int().nonnegative(),id:zod.z.string().optional(),name:zod.z.string().optional(),arguments:zod.z.string().optional(),serverName:zod.z.string().optional(),metadata:o}),U="tool-response",So=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(U),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:o}),vo="partial-tool-response",xo=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(vo),index:zod.z.number().int().nonnegative(),id:zod.z.string().optional(),name:zod.z.string().optional(),data:zod.z.string().optional(),apiResponse:zod.z.object({statusCode:zod.z.number().int().nonnegative()}).optional(),metadata:o}),Oa=[_,K,ho,j,U,J,co,fo],Eo=zod.z.enum(Oa),_a=(o=zod.z.undefined(),t=zod.z.undefined(),n=zod.z.undefined(),a=zod.z.undefined(),i=zod.z.undefined(),p=zod.z.undefined(),d=zod.z.undefined(),c=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[Co(o),ga(t),Ca(n),Ro(a),So(i),ot(p),aa(d),va(c)]),Aa=[at,it,he,go,To];zod.z.enum(Aa);var Pa=(o=zod.z.undefined(),t=zod.z.undefined(),n=zod.z.undefined(),a=zod.z.undefined(),i=zod.z.undefined(),p=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[Mo(o),ko(t),nt(a),xo(n),sa(i),Ea(p)]);var st=(o=Ye,t=zod.z.undefined(),n=zod.z.undefined(),a=zod.z.undefined(),i=zod.z.undefined(),p=zod.z.undefined(),d=zod.z.undefined(),c=zod.z.undefined())=>zod.z.object({role:o,content:zod.z.array(_a(t,n,a,i,d,p)),metadata:c}),se=(o=oa,t=zod.z.undefined(),n=zod.z.undefined(),a=zod.z.undefined(),i=zod.z.undefined(),p=zod.z.undefined())=>zod.z.object({role:o,partialContent:Pa(t,n,a,p),metadata:i}),wa=zod.z.object({promptTokens:zod.z.number().nonnegative(),completionTokens:zod.z.number().nonnegative(),totalTokens:zod.z.number().nonnegative()}),lo=zod.z.object({token:zod.z.string(),logProb:zod.z.number(),bytes:zod.z.array(zod.z.number().int()).nullable()}),qa=lo.extend({topLogProbs:zod.z.array(lo)}),Oo=zod.z.array(qa);zod.z.object({messages:zod.z.array(st()),usage:wa.optional(),logProbs:Oo.optional()});var ja=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(se()),usage:ja.optional(),logProbs:Oo.optional()});var fe=(o=zod.z.record(zod.z.string(),zod.z.any()).optional())=>o,Ia=zod.z.object({enabled:zod.z.boolean().default(!0),allowedTools:zod.z.array(zod.z.string().min(1))}),_o=zod.z.object({type:zod.z.literal("url"),url:zod.z.string().url().refine(o=>o.startsWith("https://"),{message:"MCP server URL must start with https://"}),name:zod.z.string().min(1),toolConfiguration:Ia.optional(),authorizationToken:zod.z.string().min(1).optional()}),La=["object","array","number","string","boolean","enum"],po=zod.z.enum(La),Ua=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:zod.z.union([po,zod.z.array(zod.z.union([po,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()}),Ba=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(Ua),additionalProperties:zod.z.literal(!1)});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:Ba}).optional();var Y="text",Ao="token",Na=[Y,Ao],Po=zod.z.enum(Na),za=zod.z.array(zod.z.string().min(1)),Da=zod.z.array(zod.z.array(zod.z.number().int().nonnegative())),wo=(o=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[zod.z.object({modality:zod.z.literal(Y),metadata:o,requests:za}),zod.z.object({modality:zod.z.literal(Ao),metadata:o,requests:Da})]),rt="float",Va=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.array(zod.z.number())}),lt="base64",$a=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.string().base64()}),mo=zod.z.object({totalTokens:zod.z.number().int().nonnegative()});zod.z.discriminatedUnion("encodingFormat",[zod.z.object({encodingFormat:zod.z.literal(rt),embeddings:zod.z.array(Va),usage:mo.optional()}),zod.z.object({encodingFormat:zod.z.literal(lt),embeddings:zod.z.array($a),usage:mo.optional()})]);var Fa=o=>{let t=new WeakSet;return JSON.stringify(o,(n,a)=>{if(typeof a=="object"&&a!==null){if(t.has(a))return;t.add(a);}return a})},Ha=o=>o==null?"unknown error":typeof o=="string"?o:o instanceof Error?o.message:Fa(o),Xe="GatewayBaseError",ee=class qo extends Error{constructor({info:t,cause:n},a){super(`[${a!=null?a:Xe}]: ${t}
6
+ Message: ${Ha(n)}`),this.name=Xe,this.info=t,this.cause=n,this.name=a!=null?a:Xe,Object.setPrototypeOf(this,new.target.prototype);}static isGatewayBaseError(t){return t instanceof qo}toJSON(){return {name:this.name,info:this.info,cause:this.cause,message:this.message,stack:this.stack}}},Ga=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."),Ka=zod.z.object({base:Ga.describe("Base (uncached, non\u2011reasoning) rates")}).describe("Holds the `ChatModelTokenPairPrice` for different categories (e.g., base) within a single pricing tier."),Ja=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:Ka.describe("Price categories and rates for this specific token range.")}).refine(o=>o.maxTokens===null||typeof o.maxTokens=="number"&&o.maxTokens>o.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(Ja).min(1).describe("Pricing tiers (`ChatModelTokenRangePrice`) schedule, sorted by minTokens.")}).superRefine((o,t)=>{let{tokenRanges:n}=o;n[0].minTokens!==0&&t.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",0,"minTokens"],message:"The first tier must have minTokens = 0."});for(let i=1;i<n.length;i++){let p=n[i-1],d=n[i];if(p.maxTokens===null){t.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",i-1,"maxTokens"],message:"Cannot define any tokenRanges after an infinite tier (maxTokens = null)."});break}d.minTokens!==p.maxTokens&&t.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",i,"minTokens"],message:`Tier ${i} minTokens (${d.minTokens}) must equal previous tier's maxTokens (${p.maxTokens}) for contiguity.`}),d.minTokens<p.minTokens&&t.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",i,"minTokens"],message:`tokenRanges must be sorted by ascending minTokens. Tier ${i} (${d.minTokens}) starts before Tier ${i-1} (${p.minTokens}).`});}let a=n[n.length-1];n.every(i=>i.maxTokens!==null||i===a)&&a.maxTokens!==null&&t.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",n.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 Wa="function";var Za=zod.z.enum(["object","array","number","string","boolean","null"]),Xa=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:Za.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(Xa).optional(),required:zod.z.array(zod.z.string()).optional()});var Qa=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 Ya=zod.z.enum(["function"]),ei=zod.z.object({maxAttempts:zod.z.number().int().positive(),initialDelay:zod.z.number().int().positive(),exponentialFactor:zod.z.number().int().positive()}),ti=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:ei.optional()}),oi=zod.z.discriminatedUnion("type",[ti]),ni=zod.z.object({type:Ya,definition:zod.z.object({schema:Qa}),request:oi.optional()}),ai=[Wa];zod.z.enum(ai);var jo=(o=zod.z.undefined())=>zod.z.discriminatedUnion("type",[ni.extend({metadata:o})]),Io=o=>Co().parse({modality:_,value:o}),dt=(o,t,n,a,i)=>Ro().parse({modality:j,index:o,id:t,name:n,arguments:a,serverName:i}),Lo=(o,t,n,a,i,p)=>So().parse({modality:U,index:o,id:t,name:n,data:a,apiResponse:i,metadata:p});var pt=(o,t)=>se().parse({role:o,partialContent:Mo().parse({modality:at,value:t})}),be=(o,t,n,a,i,p)=>se().parse({role:o,partialContent:ko().parse({modality:it,index:t,id:n,name:a,arguments:i,serverName:p})}),Uo=(o,t,n,a,i)=>se().parse({role:o,partialContent:xo().parse({modality:vo,index:t,id:n,name:a,data:i})}),Bo=(o,t)=>ot().parse({modality:J,value:{type:ye,thinking:o,signature:t}});var No=o=>ot().parse({modality:J,value:{type:tt,data:o}});var Te=(o,t,n)=>se().parse({role:o,partialContent:nt().parse({modality:he,value:{type:ye,thinking:t,signature:n}})}),zo=(o,t)=>se().parse({role:o,partialContent:nt().parse({modality:he,value:{type:tt,data:t}})});var ii=Object.defineProperty,Do=Object.getOwnPropertySymbols,si=Object.prototype.hasOwnProperty,ri=Object.prototype.propertyIsEnumerable,Vo=(o,t,n)=>t in o?ii(o,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[t]=n,pe=(o,t)=>{for(var n in t||(t={}))si.call(t,n)&&Vo(o,n,t[n]);if(Do)for(var n of Do(t))ri.call(t,n)&&Vo(o,n,t[n]);return o},$o="ProviderError",mt=class Xo extends ee{constructor({info:t,cause:n}){super({info:t,cause:n},$o),this.name=$o,this.info=t,this.cause=n;}static isProviderError(t){return t instanceof Xo}};var Fo="ModelResponseError",F=class Qo extends ee{constructor({info:t,cause:n}){super({info:t,cause:n},Fo),this.name=Fo,this.cause=n,this.info=t;}static isModelResponseError(t){return t instanceof Qo}},Ho="InvalidModelRequestError",me=class Yo extends ee{constructor({info:t,cause:n}){super({info:t,cause:n},Ho),this.name=Ho,this.cause=n,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidModelRequestError(t){return t instanceof Yo}},Go="InvalidConfigError",W=class en extends ee{constructor({info:t,cause:n}){super({info:t,cause:n},Go),this.name=Go,this.cause=n,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidConfigError(t){return t instanceof en}},Ko="InvalidMessagesError",I=class tn extends ee{constructor({info:t,cause:n}){super({info:t,cause:n},Ko),this.name=Ko,this.cause=n,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidMessagesError(t){return t instanceof tn}},Jo="InvalidToolsError",ct=class on extends ee{constructor({info:t,cause:n}){super({info:t,cause:n},Jo),this.name=Jo,this.cause=n,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidToolsError(t){return t instanceof on}},Wo="InvalidEmbeddingRequestsError",ut=class nn extends ee{constructor({info:t,cause:n}){super({info:t,cause:n},Wo),this.name=Wo,this.info=t,this.cause=n,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidEmbeddingRequestsError(t){return t instanceof nn}},gt="multi-string",an=zod.z.object({type:zod.z.literal(gt),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()}),li=o=>zod.z.array(zod.z.string()).max(o).default([]).optional(),sn=o=>({def:an.parse(pe({type:gt},o)),schema:li(o.max)}),ht="object-schema",rn=zod.z.object({type:zod.z.literal(ht),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),objectSchema:zod.z.any()}),di=o=>o.optional(),ln=o=>({def:rn.parse(pe({type:ht},o)),schema:di(o.objectSchema)}),dn="paired-select",pi=zod.z.object({value:zod.z.string().min(1),label:zod.z.string().min(1)}),Zo=zod.z.object({key:zod.z.string().min(1),label:zod.z.string().min(1),description:zod.z.string().min(1).max(500).optional(),choices:zod.z.array(pi).min(1)}),mi=zod.z.object({type:zod.z.literal(dn),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),fields:zod.z.tuple([Zo,Zo]),uniqueByField:zod.z.string().min(1).optional()});var yt="range",pn=zod.z.object({type:zod.z.literal(yt),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()}),ci=(o,t,n,a)=>zod.z.number().min(o).max(t).step(n).default(a).optional(),ae=o=>({def:pn.parse(pe({type:yt},o)),schema:ci(o.min,o.max,o.step,o.default)}),ft="select-boolean",mn=zod.z.object({type:zod.z.literal(ft),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()}),ui=o=>zod.z.boolean().nullable().default(o).optional(),re=o=>({def:mn.parse(pe({type:ft},o)),schema:ui(o.default)}),bt="select-string",cn=zod.z.object({type:zod.z.literal(bt),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())}),gi=(o,t)=>zod.z.enum(t).nullable().default(o).optional(),ce=o=>({def:cn.parse(pe({type:bt},o)),schema:gi(o.default,o.choices)}),hi=[yt,gt,bt,ht,ft,dn];zod.z.enum(hi);var un=zod.z.discriminatedUnion("type",[pn,an,cn,mn,rn,mi]),C=(o=Ye,t=Eo)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),roles:zod.z.record(o,zod.z.string().min(1).optional()),modalities:zod.z.array(t).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),un),schema:zod.z.instanceof(zod.z.ZodObject)}).refine(n=>{var a,i;let p=Object.keys(n.def),d=Object.keys((i=(a=n.schema)==null?void 0:a.shape)!=null?i:{});return p.every(c=>d.includes(c))&&d.every(c=>p.includes(c))},{message:"Keys in 'config.def' must exactly match keys in 'config.schema'"}),price:zod.z.custom()}),B=(o=Po)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),modalities:zod.z.array(o).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),un),schema:zod.z.instanceof(zod.z.ZodObject)}).refine(t=>{var n,a;let i=Object.keys(t.def),p=Object.keys((a=(n=t.schema)==null?void 0:n.shape)!=null?a:{});return i.every(d=>p.includes(d))&&p.every(d=>i.includes(d))},{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 yi={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."},fi={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."},bi={type:"range",title:"Max reasoning tokens",description:"Specify the total tokens for reasoning, where one token approximates four English characters."},Ti=o=>({type:"multi",title:"Stop sequence",description:`Enter up to ${o} sequences that will halt additional text output. The generated text will exclude these sequences.`}),Ci={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."},Mi={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."},Ri={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."},ki={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."},Si={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."},vi={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."},xi={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."},Ei={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."},Oi={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."},_i={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."},Ai={type:"boolean",title:"Echo",description:"If true, the response will contain the prompt."},Pi={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."},wi={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."},qi={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."},ji={type:"object",title:"MCP servers",description:"MCP servers to use for the model."},A={TEMPERATURE:yi,MAX_TOKENS:fi,STOP:Ti,TOP_A:Ci,TOP_P:Mi,TOP_K:Ri,MIN_P:ki,FREQUENCY_PENALTY:Si,PRESENCE_PENALTY:vi,REPETITION_PENALTY:Ei,SEED:xi,LOG_PROBS:Oi,TOP_LOG_PROBS:_i,ECHO:Ai,RESPONSE_FORMAT:Pi,RESPONSE_FORMAT_WITH_SCHEMA:wi,RESPONSE_SCHEMA:qi,MAX_REASONING_TOKENS:bi,MCP_SERVERS:ji};var Ce=o=>Object.fromEntries(Object.entries(o).filter(([t,n])=>n!=null));var ie=o=>o==null?void 0:o.replace(/\/$/,"");var Tt=ae({param:"temperature",title:A.TEMPERATURE.title,description:A.TEMPERATURE.description,min:0,max:1,step:.01,default:1}),Ct=o=>ae({param:"max_tokens",title:A.MAX_TOKENS.title,description:A.MAX_TOKENS.description,min:0,max:o,step:1,default:0}),Mt=o=>sn({param:"stop_sequences",title:A.STOP(o).title,description:A.STOP(o).description,max:o}),Rt=ae({param:"top_p",title:A.TOP_P.title,description:A.TOP_P.description,min:0,max:1,step:.01,default:1}),kt=ae({param:"top_k",title:A.TOP_K.title,description:A.TOP_K.description,min:0,max:1,step:.01,default:1}),St=ce({param:"tool_choice",title:"Tool choice",description:"Controls which (if any) tool is called by the model. 'any' means the model will call any of the provided tools. 'auto' means the model can pick between generating a message or calling a tool.",default:"auto",choices:["auto","any"]}),vt=re({param:"mcp",title:"MCP",description:"Enable or disable Model Context Protocol (MCP) functionality for this model.",default:!1}),xt=ln({param:"mcp_servers",title:A.MCP_SERVERS.title,description:A.MCP_SERVERS.description,objectSchema:zod.z.array(_o)});var Me=(o,t)=>zod.z.object({temperature:Tt.schema,maxTokens:Ct(o).schema,stop:Mt(t).schema,topP:Rt.schema,topK:kt.schema,toolChoice:St.schema,mcp:vt.schema,mcpServers:xt.schema}),Re=(o,t)=>({temperature:Tt.def,maxTokens:Ct(o).def,stop:Mt(t).def,topP:Rt.def,topK:kt.def,toolChoice:St.def,mcp:vt.def,mcpServers:xt.def});var gn=(o,t)=>ae({param:"max_reasoning_tokens",title:A.MAX_REASONING_TOKENS.title,description:A.MAX_REASONING_TOKENS.description,min:o,max:t,step:1,default:0}),hn=re({param:"reasoning_enabled",title:"Reasoning Enabled",description:`Controls whether the model is allowed to think for a longer period of time before generating a response.
7
+ This can be useful for complex tasks that require more time to think.`,default:!1}),yn=(o,t,n,a)=>G(f({},Re(o,t)),{reasoningEnabled:hn.def,maxReasoningTokens:gn(n,a).def}),fn=(o,t,n,a)=>Me(o,t).extend({reasoningEnabled:hn.schema,maxReasoningTokens:gn(n,a).schema});var Et=ce({param:"encoding_format",title:"Encoding format",description:"Select the encoding format for the word embedding.",default:"",choices:["base64",""]}),Ot=ce({param:"input_type",title:"Input type",description:"Select the input type for the word embedding.",default:"",choices:["query","document",""]}),_t=re({param:"truncation",title:"Truncation",description:"Select the truncation for the word embedding.",default:!0});var bn=()=>zod.z.object({encodingFormat:Et.schema,inputType:Ot.schema,truncation:_t.schema}),Tn=()=>({encodingFormat:Et.def,inputType:Ot.def,truncation:_t.def});var h={base:(o,t)=>({def:Re(o,t),schema:Me(o,t)}),extendedThinking:(o,t,n,a)=>({def:yn(o,t,n,a),schema:fn(o,t,n,a)})},O={base:()=>({def:Tn(),schema:bn()})};var Bi="anthropic",te=class{constructor(){this.version="v1";this.name=Bi;this.chatModelFactories={[Ut]:{model:Ue,modelOptions:En,modelSchema:Bt},[Vt]:{model:De,modelOptions:An,modelSchema:$t},[zt]:{model:ze,modelOptions:_n,modelSchema:Dt},[Pe]:{model:we,modelOptions:Sn,modelSchema:jt},[qe]:{model:je,modelOptions:vn,modelSchema:It},[Be]:{model:Ne,modelOptions:On,modelSchema:Nt},[Ie]:{model:Le,modelOptions:xn,modelSchema:Lt},[ve]:{model:xe,modelOptions:Mn,modelSchema:Pt},[_e]:{model:Ae,modelOptions:kn,modelSchema:qt},[ke]:{model:Se,modelOptions:Cn,modelSchema:At},[Ee]:{model:Oe,modelOptions:Rn,modelSchema:wt}};this.embeddingModelFactories={[eo]:{model:Ke,modelOptions:Ln,modelSchema:to},[Qt]:{model:Ge,modelOptions:In,modelSchema:Yt},[Ft]:{model:Ve,modelOptions:Pn,modelSchema:Ht},[Gt]:{model:$e,modelOptions:wn,modelSchema:Kt},[Jt]:{model:Fe,modelOptions:qn,modelSchema:Wt},[Zt]:{model:He,modelOptions:jn,modelSchema:Xt}};}chatModelLiterals(){return Object.keys(this.chatModelFactories)}chatModelSchemas(){return Object.keys(this.chatModelFactories).reduce((t,n)=>(t[n]=this.chatModelFactories[n].modelSchema,t),{})}chatModel(t){let n=t.modelName;if(!(n in this.chatModelFactories))throw new mt({info:`Anthropic chat model: ${n} not found`,cause:new Error(`Anthropic chat model: ${n} not found, available chat models:
8
+ ${this.chatModelLiterals().join(", ")}`)});let a=this.chatModelFactories[n].model,i=this.chatModelFactories[n].modelOptions.parse(t);return new a(i)}embeddingModelLiterals(){return Object.keys(this.embeddingModelFactories)}embeddingModelSchemas(){return Object.keys(this.embeddingModelFactories).reduce((t,n)=>(t[n]=this.embeddingModelFactories[n].modelSchema,t),{})}embeddingModel(t){let n=t.modelName;if(!(n in this.embeddingModelFactories))throw new mt({info:`Anthropic embedding model: ${n} not found`,cause:new Error(`Anthropic embedding model: ${n} not found, available embedding models:
9
+ ${this.embeddingModelLiterals().join(", ")}`)});let a=this.embeddingModelFactories[n].model,i=this.embeddingModelFactories[n].modelOptions.parse(t);return new a(i)}};te.chatBaseUrl="https://api.anthropic.com/v1",te.embeddingBaseUrl="https://api.voyageai.com/v1";var x={"claude-3-opus-20240229":{modelName:"claude-3-opus-20240229",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:15,outputPricePerMillion:75}}}]},"claude-3-sonnet-20240229":{modelName:"claude-3-sonnet-20240229",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:3,outputPricePerMillion:15}}}]},"claude-3-5-sonnet-20240620":{modelName:"claude-3-5-sonnet-20240620",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:3,outputPricePerMillion:15}}}]},"claude-3-5-sonnet-20241022":{modelName:"claude-3-5-sonnet-20241022",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:3,outputPricePerMillion:15}}}]},"claude-3-7-sonnet-20250219":{modelName:"claude-3-7-sonnet-20250219",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:3,outputPricePerMillion:15}}}]},"claude-3-haiku-20240307":{modelName:"claude-3-haiku-20240307",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.25,outputPricePerMillion:1.25}}}]},"claude-3-haiku-20241022":{modelName:"claude-3-haiku-20241022",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.25,outputPricePerMillion:1.25}}}]},"claude-3-5-haiku-20241022":{modelName:"claude-3-5-haiku-20241022",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.8,outputPricePerMillion:4}}}]},"claude-4-sonnet-20250514":{modelName:"claude-4-sonnet-20250514",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:3,outputPricePerMillion:15}}}]},"claude-4-opus-20250514":{modelName:"claude-4-opus-20250514",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:15,outputPricePerMillion:75}}}]},"claude-sonnet-4-5-20250929":{modelName:"claude-sonnet-4-5-20250929",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:3,outputPricePerMillion:15}}}]},"claude-opus-4-5-20251101":{modelName:"claude-opus-4-5-20251101",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:5,outputPricePerMillion:25}}}]}};var M=zod.z.enum([ne,Q,E,de]),R={system:ne,user:Q,assistant:E,tool:Q};var N=[_,K,j,U],z=zod.z.enum([_,K,j,U]),Z=[_,K,j,U,J],X=zod.z.enum([_,K,j,U,J]);var Di=zod.z.object({type:zod.z.literal("text"),text:zod.z.string()}),Vi=zod.z.object({type:zod.z.literal("tool_use"),id:zod.z.string(),name:zod.z.string(),input:zod.z.record(zod.z.any())}),$i=zod.z.object({type:zod.z.literal("thinking"),thinking:zod.z.string(),signature:zod.z.string()}),Fi=zod.z.object({type:zod.z.literal("redacted_thinking"),data:zod.z.string()}),Hi=zod.z.object({type:zod.z.literal("mcp_tool_use"),id:zod.z.string(),name:zod.z.string(),server_name:zod.z.string(),input:zod.z.record(zod.z.any())}),Gi=zod.z.object({type:zod.z.literal("mcp_tool_result"),tool_use_id:zod.z.string(),is_error:zod.z.boolean(),content:zod.z.array(zod.z.any())}),Bn=zod.z.object({content:zod.z.array(zod.z.discriminatedUnion("type",[Di,Vi,$i,Fi,Hi,Gi])),id:zod.z.string(),model:zod.z.string(),role:zod.z.string(),stop_reason:zod.z.string(),stop_sequence:zod.z.null(),type:zod.z.literal("message"),usage:zod.z.object({input_tokens:zod.z.number(),output_tokens:zod.z.number(),cache_creation_input_tokens:zod.z.number().nullish(),cache_read_input_tokens:zod.z.number().nullish()})}),Nn=zod.z.object({type:zod.z.literal("message_start"),message:zod.z.object({id:zod.z.string(),type:zod.z.literal("message"),role:zod.z.string(),model:zod.z.string(),stop_reason:zod.z.string().nullable(),stop_sequence:zod.z.string().nullable(),content:zod.z.array(zod.z.any()),usage:zod.z.object({input_tokens:zod.z.number(),output_tokens:zod.z.number()})})}),zn=zod.z.object({type:zod.z.literal("message_delta"),delta:zod.z.object({stop_reason:zod.z.string().nullable(),stop_sequence:zod.z.string().nullable()}),usage:zod.z.object({output_tokens:zod.z.number()})}),Ki=zod.z.object({type:zod.z.literal("text"),text:zod.z.string()}),Ji=zod.z.object({type:zod.z.literal("tool_use"),id:zod.z.string(),name:zod.z.string(),input:zod.z.object({})}),Wi=zod.z.object({type:zod.z.literal("thinking"),thinking:zod.z.string()}),Zi=zod.z.object({type:zod.z.literal("redacted_thinking"),data:zod.z.string()}),Xi=zod.z.object({type:zod.z.literal("mcp_tool_use"),id:zod.z.string(),name:zod.z.string(),server_name:zod.z.string(),input:zod.z.record(zod.z.any())}),Qi=zod.z.object({type:zod.z.literal("mcp_tool_result"),tool_use_id:zod.z.string(),is_error:zod.z.boolean(),content:zod.z.array(zod.z.any())}),Dn=zod.z.object({type:zod.z.literal("content_block_start"),index:zod.z.number(),content_block:zod.z.discriminatedUnion("type",[Ki,Ji,Wi,Zi,Xi,Qi])}),Yi=zod.z.object({type:zod.z.literal("text_delta"),text:zod.z.string()}),es=zod.z.object({type:zod.z.literal("input_json_delta"),partial_json:zod.z.string()}),ts=zod.z.object({type:zod.z.literal("thinking_delta"),thinking:zod.z.string()}),os=zod.z.object({type:zod.z.literal("signature_delta"),signature:zod.z.string()}),Vn=zod.z.object({type:zod.z.literal("content_block_delta"),index:zod.z.number(),delta:zod.z.discriminatedUnion("type",[Yi,es,ts,os])});var ns=zod.z.object({type:zod.z.literal("thinking"),thinking:zod.z.string().optional(),signature:zod.z.string().optional()}),as=zod.z.object({type:zod.z.literal("redacted_thinking"),data:zod.z.string()}),is=zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1).optional(),input_schema:zod.z.any()}),ss=zod.z.object({type:zod.z.enum(["auto","any"])}),rs=zod.z.object({type:zod.z.literal("tool"),name:zod.z.string().min(1)}),oo=zod.z.object({text:zod.z.string().min(1),type:zod.z.literal("text")}),$n=zod.z.object({type:zod.z.literal("image"),source:zod.z.object({type:zod.z.literal("base64"),media_type:zod.z.enum(["image/jpeg","image/png","image/gif","image/webp"]),data:zod.z.string().base64()})}),jr=zod.z.object({id:zod.z.string().min(1),type:zod.z.literal("tool_use"),name:zod.z.string().min(1),input:zod.z.record(zod.z.any())}),Fn=zod.z.object({type:zod.z.literal("tool_result"),tool_use_id:zod.z.string().min(1),content:zod.z.string().min(1).or(zod.z.array(zod.z.union([oo,$n])).min(1))}),Ir=zod.z.object({type:zod.z.literal("mcp_tool_use"),id:zod.z.string().min(1),name:zod.z.string().min(1),server_name:zod.z.string().min(1),input:zod.z.record(zod.z.any())}),Lr=zod.z.object({type:zod.z.literal("mcp_tool_result"),tool_use_id:zod.z.string().min(1),is_error:zod.z.boolean().default(!1),content:zod.z.array(zod.z.any())}),ls=zod.z.object({enabled:zod.z.boolean().default(!0),allowed_tools:zod.z.array(zod.z.string().min(1)).optional()}),ds=zod.z.object({type:zod.z.literal("url"),url:zod.z.string().url().refine(o=>o.startsWith("https://"),{message:"MCP server URL must start with https://"}),name:zod.z.string().min(1),tool_configuration:ls.optional(),authorization_token:zod.z.string().min(1).optional()}),ps=zod.z.object({role:zod.z.literal("user"),content:zod.z.string().min(1).or(zod.z.array(zod.z.union([oo,$n,Fn])).min(1))}),ms=zod.z.object({role:zod.z.literal("assistant"),content:zod.z.string().min(1).or(zod.z.array(zod.z.union([oo,Fn,ns,as])).min(1))}),cs=zod.z.union([ps,ms]),Hn=zod.z.object({model:zod.z.string().min(1).optional(),messages:zod.z.array(cs).min(1),system:zod.z.string().min(1).optional(),max_tokens:zod.z.number().min(0).optional(),stop_sequences:zod.z.array(zod.z.string().min(1)).optional(),temperature:zod.z.number().min(0).max(1).optional(),tool_choice:zod.z.union([ss,rs]).optional(),tools:zod.z.array(is).min(1).optional(),top_p:zod.z.number().min(0).max(1).optional(),top_k:zod.z.number().min(0).optional(),mcp_servers:zod.z.array(ds).min(1).optional()});var T=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string(),completeChatUrl:zod.z.string().url().optional(),streamChatUrl:zod.z.string().url().optional()}),b=class{constructor(t,n){this.version="v1";let a=T.parse(n);this.modelSchema=t,this.modelName=a.modelName,this.apiKey=a.apiKey,this.baseUrl=ie(te.chatBaseUrl),this.completeChatUrl=ie(a.completeChatUrl||`${this.baseUrl}/messages`),this.streamChatUrl=ie(a.streamChatUrl||`${this.baseUrl}/messages`);}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {"x-api-key":`${this.apiKey}`,"anthropic-version":"2023-06-01","content-type":"application/json","anthropic-dangerous-direct-browser-access":"true"}}getDefaultParams(){return {model:this.modelName}}getRetryDelay(t){let n=0,a=!0;return t["x-should-retry"]&&(a=t["x-should-retry"].toLowerCase()!=="false"),t["retry-after"]&&(n=parseInt(t["retry-after"])*1e3),{shouldRetry:a,delayMs:n}}getTokenCount(t){return t.reduce((n,a)=>n+a.content.map(i=>i.modality==="text"?i.value:"").join(" ").length,0)}transformModelRequest(t){let n=Hn.safeParse(t);if(!n.success)throw new me({info:"Invalid model request",cause:n.error});let a=n.data,i=a.model;if(a.tool_choice&&(!a.tools||a.tools.length===0))throw new me({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'tool_choice' is specified")});let p={};a.tool_choice&&(a.tool_choice.type==="tool"?p.toolChoice=a.tool_choice.name:p.toolChoice=a.tool_choice.type),p.maxTokens=a.max_tokens,p.temperature=a.temperature,p.topP=a.top_p,p.topK=a.top_k,p.stop=a.stop_sequences;let d=fe().parse(Ce(p)),c=[],r={};a.system&&c.push({role:ne,content:[{modality:_,value:a.system}]}),a.messages.forEach(u=>{let y=u.role;switch(y){case"user":{let k=u.content;if(typeof k=="string")c.push({role:y,content:[{modality:_,value:k}]});else {let P=k.map(S=>{if(S.type==="text")return {modality:_,value:S.text};if(S.type==="image"){let v="auto",H=S.source.media_type.split("/")[1];return {modality:K,detail:v,value:{type:et,mediaType:H,base64:S.source.data}}}else return {modality:U,id:S.tool_use_id,index:r[S.tool_use_id].index,name:r[S.tool_use_id].name,data:typeof S.content=="string"?S.content:JSON.stringify(S.content)}});c.push({role:y,content:P});}}break;case"assistant":{let k=u.content;if(typeof k=="string")c.push({role:y,content:[{modality:_,value:k}]});else {let P=k.map((S,v)=>{if(S.type==="text")return {modality:_,value:S.text};{let H={modality:j,id:S.id,index:v,name:S.name,arguments:JSON.stringify(S.input)};return r[S.id]=H,H}});c.push({role:y,content:P});}}break}});let g=[];return a.tools&&a.tools.forEach(u=>{g.push({type:"function",definition:{schema:{name:u.name,description:u.description||"",parameters:u.input_schema}}});}),{modelName:i,config:d,messages:c,tools:g.length>0?g:void 0}}transformConfig(t,n,a){let i=t.toolChoice,p=t.reasoningEnabled,d=t.maxReasoningTokens,c=t.mcp,r=t.mcpServers,g=f({},t);delete g.toolChoice,delete g.reasoningEnabled,delete g.maxReasoningTokens,delete g.mcp,delete g.mcpServers;let u=this.modelSchema.config.schema.safeParse(g);if(!u.success)throw new W({info:`Invalid config for model : '${this.modelName}'`,cause:u.error});let y=u.data;i!==void 0&&(y.toolChoice=i),Object.keys(y).forEach(v=>{if(!(v in this.modelSchema.config.def))throw new W({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${v}',
10
+ available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})});let k=Object.keys(y).reduce((v,H)=>{let le=this.modelSchema.config.def[H],We=le.param,no=y[H];return We==="max_tokens"&&le.type==="range"&&no===0?v[We]=le.max:v[We]=no,v},{});if(!k.max_tokens){let v=this.modelSchema.config.def.maxTokens;k.max_tokens=v.max;}if("tool_choice"in k&&k.tool_choice!==void 0){let v=k.tool_choice;if(!a||a&&a.length===0)throw new W({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'toolChoice' is specified")});if(a&&a.length>0){let H=this.modelSchema.config.def.toolChoice;if(H.choices.includes(v))k.tool_choice={type:v};else if(a.map(le=>le.definition.schema.name).includes(v))k.tool_choice={type:"tool",name:v};else throw new W({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`toolChoice : '${v}' is not part of provided 'tools' names or
11
+ one of [${H.choices.join(", ")}]`)})}}let P=p!==void 0,S=d!==void 0;if(P!==S)throw new W({info:`Invalid extended thinking config for model: '${this.modelName}'`,cause:new Error("Both 'reasoningEnabled' and 'maxReasoningTokens' must be defined together.")});if(P&&S){let v=k.max_tokens;if(p)if(d<v)k.thinking={type:"enabled",budget_tokens:d};else throw new W({info:`Invalid extended thinking token budget for model: '${this.modelName}'`,cause:new Error(`maxReasoningTokens (${d}) must be less than max_tokens (${v})`)})}return c&&r&&(k.mcp_servers=r),k}transformMessages(t){if(!t||t&&t.length===0)return {messages:[]};let n=d=>{let c=d.match(/^data:image\/[a-zA-Z]+;base64,/);return c?d.substring(c[0].length):d},a=t.map(d=>{let c=st().safeParse(d);if(!c.success)throw new I({info:"Invalid messages",cause:c.error});return c.data});a.forEach(d=>{d.content.forEach(c=>{if(!this.modelSchema.modalities.includes(c.modality))throw new I({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support modality : '${c.modality}', available modalities : [${this.modelSchema.modalities.join(", ")}]`)})});}),a.forEach(d=>{if(!Object.keys(this.modelSchema.roles).includes(d.role))throw new I({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support role : '${d.role}', available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})});let i="",p=[];if(a.forEach(d=>{switch(d.role){case ne:{d.content.forEach(c=>{if(c.modality===_)i+=c.value;else throw new I({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${d.role}' cannot have content with modality : '${c.modality}'`)})});break}case E:{let c=[];d.content.forEach(r=>{if(r.modality===_)c.push({type:"text",text:r.value});else if(r.modality===j)r.serverName?c.push({type:"mcp_tool_use",id:r.id,name:r.name,server_name:r.serverName,input:JSON.parse(r.arguments)}):c.push({type:"tool_use",id:r.id,name:r.name,input:JSON.parse(r.arguments)});else if(r.modality===J&&r.value.type==="thinking")c.push({type:"thinking",thinking:r.value.thinking,signature:r.value.signature});else if(r.modality===J&&r.value.type==="redacted")c.push({type:"redacted_thinking",data:r.value.data});else if(r.modality===U)c.push({type:"mcp_tool_result",tool_use_id:r.id,content:JSON.parse(r.data),is_error:r.apiResponse&&r.apiResponse.statusCode!==200||!1});else throw new I({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${d.role}' cannot have content with modality : '${r.modality}'`)})}),p.push({role:this.modelSchema.roles[d.role],content:c});break}case Q:{let c=[];d.content.forEach(r=>{if(r.modality===_)c.push({type:"text",text:r.value});else if(r.modality===K){if(r.value.type==="base64"){let g=r.value.base64;g=n(g),c.push({type:"image",source:{type:"base64",media_type:`image/${r.value.mediaType}`,data:g}});}else if(r.value.type==="url")throw new I({info:`Invalid message 'modality' for model : ${this.modelName}`,cause:new Error(`model: '${this.modelName}' does not support image content type: '${r.value.type}'`)})}else throw new I({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${d.role}' cannot have content with modality : '${r.modality}'`)})}),p.push({role:this.modelSchema.roles[d.role],content:c});break}case de:{let c=[];d.content.forEach(r=>{if(r.modality===U)c.push({type:"tool_result",tool_use_id:r.id,content:r.data});else throw new I({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${d.role}' cannot have content with modality : '${r.modality}'`)})}),p.push({role:this.modelSchema.roles[d.role],content:c});break}default:throw new I({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`role : '${d.role}' is not supported,
12
+ available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}}),p[0].role!==this.modelSchema.roles[Q])throw new I({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' requires first message to be from user`)});return {system:i,messages:p}}transformTools(t){if(!this.modelSchema.modalities.includes(j))throw new ct({info:`Invalid tool 'modality' for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' does not support tool modality : '${j}'`)});return !t||t&&t.length===0?{tools:[]}:{tools:t.map(i=>{let p=jo().safeParse(i);if(!p.success)throw new ct({info:"Invalid tools",cause:p.error});return p.data}).map(i=>({name:i.definition.schema.name,description:i.definition.schema.description,input_schema:i.definition.schema.parameters}))}}getCompleteChatUrl(t,n,a){return w(this,null,function*(){return new Promise(i=>{i(this.completeChatUrl);})})}getCompleteChatHeaders(t,n,a){return w(this,null,function*(){let i=this.getDefaultHeaders();if(t&&t.mcp&&t.mcpServers){let p=i["anthropic-beta"],d="mcp-client-2025-04-04";p?i=G(f({},i),{"anthropic-beta":`${p},${d}`}):i=G(f({},i),{"anthropic-beta":d});}return new Promise(p=>{p(i);})})}getCompleteChatData(t,n,a){return w(this,null,function*(){let i=this.transformConfig(t,n,a),p=this.transformMessages(n);if(p.messages&&p.messages.length===0)throw new I({info:"Messages are required",cause:new Error("Messages are required")});let d=a?this.transformTools(a):{};return new Promise(c=>{c(f(f(f(f({},this.getDefaultParams()),i),p),d));})})}transformCompleteChatResponse(t){let n=Bn.safeParse(t);if(n.success){let a=n.data,p=a.content.map((r,g)=>{if(r.type==="text")return Io(r.text);if(r.type==="tool_use")return dt(g,r.id,r.name,JSON.stringify(r.input));if(r.type==="thinking")return Bo(r.thinking,r.signature);if(r.type==="redacted_thinking")return No(r.data);if(r.type==="mcp_tool_use")return dt(g,r.id,r.name,JSON.stringify(r.input),r.server_name);if(r.type==="mcp_tool_result")return Lo(g,r.tool_use_id,"mcp_tool_result",JSON.stringify(r.content),{statusCode:r.is_error?500:200})}),d=[{role:E,content:p}],c={promptTokens:a.usage.input_tokens,completionTokens:a.usage.output_tokens,totalTokens:a.usage.input_tokens+a.usage.output_tokens};return {messages:d,usage:c,logProbs:[]}}throw new F({info:"Invalid response from model",cause:n.error})}getStreamChatUrl(t,n,a){return w(this,null,function*(){return new Promise(i=>{i(this.streamChatUrl);})})}getStreamChatHeaders(t,n,a){return w(this,null,function*(){let i=this.getDefaultHeaders();if(t&&t.mcp&&t.mcpServers){let p=i["anthropic-beta"],d="mcp-client-2025-04-04";p?i=G(f({},i),{"anthropic-beta":`${p},${d}`}):i=G(f({},i),{"anthropic-beta":d});}return new Promise(p=>{p(i);})})}getStreamChatData(t,n,a){return w(this,null,function*(){let i=this.transformConfig(t,n,a),p=this.transformMessages(n);if(p.messages&&p.messages.length===0)throw new I({info:"Messages are required",cause:new Error("Messages are required")});let d=a?this.transformTools(a):{};return new Promise(c=>{c(f(f(f(f({stream:!0},this.getDefaultParams()),i),p),d));})})}transformStreamChatResponseChunk(t,n){return Ze(this,null,function*(){let a=n+t,i=[],p="",d=0;for(;d<a.length;){let c=a.indexOf(`
13
+ `,d);if(c===-1){p=a.substring(d);break}else {let r=a.substring(d,c).trim();r&&i.push(r),d=c+1;}}for(let c of i)if(c.startsWith("data: {")&&c.endsWith("}")){let r;try{r=JSON.parse(c.substring(6));}catch(g){throw new F({info:`Malformed JSON received in stream : ${r}`,cause:g})}if("type"in r){if(r.type==="message_stop")return;if(r.type==="message_start"){let g=Nn.safeParse(r);if(g.success){let u=g.data;yield {partialResponse:{partialMessages:[],usage:{promptTokens:u.message.usage.input_tokens,completionTokens:u.message.usage.output_tokens,totalTokens:u.message.usage.input_tokens+u.message.usage.output_tokens}},buffer:n};}else throw new F({info:"Invalid response from model",cause:g.error})}else if(r.type==="message_delta"){let g=zn.safeParse(r);if(g.success){let u=g.data;yield {partialResponse:{partialMessages:[],usage:{promptTokens:void 0,completionTokens:u.usage.output_tokens,totalTokens:u.usage.output_tokens}},buffer:n};}else throw new F({info:"Invalid response from model",cause:g.error})}else if(r.type==="content_block_start"){let g=Dn.safeParse(r);if(g.success){let u=g.data,y=[];u.content_block.type==="text"?y.push(pt(E,u.content_block.text)):u.content_block.type==="tool_use"?y.push(be(E,u.index,u.content_block.id,u.content_block.name,"")):u.content_block.type==="thinking"?y.push(Te(E,u.content_block.thinking)):u.content_block.type==="redacted_thinking"?y.push(zo(E,u.content_block.data)):u.content_block.type==="mcp_tool_use"?y.push(be(E,u.index,u.content_block.id,u.content_block.name,JSON.stringify(u.content_block.input),u.content_block.server_name)):u.content_block.type==="mcp_tool_result"&&y.push(Uo(E,u.index,u.content_block.tool_use_id,"mcp_tool_result",JSON.stringify(u.content_block.content))),yield {partialResponse:{partialMessages:y},buffer:n};}else throw new F({info:"Invalid response from model",cause:g.error})}else if(r.type==="content_block_delta"){let g=Vn.safeParse(r);if(g.success){let u=g.data,y=[];u.delta.type==="text_delta"?y.push(pt(E,u.delta.text)):u.delta.type==="input_json_delta"?y.push(be(E,u.index,"","",u.delta.partial_json)):u.delta.type==="thinking_delta"?y.push(Te(E,u.delta.thinking)):u.delta.type==="signature_delta"&&y.push(Te(E,void 0,u.delta.signature)),yield {partialResponse:{partialMessages:y},buffer:n};}else throw new F({info:"Invalid response from model",cause:g.error})}}else throw new F({info:"Invalid JSON received in stream",cause:new Error(`Invalid JSON received in stream, expected 'type' property, received: ${JSON.stringify(r)}`)})}yield {partialResponse:{partialMessages:[]},buffer:p};})}transformProxyStreamChatResponseChunk(t,n,a,i,p){return Ze(this,null,function*(){yield*ro(this.transformStreamChatResponseChunk(t,n));})}getProxyStreamChatUrl(t,n,a){return w(this,null,function*(){return new Promise(i=>{i(this.streamChatUrl);})})}getProxyCompleteChatUrl(t,n,a){return w(this,null,function*(){return new Promise(i=>{i(this.completeChatUrl);})})}getProxyCompleteChatHeaders(t,n,a){return w(this,null,function*(){if(!n)return {};let i=f({},n);return delete i.host,delete i["content-length"],i})}getProxyStreamChatHeaders(t,n,a){return w(this,null,function*(){return yield this.getProxyCompleteChatHeaders(t,n,a)})}getModelPricing(){if(!(this.modelName in x))throw new F({info:`Invalid model pricing for model : '${this.modelName}'`,cause:new Error(`No pricing configuration found for model "${this.modelName}"`)});return x[this.modelName]}};var ke="claude-4-opus-20250514",us="Our high-performance model with exceptional reasoning and efficiency. Training cutoff: March 2025.",At=C(M,X).parse({name:ke,description:us,maxInputTokens:2e5,maxOutputTokens:32e3,maxReasoningTokens:32e3,roles:R,modalities:Z,config:{def:h.extendedThinking(32e3,4,1024,32e3).def,schema:h.extendedThinking(32e3,4,1024,32e3).schema},price:x[ke]}),Cn=T,Se=class extends b{constructor(t){super(At,t);}};var ve="claude-4-sonnet-20250514",gs="Our most capable and intelligent model yet. Training cutoff: March 2025.",Pt=C(M,X).parse({name:ve,description:gs,maxInputTokens:2e5,maxOutputTokens:64e3,maxReasoningTokens:64e3,roles:R,modalities:Z,config:{def:h.extendedThinking(64e3,4,1024,64e3).def,schema:h.extendedThinking(64e3,4,1024,64e3).schema},price:x[ve]}),Mn=T,xe=class extends b{constructor(t){super(Pt,t);}};var Ee="claude-opus-4-5-20251101",hs="Premium model combining maximum intelligence with practical performance. Ideal for complex specialized tasks, professional software engineering, and advanced agents. Training cutoff: August 2025.",wt=C(M,X).parse({name:Ee,description:hs,maxInputTokens:2e5,maxOutputTokens:64e3,maxReasoningTokens:64e3,roles:R,modalities:Z,config:{def:h.extendedThinking(64e3,4,1024,64e3).def,schema:h.extendedThinking(64e3,4,1024,64e3).schema},price:x[Ee]}),Rn=T,Oe=class extends b{constructor(t){super(wt,t);}};var _e="claude-sonnet-4-5-20250929",ys="Our best model for complex agents and coding, with the highest intelligence across most tasks. Training cutoff: July 2025.",qt=C(M,X).parse({name:_e,description:ys,maxInputTokens:2e5,maxOutputTokens:64e3,maxReasoningTokens:64e3,roles:R,modalities:Z,config:{def:h.extendedThinking(64e3,4,1024,64e3).def,schema:h.extendedThinking(64e3,4,1024,64e3).schema},price:x[_e]}),kn=T,Ae=class extends b{constructor(t){super(qt,t);}};var Pe="claude-3-5-sonnet-20240620",fs="Most intelligent model. Highest level of intelligence and capability.",jt=C(M,z).parse({name:Pe,description:fs,maxInputTokens:2e5,maxOutputTokens:8192,roles:R,modalities:N,config:{def:h.base(8192,4).def,schema:h.base(8192,4).schema},price:x[Pe]}),Sn=T,we=class extends b{constructor(t){super(jt,t);}};var qe="claude-3-5-sonnet-20241022",bs="Most intelligent model. Highest level of intelligence and capability.",It=C(M,z).parse({name:qe,description:bs,maxInputTokens:2e5,maxOutputTokens:8192,roles:R,modalities:N,config:{def:h.base(8192,4).def,schema:h.base(8192,4).schema},price:x[qe]}),vn=T,je=class extends b{constructor(t){super(It,t);}};var Ie="claude-3-7-sonnet-20250219",Ts="Most intelligent model. Highest level of intelligence and capability.",Lt=C(M,X).parse({name:Ie,description:Ts,maxInputTokens:2e5,maxOutputTokens:128e3,maxReasoningTokens:64e3,roles:R,modalities:Z,config:{def:h.extendedThinking(128e3,4,1024,64e3).def,schema:h.extendedThinking(128e3,4,1024,64e3).schema},price:x[Ie]}),xn=T,Le=class extends b{constructor(t){super(Lt,t);}getDefaultHeaders(){let t=super.getDefaultHeaders(),n=t["anthropic-beta"],a="output-128k-2025-02-19";return n?t=G(f({},t),{"anthropic-beta":`${n},${a}`}):t=G(f({},t),{"anthropic-beta":a}),t}};var Ut="claude-3-haiku-20240307",Cs="Fastest and most compact model for near-instant responsiveness. Quick and accurate targeted performance.",Bt=C(M,z).parse({name:Ut,description:Cs,maxInputTokens:2e5,maxOutputTokens:4096,roles:R,modalities:N,config:{def:h.base(4096,4).def,schema:h.base(4096,4).schema}}),En=T,Ue=class extends b{constructor(t){super(Bt,t);}};var Be="claude-3-5-haiku-20241022",Ms="Our fastest model with intelligence at blazing speeds.",Nt=C(M,z).parse({name:Be,description:Ms,maxInputTokens:2e5,maxOutputTokens:8192,roles:R,modalities:N,config:{def:h.base(8192,4).def,schema:h.base(8192,4).schema},price:x[Be]}),On=T,Ne=class extends b{constructor(t){super(Nt,t);}};var zt="claude-3-opus-20240229",Rs="Powerful model for highly complex tasks. Top-level performance, intelligence, fluency, and understanding.",Dt=C(M,z).parse({name:zt,description:Rs,maxInputTokens:2e5,maxOutputTokens:4096,roles:R,modalities:N,config:{def:h.base(4096,4).def,schema:h.base(4096,4).schema}}),_n=T,ze=class extends b{constructor(t){super(Dt,t);}};var Vt="claude-3-sonnet-20240229",ks="Balance of intelligence and speed. Strong utility, balanced for scaled deployments.",$t=C(M,z).parse({name:Vt,description:ks,maxInputTokens:2e5,maxOutputTokens:4096,roles:R,modalities:N,config:{def:h.base(4096,4).def,schema:h.base(4096,4).schema}}),An=T,De=class extends b{constructor(t){super($t,t);}};var D=[Y],V=zod.z.enum([Y]);var Gn=zod.z.object({object:zod.z.literal("list"),model:zod.z.string(),data:zod.z.array(zod.z.object({index:zod.z.number(),object:zod.z.literal("embedding"),embedding:zod.z.array(zod.z.number()).or(zod.z.string().base64())})),usage:zod.z.object({total_tokens:zod.z.number()})});var vs=zod.z.string().min(1).or(zod.z.array(zod.z.string().min(1)).min(1)),Kn=zod.z.object({model:zod.z.string().min(1).optional(),input:vs,encoding_format:zod.z.enum(["base64"]).nullable().optional(),input_type:zod.z.enum(["query","document"]).nullable().optional(),truncation:zod.z.boolean().optional()});var L=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string(),getEmbeddingsUrl:zod.z.string().url().optional()}),q=class{constructor(t,n){this.version="v1";let a=L.parse(n);this.modelSchema=t,this.modelName=a.modelName,this.apiKey=a.apiKey,this.baseUrl=ie(te.embeddingBaseUrl),this.getEmbeddingsUrl=ie(a.getEmbeddingsUrl||`${this.baseUrl}/embeddings`);}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"}}getDefaultParams(){return {model:this.modelName}}getTokenCount(t){return t.requests.reduce((n,a)=>n+a.length,0)}getRetryDelay(t){return {shouldRetry:!0,delayMs:0}}transformModelRequest(t){let n=Kn.safeParse(t);if(!n.success)throw new me({info:"Invalid model request",cause:n.error});let a=n.data,i=a.model,p={encodingFormat:a.encoding_format,inputType:a.input_type,truncation:a.truncation},d=fe().parse(Ce(p)),c;return typeof a.input=="string"?c={modality:Y,requests:[a.input]}:c={modality:Y,requests:a.input},{modelName:i,config:d,embeddingRequests:c}}transformConfig(t,n){"inputType"in t&&t.inputType===""&&delete t.inputType,"encodingFormat"in t&&t.encodingFormat===""&&delete t.encodingFormat;let a=this.modelSchema.config.schema.safeParse(t);if(!a.success)throw new W({info:`Invalid config for model : '${this.modelName}'`,cause:a.error});let i=a.data;return Object.keys(i).forEach(d=>{if(!this.modelSchema.config.def[d])throw new W({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${d}',
14
+ available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})}),Object.keys(i).reduce((d,c)=>{let g=this.modelSchema.config.def[c].param,u=i[c];return d[g]=u,d},{})}transformEmbeddingRequests(t){let n=wo().safeParse(t);if(!n.success)throw new ut({info:"Invalid embedding requests",cause:n.error});if(n.data.requests.length>128)throw new ut({info:`Invalid embedding requests for model : '${this.modelName}'`,cause:new Error(`Max requests for model : '${this.modelName}' is 128`)});return {input:n.data.requests}}getGetEmbeddingsUrl(t,n){return w(this,null,function*(){return new Promise(a=>{a(this.getEmbeddingsUrl);})})}getGetEmbeddingsHeaders(t,n){return w(this,null,function*(){return new Promise(a=>{a(this.getDefaultHeaders());})})}getGetEmbeddingsData(t,n){return w(this,null,function*(){return new Promise(a=>{a(f(f(f({},this.getDefaultParams()),this.transformConfig(t,n)),this.transformEmbeddingRequests(n)));})})}transformGetEmbeddingsResponse(t){let n,a=Gn.safeParse(t);if(a.success){let i=a.data;n=typeof i.data[0].embedding=="string"?lt:rt;let p=i.data.map(d=>typeof d.embedding=="string"?{index:d.index,embedding:d.embedding}:{index:d.index,embedding:d.embedding});return {encodingFormat:n,embeddings:p,usage:{totalTokens:i.usage.total_tokens}}}throw new F({info:"Invalid response from model",cause:a.error})}};var Ft="voyage-code-2",xs="Optimized for code retrieval.",Ht=B(V).parse({name:Ft,description:xs,modalities:D,maxInputTokens:16e3,maxOutputTokens:16e3,config:{def:O.base().def,schema:O.base().schema}}),Pn=L,Ve=class extends q{constructor(t){super(Ht,t);}};var Gt="voyage-law-2",Es="Optimized for legal and long-context retrieval and RAG. Also improved performance across all domains.",Kt=B(V).parse({name:Gt,description:Es,modalities:D,maxInputTokens:16e3,maxOutputTokens:16e3,config:{def:O.base().def,schema:O.base().schema}}),wn=L,$e=class extends q{constructor(t){super(Kt,t);}};var Jt="voyage-multilingual-2",Os="Optimized for multilingual retrieval and RAG.",Wt=B(V).parse({name:Jt,description:Os,modalities:D,maxInputTokens:32e3,maxOutputTokens:32e3,config:{def:O.base().def,schema:O.base().schema}}),qn=L,Fe=class extends q{constructor(t){super(Wt,t);}};var Zt="voyage-finance-2",_s="Optimized for finance retrieval and RAG.",Xt=B(V).parse({name:Zt,description:_s,modalities:D,maxInputTokens:32e3,maxOutputTokens:32e3,config:{def:O.base().def,schema:O.base().schema}}),jn=L,He=class extends q{constructor(t){super(Xt,t);}};var Qt="voyage-3-lite",As="Optimized for latency and cost.",Yt=B(V).parse({name:Qt,description:As,modalities:D,maxInputTokens:32e3,maxOutputTokens:32e3,config:{def:O.base().def,schema:O.base().schema}}),In=L,Ge=class extends q{constructor(t){super(Yt,t);}};var eo="voyage-3",Ps="Optimized for quality.",to=B(V).parse({name:eo,description:Ps,modalities:D,maxInputTokens:32e3,maxOutputTokens:32e3,config:{def:O.base().def,schema:O.base().schema}}),Ln=L,Ke=class extends q{constructor(t){super(to,t);}};
15
15
 
16
16
  exports.Anthropic = te;
17
17
  exports.AnthropicChatModelConfigs = h;
18
- exports.AnthropicChatModelModalities = U;
18
+ exports.AnthropicChatModelModalities = N;
19
19
  exports.AnthropicChatModelModalitiesEnum = z;
20
20
  exports.AnthropicChatModelRoles = M;
21
- exports.AnthropicChatModelRolesMap = k;
22
- exports.AnthropicCompleteChatMcpToolResultResponse = wa;
23
- exports.AnthropicCompleteChatMcpToolUseResponse = Pa;
24
- exports.AnthropicCompleteChatResponse = wn;
25
- exports.AnthropicEmbeddingModelConfigs = E;
21
+ exports.AnthropicChatModelRolesMap = R;
22
+ exports.AnthropicCompleteChatMcpToolResultResponse = Gi;
23
+ exports.AnthropicCompleteChatMcpToolUseResponse = Hi;
24
+ exports.AnthropicCompleteChatResponse = Bn;
25
+ exports.AnthropicEmbeddingModelConfigs = O;
26
26
  exports.AnthropicEmbeddingModelModalities = D;
27
27
  exports.AnthropicEmbeddingModelModalitiesEnum = V;
28
- exports.AnthropicEmbeddingRequest = Dn;
29
- exports.AnthropicEmbeddingRequestInput = ms;
30
- exports.AnthropicGetEmbeddingsResponse = zn;
31
- exports.AnthropicRequest = Un;
32
- exports.AnthropicRequestAssistantMessage = Xa;
33
- exports.AnthropicRequestImageContent = Bn;
34
- exports.AnthropicRequestMcpServer = Za;
35
- exports.AnthropicRequestMcpServerToolConfiguration = Ja;
36
- exports.AnthropicRequestMcpToolResultContent = kr;
37
- exports.AnthropicRequestMcpToolUseContent = Mr;
38
- exports.AnthropicRequestMessage = Ya;
39
- exports.AnthropicRequestRedactedThinkingContent = Fa;
28
+ exports.AnthropicEmbeddingRequest = Kn;
29
+ exports.AnthropicEmbeddingRequestInput = vs;
30
+ exports.AnthropicGetEmbeddingsResponse = Gn;
31
+ exports.AnthropicRequest = Hn;
32
+ exports.AnthropicRequestAssistantMessage = ms;
33
+ exports.AnthropicRequestImageContent = $n;
34
+ exports.AnthropicRequestMcpServer = ds;
35
+ exports.AnthropicRequestMcpServerToolConfiguration = ls;
36
+ exports.AnthropicRequestMcpToolResultContent = Lr;
37
+ exports.AnthropicRequestMcpToolUseContent = Ir;
38
+ exports.AnthropicRequestMessage = cs;
39
+ exports.AnthropicRequestRedactedThinkingContent = as;
40
40
  exports.AnthropicRequestTextContent = oo;
41
- exports.AnthropicRequestThinkingContent = $a;
42
- exports.AnthropicRequestTool = Ha;
43
- exports.AnthropicRequestToolCallContent = br;
44
- exports.AnthropicRequestToolChoiceEnum = Ga;
45
- exports.AnthropicRequestToolChoiceTool = Ka;
46
- exports.AnthropicRequestToolResponseContent = Nn;
47
- exports.AnthropicRequestUserMessage = Wa;
48
- exports.AnthropicStreamChatContentBlockDeltaResponse = Ln;
49
- exports.AnthropicStreamChatContentBlockStartMcpToolResultResponse = Na;
50
- exports.AnthropicStreamChatContentBlockStartMcpToolUseResponse = Ba;
51
- exports.AnthropicStreamChatContentBlockStartResponse = In;
52
- exports.AnthropicStreamChatMessageDeltaResponse = jn;
53
- exports.AnthropicStreamChatMessageStartResponse = qn;
54
- exports.AnthropicThinkingChatModelModalities = W;
41
+ exports.AnthropicRequestThinkingContent = ns;
42
+ exports.AnthropicRequestTool = is;
43
+ exports.AnthropicRequestToolCallContent = jr;
44
+ exports.AnthropicRequestToolChoiceEnum = ss;
45
+ exports.AnthropicRequestToolChoiceTool = rs;
46
+ exports.AnthropicRequestToolResponseContent = Fn;
47
+ exports.AnthropicRequestUserMessage = ps;
48
+ exports.AnthropicStreamChatContentBlockDeltaResponse = Vn;
49
+ exports.AnthropicStreamChatContentBlockStartMcpToolResultResponse = Qi;
50
+ exports.AnthropicStreamChatContentBlockStartMcpToolUseResponse = Xi;
51
+ exports.AnthropicStreamChatContentBlockStartResponse = Dn;
52
+ exports.AnthropicStreamChatMessageDeltaResponse = zn;
53
+ exports.AnthropicStreamChatMessageStartResponse = Nn;
54
+ exports.AnthropicThinkingChatModelModalities = Z;
55
55
  exports.AnthropicThinkingChatModelModalitiesEnum = X;
56
- exports.BaseChatModel = T;
57
- exports.BaseChatModelOptions = C;
56
+ exports.BaseChatModel = b;
57
+ exports.BaseChatModelOptions = T;
58
58
  exports.BaseEmbeddingModel = q;
59
59
  exports.BaseEmbeddingModelOptions = L;
60
- exports.ChatModelBaseConfigDef = ke;
60
+ exports.ChatModelBaseConfigDef = Re;
61
61
  exports.ChatModelBaseConfigSchema = Me;
62
- exports.ChatModelReasoningConfigDef = pn;
63
- exports.ChatModelReasoningConfigSchema = mn;
64
- exports.Claude3Haiku20240307 = Be;
65
- exports.Claude3Haiku20240307Literal = Bt;
66
- exports.Claude3Haiku20240307Options = Mn;
67
- exports.Claude3Haiku20240307Schema = Nt;
62
+ exports.ChatModelReasoningConfigDef = yn;
63
+ exports.ChatModelReasoningConfigSchema = fn;
64
+ exports.Claude3Haiku20240307 = Ue;
65
+ exports.Claude3Haiku20240307Literal = Ut;
66
+ exports.Claude3Haiku20240307Options = En;
67
+ exports.Claude3Haiku20240307Schema = Bt;
68
68
  exports.Claude3Opus20240229 = ze;
69
69
  exports.Claude3Opus20240229Literal = zt;
70
- exports.Claude3Opus20240229Options = Rn;
70
+ exports.Claude3Opus20240229Options = _n;
71
71
  exports.Claude3Opus20240229Schema = Dt;
72
72
  exports.Claude3Sonnet20240229 = De;
73
73
  exports.Claude3Sonnet20240229Literal = Vt;
74
- exports.Claude3Sonnet20240229Options = Sn;
74
+ exports.Claude3Sonnet20240229Options = An;
75
75
  exports.Claude3Sonnet20240229Schema = $t;
76
- exports.Claude3_5Haiku20241022 = Ue;
77
- exports.Claude3_5Haiku20241022Literal = Ne;
78
- exports.Claude3_5Haiku20241022Options = kn;
79
- exports.Claude3_5Haiku20241022Schema = Ut;
76
+ exports.Claude3_5Haiku20241022 = Ne;
77
+ exports.Claude3_5Haiku20241022Literal = Be;
78
+ exports.Claude3_5Haiku20241022Options = On;
79
+ exports.Claude3_5Haiku20241022Schema = Nt;
80
80
  exports.Claude3_5Sonnet20240620 = we;
81
81
  exports.Claude3_5Sonnet20240620Literal = Pe;
82
- exports.Claude3_5Sonnet20240620Options = Tn;
82
+ exports.Claude3_5Sonnet20240620Options = Sn;
83
83
  exports.Claude3_5Sonnet20240620Schema = jt;
84
84
  exports.Claude3_5Sonnet20241022 = je;
85
85
  exports.Claude3_5Sonnet20241022Literal = qe;
86
- exports.Claude3_5Sonnet20241022Options = Cn;
86
+ exports.Claude3_5Sonnet20241022Options = vn;
87
87
  exports.Claude3_5Sonnet20241022Schema = It;
88
88
  exports.Claude3_7Sonnet20250219 = Le;
89
89
  exports.Claude3_7Sonnet20250219Literal = Ie;
90
- exports.Claude3_7Sonnet20250219Options = bn;
90
+ exports.Claude3_7Sonnet20250219Options = xn;
91
91
  exports.Claude3_7Sonnet20250219Schema = Lt;
92
92
  exports.Claude4Opus20250514 = Se;
93
- exports.Claude4Opus20250514Literal = Re;
94
- exports.Claude4Opus20250514Options = gn;
93
+ exports.Claude4Opus20250514Literal = ke;
94
+ exports.Claude4Opus20250514Options = Cn;
95
95
  exports.Claude4Opus20250514Schema = At;
96
- exports.Claude4Sonnet20250514 = ve;
97
- exports.Claude4Sonnet20250514Literal = xe;
98
- exports.Claude4Sonnet20250514Options = hn;
96
+ exports.Claude4Sonnet20250514 = xe;
97
+ exports.Claude4Sonnet20250514Literal = ve;
98
+ exports.Claude4Sonnet20250514Options = Mn;
99
99
  exports.Claude4Sonnet20250514Schema = Pt;
100
- exports.ClaudeOpus4_520251101 = Ee;
101
- exports.ClaudeOpus4_520251101Literal = Oe;
102
- exports.ClaudeOpus4_520251101Options = yn;
100
+ exports.ClaudeOpus4_520251101 = Oe;
101
+ exports.ClaudeOpus4_520251101Literal = Ee;
102
+ exports.ClaudeOpus4_520251101Options = Rn;
103
103
  exports.ClaudeOpus4_520251101Schema = wt;
104
104
  exports.ClaudeSonnet4_520250929 = Ae;
105
105
  exports.ClaudeSonnet4_520250929Literal = _e;
106
- exports.ClaudeSonnet4_520250929Options = fn;
106
+ exports.ClaudeSonnet4_520250929Options = kn;
107
107
  exports.ClaudeSonnet4_520250929Schema = qt;
108
- exports.EmbeddingModelBaseConfigDef = un;
109
- exports.EmbeddingModelBaseConfigSchema = cn;
110
- exports.ProviderLiteral = Sa;
108
+ exports.EmbeddingModelBaseConfigDef = Tn;
109
+ exports.EmbeddingModelBaseConfigSchema = bn;
110
+ exports.ProviderLiteral = Bi;
111
111
  exports.Voyage3 = Ke;
112
112
  exports.Voyage3Lite = Ge;
113
- exports.Voyage3LiteLiteral = Yt;
114
- exports.Voyage3LiteOptions = _n;
115
- exports.Voyage3LiteSchema = Qt;
113
+ exports.Voyage3LiteLiteral = Qt;
114
+ exports.Voyage3LiteOptions = In;
115
+ exports.Voyage3LiteSchema = Yt;
116
116
  exports.Voyage3Literal = eo;
117
- exports.Voyage3Options = An;
117
+ exports.Voyage3Options = Ln;
118
118
  exports.Voyage3Schema = to;
119
119
  exports.VoyageCode2 = Ve;
120
120
  exports.VoyageCode2Literal = Ft;
121
- exports.VoyageCode2Options = xn;
121
+ exports.VoyageCode2Options = Pn;
122
122
  exports.VoyageCode2Schema = Ht;
123
123
  exports.VoyageFinance2 = He;
124
- exports.VoyageFinance2Literal = Wt;
125
- exports.VoyageFinance2Options = En;
124
+ exports.VoyageFinance2Literal = Zt;
125
+ exports.VoyageFinance2Options = jn;
126
126
  exports.VoyageFinance2Schema = Xt;
127
127
  exports.VoyageLaw2 = $e;
128
128
  exports.VoyageLaw2Literal = Gt;
129
- exports.VoyageLaw2Options = vn;
129
+ exports.VoyageLaw2Options = wn;
130
130
  exports.VoyageLaw2Schema = Kt;
131
131
  exports.VoyageMultilingual2 = Fe;
132
132
  exports.VoyageMultilingual2Literal = Jt;
133
- exports.VoyageMultilingual2Options = On;
134
- exports.VoyageMultilingual2Schema = Zt;
135
- exports.encodingFormat = Ot;
136
- exports.inputType = Et;
137
- exports.maxTokens = bt;
138
- exports.mcp = xt;
139
- exports.mcpServers = vt;
133
+ exports.VoyageMultilingual2Options = qn;
134
+ exports.VoyageMultilingual2Schema = Wt;
135
+ exports.encodingFormat = Et;
136
+ exports.inputType = Ot;
137
+ exports.maxTokens = Ct;
138
+ exports.mcp = vt;
139
+ exports.mcpServers = xt;
140
140
  exports.stop = Mt;
141
- exports.temperature = Ct;
141
+ exports.temperature = Tt;
142
142
  exports.toolChoice = St;
143
- exports.topK = Rt;
144
- exports.topP = kt;
143
+ exports.topK = kt;
144
+ exports.topP = Rt;
145
145
  exports.truncation = _t;
146
146
  //# sourceMappingURL=index.js.map
147
147
  //# sourceMappingURL=index.js.map